mirror of https://gitee.com/openkylin/linux.git
Merge series "ASoC: rt5645: Enable internal mic and headset on ECS EF20" from Chris Chiu <chiu@endlessos.org>:
These patches are trying to fix the jack detection and internal microphone problems on ECS EF20 series laptops which are empowered by Intel Atom x5-Z8350 CPU (CherryTrail) with Realtek rt5645 audio codec. --- v2 -> v3: Restore the accidentally removed terminator of the dmi_platform_data[]. v1 -> v2: Invoke callback() of the DMI quirk if it exists, because the dmi_first_match() doesn't. --- Chris Chiu (4): ASoC: rt5645: Introduce mapping for ACPI-defined GPIO ASoC: rt5645: Add ACPI-defined GPIO for ECS EF20 series ASoC: rt5645: add inv_hp_det flag ASoC: rt5645: Enable internal microphone and JD on ECS EF20 include/sound/rt5645.h | 2 ++ sound/soc/codecs/rt5645.c | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) -- 2.20.1
This commit is contained in:
commit
1675cdd3d7
|
@ -22,6 +22,8 @@ struct rt5645_platform_data {
|
|||
bool level_trigger_irq;
|
||||
/* Invert JD1_1 status polarity */
|
||||
bool inv_jd1_1;
|
||||
/* Invert HP detect status polarity */
|
||||
bool inv_hp_pol;
|
||||
|
||||
/* Value to asign to snd_soc_card.long_name */
|
||||
const char *long_name;
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#define QUIRK_INV_JD1_1(q) ((q) & 1)
|
||||
#define QUIRK_LEVEL_IRQ(q) (((q) >> 1) & 1)
|
||||
#define QUIRK_IN2_DIFF(q) (((q) >> 2) & 1)
|
||||
#define QUIRK_INV_HP_POL(q) (((q) >> 3) & 1)
|
||||
#define QUIRK_JD_MODE(q) (((q) >> 4) & 7)
|
||||
#define QUIRK_DMIC1_DATA_PIN(q) (((q) >> 8) & 3)
|
||||
#define QUIRK_DMIC2_DATA_PIN(q) (((q) >> 12) & 3)
|
||||
|
@ -42,6 +43,8 @@ static unsigned int quirk = -1;
|
|||
module_param(quirk, uint, 0444);
|
||||
MODULE_PARM_DESC(quirk, "RT5645 pdata quirk override");
|
||||
|
||||
static const struct acpi_gpio_mapping *cht_rt5645_gpios;
|
||||
|
||||
#define RT5645_DEVICE_ID 0x6308
|
||||
#define RT5650_DEVICE_ID 0x6419
|
||||
|
||||
|
@ -3244,6 +3247,8 @@ static void rt5645_jack_detect_work(struct work_struct *work)
|
|||
case 0: /* Not using rt5645 JD */
|
||||
if (rt5645->gpiod_hp_det) {
|
||||
gpio_state = gpiod_get_value(rt5645->gpiod_hp_det);
|
||||
if (rt5645->pdata.inv_hp_pol)
|
||||
gpio_state ^= 1;
|
||||
dev_dbg(rt5645->component->dev, "gpio_state = %d\n",
|
||||
gpio_state);
|
||||
report = rt5645_jack_detect(rt5645->component, gpio_state);
|
||||
|
@ -3634,6 +3639,25 @@ static const struct rt5645_platform_data kahlee_platform_data = {
|
|||
.jd_mode = 3,
|
||||
};
|
||||
|
||||
static const struct rt5645_platform_data ecs_ef20_platform_data = {
|
||||
.dmic1_data_pin = RT5645_DMIC1_DISABLE,
|
||||
.dmic2_data_pin = RT5645_DMIC_DATA_IN2P,
|
||||
.inv_hp_pol = 1,
|
||||
};
|
||||
|
||||
static const struct acpi_gpio_params ef20_hp_detect = { 1, 0, false };
|
||||
|
||||
static const struct acpi_gpio_mapping cht_rt5645_ef20_gpios[] = {
|
||||
{ "hp-detect-gpios", &ef20_hp_detect, 1 },
|
||||
{ },
|
||||
};
|
||||
|
||||
static int cht_rt5645_ef20_quirk_cb(const struct dmi_system_id *id)
|
||||
{
|
||||
cht_rt5645_gpios = cht_rt5645_ef20_gpios;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const struct dmi_system_id dmi_platform_data[] = {
|
||||
{
|
||||
.ident = "Chrome Buddy",
|
||||
|
@ -3763,6 +3787,22 @@ static const struct dmi_system_id dmi_platform_data[] = {
|
|||
},
|
||||
.driver_data = (void *)&intel_braswell_platform_data,
|
||||
},
|
||||
{
|
||||
.ident = "EF20",
|
||||
.callback = cht_rt5645_ef20_quirk_cb,
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_NAME, "EF20"),
|
||||
},
|
||||
.driver_data = (void *)&ecs_ef20_platform_data,
|
||||
},
|
||||
{
|
||||
.ident = "EF20EA",
|
||||
.callback = cht_rt5645_ef20_quirk_cb,
|
||||
.matches = {
|
||||
DMI_MATCH(DMI_PRODUCT_NAME, "EF20EA"),
|
||||
},
|
||||
.driver_data = (void *)&ecs_ef20_platform_data,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -3826,11 +3866,16 @@ static int rt5645_i2c_probe(struct i2c_client *i2c,
|
|||
rt5645->pdata.in2_diff = QUIRK_IN2_DIFF(quirk);
|
||||
rt5645->pdata.level_trigger_irq = QUIRK_LEVEL_IRQ(quirk);
|
||||
rt5645->pdata.inv_jd1_1 = QUIRK_INV_JD1_1(quirk);
|
||||
rt5645->pdata.inv_hp_pol = QUIRK_INV_HP_POL(quirk);
|
||||
rt5645->pdata.jd_mode = QUIRK_JD_MODE(quirk);
|
||||
rt5645->pdata.dmic1_data_pin = QUIRK_DMIC1_DATA_PIN(quirk);
|
||||
rt5645->pdata.dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk);
|
||||
}
|
||||
|
||||
if (cht_rt5645_gpios && has_acpi_companion(&i2c->dev))
|
||||
if (devm_acpi_dev_add_driver_gpios(&i2c->dev, cht_rt5645_gpios))
|
||||
dev_dbg(&i2c->dev, "Failed to add driver gpios\n");
|
||||
|
||||
rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect",
|
||||
GPIOD_IN);
|
||||
|
||||
|
|
Loading…
Reference in New Issue