From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Richard Fitzgerald <rf@opensource.cirrus.com>,
Stefan Binding <sbinding@opensource.cirrus.com>,
Mark Brown <broonie@kernel.org>
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
patches@opensource.cirrus.com
Subject: Re: [PATCH v2 6/8] ASoC: cs42l42: Add Soundwire support
Date: Thu, 19 Jan 2023 08:48:14 -0600 [thread overview]
Message-ID: <6ea1b85f-22e2-8744-9638-6321a5a21acf@linux.intel.com> (raw)
In-Reply-To: <418f6b73-b5ac-8d87-a856-3413ec103f91@opensource.cirrus.com>
>>> +static int cs42l42_sdw_dai_startup(struct snd_pcm_substream *substream,
>>> + struct snd_soc_dai *dai)
>>> +{
>>> + struct cs42l42_private *cs42l42 =
>>> snd_soc_component_get_drvdata(dai->component);
>>> +
>>> + if (!cs42l42->init_done)
>>> + return -ENODEV;
>>
>> Can this happen? IIRC the ASoC framework would use
>> pm_runtime_resume_and_get() before .startup, which would guarantee that
>> the device is initialized, no?
>>
>
> Yes, this can happen. Because of the way that the SoundWire enumeration
> was implemented in the core code, it isn't a probe event so we cannot
> call snd_soc_register_component() on enumeration because -EPROBE_DEFER
> wouldn't be handled. So the snd_soc_register_component() must be called
> from probe(). This leaves a limbo situation where we've registered the
> driver but in fact don't yet have any hardware. ALSA/ASoC doesn't know
> that we've registered before we are functional so they are happy to
> go ahead and try to use the soundcard. If for some reason the hardware
> failed to enumerate we can get here without having enumerated.
Humm, yes, but you've also made the regmap cache-only, so is there
really a problem?
FWIW I don't see a startup callback in any other codec driver. It may be
wrong but it's also a sign that this isn't a problem we've seen so far
on existing Intel-based platforms.
>
>>> +
>>> + return 0;
>>> +}
>>> +
>>> +static int cs42l42_sdw_dai_hw_params(struct snd_pcm_substream
>>> *substream,
>>> + struct snd_pcm_hw_params *params,
>>> + struct snd_soc_dai *dai)
>>> +{
>>> + struct cs42l42_private *cs42l42 =
>>> snd_soc_component_get_drvdata(dai->component);
>>> + struct sdw_stream_runtime *sdw_stream =
>>> snd_soc_dai_get_dma_data(dai, substream);
>>> + struct sdw_stream_config stream_config = {0};
>>> + struct sdw_port_config port_config = {0};
>>> + int ret;
>>> +
>>> + if (!sdw_stream)
>>> + return -EINVAL;
>>> +
>>> + /* Needed for PLL configuration when we are notified of new bus
>>> config */
>>> + cs42l42->sample_rate = params_rate(params);
>>
>> wouldn't it be better to check if the sample_rate is supported by the
>> PLL here, instead of in the .prepare step ...
>>
> It depends on the soundwire bus clock. We need to know both to determine
> whether they are valid. IFF we can assume that the call to
> sdw_stream_add_slave() will always invoke the bus_config() callback we
> can call cs42l42_pll_config() from cs42l42_sdw_bus_config() and return
> an error from cs42l42_sdw_bus_config() if the {swire_clk, sample_rate}
> pair isn't valid.
You lost me here. Are you saying the soundwire bus clock is only known
in the prepare stage?
>>> +static int cs42l42_sdw_dai_set_sdw_stream(struct snd_soc_dai *dai,
>>> void *sdw_stream,
>>> + int direction)
>>> +{
>>> + if (!sdw_stream)
>>> + return 0;
>>> +
>>> + if (direction == SNDRV_PCM_STREAM_PLAYBACK)
>>> + dai->playback_dma_data = sdw_stream;
>>> + else
>>> + dai->capture_dma_data = sdw_stream;
>>> +
>>> + return 0;
>>
>> Humm, this is interesting, you are not using the sdw_stream_data that
>> all other codecs use, but in hindsight I have no idea why we allocate
>> something to only store a pointer.
>>
>
> Indeed. I can see no reason to wrap this pointer in another struct when
> we can store the pointer direct so I dropped the wrapper struct.
I'll see if we can simplify the other codec drivers.
>>> +static int cs42l42_sdw_update_status(struct sdw_slave *peripheral,
>>> + enum sdw_slave_status status);s
>>> +{
>>> + struct cs42l42_private *cs42l42 =
>>> dev_get_drvdata(&peripheral->dev);
>>> +
>>> + switch (status) {
>>> + case SDW_SLAVE_ATTACHED:
>>> + dev_dbg(cs42l42->dev, "ATTACHED\n");
>>> + if (!cs42l42->init_done)
>>> + cs42l42_sdw_init(peripheral);
>>
>> unclear to me what happens is the bus suspends, how would you redo the
>> init?
>>
>
> We don't need to re-run the init(). A regcache_sync() will restore
> settings.
ah, interesting. Other codec drivers play with specific registers that
aren't in regmap. There's also headset calibration that's done
differently in the first init or later.
next prev parent reply other threads:[~2023-01-19 14:49 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 16:04 [PATCH v2 0/8] ASoC: cs42l42: Add Soundwire support Stefan Binding
2023-01-18 16:04 ` [PATCH v2 1/8] soundwire: stream: Add specific prep/deprep commands to port_prep callback Stefan Binding
2023-01-18 16:37 ` Pierre-Louis Bossart
2023-01-18 16:04 ` [PATCH v2 2/8] ASoC: cs42l42: Add SOFT_RESET_REBOOT register Stefan Binding
2023-01-18 16:41 ` Pierre-Louis Bossart
2023-01-19 13:33 ` Richard Fitzgerald
2023-01-18 16:04 ` [PATCH v2 3/8] ASoC: cs42l42: Ensure MCLKint is a multiple of the sample rate Stefan Binding
2023-01-18 16:46 ` Pierre-Louis Bossart
2023-01-18 16:04 ` [PATCH v2 4/8] ASoC: cs42l42: Separate ASP config from PLL config Stefan Binding
2023-01-18 16:04 ` [PATCH v2 5/8] ASoC: cs42l42: Export some functions for Soundwire Stefan Binding
2023-01-18 16:04 ` [PATCH v2 6/8] ASoC: cs42l42: Add Soundwire support Stefan Binding
2023-01-18 17:41 ` Pierre-Louis Bossart
2023-01-19 13:58 ` Richard Fitzgerald
2023-01-19 14:48 ` Pierre-Louis Bossart [this message]
2023-01-19 15:35 ` Richard Fitzgerald
2023-01-19 16:27 ` Pierre-Louis Bossart
2023-01-20 12:31 ` Richard Fitzgerald
2023-01-20 19:55 ` Pierre-Louis Bossart
2023-01-23 15:51 ` Richard Fitzgerald
2023-01-23 16:05 ` Pierre-Louis Bossart
2023-01-23 16:14 ` Richard Fitzgerald
2023-01-23 16:25 ` Pierre-Louis Bossart
2023-01-18 16:04 ` [PATCH v2 7/8] ASoC: cs42l42: Don't set idle_bias_on Stefan Binding
2023-01-18 16:04 ` [PATCH v2 8/8] ASoC: cs42l42: Wait for debounce interval after resume Stefan Binding
2023-01-18 17:43 ` [PATCH v2 0/8] ASoC: cs42l42: Add Soundwire support Pierre-Louis Bossart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6ea1b85f-22e2-8744-9638-6321a5a21acf@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=rf@opensource.cirrus.com \
--cc=sbinding@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox