Return-Path: MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 29 Jan 2010 09:14:59 -0800 Message-ID: <167e8a331001290914t578ffef7y16d52e40c8c54079@mail.gmail.com> Subject: Re: [PATCH 2/3] HID: Implement Wacom quirk in the kernel From: Ping Cheng To: Jiri Kosina Cc: "Gunn, Brian" , Marcel Holtmann , linux-kernel@vger.kernel.org, BlueZ development Content-Type: multipart/alternative; boundary=001636ed67247e9948047e50c6cb List-ID: --001636ed67247e9948047e50c6cb Content-Type: text/plain; charset=ISO-8859-1 On Fri, Jan 29, 2010 at 6:20 AM, Jiri Kosina wrote: > From: Bastien Nocera > > The hid-wacom driver required user-space to poke at the tablet > to make it send data about the cursor location. > > This patch makes it do the same thing but in the kernel. > > Signed-off-by: Bastien Nocera > Signed-off-by: Jiri Kosina > --- > drivers/hid/hid-wacom.c | 27 +++++++++++++++++++++++++++ > 1 files changed, 27 insertions(+), 0 deletions(-) > > diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c > index 12dcda5..d7897b5 100644 > --- a/drivers/hid/hid-wacom.c > +++ b/drivers/hid/hid-wacom.c > @@ -156,7 +156,9 @@ static int wacom_probe(struct hid_device *hdev, > struct hid_input *hidinput; > struct input_dev *input; > struct wacom_data *wdata; > + char rep_data[2]; > int ret; > + int limit; > > wdata = kzalloc(sizeof(*wdata), GFP_KERNEL); > if (wdata == NULL) { > @@ -166,6 +168,7 @@ static int wacom_probe(struct hid_device *hdev, > > hid_set_drvdata(hdev, wdata); > > + /* Parse the HID report now */ > ret = hid_parse(hdev); > if (ret) { > dev_err(&hdev->dev, "parse failed\n"); > @@ -178,6 +181,30 @@ static int wacom_probe(struct hid_device *hdev, > goto err_free; > } > > + /* Set Wacom mode2 */ > + rep_data[0] = 0x03; rep_data[1] = 0x00; > + limit =3; > + do { > + ret = hdev->hid_output_raw_report(hdev, rep_data, 2, > + HID_FEATURE_REPORT); > + } while (ret < 0 && limit-- > 0); > hdev->hid_output_raw_report error is not a hard failure, i.e., the following four lines are unnecessay. We can continue with the rest of the code. > + if (ret < 0) { > + dev_err(&hdev->dev, "failed to poke device #1, %d\n", ret); > + goto err_free; > + } > + > + /* 0x06 - high reporting speed, 0x05 - low speed */ > + rep_data[0] = 0x06; rep_data[1] = 0x00; > + limit = 3; > + do { > + ret = hdev->hid_output_raw_report(hdev, rep_data, 2, > + HID_FEATURE_REPORT); > + } while (ret < 0 && limit-- > 0); > Same comments apply here. "/* Note that if query fails it is not a hard failure */" is the comments we use in the corresponding Wacom USB driver, wacom_sys.c > + if (ret < 0) { > + dev_err(&hdev->dev, "failed to poke device #2, %d\n", ret); > + goto err_free; > + } > + > hidinput = list_entry(hdev->inputs.next, struct hid_input, list); > input = hidinput->input; Everything else looks good to me. Ping --001636ed67247e9948047e50c6cb Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Fri, Jan 29, 2010 at 6:20 AM, Jiri Kosina <jkosina@suse.cz&g= t; wrote:
From: Bastien Nocera <hadess@hadess.net>

The hid-waco= m driver required user-space to poke at the tablet
to make it send data about the cursor location.

This patch makes it = do the same thing but in the kernel.

Signed-off-by: Bastien Nocera &= lt;hadess@hadess.net>
Signed= -off-by: Jiri Kosina <jkosina@suse.cz= >
---
=A0drivers/hid/hid-wacom.c | =A0 27 +++++++++++++++++++++++++++
= =A01 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/dr= ivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index 12dcda5..d7897b5 1= 00644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -156,7= +156,9 @@ static int wacom_probe(struct hid_device *hdev,
=A0 =A0 =A0 = =A0struct hid_input *hidinput;
=A0 =A0 =A0 =A0struct input_dev *input;=A0 =A0 =A0 =A0struct wacom_data *wdata;
+ =A0 =A0 =A0 char rep_data[2];
=A0 =A0 =A0 =A0int ret;
+ =A0 =A0 =A0= int limit;

=A0 =A0 =A0 =A0wdata =3D kzalloc(sizeof(*wdata), GFP_KER= NEL);
=A0 =A0 =A0 =A0if (wdata =3D=3D NULL) {
@@ -166,6 +168,7 @@ sta= tic int wacom_probe(struct hid_device *hdev,

=A0 =A0 =A0 =A0hid_set_drvdata(hdev, wdata);

+ =A0 =A0 =A0 /* Pa= rse the HID report now */
=A0 =A0 =A0 =A0ret =3D hid_parse(hdev);
=A0= =A0 =A0 =A0if (ret) {
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0dev_err(&hdev-= >dev, "parse failed\n");
@@ -178,6 +181,30 @@ static int wa= com_probe(struct hid_device *hdev,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto err_free;
=A0 =A0 =A0 =A0}

+ = =A0 =A0 =A0 /* Set Wacom mode2 */
+ =A0 =A0 =A0 rep_data[0] =3D 0x03; re= p_data[1] =3D 0x00;
+ =A0 =A0 =A0 limit =3D3;
+ =A0 =A0 =A0 do {
+= =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D hdev->hid_output_raw_report(hdev, r= ep_data, 2,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 HID_FEATURE_R= EPORT);
+ =A0 =A0 =A0 } while (ret < 0 && limit-- > 0);
=A0
hdev->hid_output_raw_report error is not a hard failure, i.e., the = following four lines are unnecessay.=A0We can continue with the rest of the= code.
=A0
+ =A0 =A0 =A0 if (ret < 0) {<= br>+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_err(&hdev->dev, "failed to= poke device #1, %d\n", ret);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto err_free;
+ =A0 =A0 =A0 }
+
+ = =A0 =A0 =A0 /* 0x06 - high reporting speed, 0x05 - low speed */
+ =A0 = =A0 =A0 rep_data[0] =3D 0x06; rep_data[1] =3D 0x00;
+ =A0 =A0 =A0 limit = =3D 3;
+ =A0 =A0 =A0 do {
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D hdev-= >hid_output_raw_report(hdev, rep_data, 2,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 HID_FEATURE_R= EPORT);
+ =A0 =A0 =A0 } while (ret < 0 && limit-- > 0);
=A0
Same comments apply here.=A0"/* Note that if query fails it is no= t a hard failure */" is=A0the comments=A0we use in the corresponding W= acom USB driver, wacom_sys.c
=A0
+ =A0 =A0 =A0 if (ret < 0) {<= br>+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 dev_err(&hdev->dev, "failed to= poke device #2, %d\n", ret);
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto err_free;
+ =A0 =A0 =A0 }
+
=A0= =A0 =A0 =A0hidinput =3D list_entry(hdev->inputs.next, struct hid_input,= list);
=A0 =A0 =A0 =A0input =3D hidinput->input;
=A0
Everything else looks good to me.
=A0
Ping
=A0
=A0

--001636ed67247e9948047e50c6cb--