V4L/DVB (13545): em28xx: properly select IR protocol based on the IR table
authorMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 5 Dec 2009 11:27:49 +0000 (08:27 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 16 Dec 2009 02:17:52 +0000 (00:17 -0200)
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/em28xx/em28xx-core.c
drivers/media/video/em28xx/em28xx-input.c
drivers/media/video/em28xx/em28xx.h

index 3f86d36dff2b0e490dcad8dd5ca93dbd6fd3ab2f..4f61e05d30b491abd9588b16de63cdcad7e2b1c3 100644 (file)
@@ -216,7 +216,7 @@ int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val)
  * sets only some bits (specified by bitmask) of a register, by first reading
  * the actual value
  */
-static int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
+int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
                                 u8 bitmask)
 {
        int oldval;
index d96ec7c09dcaab1580cbfd9bf3e1435dd151615e..3f5cf02f31476d49fbf232f9e7496e4719de3e79 100644 (file)
@@ -337,19 +337,28 @@ int em28xx_ir_init(struct em28xx *dev)
                goto err_out_free;
 
        ir->input = input_dev;
+       ir_config = EM2874_IR_RC5;
+
+       /* Adjust xclk based o IR table for RC5/NEC tables */
+       if (dev->board.ir_codes->ir_type == IR_TYPE_RC5) {
+               dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE;
+               ir->full_code = 1;
+       } else  if (dev->board.ir_codes->ir_type == IR_TYPE_NEC) {
+               dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE;
+               ir_config = EM2874_IR_NEC;
+               ir->full_code = 1;
+       }
+       em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk,
+                             EM28XX_XCLK_IR_RC5_MODE);
 
        /* Setup the proper handler based on the chip */
        switch (dev->chip_id) {
        case CHIP_ID_EM2860:
        case CHIP_ID_EM2883:
-               if (dev->model == EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950)
-                       ir->full_code = 1;
                ir->get_key = default_polling_getkey;
                break;
        case CHIP_ID_EM2874:
                ir->get_key = em2874_polling_getkey;
-               /* For now we only support RC5, so enable it */
-               ir_config = EM2874_IR_RC5;
                em28xx_write_regs(dev, EM2874_R50_IR_CONFIG, &ir_config, 1);
                break;
        default:
index 441df644ddbe329146329e17854d82de9842d808..48977832316eaafaadf374ae21f62692d836a9ae 100644 (file)
@@ -643,6 +643,8 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
                          int len);
 int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len);
 int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val);
+int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
+                                u8 bitmask);
 
 int em28xx_read_ac97(struct em28xx *dev, u8 reg);
 int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val);