Re: [PATCH] [media] iguanair: various fixes

2012-08-12 Thread Sean Young
On Sat, Aug 11, 2012 at 09:35:29PM -0300, Mauro Carvalho Chehab wrote:
 Em 31-07-2012 07:37, Sean Young escreveu:
  This fixes:
   - rx_overflow while holding down any down button on a nec remote
   - suspend/resume
   - stop receiver on rmmod
   - advertise rx_resolution and timeout properly
   - code simplify
   - ignore unsupported firmware versions
 
 Please don't mix several different things on the same patch; it makes
 harder for review and, if any of these changes break, a git revert would
 change a lot of unrelated things. It also makes hard for bug disect.

That makes a lot of sense. I'll rework the patch.

 Tip: git citool helps a lot to break messy patches into smaller, concise
 ones.

Thank you very much, I'll try that.


Sean
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [media] iguanair: various fixes

2012-08-11 Thread Mauro Carvalho Chehab
Em 31-07-2012 07:37, Sean Young escreveu:
 This fixes:
  - rx_overflow while holding down any down button on a nec remote
  - suspend/resume
  - stop receiver on rmmod
  - advertise rx_resolution and timeout properly
  - code simplify
  - ignore unsupported firmware versions

Please don't mix several different things on the same patch; it makes
harder for review and, if any of these changes break, a git revert would
change a lot of unrelated things. It also makes hard for bug disect.

Tip: git citool helps a lot to break messy patches into smaller, concise
ones.

Thanks!
Mauro

 
 Signed-off-by: Sean Young s...@mess.org
 ---
  drivers/media/rc/Kconfig|   8 +-
  drivers/media/rc/iguanair.c | 206 
 ++--
  2 files changed, 107 insertions(+), 107 deletions(-)
 
 diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
 index 5180390..fa1745c 100644
 --- a/drivers/media/rc/Kconfig
 +++ b/drivers/media/rc/Kconfig
 @@ -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.
 diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
 index 5e2eaf8..aa7f34f 100644
 --- a/drivers/media/rc/iguanair.c
 +++ b/drivers/media/rc/iguanair.c
 @@ -35,9 +35,9 @@ struct iguanair {
   struct device *dev;
   struct usb_device *udev;
  
 - int pipe_in, pipe_out;
 + int pipe_out;
 + uint16_t version;
   uint8_t bufsize;
 - uint8_t version[2];
  
   struct mutex lock;
  
 @@ -61,20 +61,21 @@ struct iguanair {
  };
  
  #define CMD_GET_VERSION  0x01
 -#define CMD_GET_BUFSIZE  0x11
  #define CMD_GET_FEATURES 0x10
 +#define CMD_GET_BUFSIZE  0x11
 +#define CMD_RECEIVER_ON  0x12
 +#define CMD_RECEIVER_OFF 0x14
  #define CMD_SEND 0x15
 -#define CMD_EXECUTE  0x1f
 +#define CMD_GET_ID   0x1f
  #define CMD_RX_OVERFLOW  0x31
  #define CMD_TX_OVERFLOW  0x32
 -#define CMD_RECEIVER_ON  0x12
 -#define CMD_RECEIVER_OFF 0x14
  
  #define DIR_IN   0xdc
  #define DIR_OUT  0xcd
  
  #define MAX_PACKET_SIZE  8u
  #define TIMEOUT  1000
 +#define RX_RESOLUTION21330
  
  struct packet {
   uint16_t start;
 @@ -82,11 +83,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;
 @@ -96,10 +92,46 @@ struct send_packet {
   uint8_t payload[0];
  };
  
 +/*
 + * The hardware advertises a polling interval of 10ms. This is far too
 + * slow and will cause regular rx overflows.
 + */
 +static int int_urb_interval(struct usb_device *udev)
 +{
 + switch (udev-speed) {
 + case USB_SPEED_HIGH:
 + return 4;
 + case USB_SPEED_LOW:
 + return 1;
 + case USB_SPEED_FULL:
 + default:
 + return 1;
 + }
 +}
 +
  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 = (ir-buf_in[5]  8) |
 + ir-buf_in[4];
 + 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) {
 + ir-cycle_overhead = ir-buf_in[5];
 + complete(ir-completion);
 + }
 + break;
   case CMD_TX_OVERFLOW:
   ir-tx_overflow = true;
   case CMD_RECEIVER_OFF:
 @@ -109,6 +141,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);
   

