ASoC: rt5651: Configure jack-detect source through a device-property

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 <hdegoede@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Hans de Goede 2018-03-04 15:35:51 +01:00 committed by Mark Brown
parent 9db7d4b32c
commit f0c2a330d9
No known key found for this signature in database
GPG key ID: 24D68B725D5487D0
2 changed files with 11 additions and 26 deletions

View file

@ -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,

View file

@ -19,7 +19,6 @@
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/acpi.h>
#include <linux/dmi.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
@ -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)
@ -1831,24 +1833,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;
@ -1916,9 +1900,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);