Skip to content

Commit 2def817

Browse files
nvswarrentiwai
authored andcommitted
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>
1 parent 3aaf898 commit 2def817

File tree

3 files changed

+36
-32
lines changed

3 files changed

+36
-32
lines changed

sound/pci/hda/hda_eld.c

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -580,43 +580,45 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)
580580
#endif /* CONFIG_PROC_FS */
581581

582582
/* update PCM info based on ELD */
583-
void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm,
584-
struct hda_pcm_stream *codec_pars)
583+
void snd_hdmi_eld_update_pcm_info(struct hdmi_eld *eld,
584+
struct hda_pcm_stream *hinfo)
585585
{
586+
u32 rates;
587+
u64 formats;
588+
unsigned int maxbps;
589+
unsigned int channels_max;
586590
int i;
587591

588592
/* assume basic audio support (the basic audio flag is not in ELD;
589593
* however, all audio capable sinks are required to support basic
590594
* audio) */
591-
pcm->rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
592-
pcm->formats = SNDRV_PCM_FMTBIT_S16_LE;
593-
pcm->maxbps = 16;
594-
pcm->channels_max = 2;
595+
rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
596+
SNDRV_PCM_RATE_48000;
597+
formats = SNDRV_PCM_FMTBIT_S16_LE;
598+
maxbps = 16;
599+
channels_max = 2;
595600
for (i = 0; i < eld->sad_count; i++) {
596601
struct cea_sad *a = &eld->sad[i];
597-
pcm->rates |= a->rates;
598-
if (a->channels > pcm->channels_max)
599-
pcm->channels_max = a->channels;
602+
rates |= a->rates;
603+
if (a->channels > channels_max)
604+
channels_max = a->channels;
600605
if (a->format == AUDIO_CODING_TYPE_LPCM) {
601606
if (a->sample_bits & AC_SUPPCM_BITS_20) {
602-
pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE;
603-
if (pcm->maxbps < 20)
604-
pcm->maxbps = 20;
607+
formats |= SNDRV_PCM_FMTBIT_S32_LE;
608+
if (maxbps < 20)
609+
maxbps = 20;
605610
}
606611
if (a->sample_bits & AC_SUPPCM_BITS_24) {
607-
pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE;
608-
if (pcm->maxbps < 24)
609-
pcm->maxbps = 24;
612+
formats |= SNDRV_PCM_FMTBIT_S32_LE;
613+
if (maxbps < 24)
614+
maxbps = 24;
610615
}
611616
}
612617
}
613618

614-
if (!codec_pars)
615-
return;
616-
617619
/* restrict the parameters by the values the codec provides */
618-
pcm->rates &= codec_pars->rates;
619-
pcm->formats &= codec_pars->formats;
620-
pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max);
621-
pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps);
620+
hinfo->rates &= rates;
621+
hinfo->formats &= formats;
622+
hinfo->maxbps = min(hinfo->maxbps, maxbps);
623+
hinfo->channels_max = min(hinfo->channels_max, channels_max);
622624
}

sound/pci/hda/hda_local.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ struct hdmi_eld {
641641
int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
642642
int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t);
643643
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,
645-
struct hda_pcm_stream *codec_pars);
644+
void snd_hdmi_eld_update_pcm_info(struct hdmi_eld *eld,
645+
struct hda_pcm_stream *hinfo);
646646

647647
#ifdef CONFIG_PROC_FS
648648
int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld,

sound/pci/hda/patch_hdmi.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -815,20 +815,22 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
815815
if (!codec_pars->rates)
816816
*codec_pars = *hinfo;
817817

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+
818825
eld = &spec->sink_eld[idx];
819826
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);
821828
if (hinfo->channels_min > hinfo->channels_max ||
822829
!hinfo->rates || !hinfo->formats)
823830
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;
830831
}
831-
/* store the updated parameters */
832+
833+
/* Store the updated parameters */
832834
runtime->hw.channels_min = hinfo->channels_min;
833835
runtime->hw.channels_max = hinfo->channels_max;
834836
runtime->hw.formats = hinfo->formats;

0 commit comments

Comments
 (0)