Commit c6a3ea57 authored by Sean Young's avatar Sean Young Committed by Mauro Carvalho Chehab

[media] iguanair: intermittent initialization failure

On cold boot the device does not initialize until the first packet is
received, and that packet is not processed.
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d0aab656
...@@ -58,6 +58,7 @@ struct iguanair { ...@@ -58,6 +58,7 @@ struct iguanair {
char phys[64]; char phys[64];
}; };
#define CMD_NOP 0x00
#define CMD_GET_VERSION 0x01 #define CMD_GET_VERSION 0x01
#define CMD_GET_BUFSIZE 0x11 #define CMD_GET_BUFSIZE 0x11
#define CMD_GET_FEATURES 0x10 #define CMD_GET_FEATURES 0x10
...@@ -196,6 +197,10 @@ static void iguanair_irq_out(struct urb *urb) ...@@ -196,6 +197,10 @@ static void iguanair_irq_out(struct urb *urb)
if (urb->status) if (urb->status)
dev_dbg(ir->dev, "Error: out urb status = %d\n", urb->status); dev_dbg(ir->dev, "Error: out urb status = %d\n", urb->status);
/* if we sent an nop packet, do not expect a response */
if (urb->status == 0 && ir->packet->header.cmd == CMD_NOP)
complete(&ir->completion);
} }
static int iguanair_send(struct iguanair *ir, unsigned size) static int iguanair_send(struct iguanair *ir, unsigned size)
...@@ -219,10 +224,17 @@ static int iguanair_get_features(struct iguanair *ir) ...@@ -219,10 +224,17 @@ static int iguanair_get_features(struct iguanair *ir)
{ {
int rc; int rc;
/*
* On cold boot, the iguanair initializes on the first packet
* received but does not process that packet. Send an empty
* packet.
*/
ir->packet->header.start = 0; ir->packet->header.start = 0;
ir->packet->header.direction = DIR_OUT; ir->packet->header.direction = DIR_OUT;
ir->packet->header.cmd = CMD_GET_VERSION; ir->packet->header.cmd = CMD_NOP;
iguanair_send(ir, sizeof(ir->packet->header));
ir->packet->header.cmd = CMD_GET_VERSION;
rc = iguanair_send(ir, sizeof(ir->packet->header)); rc = iguanair_send(ir, sizeof(ir->packet->header));
if (rc) { if (rc) {
dev_info(ir->dev, "failed to get version\n"); dev_info(ir->dev, "failed to get version\n");
...@@ -255,19 +267,14 @@ static int iguanair_get_features(struct iguanair *ir) ...@@ -255,19 +267,14 @@ static int iguanair_get_features(struct iguanair *ir)
ir->packet->header.cmd = CMD_GET_FEATURES; ir->packet->header.cmd = CMD_GET_FEATURES;
rc = iguanair_send(ir, sizeof(ir->packet->header)); rc = iguanair_send(ir, sizeof(ir->packet->header));
if (rc) { if (rc)
dev_info(ir->dev, "failed to get features\n"); dev_info(ir->dev, "failed to get features\n");
goto out;
}
out: out:
return rc; return rc;
} }
static int iguanair_receiver(struct iguanair *ir, bool enable) static int iguanair_receiver(struct iguanair *ir, bool enable)
{ {
int rc;
ir->packet->header.start = 0; ir->packet->header.start = 0;
ir->packet->header.direction = DIR_OUT; ir->packet->header.direction = DIR_OUT;
ir->packet->header.cmd = enable ? CMD_RECEIVER_ON : CMD_RECEIVER_OFF; ir->packet->header.cmd = enable ? CMD_RECEIVER_ON : CMD_RECEIVER_OFF;
...@@ -275,9 +282,7 @@ static int iguanair_receiver(struct iguanair *ir, bool enable) ...@@ -275,9 +282,7 @@ static int iguanair_receiver(struct iguanair *ir, bool enable)
if (enable) if (enable)
ir_raw_event_reset(ir->rc); ir_raw_event_reset(ir->rc);
rc = iguanair_send(ir, sizeof(ir->packet->header)); return iguanair_send(ir, sizeof(ir->packet->header));
return rc;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment