All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org, Matthias Reichl <hias@horus.com>
Cc: Carlo Caione <carlo@caione.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Alex Deryskyba <alex@codesnake.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	linux-amlogic@lists.infradead.org
Subject: [PATCH v2 7/7] media: rc: mceusb: allow the timeout to be configurable
Date: Sun,  8 Apr 2018 22:19:42 +0100	[thread overview]
Message-ID: <02b5dac3b27169c6e6a4a070a2569b33fef47bbe.1523221902.git.sean@mess.org> (raw)
In-Reply-To: <cover.1523221902.git.sean@mess.org>
In-Reply-To: <cover.1523221902.git.sean@mess.org>

mceusb devices have a default timeout of 100ms, but this can be changed.

Signed-off-by: Sean Young <sean@mess.org>
---
 drivers/media/rc/mceusb.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 69ba57372c05..c97cb2eb1c5f 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -982,6 +982,25 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
 	return 0;
 }
 
+static int mceusb_set_timeout(struct rc_dev *dev, unsigned int timeout)
+{
+	u8 cmdbuf[4] = { MCE_CMD_PORT_IR, MCE_CMD_SETIRTIMEOUT, 0, 0 };
+	struct mceusb_dev *ir = dev->priv;
+	unsigned int units;
+
+	units = DIV_ROUND_CLOSEST(timeout, US_TO_NS(MCE_TIME_UNIT));
+
+	cmdbuf[2] = units >> 8;
+	cmdbuf[3] = units;
+
+	mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
+
+	/* get receiver timeout value */
+	mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT));
+
+	return 0;
+}
+
 /*
  * Select or deselect the 2nd receiver port.
  * Second receiver is learning mode, wide-band, short-range receiver.
@@ -1415,7 +1434,10 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
 	rc->dev.parent = dev;
 	rc->priv = ir;
 	rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
+	rc->min_timeout = US_TO_NS(MCE_TIME_UNIT);
 	rc->timeout = MS_TO_NS(100);
+	rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
+	rc->s_timeout = mceusb_set_timeout;
 	if (!ir->flags.no_tx) {
 		rc->s_tx_mask = mceusb_set_tx_mask;
 		rc->s_tx_carrier = mceusb_set_tx_carrier;
-- 
2.14.3

WARNING: multiple messages have this Message-ID (diff)
From: sean@mess.org (Sean Young)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH v2 7/7] media: rc: mceusb: allow the timeout to be configurable
Date: Sun,  8 Apr 2018 22:19:42 +0100	[thread overview]
Message-ID: <02b5dac3b27169c6e6a4a070a2569b33fef47bbe.1523221902.git.sean@mess.org> (raw)
In-Reply-To: <cover.1523221902.git.sean@mess.org>

mceusb devices have a default timeout of 100ms, but this can be changed.

Signed-off-by: Sean Young <sean@mess.org>
---
 drivers/media/rc/mceusb.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
index 69ba57372c05..c97cb2eb1c5f 100644
--- a/drivers/media/rc/mceusb.c
+++ b/drivers/media/rc/mceusb.c
@@ -982,6 +982,25 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier)
 	return 0;
 }
 
+static int mceusb_set_timeout(struct rc_dev *dev, unsigned int timeout)
+{
+	u8 cmdbuf[4] = { MCE_CMD_PORT_IR, MCE_CMD_SETIRTIMEOUT, 0, 0 };
+	struct mceusb_dev *ir = dev->priv;
+	unsigned int units;
+
+	units = DIV_ROUND_CLOSEST(timeout, US_TO_NS(MCE_TIME_UNIT));
+
+	cmdbuf[2] = units >> 8;
+	cmdbuf[3] = units;
+
+	mce_async_out(ir, cmdbuf, sizeof(cmdbuf));
+
+	/* get receiver timeout value */
+	mce_async_out(ir, GET_RX_TIMEOUT, sizeof(GET_RX_TIMEOUT));
+
+	return 0;
+}
+
 /*
  * Select or deselect the 2nd receiver port.
  * Second receiver is learning mode, wide-band, short-range receiver.
@@ -1415,7 +1434,10 @@ static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir)
 	rc->dev.parent = dev;
 	rc->priv = ir;
 	rc->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER;
+	rc->min_timeout = US_TO_NS(MCE_TIME_UNIT);
 	rc->timeout = MS_TO_NS(100);
+	rc->max_timeout = 10 * IR_DEFAULT_TIMEOUT;
+	rc->s_timeout = mceusb_set_timeout;
 	if (!ir->flags.no_tx) {
 		rc->s_tx_mask = mceusb_set_tx_mask;
 		rc->s_tx_carrier = mceusb_set_tx_carrier;
-- 
2.14.3

  parent reply	other threads:[~2018-04-08 21:19 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-08 21:19 [PATCH v2 0/7] Improve latency of IR decoding Sean Young
2018-04-08 21:19 ` Sean Young
2018-04-08 21:19 ` [PATCH v2 1/7] media: rc: set timeout to smallest value required by enabled protocols Sean Young
2018-04-08 21:19   ` Sean Young
2018-04-08 21:19 ` [PATCH v2 2/7] media: rc: add ioctl to get the current timeout Sean Young
2018-04-08 21:19   ` Sean Young
2018-04-08 21:19 ` [PATCH v2 3/7] media: rc: per-protocol repeat period and minimum keyup timer Sean Young
2018-04-08 21:19   ` Sean Young
2018-04-08 21:19 ` [PATCH v2 4/7] media: rc: mce_kbd decoder: low timeout values cause double keydowns Sean Young
2018-04-08 21:19   ` Sean Young
2018-04-08 21:19 ` [PATCH v2 5/7] media: rc: mce_kbd protocol encodes two scancodes Sean Young
2018-04-08 21:19   ` Sean Young
2018-04-08 21:19 ` [PATCH v2 6/7] media: rc: mce_kbd decoder: fix stuck keys Sean Young
2018-04-08 21:19   ` Sean Young
2018-04-08 21:19 ` Sean Young [this message]
2018-04-08 21:19   ` [PATCH v2 7/7] media: rc: mceusb: allow the timeout to be configurable Sean Young
2018-04-17 19:14   ` Matthias Reichl
2018-04-17 19:14     ` Matthias Reichl
2018-04-18 11:24     ` Sean Young
2018-04-18 11:24       ` Sean Young
2018-04-18 17:42       ` Matthias Reichl
2018-04-18 17:42         ` Matthias Reichl
2018-04-19 22:17         ` Matthias Reichl
2018-04-19 22:17           ` Matthias Reichl
2018-04-21 13:18           ` Matthias Reichl
2018-04-21 13:18             ` Matthias Reichl
2018-04-21 17:41             ` Matthias Reichl
2018-04-21 17:41               ` Matthias Reichl
2018-05-07 15:54               ` Matthias Reichl
2018-05-09 21:44                 ` Sean Young
2018-05-10 11:01                   ` Matthias Reichl
2018-05-13 11:34                     ` Matthias Reichl
2018-04-10 17:53 ` [PATCH v2 0/7] Improve latency of IR decoding Matthias Reichl
2018-04-10 17:53   ` Matthias Reichl
2018-04-10 18:39   ` Sean Young
2018-04-10 18:39     ` Sean Young
2018-04-10 19:24     ` Matthias Reichl
2018-04-10 19:24       ` Matthias Reichl
2018-04-12 22:02       ` Sean Young
2018-04-12 22:02         ` Sean Young

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02b5dac3b27169c6e6a4a070a2569b33fef47bbe.1523221902.git.sean@mess.org \
    --to=sean@mess.org \
    --cc=alex@codesnake.com \
    --cc=carlo@caione.org \
    --cc=hias@horus.com \
    --cc=hkallweit1@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-media@vger.kernel.org \
    --cc=narmstrong@baylibre.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.