2023-09-27 06:13:49

by ChiYuan Huang

[permalink] [raw]
Subject: [PATCH] ASoC: codecs: rtq9128: Add TDM data source selection

From: ChiYuan Huang <[email protected]>

Since rtq9128 can support 4 channel I2S mode audio data, there are two
dedicated data input pins for CH12 and CH34. But in TDM mode, input
source was already drived on one data pin for multiple data slots. In
this case, only one input source is needed for TDM mode.

This patch is to add the data source pin selection for CH12 and CH34.

Signed-off-by: ChiYuan Huang <[email protected]>
---
sound/soc/codecs/rtq9128.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/sound/soc/codecs/rtq9128.c b/sound/soc/codecs/rtq9128.c
index 926b79ed8078..3cf613c6900e 100644
--- a/sound/soc/codecs/rtq9128.c
+++ b/sound/soc/codecs/rtq9128.c
@@ -225,6 +225,7 @@ static const char * const phase_select_text[] = {
"180 degree", "225 degree", "270 degree", "315 degree",
};
static const char * const dvdduv_select_text[] = { "1P4V", "1P5V", "2P1V", "2P3V" };
+static const char * const tdm_data_select_text[] = { "DATA1", "DATA2" };

static const struct soc_enum rtq9128_ch1_si_enum =
SOC_ENUM_SINGLE(RTQ9128_REG_SDI_SEL, 6, ARRAY_SIZE(source_select_text), source_select_text);
@@ -246,6 +247,12 @@ static const struct soc_enum rtq9128_out3_phase_enum =
static const struct soc_enum rtq9128_out4_phase_enum =
SOC_ENUM_SINGLE(RTQ9128_REG_PLLTRI_GEN2, 0, ARRAY_SIZE(phase_select_text),
phase_select_text);
+static const struct soc_enum rtq9128_ch12_tdm_data_select_enum =
+ SOC_ENUM_SINGLE(RTQ9128_REG_SDO_SEL, 5, ARRAY_SIZE(tdm_data_select_text),
+ tdm_data_select_text);
+static const struct soc_enum rtq9128_ch34_tdm_data_select_enum =
+ SOC_ENUM_SINGLE(RTQ9128_REG_SDO_SEL, 4, ARRAY_SIZE(tdm_data_select_text),
+ tdm_data_select_text);

