Skip to content

Commit dde7edf

Browse files
seanyoungmchehab
authored andcommitted
media: lirc: when transmitting scancodes, block until transmit is done
The semantics for lirc IR transmit with raw IR is that the write call should block until the IR is transmitted. Some drivers have no idea when this actually is (e.g. mceusb), so there is a wait. This is useful for userspace, as it might want to send a IR button press, a gap of a predefined number of milliseconds, and then send a repeat message. It turns out that for transmitting scancodes this feature is even more useful, as user space has no idea how long the IR is. So, maintain the existing semantics for IR scancode transmit. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent fb7ccc6 commit dde7edf

2 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎Documentation/media/uapi/rc/lirc-write.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ When in :ref:`LIRC_MODE_SCANCODE <lirc-mode-scancode>` mode, one
6060
and the protocol in the :c:type:`rc_proto`: member. All other members must be
6161
set to 0, else ``EINVAL`` is returned. If there is no protocol encoder
6262
for the protocol or the scancode is not valid for the specified protocol,
63-
``EINVAL`` is returned. The write function may not wait until the scancode
64-
is transmitted.
63+
``EINVAL`` is returned. The write function blocks until the scancode
64+
is transmitted by the hardware.
6565
6666
6767
Return Value

‎drivers/media/rc/lirc_dev.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,18 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char __user *buf,
354354
duration += txbuf[i];
355355

356356
ret *= sizeof(unsigned int);
357+
}
357358

358-
/*
359-
* The lircd gap calculation expects the write function to
360-
* wait for the actual IR signal to be transmitted before
361-
* returning.
362-
*/
363-
towait = ktime_us_delta(ktime_add_us(start, duration),
364-
ktime_get());
365-
if (towait > 0) {
366-
set_current_state(TASK_INTERRUPTIBLE);
367-
schedule_timeout(usecs_to_jiffies(towait));
368-
}
359+
/*
360+
* The lircd gap calculation expects the write function to
361+
* wait for the actual IR signal to be transmitted before
362+
* returning.
363+
*/
364+
towait = ktime_us_delta(ktime_add_us(start, duration),
365+
ktime_get());
366+
if (towait > 0) {
367+
set_current_state(TASK_INTERRUPTIBLE);
368+
schedule_timeout(usecs_to_jiffies(towait));
369369
}
370370

371371
out:

0 commit comments

Comments
 (0)