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

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

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

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

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

示例1: rockchip_vpu_video_device_register

static int rockchip_vpu_video_device_register(struct rockchip_vpu_dev *vpu){	const struct of_device_id *match;	struct video_device *vfd;	int function, ret;	match = of_match_node(of_rockchip_vpu_match, vpu->dev->of_node);	vfd = video_device_alloc();	if (!vfd) {		v4l2_err(&vpu->v4l2_dev, "Failed to allocate video device/n");		return -ENOMEM;	}	vfd->fops = &rockchip_vpu_fops;	vfd->release = video_device_release;	vfd->lock = &vpu->vpu_mutex;	vfd->v4l2_dev = &vpu->v4l2_dev;	vfd->vfl_dir = VFL_DIR_M2M;	vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE;	vfd->ioctl_ops = &rockchip_vpu_enc_ioctl_ops;	snprintf(vfd->name, sizeof(vfd->name), "%s-enc", match->compatible);	vpu->vfd_enc = vfd;	video_set_drvdata(vfd, vpu);	ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);	if (ret) {		v4l2_err(&vpu->v4l2_dev, "Failed to register video device/n");		goto err_free_dev;	}	v4l2_info(&vpu->v4l2_dev, "registered as /dev/video%d/n", vfd->num);	function = MEDIA_ENT_F_PROC_VIDEO_ENCODER;	ret = v4l2_m2m_register_media_controller(vpu->m2m_dev, vfd, function);	if (ret) {		v4l2_err(&vpu->v4l2_dev, "Failed to init mem2mem media controller/n");		goto err_unreg_video;	}	return 0;err_unreg_video:	video_unregister_device(vfd);err_free_dev:	video_device_release(vfd);	return ret;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:45,


示例2: isp_video_init

int isp_video_init(struct isp_video *video, const char *name){	const char *direction;	int ret;	switch (video->type) {	case V4L2_BUF_TYPE_VIDEO_CAPTURE:		direction = "output";		video->pad.type = MEDIA_PAD_TYPE_INPUT;		break;	case V4L2_BUF_TYPE_VIDEO_OUTPUT:		direction = "input";		video->pad.type = MEDIA_PAD_TYPE_OUTPUT;		break;	default:		return -EINVAL;	}	ret = media_entity_init(&video->video.entity, 1, &video->pad, 0);	if (ret < 0)		return ret;	mutex_init(&video->mutex);	atomic_set(&video->active, 0);	atomic_set(&video->users, 0);	spin_lock_init(&video->__pipe.lock);	mutex_init(&video->stream_lock);	/* Initialize the video device. */	if (video->ops == NULL)		video->ops = &isp_video_dummy_ops;	video->video.fops = &isp_video_fops;	snprintf(video->video.name, sizeof(video->video.name),		 "OMAP3 ISP %s %s", name, direction);	video->video.vfl_type = VFL_TYPE_GRABBER;	video->video.release = video_device_release_empty;	video->video.ioctl_ops = &isp_video_ioctl_ops;	video_set_drvdata(&video->video, video);	return 0;}
开发者ID:mgrundy,项目名称:bug20-2.6.35-linaro,代码行数:45,


示例3: uvc_register_video

static intuvc_register_video(struct uvc_device *uvc){	struct usb_composite_dev *cdev = uvc->func.config->cdev;	/* TODO reference counting. */	uvc->vdev.v4l2_dev = &uvc->v4l2_dev;	uvc->vdev.fops = &uvc_v4l2_fops;	uvc->vdev.ioctl_ops = &uvc_v4l2_ioctl_ops;	uvc->vdev.release = video_device_release_empty;	uvc->vdev.vfl_dir = VFL_DIR_TX;	uvc->vdev.lock = &uvc->video.mutex;	strlcpy(uvc->vdev.name, cdev->gadget->name, sizeof(uvc->vdev.name));	video_set_drvdata(&uvc->vdev, uvc);	return video_register_device(&uvc->vdev, VFL_TYPE_GRABBER, -1);}
开发者ID:asmalldev,项目名称:linux,代码行数:18,


示例4: fimc_register_m2m_device

int fimc_register_m2m_device(struct fimc_dev *fimc,                             struct v4l2_device *v4l2_dev){    struct video_device *vfd = &fimc->m2m.vfd;    int ret;    fimc->v4l2_dev = v4l2_dev;    memset(vfd, 0, sizeof(*vfd));    vfd->fops = &fimc_m2m_fops;    vfd->ioctl_ops = &fimc_m2m_ioctl_ops;    vfd->v4l2_dev = v4l2_dev;    vfd->minor = -1;    vfd->release = video_device_release_empty;    vfd->lock = &fimc->lock;    vfd->vfl_dir = VFL_DIR_M2M;    snprintf(vfd->name, sizeof(vfd->name), "fimc.%d.m2m", fimc->id);    video_set_drvdata(vfd, fimc);    fimc->m2m.m2m_dev = v4l2_m2m_init(&m2m_ops);    if (IS_ERR(fimc->m2m.m2m_dev)) {        v4l2_err(v4l2_dev, "failed to initialize v4l2-m2m device/n");        return PTR_ERR(fimc->m2m.m2m_dev);    }    ret = media_entity_init(&vfd->entity, 0, NULL, 0);    if (ret)        goto err_me;    ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);    if (ret)        goto err_vd;    v4l2_info(v4l2_dev, "Registered %s as /dev/%s/n",              vfd->name, video_device_node_name(vfd));    return 0;err_vd:    media_entity_cleanup(&vfd->entity);err_me:    v4l2_m2m_release(fimc->m2m.m2m_dev);    return ret;}
开发者ID:Niisp,项目名称:MT6795.kernel,代码行数:44,


示例5: stk1160_video_register

