Skip to contentSkip to conversation

HID: wacom: Move handling of Intuos status packets to seperate function

PATCH In review Jason Gerecke 3 participants 20 messages Mar 6, 2015 – Mar 11, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/7 HID: wacom: Move handling of Intuos status packets to seperate function

In addition to the touchswitch state for "Intuos", these packets are also sent by the Intuos Pro, Intuos5, and last-generation Bamboo tablets when using a wired connection. They contain, among other things, information about the optional wireless module and battery charge state (to be supported in subsuquent patches).

---
 drivers/hid/wacom_wac.c | 36 +++++++++++++++++++++++-------------
 drivers/hid/wacom_wac.h |  1 +
 2 files changed, 24 insertions(+), 13 deletions(-)
drivers/hid/wacom_wac.c +23 -13
index bbf72f9..cb308c5 100644
@@ -1740,20 +1740,9 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
 	unsigned char *data = wacom->data;
 	int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
 
-	if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
+	if (data[0] != WACOM_REPORT_PENABLED)
 	    return 0;
 
-	if (data[0] == WACOM_REPORT_USB) {
-		if (features->type == INTUOSHT &&
-		    wacom->shared->touch_input &&
-		    features->touch_max) {
-			input_report_switch(wacom->shared->touch_input,
-					    SW_MUTE_DEVICE, data[8] & 0x40);
-			input_sync(wacom->shared->touch_input);
-		}
-		return 0;
-	}
-
 	prox = (data[1] & 0x20) == 0x20;
 
 	/*
@@ -1960,6 +1949,24 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 	return 0;
 }
 
+static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
+{
+	struct wacom_features *features = &wacom_wac->features;
+	unsigned char *data = wacom_wac->data;
+
+	if (data[0] != WACOM_REPORT_USB)
+		return 0;
+
+	if (features->type == INTUOSHT &&
+	    wacom_wac->shared->touch_input &&
+	    features->touch_max) {
+		input_report_switch(wacom_wac->shared->touch_input,
+				    SW_MUTE_DEVICE, data[8] & 0x40);
+		input_sync(wacom_wac->shared->touch_input);
+	}
+	return 0;
+}
+
 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 {
 	bool sync;
@@ -2044,7 +2051,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	case BAMBOO_PT:
 	case INTUOSHT:
-		sync = wacom_bpt_irq(wacom_wac, len);
+		if (wacom_wac->data[0] == WACOM_REPORT_USB)
+			sync = wacom_status_irq(wacom_wac, len);
+		else
+			sync = wacom_bpt_irq(wacom_wac, len);
 		break;
 
 	case BAMBOO_PAD:
drivers/hid/wacom_wac.h +1 -0
index a3d0828..ee6a545 100644
@@ -71,6 +71,7 @@
 #define WACOM_REPORT_USB		192
 #define WACOM_REPORT_BPAD_PEN		3
 #define WACOM_REPORT_BPAD_TOUCH		16
+#define WACOM_PKGLEN_STATUS		10
 
 /* device quirks */
 #define WACOM_QUIRK_MULTI_INPUT		0x0001
Signature · 1 line
2.3.0
#1 lore raw

PATCH 1/7 HID: wacom: Move handling of Intuos status packets to seperate function

In addition to the touchswitch state for "Intuos", these packets are also sent by the Intuos Pro, Intuos5, and last-generation Bamboo tablets when using a wired connection. They contain, among other things, information about the optional wireless module and battery charge state (to be supported in subsuquent patches).

---
 drivers/hid/wacom_wac.c | 36 +++++++++++++++++++++++-------------
 drivers/hid/wacom_wac.h |  1 +
 2 files changed, 24 insertions(+), 13 deletions(-)
drivers/hid/wacom_wac.c +23 -13
index bbf72f9..cb308c5 100644
@@ -1740,20 +1740,9 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
 	unsigned char *data = wacom->data;
 	int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
 
-	if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
+	if (data[0] != WACOM_REPORT_PENABLED)
 	    return 0;
 
-	if (data[0] == WACOM_REPORT_USB) {
-		if (features->type == INTUOSHT &&
-		    wacom->shared->touch_input &&
-		    features->touch_max) {
-			input_report_switch(wacom->shared->touch_input,
-					    SW_MUTE_DEVICE, data[8] & 0x40);
-			input_sync(wacom->shared->touch_input);
-		}
-		return 0;
-	}
-
 	prox = (data[1] & 0x20) == 0x20;
 
 	/*
@@ -1960,6 +1949,24 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 	return 0;
 }
 
+static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
+{
+	struct wacom_features *features = &wacom_wac->features;
+	unsigned char *data = wacom_wac->data;
+
+	if (data[0] != WACOM_REPORT_USB)
+		return 0;
+
+	if (features->type == INTUOSHT &&
+	    wacom_wac->shared->touch_input &&
+	    features->touch_max) {
+		input_report_switch(wacom_wac->shared->touch_input,
+				    SW_MUTE_DEVICE, data[8] & 0x40);
+		input_sync(wacom_wac->shared->touch_input);
+	}
+	return 0;
+}
+
 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 {
 	bool sync;
@@ -2044,7 +2051,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	case BAMBOO_PT:
 	case INTUOSHT:
-		sync = wacom_bpt_irq(wacom_wac, len);
+		if (wacom_wac->data[0] == WACOM_REPORT_USB)
+			sync = wacom_status_irq(wacom_wac, len);
+		else
+			sync = wacom_bpt_irq(wacom_wac, len);
 		break;
 
 	case BAMBOO_PAD:
drivers/hid/wacom_wac.h +1 -0
index a3d0828..ee6a545 100644
@@ -71,6 +71,7 @@
 #define WACOM_REPORT_USB		192
 #define WACOM_REPORT_BPAD_PEN		3
 #define WACOM_REPORT_BPAD_TOUCH		16
+#define WACOM_PKGLEN_STATUS		10
 
 /* device quirks */
 #define WACOM_QUIRK_MULTI_INPUT		0x0001
Signature · 1 line
2.3.0
#2 lore raw

PATCH 2/7 HID: wacom: Centralize updating of wacom_wac battery status

In reply to Jason Gerecke

Has the 'wacom_notify_battery' function take on the job of detecting if updating the power supply is necessary to remove multiple nearly-identical 'if' blocks.

