From patchwork Sun Mar 4 14:35:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10257685 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 7088D602B5 for ; Sun, 4 Mar 2018 14:36:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 600EC28794 for ; Sun, 4 Mar 2018 14:36:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54DEC287FD; Sun, 4 Mar 2018 14:36:52 +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.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham 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 6663F28794 for ; Sun, 4 Mar 2018 14:36:51 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B66DB26739F; Sun, 4 Mar 2018 15:36:24 +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 263ED267016; Sun, 4 Mar 2018 15:36:20 +0100 (CET) Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by alsa0.perex.cz (Postfix) with ESMTP id 4B9F1267016 for ; Sun, 4 Mar 2018 15:36:18 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3EB54040858; Sun, 4 Mar 2018 14:36:17 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-72.ams2.redhat.com [10.36.116.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id A536D111DCEE; Sun, 4 Mar 2018 14:36:16 +0000 (UTC) From: Hans de Goede To: Mark Brown , Bard Liao , Oder Chiou , Pierre-Louis Bossart Date: Sun, 4 Mar 2018 15:35:51 +0100 Message-Id: <20180304143610.21125-4-hdegoede@redhat.com> In-Reply-To: <20180304143610.21125-1-hdegoede@redhat.com> References: <20180304143610.21125-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 04 Mar 2018 14:36:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Sun, 04 Mar 2018 14:36:17 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'hdegoede@redhat.com' RCPT:'' Cc: Hans de Goede , alsa-devel@alsa-project.org, Carlo Caione , Takashi Iwai Subject: [alsa-devel] [PATCH v3 03/22] ASoC: rt5651: Configure jack-detect source through a device-property 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Configure the jack-detect source through a device-property which can be set by code outside of the codec driver. Rather then putting platform specific DMI quirks inside the generic codec driver. Signed-off-by: Hans de Goede --- Changes in v3 -Split out the machine-driver and dt-bindings changes into separate patches, keeping just the codec driver changes in this patch Changes in v2: -New patch in v2 of this patch-set --- include/sound/rt5651.h | 4 ++++ sound/soc/codecs/rt5651.c | 33 +++++++-------------------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 1612462bf5ad..725b36c329d0 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -11,6 +11,10 @@ #ifndef __LINUX_SND_RT5651_H #define __LINUX_SND_RT5651_H +/* + * Note these MUST match the values from the DT binding: + * Documentation/devicetree/bindings/sound/rt5651.txt + */ enum rt5651_jd_src { RT5651_JD_NULL, RT5651_JD1_1, diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 7bff5cda61fd..f80b3da4667f 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -32,8 +31,6 @@ #include "rl6231.h" #include "rt5651.h" -#define RT5651_JD_MAP(quirk) ((quirk) & GENMASK(7, 0)) - #define RT5651_DEVICE_ID_VALUE 0x6281 #define RT5651_PR_RANGE_BASE (0xff + 1) @@ -41,8 +38,6 @@ #define RT5651_PR_BASE (RT5651_PR_RANGE_BASE + (0 * RT5651_PR_SPACING)) -static unsigned long rt5651_quirk; - static const struct regmap_range_cfg rt5651_ranges[] = { { .name = "PR", .range_min = RT5651_PR_BASE, .range_max = RT5651_PR_BASE + 0xb4, @@ -1675,6 +1670,9 @@ static int rt5651_set_jack(struct snd_soc_component *component, */ static void rt5651_apply_properties(struct snd_soc_component *component) { + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + u32 val; + if (device_property_read_bool(component->dev, "realtek,in2-differential")) snd_soc_component_update_bits(component, RT5651_IN1_IN2, RT5651_IN_DF2, RT5651_IN_DF2); @@ -1682,6 +1680,10 @@ static void rt5651_apply_properties(struct snd_soc_component *component) if (device_property_read_bool(component->dev, "realtek,dmic-en")) snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); + + if (device_property_read_u32(component->dev, + "realtek,jack-detect-source", &val) == 0) + rt5651->jd_src = val; } static int rt5651_probe(struct snd_soc_component *component) @@ -1832,24 +1834,6 @@ static const struct i2c_device_id rt5651_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id); -static int rt5651_quirk_cb(const struct dmi_system_id *id) -{ - rt5651_quirk = (unsigned long) id->driver_data; - return 1; -} - -static const struct dmi_system_id rt5651_quirk_table[] = { - { - .callback = rt5651_quirk_cb, - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "KIANO"), - DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"), - }, - .driver_data = (unsigned long *) RT5651_JD1_1, - }, - {} -}; - static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { int jack_type; @@ -1917,9 +1901,6 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, rt5651); - dmi_check_system(rt5651_quirk_table); - rt5651->jd_src = RT5651_JD_MAP(rt5651_quirk); - rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); if (IS_ERR(rt5651->regmap)) { ret = PTR_ERR(rt5651->regmap);