/* * jpegdma_probe - Dma device probe method. * @pdev: Pointer Dma platform device. */ static int jpegdma_probe(struct platform_device *pdev) { struct msm_jpegdma_device *jpegdma; int ret; dev_dbg(&pdev->dev, "jpeg v4l2 DMA probed\n"); /* Jpeg dma device struct */ jpegdma = kzalloc(sizeof(struct msm_jpegdma_device), GFP_KERNEL); if (!jpegdma) return -ENOMEM; mutex_init(&jpegdma->lock); init_completion(&jpegdma->hw_reset_completion); init_completion(&jpegdma->hw_halt_completion); jpegdma->dev = &pdev->dev; /* Get resources */ ret = msm_jpegdma_hw_get_mem_resources(pdev, jpegdma); if (ret < 0) goto error_mem_resources; ret = msm_jpegdma_hw_get_regulators(jpegdma); if (ret < 0) goto error_get_regulators; ret = msm_jpegdma_hw_get_clocks(jpegdma); if (ret < 0) goto error_get_clocks; ret = msm_jpegdma_hw_get_qos(jpegdma); if (ret < 0) goto error_qos_get; ret = msm_jpegdma_hw_get_vbif(jpegdma); if (ret < 0) goto error_vbif_get; ret = msm_jpegdma_hw_get_prefetch(jpegdma); if (ret < 0) goto error_prefetch_get; ret = msm_jpegdma_hw_request_irq(pdev, jpegdma); if (ret < 0) goto error_hw_get_request_irq; ret = msm_jpegdma_hw_get_capabilities(jpegdma); if (ret < 0) goto error_hw_get_request_irq; /* mem2mem device */ jpegdma->m2m_dev = v4l2_m2m_init(&msm_jpegdma_m2m_ops); if (IS_ERR(jpegdma->m2m_dev)) { dev_err(&pdev->dev, "Failed to init mem2mem device\n"); ret = PTR_ERR(jpegdma->m2m_dev); goto error_m2m_init; } /* v4l2 device */ ret = v4l2_device_register(&pdev->dev, &jpegdma->v4l2_dev); if (ret < 0) { dev_err(&pdev->dev, "Failed to register v4l2 device\n"); goto error_v4l2_register; } jpegdma->video.fops = &fd_fops; jpegdma->video.ioctl_ops = &fd_ioctl_ops; jpegdma->video.minor = -1; jpegdma->video.release = video_device_release; jpegdma->video.v4l2_dev = &jpegdma->v4l2_dev; jpegdma->video.vfl_dir = VFL_DIR_M2M; jpegdma->video.vfl_type = VFL_TYPE_GRABBER; strlcpy(jpegdma->video.name, MSM_JPEGDMA_DRV_NAME, sizeof(jpegdma->video.name)); ret = video_register_device(&jpegdma->video, VFL_TYPE_GRABBER, -1); if (ret < 0) { dev_err(&pdev->dev, "Failed to register video device\n"); goto error_video_register; } video_set_drvdata(&jpegdma->video, jpegdma); platform_set_drvdata(pdev, jpegdma); dev_dbg(&pdev->dev, "jpeg v4l2 DMA probe success\n"); return 0; error_video_register: v4l2_device_unregister(&jpegdma->v4l2_dev); error_v4l2_register: v4l2_m2m_release(jpegdma->m2m_dev); error_m2m_init: msm_jpegdma_hw_release_irq(jpegdma); error_hw_get_request_irq: msm_jpegdma_hw_put_prefetch(jpegdma); error_prefetch_get: msm_jpegdma_hw_put_vbif(jpegdma); error_vbif_get: msm_jpegdma_hw_put_qos(jpegdma); error_qos_get: msm_jpegdma_hw_put_clocks(jpegdma); error_get_clocks: msm_jpegdma_hw_put_regulators(jpegdma); error_get_regulators: msm_jpegdma_hw_release_mem_resources(jpegdma); error_mem_resources: kfree(jpegdma); return ret; }
static int s3c_camif_probe(struct platform_device *pdev) { struct resource *res; camif_cfg_t *codec, *preview; int ret = 0; /* Initialize fimc objects */ codec = s3c_camif_get_fimc_object(CODEC_MINOR); preview = s3c_camif_get_fimc_object(PREVIEW_MINOR); memset(codec, 0, sizeof(camif_cfg_t)); memset(preview, 0, sizeof(camif_cfg_t)); /* Set the fimc name */ strcpy(codec->shortname, CODEC_DEV_NAME); strcpy(preview->shortname, PREVIEW_DEV_NAME); /* get resource for io memory */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { printk("Failed to get io memory region resouce.\n"); return -1; } /* request mem region */ res = request_mem_region(res->start, res->end - res->start + 1, pdev->name); if (!res) { printk("Failed to request io memory region.\n"); return -1; } /* ioremap for register block */ codec->regs = preview->regs = ioremap(res->start, res->end - res->start + 1); if (codec->regs == NULL) { printk(KERN_ERR "Failed to remap register block\n"); return -1; } /* ioremap for reserved memory */ codec->pp_phys_buf = PHYS_OFFSET + (MEM_SIZE - RESERVED_MEM); codec->pp_virt_buf = ioremap_nocache(codec->pp_phys_buf, YUV_MEM); preview->pp_phys_buf = PHYS_OFFSET + (MEM_SIZE - RESERVED_MEM) + YUV_MEM; preview->pp_virt_buf = ioremap_nocache(preview->pp_phys_buf, RGB_MEM); /* Device init */ s3c_camif_init(); s3c_camif_init_codec(codec); s3c_camif_init_preview(preview); /* Set irq */ codec->irq = platform_get_irq(pdev, FIMC_CODEC_INDEX); preview->irq = platform_get_irq(pdev, FIMC_PREVIEW_INDEX); s3c_camif_request_irq(codec); s3c_camif_request_irq(preview); /* Register to video device */ if (video_register_device(codec->v, VFL_TYPE_GRABBER, CODEC_MINOR) != 0) { printk(KERN_ERR "Couldn't register this codec driver\n"); return -1; } if (video_register_device(preview->v, VFL_TYPE_GRABBER, PREVIEW_MINOR) != 0) { printk(KERN_ERR "Couldn't register this preview driver\n"); return -1; } #if defined(CONFIG_CPU_S3C6400) || defined(CONFIG_CPU_S3C6410) cam_clock = clk_get(&pdev->dev, "camera"); #elif defined(CONFIG_CPU_S3C2443) || defined(CONFIG_CPU_S3C2416) || defined(CONFIG_CPU_S3C2450) cam_clock = clk_get(&pdev->dev, "camif-upll"); #else #error cam_clock should be defined #endif if (IS_ERR(cam_clock)) { printk("Failed to find camera clock source\n"); ret = PTR_ERR(cam_clock); } clk_enable(cam_clock); /* Print banner */ printk(KERN_INFO "S3C FIMC v%s\n", FIMC_VER); return 0; }
static int g2d_probe(struct platform_device *pdev) { struct g2d_dev *dev; struct video_device *vfd; struct resource *res; const struct of_device_id *of_id; int ret = 0; dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; spin_lock_init(&dev->ctrl_lock); mutex_init(&dev->mutex); atomic_set(&dev->num_inst, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); dev->regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(dev->regs)) return PTR_ERR(dev->regs); dev->clk = clk_get(&pdev->dev, "sclk_fimg2d"); if (IS_ERR(dev->clk)) { dev_err(&pdev->dev, "failed to get g2d clock\n"); return -ENXIO; } 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(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 = devm_request_irq(&pdev->dev, dev->irq, g2d_isr, 0, pdev->name, dev); if (ret) { dev_err(&pdev->dev, "failed to install IRQ\n"); goto unprep_clk_gate; } vb2_dma_contig_set_max_seg_size(&pdev->dev, DMA_BIT_MASK(32)); ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) goto unprep_clk_gate; 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; set_bit(V4L2_FL_QUIRK_INVERTED_CROP, &vfd->flags); vfd->lock = &dev->mutex; vfd->v4l2_dev = &dev->v4l2_dev; 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; } video_set_drvdata(vfd, dev); dev->vfd = vfd; v4l2_info(&dev->v4l2_dev, "device registered as /dev/video%d\n", vfd->num); platform_set_drvdata(pdev, dev); dev->m2m_dev = v4l2_m2m_init(&g2d_m2m_ops); if (IS_ERR(dev->m2m_dev)) { v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem device\n"); ret = PTR_ERR(dev->m2m_dev); goto unreg_video_dev; } def_frame.stride = (def_frame.width * def_frame.fmt->depth) >> 3; of_id = of_match_node(exynos_g2d_match, pdev->dev.of_node); if (!of_id) { ret = -ENODEV; goto unreg_video_dev; } dev->variant = (struct g2d_variant *)of_id->data; return 0; unreg_video_dev: video_unregister_device(dev->vfd); rel_vdev: video_device_release(vfd); unreg_v4l2_dev: v4l2_device_unregister(&dev->v4l2_dev); unprep_clk_gate: clk_unprepare(dev->gate); put_clk_gate: clk_put(dev->gate); unprep_clk: clk_unprepare(dev->clk); put_clk: clk_put(dev->clk); return ret; }
/* * si470x_usb_driver_probe - probe for the device */ static int si470x_usb_driver_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct si470x_device *radio; struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; int i, int_end_size, 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->disconnected = 0; radio->usbdev = interface_to_usbdev(intf); radio->intf = intf; mutex_init(&radio->lock); iface_desc = intf->cur_altsetting; /* Set up interrupt endpoint information. */ for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { endpoint = &iface_desc->endpoint[i].desc; if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) radio->int_in_endpoint = endpoint; } if (!radio->int_in_endpoint) { dev_info(&intf->dev, "could not find interrupt in endpoint\n"); retval = -EIO; goto err_radio; } int_end_size = le16_to_cpu(radio->int_in_endpoint->wMaxPacketSize); radio->int_in_buffer = kmalloc(int_end_size, GFP_KERNEL); if (!radio->int_in_buffer) { dev_info(&intf->dev, "could not allocate int_in_buffer"); retval = -ENOMEM; goto err_radio; } radio->int_in_urb = usb_alloc_urb(0, GFP_KERNEL); if (!radio->int_in_urb) { dev_info(&intf->dev, "could not allocate int_in_urb"); retval = -ENOMEM; goto err_intbuffer; } /* video device allocation and initialization */ radio->videodev = video_device_alloc(); if (!radio->videodev) { retval = -ENOMEM; goto err_urb; } memcpy(radio->videodev, &si470x_viddev_template, sizeof(si470x_viddev_template)); video_set_drvdata(radio->videodev, radio); /* get device and chip versions */ if (si470x_get_all_registers(radio) < 0) { retval = -EIO; goto err_video; } dev_info(&intf->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(&intf->dev, "This driver is known to work with " "firmware version %hu,\n", RADIO_FW_VERSION); dev_warn(&intf->dev, "but the device has firmware version %hu.\n", radio->registers[CHIPID] & CHIPID_FIRMWARE); version_warning = 1; } /* get software and hardware versions */ if (si470x_get_scratch_page_versions(radio) < 0) { retval = -EIO; goto err_video; } dev_info(&intf->dev, "software version %d, hardware version %d\n", radio->software_version, radio->hardware_version); if (radio->software_version < RADIO_SW_VERSION) { dev_warn(&intf->dev, "This driver is known to work with " "software version %hu,\n", RADIO_SW_VERSION); dev_warn(&intf->dev, "but the device has software version %hu.\n", radio->software_version); version_warning = 1; } if (radio->hardware_version < RADIO_HW_VERSION) { dev_warn(&intf->dev, "This driver is known to work with " "hardware version %hu,\n", RADIO_HW_VERSION); dev_warn(&intf->dev, "but the device has hardware version %hu.\n", radio->hardware_version); version_warning = 1; } /* give out version warning */ if (version_warning == 1) { dev_warn(&intf->dev, "If you have some trouble using this driver,\n"); dev_warn(&intf->dev, "please report to V4L ML at " "[email protected]\n"); } /* set initial frequency */ si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */ /* set led to connect state */ si470x_set_led_state(radio, BLINK_GREEN_LED); /* rds buffer allocation */ radio->buf_size = rds_buf * 3; radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); if (!radio->buffer) { retval = -EIO; goto err_video; } /* rds buffer configuration */ radio->wr_index = 0; radio->rd_index = 0; init_waitqueue_head(&radio->read_queue); /* register video device */ retval = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr); if (retval) { dev_warn(&intf->dev, "Could not register video device\n"); goto err_all; } usb_set_intfdata(intf, radio); return 0; err_all: kfree(radio->buffer); err_video: video_device_release(radio->videodev); err_urb: usb_free_urb(radio->int_in_urb); err_intbuffer: kfree(radio->int_in_buffer); err_radio: kfree(radio); err_initial: return retval; }
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; }
/* * fd_probe - Fd device probe method. * @pdev: Pointer fd platform device. */ static int fd_probe(struct platform_device *pdev) { struct msm_fd_device *fd; int ret; /* Face detection device struct */ fd = kzalloc(sizeof(struct msm_fd_device), GFP_KERNEL); if (!fd) return -ENOMEM; mutex_init(&fd->lock); spin_lock_init(&fd->slock); fd->dev = &pdev->dev; /* Get resources */ ret = msm_fd_hw_get_mem_resources(pdev, fd); if (ret < 0) { dev_err(&pdev->dev, "Fail get resources\n"); ret = -ENODEV; goto error_mem_resources; } fd->vdd = regulator_get(&pdev->dev, "vdd"); if (IS_ERR(fd->vdd)) { dev_err(&pdev->dev, "Fail to get vdd regulator\n"); ret = -ENODEV; goto error_get_regulator; } ret = msm_fd_hw_get_clocks(fd); if (ret < 0) { dev_err(&pdev->dev, "Fail to get clocks\n"); goto error_get_clocks; } ret = msm_fd_hw_get_iommu(fd); if (ret < 0) { dev_err(&pdev->dev, "Fail to get iommu\n"); goto error_iommu_get; } fd->irq_num = platform_get_irq(pdev, 0); if (fd->irq_num < 0) { dev_err(&pdev->dev, "Can not get fd irq resource\n"); ret = -ENODEV; goto error_irq_request; } ret = devm_request_irq(&pdev->dev, fd->irq_num, msm_fd_irq, IRQF_TRIGGER_RISING, dev_name(&pdev->dev), fd); if (ret) { dev_err(&pdev->dev, "Can not claim IRQ %d\n", fd->irq_num); goto error_irq_request; } fd->work_queue = alloc_workqueue(MSM_FD_DRV_NAME, WQ_HIGHPRI | WQ_NON_REENTRANT | WQ_UNBOUND, 0); if (!fd->work_queue) { dev_err(&pdev->dev, "Can not register workqueue\n"); ret = -ENOMEM; goto error_alloc_workqueue; } INIT_WORK(&fd->work, msm_fd_wq_handler); INIT_LIST_HEAD(&fd->buf_queue); /* v4l2 device */ ret = v4l2_device_register(&pdev->dev, &fd->v4l2_dev); if (ret < 0) { dev_err(&pdev->dev, "Failed to register v4l2 device\n"); ret = -ENOENT; goto error_v4l2_register; } fd->video.fops = &fd_fops; fd->video.ioctl_ops = &fd_ioctl_ops; fd->video.minor = -1; fd->video.release = video_device_release; fd->video.v4l2_dev = &fd->v4l2_dev; fd->video.vfl_dir = VFL_DIR_TX; fd->video.vfl_type = VFL_TYPE_GRABBER; strlcpy(fd->video.name, MSM_FD_DRV_NAME, sizeof(fd->video.name)); ret = video_register_device(&fd->video, VFL_TYPE_GRABBER, -1); if (ret < 0) { v4l2_err(&fd->v4l2_dev, "Failed to register video device\n"); goto error_video_register; } video_set_drvdata(&fd->video, fd); platform_set_drvdata(pdev, fd); return 0; error_video_register: v4l2_device_unregister(&fd->v4l2_dev); error_v4l2_register: destroy_workqueue(fd->work_queue); error_alloc_workqueue: devm_free_irq(&pdev->dev, fd->irq_num, fd); error_irq_request: msm_fd_hw_put_iommu(fd); error_iommu_get: msm_fd_hw_put_clocks(fd); error_get_clocks: regulator_put(fd->vdd); error_get_regulator: msm_fd_hw_release_mem_resources(fd); error_mem_resources: kfree(fd); return ret; }
static int __devinit s5p_tv_probe(struct platform_device *pdev) { int irq_num; int ret; int i, retval; /* Get csis power domain regulator */ s5ptv_status.tv_regulator = regulator_get(&pdev->dev, "pd"); if (IS_ERR(s5ptv_status.tv_regulator)) { printk(KERN_ERR "%s %d: failed to get resource %s\n", __func__, __LINE__, "s3c-tv20 pd"); return PTR_ERR(s5ptv_status.tv_regulator); } s5ptv_status.tv_tvout = regulator_get(NULL, "tvout"); if (IS_ERR(s5ptv_status.tv_tvout)) { printk(KERN_ERR "%s %d: failed to get resource %s\n", __func__, __LINE__, "s3c-tv20 tvout"); return PTR_ERR(s5ptv_status.tv_tvout); } #ifdef CONFIG_MACH_P1 s5ptv_status.tv_tv = regulator_get(NULL, "tv"); if (IS_ERR(s5ptv_status.tv_tv)) { printk(KERN_ERR "%s %d: failed to get resource %s\n", __func__, __LINE__, "s3c-tv20 tv"); return PTR_ERR(s5ptv_status.tv_tv); } regulator_enable(s5ptv_status.tv_tv); #endif s5ptv_status.dev_fb = &pdev->dev; __s5p_sdout_probe(pdev, 0); __s5p_vp_probe(pdev, 1); __s5p_mixer_probe(pdev, 2); #ifdef CONFIG_CPU_S5PC100 __s5p_hdmi_probe(pdev, 3); __s5p_tvclk_probe(pdev, 4); #endif #ifdef CONFIG_CPU_S5PV210 tv_clk_get(pdev, &s5ptv_status); s5p_tv_clk_gate(true); __s5p_hdmi_probe(pdev, 3, 4); __s5p_hdcp_init(); #endif #if defined(CONFIG_MACH_P1) retval = i2c_add_driver(&SII9234A_i2c_driver); if (retval != 0) printk(KERN_ERR "[MHL SII9234A] can't add i2c driver"); retval = i2c_add_driver(&SII9234B_i2c_driver); if (retval != 0) printk(KERN_ERR "[MHL SII9234B] can't add i2c driver"); retval = i2c_add_driver(&SII9234C_i2c_driver); if (retval != 0) printk(KERN_ERR "[MHL SII9234C] can't add i2c driver"); retval = i2c_add_driver(&SII9234_i2c_driver); if (retval != 0) printk(KERN_ERR "[MHL SII9234] can't add i2c driver"); #endif #ifdef FIX_27M_UNSTABLE_ISSUE /* for smdkc100 pop */ writel(0x1, S5PC1XX_GPA0_BASE + 0x56c); #endif #ifdef I2C_BASE /* for dev_dbg err. */ spin_lock_init(&slock_hpd); /* for bh */ INIT_WORK(&ws_hpd, (void *)set_ddc_port); #endif /* check EINT init state */ #ifdef CONFIG_CPU_S5PC100 s3c_gpio_cfgpin(S5PC1XX_GPH0(5), S3C_GPIO_SFN(2)); s3c_gpio_setpull(S5PC1XX_GPH0(5), S3C_GPIO_PULL_UP); s5ptv_status.hpd_status = gpio_get_value(S5PC1XX_GPH0(5)) ? \ false : true; #endif #ifdef CONFIG_CPU_S5PV210 #ifdef CONFIG_HDMI_HPD s5ptv_status.hpd_status = 0; #else s5ptv_status.hpd_status = 0; #endif #endif dev_info(&pdev->dev, "hpd status: cable %s\n",\ s5ptv_status.hpd_status ? "inserted":"removed/not connected"); /* Interrupt */ TVOUT_IRQ_INIT(irq_num, ret, pdev, 0, out, __s5p_mixer_irq, "mixer"); TVOUT_IRQ_INIT(irq_num, ret, pdev, 1, out_hdmi_irq, __s5p_hdmi_irq , \ "hdmi"); TVOUT_IRQ_INIT(irq_num, ret, pdev, 2, out_tvenc_irq, s5p_tvenc_irq, \ "tvenc"); #ifdef CONFIG_CPU_S5PC100 TVOUT_IRQ_INIT(irq_num, ret, pdev, 3, out_hpd_irq, __s5p_hpd_irq, \ "hpd"); set_irq_type(IRQ_EINT5, IRQ_TYPE_LEVEL_LOW); #endif /* v4l2 video device registration */ for (i = 0; i < S5P_TVMAX_CTRLS; i++) { s5ptv_status.video_dev[i] = &s5p_tvout[i]; if (video_register_device(s5ptv_status.video_dev[i], VFL_TYPE_GRABBER, s5p_tvout[i].minor) != 0) { dev_err(&pdev->dev, "Couldn't register tvout driver.\n"); return 0; } } #ifdef CONFIG_TV_FB mutex_init(&s5ptv_status.fb_lock); /* for default start up */ _s5p_tv_if_init_param(); s5ptv_status.tvout_param.disp_mode = TVOUT_720P_60; s5ptv_status.tvout_param.out_mode = TVOUT_OUTPUT_HDMI; #ifndef CONFIG_USER_ALLOC_TVOUT s5p_tv_clk_gate(true); /* if ((s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI) || (s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB)) */ tv_phy_power(true); _s5p_tv_if_set_disp(); #endif s5ptvfb_set_lcd_info(&s5ptv_status); /* prepare memory */ if (s5ptvfb_alloc_framebuffer()) goto err_alloc; if (s5ptvfb_register_framebuffer()) goto err_alloc; #ifndef CONFIG_USER_ALLOC_TVOUT s5ptvfb_display_on(&s5ptv_status); #endif #endif mutex_for_fo = kmalloc(sizeof(struct mutex), GFP_KERNEL); if (mutex_for_fo == NULL) { dev_err(&pdev->dev, "failed to create mutex handle\n"); goto out; } #ifdef I2C_BASE mutex_for_i2c = kmalloc(sizeof(struct mutex), GFP_KERNEL); if (mutex_for_i2c == NULL) { dev_err(&pdev->dev, "failed to create mutex handle\n"); goto out; } mutex_init(mutex_for_i2c); #endif mutex_init(mutex_for_fo); #ifdef CONFIG_CPU_S5PV210 /* added for phy cut off when boot up */ clk_enable(s5ptv_status.i2c_phy_clk); __s5p_hdmi_phy_power(false); clk_disable(s5ptv_status.i2c_phy_clk); s5p_tv_clk_gate(false); #endif printk(KERN_INFO "%s TV Probing is done\n", __func__); return 0; #ifdef CONFIG_TV_FB err_alloc: #endif #ifdef CONFIG_CPU_S5PC100 out_hpd_irq: free_irq(IRQ_TVENC, pdev); #endif out_tvenc_irq: free_irq(IRQ_HDMI, pdev); out_hdmi_irq: free_irq(IRQ_MIXER, pdev); out: printk(KERN_ERR "not found (%d). \n", ret); return ret; }
static int __init fmi_init(void) { struct fmi *fmi = &fmi_card; struct v4l2_device *v4l2_dev = &fmi->v4l2_dev; int res, i; int probe_ports[] = { 0, 0x284, 0x384 }; if (io < 0) { for (i = 0; i < ARRAY_SIZE(probe_ports); i++) { io = probe_ports[i]; if (io == 0) { io = isapnp_fmi_probe(); if (io < 0) continue; pnp_attached = 1; } if (!request_region(io, 2, "radio-sf16fmi")) { if (pnp_attached) pnp_device_detach(dev); io = -1; continue; } if (pnp_attached || ((inb(io) & 0xf9) == 0xf9 && (inb(io) & 0x4) == 0)) break; release_region(io, 2); io = -1; } } else { if (!request_region(io, 2, "radio-sf16fmi")) { printk(KERN_ERR "radio-sf16fmi: port %#x already in use\n", io); return -EBUSY; } if (inb(io) == 0xff) { printk(KERN_ERR "radio-sf16fmi: card not present at %#x\n", io); release_region(io, 2); return -ENODEV; } } if (io < 0) { printk(KERN_ERR "radio-sf16fmi: no cards found\n"); return -ENODEV; } strlcpy(v4l2_dev->name, "sf16fmi", sizeof(v4l2_dev->name)); fmi->io = io; res = v4l2_device_register(NULL, v4l2_dev); if (res < 0) { release_region(fmi->io, 2); if (pnp_attached) pnp_device_detach(dev); v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); return res; } strlcpy(fmi->vdev.name, v4l2_dev->name, sizeof(fmi->vdev.name)); fmi->vdev.v4l2_dev = v4l2_dev; fmi->vdev.fops = &fmi_fops; fmi->vdev.ioctl_ops = &fmi_ioctl_ops; fmi->vdev.release = video_device_release_empty; video_set_drvdata(&fmi->vdev, fmi); mutex_init(&fmi->lock); /* mute card - prevents noisy bootups */ fmi_mute(fmi); if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { v4l2_device_unregister(v4l2_dev); release_region(fmi->io, 2); if (pnp_attached) pnp_device_detach(dev); return -EINVAL; } v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io); return 0; }
static int __devinit msm_vidc_probe(struct platform_device *pdev) { int rc = 0; struct msm_vidc_core *core; struct device *dev; int nr = BASE_DEVICE_NUMBER; core = kzalloc(sizeof(*core), GFP_KERNEL); if (!core || !vidc_driver) { dprintk(VIDC_ERR, "Failed to allocate memory for device core\n"); rc = -ENOMEM; goto err_no_mem; } rc = msm_vidc_initialize_core(pdev, core); if (rc) { dprintk(VIDC_ERR, "Failed to init core\n"); goto err_core_init; } rc = device_create_file(&pdev->dev, &dev_attr_pwr_collapse_delay); if (rc) { dprintk(VIDC_ERR, "Failed to create pwr_collapse_delay sysfs node"); goto err_core_init; } if (core->hfi_type == VIDC_HFI_Q6) { dprintk(VIDC_ERR, "Q6 hfi device probe called\n"); nr += MSM_VIDC_MAX_DEVICES; core->id = MSM_VIDC_CORE_Q6; } else { core->id = MSM_VIDC_CORE_VENUS; } rc = v4l2_device_register(&pdev->dev, &core->v4l2_dev); if (rc) { dprintk(VIDC_ERR, "Failed to register v4l2 device\n"); goto err_v4l2_register; } core->vdev[MSM_VIDC_DECODER].vdev.release = msm_vidc_release_video_device; core->vdev[MSM_VIDC_DECODER].vdev.fops = &msm_v4l2_vidc_fops; core->vdev[MSM_VIDC_DECODER].vdev.ioctl_ops = &msm_v4l2_ioctl_ops; core->vdev[MSM_VIDC_DECODER].type = MSM_VIDC_DECODER; rc = video_register_device(&core->vdev[MSM_VIDC_DECODER].vdev, VFL_TYPE_GRABBER, nr); if (rc) { dprintk(VIDC_ERR, "Failed to register video decoder device"); goto err_dec_register; } video_set_drvdata(&core->vdev[MSM_VIDC_DECODER].vdev, core); dev = &core->vdev[MSM_VIDC_DECODER].vdev.dev; rc = device_create_file(dev, &dev_attr_link_name); if (rc) { dprintk(VIDC_ERR, "Failed to create link name sysfs for decoder"); goto err_dec_attr_link_name; } core->vdev[MSM_VIDC_ENCODER].vdev.release = msm_vidc_release_video_device; core->vdev[MSM_VIDC_ENCODER].vdev.fops = &msm_v4l2_vidc_fops; core->vdev[MSM_VIDC_ENCODER].vdev.ioctl_ops = &msm_v4l2_ioctl_ops; core->vdev[MSM_VIDC_ENCODER].type = MSM_VIDC_ENCODER; rc = video_register_device(&core->vdev[MSM_VIDC_ENCODER].vdev, VFL_TYPE_GRABBER, nr + 1); if (rc) { dprintk(VIDC_ERR, "Failed to register video encoder device"); goto err_enc_register; } video_set_drvdata(&core->vdev[MSM_VIDC_ENCODER].vdev, core); dev = &core->vdev[MSM_VIDC_ENCODER].vdev.dev; rc = device_create_file(dev, &dev_attr_link_name); if (rc) { dprintk(VIDC_ERR, "Failed to create link name sysfs for encoder"); goto err_enc_attr_link_name; } mutex_lock(&vidc_driver->lock); if (vidc_driver->num_cores + 1 > MSM_VIDC_CORES_MAX) { mutex_unlock(&vidc_driver->lock); dprintk(VIDC_ERR, "Maximum cores already exist, core_no = %d\n", vidc_driver->num_cores); goto err_cores_exceeded; } vidc_driver->num_cores++; mutex_unlock(&vidc_driver->lock); core->device = vidc_hfi_initialize(core->hfi_type, core->id, &core->resources, &handle_cmd_response); if (IS_ERR_OR_NULL(core->device)) { mutex_lock(&vidc_driver->lock); vidc_driver->num_cores--; mutex_unlock(&vidc_driver->lock); rc = PTR_ERR(core->device); if (rc != -EPROBE_DEFER) dprintk(VIDC_ERR, "Failed to create HFI device\n"); else dprintk(VIDC_DBG, "msm_vidc: request probe defer\n"); goto err_cores_exceeded; } mutex_lock(&vidc_driver->lock); list_add_tail(&core->list, &vidc_driver->cores); mutex_unlock(&vidc_driver->lock); core->debugfs_root = msm_vidc_debugfs_init_core( core, vidc_driver->debugfs_root); pdev->dev.platform_data = core; return rc; err_cores_exceeded: device_remove_file(&core->vdev[MSM_VIDC_ENCODER].vdev.dev, &dev_attr_link_name); err_enc_attr_link_name: video_unregister_device(&core->vdev[MSM_VIDC_ENCODER].vdev); err_enc_register: device_remove_file(&core->vdev[MSM_VIDC_DECODER].vdev.dev, &dev_attr_link_name); err_dec_attr_link_name: video_unregister_device(&core->vdev[MSM_VIDC_DECODER].vdev); err_dec_register: v4l2_device_unregister(&core->v4l2_dev); err_v4l2_register: device_remove_file(&pdev->dev, &dev_attr_pwr_collapse_delay); err_core_init: kfree(core); err_no_mem: return rc; }
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; 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; f.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; ctx->d_frame.fmt = find_format(&f, FMT_FLAGS_M2M); 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; 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; /* The 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; videobuf_queue_dma_contig_init(&vid_cap->vbq, &fimc_qops, vid_cap->v4l2_dev.dev, &fimc->irqlock, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, sizeof(struct fimc_vid_buffer), (void *)ctx); 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: dev_err(&fimc->pdev->dev, "failed to install\n"); return ret; }
static int g2d_probe(struct platform_device *pdev) { struct g2d_dev *dev; struct video_device *vfd; struct resource *res; int ret = 0; dev = devm_kzalloc(&pdev->dev, 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); dev->regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(dev->regs)) return PTR_ERR(dev->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"); return -ENXIO; } 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 = devm_request_irq(&pdev->dev, 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 unprep_clk_gate; } 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; } video_set_drvdata(vfd, dev); snprintf(vfd->name, sizeof(vfd->name), "%s", g2d_videodev.name); dev->vfd = vfd; v4l2_info(&dev->v4l2_dev, "device registered as /dev/video%d\n", vfd->num); platform_set_drvdata(pdev, dev); dev->m2m_dev = v4l2_m2m_init(&g2d_m2m_ops); if (IS_ERR(dev->m2m_dev)) { v4l2_err(&dev->v4l2_dev, "Failed to init mem2mem device\n"); ret = PTR_ERR(dev->m2m_dev); goto unreg_video_dev; } def_frame.stride = (def_frame.width * def_frame.fmt->depth) >> 3; return 0; unreg_video_dev: video_unregister_device(dev->vfd); rel_vdev: video_device_release(vfd); unreg_v4l2_dev: v4l2_device_unregister(&dev->v4l2_dev); alloc_ctx_cleanup: vb2_dma_contig_cleanup_ctx(dev->alloc_ctx); unprep_clk_gate: clk_unprepare(dev->gate); put_clk_gate: clk_put(dev->gate); unprep_clk: clk_unprepare(dev->clk); put_clk: clk_put(dev->clk); return ret; }
/* * Probe */ static int __init s5p_tv_probe(struct platform_device *pdev) { int irq_num; int ret; int i; int err; ref_count_tv = 0; ref_count_g0 = 0; ref_count_g1 = 0; __s5p_sdout_probe(pdev, 0); __s5p_vp_probe(pdev, 1); __s5p_mixer_probe(pdev, 2); #ifdef CONFIG_CPU_S5PC110 tv_clk_get(pdev, &s5ptv_status); s5p_tv_clk_gate( true ); #endif #ifdef CONFIG_CPU_S5PC110 __s5p_hdmi_probe(pdev, 3, 4); #endif #ifdef CONFIG_CPU_S5PC100 __s5p_hdmi_probe(pdev, 3); __s5p_tvclk_probe(pdev, 4); #endif /* for dev_dbg err. */ /* clock */ #ifdef FIX_27M_UNSTABLE_ISSUE /* for smdkc100 pop */ writel(0x1, S5PC1XX_GPA0_BASE + 0x56c); #endif spin_lock_init(&slock_hpd); /* for bh */ INIT_WORK(&ws_hpd, (void *)set_ddc_port); /* check EINT init state */ #ifdef CONFIG_SMDKC110_BOARD s3c_gpio_cfgpin(S5PC11X_GPH1(5), S5PC11X_GPH1_5_HDMI_HPD); s3c_gpio_setpull(S5PC11X_GPH1(5), S3C_GPIO_PULL_DOWN); s5ptv_status.hpd_status = gpio_get_value(S5PC11X_GPH1(5)) ? false:true; dev_info(&pdev->dev, "hpd status is cable %s\n", s5ptv_status.hpd_status ? "inserted":"removed"); #endif /* interrupt */ TVOUT_IRQ_INIT(irq_num, ret, pdev, 0, out, __s5p_mixer_irq, "mixer"); TVOUT_IRQ_INIT(irq_num, ret, pdev, 1, out_hdmi_irq, __s5p_hdmi_irq , "hdmi"); TVOUT_IRQ_INIT(irq_num, ret, pdev, 2, out_tvenc_irq, s5p_tvenc_irq, "tvenc"); TVOUT_IRQ_INIT(irq_num, ret, pdev, 3, out_hpd_irq, __s5p_hpd_irq, "hpd"); #ifdef CONFIG_S5PC110_JUPITER_BOARD set_irq_type(IRQ_EINT13, IRQ_TYPE_EDGE_RISING); #endif /* v4l2 video device registration */ for (i = 0;i < S5P_TVMAX_CTRLS;i++) { s5ptv_status.video_dev[i] = &s5p_tvout[i]; if (video_register_device(s5ptv_status.video_dev[i], VFL_TYPE_GRABBER, s5p_tvout[i].minor) != 0) { dev_err(&pdev->dev, "Couldn't register tvout driver.\n"); return 0; } else dev_info(&pdev->dev, "%s registered successfully \n", s5p_tvout[i].name); } //mkh: //__s5p_hdmi_init_hpd_onoff(1); mutex_for_fo = (struct mutex *)kmalloc(sizeof(struct mutex), GFP_KERNEL); if (mutex_for_fo == NULL) { dev_err(&pdev->dev, "failed to create mutex handle\n"); goto out; } mutex_for_i2c= (struct mutex *)kmalloc(sizeof(struct mutex), GFP_KERNEL); if (mutex_for_i2c == NULL) { dev_err(&pdev->dev, "failed to create mutex handle\n"); goto out; } #ifdef CONFIG_CPU_S5PC110 s5p_tv_clk_gate(false); #endif mutex_init(mutex_for_fo); mutex_init(mutex_for_i2c); return 0; out_hpd_irq: free_irq(IRQ_TVENC, pdev); out_tvenc_irq: free_irq(IRQ_HDMI, pdev); out_hdmi_irq: free_irq(IRQ_MIXER, pdev); out: printk(KERN_ERR "not found (%d). \n", ret); return ret; }
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; int minor_offset = ivtv_stream_info[type].minor_offset; int minor; /* These four fields are always initialized. If v4l2dev == NULL, then this stream is not in use. In that case no other fields but these four can be used. */ s->v4l2dev = NULL; s->itv = itv; s->type = type; s->name = ivtv_stream_info[type].name; /* Check whether the radio is supported */ if (type == IVTV_ENC_STREAM_TYPE_RAD && !(itv->v4l2_cap & V4L2_CAP_RADIO)) return 0; if (type >= IVTV_DEC_STREAM_TYPE_MPG && !(itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT)) return 0; if (minor_offset >= 0) /* card number + user defined offset + device offset */ minor = itv->num + ivtv_first_minor + minor_offset; else minor = -1; /* User explicitly selected 0 buffers for these streams, so don't create them. */ if (minor >= 0 && ivtv_stream_info[type].dma != PCI_DMA_NONE && itv->options.megabytes[type] == 0) { IVTV_INFO("Disabled %s device\n", ivtv_stream_info[type].name); return 0; } ivtv_stream_init(itv, type); /* allocate and initialize the v4l2 video device structure */ s->v4l2dev = video_device_alloc(); if (s->v4l2dev == NULL) { IVTV_ERR("Couldn't allocate v4l2 video_device for %s\n", s->name); return -ENOMEM; } s->v4l2dev->type = VID_TYPE_CAPTURE | VID_TYPE_TUNER | VID_TYPE_TELETEXT | VID_TYPE_CLIPPING | VID_TYPE_SCALES | VID_TYPE_MPEG_ENCODER; if (itv->v4l2_cap & V4L2_CAP_VIDEO_OUTPUT) { s->v4l2dev->type |= VID_TYPE_MPEG_DECODER; } snprintf(s->v4l2dev->name, sizeof(s->v4l2dev->name), "ivtv%d %s", itv->num, s->name); s->v4l2dev->minor = minor; s->v4l2dev->dev = &itv->dev->dev; s->v4l2dev->fops = ivtv_stream_info[type].fops; s->v4l2dev->release = video_device_release; if (minor >= 0) { /* Register device. First try the desired minor, then any free one. */ if (video_register_device(s->v4l2dev, vfl_type, minor) && video_register_device(s->v4l2dev, vfl_type, -1)) { IVTV_ERR("Couldn't register v4l2 device for %s minor %d\n", s->name, minor); video_device_release(s->v4l2dev); s->v4l2dev = NULL; return -ENOMEM; } } else { /* Don't register a 'hidden' stream (OSD) */ IVTV_INFO("Created framebuffer stream for %s\n", s->name); return 0; } switch (vfl_type) { case VFL_TYPE_GRABBER: IVTV_INFO("Registered device video%d for %s (%d MB)\n", s->v4l2dev->minor, s->name, itv->options.megabytes[type]); break; case VFL_TYPE_RADIO: IVTV_INFO("Registered device radio%d for %s\n", s->v4l2dev->minor - MINOR_VFL_TYPE_RADIO_MIN, s->name); break; case VFL_TYPE_VBI: if (itv->options.megabytes[type]) IVTV_INFO("Registered device vbi%d for %s (%d MB)\n", s->v4l2dev->minor - MINOR_VFL_TYPE_VBI_MIN, s->name, itv->options.megabytes[type]); else IVTV_INFO("Registered device vbi%d for %s\n", s->v4l2dev->minor - MINOR_VFL_TYPE_VBI_MIN, s->name); break; } return 0; }
int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, const char *name, int is_pix) { struct media_pad *pad = &video->pad; struct video_device *vdev; struct vb2_queue *q; int ret; vdev = &video->vdev; mutex_init(&video->q_lock); q = &video->vb2_q; q->drv_priv = video; q->mem_ops = &vb2_dma_sg_memops; q->ops = &msm_video_vb2_q_ops; q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; q->io_modes = VB2_DMABUF | VB2_MMAP | VB2_READ; q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; q->buf_struct_size = sizeof(struct camss_buffer); q->dev = video->camss->dev; q->lock = &video->q_lock; ret = vb2_queue_init(q); if (ret < 0) { dev_err(v4l2_dev->dev, "Failed to init vb2 queue: %d\n", ret); goto error_vb2_init; } pad->flags = MEDIA_PAD_FL_SINK; ret = media_entity_pads_init(&vdev->entity, 1, pad); if (ret < 0) { dev_err(v4l2_dev->dev, "Failed to init video entity: %d\n", ret); goto error_media_init; } mutex_init(&video->lock); video->formats = formats_rdi; video->nformats = ARRAY_SIZE(formats_rdi); if (is_pix) { video->formats = formats_pix; video->nformats = ARRAY_SIZE(formats_pix); } ret = msm_video_init_format(video); if (ret < 0) { dev_err(v4l2_dev->dev, "Failed to init format: %d\n", ret); goto error_video_register; } vdev->fops = &msm_vid_fops; vdev->device_caps = V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_STREAMING | V4L2_CAP_READWRITE; vdev->ioctl_ops = &msm_vid_ioctl_ops; vdev->release = msm_video_release; vdev->v4l2_dev = v4l2_dev; vdev->vfl_dir = VFL_DIR_RX; vdev->queue = &video->vb2_q; vdev->lock = &video->lock; strlcpy(vdev->name, name, sizeof(vdev->name)); ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); if (ret < 0) { dev_err(v4l2_dev->dev, "Failed to register video device: %d\n", ret); goto error_video_register; } video_set_drvdata(vdev, video); atomic_inc(&video->camss->ref_count); return 0; error_video_register: media_entity_cleanup(&vdev->entity); mutex_destroy(&video->lock); error_media_init: vb2_queue_release(&video->vb2_q); error_vb2_init: mutex_destroy(&video->q_lock); return ret; }
static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev(intf); struct pwc_device *pdev = NULL; int vendor_id, product_id, type_id; int rc; int features = 0; int compression = 0; int my_power_save = power_save; char serial_number[30], *name; vendor_id = le16_to_cpu(udev->descriptor.idVendor); product_id = le16_to_cpu(udev->descriptor.idProduct); /* Check if we can handle this device */ PWC_DEBUG_PROBE("probe() called [%04X %04X], if %d\n", vendor_id, product_id, intf->altsetting->desc.bInterfaceNumber); /* the interfaces are probed one by one. We are only interested in the video interface (0) now. Interface 1 is the Audio Control, and interface 2 Audio itself. */ if (intf->altsetting->desc.bInterfaceNumber > 0) return -ENODEV; if (vendor_id == 0x0471) { switch (product_id) { case 0x0302: PWC_INFO("Philips PCA645VC USB webcam detected.\n"); name = "Philips 645 webcam"; type_id = 645; break; case 0x0303: PWC_INFO("Philips PCA646VC USB webcam detected.\n"); name = "Philips 646 webcam"; type_id = 646; break; case 0x0304: PWC_INFO("Askey VC010 type 2 USB webcam detected.\n"); name = "Askey VC010 webcam"; type_id = 646; break; case 0x0307: PWC_INFO("Philips PCVC675K (Vesta) USB webcam detected.\n"); name = "Philips 675 webcam"; type_id = 675; break; case 0x0308: PWC_INFO("Philips PCVC680K (Vesta Pro) USB webcam detected.\n"); name = "Philips 680 webcam"; type_id = 680; break; case 0x030C: PWC_INFO("Philips PCVC690K (Vesta Pro Scan) USB webcam detected.\n"); name = "Philips 690 webcam"; type_id = 690; break; case 0x0310: PWC_INFO("Philips PCVC730K (ToUCam Fun)/PCVC830 (ToUCam II) USB webcam detected.\n"); name = "Philips 730 webcam"; type_id = 730; break; case 0x0311: PWC_INFO("Philips PCVC740K (ToUCam Pro)/PCVC840 (ToUCam II) USB webcam detected.\n"); name = "Philips 740 webcam"; type_id = 740; break; case 0x0312: PWC_INFO("Philips PCVC750K (ToUCam Pro Scan) USB webcam detected.\n"); name = "Philips 750 webcam"; type_id = 750; break; case 0x0313: PWC_INFO("Philips PCVC720K/40 (ToUCam XS) USB webcam detected.\n"); name = "Philips 720K/40 webcam"; type_id = 720; break; case 0x0329: PWC_INFO("Philips SPC 900NC USB webcam detected.\n"); name = "Philips SPC 900NC webcam"; type_id = 740; break; default: return -ENODEV; break; } } else if (vendor_id == 0x069A) { switch(product_id) { case 0x0001: PWC_INFO("Askey VC010 type 1 USB webcam detected.\n"); name = "Askey VC010 webcam"; type_id = 645; break; default: return -ENODEV; break; } } else if (vendor_id == 0x046d) { switch(product_id) { case 0x08b0: PWC_INFO("Logitech QuickCam Pro 3000 USB webcam detected.\n"); name = "Logitech QuickCam Pro 3000"; type_id = 740; /* CCD sensor */ break; case 0x08b1: PWC_INFO("Logitech QuickCam Notebook Pro USB webcam detected.\n"); name = "Logitech QuickCam Notebook Pro"; type_id = 740; /* CCD sensor */ break; case 0x08b2: PWC_INFO("Logitech QuickCam 4000 Pro USB webcam detected.\n"); name = "Logitech QuickCam Pro 4000"; type_id = 740; /* CCD sensor */ if (my_power_save == -1) my_power_save = 1; break; case 0x08b3: PWC_INFO("Logitech QuickCam Zoom USB webcam detected.\n"); name = "Logitech QuickCam Zoom"; type_id = 740; /* CCD sensor */ break; case 0x08B4: PWC_INFO("Logitech QuickCam Zoom (new model) USB webcam detected.\n"); name = "Logitech QuickCam Zoom"; type_id = 740; /* CCD sensor */ if (my_power_save == -1) my_power_save = 1; break; case 0x08b5: PWC_INFO("Logitech QuickCam Orbit/Sphere USB webcam detected.\n"); name = "Logitech QuickCam Orbit"; type_id = 740; /* CCD sensor */ if (my_power_save == -1) my_power_save = 1; features |= FEATURE_MOTOR_PANTILT; break; case 0x08b6: PWC_INFO("Logitech/Cisco VT Camera webcam detected.\n"); name = "Cisco VT Camera"; type_id = 740; /* CCD sensor */ break; case 0x08b7: PWC_INFO("Logitech ViewPort AV 100 webcam detected.\n"); name = "Logitech ViewPort AV 100"; type_id = 740; /* CCD sensor */ break; case 0x08b8: /* Where this released? */ PWC_INFO("Logitech QuickCam detected (reserved ID).\n"); name = "Logitech QuickCam (res.)"; type_id = 730; /* Assuming CMOS */ break; default: return -ENODEV; break; } } else if (vendor_id == 0x055d) { /* I don't know the difference between the C10 and the C30; I suppose the difference is the sensor, but both cameras work equally well with a type_id of 675 */ switch(product_id) { case 0x9000: PWC_INFO("Samsung MPC-C10 USB webcam detected.\n"); name = "Samsung MPC-C10"; type_id = 675; break; case 0x9001: PWC_INFO("Samsung MPC-C30 USB webcam detected.\n"); name = "Samsung MPC-C30"; type_id = 675; break; case 0x9002: PWC_INFO("Samsung SNC-35E (v3.0) USB webcam detected.\n"); name = "Samsung MPC-C30"; type_id = 740; break; default: return -ENODEV; break; } } else if (vendor_id == 0x041e) { switch(product_id) { case 0x400c: PWC_INFO("Creative Labs Webcam 5 detected.\n"); name = "Creative Labs Webcam 5"; type_id = 730; if (my_power_save == -1) my_power_save = 1; break; case 0x4011: PWC_INFO("Creative Labs Webcam Pro Ex detected.\n"); name = "Creative Labs Webcam Pro Ex"; type_id = 740; break; default: return -ENODEV; break; } } else if (vendor_id == 0x04cc) { switch(product_id) { case 0x8116: PWC_INFO("Sotec Afina Eye USB webcam detected.\n"); name = "Sotec Afina Eye"; type_id = 730; break; default: return -ENODEV; break; } } else if (vendor_id == 0x06be) { switch(product_id) { case 0x8116: /* This is essentially the same cam as the Sotec Afina Eye */ PWC_INFO("AME Co. Afina Eye USB webcam detected.\n"); name = "AME Co. Afina Eye"; type_id = 750; break; default: return -ENODEV; break; } } else if (vendor_id == 0x0d81) { switch(product_id) { case 0x1900: PWC_INFO("Visionite VCS-UC300 USB webcam detected.\n"); name = "Visionite VCS-UC300"; type_id = 740; /* CCD sensor */ break; case 0x1910: PWC_INFO("Visionite VCS-UM100 USB webcam detected.\n"); name = "Visionite VCS-UM100"; type_id = 730; /* CMOS sensor */ break; default: return -ENODEV; break; } } else return -ENODEV; /* Not any of the know types; but the list keeps growing. */ if (my_power_save == -1) my_power_save = 0; memset(serial_number, 0, 30); usb_string(udev, udev->descriptor.iSerialNumber, serial_number, 29); PWC_DEBUG_PROBE("Device serial number is %s\n", serial_number); if (udev->descriptor.bNumConfigurations > 1) PWC_WARNING("Warning: more than 1 configuration available.\n"); /* Allocate structure, initialize pointers, mutexes, etc. and link it to the usb_device */ pdev = kzalloc(sizeof(struct pwc_device), GFP_KERNEL); if (pdev == NULL) { PWC_ERROR("Oops, could not allocate memory for pwc_device.\n"); return -ENOMEM; } pdev->type = type_id; pdev->features = features; pwc_construct(pdev); /* set min/max sizes correct */ mutex_init(&pdev->v4l2_lock); mutex_init(&pdev->vb_queue_lock); spin_lock_init(&pdev->queued_bufs_lock); INIT_LIST_HEAD(&pdev->queued_bufs); pdev->udev = udev; pdev->power_save = my_power_save; /* Init videobuf2 queue structure */ pdev->vb_queue.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; pdev->vb_queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; pdev->vb_queue.drv_priv = pdev; pdev->vb_queue.buf_struct_size = sizeof(struct pwc_frame_buf); pdev->vb_queue.ops = &pwc_vb_queue_ops; pdev->vb_queue.mem_ops = &vb2_vmalloc_memops; pdev->vb_queue.timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; rc = vb2_queue_init(&pdev->vb_queue); if (rc < 0) { PWC_ERROR("Oops, could not initialize vb2 queue.\n"); goto err_free_mem; } /* Init video_device structure */ pdev->vdev = pwc_template; strcpy(pdev->vdev.name, name); pdev->vdev.queue = &pdev->vb_queue; pdev->vdev.queue->lock = &pdev->vb_queue_lock; set_bit(V4L2_FL_USE_FH_PRIO, &pdev->vdev.flags); video_set_drvdata(&pdev->vdev, pdev); pdev->release = le16_to_cpu(udev->descriptor.bcdDevice); PWC_DEBUG_PROBE("Release: %04x\n", pdev->release); /* Allocate USB command buffers */ pdev->ctrl_buf = kmalloc(sizeof(pdev->cmd_buf), GFP_KERNEL); if (!pdev->ctrl_buf) { PWC_ERROR("Oops, could not allocate memory for pwc_device.\n"); rc = -ENOMEM; goto err_free_mem; } #ifdef CPTCFG_USB_PWC_DEBUG /* Query sensor type */ if (pwc_get_cmos_sensor(pdev, &rc) >= 0) { PWC_DEBUG_OPEN("This %s camera is equipped with a %s (%d).\n", pdev->vdev.name, pwc_sensor_type_to_string(rc), rc); } #endif /* Set the leds off */ pwc_set_leds(pdev, 0, 0); /* Setup initial videomode */ rc = pwc_set_video_mode(pdev, MAX_WIDTH, MAX_HEIGHT, V4L2_PIX_FMT_YUV420, 30, &compression, 1); if (rc) goto err_free_mem; /* Register controls (and read default values from camera */ rc = pwc_init_controls(pdev); if (rc) { PWC_ERROR("Failed to register v4l2 controls (%d).\n", rc); goto err_free_mem; } /* And powerdown the camera until streaming starts */ pwc_camera_power(pdev, 0); /* Register the v4l2_device structure */ pdev->v4l2_dev.release = pwc_video_release; rc = v4l2_device_register(&intf->dev, &pdev->v4l2_dev); if (rc) { PWC_ERROR("Failed to register v4l2-device (%d).\n", rc); goto err_free_controls; } pdev->v4l2_dev.ctrl_handler = &pdev->ctrl_handler; pdev->vdev.v4l2_dev = &pdev->v4l2_dev; pdev->vdev.lock = &pdev->v4l2_lock; rc = video_register_device(&pdev->vdev, VFL_TYPE_GRABBER, -1); if (rc < 0) { PWC_ERROR("Failed to register as video device (%d).\n", rc); goto err_unregister_v4l2_dev; } PWC_INFO("Registered as %s.\n", video_device_node_name(&pdev->vdev)); #ifdef CPTCFG_USB_PWC_INPUT_EVDEV /* register webcam snapshot button input device */ pdev->button_dev = input_allocate_device(); if (!pdev->button_dev) { PWC_ERROR("Err, insufficient memory for webcam snapshot button device."); rc = -ENOMEM; goto err_video_unreg; } usb_make_path(udev, pdev->button_phys, sizeof(pdev->button_phys)); strlcat(pdev->button_phys, "/input0", sizeof(pdev->button_phys)); pdev->button_dev->name = "PWC snapshot button"; pdev->button_dev->phys = pdev->button_phys; usb_to_input_id(pdev->udev, &pdev->button_dev->id); pdev->button_dev->dev.parent = &pdev->udev->dev; pdev->button_dev->evbit[0] = BIT_MASK(EV_KEY); pdev->button_dev->keybit[BIT_WORD(KEY_CAMERA)] = BIT_MASK(KEY_CAMERA); rc = input_register_device(pdev->button_dev); if (rc) { input_free_device(pdev->button_dev); pdev->button_dev = NULL; goto err_video_unreg; } #endif return 0; err_video_unreg: video_unregister_device(&pdev->vdev); err_unregister_v4l2_dev: v4l2_device_unregister(&pdev->v4l2_dev); err_free_controls: v4l2_ctrl_handler_free(&pdev->ctrl_handler); err_free_mem: kfree(pdev->ctrl_buf); kfree(pdev); return rc; }
static int __devinit s5p_tv_probe(struct platform_device *pdev) { int irq_num; int ret; int i; s5ptv_status.dev_fb = &pdev->dev; suspend_resume_sync = 0; is_tv_clk_on = false; is_tv_phy_enable = false; //enable power /* Get csis power domain regulator */ s5ptv_status.tv_regulator = regulator_get(&pdev->dev, "pd"); if (IS_ERR(s5ptv_status.tv_regulator)) { printk(KERN_ERR "%s %d: failed to get resource %s\n", __func__, __LINE__, "s3c-tv20 pd"); return PTR_ERR(s5ptv_status.tv_regulator); } s5ptv_status.tv_tvout = regulator_get(NULL, "tvout"); if (IS_ERR(s5ptv_status.tv_tvout)) { printk(KERN_ERR "%s %d: failed to get resource %s\n", __func__, __LINE__, "s3c-tv20 tvout"); return PTR_ERR(s5ptv_status.tv_tvout); } s5ptv_status.tv_tv = regulator_get(NULL, "hdmi"); if (IS_ERR(s5ptv_status.tv_tv)) { printk(KERN_ERR "%s %d: failed to get resource %s\n", __func__, __LINE__, "s3c-tv20 tv"); return PTR_ERR(s5ptv_status.tv_tv); } regulator_enable(s5ptv_status.tv_tv); regulator_enable(s5ptv_status.tv_tvout); s5ptv_status.dev_fb = &pdev->dev; __s5p_sdout_probe(pdev, 0); __s5p_vp_probe(pdev, 1); __s5p_mixer_probe(pdev, 2); #ifdef CONFIG_CPU_S5PV210 tv_clk_get(pdev, &s5ptv_status); s5p_tv_clk_gate(true); #endif #ifdef CONFIG_CPU_S5PV210 __s5p_hdmi_probe(pdev, 3, 4); __s5p_hdcp_init(); #endif #ifdef FIX_27M_UNSTABLE_ISSUE /* for smdkc100 pop */ writel(0x1, S5PC1XX_GPA0_BASE + 0x56c); #endif #ifdef I2C_BASE /* for dev_dbg err. */ spin_lock_init(&slock_hpd); /* for bh */ INIT_WORK(&ws_hpd, (void *)set_ddc_port); #endif /* check EINT init state */ #ifdef CONFIG_MACH_STEALTHV gpio_set_value(GPIO_HDMI_EN1, 1); #endif s5ptv_status.hpd_status= 0; dev_info(&pdev->dev, "hpd status is cable %s\n", s5ptv_status.hpd_status ? "inserted":"removed"); /* interrupt */ TVOUT_IRQ_INIT(irq_num, ret, pdev, 0, out, __s5p_mixer_irq, "mixer"); TVOUT_IRQ_INIT(irq_num, ret, pdev, 1, out_hdmi_irq, __s5p_hdmi_irq , "hdmi"); TVOUT_IRQ_INIT(irq_num, ret, pdev, 2, out_tvenc_irq, s5p_tvenc_irq, "tvenc"); /* v4l2 video device registration */ for (i = 0; i < S5P_TVMAX_CTRLS; i++) { s5ptv_status.video_dev[i] = &s5p_tvout[i]; if (video_register_device(s5ptv_status.video_dev[i], VFL_TYPE_GRABBER, s5p_tvout[i].minor) != 0) { dev_err(&pdev->dev, "Couldn't register tvout driver.\n"); return 0; } } #ifdef CONFIG_TV_FB mutex_init(&s5ptv_status.fb_lock); /* for default start up */ _s5p_tv_if_init_param(); s5ptv_status.tvout_param.disp_mode = TVOUT_720P_60; s5ptv_status.tvout_param.out_mode = TVOUT_OUTPUT_HDMI; #ifndef CONFIG_USER_ALLOC_TVOUT s5p_tv_clk_gate(true); if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_DVI) tv_phy_power(true); _s5p_tv_if_set_disp(); #endif s5ptvfb_set_lcd_info(&s5ptv_status); /* prepare memory */ if (s5ptvfb_alloc_framebuffer()) goto err_alloc; if (s5ptvfb_register_framebuffer()) goto err_alloc; #ifndef CONFIG_USER_ALLOC_TVOUT s5ptvfb_display_on(&s5ptv_status); #endif #endif mutex_for_fo = kmalloc(sizeof(struct mutex), GFP_KERNEL); if (mutex_for_fo == NULL) { dev_err(&pdev->dev, "failed to create mutex handle\n"); goto out; } #ifdef I2C_BASE mutex_for_i2c = kmalloc(sizeof(struct mutex), GFP_KERNEL); if (mutex_for_i2c == NULL) { dev_err(&pdev->dev, "failed to create mutex handle\n"); goto out; } mutex_init(mutex_for_i2c); #endif mutex_init(mutex_for_fo); #ifdef CONFIG_CPU_S5PV210 /* added for phy cut off when boot up */ clk_enable(s5ptv_status.i2c_phy_clk); __s5p_hdmi_phy_power(false); clk_disable(s5ptv_status.i2c_phy_clk); s5p_tv_clk_gate(false); #endif regulator_disable(s5ptv_status.tv_tv); regulator_disable(s5ptv_status.tv_tvout); printk("tv_base_probe is successfully\n"); return 0; #ifdef CONFIG_TV_FB err_alloc: #endif out_tvenc_irq: free_irq(IRQ_HDMI, pdev); out_hdmi_irq: free_irq(IRQ_MIXER, pdev); out: printk(KERN_ERR "not found (%d). \n", ret); return ret; }
static int fimc_is_probe(struct platform_device *pdev) { struct exynos4_platform_fimc_is *pdata; struct resource *mem_res; struct resource *regs_res; struct fimc_is_dev *dev; #if defined(CONFIG_VIDEO_EXYNOS_FIMC_IS_BAYER) struct v4l2_device *v4l2_dev; struct vb2_queue *isp_q; #endif int ret = -ENODEV; dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { dev_err(&pdev->dev, "Not enough memory for FIMC-IS device.\n"); return -ENOMEM; } mutex_init(&dev->lock); spin_lock_init(&dev->slock); init_waitqueue_head(&dev->irq_queue1); dev->pdev = pdev; if (!dev->pdev) { dev_err(&pdev->dev, "No platform data specified\n"); goto p_err_info; } pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "Platform data not set\n"); goto p_err_info; } dev->pdata = pdata; /* * I/O remap */ mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem_res) { dev_err(&pdev->dev, "Failed to get io memory region\n"); ret = -ENOENT; goto p_err_info; } regs_res = request_mem_region(mem_res->start, resource_size(mem_res), pdev->name); if (!regs_res) { dev_err(&pdev->dev, "Failed to request io memory region\n"); ret = -ENOENT; goto p_err_info; } dev->regs_res = regs_res; dev->regs = ioremap(mem_res->start, resource_size(mem_res)); if (!dev->regs) { dev_err(&pdev->dev, "Failed to remap io region\n"); ret = -ENXIO; goto p_err_req_region; } /* * initialize IRQ , FIMC-IS IRQ : ISP[0] -> SPI[90] , ISP[1] -> SPI[95] */ dev->irq1 = platform_get_irq(pdev, 0); if (dev->irq1 < 0) { ret = dev->irq1; dev_err(&pdev->dev, "Failed to get irq\n"); goto p_err_get_irq; } ret = request_irq(dev->irq1, fimc_is_irq_handler1, IRQF_DISABLED, dev_name(&pdev->dev), dev); if (ret) { dev_err(&pdev->dev, "failed to allocate irq (%d)\n", ret); goto p_err_req_irq; } #if defined(CONFIG_VIDEO_EXYNOS_FIMC_IS_BAYER) /* Init v4l2 device (ISP) */ #if defined(CONFIG_VIDEOBUF2_CMA_PHYS) dev->vb2 = &fimc_is_vb2_cma; #elif defined(CONFIG_VIDEOBUF2_ION) dev->vb2 = &fimc_is_vb2_ion; #endif /* Init and register V4L2 device */ v4l2_dev = &dev->video[FIMC_IS_VIDEO_NUM_BAYER].v4l2_dev; if (!v4l2_dev->name[0]) snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s.isp", dev_name(&dev->pdev->dev)); ret = v4l2_device_register(NULL, v4l2_dev); if (ret) { v4l2_err(v4l2_dev, "Failed to register v4l2 device\n"); goto err_vd_reg; } snprintf(dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd.name, sizeof(dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd.name), "%s", "exynos4-fimc-is-bayer"); dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd.fops = &fimc_is_isp_video_fops; dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd.ioctl_ops = &fimc_is_isp_video_ioctl_ops; dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd.minor = -1; dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd.release = video_device_release; dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd.lock = &dev->lock; video_set_drvdata(&dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd, dev); dev->video[FIMC_IS_VIDEO_NUM_BAYER].dev = dev; isp_q = &dev->video[FIMC_IS_VIDEO_NUM_BAYER].vbq; memset(isp_q, 0, sizeof(*isp_q)); isp_q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; isp_q->io_modes = VB2_MMAP | VB2_USERPTR; isp_q->drv_priv = &dev->video[FIMC_IS_VIDEO_NUM_BAYER]; isp_q->ops = &fimc_is_isp_qops; isp_q->mem_ops = dev->vb2->ops; vb2_queue_init(isp_q); ret = video_register_device(&dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd, VFL_TYPE_GRABBER, 30); if (ret) goto p_err_device_register; printk(KERN_INFO "FIMC-IS Video node :: ISP %d minor : %d\n", dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd.num, dev->video[FIMC_IS_VIDEO_NUM_BAYER].vd.minor); #endif /* * initialize memory manager */ ret = fimc_is_init_mem_mgr(dev); if (ret) { dev_err(&pdev->dev, "failed to fimc_is_init_mem_mgr (%d)\n", ret); goto p_err_init_mem; } dbg("Parameter region = 0x%08x\n", (unsigned int)dev->is_p_region); /* * Get related clock for FIMC-IS */ if (dev->pdata->clk_get) { dev->pdata->clk_get(pdev); } else { err("#### failed to Get Clock####\n"); ret = -EINVAL; goto p_err_init_mem; } /* Init v4l2 sub device */ v4l2_subdev_init(&dev->sd, &fimc_is_subdev_ops); dev->sd.owner = THIS_MODULE; strcpy(dev->sd.name, MODULE_NAME); v4l2_set_subdevdata(&dev->sd, pdev); platform_set_drvdata(pdev, &dev->sd); pm_runtime_enable(&pdev->dev); #if defined(CONFIG_BUSFREQ_OPP) || defined(CONFIG_BUSFREQ_LOCK_WRAPPER) /* To lock bus frequency in OPP mode */ dev->bus_dev = dev_get("exynos-busfreq"); #endif dev->power = 0; dev->state = 0; dev->sensor_num = FIMC_IS_SENSOR_NUM; dev->sensor.id = 0; dev->p_region_index1 = 0; dev->p_region_index2 = 0; dev->sensor.offset_x = 16; dev->sensor.offset_y = 12; dev->sensor.framerate_update = false; atomic_set(&dev->p_region_num, 0); set_bit(IS_ST_IDLE, &dev->state); set_bit(IS_PWR_ST_POWEROFF, &dev->power); dev->af.af_state = FIMC_IS_AF_IDLE; dev->af.mode = IS_FOCUS_MODE_IDLE; dev->low_power_mode = false; dev->fw.state = 0; dev->setfile.state = 0; s5k6a3_dev = device_create(camera_class, NULL, 0, NULL, "front"); if (IS_ERR(s5k6a3_dev)) { printk(KERN_ERR "failed to create device!\n"); } else { if (device_create_file(s5k6a3_dev, &dev_attr_front_camtype) < 0) { printk(KERN_ERR "failed to create device file, %s\n", dev_attr_front_camtype.attr.name); } if (device_create_file(s5k6a3_dev, &dev_attr_front_camfw) < 0) { printk(KERN_ERR "failed to create device file, %s\n", dev_attr_front_camfw.attr.name); } } printk(KERN_INFO "FIMC-IS probe completed\n"); return 0; p_err_init_mem: #if defined(CONFIG_VIDEO_EXYNOS_FIMC_IS_BAYER) err_vd_reg: p_err_device_register: #endif free_irq(dev->irq1, dev); p_err_req_irq: p_err_get_irq: iounmap(dev->regs); p_err_req_region: release_mem_region(regs_res->start, resource_size(regs_res)); p_err_info: dev_err(&dev->pdev->dev, "failed to install\n"); kfree(dev); return ret; }
static int empress_init(struct saa7134_dev *dev) { struct v4l2_ctrl_handler *hdl = &dev->empress_ctrl_handler; struct vb2_queue *q; 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->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_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; 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) { 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)); empress_signal_update(&dev->empress_workqueue); return 0; }
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, 1); 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; }
/* * 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 ch->common[VPIF_VIDEO_INDEX].numbuffers = 0; memset(&ch->vpifparams, 0, sizeof(ch->vpifparams)); /* Initialize prio member of channel object */ v4l2_prio_init(&ch->prio); ch->common[VPIF_VIDEO_INDEX].fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; /* register video device */ vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n", (int)ch, (int)&ch->video_dev); err = video_register_device(ch->video_dev, VFL_TYPE_GRABBER, (j ? 3 : 2)); if (err < 0) 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; subdevdata = config->subdevinfo; 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; } for (i = 0; i < subdev_count; i++) { vpif_obj.sd[i] = v4l2_i2c_new_subdev_board(&vpif_obj.v4l2_dev, i2c_adap, subdevdata[i].name, &subdevdata[i].board_info, NULL); if (!vpif_obj.sd[i]) { vpif_err("Error registering v4l2 subdevice\n"); goto probe_subdev_out; } if (vpif_obj.sd[i]) vpif_obj.sd[i]->grp_id = 1 << i; } return 0; probe_subdev_out: kfree(vpif_obj.sd); probe_out: for (k = 0; k < j; k++) { ch = vpif_obj.dev[k]; video_unregister_device(ch->video_dev); video_device_release(ch->video_dev); ch->video_dev = NULL; } vpif_int_err: v4l2_device_unregister(&vpif_obj.v4l2_dev); vpif_err("VPIF IRQ request failed\n"); for (q = k; k >= 0; k--) { for (m = i; m >= res->start; m--) free_irq(m, (void *)(&vpif_obj.dev[k]->channel_id)); res = platform_get_resource(pdev, IORESOURCE_IRQ, k-1); m = res->end; } return err; }
static int radio_isa_common_probe(struct radio_isa_card *isa, struct device *pdev, int radio_nr, unsigned region_size) { const struct radio_isa_driver *drv = isa->drv; const struct radio_isa_ops *ops = drv->ops; struct v4l2_device *v4l2_dev = &isa->v4l2_dev; int res; if (!request_region(isa->io, region_size, v4l2_dev->name)) { v4l2_err(v4l2_dev, "port 0x%x already in use\n", isa->io); kfree(isa); return -EBUSY; } res = v4l2_device_register(pdev, v4l2_dev); if (res < 0) { v4l2_err(v4l2_dev, "Could not register v4l2_device\n"); goto err_dev_reg; } v4l2_ctrl_handler_init(&isa->hdl, 1); isa->mute = v4l2_ctrl_new_std(&isa->hdl, &radio_isa_ctrl_ops, V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); if (drv->max_volume) isa->volume = v4l2_ctrl_new_std(&isa->hdl, &radio_isa_ctrl_ops, V4L2_CID_AUDIO_VOLUME, 0, drv->max_volume, 1, drv->max_volume); v4l2_dev->ctrl_handler = &isa->hdl; if (isa->hdl.error) { res = isa->hdl.error; v4l2_err(v4l2_dev, "Could not register controls\n"); goto err_hdl; } if (drv->max_volume) v4l2_ctrl_cluster(2, &isa->mute); v4l2_dev->ctrl_handler = &isa->hdl; mutex_init(&isa->lock); isa->vdev.lock = &isa->lock; strscpy(isa->vdev.name, v4l2_dev->name, sizeof(isa->vdev.name)); isa->vdev.v4l2_dev = v4l2_dev; isa->vdev.fops = &radio_isa_fops; isa->vdev.ioctl_ops = &radio_isa_ioctl_ops; isa->vdev.release = video_device_release_empty; video_set_drvdata(&isa->vdev, isa); isa->freq = FREQ_LOW; isa->stereo = drv->has_stereo; if (ops->init) res = ops->init(isa); if (!res) res = v4l2_ctrl_handler_setup(&isa->hdl); if (!res) res = ops->s_frequency(isa, isa->freq); if (!res && ops->s_stereo) res = ops->s_stereo(isa, isa->stereo); if (res < 0) { v4l2_err(v4l2_dev, "Could not setup card\n"); goto err_hdl; } res = video_register_device(&isa->vdev, VFL_TYPE_RADIO, radio_nr); if (res < 0) { v4l2_err(v4l2_dev, "Could not register device node\n"); goto err_hdl; } v4l2_info(v4l2_dev, "Initialized radio card %s on port 0x%03x\n", drv->card, isa->io); return 0; err_hdl: v4l2_ctrl_handler_free(&isa->hdl); err_dev_reg: release_region(isa->io, region_size); kfree(isa); return res; }
static int __devinit s5p_tv_probe(struct platform_device *pdev) { int irq_num; int ret; int i,retval; s5ptv_status.dev_fb = &pdev->dev; //enable power max8998_ldo3_8_control(1,LDO_TV_OUT); //ldo 3,8 on printk("%s: LDO3_8 is enabled by TV \n", __func__); __s5p_sdout_probe(pdev, 0); __s5p_vp_probe(pdev, 1); __s5p_mixer_probe(pdev, 2); #ifdef CONFIG_CPU_S5PC100 __s5p_hdmi_probe(pdev, 3); __s5p_tvclk_probe(pdev, 4); #endif #ifdef CONFIG_CPU_S5PV210 tv_clk_get(pdev, &s5ptv_status); s5p_tv_clk_gate( true ); #endif #ifdef CONFIG_CPU_S5PV210 __s5p_hdmi_probe(pdev, 3, 4); __s5p_hdcp_init( ); #endif #ifdef FIX_27M_UNSTABLE_ISSUE /* for smdkc100 pop */ writel(0x1, S5PC1XX_GPA0_BASE + 0x56c); #endif #ifdef I2C_BASE /* for dev_dbg err. */ spin_lock_init(&slock_hpd); /* for bh */ INIT_WORK(&ws_hpd, (void *)set_ddc_port); #endif /* check EINT init state */ #ifdef CONFIG_CPU_S5PC100 s3c_gpio_cfgpin(S5PC1XX_GPH0(5), S3C_GPIO_SFN(2)); s3c_gpio_setpull(S5PC1XX_GPH0(5), S3C_GPIO_PULL_UP); s5ptv_status.hpd_status = gpio_get_value(S5PC1XX_GPH0(5)) ? false:true; #endif #ifdef CONFIG_CPU_S5PV210 #ifdef CONFIG_HDMI_HPD if(0 == gpio_get_value(GPIO_ACCESSORY_INT)) //docking station attached s5ptv_status.hpd_status= s5p_hpd_get_state(); else s5ptv_status.hpd_status= 0; #else s5ptv_status.hpd_status= 0; #endif #endif dev_info(&pdev->dev, "hpd status is cable %s\n", s5ptv_status.hpd_status ? "inserted":"removed"); /* interrupt */ TVOUT_IRQ_INIT(irq_num, ret, pdev, 0, out, __s5p_mixer_irq, "mixer"); TVOUT_IRQ_INIT(irq_num, ret, pdev, 1, out_hdmi_irq, __s5p_hdmi_irq , "hdmi"); TVOUT_IRQ_INIT(irq_num, ret, pdev, 2, out_tvenc_irq, s5p_tvenc_irq, "tvenc"); #ifdef CONFIG_CPU_S5PC100 TVOUT_IRQ_INIT(irq_num, ret, pdev, 3, out_hpd_irq, __s5p_hpd_irq, "hpd"); set_irq_type(IRQ_EINT5, IRQ_TYPE_LEVEL_LOW); #endif /* v4l2 video device registration */ for (i = 0; i < S5P_TVMAX_CTRLS; i++) { s5ptv_status.video_dev[i] = &s5p_tvout[i]; if (video_register_device(s5ptv_status.video_dev[i], VFL_TYPE_GRABBER, s5p_tvout[i].minor) != 0) { dev_err(&pdev->dev, "Couldn't register tvout driver.\n"); return 0; } } #ifdef CONFIG_TV_FB mutex_init(&s5ptv_status.fb_lock); /* for default start up */ _s5p_tv_if_init_param(); s5ptv_status.tvout_param.disp_mode = TVOUT_720P_60; s5ptv_status.tvout_param.out_mode = TVOUT_OUTPUT_HDMI; #ifndef CONFIG_USER_ALLOC_TVOUT s5p_tv_clk_gate(true); if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_DVI) tv_phy_power(true); _s5p_tv_if_set_disp(); #endif s5ptvfb_set_lcd_info(&s5ptv_status); /* prepare memory */ if (s5ptvfb_alloc_framebuffer()) goto err_alloc; if (s5ptvfb_register_framebuffer()) goto err_alloc; #ifndef CONFIG_USER_ALLOC_TVOUT s5ptvfb_display_on(&s5ptv_status); #endif #endif mutex_for_fo = kmalloc(sizeof(struct mutex), GFP_KERNEL); if (mutex_for_fo == NULL) { dev_err(&pdev->dev, "failed to create mutex handle\n"); goto out; } #ifdef I2C_BASE mutex_for_i2c = kmalloc(sizeof(struct mutex), GFP_KERNEL); if (mutex_for_i2c == NULL) { dev_err(&pdev->dev, "failed to create mutex handle\n"); goto out; } mutex_init(mutex_for_i2c); #endif mutex_init(mutex_for_fo); #ifdef CONFIG_CPU_S5PV210 /* added for phy cut off when boot up */ clk_enable(s5ptv_status.i2c_phy_clk); __s5p_hdmi_phy_power(false); clk_disable(s5ptv_status.i2c_phy_clk); s5p_tv_clk_gate( false ); #endif //disable power max8998_ldo3_8_control(0,LDO_TV_OUT); //ldo 3,8 off printk("%s: LDO3_8 is disabled by TV \n", __func__); return 0; #ifdef CONFIG_TV_FB err_alloc: #endif #ifdef CONFIG_CPU_S5PC100 out_hpd_irq: free_irq(IRQ_TVENC, pdev); #endif out_tvenc_irq: free_irq(IRQ_HDMI, pdev); out_hdmi_irq: free_irq(IRQ_MIXER, pdev); out: printk(KERN_ERR "not found (%d). \n", ret); return ret; }
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; }
/* * si470x_usb_driver_probe - probe for the device */ static int si470x_usb_driver_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct si470x_device *radio; int retval = -ENOMEM; /* private data allocation */ radio = kzalloc(sizeof(struct si470x_device), GFP_KERNEL); if (!radio) goto err_initial; /* video device allocation */ radio->videodev = video_device_alloc(); if (!radio->videodev) goto err_radio; /* initial configuration */ memcpy(radio->videodev, &si470x_viddev_template, sizeof(si470x_viddev_template)); radio->users = 0; radio->usbdev = interface_to_usbdev(intf); radio->intf = intf; mutex_init(&radio->lock); video_set_drvdata(radio->videodev, radio); /* show some infos about the specific device */ retval = -EIO; if (si470x_get_all_registers(radio) < 0) goto err_all; printk(KERN_INFO DRIVER_NAME ": DeviceID=0x%4.4hx ChipID=0x%4.4hx\n", radio->registers[DEVICEID], radio->registers[CHIPID]); /* check if firmware is current */ if ((radio->registers[CHIPID] & CHIPID_FIRMWARE) < RADIO_SW_VERSION_CURRENT) { printk(KERN_WARNING DRIVER_NAME ": This driver is known to work with " "firmware version %hu,\n", RADIO_SW_VERSION_CURRENT); printk(KERN_WARNING DRIVER_NAME ": but the device has firmware version %hu.\n", radio->registers[CHIPID] & CHIPID_FIRMWARE); printk(KERN_WARNING DRIVER_NAME ": If you have some trouble using this driver,\n"); printk(KERN_WARNING DRIVER_NAME ": please report to V4L ML at " "[email protected]\n"); } /* set initial frequency */ si470x_set_freq(radio, 87.5 * FREQ_MUL); /* available in all regions */ /* rds buffer allocation */ radio->buf_size = rds_buf * 3; radio->buffer = kmalloc(radio->buf_size, GFP_KERNEL); if (!radio->buffer) goto err_all; /* rds buffer configuration */ radio->wr_index = 0; radio->rd_index = 0; init_waitqueue_head(&radio->read_queue); /* prepare rds work function */ INIT_DELAYED_WORK(&radio->work, si470x_work); /* register video device */ if (video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr)) { printk(KERN_WARNING DRIVER_NAME ": Could not register video device\n"); goto err_all; } usb_set_intfdata(intf, radio); return 0; err_all: video_device_release(radio->videodev); kfree(radio->buffer); err_radio: kfree(radio); err_initial: return retval; }
static int __init vino_init(void) { unsigned long rev; dma_addr_t dma; int i, ret = 0; /* VINO is Indy specific beast */ if (ip22_is_fullhouse()) return -ENODEV; /* * VINO is in the EISA address space, so the sysid register will tell * us if the EISA_PRESENT pin on MC has been pulled low. * * If EISA_PRESENT is not set we definitely don't have a VINO equiped * system. */ if (!(sgimc->systemid & SGIMC_SYSID_EPRESENT)) { printk(KERN_ERR "VINO not found\n"); return -ENODEV; } vino = (struct sgi_vino *)ioremap(VINO_BASE, sizeof(struct sgi_vino)); if (!vino) return -EIO; /* Okay, once we know that VINO is present we'll read its revision * safe way. One never knows... */ if (get_dbe(rev, &(vino->rev_id))) { printk(KERN_ERR "VINO: failed to read revision register\n"); ret = -ENODEV; goto out_unmap; } if (VINO_ID_VALUE(rev) != VINO_CHIP_ID) { printk(KERN_ERR "VINO is not VINO (Rev/ID: 0x%04lx)\n", rev); ret = -ENODEV; goto out_unmap; } printk(KERN_INFO "VINO Rev: 0x%02lx\n", VINO_REV_NUM(rev)); Vino = (struct vino_video *) kmalloc(sizeof(struct vino_video), GFP_KERNEL); if (!Vino) { ret = -ENOMEM; goto out_unmap; } memset(Vino, 0, sizeof(struct vino_video)); Vino->dummy_desc = get_zeroed_page(GFP_KERNEL | GFP_DMA); if (!Vino->dummy_desc) { ret = -ENOMEM; goto out_free_vino; } Vino->dummy_dma.cpu = pci_alloc_consistent(NULL, 4 * sizeof(dma_addr_t), &Vino->dummy_dma.dma); if (!Vino->dummy_dma.cpu) { ret = -ENOMEM; goto out_free_dummy_desc; } dma = pci_map_single(NULL, (void *)Vino->dummy_desc, PAGE_SIZE, PCI_DMA_FROMDEVICE); for (i = 0; i < 4; i++) Vino->dummy_dma.cpu[i] = dma; vino->control = 0; /* prevent VINO from throwing spurious interrupts */ vino->a.next_4_desc = Vino->dummy_dma.dma; vino->b.next_4_desc = Vino->dummy_dma.dma; udelay(5); vino->intr_status = 0; /* set threshold level */ vino->a.fifo_thres = threshold_a; vino->b.fifo_thres = threshold_b; spin_lock_init(&Vino->vino_lock); spin_lock_init(&Vino->input_lock); init_channel_data(&Vino->chA, VINO_CHAN_A); init_channel_data(&Vino->chB, VINO_CHAN_B); if (request_irq(SGI_VINO_IRQ, vino_interrupt, 0, vinostr, NULL)) { printk(KERN_ERR "VINO: request irq%02d failed\n", SGI_VINO_IRQ); ret = -EAGAIN; goto out_unmap_dummy_desc; } ret = vino_i2c_add_bus(); if (ret) { printk(KERN_ERR "VINO: I2C bus registration failed\n"); goto out_free_irq; } if (video_register_device(&Vino->chA.vdev, VFL_TYPE_GRABBER, -1) < 0) { printk("%s, chnl %d: device registration failed.\n", Vino->chA.vdev.name, Vino->chA.chan); ret = -EINVAL; goto out_i2c_del_bus; } if (video_register_device(&Vino->chB.vdev, VFL_TYPE_GRABBER, -1) < 0) { printk("%s, chnl %d: device registration failed.\n", Vino->chB.vdev.name, Vino->chB.chan); ret = -EINVAL; goto out_unregister_vdev; } #if defined(CONFIG_KMOD) && defined (MODULE) request_module("saa7191"); request_module("indycam"); #endif return 0; out_unregister_vdev: video_unregister_device(&Vino->chA.vdev); out_i2c_del_bus: vino_i2c_del_bus(); out_free_irq: free_irq(SGI_VINO_IRQ, NULL); out_unmap_dummy_desc: pci_unmap_single(NULL, Vino->dummy_dma.dma, PAGE_SIZE, PCI_DMA_FROMDEVICE); pci_free_consistent(NULL, 4 * sizeof(dma_addr_t), (void *)Vino->dummy_dma.cpu, Vino->dummy_dma.dma); out_free_dummy_desc: free_page(Vino->dummy_desc); out_free_vino: kfree(Vino); out_unmap: iounmap(vino); return ret; }
static 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; #if defined CONFIG_SEC_CAMERA_TUNING pvdev->vdev->ioctl_ops = &msm_v4l2_ioctl_ops; #endif 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; }
static int jpeg_hx_probe(struct platform_device *pdev) { struct jpeg_dev *dev; struct video_device *vfd; struct resource *res; int ret; /* global structure */ dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) { dev_err(&pdev->dev, "%s: not enough memory\n", __func__); ret = -ENOMEM; goto err_alloc; } dev->plat_dev = pdev; /* setup jpeg control */ ret = jpeg_hx_setup_controller(dev); if (ret) { jpeg_err("failed to setup controller\n"); goto err_setup; } /* memory region */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { jpeg_err("failed to get jpeg memory region resource\n"); ret = -ENOENT; goto err_res; } res = request_mem_region(res->start, resource_size(res), pdev->name); if (!res) { jpeg_err("failed to request jpeg io memory region\n"); ret = -ENOMEM; goto err_region; } /* ioremap */ dev->reg_base = ioremap(res->start, resource_size(res)); if (!dev->reg_base) { jpeg_err("failed to remap jpeg io region\n"); ret = -ENOENT; goto err_map; } /* irq */ res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!res) { jpeg_err("failed to request jpeg irq resource\n"); ret = -ENOENT; goto err_irq; } dev->irq_no = res->start; ret = request_irq(dev->irq_no, (void *)jpeg_hx_irq, IRQF_DISABLED, pdev->name, dev); if (ret != 0) { jpeg_err("failed to jpeg request irq\n"); ret = -ENOENT; goto err_irq; } /* clock */ dev->clk = clk_get(&pdev->dev, "jpeg-hx"); if (IS_ERR(dev->clk)) { jpeg_err("failed to find jpeg clock source\n"); ret = -ENOENT; goto err_clk; } dev->sclk_clk = clk_get(&pdev->dev, "dout_aclk_300_jpeg"); if (IS_ERR(dev->sclk_clk)) { jpeg_err("failed to find jpeg clock source for dout_aclk_300_jpeg\n"); ret = -ENOENT; goto err_sclk_clk; } pm_runtime_enable(&pdev->dev); pm_runtime_get_sync(&pdev->dev); /* clock enable */ clk_enable(dev->sclk_clk); clk_enable(dev->clk); ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) { v4l2_err(&dev->v4l2_dev, "Failed to register v4l2 device\n"); goto err_v4l2; } /* encoder */ vfd = video_device_alloc(); if (!vfd) { v4l2_err(&dev->v4l2_dev, "Failed to allocate video device\n"); ret = -ENOMEM; goto err_vd_alloc_enc; } *vfd = jpeg_hx_enc_videodev; vfd->ioctl_ops = get_jpeg_hx_enc_v4l2_ioctl_ops(); ret = video_register_device(vfd, VFL_TYPE_GRABBER, 14); if (ret) { v4l2_err(&dev->v4l2_dev, "%s(): failed to register video device\n", __func__); video_device_release(vfd); goto err_vd_alloc_enc; } v4l2_info(&dev->v4l2_dev, "JPEG driver is registered to /dev/video%d\n", vfd->num); dev->vfd_enc = vfd; dev->m2m_dev_enc = v4l2_m2m_init(&jpeg_hx_m2m_enc_ops); if (IS_ERR(dev->m2m_dev_enc)) { v4l2_err(&dev->v4l2_dev, "failed to initialize v4l2-m2m device\n"); ret = PTR_ERR(dev->m2m_dev_enc); goto err_m2m_init_enc; } video_set_drvdata(vfd, dev); /* decoder */ vfd = video_device_alloc(); if (!vfd) { v4l2_err(&dev->v4l2_dev, "Failed to allocate video device\n"); ret = -ENOMEM; goto err_vd_alloc_dec; } *vfd = jpeg_hx_dec_videodev; vfd->ioctl_ops = get_jpeg_hx_dec_v4l2_ioctl_ops(); ret = video_register_device(vfd, VFL_TYPE_GRABBER, 13); if (ret) { v4l2_err(&dev->v4l2_dev, "%s(): failed to register video device\n", __func__); video_device_release(vfd); goto err_vd_alloc_dec; } v4l2_info(&dev->v4l2_dev, "JPEG driver is registered to /dev/video%d\n", vfd->num); dev->vfd_dec = vfd; dev->m2m_dev_dec = v4l2_m2m_init(&jpeg_hx_m2m_dec_ops); if (IS_ERR(dev->m2m_dev_dec)) { v4l2_err(&dev->v4l2_dev, "failed to initialize v4l2-m2m device\n"); ret = PTR_ERR(dev->m2m_dev_dec); goto err_m2m_init_dec; } video_set_drvdata(vfd, dev); platform_set_drvdata(pdev, dev); #ifdef CONFIG_VIDEOBUF2_CMA_PHYS dev->vb2 = &jpeg_hx_vb2_cma; #elif defined(CONFIG_VIDEOBUF2_ION) dev->vb2 = &jpeg_hx_vb2_ion; #endif dev->alloc_ctx = dev->vb2->init(dev); if (IS_ERR(dev->alloc_ctx)) { ret = PTR_ERR(dev->alloc_ctx); goto err_video_reg; } #ifdef CONFIG_BUSFREQ_OPP /* To lock bus frequency in OPP mode */ dev->bus_dev = dev_get("exynos-busfreq"); #endif /* clock disable */ clk_disable(dev->clk); clk_disable(dev->sclk_clk); return 0; err_video_reg: v4l2_m2m_release(dev->m2m_dev_dec); err_m2m_init_dec: video_unregister_device(dev->vfd_dec); video_device_release(dev->vfd_dec); err_vd_alloc_dec: v4l2_m2m_release(dev->m2m_dev_enc); err_m2m_init_enc: video_unregister_device(dev->vfd_enc); video_device_release(dev->vfd_enc); err_vd_alloc_enc: v4l2_device_unregister(&dev->v4l2_dev); err_v4l2: clk_disable(dev->sclk_clk); clk_put(dev->sclk_clk); clk_disable(dev->clk); err_sclk_clk: clk_put(dev->clk); err_clk: free_irq(dev->irq_no, NULL); err_irq: iounmap(dev->reg_base); err_map: err_region: kfree(res); err_res: mutex_destroy(&dev->lock); err_setup: kfree(dev); err_alloc: return ret; }
int 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; int ret = -ENOMEM; ctx = kzalloc(sizeof *ctx, GFP_KERNEL); if (!ctx) return -ENOMEM; ctx->gsc_dev = gsc; ctx->in_path = GSC_WRITEBACK; 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; vfd->vfl_dir = VFL_DIR_RX; 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; INIT_LIST_HEAD(&gsc->cap.active_buf_q); 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; q->timestamp_type = V4L2_BUF_FLAG_TIMESTAMP_COPY; ret = vb2_queue_init(q); if (ret) { gsc_err("failed to init vb2_queue"); goto err_ctx_alloc; } 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_ctx_alloc; } 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; } ret = gsc_capture_create_link(gsc); if (ret) { gsc_err("failed create link"); goto err_sd_reg; } vfd->ctrl_handler = &ctx->ctrl_handler; gsc_info("gsc capture driver registered as /dev/video%d", vfd->num); return 0; err_sd_reg: media_entity_cleanup(&vfd->entity); err_ent: video_device_release(vfd); err_ctx_alloc: kfree(ctx); return ret; }
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); 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; }
// 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 success, else 0 static int w9966_init(struct w9966_dev* cam, struct parport* port, int vidnr) { if (cam->dev_state != 0) return 0; 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_ECPSWE; break; case 1: // hw- or sw-ecp if (port->modes & PARPORT_MODE_ECP) cam->ppmode = IEEE1284_MODE_ECP; else cam->ppmode = IEEE1284_MODE_ECPSWE; break; case 2: // hw- or sw-epp if (port->modes & PARPORT_MODE_EPP) cam->ppmode = IEEE1284_MODE_EPP; else cam->ppmode = IEEE1284_MODE_EPPSWE; break; case 3: // hw-ecp cam->ppmode = IEEE1284_MODE_ECP; break; } // Tell the parport driver that we exists cam->pdev = parport_register_device( port, W9966_DRIVERNAME, NULL, NULL, NULL, 0, NULL); if (cam->pdev == NULL) { DPRINTF("parport_register_device() failed.\n"); return 0; } w9966_flag_set(cam, W9966_STATE_PDEV); // Claim parport if (!w9966_pdev_claim(cam)) { DPRINTF("w9966_pdev_claim() failed.\n"); return 0; } // Perform initial w9966 setup if (!w9966_setup(cam)) { DPRINTF("w9966_setup() failed.\n"); return 0; } // Detect model if (!w9966_saa7111_init(cam)) { DPRINTF("w9966_saa7111_init() failed.\n"); return 0; } if (!w9966_lc99053_init(cam)) { DPRINTF("w9966_lc99053_init() failed.\n"); return 0; } if (!w9966_flag_test(cam, W9966_STATE_DETECTED)) { DPRINTF("Camera model not identified.\n"); return 0; } // Setup w9966 with a default capture mode (QCIF res.) if (!w9966_window(cam, 0, 0, 1023, 1023, 176, 144)) { DPRINTF("w9966_window() failed.\n"); return 0; } w9966_pdev_release(cam); // Fill in the video_device struct and register us to v4l memset(&cam->vdev, 0, sizeof(struct video_device)); strcpy(cam->vdev.name, W9966_DRIVERNAME); cam->vdev.type = VID_TYPE_CAPTURE | VID_TYPE_SCALES; cam->vdev.hardware = VID_HARDWARE_W9966; cam->vdev.open = &w9966_v4l_open; cam->vdev.close = &w9966_v4l_close; cam->vdev.read = &w9966_v4l_read; cam->vdev.ioctl = &w9966_v4l_ioctl; cam->vdev.priv = (void*)cam; cam->vdev.owner = THIS_MODULE; if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, vidnr) == -1) { DPRINTF("video_register_device() failed (minor: %d).\n", vidnr); return 0; } w9966_flag_set(cam, W9966_STATE_VDEV); // All ok printk("w9966: Found and initialized %s on %s.\n", cam->name, cam->pport->name); return 1; }