All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Kosina <jkosina@suse.cz>
To: "Gunn, Brian" <bgunn@solekai.com>,
	Marcel Holtmann <marcel@holtmann.org>, Ping <pinglinux@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	BlueZ development <linux-bluetooth@vger.kernel.org>
Subject: [PATCH 1/3] HID: make raw reports possible for both feature and output reports
Date: Fri, 29 Jan 2010 15:20:49 +0100 (CET)	[thread overview]
Message-ID: <alpine.LNX.2.00.1001291518510.356@pobox.suse.cz> (raw)
In-Reply-To: <alpine.LNX.2.00.1001291515560.356@pobox.suse.cz>

In commit 2da31939a42f7a676a0bc5155d6a0a39ed8451f2 ("Bluetooth: Implement raw
output support for HIDP layer"), support for Bluetooth
hid_output_raw_report was added, but it pushes the data to the intr socket
instead of the ctrl one.

Plus it is necessary to distinguish whether the report in question should be
either FEATURE or OUTPUT. For this, we have to extend the generic HID API,
so that hid_output_raw_report() callback provides means to specify this
value so that it can be passed down to lower level hardware drivers (currently
Bluetooth and USB).

Based on original patch by Bastien Nocera <hadess@hadess.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 drivers/hid/hidraw.c          |    2 +-
 drivers/hid/usbhid/hid-core.c |    5 ++-
 include/linux/hid.h           |    2 +-
 net/bluetooth/hidp/core.c     |   79 +++++++++++++++++++++++------------------
 4 files changed, 49 insertions(+), 39 deletions(-)

diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index cdd1369..d044767 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -134,7 +134,7 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
 		goto out;
 	}
 
-	ret = dev->hid_output_raw_report(dev, buf, count);
+	ret = dev->hid_output_raw_report(dev, buf, count, HID_OUTPUT_REPORT);
 out:
 	kfree(buf);
 	return ret;
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index e2997a8..caa16c0 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -774,7 +774,8 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
 	return 0;
 }
 
-static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count)
+static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t count,
+		unsigned char report_type)
 {
 	struct usbhid_device *usbhid = hid->driver_data;
 	struct usb_device *dev = hid_to_usb_dev(hid);
@@ -785,7 +786,7 @@ static int usbhid_output_raw_report(struct hid_device *hid, __u8 *buf, size_t co
 	ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
 		HID_REQ_SET_REPORT,
 		USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
-		((HID_OUTPUT_REPORT + 1) << 8) | *buf,
+		((report_type + 1) << 8) | *buf,
 		interface->desc.bInterfaceNumber, buf + 1, count - 1,
 		USB_CTRL_SET_TIMEOUT);
 
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 8709365..3661a62 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -501,7 +501,7 @@ struct hid_device {							/* device report descriptor */
 	void (*hiddev_report_event) (struct hid_device *, struct hid_report *);
 
 	/* handler for raw output data, used by hidraw */
-	int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t);
+	int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t, unsigned char);
 
 	/* debugging support via debugfs */
 	unsigned short debug;
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 18e7f5a..9c88750 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -243,6 +243,39 @@ static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb)
 	input_sync(dev);
 }
 
+static int __hidp_send_ctrl_message(struct hidp_session *session,
+			unsigned char hdr, unsigned char *data, int size)
+{
+	struct sk_buff *skb;
+
+	BT_DBG("session %p data %p size %d", session, data, size);
+
+	if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) {
+		BT_ERR("Can't allocate memory for new frame");
+		return -ENOMEM;
+	}
+
+	*skb_put(skb, 1) = hdr;
+	if (data && size > 0)
+		memcpy(skb_put(skb, size), data, size);
+
+	skb_queue_tail(&session->ctrl_transmit, skb);
+
+	return 0;
+}
+
+static inline int hidp_send_ctrl_message(struct hidp_session *session,
+			unsigned char hdr, unsigned char *data, int size)
+{
+	int err;
+
+	err = __hidp_send_ctrl_message(session, hdr, data, size);
+
+	hidp_schedule(session);
+
+	return err;
+}
+
 static int hidp_queue_report(struct hidp_session *session,
 				unsigned char *data, int size)
 {
@@ -280,9 +313,18 @@ static int hidp_send_report(struct hidp_session *session, struct hid_report *rep
 	return hidp_queue_report(session, buf, rsize);
 }
 
-static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count)
+static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count,
+		unsigned char report_type)
 {
-	if (hidp_queue_report(hid->driver_data, data, count))
+	if (report_type == HID_FEATURE_REPORT)
+		report_type = HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE;
+	else if (report_type == HID_OUTPUT_REPORT)
+		report_type = HIDP_TRANS_DATA | HIDP_DATA_RTYPE_OUPUT;
+	else
+		return -EINVAL;
+
+	if (hidp_send_ctrl_message(hid->driver_data, report_type,
+			data, count))
 		return -ENOMEM;
 	return count;
 }
