From patchwork Wed Aug 17 08:05:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12945619 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 121B7C25B08 for ; Wed, 17 Aug 2022 08:07:46 +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 54D661640; Wed, 17 Aug 2022 10:06:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 54D661640 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1660723664; bh=f01cP3fiJitoFakWY/ckdJ4PIU0M2hy6N8Hkr6E1UVo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Bmxrvm0zQj6R7BzRJbTSAyp6UPxN3FOwjIuHEXOJlDGiPOOixKlQy5pBNu3GjbDbI GlTEMHcF2WAAAMH8rNs56RrgpxzjV5Cz55j9efCGYGCFTadTT+AHPQa28t1FOb95V2 a2XdGXnXnS9ymyTsOy3fqtvUS/HAejyGUcAXsOUI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 349ADF800DA; Wed, 17 Aug 2022 10:06:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8D27EF80549; Wed, 17 Aug 2022 10:06:05 +0200 (CEST) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60088.outbound.protection.outlook.com [40.107.6.88]) (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 7FD85F802D2 for ; Wed, 17 Aug 2022 10:05:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7FD85F802D2 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="PtnVrJWl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LSu+smIPt4fOlab3FBh83cVckRX8KyJbsNwOqgUGeeEGg1oTgLzYsqBktKRl3bTPBKE9e+z7ES4Oh+pbicbP6Vig11GIRnCIgh2qkq2Bv4leaRRXxO84XezH9525KFFgS8EiwCWMhyKRVE1VwdxdPkVrxRiG5qa4azdfh1EcMK+Z9HwPDl8fQYTD+7APt62Lt8cH/oOW3j07hBOVm/knQKrOFuPaHPH01w2eYYPBV4RTZJ39g+SZLrfSjUJhoiFn1JMhrEeqO9mcTGj4qKdqOFSskqOE91/DiVJww17hWcgIxnUrdJvsHBBNtbQao2nnkXBdOFlRhBIkABSkaPZ1hg== 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=kWWVJMpPl/MqDcxHnpDFV3ubvAG0DGhWmip0gI/eHxs=; b=EOsCQhHPBLHnIsoDTxZbb0yV2ompsX0B2wX0iHX2JzmXYLIyHECqbu3Isvji+e0HJlLbO2m+hpJm29RMDjB/GGFhZ+2RRou7teXPn06V9jPIeATSNoRd0jOAvpr88T4fKGBGAURWQaBitGjXR0sd98YLnBSGN67lMOnaGdZtq3BMW6tfn39Te11jOBzpY3ZIo+T0f4DCCBPEYIqt5eH8CwoVJM+4vdUa38o9QMCT88bPm1EOpgkX2IOrN21uJLxwSw7AGUw9iDCS/TqdQJCi671FEiAxFAfS3EMVVXvywQ+jJS4CVLDvOIJ4ZdYh8jT3cb3pPR/0t2eFCpUD4E1eUQ== 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=kWWVJMpPl/MqDcxHnpDFV3ubvAG0DGhWmip0gI/eHxs=; b=PtnVrJWle60FbbI+OOHN3CbmRIkiAYYOoTbjum8I1hWzgIMw1dgeo4pj/ZV9+wLi3F+d7Hq0CEwLe0qrD/p0QPa2TfT8xa6zYkczF3+UTwVof4iqcsdA02aDP8dExjE+ulseoxJlGf7oVzrWQ2KE/gArGzxVaG/12r9Qjn9BLxM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by AM9PR04MB7617.eurprd04.prod.outlook.com (2603:10a6:20b:286::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Wed, 17 Aug 2022 08:05:55 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::68e3:e10a:8232:10e5]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::68e3:e10a:8232:10e5%5]) with mapi id 15.20.5525.019; Wed, 17 Aug 2022 08:05:55 +0000 From: Daniel Baluta To: broonie@kernel.org, alsa-devel@alsa-project.org Subject: [PATCH 2/4] ASoC: SOF: compress: Introduce sof_compr_stream Date: Wed, 17 Aug 2022 11:05:27 +0300 Message-Id: <20220817080529.10864-3-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220817080529.10864-1-daniel.baluta@oss.nxp.com> References: <20220817080529.10864-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: FR0P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:96::18) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4946b95f-c1d6-4209-4770-08da80274f72 X-MS-TrafficTypeDiagnostic: AM9PR04MB7617: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: eRqA4ruhUBKYDghQL/Hxq8fUn2m3atDYtiARPYnEL2xR20mdj6/u+B1WT9cq0V5yDX+lFIbjTZrdoS4TQLQwRE4x3WhYbHpnJB/NlEuJx+jdayMXN+mMU9rwnlBOBlX7Wn5sDtDNcQc3g0VaNQ42t9ygmAiUnirBHCwhzpKlQI/vOEGhxWmYG2/OR/pTvAleSzvVHz4jD8a3OaqUd5K0xM3Vsz93mFzY9NXgNFZwyMscGB0KMbW/PVbu/zwNNwjuG8u/qIY0uYvNMUpKYrwX+4J/AZ+F2yWAYmnIImxZyu6g65r7tI1GintKVfDCpJASSd036iaw3bYEVCdxgoW6YW82Lb8kOo7PNQhOVr+U0BovVfcDstMt/Mcy7HqpkTbAWqS5ekRsxwg4UxoJyUlh30vsfDb9RLt91k8Nh/oC6s/ks52yf02jMl1avyI817n+su6yeJbSPHR/UCLi3t4NRLGE7jg3B45MK1ex7OM6d/urutdCnjNiMATrSUvxPnaUlfaEUOZE4Lne1Vw6B8x+zlcJPcvlnzbWdbNjsFC2ATTVP97cK9n83RYHW0Kvv8emChzGb+yHW8RWe19MwQOP+NkUf4MCmE4duAIf/xe5gtSFjJWD8nomyskk3A3CEm3ty2+ZxdhqvXiLswb0O8QuTwXUkcahRvW4ZIPSwUGyUf0wazvSVLhNXg4IW703E1xBWGEZSQd8cw03b6Vsoy5iYL2LAUW1YxRgrPAPqNo2CoDWw0X6zImekr5Y19TVDxmWkloO/kNWbb49Lgc/mIJhhY7WPx4EIQYFEqpwP4OcRgBxfTRCG7bnPImOBBw+HBDW X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39860400002)(136003)(346002)(396003)(376002)(366004)(8676002)(316002)(4326008)(66476007)(54906003)(66556008)(66946007)(2906002)(44832011)(7416002)(8936002)(38100700002)(5660300002)(38350700002)(86362001)(186003)(41300700001)(6486002)(6506007)(52116002)(6666004)(26005)(6512007)(1076003)(83380400001)(478600001)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j4blRDoqvfSHaRtRVO3EGCMm/vZVPv4+d1IUHps2Wb6AGwtDJzHXDhWiKKuwLuoq32cdu5vz27koG9KHjXMNSvnbeCPCGL62lGE4cs9jkvqRuzTCaY03SJRyn+XW0zmKN8Gy0Wfn5nbCxPC2TEbRvBgqgPShURgKvxyyPQc3kFftaiMleaz++jEmujMKJCqn+25zY2x6x0pyL6Xekt6v6WgM9yObpu+TrqFsC0jWW78fIwzNju8ylIgIe+vIOz2+aWQBA2oz1tqPmq+qb/PJ96iYQSJc6CbwqJBzl60G+0KAvvcem94ogotruxhdiINyBPDw8Dfn/+MQ21Lm2NmjA4dJ/k2esIGwAkrHJ3eekwker6JIDaJMZJ9anV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Wh8RMfTRCzAUWBIXLoocnNJxBb9lfqIXOPjA7MoscBZEyeww0FEoTMIxjiOQapSZHfK57hsiv1Kkci1ae4F/Du443koEpFxpOCKd+1lAQ2/dXzMuKx+4947AnltGX1MSje3utev X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4946b95f-c1d6-4209-4770-08da80274f72 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2022 08:05:55.6003 (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: sNzvAl+Ho6tkXDlTYvL4MJZlHauXsodwJ3N2zrOrf1dj5xcmzkHYZwhUXe6BuLK80alE2DoFkgZhNfIpvQJnKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7617 Cc: Daniel Baluta , pierre-louis.bossart@linux.intel.com, daniel.baluta@gmail.com, kai.vehmanen@linux.intel.com, peter.ujfalusi@linux.intel.com, lgirdwood@gmail.com, laurentiu.mihalcea@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Paul Olaru , yung-chuan.liao@linux.intel.com 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 This will keep SOF compress stream private data. So far we used snd_compr_tstamp to hold the private data but this is no longer enough as we need to hold other info like number of channels or sample bytes. Reviewed-by: Paul Olaru Reviewed-by: Pierre-Louis Bossart Signed-off-by: Daniel Baluta --- sound/soc/sof/compress.c | 40 ++++++++++++++++++++-------------------- sound/soc/sof/sof-priv.h | 5 +++++ 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c index 760d6a4a5253..e990fa093bb5 100644 --- a/sound/soc/sof/compress.c +++ b/sound/soc/sof/compress.c @@ -11,20 +11,20 @@ #include "sof-priv.h" #include "sof-utils.h" -static void sof_set_transferred_bytes(struct snd_compr_tstamp *tstamp, +static void sof_set_transferred_bytes(struct sof_compr_stream *sstream, u64 host_pos, u64 buffer_size) { u64 prev_pos; unsigned int copied; - div64_u64_rem(tstamp->copied_total, buffer_size, &prev_pos); + div64_u64_rem(sstream->copied_total, buffer_size, &prev_pos); if (host_pos < prev_pos) copied = (buffer_size - prev_pos) + host_pos; else copied = host_pos - prev_pos; - tstamp->copied_total += copied; + sstream->copied_total += copied; } static void snd_sof_compr_fragment_elapsed_work(struct work_struct *work) @@ -49,7 +49,7 @@ void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream) struct snd_soc_pcm_runtime *rtd; struct snd_compr_runtime *crtd; struct snd_soc_component *component; - struct snd_compr_tstamp *tstamp; + struct sof_compr_stream *sstream; struct snd_sof_pcm *spcm; if (!cstream) @@ -57,7 +57,7 @@ void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream) rtd = cstream->private_data; crtd = cstream->runtime; - tstamp = crtd->private_data; + sstream = crtd->private_data; component = snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME); spcm = snd_sof_find_spcm_dai(component, rtd); @@ -67,7 +67,7 @@ void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream) return; } - sof_set_transferred_bytes(tstamp, spcm->stream[cstream->direction].posn.host_posn, + sof_set_transferred_bytes(sstream, spcm->stream[cstream->direction].posn.host_posn, crtd->buffer_size); /* use the same workqueue-based solution as for PCM, cf. snd_sof_pcm_elapsed */ @@ -96,24 +96,24 @@ static int sof_compr_open(struct snd_soc_component *component, { struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct snd_compr_runtime *crtd = cstream->runtime; - struct snd_compr_tstamp *tstamp; + struct sof_compr_stream *sstream; struct snd_sof_pcm *spcm; int dir; - tstamp = kzalloc(sizeof(*tstamp), GFP_KERNEL); - if (!tstamp) + sstream = kzalloc(sizeof(*sstream), GFP_KERNEL); + if (!sstream) return -ENOMEM; spcm = snd_sof_find_spcm_dai(component, rtd); if (!spcm) { - kfree(tstamp); + kfree(sstream); return -EINVAL; } dir = cstream->direction; if (spcm->stream[dir].cstream) { - kfree(tstamp); + kfree(sstream); return -EBUSY; } @@ -122,7 +122,7 @@ static int sof_compr_open(struct snd_soc_component *component, spcm->stream[dir].posn.dai_posn = 0; spcm->prepared[dir] = false; - crtd->private_data = tstamp; + crtd->private_data = sstream; return 0; } @@ -131,7 +131,7 @@ static int sof_compr_free(struct snd_soc_component *component, struct snd_compr_stream *cstream) { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); - struct snd_compr_tstamp *tstamp = cstream->runtime->private_data; + struct sof_compr_stream *sstream = cstream->runtime->private_data; struct snd_soc_pcm_runtime *rtd = cstream->private_data; struct sof_ipc_stream stream; struct sof_ipc_reply reply; @@ -155,7 +155,7 @@ static int sof_compr_free(struct snd_soc_component *component, cancel_work_sync(&spcm->stream[cstream->direction].period_elapsed_work); spcm->stream[cstream->direction].cstream = NULL; - kfree(tstamp); + kfree(sstream); return ret; } @@ -169,7 +169,7 @@ static int sof_compr_set_params(struct snd_soc_component *component, struct sof_ipc_pcm_params_reply ipc_params_reply; struct sof_ipc_fw_ready *ready = &sdev->fw_ready; struct sof_ipc_fw_version *v = &ready->version; - struct snd_compr_tstamp *tstamp; + struct sof_compr_stream *sstream; struct sof_ipc_pcm_params *pcm; struct snd_sof_pcm *spcm; size_t ext_data_size; @@ -184,7 +184,7 @@ static int sof_compr_set_params(struct snd_soc_component *component, return -EINVAL; } - tstamp = crtd->private_data; + sstream = crtd->private_data; spcm = snd_sof_find_spcm_dai(component, rtd); @@ -237,7 +237,7 @@ static int sof_compr_set_params(struct snd_soc_component *component, goto out; } - tstamp->sampling_rate = params->codec.sample_rate; + sstream->sampling_rate = params->codec.sample_rate; spcm->prepared[cstream->direction] = true; @@ -325,10 +325,10 @@ static int sof_compr_pointer(struct snd_soc_component *component, struct snd_compr_stream *cstream, struct snd_compr_tstamp *tstamp) { - struct snd_compr_tstamp *pstamp = cstream->runtime->private_data; + struct sof_compr_stream *sstream = cstream->runtime->private_data; - tstamp->sampling_rate = pstamp->sampling_rate; - tstamp->copied_total = pstamp->copied_total; + tstamp->sampling_rate = sstream->sampling_rate; + tstamp->copied_total = sstream->copied_total; return 0; } diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 823583086279..42f112030fb8 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -105,6 +105,11 @@ enum sof_debugfs_access_type { SOF_DEBUGFS_ACCESS_D0_ONLY, }; +struct sof_compr_stream { + u64 copied_total; + u32 sampling_rate; +}; + struct snd_sof_dev; struct snd_sof_ipc_msg; struct snd_sof_ipc;