您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ v4l2_fh_add函数代码示例

51自学网 2021-06-03 09:29:39
  C++
这篇教程C++ v4l2_fh_add函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中v4l2_fh_add函数的典型用法代码示例。如果您正苦于以下问题:C++ v4l2_fh_add函数的具体用法?C++ v4l2_fh_add怎么用?C++ v4l2_fh_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了v4l2_fh_add函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: camera_v4l2_fh_open

static int camera_v4l2_fh_open(struct file *filep){	struct msm_video_device *pvdev = video_drvdata(filep);	struct camera_v4l2_private *sp;	unsigned int stream_id;	sp = kzalloc(sizeof(*sp), GFP_KERNEL);	if (!sp) {		pr_err("%s : memory not available/n", __func__);		return -ENOMEM;	}	filep->private_data = &sp->fh;	/* stream_id = open id */	stream_id = atomic_read(&pvdev->opened);	sp->stream_id = find_first_zero_bit(		(const unsigned long *)&stream_id, MSM_CAMERA_STREAM_CNT_BITS);	pr_debug("%s: Found stream_id=%d/n", __func__, sp->stream_id);	v4l2_fh_init(&sp->fh, pvdev->vdev);	v4l2_fh_add(&sp->fh);	return 0;}
开发者ID:LEPT-Development,项目名称:Android_kernel_lge_C50,代码行数:25,


示例2: hwcam_cfgstream_create_instance

static hwcam_cfgstream_t*hwcam_cfgstream_create_instance(        hwcam_cfgstream_mount_req_t* req){    hwcam_cfgstream_t* stm = kzalloc(            sizeof(hwcam_cfgstream_t), GFP_KERNEL);    if (stm == NULL) {        return NULL;    }    stm->intf.vtbl = &s_vtbl_cfgstream;    kref_init(&stm->ref);	v4l2_fh_init(&stm->rq, req->vdev);    v4l2_fh_add(&stm->rq);    stm->pipeline = req->pl;    hwcam_cfgpipeline_intf_get(stm->pipeline);    stm->user = req->user;    hwcam_user_intf_get(stm->user);    INIT_LIST_HEAD(&stm->bufq_idle);    INIT_LIST_HEAD(&stm->bufq_busy);    spin_lock_init(&stm->lock_bufq);    HWCAM_CFG_INFO("instance(0x%p). /n", stm);    return stm;}
开发者ID:herryfan,项目名称:kernel-huawei-h60,代码行数:28,


示例3: vpfe_open

/* * vpfe_open() - open video device * @file: file pointer * * initialize media pipeline state, allocate memory for file handle * * Return 0 if successful, or the return -ENODEV otherwise. */static int vpfe_open(struct file *file){	struct vpfe_video_device *video = video_drvdata(file);	struct vpfe_fh *handle;	/* Allocate memory for the file handle object */	handle = kzalloc(sizeof(struct vpfe_fh), GFP_KERNEL);	if (handle == NULL)		return -ENOMEM;	v4l2_fh_init(&handle->vfh, &video->video_dev);	v4l2_fh_add(&handle->vfh);	mutex_lock(&video->lock);	/* If decoder is not initialized. initialize it */	if (!video->initialized && vpfe_update_pipe_state(video)) {		mutex_unlock(&video->lock);		return -ENODEV;	}	/* Increment device users counter */	video->usrs++;	/* Set io_allowed member to false */	handle->io_allowed = 0;	handle->video = video;	file->private_data = &handle->vfh;	mutex_unlock(&video->lock);	return 0;}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:38,


示例4: g2d_open

static int g2d_open(struct file *file){    struct g2d_dev *dev = video_drvdata(file);    struct g2d_ctx *ctx = NULL;    int ret = 0;    ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);    if (!ctx)        return -ENOMEM;    ctx->dev = dev;    /* Set default formats */    ctx->in		= def_frame;    ctx->out	= def_frame;    ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);    if (IS_ERR(ctx->m2m_ctx)) {        ret = PTR_ERR(ctx->m2m_ctx);        kfree(ctx);        return ret;    }    v4l2_fh_init(&ctx->fh, video_devdata(file));    file->private_data = &ctx->fh;    v4l2_fh_add(&ctx->fh);    g2d_setup_ctrls(ctx);    /* Write the default values to the ctx struct */    v4l2_ctrl_handler_setup(&ctx->ctrl_handler);    ctx->fh.ctrl_handler = &ctx->ctrl_handler;    v4l2_info(&dev->v4l2_dev, "instance opened/n");    return 0;}
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:34,


示例5: gsc_m2m_open

static int gsc_m2m_open(struct file *file){	struct gsc_dev *gsc = video_drvdata(file);	struct gsc_ctx *ctx = NULL;	int ret;	gsc_dbg("pid: %d, state: 0x%lx", task_pid_nr(current), gsc->state);	if (gsc_out_opened(gsc) || gsc_cap_opened(gsc))		return -EBUSY;	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);	if (!ctx)		return -ENOMEM;	v4l2_fh_init(&ctx->fh, gsc->m2m.vfd);	ret = gsc_ctrls_create(ctx);	if (ret)		goto error_fh;	/* Use separate control handler per file handle */	ctx->fh.ctrl_handler = &ctx->ctrl_handler;	file->private_data = &ctx->fh;	v4l2_fh_add(&ctx->fh);	ctx->gsc_dev = gsc;	/* Default color format */	ctx->s_frame.fmt = get_format(0);	ctx->d_frame.fmt = get_format(0);	/* Setup the device context for mem2mem mode. */	ctx->state |= GSC_CTX_M2M;	ctx->flags = 0;	ctx->in_path = GSC_DMA;	ctx->out_path = GSC_DMA;	spin_lock_init(&ctx->slock);	INIT_LIST_HEAD(&ctx->fence_wait_list);	INIT_WORK(&ctx->fence_work, gsc_m2m_fence_work);	ctx->m2m_ctx = v4l2_m2m_ctx_init(gsc->m2m.m2m_dev, ctx, queue_init);	if (IS_ERR(ctx->m2m_ctx)) {		gsc_err("Failed to initialize m2m context");		ret = PTR_ERR(ctx->m2m_ctx);		goto error_fh;	}	if (gsc->m2m.refcnt++ == 0)		set_bit(ST_M2M_OPEN, &gsc->state);	gsc_dbg("gsc m2m driver is opened, ctx(0x%p)", ctx);	return 0;error_fh:	v4l2_fh_del(&ctx->fh);	v4l2_fh_exit(&ctx->fh);	kfree(ctx);	return ret;}
开发者ID:awehoky,项目名称:Googy-Max-N4-Kernel,代码行数:59,


示例6: rockchip_vpu_open

static int rockchip_vpu_open(struct file *filp){	struct rockchip_vpu_dev *vpu = video_drvdata(filp);	struct video_device *vdev = video_devdata(filp);	struct rockchip_vpu_ctx *ctx;	int ret;	/*	 * We do not need any extra locking here, because we operate only	 * on local data here, except reading few fields from dev, which	 * do not change through device's lifetime (which is guaranteed by	 * reference on module from open()) and V4L2 internal objects (such	 * as vdev and ctx->fh), which have proper locking done in respective	 * helper functions used here.	 */	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);	if (!ctx)		return -ENOMEM;	ctx->dev = vpu;	if (vdev == vpu->vfd_enc)		ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(vpu->m2m_dev, ctx,						    &enc_queue_init);	else		ctx->fh.m2m_ctx = ERR_PTR(-ENODEV);	if (IS_ERR(ctx->fh.m2m_ctx)) {		ret = PTR_ERR(ctx->fh.m2m_ctx);		kfree(ctx);		return ret;	}	v4l2_fh_init(&ctx->fh, vdev);	filp->private_data = &ctx->fh;	v4l2_fh_add(&ctx->fh);	if (vdev == vpu->vfd_enc) {		rockchip_vpu_enc_reset_dst_fmt(vpu, ctx);		rockchip_vpu_enc_reset_src_fmt(vpu, ctx);	}	ret = rockchip_vpu_ctrls_setup(vpu, ctx);	if (ret) {		vpu_err("Failed to set up controls/n");		goto err_fh_free;	}	ctx->fh.ctrl_handler = &ctx->ctrl_handler;	return 0;err_fh_free:	v4l2_fh_del(&ctx->fh);	v4l2_fh_exit(&ctx->fh);	kfree(ctx);	return ret;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:56,


示例7: s5p_jpeg_open

static int s5p_jpeg_open(struct file *file){	struct s5p_jpeg *jpeg = video_drvdata(file);	struct video_device *vfd = video_devdata(file);	struct s5p_jpeg_ctx *ctx;	struct s5p_jpeg_fmt *out_fmt;	int ret = 0;	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);	if (!ctx)		return -ENOMEM;	if (mutex_lock_interruptible(&jpeg->lock)) {		ret = -ERESTARTSYS;		goto free;	}	v4l2_fh_init(&ctx->fh, vfd);	/* Use separate control handler per file handle */	ctx->fh.ctrl_handler = &ctx->ctrl_handler;	file->private_data = &ctx->fh;	v4l2_fh_add(&ctx->fh);	ctx->jpeg = jpeg;	if (vfd == jpeg->vfd_encoder) {		ctx->mode = S5P_JPEG_ENCODE;		out_fmt = s5p_jpeg_find_format(ctx->mode, V4L2_PIX_FMT_RGB565);	} else {		ctx->mode = S5P_JPEG_DECODE;		out_fmt = s5p_jpeg_find_format(ctx->mode, V4L2_PIX_FMT_JPEG);	}	ret = s5p_jpeg_controls_create(ctx);	if (ret < 0)		goto error;	ctx->m2m_ctx = v4l2_m2m_ctx_init(jpeg->m2m_dev, ctx, queue_init);	if (IS_ERR(ctx->m2m_ctx)) {		ret = PTR_ERR(ctx->m2m_ctx);		goto error;	}	ctx->out_q.fmt = out_fmt;	ctx->cap_q.fmt = s5p_jpeg_find_format(ctx->mode, V4L2_PIX_FMT_YUYV);	mutex_unlock(&jpeg->lock);	return 0;error:	v4l2_fh_del(&ctx->fh);	v4l2_fh_exit(&ctx->fh);	mutex_unlock(&jpeg->lock);free:	kfree(ctx);	return ret;}
开发者ID:AeroGirl,项目名称:VAR-SOM-AM33-SDK7-Kernel,代码行数:55,


示例8: v4l2_fh_open

int v4l2_fh_open(struct file *filp){	struct video_device *vdev = video_devdata(filp);	struct v4l2_fh *fh = kzalloc(sizeof(*fh), GFP_KERNEL);	filp->private_data = fh;	if (fh == NULL)		return -ENOMEM;	v4l2_fh_init(fh, vdev);	v4l2_fh_add(fh);	return 0;}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:12,


示例9: subdev_open

static int subdev_open(struct file *file){    struct video_device *vdev = video_devdata(file);    struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);    struct v4l2_subdev_fh *subdev_fh;#if defined(CONFIG_MEDIA_CONTROLLER)    struct media_entity *entity = NULL;#endif    int ret;    subdev_fh = kzalloc(sizeof(*subdev_fh), GFP_KERNEL);    if (subdev_fh == NULL)        return -ENOMEM;    ret = subdev_fh_init(subdev_fh, sd);    if (ret) {        kfree(subdev_fh);        return ret;    }    v4l2_fh_init(&subdev_fh->vfh, vdev);    v4l2_fh_add(&subdev_fh->vfh);    file->private_data = &subdev_fh->vfh;#if defined(CONFIG_MEDIA_CONTROLLER)    if (sd->v4l2_dev->mdev) {        entity = media_entity_get(&sd->entity);        if (!entity) {            ret = -EBUSY;            goto err;        }    }#endif    if (sd->internal_ops && sd->internal_ops->open) {        ret = sd->internal_ops->open(sd, subdev_fh);        if (ret < 0)            goto err;    }    return 0;err:#if defined(CONFIG_MEDIA_CONTROLLER)    if (entity)        media_entity_put(entity);#endif    v4l2_fh_del(&subdev_fh->vfh);    v4l2_fh_exit(&subdev_fh->vfh);    subdev_fh_free(subdev_fh);    kfree(subdev_fh);    return ret;}
开发者ID:Yemege,项目名称:kernel-zynq,代码行数:53,


示例10: xvip_dma_open

static int xvip_dma_open(struct file *file){	struct xvip_dma *dma = video_drvdata(file);	struct v4l2_fh *vfh;	vfh = kzalloc(sizeof(*vfh), GFP_KERNEL);	if (vfh == NULL)		return -ENOMEM;	v4l2_fh_init(vfh, &dma->video);	v4l2_fh_add(vfh);	file->private_data = vfh;	return 0;}
开发者ID:bmouring,项目名称:linux-xlnx,代码行数:16,


示例11: camera_v4l2_fh_open

static int camera_v4l2_fh_open(struct file *filep){	struct msm_video_device *pvdev = video_drvdata(filep);	struct camera_v4l2_private *sp;	sp = kzalloc(sizeof(*sp), GFP_KERNEL);	if (!sp)		return -ENOMEM;	filep->private_data = &sp->fh;	/* stream_id = open id */	sp->stream_id = atomic_read(&pvdev->stream_cnt);	v4l2_fh_init(&sp->fh, pvdev->vdev);	v4l2_fh_add(&sp->fh);	return 0;}
开发者ID:TheRealTruth,项目名称:LGLS995_Gflex_Kikat_ZV9_Kernel,代码行数:19,


示例12: uvc_v4l2_open

static intuvc_v4l2_open(struct file *file){	struct video_device *vdev = video_devdata(file);	struct uvc_device *uvc = video_get_drvdata(vdev);	struct uvc_file_handle *handle;	handle = kzalloc(sizeof(*handle), GFP_KERNEL);	if (handle == NULL)		return -ENOMEM;	v4l2_fh_init(&handle->vfh, vdev);	v4l2_fh_add(&handle->vfh);	handle->device = &uvc->video;	file->private_data = &handle->vfh;	uvc_function_connect(uvc);	return 0;}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:20,


示例13: hwcam_user_create_instance

static hwcam_user_t*hwcam_user_create_instance(        hwcam_dev_t* cam){	int ret = 0;	hwcam_user_t* user;	if(!cam){		return NULL;	}	user = kzalloc(sizeof(hwcam_user_t), GFP_KERNEL);	if (!user) {		return NULL;    }    user->intf.vtbl = &s_vtbl_hwcam_user;    kref_init(&user->ref);	v4l2_fh_init(&user->eq, cam->vdev);	v4l2_fh_add(&user->eq);    user->f_format_valid = 0;    memset(&user->format, 0, sizeof(user->format));    user->vb2q.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;    user->vb2q.ops = &s_qops_hwcam_vbuf;    user->vb2q.mem_ops = &s_mops_hwcam_vbuf;    user->vb2q.io_modes = VB2_USERPTR;    user->vb2q.io_flags = 0;    user->vb2q.buf_struct_size = sizeof(hwcam_vbuf_t);    user->vb2q.drv_priv = user;    user->vb2q.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;//add by wind    ret = vb2_queue_init(&user->vb2q);    if(ret)    {        HWCAM_CFG_ERR("queue init fail./n");	 return NULL;    }    HWCAM_CFG_INFO("instance(0x%p). /n", user);    return user;}
开发者ID:herryfan,项目名称:kernel-huawei-h60,代码行数:41,


示例14: camera_v4l2_fh_open

static int camera_v4l2_fh_open(struct file *filep){	struct msm_video_device *pvdev = video_drvdata(filep);	struct camera_v4l2_private *sp;	sp = kzalloc(sizeof(*sp), GFP_KERNEL);	if (!sp) {	    pr_err("%s : memory not available/n", __FUNCTION__);	    return -ENOMEM;	}	filep->private_data = &sp->fh;	/* stream_id = open id */	sp->stream_id = atomic_read(&pvdev->opened);	v4l2_fh_init(&sp->fh, pvdev->vdev);	v4l2_fh_add(&sp->fh);	return 0;}
开发者ID:AndroidGX,项目名称:SimpleGX-L-5.0.2_BOE2_G901F,代码行数:21,


示例15: video_open

static int video_open(struct file *file){	struct video_device *vdev = video_devdata(file);	struct camss_video *video = video_drvdata(file);	struct v4l2_fh *vfh;	int ret;	mutex_lock(&video->lock);	vfh = kzalloc(sizeof(*vfh), GFP_KERNEL);	if (vfh == NULL) {		ret = -ENOMEM;		goto error_alloc;	}	v4l2_fh_init(vfh, vdev);	v4l2_fh_add(vfh);	file->private_data = vfh;	ret = v4l2_pipeline_pm_use(&vdev->entity, 1);	if (ret < 0) {		dev_err(video->camss->dev, "Failed to power up pipeline: %d/n",			ret);		goto error_pm_use;	}	mutex_unlock(&video->lock);	return 0;error_pm_use:	v4l2_fh_release(file);error_alloc:	mutex_unlock(&video->lock);	return ret;}
开发者ID:ReneNyffenegger,项目名称:linux,代码行数:39,


示例16: subdev_open

static int subdev_open(struct file *file){	struct video_device *vdev = video_devdata(file);	struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);	struct v4l2_subdev_fh *subdev_fh;#if defined(CONFIG_MEDIA_CONTROLLER)	struct media_entity *entity = NULL;#endif	int ret;	if (!sd->initialized)		return -EAGAIN;	subdev_fh = kzalloc(sizeof(*subdev_fh), GFP_KERNEL);	if (subdev_fh == NULL)		return -ENOMEM;	ret = subdev_fh_init(subdev_fh, sd);	if (ret) {		kfree(subdev_fh);		return ret;	}	ret = v4l2_fh_init(&subdev_fh->vfh, vdev);	if (ret)		goto err;	if (sd->flags & V4L2_SUBDEV_FL_HAS_EVENTS) {		ret = v4l2_event_init(&subdev_fh->vfh);		if (ret)			goto err;		ret = v4l2_event_alloc(&subdev_fh->vfh, sd->nevents);		if (ret)			goto err;	}	v4l2_fh_add(&subdev_fh->vfh);	file->private_data = &subdev_fh->vfh;#if defined(CONFIG_MEDIA_CONTROLLER)	if (sd->v4l2_dev->mdev) {		entity = media_entity_get(&sd->entity);		if (!entity) {			ret = -EBUSY;			goto err;		}	}#endif	ret = v4l2_subdev_call(sd, file, open, subdev_fh);	if (ret < 0 && ret != -ENOIOCTLCMD)		goto err;	return 0;err:#if defined(CONFIG_MEDIA_CONTROLLER)	if (entity)		media_entity_put(entity);#endif	v4l2_fh_del(&subdev_fh->vfh);	v4l2_fh_exit(&subdev_fh->vfh);	subdev_fh_free(subdev_fh);	kfree(subdev_fh);	return ret;}
开发者ID:jmw7912,项目名称:wat-0016-kernel-2.6.37,代码行数:67,


示例17: gsc_m2m_open

static int gsc_m2m_open(struct file *file){	struct gsc_dev *gsc = video_drvdata(file);	struct gsc_ctx *ctx = NULL;	int ret;	pr_debug("pid: %d, state: 0x%lx", task_pid_nr(current), gsc->state);	if (mutex_lock_interruptible(&gsc->lock))		return -ERESTARTSYS;	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);	if (!ctx) {		ret = -ENOMEM;		goto unlock;	}	v4l2_fh_init(&ctx->fh, gsc->m2m.vfd);	ret = gsc_ctrls_create(ctx);	if (ret)		goto error_fh;	/* Use separate control handler per file handle */	ctx->fh.ctrl_handler = &ctx->ctrl_handler;	file->private_data = &ctx->fh;	v4l2_fh_add(&ctx->fh);	ctx->gsc_dev = gsc;	/* Default color format */	ctx->s_frame.fmt = get_format(0);	ctx->d_frame.fmt = get_format(0);	/* Setup the device context for mem2mem mode. */	ctx->state = GSC_CTX_M2M;	ctx->flags = 0;	ctx->in_path = GSC_DMA;	ctx->out_path = GSC_DMA;	ctx->m2m_ctx = v4l2_m2m_ctx_init(gsc->m2m.m2m_dev, ctx, queue_init);	if (IS_ERR(ctx->m2m_ctx)) {		pr_err("Failed to initialize m2m context");		ret = PTR_ERR(ctx->m2m_ctx);		goto error_ctrls;	}	if (gsc->m2m.refcnt++ == 0)		set_bit(ST_M2M_OPEN, &gsc->state);	pr_debug("gsc m2m driver is opened, ctx(0x%p)", ctx);	mutex_unlock(&gsc->lock);	return 0;error_ctrls:	gsc_ctrls_delete(ctx);	v4l2_fh_del(&ctx->fh);error_fh:	v4l2_fh_exit(&ctx->fh);	kfree(ctx);unlock:	mutex_unlock(&gsc->lock);	return ret;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:62,


示例18: fimc_m2m_open

static int fimc_m2m_open(struct file *file){    struct fimc_dev *fimc = video_drvdata(file);    struct fimc_ctx *ctx;    int ret = -EBUSY;    pr_debug("pid: %d, state: %#lx/n", task_pid_nr(current), fimc->state);    if (mutex_lock_interruptible(&fimc->lock))        return -ERESTARTSYS;    /*     * Don't allow simultaneous open() of the mem-to-mem and the     * capture video node that belong to same FIMC IP instance.     */    if (test_bit(ST_CAPT_BUSY, &fimc->state))        goto unlock;    ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);    if (!ctx) {        ret = -ENOMEM;        goto unlock;    }    v4l2_fh_init(&ctx->fh, &fimc->m2m.vfd);    ctx->fimc_dev = fimc;    /* Default color format */    ctx->s_frame.fmt = fimc_get_format(0);    ctx->d_frame.fmt = fimc_get_format(0);    ret = fimc_ctrls_create(ctx);    if (ret)        goto error_fh;    /* Use separate control handler per file handle */    ctx->fh.ctrl_handler = &ctx->ctrls.handler;    file->private_data = &ctx->fh;    v4l2_fh_add(&ctx->fh);    /* Setup the device context for memory-to-memory mode */    ctx->state = FIMC_CTX_M2M;    ctx->flags = 0;    ctx->in_path = FIMC_IO_DMA;    ctx->out_path = FIMC_IO_DMA;    ctx->scaler.enabled = 1;    ctx->m2m_ctx = v4l2_m2m_ctx_init(fimc->m2m.m2m_dev, ctx, queue_init);    if (IS_ERR(ctx->m2m_ctx)) {        ret = PTR_ERR(ctx->m2m_ctx);        goto error_c;    }    if (fimc->m2m.refcnt++ == 0)        set_bit(ST_M2M_RUN, &fimc->state);    ret = fimc_m2m_set_default_format(ctx);    if (ret < 0)        goto error_m2m_ctx;    mutex_unlock(&fimc->lock);    return 0;error_m2m_ctx:    v4l2_m2m_ctx_release(ctx->m2m_ctx);error_c:    fimc_ctrls_delete(ctx);error_fh:    v4l2_fh_del(&ctx->fh);    v4l2_fh_exit(&ctx->fh);    kfree(ctx);unlock:    mutex_unlock(&fimc->lock);    return ret;}
开发者ID:Niisp,项目名称:MT6795.kernel,代码行数:73,


示例19: isp_video_open

static int isp_video_open(struct file *file){	struct isp_video *video = video_drvdata(file);	struct isp_video_fh *handle;	struct media_entity_pad *pad;	int ret = 0;	handle = kzalloc(sizeof(*handle), GFP_KERNEL);	if (handle == NULL)		return -ENOMEM;	v4l2_fh_init(&handle->vfh, &video->video);	v4l2_fh_add(&handle->vfh);	/* If this is the first user, initialise the pipeline. */	if (atomic_inc_return(&video->users) == 1) {		if (isp_get(video->isp) == NULL) {			ret = -EBUSY;			goto done;		}	}	isp_video_queue_init(&handle->queue, video->type, &isp_video_queue_ops,			     video->isp->dev, sizeof(struct isp_buffer));	memset(&handle->format, 0, sizeof(handle->format));	handle->format.type = video->type;	handle->timeperframe.denominator = 1;	/* If a subdev is linked to this dev, then initialize the	   format to match the subdev. */	pad = media_entity_remote_pad(&video->pad);	if(pad && pad->entity->type == MEDIA_ENTITY_TYPE_SUBDEV) {		struct v4l2_subdev *subdev;		struct v4l2_mbus_framefmt fmt_source;		struct v4l2_subdev_frame_interval fi;		int err;		subdev = media_entity_to_v4l2_subdev(pad->entity);		err = v4l2_subdev_call(subdev, pad, get_fmt, NULL, pad->index,				       &fmt_source, V4L2_SUBDEV_FORMAT_ACTIVE);		if(err >= 0) {			isp_video_mbus_to_pix(video, &fmt_source, &(handle->format.fmt.pix));			handle->format.fmt.pix.width = fmt_source.width;			handle->format.fmt.pix.height= fmt_source.height;		}		err = __find_timeperframe(pad, subdev, &fi, 0);		if(err >= 0) {			handle->timeperframe.numerator = fi.interval.numerator;			handle->timeperframe.denominator = fi.interval.denominator;		}	}	handle->video = video;	file->private_data = &handle->vfh;done:	if (ret < 0) {		v4l2_fh_del(&handle->vfh);		atomic_dec(&video->users);		kfree(handle);	}	return ret;}
开发者ID:mgrundy,项目名称:bug20-2.6.35-linaro,代码行数:65,


