aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/bt8xx/bttv-driver.c
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 /drivers/media/video/bt8xx/bttv-driver.c
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>
Diffstat (limited to 'drivers/media/video/bt8xx/bttv-driver.c')
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c47
1 files changed, 31 insertions, 16 deletions
diff --git a/drivers/media/video/bt8xx/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index b5fc3cc61888..3079d925e4cf 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