---
 drivers/hid/wacom.h     |  7 ------
 drivers/hid/wacom_wac.c | 57 +++++++++++++++++++++++++------------------------
 2 files changed, 29 insertions(+), 35 deletions(-)
drivers/hid/wacom.h +0 -7
index 7db4328..b8344b1 100644
@@ -129,13 +129,6 @@ static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
 	schedule_work(&wacom->work);
 }
 
-static inline void wacom_notify_battery(struct wacom_wac *wacom_wac)
-{
-	struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
-
-	power_supply_changed(&wacom->battery);
-}
-
 extern const struct hid_device_id wacom_ids[];
 
 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
drivers/hid/wacom_wac.c +29 -28

96 lines not on this page · raw message

Signature · 1 line
2.3.0
#3 lore raw

PATCH 2/7 HID: wacom: Centralize updating of wacom_wac battery status

In reply to Jason Gerecke

Has the 'wacom_notify_battery' function take on the job of detecting if updating the power supply is necessary to remove multiple nearly-identical 'if' blocks.

---
 drivers/hid/wacom.h     |  7 ------
 drivers/hid/wacom_wac.c | 57 +++++++++++++++++++++++++------------------------
 2 files changed, 29 insertions(+), 35 deletions(-)
drivers/hid/wacom.h +0 -7
index 7db4328..b8344b1 100644
@@ -129,13 +129,6 @@ static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
 	schedule_work(&wacom->work);
 }
 
-static inline void wacom_notify_battery(struct wacom_wac *wacom_wac)
-{
-	struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
-
-	power_supply_changed(&wacom->battery);
-}
-
 extern const struct hid_device_id wacom_ids[];
 
 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
drivers/hid/wacom_wac.c +29 -28

96 lines not on this page · raw message

Signature · 1 line
2.3.0
#4 lore raw

PATCH 3/7 HID: wacom: Allow dynamic battery creation/destruction

In reply to Jason Gerecke

Tablets like the Intuos, Intuos Pro, and Bamboo have a connector for an optional wireless module that can be connected on the fly. The presence (or absence) of this module is indicated in a status report recieved from the tablet. This patch adds a workqueue function that will create or destroy a power_supply object at runtime to match the current state of the WACOM_QUIRK_BATTERY flag.

---
 drivers/hid/wacom.h     |  1 +
 drivers/hid/wacom_sys.c | 17 +++++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/hid/wacom.h +1 -0
index b8344b1..ad7318d 100644
@@ -142,4 +142,5 @@ void wacom_wac_usage_mapping(struct hid_device *hdev,
 int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
 		struct hid_usage *usage, __s32 value);
 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report);
+void wacom_battery_work(struct work_struct *work);
 #endif
drivers/hid/wacom_sys.c +15 -2
index 957699f..dfa4be7 100644
@@ -1057,8 +1057,7 @@ static int wacom_initialize_battery(struct wacom *wacom)
 
 static void wacom_destroy_battery(struct wacom *wacom)
 {
-	if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
-	     wacom->battery.dev) {
+	if (wacom->battery.dev) {
 		power_supply_unregister(&wacom->battery);
 		wacom->battery.dev = NULL;
 		power_supply_unregister(&wacom->ac);
@@ -1329,6 +1328,20 @@ fail:
 	return;
 }
 
+void wacom_battery_work(struct work_struct *work)
+{
+	struct wacom *wacom = container_of(work, struct wacom, work);
+
+	if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
+	     !wacom->battery.dev) {
+		wacom_initialize_battery(wacom);
+	}
+	else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
+		 wacom->battery.dev) {
+		wacom_destroy_battery(wacom);
+	}
+}
+
 /*
  * Not all devices report physical dimensions from HID.
  * Compute the default from hardcoded logical dimension
Signature · 1 line
2.3.0
#5 lore raw

PATCH 3/7 HID: wacom: Allow dynamic battery creation/destruction

In reply to Jason Gerecke

Tablets like the Intuos, Intuos Pro, and Bamboo have a connector for an optional wireless module that can be connected on the fly. The presence (or absence) of this module is indicated in a status report recieved from the tablet. This patch adds a workqueue function that will create or destroy a power_supply object at runtime to match the current state of the WACOM_QUIRK_BATTERY flag.

---
 drivers/hid/wacom.h     |  1 +
 drivers/hid/wacom_sys.c | 17 +++++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/hid/wacom.h +1 -0
index b8344b1..ad7318d 100644
@@ -142,4 +142,5 @@ void wacom_wac_usage_mapping(struct hid_device *hdev,
 int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
 		struct hid_usage *usage, __s32 value);
 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report);
+void wacom_battery_work(struct work_struct *work);
 #endif
drivers/hid/wacom_sys.c +15 -2
index 957699f..dfa4be7 100644
@@ -1057,8 +1057,7 @@ static int wacom_initialize_battery(struct wacom *wacom)
 
 static void wacom_destroy_battery(struct wacom *wacom)
 {
-	if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
-	     wacom->battery.dev) {
+	if (wacom->battery.dev) {
 		power_supply_unregister(&wacom->battery);
 		wacom->battery.dev = NULL;
 		power_supply_unregister(&wacom->ac);
@@ -1329,6 +1328,20 @@ fail:
 	return;
 }
 
+void wacom_battery_work(struct work_struct *work)
+{
+	struct wacom *wacom = container_of(work, struct wacom, work);
+
+	if ((wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
+	     !wacom->battery.dev) {
+		wacom_initialize_battery(wacom);
+	}
+	else if (!(wacom->wacom_wac.features.quirks & WACOM_QUIRK_BATTERY) &&
+		 wacom->battery.dev) {
+		wacom_destroy_battery(wacom);
+	}
+}
+
 /*
  * Not all devices report physical dimensions from HID.
  * Compute the default from hardcoded logical dimension
Signature · 1 line
2.3.0
#6 lore raw

PATCH 4/7 HID: wacom: Provide battery charge state to system over USB if available

In reply to Jason Gerecke

If a wireless adapter (which contains the charging circuitry) is detected as being attached to the tablet then create a new battery interface and update its status as data is reported. Also destroy the battery if the adapter goes away.

---
 drivers/hid/wacom_wac.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/hid/wacom_wac.c +25 -0
index 5d57fec..f1e53f1 100644
@@ -1952,6 +1952,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 
 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 {
+	struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
 	struct wacom_features *features = &wacom_wac->features;
 	unsigned char *data = wacom_wac->data;
 
@@ -1965,6 +1966,30 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 				    SW_MUTE_DEVICE, data[8] & 0x40);
 		input_sync(wacom_wac->shared->touch_input);
 	}
+
+	if (data[9] & 0x02) { /* wireless module is attached */
+		int battery = (data[8] & 0x3f) * 100 / 31;
+		bool ps_connected = !!(data[8] & 0x80);
+		bool charging = ps_connected &&
+				wacom_wac->battery_capacity < 100;
+
+		wacom_notify_battery(wacom_wac, battery, charging,
+				     ps_connected);
+
+		if (!wacom->battery.dev &&
+		    !(features->quirks & WACOM_QUIRK_BATTERY)) {
+			features->quirks |= WACOM_QUIRK_BATTERY;
+			INIT_WORK(&wacom->work, wacom_battery_work);
+			wacom_schedule_work(wacom_wac);
+		}
+	}
+	else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
+		 wacom->battery.dev) {
+		features->quirks &= ~WACOM_QUIRK_BATTERY;
+		INIT_WORK(&wacom->work, wacom_battery_work);
+		wacom_schedule_work(wacom_wac);
+		wacom_notify_battery(wacom_wac, 0, 0, 0);
+	}
 	return 0;
 }
 
