summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2012-06-12 23:19:40 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-04 07:56:31 -0300
commit877e0aa790727eb7ceae189a721798424d820a0c (patch)
tree522f7d21fd340b1b0bc1f3c60f367a51f8f2c79b
parentcb4f77a385c3a6037c2c14d4aede7257e8dd2a6c (diff)
[media] dvb_usb_v2: move remote controller to the main file
It is only three functions so move it to the main. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/dvb-usb/Makefile2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb_usb_common.h3
-rw-r--r--drivers/media/dvb/dvb-usb/dvb_usb_init.c103
3 files changed, 104 insertions, 4 deletions
diff --git a/drivers/media/dvb/dvb-usb/Makefile b/drivers/media/dvb/dvb-usb/Makefile
index a0f5be28ca72..490e2a295f3f 100644
--- a/drivers/media/dvb/dvb-usb/Makefile
+++ b/drivers/media/dvb/dvb-usb/Makefile
@@ -1,7 +1,7 @@
dvb-usb-objs = dvb-usb-firmware.o dvb-usb-init.o dvb-usb-urb.o dvb-usb-i2c.o dvb-usb-dvb.o dvb-usb-remote.o usb-urb.o
obj-$(CONFIG_DVB_USB) += dvb-usb.o
-dvb_usbv2-objs = dvb_usb_init.o dvb_usb_urb.o dvb_usb_dvb.o dvb_usb_remote.o usb_urb.o
+dvb_usbv2-objs = dvb_usb_init.o dvb_usb_urb.o dvb_usb_dvb.o usb_urb.o
obj-$(CONFIG_DVB_USB_V2) += dvb_usbv2.o
obj-$(CONFIG_DVB_USB_FIRMWARE) += dvb_usb_firmware.o
diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_common.h b/drivers/media/dvb/dvb-usb/dvb_usb_common.h
index dcdccb7fde31..e1cff154c0ec 100644
--- a/drivers/media/dvb/dvb-usb/dvb_usb_common.h
+++ b/drivers/media/dvb/dvb-usb/dvb_usb_common.h
@@ -31,7 +31,4 @@ extern int dvb_usbv2_adapter_dvb_exit(struct dvb_usb_adapter *adap);
extern int dvb_usbv2_adapter_frontend_init(struct dvb_usb_adapter *adap);
extern int dvb_usbv2_adapter_frontend_exit(struct dvb_usb_adapter *adap);
-extern int dvb_usbv2_remote_init(struct dvb_usb_device *);
-extern int dvb_usbv2_remote_exit(struct dvb_usb_device *);
-
#endif
diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_init.c b/drivers/media/dvb/dvb-usb/dvb_usb_init.c
index be58b8422a33..ecc6bd253497 100644
--- a/drivers/media/dvb/dvb-usb/dvb_usb_init.c
+++ b/drivers/media/dvb/dvb-usb/dvb_usb_init.c
@@ -12,6 +12,7 @@
* see Documentation/dvb/README.dvb-usb for more information
*/
#include "dvb_usb_common.h"
+#include <linux/usb/input.h>
int dvb_usbv2_disable_rc_polling;
module_param_named(disable_rc_polling, dvb_usbv2_disable_rc_polling, int, 0644);
@@ -107,6 +108,108 @@ static int dvb_usbv2_i2c_exit(struct dvb_usb_device *d)
return 0;
}
+static void dvb_usb_read_remote_control(struct work_struct *work)
+{
+ struct dvb_usb_device *d = container_of(work,
+ struct dvb_usb_device, rc_query_work.work);
+ int ret;
+
+ /* TODO: need a lock here. We can simply skip checking for the remote
+ control if we're busy. */
+
+ /* when the parameter has been set to 1 via sysfs while the
+ * driver was running, or when bulk mode is enabled after IR init
+ */
+ if (dvb_usbv2_disable_rc_polling || d->rc.bulk_mode)
+ return;
+
+ ret = d->rc.query(d);
+ if (ret < 0)
+ pr_err("%s: error %d while querying for an remote control " \
+ "event\n", KBUILD_MODNAME, ret);
+
+ schedule_delayed_work(&d->rc_query_work,
+ msecs_to_jiffies(d->rc.interval));
+}
+
+static int dvb_usbv2_remote_init(struct dvb_usb_device *d)
+{
+ int ret;
+ struct rc_dev *dev;
+
+ if (dvb_usbv2_disable_rc_polling || !d->props->get_rc_config)
+ return 0;
+
+ ret = d->props->get_rc_config(d, &d->rc);
+ if (ret < 0)
+ goto err;
+
+ dev = rc_allocate_device();
+ if (!dev) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ dev->dev.parent = &d->udev->dev;
+ dev->input_name = "IR-receiver inside an USB DVB receiver";
+ usb_make_path(d->udev, d->rc_phys, sizeof(d->rc_phys));
+ strlcat(d->rc_phys, "/ir0", sizeof(d->rc_phys));
+ dev->input_phys = d->rc_phys;
+ usb_to_input_id(d->udev, &dev->input_id);
+ /* TODO: likely RC-core should took const char * */
+ dev->driver_name = (char *) d->props->driver_name;
+ dev->driver_type = d->rc.driver_type;
+ dev->allowed_protos = d->rc.allowed_protos;
+ dev->change_protocol = d->rc.change_protocol;
+ dev->priv = d;
+ /* select used keymap */
+ if (d->rc.map_name)
+ dev->map_name = d->rc.map_name;
+ else if (d->rc_map)
+ dev->map_name = d->rc_map;
+ else
+ dev->map_name = RC_MAP_EMPTY; /* keep rc enabled */
+
+ ret = rc_register_device(dev);
+ if (ret < 0) {
+ rc_free_device(dev);
+ goto err;
+ }
+
+ d->input_dev = NULL;
+ d->rc_dev = dev;
+
+ /* start polling if needed */
+ if (d->rc.query && !d->rc.bulk_mode) {
+ /* initialize a work queue for handling polling */
+ INIT_DELAYED_WORK(&d->rc_query_work,
+ dvb_usb_read_remote_control);
+ pr_info("%s: schedule remote query interval to %d msecs\n",
+ KBUILD_MODNAME, d->rc.interval);
+ schedule_delayed_work(&d->rc_query_work,
+ msecs_to_jiffies(d->rc.interval));
+ }
+
+ d->state |= DVB_USB_STATE_REMOTE;
+
+ return 0;
+err:
+ pr_debug("%s: failed=%d\n", __func__, ret);
+ return ret;
+}
+
+static int dvb_usbv2_remote_exit(struct dvb_usb_device *d)
+{
+ if (d->state & DVB_USB_STATE_REMOTE) {
+ cancel_delayed_work_sync(&d->rc_query_work);
+ rc_unregister_device(d->rc_dev);
+ }
+
+ d->state &= ~DVB_USB_STATE_REMOTE;
+
+ return 0;
+}
+
static int dvb_usbv2_adapter_init(struct dvb_usb_device *d)
{
struct dvb_usb_adapter *adap;