diff mbox series

[v3,2/2] ASoC: tas5805m: add missing page switch.

Message ID 1fea38a71ea6ab0225d19ab28d1fa12828d762d0.1675497326.git.daniel.beer@igorinstitute.com
State Accepted
Commit e0576cd642ced1ac65370b4516b7be9f536a0498
Headers show
Series Two bug fixes for tas5805m codec driver | expand

Commit Message

Daniel Beer Oct. 27, 2022, 8:38 a.m. UTC
In tas5805m_refresh, we switch pages to update the DSP volume control,
but we need to switch back to page 0 before trying to alter the
soft-mute control. This latter page-switch was missing.

Fixes: ec45268467f4 ("ASoC: add support for TAS5805M digital amplifier")
Signed-off-by: Daniel Beer <daniel.beer@igorinstitute.com>
---
 sound/soc/codecs/tas5805m.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Mark Brown Feb. 6, 2023, 1:11 p.m. UTC | #1
On Thu, Oct 27, 2022 at 09:38:38PM +1300, Daniel Beer wrote:
> In tas5805m_refresh, we switch pages to update the DSP volume control,
> but we need to switch back to page 0 before trying to alter the
> soft-mute control. This latter page-switch was missing.

You should just use the register windowing support in regmap, it will
take care of this for you, avoiding any further similar errors.
Daniel Beer Feb. 6, 2023, 8:45 p.m. UTC | #2
On Mon, Feb 06, 2023 at 01:11:09PM +0000, Mark Brown wrote:
> On Thu, Oct 27, 2022 at 09:38:38PM +1300, Daniel Beer wrote:
> > In tas5805m_refresh, we switch pages to update the DSP volume control,
> > but we need to switch back to page 0 before trying to alter the
> > soft-mute control. This latter page-switch was missing.
> 
> You should just use the register windowing support in regmap, it will
> take care of this for you, avoiding any further similar errors.

Hi Mark,

Thanks for reviewing.

We did discuss this a while back when the driver first went in.
Unfortunately the vendor software tools provide configuration for the
part in the form of a sequence of raw register writes, including
explicit page changes:

    https://lore.kernel.org/lkml/Yd85bjKEX9JnoOlI@sirena.org.uk/

Aside from this, I have two other practical issues.

The first is that I'm not sure how exactly to implement the paging
scheme in terms of regmap_range_cfg (assuming this is what you're
referring to). This chip has multi-level paging (books/pages), with the
book selection register itself requiring paging to access. A sequence of
three register writes is therefore required in the general case to
select the correct page. I had a quick look at a random assortment of
existing regmap_range_cfg uses, but didn't find anything that looked
like the same problem.

Secondly, the patches as submitted here have been tested, but I don't
currently have access to hardware. I'm very hesitant to make a
significant change without retesting and leave the driver in a broken
state again.

Cheers,
Daniel
Mark Brown Feb. 6, 2023, 9:14 p.m. UTC | #3
On Tue, Feb 07, 2023 at 09:45:46AM +1300, Daniel Beer wrote:

> We did discuss this a while back when the driver first went in.
> Unfortunately the vendor software tools provide configuration for the
> part in the form of a sequence of raw register writes, including
> explicit page changes:

>     https://lore.kernel.org/lkml/Yd85bjKEX9JnoOlI@sirena.org.uk/

That seems surmountable, either bypassing regmap or parsing the
configuration files.

> Aside from this, I have two other practical issues.

> The first is that I'm not sure how exactly to implement the paging
> scheme in terms of regmap_range_cfg (assuming this is what you're
> referring to). This chip has multi-level paging (books/pages), with the
> book selection register itself requiring paging to access. A sequence of

That's absolutely fine, this isn't the first device which has such a
setup and the code handles nested windows fine.

> Secondly, the patches as submitted here have been tested, but I don't
> currently have access to hardware. I'm very hesitant to make a
> significant change without retesting and leave the driver in a broken
> state again.

Presumably someone does given that the problem was noticed?
diff mbox series

Patch

diff --git a/sound/soc/codecs/tas5805m.c b/sound/soc/codecs/tas5805m.c
index 6e2edf045446..4e38eb7acea1 100644
--- a/sound/soc/codecs/tas5805m.c
+++ b/sound/soc/codecs/tas5805m.c
@@ -203,6 +203,9 @@  static void tas5805m_refresh(struct tas5805m_priv *tas5805m)
 	set_dsp_scale(rm, 0x24, tas5805m->vol[0]);
 	set_dsp_scale(rm, 0x28, tas5805m->vol[1]);
 
+	regmap_write(rm, REG_PAGE, 0x00);
+	regmap_write(rm, REG_BOOK, 0x00);
+
 	/* Set/clear digital soft-mute */
 	regmap_write(rm, REG_DEVICE_CTRL_2,
 		(tas5805m->is_muted ? DCTRL2_MUTE : 0) |