forked from Minki/linux
V4L/DVB (3344d): Stradis video little cleanup
Unused function removed. Used container_of instead of for loop. Some small changes Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
parent
9ae82293ff
commit
91fb8357c3
@ -309,41 +309,6 @@ static u32 debiread(struct saa7146 *saa, u32 config, int addr, int count)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* unused */
|
|
||||||
/* MUST be a multiple of 8 bytes and 8-byte aligned and < 32768 bytes */
|
|
||||||
/* data copied into saa->dmadebi buffer, caller must re-enable interrupts */
|
|
||||||
static void ibm_block_dram_read(struct saa7146 *saa, int address, int bytes)
|
|
||||||
{
|
|
||||||
int i, j;
|
|
||||||
u32 *buf;
|
|
||||||
buf = (u32 *) saa->dmadebi;
|
|
||||||
if (bytes > 0x7000)
|
|
||||||
bytes = 0x7000;
|
|
||||||
saawrite(0, SAA7146_IER); /* disable interrupts */
|
|
||||||
for (i=0; i < 10000 &&
|
|
||||||
(debiread(saa, debNormal, IBM_MP2_DRAM_CMD_STAT, 2)
|
|
||||||
& 0x8000); i++)
|
|
||||||
saaread(SAA7146_MC2);
|
|
||||||
if (i == 10000)
|
|
||||||
printk(KERN_ERR "stradis%d: dram_busy never cleared\n",
|
|
||||||
saa->nr);
|
|
||||||
debiwrite(saa, debNormal, IBM_MP2_SRC_ADDR, (address<<16) |
|
|
||||||
(address>>16), 4);
|
|
||||||
debiwrite(saa, debNormal, IBM_MP2_BLOCK_SIZE, bytes, 2);
|
|
||||||
debiwrite(saa, debNormal, IBM_MP2_CMD_STAT, 0x8a10, 2);
|
|
||||||
for (j = 0; j < bytes/4; j++) {
|
|
||||||
for (i = 0; i < 10000 &&
|
|
||||||
(!(debiread(saa, debNormal, IBM_MP2_DRAM_CMD_STAT, 2)
|
|
||||||
& 0x4000)); i++)
|
|
||||||
saaread(SAA7146_MC2);
|
|
||||||
if (i == 10000)
|
|
||||||
printk(KERN_ERR "stradis%d: dram_ready never set\n",
|
|
||||||
saa->nr);
|
|
||||||
buf[j] = debiread(saa, debNormal, IBM_MP2_DRAM_DATA, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* unused */
|
|
||||||
|
|
||||||
static void do_irq_send_data(struct saa7146 *saa)
|
static void do_irq_send_data(struct saa7146 *saa)
|
||||||
{
|
{
|
||||||
int split, audbytes, vidbytes;
|
int split, audbytes, vidbytes;
|
||||||
@ -1935,21 +1900,11 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
|
|||||||
|
|
||||||
static int saa_open(struct inode *inode, struct file *file)
|
static int saa_open(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
struct saa7146 *saa = NULL;
|
struct video_device *vdev = video_devdata(file);
|
||||||
unsigned int minor = iminor(inode);
|
struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev);
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < SAA7146_MAX; i++) {
|
|
||||||
if (saa7146s[i].video_dev.minor == minor) {
|
|
||||||
saa = &saa7146s[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (saa == NULL) {
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
file->private_data = saa;
|
file->private_data = saa;
|
||||||
|
|
||||||
//saa->video_dev.busy = 0; /* old hack to support multiple open */
|
|
||||||
saa->user++;
|
saa->user++;
|
||||||
if (saa->user > 1)
|
if (saa->user > 1)
|
||||||
return 0; /* device open already, don't reset */
|
return 0; /* device open already, don't reset */
|
||||||
@ -1961,7 +1916,7 @@ static int saa_release(struct inode *inode, struct file *file)
|
|||||||
{
|
{
|
||||||
struct saa7146 *saa = file->private_data;
|
struct saa7146 *saa = file->private_data;
|
||||||
saa->user--;
|
saa->user--;
|
||||||
//saa->video_dev.busy = 0; /* old hack to support multiple open */
|
|
||||||
if (saa->user > 0) /* still someone using device */
|
if (saa->user > 0) /* still someone using device */
|
||||||
return 0;
|
return 0;
|
||||||
saawrite(0x007f0000, SAA7146_MC1); /* stop all overlay dma */
|
saawrite(0x007f0000, SAA7146_MC1); /* stop all overlay dma */
|
||||||
@ -1993,8 +1948,8 @@ static struct video_device saa_template =
|
|||||||
|
|
||||||
static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
|
static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
|
||||||
{
|
{
|
||||||
int result;
|
int retval;
|
||||||
struct saa7146 *saa = &saa7146s[num];
|
struct saa7146 *saa = pci_get_drvdata(pdev);
|
||||||
|
|
||||||
saa->endmarkhead = saa->endmarktail = 0;
|
saa->endmarkhead = saa->endmarktail = 0;
|
||||||
saa->win.x = saa->win.y = 0;
|
saa->win.x = saa->win.y = 0;
|
||||||
@ -2030,8 +1985,11 @@ static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
|
|||||||
init_waitqueue_head(&saa->vidq);
|
init_waitqueue_head(&saa->vidq);
|
||||||
spin_lock_init(&saa->lock);
|
spin_lock_init(&saa->lock);
|
||||||
|
|
||||||
if (pci_enable_device(pdev))
|
retval = pci_enable_device(pdev);
|
||||||
return -EIO;
|
if (retval) {
|
||||||
|
dev_err(&pdev->dev, "%d: pci_enable_device failed!\n", num);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
saa->id = pdev->device;
|
saa->id = pdev->device;
|
||||||
saa->irq = pdev->irq;
|
saa->irq = pdev->irq;
|
||||||
@ -2040,33 +1998,44 @@ static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
|
|||||||
pci_read_config_byte(pdev, PCI_CLASS_REVISION, &saa->revision);
|
pci_read_config_byte(pdev, PCI_CLASS_REVISION, &saa->revision);
|
||||||
|
|
||||||
saa->saa7146_mem = ioremap(saa->saa7146_adr, 0x200);
|
saa->saa7146_mem = ioremap(saa->saa7146_adr, 0x200);
|
||||||
if (!saa->saa7146_mem)
|
if (saa->saa7146_mem == NULL) {
|
||||||
return -EIO;
|
dev_err(&pdev->dev, "%d: ioremap failed!\n", num);
|
||||||
|
retval = -EIO;
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(&saa->video_dev, &saa_template, sizeof(saa_template));
|
memcpy(&saa->video_dev, &saa_template, sizeof(saa_template));
|
||||||
saawrite(0, SAA7146_IER); /* turn off all interrupts */
|
saawrite(0, SAA7146_IER); /* turn off all interrupts */
|
||||||
result = request_irq(saa->irq, saa7146_irq,
|
|
||||||
SA_SHIRQ | SA_INTERRUPT, "stradis", (void *) saa);
|
retval = request_irq(saa->irq, saa7146_irq, SA_SHIRQ | SA_INTERRUPT,
|
||||||
if (result == -EINVAL)
|
"stradis", saa);
|
||||||
|
if (retval == -EINVAL)
|
||||||
dev_err(&pdev->dev, "%d: Bad irq number or handler\n", num);
|
dev_err(&pdev->dev, "%d: Bad irq number or handler\n", num);
|
||||||
if (result == -EBUSY)
|
else if (retval == -EBUSY)
|
||||||
dev_err(&pdev->dev, "%d: IRQ %ld busy, change your PnP config "
|
dev_err(&pdev->dev, "%d: IRQ %ld busy, change your PnP config "
|
||||||
"in BIOS\n", num, saa->irq);
|
"in BIOS\n", num, saa->irq);
|
||||||
if (result < 0) {
|
if (retval < 0)
|
||||||
iounmap(saa->saa7146_mem);
|
goto errio;
|
||||||
return result;
|
|
||||||
}
|
|
||||||
pci_set_master(pdev);
|
pci_set_master(pdev);
|
||||||
if (video_register_device(&saa->video_dev, VFL_TYPE_GRABBER, video_nr) < 0) {
|
retval = video_register_device(&saa->video_dev, VFL_TYPE_GRABBER,
|
||||||
iounmap(saa->saa7146_mem);
|
video_nr);
|
||||||
return -1;
|
if (retval < 0) {
|
||||||
}
|
dev_err(&pdev->dev, "%d: error in registering video device!\n",
|
||||||
return 0;
|
num);
|
||||||
|
goto errio;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __devinit init_saa7146(int i, struct device *dev)
|
return 0;
|
||||||
|
errio:
|
||||||
|
iounmap(saa->saa7146_mem);
|
||||||
|
err:
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __devinit init_saa7146(struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
struct saa7146 *saa = &saa7146s[i];
|
struct saa7146 *saa = pci_get_drvdata(pdev);
|
||||||
|
|
||||||
memset(saa, 0, sizeof(*saa));
|
memset(saa, 0, sizeof(*saa));
|
||||||
saa->user = 0;
|
saa->user = 0;
|
||||||
@ -2101,8 +2070,8 @@ static int __devinit init_saa7146(int i, struct device *dev)
|
|||||||
|
|
||||||
/* allocate 32k dma buffer + 4k for page table */
|
/* allocate 32k dma buffer + 4k for page table */
|
||||||
if ((saa->dmadebi = kmalloc(32768 + 4096, GFP_KERNEL)) == NULL) {
|
if ((saa->dmadebi = kmalloc(32768 + 4096, GFP_KERNEL)) == NULL) {
|
||||||
dev_err(dev, "%d: debi kmalloc failed\n", i);
|
dev_err(&pdev->dev, "%d: debi kmalloc failed\n", saa->nr);
|
||||||
return -1;
|
goto err;
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
saa->pagedebi = saa->dmadebi + 32768; /* top 4k is for mmu */
|
saa->pagedebi = saa->dmadebi + 32768; /* top 4k is for mmu */
|
||||||
@ -2112,37 +2081,23 @@ static int __devinit init_saa7146(int i, struct device *dev)
|
|||||||
#endif
|
#endif
|
||||||
saa->audhead = saa->vidhead = saa->osdhead = 0;
|
saa->audhead = saa->vidhead = saa->osdhead = 0;
|
||||||
saa->audtail = saa->vidtail = saa->osdtail = 0;
|
saa->audtail = saa->vidtail = saa->osdtail = 0;
|
||||||
if (saa->vidbuf == NULL)
|
if (saa->vidbuf == NULL && (saa->vidbuf = vmalloc(524288)) == NULL) {
|
||||||
if ((saa->vidbuf = vmalloc(524288)) == NULL) {
|
dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
|
||||||
dev_err(dev, "%d: malloc failed\n", saa->nr);
|
goto err;
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
if (saa->audbuf == NULL)
|
if (saa->audbuf == NULL && (saa->audbuf = vmalloc(65536)) == NULL) {
|
||||||
if ((saa->audbuf = vmalloc(65536)) == NULL) {
|
dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
|
||||||
dev_err(dev, "%d: malloc failed\n", saa->nr);
|
goto errvid;
|
||||||
vfree(saa->vidbuf);
|
|
||||||
saa->vidbuf = NULL;
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
if (saa->osdbuf == NULL)
|
if (saa->osdbuf == NULL && (saa->osdbuf = vmalloc(131072)) == NULL) {
|
||||||
if ((saa->osdbuf = vmalloc(131072)) == NULL) {
|
dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
|
||||||
dev_err(dev, "%d: malloc failed\n", saa->nr);
|
goto erraud;
|
||||||
vfree(saa->vidbuf);
|
|
||||||
vfree(saa->audbuf);
|
|
||||||
saa->vidbuf = saa->audbuf = NULL;
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
}
|
||||||
/* allocate 81920 byte buffer for clipping */
|
/* allocate 81920 byte buffer for clipping */
|
||||||
if ((saa->dmavid2 = kmalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) {
|
if ((saa->dmavid2 = kzalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) {
|
||||||
dev_err(dev, "%d: clip kmalloc failed\n", saa->nr);
|
dev_err(&pdev->dev, "%d: clip kmalloc failed\n", saa->nr);
|
||||||
vfree(saa->vidbuf);
|
goto errosd;
|
||||||
vfree(saa->audbuf);
|
|
||||||
vfree(saa->osdbuf);
|
|
||||||
saa->vidbuf = saa->audbuf = saa->osdbuf = NULL;
|
|
||||||
saa->dmavid2 = NULL;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
memset(saa->dmavid2, 0x00, VIDEO_CLIPMAP_SIZE); /* clip everything */
|
|
||||||
/* setup clipping registers */
|
/* setup clipping registers */
|
||||||
saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2);
|
saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2);
|
||||||
saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2);
|
saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2);
|
||||||
@ -2153,14 +2108,25 @@ static int __devinit init_saa7146(int i, struct device *dev)
|
|||||||
saawrite(((SAA7146_MC2_UPLD_DMA2) << 16) | SAA7146_MC2_UPLD_DMA2,
|
saawrite(((SAA7146_MC2_UPLD_DMA2) << 16) | SAA7146_MC2_UPLD_DMA2,
|
||||||
SAA7146_MC2);
|
SAA7146_MC2);
|
||||||
I2CBusScan(saa);
|
I2CBusScan(saa);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
errosd:
|
||||||
|
vfree(saa->osdbuf);
|
||||||
|
saa->osdbuf = NULL;
|
||||||
|
erraud:
|
||||||
|
vfree(saa->audbuf);
|
||||||
|
saa->audbuf = NULL;
|
||||||
|
errvid:
|
||||||
|
vfree(saa->vidbuf);
|
||||||
|
saa->vidbuf = NULL;
|
||||||
|
err:
|
||||||
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void stradis_release_saa(struct pci_dev *pdev)
|
static void stradis_release_saa(struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
u8 command;
|
u8 command;
|
||||||
int i = (int)pci_get_drvdata(pdev);
|
struct saa7146 *saa = pci_get_drvdata(pdev);
|
||||||
struct saa7146 *saa = &saa7146s[i];
|
|
||||||
|
|
||||||
/* turn off all capturing, DMA and IRQs */
|
/* turn off all capturing, DMA and IRQs */
|
||||||
saawrite(0xffff0000, SAA7146_MC1); /* reset chip */
|
saawrite(0xffff0000, SAA7146_MC1); /* reset chip */
|
||||||
@ -2211,7 +2177,7 @@ static int __devinit stradis_probe(struct pci_dev *pdev,
|
|||||||
else
|
else
|
||||||
dev_info(&pdev->dev, "%d: SDM2xx found\n", saa_num);
|
dev_info(&pdev->dev, "%d: SDM2xx found\n", saa_num);
|
||||||
|
|
||||||
pci_set_drvdata(pdev, (void *)saa_num);
|
pci_set_drvdata(pdev, &saa7146s[saa_num]);
|
||||||
|
|
||||||
retval = configure_saa7146(pdev, saa_num);
|
retval = configure_saa7146(pdev, saa_num);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
@ -2219,7 +2185,7 @@ static int __devinit stradis_probe(struct pci_dev *pdev,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_saa7146(saa_num, &pdev->dev) < 0) {
|
if (init_saa7146(pdev) < 0) {
|
||||||
dev_err(&pdev->dev, "%d: error in initialization\n", saa_num);
|
dev_err(&pdev->dev, "%d: error in initialization\n", saa_num);
|
||||||
retval = -EIO;
|
retval = -EIO;
|
||||||
goto errrel;
|
goto errrel;
|
||||||
|
Loading…
Reference in New Issue
Block a user