blob: fd28a5e0ca3b84b8407791421b25f8b17bf7815a [file] [log] [blame]
Nestor Lopez Casado534a7b82011-09-15 11:34:49 +02001#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
Nestor Lopez Casado844580f2011-09-20 15:59:03 +020030#define DJ_DEVICE_INDEX_MIN 1
31#define DJ_DEVICE_INDEX_MAX 6
Nestor Lopez Casado534a7b82011-09-15 11:34:49 +020032
33#define DJREPORT_SHORT_LENGTH 15
34#define DJREPORT_LONG_LENGTH 32
35
36#define REPORT_ID_DJ_SHORT 0x20
37#define REPORT_ID_DJ_LONG 0x21
38
39#define REPORT_TYPE_RFREPORT_FIRST 0x01
40#define REPORT_TYPE_RFREPORT_LAST 0x1F
41
42/* Command Switch to DJ mode */
43#define REPORT_TYPE_CMD_SWITCH 0x80
44#define CMD_SWITCH_PARAM_DEVBITFIELD 0x00
45#define CMD_SWITCH_PARAM_TIMEOUT_SECONDS 0x01
46#define TIMEOUT_NO_KEEPALIVE 0x00
47
48/* Command to Get the list of Paired devices */
49#define REPORT_TYPE_CMD_GET_PAIRED_DEVICES 0x81
50
51/* Device Paired Notification */
52#define REPORT_TYPE_NOTIF_DEVICE_PAIRED 0x41
53#define SPFUNCTION_MORE_NOTIF_EXPECTED 0x01
54#define SPFUNCTION_DEVICE_LIST_EMPTY 0x02
55#define DEVICE_PAIRED_PARAM_SPFUNCTION 0x00
56#define DEVICE_PAIRED_PARAM_EQUAD_ID_LSB 0x01
57#define DEVICE_PAIRED_PARAM_EQUAD_ID_MSB 0x02
58#define DEVICE_PAIRED_RF_REPORT_TYPE 0x03
59
60/* Device Un-Paired Notification */
61#define REPORT_TYPE_NOTIF_DEVICE_UNPAIRED 0x40
62
63
64/* Connection Status Notification */
65#define REPORT_TYPE_NOTIF_CONNECTION_STATUS 0x42
66#define CONNECTION_STATUS_PARAM_STATUS 0x00
67#define STATUS_LINKLOSS 0x01
68
69/* Error Notification */
70#define REPORT_TYPE_NOTIF_ERROR 0x7F
71#define NOTIF_ERROR_PARAM_ETYPE 0x00
72#define ETYPE_KEEPALIVE_TIMEOUT 0x01
73
74/* supported DJ HID && RF report types */
75#define REPORT_TYPE_KEYBOARD 0x01
76#define REPORT_TYPE_MOUSE 0x02
77#define REPORT_TYPE_CONSUMER_CONTROL 0x03
78#define REPORT_TYPE_SYSTEM_CONTROL 0x04
79#define REPORT_TYPE_MEDIA_CENTER 0x08
80#define REPORT_TYPE_LEDS 0x0E
81
82/* RF Report types bitfield */
83#define STD_KEYBOARD 0x00000002
84#define STD_MOUSE 0x00000004
85#define MULTIMEDIA 0x00000008
86#define POWER_KEYS 0x00000010
87#define MEDIA_CENTER 0x00000100
88#define KBD_LEDS 0x00004000
89
90struct dj_report {
91 u8 report_id;
92 u8 device_index;
93 u8 report_type;
94 u8 report_params[DJREPORT_SHORT_LENGTH - 3];
95};
96
97struct dj_receiver_dev {
98 struct hid_device *hdev;
Nestor Lopez Casado844580f2011-09-20 15:59:03 +020099 struct dj_device *paired_dj_devices[DJ_MAX_PAIRED_DEVICES +
100 DJ_DEVICE_INDEX_MIN];
Nestor Lopez Casado534a7b82011-09-15 11:34:49 +0200101 struct work_struct work;
102 struct kfifo notif_fifo;
103 spinlock_t lock;
Nestor Lopez Casado534a7b82011-09-15 11:34:49 +0200104};
105
106struct dj_device {
107 struct hid_device *hdev;
108 struct dj_receiver_dev *dj_receiver_dev;
109 u32 reports_supported;
110 u8 device_index;
111};
112
113/**
114 * is_dj_device - know if the given dj_device is not the receiver.
115 * @dj_dev: the dj device to test
116 *
117 * This macro tests if a struct dj_device pointer is a device created
118 * by the bus enumarator.
119 */
120#define is_dj_device(dj_dev) \
121 (&(dj_dev)->dj_receiver_dev->hdev->dev == (dj_dev)->hdev->dev.parent)
122
123#endif