All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Jiri Kosina <jkosina@suse.cz>,
	Frank Praznik <frank.praznik@oh.rr.com>,
	"open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 04/11] HID: logitech-dj: remove hidinput_input_event
Date: Mon, 3 Feb 2014 18:07:34 +0100	[thread overview]
Message-ID: <CANq1E4SMp6080REEbHriy6gE6pivoLbr9KzmpzJiFffK7QyJ2w@mail.gmail.com> (raw)
In-Reply-To: <CAN+gG=EesWpKiz-M4LrLTM0ne+o8=XE3vdQnwBPuHOyEgwEJKw@mail.gmail.com>

Hi

On Mon, Feb 3, 2014 at 5:21 PM, Benjamin Tissoires
<benjamin.tissoires@gmail.com> wrote:
> On Mon, Feb 3, 2014 at 11:06 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:
>>> hid-logitech-dj uses its own ->hidinput_input_event() instead of
>>> the generic binding in hid-input.
>>> Moving the handling of LEDs towards logi_dj_output_hidraw_report()
>>> allows two things:
>>> - remove hidinput_input_event in struct hid_device
>>> - hidraw user space programs can also set the LEDs
>>>
>>> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>>> ---
>>>  drivers/hid/hid-logitech-dj.c | 99 +++++++++++++++----------------------------
>>>  1 file changed, 35 insertions(+), 64 deletions(-)
>>>
>>> diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
>>> index f45279c..61d2bbf 100644
>>> --- a/drivers/hid/hid-logitech-dj.c
>>> +++ b/drivers/hid/hid-logitech-dj.c
>>> @@ -44,14 +44,6 @@ static const char kbd_descriptor[] = {
>>>         0x19, 0xE0,             /*   USAGE_MINIMUM (Left Control)   */
>>>         0x29, 0xE7,             /*   USAGE_MAXIMUM (Right GUI)      */
>>>         0x81, 0x02,             /*   INPUT (Data,Var,Abs)       */
>>> -       0x95, 0x05,             /*   REPORT COUNT (5)           */
>>> -       0x05, 0x08,             /*   USAGE PAGE (LED page)      */
>>> -       0x19, 0x01,             /*   USAGE MINIMUM (1)          */
>>> -       0x29, 0x05,             /*   USAGE MAXIMUM (5)          */
>>> -       0x91, 0x02,             /*   OUTPUT (Data, Variable, Absolute)  */
>>> -       0x95, 0x01,             /*   REPORT COUNT (1)           */
>>> -       0x75, 0x03,             /*   REPORT SIZE (3)            */
>>> -       0x91, 0x01,             /*   OUTPUT (Constant)          */
>>>         0x95, 0x06,             /*   REPORT_COUNT (6)           */
>>>         0x75, 0x08,             /*   REPORT_SIZE (8)            */
>>>         0x15, 0x00,             /*   LOGICAL_MINIMUM (0)        */
>>> @@ -60,6 +52,18 @@ static const char kbd_descriptor[] = {
>>>         0x19, 0x00,             /*   USAGE_MINIMUM (no event)       */
>>>         0x2A, 0xFF, 0x00,       /*   USAGE_MAXIMUM (reserved)       */
>>>         0x81, 0x00,             /*   INPUT (Data,Ary,Abs)       */
>>> +       0x85, 0x0e,             /* REPORT_ID (14)               */
>>> +       0x05, 0x08,             /*   USAGE PAGE (LED page)      */
>>> +       0x95, 0x05,             /*   REPORT COUNT (5)           */
>>> +       0x75, 0x01,             /*   REPORT SIZE (1)            */
>>> +       0x15, 0x00,             /*   LOGICAL_MINIMUM (0)        */
>>> +       0x25, 0x01,             /*   LOGICAL_MAXIMUM (1)        */
>>> +       0x19, 0x01,             /*   USAGE MINIMUM (1)          */
>>> +       0x29, 0x05,             /*   USAGE MAXIMUM (5)          */
>>> +       0x91, 0x02,             /*   OUTPUT (Data, Variable, Absolute)  */
>>> +       0x95, 0x01,             /*   REPORT COUNT (1)           */
>>> +       0x75, 0x03,             /*   REPORT SIZE (3)            */
>>> +       0x91, 0x01,             /*   OUTPUT (Constant)          */
>>>         0xC0
>>>  };
>>>
>>> @@ -544,10 +548,30 @@ static int logi_dj_output_hidraw_report(struct hid_device *hid, u8 * buf,
>>>                                         size_t count,
>>>                                         unsigned char report_type)
>>>  {
>>> -       /* Called by hid raw to send data */
>>> -       dbg_hid("%s\n", __func__);
>>> +       struct dj_device *djdev = hid->driver_data;
>>> +       struct dj_receiver_dev *djrcv_dev = djdev->dj_receiver_dev;
>>> +       u8 *out_buf;
>>> +       int ret;
>>>
>>> -       return 0;
>>> +       if (buf[0] != REPORT_TYPE_LEDS)
>>> +               return -EINVAL;
>>> +
>>> +       out_buf = kzalloc(DJREPORT_SHORT_LENGTH, GFP_ATOMIC);
>>> +       if (!out_buf)
>>> +               return -ENOMEM;
>>> +
>>> +       if (count < DJREPORT_SHORT_LENGTH - 2)
>>> +               count = DJREPORT_SHORT_LENGTH - 2;
>>> +
>>> +       out_buf[0] = REPORT_ID_DJ_SHORT;
>>> +       out_buf[1] = djdev->device_index;
>>> +       memcpy(out_buf + 2, buf, count);
>>> +
>>> +       ret = djrcv_dev->hdev->hid_output_raw_report(djrcv_dev->hdev, out_buf,
>>> +               DJREPORT_SHORT_LENGTH, report_type);
>>
>> Strictly speaking the code below uses HID_REQ_SET_REPORT and you
>> replace it with hid_output_raw_report() here (which at least for BTHID
>> is not equivalent). Anyhow, HID-core uses hid_output_raw_report(),
>> too, so this should be fine.
>
> Yes, you are right. This fires back on me yesterday when I tried to
> remove the hid_output_raw_report() calls.
> It occurs it works because usbhid_out_raw_report() uses set_report
> when there is no urbout, which is the case with logitech receivers.
> So I guess an ideal solution would be to implement a hid_hw_request call.
>
> However, the only concern I have with hid_hw_request is that it does
> not allow hidraw to play with the LEDs given that hidraw does not have
> an ioctl for SET_REPORT (or GET_REPORT). I already seen this issue
> regarding i2c_hid at some point, but it was "solved" in i2c_hid by
> using the same ugly trick that we have in USB-hid.

Hah! That's why it worked all the years, USB-HID checks for !urbout..
and yeah, that's what I just criticized in your i2c-hid patch.. Ok,
I'm fine if we make output_report() fall back to SET_REPORT if not
output-channel is supported. But we it gets ugly if we rely on that
from the upper stack... hmm, don't know how to make that work but
adding a hid quirk to use SET_REPORT for hidinput_input_report().

Thanks
David

  reply	other threads:[~2014-02-03 17:07 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-02  4:50 [PATCH 00/11] HID: spring cleaning Benjamin Tissoires
2014-02-02  4:50 ` [PATCH 01/11] HID: uHID: implement .raw_request Benjamin Tissoires
2014-02-03 15:26   ` David Herrmann
2014-02-03 19:07     ` Benjamin Tissoires
2014-02-02  4:50 ` [PATCH 02/11] HID: i2c-hid: implement ll_driver transport-layer callbacks Benjamin Tissoires
2014-02-03 16:04   ` David Herrmann
2014-02-03 19:00     ` Benjamin Tissoires
2014-02-02  4:50 ` [PATCH 03/11] HID: add inliners for " Benjamin Tissoires
2014-02-03 15:29   ` David Herrmann
2014-02-02  4:50 ` [PATCH 04/11] HID: logitech-dj: remove hidinput_input_event Benjamin Tissoires
2014-02-03 16:06   ` David Herrmann
2014-02-03 16:21     ` Benjamin Tissoires
2014-02-03 17:07       ` David Herrmann [this message]
2014-02-02  4:50 ` [PATCH 05/11] HID: HIDp: remove hidp_hidinput_event Benjamin Tissoires
2014-02-03 15:10   ` David Herrmann
2014-02-03 15:28     ` Benjamin Tissoires
2014-02-02  4:50 ` [PATCH 06/11] HID: remove hidinput_input_event handler Benjamin Tissoires
2014-02-03 16:10   ` David Herrmann
2014-02-02  4:50 ` [PATCH 07/11] HID: HIDp: remove duplicated coded Benjamin Tissoires
2014-02-03 15:02   ` David Herrmann
2014-02-03 15:11     ` Benjamin Tissoires
2014-02-03 15:19       ` David Herrmann
2014-02-02  4:50 ` [PATCH 08/11] HID: usbhid: remove duplicated code Benjamin Tissoires
2014-02-03 16:09   ` David Herrmann
2014-02-02  4:50 ` [PATCH 09/11] HID: remove hid_get_raw_report in struct hid_device Benjamin Tissoires
2014-02-03 16:12   ` David Herrmann
2014-02-02  4:50 ` [PATCH 10/11] HID: introduce helper to access hid_output_raw_report() Benjamin Tissoires
2014-02-03 16:14   ` David Herrmann
2014-02-02  4:50 ` [PATCH 11/11] HID: move hid_output_raw_report to hid_ll_driver Benjamin Tissoires
2014-02-03 16:48 ` [PATCH 00/11] HID: spring cleaning David Herrmann
2014-02-03 19:19   ` Benjamin Tissoires

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANq1E4SMp6080REEbHriy6gE6pivoLbr9KzmpzJiFffK7QyJ2w@mail.gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=benjamin.tissoires@gmail.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=frank.praznik@oh.rr.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.