这篇教程C++ video_device_alloc函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中video_device_alloc函数的典型用法代码示例。如果您正苦于以下问题:C++ video_device_alloc函数的具体用法?C++ video_device_alloc怎么用?C++ video_device_alloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了video_device_alloc函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: fimc_register_capture_device/* fimc->lock must be already initialized */int fimc_register_capture_device(struct fimc_dev *fimc){ struct v4l2_device *v4l2_dev = &fimc->vid_cap.v4l2_dev; struct video_device *vfd; struct fimc_vid_cap *vid_cap; struct fimc_ctx *ctx; struct v4l2_format f; struct fimc_frame *fr; struct vb2_queue *q; int ret; ctx = kzalloc(sizeof *ctx, GFP_KERNEL); if (!ctx) return -ENOMEM; ctx->fimc_dev = fimc; ctx->in_path = FIMC_CAMERA; ctx->out_path = FIMC_DMA; ctx->state = FIMC_CTX_CAP; /* Default format of the output frames */ f.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32; fr = &ctx->d_frame; fr->fmt = find_format(&f, FMT_FLAGS_M2M); fr->width = fr->f_width = fr->o_width = 640; fr->height = fr->f_height = fr->o_height = 480; if (!v4l2_dev->name[0]) snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s.capture", dev_name(&fimc->pdev->dev)); ret = v4l2_device_register(NULL, v4l2_dev); if (ret) goto err_info; vfd = video_device_alloc(); if (!vfd) { v4l2_err(v4l2_dev, "Failed to allocate video device/n"); goto err_v4l2_reg; } snprintf(vfd->name, sizeof(vfd->name), "%s:cap", dev_name(&fimc->pdev->dev)); vfd->fops = &fimc_capture_fops; vfd->ioctl_ops = &fimc_capture_ioctl_ops; vfd->minor = -1; vfd->release = video_device_release; vfd->lock = &fimc->lock; video_set_drvdata(vfd, fimc); vid_cap = &fimc->vid_cap; vid_cap->vfd = vfd; vid_cap->active_buf_cnt = 0; vid_cap->reqbufs_count = 0; vid_cap->refcnt = 0; /* Default color format for image sensor */ vid_cap->fmt.code = V4L2_MBUS_FMT_YUYV8_2X8; INIT_LIST_HEAD(&vid_cap->pending_buf_q); INIT_LIST_HEAD(&vid_cap->active_buf_q); spin_lock_init(&ctx->slock); vid_cap->ctx = ctx; q = &fimc->vid_cap.vbq; memset(q, 0, sizeof(*q)); q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; q->io_modes = VB2_MMAP | VB2_USERPTR; q->drv_priv = fimc->vid_cap.ctx; q->ops = &fimc_capture_qops; q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size = sizeof(struct fimc_vid_buffer); vb2_queue_init(q); ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); if (ret) { v4l2_err(v4l2_dev, "Failed to register video device/n"); goto err_vd_reg; } v4l2_info(v4l2_dev, "FIMC capture driver registered as /dev/video%d/n", vfd->num); return 0;err_vd_reg: video_device_release(vfd);err_v4l2_reg: v4l2_device_unregister(v4l2_dev);err_info: kfree(ctx); dev_err(&fimc->pdev->dev, "failed to install/n"); return ret;}
开发者ID:jerem,项目名称:hi35xx-buildroot,代码行数:97,
示例2: vcap_probestatic int __devinit vcap_probe(struct platform_device *pdev){ struct vcap_dev *dev; struct video_device *vfd; int ret; dprintk(1, "Probe started/n"); dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; vcap_ctrl = dev; dev->vcap_pdata = pdev->dev.platform_data; dev->vcapmem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vcap"); if (!dev->vcapmem) { pr_err("VCAP: %s: no mem resource?/n", __func__); ret = -ENODEV; goto free_dev; } dev->vcapio = request_mem_region(dev->vcapmem->start, resource_size(dev->vcapmem), pdev->name); if (!dev->vcapio) { pr_err("VCAP: %s: no valid mem region/n", __func__); ret = -EBUSY; goto free_dev; } dev->vcapbase = ioremap(dev->vcapmem->start, resource_size(dev->vcapmem)); if (!dev->vcapbase) { ret = -ENOMEM; pr_err("VCAP: %s: vcap ioremap failed/n", __func__); goto free_resource; } dev->vcirq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "vc_irq"); 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;//.........这里部分代码省略.........
开发者ID:SmokyBob,项目名称:android_kernel_asus_padfone2,代码行数:101,
示例3: call_all format.format.height = dev->height; format.format.field = dev->field; call_all(dev, pad, set_fmt, NULL, &format); return 0;}static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, struct pci_dev *pci, struct video_device *template, char *type){ struct video_device *vfd; dprintk(1, "%s()/n", __func__); vfd = video_device_alloc(); if (NULL == vfd) return NULL; *vfd = *template; vfd->v4l2_dev = &dev->v4l2_dev; vfd->release = video_device_release; vfd->lock = &dev->lock; snprintf(vfd->name, sizeof(vfd->name), "%s (%s)", cx23885_boards[dev->board].name, type); video_set_drvdata(vfd, dev); return vfd;}int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data){ /* 8 bit registers, 8 bit values */
开发者ID:ezequielgarcia,项目名称:linux,代码行数:31,
示例4: 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,
示例5: si4703_probestatic int si4703_probe(struct i2c_client *client){ uint16_t id; int ret; struct si4703_device *chip; struct si4703_platform_data *pdata = client->dev.platform_data; chip = kmalloc(sizeof(struct si4703_device), GFP_KERNEL); if (!chip) return -ENOMEM; chip->videodev = video_device_alloc(); if (!chip->videodev) { kfree(chip); return -ENOMEM; } chip->client = client; chip->irq = client->irq; init_waitqueue_head(&chip->wait); i2c_set_clientdata(client, chip); enable_oscc_tout_s0(); pdata->setup(client, pdata->context); if (chip->irq >= 0) { ret = request_irq(chip->irq, si4703_irq_handler, IRQF_TRIGGER_FALLING, "si4703", chip); if (ret) { kfree(chip->videodev); kfree(chip); printk(KERN_ERR "request IRQ for si4703 failed!/n"); return ret; } } /* init shadow registers */ if (si4703_read(chip, REG_READ_START - 1, &id)) { free_irq(chip->irq, chip); kfree(chip->videodev); kfree(chip); printk(KERN_ERR "%s: failed to init shadow registers/n", __FUNCTION__); disable_oscc_tout_s0(); return -EIO; } si4703_power_up(chip); ret = si4703_read(chip, REG_CHIPID, &id); if (ret) printk(KERN_ERR "%s: failed to detect si4703/n", __FUNCTION__); else printk(KERN_INFO "%s: si4703(0x%04x) detected/n", __FUNCTION__, id); si4703_power_down(chip); /* init volume to maxium */ chip->curvol = 0xf; memcpy(chip->videodev, &si4703_videodev_template, sizeof(si4703_videodev_template)); chip->removed = 0; chip->users = 0; chip->curfreq = FREQ_MIN*FREQ_MUL; video_set_drvdata(chip->videodev, chip); if (video_register_device(chip->videodev, VFL_TYPE_RADIO, 0)) { printk(KERN_ERR "Could not register video device"); free_irq(chip->irq, chip); video_device_release(chip->videodev); kfree(chip->videodev); kfree(chip); disable_oscc_tout_s0(); return -EIO; } disable_oscc_tout_s0(); return 0;}
开发者ID:abgoyal,项目名称:OpenX2-kernel-original,代码行数:76,
示例6: empress_initstatic 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,
示例7: fimc_lite_subdev_registeredstatic int fimc_lite_subdev_registered(struct v4l2_subdev *sd){ struct fimc_lite *fimc = v4l2_get_subdevdata(sd); struct vb2_queue *q = &fimc->vb_queue; struct video_device *vfd; int ret; fimc->fmt = &fimc_lite_formats[0]; fimc->out_path = FIMC_IO_DMA; vfd = video_device_alloc(); if (!vfd) { v4l2_err(sd->v4l2_dev, "Failed to allocate video device/n"); return -ENOMEM; } snprintf(vfd->name, sizeof(vfd->name), "fimc-lite.%d.capture", fimc->index); vfd->fops = &fimc_lite_fops; vfd->ioctl_ops = &fimc_lite_ioctl_ops; vfd->v4l2_dev = sd->v4l2_dev; vfd->minor = -1; vfd->release = video_device_release; vfd->lock = &fimc->lock; fimc->vfd = vfd; fimc->ref_count = 0; fimc->reqbufs_count = 0; INIT_LIST_HEAD(&fimc->pending_buf_q); INIT_LIST_HEAD(&fimc->active_buf_q); memset(q, 0, sizeof(*q)); q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; q->io_modes = VB2_MMAP | VB2_USERPTR; q->ops = &fimc_lite_qops; q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size = sizeof(struct flite_buffer); q->drv_priv = fimc; vb2_queue_init(q); fimc->vd_pad.flags = MEDIA_PAD_FL_SINK; ret = media_entity_init(&vfd->entity, 1, &fimc->vd_pad, 0); if (ret) goto err; video_set_drvdata(vfd, fimc); ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); if (ret) goto err_vd; v4l2_info(sd->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: video_device_release(vfd); return ret;}
开发者ID:Frontier314,项目名称:frontkernel35,代码行数:63,
示例8: g2d_probestatic int g2d_probe(struct platform_device *pdev){ struct g2d_dev *dev; struct video_device *vfd; struct resource *res; int ret = 0; dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; spin_lock_init(&dev->ctrl_lock); mutex_init(&dev->mutex); atomic_set(&dev->num_inst, 0); init_waitqueue_head(&dev->irq_queue); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "failed to find registers/n"); ret = -ENOENT; goto free_dev; } dev->res_regs = request_mem_region(res->start, resource_size(res), dev_name(&pdev->dev)); if (!dev->res_regs) { dev_err(&pdev->dev, "failed to obtain register region/n"); ret = -ENOENT; goto free_dev; } dev->regs = ioremap(res->start, resource_size(res)); if (!dev->regs) { dev_err(&pdev->dev, "failed to map registers/n"); ret = -ENOENT; goto rel_res_regs; } dev->clk = clk_get(&pdev->dev, "sclk_fimg2d"); if (IS_ERR_OR_NULL(dev->clk)) { dev_err(&pdev->dev, "failed to get g2d clock/n"); ret = -ENXIO; goto unmap_regs; } ret = clk_prepare(dev->clk); if (ret) { dev_err(&pdev->dev, "failed to prepare g2d clock/n"); goto put_clk; } dev->gate = clk_get(&pdev->dev, "fimg2d"); if (IS_ERR_OR_NULL(dev->gate)) { dev_err(&pdev->dev, "failed to get g2d clock gate/n"); ret = -ENXIO; goto unprep_clk; } ret = clk_prepare(dev->gate); if (ret) { dev_err(&pdev->dev, "failed to prepare g2d clock gate/n"); goto put_clk_gate; } res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { dev_err(&pdev->dev, "failed to find IRQ/n"); ret = -ENXIO; goto unprep_clk_gate; } dev->irq = res->start; ret = request_irq(dev->irq, g2d_isr, 0, pdev->name, dev); if (ret) { dev_err(&pdev->dev, "failed to install IRQ/n"); goto put_clk_gate; } dev->alloc_ctx = vb2_dma_contig_init_ctx(&pdev->dev); if (IS_ERR(dev->alloc_ctx)) { ret = PTR_ERR(dev->alloc_ctx); goto rel_irq; } ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) goto alloc_ctx_cleanup; vfd = video_device_alloc(); if (!vfd) { v4l2_err(&dev->v4l2_dev, "Failed to allocate video device/n"); ret = -ENOMEM; goto unreg_v4l2_dev; } *vfd = g2d_videodev; vfd->lock = &dev->mutex; ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); if (ret) { v4l2_err(&dev->v4l2_dev, "Failed to register video device/n"); goto rel_vdev;//.........这里部分代码省略.........
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:101,
示例9: create_pipestatic int create_pipe(int nr){ int minor_in, minor_out , ret; if (debug > LOG_NODEBUG) info("Video loopback %d", nr); if (dev_offset == -1) { minor_in = minor_out = -1; /* autoassign */ } else { minor_in = 2 * nr + dev_offset; minor_out = 2 * nr + 1 + dev_offset; } /* allocate space for this pipe */ loops[nr]= kmalloc(sizeof(struct vloopback_pipe), GFP_KERNEL); if (!loops[nr]) return -ENOMEM; /* set up a new video device plus our private area */ loops[nr]->vloopin = video_device_alloc(); if (loops[nr]->vloopin == NULL) return -ENOMEM; *loops[nr]->vloopin = vloopback_template;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) priv_ptr ptr_in = kmalloc(sizeof(struct vloopback_private), GFP_KERNEL); if (ptr_in == NULL) { kfree(ptr_in);#else loops[nr]->vloopin->vd_private_data = kmalloc(sizeof(struct vloopback_private), GFP_KERNEL); if (loops[nr]->vloopin->vd_private_data == NULL) { kfree(loops[nr]->vloopin);#endif return -ENOMEM; } /* repeat for the output device */ loops[nr]->vloopout = video_device_alloc(); if (loops[nr]->vloopout == NULL) {#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) kfree(ptr_in);#else kfree(loops[nr]->vloopin->vd_private_data);#endif kfree(loops[nr]->vloopin); return -ENOMEM; } *loops[nr]->vloopout = vloopback_template;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) priv_ptr ptr_out = kmalloc(sizeof(struct vloopback_private), GFP_KERNEL); if (ptr_out == NULL) { kfree(ptr_in); kfree(ptr_out);#else loops[nr]->vloopout->vd_private_data = kmalloc(sizeof(struct vloopback_private), GFP_KERNEL); if (loops[nr]->vloopout->vd_private_data == NULL) { kfree(loops[nr]->vloopin->vd_private_data);#endif kfree(loops[nr]->vloopin); kfree(loops[nr]->vloopout); return -ENOMEM; }#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) ptr_in->pipenr = nr; ptr_out->pipenr = nr;#else ((priv_ptr)loops[nr]->vloopin->vd_private_data)->pipenr = nr; ((priv_ptr)loops[nr]->vloopout->vd_private_data)->pipenr = nr;#endif loops[nr]->invalid_ioctl = 0; /* tibit */ loops[nr]->buffer = NULL; loops[nr]->width = 0; loops[nr]->height = 0; loops[nr]->palette = 0; loops[nr]->frameswrite = 0; loops[nr]->framesread = 0; loops[nr]->framesdumped = 0; loops[nr]->wopen = 0; loops[nr]->ropen = 0; loops[nr]->frame = 0;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32) ptr_in->in = 1; ptr_out->in = 0; dev_set_drvdata(&loops[nr]->vloopin->dev, ptr_in); dev_set_drvdata(&loops[nr]->vloopout->dev, ptr_out);#else ((priv_ptr)loops[nr]->vloopin->vd_private_data)->in = 1; ((priv_ptr)loops[nr]->vloopout->vd_private_data)->in = 0;#endif sprintf(loops[nr]->vloopin->name, "Video loopback %d input", nr); sprintf(loops[nr]->vloopout->name, "Video loopback %d output", nr);//.........这里部分代码省略.........
开发者ID:rfajardo,项目名称:devmech,代码行数:101,
示例10: rot_register_m2m_devicestatic int rot_register_m2m_device(struct rot_dev *rot){ struct v4l2_device *v4l2_dev; struct platform_device *pdev; struct video_device *vfd; int ret = 0; if (!rot) return -ENODEV; pdev = rot->pdev; v4l2_dev = &rot->m2m.v4l2_dev; /* Set name to "device name.m2m" if it is empty */ if (!v4l2_dev->name[0]) snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s.m2m", dev_name(&pdev->dev)); ret = v4l2_device_register(&pdev->dev, v4l2_dev); if (ret) { rot_err("failed to register v4l2 device/n"); return ret; } vfd = video_device_alloc(); if (!vfd) { rot_err("failed to allocate video device/n"); goto err_v4l2_dev; } vfd->fops = &rot_v4l2_fops; vfd->ioctl_ops = &rot_v4l2_ioctl_ops; vfd->release = video_device_release; video_set_drvdata(vfd, rot); platform_set_drvdata(pdev, rot); rot->m2m.vfd = vfd; rot->m2m.m2m_dev = v4l2_m2m_init(&rot_m2m_ops); if (IS_ERR(rot->m2m.m2m_dev)) { rot_err("failed to initialize v4l2-m2m device/n"); ret = PTR_ERR(rot->m2m.m2m_dev); goto err_dev_alloc; } ret = video_register_device(vfd, VFL_TYPE_GRABBER, EXYNOS_VIDEONODE_ROTATOR); if (ret) { rot_err("failed to register video device/n"); goto err_m2m_dev; } return 0;err_m2m_dev: v4l2_m2m_release(rot->m2m.m2m_dev);err_dev_alloc: video_device_release(rot->m2m.vfd);err_v4l2_dev: v4l2_device_unregister(v4l2_dev); return ret;}
开发者ID:danielyuan2015,项目名称:Exynos4412,代码行数:63,
示例11: device_list/* return a list of available devices. the default device (if any) will be * the first in the list. */static GList *device_list (GstOSXVideoSrc * src){ SeqGrabComponent component = NULL; SGChannel channel; SGDeviceList deviceList; SGDeviceName *deviceEntry; SGDeviceInputList inputList; SGDeviceInputName *inputEntry; ComponentResult err; int n, i; GList *list; video_device *dev, *default_dev; gchar sgname[256]; gchar friendly_name[256]; list = NULL; default_dev = NULL; if (src->video_chan) { /* if we already have a video channel allocated, use that */ GST_DEBUG_OBJECT (src, "reusing existing channel for device_list"); channel = src->video_chan; } else { /* otherwise, allocate a temporary one */ component = OpenDefaultComponent (SeqGrabComponentType, 0); if (!component) { err = paramErr; GST_ERROR_OBJECT (src, "OpenDefaultComponent failed. paramErr=%d", (int) err); goto end; } err = SGInitialize (component); if (err != noErr) { GST_ERROR_OBJECT (src, "SGInitialize returned %d", (int) err); goto end; } err = SGSetDataRef (component, 0, 0, seqGrabDontMakeMovie); if (err != noErr) { GST_ERROR_OBJECT (src, "SGSetDataRef returned %d", (int) err); goto end; } err = SGNewChannel (component, VideoMediaType, &channel); if (err != noErr) { GST_ERROR_OBJECT (src, "SGNewChannel returned %d", (int) err); goto end; } } err = SGGetChannelDeviceList (channel, sgDeviceListIncludeInputs, &deviceList); if (err != noErr) { GST_ERROR_OBJECT (src, "SGGetChannelDeviceList returned %d", (int) err); goto end; } for (n = 0; n < (*deviceList)->count; ++n) { deviceEntry = &(*deviceList)->entry[n]; if (deviceEntry->flags & sgDeviceNameFlagDeviceUnavailable) continue; p2cstrcpy (sgname, deviceEntry->name); inputList = deviceEntry->inputs; if (inputList && (*inputList)->count >= 1) { for (i = 0; i < (*inputList)->count; ++i) { inputEntry = &(*inputList)->entry[i]; p2cstrcpy (friendly_name, inputEntry->name); dev = video_device_alloc (); dev->id = create_device_id (sgname, i); if (!dev->id) { video_device_free (dev); i = -1; break; } dev->name = g_strdup (friendly_name); list = g_list_append (list, dev); /* if this is the default device, note it */ if (n == (*deviceList)->selectedIndex && i == (*inputList)->selectedIndex) { default_dev = dev; } } /* error */ if (i == -1) break; } else { /* ### can a device have no defined inputs? *///.........这里部分代码省略.........
开发者ID:ChinnaSuhas,项目名称:ossbuild,代码行数:101,
示例12: vpp_initint __init vpp_init(void){ int ret = 0; struct video_device *video_dev = NULL; logi("in vpp_init: vpp_phymem = 0x%x, camera_phymem = 0x%x, codec_phymem = 0x%x/n", hisi_reserved_vpp_phymem, hisi_reserved_camera_phymem, hisi_reserved_codec_phymem); /* alloc memory for video device */ video_dev = video_device_alloc(); if (NULL == video_dev) { loge("alloc video device failed/n"); ret = -ENOMEM; goto err; } /* init v4l device */ s_interrupt_cond = false; *video_dev = s_vpp_device; /* register vpp device */ if (video_register_device(video_dev, 0, VPP_DEVICE_ID)) { loge("video device register failed/n"); ret = -EINVAL; goto err; } s_vpp_device_p = video_dev; /*init the wait queue*/ init_waitqueue_head(&s_wait_queue); /*register a irq for vpp*/ ret = request_irq(IRQ_VPP, vpp_isr, 0, "VPP", NULL); if(ret != 0) { loge("fail to request irq, ret = 0x%x/n",ret); goto err; } s_vdec_vcc = regulator_get(NULL, "vcc_vdec"); if (IS_ERR(s_vdec_vcc)) { loge("%s: failed to get vcc_vdec regulator/n", __func__); ret = PTR_ERR(s_vdec_vcc); s_vdec_vcc = NULL; goto err; } s_clk = clk_get(NULL, "clk_vpp"); if (IS_ERR(s_clk)) { loge("get clock failed/n"); ret = PTR_ERR(s_clk); goto err; } hal_init(); return ret; err: loge("module not inserted/n"); if (NULL != s_vpp_device_p) { video_unregister_device(video_dev); s_vpp_device_p = NULL; } if(NULL != video_dev) { kfree(video_dev); video_dev = NULL; } if (NULL != s_vdec_vcc) { regulator_put(s_vdec_vcc); s_vdec_vcc = NULL; } return ret;}
开发者ID:printusrzero,项目名称:hwp6s-kernel,代码行数:82,
示例13: vpif_probe/* * vpif_probe: This function creates device entries by register itself to the * V4L2 driver and initializes fields of each channel objects */static __init int vpif_probe(struct platform_device *pdev){ struct vpif_subdev_info *subdevdata; struct vpif_display_config *config; int i, j = 0, k, q, m, err = 0; struct i2c_adapter *i2c_adap; struct common_obj *common; struct channel_obj *ch; 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; } err = v4l2_device_register(vpif_dev, &vpif_obj.v4l2_dev); if (err) { v4l2_err(vpif_dev->driver, "Error registering v4l2 device/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_Display", (void *)(&vpif_obj.dev[k]->channel_id))) { err = -EBUSY; goto vpif_int_err; } } k++; } for (i = 0; i < VPIF_DISPLAY_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 (vfd == NULL) { for (j = 0; j < i; j++) { ch = vpif_obj.dev[j]; video_device_release(ch->video_dev); } err = -ENOMEM; goto vpif_int_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_VPIFDisplay_DRIVER_V%d.%d.%d", (VPIF_DISPLAY_VERSION_CODE >> 16) & 0xff, (VPIF_DISPLAY_VERSION_CODE >> 8) & 0xff, (VPIF_DISPLAY_VERSION_CODE) & 0xff); /* Set video_dev to the video device */ ch->video_dev = vfd; } for (j = 0; j < VPIF_DISPLAY_MAX_DEVICES; j++) { ch = vpif_obj.dev[j]; /* Initialize field of the channel objects */ atomic_set(&ch->usrs, 0); for (k = 0; k < VPIF_NUMOBJECTS; k++) { ch->common[k].numbuffers = 0; common = &ch->common[k]; common->io_usrs = 0; common->started = 0; spin_lock_init(&common->irqlock); mutex_init(&common->lock); common->numbuffers = 0; common->set_addr = NULL; common->ytop_off = common->ybtm_off = 0; common->ctop_off = common->cbtm_off = 0; common->cur_frm = common->next_frm = NULL; memset(&common->fmt, 0, sizeof(common->fmt)); common->numbuffers = config_params.numbuffers[k]; } ch->initialized = 0; ch->channel_id = j; if (j < 2) ch->common[VPIF_VIDEO_INDEX].numbuffers = config_params.numbuffers[ch->channel_id]; else//.........这里部分代码省略.........
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:101,
示例14: gsc_register_capture_deviceint gsc_register_capture_device(struct gsc_dev *gsc){ struct video_device *vfd; struct gsc_capture_device *gsc_cap; struct gsc_ctx *ctx; struct vb2_queue *q; struct exynos_platform_gscaler *pdata = gsc->pdata; struct exynos_isp_info *isp_info; int ret = -ENOMEM; int i; ctx = kzalloc(sizeof *ctx, GFP_KERNEL); if (!ctx) return -ENOMEM; ctx->gsc_dev = gsc; ctx->in_path = GSC_CAMERA; ctx->out_path = GSC_DMA; ctx->state = GSC_CTX_CAP; vfd = video_device_alloc(); if (!vfd) { printk("Failed to allocate video device/n"); goto err_ctx_alloc; } snprintf(vfd->name, sizeof(vfd->name), "%s.capture", dev_name(&gsc->pdev->dev)); vfd->fops = &gsc_capture_fops; vfd->ioctl_ops = &gsc_capture_ioctl_ops; vfd->v4l2_dev = &gsc->mdev[MDEV_CAPTURE]->v4l2_dev; vfd->minor = -1; vfd->release = video_device_release; vfd->lock = &gsc->lock; video_set_drvdata(vfd, gsc); gsc_cap = &gsc->cap; gsc_cap->vfd = vfd; gsc_cap->refcnt = 0; gsc_cap->active_buf_cnt = 0; gsc_cap->reqbufs_cnt = 0; spin_lock_init(&ctx->slock); gsc_cap->ctx = ctx; q = &gsc->cap.vbq; memset(q, 0, sizeof(*q)); q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; q->drv_priv = gsc->cap.ctx; q->ops = &gsc_capture_qops; q->mem_ops = gsc->vb2->ops; vb2_queue_init(q); /* Get mipi-csis and fimc-lite subdev ptr using mdev */ for (i = 0; i < FLITE_MAX_ENTITIES; i++) gsc->cap.sd_flite[i] = gsc->mdev[MDEV_CAPTURE]->flite_sd[i]; for (i = 0; i < CSIS_MAX_ENTITIES; i++) gsc->cap.sd_csis[i] = gsc->mdev[MDEV_CAPTURE]->csis_sd[i]; if (soc_is_exynos5250()) { for (i = 0; i < pdata->num_clients; i++) { isp_info = pdata->isp_info[i]; ret = gsc_cap_config_camclk(gsc, isp_info, i); if (ret) { gsc_err("failed setup cam clk"); goto err_ctx_alloc; } } } ret = gsc_cap_register_sensor_entities(gsc); if (ret) { gsc_err("failed register sensor entities"); goto err_clk; } ret = video_register_device(vfd, VFL_TYPE_GRABBER, EXYNOS_VIDEONODE_GSC_CAP(gsc->id)); if (ret) { gsc_err("failed to register video device"); goto err_clk; } gsc->cap.vd_pad.flags = MEDIA_PAD_FL_SOURCE; ret = media_entity_init(&vfd->entity, 1, &gsc->cap.vd_pad, 0); if (ret) { gsc_err("failed to initialize entity"); goto err_ent; } ret = gsc_capture_create_subdev(gsc); if (ret) { gsc_err("failed create subdev"); goto err_sd_reg; }//.........这里部分代码省略.........
开发者ID:hedongjie,项目名称:m35x,代码行数:101,
示例15: fm_v4l2_init_video_deviceint 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,
示例16: cam_dummy_platform_probestatic int32_t cam_dummy_platform_probe(struct platform_device *pdev){ int32_t rc = 0; const struct of_device_id *match; struct msm_video_device *pvdev; /* init_waitqueue_head(&cam_dummy_queue.state_wait);*/ pr_err("%s:%d/n", __func__, __LINE__); match = of_match_device(cam_dummy_dt_match, &pdev->dev); msm_v4l2_dev = kzalloc(sizeof(*msm_v4l2_dev), GFP_KERNEL); if (WARN_ON(!msm_v4l2_dev)) { rc = -ENOMEM; goto probe_end; } pvdev = kzalloc(sizeof(struct msm_video_device), GFP_KERNEL); if (WARN_ON(!pvdev)) { rc = -ENOMEM; goto pvdev_fail; } pvdev->vdev = video_device_alloc(); if (WARN_ON(!pvdev->vdev)) { rc = -ENOMEM; goto video_fail; }#if defined(CONFIG_MEDIA_CONTROLLER) msm_v4l2_dev->mdev = kzalloc(sizeof(struct media_device), GFP_KERNEL); if (!msm_v4l2_dev->mdev) { rc = -ENOMEM; goto mdev_fail; } strlcpy(msm_v4l2_dev->mdev->model, MSM_CAMERA_DUMMY_NAME, sizeof(msm_v4l2_dev->mdev->model)); msm_v4l2_dev->mdev->dev = &(pdev->dev); rc = media_device_register(msm_v4l2_dev->mdev); if (WARN_ON(rc < 0)) goto media_fail; if (WARN_ON((rc == media_entity_init(&pvdev->vdev->entity, 0, NULL, 0)) < 0)) goto entity_fail; pvdev->vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L; pvdev->vdev->entity.group_id = QCAMERA_VNODE_GROUP_ID;#endif pvdev->vdev->v4l2_dev = msm_v4l2_dev; rc = v4l2_device_register(&(pdev->dev), pvdev->vdev->v4l2_dev); if (WARN_ON(rc < 0)) goto register_fail; strlcpy(pvdev->vdev->name, "msm-camdummy", sizeof(pvdev->vdev->name)); pvdev->vdev->release = video_device_release; pvdev->vdev->fops = &msm_fops_config; 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 v4l2_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 atomic_set(&pvdev->opened, 0); video_set_drvdata(pvdev->vdev, pvdev); goto probe_end;v4l2_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(msm_v4l2_dev->mdev);media_fail: kzfree(msm_v4l2_dev->mdev);mdev_fail:#endif video_device_release(pvdev->vdev);video_fail: kzfree(pvdev);pvdev_fail: kzfree(msm_v4l2_dev);probe_end: return rc;}
开发者ID:DAGr8,项目名称:kernel_samsung_hltecan,代码行数:98,
示例17: create_pipestatic int create_pipe(int nr){ int minor_in, minor_out , ret; if (dev_offset == -1) { if (inminor == -1) { minor_in = -1; } else { minor_in = inminor+nr; } if (outminor == -1) { minor_out = -1; } else { minor_out = outminor+nr; } } else { minor_in = 2*nr + dev_offset; minor_out = 2*nr+1 + dev_offset; } /* allocate space for this pipe */ loops[nr]= kmalloc(sizeof(struct vloopback_pipe), GFP_KERNEL); if (!loops[nr]) return -ENOMEM; /* set up a new video device plus our private area */ loops[nr]->vloopin= video_device_alloc(); if (loops[nr]->vloopin == NULL) return -ENOMEM; *loops[nr]->vloopin = vloopback_template;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) video_set_drvdata(loops[nr]->vloopin,kmalloc(sizeof(struct vloopback_private),GFP_KERNEL));#else loops[nr]->vloopin->priv= kmalloc(sizeof(struct vloopback_private),GFP_KERNEL);#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) if ((priv_ptr)video_get_drvdata(loops[nr]->vloopin) == NULL) {#else if (loops[nr]->vloopin->priv == NULL) {#endif kfree(loops[nr]->vloopin); return -ENOMEM; } /* repeat for the output device */ loops[nr]->vloopout= video_device_alloc(); if (loops[nr]->vloopout == NULL) {#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) kfree((priv_ptr)video_get_drvdata(loops[nr]->vloopin));#else kfree(loops[nr]->vloopin->priv);#endif kfree(loops[nr]->vloopin); return -ENOMEM; } *loops[nr]->vloopout = vloopback_template;#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) video_set_drvdata(loops[nr]->vloopout,kmalloc(sizeof(struct vloopback_private),GFP_KERNEL));#else loops[nr]->vloopout->priv= kmalloc(sizeof(struct vloopback_private),GFP_KERNEL);#endif if ((priv_ptr)video_get_drvdata(loops[nr]->vloopout) == NULL) {#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) kfree((priv_ptr)video_get_drvdata(loops[nr]->vloopin));#else kfree(loops[nr]->vloopin->priv);#endif kfree(loops[nr]->vloopin); kfree(loops[nr]->vloopout); return -ENOMEM; }#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) ((priv_ptr)video_get_drvdata(loops[nr]->vloopin))->pipenr=nr; ((priv_ptr)video_get_drvdata(loops[nr]->vloopout))->pipenr=nr;#else ((priv_ptr)loops[nr]->vloopin->priv)->pipenr=nr; ((priv_ptr)loops[nr]->vloopout->priv)->pipenr=nr;#endif loops[nr]->invalid_ioctl = 0; /* tibit */ loops[nr]->buffer=NULL; loops[nr]->width=0; loops[nr]->height=0; loops[nr]->palette=0; loops[nr]->frameswrite=0; loops[nr]->framesread=0; loops[nr]->framesdumped=0; loops[nr]->wopen=0; loops[nr]->ropen=0; loops[nr]->frame=0; loops[nr]->pendingread=0; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27) ((priv_ptr)video_get_drvdata(loops[nr]->vloopin))->in=1; ((priv_ptr)video_get_drvdata(loops[nr]->vloopout))->in=0;#else ((priv_ptr)loops[nr]->vloopin->priv)->in=1; ((priv_ptr)loops[nr]->vloopout->priv)->in=0;#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)//.........这里部分代码省略.........
开发者ID:ravalnet,项目名称:xarxa-omnia,代码行数:101,
示例18: camera_core_initint __initcamera_core_init(void){ struct camera_device *cam; struct video_device *vfd; cam = kmalloc(sizeof(struct camera_device), GFP_KERNEL); if (!cam) { printk(KERN_ERR CAM_NAME ": could not allocate memory/n"); goto init_error; } memset(cam, 0, sizeof(struct camera_device)); /* Save the pointer to camera device in a global variable */ camera_dev = cam; cam->active = 0; /* initialize the video_device struct */ vfd = cam->vfd = video_device_alloc(); if (!vfd) { printk(KERN_ERR CAM_NAME ": could not allocate video device struct/n"); goto init_error; } vfd->release = video_device_release; strlcpy(vfd->name, CAM_NAME, sizeof(vfd->name)); vfd->type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY | VID_TYPE_CHROMAKEY; /* need to register for a VID_HARDWARE_* ID in videodev.h */ vfd->hardware = 0; vfd->fops = &camera_core_fops; video_set_drvdata(vfd, cam); vfd->minor = -1; /* initialize the videobuf queue ops */ cam->vbq_ops.buf_setup = camera_core_vbq_setup; cam->vbq_ops.buf_prepare = camera_core_vbq_prepare; cam->vbq_ops.buf_queue = camera_core_vbq_queue; cam->vbq_ops.buf_release = camera_core_vbq_release; /* initilize the overlay interface */ cam->overlay_size = overlay_mem; if (cam->overlay_size > 0) { cam->overlay_base = (unsigned long) dma_alloc_coherent(NULL, cam->overlay_size, (dma_addr_t *) &cam->overlay_base_phys, GFP_KERNEL | GFP_DMA); if (!cam->overlay_base) { printk(KERN_ERR CAM_NAME ": cannot allocate overlay framebuffer/n"); goto init_error; } } memset((void*)cam->overlay_base, 0, cam->overlay_size); spin_lock_init(&cam->overlay_lock); spin_lock_init(&cam->capture_lock); /*Initialise the pointer to the sensor interface and camera interface */ cam->cam_sensor = &camera_sensor_if; cam->cam_hardware = &camera_hardware_if; /* initialize the camera interface */ cam->hardware_data = cam->cam_hardware->init(); if (!cam->hardware_data) { printk(KERN_ERR CAM_NAME ": cannot initialize interface hardware/n"); goto init_error; } /* initialize the spinlock used to serialize access to the image * parameters */ spin_lock_init(&cam->img_lock); /* initialize the streaming capture parameters */ cam->cparm.capability = V4L2_CAP_TIMEPERFRAME; cam->cparm.readbuffers = 1; /* Enable the xclk output. The sensor may (and does, in the case of * the OV9640) require an xclk input in order for its initialization * routine to work. */ cam->xclk = 21000000; /* choose an arbitrary xclk frequency */ cam->xclk = cam->cam_hardware->set_xclk(cam->xclk, cam->hardware_data); /* initialize the sensor and define a default capture format cam->pix */ cam->sensor_data = cam->cam_sensor->init(&cam->pix); if (!cam->sensor_data) { cam->cam_hardware->disable(cam->hardware_data); printk(KERN_ERR CAM_NAME ": cannot initialize sensor/n"); goto init_error; } printk(KERN_INFO CAM_NAME ": %s interface with %s sensor/n", cam->cam_hardware->name, cam->cam_sensor->name); /* select an arbitrary default capture frame rate of 15fps */ cam->nominal_timeperframe.numerator = 1;//.........这里部分代码省略.........
开发者ID:GodFox,项目名称:magx_kernel_xpixl,代码行数:101,
示例19: ar_initstatic int __init ar_init(void){ struct ar_device *ar; int ret; int i; DEBUG(1, "ar_init:/n"); ret = -EIO; printk(KERN_INFO "arv: Colour AR VGA driver %s/n", VERSION); ar = &ardev; memset(ar, 0, sizeof(struct ar_device));#if USE_INT /* allocate a DMA buffer for 1 line. */ ar->line_buff = kmalloc(MAX_AR_LINE_BYTES, GFP_KERNEL | GFP_DMA); if (ar->line_buff == NULL || ! ALIGN4(ar->line_buff)) { printk("arv: buffer allocation failed for DMA./n"); ret = -ENOMEM; goto out_end; }#endif /* allocate buffers for a frame */ for (i = 0; i < MAX_AR_HEIGHT; i++) { ar->frame[i] = kmalloc(MAX_AR_LINE_BYTES, GFP_KERNEL); if (ar->frame[i] == NULL || ! ALIGN4(ar->frame[i])) { printk("arv: buffer allocation failed for frame./n"); ret = -ENOMEM; goto out_line_buff; } } ar->vdev = video_device_alloc(); if (!ar->vdev) { printk(KERN_ERR "arv: video_device_alloc() failed/n"); return -ENOMEM; } memcpy(ar->vdev, &ar_template, sizeof(ar_template)); ar->vdev->priv = ar; if (vga) { ar->width = AR_WIDTH_VGA; ar->height = AR_HEIGHT_VGA; ar->size = AR_SIZE_VGA; ar->frame_bytes = AR_FRAME_BYTES_VGA; ar->line_bytes = AR_LINE_BYTES_VGA; if (vga_interlace) ar->mode = AR_MODE_INTERLACE; else ar->mode = AR_MODE_NORMAL; } else { ar->width = AR_WIDTH_QVGA; ar->height = AR_HEIGHT_QVGA; ar->size = AR_SIZE_QVGA; ar->frame_bytes = AR_FRAME_BYTES_QVGA; ar->line_bytes = AR_LINE_BYTES_QVGA; ar->mode = AR_MODE_INTERLACE; } init_MUTEX(&ar->lock); init_waitqueue_head(&ar->wait);#if USE_INT if (request_irq(M32R_IRQ_INT3, ar_interrupt, 0, "arv", ar)) { printk("arv: request_irq(%d) failed./n", M32R_IRQ_INT3); ret = -EIO; goto out_irq; }#endif if (ar_initialize(ar->vdev) != 0) { printk("arv: M64278 not found./n"); ret = -ENODEV; goto out_dev; } /* * ok, we can initialize h/w according to parameters, * so register video device as a frame grabber type. * device is named "video[0-64]". * video_register_device() initializes h/w using ar_initialize(). */ if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) { /* return -1, -ENFILE(full) or others */ printk("arv: register video (Colour AR) failed./n"); ret = -ENODEV; goto out_dev; } printk("video%d: Found M64278 VGA (IRQ %d, Freq %dMHz)./n", ar->vdev->minor, M32R_IRQ_INT3, freq); return 0;out_dev:#if USE_INT free_irq(M32R_IRQ_INT3, ar);out_irq:#endif for (i = 0; i < MAX_AR_HEIGHT; i++)//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:tew632-brp-svn,代码行数:101,
示例20: solo_v4l2_initint solo_v4l2_init(struct solo_dev *solo_dev, unsigned nr){ int ret; int i; init_waitqueue_head(&solo_dev->disp_thread_wait); spin_lock_init(&solo_dev->slock); mutex_init(&solo_dev->lock); INIT_LIST_HEAD(&solo_dev->vidq_active); solo_dev->vfd = video_device_alloc(); if (!solo_dev->vfd) return -ENOMEM; *solo_dev->vfd = solo_v4l2_template; solo_dev->vfd->v4l2_dev = &solo_dev->v4l2_dev; solo_dev->vfd->queue = &solo_dev->vidq; solo_dev->vfd->lock = &solo_dev->lock; v4l2_ctrl_handler_init(&solo_dev->disp_hdl, 1); v4l2_ctrl_new_custom(&solo_dev->disp_hdl, &solo_motion_trace_ctrl, NULL); if (solo_dev->disp_hdl.error) { ret = solo_dev->disp_hdl.error; goto fail; } solo_dev->vfd->ctrl_handler = &solo_dev->disp_hdl; video_set_drvdata(solo_dev->vfd, solo_dev); solo_dev->vidq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; solo_dev->vidq.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; solo_dev->vidq.ops = &solo_video_qops; solo_dev->vidq.mem_ops = &vb2_dma_contig_memops; solo_dev->vidq.drv_priv = solo_dev; solo_dev->vidq.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; solo_dev->vidq.gfp_flags = __GFP_DMA32; solo_dev->vidq.buf_struct_size = sizeof(struct solo_vb2_buf); solo_dev->vidq.lock = &solo_dev->lock; ret = vb2_queue_init(&solo_dev->vidq); if (ret < 0) goto fail; solo_dev->alloc_ctx = vb2_dma_contig_init_ctx(&solo_dev->pdev->dev); if (IS_ERR(solo_dev->alloc_ctx)) { dev_err(&solo_dev->pdev->dev, "Can't allocate buffer context"); return PTR_ERR(solo_dev->alloc_ctx); } /* Cycle all the channels and clear */ for (i = 0; i < solo_dev->nr_chans; i++) { solo_v4l2_set_ch(solo_dev, i); while (erase_off(solo_dev)) /* Do nothing */; } /* Set the default display channel */ solo_v4l2_set_ch(solo_dev, 0); while (erase_off(solo_dev)) /* Do nothing */; ret = video_register_device(solo_dev->vfd, VFL_TYPE_GRABBER, nr); if (ret < 0) goto fail; snprintf(solo_dev->vfd->name, sizeof(solo_dev->vfd->name), "%s (%i)", SOLO6X10_NAME, solo_dev->vfd->num); dev_info(&solo_dev->pdev->dev, "Display as /dev/video%d with " "%d inputs (%d extended)/n", solo_dev->vfd->num, solo_dev->nr_chans, solo_dev->nr_ext); return 0;fail: video_device_release(solo_dev->vfd); vb2_dma_contig_cleanup_ctx(solo_dev->alloc_ctx); v4l2_ctrl_handler_free(&solo_dev->disp_hdl); solo_dev->vfd = NULL; return ret;}
开发者ID:168519,项目名称:linux,代码行数:79,
示例21: 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_device_node_name函数代码示例 C++ video_devdata函数代码示例
|