From patchwork Thu Feb 25 05:55:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 8419411 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@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 C188B9F372 for ; Thu, 25 Feb 2016 05:55:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E27220253 for ; Thu, 25 Feb 2016 05:55:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 03C262034C for ; Thu, 25 Feb 2016 05:55:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759507AbcBYFzr (ORCPT ); Thu, 25 Feb 2016 00:55:47 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:49957 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932248AbcBYFz3 (ORCPT ); Thu, 25 Feb 2016 00:55:29 -0500 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 25 Feb 2016 14:55:26 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 741FE50FA3; Thu, 25 Feb 2016 14:55:26 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 5373C48014; Thu, 25 Feb 2016 14:55:26 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 51F15480A4; Thu, 25 Feb 2016 14:55:26 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id QAT21165; Thu, 25 Feb 2016 14:55:26 +0900 X-IronPort-AV: E=Sophos;i="5.22,496,1449500400"; d="scan'";a="205149831" Received: from mail-hk2apc01lp0215.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.215]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 25 Feb 2016 14:55:25 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=kMEZdfm5wQyZ206NyAOwuvLnJ6IU905qf+ii3gCnyMw=; b=UamBtf5nadIXVldPj10n/vTUru4WblpVmK60qx/xGkfI/rouYyI2lshr4CgI7uEbqypcoLyY9OdJhX2tj3rfyJKiF0XuS23GMEx62laHIdvd/tFKnNU838GALN/yfzpjxbRzESijo6tku7sk4+FBgA+gig1/yfY4qnckBO1B/+8= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by HK2PR06MB1010.apcprd06.prod.outlook.com (10.161.187.27) with Microsoft SMTP Server (TLS) id 15.1.409.15; Thu, 25 Feb 2016 05:55:23 +0000 Message-ID: <87y4a95oe2.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 6/6] ASoC: rsnd: add CTU support User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown CC: Simon , Linux-Renesas , Linux-ALSA , Liam Girdwood , Laurent In-Reply-To: <877fht7376.wl%kuninori.morimoto.gx@renesas.com> References: <877fht7376.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Thu, 25 Feb 2016 05:55:23 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: OS1PR01CA0045.jpnprd01.prod.outlook.com (25.164.162.27) To HK2PR06MB1010.apcprd06.prod.outlook.com (25.161.187.27) X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1010; 2:p99tSJ+g3roXXIt5VvslmlgGZ/lxDi5EpGkSpWsocWN4rGNgIQXhdG2jyTCvVVVZacJ9jNaon8RAt4pome3eh0Sdop9N9wk8s8ZhzsnNSKebnwL+An35QmLuylUUv652gFyeV3JsE+56gtlbQl715Q==; 3:0GdVIeIyfkR2FuXvd9kAHV3YQuD8j5SGSUP9pj9f8mYB1IODeqxYGAEabPjIDxvFfy3iWIUtRy8ryJJnq7vznv7ZZppcXmTSV3WZskNOgkMZYP/GZFiUj5Paq7FjRwKF; 25:YtdFcYy/ApSuZePFKZuZTuikhWDKWKNurx8uy50qw+3sh0wlVYdOgrNROippI8sGZJ/fvoUbcBkYkomF8UjZojf6baCjoge4pxOQVAUxrpOA1yJuU53cptR86+lLpJFqAV589JbgOqToub7RkccXrjUDd0EIbbOKM0QsDJWM+Ib5L+Hm/EUCFZL4sonmHKGrlKPFFbD9Amuh4jexesp2SXXzHzAiE0PGISkw/SUfHNxZFRUen77Skw3hQbLkoB6jrqVwdAeXT4kZk0/63NXSZZauOhqZZ7H4TO+wuJ9a4Rw/HXBISJ+E/ZPC/3BySLGTGtDq+vBqslo6kr8LiplrIA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HK2PR06MB1010; X-MS-Office365-Filtering-Correlation-Id: 3ff60980-71cc-4fcd-5978-08d33da840fd X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1010; 20:JiIXSkzxOCkolqrELD+zMOZFPj6nl6D3fIYvFFHYMtxTEgPb0jj9LNG4uo/PK8pyq7ykU9anNMNI0aW95f/Wl7gE1GFBI2MCKIqNM3ENudQxzgfZp3nKtdsXNRW8ve+7FdgCB/PJM8QN5zgSVXUPcSHYg4yRZlyZhdS2hhwWuJnZthzW830rdPr45sIMzAP3nNVfa2caKCg4Sk+un9qk1NnIGQikKemZ9OnWC3RE04/9DEQVTMo8ku00b54z1enQ76sCMDDfq4OzxuRpuGEaY90iqtrfz1/tWCojxcT8ElT/aAj0/AAeFzOyuz0wliF9FsCimgoB6qzR9X3mheylGuuC7TKtWc0Y+HpJwVlu+TO9vypk0HGlfE3BO+4PkaXuSNTnV7wtVugargEXp88BMHUHiFh8rJX7BrwkAoRbVam94DXANsaK0iRzVPstBxaWLf+sMJpelgDktSB1waSf1D7poDiDARw1Bci9XVdQJeTdDNQRXlCOx0mpebl+YUyM; 4:+YNe8Pe18TpgA6siPX4fI7RZa/4BZIQDmcTyeNHX3qhDTqdDJbe1jkKFgGfwJh/VHa1LclFtD9bRgZnq4FUl9Wcm4nMr6Tuyjtt5z+ZoncdUbDSnMJdUN6muFY34+VyoiUKIjyOj38CwWc8YjiA0+xdL1RV/jp8VcLijI9JyO0gqxnNAcRSp0eXiL9ErAur3XcPjMjcomqEsNksRbXz0ZrE+SGG133zWmUarCiRihQCymGbzhlw94g3ekoiXsOyP7F0VIlqSP483ZQoTDsGHrx9KMAZEMO7zdBqisEiekn0cg1dHXEYcD0uuPPZGoHj9h7FzrXuyp0qCP75F4gxWJUtOrxcS5/3KH6xhjqiWIFTSxuJ08/+PaH3ejEpIw8Lk X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:HK2PR06MB1010; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB1010; X-Forefront-PRVS: 08635C03D4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(83506001)(42186005)(46406003)(5004730100002)(53416004)(2950100001)(23726003)(5008740100001)(77096005)(33646002)(1096002)(66066001)(19580395003)(40100003)(2906002)(76176999)(50986999)(122386002)(4001350100001)(54356999)(5001960100002)(50466002)(110136002)(87976001)(4326007)(189998001)(19580405001)(92566002)(36756003)(229853001)(47776003)(575784001)(86362001)(586003)(3846002)(6116002); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB1010; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB1010; 23:SPa18/hh3sQGJdLJO7zmDcqy/b390yJejOb2/Pef3?= =?us-ascii?Q?y9dus0gBYWjdR0VcBoc6wosVZFFLiABUPIx1s+MaaZaHl3h+TWxLFktScYKD?= =?us-ascii?Q?F/dTdGkkQWXupI6sbAUt/bU/rLfG3O8uOhupVunjEymPOxuu7kYMhvBQxjTU?= =?us-ascii?Q?DNqR1sTtitedoLb/8XJZy/eAZes9z28xq+jEPIcfNhPpkc6ZzLop8pMtGhvs?= =?us-ascii?Q?9C1MIZbD5EmhuKR6Y4SggPlzE0tV6u34lixego5+a1z6TzYhJADtCrLEwelf?= =?us-ascii?Q?fvj6EU9n6KoZdoboHDOqB96tvbnQNYc0i3B3cyDEte+Ji4Cz53trn0iJ/vCu?= =?us-ascii?Q?j3BSscxsmYP5ifUcHX/Vv9NDjT7JEAT2pZLdB6OCAImhD2yjvQdP2OsK9QFI?= =?us-ascii?Q?syA+oamj2tmLbPsgKEstGlN4COsGUBpJJrgGc8VjeryMhg/FBwmKS83RpQ8k?= =?us-ascii?Q?J8RTTc+Stw2crVodgmELiwpSd0YWeuPWC0Blyp2Qs64S21NRnMwENIWXL8e5?= =?us-ascii?Q?/ZxXDaVbQI55UrepJLn3cxwOF0YSfEHs5m4vP1i3Wmg91RJT0P2x7GMd+kJL?= =?us-ascii?Q?Bs7dWUsIHTJWvgzAmz7U4ULigdTz0CpADz+K3gC8k3laL07ZQwrEZfBtPHo6?= =?us-ascii?Q?JmggUKsJTgmfIGz9os1MYQE/yfEhbofa2mIPnnTxtuQA/J2Zp6Ucbyo+o6QO?= =?us-ascii?Q?z30OUm7GrgXTw13pzekZZoxLqI0NDfgWEjSVGS/OFJ308Xs/ZIy0UUO/VAOS?= =?us-ascii?Q?5aNuGdu0Zx2hREqfnGtTTaOKs226bmtuHYW5/374eHH3R7UaKwwzhE64RU6C?= =?us-ascii?Q?a0lVOWNceiKK6W42YbUsIkyMssXtINk2aLCOuHXHeGB9ZC8eg3ki28+8EW4R?= =?us-ascii?Q?zN+uSjm2t095bhpm8UYChV8zxR3aiIgheJeSdtsXvMgSijn/jSNhyn6QWXg+?= =?us-ascii?Q?l01UJarxI8gxd0DFNbDT8V7oAc32xxohoOTtO0Gi3eNo6yNReOaQsB7vGC8M?= =?us-ascii?Q?YiFBT8N11rEzcAo1o6qZCn4OPuerK3vzpslxR/FjI71gQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1010; 5:hhXf4iaHKUiV69bGnKXBsb8PXJNxNLfvdCbvbyQqhkqa/L1J1vQnfFlMp35bd4kC3lWh+hqK+d+rsTUMEqiJW24goDbCNXFcPF/azQzR7rOhegvRc44pDUkIrUC2AOFJkzLVJ9AOE3tr7KlTVQSQ0w==; 24:/y4g/AI9w14Fl/oqEBb0J0ynZ76tp5GR06i6de3gmX40uuvgP2WT8IdjfmYQGKE0hBnWryiHYSvqRPf2lQ4JOcgKy6hwvLuUiMTTCoqhyP0=; 20:Ch4RuaEizlCJDC/unPWZCrEKwgbidsw68zvaHi6C75bLpLrCaEkK/HrI6TROPHAbHo0u3rTRYi7jvzdIL6aRFx7Eoxwx+Qe4i6lds/JMsSvdEORfW4ZHBFn7kENIAG6KKKFBXlPp+fRqc0AZwv5lOBXl8yzPAlV34ID4pr68iYc= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Feb 2016 05:55:23.6642 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB1010 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto This patch adds CTU (= Channel Transfer Unit) support on Renesas R-Car sound driver. It can Down/Up mixing and splitter. You need to check R-Car datasheet especially CTUn_CPMDR/CTUn_SV0xR/CTUn_SV1xR/CTUn_SV2xR/CTUn_SV3xR for setting parameter. Signed-off-by: Kuninori Morimoto --- sound/soc/sh/rcar/ctu.c | 234 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 197 insertions(+), 37 deletions(-) diff --git a/sound/soc/sh/rcar/ctu.c b/sound/soc/sh/rcar/ctu.c index b326966..9dcc1f9 100644 --- a/sound/soc/sh/rcar/ctu.c +++ b/sound/soc/sh/rcar/ctu.c @@ -12,8 +12,74 @@ #define CTU_NAME_SIZE 16 #define CTU_NAME "ctu" +/* + * User needs to setup CTU by amixer, and its settings are + * based on below registers + * + * CTUn_CPMDR : amixser set "CTU Pass" + * CTUn_SV0xR : amixser set "CTU SV0" + * CTUn_SV1xR : amixser set "CTU SV1" + * CTUn_SV2xR : amixser set "CTU SV2" + * CTUn_SV3xR : amixser set "CTU SV3" + * + * [CTU Pass] + * 0000: default + * 0001: Connect input data of channel 0 + * 0010: Connect input data of channel 1 + * 0011: Connect input data of channel 2 + * 0100: Connect input data of channel 3 + * 0101: Connect input data of channel 4 + * 0110: Connect input data of channel 5 + * 0111: Connect input data of channel 6 + * 1000: Connect input data of channel 7 + * 1001: Connect calculated data by scale values of matrix row 0 + * 1010: Connect calculated data by scale values of matrix row 1 + * 1011: Connect calculated data by scale values of matrix row 2 + * 1100: Connect calculated data by scale values of matrix row 3 + * + * [CTU SVx] + * [Output0] = [SV00, SV01, SV02, SV03, SV04, SV05, SV06, SV07] + * [Output1] = [SV10, SV11, SV12, SV13, SV14, SV15, SV16, SV17] + * [Output2] = [SV20, SV21, SV22, SV23, SV24, SV25, SV26, SV27] + * [Output3] = [SV30, SV31, SV32, SV33, SV34, SV35, SV36, SV37] + * [Output4] = [ 0, 0, 0, 0, 0, 0, 0, 0 ] + * [Output5] = [ 0, 0, 0, 0, 0, 0, 0, 0 ] + * [Output6] = [ 0, 0, 0, 0, 0, 0, 0, 0 ] + * [Output7] = [ 0, 0, 0, 0, 0, 0, 0, 0 ] + * + * [SVxx] + * Plus Minus + * value time dB value time dB + * ----------------------------------------------------------------------- + * H'7F_FFFF 2 6 H'80_0000 2 6 + * ... + * H'40_0000 1 0 H'C0_0000 1 0 + * ... + * H'00_0001 2.38 x 10^-7 -132 + * H'00_0000 0 Mute H'FF_FFFF 2.38 x 10^-7 -132 + * + * + * Ex) Input ch -> Output ch + * 1ch -> 0ch + * 0ch -> 1ch + * + * amixer set "CTU Reset" on + * amixer set "CTU Pass" 9,10 + * amixer set "CTU SV0" 0,4194304 + * amixer set "CTU SV1" 4194304,0 + * or + * amixer set "CTU Reset" on + * amixer set "CTU Pass" 2,1 + */ + struct rsnd_ctu { struct rsnd_mod mod; + struct rsnd_kctrl_cfg_m pass; + struct rsnd_kctrl_cfg_m sv0; + struct rsnd_kctrl_cfg_m sv1; + struct rsnd_kctrl_cfg_m sv2; + struct rsnd_kctrl_cfg_m sv3; + struct rsnd_kctrl_cfg_s reset; int channels; }; @@ -58,51 +124,91 @@ static int rsnd_ctu_probe_(struct rsnd_mod *mod, static void rsnd_ctu_value_init(struct rsnd_dai_stream *io, struct rsnd_mod *mod) { + struct rsnd_ctu *ctu = rsnd_mod_to_ctu(mod); + u32 cpmdr = 0; + u32 scmdr = 0; + int i; + + for (i = 0; i < RSND_MAX_CHANNELS; i++) { + u32 val = ctu->pass.val[i]; + + cpmdr |= val << (28 - (i * 4)); + + if ((val > 0x8) && (scmdr < (val - 0x8))) + scmdr = val - 0x8; + } + rsnd_mod_write(mod, CTU_CTUIR, 1); rsnd_mod_write(mod, CTU_ADINR, rsnd_runtime_channel_original(io)); - rsnd_mod_write(mod, CTU_CPMDR, 0); - rsnd_mod_write(mod, CTU_SCMDR, 0); - rsnd_mod_write(mod, CTU_SV00R, 0); - rsnd_mod_write(mod, CTU_SV01R, 0); - rsnd_mod_write(mod, CTU_SV02R, 0); - rsnd_mod_write(mod, CTU_SV03R, 0); - rsnd_mod_write(mod, CTU_SV04R, 0); - rsnd_mod_write(mod, CTU_SV05R, 0); - rsnd_mod_write(mod, CTU_SV06R, 0); - rsnd_mod_write(mod, CTU_SV07R, 0); - - rsnd_mod_write(mod, CTU_SV10R, 0); - rsnd_mod_write(mod, CTU_SV11R, 0); - rsnd_mod_write(mod, CTU_SV12R, 0); - rsnd_mod_write(mod, CTU_SV13R, 0); - rsnd_mod_write(mod, CTU_SV14R, 0); - rsnd_mod_write(mod, CTU_SV15R, 0); - rsnd_mod_write(mod, CTU_SV16R, 0); - rsnd_mod_write(mod, CTU_SV17R, 0); - - rsnd_mod_write(mod, CTU_SV20R, 0); - rsnd_mod_write(mod, CTU_SV21R, 0); - rsnd_mod_write(mod, CTU_SV22R, 0); - rsnd_mod_write(mod, CTU_SV23R, 0); - rsnd_mod_write(mod, CTU_SV24R, 0); - rsnd_mod_write(mod, CTU_SV25R, 0); - rsnd_mod_write(mod, CTU_SV26R, 0); - rsnd_mod_write(mod, CTU_SV27R, 0); - - rsnd_mod_write(mod, CTU_SV30R, 0); - rsnd_mod_write(mod, CTU_SV31R, 0); - rsnd_mod_write(mod, CTU_SV32R, 0); - rsnd_mod_write(mod, CTU_SV33R, 0); - rsnd_mod_write(mod, CTU_SV34R, 0); - rsnd_mod_write(mod, CTU_SV35R, 0); - rsnd_mod_write(mod, CTU_SV36R, 0); - rsnd_mod_write(mod, CTU_SV37R, 0); + rsnd_mod_write(mod, CTU_CPMDR, cpmdr); + + rsnd_mod_write(mod, CTU_SCMDR, scmdr); + + if (scmdr > 0) { + rsnd_mod_write(mod, CTU_SV00R, ctu->sv0.val[0]); + rsnd_mod_write(mod, CTU_SV01R, ctu->sv0.val[1]); + rsnd_mod_write(mod, CTU_SV02R, ctu->sv0.val[2]); + rsnd_mod_write(mod, CTU_SV03R, ctu->sv0.val[3]); + rsnd_mod_write(mod, CTU_SV04R, ctu->sv0.val[4]); + rsnd_mod_write(mod, CTU_SV05R, ctu->sv0.val[5]); + rsnd_mod_write(mod, CTU_SV06R, ctu->sv0.val[6]); + rsnd_mod_write(mod, CTU_SV07R, ctu->sv0.val[7]); + } + if (scmdr > 1) { + rsnd_mod_write(mod, CTU_SV10R, ctu->sv1.val[0]); + rsnd_mod_write(mod, CTU_SV11R, ctu->sv1.val[1]); + rsnd_mod_write(mod, CTU_SV12R, ctu->sv1.val[2]); + rsnd_mod_write(mod, CTU_SV13R, ctu->sv1.val[3]); + rsnd_mod_write(mod, CTU_SV14R, ctu->sv1.val[4]); + rsnd_mod_write(mod, CTU_SV15R, ctu->sv1.val[5]); + rsnd_mod_write(mod, CTU_SV16R, ctu->sv1.val[6]); + rsnd_mod_write(mod, CTU_SV17R, ctu->sv1.val[7]); + } + if (scmdr > 2) { + rsnd_mod_write(mod, CTU_SV20R, ctu->sv2.val[0]); + rsnd_mod_write(mod, CTU_SV21R, ctu->sv2.val[1]); + rsnd_mod_write(mod, CTU_SV22R, ctu->sv2.val[2]); + rsnd_mod_write(mod, CTU_SV23R, ctu->sv2.val[3]); + rsnd_mod_write(mod, CTU_SV24R, ctu->sv2.val[4]); + rsnd_mod_write(mod, CTU_SV25R, ctu->sv2.val[5]); + rsnd_mod_write(mod, CTU_SV26R, ctu->sv2.val[6]); + rsnd_mod_write(mod, CTU_SV27R, ctu->sv2.val[7]); + } + if (scmdr > 3) { + rsnd_mod_write(mod, CTU_SV30R, ctu->sv3.val[0]); + rsnd_mod_write(mod, CTU_SV31R, ctu->sv3.val[1]); + rsnd_mod_write(mod, CTU_SV32R, ctu->sv3.val[2]); + rsnd_mod_write(mod, CTU_SV33R, ctu->sv3.val[3]); + rsnd_mod_write(mod, CTU_SV34R, ctu->sv3.val[4]); + rsnd_mod_write(mod, CTU_SV35R, ctu->sv3.val[5]); + rsnd_mod_write(mod, CTU_SV36R, ctu->sv3.val[6]); + rsnd_mod_write(mod, CTU_SV37R, ctu->sv3.val[7]); + } rsnd_mod_write(mod, CTU_CTUIR, 0); } +static void rsnd_ctu_value_reset(struct rsnd_dai_stream *io, + struct rsnd_mod *mod) +{ + struct rsnd_ctu *ctu = rsnd_mod_to_ctu(mod); + int i; + + if (!ctu->reset.val) + return; + + for (i = 0; i < RSND_MAX_CHANNELS; i++) { + ctu->pass.val[i] = 0; + ctu->sv0.val[i] = 0; + ctu->sv1.val[i] = 0; + ctu->sv2.val[i] = 0; + ctu->sv3.val[i] = 0; + } + ctu->reset.val = 0; +} + static int rsnd_ctu_init(struct rsnd_mod *mod, struct rsnd_dai_stream *io, struct rsnd_priv *priv) @@ -164,12 +270,66 @@ static int rsnd_ctu_hw_params(struct rsnd_mod *mod, return 0; } +static int rsnd_ctu_pcm_new(struct rsnd_mod *mod, + struct rsnd_dai_stream *io, + struct snd_soc_pcm_runtime *rtd) +{ + struct rsnd_ctu *ctu = rsnd_mod_to_ctu(mod); + int ret; + + /* CTU Pass */ + ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU Pass", + NULL, + &ctu->pass, RSND_MAX_CHANNELS, + 0xC); + + /* ROW0 */ + ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV0", + NULL, + &ctu->sv0, RSND_MAX_CHANNELS, + 0x00FFFFFF); + if (ret < 0) + return ret; + + /* ROW1 */ + ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV1", + NULL, + &ctu->sv1, RSND_MAX_CHANNELS, + 0x00FFFFFF); + if (ret < 0) + return ret; + + /* ROW2 */ + ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV2", + NULL, + &ctu->sv2, RSND_MAX_CHANNELS, + 0x00FFFFFF); + if (ret < 0) + return ret; + + /* ROW3 */ + ret = rsnd_kctrl_new_m(mod, io, rtd, "CTU SV3", + NULL, + &ctu->sv3, RSND_MAX_CHANNELS, + 0x00FFFFFF); + if (ret < 0) + return ret; + + /* Reset */ + ret = rsnd_kctrl_new_s(mod, io, rtd, "CTU Reset", + rsnd_ctu_value_reset, + &ctu->reset, 1); + + return ret; +} + static struct rsnd_mod_ops rsnd_ctu_ops = { .name = CTU_NAME, .probe = rsnd_ctu_probe_, .init = rsnd_ctu_init, .quit = rsnd_ctu_quit, .hw_params = rsnd_ctu_hw_params, + .pcm_new = rsnd_ctu_pcm_new, }; struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id)