-#define line_buf_size(norm) (norm_maxw(norm)*(format.depth+7)/8)
-
-static int vivi_open(struct inode *inode, struct file *file)
-{
- int minor = iminor(inode);
- struct vivi_dev *h,*dev = NULL;
- struct vivi_fh *fh;
- struct list_head *list;
- enum v4l2_buf_type type = 0;
- int i;
-
- printk(KERN_DEBUG "vivi: open called (minor=%d)\n",minor);
-
- list_for_each(list,&vivi_devlist) {
- h = list_entry(list, struct vivi_dev, vivi_devlist);
- if (h->vfd.minor == minor) {
- dev = h;
- type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- }
- }
- if (NULL == dev)
- return -ENODEV;
-
-
-
- /* If more than one user, mutex should be added */
- dev->users++;
-
- dprintk(1,"open minor=%d type=%s users=%d\n",
- minor,v4l2_type_names[type],dev->users);
-
- /* allocate + initialize per filehandle data */
- fh = kzalloc(sizeof(*fh),GFP_KERNEL);
- if (NULL == fh) {
- dev->users--;
- return -ENOMEM;
- }
-
- file->private_data = fh;
- fh->dev = dev;
-
- fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- fh->fmt = &format;
- fh->width = 640;
- fh->height = 480;
-
- /* Put all controls at a sane state */
- for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
- qctl_regs[i] =vivi_qctrl[i].default_value;
-
- dprintk(1,"Open: fh=0x%08lx, dev=0x%08lx, dev->vidq=0x%08lx\n",
- (unsigned long)fh,(unsigned long)dev,(unsigned long)&dev->vidq);
- dprintk(1,"Open: list_empty queued=%d\n",list_empty(&dev->vidq.queued));
- dprintk(1,"Open: list_empty active=%d\n",list_empty(&dev->vidq.active));
-
- /* Resets frame counters */
- dev->h=0;
- dev->m=0;
- dev->s=0;
- dev->us=0;
- dev->jiffies=jiffies;
- sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
- dev->h,dev->m,dev->s,(dev->us+500)/1000);
-
- videobuf_queue_init(&fh->vb_vidq, &vivi_video_qops,
- NULL, NULL,
- fh->type,
- V4L2_FIELD_INTERLACED,
- sizeof(struct vivi_buffer),fh);
-
- return 0;
-}
-