From patchwork Mon Mar 7 05:09:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 8515581 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 90861C0553 for ; Mon, 7 Mar 2016 05:09:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 983862010B for ; Mon, 7 Mar 2016 05:09:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7335F2012D for ; Mon, 7 Mar 2016 05:09:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751341AbcCGFJU (ORCPT ); Mon, 7 Mar 2016 00:09:20 -0500 Received: from relmlor2.renesas.com ([210.160.252.172]:44990 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750854AbcCGFJT (ORCPT ); Mon, 7 Mar 2016 00:09:19 -0500 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie1.idc.renesas.com with ESMTP; 07 Mar 2016 14:09:17 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id B883E4AA13; Mon, 7 Mar 2016 14:09:17 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id B8B352806E; Mon, 7 Mar 2016 14:09:17 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id B1DF22806D; Mon, 7 Mar 2016 14:09:17 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac2.idc.renesas.com with ESMTP id QAD24241; Mon, 7 Mar 2016 14:09:17 +0900 X-IronPort-AV: E=Sophos;i="5.22,549,1449500400"; d="scan'";a="205831672" Received: from mail-pu1apc01lp0017.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.17]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 07 Mar 2016 14:09:16 +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=aWEpvWxBJx12XkrhmUBTQwXaq57F8+yg1qZJ48572nk=; b=YNG77qc+JK3DKWWdJ3qyb/KNS89LVFnKVSxdBXuok/t+t/5iH76FciRIH5P1YU5pT5igxTnnM8LZUN49RFUpVUdEJSMXtP33srNcUSiuxkGAxdPaQvVQLwqQBRHh34cUvCkaqXwRM1q0o3u9p/akOpSKaTqa+Y6BnqgefRtxrnI= 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 SG2PR06MB1020.apcprd06.prod.outlook.com (10.161.9.28) with Microsoft SMTP Server (TLS) id 15.1.427.16; Mon, 7 Mar 2016 05:09:14 +0000 Message-ID: <87d1r6yj30.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 6/7] ASoC: rsnd: SRC TIMSEL support for Capture User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown CC: Linux-ALSA , Liam Girdwood , Simon , In-Reply-To: <87lh5uyj9a.wl%kuninori.morimoto.gx@renesas.com> References: <87lh5uyj9a.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Mon, 7 Mar 2016 05:09:14 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: KAWPR01CA0038.jpnprd01.prod.outlook.com (25.165.48.148) To SG2PR06MB1020.apcprd06.prod.outlook.com (25.161.9.28) X-MS-Office365-Filtering-Correlation-Id: 7237f453-99ca-4afe-a7b1-08d34646a0cb X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1020; 2:BxGH5vedcJZ5TSDCEnCgyrTpa+1VNJvzmSpcLktzqdhSTvqEvr+bBUYZ8ZcfsgloHY5OuIhoFAC3YeRRXmb1gw88GFjiXxRFFDdDpuaIQx4z7Vp8eeLvCWus2r+HLxPed9JmDmGsyKVfJlwFvk07+g0gzte2Z2HMzscq+lzTnwwHpEIrDJHQnbzBTNqJZp9A; 3:RHW+z9/sefJfVDcYqyvQQ/B1J0uBnSni8WNagrQxnEWQGZHyRncBDOzD/rRS93fej/a+fBhI7yydrkptRmsvpLFni0/gFzUn7e8xY+I7SE6b8/Gx/Gndz/h4t7+wEwla; 25:UV+HGv1FexkqfvuuP6spARgCn9g2dp4HeRrZ5UKNX9rQAVjJ0PbU8UBBa8vqjpVzxphT0QAJoFae4ncQYshaj8fyh6a+byfeTH3o8zbW1P8QjNvW7EQqgqKjIi+QFs79fo2ZPaKS/o+Mu/SW//golzEgpktWxS0hn/JVFoW8qUU88J5mKxfXTkU0AyoNJFQr1ONO9gfSr5L/twjZG+1EXPCvyNaazoKFhNMFxke70D44iVS+g9tKvr1atoO/05Y/pU2EdFBDaD5z333YWB48vY7bqB34avAUVgARO6l0he6GRjGetyhZqyYj88QGL6pFC+CprM1SaiRmOpFWpDF1dg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SG2PR06MB1020; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1020; 20:Dzd36CN+QKWe4yrjnL7La0o2vm+aGnJfbix8KczpEvvmemI587TDHJG52/w0apbCq7ILDmlGG68RoWh3Or6W5XZZFcbwtRm9kFPp8Y0tUjw43s2egJqZFU00GL06U9lqvmJFsomlo9CBOeREpvWGd96zRYuH4jpCmnnWtKiz/U2Hqij3O8qEwjYfS4+0PiEBaqAGgTC9+ydXYGslF39hmORX1sZlGYbpF7Noo3C5nkB6pdr8VuPzJA6BOY6faZcO2E3xRMYKfvxO9EXRR91YlgHBHCu6KXZQz2GkFmOZnaJeJZGksHhb5/CmFZbnwG1SJCrMVcEB5wmhSyzNM5sSb/okqNqpUDC5XnGWZBl3meONtw47B3qImX1p4CiR3pVZVY+AgAPOCS1MCNAZfbIlIZlN4Q2DuYvRPg5HzYTPdXQJksHFTGo6KpsEIak7sP4NV3ZSKdnyM+hb9CbWN14ZkmFjHnzFtPLvylIQR1Be+cbxIS9uuHxNC1OrebL77PIG; 4:IcJziaNYMSeHTJKxGwtA7KwsvR6oOBugdvoJwa7hmnoRe14AjjhzezA5m8lZlp5yYsFvXlNfngykfDTvi0vTzVz7nBGBf2VRWEIGryonNlH0r7m/jdQsi8hFWlQwRaeeOTmqIF5srdBPjOI4Xy6A8LaPzgahmn+FEK6pIbQlgnIfOOHPb+zQAg+zXp3FPIDsS/XeUp8ZOshQWU0L1Raw1ctLwZtKgPHW63CtbM7SuJgW3LFAPOaWJcqBwSNRipxAmtdIWrnfh0FSwhS378t0/NUTZQ5SgoRJbodykLETqccdbE6RXb/GT7oeP+hjv7JfSpH87YULgxLkhtd/vddTfwDRq5lsKSRgbxdvcXg7eXdzpOsIs4u01eSQdkYEeQ7X 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)(10201501046)(3002001); SRVR:SG2PR06MB1020; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB1020; X-Forefront-PRVS: 087474FBFA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(110136002)(77096005)(5008740100001)(50986999)(4326007)(54356999)(76176999)(46406003)(4001350100001)(47776003)(2950100001)(19580395003)(19580405001)(83506001)(33646002)(189998001)(66066001)(36756003)(87976001)(53416004)(81166005)(40100003)(42186005)(92566002)(23726003)(122386002)(1096002)(586003)(229853001)(6116002)(3846002)(50466002)(86362001)(2906002)(5004730100002)(217873001)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB1020; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SG2PR06MB1020; 23:/TGsr4/EyAxxp02LnULt2uqpBRqeGnUaa7RZLryAt?= =?us-ascii?Q?38d7+pkK0pV5eR/GGkK5xf7qJB70yPVOp3Mfy2+Mmp06ZzPgEkbmcAYmgdIN?= =?us-ascii?Q?VoPvYCoiOjvuBujitu9czzmgl7IvvRCSr3lXMalxEj6won1a9QCrXJzG3fDu?= =?us-ascii?Q?3qy7h4yiilL4Mm6CUFWqR6V/Rqgu81IcaUQADgakMdlCBlCNZshS06gtgrGN?= =?us-ascii?Q?wUTI14H9UfMUoRo/Fkr0IczlhZ5IVrU9k/Yttng4SAvT41/WcuOuvoDF2FuD?= =?us-ascii?Q?r3wFvvRwUkxNC0v2efVc/JPT99OKIpnp+Y1tVrodSpdFU45TCH8vVZP/g5Jm?= =?us-ascii?Q?NMJmfzdxdUAA25zb36AUNesQJbLkCug0ZpF5yCp8DO5HZBdLS8zGPOu1M5kV?= =?us-ascii?Q?U+ToBE4KUn8D3sqt/1gAE56Zfb4DsMlyxoTOc1nbavWfI57I3OUnk6z3GrSA?= =?us-ascii?Q?Id/zMr+o8cMwC5Jmc2N6i3a8sFgoKVinmvnSm+/aOhB7Rj31dif+KNI0DS5z?= =?us-ascii?Q?BPS4A8ucOBBMTYZfNH/XDB0slXzlPx7PHy4iZMlRWjwFhd93rUPICDZ6NKhX?= =?us-ascii?Q?TS8avCePlrEBOgNAoTdsyEHlLoB3pap3OwyoiC/AXPGAVWPjotDxU95n7vl0?= =?us-ascii?Q?Pbmu33wtqhi8s/WSdyR4bLZDRknvmJbp7XIsaf/0wM/IhAhhufzqCFIzICc0?= =?us-ascii?Q?69vl10R8DUboFbUAImiu5vVYo7w34mJWxU1GHCfoaga+/vzKpBpIq1mTyshD?= =?us-ascii?Q?0N55q1aB4FHB8MKy5O3u9hgX9brIeO407YpCvMCf5QADSIgiEXij+rBxYJj5?= =?us-ascii?Q?hYLtcc0Urtv9iNiDmgkCRednAriOExHZtRVsiRvvGYgsMuPl7J1D5+kDMMe8?= =?us-ascii?Q?mpSKiYfoq8c63oJ1S1G+0tODYkIH8rL/t8oF2eQ27KHZh3TBMGOMqLxCrQ9M?= =?us-ascii?Q?JQZjpBOXxxE2TwS88WsTfdmOXBF13qGkKRgsC01OG7n625X+AnlB+7s2JYbl?= =?us-ascii?Q?8n2hLwWSo/Q/c9hmVEKQYum4qXvXyL40/QUDUcNL786BLfHlG+wefpNHxM4Q?= =?us-ascii?Q?mwRomw=3D?= X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1020; 5:NKCKThMpOnM/vHU6JLMF3OcNjoDqgPE1OZJ2UTm31+oiGTtyZmhBIV3TYrVgncZAQRP9aNnTIAupkui5tNys4m1OBcx2uFLFPfbjuVLv4z8Vu2fX0bpK83hWPH5hOfeyfYr4aVvTsczQ/fdMOMcDxQ==; 24:F8XcR4hUb3fFgudffDMs0kgj0sOc6HRZGE9ShMbEj/mAJIL3xmhJb/kN5qlfQdjscjklSLJdTgB62y32oTUs81Ir7740ftcJIJhj0tbbd+Q=; 20:nF6yez++tgFpP5sEoXJySK062JpOXdSf7z8h5uVKaGis9fLho2DR/7l60jfmPEAHz/MKK6BduRAHSwgBDelSB61YHcfzwIFTMctqhFhjFy/d16a+2XICExr1qdC33R2J8NqCt+oBMkE8Tq2GJhKCVU8B+MqY/NwM9lMwddwD/r0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2016 05:09:14.3103 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1020 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=-6.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,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 SRC has Sync/Async mode, and it can't use Sync mode when Capture with CMD. In Async mode, it needs to care about in/out SRC rate for settings, but current driver supporting Playback case only. This patch supports Capture case. Signed-off-by: Kuninori Morimoto --- sound/soc/sh/rcar/adg.c | 204 ++++++++++++++++++++++++++--------------------- sound/soc/sh/rcar/rsnd.h | 8 +- sound/soc/sh/rcar/src.c | 26 +++--- 3 files changed, 128 insertions(+), 110 deletions(-) diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index d74e1cc..f7e164c 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c @@ -90,6 +90,108 @@ static u32 rsnd_adg_ssi_ws_timing_gen2(struct rsnd_dai_stream *io) return (0x6 + ws) << 8; } +static void __rsnd_adg_get_timesel_ratio(struct rsnd_priv *priv, + struct rsnd_dai_stream *io, + unsigned int target_rate, + unsigned int *target_val, + unsigned int *target_en) +{ + struct rsnd_adg *adg = rsnd_priv_to_adg(priv); + struct device *dev = rsnd_priv_to_dev(priv); + int idx, sel, div, step; + unsigned int val, en; + unsigned int min, diff; + unsigned int sel_rate[] = { + clk_get_rate(adg->clk[CLKA]), /* 0000: CLKA */ + clk_get_rate(adg->clk[CLKB]), /* 0001: CLKB */ + clk_get_rate(adg->clk[CLKC]), /* 0010: CLKC */ + adg->rbga_rate_for_441khz, /* 0011: RBGA */ + adg->rbgb_rate_for_48khz, /* 0100: RBGB */ + }; + + min = ~0; + val = 0; + en = 0; + for (sel = 0; sel < ARRAY_SIZE(sel_rate); sel++) { + idx = 0; + step = 2; + + if (!sel_rate[sel]) + continue; + + for (div = 2; div <= 98304; div += step) { + diff = abs(target_rate - sel_rate[sel] / div); + if (min > diff) { + val = (sel << 8) | idx; + min = diff; + en = 1 << (sel + 1); /* fixme */ + } + + /* + * step of 0_0000 / 0_0001 / 0_1101 + * are out of order + */ + if ((idx > 2) && (idx % 2)) + step *= 2; + if (idx == 0x1c) { + div += step; + step *= 2; + } + idx++; + } + } + + if (min == ~0) { + dev_err(dev, "no Input clock\n"); + return; + } + + *target_val = val; + if (target_en) + *target_en = en; +} + +static void rsnd_adg_get_timesel_ratio(struct rsnd_priv *priv, + struct rsnd_dai_stream *io, + unsigned int in_rate, + unsigned int out_rate, + u32 *in, u32 *out, u32 *en) +{ + struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); + unsigned int target_rate; + u32 *target_val; + u32 _in; + u32 _out; + u32 _en; + + /* default = SSI WS */ + _in = + _out = rsnd_adg_ssi_ws_timing_gen2(io); + + target_rate = 0; + target_val = NULL; + _en = 0; + if (runtime->rate != in_rate) { + target_rate = out_rate; + target_val = &_out; + } else if (runtime->rate != out_rate) { + target_rate = in_rate; + target_val = &_in; + } + + if (target_rate) + __rsnd_adg_get_timesel_ratio(priv, io, + target_rate, + target_val, &_en); + + if (in) + *in = _in; + if (out) + *out = _out; + if (en) + *en = _en; +} + int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *cmd_mod, struct rsnd_dai_stream *io) { @@ -110,25 +212,24 @@ int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *cmd_mod, return 0; } -static int rsnd_adg_set_src_timsel_gen2(struct rsnd_mod *src_mod, - struct rsnd_dai_stream *io, - u32 timsel) +int rsnd_adg_set_src_timesel_gen2(struct rsnd_mod *src_mod, + struct rsnd_dai_stream *io, + unsigned int in_rate, + unsigned int out_rate) { struct rsnd_priv *priv = rsnd_mod_to_priv(src_mod); struct rsnd_adg *adg = rsnd_priv_to_adg(priv); struct rsnd_mod *adg_mod = rsnd_mod_get(adg); - int is_play = rsnd_io_is_play(io); + u32 in, out; + u32 mask, en; int id = rsnd_mod_id(src_mod); int shift = (id % 2) ? 16 : 0; - u32 mask, ws; - u32 in, out; rsnd_mod_confirm_src(src_mod); - ws = rsnd_adg_ssi_ws_timing_gen2(io); - - in = (is_play) ? timsel : ws; - out = (is_play) ? ws : timsel; + rsnd_adg_get_timesel_ratio(priv, io, + in_rate, out_rate, + &in, &out, &en); in = in << shift; out = out << shift; @@ -157,91 +258,12 @@ static int rsnd_adg_set_src_timsel_gen2(struct rsnd_mod *src_mod, break; } - return 0; -} - -int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *src_mod, - struct rsnd_dai_stream *io, - unsigned int src_rate, - unsigned int dst_rate) -{ - struct rsnd_priv *priv = rsnd_mod_to_priv(src_mod); - struct rsnd_adg *adg = rsnd_priv_to_adg(priv); - struct rsnd_mod *adg_mod = rsnd_mod_get(adg); - struct device *dev = rsnd_priv_to_dev(priv); - int idx, sel, div, step, ret; - u32 val, en; - unsigned int min, diff; - unsigned int sel_rate [] = { - clk_get_rate(adg->clk[CLKA]), /* 0000: CLKA */ - clk_get_rate(adg->clk[CLKB]), /* 0001: CLKB */ - clk_get_rate(adg->clk[CLKC]), /* 0010: CLKC */ - adg->rbga_rate_for_441khz, /* 0011: RBGA */ - adg->rbgb_rate_for_48khz, /* 0100: RBGB */ - }; - - rsnd_mod_confirm_src(src_mod); - - min = ~0; - val = 0; - en = 0; - for (sel = 0; sel < ARRAY_SIZE(sel_rate); sel++) { - idx = 0; - step = 2; - - if (!sel_rate[sel]) - continue; - - for (div = 2; div <= 98304; div += step) { - diff = abs(src_rate - sel_rate[sel] / div); - if (min > diff) { - val = (sel << 8) | idx; - min = diff; - en = 1 << (sel + 1); /* fixme */ - } - - /* - * step of 0_0000 / 0_0001 / 0_1101 - * are out of order - */ - if ((idx > 2) && (idx % 2)) - step *= 2; - if (idx == 0x1c) { - div += step; - step *= 2; - } - idx++; - } - } - - if (min == ~0) { - dev_err(dev, "no Input clock\n"); - return -EIO; - } - - ret = rsnd_adg_set_src_timsel_gen2(src_mod, io, val); - if (ret < 0) { - dev_err(dev, "timsel error\n"); - return ret; - } - - rsnd_mod_bset(adg_mod, DIV_EN, en, en); - - dev_dbg(dev, "convert rate %d <-> %d\n", src_rate, dst_rate); + if (en) + rsnd_mod_bset(adg_mod, DIV_EN, en, en); return 0; } -int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *src_mod, - struct rsnd_dai_stream *io) -{ - u32 val = rsnd_adg_ssi_ws_timing_gen2(io); - - rsnd_mod_confirm_src(src_mod); - - return rsnd_adg_set_src_timsel_gen2(src_mod, io, val); -} - static void rsnd_adg_set_ssi_clk(struct rsnd_mod *ssi_mod, u32 val) { struct rsnd_priv *priv = rsnd_mod_to_priv(ssi_mod); diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 4b77f33..fc89a67 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -446,12 +446,10 @@ int rsnd_adg_ssi_clk_stop(struct rsnd_mod *mod); int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate); int rsnd_adg_probe(struct rsnd_priv *priv); void rsnd_adg_remove(struct rsnd_priv *priv); -int rsnd_adg_set_convert_clk_gen2(struct rsnd_mod *mod, +int rsnd_adg_set_src_timesel_gen2(struct rsnd_mod *src_mod, struct rsnd_dai_stream *io, - unsigned int src_rate, - unsigned int dst_rate); -int rsnd_adg_set_convert_timing_gen2(struct rsnd_mod *mod, - struct rsnd_dai_stream *io); + unsigned int in_rate, + unsigned int out_rate); int rsnd_adg_set_cmd_timsel_gen2(struct rsnd_mod *mod, struct rsnd_dai_stream *io); diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index d1a8741..15d6ffe 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -189,7 +189,7 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, struct rsnd_priv *priv = rsnd_mod_to_priv(mod); struct device *dev = rsnd_priv_to_dev(priv); struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); - u32 convert_rate = rsnd_src_convert_rate(io, mod); + u32 fin, fout; u32 ifscr, fsrate, adinr; u32 cr, route; u32 bsdsr, bsisr; @@ -198,13 +198,16 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, if (!runtime) return; + fin = rsnd_src_get_in_rate(priv, io); + fout = rsnd_src_get_out_rate(priv, io); + /* 6 - 1/6 are very enough ratio for SRC_BSDSR */ - if (!convert_rate) + if (fin == fout) ratio = 0; - else if (convert_rate > runtime->rate) - ratio = 100 * convert_rate / runtime->rate; + else if (fin > fout) + ratio = 100 * fin / fout; else - ratio = 100 * runtime->rate / convert_rate; + ratio = 100 * fout / fin; if (ratio > 600) { dev_err(dev, "FSO/FSI ratio error\n"); @@ -222,9 +225,9 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, */ ifscr = 0; fsrate = 0; - if (convert_rate) { + if (fin != fout) { ifscr = 1; - fsrate = 0x0400000 / convert_rate * runtime->rate; + fsrate = 0x0400000 / fout * fin; } /* @@ -232,7 +235,7 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, */ cr = 0x00011110; route = 0x0; - if (convert_rate) { + if (fin != fout) { route = 0x1; if (rsnd_src_sync_is_enabled(mod)) { @@ -274,12 +277,7 @@ static void rsnd_src_set_convert_rate(struct rsnd_dai_stream *io, rsnd_mod_write(mod, SRC_O_BUSIF_MODE, 1); rsnd_mod_write(mod, SRC_BUSIF_DALIGN, rsnd_get_dalign(mod, io)); - if (convert_rate) - rsnd_adg_set_convert_clk_gen2(mod, io, - runtime->rate, - convert_rate); - else - rsnd_adg_set_convert_timing_gen2(mod, io); + rsnd_adg_set_src_timesel_gen2(mod, io, fin, fout); } static int rsnd_src_irq(struct rsnd_mod *mod,