From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: James Ogletree <jogletre@opensource.cirrus.com>
Cc: James Ogletree <james.ogletree@cirrus.com>,
Fred Treven <fred.treven@cirrus.com>,
Ben Bright <ben.bright@cirrus.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Simon Trimmer <simont@opensource.cirrus.com>,
"Richard Fitzgerald" <rf@opensource.cirrus.com>,
Lee Jones <lee@kernel.org>, "Liam Girdwood" <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
"Jaroslav Kysela" <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
James Schulman <james.schulman@cirrus.com>,
David Rhodes <david.rhodes@cirrus.com>,
"Jacky Bai" <ping.bai@nxp.com>,
Alexandre Belloni <alexandre.belloni@bootlin.com>,
Jeff LaBundy <jeff@labundy.com>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
Peng Fan <peng.fan@nxp.com>,
Weidong Wang <wangweidong.a@awinic.com>,
Arnd Bergmann <arnd@arndb.de>,
Herve Codina <herve.codina@bootlin.com>,
Shuming Fan <shumingf@realtek.com>,
Shenghao Ding <13916275206@139.com>,
Ryan Lee <ryans.lee@analog.com>,
Linus Walleij <linus.walleij@linaro.org>,
Maxim Kochetkov <fido_max@inbox.ru>,
"open list:CIRRUS LOGIC HAPTIC DRIVERS"
<patches@opensource.cirrus.com>,
"open list:INPUT (KEYBOARD, MOUSE, JOYSTICK,
TOUCHSCREEN)..." <linux-input@vger.kernel.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
"open list:SOUND - SOC LAYER / DYNAMIC AUDIO POWER MANAGEM..."
<linux-sound@vger.kernel.org>,
"moderated list:CIRRUS LOGIC AUDIO CODEC DRIVERS"
<alsa-devel@alsa-project.org>
Subject: Re: [PATCH v5 5/5] ASoC: cs40l50: Support I2S streaming to CS40L50
Date: Fri, 5 Jan 2024 14:24:58 +0000 [thread overview]
Message-ID: <20240105142458.GH14858@ediswmail.ad.cirrus.com> (raw)
In-Reply-To: <20240104223643.876292-6-jogletre@opensource.cirrus.com>
On Thu, Jan 04, 2024 at 10:36:38PM +0000, James Ogletree wrote:
> Introduce support for Cirrus Logic Device CS40L50: a
> haptic driver with waveform memory, integrated DSP,
> and closed-loop algorithms.
>
> The ASoC driver enables I2S streaming to the device.
>
> Signed-off-by: James Ogletree <jogletre@opensource.cirrus.com>
> ---
> +#include <linux/mfd/cs40l50.h>
> +#include <linux/pm_runtime.h>
> +#include <sound/pcm_params.h>
> +#include <sound/soc.h>
Need to also include bitfield.h for FIELD_PREP etc.
> +static int cs40l50_clk_en(struct snd_soc_dapm_widget *w,
> + struct snd_kcontrol *kcontrol,
> + int event)
> +{
> + struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm);
> + struct cs40l50_codec *codec = snd_soc_component_get_drvdata(comp);
> + int ret;
> +
> + switch (event) {
> + case SND_SOC_DAPM_POST_PMU:
> + ret = regmap_write(codec->regmap, CS40L50_DSP_QUEUE, CS40L50_STOP_PLAYBACK);
> + if (ret)
> + return ret;
> +
> + ret = regmap_write(codec->regmap, CS40L50_DSP_QUEUE, CS40L50_START_I2S);
> + if (ret)
> + return ret;
> +
Feels weird that we don't wait for these two commands to be
acknowledged by the DSP before doing the clock swap. Is that
intentional? Is the DSP just guaranteed to be so fast it doesn't
matter, in which case a comment would be nice.
> +static int cs40l50_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
> +{
> + struct cs40l50_codec *codec = snd_soc_component_get_drvdata(codec_dai->component);
> +
> + if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS)
> + return -EINVAL;
> +
> + switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
> + case SND_SOC_DAIFMT_NB_NF:
> + codec->daifmt = 0;
> + break;
> + case SND_SOC_DAIFMT_NB_IF:
> + codec->daifmt = CS40L50_ASP_FSYNC_INV_MASK;
> + break;
> + case SND_SOC_DAIFMT_IB_NF:
> + codec->daifmt = CS40L50_ASP_BCLK_INV_MASK;
> + break;
> + case SND_SOC_DAIFMT_IB_IF:
> + codec->daifmt = CS40L50_ASP_FSYNC_INV_MASK | CS40L50_ASP_BCLK_INV_MASK;
> + break;
> + default:
> + return -EINVAL;
> + }
> +
> + if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S)
> + codec->daifmt |= FIELD_PREP(CS40L50_ASP_FMT_MASK, CS40L50_ASP_FMT_I2S);
It feels unlikely the chip supports all formats with no
additional settings? Probably should have a switch for the
supported formats and return an error.
> +static struct snd_soc_dai_driver cs40l50_dai[] = {
> + {
> + .name = "cs40l50-pcm",
> + .id = 0,
> + .playback = {
> + .stream_name = "ASP Playback",
> + .channels_min = 1,
> + .channels_max = 2,
> + .rates = SNDRV_PCM_RATE_48000,
> + .formats = CS40L50_FORMATS,
> + },
> + .ops = &cs40l50_dai_ops,
> + .symmetric_rate = 1,
The symmetric_rate feels a bit redundant since we only have
playback supported.
Thanks,
Charles
prev parent reply other threads:[~2024-01-05 14:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 22:36 [PATCH v5 0/5] Add support for CS40L50 James Ogletree
2024-01-04 22:36 ` [PATCH v5 1/5] firmware: cs_dsp: Add write sequencer interface James Ogletree
2024-01-05 16:36 ` Charles Keepax
2024-01-04 22:36 ` [PATCH v5 2/5] dt-bindings: input: cirrus,cs40l50: Add initial DT binding James Ogletree
2024-01-04 22:36 ` [PATCH v5 3/5] mfd: cs40l50: Add support for CS40L50 core driver James Ogletree
2024-01-05 14:04 ` Charles Keepax
2024-01-09 21:08 ` James Ogletree
2024-01-04 22:36 ` [PATCH v5 4/5] Input: cs40l50 - Add support for the CS40L50 haptic driver James Ogletree
2024-01-05 15:01 ` Charles Keepax
2024-01-07 1:58 ` Dmitry Torokhov
2024-01-09 22:03 ` James Ogletree
2024-01-09 22:31 ` Dmitry Torokhov
2024-01-10 14:36 ` James Ogletree
2024-01-11 7:28 ` Dmitry Torokhov
2024-01-12 15:41 ` James Ogletree
2024-01-24 20:58 ` James Ogletree
2024-01-04 22:36 ` [PATCH v5 5/5] ASoC: cs40l50: Support I2S streaming to CS40L50 James Ogletree
2024-01-05 14:24 ` Charles Keepax [this message]
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=20240105142458.GH14858@ediswmail.ad.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=13916275206@139.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnd@arndb.de \
--cc=ben.bright@cirrus.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=david.rhodes@cirrus.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=fido_max@inbox.ru \
--cc=fred.treven@cirrus.com \
--cc=herve.codina@bootlin.com \
--cc=james.ogletree@cirrus.com \
--cc=james.schulman@cirrus.com \
--cc=jeff@labundy.com \
--cc=jogletre@opensource.cirrus.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=peng.fan@nxp.com \
--cc=perex@perex.cz \
--cc=ping.bai@nxp.com \
--cc=rf@opensource.cirrus.com \
--cc=robh+dt@kernel.org \
--cc=ryans.lee@analog.com \
--cc=sebastian.reichel@collabora.com \
--cc=shumingf@realtek.com \
--cc=simont@opensource.cirrus.com \
--cc=tiwai@suse.com \
--cc=wangweidong.a@awinic.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
all inboxes | Powered by JetHome®