* [PATCH 2/7] HID: wacom: Centralize updating of wacom_wac battery status
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 3/7] HID: wacom: Allow dynamic battery creation/destruction Jason Gerecke
` (12 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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.
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom.h | 7 ------
drivers/hid/wacom_wac.c | 57 +++++++++++++++++++++++++------------------------
2 files changed, 29 insertions(+), 35 deletions(-)
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index 7db4328..b8344b1 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -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);
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index cb308c5..5d57fec 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -45,6 +45,24 @@ 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)
+{
+ 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->ps_connected != ps_connected;
+
+ if (changed) {
+ wacom_wac->battery_capacity = bat_capacity;
+ wacom_wac->bat_charging = bat_charging;
+ wacom_wac->ps_connected = ps_connected;
+
+ if (wacom->battery.dev)
+ power_supply_changed(&wacom->battery);
+ }
+}
+
static int wacom_penpartner_irq(struct wacom_wac *wacom)
{
unsigned char *data = wacom->data;
@@ -419,12 +437,8 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
rw = (data[7] >> 2 & 0x07);
battery_capacity = batcap_gr[rw];
ps_connected = rw == 7;
- if ((wacom->battery_capacity != battery_capacity) ||
- (wacom->ps_connected != ps_connected)) {
- wacom->battery_capacity = battery_capacity;
- wacom->ps_connected = ps_connected;
- wacom_notify_battery(wacom);
- }
+ wacom_notify_battery(wacom, battery_capacity, ps_connected,
+ ps_connected);
}
exit:
return retval;
@@ -1014,15 +1028,8 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
bat_charging = (power_raw & 0x08) ? 1 : 0;
ps_connected = (power_raw & 0x10) ? 1 : 0;
battery_capacity = batcap_i4[power_raw & 0x07];
- if ((wacom->battery_capacity != battery_capacity) ||
- (wacom->bat_charging != bat_charging) ||
- (wacom->ps_connected != ps_connected)) {
- wacom->battery_capacity = battery_capacity;
- wacom->bat_charging = bat_charging;
- wacom->ps_connected = ps_connected;
- wacom_notify_battery(wacom);
- }
-
+ wacom_notify_battery(wacom, battery_capacity, bat_charging,
+ ps_connected);
break;
default:
dev_dbg(wacom->input->dev.parent,
@@ -1910,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;
+ int pid, battery, ps_connected, charging;
if ((wacom->shared->type == INTUOSHT) &&
wacom->shared->touch_input &&
@@ -1923,27 +1930,21 @@ 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;
if (wacom->pid != pid) {
wacom->pid = pid;
wacom_schedule_work(wacom);
}
- if (wacom->shared->type &&
- (battery != wacom->battery_capacity ||
- ps_connected != wacom->ps_connected)) {
- wacom->battery_capacity = battery;
- wacom->ps_connected = ps_connected;
- wacom->bat_charging = ps_connected &&
- wacom->battery_capacity < 100;
- wacom_notify_battery(wacom);
- }
+ if (wacom->shared->type)
+ wacom_notify_battery(wacom, battery, charging,
+ ps_connected);
+
} else if (wacom->pid != 0) {
/* disconnected while previously connected */
wacom->pid = 0;
wacom_schedule_work(wacom);
- wacom->battery_capacity = 0;
- wacom->bat_charging = 0;
- wacom->ps_connected = 0;
+ wacom_notify_battery(wacom, 0, 0, 0);
}
return 0;
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/7] HID: wacom: Allow dynamic battery creation/destruction
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
2015-03-06 19:47 ` [PATCH 2/7] HID: wacom: Centralize updating of wacom_wac battery status Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 4/7] HID: wacom: Provide battery charge state to system over USB if available Jason Gerecke
` (11 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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.
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom.h | 1 +
drivers/hid/wacom_sys.c | 17 +++++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index b8344b1..ad7318d 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -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
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 957699f..dfa4be7 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 4/7] HID: wacom: Provide battery charge state to system over USB if available
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
2015-03-06 19:47 ` [PATCH 2/7] HID: wacom: Centralize updating of wacom_wac battery status Jason Gerecke
2015-03-06 19:47 ` [PATCH 3/7] HID: wacom: Allow dynamic battery creation/destruction Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 5/7] HID: wacom: Report battery status for Intuos Pro and Intuos5 Jason Gerecke
` (10 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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.
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom_wac.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 5d57fec..f1e53f1 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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;
}
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 5/7] HID: wacom: Report battery status for Intuos Pro and Intuos5
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (2 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 4/7] HID: wacom: Provide battery charge state to system over USB if available Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 6/7] HID: wacom: Status packet provides 'charging', not 'powered' bit Jason Gerecke
` (9 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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).
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom_wac.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index f1e53f1..726fedb 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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;
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 6/7] HID: wacom: Status packet provides 'charging', not 'powered' bit
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (3 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 5/7] HID: wacom: Report battery status for Intuos Pro and Intuos5 Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets Jason Gerecke
` (8 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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%".
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom_sys.c | 2 ++
drivers/hid/wacom_wac.c | 14 +++++---------
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index dfa4be7..955ce7c 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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;
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 726fedb..57faf5b 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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)) {
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (4 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 6/7] HID: wacom: Status packet provides 'charging', not 'powered' bit Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (7 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, Jason Gerecke
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
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(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 955ce7c..ab7bf84 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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;
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 57faf5b..9262622 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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;
}
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index ee6a545..f3daf7b 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -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;
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (5 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 2/7] HID: wacom: Centralize updating of wacom_wac battery status Jason Gerecke
` (6 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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).
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom_wac.c | 36 +++++++++++++++++++++++-------------
drivers/hid/wacom_wac.h | 1 +
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index bbf72f9..cb308c5 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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:
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index a3d0828..ee6a545 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -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
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/7] HID: wacom: Centralize updating of wacom_wac battery status
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (6 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 3/7] HID: wacom: Allow dynamic battery creation/destruction Jason Gerecke
` (5 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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.
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom.h | 7 ------
drivers/hid/wacom_wac.c | 57 +++++++++++++++++++++++++------------------------
2 files changed, 29 insertions(+), 35 deletions(-)
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index 7db4328..b8344b1 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -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);
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index cb308c5..5d57fec 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -45,6 +45,24 @@ 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)
+{
+ 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->ps_connected != ps_connected;
+
+ if (changed) {
+ wacom_wac->battery_capacity = bat_capacity;
+ wacom_wac->bat_charging = bat_charging;
+ wacom_wac->ps_connected = ps_connected;
+
+ if (wacom->battery.dev)
+ power_supply_changed(&wacom->battery);
+ }
+}
+
static int wacom_penpartner_irq(struct wacom_wac *wacom)
{
unsigned char *data = wacom->data;
@@ -419,12 +437,8 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
rw = (data[7] >> 2 & 0x07);
battery_capacity = batcap_gr[rw];
ps_connected = rw == 7;
- if ((wacom->battery_capacity != battery_capacity) ||
- (wacom->ps_connected != ps_connected)) {
- wacom->battery_capacity = battery_capacity;
- wacom->ps_connected = ps_connected;
- wacom_notify_battery(wacom);
- }
+ wacom_notify_battery(wacom, battery_capacity, ps_connected,
+ ps_connected);
}
exit:
return retval;
@@ -1014,15 +1028,8 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
bat_charging = (power_raw & 0x08) ? 1 : 0;
ps_connected = (power_raw & 0x10) ? 1 : 0;
battery_capacity = batcap_i4[power_raw & 0x07];
- if ((wacom->battery_capacity != battery_capacity) ||
- (wacom->bat_charging != bat_charging) ||
- (wacom->ps_connected != ps_connected)) {
- wacom->battery_capacity = battery_capacity;
- wacom->bat_charging = bat_charging;
- wacom->ps_connected = ps_connected;
- wacom_notify_battery(wacom);
- }
-
+ wacom_notify_battery(wacom, battery_capacity, bat_charging,
+ ps_connected);
break;
default:
dev_dbg(wacom->input->dev.parent,
@@ -1910,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;
+ int pid, battery, ps_connected, charging;
if ((wacom->shared->type == INTUOSHT) &&
wacom->shared->touch_input &&
@@ -1923,27 +1930,21 @@ 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;
if (wacom->pid != pid) {
wacom->pid = pid;
wacom_schedule_work(wacom);
}
- if (wacom->shared->type &&
- (battery != wacom->battery_capacity ||
- ps_connected != wacom->ps_connected)) {
- wacom->battery_capacity = battery;
- wacom->ps_connected = ps_connected;
- wacom->bat_charging = ps_connected &&
- wacom->battery_capacity < 100;
- wacom_notify_battery(wacom);
- }
+ if (wacom->shared->type)
+ wacom_notify_battery(wacom, battery, charging,
+ ps_connected);
+
} else if (wacom->pid != 0) {
/* disconnected while previously connected */
wacom->pid = 0;
wacom_schedule_work(wacom);
- wacom->battery_capacity = 0;
- wacom->bat_charging = 0;
- wacom->ps_connected = 0;
+ wacom_notify_battery(wacom, 0, 0, 0);
}
return 0;
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/7] HID: wacom: Allow dynamic battery creation/destruction
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (7 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 2/7] HID: wacom: Centralize updating of wacom_wac battery status Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 4/7] HID: wacom: Provide battery charge state to system over USB if available Jason Gerecke
` (4 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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.
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom.h | 1 +
drivers/hid/wacom_sys.c | 17 +++++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/wacom.h b/drivers/hid/wacom.h
index b8344b1..ad7318d 100644
--- a/drivers/hid/wacom.h
+++ b/drivers/hid/wacom.h
@@ -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
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 957699f..dfa4be7 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 4/7] HID: wacom: Provide battery charge state to system over USB if available
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (8 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 3/7] HID: wacom: Allow dynamic battery creation/destruction Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 5/7] HID: wacom: Report battery status for Intuos Pro and Intuos5 Jason Gerecke
` (3 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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.
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom_wac.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 5d57fec..f1e53f1 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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;
}
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 5/7] HID: wacom: Report battery status for Intuos Pro and Intuos5
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (9 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 4/7] HID: wacom: Provide battery charge state to system over USB if available Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 6/7] HID: wacom: Status packet provides 'charging', not 'powered' bit Jason Gerecke
` (2 subsequent siblings)
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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).
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom_wac.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index f1e53f1..726fedb 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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;
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 6/7] HID: wacom: Status packet provides 'charging', not 'powered' bit
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (10 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 5/7] HID: wacom: Report battery status for Intuos Pro and Intuos5 Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-06 19:47 ` [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets Jason Gerecke
2015-03-10 1:31 ` [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Ping Cheng
13 siblings, 0 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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%".
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
drivers/hid/wacom_sys.c | 2 ++
drivers/hid/wacom_wac.c | 14 +++++---------
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index dfa4be7..955ce7c 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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;
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 726fedb..57faf5b 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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)) {
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (11 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 6/7] HID: wacom: Status packet provides 'charging', not 'powered' bit Jason Gerecke
@ 2015-03-06 19:47 ` Jason Gerecke
2015-03-11 15:50 ` Jiri Kosina
2015-03-11 17:25 ` [PATCH v2 " Jason Gerecke
2015-03-10 1:31 ` [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Ping Cheng
13 siblings, 2 replies; 20+ messages in thread
From: Jason Gerecke @ 2015-03-06 19:47 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, Jason Gerecke
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
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(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 955ce7c..ab7bf84 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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;
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 57faf5b..9262622 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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;
}
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index ee6a545..f3daf7b 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -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;
--
2.3.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets
2015-03-06 19:47 ` [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets Jason Gerecke
@ 2015-03-11 15:50 ` Jiri Kosina
2015-03-11 17:25 ` [PATCH v2 " Jason Gerecke
1 sibling, 0 replies; 20+ messages in thread
From: Jiri Kosina @ 2015-03-11 15:50 UTC (permalink / raw)
To: Jason Gerecke; +Cc: linux-input, pinglinux, benjamin.tissoires
On Fri, 6 Mar 2015, Jason Gerecke wrote:
> Signed-off-by: Jason Gerecke <killertofu@gmail.com>
The patch looks OK, but it needs a changelog. Please add it and resubmit.
Thanks.
> ---
> 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(-)
>
> diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
> index 955ce7c..ab7bf84 100644
> --- a/drivers/hid/wacom_sys.c
> +++ b/drivers/hid/wacom_sys.c
> @@ -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;
> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index 57faf5b..9262622 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -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;
> }
> diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
> index ee6a545..f3daf7b 100644
> --- a/drivers/hid/wacom_wac.h
> +++ b/drivers/hid/wacom_wac.h
> @@ -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;
> --
> 2.3.0
>
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH v2 7/7] HID: wacom: Add battery presence indicator to wireless tablets
2015-03-06 19:47 ` [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets Jason Gerecke
2015-03-11 15:50 ` Jiri Kosina
@ 2015-03-11 17:25 ` Jason Gerecke
2015-03-11 17:53 ` Jiri Kosina
1 sibling, 1 reply; 20+ messages in thread
From: Jason Gerecke @ 2015-03-11 17:25 UTC (permalink / raw)
To: jkosina, linux-input; +Cc: pinglinux, benjamin.tissoires, 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.
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
---
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(-)
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index 955ce7c..ab7bf84 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -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;
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index 57faf5b..9262622 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -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;
}
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index ee6a545..f3daf7b 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -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;
--
2.3.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH v2 7/7] HID: wacom: Add battery presence indicator to wireless tablets
2015-03-11 17:25 ` [PATCH v2 " Jason Gerecke
@ 2015-03-11 17:53 ` Jiri Kosina
0 siblings, 0 replies; 20+ messages in thread
From: Jiri Kosina @ 2015-03-11 17:53 UTC (permalink / raw)
To: Jason Gerecke; +Cc: linux-input, pinglinux, benjamin.tissoires
On Wed, 11 Mar 2015, Jason Gerecke wrote:
> 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.
>
> Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Applied to for-4.1/wacom.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function
2015-03-06 19:47 [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Jason Gerecke
` (12 preceding siblings ...)
2015-03-06 19:47 ` [PATCH 7/7] HID: wacom: Add battery presence indicator to wireless tablets Jason Gerecke
@ 2015-03-10 1:31 ` Ping Cheng
2015-03-10 16:22 ` Jason Gerecke
13 siblings, 1 reply; 20+ messages in thread
From: Ping Cheng @ 2015-03-10 1:31 UTC (permalink / raw)
To: Jason Gerecke; +Cc: Jiri Kosina, linux-input, Benjamin Tissoires
On Fri, Mar 6, 2015 at 11:47 AM, Jason Gerecke <killertofu@gmail.com> wrote:
> 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).
>
> Signed-off-by: Jason Gerecke <killertofu@gmail.com>
> ---
> drivers/hid/wacom_wac.c | 36 +++++++++++++++++++++++-------------
> drivers/hid/wacom_wac.h | 1 +
> 2 files changed, 24 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
> index bbf72f9..cb308c5 100644
> --- a/drivers/hid/wacom_wac.c
> +++ b/drivers/hid/wacom_wac.c
> @@ -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:
> diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
> index a3d0828..ee6a545 100644
> --- a/drivers/hid/wacom_wac.h
> +++ b/drivers/hid/wacom_wac.h
> @@ -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.
Acked-by: Ping Cheng <pinbgc@wacom.com>
Ping
> /* device quirks */
> #define WACOM_QUIRK_MULTI_INPUT 0x0001
> --
> 2.3.0
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function
2015-03-10 1:31 ` [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function Ping Cheng
@ 2015-03-10 16:22 ` Jason Gerecke
2015-03-11 15:49 ` Jiri Kosina
0 siblings, 1 reply; 20+ messages in thread
From: Jason Gerecke @ 2015-03-10 16:22 UTC (permalink / raw)
To: Ping Cheng; +Cc: Jiri Kosina, linux-input, Benjamin Tissoires
On 3/9/2015 6:31 PM, Ping Cheng wrote:
> On Fri, Mar 6, 2015 at 11:47 AM, Jason Gerecke <killertofu@gmail.com> wrote:
>> 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).
>>
>> Signed-off-by: Jason Gerecke <killertofu@gmail.com>
>> ---
>> drivers/hid/wacom_wac.c | 36 +++++++++++++++++++++++-------------
>> drivers/hid/wacom_wac.h | 1 +
>> 2 files changed, 24 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
>> index bbf72f9..cb308c5 100644
>> --- a/drivers/hid/wacom_wac.c
>> +++ b/drivers/hid/wacom_wac.c
>> @@ -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:
>> diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
>> index a3d0828..ee6a545 100644
>> --- a/drivers/hid/wacom_wac.h
>> +++ b/drivers/hid/wacom_wac.h
>> @@ -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.
> Except that, the patchset looks good.
>
> Acked-by: Ping Cheng <pinbgc@wacom.com>
>
> Ping
>
Speaking of small mistakes... s/pinbgc/pingc/ :)
--
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....
>> /* 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/7] HID: wacom: Move handling of Intuos status packets to seperate function
2015-03-10 16:22 ` Jason Gerecke
@ 2015-03-11 15:49 ` Jiri Kosina
0 siblings, 0 replies; 20+ messages in thread
From: Jiri Kosina @ 2015-03-11 15:49 UTC (permalink / raw)
To: Jason Gerecke; +Cc: Ping Cheng, linux-input, Benjamin Tissoires
On Tue, 10 Mar 2015, Jason Gerecke wrote:
> > > diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
> > > index a3d0828..ee6a545 100644
> > > --- a/drivers/hid/wacom_wac.h
> > > +++ b/drivers/hid/wacom_wac.h
> > > @@ -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.
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.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 20+ messages in thread