int stk1160_video_register(struct stk1160 *dev){	int rc;	/* Initialize video_device with a template structure */	dev->vdev = v4l_template;	dev->vdev.debug = vidioc_debug;	dev->vdev.queue = &dev->vb_vidq;	/*	 * Provide mutexes for v4l2 core and for videobuf2 queue.	 * It will be used to protect *only* v4l2 ioctls.	 */	dev->vdev.lock = &dev->v4l_lock;	dev->vdev.queue->lock = &dev->vb_queue_lock;	/* This will be used to set video_device parent */	dev->vdev.v4l2_dev = &dev->v4l2_dev;	set_bit(V4L2_FL_USE_FH_PRIO, &dev->vdev.flags);	/* NTSC is default */	dev->norm = V4L2_STD_NTSC_M;	dev->width = 720;	dev->height = 480;	/* set default format */	dev->fmt = &format[0];	stk1160_set_std(dev);	v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std,			dev->norm);	video_set_drvdata(&dev->vdev, dev);	rc = video_register_device(&dev->vdev, VFL_TYPE_GRABBER, -1);	if (rc < 0) {		stk1160_err("video_register_device failed (%d)/n", rc);		return rc;	}	v4l2_info(&dev->v4l2_dev, "V4L2 device registered as %s/n",		  video_device_node_name(&dev->vdev));	return 0;}
开发者ID:cyberphox,项目名称:monoev3kernel,代码行数:44,


示例6: register_v4l2_device

static int register_v4l2_device(void){  int ret;  struct fmdev *fmdev = NULL;	struct video_device *radio = video_device_alloc();	if (!radio)	{		TROUT_PRINT("Could not allocate video_device");		return -EINVAL;	}	strlcpy(radio->name, DRIVER_NAME, sizeof(radio->name));	radio->fops = &trout_fops;	radio->release = video_device_release;	radio->ioctl_ops = &trout_ioctl_ops;	if (video_register_device(radio, VFL_TYPE_RADIO, -1))	{		TROUT_PRINT("Could not register video_device");		video_device_release(radio);	  return -EINVAL;	}  s_radio = radio;  fmdev = (struct fmdev *)kzalloc(sizeof(struct fmdev), GFP_KERNEL);  if (!fmdev)  {    TROUT_PRINT("Could not allocate fmdev");    return -EINVAL;  }  video_set_drvdata(radio, fmdev);  radio->ctrl_handler = &fmdev->ctrl_handler;  ret = v4l2_ctrl_handler_init(&fmdev->ctrl_handler, 1);  if (ret < 0)  {    TROUT_PRINT("Failed to int v4l2_ctrl_handler");    v4l2_ctrl_handler_free(&fmdev->ctrl_handler);    return -EINVAL;  }  v4l2_ctrl_new_std(&fmdev->ctrl_handler, &trout_ctrl_ops,      V4L2_CID_PRIVATE_FM_AUDIO, 0, 1, 1, 0);	TROUT_PRINT("Registered Trout FM Receiver.");	return 0;}
开发者ID:abgoyal,项目名称:alcatel_ot_4020D_kernel,代码行数:43,


示例7: fimc_is_video_probe

int fimc_is_video_probe(struct fimc_is_video *video,	char *video_name,	u32 video_number,	u32 vfl_dir,	struct fimc_is_mem *mem,	struct v4l2_device *v4l2_dev,	struct mutex *lock,	const struct v4l2_file_operations *fops,	const struct v4l2_ioctl_ops *ioctl_ops){	int ret = 0;	u32 video_id;	vref_init(video);	mutex_init(&video->lock);	snprintf(video->vd.name, sizeof(video->vd.name), "%s", video_name);	video->id		= video_number;	video->vb2		= mem->vb2;	video->alloc_ctx	= mem->alloc_ctx;#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0))	video->vd.vfl_dir	= vfl_dir;#endif	video->vd.v4l2_dev	= v4l2_dev;	video->vd.fops		= fops;	video->vd.ioctl_ops	= ioctl_ops;	video->vd.minor		= -1;	video->vd.release	= video_device_release;	video->vd.lock		= lock;	video_set_drvdata(&video->vd, video);	video_id = EXYNOS_VIDEONODE_FIMC_IS + video_number;	ret = video_register_device(&video->vd,		VFL_TYPE_GRABBER,		(EXYNOS_VIDEONODE_FIMC_IS + video_number));	if (ret) {		err("Failed to register video device");		goto p_err;	}p_err:	info("[VID] %s(%d) is created/n", video_name, video_id);	return ret;}
开发者ID:djmax81,项目名称:android_kernel_samsung_exynos5433_LL,代码行数:43,


示例8: gsc_register_m2m_device

int gsc_register_m2m_device(struct gsc_dev *gsc){	struct platform_device *pdev;	int ret;	if (!gsc)		return -ENODEV;	pdev = gsc->pdev;	gsc->vdev.fops		= &gsc_m2m_fops;	gsc->vdev.ioctl_ops	= &gsc_m2m_ioctl_ops;	gsc->vdev.release	= video_device_release_empty;	gsc->vdev.lock		= &gsc->lock;	gsc->vdev.vfl_dir	= VFL_DIR_M2M;	gsc->vdev.v4l2_dev	= &gsc->v4l2_dev;	snprintf(gsc->vdev.name, sizeof(gsc->vdev.name), "%s.%d:m2m",					GSC_MODULE_NAME, gsc->id);	video_set_drvdata(&gsc->vdev, gsc);	gsc->m2m.vfd = &gsc->vdev;	gsc->m2m.m2m_dev = v4l2_m2m_init(&gsc_m2m_ops);	if (IS_ERR(gsc->m2m.m2m_dev)) {		dev_err(&pdev->dev, "failed to initialize v4l2-m2m device/n");		return PTR_ERR(gsc->m2m.m2m_dev);	}	ret = video_register_device(&gsc->vdev, VFL_TYPE_GRABBER, -1);	if (ret) {		dev_err(&pdev->dev,			 "%s(): failed to register video device/n", __func__);		goto err_m2m_release;	}	pr_debug("gsc m2m driver registered as /dev/video%d", gsc->vdev.num);	return 0;err_m2m_release:	v4l2_m2m_release(gsc->m2m.m2m_dev);	return ret;}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:43,


示例9: uvc_register_video

static intuvc_register_video(struct uvc_device *uvc){	struct usb_composite_dev *cdev = uvc->func.config->cdev;	struct video_device *video;	/* TODO reference counting. */	video = video_device_alloc();	if (video == NULL)		return -ENOMEM;	video->v4l2_dev = &uvc->v4l2_dev;	video->fops = &uvc_v4l2_fops;	video->release = video_device_release;	strlcpy(video->name, cdev->gadget->name, sizeof(video->name));	uvc->vdev = video;	video_set_drvdata(video, uvc);	return video_register_device(video, VFL_TYPE_GRABBER, -1);}
开发者ID:7799,项目名称:linux,代码行数:21,


示例10: empress_init

static int empress_init(struct saa7134_dev *dev){	int err;	dprintk("%s: %s/n",dev->name,__func__);	dev->empress_dev = video_device_alloc();	if (NULL == dev->empress_dev)		return -ENOMEM;	*(dev->empress_dev) = saa7134_empress_template;	dev->empress_dev->parent  = &dev->pci->dev;	dev->empress_dev->release = video_device_release;	snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name),		 "%s empress (%s)", dev->name,		 saa7134_boards[dev->board].name);	INIT_WORK(&dev->empress_workqueue, empress_signal_update);	video_set_drvdata(dev->empress_dev, dev);	err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,				    empress_nr[dev->nr]);	if (err < 0) {		printk(KERN_INFO "%s: can't register video device/n",		       dev->name);		video_device_release(dev->empress_dev);		dev->empress_dev = NULL;		return err;	}	printk(KERN_INFO "%s: registered device %s [mpeg]/n",	       dev->name, video_device_node_name(dev->empress_dev));	videobuf_queue_sg_init(&dev->empress_tsq, &saa7134_ts_qops,			    &dev->pci->dev, &dev->slock,			    V4L2_BUF_TYPE_VIDEO_CAPTURE,			    V4L2_FIELD_ALTERNATE,			    sizeof(struct saa7134_buf),			    dev);	empress_signal_update(&dev->empress_workqueue);	return 0;}
开发者ID:KaZoom,项目名称:buildroot-linux-kernel-m3,代码行数:40,


示例11: snd_tea575x_init

/* * initialize all the tea575x chips */void snd_tea575x_init(struct snd_tea575x *tea){	unsigned int val;	val = tea->ops->read(tea);	if (val == 0x1ffffff || val == 0) {		snd_printk(KERN_ERR "Cannot find TEA575x chip/n");		return;	}	memset(&tea->vd, 0, sizeof(tea->vd));	tea->vd.owner = tea->card->module;	strcpy(tea->vd.name, tea->tea5759 ? "TEA5759 radio" : "TEA5757 radio");	tea->vd.type = VID_TYPE_TUNER;	tea->vd.release = snd_tea575x_release;	video_set_drvdata(&tea->vd, tea);	tea->vd.fops = &tea->fops;	tea->fops.owner = tea->card->module;	tea->fops.open = video_exclusive_open;	tea->fops.release = video_exclusive_release;	tea->fops.ioctl = snd_tea575x_ioctl;	if (video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->dev_nr - 1) < 0) {		snd_printk(KERN_ERR "unable to register tea575x tuner/n");		return;	}	tea->vd_registered = 1;	tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40;	tea->freq = 90500 * 16;		/* 90.5Mhz default */	snd_tea575x_set_freq(tea);	/* mute on init */	if (tea->ops->mute)		tea->ops->mute(tea, 1);}
开发者ID:canalplus,项目名称:r7oss,代码行数:39,


示例12: zr364xx_probe

static int zr364xx_probe(struct usb_interface *intf,			 const struct usb_device_id *id){	struct usb_device *udev = interface_to_usbdev(intf);	struct zr364xx_camera *cam = NULL;	int err;	DBG("probing...");	dev_info(&intf->dev, DRIVER_DESC " compatible webcam plugged/n");	dev_info(&intf->dev, "model %04x:%04x detected/n",		 le16_to_cpu(udev->descriptor.idVendor),		 le16_to_cpu(udev->descriptor.idProduct));	cam = kzalloc(sizeof(struct zr364xx_camera), GFP_KERNEL);	if (cam == NULL) {		dev_err(&udev->dev, "cam: out of memory !/n");		return -ENOMEM;	}	/* save the init method used by this camera */	cam->method = id->driver_info;	cam->vdev = video_device_alloc();	if (cam->vdev == NULL) {		dev_err(&udev->dev, "cam->vdev: out of memory !/n");		kfree(cam);		return -ENOMEM;	}	memcpy(cam->vdev, &zr364xx_template, sizeof(zr364xx_template));	video_set_drvdata(cam->vdev, cam);	if (debug)		cam->vdev->debug = V4L2_DEBUG_IOCTL | V4L2_DEBUG_IOCTL_ARG;	cam->udev = udev;	if ((cam->buffer = kmalloc(BUFFER_SIZE, GFP_KERNEL)) == NULL) {		dev_info(&udev->dev, "cam->buffer: out of memory !/n");		video_device_release(cam->vdev);		kfree(cam);		return -ENODEV;	}	switch (mode) {	case 1:		dev_info(&udev->dev, "160x120 mode selected/n");		cam->width = 160;		cam->height = 120;		break;	case 2:		dev_info(&udev->dev, "640x480 mode selected/n");		cam->width = 640;		cam->height = 480;		break;	default:		dev_info(&udev->dev, "320x240 mode selected/n");		cam->width = 320;		cam->height = 240;		break;	}	m0d1[0] = mode;	m1[2].value = 0xf000 + mode;	m2[1].value = 0xf000 + mode;	header2[437] = cam->height / 256;	header2[438] = cam->height % 256;	header2[439] = cam->width / 256;	header2[440] = cam->width % 256;	cam->nb = 0;	cam->brightness = 64;	mutex_init(&cam->lock);	err = video_register_device(cam->vdev, VFL_TYPE_GRABBER, -1);	if (err) {		dev_err(&udev->dev, "video_register_device failed/n");		video_device_release(cam->vdev);		kfree(cam->buffer);		kfree(cam);		return err;	}	usb_set_intfdata(intf, cam);	dev_info(&udev->dev, DRIVER_DESC " controlling video device %d/n",		 cam->vdev->num);	return 0;}
开发者ID:KHATEEBNSIT,项目名称:lsdk_ar9531,代码行数:87,


示例13: vcap_probe

//.........这里部分代码省略.........	if (!dev->vcirq) {		pr_err("%s: no vc irq resource?/n", __func__);		ret = -ENODEV;		goto free_resource;	}	dev->vpirq = platform_get_resource_byname(pdev,					IORESOURCE_IRQ, "vp_irq");	if (!dev->vpirq) {		pr_err("%s: no vp irq resource?/n", __func__);		ret = -ENODEV;		goto free_resource;	}	ret = request_irq(dev->vcirq->start, vcap_vc_handler,		IRQF_TRIGGER_RISING, "vc_irq", 0);	if (ret < 0) {		pr_err("%s: vc irq request fail/n", __func__);		ret = -EBUSY;		goto free_resource;	}	disable_irq(dev->vcirq->start);	ret = request_irq(dev->vpirq->start, vcap_vp_handler,		IRQF_TRIGGER_RISING, "vp_irq", 0);	if (ret < 0) {		pr_err("%s: vp irq request fail/n", __func__);		ret = -EBUSY;		goto free_resource;	}	disable_irq(dev->vpirq->start);	snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name),			"%s", MSM_VCAP_DRV_NAME);	ret = v4l2_device_register(NULL, &dev->v4l2_dev);	if (ret)		goto free_resource;	ret = vcap_enable(dev, &pdev->dev);	if (ret)		goto unreg_dev;	msm_bus_scale_client_update_request(dev->bus_client_handle, 3);	ret = detect_vc(dev);	if (ret)		goto power_down;	/* init video device*/	vfd = video_device_alloc();	if (!vfd)		goto deinit_vc;	*vfd = vcap_template;	vfd->v4l2_dev = &dev->v4l2_dev;	ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);	if (ret < 0)		goto rel_vdev;	dev->vfd = vfd;	video_set_drvdata(vfd, dev);	dev->vcap_wq = create_workqueue("vcap");	if (!dev->vcap_wq) {		pr_err("Could not create workqueue");		goto rel_vdev;	}	dev->ion_client = msm_ion_client_create(-1, "vcap");	if (IS_ERR((void *)dev->ion_client)) {		pr_err("could not get ion client");		goto rel_vcap_wq;	}	atomic_set(&dev->vc_enabled, 0);	atomic_set(&dev->vp_enabled, 0);	dprintk(1, "Exit probe succesfully");	return 0;rel_vcap_wq:	destroy_workqueue(dev->vcap_wq);rel_vdev:	video_device_release(vfd);deinit_vc:	deinit_vc();power_down:	vcap_disable(dev);unreg_dev:	v4l2_device_unregister(&dev->v4l2_dev);free_resource:	iounmap(dev->vcapbase);	release_mem_region(dev->vcapmem->start, resource_size(dev->vcapmem));free_dev:	vcap_ctrl = NULL;	kfree(dev);	return ret;}
开发者ID:SmokyBob,项目名称:android_kernel_asus_padfone2,代码行数:101,


示例14: camera_init_v4l2

