bcm27xx: update 6.1 patches to latest version
[openwrt/staging/svanheule.git] / target / linux / bcm27xx / patches-6.1 / 950-1231-ASoC-dwc-Defer-bclk_ratio-handling-to-hw_params.patch
1 From dfc04900c40eb14f9364d56e96db2cc3340a1f21 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Wed, 3 Jan 2024 14:43:43 +0000
4 Subject: [PATCH] ASoC: dwc: Defer bclk_ratio handling to hw_params
5
6 bclk_ratio is only a factor in clock producer mode, and needs to
7 override the default value of num_channels * sample_size.
8 Move the bclk_ratio handling into the hw_params method, only latching
9 the value in set_bclk_ratio, to address both of those matters.
10
11 See: https://github.com/raspberrypi/linux/issues/5817
12
13 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
14 ---
15 sound/soc/dwc/dwc-i2s.c | 38 +++++++++++++++++++++-----------------
16 sound/soc/dwc/local.h | 1 +
17 2 files changed, 22 insertions(+), 17 deletions(-)
18
19 --- a/sound/soc/dwc/dwc-i2s.c
20 +++ b/sound/soc/dwc/dwc-i2s.c
21 @@ -263,6 +263,25 @@ static int dw_i2s_hw_params(struct snd_p
22 return -EINVAL;
23 }
24
25 + if ((dev->capability & DW_I2S_MASTER) && dev->bclk_ratio) {
26 + switch (dev->bclk_ratio) {
27 + case 32:
28 + dev->ccr = 0x00;
29 + break;
30 +
31 + case 48:
32 + dev->ccr = 0x08;
33 + break;
34 +
35 + case 64:
36 + dev->ccr = 0x10;
37 + break;
38 +
39 + default:
40 + return -EINVAL;
41 + }
42 + }
43 +
44 config->chan_nr = params_channels(params);
45
46 switch (config->chan_nr) {
47 @@ -436,23 +455,7 @@ static int dw_i2s_set_bclk_ratio(struct
48
49 dev_dbg(dev->dev, "%s(%d)\n", __func__, ratio);
50
51 - switch (ratio) {
52 - case 32:
53 - dev->ccr = 0x00;
54 - break;
55 -
56 - case 48:
57 - dev->ccr = 0x08;
58 - break;
59 -
60 - case 64:
61 - dev->ccr = 0x10;
62 - break;
63 - default:
64 - return -EINVAL;
65 - }
66 -
67 - i2s_write_reg(dev->i2s_base, CCR, dev->ccr);
68 + dev->bclk_ratio = ratio;
69
70 return 0;
71 }
72 @@ -746,6 +749,7 @@ static int dw_i2s_probe(struct platform_
73 }
74 }
75
76 + dev->bclk_ratio = 0;
77 dev->i2s_reg_comp1 = I2S_COMP_PARAM_1;
78 dev->i2s_reg_comp2 = I2S_COMP_PARAM_2;
79 if (pdata) {
80 --- a/sound/soc/dwc/local.h
81 +++ b/sound/soc/dwc/local.h
82 @@ -107,6 +107,7 @@ struct dw_i2s_dev {
83 unsigned int quirks;
84 unsigned int i2s_reg_comp1;
85 unsigned int i2s_reg_comp2;
86 + unsigned int bclk_ratio;
87 struct device *dev;
88 u32 ccr;
89 u32 xfer_resolution;