Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d70a2ffe authored by Przemo Firszt's avatar Przemo Firszt Committed by Jiri Kosina
Browse files

HID: wacom: Unify speed setting



This patch unifies speed setting for both supported tablets. Functionality
of "wacom_poke" (used only by Graphire) is now in "wacom_set_features".
Reporting speed for both tablets can be changed by somethinkg like:

echo 1 > /sys/class/bluetooth/hci0/hci0:1/{device No}/speed

Accepted values:
0 - low speed,
1 - high speed.

The way of changing reporting speed is the same for Graphire and Intuos4 WL.

Signed-off-by: default avatarPrzemo Firszt <przemo@firszt.eu>
Acked-by: default avatarPing Cheng <pingc@wacom.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent be4925b0
Loading
Loading
Loading
Loading
+47 −55
Original line number Original line Diff line number Diff line
@@ -229,33 +229,13 @@ static int wacom_ac_get_property(struct power_supply *psy,
}
}


static void wacom_set_features(struct hid_device *hdev, u8 speed)
static void wacom_set_features(struct hid_device *hdev, u8 speed)
{
	struct wacom_data *wdata = hid_get_drvdata(hdev);
	int ret;
	__u8 rep_data[2];

	if (speed == 1)
		wdata->features &= ~0x20;
	else
		wdata->features |= 0x20;

	rep_data[0] = 0x03;
	rep_data[1] = wdata->features;

	ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
				HID_FEATURE_REPORT);
	if (ret >= 0)
		wdata->high_speed = speed;

	return;
}

static void wacom_poke(struct hid_device *hdev, u8 speed)
{
{
	struct wacom_data *wdata = hid_get_drvdata(hdev);
	struct wacom_data *wdata = hid_get_drvdata(hdev);
	int limit, ret;
	int limit, ret;
	char rep_data[2];
	__u8 rep_data[2];


	switch (hdev->product) {
	case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH:
		rep_data[0] = 0x03 ; rep_data[1] = 0x00;
		rep_data[0] = 0x03 ; rep_data[1] = 0x00;
		limit = 3;
		limit = 3;
		do {
		do {
@@ -272,8 +252,8 @@ static void wacom_poke(struct hid_device *hdev, u8 speed)
			rep_data[1] = 0x00;
			rep_data[1] = 0x00;
			limit = 3;
			limit = 3;
			do {
			do {
			ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
				ret = hdev->hid_output_raw_report(hdev,
					HID_FEATURE_REPORT);
					rep_data, 2, HID_FEATURE_REPORT);
			} while (ret < 0 && limit-- > 0);
			} while (ret < 0 && limit-- > 0);


			if (ret >= 0) {
			if (ret >= 0) {
@@ -283,11 +263,28 @@ static void wacom_poke(struct hid_device *hdev, u8 speed)
		}
		}


		/*
		/*
	 * Note that if the raw queries fail, it's not a hard failure and it
		 * Note that if the raw queries fail, it's not a hard failure
	 * is safe to continue
		 * and it is safe to continue
		 */
		 */
		hid_warn(hdev, "failed to poke device, command %d, err %d\n",
		hid_warn(hdev, "failed to poke device, command %d, err %d\n",
			 rep_data[0], ret);
			 rep_data[0], ret);
		break;
	case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH:
		if (speed == 1)
			wdata->features &= ~0x20;
		else
			wdata->features |= 0x20;

		rep_data[0] = 0x03;
		rep_data[1] = wdata->features;

		ret = hdev->hid_output_raw_report(hdev, rep_data, 2,
					HID_FEATURE_REPORT);
		if (ret >= 0)
			wdata->high_speed = speed;
		break;
	}

	return;
	return;
}
}


@@ -311,7 +308,7 @@ static ssize_t wacom_store_speed(struct device *dev,
		return -EINVAL;
		return -EINVAL;


	if (new_speed == 0 || new_speed == 1) {
	if (new_speed == 0 || new_speed == 1) {
		wacom_poke(hdev, new_speed);
		wacom_set_features(hdev, new_speed);
		return strnlen(buf, PAGE_SIZE);
		return strnlen(buf, PAGE_SIZE);
	} else
	} else
		return -EINVAL;
		return -EINVAL;
@@ -720,22 +717,17 @@ static int wacom_probe(struct hid_device *hdev,
		hid_warn(hdev,
		hid_warn(hdev,
			 "can't create sysfs speed attribute err: %d\n", ret);
			 "can't create sysfs speed attribute err: %d\n", ret);


	switch (hdev->product) {
	case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH:
		/* Set Wacom mode 2 with high reporting speed */
		wacom_poke(hdev, 1);
		break;
	case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH:
		sprintf(hdev->name, "%s", "Wacom Intuos4 WL");
	wdata->features = 0;
	wdata->features = 0;
	wacom_set_features(hdev, 1);
	wacom_set_features(hdev, 1);

	if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) {
		sprintf(hdev->name, "%s", "Wacom Intuos4 WL");
		ret = wacom_initialize_leds(hdev);
		ret = wacom_initialize_leds(hdev);
		if (ret) {
		if (ret) {
			hid_warn(hdev,
			hid_warn(hdev,
				 "can't create led attribute, err: %d\n", ret);
				 "can't create led attribute, err: %d\n", ret);
			goto destroy_leds;
			goto destroy_leds;
		}
		}
		break;
	}
	}


	wdata->battery.properties = wacom_battery_props;
	wdata->battery.properties = wacom_battery_props;