]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/sound/soc-topology.h
ASoC: topology: Add FE DAIs dynamically
[mirror_ubuntu-bionic-kernel.git] / include / sound / soc-topology.h
CommitLineData
8a978234
LG
1/*
2 * linux/sound/soc-topology.h -- ALSA SoC Firmware Controls and DAPM
3 *
4 * Copyright (C) 2012 Texas Instruments Inc.
5 * Copyright (C) 2015 Intel Corporation.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * Simple file API to load FW that includes mixers, coefficients, DAPM graphs,
12 * algorithms, equalisers, DAIs, widgets, FE caps, BE caps, codec link caps etc.
13 */
14
15#ifndef __LINUX_SND_SOC_TPLG_H
16#define __LINUX_SND_SOC_TPLG_H
17
18#include <sound/asoc.h>
19#include <linux/list.h>
20
21struct firmware;
22struct snd_kcontrol;
23struct snd_soc_tplg_pcm_be;
24struct snd_ctl_elem_value;
25struct snd_ctl_elem_info;
26struct snd_soc_dapm_widget;
27struct snd_soc_component;
28struct snd_soc_tplg_pcm_fe;
29struct snd_soc_dapm_context;
30struct snd_soc_card;
31
32/* object scan be loaded and unloaded in groups with identfying indexes */
33#define SND_SOC_TPLG_INDEX_ALL 0 /* ID that matches all FW objects */
34
35/* dynamic object type */
36enum snd_soc_dobj_type {
37 SND_SOC_DOBJ_NONE = 0, /* object is not dynamic */
38 SND_SOC_DOBJ_MIXER,
39 SND_SOC_DOBJ_ENUM,
40 SND_SOC_DOBJ_BYTES,
41 SND_SOC_DOBJ_PCM,
42 SND_SOC_DOBJ_DAI_LINK,
43 SND_SOC_DOBJ_CODEC_LINK,
44 SND_SOC_DOBJ_WIDGET,
45};
46
47/* dynamic control object */
48struct snd_soc_dobj_control {
49 struct snd_kcontrol *kcontrol;
50 char **dtexts;
51 unsigned long *dvalues;
52};
53
54/* dynamic widget object */
55struct snd_soc_dobj_widget {
56 unsigned int kcontrol_enum:1; /* this widget is an enum kcontrol */
57};
58
8a978234
LG
59/* generic dynamic object - all dynamic objects belong to this struct */
60struct snd_soc_dobj {
61 enum snd_soc_dobj_type type;
62 unsigned int index; /* objects can belong in different groups */
63 struct list_head list;
64 struct snd_soc_tplg_ops *ops;
65 union {
66 struct snd_soc_dobj_control control;
67 struct snd_soc_dobj_widget widget;
8a978234
LG
68 };
69 void *private; /* core does not touch this */
70};
71
72/*
73 * Kcontrol operations - used to map handlers onto firmware based controls.
74 */
75struct snd_soc_tplg_kcontrol_ops {
76 u32 id;
77 int (*get)(struct snd_kcontrol *kcontrol,
78 struct snd_ctl_elem_value *ucontrol);
79 int (*put)(struct snd_kcontrol *kcontrol,
80 struct snd_ctl_elem_value *ucontrol);
81 int (*info)(struct snd_kcontrol *kcontrol,
82 struct snd_ctl_elem_info *uinfo);
83};
84
1a3232d2
ML
85/* Bytes ext operations, for TLV byte controls */
86struct snd_soc_tplg_bytes_ext_ops {
87 u32 id;
a1e5e7e9
M
88 int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
89 unsigned int size);
90 int (*put)(struct snd_kcontrol *kcontrol,
91 const unsigned int __user *bytes, unsigned int size);
1a3232d2
ML
92};
93
8a978234
LG
94/*
95 * DAPM widget event handlers - used to map handlers onto widgets.
96 */
97struct snd_soc_tplg_widget_events {
98 u16 type;
99 int (*event_handler)(struct snd_soc_dapm_widget *w,
100 struct snd_kcontrol *k, int event);
101};
102
103/*
104 * Public API - Used by component drivers to load and unload dynamic objects
105 * and their resources.
106 */
107struct snd_soc_tplg_ops {
108
109 /* external kcontrol init - used for any driver specific init */
110 int (*control_load)(struct snd_soc_component *,
111 struct snd_kcontrol_new *, struct snd_soc_tplg_ctl_hdr *);
112 int (*control_unload)(struct snd_soc_component *,
113 struct snd_soc_dobj *);
114
115 /* external widget init - used for any driver specific init */
116 int (*widget_load)(struct snd_soc_component *,
117 struct snd_soc_dapm_widget *,
118 struct snd_soc_tplg_dapm_widget *);
119 int (*widget_unload)(struct snd_soc_component *,
120 struct snd_soc_dobj *);
121
64527e8a
ML
122 /* FE DAI - used for any driver specific init */
123 int (*dai_load)(struct snd_soc_component *,
124 struct snd_soc_dai_driver *dai_drv);
125 int (*dai_unload)(struct snd_soc_component *,
8a978234
LG
126 struct snd_soc_dobj *);
127
128 /* callback to handle vendor bespoke data */
129 int (*vendor_load)(struct snd_soc_component *,
130 struct snd_soc_tplg_hdr *);
131 int (*vendor_unload)(struct snd_soc_component *,
132 struct snd_soc_tplg_hdr *);
133
134 /* completion - called at completion of firmware loading */
135 void (*complete)(struct snd_soc_component *);
136
137 /* manifest - optional to inform component of manifest */
138 int (*manifest)(struct snd_soc_component *,
139 struct snd_soc_tplg_manifest *);
140
88a17d8f 141 /* vendor specific kcontrol handlers available for binding */
8a978234
LG
142 const struct snd_soc_tplg_kcontrol_ops *io_ops;
143 int io_ops_count;
1a3232d2
ML
144
145 /* vendor specific bytes ext handlers available for binding */
146 const struct snd_soc_tplg_bytes_ext_ops *bytes_ext_ops;
147 int bytes_ext_ops_count;
8a978234
LG
148};
149
78b50f39
MB
150#ifdef CONFIG_SND_SOC_TOPOLOGY
151
8a978234
LG
152/* gets a pointer to data from the firmware block header */
153static inline const void *snd_soc_tplg_get_data(struct snd_soc_tplg_hdr *hdr)
154{
155 const void *ptr = hdr;
156
157 return ptr + sizeof(*hdr);
158}
159
160/* Dynamic Object loading and removal for component drivers */
161int snd_soc_tplg_component_load(struct snd_soc_component *comp,
162 struct snd_soc_tplg_ops *ops, const struct firmware *fw,
163 u32 index);
164int snd_soc_tplg_component_remove(struct snd_soc_component *comp, u32 index);
165
166/* Widget removal - widgets also removed wth component API */
167void snd_soc_tplg_widget_remove(struct snd_soc_dapm_widget *w);
168void snd_soc_tplg_widget_remove_all(struct snd_soc_dapm_context *dapm,
169 u32 index);
170
171/* Binds event handlers to dynamic widgets */
172int snd_soc_tplg_widget_bind_event(struct snd_soc_dapm_widget *w,
173 const struct snd_soc_tplg_widget_events *events, int num_events,
174 u16 event_type);
175
78b50f39
MB
176#else
177
178static inline int snd_soc_tplg_component_remove(struct snd_soc_component *comp,
179 u32 index)
180{
181 return 0;
182}
183
184#endif
185
8a978234 186#endif