Re: [PATCH 03/19] soundwire: amd: register sdw controller dai ops

From: Pierre-Louis Bossart
Date: Fri Jan 13 2023 - 14:28:18 EST




>>> +static int amd_sdwc_hw_params(struct snd_pcm_substream *substream,
>>> + struct snd_pcm_hw_params *params,
>>> + struct snd_soc_dai *dai)
>>> +{
>>> + struct amd_sdwc_ctrl *ctrl = snd_soc_dai_get_drvdata(dai);
>>> + struct sdw_amd_dma_data *dma;
>>> + struct sdw_stream_config sconfig;
>>> + struct sdw_port_config *pconfig;
>>> + int ch, dir;
>>> + int ret;
>>> +
>>> + dma = snd_soc_dai_get_dma_data(dai, substream);
>>> + if (!dma)
>>> + return -EIO;
>>> +
>>> + ch = params_channels(params);
>>> + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
>>> + dir = SDW_DATA_DIR_RX;
>>> + else
>>> + dir = SDW_DATA_DIR_TX;
>>> + dev_dbg(ctrl->dev, "%s: dir:%d dai->id:0x%x\n", __func__, dir, dai->id);
>>> + dma->hw_params = params;
>>> +
>>> + sconfig.direction = dir;
>>> + sconfig.ch_count = ch;
>>> + sconfig.frame_rate = params_rate(params);
>>> + sconfig.type = dma->stream_type;
>>> +
>>> + sconfig.bps = snd_pcm_format_width(params_format(params));
>>> +
>>> + /* Port configuration */
>>> + pconfig = kzalloc(sizeof(*pconfig), GFP_KERNEL);
>>> + if (!pconfig) {
>>> + ret = -ENOMEM;
>>> + goto error;
>>> + }
>>> +
>>> + pconfig->num = dai->id;
>>> + pconfig->ch_mask = (1 << ch) - 1;
>>> + ret = sdw_stream_add_master(&ctrl->bus, &sconfig,
>>> + pconfig, 1, dma->stream);
>>> + if (ret)
>>> + dev_err(ctrl->dev, "add master to stream failed:%d\n", ret);
>>> +
>>> + kfree(pconfig);
>>> +error:
>>> + return ret;
>>> +}
>> This looks inspired from intel.c, but you are not programming ANY
>> registers here. is this intentional?
> We don't have any additional registers to be programmed like intel.

ok, this is worthy of a comment.


>>> +static const struct snd_soc_dai_ops amd_sdwc_dai_ops = {
>>> + .hw_params = amd_sdwc_hw_params,
>>> + .hw_free = amd_sdwc_hw_free,
>>> + .set_stream = amd_pcm_set_sdw_stream,
>> In the first patch there was support for PDM exposed, but here it's PDM
>> only?
> Didn't get your question.
> First patch talks about creating dev nodes for Soundwire managers and
> ACP PDM controller based on ACP pin config.

Sorry, my comment has a typo.

I meant that the first patch exposed PDM support but here you only have PCM?