From: Stuart Henderson Date: Thu, 27 Apr 2017 09:49:34 +0000 (+0100) Subject: extcon: madera: Report accessory detect events through input key events X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c34020f4131a80e09752ac247f18b75cb38a4321;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git extcon: madera: Report accessory detect events through input key events Change-Id: I1120594bc9f36efba6111c033eb9c1201ed8ea5b Signed-off-by: Stuart Henderson --- diff --git a/drivers/extcon/Kconfig b/drivers/extcon/Kconfig index f70fffbb3d70..c77a9c2e23aa 100644 --- a/drivers/extcon/Kconfig +++ b/drivers/extcon/Kconfig @@ -66,6 +66,15 @@ config EXTCON_MADERA Say Y here to enable support for external accessory detection on Cirrus Logic Madera class codecs. +config EXTCON_MADERA_INPUT_EVENT + bool "Report events through input key events" + depends on EXTCON_MADERA + default n + help + Say Y here to enable support for reporting external accessory + detection events through input key events on Cirrus Logic Madera + class codecs. + config EXTCON_MAX14577 tristate "Maxim MAX14577/77836 EXTCON Support" depends on MFD_MAX14577 diff --git a/drivers/extcon/extcon-madera.c b/drivers/extcon/extcon-madera.c index a0a565b3dc93..eb933c9f7a65 100644 --- a/drivers/extcon/extcon-madera.c +++ b/drivers/extcon/extcon-madera.c @@ -519,14 +519,33 @@ inline void madera_extcon_report(struct madera_extcon *info, int ret; dev_dbg(info->dev, "Extcon report: %d is %s\n", - which, - attached ? "attached" : "removed"); + which, attached ? "attached" : "removed"); ret = extcon_set_state_sync(info->edev, which, attached); if (ret != 0) - dev_warn(info->dev, - "Failed to report cable state: %d\n", - ret); + dev_warn(info->dev, "Failed to report cable state: %d\n", ret); + + if (IS_ENABLED(CONFIG_EXTCON_MADERA_INPUT_EVENT)) { + switch (which) { + case EXTCON_MECHANICAL: + input_report_switch(info->input, + SW_JACK_PHYSICAL_INSERT, + attached); + break; + case EXTCON_JACK_HEADPHONE: + input_report_switch(info->input, + SW_HEADPHONE_INSERT, + attached); + break; + case EXTCON_JACK_MICROPHONE: + input_report_switch(info->input, + SW_MICROPHONE_INSERT, + attached); + break; + } + + input_sync(info->input); + } } EXPORT_SYMBOL_GPL(madera_extcon_report); @@ -3122,6 +3141,18 @@ static int madera_extcon_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev); + if (IS_ENABLED(CONFIG_EXTCON_MADERA_INPUT_EVENT)) { + input_set_capability(info->input, + EV_SW, + SW_MICROPHONE_INSERT); + input_set_capability(info->input, + EV_SW, + SW_HEADPHONE_INSERT); + input_set_capability(info->input, + EV_SW, + SW_JACK_PHYSICAL_INSERT); + } + ret = input_register_device(info->input); if (ret) { dev_err(&pdev->dev, "Can't register input device: %d\n", ret);