2022-09-13 08:22:49

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH] ASoC: Intel: sof_rt5682: remove SOF_RT1015_SPEAKER_AMP_100FS flag




> -static int rt1015_hw_params_pll_and_tdm(struct snd_pcm_substream *substream,
> - struct snd_pcm_hw_params *params)
> -{
> - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
> - struct snd_soc_dai *codec_dai;
> - int i, fs = 100, ret;
> -
> for_each_rtd_codec_dais(rtd, i, codec_dai) {
> ret = snd_soc_dai_set_pll(codec_dai, 0, RT1015_PLL_S_BCLK,
> - params_rate(params) * fs,
> + clk_freq,
> params_rate(params) * 256);
> - if (ret)
> + if (ret) {
> + dev_err(codec_dai->dev, "fail to set pll, ret %d\n",
> + ret);
> return ret;
> + }
>
> ret = snd_soc_dai_set_sysclk(codec_dai, RT1015_SCLK_S_PLL,
> params_rate(params) * 256,
> SND_SOC_CLOCK_IN);
> - if (ret)
> + if (ret) {
> + dev_err(codec_dai->dev, "fail to set sysclk, ret %d\n",
> + ret);
> return ret;
> - }
> - /* rx slot 1 for RT1015_DEV0_NAME */
> - ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_codec(rtd, 0),
> - 0x0, 0x1, 4, 24);
> - if (ret)
> - return ret;
> + }
>
> - /* rx slot 2 for RT1015_DEV1_NAME */
> - ret = snd_soc_dai_set_tdm_slot(asoc_rtd_to_codec(rtd, 1),
> - 0x0, 0x2, 4, 24);
> - if (ret)
> - return ret;
> + switch (dai_link->dai_fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
> + case SND_SOC_DAIFMT_DSP_A:
> + case SND_SOC_DAIFMT_DSP_B:
> + /* 4-slot TDM */
> + ret = snd_soc_dai_set_tdm_slot(codec_dai,
> + rt1015_tdm_mask[i].tx,
> + rt1015_tdm_mask[i].rx,
> + 4,
> + params_width(params));

The changes look ok, just wondering if we can avoid hard-coding those 4
values. Can we not get the number of TDM slots from topology and/or
dailink configuration?


> + if (ret < 0) {
> + dev_err(codec_dai->dev, "fail to set tdm slot, ret %d\n",
> + ret);
> + return ret;
> + }
> + break;
> + default:
> + dev_dbg(codec_dai->dev, "codec is in I2S mode\n");
> + break;
> + }
> + }
>
> - return 0;
> + return ret;


2022-09-27 13:52:48

by Brent Lu

[permalink] [raw]
Subject: RE: [PATCH] ASoC: Intel: sof_rt5682: remove SOF_RT1015_SPEAKER_AMP_100FS flag

> > + case SND_SOC_DAIFMT_DSP_A:
> > + case SND_SOC_DAIFMT_DSP_B:
> > + /* 4-slot TDM */
> > + ret = snd_soc_dai_set_tdm_slot(codec_dai,
> > + rt1015_tdm_mask[i].tx,
> > + rt1015_tdm_mask[i].rx,
> > + 4,
> > + params_width(params));
>
> The changes look ok, just wondering if we can avoid hard-coding those 4 values.
> Can we not get the number of TDM slots from topology and/or dailink
> configuration?
>
>

I think TDM slot number is possible but not TX/RX mask. What we have in topology
is union of tx/rx mask of all channels. We don't know the mask of specific channel in
DAI_CONFIG.

DAI_CONFIG(SSP, 0, BOARD_HP_BE_ID, SSP0-Codec,
SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in),
SSP_CLOCK(bclk, 2400000, codec_slave),
SSP_CLOCK(fsync, 48000, codec_slave),
SSP_TDM(2, 25, 3, 3),
SSP_CONFIG_DATA(SSP, 0, 24, 0, 0, 0, SSP_CC_BCLK_ES)))')

Regards,
Brent

2022-09-28 09:09:21

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH] ASoC: Intel: sof_rt5682: remove SOF_RT1015_SPEAKER_AMP_100FS flag



On 9/27/22 15:16, Lu, Brent wrote:
>>> + case SND_SOC_DAIFMT_DSP_A:
>>> + case SND_SOC_DAIFMT_DSP_B:
>>> + /* 4-slot TDM */
>>> + ret = snd_soc_dai_set_tdm_slot(codec_dai,
>>> + rt1015_tdm_mask[i].tx,
>>> + rt1015_tdm_mask[i].rx,
>>> + 4,
>>> + params_width(params));
>>
>> The changes look ok, just wondering if we can avoid hard-coding those 4 values.
>> Can we not get the number of TDM slots from topology and/or dailink
>> configuration?
>>
>>
>
> I think TDM slot number is possible but not TX/RX mask. What we have in topology
> is union of tx/rx mask of all channels. We don't know the mask of specific channel in
> DAI_CONFIG.
>
> DAI_CONFIG(SSP, 0, BOARD_HP_BE_ID, SSP0-Codec,
> SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in),
> SSP_CLOCK(bclk, 2400000, codec_slave),
> SSP_CLOCK(fsync, 48000, codec_slave),
> SSP_TDM(2, 25, 3, 3),

the 3 3 is precisely the channel mask!

> SSP_CONFIG_DATA(SSP, 0, 24, 0, 0, 0, SSP_CC_BCLK_ES)))')
>
> Regards,
> Brent
>

2022-09-29 07:05:27

by Brent Lu

[permalink] [raw]
Subject: RE: [PATCH] ASoC: Intel: sof_rt5682: remove SOF_RT1015_SPEAKER_AMP_100FS flag

> >
> > I think TDM slot number is possible but not TX/RX mask. What we have
> > in topology is union of tx/rx mask of all channels. We don't know the
> > mask of specific channel in DAI_CONFIG.
> >
> > DAI_CONFIG(SSP, 0, BOARD_HP_BE_ID, SSP0-Codec,
> > SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in),
> > SSP_CLOCK(bclk, 2400000, codec_slave),
> > SSP_CLOCK(fsync, 48000, codec_slave),
> > SSP_TDM(2, 25, 3, 3),
>
> the 3 3 is precisely the channel mask!
>

Yes, but what we need in the hw_params() is the mask for individual channel,
like 0x1 for left and 0x2 for right.

Regards,
Brent

2022-09-29 09:52:58

by Pierre-Louis Bossart

[permalink] [raw]
Subject: Re: [PATCH] ASoC: Intel: sof_rt5682: remove SOF_RT1015_SPEAKER_AMP_100FS flag



On 9/29/22 08:25, Lu, Brent wrote:
>>>
>>> I think TDM slot number is possible but not TX/RX mask. What we have
>>> in topology is union of tx/rx mask of all channels. We don't know the
>>> mask of specific channel in DAI_CONFIG.
>>>
>>> DAI_CONFIG(SSP, 0, BOARD_HP_BE_ID, SSP0-Codec,
>>> SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in),
>>> SSP_CLOCK(bclk, 2400000, codec_slave),
>>> SSP_CLOCK(fsync, 48000, codec_slave),
>>> SSP_TDM(2, 25, 3, 3),
>>
>> the 3 3 is precisely the channel mask!
>>
>
> Yes, but what we need in the hw_params() is the mask for individual channel,
> like 0x1 for left and 0x2 for right.

Ah yes, you're talking about the mask configuration on the codec side,
sorry I was confused with your reference to DAI_CONFIG. That would be
platform-level information, not DSP topology information indeed.

Sounds good then, thanks for the explanations.

Acked-by: Pierre-Louis Bossart <[email protected]>