| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 18b1ff043d713b6b3669a8746062f2faeb6c3557 Mon Sep 17 00:00:00 2001 |
| 2 | From: Matthias Reichl <hias@horus.com> |
| 3 | Date: Thu, 19 Mar 2020 20:00:35 +0100 |
| 4 | Subject: [PATCH] drm/vc4: move setup from hw_params to prepare |
| 5 | |
| 6 | Configuring HDMI audio registers in prepare allows us to take |
| 7 | IEC958 bits into account which are set by the alsa hook after |
| 8 | the hw_params call. |
| 9 | |
| 10 | Signed-off-by: Matthias Reichl <hias@horus.com> |
| 11 | --- |
| 12 | drivers/gpu/drm/vc4/vc4_hdmi.c | 18 ++++++++++-------- |
| 13 | 1 file changed, 10 insertions(+), 8 deletions(-) |
| 14 | |
| 15 | --- a/drivers/gpu/drm/vc4/vc4_hdmi.c |
| 16 | +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c |
| 17 | @@ -958,8 +958,7 @@ static int sample_rate_to_mai_fmt(int sa |
| 18 | } |
| 19 | |
| 20 | /* HDMI audio codec callbacks */ |
| 21 | -static int vc4_hdmi_audio_hw_params(struct snd_pcm_substream *substream, |
| 22 | - struct snd_pcm_hw_params *params, |
| 23 | +static int vc4_hdmi_audio_prepare(struct snd_pcm_substream *substream, |
| 24 | struct snd_soc_dai *dai) |
| 25 | { |
| 26 | struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai); |
| 27 | @@ -972,12 +971,15 @@ static int vc4_hdmi_audio_hw_params(stru |
| 28 | if (substream != vc4_hdmi->audio.substream) |
| 29 | return -EINVAL; |
| 30 | |
| 31 | - dev_dbg(dev, "%s: %u Hz, %d bit, %d channels\n", __func__, |
| 32 | - params_rate(params), params_width(params), |
| 33 | - params_channels(params)); |
| 34 | + dev_dbg(dev, "%s: %u Hz, %d bit, %d channels AES0=%02x\n", |
| 35 | + __func__, |
| 36 | + substream->runtime->rate, |
| 37 | + snd_pcm_format_width(substream->runtime->format), |
| 38 | + substream->runtime->channels, |
| 39 | + vc4_hdmi->audio.iec_status[0]); |
| 40 | |
| 41 | - vc4_hdmi->audio.channels = params_channels(params); |
| 42 | - vc4_hdmi->audio.samplerate = params_rate(params); |
| 43 | + vc4_hdmi->audio.channels = substream->runtime->channels; |
| 44 | + vc4_hdmi->audio.samplerate = substream->runtime->rate; |
| 45 | |
| 46 | HDMI_WRITE(HDMI_MAI_CTL, |
| 47 | VC4_HD_MAI_CTL_RESET | |
| 48 | @@ -1196,7 +1198,7 @@ static const struct snd_soc_component_dr |
| 49 | static const struct snd_soc_dai_ops vc4_hdmi_audio_dai_ops = { |
| 50 | .startup = vc4_hdmi_audio_startup, |
| 51 | .shutdown = vc4_hdmi_audio_shutdown, |
| 52 | - .hw_params = vc4_hdmi_audio_hw_params, |
| 53 | + .prepare = vc4_hdmi_audio_prepare, |
| 54 | .set_fmt = vc4_hdmi_audio_set_fmt, |
| 55 | .trigger = vc4_hdmi_audio_trigger, |
| 56 | }; |