From 528222d853f9283110f0118dd71d9f0ad686d586 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Sun, 23 Aug 2020 19:23:05 +0200 Subject: media: rc: harmonize infrared durations to microseconds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rc-core kapi uses nanoseconds for infrared durations for receiving, and microseconds for sending. The uapi already uses microseconds for both, so this patch does not change the uapi. Infrared durations do not need nanosecond resolution. IR protocols do not have durations shorter than about 100 microseconds. Some IR hardware offers 250 microseconds resolution, which is sufficient for most protocols. Better hardware has 50 microsecond resolution and is enough for every protocol I am aware off. Unify on microseconds everywhere. This simplifies the code since less conversion between microseconds and nanoseconds needs to be done. This affects: - rx_resolution member of struct rc_dev - timeout member of struct rc_dev - duration member in struct ir_raw_event Cc: "Bruno Prémont" Cc: Hans Verkuil Cc: Maxim Levitsky Cc: Patrick Lerda Cc: Kevin Hilman Cc: Neil Armstrong Cc: Jerome Brunet Cc: Martin Blumenstingl Cc: Sean Wang Cc: Matthias Brugger Cc: Patrice Chotard Cc: Maxime Ripard Cc: Chen-Yu Tsai Cc: "David Härdeman" Cc: Benjamin Valentin Cc: Antti Palosaari Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- drivers/media/usb/au0828/au0828-input.c | 8 ++++---- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 4 ++-- drivers/media/usb/dvb-usb/technisat-usb2.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/media/usb') diff --git a/drivers/media/usb/au0828/au0828-input.c b/drivers/media/usb/au0828/au0828-input.c index 4befa920246c..3d3368202cd0 100644 --- a/drivers/media/usb/au0828/au0828-input.c +++ b/drivers/media/usb/au0828/au0828-input.c @@ -104,11 +104,11 @@ static int au8522_rc_andor(struct au0828_rc *ir, u16 reg, u8 mask, u8 value) /* Remote Controller time units */ -#define AU8522_UNIT 200000 /* ns */ -#define NEC_START_SPACE (4500000 / AU8522_UNIT) -#define NEC_START_PULSE (562500 * 16) +#define AU8522_UNIT 200 /* us */ +#define NEC_START_SPACE (4500 / AU8522_UNIT) +#define NEC_START_PULSE (563 * 16) #define RC5_START_SPACE (4 * AU8522_UNIT) -#define RC5_START_PULSE 888888 +#define RC5_START_PULSE 889 static int au0828_get_key_au8522(struct au0828_rc *ir) { diff --git a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c index 2080f6ef4be1..91460e4d0c30 100644 --- a/drivers/media/usb/dvb-usb-v2/rtl28xxu.c +++ b/drivers/media/usb/dvb-usb-v2/rtl28xxu.c @@ -1781,7 +1781,7 @@ static int rtl2832u_rc_query(struct dvb_usb_device *d) /* pass data to Kernel IR decoder */ for (i = 0; i < len; i++) { ev.pulse = buf[i] >> 7; - ev.duration = 50800 * (buf[i] & 0x7f); + ev.duration = 51 * (buf[i] & 0x7f); ir_raw_event_store_with_filter(d->rc_dev, &ev); } @@ -1809,7 +1809,7 @@ static int rtl2832u_get_rc_config(struct dvb_usb_device *d, rc->query = rtl2832u_rc_query; rc->interval = 200; /* we program idle len to 0xc0, set timeout to one less */ - rc->timeout = 0xbf * 50800; + rc->timeout = 0xbf * 51; return 0; } diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c index f172120db2aa..a9ed26ce1be6 100644 --- a/drivers/media/usb/dvb-usb/technisat-usb2.c +++ b/drivers/media/usb/dvb-usb/technisat-usb2.c @@ -656,14 +656,14 @@ unlock: for (i = 1; i < ARRAY_SIZE(state->buf); i++) { if (buf[i] == 0xff) { ev.pulse = 0; - ev.duration = 888888*2; + ev.duration = 889 * 2; ir_raw_event_store(d->rc_dev, &ev); break; } ev.pulse = !ev.pulse; ev.duration = (buf[i] * FIRMWARE_CLOCK_DIVISOR * - FIRMWARE_CLOCK_TICK) / 1000; + FIRMWARE_CLOCK_TICK) / (1000 * 1000); ir_raw_event_store(d->rc_dev, &ev); } -- cgit