2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2 of the License, or (at your option) any later version.
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 * Support for the verb/device/modifier core logic and API,
17 * command line tool and file parser was kindly sponsored by
18 * Texas Instruments Inc.
19 * Support for multiple active modifiers and devices,
20 * transition sequences, multiple client access and user defined use
21 * cases was kindly sponsored by Wolfson Microelectronics PLC.
23 * Copyright (C) 2008-2010 SlimLogic Ltd
24 * Copyright (C) 2010 Wolfson Microelectronics PLC
25 * Copyright (C) 2010 Texas Instruments Inc.
26 * Copyright (C) 2010 Red Hat Inc.
27 * Authors: Liam Girdwood <lrg@slimlogic.co.uk>
28 * Stefan Schmidt <stefan@slimlogic.co.uk>
29 * Justin Xu <justinx@slimlogic.co.uk>
30 * Jaroslav Kysela <perex@perex.cz>
43 #define SYNTAX_VERSION_MAX 4
45 #define MAX_CARD_SHORT_NAME 32
46 #define MAX_CARD_LONG_NAME 80
48 #define SEQUENCE_ELEMENT_TYPE_CDEV 1
49 #define SEQUENCE_ELEMENT_TYPE_CSET 2
50 #define SEQUENCE_ELEMENT_TYPE_SLEEP 3
51 #define SEQUENCE_ELEMENT_TYPE_EXEC 4
52 #define SEQUENCE_ELEMENT_TYPE_CSET_BIN_FILE 5
53 #define SEQUENCE_ELEMENT_TYPE_CSET_TLV 6
54 #define SEQUENCE_ELEMENT_TYPE_CMPT_SEQ 7
57 struct list_head list;
62 /* sequence of a component device */
63 struct component_sequence {
64 struct use_case_device *device; /* component device */
65 int enable; /* flag to choose enable or disable list of the device */
68 struct sequence_element {
69 struct list_head list;
72 long sleep; /* Sleep time in microseconds if sleep element, else 0 */
76 struct component_sequence cmpt_seq; /* component sequence */
81 * Transition sequences. i.e. transition between one verb, device, mod to another
83 struct transition_sequence {
84 struct list_head list;
86 struct list_head transition_list;
90 * Modifier Supported Devices.
98 struct dev_list_node {
99 struct list_head list;
104 enum dev_list_type type;
105 struct list_head list;
109 struct list_head list;
114 struct list_head list;
115 struct list_head dev_list;
117 snd_ctl_card_info_t *ctl_info;
121 struct ucm_dev_name {
122 struct list_head list;
128 * Describes a Use Case Modifier and it's enable and disable sequences.
129 * A use case verb can have N modifiers.
131 struct use_case_modifier {
132 struct list_head list;
133 struct list_head active_list;
138 /* modifier enable and disable sequences */
139 struct list_head enable_list;
140 struct list_head disable_list;
142 /* modifier transition list */
143 struct list_head transition_list;
145 /* list of devices supported or conflicting */
146 struct dev_list dev_list;
149 struct list_head value_list;
153 * Describes a Use Case Device and it's enable and disable sequences.
154 * A use case verb can have N devices.
156 struct use_case_device {
157 struct list_head list;
158 struct list_head active_list;
163 /* device enable and disable sequences */
164 struct list_head enable_list;
165 struct list_head disable_list;
167 /* device transition list */
168 struct list_head transition_list;
170 /* list of devices supported or conflicting */
171 struct dev_list dev_list;
174 struct list_head value_list;
178 * Describes a Use Case Verb and it's enable and disable sequences.
179 * A use case verb can have N devices and N modifiers.
181 struct use_case_verb {
182 struct list_head list;
184 unsigned int active: 1;
189 /* verb enable and disable sequences */
190 struct list_head enable_list;
191 struct list_head disable_list;
193 /* verb transition list */
194 struct list_head transition_list;
196 struct list_head device_list;
198 /* component device list */
199 struct list_head cmpt_device_list;
201 /* modifiers that can be used with this use case */
202 struct list_head modifier_list;
205 struct list_head value_list;
207 /* temporary modifications lists */
208 struct list_head rename_list;
209 struct list_head remove_list;
213 * Manages a sound card and all its use cases.
215 struct snd_use_case_mgr {
217 char *conf_file_name;
222 /* use case verb, devices and modifier configs parsed from files */
223 struct list_head verb_list;
225 /* force boot settings - sequence */
226 struct list_head fixedboot_list;
228 /* boot settings - sequence */
229 struct list_head boot_list;
231 /* default settings - sequence */
232 struct list_head default_list;
233 int default_list_executed;
235 /* default settings - value list */
236 struct list_head value_list;
239 struct use_case_verb *active_verb;
240 struct list_head active_devices;
241 struct list_head active_modifiers;
244 pthread_mutex_t mutex;
246 /* UCM internal variables defined in configuration files */
247 struct list_head variable_list;
249 /* list of opened control devices */
250 struct list_head ctl_list;
252 /* Components don't define cdev, the card device. When executing
253 * a sequence of a component device, ucm manager enters component
254 * domain and needs to provide cdev to the component. This cdev
255 * should be defined by the machine, parent of the component.
257 int in_component_domain;
261 #define uc_error SNDERR
264 #define uc_dbg SNDERR
266 #define uc_dbg(fmt, arg...) do { } while (0)
269 void uc_mgr_error(const char *fmt, ...);
270 void uc_mgr_stdout(const char *fmt, ...);
272 const char *uc_mgr_config_dir(int format);
273 int uc_mgr_config_load(int format, const char *file, snd_config_t **cfg);
274 int uc_mgr_config_load_file(snd_use_case_mgr_t *uc_mgr, const char *file, snd_config_t **cfg);
275 int uc_mgr_import_master_config(snd_use_case_mgr_t *uc_mgr);
276 int uc_mgr_scan_master_configs(const char **_list[]);
278 int uc_mgr_put_to_dev_list(struct dev_list *dev_list, const char *name);
279 int uc_mgr_remove_device(struct use_case_verb *verb, const char *name);
280 int uc_mgr_rename_device(struct use_case_verb *verb, const char *src,
283 void uc_mgr_free_dev_name_list(struct list_head *base);
284 void uc_mgr_free_sequence_element(struct sequence_element *seq);
285 void uc_mgr_free_transition_element(struct transition_sequence *seq);
286 void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr);
287 void uc_mgr_free(snd_use_case_mgr_t *uc_mgr);
289 int uc_mgr_open_ctl(snd_use_case_mgr_t *uc_mgr,
290 struct ctl_list **ctl_list,
294 struct ctl_list *uc_mgr_get_master_ctl(snd_use_case_mgr_t *uc_mgr);
295 struct ctl_list *uc_mgr_get_ctl_by_card(snd_use_case_mgr_t *uc_mgr, int card);
296 struct ctl_list *uc_mgr_get_ctl_by_name(snd_use_case_mgr_t *uc_mgr,
297 const char *name, int idx);
298 snd_ctl_t *uc_mgr_get_ctl(snd_use_case_mgr_t *uc_mgr);
299 void uc_mgr_free_ctl_list(snd_use_case_mgr_t *uc_mgr);
301 int uc_mgr_add_value(struct list_head *base, const char *key, char *val);
303 const char *uc_mgr_get_variable(snd_use_case_mgr_t *uc_mgr,
306 int uc_mgr_set_variable(snd_use_case_mgr_t *uc_mgr,
310 int uc_mgr_get_substituted_value(snd_use_case_mgr_t *uc_mgr,
314 int uc_mgr_substitute_tree(snd_use_case_mgr_t *uc_mgr,
317 int uc_mgr_config_tree_merge(snd_use_case_mgr_t *uc_mgr,
318 snd_config_t *parent, snd_config_t *new_ctx,
319 snd_config_t *before, snd_config_t *after);
321 int uc_mgr_evaluate_inplace(snd_use_case_mgr_t *uc_mgr,
324 int uc_mgr_evaluate_include(snd_use_case_mgr_t *uc_mgr,
325 snd_config_t *parent,
328 int uc_mgr_evaluate_condition(snd_use_case_mgr_t *uc_mgr,
329 snd_config_t *parent,
332 int uc_mgr_define_regex(snd_use_case_mgr_t *uc_mgr,
336 /** The name of the environment variable containing the UCM directory */
337 #define ALSA_CONFIG_UCM_VAR "ALSA_CONFIG_UCM"
339 /** The name of the environment variable containing the UCM directory (new syntax) */
340 #define ALSA_CONFIG_UCM2_VAR "ALSA_CONFIG_UCM2"