From patchwork Mon Apr 18 13:25:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Rosin X-Patchwork-Id: 8872321 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 5FB349F39D for ; Mon, 18 Apr 2016 13:25:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31D7020251 for ; Mon, 18 Apr 2016 13:25:48 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 8A47D201E4 for ; Mon, 18 Apr 2016 13:25:46 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 6DE19265882; Mon, 18 Apr 2016 15:25:45 +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 8A2E226519F; Mon, 18 Apr 2016 15:25:37 +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 A86F8265357; Mon, 18 Apr 2016 15:25:35 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0119.outbound.protection.outlook.com [104.47.0.119]) by alsa0.perex.cz (Postfix) with ESMTP id B4BA3265112 for ; Mon, 18 Apr 2016 15:25:29 +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=e+xvUkDGpC41nAw8EDeJslgDWHbw9mL/+9zQbrQwNXE=; b=hkUWiVJ+aYBuH+qX3JdeXadaNRw2odGbqYhRmqc6rP1dnFsO/fBoyKTJXXS64+gpmHO65teS89+54nckLg7wglAVX9qgoAxpiNu6cPG7U0c8DOHyik3idI2JlVjkd24P98VCsTMDsdNBKZCZL/UdOa7FJUIE38LNaO3DFlPMJuw= 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 AM4PR02MB1300.eurprd02.prod.outlook.com (10.165.241.150) with Microsoft SMTP Server (TLS) id 15.1.453.26; Mon, 18 Apr 2016 13:25:27 +0000 From: Peter Rosin To: Date: Mon, 18 Apr 2016 15:25:09 +0200 Message-ID: <1460985909-31857-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: AM3PR02CA0007.eurprd02.prod.outlook.com (10.163.180.17) To AM4PR02MB1300.eurprd02.prod.outlook.com (10.165.241.150) X-MS-Office365-Filtering-Correlation-Id: c1fd9f74-c4e6-45d0-3c0a-08d3678ce846 X-Microsoft-Exchange-Diagnostics: 1; AM4PR02MB1300; 2:NL+cLOY4UPk9M+Clmx/f1ExeZGaLopmJ0SsEkmUHPnl6fQCyqMmgZHaRx3WyV07ab48+SvRA6tiI30yQAPrVeuNwaSz9tFTlk3YyTT+WSqkpt+umCUgLnTbaWAt+Aajpx/C7zF0CfSL9bYs0E2QylnZXLMz6hlIFI4OWXf2dYh18AZb5UAtPTsSMT7aAxCFe; 3:ONta30jkAB4eWu9vvZZvKU7xa769knWfZSHKTBDaw5mypJbDlgXQSOeYULSXMw5XgSEpKV0ObHYIJUDdP/D7TU2PVQxyq+gNd38F9229icHuqkrSDNbghEdnWg4+RbND; 25:JEt1i0S1R9tPgEuMFT4zivjDAQ/uV+a7JLzAYjLv1oGc6JtX//OrGKc+znQOfrzaim0rlQGH8HkbPLNJ/dZk+58Piklgfp2wbBc8yc2fWl82nexACrL+oskNI8gpMhYBVABqYGVmce4eC5i37pP7ucMs59PumsmGwReM9rEi0G6nBH6/GkZuvu4gMXx3xPeCgq2pZVCbMSi+aNG0IejmWGy2mtRjlrtYeJUxc0oZEqnYj0hHJNy2p3N/kIWI9BxlwytFgmRM8h0IVgG9QQfZf/JjURUDDyJczXIOLKHTBtwau8SCnHkMyOjy1GN2erM9Gz1GYjSeZtP2pLCU6maUCg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM4PR02MB1300; 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:AM4PR02MB1300; BCL:0; PCL:0; RULEID:; SRVR:AM4PR02MB1300; X-Microsoft-Exchange-Diagnostics: 1; AM4PR02MB1300; 4:7ZL44YJC3Vm44uh8dVXFV6S0Wneb8pCDGIrEi9vigGoHAV9qlbdHq5PpKD9/wtvD3OSDAKegQsevl0NV+2GUCJLPul+iFc90iVGrLq2b0dnhaayBeNJ6Wtfyxj1+4rh6878RVuVIfDYecmWMBc514cg536N7f1yRGlYYVhJteQOVu04TaIUf6jE42HEb2RXEbJ3B3bdgZ2bTZBbYHfriDX8cSpbHjn4K2JXjQ8L6uP9TAZAq9ZiGp6UpV9yqEpDN8o1yMsNh08u0ktROy3Ooap0EE+1jhVEFJKYp26uJHiFmbH91EwY5qOv6BOheXQ/7S4nO8aCjc0qZzxOzDPlP1lDUuP+MGEpMmSE0UqAMJxqI+cZtWXqErH7+w4OaCEaZqPcmcyc2Y8vvyP859TVbcUwKJ7833lunYL6EujKJ1QxPLaksDPI86ZMj4sR1MLNRYPogWEqROZDno1cNF9IaSw== X-Forefront-PRVS: 0916FC3A18 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(19580395003)(1096002)(586003)(36756003)(19580405001)(4326007)(92566002)(47776003)(66066001)(33646002)(229853001)(81166005)(50466002)(6116002)(5008740100001)(3846002)(48376002)(2906002)(189998001)(110136002)(86362001)(2351001)(50986999)(74482002)(77096005)(50226001)(42186005)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:AM4PR02MB1300; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM4PR02MB1300; 23:/VZk4sR/1Ch/Jmbx7IspJPG0v8eZzrs1Gdr0AxWa1SraS7aaZrwd+8I/OIJPId0ZyIHewCz+7P6taMX/fnAFVd+wvW6p1iRebch2CsYf2id78FB73lkiJrcsz9j2p/gguGh7N1ttxe+cnfhvxOSm8K27D1jnGLX2twdVGJ1RAzsMKyocY4hSbgPAbxO0pbSRkRzxt94572XnC5PoDQAKLclsOo5ccfrscH0ukNBkKhfKJuTRXaeagV2FpGCttoccI0zcvFfGEX6l2CMaGj9Yr+xHWGtiDt7LYz+I1QJxxHMYVojk4b9uISo9CeLmO6kYFdtj7g4uglGNdeFakUugpWFScZcjrtq34i/wcCXPR3wyC8hIOnGcsG9yDkSZCKXHCX42gDxgrxmmVpYdMZVtGsy5Dt0k0qT5vyj59IaZ2NwPo8SGkmHik0z5cpClj0g/sAuN9fmAZ1vKsxXmL8GM6PuvIj+88lck6kD1HUzwaGZE3DRs2dXyJGmSUCc0MP68pkR4DQtiDwjAxbHyoHTGXneAGJThMNZTpWo9gWYz5vObTAPyT047NjCobUWSCzB1bi/sMWzARxbNyWkUxLPl+bvTlDHA64NXv1wJNG7zZAZdf0pCOkHlcjTYMzHPpxvQYLdrn9ajcqKZiv0IpYYjPJjSyjDZOcZUaWhAt3cGdr5zKhWa2WvBmip7zthguLcX4dIW/UDpY6hNF/B62NSPL4IcaTLfKpuS7EBxdY1tMEe48ISv4dPkt56i92xiRvUW2MbQKYCQSErpnWg4w89gxpzIIfFbHKyfbE4Qv+LwkRoih56wPJ4TPO8dgpcCDlAa0UZTkbCN3+WUKeOQ/vjieg== X-Microsoft-Exchange-Diagnostics: 1; AM4PR02MB1300; 5:0E68Xa97fYNr1YSRs4zTLgCsmhAj0HsAUQz7pGa5PExoHH01heRwqdCYui02ASpUMh/XV345hHdBqzt4jxLeYsMA4Enj/bafA47rJVEg6mrrh3pda5GfekVw94cqeheiM53qF8qnzcz62+Pe0ry9kA==; 24:mgI8qIhWhxn/7cCnD8gv8faQyt1OX2bAsXHkeA4rQ/0QyQKB5sHPrTxRiEN0jjflqWD9r0ZPKsXsFb+FEIslSOY+KnglwgQTDamnKG/aMQ8= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2016 13:25:27.0620 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR02MB1300 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 v2] 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 | 145 +++++++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 2 deletions(-) Now with some words on each format as well. Cheers, Peter diff --git a/Documentation/sound/alsa/soc/clocking.txt b/Documentation/sound/alsa/soc/clocking.txt index b1300162e01c..e74e91bbee94 100644 --- a/Documentation/sound/alsa/soc/clocking.txt +++ b/Documentation/sound/alsa/soc/clocking.txt @@ -47,5 +47,146 @@ 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. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- +---. .-------------------------------. + '-------------------------------' '----- +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + | |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. +Receivers must truncate words if more bits per word are transmitted than they +can use, and transmitters must pad words if LRC is not matching the word size. + + .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. +-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '- + .-------------------------------. .----- +---' '-------------------------------' +---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.---.- + | X |...| X |MSB| |...| |LSB| X |...| X |MSB| |...| |LSB| | +---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'---'- + | Left channel | Right channel | + + +DSP mode A + +LRC should have negative flanks synchronized with a negative flank of BCLK. +The left channel word starts directly after a negative 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 |