提交 fac6986c 编写于 作者: H Hans Verkuil 提交者: Mauro Carvalho Chehab

V4L/DVB (10247): saa7134: convert to the new v4l2 framework.

Register v4l2_device and switch to v4l2_subdev to access the i2c modules.
Signed-off-by: NHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 5b73e98c
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-chip-ident.h> #include <media/v4l2-chip-ident.h>
#include <media/v4l2-i2c-drv-legacy.h> #include <media/v4l2-i2c-drv.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/crc32.h> #include <linux/crc32.h>
...@@ -45,10 +45,6 @@ ...@@ -45,10 +45,6 @@
#define MPEG_TOTAL_TARGET_BITRATE_MAX 27000 #define MPEG_TOTAL_TARGET_BITRATE_MAX 27000
#define MPEG_PID_MAX ((1 << 14) - 1) #define MPEG_PID_MAX ((1 << 14) - 1)
/* Addresses to scan */
static unsigned short normal_i2c[] = {0x20, I2C_CLIENT_END};
I2C_CLIENT_INSMOD;
MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder"); MODULE_DESCRIPTION("device driver for saa6752hs MPEG2 encoder");
MODULE_AUTHOR("Andrew de Quincey"); MODULE_AUTHOR("Andrew de Quincey");
...@@ -914,11 +910,6 @@ static int saa6752hs_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_i ...@@ -914,11 +910,6 @@ static int saa6752hs_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_i
chip, h->chip, h->revision); chip, h->chip, h->revision);
} }
static int saa6752hs_command(struct i2c_client *client, unsigned cmd, void *arg)
{
return v4l2_subdev_command(i2c_get_clientdata(client), cmd, arg);
}
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
static const struct v4l2_subdev_core_ops saa6752hs_core_ops = { static const struct v4l2_subdev_core_ops saa6752hs_core_ops = {
...@@ -993,8 +984,6 @@ MODULE_DEVICE_TABLE(i2c, saa6752hs_id); ...@@ -993,8 +984,6 @@ MODULE_DEVICE_TABLE(i2c, saa6752hs_id);
static struct v4l2_i2c_driver_data v4l2_i2c_data = { static struct v4l2_i2c_driver_data v4l2_i2c_data = {
.name = "saa6752hs", .name = "saa6752hs",
.driverid = I2C_DRIVERID_SAA6752HS,
.command = saa6752hs_command,
.probe = saa6752hs_probe, .probe = saa6752hs_probe,
.remove = saa6752hs_remove, .remove = saa6752hs_remove,
.id_table = saa6752hs_id, .id_table = saa6752hs_id,
......
...@@ -4611,7 +4611,7 @@ struct saa7134_board saa7134_boards[] = { ...@@ -4611,7 +4611,7 @@ struct saa7134_board saa7134_boards[] = {
.tuner_type = TUNER_YMEC_TVF_5533MF, .tuner_type = TUNER_YMEC_TVF_5533MF,
.radio_type = TUNER_TEA5767, .radio_type = TUNER_TEA5767,
.tuner_addr = ADDR_UNSET, .tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET, .radio_addr = 0x60,
.gpiomask = 0x80000700, .gpiomask = 0x80000700,
.inputs = { { .inputs = { {
.name = name_tv, .name = name_tv,
...@@ -6109,7 +6109,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) ...@@ -6109,7 +6109,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev)
tun_setup.mode_mask = T_RADIO; tun_setup.mode_mask = T_RADIO;
saa7134_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); saa_call_all(dev, tuner, s_type_addr, &tun_setup);
mode_mask &= ~T_RADIO; mode_mask &= ~T_RADIO;
} }
...@@ -6121,7 +6121,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) ...@@ -6121,7 +6121,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev)
tun_setup.mode_mask = mode_mask; tun_setup.mode_mask = mode_mask;
saa7134_i2c_call_clients(dev, TUNER_SET_TYPE_ADDR, &tun_setup); saa_call_all(dev, tuner, s_type_addr, &tun_setup);
} }
if (dev->tda9887_conf) { if (dev->tda9887_conf) {
...@@ -6130,8 +6130,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) ...@@ -6130,8 +6130,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev)
tda9887_cfg.tuner = TUNER_TDA9887; tda9887_cfg.tuner = TUNER_TDA9887;
tda9887_cfg.priv = &dev->tda9887_conf; tda9887_cfg.priv = &dev->tda9887_conf;
saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, saa_call_all(dev, tuner, s_config, &tda9887_cfg);
&tda9887_cfg);
} }
if (dev->tuner_type == TUNER_XC2028) { if (dev->tuner_type == TUNER_XC2028) {
...@@ -6158,7 +6157,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev) ...@@ -6158,7 +6157,7 @@ static void saa7134_tuner_setup(struct saa7134_dev *dev)
xc2028_cfg.tuner = TUNER_XC2028; xc2028_cfg.tuner = TUNER_XC2028;
xc2028_cfg.priv = &ctl; xc2028_cfg.priv = &ctl;
saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &xc2028_cfg); saa_call_all(dev, tuner, s_config, &xc2028_cfg);
} }
} }
...@@ -6401,7 +6400,7 @@ int saa7134_board_init2(struct saa7134_dev *dev) ...@@ -6401,7 +6400,7 @@ int saa7134_board_init2(struct saa7134_dev *dev)
ctl.xtal_freq = TEA5767_HIGH_LO_13MHz; ctl.xtal_freq = TEA5767_HIGH_LO_13MHz;
tea5767_cfg.tuner = TUNER_TEA5767; tea5767_cfg.tuner = TUNER_TEA5767;
tea5767_cfg.priv = &ctl; tea5767_cfg.priv = &ctl;
saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tea5767_cfg); saa_call_all(dev, tuner, s_config, &tea5767_cfg);
break; break;
} }
} /* switch() */ } /* switch() */
......
...@@ -851,6 +851,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -851,6 +851,10 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
if (NULL == dev) if (NULL == dev)
return -ENOMEM; return -ENOMEM;
err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev);
if (err)
goto fail0;
/* pci init */ /* pci init */
dev->pci = pci_dev; dev->pci = pci_dev;
if (pci_enable_device(pci_dev)) { if (pci_enable_device(pci_dev)) {
...@@ -927,6 +931,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -927,6 +931,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
dev->autodetected = card[dev->nr] != dev->board; dev->autodetected = card[dev->nr] != dev->board;
dev->tuner_type = saa7134_boards[dev->board].tuner_type; dev->tuner_type = saa7134_boards[dev->board].tuner_type;
dev->tuner_addr = saa7134_boards[dev->board].tuner_addr; dev->tuner_addr = saa7134_boards[dev->board].tuner_addr;
dev->radio_type = saa7134_boards[dev->board].radio_type;
dev->radio_addr = saa7134_boards[dev->board].radio_addr;
dev->tda9887_conf = saa7134_boards[dev->board].tda9887_conf; dev->tda9887_conf = saa7134_boards[dev->board].tda9887_conf;
if (UNSET != tuner[dev->nr]) if (UNSET != tuner[dev->nr])
dev->tuner_type = tuner[dev->nr]; dev->tuner_type = tuner[dev->nr];
...@@ -973,15 +979,50 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -973,15 +979,50 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
saa7134_i2c_register(dev); saa7134_i2c_register(dev);
/* initialize hardware #2 */ /* initialize hardware #2 */
if (TUNER_ABSENT != dev->tuner_type) if (TUNER_ABSENT != dev->tuner_type) {
request_module("tuner"); if (dev->radio_type != UNSET) {
v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner",
dev->radio_addr);
}
if (dev->tda9887_conf & TDA9887_PRESENT) {
unsigned short addrs[] = { 0x42, 0x43, 0x4a, 0x4b,
I2C_CLIENT_END };
v4l2_i2c_new_probed_subdev(&dev->i2c_adap,
"tuner", "tuner", addrs);
}
if (dev->tuner_addr != ADDR_UNSET) {
v4l2_i2c_new_subdev(&dev->i2c_adap,
"tuner", "tuner", dev->tuner_addr);
} else {
unsigned short addrs[] = {
0x42, 0x43, 0x4a, 0x4b, /* tda8290 */
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
I2C_CLIENT_END
};
if (dev->tda9887_conf & TDA9887_PRESENT) {
v4l2_i2c_new_probed_subdev(&dev->i2c_adap,
"tuner", "tuner", addrs + 4);
} else {
v4l2_i2c_new_probed_subdev(&dev->i2c_adap,
"tuner", "tuner", addrs);
}
}
}
saa7134_board_init2(dev); saa7134_board_init2(dev);
saa7134_hwinit2(dev); saa7134_hwinit2(dev);
/* load i2c helpers */ /* load i2c helpers */
if (card_is_empress(dev)) { if (card_is_empress(dev)) {
request_module("saa6752hs"); struct v4l2_subdev *sd =
v4l2_i2c_new_subdev(&dev->i2c_adap, "saa6752hs",
"saa6752hs", 0x20);
if (sd)
sd->grp_id = GRP_EMPRESS;
} }
request_submodules(dev); request_submodules(dev);
...@@ -1023,7 +1064,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1023,7 +1064,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
} }
/* everything worked */ /* everything worked */
pci_set_drvdata(pci_dev,dev);
saa7134_devcount++; saa7134_devcount++;
mutex_lock(&devlist_lock); mutex_lock(&devlist_lock);
...@@ -1040,7 +1080,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1040,7 +1080,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
} }
if (TUNER_ABSENT != dev->tuner_type) if (TUNER_ABSENT != dev->tuner_type)
saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); saa_call_all(dev, core, s_standby, 0);
return 0; return 0;
...@@ -1055,13 +1095,16 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -1055,13 +1095,16 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
release_mem_region(pci_resource_start(pci_dev,0), release_mem_region(pci_resource_start(pci_dev,0),
pci_resource_len(pci_dev,0)); pci_resource_len(pci_dev,0));
fail1: fail1:
v4l2_device_unregister(&dev->v4l2_dev);
fail0:
kfree(dev); kfree(dev);
return err; return err;
} }
static void __devexit saa7134_finidev(struct pci_dev *pci_dev) static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
{ {
struct saa7134_dev *dev = pci_get_drvdata(pci_dev); struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
struct saa7134_mpeg_ops *mops; struct saa7134_mpeg_ops *mops;
/* Release DMA sound modules if present */ /* Release DMA sound modules if present */
...@@ -1113,7 +1156,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) ...@@ -1113,7 +1156,8 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
release_mem_region(pci_resource_start(pci_dev,0), release_mem_region(pci_resource_start(pci_dev,0),
pci_resource_len(pci_dev,0)); pci_resource_len(pci_dev,0));
pci_set_drvdata(pci_dev, NULL);
v4l2_device_unregister(&dev->v4l2_dev);
/* free memory */ /* free memory */
kfree(dev); kfree(dev);
...@@ -1148,8 +1192,8 @@ static int saa7134_buffer_requeue(struct saa7134_dev *dev, ...@@ -1148,8 +1192,8 @@ static int saa7134_buffer_requeue(struct saa7134_dev *dev,
static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
{ {
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
struct saa7134_dev *dev = pci_get_drvdata(pci_dev); struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
/* disable overlay - apps should enable it explicitly on resume*/ /* disable overlay - apps should enable it explicitly on resume*/
dev->ovenable = 0; dev->ovenable = 0;
...@@ -1185,7 +1229,8 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state) ...@@ -1185,7 +1229,8 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
static int saa7134_resume(struct pci_dev *pci_dev) static int saa7134_resume(struct pci_dev *pci_dev)
{ {
struct saa7134_dev *dev = pci_get_drvdata(pci_dev); struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
struct saa7134_dev *dev = container_of(v4l2_dev, struct saa7134_dev, v4l2_dev);
unsigned long flags; unsigned long flags;
pci_set_power_state(pci_dev, PCI_D0); pci_set_power_state(pci_dev, PCI_D0);
...@@ -1307,7 +1352,6 @@ module_exit(saa7134_fini); ...@@ -1307,7 +1352,6 @@ module_exit(saa7134_fini);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
EXPORT_SYMBOL(saa7134_set_gpio); EXPORT_SYMBOL(saa7134_set_gpio);
EXPORT_SYMBOL(saa7134_i2c_call_clients);
EXPORT_SYMBOL(saa7134_devlist); EXPORT_SYMBOL(saa7134_devlist);
EXPORT_SYMBOL(saa7134_boards); EXPORT_SYMBOL(saa7134_boards);
......
...@@ -189,7 +189,7 @@ static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe, ...@@ -189,7 +189,7 @@ static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
if (fe->ops.i2c_gate_ctrl) if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1); fe->ops.i2c_gate_ctrl(fe, 1);
i2c_transfer(&dev->i2c_adap, &msg, 1); i2c_transfer(&dev->i2c_adap, &msg, 1);
saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f); saa_call_all(dev, tuner, s_frequency, &f);
msg.buf = on; msg.buf = on;
if (fe->ops.i2c_gate_ctrl) if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1); fe->ops.i2c_gate_ctrl(fe, 1);
...@@ -1449,7 +1449,7 @@ static int dvb_fini(struct saa7134_dev *dev) ...@@ -1449,7 +1449,7 @@ static int dvb_fini(struct saa7134_dev *dev)
tda9887_cfg.priv = &on; tda9887_cfg.priv = &on;
/* otherwise we don't detect the tuner on next insmod */ /* otherwise we don't detect the tuner on next insmod */
saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg); saa_call_all(dev, tuner, s_config, &tda9887_cfg);
} else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) { } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
if ((dev->eedata[2] == 0x07) && use_frontend) { if ((dev->eedata[2] == 0x07) && use_frontend) {
/* turn off the 2nd lnb supply */ /* turn off the 2nd lnb supply */
......
...@@ -76,7 +76,7 @@ static int ts_init_encoder(struct saa7134_dev* dev) ...@@ -76,7 +76,7 @@ static int ts_init_encoder(struct saa7134_dev* dev)
break; break;
} }
ts_reset_encoder(dev); ts_reset_encoder(dev);
saa7134_i2c_call_clients(dev, VIDIOC_INT_INIT, &leading_null_bytes); saa_call_all(dev, core, init, leading_null_bytes);
dev->empress_started = 1; dev->empress_started = 1;
return 0; return 0;
} }
...@@ -234,7 +234,7 @@ static int empress_g_fmt_vid_cap(struct file *file, void *priv, ...@@ -234,7 +234,7 @@ static int empress_g_fmt_vid_cap(struct file *file, void *priv,
{ {
struct saa7134_dev *dev = file->private_data; struct saa7134_dev *dev = file->private_data;
saa7134_i2c_call_clients(dev, VIDIOC_G_FMT, f); saa_call_all(dev, video, g_fmt, f);
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
...@@ -247,7 +247,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -247,7 +247,7 @@ static int empress_s_fmt_vid_cap(struct file *file, void *priv,
{ {
struct saa7134_dev *dev = file->private_data; struct saa7134_dev *dev = file->private_data;
saa7134_i2c_call_clients(dev, VIDIOC_S_FMT, f); saa_call_all(dev, video, s_fmt, f);
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG; f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets; f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
...@@ -317,7 +317,7 @@ static int empress_s_ext_ctrls(struct file *file, void *priv, ...@@ -317,7 +317,7 @@ static int empress_s_ext_ctrls(struct file *file, void *priv,
if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
return -EINVAL; return -EINVAL;
err = saa7134_i2c_call_saa6752(dev, VIDIOC_S_EXT_CTRLS, ctrls); err = saa_call_empress(dev, core, s_ext_ctrls, ctrls);
ts_init_encoder(dev); ts_init_encoder(dev);
return err; return err;
...@@ -330,7 +330,7 @@ static int empress_g_ext_ctrls(struct file *file, void *priv, ...@@ -330,7 +330,7 @@ static int empress_g_ext_ctrls(struct file *file, void *priv,
if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG) if (ctrls->ctrl_class != V4L2_CTRL_CLASS_MPEG)
return -EINVAL; return -EINVAL;
return saa7134_i2c_call_saa6752(dev, VIDIOC_G_EXT_CTRLS, ctrls); return saa_call_empress(dev, core, g_ext_ctrls, ctrls);
} }
static int empress_g_ctrl(struct file *file, void *priv, static int empress_g_ctrl(struct file *file, void *priv,
...@@ -391,7 +391,7 @@ static int empress_queryctrl(struct file *file, void *priv, ...@@ -391,7 +391,7 @@ static int empress_queryctrl(struct file *file, void *priv,
return v4l2_ctrl_query_fill_std(c); return v4l2_ctrl_query_fill_std(c);
if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG) if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG)
return saa7134_queryctrl(file, priv, c); return saa7134_queryctrl(file, priv, c);
return saa7134_i2c_call_saa6752(dev, VIDIOC_QUERYCTRL, c); return saa_call_empress(dev, core, queryctrl, c);
} }
static int empress_querymenu(struct file *file, void *priv, static int empress_querymenu(struct file *file, void *priv,
...@@ -401,7 +401,7 @@ static int empress_querymenu(struct file *file, void *priv, ...@@ -401,7 +401,7 @@ static int empress_querymenu(struct file *file, void *priv,
if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG) if (V4L2_CTRL_ID2CLASS(c->id) != V4L2_CTRL_CLASS_MPEG)
return -EINVAL; return -EINVAL;
return saa7134_i2c_call_saa6752(dev, VIDIOC_QUERYMENU, c); return saa_call_empress(dev, core, querymenu, c);
} }
static int empress_g_chip_ident(struct file *file, void *fh, static int empress_g_chip_ident(struct file *file, void *fh,
...@@ -411,14 +411,12 @@ static int empress_g_chip_ident(struct file *file, void *fh, ...@@ -411,14 +411,12 @@ static int empress_g_chip_ident(struct file *file, void *fh,
chip->ident = V4L2_IDENT_NONE; chip->ident = V4L2_IDENT_NONE;
chip->revision = 0; chip->revision = 0;
if (dev->mpeg_i2c_client == NULL)
return -EINVAL;
if (chip->match.type == V4L2_CHIP_MATCH_I2C_DRIVER && if (chip->match.type == V4L2_CHIP_MATCH_I2C_DRIVER &&
!strcmp(chip->match.name, "saa6752hs")) !strcmp(chip->match.name, "saa6752hs"))
return saa7134_i2c_call_saa6752(dev, VIDIOC_DBG_G_CHIP_IDENT, chip); return saa_call_empress(dev, core, g_chip_ident, chip);
if (chip->match.type == V4L2_CHIP_MATCH_I2C_ADDR && if (chip->match.type == V4L2_CHIP_MATCH_I2C_ADDR &&
chip->match.addr == dev->mpeg_i2c_client->addr) chip->match.addr == 0x20)
return saa7134_i2c_call_saa6752(dev, VIDIOC_DBG_G_CHIP_IDENT, chip); return saa_call_empress(dev, core, g_chip_ident, chip);
return -EINVAL; return -EINVAL;
} }
......
...@@ -327,8 +327,6 @@ static int attach_inform(struct i2c_client *client) ...@@ -327,8 +327,6 @@ static int attach_inform(struct i2c_client *client)
d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", d1printk( "%s i2c attach [addr=0x%x,client=%s]\n",
client->driver->driver.name, client->addr, client->name); client->driver->driver.name, client->addr, client->name);
if (client->addr == 0x20 && client->driver && client->driver->command)
dev->mpeg_i2c_client = client;
/* Am I an i2c remote control? */ /* Am I an i2c remote control? */
...@@ -357,7 +355,6 @@ static struct i2c_algorithm saa7134_algo = { ...@@ -357,7 +355,6 @@ static struct i2c_algorithm saa7134_algo = {
static struct i2c_adapter saa7134_adap_template = { static struct i2c_adapter saa7134_adap_template = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.class = I2C_CLASS_TV_ANALOG,
.name = "saa7134", .name = "saa7134",
.id = I2C_HW_SAA7134, .id = I2C_HW_SAA7134,
.algo = &saa7134_algo, .algo = &saa7134_algo,
...@@ -421,29 +418,13 @@ static void do_i2c_scan(char *name, struct i2c_client *c) ...@@ -421,29 +418,13 @@ static void do_i2c_scan(char *name, struct i2c_client *c)
} }
} }
void saa7134_i2c_call_clients(struct saa7134_dev *dev,
unsigned int cmd, void *arg)
{
BUG_ON(NULL == dev->i2c_adap.algo_data);
i2c_clients_command(&dev->i2c_adap, cmd, arg);
}
int saa7134_i2c_call_saa6752(struct saa7134_dev *dev,
unsigned int cmd, void *arg)
{
if (dev->mpeg_i2c_client == NULL)
return -EINVAL;
return dev->mpeg_i2c_client->driver->command(dev->mpeg_i2c_client,
cmd, arg);
}
EXPORT_SYMBOL_GPL(saa7134_i2c_call_saa6752);
int saa7134_i2c_register(struct saa7134_dev *dev) int saa7134_i2c_register(struct saa7134_dev *dev)
{ {
dev->i2c_adap = saa7134_adap_template; dev->i2c_adap = saa7134_adap_template;
dev->i2c_adap.dev.parent = &dev->pci->dev; dev->i2c_adap.dev.parent = &dev->pci->dev;
strcpy(dev->i2c_adap.name,dev->name); strcpy(dev->i2c_adap.name,dev->name);
dev->i2c_adap.algo_data = dev; dev->i2c_adap.algo_data = dev;
i2c_set_adapdata(&dev->i2c_adap, &dev->v4l2_dev);
i2c_add_adapter(&dev->i2c_adap); i2c_add_adapter(&dev->i2c_adap);
dev->i2c_client = saa7134_client_template; dev->i2c_client = saa7134_client_template;
......
...@@ -627,10 +627,10 @@ void saa7134_set_tvnorm_hw(struct saa7134_dev *dev) ...@@ -627,10 +627,10 @@ void saa7134_set_tvnorm_hw(struct saa7134_dev *dev)
saa7134_set_decoder(dev); saa7134_set_decoder(dev);
if (card_in(dev, dev->ctl_input).tv) if (card_in(dev, dev->ctl_input).tv)
saa7134_i2c_call_clients(dev, VIDIOC_S_STD, &dev->tvnorm->id); saa_call_all(dev, tuner, s_std, dev->tvnorm->id);
/* Set the correct norm for the saa6752hs. This function /* Set the correct norm for the saa6752hs. This function
does nothing if there is no saa6752hs. */ does nothing if there is no saa6752hs. */
saa7134_i2c_call_saa6752(dev, VIDIOC_S_STD, &dev->tvnorm->id); saa_call_empress(dev, tuner, s_std, dev->tvnorm->id);
} }
static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale) static void set_h_prescale(struct saa7134_dev *dev, int task, int prescale)
...@@ -1266,8 +1266,7 @@ int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, str ...@@ -1266,8 +1266,7 @@ int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, str
else else
dev->tda9887_conf &= ~TDA9887_AUTOMUTE; dev->tda9887_conf &= ~TDA9887_AUTOMUTE;
saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, saa_call_all(dev, tuner, s_config, &tda9887_cfg);
&tda9887_cfg);
} }
break; break;
} }
...@@ -1387,7 +1386,7 @@ static int video_open(struct file *file) ...@@ -1387,7 +1386,7 @@ static int video_open(struct file *file)
if (fh->radio) { if (fh->radio) {
/* switch to radio mode */ /* switch to radio mode */
saa7134_tvaudio_setinput(dev,&card(dev).radio); saa7134_tvaudio_setinput(dev,&card(dev).radio);
saa7134_i2c_call_clients(dev,AUDC_SET_RADIO, NULL); saa_call_all(dev, tuner, s_radio);
} else { } else {
/* switch to video/vbi mode */ /* switch to video/vbi mode */
video_mux(dev,dev->ctl_input); video_mux(dev,dev->ctl_input);
...@@ -1498,7 +1497,7 @@ static int video_release(struct file *file) ...@@ -1498,7 +1497,7 @@ static int video_release(struct file *file)
saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0); saa_andorb(SAA7134_OFMT_DATA_A, 0x1f, 0);
saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0);
saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); saa_call_all(dev, core, s_standby, 0);
/* free stuff */ /* free stuff */
videobuf_mmap_free(&fh->cap); videobuf_mmap_free(&fh->cap);
...@@ -2041,7 +2040,7 @@ static int saa7134_s_frequency(struct file *file, void *priv, ...@@ -2041,7 +2040,7 @@ static int saa7134_s_frequency(struct file *file, void *priv,
mutex_lock(&dev->lock); mutex_lock(&dev->lock);
dev->ctl_freq = f->frequency; dev->ctl_freq = f->frequency;
saa7134_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); saa_call_all(dev, tuner, s_frequency, f);
saa7134_tvaudio_do_scan(dev); saa7134_tvaudio_do_scan(dev);
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
...@@ -2299,7 +2298,7 @@ static int radio_g_tuner(struct file *file, void *priv, ...@@ -2299,7 +2298,7 @@ static int radio_g_tuner(struct file *file, void *priv,
strcpy(t->name, "Radio"); strcpy(t->name, "Radio");
t->type = V4L2_TUNER_RADIO; t->type = V4L2_TUNER_RADIO;
saa7134_i2c_call_clients(dev, VIDIOC_G_TUNER, t); saa_call_all(dev, tuner, g_tuner, t);
if (dev->input->amux == TV) { if (dev->input->amux == TV) {
t->signal = 0xf800 - ((saa_readb(0x581) & 0x1f) << 11); t->signal = 0xf800 - ((saa_readb(0x581) & 0x1f) << 11);
t->rxsubchans = (saa_readb(0x529) & 0x08) ? t->rxsubchans = (saa_readb(0x529) & 0x08) ?
...@@ -2316,7 +2315,7 @@ static int radio_s_tuner(struct file *file, void *priv, ...@@ -2316,7 +2315,7 @@ static int radio_s_tuner(struct file *file, void *priv,
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
saa7134_i2c_call_clients(dev, VIDIOC_S_TUNER, t); saa_call_all(dev, tuner, s_tuner, t);
return 0; return 0;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h> #include <media/v4l2-ioctl.h>
#include <media/v4l2-device.h>
#include <media/tuner.h> #include <media/tuner.h>
#include <media/ir-common.h> #include <media/ir-common.h>
#include <media/ir-kbd-i2c.h> #include <media/ir-kbd-i2c.h>
...@@ -482,6 +483,7 @@ struct saa7134_dev { ...@@ -482,6 +483,7 @@ struct saa7134_dev {
struct mutex lock; struct mutex lock;
spinlock_t slock; spinlock_t slock;
struct v4l2_prio_state prio; struct v4l2_prio_state prio;
struct v4l2_device v4l2_dev;
/* workstruct for loading modules */ /* workstruct for loading modules */
struct work_struct request_module_wk; struct work_struct request_module_wk;
...@@ -572,7 +574,6 @@ struct saa7134_dev { ...@@ -572,7 +574,6 @@ struct saa7134_dev {
enum saa7134_ts_status ts_state; enum saa7134_ts_status ts_state;
unsigned int buff_cnt; unsigned int buff_cnt;
struct saa7134_mpeg_ops *mops; struct saa7134_mpeg_ops *mops;
struct i2c_client *mpeg_i2c_client;
/* SAA7134_MPEG_EMPRESS only */ /* SAA7134_MPEG_EMPRESS only */
struct video_device *empress_dev; struct video_device *empress_dev;
...@@ -616,6 +617,12 @@ struct saa7134_dev { ...@@ -616,6 +617,12 @@ struct saa7134_dev {
V4L2_STD_NTSC | V4L2_STD_PAL_M | \ V4L2_STD_NTSC | V4L2_STD_PAL_M | \
V4L2_STD_PAL_60) V4L2_STD_PAL_60)
#define GRP_EMPRESS (1)
#define saa_call_all(dev, o, f, args...) \
v4l2_device_call_all(&(dev)->v4l2_dev, 0, o, f , ##args)
#define saa_call_empress(dev, o, f, args...) \
v4l2_device_call_until_err(&(dev)->v4l2_dev, GRP_EMPRESS, o, f , ##args)
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
/* saa7134-core.c */ /* saa7134-core.c */
...@@ -668,10 +675,6 @@ int saa7134_tuner_callback(void *priv, int component, int command, int arg); ...@@ -668,10 +675,6 @@ int saa7134_tuner_callback(void *priv, int component, int command, int arg);
int saa7134_i2c_register(struct saa7134_dev *dev); int saa7134_i2c_register(struct saa7134_dev *dev);
int saa7134_i2c_unregister(struct saa7134_dev *dev); int saa7134_i2c_unregister(struct saa7134_dev *dev);
void saa7134_i2c_call_clients(struct saa7134_dev *dev,
unsigned int cmd, void *arg);
int saa7134_i2c_call_saa6752(struct saa7134_dev *dev,
unsigned int cmd, void *arg);
/* ----------------------------------------------------------- */ /* ----------------------------------------------------------- */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册