int camera_init_v4l2(struct device *dev, unsigned int *session){	struct msm_video_device *pvdev;	struct v4l2_device *v4l2_dev;	int rc = 0;	pvdev = kzalloc(sizeof(struct msm_video_device),		GFP_KERNEL);	if (WARN_ON(!pvdev)) {		rc = -ENOMEM;		goto init_end;	}	pvdev->vdev = video_device_alloc();	if (WARN_ON(!pvdev->vdev)) {		rc = -ENOMEM;		goto video_fail;	}	v4l2_dev = kzalloc(sizeof(struct v4l2_device), GFP_KERNEL);	if (WARN_ON(!v4l2_dev)) {		rc = -ENOMEM;		goto v4l2_fail;	}#if defined(CONFIG_MEDIA_CONTROLLER)	v4l2_dev->mdev = kzalloc(sizeof(struct media_device),							 GFP_KERNEL);	if (!v4l2_dev->mdev) {		rc = -ENOMEM;		goto mdev_fail;	}	strlcpy(v4l2_dev->mdev->model, MSM_CAMERA_NAME,			sizeof(v4l2_dev->mdev->model));	v4l2_dev->mdev->dev = dev;	rc = media_device_register(v4l2_dev->mdev);	if (WARN_ON(rc < 0))		goto media_fail;	rc = media_entity_init(&pvdev->vdev->entity, 0, NULL, 0);	if (WARN_ON(rc < 0))		goto entity_fail;	pvdev->vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;	pvdev->vdev->entity.group_id = QCAMERA_VNODE_GROUP_ID;#endif	v4l2_dev->notify = NULL;	pvdev->vdev->v4l2_dev = v4l2_dev;	rc = v4l2_device_register(dev, pvdev->vdev->v4l2_dev);	if (WARN_ON(rc < 0))		goto register_fail;	strlcpy(pvdev->vdev->name, "msm-sensor", sizeof(pvdev->vdev->name));	pvdev->vdev->release  = video_device_release;	pvdev->vdev->fops     = &camera_v4l2_fops;	pvdev->vdev->ioctl_ops = &camera_v4l2_ioctl_ops;	pvdev->vdev->minor     = -1;	pvdev->vdev->vfl_type  = VFL_TYPE_GRABBER;	rc = video_register_device(pvdev->vdev,		VFL_TYPE_GRABBER, -1);	if (WARN_ON(rc < 0))		goto video_register_fail;#if defined(CONFIG_MEDIA_CONTROLLER)	/* FIXME: How to get rid of this messy? */	pvdev->vdev->entity.name = video_device_node_name(pvdev->vdev);#endif	*session = pvdev->vdev->num;	atomic_set(&pvdev->opened, 0);	atomic_set(&pvdev->stream_cnt, 0);	video_set_drvdata(pvdev->vdev, pvdev);	device_init_wakeup(&pvdev->vdev->dev, 1);    if(!cam_wakelock_init)    {        cam_wakelock_init = 1;        wake_lock_init(&cam_wakelock, WAKE_LOCK_SUSPEND, "cam_wakelock");    }	goto init_end;video_register_fail:	v4l2_device_unregister(pvdev->vdev->v4l2_dev);register_fail:#if defined(CONFIG_MEDIA_CONTROLLER)	media_entity_cleanup(&pvdev->vdev->entity);entity_fail:	media_device_unregister(v4l2_dev->mdev);media_fail:	kzfree(v4l2_dev->mdev);mdev_fail:#endif	kzfree(v4l2_dev);v4l2_fail:	video_device_release(pvdev->vdev);video_fail:	kzfree(pvdev);init_end:	return rc;//.........这里部分代码省略.........
开发者ID:TheNameIsNigel,项目名称:android_kernel_carbon_msm8928,代码行数:101,


示例15: w9966_init

/* Initialize camera device. Setup all internal flags, set a   default video mode, setup ccd-chip, register v4l device etc..   Also used for 'probing' of hardware.   -1 on error */static int w9966_init(struct w9966 *cam, struct parport *port){	struct v4l2_device *v4l2_dev = &cam->v4l2_dev;	if (cam->dev_state != 0)		return -1;	strlcpy(v4l2_dev->name, "w9966", sizeof(v4l2_dev->name));	if (v4l2_device_register(NULL, v4l2_dev) < 0) {		v4l2_err(v4l2_dev, "Could not register v4l2_device/n");		return -1;	}	cam->pport = port;	cam->brightness = 128;	cam->contrast = 64;	cam->color = 64;	cam->hue = 0;	/* Select requested transfer mode */	switch (parmode) {	default:	/* Auto-detect (priority: hw-ecp, hw-epp, sw-ecp) */	case 0:		if (port->modes & PARPORT_MODE_ECP)			cam->ppmode = IEEE1284_MODE_ECP;		else if (port->modes & PARPORT_MODE_EPP)			cam->ppmode = IEEE1284_MODE_EPP;		else			cam->ppmode = IEEE1284_MODE_ECP;		break;	case 1:		/* hw- or sw-ecp */		cam->ppmode = IEEE1284_MODE_ECP;		break;	case 2:		/* hw- or sw-epp */		cam->ppmode = IEEE1284_MODE_EPP;		break;	}	/* Tell the parport driver that we exists */	cam->pdev = parport_register_device(port, "w9966", NULL, NULL, NULL, 0, NULL);	if (cam->pdev == NULL) {		DPRINTF("parport_register_device() failed/n");		return -1;	}	w9966_set_state(cam, W9966_STATE_PDEV, W9966_STATE_PDEV);	w9966_pdev_claim(cam);	/* Setup a default capture mode */	if (w9966_setup(cam, 0, 0, 1023, 1023, 200, 160) != 0) {		DPRINTF("w9966_setup() failed./n");		return -1;	}	w9966_pdev_release(cam);	/* Fill in the video_device struct and register us to v4l */	strlcpy(cam->vdev.name, W9966_DRIVERNAME, sizeof(cam->vdev.name));	cam->vdev.v4l2_dev = v4l2_dev;	cam->vdev.fops = &w9966_fops;	cam->vdev.ioctl_ops = &w9966_ioctl_ops;	cam->vdev.release = video_device_release_empty;	video_set_drvdata(&cam->vdev, cam);	mutex_init(&cam->lock);	if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) < 0)		return -1;	w9966_set_state(cam, W9966_STATE_VDEV, W9966_STATE_VDEV);	/* All ok */	v4l2_info(v4l2_dev, "Found and initialized a webcam on %s./n",			cam->pport->name);	return 0;}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:80,


示例16: hwcam_dev_create

