From patchwork Tue Apr 19 10:11:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 8878681 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 190A99F39D for ; Tue, 19 Apr 2016 10:12:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4E6022026C for ; Tue, 19 Apr 2016 10:12:13 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 2796620225 for ; Tue, 19 Apr 2016 10:12:10 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 83EED265FCB; Tue, 19 Apr 2016 12:12:03 +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, NO_DNS_FOR_FROM,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 C236F265B6D; Tue, 19 Apr 2016 12:11:54 +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 84222265CC8; Tue, 19 Apr 2016 12:11:53 +0200 (CEST) Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1on0106.outbound.protection.outlook.com [157.56.112.106]) by alsa0.perex.cz (Postfix) with ESMTP id 7F7C126581B for ; Tue, 19 Apr 2016 12:11:48 +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=c3T7l26B4f9t2Gma/l3/tCcXmexpKCz1YekOZhLJ36M=; b=N5ECwBMGM2EPr+6LHN3V4Op+YrM9bmwko1xabm522g+EwLPLnYK1UtD4yw3xwd5yIN121qRbjO+PcBzw5z588ZyQODtjAFOmgZXNRAwqNW1wXFUYOw/5JvWQ9XdWAmF9BCqz2vAZ+9RoI4NhjZVx6wZeJfQqwZmrhNGLkbocBiI= 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 DB5PR02MB1301.eurprd02.prod.outlook.com (10.164.177.147) with Microsoft SMTP Server (TLS) id 15.1.466.19; Tue, 19 Apr 2016 10:11:45 +0000 From: Peter Rosin To: Date: Tue, 19 Apr 2016 12:11:28 +0200 Message-ID: <1461060688-19410-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: DB4PR06CA0024.eurprd06.prod.outlook.com (10.160.40.152) To DB5PR02MB1301.eurprd02.prod.outlook.com (10.164.177.147) X-MS-Office365-Filtering-Correlation-Id: ba2b39e0-5d35-49b9-af07-08d3683b03ec X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1301; 2:zhOzXqPatZyh97qLkFfCHwsoC9e8iTwzBkyyttVtN5Ry/vbK8ta82KY3/OfF7I5CFuvu8TWoRv0yYTl1CpdB36djKnNaAnTvmlrjA2JKjwh/tYAClqUNC0LOBLCfZh1kR88YnxfWrt+3/ihd4HIsOjvHvKF5KydrAqpaNMLgikhtT4wCuiw9AUeWZdfOlXHx; 3:PfSzw9u0oIxRGK+9sp3njOqlV7thk7MLtMw+PW2gualiYMn4TEweIMp7FHmGK1K2yg7MeA3UFLOT0u0FclFMopf5HFhiHqi4lSUlh8uA4iyuGZPaP7EEwnVQHbhL8aNq; 25:d4HigHV1HaqHwdM5Talgc3zJVx+moIBcnZ+J/q9Gm10ZZTyfkVENTzbg30Fe/+jUDgpi2eLdYJQUEQIUZLS0oxy4rF5qI5lOmsC6XP15qzfcxU7YnbTnwkDfezBRdu2I0SaokO6uPc65ZBqmxQnlTsF+cB0UPPkPKklLQ2gO59z2Dg4lIzlydSuLnYjkwCDBrqc3me17erTX2zuSB9yLCAjgqU5Nkeut6Zl2yQppun2Si9I10CykR2taREsQU1SfuYphLNsaOe4iJ7dVkbYfktbkk3ajhJ3Cf8jH4wXX6UU7HUyZmPGrBdcn0olS0LJ51vlhfEJEakIuxWNjuVhImg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR02MB1301; 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)(8121501046)(5005006)(10201501046)(3002001)(6041046)(6043046); SRVR:DB5PR02MB1301; BCL:0; PCL:0; RULEID:; SRVR:DB5PR02MB1301; X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1301; 4:qxUef5T469E6cODDOpujt/fPjyDBNrLmlqLMs/NrSnZYARQdEPtM699OZ6YWhKnBWGxKI5JlOJX9hV9/jUOKZ+hbFS3JyxYMi4xQ3nLcuk/IDvk/6PfqY07PBHeWfF0Ml9MtdhUAJV3J0DyB04p4R8EdyDfeGYA5gZnO2eWDKwc5DAssdJn3WUzZuTj4Zqm+K5miESarAJOkW4B6Gmd8AoD2xO3QIIh2rwwfZw1RApm9tH6cCMX65R5M9Dmz1XUgYO7MD3UNMoZ+kAcDAZexOQmMH3Oo5OavUmn+Isq8siQXXkYf6ZlHlpxlgVWeWlVRJhWUhBz/TenwMXtiIbcWQphKhNZVWlChIpaI1taFZCCEzMBWn7VK5DqTaZ+Y5GfdUGRUnKwOx/sTyXf9mmD8T3vLE6j+QEE6YjYwNd5Ls9bmnSUuta204hCwoxbgAthHU92VUdmyvWUV0xSGP8wdfg== X-Forefront-PRVS: 0917DFAC67 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(4326007)(74482002)(77096005)(66066001)(5003940100001)(19580405001)(42186005)(19580395003)(15975445007)(2906002)(81166005)(3846002)(586003)(229853001)(36756003)(86362001)(189998001)(5004730100002)(47776003)(5008740100001)(48376002)(1096002)(110136002)(92566002)(6116002)(50226001)(2351001)(50986999)(50466002)(33646002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5PR02MB1301; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1301; 23:bdvH5QVk5jtLnC3dllZ25XBSTvAJzxYF9ajshSq1bqnuzNJREmW7Crmvon5czAuAqNKDE5X/6wPVQo5xCvl4l5A9zxlPvdcKJBD2UQP2eUgzT3WHcXSFkYI6uuNoKhengUtRRK/jQ2BbL2aWr0Ms1L/SChkBjGBb5KriwC+XwOGciZHWqqe1qOcYhVXeLusYX0DPxFGev3inffxBP0t8UQKNwG/von7YrNX7u10fPqQq8Q9u2G26QI/tIW2bbHkbapRqXocdrDRnA+hRtHsWLcTQopJJoWWeJjj1x42geZX4qvGkgu+R7/Ojuz4utPaBlCcYpfaRFWh6KtZnyv8cHZguudCcSwehtZAMEKg2p7Fz2MZb2yApQCU40KfwlFunGwcI3sOAA2hqf9sdFnBaYSUJQ2uZiyYkkU4H2rlo9QM7hLb4QJuVsJCabEP4InrjUkzv4/9UfXwVfdPR9Ts4RF0yvodtXatWpXT1ZO9Y188CXT7iRTX+sQNj/d6fOtYLWy68R+FnphPtoW6I3M+G/xfW+o/kSoCrgpF2s1BXdYQzwoHJqJWwPy8RKQHhxf5xdH90CMrhHjw1XuoYr9AFuU8gGgbEkp7h9920cVcWuyEyankdi3LpBl1EmF0SXh0YVoKRHilRVqCDZFdjvIosyHdFCZ98hBlP9MZCK9M0qhuUIdH1B1O3XsXV46/Kem9PCq0M7dw7R4fHo1kVburgwbSX1Un03S27rf/Tpfo1olYyihsuzNuL8iYdmWmV1lLeXhWJfOOy1Pgy0Zg4OcFscTzRa0mJ9GIEfffarnvDCbnWWpyHALMaD0gU7wcDybJ3UJ3nZgb9B2gKOX1gBkYqvHZXt3noDuaLIazsnnZpawXdpoU2cxoqDpGExxQYKcUksMXOGUJKOhvUIAVarCrkixkQVN+MaZvrtMzoIbCHy3Q= X-Microsoft-Exchange-Diagnostics: 1; DB5PR02MB1301; 5://cBSrrt9lPd5hDA0DU6Nm0gDoJETfRFfv3ezJZfJx1U4wl5x2bBkYoEf8UAOX4mIl/TNhJgpycH5H6eBqdnwjfsRFMefCXm2wnz10tjQAV7+Y1gIYpE9ro7KXZcNPWrRP8jGlTz1iQlKS0KZ7AAAJb7sLWEQ1dpKG/D4/t24aefF7a6Tj5Yvi0RWK6Tw0M6; 24:DtjGAG86/VHm35uTm0QP+HC7y5gCRErdJ5qBZCKduv2IWd43qNJmi6WrS/6K1KvaNvdfzptokF7128hMycG/ljwT+o+JhL9LieqQnN4MFZg=; 7:T/0lriPjsP3yK+T7SL3BsF5SpXojS+3zydHxFF8skwRRrjZh7rJzEBjMxsDOimWGkXshcmTVDhETmP9enx46iPRWXNyWC+7t9C+01+8QtPgucDgw24qRlQFE6ypq8nWHKHyw3krDhC5/vF9B7SdltZReidizzqRyl9qXRbLs6xh3FGDQ87zrL7oiiS7pKDs9COMHEyHscpw9U5+fViYcmDQbFxP4vxghamPTTdrt9Eg= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2016 10:11:45.6167 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR02MB1301 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 v3] 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 | 146 +++++++++++++++++++++++++++++- 1 file changed, 144 insertions(+), 2 deletions(-) Changed PCM mode A to start left word one BCLK after positive LRC edge. Added link to I2S spec as indicated by Mark Brown. Cheers, Peter diff --git a/Documentation/sound/alsa/soc/clocking.txt b/Documentation/sound/alsa/soc/clocking.txt index b1300162e01c..7eb02f0758e7 100644 --- a/Documentation/sound/alsa/soc/clocking.txt +++ b/Documentation/sound/alsa/soc/clocking.txt @@ -47,5 +47,147 @@ 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 + +LRC should have its flanks synchronized with a negative flank of BCLK. +The left channel word starts one BCLK cycle after a negative flank of LRC, and +the right channel word starts one BCLK cycle after a positive flank of LRC. The +words start with the MSB. Receivers must truncate words if more bits per word +are transmitted than they can use, and transmitters must pad words with zeros +if LRC is not matching the word size. Also, see +https://www.sparkfun.com/datasheets/BreakoutBoards/I2SBUS.pdf + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- +---. .-------------------------------. + '-------------------------------' '----- +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + | |MSB| |...| |LSB| X |...| X |MSB| |...| |LSB| X |...| X | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | + + +Left Justified (aka MSB) + +LRC should have its flanks synchronized with a negative flank of BCLK. +The left channel word starts directly after a positive flank of LRC, and the +right channel word starts directly after a negative flank of LRC. The words +start with the MSB. Receivers must truncate words if more bits per word are +transmitted than they can use, and transmitters must pad words with zeros if +LRC is not matching the word size. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- + .-------------------------------. .----- +---' '-------------------------------' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + |MSB| |...| |LSB| X |...| X |MSB| |...| |LSB| X |...| X | | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | + + +Right Justified (aka LSB) + +LRC should have its flanks synchronized with a negative flank of BCLK. +The left channel word end right before a negative flank of LRC, and the right +channel word ends right before a positive flank of LRC. The words end with LSB. +Transmitters must pad words if LRC is not matching the word size and the +transmitter and the receiver have to agree on the word leghth. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- + .-------------------------------. .----- +---' '-------------------------------' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + | X |...| X |MSB| |...| |LSB| X |...| X |MSB| |...| |LSB| | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | + + +DSP mode A + +LRC should have positive flanks synchronized with a negative flank of BCLK. +The left channel word starts one BCLK after a positive flank of LRC, and the +right channel word starts directly after the left channel word. The words +start with MSB. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- + .- .- + -' -' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + | |MSB| |...| |LSB|MSB| |...| |LSB| X | |...| | X | | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | | + +LRC examples for DSP mode A + .---. .---. +---' '-------------------------------------------------------' '----- + .-. .-. +---' '---------------------------------------------------------' '------- +-. .---------------------------------------------------------. .--------- + '-' '-' + + +DSP mode B + +LRC should have positive flanks synchronized with a negative flank of BCLK. +The left channel word starts directly after a positive flank of LRC, and the +right channel word starts directly after the left channel word. The words +start with MSB. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- + .- .- + -' -' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + |MSB| |...| |LSB|MSB| |...| |LSB| X | |...| | X | | | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | | + +LRC examples for DSP mode B + .---. .---. +---' '-------------------------------------------------------' '----- +-. .---------------------------------------------------------. .--------- + '-' '-' + + +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. Note that DSP mode A is compatible with DSP mode B with +inverted LRC, and vice versa. + + +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 |