Merge branch 'topic/hda' into for-linus

+1142 -905
+1 -1
sound/pci/hda/Kconfig
··· 157 158 config SND_HDA_ELD 159 def_bool y 160 - depends on SND_HDA_CODEC_INTELHDMI 161 162 config SND_HDA_CODEC_CIRRUS 163 bool "Build Cirrus Logic codec support"
··· 157 158 config SND_HDA_ELD 159 def_bool y 160 + depends on SND_HDA_CODEC_INTELHDMI || SND_HDA_CODEC_NVHDMI 161 162 config SND_HDA_CODEC_CIRRUS 163 bool "Build Cirrus Logic codec support"
+2 -2
sound/pci/hda/Makefile
··· 3 snd-hda-codec-y := hda_codec.o 4 snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o 5 snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o 6 - # snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o 7 snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 8 snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o 9 ··· 18 snd-hda-codec-conexant-objs := patch_conexant.o 19 snd-hda-codec-via-objs := patch_via.o 20 snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o 21 - snd-hda-codec-intelhdmi-objs := patch_intelhdmi.o hda_eld.o 22 23 # common driver 24 obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o
··· 3 snd-hda-codec-y := hda_codec.o 4 snd-hda-codec-$(CONFIG_SND_HDA_GENERIC) += hda_generic.o 5 snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o 6 + snd-hda-codec-$(CONFIG_SND_HDA_ELD) += hda_eld.o 7 snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o 8 snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o 9 ··· 18 snd-hda-codec-conexant-objs := patch_conexant.o 19 snd-hda-codec-via-objs := patch_via.o 20 snd-hda-codec-nvhdmi-objs := patch_nvhdmi.o 21 + snd-hda-codec-intelhdmi-objs := patch_intelhdmi.o 22 23 # common driver 24 obj-$(CONFIG_SND_HDA_INTEL) := snd-hda-codec.o
+38 -31
sound/pci/hda/hda_codec.c
··· 978 * 979 * Returns 0 if successful, or a negative error code. 980 */ 981 - int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, 982 - struct hda_codec **codecp) 983 { 984 struct hda_codec *codec; 985 char component[31]; ··· 1187 */ 1188 1189 /* FIXME: more better hash key? */ 1190 - #define HDA_HASH_KEY(nid,dir,idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) 1191 #define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24)) 1192 #define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24)) 1193 #define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24)) ··· 1357 if (!codec->no_trigger_sense) { 1358 pincap = snd_hda_query_pin_caps(codec, nid); 1359 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ 1360 - snd_hda_codec_read(codec, nid, 0, AC_VERB_SET_PIN_SENSE, 0); 1361 } 1362 return snd_hda_codec_read(codec, nid, 0, 1363 AC_VERB_GET_PIN_SENSE, 0); ··· 1374 */ 1375 int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid) 1376 { 1377 - u32 sense = snd_hda_pin_sense(codec, nid); 1378 - return !!(sense & AC_PINSENSE_PRESENCE); 1379 } 1380 EXPORT_SYMBOL_HDA(snd_hda_jack_detect); 1381 ··· 1954 err = snd_hda_ctl_add(codec, 0, kctl); 1955 if (err < 0) 1956 return err; 1957 - 1958 for (s = slaves; *s; s++) { 1959 struct snd_kcontrol *sctl; 1960 int i = 0; ··· 2441 { 2442 .access = SNDRV_CTL_ELEM_ACCESS_READ, 2443 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2444 - .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,CON_MASK), 2445 .info = snd_hda_spdif_mask_info, 2446 .get = snd_hda_spdif_cmask_get, 2447 }, 2448 { 2449 .access = SNDRV_CTL_ELEM_ACCESS_READ, 2450 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2451 - .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,PRO_MASK), 2452 .info = snd_hda_spdif_mask_info, 2453 .get = snd_hda_spdif_pmask_get, 2454 }, 2455 { 2456 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2457 - .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), 2458 .info = snd_hda_spdif_mask_info, 2459 .get = snd_hda_spdif_default_get, 2460 .put = snd_hda_spdif_default_put, 2461 }, 2462 { 2463 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2464 - .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,SWITCH), 2465 .info = snd_hda_spdif_out_switch_info, 2466 .get = snd_hda_spdif_out_switch_get, 2467 .put = snd_hda_spdif_out_switch_put, ··· 2612 static struct snd_kcontrol_new dig_in_ctls[] = { 2613 { 2614 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2615 - .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,SWITCH), 2616 .info = snd_hda_spdif_in_switch_info, 2617 .get = snd_hda_spdif_in_switch_get, 2618 .put = snd_hda_spdif_in_switch_put, ··· 2620 { 2621 .access = SNDRV_CTL_ELEM_ACCESS_READ, 2622 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2623 - .name = SNDRV_CTL_NAME_IEC958("",CAPTURE,DEFAULT), 2624 .info = snd_hda_spdif_mask_info, 2625 .get = snd_hda_spdif_in_status_get, 2626 }, ··· 2885 int err = snd_hda_codec_build_controls(codec); 2886 if (err < 0) { 2887 printk(KERN_ERR "hda_codec: cannot build controls" 2888 - "for #%d (error %d)\n", codec->addr, err); 2889 err = snd_hda_codec_reset(codec); 2890 if (err < 0) { 2891 printk(KERN_ERR ··· 2981 val |= channels - 1; 2982 2983 switch (snd_pcm_format_width(format)) { 2984 - case 8: val |= 0x00; break; 2985 - case 16: val |= 0x10; break; 2986 case 20: 2987 case 24: 2988 case 32: ··· 3304 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) 3305 return audio_idx[type][i]; 3306 3307 - snd_printk(KERN_WARNING "Too many %s devices\n", snd_hda_pcm_type_name[type]); 3308 return -EAGAIN; 3309 } 3310 ··· 3343 err = codec->patch_ops.build_pcms(codec); 3344 if (err < 0) { 3345 printk(KERN_ERR "hda_codec: cannot build PCMs" 3346 - "for #%d (error %d)\n", codec->addr, err); 3347 err = snd_hda_codec_reset(codec); 3348 if (err < 0) { 3349 printk(KERN_ERR ··· 3473 3474 /** 3475 * snd_hda_check_board_codec_sid_config - compare the current codec 3476 - subsystem ID with the 3477 - config table 3478 3479 This is important for Gateway notebooks with SB450 HDA Audio 3480 where the vendor ID of the PCI device is: ··· 3614 * 3615 * Increment the power-up counter and power up the hardware really when 3616 * not turned on yet. 3617 - */ 3618 void snd_hda_power_up(struct hda_codec *codec) 3619 { 3620 struct hda_bus *bus = codec->bus; ··· 3643 * 3644 * Decrement the power-up counter and schedules the power-off work if 3645 * the counter rearches to zero. 3646 - */ 3647 void snd_hda_power_down(struct hda_codec *codec) 3648 { 3649 --codec->power_count; ··· 3669 * 3670 * This function is supposed to be set or called from the check_power_status 3671 * patch ops. 3672 - */ 3673 int snd_hda_check_amp_list_power(struct hda_codec *codec, 3674 struct hda_loopback_check *check, 3675 hda_nid_t nid) ··· 3837 { 3838 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ 3839 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) 3840 - set_dig_out_convert(codec, nid, 3841 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff, 3842 -1); 3843 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); ··· 4096 /* 4097 * Sort an associated group of pins according to their sequence numbers. 4098 */ 4099 - static void sort_pins_by_sequence(hda_nid_t * pins, short * sequences, 4100 int num_pins) 4101 { 4102 int i, j; 4103 short seq; 4104 hda_nid_t nid; 4105 - 4106 for (i = 0; i < num_pins; i++) { 4107 for (j = i + 1; j < num_pins; j++) { 4108 if (sequences[i] > sequences[j]) { ··· 4130 * is detected, one of speaker of HP pins is assigned as the primary 4131 * output, i.e. to line_out_pins[0]. So, line_outs is always positive 4132 * if any analog output exists. 4133 - * 4134 * The analog input pins are assigned to input_pins array. 4135 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, 4136 * respectively. ··· 4193 case AC_JACK_SPEAKER: 4194 seq = get_defcfg_sequence(def_conf); 4195 assoc = get_defcfg_association(def_conf); 4196 - if (! assoc) 4197 continue; 4198 - if (! assoc_speaker) 4199 assoc_speaker = assoc; 4200 else if (assoc_speaker != assoc) 4201 continue; ··· 4293 cfg->speaker_outs); 4294 sort_pins_by_sequence(cfg->hp_pins, sequences_hp, 4295 cfg->hp_outs); 4296 - 4297 /* if we have only one mic, make it AUTO_PIN_MIC */ 4298 if (!cfg->input_pins[AUTO_PIN_MIC] && 4299 cfg->input_pins[AUTO_PIN_FRONT_MIC]) { ··· 4443 /** 4444 * snd_array_new - get a new element from the given array 4445 * @array: the array object 4446 - * 4447 * Get a new element from the given array. If it exceeds the 4448 * pre-allocated array size, re-allocate the array. 4449 *
··· 978 * 979 * Returns 0 if successful, or a negative error code. 980 */ 981 + int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, 982 + unsigned int codec_addr, 983 + struct hda_codec **codecp) 984 { 985 struct hda_codec *codec; 986 char component[31]; ··· 1186 */ 1187 1188 /* FIXME: more better hash key? */ 1189 + #define HDA_HASH_KEY(nid, dir, idx) (u32)((nid) + ((idx) << 16) + ((dir) << 24)) 1190 #define HDA_HASH_PINCAP_KEY(nid) (u32)((nid) + (0x02 << 24)) 1191 #define HDA_HASH_PARPCM_KEY(nid) (u32)((nid) + (0x03 << 24)) 1192 #define HDA_HASH_PARSTR_KEY(nid) (u32)((nid) + (0x04 << 24)) ··· 1356 if (!codec->no_trigger_sense) { 1357 pincap = snd_hda_query_pin_caps(codec, nid); 1358 if (pincap & AC_PINCAP_TRIG_REQ) /* need trigger? */ 1359 + snd_hda_codec_read(codec, nid, 0, 1360 + AC_VERB_SET_PIN_SENSE, 0); 1361 } 1362 return snd_hda_codec_read(codec, nid, 0, 1363 AC_VERB_GET_PIN_SENSE, 0); ··· 1372 */ 1373 int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid) 1374 { 1375 + u32 sense = snd_hda_pin_sense(codec, nid); 1376 + return !!(sense & AC_PINSENSE_PRESENCE); 1377 } 1378 EXPORT_SYMBOL_HDA(snd_hda_jack_detect); 1379 ··· 1952 err = snd_hda_ctl_add(codec, 0, kctl); 1953 if (err < 0) 1954 return err; 1955 + 1956 for (s = slaves; *s; s++) { 1957 struct snd_kcontrol *sctl; 1958 int i = 0; ··· 2439 { 2440 .access = SNDRV_CTL_ELEM_ACCESS_READ, 2441 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2442 + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, CON_MASK), 2443 .info = snd_hda_spdif_mask_info, 2444 .get = snd_hda_spdif_cmask_get, 2445 }, 2446 { 2447 .access = SNDRV_CTL_ELEM_ACCESS_READ, 2448 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2449 + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PRO_MASK), 2450 .info = snd_hda_spdif_mask_info, 2451 .get = snd_hda_spdif_pmask_get, 2452 }, 2453 { 2454 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2455 + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT), 2456 .info = snd_hda_spdif_mask_info, 2457 .get = snd_hda_spdif_default_get, 2458 .put = snd_hda_spdif_default_put, 2459 }, 2460 { 2461 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2462 + .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, SWITCH), 2463 .info = snd_hda_spdif_out_switch_info, 2464 .get = snd_hda_spdif_out_switch_get, 2465 .put = snd_hda_spdif_out_switch_put, ··· 2610 static struct snd_kcontrol_new dig_in_ctls[] = { 2611 { 2612 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2613 + .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, SWITCH), 2614 .info = snd_hda_spdif_in_switch_info, 2615 .get = snd_hda_spdif_in_switch_get, 2616 .put = snd_hda_spdif_in_switch_put, ··· 2618 { 2619 .access = SNDRV_CTL_ELEM_ACCESS_READ, 2620 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 2621 + .name = SNDRV_CTL_NAME_IEC958("", CAPTURE, DEFAULT), 2622 .info = snd_hda_spdif_mask_info, 2623 .get = snd_hda_spdif_in_status_get, 2624 }, ··· 2883 int err = snd_hda_codec_build_controls(codec); 2884 if (err < 0) { 2885 printk(KERN_ERR "hda_codec: cannot build controls" 2886 + "for #%d (error %d)\n", codec->addr, err); 2887 err = snd_hda_codec_reset(codec); 2888 if (err < 0) { 2889 printk(KERN_ERR ··· 2979 val |= channels - 1; 2980 2981 switch (snd_pcm_format_width(format)) { 2982 + case 8: 2983 + val |= 0x00; 2984 + break; 2985 + case 16: 2986 + val |= 0x10; 2987 + break; 2988 case 20: 2989 case 24: 2990 case 32: ··· 3298 if (!test_and_set_bit(audio_idx[type][i], bus->pcm_dev_bits)) 3299 return audio_idx[type][i]; 3300 3301 + snd_printk(KERN_WARNING "Too many %s devices\n", 3302 + snd_hda_pcm_type_name[type]); 3303 return -EAGAIN; 3304 } 3305 ··· 3336 err = codec->patch_ops.build_pcms(codec); 3337 if (err < 0) { 3338 printk(KERN_ERR "hda_codec: cannot build PCMs" 3339 + "for #%d (error %d)\n", codec->addr, err); 3340 err = snd_hda_codec_reset(codec); 3341 if (err < 0) { 3342 printk(KERN_ERR ··· 3466 3467 /** 3468 * snd_hda_check_board_codec_sid_config - compare the current codec 3469 + subsystem ID with the 3470 + config table 3471 3472 This is important for Gateway notebooks with SB450 HDA Audio 3473 where the vendor ID of the PCI device is: ··· 3607 * 3608 * Increment the power-up counter and power up the hardware really when 3609 * not turned on yet. 3610 + */ 3611 void snd_hda_power_up(struct hda_codec *codec) 3612 { 3613 struct hda_bus *bus = codec->bus; ··· 3636 * 3637 * Decrement the power-up counter and schedules the power-off work if 3638 * the counter rearches to zero. 3639 + */ 3640 void snd_hda_power_down(struct hda_codec *codec) 3641 { 3642 --codec->power_count; ··· 3662 * 3663 * This function is supposed to be set or called from the check_power_status 3664 * patch ops. 3665 + */ 3666 int snd_hda_check_amp_list_power(struct hda_codec *codec, 3667 struct hda_loopback_check *check, 3668 hda_nid_t nid) ··· 3830 { 3831 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ 3832 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) 3833 + set_dig_out_convert(codec, nid, 3834 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff, 3835 -1); 3836 snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format); ··· 4089 /* 4090 * Sort an associated group of pins according to their sequence numbers. 4091 */ 4092 + static void sort_pins_by_sequence(hda_nid_t *pins, short *sequences, 4093 int num_pins) 4094 { 4095 int i, j; 4096 short seq; 4097 hda_nid_t nid; 4098 + 4099 for (i = 0; i < num_pins; i++) { 4100 for (j = i + 1; j < num_pins; j++) { 4101 if (sequences[i] > sequences[j]) { ··· 4123 * is detected, one of speaker of HP pins is assigned as the primary 4124 * output, i.e. to line_out_pins[0]. So, line_outs is always positive 4125 * if any analog output exists. 4126 + * 4127 * The analog input pins are assigned to input_pins array. 4128 * The digital input/output pins are assigned to dig_in_pin and dig_out_pin, 4129 * respectively. ··· 4186 case AC_JACK_SPEAKER: 4187 seq = get_defcfg_sequence(def_conf); 4188 assoc = get_defcfg_association(def_conf); 4189 + if (!assoc) 4190 continue; 4191 + if (!assoc_speaker) 4192 assoc_speaker = assoc; 4193 else if (assoc_speaker != assoc) 4194 continue; ··· 4286 cfg->speaker_outs); 4287 sort_pins_by_sequence(cfg->hp_pins, sequences_hp, 4288 cfg->hp_outs); 4289 + 4290 /* if we have only one mic, make it AUTO_PIN_MIC */ 4291 if (!cfg->input_pins[AUTO_PIN_MIC] && 4292 cfg->input_pins[AUTO_PIN_FRONT_MIC]) { ··· 4436 /** 4437 * snd_array_new - get a new element from the given array 4438 * @array: the array object 4439 + * 4440 * Get a new element from the given array. If it exceeds the 4441 * pre-allocated array size, re-allocate the array. 4442 *
+6
sound/pci/hda/hda_eld.c
··· 331 return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE, 332 AC_DIPSIZE_ELD_BUF); 333 } 334 335 int snd_hdmi_get_eld(struct hdmi_eld *eld, 336 struct hda_codec *codec, hda_nid_t nid) ··· 367 kfree(buf); 368 return ret; 369 } 370 371 static void hdmi_show_short_audio_desc(struct cea_sad *a) 372 { ··· 406 } 407 buf[j] = '\0'; /* necessary when j == 0 */ 408 } 409 410 void snd_hdmi_show_eld(struct hdmi_eld *e) 411 { ··· 425 for (i = 0; i < e->sad_count; i++) 426 hdmi_show_short_audio_desc(e->sad + i); 427 } 428 429 #ifdef CONFIG_PROC_FS 430 ··· 584 585 return 0; 586 } 587 588 void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) 589 { ··· 593 eld->proc_entry = NULL; 594 } 595 } 596 597 #endif /* CONFIG_PROC_FS */
··· 331 return snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_HDMI_DIP_SIZE, 332 AC_DIPSIZE_ELD_BUF); 333 } 334 + EXPORT_SYMBOL_HDA(snd_hdmi_get_eld_size); 335 336 int snd_hdmi_get_eld(struct hdmi_eld *eld, 337 struct hda_codec *codec, hda_nid_t nid) ··· 366 kfree(buf); 367 return ret; 368 } 369 + EXPORT_SYMBOL_HDA(snd_hdmi_get_eld); 370 371 static void hdmi_show_short_audio_desc(struct cea_sad *a) 372 { ··· 404 } 405 buf[j] = '\0'; /* necessary when j == 0 */ 406 } 407 + EXPORT_SYMBOL_HDA(snd_print_channel_allocation); 408 409 void snd_hdmi_show_eld(struct hdmi_eld *e) 410 { ··· 422 for (i = 0; i < e->sad_count; i++) 423 hdmi_show_short_audio_desc(e->sad + i); 424 } 425 + EXPORT_SYMBOL_HDA(snd_hdmi_show_eld); 426 427 #ifdef CONFIG_PROC_FS 428 ··· 580 581 return 0; 582 } 583 + EXPORT_SYMBOL_HDA(snd_hda_eld_proc_new); 584 585 void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) 586 { ··· 588 eld->proc_entry = NULL; 589 } 590 } 591 + EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free); 592 593 #endif /* CONFIG_PROC_FS */
+7 -2
sound/pci/hda/hda_intel.c
··· 267 #define RIRB_INT_MASK 0x05 268 269 /* STATESTS int mask: S3,SD2,SD1,SD0 */ 270 - #define AZX_MAX_CODECS 4 271 #define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1) 272 273 /* SD_CTL bits */ ··· 1368 1369 /* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ 1370 static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = { 1371 [AZX_DRIVER_TERA] = 1, 1372 }; 1373 ··· 1401 codecs = 0; 1402 max_slots = azx_max_codecs[chip->driver_type]; 1403 if (!max_slots) 1404 - max_slots = AZX_MAX_CODECS; 1405 1406 /* First try to probe all given codec slots */ 1407 for (c = 0; c < max_slots; c++) { ··· 2265 static struct snd_pci_quirk position_fix_list[] __devinitdata = { 2266 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), 2267 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), 2268 SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), 2269 SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB), 2270 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), 2271 SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), 2272 {} 2273 }; 2274 ··· 2358 static struct snd_pci_quirk msi_black_list[] __devinitdata = { 2359 SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */ 2360 SND_PCI_QUIRK(0x1043, 0x81f6, "ASUS", 0), /* nvidia */ 2361 {} 2362 }; 2363
··· 267 #define RIRB_INT_MASK 0x05 268 269 /* STATESTS int mask: S3,SD2,SD1,SD0 */ 270 + #define AZX_MAX_CODECS 8 271 + #define AZX_DEFAULT_CODECS 4 272 #define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1) 273 274 /* SD_CTL bits */ ··· 1367 1368 /* number of codec slots for each chipset: 0 = default slots (i.e. 4) */ 1369 static unsigned int azx_max_codecs[AZX_NUM_DRIVERS] __devinitdata = { 1370 + [AZX_DRIVER_NVIDIA] = 8, 1371 [AZX_DRIVER_TERA] = 1, 1372 }; 1373 ··· 1399 codecs = 0; 1400 max_slots = azx_max_codecs[chip->driver_type]; 1401 if (!max_slots) 1402 + max_slots = AZX_DEFAULT_CODECS; 1403 1404 /* First try to probe all given codec slots */ 1405 for (c = 0; c < max_slots; c++) { ··· 2263 static struct snd_pci_quirk position_fix_list[] __devinitdata = { 2264 SND_PCI_QUIRK(0x1028, 0x01cc, "Dell D820", POS_FIX_LPIB), 2265 SND_PCI_QUIRK(0x1028, 0x01de, "Dell Precision 390", POS_FIX_LPIB), 2266 + SND_PCI_QUIRK(0x1028, 0x01f6, "Dell Latitude 131L", POS_FIX_LPIB), 2267 SND_PCI_QUIRK(0x103c, 0x306d, "HP dv3", POS_FIX_LPIB), 2268 SND_PCI_QUIRK(0x1106, 0x3288, "ASUS M2V-MX SE", POS_FIX_LPIB), 2269 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), 2270 SND_PCI_QUIRK(0x1462, 0x1002, "MSI Wind U115", POS_FIX_LPIB), 2271 + SND_PCI_QUIRK(0x1565, 0x820f, "Biostar Microtech", POS_FIX_LPIB), 2272 {} 2273 }; 2274 ··· 2354 static struct snd_pci_quirk msi_black_list[] __devinitdata = { 2355 SND_PCI_QUIRK(0x1043, 0x81f2, "ASUS", 0), /* Athlon64 X2 + nvidia */ 2356 SND_PCI_QUIRK(0x1043, 0x81f6, "ASUS", 0), /* nvidia */ 2357 + SND_PCI_QUIRK(0x1849, 0x0888, "ASRock", 0), /* Athlon64 X2 + nvidia */ 2358 {} 2359 }; 2360
+849
sound/pci/hda/patch_hdmi.c
···
··· 1 + /* 2 + * 3 + * patch_hdmi.c - routines for HDMI/DisplayPort codecs 4 + * 5 + * Copyright(c) 2008-2010 Intel Corporation. All rights reserved. 6 + * 7 + * Authors: 8 + * Wu Fengguang <wfg@linux.intel.com> 9 + * 10 + * Maintained by: 11 + * Wu Fengguang <wfg@linux.intel.com> 12 + * 13 + * This program is free software; you can redistribute it and/or modify it 14 + * under the terms of the GNU General Public License as published by the Free 15 + * Software Foundation; either version 2 of the License, or (at your option) 16 + * any later version. 17 + * 18 + * This program is distributed in the hope that it will be useful, but 19 + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 20 + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21 + * for more details. 22 + * 23 + * You should have received a copy of the GNU General Public License 24 + * along with this program; if not, write to the Free Software Foundation, 25 + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 26 + */ 27 + 28 + 29 + struct hdmi_spec { 30 + int num_cvts; 31 + int num_pins; 32 + hda_nid_t cvt[MAX_HDMI_CVTS+1]; /* audio sources */ 33 + hda_nid_t pin[MAX_HDMI_PINS+1]; /* audio sinks */ 34 + 35 + /* 36 + * source connection for each pin 37 + */ 38 + hda_nid_t pin_cvt[MAX_HDMI_PINS+1]; 39 + 40 + /* 41 + * HDMI sink attached to each pin 42 + */ 43 + struct hdmi_eld sink_eld[MAX_HDMI_PINS]; 44 + 45 + /* 46 + * export one pcm per pipe 47 + */ 48 + struct hda_pcm pcm_rec[MAX_HDMI_CVTS]; 49 + 50 + /* 51 + * nvhdmi specific 52 + */ 53 + struct hda_multi_out multiout; 54 + unsigned int codec_type; 55 + }; 56 + 57 + 58 + struct hdmi_audio_infoframe { 59 + u8 type; /* 0x84 */ 60 + u8 ver; /* 0x01 */ 61 + u8 len; /* 0x0a */ 62 + 63 + u8 checksum; /* PB0 */ 64 + u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */ 65 + u8 SS01_SF24; 66 + u8 CXT04; 67 + u8 CA; 68 + u8 LFEPBL01_LSV36_DM_INH7; 69 + u8 reserved[5]; /* PB6 - PB10 */ 70 + }; 71 + 72 + /* 73 + * CEA speaker placement: 74 + * 75 + * FLH FCH FRH 76 + * FLW FL FLC FC FRC FR FRW 77 + * 78 + * LFE 79 + * TC 80 + * 81 + * RL RLC RC RRC RR 82 + * 83 + * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to 84 + * CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC. 85 + */ 86 + enum cea_speaker_placement { 87 + FL = (1 << 0), /* Front Left */ 88 + FC = (1 << 1), /* Front Center */ 89 + FR = (1 << 2), /* Front Right */ 90 + FLC = (1 << 3), /* Front Left Center */ 91 + FRC = (1 << 4), /* Front Right Center */ 92 + RL = (1 << 5), /* Rear Left */ 93 + RC = (1 << 6), /* Rear Center */ 94 + RR = (1 << 7), /* Rear Right */ 95 + RLC = (1 << 8), /* Rear Left Center */ 96 + RRC = (1 << 9), /* Rear Right Center */ 97 + LFE = (1 << 10), /* Low Frequency Effect */ 98 + FLW = (1 << 11), /* Front Left Wide */ 99 + FRW = (1 << 12), /* Front Right Wide */ 100 + FLH = (1 << 13), /* Front Left High */ 101 + FCH = (1 << 14), /* Front Center High */ 102 + FRH = (1 << 15), /* Front Right High */ 103 + TC = (1 << 16), /* Top Center */ 104 + }; 105 + 106 + /* 107 + * ELD SA bits in the CEA Speaker Allocation data block 108 + */ 109 + static int eld_speaker_allocation_bits[] = { 110 + [0] = FL | FR, 111 + [1] = LFE, 112 + [2] = FC, 113 + [3] = RL | RR, 114 + [4] = RC, 115 + [5] = FLC | FRC, 116 + [6] = RLC | RRC, 117 + /* the following are not defined in ELD yet */ 118 + [7] = FLW | FRW, 119 + [8] = FLH | FRH, 120 + [9] = TC, 121 + [10] = FCH, 122 + }; 123 + 124 + struct cea_channel_speaker_allocation { 125 + int ca_index; 126 + int speakers[8]; 127 + 128 + /* derived values, just for convenience */ 129 + int channels; 130 + int spk_mask; 131 + }; 132 + 133 + /* 134 + * ALSA sequence is: 135 + * 136 + * surround40 surround41 surround50 surround51 surround71 137 + * ch0 front left = = = = 138 + * ch1 front right = = = = 139 + * ch2 rear left = = = = 140 + * ch3 rear right = = = = 141 + * ch4 LFE center center center 142 + * ch5 LFE LFE 143 + * ch6 side left 144 + * ch7 side right 145 + * 146 + * surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR} 147 + */ 148 + static int hdmi_channel_mapping[0x32][8] = { 149 + /* stereo */ 150 + [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, 151 + /* 2.1 */ 152 + [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, 153 + /* Dolby Surround */ 154 + [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 }, 155 + /* surround40 */ 156 + [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 }, 157 + /* 4ch */ 158 + [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 }, 159 + /* surround41 */ 160 + [0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 }, 161 + /* surround50 */ 162 + [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 }, 163 + /* surround51 */ 164 + [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 }, 165 + /* 7.1 */ 166 + [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 }, 167 + }; 168 + 169 + /* 170 + * This is an ordered list! 171 + * 172 + * The preceding ones have better chances to be selected by 173 + * hdmi_setup_channel_allocation(). 174 + */ 175 + static struct cea_channel_speaker_allocation channel_allocations[] = { 176 + /* channel: 7 6 5 4 3 2 1 0 */ 177 + { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } }, 178 + /* 2.1 */ 179 + { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } }, 180 + /* Dolby Surround */ 181 + { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } }, 182 + /* surround40 */ 183 + { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } }, 184 + /* surround41 */ 185 + { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } }, 186 + /* surround50 */ 187 + { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } }, 188 + /* surround51 */ 189 + { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } }, 190 + /* 6.1 */ 191 + { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } }, 192 + /* surround71 */ 193 + { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } }, 194 + 195 + { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } }, 196 + { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } }, 197 + { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } }, 198 + { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } }, 199 + { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } }, 200 + { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } }, 201 + { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } }, 202 + { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } }, 203 + { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } }, 204 + { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } }, 205 + { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } }, 206 + { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } }, 207 + { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } }, 208 + { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } }, 209 + { .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } }, 210 + { .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } }, 211 + { .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } }, 212 + { .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } }, 213 + { .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } }, 214 + { .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } }, 215 + { .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } }, 216 + { .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } }, 217 + { .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } }, 218 + { .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } }, 219 + { .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } }, 220 + { .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } }, 221 + { .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } }, 222 + { .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } }, 223 + { .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } }, 224 + { .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } }, 225 + { .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } }, 226 + { .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } }, 227 + { .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } }, 228 + { .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } }, 229 + { .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } }, 230 + { .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } }, 231 + { .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } }, 232 + { .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } }, 233 + { .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } }, 234 + { .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } }, 235 + { .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } }, 236 + }; 237 + 238 + 239 + /* 240 + * HDMI routines 241 + */ 242 + 243 + static int hda_node_index(hda_nid_t *nids, hda_nid_t nid) 244 + { 245 + int i; 246 + 247 + for (i = 0; nids[i]; i++) 248 + if (nids[i] == nid) 249 + return i; 250 + 251 + snd_printk(KERN_WARNING "HDMI: nid %d not registered\n", nid); 252 + return -EINVAL; 253 + } 254 + 255 + static void hdmi_get_show_eld(struct hda_codec *codec, hda_nid_t pin_nid, 256 + struct hdmi_eld *eld) 257 + { 258 + if (!snd_hdmi_get_eld(eld, codec, pin_nid)) 259 + snd_hdmi_show_eld(eld); 260 + } 261 + 262 + #ifdef BE_PARANOID 263 + static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, 264 + int *packet_index, int *byte_index) 265 + { 266 + int val; 267 + 268 + val = snd_hda_codec_read(codec, pin_nid, 0, 269 + AC_VERB_GET_HDMI_DIP_INDEX, 0); 270 + 271 + *packet_index = val >> 5; 272 + *byte_index = val & 0x1f; 273 + } 274 + #endif 275 + 276 + static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, 277 + int packet_index, int byte_index) 278 + { 279 + int val; 280 + 281 + val = (packet_index << 5) | (byte_index & 0x1f); 282 + 283 + snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); 284 + } 285 + 286 + static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, 287 + unsigned char val) 288 + { 289 + snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); 290 + } 291 + 292 + static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid) 293 + { 294 + /* Unmute */ 295 + if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) 296 + snd_hda_codec_write(codec, pin_nid, 0, 297 + AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 298 + /* Enable pin out */ 299 + snd_hda_codec_write(codec, pin_nid, 0, 300 + AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 301 + } 302 + 303 + static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid) 304 + { 305 + return 1 + snd_hda_codec_read(codec, nid, 0, 306 + AC_VERB_GET_CVT_CHAN_COUNT, 0); 307 + } 308 + 309 + static void hdmi_set_channel_count(struct hda_codec *codec, 310 + hda_nid_t nid, int chs) 311 + { 312 + if (chs != hdmi_get_channel_count(codec, nid)) 313 + snd_hda_codec_write(codec, nid, 0, 314 + AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); 315 + } 316 + 317 + 318 + /* 319 + * Channel mapping routines 320 + */ 321 + 322 + /* 323 + * Compute derived values in channel_allocations[]. 324 + */ 325 + static void init_channel_allocations(void) 326 + { 327 + int i, j; 328 + struct cea_channel_speaker_allocation *p; 329 + 330 + for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { 331 + p = channel_allocations + i; 332 + p->channels = 0; 333 + p->spk_mask = 0; 334 + for (j = 0; j < ARRAY_SIZE(p->speakers); j++) 335 + if (p->speakers[j]) { 336 + p->channels++; 337 + p->spk_mask |= p->speakers[j]; 338 + } 339 + } 340 + } 341 + 342 + /* 343 + * The transformation takes two steps: 344 + * 345 + * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask 346 + * spk_mask => (channel_allocations[]) => ai->CA 347 + * 348 + * TODO: it could select the wrong CA from multiple candidates. 349 + */ 350 + static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid, 351 + struct hdmi_audio_infoframe *ai) 352 + { 353 + struct hdmi_spec *spec = codec->spec; 354 + struct hdmi_eld *eld; 355 + int i; 356 + int spk_mask = 0; 357 + int channels = 1 + (ai->CC02_CT47 & 0x7); 358 + char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; 359 + 360 + /* 361 + * CA defaults to 0 for basic stereo audio 362 + */ 363 + if (channels <= 2) 364 + return 0; 365 + 366 + i = hda_node_index(spec->pin_cvt, nid); 367 + if (i < 0) 368 + return 0; 369 + eld = &spec->sink_eld[i]; 370 + 371 + /* 372 + * HDMI sink's ELD info cannot always be retrieved for now, e.g. 373 + * in console or for audio devices. Assume the highest speakers 374 + * configuration, to _not_ prohibit multi-channel audio playback. 375 + */ 376 + if (!eld->spk_alloc) 377 + eld->spk_alloc = 0xffff; 378 + 379 + /* 380 + * expand ELD's speaker allocation mask 381 + * 382 + * ELD tells the speaker mask in a compact(paired) form, 383 + * expand ELD's notions to match the ones used by Audio InfoFrame. 384 + */ 385 + for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) { 386 + if (eld->spk_alloc & (1 << i)) 387 + spk_mask |= eld_speaker_allocation_bits[i]; 388 + } 389 + 390 + /* search for the first working match in the CA table */ 391 + for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { 392 + if (channels == channel_allocations[i].channels && 393 + (spk_mask & channel_allocations[i].spk_mask) == 394 + channel_allocations[i].spk_mask) { 395 + ai->CA = channel_allocations[i].ca_index; 396 + break; 397 + } 398 + } 399 + 400 + snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf)); 401 + snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n", 402 + ai->CA, channels, buf); 403 + 404 + return ai->CA; 405 + } 406 + 407 + static void hdmi_debug_channel_mapping(struct hda_codec *codec, 408 + hda_nid_t pin_nid) 409 + { 410 + #ifdef CONFIG_SND_DEBUG_VERBOSE 411 + int i; 412 + int slot; 413 + 414 + for (i = 0; i < 8; i++) { 415 + slot = snd_hda_codec_read(codec, pin_nid, 0, 416 + AC_VERB_GET_HDMI_CHAN_SLOT, i); 417 + printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", 418 + slot >> 4, slot & 0xf); 419 + } 420 + #endif 421 + } 422 + 423 + 424 + static void hdmi_setup_channel_mapping(struct hda_codec *codec, 425 + hda_nid_t pin_nid, 426 + struct hdmi_audio_infoframe *ai) 427 + { 428 + int i; 429 + int ca = ai->CA; 430 + int err; 431 + 432 + if (hdmi_channel_mapping[ca][1] == 0) { 433 + for (i = 0; i < channel_allocations[ca].channels; i++) 434 + hdmi_channel_mapping[ca][i] = i | (i << 4); 435 + for (; i < 8; i++) 436 + hdmi_channel_mapping[ca][i] = 0xf | (i << 4); 437 + } 438 + 439 + for (i = 0; i < 8; i++) { 440 + err = snd_hda_codec_write(codec, pin_nid, 0, 441 + AC_VERB_SET_HDMI_CHAN_SLOT, 442 + hdmi_channel_mapping[ca][i]); 443 + if (err) { 444 + snd_printdd(KERN_NOTICE 445 + "HDMI: channel mapping failed\n"); 446 + break; 447 + } 448 + } 449 + 450 + hdmi_debug_channel_mapping(codec, pin_nid); 451 + } 452 + 453 + 454 + /* 455 + * Audio InfoFrame routines 456 + */ 457 + 458 + /* 459 + * Enable Audio InfoFrame Transmission 460 + */ 461 + static void hdmi_start_infoframe_trans(struct hda_codec *codec, 462 + hda_nid_t pin_nid) 463 + { 464 + hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 465 + snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, 466 + AC_DIPXMIT_BEST); 467 + } 468 + 469 + /* 470 + * Disable Audio InfoFrame Transmission 471 + */ 472 + static void hdmi_stop_infoframe_trans(struct hda_codec *codec, 473 + hda_nid_t pin_nid) 474 + { 475 + hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 476 + snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, 477 + AC_DIPXMIT_DISABLE); 478 + } 479 + 480 + static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) 481 + { 482 + #ifdef CONFIG_SND_DEBUG_VERBOSE 483 + int i; 484 + int size; 485 + 486 + size = snd_hdmi_get_eld_size(codec, pin_nid); 487 + printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); 488 + 489 + for (i = 0; i < 8; i++) { 490 + size = snd_hda_codec_read(codec, pin_nid, 0, 491 + AC_VERB_GET_HDMI_DIP_SIZE, i); 492 + printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); 493 + } 494 + #endif 495 + } 496 + 497 + static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) 498 + { 499 + #ifdef BE_PARANOID 500 + int i, j; 501 + int size; 502 + int pi, bi; 503 + for (i = 0; i < 8; i++) { 504 + size = snd_hda_codec_read(codec, pin_nid, 0, 505 + AC_VERB_GET_HDMI_DIP_SIZE, i); 506 + if (size == 0) 507 + continue; 508 + 509 + hdmi_set_dip_index(codec, pin_nid, i, 0x0); 510 + for (j = 1; j < 1000; j++) { 511 + hdmi_write_dip_byte(codec, pin_nid, 0x0); 512 + hdmi_get_dip_index(codec, pin_nid, &pi, &bi); 513 + if (pi != i) 514 + snd_printd(KERN_INFO "dip index %d: %d != %d\n", 515 + bi, pi, i); 516 + if (bi == 0) /* byte index wrapped around */ 517 + break; 518 + } 519 + snd_printd(KERN_INFO 520 + "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n", 521 + i, size, j); 522 + } 523 + #endif 524 + } 525 + 526 + static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai) 527 + { 528 + u8 *bytes = (u8 *)ai; 529 + u8 sum = 0; 530 + int i; 531 + 532 + ai->checksum = 0; 533 + 534 + for (i = 0; i < sizeof(*ai); i++) 535 + sum += bytes[i]; 536 + 537 + ai->checksum = -sum; 538 + } 539 + 540 + static void hdmi_fill_audio_infoframe(struct hda_codec *codec, 541 + hda_nid_t pin_nid, 542 + struct hdmi_audio_infoframe *ai) 543 + { 544 + u8 *bytes = (u8 *)ai; 545 + int i; 546 + 547 + hdmi_debug_dip_size(codec, pin_nid); 548 + hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ 549 + 550 + hdmi_checksum_audio_infoframe(ai); 551 + 552 + hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 553 + for (i = 0; i < sizeof(*ai); i++) 554 + hdmi_write_dip_byte(codec, pin_nid, bytes[i]); 555 + } 556 + 557 + static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, 558 + struct hdmi_audio_infoframe *ai) 559 + { 560 + u8 *bytes = (u8 *)ai; 561 + u8 val; 562 + int i; 563 + 564 + if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) 565 + != AC_DIPXMIT_BEST) 566 + return false; 567 + 568 + hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 569 + for (i = 0; i < sizeof(*ai); i++) { 570 + val = snd_hda_codec_read(codec, pin_nid, 0, 571 + AC_VERB_GET_HDMI_DIP_DATA, 0); 572 + if (val != bytes[i]) 573 + return false; 574 + } 575 + 576 + return true; 577 + } 578 + 579 + static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, 580 + struct snd_pcm_substream *substream) 581 + { 582 + struct hdmi_spec *spec = codec->spec; 583 + hda_nid_t pin_nid; 584 + int i; 585 + struct hdmi_audio_infoframe ai = { 586 + .type = 0x84, 587 + .ver = 0x01, 588 + .len = 0x0a, 589 + .CC02_CT47 = substream->runtime->channels - 1, 590 + }; 591 + 592 + hdmi_setup_channel_allocation(codec, nid, &ai); 593 + 594 + for (i = 0; i < spec->num_pins; i++) { 595 + if (spec->pin_cvt[i] != nid) 596 + continue; 597 + if (!spec->sink_eld[i].monitor_present) 598 + continue; 599 + 600 + pin_nid = spec->pin[i]; 601 + if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) { 602 + snd_printdd("hdmi_setup_audio_infoframe: " 603 + "cvt=%d pin=%d channels=%d\n", 604 + nid, pin_nid, 605 + substream->runtime->channels); 606 + hdmi_setup_channel_mapping(codec, pin_nid, &ai); 607 + hdmi_stop_infoframe_trans(codec, pin_nid); 608 + hdmi_fill_audio_infoframe(codec, pin_nid, &ai); 609 + hdmi_start_infoframe_trans(codec, pin_nid); 610 + } 611 + } 612 + } 613 + 614 + 615 + /* 616 + * Unsolicited events 617 + */ 618 + 619 + static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) 620 + { 621 + struct hdmi_spec *spec = codec->spec; 622 + int tag = res >> AC_UNSOL_RES_TAG_SHIFT; 623 + int pind = !!(res & AC_UNSOL_RES_PD); 624 + int eldv = !!(res & AC_UNSOL_RES_ELDV); 625 + int index; 626 + 627 + printk(KERN_INFO 628 + "HDMI hot plug event: Pin=%d Presence_Detect=%d ELD_Valid=%d\n", 629 + tag, pind, eldv); 630 + 631 + index = hda_node_index(spec->pin, tag); 632 + if (index < 0) 633 + return; 634 + 635 + spec->sink_eld[index].monitor_present = pind; 636 + spec->sink_eld[index].eld_valid = eldv; 637 + 638 + if (pind && eldv) { 639 + hdmi_get_show_eld(codec, spec->pin[index], 640 + &spec->sink_eld[index]); 641 + /* TODO: do real things about ELD */ 642 + } 643 + } 644 + 645 + static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) 646 + { 647 + int tag = res >> AC_UNSOL_RES_TAG_SHIFT; 648 + int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; 649 + int cp_state = !!(res & AC_UNSOL_RES_CP_STATE); 650 + int cp_ready = !!(res & AC_UNSOL_RES_CP_READY); 651 + 652 + printk(KERN_INFO 653 + "HDMI CP event: PIN=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", 654 + tag, 655 + subtag, 656 + cp_state, 657 + cp_ready); 658 + 659 + /* TODO */ 660 + if (cp_state) 661 + ; 662 + if (cp_ready) 663 + ; 664 + } 665 + 666 + 667 + static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res) 668 + { 669 + struct hdmi_spec *spec = codec->spec; 670 + int tag = res >> AC_UNSOL_RES_TAG_SHIFT; 671 + int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; 672 + 673 + if (hda_node_index(spec->pin, tag) < 0) { 674 + snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag); 675 + return; 676 + } 677 + 678 + if (subtag == 0) 679 + hdmi_intrinsic_event(codec, res); 680 + else 681 + hdmi_non_intrinsic_event(codec, res); 682 + } 683 + 684 + /* 685 + * Callbacks 686 + */ 687 + 688 + static void hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, 689 + u32 stream_tag, int format) 690 + { 691 + int tag; 692 + int fmt; 693 + 694 + tag = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0) >> 4; 695 + fmt = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_STREAM_FORMAT, 0); 696 + 697 + snd_printdd("hdmi_setup_stream: " 698 + "NID=0x%x, %sstream=0x%x, %sformat=0x%x\n", 699 + nid, 700 + tag == stream_tag ? "" : "new-", 701 + stream_tag, 702 + fmt == format ? "" : "new-", 703 + format); 704 + 705 + if (tag != stream_tag) 706 + snd_hda_codec_write(codec, nid, 0, 707 + AC_VERB_SET_CHANNEL_STREAMID, 708 + stream_tag << 4); 709 + if (fmt != format) 710 + snd_hda_codec_write(codec, nid, 0, 711 + AC_VERB_SET_STREAM_FORMAT, format); 712 + } 713 + 714 + /* 715 + * HDA/HDMI auto parsing 716 + */ 717 + 718 + static int hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid) 719 + { 720 + struct hdmi_spec *spec = codec->spec; 721 + hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; 722 + int conn_len, curr; 723 + int index; 724 + 725 + if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { 726 + snd_printk(KERN_WARNING 727 + "HDMI: pin %d wcaps %#x " 728 + "does not support connection list\n", 729 + pin_nid, get_wcaps(codec, pin_nid)); 730 + return -EINVAL; 731 + } 732 + 733 + conn_len = snd_hda_get_connections(codec, pin_nid, conn_list, 734 + HDA_MAX_CONNECTIONS); 735 + if (conn_len > 1) 736 + curr = snd_hda_codec_read(codec, pin_nid, 0, 737 + AC_VERB_GET_CONNECT_SEL, 0); 738 + else 739 + curr = 0; 740 + 741 + index = hda_node_index(spec->pin, pin_nid); 742 + if (index < 0) 743 + return -EINVAL; 744 + 745 + spec->pin_cvt[index] = conn_list[curr]; 746 + 747 + return 0; 748 + } 749 + 750 + static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, 751 + struct hdmi_eld *eld) 752 + { 753 + int present = snd_hda_pin_sense(codec, pin_nid); 754 + 755 + eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); 756 + eld->eld_valid = !!(present & AC_PINSENSE_ELDV); 757 + 758 + if (present & AC_PINSENSE_ELDV) 759 + hdmi_get_show_eld(codec, pin_nid, eld); 760 + } 761 + 762 + static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) 763 + { 764 + struct hdmi_spec *spec = codec->spec; 765 + 766 + if (spec->num_pins >= MAX_HDMI_PINS) { 767 + snd_printk(KERN_WARNING 768 + "HDMI: no space for pin %d\n", pin_nid); 769 + return -EINVAL; 770 + } 771 + 772 + hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]); 773 + 774 + spec->pin[spec->num_pins] = pin_nid; 775 + spec->num_pins++; 776 + 777 + /* 778 + * It is assumed that converter nodes come first in the node list and 779 + * hence have been registered and usable now. 780 + */ 781 + return hdmi_read_pin_conn(codec, pin_nid); 782 + } 783 + 784 + static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid) 785 + { 786 + struct hdmi_spec *spec = codec->spec; 787 + 788 + if (spec->num_cvts >= MAX_HDMI_CVTS) { 789 + snd_printk(KERN_WARNING 790 + "HDMI: no space for converter %d\n", nid); 791 + return -EINVAL; 792 + } 793 + 794 + spec->cvt[spec->num_cvts] = nid; 795 + spec->num_cvts++; 796 + 797 + return 0; 798 + } 799 + 800 + static int hdmi_parse_codec(struct hda_codec *codec) 801 + { 802 + hda_nid_t nid; 803 + int i, nodes; 804 + 805 + nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); 806 + if (!nid || nodes < 0) { 807 + snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n"); 808 + return -EINVAL; 809 + } 810 + 811 + for (i = 0; i < nodes; i++, nid++) { 812 + unsigned int caps; 813 + unsigned int type; 814 + 815 + caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); 816 + type = get_wcaps_type(caps); 817 + 818 + if (!(caps & AC_WCAP_DIGITAL)) 819 + continue; 820 + 821 + switch (type) { 822 + case AC_WID_AUD_OUT: 823 + if (hdmi_add_cvt(codec, nid) < 0) 824 + return -EINVAL; 825 + break; 826 + case AC_WID_PIN: 827 + caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); 828 + if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP))) 829 + continue; 830 + if (hdmi_add_pin(codec, nid) < 0) 831 + return -EINVAL; 832 + break; 833 + } 834 + } 835 + 836 + /* 837 + * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event 838 + * can be lost and presence sense verb will become inaccurate if the 839 + * HDA link is powered off at hot plug or hw initialization time. 840 + */ 841 + #ifdef CONFIG_SND_HDA_POWER_SAVE 842 + if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) & 843 + AC_PWRST_EPSS)) 844 + codec->bus->power_keep_link_on = 1; 845 + #endif 846 + 847 + return 0; 848 + } 849 +
+13 -808
sound/pci/hda/patch_intelhdmi.c
··· 40 * 41 * The HDA correspondence of pipes/ports are converter/pin nodes. 42 */ 43 - #define INTEL_HDMI_CVTS 2 44 - #define INTEL_HDMI_PINS 3 45 46 - static char *intel_hdmi_pcm_names[INTEL_HDMI_CVTS] = { 47 "INTEL HDMI 0", 48 "INTEL HDMI 1", 49 }; 50 51 - struct intel_hdmi_spec { 52 - int num_cvts; 53 - int num_pins; 54 - hda_nid_t cvt[INTEL_HDMI_CVTS+1]; /* audio sources */ 55 - hda_nid_t pin[INTEL_HDMI_PINS+1]; /* audio sinks */ 56 - 57 - /* 58 - * source connection for each pin 59 - */ 60 - hda_nid_t pin_cvt[INTEL_HDMI_PINS+1]; 61 - 62 - /* 63 - * HDMI sink attached to each pin 64 - */ 65 - struct hdmi_eld sink_eld[INTEL_HDMI_PINS]; 66 - 67 - /* 68 - * export one pcm per pipe 69 - */ 70 - struct hda_pcm pcm_rec[INTEL_HDMI_CVTS]; 71 - }; 72 - 73 - struct hdmi_audio_infoframe { 74 - u8 type; /* 0x84 */ 75 - u8 ver; /* 0x01 */ 76 - u8 len; /* 0x0a */ 77 - 78 - u8 checksum; /* PB0 */ 79 - u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */ 80 - u8 SS01_SF24; 81 - u8 CXT04; 82 - u8 CA; 83 - u8 LFEPBL01_LSV36_DM_INH7; 84 - u8 reserved[5]; /* PB6 - PB10 */ 85 - }; 86 - 87 /* 88 - * CEA speaker placement: 89 - * 90 - * FLH FCH FRH 91 - * FLW FL FLC FC FRC FR FRW 92 - * 93 - * LFE 94 - * TC 95 - * 96 - * RL RLC RC RRC RR 97 - * 98 - * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to 99 - * CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC. 100 */ 101 - enum cea_speaker_placement { 102 - FL = (1 << 0), /* Front Left */ 103 - FC = (1 << 1), /* Front Center */ 104 - FR = (1 << 2), /* Front Right */ 105 - FLC = (1 << 3), /* Front Left Center */ 106 - FRC = (1 << 4), /* Front Right Center */ 107 - RL = (1 << 5), /* Rear Left */ 108 - RC = (1 << 6), /* Rear Center */ 109 - RR = (1 << 7), /* Rear Right */ 110 - RLC = (1 << 8), /* Rear Left Center */ 111 - RRC = (1 << 9), /* Rear Right Center */ 112 - LFE = (1 << 10), /* Low Frequency Effect */ 113 - FLW = (1 << 11), /* Front Left Wide */ 114 - FRW = (1 << 12), /* Front Right Wide */ 115 - FLH = (1 << 13), /* Front Left High */ 116 - FCH = (1 << 14), /* Front Center High */ 117 - FRH = (1 << 15), /* Front Right High */ 118 - TC = (1 << 16), /* Top Center */ 119 - }; 120 - 121 - /* 122 - * ELD SA bits in the CEA Speaker Allocation data block 123 - */ 124 - static int eld_speaker_allocation_bits[] = { 125 - [0] = FL | FR, 126 - [1] = LFE, 127 - [2] = FC, 128 - [3] = RL | RR, 129 - [4] = RC, 130 - [5] = FLC | FRC, 131 - [6] = RLC | RRC, 132 - /* the following are not defined in ELD yet */ 133 - [7] = FLW | FRW, 134 - [8] = FLH | FRH, 135 - [9] = TC, 136 - [10] = FCH, 137 - }; 138 - 139 - struct cea_channel_speaker_allocation { 140 - int ca_index; 141 - int speakers[8]; 142 - 143 - /* derived values, just for convenience */ 144 - int channels; 145 - int spk_mask; 146 - }; 147 - 148 - /* 149 - * ALSA sequence is: 150 - * 151 - * surround40 surround41 surround50 surround51 surround71 152 - * ch0 front left = = = = 153 - * ch1 front right = = = = 154 - * ch2 rear left = = = = 155 - * ch3 rear right = = = = 156 - * ch4 LFE center center center 157 - * ch5 LFE LFE 158 - * ch6 side left 159 - * ch7 side right 160 - * 161 - * surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR} 162 - */ 163 - static int hdmi_channel_mapping[0x32][8] = { 164 - /* stereo */ 165 - [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, 166 - /* 2.1 */ 167 - [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }, 168 - /* Dolby Surround */ 169 - [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 }, 170 - /* surround40 */ 171 - [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 }, 172 - /* 4ch */ 173 - [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 }, 174 - /* surround41 */ 175 - [0x09] = { 0x00, 0x11, 0x24, 0x34, 0x43, 0xf2, 0xf6, 0xf7 }, 176 - /* surround50 */ 177 - [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 }, 178 - /* surround51 */ 179 - [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 }, 180 - /* 7.1 */ 181 - [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 }, 182 - }; 183 - 184 - /* 185 - * This is an ordered list! 186 - * 187 - * The preceding ones have better chances to be selected by 188 - * hdmi_setup_channel_allocation(). 189 - */ 190 - static struct cea_channel_speaker_allocation channel_allocations[] = { 191 - /* channel: 7 6 5 4 3 2 1 0 */ 192 - { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } }, 193 - /* 2.1 */ 194 - { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } }, 195 - /* Dolby Surround */ 196 - { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } }, 197 - /* surround40 */ 198 - { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } }, 199 - /* surround41 */ 200 - { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } }, 201 - /* surround50 */ 202 - { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } }, 203 - /* surround51 */ 204 - { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } }, 205 - /* 6.1 */ 206 - { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } }, 207 - /* surround71 */ 208 - { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } }, 209 - 210 - { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } }, 211 - { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } }, 212 - { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } }, 213 - { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } }, 214 - { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } }, 215 - { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } }, 216 - { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } }, 217 - { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } }, 218 - { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } }, 219 - { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } }, 220 - { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } }, 221 - { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } }, 222 - { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } }, 223 - { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } }, 224 - { .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } }, 225 - { .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } }, 226 - { .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } }, 227 - { .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } }, 228 - { .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } }, 229 - { .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } }, 230 - { .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } }, 231 - { .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } }, 232 - { .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } }, 233 - { .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } }, 234 - { .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } }, 235 - { .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } }, 236 - { .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } }, 237 - { .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } }, 238 - { .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } }, 239 - { .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } }, 240 - { .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } }, 241 - { .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } }, 242 - { .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } }, 243 - { .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } }, 244 - { .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } }, 245 - { .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } }, 246 - { .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } }, 247 - { .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } }, 248 - { .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } }, 249 - { .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } }, 250 - { .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } }, 251 - }; 252 - 253 - /* 254 - * HDA/HDMI auto parsing 255 - */ 256 - 257 - static int hda_node_index(hda_nid_t *nids, hda_nid_t nid) 258 - { 259 - int i; 260 - 261 - for (i = 0; nids[i]; i++) 262 - if (nids[i] == nid) 263 - return i; 264 - 265 - snd_printk(KERN_WARNING "HDMI: nid %d not registered\n", nid); 266 - return -EINVAL; 267 - } 268 - 269 - static int intel_hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid) 270 - { 271 - struct intel_hdmi_spec *spec = codec->spec; 272 - hda_nid_t conn_list[HDA_MAX_CONNECTIONS]; 273 - int conn_len, curr; 274 - int index; 275 - 276 - if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) { 277 - snd_printk(KERN_WARNING 278 - "HDMI: pin %d wcaps %#x " 279 - "does not support connection list\n", 280 - pin_nid, get_wcaps(codec, pin_nid)); 281 - return -EINVAL; 282 - } 283 - 284 - conn_len = snd_hda_get_connections(codec, pin_nid, conn_list, 285 - HDA_MAX_CONNECTIONS); 286 - if (conn_len > 1) 287 - curr = snd_hda_codec_read(codec, pin_nid, 0, 288 - AC_VERB_GET_CONNECT_SEL, 0); 289 - else 290 - curr = 0; 291 - 292 - index = hda_node_index(spec->pin, pin_nid); 293 - if (index < 0) 294 - return -EINVAL; 295 - 296 - spec->pin_cvt[index] = conn_list[curr]; 297 - 298 - return 0; 299 - } 300 - 301 - static void hdmi_get_show_eld(struct hda_codec *codec, hda_nid_t pin_nid, 302 - struct hdmi_eld *eld) 303 - { 304 - if (!snd_hdmi_get_eld(eld, codec, pin_nid)) 305 - snd_hdmi_show_eld(eld); 306 - } 307 - 308 - static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid, 309 - struct hdmi_eld *eld) 310 - { 311 - int present = snd_hda_pin_sense(codec, pin_nid); 312 - 313 - eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE); 314 - eld->eld_valid = !!(present & AC_PINSENSE_ELDV); 315 - 316 - if (present & AC_PINSENSE_ELDV) 317 - hdmi_get_show_eld(codec, pin_nid, eld); 318 - } 319 - 320 - static int intel_hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid) 321 - { 322 - struct intel_hdmi_spec *spec = codec->spec; 323 - 324 - if (spec->num_pins >= INTEL_HDMI_PINS) { 325 - snd_printk(KERN_WARNING 326 - "HDMI: no space for pin %d \n", pin_nid); 327 - return -EINVAL; 328 - } 329 - 330 - hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]); 331 - 332 - spec->pin[spec->num_pins] = pin_nid; 333 - spec->num_pins++; 334 - 335 - /* 336 - * It is assumed that converter nodes come first in the node list and 337 - * hence have been registered and usable now. 338 - */ 339 - return intel_hdmi_read_pin_conn(codec, pin_nid); 340 - } 341 - 342 - static int intel_hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid) 343 - { 344 - struct intel_hdmi_spec *spec = codec->spec; 345 - 346 - if (spec->num_cvts >= INTEL_HDMI_CVTS) { 347 - snd_printk(KERN_WARNING 348 - "HDMI: no space for converter %d \n", nid); 349 - return -EINVAL; 350 - } 351 - 352 - spec->cvt[spec->num_cvts] = nid; 353 - spec->num_cvts++; 354 - 355 - return 0; 356 - } 357 - 358 - static int intel_hdmi_parse_codec(struct hda_codec *codec) 359 - { 360 - hda_nid_t nid; 361 - int i, nodes; 362 - 363 - nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid); 364 - if (!nid || nodes < 0) { 365 - snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n"); 366 - return -EINVAL; 367 - } 368 - 369 - for (i = 0; i < nodes; i++, nid++) { 370 - unsigned int caps; 371 - unsigned int type; 372 - 373 - caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP); 374 - type = get_wcaps_type(caps); 375 - 376 - if (!(caps & AC_WCAP_DIGITAL)) 377 - continue; 378 - 379 - switch (type) { 380 - case AC_WID_AUD_OUT: 381 - if (intel_hdmi_add_cvt(codec, nid) < 0) 382 - return -EINVAL; 383 - break; 384 - case AC_WID_PIN: 385 - caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP); 386 - if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP))) 387 - continue; 388 - if (intel_hdmi_add_pin(codec, nid) < 0) 389 - return -EINVAL; 390 - break; 391 - } 392 - } 393 - 394 - /* 395 - * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event 396 - * can be lost and presence sense verb will become inaccurate if the 397 - * HDA link is powered off at hot plug or hw initialization time. 398 - */ 399 - #ifdef CONFIG_SND_HDA_POWER_SAVE 400 - if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) & 401 - AC_PWRST_EPSS)) 402 - codec->bus->power_keep_link_on = 1; 403 - #endif 404 - 405 - return 0; 406 - } 407 - 408 - /* 409 - * HDMI routines 410 - */ 411 - 412 - #ifdef BE_PARANOID 413 - static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, 414 - int *packet_index, int *byte_index) 415 - { 416 - int val; 417 - 418 - val = snd_hda_codec_read(codec, pin_nid, 0, 419 - AC_VERB_GET_HDMI_DIP_INDEX, 0); 420 - 421 - *packet_index = val >> 5; 422 - *byte_index = val & 0x1f; 423 - } 424 - #endif 425 - 426 - static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid, 427 - int packet_index, int byte_index) 428 - { 429 - int val; 430 - 431 - val = (packet_index << 5) | (byte_index & 0x1f); 432 - 433 - snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val); 434 - } 435 - 436 - static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid, 437 - unsigned char val) 438 - { 439 - snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val); 440 - } 441 - 442 - static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid) 443 - { 444 - /* Unmute */ 445 - if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP) 446 - snd_hda_codec_write(codec, pin_nid, 0, 447 - AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE); 448 - /* Enable pin out */ 449 - snd_hda_codec_write(codec, pin_nid, 0, 450 - AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT); 451 - } 452 - 453 - /* 454 - * Enable Audio InfoFrame Transmission 455 - */ 456 - static void hdmi_start_infoframe_trans(struct hda_codec *codec, 457 - hda_nid_t pin_nid) 458 - { 459 - hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 460 - snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, 461 - AC_DIPXMIT_BEST); 462 - } 463 - 464 - /* 465 - * Disable Audio InfoFrame Transmission 466 - */ 467 - static void hdmi_stop_infoframe_trans(struct hda_codec *codec, 468 - hda_nid_t pin_nid) 469 - { 470 - hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 471 - snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT, 472 - AC_DIPXMIT_DISABLE); 473 - } 474 - 475 - static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid) 476 - { 477 - return 1 + snd_hda_codec_read(codec, nid, 0, 478 - AC_VERB_GET_CVT_CHAN_COUNT, 0); 479 - } 480 - 481 - static void hdmi_set_channel_count(struct hda_codec *codec, 482 - hda_nid_t nid, int chs) 483 - { 484 - if (chs != hdmi_get_channel_count(codec, nid)) 485 - snd_hda_codec_write(codec, nid, 0, 486 - AC_VERB_SET_CVT_CHAN_COUNT, chs - 1); 487 - } 488 - 489 - static void hdmi_debug_channel_mapping(struct hda_codec *codec, 490 - hda_nid_t pin_nid) 491 - { 492 - #ifdef CONFIG_SND_DEBUG_VERBOSE 493 - int i; 494 - int slot; 495 - 496 - for (i = 0; i < 8; i++) { 497 - slot = snd_hda_codec_read(codec, pin_nid, 0, 498 - AC_VERB_GET_HDMI_CHAN_SLOT, i); 499 - printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n", 500 - slot >> 4, slot & 0xf); 501 - } 502 - #endif 503 - } 504 - 505 - 506 - /* 507 - * Audio InfoFrame routines 508 - */ 509 - 510 - static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid) 511 - { 512 - #ifdef CONFIG_SND_DEBUG_VERBOSE 513 - int i; 514 - int size; 515 - 516 - size = snd_hdmi_get_eld_size(codec, pin_nid); 517 - printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size); 518 - 519 - for (i = 0; i < 8; i++) { 520 - size = snd_hda_codec_read(codec, pin_nid, 0, 521 - AC_VERB_GET_HDMI_DIP_SIZE, i); 522 - printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size); 523 - } 524 - #endif 525 - } 526 - 527 - static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid) 528 - { 529 - #ifdef BE_PARANOID 530 - int i, j; 531 - int size; 532 - int pi, bi; 533 - for (i = 0; i < 8; i++) { 534 - size = snd_hda_codec_read(codec, pin_nid, 0, 535 - AC_VERB_GET_HDMI_DIP_SIZE, i); 536 - if (size == 0) 537 - continue; 538 - 539 - hdmi_set_dip_index(codec, pin_nid, i, 0x0); 540 - for (j = 1; j < 1000; j++) { 541 - hdmi_write_dip_byte(codec, pin_nid, 0x0); 542 - hdmi_get_dip_index(codec, pin_nid, &pi, &bi); 543 - if (pi != i) 544 - snd_printd(KERN_INFO "dip index %d: %d != %d\n", 545 - bi, pi, i); 546 - if (bi == 0) /* byte index wrapped around */ 547 - break; 548 - } 549 - snd_printd(KERN_INFO 550 - "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n", 551 - i, size, j); 552 - } 553 - #endif 554 - } 555 - 556 - static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *ai) 557 - { 558 - u8 *bytes = (u8 *)ai; 559 - u8 sum = 0; 560 - int i; 561 - 562 - ai->checksum = 0; 563 - 564 - for (i = 0; i < sizeof(*ai); i++) 565 - sum += bytes[i]; 566 - 567 - ai->checksum = - sum; 568 - } 569 - 570 - static void hdmi_fill_audio_infoframe(struct hda_codec *codec, 571 - hda_nid_t pin_nid, 572 - struct hdmi_audio_infoframe *ai) 573 - { 574 - u8 *bytes = (u8 *)ai; 575 - int i; 576 - 577 - hdmi_debug_dip_size(codec, pin_nid); 578 - hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */ 579 - 580 - hdmi_checksum_audio_infoframe(ai); 581 - 582 - hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 583 - for (i = 0; i < sizeof(*ai); i++) 584 - hdmi_write_dip_byte(codec, pin_nid, bytes[i]); 585 - } 586 - 587 - /* 588 - * Compute derived values in channel_allocations[]. 589 - */ 590 - static void init_channel_allocations(void) 591 - { 592 - int i, j; 593 - struct cea_channel_speaker_allocation *p; 594 - 595 - for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { 596 - p = channel_allocations + i; 597 - p->channels = 0; 598 - p->spk_mask = 0; 599 - for (j = 0; j < ARRAY_SIZE(p->speakers); j++) 600 - if (p->speakers[j]) { 601 - p->channels++; 602 - p->spk_mask |= p->speakers[j]; 603 - } 604 - } 605 - } 606 - 607 - /* 608 - * The transformation takes two steps: 609 - * 610 - * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask 611 - * spk_mask => (channel_allocations[]) => ai->CA 612 - * 613 - * TODO: it could select the wrong CA from multiple candidates. 614 - */ 615 - static int hdmi_setup_channel_allocation(struct hda_codec *codec, hda_nid_t nid, 616 - struct hdmi_audio_infoframe *ai) 617 - { 618 - struct intel_hdmi_spec *spec = codec->spec; 619 - struct hdmi_eld *eld; 620 - int i; 621 - int spk_mask = 0; 622 - int channels = 1 + (ai->CC02_CT47 & 0x7); 623 - char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE]; 624 - 625 - /* 626 - * CA defaults to 0 for basic stereo audio 627 - */ 628 - if (channels <= 2) 629 - return 0; 630 - 631 - i = hda_node_index(spec->pin_cvt, nid); 632 - if (i < 0) 633 - return 0; 634 - eld = &spec->sink_eld[i]; 635 - 636 - /* 637 - * HDMI sink's ELD info cannot always be retrieved for now, e.g. 638 - * in console or for audio devices. Assume the highest speakers 639 - * configuration, to _not_ prohibit multi-channel audio playback. 640 - */ 641 - if (!eld->spk_alloc) 642 - eld->spk_alloc = 0xffff; 643 - 644 - /* 645 - * expand ELD's speaker allocation mask 646 - * 647 - * ELD tells the speaker mask in a compact(paired) form, 648 - * expand ELD's notions to match the ones used by Audio InfoFrame. 649 - */ 650 - for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) { 651 - if (eld->spk_alloc & (1 << i)) 652 - spk_mask |= eld_speaker_allocation_bits[i]; 653 - } 654 - 655 - /* search for the first working match in the CA table */ 656 - for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) { 657 - if (channels == channel_allocations[i].channels && 658 - (spk_mask & channel_allocations[i].spk_mask) == 659 - channel_allocations[i].spk_mask) { 660 - ai->CA = channel_allocations[i].ca_index; 661 - break; 662 - } 663 - } 664 - 665 - snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf)); 666 - snd_printdd(KERN_INFO 667 - "HDMI: select CA 0x%x for %d-channel allocation: %s\n", 668 - ai->CA, channels, buf); 669 - 670 - return ai->CA; 671 - } 672 - 673 - static void hdmi_setup_channel_mapping(struct hda_codec *codec, 674 - hda_nid_t pin_nid, 675 - struct hdmi_audio_infoframe *ai) 676 - { 677 - int i; 678 - int ca = ai->CA; 679 - int err; 680 - 681 - if (hdmi_channel_mapping[ca][1] == 0) { 682 - for (i = 0; i < channel_allocations[ca].channels; i++) 683 - hdmi_channel_mapping[ca][i] = i | (i << 4); 684 - for (; i < 8; i++) 685 - hdmi_channel_mapping[ca][i] = 0xf | (i << 4); 686 - } 687 - 688 - for (i = 0; i < 8; i++) { 689 - err = snd_hda_codec_write(codec, pin_nid, 0, 690 - AC_VERB_SET_HDMI_CHAN_SLOT, 691 - hdmi_channel_mapping[ca][i]); 692 - if (err) { 693 - snd_printdd(KERN_INFO "HDMI: channel mapping failed\n"); 694 - break; 695 - } 696 - } 697 - 698 - hdmi_debug_channel_mapping(codec, pin_nid); 699 - } 700 - 701 - static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid, 702 - struct hdmi_audio_infoframe *ai) 703 - { 704 - u8 *bytes = (u8 *)ai; 705 - u8 val; 706 - int i; 707 - 708 - if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0) 709 - != AC_DIPXMIT_BEST) 710 - return false; 711 - 712 - hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0); 713 - for (i = 0; i < sizeof(*ai); i++) { 714 - val = snd_hda_codec_read(codec, pin_nid, 0, 715 - AC_VERB_GET_HDMI_DIP_DATA, 0); 716 - if (val != bytes[i]) 717 - return false; 718 - } 719 - 720 - return true; 721 - } 722 - 723 - static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid, 724 - struct snd_pcm_substream *substream) 725 - { 726 - struct intel_hdmi_spec *spec = codec->spec; 727 - hda_nid_t pin_nid; 728 - int i; 729 - struct hdmi_audio_infoframe ai = { 730 - .type = 0x84, 731 - .ver = 0x01, 732 - .len = 0x0a, 733 - .CC02_CT47 = substream->runtime->channels - 1, 734 - }; 735 - 736 - hdmi_setup_channel_allocation(codec, nid, &ai); 737 - 738 - for (i = 0; i < spec->num_pins; i++) { 739 - if (spec->pin_cvt[i] != nid) 740 - continue; 741 - if (!spec->sink_eld[i].monitor_present) 742 - continue; 743 - 744 - pin_nid = spec->pin[i]; 745 - if (!hdmi_infoframe_uptodate(codec, pin_nid, &ai)) { 746 - hdmi_setup_channel_mapping(codec, pin_nid, &ai); 747 - hdmi_stop_infoframe_trans(codec, pin_nid); 748 - hdmi_fill_audio_infoframe(codec, pin_nid, &ai); 749 - hdmi_start_infoframe_trans(codec, pin_nid); 750 - } 751 - } 752 - } 753 - 754 - 755 - /* 756 - * Unsolicited events 757 - */ 758 - 759 - static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res) 760 - { 761 - struct intel_hdmi_spec *spec = codec->spec; 762 - int tag = res >> AC_UNSOL_RES_TAG_SHIFT; 763 - int pind = !!(res & AC_UNSOL_RES_PD); 764 - int eldv = !!(res & AC_UNSOL_RES_ELDV); 765 - int index; 766 - 767 - printk(KERN_INFO 768 - "HDMI hot plug event: Pin=%d Presence_Detect=%d ELD_Valid=%d\n", 769 - tag, pind, eldv); 770 - 771 - index = hda_node_index(spec->pin, tag); 772 - if (index < 0) 773 - return; 774 - 775 - spec->sink_eld[index].monitor_present = pind; 776 - spec->sink_eld[index].eld_valid = eldv; 777 - 778 - if (pind && eldv) { 779 - hdmi_get_show_eld(codec, spec->pin[index], &spec->sink_eld[index]); 780 - /* TODO: do real things about ELD */ 781 - } 782 - } 783 - 784 - static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res) 785 - { 786 - int tag = res >> AC_UNSOL_RES_TAG_SHIFT; 787 - int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; 788 - int cp_state = !!(res & AC_UNSOL_RES_CP_STATE); 789 - int cp_ready = !!(res & AC_UNSOL_RES_CP_READY); 790 - 791 - printk(KERN_INFO 792 - "HDMI CP event: PIN=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n", 793 - tag, 794 - subtag, 795 - cp_state, 796 - cp_ready); 797 - 798 - /* TODO */ 799 - if (cp_state) 800 - ; 801 - if (cp_ready) 802 - ; 803 - } 804 - 805 - 806 - static void intel_hdmi_unsol_event(struct hda_codec *codec, unsigned int res) 807 - { 808 - struct intel_hdmi_spec *spec = codec->spec; 809 - int tag = res >> AC_UNSOL_RES_TAG_SHIFT; 810 - int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT; 811 - 812 - if (hda_node_index(spec->pin, tag) < 0) { 813 - snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag); 814 - return; 815 - } 816 - 817 - if (subtag == 0) 818 - hdmi_intrinsic_event(codec, res); 819 - else 820 - hdmi_non_intrinsic_event(codec, res); 821 - } 822 - 823 - /* 824 - * Callbacks 825 - */ 826 - 827 - static void hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, 828 - u32 stream_tag, int format) 829 - { 830 - int tag; 831 - int fmt; 832 - 833 - tag = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONV, 0) >> 4; 834 - fmt = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_STREAM_FORMAT, 0); 835 - 836 - snd_printdd("hdmi_setup_stream: " 837 - "NID=0x%x, %sstream=0x%x, %sformat=0x%x\n", 838 - nid, 839 - tag == stream_tag ? "" : "new-", 840 - stream_tag, 841 - fmt == format ? "" : "new-", 842 - format); 843 - 844 - if (tag != stream_tag) 845 - snd_hda_codec_write(codec, nid, 0, 846 - AC_VERB_SET_CHANNEL_STREAMID, stream_tag << 4); 847 - if (fmt != format) 848 - snd_hda_codec_write(codec, nid, 0, 849 - AC_VERB_SET_STREAM_FORMAT, format); 850 - } 851 852 static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 853 struct hda_codec *codec, ··· 87 88 static int intel_hdmi_build_pcms(struct hda_codec *codec) 89 { 90 - struct intel_hdmi_spec *spec = codec->spec; 91 struct hda_pcm *info = spec->pcm_rec; 92 int i; 93 ··· 113 114 static int intel_hdmi_build_controls(struct hda_codec *codec) 115 { 116 - struct intel_hdmi_spec *spec = codec->spec; 117 int err; 118 int i; 119 ··· 128 129 static int intel_hdmi_init(struct hda_codec *codec) 130 { 131 - struct intel_hdmi_spec *spec = codec->spec; 132 int i; 133 134 for (i = 0; spec->pin[i]; i++) { ··· 142 143 static void intel_hdmi_free(struct hda_codec *codec) 144 { 145 - struct intel_hdmi_spec *spec = codec->spec; 146 int i; 147 148 for (i = 0; i < spec->num_pins; i++) ··· 156 .free = intel_hdmi_free, 157 .build_pcms = intel_hdmi_build_pcms, 158 .build_controls = intel_hdmi_build_controls, 159 - .unsol_event = intel_hdmi_unsol_event, 160 }; 161 162 static int patch_intel_hdmi(struct hda_codec *codec) 163 { 164 - struct intel_hdmi_spec *spec; 165 int i; 166 167 spec = kzalloc(sizeof(*spec), GFP_KERNEL); ··· 169 return -ENOMEM; 170 171 codec->spec = spec; 172 - if (intel_hdmi_parse_codec(codec) < 0) { 173 codec->spec = NULL; 174 kfree(spec); 175 return -EINVAL;
··· 40 * 41 * The HDA correspondence of pipes/ports are converter/pin nodes. 42 */ 43 + #define MAX_HDMI_CVTS 2 44 + #define MAX_HDMI_PINS 3 45 46 + #include "patch_hdmi.c" 47 + 48 + static char *intel_hdmi_pcm_names[MAX_HDMI_CVTS] = { 49 "INTEL HDMI 0", 50 "INTEL HDMI 1", 51 }; 52 53 /* 54 + * HDMI callbacks 55 */ 56 57 static int intel_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo, 58 struct hda_codec *codec, ··· 882 883 static int intel_hdmi_build_pcms(struct hda_codec *codec) 884 { 885 + struct hdmi_spec *spec = codec->spec; 886 struct hda_pcm *info = spec->pcm_rec; 887 int i; 888 ··· 908 909 static int intel_hdmi_build_controls(struct hda_codec *codec) 910 { 911 + struct hdmi_spec *spec = codec->spec; 912 int err; 913 int i; 914 ··· 923 924 static int intel_hdmi_init(struct hda_codec *codec) 925 { 926 + struct hdmi_spec *spec = codec->spec; 927 int i; 928 929 for (i = 0; spec->pin[i]; i++) { ··· 937 938 static void intel_hdmi_free(struct hda_codec *codec) 939 { 940 + struct hdmi_spec *spec = codec->spec; 941 int i; 942 943 for (i = 0; i < spec->num_pins; i++) ··· 951 .free = intel_hdmi_free, 952 .build_pcms = intel_hdmi_build_pcms, 953 .build_controls = intel_hdmi_build_controls, 954 + .unsol_event = hdmi_unsol_event, 955 }; 956 957 static int patch_intel_hdmi(struct hda_codec *codec) 958 { 959 + struct hdmi_spec *spec; 960 int i; 961 962 spec = kzalloc(sizeof(*spec), GFP_KERNEL); ··· 964 return -ENOMEM; 965 966 codec->spec = spec; 967 + if (hdmi_parse_codec(codec) < 0) { 968 codec->spec = NULL; 969 kfree(spec); 970 return -EINVAL;
+217 -60
sound/pci/hda/patch_nvhdmi.c
··· 29 #include "hda_codec.h" 30 #include "hda_local.h" 31 32 /* define below to restrict the supported rates and formats */ 33 /* #define LIMITED_RATE_FMT_SUPPORT */ 34 35 - struct nvhdmi_spec { 36 - struct hda_multi_out multiout; 37 - 38 - struct hda_pcm pcm_rec; 39 }; 40 41 #define Nv_VERB_SET_Channel_Allocation 0xF79 ··· 53 #define Nv_VERB_SET_Audio_Protection_On 0xF98 54 #define Nv_VERB_SET_Audio_Protection_Off 0xF99 55 56 - #define Nv_Master_Convert_nid 0x04 57 - #define Nv_Master_Pin_nid 0x05 58 59 - static hda_nid_t nvhdmi_convert_nids[4] = { 60 /*front, rear, clfe, rear_surr */ 61 0x6, 0x8, 0xa, 0xc, 62 }; 63 64 - static struct hda_verb nvhdmi_basic_init[] = { 65 /* set audio protect on */ 66 { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1}, 67 /* enable digital output on pin widget */ ··· 97 */ 98 static int nvhdmi_build_controls(struct hda_codec *codec) 99 { 100 - struct nvhdmi_spec *spec = codec->spec; 101 int err; 102 103 - err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid); 104 - if (err < 0) 105 - return err; 106 107 return 0; 108 } 109 110 static int nvhdmi_init(struct hda_codec *codec) 111 { 112 - snd_hda_sequence_write(codec, nvhdmi_basic_init); 113 return 0; 114 } 115 116 /* ··· 158 struct hda_codec *codec, 159 struct snd_pcm_substream *substream) 160 { 161 - struct nvhdmi_spec *spec = codec->spec; 162 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 163 } 164 165 - static int nvhdmi_dig_playback_pcm_close_8ch(struct hda_pcm_stream *hinfo, 166 struct hda_codec *codec, 167 struct snd_pcm_substream *substream) 168 { 169 - struct nvhdmi_spec *spec = codec->spec; 170 int i; 171 172 - snd_hda_codec_write(codec, Nv_Master_Convert_nid, 173 0, AC_VERB_SET_CHANNEL_STREAMID, 0); 174 for (i = 0; i < 4; i++) { 175 /* set the stream id */ 176 - snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0, 177 AC_VERB_SET_CHANNEL_STREAMID, 0); 178 /* set the stream format */ 179 - snd_hda_codec_write(codec, nvhdmi_convert_nids[i], 0, 180 AC_VERB_SET_STREAM_FORMAT, 0); 181 } 182 ··· 187 struct hda_codec *codec, 188 struct snd_pcm_substream *substream) 189 { 190 - struct nvhdmi_spec *spec = codec->spec; 191 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 192 } 193 194 static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, ··· 247 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ 248 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) 249 snd_hda_codec_write(codec, 250 - Nv_Master_Convert_nid, 251 0, 252 AC_VERB_SET_DIGI_CONVERT_1, 253 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); 254 255 /* set the stream id */ 256 - snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0, 257 AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); 258 259 /* set the stream format */ 260 - snd_hda_codec_write(codec, Nv_Master_Convert_nid, 0, 261 AC_VERB_SET_STREAM_FORMAT, format); 262 263 /* turn on again (if needed) */ 264 /* enable and set the channel status audio/data flag */ 265 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { 266 snd_hda_codec_write(codec, 267 - Nv_Master_Convert_nid, 268 0, 269 AC_VERB_SET_DIGI_CONVERT_1, 270 codec->spdif_ctls & 0xff); 271 snd_hda_codec_write(codec, 272 - Nv_Master_Convert_nid, 273 0, 274 AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); 275 } ··· 286 if (codec->spdif_status_reset && 287 (codec->spdif_ctls & AC_DIG1_ENABLE)) 288 snd_hda_codec_write(codec, 289 - nvhdmi_convert_nids[i], 290 0, 291 AC_VERB_SET_DIGI_CONVERT_1, 292 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); 293 /* set the stream id */ 294 snd_hda_codec_write(codec, 295 - nvhdmi_convert_nids[i], 296 0, 297 AC_VERB_SET_CHANNEL_STREAMID, 298 (stream_tag << 4) | channel_id); 299 /* set the stream format */ 300 snd_hda_codec_write(codec, 301 - nvhdmi_convert_nids[i], 302 0, 303 AC_VERB_SET_STREAM_FORMAT, 304 format); ··· 307 if (codec->spdif_status_reset && 308 (codec->spdif_ctls & AC_DIG1_ENABLE)) { 309 snd_hda_codec_write(codec, 310 - nvhdmi_convert_nids[i], 311 0, 312 AC_VERB_SET_DIGI_CONVERT_1, 313 codec->spdif_ctls & 0xff); 314 snd_hda_codec_write(codec, 315 - nvhdmi_convert_nids[i], 316 0, 317 AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); 318 } ··· 327 return 0; 328 } 329 330 static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo, 331 struct hda_codec *codec, 332 unsigned int stream_tag, 333 unsigned int format, 334 struct snd_pcm_substream *substream) 335 { 336 - struct nvhdmi_spec *spec = codec->spec; 337 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, 338 format, substream); 339 } 340 341 - static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch = { 342 .substreams = 1, 343 .channels_min = 2, 344 .channels_max = 8, 345 - .nid = Nv_Master_Convert_nid, 346 .rates = SUPPORTED_RATES, 347 .maxbps = SUPPORTED_MAXBPS, 348 .formats = SUPPORTED_FORMATS, 349 .ops = { 350 .open = nvhdmi_dig_playback_pcm_open, 351 - .close = nvhdmi_dig_playback_pcm_close_8ch, 352 .prepare = nvhdmi_dig_playback_pcm_prepare_8ch 353 }, 354 }; ··· 376 .substreams = 1, 377 .channels_min = 2, 378 .channels_max = 2, 379 - .nid = Nv_Master_Convert_nid, 380 .rates = SUPPORTED_RATES, 381 .maxbps = SUPPORTED_MAXBPS, 382 .formats = SUPPORTED_FORMATS, ··· 387 }, 388 }; 389 390 - static int nvhdmi_build_pcms_8ch(struct hda_codec *codec) 391 { 392 - struct nvhdmi_spec *spec = codec->spec; 393 - struct hda_pcm *info = &spec->pcm_rec; 394 395 codec->num_pcms = 1; 396 codec->pcm_info = info; ··· 424 info->name = "NVIDIA HDMI"; 425 info->pcm_type = HDA_PCM_TYPE_HDMI; 426 info->stream[SNDRV_PCM_STREAM_PLAYBACK] 427 - = nvhdmi_pcm_digital_playback_8ch; 428 429 return 0; 430 } 431 432 static int nvhdmi_build_pcms_2ch(struct hda_codec *codec) 433 { 434 - struct nvhdmi_spec *spec = codec->spec; 435 - struct hda_pcm *info = &spec->pcm_rec; 436 437 codec->num_pcms = 1; 438 codec->pcm_info = info; ··· 445 return 0; 446 } 447 448 - static void nvhdmi_free(struct hda_codec *codec) 449 - { 450 - kfree(codec->spec); 451 - } 452 - 453 - static struct hda_codec_ops nvhdmi_patch_ops_8ch = { 454 .build_controls = nvhdmi_build_controls, 455 - .build_pcms = nvhdmi_build_pcms_8ch, 456 .init = nvhdmi_init, 457 .free = nvhdmi_free, 458 }; ··· 467 .free = nvhdmi_free, 468 }; 469 470 - static int patch_nvhdmi_8ch(struct hda_codec *codec) 471 { 472 - struct nvhdmi_spec *spec; 473 474 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 475 if (spec == NULL) ··· 506 507 spec->multiout.num_dacs = 0; /* no analog */ 508 spec->multiout.max_channels = 8; 509 - spec->multiout.dig_out_nid = Nv_Master_Convert_nid; 510 511 - codec->patch_ops = nvhdmi_patch_ops_8ch; 512 513 return 0; 514 } 515 516 static int patch_nvhdmi_2ch(struct hda_codec *codec) 517 { 518 - struct nvhdmi_spec *spec; 519 520 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 521 if (spec == NULL) ··· 526 527 spec->multiout.num_dacs = 0; /* no analog */ 528 spec->multiout.max_channels = 2; 529 - spec->multiout.dig_out_nid = Nv_Master_Convert_nid; 530 531 codec->patch_ops = nvhdmi_patch_ops_2ch; 532 ··· 538 * patch entries 539 */ 540 static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { 541 - { .id = 0x10de0002, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, 542 - { .id = 0x10de0003, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, 543 - { .id = 0x10de0005, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, 544 - { .id = 0x10de0006, .name = "MCP78 HDMI", .patch = patch_nvhdmi_8ch }, 545 - { .id = 0x10de0007, .name = "MCP7A HDMI", .patch = patch_nvhdmi_8ch }, 546 { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, 547 { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, 548 {} /* terminator */ 549 }; 550 ··· 566 MODULE_ALIAS("snd-hda-codec-id:10de0007"); 567 MODULE_ALIAS("snd-hda-codec-id:10de0067"); 568 MODULE_ALIAS("snd-hda-codec-id:10de8001"); 569 570 MODULE_LICENSE("GPL"); 571 - MODULE_DESCRIPTION("Nvidia HDMI HD-audio codec"); 572 573 static struct hda_codec_preset_list nvhdmi_list = { 574 .preset = snd_hda_preset_nvhdmi,
··· 29 #include "hda_codec.h" 30 #include "hda_local.h" 31 32 + #define MAX_HDMI_CVTS 1 33 + #define MAX_HDMI_PINS 1 34 + 35 + #include "patch_hdmi.c" 36 + 37 + static char *nvhdmi_pcm_names[MAX_HDMI_CVTS] = { 38 + "NVIDIA HDMI", 39 + }; 40 + 41 /* define below to restrict the supported rates and formats */ 42 /* #define LIMITED_RATE_FMT_SUPPORT */ 43 44 + enum HDACodec { 45 + HDA_CODEC_NVIDIA_MCP7X, 46 + HDA_CODEC_NVIDIA_MCP89, 47 + HDA_CODEC_NVIDIA_GT21X, 48 + HDA_CODEC_INVALID 49 }; 50 51 #define Nv_VERB_SET_Channel_Allocation 0xF79 ··· 43 #define Nv_VERB_SET_Audio_Protection_On 0xF98 44 #define Nv_VERB_SET_Audio_Protection_Off 0xF99 45 46 + #define nvhdmi_master_con_nid_7x 0x04 47 + #define nvhdmi_master_pin_nid_7x 0x05 48 49 + #define nvhdmi_master_con_nid_89 0x04 50 + #define nvhdmi_master_pin_nid_89 0x05 51 + 52 + static hda_nid_t nvhdmi_con_nids_7x[4] = { 53 /*front, rear, clfe, rear_surr */ 54 0x6, 0x8, 0xa, 0xc, 55 }; 56 57 + static struct hda_verb nvhdmi_basic_init_7x[] = { 58 /* set audio protect on */ 59 { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1}, 60 /* enable digital output on pin widget */ ··· 84 */ 85 static int nvhdmi_build_controls(struct hda_codec *codec) 86 { 87 + struct hdmi_spec *spec = codec->spec; 88 int err; 89 + int i; 90 91 + if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) 92 + || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { 93 + for (i = 0; i < codec->num_pcms; i++) { 94 + err = snd_hda_create_spdif_out_ctls(codec, 95 + spec->cvt[i]); 96 + if (err < 0) 97 + return err; 98 + } 99 + } else { 100 + err = snd_hda_create_spdif_out_ctls(codec, 101 + spec->multiout.dig_out_nid); 102 + if (err < 0) 103 + return err; 104 + } 105 106 return 0; 107 } 108 109 static int nvhdmi_init(struct hda_codec *codec) 110 { 111 + struct hdmi_spec *spec = codec->spec; 112 + int i; 113 + if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) 114 + || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { 115 + for (i = 0; spec->pin[i]; i++) { 116 + hdmi_enable_output(codec, spec->pin[i]); 117 + snd_hda_codec_write(codec, spec->pin[i], 0, 118 + AC_VERB_SET_UNSOLICITED_ENABLE, 119 + AC_USRSP_EN | spec->pin[i]); 120 + } 121 + } else { 122 + snd_hda_sequence_write(codec, nvhdmi_basic_init_7x); 123 + } 124 return 0; 125 + } 126 + 127 + static void nvhdmi_free(struct hda_codec *codec) 128 + { 129 + struct hdmi_spec *spec = codec->spec; 130 + int i; 131 + 132 + if ((spec->codec_type == HDA_CODEC_NVIDIA_MCP89) 133 + || (spec->codec_type == HDA_CODEC_NVIDIA_GT21X)) { 134 + for (i = 0; i < spec->num_pins; i++) 135 + snd_hda_eld_proc_free(codec, &spec->sink_eld[i]); 136 + } 137 + 138 + kfree(spec); 139 } 140 141 /* ··· 107 struct hda_codec *codec, 108 struct snd_pcm_substream *substream) 109 { 110 + struct hdmi_spec *spec = codec->spec; 111 return snd_hda_multi_out_dig_open(codec, &spec->multiout); 112 } 113 114 + static int nvhdmi_dig_playback_pcm_close_8ch_7x(struct hda_pcm_stream *hinfo, 115 struct hda_codec *codec, 116 struct snd_pcm_substream *substream) 117 { 118 + struct hdmi_spec *spec = codec->spec; 119 int i; 120 121 + snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 122 0, AC_VERB_SET_CHANNEL_STREAMID, 0); 123 for (i = 0; i < 4; i++) { 124 /* set the stream id */ 125 + snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, 126 AC_VERB_SET_CHANNEL_STREAMID, 0); 127 /* set the stream format */ 128 + snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0, 129 AC_VERB_SET_STREAM_FORMAT, 0); 130 } 131 ··· 136 struct hda_codec *codec, 137 struct snd_pcm_substream *substream) 138 { 139 + struct hdmi_spec *spec = codec->spec; 140 return snd_hda_multi_out_dig_close(codec, &spec->multiout); 141 + } 142 + 143 + static int nvhdmi_dig_playback_pcm_prepare_8ch_89(struct hda_pcm_stream *hinfo, 144 + struct hda_codec *codec, 145 + unsigned int stream_tag, 146 + unsigned int format, 147 + struct snd_pcm_substream *substream) 148 + { 149 + hdmi_set_channel_count(codec, hinfo->nid, 150 + substream->runtime->channels); 151 + 152 + hdmi_setup_audio_infoframe(codec, hinfo->nid, substream); 153 + 154 + hdmi_setup_stream(codec, hinfo->nid, stream_tag, format); 155 + return 0; 156 } 157 158 static int nvhdmi_dig_playback_pcm_prepare_8ch(struct hda_pcm_stream *hinfo, ··· 181 /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */ 182 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) 183 snd_hda_codec_write(codec, 184 + nvhdmi_master_con_nid_7x, 185 0, 186 AC_VERB_SET_DIGI_CONVERT_1, 187 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); 188 189 /* set the stream id */ 190 + snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, 191 AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0); 192 193 /* set the stream format */ 194 + snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0, 195 AC_VERB_SET_STREAM_FORMAT, format); 196 197 /* turn on again (if needed) */ 198 /* enable and set the channel status audio/data flag */ 199 if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) { 200 snd_hda_codec_write(codec, 201 + nvhdmi_master_con_nid_7x, 202 0, 203 AC_VERB_SET_DIGI_CONVERT_1, 204 codec->spdif_ctls & 0xff); 205 snd_hda_codec_write(codec, 206 + nvhdmi_master_con_nid_7x, 207 0, 208 AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); 209 } ··· 220 if (codec->spdif_status_reset && 221 (codec->spdif_ctls & AC_DIG1_ENABLE)) 222 snd_hda_codec_write(codec, 223 + nvhdmi_con_nids_7x[i], 224 0, 225 AC_VERB_SET_DIGI_CONVERT_1, 226 codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff); 227 /* set the stream id */ 228 snd_hda_codec_write(codec, 229 + nvhdmi_con_nids_7x[i], 230 0, 231 AC_VERB_SET_CHANNEL_STREAMID, 232 (stream_tag << 4) | channel_id); 233 /* set the stream format */ 234 snd_hda_codec_write(codec, 235 + nvhdmi_con_nids_7x[i], 236 0, 237 AC_VERB_SET_STREAM_FORMAT, 238 format); ··· 241 if (codec->spdif_status_reset && 242 (codec->spdif_ctls & AC_DIG1_ENABLE)) { 243 snd_hda_codec_write(codec, 244 + nvhdmi_con_nids_7x[i], 245 0, 246 AC_VERB_SET_DIGI_CONVERT_1, 247 codec->spdif_ctls & 0xff); 248 snd_hda_codec_write(codec, 249 + nvhdmi_con_nids_7x[i], 250 0, 251 AC_VERB_SET_DIGI_CONVERT_2, dataDCC2); 252 } ··· 261 return 0; 262 } 263 264 + static int nvhdmi_playback_pcm_cleanup(struct hda_pcm_stream *hinfo, 265 + struct hda_codec *codec, 266 + struct snd_pcm_substream *substream) 267 + { 268 + return 0; 269 + } 270 + 271 static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo, 272 struct hda_codec *codec, 273 unsigned int stream_tag, 274 unsigned int format, 275 struct snd_pcm_substream *substream) 276 { 277 + struct hdmi_spec *spec = codec->spec; 278 return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag, 279 format, substream); 280 } 281 282 + static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_89 = { 283 + .substreams = 1, 284 + .channels_min = 2, 285 + .rates = SUPPORTED_RATES, 286 + .maxbps = SUPPORTED_MAXBPS, 287 + .formats = SUPPORTED_FORMATS, 288 + .ops = { 289 + .prepare = nvhdmi_dig_playback_pcm_prepare_8ch_89, 290 + .cleanup = nvhdmi_playback_pcm_cleanup, 291 + }, 292 + }; 293 + 294 + static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_7x = { 295 .substreams = 1, 296 .channels_min = 2, 297 .channels_max = 8, 298 + .nid = nvhdmi_master_con_nid_7x, 299 .rates = SUPPORTED_RATES, 300 .maxbps = SUPPORTED_MAXBPS, 301 .formats = SUPPORTED_FORMATS, 302 .ops = { 303 .open = nvhdmi_dig_playback_pcm_open, 304 + .close = nvhdmi_dig_playback_pcm_close_8ch_7x, 305 .prepare = nvhdmi_dig_playback_pcm_prepare_8ch 306 }, 307 }; ··· 291 .substreams = 1, 292 .channels_min = 2, 293 .channels_max = 2, 294 + .nid = nvhdmi_master_con_nid_7x, 295 .rates = SUPPORTED_RATES, 296 .maxbps = SUPPORTED_MAXBPS, 297 .formats = SUPPORTED_FORMATS, ··· 302 }, 303 }; 304 305 + static int nvhdmi_build_pcms_8ch_89(struct hda_codec *codec) 306 { 307 + struct hdmi_spec *spec = codec->spec; 308 + struct hda_pcm *info = spec->pcm_rec; 309 + int i; 310 + 311 + codec->num_pcms = spec->num_cvts; 312 + codec->pcm_info = info; 313 + 314 + for (i = 0; i < codec->num_pcms; i++, info++) { 315 + unsigned int chans; 316 + 317 + chans = get_wcaps(codec, spec->cvt[i]); 318 + chans = get_wcaps_channels(chans); 319 + 320 + info->name = nvhdmi_pcm_names[i]; 321 + info->pcm_type = HDA_PCM_TYPE_HDMI; 322 + info->stream[SNDRV_PCM_STREAM_PLAYBACK] 323 + = nvhdmi_pcm_digital_playback_8ch_89; 324 + info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->cvt[i]; 325 + info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = chans; 326 + } 327 + 328 + return 0; 329 + } 330 + 331 + static int nvhdmi_build_pcms_8ch_7x(struct hda_codec *codec) 332 + { 333 + struct hdmi_spec *spec = codec->spec; 334 + struct hda_pcm *info = spec->pcm_rec; 335 336 codec->num_pcms = 1; 337 codec->pcm_info = info; ··· 313 info->name = "NVIDIA HDMI"; 314 info->pcm_type = HDA_PCM_TYPE_HDMI; 315 info->stream[SNDRV_PCM_STREAM_PLAYBACK] 316 + = nvhdmi_pcm_digital_playback_8ch_7x; 317 318 return 0; 319 } 320 321 static int nvhdmi_build_pcms_2ch(struct hda_codec *codec) 322 { 323 + struct hdmi_spec *spec = codec->spec; 324 + struct hda_pcm *info = spec->pcm_rec; 325 326 codec->num_pcms = 1; 327 codec->pcm_info = info; ··· 334 return 0; 335 } 336 337 + static struct hda_codec_ops nvhdmi_patch_ops_8ch_89 = { 338 .build_controls = nvhdmi_build_controls, 339 + .build_pcms = nvhdmi_build_pcms_8ch_89, 340 + .init = nvhdmi_init, 341 + .free = nvhdmi_free, 342 + .unsol_event = hdmi_unsol_event, 343 + }; 344 + 345 + static struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = { 346 + .build_controls = nvhdmi_build_controls, 347 + .build_pcms = nvhdmi_build_pcms_8ch_7x, 348 .init = nvhdmi_init, 349 .free = nvhdmi_free, 350 }; ··· 353 .free = nvhdmi_free, 354 }; 355 356 + static int patch_nvhdmi_8ch_89(struct hda_codec *codec) 357 { 358 + struct hdmi_spec *spec; 359 + int i; 360 + 361 + spec = kzalloc(sizeof(*spec), GFP_KERNEL); 362 + if (spec == NULL) 363 + return -ENOMEM; 364 + 365 + codec->spec = spec; 366 + spec->codec_type = HDA_CODEC_NVIDIA_MCP89; 367 + 368 + if (hdmi_parse_codec(codec) < 0) { 369 + codec->spec = NULL; 370 + kfree(spec); 371 + return -EINVAL; 372 + } 373 + codec->patch_ops = nvhdmi_patch_ops_8ch_89; 374 + 375 + for (i = 0; i < spec->num_pins; i++) 376 + snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i); 377 + 378 + init_channel_allocations(); 379 + 380 + return 0; 381 + } 382 + 383 + static int patch_nvhdmi_8ch_7x(struct hda_codec *codec) 384 + { 385 + struct hdmi_spec *spec; 386 387 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 388 if (spec == NULL) ··· 365 366 spec->multiout.num_dacs = 0; /* no analog */ 367 spec->multiout.max_channels = 8; 368 + spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; 369 + spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; 370 371 + codec->patch_ops = nvhdmi_patch_ops_8ch_7x; 372 373 return 0; 374 } 375 376 static int patch_nvhdmi_2ch(struct hda_codec *codec) 377 { 378 + struct hdmi_spec *spec; 379 380 spec = kzalloc(sizeof(*spec), GFP_KERNEL); 381 if (spec == NULL) ··· 384 385 spec->multiout.num_dacs = 0; /* no analog */ 386 spec->multiout.max_channels = 2; 387 + spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x; 388 + spec->codec_type = HDA_CODEC_NVIDIA_MCP7X; 389 390 codec->patch_ops = nvhdmi_patch_ops_2ch; 391 ··· 395 * patch entries 396 */ 397 static struct hda_codec_preset snd_hda_preset_nvhdmi[] = { 398 { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch }, 399 { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch }, 400 + { .id = 0x10de0002, .name = "MCP77/78 HDMI", 401 + .patch = patch_nvhdmi_8ch_7x }, 402 + { .id = 0x10de0003, .name = "MCP77/78 HDMI", 403 + .patch = patch_nvhdmi_8ch_7x }, 404 + { .id = 0x10de0005, .name = "MCP77/78 HDMI", 405 + .patch = patch_nvhdmi_8ch_7x }, 406 + { .id = 0x10de0006, .name = "MCP77/78 HDMI", 407 + .patch = patch_nvhdmi_8ch_7x }, 408 + { .id = 0x10de0007, .name = "MCP79/7A HDMI", 409 + .patch = patch_nvhdmi_8ch_7x }, 410 + { .id = 0x10de000c, .name = "MCP89 HDMI", 411 + .patch = patch_nvhdmi_8ch_89 }, 412 + { .id = 0x10de000b, .name = "GT21x HDMI", 413 + .patch = patch_nvhdmi_8ch_89 }, 414 + { .id = 0x10de000d, .name = "GT240 HDMI", 415 + .patch = patch_nvhdmi_8ch_89 }, 416 {} /* terminator */ 417 }; 418 ··· 412 MODULE_ALIAS("snd-hda-codec-id:10de0007"); 413 MODULE_ALIAS("snd-hda-codec-id:10de0067"); 414 MODULE_ALIAS("snd-hda-codec-id:10de8001"); 415 + MODULE_ALIAS("snd-hda-codec-id:10de000c"); 416 + MODULE_ALIAS("snd-hda-codec-id:10de000b"); 417 + MODULE_ALIAS("snd-hda-codec-id:10de000d"); 418 419 MODULE_LICENSE("GPL"); 420 + MODULE_DESCRIPTION("NVIDIA HDMI HD-audio codec"); 421 422 static struct hda_codec_preset_list nvhdmi_list = { 423 .preset = snd_hda_preset_nvhdmi,
+9 -1
sound/pci/hda/patch_realtek.c
··· 4915 static void fixup_single_adc(struct hda_codec *codec) 4916 { 4917 struct alc_spec *spec = codec->spec; 4918 - hda_nid_t pin; 4919 int i; 4920 4921 /* search for the input pin; there must be only one */ ··· 13561 static void alc269_quanta_fl1_setup(struct hda_codec *codec) 13562 { 13563 struct alc_spec *spec = codec->spec; 13564 spec->ext_mic.pin = 0x18; 13565 spec->ext_mic.mux_idx = 0; 13566 spec->int_mic.pin = 0x19; ··· 13658 static void alc269_laptop_dmic_setup(struct hda_codec *codec) 13659 { 13660 struct alc_spec *spec = codec->spec; 13661 spec->ext_mic.pin = 0x18; 13662 spec->ext_mic.mux_idx = 0; 13663 spec->int_mic.pin = 0x12; ··· 13670 static void alc269vb_laptop_dmic_setup(struct hda_codec *codec) 13671 { 13672 struct alc_spec *spec = codec->spec; 13673 spec->ext_mic.pin = 0x18; 13674 spec->ext_mic.mux_idx = 0; 13675 spec->int_mic.pin = 0x12; ··· 13682 static void alc269_laptop_amic_setup(struct hda_codec *codec) 13683 { 13684 struct alc_spec *spec = codec->spec; 13685 spec->ext_mic.pin = 0x18; 13686 spec->ext_mic.mux_idx = 0; 13687 spec->int_mic.pin = 0x19;
··· 4915 static void fixup_single_adc(struct hda_codec *codec) 4916 { 4917 struct alc_spec *spec = codec->spec; 4918 + hda_nid_t pin = 0; 4919 int i; 4920 4921 /* search for the input pin; there must be only one */ ··· 13561 static void alc269_quanta_fl1_setup(struct hda_codec *codec) 13562 { 13563 struct alc_spec *spec = codec->spec; 13564 + spec->autocfg.hp_pins[0] = 0x15; 13565 + spec->autocfg.speaker_pins[0] = 0x14; 13566 spec->ext_mic.pin = 0x18; 13567 spec->ext_mic.mux_idx = 0; 13568 spec->int_mic.pin = 0x19; ··· 13656 static void alc269_laptop_dmic_setup(struct hda_codec *codec) 13657 { 13658 struct alc_spec *spec = codec->spec; 13659 + spec->autocfg.hp_pins[0] = 0x15; 13660 + spec->autocfg.speaker_pins[0] = 0x14; 13661 spec->ext_mic.pin = 0x18; 13662 spec->ext_mic.mux_idx = 0; 13663 spec->int_mic.pin = 0x12; ··· 13666 static void alc269vb_laptop_dmic_setup(struct hda_codec *codec) 13667 { 13668 struct alc_spec *spec = codec->spec; 13669 + spec->autocfg.hp_pins[0] = 0x15; 13670 + spec->autocfg.speaker_pins[0] = 0x14; 13671 spec->ext_mic.pin = 0x18; 13672 spec->ext_mic.mux_idx = 0; 13673 spec->int_mic.pin = 0x12; ··· 13676 static void alc269_laptop_amic_setup(struct hda_codec *codec) 13677 { 13678 struct alc_spec *spec = codec->spec; 13679 + spec->autocfg.hp_pins[0] = 0x15; 13680 + spec->autocfg.speaker_pins[0] = 0x14; 13681 spec->ext_mic.pin = 0x18; 13682 spec->ext_mic.mux_idx = 0; 13683 spec->int_mic.pin = 0x19;