inthwcam_dev_create(        struct device* dev,        int* dev_num){	int rc = 0;    struct v4l2_device* v4l2 = NULL;    struct video_device* vdev = NULL;    struct media_device* mdev = NULL;    hwcam_dev_t* cam = NULL;    cam = kzalloc(sizeof(hwcam_dev_t), GFP_KERNEL);	if (WARN_ON(!cam)) {		rc = -ENOMEM;		goto init_end;	}    v4l2 = &cam->v4l2;    vdev = video_device_alloc();    if (!vdev) {		rc = -ENOMEM;		goto video_alloc_fail;    }    mdev = kzalloc(sizeof(struct media_device), GFP_KERNEL);	if (!mdev) {		rc = -ENOMEM;		goto media_alloc_fail;	}	strlcpy(mdev->model, HWCAM_MODEL_USER, sizeof(mdev->model));	mdev->dev = dev;	rc = media_device_register(mdev);	if (rc < 0) {		goto media_register_fail;    }	rc = media_entity_init(&vdev->entity, 0, NULL, 0);	if (rc < 0) {		goto entity_init_fail;    }    v4l2->mdev = mdev;	v4l2->notify = NULL;	rc = v4l2_device_register(dev, v4l2);	if (rc < 0) {		goto v4l2_register_fail;    }	strlcpy(vdev->name, "hwcam-userdev", sizeof(vdev->name));	vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;	vdev->entity.group_id = HWCAM_DEVICE_GROUP_ID;	vdev->v4l2_dev = v4l2;	vdev->release = video_device_release;	vdev->fops = &s_fops_hwcam_dev;	vdev->ioctl_ops = &s_iops_hwcam_dev;	vdev->minor = -1;	vdev->vfl_type = VFL_TYPE_GRABBER;	rc = video_register_device(vdev, VFL_TYPE_GRABBER, -1);	if (rc < 0) {		goto video_register_fail;    }	cam_debug("video dev name %s %s",vdev->dev.kobj.name,vdev->name);    mutex_init(&cam->lock);    vdev->lock = &cam->lock;	vdev->entity.name = video_device_node_name(vdev);	video_set_drvdata(vdev, cam);    cam->vdev = vdev;    cam->mdev = mdev;    cam->intf.vtbl = &s_vtbl_hwcam_dev;    *dev_num = vdev->num;	goto init_end;video_register_fail:	v4l2_device_unregister(v4l2);v4l2_register_fail:	media_entity_cleanup(&vdev->entity);entity_init_fail:	media_device_unregister(mdev);media_register_fail:    kzfree(mdev);media_alloc_fail:	video_device_release(vdev);video_alloc_fail:	kzfree(cam);init_end:	return rc;}
开发者ID:herryfan,项目名称:kernel-huawei-h60,代码行数:95,


示例17: empress_init

static int empress_init(struct saa7134_dev *dev){    struct v4l2_ctrl_handler *hdl = &dev->empress_ctrl_handler;    struct vb2_queue *q;    int err;    pr_debug("%s: %s/n", dev->name, __func__);    dev->empress_dev = video_device_alloc();    if (NULL == dev->empress_dev)        return -ENOMEM;    *(dev->empress_dev) = saa7134_empress_template;    dev->empress_dev->v4l2_dev  = &dev->v4l2_dev;    dev->empress_dev->release = video_device_release;    dev->empress_dev->lock = &dev->lock;    snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name),             "%s empress (%s)", dev->name,             saa7134_boards[dev->board].name);    v4l2_ctrl_handler_init(hdl, 21);    v4l2_ctrl_add_handler(hdl, &dev->ctrl_handler, empress_ctrl_filter);    if (dev->empress_sd)        v4l2_ctrl_add_handler(hdl, dev->empress_sd->ctrl_handler, NULL);    if (hdl->error) {        video_device_release(dev->empress_dev);        return hdl->error;    }    dev->empress_dev->ctrl_handler = hdl;    INIT_WORK(&dev->empress_workqueue, empress_signal_update);    q = &dev->empress_vbq;    q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;    /*     * Do not add VB2_USERPTR: the saa7134 DMA engine cannot handle     * transfers that do not start at the beginning of a page. A USERPTR     * can start anywhere in a page, so USERPTR support is a no-go.     */    q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;    q->drv_priv = &dev->ts_q;    q->ops = &saa7134_empress_qops;    q->gfp_flags = GFP_DMA32;    q->mem_ops = &vb2_dma_sg_memops;    q->buf_struct_size = sizeof(struct saa7134_buf);    q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;    q->lock = &dev->lock;    q->dev = &dev->pci->dev;    err = vb2_queue_init(q);    if (err)        return err;    dev->empress_dev->queue = q;    video_set_drvdata(dev->empress_dev, dev);    err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,                                empress_nr[dev->nr]);    if (err < 0) {        pr_info("%s: can't register video device/n",                dev->name);        video_device_release(dev->empress_dev);        dev->empress_dev = NULL;        return err;    }    pr_info("%s: registered device %s [mpeg]/n",            dev->name, video_device_node_name(dev->empress_dev));    empress_signal_update(&dev->empress_workqueue);    return 0;}
开发者ID:robeat101,项目名称:linux,代码行数:66,


示例18: mxc_v4l2out_probe

/*! * Probe routine for the framebuffer driver. It is called during the * driver binding process.      The following functions are performed in * this routine: Framebuffer initialization, Memory allocation and * mapping, Framebuffer registration, IPU initialization. * * @return      Appropriate error code to the kernel common code */static int mxc_v4l2out_probe(struct device *dev){	int i;	vout_data *vout;	FUNC_START;	/*	 * Allocate sufficient memory for the fb structure	 */	vout = kmalloc(sizeof(vout_data), GFP_KERNEL);	if (!vout)		return 0;	memset(vout, 0, sizeof(vout_data));	vout->video_dev = video_device_alloc();	if (vout->video_dev == NULL)		return -1;	vout->video_dev->dev = dev;	vout->video_dev->minor = -1;	*(vout->video_dev) = mxc_v4l2out_template;	/* register v4l device */	if (video_register_device(vout->video_dev,				  VFL_TYPE_GRABBER, video_nr) == -1) {		printk(KERN_DEBUG "video_register_device failed/n");		return 0;	}	printk(KERN_INFO "mxc_v4l2out: registered device video%d/n",	       vout->video_dev->minor & 0x1f);	video_set_drvdata(vout->video_dev, vout);	init_MUTEX(&vout->param_lock);	init_MUTEX(&vout->busy_lock);	/* setup outputs and cropping */	vout->cur_disp_output = -1;	for (i = 0; i < num_registered_fb; i++) {		char *idstr = registered_fb[i]->fix.id;		if (strncmp(idstr, "DISP", 4) == 0) {			int disp_num = idstr[4] - '0';			if ((disp_num == 3) &&			    (strncmp(idstr, "DISP3 BG", 8) != 0)) {				continue;			}			vout->crop_bounds[disp_num].left = 0;			vout->crop_bounds[disp_num].top = 0;			vout->crop_bounds[disp_num].width =			    registered_fb[i]->var.xres;			vout->crop_bounds[disp_num].height =			    registered_fb[i]->var.yres;			vout->output_enabled[disp_num] = true;			vout->output_fb_num[disp_num] = i;			if (vout->cur_disp_output == -1)				vout->cur_disp_output = disp_num;		}	}	vout->crop_current = vout->crop_bounds[vout->cur_disp_output];	FUNC_END;	return 0;}
开发者ID:GodFox,项目名称:magx_kernel_xpixl,代码行数:74,


