aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ivtv/ivtv-i2c.c
diff options
context:
space:
mode:
authorAndy Walls <awalls@radix.net>2009-11-21 10:52:34 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:41:56 -0500
commitad2fe2d48812029b0b674594f297d0723f7c6e8f (patch)
tree4313d3213c527573943bde2231aedff486529154 /drivers/media/video/ivtv/ivtv-i2c.c
parentbfbde8ee56d4a19e2d36a5a24b6dbfd298298bf1 (diff)
V4L/DVB (13444): ivtv: Add explicit IR controller initialization for the AVerTV M116
Add explicit support for the AVerTV M116 for use with the ir-kbd-i2c module. This also eases future support for other AVerMedia ivtv boards with the same microcontroller program at I2C address 0x40. This is a reworked version of an earlier patch that was... Reviewed-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Andy Walls <awalls@radix.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/ivtv/ivtv-i2c.c')
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/drivers/media/video/ivtv/ivtv-i2c.c b/drivers/media/video/ivtv/ivtv-i2c.c
index 71a8aa60b3fe..6838683cdaae 100644
--- a/drivers/media/video/ivtv/ivtv-i2c.c
+++ b/drivers/media/video/ivtv/ivtv-i2c.c
@@ -88,6 +88,7 @@
88#define IVTV_UPD64083_I2C_ADDR 0x5c 88#define IVTV_UPD64083_I2C_ADDR 0x5c
89#define IVTV_VP27SMPX_I2C_ADDR 0x5b 89#define IVTV_VP27SMPX_I2C_ADDR 0x5b
90#define IVTV_M52790_I2C_ADDR 0x48 90#define IVTV_M52790_I2C_ADDR 0x48
91#define IVTV_AVERMEDIA_IR_RX_I2C_ADDR 0x40
91 92
92/* This array should match the IVTV_HW_ defines */ 93/* This array should match the IVTV_HW_ defines */
93static const u8 hw_addrs[] = { 94static const u8 hw_addrs[] = {
@@ -106,7 +107,8 @@ static const u8 hw_addrs[] = {
106 IVTV_WM8739_I2C_ADDR, 107 IVTV_WM8739_I2C_ADDR,
107 IVTV_VP27SMPX_I2C_ADDR, 108 IVTV_VP27SMPX_I2C_ADDR,
108 IVTV_M52790_I2C_ADDR, 109 IVTV_M52790_I2C_ADDR,
109 0 /* IVTV_HW_GPIO dummy driver ID */ 110 0, /* IVTV_HW_GPIO dummy driver ID */
111 IVTV_AVERMEDIA_IR_RX_I2C_ADDR /* IVTV_HW_I2C_IR_RX_AVER */
110}; 112};
111 113
112/* This array should match the IVTV_HW_ defines */ 114/* This array should match the IVTV_HW_ defines */
@@ -126,7 +128,8 @@ static const char *hw_modules[] = {
126 "wm8739", 128 "wm8739",
127 "vp27smpx", 129 "vp27smpx",
128 "m52790", 130 "m52790",
129 NULL 131 NULL,
132 NULL /* IVTV_HW_I2C_IR_RX_AVER */
130}; 133};
131 134
132/* This array should match the IVTV_HW_ defines */ 135/* This array should match the IVTV_HW_ defines */
@@ -147,8 +150,34 @@ static const char * const hw_devicenames[] = {
147 "vp27smpx", 150 "vp27smpx",
148 "m52790", 151 "m52790",
149 "gpio", 152 "gpio",
153 "ir_video", /* IVTV_HW_I2C_IR_RX_AVER */
150}; 154};
151 155
156static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
157{
158 struct i2c_board_info info;
159 struct i2c_adapter *adap = &itv->i2c_adap;
160 struct IR_i2c_init_data *init_data = &itv->ir_i2c_init_data;
161 unsigned short addr_list[2] = { addr, I2C_CLIENT_END };
162
163 /* Our default information for ir-kbd-i2c.c to use */
164 switch (hw) {
165 case IVTV_HW_I2C_IR_RX_AVER:
166 init_data->ir_codes = &ir_codes_avermedia_cardbus_table;
167 init_data->internal_get_key_func =
168 IR_KBD_GET_KEY_AVERMEDIA_CARDBUS;
169 init_data->type = IR_TYPE_OTHER;
170 init_data->name = "AVerMedia AVerTV card";
171 break;
172 }
173
174 memset(&info, 0, sizeof(struct i2c_board_info));
175 info.platform_data = init_data;
176 strlcpy(info.type, type, I2C_NAME_SIZE);
177
178 return i2c_new_probed_device(adap, &info, addr_list) == NULL ? -1 : 0;
179}
180
152/* Instantiate the IR receiver device using probing -- undesirable */ 181/* Instantiate the IR receiver device using probing -- undesirable */
153struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv) 182struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
154{ 183{
@@ -208,8 +237,15 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
208 sd->grp_id = 1 << idx; 237 sd->grp_id = 1 << idx;
209 return sd ? 0 : -1; 238 return sd ? 0 : -1;
210 } 239 }
240
241 if (hw & IVTV_HW_IR_ANY)
242 return ivtv_i2c_new_ir(itv, hw, type, hw_addrs[idx]);
243
244 /* Is it not an I2C device or one we do not wish to register? */
211 if (!hw_addrs[idx]) 245 if (!hw_addrs[idx])
212 return -1; 246 return -1;
247
248 /* It's an I2C device other than an analog tuner or IR chip */
213 if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) { 249 if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) {
214 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev, 250 sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
215 adap, mod, type, 0, I2C_ADDRS(hw_addrs[idx])); 251 adap, mod, type, 0, I2C_ADDRS(hw_addrs[idx]));
@@ -617,11 +653,10 @@ int init_ivtv_i2c(struct ivtv *itv)
617 IVTV_DEBUG_I2C("i2c init\n"); 653 IVTV_DEBUG_I2C("i2c init\n");
618 654
619 /* Sanity checks for the I2C hardware arrays. They must be the 655 /* Sanity checks for the I2C hardware arrays. They must be the
620 * same size and GPIO must be the last entry. 656 * same size.
621 */ 657 */
622 if (ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_addrs) || 658 if (ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_addrs) ||
623 ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_modules) || 659 ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_modules)) {
624 IVTV_HW_GPIO != (1 << (ARRAY_SIZE(hw_addrs) - 1))) {
625 IVTV_ERR("Mismatched I2C hardware arrays\n"); 660 IVTV_ERR("Mismatched I2C hardware arrays\n");
626 return -ENODEV; 661 return -ENODEV;
627 } 662 }