static void uvc_function_unbind(struct usb_configuration *c, struct usb_function *f) { struct usb_composite_dev *cdev = c->cdev; struct uvc_device *uvc = to_uvc(f); INFO(cdev, "uvc_function_unbind\n"); if (uvc->vdev) { if (uvc->vdev->minor == -1) video_device_release(uvc->vdev); else video_unregister_device(uvc->vdev); uvc->vdev = NULL; } if (uvc->control_ep) uvc->control_ep->driver_data = NULL; if (uvc->video.ep) uvc->video.ep->driver_data = NULL; if (uvc->control_req) { usb_ep_free_request(cdev->gadget->ep0, uvc->control_req); kfree(uvc->control_buf); } kfree(f->descriptors); kfree(f->hs_descriptors); kfree(uvc); }
int fm_v4l2_init_video_device(struct fmdrv_ops *fmdev) { FMDRV_API_START(); /* Allocate new video device */ fmdev->v4l2dev = video_device_alloc(); if (!fmdev->v4l2dev) { FM_DRV_ERR("Can't allocate video device"); FMDRV_API_EXIT(-ENOMEM); return -ENOMEM; } /* Setup FM driver's V4L2 properties */ memcpy(fmdev->v4l2dev, &fm_viddev_template, sizeof(fm_viddev_template)); video_set_drvdata(fmdev->v4l2dev, fmdev); /* Register with V4L2 subsystem as RADIO device */ if (video_register_device(fmdev->v4l2dev, VFL_TYPE_RADIO, 0)) { video_device_release(fmdev->v4l2dev); fmdev->v4l2dev = NULL; FM_DRV_ERR("Could not register video device"); FMDRV_API_EXIT(-ENOMEM); return -ENOMEM; } FMDRV_API_EXIT(0); return 0; }
static void at91sam9x5_video_unregister(struct at91sam9x5_video_priv *priv) { unsigned long flags; spin_lock_irqsave(&priv->lock, flags); if (!priv->fbinfo) { spin_unlock_irqrestore(&priv->lock, flags); return; } /* XXX: handle fbinfo being NULL in various callbacks */ priv->fbinfo = NULL; spin_unlock_irqrestore(&priv->lock, flags); /* silence DMA */ at91sam9x5_video_write32(priv, REG_HEOIDR, REG_HEOIxR_ADD | REG_HEOIxR_DMA | REG_HEOIxR_UADD | REG_HEOIxR_UDMA | REG_HEOIxR_VADD | REG_HEOIxR_VDMA); video_unregister_device(priv->video_dev); free_irq(priv->irq, priv); vb2_queue_release(&priv->queue); vb2_dma_contig_cleanup_ctx(priv->alloc_ctx); video_device_release(priv->video_dev); iounmap(priv->regbase); }
static void omap24xxcam_device_unregister(struct v4l2_int_device *s) { struct omap24xxcam_device *cam = s->u.slave->master->priv; omap24xxcam_sensor_exit(cam); if (cam->vfd) { if (!video_is_registered(cam->vfd)) { /* * The device was never registered, so release the * video_device struct directly. */ video_device_release(cam->vfd); } else { /* * The unregister function will release the * video_device struct as well as * unregistering it. */ video_unregister_device(cam->vfd); } cam->vfd = NULL; } device_remove_file(cam->dev, &dev_attr_streaming); cam->sdev = NULL; }
/* Unregister v4l2 devices */ void cx18_streams_cleanup(struct cx18 *cx, int unregister) { struct video_device *vdev; int type; /* Teardown all streams */ for (type = 0; type < CX18_MAX_STREAMS; type++) { if (cx->streams[type].dvb.enabled) { cx18_dvb_unregister(&cx->streams[type]); cx->streams[type].dvb.enabled = false; } vdev = cx->streams[type].video_dev; cx->streams[type].video_dev = NULL; if (vdev == NULL) continue; cx18_stream_free(&cx->streams[type]); /* Unregister or release device */ if (unregister) video_unregister_device(vdev); else video_device_release(vdev); } }
// 二,出口函数 static void myvivi_exit(void) { /* 2.1, 释放注册的结构体*/ video_unregister_device(myvivi_device); /* 2.2,上面有分配,则出口函数就注销 */ video_device_release(myvivi_device); }
int fimc_register_m2m_device(struct fimc_dev *fimc, struct v4l2_device *v4l2_dev) { struct video_device *vfd; struct platform_device *pdev; int ret = 0; if (!fimc) return -ENODEV; pdev = fimc->pdev; fimc->v4l2_dev = v4l2_dev; vfd = video_device_alloc(); if (!vfd) { v4l2_err(v4l2_dev, "Failed to allocate video device\n"); return -ENOMEM; } 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; vfd->lock = &fimc->lock; snprintf(vfd->name, sizeof(vfd->name), "fimc.%d.m2m", fimc->id); video_set_drvdata(vfd, fimc); fimc->m2m.vfd = vfd; 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"); ret = PTR_ERR(fimc->m2m.m2m_dev); goto err_init; } 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); err_init: video_device_release(fimc->m2m.vfd); return ret; }
/* I2C probe: check if the device exists and register with v4l if it is */ static int __devinit tea5764_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct tea5764_device *radio; struct tea5764_regs *r; int ret; PDEBUG("probe"); radio = kmalloc(sizeof(struct tea5764_device), GFP_KERNEL); if (!radio) return -ENOMEM; mutex_init(&radio->mutex); radio->i2c_client = client; ret = tea5764_i2c_read(radio); if (ret) goto errfr; r = &radio->regs; PDEBUG("chipid = %04X, manid = %04X", r->chipid, r->manid); if (r->chipid != TEA5764_CHIPID || (r->manid & 0x0fff) != TEA5764_MANID) { PWARN("This chip is not a TEA5764!"); ret = -EINVAL; goto errfr; } radio->videodev = video_device_alloc(); if (!(radio->videodev)) { ret = -ENOMEM; goto errfr; } memcpy(radio->videodev, &tea5764_radio_template, sizeof(tea5764_radio_template)); i2c_set_clientdata(client, radio); video_set_drvdata(radio->videodev, radio); ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr); if (ret < 0) { PWARN("Could not register video device!"); goto errrel; } /* initialize and power off the chip */ tea5764_i2c_read(radio); tea5764_set_audout_mode(radio, V4L2_TUNER_MODE_STEREO); tea5764_mute(radio, 1); tea5764_power_down(radio); PINFO("registered."); return 0; errrel: video_device_release(radio->videodev); errfr: kfree(radio); return ret; }
/* Unregister v4l2 devices */ void cx18_streams_cleanup(struct cx18 *cx, int unregister) { struct video_device *vdev; int type; /* Teardown all streams */ for (type = 0; type < CX18_MAX_STREAMS; type++) { /* The TS has a cx18_dvb structure, not a video_device */ if (type == CX18_ENC_STREAM_TYPE_TS) { if (cx->streams[type].dvb != NULL) { if (unregister) cx18_dvb_unregister(&cx->streams[type]); kfree(cx->streams[type].dvb); cx->streams[type].dvb = NULL; cx18_stream_free(&cx->streams[type]); } continue; } /* No struct video_device, but can have buffers allocated */ if (type == CX18_ENC_STREAM_TYPE_IDX) { /* If the module params didn't inhibit IDX ... */ if (cx->stream_buffers[type] != 0) { cx->stream_buffers[type] = 0; /* * Before calling cx18_stream_free(), * check if the IDX stream was actually set up. * Needed, since the cx18_probe() error path * exits through here as well as normal clean up */ if (cx->streams[type].buffers != 0) cx18_stream_free(&cx->streams[type]); } continue; } /* If struct video_device exists, can have buffers allocated */ vdev = cx->streams[type].video_dev; cx->streams[type].video_dev = NULL; if (vdev == NULL) continue; if (type == CX18_ENC_STREAM_TYPE_YUV) videobuf_mmap_free(&cx->streams[type].vbuf_q); cx18_stream_free(&cx->streams[type]); /* Unregister or release device */ if (unregister) video_unregister_device(vdev); else video_device_release(vdev); } }
int gsc_register_m2m_device(struct gsc_dev *gsc) { struct video_device *vfd; struct platform_device *pdev; int ret = 0; if (!gsc) return -ENODEV; pdev = gsc->pdev; vfd = video_device_alloc(); if (!vfd) { dev_err(&pdev->dev, "Failed to allocate video device\n"); return -ENOMEM; } vfd->fops = &gsc_m2m_fops; vfd->ioctl_ops = &gsc_m2m_ioctl_ops; vfd->release = video_device_release; vfd->lock = &gsc->lock; vfd->vfl_dir = VFL_DIR_M2M; snprintf(vfd->name, sizeof(vfd->name), "%s:m2m", dev_name(&pdev->dev)); video_set_drvdata(vfd, gsc); gsc->m2m.vfd = vfd; 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"); ret = PTR_ERR(gsc->m2m.m2m_dev); goto err_m2m_r1; } ret = video_register_device(vfd, VFL_TYPE_GRABBER, EXYNOS_VIDEONODE_GSC_M2M(gsc->id)); if (ret) { dev_err(&pdev->dev, "%s(): failed to register video device\n", __func__); goto err_m2m_r2; } setup_timer(&gsc->op_timer, gsc_op_timer_handler, (unsigned long)gsc); gsc_dbg("gsc m2m driver registered as /dev/video%d", vfd->num); return 0; err_m2m_r2: v4l2_m2m_release(gsc->m2m.m2m_dev); err_m2m_r1: video_device_release(gsc->m2m.vfd); return ret; }
static int __devinit __wfd_probe(struct platform_device *pdev) { int rc = 0; struct wfd_device *wfd_dev; WFD_MSG_DBG("__wfd_probe: E\n"); wfd_dev = kzalloc(sizeof(*wfd_dev), GFP_KERNEL); /*TODO: Free it*/ if (!wfd_dev) { WFD_MSG_ERR("Could not allocate memory for " "wfd device\n"); return -ENOMEM; } pdev->dev.platform_data = (void *) wfd_dev; rc = v4l2_device_register(&pdev->dev, &wfd_dev->v4l2_dev); if (rc) { WFD_MSG_ERR("Failed to register the video device\n"); goto err_v4l2_registration; } wfd_dev->pvdev = video_device_alloc(); if (!wfd_dev->pvdev) { WFD_MSG_ERR("Failed to allocate video device\n"); goto err_video_device_alloc; } wfd_dev->pvdev->release = release_video_device; wfd_dev->pvdev->fops = &g_wfd_fops; wfd_dev->pvdev->ioctl_ops = &g_wfd_ioctl_ops; rc = video_register_device(wfd_dev->pvdev, VFL_TYPE_GRABBER, -1); if (rc) { WFD_MSG_ERR("Failed to register the device\n"); goto err_video_register_device; } video_set_drvdata(wfd_dev->pvdev, wfd_dev); v4l2_subdev_init(&wfd_dev->mdp_sdev, &mdp_subdev_ops); strncpy(wfd_dev->mdp_sdev.name, "wfd-mdp", V4L2_SUBDEV_NAME_SIZE); rc = v4l2_device_register_subdev(&wfd_dev->v4l2_dev, &wfd_dev->mdp_sdev); if (rc) { WFD_MSG_ERR("Failed to register mdp subdevice: %d\n", rc); goto err_mdp_register_subdev; } WFD_MSG_DBG("__wfd_probe: X\n"); return rc; err_mdp_register_subdev: video_unregister_device(wfd_dev->pvdev); err_video_register_device: video_device_release(wfd_dev->pvdev); err_video_device_alloc: v4l2_device_unregister(&wfd_dev->v4l2_dev); err_v4l2_registration: kfree(wfd_dev); return rc; }
static void myuvc_disconnect(struct usb_interface *intf) { static int cnt = 0; printk("myuvc_disconnect : cnt = %d \n", cnt++); if(cnt == 2) { video_unregister_device(myuvc_vdev); video_device_release(myuvc_vdev); } }
static int hva_register_device(struct hva_dev *hva) { int ret; struct video_device *vdev; struct device *dev; if (!hva) return -ENODEV; dev = hva_to_dev(hva); hva->m2m_dev = v4l2_m2m_init(&hva_m2m_ops); if (IS_ERR(hva->m2m_dev)) { dev_err(dev, "%s failed to initialize v4l2-m2m device\n", HVA_PREFIX); ret = PTR_ERR(hva->m2m_dev); goto err; } vdev = video_device_alloc(); if (!vdev) { dev_err(dev, "%s failed to allocate video device\n", HVA_PREFIX); ret = -ENOMEM; goto err_m2m_release; } vdev->fops = &hva_fops; vdev->ioctl_ops = &hva_ioctl_ops; vdev->release = video_device_release; vdev->lock = &hva->lock; vdev->vfl_dir = VFL_DIR_M2M; vdev->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M; vdev->v4l2_dev = &hva->v4l2_dev; snprintf(vdev->name, sizeof(vdev->name), "%s%lx", HVA_NAME, hva->ip_version); ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); if (ret) { dev_err(dev, "%s failed to register video device\n", HVA_PREFIX); goto err_vdev_release; } hva->vdev = vdev; video_set_drvdata(vdev, hva); return 0; err_vdev_release: video_device_release(vdev); err_m2m_release: v4l2_m2m_release(hva->m2m_dev); err: return ret; }
void cx18_streams_cleanup(struct cx18 *cx, int unregister) { struct video_device *vdev; int type; for (type = 0; type < CX18_MAX_STREAMS; type++) { if (type == CX18_ENC_STREAM_TYPE_TS) { if (cx->streams[type].dvb != NULL) { if (unregister) cx18_dvb_unregister(&cx->streams[type]); kfree(cx->streams[type].dvb); cx->streams[type].dvb = NULL; cx18_stream_free(&cx->streams[type]); } continue; } if (type == CX18_ENC_STREAM_TYPE_IDX) { if (cx->stream_buffers[type] != 0) { cx->stream_buffers[type] = 0; if (cx->streams[type].buffers != 0) cx18_stream_free(&cx->streams[type]); } continue; } vdev = cx->streams[type].video_dev; cx->streams[type].video_dev = NULL; if (vdev == NULL) continue; if (type == CX18_ENC_STREAM_TYPE_YUV) videobuf_mmap_free(&cx->streams[type].vbuf_q); cx18_stream_free(&cx->streams[type]); if (unregister) video_unregister_device(vdev); else video_device_release(vdev); } }
static int ivtv_reg_dev(struct ivtv *itv, int type) { struct ivtv_stream *s = &itv->streams[type]; int vfl_type = ivtv_stream_info[type].vfl_type; const char *name; int num; if (s->vdev == NULL) return 0; num = s->vdev->num; /* card number + user defined offset + device offset */ if (type != IVTV_ENC_STREAM_TYPE_MPG) { struct ivtv_stream *s_mpg = &itv->streams[IVTV_ENC_STREAM_TYPE_MPG]; if (s_mpg->vdev) num = s_mpg->vdev->num + ivtv_stream_info[type].num_offset; } video_set_drvdata(s->vdev, s); /* Register device. First try the desired minor, then any free one. */ if (video_register_device_no_warn(s->vdev, vfl_type, num)) { IVTV_ERR("Couldn't register v4l2 device for %s (device node number %d)\n", s->name, num); video_device_release(s->vdev); s->vdev = NULL; return -ENOMEM; } name = video_device_node_name(s->vdev); switch (vfl_type) { case VFL_TYPE_GRABBER: IVTV_INFO("Registered device %s for %s (%d kB)\n", name, s->name, itv->options.kilobytes[type]); break; case VFL_TYPE_RADIO: IVTV_INFO("Registered device %s for %s\n", name, s->name); break; case VFL_TYPE_VBI: if (itv->options.kilobytes[type]) IVTV_INFO("Registered device %s for %s (%d kB)\n", name, s->name, itv->options.kilobytes[type]); else IVTV_INFO("Registered device %s for %s\n", name, s->name); break; } return 0; }
int solo_v4l2_init(struct solo6010_dev *solo_dev) { int ret; int i; init_waitqueue_head(&solo_dev->disp_thread_wait); solo_dev->vfd = video_device_alloc(); if (!solo_dev->vfd) return -ENOMEM; *solo_dev->vfd = solo_v4l2_template; solo_dev->vfd->parent = &solo_dev->pdev->dev; ret = video_register_device(solo_dev->vfd, VFL_TYPE_GRABBER, video_nr); if (ret < 0) { video_device_release(solo_dev->vfd); solo_dev->vfd = NULL; return ret; } video_set_drvdata(solo_dev->vfd, solo_dev); snprintf(solo_dev->vfd->name, sizeof(solo_dev->vfd->name), "%s (%i)", SOLO6010_NAME, solo_dev->vfd->num); if (video_nr != -1) video_nr++; 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); /* 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 solo6010_irq_on(solo_dev, SOLO_IRQ_VIDEO_IN); return 0; }
int poseidon_fm_init(struct poseidon *p) { struct video_device *fm_dev; fm_dev = vdev_init(p, &poseidon_fm_template); if (fm_dev == NULL) return -1; if (video_register_device(fm_dev, VFL_TYPE_RADIO, -1) < 0) { video_device_release(fm_dev); return -1; } p->radio_data.fm_dev = fm_dev; return 0; }
static int __devexit vcap_remove(struct platform_device *pdev) { struct vcap_dev *dev = vcap_ctrl; ion_client_destroy(dev->ion_client); flush_workqueue(dev->vcap_wq); destroy_workqueue(dev->vcap_wq); video_device_release(dev->vfd); deinit_vc(); vcap_disable(dev); v4l2_device_unregister(&dev->v4l2_dev); iounmap(dev->vcapbase); release_mem_region(dev->vcapmem->start, resource_size(dev->vcapmem)); vcap_ctrl = NULL; kfree(dev); return 0; }
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"); ret = PTR_ERR(gsc->m2m.m2m_dev); goto err_m2m_r1; } 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_r2; } pr_debug("gsc m2m driver registered as /dev/video%d", gsc->vdev.num); return 0; err_m2m_r2: v4l2_m2m_release(gsc->m2m.m2m_dev); err_m2m_r1: video_device_release(gsc->m2m.vfd); return ret; }
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; }
static int __devexit __wfd_remove(struct platform_device *pdev) { struct wfd_device *wfd_dev; wfd_dev = (struct wfd_device *)pdev->dev.platform_data; WFD_MSG_DBG("Inside wfd_remove\n"); if (!wfd_dev) { WFD_MSG_ERR("Error removing WFD device"); return -ENODEV; } v4l2_device_unregister_subdev(&wfd_dev->mdp_sdev); video_unregister_device(wfd_dev->pvdev); video_device_release(wfd_dev->pvdev); v4l2_device_unregister(&wfd_dev->v4l2_dev); kfree(wfd_dev); return 0; }
/* Unregister v4l2 devices */ void cx18_streams_cleanup(struct cx18 *cx, int unregister) { struct video_device *vdev; int type; /* Teardown all streams */ for (type = 0; type < CX18_MAX_STREAMS; type++) { /* No struct video_device, but can have buffers allocated */ if (type == CX18_ENC_STREAM_TYPE_TS) { if (cx->streams[type].dvb.enabled) { cx18_dvb_unregister(&cx->streams[type]); cx->streams[type].dvb.enabled = false; cx18_stream_free(&cx->streams[type]); } continue; } /* No struct video_device, but can have buffers allocated */ if (type == CX18_ENC_STREAM_TYPE_IDX) { if (cx->stream_buffers[type] != 0) { cx->stream_buffers[type] = 0; cx18_stream_free(&cx->streams[type]); } continue; } /* If struct video_device exists, can have buffers allocated */ vdev = cx->streams[type].video_dev; cx->streams[type].video_dev = NULL; if (vdev == NULL) continue; cx18_stream_free(&cx->streams[type]); /* Unregister or release device */ if (unregister) video_unregister_device(vdev); else video_device_release(vdev); } }
static int rockchip_vpu_remove(struct platform_device *pdev) { struct rockchip_vpu_dev *vpu = platform_get_drvdata(pdev); v4l2_info(&vpu->v4l2_dev, "Removing %s\n", pdev->name); media_device_unregister(&vpu->mdev); v4l2_m2m_unregister_media_controller(vpu->m2m_dev); v4l2_m2m_release(vpu->m2m_dev); media_device_cleanup(&vpu->mdev); if (vpu->vfd_enc) { video_unregister_device(vpu->vfd_enc); video_device_release(vpu->vfd_enc); } v4l2_device_unregister(&vpu->v4l2_dev); clk_bulk_unprepare(vpu->variant->num_clocks, vpu->clocks); pm_runtime_disable(vpu->dev); return 0; }
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; }
/* Unregister v4l2 devices */ void ivtv_streams_cleanup(struct ivtv *itv, int unregister) { int type; /* Teardown all streams */ for (type = 0; type < IVTV_MAX_STREAMS; type++) { struct video_device *vdev = itv->streams[type].vdev; itv->streams[type].vdev = NULL; if (vdev == NULL) continue; ivtv_stream_free(&itv->streams[type]); /* Unregister or release device */ if (unregister) video_unregister_device(vdev); else video_device_release(vdev); } }
/* Unregister v4l2 devices */ void ivtv_streams_cleanup(struct ivtv *itv) { int type; /* Teardown all streams */ for (type = 0; type < IVTV_MAX_STREAMS; type++) { struct video_device *vdev = itv->streams[type].v4l2dev; itv->streams[type].v4l2dev = NULL; if (vdev == NULL) continue; ivtv_stream_free(&itv->streams[type]); /* Free Device */ if (vdev->minor == -1) /* 'Hidden' never registered stream (OSD) */ video_device_release(vdev); else /* All others, just unregister. */ video_unregister_device(vdev); } }
void camera_core_cleanup(void) { struct camera_device *cam = camera_dev; struct video_device *vfd; if (!cam) return; vfd = cam->vfd; if (vfd) { if (vfd->minor == -1) { /* The device never got registered, so release the ** video_device struct directly */ video_device_release(vfd); } else { /* The unregister function will release the video_device ** struct as well as unregistering it. */ video_unregister_device(vfd); driver_unregister(&camera_core_driver); platform_device_unregister(&camera_core_device); } cam->vfd = NULL; } if (cam->overlay_base) { dma_free_coherent(NULL, cam->overlay_size, (void *)cam->overlay_base, cam->overlay_base_phys); cam->overlay_base = 0; } cam->overlay_base_phys = 0; cam->cam_sensor->cleanup(cam->sensor_data); cam->cam_hardware->cleanup(cam->hardware_data); kfree(cam); camera_dev = NULL; return; }
static int mxc_v4l2out_remove(struct device *dev) { vout_data *vout = dev_get_drvdata(dev); FUNC_START; if (vout->video_dev) { if (-1 != vout->video_dev->minor) video_unregister_device(vout->video_dev); else video_device_release(vout->video_dev); vout->video_dev = NULL; } dev_set_drvdata(dev, NULL); kfree(vout); FUNC_END; return 0; }
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; }
static int __init video_dummy_init(void) { int ret; dummy_vfd = video_device_alloc(); if (!dummy_vfd) return -ENOMEM; *dummy_vfd = dummy_template; ret = video_register_device(dummy_vfd, VFL_TYPE_GRABBER, -1); if (ret < 0) { video_device_release(dummy_vfd); dummy_vfd = NULL; return ret; } printk(KERN_INFO "video_dummy: V4L2 device registered as /dev/video%d\n", dummy_vfd->num); return 0; }