On Sun, Mar 18, 2012 at 11:24 AM, Przemo Firszt <prz...@firszt.eu> wrote: > This patch adds battery/ac reporting for Intuos4 WL. It uses existing > sysfs code, but the device reports battery capacity in more fine-grained way, > so there has to be a separate lookup table (called batcap_i4). > > Signed-off-by: Przemo Firszt <prz...@firszt.eu> > --- > drivers/hid/hid-wacom.c | 12 ++++++++++++ > 1 files changed, 12 insertions(+), 0 deletions(-) > > diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c > index 516b468..708b909 100644 > --- a/drivers/hid/hid-wacom.c > +++ b/drivers/hid/hid-wacom.c > @@ -53,6 +53,8 @@ struct wacom_data { > #ifdef CONFIG_HID_WACOM_POWER_SUPPLY > /*percent of battery capacity for Graphire, 0 means AC online*/ > static unsigned short batcap_gr[8] = { 1, 15, 25, 35, 50, 70, 100, 0 }; > +/*percent of battery capacity for Intuos4 WL, AC has a separate bit*/ > +static unsigned short batcap_i4[8] = { 1, 15, 30, 45, 60, 70, 85, 100 }; > > static enum power_supply_property wacom_battery_props[] = { > POWER_SUPPLY_PROP_PRESENT, > @@ -457,6 +459,8 @@ static int wacom_raw_event(struct hid_device *hdev, > struct hid_report *report, > struct input_dev *input; > unsigned char *data = (unsigned char *) raw_data; > int i; > + __u8 battery; > + __u8 ps_connected; > > if (!(hdev->claimed & HID_CLAIMED_INPUT)) > return 0; > @@ -484,6 +488,14 @@ static int wacom_raw_event(struct hid_device *hdev, > struct hid_report *report, > wacom_i4_parse_report(hdev, wdata, input, data + i); > i += 10; > wacom_i4_parse_report(hdev, wdata, input, data + i); > + battery = data[i+10] & 0x07; > + if (batcap_i4[battery] != wdata->battery_capacity) > + wdata->battery_capacity = batcap_i4[battery];
Its less work to set update each time; even to same value; then it is to conditionally do it. Hopefully, you consider moving to formula outside IRQ... but do you want !ps_connected to show 100% like Graphire is doing? I assume you not doing it is a feature since "status" is something you could one day support and the difference between charging/full/discharging is if battery level is 100% or not + ps_connected. Forcing to 100% would hide that info. Chris > + > + ps_connected = data[i+10] & 0x08; > + if (ps_connected != wdata->ps_connected) > + wdata->ps_connected = ps_connected; Same here. > + > break; > default: > hid_err(hdev, "Unknown report: %d,%d size:%d\n", > -- > 1.7.6.4 > > > ------------------------------------------------------------------------------ > This SF email is sponsosred by: > Try Windows Azure free for 90 days Click Here > http://p.sf.net/sfu/sfd2d-msazure > _______________________________________________ > Linuxwacom-devel mailing list > Linuxwacom-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel ------------------------------------------------------------------------------ This SF email is sponsosred by: Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel