iguanair: reuse existing urb callback for command responses
Subsystems (5)
Sean Young
maintainerPATCH 1/13 iguanair: reuse existing urb callback for command responses
Rather than using usb_interrupt_msg() to receive responses, reuse the urb callback we already have in place.
--- drivers/media/rc/iguanair.c | 147 +++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 91 deletions(-)
drivers/media/rc/iguanair.c +56 -91
@@ -35,7 +35,7 @@ struct iguanair {struct device *dev;struct usb_device *udev; -int pipe_in, pipe_out; +int pipe_out;uint8_t bufsize;uint8_t version[2 ];
@@ -82,11 +82,6 @@ struct packet {uint8_t cmd; }; -struct response_packet { -struct packet header; -uint8_t data[4 ]; -}; -struct send_packet {struct packet header;uint8_t length;
@@ -100,6 +95,26 @@ static void process_ir_data(struct iguanair *ir, unsigned len) {if (len >=4 && ir->buf_in[0 ] ==0 && ir->buf_in[1 ] ==0 ) {switch (ir->buf_in[3 ]) { +case CMD_GET_VERSION : +if (len ==6 ) { + ir->version[0 ] = ir->buf_in[4 ]; + ir->version[1 ] = ir->buf_in[5 ]; +complete (&ir->completion); + } +break ; +case CMD_GET_BUFSIZE : +if (len >=5 ) { + ir->bufsize = ir->buf_in[4 ]; +complete (&ir->completion); + } +break ; +case CMD_GET_FEATURES : +if (len >5 ) { +if (ir->version[0 ] >=4 ) + ir->cycle_overhead = ir->buf_in[5 ]; +complete (&ir->completion); + } +break ;case CMD_TX_OVERFLOW : ir->tx_overflow = true;case CMD_RECEIVER_OFF :
@@ -169,31 +184,22 @@ static void iguanair_rx(struct urb *urb)usb_submit_urb (urb,GFP_ATOMIC ); } -static int iguanair_send (struct iguanair *ir,void *data,unsigned size, -struct response_packet *response,unsigned *res_len) +static int iguanair_send (struct iguanair *ir,void *data,unsigned size) { -unsigned offset, len;int rc, transferred; -for (offset =0 ; offset < size; offset +=MAX_PACKET_SIZE ) { - len =min (size - offset,MAX_PACKET_SIZE ); - -if (ir->tx_overflow) -return -EOVERFLOW ; +INIT_COMPLETION (ir->completion); - rc =usb_interrupt_msg (ir->udev, ir->pipe_out, data + offset, - len, &transferred,TIMEOUT ); -if (rc) -return rc; + rc =usb_interrupt_msg (ir->udev, ir->pipe_out, data, size, + &transferred,TIMEOUT ); +if (rc) +return rc; -if (transferred != len) -return -EIO ; - } +if (transferred != size) +return -EIO ; -if (response) { - rc =usb_interrupt_msg (ir->udev, ir->pipe_in, response, -sizeof (*response), res_len,TIMEOUT ); - } +if (wait_for_completion_timeout (&ir->completion,TIMEOUT ) ==0 ) +return -ETIMEDOUT ;return rc; }
@@ -201,66 +207,40 @@ static int iguanair_send(struct iguanair *ir, void *data, unsigned size,static int iguanair_get_features (struct iguanair *ir) {struct packet packet; -struct response_packet response; -int rc, len; +int rc; packet.start =0 ; packet.direction =DIR_OUT ; packet.cmd =CMD_GET_VERSION ; - rc =iguanair_send (ir, &packet,sizeof (packet), &response, &len); + rc =iguanair_send (ir, &packet,sizeof (packet));if (rc) {dev_info (ir->dev,"failed to get version\n" ); goto out; } -if (len !=6 ) { -dev_info (ir->dev,"failed to get version\n" ); - rc = -EIO ; - goto out; - } - - ir->version[0 ] = response.data[0 ]; - ir->version[1 ] = response.data[1 ]; ir->bufsize =150 ; ir->cycle_overhead =65 ; packet.cmd =CMD_GET_BUFSIZE ; - rc =iguanair_send (ir, &packet,sizeof (packet), &response, &len); + rc =iguanair_send (ir, &packet,sizeof (packet));if (rc) {dev_info (ir->dev,"failed to get buffer size\n" ); goto out; } -if (len !=5 ) { -dev_info (ir->dev,"failed to get buffer size\n" ); - rc = -EIO ; - goto out; - } - - ir->bufsize = response.data[0 ]; -if (ir->version[0 ] ==0 || ir->version[1 ] ==0 ) goto out; packet.cmd =CMD_GET_FEATURES ; - rc =iguanair_send (ir, &packet,sizeof (packet), &response, &len); + rc =iguanair_send (ir, &packet,sizeof (packet));if (rc) {dev_info (ir->dev,"failed to get features\n" ); goto out; } -if (len <5 ) { -dev_info (ir->dev,"failed to get features\n" ); - rc = -EIO ; - goto out; - } - -if (len >5 && ir->version[0 ] >=4 ) - ir->cycle_overhead = response.data[1 ]; - out:return rc; }
@@ -269,17 +249,8 @@ static int iguanair_receiver(struct iguanair *ir, bool enable) {struct packet packet = {0 ,DIR_OUT , enable ?CMD_RECEIVER_ON :CMD_RECEIVER_OFF }; -int rc; - -INIT_COMPLETION (ir->completion); - - rc =iguanair_send (ir, &packet,sizeof (packet),NULL ,NULL ); -if (rc) -return rc; - -wait_for_completion_timeout (&ir->completion,TIMEOUT ); -return 0 ; +return iguanair_send (ir, &packet,sizeof (packet)); }/*
@@ -406,17 +377,10 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count) ir->tx_overflow = false; -INIT_COMPLETION (ir->completion); - - rc =iguanair_send (ir, packet, size +8 ,NULL ,NULL ); + rc =iguanair_send (ir, packet, size +8 ); -if (rc ==0 ) { -wait_for_completion_timeout (&ir->completion,TIMEOUT ); -if (ir->tx_overflow) - rc = -EOVERFLOW ; - } - - ir->tx_overflow = false; +if (rc ==0 && ir->tx_overflow) + rc = -EOVERFLOW ;if (ir->receiver_on) {if (iguanair_receiver (ir, true))
@@ -437,8 +401,6 @@ static int iguanair_open(struct rc_dev *rdev)mutex_lock (&ir->lock); -usb_submit_urb (ir->urb_in,GFP_KERNEL ); -BUG_ON (ir->receiver_on); rc =iguanair_receiver (ir, true);
@@ -462,8 +424,6 @@ static void iguanair_close(struct rc_dev *rdev)if (rc)dev_warn (ir->dev,"failed to disable receiver: %d\n" , rc); -usb_kill_urb (ir->urb_in); -mutex_unlock (&ir->lock); }
@@ -473,7 +433,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf,struct usb_device *udev =interface_to_usbdev (intf);struct iguanair *ir;struct rc_dev *rc; -int ret; +int ret, pipein;struct usb_host_interface *idesc; ir =kzalloc (sizeof (*ir),GFP_KERNEL );
@@ -483,7 +443,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf, goto out; } - ir->buf_in =usb_alloc_coherent (udev,MAX_PACKET_SIZE ,GFP_ATOMIC , + ir->buf_in =usb_alloc_coherent (udev,MAX_PACKET_SIZE ,GFP_KERNEL , &ir->dma_in); ir->urb_in =usb_alloc_urb (0 ,GFP_KERNEL );
@@ -502,25 +462,28 @@ static int __devinit iguanair_probe(struct usb_interface *intf, ir->rc = rc; ir->dev = &intf->dev; ir->udev = udev; - ir->pipe_in =usb_rcvintpipe (udev, - idesc->endpoint[0 ].desc.bEndpointAddress); ir->pipe_out =usb_sndintpipe (udev, idesc->endpoint[1 ].desc.bEndpointAddress);mutex_init (&ir->lock);init_completion (&ir->completion); - ret =iguanair_get_features (ir); -if (ret) { -dev_warn (&intf->dev,"failed to get device features" ); - goto out; - } - -usb_fill_int_urb (ir->urb_in, ir->udev, ir->pipe_in, ir->buf_in, + pipein =usb_rcvintpipe (udev, idesc->endpoint[0 ].desc.bEndpointAddress); +usb_fill_int_urb (ir->urb_in, udev, pipein, ir->buf_in,MAX_PACKET_SIZE , iguanair_rx, ir, idesc->endpoint[0 ].desc.bInterval); ir->urb_in->transfer_dma = ir->dma_in; ir->urb_in->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ; + ret =usb_submit_urb (ir->urb_in,GFP_KERNEL ); +if (ret) { +dev_warn (&intf->dev,"failed to submit urb: %d\n" , ret); + goto out; + } + + ret =iguanair_get_features (ir); +if (ret) + goto out2; +snprintf (ir->name,sizeof (ir->name),"IguanaWorks USB IR Transceiver version %d.%d" , ir->version[0 ], ir->version[1 ]);
@@ -547,7 +510,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf, ret =rc_register_device (rc);if (ret <0 ) {dev_err (&intf->dev,"failed to register rc device %d" , ret); - goto out; + goto out2; }usb_set_intfdata (intf, ir);
@@ -555,6 +518,8 @@ static int __devinit iguanair_probe(struct usb_interface *intf,dev_info (&intf->dev,"Registered %s" , ir->name);return 0 ; +out2: +usb_kill_urb (ir->urb_in); out:if (ir) {usb_free_urb (ir->urb_in);
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 2/13 iguanair: ignore unsupported firmware versions
Firmware versions lower than 0x0205 use a different interface which is not supported. Also report the firmware version in the standard format.
--- drivers/media/rc/Kconfig | 8 ++++++-- drivers/media/rc/iguanair.c | 21 +++++++++++---------- 2 files changed, 17 insertions(+), 12 deletions(-)
drivers/media/rc/Kconfig +6 -2
@@ -264,8 +264,12 @@ config IR_IGUANA depends on RC_CORE select USB ---help--- - Say Y here if you want to use the IgaunaWorks USB IR Transceiver. - Both infrared receive and send are supported. + Say Y here if you want to use the IguanaWorks USB IR Transceiver. + Both infrared receive and send are supported. If you want to + change the ID or the pin config, use the user space driver from + IguanaWorks. + + Only firmware 0x0205 and later is supported. To compile this driver as a module, choose M here: the module will be called iguanair.
drivers/media/rc/iguanair.c +11 -10
@@ -36,8 +36,8 @@ struct iguanair {struct usb_device *udev;int pipe_out; +uint16_t version;uint8_t bufsize; -uint8_t version[2 ];struct mutex lock;
@@ -97,8 +97,8 @@ static void process_ir_data(struct iguanair *ir, unsigned len)switch (ir->buf_in[3 ]) {case CMD_GET_VERSION :if (len ==6 ) { - ir->version[0 ] = ir->buf_in[4 ]; - ir->version[1 ] = ir->buf_in[5 ]; + ir->version = (ir->buf_in[5 ] <<8 ) | + ir->buf_in[4 ];complete (&ir->completion); }break ;
@@ -110,8 +110,7 @@ static void process_ir_data(struct iguanair *ir, unsigned len)break ;case CMD_GET_FEATURES :if (len >5 ) { -if (ir->version[0 ] >=4 ) - ir->cycle_overhead = ir->buf_in[5 ]; + ir->cycle_overhead = ir->buf_in[5 ];complete (&ir->completion); }break ;
@@ -219,6 +218,12 @@ static int iguanair_get_features(struct iguanair *ir) goto out; } +if (ir->version <0x205 ) { +dev_err (ir->dev,"firmware 0x%04x is too old\n" , ir->version); + rc = -ENODEV ; + goto out; + } + ir->bufsize =150 ; ir->cycle_overhead =65 ;
@@ -230,9 +235,6 @@ static int iguanair_get_features(struct iguanair *ir) goto out; } -if (ir->version[0 ] ==0 || ir->version[1 ] ==0 ) - goto out; - packet.cmd =CMD_GET_FEATURES ; rc =iguanair_send (ir, &packet,sizeof (packet));
@@ -485,8 +487,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf, goto out2;snprintf (ir->name,sizeof (ir->name), -"IguanaWorks USB IR Transceiver version %d.%d" , - ir->version[0 ], ir->version[1 ]); +"IguanaWorks USB IR Transceiver version 0x%04x" , ir->version);usb_make_path (ir->udev, ir->phys,sizeof (ir->phys));
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 3/13 iguanair: advertise the resolution and timeout properly
In reply to Sean YoungWith the timeout supplied the interface can go idle. The keymap is the same one as other drivers which do not come with a remote.
--- drivers/media/rc/iguanair.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/rc/iguanair.c +5 -2
@@ -75,6 +75,7 @@ struct iguanair {#define MAX_PACKET_SIZE 8u#define TIMEOUT 1000 +#define RX_RESOLUTION 21333struct packet {uint16_t start;
@@ -142,7 +143,7 @@ static void process_ir_data(struct iguanair *ir, unsigned len) }else { rawir.pulse = (ir->buf_in[i] &0x80 ) ==0 ; rawir.duration = ((ir->buf_in[i] &0x7f ) +1 ) * -21330 ; +RX_RESOLUTION ; }ir_raw_event_store_with_filter (ir->rc, &rawir);
@@ -504,7 +505,9 @@ static int __devinit iguanair_probe(struct usb_interface *intf, rc->s_tx_carrier = iguanair_set_tx_carrier; rc->tx_ir = iguanair_tx; rc->driver_name =DRIVER_NAME ; - rc->map_name =RC_MAP_EMPTY ; + rc->map_name =RC_MAP_RC6_MCE ; + rc->timeout =MS_TO_NS (100 ); + rc->rx_resolution =RX_RESOLUTION ;iguanair_set_tx_carrier (rc,38000 );
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 4/13 iguanair: fix return value for transmit
In reply to Sean YoungAlso fix error codes returned from open.
--- drivers/media/rc/iguanair.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/media/rc/iguanair.c +18 -12
@@ -325,7 +325,7 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count) {struct iguanair *ir = dev->priv;uint8_t space, *payload; -unsigned i, size, rc; +unsigned i, size, rc, bytes;struct send_packet *packet;mutex_lock (&ir->lock);
@@ -333,17 +333,22 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)/* convert from us to carrier periods */ for (i = size =0 ; i < count; i++) { txbuf[i] =DIV_ROUND_CLOSEST (txbuf[i] * ir->carrier,1000000 ); - size += (txbuf[i] +126 ) /127 ; + bytes = (txbuf[i] +126 ) /127 ; +if (size + bytes > ir->bufsize) { + count = i; +break ; + } + size += bytes; } - packet =kmalloc (sizeof (*packet) + size,GFP_KERNEL ); -if (!packet) { - rc = -ENOMEM ; +if (count ==0 ) { + rc = -EINVAL ; goto out; } -if (size > ir->bufsize) { - rc = -E2BIG ; + packet =kmalloc (sizeof (*packet) + size,GFP_KERNEL ); +if (!packet) { + rc = -ENOMEM ; goto out; }
@@ -374,7 +379,7 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count) rc =iguanair_receiver (ir, false);if (rc) {dev_warn (ir->dev,"disable receiver before transmit failed\n" ); - goto out; + goto out_kfree; } }
@@ -390,11 +395,12 @@ static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)dev_warn (ir->dev,"re-enable receiver after transmit failed\n" ); } +out_kfree: +kfree (packet); out:mutex_unlock (&ir->lock); -kfree (packet); -return rc; +return rc ? rc : count; }static int iguanair_open (struct rc_dev *rdev)
@@ -442,7 +448,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf, ir =kzalloc (sizeof (*ir),GFP_KERNEL ); rc =rc_allocate_device ();if (!ir || !rc) { - ret =ENOMEM ; + ret = -ENOMEM ; goto out; }
@@ -451,7 +457,7 @@ static int __devinit iguanair_probe(struct usb_interface *intf, ir->urb_in =usb_alloc_urb (0 ,GFP_KERNEL );if (!ir->buf_in || !ir->urb_in) { - ret =ENOMEM ; + ret = -ENOMEM ; goto out; }
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 5/13 iguanair: support suspend and resume
In reply to Sean YoungNow unbind also stops the receiver.
--- drivers/media/rc/iguanair.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/media/rc/iguanair.c +14 -7
@@ -156,6 +156,7 @@ static void process_ir_data(struct iguanair *ir, unsigned len)static void iguanair_rx (struct urb *urb) {struct iguanair *ir; +int rc;if (!urb)return ;
@@ -181,7 +182,9 @@ static void iguanair_rx(struct urb *urb)break ; } -usb_submit_urb (urb,GFP_ATOMIC ); + rc =usb_submit_urb (urb,GFP_ATOMIC ); +if (rc && rc != -ENODEV ) +dev_warn (ir->dev,"failed to resubmit urb: %d\n" , rc); }static int iguanair_send (struct iguanair *ir,void *data,unsigned size)
@@ -430,7 +433,7 @@ static void iguanair_close(struct rc_dev *rdev) rc =iguanair_receiver (ir, false); ir->receiver_on = false; -if (rc) +if (rc && rc != -ENODEV )dev_warn (ir->dev,"failed to disable receiver: %d\n" , rc);mutex_unlock (&ir->lock);
@@ -525,8 +528,6 @@ static int __devinit iguanair_probe(struct usb_interface *intf,usb_set_intfdata (intf, ir); -dev_info (&intf->dev,"Registered %s" , ir->name); -return 0 ; out2:usb_kill_urb (ir->urb_in);
@@ -545,12 +546,11 @@ static void __devexit iguanair_disconnect(struct usb_interface *intf) {struct iguanair *ir =usb_get_intfdata (intf); +rc_unregister_device (ir->rc);usb_set_intfdata (intf,NULL ); -usb_kill_urb (ir->urb_in);usb_free_urb (ir->urb_in);usb_free_coherent (ir->udev,MAX_PACKET_SIZE , ir->buf_in, ir->dma_in); -rc_unregister_device (ir->rc);kfree (ir); }
@@ -567,6 +567,8 @@ static int iguanair_suspend(struct usb_interface *intf, pm_message_t message)dev_warn (ir->dev,"failed to disable receiver for suspend\n" ); } +usb_kill_urb (ir->urb_in); +mutex_unlock (&ir->lock);return rc;
@@ -579,6 +581,10 @@ static int iguanair_resume(struct usb_interface *intf)mutex_lock (&ir->lock); + rc =usb_submit_urb (ir->urb_in,GFP_KERNEL ); +if (rc) +dev_warn (&intf->dev,"failed to submit urb: %d\n" , rc); +if (ir->receiver_on) { rc =iguanair_receiver (ir, true);if (rc)
@@ -602,7 +608,8 @@ static struct usb_driver iguanair_driver = { .suspend = iguanair_suspend, .resume = iguanair_resume, .reset_resume = iguanair_resume, - .id_table = iguanair_table + .id_table = iguanair_table, + .soft_unbind = 1 /* we want to disable receiver on unbind */ };module_usb_driver (iguanair_driver);
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 6/13 iguanair: reset the IR state after rx overflow or receiver enable
In reply to Sean Young--- drivers/media/rc/iguanair.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/rc/iguanair.c +4 -0
@@ -124,6 +124,7 @@ static void process_ir_data(struct iguanair *ir, unsigned len)break ;case CMD_RX_OVERFLOW :dev_warn (ir->dev,"receive overflow\n" ); +ir_raw_event_reset (ir->rc);break ;default : dev_warn(ir->dev, "control code %02x received\n",
@@ -256,6 +257,9 @@ static int iguanair_receiver(struct iguanair *ir, bool enable)struct packet packet = {0 ,DIR_OUT , enable ?CMD_RECEIVER_ON :CMD_RECEIVER_OFF }; +if (enable) +ir_raw_event_reset (ir->rc); +return iguanair_send (ir, &packet,sizeof (packet)); }
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 7/13 iguanair: fix receiver overflow
In reply to Sean YoungThe Pioneer CU-700 remote causes receiver overflows if you hold down any button. The remote does not send NEC IR repeats, it repeats the entire NEC code after 20ms.
The iguanair hardware advertises an interval of 10 which just not enough; with 100 URBs per second and at most 7 edges per URB, we handle at most 700 edges per second. The remote generates about 900.
--- drivers/media/rc/iguanair.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/rc/iguanair.c +2 -3
@@ -484,9 +484,8 @@ static int __devinit iguanair_probe(struct usb_interface *intf,init_completion (&ir->completion); pipein =usb_rcvintpipe (udev, idesc->endpoint[0 ].desc.bEndpointAddress); -usb_fill_int_urb (ir->urb_in, udev, pipein, ir->buf_in, -MAX_PACKET_SIZE , iguanair_rx, ir, - idesc->endpoint[0 ].desc.bInterval); +usb_fill_int_urb (ir->urb_in, udev, pipein, ir->buf_in,MAX_PACKET_SIZE , + iguanair_rx, ir,1 ); ir->urb_in->transfer_dma = ir->dma_in; ir->urb_in->transfer_flags |=URB_NO_TRANSFER_DMA_MAP ;
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 8/13 rc: Add support for the TechnoTrend USB IR Receiver
In reply to Sean YoungThis driver adds support for TechnoTrend USB IR Receiver. It is a complete rewrite of the staging/media/lirc/lirc_ttusbir driver. It adds more accurate sample reporting and led control.
--- drivers/media/rc/Kconfig | 13 ++ drivers/media/rc/Makefile | 1 + drivers/media/rc/keymaps/rc-tt-1500.c | 2 +- drivers/media/rc/ttusbir.c | 400 ++++++++++++++++++++++++++++++++++ 4 files changed, 415 insertions(+), 1 deletion(-) create mode 100644 drivers/media/rc/ttusbir.c
drivers/media/rc/Kconfig +13 -0
@@ -274,6 +274,19 @@ config IR_IGUANA To compile this driver as a module, choose M here: the module will be called iguanair. +config IR_TTUSBIR + tristate "TechnoTrend USB IR Receiver" + depends on RC_CORE + select USB + select NEW_LEDS + select LEDS_CLASS + ---help--- + Say Y here if you want to use the TechnoTrend USB IR Receiver. The + driver can control the led. + + To compile this driver as a module, choose M here: the module will + be called ttusbir. + config RC_LOOPBACK tristate "Remote Control Loopback Driver" depends on RC_CORE
drivers/media/rc/Makefile +1 -0
@@ -28,3 +28,4 @@ obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o obj-$(CONFIG_IR_IGUANA) += iguanair.o +obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
drivers/media/rc/keymaps/rc-tt-1500.c +1 -1
@@ -61,7 +61,7 @@ static struct rc_map_list tt_1500_map = { .map = { .scan = tt_1500, .size = ARRAY_SIZE(tt_1500), - .rc_type = RC_TYPE_UNKNOWN, /* Legacy IR type */ + .rc_type = RC_TYPE_RC5, .name = RC_MAP_TT_1500, } };
drivers/media/rc/ttusbir.c new file +400 -0
400 lines not on this page · raw message
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 9/13 rc: do not wake up rc thread unless there is something to do
In reply to Sean YoungThe TechnoTrend USB IR Receiver sends 125 ISO URBs per second, even when there is no IR activity. Reduce the number of wake ups from the other drivers too.
This saves about 0.25ms/s on a 2.4GHz Core 2 according to powertop.
--- drivers/media/rc/fintek-cir.c | 11 ++++++++--- drivers/media/rc/iguanair.c | 7 +++++-- drivers/media/rc/ir-raw.c | 6 ++++-- drivers/media/rc/mceusb.c | 10 +++++++--- drivers/media/rc/ttusbir.c | 19 +++++++++++++------ 5 files changed, 37 insertions(+), 16 deletions(-)
drivers/media/rc/fintek-cir.c +8 -3
@@ -295,6 +295,7 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek) {DEFINE_IR_RAW_EVENT (rawir);u8 sample; +bool event = false;int i;for (i =0 ; i < fintek->pkts; i++) {
@@ -332,7 +333,9 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek)fit_dbg ("Storing %s with duration %d" , rawir.pulse ?"pulse" :"space" , rawir.duration); -ir_raw_event_store_with_filter (fintek->rdev, &rawir); +if (ir_raw_event_store_with_filter (fintek->rdev, + &rawir)) + event = true;break ; }
@@ -342,8 +345,10 @@ static void fintek_process_rx_ir_data(struct fintek_dev *fintek) fintek->pkts =0 ; -fit_dbg ("Calling ir_raw_event_handle" ); -ir_raw_event_handle (fintek->rdev); +if (event) { +fit_dbg ("Calling ir_raw_event_handle" ); +ir_raw_event_handle (fintek->rdev); + } }/* copy data from hardware rx register into driver buffer */
drivers/media/rc/iguanair.c +5 -2
@@ -134,6 +134,7 @@ static void process_ir_data(struct iguanair *ir, unsigned len) }else if (len >=7 ) {DEFINE_IR_RAW_EVENT (rawir);unsigned i; +bool event = false;init_ir_raw_event (&rawir);
@@ -147,10 +148,12 @@ static void process_ir_data(struct iguanair *ir, unsigned len)RX_RESOLUTION ; } -ir_raw_event_store_with_filter (ir->rc, &rawir); +if (ir_raw_event_store_with_filter (ir->rc, &rawir)) + event = true; } -ir_raw_event_handle (ir->rc); +if (event) +ir_raw_event_handle (ir->rc); } }
drivers/media/rc/ir-raw.c +4 -2
@@ -157,7 +157,9 @@ EXPORT_SYMBOL_GPL(ir_raw_event_store_edge);* This routine (which may be called from an interrupt context) works * in similar manner to ir_raw_event_store_edge. * This routine is intended for devices with limited internal buffer -* It automerges samples of same type, and handles timeouts +* It automerges samples of same type, and handles timeouts. Returns non-zero +* if the event was added, and zero if the event was ignored due to idle +* processing. */ int ir_raw_event_store_with_filter (struct rc_dev *dev,struct ir_raw_event *ev) {
@@ -184,7 +186,7 @@ int ir_raw_event_store_with_filter(struct rc_dev *dev, struct ir_raw_event *ev) dev->raw->this_ev.duration >= dev->timeout)ir_raw_event_set_idle (dev, true); -return 0 ; +return 1 ; }EXPORT_SYMBOL_GPL (ir_raw_event_store_with_filter);
drivers/media/rc/mceusb.c +7 -3
@@ -974,6 +974,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index)static void mceusb_process_ir_data (struct mceusb_dev *ir,int buf_len) {DEFINE_IR_RAW_EVENT (rawir); +bool event = false;int i =0 ;/* skip meaningless 0xb1 0x60 header bytes on orig receiver */
@@ -1004,7 +1005,8 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) rawir.pulse ?"pulse" :"space" , rawir.duration); -ir_raw_event_store_with_filter (ir->rc, &rawir); +if (ir_raw_event_store_with_filter (ir->rc, &rawir)) + event = true;break ;case CMD_DATA : ir->rem--;
@@ -1032,8 +1034,10 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len)if (ir->parser_state !=CMD_HEADER && !ir->rem) ir->parser_state =CMD_HEADER ; } -mce_dbg (ir->dev,"processed IR data, calling ir_raw_event_handle\n" ); -ir_raw_event_handle (ir->rc); +if (event) { +mce_dbg (ir->dev,"processed IR data, calling ir_raw_event_handle\n" ); +ir_raw_event_handle (ir->rc); + } }static void mceusb_dev_recv (struct urb *urb)
drivers/media/rc/ttusbir.c +13 -6
@@ -121,8 +121,9 @@ static void ttusbir_bulk_complete(struct urb *urb)*/ static void ttusbir_process_ir_data (struct ttusbir *tt,uint8_t *buf) { +struct ir_raw_event rawir;unsigned i, v, b; -DEFINE_IR_RAW_EVENT (rawir); +bool event = false;init_ir_raw_event (&rawir);
@@ -132,12 +133,14 @@ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf)case 0xfe : rawir.pulse = false; rawir.duration =NS_PER_BYTE ; -ir_raw_event_store_with_filter (tt->rc, &rawir); +if (ir_raw_event_store_with_filter (tt->rc, &rawir)) + event = true;break ;case 0 : rawir.pulse = true; rawir.duration =NS_PER_BYTE ; -ir_raw_event_store_with_filter (tt->rc, &rawir); +if (ir_raw_event_store_with_filter (tt->rc, &rawir)) + event = true;break ;default :/* one edge per byte */
@@ -150,16 +153,20 @@ static void ttusbir_process_ir_data(struct ttusbir *tt, uint8_t *buf) } rawir.duration =NS_PER_BIT * (8 - b); -ir_raw_event_store_with_filter (tt->rc, &rawir); +if (ir_raw_event_store_with_filter (tt->rc, &rawir)) + event = true; rawir.pulse = !rawir.pulse; rawir.duration =NS_PER_BIT * b; -ir_raw_event_store_with_filter (tt->rc, &rawir); +if (ir_raw_event_store_with_filter (tt->rc, &rawir)) + event = true;break ; } } -ir_raw_event_handle (tt->rc); +/* don't wakeup when there's nothing to do */ +if (event) +ir_raw_event_handle (tt->rc); }static void ttusbir_urb_complete (struct urb *urb)
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 10/13 saa7134: simplify timer activation
In reply to Sean YoungThis simplies the code and resolves a possible race condition between ir_raw_decode_timer_end() and saa7134_raw_decode_irq().
If the interrupt handler is called after ir_raw_decode_timer_end() calls ir_raw_event_handle() but before clearing ir->active, then the timer won't be rearmed.
Compile tested only.
--- drivers/media/video/saa7134/saa7134-input.c | 10 +++------- drivers/media/video/saa7134/saa7134.h | 1 - 2 files changed, 3 insertions(+), 8 deletions(-)
drivers/media/video/saa7134/saa7134-input.c +3 -7
@@ -446,11 +446,8 @@ static void saa7134_input_timer(unsigned long data)static void ir_raw_decode_timer_end (unsigned long data) {struct saa7134_dev *dev = (struct saa7134_dev *)data; -struct saa7134_card_ir *ir = dev->remote;ir_raw_event_handle (dev->remote->dev); - - ir->active = false; }static int __saa7134_ir_start (void *priv)
@@ -501,7 +498,6 @@ static int __saa7134_ir_start(void *priv) } ir->running = true; - ir->active = false;if (ir->polling) { setup_timer(&ir->timer, saa7134_input_timer,
@@ -532,7 +528,6 @@ static void __saa7134_ir_stop(void *priv)if (ir->polling || ir->raw_decode)del_timer_sync (&ir->timer); - ir->active = false; ir->running = false;return ;
@@ -1035,10 +1030,11 @@ static int saa7134_raw_decode_irq(struct saa7134_dev *dev)* the event. This time is enough for NEC protocol. May need adjustments * to work with other protocols. */ -if (!ir->active) { +smp_mb (); + +if (!timer_pending (&ir->timer)) { timeout = jiffies +msecs_to_jiffies (15 );mod_timer (&ir->timer, timeout); - ir->active = true; }return 1 ;
drivers/media/video/saa7134/saa7134.h +0 -1
@@ -130,7 +130,6 @@ struct saa7134_card_ir {u32 mask_keycode, mask_keydown, mask_keyup;bool running; -bool active;struct timer_list timer;
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 11/13 rc: transmit on device which does not support it should fail
In reply to Sean YoungCurrently write() will return 0 if an IR device does not support sending.
--- drivers/media/rc/ir-lirc-codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/ir-lirc-codec.c +1 -1
@@ -105,7 +105,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf,struct lirc_codec *lirc;struct rc_dev *dev;unsigned int *txbuf;/* buffer with values to transmit */ -ssize_t ret =0 ; +ssize_t ret = -EINVAL ;size_t count; lirc =lirc_get_pdata (file);
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 12/13 lirc: remove lirc_ttusbir driver
In reply to Sean YoungThis has been replaced by the ttusbir driver.
--- drivers/staging/media/lirc/Kconfig | 6 - drivers/staging/media/lirc/Makefile | 1 - drivers/staging/media/lirc/lirc_ttusbir.c | 376 ------------------------------ 3 files changed, 383 deletions(-) delete mode 100644 drivers/staging/media/lirc/lirc_ttusbir.c
drivers/staging/media/lirc/Kconfig +0 -6
@@ -63,12 +63,6 @@ config LIRC_SIR help Driver for the SIR IrDA port -config LIRC_TTUSBIR - tristate "Technotrend USB IR Receiver" - depends on LIRC && USB - help - Driver for the Technotrend USB IR Receiver - config LIRC_ZILOG tristate "Zilog/Hauppauge IR Transmitter" depends on LIRC && I2C
drivers/staging/media/lirc/Makefile +0 -1
@@ -10,5 +10,4 @@ obj-$(CONFIG_LIRC_PARALLEL) += lirc_parallel.o obj-$(CONFIG_LIRC_SASEM) += lirc_sasem.o obj-$(CONFIG_LIRC_SERIAL) += lirc_serial.o obj-$(CONFIG_LIRC_SIR) += lirc_sir.o -obj-$(CONFIG_LIRC_TTUSBIR) += lirc_ttusbir.o obj-$(CONFIG_LIRC_ZILOG) += lirc_zilog.o
drivers/staging/media/lirc/lirc_ttusbir.c deleted +0 -376
376 lines not on this page · raw message
Signature · 1 line
1.7.11.2
Sean Young
maintainerPATCH 13/13 lirc: lirc_ene0100.h is not referenced anywhere
In reply to Sean YoungThere is a proper ene0100 driver anyway.
--- drivers/staging/media/lirc/lirc_ene0100.h | 169 ------------------------------ 1 file changed, 169 deletions(-) delete mode 100644 drivers/staging/media/lirc/lirc_ene0100.h
drivers/staging/media/lirc/lirc_ene0100.h deleted +0 -169
@@ -1,169 +0,0 @@ -/* -* driver for ENE KB3926 B/C/D CIR (also known as ENE0100) -* -* Copyright (C) 2009 Maxim Levitsky <[email protected]> -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of the -* License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -* USA -*/ - -#include <media/lirc.h> -#include <media/lirc_dev.h> - -/* hardware address */ -#define ENE_STATUS 0/* hardware status - unused */ -#define ENE_ADDR_HI 1/* hi byte of register address */ -#define ENE_ADDR_LO 2/* low byte of register address */ -#define ENE_IO 3/* read/write window */ -#define ENE_MAX_IO 4 - -/* 8 bytes of samples, divided in 2 halfs*/ -#define ENE_SAMPLE_BUFFER 0xF8F0/* regular sample buffer */ -#define ENE_SAMPLE_SPC_MASK (1 << 7)/* sample is space */ -#define ENE_SAMPLE_VALUE_MASK 0x7F -#define ENE_SAMPLE_OVERFLOW 0x7F -#define ENE_SAMPLES_SIZE 4 - -/* fan input sample buffer */ -#define ENE_SAMPLE_BUFFER_FAN 0xF8FB/* this buffer holds high byte of */ -/* each sample of normal buffer */ - -#define ENE_FAN_SMPL_PULS_MSK 0x8000/* this bit of combined sample */ -/* if set, says that sample is pulse */ -#define ENE_FAN_VALUE_MASK 0x0FFF/* mask for valid bits of the value */ - -/* first firmware register */ -#define ENE_FW1 0xF8F8 -#define ENE_FW1_ENABLE (1 << 0)/* enable fw processing */ -#define ENE_FW1_TXIRQ (1 << 1)/* TX interrupt pending */ -#define ENE_FW1_WAKE (1 << 6)/* enable wake from S3 */ -#define ENE_FW1_IRQ (1 << 7)/* enable interrupt */ - -/* second firmware register */ -#define ENE_FW2 0xF8F9 -#define ENE_FW2_BUF_HIGH (1 << 0)/* which half of the buffer to read */ -#define ENE_FW2_IRQ_CLR (1 << 2)/* clear this on IRQ */ -#define ENE_FW2_GP40_AS_LEARN (1 << 4)/* normal input is used as */ -/* learning input */ -#define ENE_FW2_FAN_AS_NRML_IN (1 << 6)/* fan is used as normal input */ -#define ENE_FW2_LEARNING (1 << 7)/* hardware supports learning and TX */ - -/* fan as input settings - only if learning capable */ -#define ENE_FAN_AS_IN1 0xFE30/* fan init reg 1 */ -#define ENE_FAN_AS_IN1_EN 0xCD -#define ENE_FAN_AS_IN2 0xFE31/* fan init reg 2 */ -#define ENE_FAN_AS_IN2_EN 0x03 -#define ENE_SAMPLE_PERIOD_FAN 61/* fan input has fixed sample period */ - -/* IRQ registers block (for revision B) */ -#define ENEB_IRQ 0xFD09/* IRQ number */ -#define ENEB_IRQ_UNK1 0xFD17/* unknown setting = 1 */ -#define ENEB_IRQ_STATUS 0xFD80/* irq status */ -#define ENEB_IRQ_STATUS_IR (1 << 5)/* IR irq */ - -/* IRQ registers block (for revision C,D) */ -#define ENEC_IRQ 0xFE9B/* new irq settings register */ -#define ENEC_IRQ_MASK 0x0F/* irq number mask */ -#define ENEC_IRQ_UNK_EN (1 << 4)/* always enabled */ -#define ENEC_IRQ_STATUS (1 << 5)/* irq status and ACK */ - -/* CIR block settings */ -#define ENE_CIR_CONF1 0xFEC0 -#define ENE_CIR_CONF1_ADC_ON 0x7/* receiver on gpio40 enabled */ -#define ENE_CIR_CONF1_LEARN1 (1 << 3)/* enabled on learning mode */ -#define ENE_CIR_CONF1_TX_ON 0x30/* enabled on transmit */ -#define ENE_CIR_CONF1_TX_CARR (1 << 7)/* send TX carrier or not */ - -#define ENE_CIR_CONF2 0xFEC1/* unknown setting = 0 */ -#define ENE_CIR_CONF2_LEARN2 (1 << 4)/* set on enable learning */ -#define ENE_CIR_CONF2_GPIO40DIS (1 << 5)/* disable normal input via gpio40 */ - -#define ENE_CIR_SAMPLE_PERIOD 0xFEC8/* sample period in us */ -#define ENE_CIR_SAMPLE_OVERFLOW (1 << 7)/* interrupt on overflows if set */ - - -/* transmitter - not implemented yet */ -/* KB3926C and higher */ -/* transmission is very similar to receiving, a byte is written to */ -/* ENE_TX_INPUT, in same manner as it is read from sample buffer */ -/* sample period is fixed*/ - - -/* transmitter ports */ -#define ENE_TX_PORT1 0xFC01/* this enables one or both */ -#define ENE_TX_PORT1_EN (1 << 5)/* TX ports */ -#define ENE_TX_PORT2 0xFC08 -#define ENE_TX_PORT2_EN (1 << 1) - -#define ENE_TX_INPUT 0xFEC9/* next byte to transmit */ -#define ENE_TX_SPC_MASK (1 << 7)/* Transmitted sample is space */ -#define ENE_TX_UNK1 0xFECB/* set to 0x63 */ -#define ENE_TX_SMPL_PERIOD 50/* transmit sample period */ - - -#define ENE_TX_CARRIER 0xFECE/* TX carrier * 2 (khz) */ -#define ENE_TX_CARRIER_UNKBIT 0x80/* This bit set on transmit */ -#define ENE_TX_CARRIER_LOW 0xFECF/* TX carrier / 2 */ - -/* Hardware versions */ -#define ENE_HW_VERSION 0xFF00/* hardware revision */ -#define ENE_HW_UNK 0xFF1D -#define ENE_HW_UNK_CLR (1 << 2) -#define ENE_HW_VER_MAJOR 0xFF1E/* chip version */ -#define ENE_HW_VER_MINOR 0xFF1F -#define ENE_HW_VER_OLD 0xFD00 - -#define same_sign (a, b) ((((a) > 0) && (b) > 0) || ((a) < 0 && (b) < 0)) - -#define ENE_DRIVER_NAME "enecir" -#define ENE_MAXGAP 250000/* this is amount of time we wait -before turning the sampler, chosen -arbitry */ - -#define space (len) (-(len))/* add a space */ - -/* software defines */ -#define ENE_IRQ_RX 1 -#define ENE_IRQ_TX 2 - -#define ENE_HW_B 1/* 3926B */ -#define ENE_HW_C 2/* 3926C */ -#define ENE_HW_D 3/* 3926D */ - -#define ene_printk (level, text, ...) \ - printk(level ENE_DRIVER_NAME ": " text, ## __VA_ARGS__) - -struct ene_device { -struct pnp_dev *pnp_dev; -struct lirc_driver *lirc_driver; - -/* hw settings */ -unsigned long hw_io; -int irq; - -int hw_revision;/* hardware revision */ -int hw_learning_and_tx_capable;/* learning capable */ -int hw_gpio40_learning;/* gpio40 is learning */ -int hw_fan_as_normal_input;/* fan input is used as regular input */ - -/* device data */ -int idle; -int fan_input_inuse; - -int sample; -int in_use; - -struct timeval gap_start; -};
Signature · 1 line
1.7.11.2