From patchwork Mon Jan 29 03:15:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10188931 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 A12F3602C8 for ; Mon, 29 Jan 2018 03:23:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 950662864A for ; Mon, 29 Jan 2018 03:23:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A13328688; Mon, 29 Jan 2018 03:23:51 +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 0E03C2864A for ; Mon, 29 Jan 2018 03:23:50 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0CE822679EE; Mon, 29 Jan 2018 04:23:48 +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 68D812679EE; Mon, 29 Jan 2018 04:23:47 +0100 (CET) Received: from relmlie3.idc.renesas.com (relmlor4.renesas.com [210.160.252.174]) by alsa0.perex.cz (Postfix) with ESMTP id AC976267A97 for ; Mon, 29 Jan 2018 04:15:12 +0100 (CET) Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie3.idc.renesas.com with ESMTP; 29 Jan 2018 12:15:10 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id D29CF6E177; Mon, 29 Jan 2018 12:15:10 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.46,429,1511794800"; d="scan'208";a="269588705" Received: from mail-hk2apc01lp0216.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.216]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 29 Jan 2018 12:15:10 +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=6vZoqxLGaYLpYBMW1EW1ZUk8LwA+8wkOXQcY+j6MNvg=; b=gzbVmEyh82wdpSV+8tBGQucHUqEqzwiPrXEZ0JFdpKCSlKd1i6N5+EXTQaRwQ9w8NwJBjm12quzotae1bskNFd57IX1kiAbF3f38DX8QSlp7TOa6VuUaT62hfJoK8wG3k5EpE6kEi2IIH9SvEWHSSB89IJuhjhziCdixE3KQhxk= Received: from morimoto-PC.renesas.com (211.11.155.138) by KL1PR0601MB1880.apcprd06.prod.outlook.com (2603:1096:802:8::16) 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:15:08 +0000 Message-ID: <87607l2w7w.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:15:08 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: TY1PR01CA0131.jpnprd01.prod.outlook.com (2603:1096:401:d::49) To KL1PR0601MB1880.apcprd06.prod.outlook.com (2603:1096:802:8::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c30381d6-b279-41e3-992b-08d566c68075 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:KL1PR0601MB1880; X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1880; 3:JKc7zOyIIRaS54oC2VHASiEddpHOJ4Gs8URfLCPM9wd+Bu5L+lXWivxJTU0H5+JxC5MsoekXoED/5cTURpI8ivaxJ/xcWT0prToHh76q7ureoRWvDK1GKxMwszaKoHD1kU13dqylLRkKDfCUeDmUYYzx09AywYT9JBLSQhwqOk7y14a63uTP/63iiPhzu6uxjcq+j1DTy9q/2DWMi061haTBbyLwwxZD1WQHbvre67cv55OSGvMP/gjgoLWgGXRj; 25:DRXiwDqXcmjz4a6PSpRSyZElV8Zey2enVCRY3f0DPVsChnuUbj4Nq1ozaGfzR6XObvcpAiHchC42ynixEm6+yaPNI5QMd5/dC+3hS9cFwPozu9cY5Dmgsok7z2c0EWMHQLOJ28K4v5f35tWIbDijO3eRl7IzX3aZF1UfuhU6JrOVWW1HtiXebDhqJ2nrIabIr8S3qjsg2X5DJ6MGe4/M8WmH5NufWFQ4ZQwM97ltYFqYlNW6qdgckgncj5BgA7Gs2+yEiOBfDBiPCh+2p12Z9hF1HAG3PU1a0UcobrCuNhRn5mEhf5lxYffGNUnYkwSrkyDX7u2yiykQ8Ulc285Aiw==; 31:sRJiEyrh5MXD5Beuxh1SoGzi4diSTzbTsMlRjcLGgxeiRl0xu2iycCw2gTlTwQ8C3LJrzNESBUuPv4gkkJasZLhdcehLc9gjtd5H3hLCx0kCON84MqV6ydC5a/ZVKkP0u03fx/sODd08G+hioloBhTMAq+KqEsEzb6p5Yqq8TFdTE+IXN0phUwj+7nG18MCF34hGbPtjSw38lejHbwfeiSEXCh66tvpKThlyxMrtxdk= X-MS-TrafficTypeDiagnostic: KL1PR0601MB1880: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1880; 20:GLS2zjxbi/oNeJOcS5eMBIhN9e6Gtc7v4NgdXjTGM/OMKn5GmMntJ9BZUI4uDcce3Xye9k0AQ2LOkSLFZcBqaUu8twv+UuQcMeWojqZdpdJZTJsPih8R5BjGybx3Ntyl4KizVZWbRBxJXIWZ5K2jtNFlakGzRjr2U5FCAu8Y7OmGI6qsnBakHFVGH2zd6wyVu89eaNlJl/BJ7D+nNsnAlhDtdEP6ybtVAEXICd+akH1cUrtXGBtNYd18vkBBs+VgCIfMV7jzzsVIdg1aiidp+/LbmpNITVIDNJe29CVZ0YyeHvvxaUqtijzzAjrQM5ng2S2zWr+XyCdrMN9TkGzqpOXxHBr88pk8PpFEMGZuha6rwSZQth7X++MUOixUD9sLuq7/YZO3zreW5lv1/iprCESsx2JBNXGQ4B3oixq20nuB/5T5bqvclgR8hTAyM6b2w8uTYojOcSlTtJ4H4HyazcUA1CXpEjMWmgQZdfS+fy/DNv3S2+YVAz7+5zHZTpx6; 4:eh9qa0fHdWhmDwd2H0A+xG3FLqg28TC+cgnBywiBpVnHU7gR0Kg7+6HaCVsa9YmNfrVN9TMMPoxiD08ijv4gD3/ubj6LzAHqWf/NRTblwXxd72e8/nmWSnwHQqFLWKRhOTY6dN4mrNlQz4TkMBEgWDZERYehb1ZnNaZgDSN21djAxlr+cPLQbZbFgLVFB7DAXhCPpMa+7sxotAmTZGsD5DrcOJPjM2JcEs58ECsRspElPauWal5Y/rlD6V35QwzWJROiZZ71ve6lhXctZwKbU0v0Tplgwdtedy0e/7d4ZfTTvwH7+loDFcVscu89qLwJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231101)(944501161)(6055026)(6041288)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123562045)(6072148)(201708071742011); SRVR:KL1PR0601MB1880; BCL:0; PCL:0; RULEID:; SRVR:KL1PR0601MB1880; X-Forefront-PRVS: 0567A15835 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(396003)(39860400002)(39380400002)(346002)(376002)(199004)(189003)(6486002)(23726003)(6116002)(3846002)(16526019)(186003)(26005)(2906002)(53936002)(97736004)(76176011)(52116002)(7696005)(68736007)(81156014)(81166006)(8936002)(478600001)(8676002)(4326008)(25786009)(36756003)(86362001)(47776003)(66066001)(50466002)(53416004)(106356001)(59450400001)(2950100002)(316002)(16586007)(83506002)(305945005)(105586002)(5660300001)(7736002)(6916009)(58126008)(386003)(69596002)(21314002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1PR0601MB1880; 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; KL1PR0601MB1880; 23:eNb0/eEWnqabNsFANy3yu7OBwI2OKwvzUXAIKrf?= =?us-ascii?Q?T3OFPwSFbcWZU4LXVKxxBbUiMrNHoeldSLiUf7SB3RHFQJy0ZJ4G19bryAun?= =?us-ascii?Q?0BTM6L6QQWyLxyShP5SPaLR/NvFd2wlcJTvpS497GKAMjpQnaVeI8oZzR9D9?= =?us-ascii?Q?kHFhIfhQM3W2WsGZsMLA8mvSplIaTWc5zkGx1lKkH0J+pwMrdyo60pP3Rk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yiYnfpIyaAQD6gY4DQuECdNsupCxPYBa SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; KL1PR0601MB1880; 20:Cl1T3Bzw54nMwcEPZtnNlghtY8sClopCHq7yAo5Vx0gDrwyJAbiaafAeIkQ9KWJMqNQPB0hfQznZfYhJAN44zdNBLDkQtx0exMq425aIPBy5+kdY2rfs/TtiCOAxK5naZdxyqgjlBMONcUhSGOr/10c8G2i6R35SL9SW9yxI8RY= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2018 03:15:08.3322 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c30381d6-b279-41e3-992b-08d566c68075 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR0601MB1880 Cc: Linux-ALSA Subject: [alsa-devel] [PATCH v2 059/186] ASoC: rt274: 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 = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto --- sound/soc/codecs/rt274.c | 206 +++++++++++++++++++++++------------------------ 1 file changed, 102 insertions(+), 104 deletions(-) diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index 8f92e5c..d88e673 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.c @@ -38,7 +38,7 @@ struct rt274_priv { struct reg_default *index_cache; int index_cache_size; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct i2c_client *i2c; struct snd_soc_jack *jack; struct delayed_work jack_detect_work; @@ -338,13 +338,13 @@ static bool rt274_readable_register(struct device *dev, unsigned int reg) } #ifdef CONFIG_PM -static void rt274_index_sync(struct snd_soc_codec *codec) +static void rt274_index_sync(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < INDEX_CACHE_SIZE; i++) { - snd_soc_write(codec, rt274->index_cache[i].reg, + snd_soc_component_write(component, rt274->index_cache[i].reg, rt274->index_cache[i].def); } } @@ -357,7 +357,7 @@ static int rt274_jack_detect(struct rt274_priv *rt274, bool *hp, bool *mic) *hp = false; *mic = false; - if (!rt274->codec) + if (!rt274->component) return -EINVAL; regmap_read(rt274->regmap, RT274_GET_HP_SENSE, &buf); @@ -393,10 +393,10 @@ static void rt274_jack_detect_work(struct work_struct *work) static irqreturn_t rt274_irq(int irq, void *data); -static int rt274_mic_detect(struct snd_soc_codec *codec, +static int rt274_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); if (jack == NULL) { /* Disable jack detection */ @@ -609,8 +609,8 @@ static int rt274_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 rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int d_len_code = 0, c_len_code = 0; @@ -620,7 +620,7 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, case 48000: break; default: - dev_err(codec->dev, "Unsupported sample rate %d\n", + dev_err(component->dev, "Unsupported sample rate %d\n", params_rate(params)); return -EINVAL; } @@ -628,7 +628,7 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, case 12288000: case 24576000: if (params_rate(params) != 48000) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt274->sys_clk); return -EINVAL; } @@ -636,7 +636,7 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, case 11289600: case 22579200: if (params_rate(params) != 44100) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt274->sys_clk); return -EINVAL; } @@ -647,7 +647,7 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, /* bit 3:0 Number of Channel */ val |= (params_channels(params) - 1); } else { - dev_err(codec->dev, "Unsupported channels %d\n", + dev_err(component->dev, "Unsupported channels %d\n", params_channels(params)); return -EINVAL; } @@ -685,29 +685,29 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, if (rt274->master) c_len_code = 0x3; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, 0xc018, d_len_code << 3 | c_len_code << 14); - dev_dbg(codec->dev, "format val = 0x%x\n", val); + dev_dbg(component->dev, "format val = 0x%x\n", val); - snd_soc_update_bits(codec, RT274_DAC_FORMAT, 0x407f, val); - snd_soc_update_bits(codec, RT274_ADC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT274_DAC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT274_ADC_FORMAT, 0x407f, val); return 0; } static int rt274_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_MODE_MASK, RT274_I2S_MODE_M); rt274->master = true; break; case SND_SOC_DAIFMT_CBS_CFS: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_MODE_MASK, RT274_I2S_MODE_S); rt274->master = false; break; @@ -717,27 +717,27 @@ static int rt274_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - snd_soc_update_bits(codec, RT274_I2S_CTRL1, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_FMT_MASK, RT274_I2S_FMT_I2S); break; case SND_SOC_DAIFMT_LEFT_J: - snd_soc_update_bits(codec, RT274_I2S_CTRL1, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_FMT_MASK, RT274_I2S_FMT_LJ); break; case SND_SOC_DAIFMT_DSP_A: - snd_soc_update_bits(codec, RT274_I2S_CTRL1, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_FMT_MASK, RT274_I2S_FMT_PCMA); break; case SND_SOC_DAIFMT_DSP_B: - snd_soc_update_bits(codec, RT274_I2S_CTRL1, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_FMT_MASK, RT274_I2S_FMT_PCMB); break; default: return -EINVAL; } /* bit 15 Stream Type 0:PCM 1:Non-PCM */ - snd_soc_update_bits(codec, RT274_DAC_FORMAT, 0x8000, 0); - snd_soc_update_bits(codec, RT274_ADC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT274_DAC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT274_ADC_FORMAT, 0x8000, 0); return 0; } @@ -745,47 +745,47 @@ static int rt274_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt274_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); switch (source) { case RT274_PLL2_S_MCLK: - snd_soc_update_bits(codec, RT274_PLL2_CTRL, + snd_soc_component_update_bits(component, RT274_PLL2_CTRL, RT274_PLL2_SRC_MASK, RT274_PLL2_SRC_MCLK); break; default: - dev_warn(codec->dev, "invalid pll source, use BCLK\n"); + dev_warn(component->dev, "invalid pll source, use BCLK\n"); case RT274_PLL2_S_BCLK: - snd_soc_update_bits(codec, RT274_PLL2_CTRL, + snd_soc_component_update_bits(component, RT274_PLL2_CTRL, RT274_PLL2_SRC_MASK, RT274_PLL2_SRC_BCLK); break; } if (source == RT274_PLL2_S_BCLK) { - snd_soc_update_bits(codec, RT274_MCLK_CTRL, + snd_soc_component_update_bits(component, RT274_MCLK_CTRL, (0x3 << 12), (0x3 << 12)); switch (rt274->fs) { case 50: - snd_soc_write(codec, 0x7a, 0xaab6); - snd_soc_write(codec, 0x7b, 0x0301); - snd_soc_write(codec, 0x7c, 0x04fe); + snd_soc_component_write(component, 0x7a, 0xaab6); + snd_soc_component_write(component, 0x7b, 0x0301); + snd_soc_component_write(component, 0x7c, 0x04fe); break; case 64: - snd_soc_write(codec, 0x7a, 0xaa96); - snd_soc_write(codec, 0x7b, 0x8003); - snd_soc_write(codec, 0x7c, 0x081e); + snd_soc_component_write(component, 0x7a, 0xaa96); + snd_soc_component_write(component, 0x7b, 0x8003); + snd_soc_component_write(component, 0x7c, 0x081e); break; case 128: - snd_soc_write(codec, 0x7a, 0xaa96); - snd_soc_write(codec, 0x7b, 0x8003); - snd_soc_write(codec, 0x7c, 0x080e); + snd_soc_component_write(component, 0x7a, 0xaa96); + snd_soc_component_write(component, 0x7b, 0x8003); + snd_soc_component_write(component, 0x7c, 0x080e); break; default: - dev_warn(codec->dev, "invalid freq_in, assume 4.8M\n"); + dev_warn(component->dev, "invalid freq_in, assume 4.8M\n"); case 100: - snd_soc_write(codec, 0x7a, 0xaab6); - snd_soc_write(codec, 0x7b, 0x0301); - snd_soc_write(codec, 0x7c, 0x047e); + snd_soc_component_write(component, 0x7a, 0xaab6); + snd_soc_component_write(component, 0x7b, 0x0301); + snd_soc_component_write(component, 0x7c, 0x047e); break; } } @@ -796,11 +796,11 @@ static int rt274_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt274_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); unsigned int clk_src, mclk_en; - dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); + dev_dbg(component->dev, "%s freq=%d\n", __func__, freq); switch (clk_id) { case RT274_SCLK_S_MCLK: @@ -818,43 +818,43 @@ static int rt274_set_dai_sysclk(struct snd_soc_dai *dai, default: mclk_en = RT274_MCLK_MODE_DIS; clk_src = RT274_CLK_SRC_MCLK; - dev_warn(codec->dev, "invalid sysclk source, use PLL1\n"); + dev_warn(component->dev, "invalid sysclk source, use PLL1\n"); break; } - snd_soc_update_bits(codec, RT274_MCLK_CTRL, + snd_soc_component_update_bits(component, RT274_MCLK_CTRL, RT274_MCLK_MODE_MASK, mclk_en); - snd_soc_update_bits(codec, RT274_CLK_CTRL, + snd_soc_component_update_bits(component, RT274_CLK_CTRL, RT274_CLK_SRC_MASK, clk_src); switch (freq) { case 19200000: if (clk_id == RT274_SCLK_S_MCLK) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL2, 0x40, 0x40); break; case 24000000: if (clk_id == RT274_SCLK_S_MCLK) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL2, 0x40, 0x0); break; case 12288000: case 11289600: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_MCLK_CTRL, 0x1fcf, 0x0008); break; case 24576000: case 22579200: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_MCLK_CTRL, 0x1fcf, 0x1543); break; default: - dev_err(codec->dev, "Unsupported system clock\n"); + dev_err(component->dev, "Unsupported system clock\n"); return -EINVAL; } @@ -866,16 +866,16 @@ static int rt274_set_dai_sysclk(struct snd_soc_dai *dai, static int rt274_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); rt274->fs = ratio; if ((ratio / 50) == 0) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, 0x1000, 0x1000); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, 0x1000, 0x0); @@ -886,28 +886,28 @@ static int rt274_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (rx_mask || tx_mask) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_TDM_EN, RT274_TDM_EN); } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_TDM_EN, RT274_TDM_DIS); return 0; } switch (slots) { case 4: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_TDM_CH_NUM, RT274_TDM_4CH); break; case 2: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_TDM_CH_NUM, RT274_TDM_2CH); break; default: - dev_err(codec->dev, + dev_err(component->dev, "Support 2 or 4 slots TDM only\n"); return -EINVAL; } @@ -915,20 +915,20 @@ static int rt274_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return 0; } -static int rt274_set_bias_level(struct snd_soc_codec *codec, +static int rt274_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_PREPARE: if (SND_SOC_BIAS_STANDBY == - snd_soc_codec_get_bias_level(codec)) { - snd_soc_write(codec, + snd_soc_component_get_bias_level(component)) { + snd_soc_component_write(component, RT274_SET_AUDIO_POWER, AC_PWRST_D0); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, + snd_soc_component_write(component, RT274_SET_AUDIO_POWER, AC_PWRST_D3); break; @@ -968,11 +968,11 @@ static irqreturn_t rt274_irq(int irq, void *data) return IRQ_HANDLED; } -static int rt274_probe(struct snd_soc_codec *codec) +static int rt274_probe(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); - rt274->codec = codec; + rt274->component = component; if (rt274->i2c->irq) { INIT_DELAYED_WORK(&rt274->jack_detect_work, @@ -984,19 +984,17 @@ static int rt274_probe(struct snd_soc_codec *codec) return 0; } -static int rt274_remove(struct snd_soc_codec *codec) +static void rt274_remove(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); cancel_delayed_work_sync(&rt274->jack_detect_work); - - return 0; } #ifdef CONFIG_PM -static int rt274_suspend(struct snd_soc_codec *codec) +static int rt274_suspend(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt274->regmap, true); regcache_mark_dirty(rt274->regmap); @@ -1004,12 +1002,12 @@ static int rt274_suspend(struct snd_soc_codec *codec) return 0; } -static int rt274_resume(struct snd_soc_codec *codec) +static int rt274_resume(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt274->regmap, false); - rt274_index_sync(codec); + rt274_index_sync(component); regcache_sync(rt274->regmap); return 0; @@ -1055,22 +1053,22 @@ static int rt274_resume(struct snd_soc_codec *codec) }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt274 = { - .probe = rt274_probe, - .remove = rt274_remove, - .suspend = rt274_suspend, - .resume = rt274_resume, - .set_bias_level = rt274_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt274_snd_controls, - .num_controls = ARRAY_SIZE(rt274_snd_controls), - .dapm_widgets = rt274_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt274_dapm_widgets), - .dapm_routes = rt274_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt274_dapm_routes), - }, - .set_jack = rt274_mic_detect, +static const struct snd_soc_component_driver soc_component_dev_rt274 = { + .probe = rt274_probe, + .remove = rt274_remove, + .suspend = rt274_suspend, + .resume = rt274_resume, + .set_bias_level = rt274_set_bias_level, + .set_jack = rt274_mic_detect, + .controls = rt274_snd_controls, + .num_controls = ARRAY_SIZE(rt274_snd_controls), + .dapm_widgets = rt274_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt274_dapm_widgets), + .dapm_routes = rt274_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt274_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt274_regmap = { @@ -1191,7 +1189,8 @@ static int rt274_i2c_probe(struct i2c_client *i2c, } } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt274, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt274, rt274_dai, ARRAY_SIZE(rt274_dai)); return ret; @@ -1203,7 +1202,6 @@ static int rt274_i2c_remove(struct i2c_client *i2c) if (i2c->irq) free_irq(i2c->irq, rt274); - snd_soc_unregister_codec(&i2c->dev); return 0; }