Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp745046rwn; Thu, 15 Sep 2022 06:02:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6wqArxo4LfDhhzU9YZYcgPFN7xT8k8ycxoSE5NU1bdVoU6KzOZDEwnIYKYjCbOY56MI3M7 X-Received: by 2002:a17:907:31ce:b0:780:7cd4:90d0 with SMTP id xf14-20020a17090731ce00b007807cd490d0mr591998ejb.758.1663246945021; Thu, 15 Sep 2022 06:02:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663246945; cv=none; d=google.com; s=arc-20160816; b=qd4QIWYmmRTzHHRMFwSqk3D1a90M+Ny1BF9bnW/MaEEuH2TZ+ayQz3mnHSshjgy4OH CO++z1orRk8VgEN9yPdbt33BUoAdG/sT3Q2Tk//0dQ5+bv6wTBxq/6aF5BP+3/hPK5wh aCRMgXu8poMZGQpY8jFAjGZSSbG18dxfHK6eMSaqSTr4aOUG834dOlCMtPJAW57Kkrz3 +/GYuVgolc6uOqRI4rorWbsQOYw2elqtU5WtC+PdvHNp9LKb1ZFyHVBrSVYdK53jNj2b yScfL3obiuz3imRea4IXq9M3cmlxnrRRyjrQIocYbRPQHVo8Gq7GCi5Uy0lliklBSrcv h8NQ== 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=/rwIpVMtqg6E5+Qn4IKE9HpHCiGyTi0zfy7IdHUtvvk=; b=XeLkPznYSu7Nbfq+YzExgO/M4/dXs+qzEHtqxP9kgK/itajX+aGEDhmKHRS7EfwTZU 1zhE5hcnXvZ3z7UG0txadVSKK9Wvi/ijNcNaDjfMDa6MpnDEBeuuSbfcLFdYmlVpGOXY IWDviEuwxIUpXLBI1iTJAbY+Mt9pDz1/OFm8UZFIRkVIbmw50MHBaoNXAD0LalJoMVoL KrSBPjJ1yiblfE0Hw89fMVT3DP+VzK3q9FrGPT2EdTKjWw2Ao92t5BMjkjm/WlfnAwa+ Et418zc9uMQDl4i8x9bMm9l6s/t0THWGAWAhqJq46hT25CtrYbRR0cKwZZHv5cm5s5bS YRUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lVZiZSfP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr1-20020a1709073f8100b0077f67871c33si9208811ejc.124.2022.09.15.06.01.58; Thu, 15 Sep 2022 06:02:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lVZiZSfP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S230092AbiIOMjd (ORCPT + 99 others); Thu, 15 Sep 2022 08:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229960AbiIOMjH (ORCPT ); Thu, 15 Sep 2022 08:39:07 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61CC985A95 for ; Thu, 15 Sep 2022 05:39:01 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id ay7-20020a05600c1e0700b003b49861bf48so3748837wmb.0 for ; Thu, 15 Sep 2022 05:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=/rwIpVMtqg6E5+Qn4IKE9HpHCiGyTi0zfy7IdHUtvvk=; b=lVZiZSfPUnZTZe4T+QPQHIt2UCK4rxq70unUHgC+V2ogXC9S/NpvPeFv/+Eu3QcaTJ lNkLgF6gT6dt/FZD/rrkC584Q01Rv8iasK7DeP3gwX8kUq2/GJUzLJp7c7mrzjU/FzHu 5Zb6ygtY3heZUtB4FS3x9r8QE23BGFgKTOf0i6bBnLz1jVVv4H0gkgqQ0exHpiATPoF3 j6ESTP5arrJPZ1e5IQxIwmCBwJP9h0yMnaxqZOzsZFrNkJrrPvbV/jJmeBn/Ly2upxRw PtKV6+10LCMkgX6HnYa3gJEWx/h7a2L29jXwruh8Yj0OEydN8w+IAusglbgndopiEakj oj+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/rwIpVMtqg6E5+Qn4IKE9HpHCiGyTi0zfy7IdHUtvvk=; b=zEaeAvhOmjD6t+t3A0F9v2+tSQdsSsUtArLOLAkXYB5xM4LKmK11mgnFdDndcFUH66 +8xjfZMpnRmx/BWTszQ8a/RqvN4ZyMJL7a64sRPC4ARncxQlM0TBj2AmR/pEM9IE/jgu eun9Il0EZjfn4zYdwldwvEA53LTmEyxtA8fmsad/ebzS1CDQslE3r2t5FSaUDZR7Krkk 0/ouZYZPvLRmWxdykJhZ1uSPPZPM6++VG1Alb2vauNvjbfPoO0uGYodInpEAD1Nopxx2 WN3NwX3bOtN5N9Eb3AVqW0wtKd9Rtwkfzg1vxYLOqGIZYstfeN+9tb7PM2SWoFEno++b 9pkA== X-Gm-Message-State: ACgBeo2TbCR1PLROawV+EomnUVdtmyK1DMNJFxLN7S9WM1R1RNVtzVTD b/DiIXBkBg2sPGjTazubNudGQw== X-Received: by 2002:a05:600c:41c3:b0:3b4:9668:655a with SMTP id t3-20020a05600c41c300b003b49668655amr6533300wmh.36.1663245539635; Thu, 15 Sep 2022 05:38:59 -0700 (PDT) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id bg13-20020a05600c3c8d00b003a5f4fccd4asm3112559wmb.35.2022.09.15.05.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:38:58 -0700 (PDT) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, bgoswami@quicinc.com, perex@perex.cz, tiwai@suse.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH 8/9] ASoC: qdsp6: audioreach: add support for MFC Module Date: Thu, 15 Sep 2022 13:38:36 +0100 Message-Id: <20220915123837.11591-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> References: <20220915123837.11591-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support to enable and configure Media Format Converter (MFC) Module. Signed-off-by: Srinivas Kandagatla --- sound/soc/qcom/qdsp6/audioreach.c | 53 ++++++++++++++++++++++++++++++- sound/soc/qcom/qdsp6/audioreach.h | 1 + 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/sound/soc/qcom/qdsp6/audioreach.c b/sound/soc/qcom/qdsp6/audioreach.c index 168bc3020b74..05b58239cab6 100644 --- a/sound/soc/qcom/qdsp6/audioreach.c +++ b/sound/soc/qcom/qdsp6/audioreach.c @@ -159,6 +159,8 @@ struct apm_module_hw_ep_mf_cfg { #define APM_HW_EP_CFG_PSIZE ALIGN(sizeof(struct apm_module_hw_ep_mf_cfg), 8) +#define APM_MFC_CFG_PSIZE(p, n) ALIGN(struct_size(p, channel_mapping, n), 4) + struct apm_module_frame_size_factor_cfg { struct apm_module_param_data param_data; uint32_t frame_size_factor; @@ -727,6 +729,53 @@ static int audioreach_sal_set_media_format(struct q6apm_graph *graph, return rc; } +static int audioreach_mfc_set_media_format(struct q6apm_graph *graph, + struct audioreach_module *module, + struct audioreach_module_config *cfg) +{ + struct apm_module_param_data *param_data; + struct param_id_mfc_media_format *media_format; + uint32_t num_channels = cfg->num_channels; + int payload_size; + struct gpr_pkt *pkt; + int rc; + void *p; + + payload_size = APM_MFC_CFG_PSIZE(media_format, num_channels) + + APM_MODULE_PARAM_DATA_SIZE; + + 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; + + param_data = p; + param_data->module_instance_id = module->instance_id; + param_data->error_code = 0; + param_data->param_id = PARAM_ID_MFC_OUTPUT_MEDIA_FORMAT; + param_data->param_size = APM_MFC_CFG_PSIZE(media_format, num_channels); + p = p + APM_MODULE_PARAM_DATA_SIZE; + media_format = p; + + media_format->sample_rate = cfg->sample_rate; + media_format->bit_width = cfg->bit_width; + media_format->num_channels = cfg->num_channels; + + if (num_channels == 1) { + media_format->channel_mapping[0] = PCM_CHANNEL_L; + } else if (num_channels == 2) { + media_format->channel_mapping[0] = PCM_CHANNEL_L; + media_format->channel_mapping[1] = PCM_CHANNEL_R; + } + + rc = q6apm_send_cmd_sync(graph->apm, pkt, 0); + + kfree(pkt); + + return rc; +} + static int audioreach_i2s_set_media_format(struct q6apm_graph *graph, struct audioreach_module *module, struct audioreach_module_config *cfg) @@ -1051,7 +1100,9 @@ int audioreach_set_media_format(struct q6apm_graph *graph, struct audioreach_mod audioreach_sal_set_media_format(graph, module, cfg); audioreach_sal_limiter_enable(graph, module, true); break; - + case MODULE_ID_MFC: + rc = audioreach_mfc_set_media_format(graph, module, cfg); + break; default: rc = 0; } diff --git a/sound/soc/qcom/qdsp6/audioreach.h b/sound/soc/qcom/qdsp6/audioreach.h index f2b51d8fc718..707dfbdbc156 100644 --- a/sound/soc/qcom/qdsp6/audioreach.h +++ b/sound/soc/qcom/qdsp6/audioreach.h @@ -16,6 +16,7 @@ struct q6apm_graph; #define MODULE_ID_PCM_ENC 0x07001004 #define MODULE_ID_PCM_DEC 0x07001005 #define MODULE_ID_SAL 0x07001010 +#define MODULE_ID_MFC 0x07001015 #define MODULE_ID_CODEC_DMA_SINK 0x07001023 #define MODULE_ID_CODEC_DMA_SOURCE 0x07001024 #define MODULE_ID_I2S_SINK 0x0700100A -- 2.21.0