mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Srinivas Kandagatla <srini@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] ASoC: qcom: audioreach: Add support for VI Sense module
Date: Thu, 4 Sep 2025 12:04:06 +0100	[thread overview]
Message-ID: <79274958-52a0-4041-b4f3-365ee84fb088@oss.qualcomm.com> (raw)
In-Reply-To: <20250904102558.143745-4-krzysztof.kozlowski@linaro.org>



On 9/4/25 11:26 AM, Krzysztof Kozlowski wrote:
> VI Sense module in ADSP is responsible for feedback loop for measuring
> current and voltage of amplifiers, necessary for proper calibration of
> Speaker Protection algorightms.  Implement parsing
> MODULE_ID_SPEAKER_PROTECTION_VI from Audioreach topology and sending it
> as command to the ADSP.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---
> 
> Changes in v2:
> 1. Use PARAM_ID_SP_VI_OP_MODE_NORMAL
> 2. Make num_channels u32
> 3. I did not change uint32_t type in the header for consistency
> ---
>  sound/soc/qcom/qdsp6/audioreach.c | 112 ++++++++++++++++++++++++++++++
>  sound/soc/qcom/qdsp6/audioreach.h |  27 +++++++
>  2 files changed, 139 insertions(+)
> 
> diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c
> index 3b7dffd696e7..f344ce80676f 100644
> --- a/sound/soc/qcom/qdsp6/audioreach.c
> +++ b/sound/soc/qcom/qdsp6/audioreach.c
> @@ -202,6 +202,31 @@ struct apm_display_port_module_intf_cfg {
>  } __packed;
>  #define APM_DP_INTF_CFG_PSIZE ALIGN(sizeof(struct apm_display_port_module_intf_cfg), 8)
>  
> +struct apm_module_sp_vi_op_mode_cfg {
> +	struct apm_module_param_data param_data;
> +	struct param_id_sp_vi_op_mode_cfg cfg;
> +} __packed;
> +
> +#define APM_SP_VI_OP_MODE_CFG_PSIZE(ch) ALIGN( \
> +				sizeof(struct apm_module_sp_vi_op_mode_cfg) + \
> +				(ch) * sizeof(uint32_t), 8)
> +
> +struct apm_module_sp_vi_ex_mode_cfg {
> +	struct apm_module_param_data param_data;
> +	struct param_id_sp_vi_ex_mode_cfg cfg;
> +} __packed;
> +
> +#define APM_SP_VI_EX_MODE_CFG_PSIZE ALIGN(sizeof(struct apm_module_sp_vi_ex_mode_cfg), 8)
> +
> +struct apm_module_sp_vi_channel_map_cfg {
> +	struct apm_module_param_data param_data;
> +	struct param_id_sp_vi_channel_map_cfg cfg;
> +} __packed;
> +
> +#define APM_SP_VI_CH_MAP_CFG_PSIZE(ch) ALIGN( \
> +				sizeof(struct apm_module_sp_vi_channel_map_cfg) + \
> +				(ch) * sizeof(uint32_t), 8)
> +
>  static void *__audioreach_alloc_pkt(int payload_size, uint32_t opcode, uint32_t token,
>  				    uint32_t src_port, uint32_t dest_port, bool has_cmd_hdr)
>  {
> @@ -1258,6 +1283,89 @@ static int audioreach_speaker_protection(struct q6apm_graph *graph,
>  					 operation_mode);
>  }
>  
> +static int audioreach_speaker_protection_vi(struct q6apm_graph *graph,
> +					    struct audioreach_module *module,
> +					    struct audioreach_module_config *mcfg)
> +{
> +	u32 num_channels = mcfg->num_channels;
> +	struct apm_module_sp_vi_op_mode_cfg *op_cfg;
> +	struct apm_module_sp_vi_channel_map_cfg *cm_cfg;
> +	struct apm_module_sp_vi_ex_mode_cfg *ex_cfg;
> +	int op_sz, cm_sz, ex_sz;
> +	struct apm_module_param_data *param_data;
> +	int rc, i, payload_size;
> +	struct gpr_pkt *pkt;
> +	void *p;
> +
> +	if (num_channels > 2) {
> +		dev_err(graph->dev, "Error: Invalid channels (%d)!\n", num_channels);
> +		return -EINVAL;
> +	}
> +
> +	op_sz = APM_SP_VI_OP_MODE_CFG_PSIZE(num_channels);
> +	/* Channel mapping for Isense and Vsense, thus twice number of speakers. */
> +	cm_sz = APM_SP_VI_CH_MAP_CFG_PSIZE(num_channels * 2);
> +	ex_sz = APM_SP_VI_EX_MODE_CFG_PSIZE;
> +
> +	payload_size = op_sz + cm_sz + ex_sz;
> +
> +	pkt = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0);
> +	if (IS_ERR(pkt))
> +		return PTR_ERR(pkt);
> +
> +	p = (void *)pkt + GPR_HDR_SIZE + APM_CMD_HDR_SIZE;
> +
> +	op_cfg = p;
> +	param_data = &op_cfg->param_data;
> +	param_data->module_instance_id = module->instance_id;
> +	param_data->error_code = 0;
> +	param_data->param_id = PARAM_ID_SP_VI_OP_MODE_CFG;
> +	param_data->param_size = op_sz - APM_MODULE_PARAM_DATA_SIZE;
> +
> +	op_cfg->cfg.num_channels = num_channels;
> +	op_cfg->cfg.operation_mode = PARAM_ID_SP_VI_OP_MODE_NORMAL;
> +	op_cfg->cfg.quick_calibration = 1;

This field is only valid in calibration mode, we can remove it.

Other than that, it LGTM

Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>

--srini


  parent reply	other threads:[~2025-09-04 11:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04 10:25 [PATCH v2 1/2] ASoC: qcom: audioreach: Add support for Speaker Protection module Krzysztof Kozlowski
2025-09-04 10:26 ` [PATCH v2 2/2] ASoC: qcom: audioreach: Add support for VI Sense module Krzysztof Kozlowski
2025-09-04 10:28   ` Krzysztof Kozlowski
2025-09-04 11:04   ` Srinivas Kandagatla [this message]
2025-09-04 11:07     ` Krzysztof Kozlowski
2025-09-04 11:06 ` [PATCH v2 1/2] ASoC: qcom: audioreach: Add support for Speaker Protection module Srinivas Kandagatla

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=79274958-52a0-4041-b4f3-365ee84fb088@oss.qualcomm.com \
    --to=srinivas.kandagatla@oss.qualcomm.com \
    --cc=broonie@kernel.org \
    --cc=krzysztof.kozlowski@linaro.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=srini@kernel.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 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®