ALSA project - the C library reference
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ucm_local.h
1 /*
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.
6  *
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.
11  *
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
15  *
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.
22  *
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>
31  */
32 
33 
34 
35 #if 0
36 #define UC_MGR_DEBUG
37 #endif
38 
39 #include "local.h"
40 #include "use-case.h"
41 
42 #define MAX_FILE 256
43 #define ALSA_USE_CASE_DIR ALSA_CONFIG_DIR "/ucm"
44 
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
49 
50 struct ucm_value {
51  struct list_head list;
52  char *name;
53  char *data;
54 };
55 
57  struct list_head list;
58  unsigned int type;
59  union {
60  long sleep; /* Sleep time in microseconds if sleep element, else 0 */
61  char *cdev;
62  char *cset;
63  char *exec;
64  } data;
65 };
66 
67 /*
68  * Transition sequences. i.e. transition between one verb, device, mod to another
69  */
71  struct list_head list;
72  char *name;
73  struct list_head transition_list;
74 };
75 
76 /*
77  * Modifier Supported Devices.
78  */
79 enum dev_list_type {
80  DEVLIST_NONE,
81  DEVLIST_SUPPORTED,
82  DEVLIST_CONFLICTING
83 };
84 
85 struct dev_list_node {
86  struct list_head list;
87  char *name;
88 };
89 
90 struct dev_list {
91  enum dev_list_type type;
92  struct list_head list;
93 };
94 
95 /*
96  * Describes a Use Case Modifier and it's enable and disable sequences.
97  * A use case verb can have N modifiers.
98  */
100  struct list_head list;
101  struct list_head active_list;
102 
103  char *name;
104  char *comment;
105 
106  /* modifier enable and disable sequences */
107  struct list_head enable_list;
108  struct list_head disable_list;
109 
110  /* modifier transition list */
111  struct list_head transition_list;
112 
113  /* list of devices supported or conflicting */
114  struct dev_list dev_list;
115 
116  /* values */
117  struct list_head value_list;
118 };
119 
120 /*
121  * Describes a Use Case Device and it's enable and disable sequences.
122  * A use case verb can have N devices.
123  */
125  struct list_head list;
126  struct list_head active_list;
127 
128  char *name;
129  char *comment;
130 
131  /* device enable and disable sequences */
132  struct list_head enable_list;
133  struct list_head disable_list;
134 
135  /* device transition list */
136  struct list_head transition_list;
137 
138  /* list of devices supported or conflicting */
139  struct dev_list dev_list;
140 
141  /* value list */
142  struct list_head value_list;
143 };
144 
145 /*
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.
148  */
150  struct list_head list;
151 
152  unsigned int active: 1;
153 
154  char *name;
155  char *comment;
156 
157  /* verb enable and disable sequences */
158  struct list_head enable_list;
159  struct list_head disable_list;
160 
161  /* verb transition list */
162  struct list_head transition_list;
163 
164  /* hardware devices that can be used with this use case */
165  struct list_head device_list;
166 
167  /* modifiers that can be used with this use case */
168  struct list_head modifier_list;
169 
170  /* value list */
171  struct list_head value_list;
172 };
173 
174 /*
175  * Manages a sound card and all its use cases.
176  */
178  char *card_name;
179  char *comment;
180 
181  /* use case verb, devices and modifier configs parsed from files */
182  struct list_head verb_list;
183 
184  /* default settings - sequence */
185  struct list_head default_list;
186 
187  /* default settings - value list */
188  struct list_head value_list;
189 
190  /* current status */
191  struct use_case_verb *active_verb;
192  struct list_head active_devices;
193  struct list_head active_modifiers;
194 
195  /* locking */
196  pthread_mutex_t mutex;
197 
198  /* change to list of ctl handles */
199  snd_ctl_t *ctl;
200  char *ctl_dev;
201 };
202 
203 #define uc_error SNDERR
204 
205 #ifdef UC_MGR_DEBUG
206 #define uc_dbg SNDERR
207 #else
208 #define uc_dbg(fmt, arg...) do { } while (0)
209 #endif
210 
211 void uc_mgr_error(const char *fmt, ...);
212 void uc_mgr_stdout(const char *fmt, ...);
213 
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[]);
217 
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);
Definition: ucm_local.h:149
use case interface for the ALSA driver
struct _snd_ctl snd_ctl_t
Definition: control.h:207
Definition: ucm_local.h:90
Definition: ucm_local.h:50
Definition: ucm_local.h:124
Definition: ucm_local.h:177
struct _snd_config snd_config_t
Internal structure for a configuration node object.
Definition: conf.h:69
Definition: ucm_local.h:70
Definition: ucm_local.h:85
Definition: ucm_local.h:56
Definition: ucm_local.h:99