mirror of
https://github.com/openharmony/third_party_tinyalsa.git
synced 2026-07-01 20:14:06 -04:00
tinyalsa adapter rk3568
Signed-off-by: zhao_haipeng <zhao_haipeng@hoperun.com>
This commit is contained in:
@@ -0,0 +1,108 @@
|
|||||||
|
#Copyright (C) 2021 HiHope Open Source Organization .
|
||||||
|
#Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
#you may not use this file except in compliance with the License.
|
||||||
|
#You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
#Unless required by applicable law or agreed to in writing, software
|
||||||
|
#distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
#See the License for the specific language governing permissions and
|
||||||
|
#limitations under the License.
|
||||||
|
|
||||||
|
import("//build/ohos.gni")
|
||||||
|
import("//build/ohos/ndk/ndk.gni")
|
||||||
|
|
||||||
|
config("libtinyalsa_config") {
|
||||||
|
include_dirs = [
|
||||||
|
"include",
|
||||||
|
"include/tinyalsa",
|
||||||
|
]
|
||||||
|
cflags = [
|
||||||
|
"-Wno-incompatible-pointer-types",
|
||||||
|
"-Werror",
|
||||||
|
"-Wimplicit-function-declaration",
|
||||||
|
"-Wno-error=unused-variable",
|
||||||
|
"-Wno-macro-redefined",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
ohos_shared_library("libtinyalsa") {
|
||||||
|
sources = [
|
||||||
|
"src/mixer.c",
|
||||||
|
"src/mixer_hw.c",
|
||||||
|
"src/mixer_plugin.c",
|
||||||
|
"src/pcm.c",
|
||||||
|
"src/pcm_hw.c",
|
||||||
|
"src/pcm_plugin.c",
|
||||||
|
"src/snd_card_plugin.c",
|
||||||
|
]
|
||||||
|
|
||||||
|
install_images = [
|
||||||
|
"system",
|
||||||
|
"updater",
|
||||||
|
]
|
||||||
|
install_enable = true
|
||||||
|
configs = [ ":libtinyalsa_config" ]
|
||||||
|
|
||||||
|
subsystem_name = "hdf"
|
||||||
|
}
|
||||||
|
|
||||||
|
#ohos_executable("tinycap") {
|
||||||
|
#
|
||||||
|
# sources = [
|
||||||
|
# "tinycap.c",
|
||||||
|
# ]
|
||||||
|
#
|
||||||
|
# configs = [ ":libtinyalsa_config" ]
|
||||||
|
# deps = [
|
||||||
|
# ":libtinyalsa",
|
||||||
|
# ]
|
||||||
|
#
|
||||||
|
# install_images = [
|
||||||
|
# "system",
|
||||||
|
# "updater",
|
||||||
|
# ]
|
||||||
|
# install_enable = true
|
||||||
|
#
|
||||||
|
# subsystem_name = "hdf"
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
#ohos_executable("tinyplay") {
|
||||||
|
# sources = [
|
||||||
|
# "tinyplay.c",
|
||||||
|
# ]
|
||||||
|
#
|
||||||
|
# configs = [ ":libtinyalsa_config" ]
|
||||||
|
# deps = [
|
||||||
|
# ":libtinyalsa",
|
||||||
|
# ]
|
||||||
|
#
|
||||||
|
# install_images = [
|
||||||
|
# "system",
|
||||||
|
# "updater",
|
||||||
|
# ]
|
||||||
|
# install_enable = true
|
||||||
|
#
|
||||||
|
# subsystem_name = "hdf"
|
||||||
|
#}
|
||||||
|
#
|
||||||
|
#ohos_executable("tinymix") {
|
||||||
|
# sources = [
|
||||||
|
# "tinymix.c",
|
||||||
|
# ]
|
||||||
|
#
|
||||||
|
# configs = [ ":libtinyalsa_config" ]
|
||||||
|
# deps = [
|
||||||
|
# ":libtinyalsa",
|
||||||
|
# ]
|
||||||
|
# install_enable = true
|
||||||
|
#
|
||||||
|
# install_images = [
|
||||||
|
# "system",
|
||||||
|
# "updater",
|
||||||
|
# ]
|
||||||
|
#
|
||||||
|
# subsystem_name = "hdf"
|
||||||
|
#}
|
||||||
@@ -327,13 +327,13 @@ int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, struct timespec *ts
|
|||||||
|
|
||||||
unsigned int pcm_get_subdevice(const struct pcm *pcm);
|
unsigned int pcm_get_subdevice(const struct pcm *pcm);
|
||||||
|
|
||||||
int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count) TINYALSA_WARN_UNUSED_RESULT;
|
int pcm_writei(struct pcm *pcm, const void *data, unsigned int frame_count);
|
||||||
|
|
||||||
int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count) TINYALSA_WARN_UNUSED_RESULT;
|
int pcm_readi(struct pcm *pcm, void *data, unsigned int frame_count);
|
||||||
|
|
||||||
int pcm_write(struct pcm *pcm, const void *data, unsigned int count) TINYALSA_DEPRECATED;
|
int pcm_write(struct pcm *pcm, const void *data, unsigned int count);
|
||||||
|
|
||||||
int pcm_read(struct pcm *pcm, void *data, unsigned int count) TINYALSA_DEPRECATED;
|
int pcm_read(struct pcm *pcm, void *data, unsigned int count);
|
||||||
|
|
||||||
int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count) TINYALSA_DEPRECATED;
|
int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count) TINYALSA_DEPRECATED;
|
||||||
|
|
||||||
|
|||||||
+12
@@ -62,6 +62,18 @@
|
|||||||
|
|
||||||
#include "mixer_io.h"
|
#include "mixer_io.h"
|
||||||
|
|
||||||
|
#ifndef INT_MAX
|
||||||
|
#define INT_MAX 2147483647
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UINT_MAX
|
||||||
|
#define UINT_MAX 4294967295UL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ULONG_MAX
|
||||||
|
#define ULONG_MAX 4294967295UL
|
||||||
|
#endif
|
||||||
|
|
||||||
/** A mixer control.
|
/** A mixer control.
|
||||||
* @ingroup libtinyalsa-mixer
|
* @ingroup libtinyalsa-mixer
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -82,6 +82,18 @@
|
|||||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef INT_MAX
|
||||||
|
#define INT_MAX 2147483647
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef UINT_MAX
|
||||||
|
#define UINT_MAX 4294967295UL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ULONG_MAX
|
||||||
|
#define ULONG_MAX 4294967295UL
|
||||||
|
#endif
|
||||||
|
|
||||||
/* refer to SNDRV_PCM_ACCESS_##index in sound/asound.h. */
|
/* refer to SNDRV_PCM_ACCESS_##index in sound/asound.h. */
|
||||||
static const char * const access_lookup[] = {
|
static const char * const access_lookup[] = {
|
||||||
"MMAP_INTERLEAVED",
|
"MMAP_INTERLEAVED",
|
||||||
@@ -616,6 +628,16 @@ static int pcm_sync_ptr(struct pcm *pcm, int flags)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pcm_state(struct pcm *pcm)
|
||||||
|
{
|
||||||
|
// Update the state only. Do not sync HW sync.
|
||||||
|
int err = pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_APPL | SNDRV_PCM_SYNC_PTR_AVAIL_MIN);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
return pcm->mmap_status->state;
|
||||||
|
}
|
||||||
|
|
||||||
static int pcm_hw_mmap_status(struct pcm *pcm)
|
static int pcm_hw_mmap_status(struct pcm *pcm)
|
||||||
{
|
{
|
||||||
if (pcm->sync_ptr)
|
if (pcm->sync_ptr)
|
||||||
@@ -1189,6 +1211,10 @@ int pcm_prepare(struct pcm *pcm)
|
|||||||
*/
|
*/
|
||||||
int pcm_start(struct pcm *pcm)
|
int pcm_start(struct pcm *pcm)
|
||||||
{
|
{
|
||||||
|
if (pcm_state(pcm) == PCM_STATE_SETUP && pcm_prepare(pcm) != 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* set appl_ptr and avail_min in kernel */
|
/* set appl_ptr and avail_min in kernel */
|
||||||
if (pcm_sync_ptr(pcm, 0) < 0)
|
if (pcm_sync_ptr(pcm, 0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1402,15 +1428,6 @@ again:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pcm_state(struct pcm *pcm)
|
|
||||||
{
|
|
||||||
int err = pcm_sync_ptr(pcm, 0);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
return pcm->mmap_status->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Waits for frames to be available for read or write operations.
|
/** Waits for frames to be available for read or write operations.
|
||||||
* @param pcm A PCM handle.
|
* @param pcm A PCM handle.
|
||||||
* @param timeout The maximum amount of time to wait for, in terms of milliseconds.
|
* @param timeout The maximum amount of time to wait for, in terms of milliseconds.
|
||||||
|
|||||||
Reference in New Issue
Block a user