20 #include <linux/module.h>
24 #include <linux/input.h>
32 static unsigned int ir_debug;
36 static unsigned int enable_ir = 1;
40 static unsigned int ir_clock_mhz = 12;
44 #define URB_SUBMIT_DELAY 100
45 #define URB_INT_LED_DELAY 100
49 #define dprintk(level, fmt, arg...) do {\
50 if (ir_debug >= level) \
51 printk(KERN_DEBUG "%s/ir: " fmt, ir->name , ## arg); \
95 u32 pulse = 0, leader = 0;
123 pulse = ir_clock_mhz * pulse;
124 leader = ir_clock_mhz * leader;
126 leader = leader | 0x8000;
128 dprintk(2,
"%s: %s, %d MHz, leader = 0x%04x, pulse = 0x%06x \n",
131 ir_clock_mhz, leader, pulse);
165 static void tm6000_ir_urb_received(
struct urb *
urb)
173 if (urb->status < 0 || urb->actual_length <= 0) {
175 urb->status, urb->actual_length);
180 buf = urb->transfer_buffer;
183 print_hex_dump(
KERN_DEBUG,
"tm6000: IR data: ",
185 buf, urb->actual_length,
false);
187 poll_result.rc_data = buf[0];
188 if (urb->actual_length > 1)
189 poll_result.rc_data |= buf[1] << 8;
191 dprintk(1,
"%s, scancode: 0x%04x\n",__func__, poll_result.rc_data);
223 poll_result.rc_data = buf[0] | buf[1] << 8;
225 poll_result.rc_data = buf[0];
228 if ((poll_result.rc_data & 0xff) == 0xff) {
236 dprintk(1,
"%s, scancode: 0x%04x\n",__func__, poll_result.rc_data);
245 static void tm6000_ir_int_work(
struct work_struct *work)
260 printk(
KERN_ERR "tm6000: Can't submit an IR interrupt. Error %i\n",
270 if (ir->
pwled == 2) {
274 }
else if (!ir->
pwled) {
280 static int tm6000_ir_start(
struct rc_dev *rc)
291 static void tm6000_ir_stop(
struct rc_dev *rc)
314 tm6000_ir_config(ir);
319 static int __tm6000_ir_int_start(
struct rc_dev *rc)
336 pipe = usb_rcvintpipe(dev->
udev,
337 dev->int_in.endp->desc.bEndpointAddress
340 size = usb_maxpacket(dev->
udev, pipe, usb_pipeout(pipe));
341 dprintk(1,
"IR max size: %d\n", size);
348 dprintk(1,
"int interval: %d\n", dev->int_in.endp->desc.bInterval);
351 ir->
int_urb->transfer_buffer, size,
352 tm6000_ir_urb_received, dev,
353 dev->int_in.endp->desc.bInterval);
361 static void __tm6000_ir_int_stop(
struct rc_dev *rc)
383 return __tm6000_ir_int_start(ir->
rc);
393 __tm6000_ir_int_stop(ir->
rc);
405 if (!dev->
caps.has_remote)
429 if (dev->int_in.endp) {
430 rc->
open = __tm6000_ir_int_start;
431 rc->
close = __tm6000_ir_int_stop;
434 rc->
open = tm6000_ir_start;
435 rc->
close = tm6000_ir_stop;
457 rc->
dev.parent = &dev->
udev->dev;
485 __tm6000_ir_int_stop(ir->
rc);
487 tm6000_ir_stop(ir->
rc);