Commit 6db829fa authored by Hans de Goede's avatar Hans de Goede Committed by Ilpo Järvinen

platform/x86: asus-wmi: Change q500a_i8042_filter() into a generic i8042-filter

Change asus_q500a_i8042_filter() into a generic i8042-filter,
using a new filter_i8042_e1_extended_codes flag in the quirks struct
to decide if e1 extended codes should be filtered out or not.

This is a preparation patch for adding support for filtering volume key
events being reported twice through both the PS/2 keyboard and asus-wmi.

Note while modifying the code also drop the unnecessary unlikely()
annotations, this is not in a hot path so those are not necessary.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20231120154235.610808-3-hdegoede@redhat.comReviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent b52cbca2
...@@ -49,24 +49,26 @@ MODULE_PARM_DESC(tablet_mode_sw, "Tablet mode detect: -1:auto 0:disable 1:kbd-do ...@@ -49,24 +49,26 @@ MODULE_PARM_DESC(tablet_mode_sw, "Tablet mode detect: -1:auto 0:disable 1:kbd-do
static struct quirk_entry *quirks; static struct quirk_entry *quirks;
static bool asus_q500a_i8042_filter(unsigned char data, unsigned char str, static bool asus_i8042_filter(unsigned char data, unsigned char str, struct serio *port)
struct serio *port)
{ {
static bool extended; static bool extended_e1;
bool ret = false;
if (str & I8042_STR_AUXDATA) if (str & I8042_STR_AUXDATA)
return false; return false;
if (unlikely(data == 0xe1)) { if (quirks->filter_i8042_e1_extended_codes) {
extended = true; if (data == 0xe1) {
ret = true; extended_e1 = true;
} else if (unlikely(extended)) { return true;
extended = false;
ret = true;
} }
return ret; if (extended_e1) {
extended_e1 = false;
return true;
}
}
return false;
} }
static struct quirk_entry quirk_asus_unknown = { static struct quirk_entry quirk_asus_unknown = {
...@@ -75,7 +77,7 @@ static struct quirk_entry quirk_asus_unknown = { ...@@ -75,7 +77,7 @@ static struct quirk_entry quirk_asus_unknown = {
}; };
static struct quirk_entry quirk_asus_q500a = { static struct quirk_entry quirk_asus_q500a = {
.i8042_filter = asus_q500a_i8042_filter, .filter_i8042_e1_extended_codes = true,
.wmi_backlight_set_devstate = true, .wmi_backlight_set_devstate = true,
}; };
...@@ -619,6 +621,7 @@ static struct asus_wmi_driver asus_nb_wmi_driver = { ...@@ -619,6 +621,7 @@ static struct asus_wmi_driver asus_nb_wmi_driver = {
.input_phys = ASUS_NB_WMI_FILE "/input0", .input_phys = ASUS_NB_WMI_FILE "/input0",
.detect_quirks = asus_nb_wmi_quirks, .detect_quirks = asus_nb_wmi_quirks,
.key_filter = asus_nb_wmi_key_filter, .key_filter = asus_nb_wmi_key_filter,
.i8042_filter = asus_i8042_filter,
}; };
......
...@@ -4567,8 +4567,8 @@ static int asus_wmi_add(struct platform_device *pdev) ...@@ -4567,8 +4567,8 @@ static int asus_wmi_add(struct platform_device *pdev)
goto fail_wmi_handler; goto fail_wmi_handler;
} }
if (asus->driver->quirks->i8042_filter) { if (asus->driver->i8042_filter) {
err = i8042_install_filter(asus->driver->quirks->i8042_filter); err = i8042_install_filter(asus->driver->i8042_filter);
if (err) if (err)
pr_warn("Unable to install key filter - %d\n", err); pr_warn("Unable to install key filter - %d\n", err);
} }
...@@ -4609,8 +4609,8 @@ static int asus_wmi_remove(struct platform_device *device) ...@@ -4609,8 +4609,8 @@ static int asus_wmi_remove(struct platform_device *device)
struct asus_wmi *asus; struct asus_wmi *asus;
asus = platform_get_drvdata(device); asus = platform_get_drvdata(device);
if (asus->driver->quirks->i8042_filter) if (asus->driver->i8042_filter)
i8042_remove_filter(asus->driver->quirks->i8042_filter); i8042_remove_filter(asus->driver->i8042_filter);
wmi_remove_notify_handler(asus->driver->event_guid); wmi_remove_notify_handler(asus->driver->event_guid);
asus_wmi_backlight_exit(asus); asus_wmi_backlight_exit(asus);
asus_screenpad_exit(asus); asus_screenpad_exit(asus);
......
...@@ -39,6 +39,7 @@ struct quirk_entry { ...@@ -39,6 +39,7 @@ struct quirk_entry {
bool wmi_backlight_set_devstate; bool wmi_backlight_set_devstate;
bool wmi_force_als_set; bool wmi_force_als_set;
bool wmi_ignore_fan; bool wmi_ignore_fan;
bool filter_i8042_e1_extended_codes;
enum asus_wmi_tablet_switch_mode tablet_switch_mode; enum asus_wmi_tablet_switch_mode tablet_switch_mode;
int wapf; int wapf;
/* /*
...@@ -49,9 +50,6 @@ struct quirk_entry { ...@@ -49,9 +50,6 @@ struct quirk_entry {
*/ */
int no_display_toggle; int no_display_toggle;
u32 xusb2pr; u32 xusb2pr;
bool (*i8042_filter)(unsigned char data, unsigned char str,
struct serio *serio);
}; };
struct asus_wmi_driver { struct asus_wmi_driver {
...@@ -73,6 +71,9 @@ struct asus_wmi_driver { ...@@ -73,6 +71,9 @@ struct asus_wmi_driver {
* Return ASUS_WMI_KEY_IGNORE in code if event should be ignored. */ * Return ASUS_WMI_KEY_IGNORE in code if event should be ignored. */
void (*key_filter) (struct asus_wmi_driver *driver, int *code, void (*key_filter) (struct asus_wmi_driver *driver, int *code,
unsigned int *value, bool *autorelease); unsigned int *value, bool *autorelease);
/* Optional standard i8042 filter */
bool (*i8042_filter)(unsigned char data, unsigned char str,
struct serio *serio);
int (*probe) (struct platform_device *device); int (*probe) (struct platform_device *device);
void (*detect_quirks) (struct asus_wmi_driver *driver); void (*detect_quirks) (struct asus_wmi_driver *driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment