1 /*
2 * Copyright (c) 2019-2025 Allwinner Technology Co., Ltd. ALL rights reserved.
3 *
4 * Allwinner is a trademark of Allwinner Technology Co.,Ltd., registered in
5 * the the people's Republic of China and other countries.
6 * All Allwinner Technology Co.,Ltd. trademarks are used with permission.
7 *
8 * DISCLAIMER
9 * THIRD PARTY LICENCES MAY BE REQUIRED TO IMPLEMENT THE SOLUTION/PRODUCT.
10 * IF YOU NEED TO INTEGRATE THIRD PARTY’S TECHNOLOGY (SONY, DTS, DOLBY, AVS OR MPEGLA, ETC.)
11 * IN ALLWINNERS’SDK OR PRODUCTS, YOU SHALL BE SOLELY RESPONSIBLE TO OBTAIN
12 * ALL APPROPRIATELY REQUIRED THIRD PARTY LICENCES.
13 * ALLWINNER SHALL HAVE NO WARRANTY, INDEMNITY OR OTHER OBLIGATIONS WITH RESPECT TO MATTERS
14 * COVERED UNDER ANY REQUIRED THIRD PARTY LICENSE.
15 * YOU ARE SOLELY RESPONSIBLE FOR YOUR USAGE OF THIRD PARTY’S TECHNOLOGY.
16 *
17 *
18 * THIS SOFTWARE IS PROVIDED BY ALLWINNER"AS IS" AND TO THE MAXIMUM EXTENT
19 * PERMITTED BY LAW, ALLWINNER EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND,
20 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION REGARDING
21 * THE TITLE, NON-INFRINGEMENT, ACCURACY, CONDITION, COMPLETENESS, PERFORMANCE
22 * OR MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 * IN NO EVENT SHALL ALLWINNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS, OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30 * OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <string.h>
34 #include <aw-alsa-lib/pcm_config.h>
35
36 int _snd_pcm_hw_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
37 snd_pcm_stream_t stream, int mode);
38 int _snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
39 snd_pcm_stream_t stream, int mode);
40 int _snd_pcm_dmix_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
41 snd_pcm_stream_t stream, int mode);
42 int _snd_pcm_asym_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
43 snd_pcm_stream_t stream, int mode);
44 int _snd_pcm_route_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
45 snd_pcm_stream_t stream, int mode);
46 int _snd_pcm_softvol_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
47 snd_pcm_stream_t stream, int mode);
48 int _snd_pcm_rate_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
49 snd_pcm_stream_t stream, int mode);
50 int _snd_pcm_plug_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
51 snd_pcm_stream_t stream, int mode);
52 int _snd_pcm_file_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
53 snd_pcm_stream_t stream, int mode);
54 int _snd_pcm_multi_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
55 snd_pcm_stream_t stream, int mode);
56
57 #ifdef CONFIG_AW_ALSA_PLUGINS_SONA_AUDIOAEF
58 int _snd_pcm_sona_audioaef_open(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
59 snd_pcm_stream_t stream, int mode);
60 #endif
61
62 static _snd_pcm_open_func_t _snd_pcm_open_funcs[] = {
63 { "hw", _snd_pcm_hw_open },
64 { "dsnoop", _snd_pcm_dsnoop_open },
65 { "dmix", _snd_pcm_dmix_open },
66 { "asym", _snd_pcm_asym_open },
67 { "softvol", _snd_pcm_softvol_open },
68 { "route", _snd_pcm_route_open },
69 { "rate", _snd_pcm_rate_open },
70 { "plug", _snd_pcm_plug_open },
71 { "file", _snd_pcm_file_open },
72 { "multi", _snd_pcm_multi_open },
73 #ifdef CONFIG_AW_ALSA_PLUGINS_SONA_AUDIOAEF
74 { "sona_audioaef", _snd_pcm_sona_audioaef_open },
75 #endif
76 };
77
snd_pcm_config_get_config(const char * name)78 const snd_pcm_config_t *snd_pcm_config_get_config(const char *name)
79 {
80 const snd_pcm_config_t *pcm_config = NULL;
81 size_t i;
82 for (i = 0; i < _snd_pcm_global_configs_size; ++i) {
83 if (0 == strcmp(name, _snd_pcm_global_configs[i].name)) {
84 pcm_config = &(_snd_pcm_global_configs[i]);
85 break;
86 }
87 }
88 return pcm_config;
89 }
90
snd_pcm_config_get_open_func(const char * type)91 snd_pcm_open_func_t snd_pcm_config_get_open_func(const char *type)
92 {
93 snd_pcm_open_func_t open_func = NULL;
94 size_t size = sizeof(_snd_pcm_open_funcs) / sizeof(_snd_pcm_open_funcs[0]);
95 size_t i;
96 for (i = 0; i < size; ++i) {
97 if (0 == strcmp(type, _snd_pcm_open_funcs[i].type)) {
98 open_func = _snd_pcm_open_funcs[i].func;
99 break;
100 }
101 }
102 return open_func;
103 }
104