Commit 528222d8 authored by Sean Young's avatar Sean Young Committed by Mauro Carvalho Chehab
Browse files

media: rc: harmonize infrared durations to microseconds



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" <bonbons@linux-vserver.org>
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Patrick Lerda <patrick9876@free.fr>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: Sean Wang <sean.wang@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Chen-Yu Tsai <wens@csie.org>
Cc: "David Härdeman" <david@hardeman.nu>
Cc: Benjamin Valentin <benpicco@googlemail.com>
Cc: Antti Palosaari <crope@iki.fi>
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 32c3db3d
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -59,10 +59,10 @@ int picolcd_raw_cir(struct picolcd_data *data,
	for (i = 0; i+1 < sz; i += 2) {
		w = (raw_data[i] << 8) | (raw_data[i+1]);
		rawir.pulse = !!(w & 0x8000);
		rawir.duration = US_TO_NS(rawir.pulse ? (65536 - w) : w);
		rawir.duration = rawir.pulse ? (65536 - w) : w;
		/* Quirk!! - see above */
		if (i == 0 && rawir.duration > 15000000)
			rawir.duration -= 15000000;
		if (i == 0 && rawir.duration > 15000)
			rawir.duration -= 15000;
		ir_raw_event_store(data->rc_dev, &rawir);
	}
	ir_raw_event_handle(data->rc_dev);
@@ -114,8 +114,8 @@ int picolcd_init_cir(struct picolcd_data *data, struct hid_report *report)
	rdev->dev.parent       = &data->hdev->dev;
	rdev->driver_name      = PICOLCD_NAME;
	rdev->map_name         = RC_MAP_RC6_MCE;
	rdev->timeout          = MS_TO_NS(100);
	rdev->rx_resolution    = US_TO_NS(1);
	rdev->timeout          = MS_TO_US(100);
	rdev->rx_resolution    = 1;

	ret = rc_register_device(rdev);
	if (ret)
+1 −1
Original line number Diff line number Diff line
@@ -309,7 +309,7 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
	adap->rc->allowed_protocols = RC_PROTO_BIT_CEC;
	adap->rc->priv = adap;
	adap->rc->map_name = RC_MAP_CEC;
	adap->rc->timeout = MS_TO_NS(550);
	adap->rc->timeout = MS_TO_US(550);
#endif
	return adap;
}
+1 −1
Original line number Diff line number Diff line
@@ -369,7 +369,7 @@ static int secocec_ir_probe(void *priv)
	cec->ir->allowed_protocols = RC_PROTO_BIT_RC5;
	cec->ir->priv = cec;
	cec->ir->map_name = RC_MAP_HAUPPAUGE;
	cec->ir->timeout = MS_TO_NS(100);
	cec->ir->timeout = MS_TO_US(100);

	/* Clear the status register */
	status = smb_rd16(SECOCEC_STATUS_REG_1, &val);
+2 −2
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ void sms_ir_event(struct smscore_device_t *coredev, const char *buf, int len)

	for (i = 0; i < len >> 2; i++) {
		struct ir_raw_event ev = {
			.duration = abs(samples[i]) * 1000, /* Convert to ns */
			.duration = abs(samples[i]),
			.pulse = (samples[i] > 0) ? false : true
		};

@@ -48,7 +48,7 @@ int sms_ir_init(struct smscore_device_t *coredev)
		return -ENOMEM;

	coredev->ir.controller = 0;	/* Todo: vega/nova SPI number */
	coredev->ir.timeout = IR_DEFAULT_TIMEOUT;
	coredev->ir.timeout = US_TO_NS(IR_DEFAULT_TIMEOUT);
	pr_debug("IR port %d, timeout %d ms\n",
			coredev->ir.controller, coredev->ir.timeout);

+1 −1
Original line number Diff line number Diff line
@@ -688,7 +688,7 @@ static int cx25840_ir_rx_read(struct v4l2_subdev *sd, u8 *buf, size_t count,
		}

		v = (unsigned) pulse_width_count_to_ns(
				  (u16) (p->hw_fifo_data & FIFO_RXTX), divider);
				  (u16)(p->hw_fifo_data & FIFO_RXTX), divider) / 1000;
		if (v > IR_MAX_DURATION)
			v = IR_MAX_DURATION;

Loading