Signature · 1 line
2.3.0
#7 lore raw

PATCH 4/7 HID: wacom: Provide battery charge state to system over USB if available

In reply to Jason Gerecke

If a wireless adapter (which contains the charging circuitry) is detected as being attached to the tablet then create a new battery interface and update its status as data is reported. Also destroy the battery if the adapter goes away.

---
 drivers/hid/wacom_wac.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/hid/wacom_wac.c +25 -0
index 5d57fec..f1e53f1 100644
@@ -1952,6 +1952,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 
 static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 {
+	struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
 	struct wacom_features *features = &wacom_wac->features;
 	unsigned char *data = wacom_wac->data;
 
@@ -1965,6 +1966,30 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 				    SW_MUTE_DEVICE, data[8] & 0x40);
 		input_sync(wacom_wac->shared->touch_input);
 	}
+
+	if (data[9] & 0x02) { /* wireless module is attached */
+		int battery = (data[8] & 0x3f) * 100 / 31;
+		bool ps_connected = !!(data[8] & 0x80);
+		bool charging = ps_connected &&
+				wacom_wac->battery_capacity < 100;
+
+		wacom_notify_battery(wacom_wac, battery, charging,
+				     ps_connected);
+
+		if (!wacom->battery.dev &&
+		    !(features->quirks & WACOM_QUIRK_BATTERY)) {
+			features->quirks |= WACOM_QUIRK_BATTERY;
+			INIT_WORK(&wacom->work, wacom_battery_work);
+			wacom_schedule_work(wacom_wac);
+		}
+	}
+	else if ((features->quirks & WACOM_QUIRK_BATTERY) &&
+		 wacom->battery.dev) {
+		features->quirks &= ~WACOM_QUIRK_BATTERY;
+		INIT_WORK(&wacom->work, wacom_battery_work);
+		wacom_schedule_work(wacom_wac);
+		wacom_notify_battery(wacom_wac, 0, 0, 0);
+	}
 	return 0;
 }
 
Signature · 1 line
2.3.0
#8 lore raw

PATCH 5/7 HID: wacom: Report battery status for Intuos Pro and Intuos5

In reply to Jason Gerecke

Calls the wacom_status_irq function to report battery status for the Intuos Pro and Intuos5 (in addition to the already-reporting Intuos and last-generation Bamboo).

---
 drivers/hid/wacom_wac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/hid/wacom_wac.c +2 -0
index f1e53f1..726fedb 100644
@@ -2062,6 +2062,8 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 	case INTUOSPL:
 		if (len == WACOM_PKGLEN_BBTOUCH3)
 			sync = wacom_bpt3_touch(wacom_wac);
+		else if (wacom_wac->data[0] == WACOM_REPORT_USB)
+			sync = wacom_status_irq(wacom_wac, len);
 		else
 			sync = wacom_intuos_irq(wacom_wac);
 		break;
Signature · 1 line
2.3.0
#9 lore raw

PATCH 5/7 HID: wacom: Report battery status for Intuos Pro and Intuos5

In reply to Jason Gerecke

Calls the wacom_status_irq function to report battery status for the Intuos Pro and Intuos5 (in addition to the already-reporting Intuos and last-generation Bamboo).

---
 drivers/hid/wacom_wac.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/hid/wacom_wac.c +2 -0
index f1e53f1..726fedb 100644
@@ -2062,6 +2062,8 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 	case INTUOSPL:
 		if (len == WACOM_PKGLEN_BBTOUCH3)
 			sync = wacom_bpt3_touch(wacom_wac);
+		else if (wacom_wac->data[0] == WACOM_REPORT_USB)
+			sync = wacom_status_irq(wacom_wac, len);
 		else
 			sync = wacom_intuos_irq(wacom_wac);
 		break;
Signature · 1 line
2.3.0
#10 lore raw

PATCH 6/7 HID: wacom: Status packet provides 'charging', not 'powered' bit

In reply to Jason Gerecke

The status packet for tablets which can use a wireless module contains a bit that is set if the battery is charging. This bit will be 0 if either a battery is not present or if the battery has reached full charge. Note that the charging circuit may continue to charge the battery for a short time after reaching "100%".

---
 drivers/hid/wacom_sys.c |  2 ++
 drivers/hid/wacom_wac.c | 14 +++++---------
 2 files changed, 7 insertions(+), 9 deletions(-)
