From patchwork Fri Jan 12 01:55:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 10159513 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 31D8E6029B for ; Fri, 12 Jan 2018 02:51:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A82E287CD for ; Fri, 12 Jan 2018 02:51:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F3B3287EA; Fri, 12 Jan 2018 02:51:17 +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 5DFC1287E2 for ; Fri, 12 Jan 2018 02:51:15 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B619126842F; Fri, 12 Jan 2018 03:38:23 +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 E4F6C268422; Fri, 12 Jan 2018 03:38:20 +0100 (CET) Received: from relmlie2.idc.renesas.com (relmlor3.renesas.com [210.160.252.173]) by alsa0.perex.cz (Postfix) with ESMTP id 0F0F7268107 for ; Fri, 12 Jan 2018 02:55:27 +0100 (CET) Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie2.idc.renesas.com with ESMTP; 12 Jan 2018 10:55:26 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 852986BFEB; Fri, 12 Jan 2018 10:55:26 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.46,346,1511794800"; d="scan'208";a="268012333" Received: from mail-sg2apc01lp0240.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.240]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 12 Jan 2018 10:55:25 +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=F8iGisnmcSKMTujcs4JyYyd/uHKOPbv/ktJBRWxjdyg=; b=Yky7yJ1wcZ8rtain7+swaL4dVlbNmEXuI4ZL+akFRzhKcwedtjQMm1J8VjcHJo+q1bTt1a/qMiL15jikrR8ZucB6D0d9bK+q5sOusI5KZsOT/cTfWMshPEm08f9LtDJTHi1vJ3p18JwyHIPkIXvsfdr4UX5u875zBGJF/ktVaAg= 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 SG2PR0601MB1886.apcprd06.prod.outlook.com (2603:1096:3:9::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:55:23 +0000 Message-ID: <87po6f4zaw.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:55:23 +0000 X-Originating-IP: [211.11.155.138] X-ClientProxiedBy: OSXPR01CA0007.jpnprd01.prod.outlook.com (2603:1096:600:e::28) To SG2PR0601MB1886.apcprd06.prod.outlook.com (2603:1096:3:9::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f981c820-1292-4c1d-ec32-08d5595f8baa X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7153060)(7193020); SRVR:SG2PR0601MB1886; X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1886; 3:TCsTqIXiMB1lCUB9hxeBY3RBaGAGOvqyd46V0PWHRrjiBFeJN00VqhNToTxiJnNz6bAA6m1BFs2uAbs0EE4+qZAL3eGWFvnO6eWC5ocxiUXLRw6witWPaC6jnTp8JijHV9uUQigGZV+Y62hoANN8xoY4qA/6GzUIpcl3SbCaqTN1twCiJnzQL+kg3cO0vZXXmlNFzDjP2+rP+ldjg1FZUxHMOEPgHYNMVwpFTCtxK5Mc0yZDei6ejDXbRBfnW4ef; 25:yoIbEcEnfQSdBqKADRdkKufHBxfNfosP0pb/DSQNrqvKwoYhjJZ1QRq/WN26mYC7uV8NhdlcwMViMtZ5TZNKLNR9uE3aC6LnhyogHGNLemMpYk+7oA1nq+++5jmPFFAlgOq55ZeFfdQqJNpuhkQ0uE88nLgi6R5Ol1br38kp/eFRDEcKXr51Mq4wm07wBySYpiX+cnksZH9nBYh9NJ5R5zCtLtyvwGrirCymn1T64eIsDzIgQhEHZp/1au+jex3hSncJtoHN1Ki2pg6EJIPEgo4w9eBWrevjo6dg2q0JNqPutjYhIHV/z96pMTGKw9LHyp71UUHkyQpiUIuW+BZcwA==; 31:e3DaOdMgIIrEG8wyweiMMvIXb8P14dL+Z6lhU8VkNMv+zVrt6Nez8McsTKln7BpVJLfrlhtz530wcD6jAC/uf5a1nB9AbBpCM93gpba/f/bmR79XDZwLAm1+qqwECH7XEbdWWP/22JEDGudW5zuP2tMQNASStu0ixd7Aija0jy9lvSTut4ZAQcDKx/1C2v/kQ7Lf15r37dPK7GK2LP8mvLmnaSqbOxf1mz0bRnw/8S0= X-MS-TrafficTypeDiagnostic: SG2PR0601MB1886: X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1886; 20:rhLc+SxtkOJqy7CK84dm5gOcu3gDA3WbIwOdOOF8Om56VYx6xCPaxSpH5LwVRGNLXbfSWAe2Byt7fzq5KHDOwa43TOKgizssyB9/z7AOI4C8Fco4kpS7udOmnZBRzDsCQREE7703pWiotxRst/fRooh8aNso7hCNsWUdjX7ulK5kJiK4aOHYsvUHBcpvLBVxELt9Ssfge2o16oFseqmVzFw1CH35YC0mA791mDBbAZPecbXtTTH7knk/aG5H+mPGshMhIO5ZPrWEG6zTozdCKU2V0zrOFXg6ecVfwPvcm/ut8lpvuX5ZVc/eqcrRhdyNBu36mOhhasGWFHs8JJQ+qWHI709kQEJLj7iOlJhMnzJrSOYFBoXx0PIeQDV/onTba7IcHn/i6h2GSOoRklWXhJsS/r3g7W7nlmah62FCd28KV5FrIid1XgDztOmPrD3SYVeFstUyoyJ38rGsWnDffD57TGkhGcpO52s+tDNXO1geXhwuYrOpilh99bbMn4az; 4:nXpS7S3+bj2ZX11Cx7EgNEucYahYkRdc5AEQBoCZWXKpMu7cjmBv7jpqIee8Op8eyFJrhBoI0khuhgzEQRZeB27vH4gLEIN4cPsfyDc7BvDZ8ugWChqZW42sJ3LK+OUBmsDjVIqEbgTHnGrgEh4QsxJfCLIIllmMReMeFGxnXjhlg42ka2G/4ZteQI95mfgsmmU4omeLozq0bwQeLSiiz2UfmeY4Af+0jVdHWzw2NrBC2WK3yS+MkNugvcdbnbiiilVerH3HQ9mJhIxQbyU93uoX/utukiAZdxPVS84JDBc5u7wAYoELtS1Jh7aC+LMF 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)(3002001)(3231023)(944501075)(10201501046)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(20161123562045)(6072148)(201708071742011); SRVR:SG2PR0601MB1886; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:SG2PR0601MB1886; X-Forefront-PRVS: 0550778858 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(376002)(396003)(346002)(39380400002)(366004)(39860400002)(199004)(189003)(97736004)(6116002)(105586002)(305945005)(36756003)(76176011)(106356001)(386003)(5660300001)(59450400001)(68736007)(16586007)(316002)(81166006)(3846002)(54906003)(2906002)(8936002)(2950100002)(23726003)(58126008)(6916009)(478600001)(69596002)(66066001)(53416004)(4326008)(16526018)(25786009)(47776003)(50466002)(6486002)(7696005)(52116002)(81156014)(86362001)(8676002)(53936002)(7736002)(83506002)(575784001)(21314002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR0601MB1886; 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; SG2PR0601MB1886; 23:45nK2lwbEcnKF+22YchodNtzS58zVY1JjNXJYwn?= =?us-ascii?Q?2iX6qDJOgnm1B4GvbxDPXeOXpKSq8QuKoXQmgOUcg+InYFAD6YnBAoia+7hb?= =?us-ascii?Q?QNRuRx8HL+NPooUPvaRd85KmYYgUZaqGX3YyqQHN74PbgGpJrAOh+Uis43YG?= =?us-ascii?Q?NPMHsQGZMePVliVd1+a1Vm1Wgi4i3/wqOKrPrPwh/AbFXhaARDGBIHELQC8Y?= =?us-ascii?Q?GWO+5gKKezmTlULt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pamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; SG2PR0601MB1886; 20:aSOx2jrBhEASD34AhkJJ9vh/1YEty39mFjw9TQJnLPjMoi3/IC+1y0k0qXa6vBlqsKt80uu1XWRayCkMcBT8k1eu2ylVjlNCp9uB1HkSVUNKyQvSbW7qSo7h4QDHgZ+zSRu3g9Uzk+/c1ht9klGUq5kB0NjKQEdwGJtOm3IyVr4= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2018 01:55:23.7792 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f981c820-1292-4c1d-ec32-08d5595f8baa X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR0601MB1886 Cc: Linux-ALSA , Simon Subject: [alsa-devel] [PATCH 165/187] ASoC: sn95031: 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. Intel mfld_machine is using sn95031, but there is no compile method... 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/sn95031.c | 219 ++++++++++++++++------------------ sound/soc/codecs/sn95031.h | 2 +- sound/soc/intel/boards/mfld_machine.c | 12 +- 3 files changed, 112 insertions(+), 121 deletions(-) diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c index 887923e..1a03088 100644 --- a/sound/soc/codecs/sn95031.c +++ b/sound/soc/codecs/sn95031.c @@ -46,16 +46,16 @@ /* adc helper functions */ /* enables mic bias voltage */ -static void sn95031_enable_mic_bias(struct snd_soc_codec *codec) +static void sn95031_enable_mic_bias(struct snd_soc_component *component) { - snd_soc_write(codec, SN95031_VAUD, BIT(2)|BIT(1)|BIT(0)); - snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(2), BIT(2)); + snd_soc_component_write(component, SN95031_VAUD, BIT(2)|BIT(1)|BIT(0)); + snd_soc_component_update_bits(component, SN95031_MICBIAS, BIT(2), BIT(2)); } /* Enable/Disable the ADC depending on the argument */ -static void configure_adc(struct snd_soc_codec *sn95031_codec, int val) +static void configure_adc(struct snd_soc_component *sn95031, int val) { - int value = snd_soc_read(sn95031_codec, SN95031_ADC1CNTL1); + int value = snd_soc_component_read32(sn95031, SN95031_ADC1CNTL1); if (val) { /* Enable and start the ADC */ @@ -65,7 +65,7 @@ static void configure_adc(struct snd_soc_codec *sn95031_codec, int val) /* Just stop the ADC */ value &= (~SN95031_ADC_START); } - snd_soc_write(sn95031_codec, SN95031_ADC1CNTL1, value); + snd_soc_component_write(sn95031, SN95031_ADC1CNTL1, value); } /* @@ -78,19 +78,19 @@ static void configure_adc(struct snd_soc_codec *sn95031_codec, int val) * Context: can sleep * */ -static int find_free_channel(struct snd_soc_codec *sn95031_codec) +static int find_free_channel(struct snd_soc_component *sn95031) { int i, value; /* check whether ADC is enabled */ - value = snd_soc_read(sn95031_codec, SN95031_ADC1CNTL1); + value = snd_soc_component_read32(sn95031, SN95031_ADC1CNTL1); if ((value & SN95031_ADC_ENBL) == 0) return 0; /* ADC is already enabled; Looking for an empty channel */ for (i = 0; i < SN95031_ADC_CHANLS_MAX; i++) { - value = snd_soc_read(sn95031_codec, + value = snd_soc_component_read32(sn95031, SN95031_ADC_CHNL_START_ADDR + i); if (value & SN95031_STOPBIT_MASK) break; @@ -99,14 +99,14 @@ static int find_free_channel(struct snd_soc_codec *sn95031_codec) } /* Initialize the ADC for reading micbias values. Can sleep. */ -static int sn95031_initialize_adc(struct snd_soc_codec *sn95031_codec) +static int sn95031_initialize_adc(struct snd_soc_component *sn95031) { int base_addr, chnl_addr; int value; int channel_index; /* Index of the first channel in which the stop bit is set */ - channel_index = find_free_channel(sn95031_codec); + channel_index = find_free_channel(sn95031); if (channel_index < 0) { pr_err("No free ADC channels"); return channel_index; @@ -116,9 +116,9 @@ static int sn95031_initialize_adc(struct snd_soc_codec *sn95031_codec) if (!(channel_index == 0 || channel_index == SN95031_ADC_LOOP_MAX)) { /* Reset stop bit for channels other than 0 and 12 */ - value = snd_soc_read(sn95031_codec, base_addr); + value = snd_soc_component_read32(sn95031, base_addr); /* Set the stop bit to zero */ - snd_soc_write(sn95031_codec, base_addr, value & 0xEF); + snd_soc_component_write(sn95031, base_addr, value & 0xEF); /* Index of the first free channel */ base_addr++; channel_index++; @@ -126,35 +126,35 @@ static int sn95031_initialize_adc(struct snd_soc_codec *sn95031_codec) /* Since this is the last channel, set the stop bit to 1 by ORing the DIE_SENSOR_CODE with 0x10 */ - snd_soc_write(sn95031_codec, base_addr, + snd_soc_component_write(sn95031, base_addr, SN95031_AUDIO_DETECT_CODE | 0x10); chnl_addr = SN95031_ADC_DATA_START_ADDR + 2 * channel_index; pr_debug("mid_initialize : %x", chnl_addr); - configure_adc(sn95031_codec, 1); + configure_adc(sn95031, 1); return chnl_addr; } /* reads the ADC registers and gets the mic bias value in mV. */ -static unsigned int sn95031_get_mic_bias(struct snd_soc_codec *codec) +static unsigned int sn95031_get_mic_bias(struct snd_soc_component *component) { - u16 adc_adr = sn95031_initialize_adc(codec); + u16 adc_adr = sn95031_initialize_adc(component); u16 adc_val1, adc_val2; unsigned int mic_bias; - sn95031_enable_mic_bias(codec); + sn95031_enable_mic_bias(component); /* Enable the sound card for conversion before reading */ - snd_soc_write(codec, SN95031_ADC1CNTL3, 0x05); + snd_soc_component_write(component, SN95031_ADC1CNTL3, 0x05); /* Re-toggle the RRDATARD bit */ - snd_soc_write(codec, SN95031_ADC1CNTL3, 0x04); + snd_soc_component_write(component, SN95031_ADC1CNTL3, 0x04); /* Read the higher bits of data */ msleep(1000); - adc_val1 = snd_soc_read(codec, adc_adr); + adc_val1 = snd_soc_component_read32(component, adc_adr); adc_adr++; - adc_val2 = snd_soc_read(codec, adc_adr); + adc_val2 = snd_soc_component_read32(component, adc_adr); /* Adding lower two bits to the higher bits */ mic_bias = (adc_val1 << 2) + (adc_val2 & 3); @@ -186,7 +186,7 @@ static int sn95031_write(void *ctx, unsigned int reg, unsigned int value) .reg_write = sn95031_write, }; -static int sn95031_set_vaud_bias(struct snd_soc_codec *codec, +static int sn95031_set_vaud_bias(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -194,30 +194,30 @@ static int sn95031_set_vaud_bias(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { pr_debug("vaud_bias powering up pll\n"); /* power up the pll */ - snd_soc_write(codec, SN95031_AUDPLLCTRL, BIT(5)); + snd_soc_component_write(component, SN95031_AUDPLLCTRL, BIT(5)); /* enable pcm 2 */ - snd_soc_update_bits(codec, SN95031_PCM2C2, + snd_soc_component_update_bits(component, SN95031_PCM2C2, BIT(0), BIT(0)); } break; case SND_SOC_BIAS_STANDBY: - switch (snd_soc_codec_get_bias_level(codec)) { + switch (snd_soc_component_get_bias_level(component)) { case SND_SOC_BIAS_OFF: pr_debug("vaud_bias power up rail\n"); /* power up the rail */ - snd_soc_write(codec, SN95031_VAUD, + snd_soc_component_write(component, SN95031_VAUD, BIT(2)|BIT(1)|BIT(0)); msleep(1); break; case SND_SOC_BIAS_PREPARE: /* turn off pcm */ pr_debug("vaud_bias power dn pcm\n"); - snd_soc_update_bits(codec, SN95031_PCM2C2, BIT(0), 0); - snd_soc_write(codec, SN95031_AUDPLLCTRL, 0); + snd_soc_component_update_bits(component, SN95031_PCM2C2, BIT(0), 0); + snd_soc_component_write(component, SN95031_AUDPLLCTRL, 0); break; default: break; @@ -227,7 +227,7 @@ static int sn95031_set_vaud_bias(struct snd_soc_codec *codec, case SND_SOC_BIAS_OFF: pr_debug("vaud_bias _OFF doing rail shutdown\n"); - snd_soc_write(codec, SN95031_VAUD, BIT(3)); + snd_soc_component_write(component, SN95031_VAUD, BIT(3)); break; } @@ -237,18 +237,18 @@ static int sn95031_set_vaud_bias(struct snd_soc_codec *codec, static int sn95031_vhs_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); if (SND_SOC_DAPM_EVENT_ON(event)) { pr_debug("VHS SND_SOC_DAPM_EVENT_ON doing rail startup now\n"); /* power up the rail */ - snd_soc_write(codec, SN95031_VHSP, 0x3D); - snd_soc_write(codec, SN95031_VHSN, 0x3F); + snd_soc_component_write(component, SN95031_VHSP, 0x3D); + snd_soc_component_write(component, SN95031_VHSN, 0x3F); msleep(1); } else if (SND_SOC_DAPM_EVENT_OFF(event)) { pr_debug("VHS SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n"); - snd_soc_write(codec, SN95031_VHSP, 0xC4); - snd_soc_write(codec, SN95031_VHSN, 0x04); + snd_soc_component_write(component, SN95031_VHSP, 0xC4); + snd_soc_component_write(component, SN95031_VHSN, 0x04); } return 0; } @@ -256,16 +256,16 @@ static int sn95031_vhs_event(struct snd_soc_dapm_widget *w, static int sn95031_vihf_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); if (SND_SOC_DAPM_EVENT_ON(event)) { pr_debug("VIHF SND_SOC_DAPM_EVENT_ON doing rail startup now\n"); /* power up the rail */ - snd_soc_write(codec, SN95031_VIHF, 0x27); + snd_soc_component_write(component, SN95031_VIHF, 0x27); msleep(1); } else if (SND_SOC_DAPM_EVENT_OFF(event)) { pr_debug("VIHF SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n"); - snd_soc_write(codec, SN95031_VIHF, 0x24); + snd_soc_component_write(component, SN95031_VIHF, 0x24); } return 0; } @@ -273,7 +273,7 @@ static int sn95031_vihf_event(struct snd_soc_dapm_widget *w, static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, 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); unsigned int ldo = 0, clk_dir = 0, data_dir = 0; if (SND_SOC_DAPM_EVENT_ON(event)) { @@ -282,16 +282,16 @@ static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w, data_dir = BIT(7); } /* program DMIC LDO, clock and set clock */ - snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); - snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(0), clk_dir); - snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(7), data_dir); + snd_soc_component_update_bits(component, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); + snd_soc_component_update_bits(component, SN95031_DMICBUF0123, BIT(0), clk_dir); + snd_soc_component_update_bits(component, SN95031_DMICBUF0123, BIT(7), data_dir); return 0; } static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, 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); unsigned int ldo = 0, clk_dir = 0, data_dir = 0; if (SND_SOC_DAPM_EVENT_ON(event)) { @@ -300,23 +300,23 @@ static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w, data_dir = BIT(1); } /* program DMIC LDO, clock and set clock */ - snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); - snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(2), clk_dir); - snd_soc_update_bits(codec, SN95031_DMICBUF45, BIT(1), data_dir); + snd_soc_component_update_bits(component, SN95031_MICBIAS, BIT(5)|BIT(4), ldo); + snd_soc_component_update_bits(component, SN95031_DMICBUF0123, BIT(2), clk_dir); + snd_soc_component_update_bits(component, SN95031_DMICBUF45, BIT(1), data_dir); return 0; } static int sn95031_dmic56_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, 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); unsigned int ldo = 0; if (SND_SOC_DAPM_EVENT_ON(event)) ldo = BIT(7)|BIT(6); /* program DMIC LDO */ - snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(7)|BIT(6), ldo); + snd_soc_component_update_bits(component, SN95031_MICBIAS, BIT(7)|BIT(6), ldo); return 0; } @@ -651,18 +651,18 @@ static SOC_ENUM_SINGLE_DECL(sn95031_dmic56_cfg_enum, /* speaker and headset mutes, for audio pops and clicks */ static int sn95031_pcm_hs_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, + snd_soc_component_update_bits(dai->component, SN95031_HSLVOLCTRL, BIT(7), (!mute << 7)); - snd_soc_update_bits(dai->codec, + snd_soc_component_update_bits(dai->component, SN95031_HSRVOLCTRL, BIT(7), (!mute << 7)); return 0; } static int sn95031_pcm_spkr_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, + snd_soc_component_update_bits(dai->component, SN95031_IHFLVOLCTRL, BIT(7), (!mute << 7)); - snd_soc_update_bits(dai->codec, + snd_soc_component_update_bits(dai->component, SN95031_IHFRVOLCTRL, BIT(7), (!mute << 7)); return 0; } @@ -683,7 +683,7 @@ static int sn95031_pcm_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_update_bits(dai->codec, SN95031_PCM2C2, + snd_soc_component_update_bits(dai->component, SN95031_PCM2C2, BIT(4)|BIT(5), format); switch (params_rate(params)) { @@ -701,7 +701,7 @@ static int sn95031_pcm_hw_params(struct snd_pcm_substream *substream, pr_err("ERR rate %d\n", params_rate(params)); return -EINVAL; } - snd_soc_update_bits(dai->codec, SN95031_PCM1C1, BIT(7), rate); + snd_soc_component_update_bits(dai->component, SN95031_PCM1C1, BIT(7), rate); return 0; } @@ -776,31 +776,31 @@ static int sn95031_pcm_hw_params(struct snd_pcm_substream *substream, }, }; -static inline void sn95031_disable_jack_btn(struct snd_soc_codec *codec) +static inline void sn95031_disable_jack_btn(struct snd_soc_component *component) { - snd_soc_write(codec, SN95031_BTNCTRL2, 0x00); + snd_soc_component_write(component, SN95031_BTNCTRL2, 0x00); } -static inline void sn95031_enable_jack_btn(struct snd_soc_codec *codec) +static inline void sn95031_enable_jack_btn(struct snd_soc_component *component) { - snd_soc_write(codec, SN95031_BTNCTRL1, 0x77); - snd_soc_write(codec, SN95031_BTNCTRL2, 0x01); + snd_soc_component_write(component, SN95031_BTNCTRL1, 0x77); + snd_soc_component_write(component, SN95031_BTNCTRL2, 0x01); } -static int sn95031_get_headset_state(struct snd_soc_codec *codec, +static int sn95031_get_headset_state(struct snd_soc_component *component, struct snd_soc_jack *mfld_jack) { - int micbias = sn95031_get_mic_bias(codec); + int micbias = sn95031_get_mic_bias(component); int jack_type = snd_soc_jack_get_type(mfld_jack, micbias); pr_debug("jack type detected = %d\n", jack_type); if (jack_type == SND_JACK_HEADSET) - sn95031_enable_jack_btn(codec); + sn95031_enable_jack_btn(component); return jack_type; } -void sn95031_jack_detection(struct snd_soc_codec *codec, +void sn95031_jack_detection(struct snd_soc_component *component, struct mfld_jack_data *jack_data) { unsigned int status; @@ -815,11 +815,11 @@ void sn95031_jack_detection(struct snd_soc_codec *codec, status = SND_JACK_HEADSET | SND_JACK_BTN_1; } else if (jack_data->intr_id & 0x4) { pr_debug("headset or headphones inserted\n"); - status = sn95031_get_headset_state(codec, jack_data->mfld_jack); + status = sn95031_get_headset_state(component, jack_data->mfld_jack); } else if (jack_data->intr_id & 0x8) { pr_debug("headset or headphones removed\n"); status = 0; - sn95031_disable_jack_btn(codec); + sn95031_disable_jack_btn(component); } else { pr_err("unidentified interrupt\n"); return; @@ -833,98 +833,89 @@ void sn95031_jack_detection(struct snd_soc_codec *codec, } EXPORT_SYMBOL_GPL(sn95031_jack_detection); -/* codec registration */ -static int sn95031_codec_probe(struct snd_soc_codec *codec) +/* component registration */ +static int sn95031_component_probe(struct snd_soc_component *component) { - pr_debug("codec_probe called\n"); + pr_debug("component_probe called\n"); /* PCM interface config * This sets the pcm rx slot conguration to max 6 slots * for max 4 dais (2 stereo and 2 mono) */ - snd_soc_write(codec, SN95031_PCM2RXSLOT01, 0x10); - snd_soc_write(codec, SN95031_PCM2RXSLOT23, 0x32); - snd_soc_write(codec, SN95031_PCM2RXSLOT45, 0x54); - snd_soc_write(codec, SN95031_PCM2TXSLOT01, 0x10); - snd_soc_write(codec, SN95031_PCM2TXSLOT23, 0x32); + snd_soc_component_write(component, SN95031_PCM2RXSLOT01, 0x10); + snd_soc_component_write(component, SN95031_PCM2RXSLOT23, 0x32); + snd_soc_component_write(component, SN95031_PCM2RXSLOT45, 0x54); + snd_soc_component_write(component, SN95031_PCM2TXSLOT01, 0x10); + snd_soc_component_write(component, SN95031_PCM2TXSLOT23, 0x32); /* pcm port setting * This sets the pcm port to slave and clock at 19.2Mhz which * can support 6slots, sampling rate set per stream in hw-params */ - snd_soc_write(codec, SN95031_PCM1C1, 0x00); - snd_soc_write(codec, SN95031_PCM2C1, 0x01); - snd_soc_write(codec, SN95031_PCM2C2, 0x0A); - snd_soc_write(codec, SN95031_HSMIXER, BIT(0)|BIT(4)); + snd_soc_component_write(component, SN95031_PCM1C1, 0x00); + snd_soc_component_write(component, SN95031_PCM2C1, 0x01); + snd_soc_component_write(component, SN95031_PCM2C2, 0x0A); + snd_soc_component_write(component, SN95031_HSMIXER, BIT(0)|BIT(4)); /* vendor vibra workround, the vibras are muted by * custom register so unmute them */ - snd_soc_write(codec, SN95031_SSR5, 0x80); - snd_soc_write(codec, SN95031_SSR6, 0x80); - snd_soc_write(codec, SN95031_VIB1C5, 0x00); - snd_soc_write(codec, SN95031_VIB2C5, 0x00); + snd_soc_component_write(component, SN95031_SSR5, 0x80); + snd_soc_component_write(component, SN95031_SSR6, 0x80); + snd_soc_component_write(component, SN95031_VIB1C5, 0x00); + snd_soc_component_write(component, SN95031_VIB2C5, 0x00); /* configure vibras for pcm port */ - snd_soc_write(codec, SN95031_VIB1C3, 0x00); - snd_soc_write(codec, SN95031_VIB2C3, 0x00); + snd_soc_component_write(component, SN95031_VIB1C3, 0x00); + snd_soc_component_write(component, SN95031_VIB2C3, 0x00); /* soft mute ramp time */ - snd_soc_write(codec, SN95031_SOFTMUTE, 0x3); + snd_soc_component_write(component, SN95031_SOFTMUTE, 0x3); /* fix the initial volume at 1dB, * default in +9dB, * 1dB give optimal swing on DAC, amps */ - snd_soc_write(codec, SN95031_HSLVOLCTRL, 0x08); - snd_soc_write(codec, SN95031_HSRVOLCTRL, 0x08); - snd_soc_write(codec, SN95031_IHFLVOLCTRL, 0x08); - snd_soc_write(codec, SN95031_IHFRVOLCTRL, 0x08); + snd_soc_component_write(component, SN95031_HSLVOLCTRL, 0x08); + snd_soc_component_write(component, SN95031_HSRVOLCTRL, 0x08); + snd_soc_component_write(component, SN95031_IHFLVOLCTRL, 0x08); + snd_soc_component_write(component, SN95031_IHFRVOLCTRL, 0x08); /* dac mode and lineout workaround */ - snd_soc_write(codec, SN95031_SSR2, 0x10); - snd_soc_write(codec, SN95031_SSR3, 0x40); + snd_soc_component_write(component, SN95031_SSR2, 0x10); + snd_soc_component_write(component, SN95031_SSR3, 0x40); return 0; } -static const struct snd_soc_codec_driver sn95031_codec = { - .probe = sn95031_codec_probe, - .set_bias_level = sn95031_set_vaud_bias, - .idle_bias_off = true, - - .component_driver = { - .controls = sn95031_snd_controls, - .num_controls = ARRAY_SIZE(sn95031_snd_controls), - .dapm_widgets = sn95031_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sn95031_dapm_widgets), - .dapm_routes = sn95031_audio_map, - .num_dapm_routes = ARRAY_SIZE(sn95031_audio_map), - }, +static const struct snd_soc_component_driver sn95031_component = { + .probe = sn95031_component_probe, + .set_bias_level = sn95031_set_vaud_bias, + .controls = sn95031_snd_controls, + .num_controls = ARRAY_SIZE(sn95031_snd_controls), + .dapm_widgets = sn95031_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sn95031_dapm_widgets), + .dapm_routes = sn95031_audio_map, + .num_dapm_routes = ARRAY_SIZE(sn95031_audio_map), + .pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int sn95031_device_probe(struct platform_device *pdev) { struct regmap *regmap; - pr_debug("codec device probe called for %s\n", dev_name(&pdev->dev)); + pr_debug("component device probe called for %s\n", dev_name(&pdev->dev)); regmap = devm_regmap_init(&pdev->dev, NULL, NULL, &sn95031_regmap); if (IS_ERR(regmap)) return PTR_ERR(regmap); - return snd_soc_register_codec(&pdev->dev, &sn95031_codec, + return devm_snd_soc_register_component(&pdev->dev, &sn95031_component, sn95031_dais, ARRAY_SIZE(sn95031_dais)); } -static int sn95031_device_remove(struct platform_device *pdev) -{ - pr_debug("codec device remove called\n"); - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver sn95031_codec_driver = { .driver = { .name = "sn95031", }, .probe = sn95031_device_probe, - .remove = sn95031_device_remove, }; module_platform_driver(sn95031_codec_driver); diff --git a/sound/soc/codecs/sn95031.h b/sound/soc/codecs/sn95031.h index 7651fe4..1e9fa62 100644 --- a/sound/soc/codecs/sn95031.h +++ b/sound/soc/codecs/sn95031.h @@ -127,7 +127,7 @@ struct mfld_jack_data { struct snd_soc_jack *mfld_jack; }; -extern void sn95031_jack_detection(struct snd_soc_codec *codec, +extern void sn95031_jack_detection(struct snd_soc_component *component, struct mfld_jack_data *jack_data); #endif diff --git a/sound/soc/intel/boards/mfld_machine.c b/sound/soc/intel/boards/mfld_machine.c index 7cb44fd..96d8888 100644 --- a/sound/soc/intel/boards/mfld_machine.c +++ b/sound/soc/intel/boards/mfld_machine.c @@ -53,7 +53,7 @@ enum soc_mic_bias_zones { static unsigned int hs_switch; static unsigned int lo_dac; -static struct snd_soc_codec *mfld_codec; +static struct snd_soc_component *mfld_codec; struct mfld_mc_private { void __iomem *int_base; @@ -173,28 +173,28 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol, pr_debug("set vibra path\n"); snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT"); snd_soc_dapm_disable_pin_unlocked(dapm, "VIB2OUT"); - snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0); + snd_soc_component_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0); break; case 1: pr_debug("set hs path\n"); snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones"); snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT"); - snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x22); + snd_soc_component_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x22); break; case 2: pr_debug("set spkr path\n"); snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTL"); snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTR"); - snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x44); + snd_soc_component_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x44); break; case 3: pr_debug("set null path\n"); snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTL"); snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTR"); - snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x66); + snd_soc_component_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x66); break; } @@ -271,7 +271,7 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime) return ret_val; } - mfld_codec = runtime->codec; + mfld_codec = runtime->codec_dai->component; /* we want to check if anything is inserted at boot, * so send a fake event to codec and it will read adc