Example #1
0
int fimc50_hwset_input_offset(struct fimc_control *ctrl, u32 pixelformat,
			      struct v4l2_rect *bounds,
			      struct v4l2_rect *crop)
{
	u32 cfg_y = 0, cfg_cb = 0, cfg_cr = 0;

	if (crop->left || crop->top ||
		(bounds->width != crop->width) ||
		(bounds->height != crop->height)) {
		switch (pixelformat) {
		case V4L2_PIX_FMT_YUYV:		/* fall through */
		case V4L2_PIX_FMT_UYVY:		/* fall through */
		case V4L2_PIX_FMT_YVYU:		/* fall through */
		case V4L2_PIX_FMT_VYUY:		/* fall through */
		case V4L2_PIX_FMT_RGB565:
			cfg_y |= S3C_CIIYOFF_HORIZONTAL(crop->left);
			cfg_y |= S3C_CIIYOFF_VERTICAL(crop->top);
			break;
		case V4L2_PIX_FMT_RGB32:
			cfg_y |= S3C_CIIYOFF_HORIZONTAL(crop->left);
			cfg_y |= S3C_CIIYOFF_VERTICAL(crop->top);
			break;
		case V4L2_PIX_FMT_NV12: /* fall through*/
		case V4L2_PIX_FMT_NV21: /* fall through*/
		case V4L2_PIX_FMT_NV12T:
			cfg_y |= S3C_CIIYOFF_HORIZONTAL(crop->left);
			cfg_y |= S3C_CIIYOFF_VERTICAL(crop->top);
			cfg_cb |= S3C_CIICBOFF_HORIZONTAL(crop->left);
			cfg_cb |= S3C_CIICBOFF_VERTICAL(crop->top);
			break;
		case V4L2_PIX_FMT_NV16:		/* fall through */
		case V4L2_PIX_FMT_NV61:		
			cfg_y |= S3C_CIIYOFF_HORIZONTAL(crop->left);
			cfg_y |= S3C_CIIYOFF_VERTICAL(crop->top);
			cfg_cb |= S3C_CIICBOFF_HORIZONTAL(crop->left);
			cfg_cb |= S3C_CIICBOFF_VERTICAL(crop->top);
			break;
		case V4L2_PIX_FMT_YUV420:
			cfg_y |= S3C_CIIYOFF_HORIZONTAL(crop->left);
			cfg_y |= S3C_CIIYOFF_VERTICAL(crop->top);
			cfg_cb |= S3C_CIICBOFF_HORIZONTAL(crop->left);
			cfg_cb |= S3C_CIICBOFF_VERTICAL(crop->top);
			cfg_cr |= S3C_CIICROFF_HORIZONTAL(crop->left);
			cfg_cr |= S3C_CIICROFF_VERTICAL(crop->top);
			break;
		default:
			fimc_err("%s: Invalid pixelformt : %d\n",
					__func__, pixelformat);
		}
	}

	writel(cfg_y, ctrl->regs + S3C_CIIYOFF);
	writel(cfg_cb, ctrl->regs + S3C_CIICBOFF);
	writel(cfg_cr, ctrl->regs + S3C_CIICROFF);

	return 0;
}
Example #2
0
void s3c_fimc_set_input_dma(struct s3c_fimc_control *ctrl)
{
	struct s3c_fimc_in_frame *frame = &ctrl->in_frame;
	u32 cfg;

	/* for offsets */
	cfg = 0;
	cfg |= S3C_CIIYOFF_HORIZONTAL(frame->offset.y_h);
	cfg |= S3C_CIIYOFF_VERTICAL(frame->offset.y_v);
	writel(cfg, ctrl->regs + S3C_CIIYOFF);

	cfg = 0;
	cfg |= S3C_CIICBOFF_HORIZONTAL(frame->offset.cb_h);
	cfg |= S3C_CIICBOFF_VERTICAL(frame->offset.cb_v);
	writel(cfg, ctrl->regs + S3C_CIICBOFF);

	cfg = 0;
	cfg |= S3C_CIICROFF_HORIZONTAL(frame->offset.cr_h);
	cfg |= S3C_CIICROFF_VERTICAL(frame->offset.cr_v);
	writel(cfg, ctrl->regs + S3C_CIICROFF);

	/* for original & real size */
	s3c_fimc_set_input_dma_size(ctrl);

	/* for input dma control */
	cfg = (S3C_MSCTRL_SUCCESSIVE_COUNT(4) | S3C_MSCTRL_INPUT_MEMORY);

	switch (frame->format) {
	case FORMAT_RGB565: /* fall through */
	case FORMAT_RGB666: /* fall through */
	case FORMAT_RGB888:
		cfg |= S3C_MSCTRL_INFORMAT_RGB;
		break;

	case FORMAT_YCBCR420:
		cfg |= S3C_MSCTRL_INFORMAT_YCBCR420;

		if (frame->planes == 2)
			cfg |= (S3C_MSCTRL_C_INT_IN_2PLANE | \
				(frame->order_2p << S3C_MSCTRL_2PLANE_SHIFT));
		else
			cfg |= S3C_MSCTRL_C_INT_IN_3PLANE;

		break;

	case FORMAT_YCBCR422:
		if (frame->planes == 1)
			cfg |= (frame->order_1p | \
				S3C_MSCTRL_INFORMAT_YCBCR422_1PLANE);
		else {
			cfg |= S3C_MSCTRL_INFORMAT_YCBCR422;

			if (frame->planes == 2)
				cfg |= (S3C_MSCTRL_C_INT_IN_2PLANE | \
					(frame->order_2p << S3C_MSCTRL_2PLANE_SHIFT));
			else
				cfg |= S3C_MSCTRL_C_INT_IN_3PLANE;
		}

		break;
	}

	writel(cfg, ctrl->regs + S3C_MSCTRL);
}