From patchwork Thu Feb 25 05:53:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 8419161 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@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 8A54AC0553 for ; Thu, 25 Feb 2016 05:53:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F23092028D for ; Thu, 25 Feb 2016 05:53:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 468C220382 for ; Thu, 25 Feb 2016 05:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759957AbcBYFxK (ORCPT ); Thu, 25 Feb 2016 00:53:10 -0500 Received: from relmlor3.renesas.com ([210.160.252.173]:25269 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759400AbcBYFxE (ORCPT ); Thu, 25 Feb 2016 00:53:04 -0500 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 25 Feb 2016 14:53:03 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 14CCF5F3EA; Thu, 25 Feb 2016 14:53:03 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id ED21E8002D; Thu, 25 Feb 2016 14:53:02 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id E45CA8002F; Thu, 25 Feb 2016 14:53:02 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id QBE30558; Thu, 25 Feb 2016 14:53:02 +0900 X-IronPort-AV: E=Sophos;i="5.22,496,1449500400"; d="scan'";a="206421163" Received: from mail-sg2apc01lp0243.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.243]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 25 Feb 2016 14:53:02 +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=igdJ0FN3FjdgniThy1iw0zuQaUg5N0nVOZcyxUKFGcI=; b=etleKA6G087M7gY9yIRQLE5tSrsGW2eSgKAKai8QQKxCS5ufFeBYEC3WxPuUjWSy5JgJgFmko8WgEEpW5/SqcfRzUsIGmPhthT/d+pUuDqxW5Hv5f5dffMStLrzGJlZQANTpzSbVyYJgq0GUk9EuIauL//1F3Xf68vjqkaXPoK0= 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 SIXPR06MB1021.apcprd06.prod.outlook.com (10.160.238.156) with Microsoft SMTP Server (TLS) id 15.1.409.15; Thu, 25 Feb 2016 05:53:00 +0000 Message-ID: <871t81732m.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 4/6] ASoC: rsnd: add CTU basic 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:53:00 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: KAWPR01CA0008.jpnprd01.prod.outlook.com (25.161.24.18) To SIXPR06MB1021.apcprd06.prod.outlook.com (25.160.238.156) X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1021; 2:XlK44nGflV+U6F2OFG/8bfX3jZt0qAiqeTFa8WPDFO/yY45Sqwg7hMddfuAJcWj2Qus2YyV3eKFZBieUA3VhoFRnlShlHZyzCaj0gDqlUdz5KH6F4MBgUW2ODh4KI4qI/sOV0Xd/3gGfkDKQ3VuHOQ==; 3:nXulRpdHD5CnxyDkzecz2PL+wtZF+8gcSnxIcTokAK9otnwAwAwdC4m+5Ukxwt5q3OBPXssQXOObmoBvQlkKC+uHhH3LDKdDrQ/bP0Zszh8jI+3fOF6WFOdp+/bXMAuU; 25:hN5rNkUc16cRortqKcHUXh/h6nzXnpMMuaufrrqoKu/RLeBR5ihukPSrQQNYJcmyWPBRgue3Il5dSZWpP2m43G8cgDVhzevaoZfFnFLvkTWF7wGj521lKC+ho7KkTCnRf6MMtPk/kJgio7xJ90Va4lXr1WoPD+swq6VVmQWK2QtLRpQHPNbjCfxzOZp2jd68NMOtP70Gd3QlN+FCA9h0i4UThY/bxCn117/AHB14UZXG9Bl4aOCQvVsRe5HgzI1e94MUysKBHek2klk0X/VzO+GOZvk6S90yW5SBVR4jHV+bpaQmlRwf4zLWvcp/oy6tErH9fpBhpCUkYOnl2PxZ3Q== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB1021; X-MS-Office365-Filtering-Correlation-Id: c3fd3839-36c8-447e-a4c9-08d33da7eb75 X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1021; 20:3FL1f1hfXSRAVepSKC3EWAOLwZmuQ8QYXBc82iq1qfrR3k125QsKsKWnTidP5yOuqZUWbNM45lbXT3+UGXEJEvvRUU8CV0UTBfeATbSNT6faTNPUaXkh2HFYOw6qq56/Ql/6Z7KYk1adj8kwwh0n7mEGIrLNPTfc+PlU7fPsxJhYMmdLpzyAx81dEzdNh0r+bGVpcetpw/Ss1f2DUbaHWy/J5nEZSVA0Cfuwn+hblj1vJuU6pe3f7eZ8qwxfQm8viDEw4jZnZzkNNrb6Wpn1krLcjJKY/NE9Jx2I7pmKmWj57bPpTm1EZrmNTrlf+u5eQKdwHng9pvJd8nrJqmcYTHU++zgKUXdu6lyVlqCGlJrUhJ99jSs4KldUo9LKnJfpQqX2uDOIcalwurzYzO4jbBMSat77ZVrn61mhhR2iijnNgwCVSaurnixz0NLnub/4FnrylN9iBBSOh6fkDtlgJDTscZzvZ1iP4vwYuqO05cI52L1I9cnsPmh8d4oib7w5; 4:vCpyzkqw0dneb0qes9JyUHa4qYddJktzXSmSycOPxWzQXRd1/EIFACykYvrIBix7LJ1/aIuKEZWN0qAAEgsoJTNwy522kZGxo8fyybK4NWGXIB8hXxvPnDGdnGRMpZtwMkHHUO0PRxo4xTFi/N18h5VXXZOWUwT10UVn6FqsDEK82gFNUzpGk6RiGeXOS2ZRCgO1lYUv0lJSnPS+eLeXc1J+7xxQboB8KSDLJ+IL729n8snXvAYvHeNiCMjFrnGkk80YKe4FkwQkS/8lFYwMe8USeeSQVuNB8Plr4kXnVA1EQmbjwy0CoMkylx0meGns3o5H1Yzbd49ScZxjskLVl34f87M7WRWwS0eLs3snuhBwG7ObpGd2wABTHeraRqq5 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:SIXPR06MB1021; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB1021; X-Forefront-PRVS: 08635C03D4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(42186005)(53416004)(50986999)(3846002)(54356999)(189998001)(76176999)(5001960100002)(87976001)(110136002)(36756003)(575784001)(66066001)(47776003)(4326007)(5008740100001)(2906002)(586003)(1096002)(23726003)(50466002)(33646002)(6116002)(5004730100002)(83506001)(92566002)(229853001)(40100003)(4001350100001)(2950100001)(122386002)(46406003)(19580395003)(19580405001)(77096005)(86362001); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB1021; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SIXPR06MB1021; 23:qd1/jjtmXU2Z3F1Viy1ho4AHLLa8JdfzjmJ8etuRh?= =?us-ascii?Q?JF0vmDkIOC6kmQyJYt9prBO4dWqPH/dqIQGa8IFQIH5TTt7qDk91uooH/3jI?= =?us-ascii?Q?up8M42lYcLOYYE9AFwFxbhh7G7PVV2bIPWRsa66mtL87ebEyg4rMzp/210zq?= =?us-ascii?Q?4dVgWPlfp9xi+EFcAUWNJAOnPKzkte4J2ePOd0XnQ5rb1BoSaFK1XDkArgyv?= =?us-ascii?Q?V0/lDN85U1eVuI2IC+n6/CZE28kIPZIvv5ihT/kZ3mGqhkB2bwWOTCGMrfIX?= =?us-ascii?Q?R7PKGHokC+vxjTlvYRH65t9kwvBirQqSJKsuGYf9yRqvDUNlUGP49Xtv5ktq?= =?us-ascii?Q?7pdAR/FpxK8dnoiqH44MUwVa5OGoLjEhBvtblWKKM4wrzQLH9WU6SpgHhQVU?= =?us-ascii?Q?waTW626Z9bmqEJYuu78PqPLcTdnNAgK229iCdkCEswkGjFGaYzdRXmbpCii3?= =?us-ascii?Q?qqrv9FRPtcwWvt0gu74CJZMMjtvpyqnMjZg14HbKhdNVLmHsypvY805w20R9?= =?us-ascii?Q?ifjjb0Zw7Z+f7Q2luxXD6oQI63FGDEJUxwyagxT8IRRPAAYUH9Ei/+4Pq9Vm?= =?us-ascii?Q?GSKTsXKc4Z779gMhdk74gIIJ8fo/9YKHJrsoozMTbdaw1aCaVM0pQlUV7RRq?= =?us-ascii?Q?Ibdldl1Yq6KyDgbZE4Rdu3Jq5hXwR5lQe0OCOD2WgvUv9stP+/+9ArWWHOxb?= =?us-ascii?Q?+Yzi/gvsIj1P5X2d9RCuKMbITlcGe39O0nUVYZ+/yFG9Q93AcGupwptZTbte?= =?us-ascii?Q?chb6b0UelKzPQHEZcJHf1kXlCTSU9HGKT9BDId2uDcSb6GRBCO1cnEacb5Gf?= =?us-ascii?Q?sZjz7ImRwHumwjkjCekmlQ2w2WdEQhgItzjFRIPASDWqmPjAcpowwNfc/SHH?= =?us-ascii?Q?ordWD0K3zJG1rpo+Xf/RSL+o30GJg/sBBArmxCaygakhDv5kPxiGPmQ2Oy7H?= =?us-ascii?Q?shMZryfKmf7nI1Ac4OeIOO2L0c42gAOnd9ly6ZQQmZlRdvTpBi6lwtUwbVOu?= =?us-ascii?Q?yySAZ76qjnOB8anYkowp+GeIZ3n+sNUtAupSNpUrLOQXg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB1021; 5:QzO2jQE2SjITQVAW9+57AaPXDX6Qm0RD+gQz7K2fbp0xdR2zr0xKOwN3ATfCYEWb7lmtWMJ9CF7o+vYHCh30UWlEVCp4hKyzewwD08KOPzW4C9eTCI9BId5PPHBIg9kDSEOFqQgQHA9iNB29sxGwTQ==; 24:TsNjulyH1u2sl2MeITqGP7bqu9rPKGr9rN7+nqaWDo+Opt3Jy0Y1xhRlxlGL2zz1NPBhe1i4UbcWDJC47J5a3+DGxKSAGrhH42PfiTjNRow=; 20:NhA6CJu7w8OSCqT14KLKTRWovLkeFiYzELzsirRFxwAyjn2UJO2lDGn6dJ6FsEPIjCbtRWoHpG7d3Hqg7rnF4pmHUxuDDxj7xiJu/TuHYL9muviDN57jdA/LJdyrK1D6jZRjP7tDdrZbmE3N+ccX99Sj8RLd/GDJ1+fyGKuO+FY= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Feb 2016 05:53:00.0903 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB1021 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 Renesas R-Car sound CTU (= Channel Transfer Unit) very basic support, but not yet enough feature at this point. Because CTU support needs more complex channel function for each modules. To avoid complex patch reviewing, this patch picked up very basic part only. Signed-off-by: Kuninori Morimoto --- sound/soc/sh/rcar/ctu.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/sh/rcar/rsnd.h | 1 + 2 files changed, 50 insertions(+) diff --git a/sound/soc/sh/rcar/ctu.c b/sound/soc/sh/rcar/ctu.c index a10d0f7..784515a 100644 --- a/sound/soc/sh/rcar/ctu.c +++ b/sound/soc/sh/rcar/ctu.c @@ -14,6 +14,7 @@ struct rsnd_ctu { struct rsnd_mod mod; + int channels; }; #define rsnd_ctu_nr(priv) ((priv)->ctu_nr) @@ -23,6 +24,9 @@ struct rsnd_ctu { ((pos) = (struct rsnd_ctu *)(priv)->ctu + i); \ i++) +#define rsnd_mod_to_ctu(_mod) \ + container_of((_mod), struct rsnd_ctu, mod) + #define rsnd_ctu_get(priv, id) ((struct rsnd_ctu *)(priv->ctu) + id) static void rsnd_ctu_activation(struct rsnd_mod *mod) @@ -37,6 +41,13 @@ static void rsnd_ctu_halt(struct rsnd_mod *mod) rsnd_mod_write(mod, CTU_SWRSR, 0); } +int rsnd_ctu_converted_channel(struct rsnd_mod *mod) +{ + struct rsnd_ctu *ctu = rsnd_mod_to_ctu(mod); + + return ctu->channels; +} + static int rsnd_ctu_probe_(struct rsnd_mod *mod, struct rsnd_dai_stream *io, struct rsnd_priv *priv) @@ -116,11 +127,49 @@ static int rsnd_ctu_quit(struct rsnd_mod *mod, return 0; } +static int rsnd_ctu_hw_params(struct rsnd_mod *mod, + struct rsnd_dai_stream *io, + struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *fe_params) +{ + struct rsnd_ctu *ctu = rsnd_mod_to_ctu(mod); + struct snd_soc_pcm_runtime *fe = substream->private_data; + + /* + * CTU assumes that it is used under DPCM if user want to use + * channel transfer. Then, CTU should be FE. + * And then, this function will be called *after* BE settings. + * this means, each BE already has fixuped hw_params. + * see + * dpcm_fe_dai_hw_params() + * dpcm_be_dai_hw_params() + */ + ctu->channels = 0; + if (fe->dai_link->dynamic) { + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct device *dev = rsnd_priv_to_dev(priv); + struct snd_soc_dpcm *dpcm; + struct snd_pcm_hw_params *be_params; + int stream = substream->stream; + + list_for_each_entry(dpcm, &fe->dpcm[stream].be_clients, list_be) { + be_params = &dpcm->hw_params; + if (params_channels(fe_params) != params_channels(be_params)) + ctu->channels = params_channels(be_params); + } + + dev_dbg(dev, "CTU convert channels %d\n", ctu->channels); + } + + return 0; +} + 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, }; struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id) diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 305cc08..bbc89bd 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -638,6 +638,7 @@ unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, */ int rsnd_ctu_probe(struct rsnd_priv *priv); void rsnd_ctu_remove(struct rsnd_priv *priv); +int rsnd_ctu_converted_channel(struct rsnd_mod *mod); struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id); #define rsnd_ctu_of_node(priv) \ of_get_child_by_name(rsnd_priv_to_dev(priv)->of_node, "rcar_sound,ctu")