From patchwork Thu Apr 21 20:58:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 8904001 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 10680BF29F for ; Thu, 21 Apr 2016 20:59:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABE3E202E9 for ; Thu, 21 Apr 2016 20:59:33 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C148C20303 for ; Thu, 21 Apr 2016 20:59:31 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1B88C26696B; Thu, 21 Apr 2016 22:59:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 78E2C266847; Thu, 21 Apr 2016 22:59:21 +0200 (CEST) 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 4A47F266855; Thu, 21 Apr 2016 22:59:20 +0200 (CEST) Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0146.outbound.protection.outlook.com [157.55.234.146]) by alsa0.perex.cz (Postfix) with ESMTP id E15B526683D for ; Thu, 21 Apr 2016 22:59:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentiatech.onmicrosoft.com; s=selector1-axentia-se; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=xvHDEvOyjgKH75odOtCTUbQM4cU6LX0bsQSYUJTerdw=; b=j0af2UAHQLSnAEu2jAkrJ794CLe8TDRKwN92uPTgykFPgHlBbWtYwcqN+q2Jx3bE9PuPDBlR07iSPuac/Q5mc9BBz6REj+fpYwk5mOTrRY/uQ9ziYuuZMxGhRmRGmdMC9G/9Rr86tDp6wspoXSr9ST8qulrGRPYTE0NT/34YVp4= Authentication-Results: alsa-project.org; dkim=none (message not signed) header.d=none;alsa-project.org; dmarc=none action=none header.from=axentia.se; Received: from localhost.localdomain (217.210.101.82) by HE1PR02MB1307.eurprd02.prod.outlook.com (10.169.115.153) with Microsoft SMTP Server (TLS) id 15.1.466.19; Thu, 21 Apr 2016 20:59:11 +0000 From: Peter Rosin To: Date: Thu, 21 Apr 2016 22:58:55 +0200 Message-ID: <1461272335-12428-1-git-send-email-peda@axentia.se> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-Originating-IP: [217.210.101.82] X-ClientProxiedBy: DB5PR03CA0056.eurprd03.prod.outlook.com (10.164.34.24) To HE1PR02MB1307.eurprd02.prod.outlook.com (10.169.115.153) X-MS-Office365-Filtering-Correlation-Id: 039bac77-a535-4dff-4508-08d36a27cacd X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB1307; 2:FzolkiJeg/sgB17RkidMi6VVvQVIxEuxyrmGamY/Qqt9QPjQIUbvHaTXBSN1DSjLopBPZz9NKnmPFL3rt+8QU0z4oNa44dJxQENwRquWMGKRm7pV4yEG/hmXfUBGcEFNgWi7tXCFzyUAcJNjHkTx3HPvidv+WvjXY+Bluqzw5PPUffT5Q/r2MZykc5Hw5xij; 3:+b9lI+lisYxmNfxKy7nYjNVk+fqVM2lABNDVL9EDKSTz9UBSCGy+86BGvo8pdN42QZHtJc7T9RBBNRa/GIgRbh6rf56KsinPoX1eiZDUgT55sZvq7XcvY8io6jRMD9nZ X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR02MB1307; X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB1307; 25:dHMjed6Y3d7tD3PS6saadAO2WmyKdQ4wcVH0kIT95+KR66GdRGD6kRZYornSTzCgpGGqfuUmvNPdB4BOtEk3oRqO5gWsiHT9ZXzLeRA6XsMDYxH//CtIJpDyQIiNhxHgnUvZxkySRdPGAbBxXYMqWzXeo4dE5fbpTJ6KoVgmtlT4DkifRRArADHySmxIlA5ScykMmk5SRACKGph3jLflzENF0xWf0kcxuV0CbhqZwZ2sd9U+6m0t+fdcS1c97pxF93pkYkdMlpVv++BxmkrvIVWW2429IGwPcX4BiX3yaWoFdZWIRY854LAJttC/Bx90NeKDT7OlCjCP3nF/f69x1AlgtWlfn6ddSXCGPaw3yeb2HPZGDx8JjHSOPOTt9fU3QJuHCAYBTl5m3HX0cl0g0hSGzpf4L/hRMeq+vgoZFH5YfbGx67dr+9LQlEto3lMaj7CWE3fA9+AkP75hZRxjmB0IfazuwbM+62N5wjptXUQzN3fhgCg2M1D7F2BSTGBU9Ffof4UP3FoajzXvvyVXOQ2WQwxW6IrSg1kgLAs9lLLiQZTYQrg846SOeUD7+uMrAai3boAfujAOP6Hk2UUb6BuXlAvdgOkZVsbLOswtBuBq/xqwABcFdo1YqQulwimaQgoRW5EuWSnRkmKm9SaLDxMYBsYrg7pBIcRnvPc2gwqHN19DdaI26psfdrz+8d8D8H5aRm4am8RaojtSTUckEM4w7Jvb5apuyB4nTQ0/iu+tWw7x8P5RdZwTZ89HmKIP X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(9101521026)(6040130)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041072)(6043046); SRVR:HE1PR02MB1307; BCL:0; PCL:0; RULEID:; SRVR:HE1PR02MB1307; X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB1307; 4:hYWDZ3WOaAA3NZfJmRzG2xSP4z+jEc4ZzFNXguJk/IoxYDQelk0rbdbV0hsFEkxbu8XnyHpv+vPsjjPs/ZlZhUdqNi01zRm0wrBF2ISfcbYyWNCzJ1Tl+s4FOT7DXA1ircdYBqsyKYr8YlqpQzqDvg1EOTmrR+2BR879gc7xd12KUvjTZreFOWyc4ml3rZb7SrORwKjhcMh1G5UkpR96PyZ/I8k3gi9E1GACNB2coUOz2z2jZE54lKvV23vPxO/2C9oB0KGbcYYYeww3Gx8JC3Xd9fX1qFwZFdCQYKtdzBba5vGv65hJcH002uRwxPF3YkHGhFHU6HgNVa7c1mUTXh488bo3QWLP9oxXILdOn1POjHpHe2nILWSxkEZ4HscFZloWifC+h/vx0tKK/8Gt3MRAMLgMfTIsnAjcxILABfC4pP/a4vwh0jkgnzojp/0lg4iQrXhmoUs7mNCb3VI1Rg== X-Forefront-PRVS: 091949432C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(48376002)(86362001)(50466002)(50986999)(66066001)(50226001)(77096005)(5004730100002)(5003940100001)(15975445007)(5008740100001)(47776003)(36756003)(81166005)(33646002)(110136002)(42186005)(229853001)(6116002)(586003)(2351001)(4326007)(19580405001)(74482002)(19580395003)(92566002)(189998001)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR02MB1307; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; HE1PR02MB1307; 23:TIPy6/5WYkJaqeb4v1lEno38b2WJp+dQfWgJLxN5ny4A6RY7R0IhPsxDoyI3B5gv1aoHemX0Ppen9WG5djTlAuXXaPZ0of6R4+EfDHBhiR2jpUmNXUrKNHNxdvgJy6gFVL+bicYJ4/bwIx6lws4FuidMj1eT446dAeaTNP9hnyKIamfuDCTAjEFACTgwGcXpccYoe3r6EHxW3DJgIKg5DkecJ0lht17WRrXT4oq64lOPosb4gZkBf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LLJ4BlCwKvR1ui6OWxWwZ/uLJDWq5qDA3PY6ilzeNCxyAtKlRLgZ2Fy9ETbpgLF9bNRQaL9I8hVQIULU8AJ1xJD5wjkgk3VMN5rdsAMnfZaLnGJvVkh+DW6t1LScapemI= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2016 20:59:11.0277 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR02MB1307 Cc: Jonathan Corbet , Takashi Iwai , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Liam Girdwood , Mark Brown , peda@lysator.liu.se, Peter Rosin Subject: [alsa-devel] [PATCH v4] ASoC: docs: add clocking examples for DAI formats 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 Provide *our* view of what the rules are for the different DAI formats, so that we do not have to trust external interpretations for this crucial bit of interoperability. Signed-off-by: Peter Rosin --- Documentation/sound/alsa/soc/clocking.txt | 195 ++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) Use rising edge and falling edge (instead of flanks). Also differentiate how transmitters and receivers behave and explain at what edges transmitters change data and at what edges receivers read data. Don't speak about left and right channels for the DSP formats where there are just a number of channels. Cheers, Peter diff --git a/Documentation/sound/alsa/soc/clocking.txt b/Documentation/sound/alsa/soc/clocking.txt index b1300162e01c..7c2bea8124b0 100644 --- a/Documentation/sound/alsa/soc/clocking.txt +++ b/Documentation/sound/alsa/soc/clocking.txt @@ -47,5 +47,200 @@ rate, number of channels and word size) to save on power. It is also desirable to use the codec (if possible) to drive (or master) the audio clocks as it usually gives more accurate sample rates than the CPU. +The below diagrams all have BCLK as the first signal, LRC as the second signal +and DATA as the third. Below that is an indication about which DATA bits belong +in what channel. + +A "..." marking as DATA indicates that there may be more bits that are not +shown. Also, all DATA bits marked X may or may not be present. DAI +transmitters must add them should LRC not match the word size exactly and DAI +receivers must be prepared to ignore them. DAI transmitters must insert zeros +for I2S and Left Justified modes, and preferably not drive DATA for the DSP +modes for these extra X bits. + + +I2S +--- + +The LRC master should put the edges of LRC so that the LRC slaves can reliably +sample LRC at the rising edges of BCLK, preferably by changing LRC in response +to falling edges of BCLK. + +Transmitters wait for a falling edge of LRC, then skip a rising edge of BCLK, +and start the left word (output MSB) at the following falling edge of BCLK. +Transmitters continue with the rest of the word by changing DATA at the falling +edges to BCLK. Transmitters must pad words with zeros if LRC is not matching +the word size, so that receivers expecting wider words do not get noise. +Transmission of the right word works the same, but is initiated by a rising +edge of LRC instead. + +Receivers wait for a falling edge of LRC, then skip a rising edge of BCLK and +read the MSB of the left word at the following rising edge of BCLK. Receivers +then continue with the rest of the word at the following rising edges of BCLK. +Receivers must ignore the tail if more bits per word are transmitted than they +can use. Reception of the right word works the same, but is initiated by a +rising edge of LRC instead. + +See the official I2S specification +https://www.sparkfun.com/datasheets/BreakoutBoards/I2SBUS.pdf + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- +---. .-------------------------------. + '-------------------------------' '----- +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + | |MSB| |...| |LSB| X |...| X |MSB| |...| |LSB| X |...| X | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | + + +Left Justified (aka MSB) +------------------------ + +The LRC master should synchronize the LRC clock edges with the falling edges of +BCLK. + +Transmitters start the left word (output MSB) at the rising edge of LRC and +hold MSB over the first rising edge of BCLK. The transmitters then change DATA +at the falling edges of BCLK. Transmitters must pad words with zeros if LRC is +not matching the word size, so that receivers expecting wider words do not get +noise. Transmission of the right word works the same, but is initiated by a +falling edge of LRC instead. + +Receivers wait for a rising edge of LRC and reads the MSB of the left word at +the first rising edge of BCLK after that. Receivers then continue with the rest +of the word at the following rising edges of BCLK. Receivers must ignore the +tail if more bits per word are transmitted than they can use. Reception of the +right word works the same, but is initiated by a falling edge of LRC instead. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- + .-------------------------------. .----- +---' '-------------------------------' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + |MSB| |...| |LSB| X |...| X |MSB| |...| |LSB| X |...| X | | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | + + +Right Justified (aka LSB) +------------------------- + +The LRC master should synchronize the LRC clock edges with the falling edges of +BCLK. + +Transmitters wait for a rising edge of LRC, and then skip the correct number of +rising edges of BCLK. If zero rising edges are skipped, transmitters start the +left word (output MSB) immediately at the rising edge of LRC. If at least one +rising edge of BCLK is skipped, they start the left word at the following +falling edge of BCLK. The correct number of rising edges of BCLK to skip after +the initial rising edge of LRC is such that the LSB is ending at the following +edge of LRC. After the MSB, transmitters continue with the rest of the word at +the falling edges of BCLK. Transmission of the right word works the same, but +is initiated by a falling edge of LRC instead. + +Receivers wait for a rising edge of LRC, and then skip the same number of rising +edges of BCLK as the transmitters, and read the MSB of the left word on the +first rising edge of BCLK after that. Receivers then continue with the rest of +the word at the following rising edges of BCLK. Reception of the right word +works the same, but is initiated by a falling edge of LRC instead. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- + .-------------------------------. .----- +---' '-------------------------------' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + | X |...| X |MSB| |...| |LSB| X |...| X |MSB| |...| |LSB| | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | + + +DSP mode A +---------- +Transmitters wait for a rising edge of LRC, then skip one rising edge of BCLK +and start the first word (output MSB) at the following falling edge of BCLK. +They then change DATA at the falling edges of BCLK. When the first word is +finished, transmitters follow up immediately with further words. + +Receivers wait for a rising edge of LRC, then skip one rising edge of BCLK and +read the MSB of the first word at the following rising edge of BCLK. Receivers +then continue with the rest of the word at the rising edges of BCLK. Further +words are following immediately. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- + .- .- + -' -' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + | |MSB| |...| |LSB|MSB| |...| |LSB| X | |...| | X | | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | 1st channel | 2nd channel | | + +LRC examples for DSP mode A + .---. .---. +---' '-------------------------------------------------------' '----- +-. .---------------------------------------------------------. .--------- + '-' '-' + + +DSP mode B +---------- +Transmitters start the first word (output MSB) at the rising edge of LRC, hold +MSB over the first rising edge of BCLK, and continue with the rest of the word +at the following falling edges of BCLK. When the first word is finished, +transmitters follow up immediately with further words. + +Receivers wait for a rising edge of LRC, then read the MSB of the first word at +the following rising edge of BCLK. Receivers then continue with the rest of the +word at the rising edges of BCLK. Further words are following immediately. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- + .- .- + -' -' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + |MSB| |...| |LSB|MSB| |...| |LSB| X | |...| | X | | | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | 1st channel | 2nd channel | | + +LRC examples for DSP mode B + .---. .---. +---' '-------------------------------------------------------' '----- +-. .---------------------------------------------------------. .--------- + '-' '-' + + +Inverted Clocks +--------------- + +The above diagrams show normal BCLK and LRC clocking where DAI transmitters +change DATA on the falling edge of BCLK and DAI receivers read DATA on the +rising edge. For inverted BCLK it is naturally the other way around. Inverted +LRC is just that. + +Left Justified, inverted BCLK +----------------------------- + +-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .- + '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' + .-------------------------------. .----- +---' '-------------------------------' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + |MSB| |...| |LSB| X |...| X |MSB| |...| |LSB| X |...| X | | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | + + +Left Justified, inverted LRC +---------------------------- + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- +---. .-------------------------------. + '-------------------------------' '----- +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + |MSB| |...| |LSB| X |...| X |MSB| |...| |LSB| X |...| X | | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel |