From patchwork Wed Jul 14 15:30:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 476811 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp676833jao; Wed, 14 Jul 2021 08:31:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGZP7e6TU/2bmIYDOLwQ987NQsg0rb2rPtCjxuIsrRuwNHTN1K0l0nkPLmiegv2y3tEOT8 X-Received: by 2002:a02:942e:: with SMTP id a43mr9508811jai.74.1626276692217; Wed, 14 Jul 2021 08:31:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626276692; cv=none; d=google.com; s=arc-20160816; b=m6cNFWECfrmUuY1xGHkr0RGleBQjzpD2h20ERdYDRGL1AdNlkBe0v0whB1AtAZhj47 BCnjm2yeTtkA/g4jGlsW53hlLuPhhcrVonA6+7lyCToLhXZpn878/VcvUmLYtgvOCGWv tPH94L7vcTR3sQnITwGYa1v9lSy/lk1BUes507f8xVzSX+JkEyNVWerbMhuhlIKW9P1Z z0MssU9N1FPRtbe/IUm/FujDVfzJxPvN3MMw0vJ5mQdUwrbOdL9Lh/kCTb/3OLN83cIn EnzzUe336HN78M6yMXBXOgb3g8NK4Ir8uDVGck8c0XoAt8C7nao9PEmMqCdDSDzsYSjP 8DFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2Lp0zZwDjM0o67Qr8IPD9fZg8MpkDEKyh4GA3N2Mu00=; b=U8o358MnWC4xrWB5881ty8iJrpWrGiQK7ZzNbwvF1iPi/HO0EdSt5eR+4S9EFMNAFw X1HmNEYKwbdQSJgOzp7WsBk5qcDYas8ElC//7Gl45oPBe40DDnX9mfVxZwmqnpbPNo+M q15uEonmrOCigL/spqu6nFh6IjkLzkvxvyUMYoHKHPL+KC2RSFsDxvfjRWfbPgo+pAkY WE/RhKsFaJHm1/hUFJ++h9wldncbL1TB3TNPDXilQgYzl9VTj0gsA0jJ8Q0j+Agjzrh7 3HkjGAvckP8v3WNPY+o7Hl98koqix/f5N6l9bUTdtKmYvf8mCohz6Djkl8l7uzdrQQCs /DwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LiBvy+mq; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g14si2951797jaj.31.2021.07.14.08.31.32; Wed, 14 Jul 2021 08:31:32 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LiBvy+mq; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239806AbhGNPeR (ORCPT + 7 others); Wed, 14 Jul 2021 11:34:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239731AbhGNPeJ (ORCPT ); Wed, 14 Jul 2021 11:34:09 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89339C06175F for ; Wed, 14 Jul 2021 08:31:17 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id l7so3726843wrv.7 for ; Wed, 14 Jul 2021 08:31:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2Lp0zZwDjM0o67Qr8IPD9fZg8MpkDEKyh4GA3N2Mu00=; b=LiBvy+mqpa9juYGqFMgrRvy5qkizs2Cp8TjMp41i3uDErqMjPTy02avYokshjxleW6 bc1hwBPPYIsfV7pBtWCoifHgQ9FfYoUO9hOq0l8TJo1HQt6OLIla5X1ML3tpEgt5BcO6 sSjVsVgBrpyBXn1mEIC6umg5vFMMYI2b5+3gX6BWw9YW26HcONQruouX0g8FTfeeXx/6 VY8TWQYizMW/apMc0EjejQ9rpreX5Y606+0mEus2tAg2M13x0xZsplXFX/VcgWZCN0iX 7SCDdx/Prl/ngUI36WoeotLi+1Npj2/9pMlwmnVrVW8q5v9+sW6+zgAIafvkW/QXFCFf 8kLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2Lp0zZwDjM0o67Qr8IPD9fZg8MpkDEKyh4GA3N2Mu00=; b=pQ+otOveO2UuG9cicY3XdcUnVLLUUN3CoaO0WuiMr39M9J1OXsp+FFka4hnUr3L2YG N2TZ+N7Tf4qiMWGTzwWDn8rEUo7sUt5dA6rP3JmCLYCZzzkzaEMGcUBcgTY8U1nthIDA 912HBjBZybzpayuVJLOIBi/hoQeU+tjph1iubnFjtfMj84yVz4PbE3Mjbez0ivIOUuWx R6muUc8swjYhDEnN/TzzaYUhbJPtNFF7noJG1WTUkuBDQNpW1+kYOPwRF/RAVj+xhglo dA8B40WN7FPqpXpPfnZLY1fUqmTrikC3wQtgHbnTlncw1YlbaZDAJQc4XO2+GxWuxel5 WuJA== X-Gm-Message-State: AOAM532ugkS8kFcWYJnKuah6V4AWIJTYQ3Fye6shd787HyNPTVvgW7/V H1RLPw5UQKaDymgn+2rejA3PnQ== X-Received: by 2002:adf:facf:: with SMTP id a15mr13666345wrs.39.1626276676193; Wed, 14 Jul 2021 08:31:16 -0700 (PDT) Received: from srini-hackbox.lan (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.gmail.com with ESMTPSA id y6sm2465174wma.48.2021.07.14.08.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jul 2021 08:31:15 -0700 (PDT) From: Srinivas Kandagatla To: bjorn.andersson@linaro.org, broonie@kernel.org, robh@kernel.org Cc: plai@codeaurora.org, tiwai@suse.de, devicetree@vger.kernel.org, perex@perex.cz, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, lgirdwood@gmail.com, bgoswami@codeaurora.org, Srinivas Kandagatla Subject: [PATCH v2 14/16] ASoC: qcom: audioreach: add volume ctrl module support Date: Wed, 14 Jul 2021 16:30:37 +0100 Message-Id: <20210714153039.28373-15-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210714153039.28373-1-srinivas.kandagatla@linaro.org> References: <20210714153039.28373-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/audioreach/audioreach.c | 34 ++++++++++++++++++++++++++ sound/soc/qcom/audioreach/audioreach.h | 8 ++++++ 2 files changed, 42 insertions(+) -- 2.21.0 diff --git a/sound/soc/qcom/audioreach/audioreach.c b/sound/soc/qcom/audioreach/audioreach.c index 1839d872fd5f..5a50eede4496 100644 --- a/sound/soc/qcom/audioreach/audioreach.c +++ b/sound/soc/qcom/audioreach/audioreach.c @@ -928,6 +928,40 @@ static int audioreach_shmem_set_media_format(struct q6apm_graph *graph, return rc; } +int audioreach_gain_set_vol_ctrl(struct q6apm *apm, struct audioreach_module + *module, int vol) +{ + struct apm_module_param_data *param_data; + struct param_id_vol_ctrl_master_gain *cfg; + int rc, payload_size; + struct gpr_pkt *pkt; + void *p; + + payload_size = sizeof(*cfg) + APM_MODULE_PARAM_DATA_SIZE; + p = audioreach_alloc_apm_cmd_pkt(payload_size, APM_CMD_SET_CFG, 0); + if (IS_ERR(p)) + return -ENOMEM; + + pkt = p; + p = p + GPR_HDR_SIZE + APM_CMD_HDR_SIZE; + + param_data = p; + param_data->module_instance_id = module->instance_id; + param_data->error_code = 0; + param_data->param_id = PARAM_ID_VOL_CTRL_MASTER_GAIN; + param_data->param_size = payload_size - APM_MODULE_PARAM_DATA_SIZE; + + p = p + APM_MODULE_PARAM_DATA_SIZE; + cfg = p; + cfg->master_gain = vol; + rc = q6apm_send_cmd_sync(apm, pkt, 0); + + kfree(pkt); + + return rc; +} +EXPORT_SYMBOL_GPL(audioreach_gain_set_vol_ctrl); + static int audioreach_gain_set(struct q6apm_graph *graph, struct audioreach_module *module) { diff --git a/sound/soc/qcom/audioreach/audioreach.h b/sound/soc/qcom/audioreach/audioreach.h index 6279ddc3c5ce..2c6d5f4e66b4 100644 --- a/sound/soc/qcom/audioreach/audioreach.h +++ b/sound/soc/qcom/audioreach/audioreach.h @@ -536,6 +536,14 @@ struct param_id_hw_ep_dma_data_align { uint32_t dma_data_align; } __packed; +#define PARAM_ID_VOL_CTRL_MASTER_GAIN 0x08001035 +#define VOL_CTRL_DEFAULT_GAIN 0x2000 +struct param_id_vol_ctrl_master_gain { + uint16_t master_gain; + uint16_t reserved; +} __packed; + + /* Graph */ struct audioreach_connection { /* Connections */