static int __init msm_sensor_init_module(void)
{
	/* Allocate memory for msm_sensor_init control structure */
	s_init = kzalloc(sizeof(struct msm_sensor_init_t), GFP_KERNEL);
	if (!s_init) {
		pr_err("failed: no memory s_init %p", NULL);
		return -ENOMEM;
	}

	CDBG("MSM_SENSOR_INIT_MODULE %p", NULL);

	/* Initialize mutex */
	mutex_init(&s_init->imutex);

	/* Create /dev/v4l-subdevX for msm_sensor_init */
	v4l2_subdev_init(&s_init->msm_sd.sd, &msm_sensor_init_subdev_ops);
	snprintf(s_init->msm_sd.sd.name, sizeof(s_init->msm_sd.sd.name), "%s",
		"msm_sensor_init");
	v4l2_set_subdevdata(&s_init->msm_sd.sd, s_init);
	s_init->msm_sd.sd.internal_ops = &msm_sensor_init_internal_ops;
	s_init->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
	media_entity_init(&s_init->msm_sd.sd.entity, 0, NULL, 0);
	s_init->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
	s_init->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_SENSOR_INIT;
	s_init->msm_sd.sd.entity.name = s_init->msm_sd.sd.name;
	s_init->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x6;
	msm_sd_register(&s_init->msm_sd);

	init_waitqueue_head(&s_init->state_wait);

	return 0;
}
int atomisp_tpg_init(struct atomisp_device *isp)
{
	struct atomisp_tpg_device *tpg = &isp->tpg;
	struct v4l2_subdev *sd = &tpg->sd;
	struct media_pad *pads = tpg->pads;
	struct media_entity *me = &sd->entity;
	int ret;

	tpg->isp = isp;
	v4l2_subdev_init(sd, &tpg_ops);
	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
	strcpy(sd->name, "tpg_subdev");
	v4l2_set_subdevdata(sd, tpg);

	pads[0].flags = MEDIA_PAD_FL_SINK;
	me->function = MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN;

	ret = media_entity_pads_init(me, 1, pads);
	if (ret < 0)
		goto fail;
	return 0;
fail:
	atomisp_tpg_cleanup(isp);
	return ret;
}
Example #3
0
static int fimc_lite_create_capture_subdev(struct fimc_lite *fimc)
{
	struct v4l2_ctrl_handler *handler = &fimc->ctrl_handler;
	struct v4l2_subdev *sd = &fimc->subdev;
	int ret;

	v4l2_subdev_init(sd, &fimc_lite_subdev_ops);
	sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE;
	snprintf(sd->name, sizeof(sd->name), "FIMC-LITE.%d", fimc->index);

	fimc->subdev_pads[FIMC_SD_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
	fimc->subdev_pads[FIMC_SD_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
	ret = media_entity_init(&sd->entity, FIMC_SD_PADS_NUM,
				fimc->subdev_pads, 0);
	if (ret)
		return ret;

	v4l2_ctrl_handler_init(handler, 1);
	fimc->test_pattern = v4l2_ctrl_new_custom(handler, &fimc_lite_ctrl,
						  NULL);
	if (handler->error) {
		media_entity_cleanup(&sd->entity);
		return handler->error;
	}

	sd->ctrl_handler = handler;
	sd->internal_ops = &fimc_lite_subdev_internal_ops;
	sd->entity.ops = &fimc_lite_subdev_media_ops;
	v4l2_set_subdevdata(sd, fimc);

	return 0;
}
Example #4
0
/**
 * 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;
}
Example #5
0
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);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
	state->rx_kfifo = kfifo_alloc(CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL,
				      &state->rx_kfifo_lock);
	if (state->rx_kfifo == NULL)
		return -ENOMEM;
#else
	if (kfifo_alloc(&state->rx_kfifo, CX23888_IR_RX_KFIFO_SIZE, GFP_KERNEL))
		return -ENOMEM;
#endif

	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 {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
		kfifo_free(state->rx_kfifo);
#else
		kfifo_free(&state->rx_kfifo);
#endif
	}
	return ret;
}
Example #6
0
int ivtv_gpio_init(struct ivtv *itv)
{
	u16 pin = 0;

	if (itv->card->xceive_pin)
		pin = 1 << itv->card->xceive_pin;

	if ((itv->card->gpio_init.direction | pin) == 0)
		return 0;

	IVTV_DEBUG_INFO("GPIO initial dir: %08x out: %08x\n",
		   read_reg(IVTV_REG_GPIO_DIR), read_reg(IVTV_REG_GPIO_OUT));

	/* init output data then direction */
	write_reg(itv->card->gpio_init.initial_value | pin, IVTV_REG_GPIO_OUT);
	write_reg(itv->card->gpio_init.direction | pin, IVTV_REG_GPIO_DIR);
	v4l2_subdev_init(&itv->sd_gpio, &subdev_ops);
	snprintf(itv->sd_gpio.name, sizeof(itv->sd_gpio.name), "%s-gpio", itv->v4l2_dev.name);
	itv->sd_gpio.grp_id = IVTV_HW_GPIO;
	v4l2_ctrl_handler_init(&itv->hdl_gpio, 1);
	v4l2_ctrl_new_std(&itv->hdl_gpio, &gpio_ctrl_ops,
			V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
	if (itv->hdl_gpio.error)
		return itv->hdl_gpio.error;
	itv->sd_gpio.ctrl_handler = &itv->hdl_gpio;
	v4l2_ctrl_handler_setup(&itv->hdl_gpio);
	return v4l2_device_register_subdev(&itv->v4l2_dev, &itv->sd_gpio);
}
/* 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 int msm_gesture_node_register(void)
{
	struct msm_gesture_ctrl *p_gesture_ctrl = &g_gesture_ctrl;
	struct v4l2_subdev *gesture_subdev =
		kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
	D("%s\n", __func__);
	if (!gesture_subdev) {
		pr_err("%s: no enough memory\n", __func__);
		return -ENOMEM;
	};

	v4l2_subdev_init(gesture_subdev, &msm_gesture_subdev_ops);
	gesture_subdev->internal_ops = &msm_gesture_internal_ops;
	gesture_subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
	snprintf(gesture_subdev->name,
			 sizeof(gesture_subdev->name), "gesture");

	media_entity_init(&gesture_subdev->entity, 0, NULL, 0);
	gesture_subdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L;
	gesture_subdev->entity.group_id = GESTURE_DEV;
	gesture_subdev->entity.name = gesture_subdev->name;

	/* events */
	gesture_subdev->flags |= V4L2_SUBDEV_FL_HAS_EVENTS;

	msm_cam_register_subdev_node(gesture_subdev, GESTURE_DEV, 0);

	gesture_subdev->entity.revision = gesture_subdev->devnode->num;

	atomic_set(&p_gesture_ctrl->active, 0);
	p_gesture_ctrl->queue_id = -1;
	p_gesture_ctrl->event.evt_data = NULL;
	p_gesture_ctrl->event.evt_len = 0;
	return 0;
}
static int32_t msm_led_cci_create_v4lsubdev(struct platform_device *pdev, void *data)
{
	struct msm_led_cci_ctrl_t *fctrl =
		(struct msm_led_cci_ctrl_t *)data;
	CDBG("Enter\n");

	if (!fctrl) {
		pr_err("fctrl NULL\n");
		return -EINVAL;
	}

	/* Initialize sub device */
	v4l2_subdev_init(&fctrl->msm_sd.sd, &msm_led_cci_subdev_ops);
	v4l2_set_subdevdata(&fctrl->msm_sd.sd, fctrl);

	fctrl->pdev = pdev;
	fctrl->msm_sd.sd.internal_ops = &msm_led_cci_internal_ops;
	fctrl->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
	snprintf(fctrl->msm_sd.sd.name, ARRAY_SIZE(fctrl->msm_sd.sd.name),
		"msm_flash");
	media_entity_init(&fctrl->msm_sd.sd.entity, 0, NULL, 0);
	fctrl->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
	fctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_LED_FLASH;
	fctrl->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x1;
	msm_sd_register(&fctrl->msm_sd);

	CDBG("probe success\n");
	return 0;
}
Example #10
0
struct vsp1_lut *vsp1_lut_create(struct vsp1_device *vsp1)
{
    struct v4l2_subdev *subdev;
    struct vsp1_lut *lut;
    int ret;

    lut = devm_kzalloc(vsp1->dev, sizeof(*lut), GFP_KERNEL);
    if (lut == NULL)
        return ERR_PTR(-ENOMEM);

    lut->entity.type = VSP1_ENTITY_LUT;

    ret = vsp1_entity_init(vsp1, &lut->entity, 2);
    if (ret < 0)
        return ERR_PTR(ret);

    /* Initialize the V4L2 subdev. */
    subdev = &lut->entity.subdev;
    v4l2_subdev_init(subdev, &lut_ops);

    subdev->entity.ops = &vsp1_media_ops;
    subdev->internal_ops = &vsp1_subdev_internal_ops;
    snprintf(subdev->name, sizeof(subdev->name), "%s lut",
             dev_name(vsp1->dev));
    v4l2_set_subdevdata(subdev, lut);
    subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;

    vsp1_entity_init_formats(subdev, NULL);

    return lut;
}
int32_t msm_led_i2c_flash_create_v4lsubdev(void *data)
{
	struct msm_led_flash_ctrl_t *fctrl =
		(struct msm_led_flash_ctrl_t *)data;
	CDBG("Enter\n");

	if (!fctrl) {
		pr_err("fctrl NULL\n");
		return -EINVAL;
	}

	/* Initialize sub device */
	v4l2_subdev_init(&fctrl->msm_sd.sd, &msm_flash_subdev_ops);
	v4l2_set_subdevdata(&fctrl->msm_sd.sd, fctrl);

	fctrl->msm_sd.sd.internal_ops = &msm_flash_internal_ops;
	fctrl->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
	snprintf(fctrl->msm_sd.sd.name, ARRAY_SIZE(fctrl->msm_sd.sd.name),
		"msm_flash");
	media_entity_init(&fctrl->msm_sd.sd.entity, 0, NULL, 0);
	fctrl->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV;
	fctrl->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_LED_FLASH;
	msm_sd_register(&fctrl->msm_sd);

	msm_led_flash_v4l2_subdev_fops = v4l2_subdev_fops;
	fctrl->msm_sd.sd.devnode->fops = &msm_led_flash_v4l2_subdev_fops;

	CDBG("probe success\n");
	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;
}
Example #13
0
/*
* ispcsi2_init_entities - Initialize subdev and media entity.
* @csi2: Pointer to ispcsi2 structure.
* return -ENOMEM or zero on success
*/
static int mipi_csi2_init_entities(struct atomisp_mipi_csi2_device *csi2,
					int port)
{
	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);
	snprintf(sd->name, sizeof(sd->name), "ATOM ISP CSI2-port%d", port);

	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;
	me->type = MEDIA_ENT_T_V4L2_SUBDEV;
	ret = media_entity_init(me, CSI2_PADS_NUM, pads, 0);
	if (ret < 0)
		return ret;

	csi2->formats[CSI2_PAD_SINK].code = V4L2_MBUS_FMT_SBGGR10_1X10;
	csi2->formats[CSI2_PAD_SOURCE].code = V4L2_MBUS_FMT_SBGGR10_1X10;

	return 0;
}
Example #14
0
/*
 * ipipe_init_entities - Initialize V4L2 subdev and media entity
 * @ipipe: ISS ISP IPIPE module
 *
 * Return 0 on success and a negative error code on failure.
 */
