From patchwork Fri Jan 12 01:26:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10159283 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 B3231602D8 for ; Fri, 12 Jan 2018 01:36:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ECB9287BE for ; Fri, 12 Jan 2018 01:36:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91308287DE; Fri, 12 Jan 2018 01:36:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 57953287BE for ; Fri, 12 Jan 2018 01:36:23 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 1173B267ACE; Fri, 12 Jan 2018 02:36:22 +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 C5867267ACE; Fri, 12 Jan 2018 02:36:20 +0100 (CET) Received: from relmlie3.idc.renesas.com (relmlor4.renesas.com [210.160.252.174]) by alsa0.perex.cz (Postfix) with ESMTP id 07962267A37 for ; Fri, 12 Jan 2018 02:27:01 +0100 (CET) Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 12 Jan 2018 10:27:00 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 5A8DF6D13C; Fri, 12 Jan 2018 10:27:00 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.46,346,1511794800"; d="scan'208";a="269308773" Received: from mail-sg2apc01lp0242.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.242]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 12 Jan 2018 10:26:59 +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=ry26c+kW5YKB4Crrl6KKtuQ3yt0frVy3IuZteB9AmkU=; b=SzUOuI5ZLkyrhXqLTvQFQv0mJU6vHHfg7GPN4CsQH0J1FICoye3mIQVIEChei78q9znv53yFIUE8W9t9brw10+krItrDIU2HhkcZKkAVsNRFoDEdXoMtAQMLrd/KHuPCSWJa8uczHy/LdKSfXBmXoRrcuiGpoWMMY6+1fsv/QzQ= Received: from morimoto-PC.renesas.com (211.11.155.138) by HK2PR0601MB1875.apcprd06.prod.outlook.com (2603:1096:202:a::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Fri, 12 Jan 2018 01:26:57 +0000 Message-ID: <87r2qvamw1.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: <87bmhzevk9.wl%kuninori.morimoto.gx@renesas.com> References: <87bmhzevk9.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 12 Jan 2018 01:26:57 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: KAXPR01CA0011.jpnprd01.prod.outlook.com (2603:1096:402:19::21) To HK2PR0601MB1875.apcprd06.prod.outlook.com (2603:1096:202:a::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 95caf588-6f6c-49ff-19dd-08d5595b92a2 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020074)(4652020)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:HK2PR0601MB1875; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1875; 3:xTSSSj2fjMtqZfaV6k1EqHY8LsxANTKV/e8OrACXJe/Rrs7AoQiUtMlvSVUs94kOTA6VOn3i8L6h2to5RZmO7yTuvivYwpViucO4ky17nmDG7TJVrLAYilkFTJUQSejRkVK77mOX+3jVfCAdgTkpJU05hExP1Di4XrhsyU3U5BvIeO9QYac7Qms0dCSwB7Aa6gNhWIlAmaxuzQq13gvdkCO7GgQy6/1DyiiaGF4Aw+SV+ZNoINIfrn2E1KAp7N9V; 25:9WuYuizKIILaV8plviFEhQ26nSoHSvGgJM3w4T5z1Ps1p9nuRTV/zKHDm0ipvHYOFu4d86driKTnkYM4P6qni6DInCBnBxD/5OheKYLH7hXY5PTTi4zt1POGKqcnaWPy7ygu6B0I+saKE+Ho2q//NYvbIOO4+vRUB5Cj/OfENWOKWxGqxIzDM7lLKH1RGJioiJjqamISQwqhxuqamlUzEEUW63Lb/PqyHjEkZQYeTcroQgTgNyzSB6Cef5ZI1uBSd9xR7Mq3v+E5BUPFHXI2E93Mr/ViL+czCpkqNAWHoTPd/yrgyidaHrgXWrZ86ivkheTPYOggFm40I60YfL/wTA==; 31:BlHc8NVAMj/kWQcSsMc+XBaa71zDTiVUGOPVYIfkDrKiIE+Zau+kxsoFHsoPng5MpOFJwO+/P1fRU45JBme934VEc447gpS0u2/lsOPjEQ5u199MpgNymUegb8SpQl53DC+T9rjTnZ1cixNumf74dp0M9+sdM2UVm47dHBprNSVmTJ+P6Jskj3UzJCknLG9Zp4nHq7Yk+LFHPOp8P8Nz9OCsQp6HKDYXZBlvThMQa/A= X-MS-TrafficTypeDiagnostic: HK2PR0601MB1875: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1875; 20:KafWs6FDBmLV8Ml5VnviQ8Bzf1xgaowz0tTu+HWRCOatI8MNq+fK4dLCRRHLNuE8E+6d3g9nLwT67l7EwiKvUwME8p9Fl7Uig1/6+qbTuoecB43SQ0s2nOBB5pP/E1aE9TaLiy/W951LBS0wI+v/a/56BcQbHOGjDqOEVkwJieUb5MS9oateO5a2BvXlFhhWqJHTxxwcZckhnbb8ITO0qAuDcfhyuN1qFhQXLKQA0EuBA9NfcdeKPMVrwjqpkgRNXvUEh6kzh2V9AthO3KBYGAU/vHIDV/dItMqMZ43eWHGTulOJ+ktpglbtBnSeC+vSS4DUpt2UbcDAlNwR85wOgpQeQZD/BLv8nxCevzbDRPeqNOAy80LEyV+cLLlC9tlErTLJWG+dJyHCBAaIHBl/TiBEcp7Vq0V7x3ovZguf8yaYbXecjax4d52dJ+7fyX5xiqTZoB9xqz+kNeHNnILaIBk8v5Gvl052g4htOvgQuNaRuSWOA530b+/nPOmCQLgC; 4:f466ZRWyTNZPp3JrSyuvdxaf22Vo+pHx5E9omXgir145CGFPRbPsXTMo/+66JWxQrvukebBWZ2Nyxy1KLwbC+QYZ80JOsU3YN/aDFmzvw1gQs1h6GdLwhN43284S/Ym/jHf513zQx7EiaF6jOMG6clH8jrYRhGHnf27ZFK/5SVJTytX/evdpRu/y6Dt0OXlzbXQSXHMYaX9T9j8OItfZgLsE0rj1nkdRo8w6hAN50QjFh4lyhFetSjswLWPWi8kcvPEBLwJ9JVDLkf27Ncyod0Zos3gRNG6/YYjVDn5j+6AUNg1gAYyO14d8Ex+xvlG3 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(788757137089); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231023)(944501138)(10201501046)(3002001)(6055026)(6041268)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011); SRVR:HK2PR0601MB1875; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HK2PR0601MB1875; X-Forefront-PRVS: 0550778858 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(376002)(39380400002)(346002)(396003)(366004)(39860400002)(199004)(189003)(53416004)(105586002)(106356001)(6116002)(3846002)(76176011)(59450400001)(2950100002)(386003)(83506002)(6916009)(52116002)(8936002)(50466002)(68736007)(7696005)(5660300001)(23726003)(36756003)(2906002)(4326008)(81166006)(69596002)(25786009)(8676002)(86362001)(81156014)(6486002)(478600001)(16526018)(66066001)(53936002)(58126008)(53946003)(47776003)(7736002)(305945005)(97736004)(16586007)(316002)(54906003)(21314002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR0601MB1875; 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; HK2PR0601MB1875; 23:PW/p3xgPprt/Fe19NImB2RWImx3+tVr5D1VRJsj?= =?us-ascii?Q?F+SKsFXGSefb0vn7eB1J0t0L4lfBbgoU9uWKTTOiCAniWC2a8+eK/BDnn5xN?= =?us-ascii?Q?rrHFR6lsnBD+kPziUSiwMEfnqWDF4hX9zLIl9z4BiIp5LpQ44WmmgWdtyAmt?= =?us-ascii?Q?Fye0lQhC4r2w7hfjokXm4e+FxFo6J9f6z+Q5Zp/0PFSweFizv00dOn5+GqUo?= =?us-ascii?Q?GMHuucNkZcCABl7b/pG9eNb7Fji1TACLAdnXmqTgYvpC2cuU8THnzxHDPaOw?= =?us-ascii?Q?DWfAAP3qfh3SFDJJ2+hqcFP9+kktrizmG65EAtBtAUwghep0BCXQavhZ17HY?= =?us-ascii?Q?rsEdve20hRz7WAi+iZJMfjnAEzqNXdHsnZPlRwaMBDc5YE3By4Os2cpCtiSk?= =?us-ascii?Q?YAjbJAqyO9gVuF56MbCtoGwWUqTrdvMxElLHhdUx131d1r26oDcoOZYDFL1T?= =?us-ascii?Q?EgGwB7jb0EUU0L9NHXit7eBJCbQ7oFRCXT47zPpwGo2bNOHqu1S41U3LNFCE?= =?us-ascii?Q?XidyeUpySjdZuRevXqoAxsAjrgWrCU/nwrvkh7d+tnRv/I2FB/10QA7Fsp6p?= =?us-ascii?Q?9h6Eiet1+wG6/o2WbD2+6+UeR72SicstKaPnQNAlr9gf/LH1xnyM0HueVv6E?= =?us-ascii?Q?okUXlxTMsHhnUTiQ3Zr6amhz7o7vlWgDPXZ/xKoF46oNkXDNPY52/6CdpTdE?= =?us-ascii?Q?d5xd9GDS+DDFYQRIGWozZxMDX23pIyNrI977A8hCozcp2lBRaM4N2fdNy9tf?= =?us-ascii?Q?BRx8alGXOltjvmzarHncHH/3ZjDve68vO/pml24uK+QJ9QlW2hOGlWkc4YM/?= =?us-ascii?Q?L26Eez2ty9AczZyzQRrPVHNQgGPUfjQaQY3DUfXZLQymScYUNHPdDmeJg7SH?= =?us-ascii?Q?Q9ILa3shCA4doZvMwTKipXfoCKWdB6vWG7bJanbiR6OwYW1bbQjMV3G9basy?= =?us-ascii?Q?46p1ScaPSXTAsdZRwXWoFurLqLULsgvcjya7FibTAdlyRqolnIYIQNRN2OyH?= =?us-ascii?Q?/IdTuU/coceDqNqFFfWtgzTza2db+wFBcKgr76cRiFJDTdMAT+K9LpvU9kDD?= =?us-ascii?Q?jdLUvgfquy6gVkZrl7S31Kk3aJplyQY9/ZVxAxrEbwhB+Mn0x5EIA6j217QF?= =?us-ascii?Q?8QpQmYS3J7CqvkCDrR58gUGhxaB3FKGLeHLjM2MWzfEJVNzh9gstPJL3yZrY?= =?us-ascii?Q?IkBI7mpNb6lW+bfk=3D?= X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1875; 6:L8G0EYLJMV0Kwvx5FunLuSpPCfC66d3CItXEnXp8FWyqwJt/g0A7S08M0kEepEM5ZhyeMJWveQoD4w5xV1RltahCYp2QG7Yl4UEur2QxYYq+M5RXGS6WaeB1Vx4eT61QeXdhpIdNIW258SP4ALJZo5/VZPpkRY/1ApvcwM8vnCJStC/rjrRg0daef0TGP9HRvWVPz9T3ajFFtGTkNrVs9FY+Q/qM3euR2+VGWs4u1SkMpi6fOnwo0/HiWbn7wVC0DrQ2jUwiMZ8NAG30SIe3JBQV+ImVl7ulm4hhTe3H18c4ZhqxqKvhnnnXf5rtrSFBDpcNaXgk56qwB4aKgQi3QOBfm7SNdfQzo7NpCl46iPU=; 5:S5eZ5oeVCE61xaqt/eTp6LTUkEWBp6KhDmmEelmn6ZvlQisGetio/I3finGIAhUh9jwDWbEkShRjCqgOHwATbzbmwQMuUe5BybjVdMboZv1Joe3LZIQAMaXiLp0312X2PcYNlbxe6y3ntDZl/ZGuKU4mlw9VjwQOZsjIZ1Ruk2k=; 24:ITN902udWYfu28TdFP/zQfMd35cHZVUoi6giDVwVawYiU/LI7TpA3IB6CB/Q6O1GOO8pqyGNR10DwxVcafCFVPd0PJkW6d58WglETO7Fz6o=; 7:b041tWBE7jyhynyMesh9BL7A3ATDOWikQ2a05RPXBZFmtMieyhn1KSizoty3FfYtWaxxerWutK2trMyBPWvA995q4TCdH79MJnQoqFK86ky1xgLPAsWeNXUbD+2tqGVxKRrbFBYZ/t6GlGT5il1xI4hKkdzqPbDXvG8Ld4XNUfAe5iVDBQHcsvcCz7Q6irseFPaf3v9Tn/Bc0oFdPFll9Hfv28+hkADgzcvfhIcvt3O/1VYwksIMTcVOaH8XuCks SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1875; 20:eTmTq7veYZ7w7zLNhysCU5kEdJJDcL1Y2MeJVqijIAfJlV/egF/U96P3ftiEzFrNXnKu98TUfORya7f3iRHQq+mzZDeRLCQNuJdyZQketg0lvWPr6/C50Hp2Qlp2mbaZcSA56xl5jO9TbCqaQCgrU1V0VDcr9gTXevrvq/5iQV4= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2018 01:26:57.6348 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 95caf588-6f6c-49ff-19dd-08d5595b92a2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR0601MB1875 Cc: Linux-ALSA , Simon Subject: [alsa-devel] [PATCH 065/187] ASoC: rt5670: 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 -> .pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto --- sound/soc/codecs/rt5670.c | 295 ++++++++++++++++---------------- sound/soc/codecs/rt5670.h | 10 +- sound/soc/intel/boards/cht_bsw_rt5672.c | 18 +- 3 files changed, 160 insertions(+), 163 deletions(-) diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index c5094b4..4851091 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -423,7 +423,7 @@ static bool rt5670_readable_register(struct device *dev, unsigned int reg) /** * rt5670_headset_detect - Detect headset. - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @jack_insert: Jack insert or not. * * Detect whether is headset or not when jack inserted. @@ -431,46 +431,46 @@ static bool rt5670_readable_register(struct device *dev, unsigned int reg) * Returns detect status. */ -static int rt5670_headset_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5670_headset_detect(struct snd_soc_component *component, int jack_insert) { int val; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (jack_insert) { snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x0); - snd_soc_update_bits(codec, RT5670_CJ_CTRL2, + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x0); + snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, RT5670_CBJ_DET_MODE | RT5670_CBJ_MN_JD, RT5670_CBJ_MN_JD); - snd_soc_write(codec, RT5670_GPIO_CTRL2, 0x0004); - snd_soc_update_bits(codec, RT5670_GPIO_CTRL1, + snd_soc_component_write(component, RT5670_GPIO_CTRL2, 0x0004); + snd_soc_component_update_bits(component, RT5670_GPIO_CTRL1, RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_IRQ); - snd_soc_update_bits(codec, RT5670_CJ_CTRL1, + snd_soc_component_update_bits(component, RT5670_CJ_CTRL1, RT5670_CBJ_BST1_EN, RT5670_CBJ_BST1_EN); - snd_soc_write(codec, RT5670_JD_CTRL3, 0x00f0); - snd_soc_update_bits(codec, RT5670_CJ_CTRL2, + snd_soc_component_write(component, RT5670_JD_CTRL3, 0x00f0); + snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, RT5670_CBJ_MN_JD, RT5670_CBJ_MN_JD); - snd_soc_update_bits(codec, RT5670_CJ_CTRL2, + snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, RT5670_CBJ_MN_JD, 0); msleep(300); - val = snd_soc_read(codec, RT5670_CJ_CTRL3) & 0x7; + val = snd_soc_component_read32(component, RT5670_CJ_CTRL3) & 0x7; if (val == 0x1 || val == 0x2) { rt5670->jack_type = SND_JACK_HEADSET; /* for push button */ - snd_soc_update_bits(codec, RT5670_INT_IRQ_ST, 0x8, 0x8); - snd_soc_update_bits(codec, RT5670_IL_CMD, 0x40, 0x40); - snd_soc_read(codec, RT5670_IL_CMD); + snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x8); + snd_soc_component_update_bits(component, RT5670_IL_CMD, 0x40, 0x40); + snd_soc_component_read32(component, RT5670_IL_CMD); } else { - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x4); + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4); rt5670->jack_type = SND_JACK_HEADPHONE; snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); } } else { - snd_soc_update_bits(codec, RT5670_INT_IRQ_ST, 0x8, 0x0); - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x4); + snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x0); + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4); rt5670->jack_type = 0; snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); @@ -479,35 +479,35 @@ static int rt5670_headset_detect(struct snd_soc_codec *codec, int jack_insert) return rt5670->jack_type; } -void rt5670_jack_suspend(struct snd_soc_codec *codec) +void rt5670_jack_suspend(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); rt5670->jack_type_saved = rt5670->jack_type; - rt5670_headset_detect(codec, 0); + rt5670_headset_detect(component, 0); } EXPORT_SYMBOL_GPL(rt5670_jack_suspend); -void rt5670_jack_resume(struct snd_soc_codec *codec) +void rt5670_jack_resume(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->jack_type_saved) - rt5670_headset_detect(codec, 1); + rt5670_headset_detect(component, 1); } EXPORT_SYMBOL_GPL(rt5670_jack_resume); -static int rt5670_button_detect(struct snd_soc_codec *codec) +static int rt5670_button_detect(struct snd_soc_component *component) { int btn_type, val; - val = snd_soc_read(codec, RT5670_IL_CMD); + val = snd_soc_component_read32(component, RT5670_IL_CMD); btn_type = val & 0xff80; - snd_soc_write(codec, RT5670_IL_CMD, val); + snd_soc_component_write(component, RT5670_IL_CMD, val); if (btn_type != 0) { msleep(20); - val = snd_soc_read(codec, RT5670_IL_CMD); - snd_soc_write(codec, RT5670_IL_CMD, val); + val = snd_soc_component_read32(component, RT5670_IL_CMD); + snd_soc_component_write(component, RT5670_IL_CMD, val); } return btn_type; @@ -521,25 +521,25 @@ static int rt5670_irq_detection(void *data) int val, btn_type, report = jack->status; if (rt5670->pdata.jd_mode == 1) /* 2 port */ - val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0070; + val = snd_soc_component_read32(rt5670->component, RT5670_A_JD_CTRL1) & 0x0070; else - val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0020; + val = snd_soc_component_read32(rt5670->component, RT5670_A_JD_CTRL1) & 0x0020; switch (val) { /* jack in */ case 0x30: /* 2 port */ case 0x0: /* 1 port or 2 port */ if (rt5670->jack_type == 0) { - report = rt5670_headset_detect(rt5670->codec, 1); + report = rt5670_headset_detect(rt5670->component, 1); /* for push button and jack out */ gpio->debounce_time = 25; break; } btn_type = 0; - if (snd_soc_read(rt5670->codec, RT5670_INT_IRQ_ST) & 0x4) { + if (snd_soc_component_read32(rt5670->component, RT5670_INT_IRQ_ST) & 0x4) { /* button pressed */ report = SND_JACK_HEADSET; - btn_type = rt5670_button_detect(rt5670->codec); + btn_type = rt5670_button_detect(rt5670->component); switch (btn_type) { case 0x2000: /* up */ report |= SND_JACK_BTN_1; @@ -551,7 +551,7 @@ static int rt5670_irq_detection(void *data) report |= SND_JACK_BTN_2; break; default: - dev_err(rt5670->codec->dev, + dev_err(rt5670->component->dev, "Unexpected button code 0x%04x\n", btn_type); break; @@ -566,8 +566,8 @@ static int rt5670_irq_detection(void *data) case 0x10: /* 2 port */ case 0x20: /* 1 port */ report = 0; - snd_soc_update_bits(rt5670->codec, RT5670_INT_IRQ_ST, 0x1, 0x0); - rt5670_headset_detect(rt5670->codec, 0); + snd_soc_component_update_bits(rt5670->component, RT5670_INT_IRQ_ST, 0x1, 0x0); + rt5670_headset_detect(rt5670->component, 0); gpio->debounce_time = 150; /* for jack in */ break; default: @@ -577,14 +577,14 @@ static int rt5670_irq_detection(void *data) return report; } -int rt5670_set_jack_detect(struct snd_soc_codec *codec, +int rt5670_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); int ret; rt5670->jack = jack; - rt5670->hp_gpio.gpiod_dev = codec->dev; + rt5670->hp_gpio.gpiod_dev = component->dev; rt5670->hp_gpio.name = "headset"; rt5670->hp_gpio.report = SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2; @@ -596,7 +596,7 @@ int rt5670_set_jack_detect(struct snd_soc_codec *codec, ret = snd_soc_jack_add_gpios(rt5670->jack, 1, &rt5670->hp_gpio); if (ret) { - dev_err(codec->dev, "Adding jack GPIO failed\n"); + dev_err(component->dev, "Adding jack GPIO failed\n"); return ret; } @@ -699,17 +699,17 @@ static SOC_ENUM_SINGLE_DECL(rt5670_if2_adc_enum, RT5670_DIG_INF1_DATA, static int set_dmic_clk(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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); int idx, rate; rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap, RT5670_ADDA_CLK1, RT5670_I2S_PD1_SFT); idx = rl6231_calc_dmic_clk(rate); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else - snd_soc_update_bits(codec, RT5670_DMIC_CTRL1, + snd_soc_component_update_bits(component, RT5670_DMIC_CTRL1, RT5670_DMIC_CLK_MASK, idx << RT5670_DMIC_CLK_SFT); return idx; } @@ -717,8 +717,8 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->sysclk_src == RT5670_SCLK_S_PLL1) return 1; @@ -729,7 +729,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg, shift, val; switch (source->shift) { @@ -765,7 +765,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, return 0; } - val = (snd_soc_read(codec, reg) >> shift) & 0xf; + val = (snd_soc_component_read32(component, reg) >> shift) & 0xf; switch (val) { case 1: case 2: @@ -781,8 +781,8 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, static int can_use_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->sysclk > rt5670->lrck[RT5670_AIF1] * 384) return 1; @@ -793,7 +793,7 @@ static int can_use_asrc(struct snd_soc_dapm_widget *source, /** * rt5670_sel_asrc_clk_src - select ASRC clock source for a set of filters - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @filter_mask: mask of filters. * @clk_src: clock source * @@ -805,7 +805,7 @@ static int can_use_asrc(struct snd_soc_dapm_widget *source, * set of filters specified by the mask. And the codec driver will turn on ASRC * for these filters if ASRC is selected as their clock source. */ -int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5670_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src) { unsigned int asrc2_mask = 0, asrc2_value = 0; @@ -863,11 +863,11 @@ int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, } if (asrc2_mask) - snd_soc_update_bits(codec, RT5670_ASRC_2, + snd_soc_component_update_bits(component, RT5670_ASRC_2, asrc2_mask, asrc2_value); if (asrc3_mask) - snd_soc_update_bits(codec, RT5670_ASRC_3, + snd_soc_component_update_bits(component, RT5670_ASRC_3, asrc3_mask, asrc3_value); return 0; } @@ -1421,8 +1421,8 @@ static SOC_ENUM_SINGLE_DECL(rt5670_vad_adc_enum, RT5670_VAD_CTRL4, static int rt5670_hp_power_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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1457,8 +1457,8 @@ static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, static int rt5670_hp_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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1507,16 +1507,16 @@ static int rt5670_hp_event(struct snd_soc_dapm_widget *w, static int rt5670_bst1_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); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST1_P, RT5670_PWR_BST1_P); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST1_P, 0); break; @@ -1530,16 +1530,16 @@ static int rt5670_bst1_event(struct snd_soc_dapm_widget *w, static int rt5670_bst2_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); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST2_P, RT5670_PWR_BST2_P); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST2_P, 0); break; @@ -2322,21 +2322,21 @@ static int rt5670_bst2_event(struct snd_soc_dapm_widget *w, static int rt5670_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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int pre_div, bclk_ms, frame_size; rt5670->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5670->sysclk, rt5670->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", + dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", rt5670->lrck[dai->id], dai->id); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } bclk_ms = frame_size > 32; @@ -2368,20 +2368,20 @@ static int rt5670_hw_params(struct snd_pcm_substream *substream, mask_clk = RT5670_I2S_BCLK_MS1_MASK | RT5670_I2S_PD1_MASK; val_clk = bclk_ms << RT5670_I2S_BCLK_MS1_SFT | pre_div << RT5670_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5670_I2S1_SDP, + snd_soc_component_update_bits(component, RT5670_I2S1_SDP, RT5670_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5670_ADDA_CLK1, mask_clk, val_clk); break; case RT5670_AIF2: mask_clk = RT5670_I2S_BCLK_MS2_MASK | RT5670_I2S_PD2_MASK; val_clk = bclk_ms << RT5670_I2S_BCLK_MS2_SFT | pre_div << RT5670_I2S_PD2_SFT; - snd_soc_update_bits(codec, RT5670_I2S2_SDP, + snd_soc_component_update_bits(component, RT5670_I2S2_SDP, RT5670_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5670_ADDA_CLK1, mask_clk, val_clk); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } @@ -2390,8 +2390,8 @@ static int rt5670_hw_params(struct snd_pcm_substream *substream, static int rt5670_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -2434,26 +2434,26 @@ static int rt5670_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (dai->id) { case RT5670_AIF1: - snd_soc_update_bits(codec, RT5670_I2S1_SDP, + snd_soc_component_update_bits(component, RT5670_I2S1_SDP, RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | RT5670_I2S_DF_MASK, reg_val); break; case RT5670_AIF2: - snd_soc_update_bits(codec, RT5670_I2S2_SDP, + snd_soc_component_update_bits(component, RT5670_I2S2_SDP, RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | RT5670_I2S_DF_MASK, reg_val); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } return 0; } -static int rt5670_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, +static int rt5670_set_codec_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (clk_id) { @@ -2467,16 +2467,16 @@ static int rt5670_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, reg_val |= RT5670_SCLK_SRC_RCCLK; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_SCLK_SRC_MASK, reg_val); rt5670->sysclk = freq; if (clk_id != RT5670_SCLK_S_RCCLK) rt5670->sysclk_src = clk_id; - dev_dbg(codec->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); + dev_dbg(component->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); return 0; } @@ -2484,8 +2484,8 @@ static int rt5670_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, static int rt5670_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 rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -2494,18 +2494,18 @@ static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5670->pll_in = 0; rt5670->pll_out = 0; - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5670_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_MCLK); break; case RT5670_PLL1_S_BCLK1: @@ -2514,36 +2514,36 @@ static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, case RT5670_PLL1_S_BCLK4: switch (dai->id) { case RT5670_AIF1: - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK1); break; case RT5670_AIF2: - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK2); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5670_PLL_CTRL1, + snd_soc_component_write(component, RT5670_PLL_CTRL1, pll_code.n_code << RT5670_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5670_PLL_CTRL2, + snd_soc_component_write(component, RT5670_PLL_CTRL2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5670_PLL_M_SFT | pll_code.m_bp << RT5670_PLL_M_BP_SFT); @@ -2557,7 +2557,7 @@ static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5670_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; unsigned int val = 0; if (rx_mask || tx_mask) @@ -2595,75 +2595,75 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return -EINVAL; } - snd_soc_update_bits(codec, RT5670_TDM_CTRL_1, 0x7c00, val); + snd_soc_component_update_bits(component, RT5670_TDM_CTRL_1, 0x7c00, val); return 0; } static int rt5670_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); if (dai->id != RT5670_AIF1) return 0; if ((ratio % 50) == 0) - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, RT5670_TDM_DATA_MODE_SEL, RT5670_TDM_DATA_MODE_50FS); else - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, RT5670_TDM_DATA_MODE_SEL, RT5670_TDM_DATA_MODE_NOR); return 0; } -static int rt5670_set_bias_level(struct snd_soc_codec *codec, +static int rt5670_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_codec_get_bias_level(codec)) { - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2); mdelay(10); - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_FV1 | RT5670_PWR_FV2, RT5670_PWR_FV1 | RT5670_PWR_FV2); - snd_soc_update_bits(codec, RT5670_CHARGE_PUMP, + snd_soc_component_update_bits(component, RT5670_CHARGE_PUMP, RT5670_OSW_L_MASK | RT5670_OSW_R_MASK, RT5670_OSW_L_DIS | RT5670_OSW_R_DIS); - snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x1); - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_DIG_MISC, 0x1, 0x1); + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_LDO_SEL_MASK, 0x5); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_VREF2 | RT5670_PWR_FV1 | RT5670_PWR_FV2, 0); - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_LDO_SEL_MASK, 0x3); break; case SND_SOC_BIAS_OFF: if (rt5670->pdata.jd_mode) - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2 | RT5670_PWR_FV1 | RT5670_PWR_FV2, RT5670_PWR_MB | RT5670_PWR_BG); else - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2 | RT5670_PWR_FV1 | RT5670_PWR_FV2, 0); - snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x0); + snd_soc_component_update_bits(component, RT5670_DIG_MISC, 0x1, 0x0); break; default: @@ -2673,12 +2673,12 @@ static int rt5670_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5670_probe(struct snd_soc_codec *codec) +static int rt5670_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); - switch (snd_soc_read(codec, RT5670_RESET) & RT5670_ID_MASK) { + switch (snd_soc_component_read32(component, RT5670_RESET) & RT5670_ID_MASK) { case RT5670_ID_5670: case RT5670_ID_5671: snd_soc_dapm_new_controls(dapm, @@ -2697,37 +2697,36 @@ static int rt5670_probe(struct snd_soc_codec *codec) ARRAY_SIZE(rt5672_specific_dapm_routes)); break; default: - dev_err(codec->dev, + dev_err(component->dev, "The driver is for RT5670 RT5671 or RT5672 only\n"); return -ENODEV; } - rt5670->codec = codec; + rt5670->component = component; return 0; } -static int rt5670_remove(struct snd_soc_codec *codec) +static void rt5670_remove(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); regmap_write(rt5670->regmap, RT5670_RESET, 0); snd_soc_jack_free_gpios(rt5670->jack, 1, &rt5670->hp_gpio); - return 0; } #ifdef CONFIG_PM -static int rt5670_suspend(struct snd_soc_codec *codec) +static int rt5670_suspend(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5670->regmap, true); regcache_mark_dirty(rt5670->regmap); return 0; } -static int rt5670_resume(struct snd_soc_codec *codec) +static int rt5670_resume(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5670->regmap, false); regcache_sync(rt5670->regmap); @@ -2794,22 +2793,22 @@ static int rt5670_resume(struct snd_soc_codec *codec) }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5670 = { - .probe = rt5670_probe, - .remove = rt5670_remove, - .suspend = rt5670_suspend, - .resume = rt5670_resume, - .set_bias_level = rt5670_set_bias_level, - .idle_bias_off = true, - .set_sysclk = rt5670_set_codec_sysclk, - .component_driver = { - .controls = rt5670_snd_controls, - .num_controls = ARRAY_SIZE(rt5670_snd_controls), - .dapm_widgets = rt5670_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5670_dapm_widgets), - .dapm_routes = rt5670_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5670_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5670 = { + .probe = rt5670_probe, + .remove = rt5670_remove, + .suspend = rt5670_suspend, + .resume = rt5670_resume, + .set_bias_level = rt5670_set_bias_level, + .set_sysclk = rt5670_set_codec_sysclk, + .controls = rt5670_snd_controls, + .num_controls = ARRAY_SIZE(rt5670_snd_controls), + .dapm_widgets = rt5670_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5670_dapm_widgets), + .dapm_routes = rt5670_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5670_dapm_routes), + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5670_regmap = { @@ -3171,7 +3170,8 @@ static int rt5670_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5670, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5670, rt5670_dai, ARRAY_SIZE(rt5670_dai)); if (ret < 0) goto err; @@ -3188,7 +3188,6 @@ static int rt5670_i2c_probe(struct i2c_client *i2c, static int rt5670_i2c_remove(struct i2c_client *i2c) { pm_runtime_disable(&i2c->dev); - snd_soc_unregister_codec(&i2c->dev); return 0; } diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h index 265df80..97e8eeb 100644 --- a/sound/soc/codecs/rt5670.h +++ b/sound/soc/codecs/rt5670.h @@ -1986,11 +1986,11 @@ enum { RT5670_DOWN_RATE_FILTER = (0x1 << 7), }; -int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5670_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src); struct rt5670_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5670_platform_data pdata; struct regmap *regmap; struct snd_soc_jack *jack; @@ -2012,8 +2012,8 @@ struct rt5670_priv { int jack_type_saved; }; -void rt5670_jack_suspend(struct snd_soc_codec *codec); -void rt5670_jack_resume(struct snd_soc_codec *codec); -int rt5670_set_jack_detect(struct snd_soc_codec *codec, +void rt5670_jack_suspend(struct snd_soc_component *component); +void rt5670_jack_resume(struct snd_soc_component *component); +int rt5670_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif /* __RT5670_H__ */ diff --git a/sound/soc/intel/boards/cht_bsw_rt5672.c b/sound/soc/intel/boards/cht_bsw_rt5672.c index f8f21ee..740e754 100644 --- a/sound/soc/intel/boards/cht_bsw_rt5672.c +++ b/sound/soc/intel/boards/cht_bsw_rt5672.c @@ -183,10 +183,10 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) { int ret; struct snd_soc_dai *codec_dai = runtime->codec_dai; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); - if (devm_acpi_dev_add_driver_gpios(codec->dev, cht_rt5672_gpios)) + if (devm_acpi_dev_add_driver_gpios(component->dev, cht_rt5672_gpios)) dev_warn(runtime->dev, "Unable to add GPIO mapping table\n"); /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ @@ -201,7 +201,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) * be supported by RT5672. Otherwise, ASRC will be disabled and cause * noise. */ - rt5670_sel_asrc_clk_src(codec, + rt5670_sel_asrc_clk_src(component, RT5670_DA_STEREO_FILTER | RT5670_DA_MONO_L_FILTER | RT5670_DA_MONO_R_FILTER @@ -219,7 +219,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) if (ret) return ret; - rt5670_set_jack_detect(codec, &ctx->headset); + rt5670_set_jack_detect(component, &ctx->headset); if (ctx->mclk) { /* * The firmware might enable the clock at @@ -333,10 +333,9 @@ static int cht_suspend_pre(struct snd_soc_card *card) list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strncmp(component->name, ctx->codec_name, sizeof(ctx->codec_name))) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); - rt5670_jack_suspend(codec); + dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); + rt5670_jack_suspend(component); break; } } @@ -351,10 +350,9 @@ static int cht_resume_post(struct snd_soc_card *card) list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strncmp(component->name, ctx->codec_name, sizeof(ctx->codec_name))) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "enabling jack detect for resume.\n"); - rt5670_jack_resume(codec); + dev_dbg(component->dev, "enabling jack detect for resume.\n"); + rt5670_jack_resume(component); break; } }