All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexey Klimov" <alexey.klimov@linaro.org>
To: "Krzysztof Kozlowski" <krzk@kernel.org>
Cc: <broonie@kernel.org>, <konradybcio@kernel.org>,
	<konrad.dybcio@oss.qualcomm.com>, <andersson@kernel.org>,
	<srinivas.kandagatla@linaro.org>, <tiwai@suse.com>,
	<lgirdwood@gmail.com>, <perex@perex.cz>, <robh@kernel.org>,
	<krzk+dt@kernel.org>, <conor+dt@kernel.org>,
	<dmitry.baryshkov@linaro.org>, <linux-sound@vger.kernel.org>,
	<linux-arm-msm@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 07/10] ASoC: codecs: add wsa881x-i2c amplifier codec driver
Date: Wed, 11 Dec 2024 21:17:43 +0000	[thread overview]
Message-ID: <D696MX61IL6R.1AU1HXYUNH9LI@linaro.org> (raw)
In-Reply-To: <jqsa7lsypf62uqjydqbyspvtnt7iuwxclfwuyatgee2zgduwvd@4wwagvovam4k>

On Fri Nov 1, 2024 at 8:12 AM GMT, Krzysztof Kozlowski wrote:
> On Fri, Nov 01, 2024 at 05:31:51AM +0000, Alexey Klimov wrote:
> > Add support to analog mode of WSA8810/WSA8815 Class-D Smart Speaker
> > family of amplifiers. Such amplifiers is primarily interfaced with
> > SoundWire but they also support analog mode which is configurable
> > by setting one of the pins to high/low. In such case the WSA881X
> > amplifier is configurable only using i2c.
> > 
> > To have stereo two WSA881X amplifiers are required but mono
> > configurations are also possible.
> > 
> > Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > Signed-off-by: Alexey Klimov <alexey.klimov@linaro.org>
> > ---
> >  sound/soc/codecs/Kconfig          |   11 +
> >  sound/soc/codecs/Makefile         |    2 +
> >  sound/soc/codecs/wsa881x-common.h |   19 +
> >  sound/soc/codecs/wsa881x-i2c.c    | 1454 +++++++++++++++++++++++++++++
> >  4 files changed, 1486 insertions(+)
> >  create mode 100644 sound/soc/codecs/wsa881x-i2c.c

> > +++ b/sound/soc/codecs/wsa881x-i2c.c

[...]

