Linux Audio

Check our new training course

Loading...
v4.6
  1/*
  2 * Force feedback support for DragonRise Inc. game controllers
  3 *
  4 * From what I have gathered, these devices are mass produced in China and are
  5 * distributed under several vendors. They often share the same design as
  6 * the original PlayStation DualShock controller.
  7 *
  8 * 0079:0006 "DragonRise Inc.   Generic   USB  Joystick  "
  9 *  - tested with a Tesun USB-703 game controller.
 10 *
 11 * Copyright (c) 2009 Richard Walmsley <richwalm@gmail.com>
 12 */
 13
 14/*
 15 * This program is free software; you can redistribute it and/or modify
 16 * it under the terms of the GNU General Public License as published by
 17 * the Free Software Foundation; either version 2 of the License, or
 18 * (at your option) any later version.
 19 *
 20 * This program is distributed in the hope that it will be useful,
 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 23 * GNU General Public License for more details.
 24 *
 25 * You should have received a copy of the GNU General Public License
 26 * along with this program; if not, write to the Free Software
 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 28 */
 29
 30#include <linux/input.h>
 31#include <linux/slab.h>
 
 32#include <linux/hid.h>
 33#include <linux/module.h>
 34
 35#include "hid-ids.h"
 36
 37#ifdef CONFIG_DRAGONRISE_FF
 
 38
 39struct drff_device {
 40	struct hid_report *report;
 41};
 42
 43static int drff_play(struct input_dev *dev, void *data,
 44				 struct ff_effect *effect)
 45{
 46	struct hid_device *hid = input_get_drvdata(dev);
 47	struct drff_device *drff = data;
 48	int strong, weak;
 49
 50	strong = effect->u.rumble.strong_magnitude;
 51	weak = effect->u.rumble.weak_magnitude;
 52
 53	dbg_hid("called with 0x%04x 0x%04x", strong, weak);
 54
 55	if (strong || weak) {
 56		strong = strong * 0xff / 0xffff;
 57		weak = weak * 0xff / 0xffff;
 58
 59		/* While reverse engineering this device, I found that when
 60		   this value is set, it causes the strong rumble to function
 61		   at a near maximum speed, so we'll bypass it. */
 62		if (weak == 0x0a)
 63			weak = 0x0b;
 64
 65		drff->report->field[0]->value[0] = 0x51;
 66		drff->report->field[0]->value[1] = 0x00;
 67		drff->report->field[0]->value[2] = weak;
 68		drff->report->field[0]->value[4] = strong;
 69		hid_hw_request(hid, drff->report, HID_REQ_SET_REPORT);
 70
 71		drff->report->field[0]->value[0] = 0xfa;
 72		drff->report->field[0]->value[1] = 0xfe;
 73	} else {
 74		drff->report->field[0]->value[0] = 0xf3;
 75		drff->report->field[0]->value[1] = 0x00;
 76	}
 77
 78	drff->report->field[0]->value[2] = 0x00;
 79	drff->report->field[0]->value[4] = 0x00;
 80	dbg_hid("running with 0x%02x 0x%02x", strong, weak);
 81	hid_hw_request(hid, drff->report, HID_REQ_SET_REPORT);
 82
 83	return 0;
 84}
 85
 86static int drff_init(struct hid_device *hid)
 87{
 88	struct drff_device *drff;
 89	struct hid_report *report;
 90	struct hid_input *hidinput = list_first_entry(&hid->inputs,
 91						struct hid_input, list);
 92	struct list_head *report_list =
 93			&hid->report_enum[HID_OUTPUT_REPORT].report_list;
 94	struct input_dev *dev = hidinput->input;
 95	int error;
 96
 97	if (list_empty(report_list)) {
 98		hid_err(hid, "no output reports found\n");
 99		return -ENODEV;
100	}
101
102	report = list_first_entry(report_list, struct hid_report, list);
103	if (report->maxfield < 1) {
104		hid_err(hid, "no fields in the report\n");
105		return -ENODEV;
106	}
107
108	if (report->field[0]->report_count < 7) {
109		hid_err(hid, "not enough values in the field\n");
110		return -ENODEV;
111	}
112
113	drff = kzalloc(sizeof(struct drff_device), GFP_KERNEL);
114	if (!drff)
115		return -ENOMEM;
116
117	set_bit(FF_RUMBLE, dev->ffbit);
118
119	error = input_ff_create_memless(dev, drff, drff_play);
120	if (error) {
121		kfree(drff);
122		return error;
123	}
124
125	drff->report = report;
126	drff->report->field[0]->value[0] = 0xf3;
127	drff->report->field[0]->value[1] = 0x00;
128	drff->report->field[0]->value[2] = 0x00;
129	drff->report->field[0]->value[3] = 0x00;
130	drff->report->field[0]->value[4] = 0x00;
131	drff->report->field[0]->value[5] = 0x00;
132	drff->report->field[0]->value[6] = 0x00;
133	hid_hw_request(hid, drff->report, HID_REQ_SET_REPORT);
134
135	hid_info(hid, "Force Feedback for DragonRise Inc. "
136		 "game controllers by Richard Walmsley <richwalm@gmail.com>\n");
137
138	return 0;
139}
140#else
141static inline int drff_init(struct hid_device *hid)
142{
143	return 0;
144}
145#endif
146
147/*
148 * The original descriptor of joystick with PID 0x0011, represented by DVTech PC
149 * JS19. It seems both copied from another device and a result of confusion
150 * either about the specification or about the program used to create the
151 * descriptor. In any case, it's a wonder it works on Windows.
152 *
153 *  Usage Page (Desktop),             ; Generic desktop controls (01h)
154 *  Usage (Joystick),                 ; Joystick (04h, application collection)
155 *  Collection (Application),
156 *    Collection (Logical),
157 *      Report Size (8),
158 *      Report Count (5),
159 *      Logical Minimum (0),
160 *      Logical Maximum (255),
161 *      Physical Minimum (0),
162 *      Physical Maximum (255),
163 *      Usage (X),                    ; X (30h, dynamic value)
164 *      Usage (X),                    ; X (30h, dynamic value)
165 *      Usage (X),                    ; X (30h, dynamic value)
166 *      Usage (X),                    ; X (30h, dynamic value)
167 *      Usage (Y),                    ; Y (31h, dynamic value)
168 *      Input (Variable),
169 *      Report Size (4),
170 *      Report Count (1),
171 *      Logical Maximum (7),
172 *      Physical Maximum (315),
173 *      Unit (Degrees),
174 *      Usage (00h),
175 *      Input (Variable, Null State),
176 *      Unit,
177 *      Report Size (1),
178 *      Report Count (10),
179 *      Logical Maximum (1),
180 *      Physical Maximum (1),
181 *      Usage Page (Button),          ; Button (09h)
182 *      Usage Minimum (01h),
183 *      Usage Maximum (0Ah),
184 *      Input (Variable),
185 *      Usage Page (FF00h),           ; FF00h, vendor-defined
186 *      Report Size (1),
187 *      Report Count (10),
188 *      Logical Maximum (1),
189 *      Physical Maximum (1),
190 *      Usage (01h),
191 *      Input (Variable),
192 *    End Collection,
193 *    Collection (Logical),
194 *      Report Size (8),
195 *      Report Count (4),
196 *      Physical Maximum (255),
197 *      Logical Maximum (255),
198 *      Usage (02h),
199 *      Output (Variable),
200 *    End Collection,
201 *  End Collection
202 */
203
204/* Size of the original descriptor of the PID 0x0011 joystick */
205#define PID0011_RDESC_ORIG_SIZE	101
206
207/* Fixed report descriptor for PID 0x011 joystick */
208static __u8 pid0011_rdesc_fixed[] = {
209	0x05, 0x01,         /*  Usage Page (Desktop),           */
210	0x09, 0x04,         /*  Usage (Joystick),               */
211	0xA1, 0x01,         /*  Collection (Application),       */
212	0xA1, 0x02,         /*      Collection (Logical),       */
213	0x14,               /*          Logical Minimum (0),    */
214	0x75, 0x08,         /*          Report Size (8),        */
215	0x95, 0x03,         /*          Report Count (3),       */
216	0x81, 0x01,         /*          Input (Constant),       */
217	0x26, 0xFF, 0x00,   /*          Logical Maximum (255),  */
218	0x95, 0x02,         /*          Report Count (2),       */
219	0x09, 0x30,         /*          Usage (X),              */
220	0x09, 0x31,         /*          Usage (Y),              */
221	0x81, 0x02,         /*          Input (Variable),       */
222	0x75, 0x01,         /*          Report Size (1),        */
223	0x95, 0x04,         /*          Report Count (4),       */
224	0x81, 0x01,         /*          Input (Constant),       */
225	0x25, 0x01,         /*          Logical Maximum (1),    */
226	0x95, 0x0A,         /*          Report Count (10),      */
227	0x05, 0x09,         /*          Usage Page (Button),    */
228	0x19, 0x01,         /*          Usage Minimum (01h),    */
229	0x29, 0x0A,         /*          Usage Maximum (0Ah),    */
230	0x81, 0x02,         /*          Input (Variable),       */
231	0x95, 0x0A,         /*          Report Count (10),      */
232	0x81, 0x01,         /*          Input (Constant),       */
233	0xC0,               /*      End Collection,             */
234	0xC0                /*  End Collection                  */
235};
236
237static __u8 pid0006_rdesc_fixed[] = {
238	0x05, 0x01,        /* Usage Page (Generic Desktop)	*/
239	0x09, 0x04,        /* Usage (Joystick)			*/
240	0xA1, 0x01,        /* Collection (Application)		*/
241	0xA1, 0x02,        /*   Collection (Logical)		*/
242	0x75, 0x08,        /*     Report Size (8)		*/
243	0x95, 0x05,        /*     Report Count (5)		*/
244	0x15, 0x00,        /*     Logical Minimum (0)		*/
245	0x26, 0xFF, 0x00,  /*     Logical Maximum (255)		*/
246	0x35, 0x00,        /*     Physical Minimum (0)		*/
247	0x46, 0xFF, 0x00,  /*     Physical Maximum (255)	*/
248	0x09, 0x30,        /*     Usage (X)			*/
249	0x09, 0x33,        /*     Usage (Ry)			*/
250	0x09, 0x32,        /*     Usage (Z)			*/
251	0x09, 0x31,        /*     Usage (Y)			*/
252	0x09, 0x34,        /*     Usage (Ry)			*/
253	0x81, 0x02,        /*     Input (Variable)		*/
254	0x75, 0x04,        /*     Report Size (4)		*/
255	0x95, 0x01,        /*     Report Count (1)		*/
256	0x25, 0x07,        /*     Logical Maximum (7)		*/
257	0x46, 0x3B, 0x01,  /*     Physical Maximum (315)	*/
258	0x65, 0x14,        /*     Unit (Centimeter)		*/
259	0x09, 0x39,        /*     Usage (Hat switch)		*/
260	0x81, 0x42,        /*     Input (Variable)		*/
261	0x65, 0x00,        /*     Unit (None)			*/
262	0x75, 0x01,        /*     Report Size (1)		*/
263	0x95, 0x0C,        /*     Report Count (12)		*/
264	0x25, 0x01,        /*     Logical Maximum (1)		*/
265	0x45, 0x01,        /*     Physical Maximum (1)		*/
266	0x05, 0x09,        /*     Usage Page (Button)		*/
267	0x19, 0x01,        /*     Usage Minimum (0x01)		*/
268	0x29, 0x0C,        /*     Usage Maximum (0x0C)		*/
269	0x81, 0x02,        /*     Input (Variable)		*/
270	0x06, 0x00, 0xFF,  /*     Usage Page (Vendor Defined)	*/
271	0x75, 0x01,        /*     Report Size (1)		*/
272	0x95, 0x08,        /*     Report Count (8)		*/
273	0x25, 0x01,        /*     Logical Maximum (1)		*/
274	0x45, 0x01,        /*     Physical Maximum (1)		*/
275	0x09, 0x01,        /*     Usage (0x01)			*/
276	0x81, 0x02,        /*     Input (Variable)		*/
277	0xC0,              /*   End Collection			*/
278	0xA1, 0x02,        /*   Collection (Logical)		*/
279	0x75, 0x08,        /*     Report Size (8)		*/
280	0x95, 0x07,        /*     Report Count (7)		*/
281	0x46, 0xFF, 0x00,  /*     Physical Maximum (255)	*/
282	0x26, 0xFF, 0x00,  /*     Logical Maximum (255)		*/
283	0x09, 0x02,        /*     Usage (0x02)			*/
284	0x91, 0x02,        /*     Output (Variable)		*/
285	0xC0,              /*   End Collection			*/
286	0xC0               /* End Collection			*/
287};
288
289static __u8 *dr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
290				unsigned int *rsize)
291{
292	switch (hdev->product) {
293	case 0x0011:
294		if (*rsize == PID0011_RDESC_ORIG_SIZE) {
295			rdesc = pid0011_rdesc_fixed;
296			*rsize = sizeof(pid0011_rdesc_fixed);
297		}
298		break;
299	case 0x0006:
300		if (*rsize == sizeof(pid0006_rdesc_fixed)) {
301			rdesc = pid0006_rdesc_fixed;
302			*rsize = sizeof(pid0006_rdesc_fixed);
303		}
304		break;
305	}
306	return rdesc;
307}
308
309static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id)
310{
311	int ret;
312
313	dev_dbg(&hdev->dev, "DragonRise Inc. HID hardware probe...");
314
315	ret = hid_parse(hdev);
316	if (ret) {
317		hid_err(hdev, "parse failed\n");
318		goto err;
319	}
320
321	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
322	if (ret) {
323		hid_err(hdev, "hw start failed\n");
324		goto err;
325	}
326
327	switch (hdev->product) {
328	case 0x0006:
329		ret = drff_init(hdev);
330		if (ret) {
331			dev_err(&hdev->dev, "force feedback init failed\n");
332			hid_hw_stop(hdev);
333			goto err;
334		}
335		break;
336	}
337
338	return 0;
339err:
340	return ret;
341}
342
343static const struct hid_device_id dr_devices[] = {
344	{ HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006),  },
345	{ HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011),  },
346	{ }
347};
348MODULE_DEVICE_TABLE(hid, dr_devices);
349
350static struct hid_driver dr_driver = {
351	.name = "dragonrise",
352	.id_table = dr_devices,
353	.report_fixup = dr_report_fixup,
354	.probe = dr_probe,
355};
356module_hid_driver(dr_driver);
357
 
 
 
 
 
 
 
 
 
 
 
 
358MODULE_LICENSE("GPL");
v3.1
  1/*
  2 * Force feedback support for DragonRise Inc. game controllers
  3 *
  4 * From what I have gathered, these devices are mass produced in China and are
  5 * distributed under several vendors. They often share the same design as
  6 * the original PlayStation DualShock controller.
  7 *
  8 * 0079:0006 "DragonRise Inc.   Generic   USB  Joystick  "
  9 *  - tested with a Tesun USB-703 game controller.
 10 *
 11 * Copyright (c) 2009 Richard Walmsley <richwalm@gmail.com>
 12 */
 13
 14/*
 15 * This program is free software; you can redistribute it and/or modify
 16 * it under the terms of the GNU General Public License as published by
 17 * the Free Software Foundation; either version 2 of the License, or
 18 * (at your option) any later version.
 19 *
 20 * This program is distributed in the hope that it will be useful,
 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 23 * GNU General Public License for more details.
 24 *
 25 * You should have received a copy of the GNU General Public License
 26 * along with this program; if not, write to the Free Software
 27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 28 */
 29
 30#include <linux/input.h>
 31#include <linux/slab.h>
 32#include <linux/usb.h>
 33#include <linux/hid.h>
 
 34
 35#include "hid-ids.h"
 36
 37#ifdef CONFIG_DRAGONRISE_FF
 38#include "usbhid/usbhid.h"
 39
 40struct drff_device {
 41	struct hid_report *report;
 42};
 43
 44static int drff_play(struct input_dev *dev, void *data,
 45				 struct ff_effect *effect)
 46{
 47	struct hid_device *hid = input_get_drvdata(dev);
 48	struct drff_device *drff = data;
 49	int strong, weak;
 50
 51	strong = effect->u.rumble.strong_magnitude;
 52	weak = effect->u.rumble.weak_magnitude;
 53
 54	dbg_hid("called with 0x%04x 0x%04x", strong, weak);
 55
 56	if (strong || weak) {
 57		strong = strong * 0xff / 0xffff;
 58		weak = weak * 0xff / 0xffff;
 59
 60		/* While reverse engineering this device, I found that when
 61		   this value is set, it causes the strong rumble to function
 62		   at a near maximum speed, so we'll bypass it. */
 63		if (weak == 0x0a)
 64			weak = 0x0b;
 65
 66		drff->report->field[0]->value[0] = 0x51;
 67		drff->report->field[0]->value[1] = 0x00;
 68		drff->report->field[0]->value[2] = weak;
 69		drff->report->field[0]->value[4] = strong;
 70		usbhid_submit_report(hid, drff->report, USB_DIR_OUT);
 71
 72		drff->report->field[0]->value[0] = 0xfa;
 73		drff->report->field[0]->value[1] = 0xfe;
 74	} else {
 75		drff->report->field[0]->value[0] = 0xf3;
 76		drff->report->field[0]->value[1] = 0x00;
 77	}
 78
 79	drff->report->field[0]->value[2] = 0x00;
 80	drff->report->field[0]->value[4] = 0x00;
 81	dbg_hid("running with 0x%02x 0x%02x", strong, weak);
 82	usbhid_submit_report(hid, drff->report, USB_DIR_OUT);
 83
 84	return 0;
 85}
 86
 87static int drff_init(struct hid_device *hid)
 88{
 89	struct drff_device *drff;
 90	struct hid_report *report;
 91	struct hid_input *hidinput = list_first_entry(&hid->inputs,
 92						struct hid_input, list);
 93	struct list_head *report_list =
 94			&hid->report_enum[HID_OUTPUT_REPORT].report_list;
 95	struct input_dev *dev = hidinput->input;
 96	int error;
 97
 98	if (list_empty(report_list)) {
 99		hid_err(hid, "no output reports found\n");
100		return -ENODEV;
101	}
102
103	report = list_first_entry(report_list, struct hid_report, list);
104	if (report->maxfield < 1) {
105		hid_err(hid, "no fields in the report\n");
106		return -ENODEV;
107	}
108
109	if (report->field[0]->report_count < 7) {
110		hid_err(hid, "not enough values in the field\n");
111		return -ENODEV;
112	}
113
114	drff = kzalloc(sizeof(struct drff_device), GFP_KERNEL);
115	if (!drff)
116		return -ENOMEM;
117
118	set_bit(FF_RUMBLE, dev->ffbit);
119
120	error = input_ff_create_memless(dev, drff, drff_play);
121	if (error) {
122		kfree(drff);
123		return error;
124	}
125
126	drff->report = report;
127	drff->report->field[0]->value[0] = 0xf3;
128	drff->report->field[0]->value[1] = 0x00;
129	drff->report->field[0]->value[2] = 0x00;
130	drff->report->field[0]->value[3] = 0x00;
131	drff->report->field[0]->value[4] = 0x00;
132	drff->report->field[0]->value[5] = 0x00;
133	drff->report->field[0]->value[6] = 0x00;
134	usbhid_submit_report(hid, drff->report, USB_DIR_OUT);
135
136	hid_info(hid, "Force Feedback for DragonRise Inc. "
137		 "game controllers by Richard Walmsley <richwalm@gmail.com>\n");
138
139	return 0;
140}
141#else
142static inline int drff_init(struct hid_device *hid)
143{
144	return 0;
145}
146#endif
147
148/*
149 * The original descriptor of joystick with PID 0x0011, represented by DVTech PC
150 * JS19. It seems both copied from another device and a result of confusion
151 * either about the specification or about the program used to create the
152 * descriptor. In any case, it's a wonder it works on Windows.
153 *
154 *  Usage Page (Desktop),             ; Generic desktop controls (01h)
155 *  Usage (Joystik),                  ; Joystik (04h, application collection)
156 *  Collection (Application),
157 *    Collection (Logical),
158 *      Report Size (8),
159 *      Report Count (5),
160 *      Logical Minimum (0),
161 *      Logical Maximum (255),
162 *      Physical Minimum (0),
163 *      Physical Maximum (255),
164 *      Usage (X),                    ; X (30h, dynamic value)
165 *      Usage (X),                    ; X (30h, dynamic value)
166 *      Usage (X),                    ; X (30h, dynamic value)
167 *      Usage (X),                    ; X (30h, dynamic value)
168 *      Usage (Y),                    ; Y (31h, dynamic value)
169 *      Input (Variable),
170 *      Report Size (4),
171 *      Report Count (1),
172 *      Logical Maximum (7),
173 *      Physical Maximum (315),
174 *      Unit (Degrees),
175 *      Usage (00h),
176 *      Input (Variable, Null State),
177 *      Unit,
178 *      Report Size (1),
179 *      Report Count (10),
180 *      Logical Maximum (1),
181 *      Physical Maximum (1),
182 *      Usage Page (Button),          ; Button (09h)
183 *      Usage Minimum (01h),
184 *      Usage Maximum (0Ah),
185 *      Input (Variable),
186 *      Usage Page (FF00h),           ; FF00h, vendor-defined
187 *      Report Size (1),
188 *      Report Count (10),
189 *      Logical Maximum (1),
190 *      Physical Maximum (1),
191 *      Usage (01h),
192 *      Input (Variable),
193 *    End Collection,
194 *    Collection (Logical),
195 *      Report Size (8),
196 *      Report Count (4),
197 *      Physical Maximum (255),
198 *      Logical Maximum (255),
199 *      Usage (02h),
200 *      Output (Variable),
201 *    End Collection,
202 *  End Collection
203 */
204
205/* Size of the original descriptor of the PID 0x0011 joystick */
206#define PID0011_RDESC_ORIG_SIZE	101
207
208/* Fixed report descriptor for PID 0x011 joystick */
209static __u8 pid0011_rdesc_fixed[] = {
210	0x05, 0x01,         /*  Usage Page (Desktop),           */
211	0x09, 0x04,         /*  Usage (Joystik),                */
212	0xA1, 0x01,         /*  Collection (Application),       */
213	0xA1, 0x02,         /*      Collection (Logical),       */
214	0x14,               /*          Logical Minimum (0),    */
215	0x75, 0x08,         /*          Report Size (8),        */
216	0x95, 0x03,         /*          Report Count (3),       */
217	0x81, 0x01,         /*          Input (Constant),       */
218	0x26, 0xFF, 0x00,   /*          Logical Maximum (255),  */
219	0x95, 0x02,         /*          Report Count (2),       */
220	0x09, 0x30,         /*          Usage (X),              */
221	0x09, 0x31,         /*          Usage (Y),              */
222	0x81, 0x02,         /*          Input (Variable),       */
223	0x75, 0x01,         /*          Report Size (1),        */
224	0x95, 0x04,         /*          Report Count (4),       */
225	0x81, 0x01,         /*          Input (Constant),       */
226	0x25, 0x01,         /*          Logical Maximum (1),    */
227	0x95, 0x0A,         /*          Report Count (10),      */
228	0x05, 0x09,         /*          Usage Page (Button),    */
229	0x19, 0x01,         /*          Usage Minimum (01h),    */
230	0x29, 0x0A,         /*          Usage Maximum (0Ah),    */
231	0x81, 0x02,         /*          Input (Variable),       */
232	0x95, 0x0A,         /*          Report Count (10),      */
233	0x81, 0x01,         /*          Input (Constant),       */
234	0xC0,               /*      End Collection,             */
235	0xC0                /*  End Collection                  */
236};
237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238static __u8 *dr_report_fixup(struct hid_device *hdev, __u8 *rdesc,
239				unsigned int *rsize)
240{
241	switch (hdev->product) {
242	case 0x0011:
243		if (*rsize == PID0011_RDESC_ORIG_SIZE) {
244			rdesc = pid0011_rdesc_fixed;
245			*rsize = sizeof(pid0011_rdesc_fixed);
246		}
247		break;
 
 
 
 
 
 
248	}
249	return rdesc;
250}
251
252static int dr_probe(struct hid_device *hdev, const struct hid_device_id *id)
253{
254	int ret;
255
256	dev_dbg(&hdev->dev, "DragonRise Inc. HID hardware probe...");
257
258	ret = hid_parse(hdev);
259	if (ret) {
260		hid_err(hdev, "parse failed\n");
261		goto err;
262	}
263
264	ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT & ~HID_CONNECT_FF);
265	if (ret) {
266		hid_err(hdev, "hw start failed\n");
267		goto err;
268	}
269
270	switch (hdev->product) {
271	case 0x0006:
272		ret = drff_init(hdev);
273		if (ret) {
274			dev_err(&hdev->dev, "force feedback init failed\n");
275			hid_hw_stop(hdev);
276			goto err;
277		}
278		break;
279	}
280
281	return 0;
282err:
283	return ret;
284}
285
286static const struct hid_device_id dr_devices[] = {
287	{ HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006),  },
288	{ HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0011),  },
289	{ }
290};
291MODULE_DEVICE_TABLE(hid, dr_devices);
292
293static struct hid_driver dr_driver = {
294	.name = "dragonrise",
295	.id_table = dr_devices,
296	.report_fixup = dr_report_fixup,
297	.probe = dr_probe,
298};
 
299
300static int __init dr_init(void)
301{
302	return hid_register_driver(&dr_driver);
303}
304
305static void __exit dr_exit(void)
306{
307	hid_unregister_driver(&dr_driver);
308}
309
310module_init(dr_init);
311module_exit(dr_exit);
312MODULE_LICENSE("GPL");