diff mbox

[01/11] HID: uHID: implement .raw_request

Message ID 1391316630-29541-2-git-send-email-benjamin.tissoires@redhat.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Benjamin Tissoires Feb. 2, 2014, 4:50 a.m. UTC
It was missing, so adding it.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
 drivers/hid/uhid.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Comments

David Herrmann Feb. 3, 2014, 3:26 p.m. UTC | #1
Hi

On Sun, Feb 2, 2014 at 5:50 AM, Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
> It was missing, so adding it.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
>  drivers/hid/uhid.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
> index f5a2b19..438c9f1 100644
> --- a/drivers/hid/uhid.c
> +++ b/drivers/hid/uhid.c
> @@ -270,6 +270,22 @@ static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf,
>         return count;
>  }
>
> +static int uhid_raw_request(struct hid_device *hid, unsigned char reportnum,
> +                           __u8 *buf, size_t len, unsigned char rtype,
> +                           int reqtype)
> +{
> +       switch (reqtype) {
> +       case HID_REQ_GET_REPORT:
> +               return uhid_hid_get_raw(hid, reportnum, buf, len, rtype);
> +       case HID_REQ_SET_REPORT:
> +               if (buf[0] != reportnum)
> +                       return -EINVAL;
> +               return uhid_hid_output_raw(hid, buf, len, rtype);

But that one looks wrong. UHID does not have any SET_REPORT query in
the protocol, yet. You turn a SET_REPORT into an OUTPUT_REPORT here.
So if user-space gets the UHID_OUTPUT event, it doesn't know whether
to send a SET_REPORT@ctrl to the device, or an async
OUTPUT_REPORT@intr. This at least matters for low-energy BT in bluez,
which uses uhid.

So we'd have to add an UHID_SET_REPORT event. Note that currently
UHID_FEATURE is the equivalent of UHID_GET_REPORT, but just horribly
named..

Thanks
David

> +       default:
> +               return -EIO;
> +       }
> +}
> +
>  static struct hid_ll_driver uhid_hid_driver = {
>         .start = uhid_hid_start,
>         .stop = uhid_hid_stop,
> @@ -277,6 +293,7 @@ static struct hid_ll_driver uhid_hid_driver = {
>         .close = uhid_hid_close,
>         .parse = uhid_hid_parse,
>         .output_report = uhid_hid_output_report,
> +       .raw_request = uhid_raw_request,
>  };
>
>  #ifdef CONFIG_COMPAT
> --
> 1.8.3.1
>
--
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
Benjamin Tissoires Feb. 3, 2014, 7:07 p.m. UTC | #2
On Mon, Feb 3, 2014 at 10:26 AM, David Herrmann <dh.herrmann@gmail.com> wrote:
> Hi
>
> On Sun, Feb 2, 2014 at 5:50 AM, Benjamin Tissoires
> <benjamin.tissoires@redhat.com> wrote:
>> It was missing, so adding it.
>>
>> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>> ---
>>  drivers/hid/uhid.c | 17 +++++++++++++++++
>>  1 file changed, 17 insertions(+)
>>
>> diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
>> index f5a2b19..438c9f1 100644
>> --- a/drivers/hid/uhid.c
>> +++ b/drivers/hid/uhid.c
>> @@ -270,6 +270,22 @@ static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf,
>>         return count;
>>  }
>>
>> +static int uhid_raw_request(struct hid_device *hid, unsigned char reportnum,
>> +                           __u8 *buf, size_t len, unsigned char rtype,
>> +                           int reqtype)
>> +{
>> +       switch (reqtype) {
>> +       case HID_REQ_GET_REPORT:
>> +               return uhid_hid_get_raw(hid, reportnum, buf, len, rtype);
>> +       case HID_REQ_SET_REPORT:
>> +               if (buf[0] != reportnum)
>> +                       return -EINVAL;
>> +               return uhid_hid_output_raw(hid, buf, len, rtype);
>
> But that one looks wrong. UHID does not have any SET_REPORT query in
> the protocol, yet. You turn a SET_REPORT into an OUTPUT_REPORT here.
> So if user-space gets the UHID_OUTPUT event, it doesn't know whether
> to send a SET_REPORT@ctrl to the device, or an async
> OUTPUT_REPORT@intr. This at least matters for low-energy BT in bluez,
> which uses uhid.

right. So we can drop this for now.

>
> So we'd have to add an UHID_SET_REPORT event. Note that currently
> UHID_FEATURE is the equivalent of UHID_GET_REPORT, but just horribly
> named..

ouch. I think this is something which can be fixed quite easily (by
marking UHID_FEATURE obsolete and creating the two events).
However, I don't think I will have the time to make the change and do
proper testings in the next few days/weeks.

Can somebody else take this?

Cheers,
Benjamin

>
> Thanks
> David
>
>> +       default:
>> +               return -EIO;
>> +       }
>> +}
>> +
>>  static struct hid_ll_driver uhid_hid_driver = {
>>         .start = uhid_hid_start,
>>         .stop = uhid_hid_stop,
>> @@ -277,6 +293,7 @@ static struct hid_ll_driver uhid_hid_driver = {
>>         .close = uhid_hid_close,
>>         .parse = uhid_hid_parse,
>>         .output_report = uhid_hid_output_report,
>> +       .raw_request = uhid_raw_request,
>>  };
>>
>>  #ifdef CONFIG_COMPAT
>> --
>> 1.8.3.1
>>
--
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
diff mbox

Patch

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index f5a2b19..438c9f1 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -270,6 +270,22 @@  static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf,
 	return count;
 }
 
+static int uhid_raw_request(struct hid_device *hid, unsigned char reportnum,
+			    __u8 *buf, size_t len, unsigned char rtype,
+			    int reqtype)
+{
+	switch (reqtype) {
+	case HID_REQ_GET_REPORT:
+		return uhid_hid_get_raw(hid, reportnum, buf, len, rtype);
+	case HID_REQ_SET_REPORT:
+		if (buf[0] != reportnum)
+			return -EINVAL;
+		return uhid_hid_output_raw(hid, buf, len, rtype);
+	default:
+		return -EIO;
+	}
+}
+
 static struct hid_ll_driver uhid_hid_driver = {
 	.start = uhid_hid_start,
 	.stop = uhid_hid_stop,
@@ -277,6 +293,7 @@  static struct hid_ll_driver uhid_hid_driver = {
 	.close = uhid_hid_close,
 	.parse = uhid_hid_parse,
 	.output_report = uhid_hid_output_report,
+	.raw_request = uhid_raw_request,
 };
 
 #ifdef CONFIG_COMPAT