Re: [alsa-devel] [PATCH v2 4/4] ASoC: codecs: add wsa881x amplifier support

From: Srinivas Kandagatla
Date: Thu Aug 08 2019 - 12:20:17 EST


Thanks for taking time to review,

On 08/08/2019 16:18, Pierre-Louis Bossart wrote:

+/* 4 ports */
+static struct sdw_dpn_prop wsa_sink_dpn_prop[WSA881X_MAX_SWR_PORTS] = {
+ÂÂÂ {
+ÂÂÂÂÂÂÂ /* DAC */
+ÂÂÂÂÂÂÂ .num = 1,
+ÂÂÂÂÂÂÂ .type = SDW_DPN_SIMPLE,

IIRC we added the REDUCED type in SoundWire 1.1 to cover the PDM case with channel packing (or was it grouping) used by Qualcomm. I am not sure the SIMPLE type works?
grouping I guess.

This is a simplified data port as there is no DPn_OffsetCtrl2 register implemented.

Having said below channel count looks incorrect, i should fix that.


+ÂÂÂÂÂÂÂ .min_ch = 1,
+ÂÂÂÂÂÂÂ .max_ch = 8,
+ÂÂÂÂÂÂÂ .simple_ch_prep_sm = true,
+ÂÂÂ }, {
+ÂÂÂÂÂÂÂ /* COMP */
+ÂÂÂÂÂÂÂ .num = 2,
+ÂÂÂÂÂÂÂ .type = SDW_DPN_SIMPLE,
+ÂÂÂÂÂÂÂ .min_ch = 1,
+ÂÂÂÂÂÂÂ .max_ch = 8,
+ÂÂÂÂÂÂÂ .simple_ch_prep_sm = true,
+ÂÂÂ }, {
+ÂÂÂÂÂÂÂ /* BOOST */
+ÂÂÂÂÂÂÂ .num = 3,
+ÂÂÂÂÂÂÂ .type = SDW_DPN_SIMPLE,
+ÂÂÂÂÂÂÂ .min_ch = 1,
+ÂÂÂÂÂÂÂ .max_ch = 8,
+ÂÂÂÂÂÂÂ .simple_ch_prep_sm = true,
+ÂÂÂ }, {
+ÂÂÂÂÂÂÂ /* VISENSE */
+ÂÂÂÂÂÂÂ .num = 4,
+ÂÂÂÂÂÂÂ .type = SDW_DPN_SIMPLE,
+ÂÂÂÂÂÂÂ .min_ch = 1,
+ÂÂÂÂÂÂÂ .max_ch = 8,
+ÂÂÂÂÂÂÂ .simple_ch_prep_sm = true,
+ÂÂÂ }
+};

+static int wsa881x_update_status(struct sdw_slave *slave,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ enum sdw_slave_status status)
+{
+ÂÂÂ struct wsa881x_priv *wsa881x = dev_get_drvdata(&slave->dev);
+
+ÂÂÂ if (status == SDW_SLAVE_ATTACHED) {

there is an ambiguity here, the Slave can be attached but as device0 (not enumerated). We should check dev_num > 0

Thanks for point that! will add a check!

+ÂÂÂÂÂÂÂ if (!wsa881x->regmap) {
+ÂÂÂÂÂÂÂÂÂÂÂ wsa881x->regmap = devm_regmap_init_sdw(slave,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &wsa881x_regmap_config);
+ÂÂÂÂÂÂÂÂÂÂÂ if (IS_ERR(wsa881x->regmap)) {
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ dev_err(&slave->dev, "regmap_init failed\n");
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ return PTR_ERR(wsa881x->regmap);
+ÂÂÂÂÂÂÂÂÂÂÂ }
+ÂÂÂÂÂÂÂ }
+
+ÂÂÂÂÂÂÂ return snd_soc_register_component(&slave->dev,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ &wsa881x_component_drv,
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ NULL, 0);
+ÂÂÂ } else if (status == SDW_SLAVE_UNATTACHED) {
+ÂÂÂÂÂÂÂ snd_soc_unregister_component(&slave->dev);

the update_status() is supposed to be called based on bus events, it'd be very odd to register/unregister the component itself dynamically. In our existing Realtek-based solutions the register_component() is called in the probe function (and unregister_component() in remove). We do the inits when the Slave becomes attached but the component is already registered.

looks less intrusive! I will give that a try!

+ÂÂÂ }
+
+ÂÂÂ return 0;
+}
+
+
+static int wsa881x_remove(struct sdw_slave *sdw)
+{
+ÂÂÂ return 0;
+}
+
+static const struct sdw_device_id wsa881x_slave_id[] = {
+ÂÂÂ SDW_SLAVE_ENTRY(0x0217, 0x2010, 0),
+ÂÂÂ {},
+};
+MODULE_DEVICE_TABLE(sdw, wsa881x_slave_id);
+
+static struct sdw_driver wsa881x_codec_driver = {
+ÂÂÂ .probeÂÂÂ = wsa881x_probe,
+ÂÂÂ .remove = wsa881x_remove,

is this needed since you do nothing in that function?

yes, it can be removed! will do that in next version.

--srini