drivers/hid/wacom_sys.c +2 -0
index dfa4be7..955ce7c 100644
@@ -977,6 +977,8 @@ static int wacom_battery_get_property(struct power_supply *psy,
 			else if (wacom->wacom_wac.battery_capacity == 100 &&
 				    wacom->wacom_wac.ps_connected)
 				val->intval = POWER_SUPPLY_STATUS_FULL;
+			else if (wacom->wacom_wac.ps_connected)
+				val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
 			else
 				val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
 			break;
drivers/hid/wacom_wac.c +5 -9
index 726fedb..57faf5b 100644
@@ -1917,7 +1917,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 
 	connected = data[1] & 0x01;
 	if (connected) {
-		int pid, battery, ps_connected, charging;
+		int pid, battery, charging;
 
 		if ((wacom->shared->type == INTUOSHT) &&
 		    wacom->shared->touch_input &&
@@ -1929,16 +1929,14 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 
 		pid = get_unaligned_be16(&data[6]);
 		battery = (data[5] & 0x3f) * 100 / 31;
-		ps_connected = !!(data[5] & 0x80);
-		charging = ps_connected && wacom->battery_capacity < 100;
+		charging = !!(data[5] & 0x80);
 		if (wacom->pid != pid) {
 			wacom->pid = pid;
 			wacom_schedule_work(wacom);
 		}
 
 		if (wacom->shared->type)
-			wacom_notify_battery(wacom, battery, charging,
-					     ps_connected);
+			wacom_notify_battery(wacom, battery, charging, 0);
 
 	} else if (wacom->pid != 0) {
 		/* disconnected while previously connected */
@@ -1969,12 +1967,10 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	if (data[9] & 0x02) { /* wireless module is attached */
 		int battery = (data[8] & 0x3f) * 100 / 31;
-		bool ps_connected = !!(data[8] & 0x80);
-		bool charging = ps_connected &&
-				wacom_wac->battery_capacity < 100;
+		bool charging = !!(data[8] & 0x80);
 
 		wacom_notify_battery(wacom_wac, battery, charging,
-				     ps_connected);
+				     1);
 
 		if (!wacom->battery.dev &&
 		    !(features->quirks & WACOM_QUIRK_BATTERY)) {
Signature · 1 line
2.3.0
#11 lore raw

PATCH 6/7 HID: wacom: Status packet provides 'charging', not 'powered' bit

In reply to Jason Gerecke

The status packet for tablets which can use a wireless module contains a bit that is set if the battery is charging. This bit will be 0 if either a battery is not present or if the battery has reached full charge. Note that the charging circuit may continue to charge the battery for a short time after reaching "100%".

---
 drivers/hid/wacom_sys.c |  2 ++
 drivers/hid/wacom_wac.c | 14 +++++---------
 2 files changed, 7 insertions(+), 9 deletions(-)
drivers/hid/wacom_sys.c +2 -0
index dfa4be7..955ce7c 100644
@@ -977,6 +977,8 @@ static int wacom_battery_get_property(struct power_supply *psy,
 			else if (wacom->wacom_wac.battery_capacity == 100 &&
 				    wacom->wacom_wac.ps_connected)
 				val->intval = POWER_SUPPLY_STATUS_FULL;
+			else if (wacom->wacom_wac.ps_connected)
+				val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
 			else
 				val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
 			break;
drivers/hid/wacom_wac.c +5 -9
index 726fedb..57faf5b 100644
@@ -1917,7 +1917,7 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 
 	connected = data[1] & 0x01;
 	if (connected) {
-		int pid, battery, ps_connected, charging;
+		int pid, battery, charging;
 
 		if ((wacom->shared->type == INTUOSHT) &&
 		    wacom->shared->touch_input &&
@@ -1929,16 +1929,14 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 
 		pid = get_unaligned_be16(&data[6]);
 		battery = (data[5] & 0x3f) * 100 / 31;
-		ps_connected = !!(data[5] & 0x80);
-		charging = ps_connected && wacom->battery_capacity < 100;
+		charging = !!(data[5] & 0x80);
 		if (wacom->pid != pid) {
 			wacom->pid = pid;
 			wacom_schedule_work(wacom);
 		}
 
 		if (wacom->shared->type)
-			wacom_notify_battery(wacom, battery, charging,
-					     ps_connected);
+			wacom_notify_battery(wacom, battery, charging, 0);
 
 	} else if (wacom->pid != 0) {
 		/* disconnected while previously connected */
@@ -1969,12 +1967,10 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 
 	if (data[9] & 0x02) { /* wireless module is attached */
 		int battery = (data[8] & 0x3f) * 100 / 31;
-		bool ps_connected = !!(data[8] & 0x80);
-		bool charging = ps_connected &&
-				wacom_wac->battery_capacity < 100;
+		bool charging = !!(data[8] & 0x80);
 
 		wacom_notify_battery(wacom_wac, battery, charging,
-				     ps_connected);
+				     1);
 
 		if (!wacom->battery.dev &&
 		    !(features->quirks & WACOM_QUIRK_BATTERY)) {
Signature · 1 line
2.3.0
#12 lore raw

PATCH 7/7 HID: wacom: Add battery presence indicator to wireless tablets

In reply to Jason Gerecke
---
 drivers/hid/wacom_sys.c |  4 ++++
 drivers/hid/wacom_wac.c | 16 ++++++++++------
 drivers/hid/wacom_wac.h |  1 +
 3 files changed, 15 insertions(+), 6 deletions(-)
drivers/hid/wacom_sys.c +4 -0
index 955ce7c..ab7bf84 100644
@@ -945,6 +945,7 @@ static void wacom_destroy_leds(struct wacom *wacom)
 }
 
 static enum power_supply_property wacom_battery_props[] = {
+	POWER_SUPPLY_PROP_PRESENT,
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_SCOPE,
 	POWER_SUPPLY_PROP_CAPACITY
@@ -964,6 +965,9 @@ static int wacom_battery_get_property(struct power_supply *psy,
 	int ret = 0;
 
 	switch (psp) {
+		case POWER_SUPPLY_PROP_PRESENT:
+			val->intval = wacom->wacom_wac.bat_connected;
+			break;
 		case POWER_SUPPLY_PROP_SCOPE:
 			val->intval = POWER_SUPPLY_SCOPE_DEVICE;
 			break;
drivers/hid/wacom_wac.c +10 -6
index 57faf5b..9262622 100644
@@ -46,16 +46,19 @@ static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
 
 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
-	int bat_capacity, bool bat_charging, bool ps_connected)
+	int bat_capacity, bool bat_charging, bool bat_connected,
+	bool ps_connected)
 {
 	struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
 	bool changed = wacom_wac->battery_capacity != bat_capacity  ||
 		       wacom_wac->bat_charging     != bat_charging  ||
+		       wacom_wac->bat_connected    != bat_connected ||
 		       wacom_wac->ps_connected     != ps_connected;
 
 	if (changed) {
 		wacom_wac->battery_capacity = bat_capacity;
 		wacom_wac->bat_charging = bat_charging;
+		wacom_wac->bat_connected = bat_connected;
 		wacom_wac->ps_connected = ps_connected;
 
 		if (wacom->battery.dev)
@@ -438,7 +441,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
 		battery_capacity = batcap_gr[rw];
 		ps_connected = rw == 7;
 		wacom_notify_battery(wacom, battery_capacity, ps_connected,
-				     ps_connected);
+				     1, ps_connected);
 	}
 exit:
 	return retval;
@@ -1029,6 +1032,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
 		ps_connected = (power_raw & 0x10) ? 1 : 0;
 		battery_capacity = batcap_i4[power_raw & 0x07];
 		wacom_notify_battery(wacom, battery_capacity, bat_charging,
+				     battery_capacity || bat_charging,
 				     ps_connected);
 		break;
 	default:
@@ -1936,13 +1940,13 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 		}
 
 		if (wacom->shared->type)
-			wacom_notify_battery(wacom, battery, charging, 0);
+			wacom_notify_battery(wacom, battery, charging, 1, 0);
 
 	} else if (wacom->pid != 0) {
 		/* disconnected while previously connected */
 		wacom->pid = 0;
 		wacom_schedule_work(wacom);
-		wacom_notify_battery(wacom, 0, 0, 0);
+		wacom_notify_battery(wacom, 0, 0, 0, 0);
 	}
 
 	return 0;
@@ -1970,7 +1974,7 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 		bool charging = !!(data[8] & 0x80);
 
 		wacom_notify_battery(wacom_wac, battery, charging,
-				     1);
+				     battery || charging, 1);
 
 		if (!wacom->battery.dev &&
 		    !(features->quirks & WACOM_QUIRK_BATTERY)) {
@@ -1984,7 +1988,7 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 		features->quirks &= ~WACOM_QUIRK_BATTERY;
 		INIT_WORK(&wacom->work, wacom_battery_work);
 		wacom_schedule_work(wacom_wac);
-		wacom_notify_battery(wacom_wac, 0, 0, 0);
+		wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
 	}
 	return 0;
 }
drivers/hid/wacom_wac.h +1 -0
index ee6a545..f3daf7b 100644
@@ -213,6 +213,7 @@ struct wacom_wac {
 	int battery_capacity;
 	int num_contacts_left;
 	int bat_charging;
+	int bat_connected;
 	int ps_connected;
 	u8 bt_features;
 	u8 bt_high_speed;
Signature · 1 line
2.3.0
#13 lore raw

PATCH 7/7 HID: wacom: Add battery presence indicator to wireless tablets

In reply to Jason Gerecke
---
 drivers/hid/wacom_sys.c |  4 ++++
 drivers/hid/wacom_wac.c | 16 ++++++++++------
 drivers/hid/wacom_wac.h |  1 +
 3 files changed, 15 insertions(+), 6 deletions(-)
drivers/hid/wacom_sys.c +4 -0
index 955ce7c..ab7bf84 100644
@@ -945,6 +945,7 @@ static void wacom_destroy_leds(struct wacom *wacom)
 }
 
 static enum power_supply_property wacom_battery_props[] = {
+	POWER_SUPPLY_PROP_PRESENT,
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_SCOPE,
 	POWER_SUPPLY_PROP_CAPACITY
@@ -964,6 +965,9 @@ static int wacom_battery_get_property(struct power_supply *psy,
 	int ret = 0;
 
 	switch (psp) {
+		case POWER_SUPPLY_PROP_PRESENT:
+			val->intval = wacom->wacom_wac.bat_connected;
+			break;
 		case POWER_SUPPLY_PROP_SCOPE:
 			val->intval = POWER_SUPPLY_SCOPE_DEVICE;
 			break;
drivers/hid/wacom_wac.c +10 -6
index 57faf5b..9262622 100644
@@ -46,16 +46,19 @@ static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
 
 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
-	int bat_capacity, bool bat_charging, bool ps_connected)
+	int bat_capacity, bool bat_charging, bool bat_connected,
+	bool ps_connected)
 {
 	struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
 	bool changed = wacom_wac->battery_capacity != bat_capacity  ||
 		       wacom_wac->bat_charging     != bat_charging  ||
+		       wacom_wac->bat_connected    != bat_connected ||
 		       wacom_wac->ps_connected     != ps_connected;
 
 	if (changed) {
 		wacom_wac->battery_capacity = bat_capacity;
 		wacom_wac->bat_charging = bat_charging;
+		wacom_wac->bat_connected = bat_connected;
 		wacom_wac->ps_connected = ps_connected;
 
 		if (wacom->battery.dev)
@@ -438,7 +441,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
 		battery_capacity = batcap_gr[rw];
 		ps_connected = rw == 7;
 		wacom_notify_battery(wacom, battery_capacity, ps_connected,
-				     ps_connected);
+				     1, ps_connected);
 	}
 exit:
 	return retval;
@@ -1029,6 +1032,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
 		ps_connected = (power_raw & 0x10) ? 1 : 0;
 		battery_capacity = batcap_i4[power_raw & 0x07];
 		wacom_notify_battery(wacom, battery_capacity, bat_charging,
+				     battery_capacity || bat_charging,
 				     ps_connected);
 		break;
 	default:
@@ -1936,13 +1940,13 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 		}
 
 		if (wacom->shared->type)
-			wacom_notify_battery(wacom, battery, charging, 0);
+			wacom_notify_battery(wacom, battery, charging, 1, 0);
 
 	} else if (wacom->pid != 0) {
 		/* disconnected while previously connected */
 		wacom->pid = 0;
 		wacom_schedule_work(wacom);
-		wacom_notify_battery(wacom, 0, 0, 0);
+		wacom_notify_battery(wacom, 0, 0, 0, 0);
 	}
 
 	return 0;
@@ -1970,7 +1974,7 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 		bool charging = !!(data[8] & 0x80);
 
 		wacom_notify_battery(wacom_wac, battery, charging,
-				     1);
+				     battery || charging, 1);
 
 		if (!wacom->battery.dev &&
 		    !(features->quirks & WACOM_QUIRK_BATTERY)) {
@@ -1984,7 +1988,7 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 		features->quirks &= ~WACOM_QUIRK_BATTERY;
 		INIT_WORK(&wacom->work, wacom_battery_work);
 		wacom_schedule_work(wacom_wac);
-		wacom_notify_battery(wacom_wac, 0, 0, 0);
+		wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
 	}
 	return 0;
 }
drivers/hid/wacom_wac.h +1 -0
index ee6a545..f3daf7b 100644
@@ -213,6 +213,7 @@ struct wacom_wac {
 	int battery_capacity;
 	int num_contacts_left;
 	int bat_charging;
+	int bat_connected;
 	int ps_connected;
 	u8 bt_features;
 	u8 bt_high_speed;
Signature · 1 line
2.3.0
#14 lore raw

Re: [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets

Quoted 1 line · Jason Gerecke

The patch looks OK, but it needs a changelog. Please add it and resubmit. Thanks.

Quoted 119 lines
---
 drivers/hid/wacom_sys.c |  4 ++++
 drivers/hid/wacom_wac.c | 16 ++++++++++------
 drivers/hid/wacom_wac.h |  1 +
 3 files changed, 15 insertions(+), 6 deletions(-)
drivers/hid/wacom_sys.c +4 -0
index 955ce7c..ab7bf84 100644
@@ -945,6 +945,7 @@ static void wacom_destroy_leds(struct wacom *wacom)
 }
 
 static enum power_supply_property wacom_battery_props[] = {
+	POWER_SUPPLY_PROP_PRESENT,
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_SCOPE,
 	POWER_SUPPLY_PROP_CAPACITY
@@ -964,6 +965,9 @@ static int wacom_battery_get_property(struct power_supply *psy,
 	int ret = 0;
 
 	switch (psp) {
+		case POWER_SUPPLY_PROP_PRESENT:
+			val->intval = wacom->wacom_wac.bat_connected;
+			break;
 		case POWER_SUPPLY_PROP_SCOPE:
 			val->intval = POWER_SUPPLY_SCOPE_DEVICE;
 			break;
drivers/hid/wacom_wac.c +10 -6
index 57faf5b..9262622 100644
@@ -46,16 +46,19 @@ static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
 
 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
-	int bat_capacity, bool bat_charging, bool ps_connected)
+	int bat_capacity, bool bat_charging, bool bat_connected,
+	bool ps_connected)
 {
 	struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
 	bool changed = wacom_wac->battery_capacity != bat_capacity  ||
 		       wacom_wac->bat_charging     != bat_charging  ||
+		       wacom_wac->bat_connected    != bat_connected ||
 		       wacom_wac->ps_connected     != ps_connected;
 
 	if (changed) {
 		wacom_wac->battery_capacity = bat_capacity;
 		wacom_wac->bat_charging = bat_charging;
+		wacom_wac->bat_connected = bat_connected;
 		wacom_wac->ps_connected = ps_connected;
 
 		if (wacom->battery.dev)
@@ -438,7 +441,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
 		battery_capacity = batcap_gr[rw];
 		ps_connected = rw == 7;
 		wacom_notify_battery(wacom, battery_capacity, ps_connected,
-				     ps_connected);
+				     1, ps_connected);
 	}
 exit:
 	return retval;
@@ -1029,6 +1032,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
 		ps_connected = (power_raw & 0x10) ? 1 : 0;
 		battery_capacity = batcap_i4[power_raw & 0x07];
 		wacom_notify_battery(wacom, battery_capacity, bat_charging,
+				     battery_capacity || bat_charging,
 				     ps_connected);
 		break;
 	default:
@@ -1936,13 +1940,13 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 		}
 
 		if (wacom->shared->type)
-			wacom_notify_battery(wacom, battery, charging, 0);
+			wacom_notify_battery(wacom, battery, charging, 1, 0);
 
 	} else if (wacom->pid != 0) {
 		/* disconnected while previously connected */
 		wacom->pid = 0;
 		wacom_schedule_work(wacom);
-		wacom_notify_battery(wacom, 0, 0, 0);
+		wacom_notify_battery(wacom, 0, 0, 0, 0);
 	}
 
 	return 0;
@@ -1970,7 +1974,7 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 		bool charging = !!(data[8] & 0x80);
 
 		wacom_notify_battery(wacom_wac, battery, charging,
-				     1);
+				     battery || charging, 1);
 
 		if (!wacom->battery.dev &&
 		    !(features->quirks & WACOM_QUIRK_BATTERY)) {
@@ -1984,7 +1988,7 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 		features->quirks &= ~WACOM_QUIRK_BATTERY;
 		INIT_WORK(&wacom->work, wacom_battery_work);
 		wacom_schedule_work(wacom_wac);
-		wacom_notify_battery(wacom_wac, 0, 0, 0);
+		wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
 	}
 	return 0;
 }