static int ipipe_init_entities(struct iss_ipipe_device *ipipe)
{
	struct v4l2_subdev *sd = &ipipe->subdev;
	struct media_pad *pads = ipipe->pads;
	struct media_entity *me = &sd->entity;
	int ret;

	ipipe->input = IPIPE_INPUT_NONE;

	v4l2_subdev_init(sd, &ipipe_v4l2_ops);
	sd->internal_ops = &ipipe_v4l2_internal_ops;
	strlcpy(sd->name, "OMAP4 ISS ISP IPIPE", sizeof(sd->name));
	sd->grp_id = 1 << 16;	/* group ID for iss subdevs */
	v4l2_set_subdevdata(sd, ipipe);
	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;

	pads[IPIPE_PAD_SINK].flags = MEDIA_PAD_FL_SINK;
	pads[IPIPE_PAD_SOURCE_VP].flags = MEDIA_PAD_FL_SOURCE;

	me->ops = &ipipe_media_ops;
	ret = media_entity_pads_init(me, IPIPE_PADS_NUM, pads);
	if (ret < 0)
		return ret;

	ipipe_init_formats(sd, NULL);

	return 0;
}
Example #15
0
struct vsp1_uds *vsp1_uds_create(struct vsp1_device *vsp1, unsigned int index)
{
	struct v4l2_subdev *subdev;
	struct vsp1_uds *uds;
	int ret;

