aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <xslaby@fi.muni.cz>2006-01-11 16:41:21 -0500
committerMauro Carvalho Chehab <mchehab@brturbo.com.br>2006-01-11 16:41:21 -0500
commit91fb8357c3e097a46eb6e92d03b284182172ce80 (patch)
treebf72766a6cd82835c27adfbc796bbed48026593d
parent9ae82293ff3a3057d939b4f56d57eeea2f91bbec (diff)
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>
-rw-r--r--drivers/media/video/stradis.c170
1 files changed, 68 insertions, 102 deletions
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index ad6646c7da03..48cd30d8eb5a 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -309,41 +309,6 @@ static u32 debiread(struct saa7146 *saa, u32 config, int addr, int count)
309 return result; 309 return result;
310} 310}
311 311
312#if 0 /* unused */
313/* MUST be a multiple of 8 bytes and 8-byte aligned and < 32768 bytes */
314/* data copied into saa->dmadebi buffer, caller must re-enable interrupts */
315static void ibm_block_dram_read(struct saa7146 *saa, int address, int bytes)
316{
317 int i, j;
318 u32 *buf;
319 buf = (u32 *) saa->dmadebi;
320 if (bytes > 0x7000)
321 bytes = 0x7000;
322 saawrite(0, SAA7146_IER); /* disable interrupts */
323 for (i=0; i < 10000 &&
324 (debiread(saa, debNormal, IBM_MP2_DRAM_CMD_STAT, 2)
325 & 0x8000); i++)
326 saaread(SAA7146_MC2);
327 if (i == 10000)
328 printk(KERN_ERR "stradis%d: dram_busy never cleared\n",
329 saa->nr);
330 debiwrite(saa, debNormal, IBM_MP2_SRC_ADDR, (address<<16) |
331 (address>>16), 4);
332 debiwrite(saa, debNormal, IBM_MP2_BLOCK_SIZE, bytes, 2);
333 debiwrite(saa, debNormal, IBM_MP2_CMD_STAT, 0x8a10, 2);
334 for (j = 0; j < bytes/4; j++) {
335 for (i = 0; i < 10000 &&
336 (!(debiread(saa, debNormal, IBM_MP2_DRAM_CMD_STAT, 2)
337 & 0x4000)); i++)
338 saaread(SAA7146_MC2);
339 if (i == 10000)
340 printk(KERN_ERR "stradis%d: dram_ready never set\n",
341 saa->nr);
342 buf[j] = debiread(saa, debNormal, IBM_MP2_DRAM_DATA, 4);
343 }
344}
345#endif /* unused */
346
347static void do_irq_send_data(struct saa7146 *saa) 312static void do_irq_send_data(struct saa7146 *saa)
348{ 313{
349 int split, audbytes, vidbytes; 314 int split, audbytes, vidbytes;
@@ -1935,21 +1900,11 @@ static ssize_t saa_write(struct file *file, const char __user *buf,
1935 1900
1936static int saa_open(struct inode *inode, struct file *file) 1901static int saa_open(struct inode *inode, struct file *file)
1937{ 1902{
1938 struct saa7146 *saa = NULL; 1903 struct video_device *vdev = video_devdata(file);
1939 unsigned int minor = iminor(inode); 1904 struct saa7146 *saa = container_of(vdev, struct saa7146, video_dev);
1940 int i;
1941 1905
1942 for (i = 0; i < SAA7146_MAX; i++) {
1943 if (saa7146s[i].video_dev.minor == minor) {
1944 saa = &saa7146s[i];
1945 }
1946 }
1947 if (saa == NULL) {
1948 return -ENODEV;
1949 }
1950 file->private_data = saa; 1906 file->private_data = saa;
1951 1907
1952 //saa->video_dev.busy = 0; /* old hack to support multiple open */
1953 saa->user++; 1908 saa->user++;
1954 if (saa->user > 1) 1909 if (saa->user > 1)
1955 return 0; /* device open already, don't reset */ 1910 return 0; /* device open already, don't reset */
@@ -1961,7 +1916,7 @@ static int saa_release(struct inode *inode, struct file *file)
1961{ 1916{
1962 struct saa7146 *saa = file->private_data; 1917 struct saa7146 *saa = file->private_data;
1963 saa->user--; 1918 saa->user--;
1964 //saa->video_dev.busy = 0; /* old hack to support multiple open */ 1919
1965 if (saa->user > 0) /* still someone using device */ 1920 if (saa->user > 0) /* still someone using device */
1966 return 0; 1921 return 0;
1967 saawrite(0x007f0000, SAA7146_MC1); /* stop all overlay dma */ 1922 saawrite(0x007f0000, SAA7146_MC1); /* stop all overlay dma */
@@ -1993,8 +1948,8 @@ static struct video_device saa_template =
1993 1948
1994static int __devinit configure_saa7146(struct pci_dev *pdev, int num) 1949static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
1995{ 1950{
1996 int result; 1951 int retval;
1997 struct saa7146 *saa = &saa7146s[num]; 1952 struct saa7146 *saa = pci_get_drvdata(pdev);
1998 1953
1999 saa->endmarkhead = saa->endmarktail = 0; 1954 saa->endmarkhead = saa->endmarktail = 0;
2000 saa->win.x = saa->win.y = 0; 1955 saa->win.x = saa->win.y = 0;
@@ -2030,8 +1985,11 @@ static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
2030 init_waitqueue_head(&saa->vidq); 1985 init_waitqueue_head(&saa->vidq);
2031 spin_lock_init(&saa->lock); 1986 spin_lock_init(&saa->lock);
2032 1987
2033 if (pci_enable_device(pdev)) 1988 retval = pci_enable_device(pdev);
2034 return -EIO; 1989 if (retval) {
1990 dev_err(&pdev->dev, "%d: pci_enable_device failed!\n", num);
1991 goto err;
1992 }
2035 1993
2036 saa->id = pdev->device; 1994 saa->id = pdev->device;
2037 saa->irq = pdev->irq; 1995 saa->irq = pdev->irq;
@@ -2040,33 +1998,44 @@ static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
2040 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &saa->revision); 1998 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &saa->revision);
2041 1999
2042 saa->saa7146_mem = ioremap(saa->saa7146_adr, 0x200); 2000 saa->saa7146_mem = ioremap(saa->saa7146_adr, 0x200);
2043 if (!saa->saa7146_mem) 2001 if (saa->saa7146_mem == NULL) {
2044 return -EIO; 2002 dev_err(&pdev->dev, "%d: ioremap failed!\n", num);
2003 retval = -EIO;
2004 goto err;
2005 }
2045 2006
2046 memcpy(&saa->video_dev, &saa_template, sizeof(saa_template)); 2007 memcpy(&saa->video_dev, &saa_template, sizeof(saa_template));
2047 saawrite(0, SAA7146_IER); /* turn off all interrupts */ 2008 saawrite(0, SAA7146_IER); /* turn off all interrupts */
2048 result = request_irq(saa->irq, saa7146_irq, 2009
2049 SA_SHIRQ | SA_INTERRUPT, "stradis", (void *) saa); 2010 retval = request_irq(saa->irq, saa7146_irq, SA_SHIRQ | SA_INTERRUPT,
2050 if (result == -EINVAL) 2011 "stradis", saa);
2012 if (retval == -EINVAL)
2051 dev_err(&pdev->dev, "%d: Bad irq number or handler\n", num); 2013 dev_err(&pdev->dev, "%d: Bad irq number or handler\n", num);
2052 if (result == -EBUSY) 2014 else if (retval == -EBUSY)
2053 dev_err(&pdev->dev, "%d: IRQ %ld busy, change your PnP config " 2015 dev_err(&pdev->dev, "%d: IRQ %ld busy, change your PnP config "
2054 "in BIOS\n", num, saa->irq); 2016 "in BIOS\n", num, saa->irq);
2055 if (result < 0) { 2017 if (retval < 0)
2056 iounmap(saa->saa7146_mem); 2018 goto errio;
2057 return result; 2019
2058 }
2059 pci_set_master(pdev); 2020 pci_set_master(pdev);
2060 if (video_register_device(&saa->video_dev, VFL_TYPE_GRABBER, video_nr) < 0) { 2021 retval = video_register_device(&saa->video_dev, VFL_TYPE_GRABBER,
2061 iounmap(saa->saa7146_mem); 2022 video_nr);
2062 return -1; 2023 if (retval < 0) {
2024 dev_err(&pdev->dev, "%d: error in registering video device!\n",
2025 num);
2026 goto errio;
2063 } 2027 }
2028
2064 return 0; 2029 return 0;
2030errio:
2031 iounmap(saa->saa7146_mem);
2032err:
2033 return retval;
2065} 2034}
2066 2035
2067static int __devinit init_saa7146(int i, struct device *dev) 2036static int __devinit init_saa7146(struct pci_dev *pdev)
2068{ 2037{
2069 struct saa7146 *saa = &saa7146s[i]; 2038 struct saa7146 *saa = pci_get_drvdata(pdev);
2070 2039
2071 memset(saa, 0, sizeof(*saa)); 2040 memset(saa, 0, sizeof(*saa));
2072 saa->user = 0; 2041 saa->user = 0;
@@ -2101,8 +2070,8 @@ static int __devinit init_saa7146(int i, struct device *dev)
2101 2070
2102 /* allocate 32k dma buffer + 4k for page table */ 2071 /* allocate 32k dma buffer + 4k for page table */
2103 if ((saa->dmadebi = kmalloc(32768 + 4096, GFP_KERNEL)) == NULL) { 2072 if ((saa->dmadebi = kmalloc(32768 + 4096, GFP_KERNEL)) == NULL) {
2104 dev_err(dev, "%d: debi kmalloc failed\n", i); 2073 dev_err(&pdev->dev, "%d: debi kmalloc failed\n", saa->nr);
2105 return -1; 2074 goto err;
2106 } 2075 }
2107#if 0 2076#if 0
2108 saa->pagedebi = saa->dmadebi + 32768; /* top 4k is for mmu */ 2077 saa->pagedebi = saa->dmadebi + 32768; /* top 4k is for mmu */
@@ -2112,37 +2081,23 @@ static int __devinit init_saa7146(int i, struct device *dev)
2112#endif 2081#endif
2113 saa->audhead = saa->vidhead = saa->osdhead = 0; 2082 saa->audhead = saa->vidhead = saa->osdhead = 0;
2114 saa->audtail = saa->vidtail = saa->osdtail = 0; 2083 saa->audtail = saa->vidtail = saa->osdtail = 0;
2115 if (saa->vidbuf == NULL) 2084 if (saa->vidbuf == NULL && (saa->vidbuf = vmalloc(524288)) == NULL) {
2116 if ((saa->vidbuf = vmalloc(524288)) == NULL) { 2085 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2117 dev_err(dev, "%d: malloc failed\n", saa->nr); 2086 goto err;
2118 return -ENOMEM; 2087 }
2119 } 2088 if (saa->audbuf == NULL && (saa->audbuf = vmalloc(65536)) == NULL) {
2120 if (saa->audbuf == NULL) 2089 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2121 if ((saa->audbuf = vmalloc(65536)) == NULL) { 2090 goto errvid;
2122 dev_err(dev, "%d: malloc failed\n", saa->nr); 2091 }
2123 vfree(saa->vidbuf); 2092 if (saa->osdbuf == NULL && (saa->osdbuf = vmalloc(131072)) == NULL) {
2124 saa->vidbuf = NULL; 2093 dev_err(&pdev->dev, "%d: malloc failed\n", saa->nr);
2125 return -ENOMEM; 2094 goto erraud;
2126 } 2095 }
2127 if (saa->osdbuf == NULL)
2128 if ((saa->osdbuf = vmalloc(131072)) == NULL) {
2129 dev_err(dev, "%d: malloc failed\n", saa->nr);
2130 vfree(saa->vidbuf);
2131 vfree(saa->audbuf);
2132 saa->vidbuf = saa->audbuf = NULL;
2133 return -ENOMEM;
2134 }
2135 /* allocate 81920 byte buffer for clipping */ 2096 /* allocate 81920 byte buffer for clipping */
2136 if ((saa->dmavid2 = kmalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) { 2097 if ((saa->dmavid2 = kzalloc(VIDEO_CLIPMAP_SIZE, GFP_KERNEL)) == NULL) {
2137 dev_err(dev, "%d: clip kmalloc failed\n", saa->nr); 2098 dev_err(&pdev->dev, "%d: clip kmalloc failed\n", saa->nr);
2138 vfree(saa->vidbuf); 2099 goto errosd;
2139 vfree(saa->audbuf);
2140 vfree(saa->osdbuf);
2141 saa->vidbuf = saa->audbuf = saa->osdbuf = NULL;
2142 saa->dmavid2 = NULL;
2143 return -1;
2144 } 2100 }
2145 memset(saa->dmavid2, 0x00, VIDEO_CLIPMAP_SIZE); /* clip everything */
2146 /* setup clipping registers */ 2101 /* setup clipping registers */
2147 saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2); 2102 saawrite(virt_to_bus(saa->dmavid2), SAA7146_BASE_EVEN2);
2148 saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2); 2103 saawrite(virt_to_bus(saa->dmavid2) + 128, SAA7146_BASE_ODD2);
@@ -2153,14 +2108,25 @@ static int __devinit init_saa7146(int i, struct device *dev)
2153 saawrite(((SAA7146_MC2_UPLD_DMA2) << 16) | SAA7146_MC2_UPLD_DMA2, 2108 saawrite(((SAA7146_MC2_UPLD_DMA2) << 16) | SAA7146_MC2_UPLD_DMA2,
2154 SAA7146_MC2); 2109 SAA7146_MC2);
2155 I2CBusScan(saa); 2110 I2CBusScan(saa);
2111
2156 return 0; 2112 return 0;
2113errosd:
2114 vfree(saa->osdbuf);
2115 saa->osdbuf = NULL;
2116erraud:
2117 vfree(saa->audbuf);
2118 saa->audbuf = NULL;
2119errvid:
2120 vfree(saa->vidbuf);
2121 saa->vidbuf = NULL;
2122err:
2123 return -ENOMEM;
2157} 2124}
2158 2125
2159static void stradis_release_saa(struct pci_dev *pdev) 2126static void stradis_release_saa(struct pci_dev *pdev)
2160{ 2127{
2161 u8 command; 2128 u8 command;
2162 int i = (int)pci_get_drvdata(pdev); 2129 struct saa7146 *saa = pci_get_drvdata(pdev);
2163 struct saa7146 *saa = &saa7146s[i];
2164 2130
2165 /* turn off all capturing, DMA and IRQs */ 2131 /* turn off all capturing, DMA and IRQs */
2166 saawrite(0xffff0000, SAA7146_MC1); /* reset chip */ 2132 saawrite(0xffff0000, SAA7146_MC1); /* reset chip */
@@ -2211,7 +2177,7 @@ static int __devinit stradis_probe(struct pci_dev *pdev,
2211 else 2177 else
2212 dev_info(&pdev->dev, "%d: SDM2xx found\n", saa_num); 2178 dev_info(&pdev->dev, "%d: SDM2xx found\n", saa_num);
2213 2179
2214 pci_set_drvdata(pdev, (void *)saa_num); 2180 pci_set_drvdata(pdev, &saa7146s[saa_num]);
2215 2181
2216 retval = configure_saa7146(pdev, saa_num); 2182 retval = configure_saa7146(pdev, saa_num);
2217 if (retval) { 2183 if (retval) {
@@ -2219,7 +2185,7 @@ static int __devinit stradis_probe(struct pci_dev *pdev,
2219 goto err; 2185 goto err;
2220 } 2186 }
2221 2187
2222 if (init_saa7146(saa_num, &pdev->dev) < 0) { 2188 if (init_saa7146(pdev) < 0) {
2223 dev_err(&pdev->dev, "%d: error in initialization\n", saa_num); 2189 dev_err(&pdev->dev, "%d: error in initialization\n", saa_num);
2224 retval = -EIO; 2190 retval = -EIO;
2225 goto errrel; 2191 goto errrel;