cfe27b866a8ade8923468ab20a0b866a324e8ca8
[openwrt/staging/jow.git] / target / linux / bcm27xx / patches-5.10 / 950-0315-drm-vc4-move-setup-from-hw_params-to-prepare.patch
1 From 7b6cfdfc74c7e9c00060a0c4146a6358b261f7db 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 | 20 +++++++++++---------
13 1 file changed, 11 insertions(+), 9 deletions(-)
14
15 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
16 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
17 @@ -1028,9 +1028,8 @@ 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 - struct snd_soc_dai *dai)
24 +static int vc4_hdmi_audio_prepare(struct snd_pcm_substream *substream,
25 + struct snd_soc_dai *dai)
26 {
27 struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
28 struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
29 @@ -1043,12 +1042,15 @@ static int vc4_hdmi_audio_hw_params(stru
30 if (substream != vc4_hdmi->audio.substream)
31 return -EINVAL;
32
33 - dev_dbg(dev, "%s: %u Hz, %d bit, %d channels\n", __func__,
34 - params_rate(params), params_width(params),
35 - params_channels(params));
36 + dev_dbg(dev, "%s: %u Hz, %d bit, %d channels AES0=%02x\n",
37 + __func__,
38 + substream->runtime->rate,
39 + snd_pcm_format_width(substream->runtime->format),
40 + substream->runtime->channels,
41 + vc4_hdmi->audio.iec_status[0]);
42
43 - vc4_hdmi->audio.channels = params_channels(params);
44 - vc4_hdmi->audio.samplerate = params_rate(params);
45 + vc4_hdmi->audio.channels = substream->runtime->channels;
46 + vc4_hdmi->audio.samplerate = substream->runtime->rate;
47
48 HDMI_WRITE(HDMI_MAI_CTL,
49 VC4_HD_MAI_CTL_RESET |
50 @@ -1270,7 +1272,7 @@ static const struct snd_soc_component_dr
51 static const struct snd_soc_dai_ops vc4_hdmi_audio_dai_ops = {
52 .startup = vc4_hdmi_audio_startup,
53 .shutdown = vc4_hdmi_audio_shutdown,
54 - .hw_params = vc4_hdmi_audio_hw_params,
55 + .prepare = vc4_hdmi_audio_prepare,
56 .set_fmt = vc4_hdmi_audio_set_fmt,
57 .trigger = vc4_hdmi_audio_trigger,
58 };