	uds = devm_kzalloc(vsp1->dev, sizeof(*uds), GFP_KERNEL);
	if (uds == NULL)
		return ERR_PTR(-ENOMEM);

	uds->entity.type = VSP1_ENTITY_UDS;
	uds->entity.index = index;

	ret = vsp1_entity_init(vsp1, &uds->entity, 2);
	if (ret < 0)
		return ERR_PTR(ret);

	/* Initialize the V4L2 subdev. */
	subdev = &uds->entity.subdev;
	v4l2_subdev_init(subdev, &uds_ops);

	subdev->entity.ops = &vsp1_media_ops;
	subdev->internal_ops = &vsp1_subdev_internal_ops;
	snprintf(subdev->name, sizeof(subdev->name), "%s uds.%u",
		 dev_name(vsp1->dev), index);
	v4l2_set_subdevdata(subdev, uds);
	subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;

	vsp1_entity_init_formats(subdev, NULL);

	return uds;
}
Example #16
0
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, "msm_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, "msm_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;
//HTC_START chris, 20120310 fix unknown reset which is caused by vpe clk disabled when vpe state is active.
    init_waitqueue_head(&vpe_ctrl->vpe_event_queue);
//HTC_END
    return 0;

vpe_no_resource:
    kfree(vpe_ctrl);
    return 0;
}
Example #17
0
int cx18_gpio_register(struct cx18 *cx, u32 hw)
{
	struct v4l2_subdev *sd;
	const struct v4l2_subdev_ops *ops;
	char *str;

	switch (hw) {
	case CX18_HW_GPIO_MUX:
		sd = &cx->sd_gpiomux;
		ops = &gpiomux_ops;
		str = "gpio-mux";
		break;
	case CX18_HW_GPIO_RESET_CTRL:
		sd = &cx->sd_resetctrl;
		ops = &resetctrl_ops;
		str = "gpio-reset-ctrl";
		break;
	default:
		return -EINVAL;
	}

	v4l2_subdev_init(sd, ops);
	v4l2_set_subdevdata(sd, cx);
	snprintf(sd->name, sizeof(sd->name), "%s %s", cx->v4l2_dev.name, str);
	sd->grp_id = hw;
	return v4l2_device_register_subdev(&cx->v4l2_dev, sd);
}
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);
	vpe_ctrl->subdev.internal_ops = &msm_vpe_internal_ops;
	vpe_ctrl->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
	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, "vpe", 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;
	msm_cam_register_subdev_node(&vpe_ctrl->subdev, VPE_DEV, pdev->id);
	return 0;

