From patchwork Fri Sep 1 06:36:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9933575 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 9A6C16016C for ; Fri, 1 Sep 2017 06:36:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 875EF2847D for ; Fri, 1 Sep 2017 06:36:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77CC628543; Fri, 1 Sep 2017 06:36:56 +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 CCCC32847D for ; Fri, 1 Sep 2017 06:36:54 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 3FEB3267649; Fri, 1 Sep 2017 08:36:53 +0200 (CEST) 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 71320267649; Fri, 1 Sep 2017 08:36:51 +0200 (CEST) Received: from relmlie3.idc.renesas.com (relmlor4.renesas.com [210.160.252.174]) by alsa0.perex.cz (Postfix) with ESMTP id 2A43C26765A for ; Fri, 1 Sep 2017 08:36:38 +0200 (CEST) Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie3.idc.renesas.com with ESMTP; 01 Sep 2017 15:36:37 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 5B2CD6C919; Fri, 1 Sep 2017 15:36:37 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.41,456,1498489200"; d="scan'208";a="255518250" Received: from mail-sg2apc01lp0246.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.246]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 01 Sep 2017 15:36:36 +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=h/LCsHVipmI5yooMtrb7XWfjFWi+ynJkywfYj3Rz06Q=; b=Ohjj3WqZDEPoDPnxaGjdFPv5dZZSUcxfqknEpvR9rRDJrO5cb3qrOomSfmmc2JWzZhkz+xZMU3M7VPEx/vZ1pTrmKLw/MiASke060217mB4osQ+epSNXNf+cdsffv5EC4qwI9E/3gsAexXw0Beu4sR6knVXCUQaEAxrntZ2d9to= 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 PS1PR0601MB1884.apcprd06.prod.outlook.com (2603:1096:803:8::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Fri, 1 Sep 2017 06:36:33 +0000 Message-ID: <87lglzj5iv.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: <87r2vrj5lz.wl%kuninori.morimoto.gx@renesas.com> References: <873787ngjb.wl%kuninori.morimoto.gx@renesas.com> <87r2vrj5lz.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 1 Sep 2017 06:36:33 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: OS2PR01CA0110.jpnprd01.prod.outlook.com (2603:1096:602:1::28) To PS1PR0601MB1884.apcprd06.prod.outlook.com (2603:1096:803:8::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 353a298f-0702-4d4f-7f7a-08d4f103c9d5 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:PS1PR0601MB1884; X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1884; 3:Cp2ehtRlGOp2nqljEjQIriXBXoSSMBozftV9muEoml8T4BpWRzlvXy59/nnU2FogVNK95wC4WYqm3D/Rq0o8Od96GlkEI+cnJzpzYWthbE418dSAXlMRvIwGUMpQuN7Er7vT4hBDVT01ZvXt6HF3YxHHlwmi/OjqqJ+HEsPHqksiX4Lo6DUfX4K+CBI8rI+L2ShKHvooIi4KlJ7+cxdO3HxbZxh/1+MhlYJf0Knbew4yeaoKmwTu+Lq4tXmhfCE2; 25:3jTOpAslioJChOtI3RhBUMwTuGGvd81NWqiW4EMz+/lixeymLETATJE4Fj6P6pkhON2ELksQq/fPrtLxhptF3IyBzhVDEE8Bw9qO+Vs7V1hkkVpFVkCNWQL2AkWWDbLdFa08gmYMP9JEdW4qjjYW4V3zGQ4Kyvpvy0bMFl8sbsU9oBSDjg3lmld6hyCxNpjEb6ELyLZp2pZAVTzSKcyE1Lqo30FRlsJd8lZe00QkwFAjmGxFj94aI2msZGkZTuK2LnKeWm+FMZt/6n07QjRoI+fzC4mxV1gLlurz0Eb0jJJjwvo01oaWNtQ40ev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m59f2rNBFvnXMYldWLLX4IEV9r8b+8ryuwTQnRgIIDkg9ljL0tTupB/Exu/Et2A/FrnGWeEqxnnzDs8zgK3o= X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123555025)(20161123558100)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:PS1PR0601MB1884; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:PS1PR0601MB1884; X-Forefront-PRVS: 0417A3FFD2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(7370300001)(4630300001)(6009001)(39860400002)(199003)(189002)(86362001)(2950100002)(6486002)(6916009)(110136004)(83506001)(50986999)(50466002)(54356999)(76176999)(36756003)(54906002)(53936002)(101416001)(68736007)(33646002)(66066001)(47776003)(4326008)(25786009)(106356001)(105586002)(189998001)(7350300001)(478600001)(5660300001)(69596002)(97736004)(4001350100001)(81166006)(81156014)(8676002)(2906002)(7736002)(305945005)(3846002)(23726003)(6116002)(53416004)(42186005)(21314002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:PS1PR0601MB1884; 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; PS1PR0601MB1884; 23:scW4bmfjbJ/nKyiYBdtaBin/3HSt/jv9Hta9pZy?= =?us-ascii?Q?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ahXSBOa1QpssQpyaU1i4novnkrxPAGegMBgBDitDVaNIKirWmc1+IPW/v7x62Uu7UpHNLh+ceItYcCORCdDB7bFiLd9yzhBzEerYE6F5MTttLFFdOaFDydmOo/Es= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; PS1PR0601MB1884; 20:HY9/ZLkLGgbjDVpKSNeXxA19in2kbg3J7JsyA0O9+TbXa93v8/Atao97+y1/dmgQ4gDOlP2gdHOtnAvNSrH/9yCpRBsKcoaVErG5WuUfB0ZJFVfgZFSu8gG7qSjQF+QU+wwjRGgwfK+5OTzNhl1DyVJc9VVV2RI0AzJN3wBGBKo= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Sep 2017 06:36:33.5896 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS1PR0601MB1884 Cc: Linux-ALSA , Lars-Peter Subject: [alsa-devel] [SAMPLE 4/6] ASoC: convert codec to compoent on sgtl5000 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 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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto --- sound/soc/codecs/sgtl5000.c | 173 +++++++++++++++++++++----------------------- 1 file changed, 84 insertions(+), 89 deletions(-) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index f2bb4fe..00ddc66 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -147,19 +147,19 @@ struct sgtl5000_priv { static int mic_bias_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: /* change mic bias resistor */ - snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_R_MASK, sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_R_MASK, 0); break; } @@ -174,12 +174,12 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w, static int power_vag_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP; switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); msleep(400); break; @@ -190,9 +190,9 @@ static int power_vag_event(struct snd_soc_dapm_widget *w, * operational to prevent inadvertently starving the * other one of them. */ - if ((snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER) & + if ((snd_soc_component_read32(component, SGTL5000_CHIP_ANA_POWER) & mask) != mask) { - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_VAG_POWERUP, 0); msleep(400); } @@ -318,12 +318,12 @@ static int dac_info_volsw(struct snd_kcontrol *kcontrol, static int dac_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int reg; int l; int r; - reg = snd_soc_read(codec, SGTL5000_CHIP_DAC_VOL); + reg = snd_soc_component_read32(component, SGTL5000_CHIP_DAC_VOL); /* get left channel volume */ l = (reg & SGTL5000_DAC_VOL_LEFT_MASK) >> SGTL5000_DAC_VOL_LEFT_SHIFT; @@ -371,7 +371,7 @@ static int dac_get_volsw(struct snd_kcontrol *kcontrol, static int dac_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int reg; int l; int r; @@ -391,7 +391,7 @@ static int dac_put_volsw(struct snd_kcontrol *kcontrol, reg = l << SGTL5000_DAC_VOL_LEFT_SHIFT | r << SGTL5000_DAC_VOL_RIGHT_SHIFT; - snd_soc_write(codec, SGTL5000_CHIP_DAC_VOL, reg); + snd_soc_component_write(component, SGTL5000_CHIP_DAC_VOL, reg); return 0; } @@ -409,9 +409,9 @@ static int dac_put_volsw(struct snd_kcontrol *kcontrol, static int avc_get_threshold(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int db, i; - u16 reg = snd_soc_read(codec, SGTL5000_DAP_AVC_THRESHOLD); + u16 reg = snd_soc_component_read32(component, SGTL5000_DAP_AVC_THRESHOLD); /* register value 0 => -96dB */ if (!reg) { @@ -442,7 +442,7 @@ static int avc_get_threshold(struct snd_kcontrol *kcontrol, static int avc_put_threshold(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int db; u16 reg; @@ -450,7 +450,7 @@ static int avc_put_threshold(struct snd_kcontrol *kcontrol, if (db < 0 || db > 96) return -EINVAL; reg = avc_thr_db2reg[db]; - snd_soc_write(codec, SGTL5000_DAP_AVC_THRESHOLD, reg); + snd_soc_component_write(component, SGTL5000_DAP_AVC_THRESHOLD, reg); return 0; } @@ -528,10 +528,10 @@ static const DECLARE_TLV_DB_RANGE(mic_gain_tlv, /* mute the codec used by alsa core */ static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 adcdac_ctrl = SGTL5000_DAC_MUTE_LEFT | SGTL5000_DAC_MUTE_RIGHT; - snd_soc_update_bits(codec, SGTL5000_CHIP_ADCDAC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ADCDAC_CTRL, adcdac_ctrl, mute ? adcdac_ctrl : 0); return 0; @@ -540,8 +540,8 @@ static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute) /* set codec format */ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); u16 i2sctl = 0; sgtl5000->master = 0; @@ -599,7 +599,7 @@ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_write(codec, SGTL5000_CHIP_I2S_CTRL, i2sctl); + snd_soc_component_write(component, SGTL5000_CHIP_I2S_CTRL, i2sctl); return 0; } @@ -608,8 +608,8 @@ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int sgtl5000_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 sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); switch (clk_id) { case SGTL5000_SYSCLK: @@ -635,9 +635,9 @@ static int sgtl5000_set_dai_sysclk(struct snd_soc_dai *codec_dai, * and above. * 3. usage of sys_mclk is preferred over pll to save power. */ -static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) +static int sgtl5000_set_clock(struct snd_soc_component *component, int frame_rate) { - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); int clk_ctl = 0; int sys_fs; /* sample freq */ @@ -690,7 +690,7 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) clk_ctl |= SGTL5000_SYS_FS_96k << SGTL5000_SYS_FS_SHIFT; break; default: - dev_err(codec->dev, "frame rate %d not supported\n", + dev_err(component->dev, "frame rate %d not supported\n", frame_rate); return -EINVAL; } @@ -719,9 +719,9 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) clk_ctl |= SGTL5000_MCLK_FREQ_PLL << SGTL5000_MCLK_FREQ_SHIFT; } else { - dev_err(codec->dev, + dev_err(component->dev, "PLL not supported in slave mode\n"); - dev_err(codec->dev, "%d ratio is not supported. " + dev_err(component->dev, "%d ratio is not supported. " "SYS_MCLK needs to be 256, 384 or 512 * fs\n", sgtl5000->sysclk / frame_rate); return -EINVAL; @@ -754,31 +754,31 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) pll_ctl = int_div << SGTL5000_PLL_INT_DIV_SHIFT | frac_div << SGTL5000_PLL_FRAC_DIV_SHIFT; - snd_soc_write(codec, SGTL5000_CHIP_PLL_CTRL, pll_ctl); + snd_soc_component_write(component, SGTL5000_CHIP_PLL_CTRL, pll_ctl); if (div2) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, SGTL5000_CHIP_CLK_TOP_CTRL, SGTL5000_INPUT_FREQ_DIV2, SGTL5000_INPUT_FREQ_DIV2); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, SGTL5000_CHIP_CLK_TOP_CTRL, SGTL5000_INPUT_FREQ_DIV2, 0); /* power up pll */ - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP, SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP); /* if using pll, clk_ctrl must be set after pll power up */ - snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl); + snd_soc_component_write(component, SGTL5000_CHIP_CLK_CTRL, clk_ctl); } else { /* otherwise, clk_ctrl must be set before pll power down */ - snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl); + snd_soc_component_write(component, SGTL5000_CHIP_CLK_CTRL, clk_ctl); /* power down pll */ - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP, 0); } @@ -794,8 +794,8 @@ static int sgtl5000_pcm_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 sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); int channels = params_channels(params); int i2s_ctl = 0; int stereo; @@ -803,7 +803,7 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, /* sysclk should already set */ if (!sgtl5000->sysclk) { - dev_err(codec->dev, "%s: set sysclk first!\n", __func__); + dev_err(component->dev, "%s: set sysclk first!\n", __func__); return -EFAULT; } @@ -813,11 +813,11 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, stereo = SGTL5000_ADC_STEREO; /* set mono to save power */ - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, stereo, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, stereo, channels == 1 ? 0 : stereo); /* set codec clock base on lrclk */ - ret = sgtl5000_set_clock(codec, params_rate(params)); + ret = sgtl5000_set_clock(component, params_rate(params)); if (ret) return ret; @@ -851,7 +851,7 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, SGTL5000_CHIP_I2S_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_I2S_CTRL, SGTL5000_I2S_DLEN_MASK | SGTL5000_I2S_SCLKFREQ_MASK, i2s_ctl); @@ -868,19 +868,19 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, * stop: * on --> prepare --> standby */ -static int sgtl5000_set_bias_level(struct snd_soc_codec *codec, +static int sgtl5000_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_REFTOP_POWERUP, SGTL5000_REFTOP_POWERUP); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_REFTOP_POWERUP, 0); break; } @@ -1020,7 +1020,7 @@ static bool sgtl5000_readable(struct device *dev, unsigned int reg) * 1. vddd provided by external or not * 2. vdda and vddio voltage value. > 3.1v or not */ -static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) +static int sgtl5000_set_power_regs(struct snd_soc_component *component) { int vddd; int vdda; @@ -1032,7 +1032,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) int vol_quot; int lo_vol; size_t i; - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); vdda = regulator_get_voltage(sgtl5000->supplies[VDDA].consumer); vddio = regulator_get_voltage(sgtl5000->supplies[VDDIO].consumer); @@ -1045,14 +1045,14 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) vddd = vddd / 1000; if (vdda <= 0 || vddio <= 0 || vddd < 0) { - dev_err(codec->dev, "regulator voltage not set correctly\n"); + dev_err(component->dev, "regulator voltage not set correctly\n"); return -EINVAL; } /* according to datasheet, maximum voltage of supplies */ if (vdda > 3600 || vddio > 3600 || vddd > 1980) { - dev_err(codec->dev, + dev_err(component->dev, "exceed max voltage vdda %dmV vddio %dmV vddd %dmV\n", vdda, vddio, vddd); @@ -1060,15 +1060,15 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) } /* reset value */ - ana_pwr = snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER); + ana_pwr = snd_soc_component_read32(component, SGTL5000_CHIP_ANA_POWER); ana_pwr |= SGTL5000_DAC_STEREO | SGTL5000_ADC_STEREO | SGTL5000_REFTOP_POWERUP; - lreg_ctrl = snd_soc_read(codec, SGTL5000_CHIP_LINREG_CTRL); + lreg_ctrl = snd_soc_component_read32(component, SGTL5000_CHIP_LINREG_CTRL); if (vddio < 3100 && vdda < 3100) { /* enable internal oscillator used for charge pump */ - snd_soc_update_bits(codec, SGTL5000_CHIP_CLK_TOP_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_CLK_TOP_CTRL, SGTL5000_INT_OSC_EN, SGTL5000_INT_OSC_EN); /* Enable VDDC charge pump */ @@ -1081,9 +1081,9 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) SGTL5000_VDDC_MAN_ASSN_SHIFT; } - snd_soc_write(codec, SGTL5000_CHIP_LINREG_CTRL, lreg_ctrl); + snd_soc_component_write(component, SGTL5000_CHIP_LINREG_CTRL, lreg_ctrl); - snd_soc_write(codec, SGTL5000_CHIP_ANA_POWER, ana_pwr); + snd_soc_component_write(component, SGTL5000_CHIP_ANA_POWER, ana_pwr); /* * set ADC/DAC VAG to vdda / 2, @@ -1098,7 +1098,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) else vag = (vag - SGTL5000_ANA_GND_BASE) / SGTL5000_ANA_GND_STP; - snd_soc_update_bits(codec, SGTL5000_CHIP_REF_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_REF_CTRL, SGTL5000_ANA_GND_MASK, vag << SGTL5000_ANA_GND_SHIFT); /* set line out VAG to vddio / 2, in range (0.8v, 1.675v) */ @@ -1112,7 +1112,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) lo_vag = (lo_vag - SGTL5000_LINE_OUT_GND_BASE) / SGTL5000_LINE_OUT_GND_STP; - snd_soc_update_bits(codec, SGTL5000_CHIP_LINE_OUT_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_LINE_OUT_CTRL, SGTL5000_LINE_OUT_CURRENT_MASK | SGTL5000_LINE_OUT_GND_MASK, lo_vag << SGTL5000_LINE_OUT_GND_SHIFT | @@ -1135,7 +1135,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) break; } - snd_soc_update_bits(codec, SGTL5000_CHIP_LINE_OUT_VOL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_LINE_OUT_VOL, SGTL5000_LINE_OUT_VOL_RIGHT_MASK | SGTL5000_LINE_OUT_VOL_LEFT_MASK, lo_vol << SGTL5000_LINE_OUT_VOL_RIGHT_SHIFT | @@ -1183,51 +1183,51 @@ static int sgtl5000_enable_regulators(struct i2c_client *client) return ret; } -static int sgtl5000_probe(struct snd_soc_codec *codec) +static int sgtl5000_probe(struct snd_soc_component *component) { int ret; u16 reg; - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); /* power up sgtl5000 */ - ret = sgtl5000_set_power_regs(codec); + ret = sgtl5000_set_power_regs(component); if (ret) goto err; /* enable small pop, introduce 400ms delay in turning off */ - snd_soc_update_bits(codec, SGTL5000_CHIP_REF_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_REF_CTRL, SGTL5000_SMALL_POP, 1); /* disable short cut detector */ - snd_soc_write(codec, SGTL5000_CHIP_SHORT_CTRL, 0); + snd_soc_component_write(component, SGTL5000_CHIP_SHORT_CTRL, 0); /* * set i2s as default input of sound switch * TODO: add sound switch to control and dapm widge. */ - snd_soc_write(codec, SGTL5000_CHIP_SSS_CTRL, + snd_soc_component_write(component, SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAC_SEL_I2S_IN << SGTL5000_DAC_SEL_SHIFT); - snd_soc_write(codec, SGTL5000_CHIP_DIG_POWER, + snd_soc_component_write(component, SGTL5000_CHIP_DIG_POWER, SGTL5000_ADC_EN | SGTL5000_DAC_EN); /* enable dac volume ramp by default */ - snd_soc_write(codec, SGTL5000_CHIP_ADCDAC_CTRL, + snd_soc_component_write(component, SGTL5000_CHIP_ADCDAC_CTRL, SGTL5000_DAC_VOL_RAMP_EN | SGTL5000_DAC_MUTE_RIGHT | SGTL5000_DAC_MUTE_LEFT); reg = ((sgtl5000->lrclk_strength) << SGTL5000_PAD_I2S_LRCLK_SHIFT | 0x5f); - snd_soc_write(codec, SGTL5000_CHIP_PAD_STRENGTH, reg); + snd_soc_component_write(component, SGTL5000_CHIP_PAD_STRENGTH, reg); - snd_soc_write(codec, SGTL5000_CHIP_ANA_CTRL, + snd_soc_component_write(component, SGTL5000_CHIP_ANA_CTRL, SGTL5000_HP_ZCD_EN | SGTL5000_ADC_ZCD_EN); - snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_R_MASK, sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); - snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_VOLT_MASK, sgtl5000->micbias_voltage << SGTL5000_BIAS_VOLT_SHIFT); /* @@ -1235,7 +1235,7 @@ static int sgtl5000_probe(struct snd_soc_codec *codec) * TODO: * Enable DAP in kcontrol and dapm. */ - snd_soc_write(codec, SGTL5000_DAP_CTRL, 0); + snd_soc_component_write(component, SGTL5000_DAP_CTRL, 0); return 0; @@ -1243,24 +1243,20 @@ static int sgtl5000_probe(struct snd_soc_codec *codec) return ret; } -static int sgtl5000_remove(struct snd_soc_codec *codec) -{ - return 0; -} - -static const struct snd_soc_codec_driver sgtl5000_driver = { - .probe = sgtl5000_probe, - .remove = sgtl5000_remove, - .set_bias_level = sgtl5000_set_bias_level, - .suspend_bias_off = true, - .component_driver = { - .controls = sgtl5000_snd_controls, - .num_controls = ARRAY_SIZE(sgtl5000_snd_controls), - .dapm_widgets = sgtl5000_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sgtl5000_dapm_widgets), - .dapm_routes = sgtl5000_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(sgtl5000_dapm_routes), - }, +static const struct snd_soc_component_driver sgtl5000_driver = { + .probe = sgtl5000_probe, + .set_bias_level = sgtl5000_set_bias_level, + .controls = sgtl5000_snd_controls, + .num_controls = ARRAY_SIZE(sgtl5000_snd_controls), + .dapm_widgets = sgtl5000_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sgtl5000_dapm_widgets), + .dapm_routes = sgtl5000_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(sgtl5000_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config sgtl5000_regmap = { @@ -1456,7 +1452,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, /* Ensure sgtl5000 will start with sane register values */ sgtl5000_fill_defaults(client); - ret = snd_soc_register_codec(&client->dev, + ret = devm_snd_soc_register_component(&client->dev, &sgtl5000_driver, &sgtl5000_dai, 1); if (ret) goto disable_clk; @@ -1477,7 +1473,6 @@ static int sgtl5000_i2c_remove(struct i2c_client *client) { struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); clk_disable_unprepare(sgtl5000->mclk); regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies); regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies);