Beispiel #1
0
static int gsc_capture_subdev_set_fmt(struct v4l2_subdev *sd,
				      struct v4l2_subdev_fh *fh,
				      struct v4l2_subdev_format *fmt)
{
	struct gsc_dev *gsc = v4l2_get_subdevdata(sd);
	struct v4l2_mbus_framefmt *mf;
	struct gsc_ctx *ctx = gsc->cap.ctx;
	struct gsc_frame *frame;

	mf = __gsc_cap_get_format(gsc, fh, fmt->pad, fmt->which);
	if (mf == NULL)
		return -EINVAL;

	gsc_cap_try_format(gsc, fh, fmt->pad, &fmt->format, fmt->which);
	*mf = fmt->format;

	if (fmt->which == V4L2_SUBDEV_FORMAT_TRY)
		return 0;

	frame = gsc_capture_get_frame(ctx, fmt->pad);

	if (fmt->which == V4L2_SUBDEV_FORMAT_ACTIVE) {
		frame->crop.left = 0;
		frame->crop.top = 0;
		frame->f_width = mf->width;
		frame->f_height = mf->height;
		frame->crop.width = mf->width;
		frame->crop.height = mf->height;
	}
	gsc_dbg("offs_h : %d, offs_v : %d, f_width : %d, f_height :%d,\
				width : %d, height : %d", frame->crop.left,\
				frame->crop.top, frame->f_width,
				frame->f_height,\
				frame->crop.width, frame->crop.height);