/*
* In general usage, DVDD could be 1P8V, 3P0V or 3P3V.
@@ -277,6 +284,8 @@ static const struct snd_kcontrol_new rtq9128_snd_ctrls[] = {
SOC_ENUM("OUT3 Phase Select", rtq9128_out3_phase_enum),
SOC_ENUM("OUT4 Phase Select", rtq9128_out4_phase_enum),
SOC_ENUM("DVDD UV Threshold Select", rtq9128_dvdduv_select_enum),
+ SOC_ENUM("CH12 TDM Data Select", rtq9128_ch12_tdm_data_select_enum),
+ SOC_ENUM("CH34 TDM Data Select", rtq9128_ch34_tdm_data_select_enum),
};

static int rtq9128_dac_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol,

base-commit: c351835058419c1eb8791941a057c3f3e6068cb6
--
2.34.1


2023-09-27 10:12:11

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: codecs: rtq9128: Add TDM data source selection

On Wed, Sep 27, 2023 at 05:46:37PM +0800, ChiYuan Huang wrote:
> On Wed, Sep 27, 2023 at 11:13:22AM +0200, Mark Brown wrote:

> > Is this something that's going to be changing dynamically at runtime or
> > should this be a device property that's set either by firmware or when
> > we're doing the TDM setup? This sounds like something I'd expect to be
> > fixed by the board design.

> I may think one case if ASoC platform support multiple data source outputs
> that share the same bck/lcrk on different data pin. If it can be dynamically
> adjusted for the scenarios, this will keep the flexibility for the differet
> platform design.

Sure, but is that actually a practical design - or if someone is doing
this shouldn't it be joined up with the TDM configuration since with
just the control it'd only be possible to switch the pins but not change
the TDM layout? I'm not sure that this control works as a standalone
thing.


Attachments:
(No filename) (947.00 B)
signature.asc (499.00 B)
Download all attachments

2023-09-27 10:12:54

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: codecs: rtq9128: Add TDM data source selection

On Wed, Sep 27, 2023 at 10:06:16AM +0800, [email protected] wrote:

> Since rtq9128 can support 4 channel I2S mode audio data, there are two
> dedicated data input pins for CH12 and CH34. But in TDM mode, input
> source was already drived on one data pin for multiple data slots. In
> this case, only one input source is needed for TDM mode.
>
> This patch is to add the data source pin selection for CH12 and CH34.

> + SOC_ENUM("CH12 TDM Data Select", rtq9128_ch12_tdm_data_select_enum),
> + SOC_ENUM("CH34 TDM Data Select", rtq9128_ch34_tdm_data_select_enum),

Is this something that's going to be changing dynamically at runtime or
should this be a device property that's set either by firmware or when
we're doing the TDM setup? This sounds like something I'd expect to be
fixed by the board design.


Attachments:
(No filename) (827.00 B)
signature.asc (499.00 B)
Download all attachments

2023-09-27 10:36:46

by ChiYuan Huang

[permalink] [raw]
Subject: Re: [PATCH] ASoC: codecs: rtq9128: Add TDM data source selection

On Wed, Sep 27, 2023 at 11:59:31AM +0200, Mark Brown wrote:
> On Wed, Sep 27, 2023 at 05:46:37PM +0800, ChiYuan Huang wrote:
> > On Wed, Sep 27, 2023 at 11:13:22AM +0200, Mark Brown wrote:
>
> > > Is this something that's going to be changing dynamically at runtime or
> > > should this be a device property that's set either by firmware or when
> > > we're doing the TDM setup? This sounds like something I'd expect to be
> > > fixed by the board design.
>
> > I may think one case if ASoC platform support multiple data source outputs
> > that share the same bck/lcrk on different data pin. If it can be dynamically
> > adjusted for the scenarios, this will keep the flexibility for the differet
> > platform design.
>
> Sure, but is that actually a practical design - or if someone is doing
> this shouldn't it be joined up with the TDM configuration since with
> just the control it'd only be possible to switch the pins but not change
> the TDM layout? I'm not sure that this control works as a standalone
> thing.

I think if two data source input for different scenarios, then the data source
switch will become practical. For the standalone usage, keep a device property
to decide this may be enough. But consider the future application, to keep this
in general mixer control is still usable to meet the complex design.

2023-09-27 10:38:57

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] ASoC: codecs: rtq9128: Add TDM data source selection

On Wed, Sep 27, 2023 at 06:19:48PM +0800, ChiYuan Huang wrote:
> On Wed, Sep 27, 2023 at 11:59:31AM +0200, Mark Brown wrote:

> > Sure, but is that actually a practical design - or if someone is doing
> > this shouldn't it be joined up with the TDM configuration since with
> > just the control it'd only be possible to switch the pins but not change
> > the TDM layout? I'm not sure that this control works as a standalone
> > thing.

> I think if two data source input for different scenarios, then the data source
> switch will become practical. For the standalone usage, keep a device property
> to decide this may be enough. But consider the future application, to keep this
> in general mixer control is still usable to meet the complex design.

My concern is that the control might not actually be usable without also
changing the TDM mode so we might need the machine driver to add a
control which flips the input and also changes the TDM mode - it feels
likley that if there are two inputs they won't have identical formats.


Attachments:
(No filename) (1.03 kB)
signature.asc (499.00 B)
Download all attachments

2023-09-27 10:45:05

by ChiYuan Huang

[permalink] [raw]
Subject: Re: [PATCH] ASoC: codecs: rtq9128: Add TDM data source selection

On Wed, Sep 27, 2023 at 11:13:22AM +0200, Mark Brown wrote:
> On Wed, Sep 27, 2023 at 10:06:16AM +0800, [email protected] wrote:
>
> > Since rtq9128 can support 4 channel I2S mode audio data, there are two
> > dedicated data input pins for CH12 and CH34. But in TDM mode, input
> > source was already drived on one data pin for multiple data slots. In
> > this case, only one input source is needed for TDM mode.
> >
> > This patch is to add the data source pin selection for CH12 and CH34.
>
> > + SOC_ENUM("CH12 TDM Data Select", rtq9128_ch12_tdm_data_select_enum),
> > + SOC_ENUM("CH34 TDM Data Select", rtq9128_ch34_tdm_data_select_enum),
>
> Is this something that's going to be changing dynamically at runtime or
> should this be a device property that's set either by firmware or when
> we're doing the TDM setup? This sounds like something I'd expect to be
> fixed by the board design.

I may think one case if ASoC platform support multiple data source outputs
that share the same bck/lcrk on different data pin. If it can be dynamically
adjusted for the scenarios, this will keep the flexibility for the differet
platform design.

Like as in most codecs, there could be mux design that can use to choose the
dedicated data input. If we fixed in device property, the flexibility will be
missing. It's our original thought to have the control for the data select
mutiplexer.

2023-09-28 02:08:20

by ChiYuan Huang

[permalink] [raw]
Subject: Re: [PATCH] ASoC: codecs: rtq9128: Add TDM data source selection

On Wed, Sep 27, 2023 at 12:28:29PM +0200, Mark Brown wrote:
> On Wed, Sep 27, 2023 at 06:19:48PM +0800, ChiYuan Huang wrote:
> > On Wed, Sep 27, 2023 at 11:59:31AM +0200, Mark Brown wrote:
>
> > > Sure, but is that actually a practical design - or if someone is doing
> > > this shouldn't it be joined up with the TDM configuration since with
> > > just the control it'd only be possible to switch the pins but not change
> > > the TDM layout? I'm not sure that this control works as a standalone
> > > thing.
>
> > I think if two data source input for different scenarios, then the data source
> > switch will become practical. For the standalone usage, keep a device property
> > to decide this may be enough. But consider the future application, to keep this
> > in general mixer control is still usable to meet the complex design.
>
> My concern is that the control might not actually be usable without also
> changing the TDM mode so we might need the machine driver to add a
> control which flips the input and also changes the TDM mode - it feels
> likley that if there are two inputs they won't have identical formats.

Yap, your concern may be correct. This change is really becuase our default register
is badly defined. it choose TDM CH12 from 'DATA1' and CH34 from 'DATA2'. If it can
choose both default to either one, this doesn't make it confused. Also, there's the
another option is 'to tell user if TDM will be used, plase connect 'DATA1' and 'DATA2'
together'. But our datasheet did not directly define this.

I'll prepare another patch to define a device property, parsing at probe function and
configure this input source source directly in 'set_tdm_slot' API when TDM is chosen
to use.

Thanks for all the comment.