summaryrefslogtreecommitdiff
path: root/include/ascenario.h
blob: b1395515b035629d09cd9b3d3a224743053aa159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/**
 * \file include/ascenario.h
 * \brief Scenario interface for the ALSA driver
 * \author Liam Girdwood <lrg@slimlogic.co.uk>
 * \author Stefan Schmidt <stefan@slimlogic.co.uk>
 * \author Jaroslav Kysela <perex@perex.cz>
 * \date 2008-2009
 */
/*
 *
 *   This library is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as
 *   published by the Free Software Foundation; either version 2.1 of
 *   the License, or (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU Lesser General Public License for more details.
 *
 *   You should have received a copy of the GNU Lesser General Public
 *   License along with this library; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 *  Copyright (C) 2008-2009 SlimLogic Ltd
 */

#ifndef __ALSA_ASCENARIO_H
#define __ALSA_ASCENARIO_H

/*! \page ascenario Scenario interface

It allows switching audio settings between scenarios or uses-cases like
listening to music and answering an incoming phone call. Made of control
aliasing for playback, capture master and switch as well as the option to
post- and prefix a sequence of control changes avoiding pops and other
unwanted noise.

*/

#ifdef __cplusplus
extern "C" {
#endif

/**
 *  \defgroup AScenario Scenario Interface
 *  The ALSA scenario interface.
 *  See \ref ascenario page for more details.
 *  \{
 */
     
/**
 * Scenario IDs
 *
 * Standard Scenario IDs - Add new scenarios at the end.
 */

/** use main speaker for playback */
#define SND_SCN_PLAYBACK_SPEAKER        "playback speaker"
/** use headphone output for playback */
#define SND_SCN_PLAYBACK_HEADPHONES     "playback headphone"
/** use headset for playback */
#define SND_SCN_PLAYBACK_HEADSET        "playback headset"
/** use bluetooth interface for playback */
#define SND_SCN_PLAYBACK_BLUETOOTH      "playback bluetooth"
/** use handset interface for playback */
#define SND_SCN_PLAYBACK_HANDSET        "playback handset"
/** use gsm interface for playback */
#define SND_SCN_PLAYBACK_GSM            "playback gsm"
/** use line interface for playback */
#define SND_SCN_PLAYBACK_LINE           "playback line"

/** use mic input for capture */
#define SND_SCN_CAPTURE_MIC             "capture mic"
/** use line input for capture */
#define SND_SCN_CAPTURE_LINE            "capture line"
/** use headset input for capture */
#define SND_SCN_CAPTURE_HEADSET         "capture headset"
/** use handset input for capture */
#define SND_SCN_CAPTURE_HANDSET         "capture handset"
/** use bluetooth input for capture */
#define SND_SCN_CAPTURE_BLUETOOTH       "capture bluetooth"
/** use gsm input for capture */
#define SND_SCN_CAPTURE_GSM             "capture gsm"

/** phone call through gsm handset */
#define SND_SCN_PHONECALL_GSM_HANDSET   "phonecall gsm handset"
/** phone call through bluetooth handset */
#define SND_SCN_PHONECALL_BT_HANDSET    "phonecall bt handset"
/** phone call through ip handset */
#define SND_SCN_PHONECALL_IP_HANDSET    "phonecall ip handset"
/** phone call through gsm headset */
#define SND_SCN_PHONECALL_GSM_HEADSET   "phonecall gsm headset"
/** phone call through bluetooth headset */
#define SND_SCN_PHONECALL_BT_HEADSET    "phonecall bt headset"
/** phone call through ip headset */
#define SND_SCN_PHONECALL_IP_HEADSET    "phonecall ip headset"

/**
 * QOS
 *
 * Defines Audio Quality of Service. Systems supporting different types of QoS
 * often have lower power consumption on lower quality levels.
 */
/** use HIFI grade QoS service */
#define SND_POWER_QOS_HIFI			0
/** use voice grade QoS service */
#define SND_POWER_QOS_VOICE			1
/** use system sound grade QoS service */
#define SND_POWER_QOS_SYSTEM			2

/**
 * KControl types
 */
/** master playback volume */
#define SND_SCN_KCTL_MASTER_PLAYBACK_VOLUME	1
/** master playback switch */
#define SND_SCN_KCTL_MASTER_PLAYBACK_SWITCH	2
/** master capture volume */
#define SND_SCN_KCTL_MASTER_CAPTURE_VOLUME	3
/** master capture switch */
#define SND_SCN_KCTL_MASTER_CAPTURE_SWITCH	4

/**
 * Integer types
 */
/** QoS volume */
#define SND_SCN_INT_QOS				1

/** Scenario container */
typedef struct snd_scenario snd_scenario_t;

/* TODO: add notification */

/**
 * \brief list supported scenarios for given soundcard
 * \param scn scenario
 * \param list returned list of supported scenario names
 * \return number of scenarios if success, otherwise a negative error code
 */
int snd_scenario_list(snd_scenario_t *scn, const char **list[]);

/**
 * \brief set new scenario for sound card
 * \param scn scenario
 * \param scenario scenario id string
 * \return zero if success, otherwise a negative error code
 */
int snd_scenario_set_scn(snd_scenario_t *scn, const char *scenario);

/**
 * \brief get scenario
 * \param scn scenario
 * \return scenario id string
 *
 * Get current sound card scenario.
 */
const char *snd_scenario_get_scn(snd_scenario_t *scn);

/**
 * \brief get associated control id
 * \param scn scenario
 * \param kctl_type see SND_SCN_KCTL_* constants
 * \param id returned control id
 * \return zero if success, otherwise a negative error code
 *
 * Get the control id for the current scenario.
 */
int snd_scenario_get_kcontrol(snd_scenario_t *scn,
                              int kctl_type, snd_ctl_elem_id_t *id);

/**
 * \brief set integer value
 * \param scn scenario
 * \param int_key see SND_SCN_INT_* constants
 * \param value value
 * \return zero if success, otherwise a negative error code
 */
int snd_scenario_set_integer(snd_scenario_t *scn, int int_key, int value);

/**
 * \brief get integer value
 * \param scn scenario
 * \param int_key see SND_SCN_INT_* constants
 * \param value value
 * \return zero if success, otherwise a negative error code
 */
int snd_scenario_get_integer(snd_scenario_t *scn, int int_key, int *value);

/**
 * \brief open scenario core for sound card
 * \param card_name sound card name.
 * \return zero if success, otherwise a negative error code
 */
snd_scenario_t *snd_scenario_open(const char *card_name);

/**
 * \brief reload and reparse scenario configuration
 * \param scn scenario
 * \return zero if success, otherwise a negative error code
 */
int snd_scenario_reload(snd_scenario_t *scn);

/**
 * \brief close scenario
 * \param scn scenario
 * \return zero if success, otherwise a negative error code
 */
int snd_scenario_close(snd_scenario_t *scn);

/**
 * \brief dump scenario
 * \param output handle
 * \param card_name sound card name
 * \return zero if success, otherwise a negative error code
 */
int snd_scenario_dump(snd_output_t *output, const char *card_name);

/**
 *  \}
 */

#ifdef __cplusplus
}
#endif

#endif /* __ALSA_ASCENARIO_H */