Commit 4f253cec authored by Sean Young's avatar Sean Young Committed by Mauro Carvalho Chehab

[media] redrat3: make hardware timeout configurable

Instead of hardcoding a timeout, let userspace change it dynamically
by adding a s_timeout ops.
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 25da661a
......@@ -292,6 +292,9 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
tmp > dev->max_timeout)
return -EINVAL;
if (dev->s_timeout)
ret = dev->s_timeout(dev, tmp);
if (!ret)
dev->timeout = tmp;
break;
......
......@@ -475,6 +475,37 @@ static u32 redrat3_get_timeout(struct redrat3_dev *rr3)
return timeout;
}
static int redrat3_set_timeout(struct rc_dev *rc_dev, unsigned int timeoutns)
{
struct redrat3_dev *rr3 = rc_dev->priv;
struct usb_device *udev = rr3->udev;
struct device *dev = rr3->dev;
u32 *timeout;
int ret;
timeout = kmalloc(sizeof(*timeout), GFP_KERNEL);
if (!timeout)
return -ENOMEM;
*timeout = cpu_to_be32(redrat3_us_to_len(timeoutns / 1000));
ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RR3_SET_IR_PARAM,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
RR3_IR_IO_SIG_TIMEOUT, 0, timeout, sizeof(*timeout),
HZ * 25);
dev_dbg(dev, "set ir parm timeout %d ret 0x%02x\n",
be32_to_cpu(*timeout), ret);
if (ret == sizeof(*timeout)) {
rr3->hw_timeout = timeoutns / 1000;
ret = 0;
} else if (ret >= 0)
ret = -EIO;
kfree(timeout);
return ret;
}
static void redrat3_reset(struct redrat3_dev *rr3)
{
struct usb_device *udev = rr3->udev;
......@@ -856,7 +887,10 @@ static struct rc_dev *redrat3_init_rc_dev(struct redrat3_dev *rr3)
rc->priv = rr3;
rc->driver_type = RC_DRIVER_IR_RAW;
rc->allowed_protocols = RC_BIT_ALL;
rc->min_timeout = MS_TO_NS(RR3_RX_MIN_TIMEOUT);
rc->max_timeout = MS_TO_NS(RR3_RX_MAX_TIMEOUT);
rc->timeout = US_TO_NS(rr3->hw_timeout);
rc->s_timeout = redrat3_set_timeout;
rc->tx_ir = redrat3_transmit_ir;
rc->s_tx_carrier = redrat3_set_tx_carrier;
rc->driver_name = DRIVER_NAME;
......
......@@ -119,6 +119,7 @@ enum rc_filter_type {
* @s_carrier_report: enable carrier reports
* @s_filter: set the scancode filter
* @s_wakeup_filter: set the wakeup scancode filter
* @s_timeout: set hardware timeout in ns
*/
struct rc_dev {
struct device dev;
......@@ -174,6 +175,8 @@ struct rc_dev {
struct rc_scancode_filter *filter);
int (*s_wakeup_filter)(struct rc_dev *dev,
struct rc_scancode_filter *filter);
int (*s_timeout)(struct rc_dev *dev,
unsigned int timeout);
};
#define to_rc_dev(d) container_of(d, struct rc_dev, dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment