提交 2def8172 编写于 作者: S Stephen Warren 提交者: Takashi Iwai

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: NStephen Warren <swarren@nvidia.com>
Signed-off-by: NTakashi Iwai <tiwai@suse.de>
上级 3aaf8980
...@@ -580,43 +580,45 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld) ...@@ -580,43 +580,45 @@ void snd_hda_eld_proc_free(struct hda_codec *codec, struct hdmi_eld *eld)
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
/* update PCM info based on ELD */ /* update PCM info based on ELD */
void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm, void snd_hdmi_eld_update_pcm_info(struct hdmi_eld *eld,
struct hda_pcm_stream *codec_pars) struct hda_pcm_stream *hinfo)
{ {
u32 rates;
u64 formats;
unsigned int maxbps;
unsigned int channels_max;
int i; int i;
/* assume basic audio support (the basic audio flag is not in ELD; /* assume basic audio support (the basic audio flag is not in ELD;
* however, all audio capable sinks are required to support basic * however, all audio capable sinks are required to support basic
* audio) */ * audio) */
pcm->rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; rates = SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 |
pcm->formats = SNDRV_PCM_FMTBIT_S16_LE; SNDRV_PCM_RATE_48000;
pcm->maxbps = 16; formats = SNDRV_PCM_FMTBIT_S16_LE;
pcm->channels_max = 2; maxbps = 16;
channels_max = 2;
for (i = 0; i < eld->sad_count; i++) { for (i = 0; i < eld->sad_count; i++) {
struct cea_sad *a = &eld->sad[i]; struct cea_sad *a = &eld->sad[i];
pcm->rates |= a->rates; rates |= a->rates;
if (a->channels > pcm->channels_max) if (a->channels > channels_max)
pcm->channels_max = a->channels; channels_max = a->channels;
if (a->format == AUDIO_CODING_TYPE_LPCM) { if (a->format == AUDIO_CODING_TYPE_LPCM) {
if (a->sample_bits & AC_SUPPCM_BITS_20) { if (a->sample_bits & AC_SUPPCM_BITS_20) {
pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE; formats |= SNDRV_PCM_FMTBIT_S32_LE;
if (pcm->maxbps < 20) if (maxbps < 20)
pcm->maxbps = 20; maxbps = 20;
} }
if (a->sample_bits & AC_SUPPCM_BITS_24) { if (a->sample_bits & AC_SUPPCM_BITS_24) {
pcm->formats |= SNDRV_PCM_FMTBIT_S32_LE; formats |= SNDRV_PCM_FMTBIT_S32_LE;
if (pcm->maxbps < 24) if (maxbps < 24)
pcm->maxbps = 24; maxbps = 24;
} }
} }
} }
if (!codec_pars)
return;
/* restrict the parameters by the values the codec provides */ /* restrict the parameters by the values the codec provides */
pcm->rates &= codec_pars->rates; hinfo->rates &= rates;
pcm->formats &= codec_pars->formats; hinfo->formats &= formats;
pcm->channels_max = min(pcm->channels_max, codec_pars->channels_max); hinfo->maxbps = min(hinfo->maxbps, maxbps);
pcm->maxbps = min(pcm->maxbps, codec_pars->maxbps); hinfo->channels_max = min(hinfo->channels_max, channels_max);
} }
...@@ -641,8 +641,8 @@ struct hdmi_eld { ...@@ -641,8 +641,8 @@ struct hdmi_eld {
int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid); int snd_hdmi_get_eld_size(struct hda_codec *codec, hda_nid_t nid);
int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t); int snd_hdmi_get_eld(struct hdmi_eld *, struct hda_codec *, hda_nid_t);
void snd_hdmi_show_eld(struct hdmi_eld *eld); void snd_hdmi_show_eld(struct hdmi_eld *eld);
void hdmi_eld_update_pcm_info(struct hdmi_eld *eld, struct hda_pcm_stream *pcm, void snd_hdmi_eld_update_pcm_info(struct hdmi_eld *eld,
struct hda_pcm_stream *codec_pars); struct hda_pcm_stream *hinfo);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld, int snd_hda_eld_proc_new(struct hda_codec *codec, struct hdmi_eld *eld,
......
...@@ -815,20 +815,22 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo, ...@@ -815,20 +815,22 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
if (!codec_pars->rates) if (!codec_pars->rates)
*codec_pars = *hinfo; *codec_pars = *hinfo;
/* Initially set the converter's capabilities */
hinfo->channels_min = codec_pars->channels_min;
hinfo->channels_max = codec_pars->channels_max;
hinfo->rates = codec_pars->rates;
hinfo->formats = codec_pars->formats;
hinfo->maxbps = codec_pars->maxbps;
eld = &spec->sink_eld[idx]; eld = &spec->sink_eld[idx];
if (!static_hdmi_pcm && eld->eld_valid) { if (!static_hdmi_pcm && eld->eld_valid) {
hdmi_eld_update_pcm_info(eld, hinfo, codec_pars); snd_hdmi_eld_update_pcm_info(eld, hinfo);
if (hinfo->channels_min > hinfo->channels_max || if (hinfo->channels_min > hinfo->channels_max ||
!hinfo->rates || !hinfo->formats) !hinfo->rates || !hinfo->formats)
return -ENODEV; return -ENODEV;
} else {
/* fallback to the codec default */
hinfo->channels_max = codec_pars->channels_max;
hinfo->rates = codec_pars->rates;
hinfo->formats = codec_pars->formats;
hinfo->maxbps = codec_pars->maxbps;
} }
/* store the updated parameters */
/* Store the updated parameters */
runtime->hw.channels_min = hinfo->channels_min; runtime->hw.channels_min = hinfo->channels_min;
runtime->hw.channels_max = hinfo->channels_max; runtime->hw.channels_max = hinfo->channels_max;
runtime->hw.formats = hinfo->formats; runtime->hw.formats = hinfo->formats;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册