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: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20231120154235.610808-3-hdegoede@redhat.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
This commit is contained in:
parent
b52cbca22c
commit
6db829fa2f
@ -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 bool asus_q500a_i8042_filter(unsigned char data, unsigned char str,
|
||||
struct serio *port)
|
||||
static bool asus_i8042_filter(unsigned char data, unsigned char str, struct serio *port)
|
||||
{
|
||||
static bool extended;
|
||||
bool ret = false;
|
||||
static bool extended_e1;
|
||||
|
||||
if (str & I8042_STR_AUXDATA)
|
||||
return false;
|
||||
|
||||
if (unlikely(data == 0xe1)) {
|
||||
extended = true;
|
||||
ret = true;
|
||||
} else if (unlikely(extended)) {
|
||||
extended = false;
|
||||
ret = true;
|
||||
if (quirks->filter_i8042_e1_extended_codes) {
|
||||
if (data == 0xe1) {
|
||||
extended_e1 = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (extended_e1) {
|
||||
extended_e1 = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
|
||||
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 = {
|
||||
.i8042_filter = asus_q500a_i8042_filter,
|
||||
.filter_i8042_e1_extended_codes = true,
|
||||
.wmi_backlight_set_devstate = true,
|
||||
};
|
||||
|
||||
@ -619,6 +621,7 @@ static struct asus_wmi_driver asus_nb_wmi_driver = {
|
||||
.input_phys = ASUS_NB_WMI_FILE "/input0",
|
||||
.detect_quirks = asus_nb_wmi_quirks,
|
||||
.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)
|
||||
goto fail_wmi_handler;
|
||||
}
|
||||
|
||||
if (asus->driver->quirks->i8042_filter) {
|
||||
err = i8042_install_filter(asus->driver->quirks->i8042_filter);
|
||||
if (asus->driver->i8042_filter) {
|
||||
err = i8042_install_filter(asus->driver->i8042_filter);
|
||||
if (err)
|
||||
pr_warn("Unable to install key filter - %d\n", err);
|
||||
}
|
||||
@ -4609,8 +4609,8 @@ static int asus_wmi_remove(struct platform_device *device)
|
||||
struct asus_wmi *asus;
|
||||
|
||||
asus = platform_get_drvdata(device);
|
||||
if (asus->driver->quirks->i8042_filter)
|
||||
i8042_remove_filter(asus->driver->quirks->i8042_filter);
|
||||
if (asus->driver->i8042_filter)
|
||||
i8042_remove_filter(asus->driver->i8042_filter);
|
||||
wmi_remove_notify_handler(asus->driver->event_guid);
|
||||
asus_wmi_backlight_exit(asus);
|
||||
asus_screenpad_exit(asus);
|
||||
|
@ -39,6 +39,7 @@ struct quirk_entry {
|
||||
bool wmi_backlight_set_devstate;
|
||||
bool wmi_force_als_set;
|
||||
bool wmi_ignore_fan;
|
||||
bool filter_i8042_e1_extended_codes;
|
||||
enum asus_wmi_tablet_switch_mode tablet_switch_mode;
|
||||
int wapf;
|
||||
/*
|
||||
@ -49,9 +50,6 @@ struct quirk_entry {
|
||||
*/
|
||||
int no_display_toggle;
|
||||
u32 xusb2pr;
|
||||
|
||||
bool (*i8042_filter)(unsigned char data, unsigned char str,
|
||||
struct serio *serio);
|
||||
};
|
||||
|
||||
struct asus_wmi_driver {
|
||||
@ -73,6 +71,9 @@ struct asus_wmi_driver {
|
||||
* Return ASUS_WMI_KEY_IGNORE in code if event should be ignored. */
|
||||
void (*key_filter) (struct asus_wmi_driver *driver, int *code,
|
||||
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);
|
||||
void (*detect_quirks) (struct asus_wmi_driver *driver);
|
||||
|
Loading…
x
Reference in New Issue
Block a user