diff options
author | Takashi Iwai <tiwai@suse.de> | 2010-08-15 08:33:56 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-08-15 08:33:56 -0400 |
commit | 18c5ef385c65360761f39d55b2e2cd370ab151db (patch) | |
tree | 51ffa37ad94600f908867196dd9f216e42163de7 | |
parent | 38d7b08f374b640b00d350ac2d12ffed5d723423 (diff) | |
parent | f0cea79724f03ee55e7b5933b6a6f6a3fd177710 (diff) |
Merge branch 'fix/hda' into for-linus
-rw-r--r-- | sound/pci/hda/hda_codec.c | 26 | ||||
-rw-r--r-- | sound/pci/hda/hda_codec.h | 5 | ||||
-rw-r--r-- | sound/pci/hda/hda_eld.c | 49 | ||||
-rw-r--r-- | sound/pci/hda/hda_local.h | 2 | ||||
-rw-r--r-- | sound/pci/hda/patch_cirrus.c | 2 | ||||
-rw-r--r-- | sound/pci/hda/patch_conexant.c | 2 | ||||
-rw-r--r-- | sound/pci/hda/patch_hdmi.c | 42 | ||||
-rw-r--r-- | sound/pci/hda/patch_intelhdmi.c | 1 | ||||
-rw-r--r-- | sound/pci/hda/patch_nvhdmi.c | 4 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 2 |
10 files changed, 120 insertions, 15 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 720a81d711e3..dd8fb86c842b 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -1261,12 +1261,17 @@ void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, | |||
1261 | } | 1261 | } |
1262 | EXPORT_SYMBOL_HDA(snd_hda_codec_setup_stream); | 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 | * @codec: the CODEC to clean up | 1269 | * @codec: the CODEC to clean up |
1267 | * @nid: the NID to clean up | 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 | struct hda_cvt_setup *p; | 1276 | struct hda_cvt_setup *p; |
1272 | 1277 | ||
@@ -1274,14 +1279,19 @@ void snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid) | |||
1274 | return; | 1279 | return; |
1275 | 1280 | ||
1276 | snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid); | 1281 | snd_printdd("hda_codec_cleanup_stream: NID=0x%x\n", nid); |
1277 | /* here we just clear the active flag; actual clean-ups will be done | ||
1278 | * in purify_inactive_streams() | ||
1279 | */ | ||
1280 | p = get_hda_cvt_setup(codec, nid); | 1282 | p = get_hda_cvt_setup(codec, nid); |
1281 | if (p) | 1283 | if (p) { |
1282 | p->active = 0; | 1284 | /* here we just clear the active flag when do_now isn't set; |
1285 | * actual clean-ups will be done later in | ||
1286 | * purify_inactive_streams() called from snd_hda_codec_prpapre() | ||
1287 | */ | ||
1288 | if (do_now) | ||
1289 | really_cleanup_stream(codec, p); | ||
1290 | else | ||
1291 | p->active = 0; | ||
1292 | } | ||
1283 | } | 1293 | } |
1284 | EXPORT_SYMBOL_HDA(snd_hda_codec_cleanup_stream); | 1294 | EXPORT_SYMBOL_HDA(__snd_hda_codec_cleanup_stream); |
1285 | 1295 | ||
1286 | static void really_cleanup_stream(struct hda_codec *codec, | 1296 | static void really_cleanup_stream(struct hda_codec *codec, |
1287 | struct hda_cvt_setup *q) | 1297 | struct hda_cvt_setup *q) |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 3f7a479881e5..4303353feda9 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -963,7 +963,10 @@ void snd_hda_codec_cleanup(struct hda_codec *codec, | |||
963 | void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, | 963 | void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid, |
964 | u32 stream_tag, | 964 | u32 stream_tag, |
965 | int channel_id, int format); | 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 | unsigned int snd_hda_calc_stream_format(unsigned int rate, | 970 | unsigned int snd_hda_calc_stream_format(unsigned int rate, |
968 | unsigned int channels, | 971 | unsigned int channels, |
969 | unsigned int format, | 972 | unsigned int format, |
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index d8da18a9e98b..803b298f7411 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c | |||
@@ -596,4 +596,53 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) | |||
596 | } | 596 | } |
597 | EXPORT_SYMBOL_HDA(snd_hda_eld_proc_free); | 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 | #endif /* CONFIG_PROC_FS */ | 648 | #endif /* CONFIG_PROC_FS */ |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 7a97f126f6f7..28ab4aead48f 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -604,6 +604,8 @@ struct hdmi_eld { | |||
604 | int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); | 604 | int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); |
605 | int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t); | 605 | int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t); |
606 | void snd_hdmi_show_eld(struct hdmi_eld *eld); | 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 | #ifdef CONFIG_PROC_FS | 610 | #ifdef CONFIG_PROC_FS |
609 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, | 611 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, |
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c index 350ee8ac4153..4ef5efaaaef1 100644 --- a/sound/pci/hda/patch_cirrus.c +++ b/sound/pci/hda/patch_cirrus.c | |||
@@ -656,7 +656,7 @@ static int change_cur_input(struct hda_codec *codec, unsigned int idx, | |||
656 | return 0; | 656 | return 0; |
657 | if (spec->cur_adc && spec->cur_adc != spec->adc_nid[idx]) { | 657 | if (spec->cur_adc && spec->cur_adc != spec->adc_nid[idx]) { |
658 | /* stream is running, let's swap the current ADC */ | 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 | spec->cur_adc = spec->adc_nid[idx]; | 660 | spec->cur_adc = spec->adc_nid[idx]; |
661 | snd_hda_codec_setup_stream(codec, spec->cur_adc, | 661 | snd_hda_codec_setup_stream(codec, spec->cur_adc, |
662 | spec->cur_adc_stream_tag, 0, | 662 | spec->cur_adc_stream_tag, 0, |
diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c index f7e234e5ee96..31b5d9eeba68 100644 --- a/sound/pci/hda/patch_conexant.c +++ b/sound/pci/hda/patch_conexant.c | |||
@@ -1733,7 +1733,7 @@ static void cxt5051_portc_automic(struct hda_codec *codec) | |||
1733 | new_adc = spec->adc_nids[spec->cur_adc_idx]; | 1733 | new_adc = spec->adc_nids[spec->cur_adc_idx]; |
1734 | if (spec->cur_adc && spec->cur_adc != new_adc) { | 1734 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
1735 | /* stream is running, let's swap the current ADC */ | 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 | spec->cur_adc = new_adc; | 1737 | spec->cur_adc = new_adc; |
1738 | snd_hda_codec_setup_stream(codec, new_adc, | 1738 | snd_hda_codec_setup_stream(codec, new_adc, |
1739 | spec->cur_adc_stream_tag, 0, | 1739 | spec->cur_adc_stream_tag, 0, |
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 522e0748ee99..2bc0f07cf33f 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c | |||
@@ -46,6 +46,7 @@ struct hdmi_spec { | |||
46 | * export one pcm per pipe | 46 | * export one pcm per pipe |
47 | */ | 47 | */ |
48 | struct hda_pcm pcm_rec[MAX_HDMI_CVTS]; | 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 | * nvhdmi specific | 52 | * nvhdmi specific |
@@ -766,6 +767,47 @@ static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid, | |||
766 | } | 767 | } |
767 | 768 | ||
768 | /* | 769 | /* |
770 | * HDA PCM callbacks | ||
771 | */ | ||
772 | static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, | ||
773 | struct hda_codec *codec, | ||
774 | struct snd_pcm_substream *substream) | ||
775 | { | ||
776 | struct hdmi_spec *spec = codec->spec; | ||
777 | struct hdmi_eld *eld; | ||
778 | struct hda_pcm_stream *codec_pars; | ||
779 | unsigned int idx; | ||
780 | |||
781 | for (idx = 0; idx < spec->num_cvts; idx++) | ||
782 | if (hinfo->nid == spec->cvt[idx]) | ||
783 | break; | ||
784 | if (snd_BUG_ON(idx >= spec->num_cvts) || | ||
785 | snd_BUG_ON(idx >= spec->num_pins)) | ||
786 | return -EINVAL; | ||
787 | |||
788 | /* save the PCM info the codec provides */ | ||
789 | codec_pars = &spec->codec_pcm_pars[idx]; | ||
790 | if (!codec_pars->rates) | ||
791 | *codec_pars = *hinfo; | ||
792 | |||
793 | eld = &spec->sink_eld[idx]; | ||
794 | if (eld->sad_count > 0) { | ||
795 | hdmi_eld_update_pcm_info(eld, hinfo, codec_pars); | ||
796 | if (hinfo->channels_min > hinfo->channels_max || | ||
797 | !hinfo->rates || !hinfo->formats) | ||
798 | return -ENODEV; | ||
799 | } else { | ||
800 | /* fallback to the codec default */ | ||
801 | hinfo->channels_min = codec_pars->channels_min; | ||
802 | hinfo->channels_max = codec_pars->channels_max; | ||
803 | hinfo->rates = codec_pars->rates; | ||
804 | hinfo->formats = codec_pars->formats; | ||
805 | hinfo->maxbps = codec_pars->maxbps; | ||
806 | } | ||
807 | return 0; | ||
808 | } | ||
809 | |||
810 | /* | ||
769 | * HDA/HDMI auto parsing | 811 | * HDA/HDMI auto parsing |
770 | */ | 812 | */ |
771 | 813 | ||
diff --git a/sound/pci/hda/patch_intelhdmi.c b/sound/pci/hda/patch_intelhdmi.c index 5972d5e7d01f..d382d3c81c0f 100644 --- a/sound/pci/hda/patch_intelhdmi.c +++ b/sound/pci/hda/patch_intelhdmi.c | |||
@@ -80,6 +80,7 @@ static struct hda_pcm_stream intel_hdmi_pcm_playback = { | |||
80 | .substreams = 1, | 80 | .substreams = 1, |
81 | .channels_min = 2, | 81 | .channels_min = 2, |
82 | .ops = { | 82 | .ops = { |
83 | .open = hdmi_pcm_open, | ||
83 | .prepare = intel_hdmi_playback_pcm_prepare, | 84 | .prepare = intel_hdmi_playback_pcm_prepare, |
84 | .cleanup = intel_hdmi_playback_pcm_cleanup, | 85 | .cleanup = intel_hdmi_playback_pcm_cleanup, |
85 | }, | 86 | }, |
diff --git a/sound/pci/hda/patch_nvhdmi.c b/sound/pci/hda/patch_nvhdmi.c index 77e2b4028b9f..f636870dc718 100644 --- a/sound/pci/hda/patch_nvhdmi.c +++ b/sound/pci/hda/patch_nvhdmi.c | |||
@@ -347,10 +347,8 @@ static int nvhdmi_dig_playback_pcm_prepare_2ch(struct hda_pcm_stream *hinfo, | |||
347 | static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_89 = { | 347 | static struct hda_pcm_stream nvhdmi_pcm_digital_playback_8ch_89 = { |
348 | .substreams = 1, | 348 | .substreams = 1, |
349 | .channels_min = 2, | 349 | .channels_min = 2, |
350 | .rates = SUPPORTED_RATES, | ||
351 | .maxbps = SUPPORTED_MAXBPS, | ||
352 | .formats = SUPPORTED_FORMATS, | ||
353 | .ops = { | 350 | .ops = { |
351 | .open = hdmi_pcm_open, | ||
354 | .prepare = nvhdmi_dig_playback_pcm_prepare_8ch_89, | 352 | .prepare = nvhdmi_dig_playback_pcm_prepare_8ch_89, |
355 | .cleanup = nvhdmi_playback_pcm_cleanup, | 353 | .cleanup = nvhdmi_playback_pcm_cleanup, |
356 | }, | 354 | }, |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 55d6e5b6bb7d..2cd1ae809e46 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -1037,7 +1037,7 @@ static void alc_dual_mic_adc_auto_switch(struct hda_codec *codec) | |||
1037 | new_adc = spec->adc_nids[spec->cur_adc_idx]; | 1037 | new_adc = spec->adc_nids[spec->cur_adc_idx]; |
1038 | if (spec->cur_adc && spec->cur_adc != new_adc) { | 1038 | if (spec->cur_adc && spec->cur_adc != new_adc) { |
1039 | /* stream is running, let's swap the current ADC */ | 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 | spec->cur_adc = new_adc; | 1041 | spec->cur_adc = new_adc; |
1042 | snd_hda_codec_setup_stream(codec, new_adc, | 1042 | snd_hda_codec_setup_stream(codec, new_adc, |
1043 | spec->cur_adc_stream_tag, 0, | 1043 | spec->cur_adc_stream_tag, 0, |