drivers/hid/wacom_wac.h +1 -0
index ee6a545..f3daf7b 100644
@@ -213,6 +213,7 @@ struct wacom_wac {
 	int battery_capacity;
 	int num_contacts_left;
 	int bat_charging;
+	int bat_connected;
 	int ps_connected;
 	u8 bt_features;
 	u8 bt_high_speed;
Signature · 1 line
2.3.0
Signature · 2 lines
Jiri Kosina
SUSE Labs
#15 lore raw

PATCH v2 7/7 HID: wacom: Add battery presence indicator to wireless tablets

In reply to Jason Gerecke

Declares the POWER_SUPPLY_PROP_PRESENT property to provide userspace with a way to determine if the battery on a wireless tablet is plugged in. Although current wireless tablets do not explicitly report this information, it can be inferred from other state information. In particular, a battery is assumed to be present if any of the following are true: a non-zero battery level reported, the battery is reported as charging, or the tablet is operating wirelessly.

Note: The last condition above may not strictly hold for the Graphire Wireless (it charges from a DC barrel jack instead of a USB port), but I do not know what is reported in the no-battery condition.

---
 drivers/hid/wacom_sys.c |  4 ++++
 drivers/hid/wacom_wac.c | 16 ++++++++++------
 drivers/hid/wacom_wac.h |  1 +
 3 files changed, 15 insertions(+), 6 deletions(-)
drivers/hid/wacom_sys.c +4 -0
index 955ce7c..ab7bf84 100644
@@ -945,6 +945,7 @@ static void wacom_destroy_leds(struct wacom *wacom)
 }
 
 static enum power_supply_property wacom_battery_props[] = {
+	POWER_SUPPLY_PROP_PRESENT,
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_SCOPE,
 	POWER_SUPPLY_PROP_CAPACITY
@@ -964,6 +965,9 @@ static int wacom_battery_get_property(struct power_supply *psy,
 	int ret = 0;
 
 	switch (psp) {
+		case POWER_SUPPLY_PROP_PRESENT:
+			val->intval = wacom->wacom_wac.bat_connected;
+			break;
 		case POWER_SUPPLY_PROP_SCOPE:
 			val->intval = POWER_SUPPLY_SCOPE_DEVICE;
 			break;
drivers/hid/wacom_wac.c +10 -6
index 57faf5b..9262622 100644
@@ -46,16 +46,19 @@ static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 100 };
 static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 };
 
 static void wacom_notify_battery(struct wacom_wac *wacom_wac,
-	int bat_capacity, bool bat_charging, bool ps_connected)
+	int bat_capacity, bool bat_charging, bool bat_connected,
+	bool ps_connected)
 {
 	struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
 	bool changed = wacom_wac->battery_capacity != bat_capacity  ||
 		       wacom_wac->bat_charging     != bat_charging  ||
+		       wacom_wac->bat_connected    != bat_connected ||
 		       wacom_wac->ps_connected     != ps_connected;
 
 	if (changed) {
 		wacom_wac->battery_capacity = bat_capacity;
 		wacom_wac->bat_charging = bat_charging;
+		wacom_wac->bat_connected = bat_connected;
 		wacom_wac->ps_connected = ps_connected;
 
 		if (wacom->battery.dev)
@@ -438,7 +441,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
 		battery_capacity = batcap_gr[rw];
 		ps_connected = rw == 7;
 		wacom_notify_battery(wacom, battery_capacity, ps_connected,
-				     ps_connected);
+				     1, ps_connected);
 	}
 exit:
 	return retval;
