static int fimc_lite_open(struct file *file) { struct fimc_lite *fimc = video_drvdata(file); int ret; if (mutex_lock_interruptible(&fimc->lock)) return -ERESTARTSYS; set_bit(ST_FLITE_IN_USE, &fimc->state); ret = pm_runtime_get_sync(&fimc->pdev->dev); if (ret < 0) goto done; ret = v4l2_fh_open(file); if (ret < 0) goto done; if (++fimc->ref_count == 1 && fimc->out_path == FIMC_IO_DMA) { ret = fimc_pipeline_call(fimc, open, &fimc->pipeline, &fimc->vfd.entity, true); if (ret < 0) { pm_runtime_put_sync(&fimc->pdev->dev); fimc->ref_count--; v4l2_fh_release(file); clear_bit(ST_FLITE_IN_USE, &fimc->state); } fimc_lite_clear_event_counters(fimc); } done: mutex_unlock(&fimc->lock); return ret; }
static int rvin_mc_open(struct file *file) { struct rvin_dev *vin = video_drvdata(file); int ret; ret = mutex_lock_interruptible(&vin->lock); if (ret) return ret; ret = pm_runtime_get_sync(vin->dev); if (ret < 0) goto err_unlock; ret = v4l2_pipeline_pm_use(&vin->vdev.entity, 1); if (ret < 0) goto err_pm; file->private_data = vin; ret = v4l2_fh_open(file); if (ret) goto err_v4l2pm; mutex_unlock(&vin->lock); return 0; err_v4l2pm: v4l2_pipeline_pm_use(&vin->vdev.entity, 0); err_pm: pm_runtime_put(vin->dev); err_unlock: mutex_unlock(&vin->lock); return ret; }
static int rvin_open(struct file *file) { struct rvin_dev *vin = video_drvdata(file); int ret; mutex_lock(&vin->lock); file->private_data = vin; ret = v4l2_fh_open(file); if (ret) goto unlock; if (!v4l2_fh_is_singular_file(file)) goto unlock; if (rvin_initialize_device(file)) { v4l2_fh_release(file); ret = -ENODEV; } unlock: mutex_unlock(&vin->lock); return ret; }
/****************************************************************************** * * cpia2_open * *****************************************************************************/ static int cpia2_open(struct file *file) { struct camera_data *cam = video_drvdata(file); int retval = v4l2_fh_open(file); if (retval) return retval; if (v4l2_fh_is_singular_file(file)) { if (cpia2_allocate_buffers(cam)) { v4l2_fh_release(file); return -ENOMEM; } /* reset the camera */ if (cpia2_reset_camera(cam) < 0) { v4l2_fh_release(file); return -EIO; } cam->APP_len = 0; cam->COM_len = 0; } cpia2_dbg_dump_registers(cam); return 0; }
/****************************************************************************** * * cpia2_open * *****************************************************************************/ static int cpia2_open(struct file *file) { struct camera_data *cam = video_drvdata(file); int retval; if (mutex_lock_interruptible(&cam->v4l2_lock)) return -ERESTARTSYS; retval = v4l2_fh_open(file); if (retval) goto open_unlock; if (v4l2_fh_is_singular_file(file)) { if (cpia2_allocate_buffers(cam)) { v4l2_fh_release(file); retval = -ENOMEM; goto open_unlock; } /* reset the camera */ if (cpia2_reset_camera(cam) < 0) { v4l2_fh_release(file); retval = -EIO; goto open_unlock; } cam->APP_len = 0; cam->COM_len = 0; } cpia2_dbg_dump_registers(cam); open_unlock: mutex_unlock(&cam->v4l2_lock); return retval; }
static int fimc_lite_open(struct file *file) { struct fimc_lite *fimc = video_drvdata(file); struct media_entity *me = &fimc->ve.vdev.entity; int ret; mutex_lock(&fimc->lock); if (atomic_read(&fimc->out_path) != FIMC_IO_DMA) { ret = -EBUSY; goto unlock; } set_bit(ST_FLITE_IN_USE, &fimc->state); ret = pm_runtime_get_sync(&fimc->pdev->dev); if (ret < 0) goto unlock; ret = v4l2_fh_open(file); if (ret < 0) goto err_pm; if (!v4l2_fh_is_singular_file(file) || atomic_read(&fimc->out_path) != FIMC_IO_DMA) goto unlock; mutex_lock(&me->parent->graph_mutex); ret = fimc_pipeline_call(&fimc->ve, open, me, true); /* Mark video pipeline ending at this video node as in use. */ if (ret == 0) me->use_count++; mutex_unlock(&me->parent->graph_mutex); if (!ret) { fimc_lite_clear_event_counters(fimc); goto unlock; } v4l2_fh_release(file); err_pm: pm_runtime_put_sync(&fimc->pdev->dev); clear_bit(ST_FLITE_IN_USE, &fimc->state); unlock: mutex_unlock(&fimc->lock); return ret; }
static int fimc_capture_open(struct file *file) { struct fimc_dev *fimc = video_drvdata(file); int ret = -EBUSY; dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); if (mutex_lock_interruptible(&fimc->lock)) return -ERESTARTSYS; if (fimc_m2m_active(fimc)) goto unlock; set_bit(ST_CAPT_BUSY, &fimc->state); ret = pm_runtime_get_sync(&fimc->pdev->dev); if (ret < 0) goto unlock; ret = v4l2_fh_open(file); if (ret) { pm_runtime_put(&fimc->pdev->dev); goto unlock; } if (++fimc->vid_cap.refcnt == 1) { ret = fimc_pipeline_call(fimc, open, &fimc->pipeline, &fimc->vid_cap.vfd.entity, true); if (!ret && !fimc->vid_cap.user_subdev_api) ret = fimc_capture_set_default_format(fimc); if (!ret) ret = fimc_capture_ctrls_create(fimc); if (ret < 0) { clear_bit(ST_CAPT_BUSY, &fimc->state); pm_runtime_put_sync(&fimc->pdev->dev); fimc->vid_cap.refcnt--; v4l2_fh_release(file); } } unlock: mutex_unlock(&fimc->lock); return ret; }
static int gsc_capture_open(struct file *file) { struct gsc_dev *gsc = video_drvdata(file); int ret = v4l2_fh_open(file); if (ret) return ret; if (gsc_m2m_opened(gsc) || gsc_out_opened(gsc) || gsc_cap_opened(gsc)) { v4l2_fh_release(file); return -EBUSY; } set_bit(ST_CAPT_OPEN, &gsc->state); pm_runtime_get_sync(&gsc->pdev->dev); if (++gsc->cap.refcnt == 1) { ret = gsc_cap_pipeline_initialize(gsc, &gsc->cap.vfd->entity, true); if (ret < 0) { gsc_err("gsc pipeline initialization failed\n"); goto err; } ret = gsc_capture_ctrls_create(gsc); if (ret) { gsc_err("failed to create controls\n"); goto err; } } gsc_dbg("pid: %d, state: 0x%lx", task_pid_nr(current), gsc->state); return 0; err: pm_runtime_put_sync(&gsc->pdev->dev); v4l2_fh_release(file); clear_bit(ST_CAPT_OPEN, &gsc->state); return ret; }
static int isp_video_open(struct file *file) { struct fimc_isp *isp = video_drvdata(file); struct exynos_video_entity *ve = &isp->video_capture.ve; struct media_entity *me = &ve->vdev.entity; int ret; if (mutex_lock_interruptible(&isp->video_lock)) return -ERESTARTSYS; ret = v4l2_fh_open(file); if (ret < 0) goto unlock; ret = pm_runtime_get_sync(&isp->pdev->dev); if (ret < 0) goto rel_fh; if (v4l2_fh_is_singular_file(file)) { mutex_lock(&me->graph_obj.mdev->graph_mutex); ret = fimc_pipeline_call(ve, open, me, true); /* Mark the video pipeline as in use. */ if (ret == 0) me->use_count++; mutex_unlock(&me->graph_obj.mdev->graph_mutex); } if (!ret) goto unlock; rel_fh: v4l2_fh_release(file); unlock: mutex_unlock(&isp->video_lock); return ret; }
static int mxr_video_open(struct file *file) { struct mxr_layer *layer = video_drvdata(file); struct mxr_device *mdev = layer->mdev; int ret = 0; mxr_dbg(mdev, "%s:%d\n", __func__, __LINE__); /* assure device probe is finished */ wait_for_device_probe(); /* creating context for file descriptor */ ret = v4l2_fh_open(file); if (ret) { mxr_err(mdev, "v4l2_fh_open failed\n"); return ret; } /* leaving if layer is already initialized */ if (!v4l2_fh_is_singular_file(file)) return 0; ret = vb2_queue_init(&layer->vb_queue); if (ret != 0) { mxr_err(mdev, "failed to initialize vb2 queue\n"); goto fail_fh_open; } /* set default format, first on the list */ layer->fmt = layer->fmt_array[0]; /* setup default geometry */ mxr_layer_default_geo(layer); return 0; fail_fh_open: v4l2_fh_release(file); return ret; }
static int fimc_capture_open(struct file *file) { struct fimc_dev *fimc = video_drvdata(file); int ret = v4l2_fh_open(file); if (ret) return ret; dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state); /* Return if the corresponding video mem2mem node is already opened. */ if (fimc_m2m_active(fimc)) return -EBUSY; set_bit(ST_CAPT_BUSY, &fimc->state); pm_runtime_get_sync(&fimc->pdev->dev); if (++fimc->vid_cap.refcnt == 1) { ret = fimc_pipeline_initialize(fimc, &fimc->vid_cap.vfd->entity, true); if (ret < 0) { dev_err(&fimc->pdev->dev, "Video pipeline initialization failed\n"); pm_runtime_put_sync(&fimc->pdev->dev); fimc->vid_cap.refcnt--; v4l2_fh_release(file); clear_bit(ST_CAPT_BUSY, &fimc->state); return ret; } ret = fimc_capture_ctrls_create(fimc); if (!ret && !fimc->vid_cap.user_subdev_api) ret = fimc_capture_set_default_format(fimc); } return ret; }
int si470x_fops_open(struct file *file) { return v4l2_fh_open(file); }