/* open the camera */ static int zr364xx_open(struct inode *inode, struct file *file) { struct video_device *vdev = video_devdata(file); struct zr364xx_camera *cam = video_get_drvdata(vdev); struct usb_device *udev = cam->udev; int i, err; DBG("zr364xx_open"); cam->skip = 2; err = video_exclusive_open(inode, file); if (err < 0) return err; if (!cam->framebuf) { cam->framebuf = vmalloc_32(MAX_FRAME_SIZE * FRAMES); if (!cam->framebuf) { info("vmalloc_32 failed!"); return -ENOMEM; } } mutex_lock(&cam->lock); for (i = 0; init[cam->method][i].size != -1; i++) { err = send_control_msg(udev, 1, init[cam->method][i].value, 0, init[cam->method][i].bytes, init[cam->method][i].size); if (err < 0) { info("error during open sequence: %d", i); mutex_unlock(&cam->lock); return err; } } file->private_data = vdev; /* Added some delay here, since opening/closing the camera quickly, * like Ekiga does during its startup, can crash the webcam */ mdelay(100); mutex_unlock(&cam->lock); return 0; }
int s3c_camif_open(struct inode *inode, struct file *file) { int err; camif_cfg_t *cfg = s3c_camif_get_fimc_object(MINOR(inode->i_rdev)); if (!cfg->cis) { printk(KERN_ERR "An object for a CIS is missing\n"); printk(KERN_ERR "Using msdma_input as a default CIS data structure\n"); cfg->cis = &msdma_input; /* global lock for both Codec and Preview */ sema_init((struct semaphore *) &cfg->cis->lock, 1); cfg->cis->status |= P_NOT_WORKING; } if (cfg->dma_type & CAMIF_PREVIEW) { if (cfg->dma_type & CAMIF_PREVIEW) cfg->cis->status &= ~P_NOT_WORKING; up((struct semaphore *) &cfg->cis->lock); } err = video_exclusive_open(inode, file); cfg->cis->user++; cfg->status = CAMIF_STOPPED; if (err < 0) return err; if (file->f_flags & O_NONCAP) { printk(KERN_ERR "Don't support non-capturing open\n"); return 0; } file->private_data = cfg; s3c_camif_init_sensor(cfg); return 0; }