From patchwork Wed Nov 9 22:40:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 9420475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E2272601C2 for ; Thu, 10 Nov 2016 01:11:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA5742944A for ; Thu, 10 Nov 2016 01:11:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEF722944F; Thu, 10 Nov 2016 01:11:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 300652944E for ; Thu, 10 Nov 2016 01:11:03 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 8225A26723A; Thu, 10 Nov 2016 02:11:02 +0100 (CET) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id DCCFC267234; Thu, 10 Nov 2016 02:08:43 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D528E2666D2; Wed, 9 Nov 2016 23:41:44 +0100 (CET) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30104.outbound.protection.outlook.com [40.107.3.104]) by alsa0.perex.cz (Postfix) with ESMTP id 633F326640F for ; Wed, 9 Nov 2016 23:41:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentiatech.onmicrosoft.com; s=selector1-axentia-se; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=w7Jc7cTgp3agmjU2rOHtZkD9J79/07TUojwBZsZLAsM=; b=OPoNuwxhy5Rqfz17TEydZzu8iLP70iFECXI9r2zHusjurA1/TEz2EX/a9T3zCNBjXrnhIudAM6aOupbYfDx2UhU6ZzL6YuEwSdAsnGTU814cPUAVIqW8ojt+jyBpDCJZ/WLMcZi3FAVg44BzYbCaSdLad/+Y9i+ZAYYwUEx4HeQ= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Received: from localhost.localdomain (217.210.101.82) by VI1PR0201MB2319.eurprd02.prod.outlook.com (10.168.63.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.6; Wed, 9 Nov 2016 22:41:35 +0000 From: Peter Rosin To: Date: Wed, 9 Nov 2016 23:40:56 +0100 Message-ID: <1478731258-26084-2-git-send-email-peda@axentia.se> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1478731258-26084-1-git-send-email-peda@axentia.se> References: <1478731258-26084-1-git-send-email-peda@axentia.se> MIME-Version: 1.0 X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: DB4PR01CA0034.eurprd01.prod.exchangelabs.com (10.242.152.24) To VI1PR0201MB2319.eurprd02.prod.outlook.com (10.168.63.21) X-MS-Office365-Filtering-Correlation-Id: 20cba5af-a203-4e21-153f-08d408f1907c X-Microsoft-Exchange-Diagnostics: 1; VI1PR0201MB2319; 2:2wZwwd/7kAQ97szmHpOss4hVtmLESJOxzuO0pNo6Tds1jynnydt2O/BSnpPRcq19HKLs4Y6yKdqLziakgA/d4lnVERbcCOF+xYw7AKEFdnwPecYxOj3PEz3l++V47gIuoQHD/8SMzAYIyXa/akxoL60mnqxDqNi4r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ZWbwEO9t0glDdT2MLt6SmYkHgnuQzZm6BKES2io4PI8fJKlmwpslFXHNwfwSCrvK9FNuEsxqWowYFYvIamoeH/sJjNyln4r2YM3vDbzQWwDH+AjdvONPeUmTQfUxq1kbHQO1ezl7Tn3SzV0KxVvq31sBatQW7zVQm6fODxPl5WoY4Y/HbzSx1vOB4Y5EmfI/M0iQ2wKOrx0vX4LsD5FgqP6zp498vJQm6pkCzcyIffySierdDZkWm68p3qvqyG5RHGUqMcKLl5f9CsinHDfn2mcDWxxmEAy1O2hvxm+8V0y+PEKHoHR4qh+wMVe+p79hAXp4je0mEq7RsdSB8MpWlQhshq/u84yfld7UArflfV6etoUd0XVRrMv3zZue11P9lc91RJiL8i9 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6043046)(6042046); SRVR:VI1PR0201MB2319; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0201MB2319; X-Forefront-PRVS: 0121F24F22 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(42186005)(76176999)(50986999)(5003940100001)(2906002)(68736007)(47776003)(5660300001)(106356001)(305945005)(66066001)(77096005)(7846002)(7736002)(105586002)(2351001)(189998001)(74482002)(86362001)(101416001)(33646002)(97736004)(50466002)(36756003)(92566002)(50226002)(6666003)(8676002)(586003)(4326007)(81156014)(48376002)(2950100002)(81166006)(110136003)(6916009)(7416002)(3846002)(6116002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR0201MB2319; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0201MB2319; 23:Lum00UHIdDE5aU7JfW7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/bHR4rEvhx9kI4D83EhYPXqVcum+d5iNsFqsW0B4sr/SU?= =?us-ascii?Q?V1/q1/MgAyje3sM5Zp2NDVYP0gWvwZXS4fiMIcoYEpazwW1l0MyC4L2lDxJV?= =?us-ascii?Q?xs+Xd+pqkY0ZlInRvQxVLMc34whKI1NhGjnIXhyB7x8nzUlWoR0QbvB0tmfg?= =?us-ascii?Q?9ek/u9RKIqkuxTz/VDKZXbuOEPBOAo6nhCXj4HzNKjJ9WHSeGgw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0201MB2319; 6:9KRMgBhAZPR5kNwA+lXlh4pDSTT83GiKczJA2XoLNPCcBIhjv/6CiSm0Y5OyI/7/GoYEQ3rpfnJQ2Dp6Y28UtdBZlpnc6eHV3Ne5K1CxuCe3zjCVO8QyyufnIe6wkIBWKrtEAC6O3j7kl5iEqCTNNKQTlYO/g+BdpryxaxrCAukn+p8VjeDMHVmzLqZMcE9sG0dYmzxM25ypN/amuqbYXjFpGsyaWN8GdC4ApGXPiKRNSkOJ1WJX8MqlPvNoKXMLFx1XPema82MOneUNO8tKeBPiWiL+FxxrFZuiC2CldmvyMrS0rqrvEK/jwO10q78LtqO+JVklYiRPvxtnMfMl/Q==; 5:eeyk96xgLeENDcwXJuTp8SGAXsEoAbYil685EKbIIDGZjYjU9o46NS6KjdzzXmv7yqvlh6DciBTgaUyARXXprSiH/40BbUWLDw/xT+PBiD7WIOilTpwVPAUHeBCFTL00TtuyrRC0qn3BQvHMWNLsMw==; 24:zQvGygR0GeRnV1bszDOHRY9/3YxfTsOF/nn4NxRnZrnfLkdFTe5jMsmwIC8XDOL5B7lq22P9GanzZ29av00ApQJHPsXel2oBa+tjuNzgb/U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0201MB2319; 7:NqHY3YSrum6frWiljq8obUxzIz4zP/t7BwsuafoSyp/we7Uyrnp85uxolpRSXqF8y5yEugDLXCDfIATMZTBFFPNAwC4Ml9yLwt/EvU008oNBbSKVlySw7jtScJFS5X5IRZpaIN+aKMpfomFObsMFw2c5KJFYWqTX++Orp5nQY5gmobrgxNhTqO5FvbKp16UcDrfoWLBkH2dJRGAGR7NGWCf4Iz7JivEMmFjfU5LJ04hH5FNqhh9gE0wvxUnRjfoXswCHrkgUwFzXs5dE13XGiIX+O0TPztHH9Q5hrSN9/iKwYleN10L34YiOgTa7jPyinXcK+iqgqAUs8vqIDPM2/Pn5FJ4NUEB1HjvfxsoPYsQ= X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2016 22:41:35.4355 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0201MB2319 Cc: Mark Rutland , devicetree@vger.kernel.org, alsa-devel@alsa-project.org, Takashi Iwai , Nicolas Ferre , Liam Girdwood , Rob Herring , Mark Brown , Peter Rosin Subject: [alsa-devel] [PATCH v2 1/3] ASoC: atmel_ssc_dai: if not provided, default to sensible TCMR/RCMR periods X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 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-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP When this driver runs the dai link frame clock, and noone has stated differently, assume that all the bits of a frame are used. This relieves the cpu dai users from the duty to fill in the dividers for the common case. Signed-off-by: Peter Rosin --- sound/soc/atmel/atmel_ssc_dai.c | 29 +++++++++++++++++++++++------ sound/soc/atmel/atmel_ssc_dai.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index 16e459aedffe..674191508437 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c @@ -380,6 +380,7 @@ static void atmel_ssc_shutdown(struct snd_pcm_substream *substream, ssc_writel(ssc_p->ssc->regs, CR, SSC_BIT(CR_SWRST)); /* Clear the SSC dividers */ ssc_p->cmr_div = ssc_p->tcmr_period = ssc_p->rcmr_period = 0; + ssc_p->forced_divider = 0; } spin_unlock_irq(&ssc_p->lock); @@ -429,10 +430,12 @@ static int atmel_ssc_set_dai_clkdiv(struct snd_soc_dai *cpu_dai, break; case ATMEL_SSC_TCMR_PERIOD: + ssc_p->forced_divider |= BIT(ATMEL_SSC_TCMR_PERIOD); ssc_p->tcmr_period = div; break; case ATMEL_SSC_RCMR_PERIOD: + ssc_p->forced_divider |= BIT(ATMEL_SSC_RCMR_PERIOD); ssc_p->rcmr_period = div; break; @@ -459,6 +462,8 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, u32 tfmr, rfmr, tcmr, rcmr; int ret; int fslen, fslen_ext; + u32 tcmr_period; + u32 rcmr_period; /* * Currently, there is only one set of dma params for @@ -470,6 +475,18 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, else dir = 1; + /* + * If the cpu dai should provide the frame clock, + * but noone has provided the dividers needed for + * that to work, fall back to something sensible. + */ + tcmr_period = ssc_p->tcmr_period; + if (!(ssc_p->forced_divider & BIT(ATMEL_SSC_TCMR_PERIOD))) + tcmr_period = snd_soc_params_to_frame_size(params) / 2 - 1; + rcmr_period = ssc_p->rcmr_period; + if (!(ssc_p->forced_divider & BIT(ATMEL_SSC_RCMR_PERIOD))) + rcmr_period = snd_soc_params_to_frame_size(params) / 2 - 1; + dma_params = ssc_p->dma_params[dir]; channels = params_channels(params); @@ -524,7 +541,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, fslen_ext = (bits - 1) / 16; fslen = (bits - 1) % 16; - rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period) + rcmr = SSC_BF(RCMR_PERIOD, rcmr_period) | SSC_BF(RCMR_STTDLY, START_DELAY) | SSC_BF(RCMR_START, SSC_START_FALLING_RF) | SSC_BF(RCMR_CKI, SSC_CKI_RISING) @@ -540,7 +557,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, | SSC_BF(RFMR_LOOP, 0) | SSC_BF(RFMR_DATLEN, (bits - 1)); - tcmr = SSC_BF(TCMR_PERIOD, ssc_p->tcmr_period) + tcmr = SSC_BF(TCMR_PERIOD, tcmr_period) | SSC_BF(TCMR_STTDLY, START_DELAY) | SSC_BF(TCMR_START, SSC_START_FALLING_RF) | SSC_BF(TCMR_CKI, SSC_CKI_FALLING) @@ -606,7 +623,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, fslen_ext = (bits - 1) / 16; fslen = (bits - 1) % 16; - rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period) + rcmr = SSC_BF(RCMR_PERIOD, rcmr_period) | SSC_BF(RCMR_STTDLY, START_DELAY) | SSC_BF(RCMR_START, SSC_START_FALLING_RF) | SSC_BF(RCMR_CKI, SSC_CKI_RISING) @@ -623,7 +640,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, | SSC_BF(RFMR_LOOP, 0) | SSC_BF(RFMR_DATLEN, (bits - 1)); - tcmr = SSC_BF(TCMR_PERIOD, ssc_p->tcmr_period) + tcmr = SSC_BF(TCMR_PERIOD, tcmr_period) | SSC_BF(TCMR_STTDLY, START_DELAY) | SSC_BF(TCMR_START, SSC_START_FALLING_RF) | SSC_BF(TCMR_CKI, SSC_CKI_FALLING) @@ -650,7 +667,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, * MCK divider, and the BCLK signal is output * on the SSC TK line. */ - rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period) + rcmr = SSC_BF(RCMR_PERIOD, rcmr_period) | SSC_BF(RCMR_STTDLY, 1) | SSC_BF(RCMR_START, SSC_START_RISING_RF) | SSC_BF(RCMR_CKI, SSC_CKI_RISING) @@ -665,7 +682,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, | SSC_BF(RFMR_LOOP, 0) | SSC_BF(RFMR_DATLEN, (bits - 1)); - tcmr = SSC_BF(TCMR_PERIOD, ssc_p->tcmr_period) + tcmr = SSC_BF(TCMR_PERIOD, tcmr_period) | SSC_BF(TCMR_STTDLY, 1) | SSC_BF(TCMR_START, SSC_START_RISING_RF) | SSC_BF(TCMR_CKI, SSC_CKI_FALLING) diff --git a/sound/soc/atmel/atmel_ssc_dai.h b/sound/soc/atmel/atmel_ssc_dai.h index 80b153857a88..75194f582131 100644 --- a/sound/soc/atmel/atmel_ssc_dai.h +++ b/sound/soc/atmel/atmel_ssc_dai.h @@ -113,6 +113,7 @@ struct atmel_ssc_info { unsigned short cmr_div; unsigned short tcmr_period; unsigned short rcmr_period; + unsigned int forced_divider; struct atmel_pcm_dma_params *dma_params[2]; struct atmel_ssc_state ssc_state; unsigned long mck_rate;