From patchwork Mon Jan 29 03:06:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10188873 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 CCC6360375 for ; Mon, 29 Jan 2018 03:11:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDCD0286F2 for ; Mon, 29 Jan 2018 03:11:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B21CF286F5; Mon, 29 Jan 2018 03:11:24 +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=-1.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21F33286F2 for ; Mon, 29 Jan 2018 03:11:23 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 3758E267A10; Mon, 29 Jan 2018 04:11:21 +0100 (CET) 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 71405267873; Mon, 29 Jan 2018 04:11:18 +0100 (CET) Received: from relmlie2.idc.renesas.com (relmlor3.renesas.com [210.160.252.173]) by alsa0.perex.cz (Postfix) with ESMTP id 3920A26795C for ; Mon, 29 Jan 2018 04:06:44 +0100 (CET) Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 29 Jan 2018 12:06:43 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 6E6B06DA5C; Mon, 29 Jan 2018 12:06:40 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.46,429,1511794800"; d="scan'208";a="270907777" Received: from mail-sg2apc01lp0247.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.247]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 29 Jan 2018 12:06:39 +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=BUMTcE8i67O2JE0oZmcijAWxB/B/+Zwb905ONrTSR8I=; b=bUwwG4aW9SYSd7R8WukW2eWgezK1eqFSh/t4bBVk9m1I+Ay0jx8Cq0Y9bCWTRwritdmGrbuoQGp0SoaEv0UPd8wmptzuAGsKhr3ubLQ9bsTzTpT6F3B6JINY7ffAlJ11UynVtQsB8rCWmfAktndFTEskf/ni22hbUKXCfq4zxdw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.138) by HK2PR0601MB1876.apcprd06.prod.outlook.com (2603:1096:202:a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Mon, 29 Jan 2018 03:06:37 +0000 Message-ID: <87a7wx4b6g.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown In-Reply-To: <87inbl5q6q.wl%kuninori.morimoto.gx@renesas.com> References: <87607l8k9i.wl%kuninori.morimoto.gx@renesas.com> <87inbl5q6q.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Mon, 29 Jan 2018 03:06:37 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: OSBPR01CA0039.jpnprd01.prod.outlook.com (2603:1096:603:1e::27) To HK2PR0601MB1876.apcprd06.prod.outlook.com (2603:1096:202:a::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c4e31356-3c05-4440-c134-08d566c55026 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:HK2PR0601MB1876; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1876; 3:B9zg74kTtb/v4WIIJbKnA14X5Wd3efnNAdbZCwVQZijxi0Fuj0axqCD050Yd+nUMR3hOGDKLo3OWeO5Xi/tbDOyTkRoWQIQ1DqeLDz9Ce7VG/iKNVF+I7q6r4qPxe1H0rceSTMA2ampBmT1ohKPYaPUt4A2GXNEiGnDMl5EGHrVSvBAyrGsx/b/HcGCb8Do36xefXhUStERlyhua6EunmmGaUcFvg843tzrAPEuedoH5kwW8ryLsdS3bIMcj1tii; 25:036VX46mpLf5msmDCAuQbhsNElqqk0jOTI6Y8S3kP/cP7TTQEvN4W9DcuIgM+ejIuLsuOSuHLaAAqN/M1bj2dYAxcr8JWTJc20eL8HcG3ZJEowLK/tsWlkdI2wa29whxiVhxnVS51bjfchZEOf+qNjX4kFUIjAwX6cQjupMgLtmXM71JBAj+q5WubnN3+nb+fvadXHI5phJrwKbj3ejwKJF9PUnT+iuzrmuThrb7UEMCJ7+IifXvE2AuYP/8n11cyG77Y4EAoVwe0YFNLt4KZmBuOpQFawVE8fPRX0yUQJNutHCRH02TnZzZ3IeKdDtW3rTmGqzEZR7iD1m1Bs5scQ==; 31:b7rYgzSmpARJ66AhD0xg3lfqok+Ow/QWN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ejsytvoLU9r72B5PQkHCB3Q8JmFMT3BoTSB/wA/Juo X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231101)(944501161)(6055026)(6041288)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:HK2PR0601MB1876; BCL:0; PCL:0; RULEID:; SRVR:HK2PR0601MB1876; X-Forefront-PRVS: 0567A15835 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(396003)(366004)(346002)(39860400002)(39380400002)(376002)(199004)(189003)(3846002)(386003)(68736007)(59450400001)(4326008)(16586007)(6116002)(36756003)(478600001)(106356001)(53936002)(2950100002)(6486002)(6916009)(50466002)(26005)(23726003)(8936002)(105586002)(53416004)(47776003)(66066001)(5660300001)(97736004)(58126008)(316002)(186003)(305945005)(83506002)(76176011)(25786009)(86362001)(8676002)(16526019)(81156014)(81166006)(2906002)(52116002)(7696005)(7736002)(69596002)(21314002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR0601MB1876; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: renesas.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR0601MB1876; 23:w6WFYXj0HTqpQ15smNnCdjtHkmPc+lYP5Pkigqk?= =?us-ascii?Q?70OAmO5Wz8srsWBkbqrWKeieIZXSykCu0KBUw6Czq7c11EWpNklI3eluAtdY?= =?us-ascii?Q?by8p7qj0A2QF6Ii9YO5o65dV28+iB33yrIT9R1wKQRIJBWot91+9iOZD5737?= =?us-ascii?Q?f7fZNKT9oa07y8TKwv2IMIoV1xGN1e7Md3gwu3KDYh0Cdm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K6yM6ntRhPkA08p4gA9mVSEAhbApHkAhnqfNKE1lS SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1876; 20:IrCMZWvuMcR/4WSdI2an3X/+6Tm1HvInNthLNk40XLf3Y48+IlMLLn9C5UIqK4n6X5CQDA6Wali+Jid+XXvs9gOXxJxEK731oPoYI7+tcD3cqQcVnnI/NQk5150D7dvx4e24yONsje6w9ZAcyGj75UTD0yxum3S+0eeDG6+dyNo= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2018 03:06:37.8819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4e31356-3c05-4440-c134-08d566c55026 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR0601MB1876 Cc: Linux-ALSA Subject: [alsa-devel] [PATCH v2 031/186] ASoC: wm8978: replace codec to component 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 From: Kuninori Morimoto Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto --- sound/soc/codecs/wm8978.c | 185 ++++++++++++++++++++++------------------------ 1 file changed, 89 insertions(+), 96 deletions(-) diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c index cf761e2..bae4fe8 100644 --- a/sound/soc/codecs/wm8978.c +++ b/sound/soc/codecs/wm8978.c @@ -408,7 +408,7 @@ struct wm8978_pll_div { #define FIXED_PLL_SIZE (1 << 24) -static void pll_factors(struct snd_soc_codec *codec, +static void pll_factors(struct snd_soc_component *component, struct wm8978_pll_div *pll_div, unsigned int target, unsigned int source) { u64 k_part; @@ -424,7 +424,7 @@ static void pll_factors(struct snd_soc_codec *codec, } if (n_div < 6 || n_div > 12) - dev_warn(codec->dev, + dev_warn(component->dev, "WM8978 N value exceeds recommended range! N = %u\n", n_div); @@ -471,9 +471,9 @@ static int wm8978_enum_mclk(unsigned int f_out, unsigned int f_mclk, * Calculate internal frequencies and dividers, according to Figure 40 * "PLL and Clock Select Circuit" in WM8978 datasheet Rev. 2.6 */ -static int wm8978_configure_pll(struct snd_soc_codec *codec) +static int wm8978_configure_pll(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); struct wm8978_pll_div pll_div; unsigned int f_opclk = wm8978->f_opclk, f_mclk = wm8978->f_mclk, f_256fs = wm8978->f_256fs; @@ -505,9 +505,9 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec) else opclk_div = 1; - dev_dbg(codec->dev, "%s: OPCLKDIV=%d\n", __func__, opclk_div); + dev_dbg(component->dev, "%s: OPCLKDIV=%d\n", __func__, opclk_div); - snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 0x30, + snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 0x30, (opclk_div - 1) << 4); wm8978->f_pllout = f_opclk * opclk_div; @@ -533,28 +533,28 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec) f2 = wm8978->f_pllout * 4; - dev_dbg(codec->dev, "%s: f_MCLK=%uHz, f_PLLOUT=%uHz\n", __func__, + dev_dbg(component->dev, "%s: f_MCLK=%uHz, f_PLLOUT=%uHz\n", __func__, wm8978->f_mclk, wm8978->f_pllout); - pll_factors(codec, &pll_div, f2, wm8978->f_mclk); + pll_factors(component, &pll_div, f2, wm8978->f_mclk); - dev_dbg(codec->dev, "%s: calculated PLL N=0x%x, K=0x%x, div2=%d\n", + dev_dbg(component->dev, "%s: calculated PLL N=0x%x, K=0x%x, div2=%d\n", __func__, pll_div.n, pll_div.k, pll_div.div2); /* Turn PLL off for configuration... */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0); - snd_soc_write(codec, WM8978_PLL_N, (pll_div.div2 << 4) | pll_div.n); - snd_soc_write(codec, WM8978_PLL_K1, pll_div.k >> 18); - snd_soc_write(codec, WM8978_PLL_K2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8978_PLL_K3, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8978_PLL_N, (pll_div.div2 << 4) | pll_div.n); + snd_soc_component_write(component, WM8978_PLL_K1, pll_div.k >> 18); + snd_soc_component_write(component, WM8978_PLL_K2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8978_PLL_K3, pll_div.k & 0x1ff); /* ...and on again */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); if (f_opclk) /* Output PLL (OPCLK) to GPIO1 */ - snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 7, 4); + snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 7, 4); return 0; } @@ -565,8 +565,8 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec) static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); int ret = 0; switch (div_id) { @@ -588,18 +588,18 @@ static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, * find an exact MCLK divider configuration - it will * be equal to or double the OPCLK divisor. */ - ret = wm8978_configure_pll(codec); + ret = wm8978_configure_pll(component); break; case WM8978_BCLKDIV: if (div & ~0x1c) return -EINVAL; - snd_soc_update_bits(codec, WM8978_CLOCKING, 0x1c, div); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x1c, div); break; default: return -EINVAL; } - dev_dbg(codec->dev, "%s: ID %d, value %u\n", __func__, div_id, div); + dev_dbg(component->dev, "%s: ID %d, value %u\n", __func__, div_id, div); return ret; } @@ -610,18 +610,18 @@ static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); int ret = 0; - dev_dbg(codec->dev, "%s: ID %d, freq %u\n", __func__, clk_id, freq); + dev_dbg(component->dev, "%s: ID %d, freq %u\n", __func__, clk_id, freq); if (freq) { wm8978->f_mclk = freq; /* Even if MCLK is used for system clock, might have to drive OPCLK */ if (wm8978->f_opclk) - ret = wm8978_configure_pll(codec); + ret = wm8978_configure_pll(component); /* Our sysclk is fixed to 256 * fs, will configure in .hw_params() */ @@ -631,13 +631,13 @@ static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, if (wm8978->sysclk == WM8978_PLL && (!freq || clk_id == WM8978_MCLK)) { /* Clock CODEC directly from MCLK */ - snd_soc_update_bits(codec, WM8978_CLOCKING, 0x100, 0); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0); /* GPIO1 into default mode as input - before configuring PLL */ - snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 7, 0); + snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 7, 0); /* Turn off PLL */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0); wm8978->sysclk = WM8978_MCLK; wm8978->f_pllout = 0; wm8978->f_opclk = 0; @@ -651,15 +651,15 @@ static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, */ static int wm8978_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; /* * BCLK polarity mask = 0x100, LRC clock polarity mask = 0x80, * Data Format mask = 0x18: all will be calculated anew */ - u16 iface = snd_soc_read(codec, WM8978_AUDIO_INTERFACE) & ~0x198; - u16 clk = snd_soc_read(codec, WM8978_CLOCKING); + u16 iface = snd_soc_component_read32(component, WM8978_AUDIO_INTERFACE) & ~0x198; + u16 clk = snd_soc_component_read32(component, WM8978_CLOCKING); - dev_dbg(codec->dev, "%s\n", __func__); + dev_dbg(component->dev, "%s\n", __func__); /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -707,8 +707,8 @@ static int wm8978_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_write(codec, WM8978_AUDIO_INTERFACE, iface); - snd_soc_write(codec, WM8978_CLOCKING, clk); + snd_soc_component_write(component, WM8978_AUDIO_INTERFACE, iface); + snd_soc_component_write(component, WM8978_CLOCKING, clk); return 0; } @@ -720,13 +720,13 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); /* Word length mask = 0x60 */ - u16 iface_ctl = snd_soc_read(codec, WM8978_AUDIO_INTERFACE) & ~0x60; + u16 iface_ctl = snd_soc_component_read32(component, WM8978_AUDIO_INTERFACE) & ~0x60; /* Sampling rate mask = 0xe (for filters) */ - u16 add_ctl = snd_soc_read(codec, WM8978_ADDITIONAL_CONTROL) & ~0xe; - u16 clking = snd_soc_read(codec, WM8978_CLOCKING); + u16 add_ctl = snd_soc_component_read32(component, WM8978_ADDITIONAL_CONTROL) & ~0xe; + u16 clking = snd_soc_component_read32(component, WM8978_CLOCKING); enum wm8978_sysclk_src current_clk_id = clking & 0x100 ? WM8978_PLL : WM8978_MCLK; unsigned int f_sel, diff, diff_best = INT_MAX; @@ -781,7 +781,7 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, } else { if (!wm8978->f_opclk) { /* We only enter here, if OPCLK is not used */ - int ret = wm8978_configure_pll(codec); + int ret = wm8978_configure_pll(component); if (ret < 0) return ret; } @@ -812,28 +812,28 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, } if (diff) - dev_warn(codec->dev, "Imprecise sampling rate: %uHz%s\n", + dev_warn(component->dev, "Imprecise sampling rate: %uHz%s\n", f_sel * mclk_denominator[best] / mclk_numerator[best] / 256, wm8978->sysclk == WM8978_MCLK ? ", consider using PLL" : ""); - dev_dbg(codec->dev, "%s: width %d, rate %u, MCLK divisor #%d\n", __func__, + dev_dbg(component->dev, "%s: width %d, rate %u, MCLK divisor #%d\n", __func__, params_width(params), params_rate(params), best); /* MCLK divisor mask = 0xe0 */ - snd_soc_update_bits(codec, WM8978_CLOCKING, 0xe0, best << 5); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0xe0, best << 5); - snd_soc_write(codec, WM8978_AUDIO_INTERFACE, iface_ctl); - snd_soc_write(codec, WM8978_ADDITIONAL_CONTROL, add_ctl); + snd_soc_component_write(component, WM8978_AUDIO_INTERFACE, iface_ctl); + snd_soc_component_write(component, WM8978_ADDITIONAL_CONTROL, add_ctl); if (wm8978->sysclk != current_clk_id) { if (wm8978->sysclk == WM8978_PLL) /* Run CODEC from PLL instead of MCLK */ - snd_soc_update_bits(codec, WM8978_CLOCKING, + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0x100); else /* Clock CODEC directly from MCLK */ - snd_soc_update_bits(codec, WM8978_CLOCKING, 0x100, 0); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0); } return 0; @@ -841,52 +841,52 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, static int wm8978_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - dev_dbg(codec->dev, "%s: %d\n", __func__, mute); + dev_dbg(component->dev, "%s: %d\n", __func__, mute); if (mute) - snd_soc_update_bits(codec, WM8978_DAC_CONTROL, 0x40, 0x40); + snd_soc_component_update_bits(component, WM8978_DAC_CONTROL, 0x40, 0x40); else - snd_soc_update_bits(codec, WM8978_DAC_CONTROL, 0x40, 0); + snd_soc_component_update_bits(component, WM8978_DAC_CONTROL, 0x40, 0); return 0; } -static int wm8978_set_bias_level(struct snd_soc_codec *codec, +static int wm8978_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - u16 power1 = snd_soc_read(codec, WM8978_POWER_MANAGEMENT_1) & ~3; + u16 power1 = snd_soc_component_read32(component, WM8978_POWER_MANAGEMENT_1) & ~3; switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: power1 |= 1; /* VMID 75k */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, power1); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1); break; case SND_SOC_BIAS_STANDBY: /* bit 3: enable bias, bit 2: enable I/O tie off buffer */ power1 |= 0xc; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Initial cap charge at VMID 5k */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1 | 0x3); mdelay(100); } power1 |= 0x2; /* VMID 500k */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, power1); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1); break; case SND_SOC_BIAS_OFF: /* Preserve PLL - OPCLK may be used by someone */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, ~0x20, 0); - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_2, 0); - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_3, 0); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, ~0x20, 0); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_2, 0); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_3, 0); break; } - dev_dbg(codec->dev, "%s: %d, %x\n", __func__, level, power1); + dev_dbg(component->dev, "%s: %d, %x\n", __func__, level, power1); return 0; } @@ -923,31 +923,31 @@ static int wm8978_set_bias_level(struct snd_soc_codec *codec, .symmetric_rates = 1, }; -static int wm8978_suspend(struct snd_soc_codec *codec) +static int wm8978_suspend(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); /* Also switch PLL off */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, 0); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, 0); regcache_mark_dirty(wm8978->regmap); return 0; } -static int wm8978_resume(struct snd_soc_codec *codec) +static int wm8978_resume(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); /* Sync reg_cache with the hardware */ regcache_sync(wm8978->regmap); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); if (wm8978->f_pllout) /* Switch PLL on */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); return 0; } @@ -971,9 +971,9 @@ static int wm8978_resume(struct snd_soc_codec *codec) WM8978_ROUT2_SPK_CONTROL, }; -static int wm8978_probe(struct snd_soc_codec *codec) +static int wm8978_probe(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); int i; /* @@ -988,25 +988,26 @@ static int wm8978_probe(struct snd_soc_codec *codec) * written. */ for (i = 0; i < ARRAY_SIZE(update_reg); i++) - snd_soc_update_bits(codec, update_reg[i], 0x100, 0x100); + snd_soc_component_update_bits(component, update_reg[i], 0x100, 0x100); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8978 = { - .probe = wm8978_probe, - .suspend = wm8978_suspend, - .resume = wm8978_resume, - .set_bias_level = wm8978_set_bias_level, - - .component_driver = { - .controls = wm8978_snd_controls, - .num_controls = ARRAY_SIZE(wm8978_snd_controls), - .dapm_widgets = wm8978_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8978_dapm_widgets), - .dapm_routes = wm8978_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8978_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8978 = { + .probe = wm8978_probe, + .suspend = wm8978_suspend, + .resume = wm8978_resume, + .set_bias_level = wm8978_set_bias_level, + .controls = wm8978_snd_controls, + .num_controls = ARRAY_SIZE(wm8978_snd_controls), + .dapm_widgets = wm8978_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8978_dapm_widgets), + .dapm_routes = wm8978_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8978_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8978_regmap_config = { @@ -1048,8 +1049,8 @@ static int wm8978_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8978, &wm8978_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8978, &wm8978_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); return ret; @@ -1058,13 +1059,6 @@ static int wm8978_i2c_probe(struct i2c_client *i2c, return 0; } -static int wm8978_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8978_i2c_id[] = { { "wm8978", 0 }, { } @@ -1083,7 +1077,6 @@ static int wm8978_i2c_remove(struct i2c_client *client) .of_match_table = wm8978_of_match, }, .probe = wm8978_i2c_probe, - .remove = wm8978_i2c_remove, .id_table = wm8978_i2c_id, };