-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrigger6_commands.c
77 lines (60 loc) · 1.96 KB
/
trigger6_commands.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "trigger6.h"
int trigger6_read_modes(struct trigger6_device *trigger6, int output_index,
int byte_offset, void *data, int length)
{
int ret;
struct usb_interface *intf = trigger6->intf;
struct usb_device *usb_dev = interface_to_usbdev(intf);
ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), 0x89,
USB_DIR_IN | USB_TYPE_VENDOR, output_index,
byte_offset, data, length, USB_CTRL_GET_TIMEOUT);
return ret;
}
int trigger6_read_connector_status(struct trigger6_device *trigger6,
int output_index)
{
int ret;
struct usb_interface *intf = trigger6->intf;
struct usb_device *usb_dev = interface_to_usbdev(intf);
u8 *status;
status = kmalloc(1, GFP_KERNEL);
ret = usb_control_msg(usb_dev, usb_rcvctrlpipe(usb_dev, 0), 0x87,
USB_DIR_IN | USB_TYPE_VENDOR, output_index, 0,
status, 1, USB_CTRL_GET_TIMEOUT);
if (ret < 0)
return ret;
ret = *status;
kfree(status);
return ret;
}
int trigger6_enable_output(struct trigger6_device *trigger6)
{
int ret;
struct usb_interface *intf = trigger6->intf;
struct usb_device *usb_dev = interface_to_usbdev(intf);
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), 0x3,
USB_TYPE_VENDOR, 0, 0x0001, NULL, 0,
USB_CTRL_SET_TIMEOUT);
return ret;
}
int trigger6_disable_output(struct trigger6_device *trigger6)
{
int ret;
struct usb_interface *intf = trigger6->intf;
struct usb_device *usb_dev = interface_to_usbdev(intf);
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), 0x3,
USB_TYPE_VENDOR, 0, 0x0000, NULL, 0,
USB_CTRL_SET_TIMEOUT);
return ret;
}
int trigger6_set_resolution(struct trigger6_device *trigger6,
struct trigger6_mode *mode)
{
int ret;
struct usb_interface *intf = trigger6->intf;
struct usb_device *usb_dev = interface_to_usbdev(intf);
ret = usb_control_msg(usb_dev, usb_sndctrlpipe(usb_dev, 0), 0x12,
USB_TYPE_VENDOR, 0, 0, mode, 32,
USB_CTRL_SET_TIMEOUT);
return ret;
}