示例20: msm_fd_open

/* * msm_fd_open - Fd device open method. * @file: Pointer to file struct. */static int msm_fd_open(struct file *file){	struct msm_fd_device *device = video_drvdata(file);	struct video_device *video = video_devdata(file);	struct fd_ctx *ctx;	int ret;	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);	if (!ctx)		return -ENOMEM;	ctx->fd_device = device;	/* Initialize work buffer handler */	ctx->work_buf.pool = NULL;	ctx->work_buf.fd = -1;	/* Set ctx defaults */	ctx->settings.speed = ctx->fd_device->clk_rates_num;	ctx->settings.angle_index = MSM_FD_DEF_ANGLE_IDX;	ctx->settings.direction_index = MSM_FD_DEF_DIR_IDX;	ctx->settings.min_size_index = MSM_FD_DEF_MIN_SIZE_IDX;	ctx->settings.threshold = MSM_FD_DEF_THRESHOLD;	atomic_set(&ctx->subscribed_for_event, 0);	v4l2_fh_init(&ctx->fh, video);	file->private_data = &ctx->fh;	v4l2_fh_add(&ctx->fh);	ctx->vb2_q.drv_priv = ctx;	ctx->vb2_q.mem_ops = &msm_fd_vb2_mem_ops;	ctx->vb2_q.ops = &msm_fd_vb2_q_ops;	ctx->vb2_q.buf_struct_size = sizeof(struct msm_fd_buffer);	ctx->vb2_q.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;	ctx->vb2_q.io_modes = VB2_USERPTR;	ctx->vb2_q.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY;	ret = vb2_queue_init(&ctx->vb2_q);	if (ret < 0) {		dev_err(device->dev, "Error queue init/n");		goto error_vb2_queue_init;	}	ctx->mem_pool.client = msm_ion_client_create(MSM_FD_DRV_NAME);	if (IS_ERR_OR_NULL(ctx->mem_pool.client)) {		dev_err(device->dev, "Error ion client create/n");		goto error_ion_client_create;	}	ctx->mem_pool.domain_num = ctx->fd_device->iommu_domain_num;	ret = iommu_attach_device(ctx->fd_device->iommu_domain,		ctx->fd_device->iommu_dev);	if (ret) {		dev_err(device->dev, "Can not attach iommu domain/n");		goto error_iommu_attach;	}	ctx->stats = vmalloc(sizeof(*ctx->stats) * MSM_FD_MAX_RESULT_BUFS);	if (!ctx->stats) {		dev_err(device->dev, "No memory for face statistics/n");		ret = -ENOMEM;		goto error_stats_vmalloc;	}	return 0;error_stats_vmalloc:	iommu_detach_device(ctx->fd_device->iommu_domain,			ctx->fd_device->iommu_dev);error_iommu_attach:	ion_client_destroy(ctx->mem_pool.client);error_ion_client_create:	vb2_queue_release(&ctx->vb2_q);error_vb2_queue_init:	v4l2_fh_del(&ctx->fh);	v4l2_fh_exit(&ctx->fh);	kfree(ctx);	return ret;}
开发者ID:Skin1980,项目名称:bass-MM,代码行数:84,


示例21: hva_open

static int hva_open(struct file *file){	struct hva_dev *hva = video_drvdata(file);	struct device *dev = hva_to_dev(hva);	struct hva_ctx *ctx;	int ret;	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);	if (!ctx) {		ret = -ENOMEM;		goto out;	}	ctx->hva_dev = hva;	INIT_WORK(&ctx->run_work, hva_run_work);	v4l2_fh_init(&ctx->fh, video_devdata(file));	file->private_data = &ctx->fh;	v4l2_fh_add(&ctx->fh);	ret = hva_ctrls_setup(ctx);	if (ret) {		dev_err(dev, "%s [x:x] failed to setup controls/n",			HVA_PREFIX);		goto err_fh;	}	ctx->fh.ctrl_handler = &ctx->ctrl_handler;	mutex_init(&ctx->lock);	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(hva->m2m_dev, ctx,					    &hva_queue_init);	if (IS_ERR(ctx->fh.m2m_ctx)) {		ret = PTR_ERR(ctx->fh.m2m_ctx);		dev_err(dev, "%s failed to initialize m2m context (%d)/n",			HVA_PREFIX, ret);		goto err_ctrls;	}	/* set the instance name */	mutex_lock(&hva->lock);	hva->instance_id++;	snprintf(ctx->name, sizeof(ctx->name), "[%3d:----]",		 hva->instance_id);	mutex_unlock(&hva->lock);	/* default parameters for frame and stream */	set_default_params(ctx);	dev_info(dev, "%s encoder instance created/n", ctx->name);	return 0;err_ctrls:	v4l2_ctrl_handler_free(&ctx->ctrl_handler);err_fh:	v4l2_fh_del(&ctx->fh);	v4l2_fh_exit(&ctx->fh);	kfree(ctx);out:	return ret;}
开发者ID:acton393,项目名称:linux,代码行数:61,


示例22: bdisp_open

