fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / media / video / vivi.c
index 841884a..d4cf556 100644 (file)
@@ -36,6 +36,7 @@
 #include <media/v4l2-common.h>
 #include <linux/kthread.h>
 #include <linux/highmem.h>
+#include <linux/freezer.h>
 
 /* Wake up at about 30 fps */
 #define WAKE_NUMERATOR 30
@@ -269,10 +270,15 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
        char *p,*s,*basep;
        struct page *pg;
        u8   chr,r,g,b,color;
+       unsigned long flags;
+       spinlock_t spinlock;
+
+       spin_lock_init(&spinlock);
 
        /* Get first addr pointed to pixel position */
        oldpg=get_addr_pos(pos,pages,to_addr);
-       pg=pfn_to_page(to_addr[oldpg].sg->dma_address >> PAGE_SHIFT);
+       pg=pfn_to_page(sg_dma_address(to_addr[oldpg].sg) >> PAGE_SHIFT);
+       spin_lock_irqsave(&spinlock,flags);
        basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
 
        /* We will just duplicate the second pixel at the packet */
@@ -287,7 +293,7 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
                for (color=0;color<4;color++) {
                        pgpos=get_addr_pos(pos,pages,to_addr);
                        if (pgpos!=oldpg) {
-                               pg=pfn_to_page(to_addr[pgpos].sg->dma_address >> PAGE_SHIFT);
+                               pg=pfn_to_page(sg_dma_address(to_addr[pgpos].sg) >> PAGE_SHIFT);
                                kunmap_atomic(basep, KM_BOUNCE_READ);
                                basep= kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[pgpos].sg->offset;
                                oldpg=pgpos;
@@ -339,8 +345,8 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
                                for (color=0;color<4;color++) {
                                        pgpos=get_addr_pos(pos,pages,to_addr);
                                        if (pgpos!=oldpg) {
-                                               pg=pfn_to_page(to_addr[pgpos].
-                                                               sg->dma_address
+                                               pg=pfn_to_page(sg_dma_address(
+                                                               to_addr[pgpos].sg)
                                                                >> PAGE_SHIFT);
                                                kunmap_atomic(basep,
                                                                KM_BOUNCE_READ);
@@ -375,6 +381,8 @@ static void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
 
 end:
        kunmap_atomic(basep, KM_BOUNCE_READ);
+       spin_unlock_irqrestore(&spinlock,flags);
+
 }
 static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
 {
@@ -386,7 +394,7 @@ static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
        struct timeval ts;
 
        /* Test if DMA mapping is ready */
-       if (!vb->dma.sglist[0].dma_address)
+       if (!sg_dma_address(&vb->dma.sglist[0]))
                return;
 
        prep_to_addr(to_addr,vb);
@@ -534,9 +542,9 @@ static int vivi_start_thread(struct vivi_dmaqueue  *dma_q)
 
        dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi");
 
-       if (dma_q->kthread == NULL) {
+       if (IS_ERR(dma_q->kthread)) {
                printk(KERN_ERR "vivi: kernel_thread() failed\n");
-               return -EINVAL;
+               return PTR_ERR(dma_q->kthread);
        }
        dprintk(1,"returning from %s\n",__FUNCTION__);
        return 0;
@@ -783,7 +791,7 @@ static int vivi_map_sg(void *dev, struct scatterlist *sg, int nents,
        for (i = 0; i < nents; i++ ) {
                BUG_ON(!sg[i].page);
 
-               sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset;
+               sg_dma_address(&sg[i]) = page_to_phys(sg[i].page) + sg[i].offset;
        }
 
        return nents;
@@ -992,7 +1000,8 @@ static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf)
        struct vivi_fh  *fh=priv;
        struct videobuf_queue *q=&fh->vb_vidq;
        struct v4l2_requestbuffers req;
-       unsigned int i, ret;
+       unsigned int i;
+       int ret;
 
        req.type   = q->type;
        req.count  = 8;
@@ -1042,16 +1051,8 @@ static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
        return (0);
 }
 
-static struct v4l2_tvnorm tvnorms[] = {
-       {
-               .name      = "NTSC-M",
-               .id        = V4L2_STD_NTSC_M,
-       }
-};
-
-static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id a)
+static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *i)
 {
-
        return 0;
 }
 
@@ -1331,8 +1332,8 @@ static struct video_device vivi = {
 #ifdef CONFIG_VIDEO_V4L1_COMPAT
        .vidiocgmbuf          = vidiocgmbuf,
 #endif
-       .tvnorms              = tvnorms,
-       .tvnormsize           = ARRAY_SIZE(tvnorms),
+       .tvnorms              = V4L2_STD_NTSC_M,
+       .current_norm         = V4L2_STD_NTSC_M,
 };
 /* -----------------------------------------------------------------
        Initialization and module stuff
@@ -1369,7 +1370,9 @@ static void __exit vivi_exit(void)
        struct vivi_dev *h;
        struct list_head *list;
 
-       list_for_each(list,&vivi_devlist) {
+       while (!list_empty(&vivi_devlist)) {
+               list = vivi_devlist.next;
+               list_del(list);
                h = list_entry(list, struct vivi_dev, vivi_devlist);
                kfree (h);
        }