vpe_no_resource:
	kfree(vpe_ctrl);
	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;
}
Example #21
0
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);
}
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;
}
Example #23
0
/*
 * 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;
}
Example #24
0
static int __devinit __wfd_probe(struct platform_device *pdev)
{
	int rc = 0;
	struct wfd_device *wfd_dev;
	WFD_MSG_DBG("__wfd_probe: E\n");
	wfd_dev = kzalloc(sizeof(*wfd_dev), GFP_KERNEL);  /*TODO: Free it*/
	if (!wfd_dev) {
		WFD_MSG_ERR("Could not allocate memory for "
				"wfd device\n");
		return -ENOMEM;
	}
	pdev->dev.platform_data = (void *) wfd_dev;
	rc = v4l2_device_register(&pdev->dev, &wfd_dev->v4l2_dev);
	if (rc) {
		WFD_MSG_ERR("Failed to register the video device\n");
		goto err_v4l2_registration;
	}
	wfd_dev->pvdev = video_device_alloc();
	if (!wfd_dev->pvdev) {
		WFD_MSG_ERR("Failed to allocate video device\n");
		goto err_video_device_alloc;
	}

	wfd_dev->pvdev->release = release_video_device;
	wfd_dev->pvdev->fops = &g_wfd_fops;
	wfd_dev->pvdev->ioctl_ops = &g_wfd_ioctl_ops;

	rc = video_register_device(wfd_dev->pvdev, VFL_TYPE_GRABBER, -1);
	if (rc) {
		WFD_MSG_ERR("Failed to register the device\n");
		goto err_video_register_device;
	}
	video_set_drvdata(wfd_dev->pvdev, wfd_dev);

	v4l2_subdev_init(&wfd_dev->mdp_sdev, &mdp_subdev_ops);
	strncpy(wfd_dev->mdp_sdev.name, "wfd-mdp", V4L2_SUBDEV_NAME_SIZE);
	rc = v4l2_device_register_subdev(&wfd_dev->v4l2_dev,
						&wfd_dev->mdp_sdev);
	if (rc) {
		WFD_MSG_ERR("Failed to register mdp subdevice: %d\n", rc);
		goto err_mdp_register_subdev;
	}
	WFD_MSG_DBG("__wfd_probe: X\n");
	return rc;
