aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-03-14 11:36:54 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:43:23 -0400
commit74fc7bd9cec0ccdbea23659208492ec7ffc58297 (patch)
treecd16dbc46ec3771da456d71e2d0f27519ca9ae79
parentf1ba28c3a6e472742cbd73b05b807684e5d56b5a (diff)
V4L/DVB (11046): bttv: convert to v4l2_device.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c47
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c10
-rw-r--r--drivers/media/video/bt8xx/bttv.h3
-rw-r--r--drivers/media/video/bt8xx/bttvp.h5
5 files changed, 45 insertions, 22 deletions
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index 48762a2b9e4..b1857c19bbd 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -814,7 +814,7 @@ static int __devinit dvb_bt8xx_probe(struct bttv_sub_device *sub)
814 814
815 mutex_init(&card->lock); 815 mutex_init(&card->lock);
816 card->bttv_nr = sub->core->nr; 816 card->bttv_nr = sub->core->nr;
817 strncpy(card->card_name, sub->core->name, sizeof(sub->core->name)); 817 strlcpy(card->card_name, sub->core->v4l2_dev.name, sizeof(card->card_name));
818 card->i2c_adapter = &sub->core->i2c_adap; 818 card->i2c_adapter = &sub->core->i2c_adap;
819 819
820 switch(sub->core->type) { 820 switch(sub->core->type) {
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index b5fc3cc6188..3079d925e4c 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -167,7 +167,7 @@ static ssize_t show_card(struct device *cd,
167 struct device_attribute *attr, char *buf) 167 struct device_attribute *attr, char *buf)
168{ 168{
169 struct video_device *vfd = container_of(cd, struct video_device, dev); 169 struct video_device *vfd = container_of(cd, struct video_device, dev);
170 struct bttv *btv = dev_get_drvdata(vfd->parent); 170 struct bttv *btv = video_get_drvdata(vfd);
171 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET); 171 return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
172} 172}
173static DEVICE_ATTR(card, S_IRUGO, show_card, NULL); 173static DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
@@ -3692,14 +3692,14 @@ static void bttv_risc_disasm(struct bttv *btv,
3692 unsigned int i,j,n; 3692 unsigned int i,j,n;
3693 3693
3694 printk("%s: risc disasm: %p [dma=0x%08lx]\n", 3694 printk("%s: risc disasm: %p [dma=0x%08lx]\n",
3695 btv->c.name, risc->cpu, (unsigned long)risc->dma); 3695 btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma);
3696 for (i = 0; i < (risc->size >> 2); i += n) { 3696 for (i = 0; i < (risc->size >> 2); i += n) {
3697 printk("%s: 0x%lx: ", btv->c.name, 3697 printk("%s: 0x%lx: ", btv->c.v4l2_dev.name,
3698 (unsigned long)(risc->dma + (i<<2))); 3698 (unsigned long)(risc->dma + (i<<2)));
3699 n = bttv_risc_decode(le32_to_cpu(risc->cpu[i])); 3699 n = bttv_risc_decode(le32_to_cpu(risc->cpu[i]));
3700 for (j = 1; j < n; j++) 3700 for (j = 1; j < n; j++)
3701 printk("%s: 0x%lx: 0x%08x [ arg #%d ]\n", 3701 printk("%s: 0x%lx: 0x%08x [ arg #%d ]\n",
3702 btv->c.name, (unsigned long)(risc->dma + ((i+j)<<2)), 3702 btv->c.v4l2_dev.name, (unsigned long)(risc->dma + ((i+j)<<2)),
3703 risc->cpu[i+j], j); 3703 risc->cpu[i+j], j);
3704 if (0 == risc->cpu[i]) 3704 if (0 == risc->cpu[i])
3705 break; 3705 break;
@@ -4175,7 +4175,7 @@ static struct video_device *vdev_init(struct bttv *btv,
4175 return NULL; 4175 return NULL;
4176 *vfd = *template; 4176 *vfd = *template;
4177 vfd->minor = -1; 4177 vfd->minor = -1;
4178 vfd->parent = &btv->c.pci->dev; 4178 vfd->v4l2_dev = &btv->c.v4l2_dev;
4179 vfd->release = video_device_release; 4179 vfd->release = video_device_release;
4180 vfd->debug = bttv_debug; 4180 vfd->debug = bttv_debug;
4181 video_set_drvdata(vfd, btv); 4181 video_set_drvdata(vfd, btv);
@@ -4289,8 +4289,13 @@ static int __devinit bttv_probe(struct pci_dev *dev,
4289 return -ENOMEM; 4289 return -ENOMEM;
4290 printk(KERN_INFO "bttv: Bt8xx card found (%d).\n", bttv_num); 4290 printk(KERN_INFO "bttv: Bt8xx card found (%d).\n", bttv_num);
4291 bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL); 4291 bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL);
4292 if (btv == NULL) {
4293 printk(KERN_ERR "bttv: out of memory.\n");
4294 return -ENOMEM;
4295 }
4292 btv->c.nr = bttv_num; 4296 btv->c.nr = bttv_num;
4293 sprintf(btv->c.name,"bttv%d",btv->c.nr); 4297 snprintf(btv->c.v4l2_dev.name, sizeof(btv->c.v4l2_dev.name),
4298 "bttv%d", btv->c.nr);
4294 4299
4295 /* initialize structs / fill in defaults */ 4300 /* initialize structs / fill in defaults */
4296 mutex_init(&btv->lock); 4301 mutex_init(&btv->lock);
@@ -4327,7 +4332,7 @@ static int __devinit bttv_probe(struct pci_dev *dev,
4327 } 4332 }
4328 if (!request_mem_region(pci_resource_start(dev,0), 4333 if (!request_mem_region(pci_resource_start(dev,0),
4329 pci_resource_len(dev,0), 4334 pci_resource_len(dev,0),
4330 btv->c.name)) { 4335 btv->c.v4l2_dev.name)) {
4331 printk(KERN_WARNING "bttv%d: can't request iomem (0x%llx).\n", 4336 printk(KERN_WARNING "bttv%d: can't request iomem (0x%llx).\n",
4332 btv->c.nr, 4337 btv->c.nr,
4333 (unsigned long long)pci_resource_start(dev,0)); 4338 (unsigned long long)pci_resource_start(dev,0));
@@ -4335,7 +4340,12 @@ static int __devinit bttv_probe(struct pci_dev *dev,
4335 } 4340 }
4336 pci_set_master(dev); 4341 pci_set_master(dev);
4337 pci_set_command(dev); 4342 pci_set_command(dev);
4338 pci_set_drvdata(dev,btv); 4343
4344 result = v4l2_device_register(&dev->dev, &btv->c.v4l2_dev);
4345 if (result < 0) {
4346 printk(KERN_WARNING "bttv%d: v4l2_device_register() failed\n", btv->c.nr);
4347 goto fail0;
4348 }
4339 4349
4340 pci_read_config_byte(dev, PCI_CLASS_REVISION, &btv->revision); 4350 pci_read_config_byte(dev, PCI_CLASS_REVISION, &btv->revision);
4341 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); 4351 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
@@ -4359,7 +4369,7 @@ static int __devinit bttv_probe(struct pci_dev *dev,
4359 /* disable irqs, register irq handler */ 4369 /* disable irqs, register irq handler */
4360 btwrite(0, BT848_INT_MASK); 4370 btwrite(0, BT848_INT_MASK);
4361 result = request_irq(btv->c.pci->irq, bttv_irq, 4371 result = request_irq(btv->c.pci->irq, bttv_irq,
4362 IRQF_SHARED | IRQF_DISABLED,btv->c.name,(void *)btv); 4372 IRQF_SHARED | IRQF_DISABLED, btv->c.v4l2_dev.name, (void *)btv);
4363 if (result < 0) { 4373 if (result < 0) {
4364 printk(KERN_ERR "bttv%d: can't get IRQ %d\n", 4374 printk(KERN_ERR "bttv%d: can't get IRQ %d\n",
4365 bttv_num,btv->c.pci->irq); 4375 bttv_num,btv->c.pci->irq);
@@ -4443,21 +4453,24 @@ static int __devinit bttv_probe(struct pci_dev *dev,
4443 bttv_num++; 4453 bttv_num++;
4444 return 0; 4454 return 0;
4445 4455
4446 fail2: 4456fail2:
4447 free_irq(btv->c.pci->irq,btv); 4457 free_irq(btv->c.pci->irq,btv);
4448 4458
4449 fail1: 4459fail1:
4460 v4l2_device_unregister(&btv->c.v4l2_dev);
4461
4462fail0:
4450 if (btv->bt848_mmio) 4463 if (btv->bt848_mmio)
4451 iounmap(btv->bt848_mmio); 4464 iounmap(btv->bt848_mmio);
4452 release_mem_region(pci_resource_start(btv->c.pci,0), 4465 release_mem_region(pci_resource_start(btv->c.pci,0),
4453 pci_resource_len(btv->c.pci,0)); 4466 pci_resource_len(btv->c.pci,0));
4454 pci_set_drvdata(dev,NULL);
4455 return result; 4467 return result;
4456} 4468}
4457 4469
4458static void __devexit bttv_remove(struct pci_dev *pci_dev) 4470static void __devexit bttv_remove(struct pci_dev *pci_dev)
4459{ 4471{
4460 struct bttv *btv = pci_get_drvdata(pci_dev); 4472 struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
4473 struct bttv *btv = to_bttv(v4l2_dev);
4461 4474
4462 if (bttv_verbose) 4475 if (bttv_verbose)
4463 printk("bttv%d: unloading\n",btv->c.nr); 4476 printk("bttv%d: unloading\n",btv->c.nr);
@@ -4491,7 +4504,7 @@ static void __devexit bttv_remove(struct pci_dev *pci_dev)
4491 release_mem_region(pci_resource_start(btv->c.pci,0), 4504 release_mem_region(pci_resource_start(btv->c.pci,0),
4492 pci_resource_len(btv->c.pci,0)); 4505 pci_resource_len(btv->c.pci,0));
4493 4506
4494 pci_set_drvdata(pci_dev, NULL); 4507 v4l2_device_unregister(&btv->c.v4l2_dev);
4495 bttvs[btv->c.nr] = NULL; 4508 bttvs[btv->c.nr] = NULL;
4496 kfree(btv); 4509 kfree(btv);
4497 4510
@@ -4501,7 +4514,8 @@ static void __devexit bttv_remove(struct pci_dev *pci_dev)
4501#ifdef CONFIG_PM 4514#ifdef CONFIG_PM
4502static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state) 4515static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
4503{ 4516{
4504 struct bttv *btv = pci_get_drvdata(pci_dev); 4517 struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
4518 struct bttv *btv = to_bttv(v4l2_dev);
4505 struct bttv_buffer_set idle; 4519 struct bttv_buffer_set idle;
4506 unsigned long flags; 4520 unsigned long flags;
4507 4521
@@ -4536,7 +4550,8 @@ static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
4536 4550
4537static int bttv_resume(struct pci_dev *pci_dev) 4551static int bttv_resume(struct pci_dev *pci_dev)
4538{ 4552{
4539 struct bttv *btv = pci_get_drvdata(pci_dev); 4553 struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
4554 struct bttv *btv = to_bttv(v4l2_dev);
4540 unsigned long flags; 4555 unsigned long flags;
4541 int err; 4556 int err;
4542 4557
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index 511d2bf176f..9b66c5b0932 100644
--- a/drivers/media/video/bt8xx/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -231,7 +231,8 @@ bttv_i2c_readbytes(struct bttv *btv, const struct i2c_msg *msg, int last)
231 231
232static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num) 232static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
233{ 233{
234 struct bttv *btv = i2c_get_adapdata(i2c_adap); 234 struct v4l2_device *v4l2_dev = i2c_get_adapdata(i2c_adap);
235 struct bttv *btv = to_bttv(v4l2_dev);
235 int retval = 0; 236 int retval = 0;
236 int i; 237 int i;
237 238
@@ -267,7 +268,8 @@ static const struct i2c_algorithm bttv_algo = {
267 268
268static int attach_inform(struct i2c_client *client) 269static int attach_inform(struct i2c_client *client)
269{ 270{
270 struct bttv *btv = i2c_get_adapdata(client->adapter); 271 struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
272 struct bttv *btv = to_bttv(v4l2_dev);
271 int addr=ADDR_UNSET; 273 int addr=ADDR_UNSET;
272 274
273 275
@@ -423,7 +425,7 @@ int __devinit init_bttv_i2c(struct bttv *btv)
423 "bt%d #%d [%s]", btv->id, btv->c.nr, 425 "bt%d #%d [%s]", btv->id, btv->c.nr,
424 btv->use_i2c_hw ? "hw" : "sw"); 426 btv->use_i2c_hw ? "hw" : "sw");
425 427
426 i2c_set_adapdata(&btv->c.i2c_adap, btv); 428 i2c_set_adapdata(&btv->c.i2c_adap, &btv->c.v4l2_dev);
427 btv->i2c_client.adapter = &btv->c.i2c_adap; 429 btv->i2c_client.adapter = &btv->c.i2c_adap;
428 430
429 if (bttv_tvcards[btv->c.type].no_video) 431 if (bttv_tvcards[btv->c.type].no_video)
@@ -439,7 +441,7 @@ int __devinit init_bttv_i2c(struct bttv *btv)
439 btv->i2c_rc = i2c_bit_add_bus(&btv->c.i2c_adap); 441 btv->i2c_rc = i2c_bit_add_bus(&btv->c.i2c_adap);
440 } 442 }
441 if (0 == btv->i2c_rc && i2c_scan) 443 if (0 == btv->i2c_rc && i2c_scan)
442 do_i2c_scan(btv->c.name,&btv->i2c_client); 444 do_i2c_scan(btv->c.v4l2_dev.name, &btv->i2c_client);
443 return btv->i2c_rc; 445 return btv->i2c_rc;
444} 446}
445 447
diff --git a/drivers/media/video/bt8xx/bttv.h b/drivers/media/video/bt8xx/bttv.h
index e08719b378b..85b0e3e9d38 100644
--- a/drivers/media/video/bt8xx/bttv.h
+++ b/drivers/media/video/bt8xx/bttv.h
@@ -16,6 +16,7 @@
16 16
17#include <linux/videodev2.h> 17#include <linux/videodev2.h>
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <media/v4l2-device.h>
19#include <media/ir-common.h> 20#include <media/ir-common.h>
20#include <media/ir-kbd-i2c.h> 21#include <media/ir-kbd-i2c.h>
21#include <media/i2c-addr.h> 22#include <media/i2c-addr.h>
@@ -196,6 +197,7 @@
196 197
197struct bttv_core { 198struct bttv_core {
198 /* device structs */ 199 /* device structs */
200 struct v4l2_device v4l2_dev;
199 struct pci_dev *pci; 201 struct pci_dev *pci;
200 struct i2c_adapter i2c_adap; 202 struct i2c_adapter i2c_adap;
201 struct list_head subs; /* struct bttv_sub_device */ 203 struct list_head subs; /* struct bttv_sub_device */
@@ -203,7 +205,6 @@ struct bttv_core {
203 /* device config */ 205 /* device config */
204 unsigned int nr; /* dev nr (for printk("bttv%d: ..."); */ 206 unsigned int nr; /* dev nr (for printk("bttv%d: ..."); */
205 unsigned int type; /* card type (pointer into tvcards[]) */ 207 unsigned int type; /* card type (pointer into tvcards[]) */
206 char name[8]; /* dev name */
207}; 208};
208 209
209struct bttv; 210struct bttv;
diff --git a/drivers/media/video/bt8xx/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index 2c0a2cc61d0..5755b407c0a 100644
--- a/drivers/media/video/bt8xx/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -458,6 +458,11 @@ struct bttv {
458 __s32 crop_start; 458 __s32 crop_start;
459}; 459};
460 460
461static inline struct bttv *to_bttv(struct v4l2_device *v4l2_dev)
462{
463 return container_of(v4l2_dev, struct bttv, c.v4l2_dev);
464}
465
461/* our devices */ 466/* our devices */
462#define BTTV_MAX 32 467#define BTTV_MAX 32
463extern unsigned int bttv_num; 468extern unsigned int bttv_num;