diff options
Diffstat (limited to 'drivers/media/dvb/dvb-usb/vp7045.c')
-rw-r--r-- | drivers/media/dvb/dvb-usb/vp7045.c | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c index f13791ca5994..3db89e3cb0bb 100644 --- a/drivers/media/dvb/dvb-usb/vp7045.c +++ b/drivers/media/dvb/dvb-usb/vp7045.c | |||
@@ -28,9 +28,9 @@ DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); | |||
28 | int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec) | 28 | int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, int inlen, int msec) |
29 | { | 29 | { |
30 | int ret = 0; | 30 | int ret = 0; |
31 | u8 inbuf[12] = { 0 }, outbuf[20] = { 0 }; | 31 | u8 *buf = d->priv; |
32 | 32 | ||
33 | outbuf[0] = cmd; | 33 | buf[0] = cmd; |
34 | 34 | ||
35 | if (outlen > 19) | 35 | if (outlen > 19) |
36 | outlen = 19; | 36 | outlen = 19; |
@@ -38,19 +38,21 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, | |||
38 | if (inlen > 11) | 38 | if (inlen > 11) |
39 | inlen = 11; | 39 | inlen = 11; |
40 | 40 | ||
41 | ret = mutex_lock_interruptible(&d->usb_mutex); | ||
42 | if (ret) | ||
43 | return ret; | ||
44 | |||
41 | if (out != NULL && outlen > 0) | 45 | if (out != NULL && outlen > 0) |
42 | memcpy(&outbuf[1], out, outlen); | 46 | memcpy(&buf[1], out, outlen); |
43 | 47 | ||
44 | deb_xfer("out buffer: "); | 48 | deb_xfer("out buffer: "); |
45 | debug_dump(outbuf,outlen+1,deb_xfer); | 49 | debug_dump(buf, outlen+1, deb_xfer); |
46 | 50 | ||
47 | if ((ret = mutex_lock_interruptible(&d->usb_mutex))) | ||
48 | return ret; | ||
49 | 51 | ||
50 | if (usb_control_msg(d->udev, | 52 | if (usb_control_msg(d->udev, |
51 | usb_sndctrlpipe(d->udev,0), | 53 | usb_sndctrlpipe(d->udev,0), |
52 | TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, | 54 | TH_COMMAND_OUT, USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, |
53 | outbuf, 20, 2000) != 20) { | 55 | buf, 20, 2000) != 20) { |
54 | err("USB control message 'out' went wrong."); | 56 | err("USB control message 'out' went wrong."); |
55 | ret = -EIO; | 57 | ret = -EIO; |
56 | goto unlock; | 58 | goto unlock; |
@@ -61,17 +63,17 @@ int vp7045_usb_op(struct dvb_usb_device *d, u8 cmd, u8 *out, int outlen, u8 *in, | |||
61 | if (usb_control_msg(d->udev, | 63 | if (usb_control_msg(d->udev, |
62 | usb_rcvctrlpipe(d->udev,0), | 64 | usb_rcvctrlpipe(d->udev,0), |
63 | TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, | 65 | TH_COMMAND_IN, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, |
64 | inbuf, 12, 2000) != 12) { | 66 | buf, 12, 2000) != 12) { |
65 | err("USB control message 'in' went wrong."); | 67 | err("USB control message 'in' went wrong."); |
66 | ret = -EIO; | 68 | ret = -EIO; |
67 | goto unlock; | 69 | goto unlock; |
68 | } | 70 | } |
69 | 71 | ||
70 | deb_xfer("in buffer: "); | 72 | deb_xfer("in buffer: "); |
71 | debug_dump(inbuf,12,deb_xfer); | 73 | debug_dump(buf, 12, deb_xfer); |
72 | 74 | ||
73 | if (in != NULL && inlen > 0) | 75 | if (in != NULL && inlen > 0) |
74 | memcpy(in,&inbuf[1],inlen); | 76 | memcpy(in, &buf[1], inlen); |
75 | 77 | ||
76 | unlock: | 78 | unlock: |
77 | mutex_unlock(&d->usb_mutex); | 79 | mutex_unlock(&d->usb_mutex); |
@@ -99,7 +101,7 @@ static int vp7045_power_ctrl(struct dvb_usb_device *d, int onoff) | |||
99 | 101 | ||
100 | /* The keymapping struct. Somehow this should be loaded to the driver, but | 102 | /* The keymapping struct. Somehow this should be loaded to the driver, but |
101 | * currently it is hardcoded. */ | 103 | * currently it is hardcoded. */ |
102 | static struct ir_scancode ir_codes_vp7045_table[] = { | 104 | static struct rc_map_table rc_map_vp7045_table[] = { |
103 | { 0x0016, KEY_POWER }, | 105 | { 0x0016, KEY_POWER }, |
104 | { 0x0010, KEY_MUTE }, | 106 | { 0x0010, KEY_MUTE }, |
105 | { 0x0003, KEY_1 }, | 107 | { 0x0003, KEY_1 }, |
@@ -165,10 +167,10 @@ static int vp7045_rc_query(struct dvb_usb_device *d, u32 *event, int *state) | |||
165 | return 0; | 167 | return 0; |
166 | } | 168 | } |
167 | 169 | ||
168 | for (i = 0; i < ARRAY_SIZE(ir_codes_vp7045_table); i++) | 170 | for (i = 0; i < ARRAY_SIZE(rc_map_vp7045_table); i++) |
169 | if (rc5_data(&ir_codes_vp7045_table[i]) == key) { | 171 | if (rc5_data(&rc_map_vp7045_table[i]) == key) { |
170 | *state = REMOTE_KEY_PRESSED; | 172 | *state = REMOTE_KEY_PRESSED; |
171 | *event = ir_codes_vp7045_table[i].keycode; | 173 | *event = rc_map_vp7045_table[i].keycode; |
172 | break; | 174 | break; |
173 | } | 175 | } |
174 | return 0; | 176 | return 0; |
@@ -222,8 +224,26 @@ static struct dvb_usb_device_properties vp7045_properties; | |||
222 | static int vp7045_usb_probe(struct usb_interface *intf, | 224 | static int vp7045_usb_probe(struct usb_interface *intf, |
223 | const struct usb_device_id *id) | 225 | const struct usb_device_id *id) |
224 | { | 226 | { |
225 | return dvb_usb_device_init(intf, &vp7045_properties, | 227 | struct dvb_usb_device *d; |
226 | THIS_MODULE, NULL, adapter_nr); | 228 | int ret = dvb_usb_device_init(intf, &vp7045_properties, |
229 | THIS_MODULE, &d, adapter_nr); | ||
230 | if (ret) | ||
231 | return ret; | ||
232 | |||
233 | d->priv = kmalloc(20, GFP_KERNEL); | ||
234 | if (!d->priv) { | ||
235 | dvb_usb_device_exit(intf); | ||
236 | return -ENOMEM; | ||
237 | } | ||
238 | |||
239 | return ret; | ||
240 | } | ||
241 | |||
242 | static void vp7045_usb_disconnect(struct usb_interface *intf) | ||
243 | { | ||
244 | struct dvb_usb_device *d = usb_get_intfdata(intf); | ||
245 | kfree(d->priv); | ||
246 | dvb_usb_device_exit(intf); | ||
227 | } | 247 | } |
228 | 248 | ||
229 | static struct usb_device_id vp7045_usb_table [] = { | 249 | static struct usb_device_id vp7045_usb_table [] = { |
@@ -238,6 +258,7 @@ MODULE_DEVICE_TABLE(usb, vp7045_usb_table); | |||
238 | static struct dvb_usb_device_properties vp7045_properties = { | 258 | static struct dvb_usb_device_properties vp7045_properties = { |
239 | .usb_ctrl = CYPRESS_FX2, | 259 | .usb_ctrl = CYPRESS_FX2, |
240 | .firmware = "dvb-usb-vp7045-01.fw", | 260 | .firmware = "dvb-usb-vp7045-01.fw", |
261 | .size_of_priv = sizeof(u8 *), | ||
241 | 262 | ||
242 | .num_adapters = 1, | 263 | .num_adapters = 1, |
243 | .adapter = { | 264 | .adapter = { |
@@ -261,8 +282,8 @@ static struct dvb_usb_device_properties vp7045_properties = { | |||
261 | 282 | ||
262 | .rc.legacy = { | 283 | .rc.legacy = { |
263 | .rc_interval = 400, | 284 | .rc_interval = 400, |
264 | .rc_key_map = ir_codes_vp7045_table, | 285 | .rc_map_table = rc_map_vp7045_table, |
265 | .rc_key_map_size = ARRAY_SIZE(ir_codes_vp7045_table), | 286 | .rc_map_size = ARRAY_SIZE(rc_map_vp7045_table), |
266 | .rc_query = vp7045_rc_query, | 287 | .rc_query = vp7045_rc_query, |
267 | }, | 288 | }, |
268 | 289 | ||
@@ -284,7 +305,7 @@ static struct dvb_usb_device_properties vp7045_properties = { | |||
284 | static struct usb_driver vp7045_usb_driver = { | 305 | static struct usb_driver vp7045_usb_driver = { |
285 | .name = "dvb_usb_vp7045", | 306 | .name = "dvb_usb_vp7045", |
286 | .probe = vp7045_usb_probe, | 307 | .probe = vp7045_usb_probe, |
287 | .disconnect = dvb_usb_device_exit, | 308 | .disconnect = vp7045_usb_disconnect, |
288 | .id_table = vp7045_usb_table, | 309 | .id_table = vp7045_usb_table, |
289 | }; | 310 | }; |
290 | 311 | ||