static int bdisp_open(struct file *file){	struct bdisp_dev *bdisp = video_drvdata(file);	struct bdisp_ctx *ctx = NULL;	int ret;	if (mutex_lock_interruptible(&bdisp->lock))		return -ERESTARTSYS;	/* Allocate memory for both context and node */	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);	if (!ctx) {		ret = -ENOMEM;		goto unlock;	}	ctx->bdisp_dev = bdisp;	if (bdisp_hw_alloc_nodes(ctx)) {		dev_err(bdisp->dev, "no memory for nodes/n");		ret = -ENOMEM;		goto mem_ctx;	}	v4l2_fh_init(&ctx->fh, bdisp->m2m.vdev);	ret = bdisp_ctrls_create(ctx);	if (ret) {		dev_err(bdisp->dev, "Failed to create control/n");		goto error_fh;	}	/* Use separate control handler per file handle */	ctx->fh.ctrl_handler = &ctx->ctrl_handler;	file->private_data = &ctx->fh;	v4l2_fh_add(&ctx->fh);	/* Default format */	ctx->src = bdisp_dflt_fmt;	ctx->dst = bdisp_dflt_fmt;	/* Setup the device context for mem2mem mode. */	ctx->fh.m2m_ctx = v4l2_m2m_ctx_init(bdisp->m2m.m2m_dev, ctx,					    queue_init);	if (IS_ERR(ctx->fh.m2m_ctx)) {		dev_err(bdisp->dev, "Failed to initialize m2m context/n");		ret = PTR_ERR(ctx->fh.m2m_ctx);		goto error_ctrls;	}	bdisp->m2m.refcnt++;	set_bit(ST_M2M_OPEN, &bdisp->state);	dev_dbg(bdisp->dev, "driver opened, ctx = 0x%p/n", ctx);	mutex_unlock(&bdisp->lock);	return 0;error_ctrls:	bdisp_ctrls_delete(ctx);error_fh:	v4l2_fh_del(&ctx->fh);	v4l2_fh_exit(&ctx->fh);	bdisp_hw_free_nodes(ctx);mem_ctx:	kfree(ctx);unlock:	mutex_unlock(&bdisp->lock);	return ret;}
开发者ID:AK101111,项目名称:linux,代码行数:71,


示例23: ivtv_open