	return 0;
}
static int gsc_capture_link_setup(struct media_entity *entity,
				  const struct media_pad *local,
				  const struct media_pad *remote, u32 flags)
{
	struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity);
	struct gsc_dev *gsc = v4l2_get_subdevdata(sd);
	struct gsc_capture_device *cap = &gsc->cap;

	gsc_info("");
	switch (local->index | media_entity_type(remote->entity)) {
	case GSC_PAD_SINK | MEDIA_ENT_T_V4L2_SUBDEV:
		if (flags & MEDIA_LNK_FL_ENABLED) {
			if (cap->input != 0)
				return -EBUSY;
			/* Write-Back link enabled */
			if (!strcmp(remote->entity->name, FIMD_MODULE_NAME)) {
				gsc->cap.sd_disp =
					media_entity_to_v4l2_subdev(remote->entity);
				gsc->cap.sd_disp->grp_id = FIMD_GRP_ID;
				cap->ctx->in_path = GSC_WRITEBACK;
				cap->input |= GSC_IN_FIMD_WRITEBACK;
			} else if (remote->index == FLITE_PAD_SOURCE_PREV) {
				cap->input |= GSC_IN_FLITE_PREVIEW;
			} else {
				cap->input |= GSC_IN_FLITE_CAMCORDING;
			}
		} else {
			cap->input = GSC_IN_NONE;
		}
		break;
	case GSC_PAD_SOURCE | MEDIA_ENT_T_DEVNODE:
		/* gsc-cap always write to memory */
		break;
	}

	return 0;
}
Beispiel #3
0
static int resetctrl_reset(struct v4l2_subdev *sd, u32 val)
{
	struct cx18 *cx = v4l2_get_subdevdata(sd);
	const struct cx18_gpio_i2c_slave_reset *p;

	p = &cx->card->gpio_i2c_slave_reset;
	switch (val) {
	case CX18_GPIO_RESET_I2C:
		gpio_reset_seq(cx, p->active_lo_mask, p->active_hi_mask,
			       p->msecs_asserted, p->msecs_recovery);
		break;
	case CX18_GPIO_RESET_Z8F0811:
		/*
		 * Assert timing for the Z8F0811 on HVR-1600 boards:
		 * 1. Assert RESET for min of 4 clock cycles at 18.432 MHz to
		 *    initiate
		 * 2. Reset then takes 66 WDT cycles at 10 kHz + 16 xtal clock
		 *    cycles (6,601,085 nanoseconds ~= 7 milliseconds)
		 * 3. DBG pin must be high before chip exits reset for normal
		 *    operation.  DBG is open drain and hopefully pulled high
		 *    since we don't normally drive it (GPIO 1?) for the
		 *    HVR-1600
		 * 4. Z8F0811 won't exit reset until RESET is deasserted
		 * 5. Zilog comes out of reset, loads reset vector address and
		 *    executes from there. Required recovery delay unknown.
		 */
		gpio_reset_seq(cx, p->ir_reset_mask, 0,
			       p->msecs_asserted, p->msecs_recovery);
		break;
	case CX18_GPIO_RESET_XC2028:
		if (cx->card->tuners[0].tuner == TUNER_XC2028)
			gpio_reset_seq(cx, (1 << cx->card->xceive_pin), 0,
				       1, 1);
		break;
	}
	return 0;
}
Beispiel #4
0
static int aksensor_s_crop(struct v4l2_subdev *sd, struct v4l2_crop *a)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct aksensor_priv *priv = to_aksensor(client);
	int ret = -EINVAL;
	T_BOOL bRet = AK_FALSE;
	
	sensor_dbg("entry %s\n", __func__);
	
	priv->win.width = a->c.width;
	priv->win.height =a->c.height;
		
	switch (g_mode)
	{
		case CAMERA_WMODE_PREV:
			if (cur_sensor_info->handler->cam_set_to_prev_func != NULL)
				bRet = cur_sensor_info->handler->cam_set_to_prev_func(a->c.width, a->c.height);
			break;
		case CAMERA_WMODE_CAP:
			if (cur_sensor_info->handler->cam_set_to_cap_func != NULL)
				bRet = cur_sensor_info->handler->cam_set_to_cap_func(a->c.width, a->c.height);
			break;
		case CAMERA_WMODE_REC:
			if (cur_sensor_info->handler->cam_set_to_record_func != NULL)
				bRet = cur_sensor_info->handler->cam_set_to_record_func(a->c.width, a->c.height);
			break;
		default :
			if (cur_sensor_info->handler->cam_set_to_record_func != NULL)
				bRet = cur_sensor_info->handler->cam_set_to_record_func(a->c.width, a->c.height);
			break;
	}

	if ( bRet )
		ret = 0;
	
	return ret;
}
Beispiel #5
0
static int aksensor_cropcap(struct v4l2_subdev *sd, struct v4l2_cropcap *a)
{
	struct i2c_client *client = v4l2_get_subdevdata(sd);
	struct aksensor_priv *priv = to_aksensor(client);
 	int i;

	sensor_dbg("entry %s. priv=%p\n", __func__, priv);

	for (i = 0; i < cur_sensor_info->num_resolution; ++i) {
		if (!strcmp(cur_sensor_info->resolution[i].name, "720P")) 
			break;
	}
	// the resolution is 720P or larger
	if (i == cur_sensor_info->num_resolution)
		--i;
	a->bounds.width	= cur_sensor_info->resolution[i].width;
	a->bounds.height = cur_sensor_info->resolution[i].height;
	a->bounds.left			= 0;
	a->bounds.top			= 0;
		
	a->defrect.width		= priv->win.width;
	a->defrect.height		= priv->win.height;
	a->defrect.left			= 0;
	a->defrect.top			= 0;
	
	a->type					= V4L2_BUF_TYPE_VIDEO_CAPTURE;
	a->pixelaspect.numerator	= 1;
	a->pixelaspect.denominator	= 1;

	sensor_dbg("%s.\n"
				"	a->bounds.width=%d, a->bounds.height=%d\n"
				"	a->defrect.width=%d, a->defrect.height=%d\n",
				__func__, 
				a->bounds.width, a->bounds.height,
				a->defrect.width, a->defrect.height);
	return 0;
}
static int msm_csiphy_init(struct v4l2_subdev *sd)
{
	int rc = 0;
	struct csiphy_device *csiphy_dev;
	csiphy_dev = v4l2_get_subdevdata(sd);
	if (csiphy_dev == NULL) {
		rc = -ENOMEM;
		return rc;
	}

	csiphy_dev->base = ioremap(csiphy_dev->mem->start,
		resource_size(csiphy_dev->mem));
	if (!csiphy_dev->base) {
		rc = -ENOMEM;
		return rc;
	}

	rc = msm_cam_clk_enable(&csiphy_dev->pdev->dev, csiphy_clk_info,
			csiphy_dev->csiphy_clk, ARRAY_SIZE(csiphy_clk_info), 1);

	if (rc < 0) {
		iounmap(csiphy_dev->base);
		csiphy_dev->base = NULL;
		return rc;
	}

#if DBG_CSIPHY
	rc = request_irq(new_csiphy_dev->irq->start, msm_csiphy_irq,
		IRQF_TRIGGER_RISING, "csiphy", new_csiphy_dev);
	if (rc < 0) {
		pr_err("%s: irq request fail\n", __func__);
		return -EBUSY;
	}
#endif

	return 0;
}
Beispiel #7
0
static int mt9v011_read(struct v4l2_subdev *sd, unsigned char addr)
{
	struct i2c_client *c = v4l2_get_subdevdata(sd);
	__be16 buffer;
	int rc, val;

	rc = i2c_master_send(c, &addr, 1);
	if (rc != 1)
		v4l2_dbg(0, debug, sd,
			 "i2c i/o error: rc == %d (should be 1)\n", rc);

	msleep(10);

	rc = i2c_master_recv(c, (char *)&buffer, 2);
	if (rc != 2)
		v4l2_dbg(0, debug, sd,
			 "i2c i/o error: rc == %d (should be 2)\n", rc);

	val = be16_to_cpu(buffer);

	v4l2_dbg(2, debug, sd, "mt9v011: read 0x%02x = 0x%04x\n", addr, val);

	return val;
}