@@ -1029,6 +1032,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
 		ps_connected = (power_raw & 0x10) ? 1 : 0;
 		battery_capacity = batcap_i4[power_raw & 0x07];
 		wacom_notify_battery(wacom, battery_capacity, bat_charging,
+				     battery_capacity || bat_charging,
 				     ps_connected);
 		break;
 	default:
@@ -1936,13 +1940,13 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
 		}
 
 		if (wacom->shared->type)
-			wacom_notify_battery(wacom, battery, charging, 0);
+			wacom_notify_battery(wacom, battery, charging, 1, 0);
 
 	} else if (wacom->pid != 0) {
 		/* disconnected while previously connected */
 		wacom->pid = 0;
 		wacom_schedule_work(wacom);
-		wacom_notify_battery(wacom, 0, 0, 0);
+		wacom_notify_battery(wacom, 0, 0, 0, 0);
 	}
 
 	return 0;
@@ -1970,7 +1974,7 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 		bool charging = !!(data[8] & 0x80);
 
 		wacom_notify_battery(wacom_wac, battery, charging,
-				     1);
+				     battery || charging, 1);
 
 		if (!wacom->battery.dev &&
 		    !(features->quirks & WACOM_QUIRK_BATTERY)) {
@@ -1984,7 +1988,7 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
 		features->quirks &= ~WACOM_QUIRK_BATTERY;
 		INIT_WORK(&wacom->work, wacom_battery_work);
 		wacom_schedule_work(wacom_wac);
-		wacom_notify_battery(wacom_wac, 0, 0, 0);
+		wacom_notify_battery(wacom_wac, 0, 0, 0, 0);
 	}
 	return 0;
 }
