]> code.delx.au - pulseaudio/blob - src/modules/alsa/alsa-ucm.h
alsa: Add separate sinks/sources for UCM modifiers if needed
[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 #include <use-case.h>
28
29 #include "alsa-mixer.h"
30
31 /** For devices: List of verbs, devices or modifiers available */
32 #define PA_ALSA_PROP_UCM_NAME "alsa.ucm.name"
33
34 /** For devices: List of supported devices per verb*/
35 #define PA_ALSA_PROP_UCM_DESCRIPTION "alsa.ucm.description"
36
37 /** For devices: Playback device name e.g PlaybackPCM */
38 #define PA_ALSA_PROP_UCM_SINK "alsa.ucm.sink"
39
40 /** For devices: Capture device name e.g CapturePCM*/
41 #define PA_ALSA_PROP_UCM_SOURCE "alsa.ucm.source"
42
43 /** For devices: Playback roles */
44 #define PA_ALSA_PROP_UCM_PLAYBACK_ROLES "alsa.ucm.playback.roles"
45
46 /** For devices: Playback control volume ID string. e.g PlaybackVolume */
47 #define PA_ALSA_PROP_UCM_PLAYBACK_VOLUME "alsa.ucm.playback.volume"
48
49 /** For devices: Playback switch e.g PlaybackSwitch */
50 #define PA_ALSA_PROP_UCM_PLAYBACK_SWITCH "alsa.ucm.playback.switch"
51
52 /** For devices: Playback priority */
53 #define PA_ALSA_PROP_UCM_PLAYBACK_PRIORITY "alsa.ucm.playback.priority"
54
55 /** For devices: Playback channels */
56 #define PA_ALSA_PROP_UCM_PLAYBACK_CHANNELS "alsa.ucm.playback.channels"
57
58 /** For devices: Capture roles */
59 #define PA_ALSA_PROP_UCM_CAPTURE_ROLES "alsa.ucm.capture.roles"
60
61 /** For devices: Capture controls volume ID string. e.g CaptureVolume */
62 #define PA_ALSA_PROP_UCM_CAPTURE_VOLUME "alsa.ucm.capture.volume"
63
64 /** For devices: Capture switch e.g CaptureSwitch */
65 #define PA_ALSA_PROP_UCM_CAPTURE_SWITCH "alsa.ucm.capture.switch"
66
67 /** For devices: Capture priority */
68 #define PA_ALSA_PROP_UCM_CAPTURE_PRIORITY "alsa.ucm.capture.priority"
69
70 /** For devices: Capture channels */
71 #define PA_ALSA_PROP_UCM_CAPTURE_CHANNELS "alsa.ucm.capture.channels"
72
73 /** For devices: Quality of Service */
74 #define PA_ALSA_PROP_UCM_QOS "alsa.ucm.qos"
75
76 /** For devices: The modifier (if any) that this device corresponds to */
77 #define PA_ALSA_PROP_UCM_MODIFIER "alsa.ucm.modifier"
78
79 typedef struct pa_alsa_ucm_verb pa_alsa_ucm_verb;
80 typedef struct pa_alsa_ucm_modifier pa_alsa_ucm_modifier;
81 typedef struct pa_alsa_ucm_device pa_alsa_ucm_device;
82 typedef struct pa_alsa_ucm_config pa_alsa_ucm_config;
83 typedef struct pa_alsa_ucm_mapping_context pa_alsa_ucm_mapping_context;
84
85 int pa_alsa_ucm_query_profiles(pa_alsa_ucm_config *ucm, int card_index);
86 pa_alsa_profile_set* pa_alsa_ucm_add_profile_set(pa_alsa_ucm_config *ucm, pa_channel_map *default_channel_map);
87 int pa_alsa_ucm_set_profile(pa_alsa_ucm_config *ucm, const char *new_profile, const char *old_profile);
88
89 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);
90
91 void pa_alsa_ucm_add_ports(
92 pa_hashmap **hash,
93 pa_proplist *proplist,
94 pa_alsa_ucm_mapping_context *context,
95 bool is_sink,
96 pa_card *card);
97 void pa_alsa_ucm_add_ports_combination(
98 pa_hashmap *hash,
99 pa_alsa_ucm_mapping_context *context,
100 bool is_sink,
101 pa_hashmap *ports,
102 pa_card_profile *cp,
103 pa_core *core);
104 int pa_alsa_ucm_set_port(pa_alsa_ucm_mapping_context *context, pa_device_port *port, bool is_sink);
105
106 void pa_alsa_ucm_free(pa_alsa_ucm_config *ucm);
107 void pa_alsa_ucm_mapping_context_free(pa_alsa_ucm_mapping_context *context);
108
109 /* UCM - Use Case Manager is available on some audio cards */
110
111 struct pa_alsa_ucm_device {
112 PA_LLIST_FIELDS(pa_alsa_ucm_device);
113
114 pa_proplist *proplist;
115
116 unsigned playback_priority;
117 unsigned capture_priority;
118
119 unsigned playback_channels;
120 unsigned capture_channels;
121
122 pa_alsa_mapping *playback_mapping;
123 pa_alsa_mapping *capture_mapping;
124
125 pa_idxset *conflicting_devices;
126 pa_idxset *supported_devices;
127
128 pa_alsa_jack *input_jack;
129 pa_alsa_jack *output_jack;
130 };
131
132 struct pa_alsa_ucm_modifier {
133 PA_LLIST_FIELDS(pa_alsa_ucm_modifier);
134
135 pa_proplist *proplist;
136
137 int n_confdev;
138 int n_suppdev;
139
140 const char **conflicting_devices;
141 const char **supported_devices;
142
143 pa_direction_t action_direction;
144
145 char *media_role;
146
147 /* Non-NULL if the modifier has its own PlaybackPCM/CapturePCM */
148 pa_alsa_mapping *playback_mapping;
149 pa_alsa_mapping *capture_mapping;
150 };
151
152 struct pa_alsa_ucm_verb {
153 PA_LLIST_FIELDS(pa_alsa_ucm_verb);
154
155 pa_proplist *proplist;
156
157 PA_LLIST_HEAD(pa_alsa_ucm_device, devices);
158 PA_LLIST_HEAD(pa_alsa_ucm_modifier, modifiers);
159 };
160
161 struct pa_alsa_ucm_config {
162 pa_core *core;
163 snd_use_case_mgr_t *ucm_mgr;
164 pa_alsa_ucm_verb *active_verb;
165
166 PA_LLIST_HEAD(pa_alsa_ucm_verb, verbs);
167 PA_LLIST_HEAD(pa_alsa_jack, jacks);
168 };
169
170 struct pa_alsa_ucm_mapping_context {
171 pa_alsa_ucm_config *ucm;
172 pa_direction_t direction;
173
174 pa_idxset *ucm_devices;
175 pa_idxset *ucm_modifiers;
176 };
177
178 #endif