3 * patch_hdmi.c - routines for HDMI/DisplayPort codecs
5 * Copyright(c) 2008-2010 Intel Corporation. All rights reserved.
6 * Copyright (c) 2006 ATI Technologies Inc.
7 * Copyright (c) 2008 NVIDIA Corp. All rights reserved.
8 * Copyright (c) 2008 Wei Ni <wni@nvidia.com>
11 * Wu Fengguang <wfg@linux.intel.com>
14 * Wu Fengguang <wfg@linux.intel.com>
16 * This program is free software; you can redistribute it and/or modify it
17 * under the terms of the GNU General Public License as published by the Free
18 * Software Foundation; either version 2 of the License, or (at your option)
21 * This program is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software Foundation,
28 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <linux/init.h>
32 #include <linux/delay.h>
33 #include <linux/slab.h>
34 #include <linux/module.h>
35 #include <sound/core.h>
36 #include <sound/jack.h>
37 #include <sound/asoundef.h>
38 #include <sound/tlv.h>
39 #include "hda_codec.h"
40 #include "hda_local.h"
43 static bool static_hdmi_pcm;
44 module_param(static_hdmi_pcm, bool, 0644);
45 MODULE_PARM_DESC(static_hdmi_pcm, "Don't restrict PCM parameters per ELD info");
47 #define is_haswell(codec) ((codec)->vendor_id == 0x80862807)
49 struct hdmi_spec_per_cvt {
52 unsigned int channels_min;
53 unsigned int channels_max;
59 /* max. connections to a widget */
60 #define HDA_MAX_CONNECTIONS 32
62 struct hdmi_spec_per_pin {
65 hda_nid_t mux_nids[HDA_MAX_CONNECTIONS];
68 struct hda_codec *codec;
69 struct hdmi_eld sink_eld;
71 struct delayed_work work;
72 struct snd_kcontrol *eld_ctl;
74 bool setup; /* the stream has been set up by prepare callback */
75 int channels; /* current number of channels */
77 bool chmap_set; /* channel-map override by ALSA API? */
78 unsigned char chmap[8]; /* ALSA API channel-map */
79 char pcm_name[8]; /* filled in build_pcm callbacks */
81 struct snd_info_entry *proc_entry;
87 struct snd_array cvts; /* struct hdmi_spec_per_cvt */
88 hda_nid_t cvt_nids[4]; /* only for haswell fix */
91 struct snd_array pins; /* struct hdmi_spec_per_pin */
92 struct snd_array pcm_rec; /* struct hda_pcm */
93 unsigned int channels_max; /* max over all cvts */
95 struct hdmi_eld temp_eld;
97 * Non-generic ATI/NVIDIA specific
99 struct hda_multi_out multiout;
100 struct hda_pcm_stream pcm_playback;
104 struct hdmi_audio_infoframe {
111 u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */
115 u8 LFEPBL01_LSV36_DM_INH7;
118 struct dp_audio_infoframe {
121 u8 ver; /* 0x11 << 2 */
123 u8 CC02_CT47; /* match with HDMI infoframe from this on */
127 u8 LFEPBL01_LSV36_DM_INH7;
130 union audio_infoframe {
131 struct hdmi_audio_infoframe hdmi;
132 struct dp_audio_infoframe dp;
137 * CEA speaker placement:
140 * FLW FL FLC FC FRC FR FRW
147 * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to
148 * CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC.
150 enum cea_speaker_placement {
151 FL = (1 << 0), /* Front Left */
152 FC = (1 << 1), /* Front Center */
153 FR = (1 << 2), /* Front Right */
154 FLC = (1 << 3), /* Front Left Center */
155 FRC = (1 << 4), /* Front Right Center */
156 RL = (1 << 5), /* Rear Left */
157 RC = (1 << 6), /* Rear Center */
158 RR = (1 << 7), /* Rear Right */
159 RLC = (1 << 8), /* Rear Left Center */
160 RRC = (1 << 9), /* Rear Right Center */
161 LFE = (1 << 10), /* Low Frequency Effect */
162 FLW = (1 << 11), /* Front Left Wide */
163 FRW = (1 << 12), /* Front Right Wide */
164 FLH = (1 << 13), /* Front Left High */
165 FCH = (1 << 14), /* Front Center High */
166 FRH = (1 << 15), /* Front Right High */
167 TC = (1 << 16), /* Top Center */
171 * ELD SA bits in the CEA Speaker Allocation data block
173 static int eld_speaker_allocation_bits[] = {
181 /* the following are not defined in ELD yet */
188 struct cea_channel_speaker_allocation {
192 /* derived values, just for convenience */
200 * surround40 surround41 surround50 surround51 surround71
201 * ch0 front left = = = =
202 * ch1 front right = = = =
203 * ch2 rear left = = = =
204 * ch3 rear right = = = =
205 * ch4 LFE center center center
210 * surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR}
212 static int hdmi_channel_mapping[0x32][8] = {
214 [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
216 [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
218 [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 },
220 [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 },
222 [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 },
224 [0x09] = { 0x00, 0x11, 0x24, 0x35, 0x42, 0xf3, 0xf6, 0xf7 },
226 [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 },
228 [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 },
230 [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 },
234 * This is an ordered list!
236 * The preceding ones have better chances to be selected by
237 * hdmi_channel_allocation().
239 static struct cea_channel_speaker_allocation channel_allocations[] = {
240 /* channel: 7 6 5 4 3 2 1 0 */
241 { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } },
243 { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } },
245 { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } },
247 { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } },
249 { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } },
251 { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } },
253 { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } },
255 { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } },
257 { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } },
259 { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } },
260 { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } },
261 { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } },
262 { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } },
263 { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } },
264 { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } },
265 { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } },
266 { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } },
267 { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } },
268 { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } },
269 { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } },
270 { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } },
271 { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } },
272 { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } },
273 { .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } },
274 { .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } },
275 { .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } },
276 { .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } },
277 { .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } },
278 { .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } },
279 { .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } },
280 { .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } },
281 { .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } },
282 { .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } },
283 { .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } },
284 { .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } },
285 { .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } },
286 { .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } },
287 { .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } },
288 { .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } },
289 { .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } },
290 { .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } },
291 { .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } },
292 { .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } },
293 { .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } },
294 { .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } },
295 { .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } },
296 { .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } },
297 { .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } },
298 { .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } },
299 { .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } },
307 #define get_pin(spec, idx) \
308 ((struct hdmi_spec_per_pin *)snd_array_elem(&spec->pins, idx))
309 #define get_cvt(spec, idx) \
310 ((struct hdmi_spec_per_cvt *)snd_array_elem(&spec->cvts, idx))
311 #define get_pcm_rec(spec, idx) \
312 ((struct hda_pcm *)snd_array_elem(&spec->pcm_rec, idx))
314 static int pin_nid_to_pin_index(struct hdmi_spec *spec, hda_nid_t pin_nid)
318 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++)
319 if (get_pin(spec, pin_idx)->pin_nid == pin_nid)
322 snd_printk(KERN_WARNING "HDMI: pin nid %d not registered\n", pin_nid);
326 static int hinfo_to_pin_index(struct hdmi_spec *spec,
327 struct hda_pcm_stream *hinfo)
331 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++)
332 if (get_pcm_rec(spec, pin_idx)->stream == hinfo)
335 snd_printk(KERN_WARNING "HDMI: hinfo %p not registered\n", hinfo);
339 static int cvt_nid_to_cvt_index(struct hdmi_spec *spec, hda_nid_t cvt_nid)
343 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++)
344 if (get_cvt(spec, cvt_idx)->cvt_nid == cvt_nid)
347 snd_printk(KERN_WARNING "HDMI: cvt nid %d not registered\n", cvt_nid);
351 static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol,
352 struct snd_ctl_elem_info *uinfo)
354 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
355 struct hdmi_spec *spec = codec->spec;
356 struct hdmi_spec_per_pin *per_pin;
357 struct hdmi_eld *eld;
360 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
362 pin_idx = kcontrol->private_value;
363 per_pin = get_pin(spec, pin_idx);
364 eld = &per_pin->sink_eld;
366 mutex_lock(&per_pin->lock);
367 uinfo->count = eld->eld_valid ? eld->eld_size : 0;
368 mutex_unlock(&per_pin->lock);
373 static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
374 struct snd_ctl_elem_value *ucontrol)
376 struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
377 struct hdmi_spec *spec = codec->spec;
378 struct hdmi_spec_per_pin *per_pin;
379 struct hdmi_eld *eld;
382 pin_idx = kcontrol->private_value;
383 per_pin = get_pin(spec, pin_idx);
384 eld = &per_pin->sink_eld;
386 mutex_lock(&per_pin->lock);
387 if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data)) {
388 mutex_unlock(&per_pin->lock);
393 memset(ucontrol->value.bytes.data, 0,
394 ARRAY_SIZE(ucontrol->value.bytes.data));
396 memcpy(ucontrol->value.bytes.data, eld->eld_buffer,
398 mutex_unlock(&per_pin->lock);
403 static struct snd_kcontrol_new eld_bytes_ctl = {
404 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
405 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
407 .info = hdmi_eld_ctl_info,
408 .get = hdmi_eld_ctl_get,
411 static int hdmi_create_eld_ctl(struct hda_codec *codec, int pin_idx,
414 struct snd_kcontrol *kctl;
415 struct hdmi_spec *spec = codec->spec;
418 kctl = snd_ctl_new1(&eld_bytes_ctl, codec);
421 kctl->private_value = pin_idx;
422 kctl->id.device = device;
424 err = snd_hda_ctl_add(codec, get_pin(spec, pin_idx)->pin_nid, kctl);
428 get_pin(spec, pin_idx)->eld_ctl = kctl;
433 static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
434 int *packet_index, int *byte_index)
438 val = snd_hda_codec_read(codec, pin_nid, 0,
439 AC_VERB_GET_HDMI_DIP_INDEX, 0);
441 *packet_index = val >> 5;
442 *byte_index = val & 0x1f;
446 static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
447 int packet_index, int byte_index)
451 val = (packet_index << 5) | (byte_index & 0x1f);
453 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val);
456 static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid,
459 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val);
462 static void hdmi_init_pin(struct hda_codec *codec, hda_nid_t pin_nid)
465 if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
466 snd_hda_codec_write(codec, pin_nid, 0,
467 AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
468 /* Enable pin out: some machines with GM965 gets broken output when
469 * the pin is disabled or changed while using with HDMI
471 snd_hda_codec_write(codec, pin_nid, 0,
472 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
475 static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t cvt_nid)
477 return 1 + snd_hda_codec_read(codec, cvt_nid, 0,
478 AC_VERB_GET_CVT_CHAN_COUNT, 0);
481 static void hdmi_set_channel_count(struct hda_codec *codec,
482 hda_nid_t cvt_nid, int chs)
484 if (chs != hdmi_get_channel_count(codec, cvt_nid))
485 snd_hda_codec_write(codec, cvt_nid, 0,
486 AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
493 #ifdef CONFIG_PROC_FS
494 static void print_eld_info(struct snd_info_entry *entry,
495 struct snd_info_buffer *buffer)
497 struct hdmi_spec_per_pin *per_pin = entry->private_data;
499 mutex_lock(&per_pin->lock);
500 snd_hdmi_print_eld_info(&per_pin->sink_eld, buffer);
501 mutex_unlock(&per_pin->lock);
504 static void write_eld_info(struct snd_info_entry *entry,
505 struct snd_info_buffer *buffer)
507 struct hdmi_spec_per_pin *per_pin = entry->private_data;
509 mutex_lock(&per_pin->lock);
510 snd_hdmi_write_eld_info(&per_pin->sink_eld, buffer);
511 mutex_unlock(&per_pin->lock);
514 static int eld_proc_new(struct hdmi_spec_per_pin *per_pin, int index)
517 struct hda_codec *codec = per_pin->codec;
518 struct snd_info_entry *entry;
521 snprintf(name, sizeof(name), "eld#%d.%d", codec->addr, index);
522 err = snd_card_proc_new(codec->bus->card, name, &entry);
526 snd_info_set_text_ops(entry, per_pin, print_eld_info);
527 entry->c.text.write = write_eld_info;
528 entry->mode |= S_IWUSR;
529 per_pin->proc_entry = entry;
534 static void eld_proc_free(struct hdmi_spec_per_pin *per_pin)
536 if (!per_pin->codec->bus->shutdown && per_pin->proc_entry) {
537 snd_device_free(per_pin->codec->bus->card, per_pin->proc_entry);
538 per_pin->proc_entry = NULL;
542 static inline int eld_proc_new(struct hdmi_spec_per_pin *per_pin,
547 static inline void eld_proc_free(struct hdmi_spec_per_pin *per_pin)
553 * Channel mapping routines
557 * Compute derived values in channel_allocations[].
559 static void init_channel_allocations(void)
562 struct cea_channel_speaker_allocation *p;
564 for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
565 p = channel_allocations + i;
568 for (j = 0; j < ARRAY_SIZE(p->speakers); j++)
569 if (p->speakers[j]) {
571 p->spk_mask |= p->speakers[j];
576 static int get_channel_allocation_order(int ca)
580 for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
581 if (channel_allocations[i].ca_index == ca)
588 * The transformation takes two steps:
590 * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask
591 * spk_mask => (channel_allocations[]) => ai->CA
593 * TODO: it could select the wrong CA from multiple candidates.
595 static int hdmi_channel_allocation(struct hdmi_eld *eld, int channels)
600 char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
603 * CA defaults to 0 for basic stereo audio
609 * expand ELD's speaker allocation mask
611 * ELD tells the speaker mask in a compact(paired) form,
612 * expand ELD's notions to match the ones used by Audio InfoFrame.
614 for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) {
615 if (eld->info.spk_alloc & (1 << i))
616 spk_mask |= eld_speaker_allocation_bits[i];
619 /* search for the first working match in the CA table */
620 for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
621 if (channels == channel_allocations[i].channels &&
622 (spk_mask & channel_allocations[i].spk_mask) ==
623 channel_allocations[i].spk_mask) {
624 ca = channel_allocations[i].ca_index;
630 /* if there was no match, select the regular ALSA channel
631 * allocation with the matching number of channels */
632 for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
633 if (channels == channel_allocations[i].channels) {
634 ca = channel_allocations[i].ca_index;
640 snd_print_channel_allocation(eld->info.spk_alloc, buf, sizeof(buf));
641 snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n",
647 static void hdmi_debug_channel_mapping(struct hda_codec *codec,
650 #ifdef CONFIG_SND_DEBUG_VERBOSE
654 for (i = 0; i < 8; i++) {
655 slot = snd_hda_codec_read(codec, pin_nid, 0,
656 AC_VERB_GET_HDMI_CHAN_SLOT, i);
657 printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n",
658 slot >> 4, slot & 0xf);
664 static void hdmi_std_setup_channel_mapping(struct hda_codec *codec,
669 struct cea_channel_speaker_allocation *ch_alloc;
673 int non_pcm_mapping[8];
675 order = get_channel_allocation_order(ca);
676 ch_alloc = &channel_allocations[order];
678 if (hdmi_channel_mapping[ca][1] == 0) {
680 /* fill actual channel mappings in ALSA channel (i) order */
681 for (i = 0; i < ch_alloc->channels; i++) {
682 while (!ch_alloc->speakers[7 - hdmi_slot] && !WARN_ON(hdmi_slot >= 8))
683 hdmi_slot++; /* skip zero slots */
685 hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++;
687 /* fill the rest of the slots with ALSA channel 0xf */
688 for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++)
689 if (!ch_alloc->speakers[7 - hdmi_slot])
690 hdmi_channel_mapping[ca][i++] = (0xf << 4) | hdmi_slot;
694 for (i = 0; i < ch_alloc->channels; i++)
695 non_pcm_mapping[i] = (i << 4) | i;
697 non_pcm_mapping[i] = (0xf << 4) | i;
700 for (i = 0; i < 8; i++) {
701 err = snd_hda_codec_write(codec, pin_nid, 0,
702 AC_VERB_SET_HDMI_CHAN_SLOT,
703 non_pcm ? non_pcm_mapping[i] : hdmi_channel_mapping[ca][i]);
705 snd_printdd(KERN_NOTICE
706 "HDMI: channel mapping failed\n");
712 struct channel_map_table {
713 unsigned char map; /* ALSA API channel map position */
714 int spk_mask; /* speaker position bit mask */
717 static struct channel_map_table map_tables[] = {
718 { SNDRV_CHMAP_FL, FL },
719 { SNDRV_CHMAP_FR, FR },
720 { SNDRV_CHMAP_RL, RL },
721 { SNDRV_CHMAP_RR, RR },
722 { SNDRV_CHMAP_LFE, LFE },
723 { SNDRV_CHMAP_FC, FC },
724 { SNDRV_CHMAP_RLC, RLC },
725 { SNDRV_CHMAP_RRC, RRC },
726 { SNDRV_CHMAP_RC, RC },
727 { SNDRV_CHMAP_FLC, FLC },
728 { SNDRV_CHMAP_FRC, FRC },
729 { SNDRV_CHMAP_FLH, FLH },
730 { SNDRV_CHMAP_FRH, FRH },
731 { SNDRV_CHMAP_FLW, FLW },
732 { SNDRV_CHMAP_FRW, FRW },
733 { SNDRV_CHMAP_TC, TC },
734 { SNDRV_CHMAP_FCH, FCH },
738 /* from ALSA API channel position to speaker bit mask */
739 static int to_spk_mask(unsigned char c)
741 struct channel_map_table *t = map_tables;
742 for (; t->map; t++) {
749 /* from ALSA API channel position to CEA slot */
750 static int to_cea_slot(int ordered_ca, unsigned char pos)
752 int mask = to_spk_mask(pos);
756 for (i = 0; i < 8; i++) {
757 if (channel_allocations[ordered_ca].speakers[7 - i] == mask)
765 /* from speaker bit mask to ALSA API channel position */
766 static int spk_to_chmap(int spk)
768 struct channel_map_table *t = map_tables;
769 for (; t->map; t++) {
770 if (t->spk_mask == spk)
776 /* from CEA slot to ALSA API channel position */
777 static int from_cea_slot(int ordered_ca, unsigned char slot)
779 int mask = channel_allocations[ordered_ca].speakers[7 - slot];
781 return spk_to_chmap(mask);
784 /* get the CA index corresponding to the given ALSA API channel map */
785 static int hdmi_manual_channel_allocation(int chs, unsigned char *map)
787 int i, spks = 0, spk_mask = 0;
789 for (i = 0; i < chs; i++) {
790 int mask = to_spk_mask(map[i]);
797 for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
798 if ((chs == channel_allocations[i].channels ||
799 spks == channel_allocations[i].channels) &&
800 (spk_mask & channel_allocations[i].spk_mask) ==
801 channel_allocations[i].spk_mask)
802 return channel_allocations[i].ca_index;
807 /* set up the channel slots for the given ALSA API channel map */
808 static int hdmi_manual_setup_channel_mapping(struct hda_codec *codec,
810 int chs, unsigned char *map,
813 int ordered_ca = get_channel_allocation_order(ca);
814 int alsa_pos, hdmi_slot;
815 int assignments[8] = {[0 ... 7] = 0xf};
817 for (alsa_pos = 0; alsa_pos < chs; alsa_pos++) {
819 hdmi_slot = to_cea_slot(ordered_ca, map[alsa_pos]);
822 continue; /* unassigned channel */
824 assignments[hdmi_slot] = alsa_pos;
827 for (hdmi_slot = 0; hdmi_slot < 8; hdmi_slot++) {
830 val = (assignments[hdmi_slot] << 4) | hdmi_slot;
831 err = snd_hda_codec_write(codec, pin_nid, 0,
832 AC_VERB_SET_HDMI_CHAN_SLOT, val);
839 /* store ALSA API channel map from the current default map */
840 static void hdmi_setup_fake_chmap(unsigned char *map, int ca)
843 int ordered_ca = get_channel_allocation_order(ca);
844 for (i = 0; i < 8; i++) {
845 if (i < channel_allocations[ordered_ca].channels)
846 map[i] = from_cea_slot(ordered_ca, hdmi_channel_mapping[ca][i] & 0x0f);
852 static void hdmi_setup_channel_mapping(struct hda_codec *codec,
853 hda_nid_t pin_nid, bool non_pcm, int ca,
854 int channels, unsigned char *map,
857 if (!non_pcm && chmap_set) {
858 hdmi_manual_setup_channel_mapping(codec, pin_nid,
861 hdmi_std_setup_channel_mapping(codec, pin_nid, non_pcm, ca);
862 hdmi_setup_fake_chmap(map, ca);
865 hdmi_debug_channel_mapping(codec, pin_nid);
869 * Audio InfoFrame routines
873 * Enable Audio InfoFrame Transmission
875 static void hdmi_start_infoframe_trans(struct hda_codec *codec,
878 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
879 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
884 * Disable Audio InfoFrame Transmission
886 static void hdmi_stop_infoframe_trans(struct hda_codec *codec,
889 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
890 snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
894 static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid)
896 #ifdef CONFIG_SND_DEBUG_VERBOSE
900 size = snd_hdmi_get_eld_size(codec, pin_nid);
901 printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size);
903 for (i = 0; i < 8; i++) {
904 size = snd_hda_codec_read(codec, pin_nid, 0,
905 AC_VERB_GET_HDMI_DIP_SIZE, i);
906 printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size);
911 static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid)
917 for (i = 0; i < 8; i++) {
918 size = snd_hda_codec_read(codec, pin_nid, 0,
919 AC_VERB_GET_HDMI_DIP_SIZE, i);
923 hdmi_set_dip_index(codec, pin_nid, i, 0x0);
924 for (j = 1; j < 1000; j++) {
925 hdmi_write_dip_byte(codec, pin_nid, 0x0);
926 hdmi_get_dip_index(codec, pin_nid, &pi, &bi);
928 snd_printd(KERN_INFO "dip index %d: %d != %d\n",
930 if (bi == 0) /* byte index wrapped around */
934 "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n",
940 static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *hdmi_ai)
942 u8 *bytes = (u8 *)hdmi_ai;
946 hdmi_ai->checksum = 0;
948 for (i = 0; i < sizeof(*hdmi_ai); i++)
951 hdmi_ai->checksum = -sum;
954 static void hdmi_fill_audio_infoframe(struct hda_codec *codec,
960 hdmi_debug_dip_size(codec, pin_nid);
961 hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */
963 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
964 for (i = 0; i < size; i++)
965 hdmi_write_dip_byte(codec, pin_nid, dip[i]);
968 static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid,
974 if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0)
978 hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
979 for (i = 0; i < size; i++) {
980 val = snd_hda_codec_read(codec, pin_nid, 0,
981 AC_VERB_GET_HDMI_DIP_DATA, 0);
989 static void hdmi_setup_audio_infoframe(struct hda_codec *codec,
990 struct hdmi_spec_per_pin *per_pin,
993 hda_nid_t pin_nid = per_pin->pin_nid;
994 int channels = per_pin->channels;
996 struct hdmi_eld *eld;
998 union audio_infoframe ai;
1003 if (is_haswell(codec))
1004 snd_hda_codec_write(codec, pin_nid, 0,
1005 AC_VERB_SET_AMP_GAIN_MUTE,
1008 eld = &per_pin->sink_eld;
1009 if (!eld->monitor_present)
1012 if (!non_pcm && per_pin->chmap_set)
1013 ca = hdmi_manual_channel_allocation(channels, per_pin->chmap);
1015 ca = hdmi_channel_allocation(eld, channels);
1019 ordered_ca = get_channel_allocation_order(ca);
1020 active_channels = channel_allocations[ordered_ca].channels;
1022 hdmi_set_channel_count(codec, per_pin->cvt_nid, active_channels);
1024 memset(&ai, 0, sizeof(ai));
1025 if (eld->info.conn_type == 0) { /* HDMI */
1026 struct hdmi_audio_infoframe *hdmi_ai = &ai.hdmi;
1028 hdmi_ai->type = 0x84;
1029 hdmi_ai->ver = 0x01;
1030 hdmi_ai->len = 0x0a;
1031 hdmi_ai->CC02_CT47 = active_channels - 1;
1033 hdmi_checksum_audio_infoframe(hdmi_ai);
1034 } else if (eld->info.conn_type == 1) { /* DisplayPort */
1035 struct dp_audio_infoframe *dp_ai = &ai.dp;
1039 dp_ai->ver = 0x11 << 2;
1040 dp_ai->CC02_CT47 = active_channels - 1;
1043 snd_printd("HDMI: unknown connection type at pin %d\n",
1049 * always configure channel mapping, it may have been changed by the
1050 * user in the meantime
1052 hdmi_setup_channel_mapping(codec, pin_nid, non_pcm, ca,
1053 channels, per_pin->chmap,
1054 per_pin->chmap_set);
1057 * sizeof(ai) is used instead of sizeof(*hdmi_ai) or
1058 * sizeof(*dp_ai) to avoid partial match/update problems when
1059 * the user switches between HDMI/DP monitors.
1061 if (!hdmi_infoframe_uptodate(codec, pin_nid, ai.bytes,
1063 snd_printdd("hdmi_setup_audio_infoframe: "
1064 "pin=%d channels=%d ca=0x%02x\n",
1066 active_channels, ca);
1067 hdmi_stop_infoframe_trans(codec, pin_nid);
1068 hdmi_fill_audio_infoframe(codec, pin_nid,
1069 ai.bytes, sizeof(ai));
1070 hdmi_start_infoframe_trans(codec, pin_nid);
1073 per_pin->non_pcm = non_pcm;
1078 * Unsolicited events
1081 static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll);
1083 static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
1085 struct hdmi_spec *spec = codec->spec;
1086 int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
1089 struct hda_jack_tbl *jack;
1090 int dev_entry = (res & AC_UNSOL_RES_DE) >> AC_UNSOL_RES_DE_SHIFT;
1092 jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
1095 pin_nid = jack->nid;
1096 jack->jack_dirty = 1;
1098 _snd_printd(SND_PR_VERBOSE,
1099 "HDMI hot plug event: Codec=%d Pin=%d Device=%d Inactive=%d Presence_Detect=%d ELD_Valid=%d\n",
1100 codec->addr, pin_nid, dev_entry, !!(res & AC_UNSOL_RES_IA),
1101 !!(res & AC_UNSOL_RES_PD), !!(res & AC_UNSOL_RES_ELDV));
1103 pin_idx = pin_nid_to_pin_index(spec, pin_nid);
1107 hdmi_present_sense(get_pin(spec, pin_idx), 1);
1108 snd_hda_jack_report_sync(codec);
1111 static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
1113 int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
1114 int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
1115 int cp_state = !!(res & AC_UNSOL_RES_CP_STATE);
1116 int cp_ready = !!(res & AC_UNSOL_RES_CP_READY);
1119 "HDMI CP event: CODEC=%d TAG=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n",
1134 static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
1136 int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
1137 int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
1139 if (!snd_hda_jack_tbl_get_from_tag(codec, tag)) {
1140 snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag);
1145 hdmi_intrinsic_event(codec, res);
1147 hdmi_non_intrinsic_event(codec, res);
1150 static void haswell_verify_D0(struct hda_codec *codec,
1151 hda_nid_t cvt_nid, hda_nid_t nid)
1155 /* For Haswell, the converter 1/2 may keep in D3 state after bootup,
1156 * thus pins could only choose converter 0 for use. Make sure the
1157 * converters are in correct power state */
1158 if (!snd_hda_check_power_state(codec, cvt_nid, AC_PWRST_D0))
1159 snd_hda_codec_write(codec, cvt_nid, 0, AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
1161 if (!snd_hda_check_power_state(codec, nid, AC_PWRST_D0)) {
1162 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_POWER_STATE,
1165 pwr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_POWER_STATE, 0);
1166 pwr = (pwr & AC_PWRST_ACTUAL) >> AC_PWRST_ACTUAL_SHIFT;
1167 snd_printd("Haswell HDMI audio: Power for pin 0x%x is now D%d\n", nid, pwr);
1175 /* HBR should be Non-PCM, 8 channels */
1176 #define is_hbr_format(format) \
1177 ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7)
1179 static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t cvt_nid,
1180 hda_nid_t pin_nid, u32 stream_tag, int format)
1185 if (is_haswell(codec))
1186 haswell_verify_D0(codec, cvt_nid, pin_nid);
1188 if (snd_hda_query_pin_caps(codec, pin_nid) & AC_PINCAP_HBR) {
1189 pinctl = snd_hda_codec_read(codec, pin_nid, 0,
1190 AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
1192 new_pinctl = pinctl & ~AC_PINCTL_EPT;
1193 if (is_hbr_format(format))
1194 new_pinctl |= AC_PINCTL_EPT_HBR;
1196 new_pinctl |= AC_PINCTL_EPT_NATIVE;
1198 snd_printdd("hdmi_setup_stream: "
1199 "NID=0x%x, %spinctl=0x%x\n",
1201 pinctl == new_pinctl ? "" : "new-",
1204 if (pinctl != new_pinctl)
1205 snd_hda_codec_write(codec, pin_nid, 0,
1206 AC_VERB_SET_PIN_WIDGET_CONTROL,
1210 if (is_hbr_format(format) && !new_pinctl) {
1211 snd_printdd("hdmi_setup_stream: HBR is not supported\n");
1215 snd_hda_codec_setup_stream(codec, cvt_nid, stream_tag, 0, format);
1219 static int hdmi_choose_cvt(struct hda_codec *codec,
1220 int pin_idx, int *cvt_id, int *mux_id)
1222 struct hdmi_spec *spec = codec->spec;
1223 struct hdmi_spec_per_pin *per_pin;
1224 struct hdmi_spec_per_cvt *per_cvt = NULL;
1225 int cvt_idx, mux_idx = 0;
1227 per_pin = get_pin(spec, pin_idx);
1229 /* Dynamically assign converter to stream */
1230 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) {
1231 per_cvt = get_cvt(spec, cvt_idx);
1233 /* Must not already be assigned */
1234 if (per_cvt->assigned)
1236 /* Must be in pin's mux's list of converters */
1237 for (mux_idx = 0; mux_idx < per_pin->num_mux_nids; mux_idx++)
1238 if (per_pin->mux_nids[mux_idx] == per_cvt->cvt_nid)
1240 /* Not in mux list */
1241 if (mux_idx == per_pin->num_mux_nids)
1246 /* No free converters */
1247 if (cvt_idx == spec->num_cvts)
1258 static void haswell_config_cvts(struct hda_codec *codec,
1259 hda_nid_t pin_nid, int mux_idx)
1261 struct hdmi_spec *spec = codec->spec;
1262 hda_nid_t nid, end_nid;
1264 struct hdmi_spec_per_cvt *per_cvt;
1266 /* configure all pins, including "no physical connection" ones */
1267 end_nid = codec->start_nid + codec->num_nodes;
1268 for (nid = codec->start_nid; nid < end_nid; nid++) {
1269 unsigned int wid_caps = get_wcaps(codec, nid);
1270 unsigned int wid_type = get_wcaps_type(wid_caps);
1272 if (wid_type != AC_WID_PIN)
1278 curr = snd_hda_codec_read(codec, nid, 0,
1279 AC_VERB_GET_CONNECT_SEL, 0);
1280 if (curr != mux_idx)
1283 /* choose an unassigned converter. The conveters in the
1284 * connection list are in the same order as in the codec.
1286 for (cvt_idx = 0; cvt_idx < spec->num_cvts; cvt_idx++) {
1287 per_cvt = get_cvt(spec, cvt_idx);
1288 if (!per_cvt->assigned) {
1289 snd_printdd("choose cvt %d for pin nid %d\n",
1291 snd_hda_codec_write_cache(codec, nid, 0,
1292 AC_VERB_SET_CONNECT_SEL,
1303 static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
1304 struct hda_codec *codec,
1305 struct snd_pcm_substream *substream)
1307 struct hdmi_spec *spec = codec->spec;
1308 struct snd_pcm_runtime *runtime = substream->runtime;
1309 int pin_idx, cvt_idx, mux_idx = 0;
1310 struct hdmi_spec_per_pin *per_pin;
1311 struct hdmi_eld *eld;
1312 struct hdmi_spec_per_cvt *per_cvt = NULL;
1315 /* Validate hinfo */
1316 pin_idx = hinfo_to_pin_index(spec, hinfo);
1317 if (snd_BUG_ON(pin_idx < 0))
1319 per_pin = get_pin(spec, pin_idx);
1320 eld = &per_pin->sink_eld;
1322 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx, &mux_idx);
1326 per_cvt = get_cvt(spec, cvt_idx);
1327 /* Claim converter */
1328 per_cvt->assigned = 1;
1329 per_pin->cvt_nid = per_cvt->cvt_nid;
1330 hinfo->nid = per_cvt->cvt_nid;
1332 snd_hda_codec_write_cache(codec, per_pin->pin_nid, 0,
1333 AC_VERB_SET_CONNECT_SEL,
1336 /* configure unused pins to choose other converters */
1337 if (is_haswell(codec))
1338 haswell_config_cvts(codec, per_pin->pin_nid, mux_idx);
1340 snd_hda_spdif_ctls_assign(codec, pin_idx, per_cvt->cvt_nid);
1342 /* Initially set the converter's capabilities */
1343 hinfo->channels_min = per_cvt->channels_min;
1344 hinfo->channels_max = per_cvt->channels_max;
1345 hinfo->rates = per_cvt->rates;
1346 hinfo->formats = per_cvt->formats;
1347 hinfo->maxbps = per_cvt->maxbps;
1349 /* Restrict capabilities by ELD if this isn't disabled */
1350 if (!static_hdmi_pcm && eld->eld_valid) {
1351 snd_hdmi_eld_update_pcm_info(&eld->info, hinfo);
1352 if (hinfo->channels_min > hinfo->channels_max ||
1353 !hinfo->rates || !hinfo->formats) {
1354 per_cvt->assigned = 0;
1356 snd_hda_spdif_ctls_unassign(codec, pin_idx);
1361 /* Store the updated parameters */
1362 runtime->hw.channels_min = hinfo->channels_min;
1363 runtime->hw.channels_max = hinfo->channels_max;
1364 runtime->hw.formats = hinfo->formats;
1365 runtime->hw.rates = hinfo->rates;
1367 snd_pcm_hw_constraint_step(substream->runtime, 0,
1368 SNDRV_PCM_HW_PARAM_CHANNELS, 2);
1373 * HDA/HDMI auto parsing
1375 static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)
1377 struct hdmi_spec *spec = codec->spec;
1378 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1379 hda_nid_t pin_nid = per_pin->pin_nid;
1381 if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
1382 snd_printk(KERN_WARNING
1383 "HDMI: pin %d wcaps %#x "
1384 "does not support connection list\n",
1385 pin_nid, get_wcaps(codec, pin_nid));
1389 per_pin->num_mux_nids = snd_hda_get_connections(codec, pin_nid,
1391 HDA_MAX_CONNECTIONS);
1396 static void hdmi_present_sense(struct hdmi_spec_per_pin *per_pin, int repoll)
1398 struct hda_codec *codec = per_pin->codec;
1399 struct hdmi_spec *spec = codec->spec;
1400 struct hdmi_eld *eld = &spec->temp_eld;
1401 struct hdmi_eld *pin_eld = &per_pin->sink_eld;
1402 hda_nid_t pin_nid = per_pin->pin_nid;
1404 * Always execute a GetPinSense verb here, even when called from
1405 * hdmi_intrinsic_event; for some NVIDIA HW, the unsolicited
1406 * response's PD bit is not the real PD value, but indicates that
1407 * the real PD value changed. An older version of the HD-audio
1408 * specification worked this way. Hence, we just ignore the data in
1409 * the unsolicited response to avoid custom WARs.
1411 int present = snd_hda_pin_sense(codec, pin_nid);
1412 bool update_eld = false;
1413 bool eld_changed = false;
1415 mutex_lock(&per_pin->lock);
1416 pin_eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
1417 if (pin_eld->monitor_present)
1418 eld->eld_valid = !!(present & AC_PINSENSE_ELDV);
1420 eld->eld_valid = false;
1422 _snd_printd(SND_PR_VERBOSE,
1423 "HDMI status: Codec=%d Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
1424 codec->addr, pin_nid, pin_eld->monitor_present, eld->eld_valid);
1426 if (eld->eld_valid) {
1427 if (snd_hdmi_get_eld(codec, pin_nid, eld->eld_buffer,
1428 &eld->eld_size) < 0)
1429 eld->eld_valid = false;
1431 memset(&eld->info, 0, sizeof(struct parsed_hdmi_eld));
1432 if (snd_hdmi_parse_eld(&eld->info, eld->eld_buffer,
1434 eld->eld_valid = false;
1437 if (eld->eld_valid) {
1438 snd_hdmi_show_eld(&eld->info);
1442 queue_delayed_work(codec->bus->workq,
1444 msecs_to_jiffies(300));
1449 if (pin_eld->eld_valid && !eld->eld_valid) {
1454 bool old_eld_valid = pin_eld->eld_valid;
1455 pin_eld->eld_valid = eld->eld_valid;
1456 eld_changed = pin_eld->eld_size != eld->eld_size ||
1457 memcmp(pin_eld->eld_buffer, eld->eld_buffer,
1458 eld->eld_size) != 0;
1460 memcpy(pin_eld->eld_buffer, eld->eld_buffer,
1462 pin_eld->eld_size = eld->eld_size;
1463 pin_eld->info = eld->info;
1465 /* Haswell-specific workaround: re-setup when the transcoder is
1466 * changed during the stream playback
1468 if (is_haswell(codec) &&
1469 eld->eld_valid && !old_eld_valid && per_pin->setup)
1470 hdmi_setup_audio_infoframe(codec, per_pin,
1475 snd_ctl_notify(codec->bus->card,
1476 SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO,
1477 &per_pin->eld_ctl->id);
1479 mutex_unlock(&per_pin->lock);
1482 static void hdmi_repoll_eld(struct work_struct *work)
1484 struct hdmi_spec_per_pin *per_pin =
1485 container_of(to_delayed_work(work), struct hdmi_spec_per_pin, work);
1487 if (per_pin->repoll_count++ > 6)
1488 per_pin->repoll_count = 0;
1490 hdmi_present_sense(per_pin, per_pin->repoll_count);
1493 static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
1496 static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
1498 struct hdmi_spec *spec = codec->spec;
1499 unsigned int caps, config;
1501 struct hdmi_spec_per_pin *per_pin;
1504 caps = snd_hda_query_pin_caps(codec, pin_nid);
1505 if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP)))
1508 config = snd_hda_codec_get_pincfg(codec, pin_nid);
1509 if (get_defcfg_connect(config) == AC_JACK_PORT_NONE)
1512 if (is_haswell(codec))
1513 intel_haswell_fixup_connect_list(codec, pin_nid);
1515 pin_idx = spec->num_pins;
1516 per_pin = snd_array_new(&spec->pins);
1520 per_pin->pin_nid = pin_nid;
1521 per_pin->non_pcm = false;
1523 err = hdmi_read_pin_conn(codec, pin_idx);
1532 static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
1534 struct hdmi_spec *spec = codec->spec;
1535 struct hdmi_spec_per_cvt *per_cvt;
1539 chans = get_wcaps(codec, cvt_nid);
1540 chans = get_wcaps_channels(chans);
1542 per_cvt = snd_array_new(&spec->cvts);
1546 per_cvt->cvt_nid = cvt_nid;
1547 per_cvt->channels_min = 2;
1549 per_cvt->channels_max = chans;
1550 if (chans > spec->channels_max)
1551 spec->channels_max = chans;
1554 err = snd_hda_query_supported_pcm(codec, cvt_nid,
1561 if (spec->num_cvts < ARRAY_SIZE(spec->cvt_nids))
1562 spec->cvt_nids[spec->num_cvts] = cvt_nid;
1568 static int hdmi_parse_codec(struct hda_codec *codec)
1573 nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
1574 if (!nid || nodes < 0) {
1575 snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n");
1579 for (i = 0; i < nodes; i++, nid++) {
1583 caps = get_wcaps(codec, nid);
1584 type = get_wcaps_type(caps);
1586 if (!(caps & AC_WCAP_DIGITAL))
1590 case AC_WID_AUD_OUT:
1591 hdmi_add_cvt(codec, nid);
1594 hdmi_add_pin(codec, nid);
1600 /* We're seeing some problems with unsolicited hot plug events on
1601 * PantherPoint after S3, if this is not enabled */
1602 if (codec->vendor_id == 0x80862806)
1603 codec->bus->power_keep_link_on = 1;
1605 * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event
1606 * can be lost and presence sense verb will become inaccurate if the
1607 * HDA link is powered off at hot plug or hw initialization time.
1609 else if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) &
1611 codec->bus->power_keep_link_on = 1;
1619 static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
1621 struct hda_spdif_out *spdif;
1624 mutex_lock(&codec->spdif_mutex);
1625 spdif = snd_hda_spdif_out_of_nid(codec, cvt_nid);
1626 non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO);
1627 mutex_unlock(&codec->spdif_mutex);
1636 static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1637 struct hda_codec *codec,
1638 unsigned int stream_tag,
1639 unsigned int format,
1640 struct snd_pcm_substream *substream)
1642 hda_nid_t cvt_nid = hinfo->nid;
1643 struct hdmi_spec *spec = codec->spec;
1644 int pin_idx = hinfo_to_pin_index(spec, hinfo);
1645 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1646 hda_nid_t pin_nid = per_pin->pin_nid;
1649 non_pcm = check_non_pcm_per_cvt(codec, cvt_nid);
1650 mutex_lock(&per_pin->lock);
1651 per_pin->channels = substream->runtime->channels;
1652 per_pin->setup = true;
1654 hdmi_setup_audio_infoframe(codec, per_pin, non_pcm);
1655 mutex_unlock(&per_pin->lock);
1657 return hdmi_setup_stream(codec, cvt_nid, pin_nid, stream_tag, format);
1660 static int generic_hdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
1661 struct hda_codec *codec,
1662 struct snd_pcm_substream *substream)
1664 snd_hda_codec_cleanup_stream(codec, hinfo->nid);
1668 static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
1669 struct hda_codec *codec,
1670 struct snd_pcm_substream *substream)
1672 struct hdmi_spec *spec = codec->spec;
1673 int cvt_idx, pin_idx;
1674 struct hdmi_spec_per_cvt *per_cvt;
1675 struct hdmi_spec_per_pin *per_pin;
1678 cvt_idx = cvt_nid_to_cvt_index(spec, hinfo->nid);
1679 if (snd_BUG_ON(cvt_idx < 0))
1681 per_cvt = get_cvt(spec, cvt_idx);
1683 snd_BUG_ON(!per_cvt->assigned);
1684 per_cvt->assigned = 0;
1687 pin_idx = hinfo_to_pin_index(spec, hinfo);
1688 if (snd_BUG_ON(pin_idx < 0))
1690 per_pin = get_pin(spec, pin_idx);
1692 snd_hda_spdif_ctls_unassign(codec, pin_idx);
1694 mutex_lock(&per_pin->lock);
1695 per_pin->chmap_set = false;
1696 memset(per_pin->chmap, 0, sizeof(per_pin->chmap));
1698 per_pin->setup = false;
1699 per_pin->channels = 0;
1700 mutex_unlock(&per_pin->lock);
1706 static const struct hda_pcm_ops generic_ops = {
1707 .open = hdmi_pcm_open,
1708 .close = hdmi_pcm_close,
1709 .prepare = generic_hdmi_playback_pcm_prepare,
1710 .cleanup = generic_hdmi_playback_pcm_cleanup,
1714 * ALSA API channel-map control callbacks
1716 static int hdmi_chmap_ctl_info(struct snd_kcontrol *kcontrol,
1717 struct snd_ctl_elem_info *uinfo)
1719 struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
1720 struct hda_codec *codec = info->private_data;
1721 struct hdmi_spec *spec = codec->spec;
1722 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1723 uinfo->count = spec->channels_max;
1724 uinfo->value.integer.min = 0;
1725 uinfo->value.integer.max = SNDRV_CHMAP_LAST;
1729 static int hdmi_chmap_ctl_tlv(struct snd_kcontrol *kcontrol, int op_flag,
1730 unsigned int size, unsigned int __user *tlv)
1732 struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
1733 struct hda_codec *codec = info->private_data;
1734 struct hdmi_spec *spec = codec->spec;
1735 unsigned int __user *dst;
1740 if (put_user(SNDRV_CTL_TLVT_CONTAINER, tlv))
1744 for (chs = 2; chs <= spec->channels_max; chs++) {
1746 struct cea_channel_speaker_allocation *cap;
1747 cap = channel_allocations;
1748 for (i = 0; i < ARRAY_SIZE(channel_allocations); i++, cap++) {
1749 int chs_bytes = chs * 4;
1750 if (cap->channels != chs)
1754 if (put_user(SNDRV_CTL_TLVT_CHMAP_VAR, dst) ||
1755 put_user(chs_bytes, dst + 1))
1760 if (size < chs_bytes)
1764 for (c = 7; c >= 0; c--) {
1765 int spk = cap->speakers[c];
1768 if (put_user(spk_to_chmap(spk), dst))
1774 if (put_user(count, tlv + 1))
1779 static int hdmi_chmap_ctl_get(struct snd_kcontrol *kcontrol,
1780 struct snd_ctl_elem_value *ucontrol)
1782 struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
1783 struct hda_codec *codec = info->private_data;
1784 struct hdmi_spec *spec = codec->spec;
1785 int pin_idx = kcontrol->private_value;
1786 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1789 for (i = 0; i < ARRAY_SIZE(per_pin->chmap); i++)
1790 ucontrol->value.integer.value[i] = per_pin->chmap[i];
1794 static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol,
1795 struct snd_ctl_elem_value *ucontrol)
1797 struct snd_pcm_chmap *info = snd_kcontrol_chip(kcontrol);
1798 struct hda_codec *codec = info->private_data;
1799 struct hdmi_spec *spec = codec->spec;
1800 int pin_idx = kcontrol->private_value;
1801 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1802 unsigned int ctl_idx;
1803 struct snd_pcm_substream *substream;
1804 unsigned char chmap[8];
1805 int i, ca, prepared = 0;
1807 ctl_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
1808 substream = snd_pcm_chmap_substream(info, ctl_idx);
1809 if (!substream || !substream->runtime)
1810 return 0; /* just for avoiding error from alsactl restore */
1811 switch (substream->runtime->status->state) {
1812 case SNDRV_PCM_STATE_OPEN:
1813 case SNDRV_PCM_STATE_SETUP:
1815 case SNDRV_PCM_STATE_PREPARED:
1821 memset(chmap, 0, sizeof(chmap));
1822 for (i = 0; i < ARRAY_SIZE(chmap); i++)
1823 chmap[i] = ucontrol->value.integer.value[i];
1824 if (!memcmp(chmap, per_pin->chmap, sizeof(chmap)))
1826 ca = hdmi_manual_channel_allocation(ARRAY_SIZE(chmap), chmap);
1829 mutex_lock(&per_pin->lock);
1830 per_pin->chmap_set = true;
1831 memcpy(per_pin->chmap, chmap, sizeof(chmap));
1833 hdmi_setup_audio_infoframe(codec, per_pin, per_pin->non_pcm);
1834 mutex_unlock(&per_pin->lock);
1839 static int generic_hdmi_build_pcms(struct hda_codec *codec)
1841 struct hdmi_spec *spec = codec->spec;
1844 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
1845 struct hda_pcm *info;
1846 struct hda_pcm_stream *pstr;
1847 struct hdmi_spec_per_pin *per_pin;
1849 per_pin = get_pin(spec, pin_idx);
1850 sprintf(per_pin->pcm_name, "HDMI %d", pin_idx);
1851 info = snd_array_new(&spec->pcm_rec);
1854 info->name = per_pin->pcm_name;
1855 info->pcm_type = HDA_PCM_TYPE_HDMI;
1856 info->own_chmap = true;
1858 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
1859 pstr->substreams = 1;
1860 pstr->ops = generic_ops;
1861 /* other pstr fields are set in open */
1864 codec->num_pcms = spec->num_pins;
1865 codec->pcm_info = spec->pcm_rec.list;
1870 static int generic_hdmi_build_jack(struct hda_codec *codec, int pin_idx)
1872 char hdmi_str[32] = "HDMI/DP";
1873 struct hdmi_spec *spec = codec->spec;
1874 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1875 int pcmdev = get_pcm_rec(spec, pin_idx)->device;
1878 sprintf(hdmi_str + strlen(hdmi_str), ",pcm=%d", pcmdev);
1879 if (!is_jack_detectable(codec, per_pin->pin_nid))
1880 strncat(hdmi_str, " Phantom",
1881 sizeof(hdmi_str) - strlen(hdmi_str) - 1);
1883 return snd_hda_jack_add_kctl(codec, per_pin->pin_nid, hdmi_str, 0);
1886 static int generic_hdmi_build_controls(struct hda_codec *codec)
1888 struct hdmi_spec *spec = codec->spec;
1892 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
1893 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1895 err = generic_hdmi_build_jack(codec, pin_idx);
1899 err = snd_hda_create_dig_out_ctls(codec,
1901 per_pin->mux_nids[0],
1905 snd_hda_spdif_ctls_unassign(codec, pin_idx);
1907 /* add control for ELD Bytes */
1908 err = hdmi_create_eld_ctl(codec, pin_idx,
1909 get_pcm_rec(spec, pin_idx)->device);
1914 hdmi_present_sense(per_pin, 0);
1917 /* add channel maps */
1918 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
1919 struct snd_pcm_chmap *chmap;
1920 struct snd_kcontrol *kctl;
1923 if (!codec->pcm_info[pin_idx].pcm)
1925 err = snd_pcm_add_chmap_ctls(codec->pcm_info[pin_idx].pcm,
1926 SNDRV_PCM_STREAM_PLAYBACK,
1927 NULL, 0, pin_idx, &chmap);
1930 /* override handlers */
1931 chmap->private_data = codec;
1933 for (i = 0; i < kctl->count; i++)
1934 kctl->vd[i].access |= SNDRV_CTL_ELEM_ACCESS_WRITE;
1935 kctl->info = hdmi_chmap_ctl_info;
1936 kctl->get = hdmi_chmap_ctl_get;
1937 kctl->put = hdmi_chmap_ctl_put;
1938 kctl->tlv.c = hdmi_chmap_ctl_tlv;
1944 static int generic_hdmi_init_per_pins(struct hda_codec *codec)
1946 struct hdmi_spec *spec = codec->spec;
1949 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
1950 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1952 per_pin->codec = codec;
1953 mutex_init(&per_pin->lock);
1954 INIT_DELAYED_WORK(&per_pin->work, hdmi_repoll_eld);
1955 eld_proc_new(per_pin, pin_idx);
1960 static int generic_hdmi_init(struct hda_codec *codec)
1962 struct hdmi_spec *spec = codec->spec;
1965 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
1966 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1967 hda_nid_t pin_nid = per_pin->pin_nid;
1969 hdmi_init_pin(codec, pin_nid);
1970 snd_hda_jack_detect_enable(codec, pin_nid, pin_nid);
1975 static void hdmi_array_init(struct hdmi_spec *spec, int nums)
1977 snd_array_init(&spec->pins, sizeof(struct hdmi_spec_per_pin), nums);
1978 snd_array_init(&spec->cvts, sizeof(struct hdmi_spec_per_cvt), nums);
1979 snd_array_init(&spec->pcm_rec, sizeof(struct hda_pcm), nums);
1982 static void hdmi_array_free(struct hdmi_spec *spec)
1984 snd_array_free(&spec->pins);
1985 snd_array_free(&spec->cvts);
1986 snd_array_free(&spec->pcm_rec);
1989 static void generic_hdmi_free(struct hda_codec *codec)
1991 struct hdmi_spec *spec = codec->spec;
1994 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
1995 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
1997 cancel_delayed_work(&per_pin->work);
1998 eld_proc_free(per_pin);
2001 flush_workqueue(codec->bus->workq);
2002 hdmi_array_free(spec);
2007 static int generic_hdmi_resume(struct hda_codec *codec)
2009 struct hdmi_spec *spec = codec->spec;
2012 generic_hdmi_init(codec);
2013 snd_hda_codec_resume_amp(codec);
2014 snd_hda_codec_resume_cache(codec);
2016 for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) {
2017 struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx);
2018 hdmi_present_sense(per_pin, 1);
2024 static const struct hda_codec_ops generic_hdmi_patch_ops = {
2025 .init = generic_hdmi_init,
2026 .free = generic_hdmi_free,
2027 .build_pcms = generic_hdmi_build_pcms,
2028 .build_controls = generic_hdmi_build_controls,
2029 .unsol_event = hdmi_unsol_event,
2031 .resume = generic_hdmi_resume,
2036 static void intel_haswell_fixup_connect_list(struct hda_codec *codec,
2039 struct hdmi_spec *spec = codec->spec;
2043 nconns = snd_hda_get_connections(codec, nid, conns, ARRAY_SIZE(conns));
2044 if (nconns == spec->num_cvts &&
2045 !memcmp(conns, spec->cvt_nids, spec->num_cvts * sizeof(hda_nid_t)))
2048 /* override pins connection list */
2049 snd_printdd("hdmi: haswell: override pin connection 0x%x\n", nid);
2050 snd_hda_override_conn_list(codec, nid, spec->num_cvts, spec->cvt_nids);
2053 #define INTEL_VENDOR_NID 0x08
2054 #define INTEL_GET_VENDOR_VERB 0xf81
2055 #define INTEL_SET_VENDOR_VERB 0x781
2056 #define INTEL_EN_DP12 0x02 /* enable DP 1.2 features */
2057 #define INTEL_EN_ALL_PIN_CVTS 0x01 /* enable 2nd & 3rd pins and convertors */
2059 static void intel_haswell_enable_all_pins(struct hda_codec *codec,
2062 unsigned int vendor_param;
2064 vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0,
2065 INTEL_GET_VENDOR_VERB, 0);
2066 if (vendor_param == -1 || vendor_param & INTEL_EN_ALL_PIN_CVTS)
2069 vendor_param |= INTEL_EN_ALL_PIN_CVTS;
2070 vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0,
2071 INTEL_SET_VENDOR_VERB, vendor_param);
2072 if (vendor_param == -1)
2076 snd_hda_codec_update_widgets(codec);
2079 static void intel_haswell_fixup_enable_dp12(struct hda_codec *codec)
2081 unsigned int vendor_param;
2083 vendor_param = snd_hda_codec_read(codec, INTEL_VENDOR_NID, 0,
2084 INTEL_GET_VENDOR_VERB, 0);
2085 if (vendor_param == -1 || vendor_param & INTEL_EN_DP12)
2088 /* enable DP1.2 mode */
2089 vendor_param |= INTEL_EN_DP12;
2090 snd_hda_codec_write_cache(codec, INTEL_VENDOR_NID, 0,
2091 INTEL_SET_VENDOR_VERB, vendor_param);
2094 /* Haswell needs to re-issue the vendor-specific verbs before turning to D0.
2095 * Otherwise you may get severe h/w communication errors.
2097 static void haswell_set_power_state(struct hda_codec *codec, hda_nid_t fg,
2098 unsigned int power_state)
2100 if (power_state == AC_PWRST_D0) {
2101 intel_haswell_enable_all_pins(codec, false);
2102 intel_haswell_fixup_enable_dp12(codec);
2105 snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE, power_state);
2106 snd_hda_codec_set_power_to_all(codec, fg, power_state);
2109 static int patch_generic_hdmi(struct hda_codec *codec)
2111 struct hdmi_spec *spec;
2113 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2118 hdmi_array_init(spec, 4);
2120 if (is_haswell(codec)) {
2121 intel_haswell_enable_all_pins(codec, true);
2122 intel_haswell_fixup_enable_dp12(codec);
2125 if (hdmi_parse_codec(codec) < 0) {
2130 codec->patch_ops = generic_hdmi_patch_ops;
2131 if (is_haswell(codec)) {
2132 codec->patch_ops.set_power_state = haswell_set_power_state;
2133 codec->dp_mst = true;
2136 generic_hdmi_init_per_pins(codec);
2138 init_channel_allocations();
2144 * Shared non-generic implementations
2147 static int simple_playback_build_pcms(struct hda_codec *codec)
2149 struct hdmi_spec *spec = codec->spec;
2150 struct hda_pcm *info;
2152 struct hda_pcm_stream *pstr;
2153 struct hdmi_spec_per_cvt *per_cvt;
2155 per_cvt = get_cvt(spec, 0);
2156 chans = get_wcaps(codec, per_cvt->cvt_nid);
2157 chans = get_wcaps_channels(chans);
2159 info = snd_array_new(&spec->pcm_rec);
2162 info->name = get_pin(spec, 0)->pcm_name;
2163 sprintf(info->name, "HDMI 0");
2164 info->pcm_type = HDA_PCM_TYPE_HDMI;
2165 pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
2166 *pstr = spec->pcm_playback;
2167 pstr->nid = per_cvt->cvt_nid;
2168 if (pstr->channels_max <= 2 && chans && chans <= 16)
2169 pstr->channels_max = chans;
2171 codec->num_pcms = 1;
2172 codec->pcm_info = info;
2177 /* unsolicited event for jack sensing */
2178 static void simple_hdmi_unsol_event(struct hda_codec *codec,
2181 snd_hda_jack_set_dirty_all(codec);
2182 snd_hda_jack_report_sync(codec);
2185 /* generic_hdmi_build_jack can be used for simple_hdmi, too,
2186 * as long as spec->pins[] is set correctly
2188 #define simple_hdmi_build_jack generic_hdmi_build_jack
2190 static int simple_playback_build_controls(struct hda_codec *codec)
2192 struct hdmi_spec *spec = codec->spec;
2193 struct hdmi_spec_per_cvt *per_cvt;
2196 per_cvt = get_cvt(spec, 0);
2197 err = snd_hda_create_spdif_out_ctls(codec, per_cvt->cvt_nid,
2201 return simple_hdmi_build_jack(codec, 0);
2204 static int simple_playback_init(struct hda_codec *codec)
2206 struct hdmi_spec *spec = codec->spec;
2207 struct hdmi_spec_per_pin *per_pin = get_pin(spec, 0);
2208 hda_nid_t pin = per_pin->pin_nid;
2210 snd_hda_codec_write(codec, pin, 0,
2211 AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
2212 /* some codecs require to unmute the pin */
2213 if (get_wcaps(codec, pin) & AC_WCAP_OUT_AMP)
2214 snd_hda_codec_write(codec, pin, 0, AC_VERB_SET_AMP_GAIN_MUTE,
2216 snd_hda_jack_detect_enable(codec, pin, pin);
2220 static void simple_playback_free(struct hda_codec *codec)
2222 struct hdmi_spec *spec = codec->spec;
2224 hdmi_array_free(spec);
2229 * Nvidia specific implementations
2232 #define Nv_VERB_SET_Channel_Allocation 0xF79
2233 #define Nv_VERB_SET_Info_Frame_Checksum 0xF7A
2234 #define Nv_VERB_SET_Audio_Protection_On 0xF98
2235 #define Nv_VERB_SET_Audio_Protection_Off 0xF99
2237 #define nvhdmi_master_con_nid_7x 0x04
2238 #define nvhdmi_master_pin_nid_7x 0x05
2240 static const hda_nid_t nvhdmi_con_nids_7x[4] = {
2241 /*front, rear, clfe, rear_surr */
2245 static const struct hda_verb nvhdmi_basic_init_7x_2ch[] = {
2246 /* set audio protect on */
2247 { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
2248 /* enable digital output on pin widget */
2249 { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
2253 static const struct hda_verb nvhdmi_basic_init_7x_8ch[] = {
2254 /* set audio protect on */
2255 { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
2256 /* enable digital output on pin widget */
2257 { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
2258 { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
2259 { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
2260 { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
2261 { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
2265 #ifdef LIMITED_RATE_FMT_SUPPORT
2266 /* support only the safe format and rate */
2267 #define SUPPORTED_RATES SNDRV_PCM_RATE_48000
2268 #define SUPPORTED_MAXBPS 16
2269 #define SUPPORTED_FORMATS SNDRV_PCM_FMTBIT_S16_LE
2271 /* support all rates and formats */
2272 #define SUPPORTED_RATES \
2273 (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
2274 SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\
2275 SNDRV_PCM_RATE_192000)
2276 #define SUPPORTED_MAXBPS 24
2277 #define SUPPORTED_FORMATS \
2278 (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
2281 static int nvhdmi_7x_init_2ch(struct hda_codec *codec)
2283 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_2ch);
2287 static int nvhdmi_7x_init_8ch(struct hda_codec *codec)
2289 snd_hda_sequence_write(codec, nvhdmi_basic_init_7x_8ch);
2293 static unsigned int channels_2_6_8[] = {
2297 static unsigned int channels_2_8[] = {
2301 static struct snd_pcm_hw_constraint_list hw_constraints_2_6_8_channels = {
2302 .count = ARRAY_SIZE(channels_2_6_8),
2303 .list = channels_2_6_8,
2307 static struct snd_pcm_hw_constraint_list hw_constraints_2_8_channels = {
2308 .count = ARRAY_SIZE(channels_2_8),
2309 .list = channels_2_8,
2313 static int simple_playback_pcm_open(struct hda_pcm_stream *hinfo,
2314 struct hda_codec *codec,
2315 struct snd_pcm_substream *substream)
2317 struct hdmi_spec *spec = codec->spec;
2318 struct snd_pcm_hw_constraint_list *hw_constraints_channels = NULL;
2320 switch (codec->preset->id) {
2325 hw_constraints_channels = &hw_constraints_2_8_channels;
2328 hw_constraints_channels = &hw_constraints_2_6_8_channels;
2334 if (hw_constraints_channels != NULL) {
2335 snd_pcm_hw_constraint_list(substream->runtime, 0,
2336 SNDRV_PCM_HW_PARAM_CHANNELS,
2337 hw_constraints_channels);
2339 snd_pcm_hw_constraint_step(substream->runtime, 0,
2340 SNDRV_PCM_HW_PARAM_CHANNELS, 2);
2343 return snd_hda_multi_out_dig_open(codec, &spec->multiout);
2346 static int simple_playback_pcm_close(struct hda_pcm_stream *hinfo,
2347 struct hda_codec *codec,
2348 struct snd_pcm_substream *substream)
2350 struct hdmi_spec *spec = codec->spec;
2351 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2354 static int simple_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2355 struct hda_codec *codec,
2356 unsigned int stream_tag,
2357 unsigned int format,
2358 struct snd_pcm_substream *substream)
2360 struct hdmi_spec *spec = codec->spec;
2361 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
2362 stream_tag, format, substream);
2365 static const struct hda_pcm_stream simple_pcm_playback = {
2370 .open = simple_playback_pcm_open,
2371 .close = simple_playback_pcm_close,
2372 .prepare = simple_playback_pcm_prepare
2376 static const struct hda_codec_ops simple_hdmi_patch_ops = {
2377 .build_controls = simple_playback_build_controls,
2378 .build_pcms = simple_playback_build_pcms,
2379 .init = simple_playback_init,
2380 .free = simple_playback_free,
2381 .unsol_event = simple_hdmi_unsol_event,
2384 static int patch_simple_hdmi(struct hda_codec *codec,
2385 hda_nid_t cvt_nid, hda_nid_t pin_nid)
2387 struct hdmi_spec *spec;
2388 struct hdmi_spec_per_cvt *per_cvt;
2389 struct hdmi_spec_per_pin *per_pin;
2391 spec = kzalloc(sizeof(*spec), GFP_KERNEL);
2396 hdmi_array_init(spec, 1);
2398 spec->multiout.num_dacs = 0; /* no analog */
2399 spec->multiout.max_channels = 2;
2400 spec->multiout.dig_out_nid = cvt_nid;
2403 per_pin = snd_array_new(&spec->pins);
2404 per_cvt = snd_array_new(&spec->cvts);
2405 if (!per_pin || !per_cvt) {
2406 simple_playback_free(codec);
2409 per_cvt->cvt_nid = cvt_nid;
2410 per_pin->pin_nid = pin_nid;
2411 spec->pcm_playback = simple_pcm_playback;
2413 codec->patch_ops = simple_hdmi_patch_ops;
2418 static void nvhdmi_8ch_7x_set_info_frame_parameters(struct hda_codec *codec,
2421 unsigned int chanmask;
2422 int chan = channels ? (channels - 1) : 1;
2441 /* Set the audio infoframe channel allocation and checksum fields. The
2442 * channel count is computed implicitly by the hardware. */
2443 snd_hda_codec_write(codec, 0x1, 0,
2444 Nv_VERB_SET_Channel_Allocation, chanmask);
2446 snd_hda_codec_write(codec, 0x1, 0,
2447 Nv_VERB_SET_Info_Frame_Checksum,
2448 (0x71 - chan - chanmask));
2451 static int nvhdmi_8ch_7x_pcm_close(struct hda_pcm_stream *hinfo,
2452 struct hda_codec *codec,
2453 struct snd_pcm_substream *substream)
2455 struct hdmi_spec *spec = codec->spec;
2458 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x,
2459 0, AC_VERB_SET_CHANNEL_STREAMID, 0);
2460 for (i = 0; i < 4; i++) {
2461 /* set the stream id */
2462 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0,
2463 AC_VERB_SET_CHANNEL_STREAMID, 0);
2464 /* set the stream format */
2465 snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0,
2466 AC_VERB_SET_STREAM_FORMAT, 0);
2469 /* The audio hardware sends a channel count of 0x7 (8ch) when all the
2470 * streams are disabled. */
2471 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8);
2473 return snd_hda_multi_out_dig_close(codec, &spec->multiout);
2476 static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,
2477 struct hda_codec *codec,
2478 unsigned int stream_tag,
2479 unsigned int format,
2480 struct snd_pcm_substream *substream)
2483 unsigned int dataDCC2, channel_id;
2485 struct hdmi_spec *spec = codec->spec;
2486 struct hda_spdif_out *spdif;
2487 struct hdmi_spec_per_cvt *per_cvt;
2489 mutex_lock(&codec->spdif_mutex);
2490 per_cvt = get_cvt(spec, 0);
2491 spdif = snd_hda_spdif_out_of_nid(codec, per_cvt->cvt_nid);
2493 chs = substream->runtime->channels;
2497 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
2498 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE))
2499 snd_hda_codec_write(codec,
2500 nvhdmi_master_con_nid_7x,
2502 AC_VERB_SET_DIGI_CONVERT_1,
2503 spdif->ctls & ~AC_DIG1_ENABLE & 0xff);
2505 /* set the stream id */
2506 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
2507 AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0);
2509 /* set the stream format */
2510 snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
2511 AC_VERB_SET_STREAM_FORMAT, format);
2513 /* turn on again (if needed) */
2514 /* enable and set the channel status audio/data flag */
2515 if (codec->spdif_status_reset && (spdif->ctls & AC_DIG1_ENABLE)) {
2516 snd_hda_codec_write(codec,
2517 nvhdmi_master_con_nid_7x,
2519 AC_VERB_SET_DIGI_CONVERT_1,
2520 spdif->ctls & 0xff);
2521 snd_hda_codec_write(codec,
2522 nvhdmi_master_con_nid_7x,
2524 AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);
2527 for (i = 0; i < 4; i++) {
2533 /* turn off SPDIF once;
2534 *otherwise the IEC958 bits won't be updated
2536 if (codec->spdif_status_reset &&
2537 (spdif->ctls & AC_DIG1_ENABLE))
2538 snd_hda_codec_write(codec,
2539 nvhdmi_con_nids_7x[i],
2541 AC_VERB_SET_DIGI_CONVERT_1,
2542 spdif->ctls & ~AC_DIG1_ENABLE & 0xff);
2543 /* set the stream id */
2544 snd_hda_codec_write(codec,
2545 nvhdmi_con_nids_7x[i],
2547 AC_VERB_SET_CHANNEL_STREAMID,
2548 (stream_tag << 4) | channel_id);
2549 /* set the stream format */
2550 snd_hda_codec_write(codec,
2551 nvhdmi_con_nids_7x[i],
2553 AC_VERB_SET_STREAM_FORMAT,
2555 /* turn on again (if needed) */
2556 /* enable and set the channel status audio/data flag */
2557 if (codec->spdif_status_reset &&
2558 (spdif->ctls & AC_DIG1_ENABLE)) {
2559 snd_hda_codec_write(codec,
2560 nvhdmi_con_nids_7x[i],
2562 AC_VERB_SET_DIGI_CONVERT_1,
2563 spdif->ctls & 0xff);
2564 snd_hda_codec_write(codec,
2565 nvhdmi_con_nids_7x[i],
2567 AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);
2571 nvhdmi_8ch_7x_set_info_frame_parameters(codec, chs);
2573 mutex_unlock(&codec->spdif_mutex);
2577 static const struct hda_pcm_stream nvhdmi_pcm_playback_8ch_7x = {
2581 .nid = nvhdmi_master_con_nid_7x,
2582 .rates = SUPPORTED_RATES,
2583 .maxbps = SUPPORTED_MAXBPS,
2584 .formats = SUPPORTED_FORMATS,
2586 .open = simple_playback_pcm_open,
2587 .close = nvhdmi_8ch_7x_pcm_close,
2588 .prepare = nvhdmi_8ch_7x_pcm_prepare
2592 static int patch_nvhdmi_2ch(struct hda_codec *codec)
2594 struct hdmi_spec *spec;
2595 int err = patch_simple_hdmi(codec, nvhdmi_master_con_nid_7x,
2596 nvhdmi_master_pin_nid_7x);
2600 codec->patch_ops.init = nvhdmi_7x_init_2ch;
2601 /* override the PCM rates, etc, as the codec doesn't give full list */
2603 spec->pcm_playback.rates = SUPPORTED_RATES;
2604 spec->pcm_playback.maxbps = SUPPORTED_MAXBPS;
2605 spec->pcm_playback.formats = SUPPORTED_FORMATS;
2609 static int nvhdmi_7x_8ch_build_pcms(struct hda_codec *codec)
2611 struct hdmi_spec *spec = codec->spec;
2612 int err = simple_playback_build_pcms(codec);
2614 struct hda_pcm *info = get_pcm_rec(spec, 0);
2615 info->own_chmap = true;
2620 static int nvhdmi_7x_8ch_build_controls(struct hda_codec *codec)
2622 struct hdmi_spec *spec = codec->spec;
2623 struct hda_pcm *info;
2624 struct snd_pcm_chmap *chmap;
2627 err = simple_playback_build_controls(codec);
2631 /* add channel maps */
2632 info = get_pcm_rec(spec, 0);
2633 err = snd_pcm_add_chmap_ctls(info->pcm,
2634 SNDRV_PCM_STREAM_PLAYBACK,
2635 snd_pcm_alt_chmaps, 8, 0, &chmap);
2638 switch (codec->preset->id) {
2643 chmap->channel_mask = (1U << 2) | (1U << 8);
2646 chmap->channel_mask = (1U << 2) | (1U << 6) | (1U << 8);
2651 static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
2653 struct hdmi_spec *spec;
2654 int err = patch_nvhdmi_2ch(codec);
2658 spec->multiout.max_channels = 8;
2659 spec->pcm_playback = nvhdmi_pcm_playback_8ch_7x;
2660 codec->patch_ops.init = nvhdmi_7x_init_8ch;
2661 codec->patch_ops.build_pcms = nvhdmi_7x_8ch_build_pcms;
2662 codec->patch_ops.build_controls = nvhdmi_7x_8ch_build_controls;
2664 /* Initialize the audio infoframe channel mask and checksum to something
2666 nvhdmi_8ch_7x_set_info_frame_parameters(codec, 8);
2672 * ATI-specific implementations
2674 * FIXME: we may omit the whole this and use the generic code once after
2675 * it's confirmed to work.
2678 #define ATIHDMI_CVT_NID 0x02 /* audio converter */
2679 #define ATIHDMI_PIN_NID 0x03 /* HDMI output pin */
2681 static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
2682 struct hda_codec *codec,
2683 unsigned int stream_tag,
2684 unsigned int format,
2685 struct snd_pcm_substream *substream)
2687 struct hdmi_spec *spec = codec->spec;
2688 struct hdmi_spec_per_cvt *per_cvt = get_cvt(spec, 0);
2689 int chans = substream->runtime->channels;
2692 err = simple_playback_pcm_prepare(hinfo, codec, stream_tag, format,
2696 snd_hda_codec_write(codec, per_cvt->cvt_nid, 0,
2697 AC_VERB_SET_CVT_CHAN_COUNT, chans - 1);
2699 for (i = 0; i < chans; i++) {
2700 snd_hda_codec_write(codec, per_cvt->cvt_nid, 0,
2701 AC_VERB_SET_HDMI_CHAN_SLOT,
2707 static int patch_atihdmi(struct hda_codec *codec)
2709 struct hdmi_spec *spec;
2710 int err = patch_simple_hdmi(codec, ATIHDMI_CVT_NID, ATIHDMI_PIN_NID);
2714 spec->pcm_playback.ops.prepare = atihdmi_playback_pcm_prepare;
2718 /* VIA HDMI Implementation */
2719 #define VIAHDMI_CVT_NID 0x02 /* audio converter1 */
2720 #define VIAHDMI_PIN_NID 0x03 /* HDMI output pin1 */
2722 static int patch_via_hdmi(struct hda_codec *codec)
2724 return patch_simple_hdmi(codec, VIAHDMI_CVT_NID, VIAHDMI_PIN_NID);
2730 static const struct hda_codec_preset snd_hda_preset_hdmi[] = {
2731 { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi },
2732 { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi },
2733 { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi },
2734 { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_generic_hdmi },
2735 { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_generic_hdmi },
2736 { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_generic_hdmi },
2737 { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_generic_hdmi },
2738 { .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
2739 { .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
2740 { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
2741 { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
2742 { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x },
2743 { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_generic_hdmi },
2744 { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_generic_hdmi },
2745 { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_generic_hdmi },
2746 { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_generic_hdmi },
2747 { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_generic_hdmi },
2748 { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_generic_hdmi },
2749 { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_generic_hdmi },
2750 { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_generic_hdmi },
2751 { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_generic_hdmi },
2752 { .id = 0x10de0015, .name = "GPU 15 HDMI/DP", .patch = patch_generic_hdmi },
2753 { .id = 0x10de0016, .name = "GPU 16 HDMI/DP", .patch = patch_generic_hdmi },
2754 /* 17 is known to be absent */
2755 { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_generic_hdmi },
2756 { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_generic_hdmi },
2757 { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_generic_hdmi },
2758 { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_generic_hdmi },
2759 { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_generic_hdmi },
2760 { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_generic_hdmi },
2761 { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_generic_hdmi },
2762 { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_generic_hdmi },
2763 { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_generic_hdmi },
2764 { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_generic_hdmi },
2765 { .id = 0x10de0051, .name = "GPU 51 HDMI/DP", .patch = patch_generic_hdmi },
2766 { .id = 0x10de0060, .name = "GPU 60 HDMI/DP", .patch = patch_generic_hdmi },
2767 { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
2768 { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
2769 { .id = 0x11069f80, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi },
2770 { .id = 0x11069f81, .name = "VX900 HDMI/DP", .patch = patch_via_hdmi },
2771 { .id = 0x11069f84, .name = "VX11 HDMI/DP", .patch = patch_generic_hdmi },
2772 { .id = 0x11069f85, .name = "VX11 HDMI/DP", .patch = patch_generic_hdmi },
2773 { .id = 0x80860054, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi },
2774 { .id = 0x80862801, .name = "Bearlake HDMI", .patch = patch_generic_hdmi },
2775 { .id = 0x80862802, .name = "Cantiga HDMI", .patch = patch_generic_hdmi },
2776 { .id = 0x80862803, .name = "Eaglelake HDMI", .patch = patch_generic_hdmi },
2777 { .id = 0x80862804, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi },
2778 { .id = 0x80862805, .name = "CougarPoint HDMI", .patch = patch_generic_hdmi },
2779 { .id = 0x80862806, .name = "PantherPoint HDMI", .patch = patch_generic_hdmi },
2780 { .id = 0x80862807, .name = "Haswell HDMI", .patch = patch_generic_hdmi },
2781 { .id = 0x80862880, .name = "CedarTrail HDMI", .patch = patch_generic_hdmi },
2782 { .id = 0x80862882, .name = "Valleyview2 HDMI", .patch = patch_generic_hdmi },
2783 { .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi },
2787 MODULE_ALIAS("snd-hda-codec-id:1002793c");
2788 MODULE_ALIAS("snd-hda-codec-id:10027919");
2789 MODULE_ALIAS("snd-hda-codec-id:1002791a");
2790 MODULE_ALIAS("snd-hda-codec-id:1002aa01");
2791 MODULE_ALIAS("snd-hda-codec-id:10951390");
2792 MODULE_ALIAS("snd-hda-codec-id:10951392");
2793 MODULE_ALIAS("snd-hda-codec-id:10de0002");
2794 MODULE_ALIAS("snd-hda-codec-id:10de0003");
2795 MODULE_ALIAS("snd-hda-codec-id:10de0005");
2796 MODULE_ALIAS("snd-hda-codec-id:10de0006");
2797 MODULE_ALIAS("snd-hda-codec-id:10de0007");
2798 MODULE_ALIAS("snd-hda-codec-id:10de000a");
2799 MODULE_ALIAS("snd-hda-codec-id:10de000b");
2800 MODULE_ALIAS("snd-hda-codec-id:10de000c");
2801 MODULE_ALIAS("snd-hda-codec-id:10de000d");
2802 MODULE_ALIAS("snd-hda-codec-id:10de0010");
2803 MODULE_ALIAS("snd-hda-codec-id:10de0011");
2804 MODULE_ALIAS("snd-hda-codec-id:10de0012");
2805 MODULE_ALIAS("snd-hda-codec-id:10de0013");
2806 MODULE_ALIAS("snd-hda-codec-id:10de0014");
2807 MODULE_ALIAS("snd-hda-codec-id:10de0015");
2808 MODULE_ALIAS("snd-hda-codec-id:10de0016");
2809 MODULE_ALIAS("snd-hda-codec-id:10de0018");
2810 MODULE_ALIAS("snd-hda-codec-id:10de0019");
2811 MODULE_ALIAS("snd-hda-codec-id:10de001a");
2812 MODULE_ALIAS("snd-hda-codec-id:10de001b");
2813 MODULE_ALIAS("snd-hda-codec-id:10de001c");
2814 MODULE_ALIAS("snd-hda-codec-id:10de0040");
2815 MODULE_ALIAS("snd-hda-codec-id:10de0041");
2816 MODULE_ALIAS("snd-hda-codec-id:10de0042");
2817 MODULE_ALIAS("snd-hda-codec-id:10de0043");
2818 MODULE_ALIAS("snd-hda-codec-id:10de0044");
2819 MODULE_ALIAS("snd-hda-codec-id:10de0051");
2820 MODULE_ALIAS("snd-hda-codec-id:10de0060");
2821 MODULE_ALIAS("snd-hda-codec-id:10de0067");
2822 MODULE_ALIAS("snd-hda-codec-id:10de8001");
2823 MODULE_ALIAS("snd-hda-codec-id:11069f80");
2824 MODULE_ALIAS("snd-hda-codec-id:11069f81");
2825 MODULE_ALIAS("snd-hda-codec-id:11069f84");
2826 MODULE_ALIAS("snd-hda-codec-id:11069f85");
2827 MODULE_ALIAS("snd-hda-codec-id:17e80047");
2828 MODULE_ALIAS("snd-hda-codec-id:80860054");
2829 MODULE_ALIAS("snd-hda-codec-id:80862801");
2830 MODULE_ALIAS("snd-hda-codec-id:80862802");
2831 MODULE_ALIAS("snd-hda-codec-id:80862803");
2832 MODULE_ALIAS("snd-hda-codec-id:80862804");
2833 MODULE_ALIAS("snd-hda-codec-id:80862805");
2834 MODULE_ALIAS("snd-hda-codec-id:80862806");
2835 MODULE_ALIAS("snd-hda-codec-id:80862807");
2836 MODULE_ALIAS("snd-hda-codec-id:80862880");
2837 MODULE_ALIAS("snd-hda-codec-id:80862882");
2838 MODULE_ALIAS("snd-hda-codec-id:808629fb");
2840 MODULE_LICENSE("GPL");
2841 MODULE_DESCRIPTION("HDMI HD-audio codec");
2842 MODULE_ALIAS("snd-hda-codec-intelhdmi");
2843 MODULE_ALIAS("snd-hda-codec-nvhdmi");
2844 MODULE_ALIAS("snd-hda-codec-atihdmi");
2846 static struct hda_codec_preset_list intel_list = {
2847 .preset = snd_hda_preset_hdmi,
2848 .owner = THIS_MODULE,
2851 static int __init patch_hdmi_init(void)
2853 return snd_hda_add_codec_preset(&intel_list);
2856 static void __exit patch_hdmi_exit(void)
2858 snd_hda_delete_codec_preset(&intel_list);
2861 module_init(patch_hdmi_init)
2862 module_exit(patch_hdmi_exit)