drivers/hid/wacom_wac.h +1 -0
index ee6a545..f3daf7b 100644
@@ -213,6 +213,7 @@ struct wacom_wac {
 	int battery_capacity;
 	int num_contacts_left;
 	int bat_charging;
+	int bat_connected;
 	int ps_connected;
 	u8 bt_features;
 	u8 bt_high_speed;
Signature · 1 line
2.3.2
Applied
#16 lore raw

Re: [PATCH v2 7/7] HID: wacom: Add battery presence indicator to wireless tablets

Quoted 8 lines · Jason Gerecke

Declares the POWER_SUPPLY_PROP_PRESENT property to provide userspace with a way to determine if the battery on a wireless tablet is plugged in. Although current wireless tablets do not explicitly report this information, it can be inferred from other state information. In particular, a battery is assumed to be present if any of the following are true: a non-zero battery level reported, the battery is reported as charging, or the tablet is operating wirelessly.

Quoted 5 lines

Note: The last condition above may not strictly hold for the Graphire Wireless (it charges from a DC barrel jack instead of a USB port), but I do not know what is reported in the no-battery condition.

Applied to for-4.1/wacom.

Signature · 2 lines
Jiri Kosina
SUSE Labs
Acked-by on v1 1/7
#17 lore raw
In reply to Jason Gerecke
Quoted 80 lines · Jason Gerecke

In addition to the touchswitch state for "Intuos", these packets are also sent by the Intuos Pro, Intuos5, and last-generation Bamboo tablets when using a wired connection. They contain, among other things, information about the optional wireless module and battery charge state (to be supported in subsuquent patches).

---
 drivers/hid/wacom_wac.c | 36 +++++++++++++++++++++++-------------
 drivers/hid/wacom_wac.h |  1 +
 2 files changed, 24 insertions(+), 13 deletions(-)
drivers/hid/wacom_wac.c +23 -13
index bbf72f9..cb308c5 100644
@@ -1740,20 +1740,9 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
        unsigned char *data = wacom->data;
        int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
 
-       if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
+       if (data[0] != WACOM_REPORT_PENABLED)
            return 0;
 
-       if (data[0] == WACOM_REPORT_USB) {
-               if (features->type == INTUOSHT &&
-                   wacom->shared->touch_input &&
-                   features->touch_max) {
-                       input_report_switch(wacom->shared->touch_input,
-                                           SW_MUTE_DEVICE, data[8] & 0x40);
-                       input_sync(wacom->shared->touch_input);
-               }
-               return 0;
-       }
-
        prox = (data[1] & 0x20) == 0x20;
 
        /*
@@ -1960,6 +1949,24 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
        return 0;
 }
 
+static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
+{
+       struct wacom_features *features = &wacom_wac->features;
+       unsigned char *data = wacom_wac->data;
+
+       if (data[0] != WACOM_REPORT_USB)
+               return 0;
+
+       if (features->type == INTUOSHT &&
+           wacom_wac->shared->touch_input &&
+           features->touch_max) {
+               input_report_switch(wacom_wac->shared->touch_input,
+                                   SW_MUTE_DEVICE, data[8] & 0x40);
+               input_sync(wacom_wac->shared->touch_input);
+       }
+       return 0;
+}
+
 void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 {
        bool sync;
@@ -2044,7 +2051,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 
        case BAMBOO_PT:
        case INTUOSHT:
-               sync = wacom_bpt_irq(wacom_wac, len);
+               if (wacom_wac->data[0] == WACOM_REPORT_USB)
+                       sync = wacom_status_irq(wacom_wac, len);
+               else
+                       sync = wacom_bpt_irq(wacom_wac, len);
                break;
 
        case BAMBOO_PAD:
drivers/hid/wacom_wac.h +0 -0
index a3d0828..ee6a545 100644

drivers/hid/wacom_wac.h line 74

Quoted 4 lines
drivers/hid/wacom_wac.h +1 -0
@@ -71,6 +71,7 @@
 #define WACOM_REPORT_USB               192
 #define WACOM_REPORT_BPAD_PEN          3
 #define WACOM_REPORT_BPAD_TOUCH                16
+#define WACOM_PKGLEN_STATUS            10

I don't see anywhere else WACOM_PKGLEN_STATUS is used. Do I miss something?

Except that, the patchset looks good.

Ping

Quoted 5 lines
drivers/hid/wacom_wac.h +0 -1
 /* device quirks */
 #define WACOM_QUIRK_MULTI_INPUT                0x0001
--

2.3.0

#18 lore raw
Quoted 75 lines · Ping Cheng
Quoted 74 lines · Jason Gerecke

In addition to the touchswitch state for "Intuos", these packets are also sent by the Intuos Pro, Intuos5, and last-generation Bamboo tablets when using a wired connection. They contain, among other things, information about the optional wireless module and battery charge state (to be supported in subsuquent patches).

---
  drivers/hid/wacom_wac.c | 36 +++++++++++++++++++++++-------------
  drivers/hid/wacom_wac.h |  1 +
  2 files changed, 24 insertions(+), 13 deletions(-)
drivers/hid/wacom_wac.c +23 -13
index bbf72f9..cb308c5 100644
@@ -1740,20 +1740,9 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
         unsigned char *data = wacom->data;
         int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
 
-       if (data[0] != WACOM_REPORT_PENABLED && data[0] != WACOM_REPORT_USB)
+       if (data[0] != WACOM_REPORT_PENABLED)
             return 0;
 
-       if (data[0] == WACOM_REPORT_USB) {
-               if (features->type == INTUOSHT &&
-                   wacom->shared->touch_input &&
-                   features->touch_max) {
-                       input_report_switch(wacom->shared->touch_input,
-                                           SW_MUTE_DEVICE, data[8] & 0x40);
-                       input_sync(wacom->shared->touch_input);
-               }
-               return 0;
-       }
-
         prox = (data[1] & 0x20) == 0x20;
 
         /*
@@ -1960,6 +1949,24 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
         return 0;
  }
 
+static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
+{
+       struct wacom_features *features = &wacom_wac->features;
+       unsigned char *data = wacom_wac->data;
+
+       if (data[0] != WACOM_REPORT_USB)
+               return 0;
+
+       if (features->type == INTUOSHT &&
+           wacom_wac->shared->touch_input &&
+           features->touch_max) {
+               input_report_switch(wacom_wac->shared->touch_input,
+                                   SW_MUTE_DEVICE, data[8] & 0x40);
+               input_sync(wacom_wac->shared->touch_input);
+       }
+       return 0;
+}
+
  void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
  {
         bool sync;
@@ -2044,7 +2051,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
 
         case BAMBOO_PT:
         case INTUOSHT:
-               sync = wacom_bpt_irq(wacom_wac, len);
+               if (wacom_wac->data[0] == WACOM_REPORT_USB)
+                       sync = wacom_status_irq(wacom_wac, len);
+               else
+                       sync = wacom_bpt_irq(wacom_wac, len);
                 break;
 
Quoted 13 lines

drivers/hid/wacom_wac.h line 74

Quoted 10 lines
drivers/hid/wacom_wac.c +0 -0
         case BAMBOO_PAD:
drivers/hid/wacom_wac.h +1 -0
index a3d0828..ee6a545 100644
@@ -71,6 +71,7 @@
  #define WACOM_REPORT_USB               192
  #define WACOM_REPORT_BPAD_PEN          3
  #define WACOM_REPORT_BPAD_TOUCH                16
+#define WACOM_PKGLEN_STATUS            10

I don't see anywhere else WACOM_PKGLEN_STATUS is used. Do I miss something?

Good catch. That's leftover cruft from an earlier revision which is not necessary anymore. I'll resubmit this patch with the hunk removed.

Quoted 6 lines

Except that, the patchset looks good.

Ping

Speaking of small mistakes... s/pinbgc/pingc/ :)

Signature · 7 lines
Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....
Quoted 5 lines
Quoted 5 lines
drivers/hid/wacom_wac.h +0 -1
  /* device quirks */
  #define WACOM_QUIRK_MULTI_INPUT                0x0001
--

2.3.0

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#19 lore raw
Quoted 12 lines · Jason Gerecke
Quoted 12 lines

drivers/hid/wacom_wac.h line 74

Quoted 9 lines
drivers/hid/wacom_wac.h +1 -0
index a3d0828..ee6a545 100644
@@ -71,6 +71,7 @@
  #define WACOM_REPORT_USB               192
  #define WACOM_REPORT_BPAD_PEN          3
  #define WACOM_REPORT_BPAD_TOUCH                16
+#define WACOM_PKGLEN_STATUS            10

I don't see anywhere else WACOM_PKGLEN_STATUS is used. Do I miss something?

Quoted 2 lines

Good catch. That's leftover cruft from an earlier revision which is not necessary anymore. I'll resubmit this patch with the hunk removed.

No need to resubmit, I'll take care of it in the tree, thanks.

I have now applied 1-6, I'll send a small comment to no.7 and ask for respin of that one.

Signature · 2 lines
Jiri Kosina
SUSE Labs