From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Niranjan H Y <niranjan.hy@ti.com>
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
broonie@kernel.org, lgirdwood@gmail.com, perex@perex.cz,
tiwai@suse.com, cezary.rojewski@intel.com,
peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com,
ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com,
pierre-louis.bossart@linux.dev, baojun.xu@ti.com,
shenghao-ding@ti.com, sandeepk@ti.com, v-hampiholi@ti.com
Subject: Re: [PATCH v2 2/4] ASoC: tac5xx2-sdw: add soundwire based codec driver
Date: Fri, 27 Mar 2026 10:48:06 +0000 [thread overview]
Message-ID: <acZgZnup3ENYl9SS@opensource.cirrus.com> (raw)
In-Reply-To: <20260326181712.2274-2-niranjan.hy@ti.com>
On Thu, Mar 26, 2026 at 11:47:10PM +0530, Niranjan H Y wrote:
> +/* TLV for volume control */
> +static const DECLARE_TLV_DB_SCALE(tac5xx2_amp_tlv, 0, 50, 0);
> +static const DECLARE_TLV_DB_SCALE(tac5xx2_dvc_tlv, -7200, 50, 0);
> +
> +/* Q7.8 volume control parameters: range -72dB to +6dB, step 0.5dB */
> +#define TAC_DVC_STEP 128 /* 0.5 dB in Q7.8 format */
> +#define TAC_DVC_MIN (-144) /* -72 dB / 0.5 dB step */
> +#define TAC_DVC_MAX 12 /* +6 dB / 0.5 dB step */
> +
> +#define SOC_SINGLE_Q78_TLV(xname, xreg, tlv_array) { \
> + .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
> + .name = xname, \
> + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE, \
> + .tlv.p = (tlv_array), \
> + .info = snd_soc_info_volsw, .get = q78_get_volsw, .put = q78_put_volsw, \
> + .private_value = (unsigned long)&(struct soc_mixer_control) { \
> + .reg = (xreg), .rreg = (xreg), \
> + .min = TAC_DVC_MIN, .max = TAC_DVC_MAX, \
> + .platform_max = TAC_DVC_MAX - TAC_DVC_MIN, .shift = TAC_DVC_STEP, \
What is the purpose of the platform_max here? Doesn't feel like
we should be setting that from the driver.
> + .sign_bit = 15 \
> + } \
> +}
Probably makes sense to parameterise min,max,step here and then
put this macro in the sdca_asoc.h header, perhaps rename to
something like SDCA_SINGLE_Q78_TLV as well. That way if others
are creating these controls directly they can just reuse that.
> +static int tac5xx2_sdca_button_detect(struct tac5xx2_prv *tac_dev)
> +{
> + unsigned int btn_type, offset, idx;
> + int ret, value, owner;
> + u8 buf[2];
> +
> + ret = regmap_read(tac_dev->regmap,
> + SDW_SDCA_CTL(TAC_FUNCTION_ID_HID, TAC_SDCA_ENT_HID1,
> + TAC_SDCA_CTL_HIDTX_CURRENT_OWNER, 0), &owner);
> + if (ret) {
> + dev_err(tac_dev->dev,
> + "Failed to read current UMP message owner 0x%x", ret);
> + return ret;
> + }
> +
> + if (owner == 1) {
Would be nice to use the SDCA_UMP_OWNER_DEVICE define here.
> + dev_dbg(tac_dev->dev, "current owner is host, skipping..");
I think this message should read either "current owner is device"
or "current owner is not host", as a value of 1 is device and it
makes more sense in the context.
> + return 0;
> + }
> +
> + ret = regmap_read(tac_dev->regmap,
> + SDW_SDCA_CTL(TAC_FUNCTION_ID_HID, TAC_SDCA_ENT_HID1,
> + TAC_SDCA_CTL_HIDTX_MESSAGE_OFFSET, 0), &value);
> + if (ret) {
> + dev_err(tac_dev->dev,
> + "Failed to read current UMP message offset: %d", ret);
> + goto end_btn_det;
> + }
> +
> + dev_dbg(tac_dev->dev, "btn_ message offset = %x", value);
> + offset = value;
> +
> + for (idx = 0; idx < sizeof(buf); idx++) {
> + ret = regmap_read(tac_dev->regmap,
> + TAC_BUF_ADDR_HID1 + offset + idx, &value);
> + if (ret) {
> + dev_err(tac_dev->dev,
> + "Failed to read HID buffer: %d", ret);
> + goto end_btn_det;
> + }
> + buf[idx] = value & 0xff;
> + }
> +
> + if (buf[0] == 0x1) {
> + btn_type = tac5xx2_sdca_btn_type(&buf[1], tac_dev);
> + ret = btn_type;
> + }
> +
> +end_btn_det:
> + if (!owner)
Does this if actually make sense? owner can only be 0,1 by the spec
and you check for 1 earlier in the function, so isn't this always
true?
> + regmap_write(tac_dev->regmap,
> + SDW_SDCA_CTL(TAC_FUNCTION_ID_HID, TAC_SDCA_ENT_HID1,
> + TAC_SDCA_CTL_HIDTX_CURRENT_OWNER, 0), 0x01);
> +
> + return ret;
> +}
> +static const struct sdw_device_id tac_sdw_id[] = {
> + SDW_SLAVE_ENTRY(0x0102, 0x5572, 0),
> + SDW_SLAVE_ENTRY(0x0102, 0x5672, 0),
> + SDW_SLAVE_ENTRY(0x0102, 0x5682, 0),
> + SDW_SLAVE_ENTRY(0x0102, 0x2883, 0),
> + {},
> +};
Not that I am pushing for this now on this driver but would be
good for you guys to perhaps poke what happens binding your parts
with the class driver itself (sdca_class.c). The hope would be
in time we can support all new SDCA parts out of there by just
adding the slave entry. So good to start finding out what does
and doesn't work for you guys. At the moment the class driver is
still in active development and a lot of shipping products have
dodgy DisCo or hardware issues that make use difficult, so
this is more of a long term goal. From scanning the driver here
I am guessing perhaps the firmware download might not work so
well with your current parts. But a lot of the rest looks like
it would assuming the DisCo is all correct.
Thanks,
Charles
next prev parent reply other threads:[~2026-03-27 10:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 18:17 [PATCH v2 1/4] ASoC: SDCA: make q78_get_volsw and q78_put_volsw extern Niranjan H Y
2026-03-26 18:17 ` [PATCH v2 2/4] ASoC: tac5xx2-sdw: add soundwire based codec driver Niranjan H Y
2026-03-27 10:48 ` Charles Keepax [this message]
2026-03-26 18:17 ` [PATCH v2 3/4] ASoC: sdw_utils: TI amp utility for tac5xx2 family Niranjan H Y
2026-03-26 18:17 ` [PATCH v2 4/4] ASoC: tac5xx2-sdw: ACPI match for intel mtl platform Niranjan H Y
2026-03-27 10:49 ` [PATCH v2 1/4] ASoC: SDCA: make q78_get_volsw and q78_put_volsw extern Charles Keepax
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=acZgZnup3ENYl9SS@opensource.cirrus.com \
--to=ckeepax@opensource.cirrus.com \
--cc=baojun.xu@ti.com \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=niranjan.hy@ti.com \
--cc=perex@perex.cz \
--cc=peter.ujfalusi@linux.intel.com \
--cc=pierre-louis.bossart@linux.dev \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sandeepk@ti.com \
--cc=shenghao-ding@ti.com \
--cc=tiwai@suse.com \
--cc=v-hampiholi@ti.com \
--cc=yung-chuan.liao@linux.intel.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