HID: roccat: Add support for Roccat Kone[+] v2
[deliverable/linux.git] / drivers / hid / hid-roccat-kone.h
CommitLineData
14bf62cd
SA
1#ifndef __HID_ROCCAT_KONE_H
2#define __HID_ROCCAT_KONE_H
3
4/*
5 * Copyright (c) 2010 Stefan Achatz <erazor_de@users.sourceforge.net>
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14
15#include <linux/types.h>
16
bd3a2b96
SA
17/*
18 * Binary data structures used for hardware communication must have no padding.
19 */
14bf62cd
SA
20#pragma pack(push)
21#pragma pack(1)
22
23struct kone_keystroke {
24 uint8_t key;
25 uint8_t action;
26 uint16_t period; /* in milliseconds */
27};
28
29enum kone_keystroke_buttons {
30 kone_keystroke_button_1 = 0xf0, /* left mouse button */
31 kone_keystroke_button_2 = 0xf1, /* right mouse button */
32 kone_keystroke_button_3 = 0xf2, /* wheel */
33 kone_keystroke_button_9 = 0xf3, /* side button up */
34 kone_keystroke_button_8 = 0xf4 /* side button down */
35};
36
37enum kone_keystroke_actions {
38 kone_keystroke_action_press = 0,
39 kone_keystroke_action_release = 1
40};
41
42struct kone_button_info {
43 uint8_t number; /* range 1-8 */
44 uint8_t type;
45 uint8_t macro_type; /* 0 = short, 1 = overlong */
46 uint8_t macro_set_name[16]; /* can be max 15 chars long */
47 uint8_t macro_name[16]; /* can be max 15 chars long */
48 uint8_t count;
49 struct kone_keystroke keystrokes[20];
50};
51
52enum kone_button_info_types {
53 /* valid button types until firmware 1.32 */
54 kone_button_info_type_button_1 = 0x1, /* click (left mouse button) */
55 kone_button_info_type_button_2 = 0x2, /* menu (right mouse button)*/
56 kone_button_info_type_button_3 = 0x3, /* scroll (wheel) */
57 kone_button_info_type_double_click = 0x4,
58 kone_button_info_type_key = 0x5,
59 kone_button_info_type_macro = 0x6,
60 kone_button_info_type_off = 0x7,
61 /* TODO clarify function and rename */
62 kone_button_info_type_osd_xy_prescaling = 0x8,
63 kone_button_info_type_osd_dpi = 0x9,
64 kone_button_info_type_osd_profile = 0xa,
65 kone_button_info_type_button_9 = 0xb, /* ie forward */
66 kone_button_info_type_button_8 = 0xc, /* ie backward */
67 kone_button_info_type_dpi_up = 0xd, /* internal */
68 kone_button_info_type_dpi_down = 0xe, /* internal */
69 kone_button_info_type_button_7 = 0xf, /* tilt left */
70 kone_button_info_type_button_6 = 0x10, /* tilt right */
71 kone_button_info_type_profile_up = 0x11, /* internal */
72 kone_button_info_type_profile_down = 0x12, /* internal */
73 /* additional valid button types since firmware 1.38 */
74 kone_button_info_type_multimedia_open_player = 0x20,
75 kone_button_info_type_multimedia_next_track = 0x21,
76 kone_button_info_type_multimedia_prev_track = 0x22,
77 kone_button_info_type_multimedia_play_pause = 0x23,
78 kone_button_info_type_multimedia_stop = 0x24,
79 kone_button_info_type_multimedia_mute = 0x25,
80 kone_button_info_type_multimedia_volume_up = 0x26,
81 kone_button_info_type_multimedia_volume_down = 0x27
82};
83
73b3577d
SA
84enum kone_button_info_numbers {
85 kone_button_top = 1,
86 kone_button_wheel_tilt_left = 2,
87 kone_button_wheel_tilt_right = 3,
88 kone_button_forward = 4,
89 kone_button_backward = 5,
90 kone_button_middle = 6,
91 kone_button_plus = 7,
92 kone_button_minus = 8,
93};
94
14bf62cd
SA
95struct kone_light_info {
96 uint8_t number; /* number of light 1-5 */
97 uint8_t mod; /* 1 = on, 2 = off */
98 uint8_t red; /* range 0x00-0xff */
99 uint8_t green; /* range 0x00-0xff */
100 uint8_t blue; /* range 0x00-0xff */
101};
102
103struct kone_profile {
104 uint16_t size; /* always 975 */
105 uint16_t unused; /* always 0 */
106
107 /*
108 * range 1-5
109 * This number does not need to correspond with location where profile
110 * saved
111 */
112 uint8_t profile; /* range 1-5 */
113
114 uint16_t main_sensitivity; /* range 100-1000 */
115 uint8_t xy_sensitivity_enabled; /* 1 = on, 2 = off */
116 uint16_t x_sensitivity; /* range 100-1000 */
117 uint16_t y_sensitivity; /* range 100-1000 */
118 uint8_t dpi_rate; /* bit 1 = 800, ... */
119 uint8_t startup_dpi; /* range 1-6 */
120 uint8_t polling_rate; /* 1 = 125Hz, 2 = 500Hz, 3 = 1000Hz */
121 /* kone has no dcu
122 * value is always 2 in firmwares <= 1.32 and
123 * 1 in firmwares > 1.32
124 */
125 uint8_t dcu_flag;
126 uint8_t light_effect_1; /* range 1-3 */
127 uint8_t light_effect_2; /* range 1-5 */
128 uint8_t light_effect_3; /* range 1-4 */
129 uint8_t light_effect_speed; /* range 0-255 */
130
131 struct kone_light_info light_infos[5];
73b3577d 132 /* offset is kone_button_info_numbers - 1 */
14bf62cd
SA
133 struct kone_button_info button_infos[8];
134
135 uint16_t checksum; /* \brief holds checksum of struct */
136};
137
138enum kone_polling_rates {
139 kone_polling_rate_125 = 1,
140 kone_polling_rate_500 = 2,
141 kone_polling_rate_1000 = 3
142};
143
144struct kone_settings {
145 uint16_t size; /* always 36 */
146 uint8_t startup_profile; /* 1-5 */
147 uint8_t unknown1;
148 uint8_t tcu; /* 0 = off, 1 = on */
149 uint8_t unknown2[23];
150 uint8_t calibration_data[4];
151 uint8_t unknown3[2];
152 uint16_t checksum;
153};
154
155/*
156 * 12 byte mouse event read by interrupt_read
157 */
158struct kone_mouse_event {
159 uint8_t report_number; /* always 1 */
160 uint8_t button;
161 uint16_t x;
162 uint16_t y;
163 uint8_t wheel; /* up = 1, down = -1 */
164 uint8_t tilt; /* right = 1, left = -1 */
165 uint8_t unknown;
166 uint8_t event;
167 uint8_t value; /* press = 0, release = 1 */
168 uint8_t macro_key; /* 0 to 8 */
169};
170
171enum kone_mouse_events {
172 /* osd events are thought to be display on screen */
173 kone_mouse_event_osd_dpi = 0xa0,
174 kone_mouse_event_osd_profile = 0xb0,
175 /* TODO clarify meaning and occurence of kone_mouse_event_calibration */
176 kone_mouse_event_calibration = 0xc0,
177 kone_mouse_event_call_overlong_macro = 0xe0,
73b3577d 178 /* switch events notify if user changed values with mousebutton click */
14bf62cd
SA
179 kone_mouse_event_switch_dpi = 0xf0,
180 kone_mouse_event_switch_profile = 0xf1
181};
182
183enum kone_commands {
184 kone_command_profile = 0x5a,
185 kone_command_settings = 0x15a,
186 kone_command_firmware_version = 0x25a,
187 kone_command_weight = 0x45a,
188 kone_command_calibrate = 0x55a,
189 kone_command_confirm_write = 0x65a,
190 kone_command_firmware = 0xe5a
191};
192
206f5f2f
SA
193struct kone_roccat_report {
194 uint8_t event;
195 uint8_t value; /* holds dpi or profile value */
196 uint8_t key; /* macro key on overlong macro execution */
197};
198
14bf62cd
SA
199#pragma pack(pop)
200
201struct kone_device {
202 /*
203 * Storing actual values when we get informed about changes since there
204 * is no way of getting this information from the device on demand
205 */
206 int actual_profile, actual_dpi;
73b3577d
SA
207 /* Used for neutralizing abnormal button behaviour */
208 struct kone_mouse_event last_mouse_event;
209
14bf62cd
SA
210 /*
211 * It's unlikely that multiple sysfs attributes are accessed at a time,
212 * so only one mutex is used to secure hardware access and profiles and
213 * settings of this struct.
214 */
215 struct mutex kone_lock;
216
217 /*
218 * Storing the data here reduces IO and ensures that data is available
219 * when its needed (E.g. interrupt handler).
220 */
221 struct kone_profile profiles[5];
222 struct kone_settings settings;
223
224 /*
225 * firmware doesn't change unless firmware update is implemented,
226 * so it's read only once
227 */
228 int firmware_version;
206f5f2f
SA
229
230 int roccat_claimed;
231 int chrdev_minor;
14bf62cd
SA
232};
233
234#endif
This page took 0.059199 seconds and 5 git commands to generate.