]> code.delx.au - pulseaudio/blob - src/modules/alsa/alsa-ucm.h
alsa-mixer: Add surround 2.1 profile
[pulseaudio] / src / modules / alsa / alsa-ucm.h
1 #ifndef fooalsaucmhfoo
2 #define fooalsaucmhfoo
3
4 /***
5 This file is part of PulseAudio.
6
7 Copyright 2011 Wolfson Microelectronics PLC
8 Author Margarita Olaya <magi@slimlogic.co.uk>
9 Copyright 2012 Feng Wei <wei.feng@freescale.com>, Freescale Ltd.
10
11 PulseAudio is free software; you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License as published
13 by the Free Software Foundation; either version 2.1 of the License,
14 or (at your option) any later version.
15
16 PulseAudio is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
20
21 You should have received a copy of the GNU Lesser General Public License
22 along with PulseAudio; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 USA.
25 ***/
26
27 #ifdef HAVE_ALSA_UCM
28 #include <use-case.h>
29 #else
30 typedef void snd_use_case_mgr_t;
31 #endif
32
33 #include "alsa-mixer.h"
34
35 /** For devices: List of verbs, devices or modifiers available */
36 #define PA_ALSA_PROP_UCM_NAME "alsa.ucm.name"
37
38 /** For devices: List of supported devices per verb*/
39 #define PA_ALSA_PROP_UCM_DESCRIPTION "alsa.ucm.description"
40
41 /** For devices: Playback device name e.g PlaybackPCM */
42 #define PA_ALSA_PROP_UCM_SINK "alsa.ucm.sink"
43
44 /** For devices: Capture device name e.g CapturePCM*/
45 #define PA_ALSA_PROP_UCM_SOURCE "alsa.ucm.source"
46
47 /** For devices: Playback roles */
48 #define PA_ALSA_PROP_UCM_PLAYBACK_ROLES "alsa.ucm.playback.roles"
49
50 /** For devices: Playback control volume ID string. e.g PlaybackVolume */
51 #define PA_ALSA_PROP_UCM_PLAYBACK_VOLUME "alsa.ucm.playback.volume"
52
53 /** For devices: Playback switch e.g PlaybackSwitch */
54 #define PA_ALSA_PROP_UCM_PLAYBACK_SWITCH "alsa.ucm.playback.switch"
55
56 /** For devices: Playback priority */
57 #define PA_ALSA_PROP_UCM_PLAYBACK_PRIORITY "alsa.ucm.playback.priority"
58
59 /** For devices: Playback rate */
60 #define PA_ALSA_PROP_UCM_PLAYBACK_RATE "alsa.ucm.playback.rate"
61
62 /** For devices: Playback channels */
63 #define PA_ALSA_PROP_UCM_PLAYBACK_CHANNELS "alsa.ucm.playback.channels"
64
65 /** For devices: Capture roles */
66 #define PA_ALSA_PROP_UCM_CAPTURE_ROLES "alsa.ucm.capture.roles"
67
68 /** For devices: Capture controls volume ID string. e.g CaptureVolume */
69 #define PA_ALSA_PROP_UCM_CAPTURE_VOLUME "alsa.ucm.capture.volume"
70
71 /** For devices: Capture switch e.g CaptureSwitch */
72 #define PA_ALSA_PROP_UCM_CAPTURE_SWITCH "alsa.ucm.capture.switch"
73
74 /** For devices: Capture priority */
75 #define PA_ALSA_PROP_UCM_CAPTURE_PRIORITY "alsa.ucm.capture.priority"
76
77 /** For devices: Capture rate */
78 #define PA_ALSA_PROP_UCM_CAPTURE_RATE "alsa.ucm.capture.rate"
79
80 /** For devices: Capture channels */
81 #define PA_ALSA_PROP_UCM_CAPTURE_CHANNELS "alsa.ucm.capture.channels"
82
83 /** For devices: Quality of Service */
84 #define PA_ALSA_PROP_UCM_QOS "alsa.ucm.qos"
85
86 /** For devices: The modifier (if any) that this device corresponds to */
87 #define PA_ALSA_PROP_UCM_MODIFIER "alsa.ucm.modifier"
88
89 typedef struct pa_alsa_ucm_verb pa_alsa_ucm_verb;
90 typedef struct pa_alsa_ucm_modifier pa_alsa_ucm_modifier;
91 typedef struct pa_alsa_ucm_device pa_alsa_ucm_device;
92 typedef struct pa_alsa_ucm_config pa_alsa_ucm_config;
93 typedef struct pa_alsa_ucm_mapping_context pa_alsa_ucm_mapping_context;
94
95 int pa_alsa_ucm_query_profiles(pa_alsa_ucm_config *ucm, int card_index);
96 pa_alsa_profile_set* pa_alsa_ucm_add_profile_set(pa_alsa_ucm_config *ucm, pa_channel_map *default_channel_map);
97 int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, const char *new_profile, const char *old_profile);
98
99 int pa_alsa_ucm_get_verb(snd_use_case_mgr_t *uc_mgr, const char *verb_name, const char *verb_desc, pa_alsa_ucm_verb **p_verb);
100
101 void pa_alsa_ucm_add_ports(
102 pa_hashmap **hash,
103 pa_proplist *proplist,
104 pa_alsa_ucm_mapping_context *context,
105 bool is_sink,
106 pa_card *card);
107 void pa_alsa_ucm_add_ports_combination(
108 pa_hashmap *hash,
109 pa_alsa_ucm_mapping_context *context,
110 bool is_sink,
111 pa_hashmap *ports,
112 pa_card_profile *cp,
113 pa_core *core);
114 int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port, bool is_sink);
115
116 void pa_alsa_ucm_free(pa_alsa_ucm_config *ucm);
117 void pa_alsa_ucm_mapping_context_free(pa_alsa_ucm_mapping_context *context);
118
119 void pa_alsa_ucm_roled_stream_begin(pa_alsa_ucm_config *ucm, const char *role, pa_direction_t dir);
120 void pa_alsa_ucm_roled_stream_end(pa_alsa_ucm_config *ucm, const char *role, pa_direction_t dir);
121
122 /* UCM - Use Case Manager is available on some audio cards */
123
124 struct pa_alsa_ucm_device {
125 PA_LLIST_FIELDS(pa_alsa_ucm_device);
126
127 pa_proplist *proplist;
128
129 unsigned playback_priority;
130 unsigned capture_priority;
131
132 unsigned playback_rate;
133 unsigned capture_rate;
134
135 unsigned playback_channels;
136 unsigned capture_channels;
137
138 pa_alsa_mapping *playback_mapping;
139 pa_alsa_mapping *capture_mapping;
140
141 pa_idxset *conflicting_devices;
142 pa_idxset *supported_devices;
143
144 pa_alsa_jack *input_jack;
145 pa_alsa_jack *output_jack;
146 };
147
148 struct pa_alsa_ucm_modifier {
149 PA_LLIST_FIELDS(pa_alsa_ucm_modifier);
150
151 pa_proplist *proplist;
152
153 int n_confdev;
154 int n_suppdev;
155
156 const char **conflicting_devices;
157 const char **supported_devices;
158
159 pa_direction_t action_direction;
160
161 char *media_role;
162
163 /* Non-NULL if the modifier has its own PlaybackPCM/CapturePCM */
164 pa_alsa_mapping *playback_mapping;
165 pa_alsa_mapping *capture_mapping;
166
167 /* Count how many role matched streams are running */
168 int enabled_counter;
169 };
170
171 struct pa_alsa_ucm_verb {
172 PA_LLIST_FIELDS(pa_alsa_ucm_verb);
173
174 pa_proplist *proplist;
175
176 PA_LLIST_HEAD(pa_alsa_ucm_device, devices);
177 PA_LLIST_HEAD(pa_alsa_ucm_modifier, modifiers);
178 };
179
180 struct pa_alsa_ucm_config {
181 pa_core *core;
182 snd_use_case_mgr_t *ucm_mgr;
183 pa_alsa_ucm_verb *active_verb;
184
185 PA_LLIST_HEAD(pa_alsa_ucm_verb, verbs);
186 PA_LLIST_HEAD(pa_alsa_jack, jacks);
187 };
188
189 struct pa_alsa_ucm_mapping_context {
190 pa_alsa_ucm_config *ucm;
191 pa_direction_t direction;
192
193 pa_idxset *ucm_devices;
194 pa_idxset *ucm_modifiers;
195 };
196
197 #endif