Skip to content

Commit f0c15b3

Browse files
seanyoungmchehab
authored andcommitted
media: ir_toy: prevent device from hanging during transmit
If the IR Toy is receiving IR while a transmit is done, it may end up hanging. We can prevent this from happening by re-entering sample mode just before issuing the transmit command. Link: bengtmartensson/HarcHardware#25 Cc: [email protected] Signed-off-by: Sean Young <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 3ad02c2 commit f0c15b3

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

drivers/media/rc/ir_toy.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ static const u8 COMMAND_VERSION[] = { 'v' };
2424
// End transmit and repeat reset command so we exit sump mode
2525
static const u8 COMMAND_RESET[] = { 0xff, 0xff, 0, 0, 0, 0, 0 };
2626
static const u8 COMMAND_SMODE_ENTER[] = { 's' };
27+
static const u8 COMMAND_SMODE_EXIT[] = { 0 };
2728
static const u8 COMMAND_TXSTART[] = { 0x26, 0x24, 0x25, 0x03 };
2829

2930
#define REPLY_XMITCOUNT 't'
@@ -309,12 +310,30 @@ static int irtoy_tx(struct rc_dev *rc, uint *txbuf, uint count)
309310
buf[i] = cpu_to_be16(v);
310311
}
311312

312-
buf[count] = cpu_to_be16(0xffff);
313+
buf[count] = 0xffff;
313314

314315
irtoy->tx_buf = buf;
315316
irtoy->tx_len = size;
316317
irtoy->emitted = 0;
317318

319+
// There is an issue where if the unit is receiving IR while the
320+
// first TXSTART command is sent, the device might end up hanging
321+
// with its led on. It does not respond to any command when this
322+
// happens. To work around this, re-enter sample mode.
323+
err = irtoy_command(irtoy, COMMAND_SMODE_EXIT,
324+
sizeof(COMMAND_SMODE_EXIT), STATE_RESET);
325+
if (err) {
326+
dev_err(irtoy->dev, "exit sample mode: %d\n", err);
327+
return err;
328+
}
329+
330+
err = irtoy_command(irtoy, COMMAND_SMODE_ENTER,
331+
sizeof(COMMAND_SMODE_ENTER), STATE_COMMAND);
332+
if (err) {
333+
dev_err(irtoy->dev, "enter sample mode: %d\n", err);
334+
return err;
335+
}
336+
318337
err = irtoy_command(irtoy, COMMAND_TXSTART, sizeof(COMMAND_TXSTART),
319338
STATE_TX);
320339
kfree(buf);

0 commit comments

Comments
 (0)