示例19: vpif_probe

static __init int vpif_probe(struct platform_device *pdev){	struct vpif_subdev_info *subdevdata;	struct vpif_capture_config *config;	int i, j, k, m, q, err;	struct i2c_adapter *i2c_adap;	struct channel_obj *ch;	struct common_obj *common;	struct video_device *vfd;	struct resource *res;	int subdev_count;	vpif_dev = &pdev->dev;	err = initialize_vpif();	if (err) {		v4l2_err(vpif_dev->driver, "Error initializing vpif/n");		return err;	}	k = 0;	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, k))) {		for (i = res->start; i <= res->end; i++) {			if (request_irq(i, vpif_channel_isr, IRQF_DISABLED,					"DM646x_Capture",				(void *)(&vpif_obj.dev[k]->channel_id))) {				err = -EBUSY;				i--;				goto vpif_int_err;			}		}		k++;	}	for (i = 0; i < VPIF_CAPTURE_MAX_DEVICES; i++) {		/* Get the pointer to the channel object */		ch = vpif_obj.dev[i];		/* Allocate memory for video device */		vfd = video_device_alloc();		if (NULL == vfd) {			for (j = 0; j < i; j++) {				ch = vpif_obj.dev[j];				video_device_release(ch->video_dev);			}			err = -ENOMEM;			goto vpif_dev_alloc_err;		}		/* Initialize field of video device */		*vfd = vpif_video_template;		vfd->v4l2_dev = &vpif_obj.v4l2_dev;		vfd->release = video_device_release;		snprintf(vfd->name, sizeof(vfd->name),			 "DM646x_VPIFCapture_DRIVER_V%d.%d.%d",			 (VPIF_CAPTURE_VERSION_CODE >> 16) & 0xff,			 (VPIF_CAPTURE_VERSION_CODE >> 8) & 0xff,			 (VPIF_CAPTURE_VERSION_CODE) & 0xff);		/* Set video_dev to the video device */		ch->video_dev = vfd;	}	for (j = 0; j < VPIF_CAPTURE_MAX_DEVICES; j++) {		ch = vpif_obj.dev[j];		ch->channel_id = j;		common = &(ch->common[VPIF_VIDEO_INDEX]);		spin_lock_init(&common->irqlock);		mutex_init(&common->lock);		/* Initialize prio member of channel object */		v4l2_prio_init(&ch->prio);		err = video_register_device(ch->video_dev,					    VFL_TYPE_GRABBER, (j ? 1 : 0));		if (err)			goto probe_out;		video_set_drvdata(ch->video_dev, ch);	}	i2c_adap = i2c_get_adapter(1);	config = pdev->dev.platform_data;	subdev_count = config->subdev_count;	vpif_obj.sd = kmalloc(sizeof(struct v4l2_subdev *) * subdev_count,				GFP_KERNEL);	if (vpif_obj.sd == NULL) {		vpif_err("unable to allocate memory for subdevice pointers/n");		err = -ENOMEM;		goto probe_out;	}	err = v4l2_device_register(vpif_dev, &vpif_obj.v4l2_dev);	if (err) {		v4l2_err(vpif_dev->driver, "Error registering v4l2 device/n");		goto probe_subdev_out;	}	for (i = 0; i < subdev_count; i++) {		subdevdata = &config->subdev_info[i];		vpif_obj.sd[i] =			v4l2_i2c_new_subdev_board(&vpif_obj.v4l2_dev,//.........这里部分代码省略.........
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:101,


示例20: fm_v4l2_init_video_device

int fm_v4l2_init_video_device(struct fmdev *fmdev, int radio_nr){	struct v4l2_ctrl *ctrl;	int ret;	/* Init mutex for core locking */	mutex_init(&fmdev->mutex);	/* Allocate new video device */	gradio_dev = video_device_alloc();	if (NULL == gradio_dev) {		fmerr("Can't allocate video device/n");		return -ENOMEM;	}	/* Setup FM driver's V4L2 properties */	memcpy(gradio_dev, &fm_viddev_template, sizeof(fm_viddev_template));	video_set_drvdata(gradio_dev, fmdev);	gradio_dev->lock = &fmdev->mutex;	/* Register with V4L2 subsystem as RADIO device */	if (video_register_device(gradio_dev, VFL_TYPE_RADIO, radio_nr)) {		video_device_release(gradio_dev);		fmerr("Could not register video device/n");		return -ENOMEM;	}	fmdev->radio_dev = gradio_dev;	/* Register to v4l2 ctrl handler framework */	fmdev->radio_dev->ctrl_handler = &fmdev->ctrl_handler;	ret = v4l2_ctrl_handler_init(&fmdev->ctrl_handler, 5);	if (ret < 0) {		fmerr("(fmdev): Can't init ctrl handler/n");		v4l2_ctrl_handler_free(&fmdev->ctrl_handler);		return -EBUSY;	}	/*	 * Following controls are handled by V4L2 control framework.	 * Added in ascending ID order.	 */	v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,			V4L2_CID_AUDIO_VOLUME, FM_RX_VOLUME_MIN,			FM_RX_VOLUME_MAX, 1, FM_RX_VOLUME_MAX);	v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,			V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);	v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,			V4L2_CID_RDS_TX_PI, 0x0, 0xffff, 1, 0x0);	v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,			V4L2_CID_RDS_TX_PTY, 0, 32, 1, 0);	v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,			V4L2_CID_RDS_TX_PS_NAME, 0, 0xffff, 1, 0);	v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,			V4L2_CID_RDS_TX_RADIO_TEXT, 0, 0xffff, 1, 0);	v4l2_ctrl_new_std_menu(&fmdev->ctrl_handler, &fm_ctrl_ops,			V4L2_CID_TUNE_PREEMPHASIS, V4L2_PREEMPHASIS_75_uS,			0, V4L2_PREEMPHASIS_75_uS);	v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,			V4L2_CID_TUNE_POWER_LEVEL, FM_PWR_LVL_LOW,			FM_PWR_LVL_HIGH, 1, FM_PWR_LVL_HIGH);	ctrl = v4l2_ctrl_new_std(&fmdev->ctrl_handler, &fm_ctrl_ops,			V4L2_CID_TUNE_ANTENNA_CAPACITOR, 0,			255, 1, 255);	if (ctrl)		ctrl->is_volatile = 1;	return 0;}
开发者ID:LeaderRider,项目名称:kernel3NookTablet,代码行数:81,


