]> err.no Git - linux-2.6/commitdiff
V4L/DVB (5964): Fixed remote control for dib0700 with new firmware
authorJanne Grunau <janne-dvb@grunau.be>
Tue, 31 Jul 2007 22:45:13 +0000 (19:45 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 10 Oct 2007 01:04:05 +0000 (22:04 -0300)
The new firmware returns the data of the REQUEST_POLL_RC request in
reversed order. The default is RC5, but it can be adjusted using a
module parameter.

Signed-off-by: Janne Grunau <janne-dvb@grunau.be>
Signed-off-by: Patrick Boettcher <pb@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/dvb/dvb-usb/dib0700.h
drivers/media/dvb/dvb-usb/dib0700_core.c
drivers/media/dvb/dvb-usb/dib0700_devices.c

index 74ae6c24087ef6b603ebc067601e9b49eacd1ba1..4a903ea958965d5bc7cbadbd96f2282e89dedf34 100644 (file)
@@ -30,6 +30,7 @@ extern int dvb_usb_dib0700_debug;
        // 1 Byte: 4MSB(1 = enable streaming, 0 = disable streaming) 4LSB(Video Mode: 0 = MPEG2 188Bytes, 1 = Analog)
        // 2 Byte: MPEG2 mode:  4MSB(1 = Master Mode, 0 = Slave Mode) 4LSB(Channel 1 = bit0, Channel 2 = bit1)
        // 2 Byte: Analog mode: 4MSB(0 = 625 lines, 1 = 525 lines)    4LSB(     "                "           )
+#define REQUEST_SET_RC       0x11
 #define REQUEST_GET_VERSION  0x15
 
 struct dib0700_state {
index 8a1ea114deb04e5e9bd7ef0b1d0095634a2fa906..3ea294eb96bdedc4a7b6e12dfa3af42143cedb6c 100644 (file)
@@ -13,6 +13,10 @@ int dvb_usb_dib0700_debug;
 module_param_named(debug,dvb_usb_dib0700_debug, int, 0644);
 MODULE_PARM_DESC(debug, "set debugging level (1=info,2=fw,4=fwdata,8=data (or-able))." DVB_USB_DEBUG_STATUS);
 
+static int dvb_usb_dib0700_ir_proto = 1;
+module_param(dvb_usb_dib0700_ir_proto, int, 0644);
+MODULE_PARM_DESC(dvb_usb_dib0700_ir_proto, "set ir protocol (0=NEC, 1=RC5 (default), 2=RC6).");
+
 /* expecting rx buffer: request data[0] data[1] ... data[2] */
 static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
 {
@@ -260,14 +264,29 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
        return dib0700_ctrl_wr(adap->dev, b, 4);
 }
 
+static int dib0700_rc_setup(struct dvb_usb_device *d)
+{
+       u8 rc_setup[3] = {REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0};
+       int i = dib0700_ctrl_wr(d, rc_setup, 3);
+       if (i<0) {
+               err("ir protocol setup failed");
+               return -1;
+       }
+       return 0;
+}
+
 static int dib0700_probe(struct usb_interface *intf,
                const struct usb_device_id *id)
 {
        int i;
+       struct dvb_usb_device *dev;
 
        for (i = 0; i < dib0700_device_count; i++)
-               if (dvb_usb_device_init(intf, &dib0700_devices[i], THIS_MODULE, NULL) == 0)
+               if (dvb_usb_device_init(intf, &dib0700_devices[i], THIS_MODULE, &dev) == 0)
+               {
+                       dib0700_rc_setup(dev);
                        return 0;
+               }
 
        return -ENODEV;
 }
index 0eca0fc75327001b89fde08e86cb1d4b19ed677f..4a3c5467d7e05f1e67ccfc86d6258f573eabc903 100644 (file)
@@ -275,19 +275,19 @@ static int dib0700_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
        i=dib0700_ctrl_rd(d,rc_request,2,key,4);
        if (i<=0) {
                err("RC Query Failed");
-               return 0;
+               return -1;
        }
        if (key[0]==0 && key[1]==0 && key[2]==0 && key[3]==0) return 0;
-       if (key[1]!=st->rc_toggle) {
+       if (key[3-1]!=st->rc_toggle) {
                for (i=0;i<d->props.rc_key_map_size; i++) {
-                       if (keymap[i].custom == key[2] && keymap[i].data == key[3]) {
+                       if (keymap[i].custom == key[3-2] && keymap[i].data == key[3-3]) {
                                *event = keymap[i].event;
                                *state = REMOTE_KEY_PRESSED;
-                               st->rc_toggle=key[1];
+                               st->rc_toggle=key[3-1];
                                return 0;
                        }
                }
-               err("Unknown remote controller key : %2X %2X",(int)key[2],(int)key[3]);
+               err("Unknown remote controller key : %2X %2X",(int)key[3-2],(int)key[3-3]);
        }
        return 0;
 }