Dnia 2012-03-18, nie o godzinie 13:38 -0500, Chris Bagwell pisze: > 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. Hi Chris, It is conditional. One line after "if" doesnt' require {brackets} http://www.cprogramming.com/tutorial/c/lesson2.html
> Hopefully, you consider moving to formula outside IRQ... I don't want to do that - see my first email. It would add checking the device type in "sysfs section" instead of plain "report whatever is in wdata->battery_capacity/ps_connected". > but do you > want !ps_connected to show 100% like Graphire is doing? No, Intuos4 WL seems to report proper battery value even when charging. I'll confirm that as soon as I find a standalone charger (USB connection switches the device to usb driver :-) ) > 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. Thanks for that - I'll check how to report it and I'll add it. -- Regards, Przemo Firszt ------------------------------------------------------------------------------ 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