Merge branch 'fix/hda' into for-linus

+120 -15
+18 -8
sound/pci/hda/hda_codec.c
··· 1261 1261 } 1262 1262 EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream); 1263 1263 1264 + static void really_cleanup_stream(struct hda_codec *codec, 1265 + struct hda_cvt_setup *q); 1266 + 1264 1267 /** 1265 - * snd_hda_codec_cleanup_stream - clean up the codec for closing 1268 + * __snd_hda_codec_cleanup_stream - clean up the codec for closing 1266 1269 * @codec: the CODEC to clean up 1267 1270 * @nid: the NID to clean up 1271 + * @do_now: really clean up the stream instead of clearing the active flag 1268 1272 */ 1269 - void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) 1273 + void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid, 1274 + int do_now) 1270 1275 { 1271 1276 struct hda_cvt_setup *p; 1272 1277 ··· 1279 1274 return; 1280 1275 1281 1276 snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid); 1282 - /* here we just clear the active flag; actual clean-ups will be done 1283 - * in purify_inactive_streams() 1284 - */ 1285 1277 p = get_hda_cvt_setup(codec, nid); 1286 - if (p) 1287 - p->active = 0; 1278 + if (p) { 1279 + /* here we just clear the active flag when do_now isn't set; 1280 + * actual clean-ups will be done later in 1281 + * purify_inactive_streams() called from snd_hda_codec_prpapre() 1282 + */ 1283 + if (do_now) 1284 + really_cleanup_stream(codec, p); 1285 + else 1286 + p->active = 0; 1287 + } 1288 1288 } 1289 - EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); 1289 + EXPORT_SYMBOL_HDA(__snd_hda_codec_cleanup_stream); 1290 1290 1291 1291 static void really_cleanup_stream(struct hda_codec *codec, 1292 1292 struct hda_cvt_setup *q)
+4 -1
sound/pci/hda/hda_codec.h
··· 963 963 void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, 964 964 u32 stream_tag, 965 965 int channel_id, int format); 966 - void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid); 966 + void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid, 967 + int do_now); 968 + #define snd_hda_codec_cleanup_stream(codec, nid) \ 969 + __snd_hda_codec_cleanup_stream(codec, nid, 0) 967 970 unsigned int snd_hda_calc_stream_format(unsigned int rate, 968 971 unsigned int channels, 969 972 unsigned int format,
+49
sound/pci/hda/hda_eld.c
··· 596 596 } 597 597 EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free); 598 598 599 + /* update PCM info based on ELD */ 600 + void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm, 601 + struct hda_pcm_stream *codec_pars) 602 + { 603 + int i; 604 + 605 + pcm->rates = 0; 606 + pcm->formats = 0; 607 + pcm->maxbps = 0; 608 + pcm->channels_min = -1; 609 + pcm->channels_max = 0; 610 + for (i = 0; i < eld->sad_count; i++) { 611 + struct cea_sad *a = &eld->sad[i]; 612 + pcm->rates |= a->rates; 613 + if (a->channels < pcm->channels_min) 614 + pcm->channels_min = a->channels; 615 + if (a->channels > pcm->channels_max) 616 + pcm->channels_max = a->channels; 617 + if (a->format == AUDIO_CODING_TYPE_LPCM) { 618 + if (a->sample_bits & AC_SUPPCM_BITS_16) { 619 + pcm->formats |= SNDRV_PCM_FMTBIT_S16_LE; 620 + if (pcm->maxbps < 16) 621 + pcm->maxbps = 16; 622 + } 623 + if (a->sample_bits & AC_SUPPCM_BITS_20) { 624 + pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE; 625 + if (pcm->maxbps < 20) 626 + pcm->maxbps = 20; 627 + } 628 + if (a->sample_bits & AC_SUPPCM_BITS_24) { 629 + pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE; 630 + if (pcm->maxbps < 24) 631 + pcm->maxbps = 24; 632 + } 633 + } 634 + } 635 + 636 + if (!codec_pars) 637 + return; 638 + 639 + /* restrict the parameters by the values the codec provides */ 640 + pcm->rates &= codec_pars->rates; 641 + pcm->formats &= codec_pars->formats; 642 + pcm->channels_min = max(pcm->channels_min, codec_pars->channels_min); 643 + pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max); 644 + pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps); 645 + } 646 + EXPORT_SYMBOL_HDA(hdmi_eld_update_pcm_info); 647 + 599 648 #endif /* CONFIG_PROC_FS */
+2
sound/pci/hda/hda_local.h
··· 604 604 int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); 605 605 int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t); 606 606 void snd_hdmi_show_eld(struct hdmi_eld *eld); 607 + void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm, 608 + struct hda_pcm_stream *codec_pars); 607 609 608 610 #ifdef CONFIG_PROC_FS 609 611 int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld,
+1 -1
sound/pci/hda/patch_cirrus.c
··· 656 656 return 0; 657 657 if (spec->cur_adc && spec->cur_adc != spec->adc_nid[idx]) { 658 658 /* stream is running, let's swap the current ADC */ 659 - snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 659 + __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 660 660 spec->cur_adc = spec->adc_nid[idx]; 661 661 snd_hda_codec_setup_stream(codec, spec->cur_adc, 662 662 spec->cur_adc_stream_tag, 0,
+1 -1
sound/pci/hda/patch_conexant.c
··· 1733 1733 new_adc = spec->adc_nids[spec->cur_adc_idx]; 1734 1734 if (spec->cur_adc && spec->cur_adc != new_adc) { 1735 1735 /* stream is running, let's swap the current ADC */ 1736 - snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 1736 + __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 1737 1737 spec->cur_adc = new_adc; 1738 1738 snd_hda_codec_setup_stream(codec, new_adc, 1739 1739 spec->cur_adc_stream_tag, 0,
+42
sound/pci/hda/patch_hdmi.c
··· 46 46 * export one pcm per pipe 47 47 */ 48 48 struct hda_pcm pcm_rec[MAX_HDMI_CVTS]; 49 + struct hda_pcm_stream codec_pcm_pars[MAX_HDMI_CVTS]; 49 50 50 51 /* 51 52 * nvhdmi specific ··· 763 762 if (fmt != format) 764 763 snd_hda_codec_write(codec, nid, 0, 765 764 AC_VERB_SET_STREAM_FORMAT, format); 765 + return 0; 766 + } 767 + 768 + /* 769 + * HDA PCM callbacks 770 + */ 771 + static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, 772 + struct hda_codec *codec, 773 + struct snd_pcm_substream *substream) 774 + { 775 + struct hdmi_spec *spec = codec->spec; 776 + struct hdmi_eld *eld; 777 + struct hda_pcm_stream *codec_pars; 778 + unsigned int idx; 779 + 780 + for (idx = 0; idx < spec->num_cvts; idx++) 781 + if (hinfo->nid == spec->cvt[idx]) 782 + break; 783 + if (snd_BUG_ON(idx >= spec->num_cvts) || 784 + snd_BUG_ON(idx >= spec->num_pins)) 785 + return -EINVAL; 786 + 787 + /* save the PCM info the codec provides */ 788 + codec_pars = &spec->codec_pcm_pars[idx]; 789 + if (!codec_pars->rates) 790 + *codec_pars = *hinfo; 791 + 792 + eld = &spec->sink_eld[idx]; 793 + if (eld->sad_count > 0) { 794 + hdmi_eld_update_pcm_info(eld, hinfo, codec_pars); 795 + if (hinfo->channels_min > hinfo->channels_max || 796 + !hinfo->rates || !hinfo->formats) 797 + return -ENODEV; 798 + } else { 799 + /* fallback to the codec default */ 800 + hinfo->channels_min = codec_pars->channels_min; 801 + hinfo->channels_max = codec_pars->channels_max; 802 + hinfo->rates = codec_pars->rates; 803 + hinfo->formats = codec_pars->formats; 804 + hinfo->maxbps = codec_pars->maxbps; 805 + } 766 806 return 0; 767 807 } 768 808
+1
sound/pci/hda/patch_intelhdmi.c
··· 80 80 .substreams = 1, 81 81 .channels_min = 2, 82 82 .ops = { 83 + .open = hdmi_pcm_open, 83 84 .prepare = intel_hdmi_playback_pcm_prepare, 84 85 .cleanup = intel_hdmi_playback_pcm_cleanup, 85 86 },
+1 -3
sound/pci/hda/patch_nvhdmi.c
··· 347 347 static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_89 = { 348 348 .substreams = 1, 349 349 .channels_min = 2, 350 - .rates = SUPPORTED_RATES, 351 - .maxbps = SUPPORTED_MAXBPS, 352 - .formats = SUPPORTED_FORMATS, 353 350 .ops = { 351 + .open = hdmi_pcm_open, 354 352 .prepare = nvhdmi_dig_playback_pcm_prepare_8ch_89, 355 353 .cleanup = nvhdmi_playback_pcm_cleanup, 356 354 },
+1 -1
sound/pci/hda/patch_realtek.c
··· 1037 1037 new_adc = spec->adc_nids[spec->cur_adc_idx]; 1038 1038 if (spec->cur_adc && spec->cur_adc != new_adc) { 1039 1039 /* stream is running, let's swap the current ADC */ 1040 - snd_hda_codec_cleanup_stream(codec, spec->cur_adc); 1040 + __snd_hda_codec_cleanup_stream(codec, spec->cur_adc, 1); 1041 1041 spec->cur_adc = new_adc; 1042 1042 snd_hda_codec_setup_stream(codec, new_adc, 1043 1043 spec->cur_adc_stream_tag, 0,