mirror of
https://github.com/adulau/aha.git
synced 2025-01-01 05:36:24 +00:00
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>
This commit is contained in:
parent
f1ba28c3a6
commit
74fc7bd9ce
5 changed files with 45 additions and 22 deletions
|
@ -814,7 +814,7 @@ static int __devinit dvb_bt8xx_probe(struct bttv_sub_device *sub)
|
||||||
|
|
||||||
mutex_init(&card->lock);
|
mutex_init(&card->lock);
|
||||||
card->bttv_nr = sub->core->nr;
|
card->bttv_nr = sub->core->nr;
|
||||||
strncpy(card->card_name, sub->core->name, sizeof(sub->core->name));
|
strlcpy(card->card_name, sub->core->v4l2_dev.name, sizeof(card->card_name));
|
||||||
card->i2c_adapter = &sub->core->i2c_adap;
|
card->i2c_adapter = &sub->core->i2c_adap;
|
||||||
|
|
||||||
switch(sub->core->type) {
|
switch(sub->core->type) {
|
||||||
|
|
|
@ -167,7 +167,7 @@ static ssize_t show_card(struct device *cd,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct video_device *vfd = container_of(cd, struct video_device, dev);
|
struct video_device *vfd = container_of(cd, struct video_device, dev);
|
||||||
struct bttv *btv = dev_get_drvdata(vfd->parent);
|
struct bttv *btv = video_get_drvdata(vfd);
|
||||||
return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
|
return sprintf(buf, "%d\n", btv ? btv->c.type : UNSET);
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
|
static DEVICE_ATTR(card, S_IRUGO, show_card, NULL);
|
||||||
|
@ -3692,14 +3692,14 @@ static void bttv_risc_disasm(struct bttv *btv,
|
||||||
unsigned int i,j,n;
|
unsigned int i,j,n;
|
||||||
|
|
||||||
printk("%s: risc disasm: %p [dma=0x%08lx]\n",
|
printk("%s: risc disasm: %p [dma=0x%08lx]\n",
|
||||||
btv->c.name, risc->cpu, (unsigned long)risc->dma);
|
btv->c.v4l2_dev.name, risc->cpu, (unsigned long)risc->dma);
|
||||||
for (i = 0; i < (risc->size >> 2); i += n) {
|
for (i = 0; i < (risc->size >> 2); i += n) {
|
||||||
printk("%s: 0x%lx: ", btv->c.name,
|
printk("%s: 0x%lx: ", btv->c.v4l2_dev.name,
|
||||||
(unsigned long)(risc->dma + (i<<2)));
|
(unsigned long)(risc->dma + (i<<2)));
|
||||||
n = bttv_risc_decode(le32_to_cpu(risc->cpu[i]));
|
n = bttv_risc_decode(le32_to_cpu(risc->cpu[i]));
|
||||||
for (j = 1; j < n; j++)
|
for (j = 1; j < n; j++)
|
||||||
printk("%s: 0x%lx: 0x%08x [ arg #%d ]\n",
|
printk("%s: 0x%lx: 0x%08x [ arg #%d ]\n",
|
||||||
btv->c.name, (unsigned long)(risc->dma + ((i+j)<<2)),
|
btv->c.v4l2_dev.name, (unsigned long)(risc->dma + ((i+j)<<2)),
|
||||||
risc->cpu[i+j], j);
|
risc->cpu[i+j], j);
|
||||||
if (0 == risc->cpu[i])
|
if (0 == risc->cpu[i])
|
||||||
break;
|
break;
|
||||||
|
@ -4175,7 +4175,7 @@ static struct video_device *vdev_init(struct bttv *btv,
|
||||||
return NULL;
|
return NULL;
|
||||||
*vfd = *template;
|
*vfd = *template;
|
||||||
vfd->minor = -1;
|
vfd->minor = -1;
|
||||||
vfd->parent = &btv->c.pci->dev;
|
vfd->v4l2_dev = &btv->c.v4l2_dev;
|
||||||
vfd->release = video_device_release;
|
vfd->release = video_device_release;
|
||||||
vfd->debug = bttv_debug;
|
vfd->debug = bttv_debug;
|
||||||
video_set_drvdata(vfd, btv);
|
video_set_drvdata(vfd, btv);
|
||||||
|
@ -4289,8 +4289,13 @@ static int __devinit bttv_probe(struct pci_dev *dev,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
printk(KERN_INFO "bttv: Bt8xx card found (%d).\n", bttv_num);
|
printk(KERN_INFO "bttv: Bt8xx card found (%d).\n", bttv_num);
|
||||||
bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL);
|
bttvs[bttv_num] = btv = kzalloc(sizeof(*btv), GFP_KERNEL);
|
||||||
|
if (btv == NULL) {
|
||||||
|
printk(KERN_ERR "bttv: out of memory.\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
btv->c.nr = bttv_num;
|
btv->c.nr = bttv_num;
|
||||||
sprintf(btv->c.name,"bttv%d",btv->c.nr);
|
snprintf(btv->c.v4l2_dev.name, sizeof(btv->c.v4l2_dev.name),
|
||||||
|
"bttv%d", btv->c.nr);
|
||||||
|
|
||||||
/* initialize structs / fill in defaults */
|
/* initialize structs / fill in defaults */
|
||||||
mutex_init(&btv->lock);
|
mutex_init(&btv->lock);
|
||||||
|
@ -4327,7 +4332,7 @@ static int __devinit bttv_probe(struct pci_dev *dev,
|
||||||
}
|
}
|
||||||
if (!request_mem_region(pci_resource_start(dev,0),
|
if (!request_mem_region(pci_resource_start(dev,0),
|
||||||
pci_resource_len(dev,0),
|
pci_resource_len(dev,0),
|
||||||
btv->c.name)) {
|
btv->c.v4l2_dev.name)) {
|
||||||
printk(KERN_WARNING "bttv%d: can't request iomem (0x%llx).\n",
|
printk(KERN_WARNING "bttv%d: can't request iomem (0x%llx).\n",
|
||||||
btv->c.nr,
|
btv->c.nr,
|
||||||
(unsigned long long)pci_resource_start(dev,0));
|
(unsigned long long)pci_resource_start(dev,0));
|
||||||
|
@ -4335,7 +4340,12 @@ static int __devinit bttv_probe(struct pci_dev *dev,
|
||||||
}
|
}
|
||||||
pci_set_master(dev);
|
pci_set_master(dev);
|
||||||
pci_set_command(dev);
|
pci_set_command(dev);
|
||||||
pci_set_drvdata(dev,btv);
|
|
||||||
|
result = v4l2_device_register(&dev->dev, &btv->c.v4l2_dev);
|
||||||
|
if (result < 0) {
|
||||||
|
printk(KERN_WARNING "bttv%d: v4l2_device_register() failed\n", btv->c.nr);
|
||||||
|
goto fail0;
|
||||||
|
}
|
||||||
|
|
||||||
pci_read_config_byte(dev, PCI_CLASS_REVISION, &btv->revision);
|
pci_read_config_byte(dev, PCI_CLASS_REVISION, &btv->revision);
|
||||||
pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
|
pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
|
||||||
|
@ -4359,7 +4369,7 @@ static int __devinit bttv_probe(struct pci_dev *dev,
|
||||||
/* disable irqs, register irq handler */
|
/* disable irqs, register irq handler */
|
||||||
btwrite(0, BT848_INT_MASK);
|
btwrite(0, BT848_INT_MASK);
|
||||||
result = request_irq(btv->c.pci->irq, bttv_irq,
|
result = request_irq(btv->c.pci->irq, bttv_irq,
|
||||||
IRQF_SHARED | IRQF_DISABLED,btv->c.name,(void *)btv);
|
IRQF_SHARED | IRQF_DISABLED, btv->c.v4l2_dev.name, (void *)btv);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
printk(KERN_ERR "bttv%d: can't get IRQ %d\n",
|
printk(KERN_ERR "bttv%d: can't get IRQ %d\n",
|
||||||
bttv_num,btv->c.pci->irq);
|
bttv_num,btv->c.pci->irq);
|
||||||
|
@ -4443,21 +4453,24 @@ static int __devinit bttv_probe(struct pci_dev *dev,
|
||||||
bttv_num++;
|
bttv_num++;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail2:
|
fail2:
|
||||||
free_irq(btv->c.pci->irq,btv);
|
free_irq(btv->c.pci->irq,btv);
|
||||||
|
|
||||||
fail1:
|
fail1:
|
||||||
|
v4l2_device_unregister(&btv->c.v4l2_dev);
|
||||||
|
|
||||||
|
fail0:
|
||||||
if (btv->bt848_mmio)
|
if (btv->bt848_mmio)
|
||||||
iounmap(btv->bt848_mmio);
|
iounmap(btv->bt848_mmio);
|
||||||
release_mem_region(pci_resource_start(btv->c.pci,0),
|
release_mem_region(pci_resource_start(btv->c.pci,0),
|
||||||
pci_resource_len(btv->c.pci,0));
|
pci_resource_len(btv->c.pci,0));
|
||||||
pci_set_drvdata(dev,NULL);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __devexit bttv_remove(struct pci_dev *pci_dev)
|
static void __devexit bttv_remove(struct pci_dev *pci_dev)
|
||||||
{
|
{
|
||||||
struct bttv *btv = pci_get_drvdata(pci_dev);
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
||||||
|
struct bttv *btv = to_bttv(v4l2_dev);
|
||||||
|
|
||||||
if (bttv_verbose)
|
if (bttv_verbose)
|
||||||
printk("bttv%d: unloading\n",btv->c.nr);
|
printk("bttv%d: unloading\n",btv->c.nr);
|
||||||
|
@ -4491,7 +4504,7 @@ static void __devexit bttv_remove(struct pci_dev *pci_dev)
|
||||||
release_mem_region(pci_resource_start(btv->c.pci,0),
|
release_mem_region(pci_resource_start(btv->c.pci,0),
|
||||||
pci_resource_len(btv->c.pci,0));
|
pci_resource_len(btv->c.pci,0));
|
||||||
|
|
||||||
pci_set_drvdata(pci_dev, NULL);
|
v4l2_device_unregister(&btv->c.v4l2_dev);
|
||||||
bttvs[btv->c.nr] = NULL;
|
bttvs[btv->c.nr] = NULL;
|
||||||
kfree(btv);
|
kfree(btv);
|
||||||
|
|
||||||
|
@ -4501,7 +4514,8 @@ static void __devexit bttv_remove(struct pci_dev *pci_dev)
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
|
static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
|
||||||
{
|
{
|
||||||
struct bttv *btv = pci_get_drvdata(pci_dev);
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
||||||
|
struct bttv *btv = to_bttv(v4l2_dev);
|
||||||
struct bttv_buffer_set idle;
|
struct bttv_buffer_set idle;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
|
@ -4536,7 +4550,8 @@ static int bttv_suspend(struct pci_dev *pci_dev, pm_message_t state)
|
||||||
|
|
||||||
static int bttv_resume(struct pci_dev *pci_dev)
|
static int bttv_resume(struct pci_dev *pci_dev)
|
||||||
{
|
{
|
||||||
struct bttv *btv = pci_get_drvdata(pci_dev);
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
||||||
|
struct bttv *btv = to_bttv(v4l2_dev);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,8 @@ bttv_i2c_readbytes(struct bttv *btv, const struct i2c_msg *msg, int last)
|
||||||
|
|
||||||
static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
|
static int bttv_i2c_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
|
||||||
{
|
{
|
||||||
struct bttv *btv = i2c_get_adapdata(i2c_adap);
|
struct v4l2_device *v4l2_dev = i2c_get_adapdata(i2c_adap);
|
||||||
|
struct bttv *btv = to_bttv(v4l2_dev);
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -267,7 +268,8 @@ static const struct i2c_algorithm bttv_algo = {
|
||||||
|
|
||||||
static int attach_inform(struct i2c_client *client)
|
static int attach_inform(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
struct bttv *btv = i2c_get_adapdata(client->adapter);
|
struct v4l2_device *v4l2_dev = i2c_get_adapdata(client->adapter);
|
||||||
|
struct bttv *btv = to_bttv(v4l2_dev);
|
||||||
int addr=ADDR_UNSET;
|
int addr=ADDR_UNSET;
|
||||||
|
|
||||||
|
|
||||||
|
@ -423,7 +425,7 @@ int __devinit init_bttv_i2c(struct bttv *btv)
|
||||||
"bt%d #%d [%s]", btv->id, btv->c.nr,
|
"bt%d #%d [%s]", btv->id, btv->c.nr,
|
||||||
btv->use_i2c_hw ? "hw" : "sw");
|
btv->use_i2c_hw ? "hw" : "sw");
|
||||||
|
|
||||||
i2c_set_adapdata(&btv->c.i2c_adap, btv);
|
i2c_set_adapdata(&btv->c.i2c_adap, &btv->c.v4l2_dev);
|
||||||
btv->i2c_client.adapter = &btv->c.i2c_adap;
|
btv->i2c_client.adapter = &btv->c.i2c_adap;
|
||||||
|
|
||||||
if (bttv_tvcards[btv->c.type].no_video)
|
if (bttv_tvcards[btv->c.type].no_video)
|
||||||
|
@ -439,7 +441,7 @@ int __devinit init_bttv_i2c(struct bttv *btv)
|
||||||
btv->i2c_rc = i2c_bit_add_bus(&btv->c.i2c_adap);
|
btv->i2c_rc = i2c_bit_add_bus(&btv->c.i2c_adap);
|
||||||
}
|
}
|
||||||
if (0 == btv->i2c_rc && i2c_scan)
|
if (0 == btv->i2c_rc && i2c_scan)
|
||||||
do_i2c_scan(btv->c.name,&btv->i2c_client);
|
do_i2c_scan(btv->c.v4l2_dev.name, &btv->i2c_client);
|
||||||
return btv->i2c_rc;
|
return btv->i2c_rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#include <linux/i2c.h>
|
#include <linux/i2c.h>
|
||||||
|
#include <media/v4l2-device.h>
|
||||||
#include <media/ir-common.h>
|
#include <media/ir-common.h>
|
||||||
#include <media/ir-kbd-i2c.h>
|
#include <media/ir-kbd-i2c.h>
|
||||||
#include <media/i2c-addr.h>
|
#include <media/i2c-addr.h>
|
||||||
|
@ -196,6 +197,7 @@
|
||||||
|
|
||||||
struct bttv_core {
|
struct bttv_core {
|
||||||
/* device structs */
|
/* device structs */
|
||||||
|
struct v4l2_device v4l2_dev;
|
||||||
struct pci_dev *pci;
|
struct pci_dev *pci;
|
||||||
struct i2c_adapter i2c_adap;
|
struct i2c_adapter i2c_adap;
|
||||||
struct list_head subs; /* struct bttv_sub_device */
|
struct list_head subs; /* struct bttv_sub_device */
|
||||||
|
@ -203,7 +205,6 @@ struct bttv_core {
|
||||||
/* device config */
|
/* device config */
|
||||||
unsigned int nr; /* dev nr (for printk("bttv%d: ..."); */
|
unsigned int nr; /* dev nr (for printk("bttv%d: ..."); */
|
||||||
unsigned int type; /* card type (pointer into tvcards[]) */
|
unsigned int type; /* card type (pointer into tvcards[]) */
|
||||||
char name[8]; /* dev name */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bttv;
|
struct bttv;
|
||||||
|
|
|
@ -458,6 +458,11 @@ struct bttv {
|
||||||
__s32 crop_start;
|
__s32 crop_start;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline struct bttv *to_bttv(struct v4l2_device *v4l2_dev)
|
||||||
|
{
|
||||||
|
return container_of(v4l2_dev, struct bttv, c.v4l2_dev);
|
||||||
|
}
|
||||||
|
|
||||||
/* our devices */
|
/* our devices */
|
||||||
#define BTTV_MAX 32
|
#define BTTV_MAX 32
|
||||||
extern unsigned int bttv_num;
|
extern unsigned int bttv_num;
|
||||||
|
|
Loading…
Reference in a new issue