diff options
author | Stephen Warren <swarren@nvidia.com> | 2011-06-01 13:14:20 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-06-06 06:58:09 -0400 |
commit | 2def8172c6611f2577260287ebf5dd3b63f7ef55 (patch) | |
tree | 1f45f1e5a5051a06ac7988de36227df581403c7d /sound | |
parent | 3aaf898025b1f75f30457e00e890c9f7c43567ab (diff) |
ALSA: hda: hdmi_eld_update_pcm_info: update a stream in place
A future change won't store an entire hda_pcm_stream just to represent
the capabilities of a codec; a custom data-structure will be used. To
ease that transition, modify hdmi_eld_update_pcm_info to expect the
hda_pcm_stream to be pre-initialized with the codec's capabilities, and
to update those capabilities in-place based on the ELD.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/pci/hda/hda_eld.c | 46 | ||||
-rw-r--r-- | sound/pci/hda/hda_local.h | 4 | ||||
-rw-r--r-- | sound/pci/hda/patch_hdmi.c | 18 |
3 files changed, 36 insertions, 32 deletions
diff --git a/sound/pci/hda/hda_eld.c b/sound/pci/hda/hda_eld.c index b05f7be9dc1b..473cfa13a30d 100644 --- a/sound/pci/hda/hda_eld.c +++ b/sound/pci/hda/hda_eld.c | |||
@@ -580,43 +580,45 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) | |||
580 | #endif /* CONFIG_PROC_FS */ | 580 | #endif /* CONFIG_PROC_FS */ |
581 | 581 | ||
582 | /* update PCM info based on ELD */ | 582 | /* update PCM info based on ELD */ |
583 | void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm, | 583 | void snd_hdmi_eld_update_pcm_info(struct hdmi_eld *eld, |
584 | struct hda_pcm_stream *codec_pars) | 584 | struct hda_pcm_stream *hinfo) |
585 | { | 585 | { |
586 | u32 rates; | ||
587 | u64 formats; | ||
588 | unsigned int maxbps; | ||
589 | unsigned int channels_max; | ||
586 | int i; | 590 | int i; |
587 | 591 | ||
588 | /* assume basic audio support (the basic audio flag is not in ELD; | 592 | /* assume basic audio support (the basic audio flag is not in ELD; |
589 | * however, all audio capable sinks are required to support basic | 593 | * however, all audio capable sinks are required to support basic |
590 | * audio) */ | 594 | * audio) */ |
591 | pcm->rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; | 595 | rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | |
592 | pcm->formats = SNDRV_PCM_FMTBIT_S16_LE; | 596 | SNDRV_PCM_RATE_48000; |
593 | pcm->maxbps = 16; | 597 | formats = SNDRV_PCM_FMTBIT_S16_LE; |
594 | pcm->channels_max = 2; | 598 | maxbps = 16; |
599 | channels_max = 2; | ||
595 | for (i = 0; i < eld->sad_count; i++) { | 600 | for (i = 0; i < eld->sad_count; i++) { |
596 | struct cea_sad *a = &eld->sad[i]; | 601 | struct cea_sad *a = &eld->sad[i]; |
597 | pcm->rates |= a->rates; | 602 | rates |= a->rates; |
598 | if (a->channels > pcm->channels_max) | 603 | if (a->channels > channels_max) |
599 | pcm->channels_max = a->channels; | 604 | channels_max = a->channels; |
600 | if (a->format == AUDIO_CODING_TYPE_LPCM) { | 605 | if (a->format == AUDIO_CODING_TYPE_LPCM) { |
601 | if (a->sample_bits & AC_SUPPCM_BITS_20) { | 606 | if (a->sample_bits & AC_SUPPCM_BITS_20) { |
602 | pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE; | 607 | formats |= SNDRV_PCM_FMTBIT_S32_LE; |
603 | if (pcm->maxbps < 20) | 608 | if (maxbps < 20) |
604 | pcm->maxbps = 20; | 609 | maxbps = 20; |
605 | } | 610 | } |
606 | if (a->sample_bits & AC_SUPPCM_BITS_24) { | 611 | if (a->sample_bits & AC_SUPPCM_BITS_24) { |
607 | pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE; | 612 | formats |= SNDRV_PCM_FMTBIT_S32_LE; |
608 | if (pcm->maxbps < 24) | 613 | if (maxbps < 24) |
609 | pcm->maxbps = 24; | 614 | maxbps = 24; |
610 | } | 615 | } |
611 | } | 616 | } |
612 | } | 617 | } |
613 | 618 | ||
614 | if (!codec_pars) | ||
615 | return; | ||
616 | |||
617 | /* restrict the parameters by the values the codec provides */ | 619 | /* restrict the parameters by the values the codec provides */ |
618 | pcm->rates &= codec_pars->rates; | 620 | hinfo->rates &= rates; |
619 | pcm->formats &= codec_pars->formats; | 621 | hinfo->formats &= formats; |
620 | pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max); | 622 | hinfo->maxbps = min(hinfo->maxbps, maxbps); |
621 | pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps); | 623 | hinfo->channels_max = min(hinfo->channels_max, channels_max); |
622 | } | 624 | } |
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h index 8b88c92826a1..b333bf46a19c 100644 --- a/sound/pci/hda/hda_local.h +++ b/sound/pci/hda/hda_local.h | |||
@@ -641,8 +641,8 @@ struct hdmi_eld { | |||
641 | int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); | 641 | int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); |
642 | int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t); | 642 | int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t); |
643 | void snd_hdmi_show_eld(struct hdmi_eld *eld); | 643 | void snd_hdmi_show_eld(struct hdmi_eld *eld); |
644 | void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm, | 644 | void snd_hdmi_eld_update_pcm_info(struct hdmi_eld *eld, |
645 | struct hda_pcm_stream *codec_pars); | 645 | struct hda_pcm_stream *hinfo); |
646 | 646 | ||
647 | #ifdef CONFIG_PROC_FS | 647 | #ifdef CONFIG_PROC_FS |
648 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, | 648 | int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, |
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c index 92fb105da1e0..338546531c17 100644 --- a/sound/pci/hda/patch_hdmi.c +++ b/sound/pci/hda/patch_hdmi.c | |||
@@ -815,20 +815,22 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, | |||
815 | if (!codec_pars->rates) | 815 | if (!codec_pars->rates) |
816 | *codec_pars = *hinfo; | 816 | *codec_pars = *hinfo; |
817 | 817 | ||
818 | /* Initially set the converter's capabilities */ | ||
819 | hinfo->channels_min = codec_pars->channels_min; | ||
820 | hinfo->channels_max = codec_pars->channels_max; | ||
821 | hinfo->rates = codec_pars->rates; | ||
822 | hinfo->formats = codec_pars->formats; | ||
823 | hinfo->maxbps = codec_pars->maxbps; | ||
824 | |||
818 | eld = &spec->sink_eld[idx]; | 825 | eld = &spec->sink_eld[idx]; |
819 | if (!static_hdmi_pcm && eld->eld_valid) { | 826 | if (!static_hdmi_pcm && eld->eld_valid) { |
820 | hdmi_eld_update_pcm_info(eld, hinfo, codec_pars); | 827 | snd_hdmi_eld_update_pcm_info(eld, hinfo); |
821 | if (hinfo->channels_min > hinfo->channels_max || | 828 | if (hinfo->channels_min > hinfo->channels_max || |
822 | !hinfo->rates || !hinfo->formats) | 829 | !hinfo->rates || !hinfo->formats) |
823 | return -ENODEV; | 830 | return -ENODEV; |
824 | } else { | ||
825 | /* fallback to the codec default */ | ||
826 | hinfo->channels_max = codec_pars->channels_max; | ||
827 | hinfo->rates = codec_pars->rates; | ||
828 | hinfo->formats = codec_pars->formats; | ||
829 | hinfo->maxbps = codec_pars->maxbps; | ||
830 | } | 831 | } |
831 | /* store the updated parameters */ | 832 | |
833 | /* Store the updated parameters */ | ||
832 | runtime->hw.channels_min = hinfo->channels_min; | 834 | runtime->hw.channels_min = hinfo->channels_min; |
833 | runtime->hw.channels_max = hinfo->channels_max; | 835 | runtime->hw.channels_max = hinfo->channels_max; |
834 | runtime->hw.formats = hinfo->formats; | 836 | runtime->hw.formats = hinfo->formats; |