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 #ifndef __AW_ALSA_PCM_CONFIG_H
34 #define __AW_ALSA_PCM_CONFIG_H
35 
36 #include <stddef.h>
37 #include <aw-alsa-lib/pcm.h>
38 
39 typedef struct _snd_pcm_config {
40     const char *name;
41     const char *type;
42     void *config;
43 } snd_pcm_config_t;
44 
45 extern const snd_pcm_config_t *_snd_pcm_global_configs;
46 extern const size_t _snd_pcm_global_configs_size;
47 
48 #define SND_PCM_CONFIG(xname, xtype, xconfig) \
49 { \
50     .name = xname, \
51     .type = xtype, \
52     .config = (void *)xconfig, \
53 }
54 
55 #define REGISTER_SND_PCM_GLOBAL_CONFIGS(configs_array) \
56     const size_t _snd_pcm_global_configs_size = \
57         sizeof(configs_array) / sizeof(configs_array[0]); \
58     const snd_pcm_config_t *_snd_pcm_global_configs = configs_array;
59 
60 const snd_pcm_config_t *snd_pcm_config_get_config(const char *name);
61 
62 typedef int (*snd_pcm_open_func_t)(snd_pcm_t **pcmp, const snd_pcm_config_t *pcm_config,
63         snd_pcm_stream_t stream, int mode);
64 
65 typedef struct {
66     const char *type;
67     snd_pcm_open_func_t func;
68 } _snd_pcm_open_func_t;
69 
70 snd_pcm_open_func_t snd_pcm_config_get_open_func(const char *type);
71 
72 #endif /* __AW_ALSA_PCM_CONFIG_H */
73