]> code.delx.au - pulseaudio/blob - src/modules/alsa/alsa-ucm.h
alsa: Support ALSA without a use case manager
[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 channels */
60 #define PA_ALSA_PROP_UCM_PLAYBACK_CHANNELS "alsa.ucm.playback.channels"
61
62 /** For devices: Capture roles */
63 #define PA_ALSA_PROP_UCM_CAPTURE_ROLES "alsa.ucm.capture.roles"
64
65 /** For devices: Capture controls volume ID string. e.g CaptureVolume */
66 #define PA_ALSA_PROP_UCM_CAPTURE_VOLUME "alsa.ucm.capture.volume"
67
68 /** For devices: Capture switch e.g CaptureSwitch */
69 #define PA_ALSA_PROP_UCM_CAPTURE_SWITCH "alsa.ucm.capture.switch"
70
71 /** For devices: Capture priority */
72 #define PA_ALSA_PROP_UCM_CAPTURE_PRIORITY "alsa.ucm.capture.priority"
73
74 /** For devices: Capture channels */
75 #define PA_ALSA_PROP_UCM_CAPTURE_CHANNELS "alsa.ucm.capture.channels"
76
77 /** For devices: Quality of Service */
78 #define PA_ALSA_PROP_UCM_QOS "alsa.ucm.qos"
79
80 /** For devices: The modifier (if any) that this device corresponds to */
81 #define PA_ALSA_PROP_UCM_MODIFIER "alsa.ucm.modifier"
82
83 typedef struct pa_alsa_ucm_verb pa_alsa_ucm_verb;
84 typedef struct pa_alsa_ucm_modifier pa_alsa_ucm_modifier;
85 typedef struct pa_alsa_ucm_device pa_alsa_ucm_device;
86 typedef struct pa_alsa_ucm_config pa_alsa_ucm_config;
87 typedef struct pa_alsa_ucm_mapping_context pa_alsa_ucm_mapping_context;
88
89 int pa_alsa_ucm_query_profiles(pa_alsa_ucm_config *ucm, int card_index);
90 pa_alsa_profile_set* pa_alsa_ucm_add_profile_set(pa_alsa_ucm_config *ucm, pa_channel_map *default_channel_map);
91 int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, const char *new_profile, const char *old_profile);
92
93 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);
94
95 void pa_alsa_ucm_add_ports(
96 pa_hashmap **hash,
97 pa_proplist *proplist,
98 pa_alsa_ucm_mapping_context *context,
99 bool is_sink,
100 pa_card *card);
101 void pa_alsa_ucm_add_ports_combination(
102 pa_hashmap *hash,
103 pa_alsa_ucm_mapping_context *context,
104 bool is_sink,
105 pa_hashmap *ports,
106 pa_card_profile *cp,
107 pa_core *core);
108 int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port, bool is_sink);
109
110 void pa_alsa_ucm_free(pa_alsa_ucm_config *ucm);
111 void pa_alsa_ucm_mapping_context_free(pa_alsa_ucm_mapping_context *context);
112
113 void pa_alsa_ucm_roled_stream_begin(pa_alsa_ucm_config *ucm, const char *role, pa_direction_t dir);
114 void pa_alsa_ucm_roled_stream_end(pa_alsa_ucm_config *ucm, const char *role, pa_direction_t dir);
115
116 /* UCM - Use Case Manager is available on some audio cards */
117
118 struct pa_alsa_ucm_device {
119 PA_LLIST_FIELDS(pa_alsa_ucm_device);
120
121 pa_proplist *proplist;
122
123 unsigned playback_priority;
124 unsigned capture_priority;
125
126 unsigned playback_channels;
127 unsigned capture_channels;
128
129 pa_alsa_mapping *playback_mapping;
130 pa_alsa_mapping *capture_mapping;
131
132 pa_idxset *conflicting_devices;
133 pa_idxset *supported_devices;
134
135 pa_alsa_jack *input_jack;
136 pa_alsa_jack *output_jack;
137 };
138
139 struct pa_alsa_ucm_modifier {
140 PA_LLIST_FIELDS(pa_alsa_ucm_modifier);
141
142 pa_proplist *proplist;
143
144 int n_confdev;
145 int n_suppdev;
146
147 const char **conflicting_devices;
148 const char **supported_devices;
149
150 pa_direction_t action_direction;
151
152 char *media_role;
153
154 /* Non-NULL if the modifier has its own PlaybackPCM/CapturePCM */
155 pa_alsa_mapping *playback_mapping;
156 pa_alsa_mapping *capture_mapping;
157
158 /* Count how many role matched streams are running */
159 int enabled_counter;
160 };
161
162 struct pa_alsa_ucm_verb {
163 PA_LLIST_FIELDS(pa_alsa_ucm_verb);
164
165 pa_proplist *proplist;
166
167 PA_LLIST_HEAD(pa_alsa_ucm_device, devices);
168 PA_LLIST_HEAD(pa_alsa_ucm_modifier, modifiers);
169 };
170
171 struct pa_alsa_ucm_config {
172 pa_core *core;
173 snd_use_case_mgr_t *ucm_mgr;
174 pa_alsa_ucm_verb *active_verb;
175
176 PA_LLIST_HEAD(pa_alsa_ucm_verb, verbs);
177 PA_LLIST_HEAD(pa_alsa_jack, jacks);
178 };
179
180 struct pa_alsa_ucm_mapping_context {
181 pa_alsa_ucm_config *ucm;
182 pa_direction_t direction;
183
184 pa_idxset *ucm_devices;
185 pa_idxset *ucm_modifiers;
186 };
187
188 #endif