示例21: fimc_isp_video_device_register

int fimc_isp_video_device_register(struct fimc_isp *isp,				   struct v4l2_device *v4l2_dev,				   enum v4l2_buf_type type){	struct vb2_queue *q = &isp->video_capture.vb_queue;	struct fimc_is_video *iv;	struct video_device *vdev;	int ret;	if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)		iv = &isp->video_capture;	else		return -ENOSYS;	mutex_init(&isp->video_lock);	INIT_LIST_HEAD(&iv->pending_buf_q);	INIT_LIST_HEAD(&iv->active_buf_q);	iv->format = fimc_isp_find_format(NULL, NULL, 0);	iv->pixfmt.width = IS_DEFAULT_WIDTH;	iv->pixfmt.height = IS_DEFAULT_HEIGHT;	iv->pixfmt.pixelformat = iv->format->fourcc;	iv->pixfmt.colorspace = V4L2_COLORSPACE_SRGB;	iv->reqbufs_count = 0;	memset(q, 0, sizeof(*q));	q->type = type;	q->io_modes = VB2_MMAP | VB2_USERPTR;	q->ops = &isp_video_capture_qops;	q->mem_ops = &vb2_dma_contig_memops;	q->buf_struct_size = sizeof(struct isp_video_buf);	q->drv_priv = isp;	q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;	q->lock = &isp->video_lock;	ret = vb2_queue_init(q);	if (ret < 0)		return ret;	vdev = &iv->ve.vdev;	memset(vdev, 0, sizeof(*vdev));	snprintf(vdev->name, sizeof(vdev->name), "fimc-is-isp.%s",			type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ?			"capture" : "output");	vdev->queue = q;	vdev->fops = &isp_video_fops;	vdev->ioctl_ops = &isp_video_ioctl_ops;	vdev->v4l2_dev = v4l2_dev;	vdev->minor = -1;	vdev->release = video_device_release_empty;	vdev->lock = &isp->video_lock;	iv->pad.flags = MEDIA_PAD_FL_SINK;	ret = media_entity_pads_init(&vdev->entity, 1, &iv->pad);	if (ret < 0)		return ret;	video_set_drvdata(vdev, isp);	ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1);	if (ret < 0) {		media_entity_cleanup(&vdev->entity);		return ret;	}	v4l2_info(v4l2_dev, "Registered %s as /dev/%s/n",		  vdev->name, video_device_node_name(vdev));	return 0;}
开发者ID:a2hojsjsjs,项目名称:linux,代码行数:69,


示例22: si470x_i2c_probe

/* * si470x_i2c_probe - probe for the device */static int __devinit si470x_i2c_probe(struct i2c_client *client,		const struct i2c_device_id *id){	struct si470x_device *radio;	int retval = 0;	unsigned char version_warning = 0;	/* private data allocation and initialization */	radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL);	if (!radio) {		retval = -ENOMEM;		goto err_initial;	}	radio->users = 0;	radio->client = client;	mutex_init(&radio->lock);	/* video device allocation and initialization */	radio->videodev = video_device_alloc();	if (!radio->videodev) {		retval = -ENOMEM;		goto err_radio;	}	memcpy(radio->videodev, &si470x_viddev_template,			sizeof(si470x_viddev_template));	video_set_drvdata(radio->videodev, radio);	/* power up : need 110ms */	radio->registers[POWERCFG] = POWERCFG_ENABLE;	if (si470x_set_register(radio, POWERCFG) < 0) {		retval = -EIO;		goto err_video;	}	msleep(110);	/* get device and chip versions */	if (si470x_get_all_registers(radio) < 0) {		retval = -EIO;		goto err_video;	}	dev_info(&client->dev, "DeviceID=0x%4.4hx ChipID=0x%4.4hx/n",			radio->registers[DEVICEID], radio->registers[CHIPID]);	if ((radio->registers[CHIPID] & CHIPID_FIRMWARE) < RADIO_FW_VERSION) {		dev_warn(&client->dev,			"This driver is known to work with "			"firmware version %hu,/n", RADIO_FW_VERSION);		dev_warn(&client->dev,			"but the device has firmware version %hu./n",			radio->registers[CHIPID] & CHIPID_FIRMWARE);		version_warning = 1;	}	/* give out version warning */	if (version_warning == 1) {		dev_warn(&client->dev,			"If you have some trouble using this driver,/n");		dev_warn(&client->dev,			"please report to V4L ML at "			"[email
C++ video_unregister_device函数代码示例
C++ video_init函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。