aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/ivtv
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
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')
-rw-r--r--drivers/media/video/ivtv/ivtv-cards.c3
-rw-r--r--drivers/media/video/ivtv/ivtv-cards.h36
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.h2
-rw-r--r--drivers/media/video/ivtv/ivtv-i2c.c45
4 files changed, 63 insertions, 23 deletions
diff --git a/drivers/media/video/ivtv/ivtv-cards.c b/drivers/media/video/ivtv/ivtv-cards.c
index e15c153b3012..e98ecadfde29 100644
--- a/drivers/media/video/ivtv/ivtv-cards.c
+++ b/drivers/media/video/ivtv/ivtv-cards.c
@@ -955,7 +955,8 @@ static const struct ivtv_card ivtv_card_avertv_mce116 = {
955 .hw_video = IVTV_HW_CX25840, 955 .hw_video = IVTV_HW_CX25840,
956 .hw_audio = IVTV_HW_CX25840, 956 .hw_audio = IVTV_HW_CX25840,
957 .hw_audio_ctrl = IVTV_HW_CX25840, 957 .hw_audio_ctrl = IVTV_HW_CX25840,
958 .hw_all = IVTV_HW_CX25840 | IVTV_HW_TUNER | IVTV_HW_WM8739, 958 .hw_all = IVTV_HW_CX25840 | IVTV_HW_TUNER | IVTV_HW_WM8739 |
959 IVTV_HW_I2C_IR_RX_AVER,
959 .video_inputs = { 960 .video_inputs = {
960 { IVTV_CARD_INPUT_VID_TUNER, 0, CX25840_COMPOSITE2 }, 961 { IVTV_CARD_INPUT_VID_TUNER, 0, CX25840_COMPOSITE2 },
961 { IVTV_CARD_INPUT_SVIDEO1, 1, CX25840_SVIDEO3 }, 962 { IVTV_CARD_INPUT_SVIDEO1, 1, CX25840_SVIDEO3 },
diff --git a/drivers/media/video/ivtv/ivtv-cards.h b/drivers/media/video/ivtv/ivtv-cards.h
index e99a0a255578..1ac09ebaa2f0 100644
--- a/drivers/media/video/ivtv/ivtv-cards.h
+++ b/drivers/media/video/ivtv/ivtv-cards.h
@@ -87,25 +87,27 @@
87#define IVTV_PCI_ID_GOTVIEW1 0xffac 87#define IVTV_PCI_ID_GOTVIEW1 0xffac
88#define IVTV_PCI_ID_GOTVIEW2 0xffad 88#define IVTV_PCI_ID_GOTVIEW2 0xffad
89 89
90/* hardware flags, no gaps allowed, IVTV_HW_GPIO must always be last */ 90/* hardware flags, no gaps allowed */
91#define IVTV_HW_CX25840 (1 << 0) 91#define IVTV_HW_CX25840 (1 << 0)
92#define IVTV_HW_SAA7115 (1 << 1) 92#define IVTV_HW_SAA7115 (1 << 1)
93#define IVTV_HW_SAA7127 (1 << 2) 93#define IVTV_HW_SAA7127 (1 << 2)
94#define IVTV_HW_MSP34XX (1 << 3) 94#define IVTV_HW_MSP34XX (1 << 3)
95#define IVTV_HW_TUNER (1 << 4) 95#define IVTV_HW_TUNER (1 << 4)
96#define IVTV_HW_WM8775 (1 << 5) 96#define IVTV_HW_WM8775 (1 << 5)
97#define IVTV_HW_CS53L32A (1 << 6) 97#define IVTV_HW_CS53L32A (1 << 6)
98#define IVTV_HW_TVEEPROM (1 << 7) 98#define IVTV_HW_TVEEPROM (1 << 7)
99#define IVTV_HW_SAA7114 (1 << 8) 99#define IVTV_HW_SAA7114 (1 << 8)
100#define IVTV_HW_UPD64031A (1 << 9) 100#define IVTV_HW_UPD64031A (1 << 9)
101#define IVTV_HW_UPD6408X (1 << 10) 101#define IVTV_HW_UPD6408X (1 << 10)
102#define IVTV_HW_SAA717X (1 << 11) 102#define IVTV_HW_SAA717X (1 << 11)
103#define IVTV_HW_WM8739 (1 << 12) 103#define IVTV_HW_WM8739 (1 << 12)
104#define IVTV_HW_VP27SMPX (1 << 13) 104#define IVTV_HW_VP27SMPX (1 << 13)
105#define IVTV_HW_M52790 (1 << 14) 105#define IVTV_HW_M52790 (1 << 14)
106#define IVTV_HW_GPIO (1 << 15) 106#define IVTV_HW_GPIO (1 << 15)
107#define IVTV_HW_I2C_IR_RX_AVER (1 << 16)
107 108
108#define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114) 109#define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114)
110#define IVTV_HW_IR_ANY (IVTV_HW_I2C_IR_RX_AVER)
109 111
110/* video inputs */ 112/* video inputs */
111#define IVTV_CARD_INPUT_VID_TUNER 1 113#define IVTV_CARD_INPUT_VID_TUNER 1
diff --git a/drivers/media/video/ivtv/ivtv-driver.h b/drivers/media/video/ivtv/ivtv-driver.h
index 2b3db90afb74..e4816da6482b 100644
--- a/drivers/media/video/ivtv/ivtv-driver.h
+++ b/drivers/media/video/ivtv/ivtv-driver.h
@@ -64,6 +64,7 @@
64#include <media/v4l2-device.h> 64#include <media/v4l2-device.h>
65#include <media/tuner.h> 65#include <media/tuner.h>
66#include <media/cx2341x.h> 66#include <media/cx2341x.h>
67#include <media/ir-kbd-i2c.h>
67 68
68#include <linux/ivtv.h> 69#include <linux/ivtv.h>
69 70
@@ -681,6 +682,7 @@ struct ivtv {
681 int i2c_state; /* i2c bit state */ 682 int i2c_state; /* i2c bit state */
682 struct mutex i2c_bus_lock; /* lock i2c bus */ 683 struct mutex i2c_bus_lock; /* lock i2c bus */
683 684
685 struct IR_i2c_init_data ir_i2c_init_data;
684 686
685 /* Program Index information */ 687 /* Program Index information */
686 u32 pgm_info_offset; /* start of pgm info in encoder memory */ 688 u32 pgm_info_offset; /* start of pgm info in encoder memory */
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 }