> > +struct reg_default wsa881x_ana_reg_defaults[] = {
>
> Not const?
>
> Same question everywhere further.

Here it doesn't work:

sound/soc/codecs/wsa881x-i2c.c: In function ‘wsa881x_update_reg_defaults_2_0’:
sound/soc/codecs/wsa881x-i2c.c:421:65: error: assignment of member ‘def’ in read-only object
  421 |                                 wsa881x_ana_reg_defaults[j].def =
      |                                                                 ^
sound/soc/codecs/wsa881x-i2c.c:428:65: error: assignment of member ‘def’ in read-only object
  428 |                                 wsa881x_ana_reg_defaults[j].def =
      |                                                                 ^

but I updated it other places.

> > +	{WSA881X_CHIP_ID0, 0x00},
> > +	{WSA881X_CHIP_ID1, 0x00},

[...]

> > +static void wsa881x_clk_ctrl(struct snd_soc_component *component, bool enable)
> > +{
> > +	struct wsa881x_priv *wsa881x =
> > +				snd_soc_component_get_drvdata(component);
> > +
> > +	dev_dbg(component->dev, "%s:ss enable:%d\n", __func__, enable);
>
> Please drop all tracing-like debugs from final code.

With a pleasure.

> > +static int wsa881x_i2c_probe(struct i2c_client *client)
> > +{
> > +	struct device *dev = &client->dev;
> > +	struct wsa881x_priv *wsa881x;
> > +	int wsa881x_index = 0;
> > +	int ret;
> > +
> > +	ret = wsa881x_probe_common(&wsa881x, dev);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = wsa881x_i2c_get_client_index(client, &wsa881x_index);
> > +	if (ret) {
> > +		dev_err(dev, "get codec I2C client failed\n");
> > +		return ret;
> > +	}
> > +	wsa881x->index = wsa881x_index;
>
> I cannot find how this is used. Your entire I2C address detection seems
> odd and not used at all. None of the I2C drivers are supposed to do
> this.

This is used to differentiate between two amplifiers, mostly in sound
component names. I found another way to implement this and it will be
present in version 2.

[..]

> > +	wsa881x->driver = devm_kzalloc(dev, sizeof(*wsa881x->driver),
> > +				       GFP_KERNEL);
> > +	if (!wsa881x->driver)
> > +		return -ENOMEM;
> > +
> > +	memcpy(wsa881x->driver, &soc_codec_dev_wsa881x,
> > +	       sizeof(*wsa881x->driver));
>
> Why not devm_kmemdump?

Because it doesn't yet exist in kernel.
But there is another nice thingy -- devm_kmemdup that can be used. Thanks!

> > +	wsa881x->dai_driver = devm_kzalloc(dev,

[...]

> Why this is just not module_i2c_driver?

Thank you for the review. I was aware that initialisation is not perfect,
it is inherited from downstream code.
I reworked a lot of these parts of wsa881x-i2c.c driver and will share it
in version 2.

Best regards,
Alexey


  parent reply	other threads:[~2024-12-11 21:17 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-01  5:31 [PATCH v1 00/10] qrb4210-rb2: add wsa/wcd audio playback support Alexey Klimov
2024-11-01  5:31 ` [PATCH v1 01/10] arm64: dts: qcom: sm6115: add LPASS devices Alexey Klimov
2024-11-01  5:31 ` [PATCH v1 02/10] arm64: dts: qcom: sm4250: add description of soundwire pins Alexey Klimov
2024-11-01  5:31 ` [PATCH v1 03/10] arm64: dts: qcom: qrb4210-rb2: add wcd937x codec support Alexey Klimov
2024-11-01  7:59   ` Krzysztof Kozlowski
2024-12-11 20:37     ` Alexey Klimov
2024-11-01  5:31 ` [PATCH v1 04/10] ASoC: codecs: wsa881x: split into common and soundwire drivers Alexey Klimov
2024-11-01  5:31 ` [PATCH v1 05/10] dt-bindings: arm: qcom-soc: extend pattern matching for QRB4210/QRB2210 SoCs Alexey Klimov
2024-11-01  7:54   ` Krzysztof Kozlowski
2024-12-11 20:12     ` Alexey Klimov
2024-11-01  5:31 ` [PATCH v1 06/10] ASoC: dt-bindings: add wsa881x-i2c binding for analog mode Alexey Klimov
2024-11-01  7:57   ` Krzysztof Kozlowski
2024-11-01  8:00     ` Krzysztof Kozlowski
2024-12-11 20:35     ` Alexey Klimov
2024-12-12  7:23       ` Krzysztof Kozlowski
2024-11-01  5:31 ` [PATCH v1 07/10] ASoC: codecs: add wsa881x-i2c amplifier codec driver Alexey Klimov
2024-11-01  8:12   ` Krzysztof Kozlowski
2024-11-01 13:12     ` Mark Brown
2024-11-01 13:53       ` Krzysztof Kozlowski
2024-11-01 14:03         ` Mark Brown
2024-12-11 21:17     ` Alexey Klimov [this message]
2024-11-01 12:02   ` Rob Herring
2024-11-01  5:31 ` [PATCH v1 08/10] arm64: dts: qcom: qrb4210-rb2: enable wsa881x amplifier Alexey Klimov
2024-11-01  8:14   ` Krzysztof Kozlowski
2024-12-12  0:46     ` Alexey Klimov
2024-11-02  9:30   ` Konrad Dybcio
2024-12-11 23:18     ` Alexey Klimov
2024-11-01  5:31 ` [PATCH v1 09/10] arm64: dts: qcom: qrb4210-rb2: add WSA audio playback support Alexey Klimov
2024-11-01  5:31 ` [PATCH v1 10/10] ASoC: qcom: sm8250: force single channel via RX_1 output Alexey Klimov
2024-11-04 11:19   ` Konrad Dybcio

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=D696MX61IL6R.1AU1HXYUNH9LI@linaro.org \
    --to=alexey.klimov@linaro.org \
    --cc=andersson@kernel.org \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=krzk@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=robh@kernel.org \
    --cc=srinivas.kandagatla@linaro.org \
    --cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.