From patchwork Thu Jun 15 00:50:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9787717 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF65560384 for ; Thu, 15 Jun 2017 00:50:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3CA721F61 for ; Thu, 15 Jun 2017 00:50:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6ED92810E; Thu, 15 Jun 2017 00:50:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA8A123794 for ; Thu, 15 Jun 2017 00:50:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750770AbdFOAuY (ORCPT ); Wed, 14 Jun 2017 20:50:24 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:49623 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750768AbdFOAuX (ORCPT ); Wed, 14 Jun 2017 20:50:23 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie4.idc.renesas.com with ESMTP; 15 Jun 2017 09:50:21 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id CC69756FFC; Thu, 15 Jun 2017 09:50:21 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.39,341,1493650800"; d="scan'208";a="246636591" Received: from mail-sg2apc01lp0241.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.241]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 15 Jun 2017 09:50:21 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=PLNYGL6tbwa539bmpPOzJq+30uZsImkMnnEQUahpKz0=; b=p66FNR4jvtQ/fMni/ZOcb6msE+Se622mCQs429OJm1BtZiM4Arf1JukT4CCAGEl3jXz56Ht9b9VZlOlthIy6+XW6C0ZMNYWHCW5SijvgvLkMTsJbG7dvnnERiKXI798JQTRJ/F+ETH+TpXmj8WNCG6BaB3f5ZnhimeeOb++QhQM= 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 SG2PR0601MB1887.apcprd06.prod.outlook.com (2603:1096:3:9::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1157.12; Thu, 15 Jun 2017 00:50:19 +0000 Message-ID: <87h8zim647.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 4/4] ASoC: rsnd: add rsnd_soc_hw_rule/constraint() User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown CC: Linux-ALSA , Simon , In-Reply-To: <87mv9am66o.wl%kuninori.morimoto.gx@renesas.com> References: <87mv9am66o.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Thu, 15 Jun 2017 00:50:19 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: HK2PR0302CA0004.apcprd03.prod.outlook.com (2603:1096:202::14) To SG2PR0601MB1887.apcprd06.prod.outlook.com (2603:1096:3:9::20) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SG2PR0601MB1887: X-MS-Office365-Filtering-Correlation-Id: 28ab6b49-64a2-4b8a-5194-08d4b3887f74 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:SG2PR0601MB1887; X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1887; 3:mT/Kvr4zaXlXWpBgDfj1D53fc9WEMeflGiMbLUE/uEAzHIZTsy1J3jQDqt6Zqqv9dAaaSvO/lPGUBF+DlY/iO9PXP4XVqfcO07H8yNMgBU2RvigeWR8M/LrRRV6fS3dm9c2O+Yj6Hd/Fb3S8SCQ+9xygpht4NKVlPYYFDbbrKKA/GU/VwCu7KTEIy+04BbeQ2WP+QfOq1STO9Yv2vLUIJxN6aVOFkteL5vIIaMRTbS8tol5QlJ41aSo/iytxNMZJRHMyGXxD0sexRRGToHC9NSEacU6RfU4YIPsSz3jPeT+cdye//R1YhHeYw+haFqErKK+vGKYrGCFmbiEFMUWgHzFyQ6gYWGkMpPoZDqoQbGM=; 25:g3nh0Al88QLZqAI3hEjZmPf717DoyQh1358YpxuRaVPYutg3o+/9L82SRqh2YvR/uzwF6gslxkO9hXGUtSl3iZN6qrbQpuPuavlUtBOwdz2c4xtr8XA81O8zrluWmhQtgqAsInyWqqB/CJ8Z6NWeITU4BLQfytlX9wJ+qdtQwPV7LaxUN1IdTXcd7945i2n0iqhBfS9oWb0drZ3FRV3GU1WprF7yye5TT67QudVhze+GYX8ytryTZnj/Ijl+U4jpu89ORIeuSMR+keSEdFfkMAVG8k4Hld5Pf8Ge78yGOL/nnyptlAN7cz74uH6+POQWWgYl6I2+TwGPYKvFPuLn6v85ta2NXqtFUdtlyFigGd1js828k0+jiIGY1xfUq/GpQCJOEvhbmpm1KqzXDUZRCpphGGCTtPGThYGPLm3CTgwQyCTiU0A70nOg58b5vcui2Hd+2tu1K+rEsE4290R8+qTBkkrc0GmJ81dR3PzY/Ow= X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1887; 31:ppzJaYpbTxtPsFjPVSycdcVUlOt+OAlC/DDUrTXF2Dn8JFkCa2zjzOdBGTA6Yvt5lYyAVi62uUA+tEKExR/z97fQoVf9WqLMN3xRCetZfcHweHQps1rGH8LBgXWnI21+u89PBG6B5pkQHyDEhLUeu9IFPjQA6gULrT5YgU29Wxs9YPjSfrc6b3OUAH9rsHuWmzr/ICjsUwawBSjDbc3mb+E+3D5XLEDcy+/SYywV/7XgiZkQscb/l2sLAxwfdVnK; 20:+jSFUC8exwwaYrj2GuCVt58UXo2b68wXVfIwWaDtRyyUTsFqsZMbFxZ+DkrlQq+ymlvGxvVIah8yuM/ZTmBwwLISaDlG/OW1nntmX5JhQwIYo/Q1tSNX6kIJg6MWNgl2MSnnSh+WnatYLUXcREwlgzzwZ52xFdgXdgUo6jhv2XRJmb3ZYUw4c0y6Q/PqnJRC3bRnDmUHJ6ltuUi2DaO+FizSPYROFyFMXRGbedm05kCu7wDKdHBmcudn+rtyxmMZfk8PosYiCYNKeNKjxrWNFnjUtOJWD/62rYFrmPpqVNU51JF/JypFrFnR+kP3h5fou5FayzN0dwO5PfBfnpm3isHZcgW658WGOexD3R/yisZDX+bsLHC1OpjzP2iF56TeTb51ESa4cIg/gDy28fPbm1v78Za8jSWrOVlSrzH2/ZTG8TcjNsEezLRih5sgbcLziZVPj9ITSV89gECJ7NK9wtuHlMG3iJETLxS2/04K5Jl+uXX302RsS0H3j6CnBcqH X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(20161123560025)(20161123564025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SG2PR0601MB1887; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SG2PR0601MB1887; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR0601MB1887; 4:jJzhwDkEytSkPAke7W4YmTw9hm/dhpeOWUn15DZ/?= =?us-ascii?Q?KWbY3lKPwkXDqiXp67aWneWJGd1HlhfrKEEKtZSqVvkboP1iE/f3PBOwApkl?= =?us-ascii?Q?yLY2lwWCTb0w/sW7UIM1qTmzy5ciohfMlHQtNqtUNCURZP1eUPwtWlq9bFz2?= =?us-ascii?Q?k5npxxSQb3QsBQ7aXuEoAWHpYSzEfCHeNft9KclBTBdrTXCY0eLRTw3BD1kW?= =?us-ascii?Q?p781k91WSCULycBQsAp4xPA0Z5zpVIKBqCbCnlYpF86hZCzkicmTzuWlQ4Lz?= =?us-ascii?Q?3BYGyPotS+hHr2AOsrLomzyyc5j1itC4gxR5bXABNCbDltvGOG7nOMdZ5QNF?= =?us-ascii?Q?d0rPBZviPD6Al+suAW7VS1WMMfy9pXvBVeBtdo+7G6ucI7XPr2FakPI+L1CN?= =?us-ascii?Q?irzA2ThplaAQqzFdQexlYGZMK/vg2ronf5boUqMqMsWo2JzTgkZKUSf2O1oA?= =?us-ascii?Q?v3Me0i74N2cDUqyHTTYrb29gYoe4e2Fzs97+sGKWjfnpbiqUq0ASD5fqmq2H?= =?us-ascii?Q?bHu9oudwlTcDC48SZWofb1hNtWCyiDg04v4JDBGv7kRRIufngSIZ8h1ouOl0?= =?us-ascii?Q?qzJ7VaSDARWxGTJG2EL32Apiina9EJ+lebcGXif8tVUMiHbFbFWSY6GIf9gx?= =?us-ascii?Q?oI9LGQ13xMsqHD5rgycRjJ+TqK0g9Gwe7b1wrS6hrwGZ8pi4mCSNyFwByikG?= =?us-ascii?Q?LvJaYYTYuFigM6nDMpWpH1DqFGu6c9p78MZGAQesLZ2BL6Bs2l8x/+7nAH8R?= =?us-ascii?Q?/5WJT2onKU8xF/Szmy4ZPEpQnvCPE516hHq7jxKfRTGYy8k6cl+aHnpcN0cn?= =?us-ascii?Q?sqElISNhL8EthvD+V0LRv4fkM6plnaecGTJT9bEJbvsckGuECrZjpuh6NyFE?= =?us-ascii?Q?tILuga+bYU11fNoI7cnmznKQSr2geJaF0jwaO/KWDkUlEf4oW3AHG45jy9Aa?= =?us-ascii?Q?BprjGCbBIBth8C94IZavb7p48NJF787owPp6dXG0P5CbVQmUXaeoZM8mta4q?= =?us-ascii?Q?MDVyjNJBjefBEtIvwZM8lMluEgWoR/AvoLAjKsF/MQFHKE0oog/zkoGfhUwH?= =?us-ascii?Q?9j++BpTvyb8xhjtSt67x/6AeetFfhVco6TDYzh1f76iYRY/S3becxr+HqBaF?= =?us-ascii?Q?xqN0Elk02b9H1ZfXAOdjaJFvT6dwcYIkwKb31oJ01NHgphNzT/Pi0A=3D=3D?= X-Forefront-PRVS: 0339F89554 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39410400002)(39860400002)(39450400003)(39840400002)(39400400002)(39850400002)(110136004)(38730400002)(2950100002)(47776003)(54356999)(76176999)(66066001)(50986999)(50466002)(6916009)(53936002)(478600001)(54906002)(25786009)(2906002)(6486002)(4326008)(5660300001)(53416004)(42186005)(36756003)(4001350100001)(189998001)(83506001)(46406003)(305945005)(7736002)(23726003)(3846002)(6116002)(8676002)(81166006)(33646002)(86362001)(575784001)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR0601MB1887; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv;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6Ee3/yg6LkBh5nM9uTfiedn9IKtRfv62L6xLoMY+TyX3U5uoIMuq3JKPZAmvo7vL0H3XI9b4bwjFh3mGSK2HKNO1j4B5Hp8IcTjyjRmOdQehlOc88f8esB+jdlTg6nCCe7qWo5crcV9tBXkKmEA1Wx/O5RIPLpv+2nWZjWOS7LHB1oO2eyfTm0zA6po6eFq5k2SlcILj16QQQ6h9bnH1KyE3ceqVtU8V+ykut7qL/D6iStQaY+qiT3PaIJUaGskQLklwTHfyE5n7zwp2dFgEEOu1cpv71yXW6/AayDzoNzY39K+Migd5Qg+9AaDe8rFBVutIgcTWhvi89m5nW0WFHCtoKoB++FMzvBkuu91UVEvFex6DY1/rcNebrR1Ted38DS1v+bqI/H/cKh9fMDXIdXuB0S50Vj/Cd/0evvAdoYbcA9NX4BxYSztTIIW2dOdbTNdO5PBes7hw3TsHXrMUXY1v7wSbBoGs; 24:YvlAe6tRxa2KQq+f9O82s24kVzv6UncLJBh633Y4nNGU9sSqAe8toCKYdKJTQxj60UCeMLTc51168a9JPEEdu2aWbWNeDTOm88mX61Wcby8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1887; 7:x6fKZPT6zE0MxoucKNLf5kn4SlXQ+574tNcz/oHjBx12sAaZydRKfIHlu9ObML4qJ5qzgW8f/8qYeoeViBp1RZ7sh/ZSCtUzY814hRJqb7GPyoxWP64z0eg1b1MeElQL7ViAXj7qzFAFSLxbNFvbixHylJBR3GUsW/oL8G+yXHastwUFonTbKEeORYI3HzBriJLlGpr702TfSoF5uxQ7caHorjX738zzTxenCv8MwPU4g4OnT1AwkvMzsx7nIeWRd9wmjqYpIR3iPxT4LcpPGU984J49e+LOJzR2SbW5Q/CioRijjX9U5Y9y344UL7z43+tVjxXTBlTd1oTa2Ix0rw==; 20:hQoEU3yEFA+jUcWc7zyq12tJMZfYGo7UPJHLc/DJjWJURTes+WN9eA9NqiA3qvbPrHMJsOojkYi1IdmJfbYLqFuS9F2L+m9FrC/bAevNlWOfaCnnK5zW/vzjhbY0skDhWYkMDTMpO405OCQ+dIUe4jVp6nQk85J8dftpYSeJnQo= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2017 00:50:19.4929 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR0601MB1887 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current Renesas sound driver is assuming that all Sampling rate and channles are possible to use, but these are depends on inputed clock and SSI connection situation. For example, if it is using 1 SSI, enabled TDM mode and has 12288000 input clock, 2ch output can support until 192000Hz, but 6ch output can support until 64000Hz, 8ch can support 48000Hz. To control these situation correctly, it needs to support hw_constraints / refine feature. To support such feature, this patch adds new rsnd_soc_hw_rule/constraint() which adds hw rule of Channel and Sampling Rate. Signed-off-by: Kuninori Morimoto Tested-by: Hiroyuki Yokoyama --- sound/soc/sh/rcar/core.c | 155 ++++++++++++++++++++++++++++++++++++++++++++++- sound/soc/sh/rcar/rsnd.h | 1 + 2 files changed, 154 insertions(+), 2 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 9b9e898..4892c0a 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -723,7 +723,10 @@ static int rsnd_soc_set_dai_tdm_slot(struct snd_soc_dai *dai, struct device *dev = rsnd_priv_to_dev(priv); switch (slots) { + case 2: case 6: + case 8: + case 16: /* TDM Extend Mode */ rsnd_rdai_channels_set(rdai, slots); rsnd_rdai_ssi_lane_set(rdai, 1); @@ -736,6 +739,151 @@ static int rsnd_soc_set_dai_tdm_slot(struct snd_soc_dai *dai, return 0; } +static unsigned int rsnd_soc_hw_channels_list[] = { + 2, 6, 8, 16, +}; + +static unsigned int rsnd_soc_hw_rate_list[] = { + 8000, + 11025, + 16000, + 22050, + 32000, + 44100, + 48000, + 64000, + 88200, + 96000, + 176400, + 192000, +}; + +static int rsnd_soc_hw_rule(struct rsnd_priv *priv, + unsigned int *list, int list_num, + struct snd_interval *baseline, struct snd_interval *iv) +{ + struct snd_interval p; + int rate; + int i; + + snd_interval_any(&p); + p.min = UINT_MAX; + p.max = 0; + + for (i = 0; i < list_num; i++) { + + if (!snd_interval_test(iv, list[i])) + continue; + + rate = rsnd_ssi_clk_query(priv, + baseline->min, list[i], NULL); + if (rate > 0) { + p.min = min(p.min, list[i]); + p.max = max(p.max, list[i]); + } + + rate = rsnd_ssi_clk_query(priv, + baseline->max, list[i], NULL); + if (rate > 0) { + p.min = min(p.min, list[i]); + p.max = max(p.max, list[i]); + } + } + + return snd_interval_refine(iv, &p); +} + +static int rsnd_soc_hw_rule_rate(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) +{ + struct snd_interval *ic_ = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *ir = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval ic; + struct snd_soc_dai *dai = rule->private; + struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); + struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); + + /* + * possible sampling rate limitation is same as + * 2ch if it supports multi ssi + */ + ic = *ic_; + if (1 < rsnd_rdai_ssi_lane_get(rdai)) { + ic.min = 2; + ic.max = 2; + } + + return rsnd_soc_hw_rule(priv, rsnd_soc_hw_rate_list, + ARRAY_SIZE(rsnd_soc_hw_rate_list), + &ic, ir); +} + + +static int rsnd_soc_hw_rule_channels(struct snd_pcm_hw_params *params, + struct snd_pcm_hw_rule *rule) +{ + struct snd_interval *ic_ = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_interval *ir = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval ic; + struct snd_soc_dai *dai = rule->private; + struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); + struct rsnd_priv *priv = rsnd_rdai_to_priv(rdai); + + /* + * possible sampling rate limitation is same as + * 2ch if it supports multi ssi + */ + ic = *ic_; + if (1 < rsnd_rdai_ssi_lane_get(rdai)) { + ic.min = 2; + ic.max = 2; + } + + return rsnd_soc_hw_rule(priv, rsnd_soc_hw_channels_list, + ARRAY_SIZE(rsnd_soc_hw_channels_list), + ir, &ic); +} + +static void rsnd_soc_hw_constraint(struct snd_pcm_runtime *runtime, + struct snd_soc_dai *dai) +{ + struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); + struct snd_pcm_hw_constraint_list *constraint = &rdai->constraint; + unsigned int max_channels = rsnd_rdai_channels_get(rdai); + int i; + + /* + * Channel Limitation + * It depends on Platform design + */ + constraint->list = rsnd_soc_hw_channels_list; + constraint->count = 0; + constraint->mask = 0; + + for (i = 0; i < ARRAY_SIZE(rsnd_soc_hw_channels_list); i++) { + if (rsnd_soc_hw_channels_list[i] > max_channels) + break; + constraint->count = i + 1; + } + + snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_CHANNELS, constraint); + + /* + * Sampling Rate / Channel Limitation + * It depends on Clock Master Mode + */ + if (!rsnd_rdai_is_clk_master(rdai)) + return; + + snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + rsnd_soc_hw_rule_rate, dai, + SNDRV_PCM_HW_PARAM_CHANNELS, -1); + snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + rsnd_soc_hw_rule_channels, dai, + SNDRV_PCM_HW_PARAM_RATE, -1); +} + static int rsnd_soc_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { @@ -744,6 +892,9 @@ static int rsnd_soc_dai_startup(struct snd_pcm_substream *substream, struct rsnd_dai_stream *io = rsnd_rdai_to_io(rdai, substream); int ret; + /* rsnd_io_to_runtime() is not yet enabled here */ + rsnd_soc_hw_constraint(substream->runtime, dai); + /* * call rsnd_dai_call without spinlock */ @@ -866,7 +1017,7 @@ static void __rsnd_dai_probe(struct rsnd_priv *priv, drv->playback.rates = RSND_RATES; drv->playback.formats = RSND_FMTS; drv->playback.channels_min = 2; - drv->playback.channels_max = 6; + drv->playback.channels_max = 16; drv->playback.stream_name = rdai->playback.name; snprintf(rdai->capture.name, RSND_DAI_NAME_SIZE, @@ -874,7 +1025,7 @@ static void __rsnd_dai_probe(struct rsnd_priv *priv, drv->capture.rates = RSND_RATES; drv->capture.formats = RSND_FMTS; drv->capture.channels_min = 2; - drv->capture.channels_max = 6; + drv->capture.channels_max = 16; drv->capture.stream_name = rdai->capture.name; rdai->playback.rdai = rdai; diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 3aa07a0..9428d4e 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -449,6 +449,7 @@ struct rsnd_dai { struct rsnd_dai_stream playback; struct rsnd_dai_stream capture; struct rsnd_priv *priv; + struct snd_pcm_hw_constraint_list constraint; int max_channels; /* 2ch - 16ch */ int ssi_lane; /* 1lane - 4lane */