2 * Common code to disable/enable mixer emulation at run time
4 * Copyright (C) 2013 Red Hat, Inc.
6 * Written by Bandan Das <bsd@redhat.com>
7 * with important bits picked up from hda-codec.c
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 or
12 * (at your option) version 3 of the License.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>.
24 * HDA codec descriptions
28 #define QEMU_HDA_ID_OUTPUT ((QEMU_HDA_ID_VENDOR << 16) | 0x12)
29 #define QEMU_HDA_ID_DUPLEX ((QEMU_HDA_ID_VENDOR << 16) | 0x22)
30 #define QEMU_HDA_ID_MICRO ((QEMU_HDA_ID_VENDOR << 16) | 0x32)
31 #define QEMU_HDA_AMP_CAPS \
33 (QEMU_HDA_AMP_STEPS << AC_AMPCAP_OFFSET_SHIFT) | \
34 (QEMU_HDA_AMP_STEPS << AC_AMPCAP_NUM_STEPS_SHIFT) | \
35 (3 << AC_AMPCAP_STEP_SIZE_SHIFT))
37 #define QEMU_HDA_ID_OUTPUT ((QEMU_HDA_ID_VENDOR << 16) | 0x11)
38 #define QEMU_HDA_ID_DUPLEX ((QEMU_HDA_ID_VENDOR << 16) | 0x21)
39 #define QEMU_HDA_ID_MICRO ((QEMU_HDA_ID_VENDOR << 16) | 0x31)
40 #define QEMU_HDA_AMP_CAPS QEMU_HDA_AMP_NONE
44 /* common: audio output widget */
45 static const desc_param
glue(common_params_audio_dac_
, PARAM
)[] = {
47 .id
= AC_PAR_AUDIO_WIDGET_CAP
,
48 .val
= ((AC_WID_AUD_OUT
<< AC_WCAP_TYPE_SHIFT
) |
55 .val
= QEMU_HDA_PCM_FORMATS
,
60 .id
= AC_PAR_AMP_IN_CAP
,
61 .val
= QEMU_HDA_AMP_NONE
,
63 .id
= AC_PAR_AMP_OUT_CAP
,
64 .val
= QEMU_HDA_AMP_CAPS
,
68 /* common: audio input widget */
69 static const desc_param
glue(common_params_audio_adc_
, PARAM
)[] = {
71 .id
= AC_PAR_AUDIO_WIDGET_CAP
,
72 .val
= ((AC_WID_AUD_IN
<< AC_WCAP_TYPE_SHIFT
) |
79 .id
= AC_PAR_CONNLIST_LEN
,
83 .val
= QEMU_HDA_PCM_FORMATS
,
88 .id
= AC_PAR_AMP_IN_CAP
,
89 .val
= QEMU_HDA_AMP_CAPS
,
91 .id
= AC_PAR_AMP_OUT_CAP
,
92 .val
= QEMU_HDA_AMP_NONE
,
96 /* common: pin widget (line-out) */
97 static const desc_param
glue(common_params_audio_lineout_
, PARAM
)[] = {
99 .id
= AC_PAR_AUDIO_WIDGET_CAP
,
100 .val
= ((AC_WID_PIN
<< AC_WCAP_TYPE_SHIFT
) |
104 .id
= AC_PAR_PIN_CAP
,
105 .val
= AC_PINCAP_OUT
,
107 .id
= AC_PAR_CONNLIST_LEN
,
110 .id
= AC_PAR_AMP_IN_CAP
,
111 .val
= QEMU_HDA_AMP_NONE
,
113 .id
= AC_PAR_AMP_OUT_CAP
,
114 .val
= QEMU_HDA_AMP_NONE
,
118 /* common: pin widget (line-in) */
119 static const desc_param
glue(common_params_audio_linein_
, PARAM
)[] = {
121 .id
= AC_PAR_AUDIO_WIDGET_CAP
,
122 .val
= ((AC_WID_PIN
<< AC_WCAP_TYPE_SHIFT
) |
125 .id
= AC_PAR_PIN_CAP
,
128 .id
= AC_PAR_AMP_IN_CAP
,
129 .val
= QEMU_HDA_AMP_NONE
,
131 .id
= AC_PAR_AMP_OUT_CAP
,
132 .val
= QEMU_HDA_AMP_NONE
,
136 /* output: root node */
137 static const desc_param
glue(output_params_root_
, PARAM
)[] = {
139 .id
= AC_PAR_VENDOR_ID
,
140 .val
= QEMU_HDA_ID_OUTPUT
,
142 .id
= AC_PAR_SUBSYSTEM_ID
,
143 .val
= QEMU_HDA_ID_OUTPUT
,
148 .id
= AC_PAR_NODE_COUNT
,
153 /* output: audio function */
154 static const desc_param
glue(output_params_audio_func_
, PARAM
)[] = {
156 .id
= AC_PAR_FUNCTION_TYPE
,
157 .val
= AC_GRP_AUDIO_FUNCTION
,
159 .id
= AC_PAR_SUBSYSTEM_ID
,
160 .val
= QEMU_HDA_ID_OUTPUT
,
162 .id
= AC_PAR_NODE_COUNT
,
166 .val
= QEMU_HDA_PCM_FORMATS
,
169 .val
= AC_SUPFMT_PCM
,
171 .id
= AC_PAR_AMP_IN_CAP
,
172 .val
= QEMU_HDA_AMP_NONE
,
174 .id
= AC_PAR_AMP_OUT_CAP
,
175 .val
= QEMU_HDA_AMP_NONE
,
177 .id
= AC_PAR_GPIO_CAP
,
180 .id
= AC_PAR_AUDIO_FG_CAP
,
183 .id
= AC_PAR_POWER_STATE
,
189 static const desc_node
glue(output_nodes_
, PARAM
)[] = {
193 .params
= glue(output_params_root_
, PARAM
),
194 .nparams
= ARRAY_SIZE(glue(output_params_root_
, PARAM
)),
198 .params
= glue(output_params_audio_func_
, PARAM
),
199 .nparams
= ARRAY_SIZE(glue(output_params_audio_func_
, PARAM
)),
203 .params
= glue(common_params_audio_dac_
, PARAM
),
204 .nparams
= ARRAY_SIZE(glue(common_params_audio_dac_
, PARAM
)),
209 .params
= glue(common_params_audio_lineout_
, PARAM
),
210 .nparams
= ARRAY_SIZE(glue(common_params_audio_lineout_
, PARAM
)),
211 .config
= ((AC_JACK_PORT_COMPLEX
<< AC_DEFCFG_PORT_CONN_SHIFT
) |
212 (AC_JACK_LINE_OUT
<< AC_DEFCFG_DEVICE_SHIFT
) |
213 (AC_JACK_CONN_UNKNOWN
<< AC_DEFCFG_CONN_TYPE_SHIFT
) |
214 (AC_JACK_COLOR_GREEN
<< AC_DEFCFG_COLOR_SHIFT
) |
216 .pinctl
= AC_PINCTL_OUT_EN
,
217 .conn
= (uint32_t[]) { 2 },
222 static const desc_codec
glue(output_
, PARAM
) = {
224 .iid
= QEMU_HDA_ID_OUTPUT
,
225 .nodes
= glue(output_nodes_
, PARAM
),
226 .nnodes
= ARRAY_SIZE(glue(output_nodes_
, PARAM
)),
229 /* duplex: root node */
230 static const desc_param
glue(duplex_params_root_
, PARAM
)[] = {
232 .id
= AC_PAR_VENDOR_ID
,
233 .val
= QEMU_HDA_ID_DUPLEX
,
235 .id
= AC_PAR_SUBSYSTEM_ID
,
236 .val
= QEMU_HDA_ID_DUPLEX
,
241 .id
= AC_PAR_NODE_COUNT
,
246 /* duplex: audio function */
247 static const desc_param
glue(duplex_params_audio_func_
, PARAM
)[] = {
249 .id
= AC_PAR_FUNCTION_TYPE
,
250 .val
= AC_GRP_AUDIO_FUNCTION
,
252 .id
= AC_PAR_SUBSYSTEM_ID
,
253 .val
= QEMU_HDA_ID_DUPLEX
,
255 .id
= AC_PAR_NODE_COUNT
,
259 .val
= QEMU_HDA_PCM_FORMATS
,
262 .val
= AC_SUPFMT_PCM
,
264 .id
= AC_PAR_AMP_IN_CAP
,
265 .val
= QEMU_HDA_AMP_NONE
,
267 .id
= AC_PAR_AMP_OUT_CAP
,
268 .val
= QEMU_HDA_AMP_NONE
,
270 .id
= AC_PAR_GPIO_CAP
,
273 .id
= AC_PAR_AUDIO_FG_CAP
,
276 .id
= AC_PAR_POWER_STATE
,
282 static const desc_node
glue(duplex_nodes_
, PARAM
)[] = {
286 .params
= glue(duplex_params_root_
, PARAM
),
287 .nparams
= ARRAY_SIZE(glue(duplex_params_root_
, PARAM
)),
291 .params
= glue(duplex_params_audio_func_
, PARAM
),
292 .nparams
= ARRAY_SIZE(glue(duplex_params_audio_func_
, PARAM
)),
296 .params
= glue(common_params_audio_dac_
, PARAM
),
297 .nparams
= ARRAY_SIZE(glue(common_params_audio_dac_
, PARAM
)),
302 .params
= glue(common_params_audio_lineout_
, PARAM
),
303 .nparams
= ARRAY_SIZE(glue(common_params_audio_lineout_
, PARAM
)),
304 .config
= ((AC_JACK_PORT_COMPLEX
<< AC_DEFCFG_PORT_CONN_SHIFT
) |
305 (AC_JACK_LINE_OUT
<< AC_DEFCFG_DEVICE_SHIFT
) |
306 (AC_JACK_CONN_UNKNOWN
<< AC_DEFCFG_CONN_TYPE_SHIFT
) |
307 (AC_JACK_COLOR_GREEN
<< AC_DEFCFG_COLOR_SHIFT
) |
309 .pinctl
= AC_PINCTL_OUT_EN
,
310 .conn
= (uint32_t[]) { 2 },
314 .params
= glue(common_params_audio_adc_
, PARAM
),
315 .nparams
= ARRAY_SIZE(glue(common_params_audio_adc_
, PARAM
)),
317 .conn
= (uint32_t[]) { 5 },
321 .params
= glue(common_params_audio_linein_
, PARAM
),
322 .nparams
= ARRAY_SIZE(glue(common_params_audio_linein_
, PARAM
)),
323 .config
= ((AC_JACK_PORT_COMPLEX
<< AC_DEFCFG_PORT_CONN_SHIFT
) |
324 (AC_JACK_LINE_IN
<< AC_DEFCFG_DEVICE_SHIFT
) |
325 (AC_JACK_CONN_UNKNOWN
<< AC_DEFCFG_CONN_TYPE_SHIFT
) |
326 (AC_JACK_COLOR_RED
<< AC_DEFCFG_COLOR_SHIFT
) |
328 .pinctl
= AC_PINCTL_IN_EN
,
333 static const desc_codec
glue(duplex_
, PARAM
) = {
335 .iid
= QEMU_HDA_ID_DUPLEX
,
336 .nodes
= glue(duplex_nodes_
, PARAM
),
337 .nnodes
= ARRAY_SIZE(glue(duplex_nodes_
, PARAM
)),
340 /* micro: root node */
341 static const desc_param
glue(micro_params_root_
, PARAM
)[] = {
343 .id
= AC_PAR_VENDOR_ID
,
344 .val
= QEMU_HDA_ID_MICRO
,
346 .id
= AC_PAR_SUBSYSTEM_ID
,
347 .val
= QEMU_HDA_ID_MICRO
,
352 .id
= AC_PAR_NODE_COUNT
,
357 /* micro: audio function */
358 static const desc_param
glue(micro_params_audio_func_
, PARAM
)[] = {
360 .id
= AC_PAR_FUNCTION_TYPE
,
361 .val
= AC_GRP_AUDIO_FUNCTION
,
363 .id
= AC_PAR_SUBSYSTEM_ID
,
364 .val
= QEMU_HDA_ID_MICRO
,
366 .id
= AC_PAR_NODE_COUNT
,
370 .val
= QEMU_HDA_PCM_FORMATS
,
373 .val
= AC_SUPFMT_PCM
,
375 .id
= AC_PAR_AMP_IN_CAP
,
376 .val
= QEMU_HDA_AMP_NONE
,
378 .id
= AC_PAR_AMP_OUT_CAP
,
379 .val
= QEMU_HDA_AMP_NONE
,
381 .id
= AC_PAR_GPIO_CAP
,
384 .id
= AC_PAR_AUDIO_FG_CAP
,
387 .id
= AC_PAR_POWER_STATE
,
393 static const desc_node
glue(micro_nodes_
, PARAM
)[] = {
397 .params
= glue(micro_params_root_
, PARAM
),
398 .nparams
= ARRAY_SIZE(glue(micro_params_root_
, PARAM
)),
402 .params
= glue(micro_params_audio_func_
, PARAM
),
403 .nparams
= ARRAY_SIZE(glue(micro_params_audio_func_
, PARAM
)),
407 .params
= glue(common_params_audio_dac_
, PARAM
),
408 .nparams
= ARRAY_SIZE(glue(common_params_audio_dac_
, PARAM
)),
413 .params
= glue(common_params_audio_lineout_
, PARAM
),
414 .nparams
= ARRAY_SIZE(glue(common_params_audio_lineout_
, PARAM
)),
415 .config
= ((AC_JACK_PORT_COMPLEX
<< AC_DEFCFG_PORT_CONN_SHIFT
) |
416 (AC_JACK_SPEAKER
<< AC_DEFCFG_DEVICE_SHIFT
) |
417 (AC_JACK_CONN_UNKNOWN
<< AC_DEFCFG_CONN_TYPE_SHIFT
) |
418 (AC_JACK_COLOR_GREEN
<< AC_DEFCFG_COLOR_SHIFT
) |
420 .pinctl
= AC_PINCTL_OUT_EN
,
421 .conn
= (uint32_t[]) { 2 },
425 .params
= glue(common_params_audio_adc_
, PARAM
),
426 .nparams
= ARRAY_SIZE(glue(common_params_audio_adc_
, PARAM
)),
428 .conn
= (uint32_t[]) { 5 },
432 .params
= glue(common_params_audio_linein_
, PARAM
),
433 .nparams
= ARRAY_SIZE(glue(common_params_audio_linein_
, PARAM
)),
434 .config
= ((AC_JACK_PORT_COMPLEX
<< AC_DEFCFG_PORT_CONN_SHIFT
) |
435 (AC_JACK_MIC_IN
<< AC_DEFCFG_DEVICE_SHIFT
) |
436 (AC_JACK_CONN_UNKNOWN
<< AC_DEFCFG_CONN_TYPE_SHIFT
) |
437 (AC_JACK_COLOR_RED
<< AC_DEFCFG_COLOR_SHIFT
) |
439 .pinctl
= AC_PINCTL_IN_EN
,
444 static const desc_codec
glue(micro_
, PARAM
) = {
446 .iid
= QEMU_HDA_ID_MICRO
,
447 .nodes
= glue(micro_nodes_
, PARAM
),
448 .nnodes
= ARRAY_SIZE(glue(micro_nodes_
, PARAM
)),
453 #undef QEMU_HDA_ID_OUTPUT
454 #undef QEMU_HDA_ID_DUPLEX
455 #undef QEMU_HDA_ID_MICRO
456 #undef QEMU_HDA_AMP_CAPS