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>
This commit is contained in:
parent
bfbde8ee56
commit
ad2fe2d488
4 changed files with 63 additions and 23 deletions
|
@ -955,7 +955,8 @@ static const struct ivtv_card ivtv_card_avertv_mce116 = {
|
||||||
.hw_video = IVTV_HW_CX25840,
|
.hw_video = IVTV_HW_CX25840,
|
||||||
.hw_audio = IVTV_HW_CX25840,
|
.hw_audio = IVTV_HW_CX25840,
|
||||||
.hw_audio_ctrl = IVTV_HW_CX25840,
|
.hw_audio_ctrl = IVTV_HW_CX25840,
|
||||||
.hw_all = IVTV_HW_CX25840 | IVTV_HW_TUNER | IVTV_HW_WM8739,
|
.hw_all = IVTV_HW_CX25840 | IVTV_HW_TUNER | IVTV_HW_WM8739 |
|
||||||
|
IVTV_HW_I2C_IR_RX_AVER,
|
||||||
.video_inputs = {
|
.video_inputs = {
|
||||||
{ IVTV_CARD_INPUT_VID_TUNER, 0, CX25840_COMPOSITE2 },
|
{ IVTV_CARD_INPUT_VID_TUNER, 0, CX25840_COMPOSITE2 },
|
||||||
{ IVTV_CARD_INPUT_SVIDEO1, 1, CX25840_SVIDEO3 },
|
{ IVTV_CARD_INPUT_SVIDEO1, 1, CX25840_SVIDEO3 },
|
||||||
|
|
|
@ -87,25 +87,27 @@
|
||||||
#define IVTV_PCI_ID_GOTVIEW1 0xffac
|
#define IVTV_PCI_ID_GOTVIEW1 0xffac
|
||||||
#define IVTV_PCI_ID_GOTVIEW2 0xffad
|
#define IVTV_PCI_ID_GOTVIEW2 0xffad
|
||||||
|
|
||||||
/* hardware flags, no gaps allowed, IVTV_HW_GPIO must always be last */
|
/* hardware flags, no gaps allowed */
|
||||||
#define IVTV_HW_CX25840 (1 << 0)
|
#define IVTV_HW_CX25840 (1 << 0)
|
||||||
#define IVTV_HW_SAA7115 (1 << 1)
|
#define IVTV_HW_SAA7115 (1 << 1)
|
||||||
#define IVTV_HW_SAA7127 (1 << 2)
|
#define IVTV_HW_SAA7127 (1 << 2)
|
||||||
#define IVTV_HW_MSP34XX (1 << 3)
|
#define IVTV_HW_MSP34XX (1 << 3)
|
||||||
#define IVTV_HW_TUNER (1 << 4)
|
#define IVTV_HW_TUNER (1 << 4)
|
||||||
#define IVTV_HW_WM8775 (1 << 5)
|
#define IVTV_HW_WM8775 (1 << 5)
|
||||||
#define IVTV_HW_CS53L32A (1 << 6)
|
#define IVTV_HW_CS53L32A (1 << 6)
|
||||||
#define IVTV_HW_TVEEPROM (1 << 7)
|
#define IVTV_HW_TVEEPROM (1 << 7)
|
||||||
#define IVTV_HW_SAA7114 (1 << 8)
|
#define IVTV_HW_SAA7114 (1 << 8)
|
||||||
#define IVTV_HW_UPD64031A (1 << 9)
|
#define IVTV_HW_UPD64031A (1 << 9)
|
||||||
#define IVTV_HW_UPD6408X (1 << 10)
|
#define IVTV_HW_UPD6408X (1 << 10)
|
||||||
#define IVTV_HW_SAA717X (1 << 11)
|
#define IVTV_HW_SAA717X (1 << 11)
|
||||||
#define IVTV_HW_WM8739 (1 << 12)
|
#define IVTV_HW_WM8739 (1 << 12)
|
||||||
#define IVTV_HW_VP27SMPX (1 << 13)
|
#define IVTV_HW_VP27SMPX (1 << 13)
|
||||||
#define IVTV_HW_M52790 (1 << 14)
|
#define IVTV_HW_M52790 (1 << 14)
|
||||||
#define IVTV_HW_GPIO (1 << 15)
|
#define IVTV_HW_GPIO (1 << 15)
|
||||||
|
#define IVTV_HW_I2C_IR_RX_AVER (1 << 16)
|
||||||
|
|
||||||
#define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114)
|
#define IVTV_HW_SAA711X (IVTV_HW_SAA7115 | IVTV_HW_SAA7114)
|
||||||
|
#define IVTV_HW_IR_ANY (IVTV_HW_I2C_IR_RX_AVER)
|
||||||
|
|
||||||
/* video inputs */
|
/* video inputs */
|
||||||
#define IVTV_CARD_INPUT_VID_TUNER 1
|
#define IVTV_CARD_INPUT_VID_TUNER 1
|
||||||
|
|
|
@ -64,6 +64,7 @@
|
||||||
#include <media/v4l2-device.h>
|
#include <media/v4l2-device.h>
|
||||||
#include <media/tuner.h>
|
#include <media/tuner.h>
|
||||||
#include <media/cx2341x.h>
|
#include <media/cx2341x.h>
|
||||||
|
#include <media/ir-kbd-i2c.h>
|
||||||
|
|
||||||
#include <linux/ivtv.h>
|
#include <linux/ivtv.h>
|
||||||
|
|
||||||
|
@ -681,6 +682,7 @@ struct ivtv {
|
||||||
int i2c_state; /* i2c bit state */
|
int i2c_state; /* i2c bit state */
|
||||||
struct mutex i2c_bus_lock; /* lock i2c bus */
|
struct mutex i2c_bus_lock; /* lock i2c bus */
|
||||||
|
|
||||||
|
struct IR_i2c_init_data ir_i2c_init_data;
|
||||||
|
|
||||||
/* Program Index information */
|
/* Program Index information */
|
||||||
u32 pgm_info_offset; /* start of pgm info in encoder memory */
|
u32 pgm_info_offset; /* start of pgm info in encoder memory */
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
#define IVTV_UPD64083_I2C_ADDR 0x5c
|
#define IVTV_UPD64083_I2C_ADDR 0x5c
|
||||||
#define IVTV_VP27SMPX_I2C_ADDR 0x5b
|
#define IVTV_VP27SMPX_I2C_ADDR 0x5b
|
||||||
#define IVTV_M52790_I2C_ADDR 0x48
|
#define IVTV_M52790_I2C_ADDR 0x48
|
||||||
|
#define IVTV_AVERMEDIA_IR_RX_I2C_ADDR 0x40
|
||||||
|
|
||||||
/* This array should match the IVTV_HW_ defines */
|
/* This array should match the IVTV_HW_ defines */
|
||||||
static const u8 hw_addrs[] = {
|
static const u8 hw_addrs[] = {
|
||||||
|
@ -106,7 +107,8 @@ static const u8 hw_addrs[] = {
|
||||||
IVTV_WM8739_I2C_ADDR,
|
IVTV_WM8739_I2C_ADDR,
|
||||||
IVTV_VP27SMPX_I2C_ADDR,
|
IVTV_VP27SMPX_I2C_ADDR,
|
||||||
IVTV_M52790_I2C_ADDR,
|
IVTV_M52790_I2C_ADDR,
|
||||||
0 /* IVTV_HW_GPIO dummy driver ID */
|
0, /* IVTV_HW_GPIO dummy driver ID */
|
||||||
|
IVTV_AVERMEDIA_IR_RX_I2C_ADDR /* IVTV_HW_I2C_IR_RX_AVER */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This array should match the IVTV_HW_ defines */
|
/* This array should match the IVTV_HW_ defines */
|
||||||
|
@ -126,7 +128,8 @@ static const char *hw_modules[] = {
|
||||||
"wm8739",
|
"wm8739",
|
||||||
"vp27smpx",
|
"vp27smpx",
|
||||||
"m52790",
|
"m52790",
|
||||||
NULL
|
NULL,
|
||||||
|
NULL /* IVTV_HW_I2C_IR_RX_AVER */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This array should match the IVTV_HW_ defines */
|
/* This array should match the IVTV_HW_ defines */
|
||||||
|
@ -147,8 +150,34 @@ static const char * const hw_devicenames[] = {
|
||||||
"vp27smpx",
|
"vp27smpx",
|
||||||
"m52790",
|
"m52790",
|
||||||
"gpio",
|
"gpio",
|
||||||
|
"ir_video", /* IVTV_HW_I2C_IR_RX_AVER */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)
|
||||||
|
{
|
||||||
|
struct i2c_board_info info;
|
||||||
|
struct i2c_adapter *adap = &itv->i2c_adap;
|
||||||
|
struct IR_i2c_init_data *init_data = &itv->ir_i2c_init_data;
|
||||||
|
unsigned short addr_list[2] = { addr, I2C_CLIENT_END };
|
||||||
|
|
||||||
|
/* Our default information for ir-kbd-i2c.c to use */
|
||||||
|
switch (hw) {
|
||||||
|
case IVTV_HW_I2C_IR_RX_AVER:
|
||||||
|
init_data->ir_codes = &ir_codes_avermedia_cardbus_table;
|
||||||
|
init_data->internal_get_key_func =
|
||||||
|
IR_KBD_GET_KEY_AVERMEDIA_CARDBUS;
|
||||||
|
init_data->type = IR_TYPE_OTHER;
|
||||||
|
init_data->name = "AVerMedia AVerTV card";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&info, 0, sizeof(struct i2c_board_info));
|
||||||
|
info.platform_data = init_data;
|
||||||
|
strlcpy(info.type, type, I2C_NAME_SIZE);
|
||||||
|
|
||||||
|
return i2c_new_probed_device(adap, &info, addr_list) == NULL ? -1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Instantiate the IR receiver device using probing -- undesirable */
|
/* Instantiate the IR receiver device using probing -- undesirable */
|
||||||
struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
|
struct i2c_client *ivtv_i2c_new_ir_legacy(struct ivtv *itv)
|
||||||
{
|
{
|
||||||
|
@ -208,8 +237,15 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
|
||||||
sd->grp_id = 1 << idx;
|
sd->grp_id = 1 << idx;
|
||||||
return sd ? 0 : -1;
|
return sd ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hw & IVTV_HW_IR_ANY)
|
||||||
|
return ivtv_i2c_new_ir(itv, hw, type, hw_addrs[idx]);
|
||||||
|
|
||||||
|
/* Is it not an I2C device or one we do not wish to register? */
|
||||||
if (!hw_addrs[idx])
|
if (!hw_addrs[idx])
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
/* It's an I2C device other than an analog tuner or IR chip */
|
||||||
if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) {
|
if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) {
|
||||||
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
|
sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
|
||||||
adap, mod, type, 0, I2C_ADDRS(hw_addrs[idx]));
|
adap, mod, type, 0, I2C_ADDRS(hw_addrs[idx]));
|
||||||
|
@ -617,11 +653,10 @@ int init_ivtv_i2c(struct ivtv *itv)
|
||||||
IVTV_DEBUG_I2C("i2c init\n");
|
IVTV_DEBUG_I2C("i2c init\n");
|
||||||
|
|
||||||
/* Sanity checks for the I2C hardware arrays. They must be the
|
/* Sanity checks for the I2C hardware arrays. They must be the
|
||||||
* same size and GPIO must be the last entry.
|
* same size.
|
||||||
*/
|
*/
|
||||||
if (ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_addrs) ||
|
if (ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_addrs) ||
|
||||||
ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_modules) ||
|
ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_modules)) {
|
||||||
IVTV_HW_GPIO != (1 << (ARRAY_SIZE(hw_addrs) - 1))) {
|
|
||||||
IVTV_ERR("Mismatched I2C hardware arrays\n");
|
IVTV_ERR("Mismatched I2C hardware arrays\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue