aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/cx231xx/cx231xx-input.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-11-11 06:14:16 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-12-29 05:16:38 -0500
commit141bb0dc2d0ad03202aef7c070555cd970ca6bf9 (patch)
tree7a90847af8e37a438e4b3ccdcf24c9d3c63c3149 /drivers/media/video/cx231xx/cx231xx-input.c
parent2eb258327722de3ed4d84ce1b9add2bad21a0ec4 (diff)
[media] cx231xx: Fix i2c support at cx231xx-input
There was a bug at cx231xx-input, where it were registering the remote controls twice, one via ir-kbd-i2c and another directly. Also, the patch that added rc_register_device() broke compilation for it. This patch fixes cx231xx-input by fixing the depends on, to point to the new symbol, and initializing the scanmask via platform_data. While here, also fix Kconfig symbol change for IR core dependencies. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cx231xx/cx231xx-input.c')
-rw-r--r--drivers/media/video/cx231xx/cx231xx-input.c55
1 files changed, 17 insertions, 38 deletions
diff --git a/drivers/media/video/cx231xx/cx231xx-input.c b/drivers/media/video/cx231xx/cx231xx-input.c
index 6725244c400c..65d951e03c17 100644
--- a/drivers/media/video/cx231xx/cx231xx-input.c
+++ b/drivers/media/video/cx231xx/cx231xx-input.c
@@ -29,6 +29,8 @@ static int get_key_isdbt(struct IR_i2c *ir, u32 *ir_key,
29{ 29{
30 u8 cmd; 30 u8 cmd;
31 31
32 dev_dbg(&ir->rc->input_dev->dev, "%s\n", __func__);
33
32 /* poll IR chip */ 34 /* poll IR chip */
33 if (1 != i2c_master_recv(ir->c, &cmd, 1)) 35 if (1 != i2c_master_recv(ir->c, &cmd, 1))
34 return -EIO; 36 return -EIO;
@@ -40,7 +42,7 @@ static int get_key_isdbt(struct IR_i2c *ir, u32 *ir_key,
40 if (cmd == 0xff) 42 if (cmd == 0xff)
41 return 0; 43 return 0;
42 44
43 dev_dbg(&ir->input->dev, "scancode = %02x\n", cmd); 45 dev_dbg(&ir->rc->input_dev->dev, "scancode = %02x\n", cmd);
44 46
45 *ir_key = cmd; 47 *ir_key = cmd;
46 *ir_raw = cmd; 48 *ir_raw = cmd;
@@ -49,9 +51,7 @@ static int get_key_isdbt(struct IR_i2c *ir, u32 *ir_key,
49 51
50int cx231xx_ir_init(struct cx231xx *dev) 52int cx231xx_ir_init(struct cx231xx *dev)
51{ 53{
52 struct input_dev *input_dev;
53 struct i2c_board_info info; 54 struct i2c_board_info info;
54 int rc;
55 u8 ir_i2c_bus; 55 u8 ir_i2c_bus;
56 56
57 dev_dbg(&dev->udev->dev, "%s\n", __func__); 57 dev_dbg(&dev->udev->dev, "%s\n", __func__);
@@ -60,34 +60,18 @@ int cx231xx_ir_init(struct cx231xx *dev)
60 if (!cx231xx_boards[dev->model].rc_map) 60 if (!cx231xx_boards[dev->model].rc_map)
61 return -ENODEV; 61 return -ENODEV;
62 62
63 input_dev = input_allocate_device();
64 if (!input_dev)
65 return -ENOMEM;
66
67 request_module("ir-kbd-i2c"); 63 request_module("ir-kbd-i2c");
68 64
69 memset(&info, 0, sizeof(struct i2c_board_info)); 65 memset(&info, 0, sizeof(struct i2c_board_info));
70 memset(&dev->ir.init_data, 0, sizeof(dev->ir.init_data)); 66 memset(&dev->init_data, 0, sizeof(dev->init_data));
67 dev->init_data.rc_dev = rc_allocate_device();
68 if (!dev->init_data.rc_dev)
69 return -ENOMEM;
71 70
72 dev->ir.input_dev = input_dev; 71 dev->init_data.name = cx231xx_boards[dev->model].name;
73 dev->ir.init_data.name = cx231xx_boards[dev->model].name;
74 dev->ir.props.priv = dev;
75 dev->ir.props.allowed_protos = IR_TYPE_NEC;
76 snprintf(dev->ir.name, sizeof(dev->ir.name),
77 "cx231xx IR (%s)", cx231xx_boards[dev->model].name);
78 usb_make_path(dev->udev, dev->ir.phys, sizeof(dev->ir.phys));
79 strlcat(dev->ir.phys, "/input0", sizeof(dev->ir.phys));
80 72
81 strlcpy(info.type, "ir_video", I2C_NAME_SIZE); 73 strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
82 info.platform_data = &dev->ir.init_data; 74 info.platform_data = &dev->init_data;
83
84 input_dev->name = dev->ir.name;
85 input_dev->phys = dev->ir.phys;
86 input_dev->dev.parent = &dev->udev->dev;
87 input_dev->id.bustype = BUS_USB;
88 input_dev->id.version = 1;
89 input_dev->id.vendor = le16_to_cpu(dev->udev->descriptor.idVendor);
90 input_dev->id.product = le16_to_cpu(dev->udev->descriptor.idProduct);
91 75
92 /* 76 /*
93 * Board-dependent values 77 * Board-dependent values
@@ -95,28 +79,23 @@ int cx231xx_ir_init(struct cx231xx *dev)
95 * For now, there's just one type of hardware design using 79 * For now, there's just one type of hardware design using
96 * an i2c device. 80 * an i2c device.
97 */ 81 */
98 dev->ir.init_data.get_key = get_key_isdbt; 82 dev->init_data.get_key = get_key_isdbt;
99 dev->ir.init_data.ir_codes = cx231xx_boards[dev->model].rc_map; 83 dev->init_data.ir_codes = cx231xx_boards[dev->model].rc_map;
100 /* The i2c micro-controller only outputs the cmd part of NEC protocol */ 84 /* The i2c micro-controller only outputs the cmd part of NEC protocol */
101 dev->ir.props.scanmask = 0xff; 85 dev->init_data.rc_dev->scanmask = 0xff;
86 dev->init_data.rc_dev->driver_name = "cx231xx";
87 dev->init_data.type = IR_TYPE_NEC;
102 info.addr = 0x30; 88 info.addr = 0x30;
103 89
104 rc = ir_input_register(input_dev, cx231xx_boards[dev->model].rc_map,
105 &dev->ir.props, MODULE_NAME);
106 if (rc < 0)
107 return rc;
108
109 /* Load and bind ir-kbd-i2c */ 90 /* Load and bind ir-kbd-i2c */
110 ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master; 91 ir_i2c_bus = cx231xx_boards[dev->model].ir_i2c_master;
92 dev_dbg(&dev->udev->dev, "Trying to bind ir at bus %d, addr 0x%02x\n",
93 ir_i2c_bus, info.addr);
111 i2c_new_device(&dev->i2c_bus[ir_i2c_bus].i2c_adap, &info); 94 i2c_new_device(&dev->i2c_bus[ir_i2c_bus].i2c_adap, &info);
112 95
113 return rc; 96 return 0;
114} 97}
115 98
116void cx231xx_ir_exit(struct cx231xx *dev) 99void cx231xx_ir_exit(struct cx231xx *dev)
117{ 100{
118 if (dev->ir.input_dev) {
119 ir_input_unregister(dev->ir.input_dev);
120 dev->ir.input_dev = NULL;
121 }
122} 101}