static int32_t msm_sensor_driver_create_i2c_v4l_subdev (struct msm_sensor_ctrl_t *s_ctrl) { int32_t rc = 0; uint32_t session_id = 0; struct i2c_client *client = s_ctrl->sensor_i2c_client->client; CDBG("%s %s I2c probe succeeded\n", __func__, client->name); rc = camera_init_v4l2(&client->dev, &session_id); if (rc < 0) { pr_err("failed: camera_init_i2c_v4l2 rc %d", rc); return rc; } CDBG("%s rc %d session_id %d\n", __func__, rc, session_id); snprintf(s_ctrl->msm_sd.sd.name, sizeof(s_ctrl->msm_sd.sd.name), "%s", s_ctrl->sensordata->sensor_name); v4l2_i2c_subdev_init(&s_ctrl->msm_sd.sd, client, s_ctrl->sensor_v4l2_subdev_ops); v4l2_set_subdevdata(&s_ctrl->msm_sd.sd, client); s_ctrl->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; media_entity_init(&s_ctrl->msm_sd.sd.entity, 0, NULL, 0); s_ctrl->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV; s_ctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_SENSOR; s_ctrl->msm_sd.sd.entity.name = s_ctrl->msm_sd.sd.name; s_ctrl->sensordata->sensor_info->session_id = session_id; s_ctrl->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x3; msm_sd_register(&s_ctrl->msm_sd); CDBG("%s:%d\n", __func__, __LINE__); return rc; }
/* this function plug in the implementation of a v4l2_subdev */ int msm_mctl_init_module(struct msm_cam_v4l2_device *pcam) { struct msm_cam_media_controller *pmctl = NULL; D("%s\n", __func__); if (!pcam) { pr_err("%s: param is NULL", __func__); return -EINVAL; } else pmctl = &pcam->mctl; pmctl->sync.opencnt = 0; /* init module operations*/ pmctl->mctl_open = msm_mctl_open; pmctl->mctl_cmd = msm_mctl_cmd; pmctl->mctl_notify = msm_mctl_notify; pmctl->mctl_release = msm_mctl_release; pmctl->plat_dev = pcam->pdev; /* init mctl buf */ msm_mctl_buf_init(pcam); memset(&pmctl->pp_info, 0, sizeof(pmctl->pp_info)); spin_lock_init(&pmctl->pp_info.lock); /* init sub device*/ v4l2_subdev_init(&(pmctl->mctl_sdev), &mctl_subdev_ops); v4l2_set_subdevdata(&(pmctl->mctl_sdev), pmctl); return 0; }
static int32_t msm_sensor_driver_create_v4l_subdev (struct msm_sensor_ctrl_t *s_ctrl) { int32_t rc = 0; uint32_t session_id = 0; rc = camera_init_v4l2(&s_ctrl->pdev->dev, &session_id); if (rc < 0) { pr_err("failed: camera_init_v4l2 rc %d", rc); return rc; } CDBG("rc %d session_id %d", rc, session_id); s_ctrl->sensordata->sensor_info->session_id = session_id; /* Create /dev/v4l-subdevX device */ v4l2_subdev_init(&s_ctrl->msm_sd.sd, s_ctrl->sensor_v4l2_subdev_ops); snprintf(s_ctrl->msm_sd.sd.name, sizeof(s_ctrl->msm_sd.sd.name), "%s", s_ctrl->sensordata->sensor_name); v4l2_set_subdevdata(&s_ctrl->msm_sd.sd, s_ctrl->pdev); s_ctrl->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; media_entity_init(&s_ctrl->msm_sd.sd.entity, 0, NULL, 0); s_ctrl->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV; s_ctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_SENSOR; s_ctrl->msm_sd.sd.entity.name = s_ctrl->msm_sd.sd.name; s_ctrl->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x3; msm_sd_register(&s_ctrl->msm_sd); return rc; }
/** * init entity */ static int _init_entities(struct nxp_resc *me) { int ret; struct v4l2_subdev *sd = &me->subdev; struct media_pad *pads = me->pads; struct media_entity *entity = &sd->entity; v4l2_subdev_init(sd, &nxp_resc_subdev_ops); snprintf(sd->name, sizeof(sd->name), "NXP RESC%d", me->id); v4l2_set_subdevdata(sd, me); sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; pads[NXP_RESC_PAD_SINK].flags = MEDIA_PAD_FL_SINK; pads[NXP_RESC_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; entity->ops = &nxp_resc_media_ops; ret = media_entity_init(entity, NXP_RESC_PAD_MAX, pads, 0); if (ret < 0) { pr_err("%s: failed to media_entity_init(()\n", __func__); return ret; } return 0; }
int vpfe_resizer_init(struct vpfe_resizer_device *vpfe_rsz, struct platform_device *pdev) { struct v4l2_subdev *resizer = &vpfe_rsz->subdev; struct media_pad *pads = &vpfe_rsz->pads[0]; struct media_entity *me = &resizer->entity; struct imp_logical_channel *channel = &vpfe_rsz->channel; int ret; if (cpu_is_davinci_dm365() || cpu_is_davinci_dm355()) { vpfe_rsz->imp_hw_if = imp_get_hw_if(); if (ISNULL(vpfe_rsz->imp_hw_if)) return -1; } else return -1; vpfe_rsz->video_in.ops = &video_in_ops; vpfe_rsz->video_out.ops = &video_out1_ops; /*TODO:enable with rsz-b*/ v4l2_subdev_init(resizer, &resizer_v4l2_ops); strlcpy(resizer->name, "DAVINCI RESIZER", sizeof(resizer->name)); resizer->grp_id = 1 << 16; /* group ID for davinci subdevs */ v4l2_set_subdevdata(resizer, vpfe_rsz); resizer->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; pads[RESIZER_PAD_SINK].flags = MEDIA_PAD_FL_INPUT; pads[RESIZER_PAD_SOURCE].flags = MEDIA_PAD_FL_OUTPUT; vpfe_rsz->input = RESIZER_INPUT_NONE; vpfe_rsz->output = RESIZER_OUTPUT_NONE; channel->type = IMP_RESIZER; channel->config_state = STATE_NOT_CONFIGURED; me->ops = &resizer_media_ops; ret = media_entity_init(me, RESIZER_PADS_NUM, pads, 0); if (ret) return ret; vpfe_rsz->video_in.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; ret = vpfe_video_init(&vpfe_rsz->video_in, "RSZ"); if (ret) { printk(KERN_ERR "failed to init RSZ video-in device\n"); return ret; } vpfe_rsz->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ret = vpfe_video_init(&vpfe_rsz->video_out, "RSZ"); if (ret) { printk(KERN_ERR "failed to init RSZ video-out device\n"); return ret; } return 0; }
static int __devinit csiphy_probe(struct platform_device *pdev) { struct csiphy_device *new_csiphy_dev; int rc = 0; CDBG("%s: device id = %d\n", __func__, pdev->id); new_csiphy_dev = kzalloc(sizeof(struct csiphy_device), GFP_KERNEL); if (!new_csiphy_dev) { pr_err("%s: no enough memory\n", __func__); return -ENOMEM; } v4l2_subdev_init(&new_csiphy_dev->subdev, &msm_csiphy_subdev_ops); v4l2_set_subdevdata(&new_csiphy_dev->subdev, new_csiphy_dev); platform_set_drvdata(pdev, &new_csiphy_dev->subdev); mutex_init(&new_csiphy_dev->mutex); new_csiphy_dev->mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "csiphy"); if (!new_csiphy_dev->mem) { pr_err("%s: no mem resource?\n", __func__); rc = -ENODEV; goto csiphy_no_resource; } new_csiphy_dev->irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "csiphy"); if (!new_csiphy_dev->irq) { pr_err("%s: no irq resource?\n", __func__); rc = -ENODEV; goto csiphy_no_resource; } new_csiphy_dev->io = request_mem_region(new_csiphy_dev->mem->start, resource_size(new_csiphy_dev->mem), pdev->name); if (!new_csiphy_dev->io) { pr_err("%s: no valid mem region\n", __func__); rc = -EBUSY; goto csiphy_no_resource; } rc = request_irq(new_csiphy_dev->irq->start, msm_csiphy_irq, IRQF_TRIGGER_RISING, "csiphy", new_csiphy_dev); if (rc < 0) { release_mem_region(new_csiphy_dev->mem->start, resource_size(new_csiphy_dev->mem)); pr_err("%s: irq request fail\n", __func__); rc = -EBUSY; goto csiphy_no_resource; } disable_irq(new_csiphy_dev->irq->start); new_csiphy_dev->pdev = pdev; return 0; csiphy_no_resource: mutex_destroy(&new_csiphy_dev->mutex); kfree(new_csiphy_dev); return 0; }
int32_t msm_eeprom_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { int rc = 0; struct msm_eeprom_ctrl_t *e_ctrl = NULL; struct msm_camera_power_ctrl_t *power_info = NULL; CDBG("%s E\n", __func__); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { pr_err("%s i2c_check_functionality failed\n", __func__); goto probe_failure; } e_ctrl = kzalloc(sizeof(struct msm_eeprom_ctrl_t), GFP_KERNEL); if (!e_ctrl) { pr_err("%s:%d kzalloc failed\n", __func__, __LINE__); return -ENOMEM; } e_ctrl->eeprom_v4l2_subdev_ops = &msm_eeprom_subdev_ops; e_ctrl->eeprom_mutex = &msm_eeprom_mutex; CDBG("%s client = %x\n", __func__, (unsigned int)client); e_ctrl->eboard_info = (struct msm_eeprom_board_info *)(id->driver_data); if (!e_ctrl->eboard_info) { pr_err("%s:%d board info NULL\n", __func__, __LINE__); return -EINVAL; } power_info = &e_ctrl->eboard_info->power_info; e_ctrl->i2c_client.client = client; /* Set device type as I2C */ e_ctrl->eeprom_device_type = MSM_CAMERA_I2C_DEVICE; e_ctrl->i2c_client.i2c_func_tbl = &msm_eeprom_qup_func_tbl; if (e_ctrl->eboard_info->i2c_slaveaddr != 0) e_ctrl->i2c_client.client->addr = e_ctrl->eboard_info->i2c_slaveaddr; power_info->clk_info = cam_8960_clk_info; power_info->clk_info_size = ARRAY_SIZE(cam_8960_clk_info); power_info->dev = &client->dev; /*IMPLEMENT READING PART*/ /* Initialize sub device */ v4l2_i2c_subdev_init(&e_ctrl->msm_sd.sd, e_ctrl->i2c_client.client, e_ctrl->eeprom_v4l2_subdev_ops); v4l2_set_subdevdata(&e_ctrl->msm_sd.sd, e_ctrl); e_ctrl->msm_sd.sd.internal_ops = &msm_eeprom_internal_ops; e_ctrl->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; media_entity_init(&e_ctrl->msm_sd.sd.entity, 0, NULL, 0); e_ctrl->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV; e_ctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_EEPROM; msm_sd_register(&e_ctrl->msm_sd); CDBG("%s success result=%d X\n", __func__, rc); return rc; probe_failure: pr_err("%s failed! rc = %d\n", __func__, rc); return rc; }
static int __devinit vpe_probe(struct platform_device *pdev) { int rc = 0; CDBG("%s: device id = %d\n", __func__, pdev->id); vpe_ctrl = kzalloc(sizeof(struct vpe_ctrl_type), GFP_KERNEL); if (!vpe_ctrl) { pr_err("%s: no enough memory\n", __func__); return -ENOMEM; } v4l2_subdev_init(&vpe_ctrl->subdev, &msm_vpe_subdev_ops); v4l2_set_subdevdata(&vpe_ctrl->subdev, vpe_ctrl); snprintf(vpe_ctrl->subdev.name, sizeof(vpe_ctrl->subdev.name), "vpe"); platform_set_drvdata(pdev, &vpe_ctrl->subdev); vpe_ctrl->vpemem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "vpe"); if (!vpe_ctrl->vpemem) { pr_err("%s: no mem resource?\n", __func__); rc = -ENODEV; goto vpe_no_resource; } vpe_ctrl->vpeirq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "vpe"); if (!vpe_ctrl->vpeirq) { pr_err("%s: no irq resource?\n", __func__); rc = -ENODEV; goto vpe_no_resource; } vpe_ctrl->vpeio = request_mem_region(vpe_ctrl->vpemem->start, resource_size(vpe_ctrl->vpemem), pdev->name); if (!vpe_ctrl->vpeio) { pr_err("%s: no valid mem region\n", __func__); rc = -EBUSY; goto vpe_no_resource; } rc = request_irq(vpe_ctrl->vpeirq->start, vpe_parse_irq, IRQF_TRIGGER_RISING, "vfe", 0); if (rc < 0) { release_mem_region(vpe_ctrl->vpemem->start, resource_size(vpe_ctrl->vpemem)); pr_err("%s: irq request fail\n", __func__); rc = -EBUSY; goto vpe_no_resource; } disable_irq(vpe_ctrl->vpeirq->start); vpe_ctrl->pdev = pdev; return 0; vpe_no_resource: kfree(vpe_ctrl); return 0; }
static void fimc_lite_unregister_capture_subdev(struct fimc_lite *fimc) { struct v4l2_subdev *sd = &fimc->subdev; v4l2_device_unregister_subdev(sd); media_entity_cleanup(&sd->entity); v4l2_ctrl_handler_free(&fimc->ctrl_handler); v4l2_set_subdevdata(sd, NULL); }
void fimc_isp_subdev_destroy(struct fimc_isp *isp) { struct v4l2_subdev *sd = &isp->subdev; v4l2_device_unregister_subdev(sd); media_entity_cleanup(&sd->entity); v4l2_ctrl_handler_free(&isp->ctrls.handler); v4l2_set_subdevdata(sd, NULL); }
struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) { struct v4l2_subdev *subdev; struct vsp1_rwpf *rpf; int ret; rpf = devm_kzalloc(vsp1->dev, sizeof(*rpf), GFP_KERNEL); if (rpf == NULL) return ERR_PTR(-ENOMEM); rpf->ops = &rpf_vdev_ops; rpf->max_width = RPF_MAX_WIDTH; rpf->max_height = RPF_MAX_HEIGHT; rpf->entity.type = VSP1_ENTITY_RPF; rpf->entity.index = index; ret = vsp1_entity_init(vsp1, &rpf->entity, 2); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &rpf->entity.subdev; v4l2_subdev_init(subdev, &rpf_ops); subdev->entity.ops = &vsp1->media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s rpf.%u", dev_name(vsp1->dev), index); v4l2_set_subdevdata(subdev, rpf); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); /* Initialize the control handler. */ v4l2_ctrl_handler_init(&rpf->ctrls, 1); rpf->alpha = v4l2_ctrl_new_std(&rpf->ctrls, &rpf_ctrl_ops, V4L2_CID_ALPHA_COMPONENT, 0, 255, 1, 255); rpf->entity.subdev.ctrl_handler = &rpf->ctrls; if (rpf->ctrls.error) { dev_err(vsp1->dev, "rpf%u: failed to initialize controls\n", index); ret = rpf->ctrls.error; goto error; } return rpf; error: vsp1_entity_destroy(&rpf->entity); return ERR_PTR(ret); }
/* * csi2_init_entities - Initialize subdev and media entity. * @csi2: Pointer to csi2 structure. * return -ENOMEM or zero on success */ static int csi2_init_entities(struct iss_csi2_device *csi2, const char *subname) { struct v4l2_subdev *sd = &csi2->subdev; struct media_pad *pads = csi2->pads; struct media_entity *me = &sd->entity; int ret; char name[V4L2_SUBDEV_NAME_SIZE]; v4l2_subdev_init(sd, &csi2_ops); sd->internal_ops = &csi2_internal_ops; sprintf(name, "CSI2%s", subname); snprintf(sd->name, sizeof(sd->name), "OMAP4 ISS %s", name); sd->grp_id = 1 << 16; /* group ID for iss subdevs */ v4l2_set_subdevdata(sd, csi2); sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; pads[CSI2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; pads[CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK; me->ops = &csi2_media_ops; ret = media_entity_init(me, CSI2_PADS_NUM, pads, 0); if (ret < 0) return ret; csi2_init_formats(sd, NULL); /* Video device node */ csi2->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; csi2->video_out.ops = &csi2_issvideo_ops; csi2->video_out.bpl_alignment = 32; csi2->video_out.bpl_zero_padding = 1; csi2->video_out.bpl_max = 0x1ffe0; csi2->video_out.iss = csi2->iss; csi2->video_out.capture_mem = PAGE_ALIGN(4096 * 4096) * 3; ret = omap4iss_video_init(&csi2->video_out, name); if (ret < 0) goto error_video; /* Connect the CSI2 subdev to the video node. */ ret = media_entity_create_link(&csi2->subdev.entity, CSI2_PAD_SOURCE, &csi2->video_out.video.entity, 0, 0); if (ret < 0) goto error_link; return 0; error_link: omap4iss_video_cleanup(&csi2->video_out); error_video: media_entity_cleanup(&csi2->subdev.entity); return ret; }
static int __devinit irqrouter_probe(struct platform_device *pdev) { int rc = 0; struct irqrouter_ctrl_type *irqrouter_ctrl; struct msm_cam_subdev_info sd_info; D("%s: device id = %d\n", __func__, pdev->id); irqrouter_ctrl = kzalloc(sizeof(struct irqrouter_ctrl_type), GFP_KERNEL); if (!irqrouter_ctrl) { pr_err("%s: not enough memory\n", __func__); return -ENOMEM; } v4l2_subdev_init(&irqrouter_ctrl->subdev, &msm_irqrouter_subdev_ops); irqrouter_ctrl->subdev.internal_ops = &msm_irqrouter_internal_ops; irqrouter_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; snprintf(irqrouter_ctrl->subdev.name, sizeof(irqrouter_ctrl->subdev.name), "msm_irqrouter"); v4l2_set_subdevdata(&irqrouter_ctrl->subdev, irqrouter_ctrl); irqrouter_ctrl->pdev = pdev; if (pdev->dev.of_node) of_property_read_u32((&pdev->dev)->of_node, "cell-index", &pdev->id); msm_irqrouter_send_default_irqmap(irqrouter_ctrl); media_entity_init(&irqrouter_ctrl->subdev.entity, 0, NULL, 0); irqrouter_ctrl->subdev.entity.type = MEDIA_ENT_T_DEVNODE_V4L; irqrouter_ctrl->subdev.entity.group_id = IRQ_ROUTER_DEV; irqrouter_ctrl->subdev.entity.name = pdev->name; sd_info.sdev_type = IRQ_ROUTER_DEV; sd_info.sd_index = 0; sd_info.irq_num = 0; /* Now register this subdev with the camera server. */ rc = msm_cam_register_subdev_node(&irqrouter_ctrl->subdev, &sd_info); if (rc < 0) { pr_err("%s Error registering irqr subdev %d", __func__, rc); goto error; } irqrouter_ctrl->subdev.entity.revision = irqrouter_ctrl->subdev.devnode->num; atomic_set(&irqrouter_ctrl->active, 0); platform_set_drvdata(pdev, &irqrouter_ctrl->subdev); return rc; error: kfree(irqrouter_ctrl); return rc; }
static int __devinit i2c_mux_probe(struct platform_device *pdev) { struct i2c_mux_device *mux_device; int rc = 0; CDBG("%s: device id = %d\n", __func__, pdev->id); mux_device = kzalloc(sizeof(struct i2c_mux_device), GFP_KERNEL); if (!mux_device) { pr_err("%s: no enough memory\n", __func__); return -ENOMEM; } v4l2_subdev_init(&mux_device->subdev, &msm_i2c_mux_subdev_ops); v4l2_set_subdevdata(&mux_device->subdev, mux_device); platform_set_drvdata(pdev, &mux_device->subdev); mutex_init(&mux_device->mutex); mux_device->ctl_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "i2c_mux_ctl"); if (!mux_device->ctl_mem) { pr_err("%s: no mem resource?\n", __func__); rc = -ENODEV; goto i2c_mux_no_resource; } mux_device->ctl_io = request_mem_region(mux_device->ctl_mem->start, resource_size(mux_device->ctl_mem), pdev->name); if (!mux_device->ctl_io) { pr_err("%s: no valid mem region\n", __func__); rc = -EBUSY; goto i2c_mux_no_resource; } mux_device->rw_mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "i2c_mux_rw"); if (!mux_device->rw_mem) { pr_err("%s: no mem resource?\n", __func__); rc = -ENODEV; goto i2c_mux_no_resource; } mux_device->rw_io = request_mem_region(mux_device->rw_mem->start, resource_size(mux_device->rw_mem), pdev->name); if (!mux_device->rw_io) { pr_err("%s: no valid mem region\n", __func__); rc = -EBUSY; goto i2c_mux_no_resource; } mux_device->pdev = pdev; return 0; i2c_mux_no_resource: mutex_destroy(&mux_device->mutex); kfree(mux_device); return rc; }
static int __devinit csid_probe(struct platform_device *pdev) { struct csid_device *new_csid_dev; int rc = 0; CDBG("%s: device id = %d\n", __func__, pdev->id); new_csid_dev = kzalloc(sizeof(struct csid_device), GFP_KERNEL); if (!new_csid_dev) { pr_err("%s: no enough memory\n", __func__); return -ENOMEM; } v4l2_subdev_init(&new_csid_dev->subdev, &msm_csid_subdev_ops); new_csid_dev->subdev.internal_ops = &msm_csid_internal_ops; new_csid_dev->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; snprintf(new_csid_dev->subdev.name, ARRAY_SIZE(new_csid_dev->subdev.name), "msm_csid"); v4l2_set_subdevdata(&new_csid_dev->subdev, new_csid_dev); platform_set_drvdata(pdev, &new_csid_dev->subdev); mutex_init(&new_csid_dev->mutex); new_csid_dev->mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "csid"); if (!new_csid_dev->mem) { pr_err("%s: no mem resource?\n", __func__); rc = -ENODEV; goto csid_no_resource; } new_csid_dev->irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "csid"); if (!new_csid_dev->irq) { pr_err("%s: no irq resource?\n", __func__); rc = -ENODEV; goto csid_no_resource; } new_csid_dev->io = request_mem_region(new_csid_dev->mem->start, resource_size(new_csid_dev->mem), pdev->name); if (!new_csid_dev->io) { pr_err("%s: no valid mem region\n", __func__); rc = -EBUSY; goto csid_no_resource; } new_csid_dev->pdev = pdev; msm_cam_register_subdev_node(&new_csid_dev->subdev, CSID_DEV, pdev->id); return 0; csid_no_resource: mutex_destroy(&new_csid_dev->mutex); kfree(new_csid_dev); return 0; }
void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi, const struct v4l2_subdev_ops *ops) { v4l2_subdev_init(sd, ops); sd->flags |= V4L2_SUBDEV_FL_IS_SPI; /* the owner is the same as the spi_device's driver owner */ sd->owner = spi->dev.driver->owner; /* spi_device and v4l2_subdev point to one another */ v4l2_set_subdevdata(sd, spi); spi_set_drvdata(spi, sd); /* initialize name */ strlcpy(sd->name, spi->dev.driver->name, sizeof(sd->name)); }
void v4l2_spi_subdev_init(struct v4l2_subdev *sd, struct spi_device *spi, const struct v4l2_subdev_ops *ops) { v4l2_subdev_init(sd, ops); sd->flags |= V4L2_SUBDEV_FL_IS_SPI; sd->owner = spi->dev.driver->owner; v4l2_set_subdevdata(sd, spi); spi_set_drvdata(spi, sd); strlcpy(sd->name, spi->dev.driver->name, sizeof(sd->name)); }
int cx23888_ir_probe(struct cx23885_dev *dev) { struct cx23888_ir_state *state; struct v4l2_subdev *sd; struct v4l2_subdev_ir_parameters default_params; int ret; state = kzalloc(sizeof(struct cx23888_ir_state), GFP_KERNEL); if (state == NULL) return -ENOMEM; spin_lock_init(&state->rx_kfifo_lock); state->rx_kfifo = kfifo_alloc(CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL, &state->rx_kfifo_lock); if (IS_ERR(state->rx_kfifo)) return IS_ERR(state->rx_kfifo); state->dev = dev; state->id = V4L2_IDENT_CX23888_IR; state->rev = 0; sd = &state->sd; v4l2_subdev_init(sd, &cx23888_ir_controller_ops); v4l2_set_subdevdata(sd, state); /* FIXME - fix the formatting of dev->v4l2_dev.name and use it */ snprintf(sd->name, sizeof(sd->name), "%s/888-ir", dev->name); sd->grp_id = CX23885_HW_888_IR; ret = v4l2_device_register_subdev(&dev->v4l2_dev, sd); if (ret == 0) { /* * Ensure no interrupts arrive from '888 specific conditions, * since we ignore them in this driver to have commonality with * similar IR controller cores. */ cx23888_ir_write4(dev, CX23888_IR_IRQEN_REG, 0); mutex_init(&state->rx_params_lock); memcpy(&default_params, &default_rx_params, sizeof(struct v4l2_subdev_ir_parameters)); v4l2_subdev_call(sd, ir, rx_s_parameters, &default_params); mutex_init(&state->tx_params_lock); memcpy(&default_params, &default_tx_params, sizeof(struct v4l2_subdev_ir_parameters)); v4l2_subdev_call(sd, ir, tx_s_parameters, &default_params); } else { kfifo_free(state->rx_kfifo); } return ret; }
static int stmvl6180_cci_init(struct cci_data *data) { int rc = 0; struct msm_camera_cci_client *cci_client = data->client->cci_client; if (FALSE == data->subdev_initialized) { data->client->i2c_func_tbl = &msm_sensor_cci_func_tbl; data->client->cci_client = kzalloc(sizeof(struct msm_camera_cci_client), GFP_KERNEL); if (!data->client->cci_client) { vl6180_errmsg("%d, failed no memory\n", __LINE__); return -ENOMEM; } cci_client = data->client->cci_client; cci_client->cci_subdev = msm_cci_get_subdev(); cci_client->cci_i2c_master = data->cci_master; v4l2_subdev_init(&data->msm_sd.sd, data->subdev_ops); v4l2_set_subdevdata(&data->msm_sd.sd, data); data->msm_sd.sd.internal_ops = &msm_tof_internal_ops; data->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; snprintf(data->msm_sd.sd.name, ARRAY_SIZE(data->msm_sd.sd.name), "msm_tof"); media_entity_init(&data->msm_sd.sd.entity, 0, NULL, 0); data->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV; data->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_TOF; data->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x2; msm_sd_register(&data->msm_sd); msm_tof_v4l2_subdev_fops = v4l2_subdev_fops; /* #ifdef CONFIG_COMPAT msm_tof_v4l2_subdev_fops.compat_ioctl32 = msm_tof_subdev_fops_ioctl; #endif */ data->msm_sd.sd.devnode->fops = &msm_tof_v4l2_subdev_fops; data->subdev_initialized = TRUE; } cci_client->sid = data->slave_addr; cci_client->i2c_freq_mode = data->i2c_freq_mode; cci_client->retries = 3; cci_client->id_map = 0; cci_client->cci_i2c_master = data->cci_master; rc = data->client->i2c_func_tbl->i2c_util(data->client, MSM_CCI_INIT); if (rc < 0) { vl6180_errmsg("%d: CCI Init failed\n", __LINE__); return rc; } vl6180_dbgmsg("CCI Init Succeeded\n"); data->client->addr_type = MSM_CAMERA_I2C_WORD_ADDR; return 0; }
static int imx_ic_probe(struct platform_device *pdev) { struct imx_media_ipu_internal_sd_pdata *pdata; struct imx_ic_priv *priv; int ret; priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; platform_set_drvdata(pdev, &priv->sd); priv->dev = &pdev->dev; /* get our ipu_id, grp_id and IC task id */ pdata = priv->dev->platform_data; priv->ipu_id = pdata->ipu_id; switch (pdata->grp_id) { case IMX_MEDIA_GRP_ID_IPU_IC_PRP: priv->task_id = IC_TASK_PRP; break; case IMX_MEDIA_GRP_ID_IPU_IC_PRPENC: priv->task_id = IC_TASK_ENCODER; break; case IMX_MEDIA_GRP_ID_IPU_IC_PRPVF: priv->task_id = IC_TASK_VIEWFINDER; break; default: return -EINVAL; } v4l2_subdev_init(&priv->sd, ic_ops[priv->task_id]->subdev_ops); v4l2_set_subdevdata(&priv->sd, priv); priv->sd.internal_ops = ic_ops[priv->task_id]->internal_ops; priv->sd.entity.ops = ic_ops[priv->task_id]->entity_ops; priv->sd.entity.function = MEDIA_ENT_F_PROC_VIDEO_SCALER; priv->sd.dev = &pdev->dev; priv->sd.owner = THIS_MODULE; priv->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; priv->sd.grp_id = pdata->grp_id; strscpy(priv->sd.name, pdata->sd_name, sizeof(priv->sd.name)); ret = ic_ops[priv->task_id]->init(priv); if (ret) return ret; ret = v4l2_async_register_subdev(&priv->sd); if (ret) ic_ops[priv->task_id]->remove(priv); return ret; }
void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, const struct v4l2_subdev_ops *ops) { v4l2_subdev_init(sd, ops); sd->flags |= V4L2_SUBDEV_FL_IS_I2C; /* the owner is the same as the i2c_client's driver owner */ sd->owner = client->driver->driver.owner; /* i2c_client and v4l2_subdev point to one another */ v4l2_set_subdevdata(sd, client); i2c_set_clientdata(client, sd); /* initialize name */ snprintf(sd->name, sizeof(sd->name), "%s %d-%04x", client->driver->driver.name, i2c_adapter_id(client->adapter), client->addr); }
void v4l2_i2c_subdev_init(struct v4l2_subdev *sd, struct i2c_client *client, const struct v4l2_subdev_ops *ops) { v4l2_subdev_init(sd, ops); sd->flags |= V4L2_SUBDEV_FL_IS_I2C; sd->owner = client->driver->driver.owner; v4l2_set_subdevdata(sd, client); i2c_set_clientdata(client, sd); snprintf(sd->name, sizeof(sd->name), "%s %d-%04x", client->driver->driver.name, i2c_adapter_id(client->adapter), client->addr); }
void vfe40_axi_probe(struct axi_ctrl_t *axi_ctrl) { struct msm_cam_subdev_info sd_info; v4l2_subdev_init(&axi_ctrl->subdev, &msm_axi_subdev_ops); axi_ctrl->subdev.internal_ops = &msm_axi_internal_ops; axi_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; snprintf(axi_ctrl->subdev.name, sizeof(axi_ctrl->subdev.name), "axi"); v4l2_set_subdevdata(&axi_ctrl->subdev, axi_ctrl); sd_info.sdev_type = AXI_DEV; sd_info.sd_index = axi_ctrl->pdev->id; sd_info.irq_num = 0; msm_cam_register_subdev_node(&axi_ctrl->subdev, &sd_info); }
/* * ispcsi2_init_entities - Initialize subdev and media entity. * @csi2: Pointer to ispcsi2 structure. * return -ENOMEM or zero on success */ static int isp_csi2_init_entities(struct isp_csi2_device *csi2) { struct v4l2_subdev *sd = &csi2->subdev; struct media_pad *pads = csi2->pads; struct media_entity *me = &sd->entity; int ret; v4l2_subdev_init(sd, &csi2_ops); strlcpy(sd->name, "OMAP3 ISP CSI2a", sizeof(sd->name)); sd->grp_id = 1 << 16; /* group ID for isp subdevs */ v4l2_set_subdevdata(sd, csi2); sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; v4l2_ctrl_handler_init(&csi2->ctrls, 1); sd->ctrl_handler = &csi2->ctrls; pads[CSI2_PAD_SOURCE].flags = MEDIA_PAD_FLAG_OUTPUT; pads[CSI2_PAD_SINK].flags = MEDIA_PAD_FLAG_INPUT; me->ops = &csi2_media_ops; ret = media_entity_init(me, CSI2_PADS_NUM, pads, 0); if (ret < 0) return ret; csi2_init_formats(sd, NULL); /* Video device node */ csi2->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; csi2->video_out.ops = &csi2_ispvideo_ops; csi2->video_out.bpl_alignment = 32; csi2->video_out.bpl_zero_padding = 1; csi2->video_out.bpl_max = 0x1ffe0; csi2->video_out.isp = csi2->isp; csi2->video_out.capture_mem = PAGE_ALIGN(4096 * 4096) * 3; ret = isp_video_init(&csi2->video_out, "CSI2a"); if (ret < 0) return ret; /* Connect the CSI2 subdev to the video node. */ ret = media_entity_create_link(&csi2->subdev.entity, CSI2_PAD_SOURCE, &csi2->video_out.video.entity, 0, 0); if (ret < 0) return ret; return 0; }
/* * ipipeif_init_entities - Initialize V4L2 subdev and media entity * @ipipeif: ISS ISP IPIPEIF module * * Return 0 on success and a negative error code on failure. */ static int ipipeif_init_entities(struct iss_ipipeif_device *ipipeif) { struct v4l2_subdev *sd = &ipipeif->subdev; struct media_pad *pads = ipipeif->pads; struct media_entity *me = &sd->entity; int ret; ipipeif->input = IPIPEIF_INPUT_NONE; v4l2_subdev_init(sd, &ipipeif_v4l2_ops); sd->internal_ops = &ipipeif_v4l2_internal_ops; strlcpy(sd->name, "OMAP4 ISS ISP IPIPEIF", sizeof(sd->name)); sd->grp_id = 1 << 16; /* group ID for iss subdevs */ v4l2_set_subdevdata(sd, ipipeif); sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; pads[IPIPEIF_PAD_SINK].flags = MEDIA_PAD_FL_SINK; pads[IPIPEIF_PAD_SOURCE_ISIF_SF].flags = MEDIA_PAD_FL_SOURCE; pads[IPIPEIF_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE; me->ops = &ipipeif_media_ops; ret = media_entity_init(me, IPIPEIF_PADS_NUM, pads, 0); if (ret < 0) return ret; ipipeif_init_formats(sd, NULL); ipipeif->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ipipeif->video_out.ops = &ipipeif_video_ops; ipipeif->video_out.iss = to_iss_device(ipipeif); ipipeif->video_out.capture_mem = PAGE_ALIGN(4096 * 4096) * 3; ipipeif->video_out.bpl_alignment = 32; ipipeif->video_out.bpl_zero_padding = 1; ipipeif->video_out.bpl_max = 0x1ffe0; ret = omap4iss_video_init(&ipipeif->video_out, "ISP IPIPEIF"); if (ret < 0) return ret; /* Connect the IPIPEIF subdev to the video node. */ ret = media_entity_create_link(&ipipeif->subdev.entity, IPIPEIF_PAD_SOURCE_ISIF_SF, &ipipeif->video_out.video.entity, 0, 0); if (ret < 0) return ret; return 0; }
static int __devinit cpp_probe(struct platform_device *pdev) { struct cpp_device *cpp_dev; struct msm_cam_subdev_info sd_info; int rc = 0; CDBG("%s: device id = %d\n", __func__, pdev->id); cpp_dev = kzalloc(sizeof(struct cpp_device), GFP_KERNEL); if (!cpp_dev) { pr_err("%s: no enough memory\n", __func__); return -ENOMEM; } v4l2_subdev_init(&cpp_dev->subdev, &msm_cpp_subdev_ops); cpp_dev->subdev.internal_ops = &msm_cpp_internal_ops; snprintf(cpp_dev->subdev.name, ARRAY_SIZE(cpp_dev->subdev.name), "cpp"); cpp_dev->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; cpp_dev->subdev.flags |= V4L2_SUBDEV_FL_HAS_EVENTS; v4l2_set_subdevdata(&cpp_dev->subdev, cpp_dev); platform_set_drvdata(pdev, &cpp_dev->subdev); mutex_init(&cpp_dev->mutex); cpp_dev->pdev = pdev; media_entity_init(&cpp_dev->subdev.entity, 0, NULL, 0); cpp_dev->subdev.entity.type = MEDIA_ENT_T_DEVNODE_V4L; cpp_dev->subdev.entity.group_id = CPP_DEV; cpp_dev->subdev.entity.name = pdev->name; sd_info.sdev_type = CPP_DEV; sd_info.sd_index = pdev->id; msm_cam_register_subdev_node(&cpp_dev->subdev, &sd_info); msm_cpp_v4l2_subdev_fops.owner = v4l2_subdev_fops.owner; msm_cpp_v4l2_subdev_fops.open = v4l2_subdev_fops.open; msm_cpp_v4l2_subdev_fops.unlocked_ioctl = msm_cpp_subdev_fops_ioctl; msm_cpp_v4l2_subdev_fops.release = v4l2_subdev_fops.release; msm_cpp_v4l2_subdev_fops.poll = v4l2_subdev_fops.poll; cpp_dev->subdev.devnode->fops = &msm_cpp_v4l2_subdev_fops; cpp_dev->subdev.entity.revision = cpp_dev->subdev.devnode->num; msm_cpp_enable_debugfs(cpp_dev); msm_queue_init(&cpp_dev->eventData_q, "eventdata"); msm_queue_init(&cpp_dev->offline_q, "frame"); msm_queue_init(&cpp_dev->realtime_q, "frame"); msm_queue_init(&cpp_dev->processing_q, "frame"); cpp_dev->cpp_open_cnt = 0; return rc; }
static int isp_stat_init_entities(struct ispstat *stat, const char *name, const struct v4l2_subdev_ops *sd_ops) { struct v4l2_subdev *subdev = &stat->subdev; struct media_entity *me = &subdev->entity; v4l2_subdev_init(subdev, sd_ops); snprintf(subdev->name, V4L2_SUBDEV_NAME_SIZE, "OMAP3 ISP %s", name); subdev->grp_id = 1 << 16; /* group ID for isp subdevs */ subdev->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE; v4l2_set_subdevdata(subdev, stat); stat->pad.flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT; me->ops = NULL; return media_entity_init(me, 1, &stat->pad, 0); }
struct vsp1_bru *vsp1_bru_create(struct vsp1_device *vsp1) { struct v4l2_subdev *subdev; struct vsp1_bru *bru; int ret; bru = devm_kzalloc(vsp1->dev, sizeof(*bru), GFP_KERNEL); if (bru == NULL) return ERR_PTR(-ENOMEM); bru->entity.type = VSP1_ENTITY_BRU; ret = vsp1_entity_init(vsp1, &bru->entity, vsp1->info->num_bru_inputs + 1); if (ret < 0) return ERR_PTR(ret); /* Initialize the V4L2 subdev. */ subdev = &bru->entity.subdev; v4l2_subdev_init(subdev, &bru_ops); subdev->entity.ops = &vsp1->media_ops; subdev->internal_ops = &vsp1_subdev_internal_ops; snprintf(subdev->name, sizeof(subdev->name), "%s bru", dev_name(vsp1->dev)); v4l2_set_subdevdata(subdev, bru); subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; vsp1_entity_init_formats(subdev, NULL); /* Initialize the control handler. */ v4l2_ctrl_handler_init(&bru->ctrls, 1); v4l2_ctrl_new_std(&bru->ctrls, &bru_ctrl_ops, V4L2_CID_BG_COLOR, 0, 0xffffff, 1, 0); bru->entity.subdev.ctrl_handler = &bru->ctrls; if (bru->ctrls.error) { dev_err(vsp1->dev, "bru: failed to initialize controls\n"); ret = bru->ctrls.error; vsp1_entity_destroy(&bru->entity); return ERR_PTR(ret); } return bru; }
static int soc_camera_platform_probe(struct platform_device *pdev) { struct soc_camera_host *ici; struct soc_camera_platform_priv *priv; struct soc_camera_platform_info *p = pdev->dev.platform_data; struct soc_camera_device *icd; int ret; if (!p) return -EINVAL; if (!p->icd) { dev_err(&pdev->dev, "Platform has not set soc_camera_device pointer!\n"); return -EINVAL; } priv = kzalloc(sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; icd = p->icd; /* soc-camera convention: control's drvdata points to the subdev */ platform_set_drvdata(pdev, &priv->subdev); /* Set the control device reference */ icd->control = &pdev->dev; ici = to_soc_camera_host(icd->parent); v4l2_subdev_init(&priv->subdev, &platform_subdev_ops); v4l2_set_subdevdata(&priv->subdev, p); strncpy(priv->subdev.name, dev_name(&pdev->dev), V4L2_SUBDEV_NAME_SIZE); ret = v4l2_device_register_subdev(&ici->v4l2_dev, &priv->subdev); if (ret) goto evdrs; return ret; evdrs: platform_set_drvdata(pdev, NULL); kfree(priv); return ret; }
/* * csi2_init_entities - Initialize subdev and media entity. * @csi2: Pointer to csi2 structure. * return -ENOMEM or zero on success */ static int csi2_init_entities(struct isp_csi2_device *csi2) { struct v4l2_subdev *sd = &csi2->subdev; struct media_pad *pads = csi2->pads; struct media_entity *me = &sd->entity; int ret; v4l2_subdev_init(sd, &csi2_ops); sd->internal_ops = &csi2_internal_ops; strlcpy(sd->name, "OMAP3 ISP CSI2a", sizeof(sd->name)); sd->grp_id = 1 << 16; /* group ID for isp subdevs */ v4l2_set_subdevdata(sd, csi2); sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; pads[CSI2_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; pads[CSI2_PAD_SINK].flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT; me->ops = &csi2_media_ops; ret = media_entity_pads_init(me, CSI2_PADS_NUM, pads); if (ret < 0) return ret; csi2_init_formats(sd, NULL); /* Video device node */ csi2->video_out.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; csi2->video_out.ops = &csi2_ispvideo_ops; csi2->video_out.bpl_alignment = 32; csi2->video_out.bpl_zero_padding = 1; csi2->video_out.bpl_max = 0x1ffe0; csi2->video_out.isp = csi2->isp; csi2->video_out.capture_mem = PAGE_ALIGN(4096 * 4096) * 3; ret = omap3isp_video_init(&csi2->video_out, "CSI2a"); if (ret < 0) goto error_video; return 0; error_video: media_entity_cleanup(&csi2->subdev.entity); return ret; }