From patchwork Wed Jan 5 22:51:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 530183 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 949CCC433F5 for ; Wed, 5 Jan 2022 22:53:58 +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 E04931A75; Wed, 5 Jan 2022 23:53:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E04931A75 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1641423237; bh=Kpk9qhTYS2kOpi7at+9nYNz6Y6sM/dbrkCZfSTkKep8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=V2c9xPbWZEvKR0xwY43nLbKWdC6kGSQ4J/APSfvPvgz+FTdpakVCw9BiR1qJxf8r/ Qa0jrAS9gcDpAPtGNDm7YOJ+9efOnkz9f/gzBr2cwhNw37LmPR8yFZS24CUnt20SUX SZu6NQNpEwZNGL1FSdzR18OphbtFugciAerkiQHU= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0336BF8007E; Wed, 5 Jan 2022 23:52:30 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1D9F7F804FE; Wed, 5 Jan 2022 23:52:29 +0100 (CET) Received: from mx0c-0054df01.pphosted.com (mx0c-0054df01.pphosted.com [67.231.159.91]) (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 DF8E1F80167 for ; Wed, 5 Jan 2022 23:52:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DF8E1F80167 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=calian.com header.i=@calian.com header.b="WEglp9Ld" Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 205D3T0L019799; Wed, 5 Jan 2022 17:52:20 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2059.outbound.protection.outlook.com [104.47.61.59]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dc72w9gck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jan 2022 17:52:20 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nJBvR9/Y+yXz1FnDFC28KcFh2muk9hdUjOElqfR4xR9QFax+/sja9P+1/HeWcsrZ3P+X8ZLrikeX8rtximQlsoqkv9ErHv2lz2/13LHOJ6ThteiwQcY9lfZgRK05VET/iNDuM6i7VStMsAtY96vIq2Ma6hiLGSuodFwDdpgFM6+CzrXRWngDOzL4QBVmsnPkigu0db9N02c0xa8EHm6Sza/Wu+Mh1l4Zp0OAEswAxw3isYwi8zL6lfpQl8x1mjhe3XALIugo6Wbf31h7E+wZ3LWjYXyfarNeEor09YD2bcM9h4GgBvTuUa5WF74PTcNJhev7couXb9uA9IzdweNeyw== 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=hU7zWpoZzdvDdKP/q77u61lEELmCpJXLbpXqzz7uFwc=; b=F8opmxcDAxxJ2Chfhi0cT+jkU32qXZlesBNJmrpj/vgBdf8/nro5zZD1uhAl/bO2jfalOgGSsy+tqd1+FPN0Mso0rPDxYuUl0nEfME5jtWtp0SZoDIWx2E21Pk1IkmjCACDuvNxjeQZ2g5miq0H+S2821mP5kuzZ4QwWnQwp12gIlahmHmMnvLXqZW0G4vqE8X7YxvocF1DJTZv+WOEdzmGwwqmi4MFOGFMrYHEI37NIkvcR8O+eBBbZfQoItMbtiQkxWSR/hpJcgXgkgk4tfV2d5AiJ0fwxmAG36vG6JARfNuQL9/it5Wcq+GpgvScYkB+fDBT2KKSkalSQcQW8ZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hU7zWpoZzdvDdKP/q77u61lEELmCpJXLbpXqzz7uFwc=; b=WEglp9LdsoF/bZa/u6IfC4Xq7IsSAAXi0D6pVn5KxLuFRYV1coiFexAxB/Zy+ydXTpsCohqpHk1rgMa/GvAfZEPRYRsHDeECoMY8nuwjjIKBdk5a9QRrYL7MDd+sPEQlOHvuzeQiYEdd7Md01AcJFC6rL5YRYJR1Srg8JgN0kQw= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YT2PR01MB5120.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:3b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Wed, 5 Jan 2022 22:52:18 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76%5]) with mapi id 15.20.4844.016; Wed, 5 Jan 2022 22:52:18 +0000 From: Robert Hancock To: alsa-devel@alsa-project.org Subject: [PATCH 1/5] ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes Date: Wed, 5 Jan 2022 16:51:42 -0600 Message-Id: <20220105225146.3517039-2-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220105225146.3517039-1-robert.hancock@calian.com> References: <20220105225146.3517039-1-robert.hancock@calian.com> X-ClientProxiedBy: CH0PR04CA0059.namprd04.prod.outlook.com (2603:10b6:610:77::34) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42d4374f-f70b-46b7-0a5c-08d9d09e06ba X-MS-TrafficTypeDiagnostic: YT2PR01MB5120:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m48YWI8aLCr5Aszn7vyzUdLrE3HDAqmd/YbfSO+ik/5sibg1aHw54k3LEKEWENAYys1mB6Gft2YBFhMGypXLjEQEn4E3q8BcKaBw2CMh5W6qTiOyhRWtoBP4iEWy7l2SX4NOQOZvIfAKyr0eI5jVQWDmHilQ3yzaKOSzMN0p3i4HTMvcXR4E+T9CYgxqPyVKGPZDImxuvZhhxDYan9McM2vRcoes5YTKQeF1fHTnu63yxeceNS5Mw44MPGjBWYwduUkRxWTgXd3D4ws/DQkLdGUl0se3UX3GjOAeFvz/xeA5rlQaE1waq7JLIODQq9RSLoevvNY0BRwTUpKmln75Wwnx59AESs+ZTGyIASE3qds8EmubS+k2Bc0rZs6QuCNYVJjyS54w+o8ij3VwK8pFOtXoqVjC0ynwhyC8uBj+yWXvhfqZwlaLxMvQyx+QqYLfiEZtXUAVrehYjbq+/FrZooM36YiIuwaNkRZhKHJyyYnegAJcmEUdDwEdO69v8ksSHcqh4wbRKdfhhCg+2zC2QAVDrl/+Zh/CcQ91j2TmpkH8UhxvZPU0Rdn0JOvfAHkpwVFf6y2o7/Bx6gVl3ZcNpfmY+OGxI1ipNCIY0RLmc9ZjVbCnbGX9x9BZER0izvdz27k06+Q//9FjNDiwsXMN/dn0FIjyvOq61CTQD1Vj0azyaITLQeyVlVtTp8QboJBsrkt/1aX2Zns4eoKXydOLEA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(366004)(4326008)(508600001)(6916009)(2616005)(5660300002)(52116002)(1076003)(36756003)(83380400001)(86362001)(66946007)(66556008)(66476007)(6486002)(54906003)(6512007)(44832011)(38100700002)(38350700002)(6506007)(6666004)(186003)(26005)(316002)(8936002)(8676002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TvYJDRT6MyKb89Kh7z0ymTENyHQPy3HOk1DkQg9GVSOp0sX0shquvj9yUylGU49vcU1lb9hfewlM1xBj/O8umu7FaTGhkbUfDQdfFZKp+Qu5jLk+BDjeQZffpLFAlgk+muRbHpxc/6etkIbbkVfwiJJCJ5iT9xPfy+borN4RIKfAIWEmhBfpvJYMk8ljm4sKPh2DjDHjB9pdWvpAmOsdf5HN9p0V5J5CxlBNS4pFNUJR7/5y4qwszBZWcwMMk9cbnyjelBuaRjK7Ms7X3/XsDQbtRXUM4hauJd7/wv55zXwZp8pq/phU8MOEGaG55tw+uXh6sw7upcXZmjcDBZs/GxfijTXyX7nM8xxUbxfvNkyEkgEUqH8DMqu13ibkdj3CSzHWg1tnj6LbqfVvQrBblCsgoYws5SbfHdJ2UZtjYNt7LFrwtAL308MHDTgKwF4ZcN/shfowNJtPE1VZ1duN24/Dxl5auS2x5z4YaJbBV1jOqjPOREh9Qx/wigyex/kPBzEZRf47CuM8pxxb+OukekvYSBwoxQYOwKZK/akQElJAbdXkN9NB0yT4lfpJAtSBK+TsXlB1PCMuzTBxqgymJQ9vV+dV1Zc6ryq0/KmeWiUmVUUy7UCA4D0+CPViD5Y+rFoj6YgBem7fHWM8tg0yUtvCTRKA97TZLem4gpbK5YZRxb9CknOWpiCOMuxPR+TlbK+mqjtl9ZBzO9yGWWvYCen9O/YHebqXmXTTEU/hrJg/cGlh645glY7dh5BiMEitG3UK8AS1wvW51NhdMRjaf78Z4lDHdcypl7C/1wmA1dl6pseC6ga63XuMrYp6dQ7wAySlb6qMRPDasuFhWJ9N1GexLrgazBSSyyj0e5U7fAEq9CL3bMnRA1q5lKtWelxiXDuQsIVYj4X2VJHDc8dJE+VSv0XHHlclFY+CgoemEdv+OqPO1XXnp8Lk+qmh1UIrBPjLQXkZHXcwpiGViVebJaG/CcuBE5xt6GhyFgSem2UnKzq4g3uKyITENz3yI28wtnv/4rBzvSrcCZAmruEm0qnM2Njyu2JVGzzgmv4pBEMgIzSlH9bBEPntvEYC/wdmHcC/Vr46utCIr3ePhY81IkJNdy/zXGroyj9Adk7nW6Ty9O5Tq1VaHcb65UU4jzKvEbxhjhwu52QyoDZo+W0OV/VShB5uafxbbmFltq5Q45jt0PGN2Mnn/dUNX3TWDeDUtnkaD0CEA036AP2Uspr6pVk3LmUIsxpj4SqefX4ZQ3V80j5seS95quMz7QFE1cMlOdk/FrzCynlf8GdGI8Xfgl3a2y+p0QJgehOZ89f1QRKgalPdv98yJDDEN9EFRLHn16vHfvgpGB9c94Ki/2XYW+Kac0DFIHFPkYgCEy/rN/haDI+Yt+inzHNdyJPcE4wKLgwdYtaUVhFomO1dey9aMPagnAYtrOpNL4o7ZG4nnEzuqHmJThglHdJbJy6xm/Iexk9Udlifr/K1ffJpW6rSrM4yrKTZ5OFhq76q2MlW+sIqtLZINCQEJtUGu8glu9sgt+03U8tf4Wz1BxVd57MmIeDBppLc3tp25suonmD2ZF4ynxOYENqYmW33nuQRE18pHKUwUuVqnZRA5Vt16tVLCT0/2ShEgkXhqC9HCAjOsxurhjHY9U2gkcCH5xSg+nsTctE0kJOy1ACHWtTHKuJtMk4E26ZjiQAQDRsVyvkQGIg= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42d4374f-f70b-46b7-0a5c-08d9d09e06ba X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 22:52:18.7620 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4VH5c6t4JwxDXBWcigXswfYOI1WTrW03djSbxXKjoi0j/Cc9sgwLQpKhV+mUGM1gNbzdAsQxdmge+nLA4Er25OoJ1OgZGV44KtZctwUUeqc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT2PR01MB5120 X-Proofpoint-GUID: q1FicpGcwcmv_p-7GxLX32SkOhk5jFb_ X-Proofpoint-ORIG-GUID: q1FicpGcwcmv_p-7GxLX32SkOhk5jFb_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-05_08,2022-01-04_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201050144 Cc: kuninori.morimoto.gx@renesas.com, Devarsh Thakkar , michal.simek@xilinx.com, maruthi.srinivas.bayyavarapu@xilinx.com, tiwai@suse.com, Robert Hancock , broonie@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" This patch is based on one in the Xilinx kernel tree, "ASoc: xlnx: Make buffer bytes multiple of period bytes" by Devarsh Thakkar. The same issue exists in the mainline version of the driver. The original patch description is as follows: "The Xilinx Audio Formatter IP has a constraint on period bytes to be multiple of 64. This leads to driver changing the period size to suitable frames such that period bytes are multiple of 64. Now since period bytes and period size are updated but not the buffer bytes, this may make the buffer bytes unaligned and not multiple of period bytes. When this happens we hear popping noise as while DMA is being done the buffer bytes are not enough to complete DMA access for last period of frame within the application buffer boundary. To avoid this, align buffer bytes too as multiple of 64, and set another constraint to always enforce number of periods as integer. Now since, there is already a rule in alsa core to enforce Buffer size = Number of Periods * Period Size this automatically aligns buffer bytes as multiple of period bytes." Fixes: 6f6c3c36f091 ("ASoC: xlnx: add pcm formatter platform driver") Cc: Devarsh Thakkar Signed-off-by: Robert Hancock --- sound/soc/xilinx/xlnx_formatter_pcm.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c index 91afea9d5de6..db22e25cf3f8 100644 --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c @@ -37,6 +37,7 @@ #define XLNX_AUD_XFER_COUNT 0x28 #define XLNX_AUD_CH_STS_START 0x2C #define XLNX_BYTES_PER_CH 0x44 +#define XLNX_AUD_ALIGN_BYTES 64 #define AUD_STS_IOC_IRQ_MASK BIT(31) #define AUD_STS_CH_STS_MASK BIT(29) @@ -368,12 +369,30 @@ static int xlnx_formatter_pcm_open(struct snd_soc_component *component, snd_soc_set_runtime_hwparams(substream, &xlnx_pcm_hardware); runtime->private_data = stream_data; - /* Resize the period size divisible by 64 */ + /* Resize the period bytes as divisible by 64 */ err = snd_pcm_hw_constraint_step(runtime, 0, - SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64); + SNDRV_PCM_HW_PARAM_PERIOD_BYTES, + XLNX_AUD_ALIGN_BYTES); if (err) { dev_err(component->dev, - "unable to set constraint on period bytes\n"); + "Unable to set constraint on period bytes\n"); + return err; + } + /* Resize the buffer bytes as divisible by 64 */ + err = snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, + XLNX_AUD_ALIGN_BYTES); + if (err) { + dev_err(component->dev, + "Unable to set constraint on buffer bytes\n"); + return err; + } + /* Set periods as integer multiple */ + err = snd_pcm_hw_constraint_integer(runtime, + SNDRV_PCM_HW_PARAM_PERIODS); + if (err < 0) { + dev_err(component->dev, + "Unable to set constraint on periods to be integer\n"); return err; } From patchwork Wed Jan 5 22:51:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 530533 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 96269C433EF for ; Wed, 5 Jan 2022 22:54:11 +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 8ADC41A9C; Wed, 5 Jan 2022 23:53:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8ADC41A9C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1641423249; bh=nNAUAVctljaHr7mr4t+nNOyCjmuxus3RkPmmGM4nVH4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hM4XNOh021EhjGL9wjFSCCr/nrNYqBv7TifS1dR61dPQ5pf4otGmlenZ3qSt8d1Cf HgLIdKHB+JifaCLDccSDsWdJiVrk7VwjBjGm52sM9oXbwnVzeOSkmhgxH7G9V2kJc6 OKGr6MULblwFGVvmg+7LHwUl9HazKtLwJAkEgacA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C05F2F801D8; Wed, 5 Jan 2022 23:52:32 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F2891F8028B; Wed, 5 Jan 2022 23:52:29 +0100 (CET) Received: from mx0c-0054df01.pphosted.com (mx0c-0054df01.pphosted.com [67.231.159.91]) (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 4E4A2F8007E for ; Wed, 5 Jan 2022 23:52:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4E4A2F8007E Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=calian.com header.i=@calian.com header.b="daA0fdSx" Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 205D3T0M019799; Wed, 5 Jan 2022 17:52:21 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2059.outbound.protection.outlook.com [104.47.61.59]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dc72w9gck-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jan 2022 17:52:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d2DoDphhT4Lxem9f7jG5QRgOtFuRHBnfiYFNo4QC5tRSBOlFdiimJC6wWxsl3BT24heGqAcYwIfzPQVTfuDW9h8MGYJce2KCnnOW9p8wXO0ltCGqTCwrLFKMyo7lFn0QfOm1oNR3gqwfPQZxXC95lRCPzrzycuK5QhTRBpNqjXQWZH7hcn01CjfMMCg5RHIpFDrgiWxJDBEZififpCOAL84RDa9NtBS/jLd2bE+8qQdvUm4JoCcNl1X0/sWfOzFm9vk64iNFiLQveM1flBE/PdjcDb0MUrNshsk6Qe8QSqDZKAMPSMSPhUXGLnxiVvYTYr+J8hnOIMxF3nPxhKeWlQ== 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=DSizCVFqIt23/SBCwXNEDvuJVo857JwGQXzywYmfK60=; b=oAH6lPOFyP+VrVFqbznCGvRmCwkjEsadSNrcOvVSVquagDcz9KbZVkYeYBo8gfCeHtqHcQVxZqP0aikX1aKu3NLkOe4gmXQzYOySOS4pDdGmbvEOKmWSmGMr2HpyebI/sA3loKnKJirmd+j7A1l7hpooFtpQ8S4AWj8a+ogIh6ml03OZnMWY5dutxutHbAM5q0OfSNzW/K2PnV1S7gKhV+FQ8iU6qwVuUCKi1JJLyTekAyXO6/jFScUXoqkPrPgb6gHB8C3IVcVK+WZjXbmwvVZyUZJq3suot5ZYuCQpgiUDkJgiuDjmAbrMZT4GxtAFURxPg9f1gzNUC0FkddMmEA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DSizCVFqIt23/SBCwXNEDvuJVo857JwGQXzywYmfK60=; b=daA0fdSxTbjCus68ewljnjtUXYeIAAk3fKJuog9gnALaI56YGqseESgftduQOMT1YrGZ7TGEctc/ihOMqBO4FpNhD4TNknNqgqPz+CST3LIE0OW6bDutvM67TeZ5La9TOpGIf4ahQUJkla5wtggwcbXsee39fbDF2vSEmKHKFIM= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YT2PR01MB5120.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:3b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Wed, 5 Jan 2022 22:52:19 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76%5]) with mapi id 15.20.4844.016; Wed, 5 Jan 2022 22:52:19 +0000 From: Robert Hancock To: alsa-devel@alsa-project.org Subject: [PATCH 2/5] ASoC: xilinx: xlnx_formatter_pcm: Handle sysclk setting Date: Wed, 5 Jan 2022 16:51:43 -0600 Message-Id: <20220105225146.3517039-3-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220105225146.3517039-1-robert.hancock@calian.com> References: <20220105225146.3517039-1-robert.hancock@calian.com> X-ClientProxiedBy: CH0PR04CA0059.namprd04.prod.outlook.com (2603:10b6:610:77::34) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f2c5d6d1-228b-4458-abaf-08d9d09e0765 X-MS-TrafficTypeDiagnostic: YT2PR01MB5120:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L0rUVIgrJB9dohL7Zbu5N99hZMqn4/l7m5lQRb9Vg9F1Mxl5C3ApLCGfs97hwuwZacOWqEnyJweOAdx70zOX5uSLawM31Dz4trJnpBuV88HbZaJH+GUKpTjFNa/lVX6MzqCUiIrvbQDNwIP5Gv+WwvvtubW38JvKq7GwJGGdvKMswGV2o2izG0pKL60pLGSJuWtp4mcMWX+bDrD+cNNpuxuVgpxu2AbBSAg8C5NmHYmGSp3GDcMGGJOuAs61+77WtyB6Xy2Zcupzy/Xs9WV4u1z9ZGkLdxyS3/9qmfi0913G1P/XuqAghkiBwSqJyM3l3r1TrcXkRueAWwaS8yuBpUt7yQ0FoshtySKCwH/tQMc/jg7PUgAm45mlJPEMvPCmV5AmYG3XN4CjPXLOiUQBpKBAq4KnZSagNBUBCHOb3JYr/5bqxKN7j/yQ9HNkAHQmgm397xGLtN3O794FKlysvSpgNGpZfIYSjwPmje4zuknSKeypRDikupo2uYkdqfDc0eu1xGIlyX88rk/8PTPjqv9HN/DGnqA3/CshLydv/jEwerwgMjLaAfXP1OaY6a0tiqbnTYM2x/6UY2PKbN4SYKDUFey5a9M2+dBkGeneOp3dJAQEwcXf4UOnYfwcZQ9w3eRcf/o5UcXnnJFh6y6AIYDs1AvOHk91A+5s8Ugd3pdS1fv4I29ZyHh0ZHbMf7qxQXx/VdZiXfiW+X9EyH2QMQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(4326008)(508600001)(6916009)(2616005)(5660300002)(52116002)(1076003)(36756003)(83380400001)(86362001)(66946007)(66556008)(66476007)(6486002)(6512007)(44832011)(38100700002)(38350700002)(6506007)(6666004)(186003)(26005)(316002)(8936002)(8676002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FrUPx+lbOjsNLveRKFFES8S55u5MfflNpET0iaFKEUfeOp4HHcjKV+yStAdDErjcQWJnVY+y1fuplKCx5YtrEiAcSXBbT3i0wtiH9dtiNpfcQkKo68vTjl+bSjmW/aczfKOJ3AxrnV9y29IU8iVlXg3WiXlyZqOgsCsEVQjoUbPenGIzwiLZiXkpFddLns5LS6Ru6Hl49ZxzOruHad4av5Fq55huUwvckt7oShS0n3PfJY4vd4CVr7KGQxoxDdTJ81P49MWp2V69Ol0OkVRQY+PyuB6vuZMY2qp+u3yvUxfCezD4/TPoEgpCYFr1ZSAVC2dF3h98OioVw3eOQPg+CvKRWwk7OtmSvbdkX9i60lyubhpcPZ7toc3moJwoA2e3cDdBuavR5A+haHVzXIafSvYb+6ZWQpq1ZvMD90a54VDcokwLsqzR9A2td1FQURuIuLb5UJ2OHYatWpdVjmYw+ZhatIsNTs4VziAHeJidXuu6UDk4X6uEgJrj8hTsGpTWs9LEIKHuDtTdY1mWPbBDBZ2jdzTC+Rd9EBuBb652KMfmIWHnGmUpON5U05UjHKF9gDM6aZsj62oA+VR19qNMem7l8afBI+QH6n1i60tdnRcy/6JwxqkzuSR7Q4Y9Z7YQyZyASgZIVsQ/4FWO1Kr4B+pmcbkc0HEGN2mIfPmBp6ZHw9lJpNWGe2XevakkzEsSafFrMp/jLeyT/eWK81j1HS0gtjulYVb6kRovb0owOPPd6YqpJvfUq3tdATPT5yUqO3GOmCcBnKUkqJNxFwr6OdWQf3fBXDXb6k0QDWLctF/LiAmtuSTtP2M5lYI2CdOezV/zTVfjdxBBu8mNFYn2ViucYt7cJsZ44qtBJfwOx0my1M1enHkIx6Y6Q3Bi7c6GwRs4aZleq+VgAkGjyx9zpfffNT+SdMsa9Lqwu+vjYBSQ4ZYEuj/ubHdo0GTgyMJ6DZz/75pWgJswkM5epEV0OGY0X5MosH3u2Jvb8W4wUqtMJou5skTPjJ4VSkBKsJEE+Gs00FlATYBou0OUr1xo55GSrbMHv1KrwhnUk5qxZsBsU2jiIr8ePyTmWnRRhrF1H3067OxeCKYhCR+W9DxUQXqcE24OWtIv3Zh8gVlw0Ih2uVf+ATMRRNbZv8Q3qEUMuClmxTUWSvf3OpJIVhfnqHcyFqvAF9OPolW9AOc32P1ED8Y3Ynu6oHAEFdXpdr3Y6CMwrLsjltT0KCf7hONpInOK2+Qb798xHCGs+OiYfS7uQsT1Pg27hglF96bcxIcr03dozTp+MTdlgYsQPQnWVlsu58gcGVPDvkcr910xVy20BvA74OIGkLdG7TFlHaAcPJlwSeFPxCPX97Qh1VgG6am1bM91xz0N1b1UcKCXd+Qex6kH2pYvQiJtaUOvdPZVyfpx+Q8RP9x/cu1yFbB2Do+TjSfUZDDrHhPjryze0FTT5z5QbHjPAeIZYZrQDPkbKFO/AH5paG1foU4DfIo9QZZp3Pe4Q1j7PMna+GBJzMsVxY0YOZ5ySx5mONy507ToGXTmExlBp9g1jeOxQXYRwWzB/nGFtAAmyOPyK+IGWo3tate+Tz1/sxoOr9FvOVSK6ITqLUM5WXAey+7JeIe9/jFWxBOVioaaEeeu33nDgroXw0R6At5IoN0OGzomJsrbSDR0/9lCUbuuC9q062n5i4YIn2tX4uEDOhksXB2t90I= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2c5d6d1-228b-4458-abaf-08d9d09e0765 X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 22:52:19.8711 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MCAw+D/ReEt3m0IbzTtlQML5lp86gmSVRt55OCfQZZ2Q+8V6uMxwZkPUkg7EoYsqPk44xDcU1SlPXAH/onG2WlsqRIFQcu6vzwdpsSnlSjw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT2PR01MB5120 X-Proofpoint-GUID: CWuujyVMXmTf0DJGFPbPk3_b6OsgT2nd X-Proofpoint-ORIG-GUID: CWuujyVMXmTf0DJGFPbPk3_b6OsgT2nd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-05_08,2022-01-04_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 spamscore=0 mlxlogscore=572 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201050144 Cc: kuninori.morimoto.gx@renesas.com, michal.simek@xilinx.com, maruthi.srinivas.bayyavarapu@xilinx.com, tiwai@suse.com, Robert Hancock , broonie@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" This driver did not set the MM2S Fs Multiplier Register to the proper value for playback streams. This needs to be set to the sample rate to MCLK multiplier, or random stream underflows can occur on the downstream I2S transmitter. Store the sysclk value provided via the set_sysclk callback and use that in conjunction with the sample rate in the hw_params callback to calculate the proper value to set for this register. Fixes: 6f6c3c36f091 ("ASoC: xlnx: add pcm formatter platform driver") Signed-off-by: Robert Hancock --- sound/soc/xilinx/xlnx_formatter_pcm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/sound/soc/xilinx/xlnx_formatter_pcm.c b/sound/soc/xilinx/xlnx_formatter_pcm.c index db22e25cf3f8..d35838cf5302 100644 --- a/sound/soc/xilinx/xlnx_formatter_pcm.c +++ b/sound/soc/xilinx/xlnx_formatter_pcm.c @@ -84,6 +84,7 @@ struct xlnx_pcm_drv_data { struct snd_pcm_substream *play_stream; struct snd_pcm_substream *capture_stream; struct clk *axi_clk; + unsigned int last_sysclk; }; /* @@ -314,6 +315,15 @@ static irqreturn_t xlnx_s2mm_irq_handler(int irq, void *arg) return IRQ_NONE; } +static int xlnx_formatter_set_sysclk(struct snd_soc_component *component, + int clk_id, int source, unsigned int freq, int dir) +{ + struct xlnx_pcm_drv_data *adata = dev_get_drvdata(component->dev); + + adata->last_sysclk = freq; + return 0; +} + static int xlnx_formatter_pcm_open(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -448,11 +458,19 @@ static int xlnx_formatter_pcm_hw_params(struct snd_soc_component *component, u64 size; struct snd_pcm_runtime *runtime = substream->runtime; struct xlnx_pcm_stream_param *stream_data = runtime->private_data; + struct xlnx_pcm_drv_data *adata = dev_get_drvdata(component->dev); active_ch = params_channels(params); if (active_ch > stream_data->ch_limit) return -EINVAL; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && + adata->last_sysclk) { + unsigned int mclk_fs = DIV_ROUND_CLOSEST(adata->last_sysclk, params_rate(params)); + + writel(mclk_fs, stream_data->mmio + XLNX_AUD_FS_MULTIPLIER); + } + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && stream_data->xfer_mode == AES_TO_PCM) { val = readl(stream_data->mmio + XLNX_AUD_STS); @@ -550,6 +568,7 @@ static int xlnx_formatter_pcm_new(struct snd_soc_component *component, static const struct snd_soc_component_driver xlnx_asoc_component = { .name = DRV_NAME, + .set_sysclk = xlnx_formatter_set_sysclk, .open = xlnx_formatter_pcm_open, .close = xlnx_formatter_pcm_close, .hw_params = xlnx_formatter_pcm_hw_params, From patchwork Wed Jan 5 22:51:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 530182 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 620DCC433F5 for ; Wed, 5 Jan 2022 22:54:27 +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 AAAB519FF; Wed, 5 Jan 2022 23:53:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AAAB519FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1641423265; bh=fgvR67pJL1Jnk7JvkJI7hOw/vstTi44avJCH99nZTIc=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PQOAkZh5fpPW1XYyZ6nmbWRW69a6K9SNGDmkXkaYHyvgrm/Zy9L/8nKFZdz/6eZ/z xk1ducP5cqbxjHl2evwVetsqV2spl5nCv7zdaBKGCcYQcJWk67rH9IM4EYDKCFnR9r tP0I2iIXmBgFG0bzktwZ85p9RhJRVn5hQQynI10A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 3D009F80511; Wed, 5 Jan 2022 23:52:33 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D1EB2F80507; Wed, 5 Jan 2022 23:52:30 +0100 (CET) Received: from mx0c-0054df01.pphosted.com (mx0c-0054df01.pphosted.com [67.231.159.91]) (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 9907EF801D8 for ; Wed, 5 Jan 2022 23:52:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9907EF801D8 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=calian.com header.i=@calian.com header.b="n6/wzZXb" Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 205CIoUh021088; Wed, 5 Jan 2022 17:52:22 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2059.outbound.protection.outlook.com [104.47.61.59]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dc72w9gcm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jan 2022 17:52:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X3jg5AM3zSbqn0tPSnJX8kzBSK+gEoUDK3OUKME2YPltZQbrUVE77fDaSmsf0eoHGZ+OmY96LeIbNPyqTbS2YLst2Aog5cduk+xu72wolVxdGuwX8EvK/kWz6aLThrZEHx+FYxOxT9vyUo67F9HO1CQEIC4eDEhsH3LLlx7HyCIPFusGUt1V1VDhYVPMib8r0k6ikWpxAflX04s6WFyHzD5WugtDvZUY9b2Um+52jYOgKniGaKFmCIE1bidK/GrF9pMR1us1jPX7MXVU5/uBKBor/SxE7meVYQlnverx9pgXqIsJQm/qIz49kVJJyJLOPbdoHe/gjUwol4ExQRmEjw== 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=K/m9bPXn54SMU72qCxPtvD5LlrqMp4lSdOwbUAAQ6lg=; b=hQgonGj3sRXPiYdVpbZ98bzzKWXyDScaA75R5UgWAlyW3uY+eUuK+NGGU5naOZqQLKoVmhQUwrMuiRp7A8uDKjCkYvaTwX25+bEKYp/iWVwz0cQCBOPCW2ja5YsdXQVmWtJA8HoobG4vBJiMn1KKVaf9SwVGfgMCJOv/KzBJkqKAo8XCWYRNoK0fIl4/GYlHzZdEokasJEmzJwvbXQ4DoVmkJD0p538JWS4LU74UoPPKfiXXNM5XtgUUmN1AZUpnrkrmrrdjpoF19knx1clkzVAJ9OMNeaytfaC2MWIsWOasy62Vw39piw3K9di+VA87ocV0ooAo3nuqtGBViRDdWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K/m9bPXn54SMU72qCxPtvD5LlrqMp4lSdOwbUAAQ6lg=; b=n6/wzZXbEasMFOuzFnMzqYmc6x9u1xikCLg9dOMV3OX8Xxuu4JyCXZG1jM3TE1TvcBtqyujmSWauai/vzmTGyMsyEd1oEEvCyd8gsf3AYL5siRE2XKpPllEydADEk6+qTQDv+q+jdMRnY9jqYqfhwNrzPkjT1554q4hVptGB1jA= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YT2PR01MB5120.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:3b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Wed, 5 Jan 2022 22:52:21 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76%5]) with mapi id 15.20.4844.016; Wed, 5 Jan 2022 22:52:20 +0000 From: Robert Hancock To: alsa-devel@alsa-project.org Subject: [PATCH 3/5] ASoC: xilinx: xlnx_i2s.c: Handle sysclk setting Date: Wed, 5 Jan 2022 16:51:44 -0600 Message-Id: <20220105225146.3517039-4-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220105225146.3517039-1-robert.hancock@calian.com> References: <20220105225146.3517039-1-robert.hancock@calian.com> X-ClientProxiedBy: CH0PR04CA0059.namprd04.prod.outlook.com (2603:10b6:610:77::34) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5366ff3c-e45f-4971-c2c5-08d9d09e080c X-MS-TrafficTypeDiagnostic: YT2PR01MB5120:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:595; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yzw21WhS2RL2EKl+t9OwbByE40sEROty1dqIX9frMoQ1OpznZDsCOXDpAHB1RrLXXECamCW+jwzATtMIAvhl0JV3+IIV+dQaybjhtWOcoPi5F4JrZzwEZInjCI4ljuGpvFEBLkeHNXIpjfenhyf7OC2ucXxk4O4AJY7m2x4ONx802zk+Bza11Z/BIanVu2t6pnkeHiHxBcVXY+XyG9GL7fGn0qDMFMohZngk+niyEx9CPN0lDfwLQD9PLfHSAg+2+wfAF+tXTN3RrR9RSiquyuSP0A0kWfsRBxwy7exjUjkcBqateAWZwD9G+XofF+IQjCYllzfVgbvKPt5sJDL/BIE+URUnCtNeeE1QcwFK3X86SuBrRbWTjtsyMn2uHBxi8ExlTlBq6Kc5OrM2W9mOvAWubb7gPGIDf47V0cPf7k2RXv4VPp/6vvQDBg6SscDLrblneILh2tHFzCCOyc7AxF6b4KUoFuPWvIThGvjuKzHzZfPAwmkXN+jkI9IMmR/4kVQj8cjhqwTgU5kQ8RJOuIViwqdslmDR/ex0ucFGTQ1esaVDiWZVSYP2ppbZ7Rg0jf4j1m2qbkino/Nfur+VkObAmBpHeMzLxhb16oo4vUSFr8GRG3FMV7lVMQ8bB1OYD0U32VswaCMkDagaGJKXjGTR2kxJ1uKeU0ir2WsVIXX19/zWMIWnyFh9qOHpFEG2pKxGfTU/xdDM0xdLlTKs3q9sYL4gL4nNRUpjmfuS8OQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(4326008)(508600001)(6916009)(2616005)(5660300002)(52116002)(1076003)(36756003)(83380400001)(86362001)(66946007)(66556008)(66476007)(6486002)(6512007)(44832011)(38100700002)(38350700002)(6506007)(6666004)(186003)(26005)(316002)(8936002)(8676002)(2906002)(70780200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BCy/J2xajRF0wg0sEOb1Mo/5/BEkhBf8fSO5Qqef6JfzY4B0Rpfv1YThCv1pHtgCbEtKGZOHH4HVEEpyw5t7mFqk8bFjIa0upPYEC1unQfRPafOcAnan3P24HHtcpNWCXLBl0E9JXAohYLtNzhPBZ2zgEXKIRUzDgAk8ql1t4zd8othcVG49VF0V1c5JroTsUdExEACekKHqxA6V2SLoLfkBXnT5Z4jgOr6AQgQKpTAtDorUPNIsLqB+GMn/Egqy7c4TQm/4t2CZVGhK29g7POcp7TnW7HgICnqtEulMPWP67TR+5UViNNRnD2z6v1nIp4zEXmmt7qEnTHhI4HzkxfYF4sJg2JC/2oMI43qjST/OQ69ZgSmgdbV5mRfWVHATMPKuJLK/e/CljLmwkhAbR8mvc2h9OKc+9uEPN9RiZRff70Vh+FSDmB8EKsr8tql3QJvGcLD23heGNqVdma/zRMDWxZQFgECbDFExx5vpFTI+nI1HcCxm2XcjBE1ZmnkBPZu2CNtnwV5KVcuO/fBN5RzCwoZ17aCAJbHRzEQP4EsXUaovvF995gcowSBsY+C8bkRMkLbmVInisSQKMdL+eD+sJx3dTq6t5vzlVwlVq2kP2Y6i0eWn69waJgtLPT3dRWFX2gkz9UcwxfXo+3pe4LozgQvQBf8a+Z1xN7LsYHd7Zz2i/ayarAPfU1Aqvn+/ck4oMaZQu3cw+LssbnACSWstb7YT/ttkYcbj6yaa0HHCWChJqvJHUCuBMRDgf1TkjUXARENzDIAVVbSArs7i1T+YAhkE6mf8h9ktFzK0F46gxubkBkeZk3In153ifBg22lSuhx0cNImBD9msNcfDZ48r3CyE3SQxFonym1GUhcSjpecZdLfOmggLxVPSd98O89il23FltTsayintfCxXo74TfzynIEr62pdTEO+o8e3k4zSlwkS56yPRc5+xYonuPElTIEJyn72qID6y9QdCsg/Ui+UXtVsNMCO/SJnQH44u0ddPam56jNoAkTUzAcx1qK7lU7FFdft3UaLrwBwL5ZwuvMkFTSrsXkLqknQtAxc+uy9BEsqPT3N6j9wd2HgZE4FtAcp0TU4PDtk0Un1V/tfM0NLm0y1oGZjL1h8UBtqUZdVO8pSowQsU/onjPA8gxbqoJ2qbXysDJ99ZgJX11wU/YF0F71ojes+aDQQT8KHu1sw4o+aAYZDkCuVcAWmCjvVBOHBhcZ1xffHHVATD2DC6v9HK8C2yyWtjCOYzdE2LeoVnw6/30xP55vPdjkPdPbpOtgones7pXrm2+2i8Yrr1AUAnQhtxZjNcmu/WnXifeaUsUv448Prt+6IH7shdt1Sl9Rh64zukriEcH9HOuf2E2FnxiY7N1Ptp+W+TZAAnMFT9gE7cnquFycw2FTJNjnHrbmt9Q5TKOab3zd5cp+0ONjqoi3qSnN4QzxjCRSWxNFg8Rx/Xyp2yukW/enLwPn1hXKbAtE8Bk2OBpEKu83rM1aBUztAvpmwQgVSCgsLwK0OeJ/nCUnVWq8YJPzTaAV6JJ5uCRSJFs6gfTb0pe77Y0tj9T+A0iXNAd/wxpUcbCdZZgdhZQ9Ynfk2nqVFjaYRT4/KqUxZpNDIQaGXRuG5tGiRO/WjbQ1XSQA/CiJj41E//avtBnXsRLP1mjS9D75op82jwKgpke7aUwTyWUS3vc0yi/VEsFFGUNau5dWw= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5366ff3c-e45f-4971-c2c5-08d9d09e080c X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 22:52:20.9505 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BT+gWQKATQkMSFAOB8fcYXWEiQ2apeoF8f5Pg3/MXxefM9cgV+9MUvzsxvYNKz6NlCCrP4cMYG01UpyRGgQR9JEzM5yEVTb+Q7JLYl+zkzg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT2PR01MB5120 X-Proofpoint-GUID: WtqR2Xy-rY8XJzkdfYte743eZyTby50L X-Proofpoint-ORIG-GUID: WtqR2Xy-rY8XJzkdfYte743eZyTby50L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-05_08,2022-01-04_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 spamscore=0 mlxlogscore=605 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201050144 Cc: kuninori.morimoto.gx@renesas.com, michal.simek@xilinx.com, maruthi.srinivas.bayyavarapu@xilinx.com, tiwai@suse.com, Robert Hancock , broonie@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" This driver previously only handled the set_clkdiv divider callback when setting the SCLK Out Divider field in the I2S Timing Control register. However, when using the simple-audio-card driver, the set_sysclk function is called but not set_clkdiv. This caused the divider not to be set, leaving it at an invalid value of 0 and resulting in a very low SCLK output rate. Handle set_clkdiv and store the sysclk (MCLK) value for later use in hw_params to set the SCLK Out Divider such that: MCLK/SCLK = divider * 2 Fixes: 112a8900d4b0 ("ASoC: xlnx: Add i2s driver") Signed-off-by: Robert Hancock --- sound/soc/xilinx/xlnx_i2s.c | 104 ++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 34 deletions(-) diff --git a/sound/soc/xilinx/xlnx_i2s.c b/sound/soc/xilinx/xlnx_i2s.c index cc641e582c82..1abe28821916 100644 --- a/sound/soc/xilinx/xlnx_i2s.c +++ b/sound/soc/xilinx/xlnx_i2s.c @@ -18,20 +18,39 @@ #define DRV_NAME "xlnx_i2s" #define I2S_CORE_CTRL_OFFSET 0x08 +#define I2S_CORE_CTRL_32BIT_LRCLK BIT(3) +#define I2S_CORE_CTRL_ENABLE BIT(0) #define I2S_I2STIM_OFFSET 0x20 #define I2S_CH0_OFFSET 0x30 #define I2S_I2STIM_VALID_MASK GENMASK(7, 0) +struct xlnx_i2s_drv_data { + struct snd_soc_dai_driver dai_drv; + void __iomem *base; + unsigned int last_sysclk; + u32 data_width; + bool is_32bit_lrclk; +}; + static int xlnx_i2s_set_sclkout_div(struct snd_soc_dai *cpu_dai, int div_id, int div) { - void __iomem *base = snd_soc_dai_get_drvdata(cpu_dai); + struct xlnx_i2s_drv_data *drv_data = snd_soc_dai_get_drvdata(cpu_dai); if (!div || (div & ~I2S_I2STIM_VALID_MASK)) return -EINVAL; - writel(div, base + I2S_I2STIM_OFFSET); + writel(div, drv_data->base + I2S_I2STIM_OFFSET); + + return 0; +} + +static int xlnx_i2s_set_sysclk(struct snd_soc_dai *dai, + int clk_id, unsigned int freq, int dir) +{ + struct xlnx_i2s_drv_data *drv_data = snd_soc_dai_get_drvdata(dai); + drv_data->last_sysclk = freq; return 0; } @@ -40,13 +59,28 @@ static int xlnx_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *i2s_dai) { u32 reg_off, chan_id; - void __iomem *base = snd_soc_dai_get_drvdata(i2s_dai); + struct xlnx_i2s_drv_data *drv_data = snd_soc_dai_get_drvdata(i2s_dai); + + if (drv_data->last_sysclk) { + unsigned int bits_per_sample = drv_data->is_32bit_lrclk ? + 32 : drv_data->data_width; + unsigned int sclk = params_rate(params) * bits_per_sample * + params_channels(params); + unsigned int sclk_div = DIV_ROUND_CLOSEST(drv_data->last_sysclk, sclk) / 2; + + if (!sclk_div || (sclk_div & ~I2S_I2STIM_VALID_MASK)) { + dev_warn(i2s_dai->dev, "invalid SCLK divisor for sysclk %u and sclk %u\n", + drv_data->last_sysclk, sclk); + return -EINVAL; + } + writel(sclk_div, drv_data->base + I2S_I2STIM_OFFSET); + } chan_id = params_channels(params) / 2; while (chan_id > 0) { reg_off = I2S_CH0_OFFSET + ((chan_id - 1) * 4); - writel(chan_id, base + reg_off); + writel(chan_id, drv_data->base + reg_off); chan_id--; } @@ -56,18 +90,18 @@ static int xlnx_i2s_hw_params(struct snd_pcm_substream *substream, static int xlnx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *i2s_dai) { - void __iomem *base = snd_soc_dai_get_drvdata(i2s_dai); + struct xlnx_i2s_drv_data *drv_data = snd_soc_dai_get_drvdata(i2s_dai); switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - writel(1, base + I2S_CORE_CTRL_OFFSET); + writel(I2S_CORE_CTRL_ENABLE, drv_data->base + I2S_CORE_CTRL_OFFSET); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - writel(0, base + I2S_CORE_CTRL_OFFSET); + writel(0, drv_data->base + I2S_CORE_CTRL_OFFSET); break; default: return -EINVAL; @@ -78,6 +112,7 @@ static int xlnx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, static const struct snd_soc_dai_ops xlnx_i2s_dai_ops = { .trigger = xlnx_i2s_trigger, + .set_sysclk = xlnx_i2s_set_sysclk, .set_clkdiv = xlnx_i2s_set_sclkout_div, .hw_params = xlnx_i2s_hw_params }; @@ -95,20 +130,19 @@ MODULE_DEVICE_TABLE(of, xlnx_i2s_of_match); static int xlnx_i2s_probe(struct platform_device *pdev) { - void __iomem *base; - struct snd_soc_dai_driver *dai_drv; + struct xlnx_i2s_drv_data *drv_data; int ret; - u32 ch, format, data_width; + u32 ch, format; struct device *dev = &pdev->dev; struct device_node *node = dev->of_node; - dai_drv = devm_kzalloc(&pdev->dev, sizeof(*dai_drv), GFP_KERNEL); - if (!dai_drv) + drv_data = devm_kzalloc(&pdev->dev, sizeof(*drv_data), GFP_KERNEL); + if (!drv_data) return -ENOMEM; - base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(base)) - return PTR_ERR(base); + drv_data->base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(drv_data->base)) + return PTR_ERR(drv_data->base); ret = of_property_read_u32(node, "xlnx,num-channels", &ch); if (ret < 0) { @@ -117,12 +151,12 @@ static int xlnx_i2s_probe(struct platform_device *pdev) } ch = ch * 2; - ret = of_property_read_u32(node, "xlnx,dwidth", &data_width); + ret = of_property_read_u32(node, "xlnx,dwidth", &drv_data->data_width); if (ret < 0) { dev_err(dev, "cannot get data width\n"); return ret; } - switch (data_width) { + switch (drv_data->data_width) { case 16: format = SNDRV_PCM_FMTBIT_S16_LE; break; @@ -134,35 +168,37 @@ static int xlnx_i2s_probe(struct platform_device *pdev) } if (of_device_is_compatible(node, "xlnx,i2s-transmitter-1.0")) { - dai_drv->name = "xlnx_i2s_playback"; - dai_drv->playback.stream_name = "Playback"; - dai_drv->playback.formats = format; - dai_drv->playback.channels_min = ch; - dai_drv->playback.channels_max = ch; - dai_drv->playback.rates = SNDRV_PCM_RATE_8000_192000; - dai_drv->ops = &xlnx_i2s_dai_ops; + drv_data->dai_drv.name = "xlnx_i2s_playback"; + drv_data->dai_drv.playback.stream_name = "Playback"; + drv_data->dai_drv.playback.formats = format; + drv_data->dai_drv.playback.channels_min = ch; + drv_data->dai_drv.playback.channels_max = ch; + drv_data->dai_drv.playback.rates = SNDRV_PCM_RATE_8000_192000; + drv_data->dai_drv.ops = &xlnx_i2s_dai_ops; } else if (of_device_is_compatible(node, "xlnx,i2s-receiver-1.0")) { - dai_drv->name = "xlnx_i2s_capture"; - dai_drv->capture.stream_name = "Capture"; - dai_drv->capture.formats = format; - dai_drv->capture.channels_min = ch; - dai_drv->capture.channels_max = ch; - dai_drv->capture.rates = SNDRV_PCM_RATE_8000_192000; - dai_drv->ops = &xlnx_i2s_dai_ops; + drv_data->dai_drv.name = "xlnx_i2s_capture"; + drv_data->dai_drv.capture.stream_name = "Capture"; + drv_data->dai_drv.capture.formats = format; + drv_data->dai_drv.capture.channels_min = ch; + drv_data->dai_drv.capture.channels_max = ch; + drv_data->dai_drv.capture.rates = SNDRV_PCM_RATE_8000_192000; + drv_data->dai_drv.ops = &xlnx_i2s_dai_ops; } else { return -ENODEV; } + drv_data->is_32bit_lrclk = readl(drv_data->base + I2S_CORE_CTRL_OFFSET) & + I2S_CORE_CTRL_32BIT_LRCLK; - dev_set_drvdata(&pdev->dev, base); + dev_set_drvdata(&pdev->dev, drv_data); ret = devm_snd_soc_register_component(&pdev->dev, &xlnx_i2s_component, - dai_drv, 1); + &drv_data->dai_drv, 1); if (ret) { dev_err(&pdev->dev, "i2s component registration failed\n"); return ret; } - dev_info(&pdev->dev, "%s DAI registered\n", dai_drv->name); + dev_info(&pdev->dev, "%s DAI registered\n", drv_data->dai_drv.name); return ret; } From patchwork Wed Jan 5 22:51:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 530532 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 4F683C433F5 for ; Wed, 5 Jan 2022 22:54:52 +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 5C1501ABE; Wed, 5 Jan 2022 23:54:00 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5C1501ABE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1641423290; bh=OBud6+DeUg7FMzsKVMY32vFPsa+34KlXd4lsqus++bQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ABELWJtvKEM6IXUxGGqFYqrvVNR+jsbozhiU7AEN31dEtMdZloutD5y+CPcKV/541 4D1d6KC9gSrQn0+KGHaP1TJC5xhl2F7XNo7lvbXD7qNkabBJdmkYG8/1vuIIAvWG9r bxexZBKNl1j4vXKd3rr2JWF26Ia0Szwn7JRIhe64= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 16A3EF80519; Wed, 5 Jan 2022 23:52:36 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4548CF8020C; Wed, 5 Jan 2022 23:52:34 +0100 (CET) Received: from mx0c-0054df01.pphosted.com (mx0c-0054df01.pphosted.com [67.231.159.91]) (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 7A89DF8020C for ; Wed, 5 Jan 2022 23:52:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 7A89DF8020C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=calian.com header.i=@calian.com header.b="nt5Qq6RK" Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 205CIoUi021088; Wed, 5 Jan 2022 17:52:23 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2059.outbound.protection.outlook.com [104.47.61.59]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dc72w9gcp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jan 2022 17:52:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n8hTALqODYQFpT3NnNf7kLqbvscoVTS9MlxSmk6G6UyUNH1X7GftsPx3VANIfvN6Y0SOyi/O29ISugvQsStvHZoh6y2pQyMjnEdx/WB0dqKSXIJ26t/oPc/uBW38jU7Fu4KdaNJHuBb7LP5fABjil+Dgt7V1ORJ1FEwuOY4Aj8GBRQwDy6PaLQb1qAFXsgYJBPfVrVQoartXNpz49/Bk86V267KUsUkd3Yh9ALwnhq727RYMHihBfVMBy8Xau+uegmySvaYy85O/IiiodUVn41OUTP4rWM/cfRaqwBwKtzLtFa/mPoMy3a9p7d/hQVEAL6xLQ2Pae0Ea/hxYO/2R+A== 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=SPWSwqu+iiil2P0VGkKX2eXZxrhD/a+sfCnuNfMvUkM=; b=RGgElsCM4SsUUb/K+oI+C0TIusl8KHqF36oKJogp9nIHHQhJOkh6DqWm5ZypsgDrlKHrAhWS8KFBe2zCZpwb+vsVuIsG5C2JZ49liCBKsHBeNPy7zcCyW7XoUoW66iW6MgwRRcKF/ml+ISk3xcgm8z9gOk35DBSyGsHTq19q3IHLZg3XjfVho4toeqJ7Tpogch0wot+ZO1kL0fypJRSDi/Zkql3KSNmNMMowUlPfQgfAoxEt4SaR5SLegSvxA2qLLdXKBoG2Pjogf8S0yYqY8hNW6oBTaeta8d/IywFzK3SSAEjB9vScsdIeUc7I480MFsIVfgV50Z/xyMlqcFj8Vw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SPWSwqu+iiil2P0VGkKX2eXZxrhD/a+sfCnuNfMvUkM=; b=nt5Qq6RKplK23y6mnmUyz4j8OF4THaGKV+53ItIWUEc1YUPtzAB0hromGoD5jvwLBQF+Kv6zZUfk7CnCofFzTSxiHINvxSKIAcAExizTVYITDGmQFTXkj48oOwOCXzEdBHa2PboMIakqrVdqTaKsmGBgWghQdCniKLZik6ZJ8Xc= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YT2PR01MB5120.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:3b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Wed, 5 Jan 2022 22:52:22 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76%5]) with mapi id 15.20.4844.016; Wed, 5 Jan 2022 22:52:22 +0000 From: Robert Hancock To: alsa-devel@alsa-project.org Subject: [PATCH 4/5] ASoC: simple-card: fix probe failure on platform component Date: Wed, 5 Jan 2022 16:51:45 -0600 Message-Id: <20220105225146.3517039-5-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220105225146.3517039-1-robert.hancock@calian.com> References: <20220105225146.3517039-1-robert.hancock@calian.com> X-ClientProxiedBy: CH0PR04CA0059.namprd04.prod.outlook.com (2603:10b6:610:77::34) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fd93dc0a-9fbc-4507-38d8-08d9d09e08ef X-MS-TrafficTypeDiagnostic: YT2PR01MB5120:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xALCS45s4x+r4rwJ9x2eJiSTkli5586Pcppw5PnUwo5rE4NVZS7Bqs6RgqJYLpZPphFLroAIhB7fy2r640oCYnSEpoEYWpXzQrPr8jRz5/8KhYqlbiV2dTvqn+QT4nvtaaoPGpF3EF5LVZ5rRzxLhpRNgMtafsceyPRCDsG13fh/o+fipH/saCJJrfGNfCV4/mmqvgfaOmMA2LoQ9kTpfdDoRc9nzCsGexRJyiUkJFsF2U9qMZE4u4uDdxbr/l8l8mgcIBFUsvZGnTe43iVuhE+YjxpARYtCItyKiaKxASgBTxtrLydLUOG0qnj14Con6zkVZ9o36e/gbaPmo3Kq2DtCLV28oRbwQ62rbuJrdGogSSfKk91h8ZIGEFVdbKbGlvfloRawtCAnTizYZ/F/bgxYuqDjYw0NIOf5nEDmLuDeTa8MSABO6DwvRFMsFQ2bL079xwazx7Kfu+GWLBt6lZbgK/s3vB9IzdsTM7U69fODptZbDjUKPmoF/FIvWNqgUDpY8I3G612dI3XM9lhCH8Os6Wti/mCRhuZI0n9szNakWJzbxNk9CqKPnTwHgjwvU8cUwjJRTQvEYrhr0EQ/WQNAai/RB0jjoPj2gXyXetc73hthXQVdzQx+LpRHyYIPNUvK3GQBSACorMwD50yDADk8ULVuIokYKK9mWe5RESD/Nh9HR5NaqiSunvfl2u6P1vTDS/10ooe3dBbWp2ekbw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(4326008)(508600001)(6916009)(2616005)(5660300002)(52116002)(1076003)(36756003)(83380400001)(86362001)(66946007)(66556008)(66476007)(6486002)(6512007)(44832011)(38100700002)(38350700002)(6506007)(6666004)(186003)(26005)(316002)(8936002)(8676002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: R/JMuymsPn2z5xz133rkxpxBY0j8Kh65ym8KmwT41h0VxHCpnbSZ5YzI20Yo2agYO8V204RdKsz92IzMCaSjy7UDNgWDSdM4Jrn5+OiYNVv24wTl71DU/im4NTRpAoEl7PkyQO1HizerLWbdE+OoUlg/RvYNYgsFGP9RdVLW9zgkDA+X95wlVJGse/2szD2QwFB/HdmOLqYtF5GIZb0r7UJn63OX0s17tAuOZAvGnCtxb6jVhJ1f9rkToEhQrOFDVkcc5xesXrEPq5w+AhBvnAAH5m+ptb7QsNm2XF6vUMZF0OmckjiOliuyE5yB1kRMlI0fh90NXmSjEuHvN1NI1qvNM0LSu6cViSLxUf3p7bNzXnLAH9SogeDBE8b0+YdG0K6ABLpt4X0vRNs+/qB10vu5TKT0pOmeD+rkjVtbZFVwlHH64gTANsRggk2WLfL8bLfrbPl8dz9noMTFGVIIwx7OVEFNlhAPl+gWCBWB3MoFV05XOw9DiElm5T/eqf0BR4C1Ic+5OQL3xppuFtrMz1IK51Myy7DQAnGKL2eoEJyV0pENK3b4NhSb1pfCu22vHuLho8VIS0Ksw0bcecW4kjy+RXHX+wT9kRio/EBHctWAuSEgPcfM7MAN21y/RLV4uyGgK7644FmxPcFfKJYGpcDAVtYLVcL7/vA00VLvhmYoXF74HLZ426R348b85SNw/v/5IC4rR4lUUTRzuyWdfD/N+hiGS5CjQkRptXisyJ5E7CidHWWO82wejuh9nk/dxeHoJ8pzWsVGG3rX0sXO/GAay+b4KmCieeQpgeuzwXI7Icy1+VOS8sZWabBqo28iXajmvpZJ91JqolqMnt/ziTFPTjTJJgGTOKtQ7TiOkEC0pvAO1iWQ9n3yLcqXbd59jG7J5mKBT5Ijt2soNb08KMq+IJ57E5vzk2STWC+ruY7U7qP9dzE9FnYN7du6buprbza841Kz4GAfwwJ0zvgsyUejJx7IJXVR411AjaFTX/jYeUIbcsGG3x6Atg6FH+ehdTjHYEJx11cDSQSGBefqtHMzKeyPFSHeHP6rY9dlYwxsz9TPoFEEg73cB19XcKnr1CaXtaGSAEmfgRvfb/wFe8U3Eb/CJISNt633+0WBpYnyqUDxdbrF2MPRKotlQcLBmV5C3PfmUqC30M+MGhk0jLwPbhEFDBTvgomskpm4IvAYmu6ZBDgxeUt4fz5WxUsc9d91OjdqT2wLuTLhBKOiTLYQ52cmnajWDMdx19NLckmXts6/ok1Tm7d1ASrAAXSUjHEwd29IOkBXxTb9BJUb7GM3jIRi4ziN0bC2N9gctcd9q4f7x6fd9Sy3Husm8PstXVQvGE22fPvFp3lzbl1fhwYJ62XqRzpH4+kAlajXRGVMFBP3hZQteq9J87Z3Xdd+HpFndLxqVTBma2sPX0L88U6iLgtNxrMTUTyB/CJGmkqMZAhKBzOyu/kWIIJU0Mx2DHiMKAH3steI6qmYH4xQ/DCQx30h2ZUK8YUtETK/z626GTVZYf2Kmdxss7TtgEfcUWqbKEKcbz83YSWmToLPsRmltqLsnhXpNQLSOPh7XtH+C0cFJstxUvoHV5Ja9zo1nCxqfrTkxfBbB11nGUEg55HSgrp72WwzMBeEDNibwyzF+n9ZRrZqtKs9iwKocnsqx/u+xmxjJgKSKGGFFG9gs7Kr8mQdsxn81weFGqctIiM= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd93dc0a-9fbc-4507-38d8-08d9d09e08ef X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 22:52:22.4659 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 258s4tglfCSltIaqHh/4rtd63gSi4Et/vonTJSsOg88UpkeUjCUtraudTo4sGe+5IR3JVSW6kAdcNjfs3haFQYZzChJEV9/CDK7N2X9P2Sc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT2PR01MB5120 X-Proofpoint-GUID: Mnw8yIliKRUv1mHVu5rJLaYZfkZrn1cs X-Proofpoint-ORIG-GUID: Mnw8yIliKRUv1mHVu5rJLaYZfkZrn1cs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-05_08,2022-01-04_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 spamscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201050144 Cc: kuninori.morimoto.gx@renesas.com, michal.simek@xilinx.com, maruthi.srinivas.bayyavarapu@xilinx.com, tiwai@suse.com, Robert Hancock , broonie@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" A previous change to simple-card resulted in asoc_simple_parse_dai attempting to retrieve the dai_name for platform components, which are unlikely to have a valid DAI name. This caused simple-card to fail to probe when using the xlnx_formatter_pcm as the platform component, since it does not register any DAI components. Since the dai_name is not used for platform components, just skip trying to retrieve it for those. Fixes: f107294c6422 ("ASoC: simple-card: support snd_soc_dai_link_component style for cpu") Signed-off-by: Robert Hancock --- sound/soc/generic/simple-card.c | 52 ++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index a89d1cfdda32..1295836e04f4 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -30,6 +30,7 @@ static const struct snd_soc_ops simple_ops = { static int asoc_simple_parse_dai(struct device_node *node, struct snd_soc_dai_link_component *dlc, + bool is_plat, int *is_single_link) { struct of_phandle_args args; @@ -46,28 +47,31 @@ static int asoc_simple_parse_dai(struct device_node *node, if (ret) return ret; - /* - * FIXME - * - * Here, dlc->dai_name is pointer to CPU/Codec DAI name. - * If user unbinded CPU or Codec driver, but not for Sound Card, - * dlc->dai_name is keeping unbinded CPU or Codec - * driver's pointer. - * - * If user re-bind CPU or Codec driver again, ALSA SoC will try - * to rebind Card via snd_soc_try_rebind_card(), but because of - * above reason, it might can't bind Sound Card. - * Because Sound Card is pointing to released dai_name pointer. - * - * To avoid this rebind Card issue, - * 1) It needs to alloc memory to keep dai_name eventhough - * CPU or Codec driver was unbinded, or - * 2) user need to rebind Sound Card everytime - * if he unbinded CPU or Codec. - */ - ret = snd_soc_of_get_dai_name(node, &dlc->dai_name); - if (ret < 0) - return ret; + /* dai_name is not required and may not exist for plat component */ + if (!is_plat) { + /* + * FIXME + * + * Here, dlc->dai_name is pointer to CPU/Codec DAI name. + * If user unbinded CPU or Codec driver, but not for Sound Card, + * dlc->dai_name is keeping unbinded CPU or Codec + * driver's pointer. + * + * If user re-bind CPU or Codec driver again, ALSA SoC will try + * to rebind Card via snd_soc_try_rebind_card(), but because of + * above reason, it might can't bind Sound Card. + * Because Sound Card is pointing to released dai_name pointer. + * + * To avoid this rebind Card issue, + * 1) It needs to alloc memory to keep dai_name eventhough + * CPU or Codec driver was unbinded, or + * 2) user need to rebind Sound Card everytime + * if he unbinded CPU or Codec. + */ + ret = snd_soc_of_get_dai_name(node, &dlc->dai_name); + if (ret < 0) + return ret; + } dlc->of_node = args.np; @@ -134,7 +138,7 @@ static int simple_parse_node(struct asoc_simple_priv *priv, simple_parse_mclk_fs(top, np, dai_props, prefix); - ret = asoc_simple_parse_dai(np, dlc, cpu); + ret = asoc_simple_parse_dai(np, dlc, false, cpu); if (ret) return ret; @@ -289,7 +293,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv, if (ret < 0) goto dai_link_of_err; - ret = asoc_simple_parse_dai(plat, platforms, NULL); + ret = asoc_simple_parse_dai(plat, platforms, true, NULL); if (ret < 0) goto dai_link_of_err; From patchwork Wed Jan 5 22:51:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Hancock X-Patchwork-Id: 530181 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 4BF1AC433F5 for ; Wed, 5 Jan 2022 22:55:03 +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 846A21AC3; Wed, 5 Jan 2022 23:54:11 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 846A21AC3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1641423301; bh=3kKvh22MCThEOLdCD/Pqzv4d4WChZ8gHm1iq2aBqRQg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=mW636uif0L5AUUMUKUBbUtSJ7DnQDIokcAm3YUja2FxURV7ufn4FMI+Wtw7XpjhNp fq8Ofxvl+Uf5OY4Caek22Lpbr7VRm855U7craOjwRyBjQFZqXV1UBDvhOvkKOHoLut deDoAorQ/2b+2jHN5gego8w8gEyBVrrkxTXbikC8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8829EF8051F; Wed, 5 Jan 2022 23:52:36 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 69CBEF8051D; Wed, 5 Jan 2022 23:52:34 +0100 (CET) Received: from mx0c-0054df01.pphosted.com (mx0c-0054df01.pphosted.com [67.231.159.91]) (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 5A7EEF800BB for ; Wed, 5 Jan 2022 23:52:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5A7EEF800BB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=calian.com header.i=@calian.com header.b="sWaWwtPy" Received: from pps.filterd (m0208999.ppops.net [127.0.0.1]) by mx0c-0054df01.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 205D3T0N019799; Wed, 5 Jan 2022 17:52:24 -0500 Received: from can01-to1-obe.outbound.protection.outlook.com (mail-to1can01lp2057.outbound.protection.outlook.com [104.47.61.57]) by mx0c-0054df01.pphosted.com (PPS) with ESMTPS id 3dc72w9gcr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jan 2022 17:52:24 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QVLC2wrvRHhuJsK/o/mdCD9XV4DpNjIQU+1SCRvhC+FVSymGzZoOh6JFyDHUEZ/VxSX0PLBvQtcVLCQwznJmnm4v9fUFnbE3ZF+TyqBA6yC5bq/ptXHDPboKLu2IUcZRMMiv7tk4RrSf0gdh4YPJqpUj067wEH94yxHYniieS/dUyTFODmvkhpjJIRScgSQ+y+Q9eetJMfMcuk55iv0TSvlCB1jCzQYhDY+2etYeQKSsJ9FUPF7/gnh0QgE6W1OOwqcsa0BOqeIuzGixZ4e8gHKTsgtm2vxVHUZFKBW/pkpphuHC67wvog4vCwZK6LglUMJHE/YyGroaFQo8USjGHw== 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=u1b8wmatKzzCjGEPPM/mnK84tw9++aSItra6VC2jDg0=; b=kA7b9q2YAwMf2sb/JOOqkgMbwmh9VzAP0wU4IbjW5bQ6y4HhtZ1FM08v5zkULekL42BAAaucaiqAV9NY4YTPrymjeD/cey3KYLSBpLj3VRSxvnuH5sYXP2Qo5xjLYSrpE17Y76WSWQ+seVf+UtGlrQmCHEie6gJrPPsamyawPxg+PYBBOb7Sen42il7S/ovg+KakqEKmBz2i68w/aNoBj5PfxUUqAH8Tuu0E2hR4e+bTVkiCkXJ5eIlqNaVjcju3a0bU/18MA51PZSaUX+dmDj5KSEFVsEXorNzQYnbSRCL8AEBKH4FZzW7sL/rgUVgh1hwXb6Tz9/yNaYsTx1G7Ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=calian.com; dmarc=pass action=none header.from=calian.com; dkim=pass header.d=calian.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=calian.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=u1b8wmatKzzCjGEPPM/mnK84tw9++aSItra6VC2jDg0=; b=sWaWwtPythdudvdDk511TRwbALqs1mLPzm7fsft+aa3vCe5yUvfqzWvP0pnxq1yP6XzbbjTIlPbYZqel+/htietbsDUwLnHMgv/2BZiv1vHxOcLHwq8FHZyzFACmhHWn1DyVKwgWdwvDu9SRAVqsw2uWjZO2cQzp4S3JS6SRRdU= Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) by YT2PR01MB5120.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:3b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.7; Wed, 5 Jan 2022 22:52:23 +0000 Received: from YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76]) by YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM ([fe80::d1f6:d9e4:7cc7:af76%5]) with mapi id 15.20.4844.016; Wed, 5 Jan 2022 22:52:23 +0000 From: Robert Hancock To: alsa-devel@alsa-project.org Subject: [PATCH 5/5] ASoC: simple-card-utils: Set sysclk on all components Date: Wed, 5 Jan 2022 16:51:46 -0600 Message-Id: <20220105225146.3517039-6-robert.hancock@calian.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220105225146.3517039-1-robert.hancock@calian.com> References: <20220105225146.3517039-1-robert.hancock@calian.com> X-ClientProxiedBy: CH0PR04CA0059.namprd04.prod.outlook.com (2603:10b6:610:77::34) To YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:6a::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f4f69109-f86b-4c1c-6a9a-08d9d09e099d X-MS-TrafficTypeDiagnostic: YT2PR01MB5120:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TEpyiA2Q0R/tziGMpnQ1uaf4Dt9PyWR0NIUzt/bGlYiElkG/aI3ydu0MdYws1cDamIS7zyFouOCaVt8TRKCcndAh9riWZqQNHLroW7RxL13RmftY6LgB5es1IZ0tGN+i6ejU74Szg5tL9vN5fqw0MbYuF29xmZV61l+MM48ECxFrv59TGWVHp6JxNttIls/ZY/KMPi5wjjSTBdpQY1XK/Laa/u5Rf36+0Te2rYcnDSok2TyjD6BcJ+RJIVXk1YrFAMBNSlfncW9kXOp7ABRXhB+3B8DZDYyy8XPDPKTg6+tRUh0tLLY/Vr9Vd9HT4FZmantNyqUBUPIAN/km2ltonHsX5K5dIsxfH+7IlBc/VjdGEqFVSveRi3irk/VJthNk0LT0PalQJdN50NVDAYEWpi6UG5TAo4LA8Zi7WoTwrsioebZ4Bol4dTCapHFP2tBDRKy8WldWfGBHFfcRE9Nkp3mwjXb+KKLgMXmU44nl+sxb7VvlrSHtBm5IYxm2uYpWvlyNxCZnk/ayzD185zJkwGeC0XczshmLq66Aq+M49N8/z8hE8fKbariXzDrcHqGoa5FSHW+m/oGF4w4PB6k2yxbnGry4hfjoEbdgHDDOIS77ELD9zbejehBP/xDy3Tsm2Z+vgG7s4oSqD60tgpk13FYRFQEBaoxjNamgd9HaNf5BGgS28/YxwyApW+1nXEb6u0QTVYXUgsdFZ33Gfb474A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(4636009)(366004)(107886003)(4326008)(508600001)(6916009)(2616005)(5660300002)(52116002)(1076003)(36756003)(83380400001)(86362001)(66946007)(66556008)(66476007)(6486002)(6512007)(44832011)(38100700002)(38350700002)(6506007)(6666004)(186003)(26005)(316002)(8936002)(8676002)(2906002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Kx6aSzY0peZilaOpLv6QzQUBdpWvu/EdNRM6jLnZGvNy0lVF0Piy5AxyUXxfKZV1vJejlD3LuoMwBB2nvZUaeNn5HzcZBZ1raE/XAP7HvhqWUJiGkYABVtYmYufFfYvWmfvFcfN3hgbmKCc/Rc0N9JZjkaIQ50equhzBfsvmcvEpkdrOIOeF+B9BV6j1WY8QjtWhDxDr8jgUqPSFWkFRTWAkIZtoRiBw3y5UtXUxAy3G7RgFu+RUGaEt0mBxjKQkYqJDmdLDK6X/R5UU3+uYvX19+m2AhHGvNmKPM/p7eZwQgofb1hXuBL+paVS6fpN0/2vtZZsi42LOJr2p3Fydhsuw2pOIPGUz4nraK/+MQZbJIOrg6Vis6Y9SlEmeC8qtl4+df55RmBqI350G9U462E5q8v55jPmu2x8tQuaQTWhmyMXrgdTLoSbStVafZWM5n63OHHlV1cN56pfND4fZRDmAvUaj77AMg88rBBScs9zrk/rAWoLZetLceJgv8QnCJv1/pIia8nIr4BNFsaM+PDf43/V0bOeKTAeRQv65JhCWTiVCurYBtxDBl56Ol30lNTt6zsqRjlKBlvpiGnvcAg+0//wJlwUnBsAnsvWQQB8qeUOkAaqsxMNpTcrfgXRBGbdKBJZ48wWmdExF6xNzh6pYTaOb+MDazyaExY9vQOJB0Wa7OavoEJpUEgdMv0RImN6udGY5P5NQpyyPcV/OAZYjkfcCeAcw9HXJvTh0Me/KJnjqiQbYlMbb9gvh/91m38bc2R6qO5R1FnKnGFpMHMVFpO5ubpinK9zbCNcJnUF27zb2WAuzQ8xV4AyYHbnfiKSKip+72sFZLsThvjCjd+XblGDgjCzpoGWK+osk+fwiDMKYjneR3mvjnFGn6uxddpjy+3XE9fMsJyUFjsqKXceobiu7tAyzYXPQPGD1RAl/Vi2aOwBnq89MPFKXYVnXbYwg9LbNL5y0zQYraZV+izscidQZAZhuwxA7MtNc3/YbgGbxcreSZQfZIdEHK9UUIFcr72qFfEypWhgEwyGIXOB4ih6ZkEj3BvKBEXiBFsmw1bz6/K7eM47DOTMBIv3UIpD8lVRPSm2uZvC0m2au76689ux+ZTVOmfQOkNYqMJi5lAc42wIC2t5dX4Ng9ZNvfrxeLlveh4saKfcSx2DP9jy/H6lsT1c3npn8Wzqmee4Tk2GqoY5tUWW+etpgW61JAFGQk11haCMugorP024bXBkWAJo02YhBD0SRs+aT9NFBMw2pNrU3wowkQC5ypBsb3uQSc82F85JQcsyqFZuKnM3VCG84IM95RXPCu51eGKpzITnkCMKzkz/rGV9YcTdWyWjZrbmDzVk1SGwkKwM4BFw3Kxuf2W+pUZGKrZw4TdmYy+zv5H7rzQYZ4FJ7Pn97vcN9vsbm4V5aiJej0DSeYqbNQEwX/sWkrm3Sbueyc9KPXE6VPFdpUpS0UckchPhmkBXQnOJHn2+TNR94zfHUFo5Az2/xboai39urDDE/FPZMk3KYbUjtKAf0MSkgN9IK2oT4qjEmz/17BWgdkMfop44WyjFV7wXKc/asbnsD2V05VtVDSjW/YFh4VRMAp3flpNTP2cdne5CE057Ztu8D2+ahih2dJrpptyFawpVtq4kBNOrcrRgpj3SBOtqTeirZJHPjLx8/JakvbOxuv/V4lDtXFaVtbqaZXa2jQS1lfRM= X-OriginatorOrg: calian.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4f69109-f86b-4c1c-6a9a-08d9d09e099d X-MS-Exchange-CrossTenant-AuthSource: YT3PR01MB6274.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 22:52:23.5909 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 23b57807-562f-49ad-92c4-3bb0f07a1fdf X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2kkeOz6VUZrgkL9j+OWB+AyzqVSdKLjT66IMgVvNGfhsz7NV+4/ubGSjq/KA0AuohDemG57y2u4ZP5nWusLnQzbQfxQnVPujyYPNRWA6BDM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT2PR01MB5120 X-Proofpoint-GUID: szf1Vgn_2oITyD59hBSn2ZZBJrPZIp0p X-Proofpoint-ORIG-GUID: szf1Vgn_2oITyD59hBSn2ZZBJrPZIp0p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-05_08,2022-01-04_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 spamscore=0 mlxlogscore=905 phishscore=0 mlxscore=0 adultscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201050144 Cc: kuninori.morimoto.gx@renesas.com, michal.simek@xilinx.com, maruthi.srinivas.bayyavarapu@xilinx.com, tiwai@suse.com, Robert Hancock , broonie@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" If an mclk-fs value was provided in the device tree configuration, the calculated MCLK was fed into the downstream codec DAI and CPU DAI, however set_sysclk was not being called on the platform device. Some platform devices such as the Xilinx Audio Formatter need to know the MCLK as well. Call snd_soc_component_set_sysclk on each component in the stream to set the proper sysclk value in addition to the existing call of snd_soc_dai_set_sysclk on the codec DAI and CPU DAI. This may end up resulting in redundant calls if one of the snd_soc_dai_set_sysclk calls ends up calling snd_soc_component_set_sysclk itself, but that isn't expected to cause any significant harm. Fixes: f48dcbb6d47d ("ASoC: simple-card-utils: share asoc_simple_hw_param()") Signed-off-by: Robert Hancock --- sound/soc/generic/simple-card-utils.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index a81323d1691d..8345a750b183 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -275,6 +275,7 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream, mclk_fs = props->mclk_fs; if (mclk_fs) { + struct snd_soc_component *component; mclk = params_rate(params) * mclk_fs; for_each_prop_dai_codec(props, i, pdai) { @@ -287,6 +288,16 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; } + /* Ensure sysclk is set on all components in case any + * (such as platform components) are missed by calls to + * snd_soc_dai_set_sysclk. + */ + for_each_rtd_components(rtd, i, component) { + ret = snd_soc_component_set_sysclk(component, 0, 0, + mclk, SND_SOC_CLOCK_IN); + if (ret && ret != -ENOTSUPP) + return ret; + } for_each_rtd_codec_dais(rtd, i, sdai) { ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, SND_SOC_CLOCK_IN); if (ret && ret != -ENOTSUPP)