aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-03-29 05:53:29 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:48 -0400
commit0d5a19f15837de69f864b2a43a93f119224d778c (patch)
tree952be3a127bdf863a7163f552e243020a44f64b1 /drivers/media/video
parentd35ed62704bc1d44dd4746a242e8c09f2a48fc40 (diff)
V4L/DVB (11297): cx23885: convert to v4l2_subdev.
Convert this driver to v4l2_subdev. Note that currently the only card with analog support in this driver is the HVR-1800. The analog tuner support in this driver is limited to what is needed for this board. When analog support is added for other cards, then the tuner load code will probably have to be expanded to take care of those boards. For example, there is currently no support for either radio tuners or tda9887 demods. I'd like to thank Steven Toth for testing this on his HVR-1800. Tested-by: Steven Toth <stoth@linuxtv.org> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c20
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c4
-rw-r--r--drivers/media/video/cx23885/cx23885-core.c2
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c2
-rw-r--r--drivers/media/video/cx23885/cx23885-i2c.c67
-rw-r--r--drivers/media/video/cx23885/cx23885-video.c41
-rw-r--r--drivers/media/video/cx23885/cx23885.h6
7 files changed, 47 insertions, 95 deletions
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index 9e57c33b5496..6f5df90af93e 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -1251,8 +1251,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
1251 if (0 != t->index) 1251 if (0 != t->index)
1252 return -EINVAL; 1252 return -EINVAL;
1253 strcpy(t->name, "Television"); 1253 strcpy(t->name, "Television");
1254 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_TUNER, t); 1254 call_all(dev, tuner, g_tuner, t);
1255 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t);
1256 1255
1257 dprintk(1, "VIDIOC_G_TUNER: tuner type %d\n", t->type); 1256 dprintk(1, "VIDIOC_G_TUNER: tuner type %d\n", t->type);
1258 1257
@@ -1269,7 +1268,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
1269 return -EINVAL; 1268 return -EINVAL;
1270 1269
1271 /* Update the A/V core */ 1270 /* Update the A/V core */
1272 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_TUNER, t); 1271 call_all(dev, tuner, s_tuner, t);
1273 1272
1274 return 0; 1273 return 0;
1275} 1274}
@@ -1285,8 +1284,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
1285 f->type = V4L2_TUNER_ANALOG_TV; 1284 f->type = V4L2_TUNER_ANALOG_TV;
1286 f->frequency = dev->freq; 1285 f->frequency = dev->freq;
1287 1286
1288 /* Assumption that tuner is always on bus 1 */ 1287 call_all(dev, tuner, g_frequency, f);
1289 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_FREQUENCY, f);
1290 1288
1291 return 0; 1289 return 0;
1292} 1290}
@@ -1313,8 +1311,7 @@ static int vidioc_s_frequency(struct file *file, void *priv,
1313 return -EINVAL; 1311 return -EINVAL;
1314 dev->freq = f->frequency; 1312 dev->freq = f->frequency;
1315 1313
1316 /* Assumption that tuner is always on bus 1 */ 1314 call_all(dev, tuner, s_frequency, f);
1317 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, f);
1318 1315
1319 cx23885_initialize_codec(dev); 1316 cx23885_initialize_codec(dev);
1320 1317
@@ -1328,7 +1325,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
1328 struct cx23885_dev *dev = fh->dev; 1325 struct cx23885_dev *dev = fh->dev;
1329 1326
1330 /* Update the A/V core */ 1327 /* Update the A/V core */
1331 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_CTRL, ctl); 1328 call_all(dev, core, s_ctrl, ctl);
1332 return 0; 1329 return 0;
1333} 1330}
1334 1331
@@ -1524,12 +1521,7 @@ static int vidioc_log_status(struct file *file, void *priv)
1524 printk(KERN_INFO 1521 printk(KERN_INFO
1525 "%s/2: ============ START LOG STATUS ============\n", 1522 "%s/2: ============ START LOG STATUS ============\n",
1526 dev->name); 1523 dev->name);
1527 cx23885_call_i2c_clients(&dev->i2c_bus[0], VIDIOC_LOG_STATUS, 1524 call_all(dev, core, log_status);
1528 NULL);
1529 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_LOG_STATUS,
1530 NULL);
1531 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_LOG_STATUS,
1532 NULL);
1533 cx2341x_log_status(&dev->mpeg_params, name); 1525 cx2341x_log_status(&dev->mpeg_params, name);
1534 printk(KERN_INFO 1526 printk(KERN_INFO
1535 "%s/2: ============= END LOG STATUS =============\n", 1527 "%s/2: ============= END LOG STATUS =============\n",
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index 08cd793cd151..5e4b7e790d94 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -739,7 +739,9 @@ void cx23885_card_setup(struct cx23885_dev *dev)
739 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: 739 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
740 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F: 740 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
741 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: 741 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
742 request_module("cx25840"); 742 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->i2c_bus[2].i2c_adap,
743 "cx25840", "cx25840", 0x88 >> 1);
744 v4l2_subdev_call(dev->sd_cx25840, core, init, 0);
743 break; 745 break;
744 } 746 }
745 747
diff --git a/drivers/media/video/cx23885/cx23885-core.c b/drivers/media/video/cx23885/cx23885-core.c
index 548279225d73..dc7fff22cfdd 100644
--- a/drivers/media/video/cx23885/cx23885-core.c
+++ b/drivers/media/video/cx23885/cx23885-core.c
@@ -875,7 +875,7 @@ static int cx23885_dev_setup(struct cx23885_dev *dev)
875 cx23885_i2c_register(&dev->i2c_bus[1]); 875 cx23885_i2c_register(&dev->i2c_bus[1]);
876 cx23885_i2c_register(&dev->i2c_bus[2]); 876 cx23885_i2c_register(&dev->i2c_bus[2]);
877 cx23885_card_setup(dev); 877 cx23885_card_setup(dev);
878 cx23885_call_i2c_clients(&dev->i2c_bus[0], TUNER_SET_STANDBY, NULL); 878 call_all(dev, core, s_standby, 0);
879 cx23885_ir_init(dev); 879 cx23885_ir_init(dev);
880 880
881 if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) { 881 if (cx23885_boards[dev->board].porta == CX23885_ANALOG_VIDEO) {
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index 8d731fffad58..d43c74396767 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -673,7 +673,7 @@ static int dvb_register(struct cx23885_tsport *port)
673 fe0->dvb.frontend->callback = cx23885_tuner_callback; 673 fe0->dvb.frontend->callback = cx23885_tuner_callback;
674 674
675 /* Put the analog decoder in standby to keep it quiet */ 675 /* Put the analog decoder in standby to keep it quiet */
676 cx23885_call_i2c_clients(i2c_bus, TUNER_SET_STANDBY, NULL); 676 call_all(dev, core, s_standby, 0);
677 677
678 if (fe0->dvb.frontend->ops.analog_ops.standby) 678 if (fe0->dvb.frontend->ops.analog_ops.standby)
679 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend); 679 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
diff --git a/drivers/media/video/cx23885/cx23885-i2c.c b/drivers/media/video/cx23885/cx23885-i2c.c
index 969b7ebbc827..3421bd12056a 100644
--- a/drivers/media/video/cx23885/cx23885-i2c.c
+++ b/drivers/media/video/cx23885/cx23885-i2c.c
@@ -268,65 +268,6 @@ static int i2c_xfer(struct i2c_adapter *i2c_adap,
268 return retval; 268 return retval;
269} 269}
270 270
271static int attach_inform(struct i2c_client *client)
272{
273 struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
274 struct cx23885_dev *dev = to_cx23885(v4l2_dev);
275 struct tuner_setup tun_setup;
276
277 dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
278 client->driver->driver.name, client->addr, client->name);
279
280 if (!client->driver->command)
281 return 0;
282
283 if (dev->tuner_type != UNSET) {
284
285 dprintk(1, "%s (tuner) i2c attach [addr=0x%x,client=%s]\n",
286 client->driver->driver.name, client->addr,
287 client->name);
288
289 if ((dev->tuner_addr == ADDR_UNSET) ||
290 (dev->tuner_addr == client->addr)) {
291
292 dprintk(1, "%s (tuner || addr UNSET)\n",
293 client->driver->driver.name);
294
295 dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
296 client->driver->driver.name,
297 client->addr, client->name);
298
299 tun_setup.mode_mask = T_ANALOG_TV;
300 tun_setup.type = dev->tuner_type;
301 tun_setup.addr = dev->tuner_addr;
302
303 client->driver->command(client, TUNER_SET_TYPE_ADDR,
304 &tun_setup);
305 }
306 }
307
308 return 0;
309}
310
311static int detach_inform(struct i2c_client *client)
312{
313 struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
314 struct cx23885_dev *dev = to_cx23885(v4l2_dev);
315
316 dprintk(1, "i2c detach [client=%s]\n", client->name);
317
318 return 0;
319}
320
321void cx23885_call_i2c_clients(struct cx23885_i2c *bus,
322 unsigned int cmd, void *arg)
323{
324 if (bus->i2c_rc != 0)
325 return;
326
327 i2c_clients_command(&bus->i2c_adap, cmd, arg);
328}
329
330static u32 cx23885_functionality(struct i2c_adapter *adap) 271static u32 cx23885_functionality(struct i2c_adapter *adap)
331{ 272{
332 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C; 273 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_I2C;
@@ -344,9 +285,6 @@ static struct i2c_adapter cx23885_i2c_adap_template = {
344 .owner = THIS_MODULE, 285 .owner = THIS_MODULE,
345 .id = I2C_HW_B_CX23885, 286 .id = I2C_HW_B_CX23885,
346 .algo = &cx23885_i2c_algo_template, 287 .algo = &cx23885_i2c_algo_template,
347 .class = I2C_CLASS_TV_ANALOG,
348 .client_register = attach_inform,
349 .client_unregister = detach_inform,
350}; 288};
351 289
352static struct i2c_client cx23885_i2c_client_template = { 290static struct i2c_client cx23885_i2c_client_template = {
@@ -410,8 +348,11 @@ int cx23885_i2c_register(struct cx23885_i2c *bus)
410 348
411 if (0 == bus->i2c_rc) { 349 if (0 == bus->i2c_rc) {
412 dprintk(1, "%s: i2c bus %d registered\n", dev->name, bus->nr); 350 dprintk(1, "%s: i2c bus %d registered\n", dev->name, bus->nr);
413 if (i2c_scan) 351 if (i2c_scan) {
352 printk(KERN_INFO "%s: scan bus %d:\n",
353 dev->name, bus->nr);
414 do_i2c_scan(dev->name, &bus->i2c_client); 354 do_i2c_scan(dev->name, &bus->i2c_client);
355 }
415 } else 356 } else
416 printk(KERN_WARNING "%s: i2c bus %d register FAILED\n", 357 printk(KERN_WARNING "%s: i2c bus %d register FAILED\n",
417 dev->name, bus->nr); 358 dev->name, bus->nr);
diff --git a/drivers/media/video/cx23885/cx23885-video.c b/drivers/media/video/cx23885/cx23885-video.c
index 1596f4ff3dfe..f0ac62c5dc83 100644
--- a/drivers/media/video/cx23885/cx23885-video.c
+++ b/drivers/media/video/cx23885/cx23885-video.c
@@ -299,11 +299,7 @@ static int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm)
299 299
300 dev->tvnorm = norm; 300 dev->tvnorm = norm;
301 301
302 /* Tell the analog tuner/demods */ 302 call_all(dev, tuner, s_std, norm);
303 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_S_STD, &norm);
304
305 /* Tell the internal A/V decoder */
306 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_STD, &norm);
307 303
308 return 0; 304 return 0;
309} 305}
@@ -410,8 +406,7 @@ static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
410 route.input = INPUT(input)->vmux; 406 route.input = INPUT(input)->vmux;
411 407
412 /* Tell the internal A/V decoder */ 408 /* Tell the internal A/V decoder */
413 cx23885_call_i2c_clients(&dev->i2c_bus[2], 409 v4l2_subdev_call(dev->sd_cx25840, video, s_routing, &route);
414 VIDIOC_INT_S_VIDEO_ROUTING, &route);
415 410
416 return 0; 411 return 0;
417} 412}
@@ -887,7 +882,7 @@ static int cx23885_get_control(struct cx23885_dev *dev,
887 struct v4l2_control *ctl) 882 struct v4l2_control *ctl)
888{ 883{
889 dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __func__); 884 dprintk(1, "%s() calling cx25840(VIDIOC_G_CTRL)\n", __func__);
890 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_CTRL, ctl); 885 call_all(dev, core, g_ctrl, ctl);
891 return 0; 886 return 0;
892} 887}
893 888
@@ -1001,7 +996,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1001 fh->vidq.field = f->fmt.pix.field; 996 fh->vidq.field = f->fmt.pix.field;
1002 dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, 997 dprintk(2, "%s() width=%d height=%d field=%d\n", __func__,
1003 fh->width, fh->height, fh->vidq.field); 998 fh->width, fh->height, fh->vidq.field);
1004 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_FMT, f); 999 call_all(dev, video, s_fmt, f);
1005 return 0; 1000 return 0;
1006} 1001}
1007 1002
@@ -1281,7 +1276,7 @@ static int vidioc_g_frequency(struct file *file, void *priv,
1281 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1276 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
1282 f->frequency = dev->freq; 1277 f->frequency = dev->freq;
1283 1278
1284 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_FREQUENCY, f); 1279 call_all(dev, tuner, g_frequency, f);
1285 1280
1286 return 0; 1281 return 0;
1287} 1282}
@@ -1296,7 +1291,7 @@ static int cx23885_set_freq(struct cx23885_dev *dev, struct v4l2_frequency *f)
1296 mutex_lock(&dev->lock); 1291 mutex_lock(&dev->lock);
1297 dev->freq = f->frequency; 1292 dev->freq = f->frequency;
1298 1293
1299 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, f); 1294 call_all(dev, tuner, s_frequency, f);
1300 1295
1301 /* When changing channels it is required to reset TVAUDIO */ 1296 /* When changing channels it is required to reset TVAUDIO */
1302 msleep(10); 1297 msleep(10);
@@ -1330,7 +1325,7 @@ static int vidioc_g_register(struct file *file, void *fh,
1330 if (!v4l2_chip_match_host(&reg->match)) 1325 if (!v4l2_chip_match_host(&reg->match))
1331 return -EINVAL; 1326 return -EINVAL;
1332 1327
1333 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_G_REGISTER, reg); 1328 call_all(dev, core, g_register, reg);
1334 1329
1335 return 0; 1330 return 0;
1336} 1331}
@@ -1343,7 +1338,7 @@ static int vidioc_s_register(struct file *file, void *fh,
1343 if (!v4l2_chip_match_host(&reg->match)) 1338 if (!v4l2_chip_match_host(&reg->match))
1344 return -EINVAL; 1339 return -EINVAL;
1345 1340
1346 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_S_REGISTER, reg); 1341 call_all(dev, core, s_register, reg);
1347 1342
1348 return 0; 1343 return 0;
1349} 1344}
@@ -1524,6 +1519,26 @@ int cx23885_video_register(struct cx23885_dev *dev)
1524 /* Don't enable VBI yet */ 1519 /* Don't enable VBI yet */
1525 cx_set(PCI_INT_MSK, 1); 1520 cx_set(PCI_INT_MSK, 1);
1526 1521
1522 if (TUNER_ABSENT != dev->tuner_type) {
1523 struct v4l2_subdev *sd = NULL;
1524
1525 if (dev->tuner_addr)
1526 sd = v4l2_i2c_new_subdev(&dev->i2c_bus[1].i2c_adap,
1527 "tuner", "tuner", dev->tuner_addr);
1528 else
1529 sd = v4l2_i2c_new_probed_subdev(&dev->i2c_bus[1].i2c_adap,
1530 "tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_TV));
1531 if (sd) {
1532 struct tuner_setup tun_setup;
1533
1534 tun_setup.mode_mask = T_ANALOG_TV;
1535 tun_setup.type = dev->tuner_type;
1536 tun_setup.addr = v4l2_i2c_subdev_addr(sd);
1537
1538 v4l2_subdev_call(sd, tuner, s_type_addr, &tun_setup);
1539 }
1540 }
1541
1527 1542
1528 /* register v4l devices */ 1543 /* register v4l devices */
1529 dev->video_dev = cx23885_vdev_init(dev, dev->pci, 1544 dev->video_dev = cx23885_vdev_init(dev, dev->pci,
diff --git a/drivers/media/video/cx23885/cx23885.h b/drivers/media/video/cx23885/cx23885.h
index ba57643f1198..02d980a29962 100644
--- a/drivers/media/video/cx23885/cx23885.h
+++ b/drivers/media/video/cx23885/cx23885.h
@@ -323,6 +323,7 @@ struct cx23885_dev {
323 unsigned int radio_type; 323 unsigned int radio_type;
324 unsigned char radio_addr; 324 unsigned char radio_addr;
325 unsigned int has_radio; 325 unsigned int has_radio;
326 struct v4l2_subdev *sd_cx25840;
326 327
327 /* V4l */ 328 /* V4l */
328 u32 freq; 329 u32 freq;
@@ -348,6 +349,9 @@ static inline struct cx23885_dev *to_cx23885(struct v4l2_device *v4l2_dev)
348 return container_of(v4l2_dev, struct cx23885_dev, v4l2_dev); 349 return container_of(v4l2_dev, struct cx23885_dev, v4l2_dev);
349} 350}
350 351
352#define call_all(dev, o, f, args...) \
353 v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args)
354
351extern struct list_head cx23885_devlist; 355extern struct list_head cx23885_devlist;
352 356
353#define SRAM_CH01 0 /* Video A */ 357#define SRAM_CH01 0 /* Video A */
@@ -464,8 +468,6 @@ extern struct videobuf_queue_ops cx23885_vbi_qops;
464/* cx23885-i2c.c */ 468/* cx23885-i2c.c */
465extern int cx23885_i2c_register(struct cx23885_i2c *bus); 469extern int cx23885_i2c_register(struct cx23885_i2c *bus);
466extern int cx23885_i2c_unregister(struct cx23885_i2c *bus); 470extern int cx23885_i2c_unregister(struct cx23885_i2c *bus);
467extern void cx23885_call_i2c_clients(struct cx23885_i2c *bus, unsigned int cmd,
468 void *arg);
469extern void cx23885_av_clk(struct cx23885_dev *dev, int enable); 471extern void cx23885_av_clk(struct cx23885_dev *dev, int enable);
470 472
471/* ----------------------------------------------------------- */ 473/* ----------------------------------------------------------- */