Message ID | 20210606004102.26190-4-brent.lu@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Support CS42L42 on JSL platform | expand |
On 6/5/21 7:41 PM, Brent Lu wrote: > This patch adds driver data for jsl_cs4242_mx98360a which supports two > max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec on > SSP0 running on JSL platform. DAI format is leveraged from sof_rt5682 > machine driver to reuse the topology. This also looks like we have two topologies configuring the same DAIs differently on different platforms. Why can't we pick one configuration that would work in all cases? > Also use module device table to replace module alias. Humm, this looks like a missing dependency, I modified this a while ago. > > Signed-off-by: Brent Lu <brent.lu@intel.com> > --- > sound/soc/intel/boards/sof_cs42l42.c | 22 +++++++++++++++---- > .../intel/common/soc-acpi-intel-jsl-match.c | 8 +++++++ > 2 files changed, 26 insertions(+), 4 deletions(-) > > diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c > index e3171242f612..d712cfb91fd1 100644 > --- a/sound/soc/intel/boards/sof_cs42l42.c > +++ b/sound/soc/intel/boards/sof_cs42l42.c > @@ -36,7 +36,9 @@ > #define SOF_CS42L42_NUM_HDMIDEV_MASK (GENMASK(9, 7)) > #define SOF_CS42L42_NUM_HDMIDEV(quirk) \ > (((quirk) << SOF_CS42L42_NUM_HDMIDEV_SHIFT) & SOF_CS42L42_NUM_HDMIDEV_MASK) > -#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(10) > +#define SOF_CS42L42_BCLK_2400000 BIT(10) > +#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(11) > +#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(12) > > /* Default: SSP2 */ > static unsigned long sof_cs42l42_quirk = SOF_CS42L42_SSP_CODEC(2); > @@ -122,7 +124,10 @@ static int sof_cs42l42_hw_params(struct snd_pcm_substream *substream, > struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); > int clk_freq, ret; > > - clk_freq = 3072000; /* BCLK freq */ > + if (sof_cs42l42_quirk & SOF_CS42L42_BCLK_2400000) > + clk_freq = 2400000; /* BCLK freq */ > + else > + clk_freq = 3072000; /* BCLK freq */ > > /* Configure sysclk for codec */ > ret = snd_soc_dai_set_sysclk(codec_dai, 0, > @@ -281,6 +286,8 @@ static int create_spk_amp_dai_links(struct device *dev, > > if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) { > max_98357a_dai_link(&links[*id]); > + } else if (sof_cs42l42_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) { > + max_98360a_dai_link(&links[*id]); > } else { > dev_err(dev, "no amp defined\n"); > ret = -EINVAL; > @@ -584,8 +591,17 @@ static const struct platform_device_id board_ids[] = { > SOF_MAX98357A_SPEAKER_AMP_PRESENT | > SOF_CS42L42_SSP_AMP(1)), > }, > + { > + .name = "jsl_cs4242_mx98360a", > + .driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) | > + SOF_SPEAKER_AMP_PRESENT | > + SOF_MAX98360A_SPEAKER_AMP_PRESENT | > + SOF_CS42L42_SSP_AMP(1)) | > + SOF_CS42L42_BCLK_2400000, > + }, > { } > }; > +MODULE_DEVICE_TABLE(platform, board_ids); > > static struct platform_driver sof_audio = { > .probe = sof_audio_probe, > @@ -601,7 +617,5 @@ module_platform_driver(sof_audio) > MODULE_DESCRIPTION("SOF Audio Machine driver for CS42L42"); > MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>"); > MODULE_LICENSE("GPL"); > -MODULE_ALIAS("platform:sof_cs42l42"); > -MODULE_ALIAS("platform:glk_cs4242_max98357a"); > MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); > MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); > diff --git a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c > index 73fe4f89a82d..8e86476d48de 100644 > --- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c > +++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c > @@ -73,6 +73,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { > .quirk_data = &mx98360a_spk, > .sof_tplg_filename = "sof-jsl-rt5682-mx98360a.tplg", > }, > + { > + .id = "10134242", > + .drv_name = "jsl_cs4242_mx98360a", > + .sof_fw_filename = "sof-jsl.ri", > + .machine_quirk = snd_soc_acpi_codec_list, > + .quirk_data = &mx98360a_spk, > + .sof_tplg_filename = "sof-jsl-rt5682-mx98360a.tplg", > + }, > {}, > }; > EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_jsl_machines); >
> On 6/5/21 7:41 PM, Brent Lu wrote: > > This patch adds driver data for jsl_cs4242_mx98360a which supports two > > max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec on > > SSP0 running on JSL platform. DAI format is leveraged from sof_rt5682 > > machine driver to reuse the topology. > > This also looks like we have two topologies configuring the same DAIs > differently on different platforms. > > Why can't we pick one configuration that would work in all cases? > The comment just say we are reusing rt5685's sof-jsl-rt5682-mx98360a.tplg. This patch does not care about the dai sequence. Maybe I should reword the commit log. Regards, Brent > > Also use module device table to replace module alias. > > Humm, this looks like a missing dependency, I modified this a while ago. >
On 6/7/21 9:29 AM, Lu, Brent wrote: >> On 6/5/21 7:41 PM, Brent Lu wrote: >>> This patch adds driver data for jsl_cs4242_mx98360a which supports two >>> max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec on >>> SSP0 running on JSL platform. DAI format is leveraged from sof_rt5682 >>> machine driver to reuse the topology. >> >> This also looks like we have two topologies configuring the same DAIs >> differently on different platforms. >> >> Why can't we pick one configuration that would work in all cases? >> > > The comment just say we are reusing rt5685's sof-jsl-rt5682-mx98360a.tplg. > This patch does not care about the dai sequence. Maybe I should reword the > commit log. I was referring to the bclk frequency, one case uses 2.4 and the other 3.072MHz.
> >> > >> This also looks like we have two topologies configuring the same DAIs > >> differently on different platforms. > >> > >> Why can't we pick one configuration that would work in all cases? > >> > > > > The comment just say we are reusing rt5685's sof-jsl-rt5682-mx98360a.tplg. > > This patch does not care about the dai sequence. Maybe I should reword > > the commit log. > > I was referring to the bclk frequency, one case uses 2.4 and the other > 3.072MHz. The 2.4MHz setting isn't ready when we enabled this codec so we selected 3.072MHz. Since we are updating topology for PLL issue soon, we can change bclk frequency to 2.4MHz as well. How do you think? Regards, Brent
On 6/7/21 11:28 AM, Lu, Brent wrote: >>>> >>>> This also looks like we have two topologies configuring the same DAIs >>>> differently on different platforms. >>>> >>>> Why can't we pick one configuration that would work in all cases? >>>> >>> >>> The comment just say we are reusing rt5685's sof-jsl-rt5682-mx98360a.tplg. >>> This patch does not care about the dai sequence. Maybe I should reword >>> the commit log. >> >> I was referring to the bclk frequency, one case uses 2.4 and the other >> 3.072MHz. > > The 2.4MHz setting isn't ready when we enabled this codec so we selected > 3.072MHz. Since we are updating topology for PLL issue soon, we can change > bclk frequency to 2.4MHz as well. How do you think? The 3.072MHz clock will require the 24.576MHz PLL to be on on the SOC/PCH. If you can use 2.4 MHz without any loss of quality and the codec can deal with 25 bit slots with 24-bit data it's better power-wise. We try to use 64.fs only when it's absolutely mandatory, e.g. if the codec or amplifier doesn't support the 25/24 configuration. IIRC this was the case with TI PCM512x and Maxim amps. We've also used the 3.072 MHz bit clock when there are constraints on the clock sources and selectors. This isn't the case on GLK but the SOF commit 0a97c1a92f2d93bd4d45bc99d61e362cd214748c clarified the clock selection for newer platforms, including JSL. In the end we may be forced to use the 3.072 MHz PLL, you'd need to look at the various topologies used with this machine driver.
diff --git a/sound/soc/intel/boards/sof_cs42l42.c b/sound/soc/intel/boards/sof_cs42l42.c index e3171242f612..d712cfb91fd1 100644 --- a/sound/soc/intel/boards/sof_cs42l42.c +++ b/sound/soc/intel/boards/sof_cs42l42.c @@ -36,7 +36,9 @@ #define SOF_CS42L42_NUM_HDMIDEV_MASK (GENMASK(9, 7)) #define SOF_CS42L42_NUM_HDMIDEV(quirk) \ (((quirk) << SOF_CS42L42_NUM_HDMIDEV_SHIFT) & SOF_CS42L42_NUM_HDMIDEV_MASK) -#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(10) +#define SOF_CS42L42_BCLK_2400000 BIT(10) +#define SOF_MAX98357A_SPEAKER_AMP_PRESENT BIT(11) +#define SOF_MAX98360A_SPEAKER_AMP_PRESENT BIT(12) /* Default: SSP2 */ static unsigned long sof_cs42l42_quirk = SOF_CS42L42_SSP_CODEC(2); @@ -122,7 +124,10 @@ static int sof_cs42l42_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); int clk_freq, ret; - clk_freq = 3072000; /* BCLK freq */ + if (sof_cs42l42_quirk & SOF_CS42L42_BCLK_2400000) + clk_freq = 2400000; /* BCLK freq */ + else + clk_freq = 3072000; /* BCLK freq */ /* Configure sysclk for codec */ ret = snd_soc_dai_set_sysclk(codec_dai, 0, @@ -281,6 +286,8 @@ static int create_spk_amp_dai_links(struct device *dev, if (sof_cs42l42_quirk & SOF_MAX98357A_SPEAKER_AMP_PRESENT) { max_98357a_dai_link(&links[*id]); + } else if (sof_cs42l42_quirk & SOF_MAX98360A_SPEAKER_AMP_PRESENT) { + max_98360a_dai_link(&links[*id]); } else { dev_err(dev, "no amp defined\n"); ret = -EINVAL; @@ -584,8 +591,17 @@ static const struct platform_device_id board_ids[] = { SOF_MAX98357A_SPEAKER_AMP_PRESENT | SOF_CS42L42_SSP_AMP(1)), }, + { + .name = "jsl_cs4242_mx98360a", + .driver_data = (kernel_ulong_t)(SOF_CS42L42_SSP_CODEC(0) | + SOF_SPEAKER_AMP_PRESENT | + SOF_MAX98360A_SPEAKER_AMP_PRESENT | + SOF_CS42L42_SSP_AMP(1)) | + SOF_CS42L42_BCLK_2400000, + }, { } }; +MODULE_DEVICE_TABLE(platform, board_ids); static struct platform_driver sof_audio = { .probe = sof_audio_probe, @@ -601,7 +617,5 @@ module_platform_driver(sof_audio) MODULE_DESCRIPTION("SOF Audio Machine driver for CS42L42"); MODULE_AUTHOR("Brent Lu <brent.lu@intel.com>"); MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:sof_cs42l42"); -MODULE_ALIAS("platform:glk_cs4242_max98357a"); MODULE_IMPORT_NS(SND_SOC_INTEL_HDA_DSP_COMMON); MODULE_IMPORT_NS(SND_SOC_INTEL_SOF_MAXIM_COMMON); diff --git a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c index 73fe4f89a82d..8e86476d48de 100644 --- a/sound/soc/intel/common/soc-acpi-intel-jsl-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-jsl-match.c @@ -73,6 +73,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_jsl_machines[] = { .quirk_data = &mx98360a_spk, .sof_tplg_filename = "sof-jsl-rt5682-mx98360a.tplg", }, + { + .id = "10134242", + .drv_name = "jsl_cs4242_mx98360a", + .sof_fw_filename = "sof-jsl.ri", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &mx98360a_spk, + .sof_tplg_filename = "sof-jsl-rt5682-mx98360a.tplg", + }, {}, }; EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_jsl_machines);
This patch adds driver data for jsl_cs4242_mx98360a which supports two max98360a speaker amplifiers on SSP1 and cs42l42 headphone codec on SSP0 running on JSL platform. DAI format is leveraged from sof_rt5682 machine driver to reuse the topology. Also use module device table to replace module alias. Signed-off-by: Brent Lu <brent.lu@intel.com> --- sound/soc/intel/boards/sof_cs42l42.c | 22 +++++++++++++++---- .../intel/common/soc-acpi-intel-jsl-match.c | 8 +++++++ 2 files changed, 26 insertions(+), 4 deletions(-)