@@ -307,39 +349,6 @@ static inline void hidp_del_timer(struct hidp_session *session)
 		del_timer(&session->timer);
 }
 
-static int __hidp_send_ctrl_message(struct hidp_session *session,
-			unsigned char hdr, unsigned char *data, int size)
-{
-	struct sk_buff *skb;
-
-	BT_DBG("session %p data %p size %d", session, data, size);
-
-	if (!(skb = alloc_skb(size + 1, GFP_ATOMIC))) {
-		BT_ERR("Can't allocate memory for new frame");
-		return -ENOMEM;
-	}
-
-	*skb_put(skb, 1) = hdr;
-	if (data && size > 0)
-		memcpy(skb_put(skb, size), data, size);
-
-	skb_queue_tail(&session->ctrl_transmit, skb);
-
-	return 0;
-}
-
-static inline int hidp_send_ctrl_message(struct hidp_session *session,
-			unsigned char hdr, unsigned char *data, int size)
-{
-	int err;
-
-	err = __hidp_send_ctrl_message(session, hdr, data, size);
-
-	hidp_schedule(session);
-
-	return err;
-}
-
 static void hidp_process_handshake(struct hidp_session *session,
 					unsigned char param)
 {
-- 
1.6.4.2


  reply	other threads:[~2010-01-29 14:20 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 14:20 [PATCH 0/3] HID: make raw output callback more flexible Jiri Kosina
2010-01-29 14:20 ` Jiri Kosina [this message]
2010-01-29 14:20 ` [PATCH 2/3] HID: Implement Wacom quirk in the kernel Jiri Kosina
2010-01-29 17:14   ` Ping Cheng
2010-02-03 14:50     ` Jiri Kosina
2010-01-29 14:21 ` [PATCH 3/3] HID: Enable Sixaxis controller over Bluetooth Jiri Kosina
2010-01-29 16:39 ` [PATCH 0/3] HID: make raw output callback more flexible Bastien Nocera
2010-01-30  0:46   ` Michael Poole
2010-01-30  0:46     ` Michael Poole
2010-01-30 14:11     ` Bastien Nocera
2010-01-31  3:27       ` Michael Poole
2010-01-31  3:27         ` Michael Poole
2010-02-03  1:25       ` Michael Poole
2010-02-03  1:25         ` Michael Poole
2010-02-03  9:47         ` Bastien Nocera
     [not found]           ` <alpine.LNX.2.00.1002031202040.15395@pobox.suse.cz>
2010-02-03 12:48             ` Jiri Kosina
2010-02-03 12:49               ` [PATCH 1/3] HID: make raw reports possible for both feature and output reports Jiri Kosina
2010-02-03 14:14                 ` Marcel Holtmann
2010-02-03 14:37                   ` Jiri Kosina
2010-02-03 12:49               ` [PATCH 2/3] HID: Implement Wacom quirk in the kernel Jiri Kosina
2010-02-03 14:19                 ` Marcel Holtmann
2010-02-03 14:40                   ` Jiri Kosina
2010-02-03 12:50               ` [PATCH 3/3] HID: Enable Sixaxis controller over Bluetooth Jiri Kosina
2010-02-03 14:17                 ` Marcel Holtmann
2010-02-03 14:42                   ` Jiri Kosina
2010-02-04 12:26       ` [PATCH] Bluetooth: Keep a copy of each HID device's report descriptor Michael Poole
2010-02-04 14:23         ` Marcel Holtmann
2010-02-05 17:23           ` Michael Poole
2010-02-05 17:23             ` Michael Poole
2010-02-05 17:51             ` Marcel Holtmann
2010-02-09  2:06               ` Ed Tomlinson
2010-02-09  7:22                 ` Justin Mattock
2010-02-09  7:22                   ` Justin Mattock
2010-02-09 10:14                   ` Bastien Nocera
2010-02-09 10:14                     ` Bastien Nocera
2010-02-09 12:36                     ` Ed Tomlinson
2010-02-09 12:40                       ` Jiri Kosina
2010-02-09 13:10                         ` [PATCH 0/2] Provide a driver for the Apple Magic Mouse Michael Poole
2010-02-09 13:10                           ` Michael Poole
2010-02-09 13:11                           ` [PATCH 1/2] " Michael Poole
2010-02-09 13:11                             ` Michael Poole
2010-02-09 13:11                             ` Michael Poole
2010-02-09 13:13                           ` [PATCH 2/2] Add a device " Michael Poole
2010-02-09 13:13                             ` Michael Poole
2010-02-10 13:06                             ` Jiri Kosina
2010-02-10 13:06                               ` Jiri Kosina
2010-02-10 13:58                               ` Jiri Kosina
2010-02-10 13:58                                 ` Jiri Kosina
2010-02-10 18:20                             ` Dmitry Torokhov
2010-02-10 20:31                               ` Michael Poole
2010-02-10 20:31                                 ` Michael Poole
2010-02-10 20:31                                 ` Michael Poole
2010-02-11  5:32                               ` [PATCH] hid-magicmouse: Coding style and probe failure fixes Michael Poole
2010-02-11  5:32                                 ` Michael Poole
2010-02-11  6:55                                 ` Dmitry Torokhov
2010-02-11  6:55                                   ` Dmitry Torokhov
2010-02-11 10:26                                 ` Jiri Kosina
2010-02-11 23:10                                   ` Michael Poole
2010-02-11  3:05                             ` [PATCH 2/2] Add a device driver for the Apple Magic Mouse Ed Tomlinson
2010-02-11  3:05                               ` Ed Tomlinson
2010-02-11  3:20                               ` Michael Poole
2010-02-11  3:20                                 ` Michael Poole
2010-02-11  3:20                                 ` Michael Poole
2010-02-11 12:51                                 ` [PATCH 2/2] Add a device driver for the Apple Magic Mouse (2.6.32.8) Ed Tomlinson
2010-02-09 21:37                           ` [PATCH 0/2] Provide a driver for the Apple Magic Mouse Justin P. Mattock
2010-02-09 21:37                             ` Justin P. Mattock
2010-02-10 13:57                           ` Jiri Kosina
2010-02-10 13:57                             ` Jiri Kosina
2010-02-13 19:29                             ` [PATCH 0/2] Provide a driver for the Apple Magic Mouse - opps Ed Tomlinson
2010-02-14  8:03                               ` Dmitry Torokhov
2010-02-14 14:22                                 ` Ed Tomlinson
2010-02-14 14:22                                   ` Ed Tomlinson
2010-02-15  7:11                                   ` Dmitry Torokhov
2010-02-15 12:42                                     ` Ed Tomlinson
2010-02-15 12:42                                       ` Ed Tomlinson
2010-02-15 12:44                                     ` Ed Tomlinson
2010-02-16 12:57                                       ` Jiri Kosina
2010-02-16 12:34                                     ` Ed Tomlinson
2010-02-16 12:55                                       ` Jiri Kosina
2010-02-14 22:24                             ` [PATCH 1/1] Enable xy scrolling for Apple Magic Mouse Ed Tomlinson
2010-02-14 22:24                               ` Ed Tomlinson
2010-02-14 22:51                               ` Michael Poole
2010-02-14 22:51                                 ` Michael Poole
2010-02-14 23:58                                 ` Ed Tomlinson
2010-02-14 23:58                                   ` Ed Tomlinson
2010-02-15  7:18                                   ` Dmitry Torokhov
2010-02-15 12:50                                     ` Ed Tomlinson
2010-02-15 12:50                                       ` Ed Tomlinson
2010-02-15  0:18                                 ` Ed Tomlinson
2010-02-09 15:03                     ` [PATCH] Bluetooth: Keep a copy of each HID device's report descriptor Justin P. Mattock
2010-02-05 12:49         ` Bastien Nocera
2010-02-05 13:27           ` Marcel Holtmann
2010-01-30 14:13 ` [PATCH 0/3] HID: make raw output callback more flexible Marcel Holtmann

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=alpine.LNX.2.00.1001291518510.356@pobox.suse.cz \
    --to=jkosina@suse.cz \
    --cc=bgunn@solekai.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=pinglinux@gmail.com \
    /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.