linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: Frank Praznik <frank.praznik@oh.rr.com>
Cc: "open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
	Jiri Kosina <jkosina@suse.cz>
Subject: Re: [PATCH 1/7] HID: sony: Change dualshock4_state_worker to use the low-level transport driver function
Date: Wed, 29 Jan 2014 18:39:48 +0100	[thread overview]
Message-ID: <CANq1E4Rgw0ExJr4Qhe2Ge4yAA6t7Gf9qgQ2d0anFC7Yxzz1b4A@mail.gmail.com> (raw)
In-Reply-To: <1391016797-12842-2-git-send-email-frank.praznik@oh.rr.com>

Hi

On Wed, Jan 29, 2014 at 6:33 PM, Frank Praznik <frank.praznik@oh.rr.com> wrote:
> Use the new low-level transport driver functions to send the output reports to
> the controller.
>
> Remove sony_set_output_report since it is no longer used.
>
> Signed-off-by: Frank Praznik <frank.praznik@oh.rr.com>
>
> ---
>  drivers/hid/hid-sony.c | 56 +++++++++++++-------------------------------------
>  1 file changed, 14 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index 2bd3f13..a3cefdec 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -502,7 +502,6 @@ struct sony_sc {
>         spinlock_t lock;
>         struct hid_device *hdev;
>         struct led_classdev *leds[MAX_LEDS];
> -       struct hid_report *output_report;
>         unsigned long quirks;
>         struct work_struct state_worker;
>         struct power_supply battery;
> @@ -1053,21 +1052,26 @@ static void dualshock4_state_worker(struct work_struct *work)
>  {
>         struct sony_sc *sc = container_of(work, struct sony_sc, state_worker);
>         struct hid_device *hdev = sc->hdev;
> -       struct hid_report *report = sc->output_report;
> -       __s32 *value = report->field[0]->value;
> +       int offset;
> +
> +       __u8 buf[32] = { 0 };
>
> -       value[0] = 0x03;
> +       buf[0] = 0x05;
> +       buf[1] = 0x03;
> +       offset = 4;
>
>  #ifdef CONFIG_SONY_FF
> -       value[3] = sc->right;
> -       value[4] = sc->left;
> +       buf[offset++] = sc->right;
> +       buf[offset++] = sc->left;
> +#else
> +       offset += 2;
>  #endif
>
> -       value[5] = sc->led_state[0];
> -       value[6] = sc->led_state[1];
> -       value[7] = sc->led_state[2];
> +       buf[offset++] = sc->led_state[0];
> +       buf[offset++] = sc->led_state[1];
> +       buf[offset++] = sc->led_state[2];
>
> -       hid_hw_request(hdev, report, HID_REQ_SET_REPORT);
> +       hdev->ll_driver->output_report(hdev, buf, sizeof(buf));

You should check that "output_report" is non-NULL. Feel free to do
that in ->probe(). Not all transport-drivers currently implement it
and we allow user-space to rebind drivers via sysfs.

Thanks
David

>  }
>
>  #ifdef CONFIG_SONY_FF
> @@ -1200,33 +1204,6 @@ static void sony_battery_remove(struct sony_sc *sc)
>         sc->battery.name = NULL;
>  }
>
> -static int sony_set_output_report(struct sony_sc *sc, int req_id, int req_size)
> -{
> -       struct list_head *head, *list;
> -       struct hid_report *report;
> -       struct hid_device *hdev = sc->hdev;
> -
> -       list = &hdev->report_enum[HID_OUTPUT_REPORT].report_list;
> -
> -       list_for_each(head, list) {
> -               report = list_entry(head, struct hid_report, list);
> -
> -               if (report->id == req_id) {
> -                       if (report->size < req_size) {
> -                               hid_err(hdev, "Output report 0x%02x (%i bits) is smaller than requested size (%i bits)\n",
> -                                       req_id, report->size, req_size);
> -                               return -EINVAL;
> -                       }
> -                       sc->output_report = report;
> -                       return 0;
> -               }
> -       }
> -
> -       hid_err(hdev, "Unable to locate output report 0x%02x\n", req_id);
> -
> -       return -EINVAL;
> -}
> -
>  static int sony_register_touchpad(struct sony_sc *sc, int touch_count,
>                                         int w, int h)
>  {
> @@ -1291,11 +1268,6 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
>         else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
>                 ret = sixaxis_set_operational_bt(hdev);
>         else if (sc->quirks & DUALSHOCK4_CONTROLLER_USB) {
> -               /* Report 5 (31 bytes) is used to send data to the controller via USB */
> -               ret = sony_set_output_report(sc, 0x05, 248);
> -               if (ret < 0)
> -                       goto err_stop;
> -
>                 /* The Dualshock 4 touchpad supports 2 touches and has a
>                  * resolution of 1920x940.
>                  */
> --
> 1.8.5.3
>
> --
> 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

  reply	other threads:[~2014-01-29 17:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-29 17:33 [PATCH 0/7] HID: sony: Add full support for the Dualshock 4 on Bluetooth Frank Praznik
2014-01-29 17:33 ` [PATCH 1/7] HID: sony: Change dualshock4_state_worker to use the low-level transport driver function Frank Praznik
2014-01-29 17:39   ` David Herrmann [this message]
2014-01-29 17:33 ` [PATCH 2/7] HID: sony: Add Bluetooth HID descriptor for Dualshock 4 Frank Praznik
2014-01-29 17:33 ` [PATCH 3/7] HID: sony: Add Bluetooth output report formatting for the " Frank Praznik
2014-01-29 17:33 ` [PATCH 4/7] HID: sony: Add offsets and battery calculations for parsing Dualshock 4 reports sent via Bluetooth Frank Praznik
2014-01-29 21:36   ` simon
2014-01-29 17:33 ` [PATCH 5/7] HID: sony: Set inital battery level to 100% to avoid false low battery warnings Frank Praznik
2014-01-29 17:33 ` [PATCH 6/7] HID: sony: Add conditionals to enable LED, rumble, battery and touchpad support on the Dualshock 4 Frank Praznik
2014-01-29 17:33 ` [PATCH 7/7] HID: sony: Prevent devices from being connected twice Frank Praznik
2014-01-29 17:42   ` David Herrmann

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=CANq1E4Rgw0ExJr4Qhe2Ge4yAA6t7Gf9qgQ2d0anFC7Yxzz1b4A@mail.gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=frank.praznik@oh.rr.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).