diff options
Diffstat (limited to 'drivers/media/dvb/ttusb-dec')
-rw-r--r-- | drivers/media/dvb/ttusb-dec/ttusb_dec.c | 51 |
1 files changed, 32 insertions, 19 deletions
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c index 3d08fc83a75..832d179f26f 100644 --- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c | |||
@@ -152,7 +152,8 @@ struct ttusb_dec { | |||
152 | struct list_head filter_info_list; | 152 | struct list_head filter_info_list; |
153 | spinlock_t filter_info_list_lock; | 153 | spinlock_t filter_info_list_lock; |
154 | 154 | ||
155 | struct input_dev rc_input_dev; | 155 | struct input_dev *rc_input_dev; |
156 | char rc_phys[64]; | ||
156 | 157 | ||
157 | int active; /* Loaded successfully */ | 158 | int active; /* Loaded successfully */ |
158 | }; | 159 | }; |
@@ -235,9 +236,9 @@ static void ttusb_dec_handle_irq( struct urb *urb, struct pt_regs *regs) | |||
235 | * this should/could be added later ... | 236 | * this should/could be added later ... |
236 | * for now lets report each signal as a key down and up*/ | 237 | * for now lets report each signal as a key down and up*/ |
237 | dprintk("%s:rc signal:%d\n", __FUNCTION__, buffer[4]); | 238 | dprintk("%s:rc signal:%d\n", __FUNCTION__, buffer[4]); |
238 | input_report_key(&dec->rc_input_dev,rc_keys[buffer[4]-1],1); | 239 | input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 1); |
239 | input_report_key(&dec->rc_input_dev,rc_keys[buffer[4]-1],0); | 240 | input_report_key(dec->rc_input_dev, rc_keys[buffer[4] - 1], 0); |
240 | input_sync(&dec->rc_input_dev); | 241 | input_sync(dec->rc_input_dev); |
241 | } | 242 | } |
242 | 243 | ||
243 | exit: retval = usb_submit_urb(urb, GFP_ATOMIC); | 244 | exit: retval = usb_submit_urb(urb, GFP_ATOMIC); |
@@ -1181,29 +1182,38 @@ static void ttusb_dec_init_tasklet(struct ttusb_dec *dec) | |||
1181 | (unsigned long)dec); | 1182 | (unsigned long)dec); |
1182 | } | 1183 | } |
1183 | 1184 | ||
1184 | static void ttusb_init_rc( struct ttusb_dec *dec) | 1185 | static int ttusb_init_rc(struct ttusb_dec *dec) |
1185 | { | 1186 | { |
1187 | struct input_dev *input_dev; | ||
1186 | u8 b[] = { 0x00, 0x01 }; | 1188 | u8 b[] = { 0x00, 0x01 }; |
1187 | int i; | 1189 | int i; |
1188 | 1190 | ||
1189 | init_input_dev(&dec->rc_input_dev); | 1191 | usb_make_path(dec->udev, dec->rc_phys, sizeof(dec->rc_phys)); |
1192 | strlcpy(dec->rc_phys, "/input0", sizeof(dec->rc_phys)); | ||
1190 | 1193 | ||
1191 | dec->rc_input_dev.name = "ttusb_dec remote control"; | 1194 | dec->rc_input_dev = input_dev = input_allocate_device(); |
1192 | dec->rc_input_dev.evbit[0] = BIT(EV_KEY); | 1195 | if (!input_dev) |
1193 | dec->rc_input_dev.keycodesize = sizeof(u16); | 1196 | return -ENOMEM; |
1194 | dec->rc_input_dev.keycodemax = 0x1a; | 1197 | |
1195 | dec->rc_input_dev.keycode = rc_keys; | 1198 | input_dev->name = "ttusb_dec remote control"; |
1199 | input_dev->phys = dec->rc_phys; | ||
1200 | input_dev->evbit[0] = BIT(EV_KEY); | ||
1201 | input_dev->keycodesize = sizeof(u16); | ||
1202 | input_dev->keycodemax = 0x1a; | ||
1203 | input_dev->keycode = rc_keys; | ||
1196 | 1204 | ||
1197 | for (i = 0; i < sizeof(rc_keys)/sizeof(rc_keys[0]); i++) | 1205 | for (i = 0; i < ARRAY_SIZE(rc_keys); i++) |
1198 | set_bit(rc_keys[i], dec->rc_input_dev.keybit); | 1206 | set_bit(rc_keys[i], input_dev->keybit); |
1199 | 1207 | ||
1200 | input_register_device(&dec->rc_input_dev); | 1208 | input_register_device(input_dev); |
1201 | 1209 | ||
1202 | if(usb_submit_urb(dec->irq_urb,GFP_KERNEL)) { | 1210 | if (usb_submit_urb(dec->irq_urb, GFP_KERNEL)) |
1203 | printk("%s: usb_submit_urb failed\n",__FUNCTION__); | 1211 | printk("%s: usb_submit_urb failed\n",__FUNCTION__); |
1204 | } | 1212 | |
1205 | /* enable irq pipe */ | 1213 | /* enable irq pipe */ |
1206 | ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL); | 1214 | ttusb_dec_send_command(dec,0xb0,sizeof(b),b,NULL,NULL); |
1215 | |||
1216 | return 0; | ||
1207 | } | 1217 | } |
1208 | 1218 | ||
1209 | static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) | 1219 | static void ttusb_dec_init_v_pes(struct ttusb_dec *dec) |
@@ -1513,7 +1523,7 @@ static void ttusb_dec_exit_rc(struct ttusb_dec *dec) | |||
1513 | * As the irq is submitted after the interface is changed, | 1523 | * As the irq is submitted after the interface is changed, |
1514 | * this is the best method i figured out. | 1524 | * this is the best method i figured out. |
1515 | * Any others?*/ | 1525 | * Any others?*/ |
1516 | if(dec->interface == TTUSB_DEC_INTERFACE_IN) | 1526 | if (dec->interface == TTUSB_DEC_INTERFACE_IN) |
1517 | usb_kill_urb(dec->irq_urb); | 1527 | usb_kill_urb(dec->irq_urb); |
1518 | 1528 | ||
1519 | usb_free_urb(dec->irq_urb); | 1529 | usb_free_urb(dec->irq_urb); |
@@ -1521,7 +1531,10 @@ static void ttusb_dec_exit_rc(struct ttusb_dec *dec) | |||
1521 | usb_buffer_free(dec->udev,IRQ_PACKET_SIZE, | 1531 | usb_buffer_free(dec->udev,IRQ_PACKET_SIZE, |
1522 | dec->irq_buffer, dec->irq_dma_handle); | 1532 | dec->irq_buffer, dec->irq_dma_handle); |
1523 | 1533 | ||
1524 | input_unregister_device(&dec->rc_input_dev); | 1534 | if (dec->rc_input_dev) { |
1535 | input_unregister_device(dec->rc_input_dev); | ||
1536 | dec->rc_input_dev = NULL; | ||
1537 | } | ||
1525 | } | 1538 | } |
1526 | 1539 | ||
1527 | 1540 | ||
@@ -1659,7 +1672,7 @@ static int ttusb_dec_probe(struct usb_interface *intf, | |||
1659 | 1672 | ||
1660 | ttusb_dec_set_interface(dec, TTUSB_DEC_INTERFACE_IN); | 1673 | ttusb_dec_set_interface(dec, TTUSB_DEC_INTERFACE_IN); |
1661 | 1674 | ||
1662 | if(enable_rc) | 1675 | if (enable_rc) |
1663 | ttusb_init_rc(dec); | 1676 | ttusb_init_rc(dec); |
1664 | 1677 | ||
1665 | return 0; | 1678 | return 0; |