/var/tmp/repot-build/BUILD/alsa-lib-1.0.24.1/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 General Public License
00013  *  along with this program; 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 msecs 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 struct dev_list {
00080         struct list_head list;
00081         char *name;
00082 };
00083 
00084 
00085 /*
00086  * Describes a Use Case Modifier and it's enable and disable sequences.
00087  * A use case verb can have N modifiers.
00088  */
00089 struct use_case_modifier {
00090         struct list_head list;
00091         struct list_head active_list;
00092 
00093         char *name;
00094         char *comment;
00095 
00096         /* modifier enable and disable sequences */
00097         struct list_head enable_list;
00098         struct list_head disable_list;
00099 
00100         /* modifier transition list */
00101         struct list_head transition_list;
00102 
00103         /* list of supported devices per modifier */
00104         struct list_head dev_list;
00105 
00106         /* values */
00107         struct list_head value_list;
00108 };
00109 
00110 /*
00111  * Describes a Use Case Device and it's enable and disable sequences.
00112  * A use case verb can have N devices.
00113  */
00114 struct use_case_device {
00115         struct list_head list;
00116         struct list_head active_list;
00117 
00118         char *name;
00119         char *comment;
00120 
00121         /* device enable and disable sequences */
00122         struct list_head enable_list;
00123         struct list_head disable_list;
00124 
00125         /* device transition list */
00126         struct list_head transition_list;
00127 
00128         /* value list */
00129         struct list_head value_list;
00130 };
00131 
00132 /*
00133  * Describes a Use Case Verb and it's enable and disable sequences.
00134  * A use case verb can have N devices and N modifiers.
00135  */
00136 struct use_case_verb {
00137         struct list_head list;
00138 
00139         unsigned int active: 1;
00140 
00141         char *name;
00142         char *comment;
00143 
00144         /* verb enable and disable sequences */
00145         struct list_head enable_list;
00146         struct list_head disable_list;
00147 
00148         /* verb transition list */
00149         struct list_head transition_list;
00150 
00151         /* hardware devices that can be used with this use case */
00152         struct list_head device_list;
00153 
00154         /* modifiers that can be used with this use case */
00155         struct list_head modifier_list;
00156 
00157         /* value list */
00158         struct list_head value_list;
00159 };
00160 
00161 /*
00162  *  Manages a sound card and all its use cases.
00163  */
00164 struct snd_use_case_mgr {
00165         char *card_name;
00166         char *comment;
00167 
00168         /* use case verb, devices and modifier configs parsed from files */
00169         struct list_head verb_list;
00170 
00171         /* default settings - sequence */
00172         struct list_head default_list;
00173 
00174         /* default settings - value list */
00175         struct list_head value_list;
00176 
00177         /* current status */
00178         struct use_case_verb *active_verb;
00179         struct list_head active_devices;
00180         struct list_head active_modifiers;
00181 
00182         /* locking */
00183         pthread_mutex_t mutex;
00184 
00185         /* change to list of ctl handles */
00186         snd_ctl_t *ctl;
00187         char *ctl_dev;
00188 };
00189 
00190 #define uc_error SNDERR
00191 
00192 #ifdef UC_MGR_DEBUG
00193 #define uc_dbg SNDERR
00194 #else
00195 #define uc_dbg(fmt, arg...) do { } while (0)
00196 #endif
00197 
00198 void uc_mgr_error(const char *fmt, ...);
00199 void uc_mgr_stdout(const char *fmt, ...);
00200 
00201 int uc_mgr_config_load(const char *file, snd_config_t **cfg);
00202 int uc_mgr_import_master_config(snd_use_case_mgr_t *uc_mgr);
00203 int uc_mgr_scan_master_configs(const char **_list[]);
00204 
00205 void uc_mgr_free_sequence_element(struct sequence_element *seq);
00206 void uc_mgr_free_transition_element(struct transition_sequence *seq);
00207 void uc_mgr_free_verb(snd_use_case_mgr_t *uc_mgr);
00208 void uc_mgr_free(snd_use_case_mgr_t *uc_mgr);

Generated for ALSA project - the C library reference by doxygen 1.4.7