openwrt/target/linux/bcm27xx/patches-6.6/950-0809-ASoC-dwc-Defer-bclk_ratio-handling-to-hw_params.patch
Álvaro Fernández Rojas 8c405cdccc bcm27xx: add 6.6 kernel patches
The patches were generated from the RPi repo with the following command:
git format-patch v6.6.34..rpi-6.1.y

Some patches needed rebasing and, as usual, the applied and reverted, wireless
drivers, Github workflows, READMEs and defconfigs patches were removed.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2024-06-18 18:52:49 +02:00

90 lines
2.1 KiB
Diff

From 6aec34c8eabdf8bef90e9ce66a088972ee25617e Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Wed, 3 Jan 2024 14:43:43 +0000
Subject: [PATCH 0809/1085] ASoC: dwc: Defer bclk_ratio handling to hw_params
bclk_ratio is only a factor in clock producer mode, and needs to
override the default value of num_channels * sample_size.
Move the bclk_ratio handling into the hw_params method, only latching
the value in set_bclk_ratio, to address both of those matters.
See: https://github.com/raspberrypi/linux/issues/5817
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
sound/soc/dwc/dwc-i2s.c | 38 +++++++++++++++++++++-----------------
sound/soc/dwc/local.h | 1 +
2 files changed, 22 insertions(+), 17 deletions(-)
--- a/sound/soc/dwc/dwc-i2s.c
+++ b/sound/soc/dwc/dwc-i2s.c
@@ -314,6 +314,25 @@ static int dw_i2s_hw_params(struct snd_p
if (dev->tdm_slots)
config->data_width = 32;
+ if ((dev->capability & DW_I2S_MASTER) && dev->bclk_ratio) {
+ switch (dev->bclk_ratio) {
+ case 32:
+ dev->ccr = 0x00;
+ break;
+
+ case 48:
+ dev->ccr = 0x08;
+ break;
+
+ case 64:
+ dev->ccr = 0x10;
+ break;
+
+ default:
+ return -EINVAL;
+ }
+ }
+
config->chan_nr = params_channels(params);
switch (config->chan_nr) {
@@ -537,23 +556,7 @@ static int dw_i2s_set_bclk_ratio(struct
dev_dbg(dev->dev, "%s(%d)\n", __func__, ratio);
- switch (ratio) {
- case 32:
- dev->ccr = 0x00;
- break;
-
- case 48:
- dev->ccr = 0x08;
- break;
-
- case 64:
- dev->ccr = 0x10;
- break;
- default:
- return -EINVAL;
- }
-
- i2s_write_reg(dev->i2s_base, CCR, dev->ccr);
+ dev->bclk_ratio = ratio;
return 0;
}
@@ -1068,6 +1071,7 @@ static int dw_i2s_probe(struct platform_
}
}
+ dev->bclk_ratio = 0;
dev->i2s_reg_comp1 = I2S_COMP_PARAM_1;
dev->i2s_reg_comp2 = I2S_COMP_PARAM_2;
if (pdata) {
--- a/sound/soc/dwc/local.h
+++ b/sound/soc/dwc/local.h
@@ -128,6 +128,7 @@ struct dw_i2s_dev {
unsigned int quirks;
unsigned int i2s_reg_comp1;
unsigned int i2s_reg_comp2;
+ unsigned int bclk_ratio;
struct device *dev;
u32 ccr;
u32 xfer_resolution;