From patchwork Tue Jul 12 14:15:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12915028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCAF0C433EF for ; Tue, 12 Jul 2022 14:17:12 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 55F6F42; Tue, 12 Jul 2022 16:16:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 55F6F42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1657635430; bh=QdHcpzyoNuLnIYeF/Kx+Fi+xYpM6uMQAwoGyOHmKp+g=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TEtaUEE8YkkAntS9iisAdvQqw6fX+SaJfXKHfifqFSvyKNU5yeUOlfly9nZv82VSJ ST8UW+JERZC478enKL/Iw8lkEUNJbXQr79pg+KeofSHxTupeeWfQEzpU0X6tSxrXul JI0bO7P+25TB8/qHKS1EfSHkOlvOl4Tnq/FtrYzY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B56C8F800BD; Tue, 12 Jul 2022 16:16:19 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C2E69F804FF; Tue, 12 Jul 2022 16:16:17 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2055.outbound.protection.outlook.com [40.107.20.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A888FF8012B for ; Tue, 12 Jul 2022 16:16:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A888FF8012B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="joNb5Q/Y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IjwM5HnQm3n2Gb8YF3EEZ05vLl64BFCvrMXEcnNlmsYwRdEHEAdwTcez1Ykg0yNzF77yBsWFTlihb3wwvoc6TlyWcOJwMrLUTGSrwomxQbdknTCnC1Cdy+Wx63Hcxe+tUlTN3aoE5do3FsLbLVGqMytHIjCBuIOsg0n/KDouItuQYSTs/NdWtzYu9R4aXkkoZETaQBQW9sZNL64IDuz+AEaS0M7NNMxHCIiGVvMxeDEfnE5QeeTXQsM6lbir/Iikn3b0BMH///SEjXIsxT+MnqQoPDgMi/6hkoGBwnxrWlqX0cOxVHX5CmUKZ84mQXKalQaEUQORa0ltL7vmlUynzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Jbbl/cv+q2cw9BCYTXHn0REGjMf8Qz2rYqtLgmOKznA=; b=nhFcd2zkfFfBdu+NxEHlHHpziEVfFFzG6zvwk8AP/NFRIwYhmxRmD2cwoFh6jcNNUc84kCLPHMHtiUVaT33YfzpNDAPtCfVGr5gW4NpfxMpEoOdIl/8evc2bxX8hpJ0q45AbpMfxEfQii6rSFvMZqIImECQHip2ak5CnQzJ5lnKs5cXR2uH4ccj1hmPSmJ0o9ajT49H6inG+OrLJZ9+qjFOML4hqZVGy+xk0T0S9mguiNH0OPPHoTiWYm7SlxeBo22AzgoF100IZiiyLe/IuYGO5nAT81xPzHYrzFd9bBHWfZbxQSNx6DA3SzgLaW2Y1IGZ0CfcxbcD/y8dxBHV8Iw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Jbbl/cv+q2cw9BCYTXHn0REGjMf8Qz2rYqtLgmOKznA=; b=joNb5Q/YplZSvmxCRCFnKwmWcjgm4y+jzDwIgvet3Y8m7iZuyyXwFdWKyWBzem4j7OOYOqeIpXj8+Wwl8PMHOj9/JFH7zrP0EYic5e5u6+7kPwzZylSJwvOazfzSAZT1dOYprVnolN5Pp6i9m4NrWaAdfnM4zQvl7boIF9tv4iA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by PAXPR04MB8559.eurprd04.prod.outlook.com (2603:10a6:102:216::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5417.26; Tue, 12 Jul 2022 14:16:08 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::15ba:4274:2df4:8928]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::15ba:4274:2df4:8928%5]) with mapi id 15.20.5417.026; Tue, 12 Jul 2022 14:16:08 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 2/4] ASoC: SOF: Copy compress parameters into extended data Date: Tue, 12 Jul 2022 17:15:29 +0300 Message-Id: <20220712141531.14599-3-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220712141531.14599-1-daniel.baluta@oss.nxp.com> References: <20220712141531.14599-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM3PR07CA0141.eurprd07.prod.outlook.com (2603:10a6:207:8::27) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 177ee0df-89c5-4ec1-32cf-08da641110c2 X-MS-TrafficTypeDiagnostic: PAXPR04MB8559:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NJvVAzbVHGKdy6avCGqUfMj/iYgKM9pyMEM+XC7puC2EbSm0p6SwrfpV6TZPQ4IJgMmqT6xcogPyaDGJHHmwzZxAWzayGCEFysnRVlSLDexq12AQFY8BVmx+VdOr992zYDh6Lri6gR0EZ9dNwh64hOptrELj+Dp6x41FityGd65ig/lQfXRd/EWEa28z6oJ5yQmCAI0DfJhRj75kKtOCuh8ygcU1jCm9RAWqRM2ArthNxYkXQFRKcZ2hb3NEjlGqmCqo9kdCP4TMCiTwvE0TgGk2zvLBrCMYFL4/w6924o1dDVhaEbiYo38KaZd8h+wzFHfVFW1zAlSKKFIAwhalxWG/Nj0kGq+XCg54qGTQkHrVDKupIc+iMqW0/mkWeD6wEiFkIYTfqrtN7z0PW6kKb1TuMkbdzuTTr5EWSw3lSfOtnkIkSscgo8z23/kfVZIqf6jrm9V4UAZUwslHQjfQzh/sglIEU0r8Q8ijDl4Vmo2eTrQKB+trX4MnKDBx3LoJSTI68B/l0hiWEf9Yyxq2gA1taJME0dBevXlf+bnEmMmrBs6R2lhk0xSo47z+dPsU13uADplWAMFuEZz3u+fH+Gb+A8+AGQJvO6N26i2RkFyQWt6lv5FQnu0WeEj2TQ5eCEEHwC0aHUJzvmcfAOxVqdE00bNiHKEobwKDJtpgowqixnqD2ZylGXBfq4QzuIe8ff3+xfJypomBXqa3iDdoYm7aPnpyJcg8AcAcRWuztTPPooP/5KN7L5fBwlabl92H8aDsGC9Afqvuf42fC+Umpbw3IjnzydjBJlSt3OF7ZK1Pfxxc93iykmDXeEZT1QFF X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(366004)(136003)(396003)(39860400002)(346002)(376002)(478600001)(8676002)(66946007)(66476007)(4326008)(2616005)(66556008)(83380400001)(52116002)(86362001)(2906002)(6666004)(6486002)(186003)(44832011)(6506007)(26005)(5660300002)(7416002)(316002)(41300700001)(8936002)(1076003)(38100700002)(38350700002)(66574015)(6512007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?KI0PyeUGKImeKkOrmk/EGs5qqGkA?= =?utf-8?q?KwQrQzj8URBTYRmqlpwnnysIHNpDSvfeRQ6qv35jjQO8FHbPock1ata0EDzTcx/Yx?= =?utf-8?q?KC4OnrvoIaugjFOtrZGLJo6RzOlu8azEmKY/gccewqw8FKkmjfHajRJAQUezjLy2/?= =?utf-8?q?PTVIpIXcfmKmyFSG5bsQbyhJFOaqQEgJB78g35q5DOEVWC4KmDdP8Zk7mbIuMz8WD?= =?utf-8?q?tiMcdaU4KCXAn9+QYjFP6WxrrAVZfLAlhGNf0BiIqlwKB7zB1EjUClTPQqAZvCsmw?= =?utf-8?q?WjzX+Cg4cwFA+d4FeK8U8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u7wxreWZYijp9tByYd4ayvLvmxFF+1lPTSNmNkVp3X?= =?utf-8?q?A0fdnTXbAc5oS7jNWDXZje9ZId0JnxWE2SI06cQkpjtdAoce6M059casoMY5F/pfw?= =?utf-8?q?gSj7PGBZhkeMCnNUeN34xFYmCkCQNN/l7Uet92lKragKgHgne15VHqkOfveINOrkp?= =?utf-8?q?exdtuc2EDnj2f0asYTIkYcco225IMmu2UTWk8I0H3IZpd+sH957O/WKGwc+tsVTj3?= =?utf-8?q?glq3gGDTXkV6Y4ij/ZvFDMRmLDoRk8AzR+ADHno2ES/vZlHOU4iRbV8QuzNTqcis/?= =?utf-8?q?OT6tlxIkSyj9GzJOTqfQbdiNHImZtNJsun95qaRPbmRcOfy1f1tjIVyyiKWcEWgWO?= =?utf-8?q?vRK0hj/n88QY?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 177ee0df-89c5-4ec1-32cf-08da641110c2 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2022 14:16:08.6449 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5s8DEo80eKNFce6qZN04EvzkLCfpps0r0a/125MTrKwWSWA9BvOJRPDCF/fLgPbzSEKHA7+doiyjTdk7SUW6SQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8559 Cc: Pierre-Louis Bossart , kai.vehmanen@linux.intel.com, yung-chuan.liao@linux.intel.com, daniel.baluta@nxp.com, ranjani.sridharan@linux.intel.com, lgirdwood@gmail.com, linux-imx@nxp.com, yc.hung@mediatek.com, peter.ujfalusi@linux.intel.com, linux-kernel@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Daniel Baluta Allocate memory at the end of sof_ipc_stream_params to store snd_compr_params in order to be sent them to SOF firmware. This will help firmware correctly configure codecs parameters. Notice, that we use 2 bytes from the reserved pool in order to store the extended data length. This is compatible with older FWs where there was no extended data. Signed-off-by: Daniel Baluta Reviewed-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Péter Ujfalusi --- include/sound/sof/stream.h | 6 ++++-- sound/soc/sof/compress.c | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/sound/sof/stream.h b/include/sound/sof/stream.h index 1db3bbc3e65d..9377113f13e4 100644 --- a/include/sound/sof/stream.h +++ b/include/sound/sof/stream.h @@ -86,9 +86,11 @@ struct sof_ipc_stream_params { uint32_t host_period_bytes; uint16_t no_stream_position; /**< 1 means don't send stream position */ uint8_t cont_update_posn; /**< 1 means continuous update stream position */ - - uint8_t reserved[5]; + uint8_t reserved0; + int16_t ext_data_length; /**< 0, means no extended data */ + uint8_t reserved[2]; uint16_t chmap[SOF_IPC_MAX_CHANNELS]; /**< channel map - SOF_CHMAP_ */ + uint8_t ext_data[]; /**< extended data */ } __packed; /* PCM params info - SOF_IPC_STREAM_PCM_PARAMS */ diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c index 45c2ff61ee4d..1204dce29ef9 100644 --- a/sound/soc/sof/compress.c +++ b/sound/soc/sof/compress.c @@ -170,6 +170,7 @@ static int sof_compr_set_params(struct snd_soc_component *component, struct snd_compr_tstamp *tstamp; struct sof_ipc_pcm_params *pcm; struct snd_sof_pcm *spcm; + size_t ext_data_size; int ret; tstamp = crtd->private_data; @@ -179,7 +180,12 @@ static int sof_compr_set_params(struct snd_soc_component *component, if (!spcm) return -EINVAL; - pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); + ext_data_size = sizeof(params->codec); + + if (sizeof(*pcm) + ext_data_size > sdev->ipc->max_payload_size) + return -EINVAL; + + pcm = kzalloc(sizeof(*pcm) + ext_data_size, GFP_KERNEL); if (!pcm) return -ENOMEM; @@ -194,11 +200,11 @@ static int sof_compr_set_params(struct snd_soc_component *component, goto out; pcm->params.buffer.pages = PFN_UP(crtd->dma_bytes); - pcm->hdr.size = sizeof(*pcm); + pcm->hdr.size = sizeof(*pcm) + ext_data_size; pcm->hdr.cmd = SOF_IPC_GLB_STREAM_MSG | SOF_IPC_STREAM_PCM_PARAMS; pcm->comp_id = spcm->stream[cstream->direction].comp_id; - pcm->params.hdr.size = sizeof(pcm->params); + pcm->params.hdr.size = sizeof(pcm->params) + ext_data_size; pcm->params.buffer.phy_addr = spcm->stream[cstream->direction].page_table.addr; pcm->params.buffer.size = crtd->dma_bytes; pcm->params.direction = cstream->direction; @@ -209,8 +215,11 @@ static int sof_compr_set_params(struct snd_soc_component *component, pcm->params.sample_container_bytes = snd_pcm_format_physical_width(SNDRV_PCM_FORMAT_S32) >> 3; pcm->params.host_period_bytes = params->buffer.fragment_size; + pcm->params.ext_data_length = ext_data_size; + + memcpy((u8 *)pcm->params.ext_data, ¶ms->codec, ext_data_size); - ret = sof_ipc_tx_message(sdev->ipc, pcm, sizeof(*pcm), + ret = sof_ipc_tx_message(sdev->ipc, pcm, sizeof(*pcm) + ext_data_size, &ipc_params_reply, sizeof(ipc_params_reply)); if (ret < 0) { dev_err(component->dev, "error ipc failed\n");