[PATCH] [media] iguanair: various fixes

2012-07-31 Thread Sean Young
This fixes:
 - rx_overflow while holding down any down button on a nec remote
 - suspend/resume
 - stop receiver on rmmod
 - advertise rx_resolution and timeout properly
 - code simplify
 - ignore unsupported firmware versions

Signed-off-by: Sean Young s...@mess.org
---
 drivers/media/rc/Kconfig|   8 +-
 drivers/media/rc/iguanair.c | 206 ++--
 2 files changed, 107 insertions(+), 107 deletions(-)

diff --git a/drivers/media/rc/Kconfig b/drivers/media/rc/Kconfig
index 5180390..fa1745c 100644
--- a/drivers/media/rc/Kconfig
+++ b/drivers/media/rc/Kconfig
@@ -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.
diff --git a/drivers/media/rc/iguanair.c b/drivers/media/rc/iguanair.c
index 5e2eaf8..aa7f34f 100644
--- a/drivers/media/rc/iguanair.c
+++ b/drivers/media/rc/iguanair.c
@@ -35,9 +35,9 @@ struct iguanair {
struct device *dev;
struct usb_device *udev;
 
-   int pipe_in, pipe_out;
+   int pipe_out;
+   uint16_t version;
uint8_t bufsize;
-   uint8_t version[2];
 
struct mutex lock;
 
@@ -61,20 +61,21 @@ struct iguanair {
 };
 
 #define CMD_GET_VERSION0x01
-#define CMD_GET_BUFSIZE0x11
 #define CMD_GET_FEATURES   0x10
+#define CMD_GET_BUFSIZE0x11
+#define CMD_RECEIVER_ON0x12
+#define CMD_RECEIVER_OFF   0x14
 #define CMD_SEND   0x15
-#define CMD_EXECUTE0x1f
+#define CMD_GET_ID 0x1f
 #define CMD_RX_OVERFLOW0x31
 #define CMD_TX_OVERFLOW0x32
-#define CMD_RECEIVER_ON0x12
-#define CMD_RECEIVER_OFF   0x14
 
 #define DIR_IN 0xdc
 #define DIR_OUT0xcd
 
 #define MAX_PACKET_SIZE8u
 #define TIMEOUT1000
+#define RX_RESOLUTION  21330
 
 struct packet {
uint16_t start;
@@ -82,11 +83,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;
@@ -96,10 +92,46 @@ struct send_packet {
uint8_t payload[0];
 };
 
+/*
+ * The hardware advertises a polling interval of 10ms. This is far too
+ * slow and will cause regular rx overflows.
+ */
+static int int_urb_interval(struct usb_device *udev)
+{
+   switch (udev-speed) {
+   case USB_SPEED_HIGH:
+   return 4;
+   case USB_SPEED_LOW:
+   return 1;
+   case USB_SPEED_FULL:
+   default:
+   return 1;
+   }
+}
+
 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 = (ir-buf_in[5]  8) |
+   ir-buf_in[4];
+   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) {
+   ir-cycle_overhead = ir-buf_in[5];
+   complete(ir-completion);
+   }
+   break;
case CMD_TX_OVERFLOW:
ir-tx_overflow = true;
case CMD_RECEIVER_OFF:
@@ -109,6 +141,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,
@@ -128,7 +161,7 @@ static void process_ir_data(struct iguanair *ir, unsigned 
len)
} else {
rawir.pulse = (ir-buf_in[i]  0x80) == 0;
rawir.duration =