ALSA project - the C library reference
/home/users/builder/rpm/BUILD/alsa-lib-1.0.25/src/ucm/ucm_local.h
00001 /*
00002  *  This library is free software; you can redistribute it and/or
00003  *  modify it under the terms of the GNU Lesser General Public
00004  *  License as published by the Free Software Foundation; either
00005  *  version 2 of the License, or (at your option) any later version.
00006  *
00007  *  This library is distributed in the hope that it will be useful,
00008  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00010  *  Lesser General Public License for more details.
00011  *
00012  *  You should have received a copy of the GNU Lesser General Public
00013  *  License along with this library; if not, write to the Free Software  
00014  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00015  *
00016  *  Support for the verb/device/modifier core logic and API,
00017  *  command line tool and file parser was kindly sponsored by
00018  *  Texas Instruments Inc.
00019  *  Support for multiple active modifiers and devices,
00020  *  transition sequences, multiple client access and user defined use
00021  *  cases was kindly sponsored by Wolfson Microelectronics PLC.
00022  *
00023  *  Copyright (C) 2008-2010 SlimLogic Ltd
00024  *  Copyright (C) 2010 Wolfson Microelectronics PLC
00025  *  Copyright (C) 2010 Texas Instruments Inc.
00026  *  Copyright (C) 2010 Red Hat Inc.
00027  *  Authors: Liam Girdwood <lrg@slimlogic.co.uk>
00028  *               Stefan Schmidt <stefan@slimlogic.co.uk>
00029  *               Justin Xu <justinx@slimlogic.co.uk>
00030  *               Jaroslav Kysela <perex@perex.cz>
00031  */
00032 
00033 
00034 
00035 #if 0
00036 #define UC_MGR_DEBUG
00037 #endif
00038 
00039 #include "local.h"
00040 #include "use-case.h"
00041 
00042 #define MAX_FILE                256
00043 #define ALSA_USE_CASE_DIR       ALSA_CONFIG_DIR "/ucm"
00044 
00045 #define SEQUENCE_ELEMENT_TYPE_CDEV      1
00046 #define SEQUENCE_ELEMENT_TYPE_CSET      2
00047 #define SEQUENCE_ELEMENT_TYPE_SLEEP     3
00048 #define SEQUENCE_ELEMENT_TYPE_EXEC      4
00049 
00050 struct ucm_value {
00051         struct list_head list;
00052         char *name;
00053         char *data;
00054 };
00055 
00056 struct sequence_element {
00057         struct list_head list;
00058         unsigned int type;
00059         union {
00060                 long sleep; /* Sleep time in microseconds if sleep element, else 0 */
00061                 char *cdev;
00062                 char *cset;
00063                 char *exec;
00064         } data;
00065 };
00066 
00067 /*
00068  * Transition sequences. i.e. transition between one verb, device, mod to another
00069  */
00070 struct transition_sequence {
00071         struct list_head list;
00072         char *name;
00073         struct list_head transition_list;
00074 };
00075 
00076 /*
00077  * Modifier Supported Devices.
00078  */
00079 enum dev_list_type {
00080         DEVLIST_NONE,
00081         DEVLIST_SUPPORTED,
00082         DEVLIST_CONFLICTING
00083 };
00084 
00085 struct dev_list_node {
00086         struct list_head list;
00087         char *name;
00088 };
00089 
00090 struct dev_list {
00091         enum dev_list_type type;
00092         struct list_head list;
00093 };
00094 
00095 /*
00096  * Describes a Use Case Modifier and it's enable and disable sequences.
00097  * A use case verb can have N modifiers.
00098  */
00099 struct use_case_modifier {
00100         struct list_head list;
00101         struct list_head active_list;
00102 
00103         char *name;
00104         char *comment;
00105 
00106         /* modifier enable and disable sequences */
00107         struct list_head enable_list;
00108         struct list_head disable_list;
00109 
00110         /* modifier transition list */
00111         struct list_head transition_list;
00112 
00113         /* list of devices supported or conflicting */
00114         struct dev_list dev_list;
00115 
00116         /* values */
00117         struct list_head value_list;
00118 };
00119 
00120 /*
00121  * Describes a Use Case Device and it's enable and disable sequences.
00122  * A use case verb can have N devices.
00123  */
00124 struct use_case_device {
00125         struct list_head list;
00126         struct list_head active_list;
00127 
00128         char *name;
00129         char *comment;
00130 
00131         /* device enable and disable sequences */
00132         struct list_head enable_list;
00133         struct list_head disable_list;
00134 
00135         /* device transition list */
00136         struct list_head transition_list;
00137 
00138         /* list of devices supported or conflicting */
00139         struct dev_list dev_list;
00140 
00141         /* value list */
00142         struct list_head value_list;
00143 };
00144 
00145 /*
00146  * Describes a Use Case Verb and it's enable and disable sequences.
00147  * A use case verb can have N devices and N modifiers.
00148  */
00149 struct use_case_verb {
00150         struct list_head list;
00151 
00152         unsigned int active: 1;
00153 
00154         char *name;
00155         char *comment;
00156 
00157         /* verb enable and disable sequences */
00158         struct list_head enable_list;
00159         struct list_head disable_list;
00160 
00161         /* verb transition list */
00162         struct list_head transition_list;
00163 
00164         /* hardware devices that can be used with this use case */
00165         struct list_head device_list;
00166 
00167         /* modifiers that can be used with this use case */
00168         struct list_head modifier_list;
00169 
00170         /* value list */
00171         struct list_head value_list;
00172 };
00173 
00174 /*
00175  *  Manages a sound card and all its use cases.
00176  */
00177 struct snd_use_case_mgr {
00178         char *card_name;
00179         char *comment;
00180 
00181         /* use case verb, devices and modifier configs parsed from files */
00182         struct list_head verb_list;
00183 
00184         /* default settings - sequence */
00185         struct list_head default_list;
00186 
00187         /* default settings - value list */
00188         struct list_head value_list;
00189 
00190         /* current status */
00191         struct use_case_verb *active_verb;
00192         struct list_head active_devices;
00193         struct list_head active_modifiers;
00194 
00195         /* locking */
00196         pthread_mutex_t mutex;
00197 
00198         /* change to list of ctl handles */
00199         snd_ctl_t *ctl;
00200         char *ctl_dev;
00201 };
00202 
00203 #define uc_error SNDERR
00204 
00205 #ifdef UC_MGR_DEBUG
00206 #define uc_dbg SNDERR
00207 #else
00208 #define uc_dbg(fmt, arg...) do { } while (0)
00209 #endif
00210 
00211 void uc_mgr_error(const char *fmt, ...);
00212 void uc_mgr_stdout(const char *fmt, ...);
00213 
00214 int uc_mgr_config_load(const char *file, snd_config_t **cfg);
00215 int uc_mgr_import_master_config(snd_use_case_mgr_t *uc_mgr);
00216 int uc_mgr_scan_master_configs(const char **_list[]);
00217 
00218 void uc_mgr_free_sequence_element(struct sequence_element *seq);
00219 void uc_mgr_free_transition_element(struct transition_sequence *seq);
00220 void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr);
00221 void uc_mgr_free(snd_use_case_mgr_t *uc_mgr);
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines