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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 ALSA_USE_CASE_DIR ALSA_CONFIG_DIR "/ucm"
45 #define SEQUENCE_ELEMENT_TYPE_CDEV 1
46 #define SEQUENCE_ELEMENT_TYPE_CSET 2
47 #define SEQUENCE_ELEMENT_TYPE_SLEEP 3
48 #define SEQUENCE_ELEMENT_TYPE_EXEC 4
51 struct list_head list;
56 struct sequence_element {
57 struct list_head list;
60 long sleep; /* Sleep time in microseconds if sleep element, else 0 */
68 * Transition sequences. i.e. transition between one verb, device, mod to another
70 struct transition_sequence {
71 struct list_head list;
73 struct list_head transition_list;
77 * Modifier Supported Devices.
85 struct dev_list_node {
86 struct list_head list;
91 enum dev_list_type type;
92 struct list_head list;
96 * Describes a Use Case Modifier and it's enable and disable sequences.
97 * A use case verb can have N modifiers.
99 struct use_case_modifier {
100 struct list_head list;
101 struct list_head active_list;
106 /* modifier enable and disable sequences */
107 struct list_head enable_list;
108 struct list_head disable_list;
110 /* modifier transition list */
111 struct list_head transition_list;
113 /* list of devices supported or conflicting */
114 struct dev_list dev_list;
117 struct list_head value_list;
121 * Describes a Use Case Device and it's enable and disable sequences.
122 * A use case verb can have N devices.
124 struct use_case_device {
125 struct list_head list;
126 struct list_head active_list;
131 /* device enable and disable sequences */
132 struct list_head enable_list;
133 struct list_head disable_list;
135 /* device transition list */
136 struct list_head transition_list;
138 /* list of devices supported or conflicting */
139 struct dev_list dev_list;
142 struct list_head value_list;
146 * Describes a Use Case Verb and it's enable and disable sequences.
147 * A use case verb can have N devices and N modifiers.
149 struct use_case_verb {
150 struct list_head list;
152 unsigned int active: 1;
157 /* verb enable and disable sequences */
158 struct list_head enable_list;
159 struct list_head disable_list;
161 /* verb transition list */
162 struct list_head transition_list;
164 /* hardware devices that can be used with this use case */
165 struct list_head device_list;
167 /* modifiers that can be used with this use case */
168 struct list_head modifier_list;
171 struct list_head value_list;
175 * Manages a sound card and all its use cases.
177 struct snd_use_case_mgr {
181 /* use case verb, devices and modifier configs parsed from files */
182 struct list_head verb_list;
184 /* default settings - sequence */
185 struct list_head default_list;
187 /* default settings - value list */
188 struct list_head value_list;
191 struct use_case_verb *active_verb;
192 struct list_head active_devices;
193 struct list_head active_modifiers;
196 pthread_mutex_t mutex;
198 /* change to list of ctl handles */
203 #define uc_error SNDERR
206 #define uc_dbg SNDERR
208 #define uc_dbg(fmt, arg...) do { } while (0)
211 void uc_mgr_error(const char *fmt, ...);
212 void uc_mgr_stdout(const char *fmt, ...);
214 int uc_mgr_config_load(const char *file, snd_config_t **cfg);
215 int uc_mgr_import_master_config(snd_use_case_mgr_t *uc_mgr);
216 int uc_mgr_scan_master_configs(const char **_list[]);
218 void uc_mgr_free_sequence_element(struct sequence_element *seq);
219 void uc_mgr_free_transition_element(struct transition_sequence *seq);
220 void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr);
221 void uc_mgr_free(snd_use_case_mgr_t *uc_mgr);