HID: separate mode switching function for wacom bluetooth driver
wacom_poke function allows to switch tablet reporting speed. The patch dosen't add any new functionality, but it's preparation for user-space speed switching through sysfs. Signed-off-by: Przemo Firszt <przemo@firszt.eu> Signed-off-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
parent
59d2334ac9
commit
06c7c313b5
1 changed files with 40 additions and 26 deletions
|
@ -103,6 +103,44 @@ static int wacom_ac_get_property(struct power_supply *psy,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void wacom_poke(struct hid_device *hdev, u8 speed)
|
||||||
|
{
|
||||||
|
int limit, ret;
|
||||||
|
char rep_data[2];
|
||||||
|
|
||||||
|
rep_data[0] = 0x03 ; rep_data[1] = 0x00;
|
||||||
|
limit = 3;
|
||||||
|
do {
|
||||||
|
ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
|
||||||
|
HID_FEATURE_REPORT);
|
||||||
|
} while (ret < 0 && limit-- > 0);
|
||||||
|
|
||||||
|
if (ret >= 0) {
|
||||||
|
if (speed == 0)
|
||||||
|
rep_data[0] = 0x05;
|
||||||
|
else
|
||||||
|
rep_data[0] = 0x06;
|
||||||
|
|
||||||
|
rep_data[1] = 0x00;
|
||||||
|
limit = 3;
|
||||||
|
do {
|
||||||
|
ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
|
||||||
|
HID_FEATURE_REPORT);
|
||||||
|
} while (ret < 0 && limit-- > 0);
|
||||||
|
|
||||||
|
if (ret >= 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note that if the raw queries fail, it's not a hard failure and it
|
||||||
|
* is safe to continue
|
||||||
|
*/
|
||||||
|
dev_warn(&hdev->dev, "failed to poke device, command %d, err %d\n",
|
||||||
|
rep_data[0], ret);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
|
static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
|
||||||
u8 *raw_data, int size)
|
u8 *raw_data, int size)
|
||||||
{
|
{
|
||||||
|
@ -236,9 +274,7 @@ static int wacom_probe(struct hid_device *hdev,
|
||||||
struct hid_input *hidinput;
|
struct hid_input *hidinput;
|
||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
struct wacom_data *wdata;
|
struct wacom_data *wdata;
|
||||||
char rep_data[2];
|
|
||||||
int ret;
|
int ret;
|
||||||
int limit;
|
|
||||||
|
|
||||||
wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
|
wdata = kzalloc(sizeof(*wdata), GFP_KERNEL);
|
||||||
if (wdata == NULL) {
|
if (wdata == NULL) {
|
||||||
|
@ -261,30 +297,8 @@ static int wacom_probe(struct hid_device *hdev,
|
||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Set Wacom mode 2 with high reporting speed */
|
||||||
* Note that if the raw queries fail, it's not a hard failure and it
|
wacom_poke(hdev, 1);
|
||||||
* is safe to continue
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Set Wacom mode2 */
|
|
||||||
rep_data[0] = 0x03; rep_data[1] = 0x00;
|
|
||||||
limit = 3;
|
|
||||||
do {
|
|
||||||
ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
|
|
||||||
HID_FEATURE_REPORT);
|
|
||||||
} while (ret < 0 && limit-- > 0);
|
|
||||||
if (ret < 0)
|
|
||||||
dev_warn(&hdev->dev, "failed to poke device #1, %d\n", ret);
|
|
||||||
|
|
||||||
/* 0x06 - high reporting speed, 0x05 - low speed */
|
|
||||||
rep_data[0] = 0x06; rep_data[1] = 0x00;
|
|
||||||
limit = 3;
|
|
||||||
do {
|
|
||||||
ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
|
|
||||||
HID_FEATURE_REPORT);
|
|
||||||
} while (ret < 0 && limit-- > 0);
|
|
||||||
if (ret < 0)
|
|
||||||
dev_warn(&hdev->dev, "failed to poke device #2, %d\n", ret);
|
|
||||||
|
|
||||||
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
|
#ifdef CONFIG_HID_WACOM_POWER_SUPPLY
|
||||||
wdata->battery.properties = wacom_battery_props;
|
wdata->battery.properties = wacom_battery_props;
|
||||||
|
|
Loading…
Reference in a new issue