err_mdp_register_subdev:
	video_unregister_device(wfd_dev->pvdev);
err_video_register_device:
	video_device_release(wfd_dev->pvdev);
err_video_device_alloc:
	v4l2_device_unregister(&wfd_dev->v4l2_dev);
err_v4l2_registration:
	kfree(wfd_dev);
	return rc;
}
Example #25
0
static struct v4l2_flash *__v4l2_flash_init(
	struct device *dev, struct fwnode_handle *fwn,
	struct led_classdev_flash *fled_cdev, struct led_classdev *iled_cdev,
	const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config)
{
	struct v4l2_flash *v4l2_flash;
	struct v4l2_subdev *sd;
	int ret;

	if (!config)
		return ERR_PTR(-EINVAL);

	v4l2_flash = devm_kzalloc(dev, sizeof(*v4l2_flash), GFP_KERNEL);
	if (!v4l2_flash)
		return ERR_PTR(-ENOMEM);

	sd = &v4l2_flash->sd;
	v4l2_flash->fled_cdev = fled_cdev;
	v4l2_flash->iled_cdev = iled_cdev;
	v4l2_flash->ops = ops;
	sd->dev = dev;
	sd->fwnode = fwn ? fwn : dev_fwnode(dev);
	v4l2_subdev_init(sd, &v4l2_flash_subdev_ops);
	sd->internal_ops = &v4l2_flash_subdev_internal_ops;
	sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
	strlcpy(sd->name, config->dev_name, sizeof(sd->name));

	ret = media_entity_pads_init(&sd->entity, 0, NULL);
	if (ret < 0)
		return ERR_PTR(ret);

	sd->entity.function = MEDIA_ENT_F_FLASH;

	ret = v4l2_flash_init_controls(v4l2_flash, config);
	if (ret < 0)
		goto err_init_controls;

	fwnode_handle_get(sd->fwnode);

	ret = v4l2_async_register_subdev(sd);
	if (ret < 0)
		goto err_async_register_sd;

	return v4l2_flash;

err_async_register_sd:
	fwnode_handle_put(sd->fwnode);
	v4l2_ctrl_handler_free(sd->ctrl_handler);
err_init_controls:
	media_entity_cleanup(&sd->entity);

	return ERR_PTR(ret);
}
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;
}
Example #27
0
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;
	
	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));
}
Example #29
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));
}
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;
}