static int ivtv_open(struct file *filp){	struct video_device *vdev = video_devdata(filp);	struct ivtv_stream *s = video_get_drvdata(vdev);	struct ivtv *itv = s->itv;	struct ivtv_open_id *item;	int res = 0;	IVTV_DEBUG_FILE("open %s/n", s->name);	if (ivtv_init_on_first_open(itv)) {		IVTV_ERR("Failed to initialize on device %s/n",			 video_device_node_name(vdev));		return -ENXIO;	}#ifdef CONFIG_VIDEO_ADV_DEBUG	/* Unless ivtv_fw_debug is set, error out if firmware dead. */	if (ivtv_fw_debug) {		IVTV_WARN("Opening %s with dead firmware lockout disabled/n",			  video_device_node_name(vdev));		IVTV_WARN("Selected firmware errors will be ignored/n");	} else {#else	if (1) {#endif		res = ivtv_firmware_check(itv, "ivtv_serialized_open");		if (res == -EAGAIN)			res = ivtv_firmware_check(itv, "ivtv_serialized_open");		if (res < 0)			return -EIO;	}	if (s->type == IVTV_DEC_STREAM_TYPE_MPG &&		test_bit(IVTV_F_S_CLAIMED, &itv->streams[IVTV_DEC_STREAM_TYPE_YUV].s_flags))		return -EBUSY;	if (s->type == IVTV_DEC_STREAM_TYPE_YUV &&		test_bit(IVTV_F_S_CLAIMED, &itv->streams[IVTV_DEC_STREAM_TYPE_MPG].s_flags))		return -EBUSY;	if (s->type == IVTV_DEC_STREAM_TYPE_YUV) {		if (read_reg(0x82c) == 0) {			IVTV_ERR("Tried to open YUV output device but need to send data to mpeg decoder before it can be used/n");			/* return -ENODEV; */		}		ivtv_udma_alloc(itv);	}	/* Allocate memory */	item = kzalloc(sizeof(struct ivtv_open_id), GFP_KERNEL);	if (NULL == item) {		IVTV_DEBUG_WARN("nomem on v4l2 open/n");		return -ENOMEM;	}	v4l2_fh_init(&item->fh, &s->vdev);	item->itv = itv;	item->type = s->type;	filp->private_data = &item->fh;	v4l2_fh_add(&item->fh);	if (item->type == IVTV_ENC_STREAM_TYPE_RAD &&			v4l2_fh_is_singular_file(filp)) {		if (!test_bit(IVTV_F_I_RADIO_USER, &itv->i_flags)) {			if (atomic_read(&itv->capturing) > 0) {				/* switching to radio while capture is				   in progress is not polite */				v4l2_fh_del(&item->fh);				v4l2_fh_exit(&item->fh);				kfree(item);				return -EBUSY;			}		}		/* Mark that the radio is being used. */		set_bit(IVTV_F_I_RADIO_USER, &itv->i_flags);		/* We have the radio */		ivtv_mute(itv);		/* Switch tuner to radio */		ivtv_call_all(itv, tuner, s_radio);		/* Select the correct audio input (i.e. radio tuner) */		ivtv_audio_set_io(itv);		if (itv->hw_flags & IVTV_HW_SAA711X) {			ivtv_call_hw(itv, IVTV_HW_SAA711X, video, s_crystal_freq,				SAA7115_FREQ_32_11_MHZ, SAA7115_FREQ_FL_APLL);		}		/* Done! Unmute and continue. */		ivtv_unmute(itv);	}	/* YUV or MPG Decoding Mode? */	if (s->type == IVTV_DEC_STREAM_TYPE_MPG) {		clear_bit(IVTV_F_I_DEC_YUV, &itv->i_flags);	} else if (s->type == IVTV_DEC_STREAM_TYPE_YUV) {		set_bit(IVTV_F_I_DEC_YUV, &itv->i_flags);		/* For yuv, we need to know the dma size before we start */		itv->dma_data_req_size =				1080 * ((itv->yuv_info.v4l2_src_h + 31) & ~31);		itv->yuv_info.stream_size = 0;	}//.........这里部分代码省略.........
开发者ID:AlexShiLucky,项目名称:linux,代码行数:101,


示例24: iss_video_open

static int iss_video_open(struct file *file){	struct iss_video *video = video_drvdata(file);	struct iss_video_fh *handle;	struct vb2_queue *q;	int ret = 0;	handle = kzalloc(sizeof(*handle), GFP_KERNEL);	if (handle == NULL)		return -ENOMEM;	v4l2_fh_init(&handle->vfh, &video->video);	v4l2_fh_add(&handle->vfh);	/* If this is the first user, initialise the pipeline. */	if (omap4iss_get(video->iss) == NULL) {		ret = -EBUSY;		goto done;	}	ret = omap4iss_pipeline_pm_use(&video->video.entity, 1);	if (ret < 0) {		omap4iss_put(video->iss);		goto done;	}	video->alloc_ctx = vb2_dma_contig_init_ctx(video->iss->dev);	if (IS_ERR(video->alloc_ctx)) {		ret = PTR_ERR(video->alloc_ctx);		omap4iss_put(video->iss);		goto done;	}	q = &handle->queue;	q->type = video->type;	q->io_modes = VB2_MMAP;	q->drv_priv = handle;	q->ops = &iss_video_vb2ops;	q->mem_ops = &vb2_dma_contig_memops;	q->buf_struct_size = sizeof(struct iss_buffer);	q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;	ret = vb2_queue_init(q);	if (ret) {		omap4iss_put(video->iss);		goto done;	}	memset(&handle->format, 0, sizeof(handle->format));	handle->format.type = video->type;	handle->timeperframe.denominator = 1;	handle->video = video;	file->private_data = &handle->vfh;done:	if (ret < 0) {		v4l2_fh_del(&handle->vfh);		kfree(handle);	}	return ret;}
开发者ID:Astralix,项目名称:mainline-dss11,代码行数:64,


示例25: fimc_m2m_open

static int fimc_m2m_open(struct file *file){	struct fimc_dev *fimc = video_drvdata(file);	struct fimc_ctx *ctx;	int ret = -EBUSY;	dbg("pid: %d, state: 0x%lx, refcnt: %d",	    task_pid_nr(current), fimc->state, fimc->vid_cap.refcnt);	if (mutex_lock_interruptible(&fimc->lock))		return -ERESTARTSYS;	/*	 * Return if the corresponding video capture node	 * is already opened.	 */	if (fimc->vid_cap.refcnt > 0)		goto unlock;	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);	if (!ctx) {		ret = -ENOMEM;		goto unlock;	}	v4l2_fh_init(&ctx->fh, fimc->m2m.vfd);	ctx->fimc_dev = fimc;	/* Default color format */	ctx->s_frame.fmt = fimc_get_format(0);	ctx->d_frame.fmt = fimc_get_format(0);	ret = fimc_ctrls_create(ctx);	if (ret)		goto error_fh;	/* Use separate control handler per file handle */	ctx->fh.ctrl_handler = &ctx->ctrls.handler;	file->private_data = &ctx->fh;	v4l2_fh_add(&ctx->fh);	/* Setup the device context for memory-to-memory mode */	ctx->state = FIMC_CTX_M2M;	ctx->flags = 0;	ctx->in_path = FIMC_IO_DMA;	ctx->out_path = FIMC_IO_DMA;	ctx->m2m_ctx = v4l2_m2m_ctx_init(fimc->m2m.m2m_dev, ctx, queue_init);	if (IS_ERR(ctx->m2m_ctx)) {		ret = PTR_ERR(ctx->m2m_ctx);		goto error_c;	}	if (fimc->m2m.refcnt++ == 0)		set_bit(ST_M2M_RUN, &fimc->state);	mutex_unlock(&fimc->lock);	return 0;error_c:	fimc_ctrls_delete(ctx);error_fh:	v4l2_fh_del(&ctx->fh);	v4l2_fh_exit(&ctx->fh);	kfree(ctx);unlock:	mutex_unlock(&fimc->lock);	return ret;}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:67,



注:本文中的v4l2_fh_add函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ v4l2_fh_del函数代码示例
C++ v4l2_event_queue函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。