aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-logitech-dj.h
diff options
context:
space:
mode:
authorNestor Lopez Casado <nlopezcasad@logitech.com>2011-09-15 05:34:49 -0400
committerJiri Kosina <jkosina@suse.cz>2011-09-15 05:34:49 -0400
commit534a7b8e10ec55d9f521e68c20dbb3634c25b98a (patch)
treeb6cbaad7a3fea91ff9cab6c08a2e6c4c5a6ff07f /drivers/hid/hid-logitech-dj.h
parent8f25229026c89912574558d0a4e36c8fe51b9bb4 (diff)
HID: Add full support for Logitech Unifying receivers
With this driver, all the devices paired to a single Unifying receiver are exposed to user processes in separated /input/dev nodes. Keyboards with different layouts can be treated differently, Multiplayer games on single PC (like home theater PC) can differentiate input coming from different kbds paired to the same receiver. Up to now, when Logitech Unifying receivers are connected to a Linux based system, a single keyboard and a single mouse are presented to the HID Layer, even if the Unifying receiver can pair up to six compatible devices. The Unifying receiver by default multiplexes all incoming events (from multiple keyboards/mice) into these two. Signed-off-by: Nestor Lopez Casado <nlopezcasad@logitech.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-logitech-dj.h')
-rw-r--r--drivers/hid/hid-logitech-dj.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/drivers/hid/hid-logitech-dj.h b/drivers/hid/hid-logitech-dj.h
new file mode 100644
index 000000000000..5982263acd73
--- /dev/null
+++ b/drivers/hid/hid-logitech-dj.h
@@ -0,0 +1,120 @@
1#ifndef __HID_LOGITECH_DJ_H
2#define __HID_LOGITECH_DJ_H
3
4/*
5 * HID driver for Logitech Unifying receivers
6 *
7 * Copyright (c) 2011 Logitech
8 */
9
10/*
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 */
25
26#include <linux/kfifo.h>
27
28#define DJ_MAX_PAIRED_DEVICES 6
29#define DJ_MAX_NUMBER_NOTIFICATIONS 8
30
31#define DJREPORT_SHORT_LENGTH 15
32#define DJREPORT_LONG_LENGTH 32
33
34#define REPORT_ID_DJ_SHORT 0x20
35#define REPORT_ID_DJ_LONG 0x21
36
37#define REPORT_TYPE_RFREPORT_FIRST 0x01
38#define REPORT_TYPE_RFREPORT_LAST 0x1F
39
40/* Command Switch to DJ mode */
41#define REPORT_TYPE_CMD_SWITCH 0x80
42#define CMD_SWITCH_PARAM_DEVBITFIELD 0x00
43#define CMD_SWITCH_PARAM_TIMEOUT_SECONDS 0x01
44#define TIMEOUT_NO_KEEPALIVE 0x00
45
46/* Command to Get the list of Paired devices */
47#define REPORT_TYPE_CMD_GET_PAIRED_DEVICES 0x81
48
49/* Device Paired Notification */
50#define REPORT_TYPE_NOTIF_DEVICE_PAIRED 0x41
51#define SPFUNCTION_MORE_NOTIF_EXPECTED 0x01
52#define SPFUNCTION_DEVICE_LIST_EMPTY 0x02
53#define DEVICE_PAIRED_PARAM_SPFUNCTION 0x00
54#define DEVICE_PAIRED_PARAM_EQUAD_ID_LSB 0x01
55#define DEVICE_PAIRED_PARAM_EQUAD_ID_MSB 0x02
56#define DEVICE_PAIRED_RF_REPORT_TYPE 0x03
57
58/* Device Un-Paired Notification */
59#define REPORT_TYPE_NOTIF_DEVICE_UNPAIRED 0x40
60
61
62/* Connection Status Notification */
63#define REPORT_TYPE_NOTIF_CONNECTION_STATUS 0x42
64#define CONNECTION_STATUS_PARAM_STATUS 0x00
65#define STATUS_LINKLOSS 0x01
66
67/* Error Notification */
68#define REPORT_TYPE_NOTIF_ERROR 0x7F
69#define NOTIF_ERROR_PARAM_ETYPE 0x00
70#define ETYPE_KEEPALIVE_TIMEOUT 0x01
71
72/* supported DJ HID && RF report types */
73#define REPORT_TYPE_KEYBOARD 0x01
74#define REPORT_TYPE_MOUSE 0x02
75#define REPORT_TYPE_CONSUMER_CONTROL 0x03
76#define REPORT_TYPE_SYSTEM_CONTROL 0x04
77#define REPORT_TYPE_MEDIA_CENTER 0x08
78#define REPORT_TYPE_LEDS 0x0E
79
80/* RF Report types bitfield */
81#define STD_KEYBOARD 0x00000002
82#define STD_MOUSE 0x00000004
83#define MULTIMEDIA 0x00000008
84#define POWER_KEYS 0x00000010
85#define MEDIA_CENTER 0x00000100
86#define KBD_LEDS 0x00004000
87
88struct dj_report {
89 u8 report_id;
90 u8 device_index;
91 u8 report_type;
92 u8 report_params[DJREPORT_SHORT_LENGTH - 3];
93};
94
95struct dj_receiver_dev {
96 struct hid_device *hdev;
97 struct dj_device *paired_dj_devices[DJ_MAX_PAIRED_DEVICES];
98 struct work_struct work;
99 struct kfifo notif_fifo;
100 spinlock_t lock;
101};
102
103struct dj_device {
104 struct hid_device *hdev;
105 struct dj_receiver_dev *dj_receiver_dev;
106 u32 reports_supported;
107 u8 device_index;
108};
109
110/**
111 * is_dj_device - know if the given dj_device is not the receiver.
112 * @dj_dev: the dj device to test
113 *
114 * This macro tests if a struct dj_device pointer is a device created
115 * by the bus enumarator.
116 */
117#define is_dj_device(dj_dev) \
118 (&(dj_dev)->dj_receiver_dev->hdev->dev == (dj_dev)->hdev->dev.parent)
119
120#endif