Esempio n. 1
0
static int rotator_dst_set_size(struct device *dev, int swap,
						struct drm_exynos_pos *pos,
						struct drm_exynos_sz *sz)
{
	struct rot_context *rot = dev_get_drvdata(dev);
	struct drm_exynos_ipp_property *property = &rot->property;
	struct drm_exynos_ipp_config *src_config =
					&property->config[EXYNOS_DRM_OPS_SRC];
	struct drm_exynos_ipp_config *config =
					&property->config[EXYNOS_DRM_OPS_DST];

	/* Check crop image size for NO scale feature */
	if ((src_config->pos.w != pos->w) || (src_config->pos.h != pos->h)) {
		DRM_ERROR("different size\n");
		return -EINVAL;
	}

	/* Check boundary */
	if (swap) {
		if ((pos->x + pos->h > sz->vsize) ||
			(pos->y + pos->w > sz->hsize)) {
			DRM_ERROR("out of bound\n");
			return -EINVAL;
		}
	} else {
		if ((pos->x + pos->w > sz->hsize) ||
			(pos->y + pos->h > sz->vsize)) {
			DRM_ERROR("out of bound\n");
			return -EINVAL;
		}
	}

	/* Set buffer size configuration */
	if (swap) {
		config->sz.hsize = sz->vsize;
		config->sz.vsize = sz->hsize;
	} else {
		config->sz.hsize = sz->hsize;
		config->sz.vsize = sz->vsize;
	}

	rotator_reg_set_dst_buf_size(rot, config->sz.hsize, config->sz.vsize);

	/* Set crop image position configuration */
	config->pos.x = pos->x;
	config->pos.y = pos->y;

	rotator_reg_set_dst_crop_pos(rot, config->pos.x, config->pos.y);

	return 0;
}
static int rotator_dst_set_size(struct device *dev, int swap,
						struct drm_exynos_pos *pos,
						struct drm_exynos_sz *sz)
{
	struct rot_context *rot = dev_get_drvdata(dev);
	u32 fmt, hsize, vsize;

	/* Get format */
	fmt = rotator_reg_get_format(rot);

	/* Align buffer size */
	hsize = sz->hsize;
	vsize = sz->vsize;
	rotator_align_size(rot, fmt, &hsize, &vsize);

	/* Set buffer size configuration */
	rotator_reg_set_dst_buf_size(rot, hsize, vsize);

	/* Set crop image position configuration */
	rotator_reg_set_dst_crop_pos(rot, pos->x, pos->y);

	return 0;
}