dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [RFC v3 0/5] drm/exynos: add ipp subsystem and each ipp drivers
@ 2012-12-12  7:34 Eunchul Kim
  2012-12-12  7:34 ` [RFC v3 1/5] drm/exynos: add ipp subsystem Eunchul Kim
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12  7:34 UTC (permalink / raw)
  To: dri-devel, inki.dae; +Cc: jy0.jeon, jaejoon.seo, kyungmin.park, jmock.shin

Changelog v3:
Hi All.

This RFC v3 changed ipp subsystem for arrangement.
Fixed scaler problem in GSC.
Added/Removed comment from Inki.Dae.
Fixed Joonyoung.Shim comment.
Added rotator comments.

Changelog v2:
Hi All.

This RFC v2 supports iommu in ipp. and Added/Removed comment from Inki.Dae.
Fixed GSC part bugs and next time I will send our local git commit.
and We finished implementation of SC for post-processing.
SC driver not fully tested yet. so, I didn't add SC feature in this patch.

Thank's

Changelog v1:

Hi All.

I am responsible for a display part from Samsung Electronics Telecommunication Division.
and I am going to add post-processing features in exynos drm.
If you have some opinions of this patch,
please give some comments about my patch.

This patch is post-processing(IPP) support for exynos drm driver.

IPP is stands for Image Post Processing and supports image scaler/rotator
and input/output DMA operations using IPP drivers(FIMC, Rotator, GSC, SC, so on.)
IPP is integration device driver of same attibute hardware.

Exynos4xxxx SoC support FIMC, Rotator for post-processing.
and Exynos5xxxx SoC support GSC, Rotator, SC for post-processing.
SC driver not tested yet. so, I didn't add SC feature in this patch.
and IPP subsystem works on Exynos SoC version independently.

IPP drivers supports Memory to Memory operations with various converting.
and some drivers supports Writeback and Display output operations using local path.
User can make converted image using this driver.
and also supports streaming concept for multimedia data processing.

And supports various operations
1. Scale operation generates various sizes of image.
2. CSC(Color Space Conversion) operation supports format converting.
3. Crop operation supports cutting the image.
4. Rotate operation supports to 90, 180, 270 degree.
5. Flip operation supports to vertical, horizontal, and both.
6. Writeback operation genertates cloned image from display controller(FIMD).
7. Display output operation support various format display to display controller(FIMD).
8. Input DMA reads image data from the memory.
9. Output DMA writes image data to memory.
10. Supports image effect functions.

Descriptions)
User should make property informations and set this property to registers.
and IPP subsystem manages property id using command node and make queue list using memory node.
IPP subsystem supports register function of IPP drivers.
IPP driver manages input/output DMA with various operations. and some driver supports
optional operations(writeback, output).
IPP driver needs various informations, so User set property information to IPP driver.
and also IPP driver needs memory base address of image for various operations.
User doesn't know its address, so fills the gem handle of that memory than address of image base.
and than IPP driver start operation.

Ioctls)
We adds four ioctls and one event for IPP subsystem.

- ioctls
DRM_EXYNOS_IPP_GET_PROPERTY : get ipp driver capabilitis and id.
DRM_EXYNOS_IPP_SET_PROPERTY : set format, position, rotation, flip about source/destination.
DRM_EXYNOS_IPP_QUEUE_BUF : enqueue/dequeue buffer and make event list.
DRM_EXYNOS_IPP_CMD_CTRL : play/stop/pause/resume control.

- event
DRM_EXYNOS_IPP_EVENT : event to give notification completion of buffer DMA with buffer list

Basic control flow and Sample pseudo application)
1. Basic control flow is same as below
Open -> Get properties -> User choose IPP driver and set property information -> Set Property -> Create gem handle ->
Queue buffer(Enqueue) of source/destination -> Command control(Play) -> Event occured to User
-> User handle converted image -> (Queue buffer(Enqueue) of source/destination -> Event occured to User)*N ->
Queue buffer(Dequeue) of source/destination -> Command control(Stop) -> Free gem handle -> Close

2. Sample pseudo application
#include "exynos_drm.h"
static int exynos_drm_ipp_set_property(int fd ...)
{
	struct drm_exynos_pos crop_pos = {0, 0, hsize, vsize};
	struct drm_exynos_pos scale_pos = {0, 0, hsize, vsize};
	struct drm_exynos_sz src_sz = {hsize, vsize};
	struct drm_exynos_sz dst_sz = {hsize, vsize};
	int ret = 0;

	memset(property, 0x00, sizeof(struct drm_exynos_ipp_property));
	property->cmd = cmd;

	property->config[EXYNOS_DRM_OPS_SRC].ops_id = EXYNOS_DRM_OPS_SRC;
	property->config[EXYNOS_DRM_OPS_SRC].flip = EXYNOS_DRM_FLIP_NONE;
	property->config[EXYNOS_DRM_OPS_SRC].degree = EXYNOS_DRM_DEGREE_0;
	property->config[EXYNOS_DRM_OPS_SRC].fmt = DRM_FORMAT_XRGB8888;
	property->config[EXYNOS_DRM_OPS_SRC].pos = crop_pos;
	property->config[EXYNOS_DRM_OPS_SRC].sz = src_sz;

	property->config[EXYNOS_DRM_OPS_DST].ops_id = EXYNOS_DRM_OPS_DST;
	property->config[EXYNOS_DRM_OPS_DST].flip = EXYNOS_DRM_FLIP_NONE;
	property->config[EXYNOS_DRM_OPS_DST].degree = degree;
	property->config[EXYNOS_DRM_OPS_DST].fmt = DRM_FORMAT_XRGB8888;
	property->config[EXYNOS_DRM_OPS_DST].pos = scale_pos;
	property->config[EXYNOS_DRM_OPS_DST].sz = dst_sz;

	ret = ioctl(fd, DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY, property);
	if (ret)
		fprintf(stderr,
			"failed to DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY : %s\n",
			strerror(errno));
	
	printf("DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY : prop_id[%d]\n",
		property->prop_id);

	return ret;
}

static int exynos_drm_ipp_queue_buf(int fd, ..., unsigned int gem_handle)
{
	int ret = 0;

	memset(qbuf, 0x00, sizeof(struct drm_exynos_ipp_queue_buf));

	qbuf->ops_id = ops_id;
	qbuf->buf = buf;
	qbuf->user_data = 0;
	qbuf->prop_id = prop_id;
	qbuf->buf_id = buf_id;
	qbuf->handle[EXYNOS_DRM_PLANAR_Y] = gem_handle;
	qbuf->handle[EXYNOS_DRM_PLANAR_CB] = 0;
	qbuf->handle[EXYNOS_DRM_PLANAR_CR] = 0;

	ret = ioctl(fd, DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF, qbuf);
	if (ret)
		fprintf(stderr,
		"failed to DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF[id:%d][buf:%d] : %s\n",
		ops_id, buf, strerror(errno));
 
	return ret;
}

static int exynos_drm_ipp_cmd_ctrl(int fd, ...)
{
	int ret = 0;

	memset(cmd_ctrl, 0x00, sizeof(struct drm_exynos_ipp_cmd_ctrl));

	cmd_ctrl->prop_id = prop_id;
	cmd_ctrl->ctrl = ctrl;

	ret = ioctl(fd, DRM_IOCTL_EXYNOS_IPP_CMD_CTRL, cmd_ctrl);
	if (ret)
		fprintf(stderr,
		"failed to DRM_IOCTL_EXYNOS_IPP_CMD_CTRL[prop_id:%d][ctrl:%d] : %s\n",
		prop_id, ctrl, strerror(errno));

	return ret;
}

int ipp_event_handler(...)
{
	char buffer[1024];
	int len, i;
	struct drm_event *e;
	struct drm_exynos_ipp_event *ipp_event;
	char filename[100];
	int ret = 0;
	int src_buf_id, dst_buf_id;
	static bmp_idx = 0;

	len = read(fd, buffer, sizeof buffer);
	if (len == 0)
		return 0;
	if (len < sizeof *e)
		return -1;

	i = 0;
	while (i < len) {
		e = (struct drm_event *) &buffer[i];
		switch (e->type) {
		case DRM_EXYNOS_IPP_EVENT:
			ipp_event = (struct drm_exynos_ipp_event *) e;
			src_buf_id = ipp_event->buf_id[EXYNOS_DRM_OPS_SRC];
			dst_buf_id = ipp_event->buf_id[EXYNOS_DRM_OPS_DST];

			/* For source buffer queue to IPP */
			ret = exynos_drm_ipp_queue_buf(fd, &src_qbuf[src_buf_id], EXYNOS_DRM_OPS_SRC,
						IPP_BUF_ENQUEUE, property->prop_id,
						src_buf_id, src_gem[src_buf_id].handle);
			if (ret) {
				fprintf(stderr, "failed to ipp buf src queue\n");
				goto err_ipp_ctrl_close;
			}

			/* For destination buffer queue to IPP */
			ret = exynos_drm_ipp_queue_buf(fd, &dst_qbuf[dst_buf_id], EXYNOS_DRM_OPS_DST,
						IPP_BUF_ENQUEUE, property->prop_id,
						dst_buf_id, dst_gem[dst_buf_id].handle);
			if (ret) {
				fprintf(stderr, "failed to ipp buf dst queue\n");
				goto err_ipp_ctrl_close;
			}
			break;
		default:
			break;
		}
		i += e->length;
	}

err_ipp_ctrl_close:
	return ret;
}

void ipp_main(...)
{
	struct drm_exynos_ipp_property property;
	struct drm_exynos_ipp_cmd_ctrl cmd_ctrl;
	struct drm_exynos_sz def_sz = {720, 1280};
	struct drm_exynos_ipp_queue_buf qbuf1[MAX_BUF], qbuf2[MAX_BUF];
	unsigned int width=720, height=1280, stride;
	int ret, i, j, x;
	struct drm_exynos_gem_create gem1[MAX_BUF], gem2[MAX_BUF];
	struct drm_exynos_gem_mmap mmap1[MAX_BUF], mmap2[MAX_BUF];
	void *usr_addr1[MAX_BUF], *usr_addr2[MAX_BUF];
	struct timeval begin, end;
	struct drm_gem_close args;
	char filename[100];

	/* For property */
	ret = exynos_drm_ipp_set_property(fd, &property, &def_sz, IPP_CMD_M2M, EXYNOS_DRM_DEGREE_0);
	if (ret) {
		fprintf(stderr, "failed to ipp property\n");
		return;
	}

	for (i = 0; i < MAX_BUF; i++) {
		/* For source buffer map to IPP */
		ret = exynos_drm_ipp_queue_buf(fd, &qbuf1[i], EXYNOS_DRM_OPS_SRC,
				IPP_BUF_ENQUEUE, property.prop_id, i, gem1[i].handle);
		if (ret) {
			fprintf(stderr, "failed to ipp buf src map\n");
			goto err_ipp_ctrl_close;
		}
	}

	for (i = 0; i < MAX_BUF; i++) {
		/* For destination buffer map to IPP */
		ret = exynos_drm_ipp_queue_buf(fd, &qbuf2[i], EXYNOS_DRM_OPS_DST,
			IPP_BUF_ENQUEUE, property.prop_id, i, gem2[i].handle);
		if (ret) {
			fprintf(stderr, "failed to ipp buf dst map\n");
			goto err_ipp_ctrl_close;
		}
	}

	/* Start */
	gettimeofday(&begin, NULL);
	ret = exynos_drm_ipp_cmd_ctrl(fd, &cmd_ctrl, property.prop_id, IPP_CTRL_PLAY);
	if (ret) {
		fprintf(stderr,
		"failed to ipp ctrl IPP_CMD_M2M start\n");
		goto err_ipp_ctrl_close;
	}
        
	j=0;
	while (1) {
		struct timeval timeout = { .tv_sec = 3, .tv_usec = 0 };
		fd_set fds;

		FD_ZERO(&fds);
		FD_SET(0, &fds);
		FD_SET(fd, &fds);
		ret = select(fd + 1, &fds, NULL, NULL, &timeout);
		if (ret <= 0) {
			fprintf(stderr, "select timed out or error.\n");
			continue;
		} else if (FD_ISSET(0, &fds)) {
			break;
		}

		gettimeofday(&end, NULL);
		usec[j] = (end.tv_sec - begin.tv_sec) * 1000000 +
		(end.tv_usec - begin.tv_usec);

		if(ipp_event_handler() < 0)
			break;

		if (++j > MAX_LOOP)
			break;

		gettimeofday(&begin, NULL);
	}

err_ipp_ctrl_close:
	/* For source buffer dequeue to IPP */
	for (i = 0; i < MAX_BUF; i++) {
		ret = exynos_drm_ipp_queue_buf(fd, &qbuf1[i], EXYNOS_DRM_OPS_SRC,
						IPP_BUF_DEQUEUE, property.prop_id, i, gem1[i].handle);
		if (ret < 0)
			fprintf(stderr, "failed to ipp buf dst dequeue\n");
	}

	/* For destination buffer dequeue to IPP */
	for (i = 0; i < MAX_BUF; i++) {
		ret = exynos_drm_ipp_queue_buf(fd, &qbuf2[i], EXYNOS_DRM_OPS_DST,
						IPP_BUF_DEQUEUE, property.prop_id, i, gem2[i].handle);
		if (ret < 0)
			fprintf(stderr, "failed to ipp buf dst dequeue\n");
	}

	/* Stop */
	ret = exynos_drm_ipp_cmd_ctrl(fd, &cmd_ctrl, property.prop_id, IPP_CTRL_STOP);
	if (ret)
		fprintf(stderr, "failed to ipp ctrl IPP_CMD_WB stop\n");

	return;
}

Eunchul Kim (5):
  drm/exynos: add ipp subsystem
  drm/exynos: add iommu support for ipp
  drm/exynos: add fimc ipp driver
  drm/exynos: add rotator ipp driver
  drm/exynos: add gsc ipp driver

 drivers/gpu/drm/exynos/Kconfig              |   24 +
 drivers/gpu/drm/exynos/Makefile             |    4 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c     |   69 +
 drivers/gpu/drm/exynos/exynos_drm_drv.h     |   10 +
 drivers/gpu/drm/exynos/exynos_drm_fimc.c    | 2022 ++++++++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_fimc.h    |   34 +
 drivers/gpu/drm/exynos/exynos_drm_gsc.c     | 1927 +++++++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_gsc.h     |   34 +
 drivers/gpu/drm/exynos/exynos_drm_ipp.c     | 2077 +++++++++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_ipp.h     |  266 ++++
 drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829 +++++++++++
 drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
 drivers/gpu/drm/exynos/regs-fimc.h          |  669 +++++++++
 drivers/gpu/drm/exynos/regs-gsc.h           |  295 ++++
 drivers/gpu/drm/exynos/regs-rotator.h       |   73 +
 include/drm/exynos_drm.h                    |   26 +
 include/uapi/drm/exynos_drm.h               |  190 +++
 17 files changed, 8562 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.h
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.h
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.h
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
 create mode 100644 drivers/gpu/drm/exynos/regs-fimc.h
 create mode 100644 drivers/gpu/drm/exynos/regs-gsc.h
 create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [RFC v3 1/5] drm/exynos: add ipp subsystem
  2012-12-12  7:34 [RFC v3 0/5] drm/exynos: add ipp subsystem and each ipp drivers Eunchul Kim
@ 2012-12-12  7:34 ` Eunchul Kim
  2012-12-12  8:18   ` Inki Dae
  2012-12-12  7:34 ` [RFC v3 2/5] drm/exynos: add iommu support for ipp Eunchul Kim
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12  7:34 UTC (permalink / raw)
  To: dri-devel, inki.dae; +Cc: jy0.jeon, jaejoon.seo, kyungmin.park, jmock.shin

IPP stand for Image Post Processing and supports image scaler/rotator
/crop/flip/csc(color space conversion) and input/output DMA operations using ipp drivers.
also supports writeback and display output operations.
ipp driver include FIMC, Rotator, GSC, SC, so on.
and ipp is integration device driver for each hardware.

Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
Signed-off-by: Jinyoung Jeon <jy0.jeon@samsung.com>
---
 drivers/gpu/drm/exynos/Kconfig          |    6 +
 drivers/gpu/drm/exynos/Makefile         |    1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c |   24 +
 drivers/gpu/drm/exynos/exynos_drm_drv.h |    7 +
 drivers/gpu/drm/exynos/exynos_drm_ipp.c | 2059 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_ipp.h |  266 ++++
 include/uapi/drm/exynos_drm.h           |  190 +++
 7 files changed, 2553 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.h

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 4ea8cdc..bcf1c9d 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -45,3 +45,9 @@ config DRM_EXYNOS_G2D
 	depends on DRM_EXYNOS && !VIDEO_SAMSUNG_S5P_G2D
 	help
 	  Choose this option if you want to use Exynos G2D for DRM.
+
+config DRM_EXYNOS_IPP
+	bool "Exynos DRM IPP"
+	depends on DRM_EXYNOS
+	help
+	  Choose this option if you want to use IPP feature for DRM.
diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 26813b8..6c536ce 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -16,5 +16,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI)	+= exynos_hdmi.o exynos_mixer.o \
 					   exynos_drm_hdmi.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+= exynos_drm_vidi.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
+exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
 
 obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 4a1168d..0eb8a97 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -40,6 +40,7 @@
 #include "exynos_drm_vidi.h"
 #include "exynos_drm_dmabuf.h"
 #include "exynos_drm_g2d.h"
+#include "exynos_drm_ipp.h"
 #include "exynos_drm_iommu.h"
 
 #define DRIVER_NAME	"exynos"
@@ -249,6 +250,14 @@ static struct drm_ioctl_desc exynos_ioctls[] = {
 			exynos_g2d_set_cmdlist_ioctl, DRM_UNLOCKED | DRM_AUTH),
 	DRM_IOCTL_DEF_DRV(EXYNOS_G2D_EXEC,
 			exynos_g2d_exec_ioctl, DRM_UNLOCKED | DRM_AUTH),
+	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_PROPERTY,
+			exynos_drm_ipp_get_property, DRM_UNLOCKED | DRM_AUTH),
+	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_SET_PROPERTY,
+			exynos_drm_ipp_set_property, DRM_UNLOCKED | DRM_AUTH),
+	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_QUEUE_BUF,
+			exynos_drm_ipp_queue_buf, DRM_UNLOCKED | DRM_AUTH),
+	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_CMD_CTRL,
+			exynos_drm_ipp_cmd_ctrl, DRM_UNLOCKED | DRM_AUTH),
 };
 
 static const struct file_operations exynos_drm_driver_fops = {
@@ -363,6 +372,12 @@ static int __init exynos_drm_init(void)
 		goto out_g2d;
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_IPP
+	ret = platform_driver_register(&ipp_driver);
+	if (ret < 0)
+		goto out_ipp;
+#endif
+
 	ret = platform_driver_register(&exynos_drm_platform_driver);
 	if (ret < 0)
 		goto out_drm;
@@ -380,6 +395,11 @@ out:
 	platform_driver_unregister(&exynos_drm_platform_driver);
 
 out_drm:
+#ifdef CONFIG_DRM_EXYNOS_IPP
+	platform_driver_unregister(&ipp_driver);
+out_ipp:
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_G2D
 	platform_driver_unregister(&g2d_driver);
 out_g2d:
@@ -416,6 +436,10 @@ static void __exit exynos_drm_exit(void)
 
 	platform_driver_unregister(&exynos_drm_platform_driver);
 
+#ifdef CONFIG_DRM_EXYNOS_IPP
+	platform_driver_unregister(&ipp_driver);
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_G2D
 	platform_driver_unregister(&g2d_driver);
 #endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index a9db025..a365788 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -235,8 +235,14 @@ struct exynos_drm_g2d_private {
 	unsigned int		gem_nr;
 };
 
+struct exynos_drm_ipp_private {
+	struct device	*dev;
+	struct list_head	event_list;
+};
+
 struct drm_exynos_file_private {
 	struct exynos_drm_g2d_private	*g2d_priv;
+	struct exynos_drm_ipp_private	*ipp_priv;
 };
 
 /*
@@ -346,4 +352,5 @@ extern struct platform_driver mixer_driver;
 extern struct platform_driver exynos_drm_common_hdmi_driver;
 extern struct platform_driver vidi_driver;
 extern struct platform_driver g2d_driver;
+extern struct platform_driver ipp_driver;
 #endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
new file mode 100644
index 0000000..eb12cb5
--- /dev/null
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -0,0 +1,2059 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics Co.Ltd
+ * Authors:
+ *	Eunchul Kim <chulspro.kim@samsung.com>
+ *	Jinyoung Jeon <jy0.jeon@samsung.com>
+ *	Sangmin Lee <lsmin.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/pm_runtime.h>
+#include <plat/map-base.h>
+
+#include <drm/drmP.h>
+#include <drm/exynos_drm.h>
+#include "exynos_drm_drv.h"
+#include "exynos_drm_gem.h"
+#include "exynos_drm_ipp.h"
+
+/*
+ * IPP is stand for Image Post Processing and
+ * supports image scaler/rotator and input/output DMA operations.
+ * using FIMC, GSC, Rotator, so on.
+ * IPP is integration device driver of same attribute h/w
+ */
+
+#define get_ipp_context(dev)	platform_get_drvdata(to_platform_device(dev))
+#define ipp_is_m2m_cmd(c)	(c == IPP_CMD_M2M)
+
+/*
+ * A structure of event.
+ *
+ * @base: base of event.
+ * @event: ipp event.
+ */
+struct drm_exynos_ipp_send_event {
+	struct drm_pending_event	base;
+	struct drm_exynos_ipp_event	event;
+};
+
+/*
+ * A structure of memory node.
+ *
+ * @list: list head to memory queue information.
+ * @ops_id: id of operations.
+ * @prop_id: id of property.
+ * @buf_id: id of buffer.
+ * @buf_info: gem objects and dma address, size.
+ * @filp: a pointer to drm_file.
+ */
+struct drm_exynos_ipp_mem_node {
+	struct list_head	list;
+	enum drm_exynos_ops_id	ops_id;
+	u32	prop_id;
+	u32	buf_id;
+	struct drm_exynos_ipp_buf_info	buf_info;
+	struct drm_file		*filp;
+};
+
+/*
+ * A structure of ipp context.
+ *
+ * @subdrv: prepare initialization using subdrv.
+ * @ipp_lock: lock for synchronization of access to ipp_idr.
+ * @prop_lock: lock for synchronization of access to prop_idr.
+ * @ipp_idr: ipp driver idr.
+ * @prop_idr: property idr.
+ * @event_workq: event work queue.
+ * @cmd_workq: command work queue.
+ */
+struct ipp_context {
+	struct exynos_drm_subdrv	subdrv;
+	struct mutex	ipp_lock;
+	struct mutex	prop_lock;
+	struct idr	ipp_idr;
+	struct idr	prop_idr;
+	struct workqueue_struct	*event_workq;
+	struct workqueue_struct	*cmd_workq;
+};
+
+static LIST_HEAD(exynos_drm_ippdrv_list);
+static DEFINE_MUTEX(exynos_drm_ippdrv_lock);
+static BLOCKING_NOTIFIER_HEAD(exynos_drm_ippnb_list);
+
+int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv *ippdrv)
+{
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!ippdrv)
+		return -EINVAL;
+
+	mutex_lock(&exynos_drm_ippdrv_lock);
+	list_add_tail(&ippdrv->drv_list, &exynos_drm_ippdrv_list);
+	mutex_unlock(&exynos_drm_ippdrv_lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(exynos_drm_ippdrv_register);
+
+int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv *ippdrv)
+{
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!ippdrv)
+		return -EINVAL;
+
+	mutex_lock(&exynos_drm_ippdrv_lock);
+	list_del(&ippdrv->drv_list);
+	mutex_unlock(&exynos_drm_ippdrv_lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(exynos_drm_ippdrv_unregister);
+
+static int ipp_create_id(struct idr *id_idr, struct mutex *lock, void *obj,
+		u32 *idp)
+{
+	int ret;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+again:
+	/* ensure there is space available to allocate a handle */
+	if (idr_pre_get(id_idr, GFP_KERNEL) == 0) {
+		DRM_ERROR("failed to get idr.\n");
+		return -ENOMEM;
+	}
+
+	/* do the allocation under our mutexlock */
+	mutex_lock(lock);
+	ret = idr_get_new_above(id_idr, obj, 1, (int *)idp);
+	mutex_unlock(lock);
+	if (ret == -EAGAIN)
+		goto again;
+
+	return ret;
+}
+
+static void *ipp_find_obj(struct idr *id_idr, struct mutex *lock, u32 id)
+{
+	void *obj;
+
+	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, id);
+
+	mutex_lock(lock);
+
+	/* find object using handle */
+	obj = idr_find(id_idr, id);
+	if (!obj) {
+		DRM_ERROR("failed to find object.\n");
+		mutex_unlock(lock);
+		return ERR_PTR(-ENODEV);
+	}
+
+	mutex_unlock(lock);
+
+	return obj;
+}
+
+static inline bool ipp_check_dedicated(struct exynos_drm_ippdrv *ippdrv,
+		enum drm_exynos_ipp_cmd	cmd)
+{
+	/*
+	 * check dedicated flag and WB, OUTPUT operation with
+	 * power on state.
+	 */
+	if (ippdrv->dedicated || (!ipp_is_m2m_cmd(cmd) &&
+	    !pm_runtime_suspended(ippdrv->dev)))
+		return true;
+
+	return false;
+}
+
+static struct exynos_drm_ippdrv *ipp_find_driver(struct ipp_context *ctx,
+		struct drm_exynos_ipp_property *property)
+{
+	struct exynos_drm_ippdrv *ippdrv;
+	u32 ipp_id = property->ipp_id;
+
+	DRM_DEBUG_KMS("%s:ipp_id[%d]\n", __func__, ipp_id);
+
+	if (ipp_id) {
+		/* find ipp driver using idr */
+		ippdrv = ipp_find_obj(&ctx->ipp_idr, &ctx->ipp_lock,
+			ipp_id);
+		if (IS_ERR_OR_NULL(ippdrv)) {
+			DRM_ERROR("not found ipp%d driver.\n", ipp_id);
+			goto err_null;
+		}
+
+		/*
+		 * WB, OUTPUT opertion not supported multi-operation.
+		 * so, make dedicated state at set property ioctl.
+		 * when ipp driver finished operations, clear dedicated flags.
+		 */
+		if (ipp_check_dedicated(ippdrv, property->cmd)) {
+			DRM_ERROR("already used choose device.\n");
+			goto err_null;
+		}
+
+		/*
+		 * This is necessary to find correct device in ipp drivers.
+		 * ipp drivers have different abilities,
+		 * so need to check property.
+		 */
+		if (ippdrv->check_property &&
+		    ippdrv->check_property(ippdrv->dev, property)) {
+			DRM_ERROR("not support property.\n");
+			goto err_null;
+		}
+
+		return ippdrv;
+	} else {
+		/*
+		 * This case is search all ipp driver for finding.
+		 * user application don't set ipp_id in this case,
+		 * so ipp subsystem search correct driver in driver list.
+		 */
+		list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
+			if (ipp_check_dedicated(ippdrv, property->cmd)) {
+				DRM_DEBUG_KMS("%s:used device.\n", __func__);
+				continue;
+			}
+
+			if (ippdrv->check_property &&
+			    ippdrv->check_property(ippdrv->dev, property)) {
+				DRM_DEBUG_KMS("%s:not support property.\n",
+					__func__);
+				continue;
+			}
+
+			return ippdrv;
+		}
+
+		DRM_ERROR("not support ipp driver operations.\n");
+	}
+
+	return ERR_PTR(-ENODEV);
+
+err_null:
+	return NULL;
+}
+
+static struct exynos_drm_ippdrv *ipp_find_drv_by_handle(u32 prop_id)
+{
+	struct exynos_drm_ippdrv *ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node;
+	int count = 0;
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, prop_id);
+
+	if (list_empty(&exynos_drm_ippdrv_list)) {
+		DRM_DEBUG_KMS("%s:ippdrv_list is empty.\n", __func__);
+		return ERR_PTR(-ENODEV);
+	}
+
+	/*
+	 * This case is search ipp driver by prop_id handle.
+	 * sometimes, ipp subsystem find driver by prop_id.
+	 * e.g PAUSE state, queue buf, command contro.
+	 */
+	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
+		DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]\n", __func__,
+			count++, (int)ippdrv);
+
+		if (!list_empty(&ippdrv->cmd_list)) {
+			list_for_each_entry(c_node, &ippdrv->cmd_list, list)
+				if (c_node->property.prop_id == prop_id)
+					return ippdrv;
+		}
+	}
+
+	return ERR_PTR(-ENODEV);
+}
+
+int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void *data,
+		struct drm_file *file)
+{
+	struct drm_exynos_file_private *file_priv = file->driver_priv;
+	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
+	struct device *dev = priv->dev;
+	struct ipp_context *ctx = get_ipp_context(dev);
+	struct drm_exynos_ipp_prop_list *prop_list = data;
+	struct exynos_drm_ippdrv *ippdrv;
+	int count = 0;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!ctx) {
+		DRM_ERROR("invalid context.\n");
+		return -EINVAL;
+	}
+
+	if (!prop_list) {
+		DRM_ERROR("invalid property parameter.\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG_KMS("%s:ipp_id[%d]\n", __func__, prop_list->ipp_id);
+
+	if (!prop_list->ipp_id) {
+		list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list)
+			count++;
+		/*
+		 * Supports ippdrv list count for user application.
+		 * First step user application getting ippdrv count.
+		 * and second step getting ippdrv capability using ipp_id.
+		 */
+		prop_list->count = count;
+	} else {
+		/*
+		 * Getting ippdrv capability by ipp_id.
+		 * some deivce not supported wb, output interface.
+		 * so, user application detect correct ipp driver
+		 * using this ioctl.
+		 */
+		ippdrv = ipp_find_obj(&ctx->ipp_idr, &ctx->ipp_lock,
+						prop_list->ipp_id);
+		if (!ippdrv) {
+			DRM_ERROR("not found ipp%d driver.\n",
+					prop_list->ipp_id);
+			return -EINVAL;
+		}
+
+		prop_list = ippdrv->prop_list;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(exynos_drm_ipp_get_property);
+
+static void ipp_print_property(struct drm_exynos_ipp_property *property,
+		int idx)
+{
+	struct drm_exynos_ipp_config *config = &property->config[idx];
+	struct drm_exynos_pos *pos = &config->pos;
+	struct drm_exynos_sz *sz = &config->sz;
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]ops[%s]fmt[0x%x]\n",
+		__func__, property->prop_id, idx ? "dst" : "src", config->fmt);
+
+	DRM_DEBUG_KMS("%s:pos[%d %d %d %d]sz[%d %d]f[%d]r[%d]\n",
+		__func__, pos->x, pos->y, pos->w, pos->h,
+		sz->hsize, sz->vsize, config->flip, config->degree);
+}
+
+static int ipp_find_and_set_property(struct drm_exynos_ipp_property *property)
+{
+	struct exynos_drm_ippdrv *ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node;
+	u32 prop_id = property->prop_id;
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, prop_id);
+
+	ippdrv = ipp_find_drv_by_handle(prop_id);
+	if (IS_ERR_OR_NULL(ippdrv)) {
+		DRM_ERROR("failed to get ipp driver.\n");
+		return -EINVAL;
+	}
+
+	/*
+	 * Find command node using command list in ippdrv.
+	 * when we find this command no using prop_id.
+	 * return property information set in this command node.
+	 */
+	list_for_each_entry(c_node, &ippdrv->cmd_list, list) {
+		if ((c_node->property.prop_id == prop_id) &&
+		    (c_node->state == IPP_STATE_STOP)) {
+			DRM_DEBUG_KMS("%s:found cmd[%d]ippdrv[0x%x]\n",
+				__func__, property->cmd, (int)ippdrv);
+
+			c_node->property = *property;
+			return 0;
+		}
+	}
+
+	DRM_ERROR("failed to search property.\n");
+
+	return -EINVAL;
+}
+
+static struct drm_exynos_ipp_cmd_work *ipp_create_cmd_work(void)
+{
+	struct drm_exynos_ipp_cmd_work *cmd_work;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	cmd_work = kzalloc(sizeof(*cmd_work), GFP_KERNEL);
+	if (!cmd_work) {
+		DRM_ERROR("failed to alloc cmd_work.\n");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	INIT_WORK((struct work_struct *)cmd_work, ipp_sched_cmd);
+
+	return cmd_work;
+}
+
+static struct drm_exynos_ipp_event_work *ipp_create_event_work(void)
+{
+	struct drm_exynos_ipp_event_work *event_work;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	event_work = kzalloc(sizeof(*event_work), GFP_KERNEL);
+	if (!event_work) {
+		DRM_ERROR("failed to alloc event_work.\n");
+		return ERR_PTR(-ENOMEM);
+	}
+
+	INIT_WORK((struct work_struct *)event_work, ipp_sched_event);
+
+	return event_work;
+}
+
+int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
+		struct drm_file *file)
+{
+	struct drm_exynos_file_private *file_priv = file->driver_priv;
+	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
+	struct device *dev = priv->dev;
+	struct ipp_context *ctx = get_ipp_context(dev);
+	struct drm_exynos_ipp_property *property = data;
+	struct exynos_drm_ippdrv *ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node;
+	int ret, i;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!ctx) {
+		DRM_ERROR("invalid context.\n");
+		return -EINVAL;
+	}
+
+	if (!property) {
+		DRM_ERROR("invalid property parameter.\n");
+		return -EINVAL;
+	}
+
+	/*
+	 * This is log print for user application property.
+	 * user application set various property.
+	 */
+	for_each_ipp_ops(i)
+		ipp_print_property(property, i);
+
+	/*
+	 * set property ioctl generated new prop_id.
+	 * but in this case already asigned prop_id using old set property.
+	 * e.g PAUSE state. this case supports find current prop_id and use it
+	 * instead of allocation.
+	 */
+	if (property->prop_id) {
+		DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
+		return ipp_find_and_set_property(property);
+	}
+
+	/* find ipp driver using ipp id */
+	ippdrv = ipp_find_driver(ctx, property);
+	if (IS_ERR_OR_NULL(ippdrv)) {
+		DRM_ERROR("failed to get ipp driver.\n");
+		return -EINVAL;
+	}
+
+	/* allocate command node */
+	c_node = kzalloc(sizeof(*c_node), GFP_KERNEL);
+	if (!c_node) {
+		DRM_ERROR("failed to allocate map node.\n");
+		return -ENOMEM;
+	}
+
+	/* create property id */
+	ret = ipp_create_id(&ctx->prop_idr, &ctx->prop_lock, c_node,
+		&property->prop_id);
+	if (ret) {
+		DRM_ERROR("failed to create id.\n");
+		goto err_clear;
+	}
+
+	DRM_DEBUG_KMS("%s:created prop_id[%d]cmd[%d]ippdrv[0x%x]\n",
+		__func__, property->prop_id, property->cmd, (int)ippdrv);
+
+	/* stored property information and ippdrv in private data */
+	c_node->priv = priv;
+	c_node->property = *property;
+	c_node->state = IPP_STATE_IDLE;
+
+	c_node->start_work = ipp_create_cmd_work();
+	if (IS_ERR_OR_NULL(c_node->start_work)) {
+		DRM_ERROR("failed to create start work.\n");
+		goto err_clear;
+	}
+
+	c_node->stop_work = ipp_create_cmd_work();
+	if (IS_ERR_OR_NULL(c_node->stop_work)) {
+		DRM_ERROR("failed to create stop work.\n");
+		goto err_free_start;
+	}
+
+	c_node->event_work = ipp_create_event_work();
+	if (IS_ERR_OR_NULL(c_node->event_work)) {
+		DRM_ERROR("failed to create event work.\n");
+		goto err_free_stop;
+	}
+
+	mutex_init(&c_node->cmd_lock);
+	mutex_init(&c_node->mem_lock);
+	mutex_init(&c_node->event_lock);
+
+	init_completion(&c_node->start_complete);
+	init_completion(&c_node->stop_complete);
+
+	for_each_ipp_ops(i)
+		INIT_LIST_HEAD(&c_node->mem_list[i]);
+
+	INIT_LIST_HEAD(&c_node->event_list);
+	list_splice_init(&priv->event_list, &c_node->event_list);
+	list_add_tail(&c_node->list, &ippdrv->cmd_list);
+
+	/* make dedicated state without m2m */
+	if (!ipp_is_m2m_cmd(property->cmd))
+		ippdrv->dedicated = true;
+
+	return 0;
+
+err_free_stop:
+	kfree(c_node->stop_work);
+err_free_start:
+	kfree(c_node->start_work);
+err_clear:
+	kfree(c_node);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(exynos_drm_ipp_set_property);
+
+static void ipp_clean_cmd_node(struct drm_exynos_ipp_cmd_node *c_node)
+{
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	/* delete list */
+	list_del(&c_node->list);
+
+	/* destroy mutex */
+	mutex_destroy(&c_node->cmd_lock);
+	mutex_destroy(&c_node->mem_lock);
+	mutex_destroy(&c_node->event_lock);
+
+	/* free command node */
+	kfree(c_node->start_work);
+	kfree(c_node->stop_work);
+	kfree(c_node->event_work);
+	kfree(c_node);
+}
+
+static int ipp_check_mem_list(struct drm_exynos_ipp_cmd_node *c_node)
+{
+	struct drm_exynos_ipp_property *property = &c_node->property;
+	struct drm_exynos_ipp_mem_node *m_node;
+	struct list_head *head;
+	int ret, i, count[EXYNOS_DRM_OPS_MAX] = { 0, };
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	mutex_lock(&c_node->mem_lock);
+
+	for_each_ipp_ops(i) {
+		/* source/destination memory list */
+		head = &c_node->mem_list[i];
+
+		if (list_empty(head)) {
+			DRM_DEBUG_KMS("%s:%s memory empty.\n", __func__,
+				i ? "dst" : "src");
+			continue;
+		}
+
+		/* find memory node entry */
+		list_for_each_entry(m_node, head, list) {
+			DRM_DEBUG_KMS("%s:%s,count[%d]m_node[0x%x]\n", __func__,
+				i ? "dst" : "src", count[i], (int)m_node);
+			count[i]++;
+		}
+	}
+
+	DRM_DEBUG_KMS("%s:min[%d]max[%d]\n", __func__,
+		min(count[EXYNOS_DRM_OPS_SRC], count[EXYNOS_DRM_OPS_DST]),
+		max(count[EXYNOS_DRM_OPS_SRC], count[EXYNOS_DRM_OPS_DST]));
+
+	/*
+	 * M2M operations should be need paired memory address.
+	 * so, need to check minimum count about src, dst.
+	 * other case not use paired memory, so use maximum count
+	 */
+	if (ipp_is_m2m_cmd(property->cmd))
+		ret = min(count[EXYNOS_DRM_OPS_SRC],
+			count[EXYNOS_DRM_OPS_DST]);
+	else
+		ret = max(count[EXYNOS_DRM_OPS_SRC],
+			count[EXYNOS_DRM_OPS_DST]);
+
+	mutex_unlock(&c_node->mem_lock);
+
+	return ret;
+}
+
+static struct drm_exynos_ipp_mem_node
+		*ipp_find_mem_node(struct drm_exynos_ipp_cmd_node *c_node,
+		struct drm_exynos_ipp_queue_buf *qbuf)
+{
+	struct drm_exynos_ipp_mem_node *m_node;
+	struct list_head *head;
+	int count = 0;
+
+	DRM_DEBUG_KMS("%s:buf_id[%d]\n", __func__, qbuf->buf_id);
+
+	/* source/destination memory list */
+	head = &c_node->mem_list[qbuf->ops_id];
+
+	/* find memory node from memory list */
+	list_for_each_entry(m_node, head, list) {
+		DRM_DEBUG_KMS("%s:count[%d]m_node[0x%x]\n",
+			__func__, count++, (int)m_node);
+
+		/* compare buffer id */
+		if (m_node->buf_id == qbuf->buf_id)
+			return m_node;
+	}
+
+	return NULL;
+}
+
+static int ipp_set_mem_node(struct exynos_drm_ippdrv *ippdrv,
+		struct drm_exynos_ipp_cmd_node *c_node,
+		struct drm_exynos_ipp_mem_node *m_node)
+{
+	struct exynos_drm_ipp_ops *ops = NULL;
+	int ret = 0;
+
+	DRM_DEBUG_KMS("%s:node[0x%x]\n", __func__, (int)m_node);
+
+	if (!m_node) {
+		DRM_ERROR("invalid queue node.\n");
+		return -EFAULT;
+	}
+
+	mutex_lock(&c_node->mem_lock);
+
+	DRM_DEBUG_KMS("%s:ops_id[%d]\n", __func__, m_node->ops_id);
+
+	/* get operations callback */
+	ops = ippdrv->ops[m_node->ops_id];
+	if (!ops) {
+		DRM_ERROR("not support ops.\n");
+		ret = -EFAULT;
+		goto err_unlock;
+	}
+
+	/* set address and enable irq */
+	if (ops->set_addr) {
+		ret = ops->set_addr(ippdrv->dev, &m_node->buf_info,
+			m_node->buf_id, IPP_BUF_ENQUEUE);
+		if (ret) {
+			DRM_ERROR("failed to set addr.\n");
+			goto err_unlock;
+		}
+	}
+
+err_unlock:
+	mutex_unlock(&c_node->mem_lock);
+	return ret;
+}
+
+static struct drm_exynos_ipp_mem_node
+		*ipp_get_mem_node(struct drm_device *drm_dev,
+		struct drm_file *file,
+		struct drm_exynos_ipp_cmd_node *c_node,
+		struct drm_exynos_ipp_queue_buf *qbuf)
+{
+	struct drm_exynos_ipp_mem_node *m_node;
+	struct drm_exynos_ipp_buf_info buf_info;
+	void *addr;
+	int i;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	mutex_lock(&c_node->mem_lock);
+
+	m_node = kzalloc(sizeof(*m_node), GFP_KERNEL);
+	if (!m_node) {
+		DRM_ERROR("failed to allocate queue node.\n");
+		goto err_unlock;
+	}
+
+	/* clear base address for error handling */
+	memset(&buf_info, 0x0, sizeof(buf_info));
+
+	/* operations, buffer id */
+	m_node->ops_id = qbuf->ops_id;
+	m_node->prop_id = qbuf->prop_id;
+	m_node->buf_id = qbuf->buf_id;
+
+	DRM_DEBUG_KMS("%s:m_node[0x%x]ops_id[%d]\n", __func__,
+		(int)m_node, qbuf->ops_id);
+	DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]\n", __func__,
+		qbuf->prop_id, m_node->buf_id);
+
+	for_each_ipp_planar(i) {
+		DRM_DEBUG_KMS("%s:i[%d]handle[0x%x]\n", __func__,
+			i, qbuf->handle[i]);
+
+		/* get dma address by handle */
+		if (qbuf->handle[i] != 0) {
+			addr = exynos_drm_gem_get_dma_addr(drm_dev,
+					qbuf->handle[i], file);
+			if (!addr) {
+				DRM_ERROR("failed to get addr.\n");
+				goto err_clear;
+			}
+
+			buf_info.handles[i] = qbuf->handle[i];
+			buf_info.base[i] = *(dma_addr_t *) addr;
+			DRM_DEBUG_KMS("%s:i[%d]base[0x%x]hd[0x%x]\n",
+				__func__, i, buf_info.base[i],
+				(int)buf_info.handles[i]);
+		}
+	}
+
+	m_node->filp = file;
+	m_node->buf_info = buf_info;
+	list_add_tail(&m_node->list, &c_node->mem_list[qbuf->ops_id]);
+
+	mutex_unlock(&c_node->mem_lock);
+	return m_node;
+
+err_clear:
+	kfree(m_node);
+err_unlock:
+	mutex_unlock(&c_node->mem_lock);
+	return ERR_PTR(-EFAULT);
+}
+
+static int ipp_put_mem_node(struct drm_device *drm_dev,
+		struct drm_exynos_ipp_cmd_node *c_node,
+		struct drm_exynos_ipp_mem_node *m_node)
+{
+	int i;
+
+	DRM_DEBUG_KMS("%s:node[0x%x]\n", __func__, (int)m_node);
+
+	if (!m_node) {
+		DRM_ERROR("invalid dequeue node.\n");
+		return -EFAULT;
+	}
+
+	if (list_empty(&m_node->list)) {
+		DRM_ERROR("empty memory node.\n");
+		return -ENOMEM;
+	}
+
+	mutex_lock(&c_node->mem_lock);
+
+	DRM_DEBUG_KMS("%s:ops_id[%d]\n", __func__, m_node->ops_id);
+
+	/* put gem buffer */
+	for_each_ipp_planar(i) {
+		unsigned long handle = m_node->buf_info.handles[i];
+		if (handle)
+			exynos_drm_gem_put_dma_addr(drm_dev, handle,
+							m_node->filp);
+	}
+
+	/* delete list in queue */
+	list_del(&m_node->list);
+	kfree(m_node);
+
+	mutex_unlock(&c_node->mem_lock);
+
+	return 0;
+}
+
+static void ipp_free_event(struct drm_pending_event *event)
+{
+	kfree(event);
+}
+
+static int ipp_get_event(struct drm_device *drm_dev,
+		struct drm_file *file,
+		struct drm_exynos_ipp_cmd_node *c_node,
+		struct drm_exynos_ipp_queue_buf *qbuf)
+{
+	struct drm_exynos_ipp_send_event *e;
+	unsigned long flags;
+
+	DRM_DEBUG_KMS("%s:ops_id[%d]buf_id[%d]\n", __func__,
+		qbuf->ops_id, qbuf->buf_id);
+
+	e = kzalloc(sizeof(*e), GFP_KERNEL);
+
+	if (!e) {
+		DRM_ERROR("failed to allocate event.\n");
+		spin_lock_irqsave(&drm_dev->event_lock, flags);
+		file->event_space += sizeof(e->event);
+		spin_unlock_irqrestore(&drm_dev->event_lock, flags);
+		return -ENOMEM;
+	}
+
+	/* make event */
+	e->event.base.type = DRM_EXYNOS_IPP_EVENT;
+	e->event.base.length = sizeof(e->event);
+	e->event.user_data = qbuf->user_data;
+	e->event.prop_id = qbuf->prop_id;
+	e->event.buf_id[EXYNOS_DRM_OPS_DST] = qbuf->buf_id;
+	e->base.event = &e->event.base;
+	e->base.file_priv = file;
+	e->base.destroy = ipp_free_event;
+	list_add_tail(&e->base.link, &c_node->event_list);
+
+	return 0;
+}
+
+static void ipp_put_event(struct drm_exynos_ipp_cmd_node *c_node,
+		struct drm_exynos_ipp_queue_buf *qbuf)
+{
+	struct drm_exynos_ipp_send_event *e, *te;
+	int count = 0;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (list_empty(&c_node->event_list)) {
+		DRM_DEBUG_KMS("%s:event_list is empty.\n", __func__);
+		return;
+	}
+
+	list_for_each_entry_safe(e, te, &c_node->event_list, base.link) {
+		DRM_DEBUG_KMS("%s:count[%d]e[0x%x]\n",
+			__func__, count++, (int)e);
+
+		/*
+		 * quf == NULL condition means all event deletion.
+		 * stop operations want to delete all event list.
+		 * another case delete only same buf id.
+		 */
+		if (!qbuf) {
+			/* delete list */
+			list_del(&e->base.link);
+			kfree(e);
+		}
+
+		/* compare buffer id */
+		if (qbuf && (qbuf->buf_id ==
+		    e->event.buf_id[EXYNOS_DRM_OPS_DST])) {
+			/* delete list */
+			list_del(&e->base.link);
+			kfree(e);
+			return;
+		}
+	}
+}
+
+void ipp_handle_cmd_work(struct device *dev,
+		struct exynos_drm_ippdrv *ippdrv,
+		struct drm_exynos_ipp_cmd_work *cmd_work,
+		struct drm_exynos_ipp_cmd_node *c_node)
+{
+	struct ipp_context *ctx = get_ipp_context(dev);
+
+	cmd_work->ippdrv = ippdrv;
+	cmd_work->c_node = c_node;
+	queue_work(ctx->cmd_workq, (struct work_struct *)cmd_work);
+}
+
+static int ipp_queue_buf_with_run(struct device *dev,
+		struct drm_exynos_ipp_cmd_node *c_node,
+		struct drm_exynos_ipp_mem_node *m_node,
+		struct drm_exynos_ipp_queue_buf *qbuf)
+{
+	struct exynos_drm_ippdrv *ippdrv;
+	struct drm_exynos_ipp_property *property;
+	struct exynos_drm_ipp_ops *ops;
+	int ret;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	ippdrv = ipp_find_drv_by_handle(qbuf->prop_id);
+	if (IS_ERR_OR_NULL(ippdrv)) {
+		DRM_ERROR("failed to get ipp driver.\n");
+		return -EFAULT;
+	}
+
+	ops = ippdrv->ops[qbuf->ops_id];
+	if (!ops) {
+		DRM_ERROR("failed to get ops.\n");
+		return -EFAULT;
+	}
+
+	property = &c_node->property;
+	if (!property) {
+		DRM_ERROR("invalid property parameter.\n");
+		return -EINVAL;
+	}
+
+	if (c_node->state != IPP_STATE_START) {
+		DRM_DEBUG_KMS("%s:bypass for invalid state.\n" , __func__);
+		return 0;
+	}
+
+	if (!ipp_check_mem_list(c_node)) {
+		DRM_DEBUG_KMS("%s:empty memory.\n", __func__);
+		return 0;
+	}
+
+	/*
+	 * If set destination buffer and enabled clock,
+	 * then m2m operations need start operations at queue_buf
+	 */
+	if (ipp_is_m2m_cmd(property->cmd)) {
+		struct drm_exynos_ipp_cmd_work *cmd_work = c_node->start_work;
+
+		cmd_work->ctrl = IPP_CTRL_PLAY;
+		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
+	} else {
+		ret = ipp_set_mem_node(ippdrv, c_node, m_node);
+		if (ret) {
+			DRM_ERROR("failed to set m node.\n");
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static void ipp_clean_queue_buf(struct drm_device *drm_dev,
+		struct drm_exynos_ipp_cmd_node *c_node,
+		struct drm_exynos_ipp_queue_buf *qbuf)
+{
+	struct drm_exynos_ipp_mem_node *m_node, *tm_node;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!list_empty(&c_node->mem_list[qbuf->ops_id])) {
+		/* delete list */
+		list_for_each_entry_safe(m_node, tm_node,
+			&c_node->mem_list[qbuf->ops_id], list) {
+			if (m_node->buf_id == qbuf->buf_id &&
+			    m_node->ops_id == qbuf->ops_id)
+				ipp_put_mem_node(drm_dev, c_node, m_node);
+		}
+	}
+}
+
+int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void *data,
+		struct drm_file *file)
+{
+	struct drm_exynos_file_private *file_priv = file->driver_priv;
+	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
+	struct device *dev = priv->dev;
+	struct ipp_context *ctx = get_ipp_context(dev);
+	struct drm_exynos_ipp_queue_buf *qbuf = data;
+	struct drm_exynos_ipp_cmd_node *c_node;
+	struct drm_exynos_ipp_mem_node *m_node;
+	int ret;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!qbuf) {
+		DRM_ERROR("invalid buf parameter.\n");
+		return -EINVAL;
+	}
+
+	if (qbuf->ops_id >= EXYNOS_DRM_OPS_MAX) {
+		DRM_ERROR("invalid ops parameter.\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]ops_id[%s]buf_id[%d]buf_type[%d]\n",
+		__func__, qbuf->prop_id, qbuf->ops_id ? "dst" : "src",
+		qbuf->buf_id, qbuf->buf_type);
+
+	/* find command node */
+	c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
+		qbuf->prop_id);
+	if (!c_node) {
+		DRM_ERROR("failed to get command node.\n");
+		return -EFAULT;
+	}
+
+	/* buffer control */
+	switch (qbuf->buf_type) {
+	case IPP_BUF_ENQUEUE:
+		/* get memory node */
+		m_node = ipp_get_mem_node(drm_dev, file, c_node, qbuf);
+		if (IS_ERR_OR_NULL(m_node)) {
+			DRM_ERROR("failed to get m_node.\n");
+			return -EINVAL;
+		}
+
+		/*
+		 * first step get event for destination buffer.
+		 * and second step when M2M case run with destination buffer
+		 * if needed.
+		 */
+		if (qbuf->ops_id == EXYNOS_DRM_OPS_DST) {
+			/* get event for destination buffer */
+			ret = ipp_get_event(drm_dev, file, c_node, qbuf);
+			if (ret) {
+				DRM_ERROR("failed to get event.\n");
+				goto err_clean_node;
+			}
+
+			/*
+			 * M2M case run play control for streaming feature.
+			 * other case set address and waiting.
+			 */
+			ret = ipp_queue_buf_with_run(dev, c_node, m_node, qbuf);
+			if (ret) {
+				DRM_ERROR("failed to run command.\n");
+				goto err_clean_node;
+			}
+		}
+		break;
+	case IPP_BUF_DEQUEUE:
+		mutex_lock(&c_node->cmd_lock);
+
+		/* put event for destination buffer */
+		if (qbuf->ops_id == EXYNOS_DRM_OPS_DST)
+			ipp_put_event(c_node, qbuf);
+
+		ipp_clean_queue_buf(drm_dev, c_node, qbuf);
+
+		mutex_unlock(&c_node->cmd_lock);
+		break;
+	default:
+		DRM_ERROR("invalid buffer control.\n");
+		return -EINVAL;
+	}
+
+	return 0;
+
+err_clean_node:
+	DRM_ERROR("clean memory nodes.\n");
+
+	ipp_clean_queue_buf(drm_dev, c_node, qbuf);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(exynos_drm_ipp_queue_buf);
+
+static bool exynos_drm_ipp_check_valid(struct device *dev,
+		enum drm_exynos_ipp_ctrl ctrl, enum drm_exynos_ipp_state state)
+{
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (ctrl != IPP_CTRL_PLAY) {
+		if (pm_runtime_suspended(dev)) {
+			DRM_ERROR("pm:runtime_suspended.\n");
+			goto err_status;
+		}
+	}
+
+	switch (ctrl) {
+	case IPP_CTRL_PLAY:
+		if (state != IPP_STATE_IDLE)
+			goto err_status;
+		break;
+	case IPP_CTRL_STOP:
+		if (state == IPP_STATE_STOP)
+			goto err_status;
+		break;
+	case IPP_CTRL_PAUSE:
+		if (state != IPP_STATE_START)
+			goto err_status;
+		break;
+	case IPP_CTRL_RESUME:
+		if (state != IPP_STATE_STOP)
+			goto err_status;
+		break;
+	default:
+		DRM_ERROR("invalid state.\n");
+		goto err_status;
+		break;
+	}
+
+	return true;
+
+err_status:
+	DRM_ERROR("invalid status:ctrl[%d]state[%d]\n", ctrl, state);
+	return false;
+}
+
+int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void *data,
+		struct drm_file *file)
+{
+	struct drm_exynos_file_private *file_priv = file->driver_priv;
+	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
+	struct exynos_drm_ippdrv *ippdrv = NULL;
+	struct device *dev = priv->dev;
+	struct ipp_context *ctx = get_ipp_context(dev);
+	struct drm_exynos_ipp_cmd_ctrl *cmd_ctrl = data;
+	struct drm_exynos_ipp_cmd_work *cmd_work;
+	struct drm_exynos_ipp_cmd_node *c_node;
+	int ret = 0;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!ctx) {
+		DRM_ERROR("invalid context.\n");
+		return -EINVAL;
+	}
+
+	if (!cmd_ctrl) {
+		DRM_ERROR("invalid control parameter.\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG_KMS("%s:ctrl[%d]prop_id[%d]\n", __func__,
+		cmd_ctrl->ctrl, cmd_ctrl->prop_id);
+
+	ippdrv = ipp_find_drv_by_handle(cmd_ctrl->prop_id);
+	if (IS_ERR_OR_NULL(ippdrv)) {
+		DRM_ERROR("failed to get ipp driver.\n");
+		return -EINVAL;
+	}
+
+	c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
+		cmd_ctrl->prop_id);
+	if (!c_node) {
+		DRM_ERROR("invalid command node list.\n");
+		return -EINVAL;
+	}
+
+	if (!exynos_drm_ipp_check_valid(ippdrv->dev, cmd_ctrl->ctrl,
+	    c_node->state)) {
+		DRM_ERROR("invalid state.\n");
+		return -EINVAL;
+	}
+
+	switch (cmd_ctrl->ctrl) {
+	case IPP_CTRL_PLAY:
+		if (pm_runtime_suspended(ippdrv->dev))
+			pm_runtime_get_sync(ippdrv->dev);
+		c_node->state = IPP_STATE_START;
+
+		cmd_work = c_node->start_work;
+		cmd_work->ctrl = cmd_ctrl->ctrl;
+		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
+		c_node->state = IPP_STATE_START;
+		break;
+	case IPP_CTRL_STOP:
+		cmd_work = c_node->stop_work;
+		cmd_work->ctrl = cmd_ctrl->ctrl;
+		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
+
+		if (!wait_for_completion_timeout(&c_node->stop_complete,
+		    msecs_to_jiffies(300))) {
+			DRM_ERROR("timeout stop:prop_id[%d]\n",
+				c_node->property.prop_id);
+		}
+
+		c_node->state = IPP_STATE_STOP;
+		ippdrv->dedicated = false;
+		ipp_clean_cmd_node(c_node);
+
+		if (list_empty(&ippdrv->cmd_list))
+			pm_runtime_put_sync(ippdrv->dev);
+		break;
+	case IPP_CTRL_PAUSE:
+		cmd_work = c_node->stop_work;
+		cmd_work->ctrl = cmd_ctrl->ctrl;
+		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
+
+		if (!wait_for_completion_timeout(&c_node->stop_complete,
+		    msecs_to_jiffies(200))) {
+			DRM_ERROR("timeout stop:prop_id[%d]\n",
+				c_node->property.prop_id);
+		}
+
+		c_node->state = IPP_STATE_STOP;
+		break;
+	case IPP_CTRL_RESUME:
+		c_node->state = IPP_STATE_START;
+		cmd_work = c_node->start_work;
+		cmd_work->ctrl = cmd_ctrl->ctrl;
+		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
+		break;
+	default:
+		/* ToDo: expand ctrl operation */
+		DRM_ERROR("could not support this state currently.\n");
+		goto err_clear;
+	}
+
+	DRM_DEBUG_KMS("%s:done ctrl[%d]prop_id[%d]\n", __func__,
+		cmd_ctrl->ctrl, cmd_ctrl->prop_id);
+
+	return 0;
+
+err_clear:
+	return ret;
+}
+EXPORT_SYMBOL_GPL(exynos_drm_ipp_cmd_ctrl);
+
+int exynos_drm_ippnb_register(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(
+			&exynos_drm_ippnb_list, nb);
+}
+EXPORT_SYMBOL_GPL(exynos_drm_ippnb_register);
+
+int exynos_drm_ippnb_unregister(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_unregister(
+			&exynos_drm_ippnb_list, nb);
+}
+EXPORT_SYMBOL_GPL(exynos_drm_ippnb_unregister);
+
+int exynos_drm_ippnb_send_event(unsigned long val, void *v)
+{
+	return blocking_notifier_call_chain(
+			&exynos_drm_ippnb_list, val, v);
+}
+EXPORT_SYMBOL_GPL(exynos_drm_ippnb_send_event);
+
+static int ipp_set_property(struct exynos_drm_ippdrv *ippdrv,
+		struct drm_exynos_ipp_property *property)
+{
+	struct exynos_drm_ipp_ops *ops = NULL;
+	int ret, i, swap = 0;
+
+	if (!property) {
+		DRM_ERROR("invalid property parameter.\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
+
+	/* reset h/w block */
+	if (ippdrv->reset &&
+	    ippdrv->reset(ippdrv->dev)) {
+		DRM_ERROR("failed to reset.\n");
+		return -EINVAL;
+	}
+
+	/* set source,destination operations */
+	for_each_ipp_ops(i) {
+		/* ToDo: integrate property and config */
+		struct drm_exynos_ipp_config *config =
+			&property->config[i];
+
+		ops = ippdrv->ops[i];
+		if (!ops || !config) {
+			DRM_ERROR("not support ops and config.\n");
+			return -EINVAL;
+		}
+
+		/* set format */
+		if (ops->set_fmt) {
+			ret = ops->set_fmt(ippdrv->dev, config->fmt);
+			if (ret) {
+				DRM_ERROR("not support format.\n");
+				return ret;
+			}
+		}
+
+		/* set transform for rotation, flip */
+		if (ops->set_transf) {
+			swap = ops->set_transf(ippdrv->dev, config->degree,
+				config->flip);
+			if (swap < 0) {
+				DRM_ERROR("not support tranf.\n");
+				return -EINVAL;
+			}
+		}
+
+		/* set size */
+		if (ops->set_size) {
+			ret = ops->set_size(ippdrv->dev, swap, &config->pos,
+				&config->sz);
+			if (ret) {
+				DRM_ERROR("not support size.\n");
+				return ret;
+			}
+		}
+	}
+
+	return 0;
+}
+
+static int ipp_start_property(struct exynos_drm_ippdrv *ippdrv,
+		struct drm_exynos_ipp_cmd_node *c_node)
+{
+	struct drm_exynos_ipp_mem_node *m_node;
+	struct drm_exynos_ipp_property *property = &c_node->property;
+	struct list_head *head;
+	int ret, i;
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
+
+	/* store command info in ippdrv */
+	ippdrv->cmd = c_node;
+
+	if (!ipp_check_mem_list(c_node)) {
+		DRM_DEBUG_KMS("%s:empty memory.\n", __func__);
+		return -ENOMEM;
+	}
+
+	/* set current property in ippdrv */
+	ret = ipp_set_property(ippdrv, property);
+	if (ret) {
+		DRM_ERROR("failed to set property.\n");
+		ippdrv->cmd = NULL;
+		return ret;
+	}
+
+	/* check command */
+	switch (property->cmd) {
+	case IPP_CMD_M2M:
+		for_each_ipp_ops(i) {
+			/* source/destination memory list */
+			head = &c_node->mem_list[i];
+
+			m_node = list_first_entry(head,
+				struct drm_exynos_ipp_mem_node, list);
+			if (!m_node) {
+				DRM_ERROR("failed to get node.\n");
+				ret = -EFAULT;
+				return ret;
+			}
+
+			DRM_DEBUG_KMS("%s:m_node[0x%x]\n",
+				__func__, (int)m_node);
+
+			ret = ipp_set_mem_node(ippdrv, c_node, m_node);
+			if (ret) {
+				DRM_ERROR("failed to set m node.\n");
+				return ret;
+			}
+		}
+		break;
+	case IPP_CMD_WB:
+		/* destination memory list */
+		head = &c_node->mem_list[EXYNOS_DRM_OPS_DST];
+
+		list_for_each_entry(m_node, head, list) {
+			ret = ipp_set_mem_node(ippdrv, c_node, m_node);
+			if (ret) {
+				DRM_ERROR("failed to set m node.\n");
+				return ret;
+			}
+		}
+		break;
+	case IPP_CMD_OUTPUT:
+		/* source memory list */
+		head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC];
+
+		list_for_each_entry(m_node, head, list) {
+			ret = ipp_set_mem_node(ippdrv, c_node, m_node);
+			if (ret) {
+				DRM_ERROR("failed to set m node.\n");
+				return ret;
+			}
+		}
+		break;
+	default:
+		DRM_ERROR("invalid operations.\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, property->cmd);
+
+	/* start operations */
+	if (ippdrv->start) {
+		ret = ippdrv->start(ippdrv->dev, property->cmd);
+		if (ret) {
+			DRM_ERROR("failed to start ops.\n");
+			return ret;
+		}
+	}
+
+	return 0;
+}
+
+static int ipp_stop_property(struct drm_device *drm_dev,
+		struct exynos_drm_ippdrv *ippdrv,
+		struct drm_exynos_ipp_cmd_node *c_node)
+{
+	struct drm_exynos_ipp_mem_node *m_node, *tm_node;
+	struct drm_exynos_ipp_property *property = &c_node->property;
+	struct list_head *head;
+	int ret = 0, i;
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
+
+	/* put event */
+	ipp_put_event(c_node, NULL);
+
+	/* check command */
+	switch (property->cmd) {
+	case IPP_CMD_M2M:
+		for_each_ipp_ops(i) {
+			/* source/destination memory list */
+			head = &c_node->mem_list[i];
+
+			if (list_empty(head)) {
+				DRM_DEBUG_KMS("%s:mem_list is empty.\n",
+					__func__);
+				break;
+			}
+
+			list_for_each_entry_safe(m_node, tm_node,
+				head, list) {
+				ret = ipp_put_mem_node(drm_dev, c_node,
+					m_node);
+				if (ret) {
+					DRM_ERROR("failed to put m_node.\n");
+					goto err_clear;
+				}
+			}
+		}
+		break;
+	case IPP_CMD_WB:
+		/* destination memory list */
+		head = &c_node->mem_list[EXYNOS_DRM_OPS_DST];
+
+		if (list_empty(head)) {
+			DRM_DEBUG_KMS("%s:mem_list is empty.\n", __func__);
+			break;
+		}
+
+		list_for_each_entry_safe(m_node, tm_node, head, list) {
+			ret = ipp_put_mem_node(drm_dev, c_node, m_node);
+			if (ret) {
+				DRM_ERROR("failed to put m_node.\n");
+				goto err_clear;
+			}
+		}
+		break;
+	case IPP_CMD_OUTPUT:
+		/* source memory list */
+		head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC];
+
+		if (list_empty(head)) {
+			DRM_DEBUG_KMS("%s:mem_list is empty.\n", __func__);
+			break;
+		}
+
+		list_for_each_entry_safe(m_node, tm_node, head, list) {
+			ret = ipp_put_mem_node(drm_dev, c_node, m_node);
+			if (ret) {
+				DRM_ERROR("failed to put m_node.\n");
+				goto err_clear;
+			}
+		}
+		break;
+	default:
+		DRM_ERROR("invalid operations.\n");
+		ret = -EINVAL;
+		goto err_clear;
+	}
+
+err_clear:
+	/* stop operations */
+	if (ippdrv->stop)
+		ippdrv->stop(ippdrv->dev, property->cmd);
+
+	return ret;
+}
+
+void ipp_sched_cmd(struct work_struct *work)
+{
+	struct drm_exynos_ipp_cmd_work *cmd_work =
+		(struct drm_exynos_ipp_cmd_work *)work;
+	struct exynos_drm_ippdrv *ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node;
+	struct drm_exynos_ipp_property *property;
+	int ret;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	ippdrv = cmd_work->ippdrv;
+	if (!ippdrv) {
+		DRM_ERROR("invalid ippdrv list.\n");
+		return;
+	}
+
+	c_node = cmd_work->c_node;
+	if (!c_node) {
+		DRM_ERROR("invalid command node list.\n");
+		return;
+	}
+
+	mutex_lock(&c_node->cmd_lock);
+
+	property = &c_node->property;
+	if (!property) {
+		DRM_ERROR("failed to get property:prop_id[%d]\n",
+			c_node->property.prop_id);
+		goto err_unlock;
+	}
+
+	switch (cmd_work->ctrl) {
+	case IPP_CTRL_PLAY:
+	case IPP_CTRL_RESUME:
+		ret = ipp_start_property(ippdrv, c_node);
+		if (ret) {
+			DRM_ERROR("failed to start property:prop_id[%d]\n",
+				c_node->property.prop_id);
+			goto err_unlock;
+		}
+
+		/*
+		 * M2M case supports wait_completion of transfer.
+		 * because M2M case supports single unit operation
+		 * with multiple queue.
+		 * M2M need to wait completion of data transfer.
+		 */
+		if (ipp_is_m2m_cmd(property->cmd)) {
+			if (!wait_for_completion_timeout
+			    (&c_node->start_complete, msecs_to_jiffies(200))) {
+				DRM_ERROR("timeout event:prop_id[%d]\n",
+					c_node->property.prop_id);
+				goto err_unlock;
+			}
+		}
+		break;
+	case IPP_CTRL_STOP:
+	case IPP_CTRL_PAUSE:
+		ret = ipp_stop_property(ippdrv->drm_dev, ippdrv,
+			c_node);
+		if (ret) {
+			DRM_ERROR("failed to stop property.\n");
+			goto err_unlock;
+		}
+
+		complete(&c_node->stop_complete);
+		break;
+	default:
+		DRM_ERROR("unknown control type\n");
+		break;
+	}
+
+	DRM_DEBUG_KMS("%s:ctrl[%d] done.\n", __func__, cmd_work->ctrl);
+
+err_unlock:
+	mutex_unlock(&c_node->cmd_lock);
+}
+
+static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv,
+		struct drm_exynos_ipp_cmd_node *c_node, int *buf_id)
+{
+	struct drm_device *drm_dev = ippdrv->drm_dev;
+	struct drm_exynos_ipp_property *property = &c_node->property;
+	struct drm_exynos_ipp_mem_node *m_node;
+	struct drm_exynos_ipp_queue_buf qbuf;
+	struct drm_exynos_ipp_send_event *e;
+	struct list_head *head;
+	struct timeval now;
+	unsigned long flags;
+	u32 tbuf_id[EXYNOS_DRM_OPS_MAX] = {0, };
+	int ret, i;
+
+	for_each_ipp_ops(i)
+		DRM_DEBUG_KMS("%s:%s buf_id[%d]\n", __func__,
+			i ? "dst" : "src", buf_id[i]);
+
+	if (!drm_dev) {
+		DRM_ERROR("failed to get drm_dev.\n");
+		return -EINVAL;
+	}
+
+	if (!property) {
+		DRM_ERROR("failed to get property.\n");
+		return -EINVAL;
+	}
+
+	if (list_empty(&c_node->event_list)) {
+		DRM_DEBUG_KMS("%s:event list is empty.\n", __func__);
+		return 0;
+	}
+
+	if (!ipp_check_mem_list(c_node)) {
+		DRM_DEBUG_KMS("%s:empty memory.\n", __func__);
+		return 0;
+	}
+
+	/* check command */
+	switch (property->cmd) {
+	case IPP_CMD_M2M:
+		for_each_ipp_ops(i) {
+			/* source/destination memory list */
+			head = &c_node->mem_list[i];
+
+			m_node = list_first_entry(head,
+				struct drm_exynos_ipp_mem_node, list);
+			if (!m_node) {
+				DRM_ERROR("empty memory node.\n");
+				return -ENOMEM;
+			}
+
+			tbuf_id[i] = m_node->buf_id;
+			DRM_DEBUG_KMS("%s:%s buf_id[%d]\n", __func__,
+				i ? "dst" : "src", tbuf_id[i]);
+
+			ret = ipp_put_mem_node(drm_dev, c_node, m_node);
+			if (ret)
+				DRM_ERROR("failed to put m_node.\n");
+		}
+		break;
+	case IPP_CMD_WB:
+		/* clear buf for finding */
+		memset(&qbuf, 0x0, sizeof(qbuf));
+		qbuf.ops_id = EXYNOS_DRM_OPS_DST;
+		qbuf.buf_id = buf_id[EXYNOS_DRM_OPS_DST];
+
+		/* get memory node entry */
+		m_node = ipp_find_mem_node(c_node, &qbuf);
+		if (!m_node) {
+			DRM_ERROR("empty memory node.\n");
+			return -ENOMEM;
+		}
+
+		tbuf_id[EXYNOS_DRM_OPS_DST] = m_node->buf_id;
+
+		ret = ipp_put_mem_node(drm_dev, c_node, m_node);
+		if (ret)
+			DRM_ERROR("failed to put m_node.\n");
+		break;
+	case IPP_CMD_OUTPUT:
+		/* source memory list */
+		head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC];
+
+		m_node = list_first_entry(head,
+			struct drm_exynos_ipp_mem_node, list);
+		if (!m_node) {
+			DRM_ERROR("empty memory node.\n");
+			return -ENOMEM;
+		}
+
+		tbuf_id[EXYNOS_DRM_OPS_SRC] = m_node->buf_id;
+
+		ret = ipp_put_mem_node(drm_dev, c_node, m_node);
+		if (ret)
+			DRM_ERROR("failed to put m_node.\n");
+		break;
+	default:
+		DRM_ERROR("invalid operations.\n");
+		return -EINVAL;
+	}
+
+	/* ToDo: Fix buffer id */
+	if (tbuf_id[EXYNOS_DRM_OPS_DST] != buf_id[EXYNOS_DRM_OPS_DST])
+		DRM_ERROR("failed to match buf_id[%d %d]prop_id[%d]\n",
+			tbuf_id[1], buf_id[1], property->prop_id);
+
+	/*
+	 * command node have event list of destination buffer
+	 * If destination buffer enqueue to mem list,
+	 * then we make event and link to event list tail.
+	 * so, we get first event for first enqueued buffer.
+	 */
+	e = list_first_entry(&c_node->event_list,
+		struct drm_exynos_ipp_send_event, base.link);
+
+	if (!e) {
+		DRM_ERROR("empty event.\n");
+		return -EINVAL;
+	}
+
+	do_gettimeofday(&now);
+	DRM_DEBUG_KMS("%s:tv_sec[%ld]tv_usec[%ld]\n"
+		, __func__, now.tv_sec, now.tv_usec);
+	e->event.tv_sec = now.tv_sec;
+	e->event.tv_usec = now.tv_usec;
+	e->event.prop_id = property->prop_id;
+
+	/* set buffer id about source destination */
+	for_each_ipp_ops(i)
+		e->event.buf_id[i] = tbuf_id[i];
+
+	/* ToDo: compare index. If needed */
+
+	spin_lock_irqsave(&drm_dev->event_lock, flags);
+	list_move_tail(&e->base.link, &e->base.file_priv->event_list);
+	wake_up_interruptible(&e->base.file_priv->event_wait);
+	spin_unlock_irqrestore(&drm_dev->event_lock, flags);
+
+	DRM_DEBUG_KMS("%s:done cmd[%d]prop_id[%d]buf_id[%d]\n", __func__,
+		property->cmd, property->prop_id, tbuf_id[EXYNOS_DRM_OPS_DST]);
+
+	return 0;
+}
+
+void ipp_sched_event(struct work_struct *work)
+{
+	struct drm_exynos_ipp_event_work *event_work =
+		(struct drm_exynos_ipp_event_work *)work;
+	struct exynos_drm_ippdrv *ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node;
+	int ret;
+
+	if (!event_work) {
+		DRM_ERROR("failed to get event_work.\n");
+		return;
+	}
+
+	DRM_DEBUG_KMS("%s:buf_id[%d]\n", __func__,
+		event_work->buf_id[EXYNOS_DRM_OPS_DST]);
+
+	ippdrv = event_work->ippdrv;
+	if (!ippdrv) {
+		DRM_ERROR("failed to get ipp driver.\n");
+		return;
+	}
+
+	c_node = ippdrv->cmd;
+	if (!c_node) {
+		DRM_ERROR("failed to get command node.\n");
+		return;
+	}
+
+	/*
+	 * IPP supports command thread, event thread synchronization.
+	 * If IPP close immediately from user land, then IPP make
+	 * synchronization with command thread, so make complete event.
+	 * or going out operations.
+	 */
+	if (c_node->state != IPP_STATE_START) {
+		DRM_DEBUG_KMS("%s:bypass state[%d]prop_id[%d]\n",
+			__func__, c_node->state, c_node->property.prop_id);
+		goto err_completion;
+	}
+
+	mutex_lock(&c_node->event_lock);
+
+	ret = ipp_send_event(ippdrv, c_node, event_work->buf_id);
+	if (ret) {
+		DRM_ERROR("failed to send event.\n");
+		goto err_completion;
+	}
+
+err_completion:
+	if (ipp_is_m2m_cmd(c_node->property.cmd))
+		complete(&c_node->start_complete);
+
+	mutex_unlock(&c_node->event_lock);
+}
+
+static int ipp_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
+{
+	struct ipp_context *ctx = get_ipp_context(dev);
+	struct exynos_drm_ippdrv *ippdrv;
+	int ret, count = 0;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	/* get ipp driver entry */
+	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
+		ippdrv->drm_dev = drm_dev;
+
+		ret = ipp_create_id(&ctx->ipp_idr, &ctx->ipp_lock, ippdrv,
+			&ippdrv->ipp_id);
+		if (ret) {
+			DRM_ERROR("failed to create id.\n");
+			goto err_idr;
+		}
+
+		DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]ipp_id[%d]\n", __func__,
+			count++, (int)ippdrv, ippdrv->ipp_id);
+
+		if (ippdrv->ipp_id == 0) {
+			DRM_ERROR("failed to get ipp_id[%d]\n",
+				ippdrv->ipp_id);
+			goto err_idr;
+		}
+
+		/* store parent device for node */
+		ippdrv->parent_dev = dev;
+
+		/* store event work queue and handler */
+		ippdrv->event_workq = ctx->event_workq;
+		ippdrv->sched_event = ipp_sched_event;
+		INIT_LIST_HEAD(&ippdrv->cmd_list);
+	}
+
+	return 0;
+
+err_idr:
+	idr_remove_all(&ctx->ipp_idr);
+	idr_remove_all(&ctx->prop_idr);
+	idr_destroy(&ctx->ipp_idr);
+	idr_destroy(&ctx->prop_idr);
+	return ret;
+}
+
+static void ipp_subdrv_remove(struct drm_device *drm_dev, struct device *dev)
+{
+	struct exynos_drm_ippdrv *ippdrv;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	/* get ipp driver entry */
+	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
+		ippdrv->drm_dev = NULL;
+		exynos_drm_ippdrv_unregister(ippdrv);
+	}
+
+	/* ToDo: free notifier callback list if needed */
+}
+
+static int ipp_subdrv_open(struct drm_device *drm_dev, struct device *dev,
+		struct drm_file *file)
+{
+	struct drm_exynos_file_private *file_priv = file->driver_priv;
+	struct exynos_drm_ipp_private *priv;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	/* ToDo: multi device open */
+
+	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+	if (!priv) {
+		DRM_ERROR("failed to allocate priv.\n");
+		return -ENOMEM;
+	}
+	priv->dev = dev;
+	file_priv->ipp_priv = priv;
+
+	INIT_LIST_HEAD(&priv->event_list);
+
+	DRM_DEBUG_KMS("%s:done priv[0x%x]\n", __func__, (int)priv);
+
+	return 0;
+}
+
+static void ipp_subdrv_close(struct drm_device *drm_dev, struct device *dev,
+		struct drm_file *file)
+{
+	struct drm_exynos_file_private *file_priv = file->driver_priv;
+	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
+	struct exynos_drm_ippdrv *ippdrv = NULL;
+	struct drm_exynos_ipp_cmd_node *c_node, *tc_node;
+	int count = 0;
+
+	DRM_DEBUG_KMS("%s:for priv[0x%x]\n", __func__, (int)priv);
+
+	if (list_empty(&exynos_drm_ippdrv_list)) {
+		DRM_DEBUG_KMS("%s:ippdrv_list is empty.\n", __func__);
+		goto err_clear;
+	}
+
+	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
+		if (list_empty(&ippdrv->cmd_list))
+			continue;
+
+		list_for_each_entry_safe(c_node, tc_node,
+			&ippdrv->cmd_list, list) {
+			DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]\n",
+				__func__, count++, (int)ippdrv);
+
+			if (c_node->priv == priv) {
+				/*
+				 * userland goto unnormal state. process killed.
+				 * and close the file.
+				 * so, IPP didn't called stop cmd ctrl.
+				 * so, we are make stop operation in this state.
+				 */
+				if (c_node->state == IPP_STATE_START) {
+					ipp_stop_property(drm_dev, ippdrv,
+						c_node);
+					c_node->state = IPP_STATE_STOP;
+				}
+
+				ippdrv->dedicated = false;
+				ipp_clean_cmd_node(c_node);
+				if (list_empty(&ippdrv->cmd_list))
+					pm_runtime_put_sync(ippdrv->dev);
+			}
+		}
+	}
+
+err_clear:
+	kfree(priv);
+	return;
+}
+
+static int __devinit ipp_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct ipp_context *ctx;
+	struct exynos_drm_subdrv *subdrv;
+	int ret;
+
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	mutex_init(&ctx->ipp_lock);
+	mutex_init(&ctx->prop_lock);
+
+	idr_init(&ctx->ipp_idr);
+	idr_init(&ctx->prop_idr);
+
+	/*
+	 * create single thread for ipp event
+	 * IPP supports event thread for IPP drivers.
+	 * IPP driver send event_work to this thread.
+	 * and IPP event thread send event to user process.
+	 */
+	ctx->event_workq = create_singlethread_workqueue("ipp_event");
+	if (!ctx->event_workq) {
+		dev_err(dev, "failed to create event workqueue\n");
+		ret = -EINVAL;
+		goto err_clear;
+	}
+
+	/*
+	 * create single thread for ipp command
+	 * IPP supports command thread for user process.
+	 * user process make command node using set property ioctl.
+	 * and make start_work and send this work to command thread.
+	 * and then this command thread start property.
+	 */
+	ctx->cmd_workq = create_singlethread_workqueue("ipp_cmd");
+	if (!ctx->cmd_workq) {
+		dev_err(dev, "failed to create cmd workqueue\n");
+		ret = -EINVAL;
+		goto err_event_workq;
+	}
+
+	/* set sub driver informations */
+	subdrv = &ctx->subdrv;
+	subdrv->dev = dev;
+	subdrv->probe = ipp_subdrv_probe;
+	subdrv->remove = ipp_subdrv_remove;
+	subdrv->open = ipp_subdrv_open;
+	subdrv->close = ipp_subdrv_close;
+
+	platform_set_drvdata(pdev, ctx);
+
+	ret = exynos_drm_subdrv_register(subdrv);
+	if (ret < 0) {
+		DRM_ERROR("failed to register drm ipp device.\n");
+		goto err_cmd_workq;
+	}
+
+	dev_info(&pdev->dev, "drm ipp registered successfully.\n");
+
+	return 0;
+
+err_cmd_workq:
+	destroy_workqueue(ctx->cmd_workq);
+err_event_workq:
+	destroy_workqueue(ctx->event_workq);
+err_clear:
+	kfree(ctx);
+	return ret;
+}
+
+static int __devexit ipp_remove(struct platform_device *pdev)
+{
+	struct ipp_context *ctx = platform_get_drvdata(pdev);
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	/* unregister sub driver */
+	exynos_drm_subdrv_unregister(&ctx->subdrv);
+
+	/* remove,destroy ipp idr */
+	idr_remove_all(&ctx->ipp_idr);
+	idr_remove_all(&ctx->prop_idr);
+	idr_destroy(&ctx->ipp_idr);
+	idr_destroy(&ctx->prop_idr);
+
+	mutex_destroy(&ctx->ipp_lock);
+	mutex_destroy(&ctx->prop_lock);
+
+	/* destroy command, event work queue */
+	destroy_workqueue(ctx->cmd_workq);
+	destroy_workqueue(ctx->event_workq);
+
+	kfree(ctx);
+
+	return 0;
+}
+
+static int ipp_power_ctrl(struct ipp_context *ctx, bool enable)
+{
+	/* ToDo: Need to implement power and sysmmu ctrl. */
+	DRM_DEBUG_KMS("%s:enable[%d]\n", __func__, enable);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int ipp_suspend(struct device *dev)
+{
+	struct ipp_context *ctx = get_ipp_context(dev);
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (pm_runtime_suspended(dev))
+		return 0;
+
+	return ipp_power_ctrl(ctx, false);
+}
+
+static int ipp_resume(struct device *dev)
+{
+	struct ipp_context *ctx = get_ipp_context(dev);
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!pm_runtime_suspended(dev))
+		return ipp_power_ctrl(ctx, true);
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PM_RUNTIME
+static int ipp_runtime_suspend(struct device *dev)
+{
+	struct ipp_context *ctx = get_ipp_context(dev);
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	return ipp_power_ctrl(ctx, false);
+}
+
+static int ipp_runtime_resume(struct device *dev)
+{
+	struct ipp_context *ctx = get_ipp_context(dev);
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	return ipp_power_ctrl(ctx, true);
+}
+#endif
+
+static const struct dev_pm_ops ipp_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(ipp_suspend, ipp_resume)
+	SET_RUNTIME_PM_OPS(ipp_runtime_suspend, ipp_runtime_resume, NULL)
+};
+
+struct platform_driver ipp_driver = {
+	.probe		= ipp_probe,
+	.remove		= __devexit_p(ipp_remove),
+	.driver		= {
+		.name	= "exynos-drm-ipp",
+		.owner	= THIS_MODULE,
+		.pm	= &ipp_pm_ops,
+	},
+};
+
diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.h b/drivers/gpu/drm/exynos/exynos_drm_ipp.h
new file mode 100644
index 0000000..baab1f0
--- /dev/null
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.h
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Authors:
+ *	Eunchul Kim <chulspro.kim@samsung.com>
+ *	Jinyoung Jeon <jy0.jeon@samsung.com>
+ *	Sangmin Lee <lsmin.lee@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _EXYNOS_DRM_IPP_H_
+#define _EXYNOS_DRM_IPP_H_
+
+#define for_each_ipp_ops(pos)	\
+	for (pos = 0; pos < EXYNOS_DRM_OPS_MAX; pos++)
+#define for_each_ipp_planar(pos)	\
+	for (pos = 0; pos < EXYNOS_DRM_PLANAR_MAX; pos++)
+
+#define IPP_GET_LCD_WIDTH	_IOR('F', 302, int)
+#define IPP_GET_LCD_HEIGHT	_IOR('F', 303, int)
+#define IPP_SET_WRITEBACK	_IOW('F', 304, u32)
+
+/* definition of state */
+enum drm_exynos_ipp_state {
+	IPP_STATE_IDLE,
+	IPP_STATE_START,
+	IPP_STATE_STOP,
+};
+
+/*
+ * A structure of command work information.
+ * @work: work structure.
+ * @ippdrv: current work ippdrv.
+ * @c_node: command node information.
+ * @ctrl: command control.
+ */
+struct drm_exynos_ipp_cmd_work {
+	struct work_struct	work;
+	struct exynos_drm_ippdrv	*ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node;
+	enum drm_exynos_ipp_ctrl	ctrl;
+};
+
+/*
+ * A structure of command node.
+ *
+ * @priv: IPP private infomation.
+ * @list: list head to command queue information.
+ * @event_list: list head of event.
+ * @mem_list: list head to source,destination memory queue information.
+ * @cmd_lock: lock for synchronization of access to ioctl.
+ * @mem_lock: lock for synchronization of access to memory nodes.
+ * @event_lock: lock for synchronization of access to scheduled event.
+ * @start_complete: completion of start of command.
+ * @stop_complete: completion of stop of command.
+ * @property: property information.
+ * @start_work: start command work structure.
+ * @stop_work: stop command work structure.
+ * @event_work: event work structure.
+ * @state: state of command node.
+ */
+struct drm_exynos_ipp_cmd_node {
+	struct exynos_drm_ipp_private *priv;
+	struct list_head	list;
+	struct list_head	event_list;
+	struct list_head	mem_list[EXYNOS_DRM_OPS_MAX];
+	struct mutex	cmd_lock;
+	struct mutex	mem_lock;
+	struct mutex	event_lock;
+	struct completion	start_complete;
+	struct completion	stop_complete;
+	struct drm_exynos_ipp_property	property;
+	struct drm_exynos_ipp_cmd_work *start_work;
+	struct drm_exynos_ipp_cmd_work *stop_work;
+	struct drm_exynos_ipp_event_work *event_work;
+	enum drm_exynos_ipp_state	state;
+};
+
+/*
+ * A structure of buffer information.
+ *
+ * @gem_objs: Y, Cb, Cr each gem object.
+ * @base: Y, Cb, Cr each planar address.
+ */
+struct drm_exynos_ipp_buf_info {
+	unsigned long	handles[EXYNOS_DRM_PLANAR_MAX];
+	dma_addr_t	base[EXYNOS_DRM_PLANAR_MAX];
+};
+
+/*
+ * A structure of wb setting infomation.
+ *
+ * @enable: enable flag for wb.
+ * @refresh: HZ of the refresh rate.
+ */
+struct drm_exynos_ipp_set_wb {
+	__u32	enable;
+	__u32	refresh;
+};
+
+/*
+ * A structure of event work information.
+ *
+ * @work: work structure.
+ * @ippdrv: current work ippdrv.
+ * @buf_id: id of src, dst buffer.
+ */
+struct drm_exynos_ipp_event_work {
+	struct work_struct	work;
+	struct exynos_drm_ippdrv *ippdrv;
+	u32	buf_id[EXYNOS_DRM_OPS_MAX];
+};
+
+/*
+ * A structure of source,destination operations.
+ *
+ * @set_fmt: set format of image.
+ * @set_transf: set transform(rotations, flip).
+ * @set_size: set size of region.
+ * @set_addr: set address for dma.
+ */
+struct exynos_drm_ipp_ops {
+	int (*set_fmt)(struct device *dev, u32 fmt);
+	int (*set_transf)(struct device *dev,
+		enum drm_exynos_degree degree,
+		enum drm_exynos_flip flip);
+	int (*set_size)(struct device *dev, int swap,
+		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz);
+	int (*set_addr)(struct device *dev,
+			 struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
+		enum drm_exynos_ipp_buf_type buf_type);
+};
+
+/*
+ * A structure of ipp driver.
+ *
+ * @drv_list: list head for registed sub driver information.
+ * @parent_dev: parent device information.
+ * @dev: platform device.
+ * @drm_dev: drm device.
+ * @ipp_id: id of ipp driver.
+ * @dedicated: dedicated ipp device.
+ * @ops: source, destination operations.
+ * @event_workq: event work queue.
+ * @cmd: current command information.
+ * @cmd_list: list head for command information.
+ * @prop_list: property informations of current ipp driver.
+ * @check_property: check property about format, size, buffer.
+ * @reset: reset ipp block.
+ * @start: ipp each device start.
+ * @stop: ipp each device stop.
+ * @sched_event: work schedule handler.
+ */
+struct exynos_drm_ippdrv {
+	struct list_head	drv_list;
+	struct device	*parent_dev;
+	struct device	*dev;
+	struct drm_device	*drm_dev;
+	u32	ipp_id;
+	bool	dedicated;
+	struct exynos_drm_ipp_ops	*ops[EXYNOS_DRM_OPS_MAX];
+	struct workqueue_struct	*event_workq;
+	struct drm_exynos_ipp_cmd_node *cmd;
+	struct list_head	cmd_list;
+	struct drm_exynos_ipp_prop_list *prop_list;
+
+	int (*check_property)(struct device *dev,
+		struct drm_exynos_ipp_property *property);
+	int (*reset)(struct device *dev);
+	int (*start)(struct device *dev, enum drm_exynos_ipp_cmd cmd);
+	void (*stop)(struct device *dev, enum drm_exynos_ipp_cmd cmd);
+	void (*sched_event)(struct work_struct *work);
+};
+
+#ifdef CONFIG_DRM_EXYNOS_IPP
+extern int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv *ippdrv);
+extern int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv *ippdrv);
+extern int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void *data,
+					 struct drm_file *file);
+extern int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
+					 struct drm_file *file);
+extern int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void *data,
+					 struct drm_file *file);
+extern int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void *data,
+					 struct drm_file *file);
+extern int exynos_drm_ippnb_register(struct notifier_block *nb);
+extern int exynos_drm_ippnb_unregister(struct notifier_block *nb);
+extern int exynos_drm_ippnb_send_event(unsigned long val, void *v);
+extern void ipp_sched_cmd(struct work_struct *work);
+extern void ipp_sched_event(struct work_struct *work);
+
+#else
+static inline int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv *ippdrv)
+{
+	return -ENODEV;
+}
+
+static inline int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv *ippdrv)
+{
+	return -ENODEV;
+}
+
+static inline int exynos_drm_ipp_get_property(struct drm_device *drm_dev,
+						void *data,
+						struct drm_file *file_priv)
+{
+	return -ENOTTY;
+}
+
+static inline int exynos_drm_ipp_set_property(struct drm_device *drm_dev,
+						void *data,
+						struct drm_file *file_priv)
+{
+	return -ENOTTY;
+}
+
+static inline int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev,
+						void *data,
+						struct drm_file *file)
+{
+	return -ENOTTY;
+}
+
+static inline int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev,
+						void *data,
+						struct drm_file *file)
+{
+	return -ENOTTY;
+}
+
+static inline int exynos_drm_ippnb_register(struct notifier_block *nb)
+{
+	return -ENODEV;
+}
+
+static inline int exynos_drm_ippnb_unregister(struct notifier_block *nb)
+{
+	return -ENODEV;
+}
+
+static inline int exynos_drm_ippnb_send_event(unsigned long val, void *v)
+{
+	return -ENOTTY;
+}
+#endif
+
+#endif /* _EXYNOS_DRM_IPP_H_ */
+
diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
index c0494d5..82772d7 100644
--- a/include/uapi/drm/exynos_drm.h
+++ b/include/uapi/drm/exynos_drm.h
@@ -154,6 +154,170 @@ struct drm_exynos_g2d_exec {
 	__u64					async;
 };
 
+enum drm_exynos_ops_id {
+	EXYNOS_DRM_OPS_SRC,
+	EXYNOS_DRM_OPS_DST,
+	EXYNOS_DRM_OPS_MAX,
+};
+
+struct drm_exynos_sz {
+	__u32	hsize;
+	__u32	vsize;
+};
+
+struct drm_exynos_pos {
+	__u32	x;
+	__u32	y;
+	__u32	w;
+	__u32	h;
+};
+
+enum drm_exynos_flip {
+	EXYNOS_DRM_FLIP_NONE = (0 << 0),
+	EXYNOS_DRM_FLIP_VERTICAL = (1 << 0),
+	EXYNOS_DRM_FLIP_HORIZONTAL = (1 << 1),
+};
+
+enum drm_exynos_degree {
+	EXYNOS_DRM_DEGREE_0,
+	EXYNOS_DRM_DEGREE_90,
+	EXYNOS_DRM_DEGREE_180,
+	EXYNOS_DRM_DEGREE_270,
+};
+
+enum drm_exynos_planer {
+	EXYNOS_DRM_PLANAR_Y,
+	EXYNOS_DRM_PLANAR_CB,
+	EXYNOS_DRM_PLANAR_CR,
+	EXYNOS_DRM_PLANAR_MAX,
+};
+
+/**
+ * A structure for ipp supported property list.
+ *
+ * @version: version of this structure.
+ * @ipp_id: id of ipp driver.
+ * @count: count of ipp driver.
+ * @writeback: flag of writeback supporting.
+ * @flip: flag of flip supporting.
+ * @degree: flag of degree information.
+ * @csc: flag of csc supporting.
+ * @crop: flag of crop supporting.
+ * @scale: flag of scale supporting.
+ * @refresh_min: min hz of refresh.
+ * @refresh_max: max hz of refresh.
+ * @crop_min: crop min resolution.
+ * @crop_max: crop max resolution.
+ * @scale_min: scale min resolution.
+ * @scale_max: scale max resolution.
+ */
+struct drm_exynos_ipp_prop_list {
+	__u32	version;
+	__u32	ipp_id;
+	__u32	count;
+	__u32	writeback;
+	__u32	flip;
+	__u32	degree;
+	__u32	csc;
+	__u32	crop;
+	__u32	scale;
+	__u32	refresh_min;
+	__u32	refresh_max;
+	__u32	reserved;
+	struct drm_exynos_sz	crop_min;
+	struct drm_exynos_sz	crop_max;
+	struct drm_exynos_sz	scale_min;
+	struct drm_exynos_sz	scale_max;
+};
+
+/**
+ * A structure for ipp config.
+ *
+ * @ops_id: property of operation directions.
+ * @flip: property of mirror, flip.
+ * @degree: property of rotation degree.
+ * @fmt: property of image format.
+ * @sz: property of image size.
+ * @pos: property of image position(src-cropped,dst-scaler).
+ */
+struct drm_exynos_ipp_config {
+	enum drm_exynos_ops_id ops_id;
+	enum drm_exynos_flip	flip;
+	enum drm_exynos_degree	degree;
+	__u32	fmt;
+	struct drm_exynos_sz	sz;
+	struct drm_exynos_pos	pos;
+};
+
+enum drm_exynos_ipp_cmd {
+	IPP_CMD_NONE,
+	IPP_CMD_M2M,
+	IPP_CMD_WB,
+	IPP_CMD_OUTPUT,
+	IPP_CMD_MAX,
+};
+
+/**
+ * A structure for ipp property.
+ *
+ * @config: source, destination config.
+ * @cmd: definition of command.
+ * @ipp_id: id of ipp driver.
+ * @prop_id: id of property.
+ * @refresh_rate: refresh rate.
+ */
+struct drm_exynos_ipp_property {
+	struct drm_exynos_ipp_config config[EXYNOS_DRM_OPS_MAX];
+	enum drm_exynos_ipp_cmd	cmd;
+	__u32	ipp_id;
+	__u32	prop_id;
+	__u32	refresh_rate;
+};
+
+enum drm_exynos_ipp_buf_type {
+	IPP_BUF_ENQUEUE,
+	IPP_BUF_DEQUEUE,
+};
+
+/**
+ * A structure for ipp buffer operations.
+ *
+ * @ops_id: operation directions.
+ * @buf_type: definition of buffer.
+ * @prop_id: id of property.
+ * @buf_id: id of buffer.
+ * @handle: Y, Cb, Cr each planar handle.
+ * @user_data: user data.
+ */
+struct drm_exynos_ipp_queue_buf {
+	enum drm_exynos_ops_id	ops_id;
+	enum drm_exynos_ipp_buf_type	buf_type;
+	__u32	prop_id;
+	__u32	buf_id;
+	__u32	handle[EXYNOS_DRM_PLANAR_MAX];
+	__u32	reserved;
+	__u64	user_data;
+};
+
+enum drm_exynos_ipp_ctrl {
+	IPP_CTRL_PLAY,
+	IPP_CTRL_STOP,
+	IPP_CTRL_PAUSE,
+	IPP_CTRL_RESUME,
+	IPP_CTRL_MAX,
+};
+
+/**
+ * A structure for ipp start/stop operations.
+ *
+ * @prop_id: id of property.
+ * @ctrl: definition of control.
+ */
+struct drm_exynos_ipp_cmd_ctrl {
+	__u32	prop_id;
+	enum drm_exynos_ipp_ctrl	ctrl;
+};
+
 #define DRM_EXYNOS_GEM_CREATE		0x00
 #define DRM_EXYNOS_GEM_MAP_OFFSET	0x01
 #define DRM_EXYNOS_GEM_MMAP		0x02
@@ -166,6 +330,12 @@ struct drm_exynos_g2d_exec {
 #define DRM_EXYNOS_G2D_SET_CMDLIST	0x21
 #define DRM_EXYNOS_G2D_EXEC		0x22
 
+/* IPP - Image Post Processing */
+#define DRM_EXYNOS_IPP_GET_PROPERTY	0x30
+#define DRM_EXYNOS_IPP_SET_PROPERTY	0x31
+#define DRM_EXYNOS_IPP_QUEUE_BUF	0x32
+#define DRM_EXYNOS_IPP_CMD_CTRL	0x33
+
 #define DRM_IOCTL_EXYNOS_GEM_CREATE		DRM_IOWR(DRM_COMMAND_BASE + \
 		DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
 
@@ -188,8 +358,18 @@ struct drm_exynos_g2d_exec {
 #define DRM_IOCTL_EXYNOS_G2D_EXEC		DRM_IOWR(DRM_COMMAND_BASE + \
 		DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)
 
+#define DRM_IOCTL_EXYNOS_IPP_GET_PROPERTY	DRM_IOWR(DRM_COMMAND_BASE + \
+		DRM_EXYNOS_IPP_GET_PROPERTY, struct drm_exynos_ipp_prop_list)
+#define DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY	DRM_IOWR(DRM_COMMAND_BASE + \
+		DRM_EXYNOS_IPP_SET_PROPERTY, struct drm_exynos_ipp_property)
+#define DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF	DRM_IOWR(DRM_COMMAND_BASE + \
+		DRM_EXYNOS_IPP_QUEUE_BUF, struct drm_exynos_ipp_queue_buf)
+#define DRM_IOCTL_EXYNOS_IPP_CMD_CTRL		DRM_IOWR(DRM_COMMAND_BASE + \
+		DRM_EXYNOS_IPP_CMD_CTRL, struct drm_exynos_ipp_cmd_ctrl)
+
 /* EXYNOS specific events */
 #define DRM_EXYNOS_G2D_EVENT		0x80000000
+#define DRM_EXYNOS_IPP_EVENT		0x80000001
 
 struct drm_exynos_g2d_event {
 	struct drm_event	base;
@@ -200,4 +380,14 @@ struct drm_exynos_g2d_event {
 	__u32			reserved;
 };
 
+struct drm_exynos_ipp_event {
+	struct drm_event	base;
+	__u64			user_data;
+	__u32			tv_sec;
+	__u32			tv_usec;
+	__u32			prop_id;
+	__u32			reserved;
+	__u32			buf_id[EXYNOS_DRM_OPS_MAX];
+};
+
 #endif /* _UAPI_EXYNOS_DRM_H_ */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC v3 2/5] drm/exynos: add iommu support for ipp
  2012-12-12  7:34 [RFC v3 0/5] drm/exynos: add ipp subsystem and each ipp drivers Eunchul Kim
  2012-12-12  7:34 ` [RFC v3 1/5] drm/exynos: add ipp subsystem Eunchul Kim
@ 2012-12-12  7:34 ` Eunchul Kim
  2012-12-12  7:34 ` [RFC v3 3/5] drm/exynos: add fimc ipp driver Eunchul Kim
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12  7:34 UTC (permalink / raw)
  To: dri-devel, inki.dae; +Cc: jy0.jeon, jaejoon.seo, kyungmin.park, jmock.shin

This patch adds iommu support for ipp.
For this, it adds subdrv_probe/remove callback to enable or disable ipp iommu.
we can get or put device address to a gem handle from user
through exynos_drm_gem_get/put_dma_addr().

Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
Signed-off-by: Jinyoung Jeon <jy0.jeon@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_ipp.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
index eb12cb5..cb2165a 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
@@ -23,6 +23,7 @@
 #include "exynos_drm_drv.h"
 #include "exynos_drm_gem.h"
 #include "exynos_drm_ipp.h"
+#include "exynos_drm_iommu.h"
 
 /*
  * IPP is stand for Image Post Processing and
@@ -1783,10 +1784,24 @@ static int ipp_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
 		ippdrv->event_workq = ctx->event_workq;
 		ippdrv->sched_event = ipp_sched_event;
 		INIT_LIST_HEAD(&ippdrv->cmd_list);
+
+		if (is_drm_iommu_supported(drm_dev)) {
+			ret = drm_iommu_attach_device(drm_dev, ippdrv->dev);
+			if (ret) {
+				DRM_ERROR("failed to activate iommu\n");
+				goto err_iommu;
+			}
+		}
 	}
 
 	return 0;
 
+err_iommu:
+	/* get ipp driver entry */
+	list_for_each_entry_reverse(ippdrv, &exynos_drm_ippdrv_list, drv_list)
+		if (is_drm_iommu_supported(drm_dev))
+			drm_iommu_detach_device(drm_dev, ippdrv->dev);
+
 err_idr:
 	idr_remove_all(&ctx->ipp_idr);
 	idr_remove_all(&ctx->prop_idr);
@@ -1803,6 +1818,9 @@ static void ipp_subdrv_remove(struct drm_device *drm_dev, struct device *dev)
 
 	/* get ipp driver entry */
 	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
+		if (is_drm_iommu_supported(drm_dev))
+			drm_iommu_detach_device(drm_dev, ippdrv->dev);
+
 		ippdrv->drm_dev = NULL;
 		exynos_drm_ippdrv_unregister(ippdrv);
 	}
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC v3 3/5] drm/exynos: add fimc ipp driver
  2012-12-12  7:34 [RFC v3 0/5] drm/exynos: add ipp subsystem and each ipp drivers Eunchul Kim
  2012-12-12  7:34 ` [RFC v3 1/5] drm/exynos: add ipp subsystem Eunchul Kim
  2012-12-12  7:34 ` [RFC v3 2/5] drm/exynos: add iommu support for ipp Eunchul Kim
@ 2012-12-12  7:34 ` Eunchul Kim
  2012-12-12  7:34 ` [RFC v3 4/5] drm/exynos: add rotator " Eunchul Kim
  2012-12-12  7:34 ` [RFC v3 5/5] drm/exynos: add gsc " Eunchul Kim
  4 siblings, 0 replies; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12  7:34 UTC (permalink / raw)
  To: dri-devel, inki.dae; +Cc: jy0.jeon, jaejoon.seo, kyungmin.park, jmock.shin

FIMC is stand for Fully Interfactive Mobile Camera and
supports image scaler/rotator/crop/flip/csc and input/output DMA operations.
input DMA reads image data from the memory.
output DMA writes image data to memory.
FIMC supports image rotation and image effect functions.
also supports writeback and display output operations.

Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
Signed-off-by: Jinyoung Jeon <jy0.jeon@samsung.com>
---
 drivers/gpu/drm/exynos/Kconfig           |    6 +
 drivers/gpu/drm/exynos/Makefile          |    1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |   15 +
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |    1 +
 drivers/gpu/drm/exynos/exynos_drm_fimc.c | 2022 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_fimc.h |   34 +
 drivers/gpu/drm/exynos/regs-fimc.h       |  669 ++++++++++
 include/drm/exynos_drm.h                 |   26 +
 8 files changed, 2774 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.h
 create mode 100644 drivers/gpu/drm/exynos/regs-fimc.h

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index bcf1c9d..4915ab6 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -51,3 +51,9 @@ config DRM_EXYNOS_IPP
 	depends on DRM_EXYNOS
 	help
 	  Choose this option if you want to use IPP feature for DRM.
+
+config DRM_EXYNOS_FIMC
+	bool "Exynos DRM FIMC"
+	depends on DRM_EXYNOS_IPP
+	help
+	  Choose this option if you want to use Exynos FIMC for DRM.
diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 6c536ce..9710024 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -17,5 +17,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI)	+= exynos_hdmi.o exynos_mixer.o \
 exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+= exynos_drm_vidi.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
+exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
 
 obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 0eb8a97..73f02ac 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -372,6 +372,12 @@ static int __init exynos_drm_init(void)
 		goto out_g2d;
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_FIMC
+	ret = platform_driver_register(&fimc_driver);
+	if (ret < 0)
+		goto out_fimc;
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_IPP
 	ret = platform_driver_register(&ipp_driver);
 	if (ret < 0)
@@ -400,6 +406,11 @@ out_drm:
 out_ipp:
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_FIMC
+	platform_driver_unregister(&fimc_driver);
+out_fimc:
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_G2D
 	platform_driver_unregister(&g2d_driver);
 out_g2d:
@@ -440,6 +451,10 @@ static void __exit exynos_drm_exit(void)
 	platform_driver_unregister(&ipp_driver);
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_FIMC
+	platform_driver_unregister(&fimc_driver);
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_G2D
 	platform_driver_unregister(&g2d_driver);
 #endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index a365788..14f9490 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -352,5 +352,6 @@ extern struct platform_driver mixer_driver;
 extern struct platform_driver exynos_drm_common_hdmi_driver;
 extern struct platform_driver vidi_driver;
 extern struct platform_driver g2d_driver;
+extern struct platform_driver fimc_driver;
 extern struct platform_driver ipp_driver;
 #endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
new file mode 100644
index 0000000..077f6a6
--- /dev/null
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c
@@ -0,0 +1,2022 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics Co.Ltd
+ * Authors:
+ *	Eunchul Kim <chulspro.kim@samsung.com>
+ *	Jinyoung Jeon <jy0.jeon@samsung.com>
+ *	Sangmin Lee <lsmin.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/pm_runtime.h>
+#include <plat/map-base.h>
+
+#include <drm/drmP.h>
+#include <drm/exynos_drm.h>
+#include "regs-fimc.h"
+#include "exynos_drm_ipp.h"
+#include "exynos_drm_fimc.h"
+
+/*
+ * FIMC is stand for Fully Interactive Mobile Camera and
+ * supports image scaler/rotator and input/output DMA operations.
+ * input DMA reads image data from the memory.
+ * output DMA writes image data to memory.
+ * FIMC supports image rotation and image effect functions.
+ */
+
+#define FIMC_MAX_DEVS	4
+#define FIMC_MAX_SRC	2
+#define FIMC_MAX_DST	32
+#define FIMC_SHFACTOR	10
+#define FIMC_BUF_STOP	1
+#define FIMC_BUF_START	2
+#define FIMC_REG_SZ		32
+#define FIMC_WIDTH_ITU_709	1280
+#define FIMC_REFRESH_MAX	60
+#define FIMC_REFRESH_MIN	12
+#define FIMC_CROP_MAX	8192
+#define FIMC_CROP_MIN	32
+#define FIMC_SCALE_MAX	4224
+#define FIMC_SCALE_MIN	32
+
+#define get_fimc_context(dev)	platform_get_drvdata(to_platform_device(dev))
+#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
+					struct fimc_context, ippdrv);
+#define fimc_read(offset)		readl(ctx->regs + (offset))
+#define fimc_write(cfg, offset)	writel(cfg, ctx->regs + (offset))
+
+enum fimc_wb {
+	FIMC_WB_NONE,
+	FIMC_WB_A,
+	FIMC_WB_B,
+};
+
+/*
+ * A structure of scaler.
+ *
+ * @range: narrow, wide.
+ * @bypass: unused scaler path.
+ * @up_h: horizontal scale up.
+ * @up_v: vertical scale up.
+ * @hratio: horizontal ratio.
+ * @vratio: vertical ratio.
+ */
+struct fimc_scaler {
+	bool	range;
+	bool bypass;
+	bool up_h;
+	bool up_v;
+	u32 hratio;
+	u32 vratio;
+};
+
+/*
+ * A structure of scaler capability.
+ *
+ * find user manual table 43-1.
+ * @in_hori: scaler input horizontal size.
+ * @bypass: scaler bypass mode.
+ * @dst_h_wo_rot: target horizontal size without output rotation.
+ * @dst_h_rot: target horizontal size with output rotation.
+ * @rl_w_wo_rot: real width without input rotation.
+ * @rl_h_rot: real height without output rotation.
+ */
+struct fimc_capability {
+	/* scaler */
+	u32	in_hori;
+	u32	bypass;
+	/* output rotator */
+	u32	dst_h_wo_rot;
+	u32	dst_h_rot;
+	/* input rotator */
+	u32	rl_w_wo_rot;
+	u32	rl_h_rot;
+};
+
+/*
+ * A structure of fimc driver data.
+ *
+ * @parent_clk: name of parent clock.
+ */
+struct fimc_driverdata {
+	char	*parent_clk;
+};
+
+/*
+ * A structure of fimc context.
+ *
+ * @ippdrv: prepare initialization using ippdrv.
+ * @regs_res: register resources.
+ * @regs: memory mapped io registers.
+ * @lock: locking of operations.
+ * @sclk_fimc_clk: fimc source clock.
+ * @fimc_clk: fimc clock.
+ * @wb_clk: writeback a clock.
+ * @wb_b_clk: writeback b clock.
+ * @sc: scaler infomations.
+ * @odr: ordering of YUV.
+ * @ver: fimc version.
+ * @pol: porarity of writeback.
+ * @id: fimc id.
+ * @irq: irq number.
+ * @suspended: qos operations.
+ */
+struct fimc_context {
+	struct exynos_drm_ippdrv	ippdrv;
+	struct resource	*regs_res;
+	void __iomem	*regs;
+	struct mutex	lock;
+	struct clk	*sclk_fimc_clk;
+	struct clk	*fimc_clk;
+	struct clk	*wb_clk;
+	struct clk	*wb_b_clk;
+	struct fimc_scaler	sc;
+	struct fimc_driverdata	*ddata;
+	struct exynos_drm_ipp_pol	pol;
+	int	id;
+	int	irq;
+	bool	suspended;
+};
+
+static void fimc_sw_reset(struct fimc_context *ctx, bool pattern)
+{
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:pattern[%d]\n", __func__, pattern);
+
+	cfg = fimc_read(EXYNOS_CISRCFMT);
+	cfg |= EXYNOS_CISRCFMT_ITU601_8BIT;
+	if (pattern)
+		cfg |= EXYNOS_CIGCTRL_TESTPATTERN_COLOR_BAR;
+
+	fimc_write(cfg, EXYNOS_CISRCFMT);
+
+	/* s/w reset */
+	cfg = fimc_read(EXYNOS_CIGCTRL);
+	cfg |= (EXYNOS_CIGCTRL_SWRST);
+	fimc_write(cfg, EXYNOS_CIGCTRL);
+
+	/* s/w reset complete */
+	cfg = fimc_read(EXYNOS_CIGCTRL);
+	cfg &= ~EXYNOS_CIGCTRL_SWRST;
+	fimc_write(cfg, EXYNOS_CIGCTRL);
+
+	/* reset sequence */
+	fimc_write(0x0, EXYNOS_CIFCNTSEQ);
+}
+
+static void fimc_set_camblk_fimd0_wb(struct fimc_context *ctx)
+{
+	u32 camblk_cfg;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	camblk_cfg = readl(SYSREG_CAMERA_BLK);
+	camblk_cfg &= ~(SYSREG_FIMD0WB_DEST_MASK);
+	camblk_cfg |= ctx->id << (SYSREG_FIMD0WB_DEST_SHIFT);
+
+	writel(camblk_cfg, SYSREG_CAMERA_BLK);
+}
+
+static void fimc_set_type_ctrl(struct fimc_context *ctx, enum fimc_wb wb)
+{
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:wb[%d]\n", __func__, wb);
+
+	cfg = fimc_read(EXYNOS_CIGCTRL);
+	cfg &= ~(EXYNOS_CIGCTRL_TESTPATTERN_MASK |
+		EXYNOS_CIGCTRL_SELCAM_ITU_MASK |
+		EXYNOS_CIGCTRL_SELCAM_MIPI_MASK |
+		EXYNOS_CIGCTRL_SELCAM_FIMC_MASK |
+		EXYNOS_CIGCTRL_SELWB_CAMIF_MASK |
+		EXYNOS_CIGCTRL_SELWRITEBACK_MASK);
+
+	switch (wb) {
+	case FIMC_WB_A:
+		cfg |= (EXYNOS_CIGCTRL_SELWRITEBACK_A |
+			EXYNOS_CIGCTRL_SELWB_CAMIF_WRITEBACK);
+		break;
+	case FIMC_WB_B:
+		cfg |= (EXYNOS_CIGCTRL_SELWRITEBACK_B |
+			EXYNOS_CIGCTRL_SELWB_CAMIF_WRITEBACK);
+		break;
+	case FIMC_WB_NONE:
+	default:
+		cfg |= (EXYNOS_CIGCTRL_SELCAM_ITU_A |
+			EXYNOS_CIGCTRL_SELWRITEBACK_A |
+			EXYNOS_CIGCTRL_SELCAM_MIPI_A |
+			EXYNOS_CIGCTRL_SELCAM_FIMC_ITU);
+		break;
+	}
+
+	fimc_write(cfg, EXYNOS_CIGCTRL);
+}
+
+static void fimc_set_polarity(struct fimc_context *ctx,
+		struct exynos_drm_ipp_pol *pol)
+{
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:inv_pclk[%d]inv_vsync[%d]\n",
+		__func__, pol->inv_pclk, pol->inv_vsync);
+	DRM_DEBUG_KMS("%s:inv_href[%d]inv_hsync[%d]\n",
+		__func__, pol->inv_href, pol->inv_hsync);
+
+	cfg = fimc_read(EXYNOS_CIGCTRL);
+	cfg &= ~(EXYNOS_CIGCTRL_INVPOLPCLK | EXYNOS_CIGCTRL_INVPOLVSYNC |
+		 EXYNOS_CIGCTRL_INVPOLHREF | EXYNOS_CIGCTRL_INVPOLHSYNC);
+
+	if (pol->inv_pclk)
+		cfg |= EXYNOS_CIGCTRL_INVPOLPCLK;
+	if (pol->inv_vsync)
+		cfg |= EXYNOS_CIGCTRL_INVPOLVSYNC;
+	if (pol->inv_href)
+		cfg |= EXYNOS_CIGCTRL_INVPOLHREF;
+	if (pol->inv_hsync)
+		cfg |= EXYNOS_CIGCTRL_INVPOLHSYNC;
+
+	fimc_write(cfg, EXYNOS_CIGCTRL);
+}
+
+static void fimc_handle_jpeg(struct fimc_context *ctx, bool enable)
+{
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:enable[%d]\n", __func__, enable);
+
+	cfg = fimc_read(EXYNOS_CIGCTRL);
+	if (enable)
+		cfg |= EXYNOS_CIGCTRL_CAM_JPEG;
+	else
+		cfg &= ~EXYNOS_CIGCTRL_CAM_JPEG;
+
+	fimc_write(cfg, EXYNOS_CIGCTRL);
+}
+
+static void fimc_handle_irq(struct fimc_context *ctx, bool enable,
+		bool overflow, bool level)
+{
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:enable[%d]overflow[%d]level[%d]\n", __func__,
+			enable, overflow, level);
+
+	cfg = fimc_read(EXYNOS_CIGCTRL);
+	if (enable) {
+		cfg &= ~(EXYNOS_CIGCTRL_IRQ_OVFEN | EXYNOS_CIGCTRL_IRQ_LEVEL);
+		cfg |= EXYNOS_CIGCTRL_IRQ_ENABLE;
+		if (overflow)
+			cfg |= EXYNOS_CIGCTRL_IRQ_OVFEN;
+		if (level)
+			cfg |= EXYNOS_CIGCTRL_IRQ_LEVEL;
+	} else
+		cfg &= ~(EXYNOS_CIGCTRL_IRQ_OVFEN | EXYNOS_CIGCTRL_IRQ_ENABLE);
+
+	fimc_write(cfg, EXYNOS_CIGCTRL);
+}
+
+static void fimc_clear_irq(struct fimc_context *ctx)
+{
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	cfg = fimc_read(EXYNOS_CIGCTRL);
+	cfg |= EXYNOS_CIGCTRL_IRQ_CLR;
+	fimc_write(cfg, EXYNOS_CIGCTRL);
+}
+
+static bool fimc_check_ovf(struct fimc_context *ctx)
+{
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg, status, flag;
+
+	status = fimc_read(EXYNOS_CISTATUS);
+	flag = EXYNOS_CISTATUS_OVFIY | EXYNOS_CISTATUS_OVFICB |
+		EXYNOS_CISTATUS_OVFICR;
+
+	DRM_DEBUG_KMS("%s:flag[0x%x]\n", __func__, flag);
+
+	if (status & flag) {
+		cfg = fimc_read(EXYNOS_CIWDOFST);
+		cfg |= (EXYNOS_CIWDOFST_CLROVFIY | EXYNOS_CIWDOFST_CLROVFICB |
+			EXYNOS_CIWDOFST_CLROVFICR);
+
+		fimc_write(cfg, EXYNOS_CIWDOFST);
+
+		cfg = fimc_read(EXYNOS_CIWDOFST);
+		cfg &= ~(EXYNOS_CIWDOFST_CLROVFIY | EXYNOS_CIWDOFST_CLROVFICB |
+			EXYNOS_CIWDOFST_CLROVFICR);
+
+		fimc_write(cfg, EXYNOS_CIWDOFST);
+
+		dev_err(ippdrv->dev, "occured overflow at %d, status 0x%x.\n",
+			ctx->id, status);
+		return true;
+	}
+
+	return false;
+}
+
+static bool fimc_check_frame_end(struct fimc_context *ctx)
+{
+	u32 cfg;
+
+	cfg = fimc_read(EXYNOS_CISTATUS);
+
+	DRM_DEBUG_KMS("%s:cfg[0x%x]\n", __func__, cfg);
+
+	if (!(cfg & EXYNOS_CISTATUS_FRAMEEND))
+		return false;
+
+	cfg &= ~(EXYNOS_CISTATUS_FRAMEEND);
+	fimc_write(cfg, EXYNOS_CISTATUS);
+
+	return true;
+}
+
+static int fimc_get_buf_id(struct fimc_context *ctx)
+{
+	u32 cfg;
+	int frame_cnt, buf_id;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	cfg = fimc_read(EXYNOS_CISTATUS2);
+	frame_cnt = EXYNOS_CISTATUS2_GET_FRAMECOUNT_BEFORE(cfg);
+
+	if (frame_cnt == 0)
+		frame_cnt = EXYNOS_CISTATUS2_GET_FRAMECOUNT_PRESENT(cfg);
+
+	DRM_DEBUG_KMS("%s:present[%d]before[%d]\n", __func__,
+		EXYNOS_CISTATUS2_GET_FRAMECOUNT_PRESENT(cfg),
+		EXYNOS_CISTATUS2_GET_FRAMECOUNT_BEFORE(cfg));
+
+	if (frame_cnt == 0) {
+		DRM_ERROR("failed to get frame count.\n");
+		return -EIO;
+	}
+
+	buf_id = frame_cnt - 1;
+	DRM_DEBUG_KMS("%s:buf_id[%d]\n", __func__, buf_id);
+
+	return buf_id;
+}
+
+static void fimc_handle_lastend(struct fimc_context *ctx, bool enable)
+{
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:enable[%d]\n", __func__, enable);
+
+	cfg = fimc_read(EXYNOS_CIOCTRL);
+	if (enable)
+		cfg |= EXYNOS_CIOCTRL_LASTENDEN;
+	else
+		cfg &= ~EXYNOS_CIOCTRL_LASTENDEN;
+
+	fimc_write(cfg, EXYNOS_CIOCTRL);
+}
+
+
+static int fimc_src_set_fmt_order(struct fimc_context *ctx, u32 fmt)
+{
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
+
+	/* RGB */
+	cfg = fimc_read(EXYNOS_CISCCTRL);
+	cfg &= ~EXYNOS_CISCCTRL_INRGB_FMT_RGB_MASK;
+
+	switch (fmt) {
+	case DRM_FORMAT_RGB565:
+		cfg |= EXYNOS_CISCCTRL_INRGB_FMT_RGB565;
+		fimc_write(cfg, EXYNOS_CISCCTRL);
+		return 0;
+	case DRM_FORMAT_RGB888:
+	case DRM_FORMAT_XRGB8888:
+		cfg |= EXYNOS_CISCCTRL_INRGB_FMT_RGB888;
+		fimc_write(cfg, EXYNOS_CISCCTRL);
+		return 0;
+	default:
+		/* bypass */
+		break;
+	}
+
+	/* YUV */
+	cfg = fimc_read(EXYNOS_MSCTRL);
+	cfg &= ~(EXYNOS_MSCTRL_ORDER2P_SHIFT_MASK |
+		EXYNOS_MSCTRL_C_INT_IN_2PLANE |
+		EXYNOS_MSCTRL_ORDER422_YCBYCR);
+
+	switch (fmt) {
+	case DRM_FORMAT_YUYV:
+		cfg |= EXYNOS_MSCTRL_ORDER422_YCBYCR;
+		break;
+	case DRM_FORMAT_YVYU:
+		cfg |= EXYNOS_MSCTRL_ORDER422_YCRYCB;
+		break;
+	case DRM_FORMAT_UYVY:
+		cfg |= EXYNOS_MSCTRL_ORDER422_CBYCRY;
+		break;
+	case DRM_FORMAT_VYUY:
+	case DRM_FORMAT_YUV444:
+		cfg |= EXYNOS_MSCTRL_ORDER422_CRYCBY;
+		break;
+	case DRM_FORMAT_NV21:
+	case DRM_FORMAT_NV61:
+		cfg |= (EXYNOS_MSCTRL_ORDER2P_LSB_CRCB |
+			EXYNOS_MSCTRL_C_INT_IN_2PLANE);
+		break;
+	case DRM_FORMAT_YUV422:
+	case DRM_FORMAT_YUV420:
+	case DRM_FORMAT_YVU420:
+		cfg |= EXYNOS_MSCTRL_C_INT_IN_3PLANE;
+		break;
+	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_NV12MT:
+	case DRM_FORMAT_NV16:
+		cfg |= (EXYNOS_MSCTRL_ORDER2P_LSB_CBCR |
+			EXYNOS_MSCTRL_C_INT_IN_2PLANE);
+		break;
+	default:
+		dev_err(ippdrv->dev, "inavlid source yuv order 0x%x.\n", fmt);
+		return -EINVAL;
+	}
+
+	fimc_write(cfg, EXYNOS_MSCTRL);
+
+	return 0;
+}
+
+static int fimc_src_set_fmt(struct device *dev, u32 fmt)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
+
+	cfg = fimc_read(EXYNOS_MSCTRL);
+	cfg &= ~EXYNOS_MSCTRL_INFORMAT_RGB;
+
+	switch (fmt) {
+	case DRM_FORMAT_RGB565:
+	case DRM_FORMAT_RGB888:
+	case DRM_FORMAT_XRGB8888:
+		cfg |= EXYNOS_MSCTRL_INFORMAT_RGB;
+		break;
+	case DRM_FORMAT_YUV444:
+		cfg |= EXYNOS_MSCTRL_INFORMAT_YCBCR420;
+		break;
+	case DRM_FORMAT_YUYV:
+	case DRM_FORMAT_YVYU:
+	case DRM_FORMAT_UYVY:
+	case DRM_FORMAT_VYUY:
+		cfg |= EXYNOS_MSCTRL_INFORMAT_YCBCR422_1PLANE;
+		break;
+	case DRM_FORMAT_NV16:
+	case DRM_FORMAT_NV61:
+	case DRM_FORMAT_YUV422:
+		cfg |= EXYNOS_MSCTRL_INFORMAT_YCBCR422;
+		break;
+	case DRM_FORMAT_YUV420:
+	case DRM_FORMAT_YVU420:
+	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_NV21:
+	case DRM_FORMAT_NV12MT:
+		cfg |= EXYNOS_MSCTRL_INFORMAT_YCBCR420;
+		break;
+	default:
+		dev_err(ippdrv->dev, "inavlid source format 0x%x.\n", fmt);
+		return -EINVAL;
+	}
+
+	fimc_write(cfg, EXYNOS_MSCTRL);
+
+	cfg = fimc_read(EXYNOS_CIDMAPARAM);
+	cfg &= ~EXYNOS_CIDMAPARAM_R_MODE_MASK;
+
+	if (fmt == DRM_FORMAT_NV12MT)
+		cfg |= EXYNOS_CIDMAPARAM_R_MODE_64X32;
+	else
+		cfg |= EXYNOS_CIDMAPARAM_R_MODE_LINEAR;
+
+	fimc_write(cfg, EXYNOS_CIDMAPARAM);
+
+	return fimc_src_set_fmt_order(ctx, fmt);
+}
+
+static int fimc_src_set_transf(struct device *dev,
+		enum drm_exynos_degree degree,
+		enum drm_exynos_flip flip)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg1, cfg2;
+
+	DRM_DEBUG_KMS("%s:degree[%d]flip[0x%x]\n", __func__,
+		degree, flip);
+
+	cfg1 = fimc_read(EXYNOS_MSCTRL);
+	cfg1 &= ~(EXYNOS_MSCTRL_FLIP_X_MIRROR |
+		EXYNOS_MSCTRL_FLIP_Y_MIRROR);
+
+	cfg2 = fimc_read(EXYNOS_CITRGFMT);
+	cfg2 &= ~EXYNOS_CITRGFMT_INROT90_CLOCKWISE;
+
+	switch (degree) {
+	case EXYNOS_DRM_DEGREE_0:
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg1 |= EXYNOS_MSCTRL_FLIP_X_MIRROR;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg1 |= EXYNOS_MSCTRL_FLIP_Y_MIRROR;
+		break;
+	case EXYNOS_DRM_DEGREE_90:
+		cfg2 |= EXYNOS_CITRGFMT_INROT90_CLOCKWISE;
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg1 |= EXYNOS_MSCTRL_FLIP_X_MIRROR;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg1 |= EXYNOS_MSCTRL_FLIP_Y_MIRROR;
+		break;
+	case EXYNOS_DRM_DEGREE_180:
+		cfg1 |= (EXYNOS_MSCTRL_FLIP_X_MIRROR |
+			EXYNOS_MSCTRL_FLIP_Y_MIRROR);
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg1 &= ~EXYNOS_MSCTRL_FLIP_X_MIRROR;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg1 &= ~EXYNOS_MSCTRL_FLIP_Y_MIRROR;
+		break;
+	case EXYNOS_DRM_DEGREE_270:
+		cfg1 |= (EXYNOS_MSCTRL_FLIP_X_MIRROR |
+			EXYNOS_MSCTRL_FLIP_Y_MIRROR);
+		cfg2 |= EXYNOS_CITRGFMT_INROT90_CLOCKWISE;
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg1 &= ~EXYNOS_MSCTRL_FLIP_X_MIRROR;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg1 &= ~EXYNOS_MSCTRL_FLIP_Y_MIRROR;
+		break;
+	default:
+		dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
+		return -EINVAL;
+	}
+
+	fimc_write(cfg1, EXYNOS_MSCTRL);
+	fimc_write(cfg2, EXYNOS_CITRGFMT);
+
+	return (cfg2 & EXYNOS_CITRGFMT_INROT90_CLOCKWISE) ? 1 : 0;
+}
+
+static int fimc_set_window(struct fimc_context *ctx,
+		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz)
+{
+	u32 cfg, h1, h2, v1, v2;
+
+	/* cropped image */
+	h1 = pos->x;
+	h2 = sz->hsize - pos->w - pos->x;
+	v1 = pos->y;
+	v2 = sz->vsize - pos->h - pos->y;
+
+	DRM_DEBUG_KMS("%s:x[%d]y[%d]w[%d]h[%d]hsize[%d]vsize[%d]\n",
+	__func__, pos->x, pos->y, pos->w, pos->h, sz->hsize, sz->vsize);
+	DRM_DEBUG_KMS("%s:h1[%d]h2[%d]v1[%d]v2[%d]\n", __func__,
+		h1, h2, v1, v2);
+
+	/*
+	 * set window offset 1, 2 size
+	 * check figure 43-21 in user manual
+	 */
+	cfg = fimc_read(EXYNOS_CIWDOFST);
+	cfg &= ~(EXYNOS_CIWDOFST_WINHOROFST_MASK |
+		EXYNOS_CIWDOFST_WINVEROFST_MASK);
+	cfg |= (EXYNOS_CIWDOFST_WINHOROFST(h1) |
+		EXYNOS_CIWDOFST_WINVEROFST(v1));
+	cfg |= EXYNOS_CIWDOFST_WINOFSEN;
+	fimc_write(cfg, EXYNOS_CIWDOFST);
+
+	cfg = (EXYNOS_CIWDOFST2_WINHOROFST2(h2) |
+		EXYNOS_CIWDOFST2_WINVEROFST2(v2));
+	fimc_write(cfg, EXYNOS_CIWDOFST2);
+
+	return 0;
+}
+
+static int fimc_src_set_size(struct device *dev, int swap,
+		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct drm_exynos_pos img_pos = *pos;
+	struct drm_exynos_sz img_sz = *sz;
+	u32 cfg;
+
+	/* ToDo: check width and height */
+
+	DRM_DEBUG_KMS("%s:swap[%d]hsize[%d]vsize[%d]\n",
+		__func__, swap, sz->hsize, sz->vsize);
+
+	/* original size */
+	cfg = (EXYNOS_ORGISIZE_HORIZONTAL(img_sz.hsize) |
+		EXYNOS_ORGISIZE_VERTICAL(img_sz.vsize));
+
+	fimc_write(cfg, EXYNOS_ORGISIZE);
+
+	DRM_DEBUG_KMS("%s:x[%d]y[%d]w[%d]h[%d]\n", __func__,
+		pos->x, pos->y, pos->w, pos->h);
+
+	if (swap) {
+		img_pos.w = pos->h;
+		img_pos.h = pos->w;
+		img_sz.hsize = sz->vsize;
+		img_sz.vsize = sz->hsize;
+	}
+
+	/* set input DMA image size */
+	cfg = fimc_read(EXYNOS_CIREAL_ISIZE);
+	cfg &= ~(EXYNOS_CIREAL_ISIZE_HEIGHT_MASK |
+		EXYNOS_CIREAL_ISIZE_WIDTH_MASK);
+	cfg |= (EXYNOS_CIREAL_ISIZE_WIDTH(img_pos.w) |
+		EXYNOS_CIREAL_ISIZE_HEIGHT(img_pos.h));
+	fimc_write(cfg, EXYNOS_CIREAL_ISIZE);
+
+	/*
+	 * set input FIFO image size
+	 * for now, we support only ITU601 8 bit mode
+	 */
+	cfg = (EXYNOS_CISRCFMT_ITU601_8BIT |
+		EXYNOS_CISRCFMT_SOURCEHSIZE(img_sz.hsize) |
+		EXYNOS_CISRCFMT_SOURCEVSIZE(img_sz.vsize));
+	fimc_write(cfg, EXYNOS_CISRCFMT);
+
+	/* offset Y(RGB), Cb, Cr */
+	cfg = (EXYNOS_CIIYOFF_HORIZONTAL(img_pos.x) |
+		EXYNOS_CIIYOFF_VERTICAL(img_pos.y));
+	fimc_write(cfg, EXYNOS_CIIYOFF);
+	cfg = (EXYNOS_CIICBOFF_HORIZONTAL(img_pos.x) |
+		EXYNOS_CIICBOFF_VERTICAL(img_pos.y));
+	fimc_write(cfg, EXYNOS_CIICBOFF);
+	cfg = (EXYNOS_CIICROFF_HORIZONTAL(img_pos.x) |
+		EXYNOS_CIICROFF_VERTICAL(img_pos.y));
+	fimc_write(cfg, EXYNOS_CIICROFF);
+
+	return fimc_set_window(ctx, &img_pos, &img_sz);
+}
+
+static int fimc_src_set_addr(struct device *dev,
+		struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
+		enum drm_exynos_ipp_buf_type buf_type)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
+	struct drm_exynos_ipp_property *property;
+	struct drm_exynos_ipp_config *config;
+
+	if (!c_node) {
+		DRM_ERROR("failed to get c_node.\n");
+		return -EINVAL;
+	}
+
+	property = &c_node->property;
+	if (!property) {
+		DRM_ERROR("failed to get property.\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
+		property->prop_id, buf_id, buf_type);
+
+	if (buf_id > FIMC_MAX_SRC) {
+		dev_info(ippdrv->dev, "inavlid buf_id %d.\n", buf_id);
+		return -ENOMEM;
+	}
+
+	/* address register set */
+	switch (buf_type) {
+	case IPP_BUF_ENQUEUE:
+		config = &property->config[EXYNOS_DRM_OPS_SRC];
+		fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
+			EXYNOS_CIIYSA(buf_id));
+
+		if (config->fmt == DRM_FORMAT_YVU420) {
+			fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
+				EXYNOS_CIICBSA(buf_id));
+			fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
+				EXYNOS_CIICRSA(buf_id));
+		} else {
+			fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
+				EXYNOS_CIICBSA(buf_id));
+			fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
+				EXYNOS_CIICRSA(buf_id));
+		}
+		break;
+	case IPP_BUF_DEQUEUE:
+		fimc_write(0x0, EXYNOS_CIIYSA(buf_id));
+		fimc_write(0x0, EXYNOS_CIICBSA(buf_id));
+		fimc_write(0x0, EXYNOS_CIICRSA(buf_id));
+		break;
+	default:
+		/* bypass */
+		break;
+	}
+
+	return 0;
+}
+
+static struct exynos_drm_ipp_ops fimc_src_ops = {
+	.set_fmt = fimc_src_set_fmt,
+	.set_transf = fimc_src_set_transf,
+	.set_size = fimc_src_set_size,
+	.set_addr = fimc_src_set_addr,
+};
+
+static int fimc_dst_set_fmt_order(struct fimc_context *ctx, u32 fmt)
+{
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
+
+	/* RGB */
+	cfg = fimc_read(EXYNOS_CISCCTRL);
+	cfg &= ~EXYNOS_CISCCTRL_OUTRGB_FMT_RGB_MASK;
+
+	switch (fmt) {
+	case DRM_FORMAT_RGB565:
+		cfg |= EXYNOS_CISCCTRL_OUTRGB_FMT_RGB565;
+		fimc_write(cfg, EXYNOS_CISCCTRL);
+		return 0;
+	case DRM_FORMAT_RGB888:
+		cfg |= EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888;
+		fimc_write(cfg, EXYNOS_CISCCTRL);
+		return 0;
+	case DRM_FORMAT_XRGB8888:
+		cfg |= (EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888 |
+			EXYNOS_CISCCTRL_EXTRGB_EXTENSION);
+		fimc_write(cfg, EXYNOS_CISCCTRL);
+		break;
+	default:
+		/* bypass */
+		break;
+	}
+
+	/* YUV */
+	cfg = fimc_read(EXYNOS_CIOCTRL);
+	cfg &= ~(EXYNOS_CIOCTRL_ORDER2P_MASK |
+		EXYNOS_CIOCTRL_ORDER422_MASK |
+		EXYNOS_CIOCTRL_YCBCR_PLANE_MASK);
+
+	switch (fmt) {
+	case DRM_FORMAT_XRGB8888:
+		cfg |= EXYNOS_CIOCTRL_ALPHA_OUT;
+		break;
+	case DRM_FORMAT_YUYV:
+		cfg |= EXYNOS_CIOCTRL_ORDER422_YCBYCR;
+		break;
+	case DRM_FORMAT_YVYU:
+		cfg |= EXYNOS_CIOCTRL_ORDER422_YCRYCB;
+		break;
+	case DRM_FORMAT_UYVY:
+		cfg |= EXYNOS_CIOCTRL_ORDER422_CBYCRY;
+		break;
+	case DRM_FORMAT_VYUY:
+		cfg |= EXYNOS_CIOCTRL_ORDER422_CRYCBY;
+		break;
+	case DRM_FORMAT_NV21:
+	case DRM_FORMAT_NV61:
+		cfg |= EXYNOS_CIOCTRL_ORDER2P_LSB_CRCB;
+		cfg |= EXYNOS_CIOCTRL_YCBCR_2PLANE;
+		break;
+	case DRM_FORMAT_YUV422:
+	case DRM_FORMAT_YUV420:
+	case DRM_FORMAT_YVU420:
+		cfg |= EXYNOS_CIOCTRL_YCBCR_3PLANE;
+		break;
+	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_NV12MT:
+	case DRM_FORMAT_NV16:
+		cfg |= EXYNOS_CIOCTRL_ORDER2P_LSB_CBCR;
+		cfg |= EXYNOS_CIOCTRL_YCBCR_2PLANE;
+		break;
+	default:
+		dev_err(ippdrv->dev, "inavlid target yuv order 0x%x.\n", fmt);
+		return -EINVAL;
+	}
+
+	fimc_write(cfg, EXYNOS_CIOCTRL);
+
+	return 0;
+}
+
+static int fimc_dst_set_fmt(struct device *dev, u32 fmt)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
+
+	cfg = fimc_read(EXYNOS_CIEXTEN);
+
+	if (fmt == DRM_FORMAT_AYUV) {
+		cfg |= EXYNOS_CIEXTEN_YUV444_OUT;
+		fimc_write(cfg, EXYNOS_CIEXTEN);
+	} else {
+		cfg &= ~EXYNOS_CIEXTEN_YUV444_OUT;
+		fimc_write(cfg, EXYNOS_CIEXTEN);
+
+		cfg = fimc_read(EXYNOS_CITRGFMT);
+		cfg &= ~EXYNOS_CITRGFMT_OUTFORMAT_MASK;
+
+		switch (fmt) {
+		case DRM_FORMAT_RGB565:
+		case DRM_FORMAT_RGB888:
+		case DRM_FORMAT_XRGB8888:
+			cfg |= EXYNOS_CITRGFMT_OUTFORMAT_RGB;
+			break;
+		case DRM_FORMAT_YUYV:
+		case DRM_FORMAT_YVYU:
+		case DRM_FORMAT_UYVY:
+		case DRM_FORMAT_VYUY:
+			cfg |= EXYNOS_CITRGFMT_OUTFORMAT_YCBCR422_1PLANE;
+			break;
+		case DRM_FORMAT_NV16:
+		case DRM_FORMAT_NV61:
+		case DRM_FORMAT_YUV422:
+			cfg |= EXYNOS_CITRGFMT_OUTFORMAT_YCBCR422;
+			break;
+		case DRM_FORMAT_YUV420:
+		case DRM_FORMAT_YVU420:
+		case DRM_FORMAT_NV12:
+		case DRM_FORMAT_NV12MT:
+		case DRM_FORMAT_NV21:
+			cfg |= EXYNOS_CITRGFMT_OUTFORMAT_YCBCR420;
+			break;
+		default:
+			dev_err(ippdrv->dev, "inavlid target format 0x%x.\n",
+				fmt);
+			return -EINVAL;
+		}
+
+		fimc_write(cfg, EXYNOS_CITRGFMT);
+	}
+
+	cfg = fimc_read(EXYNOS_CIDMAPARAM);
+	cfg &= ~EXYNOS_CIDMAPARAM_W_MODE_MASK;
+
+	if (fmt == DRM_FORMAT_NV12MT)
+		cfg |= EXYNOS_CIDMAPARAM_W_MODE_64X32;
+	else
+		cfg |= EXYNOS_CIDMAPARAM_W_MODE_LINEAR;
+
+	fimc_write(cfg, EXYNOS_CIDMAPARAM);
+
+	return fimc_dst_set_fmt_order(ctx, fmt);
+}
+
+static int fimc_dst_set_transf(struct device *dev,
+		enum drm_exynos_degree degree,
+		enum drm_exynos_flip flip)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:degree[%d]flip[0x%x]\n", __func__,
+		degree, flip);
+
+	cfg = fimc_read(EXYNOS_CITRGFMT);
+	cfg &= ~EXYNOS_CITRGFMT_FLIP_MASK;
+	cfg &= ~EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE;
+
+	switch (degree) {
+	case EXYNOS_DRM_DEGREE_0:
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg |= EXYNOS_CITRGFMT_FLIP_X_MIRROR;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg |= EXYNOS_CITRGFMT_FLIP_Y_MIRROR;
+		break;
+	case EXYNOS_DRM_DEGREE_90:
+		cfg |= EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE;
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg |= EXYNOS_CITRGFMT_FLIP_X_MIRROR;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg |= EXYNOS_CITRGFMT_FLIP_Y_MIRROR;
+		break;
+	case EXYNOS_DRM_DEGREE_180:
+		cfg |= (EXYNOS_CITRGFMT_FLIP_X_MIRROR |
+			EXYNOS_CITRGFMT_FLIP_Y_MIRROR);
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg &= ~EXYNOS_CITRGFMT_FLIP_X_MIRROR;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg &= ~EXYNOS_CITRGFMT_FLIP_Y_MIRROR;
+		break;
+	case EXYNOS_DRM_DEGREE_270:
+		cfg |= (EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE |
+			EXYNOS_CITRGFMT_FLIP_X_MIRROR |
+			EXYNOS_CITRGFMT_FLIP_Y_MIRROR);
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg &= ~EXYNOS_CITRGFMT_FLIP_X_MIRROR;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg &= ~EXYNOS_CITRGFMT_FLIP_Y_MIRROR;
+		break;
+	default:
+		dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
+		return -EINVAL;
+	}
+
+	fimc_write(cfg, EXYNOS_CITRGFMT);
+
+	return (cfg & EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE) ? 1 : 0;
+}
+
+static int fimc_get_ratio_shift(u32 src, u32 dst, u32 *ratio, u32 *shift)
+{
+	DRM_DEBUG_KMS("%s:src[%d]dst[%d]\n", __func__, src, dst);
+
+	if (src >= dst * 64) {
+		DRM_ERROR("failed to make ratio and shift.\n");
+		return -EINVAL;
+	} else if (src >= dst * 32) {
+		*ratio = 32;
+		*shift = 5;
+	} else if (src >= dst * 16) {
+		*ratio = 16;
+		*shift = 4;
+	} else if (src >= dst * 8) {
+		*ratio = 8;
+		*shift = 3;
+	} else if (src >= dst * 4) {
+		*ratio = 4;
+		*shift = 2;
+	} else if (src >= dst * 2) {
+		*ratio = 2;
+		*shift = 1;
+	} else {
+		*ratio = 1;
+		*shift = 0;
+	}
+
+	return 0;
+}
+
+static int fimc_set_prescaler(struct fimc_context *ctx, struct fimc_scaler *sc,
+		struct drm_exynos_pos *src, struct drm_exynos_pos *dst)
+{
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg, cfg_ext, shfactor;
+	u32 pre_dst_width, pre_dst_height;
+	u32 pre_hratio, hfactor, pre_vratio, vfactor;
+	int ret = 0;
+	u32 src_w, src_h, dst_w, dst_h;
+
+	cfg_ext = fimc_read(EXYNOS_CITRGFMT);
+	if (cfg_ext & EXYNOS_CITRGFMT_INROT90_CLOCKWISE) {
+		src_w = src->h;
+		src_h = src->w;
+	} else {
+		src_w = src->w;
+		src_h = src->h;
+	}
+
+	if (cfg_ext & EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE) {
+		dst_w = dst->h;
+		dst_h = dst->w;
+	} else {
+		dst_w = dst->w;
+		dst_h = dst->h;
+	}
+
+	ret = fimc_get_ratio_shift(src_w, dst_w, &pre_hratio, &hfactor);
+	if (ret) {
+		dev_err(ippdrv->dev, "failed to get ratio horizontal.\n");
+		return ret;
+	}
+
+	ret = fimc_get_ratio_shift(src_h, dst_h, &pre_vratio, &vfactor);
+	if (ret) {
+		dev_err(ippdrv->dev, "failed to get ratio vertical.\n");
+		return ret;
+	}
+
+	pre_dst_width = src_w / pre_hratio;
+	pre_dst_height = src_h / pre_vratio;
+	DRM_DEBUG_KMS("%s:pre_dst_width[%d]pre_dst_height[%d]\n", __func__,
+		pre_dst_width, pre_dst_height);
+	DRM_DEBUG_KMS("%s:pre_hratio[%d]hfactor[%d]pre_vratio[%d]vfactor[%d]\n",
+		__func__, pre_hratio, hfactor, pre_vratio, vfactor);
+
+	sc->hratio = (src_w << 14) / (dst_w << hfactor);
+	sc->vratio = (src_h << 14) / (dst_h << vfactor);
+	sc->up_h = (dst_w >= src_w) ? true : false;
+	sc->up_v = (dst_h >= src_h) ? true : false;
+	DRM_DEBUG_KMS("%s:hratio[%d]vratio[%d]up_h[%d]up_v[%d]\n",
+	__func__, sc->hratio, sc->vratio, sc->up_h, sc->up_v);
+
+	shfactor = FIMC_SHFACTOR - (hfactor + vfactor);
+	DRM_DEBUG_KMS("%s:shfactor[%d]\n", __func__, shfactor);
+
+	cfg = (EXYNOS_CISCPRERATIO_SHFACTOR(shfactor) |
+		EXYNOS_CISCPRERATIO_PREHORRATIO(pre_hratio) |
+		EXYNOS_CISCPRERATIO_PREVERRATIO(pre_vratio));
+	fimc_write(cfg, EXYNOS_CISCPRERATIO);
+
+	cfg = (EXYNOS_CISCPREDST_PREDSTWIDTH(pre_dst_width) |
+		EXYNOS_CISCPREDST_PREDSTHEIGHT(pre_dst_height));
+	fimc_write(cfg, EXYNOS_CISCPREDST);
+
+	return ret;
+}
+
+static void fimc_set_scaler(struct fimc_context *ctx, struct fimc_scaler *sc)
+{
+	u32 cfg, cfg_ext;
+
+	DRM_DEBUG_KMS("%s:range[%d]bypass[%d]up_h[%d]up_v[%d]\n",
+		__func__, sc->range, sc->bypass, sc->up_h, sc->up_v);
+	DRM_DEBUG_KMS("%s:hratio[%d]vratio[%d]\n",
+		__func__, sc->hratio, sc->vratio);
+
+	cfg = fimc_read(EXYNOS_CISCCTRL);
+	cfg &= ~(EXYNOS_CISCCTRL_SCALERBYPASS |
+		EXYNOS_CISCCTRL_SCALEUP_H | EXYNOS_CISCCTRL_SCALEUP_V |
+		EXYNOS_CISCCTRL_MAIN_V_RATIO_MASK |
+		EXYNOS_CISCCTRL_MAIN_H_RATIO_MASK |
+		EXYNOS_CISCCTRL_CSCR2Y_WIDE |
+		EXYNOS_CISCCTRL_CSCY2R_WIDE);
+
+	if (sc->range)
+		cfg |= (EXYNOS_CISCCTRL_CSCR2Y_WIDE |
+			EXYNOS_CISCCTRL_CSCY2R_WIDE);
+	if (sc->bypass)
+		cfg |= EXYNOS_CISCCTRL_SCALERBYPASS;
+	if (sc->up_h)
+		cfg |= EXYNOS_CISCCTRL_SCALEUP_H;
+	if (sc->up_v)
+		cfg |= EXYNOS_CISCCTRL_SCALEUP_V;
+
+	cfg |= (EXYNOS_CISCCTRL_MAINHORRATIO((sc->hratio >> 6)) |
+		EXYNOS_CISCCTRL_MAINVERRATIO((sc->vratio >> 6)));
+	fimc_write(cfg, EXYNOS_CISCCTRL);
+
+	cfg_ext = fimc_read(EXYNOS_CIEXTEN);
+	cfg_ext &= ~EXYNOS_CIEXTEN_MAINHORRATIO_EXT_MASK;
+	cfg_ext &= ~EXYNOS_CIEXTEN_MAINVERRATIO_EXT_MASK;
+	cfg_ext |= (EXYNOS_CIEXTEN_MAINHORRATIO_EXT(sc->hratio) |
+		EXYNOS_CIEXTEN_MAINVERRATIO_EXT(sc->vratio));
+	fimc_write(cfg_ext, EXYNOS_CIEXTEN);
+}
+
+static int fimc_dst_set_size(struct device *dev, int swap,
+		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct drm_exynos_pos img_pos = *pos;
+	struct drm_exynos_sz img_sz = *sz;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:swap[%d]hsize[%d]vsize[%d]\n",
+		__func__, swap, sz->hsize, sz->vsize);
+
+	/* original size */
+	cfg = (EXYNOS_ORGOSIZE_HORIZONTAL(img_sz.hsize) |
+		EXYNOS_ORGOSIZE_VERTICAL(img_sz.vsize));
+
+	fimc_write(cfg, EXYNOS_ORGOSIZE);
+
+	DRM_DEBUG_KMS("%s:x[%d]y[%d]w[%d]h[%d]\n",
+		__func__, pos->x, pos->y, pos->w, pos->h);
+
+	/* CSC ITU */
+	cfg = fimc_read(EXYNOS_CIGCTRL);
+	cfg &= ~EXYNOS_CIGCTRL_CSC_MASK;
+
+	if (sz->hsize >= FIMC_WIDTH_ITU_709)
+		cfg |= EXYNOS_CIGCTRL_CSC_ITU709;
+	else
+		cfg |= EXYNOS_CIGCTRL_CSC_ITU601;
+
+	fimc_write(cfg, EXYNOS_CIGCTRL);
+
+	if (swap) {
+		img_pos.w = pos->h;
+		img_pos.h = pos->w;
+		img_sz.hsize = sz->vsize;
+		img_sz.vsize = sz->hsize;
+	}
+
+	/* target image size */
+	cfg = fimc_read(EXYNOS_CITRGFMT);
+	cfg &= ~(EXYNOS_CITRGFMT_TARGETH_MASK |
+		EXYNOS_CITRGFMT_TARGETV_MASK);
+	cfg |= (EXYNOS_CITRGFMT_TARGETHSIZE(img_pos.w) |
+		EXYNOS_CITRGFMT_TARGETVSIZE(img_pos.h));
+	fimc_write(cfg, EXYNOS_CITRGFMT);
+
+	/* target area */
+	cfg = EXYNOS_CITAREA_TARGET_AREA(img_pos.w * img_pos.h);
+	fimc_write(cfg, EXYNOS_CITAREA);
+
+	/* ToDo: Move Scaler in this line and YUV */
+
+	/* offset Y(RGB), Cb, Cr */
+	cfg = (EXYNOS_CIOYOFF_HORIZONTAL(img_pos.x) |
+		EXYNOS_CIOYOFF_VERTICAL(img_pos.y));
+	fimc_write(cfg, EXYNOS_CIOYOFF);
+	cfg = (EXYNOS_CIOCBOFF_HORIZONTAL(img_pos.x) |
+		EXYNOS_CIOCBOFF_VERTICAL(img_pos.y));
+	fimc_write(cfg, EXYNOS_CIOCBOFF);
+	cfg = (EXYNOS_CIOCROFF_HORIZONTAL(img_pos.x) |
+		EXYNOS_CIOCROFF_VERTICAL(img_pos.y));
+	fimc_write(cfg, EXYNOS_CIOCROFF);
+
+	return 0;
+}
+
+static int fimc_dst_get_buf_seq(struct fimc_context *ctx)
+{
+	u32 cfg, i, buf_num = 0;
+	u32 mask = 0x00000001;
+
+	cfg = fimc_read(EXYNOS_CIFCNTSEQ);
+
+	for (i = 0; i < FIMC_REG_SZ; i++)
+		if (cfg & (mask << i))
+			buf_num++;
+
+	DRM_DEBUG_KMS("%s:buf_num[%d]\n", __func__, buf_num);
+
+	return buf_num;
+}
+
+static int fimc_dst_set_buf_seq(struct fimc_context *ctx, u32 buf_id,
+		enum drm_exynos_ipp_buf_type buf_type)
+{
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	bool enable;
+	u32 cfg;
+	u32 mask = 0x00000001 << buf_id;
+	int ret = 0;
+
+	DRM_DEBUG_KMS("%s:buf_id[%d]buf_type[%d]\n", __func__,
+		buf_id, buf_type);
+
+	mutex_lock(&ctx->lock);
+
+	/* mask register set */
+	cfg = fimc_read(EXYNOS_CIFCNTSEQ);
+
+	switch (buf_type) {
+	case IPP_BUF_ENQUEUE:
+		enable = true;
+		break;
+	case IPP_BUF_DEQUEUE:
+		enable = false;
+		break;
+	default:
+		dev_err(ippdrv->dev, "invalid buf ctrl parameter.\n");
+		ret =  -EINVAL;
+		goto err_unlock;
+	}
+
+	/* sequence id */
+	cfg &= (~mask);
+	cfg |= (enable << buf_id);
+	fimc_write(cfg, EXYNOS_CIFCNTSEQ);
+
+	/* interrupt enable */
+	if (buf_type == IPP_BUF_ENQUEUE &&
+	    fimc_dst_get_buf_seq(ctx) >= FIMC_BUF_START)
+		fimc_handle_irq(ctx, true, false, true);
+
+	/* interrupt disable */
+	if (buf_type == IPP_BUF_DEQUEUE &&
+	    fimc_dst_get_buf_seq(ctx) <= FIMC_BUF_STOP)
+		fimc_handle_irq(ctx, false, false, true);
+
+err_unlock:
+	mutex_unlock(&ctx->lock);
+	return ret;
+}
+
+static int fimc_dst_set_addr(struct device *dev,
+		struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
+		enum drm_exynos_ipp_buf_type buf_type)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
+	struct drm_exynos_ipp_property *property;
+	struct drm_exynos_ipp_config *config;
+
+	if (!c_node) {
+		DRM_ERROR("failed to get c_node.\n");
+		return -EINVAL;
+	}
+
+	property = &c_node->property;
+	if (!property) {
+		DRM_ERROR("failed to get property.\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
+		property->prop_id, buf_id, buf_type);
+
+	if (buf_id > FIMC_MAX_DST) {
+		dev_info(ippdrv->dev, "inavlid buf_id %d.\n", buf_id);
+		return -ENOMEM;
+	}
+
+	/* address register set */
+	switch (buf_type) {
+	case IPP_BUF_ENQUEUE:
+		config = &property->config[EXYNOS_DRM_OPS_DST];
+
+		fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
+			EXYNOS_CIOYSA(buf_id));
+
+		if (config->fmt == DRM_FORMAT_YVU420) {
+			fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
+				EXYNOS_CIOCBSA(buf_id));
+			fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
+				EXYNOS_CIOCRSA(buf_id));
+		} else {
+			fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
+				EXYNOS_CIOCBSA(buf_id));
+			fimc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
+				EXYNOS_CIOCRSA(buf_id));
+		}
+		break;
+	case IPP_BUF_DEQUEUE:
+		fimc_write(0x0, EXYNOS_CIOYSA(buf_id));
+		fimc_write(0x0, EXYNOS_CIOCBSA(buf_id));
+		fimc_write(0x0, EXYNOS_CIOCRSA(buf_id));
+		break;
+	default:
+		/* bypass */
+		break;
+	}
+
+	return fimc_dst_set_buf_seq(ctx, buf_id, buf_type);
+}
+
+static struct exynos_drm_ipp_ops fimc_dst_ops = {
+	.set_fmt = fimc_dst_set_fmt,
+	.set_transf = fimc_dst_set_transf,
+	.set_size = fimc_dst_set_size,
+	.set_addr = fimc_dst_set_addr,
+};
+
+static int fimc_clk_ctrl(struct fimc_context *ctx, bool enable)
+{
+	DRM_DEBUG_KMS("%s:enable[%d]\n", __func__, enable);
+
+	if (enable) {
+		clk_enable(ctx->sclk_fimc_clk);
+		clk_enable(ctx->fimc_clk);
+		clk_enable(ctx->wb_clk);
+		ctx->suspended = false;
+	} else {
+		clk_disable(ctx->sclk_fimc_clk);
+		clk_disable(ctx->fimc_clk);
+		clk_disable(ctx->wb_clk);
+		ctx->suspended = true;
+	}
+
+	return 0;
+}
+
+static irqreturn_t fimc_irq_handler(int irq, void *dev_id)
+{
+	struct fimc_context *ctx = dev_id;
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
+	struct drm_exynos_ipp_event_work *event_work =
+		c_node->event_work;
+	int buf_id;
+
+	DRM_DEBUG_KMS("%s:fimc id[%d]\n", __func__, ctx->id);
+
+	fimc_clear_irq(ctx);
+	if (fimc_check_ovf(ctx))
+		return IRQ_NONE;
+
+	if (!fimc_check_frame_end(ctx))
+		return IRQ_NONE;
+
+	buf_id = fimc_get_buf_id(ctx);
+	if (buf_id < 0)
+		return IRQ_HANDLED;
+
+	DRM_DEBUG_KMS("%s:buf_id[%d]\n", __func__, buf_id);
+
+	if (fimc_dst_set_buf_seq(ctx, buf_id, IPP_BUF_DEQUEUE) < 0) {
+		DRM_ERROR("failed to dequeue.\n");
+		return IRQ_HANDLED;
+	}
+
+	event_work->ippdrv = ippdrv;
+	event_work->buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
+	queue_work(ippdrv->event_workq, (struct work_struct *)event_work);
+
+	return IRQ_HANDLED;
+}
+
+static int fimc_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
+{
+	struct drm_exynos_ipp_prop_list *prop_list;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
+	if (!prop_list) {
+		DRM_ERROR("failed to alloc property list.\n");
+		return -ENOMEM;
+	}
+
+	/*ToDo : fix supported function list*/
+
+	prop_list->version = 1;
+	prop_list->writeback = 1;
+	prop_list->refresh_min = FIMC_REFRESH_MIN;
+	prop_list->refresh_max = FIMC_REFRESH_MAX;
+	prop_list->flip = (1 << EXYNOS_DRM_FLIP_NONE) |
+				(1 << EXYNOS_DRM_FLIP_VERTICAL) |
+				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
+	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
+				(1 << EXYNOS_DRM_DEGREE_90) |
+				(1 << EXYNOS_DRM_DEGREE_180) |
+				(1 << EXYNOS_DRM_DEGREE_270);
+	prop_list->csc = 1;
+	prop_list->crop = 1;
+	prop_list->crop_max.hsize = FIMC_CROP_MAX;
+	prop_list->crop_max.vsize = FIMC_CROP_MAX;
+	prop_list->crop_min.hsize = FIMC_CROP_MIN;
+	prop_list->crop_min.vsize = FIMC_CROP_MIN;
+	prop_list->scale = 1;
+	prop_list->scale_max.hsize = FIMC_SCALE_MAX;
+	prop_list->scale_max.vsize = FIMC_SCALE_MAX;
+	prop_list->scale_min.hsize = FIMC_SCALE_MIN;
+	prop_list->scale_min.vsize = FIMC_SCALE_MIN;
+
+	ippdrv->prop_list = prop_list;
+
+	return 0;
+}
+
+static int fimc_ippdrv_check_property(struct device *dev,
+		struct drm_exynos_ipp_property *property)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_prop_list *pp = ippdrv->prop_list;
+	struct drm_exynos_ipp_config *config;
+	struct drm_exynos_pos *pos;
+	struct drm_exynos_sz *sz;
+	bool swap;
+	int i;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	for_each_ipp_ops(i) {
+		if ((i == EXYNOS_DRM_OPS_SRC) &&
+			(property->cmd == IPP_CMD_WB))
+			continue;
+
+		config = &property->config[i];
+		pos = &config->pos;
+		sz = &config->sz;
+
+		/* check for flip */
+		switch (config->flip) {
+		case EXYNOS_DRM_FLIP_NONE:
+		case EXYNOS_DRM_FLIP_VERTICAL:
+		case EXYNOS_DRM_FLIP_HORIZONTAL:
+		case EXYNOS_DRM_FLIP_VERTICAL | EXYNOS_DRM_FLIP_HORIZONTAL:
+			/* No problem */
+			break;
+		default:
+			DRM_ERROR("invalid flip.\n");
+			goto err_property;
+		}
+
+		/* check for degree */
+		switch (config->degree) {
+		case EXYNOS_DRM_DEGREE_90:
+		case EXYNOS_DRM_DEGREE_270:
+			swap = true;
+			break;
+		case EXYNOS_DRM_DEGREE_0:
+		case EXYNOS_DRM_DEGREE_180:
+			swap = false;
+			break;
+		default:
+			DRM_ERROR("invalid degree.\n");
+			goto err_property;
+		}
+
+		/* check for buffer bound */
+		if ((pos->x + pos->w > sz->hsize) ||
+			(pos->y + pos->h > sz->vsize)) {
+			DRM_ERROR("out of buf bound.\n");
+			goto err_property;
+		}
+
+		/* check for crop */
+		if ((i == EXYNOS_DRM_OPS_SRC) && (pp->crop)) {
+			if (swap) {
+				if ((pos->h < pp->crop_min.hsize) ||
+					(sz->vsize > pp->crop_max.hsize) ||
+					(pos->w < pp->crop_min.vsize) ||
+					(sz->hsize > pp->crop_max.vsize)) {
+					DRM_ERROR("out of crop size.\n");
+					goto err_property;
+				}
+			} else {
+				if ((pos->w < pp->crop_min.hsize) ||
+					(sz->hsize > pp->crop_max.hsize) ||
+					(pos->h < pp->crop_min.vsize) ||
+					(sz->vsize > pp->crop_max.vsize)) {
+					DRM_ERROR("out of crop size.\n");
+					goto err_property;
+				}
+			}
+		}
+
+		/* check for scale */
+		if ((i == EXYNOS_DRM_OPS_DST) && (pp->scale)) {
+			if (swap) {
+				if ((pos->h < pp->scale_min.hsize) ||
+					(sz->vsize > pp->scale_max.hsize) ||
+					(pos->w < pp->scale_min.vsize) ||
+					(sz->hsize > pp->scale_max.vsize)) {
+					DRM_ERROR("out of scale size.\n");
+					goto err_property;
+				}
+			} else {
+				if ((pos->w < pp->scale_min.hsize) ||
+					(sz->hsize > pp->scale_max.hsize) ||
+					(pos->h < pp->scale_min.vsize) ||
+					(sz->vsize > pp->scale_max.vsize)) {
+					DRM_ERROR("out of scale size.\n");
+					goto err_property;
+				}
+			}
+		}
+	}
+
+	return 0;
+
+err_property:
+	for_each_ipp_ops(i) {
+		if ((i == EXYNOS_DRM_OPS_SRC) &&
+			(property->cmd == IPP_CMD_WB))
+			continue;
+
+		config = &property->config[i];
+		pos = &config->pos;
+		sz = &config->sz;
+
+		DRM_ERROR("[%s]f[%d]r[%d]pos[%d %d %d %d]sz[%d %d]\n",
+			i ? "dst" : "src", config->flip, config->degree,
+			pos->x, pos->y, pos->w, pos->h,
+			sz->hsize, sz->vsize);
+	}
+
+	return -EINVAL;
+}
+
+static void fimc_clear_addr(struct fimc_context *ctx)
+{
+	int i;
+
+	DRM_DEBUG_KMS("%s:\n", __func__);
+
+	for (i = 0; i < FIMC_MAX_SRC; i++) {
+		fimc_write(0, EXYNOS_CIIYSA(i));
+		fimc_write(0, EXYNOS_CIICBSA(i));
+		fimc_write(0, EXYNOS_CIICRSA(i));
+	}
+
+	for (i = 0; i < FIMC_MAX_DST; i++) {
+		fimc_write(0, EXYNOS_CIOYSA(i));
+		fimc_write(0, EXYNOS_CIOCBSA(i));
+		fimc_write(0, EXYNOS_CIOCRSA(i));
+	}
+}
+
+static int fimc_ippdrv_reset(struct device *dev)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	/* reset h/w block */
+	fimc_sw_reset(ctx, false);
+
+	/* reset scaler capability */
+	memset(&ctx->sc, 0x0, sizeof(ctx->sc));
+
+	fimc_clear_addr(ctx);
+
+	return 0;
+}
+
+static int fimc_check_prepare(struct fimc_context *ctx)
+{
+	/* ToDo: check prepare using read register */
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	return 0;
+}
+
+static int fimc_ippdrv_start(struct device *dev, enum drm_exynos_ipp_cmd cmd)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
+	struct drm_exynos_ipp_property *property;
+	struct drm_exynos_ipp_config *config;
+	struct drm_exynos_pos	img_pos[EXYNOS_DRM_OPS_MAX];
+	struct drm_exynos_ipp_set_wb set_wb;
+	int ret, i;
+	u32 cfg0, cfg1;
+
+	DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, cmd);
+
+	if (!c_node) {
+		DRM_ERROR("failed to get c_node.\n");
+		return -EINVAL;
+	}
+
+	property = &c_node->property;
+	if (!property) {
+		DRM_ERROR("failed to get property.\n");
+		return -EINVAL;
+	}
+
+	ret = fimc_check_prepare(ctx);
+	if (ret) {
+		dev_err(dev, "failed to check prepare.\n");
+		return ret;
+	}
+
+	fimc_handle_irq(ctx, true, false, true);
+
+	/* ToDo: window size, prescaler config */
+	for_each_ipp_ops(i) {
+		config = &property->config[i];
+		img_pos[i] = config->pos;
+	}
+
+	ret = fimc_set_prescaler(ctx, &ctx->sc,
+		&img_pos[EXYNOS_DRM_OPS_SRC],
+		&img_pos[EXYNOS_DRM_OPS_DST]);
+	if (ret) {
+		dev_err(dev, "failed to set precalser.\n");
+		return ret;
+	}
+
+	/* If set ture, we can save jpeg about screen */
+	fimc_handle_jpeg(ctx, false);
+	fimc_set_scaler(ctx, &ctx->sc);
+	fimc_set_polarity(ctx, &ctx->pol);
+
+	switch (cmd) {
+	case IPP_CMD_M2M:
+		fimc_set_type_ctrl(ctx, FIMC_WB_NONE);
+		fimc_handle_lastend(ctx, false);
+
+		/* setup dma */
+		cfg0 = fimc_read(EXYNOS_MSCTRL);
+		cfg0 &= ~EXYNOS_MSCTRL_INPUT_MASK;
+		cfg0 |= EXYNOS_MSCTRL_INPUT_MEMORY;
+		fimc_write(cfg0, EXYNOS_MSCTRL);
+		break;
+	case IPP_CMD_WB:
+		fimc_set_type_ctrl(ctx, FIMC_WB_A);
+		fimc_handle_lastend(ctx, true);
+
+		/* setup FIMD */
+		fimc_set_camblk_fimd0_wb(ctx);
+
+		/* ToDo: need to replace the property structure. */
+		set_wb.enable = 1;
+		set_wb.refresh = property->refresh_rate;
+		exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb);
+		break;
+	case IPP_CMD_OUTPUT:
+	default:
+		ret = -EINVAL;
+		dev_err(dev, "invalid operations.\n");
+		return ret;
+	}
+
+	/* Reset status */
+	fimc_write(0x0, EXYNOS_CISTATUS);
+
+	cfg0 = fimc_read(EXYNOS_CIIMGCPT);
+	cfg0 &= ~EXYNOS_CIIMGCPT_IMGCPTEN_SC;
+	cfg0 |= EXYNOS_CIIMGCPT_IMGCPTEN_SC;
+
+	/* Scaler */
+	cfg1 = fimc_read(EXYNOS_CISCCTRL);
+	cfg1 &= ~EXYNOS_CISCCTRL_SCAN_MASK;
+	cfg1 |= (EXYNOS_CISCCTRL_PROGRESSIVE |
+		EXYNOS_CISCCTRL_SCALERSTART);
+
+	fimc_write(cfg1, EXYNOS_CISCCTRL);
+
+	/* Enable image capture*/
+	cfg0 |= EXYNOS_CIIMGCPT_IMGCPTEN;
+	fimc_write(cfg0, EXYNOS_CIIMGCPT);
+
+	/* Disable frame end irq */
+	cfg0 = fimc_read(EXYNOS_CIGCTRL);
+	cfg0 &= ~EXYNOS_CIGCTRL_IRQ_END_DISABLE;
+	fimc_write(cfg0, EXYNOS_CIGCTRL);
+
+	cfg0 = fimc_read(EXYNOS_CIOCTRL);
+	cfg0 &= ~EXYNOS_CIOCTRL_WEAVE_MASK;
+	fimc_write(cfg0, EXYNOS_CIOCTRL);
+
+	/* ToDo: m2m start errata - refer fimd */
+	if (cmd == IPP_CMD_M2M) {
+		cfg0 = fimc_read(EXYNOS_MSCTRL);
+		cfg0 |= EXYNOS_MSCTRL_ENVID;
+		fimc_write(cfg0, EXYNOS_MSCTRL);
+
+		cfg0 = fimc_read(EXYNOS_MSCTRL);
+		cfg0 |= EXYNOS_MSCTRL_ENVID;
+		fimc_write(cfg0, EXYNOS_MSCTRL);
+	}
+
+	return 0;
+}
+
+static void fimc_ippdrv_stop(struct device *dev, enum drm_exynos_ipp_cmd cmd)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct drm_exynos_ipp_set_wb set_wb = {0, 0};
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, cmd);
+
+	switch (cmd) {
+	case IPP_CMD_M2M:
+		/* Source clear */
+		cfg = fimc_read(EXYNOS_MSCTRL);
+		cfg &= ~EXYNOS_MSCTRL_INPUT_MASK;
+		cfg &= ~EXYNOS_MSCTRL_ENVID;
+		fimc_write(cfg, EXYNOS_MSCTRL);
+		break;
+	case IPP_CMD_WB:
+		exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb);
+		break;
+	case IPP_CMD_OUTPUT:
+	default:
+		dev_err(dev, "invalid operations.\n");
+		break;
+	}
+
+	fimc_handle_irq(ctx, false, false, true);
+
+	/* reset sequence */
+	fimc_write(0x0, EXYNOS_CIFCNTSEQ);
+
+	/* Scaler disable */
+	cfg = fimc_read(EXYNOS_CISCCTRL);
+	cfg &= ~EXYNOS_CISCCTRL_SCALERSTART;
+	fimc_write(cfg, EXYNOS_CISCCTRL);
+
+	/* Disable image capture */
+	cfg = fimc_read(EXYNOS_CIIMGCPT);
+	cfg &= ~(EXYNOS_CIIMGCPT_IMGCPTEN_SC | EXYNOS_CIIMGCPT_IMGCPTEN);
+	fimc_write(cfg, EXYNOS_CIIMGCPT);
+
+	/* Enable frame end irq */
+	cfg = fimc_read(EXYNOS_CIGCTRL);
+	cfg |= EXYNOS_CIGCTRL_IRQ_END_DISABLE;
+	fimc_write(cfg, EXYNOS_CIGCTRL);
+}
+
+static int __devinit fimc_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct fimc_context *ctx;
+	struct clk	*parent_clk;
+	struct resource *res;
+	struct exynos_drm_ippdrv *ippdrv;
+	struct exynos_drm_fimc_pdata *pdata;
+	struct fimc_driverdata *ddata;
+	int ret;
+
+	pdata = pdev->dev.platform_data;
+	if (!pdata) {
+		dev_err(dev, "no platform data specified.\n");
+		return -EINVAL;
+	}
+
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	ddata = (struct fimc_driverdata *)
+		platform_get_device_id(pdev)->driver_data;
+
+	/* clock control */
+	ctx->sclk_fimc_clk = clk_get(dev, "sclk_fimc");
+	if (IS_ERR(ctx->sclk_fimc_clk)) {
+		dev_err(dev, "failed to get src fimc clock.\n");
+		ret = PTR_ERR(ctx->sclk_fimc_clk);
+		goto err_ctx;
+	}
+	clk_enable(ctx->sclk_fimc_clk);
+
+	ctx->fimc_clk = clk_get(dev, "fimc");
+	if (IS_ERR(ctx->fimc_clk)) {
+		dev_err(dev, "failed to get fimc clock.\n");
+		ret = PTR_ERR(ctx->fimc_clk);
+		clk_disable(ctx->sclk_fimc_clk);
+		clk_put(ctx->sclk_fimc_clk);
+		goto err_ctx;
+	}
+
+	ctx->wb_clk = clk_get(dev, "pxl_async0");
+	if (IS_ERR(ctx->wb_clk)) {
+		dev_err(dev, "failed to get writeback a clock.\n");
+		ret = PTR_ERR(ctx->wb_clk);
+		clk_disable(ctx->sclk_fimc_clk);
+		clk_put(ctx->sclk_fimc_clk);
+		clk_put(ctx->fimc_clk);
+		goto err_ctx;
+	}
+
+	ctx->wb_b_clk = clk_get(dev, "pxl_async1");
+	if (IS_ERR(ctx->wb_b_clk)) {
+		dev_err(dev, "failed to get writeback b clock.\n");
+		ret = PTR_ERR(ctx->wb_b_clk);
+		clk_disable(ctx->sclk_fimc_clk);
+		clk_put(ctx->sclk_fimc_clk);
+		clk_put(ctx->fimc_clk);
+		clk_put(ctx->wb_clk);
+		goto err_ctx;
+	}
+
+	parent_clk = clk_get(dev, ddata->parent_clk);
+
+	if (IS_ERR(parent_clk)) {
+		dev_err(dev, "failed to get parent clock.\n");
+		ret = PTR_ERR(parent_clk);
+		clk_disable(ctx->sclk_fimc_clk);
+		clk_put(ctx->sclk_fimc_clk);
+		clk_put(ctx->fimc_clk);
+		clk_put(ctx->wb_clk);
+		clk_put(ctx->wb_b_clk);
+		goto err_ctx;
+	}
+
+	if (clk_set_parent(ctx->sclk_fimc_clk, parent_clk)) {
+		dev_err(dev, "failed to set parent.\n");
+		ret = -EINVAL;
+		clk_put(parent_clk);
+		clk_disable(ctx->sclk_fimc_clk);
+		clk_put(ctx->sclk_fimc_clk);
+		clk_put(ctx->fimc_clk);
+		clk_put(ctx->wb_clk);
+		clk_put(ctx->wb_b_clk);
+		goto err_ctx;
+	}
+
+	clk_put(parent_clk);
+	clk_set_rate(ctx->sclk_fimc_clk, pdata->clk_rate);
+
+	/* resource memory */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(dev, "failed to find registers.\n");
+		ret = -ENOENT;
+		goto err_clk;
+	}
+
+	ctx->regs_res = request_mem_region(res->start, resource_size(res),
+					   dev_name(dev));
+	if (!ctx->regs_res) {
+		dev_err(dev, "failed to claim register region.\n");
+		ret = -ENOENT;
+		goto err_clk;
+	}
+
+	ctx->regs = ioremap(res->start, resource_size(res));
+	if (!ctx->regs) {
+		dev_err(dev, "failed to map registers.\n");
+		ret = -ENXIO;
+		goto err_req_region;
+	}
+
+	/* resource irq */
+	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!res) {
+		dev_err(dev, "failed to request irq resource.\n");
+		ret = -ENOENT;
+		goto err_get_regs;
+	}
+
+	ctx->irq = res->start;
+	ret = request_threaded_irq(ctx->irq, NULL, fimc_irq_handler,
+		IRQF_ONESHOT, "drm_fimc", ctx);
+	if (ret < 0) {
+		dev_err(dev, "failed to request irq.\n");
+		goto err_get_regs;
+	}
+
+	/* context initailization */
+	ctx->id = pdev->id;
+	ctx->pol = pdata->pol;
+	ctx->ddata = ddata;
+
+	ippdrv = &ctx->ippdrv;
+	ippdrv->dev = dev;
+	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &fimc_src_ops;
+	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &fimc_dst_ops;
+	ippdrv->check_property = fimc_ippdrv_check_property;
+	ippdrv->reset = fimc_ippdrv_reset;
+	ippdrv->start = fimc_ippdrv_start;
+	ippdrv->stop = fimc_ippdrv_stop;
+	ret = fimc_init_prop_list(ippdrv);
+	if (ret < 0) {
+		dev_err(dev, "failed to init property list.\n");
+		goto err_get_irq;
+	}
+
+	DRM_DEBUG_KMS("%s:id[%d]ippdrv[0x%x]\n", __func__, ctx->id,
+		(int)ippdrv);
+
+	mutex_init(&ctx->lock);
+	platform_set_drvdata(pdev, ctx);
+
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+
+	ret = exynos_drm_ippdrv_register(ippdrv);
+	if (ret < 0) {
+		dev_err(dev, "failed to register drm fimc device.\n");
+		goto err_ippdrv_register;
+	}
+
+	dev_info(&pdev->dev, "drm fimc registered successfully.\n");
+
+	return 0;
+
+err_ippdrv_register:
+	kfree(ippdrv->prop_list);
+	pm_runtime_disable(dev);
+	free_irq(ctx->irq, ctx);
+err_get_irq:
+	free_irq(ctx->irq, ctx);
+err_get_regs:
+	iounmap(ctx->regs);
+err_req_region:
+	release_resource(ctx->regs_res);
+	kfree(ctx->regs_res);
+err_clk:
+	clk_put(ctx->sclk_fimc_clk);
+	clk_put(ctx->fimc_clk);
+	clk_put(ctx->wb_clk);
+	clk_put(ctx->wb_b_clk);
+err_ctx:
+	kfree(ctx);
+	return ret;
+}
+
+static int __devexit fimc_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct fimc_context *ctx = get_fimc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+
+	kfree(ippdrv->prop_list);
+	exynos_drm_ippdrv_unregister(ippdrv);
+	mutex_destroy(&ctx->lock);
+
+	pm_runtime_set_suspended(dev);
+	pm_runtime_disable(dev);
+
+	free_irq(ctx->irq, ctx);
+	iounmap(ctx->regs);
+	release_resource(ctx->regs_res);
+	kfree(ctx->regs_res);
+
+	clk_put(ctx->sclk_fimc_clk);
+	clk_put(ctx->fimc_clk);
+	clk_put(ctx->wb_clk);
+	clk_put(ctx->wb_b_clk);
+
+	kfree(ctx);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int fimc_suspend(struct device *dev)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
+
+	if (pm_runtime_suspended(dev))
+		return 0;
+
+	return fimc_clk_ctrl(ctx, false);
+}
+
+static int fimc_resume(struct device *dev)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
+
+	if (!pm_runtime_suspended(dev))
+		return fimc_clk_ctrl(ctx, true);
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PM_RUNTIME
+static int fimc_runtime_suspend(struct device *dev)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
+
+	return  fimc_clk_ctrl(ctx, false);
+}
+
+static int fimc_runtime_resume(struct device *dev)
+{
+	struct fimc_context *ctx = get_fimc_context(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
+
+	return  fimc_clk_ctrl(ctx, true);
+}
+#endif
+
+static struct fimc_driverdata exynos4210_fimc_data = {
+	.parent_clk = "mout_mpll",
+};
+
+static struct fimc_driverdata exynos4410_fimc_data = {
+	.parent_clk = "mout_mpll_user",
+};
+
+static struct platform_device_id fimc_driver_ids[] = {
+	{
+		.name		= "exynos4210-fimc",
+		.driver_data	= (unsigned long)&exynos4210_fimc_data,
+	}, {
+		.name		= "exynos4412-fimc",
+		.driver_data	= (unsigned long)&exynos4410_fimc_data,
+	},
+	{},
+};
+MODULE_DEVICE_TABLE(platform, fimc_driver_ids);
+
+static const struct dev_pm_ops fimc_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(fimc_suspend, fimc_resume)
+	SET_RUNTIME_PM_OPS(fimc_runtime_suspend, fimc_runtime_resume, NULL)
+};
+
+/* ToDo: need to check use case platform_device_id */
+struct platform_driver fimc_driver = {
+	.probe		= fimc_probe,
+	.remove		= __devexit_p(fimc_remove),
+	.id_table		= fimc_driver_ids,
+	.driver		= {
+		.name	= "exynos-drm-fimc",
+		.owner	= THIS_MODULE,
+		.pm	= &fimc_pm_ops,
+	},
+};
+
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.h b/drivers/gpu/drm/exynos/exynos_drm_fimc.h
new file mode 100644
index 0000000..d9dbf0e
--- /dev/null
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Authors:
+ *	Eunchul Kim <chulspro.kim@samsung.com>
+ *	Jinyoung Jeon <jy0.jeon@samsung.com>
+ *	Sangmin Lee <lsmin.lee@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _EXYNOS_DRM_FIMC_H_
+#define _EXYNOS_DRM_FIMC_H_
+
+/* ToDo */
+
+#endif /* _EXYNOS_DRM_FIMC_H_ */
diff --git a/drivers/gpu/drm/exynos/regs-fimc.h b/drivers/gpu/drm/exynos/regs-fimc.h
new file mode 100644
index 0000000..b4f9ca1
--- /dev/null
+++ b/drivers/gpu/drm/exynos/regs-fimc.h
@@ -0,0 +1,669 @@
+/* drivers/gpu/drm/exynos/regs-fimc.h
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com/
+ *
+ * Register definition file for Samsung Camera Interface (FIMC) driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef EXYNOS_REGS_FIMC_H
+#define EXYNOS_REGS_FIMC_H
+
+/*
+ * Register part
+*/
+/* Input source format */
+#define EXYNOS_CISRCFMT		(0x00)
+/* Window offset */
+#define EXYNOS_CIWDOFST		(0x04)
+/* Global control */
+#define EXYNOS_CIGCTRL		(0x08)
+/* Window offset 2 */
+#define EXYNOS_CIWDOFST2	(0x14)
+/* Y 1st frame start address for output DMA */
+#define EXYNOS_CIOYSA1		(0x18)
+/* Y 2nd frame start address for output DMA */
+#define EXYNOS_CIOYSA2		(0x1c)
+/* Y 3rd frame start address for output DMA */
+#define EXYNOS_CIOYSA3		(0x20)
+/* Y 4th frame start address for output DMA */
+#define EXYNOS_CIOYSA4		(0x24)
+/* Cb 1st frame start address for output DMA */
+#define EXYNOS_CIOCBSA1		(0x28)
+/* Cb 2nd frame start address for output DMA */
+#define EXYNOS_CIOCBSA2		(0x2c)
+/* Cb 3rd frame start address for output DMA */
+#define EXYNOS_CIOCBSA3		(0x30)
+/* Cb 4th frame start address for output DMA */
+#define EXYNOS_CIOCBSA4		(0x34)
+/* Cr 1st frame start address for output DMA */
+#define EXYNOS_CIOCRSA1		(0x38)
+/* Cr 2nd frame start address for output DMA */
+#define EXYNOS_CIOCRSA2		(0x3c)
+/* Cr 3rd frame start address for output DMA */
+#define EXYNOS_CIOCRSA3		(0x40)
+/* Cr 4th frame start address for output DMA */
+#define EXYNOS_CIOCRSA4		(0x44)
+/* Target image format */
+#define EXYNOS_CITRGFMT		(0x48)
+/* Output DMA control */
+#define EXYNOS_CIOCTRL		(0x4c)
+/* Pre-scaler control 1 */
+#define EXYNOS_CISCPRERATIO	(0x50)
+/* Pre-scaler control 2 */
+#define EXYNOS_CISCPREDST		(0x54)
+/* Main scaler control */
+#define EXYNOS_CISCCTRL		(0x58)
+/* Target area */
+#define EXYNOS_CITAREA		(0x5c)
+/* Status */
+#define EXYNOS_CISTATUS		(0x64)
+/* Status2 */
+#define EXYNOS_CISTATUS2		(0x68)
+/* Image capture enable command */
+#define EXYNOS_CIIMGCPT		(0xc0)
+/* Capture sequence */
+#define EXYNOS_CICPTSEQ		(0xc4)
+/* Image effects */
+#define EXYNOS_CIIMGEFF		(0xd0)
+/* Y frame start address for input DMA */
+#define EXYNOS_CIIYSA0		(0xd4)
+/* Cb frame start address for input DMA */
+#define EXYNOS_CIICBSA0		(0xd8)
+/* Cr frame start address for input DMA */
+#define EXYNOS_CIICRSA0		(0xdc)
+/* Input DMA Y Line Skip */
+#define EXYNOS_CIILINESKIP_Y	(0xec)
+/* Input DMA Cb Line Skip */
+#define EXYNOS_CIILINESKIP_CB	(0xf0)
+/* Input DMA Cr Line Skip */
+#define EXYNOS_CIILINESKIP_CR	(0xf4)
+/* Real input DMA image size */
+#define EXYNOS_CIREAL_ISIZE	(0xf8)
+/* Input DMA control */
+#define EXYNOS_MSCTRL		(0xfc)
+/* Y frame start address for input DMA */
+#define EXYNOS_CIIYSA1		(0x144)
+/* Cb frame start address for input DMA */
+#define EXYNOS_CIICBSA1		(0x148)
+/* Cr frame start address for input DMA */
+#define EXYNOS_CIICRSA1		(0x14c)
+/* Output DMA Y offset */
+#define EXYNOS_CIOYOFF		(0x168)
+/* Output DMA CB offset */
+#define EXYNOS_CIOCBOFF		(0x16c)
+/* Output DMA CR offset */
+#define EXYNOS_CIOCROFF		(0x170)
+/* Input DMA Y offset */
+#define EXYNOS_CIIYOFF		(0x174)
+/* Input DMA CB offset */
+#define EXYNOS_CIICBOFF		(0x178)
+/* Input DMA CR offset */
+#define EXYNOS_CIICROFF		(0x17c)
+/* Input DMA original image size */
+#define EXYNOS_ORGISIZE		(0x180)
+/* Output DMA original image size */
+#define EXYNOS_ORGOSIZE		(0x184)
+/* Real output DMA image size */
+#define EXYNOS_CIEXTEN		(0x188)
+/* DMA parameter */
+#define EXYNOS_CIDMAPARAM		(0x18c)
+/* MIPI CSI image format */
+#define EXYNOS_CSIIMGFMT		(0x194)
+/* FIMC Clock Source Select */
+#define EXYNOS_MISC_FIMC		(0x198)
+
+/* Add for FIMC v5.1 */
+/* Output Frame Buffer Sequence */
+#define EXYNOS_CIFCNTSEQ		(0x1fc)
+/* Y 5th frame start address for output DMA */
+#define EXYNOS_CIOYSA5		(0x200)
+/* Y 6th frame start address for output DMA */
+#define EXYNOS_CIOYSA6		(0x204)
+/* Y 7th frame start address for output DMA */
+#define EXYNOS_CIOYSA7		(0x208)
+/* Y 8th frame start address for output DMA */
+#define EXYNOS_CIOYSA8		(0x20c)
+/* Y 9th frame start address for output DMA */
+#define EXYNOS_CIOYSA9		(0x210)
+/* Y 10th frame start address for output DMA */
+#define EXYNOS_CIOYSA10		(0x214)
+/* Y 11th frame start address for output DMA */
+#define EXYNOS_CIOYSA11		(0x218)
+/* Y 12th frame start address for output DMA */
+#define EXYNOS_CIOYSA12		(0x21c)
+/* Y 13th frame start address for output DMA */
+#define EXYNOS_CIOYSA13		(0x220)
+/* Y 14th frame start address for output DMA */
+#define EXYNOS_CIOYSA14		(0x224)
+/* Y 15th frame start address for output DMA */
+#define EXYNOS_CIOYSA15		(0x228)
+/* Y 16th frame start address for output DMA */
+#define EXYNOS_CIOYSA16		(0x22c)
+/* Y 17th frame start address for output DMA */
+#define EXYNOS_CIOYSA17		(0x230)
+/* Y 18th frame start address for output DMA */
+#define EXYNOS_CIOYSA18		(0x234)
+/* Y 19th frame start address for output DMA */
+#define EXYNOS_CIOYSA19		(0x238)
+/* Y 20th frame start address for output DMA */
+#define EXYNOS_CIOYSA20		(0x23c)
+/* Y 21th frame start address for output DMA */
+#define EXYNOS_CIOYSA21		(0x240)
+/* Y 22th frame start address for output DMA */
+#define EXYNOS_CIOYSA22		(0x244)
+/* Y 23th frame start address for output DMA */
+#define EXYNOS_CIOYSA23		(0x248)
+/* Y 24th frame start address for output DMA */
+#define EXYNOS_CIOYSA24		(0x24c)
+/* Y 25th frame start address for output DMA */
+#define EXYNOS_CIOYSA25		(0x250)
+/* Y 26th frame start address for output DMA */
+#define EXYNOS_CIOYSA26		(0x254)
+/* Y 27th frame start address for output DMA */
+#define EXYNOS_CIOYSA27		(0x258)
+/* Y 28th frame start address for output DMA */
+#define EXYNOS_CIOYSA28		(0x25c)
+/* Y 29th frame start address for output DMA */
+#define EXYNOS_CIOYSA29		(0x260)
+/* Y 30th frame start address for output DMA */
+#define EXYNOS_CIOYSA30		(0x264)
+/* Y 31th frame start address for output DMA */
+#define EXYNOS_CIOYSA31		(0x268)
+/* Y 32th frame start address for output DMA */
+#define EXYNOS_CIOYSA32		(0x26c)
+
+/* CB 5th frame start address for output DMA */
+#define EXYNOS_CIOCBSA5		(0x270)
+/* CB 6th frame start address for output DMA */
+#define EXYNOS_CIOCBSA6		(0x274)
+/* CB 7th frame start address for output DMA */
+#define EXYNOS_CIOCBSA7		(0x278)
+/* CB 8th frame start address for output DMA */
+#define EXYNOS_CIOCBSA8		(0x27c)
+/* CB 9th frame start address for output DMA */
+#define EXYNOS_CIOCBSA9		(0x280)
+/* CB 10th frame start address for output DMA */
+#define EXYNOS_CIOCBSA10		(0x284)
+/* CB 11th frame start address for output DMA */
+#define EXYNOS_CIOCBSA11		(0x288)
+/* CB 12th frame start address for output DMA */
+#define EXYNOS_CIOCBSA12		(0x28c)
+/* CB 13th frame start address for output DMA */
+#define EXYNOS_CIOCBSA13		(0x290)
+/* CB 14th frame start address for output DMA */
+#define EXYNOS_CIOCBSA14		(0x294)
+/* CB 15th frame start address for output DMA */
+#define EXYNOS_CIOCBSA15		(0x298)
+/* CB 16th frame start address for output DMA */
+#define EXYNOS_CIOCBSA16		(0x29c)
+/* CB 17th frame start address for output DMA */
+#define EXYNOS_CIOCBSA17		(0x2a0)
+/* CB 18th frame start address for output DMA */
+#define EXYNOS_CIOCBSA18		(0x2a4)
+/* CB 19th frame start address for output DMA */
+#define EXYNOS_CIOCBSA19		(0x2a8)
+/* CB 20th frame start address for output DMA */
+#define EXYNOS_CIOCBSA20		(0x2ac)
+/* CB 21th frame start address for output DMA */
+#define EXYNOS_CIOCBSA21		(0x2b0)
+/* CB 22th frame start address for output DMA */
+#define EXYNOS_CIOCBSA22		(0x2b4)
+/* CB 23th frame start address for output DMA */
+#define EXYNOS_CIOCBSA23		(0x2b8)
+/* CB 24th frame start address for output DMA */
+#define EXYNOS_CIOCBSA24		(0x2bc)
+/* CB 25th frame start address for output DMA */
+#define EXYNOS_CIOCBSA25		(0x2c0)
+/* CB 26th frame start address for output DMA */
+#define EXYNOS_CIOCBSA26		(0x2c4)
+/* CB 27th frame start address for output DMA */
+#define EXYNOS_CIOCBSA27		(0x2c8)
+/* CB 28th frame start address for output DMA */
+#define EXYNOS_CIOCBSA28		(0x2cc)
+/* CB 29th frame start address for output DMA */
+#define EXYNOS_CIOCBSA29		(0x2d0)
+/* CB 30th frame start address for output DMA */
+#define EXYNOS_CIOCBSA30		(0x2d4)
+/* CB 31th frame start address for output DMA */
+#define EXYNOS_CIOCBSA31		(0x2d8)
+/* CB 32th frame start address for output DMA */
+#define EXYNOS_CIOCBSA32		(0x2dc)
+
+/* CR 5th frame start address for output DMA */
+#define EXYNOS_CIOCRSA5		(0x2e0)
+/* CR 6th frame start address for output DMA */
+#define EXYNOS_CIOCRSA6		(0x2e4)
+/* CR 7th frame start address for output DMA */
+#define EXYNOS_CIOCRSA7		(0x2e8)
+/* CR 8th frame start address for output DMA */
+#define EXYNOS_CIOCRSA8		(0x2ec)
+/* CR 9th frame start address for output DMA */
+#define EXYNOS_CIOCRSA9		(0x2f0)
+/* CR 10th frame start address for output DMA */
+#define EXYNOS_CIOCRSA10		(0x2f4)
+/* CR 11th frame start address for output DMA */
+#define EXYNOS_CIOCRSA11		(0x2f8)
+/* CR 12th frame start address for output DMA */
+#define EXYNOS_CIOCRSA12		(0x2fc)
+/* CR 13th frame start address for output DMA */
+#define EXYNOS_CIOCRSA13		(0x300)
+/* CR 14th frame start address for output DMA */
+#define EXYNOS_CIOCRSA14		(0x304)
+/* CR 15th frame start address for output DMA */
+#define EXYNOS_CIOCRSA15		(0x308)
+/* CR 16th frame start address for output DMA */
+#define EXYNOS_CIOCRSA16		(0x30c)
+/* CR 17th frame start address for output DMA */
+#define EXYNOS_CIOCRSA17		(0x310)
+/* CR 18th frame start address for output DMA */
+#define EXYNOS_CIOCRSA18		(0x314)
+/* CR 19th frame start address for output DMA */
+#define EXYNOS_CIOCRSA19		(0x318)
+/* CR 20th frame start address for output DMA */
+#define EXYNOS_CIOCRSA20		(0x31c)
+/* CR 21th frame start address for output DMA */
+#define EXYNOS_CIOCRSA21		(0x320)
+/* CR 22th frame start address for output DMA */
+#define EXYNOS_CIOCRSA22		(0x324)
+/* CR 23th frame start address for output DMA */
+#define EXYNOS_CIOCRSA23		(0x328)
+/* CR 24th frame start address for output DMA */
+#define EXYNOS_CIOCRSA24		(0x32c)
+/* CR 25th frame start address for output DMA */
+#define EXYNOS_CIOCRSA25		(0x330)
+/* CR 26th frame start address for output DMA */
+#define EXYNOS_CIOCRSA26		(0x334)
+/* CR 27th frame start address for output DMA */
+#define EXYNOS_CIOCRSA27		(0x338)
+/* CR 28th frame start address for output DMA */
+#define EXYNOS_CIOCRSA28		(0x33c)
+/* CR 29th frame start address for output DMA */
+#define EXYNOS_CIOCRSA29		(0x340)
+/* CR 30th frame start address for output DMA */
+#define EXYNOS_CIOCRSA30		(0x344)
+/* CR 31th frame start address for output DMA */
+#define EXYNOS_CIOCRSA31		(0x348)
+/* CR 32th frame start address for output DMA */
+#define EXYNOS_CIOCRSA32		(0x34c)
+
+/*
+ * Macro part
+*/
+/* frame start address 1 ~ 4, 5 ~ 32 */
+/* Number of Default PingPong Memory */
+#define DEF_PP		4
+#define EXYNOS_CIOYSA(__x)		\
+	(((__x) < DEF_PP) ?	\
+	 (EXYNOS_CIOYSA1  + (__x) * 4) : \
+	(EXYNOS_CIOYSA5  + ((__x) - DEF_PP) * 4))
+#define EXYNOS_CIOCBSA(__x)	\
+	(((__x) < DEF_PP) ?	\
+	 (EXYNOS_CIOCBSA1 + (__x) * 4) : \
+	(EXYNOS_CIOCBSA5 + ((__x) - DEF_PP) * 4))
+#define EXYNOS_CIOCRSA(__x)	\
+	(((__x) < DEF_PP) ?	\
+	 (EXYNOS_CIOCRSA1 + (__x) * 4) : \
+	(EXYNOS_CIOCRSA5 + ((__x) - DEF_PP) * 4))
+/* Number of Default PingPong Memory */
+#define DEF_IPP		1
+#define EXYNOS_CIIYSA(__x)		\
+	(((__x) < DEF_IPP) ?	\
+	 (EXYNOS_CIIYSA0) : (EXYNOS_CIIYSA1))
+#define EXYNOS_CIICBSA(__x)	\
+	(((__x) < DEF_IPP) ?	\
+	 (EXYNOS_CIICBSA0) : (EXYNOS_CIICBSA1))
+#define EXYNOS_CIICRSA(__x)	\
+	(((__x) < DEF_IPP) ?	\
+	 (EXYNOS_CIICRSA0) : (EXYNOS_CIICRSA1))
+
+#define EXYNOS_CISRCFMT_SOURCEHSIZE(x)		((x) << 16)
+#define EXYNOS_CISRCFMT_SOURCEVSIZE(x)		((x) << 0)
+
+#define EXYNOS_CIWDOFST_WINHOROFST(x)		((x) << 16)
+#define EXYNOS_CIWDOFST_WINVEROFST(x)		((x) << 0)
+
+#define EXYNOS_CIWDOFST2_WINHOROFST2(x)		((x) << 16)
+#define EXYNOS_CIWDOFST2_WINVEROFST2(x)		((x) << 0)
+
+#define EXYNOS_CITRGFMT_TARGETHSIZE(x)		(((x) & 0x1fff) << 16)
+#define EXYNOS_CITRGFMT_TARGETVSIZE(x)		(((x) & 0x1fff) << 0)
+
+#define EXYNOS_CISCPRERATIO_SHFACTOR(x)		((x) << 28)
+#define EXYNOS_CISCPRERATIO_PREHORRATIO(x)		((x) << 16)
+#define EXYNOS_CISCPRERATIO_PREVERRATIO(x)		((x) << 0)
+
+#define EXYNOS_CISCPREDST_PREDSTWIDTH(x)		((x) << 16)
+#define EXYNOS_CISCPREDST_PREDSTHEIGHT(x)		((x) << 0)
+
+#define EXYNOS_CISCCTRL_MAINHORRATIO(x)		((x) << 16)
+#define EXYNOS_CISCCTRL_MAINVERRATIO(x)		((x) << 0)
+
+#define EXYNOS_CITAREA_TARGET_AREA(x)		((x) << 0)
+
+#define EXYNOS_CISTATUS_GET_FRAME_COUNT(x)		(((x) >> 26) & 0x3)
+#define EXYNOS_CISTATUS_GET_FRAME_END(x)		(((x) >> 17) & 0x1)
+#define EXYNOS_CISTATUS_GET_LAST_CAPTURE_END(x)	(((x) >> 16) & 0x1)
+#define EXYNOS_CISTATUS_GET_LCD_STATUS(x)		(((x) >> 9) & 0x1)
+#define EXYNOS_CISTATUS_GET_ENVID_STATUS(x)	(((x) >> 8) & 0x1)
+
+#define EXYNOS_CISTATUS2_GET_FRAMECOUNT_BEFORE(x)	(((x) >> 7) & 0x3f)
+#define EXYNOS_CISTATUS2_GET_FRAMECOUNT_PRESENT(x)	((x) & 0x3f)
+
+#define EXYNOS_CIIMGEFF_FIN(x)			((x & 0x7) << 26)
+#define EXYNOS_CIIMGEFF_PAT_CB(x)			((x) << 13)
+#define EXYNOS_CIIMGEFF_PAT_CR(x)			((x) << 0)
+
+#define EXYNOS_CIILINESKIP(x)			(((x) & 0xf) << 24)
+
+#define EXYNOS_CIREAL_ISIZE_HEIGHT(x)		((x) << 16)
+#define EXYNOS_CIREAL_ISIZE_WIDTH(x)		((x) << 0)
+
+#define EXYNOS_MSCTRL_SUCCESSIVE_COUNT(x)		((x) << 24)
+#define EXYNOS_MSCTRL_GET_INDMA_STATUS(x)		((x) & 0x1)
+
+#define EXYNOS_CIOYOFF_VERTICAL(x)			((x) << 16)
+#define EXYNOS_CIOYOFF_HORIZONTAL(x)		((x) << 0)
+
+#define EXYNOS_CIOCBOFF_VERTICAL(x)		((x) << 16)
+#define EXYNOS_CIOCBOFF_HORIZONTAL(x)		((x) << 0)
+
+#define EXYNOS_CIOCROFF_VERTICAL(x)		((x) << 16)
+#define EXYNOS_CIOCROFF_HORIZONTAL(x)		((x) << 0)
+
+#define EXYNOS_CIIYOFF_VERTICAL(x)			((x) << 16)
+#define EXYNOS_CIIYOFF_HORIZONTAL(x)		((x) << 0)
+
+#define EXYNOS_CIICBOFF_VERTICAL(x)		((x) << 16)
+#define EXYNOS_CIICBOFF_HORIZONTAL(x)		((x) << 0)
+
+#define EXYNOS_CIICROFF_VERTICAL(x)		((x) << 16)
+#define EXYNOS_CIICROFF_HORIZONTAL(x)		((x) << 0)
+
+#define EXYNOS_ORGISIZE_VERTICAL(x)		((x) << 16)
+#define EXYNOS_ORGISIZE_HORIZONTAL(x)		((x) << 0)
+
+#define EXYNOS_ORGOSIZE_VERTICAL(x)		((x) << 16)
+#define EXYNOS_ORGOSIZE_HORIZONTAL(x)		((x) << 0)
+
+#define EXYNOS_CIEXTEN_TARGETH_EXT(x)		((((x) & 0x2000) >> 13) << 26)
+#define EXYNOS_CIEXTEN_TARGETV_EXT(x)		((((x) & 0x2000) >> 13) << 24)
+#define EXYNOS_CIEXTEN_MAINHORRATIO_EXT(x)		(((x) & 0x3F) << 10)
+#define EXYNOS_CIEXTEN_MAINVERRATIO_EXT(x)		((x) & 0x3F)
+
+/*
+ * Bit definition part
+*/
+/* Source format register */
+#define EXYNOS_CISRCFMT_ITU601_8BIT		(1 << 31)
+#define EXYNOS_CISRCFMT_ITU656_8BIT		(0 << 31)
+#define EXYNOS_CISRCFMT_ITU601_16BIT		(1 << 29)
+#define EXYNOS_CISRCFMT_ORDER422_YCBYCR		(0 << 14)
+#define EXYNOS_CISRCFMT_ORDER422_YCRYCB		(1 << 14)
+#define EXYNOS_CISRCFMT_ORDER422_CBYCRY		(2 << 14)
+#define EXYNOS_CISRCFMT_ORDER422_CRYCBY		(3 << 14)
+/* ITU601 16bit only */
+#define EXYNOS_CISRCFMT_ORDER422_Y4CBCRCBCR	(0 << 14)
+/* ITU601 16bit only */
+#define EXYNOS_CISRCFMT_ORDER422_Y4CRCBCRCB	(1 << 14)
+
+/* Window offset register */
+#define EXYNOS_CIWDOFST_WINOFSEN			(1 << 31)
+#define EXYNOS_CIWDOFST_CLROVFIY			(1 << 30)
+#define EXYNOS_CIWDOFST_CLROVRLB			(1 << 29)
+#define EXYNOS_CIWDOFST_WINHOROFST_MASK		(0x7ff << 16)
+#define EXYNOS_CIWDOFST_CLROVFICB			(1 << 15)
+#define EXYNOS_CIWDOFST_CLROVFICR			(1 << 14)
+#define EXYNOS_CIWDOFST_WINVEROFST_MASK		(0xfff << 0)
+
+/* Global control register */
+#define EXYNOS_CIGCTRL_SWRST			(1 << 31)
+#define EXYNOS_CIGCTRL_CAMRST_A			(1 << 30)
+#define EXYNOS_CIGCTRL_SELCAM_ITU_B		(0 << 29)
+#define EXYNOS_CIGCTRL_SELCAM_ITU_A		(1 << 29)
+#define EXYNOS_CIGCTRL_SELCAM_ITU_MASK		(1 << 29)
+#define EXYNOS_CIGCTRL_TESTPATTERN_NORMAL		(0 << 27)
+#define EXYNOS_CIGCTRL_TESTPATTERN_COLOR_BAR	(1 << 27)
+#define EXYNOS_CIGCTRL_TESTPATTERN_HOR_INC		(2 << 27)
+#define EXYNOS_CIGCTRL_TESTPATTERN_VER_INC		(3 << 27)
+#define EXYNOS_CIGCTRL_TESTPATTERN_MASK		(3 << 27)
+#define EXYNOS_CIGCTRL_TESTPATTERN_SHIFT		(27)
+#define EXYNOS_CIGCTRL_INVPOLPCLK			(1 << 26)
+#define EXYNOS_CIGCTRL_INVPOLVSYNC			(1 << 25)
+#define EXYNOS_CIGCTRL_INVPOLHREF			(1 << 24)
+#define EXYNOS_CIGCTRL_IRQ_OVFEN			(1 << 22)
+#define EXYNOS_CIGCTRL_HREF_MASK			(1 << 21)
+#define EXYNOS_CIGCTRL_IRQ_EDGE			(0 << 20)
+#define EXYNOS_CIGCTRL_IRQ_LEVEL			(1 << 20)
+#define EXYNOS_CIGCTRL_IRQ_CLR			(1 << 19)
+#define EXYNOS_CIGCTRL_IRQ_END_DISABLE		(1 << 18)
+#define EXYNOS_CIGCTRL_IRQ_DISABLE			(0 << 16)
+#define EXYNOS_CIGCTRL_IRQ_ENABLE			(1 << 16)
+#define EXYNOS_CIGCTRL_SHADOW_DISABLE		(1 << 12)
+#define EXYNOS_CIGCTRL_CAM_JPEG			(1 << 8)
+#define EXYNOS_CIGCTRL_SELCAM_MIPI_B		(0 << 7)
+#define EXYNOS_CIGCTRL_SELCAM_MIPI_A		(1 << 7)
+#define EXYNOS_CIGCTRL_SELCAM_MIPI_MASK		(1 << 7)
+#define EXYNOS_CIGCTRL_SELWB_CAMIF_CAMERA	(0 << 6)
+#define EXYNOS_CIGCTRL_SELWB_CAMIF_WRITEBACK	(1 << 6)
+#define EXYNOS_CIGCTRL_SELWRITEBACK_MASK		(1 << 10)
+#define EXYNOS_CIGCTRL_SELWRITEBACK_A		(1 << 10)
+#define EXYNOS_CIGCTRL_SELWRITEBACK_B		(0 << 10)
+#define EXYNOS_CIGCTRL_SELWB_CAMIF_MASK		(1 << 6)
+#define EXYNOS_CIGCTRL_CSC_ITU601			(0 << 5)
+#define EXYNOS_CIGCTRL_CSC_ITU709			(1 << 5)
+#define EXYNOS_CIGCTRL_CSC_MASK			(1 << 5)
+#define EXYNOS_CIGCTRL_INVPOLHSYNC			(1 << 4)
+#define EXYNOS_CIGCTRL_SELCAM_FIMC_ITU		(0 << 3)
+#define EXYNOS_CIGCTRL_SELCAM_FIMC_MIPI		(1 << 3)
+#define EXYNOS_CIGCTRL_SELCAM_FIMC_MASK		(1 << 3)
+#define EXYNOS_CIGCTRL_PROGRESSIVE			(0 << 0)
+#define EXYNOS_CIGCTRL_INTERLACE			(1 << 0)
+
+/* Window offset2 register */
+#define EXYNOS_CIWDOFST_WINHOROFST2_MASK		(0xfff << 16)
+#define EXYNOS_CIWDOFST_WINVEROFST2_MASK		(0xfff << 16)
+
+/* Target format register */
+#define EXYNOS_CITRGFMT_INROT90_CLOCKWISE		(1 << 31)
+#define EXYNOS_CITRGFMT_OUTFORMAT_YCBCR420		(0 << 29)
+#define EXYNOS_CITRGFMT_OUTFORMAT_YCBCR422		(1 << 29)
+#define EXYNOS_CITRGFMT_OUTFORMAT_YCBCR422_1PLANE	(2 << 29)
+#define EXYNOS_CITRGFMT_OUTFORMAT_RGB		(3 << 29)
+#define EXYNOS_CITRGFMT_OUTFORMAT_MASK		(3 << 29)
+#define EXYNOS_CITRGFMT_FLIP_SHIFT			(14)
+#define EXYNOS_CITRGFMT_FLIP_NORMAL		(0 << 14)
+#define EXYNOS_CITRGFMT_FLIP_X_MIRROR		(1 << 14)
+#define EXYNOS_CITRGFMT_FLIP_Y_MIRROR		(2 << 14)
+#define EXYNOS_CITRGFMT_FLIP_180			(3 << 14)
+#define EXYNOS_CITRGFMT_FLIP_MASK			(3 << 14)
+#define EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE		(1 << 13)
+#define EXYNOS_CITRGFMT_TARGETV_MASK		(0x1fff << 0)
+#define EXYNOS_CITRGFMT_TARGETH_MASK		(0x1fff << 16)
+
+/* Output DMA control register */
+#define EXYNOS_CIOCTRL_WEAVE_OUT			(1 << 31)
+#define EXYNOS_CIOCTRL_WEAVE_MASK			(1 << 31)
+#define EXYNOS_CIOCTRL_LASTENDEN			(1 << 30)
+#define EXYNOS_CIOCTRL_ORDER2P_LSB_CBCR		(0 << 24)
+#define EXYNOS_CIOCTRL_ORDER2P_LSB_CRCB		(1 << 24)
+#define EXYNOS_CIOCTRL_ORDER2P_MSB_CRCB		(2 << 24)
+#define EXYNOS_CIOCTRL_ORDER2P_MSB_CBCR		(3 << 24)
+#define EXYNOS_CIOCTRL_ORDER2P_SHIFT		(24)
+#define EXYNOS_CIOCTRL_ORDER2P_MASK		(3 << 24)
+#define EXYNOS_CIOCTRL_YCBCR_3PLANE		(0 << 3)
+#define EXYNOS_CIOCTRL_YCBCR_2PLANE		(1 << 3)
+#define EXYNOS_CIOCTRL_YCBCR_PLANE_MASK		(1 << 3)
+#define EXYNOS_CIOCTRL_LASTIRQ_ENABLE		(1 << 2)
+#define EXYNOS_CIOCTRL_ALPHA_OUT			(0xff << 4)
+#define EXYNOS_CIOCTRL_ORDER422_YCBYCR		(0 << 0)
+#define EXYNOS_CIOCTRL_ORDER422_YCRYCB		(1 << 0)
+#define EXYNOS_CIOCTRL_ORDER422_CBYCRY		(2 << 0)
+#define EXYNOS_CIOCTRL_ORDER422_CRYCBY		(3 << 0)
+#define EXYNOS_CIOCTRL_ORDER422_MASK		(3 << 0)
+
+/* Main scaler control register */
+#define EXYNOS_CISCCTRL_SCALERBYPASS		(1 << 31)
+#define EXYNOS_CISCCTRL_SCALEUP_H			(1 << 30)
+#define EXYNOS_CISCCTRL_SCALEUP_V			(1 << 29)
+#define EXYNOS_CISCCTRL_CSCR2Y_NARROW		(0 << 28)
+#define EXYNOS_CISCCTRL_CSCR2Y_WIDE		(1 << 28)
+#define EXYNOS_CISCCTRL_CSCY2R_NARROW		(0 << 27)
+#define EXYNOS_CISCCTRL_CSCY2R_WIDE		(1 << 27)
+#define EXYNOS_CISCCTRL_LCDPATHEN_FIFO		(1 << 26)
+#define EXYNOS_CISCCTRL_PROGRESSIVE		(0 << 25)
+#define EXYNOS_CISCCTRL_INTERLACE			(1 << 25)
+#define EXYNOS_CISCCTRL_SCAN_MASK			(1 << 25)
+#define EXYNOS_CISCCTRL_SCALERSTART		(1 << 15)
+#define EXYNOS_CISCCTRL_INRGB_FMT_RGB565		(0 << 13)
+#define EXYNOS_CISCCTRL_INRGB_FMT_RGB666		(1 << 13)
+#define EXYNOS_CISCCTRL_INRGB_FMT_RGB888		(2 << 13)
+#define EXYNOS_CISCCTRL_INRGB_FMT_RGB_MASK		(3 << 13)
+#define EXYNOS_CISCCTRL_OUTRGB_FMT_RGB565		(0 << 11)
+#define EXYNOS_CISCCTRL_OUTRGB_FMT_RGB666		(1 << 11)
+#define EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888		(2 << 11)
+#define EXYNOS_CISCCTRL_OUTRGB_FMT_RGB_MASK	(3 << 11)
+#define EXYNOS_CISCCTRL_EXTRGB_NORMAL		(0 << 10)
+#define EXYNOS_CISCCTRL_EXTRGB_EXTENSION		(1 << 10)
+#define EXYNOS_CISCCTRL_ONE2ONE			(1 << 9)
+#define EXYNOS_CISCCTRL_MAIN_V_RATIO_MASK		(0x1ff << 0)
+#define EXYNOS_CISCCTRL_MAIN_H_RATIO_MASK		(0x1ff << 16)
+
+/* Status register */
+#define EXYNOS_CISTATUS_OVFIY			(1 << 31)
+#define EXYNOS_CISTATUS_OVFICB			(1 << 30)
+#define EXYNOS_CISTATUS_OVFICR			(1 << 29)
+#define EXYNOS_CISTATUS_VSYNC			(1 << 28)
+#define EXYNOS_CISTATUS_SCALERSTART		(1 << 26)
+#define EXYNOS_CISTATUS_WINOFSTEN			(1 << 25)
+#define EXYNOS_CISTATUS_IMGCPTEN			(1 << 22)
+#define EXYNOS_CISTATUS_IMGCPTENSC			(1 << 21)
+#define EXYNOS_CISTATUS_VSYNC_A			(1 << 20)
+#define EXYNOS_CISTATUS_VSYNC_B			(1 << 19)
+#define EXYNOS_CISTATUS_OVRLB			(1 << 18)
+#define EXYNOS_CISTATUS_FRAMEEND			(1 << 17)
+#define EXYNOS_CISTATUS_LASTCAPTUREEND		(1 << 16)
+#define EXYNOS_CISTATUS_VVALID_A			(1 << 15)
+#define EXYNOS_CISTATUS_VVALID_B			(1 << 14)
+
+/* Image capture enable register */
+#define EXYNOS_CIIMGCPT_IMGCPTEN			(1 << 31)
+#define EXYNOS_CIIMGCPT_IMGCPTEN_SC		(1 << 30)
+#define EXYNOS_CIIMGCPT_CPT_FREN_ENABLE		(1 << 25)
+#define EXYNOS_CIIMGCPT_CPT_FRMOD_EN		(0 << 18)
+#define EXYNOS_CIIMGCPT_CPT_FRMOD_CNT		(1 << 18)
+
+/* Image effects register */
+#define EXYNOS_CIIMGEFF_IE_DISABLE			(0 << 30)
+#define EXYNOS_CIIMGEFF_IE_ENABLE			(1 << 30)
+#define EXYNOS_CIIMGEFF_IE_SC_BEFORE		(0 << 29)
+#define EXYNOS_CIIMGEFF_IE_SC_AFTER		(1 << 29)
+#define EXYNOS_CIIMGEFF_FIN_BYPASS			(0 << 26)
+#define EXYNOS_CIIMGEFF_FIN_ARBITRARY		(1 << 26)
+#define EXYNOS_CIIMGEFF_FIN_NEGATIVE		(2 << 26)
+#define EXYNOS_CIIMGEFF_FIN_ARTFREEZE		(3 << 26)
+#define EXYNOS_CIIMGEFF_FIN_EMBOSSING		(4 << 26)
+#define EXYNOS_CIIMGEFF_FIN_SILHOUETTE		(5 << 26)
+#define EXYNOS_CIIMGEFF_FIN_MASK			(7 << 26)
+#define EXYNOS_CIIMGEFF_PAT_CBCR_MASK		((0xff < 13) | (0xff < 0))
+
+/* Real input DMA size register */
+#define EXYNOS_CIREAL_ISIZE_AUTOLOAD_ENABLE	(1 << 31)
+#define EXYNOS_CIREAL_ISIZE_ADDR_CH_DISABLE	(1 << 30)
+#define EXYNOS_CIREAL_ISIZE_HEIGHT_MASK		(0x3FFF << 16)
+#define EXYNOS_CIREAL_ISIZE_WIDTH_MASK		(0x3FFF << 0)
+
+/* Input DMA control register */
+#define EXYNOS_MSCTRL_FIELD_MASK			(1 << 31)
+#define EXYNOS_MSCTRL_FIELD_WEAVE			(1 << 31)
+#define EXYNOS_MSCTRL_FIELD_NORMAL			(0 << 31)
+#define EXYNOS_MSCTRL_BURST_CNT			(24)
+#define EXYNOS_MSCTRL_BURST_CNT_MASK		(0xf << 24)
+#define EXYNOS_MSCTRL_ORDER2P_LSB_CBCR		(0 << 16)
+#define EXYNOS_MSCTRL_ORDER2P_LSB_CRCB		(1 << 16)
+#define EXYNOS_MSCTRL_ORDER2P_MSB_CRCB		(2 << 16)
+#define EXYNOS_MSCTRL_ORDER2P_MSB_CBCR		(3 << 16)
+#define EXYNOS_MSCTRL_ORDER2P_SHIFT		(16)
+#define EXYNOS_MSCTRL_ORDER2P_SHIFT_MASK		(0x3 << 16)
+#define EXYNOS_MSCTRL_C_INT_IN_3PLANE		(0 << 15)
+#define EXYNOS_MSCTRL_C_INT_IN_2PLANE		(1 << 15)
+#define EXYNOS_MSCTRL_FLIP_SHIFT			(13)
+#define EXYNOS_MSCTRL_FLIP_NORMAL			(0 << 13)
+#define EXYNOS_MSCTRL_FLIP_X_MIRROR		(1 << 13)
+#define EXYNOS_MSCTRL_FLIP_Y_MIRROR		(2 << 13)
+#define EXYNOS_MSCTRL_FLIP_180			(3 << 13)
+#define EXYNOS_MSCTRL_FLIP_MASK			(3 << 13)
+#define EXYNOS_MSCTRL_ORDER422_CRYCBY		(0 << 4)
+#define EXYNOS_MSCTRL_ORDER422_YCRYCB		(1 << 4)
+#define EXYNOS_MSCTRL_ORDER422_CBYCRY		(2 << 4)
+#define EXYNOS_MSCTRL_ORDER422_YCBYCR		(3 << 4)
+#define EXYNOS_MSCTRL_INPUT_EXTCAM			(0 << 3)
+#define EXYNOS_MSCTRL_INPUT_MEMORY			(1 << 3)
+#define EXYNOS_MSCTRL_INPUT_MASK			(1 << 3)
+#define EXYNOS_MSCTRL_INFORMAT_YCBCR420		(0 << 1)
+#define EXYNOS_MSCTRL_INFORMAT_YCBCR422		(1 << 1)
+#define EXYNOS_MSCTRL_INFORMAT_YCBCR422_1PLANE	(2 << 1)
+#define EXYNOS_MSCTRL_INFORMAT_RGB			(3 << 1)
+#define EXYNOS_MSCTRL_ENVID			(1 << 0)
+
+/* DMA parameter register */
+#define EXYNOS_CIDMAPARAM_R_MODE_LINEAR		(0 << 29)
+#define EXYNOS_CIDMAPARAM_R_MODE_CONFTILE		(1 << 29)
+#define EXYNOS_CIDMAPARAM_R_MODE_16X16		(2 << 29)
+#define EXYNOS_CIDMAPARAM_R_MODE_64X32		(3 << 29)
+#define EXYNOS_CIDMAPARAM_R_MODE_MASK		(3 << 29)
+#define EXYNOS_CIDMAPARAM_R_TILE_HSIZE_64		(0 << 24)
+#define EXYNOS_CIDMAPARAM_R_TILE_HSIZE_128		(1 << 24)
+#define EXYNOS_CIDMAPARAM_R_TILE_HSIZE_256		(2 << 24)
+#define EXYNOS_CIDMAPARAM_R_TILE_HSIZE_512		(3 << 24)
+#define EXYNOS_CIDMAPARAM_R_TILE_HSIZE_1024	(4 << 24)
+#define EXYNOS_CIDMAPARAM_R_TILE_HSIZE_2048	(5 << 24)
+#define EXYNOS_CIDMAPARAM_R_TILE_HSIZE_4096	(6 << 24)
+#define EXYNOS_CIDMAPARAM_R_TILE_VSIZE_1		(0 << 20)
+#define EXYNOS_CIDMAPARAM_R_TILE_VSIZE_2		(1 << 20)
+#define EXYNOS_CIDMAPARAM_R_TILE_VSIZE_4		(2 << 20)
+#define EXYNOS_CIDMAPARAM_R_TILE_VSIZE_8		(3 << 20)
+#define EXYNOS_CIDMAPARAM_R_TILE_VSIZE_16		(4 << 20)
+#define EXYNOS_CIDMAPARAM_R_TILE_VSIZE_32		(5 << 20)
+#define EXYNOS_CIDMAPARAM_W_MODE_LINEAR		(0 << 13)
+#define EXYNOS_CIDMAPARAM_W_MODE_CONFTILE		(1 << 13)
+#define EXYNOS_CIDMAPARAM_W_MODE_16X16		(2 << 13)
+#define EXYNOS_CIDMAPARAM_W_MODE_64X32		(3 << 13)
+#define EXYNOS_CIDMAPARAM_W_MODE_MASK		(3 << 13)
+#define EXYNOS_CIDMAPARAM_W_TILE_HSIZE_64		(0 << 8)
+#define EXYNOS_CIDMAPARAM_W_TILE_HSIZE_128		(1 << 8)
+#define EXYNOS_CIDMAPARAM_W_TILE_HSIZE_256		(2 << 8)
+#define EXYNOS_CIDMAPARAM_W_TILE_HSIZE_512		(3 << 8)
+#define EXYNOS_CIDMAPARAM_W_TILE_HSIZE_1024	(4 << 8)
+#define EXYNOS_CIDMAPARAM_W_TILE_HSIZE_2048	(5 << 8)
+#define EXYNOS_CIDMAPARAM_W_TILE_HSIZE_4096	(6 << 8)
+#define EXYNOS_CIDMAPARAM_W_TILE_VSIZE_1		(0 << 4)
+#define EXYNOS_CIDMAPARAM_W_TILE_VSIZE_2		(1 << 4)
+#define EXYNOS_CIDMAPARAM_W_TILE_VSIZE_4		(2 << 4)
+#define EXYNOS_CIDMAPARAM_W_TILE_VSIZE_8		(3 << 4)
+#define EXYNOS_CIDMAPARAM_W_TILE_VSIZE_16		(4 << 4)
+#define EXYNOS_CIDMAPARAM_W_TILE_VSIZE_32		(5 << 4)
+
+/* Gathering Extension register */
+#define EXYNOS_CIEXTEN_TARGETH_EXT_MASK		(1 << 26)
+#define EXYNOS_CIEXTEN_TARGETV_EXT_MASK		(1 << 24)
+#define EXYNOS_CIEXTEN_MAINHORRATIO_EXT_MASK	(0x3F << 10)
+#define EXYNOS_CIEXTEN_MAINVERRATIO_EXT_MASK	(0x3F)
+#define EXYNOS_CIEXTEN_YUV444_OUT			(1 << 22)
+
+/* FIMC Clock Source Select register */
+#define EXYNOS_CLKSRC_HCLK				(0 << 1)
+#define EXYNOS_CLKSRC_HCLK_MASK			(1 << 1)
+#define EXYNOS_CLKSRC_SCLK				(1 << 1)
+
+/* SYSREG for FIMC writeback */
+#define SYSREG_CAMERA_BLK			(S3C_VA_SYS + 0x0218)
+#define SYSREG_ISP_BLK				(S3C_VA_SYS + 0x020c)
+#define SYSREG_FIMD0WB_DEST_MASK	(0x3 << 23)
+#define SYSREG_FIMD0WB_DEST_SHIFT	23
+
+#endif /* EXYNOS_REGS_FIMC_H */
diff --git a/include/drm/exynos_drm.h b/include/drm/exynos_drm.h
index 3c13a3a..808dad2 100644
--- a/include/drm/exynos_drm.h
+++ b/include/drm/exynos_drm.h
@@ -85,4 +85,30 @@ struct exynos_drm_hdmi_pdata {
 	int (*get_hpd)(void);
 };
 
+/**
+ * Platform Specific Structure for DRM based IPP.
+ *
+ * @inv_pclk: if set 1. invert pixel clock
+ * @inv_vsync: if set 1. invert vsync signal for wb
+ * @inv_href: if set 1. invert href signal
+ * @inv_hsync: if set 1. invert hsync signal for wb
+ */
+struct exynos_drm_ipp_pol {
+	unsigned int inv_pclk;
+	unsigned int inv_vsync;
+	unsigned int inv_href;
+	unsigned int inv_hsync;
+};
+
+/**
+ * Platform Specific Structure for DRM based FIMC.
+ *
+ * @pol: current hardware block polarity settings.
+ * @clk_rate: current hardware clock rate.
+ */
+struct exynos_drm_fimc_pdata {
+	struct exynos_drm_ipp_pol pol;
+	int clk_rate;
+};
+
 #endif	/* _EXYNOS_DRM_H_ */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC v3 4/5] drm/exynos: add rotator ipp driver
  2012-12-12  7:34 [RFC v3 0/5] drm/exynos: add ipp subsystem and each ipp drivers Eunchul Kim
                   ` (2 preceding siblings ...)
  2012-12-12  7:34 ` [RFC v3 3/5] drm/exynos: add fimc ipp driver Eunchul Kim
@ 2012-12-12  7:34 ` Eunchul Kim
  2012-12-12  8:29   ` Inki Dae
  2012-12-12  7:34 ` [RFC v3 5/5] drm/exynos: add gsc " Eunchul Kim
  4 siblings, 1 reply; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12  7:34 UTC (permalink / raw)
  To: dri-devel, inki.dae; +Cc: jy0.jeon, jaejoon.seo, kyungmin.park, jmock.shin

Rotator supports rotation/crop/flip and input/output DMA operations
Rotator ipp driver supports 90,180,270 degree rotaion and vertical, horizontal flip.
and has some limitations(source and destination format have to be same, no scaler)

Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
Signed-off-by: Youngjun Cho <yj44.cho@samsung.com>
---
 drivers/gpu/drm/exynos/Kconfig              |    7 +
 drivers/gpu/drm/exynos/Makefile             |    1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c     |   15 +
 drivers/gpu/drm/exynos/exynos_drm_drv.h     |    1 +
 drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829 +++++++++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
 drivers/gpu/drm/exynos/regs-rotator.h       |   73 +++
 7 files changed, 939 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
 create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 4915ab6..4860835 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -57,3 +57,10 @@ config DRM_EXYNOS_FIMC
 	depends on DRM_EXYNOS_IPP
 	help
 	  Choose this option if you want to use Exynos FIMC for DRM.
+
+config DRM_EXYNOS_ROTATOR
+	bool "Exynos DRM Rotator"
+	depends on DRM_EXYNOS_IPP
+	help
+	  Choose this option if you want to use Exynos Rotator for DRM.
+
diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 9710024..3b70668 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+= exynos_drm_vidi.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
+exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
 
 obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 73f02ac..09d884b 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -378,6 +378,12 @@ static int __init exynos_drm_init(void)
 		goto out_fimc;
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_ROTATOR
+	ret = platform_driver_register(&rotator_driver);
+	if (ret < 0)
+		goto out_rotator;
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_IPP
 	ret = platform_driver_register(&ipp_driver);
 	if (ret < 0)
@@ -406,6 +412,11 @@ out_drm:
 out_ipp:
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_ROTATOR
+	platform_driver_unregister(&rotator_driver);
+out_rotator:
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_FIMC
 	platform_driver_unregister(&fimc_driver);
 out_fimc:
@@ -451,6 +462,10 @@ static void __exit exynos_drm_exit(void)
 	platform_driver_unregister(&ipp_driver);
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_ROTATOR
+	platform_driver_unregister(&rotator_driver);
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_FIMC
 	platform_driver_unregister(&fimc_driver);
 #endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 14f9490..a74e37c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -353,5 +353,6 @@ extern struct platform_driver exynos_drm_common_hdmi_driver;
 extern struct platform_driver vidi_driver;
 extern struct platform_driver g2d_driver;
 extern struct platform_driver fimc_driver;
+extern struct platform_driver rotator_driver;
 extern struct platform_driver ipp_driver;
 #endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
new file mode 100644
index 0000000..121569c
--- /dev/null
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
@@ -0,0 +1,829 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics Co.Ltd
+ * Authors:
+ *	YoungJun Cho <yj44.cho@samsung.com>
+ *	Eunchul Kim <chulspro.kim@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundationr
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/pm_runtime.h>
+
+#include <drm/drmP.h>
+#include <drm/exynos_drm.h>
+#include "regs-rotator.h"
+#include "exynos_drm.h"
+#include "exynos_drm_ipp.h"
+
+/*
+ * Rotator supports image crop/rotator and input/output DMA operations.
+ * input DMA reads image data from the memory.
+ * output DMA writes image data to memory.
+ */
+
+#define get_rot_context(dev)	platform_get_drvdata(to_platform_device(dev))
+#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
+					struct rot_context, ippdrv);
+#define rot_read(offset)		readl(rot->regs + (offset))
+#define rot_write(cfg, offset)	writel(cfg, rot->regs + (offset))
+
+enum rot_irq_status {
+	ROT_IRQ_STATUS_COMPLETE	= 8,
+	ROT_IRQ_STATUS_ILLEGAL	= 9,
+};
+
+/*
+ * A structure of limitation.
+ *
+ * @min_w: minimum width.
+ * @min_h: minimum height.
+ * @max_w: maximum width.
+ * @max_h: maximum height.
+ * @align: align size.
+ */
+struct rot_limit {
+	u32	min_w;
+	u32	min_h;
+	u32	max_w;
+	u32	max_h;
+	u32	align;
+};
+
+/*
+ * A structure of limitation table.
+ *
+ * @ycbcr420_2p: case of YUV.
+ * @rgb888: case of RGB.
+ */
+struct rot_limit_table {
+	struct rot_limit	ycbcr420_2p;
+	struct rot_limit	rgb888;
+};
+
+/*
+ * A structure of rotator context.
+ * @ippdrv: prepare initialization using ippdrv.
+ * @regs_res: register resources.
+ * @regs: memory mapped io registers.
+ * @clock: rotator gate clock.
+ * @limit_tbl: limitation of rotator.
+ * @irq: irq number.
+ * @cur_buf_id: current operation buffer id.
+ * @suspended: suspended state.
+ */
+struct rot_context {
+	struct exynos_drm_ippdrv	ippdrv;
+	struct resource	*regs_res;
+	void __iomem	*regs;
+	struct clk	*clock;
+	struct rot_limit_table	*limit_tbl;
+	int	irq;
+	int	cur_buf_id[EXYNOS_DRM_OPS_MAX];
+	bool	suspended;
+};
+
+static void rotator_reg_set_irq(struct rot_context *rot, bool enable)
+{
+	u32 val = rot_read(ROT_CONFIG);
+
+	if (enable == true)
+		val |= ROT_CONFIG_IRQ;
+	else
+		val &= ~ROT_CONFIG_IRQ;
+
+	rot_write(val, ROT_CONFIG);
+}
+
+static u32 rotator_reg_get_format(struct rot_context *rot)
+{
+	u32 val = rot_read(ROT_CONTROL);
+
+	val &= ROT_CONTROL_FMT_MASK;
+
+	return val;
+}
+
+static enum rot_irq_status rotator_reg_get_irq_status(struct rot_context *rot)
+{
+	u32 val = rot_read(ROT_STATUS);
+
+	val = ROT_STATUS_IRQ(val);
+
+	if (val == ROT_STATUS_IRQ_VAL_COMPLETE)
+		return ROT_IRQ_STATUS_COMPLETE;
+	else
+		return ROT_IRQ_STATUS_ILLEGAL;
+}
+
+static irqreturn_t rotator_irq_handler(int irq, void *arg)
+{
+	struct rot_context *rot = arg;
+	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
+	struct drm_exynos_ipp_event_work *event_work = c_node->event_work;
+	enum rot_irq_status irq_status;
+	u32 val;
+
+	/* Get execution result */
+	irq_status = rotator_reg_get_irq_status(rot);
+
+	/* clear status */
+	val = rot_read(ROT_STATUS);
+	val |= ROT_STATUS_IRQ_PENDING((u32)irq_status);
+	rot_write(val, ROT_STATUS);
+
+	if (irq_status == ROT_IRQ_STATUS_COMPLETE) {
+		event_work->ippdrv = ippdrv;
+		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
+			rot->cur_buf_id[EXYNOS_DRM_OPS_DST];
+		queue_work(ippdrv->event_workq,
+			(struct work_struct *)event_work);
+	} else
+		DRM_ERROR("the SFR is set illegally\n");
+
+	return IRQ_HANDLED;
+}
+
+static void rotator_align_size(struct rot_context *rot, u32 fmt, u32 *hsize,
+		u32 *vsize)
+{
+	struct rot_limit_table *limit_tbl = rot->limit_tbl;
+	struct rot_limit *limit;
+	u32 mask, val;
+
+	/* Get size limit */
+	if (fmt == ROT_CONTROL_FMT_RGB888)
+		limit = &limit_tbl->rgb888;
+	else
+		limit = &limit_tbl->ycbcr420_2p;
+
+	/* Get mask for rounding to nearest aligned val */
+	mask = ~((1 << limit->align) - 1);
+
+	/* Set aligned width */
+	val = ROT_ALIGN(*hsize, limit->align, mask);
+	if (val < limit->min_w)
+		*hsize = ROT_MIN(limit->min_w, mask);
+	else if (val > limit->max_w)
+		*hsize = ROT_MAX(limit->max_w, mask);
+	else
+		*hsize = val;
+
+	/* Set aligned height */
+	val = ROT_ALIGN(*vsize, limit->align, mask);
+	if (val < limit->min_h)
+		*vsize = ROT_MIN(limit->min_h, mask);
+	else if (val > limit->max_h)
+		*vsize = ROT_MAX(limit->max_h, mask);
+	else
+		*vsize = val;
+}
+
+static int rotator_src_set_fmt(struct device *dev, u32 fmt)
+{
+	struct rot_context *rot = dev_get_drvdata(dev);
+	u32 val;
+
+	val = rot_read(ROT_CONTROL);
+	val &= ~ROT_CONTROL_FMT_MASK;
+
+	switch (fmt) {
+	case DRM_FORMAT_NV12:
+		val |= ROT_CONTROL_FMT_YCBCR420_2P;
+		break;
+	case DRM_FORMAT_XRGB8888:
+		val |= ROT_CONTROL_FMT_RGB888;
+		break;
+	default:
+		DRM_ERROR("invalid image format\n");
+		return -EINVAL;
+	}
+
+	rot_write(val, ROT_CONTROL);
+
+	return 0;
+}
+
+static int rotator_src_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;
+	u32 val;
+
+	/* 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 */
+	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
+	rot_write(val, ROT_SRC_BUF_SIZE);
+
+	/* Set crop image position configuration */
+	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
+	rot_write(val, ROT_SRC_CROP_POS);
+	val = ROT_SRC_CROP_SIZE_H(pos->h) | ROT_SRC_CROP_SIZE_W(pos->w);
+	rot_write(val, ROT_SRC_CROP_SIZE);
+
+	return 0;
+}
+
+static int rotator_src_set_addr(struct device *dev,
+		struct drm_exynos_ipp_buf_info *buf_info,
+		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
+{
+	struct rot_context *rot = dev_get_drvdata(dev);
+	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
+	u32 val, fmt, hsize, vsize;
+	int i;
+
+	/* Set current buf_id */
+	rot->cur_buf_id[EXYNOS_DRM_OPS_SRC] = buf_id;
+
+	switch (buf_type) {
+	case IPP_BUF_ENQUEUE:
+		/* Set address configuration */
+		for_each_ipp_planar(i)
+			addr[i] = buf_info->base[i];
+
+		/* Get format */
+		fmt = rotator_reg_get_format(rot);
+
+		/* Re-set cb planar for NV12 format */
+		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
+					(addr[EXYNOS_DRM_PLANAR_CB] == 0x00)) {
+
+			val = rot_read(ROT_SRC_BUF_SIZE);
+			hsize = ROT_GET_BUF_SIZE_W(val);
+			vsize = ROT_GET_BUF_SIZE_H(val);
+
+			/* Set cb planar */
+			addr[EXYNOS_DRM_PLANAR_CB] =
+				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
+		}
+
+		for_each_ipp_planar(i)
+			rot_write(addr[i], ROT_SRC_BUF_ADDR(i));
+		break;
+	case IPP_BUF_DEQUEUE:
+		for_each_ipp_planar(i)
+			rot_write(0x0, ROT_SRC_BUF_ADDR(i));
+		break;
+	default:
+		/* Nothing to do */
+		break;
+	}
+
+	return 0;
+}
+
+static int rotator_dst_set_transf(struct device *dev,
+		enum drm_exynos_degree degree,
+		enum drm_exynos_flip flip)
+{
+	struct rot_context *rot = dev_get_drvdata(dev);
+	u32 val;
+
+	/* Set transform configuration */
+	val = rot_read(ROT_CONTROL);
+	val &= ~ROT_CONTROL_FLIP_MASK;
+
+	switch (flip) {
+	case EXYNOS_DRM_FLIP_VERTICAL:
+		val |= ROT_CONTROL_FLIP_VERTICAL;
+		break;
+	case EXYNOS_DRM_FLIP_HORIZONTAL:
+		val |= ROT_CONTROL_FLIP_HORIZONTAL;
+		break;
+	default:
+		/* Flip None */
+		break;
+	}
+
+	val &= ~ROT_CONTROL_ROT_MASK;
+
+	switch (degree) {
+	case EXYNOS_DRM_DEGREE_90:
+		val |= ROT_CONTROL_ROT_90;
+		break;
+	case EXYNOS_DRM_DEGREE_180:
+		val |= ROT_CONTROL_ROT_180;
+		break;
+	case EXYNOS_DRM_DEGREE_270:
+		val |= ROT_CONTROL_ROT_270;
+		break;
+	default:
+		/* Rotation 0 Degree */
+		break;
+	}
+
+	rot_write(val, ROT_CONTROL);
+
+	/* Check degree for setting buffer size swap */
+	if ((degree == EXYNOS_DRM_DEGREE_90) ||
+		(degree == EXYNOS_DRM_DEGREE_270))
+		return 1;
+	else
+		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 val, 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 */
+	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
+	rot_write(val, ROT_DST_BUF_SIZE);
+
+	/* Set crop image position configuration */
+	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
+	rot_write(val, ROT_DST_CROP_POS);
+
+	return 0;
+}
+
+static int rotator_dst_set_addr(struct device *dev,
+		struct drm_exynos_ipp_buf_info *buf_info,
+		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
+{
+	struct rot_context *rot = dev_get_drvdata(dev);
+	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
+	u32 val, fmt, hsize, vsize;
+	int i;
+
+	/* Set current buf_id */
+	rot->cur_buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
+
+	switch (buf_type) {
+	case IPP_BUF_ENQUEUE:
+		/* Set address configuration */
+		for_each_ipp_planar(i)
+			addr[i] = buf_info->base[i];
+
+		/* Get format */
+		fmt = rotator_reg_get_format(rot);
+
+		/* Re-set cb planar for NV12 format */
+		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
+					(addr[EXYNOS_DRM_PLANAR_CB] == 0x00)) {
+			/* Get buf size */
+			val = rot_read(ROT_DST_BUF_SIZE);
+
+			hsize = ROT_GET_BUF_SIZE_W(val);
+			vsize = ROT_GET_BUF_SIZE_H(val);
+
+			/* Set cb planar */
+			addr[EXYNOS_DRM_PLANAR_CB] =
+				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
+		}
+
+		for_each_ipp_planar(i)
+			rot_write(addr[i], ROT_DST_BUF_ADDR(i));
+		break;
+	case IPP_BUF_DEQUEUE:
+		for_each_ipp_planar(i)
+			rot_write(0x0, ROT_DST_BUF_ADDR(i));
+		break;
+	default:
+		/* Nothing to do */
+		break;
+	}
+
+	return 0;
+}
+
+static struct exynos_drm_ipp_ops rot_src_ops = {
+	.set_fmt	=	rotator_src_set_fmt,
+	.set_size	=	rotator_src_set_size,
+	.set_addr	=	rotator_src_set_addr,
+};
+
+static struct exynos_drm_ipp_ops rot_dst_ops = {
+	.set_transf	=	rotator_dst_set_transf,
+	.set_size	=	rotator_dst_set_size,
+	.set_addr	=	rotator_dst_set_addr,
+};
+
+static int rotator_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
+{
+	struct drm_exynos_ipp_prop_list *prop_list;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
+	if (!prop_list) {
+		DRM_ERROR("failed to alloc property list.\n");
+		return -ENOMEM;
+	}
+
+	/*ToDo fix support function list*/
+
+	prop_list->version = 1;
+	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
+				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
+	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
+				(1 << EXYNOS_DRM_DEGREE_90) |
+				(1 << EXYNOS_DRM_DEGREE_180) |
+				(1 << EXYNOS_DRM_DEGREE_270);
+	prop_list->csc = 0;
+	prop_list->crop = 0;
+	prop_list->scale = 0;
+
+	ippdrv->prop_list = prop_list;
+
+	return 0;
+}
+
+static int rotator_ippdrv_check_property(struct device *dev,
+		struct drm_exynos_ipp_property *property)
+{
+	struct drm_exynos_ipp_config *src_config =
+					&property->config[EXYNOS_DRM_OPS_SRC];
+	struct drm_exynos_ipp_config *dst_config =
+					&property->config[EXYNOS_DRM_OPS_DST];
+	struct drm_exynos_pos *src_pos = &src_config->pos;
+	struct drm_exynos_pos *dst_pos = &dst_config->pos;
+	struct drm_exynos_sz *src_sz = &src_config->sz;
+	struct drm_exynos_sz *dst_sz = &dst_config->sz;
+	bool swap = false;
+
+	/* Check format configuration */
+	if (src_config->fmt != dst_config->fmt) {
+		DRM_DEBUG_KMS("%s:not support csc feature\n", __func__);
+		return -EINVAL;
+	}
+
+	switch (src_config->fmt) {
+	case DRM_FORMAT_XRGB8888:
+	case DRM_FORMAT_NV12:
+		/* No problem */
+		break;
+	default:
+		DRM_DEBUG_KMS("%s:not support format\n", __func__);
+		return -EINVAL;
+	}
+
+	/* Check transform configuration */
+	if (src_config->degree != EXYNOS_DRM_DEGREE_0) {
+		DRM_DEBUG_KMS("%s:not support source-side rotation\n",
+								__func__);
+		return -EINVAL;
+	}
+
+	switch (dst_config->degree) {
+	case EXYNOS_DRM_DEGREE_90:
+	case EXYNOS_DRM_DEGREE_270:
+		swap = true;
+	case EXYNOS_DRM_DEGREE_0:
+	case EXYNOS_DRM_DEGREE_180:
+		/* No problem */
+		break;
+	default:
+		DRM_DEBUG_KMS("%s:invalid degree\n", __func__);
+		return -EINVAL;
+	}
+
+	if (src_config->flip != EXYNOS_DRM_FLIP_NONE) {
+		DRM_DEBUG_KMS("%s:not support source-side flip\n", __func__);
+		return -EINVAL;
+	}
+
+	switch (dst_config->flip) {
+	case EXYNOS_DRM_FLIP_NONE:
+	case EXYNOS_DRM_FLIP_VERTICAL:
+	case EXYNOS_DRM_FLIP_HORIZONTAL:
+		/* No problem */
+		break;
+	default:
+		DRM_DEBUG_KMS("%s:invalid flip\n", __func__);
+		return -EINVAL;
+	}
+
+	/* Check size configuration */
+	if ((src_pos->x + src_pos->w > src_sz->hsize) ||
+		(src_pos->y + src_pos->h > src_sz->vsize)) {
+		DRM_DEBUG_KMS("%s:out of source buffer bound\n", __func__);
+		return -EINVAL;
+	}
+
+	if (swap) {
+		if ((dst_pos->x + dst_pos->h > dst_sz->vsize) ||
+			(dst_pos->y + dst_pos->w > dst_sz->hsize)) {
+			DRM_DEBUG_KMS("%s:out of destination buffer bound\n",
+								__func__);
+			return -EINVAL;
+		}
+
+		if ((src_pos->w != dst_pos->h) || (src_pos->h != dst_pos->w)) {
+			DRM_DEBUG_KMS("%s:not support scale feature\n",
+								__func__);
+			return -EINVAL;
+		}
+	} else {
+		if ((dst_pos->x + dst_pos->w > dst_sz->hsize) ||
+			(dst_pos->y + dst_pos->h > dst_sz->vsize)) {
+			DRM_DEBUG_KMS("%s:out of destination buffer bound\n",
+								__func__);
+			return -EINVAL;
+		}
+
+		if ((src_pos->w != dst_pos->w) || (src_pos->h != dst_pos->h)) {
+			DRM_DEBUG_KMS("%s:not support scale feature\n",
+								__func__);
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
+static int rotator_ippdrv_start(struct device *dev, enum drm_exynos_ipp_cmd cmd)
+{
+	struct rot_context *rot = dev_get_drvdata(dev);
+	u32 val;
+
+	if (rot->suspended) {
+		DRM_ERROR("suspended state\n");
+		return -EPERM;
+	}
+
+	if (cmd != IPP_CMD_M2M) {
+		DRM_ERROR("not support cmd: %d\n", cmd);
+		return -EINVAL;
+	}
+
+	/* Set interrupt enable */
+	rotator_reg_set_irq(rot, true);
+
+	val = rot_read(ROT_CONTROL);
+	val |= ROT_CONTROL_START;
+
+	rot_write(val, ROT_CONTROL);
+
+	return 0;
+}
+
+static int __devinit rotator_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct rot_context *rot;
+	struct resource *res;
+	struct exynos_drm_ippdrv *ippdrv;
+	int ret;
+
+	rot = kzalloc(sizeof(*rot), GFP_KERNEL);
+	if (!rot) {
+		dev_err(dev, "failed to allocate rot\n");
+		return -ENOMEM;
+	}
+
+	rot->limit_tbl = (struct rot_limit_table *)
+				platform_get_device_id(pdev)->driver_data;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(dev, "failed to find registers\n");
+		ret = -ENOENT;
+		goto err_get_resource;
+	}
+
+	rot->regs_res = request_mem_region(res->start, resource_size(res),
+								dev_name(dev));
+	if (!rot->regs_res) {
+		dev_err(dev, "failed to claim register region\n");
+		ret = -ENOENT;
+		goto err_get_resource;
+	}
+
+	rot->regs = ioremap(res->start, resource_size(res));
+	if (!rot->regs) {
+		dev_err(dev, "failed to map register\n");
+		ret = -ENXIO;
+		goto err_ioremap;
+	}
+
+	rot->irq = platform_get_irq(pdev, 0);
+	if (rot->irq < 0) {
+		dev_err(dev, "failed to get irq\n");
+		ret = rot->irq;
+		goto err_get_irq;
+	}
+
+	ret = request_threaded_irq(rot->irq, NULL, rotator_irq_handler,
+					IRQF_ONESHOT, "drm_rotator", rot);
+	if (ret < 0) {
+		dev_err(dev, "failed to request irq\n");
+		goto err_get_irq;
+	}
+
+	rot->clock = clk_get(dev, "rotator");
+	if (IS_ERR_OR_NULL(rot->clock)) {
+		dev_err(dev, "failed to get clock\n");
+		ret = PTR_ERR(rot->clock);
+		goto err_clk_get;
+	}
+
+	pm_runtime_enable(dev);
+
+	ippdrv = &rot->ippdrv;
+	ippdrv->dev = dev;
+	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &rot_src_ops;
+	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &rot_dst_ops;
+	ippdrv->check_property = rotator_ippdrv_check_property;
+	ippdrv->start = rotator_ippdrv_start;
+	ret = rotator_init_prop_list(ippdrv);
+	if (ret < 0) {
+		dev_err(dev, "failed to init property list.\n");
+		goto err_ippdrv_register;
+	}
+
+	DRM_DEBUG_KMS("%s:ippdrv[0x%x]\n", __func__, (int)ippdrv);
+
+	platform_set_drvdata(pdev, rot);
+
+	ret = exynos_drm_ippdrv_register(ippdrv);
+	if (ret < 0) {
+		dev_err(dev, "failed to register drm rotator device\n");
+		kfree(ippdrv->prop_list);
+		goto err_ippdrv_register;
+	}
+
+	dev_info(dev, "The exynos rotator is probed successfully\n");
+
+	return 0;
+
+err_ippdrv_register:
+	pm_runtime_disable(dev);
+	clk_put(rot->clock);
+err_clk_get:
+	free_irq(rot->irq, rot);
+err_get_irq:
+	iounmap(rot->regs);
+err_ioremap:
+	release_resource(rot->regs_res);
+	kfree(rot->regs_res);
+err_get_resource:
+	kfree(rot);
+	return ret;
+}
+
+static int __devexit rotator_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct rot_context *rot = dev_get_drvdata(dev);
+	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
+
+	kfree(ippdrv->prop_list);
+	exynos_drm_ippdrv_unregister(ippdrv);
+
+	pm_runtime_disable(dev);
+	clk_put(rot->clock);
+
+	free_irq(rot->irq, rot);
+
+	iounmap(rot->regs);
+
+	release_resource(rot->regs_res);
+	kfree(rot->regs_res);
+
+	kfree(rot);
+
+	return 0;
+}
+
+struct rot_limit_table rot_limit_tbl = {
+	.ycbcr420_2p = {
+		.min_w = 32,
+		.min_h = 32,
+		.max_w = SZ_32K,
+		.max_h = SZ_32K,
+		.align = 3,
+	},
+	.rgb888 = {
+		.min_w = 8,
+		.min_h = 8,
+		.max_w = SZ_8K,
+		.max_h = SZ_8K,
+		.align = 2,
+	},
+};
+
+struct platform_device_id rotator_driver_ids[] = {
+	{
+		.name		= "exynos-rot",
+		.driver_data	= (unsigned long)&rot_limit_tbl,
+	},
+	{},
+};
+
+static int rotator_clk_crtl(struct rot_context *rot, bool enable)
+{
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (enable) {
+		clk_enable(rot->clock);
+		rot->suspended = false;
+	} else {
+		clk_disable(rot->clock);
+		rot->suspended = true;
+	}
+
+	return 0;
+}
+
+
+#ifdef CONFIG_PM_SLEEP
+static int rotator_suspend(struct device *dev)
+{
+	struct rot_context *rot = dev_get_drvdata(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (pm_runtime_suspended(dev))
+		return 0;
+
+	return rotator_clk_crtl(rot, false);
+}
+
+static int rotator_resume(struct device *dev)
+{
+	struct rot_context *rot = dev_get_drvdata(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	if (!pm_runtime_suspended(dev))
+		return rotator_clk_crtl(rot, true);
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PM_RUNTIME
+static int rotator_runtime_suspend(struct device *dev)
+{
+	struct rot_context *rot = dev_get_drvdata(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	return  rotator_clk_crtl(rot, false);
+}
+
+static int rotator_runtime_resume(struct device *dev)
+{
+	struct rot_context *rot = dev_get_drvdata(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	return  rotator_clk_crtl(rot, true);
+}
+#endif
+
+static const struct dev_pm_ops rotator_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(rotator_suspend, rotator_resume)
+	SET_RUNTIME_PM_OPS(rotator_runtime_suspend, rotator_runtime_resume,
+									NULL)
+};
+
+struct platform_driver rotator_driver = {
+	.probe		= rotator_probe,
+	.remove		= __devexit_p(rotator_remove),
+	.id_table	= rotator_driver_ids,
+	.driver		= {
+		.name	= "exynos-rot",
+		.owner	= THIS_MODULE,
+		.pm	= &rotator_pm_ops,
+	},
+};
diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
new file mode 100644
index 0000000..fe929c9
--- /dev/null
+++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics Co.Ltd
+ * Authors: YoungJun Cho <yj44.cho@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundationr
+ */
+
+#ifndef	_EXYNOS_DRM_ROTATOR_H_
+#define	_EXYNOS_DRM_ROTATOR_H_
+
+#endif
diff --git a/drivers/gpu/drm/exynos/regs-rotator.h b/drivers/gpu/drm/exynos/regs-rotator.h
new file mode 100644
index 0000000..a09ac6e
--- /dev/null
+++ b/drivers/gpu/drm/exynos/regs-rotator.h
@@ -0,0 +1,73 @@
+/* drivers/gpu/drm/exynos/regs-rotator.h
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com/
+ *
+ * Register definition file for Samsung Rotator Interface (Rotator) driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef EXYNOS_REGS_ROTATOR_H
+#define EXYNOS_REGS_ROTATOR_H
+
+/* Configuration */
+#define ROT_CONFIG			0x00
+#define ROT_CONFIG_IRQ			(3 << 8)
+
+/* Image Control */
+#define ROT_CONTROL			0x10
+#define ROT_CONTROL_PATTERN_WRITE	(1 << 16)
+#define ROT_CONTROL_FMT_YCBCR420_2P	(1 << 8)
+#define ROT_CONTROL_FMT_RGB888		(6 << 8)
+#define ROT_CONTROL_FMT_MASK		(7 << 8)
+#define ROT_CONTROL_FLIP_VERTICAL	(2 << 6)
+#define ROT_CONTROL_FLIP_HORIZONTAL	(3 << 6)
+#define ROT_CONTROL_FLIP_MASK		(3 << 6)
+#define ROT_CONTROL_ROT_90		(1 << 4)
+#define ROT_CONTROL_ROT_180		(2 << 4)
+#define ROT_CONTROL_ROT_270		(3 << 4)
+#define ROT_CONTROL_ROT_MASK		(3 << 4)
+#define ROT_CONTROL_START		(1 << 0)
+
+/* Status */
+#define ROT_STATUS			0x20
+#define ROT_STATUS_IRQ_PENDING(x)	(1 << (x))
+#define ROT_STATUS_IRQ(x)		(((x) >> 8) & 0x3)
+#define ROT_STATUS_IRQ_VAL_COMPLETE	1
+#define ROT_STATUS_IRQ_VAL_ILLEGAL	2
+
+/* Buffer Address */
+#define ROT_SRC_BUF_ADDR(n)		(0x30 + ((n) << 2))
+#define ROT_DST_BUF_ADDR(n)		(0x50 + ((n) << 2))
+
+/* Buffer Size */
+#define ROT_SRC_BUF_SIZE		0x3c
+#define ROT_DST_BUF_SIZE		0x5c
+#define ROT_SET_BUF_SIZE_H(x)		((x) << 16)
+#define ROT_SET_BUF_SIZE_W(x)		((x) << 0)
+#define ROT_GET_BUF_SIZE_H(x)		((x) >> 16)
+#define ROT_GET_BUF_SIZE_W(x)		((x) & 0xffff)
+
+/* Crop Position */
+#define ROT_SRC_CROP_POS		0x40
+#define ROT_DST_CROP_POS		0x60
+#define ROT_CROP_POS_Y(x)		((x) << 16)
+#define ROT_CROP_POS_X(x)		((x) << 0)
+
+/* Source Crop Size */
+#define ROT_SRC_CROP_SIZE		0x44
+#define ROT_SRC_CROP_SIZE_H(x)		((x) << 16)
+#define ROT_SRC_CROP_SIZE_W(x)		((x) << 0)
+
+/* Round to nearest aligned value */
+#define ROT_ALIGN(x, align, mask)	(((x) + (1 << ((align) - 1))) & (mask))
+/* Minimum limit value */
+#define ROT_MIN(min, mask)		(((min) + ~(mask)) & (mask))
+/* Maximum limit value */
+#define ROT_MAX(max, mask)		((max) & (mask))
+
+#endif /* EXYNOS_REGS_ROTATOR_H */
+
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC v3 5/5] drm/exynos: add gsc ipp driver
  2012-12-12  7:34 [RFC v3 0/5] drm/exynos: add ipp subsystem and each ipp drivers Eunchul Kim
                   ` (3 preceding siblings ...)
  2012-12-12  7:34 ` [RFC v3 4/5] drm/exynos: add rotator " Eunchul Kim
@ 2012-12-12  7:34 ` Eunchul Kim
  2012-12-13  2:29   ` Joonyoung Shim
  4 siblings, 1 reply; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12  7:34 UTC (permalink / raw)
  To: dri-devel, inki.dae; +Cc: jy0.jeon, jaejoon.seo, kyungmin.park, jmock.shin

GSC is stand for General SCaler and supports supports
image scaler/rotator/crop/flip/csc and input/output DMA operations.
input DMA reads image data from the memory.
output DMA writes image data to memory.
GSC supports image rotation and imag effect functions.
also supports writeback and display output operations.

Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
Signed-off-by: Jinyoung Jeon <jy0.jeon@samsung.com>
---
 drivers/gpu/drm/exynos/Kconfig          |    5 +
 drivers/gpu/drm/exynos/Makefile         |    1 +
 drivers/gpu/drm/exynos/exynos_drm_drv.c |   15 +
 drivers/gpu/drm/exynos/exynos_drm_drv.h |    1 +
 drivers/gpu/drm/exynos/exynos_drm_gsc.c | 1927 +++++++++++++++++++++++++++++++
 drivers/gpu/drm/exynos/exynos_drm_gsc.h |   34 +
 drivers/gpu/drm/exynos/regs-gsc.h       |  295 +++++
 7 files changed, 2278 insertions(+), 0 deletions(-)
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.c
 create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.h
 create mode 100644 drivers/gpu/drm/exynos/regs-gsc.h

diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 4860835..c93d776 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -64,3 +64,8 @@ config DRM_EXYNOS_ROTATOR
 	help
 	  Choose this option if you want to use Exynos Rotator for DRM.
 
+config DRM_EXYNOS_GSC
+	bool "Exynos DRM GSC"
+	depends on DRM_EXYNOS_IPP && ARCH_EXYNOS5
+	help
+	  Choose this option if you want to use Exynos GSC for DRM.
diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
index 3b70668..639b49e 100644
--- a/drivers/gpu/drm/exynos/Makefile
+++ b/drivers/gpu/drm/exynos/Makefile
@@ -19,5 +19,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
 exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
+exynosdrm-$(CONFIG_DRM_EXYNOS_GSC)	+= exynos_drm_gsc.o
 
 obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index 09d884b..e0a8e80 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -384,6 +384,12 @@ static int __init exynos_drm_init(void)
 		goto out_rotator;
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_GSC
+	ret = platform_driver_register(&gsc_driver);
+	if (ret < 0)
+		goto out_gsc;
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_IPP
 	ret = platform_driver_register(&ipp_driver);
 	if (ret < 0)
@@ -412,6 +418,11 @@ out_drm:
 out_ipp:
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_GSC
+	platform_driver_unregister(&gsc_driver);
+out_gsc:
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_ROTATOR
 	platform_driver_unregister(&rotator_driver);
 out_rotator:
@@ -462,6 +473,10 @@ static void __exit exynos_drm_exit(void)
 	platform_driver_unregister(&ipp_driver);
 #endif
 
+#ifdef CONFIG_DRM_EXYNOS_GSC
+	platform_driver_unregister(&gsc_driver);
+#endif
+
 #ifdef CONFIG_DRM_EXYNOS_ROTATOR
 	platform_driver_unregister(&rotator_driver);
 #endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index a74e37c..afe556c 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -354,5 +354,6 @@ extern struct platform_driver vidi_driver;
 extern struct platform_driver g2d_driver;
 extern struct platform_driver fimc_driver;
 extern struct platform_driver rotator_driver;
+extern struct platform_driver gsc_driver;
 extern struct platform_driver ipp_driver;
 #endif
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
new file mode 100644
index 0000000..a4475b0
--- /dev/null
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
@@ -0,0 +1,1927 @@
+/*
+ * Copyright (C) 2012 Samsung Electronics Co.Ltd
+ * Authors:
+ *	Eunchul Kim <chulspro.kim@samsung.com>
+ *	Jinyoung Jeon <jy0.jeon@samsung.com>
+ *	Sangmin Lee <lsmin.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute  it and/or modify it
+ * under  the terms of  the GNU General  Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/pm_runtime.h>
+#include <plat/map-base.h>
+
+#include <drm/drmP.h>
+#include <drm/exynos_drm.h>
+#include "regs-gsc.h"
+#include "exynos_drm_ipp.h"
+#include "exynos_drm_gsc.h"
+
+/*
+ * GSC is stand for General SCaler and
+ * supports image scaler/rotator and input/output DMA operations.
+ * input DMA reads image data from the memory.
+ * output DMA writes image data to memory.
+ * GSC supports image rotation and image effect functions.
+ */
+
+#define GSC_MAX_DEVS	4
+#define GSC_MAX_SRC		4
+#define GSC_MAX_DST		16
+#define GSC_RESET_TIMEOUT	50
+#define GSC_BUF_STOP	1
+#define GSC_BUF_START	2
+#define GSC_REG_SZ		16
+#define GSC_WIDTH_ITU_709	1280
+#define GSC_SC_UP_MAX_RATIO		65536
+#define GSC_SC_DOWN_RATIO_7_8		74898
+#define GSC_SC_DOWN_RATIO_6_8		87381
+#define GSC_SC_DOWN_RATIO_5_8		104857
+#define GSC_SC_DOWN_RATIO_4_8		131072
+#define GSC_SC_DOWN_RATIO_3_8		174762
+#define GSC_SC_DOWN_RATIO_2_8		262144
+#define GSC_REFRESH_MIN	12
+#define GSC_REFRESH_MAX	60
+#define GSC_CROP_MAX	8192
+#define GSC_CROP_MIN	32
+#define GSC_SCALE_MAX	4224
+#define GSC_SCALE_MIN	32
+
+#define get_gsc_context(dev)	platform_get_drvdata(to_platform_device(dev))
+#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
+					struct gsc_context, ippdrv);
+#define gsc_read(offset)		readl(ctx->regs + (offset))
+#define gsc_write(cfg, offset)	writel(cfg, ctx->regs + (offset))
+
+/*
+ * A structure of scaler.
+ *
+ * @range: narrow, wide.
+ * @pre_shfactor: pre sclaer shift factor.
+ * @pre_hratio: horizontal ratio of the prescaler.
+ * @pre_vratio: vertical ratio of the prescaler.
+ * @main_hratio: the main scaler's horizontal ratio.
+ * @main_vratio: the main scaler's vertical ratio.
+ */
+struct gsc_scaler {
+	bool	range;
+	u32	pre_shfactor;
+	u32	pre_hratio;
+	u32	pre_vratio;
+	unsigned long main_hratio;
+	unsigned long main_vratio;
+};
+
+/*
+ * A structure of scaler capability.
+ *
+ * find user manual 49.2 features.
+ * @tile_w: tile mode or rotation width.
+ * @tile_h: tile mode or rotation height.
+ * @w: other cases width.
+ * @h: other cases height.
+ */
+struct gsc_capability {
+	/* tile or rotation */
+	u32	tile_w;
+	u32	tile_h;
+	/* other cases */
+	u32	w;
+	u32	h;
+};
+
+/*
+ * A structure of gsc context.
+ *
+ * @ippdrv: prepare initialization using ippdrv.
+ * @regs_res: register resources.
+ * @regs: memory mapped io registers.
+ * @lock: locking of operations.
+ * @gsc_clk: gsc gate clock.
+ * @parent_clk: parent clock e.g aclk_300.
+ * @child_clk: child clock e.g dout_aclk_300.
+ * @sc: scaler infomations.
+ * @id: gsc id.
+ * @irq: irq number.
+ * @rotation: supports rotation of src.
+ * @suspended: qos operations.
+ */
+struct gsc_context {
+	struct exynos_drm_ippdrv	ippdrv;
+	struct resource	*regs_res;
+	void __iomem	*regs;
+	struct mutex	lock;
+	struct clk	*gsc_clk;
+	struct clk	*parent_clk;
+	struct clk	*child_clk;
+	struct gsc_scaler	sc;
+	int	id;
+	int	irq;
+	bool	rotation;
+	bool	suspended;
+};
+
+/* 8-tap Filter Coefficient */
+const int h_coef_8t[7][16][8] = {
+	{	/* Ratio <= 65536 (~8:8) */
+		{  0,  0,   0, 128,   0,   0,  0,  0 },/* 0 */
+		{ -1,  2,  -6, 127,   7,  -2,  1,  0 },/* 1 */
+		{ -1,  4, -12, 125,  16,  -5,  1,  0 },/* 2 */
+		{ -1,  5, -15, 120,  25,  -8,  2,  0 },/* 3 */
+		{ -1,  6, -18, 114,  35, -10,  3, -1 },/* 4 */
+		{ -1,  6, -20, 107,  46, -13,  4, -1 },/* 5 */
+		{ -2,  7, -21,  99,  57, -16,  5, -1 },/* 6 */
+		{ -1,  6, -20,  89,  68, -18,  5, -1 },/* 7 */
+		{ -1,  6, -20,  79,  79, -20,  6, -1 },/* 8 */
+		{ -1,  5, -18,  68,  89, -20,  6, -1 },/* 9 */
+		{ -1,  5, -16,  57,  99, -21,  7, -2 },/* 10 */
+		{ -1,  4, -13,  46, 107, -20,  6, -1 },/* 11 */
+		{ -1,  3, -10,  35, 114, -18,  6, -1 },/* 12 */
+		{  0,  2,  -8,  25, 120, -15,  5, -1 },/* 13 */
+		{  0,  1,  -5,  16, 125, -12,  4, -1 },/* 14 */
+		{  0,  1,  -2,   7, 127,  -6,  2, -1 } /* 15 */
+	}, {	/* 65536 < Ratio <= 74898 (~8:7) */
+		{  3, -8,  14, 111,  13,  -8,  3,  0 },/* 0 */
+		{  2, -6,   7, 112,  21, -10,  3, -1 },/* 1 */
+		{  2, -4,   1, 110,  28, -12,  4, -1 },/* 2 */
+		{  1, -2,  -3, 106,  36, -13,  4, -1 },/* 3 */
+		{  1, -1,  -7, 103,  44, -15,  4, -1 },/* 4 */
+		{  1,  1, -11,  97,  53, -16,  4, -1 },/* 5 */
+		{  0,  2, -13,  91,  61, -16,  4, -1 },/* 6 */
+		{  0,  3, -15,  85,  69, -17,  4, -1 },/* 7 */
+		{  0,  3, -16,  77,  77, -16,  3,  0 },/* 8 */
+		{ -1,  4, -17,  69,  85, -15,  3,  0 },/* 9 */
+		{ -1,  4, -16,  61,  91, -13,  2,  0 },/* 10 */
+		{ -1,  4, -16,  53,  97, -11,  1,  1 },/* 11 */
+		{ -1,  4, -15,  44, 103,  -7, -1,  1 },/* 12 */
+		{ -1,  4, -13,  36, 106,  -3, -2,  1 },/* 13 */
+		{ -1,  4, -12,  28, 110,   1, -4,  2 },/* 14 */
+		{ -1,  3, -10,  21, 112,   7, -6,  2 } /* 15 */
+	}, {	/* 74898 < Ratio <= 87381 (~8:6) */
+		{ 2, -11,  25,  96, 25, -11,   2,  0 },/* 0 */
+		{ 2, -10,  19,  96, 31, -12,   2,  0 },/* 1 */
+		{ 2,  -9,  14,  94, 37, -12,   2,  0 },/* 2 */
+		{ 2,  -8,  10,  92, 43, -12,   1,  0 },/* 3 */
+		{ 2,  -7,   5,  90, 49, -12,   1,  0 },/* 4 */
+		{ 2,  -5,   1,  86, 55, -12,   0,  1 },/* 5 */
+		{ 2,  -4,  -2,  82, 61, -11,  -1,  1 },/* 6 */
+		{ 1,  -3,  -5,  77, 67,  -9,  -1,  1 },/* 7 */
+		{ 1,  -2,  -7,  72, 72,  -7,  -2,  1 },/* 8 */
+		{ 1,  -1,  -9,  67, 77,  -5,  -3,  1 },/* 9 */
+		{ 1,  -1, -11,  61, 82,  -2,  -4,  2 },/* 10 */
+		{ 1,   0, -12,  55, 86,   1,  -5,  2 },/* 11 */
+		{ 0,   1, -12,  49, 90,   5,  -7,  2 },/* 12 */
+		{ 0,   1, -12,  43, 92,  10,  -8,  2 },/* 13 */
+		{ 0,   2, -12,  37, 94,  14,  -9,  2 },/* 14 */
+		{ 0,   2, -12,  31, 96,  19, -10,  2 } /* 15 */
+	}, {	/* 87381 < Ratio <= 104857 (~8:5) */
+		{ -1,  -8, 33,  80, 33,  -8,  -1,  0 },/* 0 */
+		{ -1,  -8, 28,  80, 37,  -7,  -2,  1 },/* 1 */
+		{  0,  -8, 24,  79, 41,  -7,  -2,  1 },/* 2 */
+		{  0,  -8, 20,  78, 46,  -6,  -3,  1 },/* 3 */
+		{  0,  -8, 16,  76, 50,  -4,  -3,  1 },/* 4 */
+		{  0,  -7, 13,  74, 54,  -3,  -4,  1 },/* 5 */
+		{  1,  -7, 10,  71, 58,  -1,  -5,  1 },/* 6 */
+		{  1,  -6,  6,  68, 62,   1,  -5,  1 },/* 7 */
+		{  1,  -6,  4,  65, 65,   4,  -6,  1 },/* 8 */
+		{  1,  -5,  1,  62, 68,   6,  -6,  1 },/* 9 */
+		{  1,  -5, -1,  58, 71,  10,  -7,  1 },/* 10 */
+		{  1,  -4, -3,  54, 74,  13,  -7,  0 },/* 11 */
+		{  1,  -3, -4,  50, 76,  16,  -8,  0 },/* 12 */
+		{  1,  -3, -6,  46, 78,  20,  -8,  0 },/* 13 */
+		{  1,  -2, -7,  41, 79,  24,  -8,  0 },/* 14 */
+		{  1,  -2, -7,  37, 80,  28,  -8, -1 } /* 15 */
+	}, {	/* 104857 < Ratio <= 131072 (~8:4) */
+		{ -3,   0, 35,  64, 35,   0,  -3,  0 },/* 0 */
+		{ -3,  -1, 32,  64, 38,   1,  -3,  0 },/* 1 */
+		{ -2,  -2, 29,  63, 41,   2,  -3,  0 },/* 2 */
+		{ -2,  -3, 27,  63, 43,   4,  -4,  0 },/* 3 */
+		{ -2,  -3, 24,  61, 46,   6,  -4,  0 },/* 4 */
+		{ -2,  -3, 21,  60, 49,   7,  -4,  0 },/* 5 */
+		{ -1,  -4, 19,  59, 51,   9,  -4, -1 },/* 6 */
+		{ -1,  -4, 16,  57, 53,  12,  -4, -1 },/* 7 */
+		{ -1,  -4, 14,  55, 55,  14,  -4, -1 },/* 8 */
+		{ -1,  -4, 12,  53, 57,  16,  -4, -1 },/* 9 */
+		{ -1,  -4,  9,  51, 59,  19,  -4, -1 },/* 10 */
+		{  0,  -4,  7,  49, 60,  21,  -3, -2 },/* 11 */
+		{  0,  -4,  6,  46, 61,  24,  -3, -2 },/* 12 */
+		{  0,  -4,  4,  43, 63,  27,  -3, -2 },/* 13 */
+		{  0,  -3,  2,  41, 63,  29,  -2, -2 },/* 14 */
+		{  0,  -3,  1,  38, 64,  32,  -1, -3 } /* 15 */
+	}, {	/* 131072 < Ratio <= 174762 (~8:3) */
+		{ -1,   8, 33,  48, 33,   8,  -1,  0 },/* 0 */
+		{ -1,   7, 31,  49, 35,   9,  -1, -1 },/* 1 */
+		{ -1,   6, 30,  49, 36,  10,  -1, -1 },/* 2 */
+		{ -1,   5, 28,  48, 38,  12,  -1, -1 },/* 3 */
+		{ -1,   4, 26,  48, 39,  13,   0, -1 },/* 4 */
+		{ -1,   3, 24,  47, 41,  15,   0, -1 },/* 5 */
+		{ -1,   2, 23,  47, 42,  16,   0, -1 },/* 6 */
+		{ -1,   2, 21,  45, 43,  18,   1, -1 },/* 7 */
+		{ -1,   1, 19,  45, 45,  19,   1, -1 },/* 8 */
+		{ -1,   1, 18,  43, 45,  21,   2, -1 },/* 9 */
+		{ -1,   0, 16,  42, 47,  23,   2, -1 },/* 10 */
+		{ -1,   0, 15,  41, 47,  24,   3, -1 },/* 11 */
+		{ -1,   0, 13,  39, 48,  26,   4, -1 },/* 12 */
+		{ -1,  -1, 12,  38, 48,  28,   5, -1 },/* 13 */
+		{ -1,  -1, 10,  36, 49,  30,   6, -1 },/* 14 */
+		{ -1,  -1,  9,  35, 49,  31,   7, -1 } /* 15 */
+	}, {	/* 174762 < Ratio <= 262144 (~8:2) */
+		{  2,  13, 30,  38, 30,  13,   2,  0 },/* 0 */
+		{  2,  12, 29,  38, 30,  14,   3,  0 },/* 1 */
+		{  2,  11, 28,  38, 31,  15,   3,  0 },/* 2 */
+		{  2,  10, 26,  38, 32,  16,   4,  0 },/* 3 */
+		{  1,  10, 26,  37, 33,  17,   4,  0 },/* 4 */
+		{  1,   9, 24,  37, 34,  18,   5,  0 },/* 5 */
+		{  1,   8, 24,  37, 34,  19,   5,  0 },/* 6 */
+		{  1,   7, 22,  36, 35,  20,   6,  1 },/* 7 */
+		{  1,   6, 21,  36, 36,  21,   6,  1 },/* 8 */
+		{  1,   6, 20,  35, 36,  22,   7,  1 },/* 9 */
+		{  0,   5, 19,  34, 37,  24,   8,  1 },/* 10 */
+		{  0,   5, 18,  34, 37,  24,   9,  1 },/* 11 */
+		{  0,   4, 17,  33, 37,  26,  10,  1 },/* 12 */
+		{  0,   4, 16,  32, 38,  26,  10,  2 },/* 13 */
+		{  0,   3, 15,  31, 38,  28,  11,  2 },/* 14 */
+		{  0,   3, 14,  30, 38,  29,  12,  2 } /* 15 */
+	}
+};
+
+/* 4-tap Filter Coefficient */
+const int v_coef_4t[7][16][4] = {
+	{	/* Ratio <= 65536 (~8:8) */
+		{  0, 128,   0,  0 },/* 0 */
+		{ -4, 127,   5,  0 },/* 1 */
+		{ -6, 124,  11, -1 },/* 2 */
+		{ -8, 118,  19, -1 },/* 3 */
+		{ -8, 111,  27, -2 },/* 4 */
+		{ -8, 102,  37, -3 },/* 5 */
+		{ -8,  92,  48, -4 },/* 6 */
+		{ -7,  81,  59, -5 },/* 7 */
+		{ -6,  70,  70, -6 },/* 8 */
+		{ -5,  59,  81, -7 },/* 9 */
+		{ -4,  48,  92, -8 },/* 10 */
+		{ -3,  37, 102, -8 },/* 11 */
+		{ -2,  27, 111, -8 },/* 12 */
+		{ -1,  19, 118, -8 },/* 13 */
+		{ -1,  11, 124, -6 },/* 14 */
+		{  0,   5, 127, -4 } /* 15 */
+	}, {	/* 65536 < Ratio <= 74898 (~8:7) */
+		{  8, 112,   8,  0 },/* 0 */
+		{  4, 111,  14, -1 },/* 1 */
+		{  1, 109,  20, -2 },/* 2 */
+		{ -2, 105,  27, -2 },/* 3 */
+		{ -3, 100,  34, -3 },/* 4 */
+		{ -5,  93,  43, -3 },/* 5 */
+		{ -5,  86,  51, -4 },/* 6 */
+		{ -5,  77,  60, -4 },/* 7 */
+		{ -5,  69,  69, -5 },/* 8 */
+		{ -4,  60,  77, -5 },/* 9 */
+		{ -4,  51,  86, -5 },/* 10 */
+		{ -3,  43,  93, -5 },/* 11 */
+		{ -3,  34, 100, -3 },/* 12 */
+		{ -2,  27, 105, -2 },/* 13 */
+		{ -2,  20, 109,  1 },/* 14 */
+		{ -1,  14, 111,  4 } /* 15 */
+	}, {	/* 74898 < Ratio <= 87381 (~8:6) */
+		{ 16,  96,  16,  0 },/* 0 */
+		{ 12,  97,  21, -2 },/* 1 */
+		{  8,  96,  26, -2 },/* 2 */
+		{  5,  93,  32, -2 },/* 3 */
+		{  2,  89,  39, -2 },/* 4 */
+		{  0,  84,  46, -2 },/* 5 */
+		{ -1,  79,  53, -3 },/* 6 */
+		{ -2,  73,  59, -2 },/* 7 */
+		{ -2,  66,  66, -2 },/* 8 */
+		{ -2,  59,  73, -2 },/* 9 */
+		{ -3,  53,  79, -1 },/* 10 */
+		{ -2,  46,  84,  0 },/* 11 */
+		{ -2,  39,  89,  2 },/* 12 */
+		{ -2,  32,  93,  5 },/* 13 */
+		{ -2,  26,  96,  8 },/* 14 */
+		{ -2,  21,  97, 12 } /* 15 */
+	}, {	/* 87381 < Ratio <= 104857 (~8:5) */
+		{ 22,  84,  22,  0 },/* 0 */
+		{ 18,  85,  26, -1 },/* 1 */
+		{ 14,  84,  31, -1 },/* 2 */
+		{ 11,  82,  36, -1 },/* 3 */
+		{  8,  79,  42, -1 },/* 4 */
+		{  6,  76,  47, -1 },/* 5 */
+		{  4,  72,  52,  0 },/* 6 */
+		{  2,  68,  58,  0 },/* 7 */
+		{  1,  63,  63,  1 },/* 8 */
+		{  0,  58,  68,  2 },/* 9 */
+		{  0,  52,  72,  4 },/* 10 */
+		{ -1,  47,  76,  6 },/* 11 */
+		{ -1,  42,  79,  8 },/* 12 */
+		{ -1,  36,  82, 11 },/* 13 */
+		{ -1,  31,  84, 14 },/* 14 */
+		{ -1,  26,  85, 18 } /* 15 */
+	}, {	/* 104857 < Ratio <= 131072 (~8:4) */
+		{ 26,  76,  26,  0 },/* 0 */
+		{ 22,  76,  30,  0 },/* 1 */
+		{ 19,  75,  34,  0 },/* 2 */
+		{ 16,  73,  38,  1 },/* 3 */
+		{ 13,  71,  43,  1 },/* 4 */
+		{ 10,  69,  47,  2 },/* 5 */
+		{  8,  66,  51,  3 },/* 6 */
+		{  6,  63,  55,  4 },/* 7 */
+		{  5,  59,  59,  5 },/* 8 */
+		{  4,  55,  63,  6 },/* 9 */
+		{  3,  51,  66,  8 },/* 10 */
+		{  2,  47,  69, 10 },/* 11 */
+		{  1,  43,  71, 13 },/* 12 */
+		{  1,  38,  73, 16 },/* 13 */
+		{  0,  34,  75, 19 },/* 14 */
+		{  0,  30,  76, 22 } /* 15 */
+	}, {	/* 131072 < Ratio <= 174762 (~8:3) */
+		{ 29,  70,  29,  0 },/* 0 */
+		{ 26,  68,  32,  2 },/* 1 */
+		{ 23,  67,  36,  2 },/* 2 */
+		{ 20,  66,  39,  3 },/* 3 */
+		{ 17,  65,  43,  3 },/* 4 */
+		{ 15,  63,  46,  4 },/* 5 */
+		{ 12,  61,  50,  5 },/* 6 */
+		{ 10,  58,  53,  7 },/* 7 */
+		{  8,  56,  56,  8 },/* 8 */
+		{  7,  53,  58, 10 },/* 9 */
+		{  5,  50,  61, 12 },/* 10 */
+		{  4,  46,  63, 15 },/* 11 */
+		{  3,  43,  65, 17 },/* 12 */
+		{  3,  39,  66, 20 },/* 13 */
+		{  2,  36,  67, 23 },/* 14 */
+		{  2,  32,  68, 26 } /* 15 */
+	}, {	/* 174762 < Ratio <= 262144 (~8:2) */
+		{ 32,  64,  32,  0 },/* 0 */
+		{ 28,  63,  34,  3 },/* 1 */
+		{ 25,  62,  37,  4 },/* 2 */
+		{ 22,  62,  40,  4 },/* 3 */
+		{ 19,  61,  43,  5 },/* 4 */
+		{ 17,  59,  46,  6 },/* 5 */
+		{ 15,  58,  48,  7 },/* 6 */
+		{ 13,  55,  51,  9 },/* 7 */
+		{ 11,  53,  53, 11 },/* 8 */
+		{  9,  51,  55, 13 },/* 9 */
+		{  7,  48,  58, 15 },/* 10 */
+		{  6,  46,  59, 17 },/* 11 */
+		{  5,  43,  61, 19 },/* 12 */
+		{  4,  40,  62, 22 },/* 13 */
+		{  4,  37,  62, 25 },/* 14 */
+		{  3,  34,  63, 28 } /* 15 */
+	}
+};
+
+static int gsc_sw_reset(struct gsc_context *ctx)
+{
+	u32 cfg;
+	int count = GSC_RESET_TIMEOUT;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	/* s/w reset */
+	cfg = (GSC_SW_RESET_SRESET);
+	gsc_write(cfg, GSC_SW_RESET);
+
+	/* wait s/w reset complete */
+	while (count--) {
+		cfg = gsc_read(GSC_SW_RESET);
+		if (!cfg)
+			break;
+		usleep_range(1000, 2000);
+	}
+
+	if (cfg) {
+		DRM_ERROR("failed to reset gsc h/w.\n");
+		return -EBUSY;
+	}
+
+	/* display fifo reset */
+	cfg = readl(SYSREG_GSCBLK_CFG0);
+	/*
+	 * GSCBLK Pixel asyncy FIFO S/W reset sequence
+	 * set PXLASYNC_SW_RESET as 0 then,
+	 * set PXLASYNC_SW_RESET as 1 again
+	 */
+	cfg &= ~GSC_PXLASYNC_RST(ctx->id);
+	writel(cfg, SYSREG_GSCBLK_CFG0);
+	cfg |= GSC_PXLASYNC_RST(ctx->id);
+	writel(cfg, SYSREG_GSCBLK_CFG0);
+
+	/* pixel async reset */
+	cfg = readl(SYSREG_DISP1BLK_CFG);
+	/*
+	 * DISPBLK1 FIFO S/W reset sequence
+	 * set FIFORST_DISP1 as 0 then,
+	 * set FIFORST_DISP1 as 1 again
+	 */
+	cfg &= ~FIFORST_DISP1;
+	writel(cfg, SYSREG_DISP1BLK_CFG);
+	cfg |= FIFORST_DISP1;
+	writel(cfg, SYSREG_DISP1BLK_CFG);
+
+	/* reset sequence */
+	cfg = gsc_read(GSC_IN_BASE_ADDR_Y_MASK);
+	cfg |= (GSC_IN_BASE_ADDR_MASK |
+		GSC_IN_BASE_ADDR_PINGPONG(0));
+	gsc_write(cfg, GSC_IN_BASE_ADDR_Y_MASK);
+	gsc_write(cfg, GSC_IN_BASE_ADDR_CB_MASK);
+	gsc_write(cfg, GSC_IN_BASE_ADDR_CR_MASK);
+
+	cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
+	cfg |= (GSC_OUT_BASE_ADDR_MASK |
+		GSC_OUT_BASE_ADDR_PINGPONG(0));
+	gsc_write(cfg, GSC_OUT_BASE_ADDR_Y_MASK);
+	gsc_write(cfg, GSC_OUT_BASE_ADDR_CB_MASK);
+	gsc_write(cfg, GSC_OUT_BASE_ADDR_CR_MASK);
+
+	return 0;
+}
+
+static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)
+{
+	u32 gscblk_cfg;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	gscblk_cfg = readl(SYSREG_GSCBLK_CFG1);
+
+	if (enable)
+		gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |
+				GSC_BLK_GSCL_WB_IN_SRC_SEL(ctx->id) |
+				GSC_BLK_SW_RESET_WB_DEST(ctx->id);
+	else
+		gscblk_cfg |= GSC_BLK_PXLASYNC_LO_MASK_WB(ctx->id);
+
+	writel(gscblk_cfg, SYSREG_GSCBLK_CFG1);
+}
+
+static void gsc_handle_irq(struct gsc_context *ctx, bool enable,
+		bool overflow, bool done)
+{
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:enable[%d]overflow[%d]level[%d]\n", __func__,
+			enable, overflow, done);
+
+	cfg = gsc_read(GSC_IRQ);
+	cfg |= (GSC_IRQ_OR_MASK | GSC_IRQ_FRMDONE_MASK);
+
+	if (enable)
+		cfg |= GSC_IRQ_ENABLE;
+	else
+		cfg &= ~GSC_IRQ_ENABLE;
+
+	if (overflow)
+		cfg &= ~GSC_IRQ_OR_MASK;
+	else
+		cfg |= GSC_IRQ_OR_MASK;
+
+	if (done)
+		cfg &= ~GSC_IRQ_FRMDONE_MASK;
+	else
+		cfg |= GSC_IRQ_FRMDONE_MASK;
+
+	gsc_write(cfg, GSC_IRQ);
+}
+
+
+static int gsc_src_set_fmt(struct device *dev, u32 fmt)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
+
+	cfg = gsc_read(GSC_IN_CON);
+	cfg &= ~(GSC_IN_RGB_TYPE_MASK | GSC_IN_YUV422_1P_ORDER_MASK |
+		 GSC_IN_CHROMA_ORDER_MASK | GSC_IN_FORMAT_MASK |
+		 GSC_IN_TILE_TYPE_MASK | GSC_IN_TILE_MODE |
+		 GSC_IN_CHROM_STRIDE_SEL_MASK | GSC_IN_RB_SWAP_MASK);
+
+	switch (fmt) {
+	case DRM_FORMAT_RGB565:
+		cfg |= GSC_IN_RGB565;
+		break;
+	case DRM_FORMAT_XRGB8888:
+		cfg |= GSC_IN_XRGB8888;
+		break;
+	case DRM_FORMAT_BGRX8888:
+		cfg |= (GSC_IN_XRGB8888 | GSC_IN_RB_SWAP);
+		break;
+	case DRM_FORMAT_YUYV:
+		cfg |= (GSC_IN_YUV422_1P |
+			GSC_IN_YUV422_1P_ORDER_LSB_Y |
+			GSC_IN_CHROMA_ORDER_CBCR);
+		break;
+	case DRM_FORMAT_YVYU:
+		cfg |= (GSC_IN_YUV422_1P |
+			GSC_IN_YUV422_1P_ORDER_LSB_Y |
+			GSC_IN_CHROMA_ORDER_CRCB);
+		break;
+	case DRM_FORMAT_UYVY:
+		cfg |= (GSC_IN_YUV422_1P |
+			GSC_IN_YUV422_1P_OEDER_LSB_C |
+			GSC_IN_CHROMA_ORDER_CBCR);
+		break;
+	case DRM_FORMAT_VYUY:
+		cfg |= (GSC_IN_YUV422_1P |
+			GSC_IN_YUV422_1P_OEDER_LSB_C |
+			GSC_IN_CHROMA_ORDER_CRCB);
+		break;
+	case DRM_FORMAT_NV21:
+	case DRM_FORMAT_NV61:
+		cfg |= (GSC_IN_CHROMA_ORDER_CRCB |
+			GSC_IN_YUV420_2P);
+		break;
+	case DRM_FORMAT_YUV422:
+		cfg |= GSC_IN_YUV422_3P;
+		break;
+	case DRM_FORMAT_YUV420:
+	case DRM_FORMAT_YVU420:
+		cfg |= GSC_IN_YUV420_3P;
+		break;
+	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_NV16:
+		cfg |= (GSC_IN_CHROMA_ORDER_CBCR |
+			GSC_IN_YUV420_2P);
+		break;
+	case DRM_FORMAT_NV12MT:
+		cfg |= (GSC_IN_TILE_C_16x8 | GSC_IN_TILE_MODE);
+		break;
+	default:
+		dev_err(ippdrv->dev, "inavlid target yuv order 0x%x.\n", fmt);
+		return -EINVAL;
+	}
+
+	gsc_write(cfg, GSC_IN_CON);
+
+	return 0;
+}
+
+static int gsc_src_set_transf(struct device *dev,
+		enum drm_exynos_degree degree,
+		enum drm_exynos_flip flip)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:degree[%d]flip[0x%x]\n", __func__,
+		degree, flip);
+
+	cfg = gsc_read(GSC_IN_CON);
+	cfg &= ~GSC_IN_ROT_MASK;
+
+	switch (degree) {
+	case EXYNOS_DRM_DEGREE_0:
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg |= GSC_IN_ROT_XFLIP;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg |= GSC_IN_ROT_YFLIP;
+		break;
+	case EXYNOS_DRM_DEGREE_90:
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg |= GSC_IN_ROT_90_XFLIP;
+		else if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg |= GSC_IN_ROT_90_YFLIP;
+		else
+			cfg |= GSC_IN_ROT_90;
+		break;
+	case EXYNOS_DRM_DEGREE_180:
+		cfg |= GSC_IN_ROT_180;
+		break;
+	case EXYNOS_DRM_DEGREE_270:
+		cfg |= GSC_IN_ROT_270;
+		break;
+	default:
+		dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
+		return -EINVAL;
+	}
+
+	gsc_write(cfg, GSC_IN_CON);
+
+	ctx->rotation = cfg &
+		(GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
+
+	return ctx->rotation;
+}
+
+static int gsc_src_set_size(struct device *dev, int swap,
+		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct drm_exynos_pos img_pos = *pos;
+	struct gsc_scaler *sc = &ctx->sc;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:swap[%d]x[%d]y[%d]w[%d]h[%d]\n",
+		__func__, swap, pos->x, pos->y, pos->w, pos->h);
+
+	if (swap) {
+		img_pos.w = pos->h;
+		img_pos.h = pos->w;
+	}
+
+	/* pixel offset */
+	cfg = (GSC_SRCIMG_OFFSET_X(img_pos.x) |
+		GSC_SRCIMG_OFFSET_Y(img_pos.y));
+	gsc_write(cfg, GSC_SRCIMG_OFFSET);
+
+	/* cropped size */
+	cfg = (GSC_CROPPED_WIDTH(img_pos.w) |
+		GSC_CROPPED_HEIGHT(img_pos.h));
+	gsc_write(cfg, GSC_CROPPED_SIZE);
+
+	DRM_DEBUG_KMS("%s:hsize[%d]vsize[%d]\n",
+		__func__, sz->hsize, sz->vsize);
+
+	/* original size */
+	cfg = gsc_read(GSC_SRCIMG_SIZE);
+	cfg &= ~(GSC_SRCIMG_HEIGHT_MASK |
+		GSC_SRCIMG_WIDTH_MASK);
+
+	cfg |= (GSC_SRCIMG_WIDTH(sz->hsize) |
+		GSC_SRCIMG_HEIGHT(sz->vsize));
+
+	gsc_write(cfg, GSC_SRCIMG_SIZE);
+
+	cfg = gsc_read(GSC_IN_CON);
+	cfg &= ~GSC_IN_RGB_TYPE_MASK;
+
+	DRM_DEBUG_KMS("%s:width[%d]range[%d]\n",
+		__func__, pos->w, sc->range);
+
+	if (pos->w >= GSC_WIDTH_ITU_709)
+		if (sc->range)
+			cfg |= GSC_IN_RGB_HD_WIDE;
+		else
+			cfg |= GSC_IN_RGB_HD_NARROW;
+	else
+		if (sc->range)
+			cfg |= GSC_IN_RGB_SD_WIDE;
+		else
+			cfg |= GSC_IN_RGB_SD_NARROW;
+
+	gsc_write(cfg, GSC_IN_CON);
+
+	return 0;
+}
+
+static int gsc_src_set_buf_seq(struct gsc_context *ctx, u32 buf_id,
+		enum drm_exynos_ipp_buf_type buf_type)
+{
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	bool masked;
+	u32 cfg;
+	u32 mask = 0x00000001 << buf_id;
+
+	DRM_DEBUG_KMS("%s:buf_id[%d]buf_type[%d]\n", __func__,
+		buf_id, buf_type);
+
+	/* mask register set */
+	cfg = gsc_read(GSC_IN_BASE_ADDR_Y_MASK);
+
+	switch (buf_type) {
+	case IPP_BUF_ENQUEUE:
+		masked = false;
+		break;
+	case IPP_BUF_DEQUEUE:
+		masked = true;
+		break;
+	default:
+		dev_err(ippdrv->dev, "invalid buf ctrl parameter.\n");
+		return -EINVAL;
+	}
+
+	/* sequence id */
+	cfg &= (~mask);
+	cfg |= masked << buf_id;
+	gsc_write(cfg, GSC_IN_BASE_ADDR_Y_MASK);
+	gsc_write(cfg, GSC_IN_BASE_ADDR_CB_MASK);
+	gsc_write(cfg, GSC_IN_BASE_ADDR_CR_MASK);
+
+	return 0;
+}
+
+static int gsc_src_set_addr(struct device *dev,
+		struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
+		enum drm_exynos_ipp_buf_type buf_type)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
+	struct drm_exynos_ipp_property *property;
+
+	if (!c_node) {
+		DRM_ERROR("failed to get c_node.\n");
+		return -EINVAL;
+	}
+
+	property = &c_node->property;
+	if (!property) {
+		DRM_ERROR("failed to get property.\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
+		property->prop_id, buf_id, buf_type);
+
+	if (buf_id > GSC_MAX_SRC) {
+		dev_info(ippdrv->dev, "inavlid buf_id %d.\n", buf_id);
+		return -ENOMEM;
+	}
+
+	/* address register set */
+	switch (buf_type) {
+	case IPP_BUF_ENQUEUE:
+		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
+			GSC_IN_BASE_ADDR_Y(buf_id));
+		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
+			GSC_IN_BASE_ADDR_CB(buf_id));
+		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
+			GSC_IN_BASE_ADDR_CR(buf_id));
+		break;
+	case IPP_BUF_DEQUEUE:
+		gsc_write(0x0, GSC_IN_BASE_ADDR_Y(buf_id));
+		gsc_write(0x0, GSC_IN_BASE_ADDR_CB(buf_id));
+		gsc_write(0x0, GSC_IN_BASE_ADDR_CR(buf_id));
+		break;
+	default:
+		/* bypass */
+		break;
+	}
+
+	return gsc_src_set_buf_seq(ctx, buf_id, buf_type);
+}
+
+static struct exynos_drm_ipp_ops gsc_src_ops = {
+	.set_fmt = gsc_src_set_fmt,
+	.set_transf = gsc_src_set_transf,
+	.set_size = gsc_src_set_size,
+	.set_addr = gsc_src_set_addr,
+};
+
+static int gsc_dst_set_fmt(struct device *dev, u32 fmt)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
+
+	cfg = gsc_read(GSC_OUT_CON);
+	cfg &= ~(GSC_OUT_RGB_TYPE_MASK | GSC_OUT_YUV422_1P_ORDER_MASK |
+		 GSC_OUT_CHROMA_ORDER_MASK | GSC_OUT_FORMAT_MASK |
+		 GSC_OUT_CHROM_STRIDE_SEL_MASK | GSC_OUT_RB_SWAP_MASK |
+		 GSC_OUT_GLOBAL_ALPHA_MASK);
+
+	switch (fmt) {
+	case DRM_FORMAT_RGB565:
+		cfg |= GSC_OUT_RGB565;
+		break;
+	case DRM_FORMAT_XRGB8888:
+		cfg |= GSC_OUT_XRGB8888;
+		break;
+	case DRM_FORMAT_BGRX8888:
+		cfg |= (GSC_OUT_XRGB8888 | GSC_OUT_RB_SWAP);
+		break;
+	case DRM_FORMAT_YUYV:
+		cfg |= (GSC_OUT_YUV422_1P |
+			GSC_OUT_YUV422_1P_ORDER_LSB_Y |
+			GSC_OUT_CHROMA_ORDER_CBCR);
+		break;
+	case DRM_FORMAT_YVYU:
+		cfg |= (GSC_OUT_YUV422_1P |
+			GSC_OUT_YUV422_1P_ORDER_LSB_Y |
+			GSC_OUT_CHROMA_ORDER_CRCB);
+		break;
+	case DRM_FORMAT_UYVY:
+		cfg |= (GSC_OUT_YUV422_1P |
+			GSC_OUT_YUV422_1P_OEDER_LSB_C |
+			GSC_OUT_CHROMA_ORDER_CBCR);
+		break;
+	case DRM_FORMAT_VYUY:
+		cfg |= (GSC_OUT_YUV422_1P |
+			GSC_OUT_YUV422_1P_OEDER_LSB_C |
+			GSC_OUT_CHROMA_ORDER_CRCB);
+		break;
+	case DRM_FORMAT_NV21:
+	case DRM_FORMAT_NV61:
+		cfg |= (GSC_OUT_CHROMA_ORDER_CRCB |
+			GSC_OUT_YUV420_2P);
+		break;
+	case DRM_FORMAT_YUV422:
+	case DRM_FORMAT_YUV420:
+	case DRM_FORMAT_YVU420:
+		cfg |= GSC_OUT_YUV420_3P;
+		break;
+	case DRM_FORMAT_NV12:
+	case DRM_FORMAT_NV16:
+		cfg |= (GSC_OUT_CHROMA_ORDER_CBCR |
+			GSC_OUT_YUV420_2P);
+		break;
+	case DRM_FORMAT_NV12MT:
+		cfg |= (GSC_OUT_TILE_C_16x8 | GSC_OUT_TILE_MODE);
+		break;
+	default:
+		dev_err(ippdrv->dev, "inavlid target yuv order 0x%x.\n", fmt);
+		return -EINVAL;
+	}
+
+	gsc_write(cfg, GSC_OUT_CON);
+
+	return 0;
+}
+
+static int gsc_dst_set_transf(struct device *dev,
+		enum drm_exynos_degree degree,
+		enum drm_exynos_flip flip)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:degree[%d]flip[0x%x]\n", __func__,
+		degree, flip);
+
+	cfg = gsc_read(GSC_IN_CON);
+	cfg &= ~GSC_IN_ROT_MASK;
+
+	switch (degree) {
+	case EXYNOS_DRM_DEGREE_0:
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg |= GSC_IN_ROT_XFLIP;
+		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg |= GSC_IN_ROT_YFLIP;
+		break;
+	case EXYNOS_DRM_DEGREE_90:
+		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
+			cfg |= GSC_IN_ROT_90_XFLIP;
+		else if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
+			cfg |= GSC_IN_ROT_90_YFLIP;
+		else
+			cfg |= GSC_IN_ROT_90;
+		break;
+	case EXYNOS_DRM_DEGREE_180:
+		cfg |= GSC_IN_ROT_180;
+		break;
+	case EXYNOS_DRM_DEGREE_270:
+		cfg |= GSC_IN_ROT_270;
+		break;
+	default:
+		dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
+		return -EINVAL;
+	}
+
+	gsc_write(cfg, GSC_IN_CON);
+
+	ctx->rotation = cfg &
+		(GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
+
+	return ctx->rotation;
+}
+
+static int gsc_get_ratio_shift(u32 src, u32 dst, u32 *ratio)
+{
+	DRM_DEBUG_KMS("%s:src[%d]dst[%d]\n", __func__, src, dst);
+
+	if (src >= dst * 8) {
+		DRM_ERROR("failed to make ratio and shift.\n");
+		return -EINVAL;
+	} else if (src >= dst * 4)
+		*ratio = 4;
+	else if (src >= dst * 2)
+		*ratio = 2;
+	else
+		*ratio = 1;
+
+	return 0;
+}
+
+static void gsc_get_prescaler_shfactor(u32 hratio, u32 vratio, u32 *shfactor)
+{
+	if (hratio == 4 && vratio == 4)
+		*shfactor = 4;
+	else if ((hratio == 4 && vratio == 2) ||
+		 (hratio == 2 && vratio == 4))
+		*shfactor = 3;
+	else if ((hratio == 4 && vratio == 1) ||
+		 (hratio == 1 && vratio == 4) ||
+		 (hratio == 2 && vratio == 2))
+		*shfactor = 2;
+	else if (hratio == 1 && vratio == 1)
+		*shfactor = 0;
+	else
+		*shfactor = 1;
+}
+
+static int gsc_set_prescaler(struct gsc_context *ctx, struct gsc_scaler *sc,
+		struct drm_exynos_pos *src, struct drm_exynos_pos *dst)
+{
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	u32 cfg;
+	u32 src_w, src_h, dst_w, dst_h;
+	int ret = 0;
+
+	src_w = src->w;
+	src_h = src->h;
+
+	if (ctx->rotation) {
+		dst_w = dst->h;
+		dst_h = dst->w;
+	} else {
+		dst_w = dst->w;
+		dst_h = dst->h;
+	}
+
+	ret = gsc_get_ratio_shift(src_w, dst_w, &sc->pre_hratio);
+	if (ret) {
+		dev_err(ippdrv->dev, "failed to get ratio horizontal.\n");
+		return ret;
+	}
+
+	ret = gsc_get_ratio_shift(src_h, dst_h, &sc->pre_vratio);
+	if (ret) {
+		dev_err(ippdrv->dev, "failed to get ratio vertical.\n");
+		return ret;
+	}
+
+	DRM_DEBUG_KMS("%s:pre_hratio[%d]pre_vratio[%d]\n",
+		__func__, sc->pre_hratio, sc->pre_vratio);
+
+	sc->main_hratio = (src_w << 16) / dst_w;
+	sc->main_vratio = (src_h << 16) / dst_h;
+
+	DRM_DEBUG_KMS("%s:main_hratio[%ld]main_vratio[%ld]\n",
+		__func__, sc->main_hratio, sc->main_vratio);
+
+	gsc_get_prescaler_shfactor(sc->pre_hratio, sc->pre_vratio,
+		&sc->pre_shfactor);
+
+	DRM_DEBUG_KMS("%s:pre_shfactor[%d]\n", __func__,
+		sc->pre_shfactor);
+
+	cfg = (GSC_PRESC_SHFACTOR(sc->pre_shfactor) |
+		GSC_PRESC_H_RATIO(sc->pre_hratio) |
+		GSC_PRESC_V_RATIO(sc->pre_vratio));
+	gsc_write(cfg, GSC_PRE_SCALE_RATIO);
+
+	return ret;
+}
+
+static void gsc_set_h_coef(struct gsc_context *ctx, unsigned long main_hratio)
+{
+	int i, j, k, sc_ratio;
+
+	if (main_hratio <= GSC_SC_UP_MAX_RATIO)
+		sc_ratio = 0;
+	else if (main_hratio <= GSC_SC_DOWN_RATIO_7_8)
+		sc_ratio = 1;
+	else if (main_hratio <= GSC_SC_DOWN_RATIO_6_8)
+		sc_ratio = 2;
+	else if (main_hratio <= GSC_SC_DOWN_RATIO_5_8)
+		sc_ratio = 3;
+	else if (main_hratio <= GSC_SC_DOWN_RATIO_4_8)
+		sc_ratio = 4;
+	else if (main_hratio <= GSC_SC_DOWN_RATIO_3_8)
+		sc_ratio = 5;
+	else
+		sc_ratio = 6;
+
+	for (i = 0; i < 9; i++)
+		for (j = 0; j < 8; j++)
+			for (k = 0; k < 3; k++)
+				gsc_write(h_coef_8t[sc_ratio][i][j],
+					GSC_HCOEF(i, j, k));
+}
+
+static void gsc_set_v_coef(struct gsc_context *ctx, unsigned long main_vratio)
+{
+	int i, j, k, sc_ratio = 0;
+
+	if (main_vratio <= GSC_SC_UP_MAX_RATIO)
+		sc_ratio = 0;
+	else if (main_vratio <= GSC_SC_DOWN_RATIO_7_8)
+		sc_ratio = 1;
+	else if (main_vratio <= GSC_SC_DOWN_RATIO_6_8)
+		sc_ratio = 2;
+	else if (main_vratio <= GSC_SC_DOWN_RATIO_5_8)
+		sc_ratio = 3;
+	else if (main_vratio <= GSC_SC_DOWN_RATIO_4_8)
+		sc_ratio = 4;
+	else if (main_vratio <= GSC_SC_DOWN_RATIO_3_8)
+		sc_ratio = 5;
+	else
+		sc_ratio = 6;
+
+	for (i = 0; i < 9; i++)
+		for (j = 0; j < 4; j++)
+			for (k = 0; k < 3; k++)
+				gsc_write(v_coef_4t[sc_ratio][i][j],
+					GSC_VCOEF(i, j, k));
+}
+
+static void gsc_set_scaler(struct gsc_context *ctx, struct gsc_scaler *sc)
+{
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:main_hratio[%ld]main_vratio[%ld]\n",
+		__func__, sc->main_hratio, sc->main_vratio);
+
+	gsc_set_h_coef(ctx, sc->main_hratio);
+	cfg = GSC_MAIN_H_RATIO_VALUE(sc->main_hratio);
+	gsc_write(cfg, GSC_MAIN_H_RATIO);
+
+	gsc_set_v_coef(ctx, sc->main_vratio);
+	cfg = GSC_MAIN_V_RATIO_VALUE(sc->main_vratio);
+	gsc_write(cfg, GSC_MAIN_V_RATIO);
+}
+
+static int gsc_dst_set_size(struct device *dev, int swap,
+		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct drm_exynos_pos img_pos = *pos;
+	struct gsc_scaler *sc = &ctx->sc;
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:swap[%d]x[%d]y[%d]w[%d]h[%d]\n",
+		__func__, swap, pos->x, pos->y, pos->w, pos->h);
+
+	if (swap) {
+		img_pos.w = pos->h;
+		img_pos.h = pos->w;
+	}
+
+	/* pixel offset */
+	cfg = (GSC_DSTIMG_OFFSET_X(pos->x) |
+		GSC_DSTIMG_OFFSET_Y(pos->y));
+	gsc_write(cfg, GSC_DSTIMG_OFFSET);
+
+	/* scaled size */
+	cfg = (GSC_SCALED_WIDTH(img_pos.w) | GSC_SCALED_HEIGHT(img_pos.h));
+	gsc_write(cfg, GSC_SCALED_SIZE);
+
+	DRM_DEBUG_KMS("%s:hsize[%d]vsize[%d]\n",
+		__func__, sz->hsize, sz->vsize);
+
+	/* original size */
+	cfg = gsc_read(GSC_DSTIMG_SIZE);
+	cfg &= ~(GSC_DSTIMG_HEIGHT_MASK |
+		GSC_DSTIMG_WIDTH_MASK);
+	cfg |= (GSC_DSTIMG_WIDTH(sz->hsize) |
+		GSC_DSTIMG_HEIGHT(sz->vsize));
+	gsc_write(cfg, GSC_DSTIMG_SIZE);
+
+	cfg = gsc_read(GSC_OUT_CON);
+	cfg &= ~GSC_OUT_RGB_TYPE_MASK;
+
+	DRM_DEBUG_KMS("%s:width[%d]range[%d]\n",
+		__func__, pos->w, sc->range);
+
+	if (pos->w >= GSC_WIDTH_ITU_709)
+		if (sc->range)
+			cfg |= GSC_OUT_RGB_HD_WIDE;
+		else
+			cfg |= GSC_OUT_RGB_HD_NARROW;
+	else
+		if (sc->range)
+			cfg |= GSC_OUT_RGB_SD_WIDE;
+		else
+			cfg |= GSC_OUT_RGB_SD_NARROW;
+
+	gsc_write(cfg, GSC_OUT_CON);
+
+	return 0;
+}
+
+static int gsc_dst_get_buf_seq(struct gsc_context *ctx)
+{
+	u32 cfg, i, buf_num = GSC_REG_SZ;
+	u32 mask = 0x00000001;
+
+	cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
+
+	for (i = 0; i < GSC_REG_SZ; i++)
+		if (cfg & (mask << i))
+			buf_num--;
+
+	DRM_DEBUG_KMS("%s:buf_num[%d]\n", __func__, buf_num);
+
+	return buf_num;
+}
+
+static int gsc_dst_set_buf_seq(struct gsc_context *ctx, u32 buf_id,
+		enum drm_exynos_ipp_buf_type buf_type)
+{
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	bool masked;
+	u32 cfg;
+	u32 mask = 0x00000001 << buf_id;
+	int ret = 0;
+
+	DRM_DEBUG_KMS("%s:buf_id[%d]buf_type[%d]\n", __func__,
+		buf_id, buf_type);
+
+	mutex_lock(&ctx->lock);
+
+	/* mask register set */
+	cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
+
+	switch (buf_type) {
+	case IPP_BUF_ENQUEUE:
+		masked = false;
+		break;
+	case IPP_BUF_DEQUEUE:
+		masked = true;
+		break;
+	default:
+		dev_err(ippdrv->dev, "invalid buf ctrl parameter.\n");
+		ret =  -EINVAL;
+		goto err_unlock;
+	}
+
+	/* sequence id */
+	cfg &= (~mask);
+	cfg |= masked << buf_id;
+	gsc_write(cfg, GSC_OUT_BASE_ADDR_Y_MASK);
+	gsc_write(cfg, GSC_OUT_BASE_ADDR_CB_MASK);
+	gsc_write(cfg, GSC_OUT_BASE_ADDR_CR_MASK);
+
+	/* interrupt enable */
+	if (buf_type == IPP_BUF_ENQUEUE &&
+	    gsc_dst_get_buf_seq(ctx) >= GSC_BUF_START)
+		gsc_handle_irq(ctx, true, false, true);
+
+	/* interrupt disable */
+	if (buf_type == IPP_BUF_DEQUEUE &&
+	    gsc_dst_get_buf_seq(ctx) <= GSC_BUF_STOP)
+		gsc_handle_irq(ctx, false, false, true);
+
+err_unlock:
+	mutex_unlock(&ctx->lock);
+	return ret;
+}
+
+static int gsc_dst_set_addr(struct device *dev,
+		struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
+		enum drm_exynos_ipp_buf_type buf_type)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
+	struct drm_exynos_ipp_property *property;
+
+	if (!c_node) {
+		DRM_ERROR("failed to get c_node.\n");
+		return -EINVAL;
+	}
+
+	property = &c_node->property;
+	if (!property) {
+		DRM_ERROR("failed to get property.\n");
+		return -EINVAL;
+	}
+
+	DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
+		property->prop_id, buf_id, buf_type);
+
+	if (buf_id > GSC_MAX_DST) {
+		dev_info(ippdrv->dev, "inavlid buf_id %d.\n", buf_id);
+		return -ENOMEM;
+	}
+
+	/* address register set */
+	switch (buf_type) {
+	case IPP_BUF_ENQUEUE:
+		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
+			GSC_OUT_BASE_ADDR_Y(buf_id));
+		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
+			GSC_OUT_BASE_ADDR_CB(buf_id));
+		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
+			GSC_OUT_BASE_ADDR_CR(buf_id));
+		break;
+	case IPP_BUF_DEQUEUE:
+		gsc_write(0x0, GSC_OUT_BASE_ADDR_Y(buf_id));
+		gsc_write(0x0, GSC_OUT_BASE_ADDR_CB(buf_id));
+		gsc_write(0x0, GSC_OUT_BASE_ADDR_CR(buf_id));
+		break;
+	default:
+		/* bypass */
+		break;
+	}
+
+	return gsc_dst_set_buf_seq(ctx, buf_id, buf_type);
+}
+
+static struct exynos_drm_ipp_ops gsc_dst_ops = {
+	.set_fmt = gsc_dst_set_fmt,
+	.set_transf = gsc_dst_set_transf,
+	.set_size = gsc_dst_set_size,
+	.set_addr = gsc_dst_set_addr,
+};
+
+static int gsc_clk_ctrl(struct gsc_context *ctx, bool enable)
+{
+	DRM_INFO("%s:enable[%d]\n", __func__, enable);
+
+	if (enable) {
+		clk_set_parent(ctx->child_clk, ctx->parent_clk);
+		clk_enable(ctx->gsc_clk);
+		ctx->suspended = false;
+	} else {
+		clk_disable(ctx->gsc_clk);
+		ctx->suspended = true;
+	}
+
+	return 0;
+}
+
+static int gsc_get_src_buf_index(struct gsc_context *ctx)
+{
+	u32 cfg, curr_index, i;
+	u32 buf_id = GSC_MAX_SRC;
+
+	DRM_DEBUG_KMS("%s:gsc id[%d]\n", __func__, ctx->id);
+
+	cfg = gsc_read(GSC_IN_BASE_ADDR_Y_MASK);
+	curr_index = GSC_IN_CURR_GET_INDEX(cfg);
+
+	for (i = curr_index; i < GSC_MAX_SRC; i++) {
+		if (!((cfg >> i) & 0x1)) {
+			buf_id = i;
+			break;
+		}
+	}
+
+	if (buf_id == GSC_MAX_SRC) {
+		DRM_ERROR("failed to get in buffer index.\n");
+		return -EIO;
+	}
+
+	if (gsc_src_set_buf_seq(ctx, buf_id, IPP_BUF_DEQUEUE) < 0) {
+		DRM_ERROR("failed to dequeue.\n");
+		return IRQ_HANDLED;
+	}
+
+	DRM_DEBUG_KMS("%s:cfg[0x%x]curr_index[%d]buf_id[%d]\n", __func__, cfg,
+		curr_index, buf_id);
+
+	return buf_id;
+}
+
+static int gsc_get_dst_buf_index(struct gsc_context *ctx)
+{
+	u32 cfg, curr_index, i;
+	u32 buf_id = GSC_MAX_DST;
+
+	DRM_DEBUG_KMS("%s:gsc id[%d]\n", __func__, ctx->id);
+
+	cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
+	curr_index = GSC_OUT_CURR_GET_INDEX(cfg);
+
+	for (i = curr_index; i < GSC_MAX_DST; i++) {
+		if (!((cfg >> i) & 0x1)) {
+			buf_id = i;
+			break;
+		}
+	}
+
+	if (buf_id == GSC_MAX_DST) {
+		DRM_ERROR("failed to get out buffer index.\n");
+		return -EIO;
+	}
+
+	if (gsc_dst_set_buf_seq(ctx, buf_id, IPP_BUF_DEQUEUE) < 0) {
+		DRM_ERROR("failed to dequeue.\n");
+		return IRQ_HANDLED;
+	}
+
+	DRM_DEBUG_KMS("%s:cfg[0x%x]curr_index[%d]buf_id[%d]\n", __func__, cfg,
+		curr_index, buf_id);
+
+	return buf_id;
+}
+
+static irqreturn_t gsc_irq_handler(int irq, void *dev_id)
+{
+	struct gsc_context *ctx = dev_id;
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
+	struct drm_exynos_ipp_event_work *event_work =
+		c_node->event_work;
+	u32 status;
+	int buf_id[EXYNOS_DRM_OPS_MAX];
+
+	DRM_DEBUG_KMS("%s:gsc id[%d]\n", __func__, ctx->id);
+
+	status = gsc_read(GSC_IRQ);
+	if (status & GSC_IRQ_STATUS_OR_IRQ) {
+		dev_err(ippdrv->dev, "occured overflow at %d, status 0x%x.\n",
+			ctx->id, status);
+		return IRQ_NONE;
+	}
+
+	if (status & GSC_IRQ_STATUS_OR_FRM_DONE) {
+		dev_dbg(ippdrv->dev, "occured frame done at %d, status 0x%x.\n",
+			ctx->id, status);
+
+		buf_id[EXYNOS_DRM_OPS_SRC] = gsc_get_src_buf_index(ctx);
+		if (buf_id[EXYNOS_DRM_OPS_SRC] < 0)
+			return IRQ_HANDLED;
+
+		buf_id[EXYNOS_DRM_OPS_DST] = gsc_get_dst_buf_index(ctx);
+		if (buf_id[EXYNOS_DRM_OPS_DST] < 0)
+			return IRQ_HANDLED;
+
+		DRM_DEBUG_KMS("%s:buf_id_src[%d]buf_id_dst[%d]\n", __func__,
+			buf_id[EXYNOS_DRM_OPS_SRC], buf_id[EXYNOS_DRM_OPS_DST]);
+
+		event_work->ippdrv = ippdrv;
+		event_work->buf_id[EXYNOS_DRM_OPS_SRC] =
+			buf_id[EXYNOS_DRM_OPS_SRC];
+		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
+			buf_id[EXYNOS_DRM_OPS_DST];
+		queue_work(ippdrv->event_workq,
+			(struct work_struct *)event_work);
+	}
+
+	return IRQ_HANDLED;
+}
+
+static int gsc_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
+{
+	struct drm_exynos_ipp_prop_list *prop_list;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
+	if (!prop_list) {
+		DRM_ERROR("failed to alloc property list.\n");
+		return -ENOMEM;
+	}
+
+	/*ToDo : fix supported function list*/
+
+	prop_list->version = 1;
+	prop_list->writeback = 1;
+	prop_list->refresh_min = GSC_REFRESH_MIN;
+	prop_list->refresh_max = GSC_REFRESH_MAX;
+	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
+				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
+	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
+				(1 << EXYNOS_DRM_DEGREE_90) |
+				(1 << EXYNOS_DRM_DEGREE_180) |
+				(1 << EXYNOS_DRM_DEGREE_270);
+	prop_list->csc = 1;
+	prop_list->crop = 1;
+	prop_list->crop_max.hsize = GSC_CROP_MAX;
+	prop_list->crop_max.vsize = GSC_CROP_MAX;
+	prop_list->crop_min.hsize = GSC_CROP_MIN;
+	prop_list->crop_min.vsize = GSC_CROP_MIN;
+	prop_list->scale = 1;
+	prop_list->scale_max.hsize = GSC_SCALE_MAX;
+	prop_list->scale_max.vsize = GSC_SCALE_MAX;
+	prop_list->scale_min.hsize = GSC_SCALE_MIN;
+	prop_list->scale_min.vsize = GSC_SCALE_MIN;
+
+	ippdrv->prop_list = prop_list;
+
+	return 0;
+}
+
+static int gsc_ippdrv_check_property(struct device *dev,
+		struct drm_exynos_ipp_property *property)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_prop_list *pp = ippdrv->prop_list;
+	struct drm_exynos_ipp_config *config;
+	struct drm_exynos_pos *pos;
+	struct drm_exynos_sz *sz;
+	bool swap;
+	int i;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	for_each_ipp_ops(i) {
+		if ((i == EXYNOS_DRM_OPS_SRC) &&
+			(property->cmd == IPP_CMD_WB))
+			continue;
+
+		config = &property->config[i];
+		pos = &config->pos;
+		sz = &config->sz;
+
+		/* check for flip */
+		switch (config->flip) {
+		case EXYNOS_DRM_FLIP_NONE:
+		case EXYNOS_DRM_FLIP_VERTICAL:
+		case EXYNOS_DRM_FLIP_HORIZONTAL:
+		case EXYNOS_DRM_FLIP_VERTICAL | EXYNOS_DRM_FLIP_HORIZONTAL:
+			/* No problem */
+			break;
+		default:
+			DRM_ERROR("invalid flip.\n");
+			goto err_property;
+		}
+
+		/* check for degree */
+		switch (config->degree) {
+		case EXYNOS_DRM_DEGREE_90:
+		case EXYNOS_DRM_DEGREE_270:
+			swap = true;
+			break;
+		case EXYNOS_DRM_DEGREE_0:
+		case EXYNOS_DRM_DEGREE_180:
+			swap = false;
+			break;
+		default:
+			DRM_ERROR("invalid degree.\n");
+			goto err_property;
+		}
+
+		/* check for buffer bound */
+		if ((pos->x + pos->w > sz->hsize) ||
+			(pos->y + pos->h > sz->vsize)) {
+			DRM_ERROR("out of buf bound.\n");
+			goto err_property;
+		}
+
+		/* check for crop */
+		if ((i == EXYNOS_DRM_OPS_SRC) && (pp->crop)) {
+			if (swap) {
+				if ((pos->h < pp->crop_min.hsize) ||
+					(sz->vsize > pp->crop_max.hsize) ||
+					(pos->w < pp->crop_min.vsize) ||
+					(sz->hsize > pp->crop_max.vsize)) {
+					DRM_ERROR("out of crop size.\n");
+					goto err_property;
+				}
+			} else {
+				if ((pos->w < pp->crop_min.hsize) ||
+					(sz->hsize > pp->crop_max.hsize) ||
+					(pos->h < pp->crop_min.vsize) ||
+					(sz->vsize > pp->crop_max.vsize)) {
+					DRM_ERROR("out of crop size.\n");
+					goto err_property;
+				}
+			}
+		}
+
+		/* check for scale */
+		if ((i == EXYNOS_DRM_OPS_DST) && (pp->scale)) {
+			if (swap) {
+				if ((pos->h < pp->scale_min.hsize) ||
+					(sz->vsize > pp->scale_max.hsize) ||
+					(pos->w < pp->scale_min.vsize) ||
+					(sz->hsize > pp->scale_max.vsize)) {
+					DRM_ERROR("out of scale size.\n");
+					goto err_property;
+				}
+			} else {
+				if ((pos->w < pp->scale_min.hsize) ||
+					(sz->hsize > pp->scale_max.hsize) ||
+					(pos->h < pp->scale_min.vsize) ||
+					(sz->vsize > pp->scale_max.vsize)) {
+					DRM_ERROR("out of scale size.\n");
+					goto err_property;
+				}
+			}
+		}
+	}
+
+	return 0;
+
+err_property:
+	for_each_ipp_ops(i) {
+		if ((i == EXYNOS_DRM_OPS_SRC) &&
+			(property->cmd == IPP_CMD_WB))
+			continue;
+
+		config = &property->config[i];
+		pos = &config->pos;
+		sz = &config->sz;
+
+		DRM_ERROR("[%s]f[%d]r[%d]pos[%d %d %d %d]sz[%d %d]\n",
+			i ? "dst" : "src", config->flip, config->degree,
+			pos->x, pos->y, pos->w, pos->h,
+			sz->hsize, sz->vsize);
+	}
+
+	return -EINVAL;
+}
+
+
+static int gsc_ippdrv_reset(struct device *dev)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct gsc_scaler *sc = &ctx->sc;
+	int ret;
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	/* reset h/w block */
+	ret = gsc_sw_reset(ctx);
+	if (ret < 0) {
+		dev_err(dev, "failed to reset hardware.\n");
+		return ret;
+	}
+
+	/* scaler setting */
+	memset(&ctx->sc, 0x0, sizeof(ctx->sc));
+	sc->range = true;
+
+	return 0;
+}
+
+static int gsc_check_prepare(struct gsc_context *ctx)
+{
+	/* ToDo: check prepare using read register */
+
+	DRM_DEBUG_KMS("%s\n", __func__);
+
+	return 0;
+}
+
+static int gsc_ippdrv_start(struct device *dev, enum drm_exynos_ipp_cmd cmd)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
+	struct drm_exynos_ipp_property *property;
+	struct drm_exynos_ipp_config *config;
+	struct drm_exynos_pos	img_pos[EXYNOS_DRM_OPS_MAX];
+	struct drm_exynos_ipp_set_wb set_wb;
+	u32 cfg;
+	int ret, i;
+
+	DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, cmd);
+
+	if (!c_node) {
+		DRM_ERROR("failed to get c_node.\n");
+		return -EINVAL;
+	}
+
+	property = &c_node->property;
+	if (!property) {
+		DRM_ERROR("failed to get property.\n");
+		return -EINVAL;
+	}
+
+	ret = gsc_check_prepare(ctx);
+	if (ret) {
+		dev_err(dev, "failed to check prepare.\n");
+		return ret;
+	}
+
+	gsc_handle_irq(ctx, true, false, true);
+
+	/* ToDo: window size, prescaler config */
+	for_each_ipp_ops(i) {
+		config = &property->config[i];
+		img_pos[i] = config->pos;
+	}
+
+	switch (cmd) {
+	case IPP_CMD_M2M:
+		/* enable one shot */
+		cfg = gsc_read(GSC_ENABLE);
+		cfg &= ~(GSC_ENABLE_ON_CLEAR_MASK |
+			GSC_ENABLE_CLK_GATE_MODE_MASK);
+		cfg |= GSC_ENABLE_ON_CLEAR_ONESHOT;
+		gsc_write(cfg, GSC_ENABLE);
+
+		/* src dma memory */
+		cfg = gsc_read(GSC_IN_CON);
+		cfg &= ~(GSC_IN_PATH_MASK | GSC_IN_LOCAL_SEL_MASK);
+		cfg |= GSC_IN_PATH_MEMORY;
+		gsc_write(cfg, GSC_IN_CON);
+
+		/* dst dma memory */
+		cfg = gsc_read(GSC_OUT_CON);
+		cfg |= GSC_OUT_PATH_MEMORY;
+		gsc_write(cfg, GSC_OUT_CON);
+		break;
+	case IPP_CMD_WB:
+		/* ToDo: need to replace the property structure. */
+		set_wb.enable = 1;
+		set_wb.refresh = property->refresh_rate;
+		gsc_set_gscblk_fimd_wb(ctx, set_wb.enable);
+		exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb);
+
+		/* src local path */
+		cfg = readl(GSC_IN_CON);
+		cfg &= ~(GSC_IN_PATH_MASK | GSC_IN_LOCAL_SEL_MASK);
+		cfg |= (GSC_IN_PATH_LOCAL | GSC_IN_LOCAL_FIMD_WB);
+		gsc_write(cfg, GSC_IN_CON);
+
+		/* dst dma memory */
+		cfg = gsc_read(GSC_OUT_CON);
+		cfg |= GSC_OUT_PATH_MEMORY;
+		gsc_write(cfg, GSC_OUT_CON);
+		break;
+	case IPP_CMD_OUTPUT:
+		/* src dma memory */
+		cfg = gsc_read(GSC_IN_CON);
+		cfg &= ~(GSC_IN_PATH_MASK | GSC_IN_LOCAL_SEL_MASK);
+		cfg |= GSC_IN_PATH_MEMORY;
+		gsc_write(cfg, GSC_IN_CON);
+
+		/* dst local path */
+		cfg = gsc_read(GSC_OUT_CON);
+		cfg |= GSC_OUT_PATH_MEMORY;
+		gsc_write(cfg, GSC_OUT_CON);
+		break;
+	default:
+		ret = -EINVAL;
+		dev_err(dev, "invalid operations.\n");
+		return ret;
+	}
+
+	ret = gsc_set_prescaler(ctx, &ctx->sc,
+		&img_pos[EXYNOS_DRM_OPS_SRC],
+		&img_pos[EXYNOS_DRM_OPS_DST]);
+	if (ret) {
+		dev_err(dev, "failed to set precalser.\n");
+		return ret;
+	}
+
+	gsc_set_scaler(ctx, &ctx->sc);
+
+	cfg = gsc_read(GSC_ENABLE);
+	cfg |= GSC_ENABLE_ON;
+	gsc_write(cfg, GSC_ENABLE);
+
+	return 0;
+}
+
+static void gsc_ippdrv_stop(struct device *dev, enum drm_exynos_ipp_cmd cmd)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct drm_exynos_ipp_set_wb set_wb = {0, 0};
+	u32 cfg;
+
+	DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, cmd);
+
+	switch (cmd) {
+	case IPP_CMD_M2M:
+		/* bypass */
+		break;
+	case IPP_CMD_WB:
+		gsc_set_gscblk_fimd_wb(ctx, set_wb.enable);
+		exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb);
+		break;
+	case IPP_CMD_OUTPUT:
+	default:
+		dev_err(dev, "invalid operations.\n");
+		break;
+	}
+
+	gsc_handle_irq(ctx, false, false, true);
+
+	/* reset sequence */
+	gsc_write(0xff, GSC_OUT_BASE_ADDR_Y_MASK);
+	gsc_write(0xff, GSC_OUT_BASE_ADDR_CB_MASK);
+	gsc_write(0xff, GSC_OUT_BASE_ADDR_CR_MASK);
+
+	cfg = gsc_read(GSC_ENABLE);
+	cfg &= ~GSC_ENABLE_ON;
+	gsc_write(cfg, GSC_ENABLE);
+}
+
+static int __devinit gsc_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct gsc_context *ctx;
+	struct resource *res;
+	struct exynos_drm_ippdrv *ippdrv;
+	int ret;
+
+	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	/* clock control */
+	ctx->gsc_clk = clk_get(dev, "gscl");
+	if (IS_ERR(ctx->gsc_clk)) {
+		dev_err(dev, "failed to get gsc clock.\n");
+		ret = PTR_ERR(ctx->gsc_clk);
+		goto err_ctx;
+	}
+
+	ctx->parent_clk = clk_get(NULL, "aclk_300_gscl");
+	if (IS_ERR(ctx->parent_clk)) {
+		dev_err(dev, "failed to get parent clock.\n");
+		ret = PTR_ERR(ctx->parent_clk);
+		clk_put(ctx->gsc_clk);
+		goto err_ctx;
+	}
+
+	ctx->child_clk = clk_get(NULL, "dout_aclk_300_gscl");
+	if (IS_ERR(ctx->child_clk)) {
+		dev_err(dev, "failed to get child clock.\n");
+		ret = PTR_ERR(ctx->child_clk);
+		clk_put(ctx->gsc_clk);
+		clk_put(ctx->parent_clk);
+		goto err_ctx;
+	}
+
+	/* resource memory */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(dev, "failed to find registers.\n");
+		ret = -ENOENT;
+		goto err_clk;
+	}
+
+	ctx->regs_res = request_mem_region(res->start, resource_size(res),
+					   dev_name(dev));
+	if (!ctx->regs_res) {
+		dev_err(dev, "failed to claim register region.\n");
+		ret = -ENOENT;
+		goto err_clk;
+	}
+
+	ctx->regs = ioremap(res->start, resource_size(res));
+	if (!ctx->regs) {
+		dev_err(dev, "failed to map registers.\n");
+		ret = -ENXIO;
+		goto err_req_region;
+	}
+
+	/* resource irq */
+	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+	if (!res) {
+		dev_err(dev, "failed to request irq resource.\n");
+		ret = -ENOENT;
+		goto err_get_regs;
+	}
+
+	ctx->irq = res->start;
+	ret = request_threaded_irq(ctx->irq, NULL, gsc_irq_handler,
+		IRQF_ONESHOT, "drm_gsc", ctx);
+	if (ret < 0) {
+		dev_err(dev, "failed to request irq.\n");
+		goto err_get_regs;
+	}
+
+	/* context initailization */
+	ctx->id = pdev->id;
+
+	ippdrv = &ctx->ippdrv;
+	ippdrv->dev = dev;
+	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &gsc_src_ops;
+	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &gsc_dst_ops;
+	ippdrv->check_property = gsc_ippdrv_check_property;
+	ippdrv->reset = gsc_ippdrv_reset;
+	ippdrv->start = gsc_ippdrv_start;
+	ippdrv->stop = gsc_ippdrv_stop;
+	ret = gsc_init_prop_list(ippdrv);
+	if (ret < 0) {
+		dev_err(dev, "failed to init property list.\n");
+		goto err_get_irq;
+	}
+
+	DRM_DEBUG_KMS("%s:id[%d]ippdrv[0x%x]\n", __func__, ctx->id,
+		(int)ippdrv);
+
+	mutex_init(&ctx->lock);
+	platform_set_drvdata(pdev, ctx);
+
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+
+	ret = exynos_drm_ippdrv_register(ippdrv);
+	if (ret < 0) {
+		dev_err(dev, "failed to register drm gsc device.\n");
+		goto err_ippdrv_register;
+	}
+
+	dev_info(&pdev->dev, "drm gsc registered successfully.\n");
+
+	return 0;
+
+err_ippdrv_register:
+	kfree(ippdrv->prop_list);
+	pm_runtime_disable(dev);
+	free_irq(ctx->irq, ctx);
+err_get_irq:
+	free_irq(ctx->irq, ctx);
+err_get_regs:
+	iounmap(ctx->regs);
+err_req_region:
+	release_resource(ctx->regs_res);
+	kfree(ctx->regs_res);
+err_clk:
+	clk_put(ctx->child_clk);
+	clk_put(ctx->parent_clk);
+	clk_put(ctx->gsc_clk);
+err_ctx:
+	kfree(ctx);
+	return ret;
+}
+
+static int __devexit gsc_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct gsc_context *ctx = get_gsc_context(dev);
+	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
+
+	kfree(ippdrv->prop_list);
+	exynos_drm_ippdrv_unregister(ippdrv);
+	mutex_destroy(&ctx->lock);
+
+	pm_runtime_set_suspended(dev);
+	pm_runtime_disable(dev);
+
+	free_irq(ctx->irq, ctx);
+	iounmap(ctx->regs);
+	release_resource(ctx->regs_res);
+	kfree(ctx->regs_res);
+
+	clk_put(ctx->child_clk);
+	clk_put(ctx->parent_clk);
+	clk_put(ctx->gsc_clk);
+
+	kfree(ctx);
+
+	return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int gsc_suspend(struct device *dev)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
+
+	if (pm_runtime_suspended(dev))
+		return 0;
+
+	return gsc_clk_ctrl(ctx, false);
+}
+
+static int gsc_resume(struct device *dev)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
+
+	if (!pm_runtime_suspended(dev))
+		return gsc_clk_ctrl(ctx, true);
+
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_PM_RUNTIME
+static int gsc_runtime_suspend(struct device *dev)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
+
+	return  gsc_clk_ctrl(ctx, false);
+}
+
+static int gsc_runtime_resume(struct device *dev)
+{
+	struct gsc_context *ctx = get_gsc_context(dev);
+
+	/* ToDo */
+
+	DRM_DEBUG_KMS("%s:id[%d]\n", __FILE__, ctx->id);
+
+	return  gsc_clk_ctrl(ctx, true);
+}
+#endif
+
+static const struct dev_pm_ops gsc_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(gsc_suspend, gsc_resume)
+	SET_RUNTIME_PM_OPS(gsc_runtime_suspend, gsc_runtime_resume, NULL)
+};
+
+/* ToDo: need to check use case platform_device_id */
+struct platform_driver gsc_driver = {
+	.probe		= gsc_probe,
+	.remove		= __devexit_p(gsc_remove),
+	.driver		= {
+		.name	= "exynos-drm-gsc",
+		.owner	= THIS_MODULE,
+		.pm	= &gsc_pm_ops,
+	},
+};
+
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.h b/drivers/gpu/drm/exynos/exynos_drm_gsc.h
new file mode 100644
index 0000000..b3ef7a0
--- /dev/null
+++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Authors:
+ *	Eunchul Kim <chulspro.kim@samsung.com>
+ *	Jinyoung Jeon <jy0.jeon@samsung.com>
+ *	Sangmin Lee <lsmin.lee@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _EXYNOS_DRM_GSC_H_
+#define _EXYNOS_DRM_GSC_H_
+
+/* ToDo */
+
+#endif /* _EXYNOS_DRM_GSC_H_ */
diff --git a/drivers/gpu/drm/exynos/regs-gsc.h b/drivers/gpu/drm/exynos/regs-gsc.h
new file mode 100644
index 0000000..ed297b5
--- /dev/null
+++ b/drivers/gpu/drm/exynos/regs-gsc.h
@@ -0,0 +1,295 @@
+/* linux/drivers/gpu/drm/exynos/regs-gsc.h
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *		http://www.samsung.com
+ *
+ * Register definition file for Samsung G-Scaler driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef EXYNOS_REGS_GSC_H_
+#define EXYNOS_REGS_GSC_H_
+
+/* SYSCON. GSCBLK_CFG */
+#include <plat/map-base.h>
+#include <plat/cpu.h>
+#define SYSREG_DISP1BLK_CFG		(S3C_VA_SYS + 0x0214)
+#define FIFORST_DISP1			(1 << 23)
+#define GSC_OUT_MIXER0			(1 << 7)
+#define GSC_OUT_MIXER0_GSC3		(3 << 5)
+#define SYSREG_GSCBLK_CFG0		(S3C_VA_SYS + 0x0220)
+#define GSC_OUT_DST_FIMD_SEL(x)		(1 << (8 + 2 * (x)))
+#define GSC_OUT_DST_MXR_SEL(x)		(2 << (8 + 2 * (x)))
+#define GSC_PXLASYNC_RST(x)		(1 << (x))
+#define PXLASYNC_LO_MASK_CAMIF_TOP	(1 << 20)
+#define SYSREG_GSCBLK_CFG1		(S3C_VA_SYS + 0x0224)
+#define GSC_BLK_DISP1WB_DEST(x)		(x << 10)
+#define GSC_BLK_SW_RESET_WB_DEST(x)	(1 << (18 + x))
+#define GSC_BLK_PXLASYNC_LO_MASK_WB(x)	(0 << (14 + x))
+#define GSC_BLK_GSCL_WB_IN_SRC_SEL(x)	(1 << (2 * x))
+#define SYSREG_GSCBLK_CFG2		(S3C_VA_SYS + 0x2000)
+#define PXLASYNC_LO_MASK_CAMIF_GSCL(x)	(1 << (x))
+
+/* G-Scaler enable */
+#define GSC_ENABLE			0x00
+#define GSC_ENABLE_PP_UPDATE_TIME_MASK	(1 << 9)
+#define GSC_ENABLE_PP_UPDATE_TIME_CURR	(0 << 9)
+#define GSC_ENABLE_PP_UPDATE_TIME_EOPAS	(1 << 9)
+#define GSC_ENABLE_CLK_GATE_MODE_MASK	(1 << 8)
+#define GSC_ENABLE_CLK_GATE_MODE_FREE	(1 << 8)
+#define GSC_ENABLE_IPC_MODE_MASK	(1 << 7)
+#define GSC_ENABLE_NORM_MODE		(0 << 7)
+#define GSC_ENABLE_IPC_MODE		(1 << 7)
+#define GSC_ENABLE_PP_UPDATE_MODE_MASK	(1 << 6)
+#define GSC_ENABLE_PP_UPDATE_FIRE_MODE	(1 << 6)
+#define GSC_ENABLE_IN_PP_UPDATE		(1 << 5)
+#define GSC_ENABLE_ON_CLEAR_MASK	(1 << 4)
+#define GSC_ENABLE_ON_CLEAR_ONESHOT	(1 << 4)
+#define GSC_ENABLE_QOS_ENABLE		(1 << 3)
+#define GSC_ENABLE_OP_STATUS		(1 << 2)
+#define GSC_ENABLE_SFR_UPDATE		(1 << 1)
+#define GSC_ENABLE_ON			(1 << 0)
+
+/* G-Scaler S/W reset */
+#define GSC_SW_RESET			0x04
+#define GSC_SW_RESET_SRESET		(1 << 0)
+
+/* G-Scaler IRQ */
+#define GSC_IRQ				0x08
+#define GSC_IRQ_STATUS_OR_IRQ		(1 << 17)
+#define GSC_IRQ_STATUS_OR_FRM_DONE	(1 << 16)
+#define GSC_IRQ_OR_MASK			(1 << 2)
+#define GSC_IRQ_FRMDONE_MASK		(1 << 1)
+#define GSC_IRQ_ENABLE			(1 << 0)
+
+/* G-Scaler input control */
+#define GSC_IN_CON			0x10
+#define GSC_IN_CHROM_STRIDE_SEL_MASK	(1 << 20)
+#define GSC_IN_CHROM_STRIDE_SEPAR	(1 << 20)
+#define GSC_IN_RB_SWAP_MASK		(1 << 19)
+#define GSC_IN_RB_SWAP			(1 << 19)
+#define GSC_IN_ROT_MASK			(7 << 16)
+#define GSC_IN_ROT_270			(7 << 16)
+#define GSC_IN_ROT_90_YFLIP		(6 << 16)
+#define GSC_IN_ROT_90_XFLIP		(5 << 16)
+#define GSC_IN_ROT_90			(4 << 16)
+#define GSC_IN_ROT_180			(3 << 16)
+#define GSC_IN_ROT_YFLIP		(2 << 16)
+#define GSC_IN_ROT_XFLIP		(1 << 16)
+#define GSC_IN_RGB_TYPE_MASK		(3 << 14)
+#define GSC_IN_RGB_HD_WIDE		(3 << 14)
+#define GSC_IN_RGB_HD_NARROW		(2 << 14)
+#define GSC_IN_RGB_SD_WIDE		(1 << 14)
+#define GSC_IN_RGB_SD_NARROW		(0 << 14)
+#define GSC_IN_YUV422_1P_ORDER_MASK	(1 << 13)
+#define GSC_IN_YUV422_1P_ORDER_LSB_Y	(0 << 13)
+#define GSC_IN_YUV422_1P_OEDER_LSB_C	(1 << 13)
+#define GSC_IN_CHROMA_ORDER_MASK	(1 << 12)
+#define GSC_IN_CHROMA_ORDER_CBCR	(0 << 12)
+#define GSC_IN_CHROMA_ORDER_CRCB	(1 << 12)
+#define GSC_IN_FORMAT_MASK		(7 << 8)
+#define GSC_IN_XRGB8888			(0 << 8)
+#define GSC_IN_RGB565			(1 << 8)
+#define GSC_IN_YUV420_2P		(2 << 8)
+#define GSC_IN_YUV420_3P		(3 << 8)
+#define GSC_IN_YUV422_1P		(4 << 8)
+#define GSC_IN_YUV422_2P		(5 << 8)
+#define GSC_IN_YUV422_3P		(6 << 8)
+#define GSC_IN_TILE_TYPE_MASK		(1 << 4)
+#define GSC_IN_TILE_C_16x8		(0 << 4)
+#define GSC_IN_TILE_C_16x16		(1 << 4)
+#define GSC_IN_TILE_MODE		(1 << 3)
+#define GSC_IN_LOCAL_SEL_MASK		(3 << 1)
+#define GSC_IN_LOCAL_CAM3		(3 << 1)
+#define GSC_IN_LOCAL_FIMD_WB		(2 << 1)
+#define GSC_IN_LOCAL_CAM1		(1 << 1)
+#define GSC_IN_LOCAL_CAM0		(0 << 1)
+#define GSC_IN_PATH_MASK		(1 << 0)
+#define GSC_IN_PATH_LOCAL		(1 << 0)
+#define GSC_IN_PATH_MEMORY		(0 << 0)
+
+/* G-Scaler source image size */
+#define GSC_SRCIMG_SIZE			0x14
+#define GSC_SRCIMG_HEIGHT_MASK		(0x1fff << 16)
+#define GSC_SRCIMG_HEIGHT(x)		((x) << 16)
+#define GSC_SRCIMG_WIDTH_MASK		(0x3fff << 0)
+#define GSC_SRCIMG_WIDTH(x)		((x) << 0)
+
+/* G-Scaler source image offset */
+#define GSC_SRCIMG_OFFSET		0x18
+#define GSC_SRCIMG_OFFSET_Y_MASK	(0x1fff << 16)
+#define GSC_SRCIMG_OFFSET_Y(x)		((x) << 16)
+#define GSC_SRCIMG_OFFSET_X_MASK	(0x1fff << 0)
+#define GSC_SRCIMG_OFFSET_X(x)		((x) << 0)
+
+/* G-Scaler cropped source image size */
+#define GSC_CROPPED_SIZE		0x1C
+#define GSC_CROPPED_HEIGHT_MASK		(0x1fff << 16)
+#define GSC_CROPPED_HEIGHT(x)		((x) << 16)
+#define GSC_CROPPED_WIDTH_MASK		(0x1fff << 0)
+#define GSC_CROPPED_WIDTH(x)		((x) << 0)
+
+/* G-Scaler output control */
+#define GSC_OUT_CON			0x20
+#define GSC_OUT_GLOBAL_ALPHA_MASK	(0xff << 24)
+#define GSC_OUT_GLOBAL_ALPHA(x)		((x) << 24)
+#define GSC_OUT_CHROM_STRIDE_SEL_MASK	(1 << 13)
+#define GSC_OUT_CHROM_STRIDE_SEPAR	(1 << 13)
+#define GSC_OUT_RB_SWAP_MASK		(1 << 12)
+#define GSC_OUT_RB_SWAP			(1 << 12)
+#define GSC_OUT_RGB_TYPE_MASK		(3 << 10)
+#define GSC_OUT_RGB_HD_NARROW		(3 << 10)
+#define GSC_OUT_RGB_HD_WIDE		(2 << 10)
+#define GSC_OUT_RGB_SD_NARROW		(1 << 10)
+#define GSC_OUT_RGB_SD_WIDE		(0 << 10)
+#define GSC_OUT_YUV422_1P_ORDER_MASK	(1 << 9)
+#define GSC_OUT_YUV422_1P_ORDER_LSB_Y	(0 << 9)
+#define GSC_OUT_YUV422_1P_OEDER_LSB_C	(1 << 9)
+#define GSC_OUT_CHROMA_ORDER_MASK	(1 << 8)
+#define GSC_OUT_CHROMA_ORDER_CBCR	(0 << 8)
+#define GSC_OUT_CHROMA_ORDER_CRCB	(1 << 8)
+#define GSC_OUT_FORMAT_MASK		(7 << 4)
+#define GSC_OUT_XRGB8888		(0 << 4)
+#define GSC_OUT_RGB565			(1 << 4)
+#define GSC_OUT_YUV420_2P		(2 << 4)
+#define GSC_OUT_YUV420_3P		(3 << 4)
+#define GSC_OUT_YUV422_1P		(4 << 4)
+#define GSC_OUT_YUV422_2P		(5 << 4)
+#define GSC_OUT_YUV444			(7 << 4)
+#define GSC_OUT_TILE_TYPE_MASK		(1 << 2)
+#define GSC_OUT_TILE_C_16x8		(0 << 2)
+#define GSC_OUT_TILE_C_16x16		(1 << 2)
+#define GSC_OUT_TILE_MODE		(1 << 1)
+#define GSC_OUT_PATH_MASK		(1 << 0)
+#define GSC_OUT_PATH_LOCAL		(1 << 0)
+#define GSC_OUT_PATH_MEMORY		(0 << 0)
+
+/* G-Scaler scaled destination image size */
+#define GSC_SCALED_SIZE			0x24
+#define GSC_SCALED_HEIGHT_MASK		(0x1fff << 16)
+#define GSC_SCALED_HEIGHT(x)		((x) << 16)
+#define GSC_SCALED_WIDTH_MASK		(0x1fff << 0)
+#define GSC_SCALED_WIDTH(x)		((x) << 0)
+
+/* G-Scaler pre scale ratio */
+#define GSC_PRE_SCALE_RATIO		0x28
+#define GSC_PRESC_SHFACTOR_MASK		(7 << 28)
+#define GSC_PRESC_SHFACTOR(x)		((x) << 28)
+#define GSC_PRESC_V_RATIO_MASK		(7 << 16)
+#define GSC_PRESC_V_RATIO(x)		((x) << 16)
+#define GSC_PRESC_H_RATIO_MASK		(7 << 0)
+#define GSC_PRESC_H_RATIO(x)		((x) << 0)
+
+/* G-Scaler main scale horizontal ratio */
+#define GSC_MAIN_H_RATIO		0x2C
+#define GSC_MAIN_H_RATIO_MASK		(0xfffff << 0)
+#define GSC_MAIN_H_RATIO_VALUE(x)	((x) << 0)
+
+/* G-Scaler main scale vertical ratio */
+#define GSC_MAIN_V_RATIO		0x30
+#define GSC_MAIN_V_RATIO_MASK		(0xfffff << 0)
+#define GSC_MAIN_V_RATIO_VALUE(x)	((x) << 0)
+
+/* G-Scaler input chrominance stride */
+#define GSC_IN_CHROM_STRIDE		0x3C
+#define GSC_IN_CHROM_STRIDE_MASK	(0x3fff << 0)
+#define GSC_IN_CHROM_STRIDE_VALUE(x)	((x) << 0)
+
+/* G-Scaler destination image size */
+#define GSC_DSTIMG_SIZE			0x40
+#define GSC_DSTIMG_HEIGHT_MASK		(0x1fff << 16)
+#define GSC_DSTIMG_HEIGHT(x)		((x) << 16)
+#define GSC_DSTIMG_WIDTH_MASK		(0x1fff << 0)
+#define GSC_DSTIMG_WIDTH(x)		((x) << 0)
+
+/* G-Scaler destination image offset */
+#define GSC_DSTIMG_OFFSET		0x44
+#define GSC_DSTIMG_OFFSET_Y_MASK	(0x1fff << 16)
+#define GSC_DSTIMG_OFFSET_Y(x)		((x) << 16)
+#define GSC_DSTIMG_OFFSET_X_MASK	(0x1fff << 0)
+#define GSC_DSTIMG_OFFSET_X(x)		((x) << 0)
+
+/* G-Scaler output chrominance stride */
+#define GSC_OUT_CHROM_STRIDE		0x48
+#define GSC_OUT_CHROM_STRIDE_MASK	(0x3fff << 0)
+#define GSC_OUT_CHROM_STRIDE_VALUE(x)	((x) << 0)
+
+/* G-Scaler input y address mask */
+#define GSC_IN_BASE_ADDR_Y_MASK		0x4C
+/* G-Scaler input y base address */
+#define GSC_IN_BASE_ADDR_Y(n)		(0x50 + (n) * 0x4)
+/* G-Scaler input y base current address */
+#define GSC_IN_BASE_ADDR_Y_CUR(n)	(0x60 + (n) * 0x4)
+
+/* G-Scaler input cb address mask */
+#define GSC_IN_BASE_ADDR_CB_MASK	0x7C
+/* G-Scaler input cb base address */
+#define GSC_IN_BASE_ADDR_CB(n)		(0x80 + (n) * 0x4)
+/* G-Scaler input cb base current address */
+#define GSC_IN_BASE_ADDR_CB_CUR(n)	(0x90 + (n) * 0x4)
+
+/* G-Scaler input cr address mask */
+#define GSC_IN_BASE_ADDR_CR_MASK	0xAC
+/* G-Scaler input cr base address */
+#define GSC_IN_BASE_ADDR_CR(n)		(0xB0 + (n) * 0x4)
+/* G-Scaler input cr base current address */
+#define GSC_IN_BASE_ADDR_CR_CUR(n)	(0xC0 + (n) * 0x4)
+
+/* G-Scaler input address mask */
+#define GSC_IN_CURR_ADDR_INDEX	(0xf << 24)
+#define GSC_IN_CURR_GET_INDEX(x)	((x) >> 24)
+#define GSC_IN_BASE_ADDR_PINGPONG(x)	((x) << 16)
+#define GSC_IN_BASE_ADDR_MASK		(0xff << 0)
+
+/* G-Scaler output y address mask */
+#define GSC_OUT_BASE_ADDR_Y_MASK	0x10C
+/* G-Scaler output y base address */
+#define GSC_OUT_BASE_ADDR_Y(n)		(0x110 + (n) * 0x4)
+
+/* G-Scaler output cb address mask */
+#define GSC_OUT_BASE_ADDR_CB_MASK	0x15C
+/* G-Scaler output cb base address */
+#define GSC_OUT_BASE_ADDR_CB(n)		(0x160 + (n) * 0x4)
+
+/* G-Scaler output cr address mask */
+#define GSC_OUT_BASE_ADDR_CR_MASK	0x1AC
+/* G-Scaler output cr base address */
+#define GSC_OUT_BASE_ADDR_CR(n)		(0x1B0 + (n) * 0x4)
+
+/* G-Scaler output address mask */
+#define GSC_OUT_CURR_ADDR_INDEX		(0xf << 24)
+#define GSC_OUT_CURR_GET_INDEX(x)	((x) >> 24)
+#define GSC_OUT_BASE_ADDR_PINGPONG(x)	((x) << 16)
+#define GSC_OUT_BASE_ADDR_MASK		(0xffff << 0)
+
+/* G-Scaler horizontal scaling filter */
+#define GSC_HCOEF(n, s, x)	(0x300 + (n) * 0x4 + (s) * 0x30 + (x) * 0x300)
+
+/* G-Scaler vertical scaling filter */
+#define GSC_VCOEF(n, s, x)	(0x200 + (n) * 0x4 + (s) * 0x30 + (x) * 0x300)
+
+/* G-Scaler BUS control */
+#define GSC_BUSCON			0xA78
+#define GSC_BUSCON_INT_TIME_MASK	(1 << 8)
+#define GSC_BUSCON_INT_DATA_TRANS	(0 << 8)
+#define GSC_BUSCON_INT_AXI_RESPONSE	(1 << 8)
+#define GSC_BUSCON_AWCACHE(x)		((x) << 4)
+#define GSC_BUSCON_ARCACHE(x)		((x) << 0)
+
+/* G-Scaler V position */
+#define GSC_VPOSITION			0xA7C
+#define GSC_VPOS_F(x)			((x) << 0)
+
+
+/* G-Scaler clock initial count */
+#define GSC_CLK_INIT_COUNT		0xC00
+#define GSC_CLK_GATE_MODE_INIT_CNT(x)	((x) << 0)
+
+/* G-Scaler clock snoop count */
+#define GSC_CLK_SNOOP_COUNT		0xC04
+#define GSC_CLK_GATE_MODE_SNOOP_CNT(x)	((x) << 0)
+
+#endif /* EXYNOS_REGS_GSC_H_ */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* RE: [RFC v3 1/5] drm/exynos: add ipp subsystem
  2012-12-12  7:34 ` [RFC v3 1/5] drm/exynos: add ipp subsystem Eunchul Kim
@ 2012-12-12  8:18   ` Inki Dae
  2012-12-12  9:02     ` Eunchul Kim
  0 siblings, 1 reply; 18+ messages in thread
From: Inki Dae @ 2012-12-12  8:18 UTC (permalink / raw)
  To: 'Eunchul Kim', dri-devel
  Cc: jy0.jeon, kyungmin.park, jmock.shin, jaejoon.seo



> -----Original Message-----
> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> Sent: Wednesday, December 12, 2012 4:35 PM
> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com; jmock.shin@samsung.com;
> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
> chulspro.kim@samsung.com
> Subject: [RFC v3 1/5] drm/exynos: add ipp subsystem
> 
> IPP stand for Image Post Processing and supports image scaler/rotator
> /crop/flip/csc(color space conversion) and input/output DMA operations
> using ipp drivers.
> also supports writeback and display output operations.
> ipp driver include FIMC, Rotator, GSC, SC, so on.
> and ipp is integration device driver for each hardware.
> 
> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
> Signed-off-by: Jinyoung Jeon <jy0.jeon@samsung.com>
> ---
>  drivers/gpu/drm/exynos/Kconfig          |    6 +
>  drivers/gpu/drm/exynos/Makefile         |    1 +
>  drivers/gpu/drm/exynos/exynos_drm_drv.c |   24 +
>  drivers/gpu/drm/exynos/exynos_drm_drv.h |    7 +
>  drivers/gpu/drm/exynos/exynos_drm_ipp.c | 2059
> +++++++++++++++++++++++++++++++
>  drivers/gpu/drm/exynos/exynos_drm_ipp.h |  266 ++++
>  include/uapi/drm/exynos_drm.h           |  190 +++
>  7 files changed, 2553 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.c
>  create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.h
> 
> diff --git a/drivers/gpu/drm/exynos/Kconfig
> b/drivers/gpu/drm/exynos/Kconfig
> index 4ea8cdc..bcf1c9d 100644
> --- a/drivers/gpu/drm/exynos/Kconfig
> +++ b/drivers/gpu/drm/exynos/Kconfig
> @@ -45,3 +45,9 @@ config DRM_EXYNOS_G2D
>  	depends on DRM_EXYNOS && !VIDEO_SAMSUNG_S5P_G2D
>  	help
>  	  Choose this option if you want to use Exynos G2D for DRM.
> +
> +config DRM_EXYNOS_IPP
> +	bool "Exynos DRM IPP"
> +	depends on DRM_EXYNOS
> +	help
> +	  Choose this option if you want to use IPP feature for DRM.
> diff --git a/drivers/gpu/drm/exynos/Makefile
> b/drivers/gpu/drm/exynos/Makefile
> index 26813b8..6c536ce 100644
> --- a/drivers/gpu/drm/exynos/Makefile
> +++ b/drivers/gpu/drm/exynos/Makefile
> @@ -16,5 +16,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI)	+=
> exynos_hdmi.o exynos_mixer.o \
>  					   exynos_drm_hdmi.o
>  exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+= exynos_drm_vidi.o
>  exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
> +exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
> 
>  obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index 4a1168d..0eb8a97 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -40,6 +40,7 @@
>  #include "exynos_drm_vidi.h"
>  #include "exynos_drm_dmabuf.h"
>  #include "exynos_drm_g2d.h"
> +#include "exynos_drm_ipp.h"
>  #include "exynos_drm_iommu.h"
> 
>  #define DRIVER_NAME	"exynos"
> @@ -249,6 +250,14 @@ static struct drm_ioctl_desc exynos_ioctls[] = {
>  			exynos_g2d_set_cmdlist_ioctl, DRM_UNLOCKED |
DRM_AUTH),
>  	DRM_IOCTL_DEF_DRV(EXYNOS_G2D_EXEC,
>  			exynos_g2d_exec_ioctl, DRM_UNLOCKED | DRM_AUTH),
> +	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_PROPERTY,
> +			exynos_drm_ipp_get_property, DRM_UNLOCKED |
DRM_AUTH),
> +	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_SET_PROPERTY,
> +			exynos_drm_ipp_set_property, DRM_UNLOCKED |
DRM_AUTH),
> +	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_QUEUE_BUF,
> +			exynos_drm_ipp_queue_buf, DRM_UNLOCKED | DRM_AUTH),
> +	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_CMD_CTRL,
> +			exynos_drm_ipp_cmd_ctrl, DRM_UNLOCKED | DRM_AUTH),
>  };
> 
>  static const struct file_operations exynos_drm_driver_fops = {
> @@ -363,6 +372,12 @@ static int __init exynos_drm_init(void)
>  		goto out_g2d;
>  #endif
> 
> +#ifdef CONFIG_DRM_EXYNOS_IPP
> +	ret = platform_driver_register(&ipp_driver);
> +	if (ret < 0)
> +		goto out_ipp;
> +#endif
> +
>  	ret = platform_driver_register(&exynos_drm_platform_driver);
>  	if (ret < 0)
>  		goto out_drm;
> @@ -380,6 +395,11 @@ out:
>  	platform_driver_unregister(&exynos_drm_platform_driver);
> 
>  out_drm:
> +#ifdef CONFIG_DRM_EXYNOS_IPP
> +	platform_driver_unregister(&ipp_driver);
> +out_ipp:
> +#endif
> +
>  #ifdef CONFIG_DRM_EXYNOS_G2D
>  	platform_driver_unregister(&g2d_driver);
>  out_g2d:
> @@ -416,6 +436,10 @@ static void __exit exynos_drm_exit(void)
> 
>  	platform_driver_unregister(&exynos_drm_platform_driver);
> 
> +#ifdef CONFIG_DRM_EXYNOS_IPP
> +	platform_driver_unregister(&ipp_driver);
> +#endif
> +
>  #ifdef CONFIG_DRM_EXYNOS_G2D
>  	platform_driver_unregister(&g2d_driver);
>  #endif
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> index a9db025..a365788 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> @@ -235,8 +235,14 @@ struct exynos_drm_g2d_private {
>  	unsigned int		gem_nr;
>  };
> 
> +struct exynos_drm_ipp_private {
> +	struct device	*dev;
> +	struct list_head	event_list;
> +};
> +
>  struct drm_exynos_file_private {
>  	struct exynos_drm_g2d_private	*g2d_priv;
> +	struct exynos_drm_ipp_private	*ipp_priv;
>  };
> 
>  /*
> @@ -346,4 +352,5 @@ extern struct platform_driver mixer_driver;
>  extern struct platform_driver exynos_drm_common_hdmi_driver;
>  extern struct platform_driver vidi_driver;
>  extern struct platform_driver g2d_driver;
> +extern struct platform_driver ipp_driver;
>  #endif
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> new file mode 100644
> index 0000000..eb12cb5
> --- /dev/null
> +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
> @@ -0,0 +1,2059 @@
> +/*
> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> + * Authors:
> + *	Eunchul Kim <chulspro.kim@samsung.com>
> + *	Jinyoung Jeon <jy0.jeon@samsung.com>
> + *	Sangmin Lee <lsmin.lee@samsung.com>
> + *
> + * This program is free software; you can redistribute  it and/or modify
> it
> + * under  the terms of  the GNU General  Public License as published by
> the
> + * Free Software Foundation;  either version 2 of the  License, or (at
> your
> + * option) any later version.
> + *
> + */
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/clk.h>
> +#include <linux/pm_runtime.h>
> +#include <plat/map-base.h>
> +
> +#include <drm/drmP.h>
> +#include <drm/exynos_drm.h>
> +#include "exynos_drm_drv.h"
> +#include "exynos_drm_gem.h"
> +#include "exynos_drm_ipp.h"
> +
> +/*
> + * IPP is stand for Image Post Processing and
> + * supports image scaler/rotator and input/output DMA operations.
> + * using FIMC, GSC, Rotator, so on.
> + * IPP is integration device driver of same attribute h/w
> + */
> +
> +#define get_ipp_context(dev)
> 	platform_get_drvdata(to_platform_device(dev))
> +#define ipp_is_m2m_cmd(c)	(c == IPP_CMD_M2M)
> +
> +/*
> + * A structure of event.
> + *
> + * @base: base of event.
> + * @event: ipp event.
> + */
> +struct drm_exynos_ipp_send_event {
> +	struct drm_pending_event	base;
> +	struct drm_exynos_ipp_event	event;
> +};
> +
> +/*
> + * A structure of memory node.
> + *
> + * @list: list head to memory queue information.
> + * @ops_id: id of operations.
> + * @prop_id: id of property.
> + * @buf_id: id of buffer.
> + * @buf_info: gem objects and dma address, size.
> + * @filp: a pointer to drm_file.
> + */
> +struct drm_exynos_ipp_mem_node {
> +	struct list_head	list;
> +	enum drm_exynos_ops_id	ops_id;
> +	u32	prop_id;
> +	u32	buf_id;
> +	struct drm_exynos_ipp_buf_info	buf_info;
> +	struct drm_file		*filp;
> +};
> +
> +/*
> + * A structure of ipp context.
> + *
> + * @subdrv: prepare initialization using subdrv.
> + * @ipp_lock: lock for synchronization of access to ipp_idr.
> + * @prop_lock: lock for synchronization of access to prop_idr.
> + * @ipp_idr: ipp driver idr.
> + * @prop_idr: property idr.
> + * @event_workq: event work queue.
> + * @cmd_workq: command work queue.
> + */
> +struct ipp_context {
> +	struct exynos_drm_subdrv	subdrv;
> +	struct mutex	ipp_lock;
> +	struct mutex	prop_lock;
> +	struct idr	ipp_idr;
> +	struct idr	prop_idr;
> +	struct workqueue_struct	*event_workq;
> +	struct workqueue_struct	*cmd_workq;
> +};
> +
> +static LIST_HEAD(exynos_drm_ippdrv_list);
> +static DEFINE_MUTEX(exynos_drm_ippdrv_lock);
> +static BLOCKING_NOTIFIER_HEAD(exynos_drm_ippnb_list);
> +
> +int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv *ippdrv)
> +{
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (!ippdrv)
> +		return -EINVAL;
> +
> +	mutex_lock(&exynos_drm_ippdrv_lock);
> +	list_add_tail(&ippdrv->drv_list, &exynos_drm_ippdrv_list);
> +	mutex_unlock(&exynos_drm_ippdrv_lock);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(exynos_drm_ippdrv_register);
> +
> +int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv *ippdrv)
> +{
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (!ippdrv)
> +		return -EINVAL;
> +
> +	mutex_lock(&exynos_drm_ippdrv_lock);
> +	list_del(&ippdrv->drv_list);
> +	mutex_unlock(&exynos_drm_ippdrv_lock);
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(exynos_drm_ippdrv_unregister);
> +
> +static int ipp_create_id(struct idr *id_idr, struct mutex *lock, void
> *obj,
> +		u32 *idp)
> +{
> +	int ret;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +again:
> +	/* ensure there is space available to allocate a handle */
> +	if (idr_pre_get(id_idr, GFP_KERNEL) == 0) {
> +		DRM_ERROR("failed to get idr.\n");
> +		return -ENOMEM;
> +	}
> +
> +	/* do the allocation under our mutexlock */
> +	mutex_lock(lock);
> +	ret = idr_get_new_above(id_idr, obj, 1, (int *)idp);
> +	mutex_unlock(lock);
> +	if (ret == -EAGAIN)
> +		goto again;
> +
> +	return ret;
> +}
> +
> +static void *ipp_find_obj(struct idr *id_idr, struct mutex *lock, u32 id)
> +{
> +	void *obj;
> +
> +	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, id);
> +
> +	mutex_lock(lock);
> +
> +	/* find object using handle */
> +	obj = idr_find(id_idr, id);
> +	if (!obj) {
> +		DRM_ERROR("failed to find object.\n");
> +		mutex_unlock(lock);
> +		return ERR_PTR(-ENODEV);
> +	}
> +
> +	mutex_unlock(lock);
> +
> +	return obj;
> +}
> +
> +static inline bool ipp_check_dedicated(struct exynos_drm_ippdrv *ippdrv,
> +		enum drm_exynos_ipp_cmd	cmd)
> +{
> +	/*
> +	 * check dedicated flag and WB, OUTPUT operation with
> +	 * power on state.
> +	 */
> +	if (ippdrv->dedicated || (!ipp_is_m2m_cmd(cmd) &&
> +	    !pm_runtime_suspended(ippdrv->dev)))
> +		return true;
> +
> +	return false;
> +}
> +
> +static struct exynos_drm_ippdrv *ipp_find_driver(struct ipp_context *ctx,
> +		struct drm_exynos_ipp_property *property)
> +{
> +	struct exynos_drm_ippdrv *ippdrv;
> +	u32 ipp_id = property->ipp_id;
> +
> +	DRM_DEBUG_KMS("%s:ipp_id[%d]\n", __func__, ipp_id);
> +
> +	if (ipp_id) {
> +		/* find ipp driver using idr */
> +		ippdrv = ipp_find_obj(&ctx->ipp_idr, &ctx->ipp_lock,
> +			ipp_id);
> +		if (IS_ERR_OR_NULL(ippdrv)) {
> +			DRM_ERROR("not found ipp%d driver.\n", ipp_id);
> +			goto err_null;

Just return ippdrv;

> +		}
> +
> +		/*
> +		 * WB, OUTPUT opertion not supported multi-operation.
> +		 * so, make dedicated state at set property ioctl.
> +		 * when ipp driver finished operations, clear dedicated
flags.
> +		 */
> +		if (ipp_check_dedicated(ippdrv, property->cmd)) {
> +			DRM_ERROR("already used choose device.\n");
> +			goto err_null;

Just return proper error;

> +		}
> +
> +		/*
> +		 * This is necessary to find correct device in ipp drivers.
> +		 * ipp drivers have different abilities,
> +		 * so need to check property.
> +		 */
> +		if (ippdrv->check_property &&
> +		    ippdrv->check_property(ippdrv->dev, property)) {
> +			DRM_ERROR("not support property.\n");
> +			goto err_null;

Just return proper error;

> +		}
> +
> +		return ippdrv;
> +	} else {
> +		/*
> +		 * This case is search all ipp driver for finding.
> +		 * user application don't set ipp_id in this case,
> +		 * so ipp subsystem search correct driver in driver list.
> +		 */
> +		list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list,
> drv_list) {
> +			if (ipp_check_dedicated(ippdrv, property->cmd)) {
> +				DRM_DEBUG_KMS("%s:used device.\n",
__func__);
> +				continue;
> +			}
> +
> +			if (ippdrv->check_property &&
> +			    ippdrv->check_property(ippdrv->dev, property)) {
> +				DRM_DEBUG_KMS("%s:not support property.\n",
> +					__func__);
> +				continue;
> +			}
> +
> +			return ippdrv;
> +		}
> +
> +		DRM_ERROR("not support ipp driver operations.\n");
> +	}
> +
> +	return ERR_PTR(-ENODEV);
> +
> +err_null:
> +	return NULL;

And remove the above codes.

> +}
> +
> +static struct exynos_drm_ippdrv *ipp_find_drv_by_handle(u32 prop_id)
> +{
> +	struct exynos_drm_ippdrv *ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node;
> +	int count = 0;
> +
> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, prop_id);
> +
> +	if (list_empty(&exynos_drm_ippdrv_list)) {
> +		DRM_DEBUG_KMS("%s:ippdrv_list is empty.\n", __func__);
> +		return ERR_PTR(-ENODEV);
> +	}
> +
> +	/*
> +	 * This case is search ipp driver by prop_id handle.
> +	 * sometimes, ipp subsystem find driver by prop_id.
> +	 * e.g PAUSE state, queue buf, command contro.
> +	 */
> +	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
> +		DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]\n", __func__,
> +			count++, (int)ippdrv);
> +
> +		if (!list_empty(&ippdrv->cmd_list)) {
> +			list_for_each_entry(c_node, &ippdrv->cmd_list, list)
> +				if (c_node->property.prop_id == prop_id)
> +					return ippdrv;
> +		}
> +	}
> +
> +	return ERR_PTR(-ENODEV);
> +}
> +
> +int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void *data,
> +		struct drm_file *file)
> +{
> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
> +	struct device *dev = priv->dev;
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +	struct drm_exynos_ipp_prop_list *prop_list = data;
> +	struct exynos_drm_ippdrv *ippdrv;
> +	int count = 0;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (!ctx) {
> +		DRM_ERROR("invalid context.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (!prop_list) {
> +		DRM_ERROR("invalid property parameter.\n");
> +		return -EINVAL;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:ipp_id[%d]\n", __func__, prop_list->ipp_id);
> +
> +	if (!prop_list->ipp_id) {
> +		list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list,
> drv_list)
> +			count++;
> +		/*
> +		 * Supports ippdrv list count for user application.
> +		 * First step user application getting ippdrv count.
> +		 * and second step getting ippdrv capability using ipp_id.
> +		 */
> +		prop_list->count = count;
> +	} else {
> +		/*
> +		 * Getting ippdrv capability by ipp_id.
> +		 * some deivce not supported wb, output interface.
> +		 * so, user application detect correct ipp driver
> +		 * using this ioctl.
> +		 */
> +		ippdrv = ipp_find_obj(&ctx->ipp_idr, &ctx->ipp_lock,
> +						prop_list->ipp_id);
> +		if (!ippdrv) {
> +			DRM_ERROR("not found ipp%d driver.\n",
> +					prop_list->ipp_id);
> +			return -EINVAL;
> +		}
> +
> +		prop_list = ippdrv->prop_list;
> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(exynos_drm_ipp_get_property);

Should this function really be exported? Which external module calls this
function? If not so, remove it.

> +
> +static void ipp_print_property(struct drm_exynos_ipp_property *property,
> +		int idx)
> +{
> +	struct drm_exynos_ipp_config *config = &property->config[idx];
> +	struct drm_exynos_pos *pos = &config->pos;
> +	struct drm_exynos_sz *sz = &config->sz;
> +
> +	DRM_DEBUG_KMS("%s:prop_id[%d]ops[%s]fmt[0x%x]\n",
> +		__func__, property->prop_id, idx ? "dst" : "src", config-
> >fmt);
> +
> +	DRM_DEBUG_KMS("%s:pos[%d %d %d %d]sz[%d %d]f[%d]r[%d]\n",
> +		__func__, pos->x, pos->y, pos->w, pos->h,
> +		sz->hsize, sz->vsize, config->flip, config->degree);
> +}
> +
> +static int ipp_find_and_set_property(struct drm_exynos_ipp_property
> *property)
> +{
> +	struct exynos_drm_ippdrv *ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node;
> +	u32 prop_id = property->prop_id;
> +
> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, prop_id);
> +
> +	ippdrv = ipp_find_drv_by_handle(prop_id);
> +	if (IS_ERR_OR_NULL(ippdrv)) {
> +		DRM_ERROR("failed to get ipp driver.\n");
> +		return -EINVAL;
> +	}
> +
> +	/*
> +	 * Find command node using command list in ippdrv.
> +	 * when we find this command no using prop_id.
> +	 * return property information set in this command node.
> +	 */
> +	list_for_each_entry(c_node, &ippdrv->cmd_list, list) {
> +		if ((c_node->property.prop_id == prop_id) &&
> +		    (c_node->state == IPP_STATE_STOP)) {
> +			DRM_DEBUG_KMS("%s:found cmd[%d]ippdrv[0x%x]\n",
> +				__func__, property->cmd, (int)ippdrv);
> +
> +			c_node->property = *property;
> +			return 0;
> +		}
> +	}
> +
> +	DRM_ERROR("failed to search property.\n");
> +
> +	return -EINVAL;
> +}
> +
> +static struct drm_exynos_ipp_cmd_work *ipp_create_cmd_work(void)
> +{
> +	struct drm_exynos_ipp_cmd_work *cmd_work;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	cmd_work = kzalloc(sizeof(*cmd_work), GFP_KERNEL);
> +	if (!cmd_work) {
> +		DRM_ERROR("failed to alloc cmd_work.\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	INIT_WORK((struct work_struct *)cmd_work, ipp_sched_cmd);
> +
> +	return cmd_work;
> +}
> +
> +static struct drm_exynos_ipp_event_work *ipp_create_event_work(void)
> +{
> +	struct drm_exynos_ipp_event_work *event_work;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	event_work = kzalloc(sizeof(*event_work), GFP_KERNEL);
> +	if (!event_work) {
> +		DRM_ERROR("failed to alloc event_work.\n");
> +		return ERR_PTR(-ENOMEM);
> +	}
> +
> +	INIT_WORK((struct work_struct *)event_work, ipp_sched_event);
> +
> +	return event_work;
> +}
> +
> +int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
> +		struct drm_file *file)
> +{
> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
> +	struct device *dev = priv->dev;
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +	struct drm_exynos_ipp_property *property = data;
> +	struct exynos_drm_ippdrv *ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node;
> +	int ret, i;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (!ctx) {
> +		DRM_ERROR("invalid context.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (!property) {
> +		DRM_ERROR("invalid property parameter.\n");
> +		return -EINVAL;
> +	}
> +
> +	/*
> +	 * This is log print for user application property.
> +	 * user application set various property.
> +	 */
> +	for_each_ipp_ops(i)
> +		ipp_print_property(property, i);
> +
> +	/*
> +	 * set property ioctl generated new prop_id.
> +	 * but in this case already asigned prop_id using old set property.
> +	 * e.g PAUSE state. this case supports find current prop_id and use
> it
> +	 * instead of allocation.
> +	 */
> +	if (property->prop_id) {
> +		DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property-
> >prop_id);
> +		return ipp_find_and_set_property(property);
> +	}
> +
> +	/* find ipp driver using ipp id */
> +	ippdrv = ipp_find_driver(ctx, property);
> +	if (IS_ERR_OR_NULL(ippdrv)) {
> +		DRM_ERROR("failed to get ipp driver.\n");
> +		return -EINVAL;
> +	}
> +
> +	/* allocate command node */
> +	c_node = kzalloc(sizeof(*c_node), GFP_KERNEL);
> +	if (!c_node) {
> +		DRM_ERROR("failed to allocate map node.\n");
> +		return -ENOMEM;
> +	}
> +
> +	/* create property id */
> +	ret = ipp_create_id(&ctx->prop_idr, &ctx->prop_lock, c_node,
> +		&property->prop_id);
> +	if (ret) {
> +		DRM_ERROR("failed to create id.\n");
> +		goto err_clear;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:created prop_id[%d]cmd[%d]ippdrv[0x%x]\n",
> +		__func__, property->prop_id, property->cmd, (int)ippdrv);
> +
> +	/* stored property information and ippdrv in private data */
> +	c_node->priv = priv;
> +	c_node->property = *property;
> +	c_node->state = IPP_STATE_IDLE;
> +
> +	c_node->start_work = ipp_create_cmd_work();
> +	if (IS_ERR_OR_NULL(c_node->start_work)) {
> +		DRM_ERROR("failed to create start work.\n");
> +		goto err_clear;
> +	}
> +
> +	c_node->stop_work = ipp_create_cmd_work();
> +	if (IS_ERR_OR_NULL(c_node->stop_work)) {
> +		DRM_ERROR("failed to create stop work.\n");
> +		goto err_free_start;
> +	}
> +
> +	c_node->event_work = ipp_create_event_work();
> +	if (IS_ERR_OR_NULL(c_node->event_work)) {
> +		DRM_ERROR("failed to create event work.\n");
> +		goto err_free_stop;
> +	}
> +
> +	mutex_init(&c_node->cmd_lock);
> +	mutex_init(&c_node->mem_lock);
> +	mutex_init(&c_node->event_lock);
> +
> +	init_completion(&c_node->start_complete);
> +	init_completion(&c_node->stop_complete);
> +
> +	for_each_ipp_ops(i)
> +		INIT_LIST_HEAD(&c_node->mem_list[i]);
> +
> +	INIT_LIST_HEAD(&c_node->event_list);
> +	list_splice_init(&priv->event_list, &c_node->event_list);
> +	list_add_tail(&c_node->list, &ippdrv->cmd_list);
> +
> +	/* make dedicated state without m2m */
> +	if (!ipp_is_m2m_cmd(property->cmd))
> +		ippdrv->dedicated = true;
> +
> +	return 0;
> +
> +err_free_stop:
> +	kfree(c_node->stop_work);
> +err_free_start:
> +	kfree(c_node->start_work);
> +err_clear:
> +	kfree(c_node);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(exynos_drm_ipp_set_property);
> +
> +static void ipp_clean_cmd_node(struct drm_exynos_ipp_cmd_node *c_node)
> +{
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	/* delete list */
> +	list_del(&c_node->list);
> +
> +	/* destroy mutex */
> +	mutex_destroy(&c_node->cmd_lock);
> +	mutex_destroy(&c_node->mem_lock);
> +	mutex_destroy(&c_node->event_lock);
> +
> +	/* free command node */
> +	kfree(c_node->start_work);
> +	kfree(c_node->stop_work);
> +	kfree(c_node->event_work);
> +	kfree(c_node);
> +}
> +
> +static int ipp_check_mem_list(struct drm_exynos_ipp_cmd_node *c_node)
> +{
> +	struct drm_exynos_ipp_property *property = &c_node->property;
> +	struct drm_exynos_ipp_mem_node *m_node;
> +	struct list_head *head;
> +	int ret, i, count[EXYNOS_DRM_OPS_MAX] = { 0, };
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	mutex_lock(&c_node->mem_lock);
> +
> +	for_each_ipp_ops(i) {
> +		/* source/destination memory list */
> +		head = &c_node->mem_list[i];
> +
> +		if (list_empty(head)) {
> +			DRM_DEBUG_KMS("%s:%s memory empty.\n", __func__,
> +				i ? "dst" : "src");
> +			continue;
> +		}
> +
> +		/* find memory node entry */
> +		list_for_each_entry(m_node, head, list) {
> +			DRM_DEBUG_KMS("%s:%s,count[%d]m_node[0x%x]\n",
> __func__,
> +				i ? "dst" : "src", count[i], (int)m_node);
> +			count[i]++;
> +		}
> +	}
> +
> +	DRM_DEBUG_KMS("%s:min[%d]max[%d]\n", __func__,
> +		min(count[EXYNOS_DRM_OPS_SRC], count[EXYNOS_DRM_OPS_DST]),
> +		max(count[EXYNOS_DRM_OPS_SRC], count[EXYNOS_DRM_OPS_DST]));
> +
> +	/*
> +	 * M2M operations should be need paired memory address.
> +	 * so, need to check minimum count about src, dst.
> +	 * other case not use paired memory, so use maximum count
> +	 */
> +	if (ipp_is_m2m_cmd(property->cmd))
> +		ret = min(count[EXYNOS_DRM_OPS_SRC],
> +			count[EXYNOS_DRM_OPS_DST]);
> +	else
> +		ret = max(count[EXYNOS_DRM_OPS_SRC],
> +			count[EXYNOS_DRM_OPS_DST]);
> +
> +	mutex_unlock(&c_node->mem_lock);
> +
> +	return ret;
> +}
> +
> +static struct drm_exynos_ipp_mem_node
> +		*ipp_find_mem_node(struct drm_exynos_ipp_cmd_node *c_node,
> +		struct drm_exynos_ipp_queue_buf *qbuf)
> +{
> +	struct drm_exynos_ipp_mem_node *m_node;
> +	struct list_head *head;
> +	int count = 0;
> +
> +	DRM_DEBUG_KMS("%s:buf_id[%d]\n", __func__, qbuf->buf_id);
> +
> +	/* source/destination memory list */
> +	head = &c_node->mem_list[qbuf->ops_id];
> +
> +	/* find memory node from memory list */
> +	list_for_each_entry(m_node, head, list) {
> +		DRM_DEBUG_KMS("%s:count[%d]m_node[0x%x]\n",
> +			__func__, count++, (int)m_node);
> +
> +		/* compare buffer id */
> +		if (m_node->buf_id == qbuf->buf_id)
> +			return m_node;
> +	}
> +
> +	return NULL;
> +}
> +
> +static int ipp_set_mem_node(struct exynos_drm_ippdrv *ippdrv,
> +		struct drm_exynos_ipp_cmd_node *c_node,
> +		struct drm_exynos_ipp_mem_node *m_node)
> +{
> +	struct exynos_drm_ipp_ops *ops = NULL;
> +	int ret = 0;
> +
> +	DRM_DEBUG_KMS("%s:node[0x%x]\n", __func__, (int)m_node);
> +
> +	if (!m_node) {
> +		DRM_ERROR("invalid queue node.\n");
> +		return -EFAULT;
> +	}
> +
> +	mutex_lock(&c_node->mem_lock);
> +
> +	DRM_DEBUG_KMS("%s:ops_id[%d]\n", __func__, m_node->ops_id);
> +
> +	/* get operations callback */
> +	ops = ippdrv->ops[m_node->ops_id];
> +	if (!ops) {
> +		DRM_ERROR("not support ops.\n");
> +		ret = -EFAULT;
> +		goto err_unlock;
> +	}
> +
> +	/* set address and enable irq */
> +	if (ops->set_addr) {
> +		ret = ops->set_addr(ippdrv->dev, &m_node->buf_info,
> +			m_node->buf_id, IPP_BUF_ENQUEUE);
> +		if (ret) {
> +			DRM_ERROR("failed to set addr.\n");
> +			goto err_unlock;
> +		}
> +	}
> +
> +err_unlock:
> +	mutex_unlock(&c_node->mem_lock);
> +	return ret;
> +}
> +
> +static struct drm_exynos_ipp_mem_node
> +		*ipp_get_mem_node(struct drm_device *drm_dev,
> +		struct drm_file *file,
> +		struct drm_exynos_ipp_cmd_node *c_node,
> +		struct drm_exynos_ipp_queue_buf *qbuf)
> +{
> +	struct drm_exynos_ipp_mem_node *m_node;
> +	struct drm_exynos_ipp_buf_info buf_info;
> +	void *addr;
> +	int i;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	mutex_lock(&c_node->mem_lock);
> +
> +	m_node = kzalloc(sizeof(*m_node), GFP_KERNEL);
> +	if (!m_node) {
> +		DRM_ERROR("failed to allocate queue node.\n");
> +		goto err_unlock;
> +	}
> +
> +	/* clear base address for error handling */
> +	memset(&buf_info, 0x0, sizeof(buf_info));
> +
> +	/* operations, buffer id */
> +	m_node->ops_id = qbuf->ops_id;
> +	m_node->prop_id = qbuf->prop_id;
> +	m_node->buf_id = qbuf->buf_id;
> +
> +	DRM_DEBUG_KMS("%s:m_node[0x%x]ops_id[%d]\n", __func__,
> +		(int)m_node, qbuf->ops_id);
> +	DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]\n", __func__,
> +		qbuf->prop_id, m_node->buf_id);
> +
> +	for_each_ipp_planar(i) {
> +		DRM_DEBUG_KMS("%s:i[%d]handle[0x%x]\n", __func__,
> +			i, qbuf->handle[i]);
> +
> +		/* get dma address by handle */
> +		if (qbuf->handle[i] != 0) {

if (qbuf->handle[i]) {

> +			addr = exynos_drm_gem_get_dma_addr(drm_dev,
> +					qbuf->handle[i], file);
> +			if (!addr) {

if (IS_ERR(addr))

> +				DRM_ERROR("failed to get addr.\n");
> +				goto err_clear;
> +			}
> +
> +			buf_info.handles[i] = qbuf->handle[i];
> +			buf_info.base[i] = *(dma_addr_t *) addr;
> +			DRM_DEBUG_KMS("%s:i[%d]base[0x%x]hd[0x%x]\n",
> +				__func__, i, buf_info.base[i],
> +				(int)buf_info.handles[i]);
> +		}
> +	}
> +
> +	m_node->filp = file;
> +	m_node->buf_info = buf_info;
> +	list_add_tail(&m_node->list, &c_node->mem_list[qbuf->ops_id]);
> +
> +	mutex_unlock(&c_node->mem_lock);
> +	return m_node;
> +
> +err_clear:
> +	kfree(m_node);
> +err_unlock:
> +	mutex_unlock(&c_node->mem_lock);
> +	return ERR_PTR(-EFAULT);
> +}
> +
> +static int ipp_put_mem_node(struct drm_device *drm_dev,
> +		struct drm_exynos_ipp_cmd_node *c_node,
> +		struct drm_exynos_ipp_mem_node *m_node)
> +{
> +	int i;
> +
> +	DRM_DEBUG_KMS("%s:node[0x%x]\n", __func__, (int)m_node);
> +
> +	if (!m_node) {
> +		DRM_ERROR("invalid dequeue node.\n");
> +		return -EFAULT;
> +	}
> +
> +	if (list_empty(&m_node->list)) {
> +		DRM_ERROR("empty memory node.\n");
> +		return -ENOMEM;
> +	}
> +
> +	mutex_lock(&c_node->mem_lock);
> +
> +	DRM_DEBUG_KMS("%s:ops_id[%d]\n", __func__, m_node->ops_id);
> +
> +	/* put gem buffer */
> +	for_each_ipp_planar(i) {
> +		unsigned long handle = m_node->buf_info.handles[i];
> +		if (handle)
> +			exynos_drm_gem_put_dma_addr(drm_dev, handle,
> +							m_node->filp);
> +	}
> +
> +	/* delete list in queue */
> +	list_del(&m_node->list);
> +	kfree(m_node);
> +
> +	mutex_unlock(&c_node->mem_lock);
> +
> +	return 0;
> +}
> +
> +static void ipp_free_event(struct drm_pending_event *event)

Does this function need? This function just calls kfree. Just call kfree
instead of wrapper.

> +{
> +	kfree(event);
> +}
> +
> +static int ipp_get_event(struct drm_device *drm_dev,
> +		struct drm_file *file,
> +		struct drm_exynos_ipp_cmd_node *c_node,
> +		struct drm_exynos_ipp_queue_buf *qbuf)
> +{
> +	struct drm_exynos_ipp_send_event *e;
> +	unsigned long flags;
> +
> +	DRM_DEBUG_KMS("%s:ops_id[%d]buf_id[%d]\n", __func__,
> +		qbuf->ops_id, qbuf->buf_id);
> +
> +	e = kzalloc(sizeof(*e), GFP_KERNEL);
> +
> +	if (!e) {
> +		DRM_ERROR("failed to allocate event.\n");
> +		spin_lock_irqsave(&drm_dev->event_lock, flags);
> +		file->event_space += sizeof(e->event);
> +		spin_unlock_irqrestore(&drm_dev->event_lock, flags);
> +		return -ENOMEM;
> +	}
> +
> +	/* make event */
> +	e->event.base.type = DRM_EXYNOS_IPP_EVENT;
> +	e->event.base.length = sizeof(e->event);
> +	e->event.user_data = qbuf->user_data;
> +	e->event.prop_id = qbuf->prop_id;
> +	e->event.buf_id[EXYNOS_DRM_OPS_DST] = qbuf->buf_id;
> +	e->base.event = &e->event.base;
> +	e->base.file_priv = file;
> +	e->base.destroy = ipp_free_event;
> +	list_add_tail(&e->base.link, &c_node->event_list);
> +
> +	return 0;
> +}
> +
> +static void ipp_put_event(struct drm_exynos_ipp_cmd_node *c_node,
> +		struct drm_exynos_ipp_queue_buf *qbuf)
> +{
> +	struct drm_exynos_ipp_send_event *e, *te;
> +	int count = 0;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (list_empty(&c_node->event_list)) {
> +		DRM_DEBUG_KMS("%s:event_list is empty.\n", __func__);
> +		return;
> +	}
> +
> +	list_for_each_entry_safe(e, te, &c_node->event_list, base.link) {
> +		DRM_DEBUG_KMS("%s:count[%d]e[0x%x]\n",
> +			__func__, count++, (int)e);
> +
> +		/*
> +		 * quf == NULL condition means all event deletion.
> +		 * stop operations want to delete all event list.
> +		 * another case delete only same buf id.
> +		 */
> +		if (!qbuf) {
> +			/* delete list */
> +			list_del(&e->base.link);
> +			kfree(e);
> +		}
> +
> +		/* compare buffer id */
> +		if (qbuf && (qbuf->buf_id ==
> +		    e->event.buf_id[EXYNOS_DRM_OPS_DST])) {
> +			/* delete list */
> +			list_del(&e->base.link);
> +			kfree(e);
> +			return;
> +		}
> +	}
> +}
> +
> +void ipp_handle_cmd_work(struct device *dev,
> +		struct exynos_drm_ippdrv *ippdrv,
> +		struct drm_exynos_ipp_cmd_work *cmd_work,
> +		struct drm_exynos_ipp_cmd_node *c_node)
> +{
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +
> +	cmd_work->ippdrv = ippdrv;
> +	cmd_work->c_node = c_node;
> +	queue_work(ctx->cmd_workq, (struct work_struct *)cmd_work);
> +}
> +
> +static int ipp_queue_buf_with_run(struct device *dev,
> +		struct drm_exynos_ipp_cmd_node *c_node,
> +		struct drm_exynos_ipp_mem_node *m_node,
> +		struct drm_exynos_ipp_queue_buf *qbuf)
> +{
> +	struct exynos_drm_ippdrv *ippdrv;
> +	struct drm_exynos_ipp_property *property;
> +	struct exynos_drm_ipp_ops *ops;
> +	int ret;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	ippdrv = ipp_find_drv_by_handle(qbuf->prop_id);
> +	if (IS_ERR_OR_NULL(ippdrv)) {
> +		DRM_ERROR("failed to get ipp driver.\n");
> +		return -EFAULT;
> +	}
> +
> +	ops = ippdrv->ops[qbuf->ops_id];
> +	if (!ops) {
> +		DRM_ERROR("failed to get ops.\n");
> +		return -EFAULT;
> +	}
> +
> +	property = &c_node->property;
> +	if (!property) {

Property couldn't be NULL. remove it.

> +		DRM_ERROR("invalid property parameter.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (c_node->state != IPP_STATE_START) {
> +		DRM_DEBUG_KMS("%s:bypass for invalid state.\n" , __func__);
> +		return 0;

No error?

> +	}
> +
> +	if (!ipp_check_mem_list(c_node)) {
> +		DRM_DEBUG_KMS("%s:empty memory.\n", __func__);
> +		return 0;

No error?

> +	}
> +
> +	/*
> +	 * If set destination buffer and enabled clock,
> +	 * then m2m operations need start operations at queue_buf
> +	 */
> +	if (ipp_is_m2m_cmd(property->cmd)) {
> +		struct drm_exynos_ipp_cmd_work *cmd_work = c_node-
> >start_work;
> +
> +		cmd_work->ctrl = IPP_CTRL_PLAY;
> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
> +	} else {
> +		ret = ipp_set_mem_node(ippdrv, c_node, m_node);
> +		if (ret) {
> +			DRM_ERROR("failed to set m node.\n");
> +			return ret;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static void ipp_clean_queue_buf(struct drm_device *drm_dev,
> +		struct drm_exynos_ipp_cmd_node *c_node,
> +		struct drm_exynos_ipp_queue_buf *qbuf)
> +{
> +	struct drm_exynos_ipp_mem_node *m_node, *tm_node;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (!list_empty(&c_node->mem_list[qbuf->ops_id])) {
> +		/* delete list */
> +		list_for_each_entry_safe(m_node, tm_node,
> +			&c_node->mem_list[qbuf->ops_id], list) {
> +			if (m_node->buf_id == qbuf->buf_id &&
> +			    m_node->ops_id == qbuf->ops_id)
> +				ipp_put_mem_node(drm_dev, c_node, m_node);
> +		}
> +	}
> +}
> +
> +int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void *data,
> +		struct drm_file *file)
> +{
> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
> +	struct device *dev = priv->dev;
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +	struct drm_exynos_ipp_queue_buf *qbuf = data;
> +	struct drm_exynos_ipp_cmd_node *c_node;
> +	struct drm_exynos_ipp_mem_node *m_node;
> +	int ret;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (!qbuf) {
> +		DRM_ERROR("invalid buf parameter.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (qbuf->ops_id >= EXYNOS_DRM_OPS_MAX) {
> +		DRM_ERROR("invalid ops parameter.\n");
> +		return -EINVAL;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:prop_id[%d]ops_id[%s]buf_id[%d]buf_type[%d]\n",
> +		__func__, qbuf->prop_id, qbuf->ops_id ? "dst" : "src",
> +		qbuf->buf_id, qbuf->buf_type);
> +
> +	/* find command node */
> +	c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
> +		qbuf->prop_id);
> +	if (!c_node) {
> +		DRM_ERROR("failed to get command node.\n");
> +		return -EFAULT;
> +	}
> +
> +	/* buffer control */
> +	switch (qbuf->buf_type) {
> +	case IPP_BUF_ENQUEUE:
> +		/* get memory node */
> +		m_node = ipp_get_mem_node(drm_dev, file, c_node, qbuf);
> +		if (IS_ERR_OR_NULL(m_node)) {

This function never returns error. Use IS_ERR(m_node) instead.

> +			DRM_ERROR("failed to get m_node.\n");
> +			return -EINVAL;

And return PTR_ERR(m_node);

> +		}
> +
> +		/*
> +		 * first step get event for destination buffer.
> +		 * and second step when M2M case run with destination buffer
> +		 * if needed.
> +		 */
> +		if (qbuf->ops_id == EXYNOS_DRM_OPS_DST) {
> +			/* get event for destination buffer */
> +			ret = ipp_get_event(drm_dev, file, c_node, qbuf);
> +			if (ret) {
> +				DRM_ERROR("failed to get event.\n");
> +				goto err_clean_node;
> +			}
> +
> +			/*
> +			 * M2M case run play control for streaming feature.
> +			 * other case set address and waiting.
> +			 */
> +			ret = ipp_queue_buf_with_run(dev, c_node, m_node,
> qbuf);
> +			if (ret) {
> +				DRM_ERROR("failed to run command.\n");
> +				goto err_clean_node;
> +			}
> +		}
> +		break;
> +	case IPP_BUF_DEQUEUE:
> +		mutex_lock(&c_node->cmd_lock);
> +
> +		/* put event for destination buffer */
> +		if (qbuf->ops_id == EXYNOS_DRM_OPS_DST)
> +			ipp_put_event(c_node, qbuf);
> +
> +		ipp_clean_queue_buf(drm_dev, c_node, qbuf);
> +
> +		mutex_unlock(&c_node->cmd_lock);
> +		break;
> +	default:
> +		DRM_ERROR("invalid buffer control.\n");
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +
> +err_clean_node:
> +	DRM_ERROR("clean memory nodes.\n");
> +
> +	ipp_clean_queue_buf(drm_dev, c_node, qbuf);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(exynos_drm_ipp_queue_buf);

Remove EXPORT_SYMBOL_GPL.

> +
> +static bool exynos_drm_ipp_check_valid(struct device *dev,
> +		enum drm_exynos_ipp_ctrl ctrl, enum drm_exynos_ipp_state
> state)
> +{
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (ctrl != IPP_CTRL_PLAY) {
> +		if (pm_runtime_suspended(dev)) {
> +			DRM_ERROR("pm:runtime_suspended.\n");
> +			goto err_status;
> +		}
> +	}
> +
> +	switch (ctrl) {
> +	case IPP_CTRL_PLAY:
> +		if (state != IPP_STATE_IDLE)
> +			goto err_status;
> +		break;
> +	case IPP_CTRL_STOP:
> +		if (state == IPP_STATE_STOP)
> +			goto err_status;
> +		break;
> +	case IPP_CTRL_PAUSE:
> +		if (state != IPP_STATE_START)
> +			goto err_status;
> +		break;
> +	case IPP_CTRL_RESUME:
> +		if (state != IPP_STATE_STOP)
> +			goto err_status;
> +		break;
> +	default:
> +		DRM_ERROR("invalid state.\n");
> +		goto err_status;
> +		break;
> +	}
> +
> +	return true;
> +
> +err_status:
> +	DRM_ERROR("invalid status:ctrl[%d]state[%d]\n", ctrl, state);
> +	return false;
> +}
> +
> +int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void *data,
> +		struct drm_file *file)
> +{
> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
> +	struct exynos_drm_ippdrv *ippdrv = NULL;
> +	struct device *dev = priv->dev;
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +	struct drm_exynos_ipp_cmd_ctrl *cmd_ctrl = data;
> +	struct drm_exynos_ipp_cmd_work *cmd_work;
> +	struct drm_exynos_ipp_cmd_node *c_node;
> +	int ret = 0;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (!ctx) {
> +		DRM_ERROR("invalid context.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (!cmd_ctrl) {
> +		DRM_ERROR("invalid control parameter.\n");
> +		return -EINVAL;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:ctrl[%d]prop_id[%d]\n", __func__,
> +		cmd_ctrl->ctrl, cmd_ctrl->prop_id);
> +
> +	ippdrv = ipp_find_drv_by_handle(cmd_ctrl->prop_id);
> +	if (IS_ERR_OR_NULL(ippdrv)) {

Never return NULL. just use IS_ERR(ippdrv)

> +		DRM_ERROR("failed to get ipp driver.\n");
> +		return -EINVAL;

And return PTR_ERR(ippdrv);

> +	}
> +
> +	c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
> +		cmd_ctrl->prop_id);
> +	if (!c_node) {
> +		DRM_ERROR("invalid command node list.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (!exynos_drm_ipp_check_valid(ippdrv->dev, cmd_ctrl->ctrl,
> +	    c_node->state)) {
> +		DRM_ERROR("invalid state.\n");
> +		return -EINVAL;
> +	}
> +
> +	switch (cmd_ctrl->ctrl) {
> +	case IPP_CTRL_PLAY:
> +		if (pm_runtime_suspended(ippdrv->dev))
> +			pm_runtime_get_sync(ippdrv->dev);
> +		c_node->state = IPP_STATE_START;
> +
> +		cmd_work = c_node->start_work;
> +		cmd_work->ctrl = cmd_ctrl->ctrl;
> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
> +		c_node->state = IPP_STATE_START;
> +		break;
> +	case IPP_CTRL_STOP:
> +		cmd_work = c_node->stop_work;
> +		cmd_work->ctrl = cmd_ctrl->ctrl;
> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
> +
> +		if (!wait_for_completion_timeout(&c_node->stop_complete,
> +		    msecs_to_jiffies(300))) {
> +			DRM_ERROR("timeout stop:prop_id[%d]\n",
> +				c_node->property.prop_id);
> +		}
> +
> +		c_node->state = IPP_STATE_STOP;
> +		ippdrv->dedicated = false;
> +		ipp_clean_cmd_node(c_node);
> +
> +		if (list_empty(&ippdrv->cmd_list))
> +			pm_runtime_put_sync(ippdrv->dev);
> +		break;
> +	case IPP_CTRL_PAUSE:
> +		cmd_work = c_node->stop_work;
> +		cmd_work->ctrl = cmd_ctrl->ctrl;
> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
> +
> +		if (!wait_for_completion_timeout(&c_node->stop_complete,
> +		    msecs_to_jiffies(200))) {
> +			DRM_ERROR("timeout stop:prop_id[%d]\n",
> +				c_node->property.prop_id);
> +		}
> +
> +		c_node->state = IPP_STATE_STOP;
> +		break;
> +	case IPP_CTRL_RESUME:
> +		c_node->state = IPP_STATE_START;
> +		cmd_work = c_node->start_work;
> +		cmd_work->ctrl = cmd_ctrl->ctrl;
> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
> +		break;
> +	default:
> +		/* ToDo: expand ctrl operation */
> +		DRM_ERROR("could not support this state currently.\n");
> +		goto err_clear;

Just return error;

> +	}
> +
> +	DRM_DEBUG_KMS("%s:done ctrl[%d]prop_id[%d]\n", __func__,
> +		cmd_ctrl->ctrl, cmd_ctrl->prop_id);
> +
> +	return 0;
> +
> +err_clear:
> +	return ret;

And remove the above label.

> +}
> +EXPORT_SYMBOL_GPL(exynos_drm_ipp_cmd_ctrl);

Remove it.

> +
> +int exynos_drm_ippnb_register(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_register(
> +			&exynos_drm_ippnb_list, nb);
> +}
> +EXPORT_SYMBOL_GPL(exynos_drm_ippnb_register);

Remove it.

> +
> +int exynos_drm_ippnb_unregister(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_unregister(
> +			&exynos_drm_ippnb_list, nb);
> +}
> +EXPORT_SYMBOL_GPL(exynos_drm_ippnb_unregister);

Remove it.

> +
> +int exynos_drm_ippnb_send_event(unsigned long val, void *v)
> +{
> +	return blocking_notifier_call_chain(
> +			&exynos_drm_ippnb_list, val, v);
> +}
> +EXPORT_SYMBOL_GPL(exynos_drm_ippnb_send_event);

Remove it.

> +
> +static int ipp_set_property(struct exynos_drm_ippdrv *ippdrv,
> +		struct drm_exynos_ipp_property *property)
> +{
> +	struct exynos_drm_ipp_ops *ops = NULL;
> +	int ret, i, swap = 0;
> +
> +	if (!property) {
> +		DRM_ERROR("invalid property parameter.\n");
> +		return -EINVAL;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
> +
> +	/* reset h/w block */
> +	if (ippdrv->reset &&
> +	    ippdrv->reset(ippdrv->dev)) {
> +		DRM_ERROR("failed to reset.\n");
> +		return -EINVAL;
> +	}
> +
> +	/* set source,destination operations */
> +	for_each_ipp_ops(i) {
> +		/* ToDo: integrate property and config */
> +		struct drm_exynos_ipp_config *config =
> +			&property->config[i];
> +
> +		ops = ippdrv->ops[i];
> +		if (!ops || !config) {
> +			DRM_ERROR("not support ops and config.\n");
> +			return -EINVAL;
> +		}
> +
> +		/* set format */
> +		if (ops->set_fmt) {
> +			ret = ops->set_fmt(ippdrv->dev, config->fmt);
> +			if (ret) {
> +				DRM_ERROR("not support format.\n");
> +				return ret;
> +			}
> +		}
> +
> +		/* set transform for rotation, flip */
> +		if (ops->set_transf) {
> +			swap = ops->set_transf(ippdrv->dev, config->degree,
> +				config->flip);
> +			if (swap < 0) {
> +				DRM_ERROR("not support tranf.\n");
> +				return -EINVAL;
> +			}
> +		}
> +
> +		/* set size */
> +		if (ops->set_size) {
> +			ret = ops->set_size(ippdrv->dev, swap, &config->pos,
> +				&config->sz);
> +			if (ret) {
> +				DRM_ERROR("not support size.\n");
> +				return ret;
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static int ipp_start_property(struct exynos_drm_ippdrv *ippdrv,
> +		struct drm_exynos_ipp_cmd_node *c_node)
> +{
> +	struct drm_exynos_ipp_mem_node *m_node;
> +	struct drm_exynos_ipp_property *property = &c_node->property;
> +	struct list_head *head;
> +	int ret, i;
> +
> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
> +
> +	/* store command info in ippdrv */
> +	ippdrv->cmd = c_node;
> +
> +	if (!ipp_check_mem_list(c_node)) {
> +		DRM_DEBUG_KMS("%s:empty memory.\n", __func__);
> +		return -ENOMEM;
> +	}
> +
> +	/* set current property in ippdrv */
> +	ret = ipp_set_property(ippdrv, property);
> +	if (ret) {
> +		DRM_ERROR("failed to set property.\n");
> +		ippdrv->cmd = NULL;
> +		return ret;
> +	}
> +
> +	/* check command */
> +	switch (property->cmd) {
> +	case IPP_CMD_M2M:
> +		for_each_ipp_ops(i) {
> +			/* source/destination memory list */
> +			head = &c_node->mem_list[i];
> +
> +			m_node = list_first_entry(head,
> +				struct drm_exynos_ipp_mem_node, list);
> +			if (!m_node) {
> +				DRM_ERROR("failed to get node.\n");
> +				ret = -EFAULT;
> +				return ret;
> +			}
> +
> +			DRM_DEBUG_KMS("%s:m_node[0x%x]\n",
> +				__func__, (int)m_node);
> +
> +			ret = ipp_set_mem_node(ippdrv, c_node, m_node);
> +			if (ret) {
> +				DRM_ERROR("failed to set m node.\n");
> +				return ret;
> +			}
> +		}
> +		break;
> +	case IPP_CMD_WB:
> +		/* destination memory list */
> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_DST];
> +
> +		list_for_each_entry(m_node, head, list) {
> +			ret = ipp_set_mem_node(ippdrv, c_node, m_node);
> +			if (ret) {
> +				DRM_ERROR("failed to set m node.\n");
> +				return ret;
> +			}
> +		}
> +		break;
> +	case IPP_CMD_OUTPUT:
> +		/* source memory list */
> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC];
> +
> +		list_for_each_entry(m_node, head, list) {
> +			ret = ipp_set_mem_node(ippdrv, c_node, m_node);
> +			if (ret) {
> +				DRM_ERROR("failed to set m node.\n");
> +				return ret;
> +			}
> +		}
> +		break;
> +	default:
> +		DRM_ERROR("invalid operations.\n");
> +		return -EINVAL;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, property->cmd);
> +
> +	/* start operations */
> +	if (ippdrv->start) {
> +		ret = ippdrv->start(ippdrv->dev, property->cmd);
> +		if (ret) {
> +			DRM_ERROR("failed to start ops.\n");
> +			return ret;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static int ipp_stop_property(struct drm_device *drm_dev,
> +		struct exynos_drm_ippdrv *ippdrv,
> +		struct drm_exynos_ipp_cmd_node *c_node)
> +{
> +	struct drm_exynos_ipp_mem_node *m_node, *tm_node;
> +	struct drm_exynos_ipp_property *property = &c_node->property;
> +	struct list_head *head;
> +	int ret = 0, i;
> +
> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
> +
> +	/* put event */
> +	ipp_put_event(c_node, NULL);
> +
> +	/* check command */
> +	switch (property->cmd) {
> +	case IPP_CMD_M2M:
> +		for_each_ipp_ops(i) {
> +			/* source/destination memory list */
> +			head = &c_node->mem_list[i];
> +
> +			if (list_empty(head)) {
> +				DRM_DEBUG_KMS("%s:mem_list is empty.\n",
> +					__func__);
> +				break;
> +			}
> +
> +			list_for_each_entry_safe(m_node, tm_node,
> +				head, list) {
> +				ret = ipp_put_mem_node(drm_dev, c_node,
> +					m_node);
> +				if (ret) {
> +					DRM_ERROR("failed to put
m_node.\n");
> +					goto err_clear;
> +				}
> +			}
> +		}
> +		break;
> +	case IPP_CMD_WB:
> +		/* destination memory list */
> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_DST];
> +
> +		if (list_empty(head)) {
> +			DRM_DEBUG_KMS("%s:mem_list is empty.\n", __func__);
> +			break;
> +		}
> +
> +		list_for_each_entry_safe(m_node, tm_node, head, list) {
> +			ret = ipp_put_mem_node(drm_dev, c_node, m_node);
> +			if (ret) {
> +				DRM_ERROR("failed to put m_node.\n");
> +				goto err_clear;
> +			}
> +		}
> +		break;
> +	case IPP_CMD_OUTPUT:
> +		/* source memory list */
> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC];
> +
> +		if (list_empty(head)) {
> +			DRM_DEBUG_KMS("%s:mem_list is empty.\n", __func__);
> +			break;
> +		}
> +
> +		list_for_each_entry_safe(m_node, tm_node, head, list) {
> +			ret = ipp_put_mem_node(drm_dev, c_node, m_node);
> +			if (ret) {
> +				DRM_ERROR("failed to put m_node.\n");
> +				goto err_clear;
> +			}
> +		}
> +		break;
> +	default:
> +		DRM_ERROR("invalid operations.\n");
> +		ret = -EINVAL;
> +		goto err_clear;
> +	}
> +
> +err_clear:
> +	/* stop operations */
> +	if (ippdrv->stop)
> +		ippdrv->stop(ippdrv->dev, property->cmd);
> +
> +	return ret;
> +}
> +
> +void ipp_sched_cmd(struct work_struct *work)
> +{
> +	struct drm_exynos_ipp_cmd_work *cmd_work =
> +		(struct drm_exynos_ipp_cmd_work *)work;
> +	struct exynos_drm_ippdrv *ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node;
> +	struct drm_exynos_ipp_property *property;
> +	int ret;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	ippdrv = cmd_work->ippdrv;
> +	if (!ippdrv) {
> +		DRM_ERROR("invalid ippdrv list.\n");
> +		return;
> +	}
> +
> +	c_node = cmd_work->c_node;
> +	if (!c_node) {
> +		DRM_ERROR("invalid command node list.\n");
> +		return;
> +	}
> +
> +	mutex_lock(&c_node->cmd_lock);
> +
> +	property = &c_node->property;
> +	if (!property) {
> +		DRM_ERROR("failed to get property:prop_id[%d]\n",
> +			c_node->property.prop_id);
> +		goto err_unlock;
> +	}
> +
> +	switch (cmd_work->ctrl) {
> +	case IPP_CTRL_PLAY:
> +	case IPP_CTRL_RESUME:
> +		ret = ipp_start_property(ippdrv, c_node);
> +		if (ret) {
> +			DRM_ERROR("failed to start property:prop_id[%d]\n",
> +				c_node->property.prop_id);
> +			goto err_unlock;
> +		}
> +
> +		/*
> +		 * M2M case supports wait_completion of transfer.
> +		 * because M2M case supports single unit operation
> +		 * with multiple queue.
> +		 * M2M need to wait completion of data transfer.
> +		 */
> +		if (ipp_is_m2m_cmd(property->cmd)) {
> +			if (!wait_for_completion_timeout
> +			    (&c_node->start_complete,
msecs_to_jiffies(200))) {
> +				DRM_ERROR("timeout event:prop_id[%d]\n",
> +					c_node->property.prop_id);
> +				goto err_unlock;
> +			}
> +		}
> +		break;
> +	case IPP_CTRL_STOP:
> +	case IPP_CTRL_PAUSE:
> +		ret = ipp_stop_property(ippdrv->drm_dev, ippdrv,
> +			c_node);
> +		if (ret) {
> +			DRM_ERROR("failed to stop property.\n");
> +			goto err_unlock;
> +		}
> +
> +		complete(&c_node->stop_complete);
> +		break;
> +	default:
> +		DRM_ERROR("unknown control type\n");
> +		break;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:ctrl[%d] done.\n", __func__, cmd_work->ctrl);
> +
> +err_unlock:
> +	mutex_unlock(&c_node->cmd_lock);
> +}
> +
> +static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv,
> +		struct drm_exynos_ipp_cmd_node *c_node, int *buf_id)
> +{
> +	struct drm_device *drm_dev = ippdrv->drm_dev;
> +	struct drm_exynos_ipp_property *property = &c_node->property;
> +	struct drm_exynos_ipp_mem_node *m_node;
> +	struct drm_exynos_ipp_queue_buf qbuf;
> +	struct drm_exynos_ipp_send_event *e;
> +	struct list_head *head;
> +	struct timeval now;
> +	unsigned long flags;
> +	u32 tbuf_id[EXYNOS_DRM_OPS_MAX] = {0, };
> +	int ret, i;
> +
> +	for_each_ipp_ops(i)
> +		DRM_DEBUG_KMS("%s:%s buf_id[%d]\n", __func__,
> +			i ? "dst" : "src", buf_id[i]);
> +
> +	if (!drm_dev) {
> +		DRM_ERROR("failed to get drm_dev.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (!property) {
> +		DRM_ERROR("failed to get property.\n");
> +		return -EINVAL;
> +	}
> +
> +	if (list_empty(&c_node->event_list)) {
> +		DRM_DEBUG_KMS("%s:event list is empty.\n", __func__);
> +		return 0;
> +	}
> +
> +	if (!ipp_check_mem_list(c_node)) {
> +		DRM_DEBUG_KMS("%s:empty memory.\n", __func__);
> +		return 0;
> +	}
> +
> +	/* check command */
> +	switch (property->cmd) {
> +	case IPP_CMD_M2M:
> +		for_each_ipp_ops(i) {
> +			/* source/destination memory list */
> +			head = &c_node->mem_list[i];
> +
> +			m_node = list_first_entry(head,
> +				struct drm_exynos_ipp_mem_node, list);
> +			if (!m_node) {
> +				DRM_ERROR("empty memory node.\n");
> +				return -ENOMEM;
> +			}
> +
> +			tbuf_id[i] = m_node->buf_id;
> +			DRM_DEBUG_KMS("%s:%s buf_id[%d]\n", __func__,
> +				i ? "dst" : "src", tbuf_id[i]);
> +
> +			ret = ipp_put_mem_node(drm_dev, c_node, m_node);
> +			if (ret)
> +				DRM_ERROR("failed to put m_node.\n");
> +		}
> +		break;
> +	case IPP_CMD_WB:
> +		/* clear buf for finding */
> +		memset(&qbuf, 0x0, sizeof(qbuf));
> +		qbuf.ops_id = EXYNOS_DRM_OPS_DST;
> +		qbuf.buf_id = buf_id[EXYNOS_DRM_OPS_DST];
> +
> +		/* get memory node entry */
> +		m_node = ipp_find_mem_node(c_node, &qbuf);
> +		if (!m_node) {
> +			DRM_ERROR("empty memory node.\n");
> +			return -ENOMEM;
> +		}
> +
> +		tbuf_id[EXYNOS_DRM_OPS_DST] = m_node->buf_id;
> +
> +		ret = ipp_put_mem_node(drm_dev, c_node, m_node);
> +		if (ret)
> +			DRM_ERROR("failed to put m_node.\n");
> +		break;
> +	case IPP_CMD_OUTPUT:
> +		/* source memory list */
> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC];
> +
> +		m_node = list_first_entry(head,
> +			struct drm_exynos_ipp_mem_node, list);
> +		if (!m_node) {
> +			DRM_ERROR("empty memory node.\n");
> +			return -ENOMEM;
> +		}
> +
> +		tbuf_id[EXYNOS_DRM_OPS_SRC] = m_node->buf_id;
> +
> +		ret = ipp_put_mem_node(drm_dev, c_node, m_node);
> +		if (ret)
> +			DRM_ERROR("failed to put m_node.\n");
> +		break;
> +	default:
> +		DRM_ERROR("invalid operations.\n");
> +		return -EINVAL;
> +	}
> +
> +	/* ToDo: Fix buffer id */
> +	if (tbuf_id[EXYNOS_DRM_OPS_DST] != buf_id[EXYNOS_DRM_OPS_DST])
> +		DRM_ERROR("failed to match buf_id[%d %d]prop_id[%d]\n",
> +			tbuf_id[1], buf_id[1], property->prop_id);
> +
> +	/*
> +	 * command node have event list of destination buffer
> +	 * If destination buffer enqueue to mem list,
> +	 * then we make event and link to event list tail.
> +	 * so, we get first event for first enqueued buffer.
> +	 */
> +	e = list_first_entry(&c_node->event_list,
> +		struct drm_exynos_ipp_send_event, base.link);
> +
> +	if (!e) {
> +		DRM_ERROR("empty event.\n");
> +		return -EINVAL;
> +	}
> +
> +	do_gettimeofday(&now);
> +	DRM_DEBUG_KMS("%s:tv_sec[%ld]tv_usec[%ld]\n"
> +		, __func__, now.tv_sec, now.tv_usec);
> +	e->event.tv_sec = now.tv_sec;
> +	e->event.tv_usec = now.tv_usec;
> +	e->event.prop_id = property->prop_id;
> +
> +	/* set buffer id about source destination */
> +	for_each_ipp_ops(i)
> +		e->event.buf_id[i] = tbuf_id[i];
> +
> +	/* ToDo: compare index. If needed */
> +
> +	spin_lock_irqsave(&drm_dev->event_lock, flags);
> +	list_move_tail(&e->base.link, &e->base.file_priv->event_list);
> +	wake_up_interruptible(&e->base.file_priv->event_wait);
> +	spin_unlock_irqrestore(&drm_dev->event_lock, flags);
> +
> +	DRM_DEBUG_KMS("%s:done cmd[%d]prop_id[%d]buf_id[%d]\n", __func__,
> +		property->cmd, property->prop_id,
> tbuf_id[EXYNOS_DRM_OPS_DST]);
> +
> +	return 0;
> +}
> +
> +void ipp_sched_event(struct work_struct *work)
> +{
> +	struct drm_exynos_ipp_event_work *event_work =
> +		(struct drm_exynos_ipp_event_work *)work;
> +	struct exynos_drm_ippdrv *ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node;
> +	int ret;
> +
> +	if (!event_work) {
> +		DRM_ERROR("failed to get event_work.\n");
> +		return;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:buf_id[%d]\n", __func__,
> +		event_work->buf_id[EXYNOS_DRM_OPS_DST]);
> +
> +	ippdrv = event_work->ippdrv;
> +	if (!ippdrv) {
> +		DRM_ERROR("failed to get ipp driver.\n");
> +		return;
> +	}
> +
> +	c_node = ippdrv->cmd;
> +	if (!c_node) {
> +		DRM_ERROR("failed to get command node.\n");
> +		return;
> +	}
> +
> +	/*
> +	 * IPP supports command thread, event thread synchronization.
> +	 * If IPP close immediately from user land, then IPP make
> +	 * synchronization with command thread, so make complete event.
> +	 * or going out operations.
> +	 */
> +	if (c_node->state != IPP_STATE_START) {
> +		DRM_DEBUG_KMS("%s:bypass state[%d]prop_id[%d]\n",
> +			__func__, c_node->state, c_node->property.prop_id);
> +		goto err_completion;
> +	}
> +
> +	mutex_lock(&c_node->event_lock);
> +
> +	ret = ipp_send_event(ippdrv, c_node, event_work->buf_id);
> +	if (ret) {
> +		DRM_ERROR("failed to send event.\n");
> +		goto err_completion;
> +	}
> +
> +err_completion:
> +	if (ipp_is_m2m_cmd(c_node->property.cmd))
> +		complete(&c_node->start_complete);
> +
> +	mutex_unlock(&c_node->event_lock);
> +}
> +
> +static int ipp_subdrv_probe(struct drm_device *drm_dev, struct device
> *dev)
> +{
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv;
> +	int ret, count = 0;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	/* get ipp driver entry */
> +	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
> +		ippdrv->drm_dev = drm_dev;
> +
> +		ret = ipp_create_id(&ctx->ipp_idr, &ctx->ipp_lock, ippdrv,
> +			&ippdrv->ipp_id);
> +		if (ret) {
> +			DRM_ERROR("failed to create id.\n");
> +			goto err_idr;
> +		}
> +
> +		DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]ipp_id[%d]\n",
> __func__,
> +			count++, (int)ippdrv, ippdrv->ipp_id);
> +
> +		if (ippdrv->ipp_id == 0) {
> +			DRM_ERROR("failed to get ipp_id[%d]\n",
> +				ippdrv->ipp_id);
> +			goto err_idr;
> +		}
> +
> +		/* store parent device for node */
> +		ippdrv->parent_dev = dev;
> +
> +		/* store event work queue and handler */
> +		ippdrv->event_workq = ctx->event_workq;
> +		ippdrv->sched_event = ipp_sched_event;
> +		INIT_LIST_HEAD(&ippdrv->cmd_list);
> +	}
> +
> +	return 0;
> +
> +err_idr:
> +	idr_remove_all(&ctx->ipp_idr);
> +	idr_remove_all(&ctx->prop_idr);
> +	idr_destroy(&ctx->ipp_idr);
> +	idr_destroy(&ctx->prop_idr);
> +	return ret;
> +}
> +
> +static void ipp_subdrv_remove(struct drm_device *drm_dev, struct device
> *dev)
> +{
> +	struct exynos_drm_ippdrv *ippdrv;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	/* get ipp driver entry */
> +	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
> +		ippdrv->drm_dev = NULL;
> +		exynos_drm_ippdrv_unregister(ippdrv);
> +	}
> +
> +	/* ToDo: free notifier callback list if needed */
> +}
> +
> +static int ipp_subdrv_open(struct drm_device *drm_dev, struct device
*dev,
> +		struct drm_file *file)
> +{
> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
> +	struct exynos_drm_ipp_private *priv;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	/* ToDo: multi device open */
> +
> +	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
> +	if (!priv) {
> +		DRM_ERROR("failed to allocate priv.\n");
> +		return -ENOMEM;
> +	}
> +	priv->dev = dev;
> +	file_priv->ipp_priv = priv;
> +
> +	INIT_LIST_HEAD(&priv->event_list);
> +
> +	DRM_DEBUG_KMS("%s:done priv[0x%x]\n", __func__, (int)priv);
> +
> +	return 0;
> +}
> +
> +static void ipp_subdrv_close(struct drm_device *drm_dev, struct device
> *dev,
> +		struct drm_file *file)
> +{
> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
> +	struct exynos_drm_ippdrv *ippdrv = NULL;
> +	struct drm_exynos_ipp_cmd_node *c_node, *tc_node;
> +	int count = 0;
> +
> +	DRM_DEBUG_KMS("%s:for priv[0x%x]\n", __func__, (int)priv);
> +
> +	if (list_empty(&exynos_drm_ippdrv_list)) {
> +		DRM_DEBUG_KMS("%s:ippdrv_list is empty.\n", __func__);
> +		goto err_clear;
> +	}
> +
> +	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
> +		if (list_empty(&ippdrv->cmd_list))
> +			continue;
> +
> +		list_for_each_entry_safe(c_node, tc_node,
> +			&ippdrv->cmd_list, list) {
> +			DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]\n",
> +				__func__, count++, (int)ippdrv);
> +
> +			if (c_node->priv == priv) {
> +				/*
> +				 * userland goto unnormal state. process
killed.
> +				 * and close the file.
> +				 * so, IPP didn't called stop cmd ctrl.
> +				 * so, we are make stop operation in this
state.
> +				 */
> +				if (c_node->state == IPP_STATE_START) {
> +					ipp_stop_property(drm_dev, ippdrv,
> +						c_node);
> +					c_node->state = IPP_STATE_STOP;
> +				}
> +
> +				ippdrv->dedicated = false;
> +				ipp_clean_cmd_node(c_node);
> +				if (list_empty(&ippdrv->cmd_list))
> +					pm_runtime_put_sync(ippdrv->dev);
> +			}
> +		}
> +	}
> +
> +err_clear:
> +	kfree(priv);
> +	return;
> +}
> +
> +static int __devinit ipp_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct ipp_context *ctx;
> +	struct exynos_drm_subdrv *subdrv;
> +	int ret;
> +
> +	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> +	if (!ctx)
> +		return -ENOMEM;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	mutex_init(&ctx->ipp_lock);
> +	mutex_init(&ctx->prop_lock);
> +
> +	idr_init(&ctx->ipp_idr);
> +	idr_init(&ctx->prop_idr);
> +
> +	/*
> +	 * create single thread for ipp event
> +	 * IPP supports event thread for IPP drivers.
> +	 * IPP driver send event_work to this thread.
> +	 * and IPP event thread send event to user process.
> +	 */
> +	ctx->event_workq = create_singlethread_workqueue("ipp_event");
> +	if (!ctx->event_workq) {
> +		dev_err(dev, "failed to create event workqueue\n");
> +		ret = -EINVAL;
> +		goto err_clear;
> +	}
> +
> +	/*
> +	 * create single thread for ipp command
> +	 * IPP supports command thread for user process.
> +	 * user process make command node using set property ioctl.
> +	 * and make start_work and send this work to command thread.
> +	 * and then this command thread start property.
> +	 */
> +	ctx->cmd_workq = create_singlethread_workqueue("ipp_cmd");
> +	if (!ctx->cmd_workq) {
> +		dev_err(dev, "failed to create cmd workqueue\n");
> +		ret = -EINVAL;
> +		goto err_event_workq;
> +	}
> +
> +	/* set sub driver informations */
> +	subdrv = &ctx->subdrv;
> +	subdrv->dev = dev;
> +	subdrv->probe = ipp_subdrv_probe;
> +	subdrv->remove = ipp_subdrv_remove;
> +	subdrv->open = ipp_subdrv_open;
> +	subdrv->close = ipp_subdrv_close;
> +
> +	platform_set_drvdata(pdev, ctx);
> +
> +	ret = exynos_drm_subdrv_register(subdrv);
> +	if (ret < 0) {
> +		DRM_ERROR("failed to register drm ipp device.\n");
> +		goto err_cmd_workq;
> +	}
> +
> +	dev_info(&pdev->dev, "drm ipp registered successfully.\n");
> +
> +	return 0;
> +
> +err_cmd_workq:
> +	destroy_workqueue(ctx->cmd_workq);
> +err_event_workq:
> +	destroy_workqueue(ctx->event_workq);
> +err_clear:
> +	kfree(ctx);
> +	return ret;
> +}
> +
> +static int __devexit ipp_remove(struct platform_device *pdev)
> +{
> +	struct ipp_context *ctx = platform_get_drvdata(pdev);
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	/* unregister sub driver */
> +	exynos_drm_subdrv_unregister(&ctx->subdrv);
> +
> +	/* remove,destroy ipp idr */
> +	idr_remove_all(&ctx->ipp_idr);
> +	idr_remove_all(&ctx->prop_idr);
> +	idr_destroy(&ctx->ipp_idr);
> +	idr_destroy(&ctx->prop_idr);
> +
> +	mutex_destroy(&ctx->ipp_lock);
> +	mutex_destroy(&ctx->prop_lock);
> +
> +	/* destroy command, event work queue */
> +	destroy_workqueue(ctx->cmd_workq);
> +	destroy_workqueue(ctx->event_workq);
> +
> +	kfree(ctx);
> +
> +	return 0;
> +}
> +
> +static int ipp_power_ctrl(struct ipp_context *ctx, bool enable)
> +{
> +	/* ToDo: Need to implement power and sysmmu ctrl. */
> +	DRM_DEBUG_KMS("%s:enable[%d]\n", __func__, enable);
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_PM_SLEEP
> +static int ipp_suspend(struct device *dev)
> +{
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (pm_runtime_suspended(dev))
> +		return 0;
> +
> +	return ipp_power_ctrl(ctx, false);
> +}
> +
> +static int ipp_resume(struct device *dev)
> +{
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (!pm_runtime_suspended(dev))
> +		return ipp_power_ctrl(ctx, true);
> +
> +	return 0;
> +}
> +#endif
> +
> +#ifdef CONFIG_PM_RUNTIME
> +static int ipp_runtime_suspend(struct device *dev)
> +{
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	return ipp_power_ctrl(ctx, false);
> +}
> +
> +static int ipp_runtime_resume(struct device *dev)
> +{
> +	struct ipp_context *ctx = get_ipp_context(dev);
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	return ipp_power_ctrl(ctx, true);
> +}
> +#endif
> +
> +static const struct dev_pm_ops ipp_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(ipp_suspend, ipp_resume)
> +	SET_RUNTIME_PM_OPS(ipp_runtime_suspend, ipp_runtime_resume, NULL)
> +};
> +
> +struct platform_driver ipp_driver = {
> +	.probe		= ipp_probe,
> +	.remove		= __devexit_p(ipp_remove),
> +	.driver		= {
> +		.name	= "exynos-drm-ipp",
> +		.owner	= THIS_MODULE,
> +		.pm	= &ipp_pm_ops,
> +	},
> +};
> +
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.h
> b/drivers/gpu/drm/exynos/exynos_drm_ipp.h
> new file mode 100644
> index 0000000..baab1f0
> --- /dev/null
> +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.h
> @@ -0,0 +1,266 @@
> +/*
> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> + *
> + * Authors:
> + *	Eunchul Kim <chulspro.kim@samsung.com>
> + *	Jinyoung Jeon <jy0.jeon@samsung.com>
> + *	Sangmin Lee <lsmin.lee@samsung.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining
> a
> + * copy of this software and associated documentation files (the
> "Software"),
> + * to deal in the Software without restriction, including without
> limitation
> + * the rights to use, copy, modify, merge, publish, distribute,
> sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the
> next
> + * paragraph) shall be included in all copies or substantial portions of
> the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
> SHALL
> + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES
> OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +#ifndef _EXYNOS_DRM_IPP_H_
> +#define _EXYNOS_DRM_IPP_H_
> +
> +#define for_each_ipp_ops(pos)	\
> +	for (pos = 0; pos < EXYNOS_DRM_OPS_MAX; pos++)
> +#define for_each_ipp_planar(pos)	\
> +	for (pos = 0; pos < EXYNOS_DRM_PLANAR_MAX; pos++)
> +
> +#define IPP_GET_LCD_WIDTH	_IOR('F', 302, int)
> +#define IPP_GET_LCD_HEIGHT	_IOR('F', 303, int)
> +#define IPP_SET_WRITEBACK	_IOW('F', 304, u32)
> +
> +/* definition of state */
> +enum drm_exynos_ipp_state {
> +	IPP_STATE_IDLE,
> +	IPP_STATE_START,
> +	IPP_STATE_STOP,
> +};
> +
> +/*
> + * A structure of command work information.
> + * @work: work structure.
> + * @ippdrv: current work ippdrv.
> + * @c_node: command node information.
> + * @ctrl: command control.
> + */
> +struct drm_exynos_ipp_cmd_work {
> +	struct work_struct	work;
> +	struct exynos_drm_ippdrv	*ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node;
> +	enum drm_exynos_ipp_ctrl	ctrl;
> +};
> +
> +/*
> + * A structure of command node.
> + *
> + * @priv: IPP private infomation.
> + * @list: list head to command queue information.
> + * @event_list: list head of event.
> + * @mem_list: list head to source,destination memory queue information.
> + * @cmd_lock: lock for synchronization of access to ioctl.
> + * @mem_lock: lock for synchronization of access to memory nodes.
> + * @event_lock: lock for synchronization of access to scheduled event.
> + * @start_complete: completion of start of command.
> + * @stop_complete: completion of stop of command.
> + * @property: property information.
> + * @start_work: start command work structure.
> + * @stop_work: stop command work structure.
> + * @event_work: event work structure.
> + * @state: state of command node.
> + */
> +struct drm_exynos_ipp_cmd_node {
> +	struct exynos_drm_ipp_private *priv;
> +	struct list_head	list;
> +	struct list_head	event_list;
> +	struct list_head	mem_list[EXYNOS_DRM_OPS_MAX];
> +	struct mutex	cmd_lock;
> +	struct mutex	mem_lock;
> +	struct mutex	event_lock;
> +	struct completion	start_complete;
> +	struct completion	stop_complete;
> +	struct drm_exynos_ipp_property	property;
> +	struct drm_exynos_ipp_cmd_work *start_work;
> +	struct drm_exynos_ipp_cmd_work *stop_work;
> +	struct drm_exynos_ipp_event_work *event_work;
> +	enum drm_exynos_ipp_state	state;
> +};
> +
> +/*
> + * A structure of buffer information.
> + *
> + * @gem_objs: Y, Cb, Cr each gem object.
> + * @base: Y, Cb, Cr each planar address.
> + */
> +struct drm_exynos_ipp_buf_info {
> +	unsigned long	handles[EXYNOS_DRM_PLANAR_MAX];
> +	dma_addr_t	base[EXYNOS_DRM_PLANAR_MAX];
> +};
> +
> +/*
> + * A structure of wb setting infomation.
> + *
> + * @enable: enable flag for wb.
> + * @refresh: HZ of the refresh rate.
> + */
> +struct drm_exynos_ipp_set_wb {
> +	__u32	enable;
> +	__u32	refresh;
> +};
> +
> +/*
> + * A structure of event work information.
> + *
> + * @work: work structure.
> + * @ippdrv: current work ippdrv.
> + * @buf_id: id of src, dst buffer.
> + */
> +struct drm_exynos_ipp_event_work {
> +	struct work_struct	work;
> +	struct exynos_drm_ippdrv *ippdrv;
> +	u32	buf_id[EXYNOS_DRM_OPS_MAX];
> +};
> +
> +/*
> + * A structure of source,destination operations.
> + *
> + * @set_fmt: set format of image.
> + * @set_transf: set transform(rotations, flip).
> + * @set_size: set size of region.
> + * @set_addr: set address for dma.
> + */
> +struct exynos_drm_ipp_ops {
> +	int (*set_fmt)(struct device *dev, u32 fmt);
> +	int (*set_transf)(struct device *dev,
> +		enum drm_exynos_degree degree,
> +		enum drm_exynos_flip flip);
> +	int (*set_size)(struct device *dev, int swap,
> +		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz);
> +	int (*set_addr)(struct device *dev,
> +			 struct drm_exynos_ipp_buf_info *buf_info, u32
buf_id,
> +		enum drm_exynos_ipp_buf_type buf_type);
> +};
> +
> +/*
> + * A structure of ipp driver.
> + *
> + * @drv_list: list head for registed sub driver information.
> + * @parent_dev: parent device information.
> + * @dev: platform device.
> + * @drm_dev: drm device.
> + * @ipp_id: id of ipp driver.
> + * @dedicated: dedicated ipp device.
> + * @ops: source, destination operations.
> + * @event_workq: event work queue.
> + * @cmd: current command information.
> + * @cmd_list: list head for command information.
> + * @prop_list: property informations of current ipp driver.
> + * @check_property: check property about format, size, buffer.
> + * @reset: reset ipp block.
> + * @start: ipp each device start.
> + * @stop: ipp each device stop.
> + * @sched_event: work schedule handler.
> + */
> +struct exynos_drm_ippdrv {
> +	struct list_head	drv_list;
> +	struct device	*parent_dev;
> +	struct device	*dev;
> +	struct drm_device	*drm_dev;
> +	u32	ipp_id;
> +	bool	dedicated;
> +	struct exynos_drm_ipp_ops	*ops[EXYNOS_DRM_OPS_MAX];
> +	struct workqueue_struct	*event_workq;
> +	struct drm_exynos_ipp_cmd_node *cmd;
> +	struct list_head	cmd_list;
> +	struct drm_exynos_ipp_prop_list *prop_list;
> +
> +	int (*check_property)(struct device *dev,
> +		struct drm_exynos_ipp_property *property);
> +	int (*reset)(struct device *dev);
> +	int (*start)(struct device *dev, enum drm_exynos_ipp_cmd cmd);
> +	void (*stop)(struct device *dev, enum drm_exynos_ipp_cmd cmd);
> +	void (*sched_event)(struct work_struct *work);
> +};
> +
> +#ifdef CONFIG_DRM_EXYNOS_IPP
> +extern int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv *ippdrv);
> +extern int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv
*ippdrv);
> +extern int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void
> *data,
> +					 struct drm_file *file);
> +extern int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void
> *data,
> +					 struct drm_file *file);
> +extern int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void
> *data,
> +					 struct drm_file *file);
> +extern int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void
*data,
> +					 struct drm_file *file);
> +extern int exynos_drm_ippnb_register(struct notifier_block *nb);
> +extern int exynos_drm_ippnb_unregister(struct notifier_block *nb);
> +extern int exynos_drm_ippnb_send_event(unsigned long val, void *v);
> +extern void ipp_sched_cmd(struct work_struct *work);
> +extern void ipp_sched_event(struct work_struct *work);
> +
> +#else
> +static inline int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv
> *ippdrv)
> +{
> +	return -ENODEV;
> +}
> +
> +static inline int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv
> *ippdrv)
> +{
> +	return -ENODEV;
> +}
> +
> +static inline int exynos_drm_ipp_get_property(struct drm_device *drm_dev,
> +						void *data,
> +						struct drm_file *file_priv)
> +{
> +	return -ENOTTY;
> +}
> +
> +static inline int exynos_drm_ipp_set_property(struct drm_device *drm_dev,
> +						void *data,
> +						struct drm_file *file_priv)
> +{
> +	return -ENOTTY;
> +}
> +
> +static inline int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev,
> +						void *data,
> +						struct drm_file *file)
> +{
> +	return -ENOTTY;
> +}
> +
> +static inline int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev,
> +						void *data,
> +						struct drm_file *file)
> +{
> +	return -ENOTTY;
> +}
> +
> +static inline int exynos_drm_ippnb_register(struct notifier_block *nb)
> +{
> +	return -ENODEV;
> +}
> +
> +static inline int exynos_drm_ippnb_unregister(struct notifier_block *nb)
> +{
> +	return -ENODEV;
> +}
> +
> +static inline int exynos_drm_ippnb_send_event(unsigned long val, void *v)
> +{
> +	return -ENOTTY;
> +}
> +#endif
> +
> +#endif /* _EXYNOS_DRM_IPP_H_ */
> +
> diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
> index c0494d5..82772d7 100644
> --- a/include/uapi/drm/exynos_drm.h
> +++ b/include/uapi/drm/exynos_drm.h
> @@ -154,6 +154,170 @@ struct drm_exynos_g2d_exec {
>  	__u64					async;
>  };
> 
> +enum drm_exynos_ops_id {
> +	EXYNOS_DRM_OPS_SRC,
> +	EXYNOS_DRM_OPS_DST,
> +	EXYNOS_DRM_OPS_MAX,
> +};
> +
> +struct drm_exynos_sz {
> +	__u32	hsize;
> +	__u32	vsize;
> +};
> +
> +struct drm_exynos_pos {
> +	__u32	x;
> +	__u32	y;
> +	__u32	w;
> +	__u32	h;
> +};
> +
> +enum drm_exynos_flip {
> +	EXYNOS_DRM_FLIP_NONE = (0 << 0),
> +	EXYNOS_DRM_FLIP_VERTICAL = (1 << 0),
> +	EXYNOS_DRM_FLIP_HORIZONTAL = (1 << 1),
> +};
> +
> +enum drm_exynos_degree {
> +	EXYNOS_DRM_DEGREE_0,
> +	EXYNOS_DRM_DEGREE_90,
> +	EXYNOS_DRM_DEGREE_180,
> +	EXYNOS_DRM_DEGREE_270,
> +};
> +
> +enum drm_exynos_planer {
> +	EXYNOS_DRM_PLANAR_Y,
> +	EXYNOS_DRM_PLANAR_CB,
> +	EXYNOS_DRM_PLANAR_CR,
> +	EXYNOS_DRM_PLANAR_MAX,
> +};
> +
> +/**
> + * A structure for ipp supported property list.
> + *
> + * @version: version of this structure.
> + * @ipp_id: id of ipp driver.
> + * @count: count of ipp driver.
> + * @writeback: flag of writeback supporting.
> + * @flip: flag of flip supporting.
> + * @degree: flag of degree information.
> + * @csc: flag of csc supporting.
> + * @crop: flag of crop supporting.
> + * @scale: flag of scale supporting.
> + * @refresh_min: min hz of refresh.
> + * @refresh_max: max hz of refresh.
> + * @crop_min: crop min resolution.
> + * @crop_max: crop max resolution.
> + * @scale_min: scale min resolution.
> + * @scale_max: scale max resolution.
> + */
> +struct drm_exynos_ipp_prop_list {
> +	__u32	version;
> +	__u32	ipp_id;
> +	__u32	count;
> +	__u32	writeback;
> +	__u32	flip;
> +	__u32	degree;
> +	__u32	csc;
> +	__u32	crop;
> +	__u32	scale;
> +	__u32	refresh_min;
> +	__u32	refresh_max;
> +	__u32	reserved;
> +	struct drm_exynos_sz	crop_min;
> +	struct drm_exynos_sz	crop_max;
> +	struct drm_exynos_sz	scale_min;
> +	struct drm_exynos_sz	scale_max;
> +};
> +
> +/**
> + * A structure for ipp config.
> + *
> + * @ops_id: property of operation directions.
> + * @flip: property of mirror, flip.
> + * @degree: property of rotation degree.
> + * @fmt: property of image format.
> + * @sz: property of image size.
> + * @pos: property of image position(src-cropped,dst-scaler).
> + */
> +struct drm_exynos_ipp_config {
> +	enum drm_exynos_ops_id ops_id;
> +	enum drm_exynos_flip	flip;
> +	enum drm_exynos_degree	degree;
> +	__u32	fmt;
> +	struct drm_exynos_sz	sz;
> +	struct drm_exynos_pos	pos;
> +};
> +
> +enum drm_exynos_ipp_cmd {
> +	IPP_CMD_NONE,
> +	IPP_CMD_M2M,
> +	IPP_CMD_WB,
> +	IPP_CMD_OUTPUT,
> +	IPP_CMD_MAX,
> +};
> +
> +/**
> + * A structure for ipp property.
> + *
> + * @config: source, destination config.
> + * @cmd: definition of command.
> + * @ipp_id: id of ipp driver.
> + * @prop_id: id of property.
> + * @refresh_rate: refresh rate.
> + */
> +struct drm_exynos_ipp_property {
> +	struct drm_exynos_ipp_config config[EXYNOS_DRM_OPS_MAX];
> +	enum drm_exynos_ipp_cmd	cmd;
> +	__u32	ipp_id;
> +	__u32	prop_id;
> +	__u32	refresh_rate;
> +};
> +
> +enum drm_exynos_ipp_buf_type {
> +	IPP_BUF_ENQUEUE,
> +	IPP_BUF_DEQUEUE,
> +};
> +
> +/**
> + * A structure for ipp buffer operations.
> + *
> + * @ops_id: operation directions.
> + * @buf_type: definition of buffer.
> + * @prop_id: id of property.
> + * @buf_id: id of buffer.
> + * @handle: Y, Cb, Cr each planar handle.
> + * @user_data: user data.
> + */
> +struct drm_exynos_ipp_queue_buf {
> +	enum drm_exynos_ops_id	ops_id;
> +	enum drm_exynos_ipp_buf_type	buf_type;
> +	__u32	prop_id;
> +	__u32	buf_id;
> +	__u32	handle[EXYNOS_DRM_PLANAR_MAX];
> +	__u32	reserved;
> +	__u64	user_data;
> +};
> +
> +enum drm_exynos_ipp_ctrl {
> +	IPP_CTRL_PLAY,
> +	IPP_CTRL_STOP,
> +	IPP_CTRL_PAUSE,
> +	IPP_CTRL_RESUME,
> +	IPP_CTRL_MAX,
> +};
> +
> +/**
> + * A structure for ipp start/stop operations.
> + *
> + * @prop_id: id of property.
> + * @ctrl: definition of control.
> + */
> +struct drm_exynos_ipp_cmd_ctrl {
> +	__u32	prop_id;
> +	enum drm_exynos_ipp_ctrl	ctrl;
> +};
> +
>  #define DRM_EXYNOS_GEM_CREATE		0x00
>  #define DRM_EXYNOS_GEM_MAP_OFFSET	0x01
>  #define DRM_EXYNOS_GEM_MMAP		0x02
> @@ -166,6 +330,12 @@ struct drm_exynos_g2d_exec {
>  #define DRM_EXYNOS_G2D_SET_CMDLIST	0x21
>  #define DRM_EXYNOS_G2D_EXEC		0x22
> 
> +/* IPP - Image Post Processing */
> +#define DRM_EXYNOS_IPP_GET_PROPERTY	0x30
> +#define DRM_EXYNOS_IPP_SET_PROPERTY	0x31
> +#define DRM_EXYNOS_IPP_QUEUE_BUF	0x32
> +#define DRM_EXYNOS_IPP_CMD_CTRL	0x33
> +
>  #define DRM_IOCTL_EXYNOS_GEM_CREATE		DRM_IOWR(DRM_COMMAND_BASE +
> \
>  		DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
> 
> @@ -188,8 +358,18 @@ struct drm_exynos_g2d_exec {
>  #define DRM_IOCTL_EXYNOS_G2D_EXEC		DRM_IOWR(DRM_COMMAND_BASE +
> \
>  		DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)
> 
> +#define DRM_IOCTL_EXYNOS_IPP_GET_PROPERTY	DRM_IOWR(DRM_COMMAND_BASE +
> \
> +		DRM_EXYNOS_IPP_GET_PROPERTY, struct
drm_exynos_ipp_prop_list)
> +#define DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY	DRM_IOWR(DRM_COMMAND_BASE +
> \
> +		DRM_EXYNOS_IPP_SET_PROPERTY, struct drm_exynos_ipp_property)
> +#define DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF	DRM_IOWR(DRM_COMMAND_BASE +
\
> +		DRM_EXYNOS_IPP_QUEUE_BUF, struct drm_exynos_ipp_queue_buf)
> +#define DRM_IOCTL_EXYNOS_IPP_CMD_CTRL
DRM_IOWR(DRM_COMMAND_BASE +
> \
> +		DRM_EXYNOS_IPP_CMD_CTRL, struct drm_exynos_ipp_cmd_ctrl)
> +
>  /* EXYNOS specific events */
>  #define DRM_EXYNOS_G2D_EVENT		0x80000000
> +#define DRM_EXYNOS_IPP_EVENT		0x80000001
> 
>  struct drm_exynos_g2d_event {
>  	struct drm_event	base;
> @@ -200,4 +380,14 @@ struct drm_exynos_g2d_event {
>  	__u32			reserved;
>  };
> 
> +struct drm_exynos_ipp_event {
> +	struct drm_event	base;
> +	__u64			user_data;
> +	__u32			tv_sec;
> +	__u32			tv_usec;
> +	__u32			prop_id;
> +	__u32			reserved;
> +	__u32			buf_id[EXYNOS_DRM_OPS_MAX];
> +};
> +
>  #endif /* _UAPI_EXYNOS_DRM_H_ */
> --
> 1.7.0.4

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
  2012-12-12  7:34 ` [RFC v3 4/5] drm/exynos: add rotator " Eunchul Kim
@ 2012-12-12  8:29   ` Inki Dae
  2012-12-12  9:26     ` Eunchul Kim
  0 siblings, 1 reply; 18+ messages in thread
From: Inki Dae @ 2012-12-12  8:29 UTC (permalink / raw)
  To: 'Eunchul Kim', dri-devel
  Cc: jy0.jeon, kyungmin.park, jmock.shin, jaejoon.seo



> -----Original Message-----
> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> Sent: Wednesday, December 12, 2012 4:35 PM
> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com; jmock.shin@samsung.com;
> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
> chulspro.kim@samsung.com
> Subject: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> 
> Rotator supports rotation/crop/flip and input/output DMA operations
> Rotator ipp driver supports 90,180,270 degree rotaion and vertical,
> horizontal flip.
> and has some limitations(source and destination format have to be same, no
> scaler)
> 
> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
> Signed-off-by: Youngjun Cho <yj44.cho@samsung.com>
> ---
>  drivers/gpu/drm/exynos/Kconfig              |    7 +
>  drivers/gpu/drm/exynos/Makefile             |    1 +
>  drivers/gpu/drm/exynos/exynos_drm_drv.c     |   15 +
>  drivers/gpu/drm/exynos/exynos_drm_drv.h     |    1 +
>  drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829
> +++++++++++++++++++++++++++
>  drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
>  drivers/gpu/drm/exynos/regs-rotator.h       |   73 +++
>  7 files changed, 939 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
>  create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
>  create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
> 
> diff --git a/drivers/gpu/drm/exynos/Kconfig
> b/drivers/gpu/drm/exynos/Kconfig
> index 4915ab6..4860835 100644
> --- a/drivers/gpu/drm/exynos/Kconfig
> +++ b/drivers/gpu/drm/exynos/Kconfig
> @@ -57,3 +57,10 @@ config DRM_EXYNOS_FIMC
>  	depends on DRM_EXYNOS_IPP
>  	help
>  	  Choose this option if you want to use Exynos FIMC for DRM.
> +
> +config DRM_EXYNOS_ROTATOR
> +	bool "Exynos DRM Rotator"
> +	depends on DRM_EXYNOS_IPP
> +	help
> +	  Choose this option if you want to use Exynos Rotator for DRM.
> +
> diff --git a/drivers/gpu/drm/exynos/Makefile
> b/drivers/gpu/drm/exynos/Makefile
> index 9710024..3b70668 100644
> --- a/drivers/gpu/drm/exynos/Makefile
> +++ b/drivers/gpu/drm/exynos/Makefile
> @@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+=
> exynos_drm_vidi.o
>  exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
>  exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
>  exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
> +exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
> 
>  obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index 73f02ac..09d884b 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -378,6 +378,12 @@ static int __init exynos_drm_init(void)
>  		goto out_fimc;
>  #endif
> 
> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> +	ret = platform_driver_register(&rotator_driver);
> +	if (ret < 0)
> +		goto out_rotator;
> +#endif
> +
>  #ifdef CONFIG_DRM_EXYNOS_IPP
>  	ret = platform_driver_register(&ipp_driver);
>  	if (ret < 0)
> @@ -406,6 +412,11 @@ out_drm:
>  out_ipp:
>  #endif
> 
> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> +	platform_driver_unregister(&rotator_driver);
> +out_rotator:
> +#endif
> +
>  #ifdef CONFIG_DRM_EXYNOS_FIMC
>  	platform_driver_unregister(&fimc_driver);
>  out_fimc:
> @@ -451,6 +462,10 @@ static void __exit exynos_drm_exit(void)
>  	platform_driver_unregister(&ipp_driver);
>  #endif
> 
> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> +	platform_driver_unregister(&rotator_driver);
> +#endif
> +
>  #ifdef CONFIG_DRM_EXYNOS_FIMC
>  	platform_driver_unregister(&fimc_driver);
>  #endif
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> index 14f9490..a74e37c 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> @@ -353,5 +353,6 @@ extern struct platform_driver
> exynos_drm_common_hdmi_driver;
>  extern struct platform_driver vidi_driver;
>  extern struct platform_driver g2d_driver;
>  extern struct platform_driver fimc_driver;
> +extern struct platform_driver rotator_driver;
>  extern struct platform_driver ipp_driver;
>  #endif
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> new file mode 100644
> index 0000000..121569c
> --- /dev/null
> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> @@ -0,0 +1,829 @@
> +/*
> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> + * Authors:
> + *	YoungJun Cho <yj44.cho@samsung.com>
> + *	Eunchul Kim <chulspro.kim@samsung.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundationr
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/err.h>
> +#include <linux/interrupt.h>
> +#include <linux/io.h>
> +#include <linux/platform_device.h>
> +#include <linux/clk.h>
> +#include <linux/pm_runtime.h>
> +
> +#include <drm/drmP.h>
> +#include <drm/exynos_drm.h>
> +#include "regs-rotator.h"
> +#include "exynos_drm.h"
> +#include "exynos_drm_ipp.h"
> +
> +/*
> + * Rotator supports image crop/rotator and input/output DMA operations.
> + * input DMA reads image data from the memory.
> + * output DMA writes image data to memory.
> + */
> +
> +#define get_rot_context(dev)
> 	platform_get_drvdata(to_platform_device(dev))
> +#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
> +					struct rot_context, ippdrv);
> +#define rot_read(offset)		readl(rot->regs + (offset))
> +#define rot_write(cfg, offset)	writel(cfg, rot->regs + (offset))
> +
> +enum rot_irq_status {
> +	ROT_IRQ_STATUS_COMPLETE	= 8,
> +	ROT_IRQ_STATUS_ILLEGAL	= 9,
> +};
> +
> +/*
> + * A structure of limitation.
> + *
> + * @min_w: minimum width.
> + * @min_h: minimum height.
> + * @max_w: maximum width.
> + * @max_h: maximum height.
> + * @align: align size.
> + */
> +struct rot_limit {
> +	u32	min_w;
> +	u32	min_h;
> +	u32	max_w;
> +	u32	max_h;
> +	u32	align;
> +};
> +
> +/*
> + * A structure of limitation table.
> + *
> + * @ycbcr420_2p: case of YUV.
> + * @rgb888: case of RGB.
> + */
> +struct rot_limit_table {
> +	struct rot_limit	ycbcr420_2p;
> +	struct rot_limit	rgb888;
> +};
> +
> +/*
> + * A structure of rotator context.
> + * @ippdrv: prepare initialization using ippdrv.
> + * @regs_res: register resources.
> + * @regs: memory mapped io registers.
> + * @clock: rotator gate clock.
> + * @limit_tbl: limitation of rotator.
> + * @irq: irq number.
> + * @cur_buf_id: current operation buffer id.
> + * @suspended: suspended state.
> + */
> +struct rot_context {
> +	struct exynos_drm_ippdrv	ippdrv;
> +	struct resource	*regs_res;
> +	void __iomem	*regs;
> +	struct clk	*clock;
> +	struct rot_limit_table	*limit_tbl;
> +	int	irq;
> +	int	cur_buf_id[EXYNOS_DRM_OPS_MAX];
> +	bool	suspended;
> +};
> +
> +static void rotator_reg_set_irq(struct rot_context *rot, bool enable)
> +{
> +	u32 val = rot_read(ROT_CONFIG);
> +
> +	if (enable == true)
> +		val |= ROT_CONFIG_IRQ;
> +	else
> +		val &= ~ROT_CONFIG_IRQ;
> +
> +	rot_write(val, ROT_CONFIG);
> +}
> +
> +static u32 rotator_reg_get_format(struct rot_context *rot)
> +{
> +	u32 val = rot_read(ROT_CONTROL);
> +
> +	val &= ROT_CONTROL_FMT_MASK;
> +
> +	return val;
> +}
> +
> +static enum rot_irq_status rotator_reg_get_irq_status(struct rot_context
> *rot)
> +{
> +	u32 val = rot_read(ROT_STATUS);
> +
> +	val = ROT_STATUS_IRQ(val);
> +
> +	if (val == ROT_STATUS_IRQ_VAL_COMPLETE)
> +		return ROT_IRQ_STATUS_COMPLETE;
> +	else

Remove else.

> +		return ROT_IRQ_STATUS_ILLEGAL;
> +}
> +
> +static irqreturn_t rotator_irq_handler(int irq, void *arg)
> +{
> +	struct rot_context *rot = arg;
> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
> +	struct drm_exynos_ipp_event_work *event_work = c_node->event_work;
> +	enum rot_irq_status irq_status;
> +	u32 val;
> +
> +	/* Get execution result */
> +	irq_status = rotator_reg_get_irq_status(rot);
> +
> +	/* clear status */
> +	val = rot_read(ROT_STATUS);
> +	val |= ROT_STATUS_IRQ_PENDING((u32)irq_status);
> +	rot_write(val, ROT_STATUS);
> +
> +	if (irq_status == ROT_IRQ_STATUS_COMPLETE) {
> +		event_work->ippdrv = ippdrv;
> +		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
> +			rot->cur_buf_id[EXYNOS_DRM_OPS_DST];
> +		queue_work(ippdrv->event_workq,
> +			(struct work_struct *)event_work);
> +	} else
> +		DRM_ERROR("the SFR is set illegally\n");
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static void rotator_align_size(struct rot_context *rot, u32 fmt, u32
> *hsize,
> +		u32 *vsize)
> +{
> +	struct rot_limit_table *limit_tbl = rot->limit_tbl;
> +	struct rot_limit *limit;
> +	u32 mask, val;
> +
> +	/* Get size limit */
> +	if (fmt == ROT_CONTROL_FMT_RGB888)
> +		limit = &limit_tbl->rgb888;
> +	else
> +		limit = &limit_tbl->ycbcr420_2p;
> +
> +	/* Get mask for rounding to nearest aligned val */
> +	mask = ~((1 << limit->align) - 1);
> +
> +	/* Set aligned width */
> +	val = ROT_ALIGN(*hsize, limit->align, mask);
> +	if (val < limit->min_w)
> +		*hsize = ROT_MIN(limit->min_w, mask);
> +	else if (val > limit->max_w)
> +		*hsize = ROT_MAX(limit->max_w, mask);
> +	else
> +		*hsize = val;
> +
> +	/* Set aligned height */
> +	val = ROT_ALIGN(*vsize, limit->align, mask);
> +	if (val < limit->min_h)
> +		*vsize = ROT_MIN(limit->min_h, mask);
> +	else if (val > limit->max_h)
> +		*vsize = ROT_MAX(limit->max_h, mask);
> +	else
> +		*vsize = val;
> +}
> +
> +static int rotator_src_set_fmt(struct device *dev, u32 fmt)
> +{
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +	u32 val;
> +
> +	val = rot_read(ROT_CONTROL);
> +	val &= ~ROT_CONTROL_FMT_MASK;
> +
> +	switch (fmt) {
> +	case DRM_FORMAT_NV12:
> +		val |= ROT_CONTROL_FMT_YCBCR420_2P;
> +		break;
> +	case DRM_FORMAT_XRGB8888:
> +		val |= ROT_CONTROL_FMT_RGB888;
> +		break;
> +	default:
> +		DRM_ERROR("invalid image format\n");
> +		return -EINVAL;
> +	}
> +
> +	rot_write(val, ROT_CONTROL);
> +
> +	return 0;
> +}
> +
> +static int rotator_src_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;
> +	u32 val;
> +
> +	/* 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 */
> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> +	rot_write(val, ROT_SRC_BUF_SIZE);
> +
> +	/* Set crop image position configuration */
> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> +	rot_write(val, ROT_SRC_CROP_POS);
> +	val = ROT_SRC_CROP_SIZE_H(pos->h) | ROT_SRC_CROP_SIZE_W(pos->w);
> +	rot_write(val, ROT_SRC_CROP_SIZE);
> +
> +	return 0;
> +}
> +
> +static int rotator_src_set_addr(struct device *dev,
> +		struct drm_exynos_ipp_buf_info *buf_info,
> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> +{
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> +	u32 val, fmt, hsize, vsize;
> +	int i;
> +
> +	/* Set current buf_id */
> +	rot->cur_buf_id[EXYNOS_DRM_OPS_SRC] = buf_id;
> +
> +	switch (buf_type) {
> +	case IPP_BUF_ENQUEUE:
> +		/* Set address configuration */
> +		for_each_ipp_planar(i)
> +			addr[i] = buf_info->base[i];

Check NULL.

> +
> +		/* Get format */
> +		fmt = rotator_reg_get_format(rot);
> +
> +		/* Re-set cb planar for NV12 format */
> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
0x00)) {

What is 0x00?

> +
> +			val = rot_read(ROT_SRC_BUF_SIZE);
> +			hsize = ROT_GET_BUF_SIZE_W(val);
> +			vsize = ROT_GET_BUF_SIZE_H(val);
> +
> +			/* Set cb planar */
> +			addr[EXYNOS_DRM_PLANAR_CB] =
> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
> +		}
> +
> +		for_each_ipp_planar(i)
> +			rot_write(addr[i], ROT_SRC_BUF_ADDR(i));
> +		break;
> +	case IPP_BUF_DEQUEUE:
> +		for_each_ipp_planar(i)
> +			rot_write(0x0, ROT_SRC_BUF_ADDR(i));
> +		break;
> +	default:
> +		/* Nothing to do */
> +		break;
> +	}
> +
> +	return 0;
> +}
> +
> +static int rotator_dst_set_transf(struct device *dev,
> +		enum drm_exynos_degree degree,
> +		enum drm_exynos_flip flip)
> +{
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +	u32 val;
> +
> +	/* Set transform configuration */
> +	val = rot_read(ROT_CONTROL);
> +	val &= ~ROT_CONTROL_FLIP_MASK;
> +
> +	switch (flip) {
> +	case EXYNOS_DRM_FLIP_VERTICAL:
> +		val |= ROT_CONTROL_FLIP_VERTICAL;
> +		break;
> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> +		val |= ROT_CONTROL_FLIP_HORIZONTAL;
> +		break;
> +	default:
> +		/* Flip None */
> +		break;
> +	}
> +
> +	val &= ~ROT_CONTROL_ROT_MASK;
> +
> +	switch (degree) {
> +	case EXYNOS_DRM_DEGREE_90:
> +		val |= ROT_CONTROL_ROT_90;
> +		break;
> +	case EXYNOS_DRM_DEGREE_180:
> +		val |= ROT_CONTROL_ROT_180;
> +		break;
> +	case EXYNOS_DRM_DEGREE_270:
> +		val |= ROT_CONTROL_ROT_270;
> +		break;
> +	default:
> +		/* Rotation 0 Degree */
> +		break;
> +	}
> +
> +	rot_write(val, ROT_CONTROL);
> +
> +	/* Check degree for setting buffer size swap */
> +	if ((degree == EXYNOS_DRM_DEGREE_90) ||
> +		(degree == EXYNOS_DRM_DEGREE_270))
> +		return 1;

Correct return type. This function should return 0 or negative.

> +	else
> +		return 0;

Ditto.

> +}
> +
> +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 val, fmt, hsize, vsize;
> +
> +	/* Get format */
> +	fmt = rotator_reg_get_format(rot);

Check if fmt is valid or not.

> +
> +	/* Align buffer size */
> +	hsize = sz->hsize;
> +	vsize = sz->vsize;
> +	rotator_align_size(rot, fmt, &hsize, &vsize);
> +
> +	/* Set buffer size configuration */
> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> +	rot_write(val, ROT_DST_BUF_SIZE);
> +
> +	/* Set crop image position configuration */
> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> +	rot_write(val, ROT_DST_CROP_POS);
> +
> +	return 0;
> +}
> +
> +static int rotator_dst_set_addr(struct device *dev,
> +		struct drm_exynos_ipp_buf_info *buf_info,
> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> +{
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> +	u32 val, fmt, hsize, vsize;
> +	int i;
> +
> +	/* Set current buf_id */
> +	rot->cur_buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
> +
> +	switch (buf_type) {
> +	case IPP_BUF_ENQUEUE:
> +		/* Set address configuration */
> +		for_each_ipp_planar(i)
> +			addr[i] = buf_info->base[i];
> +
> +		/* Get format */
> +		fmt = rotator_reg_get_format(rot);

Check if fmt is valid or not.

> +
> +		/* Re-set cb planar for NV12 format */
> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
0x00)) {
> +			/* Get buf size */
> +			val = rot_read(ROT_DST_BUF_SIZE);
> +
> +			hsize = ROT_GET_BUF_SIZE_W(val);
> +			vsize = ROT_GET_BUF_SIZE_H(val);
> +
> +			/* Set cb planar */
> +			addr[EXYNOS_DRM_PLANAR_CB] =
> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
> +		}
> +
> +		for_each_ipp_planar(i)
> +			rot_write(addr[i], ROT_DST_BUF_ADDR(i));
> +		break;
> +	case IPP_BUF_DEQUEUE:
> +		for_each_ipp_planar(i)
> +			rot_write(0x0, ROT_DST_BUF_ADDR(i));
> +		break;
> +	default:
> +		/* Nothing to do */
> +		break;
> +	}
> +
> +	return 0;
> +}
> +
> +static struct exynos_drm_ipp_ops rot_src_ops = {
> +	.set_fmt	=	rotator_src_set_fmt,
> +	.set_size	=	rotator_src_set_size,
> +	.set_addr	=	rotator_src_set_addr,
> +};
> +
> +static struct exynos_drm_ipp_ops rot_dst_ops = {
> +	.set_transf	=	rotator_dst_set_transf,
> +	.set_size	=	rotator_dst_set_size,
> +	.set_addr	=	rotator_dst_set_addr,
> +};
> +
> +static int rotator_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
> +{
> +	struct drm_exynos_ipp_prop_list *prop_list;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
> +	if (!prop_list) {
> +		DRM_ERROR("failed to alloc property list.\n");
> +		return -ENOMEM;
> +	}
> +
> +	/*ToDo fix support function list*/
> +
> +	prop_list->version = 1;
> +	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
> +				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
> +	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
> +				(1 << EXYNOS_DRM_DEGREE_90) |
> +				(1 << EXYNOS_DRM_DEGREE_180) |
> +				(1 << EXYNOS_DRM_DEGREE_270);
> +	prop_list->csc = 0;
> +	prop_list->crop = 0;
> +	prop_list->scale = 0;
> +
> +	ippdrv->prop_list = prop_list;
> +
> +	return 0;
> +}
> +
> +static int rotator_ippdrv_check_property(struct device *dev,
> +		struct drm_exynos_ipp_property *property)
> +{
> +	struct drm_exynos_ipp_config *src_config =
> +
&property->config[EXYNOS_DRM_OPS_SRC];
> +	struct drm_exynos_ipp_config *dst_config =
> +
&property->config[EXYNOS_DRM_OPS_DST];
> +	struct drm_exynos_pos *src_pos = &src_config->pos;
> +	struct drm_exynos_pos *dst_pos = &dst_config->pos;
> +	struct drm_exynos_sz *src_sz = &src_config->sz;
> +	struct drm_exynos_sz *dst_sz = &dst_config->sz;
> +	bool swap = false;
> +
> +	/* Check format configuration */
> +	if (src_config->fmt != dst_config->fmt) {
> +		DRM_DEBUG_KMS("%s:not support csc feature\n", __func__);
> +		return -EINVAL;
> +	}
> +
> +	switch (src_config->fmt) {
> +	case DRM_FORMAT_XRGB8888:
> +	case DRM_FORMAT_NV12:
> +		/* No problem */
> +		break;
> +	default:
> +		DRM_DEBUG_KMS("%s:not support format\n", __func__);
> +		return -EINVAL;
> +	}

Use macro instead of switch-case. this just checks only format type.

> +
> +	/* Check transform configuration */
> +	if (src_config->degree != EXYNOS_DRM_DEGREE_0) {
> +		DRM_DEBUG_KMS("%s:not support source-side rotation\n",
> +								__func__);
> +		return -EINVAL;
> +	}
> +
> +	switch (dst_config->degree) {
> +	case EXYNOS_DRM_DEGREE_90:
> +	case EXYNOS_DRM_DEGREE_270:
> +		swap = true;
> +	case EXYNOS_DRM_DEGREE_0:
> +	case EXYNOS_DRM_DEGREE_180:
> +		/* No problem */
> +		break;
> +	default:
> +		DRM_DEBUG_KMS("%s:invalid degree\n", __func__);
> +		return -EINVAL;
> +	}
> +
> +	if (src_config->flip != EXYNOS_DRM_FLIP_NONE) {
> +		DRM_DEBUG_KMS("%s:not support source-side flip\n",
__func__);
> +		return -EINVAL;
> +	}
> +
> +	switch (dst_config->flip) {
> +	case EXYNOS_DRM_FLIP_NONE:
> +	case EXYNOS_DRM_FLIP_VERTICAL:
> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> +		/* No problem */
> +		break;
> +	default:
> +		DRM_DEBUG_KMS("%s:invalid flip\n", __func__);
> +		return -EINVAL;
> +	}

Use macro instead of switch-case. this just checks only flip type.

> +
> +	/* Check size configuration */
> +	if ((src_pos->x + src_pos->w > src_sz->hsize) ||
> +		(src_pos->y + src_pos->h > src_sz->vsize)) {
> +		DRM_DEBUG_KMS("%s:out of source buffer bound\n", __func__);
> +		return -EINVAL;
> +	}
> +
> +	if (swap) {
> +		if ((dst_pos->x + dst_pos->h > dst_sz->vsize) ||
> +			(dst_pos->y + dst_pos->w > dst_sz->hsize)) {
> +			DRM_DEBUG_KMS("%s:out of destination buffer
bound\n",
> +								__func__);
> +			return -EINVAL;
> +		}
> +
> +		if ((src_pos->w != dst_pos->h) || (src_pos->h !=
dst_pos->w))
> {
> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
> +								__func__);
> +			return -EINVAL;
> +		}
> +	} else {
> +		if ((dst_pos->x + dst_pos->w > dst_sz->hsize) ||
> +			(dst_pos->y + dst_pos->h > dst_sz->vsize)) {
> +			DRM_DEBUG_KMS("%s:out of destination buffer
bound\n",
> +								__func__);
> +			return -EINVAL;
> +		}
> +
> +		if ((src_pos->w != dst_pos->w) || (src_pos->h !=
dst_pos->h))
> {
> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
> +								__func__);
> +			return -EINVAL;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static int rotator_ippdrv_start(struct device *dev, enum
> drm_exynos_ipp_cmd cmd)
> +{
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +	u32 val;
> +
> +	if (rot->suspended) {
> +		DRM_ERROR("suspended state\n");
> +		return -EPERM;
> +	}
> +
> +	if (cmd != IPP_CMD_M2M) {
> +		DRM_ERROR("not support cmd: %d\n", cmd);
> +		return -EINVAL;
> +	}
> +
> +	/* Set interrupt enable */
> +	rotator_reg_set_irq(rot, true);
> +
> +	val = rot_read(ROT_CONTROL);
> +	val |= ROT_CONTROL_START;
> +
> +	rot_write(val, ROT_CONTROL);
> +
> +	return 0;
> +}
> +
> +static int __devinit rotator_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct rot_context *rot;
> +	struct resource *res;
> +	struct exynos_drm_ippdrv *ippdrv;
> +	int ret;
> +
> +	rot = kzalloc(sizeof(*rot), GFP_KERNEL);
> +	if (!rot) {
> +		dev_err(dev, "failed to allocate rot\n");
> +		return -ENOMEM;
> +	}
> +
> +	rot->limit_tbl = (struct rot_limit_table *)
> +				platform_get_device_id(pdev)->driver_data;
> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res) {
> +		dev_err(dev, "failed to find registers\n");
> +		ret = -ENOENT;
> +		goto err_get_resource;
> +	}
> +
> +	rot->regs_res = request_mem_region(res->start, resource_size(res),
> +
dev_name(dev));
> +	if (!rot->regs_res) {
> +		dev_err(dev, "failed to claim register region\n");
> +		ret = -ENOENT;
> +		goto err_get_resource;
> +	}
> +
> +	rot->regs = ioremap(res->start, resource_size(res));
> +	if (!rot->regs) {
> +		dev_err(dev, "failed to map register\n");
> +		ret = -ENXIO;
> +		goto err_ioremap;
> +	}
> +
> +	rot->irq = platform_get_irq(pdev, 0);
> +	if (rot->irq < 0) {
> +		dev_err(dev, "failed to get irq\n");
> +		ret = rot->irq;
> +		goto err_get_irq;
> +	}
> +
> +	ret = request_threaded_irq(rot->irq, NULL, rotator_irq_handler,
> +					IRQF_ONESHOT, "drm_rotator", rot);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to request irq\n");
> +		goto err_get_irq;
> +	}
> +
> +	rot->clock = clk_get(dev, "rotator");
> +	if (IS_ERR_OR_NULL(rot->clock)) {
> +		dev_err(dev, "failed to get clock\n");
> +		ret = PTR_ERR(rot->clock);
> +		goto err_clk_get;
> +	}
> +
> +	pm_runtime_enable(dev);
> +
> +	ippdrv = &rot->ippdrv;
> +	ippdrv->dev = dev;
> +	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &rot_src_ops;
> +	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &rot_dst_ops;
> +	ippdrv->check_property = rotator_ippdrv_check_property;
> +	ippdrv->start = rotator_ippdrv_start;
> +	ret = rotator_init_prop_list(ippdrv);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to init property list.\n");
> +		goto err_ippdrv_register;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:ippdrv[0x%x]\n", __func__, (int)ippdrv);
> +
> +	platform_set_drvdata(pdev, rot);
> +
> +	ret = exynos_drm_ippdrv_register(ippdrv);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to register drm rotator device\n");
> +		kfree(ippdrv->prop_list);
> +		goto err_ippdrv_register;
> +	}
> +
> +	dev_info(dev, "The exynos rotator is probed successfully\n");
> +
> +	return 0;
> +
> +err_ippdrv_register:
> +	pm_runtime_disable(dev);
> +	clk_put(rot->clock);
> +err_clk_get:
> +	free_irq(rot->irq, rot);
> +err_get_irq:
> +	iounmap(rot->regs);
> +err_ioremap:
> +	release_resource(rot->regs_res);
> +	kfree(rot->regs_res);
> +err_get_resource:
> +	kfree(rot);
> +	return ret;
> +}
> +
> +static int __devexit rotator_remove(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> +
> +	kfree(ippdrv->prop_list);
> +	exynos_drm_ippdrv_unregister(ippdrv);
> +
> +	pm_runtime_disable(dev);
> +	clk_put(rot->clock);
> +
> +	free_irq(rot->irq, rot);
> +
> +	iounmap(rot->regs);
> +
> +	release_resource(rot->regs_res);
> +	kfree(rot->regs_res);
> +
> +	kfree(rot);
> +
> +	return 0;
> +}
> +
> +struct rot_limit_table rot_limit_tbl = {
> +	.ycbcr420_2p = {
> +		.min_w = 32,
> +		.min_h = 32,
> +		.max_w = SZ_32K,
> +		.max_h = SZ_32K,
> +		.align = 3,
> +	},
> +	.rgb888 = {
> +		.min_w = 8,
> +		.min_h = 8,
> +		.max_w = SZ_8K,
> +		.max_h = SZ_8K,
> +		.align = 2,
> +	},
> +};
> +
> +struct platform_device_id rotator_driver_ids[] = {
> +	{
> +		.name		= "exynos-rot",
> +		.driver_data	= (unsigned long)&rot_limit_tbl,
> +	},
> +	{},
> +};
> +
> +static int rotator_clk_crtl(struct rot_context *rot, bool enable)
> +{
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (enable) {
> +		clk_enable(rot->clock);
> +		rot->suspended = false;
> +	} else {
> +		clk_disable(rot->clock);
> +		rot->suspended = true;
> +	}
> +
> +	return 0;
> +}
> +
> +
> +#ifdef CONFIG_PM_SLEEP
> +static int rotator_suspend(struct device *dev)
> +{
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +
> +	/* ToDo */
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (pm_runtime_suspended(dev))
> +		return 0;
> +
> +	return rotator_clk_crtl(rot, false);
> +}
> +
> +static int rotator_resume(struct device *dev)
> +{
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +
> +	/* ToDo */
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	if (!pm_runtime_suspended(dev))
> +		return rotator_clk_crtl(rot, true);
> +
> +	return 0;
> +}
> +#endif
> +
> +#ifdef CONFIG_PM_RUNTIME
> +static int rotator_runtime_suspend(struct device *dev)
> +{
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +
> +	/* ToDo */
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	return  rotator_clk_crtl(rot, false);
> +}
> +
> +static int rotator_runtime_resume(struct device *dev)
> +{
> +	struct rot_context *rot = dev_get_drvdata(dev);
> +
> +	/* ToDo */
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	return  rotator_clk_crtl(rot, true);
> +}
> +#endif
> +
> +static const struct dev_pm_ops rotator_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(rotator_suspend, rotator_resume)
> +	SET_RUNTIME_PM_OPS(rotator_runtime_suspend, rotator_runtime_resume,
> +
NULL)
> +};
> +
> +struct platform_driver rotator_driver = {
> +	.probe		= rotator_probe,
> +	.remove		= __devexit_p(rotator_remove),
> +	.id_table	= rotator_driver_ids,
> +	.driver		= {
> +		.name	= "exynos-rot",
> +		.owner	= THIS_MODULE,
> +		.pm	= &rotator_pm_ops,
> +	},
> +};
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> new file mode 100644
> index 0000000..fe929c9
> --- /dev/null
> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> @@ -0,0 +1,13 @@
> +/*
> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> + * Authors: YoungJun Cho <yj44.cho@samsung.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundationr
> + */
> +
> +#ifndef	_EXYNOS_DRM_ROTATOR_H_
> +#define	_EXYNOS_DRM_ROTATOR_H_
> +
> +#endif
> diff --git a/drivers/gpu/drm/exynos/regs-rotator.h
> b/drivers/gpu/drm/exynos/regs-rotator.h
> new file mode 100644
> index 0000000..a09ac6e
> --- /dev/null
> +++ b/drivers/gpu/drm/exynos/regs-rotator.h
> @@ -0,0 +1,73 @@
> +/* drivers/gpu/drm/exynos/regs-rotator.h
> + *
> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> + *		http://www.samsung.com/
> + *
> + * Register definition file for Samsung Rotator Interface (Rotator)
> driver
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> +*/
> +
> +#ifndef EXYNOS_REGS_ROTATOR_H
> +#define EXYNOS_REGS_ROTATOR_H
> +
> +/* Configuration */
> +#define ROT_CONFIG			0x00
> +#define ROT_CONFIG_IRQ			(3 << 8)
> +
> +/* Image Control */
> +#define ROT_CONTROL			0x10
> +#define ROT_CONTROL_PATTERN_WRITE	(1 << 16)
> +#define ROT_CONTROL_FMT_YCBCR420_2P	(1 << 8)
> +#define ROT_CONTROL_FMT_RGB888		(6 << 8)
> +#define ROT_CONTROL_FMT_MASK		(7 << 8)
> +#define ROT_CONTROL_FLIP_VERTICAL	(2 << 6)
> +#define ROT_CONTROL_FLIP_HORIZONTAL	(3 << 6)
> +#define ROT_CONTROL_FLIP_MASK		(3 << 6)
> +#define ROT_CONTROL_ROT_90		(1 << 4)
> +#define ROT_CONTROL_ROT_180		(2 << 4)
> +#define ROT_CONTROL_ROT_270		(3 << 4)
> +#define ROT_CONTROL_ROT_MASK		(3 << 4)
> +#define ROT_CONTROL_START		(1 << 0)
> +
> +/* Status */
> +#define ROT_STATUS			0x20
> +#define ROT_STATUS_IRQ_PENDING(x)	(1 << (x))
> +#define ROT_STATUS_IRQ(x)		(((x) >> 8) & 0x3)
> +#define ROT_STATUS_IRQ_VAL_COMPLETE	1
> +#define ROT_STATUS_IRQ_VAL_ILLEGAL	2
> +
> +/* Buffer Address */
> +#define ROT_SRC_BUF_ADDR(n)		(0x30 + ((n) << 2))
> +#define ROT_DST_BUF_ADDR(n)		(0x50 + ((n) << 2))
> +
> +/* Buffer Size */
> +#define ROT_SRC_BUF_SIZE		0x3c
> +#define ROT_DST_BUF_SIZE		0x5c
> +#define ROT_SET_BUF_SIZE_H(x)		((x) << 16)
> +#define ROT_SET_BUF_SIZE_W(x)		((x) << 0)
> +#define ROT_GET_BUF_SIZE_H(x)		((x) >> 16)
> +#define ROT_GET_BUF_SIZE_W(x)		((x) & 0xffff)
> +
> +/* Crop Position */
> +#define ROT_SRC_CROP_POS		0x40
> +#define ROT_DST_CROP_POS		0x60
> +#define ROT_CROP_POS_Y(x)		((x) << 16)
> +#define ROT_CROP_POS_X(x)		((x) << 0)
> +
> +/* Source Crop Size */
> +#define ROT_SRC_CROP_SIZE		0x44
> +#define ROT_SRC_CROP_SIZE_H(x)		((x) << 16)
> +#define ROT_SRC_CROP_SIZE_W(x)		((x) << 0)
> +
> +/* Round to nearest aligned value */
> +#define ROT_ALIGN(x, align, mask)	(((x) + (1 << ((align) - 1))) &
> (mask))
> +/* Minimum limit value */
> +#define ROT_MIN(min, mask)		(((min) + ~(mask)) & (mask))
> +/* Maximum limit value */
> +#define ROT_MAX(max, mask)		((max) & (mask))
> +
> +#endif /* EXYNOS_REGS_ROTATOR_H */
> +
> --
> 1.7.0.4

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC v3 1/5] drm/exynos: add ipp subsystem
  2012-12-12  8:18   ` Inki Dae
@ 2012-12-12  9:02     ` Eunchul Kim
  0 siblings, 0 replies; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12  9:02 UTC (permalink / raw)
  To: Inki Dae
  Cc: jy0.jeon, sw0312.kim, jaejoon.seo, kyungmin.park, dri-devel, jmock.shin

Thank's your comment.

I anwer your comment, please check that.

Thank's

BR
Eunchul Kim.

On 12/12/2012 05:18 PM, Inki Dae wrote:
>
>
>> -----Original Message-----
>> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
>> Sent: Wednesday, December 12, 2012 4:35 PM
>> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
>> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com; jmock.shin@samsung.com;
>> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
>> chulspro.kim@samsung.com
>> Subject: [RFC v3 1/5] drm/exynos: add ipp subsystem
>>
>> IPP stand for Image Post Processing and supports image scaler/rotator
>> /crop/flip/csc(color space conversion) and input/output DMA operations
>> using ipp drivers.
>> also supports writeback and display output operations.
>> ipp driver include FIMC, Rotator, GSC, SC, so on.
>> and ipp is integration device driver for each hardware.
>>
>> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
>> Signed-off-by: Jinyoung Jeon <jy0.jeon@samsung.com>
>> ---
>>   drivers/gpu/drm/exynos/Kconfig          |    6 +
>>   drivers/gpu/drm/exynos/Makefile         |    1 +
>>   drivers/gpu/drm/exynos/exynos_drm_drv.c |   24 +
>>   drivers/gpu/drm/exynos/exynos_drm_drv.h |    7 +
>>   drivers/gpu/drm/exynos/exynos_drm_ipp.c | 2059
>> +++++++++++++++++++++++++++++++
>>   drivers/gpu/drm/exynos/exynos_drm_ipp.h |  266 ++++
>>   include/uapi/drm/exynos_drm.h           |  190 +++
>>   7 files changed, 2553 insertions(+), 0 deletions(-)
>>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.c
>>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.h
>>
>> diff --git a/drivers/gpu/drm/exynos/Kconfig
>> b/drivers/gpu/drm/exynos/Kconfig
>> index 4ea8cdc..bcf1c9d 100644
>> --- a/drivers/gpu/drm/exynos/Kconfig
>> +++ b/drivers/gpu/drm/exynos/Kconfig
>> @@ -45,3 +45,9 @@ config DRM_EXYNOS_G2D
>>   	depends on DRM_EXYNOS && !VIDEO_SAMSUNG_S5P_G2D
>>   	help
>>   	  Choose this option if you want to use Exynos G2D for DRM.
>> +
>> +config DRM_EXYNOS_IPP
>> +	bool "Exynos DRM IPP"
>> +	depends on DRM_EXYNOS
>> +	help
>> +	  Choose this option if you want to use IPP feature for DRM.
>> diff --git a/drivers/gpu/drm/exynos/Makefile
>> b/drivers/gpu/drm/exynos/Makefile
>> index 26813b8..6c536ce 100644
>> --- a/drivers/gpu/drm/exynos/Makefile
>> +++ b/drivers/gpu/drm/exynos/Makefile
>> @@ -16,5 +16,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI)	+=
>> exynos_hdmi.o exynos_mixer.o \
>>   					   exynos_drm_hdmi.o
>>   exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+= exynos_drm_vidi.o
>>   exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
>> +exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
>>
>>   obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> index 4a1168d..0eb8a97 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> @@ -40,6 +40,7 @@
>>   #include "exynos_drm_vidi.h"
>>   #include "exynos_drm_dmabuf.h"
>>   #include "exynos_drm_g2d.h"
>> +#include "exynos_drm_ipp.h"
>>   #include "exynos_drm_iommu.h"
>>
>>   #define DRIVER_NAME	"exynos"
>> @@ -249,6 +250,14 @@ static struct drm_ioctl_desc exynos_ioctls[] = {
>>   			exynos_g2d_set_cmdlist_ioctl, DRM_UNLOCKED |
> DRM_AUTH),
>>   	DRM_IOCTL_DEF_DRV(EXYNOS_G2D_EXEC,
>>   			exynos_g2d_exec_ioctl, DRM_UNLOCKED | DRM_AUTH),
>> +	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_PROPERTY,
>> +			exynos_drm_ipp_get_property, DRM_UNLOCKED |
> DRM_AUTH),
>> +	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_SET_PROPERTY,
>> +			exynos_drm_ipp_set_property, DRM_UNLOCKED |
> DRM_AUTH),
>> +	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_QUEUE_BUF,
>> +			exynos_drm_ipp_queue_buf, DRM_UNLOCKED | DRM_AUTH),
>> +	DRM_IOCTL_DEF_DRV(EXYNOS_IPP_CMD_CTRL,
>> +			exynos_drm_ipp_cmd_ctrl, DRM_UNLOCKED | DRM_AUTH),
>>   };
>>
>>   static const struct file_operations exynos_drm_driver_fops = {
>> @@ -363,6 +372,12 @@ static int __init exynos_drm_init(void)
>>   		goto out_g2d;
>>   #endif
>>
>> +#ifdef CONFIG_DRM_EXYNOS_IPP
>> +	ret = platform_driver_register(&ipp_driver);
>> +	if (ret < 0)
>> +		goto out_ipp;
>> +#endif
>> +
>>   	ret = platform_driver_register(&exynos_drm_platform_driver);
>>   	if (ret < 0)
>>   		goto out_drm;
>> @@ -380,6 +395,11 @@ out:
>>   	platform_driver_unregister(&exynos_drm_platform_driver);
>>
>>   out_drm:
>> +#ifdef CONFIG_DRM_EXYNOS_IPP
>> +	platform_driver_unregister(&ipp_driver);
>> +out_ipp:
>> +#endif
>> +
>>   #ifdef CONFIG_DRM_EXYNOS_G2D
>>   	platform_driver_unregister(&g2d_driver);
>>   out_g2d:
>> @@ -416,6 +436,10 @@ static void __exit exynos_drm_exit(void)
>>
>>   	platform_driver_unregister(&exynos_drm_platform_driver);
>>
>> +#ifdef CONFIG_DRM_EXYNOS_IPP
>> +	platform_driver_unregister(&ipp_driver);
>> +#endif
>> +
>>   #ifdef CONFIG_DRM_EXYNOS_G2D
>>   	platform_driver_unregister(&g2d_driver);
>>   #endif
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> index a9db025..a365788 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> @@ -235,8 +235,14 @@ struct exynos_drm_g2d_private {
>>   	unsigned int		gem_nr;
>>   };
>>
>> +struct exynos_drm_ipp_private {
>> +	struct device	*dev;
>> +	struct list_head	event_list;
>> +};
>> +
>>   struct drm_exynos_file_private {
>>   	struct exynos_drm_g2d_private	*g2d_priv;
>> +	struct exynos_drm_ipp_private	*ipp_priv;
>>   };
>>
>>   /*
>> @@ -346,4 +352,5 @@ extern struct platform_driver mixer_driver;
>>   extern struct platform_driver exynos_drm_common_hdmi_driver;
>>   extern struct platform_driver vidi_driver;
>>   extern struct platform_driver g2d_driver;
>> +extern struct platform_driver ipp_driver;
>>   #endif
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c
>> b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
>> new file mode 100644
>> index 0000000..eb12cb5
>> --- /dev/null
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c
>> @@ -0,0 +1,2059 @@
>> +/*
>> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
>> + * Authors:
>> + *	Eunchul Kim <chulspro.kim@samsung.com>
>> + *	Jinyoung Jeon <jy0.jeon@samsung.com>
>> + *	Sangmin Lee <lsmin.lee@samsung.com>
>> + *
>> + * This program is free software; you can redistribute  it and/or modify
>> it
>> + * under  the terms of  the GNU General  Public License as published by
>> the
>> + * Free Software Foundation;  either version 2 of the  License, or (at
>> your
>> + * option) any later version.
>> + *
>> + */
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/clk.h>
>> +#include <linux/pm_runtime.h>
>> +#include <plat/map-base.h>
>> +
>> +#include <drm/drmP.h>
>> +#include <drm/exynos_drm.h>
>> +#include "exynos_drm_drv.h"
>> +#include "exynos_drm_gem.h"
>> +#include "exynos_drm_ipp.h"
>> +
>> +/*
>> + * IPP is stand for Image Post Processing and
>> + * supports image scaler/rotator and input/output DMA operations.
>> + * using FIMC, GSC, Rotator, so on.
>> + * IPP is integration device driver of same attribute h/w
>> + */
>> +
>> +#define get_ipp_context(dev)
>> 	platform_get_drvdata(to_platform_device(dev))
>> +#define ipp_is_m2m_cmd(c)	(c == IPP_CMD_M2M)
>> +
>> +/*
>> + * A structure of event.
>> + *
>> + * @base: base of event.
>> + * @event: ipp event.
>> + */
>> +struct drm_exynos_ipp_send_event {
>> +	struct drm_pending_event	base;
>> +	struct drm_exynos_ipp_event	event;
>> +};
>> +
>> +/*
>> + * A structure of memory node.
>> + *
>> + * @list: list head to memory queue information.
>> + * @ops_id: id of operations.
>> + * @prop_id: id of property.
>> + * @buf_id: id of buffer.
>> + * @buf_info: gem objects and dma address, size.
>> + * @filp: a pointer to drm_file.
>> + */
>> +struct drm_exynos_ipp_mem_node {
>> +	struct list_head	list;
>> +	enum drm_exynos_ops_id	ops_id;
>> +	u32	prop_id;
>> +	u32	buf_id;
>> +	struct drm_exynos_ipp_buf_info	buf_info;
>> +	struct drm_file		*filp;
>> +};
>> +
>> +/*
>> + * A structure of ipp context.
>> + *
>> + * @subdrv: prepare initialization using subdrv.
>> + * @ipp_lock: lock for synchronization of access to ipp_idr.
>> + * @prop_lock: lock for synchronization of access to prop_idr.
>> + * @ipp_idr: ipp driver idr.
>> + * @prop_idr: property idr.
>> + * @event_workq: event work queue.
>> + * @cmd_workq: command work queue.
>> + */
>> +struct ipp_context {
>> +	struct exynos_drm_subdrv	subdrv;
>> +	struct mutex	ipp_lock;
>> +	struct mutex	prop_lock;
>> +	struct idr	ipp_idr;
>> +	struct idr	prop_idr;
>> +	struct workqueue_struct	*event_workq;
>> +	struct workqueue_struct	*cmd_workq;
>> +};
>> +
>> +static LIST_HEAD(exynos_drm_ippdrv_list);
>> +static DEFINE_MUTEX(exynos_drm_ippdrv_lock);
>> +static BLOCKING_NOTIFIER_HEAD(exynos_drm_ippnb_list);
>> +
>> +int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv *ippdrv)
>> +{
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (!ippdrv)
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&exynos_drm_ippdrv_lock);
>> +	list_add_tail(&ippdrv->drv_list, &exynos_drm_ippdrv_list);
>> +	mutex_unlock(&exynos_drm_ippdrv_lock);
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(exynos_drm_ippdrv_register);
>> +
>> +int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv *ippdrv)
>> +{
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (!ippdrv)
>> +		return -EINVAL;
>> +
>> +	mutex_lock(&exynos_drm_ippdrv_lock);
>> +	list_del(&ippdrv->drv_list);
>> +	mutex_unlock(&exynos_drm_ippdrv_lock);
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(exynos_drm_ippdrv_unregister);
>> +
>> +static int ipp_create_id(struct idr *id_idr, struct mutex *lock, void
>> *obj,
>> +		u32 *idp)
>> +{
>> +	int ret;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +again:
>> +	/* ensure there is space available to allocate a handle */
>> +	if (idr_pre_get(id_idr, GFP_KERNEL) == 0) {
>> +		DRM_ERROR("failed to get idr.\n");
>> +		return -ENOMEM;
>> +	}
>> +
>> +	/* do the allocation under our mutexlock */
>> +	mutex_lock(lock);
>> +	ret = idr_get_new_above(id_idr, obj, 1, (int *)idp);
>> +	mutex_unlock(lock);
>> +	if (ret == -EAGAIN)
>> +		goto again;
>> +
>> +	return ret;
>> +}
>> +
>> +static void *ipp_find_obj(struct idr *id_idr, struct mutex *lock, u32 id)
>> +{
>> +	void *obj;
>> +
>> +	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, id);
>> +
>> +	mutex_lock(lock);
>> +
>> +	/* find object using handle */
>> +	obj = idr_find(id_idr, id);
>> +	if (!obj) {
>> +		DRM_ERROR("failed to find object.\n");
>> +		mutex_unlock(lock);
>> +		return ERR_PTR(-ENODEV);
>> +	}
>> +
>> +	mutex_unlock(lock);
>> +
>> +	return obj;
>> +}
>> +
>> +static inline bool ipp_check_dedicated(struct exynos_drm_ippdrv *ippdrv,
>> +		enum drm_exynos_ipp_cmd	cmd)
>> +{
>> +	/*
>> +	 * check dedicated flag and WB, OUTPUT operation with
>> +	 * power on state.
>> +	 */
>> +	if (ippdrv->dedicated || (!ipp_is_m2m_cmd(cmd) &&
>> +	    !pm_runtime_suspended(ippdrv->dev)))
>> +		return true;
>> +
>> +	return false;
>> +}
>> +
>> +static struct exynos_drm_ippdrv *ipp_find_driver(struct ipp_context *ctx,
>> +		struct drm_exynos_ipp_property *property)
>> +{
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	u32 ipp_id = property->ipp_id;
>> +
>> +	DRM_DEBUG_KMS("%s:ipp_id[%d]\n", __func__, ipp_id);
>> +
>> +	if (ipp_id) {
>> +		/* find ipp driver using idr */
>> +		ippdrv = ipp_find_obj(&ctx->ipp_idr, &ctx->ipp_lock,
>> +			ipp_id);
>> +		if (IS_ERR_OR_NULL(ippdrv)) {
>> +			DRM_ERROR("not found ipp%d driver.\n", ipp_id);
>> +			goto err_null;
>
> Just return ippdrv;

- done.

>
>> +		}
>> +
>> +		/*
>> +		 * WB, OUTPUT opertion not supported multi-operation.
>> +		 * so, make dedicated state at set property ioctl.
>> +		 * when ipp driver finished operations, clear dedicated
> flags.
>> +		 */
>> +		if (ipp_check_dedicated(ippdrv, property->cmd)) {
>> +			DRM_ERROR("already used choose device.\n");
>> +			goto err_null;
>
> Just return proper error;

- done ERR_PTR(-EBUSY);

>
>> +		}
>> +
>> +		/*
>> +		 * This is necessary to find correct device in ipp drivers.
>> +		 * ipp drivers have different abilities,
>> +		 * so need to check property.
>> +		 */
>> +		if (ippdrv->check_property &&
>> +		    ippdrv->check_property(ippdrv->dev, property)) {
>> +			DRM_ERROR("not support property.\n");
>> +			goto err_null;
>
> Just return proper error;

- done ERR_PTR(-EINVAL);

>
>> +		}
>> +
>> +		return ippdrv;
>> +	} else {
>> +		/*
>> +		 * This case is search all ipp driver for finding.
>> +		 * user application don't set ipp_id in this case,
>> +		 * so ipp subsystem search correct driver in driver list.
>> +		 */
>> +		list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list,
>> drv_list) {
>> +			if (ipp_check_dedicated(ippdrv, property->cmd)) {
>> +				DRM_DEBUG_KMS("%s:used device.\n",
> __func__);
>> +				continue;
>> +			}
>> +
>> +			if (ippdrv->check_property &&
>> +			    ippdrv->check_property(ippdrv->dev, property)) {
>> +				DRM_DEBUG_KMS("%s:not support property.\n",
>> +					__func__);
>> +				continue;
>> +			}
>> +
>> +			return ippdrv;
>> +		}
>> +
>> +		DRM_ERROR("not support ipp driver operations.\n");
>> +	}
>> +
>> +	return ERR_PTR(-ENODEV);
>> +
>> +err_null:
>> +	return NULL;
>
> And remove the above codes.

- removed.

>
>> +}
>> +
>> +static struct exynos_drm_ippdrv *ipp_find_drv_by_handle(u32 prop_id)
>> +{
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	struct drm_exynos_ipp_cmd_node *c_node;
>> +	int count = 0;
>> +
>> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, prop_id);
>> +
>> +	if (list_empty(&exynos_drm_ippdrv_list)) {
>> +		DRM_DEBUG_KMS("%s:ippdrv_list is empty.\n", __func__);
>> +		return ERR_PTR(-ENODEV);
>> +	}
>> +
>> +	/*
>> +	 * This case is search ipp driver by prop_id handle.
>> +	 * sometimes, ipp subsystem find driver by prop_id.
>> +	 * e.g PAUSE state, queue buf, command contro.
>> +	 */
>> +	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
>> +		DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]\n", __func__,
>> +			count++, (int)ippdrv);
>> +
>> +		if (!list_empty(&ippdrv->cmd_list)) {
>> +			list_for_each_entry(c_node, &ippdrv->cmd_list, list)
>> +				if (c_node->property.prop_id == prop_id)
>> +					return ippdrv;
>> +		}
>> +	}
>> +
>> +	return ERR_PTR(-ENODEV);
>> +}
>> +
>> +int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void *data,
>> +		struct drm_file *file)
>> +{
>> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
>> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
>> +	struct device *dev = priv->dev;
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +	struct drm_exynos_ipp_prop_list *prop_list = data;
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	int count = 0;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (!ctx) {
>> +		DRM_ERROR("invalid context.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (!prop_list) {
>> +		DRM_ERROR("invalid property parameter.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:ipp_id[%d]\n", __func__, prop_list->ipp_id);
>> +
>> +	if (!prop_list->ipp_id) {
>> +		list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list,
>> drv_list)
>> +			count++;
>> +		/*
>> +		 * Supports ippdrv list count for user application.
>> +		 * First step user application getting ippdrv count.
>> +		 * and second step getting ippdrv capability using ipp_id.
>> +		 */
>> +		prop_list->count = count;
>> +	} else {
>> +		/*
>> +		 * Getting ippdrv capability by ipp_id.
>> +		 * some deivce not supported wb, output interface.
>> +		 * so, user application detect correct ipp driver
>> +		 * using this ioctl.
>> +		 */
>> +		ippdrv = ipp_find_obj(&ctx->ipp_idr, &ctx->ipp_lock,
>> +						prop_list->ipp_id);
>> +		if (!ippdrv) {
>> +			DRM_ERROR("not found ipp%d driver.\n",
>> +					prop_list->ipp_id);
>> +			return -EINVAL;
>> +		}
>> +
>> +		prop_list = ippdrv->prop_list;
>> +	}
>> +
>> +	return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(exynos_drm_ipp_get_property);
>
> Should this function really be exported? Which external module calls this
> function? If not so, remove it.

- removed all EXPORT_SYMBOL_GPL

>
>> +
>> +static void ipp_print_property(struct drm_exynos_ipp_property *property,
>> +		int idx)
>> +{
>> +	struct drm_exynos_ipp_config *config = &property->config[idx];
>> +	struct drm_exynos_pos *pos = &config->pos;
>> +	struct drm_exynos_sz *sz = &config->sz;
>> +
>> +	DRM_DEBUG_KMS("%s:prop_id[%d]ops[%s]fmt[0x%x]\n",
>> +		__func__, property->prop_id, idx ? "dst" : "src", config-
>>> fmt);
>> +
>> +	DRM_DEBUG_KMS("%s:pos[%d %d %d %d]sz[%d %d]f[%d]r[%d]\n",
>> +		__func__, pos->x, pos->y, pos->w, pos->h,
>> +		sz->hsize, sz->vsize, config->flip, config->degree);
>> +}
>> +
>> +static int ipp_find_and_set_property(struct drm_exynos_ipp_property
>> *property)
>> +{
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	struct drm_exynos_ipp_cmd_node *c_node;
>> +	u32 prop_id = property->prop_id;
>> +
>> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, prop_id);
>> +
>> +	ippdrv = ipp_find_drv_by_handle(prop_id);
>> +	if (IS_ERR_OR_NULL(ippdrv)) {
>> +		DRM_ERROR("failed to get ipp driver.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	/*
>> +	 * Find command node using command list in ippdrv.
>> +	 * when we find this command no using prop_id.
>> +	 * return property information set in this command node.
>> +	 */
>> +	list_for_each_entry(c_node, &ippdrv->cmd_list, list) {
>> +		if ((c_node->property.prop_id == prop_id) &&
>> +		    (c_node->state == IPP_STATE_STOP)) {
>> +			DRM_DEBUG_KMS("%s:found cmd[%d]ippdrv[0x%x]\n",
>> +				__func__, property->cmd, (int)ippdrv);
>> +
>> +			c_node->property = *property;
>> +			return 0;
>> +		}
>> +	}
>> +
>> +	DRM_ERROR("failed to search property.\n");
>> +
>> +	return -EINVAL;
>> +}
>> +
>> +static struct drm_exynos_ipp_cmd_work *ipp_create_cmd_work(void)
>> +{
>> +	struct drm_exynos_ipp_cmd_work *cmd_work;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	cmd_work = kzalloc(sizeof(*cmd_work), GFP_KERNEL);
>> +	if (!cmd_work) {
>> +		DRM_ERROR("failed to alloc cmd_work.\n");
>> +		return ERR_PTR(-ENOMEM);
>> +	}
>> +
>> +	INIT_WORK((struct work_struct *)cmd_work, ipp_sched_cmd);
>> +
>> +	return cmd_work;
>> +}
>> +
>> +static struct drm_exynos_ipp_event_work *ipp_create_event_work(void)
>> +{
>> +	struct drm_exynos_ipp_event_work *event_work;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	event_work = kzalloc(sizeof(*event_work), GFP_KERNEL);
>> +	if (!event_work) {
>> +		DRM_ERROR("failed to alloc event_work.\n");
>> +		return ERR_PTR(-ENOMEM);
>> +	}
>> +
>> +	INIT_WORK((struct work_struct *)event_work, ipp_sched_event);
>> +
>> +	return event_work;
>> +}
>> +
>> +int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data,
>> +		struct drm_file *file)
>> +{
>> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
>> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
>> +	struct device *dev = priv->dev;
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +	struct drm_exynos_ipp_property *property = data;
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	struct drm_exynos_ipp_cmd_node *c_node;
>> +	int ret, i;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (!ctx) {
>> +		DRM_ERROR("invalid context.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (!property) {
>> +		DRM_ERROR("invalid property parameter.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	/*
>> +	 * This is log print for user application property.
>> +	 * user application set various property.
>> +	 */
>> +	for_each_ipp_ops(i)
>> +		ipp_print_property(property, i);
>> +
>> +	/*
>> +	 * set property ioctl generated new prop_id.
>> +	 * but in this case already asigned prop_id using old set property.
>> +	 * e.g PAUSE state. this case supports find current prop_id and use
>> it
>> +	 * instead of allocation.
>> +	 */
>> +	if (property->prop_id) {
>> +		DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property-
>>> prop_id);
>> +		return ipp_find_and_set_property(property);
>> +	}
>> +
>> +	/* find ipp driver using ipp id */
>> +	ippdrv = ipp_find_driver(ctx, property);
>> +	if (IS_ERR_OR_NULL(ippdrv)) {
>> +		DRM_ERROR("failed to get ipp driver.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	/* allocate command node */
>> +	c_node = kzalloc(sizeof(*c_node), GFP_KERNEL);
>> +	if (!c_node) {
>> +		DRM_ERROR("failed to allocate map node.\n");
>> +		return -ENOMEM;
>> +	}
>> +
>> +	/* create property id */
>> +	ret = ipp_create_id(&ctx->prop_idr, &ctx->prop_lock, c_node,
>> +		&property->prop_id);
>> +	if (ret) {
>> +		DRM_ERROR("failed to create id.\n");
>> +		goto err_clear;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:created prop_id[%d]cmd[%d]ippdrv[0x%x]\n",
>> +		__func__, property->prop_id, property->cmd, (int)ippdrv);
>> +
>> +	/* stored property information and ippdrv in private data */
>> +	c_node->priv = priv;
>> +	c_node->property = *property;
>> +	c_node->state = IPP_STATE_IDLE;
>> +
>> +	c_node->start_work = ipp_create_cmd_work();
>> +	if (IS_ERR_OR_NULL(c_node->start_work)) {
>> +		DRM_ERROR("failed to create start work.\n");
>> +		goto err_clear;
>> +	}
>> +
>> +	c_node->stop_work = ipp_create_cmd_work();
>> +	if (IS_ERR_OR_NULL(c_node->stop_work)) {
>> +		DRM_ERROR("failed to create stop work.\n");
>> +		goto err_free_start;
>> +	}
>> +
>> +	c_node->event_work = ipp_create_event_work();
>> +	if (IS_ERR_OR_NULL(c_node->event_work)) {
>> +		DRM_ERROR("failed to create event work.\n");
>> +		goto err_free_stop;
>> +	}
>> +
>> +	mutex_init(&c_node->cmd_lock);
>> +	mutex_init(&c_node->mem_lock);
>> +	mutex_init(&c_node->event_lock);
>> +
>> +	init_completion(&c_node->start_complete);
>> +	init_completion(&c_node->stop_complete);
>> +
>> +	for_each_ipp_ops(i)
>> +		INIT_LIST_HEAD(&c_node->mem_list[i]);
>> +
>> +	INIT_LIST_HEAD(&c_node->event_list);
>> +	list_splice_init(&priv->event_list, &c_node->event_list);
>> +	list_add_tail(&c_node->list, &ippdrv->cmd_list);
>> +
>> +	/* make dedicated state without m2m */
>> +	if (!ipp_is_m2m_cmd(property->cmd))
>> +		ippdrv->dedicated = true;
>> +
>> +	return 0;
>> +
>> +err_free_stop:
>> +	kfree(c_node->stop_work);
>> +err_free_start:
>> +	kfree(c_node->start_work);
>> +err_clear:
>> +	kfree(c_node);
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(exynos_drm_ipp_set_property);
>> +
>> +static void ipp_clean_cmd_node(struct drm_exynos_ipp_cmd_node *c_node)
>> +{
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	/* delete list */
>> +	list_del(&c_node->list);
>> +
>> +	/* destroy mutex */
>> +	mutex_destroy(&c_node->cmd_lock);
>> +	mutex_destroy(&c_node->mem_lock);
>> +	mutex_destroy(&c_node->event_lock);
>> +
>> +	/* free command node */
>> +	kfree(c_node->start_work);
>> +	kfree(c_node->stop_work);
>> +	kfree(c_node->event_work);
>> +	kfree(c_node);
>> +}
>> +
>> +static int ipp_check_mem_list(struct drm_exynos_ipp_cmd_node *c_node)
>> +{
>> +	struct drm_exynos_ipp_property *property = &c_node->property;
>> +	struct drm_exynos_ipp_mem_node *m_node;
>> +	struct list_head *head;
>> +	int ret, i, count[EXYNOS_DRM_OPS_MAX] = { 0, };
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	mutex_lock(&c_node->mem_lock);
>> +
>> +	for_each_ipp_ops(i) {
>> +		/* source/destination memory list */
>> +		head = &c_node->mem_list[i];
>> +
>> +		if (list_empty(head)) {
>> +			DRM_DEBUG_KMS("%s:%s memory empty.\n", __func__,
>> +				i ? "dst" : "src");
>> +			continue;
>> +		}
>> +
>> +		/* find memory node entry */
>> +		list_for_each_entry(m_node, head, list) {
>> +			DRM_DEBUG_KMS("%s:%s,count[%d]m_node[0x%x]\n",
>> __func__,
>> +				i ? "dst" : "src", count[i], (int)m_node);
>> +			count[i]++;
>> +		}
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:min[%d]max[%d]\n", __func__,
>> +		min(count[EXYNOS_DRM_OPS_SRC], count[EXYNOS_DRM_OPS_DST]),
>> +		max(count[EXYNOS_DRM_OPS_SRC], count[EXYNOS_DRM_OPS_DST]));
>> +
>> +	/*
>> +	 * M2M operations should be need paired memory address.
>> +	 * so, need to check minimum count about src, dst.
>> +	 * other case not use paired memory, so use maximum count
>> +	 */
>> +	if (ipp_is_m2m_cmd(property->cmd))
>> +		ret = min(count[EXYNOS_DRM_OPS_SRC],
>> +			count[EXYNOS_DRM_OPS_DST]);
>> +	else
>> +		ret = max(count[EXYNOS_DRM_OPS_SRC],
>> +			count[EXYNOS_DRM_OPS_DST]);
>> +
>> +	mutex_unlock(&c_node->mem_lock);
>> +
>> +	return ret;
>> +}
>> +
>> +static struct drm_exynos_ipp_mem_node
>> +		*ipp_find_mem_node(struct drm_exynos_ipp_cmd_node *c_node,
>> +		struct drm_exynos_ipp_queue_buf *qbuf)
>> +{
>> +	struct drm_exynos_ipp_mem_node *m_node;
>> +	struct list_head *head;
>> +	int count = 0;
>> +
>> +	DRM_DEBUG_KMS("%s:buf_id[%d]\n", __func__, qbuf->buf_id);
>> +
>> +	/* source/destination memory list */
>> +	head = &c_node->mem_list[qbuf->ops_id];
>> +
>> +	/* find memory node from memory list */
>> +	list_for_each_entry(m_node, head, list) {
>> +		DRM_DEBUG_KMS("%s:count[%d]m_node[0x%x]\n",
>> +			__func__, count++, (int)m_node);
>> +
>> +		/* compare buffer id */
>> +		if (m_node->buf_id == qbuf->buf_id)
>> +			return m_node;
>> +	}
>> +
>> +	return NULL;
>> +}
>> +
>> +static int ipp_set_mem_node(struct exynos_drm_ippdrv *ippdrv,
>> +		struct drm_exynos_ipp_cmd_node *c_node,
>> +		struct drm_exynos_ipp_mem_node *m_node)
>> +{
>> +	struct exynos_drm_ipp_ops *ops = NULL;
>> +	int ret = 0;
>> +
>> +	DRM_DEBUG_KMS("%s:node[0x%x]\n", __func__, (int)m_node);
>> +
>> +	if (!m_node) {
>> +		DRM_ERROR("invalid queue node.\n");
>> +		return -EFAULT;
>> +	}
>> +
>> +	mutex_lock(&c_node->mem_lock);
>> +
>> +	DRM_DEBUG_KMS("%s:ops_id[%d]\n", __func__, m_node->ops_id);
>> +
>> +	/* get operations callback */
>> +	ops = ippdrv->ops[m_node->ops_id];
>> +	if (!ops) {
>> +		DRM_ERROR("not support ops.\n");
>> +		ret = -EFAULT;
>> +		goto err_unlock;
>> +	}
>> +
>> +	/* set address and enable irq */
>> +	if (ops->set_addr) {
>> +		ret = ops->set_addr(ippdrv->dev, &m_node->buf_info,
>> +			m_node->buf_id, IPP_BUF_ENQUEUE);
>> +		if (ret) {
>> +			DRM_ERROR("failed to set addr.\n");
>> +			goto err_unlock;
>> +		}
>> +	}
>> +
>> +err_unlock:
>> +	mutex_unlock(&c_node->mem_lock);
>> +	return ret;
>> +}
>> +
>> +static struct drm_exynos_ipp_mem_node
>> +		*ipp_get_mem_node(struct drm_device *drm_dev,
>> +		struct drm_file *file,
>> +		struct drm_exynos_ipp_cmd_node *c_node,
>> +		struct drm_exynos_ipp_queue_buf *qbuf)
>> +{
>> +	struct drm_exynos_ipp_mem_node *m_node;
>> +	struct drm_exynos_ipp_buf_info buf_info;
>> +	void *addr;
>> +	int i;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	mutex_lock(&c_node->mem_lock);
>> +
>> +	m_node = kzalloc(sizeof(*m_node), GFP_KERNEL);
>> +	if (!m_node) {
>> +		DRM_ERROR("failed to allocate queue node.\n");
>> +		goto err_unlock;
>> +	}
>> +
>> +	/* clear base address for error handling */
>> +	memset(&buf_info, 0x0, sizeof(buf_info));
>> +
>> +	/* operations, buffer id */
>> +	m_node->ops_id = qbuf->ops_id;
>> +	m_node->prop_id = qbuf->prop_id;
>> +	m_node->buf_id = qbuf->buf_id;
>> +
>> +	DRM_DEBUG_KMS("%s:m_node[0x%x]ops_id[%d]\n", __func__,
>> +		(int)m_node, qbuf->ops_id);
>> +	DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]\n", __func__,
>> +		qbuf->prop_id, m_node->buf_id);
>> +
>> +	for_each_ipp_planar(i) {
>> +		DRM_DEBUG_KMS("%s:i[%d]handle[0x%x]\n", __func__,
>> +			i, qbuf->handle[i]);
>> +
>> +		/* get dma address by handle */
>> +		if (qbuf->handle[i] != 0) {
>
> if (qbuf->handle[i]) {

- done.

>
>> +			addr = exynos_drm_gem_get_dma_addr(drm_dev,
>> +					qbuf->handle[i], file);
>> +			if (!addr) {
>
> if (IS_ERR(addr))

- done.

>
>> +				DRM_ERROR("failed to get addr.\n");
>> +				goto err_clear;
>> +			}
>> +
>> +			buf_info.handles[i] = qbuf->handle[i];
>> +			buf_info.base[i] = *(dma_addr_t *) addr;
>> +			DRM_DEBUG_KMS("%s:i[%d]base[0x%x]hd[0x%x]\n",
>> +				__func__, i, buf_info.base[i],
>> +				(int)buf_info.handles[i]);
>> +		}
>> +	}
>> +
>> +	m_node->filp = file;
>> +	m_node->buf_info = buf_info;
>> +	list_add_tail(&m_node->list, &c_node->mem_list[qbuf->ops_id]);
>> +
>> +	mutex_unlock(&c_node->mem_lock);
>> +	return m_node;
>> +
>> +err_clear:
>> +	kfree(m_node);
>> +err_unlock:
>> +	mutex_unlock(&c_node->mem_lock);
>> +	return ERR_PTR(-EFAULT);
>> +}
>> +
>> +static int ipp_put_mem_node(struct drm_device *drm_dev,
>> +		struct drm_exynos_ipp_cmd_node *c_node,
>> +		struct drm_exynos_ipp_mem_node *m_node)
>> +{
>> +	int i;
>> +
>> +	DRM_DEBUG_KMS("%s:node[0x%x]\n", __func__, (int)m_node);
>> +
>> +	if (!m_node) {
>> +		DRM_ERROR("invalid dequeue node.\n");
>> +		return -EFAULT;
>> +	}
>> +
>> +	if (list_empty(&m_node->list)) {
>> +		DRM_ERROR("empty memory node.\n");
>> +		return -ENOMEM;
>> +	}
>> +
>> +	mutex_lock(&c_node->mem_lock);
>> +
>> +	DRM_DEBUG_KMS("%s:ops_id[%d]\n", __func__, m_node->ops_id);
>> +
>> +	/* put gem buffer */
>> +	for_each_ipp_planar(i) {
>> +		unsigned long handle = m_node->buf_info.handles[i];
>> +		if (handle)
>> +			exynos_drm_gem_put_dma_addr(drm_dev, handle,
>> +							m_node->filp);
>> +	}
>> +
>> +	/* delete list in queue */
>> +	list_del(&m_node->list);
>> +	kfree(m_node);
>> +
>> +	mutex_unlock(&c_node->mem_lock);
>> +
>> +	return 0;
>> +}
>> +
>> +static void ipp_free_event(struct drm_pending_event *event)
>
> Does this function need? This function just calls kfree. Just call kfree
> instead of wrapper.

- It is Kyungmin.Park review.

>
>> +{
>> +	kfree(event);
>> +}
>> +
>> +static int ipp_get_event(struct drm_device *drm_dev,
>> +		struct drm_file *file,
>> +		struct drm_exynos_ipp_cmd_node *c_node,
>> +		struct drm_exynos_ipp_queue_buf *qbuf)
>> +{
>> +	struct drm_exynos_ipp_send_event *e;
>> +	unsigned long flags;
>> +
>> +	DRM_DEBUG_KMS("%s:ops_id[%d]buf_id[%d]\n", __func__,
>> +		qbuf->ops_id, qbuf->buf_id);
>> +
>> +	e = kzalloc(sizeof(*e), GFP_KERNEL);
>> +
>> +	if (!e) {
>> +		DRM_ERROR("failed to allocate event.\n");
>> +		spin_lock_irqsave(&drm_dev->event_lock, flags);
>> +		file->event_space += sizeof(e->event);
>> +		spin_unlock_irqrestore(&drm_dev->event_lock, flags);
>> +		return -ENOMEM;
>> +	}
>> +
>> +	/* make event */
>> +	e->event.base.type = DRM_EXYNOS_IPP_EVENT;
>> +	e->event.base.length = sizeof(e->event);
>> +	e->event.user_data = qbuf->user_data;
>> +	e->event.prop_id = qbuf->prop_id;
>> +	e->event.buf_id[EXYNOS_DRM_OPS_DST] = qbuf->buf_id;
>> +	e->base.event = &e->event.base;
>> +	e->base.file_priv = file;
>> +	e->base.destroy = ipp_free_event;
>> +	list_add_tail(&e->base.link, &c_node->event_list);
>> +
>> +	return 0;
>> +}
>> +
>> +static void ipp_put_event(struct drm_exynos_ipp_cmd_node *c_node,
>> +		struct drm_exynos_ipp_queue_buf *qbuf)
>> +{
>> +	struct drm_exynos_ipp_send_event *e, *te;
>> +	int count = 0;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (list_empty(&c_node->event_list)) {
>> +		DRM_DEBUG_KMS("%s:event_list is empty.\n", __func__);
>> +		return;
>> +	}
>> +
>> +	list_for_each_entry_safe(e, te, &c_node->event_list, base.link) {
>> +		DRM_DEBUG_KMS("%s:count[%d]e[0x%x]\n",
>> +			__func__, count++, (int)e);
>> +
>> +		/*
>> +		 * quf == NULL condition means all event deletion.
>> +		 * stop operations want to delete all event list.
>> +		 * another case delete only same buf id.
>> +		 */
>> +		if (!qbuf) {
>> +			/* delete list */
>> +			list_del(&e->base.link);
>> +			kfree(e);
>> +		}
>> +
>> +		/* compare buffer id */
>> +		if (qbuf && (qbuf->buf_id ==
>> +		    e->event.buf_id[EXYNOS_DRM_OPS_DST])) {
>> +			/* delete list */
>> +			list_del(&e->base.link);
>> +			kfree(e);
>> +			return;
>> +		}
>> +	}
>> +}
>> +
>> +void ipp_handle_cmd_work(struct device *dev,
>> +		struct exynos_drm_ippdrv *ippdrv,
>> +		struct drm_exynos_ipp_cmd_work *cmd_work,
>> +		struct drm_exynos_ipp_cmd_node *c_node)
>> +{
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +
>> +	cmd_work->ippdrv = ippdrv;
>> +	cmd_work->c_node = c_node;
>> +	queue_work(ctx->cmd_workq, (struct work_struct *)cmd_work);
>> +}
>> +
>> +static int ipp_queue_buf_with_run(struct device *dev,
>> +		struct drm_exynos_ipp_cmd_node *c_node,
>> +		struct drm_exynos_ipp_mem_node *m_node,
>> +		struct drm_exynos_ipp_queue_buf *qbuf)
>> +{
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	struct drm_exynos_ipp_property *property;
>> +	struct exynos_drm_ipp_ops *ops;
>> +	int ret;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	ippdrv = ipp_find_drv_by_handle(qbuf->prop_id);
>> +	if (IS_ERR_OR_NULL(ippdrv)) {
>> +		DRM_ERROR("failed to get ipp driver.\n");
>> +		return -EFAULT;
>> +	}
>> +
>> +	ops = ippdrv->ops[qbuf->ops_id];
>> +	if (!ops) {
>> +		DRM_ERROR("failed to get ops.\n");
>> +		return -EFAULT;
>> +	}
>> +
>> +	property = &c_node->property;
>> +	if (!property) {
>
> Property couldn't be NULL. remove it.

- done.

>
>> +		DRM_ERROR("invalid property parameter.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (c_node->state != IPP_STATE_START) {
>> +		DRM_DEBUG_KMS("%s:bypass for invalid state.\n" , __func__);
>> +		return 0;
>
> No error?

- This is no error. command started yet. user application make play 
command control.

>
>> +	}
>> +
>> +	if (!ipp_check_mem_list(c_node)) {
>> +		DRM_DEBUG_KMS("%s:empty memory.\n", __func__);
>> +		return 0;
>
> No error?

- also, this case no error. not finished memory list.

>
>> +	}
>> +
>> +	/*
>> +	 * If set destination buffer and enabled clock,
>> +	 * then m2m operations need start operations at queue_buf
>> +	 */
>> +	if (ipp_is_m2m_cmd(property->cmd)) {
>> +		struct drm_exynos_ipp_cmd_work *cmd_work = c_node-
>>> start_work;
>> +
>> +		cmd_work->ctrl = IPP_CTRL_PLAY;
>> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
>> +	} else {
>> +		ret = ipp_set_mem_node(ippdrv, c_node, m_node);
>> +		if (ret) {
>> +			DRM_ERROR("failed to set m node.\n");
>> +			return ret;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static void ipp_clean_queue_buf(struct drm_device *drm_dev,
>> +		struct drm_exynos_ipp_cmd_node *c_node,
>> +		struct drm_exynos_ipp_queue_buf *qbuf)
>> +{
>> +	struct drm_exynos_ipp_mem_node *m_node, *tm_node;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (!list_empty(&c_node->mem_list[qbuf->ops_id])) {
>> +		/* delete list */
>> +		list_for_each_entry_safe(m_node, tm_node,
>> +			&c_node->mem_list[qbuf->ops_id], list) {
>> +			if (m_node->buf_id == qbuf->buf_id &&
>> +			    m_node->ops_id == qbuf->ops_id)
>> +				ipp_put_mem_node(drm_dev, c_node, m_node);
>> +		}
>> +	}
>> +}
>> +
>> +int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void *data,
>> +		struct drm_file *file)
>> +{
>> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
>> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
>> +	struct device *dev = priv->dev;
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +	struct drm_exynos_ipp_queue_buf *qbuf = data;
>> +	struct drm_exynos_ipp_cmd_node *c_node;
>> +	struct drm_exynos_ipp_mem_node *m_node;
>> +	int ret;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (!qbuf) {
>> +		DRM_ERROR("invalid buf parameter.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (qbuf->ops_id >= EXYNOS_DRM_OPS_MAX) {
>> +		DRM_ERROR("invalid ops parameter.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:prop_id[%d]ops_id[%s]buf_id[%d]buf_type[%d]\n",
>> +		__func__, qbuf->prop_id, qbuf->ops_id ? "dst" : "src",
>> +		qbuf->buf_id, qbuf->buf_type);
>> +
>> +	/* find command node */
>> +	c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
>> +		qbuf->prop_id);
>> +	if (!c_node) {
>> +		DRM_ERROR("failed to get command node.\n");
>> +		return -EFAULT;
>> +	}
>> +
>> +	/* buffer control */
>> +	switch (qbuf->buf_type) {
>> +	case IPP_BUF_ENQUEUE:
>> +		/* get memory node */
>> +		m_node = ipp_get_mem_node(drm_dev, file, c_node, qbuf);
>> +		if (IS_ERR_OR_NULL(m_node)) {
>
> This function never returns error. Use IS_ERR(m_node) instead.

- done.

>
>> +			DRM_ERROR("failed to get m_node.\n");
>> +			return -EINVAL;
>
> And return PTR_ERR(m_node);

- done.

>
>> +		}
>> +
>> +		/*
>> +		 * first step get event for destination buffer.
>> +		 * and second step when M2M case run with destination buffer
>> +		 * if needed.
>> +		 */
>> +		if (qbuf->ops_id == EXYNOS_DRM_OPS_DST) {
>> +			/* get event for destination buffer */
>> +			ret = ipp_get_event(drm_dev, file, c_node, qbuf);
>> +			if (ret) {
>> +				DRM_ERROR("failed to get event.\n");
>> +				goto err_clean_node;
>> +			}
>> +
>> +			/*
>> +			 * M2M case run play control for streaming feature.
>> +			 * other case set address and waiting.
>> +			 */
>> +			ret = ipp_queue_buf_with_run(dev, c_node, m_node,
>> qbuf);
>> +			if (ret) {
>> +				DRM_ERROR("failed to run command.\n");
>> +				goto err_clean_node;
>> +			}
>> +		}
>> +		break;
>> +	case IPP_BUF_DEQUEUE:
>> +		mutex_lock(&c_node->cmd_lock);
>> +
>> +		/* put event for destination buffer */
>> +		if (qbuf->ops_id == EXYNOS_DRM_OPS_DST)
>> +			ipp_put_event(c_node, qbuf);
>> +
>> +		ipp_clean_queue_buf(drm_dev, c_node, qbuf);
>> +
>> +		mutex_unlock(&c_node->cmd_lock);
>> +		break;
>> +	default:
>> +		DRM_ERROR("invalid buffer control.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	return 0;
>> +
>> +err_clean_node:
>> +	DRM_ERROR("clean memory nodes.\n");
>> +
>> +	ipp_clean_queue_buf(drm_dev, c_node, qbuf);
>> +	return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(exynos_drm_ipp_queue_buf);
>
> Remove EXPORT_SYMBOL_GPL.

- done.

>
>> +
>> +static bool exynos_drm_ipp_check_valid(struct device *dev,
>> +		enum drm_exynos_ipp_ctrl ctrl, enum drm_exynos_ipp_state
>> state)
>> +{
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (ctrl != IPP_CTRL_PLAY) {
>> +		if (pm_runtime_suspended(dev)) {
>> +			DRM_ERROR("pm:runtime_suspended.\n");
>> +			goto err_status;
>> +		}
>> +	}
>> +
>> +	switch (ctrl) {
>> +	case IPP_CTRL_PLAY:
>> +		if (state != IPP_STATE_IDLE)
>> +			goto err_status;
>> +		break;
>> +	case IPP_CTRL_STOP:
>> +		if (state == IPP_STATE_STOP)
>> +			goto err_status;
>> +		break;
>> +	case IPP_CTRL_PAUSE:
>> +		if (state != IPP_STATE_START)
>> +			goto err_status;
>> +		break;
>> +	case IPP_CTRL_RESUME:
>> +		if (state != IPP_STATE_STOP)
>> +			goto err_status;
>> +		break;
>> +	default:
>> +		DRM_ERROR("invalid state.\n");
>> +		goto err_status;
>> +		break;
>> +	}
>> +
>> +	return true;
>> +
>> +err_status:
>> +	DRM_ERROR("invalid status:ctrl[%d]state[%d]\n", ctrl, state);
>> +	return false;
>> +}
>> +
>> +int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void *data,
>> +		struct drm_file *file)
>> +{
>> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
>> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
>> +	struct exynos_drm_ippdrv *ippdrv = NULL;
>> +	struct device *dev = priv->dev;
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +	struct drm_exynos_ipp_cmd_ctrl *cmd_ctrl = data;
>> +	struct drm_exynos_ipp_cmd_work *cmd_work;
>> +	struct drm_exynos_ipp_cmd_node *c_node;
>> +	int ret = 0;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (!ctx) {
>> +		DRM_ERROR("invalid context.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (!cmd_ctrl) {
>> +		DRM_ERROR("invalid control parameter.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:ctrl[%d]prop_id[%d]\n", __func__,
>> +		cmd_ctrl->ctrl, cmd_ctrl->prop_id);
>> +
>> +	ippdrv = ipp_find_drv_by_handle(cmd_ctrl->prop_id);
>> +	if (IS_ERR_OR_NULL(ippdrv)) {
>
> Never return NULL. just use IS_ERR(ippdrv)

- done.

>
>> +		DRM_ERROR("failed to get ipp driver.\n");
>> +		return -EINVAL;
>
> And return PTR_ERR(ippdrv);

- done.

>
>> +	}
>> +
>> +	c_node = ipp_find_obj(&ctx->prop_idr, &ctx->prop_lock,
>> +		cmd_ctrl->prop_id);
>> +	if (!c_node) {
>> +		DRM_ERROR("invalid command node list.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (!exynos_drm_ipp_check_valid(ippdrv->dev, cmd_ctrl->ctrl,
>> +	    c_node->state)) {
>> +		DRM_ERROR("invalid state.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	switch (cmd_ctrl->ctrl) {
>> +	case IPP_CTRL_PLAY:
>> +		if (pm_runtime_suspended(ippdrv->dev))
>> +			pm_runtime_get_sync(ippdrv->dev);
>> +		c_node->state = IPP_STATE_START;
>> +
>> +		cmd_work = c_node->start_work;
>> +		cmd_work->ctrl = cmd_ctrl->ctrl;
>> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
>> +		c_node->state = IPP_STATE_START;
>> +		break;
>> +	case IPP_CTRL_STOP:
>> +		cmd_work = c_node->stop_work;
>> +		cmd_work->ctrl = cmd_ctrl->ctrl;
>> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
>> +
>> +		if (!wait_for_completion_timeout(&c_node->stop_complete,
>> +		    msecs_to_jiffies(300))) {
>> +			DRM_ERROR("timeout stop:prop_id[%d]\n",
>> +				c_node->property.prop_id);
>> +		}
>> +
>> +		c_node->state = IPP_STATE_STOP;
>> +		ippdrv->dedicated = false;
>> +		ipp_clean_cmd_node(c_node);
>> +
>> +		if (list_empty(&ippdrv->cmd_list))
>> +			pm_runtime_put_sync(ippdrv->dev);
>> +		break;
>> +	case IPP_CTRL_PAUSE:
>> +		cmd_work = c_node->stop_work;
>> +		cmd_work->ctrl = cmd_ctrl->ctrl;
>> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
>> +
>> +		if (!wait_for_completion_timeout(&c_node->stop_complete,
>> +		    msecs_to_jiffies(200))) {
>> +			DRM_ERROR("timeout stop:prop_id[%d]\n",
>> +				c_node->property.prop_id);
>> +		}
>> +
>> +		c_node->state = IPP_STATE_STOP;
>> +		break;
>> +	case IPP_CTRL_RESUME:
>> +		c_node->state = IPP_STATE_START;
>> +		cmd_work = c_node->start_work;
>> +		cmd_work->ctrl = cmd_ctrl->ctrl;
>> +		ipp_handle_cmd_work(dev, ippdrv, cmd_work, c_node);
>> +		break;
>> +	default:
>> +		/* ToDo: expand ctrl operation */
>> +		DRM_ERROR("could not support this state currently.\n");
>> +		goto err_clear;
>
> Just return error;

- added return -EINVAL;

>
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:done ctrl[%d]prop_id[%d]\n", __func__,
>> +		cmd_ctrl->ctrl, cmd_ctrl->prop_id);
>> +
>> +	return 0;
>> +
>> +err_clear:
>> +	return ret;
>
> And remove the above label.

- done.

>
>> +}
>> +EXPORT_SYMBOL_GPL(exynos_drm_ipp_cmd_ctrl);
>
> Remove it.

- done.

>
>> +
>> +int exynos_drm_ippnb_register(struct notifier_block *nb)
>> +{
>> +	return blocking_notifier_chain_register(
>> +			&exynos_drm_ippnb_list, nb);
>> +}
>> +EXPORT_SYMBOL_GPL(exynos_drm_ippnb_register);
>
> Remove it.

- done.

>
>> +
>> +int exynos_drm_ippnb_unregister(struct notifier_block *nb)
>> +{
>> +	return blocking_notifier_chain_unregister(
>> +			&exynos_drm_ippnb_list, nb);
>> +}
>> +EXPORT_SYMBOL_GPL(exynos_drm_ippnb_unregister);
>
> Remove it.

- done.

>
>> +
>> +int exynos_drm_ippnb_send_event(unsigned long val, void *v)
>> +{
>> +	return blocking_notifier_call_chain(
>> +			&exynos_drm_ippnb_list, val, v);
>> +}
>> +EXPORT_SYMBOL_GPL(exynos_drm_ippnb_send_event);
>
> Remove it.

- done.

>
>> +
>> +static int ipp_set_property(struct exynos_drm_ippdrv *ippdrv,
>> +		struct drm_exynos_ipp_property *property)
>> +{
>> +	struct exynos_drm_ipp_ops *ops = NULL;
>> +	int ret, i, swap = 0;
>> +
>> +	if (!property) {
>> +		DRM_ERROR("invalid property parameter.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
>> +
>> +	/* reset h/w block */
>> +	if (ippdrv->reset &&
>> +	    ippdrv->reset(ippdrv->dev)) {
>> +		DRM_ERROR("failed to reset.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	/* set source,destination operations */
>> +	for_each_ipp_ops(i) {
>> +		/* ToDo: integrate property and config */
>> +		struct drm_exynos_ipp_config *config =
>> +			&property->config[i];
>> +
>> +		ops = ippdrv->ops[i];
>> +		if (!ops || !config) {
>> +			DRM_ERROR("not support ops and config.\n");
>> +			return -EINVAL;
>> +		}
>> +
>> +		/* set format */
>> +		if (ops->set_fmt) {
>> +			ret = ops->set_fmt(ippdrv->dev, config->fmt);
>> +			if (ret) {
>> +				DRM_ERROR("not support format.\n");
>> +				return ret;
>> +			}
>> +		}
>> +
>> +		/* set transform for rotation, flip */
>> +		if (ops->set_transf) {
>> +			swap = ops->set_transf(ippdrv->dev, config->degree,
>> +				config->flip);
>> +			if (swap < 0) {
>> +				DRM_ERROR("not support tranf.\n");
>> +				return -EINVAL;
>> +			}
>> +		}
>> +
>> +		/* set size */
>> +		if (ops->set_size) {
>> +			ret = ops->set_size(ippdrv->dev, swap, &config->pos,
>> +				&config->sz);
>> +			if (ret) {
>> +				DRM_ERROR("not support size.\n");
>> +				return ret;
>> +			}
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static int ipp_start_property(struct exynos_drm_ippdrv *ippdrv,
>> +		struct drm_exynos_ipp_cmd_node *c_node)
>> +{
>> +	struct drm_exynos_ipp_mem_node *m_node;
>> +	struct drm_exynos_ipp_property *property = &c_node->property;
>> +	struct list_head *head;
>> +	int ret, i;
>> +
>> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
>> +
>> +	/* store command info in ippdrv */
>> +	ippdrv->cmd = c_node;
>> +
>> +	if (!ipp_check_mem_list(c_node)) {
>> +		DRM_DEBUG_KMS("%s:empty memory.\n", __func__);
>> +		return -ENOMEM;
>> +	}
>> +
>> +	/* set current property in ippdrv */
>> +	ret = ipp_set_property(ippdrv, property);
>> +	if (ret) {
>> +		DRM_ERROR("failed to set property.\n");
>> +		ippdrv->cmd = NULL;
>> +		return ret;
>> +	}
>> +
>> +	/* check command */
>> +	switch (property->cmd) {
>> +	case IPP_CMD_M2M:
>> +		for_each_ipp_ops(i) {
>> +			/* source/destination memory list */
>> +			head = &c_node->mem_list[i];
>> +
>> +			m_node = list_first_entry(head,
>> +				struct drm_exynos_ipp_mem_node, list);
>> +			if (!m_node) {
>> +				DRM_ERROR("failed to get node.\n");
>> +				ret = -EFAULT;
>> +				return ret;
>> +			}
>> +
>> +			DRM_DEBUG_KMS("%s:m_node[0x%x]\n",
>> +				__func__, (int)m_node);
>> +
>> +			ret = ipp_set_mem_node(ippdrv, c_node, m_node);
>> +			if (ret) {
>> +				DRM_ERROR("failed to set m node.\n");
>> +				return ret;
>> +			}
>> +		}
>> +		break;
>> +	case IPP_CMD_WB:
>> +		/* destination memory list */
>> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_DST];
>> +
>> +		list_for_each_entry(m_node, head, list) {
>> +			ret = ipp_set_mem_node(ippdrv, c_node, m_node);
>> +			if (ret) {
>> +				DRM_ERROR("failed to set m node.\n");
>> +				return ret;
>> +			}
>> +		}
>> +		break;
>> +	case IPP_CMD_OUTPUT:
>> +		/* source memory list */
>> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC];
>> +
>> +		list_for_each_entry(m_node, head, list) {
>> +			ret = ipp_set_mem_node(ippdrv, c_node, m_node);
>> +			if (ret) {
>> +				DRM_ERROR("failed to set m node.\n");
>> +				return ret;
>> +			}
>> +		}
>> +		break;
>> +	default:
>> +		DRM_ERROR("invalid operations.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, property->cmd);
>> +
>> +	/* start operations */
>> +	if (ippdrv->start) {
>> +		ret = ippdrv->start(ippdrv->dev, property->cmd);
>> +		if (ret) {
>> +			DRM_ERROR("failed to start ops.\n");
>> +			return ret;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static int ipp_stop_property(struct drm_device *drm_dev,
>> +		struct exynos_drm_ippdrv *ippdrv,
>> +		struct drm_exynos_ipp_cmd_node *c_node)
>> +{
>> +	struct drm_exynos_ipp_mem_node *m_node, *tm_node;
>> +	struct drm_exynos_ipp_property *property = &c_node->property;
>> +	struct list_head *head;
>> +	int ret = 0, i;
>> +
>> +	DRM_DEBUG_KMS("%s:prop_id[%d]\n", __func__, property->prop_id);
>> +
>> +	/* put event */
>> +	ipp_put_event(c_node, NULL);
>> +
>> +	/* check command */
>> +	switch (property->cmd) {
>> +	case IPP_CMD_M2M:
>> +		for_each_ipp_ops(i) {
>> +			/* source/destination memory list */
>> +			head = &c_node->mem_list[i];
>> +
>> +			if (list_empty(head)) {
>> +				DRM_DEBUG_KMS("%s:mem_list is empty.\n",
>> +					__func__);
>> +				break;
>> +			}
>> +
>> +			list_for_each_entry_safe(m_node, tm_node,
>> +				head, list) {
>> +				ret = ipp_put_mem_node(drm_dev, c_node,
>> +					m_node);
>> +				if (ret) {
>> +					DRM_ERROR("failed to put
> m_node.\n");
>> +					goto err_clear;
>> +				}
>> +			}
>> +		}
>> +		break;
>> +	case IPP_CMD_WB:
>> +		/* destination memory list */
>> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_DST];
>> +
>> +		if (list_empty(head)) {
>> +			DRM_DEBUG_KMS("%s:mem_list is empty.\n", __func__);
>> +			break;
>> +		}
>> +
>> +		list_for_each_entry_safe(m_node, tm_node, head, list) {
>> +			ret = ipp_put_mem_node(drm_dev, c_node, m_node);
>> +			if (ret) {
>> +				DRM_ERROR("failed to put m_node.\n");
>> +				goto err_clear;
>> +			}
>> +		}
>> +		break;
>> +	case IPP_CMD_OUTPUT:
>> +		/* source memory list */
>> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC];
>> +
>> +		if (list_empty(head)) {
>> +			DRM_DEBUG_KMS("%s:mem_list is empty.\n", __func__);
>> +			break;
>> +		}
>> +
>> +		list_for_each_entry_safe(m_node, tm_node, head, list) {
>> +			ret = ipp_put_mem_node(drm_dev, c_node, m_node);
>> +			if (ret) {
>> +				DRM_ERROR("failed to put m_node.\n");
>> +				goto err_clear;
>> +			}
>> +		}
>> +		break;
>> +	default:
>> +		DRM_ERROR("invalid operations.\n");
>> +		ret = -EINVAL;
>> +		goto err_clear;
>> +	}
>> +
>> +err_clear:
>> +	/* stop operations */
>> +	if (ippdrv->stop)
>> +		ippdrv->stop(ippdrv->dev, property->cmd);
>> +
>> +	return ret;
>> +}
>> +
>> +void ipp_sched_cmd(struct work_struct *work)
>> +{
>> +	struct drm_exynos_ipp_cmd_work *cmd_work =
>> +		(struct drm_exynos_ipp_cmd_work *)work;
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	struct drm_exynos_ipp_cmd_node *c_node;
>> +	struct drm_exynos_ipp_property *property;
>> +	int ret;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	ippdrv = cmd_work->ippdrv;
>> +	if (!ippdrv) {
>> +		DRM_ERROR("invalid ippdrv list.\n");
>> +		return;
>> +	}
>> +
>> +	c_node = cmd_work->c_node;
>> +	if (!c_node) {
>> +		DRM_ERROR("invalid command node list.\n");
>> +		return;
>> +	}
>> +
>> +	mutex_lock(&c_node->cmd_lock);
>> +
>> +	property = &c_node->property;
>> +	if (!property) {
>> +		DRM_ERROR("failed to get property:prop_id[%d]\n",
>> +			c_node->property.prop_id);
>> +		goto err_unlock;
>> +	}
>> +
>> +	switch (cmd_work->ctrl) {
>> +	case IPP_CTRL_PLAY:
>> +	case IPP_CTRL_RESUME:
>> +		ret = ipp_start_property(ippdrv, c_node);
>> +		if (ret) {
>> +			DRM_ERROR("failed to start property:prop_id[%d]\n",
>> +				c_node->property.prop_id);
>> +			goto err_unlock;
>> +		}
>> +
>> +		/*
>> +		 * M2M case supports wait_completion of transfer.
>> +		 * because M2M case supports single unit operation
>> +		 * with multiple queue.
>> +		 * M2M need to wait completion of data transfer.
>> +		 */
>> +		if (ipp_is_m2m_cmd(property->cmd)) {
>> +			if (!wait_for_completion_timeout
>> +			    (&c_node->start_complete,
> msecs_to_jiffies(200))) {
>> +				DRM_ERROR("timeout event:prop_id[%d]\n",
>> +					c_node->property.prop_id);
>> +				goto err_unlock;
>> +			}
>> +		}
>> +		break;
>> +	case IPP_CTRL_STOP:
>> +	case IPP_CTRL_PAUSE:
>> +		ret = ipp_stop_property(ippdrv->drm_dev, ippdrv,
>> +			c_node);
>> +		if (ret) {
>> +			DRM_ERROR("failed to stop property.\n");
>> +			goto err_unlock;
>> +		}
>> +
>> +		complete(&c_node->stop_complete);
>> +		break;
>> +	default:
>> +		DRM_ERROR("unknown control type\n");
>> +		break;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:ctrl[%d] done.\n", __func__, cmd_work->ctrl);
>> +
>> +err_unlock:
>> +	mutex_unlock(&c_node->cmd_lock);
>> +}
>> +
>> +static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv,
>> +		struct drm_exynos_ipp_cmd_node *c_node, int *buf_id)
>> +{
>> +	struct drm_device *drm_dev = ippdrv->drm_dev;
>> +	struct drm_exynos_ipp_property *property = &c_node->property;
>> +	struct drm_exynos_ipp_mem_node *m_node;
>> +	struct drm_exynos_ipp_queue_buf qbuf;
>> +	struct drm_exynos_ipp_send_event *e;
>> +	struct list_head *head;
>> +	struct timeval now;
>> +	unsigned long flags;
>> +	u32 tbuf_id[EXYNOS_DRM_OPS_MAX] = {0, };
>> +	int ret, i;
>> +
>> +	for_each_ipp_ops(i)
>> +		DRM_DEBUG_KMS("%s:%s buf_id[%d]\n", __func__,
>> +			i ? "dst" : "src", buf_id[i]);
>> +
>> +	if (!drm_dev) {
>> +		DRM_ERROR("failed to get drm_dev.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (!property) {
>> +		DRM_ERROR("failed to get property.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (list_empty(&c_node->event_list)) {
>> +		DRM_DEBUG_KMS("%s:event list is empty.\n", __func__);
>> +		return 0;
>> +	}
>> +
>> +	if (!ipp_check_mem_list(c_node)) {
>> +		DRM_DEBUG_KMS("%s:empty memory.\n", __func__);
>> +		return 0;
>> +	}
>> +
>> +	/* check command */
>> +	switch (property->cmd) {
>> +	case IPP_CMD_M2M:
>> +		for_each_ipp_ops(i) {
>> +			/* source/destination memory list */
>> +			head = &c_node->mem_list[i];
>> +
>> +			m_node = list_first_entry(head,
>> +				struct drm_exynos_ipp_mem_node, list);
>> +			if (!m_node) {
>> +				DRM_ERROR("empty memory node.\n");
>> +				return -ENOMEM;
>> +			}
>> +
>> +			tbuf_id[i] = m_node->buf_id;
>> +			DRM_DEBUG_KMS("%s:%s buf_id[%d]\n", __func__,
>> +				i ? "dst" : "src", tbuf_id[i]);
>> +
>> +			ret = ipp_put_mem_node(drm_dev, c_node, m_node);
>> +			if (ret)
>> +				DRM_ERROR("failed to put m_node.\n");
>> +		}
>> +		break;
>> +	case IPP_CMD_WB:
>> +		/* clear buf for finding */
>> +		memset(&qbuf, 0x0, sizeof(qbuf));
>> +		qbuf.ops_id = EXYNOS_DRM_OPS_DST;
>> +		qbuf.buf_id = buf_id[EXYNOS_DRM_OPS_DST];
>> +
>> +		/* get memory node entry */
>> +		m_node = ipp_find_mem_node(c_node, &qbuf);
>> +		if (!m_node) {
>> +			DRM_ERROR("empty memory node.\n");
>> +			return -ENOMEM;
>> +		}
>> +
>> +		tbuf_id[EXYNOS_DRM_OPS_DST] = m_node->buf_id;
>> +
>> +		ret = ipp_put_mem_node(drm_dev, c_node, m_node);
>> +		if (ret)
>> +			DRM_ERROR("failed to put m_node.\n");
>> +		break;
>> +	case IPP_CMD_OUTPUT:
>> +		/* source memory list */
>> +		head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC];
>> +
>> +		m_node = list_first_entry(head,
>> +			struct drm_exynos_ipp_mem_node, list);
>> +		if (!m_node) {
>> +			DRM_ERROR("empty memory node.\n");
>> +			return -ENOMEM;
>> +		}
>> +
>> +		tbuf_id[EXYNOS_DRM_OPS_SRC] = m_node->buf_id;
>> +
>> +		ret = ipp_put_mem_node(drm_dev, c_node, m_node);
>> +		if (ret)
>> +			DRM_ERROR("failed to put m_node.\n");
>> +		break;
>> +	default:
>> +		DRM_ERROR("invalid operations.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	/* ToDo: Fix buffer id */
>> +	if (tbuf_id[EXYNOS_DRM_OPS_DST] != buf_id[EXYNOS_DRM_OPS_DST])
>> +		DRM_ERROR("failed to match buf_id[%d %d]prop_id[%d]\n",
>> +			tbuf_id[1], buf_id[1], property->prop_id);
>> +
>> +	/*
>> +	 * command node have event list of destination buffer
>> +	 * If destination buffer enqueue to mem list,
>> +	 * then we make event and link to event list tail.
>> +	 * so, we get first event for first enqueued buffer.
>> +	 */
>> +	e = list_first_entry(&c_node->event_list,
>> +		struct drm_exynos_ipp_send_event, base.link);
>> +
>> +	if (!e) {
>> +		DRM_ERROR("empty event.\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	do_gettimeofday(&now);
>> +	DRM_DEBUG_KMS("%s:tv_sec[%ld]tv_usec[%ld]\n"
>> +		, __func__, now.tv_sec, now.tv_usec);
>> +	e->event.tv_sec = now.tv_sec;
>> +	e->event.tv_usec = now.tv_usec;
>> +	e->event.prop_id = property->prop_id;
>> +
>> +	/* set buffer id about source destination */
>> +	for_each_ipp_ops(i)
>> +		e->event.buf_id[i] = tbuf_id[i];
>> +
>> +	/* ToDo: compare index. If needed */
>> +
>> +	spin_lock_irqsave(&drm_dev->event_lock, flags);
>> +	list_move_tail(&e->base.link, &e->base.file_priv->event_list);
>> +	wake_up_interruptible(&e->base.file_priv->event_wait);
>> +	spin_unlock_irqrestore(&drm_dev->event_lock, flags);
>> +
>> +	DRM_DEBUG_KMS("%s:done cmd[%d]prop_id[%d]buf_id[%d]\n", __func__,
>> +		property->cmd, property->prop_id,
>> tbuf_id[EXYNOS_DRM_OPS_DST]);
>> +
>> +	return 0;
>> +}
>> +
>> +void ipp_sched_event(struct work_struct *work)
>> +{
>> +	struct drm_exynos_ipp_event_work *event_work =
>> +		(struct drm_exynos_ipp_event_work *)work;
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	struct drm_exynos_ipp_cmd_node *c_node;
>> +	int ret;
>> +
>> +	if (!event_work) {
>> +		DRM_ERROR("failed to get event_work.\n");
>> +		return;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:buf_id[%d]\n", __func__,
>> +		event_work->buf_id[EXYNOS_DRM_OPS_DST]);
>> +
>> +	ippdrv = event_work->ippdrv;
>> +	if (!ippdrv) {
>> +		DRM_ERROR("failed to get ipp driver.\n");
>> +		return;
>> +	}
>> +
>> +	c_node = ippdrv->cmd;
>> +	if (!c_node) {
>> +		DRM_ERROR("failed to get command node.\n");
>> +		return;
>> +	}
>> +
>> +	/*
>> +	 * IPP supports command thread, event thread synchronization.
>> +	 * If IPP close immediately from user land, then IPP make
>> +	 * synchronization with command thread, so make complete event.
>> +	 * or going out operations.
>> +	 */
>> +	if (c_node->state != IPP_STATE_START) {
>> +		DRM_DEBUG_KMS("%s:bypass state[%d]prop_id[%d]\n",
>> +			__func__, c_node->state, c_node->property.prop_id);
>> +		goto err_completion;
>> +	}
>> +
>> +	mutex_lock(&c_node->event_lock);
>> +
>> +	ret = ipp_send_event(ippdrv, c_node, event_work->buf_id);
>> +	if (ret) {
>> +		DRM_ERROR("failed to send event.\n");
>> +		goto err_completion;
>> +	}
>> +
>> +err_completion:
>> +	if (ipp_is_m2m_cmd(c_node->property.cmd))
>> +		complete(&c_node->start_complete);
>> +
>> +	mutex_unlock(&c_node->event_lock);
>> +}
>> +
>> +static int ipp_subdrv_probe(struct drm_device *drm_dev, struct device
>> *dev)
>> +{
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	int ret, count = 0;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	/* get ipp driver entry */
>> +	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
>> +		ippdrv->drm_dev = drm_dev;
>> +
>> +		ret = ipp_create_id(&ctx->ipp_idr, &ctx->ipp_lock, ippdrv,
>> +			&ippdrv->ipp_id);
>> +		if (ret) {
>> +			DRM_ERROR("failed to create id.\n");
>> +			goto err_idr;
>> +		}
>> +
>> +		DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]ipp_id[%d]\n",
>> __func__,
>> +			count++, (int)ippdrv, ippdrv->ipp_id);
>> +
>> +		if (ippdrv->ipp_id == 0) {
>> +			DRM_ERROR("failed to get ipp_id[%d]\n",
>> +				ippdrv->ipp_id);
>> +			goto err_idr;
>> +		}
>> +
>> +		/* store parent device for node */
>> +		ippdrv->parent_dev = dev;
>> +
>> +		/* store event work queue and handler */
>> +		ippdrv->event_workq = ctx->event_workq;
>> +		ippdrv->sched_event = ipp_sched_event;
>> +		INIT_LIST_HEAD(&ippdrv->cmd_list);
>> +	}
>> +
>> +	return 0;
>> +
>> +err_idr:
>> +	idr_remove_all(&ctx->ipp_idr);
>> +	idr_remove_all(&ctx->prop_idr);
>> +	idr_destroy(&ctx->ipp_idr);
>> +	idr_destroy(&ctx->prop_idr);
>> +	return ret;
>> +}
>> +
>> +static void ipp_subdrv_remove(struct drm_device *drm_dev, struct device
>> *dev)
>> +{
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	/* get ipp driver entry */
>> +	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
>> +		ippdrv->drm_dev = NULL;
>> +		exynos_drm_ippdrv_unregister(ippdrv);
>> +	}
>> +
>> +	/* ToDo: free notifier callback list if needed */
>> +}
>> +
>> +static int ipp_subdrv_open(struct drm_device *drm_dev, struct device
> *dev,
>> +		struct drm_file *file)
>> +{
>> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
>> +	struct exynos_drm_ipp_private *priv;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	/* ToDo: multi device open */
>> +
>> +	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
>> +	if (!priv) {
>> +		DRM_ERROR("failed to allocate priv.\n");
>> +		return -ENOMEM;
>> +	}
>> +	priv->dev = dev;
>> +	file_priv->ipp_priv = priv;
>> +
>> +	INIT_LIST_HEAD(&priv->event_list);
>> +
>> +	DRM_DEBUG_KMS("%s:done priv[0x%x]\n", __func__, (int)priv);
>> +
>> +	return 0;
>> +}
>> +
>> +static void ipp_subdrv_close(struct drm_device *drm_dev, struct device
>> *dev,
>> +		struct drm_file *file)
>> +{
>> +	struct drm_exynos_file_private *file_priv = file->driver_priv;
>> +	struct exynos_drm_ipp_private *priv = file_priv->ipp_priv;
>> +	struct exynos_drm_ippdrv *ippdrv = NULL;
>> +	struct drm_exynos_ipp_cmd_node *c_node, *tc_node;
>> +	int count = 0;
>> +
>> +	DRM_DEBUG_KMS("%s:for priv[0x%x]\n", __func__, (int)priv);
>> +
>> +	if (list_empty(&exynos_drm_ippdrv_list)) {
>> +		DRM_DEBUG_KMS("%s:ippdrv_list is empty.\n", __func__);
>> +		goto err_clear;
>> +	}
>> +
>> +	list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) {
>> +		if (list_empty(&ippdrv->cmd_list))
>> +			continue;
>> +
>> +		list_for_each_entry_safe(c_node, tc_node,
>> +			&ippdrv->cmd_list, list) {
>> +			DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]\n",
>> +				__func__, count++, (int)ippdrv);
>> +
>> +			if (c_node->priv == priv) {
>> +				/*
>> +				 * userland goto unnormal state. process
> killed.
>> +				 * and close the file.
>> +				 * so, IPP didn't called stop cmd ctrl.
>> +				 * so, we are make stop operation in this
> state.
>> +				 */
>> +				if (c_node->state == IPP_STATE_START) {
>> +					ipp_stop_property(drm_dev, ippdrv,
>> +						c_node);
>> +					c_node->state = IPP_STATE_STOP;
>> +				}
>> +
>> +				ippdrv->dedicated = false;
>> +				ipp_clean_cmd_node(c_node);
>> +				if (list_empty(&ippdrv->cmd_list))
>> +					pm_runtime_put_sync(ippdrv->dev);
>> +			}
>> +		}
>> +	}
>> +
>> +err_clear:
>> +	kfree(priv);
>> +	return;
>> +}
>> +
>> +static int __devinit ipp_probe(struct platform_device *pdev)
>> +{
>> +	struct device *dev = &pdev->dev;
>> +	struct ipp_context *ctx;
>> +	struct exynos_drm_subdrv *subdrv;
>> +	int ret;
>> +
>> +	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
>> +	if (!ctx)
>> +		return -ENOMEM;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	mutex_init(&ctx->ipp_lock);
>> +	mutex_init(&ctx->prop_lock);
>> +
>> +	idr_init(&ctx->ipp_idr);
>> +	idr_init(&ctx->prop_idr);
>> +
>> +	/*
>> +	 * create single thread for ipp event
>> +	 * IPP supports event thread for IPP drivers.
>> +	 * IPP driver send event_work to this thread.
>> +	 * and IPP event thread send event to user process.
>> +	 */
>> +	ctx->event_workq = create_singlethread_workqueue("ipp_event");
>> +	if (!ctx->event_workq) {
>> +		dev_err(dev, "failed to create event workqueue\n");
>> +		ret = -EINVAL;
>> +		goto err_clear;
>> +	}
>> +
>> +	/*
>> +	 * create single thread for ipp command
>> +	 * IPP supports command thread for user process.
>> +	 * user process make command node using set property ioctl.
>> +	 * and make start_work and send this work to command thread.
>> +	 * and then this command thread start property.
>> +	 */
>> +	ctx->cmd_workq = create_singlethread_workqueue("ipp_cmd");
>> +	if (!ctx->cmd_workq) {
>> +		dev_err(dev, "failed to create cmd workqueue\n");
>> +		ret = -EINVAL;
>> +		goto err_event_workq;
>> +	}
>> +
>> +	/* set sub driver informations */
>> +	subdrv = &ctx->subdrv;
>> +	subdrv->dev = dev;
>> +	subdrv->probe = ipp_subdrv_probe;
>> +	subdrv->remove = ipp_subdrv_remove;
>> +	subdrv->open = ipp_subdrv_open;
>> +	subdrv->close = ipp_subdrv_close;
>> +
>> +	platform_set_drvdata(pdev, ctx);
>> +
>> +	ret = exynos_drm_subdrv_register(subdrv);
>> +	if (ret < 0) {
>> +		DRM_ERROR("failed to register drm ipp device.\n");
>> +		goto err_cmd_workq;
>> +	}
>> +
>> +	dev_info(&pdev->dev, "drm ipp registered successfully.\n");
>> +
>> +	return 0;
>> +
>> +err_cmd_workq:
>> +	destroy_workqueue(ctx->cmd_workq);
>> +err_event_workq:
>> +	destroy_workqueue(ctx->event_workq);
>> +err_clear:
>> +	kfree(ctx);
>> +	return ret;
>> +}
>> +
>> +static int __devexit ipp_remove(struct platform_device *pdev)
>> +{
>> +	struct ipp_context *ctx = platform_get_drvdata(pdev);
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	/* unregister sub driver */
>> +	exynos_drm_subdrv_unregister(&ctx->subdrv);
>> +
>> +	/* remove,destroy ipp idr */
>> +	idr_remove_all(&ctx->ipp_idr);
>> +	idr_remove_all(&ctx->prop_idr);
>> +	idr_destroy(&ctx->ipp_idr);
>> +	idr_destroy(&ctx->prop_idr);
>> +
>> +	mutex_destroy(&ctx->ipp_lock);
>> +	mutex_destroy(&ctx->prop_lock);
>> +
>> +	/* destroy command, event work queue */
>> +	destroy_workqueue(ctx->cmd_workq);
>> +	destroy_workqueue(ctx->event_workq);
>> +
>> +	kfree(ctx);
>> +
>> +	return 0;
>> +}
>> +
>> +static int ipp_power_ctrl(struct ipp_context *ctx, bool enable)
>> +{
>> +	/* ToDo: Need to implement power and sysmmu ctrl. */
>> +	DRM_DEBUG_KMS("%s:enable[%d]\n", __func__, enable);
>> +
>> +	return 0;
>> +}
>> +
>> +#ifdef CONFIG_PM_SLEEP
>> +static int ipp_suspend(struct device *dev)
>> +{
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (pm_runtime_suspended(dev))
>> +		return 0;
>> +
>> +	return ipp_power_ctrl(ctx, false);
>> +}
>> +
>> +static int ipp_resume(struct device *dev)
>> +{
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (!pm_runtime_suspended(dev))
>> +		return ipp_power_ctrl(ctx, true);
>> +
>> +	return 0;
>> +}
>> +#endif
>> +
>> +#ifdef CONFIG_PM_RUNTIME
>> +static int ipp_runtime_suspend(struct device *dev)
>> +{
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	return ipp_power_ctrl(ctx, false);
>> +}
>> +
>> +static int ipp_runtime_resume(struct device *dev)
>> +{
>> +	struct ipp_context *ctx = get_ipp_context(dev);
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	return ipp_power_ctrl(ctx, true);
>> +}
>> +#endif
>> +
>> +static const struct dev_pm_ops ipp_pm_ops = {
>> +	SET_SYSTEM_SLEEP_PM_OPS(ipp_suspend, ipp_resume)
>> +	SET_RUNTIME_PM_OPS(ipp_runtime_suspend, ipp_runtime_resume, NULL)
>> +};
>> +
>> +struct platform_driver ipp_driver = {
>> +	.probe		= ipp_probe,
>> +	.remove		= __devexit_p(ipp_remove),
>> +	.driver		= {
>> +		.name	= "exynos-drm-ipp",
>> +		.owner	= THIS_MODULE,
>> +		.pm	= &ipp_pm_ops,
>> +	},
>> +};
>> +
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.h
>> b/drivers/gpu/drm/exynos/exynos_drm_ipp.h
>> new file mode 100644
>> index 0000000..baab1f0
>> --- /dev/null
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.h
>> @@ -0,0 +1,266 @@
>> +/*
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *
>> + * Authors:
>> + *	Eunchul Kim <chulspro.kim@samsung.com>
>> + *	Jinyoung Jeon <jy0.jeon@samsung.com>
>> + *	Sangmin Lee <lsmin.lee@samsung.com>
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining
>> a
>> + * copy of this software and associated documentation files (the
>> "Software"),
>> + * to deal in the Software without restriction, including without
>> limitation
>> + * the rights to use, copy, modify, merge, publish, distribute,
>> sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the
>> next
>> + * paragraph) shall be included in all copies or substantial portions of
>> the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>> EXPRESS OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
>> SHALL
>> + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES
>> OR
>> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
>> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
>> + * OTHER DEALINGS IN THE SOFTWARE.
>> + */
>> +
>> +#ifndef _EXYNOS_DRM_IPP_H_
>> +#define _EXYNOS_DRM_IPP_H_
>> +
>> +#define for_each_ipp_ops(pos)	\
>> +	for (pos = 0; pos < EXYNOS_DRM_OPS_MAX; pos++)
>> +#define for_each_ipp_planar(pos)	\
>> +	for (pos = 0; pos < EXYNOS_DRM_PLANAR_MAX; pos++)
>> +
>> +#define IPP_GET_LCD_WIDTH	_IOR('F', 302, int)
>> +#define IPP_GET_LCD_HEIGHT	_IOR('F', 303, int)
>> +#define IPP_SET_WRITEBACK	_IOW('F', 304, u32)
>> +
>> +/* definition of state */
>> +enum drm_exynos_ipp_state {
>> +	IPP_STATE_IDLE,
>> +	IPP_STATE_START,
>> +	IPP_STATE_STOP,
>> +};
>> +
>> +/*
>> + * A structure of command work information.
>> + * @work: work structure.
>> + * @ippdrv: current work ippdrv.
>> + * @c_node: command node information.
>> + * @ctrl: command control.
>> + */
>> +struct drm_exynos_ipp_cmd_work {
>> +	struct work_struct	work;
>> +	struct exynos_drm_ippdrv	*ippdrv;
>> +	struct drm_exynos_ipp_cmd_node *c_node;
>> +	enum drm_exynos_ipp_ctrl	ctrl;
>> +};
>> +
>> +/*
>> + * A structure of command node.
>> + *
>> + * @priv: IPP private infomation.
>> + * @list: list head to command queue information.
>> + * @event_list: list head of event.
>> + * @mem_list: list head to source,destination memory queue information.
>> + * @cmd_lock: lock for synchronization of access to ioctl.
>> + * @mem_lock: lock for synchronization of access to memory nodes.
>> + * @event_lock: lock for synchronization of access to scheduled event.
>> + * @start_complete: completion of start of command.
>> + * @stop_complete: completion of stop of command.
>> + * @property: property information.
>> + * @start_work: start command work structure.
>> + * @stop_work: stop command work structure.
>> + * @event_work: event work structure.
>> + * @state: state of command node.
>> + */
>> +struct drm_exynos_ipp_cmd_node {
>> +	struct exynos_drm_ipp_private *priv;
>> +	struct list_head	list;
>> +	struct list_head	event_list;
>> +	struct list_head	mem_list[EXYNOS_DRM_OPS_MAX];
>> +	struct mutex	cmd_lock;
>> +	struct mutex	mem_lock;
>> +	struct mutex	event_lock;
>> +	struct completion	start_complete;
>> +	struct completion	stop_complete;
>> +	struct drm_exynos_ipp_property	property;
>> +	struct drm_exynos_ipp_cmd_work *start_work;
>> +	struct drm_exynos_ipp_cmd_work *stop_work;
>> +	struct drm_exynos_ipp_event_work *event_work;
>> +	enum drm_exynos_ipp_state	state;
>> +};
>> +
>> +/*
>> + * A structure of buffer information.
>> + *
>> + * @gem_objs: Y, Cb, Cr each gem object.
>> + * @base: Y, Cb, Cr each planar address.
>> + */
>> +struct drm_exynos_ipp_buf_info {
>> +	unsigned long	handles[EXYNOS_DRM_PLANAR_MAX];
>> +	dma_addr_t	base[EXYNOS_DRM_PLANAR_MAX];
>> +};
>> +
>> +/*
>> + * A structure of wb setting infomation.
>> + *
>> + * @enable: enable flag for wb.
>> + * @refresh: HZ of the refresh rate.
>> + */
>> +struct drm_exynos_ipp_set_wb {
>> +	__u32	enable;
>> +	__u32	refresh;
>> +};
>> +
>> +/*
>> + * A structure of event work information.
>> + *
>> + * @work: work structure.
>> + * @ippdrv: current work ippdrv.
>> + * @buf_id: id of src, dst buffer.
>> + */
>> +struct drm_exynos_ipp_event_work {
>> +	struct work_struct	work;
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	u32	buf_id[EXYNOS_DRM_OPS_MAX];
>> +};
>> +
>> +/*
>> + * A structure of source,destination operations.
>> + *
>> + * @set_fmt: set format of image.
>> + * @set_transf: set transform(rotations, flip).
>> + * @set_size: set size of region.
>> + * @set_addr: set address for dma.
>> + */
>> +struct exynos_drm_ipp_ops {
>> +	int (*set_fmt)(struct device *dev, u32 fmt);
>> +	int (*set_transf)(struct device *dev,
>> +		enum drm_exynos_degree degree,
>> +		enum drm_exynos_flip flip);
>> +	int (*set_size)(struct device *dev, int swap,
>> +		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz);
>> +	int (*set_addr)(struct device *dev,
>> +			 struct drm_exynos_ipp_buf_info *buf_info, u32
> buf_id,
>> +		enum drm_exynos_ipp_buf_type buf_type);
>> +};
>> +
>> +/*
>> + * A structure of ipp driver.
>> + *
>> + * @drv_list: list head for registed sub driver information.
>> + * @parent_dev: parent device information.
>> + * @dev: platform device.
>> + * @drm_dev: drm device.
>> + * @ipp_id: id of ipp driver.
>> + * @dedicated: dedicated ipp device.
>> + * @ops: source, destination operations.
>> + * @event_workq: event work queue.
>> + * @cmd: current command information.
>> + * @cmd_list: list head for command information.
>> + * @prop_list: property informations of current ipp driver.
>> + * @check_property: check property about format, size, buffer.
>> + * @reset: reset ipp block.
>> + * @start: ipp each device start.
>> + * @stop: ipp each device stop.
>> + * @sched_event: work schedule handler.
>> + */
>> +struct exynos_drm_ippdrv {
>> +	struct list_head	drv_list;
>> +	struct device	*parent_dev;
>> +	struct device	*dev;
>> +	struct drm_device	*drm_dev;
>> +	u32	ipp_id;
>> +	bool	dedicated;
>> +	struct exynos_drm_ipp_ops	*ops[EXYNOS_DRM_OPS_MAX];
>> +	struct workqueue_struct	*event_workq;
>> +	struct drm_exynos_ipp_cmd_node *cmd;
>> +	struct list_head	cmd_list;
>> +	struct drm_exynos_ipp_prop_list *prop_list;
>> +
>> +	int (*check_property)(struct device *dev,
>> +		struct drm_exynos_ipp_property *property);
>> +	int (*reset)(struct device *dev);
>> +	int (*start)(struct device *dev, enum drm_exynos_ipp_cmd cmd);
>> +	void (*stop)(struct device *dev, enum drm_exynos_ipp_cmd cmd);
>> +	void (*sched_event)(struct work_struct *work);
>> +};
>> +
>> +#ifdef CONFIG_DRM_EXYNOS_IPP
>> +extern int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv *ippdrv);
>> +extern int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv
> *ippdrv);
>> +extern int exynos_drm_ipp_get_property(struct drm_device *drm_dev, void
>> *data,
>> +					 struct drm_file *file);
>> +extern int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void
>> *data,
>> +					 struct drm_file *file);
>> +extern int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void
>> *data,
>> +					 struct drm_file *file);
>> +extern int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void
> *data,
>> +					 struct drm_file *file);
>> +extern int exynos_drm_ippnb_register(struct notifier_block *nb);
>> +extern int exynos_drm_ippnb_unregister(struct notifier_block *nb);
>> +extern int exynos_drm_ippnb_send_event(unsigned long val, void *v);
>> +extern void ipp_sched_cmd(struct work_struct *work);
>> +extern void ipp_sched_event(struct work_struct *work);
>> +
>> +#else
>> +static inline int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv
>> *ippdrv)
>> +{
>> +	return -ENODEV;
>> +}
>> +
>> +static inline int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv
>> *ippdrv)
>> +{
>> +	return -ENODEV;
>> +}
>> +
>> +static inline int exynos_drm_ipp_get_property(struct drm_device *drm_dev,
>> +						void *data,
>> +						struct drm_file *file_priv)
>> +{
>> +	return -ENOTTY;
>> +}
>> +
>> +static inline int exynos_drm_ipp_set_property(struct drm_device *drm_dev,
>> +						void *data,
>> +						struct drm_file *file_priv)
>> +{
>> +	return -ENOTTY;
>> +}
>> +
>> +static inline int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev,
>> +						void *data,
>> +						struct drm_file *file)
>> +{
>> +	return -ENOTTY;
>> +}
>> +
>> +static inline int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev,
>> +						void *data,
>> +						struct drm_file *file)
>> +{
>> +	return -ENOTTY;
>> +}
>> +
>> +static inline int exynos_drm_ippnb_register(struct notifier_block *nb)
>> +{
>> +	return -ENODEV;
>> +}
>> +
>> +static inline int exynos_drm_ippnb_unregister(struct notifier_block *nb)
>> +{
>> +	return -ENODEV;
>> +}
>> +
>> +static inline int exynos_drm_ippnb_send_event(unsigned long val, void *v)
>> +{
>> +	return -ENOTTY;
>> +}
>> +#endif
>> +
>> +#endif /* _EXYNOS_DRM_IPP_H_ */
>> +
>> diff --git a/include/uapi/drm/exynos_drm.h b/include/uapi/drm/exynos_drm.h
>> index c0494d5..82772d7 100644
>> --- a/include/uapi/drm/exynos_drm.h
>> +++ b/include/uapi/drm/exynos_drm.h
>> @@ -154,6 +154,170 @@ struct drm_exynos_g2d_exec {
>>   	__u64					async;
>>   };
>>
>> +enum drm_exynos_ops_id {
>> +	EXYNOS_DRM_OPS_SRC,
>> +	EXYNOS_DRM_OPS_DST,
>> +	EXYNOS_DRM_OPS_MAX,
>> +};
>> +
>> +struct drm_exynos_sz {
>> +	__u32	hsize;
>> +	__u32	vsize;
>> +};
>> +
>> +struct drm_exynos_pos {
>> +	__u32	x;
>> +	__u32	y;
>> +	__u32	w;
>> +	__u32	h;
>> +};
>> +
>> +enum drm_exynos_flip {
>> +	EXYNOS_DRM_FLIP_NONE = (0 << 0),
>> +	EXYNOS_DRM_FLIP_VERTICAL = (1 << 0),
>> +	EXYNOS_DRM_FLIP_HORIZONTAL = (1 << 1),
>> +};
>> +
>> +enum drm_exynos_degree {
>> +	EXYNOS_DRM_DEGREE_0,
>> +	EXYNOS_DRM_DEGREE_90,
>> +	EXYNOS_DRM_DEGREE_180,
>> +	EXYNOS_DRM_DEGREE_270,
>> +};
>> +
>> +enum drm_exynos_planer {
>> +	EXYNOS_DRM_PLANAR_Y,
>> +	EXYNOS_DRM_PLANAR_CB,
>> +	EXYNOS_DRM_PLANAR_CR,
>> +	EXYNOS_DRM_PLANAR_MAX,
>> +};
>> +
>> +/**
>> + * A structure for ipp supported property list.
>> + *
>> + * @version: version of this structure.
>> + * @ipp_id: id of ipp driver.
>> + * @count: count of ipp driver.
>> + * @writeback: flag of writeback supporting.
>> + * @flip: flag of flip supporting.
>> + * @degree: flag of degree information.
>> + * @csc: flag of csc supporting.
>> + * @crop: flag of crop supporting.
>> + * @scale: flag of scale supporting.
>> + * @refresh_min: min hz of refresh.
>> + * @refresh_max: max hz of refresh.
>> + * @crop_min: crop min resolution.
>> + * @crop_max: crop max resolution.
>> + * @scale_min: scale min resolution.
>> + * @scale_max: scale max resolution.
>> + */
>> +struct drm_exynos_ipp_prop_list {
>> +	__u32	version;
>> +	__u32	ipp_id;
>> +	__u32	count;
>> +	__u32	writeback;
>> +	__u32	flip;
>> +	__u32	degree;
>> +	__u32	csc;
>> +	__u32	crop;
>> +	__u32	scale;
>> +	__u32	refresh_min;
>> +	__u32	refresh_max;
>> +	__u32	reserved;
>> +	struct drm_exynos_sz	crop_min;
>> +	struct drm_exynos_sz	crop_max;
>> +	struct drm_exynos_sz	scale_min;
>> +	struct drm_exynos_sz	scale_max;
>> +};
>> +
>> +/**
>> + * A structure for ipp config.
>> + *
>> + * @ops_id: property of operation directions.
>> + * @flip: property of mirror, flip.
>> + * @degree: property of rotation degree.
>> + * @fmt: property of image format.
>> + * @sz: property of image size.
>> + * @pos: property of image position(src-cropped,dst-scaler).
>> + */
>> +struct drm_exynos_ipp_config {
>> +	enum drm_exynos_ops_id ops_id;
>> +	enum drm_exynos_flip	flip;
>> +	enum drm_exynos_degree	degree;
>> +	__u32	fmt;
>> +	struct drm_exynos_sz	sz;
>> +	struct drm_exynos_pos	pos;
>> +};
>> +
>> +enum drm_exynos_ipp_cmd {
>> +	IPP_CMD_NONE,
>> +	IPP_CMD_M2M,
>> +	IPP_CMD_WB,
>> +	IPP_CMD_OUTPUT,
>> +	IPP_CMD_MAX,
>> +};
>> +
>> +/**
>> + * A structure for ipp property.
>> + *
>> + * @config: source, destination config.
>> + * @cmd: definition of command.
>> + * @ipp_id: id of ipp driver.
>> + * @prop_id: id of property.
>> + * @refresh_rate: refresh rate.
>> + */
>> +struct drm_exynos_ipp_property {
>> +	struct drm_exynos_ipp_config config[EXYNOS_DRM_OPS_MAX];
>> +	enum drm_exynos_ipp_cmd	cmd;
>> +	__u32	ipp_id;
>> +	__u32	prop_id;
>> +	__u32	refresh_rate;
>> +};
>> +
>> +enum drm_exynos_ipp_buf_type {
>> +	IPP_BUF_ENQUEUE,
>> +	IPP_BUF_DEQUEUE,
>> +};
>> +
>> +/**
>> + * A structure for ipp buffer operations.
>> + *
>> + * @ops_id: operation directions.
>> + * @buf_type: definition of buffer.
>> + * @prop_id: id of property.
>> + * @buf_id: id of buffer.
>> + * @handle: Y, Cb, Cr each planar handle.
>> + * @user_data: user data.
>> + */
>> +struct drm_exynos_ipp_queue_buf {
>> +	enum drm_exynos_ops_id	ops_id;
>> +	enum drm_exynos_ipp_buf_type	buf_type;
>> +	__u32	prop_id;
>> +	__u32	buf_id;
>> +	__u32	handle[EXYNOS_DRM_PLANAR_MAX];
>> +	__u32	reserved;
>> +	__u64	user_data;
>> +};
>> +
>> +enum drm_exynos_ipp_ctrl {
>> +	IPP_CTRL_PLAY,
>> +	IPP_CTRL_STOP,
>> +	IPP_CTRL_PAUSE,
>> +	IPP_CTRL_RESUME,
>> +	IPP_CTRL_MAX,
>> +};
>> +
>> +/**
>> + * A structure for ipp start/stop operations.
>> + *
>> + * @prop_id: id of property.
>> + * @ctrl: definition of control.
>> + */
>> +struct drm_exynos_ipp_cmd_ctrl {
>> +	__u32	prop_id;
>> +	enum drm_exynos_ipp_ctrl	ctrl;
>> +};
>> +
>>   #define DRM_EXYNOS_GEM_CREATE		0x00
>>   #define DRM_EXYNOS_GEM_MAP_OFFSET	0x01
>>   #define DRM_EXYNOS_GEM_MMAP		0x02
>> @@ -166,6 +330,12 @@ struct drm_exynos_g2d_exec {
>>   #define DRM_EXYNOS_G2D_SET_CMDLIST	0x21
>>   #define DRM_EXYNOS_G2D_EXEC		0x22
>>
>> +/* IPP - Image Post Processing */
>> +#define DRM_EXYNOS_IPP_GET_PROPERTY	0x30
>> +#define DRM_EXYNOS_IPP_SET_PROPERTY	0x31
>> +#define DRM_EXYNOS_IPP_QUEUE_BUF	0x32
>> +#define DRM_EXYNOS_IPP_CMD_CTRL	0x33
>> +
>>   #define DRM_IOCTL_EXYNOS_GEM_CREATE		DRM_IOWR(DRM_COMMAND_BASE +
>> \
>>   		DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
>>
>> @@ -188,8 +358,18 @@ struct drm_exynos_g2d_exec {
>>   #define DRM_IOCTL_EXYNOS_G2D_EXEC		DRM_IOWR(DRM_COMMAND_BASE +
>> \
>>   		DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec)
>>
>> +#define DRM_IOCTL_EXYNOS_IPP_GET_PROPERTY	DRM_IOWR(DRM_COMMAND_BASE +
>> \
>> +		DRM_EXYNOS_IPP_GET_PROPERTY, struct
> drm_exynos_ipp_prop_list)
>> +#define DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY	DRM_IOWR(DRM_COMMAND_BASE +
>> \
>> +		DRM_EXYNOS_IPP_SET_PROPERTY, struct drm_exynos_ipp_property)
>> +#define DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF	DRM_IOWR(DRM_COMMAND_BASE +
> \
>> +		DRM_EXYNOS_IPP_QUEUE_BUF, struct drm_exynos_ipp_queue_buf)
>> +#define DRM_IOCTL_EXYNOS_IPP_CMD_CTRL
> DRM_IOWR(DRM_COMMAND_BASE +
>> \
>> +		DRM_EXYNOS_IPP_CMD_CTRL, struct drm_exynos_ipp_cmd_ctrl)
>> +
>>   /* EXYNOS specific events */
>>   #define DRM_EXYNOS_G2D_EVENT		0x80000000
>> +#define DRM_EXYNOS_IPP_EVENT		0x80000001
>>
>>   struct drm_exynos_g2d_event {
>>   	struct drm_event	base;
>> @@ -200,4 +380,14 @@ struct drm_exynos_g2d_event {
>>   	__u32			reserved;
>>   };
>>
>> +struct drm_exynos_ipp_event {
>> +	struct drm_event	base;
>> +	__u64			user_data;
>> +	__u32			tv_sec;
>> +	__u32			tv_usec;
>> +	__u32			prop_id;
>> +	__u32			reserved;
>> +	__u32			buf_id[EXYNOS_DRM_OPS_MAX];
>> +};
>> +
>>   #endif /* _UAPI_EXYNOS_DRM_H_ */
>> --
>> 1.7.0.4
>
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC v3 4/5] drm/exynos: add rotator ipp driver
  2012-12-12  8:29   ` Inki Dae
@ 2012-12-12  9:26     ` Eunchul Kim
  2012-12-12  9:41       ` Inki Dae
  2012-12-12  9:46       ` Inki Dae
  0 siblings, 2 replies; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12  9:26 UTC (permalink / raw)
  To: Inki Dae
  Cc: jy0.jeon, sw0312.kim, jaejoon.seo, kyungmin.park, dri-devel, jmock.shin

Thank's your comment.

I answer your comment. please check that.

Thank's

BR
Eunchul Kim

On 12/12/2012 05:29 PM, Inki Dae wrote:
>
>
>> -----Original Message-----
>> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
>> Sent: Wednesday, December 12, 2012 4:35 PM
>> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
>> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com; jmock.shin@samsung.com;
>> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
>> chulspro.kim@samsung.com
>> Subject: [RFC v3 4/5] drm/exynos: add rotator ipp driver
>>
>> Rotator supports rotation/crop/flip and input/output DMA operations
>> Rotator ipp driver supports 90,180,270 degree rotaion and vertical,
>> horizontal flip.
>> and has some limitations(source and destination format have to be same, no
>> scaler)
>>
>> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
>> Signed-off-by: Youngjun Cho <yj44.cho@samsung.com>
>> ---
>>   drivers/gpu/drm/exynos/Kconfig              |    7 +
>>   drivers/gpu/drm/exynos/Makefile             |    1 +
>>   drivers/gpu/drm/exynos/exynos_drm_drv.c     |   15 +
>>   drivers/gpu/drm/exynos/exynos_drm_drv.h     |    1 +
>>   drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829
>> +++++++++++++++++++++++++++
>>   drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
>>   drivers/gpu/drm/exynos/regs-rotator.h       |   73 +++
>>   7 files changed, 939 insertions(+), 0 deletions(-)
>>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
>>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
>>   create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
>>
>> diff --git a/drivers/gpu/drm/exynos/Kconfig
>> b/drivers/gpu/drm/exynos/Kconfig
>> index 4915ab6..4860835 100644
>> --- a/drivers/gpu/drm/exynos/Kconfig
>> +++ b/drivers/gpu/drm/exynos/Kconfig
>> @@ -57,3 +57,10 @@ config DRM_EXYNOS_FIMC
>>   	depends on DRM_EXYNOS_IPP
>>   	help
>>   	  Choose this option if you want to use Exynos FIMC for DRM.
>> +
>> +config DRM_EXYNOS_ROTATOR
>> +	bool "Exynos DRM Rotator"
>> +	depends on DRM_EXYNOS_IPP
>> +	help
>> +	  Choose this option if you want to use Exynos Rotator for DRM.
>> +
>> diff --git a/drivers/gpu/drm/exynos/Makefile
>> b/drivers/gpu/drm/exynos/Makefile
>> index 9710024..3b70668 100644
>> --- a/drivers/gpu/drm/exynos/Makefile
>> +++ b/drivers/gpu/drm/exynos/Makefile
>> @@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+=
>> exynos_drm_vidi.o
>>   exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
>>   exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
>>   exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
>> +exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
>>
>>   obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> index 73f02ac..09d884b 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> @@ -378,6 +378,12 @@ static int __init exynos_drm_init(void)
>>   		goto out_fimc;
>>   #endif
>>
>> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>> +	ret = platform_driver_register(&rotator_driver);
>> +	if (ret < 0)
>> +		goto out_rotator;
>> +#endif
>> +
>>   #ifdef CONFIG_DRM_EXYNOS_IPP
>>   	ret = platform_driver_register(&ipp_driver);
>>   	if (ret < 0)
>> @@ -406,6 +412,11 @@ out_drm:
>>   out_ipp:
>>   #endif
>>
>> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>> +	platform_driver_unregister(&rotator_driver);
>> +out_rotator:
>> +#endif
>> +
>>   #ifdef CONFIG_DRM_EXYNOS_FIMC
>>   	platform_driver_unregister(&fimc_driver);
>>   out_fimc:
>> @@ -451,6 +462,10 @@ static void __exit exynos_drm_exit(void)
>>   	platform_driver_unregister(&ipp_driver);
>>   #endif
>>
>> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>> +	platform_driver_unregister(&rotator_driver);
>> +#endif
>> +
>>   #ifdef CONFIG_DRM_EXYNOS_FIMC
>>   	platform_driver_unregister(&fimc_driver);
>>   #endif
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> index 14f9490..a74e37c 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> @@ -353,5 +353,6 @@ extern struct platform_driver
>> exynos_drm_common_hdmi_driver;
>>   extern struct platform_driver vidi_driver;
>>   extern struct platform_driver g2d_driver;
>>   extern struct platform_driver fimc_driver;
>> +extern struct platform_driver rotator_driver;
>>   extern struct platform_driver ipp_driver;
>>   #endif
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
>> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
>> new file mode 100644
>> index 0000000..121569c
>> --- /dev/null
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
>> @@ -0,0 +1,829 @@
>> +/*
>> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
>> + * Authors:
>> + *	YoungJun Cho <yj44.cho@samsung.com>
>> + *	Eunchul Kim <chulspro.kim@samsung.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundationr
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/err.h>
>> +#include <linux/interrupt.h>
>> +#include <linux/io.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/clk.h>
>> +#include <linux/pm_runtime.h>
>> +
>> +#include <drm/drmP.h>
>> +#include <drm/exynos_drm.h>
>> +#include "regs-rotator.h"
>> +#include "exynos_drm.h"
>> +#include "exynos_drm_ipp.h"
>> +
>> +/*
>> + * Rotator supports image crop/rotator and input/output DMA operations.
>> + * input DMA reads image data from the memory.
>> + * output DMA writes image data to memory.
>> + */
>> +
>> +#define get_rot_context(dev)
>> 	platform_get_drvdata(to_platform_device(dev))
>> +#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
>> +					struct rot_context, ippdrv);
>> +#define rot_read(offset)		readl(rot->regs + (offset))
>> +#define rot_write(cfg, offset)	writel(cfg, rot->regs + (offset))
>> +
>> +enum rot_irq_status {
>> +	ROT_IRQ_STATUS_COMPLETE	= 8,
>> +	ROT_IRQ_STATUS_ILLEGAL	= 9,
>> +};
>> +
>> +/*
>> + * A structure of limitation.
>> + *
>> + * @min_w: minimum width.
>> + * @min_h: minimum height.
>> + * @max_w: maximum width.
>> + * @max_h: maximum height.
>> + * @align: align size.
>> + */
>> +struct rot_limit {
>> +	u32	min_w;
>> +	u32	min_h;
>> +	u32	max_w;
>> +	u32	max_h;
>> +	u32	align;
>> +};
>> +
>> +/*
>> + * A structure of limitation table.
>> + *
>> + * @ycbcr420_2p: case of YUV.
>> + * @rgb888: case of RGB.
>> + */
>> +struct rot_limit_table {
>> +	struct rot_limit	ycbcr420_2p;
>> +	struct rot_limit	rgb888;
>> +};
>> +
>> +/*
>> + * A structure of rotator context.
>> + * @ippdrv: prepare initialization using ippdrv.
>> + * @regs_res: register resources.
>> + * @regs: memory mapped io registers.
>> + * @clock: rotator gate clock.
>> + * @limit_tbl: limitation of rotator.
>> + * @irq: irq number.
>> + * @cur_buf_id: current operation buffer id.
>> + * @suspended: suspended state.
>> + */
>> +struct rot_context {
>> +	struct exynos_drm_ippdrv	ippdrv;
>> +	struct resource	*regs_res;
>> +	void __iomem	*regs;
>> +	struct clk	*clock;
>> +	struct rot_limit_table	*limit_tbl;
>> +	int	irq;
>> +	int	cur_buf_id[EXYNOS_DRM_OPS_MAX];
>> +	bool	suspended;
>> +};
>> +
>> +static void rotator_reg_set_irq(struct rot_context *rot, bool enable)
>> +{
>> +	u32 val = rot_read(ROT_CONFIG);
>> +
>> +	if (enable == true)
>> +		val |= ROT_CONFIG_IRQ;
>> +	else
>> +		val &= ~ROT_CONFIG_IRQ;
>> +
>> +	rot_write(val, ROT_CONFIG);
>> +}
>> +
>> +static u32 rotator_reg_get_format(struct rot_context *rot)
>> +{
>> +	u32 val = rot_read(ROT_CONTROL);
>> +
>> +	val &= ROT_CONTROL_FMT_MASK;
>> +
>> +	return val;
>> +}
>> +
>> +static enum rot_irq_status rotator_reg_get_irq_status(struct rot_context
>> *rot)
>> +{
>> +	u32 val = rot_read(ROT_STATUS);
>> +
>> +	val = ROT_STATUS_IRQ(val);
>> +
>> +	if (val == ROT_STATUS_IRQ_VAL_COMPLETE)
>> +		return ROT_IRQ_STATUS_COMPLETE;
>> +	else
>
> Remove else.

- done.

>
>> +		return ROT_IRQ_STATUS_ILLEGAL;
>> +}
>> +
>> +static irqreturn_t rotator_irq_handler(int irq, void *arg)
>> +{
>> +	struct rot_context *rot = arg;
>> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
>> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
>> +	struct drm_exynos_ipp_event_work *event_work = c_node->event_work;
>> +	enum rot_irq_status irq_status;
>> +	u32 val;
>> +
>> +	/* Get execution result */
>> +	irq_status = rotator_reg_get_irq_status(rot);
>> +
>> +	/* clear status */
>> +	val = rot_read(ROT_STATUS);
>> +	val |= ROT_STATUS_IRQ_PENDING((u32)irq_status);
>> +	rot_write(val, ROT_STATUS);
>> +
>> +	if (irq_status == ROT_IRQ_STATUS_COMPLETE) {
>> +		event_work->ippdrv = ippdrv;
>> +		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
>> +			rot->cur_buf_id[EXYNOS_DRM_OPS_DST];
>> +		queue_work(ippdrv->event_workq,
>> +			(struct work_struct *)event_work);
>> +	} else
>> +		DRM_ERROR("the SFR is set illegally\n");
>> +
>> +	return IRQ_HANDLED;
>> +}
>> +
>> +static void rotator_align_size(struct rot_context *rot, u32 fmt, u32
>> *hsize,
>> +		u32 *vsize)
>> +{
>> +	struct rot_limit_table *limit_tbl = rot->limit_tbl;
>> +	struct rot_limit *limit;
>> +	u32 mask, val;
>> +
>> +	/* Get size limit */
>> +	if (fmt == ROT_CONTROL_FMT_RGB888)
>> +		limit = &limit_tbl->rgb888;
>> +	else
>> +		limit = &limit_tbl->ycbcr420_2p;
>> +
>> +	/* Get mask for rounding to nearest aligned val */
>> +	mask = ~((1 << limit->align) - 1);
>> +
>> +	/* Set aligned width */
>> +	val = ROT_ALIGN(*hsize, limit->align, mask);
>> +	if (val < limit->min_w)
>> +		*hsize = ROT_MIN(limit->min_w, mask);
>> +	else if (val > limit->max_w)
>> +		*hsize = ROT_MAX(limit->max_w, mask);
>> +	else
>> +		*hsize = val;
>> +
>> +	/* Set aligned height */
>> +	val = ROT_ALIGN(*vsize, limit->align, mask);
>> +	if (val < limit->min_h)
>> +		*vsize = ROT_MIN(limit->min_h, mask);
>> +	else if (val > limit->max_h)
>> +		*vsize = ROT_MAX(limit->max_h, mask);
>> +	else
>> +		*vsize = val;
>> +}
>> +
>> +static int rotator_src_set_fmt(struct device *dev, u32 fmt)
>> +{
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +	u32 val;
>> +
>> +	val = rot_read(ROT_CONTROL);
>> +	val &= ~ROT_CONTROL_FMT_MASK;
>> +
>> +	switch (fmt) {
>> +	case DRM_FORMAT_NV12:
>> +		val |= ROT_CONTROL_FMT_YCBCR420_2P;
>> +		break;
>> +	case DRM_FORMAT_XRGB8888:
>> +		val |= ROT_CONTROL_FMT_RGB888;
>> +		break;
>> +	default:
>> +		DRM_ERROR("invalid image format\n");
>> +		return -EINVAL;
>> +	}
>> +
>> +	rot_write(val, ROT_CONTROL);
>> +
>> +	return 0;
>> +}
>> +
>> +static int rotator_src_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;
>> +	u32 val;
>> +
>> +	/* 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 */
>> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
>> +	rot_write(val, ROT_SRC_BUF_SIZE);
>> +
>> +	/* Set crop image position configuration */
>> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
>> +	rot_write(val, ROT_SRC_CROP_POS);
>> +	val = ROT_SRC_CROP_SIZE_H(pos->h) | ROT_SRC_CROP_SIZE_W(pos->w);
>> +	rot_write(val, ROT_SRC_CROP_SIZE);
>> +
>> +	return 0;
>> +}
>> +
>> +static int rotator_src_set_addr(struct device *dev,
>> +		struct drm_exynos_ipp_buf_info *buf_info,
>> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
>> +{
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
>> +	u32 val, fmt, hsize, vsize;
>> +	int i;
>> +
>> +	/* Set current buf_id */
>> +	rot->cur_buf_id[EXYNOS_DRM_OPS_SRC] = buf_id;
>> +
>> +	switch (buf_type) {
>> +	case IPP_BUF_ENQUEUE:
>> +		/* Set address configuration */
>> +		for_each_ipp_planar(i)
>> +			addr[i] = buf_info->base[i];
>
> Check NULL.

- If not copy this state, we need to memset about addr.
   no need check null.

>
>> +
>> +		/* Get format */
>> +		fmt = rotator_reg_get_format(rot);
>> +
>> +		/* Re-set cb planar for NV12 format */
>> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
>> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
> 0x00)) {
>
> What is 0x00?

- It is NULL, I changed !addr instead of addr == 0x00

>
>> +
>> +			val = rot_read(ROT_SRC_BUF_SIZE);
>> +			hsize = ROT_GET_BUF_SIZE_W(val);
>> +			vsize = ROT_GET_BUF_SIZE_H(val);
>> +
>> +			/* Set cb planar */
>> +			addr[EXYNOS_DRM_PLANAR_CB] =
>> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
>> +		}
>> +
>> +		for_each_ipp_planar(i)
>> +			rot_write(addr[i], ROT_SRC_BUF_ADDR(i));
>> +		break;
>> +	case IPP_BUF_DEQUEUE:
>> +		for_each_ipp_planar(i)
>> +			rot_write(0x0, ROT_SRC_BUF_ADDR(i));
>> +		break;
>> +	default:
>> +		/* Nothing to do */
>> +		break;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static int rotator_dst_set_transf(struct device *dev,
>> +		enum drm_exynos_degree degree,
>> +		enum drm_exynos_flip flip)
>> +{
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +	u32 val;
>> +
>> +	/* Set transform configuration */
>> +	val = rot_read(ROT_CONTROL);
>> +	val &= ~ROT_CONTROL_FLIP_MASK;
>> +
>> +	switch (flip) {
>> +	case EXYNOS_DRM_FLIP_VERTICAL:
>> +		val |= ROT_CONTROL_FLIP_VERTICAL;
>> +		break;
>> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
>> +		val |= ROT_CONTROL_FLIP_HORIZONTAL;
>> +		break;
>> +	default:
>> +		/* Flip None */
>> +		break;
>> +	}
>> +
>> +	val &= ~ROT_CONTROL_ROT_MASK;
>> +
>> +	switch (degree) {
>> +	case EXYNOS_DRM_DEGREE_90:
>> +		val |= ROT_CONTROL_ROT_90;
>> +		break;
>> +	case EXYNOS_DRM_DEGREE_180:
>> +		val |= ROT_CONTROL_ROT_180;
>> +		break;
>> +	case EXYNOS_DRM_DEGREE_270:
>> +		val |= ROT_CONTROL_ROT_270;
>> +		break;
>> +	default:
>> +		/* Rotation 0 Degree */
>> +		break;
>> +	}
>> +
>> +	rot_write(val, ROT_CONTROL);
>> +
>> +	/* Check degree for setting buffer size swap */
>> +	if ((degree == EXYNOS_DRM_DEGREE_90) ||
>> +		(degree == EXYNOS_DRM_DEGREE_270))
>> +		return 1;
>
> Correct return type. This function should return 0 or negative.

- no ~ this return type is boolean true or false.
   but we need to error handling so, we use integer as you know
   we reviewed this routine at our local git from our team(you and me).

>
>> +	else
>> +		return 0;
>
> Ditto.

- ditto.

>
>> +}
>> +
>> +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 val, fmt, hsize, vsize;
>> +
>> +	/* Get format */
>> +	fmt = rotator_reg_get_format(rot);
>
> Check if fmt is valid or not.

- added rotator_check_fmt()

>
>> +
>> +	/* Align buffer size */
>> +	hsize = sz->hsize;
>> +	vsize = sz->vsize;
>> +	rotator_align_size(rot, fmt, &hsize, &vsize);
>> +
>> +	/* Set buffer size configuration */
>> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
>> +	rot_write(val, ROT_DST_BUF_SIZE);
>> +
>> +	/* Set crop image position configuration */
>> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
>> +	rot_write(val, ROT_DST_CROP_POS);
>> +
>> +	return 0;
>> +}
>> +
>> +static int rotator_dst_set_addr(struct device *dev,
>> +		struct drm_exynos_ipp_buf_info *buf_info,
>> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
>> +{
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
>> +	u32 val, fmt, hsize, vsize;
>> +	int i;
>> +
>> +	/* Set current buf_id */
>> +	rot->cur_buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
>> +
>> +	switch (buf_type) {
>> +	case IPP_BUF_ENQUEUE:
>> +		/* Set address configuration */
>> +		for_each_ipp_planar(i)
>> +			addr[i] = buf_info->base[i];
>> +
>> +		/* Get format */
>> +		fmt = rotator_reg_get_format(rot);
>
> Check if fmt is valid or not.

- done.

>
>> +
>> +		/* Re-set cb planar for NV12 format */
>> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
>> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
> 0x00)) {
>> +			/* Get buf size */
>> +			val = rot_read(ROT_DST_BUF_SIZE);
>> +
>> +			hsize = ROT_GET_BUF_SIZE_W(val);
>> +			vsize = ROT_GET_BUF_SIZE_H(val);
>> +
>> +			/* Set cb planar */
>> +			addr[EXYNOS_DRM_PLANAR_CB] =
>> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
>> +		}
>> +
>> +		for_each_ipp_planar(i)
>> +			rot_write(addr[i], ROT_DST_BUF_ADDR(i));
>> +		break;
>> +	case IPP_BUF_DEQUEUE:
>> +		for_each_ipp_planar(i)
>> +			rot_write(0x0, ROT_DST_BUF_ADDR(i));
>> +		break;
>> +	default:
>> +		/* Nothing to do */
>> +		break;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static struct exynos_drm_ipp_ops rot_src_ops = {
>> +	.set_fmt	=	rotator_src_set_fmt,
>> +	.set_size	=	rotator_src_set_size,
>> +	.set_addr	=	rotator_src_set_addr,
>> +};
>> +
>> +static struct exynos_drm_ipp_ops rot_dst_ops = {
>> +	.set_transf	=	rotator_dst_set_transf,
>> +	.set_size	=	rotator_dst_set_size,
>> +	.set_addr	=	rotator_dst_set_addr,
>> +};
>> +
>> +static int rotator_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
>> +{
>> +	struct drm_exynos_ipp_prop_list *prop_list;
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
>> +	if (!prop_list) {
>> +		DRM_ERROR("failed to alloc property list.\n");
>> +		return -ENOMEM;
>> +	}
>> +
>> +	/*ToDo fix support function list*/
>> +
>> +	prop_list->version = 1;
>> +	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
>> +				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
>> +	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
>> +				(1 << EXYNOS_DRM_DEGREE_90) |
>> +				(1 << EXYNOS_DRM_DEGREE_180) |
>> +				(1 << EXYNOS_DRM_DEGREE_270);
>> +	prop_list->csc = 0;
>> +	prop_list->crop = 0;
>> +	prop_list->scale = 0;
>> +
>> +	ippdrv->prop_list = prop_list;
>> +
>> +	return 0;
>> +}
>> +
>> +static int rotator_ippdrv_check_property(struct device *dev,
>> +		struct drm_exynos_ipp_property *property)
>> +{
>> +	struct drm_exynos_ipp_config *src_config =
>> +
> &property->config[EXYNOS_DRM_OPS_SRC];
>> +	struct drm_exynos_ipp_config *dst_config =
>> +
> &property->config[EXYNOS_DRM_OPS_DST];
>> +	struct drm_exynos_pos *src_pos = &src_config->pos;
>> +	struct drm_exynos_pos *dst_pos = &dst_config->pos;
>> +	struct drm_exynos_sz *src_sz = &src_config->sz;
>> +	struct drm_exynos_sz *dst_sz = &dst_config->sz;
>> +	bool swap = false;
>> +
>> +	/* Check format configuration */
>> +	if (src_config->fmt != dst_config->fmt) {
>> +		DRM_DEBUG_KMS("%s:not support csc feature\n", __func__);
>> +		return -EINVAL;
>> +	}
>> +
>> +	switch (src_config->fmt) {
>> +	case DRM_FORMAT_XRGB8888:
>> +	case DRM_FORMAT_NV12:
>> +		/* No problem */
>> +		break;
>> +	default:
>> +		DRM_DEBUG_KMS("%s:not support format\n", __func__);
>> +		return -EINVAL;
>> +	}
>
> Use macro instead of switch-case. this just checks only format type.

- I don't thing so, If we make macro about this.
   then we got some confusion about this macro at next change.
   this case switch-case is better.
   Do you prefer this ? please one more comment.

#define drm_check_fmt(fmt) if (fmt == DRM_FORMAT_XRGB8888 || fmt == 
DRM_FORMAT_NV12) \
					return true;

>
>> +
>> +	/* Check transform configuration */
>> +	if (src_config->degree != EXYNOS_DRM_DEGREE_0) {
>> +		DRM_DEBUG_KMS("%s:not support source-side rotation\n",
>> +								__func__);
>> +		return -EINVAL;
>> +	}
>> +
>> +	switch (dst_config->degree) {
>> +	case EXYNOS_DRM_DEGREE_90:
>> +	case EXYNOS_DRM_DEGREE_270:
>> +		swap = true;
>> +	case EXYNOS_DRM_DEGREE_0:
>> +	case EXYNOS_DRM_DEGREE_180:
>> +		/* No problem */
>> +		break;
>> +	default:
>> +		DRM_DEBUG_KMS("%s:invalid degree\n", __func__);
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (src_config->flip != EXYNOS_DRM_FLIP_NONE) {
>> +		DRM_DEBUG_KMS("%s:not support source-side flip\n",
> __func__);
>> +		return -EINVAL;
>> +	}
>> +
>> +	switch (dst_config->flip) {
>> +	case EXYNOS_DRM_FLIP_NONE:
>> +	case EXYNOS_DRM_FLIP_VERTICAL:
>> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
>> +		/* No problem */
>> +		break;
>> +	default:
>> +		DRM_DEBUG_KMS("%s:invalid flip\n", __func__);
>> +		return -EINVAL;
>> +	}
>
> Use macro instead of switch-case. this just checks only flip type.

- ditto. please one more comment.
  in my opinion: I prefer enumeration use switch-case.

>
>> +
>> +	/* Check size configuration */
>> +	if ((src_pos->x + src_pos->w > src_sz->hsize) ||
>> +		(src_pos->y + src_pos->h > src_sz->vsize)) {
>> +		DRM_DEBUG_KMS("%s:out of source buffer bound\n", __func__);
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (swap) {
>> +		if ((dst_pos->x + dst_pos->h > dst_sz->vsize) ||
>> +			(dst_pos->y + dst_pos->w > dst_sz->hsize)) {
>> +			DRM_DEBUG_KMS("%s:out of destination buffer
> bound\n",
>> +								__func__);
>> +			return -EINVAL;
>> +		}
>> +
>> +		if ((src_pos->w != dst_pos->h) || (src_pos->h !=
> dst_pos->w))
>> {
>> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
>> +								__func__);
>> +			return -EINVAL;
>> +		}
>> +	} else {
>> +		if ((dst_pos->x + dst_pos->w > dst_sz->hsize) ||
>> +			(dst_pos->y + dst_pos->h > dst_sz->vsize)) {
>> +			DRM_DEBUG_KMS("%s:out of destination buffer
> bound\n",
>> +								__func__);
>> +			return -EINVAL;
>> +		}
>> +
>> +		if ((src_pos->w != dst_pos->w) || (src_pos->h !=
> dst_pos->h))
>> {
>> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
>> +								__func__);
>> +			return -EINVAL;
>> +		}
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static int rotator_ippdrv_start(struct device *dev, enum
>> drm_exynos_ipp_cmd cmd)
>> +{
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +	u32 val;
>> +
>> +	if (rot->suspended) {
>> +		DRM_ERROR("suspended state\n");
>> +		return -EPERM;
>> +	}
>> +
>> +	if (cmd != IPP_CMD_M2M) {
>> +		DRM_ERROR("not support cmd: %d\n", cmd);
>> +		return -EINVAL;
>> +	}
>> +
>> +	/* Set interrupt enable */
>> +	rotator_reg_set_irq(rot, true);
>> +
>> +	val = rot_read(ROT_CONTROL);
>> +	val |= ROT_CONTROL_START;
>> +
>> +	rot_write(val, ROT_CONTROL);
>> +
>> +	return 0;
>> +}
>> +
>> +static int __devinit rotator_probe(struct platform_device *pdev)
>> +{
>> +	struct device *dev = &pdev->dev;
>> +	struct rot_context *rot;
>> +	struct resource *res;
>> +	struct exynos_drm_ippdrv *ippdrv;
>> +	int ret;
>> +
>> +	rot = kzalloc(sizeof(*rot), GFP_KERNEL);
>> +	if (!rot) {
>> +		dev_err(dev, "failed to allocate rot\n");
>> +		return -ENOMEM;
>> +	}
>> +
>> +	rot->limit_tbl = (struct rot_limit_table *)
>> +				platform_get_device_id(pdev)->driver_data;
>> +
>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> +	if (!res) {
>> +		dev_err(dev, "failed to find registers\n");
>> +		ret = -ENOENT;
>> +		goto err_get_resource;
>> +	}
>> +
>> +	rot->regs_res = request_mem_region(res->start, resource_size(res),
>> +
> dev_name(dev));
>> +	if (!rot->regs_res) {
>> +		dev_err(dev, "failed to claim register region\n");
>> +		ret = -ENOENT;
>> +		goto err_get_resource;
>> +	}
>> +
>> +	rot->regs = ioremap(res->start, resource_size(res));
>> +	if (!rot->regs) {
>> +		dev_err(dev, "failed to map register\n");
>> +		ret = -ENXIO;
>> +		goto err_ioremap;
>> +	}
>> +
>> +	rot->irq = platform_get_irq(pdev, 0);
>> +	if (rot->irq < 0) {
>> +		dev_err(dev, "failed to get irq\n");
>> +		ret = rot->irq;
>> +		goto err_get_irq;
>> +	}
>> +
>> +	ret = request_threaded_irq(rot->irq, NULL, rotator_irq_handler,
>> +					IRQF_ONESHOT, "drm_rotator", rot);
>> +	if (ret < 0) {
>> +		dev_err(dev, "failed to request irq\n");
>> +		goto err_get_irq;
>> +	}
>> +
>> +	rot->clock = clk_get(dev, "rotator");
>> +	if (IS_ERR_OR_NULL(rot->clock)) {
>> +		dev_err(dev, "failed to get clock\n");
>> +		ret = PTR_ERR(rot->clock);
>> +		goto err_clk_get;
>> +	}
>> +
>> +	pm_runtime_enable(dev);
>> +
>> +	ippdrv = &rot->ippdrv;
>> +	ippdrv->dev = dev;
>> +	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &rot_src_ops;
>> +	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &rot_dst_ops;
>> +	ippdrv->check_property = rotator_ippdrv_check_property;
>> +	ippdrv->start = rotator_ippdrv_start;
>> +	ret = rotator_init_prop_list(ippdrv);
>> +	if (ret < 0) {
>> +		dev_err(dev, "failed to init property list.\n");
>> +		goto err_ippdrv_register;
>> +	}
>> +
>> +	DRM_DEBUG_KMS("%s:ippdrv[0x%x]\n", __func__, (int)ippdrv);
>> +
>> +	platform_set_drvdata(pdev, rot);
>> +
>> +	ret = exynos_drm_ippdrv_register(ippdrv);
>> +	if (ret < 0) {
>> +		dev_err(dev, "failed to register drm rotator device\n");
>> +		kfree(ippdrv->prop_list);
>> +		goto err_ippdrv_register;
>> +	}
>> +
>> +	dev_info(dev, "The exynos rotator is probed successfully\n");
>> +
>> +	return 0;
>> +
>> +err_ippdrv_register:
>> +	pm_runtime_disable(dev);
>> +	clk_put(rot->clock);
>> +err_clk_get:
>> +	free_irq(rot->irq, rot);
>> +err_get_irq:
>> +	iounmap(rot->regs);
>> +err_ioremap:
>> +	release_resource(rot->regs_res);
>> +	kfree(rot->regs_res);
>> +err_get_resource:
>> +	kfree(rot);
>> +	return ret;
>> +}
>> +
>> +static int __devexit rotator_remove(struct platform_device *pdev)
>> +{
>> +	struct device *dev = &pdev->dev;
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
>> +
>> +	kfree(ippdrv->prop_list);
>> +	exynos_drm_ippdrv_unregister(ippdrv);
>> +
>> +	pm_runtime_disable(dev);
>> +	clk_put(rot->clock);
>> +
>> +	free_irq(rot->irq, rot);
>> +
>> +	iounmap(rot->regs);
>> +
>> +	release_resource(rot->regs_res);
>> +	kfree(rot->regs_res);
>> +
>> +	kfree(rot);
>> +
>> +	return 0;
>> +}
>> +
>> +struct rot_limit_table rot_limit_tbl = {
>> +	.ycbcr420_2p = {
>> +		.min_w = 32,
>> +		.min_h = 32,
>> +		.max_w = SZ_32K,
>> +		.max_h = SZ_32K,
>> +		.align = 3,
>> +	},
>> +	.rgb888 = {
>> +		.min_w = 8,
>> +		.min_h = 8,
>> +		.max_w = SZ_8K,
>> +		.max_h = SZ_8K,
>> +		.align = 2,
>> +	},
>> +};
>> +
>> +struct platform_device_id rotator_driver_ids[] = {
>> +	{
>> +		.name		= "exynos-rot",
>> +		.driver_data	= (unsigned long)&rot_limit_tbl,
>> +	},
>> +	{},
>> +};
>> +
>> +static int rotator_clk_crtl(struct rot_context *rot, bool enable)
>> +{
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (enable) {
>> +		clk_enable(rot->clock);
>> +		rot->suspended = false;
>> +	} else {
>> +		clk_disable(rot->clock);
>> +		rot->suspended = true;
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +
>> +#ifdef CONFIG_PM_SLEEP
>> +static int rotator_suspend(struct device *dev)
>> +{
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +
>> +	/* ToDo */
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (pm_runtime_suspended(dev))
>> +		return 0;
>> +
>> +	return rotator_clk_crtl(rot, false);
>> +}
>> +
>> +static int rotator_resume(struct device *dev)
>> +{
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +
>> +	/* ToDo */
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	if (!pm_runtime_suspended(dev))
>> +		return rotator_clk_crtl(rot, true);
>> +
>> +	return 0;
>> +}
>> +#endif
>> +
>> +#ifdef CONFIG_PM_RUNTIME
>> +static int rotator_runtime_suspend(struct device *dev)
>> +{
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +
>> +	/* ToDo */
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	return  rotator_clk_crtl(rot, false);
>> +}
>> +
>> +static int rotator_runtime_resume(struct device *dev)
>> +{
>> +	struct rot_context *rot = dev_get_drvdata(dev);
>> +
>> +	/* ToDo */
>> +
>> +	DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +	return  rotator_clk_crtl(rot, true);
>> +}
>> +#endif
>> +
>> +static const struct dev_pm_ops rotator_pm_ops = {
>> +	SET_SYSTEM_SLEEP_PM_OPS(rotator_suspend, rotator_resume)
>> +	SET_RUNTIME_PM_OPS(rotator_runtime_suspend, rotator_runtime_resume,
>> +
> NULL)
>> +};
>> +
>> +struct platform_driver rotator_driver = {
>> +	.probe		= rotator_probe,
>> +	.remove		= __devexit_p(rotator_remove),
>> +	.id_table	= rotator_driver_ids,
>> +	.driver		= {
>> +		.name	= "exynos-rot",
>> +		.owner	= THIS_MODULE,
>> +		.pm	= &rotator_pm_ops,
>> +	},
>> +};
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h
>> b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
>> new file mode 100644
>> index 0000000..fe929c9
>> --- /dev/null
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
>> @@ -0,0 +1,13 @@
>> +/*
>> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
>> + * Authors: YoungJun Cho <yj44.cho@samsung.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundationr
>> + */
>> +
>> +#ifndef	_EXYNOS_DRM_ROTATOR_H_
>> +#define	_EXYNOS_DRM_ROTATOR_H_
>> +
>> +#endif
>> diff --git a/drivers/gpu/drm/exynos/regs-rotator.h
>> b/drivers/gpu/drm/exynos/regs-rotator.h
>> new file mode 100644
>> index 0000000..a09ac6e
>> --- /dev/null
>> +++ b/drivers/gpu/drm/exynos/regs-rotator.h
>> @@ -0,0 +1,73 @@
>> +/* drivers/gpu/drm/exynos/regs-rotator.h
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *		http://www.samsung.com/
>> + *
>> + * Register definition file for Samsung Rotator Interface (Rotator)
>> driver
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> +*/
>> +
>> +#ifndef EXYNOS_REGS_ROTATOR_H
>> +#define EXYNOS_REGS_ROTATOR_H
>> +
>> +/* Configuration */
>> +#define ROT_CONFIG			0x00
>> +#define ROT_CONFIG_IRQ			(3 << 8)
>> +
>> +/* Image Control */
>> +#define ROT_CONTROL			0x10
>> +#define ROT_CONTROL_PATTERN_WRITE	(1 << 16)
>> +#define ROT_CONTROL_FMT_YCBCR420_2P	(1 << 8)
>> +#define ROT_CONTROL_FMT_RGB888		(6 << 8)
>> +#define ROT_CONTROL_FMT_MASK		(7 << 8)
>> +#define ROT_CONTROL_FLIP_VERTICAL	(2 << 6)
>> +#define ROT_CONTROL_FLIP_HORIZONTAL	(3 << 6)
>> +#define ROT_CONTROL_FLIP_MASK		(3 << 6)
>> +#define ROT_CONTROL_ROT_90		(1 << 4)
>> +#define ROT_CONTROL_ROT_180		(2 << 4)
>> +#define ROT_CONTROL_ROT_270		(3 << 4)
>> +#define ROT_CONTROL_ROT_MASK		(3 << 4)
>> +#define ROT_CONTROL_START		(1 << 0)
>> +
>> +/* Status */
>> +#define ROT_STATUS			0x20
>> +#define ROT_STATUS_IRQ_PENDING(x)	(1 << (x))
>> +#define ROT_STATUS_IRQ(x)		(((x) >> 8) & 0x3)
>> +#define ROT_STATUS_IRQ_VAL_COMPLETE	1
>> +#define ROT_STATUS_IRQ_VAL_ILLEGAL	2
>> +
>> +/* Buffer Address */
>> +#define ROT_SRC_BUF_ADDR(n)		(0x30 + ((n) << 2))
>> +#define ROT_DST_BUF_ADDR(n)		(0x50 + ((n) << 2))
>> +
>> +/* Buffer Size */
>> +#define ROT_SRC_BUF_SIZE		0x3c
>> +#define ROT_DST_BUF_SIZE		0x5c
>> +#define ROT_SET_BUF_SIZE_H(x)		((x) << 16)
>> +#define ROT_SET_BUF_SIZE_W(x)		((x) << 0)
>> +#define ROT_GET_BUF_SIZE_H(x)		((x) >> 16)
>> +#define ROT_GET_BUF_SIZE_W(x)		((x) & 0xffff)
>> +
>> +/* Crop Position */
>> +#define ROT_SRC_CROP_POS		0x40
>> +#define ROT_DST_CROP_POS		0x60
>> +#define ROT_CROP_POS_Y(x)		((x) << 16)
>> +#define ROT_CROP_POS_X(x)		((x) << 0)
>> +
>> +/* Source Crop Size */
>> +#define ROT_SRC_CROP_SIZE		0x44
>> +#define ROT_SRC_CROP_SIZE_H(x)		((x) << 16)
>> +#define ROT_SRC_CROP_SIZE_W(x)		((x) << 0)
>> +
>> +/* Round to nearest aligned value */
>> +#define ROT_ALIGN(x, align, mask)	(((x) + (1 << ((align) - 1))) &
>> (mask))
>> +/* Minimum limit value */
>> +#define ROT_MIN(min, mask)		(((min) + ~(mask)) & (mask))
>> +/* Maximum limit value */
>> +#define ROT_MAX(max, mask)		((max) & (mask))
>> +
>> +#endif /* EXYNOS_REGS_ROTATOR_H */
>> +
>> --
>> 1.7.0.4
>
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
  2012-12-12  9:26     ` Eunchul Kim
@ 2012-12-12  9:41       ` Inki Dae
  2012-12-12 10:00         ` Inki Dae
  2012-12-12  9:46       ` Inki Dae
  1 sibling, 1 reply; 18+ messages in thread
From: Inki Dae @ 2012-12-12  9:41 UTC (permalink / raw)
  To: 'Eunchul Kim'
  Cc: jy0.jeon, sw0312.kim, jaejoon.seo, kyungmin.park, dri-devel, jmock.shin



> -----Original Message-----
> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> Sent: Wednesday, December 12, 2012 6:26 PM
> To: Inki Dae
> Cc: dri-devel@lists.freedesktop.org; jy0.jeon@samsung.com;
> yj44.cho@samsung.com; jmock.shin@samsung.com; jaejoon.seo@samsung.com;
> kyungmin.park@samsung.com; sw0312.kim@samsung.com; Joonyoung Shim
> Subject: Re: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> 
> Thank's your comment.
> 
> I answer your comment. please check that.
> 
> Thank's
> 
> BR
> Eunchul Kim
> 
> On 12/12/2012 05:29 PM, Inki Dae wrote:
> >
> >
> >> -----Original Message-----
> >> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> >> Sent: Wednesday, December 12, 2012 4:35 PM
> >> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
> >> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com; jmock.shin@samsung.com;
> >> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
> >> chulspro.kim@samsung.com
> >> Subject: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> >>
> >> Rotator supports rotation/crop/flip and input/output DMA operations
> >> Rotator ipp driver supports 90,180,270 degree rotaion and vertical,
> >> horizontal flip.
> >> and has some limitations(source and destination format have to be same,
> no
> >> scaler)
> >>
> >> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
> >> Signed-off-by: Youngjun Cho <yj44.cho@samsung.com>
> >> ---
> >>   drivers/gpu/drm/exynos/Kconfig              |    7 +
> >>   drivers/gpu/drm/exynos/Makefile             |    1 +
> >>   drivers/gpu/drm/exynos/exynos_drm_drv.c     |   15 +
> >>   drivers/gpu/drm/exynos/exynos_drm_drv.h     |    1 +
> >>   drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829
> >> +++++++++++++++++++++++++++
> >>   drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
> >>   drivers/gpu/drm/exynos/regs-rotator.h       |   73 +++
> >>   7 files changed, 939 insertions(+), 0 deletions(-)
> >>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
> >>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
> >>   create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
> >>
> >> diff --git a/drivers/gpu/drm/exynos/Kconfig
> >> b/drivers/gpu/drm/exynos/Kconfig
> >> index 4915ab6..4860835 100644
> >> --- a/drivers/gpu/drm/exynos/Kconfig
> >> +++ b/drivers/gpu/drm/exynos/Kconfig
> >> @@ -57,3 +57,10 @@ config DRM_EXYNOS_FIMC
> >>   	depends on DRM_EXYNOS_IPP
> >>   	help
> >>   	  Choose this option if you want to use Exynos FIMC for DRM.
> >> +
> >> +config DRM_EXYNOS_ROTATOR
> >> +	bool "Exynos DRM Rotator"
> >> +	depends on DRM_EXYNOS_IPP
> >> +	help
> >> +	  Choose this option if you want to use Exynos Rotator for DRM.
> >> +
> >> diff --git a/drivers/gpu/drm/exynos/Makefile
> >> b/drivers/gpu/drm/exynos/Makefile
> >> index 9710024..3b70668 100644
> >> --- a/drivers/gpu/drm/exynos/Makefile
> >> +++ b/drivers/gpu/drm/exynos/Makefile
> >> @@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+=
> >> exynos_drm_vidi.o
> >>   exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
> >>   exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
> >>   exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
> >> +exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
> >>
> >>   obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
> >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> >> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> >> index 73f02ac..09d884b 100644
> >> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> >> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> >> @@ -378,6 +378,12 @@ static int __init exynos_drm_init(void)
> >>   		goto out_fimc;
> >>   #endif
> >>
> >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> >> +	ret = platform_driver_register(&rotator_driver);
> >> +	if (ret < 0)
> >> +		goto out_rotator;
> >> +#endif
> >> +
> >>   #ifdef CONFIG_DRM_EXYNOS_IPP
> >>   	ret = platform_driver_register(&ipp_driver);
> >>   	if (ret < 0)
> >> @@ -406,6 +412,11 @@ out_drm:
> >>   out_ipp:
> >>   #endif
> >>
> >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> >> +	platform_driver_unregister(&rotator_driver);
> >> +out_rotator:
> >> +#endif
> >> +
> >>   #ifdef CONFIG_DRM_EXYNOS_FIMC
> >>   	platform_driver_unregister(&fimc_driver);
> >>   out_fimc:
> >> @@ -451,6 +462,10 @@ static void __exit exynos_drm_exit(void)
> >>   	platform_driver_unregister(&ipp_driver);
> >>   #endif
> >>
> >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> >> +	platform_driver_unregister(&rotator_driver);
> >> +#endif
> >> +
> >>   #ifdef CONFIG_DRM_EXYNOS_FIMC
> >>   	platform_driver_unregister(&fimc_driver);
> >>   #endif
> >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >> index 14f9490..a74e37c 100644
> >> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >> @@ -353,5 +353,6 @@ extern struct platform_driver
> >> exynos_drm_common_hdmi_driver;
> >>   extern struct platform_driver vidi_driver;
> >>   extern struct platform_driver g2d_driver;
> >>   extern struct platform_driver fimc_driver;
> >> +extern struct platform_driver rotator_driver;
> >>   extern struct platform_driver ipp_driver;
> >>   #endif
> >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> >> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> >> new file mode 100644
> >> index 0000000..121569c
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> >> @@ -0,0 +1,829 @@
> >> +/*
> >> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> >> + * Authors:
> >> + *	YoungJun Cho <yj44.cho@samsung.com>
> >> + *	Eunchul Kim <chulspro.kim@samsung.com>
> >> + *
> >> + * This program is free software; you can redistribute it and/or
> modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundationr
> >> + */
> >> +
> >> +#include <linux/kernel.h>
> >> +#include <linux/module.h>
> >> +#include <linux/err.h>
> >> +#include <linux/interrupt.h>
> >> +#include <linux/io.h>
> >> +#include <linux/platform_device.h>
> >> +#include <linux/clk.h>
> >> +#include <linux/pm_runtime.h>
> >> +
> >> +#include <drm/drmP.h>
> >> +#include <drm/exynos_drm.h>
> >> +#include "regs-rotator.h"
> >> +#include "exynos_drm.h"
> >> +#include "exynos_drm_ipp.h"
> >> +
> >> +/*
> >> + * Rotator supports image crop/rotator and input/output DMA
operations.
> >> + * input DMA reads image data from the memory.
> >> + * output DMA writes image data to memory.
> >> + */
> >> +
> >> +#define get_rot_context(dev)
> >> 	platform_get_drvdata(to_platform_device(dev))
> >> +#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
> >> +					struct rot_context, ippdrv);
> >> +#define rot_read(offset)		readl(rot->regs + (offset))
> >> +#define rot_write(cfg, offset)	writel(cfg, rot->regs + (offset))
> >> +
> >> +enum rot_irq_status {
> >> +	ROT_IRQ_STATUS_COMPLETE	= 8,
> >> +	ROT_IRQ_STATUS_ILLEGAL	= 9,
> >> +};
> >> +
> >> +/*
> >> + * A structure of limitation.
> >> + *
> >> + * @min_w: minimum width.
> >> + * @min_h: minimum height.
> >> + * @max_w: maximum width.
> >> + * @max_h: maximum height.
> >> + * @align: align size.
> >> + */
> >> +struct rot_limit {
> >> +	u32	min_w;
> >> +	u32	min_h;
> >> +	u32	max_w;
> >> +	u32	max_h;
> >> +	u32	align;
> >> +};
> >> +
> >> +/*
> >> + * A structure of limitation table.
> >> + *
> >> + * @ycbcr420_2p: case of YUV.
> >> + * @rgb888: case of RGB.
> >> + */
> >> +struct rot_limit_table {
> >> +	struct rot_limit	ycbcr420_2p;
> >> +	struct rot_limit	rgb888;
> >> +};
> >> +
> >> +/*
> >> + * A structure of rotator context.
> >> + * @ippdrv: prepare initialization using ippdrv.
> >> + * @regs_res: register resources.
> >> + * @regs: memory mapped io registers.
> >> + * @clock: rotator gate clock.
> >> + * @limit_tbl: limitation of rotator.
> >> + * @irq: irq number.
> >> + * @cur_buf_id: current operation buffer id.
> >> + * @suspended: suspended state.
> >> + */
> >> +struct rot_context {
> >> +	struct exynos_drm_ippdrv	ippdrv;
> >> +	struct resource	*regs_res;
> >> +	void __iomem	*regs;
> >> +	struct clk	*clock;
> >> +	struct rot_limit_table	*limit_tbl;
> >> +	int	irq;
> >> +	int	cur_buf_id[EXYNOS_DRM_OPS_MAX];
> >> +	bool	suspended;
> >> +};
> >> +
> >> +static void rotator_reg_set_irq(struct rot_context *rot, bool enable)
> >> +{
> >> +	u32 val = rot_read(ROT_CONFIG);
> >> +
> >> +	if (enable == true)
> >> +		val |= ROT_CONFIG_IRQ;
> >> +	else
> >> +		val &= ~ROT_CONFIG_IRQ;
> >> +
> >> +	rot_write(val, ROT_CONFIG);
> >> +}
> >> +
> >> +static u32 rotator_reg_get_format(struct rot_context *rot)
> >> +{
> >> +	u32 val = rot_read(ROT_CONTROL);
> >> +
> >> +	val &= ROT_CONTROL_FMT_MASK;
> >> +
> >> +	return val;
> >> +}
> >> +
> >> +static enum rot_irq_status rotator_reg_get_irq_status(struct
> rot_context
> >> *rot)
> >> +{
> >> +	u32 val = rot_read(ROT_STATUS);
> >> +
> >> +	val = ROT_STATUS_IRQ(val);
> >> +
> >> +	if (val == ROT_STATUS_IRQ_VAL_COMPLETE)
> >> +		return ROT_IRQ_STATUS_COMPLETE;
> >> +	else
> >
> > Remove else.
> 
> - done.
> 
> >
> >> +		return ROT_IRQ_STATUS_ILLEGAL;
> >> +}
> >> +
> >> +static irqreturn_t rotator_irq_handler(int irq, void *arg)
> >> +{
> >> +	struct rot_context *rot = arg;
> >> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> >> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
> >> +	struct drm_exynos_ipp_event_work *event_work = c_node->event_work;
> >> +	enum rot_irq_status irq_status;
> >> +	u32 val;
> >> +
> >> +	/* Get execution result */
> >> +	irq_status = rotator_reg_get_irq_status(rot);
> >> +
> >> +	/* clear status */
> >> +	val = rot_read(ROT_STATUS);
> >> +	val |= ROT_STATUS_IRQ_PENDING((u32)irq_status);
> >> +	rot_write(val, ROT_STATUS);
> >> +
> >> +	if (irq_status == ROT_IRQ_STATUS_COMPLETE) {
> >> +		event_work->ippdrv = ippdrv;
> >> +		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
> >> +			rot->cur_buf_id[EXYNOS_DRM_OPS_DST];
> >> +		queue_work(ippdrv->event_workq,
> >> +			(struct work_struct *)event_work);
> >> +	} else
> >> +		DRM_ERROR("the SFR is set illegally\n");
> >> +
> >> +	return IRQ_HANDLED;
> >> +}
> >> +
> >> +static void rotator_align_size(struct rot_context *rot, u32 fmt, u32
> >> *hsize,
> >> +		u32 *vsize)
> >> +{
> >> +	struct rot_limit_table *limit_tbl = rot->limit_tbl;
> >> +	struct rot_limit *limit;
> >> +	u32 mask, val;
> >> +
> >> +	/* Get size limit */
> >> +	if (fmt == ROT_CONTROL_FMT_RGB888)
> >> +		limit = &limit_tbl->rgb888;
> >> +	else
> >> +		limit = &limit_tbl->ycbcr420_2p;
> >> +
> >> +	/* Get mask for rounding to nearest aligned val */
> >> +	mask = ~((1 << limit->align) - 1);
> >> +
> >> +	/* Set aligned width */
> >> +	val = ROT_ALIGN(*hsize, limit->align, mask);
> >> +	if (val < limit->min_w)
> >> +		*hsize = ROT_MIN(limit->min_w, mask);
> >> +	else if (val > limit->max_w)
> >> +		*hsize = ROT_MAX(limit->max_w, mask);
> >> +	else
> >> +		*hsize = val;
> >> +
> >> +	/* Set aligned height */
> >> +	val = ROT_ALIGN(*vsize, limit->align, mask);
> >> +	if (val < limit->min_h)
> >> +		*vsize = ROT_MIN(limit->min_h, mask);
> >> +	else if (val > limit->max_h)
> >> +		*vsize = ROT_MAX(limit->max_h, mask);
> >> +	else
> >> +		*vsize = val;
> >> +}
> >> +
> >> +static int rotator_src_set_fmt(struct device *dev, u32 fmt)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	u32 val;
> >> +
> >> +	val = rot_read(ROT_CONTROL);
> >> +	val &= ~ROT_CONTROL_FMT_MASK;
> >> +
> >> +	switch (fmt) {
> >> +	case DRM_FORMAT_NV12:
> >> +		val |= ROT_CONTROL_FMT_YCBCR420_2P;
> >> +		break;
> >> +	case DRM_FORMAT_XRGB8888:
> >> +		val |= ROT_CONTROL_FMT_RGB888;
> >> +		break;
> >> +	default:
> >> +		DRM_ERROR("invalid image format\n");
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	rot_write(val, ROT_CONTROL);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_src_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;
> >> +	u32 val;
> >> +
> >> +	/* 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 */
> >> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> >> +	rot_write(val, ROT_SRC_BUF_SIZE);
> >> +
> >> +	/* Set crop image position configuration */
> >> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> >> +	rot_write(val, ROT_SRC_CROP_POS);
> >> +	val = ROT_SRC_CROP_SIZE_H(pos->h) | ROT_SRC_CROP_SIZE_W(pos->w);
> >> +	rot_write(val, ROT_SRC_CROP_SIZE);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_src_set_addr(struct device *dev,
> >> +		struct drm_exynos_ipp_buf_info *buf_info,
> >> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> >> +	u32 val, fmt, hsize, vsize;
> >> +	int i;
> >> +
> >> +	/* Set current buf_id */
> >> +	rot->cur_buf_id[EXYNOS_DRM_OPS_SRC] = buf_id;
> >> +
> >> +	switch (buf_type) {
> >> +	case IPP_BUF_ENQUEUE:
> >> +		/* Set address configuration */
> >> +		for_each_ipp_planar(i)
> >> +			addr[i] = buf_info->base[i];
> >
> > Check NULL.
> 
> - If not copy this state, we need to memset about addr.
>    no need check null.
> 
> >
> >> +
> >> +		/* Get format */
> >> +		fmt = rotator_reg_get_format(rot);
> >> +
> >> +		/* Re-set cb planar for NV12 format */
> >> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> >> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
> > 0x00)) {
> >
> > What is 0x00?
> 
> - It is NULL, I changed !addr instead of addr == 0x00
> 
> >
> >> +
> >> +			val = rot_read(ROT_SRC_BUF_SIZE);
> >> +			hsize = ROT_GET_BUF_SIZE_W(val);
> >> +			vsize = ROT_GET_BUF_SIZE_H(val);
> >> +
> >> +			/* Set cb planar */
> >> +			addr[EXYNOS_DRM_PLANAR_CB] =
> >> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
> >> +		}
> >> +
> >> +		for_each_ipp_planar(i)
> >> +			rot_write(addr[i], ROT_SRC_BUF_ADDR(i));
> >> +		break;
> >> +	case IPP_BUF_DEQUEUE:
> >> +		for_each_ipp_planar(i)
> >> +			rot_write(0x0, ROT_SRC_BUF_ADDR(i));
> >> +		break;
> >> +	default:
> >> +		/* Nothing to do */
> >> +		break;
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_dst_set_transf(struct device *dev,
> >> +		enum drm_exynos_degree degree,
> >> +		enum drm_exynos_flip flip)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	u32 val;
> >> +
> >> +	/* Set transform configuration */
> >> +	val = rot_read(ROT_CONTROL);
> >> +	val &= ~ROT_CONTROL_FLIP_MASK;
> >> +
> >> +	switch (flip) {
> >> +	case EXYNOS_DRM_FLIP_VERTICAL:
> >> +		val |= ROT_CONTROL_FLIP_VERTICAL;
> >> +		break;
> >> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> >> +		val |= ROT_CONTROL_FLIP_HORIZONTAL;
> >> +		break;
> >> +	default:
> >> +		/* Flip None */
> >> +		break;
> >> +	}
> >> +
> >> +	val &= ~ROT_CONTROL_ROT_MASK;
> >> +
> >> +	switch (degree) {
> >> +	case EXYNOS_DRM_DEGREE_90:
> >> +		val |= ROT_CONTROL_ROT_90;
> >> +		break;
> >> +	case EXYNOS_DRM_DEGREE_180:
> >> +		val |= ROT_CONTROL_ROT_180;
> >> +		break;
> >> +	case EXYNOS_DRM_DEGREE_270:
> >> +		val |= ROT_CONTROL_ROT_270;
> >> +		break;
> >> +	default:
> >> +		/* Rotation 0 Degree */
> >> +		break;
> >> +	}
> >> +
> >> +	rot_write(val, ROT_CONTROL);
> >> +
> >> +	/* Check degree for setting buffer size swap */
> >> +	if ((degree == EXYNOS_DRM_DEGREE_90) ||
> >> +		(degree == EXYNOS_DRM_DEGREE_270))
> >> +		return 1;
> >
> > Correct return type. This function should return 0 or negative.
> 
> - no ~ this return type is boolean true or false.
>    but we need to error handling so, we use integer as you know
>    we reviewed this routine at our local git from our team(you and me).
> 
> >
> >> +	else
> >> +		return 0;
> >
> > Ditto.
> 
> - ditto.
> 
> >
> >> +}
> >> +
> >> +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 val, fmt, hsize, vsize;
> >> +
> >> +	/* Get format */
> >> +	fmt = rotator_reg_get_format(rot);
> >
> > Check if fmt is valid or not.
> 
> - added rotator_check_fmt()
> 
> >
> >> +
> >> +	/* Align buffer size */
> >> +	hsize = sz->hsize;
> >> +	vsize = sz->vsize;
> >> +	rotator_align_size(rot, fmt, &hsize, &vsize);
> >> +
> >> +	/* Set buffer size configuration */
> >> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> >> +	rot_write(val, ROT_DST_BUF_SIZE);
> >> +
> >> +	/* Set crop image position configuration */
> >> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> >> +	rot_write(val, ROT_DST_CROP_POS);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_dst_set_addr(struct device *dev,
> >> +		struct drm_exynos_ipp_buf_info *buf_info,
> >> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> >> +	u32 val, fmt, hsize, vsize;
> >> +	int i;
> >> +
> >> +	/* Set current buf_id */
> >> +	rot->cur_buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
> >> +
> >> +	switch (buf_type) {
> >> +	case IPP_BUF_ENQUEUE:
> >> +		/* Set address configuration */
> >> +		for_each_ipp_planar(i)
> >> +			addr[i] = buf_info->base[i];
> >> +
> >> +		/* Get format */
> >> +		fmt = rotator_reg_get_format(rot);
> >
> > Check if fmt is valid or not.
> 
> - done.
> 
> >
> >> +
> >> +		/* Re-set cb planar for NV12 format */
> >> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> >> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
> > 0x00)) {
> >> +			/* Get buf size */
> >> +			val = rot_read(ROT_DST_BUF_SIZE);
> >> +
> >> +			hsize = ROT_GET_BUF_SIZE_W(val);
> >> +			vsize = ROT_GET_BUF_SIZE_H(val);
> >> +
> >> +			/* Set cb planar */
> >> +			addr[EXYNOS_DRM_PLANAR_CB] =
> >> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
> >> +		}
> >> +
> >> +		for_each_ipp_planar(i)
> >> +			rot_write(addr[i], ROT_DST_BUF_ADDR(i));
> >> +		break;
> >> +	case IPP_BUF_DEQUEUE:
> >> +		for_each_ipp_planar(i)
> >> +			rot_write(0x0, ROT_DST_BUF_ADDR(i));
> >> +		break;
> >> +	default:
> >> +		/* Nothing to do */
> >> +		break;
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static struct exynos_drm_ipp_ops rot_src_ops = {
> >> +	.set_fmt	=	rotator_src_set_fmt,
> >> +	.set_size	=	rotator_src_set_size,
> >> +	.set_addr	=	rotator_src_set_addr,
> >> +};
> >> +
> >> +static struct exynos_drm_ipp_ops rot_dst_ops = {
> >> +	.set_transf	=	rotator_dst_set_transf,
> >> +	.set_size	=	rotator_dst_set_size,
> >> +	.set_addr	=	rotator_dst_set_addr,
> >> +};
> >> +
> >> +static int rotator_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
> >> +{
> >> +	struct drm_exynos_ipp_prop_list *prop_list;
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
> >> +	if (!prop_list) {
> >> +		DRM_ERROR("failed to alloc property list.\n");
> >> +		return -ENOMEM;
> >> +	}
> >> +
> >> +	/*ToDo fix support function list*/
> >> +
> >> +	prop_list->version = 1;
> >> +	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
> >> +				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
> >> +	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
> >> +				(1 << EXYNOS_DRM_DEGREE_90) |
> >> +				(1 << EXYNOS_DRM_DEGREE_180) |
> >> +				(1 << EXYNOS_DRM_DEGREE_270);
> >> +	prop_list->csc = 0;
> >> +	prop_list->crop = 0;
> >> +	prop_list->scale = 0;
> >> +
> >> +	ippdrv->prop_list = prop_list;
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_ippdrv_check_property(struct device *dev,
> >> +		struct drm_exynos_ipp_property *property)
> >> +{
> >> +	struct drm_exynos_ipp_config *src_config =
> >> +
> > &property->config[EXYNOS_DRM_OPS_SRC];
> >> +	struct drm_exynos_ipp_config *dst_config =
> >> +
> > &property->config[EXYNOS_DRM_OPS_DST];
> >> +	struct drm_exynos_pos *src_pos = &src_config->pos;
> >> +	struct drm_exynos_pos *dst_pos = &dst_config->pos;
> >> +	struct drm_exynos_sz *src_sz = &src_config->sz;
> >> +	struct drm_exynos_sz *dst_sz = &dst_config->sz;
> >> +	bool swap = false;
> >> +
> >> +	/* Check format configuration */
> >> +	if (src_config->fmt != dst_config->fmt) {
> >> +		DRM_DEBUG_KMS("%s:not support csc feature\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	switch (src_config->fmt) {
> >> +	case DRM_FORMAT_XRGB8888:
> >> +	case DRM_FORMAT_NV12:
> >> +		/* No problem */
> >> +		break;
> >> +	default:
> >> +		DRM_DEBUG_KMS("%s:not support format\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >
> > Use macro instead of switch-case. this just checks only format type.
> 
> - I don't thing so, If we make macro about this.
>    then we got some confusion about this macro at next change.
>    this case switch-case is better.
>    Do you prefer this ? please one more comment.
> 
> #define drm_check_fmt(fmt) if (fmt == DRM_FORMAT_XRGB8888 || fmt ==
> DRM_FORMAT_NV12) \
> 					return true;

#define drm_check_fmt(fmt)		((fmt & (DRM_FORMAT_XRGB8888 |
DRM_FORMAT_NV12)) ? true : false)

if (drm_check_fmt(src_config->fmt))
	Something;
else
	Something;

> 
> >
> >> +
> >> +	/* Check transform configuration */
> >> +	if (src_config->degree != EXYNOS_DRM_DEGREE_0) {
> >> +		DRM_DEBUG_KMS("%s:not support source-side rotation\n",
> >> +								__func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	switch (dst_config->degree) {
> >> +	case EXYNOS_DRM_DEGREE_90:
> >> +	case EXYNOS_DRM_DEGREE_270:
> >> +		swap = true;
> >> +	case EXYNOS_DRM_DEGREE_0:
> >> +	case EXYNOS_DRM_DEGREE_180:
> >> +		/* No problem */
> >> +		break;
> >> +	default:
> >> +		DRM_DEBUG_KMS("%s:invalid degree\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	if (src_config->flip != EXYNOS_DRM_FLIP_NONE) {
> >> +		DRM_DEBUG_KMS("%s:not support source-side flip\n",
> > __func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	switch (dst_config->flip) {
> >> +	case EXYNOS_DRM_FLIP_NONE:
> >> +	case EXYNOS_DRM_FLIP_VERTICAL:
> >> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> >> +		/* No problem */
> >> +		break;
> >> +	default:
> >> +		DRM_DEBUG_KMS("%s:invalid flip\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >
> > Use macro instead of switch-case. this just checks only flip type.
> 
> - ditto. please one more comment.
>   in my opinion: I prefer enumeration use switch-case.

What does each case do? Just check? If so, use macro as I mentioned. We
can't accept this codes.

> 
> >
> >> +
> >> +	/* Check size configuration */
> >> +	if ((src_pos->x + src_pos->w > src_sz->hsize) ||
> >> +		(src_pos->y + src_pos->h > src_sz->vsize)) {
> >> +		DRM_DEBUG_KMS("%s:out of source buffer bound\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	if (swap) {
> >> +		if ((dst_pos->x + dst_pos->h > dst_sz->vsize) ||
> >> +			(dst_pos->y + dst_pos->w > dst_sz->hsize)) {
> >> +			DRM_DEBUG_KMS("%s:out of destination buffer
> > bound\n",
> >> +								__func__);
> >> +			return -EINVAL;
> >> +		}
> >> +
> >> +		if ((src_pos->w != dst_pos->h) || (src_pos->h !=
> > dst_pos->w))
> >> {
> >> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
> >> +								__func__);
> >> +			return -EINVAL;
> >> +		}
> >> +	} else {
> >> +		if ((dst_pos->x + dst_pos->w > dst_sz->hsize) ||
> >> +			(dst_pos->y + dst_pos->h > dst_sz->vsize)) {
> >> +			DRM_DEBUG_KMS("%s:out of destination buffer
> > bound\n",
> >> +								__func__);
> >> +			return -EINVAL;
> >> +		}
> >> +
> >> +		if ((src_pos->w != dst_pos->w) || (src_pos->h !=
> > dst_pos->h))
> >> {
> >> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
> >> +								__func__);
> >> +			return -EINVAL;
> >> +		}
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_ippdrv_start(struct device *dev, enum
> >> drm_exynos_ipp_cmd cmd)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	u32 val;
> >> +
> >> +	if (rot->suspended) {
> >> +		DRM_ERROR("suspended state\n");
> >> +		return -EPERM;
> >> +	}
> >> +
> >> +	if (cmd != IPP_CMD_M2M) {
> >> +		DRM_ERROR("not support cmd: %d\n", cmd);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	/* Set interrupt enable */
> >> +	rotator_reg_set_irq(rot, true);
> >> +
> >> +	val = rot_read(ROT_CONTROL);
> >> +	val |= ROT_CONTROL_START;
> >> +
> >> +	rot_write(val, ROT_CONTROL);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int __devinit rotator_probe(struct platform_device *pdev)
> >> +{
> >> +	struct device *dev = &pdev->dev;
> >> +	struct rot_context *rot;
> >> +	struct resource *res;
> >> +	struct exynos_drm_ippdrv *ippdrv;
> >> +	int ret;
> >> +
> >> +	rot = kzalloc(sizeof(*rot), GFP_KERNEL);
> >> +	if (!rot) {
> >> +		dev_err(dev, "failed to allocate rot\n");
> >> +		return -ENOMEM;
> >> +	}
> >> +
> >> +	rot->limit_tbl = (struct rot_limit_table *)
> >> +				platform_get_device_id(pdev)->driver_data;
> >> +
> >> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> +	if (!res) {
> >> +		dev_err(dev, "failed to find registers\n");
> >> +		ret = -ENOENT;
> >> +		goto err_get_resource;
> >> +	}
> >> +
> >> +	rot->regs_res = request_mem_region(res->start, resource_size(res),
> >> +
> > dev_name(dev));
> >> +	if (!rot->regs_res) {
> >> +		dev_err(dev, "failed to claim register region\n");
> >> +		ret = -ENOENT;
> >> +		goto err_get_resource;
> >> +	}
> >> +
> >> +	rot->regs = ioremap(res->start, resource_size(res));
> >> +	if (!rot->regs) {
> >> +		dev_err(dev, "failed to map register\n");
> >> +		ret = -ENXIO;
> >> +		goto err_ioremap;
> >> +	}
> >> +
> >> +	rot->irq = platform_get_irq(pdev, 0);
> >> +	if (rot->irq < 0) {
> >> +		dev_err(dev, "failed to get irq\n");
> >> +		ret = rot->irq;
> >> +		goto err_get_irq;
> >> +	}
> >> +
> >> +	ret = request_threaded_irq(rot->irq, NULL, rotator_irq_handler,
> >> +					IRQF_ONESHOT, "drm_rotator", rot);
> >> +	if (ret < 0) {
> >> +		dev_err(dev, "failed to request irq\n");
> >> +		goto err_get_irq;
> >> +	}
> >> +
> >> +	rot->clock = clk_get(dev, "rotator");
> >> +	if (IS_ERR_OR_NULL(rot->clock)) {
> >> +		dev_err(dev, "failed to get clock\n");
> >> +		ret = PTR_ERR(rot->clock);
> >> +		goto err_clk_get;
> >> +	}
> >> +
> >> +	pm_runtime_enable(dev);
> >> +
> >> +	ippdrv = &rot->ippdrv;
> >> +	ippdrv->dev = dev;
> >> +	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &rot_src_ops;
> >> +	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &rot_dst_ops;
> >> +	ippdrv->check_property = rotator_ippdrv_check_property;
> >> +	ippdrv->start = rotator_ippdrv_start;
> >> +	ret = rotator_init_prop_list(ippdrv);
> >> +	if (ret < 0) {
> >> +		dev_err(dev, "failed to init property list.\n");
> >> +		goto err_ippdrv_register;
> >> +	}
> >> +
> >> +	DRM_DEBUG_KMS("%s:ippdrv[0x%x]\n", __func__, (int)ippdrv);
> >> +
> >> +	platform_set_drvdata(pdev, rot);
> >> +
> >> +	ret = exynos_drm_ippdrv_register(ippdrv);
> >> +	if (ret < 0) {
> >> +		dev_err(dev, "failed to register drm rotator device\n");
> >> +		kfree(ippdrv->prop_list);
> >> +		goto err_ippdrv_register;
> >> +	}
> >> +
> >> +	dev_info(dev, "The exynos rotator is probed successfully\n");
> >> +
> >> +	return 0;
> >> +
> >> +err_ippdrv_register:
> >> +	pm_runtime_disable(dev);
> >> +	clk_put(rot->clock);
> >> +err_clk_get:
> >> +	free_irq(rot->irq, rot);
> >> +err_get_irq:
> >> +	iounmap(rot->regs);
> >> +err_ioremap:
> >> +	release_resource(rot->regs_res);
> >> +	kfree(rot->regs_res);
> >> +err_get_resource:
> >> +	kfree(rot);
> >> +	return ret;
> >> +}
> >> +
> >> +static int __devexit rotator_remove(struct platform_device *pdev)
> >> +{
> >> +	struct device *dev = &pdev->dev;
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> >> +
> >> +	kfree(ippdrv->prop_list);
> >> +	exynos_drm_ippdrv_unregister(ippdrv);
> >> +
> >> +	pm_runtime_disable(dev);
> >> +	clk_put(rot->clock);
> >> +
> >> +	free_irq(rot->irq, rot);
> >> +
> >> +	iounmap(rot->regs);
> >> +
> >> +	release_resource(rot->regs_res);
> >> +	kfree(rot->regs_res);
> >> +
> >> +	kfree(rot);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +struct rot_limit_table rot_limit_tbl = {
> >> +	.ycbcr420_2p = {
> >> +		.min_w = 32,
> >> +		.min_h = 32,
> >> +		.max_w = SZ_32K,
> >> +		.max_h = SZ_32K,
> >> +		.align = 3,
> >> +	},
> >> +	.rgb888 = {
> >> +		.min_w = 8,
> >> +		.min_h = 8,
> >> +		.max_w = SZ_8K,
> >> +		.max_h = SZ_8K,
> >> +		.align = 2,
> >> +	},
> >> +};
> >> +
> >> +struct platform_device_id rotator_driver_ids[] = {
> >> +	{
> >> +		.name		= "exynos-rot",
> >> +		.driver_data	= (unsigned long)&rot_limit_tbl,
> >> +	},
> >> +	{},
> >> +};
> >> +
> >> +static int rotator_clk_crtl(struct rot_context *rot, bool enable)
> >> +{
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	if (enable) {
> >> +		clk_enable(rot->clock);
> >> +		rot->suspended = false;
> >> +	} else {
> >> +		clk_disable(rot->clock);
> >> +		rot->suspended = true;
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +
> >> +#ifdef CONFIG_PM_SLEEP
> >> +static int rotator_suspend(struct device *dev)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +
> >> +	/* ToDo */
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	if (pm_runtime_suspended(dev))
> >> +		return 0;
> >> +
> >> +	return rotator_clk_crtl(rot, false);
> >> +}
> >> +
> >> +static int rotator_resume(struct device *dev)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +
> >> +	/* ToDo */
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	if (!pm_runtime_suspended(dev))
> >> +		return rotator_clk_crtl(rot, true);
> >> +
> >> +	return 0;
> >> +}
> >> +#endif
> >> +
> >> +#ifdef CONFIG_PM_RUNTIME
> >> +static int rotator_runtime_suspend(struct device *dev)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +
> >> +	/* ToDo */
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	return  rotator_clk_crtl(rot, false);
> >> +}
> >> +
> >> +static int rotator_runtime_resume(struct device *dev)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +
> >> +	/* ToDo */
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	return  rotator_clk_crtl(rot, true);
> >> +}
> >> +#endif
> >> +
> >> +static const struct dev_pm_ops rotator_pm_ops = {
> >> +	SET_SYSTEM_SLEEP_PM_OPS(rotator_suspend, rotator_resume)
> >> +	SET_RUNTIME_PM_OPS(rotator_runtime_suspend, rotator_runtime_resume,
> >> +
> > NULL)
> >> +};
> >> +
> >> +struct platform_driver rotator_driver = {
> >> +	.probe		= rotator_probe,
> >> +	.remove		= __devexit_p(rotator_remove),
> >> +	.id_table	= rotator_driver_ids,
> >> +	.driver		= {
> >> +		.name	= "exynos-rot",
> >> +		.owner	= THIS_MODULE,
> >> +		.pm	= &rotator_pm_ops,
> >> +	},
> >> +};
> >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> >> b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> >> new file mode 100644
> >> index 0000000..fe929c9
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> >> @@ -0,0 +1,13 @@
> >> +/*
> >> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> >> + * Authors: YoungJun Cho <yj44.cho@samsung.com>
> >> + *
> >> + * This program is free software; you can redistribute it and/or
> modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundationr
> >> + */
> >> +
> >> +#ifndef	_EXYNOS_DRM_ROTATOR_H_
> >> +#define	_EXYNOS_DRM_ROTATOR_H_
> >> +
> >> +#endif
> >> diff --git a/drivers/gpu/drm/exynos/regs-rotator.h
> >> b/drivers/gpu/drm/exynos/regs-rotator.h
> >> new file mode 100644
> >> index 0000000..a09ac6e
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/exynos/regs-rotator.h
> >> @@ -0,0 +1,73 @@
> >> +/* drivers/gpu/drm/exynos/regs-rotator.h
> >> + *
> >> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> >> + *		http://www.samsung.com/
> >> + *
> >> + * Register definition file for Samsung Rotator Interface (Rotator)
> >> driver
> >> + *
> >> + * This program is free software; you can redistribute it and/or
> modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundation.
> >> +*/
> >> +
> >> +#ifndef EXYNOS_REGS_ROTATOR_H
> >> +#define EXYNOS_REGS_ROTATOR_H
> >> +
> >> +/* Configuration */
> >> +#define ROT_CONFIG			0x00
> >> +#define ROT_CONFIG_IRQ			(3 << 8)
> >> +
> >> +/* Image Control */
> >> +#define ROT_CONTROL			0x10
> >> +#define ROT_CONTROL_PATTERN_WRITE	(1 << 16)
> >> +#define ROT_CONTROL_FMT_YCBCR420_2P	(1 << 8)
> >> +#define ROT_CONTROL_FMT_RGB888		(6 << 8)
> >> +#define ROT_CONTROL_FMT_MASK		(7 << 8)
> >> +#define ROT_CONTROL_FLIP_VERTICAL	(2 << 6)
> >> +#define ROT_CONTROL_FLIP_HORIZONTAL	(3 << 6)
> >> +#define ROT_CONTROL_FLIP_MASK		(3 << 6)
> >> +#define ROT_CONTROL_ROT_90		(1 << 4)
> >> +#define ROT_CONTROL_ROT_180		(2 << 4)
> >> +#define ROT_CONTROL_ROT_270		(3 << 4)
> >> +#define ROT_CONTROL_ROT_MASK		(3 << 4)
> >> +#define ROT_CONTROL_START		(1 << 0)
> >> +
> >> +/* Status */
> >> +#define ROT_STATUS			0x20
> >> +#define ROT_STATUS_IRQ_PENDING(x)	(1 << (x))
> >> +#define ROT_STATUS_IRQ(x)		(((x) >> 8) & 0x3)
> >> +#define ROT_STATUS_IRQ_VAL_COMPLETE	1
> >> +#define ROT_STATUS_IRQ_VAL_ILLEGAL	2
> >> +
> >> +/* Buffer Address */
> >> +#define ROT_SRC_BUF_ADDR(n)		(0x30 + ((n) << 2))
> >> +#define ROT_DST_BUF_ADDR(n)		(0x50 + ((n) << 2))
> >> +
> >> +/* Buffer Size */
> >> +#define ROT_SRC_BUF_SIZE		0x3c
> >> +#define ROT_DST_BUF_SIZE		0x5c
> >> +#define ROT_SET_BUF_SIZE_H(x)		((x) << 16)
> >> +#define ROT_SET_BUF_SIZE_W(x)		((x) << 0)
> >> +#define ROT_GET_BUF_SIZE_H(x)		((x) >> 16)
> >> +#define ROT_GET_BUF_SIZE_W(x)		((x) & 0xffff)
> >> +
> >> +/* Crop Position */
> >> +#define ROT_SRC_CROP_POS		0x40
> >> +#define ROT_DST_CROP_POS		0x60
> >> +#define ROT_CROP_POS_Y(x)		((x) << 16)
> >> +#define ROT_CROP_POS_X(x)		((x) << 0)
> >> +
> >> +/* Source Crop Size */
> >> +#define ROT_SRC_CROP_SIZE		0x44
> >> +#define ROT_SRC_CROP_SIZE_H(x)		((x) << 16)
> >> +#define ROT_SRC_CROP_SIZE_W(x)		((x) << 0)
> >> +
> >> +/* Round to nearest aligned value */
> >> +#define ROT_ALIGN(x, align, mask)	(((x) + (1 << ((align) - 1))) &
> >> (mask))
> >> +/* Minimum limit value */
> >> +#define ROT_MIN(min, mask)		(((min) + ~(mask)) & (mask))
> >> +/* Maximum limit value */
> >> +#define ROT_MAX(max, mask)		((max) & (mask))
> >> +
> >> +#endif /* EXYNOS_REGS_ROTATOR_H */
> >> +
> >> --
> >> 1.7.0.4
> >
> >

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
  2012-12-12  9:26     ` Eunchul Kim
  2012-12-12  9:41       ` Inki Dae
@ 2012-12-12  9:46       ` Inki Dae
  2012-12-12 11:10         ` Eunchul Kim
  1 sibling, 1 reply; 18+ messages in thread
From: Inki Dae @ 2012-12-12  9:46 UTC (permalink / raw)
  To: 'Eunchul Kim'
  Cc: jy0.jeon, sw0312.kim, jaejoon.seo, kyungmin.park, dri-devel, jmock.shin


One more comment.


> -----Original Message-----
> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> Sent: Wednesday, December 12, 2012 6:26 PM
> To: Inki Dae
> Cc: dri-devel@lists.freedesktop.org; jy0.jeon@samsung.com;
> yj44.cho@samsung.com; jmock.shin@samsung.com; jaejoon.seo@samsung.com;
> kyungmin.park@samsung.com; sw0312.kim@samsung.com; Joonyoung Shim
> Subject: Re: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> 
> Thank's your comment.
> 
> I answer your comment. please check that.
> 
> Thank's
> 
> BR
> Eunchul Kim
> 
> On 12/12/2012 05:29 PM, Inki Dae wrote:
> >
> >
> >> -----Original Message-----
> >> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> >> Sent: Wednesday, December 12, 2012 4:35 PM
> >> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
> >> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com; jmock.shin@samsung.com;
> >> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
> >> chulspro.kim@samsung.com
> >> Subject: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> >>
> >> Rotator supports rotation/crop/flip and input/output DMA operations
> >> Rotator ipp driver supports 90,180,270 degree rotaion and vertical,
> >> horizontal flip.
> >> and has some limitations(source and destination format have to be same,
> no
> >> scaler)
> >>
> >> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
> >> Signed-off-by: Youngjun Cho <yj44.cho@samsung.com>
> >> ---
> >>   drivers/gpu/drm/exynos/Kconfig              |    7 +
> >>   drivers/gpu/drm/exynos/Makefile             |    1 +
> >>   drivers/gpu/drm/exynos/exynos_drm_drv.c     |   15 +
> >>   drivers/gpu/drm/exynos/exynos_drm_drv.h     |    1 +
> >>   drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829
> >> +++++++++++++++++++++++++++
> >>   drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
> >>   drivers/gpu/drm/exynos/regs-rotator.h       |   73 +++
> >>   7 files changed, 939 insertions(+), 0 deletions(-)
> >>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
> >>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
> >>   create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
> >>
> >> diff --git a/drivers/gpu/drm/exynos/Kconfig
> >> b/drivers/gpu/drm/exynos/Kconfig
> >> index 4915ab6..4860835 100644
> >> --- a/drivers/gpu/drm/exynos/Kconfig
> >> +++ b/drivers/gpu/drm/exynos/Kconfig
> >> @@ -57,3 +57,10 @@ config DRM_EXYNOS_FIMC
> >>   	depends on DRM_EXYNOS_IPP
> >>   	help
> >>   	  Choose this option if you want to use Exynos FIMC for DRM.
> >> +
> >> +config DRM_EXYNOS_ROTATOR
> >> +	bool "Exynos DRM Rotator"
> >> +	depends on DRM_EXYNOS_IPP
> >> +	help
> >> +	  Choose this option if you want to use Exynos Rotator for DRM.
> >> +
> >> diff --git a/drivers/gpu/drm/exynos/Makefile
> >> b/drivers/gpu/drm/exynos/Makefile
> >> index 9710024..3b70668 100644
> >> --- a/drivers/gpu/drm/exynos/Makefile
> >> +++ b/drivers/gpu/drm/exynos/Makefile
> >> @@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+=
> >> exynos_drm_vidi.o
> >>   exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
> >>   exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
> >>   exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
> >> +exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
> >>
> >>   obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
> >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> >> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> >> index 73f02ac..09d884b 100644
> >> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> >> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> >> @@ -378,6 +378,12 @@ static int __init exynos_drm_init(void)
> >>   		goto out_fimc;
> >>   #endif
> >>
> >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> >> +	ret = platform_driver_register(&rotator_driver);
> >> +	if (ret < 0)
> >> +		goto out_rotator;
> >> +#endif
> >> +
> >>   #ifdef CONFIG_DRM_EXYNOS_IPP
> >>   	ret = platform_driver_register(&ipp_driver);
> >>   	if (ret < 0)
> >> @@ -406,6 +412,11 @@ out_drm:
> >>   out_ipp:
> >>   #endif
> >>
> >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> >> +	platform_driver_unregister(&rotator_driver);
> >> +out_rotator:
> >> +#endif
> >> +
> >>   #ifdef CONFIG_DRM_EXYNOS_FIMC
> >>   	platform_driver_unregister(&fimc_driver);
> >>   out_fimc:
> >> @@ -451,6 +462,10 @@ static void __exit exynos_drm_exit(void)
> >>   	platform_driver_unregister(&ipp_driver);
> >>   #endif
> >>
> >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> >> +	platform_driver_unregister(&rotator_driver);
> >> +#endif
> >> +
> >>   #ifdef CONFIG_DRM_EXYNOS_FIMC
> >>   	platform_driver_unregister(&fimc_driver);
> >>   #endif
> >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >> index 14f9490..a74e37c 100644
> >> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> >> @@ -353,5 +353,6 @@ extern struct platform_driver
> >> exynos_drm_common_hdmi_driver;
> >>   extern struct platform_driver vidi_driver;
> >>   extern struct platform_driver g2d_driver;
> >>   extern struct platform_driver fimc_driver;
> >> +extern struct platform_driver rotator_driver;
> >>   extern struct platform_driver ipp_driver;
> >>   #endif
> >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> >> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> >> new file mode 100644
> >> index 0000000..121569c
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> >> @@ -0,0 +1,829 @@
> >> +/*
> >> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> >> + * Authors:
> >> + *	YoungJun Cho <yj44.cho@samsung.com>
> >> + *	Eunchul Kim <chulspro.kim@samsung.com>
> >> + *
> >> + * This program is free software; you can redistribute it and/or
> modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundationr
> >> + */
> >> +
> >> +#include <linux/kernel.h>
> >> +#include <linux/module.h>
> >> +#include <linux/err.h>
> >> +#include <linux/interrupt.h>
> >> +#include <linux/io.h>
> >> +#include <linux/platform_device.h>
> >> +#include <linux/clk.h>
> >> +#include <linux/pm_runtime.h>
> >> +
> >> +#include <drm/drmP.h>
> >> +#include <drm/exynos_drm.h>
> >> +#include "regs-rotator.h"
> >> +#include "exynos_drm.h"
> >> +#include "exynos_drm_ipp.h"
> >> +
> >> +/*
> >> + * Rotator supports image crop/rotator and input/output DMA
operations.
> >> + * input DMA reads image data from the memory.
> >> + * output DMA writes image data to memory.
> >> + */
> >> +
> >> +#define get_rot_context(dev)
> >> 	platform_get_drvdata(to_platform_device(dev))
> >> +#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
> >> +					struct rot_context, ippdrv);
> >> +#define rot_read(offset)		readl(rot->regs + (offset))
> >> +#define rot_write(cfg, offset)	writel(cfg, rot->regs + (offset))
> >> +
> >> +enum rot_irq_status {
> >> +	ROT_IRQ_STATUS_COMPLETE	= 8,
> >> +	ROT_IRQ_STATUS_ILLEGAL	= 9,
> >> +};
> >> +
> >> +/*
> >> + * A structure of limitation.
> >> + *
> >> + * @min_w: minimum width.
> >> + * @min_h: minimum height.
> >> + * @max_w: maximum width.
> >> + * @max_h: maximum height.
> >> + * @align: align size.
> >> + */
> >> +struct rot_limit {
> >> +	u32	min_w;
> >> +	u32	min_h;
> >> +	u32	max_w;
> >> +	u32	max_h;
> >> +	u32	align;
> >> +};
> >> +
> >> +/*
> >> + * A structure of limitation table.
> >> + *
> >> + * @ycbcr420_2p: case of YUV.
> >> + * @rgb888: case of RGB.
> >> + */
> >> +struct rot_limit_table {
> >> +	struct rot_limit	ycbcr420_2p;
> >> +	struct rot_limit	rgb888;
> >> +};
> >> +
> >> +/*
> >> + * A structure of rotator context.
> >> + * @ippdrv: prepare initialization using ippdrv.
> >> + * @regs_res: register resources.
> >> + * @regs: memory mapped io registers.
> >> + * @clock: rotator gate clock.
> >> + * @limit_tbl: limitation of rotator.
> >> + * @irq: irq number.
> >> + * @cur_buf_id: current operation buffer id.
> >> + * @suspended: suspended state.
> >> + */
> >> +struct rot_context {
> >> +	struct exynos_drm_ippdrv	ippdrv;
> >> +	struct resource	*regs_res;
> >> +	void __iomem	*regs;
> >> +	struct clk	*clock;
> >> +	struct rot_limit_table	*limit_tbl;
> >> +	int	irq;
> >> +	int	cur_buf_id[EXYNOS_DRM_OPS_MAX];
> >> +	bool	suspended;
> >> +};
> >> +
> >> +static void rotator_reg_set_irq(struct rot_context *rot, bool enable)
> >> +{
> >> +	u32 val = rot_read(ROT_CONFIG);
> >> +
> >> +	if (enable == true)
> >> +		val |= ROT_CONFIG_IRQ;
> >> +	else
> >> +		val &= ~ROT_CONFIG_IRQ;
> >> +
> >> +	rot_write(val, ROT_CONFIG);
> >> +}
> >> +
> >> +static u32 rotator_reg_get_format(struct rot_context *rot)
> >> +{
> >> +	u32 val = rot_read(ROT_CONTROL);
> >> +
> >> +	val &= ROT_CONTROL_FMT_MASK;
> >> +
> >> +	return val;
> >> +}
> >> +
> >> +static enum rot_irq_status rotator_reg_get_irq_status(struct
> rot_context
> >> *rot)
> >> +{
> >> +	u32 val = rot_read(ROT_STATUS);
> >> +
> >> +	val = ROT_STATUS_IRQ(val);
> >> +
> >> +	if (val == ROT_STATUS_IRQ_VAL_COMPLETE)
> >> +		return ROT_IRQ_STATUS_COMPLETE;
> >> +	else
> >
> > Remove else.
> 
> - done.
> 
> >
> >> +		return ROT_IRQ_STATUS_ILLEGAL;
> >> +}
> >> +
> >> +static irqreturn_t rotator_irq_handler(int irq, void *arg)
> >> +{
> >> +	struct rot_context *rot = arg;
> >> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> >> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
> >> +	struct drm_exynos_ipp_event_work *event_work = c_node->event_work;
> >> +	enum rot_irq_status irq_status;
> >> +	u32 val;
> >> +
> >> +	/* Get execution result */
> >> +	irq_status = rotator_reg_get_irq_status(rot);
> >> +
> >> +	/* clear status */
> >> +	val = rot_read(ROT_STATUS);
> >> +	val |= ROT_STATUS_IRQ_PENDING((u32)irq_status);
> >> +	rot_write(val, ROT_STATUS);
> >> +
> >> +	if (irq_status == ROT_IRQ_STATUS_COMPLETE) {
> >> +		event_work->ippdrv = ippdrv;
> >> +		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
> >> +			rot->cur_buf_id[EXYNOS_DRM_OPS_DST];
> >> +		queue_work(ippdrv->event_workq,
> >> +			(struct work_struct *)event_work);
> >> +	} else
> >> +		DRM_ERROR("the SFR is set illegally\n");
> >> +
> >> +	return IRQ_HANDLED;
> >> +}
> >> +
> >> +static void rotator_align_size(struct rot_context *rot, u32 fmt, u32
> >> *hsize,
> >> +		u32 *vsize)
> >> +{
> >> +	struct rot_limit_table *limit_tbl = rot->limit_tbl;
> >> +	struct rot_limit *limit;
> >> +	u32 mask, val;
> >> +
> >> +	/* Get size limit */
> >> +	if (fmt == ROT_CONTROL_FMT_RGB888)
> >> +		limit = &limit_tbl->rgb888;
> >> +	else
> >> +		limit = &limit_tbl->ycbcr420_2p;
> >> +
> >> +	/* Get mask for rounding to nearest aligned val */
> >> +	mask = ~((1 << limit->align) - 1);
> >> +
> >> +	/* Set aligned width */
> >> +	val = ROT_ALIGN(*hsize, limit->align, mask);
> >> +	if (val < limit->min_w)
> >> +		*hsize = ROT_MIN(limit->min_w, mask);
> >> +	else if (val > limit->max_w)
> >> +		*hsize = ROT_MAX(limit->max_w, mask);
> >> +	else
> >> +		*hsize = val;
> >> +
> >> +	/* Set aligned height */
> >> +	val = ROT_ALIGN(*vsize, limit->align, mask);
> >> +	if (val < limit->min_h)
> >> +		*vsize = ROT_MIN(limit->min_h, mask);
> >> +	else if (val > limit->max_h)
> >> +		*vsize = ROT_MAX(limit->max_h, mask);
> >> +	else
> >> +		*vsize = val;
> >> +}
> >> +
> >> +static int rotator_src_set_fmt(struct device *dev, u32 fmt)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	u32 val;
> >> +
> >> +	val = rot_read(ROT_CONTROL);
> >> +	val &= ~ROT_CONTROL_FMT_MASK;
> >> +
> >> +	switch (fmt) {
> >> +	case DRM_FORMAT_NV12:
> >> +		val |= ROT_CONTROL_FMT_YCBCR420_2P;
> >> +		break;
> >> +	case DRM_FORMAT_XRGB8888:
> >> +		val |= ROT_CONTROL_FMT_RGB888;
> >> +		break;
> >> +	default:
> >> +		DRM_ERROR("invalid image format\n");
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	rot_write(val, ROT_CONTROL);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_src_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;
> >> +	u32 val;
> >> +
> >> +	/* 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 */
> >> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> >> +	rot_write(val, ROT_SRC_BUF_SIZE);
> >> +
> >> +	/* Set crop image position configuration */
> >> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> >> +	rot_write(val, ROT_SRC_CROP_POS);
> >> +	val = ROT_SRC_CROP_SIZE_H(pos->h) | ROT_SRC_CROP_SIZE_W(pos->w);
> >> +	rot_write(val, ROT_SRC_CROP_SIZE);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_src_set_addr(struct device *dev,
> >> +		struct drm_exynos_ipp_buf_info *buf_info,
> >> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> >> +	u32 val, fmt, hsize, vsize;
> >> +	int i;
> >> +
> >> +	/* Set current buf_id */
> >> +	rot->cur_buf_id[EXYNOS_DRM_OPS_SRC] = buf_id;
> >> +
> >> +	switch (buf_type) {
> >> +	case IPP_BUF_ENQUEUE:
> >> +		/* Set address configuration */
> >> +		for_each_ipp_planar(i)
> >> +			addr[i] = buf_info->base[i];
> >
> > Check NULL.
> 
> - If not copy this state, we need to memset about addr.
>    no need check null.
> 
> >
> >> +
> >> +		/* Get format */
> >> +		fmt = rotator_reg_get_format(rot);
> >> +
> >> +		/* Re-set cb planar for NV12 format */
> >> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> >> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
> > 0x00)) {
> >
> > What is 0x00?
> 
> - It is NULL, I changed !addr instead of addr == 0x00
> 
> >
> >> +
> >> +			val = rot_read(ROT_SRC_BUF_SIZE);
> >> +			hsize = ROT_GET_BUF_SIZE_W(val);
> >> +			vsize = ROT_GET_BUF_SIZE_H(val);
> >> +
> >> +			/* Set cb planar */
> >> +			addr[EXYNOS_DRM_PLANAR_CB] =
> >> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
> >> +		}
> >> +
> >> +		for_each_ipp_planar(i)
> >> +			rot_write(addr[i], ROT_SRC_BUF_ADDR(i));
> >> +		break;
> >> +	case IPP_BUF_DEQUEUE:
> >> +		for_each_ipp_planar(i)
> >> +			rot_write(0x0, ROT_SRC_BUF_ADDR(i));
> >> +		break;
> >> +	default:
> >> +		/* Nothing to do */
> >> +		break;
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_dst_set_transf(struct device *dev,
> >> +		enum drm_exynos_degree degree,
> >> +		enum drm_exynos_flip flip)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	u32 val;
> >> +
> >> +	/* Set transform configuration */
> >> +	val = rot_read(ROT_CONTROL);
> >> +	val &= ~ROT_CONTROL_FLIP_MASK;
> >> +
> >> +	switch (flip) {
> >> +	case EXYNOS_DRM_FLIP_VERTICAL:
> >> +		val |= ROT_CONTROL_FLIP_VERTICAL;
> >> +		break;
> >> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> >> +		val |= ROT_CONTROL_FLIP_HORIZONTAL;
> >> +		break;
> >> +	default:
> >> +		/* Flip None */
> >> +		break;
> >> +	}
> >> +
> >> +	val &= ~ROT_CONTROL_ROT_MASK;
> >> +
> >> +	switch (degree) {
> >> +	case EXYNOS_DRM_DEGREE_90:
> >> +		val |= ROT_CONTROL_ROT_90;
> >> +		break;
> >> +	case EXYNOS_DRM_DEGREE_180:
> >> +		val |= ROT_CONTROL_ROT_180;
> >> +		break;
> >> +	case EXYNOS_DRM_DEGREE_270:
> >> +		val |= ROT_CONTROL_ROT_270;
> >> +		break;
> >> +	default:
> >> +		/* Rotation 0 Degree */
> >> +		break;
> >> +	}
> >> +
> >> +	rot_write(val, ROT_CONTROL);
> >> +
> >> +	/* Check degree for setting buffer size swap */
> >> +	if ((degree == EXYNOS_DRM_DEGREE_90) ||
> >> +		(degree == EXYNOS_DRM_DEGREE_270))
> >> +		return 1;
> >
> > Correct return type. This function should return 0 or negative.
> 
> - no ~ this return type is boolean true or false.
>    but we need to error handling so, we use integer as you know
>    we reviewed this routine at our local git from our team(you and me).
> 

Ok, then what do the below codes mean?

	/* set transform for rotation, flip */
	if (ops->set_transf) {
		swap = ops->set_transf(ippdrv->dev, config->degree,
			config->flip);
		if (swap < 0) {
			DRM_ERROR("not support tranf.\n");
			return -EINVAL;
		}

If return value should be true or false then make sure error checking.

> >
> >> +	else
> >> +		return 0;
> >
> > Ditto.
> 
> - ditto.
> 
> >
> >> +}
> >> +
> >> +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 val, fmt, hsize, vsize;
> >> +
> >> +	/* Get format */
> >> +	fmt = rotator_reg_get_format(rot);
> >
> > Check if fmt is valid or not.
> 
> - added rotator_check_fmt()
> 
> >
> >> +
> >> +	/* Align buffer size */
> >> +	hsize = sz->hsize;
> >> +	vsize = sz->vsize;
> >> +	rotator_align_size(rot, fmt, &hsize, &vsize);
> >> +
> >> +	/* Set buffer size configuration */
> >> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> >> +	rot_write(val, ROT_DST_BUF_SIZE);
> >> +
> >> +	/* Set crop image position configuration */
> >> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> >> +	rot_write(val, ROT_DST_CROP_POS);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_dst_set_addr(struct device *dev,
> >> +		struct drm_exynos_ipp_buf_info *buf_info,
> >> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> >> +	u32 val, fmt, hsize, vsize;
> >> +	int i;
> >> +
> >> +	/* Set current buf_id */
> >> +	rot->cur_buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
> >> +
> >> +	switch (buf_type) {
> >> +	case IPP_BUF_ENQUEUE:
> >> +		/* Set address configuration */
> >> +		for_each_ipp_planar(i)
> >> +			addr[i] = buf_info->base[i];
> >> +
> >> +		/* Get format */
> >> +		fmt = rotator_reg_get_format(rot);
> >
> > Check if fmt is valid or not.
> 
> - done.
> 
> >
> >> +
> >> +		/* Re-set cb planar for NV12 format */
> >> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> >> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
> > 0x00)) {
> >> +			/* Get buf size */
> >> +			val = rot_read(ROT_DST_BUF_SIZE);
> >> +
> >> +			hsize = ROT_GET_BUF_SIZE_W(val);
> >> +			vsize = ROT_GET_BUF_SIZE_H(val);
> >> +
> >> +			/* Set cb planar */
> >> +			addr[EXYNOS_DRM_PLANAR_CB] =
> >> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
> >> +		}
> >> +
> >> +		for_each_ipp_planar(i)
> >> +			rot_write(addr[i], ROT_DST_BUF_ADDR(i));
> >> +		break;
> >> +	case IPP_BUF_DEQUEUE:
> >> +		for_each_ipp_planar(i)
> >> +			rot_write(0x0, ROT_DST_BUF_ADDR(i));
> >> +		break;
> >> +	default:
> >> +		/* Nothing to do */
> >> +		break;
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static struct exynos_drm_ipp_ops rot_src_ops = {
> >> +	.set_fmt	=	rotator_src_set_fmt,
> >> +	.set_size	=	rotator_src_set_size,
> >> +	.set_addr	=	rotator_src_set_addr,
> >> +};
> >> +
> >> +static struct exynos_drm_ipp_ops rot_dst_ops = {
> >> +	.set_transf	=	rotator_dst_set_transf,
> >> +	.set_size	=	rotator_dst_set_size,
> >> +	.set_addr	=	rotator_dst_set_addr,
> >> +};
> >> +
> >> +static int rotator_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
> >> +{
> >> +	struct drm_exynos_ipp_prop_list *prop_list;
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
> >> +	if (!prop_list) {
> >> +		DRM_ERROR("failed to alloc property list.\n");
> >> +		return -ENOMEM;
> >> +	}
> >> +
> >> +	/*ToDo fix support function list*/
> >> +
> >> +	prop_list->version = 1;
> >> +	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
> >> +				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
> >> +	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
> >> +				(1 << EXYNOS_DRM_DEGREE_90) |
> >> +				(1 << EXYNOS_DRM_DEGREE_180) |
> >> +				(1 << EXYNOS_DRM_DEGREE_270);
> >> +	prop_list->csc = 0;
> >> +	prop_list->crop = 0;
> >> +	prop_list->scale = 0;
> >> +
> >> +	ippdrv->prop_list = prop_list;
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_ippdrv_check_property(struct device *dev,
> >> +		struct drm_exynos_ipp_property *property)
> >> +{
> >> +	struct drm_exynos_ipp_config *src_config =
> >> +
> > &property->config[EXYNOS_DRM_OPS_SRC];
> >> +	struct drm_exynos_ipp_config *dst_config =
> >> +
> > &property->config[EXYNOS_DRM_OPS_DST];
> >> +	struct drm_exynos_pos *src_pos = &src_config->pos;
> >> +	struct drm_exynos_pos *dst_pos = &dst_config->pos;
> >> +	struct drm_exynos_sz *src_sz = &src_config->sz;
> >> +	struct drm_exynos_sz *dst_sz = &dst_config->sz;
> >> +	bool swap = false;
> >> +
> >> +	/* Check format configuration */
> >> +	if (src_config->fmt != dst_config->fmt) {
> >> +		DRM_DEBUG_KMS("%s:not support csc feature\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	switch (src_config->fmt) {
> >> +	case DRM_FORMAT_XRGB8888:
> >> +	case DRM_FORMAT_NV12:
> >> +		/* No problem */
> >> +		break;
> >> +	default:
> >> +		DRM_DEBUG_KMS("%s:not support format\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >
> > Use macro instead of switch-case. this just checks only format type.
> 
> - I don't thing so, If we make macro about this.
>    then we got some confusion about this macro at next change.
>    this case switch-case is better.
>    Do you prefer this ? please one more comment.
> 
> #define drm_check_fmt(fmt) if (fmt == DRM_FORMAT_XRGB8888 || fmt ==
> DRM_FORMAT_NV12) \
> 					return true;
> 
> >
> >> +
> >> +	/* Check transform configuration */
> >> +	if (src_config->degree != EXYNOS_DRM_DEGREE_0) {
> >> +		DRM_DEBUG_KMS("%s:not support source-side rotation\n",
> >> +								__func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	switch (dst_config->degree) {
> >> +	case EXYNOS_DRM_DEGREE_90:
> >> +	case EXYNOS_DRM_DEGREE_270:
> >> +		swap = true;
> >> +	case EXYNOS_DRM_DEGREE_0:
> >> +	case EXYNOS_DRM_DEGREE_180:
> >> +		/* No problem */
> >> +		break;
> >> +	default:
> >> +		DRM_DEBUG_KMS("%s:invalid degree\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	if (src_config->flip != EXYNOS_DRM_FLIP_NONE) {
> >> +		DRM_DEBUG_KMS("%s:not support source-side flip\n",
> > __func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	switch (dst_config->flip) {
> >> +	case EXYNOS_DRM_FLIP_NONE:
> >> +	case EXYNOS_DRM_FLIP_VERTICAL:
> >> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> >> +		/* No problem */
> >> +		break;
> >> +	default:
> >> +		DRM_DEBUG_KMS("%s:invalid flip\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >
> > Use macro instead of switch-case. this just checks only flip type.
> 
> - ditto. please one more comment.
>   in my opinion: I prefer enumeration use switch-case.
> 
> >
> >> +
> >> +	/* Check size configuration */
> >> +	if ((src_pos->x + src_pos->w > src_sz->hsize) ||
> >> +		(src_pos->y + src_pos->h > src_sz->vsize)) {
> >> +		DRM_DEBUG_KMS("%s:out of source buffer bound\n", __func__);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	if (swap) {
> >> +		if ((dst_pos->x + dst_pos->h > dst_sz->vsize) ||
> >> +			(dst_pos->y + dst_pos->w > dst_sz->hsize)) {
> >> +			DRM_DEBUG_KMS("%s:out of destination buffer
> > bound\n",
> >> +								__func__);
> >> +			return -EINVAL;
> >> +		}
> >> +
> >> +		if ((src_pos->w != dst_pos->h) || (src_pos->h !=
> > dst_pos->w))
> >> {
> >> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
> >> +								__func__);
> >> +			return -EINVAL;
> >> +		}
> >> +	} else {
> >> +		if ((dst_pos->x + dst_pos->w > dst_sz->hsize) ||
> >> +			(dst_pos->y + dst_pos->h > dst_sz->vsize)) {
> >> +			DRM_DEBUG_KMS("%s:out of destination buffer
> > bound\n",
> >> +								__func__);
> >> +			return -EINVAL;
> >> +		}
> >> +
> >> +		if ((src_pos->w != dst_pos->w) || (src_pos->h !=
> > dst_pos->h))
> >> {
> >> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
> >> +								__func__);
> >> +			return -EINVAL;
> >> +		}
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int rotator_ippdrv_start(struct device *dev, enum
> >> drm_exynos_ipp_cmd cmd)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	u32 val;
> >> +
> >> +	if (rot->suspended) {
> >> +		DRM_ERROR("suspended state\n");
> >> +		return -EPERM;
> >> +	}
> >> +
> >> +	if (cmd != IPP_CMD_M2M) {
> >> +		DRM_ERROR("not support cmd: %d\n", cmd);
> >> +		return -EINVAL;
> >> +	}
> >> +
> >> +	/* Set interrupt enable */
> >> +	rotator_reg_set_irq(rot, true);
> >> +
> >> +	val = rot_read(ROT_CONTROL);
> >> +	val |= ROT_CONTROL_START;
> >> +
> >> +	rot_write(val, ROT_CONTROL);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static int __devinit rotator_probe(struct platform_device *pdev)
> >> +{
> >> +	struct device *dev = &pdev->dev;
> >> +	struct rot_context *rot;
> >> +	struct resource *res;
> >> +	struct exynos_drm_ippdrv *ippdrv;
> >> +	int ret;
> >> +
> >> +	rot = kzalloc(sizeof(*rot), GFP_KERNEL);
> >> +	if (!rot) {
> >> +		dev_err(dev, "failed to allocate rot\n");
> >> +		return -ENOMEM;
> >> +	}
> >> +
> >> +	rot->limit_tbl = (struct rot_limit_table *)
> >> +				platform_get_device_id(pdev)->driver_data;
> >> +
> >> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> +	if (!res) {
> >> +		dev_err(dev, "failed to find registers\n");
> >> +		ret = -ENOENT;
> >> +		goto err_get_resource;
> >> +	}
> >> +
> >> +	rot->regs_res = request_mem_region(res->start, resource_size(res),
> >> +
> > dev_name(dev));
> >> +	if (!rot->regs_res) {
> >> +		dev_err(dev, "failed to claim register region\n");
> >> +		ret = -ENOENT;
> >> +		goto err_get_resource;
> >> +	}
> >> +
> >> +	rot->regs = ioremap(res->start, resource_size(res));
> >> +	if (!rot->regs) {
> >> +		dev_err(dev, "failed to map register\n");
> >> +		ret = -ENXIO;
> >> +		goto err_ioremap;
> >> +	}
> >> +
> >> +	rot->irq = platform_get_irq(pdev, 0);
> >> +	if (rot->irq < 0) {
> >> +		dev_err(dev, "failed to get irq\n");
> >> +		ret = rot->irq;
> >> +		goto err_get_irq;
> >> +	}
> >> +
> >> +	ret = request_threaded_irq(rot->irq, NULL, rotator_irq_handler,
> >> +					IRQF_ONESHOT, "drm_rotator", rot);
> >> +	if (ret < 0) {
> >> +		dev_err(dev, "failed to request irq\n");
> >> +		goto err_get_irq;
> >> +	}
> >> +
> >> +	rot->clock = clk_get(dev, "rotator");
> >> +	if (IS_ERR_OR_NULL(rot->clock)) {
> >> +		dev_err(dev, "failed to get clock\n");
> >> +		ret = PTR_ERR(rot->clock);
> >> +		goto err_clk_get;
> >> +	}
> >> +
> >> +	pm_runtime_enable(dev);
> >> +
> >> +	ippdrv = &rot->ippdrv;
> >> +	ippdrv->dev = dev;
> >> +	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &rot_src_ops;
> >> +	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &rot_dst_ops;
> >> +	ippdrv->check_property = rotator_ippdrv_check_property;
> >> +	ippdrv->start = rotator_ippdrv_start;
> >> +	ret = rotator_init_prop_list(ippdrv);
> >> +	if (ret < 0) {
> >> +		dev_err(dev, "failed to init property list.\n");
> >> +		goto err_ippdrv_register;
> >> +	}
> >> +
> >> +	DRM_DEBUG_KMS("%s:ippdrv[0x%x]\n", __func__, (int)ippdrv);
> >> +
> >> +	platform_set_drvdata(pdev, rot);
> >> +
> >> +	ret = exynos_drm_ippdrv_register(ippdrv);
> >> +	if (ret < 0) {
> >> +		dev_err(dev, "failed to register drm rotator device\n");
> >> +		kfree(ippdrv->prop_list);
> >> +		goto err_ippdrv_register;
> >> +	}
> >> +
> >> +	dev_info(dev, "The exynos rotator is probed successfully\n");
> >> +
> >> +	return 0;
> >> +
> >> +err_ippdrv_register:
> >> +	pm_runtime_disable(dev);
> >> +	clk_put(rot->clock);
> >> +err_clk_get:
> >> +	free_irq(rot->irq, rot);
> >> +err_get_irq:
> >> +	iounmap(rot->regs);
> >> +err_ioremap:
> >> +	release_resource(rot->regs_res);
> >> +	kfree(rot->regs_res);
> >> +err_get_resource:
> >> +	kfree(rot);
> >> +	return ret;
> >> +}
> >> +
> >> +static int __devexit rotator_remove(struct platform_device *pdev)
> >> +{
> >> +	struct device *dev = &pdev->dev;
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> >> +
> >> +	kfree(ippdrv->prop_list);
> >> +	exynos_drm_ippdrv_unregister(ippdrv);
> >> +
> >> +	pm_runtime_disable(dev);
> >> +	clk_put(rot->clock);
> >> +
> >> +	free_irq(rot->irq, rot);
> >> +
> >> +	iounmap(rot->regs);
> >> +
> >> +	release_resource(rot->regs_res);
> >> +	kfree(rot->regs_res);
> >> +
> >> +	kfree(rot);
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +struct rot_limit_table rot_limit_tbl = {
> >> +	.ycbcr420_2p = {
> >> +		.min_w = 32,
> >> +		.min_h = 32,
> >> +		.max_w = SZ_32K,
> >> +		.max_h = SZ_32K,
> >> +		.align = 3,
> >> +	},
> >> +	.rgb888 = {
> >> +		.min_w = 8,
> >> +		.min_h = 8,
> >> +		.max_w = SZ_8K,
> >> +		.max_h = SZ_8K,
> >> +		.align = 2,
> >> +	},
> >> +};
> >> +
> >> +struct platform_device_id rotator_driver_ids[] = {
> >> +	{
> >> +		.name		= "exynos-rot",
> >> +		.driver_data	= (unsigned long)&rot_limit_tbl,
> >> +	},
> >> +	{},
> >> +};
> >> +
> >> +static int rotator_clk_crtl(struct rot_context *rot, bool enable)
> >> +{
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	if (enable) {
> >> +		clk_enable(rot->clock);
> >> +		rot->suspended = false;
> >> +	} else {
> >> +		clk_disable(rot->clock);
> >> +		rot->suspended = true;
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +
> >> +#ifdef CONFIG_PM_SLEEP
> >> +static int rotator_suspend(struct device *dev)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +
> >> +	/* ToDo */
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	if (pm_runtime_suspended(dev))
> >> +		return 0;
> >> +
> >> +	return rotator_clk_crtl(rot, false);
> >> +}
> >> +
> >> +static int rotator_resume(struct device *dev)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +
> >> +	/* ToDo */
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	if (!pm_runtime_suspended(dev))
> >> +		return rotator_clk_crtl(rot, true);
> >> +
> >> +	return 0;
> >> +}
> >> +#endif
> >> +
> >> +#ifdef CONFIG_PM_RUNTIME
> >> +static int rotator_runtime_suspend(struct device *dev)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +
> >> +	/* ToDo */
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	return  rotator_clk_crtl(rot, false);
> >> +}
> >> +
> >> +static int rotator_runtime_resume(struct device *dev)
> >> +{
> >> +	struct rot_context *rot = dev_get_drvdata(dev);
> >> +
> >> +	/* ToDo */
> >> +
> >> +	DRM_DEBUG_KMS("%s\n", __func__);
> >> +
> >> +	return  rotator_clk_crtl(rot, true);
> >> +}
> >> +#endif
> >> +
> >> +static const struct dev_pm_ops rotator_pm_ops = {
> >> +	SET_SYSTEM_SLEEP_PM_OPS(rotator_suspend, rotator_resume)
> >> +	SET_RUNTIME_PM_OPS(rotator_runtime_suspend, rotator_runtime_resume,
> >> +
> > NULL)
> >> +};
> >> +
> >> +struct platform_driver rotator_driver = {
> >> +	.probe		= rotator_probe,
> >> +	.remove		= __devexit_p(rotator_remove),
> >> +	.id_table	= rotator_driver_ids,
> >> +	.driver		= {
> >> +		.name	= "exynos-rot",
> >> +		.owner	= THIS_MODULE,
> >> +		.pm	= &rotator_pm_ops,
> >> +	},
> >> +};
> >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> >> b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> >> new file mode 100644
> >> index 0000000..fe929c9
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> >> @@ -0,0 +1,13 @@
> >> +/*
> >> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> >> + * Authors: YoungJun Cho <yj44.cho@samsung.com>
> >> + *
> >> + * This program is free software; you can redistribute it and/or
> modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundationr
> >> + */
> >> +
> >> +#ifndef	_EXYNOS_DRM_ROTATOR_H_
> >> +#define	_EXYNOS_DRM_ROTATOR_H_
> >> +
> >> +#endif
> >> diff --git a/drivers/gpu/drm/exynos/regs-rotator.h
> >> b/drivers/gpu/drm/exynos/regs-rotator.h
> >> new file mode 100644
> >> index 0000000..a09ac6e
> >> --- /dev/null
> >> +++ b/drivers/gpu/drm/exynos/regs-rotator.h
> >> @@ -0,0 +1,73 @@
> >> +/* drivers/gpu/drm/exynos/regs-rotator.h
> >> + *
> >> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> >> + *		http://www.samsung.com/
> >> + *
> >> + * Register definition file for Samsung Rotator Interface (Rotator)
> >> driver
> >> + *
> >> + * This program is free software; you can redistribute it and/or
> modify
> >> + * it under the terms of the GNU General Public License version 2 as
> >> + * published by the Free Software Foundation.
> >> +*/
> >> +
> >> +#ifndef EXYNOS_REGS_ROTATOR_H
> >> +#define EXYNOS_REGS_ROTATOR_H
> >> +
> >> +/* Configuration */
> >> +#define ROT_CONFIG			0x00
> >> +#define ROT_CONFIG_IRQ			(3 << 8)
> >> +
> >> +/* Image Control */
> >> +#define ROT_CONTROL			0x10
> >> +#define ROT_CONTROL_PATTERN_WRITE	(1 << 16)
> >> +#define ROT_CONTROL_FMT_YCBCR420_2P	(1 << 8)
> >> +#define ROT_CONTROL_FMT_RGB888		(6 << 8)
> >> +#define ROT_CONTROL_FMT_MASK		(7 << 8)
> >> +#define ROT_CONTROL_FLIP_VERTICAL	(2 << 6)
> >> +#define ROT_CONTROL_FLIP_HORIZONTAL	(3 << 6)
> >> +#define ROT_CONTROL_FLIP_MASK		(3 << 6)
> >> +#define ROT_CONTROL_ROT_90		(1 << 4)
> >> +#define ROT_CONTROL_ROT_180		(2 << 4)
> >> +#define ROT_CONTROL_ROT_270		(3 << 4)
> >> +#define ROT_CONTROL_ROT_MASK		(3 << 4)
> >> +#define ROT_CONTROL_START		(1 << 0)
> >> +
> >> +/* Status */
> >> +#define ROT_STATUS			0x20
> >> +#define ROT_STATUS_IRQ_PENDING(x)	(1 << (x))
> >> +#define ROT_STATUS_IRQ(x)		(((x) >> 8) & 0x3)
> >> +#define ROT_STATUS_IRQ_VAL_COMPLETE	1
> >> +#define ROT_STATUS_IRQ_VAL_ILLEGAL	2
> >> +
> >> +/* Buffer Address */
> >> +#define ROT_SRC_BUF_ADDR(n)		(0x30 + ((n) << 2))
> >> +#define ROT_DST_BUF_ADDR(n)		(0x50 + ((n) << 2))
> >> +
> >> +/* Buffer Size */
> >> +#define ROT_SRC_BUF_SIZE		0x3c
> >> +#define ROT_DST_BUF_SIZE		0x5c
> >> +#define ROT_SET_BUF_SIZE_H(x)		((x) << 16)
> >> +#define ROT_SET_BUF_SIZE_W(x)		((x) << 0)
> >> +#define ROT_GET_BUF_SIZE_H(x)		((x) >> 16)
> >> +#define ROT_GET_BUF_SIZE_W(x)		((x) & 0xffff)
> >> +
> >> +/* Crop Position */
> >> +#define ROT_SRC_CROP_POS		0x40
> >> +#define ROT_DST_CROP_POS		0x60
> >> +#define ROT_CROP_POS_Y(x)		((x) << 16)
> >> +#define ROT_CROP_POS_X(x)		((x) << 0)
> >> +
> >> +/* Source Crop Size */
> >> +#define ROT_SRC_CROP_SIZE		0x44
> >> +#define ROT_SRC_CROP_SIZE_H(x)		((x) << 16)
> >> +#define ROT_SRC_CROP_SIZE_W(x)		((x) << 0)
> >> +
> >> +/* Round to nearest aligned value */
> >> +#define ROT_ALIGN(x, align, mask)	(((x) + (1 << ((align) - 1))) &
> >> (mask))
> >> +/* Minimum limit value */
> >> +#define ROT_MIN(min, mask)		(((min) + ~(mask)) & (mask))
> >> +/* Maximum limit value */
> >> +#define ROT_MAX(max, mask)		((max) & (mask))
> >> +
> >> +#endif /* EXYNOS_REGS_ROTATOR_H */
> >> +
> >> --
> >> 1.7.0.4
> >
> >

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
  2012-12-12  9:41       ` Inki Dae
@ 2012-12-12 10:00         ` Inki Dae
  2012-12-12 10:39           ` Inki Dae
  0 siblings, 1 reply; 18+ messages in thread
From: Inki Dae @ 2012-12-12 10:00 UTC (permalink / raw)
  To: 'Inki Dae', 'Eunchul Kim'
  Cc: jy0.jeon, sw0312.kim, jaejoon.seo, dri-devel, kyungmin.park, jmock.shin



> -----Original Message-----
> From: dri-devel-bounces+inki.dae=samsung.com@lists.freedesktop.org
> [mailto:dri-devel-bounces+inki.dae=samsung.com@lists.freedesktop.org] On
> Behalf Of Inki Dae
> Sent: Wednesday, December 12, 2012 6:42 PM
> To: 'Eunchul Kim'
> Cc: jy0.jeon@samsung.com; sw0312.kim@samsung.com; jaejoon.seo@samsung.com;
> kyungmin.park@samsung.com; dri-devel@lists.freedesktop.org;
> jmock.shin@samsung.com
> Subject: RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> 
> 
> 
> > -----Original Message-----
> > From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> > Sent: Wednesday, December 12, 2012 6:26 PM
> > To: Inki Dae
> > Cc: dri-devel@lists.freedesktop.org; jy0.jeon@samsung.com;
> > yj44.cho@samsung.com; jmock.shin@samsung.com; jaejoon.seo@samsung.com;
> > kyungmin.park@samsung.com; sw0312.kim@samsung.com; Joonyoung Shim
> > Subject: Re: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> >
> > Thank's your comment.
> >
> > I answer your comment. please check that.
> >
> > Thank's
> >
> > BR
> > Eunchul Kim
> >
> > On 12/12/2012 05:29 PM, Inki Dae wrote:
> > >
> > >
> > >> -----Original Message-----
> > >> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> > >> Sent: Wednesday, December 12, 2012 4:35 PM
> > >> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
> > >> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com;
> jmock.shin@samsung.com;
> > >> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
> > >> chulspro.kim@samsung.com
> > >> Subject: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> > >>
> > >> Rotator supports rotation/crop/flip and input/output DMA operations
> > >> Rotator ipp driver supports 90,180,270 degree rotaion and vertical,
> > >> horizontal flip.
> > >> and has some limitations(source and destination format have to be
> same,
> > no
> > >> scaler)
> > >>
> > >> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
> > >> Signed-off-by: Youngjun Cho <yj44.cho@samsung.com>
> > >> ---
> > >>   drivers/gpu/drm/exynos/Kconfig              |    7 +
> > >>   drivers/gpu/drm/exynos/Makefile             |    1 +
> > >>   drivers/gpu/drm/exynos/exynos_drm_drv.c     |   15 +
> > >>   drivers/gpu/drm/exynos/exynos_drm_drv.h     |    1 +
> > >>   drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829
> > >> +++++++++++++++++++++++++++
> > >>   drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
> > >>   drivers/gpu/drm/exynos/regs-rotator.h       |   73 +++
> > >>   7 files changed, 939 insertions(+), 0 deletions(-)
> > >>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
> > >>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
> > >>   create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
> > >>
> > >> diff --git a/drivers/gpu/drm/exynos/Kconfig
> > >> b/drivers/gpu/drm/exynos/Kconfig
> > >> index 4915ab6..4860835 100644
> > >> --- a/drivers/gpu/drm/exynos/Kconfig
> > >> +++ b/drivers/gpu/drm/exynos/Kconfig
> > >> @@ -57,3 +57,10 @@ config DRM_EXYNOS_FIMC
> > >>   	depends on DRM_EXYNOS_IPP
> > >>   	help
> > >>   	  Choose this option if you want to use Exynos FIMC for DRM.
> > >> +
> > >> +config DRM_EXYNOS_ROTATOR
> > >> +	bool "Exynos DRM Rotator"
> > >> +	depends on DRM_EXYNOS_IPP
> > >> +	help
> > >> +	  Choose this option if you want to use Exynos Rotator for
DRM.
> > >> +
> > >> diff --git a/drivers/gpu/drm/exynos/Makefile
> > >> b/drivers/gpu/drm/exynos/Makefile
> > >> index 9710024..3b70668 100644
> > >> --- a/drivers/gpu/drm/exynos/Makefile
> > >> +++ b/drivers/gpu/drm/exynos/Makefile
> > >> @@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+=
> > >> exynos_drm_vidi.o
> > >>   exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
> > >>   exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
> > >>   exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
> > >> +exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
> > >>
> > >>   obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
> > >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > >> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > >> index 73f02ac..09d884b 100644
> > >> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > >> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > >> @@ -378,6 +378,12 @@ static int __init exynos_drm_init(void)
> > >>   		goto out_fimc;
> > >>   #endif
> > >>
> > >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> > >> +	ret = platform_driver_register(&rotator_driver);
> > >> +	if (ret < 0)
> > >> +		goto out_rotator;
> > >> +#endif
> > >> +
> > >>   #ifdef CONFIG_DRM_EXYNOS_IPP
> > >>   	ret = platform_driver_register(&ipp_driver);
> > >>   	if (ret < 0)
> > >> @@ -406,6 +412,11 @@ out_drm:
> > >>   out_ipp:
> > >>   #endif
> > >>
> > >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> > >> +	platform_driver_unregister(&rotator_driver);
> > >> +out_rotator:
> > >> +#endif
> > >> +
> > >>   #ifdef CONFIG_DRM_EXYNOS_FIMC
> > >>   	platform_driver_unregister(&fimc_driver);
> > >>   out_fimc:
> > >> @@ -451,6 +462,10 @@ static void __exit exynos_drm_exit(void)
> > >>   	platform_driver_unregister(&ipp_driver);
> > >>   #endif
> > >>
> > >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> > >> +	platform_driver_unregister(&rotator_driver);
> > >> +#endif
> > >> +
> > >>   #ifdef CONFIG_DRM_EXYNOS_FIMC
> > >>   	platform_driver_unregister(&fimc_driver);
> > >>   #endif
> > >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> > >> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> > >> index 14f9490..a74e37c 100644
> > >> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> > >> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> > >> @@ -353,5 +353,6 @@ extern struct platform_driver
> > >> exynos_drm_common_hdmi_driver;
> > >>   extern struct platform_driver vidi_driver;
> > >>   extern struct platform_driver g2d_driver;
> > >>   extern struct platform_driver fimc_driver;
> > >> +extern struct platform_driver rotator_driver;
> > >>   extern struct platform_driver ipp_driver;
> > >>   #endif
> > >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> > >> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> > >> new file mode 100644
> > >> index 0000000..121569c
> > >> --- /dev/null
> > >> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> > >> @@ -0,0 +1,829 @@
> > >> +/*
> > >> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> > >> + * Authors:
> > >> + *	YoungJun Cho <yj44.cho@samsung.com>
> > >> + *	Eunchul Kim <chulspro.kim@samsung.com>
> > >> + *
> > >> + * This program is free software; you can redistribute it and/or
> > modify
> > >> + * it under the terms of the GNU General Public License version 2 as
> > >> + * published by the Free Software Foundationr
> > >> + */
> > >> +
> > >> +#include <linux/kernel.h>
> > >> +#include <linux/module.h>
> > >> +#include <linux/err.h>
> > >> +#include <linux/interrupt.h>
> > >> +#include <linux/io.h>
> > >> +#include <linux/platform_device.h>
> > >> +#include <linux/clk.h>
> > >> +#include <linux/pm_runtime.h>
> > >> +
> > >> +#include <drm/drmP.h>
> > >> +#include <drm/exynos_drm.h>
> > >> +#include "regs-rotator.h"
> > >> +#include "exynos_drm.h"
> > >> +#include "exynos_drm_ipp.h"
> > >> +
> > >> +/*
> > >> + * Rotator supports image crop/rotator and input/output DMA
> operations.
> > >> + * input DMA reads image data from the memory.
> > >> + * output DMA writes image data to memory.
> > >> + */
> > >> +
> > >> +#define get_rot_context(dev)
> > >> 	platform_get_drvdata(to_platform_device(dev))
> > >> +#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
> > >> +					struct rot_context, ippdrv);
> > >> +#define rot_read(offset)		readl(rot->regs + (offset))
> > >> +#define rot_write(cfg, offset)	writel(cfg, rot->regs + (offset))
> > >> +
> > >> +enum rot_irq_status {
> > >> +	ROT_IRQ_STATUS_COMPLETE	= 8,
> > >> +	ROT_IRQ_STATUS_ILLEGAL	= 9,
> > >> +};
> > >> +
> > >> +/*
> > >> + * A structure of limitation.
> > >> + *
> > >> + * @min_w: minimum width.
> > >> + * @min_h: minimum height.
> > >> + * @max_w: maximum width.
> > >> + * @max_h: maximum height.
> > >> + * @align: align size.
> > >> + */
> > >> +struct rot_limit {
> > >> +	u32	min_w;
> > >> +	u32	min_h;
> > >> +	u32	max_w;
> > >> +	u32	max_h;
> > >> +	u32	align;
> > >> +};
> > >> +
> > >> +/*
> > >> + * A structure of limitation table.
> > >> + *
> > >> + * @ycbcr420_2p: case of YUV.
> > >> + * @rgb888: case of RGB.
> > >> + */
> > >> +struct rot_limit_table {
> > >> +	struct rot_limit	ycbcr420_2p;
> > >> +	struct rot_limit	rgb888;
> > >> +};
> > >> +
> > >> +/*
> > >> + * A structure of rotator context.
> > >> + * @ippdrv: prepare initialization using ippdrv.
> > >> + * @regs_res: register resources.
> > >> + * @regs: memory mapped io registers.
> > >> + * @clock: rotator gate clock.
> > >> + * @limit_tbl: limitation of rotator.
> > >> + * @irq: irq number.
> > >> + * @cur_buf_id: current operation buffer id.
> > >> + * @suspended: suspended state.
> > >> + */
> > >> +struct rot_context {
> > >> +	struct exynos_drm_ippdrv	ippdrv;
> > >> +	struct resource	*regs_res;
> > >> +	void __iomem	*regs;
> > >> +	struct clk	*clock;
> > >> +	struct rot_limit_table	*limit_tbl;
> > >> +	int	irq;
> > >> +	int	cur_buf_id[EXYNOS_DRM_OPS_MAX];
> > >> +	bool	suspended;
> > >> +};
> > >> +
> > >> +static void rotator_reg_set_irq(struct rot_context *rot, bool
enable)
> > >> +{
> > >> +	u32 val = rot_read(ROT_CONFIG);
> > >> +
> > >> +	if (enable == true)
> > >> +		val |= ROT_CONFIG_IRQ;
> > >> +	else
> > >> +		val &= ~ROT_CONFIG_IRQ;
> > >> +
> > >> +	rot_write(val, ROT_CONFIG);
> > >> +}
> > >> +
> > >> +static u32 rotator_reg_get_format(struct rot_context *rot)
> > >> +{
> > >> +	u32 val = rot_read(ROT_CONTROL);
> > >> +
> > >> +	val &= ROT_CONTROL_FMT_MASK;
> > >> +
> > >> +	return val;
> > >> +}
> > >> +
> > >> +static enum rot_irq_status rotator_reg_get_irq_status(struct
> > rot_context
> > >> *rot)
> > >> +{
> > >> +	u32 val = rot_read(ROT_STATUS);
> > >> +
> > >> +	val = ROT_STATUS_IRQ(val);
> > >> +
> > >> +	if (val == ROT_STATUS_IRQ_VAL_COMPLETE)
> > >> +		return ROT_IRQ_STATUS_COMPLETE;
> > >> +	else
> > >
> > > Remove else.
> >
> > - done.
> >
> > >
> > >> +		return ROT_IRQ_STATUS_ILLEGAL;
> > >> +}
> > >> +
> > >> +static irqreturn_t rotator_irq_handler(int irq, void *arg)
> > >> +{
> > >> +	struct rot_context *rot = arg;
> > >> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> > >> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
> > >> +	struct drm_exynos_ipp_event_work *event_work =
c_node->event_work;
> > >> +	enum rot_irq_status irq_status;
> > >> +	u32 val;
> > >> +
> > >> +	/* Get execution result */
> > >> +	irq_status = rotator_reg_get_irq_status(rot);
> > >> +
> > >> +	/* clear status */
> > >> +	val = rot_read(ROT_STATUS);
> > >> +	val |= ROT_STATUS_IRQ_PENDING((u32)irq_status);
> > >> +	rot_write(val, ROT_STATUS);
> > >> +
> > >> +	if (irq_status == ROT_IRQ_STATUS_COMPLETE) {
> > >> +		event_work->ippdrv = ippdrv;
> > >> +		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
> > >> +			rot->cur_buf_id[EXYNOS_DRM_OPS_DST];
> > >> +		queue_work(ippdrv->event_workq,
> > >> +			(struct work_struct *)event_work);
> > >> +	} else
> > >> +		DRM_ERROR("the SFR is set illegally\n");
> > >> +
> > >> +	return IRQ_HANDLED;
> > >> +}
> > >> +
> > >> +static void rotator_align_size(struct rot_context *rot, u32 fmt, u32
> > >> *hsize,
> > >> +		u32 *vsize)
> > >> +{
> > >> +	struct rot_limit_table *limit_tbl = rot->limit_tbl;
> > >> +	struct rot_limit *limit;
> > >> +	u32 mask, val;
> > >> +
> > >> +	/* Get size limit */
> > >> +	if (fmt == ROT_CONTROL_FMT_RGB888)
> > >> +		limit = &limit_tbl->rgb888;
> > >> +	else
> > >> +		limit = &limit_tbl->ycbcr420_2p;
> > >> +
> > >> +	/* Get mask for rounding to nearest aligned val */
> > >> +	mask = ~((1 << limit->align) - 1);
> > >> +
> > >> +	/* Set aligned width */
> > >> +	val = ROT_ALIGN(*hsize, limit->align, mask);
> > >> +	if (val < limit->min_w)
> > >> +		*hsize = ROT_MIN(limit->min_w, mask);
> > >> +	else if (val > limit->max_w)
> > >> +		*hsize = ROT_MAX(limit->max_w, mask);
> > >> +	else
> > >> +		*hsize = val;
> > >> +
> > >> +	/* Set aligned height */
> > >> +	val = ROT_ALIGN(*vsize, limit->align, mask);
> > >> +	if (val < limit->min_h)
> > >> +		*vsize = ROT_MIN(limit->min_h, mask);
> > >> +	else if (val > limit->max_h)
> > >> +		*vsize = ROT_MAX(limit->max_h, mask);
> > >> +	else
> > >> +		*vsize = val;
> > >> +}
> > >> +
> > >> +static int rotator_src_set_fmt(struct device *dev, u32 fmt)
> > >> +{
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +	u32 val;
> > >> +
> > >> +	val = rot_read(ROT_CONTROL);
> > >> +	val &= ~ROT_CONTROL_FMT_MASK;
> > >> +
> > >> +	switch (fmt) {
> > >> +	case DRM_FORMAT_NV12:
> > >> +		val |= ROT_CONTROL_FMT_YCBCR420_2P;
> > >> +		break;
> > >> +	case DRM_FORMAT_XRGB8888:
> > >> +		val |= ROT_CONTROL_FMT_RGB888;
> > >> +		break;
> > >> +	default:
> > >> +		DRM_ERROR("invalid image format\n");
> > >> +		return -EINVAL;
> > >> +	}
> > >> +
> > >> +	rot_write(val, ROT_CONTROL);
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +static int rotator_src_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;
> > >> +	u32 val;
> > >> +
> > >> +	/* 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 */
> > >> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> > >> +	rot_write(val, ROT_SRC_BUF_SIZE);
> > >> +
> > >> +	/* Set crop image position configuration */
> > >> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> > >> +	rot_write(val, ROT_SRC_CROP_POS);
> > >> +	val = ROT_SRC_CROP_SIZE_H(pos->h) |
ROT_SRC_CROP_SIZE_W(pos->w);
> > >> +	rot_write(val, ROT_SRC_CROP_SIZE);
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +static int rotator_src_set_addr(struct device *dev,
> > >> +		struct drm_exynos_ipp_buf_info *buf_info,
> > >> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> > >> +{
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> > >> +	u32 val, fmt, hsize, vsize;
> > >> +	int i;
> > >> +
> > >> +	/* Set current buf_id */
> > >> +	rot->cur_buf_id[EXYNOS_DRM_OPS_SRC] = buf_id;
> > >> +
> > >> +	switch (buf_type) {
> > >> +	case IPP_BUF_ENQUEUE:
> > >> +		/* Set address configuration */
> > >> +		for_each_ipp_planar(i)
> > >> +			addr[i] = buf_info->base[i];
> > >
> > > Check NULL.
> >
> > - If not copy this state, we need to memset about addr.
> >    no need check null.
> >
> > >
> > >> +
> > >> +		/* Get format */
> > >> +		fmt = rotator_reg_get_format(rot);
> > >> +
> > >> +		/* Re-set cb planar for NV12 format */
> > >> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> > >> +					(addr[EXYNOS_DRM_PLANAR_CB]
==
> > > 0x00)) {
> > >
> > > What is 0x00?
> >
> > - It is NULL, I changed !addr instead of addr == 0x00
> >
> > >
> > >> +
> > >> +			val = rot_read(ROT_SRC_BUF_SIZE);
> > >> +			hsize = ROT_GET_BUF_SIZE_W(val);
> > >> +			vsize = ROT_GET_BUF_SIZE_H(val);
> > >> +
> > >> +			/* Set cb planar */
> > >> +			addr[EXYNOS_DRM_PLANAR_CB] =
> > >> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize *
vsize;
> > >> +		}
> > >> +
> > >> +		for_each_ipp_planar(i)
> > >> +			rot_write(addr[i], ROT_SRC_BUF_ADDR(i));
> > >> +		break;
> > >> +	case IPP_BUF_DEQUEUE:
> > >> +		for_each_ipp_planar(i)
> > >> +			rot_write(0x0, ROT_SRC_BUF_ADDR(i));
> > >> +		break;
> > >> +	default:
> > >> +		/* Nothing to do */
> > >> +		break;
> > >> +	}
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +static int rotator_dst_set_transf(struct device *dev,
> > >> +		enum drm_exynos_degree degree,
> > >> +		enum drm_exynos_flip flip)
> > >> +{
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +	u32 val;
> > >> +
> > >> +	/* Set transform configuration */
> > >> +	val = rot_read(ROT_CONTROL);
> > >> +	val &= ~ROT_CONTROL_FLIP_MASK;
> > >> +
> > >> +	switch (flip) {
> > >> +	case EXYNOS_DRM_FLIP_VERTICAL:
> > >> +		val |= ROT_CONTROL_FLIP_VERTICAL;
> > >> +		break;
> > >> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> > >> +		val |= ROT_CONTROL_FLIP_HORIZONTAL;
> > >> +		break;
> > >> +	default:
> > >> +		/* Flip None */
> > >> +		break;
> > >> +	}
> > >> +
> > >> +	val &= ~ROT_CONTROL_ROT_MASK;
> > >> +
> > >> +	switch (degree) {
> > >> +	case EXYNOS_DRM_DEGREE_90:
> > >> +		val |= ROT_CONTROL_ROT_90;
> > >> +		break;
> > >> +	case EXYNOS_DRM_DEGREE_180:
> > >> +		val |= ROT_CONTROL_ROT_180;
> > >> +		break;
> > >> +	case EXYNOS_DRM_DEGREE_270:
> > >> +		val |= ROT_CONTROL_ROT_270;
> > >> +		break;
> > >> +	default:
> > >> +		/* Rotation 0 Degree */
> > >> +		break;
> > >> +	}
> > >> +
> > >> +	rot_write(val, ROT_CONTROL);
> > >> +
> > >> +	/* Check degree for setting buffer size swap */
> > >> +	if ((degree == EXYNOS_DRM_DEGREE_90) ||
> > >> +		(degree == EXYNOS_DRM_DEGREE_270))
> > >> +		return 1;
> > >
> > > Correct return type. This function should return 0 or negative.
> >
> > - no ~ this return type is boolean true or false.
> >    but we need to error handling so, we use integer as you know
> >    we reviewed this routine at our local git from our team(you and me).
> >
> > >
> > >> +	else
> > >> +		return 0;
> > >
> > > Ditto.
> >
> > - ditto.
> >
> > >
> > >> +}
> > >> +
> > >> +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 val, fmt, hsize, vsize;
> > >> +
> > >> +	/* Get format */
> > >> +	fmt = rotator_reg_get_format(rot);
> > >
> > > Check if fmt is valid or not.
> >
> > - added rotator_check_fmt()
> >
> > >
> > >> +
> > >> +	/* Align buffer size */
> > >> +	hsize = sz->hsize;
> > >> +	vsize = sz->vsize;
> > >> +	rotator_align_size(rot, fmt, &hsize, &vsize);
> > >> +
> > >> +	/* Set buffer size configuration */
> > >> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> > >> +	rot_write(val, ROT_DST_BUF_SIZE);
> > >> +
> > >> +	/* Set crop image position configuration */
> > >> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> > >> +	rot_write(val, ROT_DST_CROP_POS);
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +static int rotator_dst_set_addr(struct device *dev,
> > >> +		struct drm_exynos_ipp_buf_info *buf_info,
> > >> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> > >> +{
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> > >> +	u32 val, fmt, hsize, vsize;
> > >> +	int i;
> > >> +
> > >> +	/* Set current buf_id */
> > >> +	rot->cur_buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
> > >> +
> > >> +	switch (buf_type) {
> > >> +	case IPP_BUF_ENQUEUE:
> > >> +		/* Set address configuration */
> > >> +		for_each_ipp_planar(i)
> > >> +			addr[i] = buf_info->base[i];
> > >> +
> > >> +		/* Get format */
> > >> +		fmt = rotator_reg_get_format(rot);
> > >
> > > Check if fmt is valid or not.
> >
> > - done.
> >
> > >
> > >> +
> > >> +		/* Re-set cb planar for NV12 format */
> > >> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> > >> +					(addr[EXYNOS_DRM_PLANAR_CB]
==
> > > 0x00)) {
> > >> +			/* Get buf size */
> > >> +			val = rot_read(ROT_DST_BUF_SIZE);
> > >> +
> > >> +			hsize = ROT_GET_BUF_SIZE_W(val);
> > >> +			vsize = ROT_GET_BUF_SIZE_H(val);
> > >> +
> > >> +			/* Set cb planar */
> > >> +			addr[EXYNOS_DRM_PLANAR_CB] =
> > >> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize *
vsize;
> > >> +		}
> > >> +
> > >> +		for_each_ipp_planar(i)
> > >> +			rot_write(addr[i], ROT_DST_BUF_ADDR(i));
> > >> +		break;
> > >> +	case IPP_BUF_DEQUEUE:
> > >> +		for_each_ipp_planar(i)
> > >> +			rot_write(0x0, ROT_DST_BUF_ADDR(i));
> > >> +		break;
> > >> +	default:
> > >> +		/* Nothing to do */
> > >> +		break;
> > >> +	}
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +static struct exynos_drm_ipp_ops rot_src_ops = {
> > >> +	.set_fmt	=	rotator_src_set_fmt,
> > >> +	.set_size	=	rotator_src_set_size,
> > >> +	.set_addr	=	rotator_src_set_addr,
> > >> +};
> > >> +
> > >> +static struct exynos_drm_ipp_ops rot_dst_ops = {
> > >> +	.set_transf	=	rotator_dst_set_transf,
> > >> +	.set_size	=	rotator_dst_set_size,
> > >> +	.set_addr	=	rotator_dst_set_addr,
> > >> +};
> > >> +
> > >> +static int rotator_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
> > >> +{
> > >> +	struct drm_exynos_ipp_prop_list *prop_list;
> > >> +
> > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > >> +
> > >> +	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
> > >> +	if (!prop_list) {
> > >> +		DRM_ERROR("failed to alloc property list.\n");
> > >> +		return -ENOMEM;
> > >> +	}
> > >> +
> > >> +	/*ToDo fix support function list*/
> > >> +
> > >> +	prop_list->version = 1;
> > >> +	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
> > >> +				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
> > >> +	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
> > >> +				(1 << EXYNOS_DRM_DEGREE_90) |
> > >> +				(1 << EXYNOS_DRM_DEGREE_180) |
> > >> +				(1 << EXYNOS_DRM_DEGREE_270);
> > >> +	prop_list->csc = 0;
> > >> +	prop_list->crop = 0;
> > >> +	prop_list->scale = 0;
> > >> +
> > >> +	ippdrv->prop_list = prop_list;
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +static int rotator_ippdrv_check_property(struct device *dev,
> > >> +		struct drm_exynos_ipp_property *property)
> > >> +{
> > >> +	struct drm_exynos_ipp_config *src_config =
> > >> +
> > > &property->config[EXYNOS_DRM_OPS_SRC];
> > >> +	struct drm_exynos_ipp_config *dst_config =
> > >> +
> > > &property->config[EXYNOS_DRM_OPS_DST];
> > >> +	struct drm_exynos_pos *src_pos = &src_config->pos;
> > >> +	struct drm_exynos_pos *dst_pos = &dst_config->pos;
> > >> +	struct drm_exynos_sz *src_sz = &src_config->sz;
> > >> +	struct drm_exynos_sz *dst_sz = &dst_config->sz;
> > >> +	bool swap = false;
> > >> +
> > >> +	/* Check format configuration */
> > >> +	if (src_config->fmt != dst_config->fmt) {
> > >> +		DRM_DEBUG_KMS("%s:not support csc feature\n",
__func__);
> > >> +		return -EINVAL;
> > >> +	}
> > >> +
> > >> +	switch (src_config->fmt) {
> > >> +	case DRM_FORMAT_XRGB8888:
> > >> +	case DRM_FORMAT_NV12:
> > >> +		/* No problem */
> > >> +		break;
> > >> +	default:
> > >> +		DRM_DEBUG_KMS("%s:not support format\n", __func__);
> > >> +		return -EINVAL;
> > >> +	}
> > >
> > > Use macro instead of switch-case. this just checks only format type.
> >
> > - I don't thing so, If we make macro about this.
> >    then we got some confusion about this macro at next change.
> >    this case switch-case is better.
> >    Do you prefer this ? please one more comment.
> >
> > #define drm_check_fmt(fmt) if (fmt == DRM_FORMAT_XRGB8888 || fmt ==
> > DRM_FORMAT_NV12) \
> > 					return true;
> 
> #define drm_check_fmt(fmt)		((fmt & (DRM_FORMAT_XRGB8888 |
> DRM_FORMAT_NV12)) ? true : false)
> 
> if (drm_check_fmt(src_config->fmt))
> 	Something;
> else
> 	Something;

Again,

#define DRM_FORMAT_MASK			(DRM_FORMAT_XRGB888 |
DRM_FORMAT_NV12)
 #define drm_check_fmt(fmt)		(((fmt & DRM_FORMAT_MASK) &
(DRM_FORMAT_XRGB8888 | \
	
DRM_FORMAT_NV12)) ? true : false)
 
 if (drm_check_fmt(src_config->fmt))
 	Something;
 else
 	Something;


> 
> >
> > >
> > >> +
> > >> +	/* Check transform configuration */
> > >> +	if (src_config->degree != EXYNOS_DRM_DEGREE_0) {
> > >> +		DRM_DEBUG_KMS("%s:not support source-side
rotation\n",
> > >> +
__func__);
> > >> +		return -EINVAL;
> > >> +	}
> > >> +
> > >> +	switch (dst_config->degree) {
> > >> +	case EXYNOS_DRM_DEGREE_90:
> > >> +	case EXYNOS_DRM_DEGREE_270:
> > >> +		swap = true;
> > >> +	case EXYNOS_DRM_DEGREE_0:
> > >> +	case EXYNOS_DRM_DEGREE_180:
> > >> +		/* No problem */
> > >> +		break;
> > >> +	default:
> > >> +		DRM_DEBUG_KMS("%s:invalid degree\n", __func__);
> > >> +		return -EINVAL;
> > >> +	}
> > >> +
> > >> +	if (src_config->flip != EXYNOS_DRM_FLIP_NONE) {
> > >> +		DRM_DEBUG_KMS("%s:not support source-side flip\n",
> > > __func__);
> > >> +		return -EINVAL;
> > >> +	}
> > >> +
> > >> +	switch (dst_config->flip) {
> > >> +	case EXYNOS_DRM_FLIP_NONE:
> > >> +	case EXYNOS_DRM_FLIP_VERTICAL:
> > >> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> > >> +		/* No problem */
> > >> +		break;
> > >> +	default:
> > >> +		DRM_DEBUG_KMS("%s:invalid flip\n", __func__);
> > >> +		return -EINVAL;
> > >> +	}
> > >
> > > Use macro instead of switch-case. this just checks only flip type.
> >
> > - ditto. please one more comment.
> >   in my opinion: I prefer enumeration use switch-case.
> 
> What does each case do? Just check? If so, use macro as I mentioned. We
> can't accept this codes.
> 
> >
> > >
> > >> +
> > >> +	/* Check size configuration */
> > >> +	if ((src_pos->x + src_pos->w > src_sz->hsize) ||
> > >> +		(src_pos->y + src_pos->h > src_sz->vsize)) {
> > >> +		DRM_DEBUG_KMS("%s:out of source buffer bound\n",
__func__);
> > >> +		return -EINVAL;
> > >> +	}
> > >> +
> > >> +	if (swap) {
> > >> +		if ((dst_pos->x + dst_pos->h > dst_sz->vsize) ||
> > >> +			(dst_pos->y + dst_pos->w > dst_sz->hsize)) {
> > >> +			DRM_DEBUG_KMS("%s:out of destination buffer
> > > bound\n",
> > >> +
__func__);
> > >> +			return -EINVAL;
> > >> +		}
> > >> +
> > >> +		if ((src_pos->w != dst_pos->h) || (src_pos->h !=
> > > dst_pos->w))
> > >> {
> > >> +			DRM_DEBUG_KMS("%s:not support scale
feature\n",
> > >> +
__func__);
> > >> +			return -EINVAL;
> > >> +		}
> > >> +	} else {
> > >> +		if ((dst_pos->x + dst_pos->w > dst_sz->hsize) ||
> > >> +			(dst_pos->y + dst_pos->h > dst_sz->vsize)) {
> > >> +			DRM_DEBUG_KMS("%s:out of destination buffer
> > > bound\n",
> > >> +
__func__);
> > >> +			return -EINVAL;
> > >> +		}
> > >> +
> > >> +		if ((src_pos->w != dst_pos->w) || (src_pos->h !=
> > > dst_pos->h))
> > >> {
> > >> +			DRM_DEBUG_KMS("%s:not support scale
feature\n",
> > >> +
__func__);
> > >> +			return -EINVAL;
> > >> +		}
> > >> +	}
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +static int rotator_ippdrv_start(struct device *dev, enum
> > >> drm_exynos_ipp_cmd cmd)
> > >> +{
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +	u32 val;
> > >> +
> > >> +	if (rot->suspended) {
> > >> +		DRM_ERROR("suspended state\n");
> > >> +		return -EPERM;
> > >> +	}
> > >> +
> > >> +	if (cmd != IPP_CMD_M2M) {
> > >> +		DRM_ERROR("not support cmd: %d\n", cmd);
> > >> +		return -EINVAL;
> > >> +	}
> > >> +
> > >> +	/* Set interrupt enable */
> > >> +	rotator_reg_set_irq(rot, true);
> > >> +
> > >> +	val = rot_read(ROT_CONTROL);
> > >> +	val |= ROT_CONTROL_START;
> > >> +
> > >> +	rot_write(val, ROT_CONTROL);
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +static int __devinit rotator_probe(struct platform_device *pdev)
> > >> +{
> > >> +	struct device *dev = &pdev->dev;
> > >> +	struct rot_context *rot;
> > >> +	struct resource *res;
> > >> +	struct exynos_drm_ippdrv *ippdrv;
> > >> +	int ret;
> > >> +
> > >> +	rot = kzalloc(sizeof(*rot), GFP_KERNEL);
> > >> +	if (!rot) {
> > >> +		dev_err(dev, "failed to allocate rot\n");
> > >> +		return -ENOMEM;
> > >> +	}
> > >> +
> > >> +	rot->limit_tbl = (struct rot_limit_table *)
> > >> +
platform_get_device_id(pdev)->driver_data;
> > >> +
> > >> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > >> +	if (!res) {
> > >> +		dev_err(dev, "failed to find registers\n");
> > >> +		ret = -ENOENT;
> > >> +		goto err_get_resource;
> > >> +	}
> > >> +
> > >> +	rot->regs_res = request_mem_region(res->start,
resource_size(res),
> > >> +
> > > dev_name(dev));
> > >> +	if (!rot->regs_res) {
> > >> +		dev_err(dev, "failed to claim register region\n");
> > >> +		ret = -ENOENT;
> > >> +		goto err_get_resource;
> > >> +	}
> > >> +
> > >> +	rot->regs = ioremap(res->start, resource_size(res));
> > >> +	if (!rot->regs) {
> > >> +		dev_err(dev, "failed to map register\n");
> > >> +		ret = -ENXIO;
> > >> +		goto err_ioremap;
> > >> +	}
> > >> +
> > >> +	rot->irq = platform_get_irq(pdev, 0);
> > >> +	if (rot->irq < 0) {
> > >> +		dev_err(dev, "failed to get irq\n");
> > >> +		ret = rot->irq;
> > >> +		goto err_get_irq;
> > >> +	}
> > >> +
> > >> +	ret = request_threaded_irq(rot->irq, NULL,
rotator_irq_handler,
> > >> +					IRQF_ONESHOT, "drm_rotator",
rot);
> > >> +	if (ret < 0) {
> > >> +		dev_err(dev, "failed to request irq\n");
> > >> +		goto err_get_irq;
> > >> +	}
> > >> +
> > >> +	rot->clock = clk_get(dev, "rotator");
> > >> +	if (IS_ERR_OR_NULL(rot->clock)) {
> > >> +		dev_err(dev, "failed to get clock\n");
> > >> +		ret = PTR_ERR(rot->clock);
> > >> +		goto err_clk_get;
> > >> +	}
> > >> +
> > >> +	pm_runtime_enable(dev);
> > >> +
> > >> +	ippdrv = &rot->ippdrv;
> > >> +	ippdrv->dev = dev;
> > >> +	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &rot_src_ops;
> > >> +	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &rot_dst_ops;
> > >> +	ippdrv->check_property = rotator_ippdrv_check_property;
> > >> +	ippdrv->start = rotator_ippdrv_start;
> > >> +	ret = rotator_init_prop_list(ippdrv);
> > >> +	if (ret < 0) {
> > >> +		dev_err(dev, "failed to init property list.\n");
> > >> +		goto err_ippdrv_register;
> > >> +	}
> > >> +
> > >> +	DRM_DEBUG_KMS("%s:ippdrv[0x%x]\n", __func__, (int)ippdrv);
> > >> +
> > >> +	platform_set_drvdata(pdev, rot);
> > >> +
> > >> +	ret = exynos_drm_ippdrv_register(ippdrv);
> > >> +	if (ret < 0) {
> > >> +		dev_err(dev, "failed to register drm rotator
device\n");
> > >> +		kfree(ippdrv->prop_list);
> > >> +		goto err_ippdrv_register;
> > >> +	}
> > >> +
> > >> +	dev_info(dev, "The exynos rotator is probed
successfully\n");
> > >> +
> > >> +	return 0;
> > >> +
> > >> +err_ippdrv_register:
> > >> +	pm_runtime_disable(dev);
> > >> +	clk_put(rot->clock);
> > >> +err_clk_get:
> > >> +	free_irq(rot->irq, rot);
> > >> +err_get_irq:
> > >> +	iounmap(rot->regs);
> > >> +err_ioremap:
> > >> +	release_resource(rot->regs_res);
> > >> +	kfree(rot->regs_res);
> > >> +err_get_resource:
> > >> +	kfree(rot);
> > >> +	return ret;
> > >> +}
> > >> +
> > >> +static int __devexit rotator_remove(struct platform_device *pdev)
> > >> +{
> > >> +	struct device *dev = &pdev->dev;
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> > >> +
> > >> +	kfree(ippdrv->prop_list);
> > >> +	exynos_drm_ippdrv_unregister(ippdrv);
> > >> +
> > >> +	pm_runtime_disable(dev);
> > >> +	clk_put(rot->clock);
> > >> +
> > >> +	free_irq(rot->irq, rot);
> > >> +
> > >> +	iounmap(rot->regs);
> > >> +
> > >> +	release_resource(rot->regs_res);
> > >> +	kfree(rot->regs_res);
> > >> +
> > >> +	kfree(rot);
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +struct rot_limit_table rot_limit_tbl = {
> > >> +	.ycbcr420_2p = {
> > >> +		.min_w = 32,
> > >> +		.min_h = 32,
> > >> +		.max_w = SZ_32K,
> > >> +		.max_h = SZ_32K,
> > >> +		.align = 3,
> > >> +	},
> > >> +	.rgb888 = {
> > >> +		.min_w = 8,
> > >> +		.min_h = 8,
> > >> +		.max_w = SZ_8K,
> > >> +		.max_h = SZ_8K,
> > >> +		.align = 2,
> > >> +	},
> > >> +};
> > >> +
> > >> +struct platform_device_id rotator_driver_ids[] = {
> > >> +	{
> > >> +		.name		= "exynos-rot",
> > >> +		.driver_data	= (unsigned long)&rot_limit_tbl,
> > >> +	},
> > >> +	{},
> > >> +};
> > >> +
> > >> +static int rotator_clk_crtl(struct rot_context *rot, bool enable)
> > >> +{
> > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > >> +
> > >> +	if (enable) {
> > >> +		clk_enable(rot->clock);
> > >> +		rot->suspended = false;
> > >> +	} else {
> > >> +		clk_disable(rot->clock);
> > >> +		rot->suspended = true;
> > >> +	}
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +
> > >> +
> > >> +#ifdef CONFIG_PM_SLEEP
> > >> +static int rotator_suspend(struct device *dev)
> > >> +{
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +
> > >> +	/* ToDo */
> > >> +
> > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > >> +
> > >> +	if (pm_runtime_suspended(dev))
> > >> +		return 0;
> > >> +
> > >> +	return rotator_clk_crtl(rot, false);
> > >> +}
> > >> +
> > >> +static int rotator_resume(struct device *dev)
> > >> +{
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +
> > >> +	/* ToDo */
> > >> +
> > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > >> +
> > >> +	if (!pm_runtime_suspended(dev))
> > >> +		return rotator_clk_crtl(rot, true);
> > >> +
> > >> +	return 0;
> > >> +}
> > >> +#endif
> > >> +
> > >> +#ifdef CONFIG_PM_RUNTIME
> > >> +static int rotator_runtime_suspend(struct device *dev)
> > >> +{
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +
> > >> +	/* ToDo */
> > >> +
> > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > >> +
> > >> +	return  rotator_clk_crtl(rot, false);
> > >> +}
> > >> +
> > >> +static int rotator_runtime_resume(struct device *dev)
> > >> +{
> > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > >> +
> > >> +	/* ToDo */
> > >> +
> > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > >> +
> > >> +	return  rotator_clk_crtl(rot, true);
> > >> +}
> > >> +#endif
> > >> +
> > >> +static const struct dev_pm_ops rotator_pm_ops = {
> > >> +	SET_SYSTEM_SLEEP_PM_OPS(rotator_suspend, rotator_resume)
> > >> +	SET_RUNTIME_PM_OPS(rotator_runtime_suspend,
rotator_runtime_resume,
> > >> +
> > > NULL)
> > >> +};
> > >> +
> > >> +struct platform_driver rotator_driver = {
> > >> +	.probe		= rotator_probe,
> > >> +	.remove		= __devexit_p(rotator_remove),
> > >> +	.id_table	= rotator_driver_ids,
> > >> +	.driver		= {
> > >> +		.name	= "exynos-rot",
> > >> +		.owner	= THIS_MODULE,
> > >> +		.pm	= &rotator_pm_ops,
> > >> +	},
> > >> +};
> > >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> > >> b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> > >> new file mode 100644
> > >> index 0000000..fe929c9
> > >> --- /dev/null
> > >> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> > >> @@ -0,0 +1,13 @@
> > >> +/*
> > >> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> > >> + * Authors: YoungJun Cho <yj44.cho@samsung.com>
> > >> + *
> > >> + * This program is free software; you can redistribute it and/or
> > modify
> > >> + * it under the terms of the GNU General Public License version 2 as
> > >> + * published by the Free Software Foundationr
> > >> + */
> > >> +
> > >> +#ifndef	_EXYNOS_DRM_ROTATOR_H_
> > >> +#define	_EXYNOS_DRM_ROTATOR_H_
> > >> +
> > >> +#endif
> > >> diff --git a/drivers/gpu/drm/exynos/regs-rotator.h
> > >> b/drivers/gpu/drm/exynos/regs-rotator.h
> > >> new file mode 100644
> > >> index 0000000..a09ac6e
> > >> --- /dev/null
> > >> +++ b/drivers/gpu/drm/exynos/regs-rotator.h
> > >> @@ -0,0 +1,73 @@
> > >> +/* drivers/gpu/drm/exynos/regs-rotator.h
> > >> + *
> > >> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> > >> + *		http://www.samsung.com/
> > >> + *
> > >> + * Register definition file for Samsung Rotator Interface (Rotator)
> > >> driver
> > >> + *
> > >> + * This program is free software; you can redistribute it and/or
> > modify
> > >> + * it under the terms of the GNU General Public License version 2 as
> > >> + * published by the Free Software Foundation.
> > >> +*/
> > >> +
> > >> +#ifndef EXYNOS_REGS_ROTATOR_H
> > >> +#define EXYNOS_REGS_ROTATOR_H
> > >> +
> > >> +/* Configuration */
> > >> +#define ROT_CONFIG			0x00
> > >> +#define ROT_CONFIG_IRQ			(3 << 8)
> > >> +
> > >> +/* Image Control */
> > >> +#define ROT_CONTROL			0x10
> > >> +#define ROT_CONTROL_PATTERN_WRITE	(1 << 16)
> > >> +#define ROT_CONTROL_FMT_YCBCR420_2P	(1 << 8)
> > >> +#define ROT_CONTROL_FMT_RGB888		(6 << 8)
> > >> +#define ROT_CONTROL_FMT_MASK		(7 << 8)
> > >> +#define ROT_CONTROL_FLIP_VERTICAL	(2 << 6)
> > >> +#define ROT_CONTROL_FLIP_HORIZONTAL	(3 << 6)
> > >> +#define ROT_CONTROL_FLIP_MASK		(3 << 6)
> > >> +#define ROT_CONTROL_ROT_90		(1 << 4)
> > >> +#define ROT_CONTROL_ROT_180		(2 << 4)
> > >> +#define ROT_CONTROL_ROT_270		(3 << 4)
> > >> +#define ROT_CONTROL_ROT_MASK		(3 << 4)
> > >> +#define ROT_CONTROL_START		(1 << 0)
> > >> +
> > >> +/* Status */
> > >> +#define ROT_STATUS			0x20
> > >> +#define ROT_STATUS_IRQ_PENDING(x)	(1 << (x))
> > >> +#define ROT_STATUS_IRQ(x)		(((x) >> 8) & 0x3)
> > >> +#define ROT_STATUS_IRQ_VAL_COMPLETE	1
> > >> +#define ROT_STATUS_IRQ_VAL_ILLEGAL	2
> > >> +
> > >> +/* Buffer Address */
> > >> +#define ROT_SRC_BUF_ADDR(n)		(0x30 + ((n) << 2))
> > >> +#define ROT_DST_BUF_ADDR(n)		(0x50 + ((n) << 2))
> > >> +
> > >> +/* Buffer Size */
> > >> +#define ROT_SRC_BUF_SIZE		0x3c
> > >> +#define ROT_DST_BUF_SIZE		0x5c
> > >> +#define ROT_SET_BUF_SIZE_H(x)		((x) << 16)
> > >> +#define ROT_SET_BUF_SIZE_W(x)		((x) << 0)
> > >> +#define ROT_GET_BUF_SIZE_H(x)		((x) >> 16)
> > >> +#define ROT_GET_BUF_SIZE_W(x)		((x) & 0xffff)
> > >> +
> > >> +/* Crop Position */
> > >> +#define ROT_SRC_CROP_POS		0x40
> > >> +#define ROT_DST_CROP_POS		0x60
> > >> +#define ROT_CROP_POS_Y(x)		((x) << 16)
> > >> +#define ROT_CROP_POS_X(x)		((x) << 0)
> > >> +
> > >> +/* Source Crop Size */
> > >> +#define ROT_SRC_CROP_SIZE		0x44
> > >> +#define ROT_SRC_CROP_SIZE_H(x)		((x) << 16)
> > >> +#define ROT_SRC_CROP_SIZE_W(x)		((x) << 0)
> > >> +
> > >> +/* Round to nearest aligned value */
> > >> +#define ROT_ALIGN(x, align, mask)	(((x) + (1 << ((align) -
1))) &
> > >> (mask))
> > >> +/* Minimum limit value */
> > >> +#define ROT_MIN(min, mask)		(((min) + ~(mask)) & (mask))
> > >> +/* Maximum limit value */
> > >> +#define ROT_MAX(max, mask)		((max) & (mask))
> > >> +
> > >> +#endif /* EXYNOS_REGS_ROTATOR_H */
> > >> +
> > >> --
> > >> 1.7.0.4
> > >
> > >
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
  2012-12-12 10:00         ` Inki Dae
@ 2012-12-12 10:39           ` Inki Dae
  2012-12-12 10:51             ` Eunchul Kim
  0 siblings, 1 reply; 18+ messages in thread
From: Inki Dae @ 2012-12-12 10:39 UTC (permalink / raw)
  To: 'Inki Dae', 'Eunchul Kim'
  Cc: jy0.jeon, sw0312.kim, jaejoon.seo, dri-devel, kyungmin.park, jmock.shin



> -----Original Message-----
> From: Inki Dae [mailto:inki.dae@samsung.com]
> Sent: Wednesday, December 12, 2012 7:01 PM
> To: 'Inki Dae'; 'Eunchul Kim'
> Cc: jy0.jeon@samsung.com; sw0312.kim@samsung.com; jaejoon.seo@samsung.com;
> kyungmin.park@samsung.com; dri-devel@lists.freedesktop.org;
> jmock.shin@samsung.com
> Subject: RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> 
> 
> 
> > -----Original Message-----
> > From: dri-devel-bounces+inki.dae=samsung.com@lists.freedesktop.org
> > [mailto:dri-devel-bounces+inki.dae=samsung.com@lists.freedesktop.org] On
> > Behalf Of Inki Dae
> > Sent: Wednesday, December 12, 2012 6:42 PM
> > To: 'Eunchul Kim'
> > Cc: jy0.jeon@samsung.com; sw0312.kim@samsung.com;
> jaejoon.seo@samsung.com;
> > kyungmin.park@samsung.com; dri-devel@lists.freedesktop.org;
> > jmock.shin@samsung.com
> > Subject: RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> >
> >
> >
> > > -----Original Message-----
> > > From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> > > Sent: Wednesday, December 12, 2012 6:26 PM
> > > To: Inki Dae
> > > Cc: dri-devel@lists.freedesktop.org; jy0.jeon@samsung.com;
> > > yj44.cho@samsung.com; jmock.shin@samsung.com; jaejoon.seo@samsung.com;
> > > kyungmin.park@samsung.com; sw0312.kim@samsung.com; Joonyoung Shim
> > > Subject: Re: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> > >
> > > Thank's your comment.
> > >
> > > I answer your comment. please check that.
> > >
> > > Thank's
> > >
> > > BR
> > > Eunchul Kim
> > >
> > > On 12/12/2012 05:29 PM, Inki Dae wrote:
> > > >
> > > >
> > > >> -----Original Message-----
> > > >> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
> > > >> Sent: Wednesday, December 12, 2012 4:35 PM
> > > >> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
> > > >> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com;
> > jmock.shin@samsung.com;
> > > >> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
> > > >> chulspro.kim@samsung.com
> > > >> Subject: [RFC v3 4/5] drm/exynos: add rotator ipp driver
> > > >>
> > > >> Rotator supports rotation/crop/flip and input/output DMA operations
> > > >> Rotator ipp driver supports 90,180,270 degree rotaion and vertical,
> > > >> horizontal flip.
> > > >> and has some limitations(source and destination format have to be
> > same,
> > > no
> > > >> scaler)
> > > >>
> > > >> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
> > > >> Signed-off-by: Youngjun Cho <yj44.cho@samsung.com>
> > > >> ---
> > > >>   drivers/gpu/drm/exynos/Kconfig              |    7 +
> > > >>   drivers/gpu/drm/exynos/Makefile             |    1 +
> > > >>   drivers/gpu/drm/exynos/exynos_drm_drv.c     |   15 +
> > > >>   drivers/gpu/drm/exynos/exynos_drm_drv.h     |    1 +
> > > >>   drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829
> > > >> +++++++++++++++++++++++++++
> > > >>   drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
> > > >>   drivers/gpu/drm/exynos/regs-rotator.h       |   73 +++
> > > >>   7 files changed, 939 insertions(+), 0 deletions(-)
> > > >>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
> > > >>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
> > > >>   create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
> > > >>
> > > >> diff --git a/drivers/gpu/drm/exynos/Kconfig
> > > >> b/drivers/gpu/drm/exynos/Kconfig
> > > >> index 4915ab6..4860835 100644
> > > >> --- a/drivers/gpu/drm/exynos/Kconfig
> > > >> +++ b/drivers/gpu/drm/exynos/Kconfig
> > > >> @@ -57,3 +57,10 @@ config DRM_EXYNOS_FIMC
> > > >>   	depends on DRM_EXYNOS_IPP
> > > >>   	help
> > > >>   	  Choose this option if you want to use Exynos FIMC for DRM.
> > > >> +
> > > >> +config DRM_EXYNOS_ROTATOR
> > > >> +	bool "Exynos DRM Rotator"
> > > >> +	depends on DRM_EXYNOS_IPP
> > > >> +	help
> > > >> +	  Choose this option if you want to use Exynos Rotator for
> DRM.
> > > >> +
> > > >> diff --git a/drivers/gpu/drm/exynos/Makefile
> > > >> b/drivers/gpu/drm/exynos/Makefile
> > > >> index 9710024..3b70668 100644
> > > >> --- a/drivers/gpu/drm/exynos/Makefile
> > > >> +++ b/drivers/gpu/drm/exynos/Makefile
> > > >> @@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+=
> > > >> exynos_drm_vidi.o
> > > >>   exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
> > > >>   exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
> > > >>   exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
> > > >> +exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+=
exynos_drm_rotator.o
> > > >>
> > > >>   obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
> > > >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > > >> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > > >> index 73f02ac..09d884b 100644
> > > >> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > > >> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> > > >> @@ -378,6 +378,12 @@ static int __init exynos_drm_init(void)
> > > >>   		goto out_fimc;
> > > >>   #endif
> > > >>
> > > >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> > > >> +	ret = platform_driver_register(&rotator_driver);
> > > >> +	if (ret < 0)
> > > >> +		goto out_rotator;
> > > >> +#endif
> > > >> +
> > > >>   #ifdef CONFIG_DRM_EXYNOS_IPP
> > > >>   	ret = platform_driver_register(&ipp_driver);
> > > >>   	if (ret < 0)
> > > >> @@ -406,6 +412,11 @@ out_drm:
> > > >>   out_ipp:
> > > >>   #endif
> > > >>
> > > >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> > > >> +	platform_driver_unregister(&rotator_driver);
> > > >> +out_rotator:
> > > >> +#endif
> > > >> +
> > > >>   #ifdef CONFIG_DRM_EXYNOS_FIMC
> > > >>   	platform_driver_unregister(&fimc_driver);
> > > >>   out_fimc:
> > > >> @@ -451,6 +462,10 @@ static void __exit exynos_drm_exit(void)
> > > >>   	platform_driver_unregister(&ipp_driver);
> > > >>   #endif
> > > >>
> > > >> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
> > > >> +	platform_driver_unregister(&rotator_driver);
> > > >> +#endif
> > > >> +
> > > >>   #ifdef CONFIG_DRM_EXYNOS_FIMC
> > > >>   	platform_driver_unregister(&fimc_driver);
> > > >>   #endif
> > > >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> > > >> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> > > >> index 14f9490..a74e37c 100644
> > > >> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> > > >> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> > > >> @@ -353,5 +353,6 @@ extern struct platform_driver
> > > >> exynos_drm_common_hdmi_driver;
> > > >>   extern struct platform_driver vidi_driver;
> > > >>   extern struct platform_driver g2d_driver;
> > > >>   extern struct platform_driver fimc_driver;
> > > >> +extern struct platform_driver rotator_driver;
> > > >>   extern struct platform_driver ipp_driver;
> > > >>   #endif
> > > >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> > > >> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> > > >> new file mode 100644
> > > >> index 0000000..121569c
> > > >> --- /dev/null
> > > >> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
> > > >> @@ -0,0 +1,829 @@
> > > >> +/*
> > > >> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> > > >> + * Authors:
> > > >> + *	YoungJun Cho <yj44.cho@samsung.com>
> > > >> + *	Eunchul Kim <chulspro.kim@samsung.com>
> > > >> + *
> > > >> + * This program is free software; you can redistribute it and/or
> > > modify
> > > >> + * it under the terms of the GNU General Public License version 2
> as
> > > >> + * published by the Free Software Foundationr
> > > >> + */
> > > >> +
> > > >> +#include <linux/kernel.h>
> > > >> +#include <linux/module.h>
> > > >> +#include <linux/err.h>
> > > >> +#include <linux/interrupt.h>
> > > >> +#include <linux/io.h>
> > > >> +#include <linux/platform_device.h>
> > > >> +#include <linux/clk.h>
> > > >> +#include <linux/pm_runtime.h>
> > > >> +
> > > >> +#include <drm/drmP.h>
> > > >> +#include <drm/exynos_drm.h>
> > > >> +#include "regs-rotator.h"
> > > >> +#include "exynos_drm.h"
> > > >> +#include "exynos_drm_ipp.h"
> > > >> +
> > > >> +/*
> > > >> + * Rotator supports image crop/rotator and input/output DMA
> > operations.
> > > >> + * input DMA reads image data from the memory.
> > > >> + * output DMA writes image data to memory.
> > > >> + */
> > > >> +
> > > >> +#define get_rot_context(dev)
> > > >> 	platform_get_drvdata(to_platform_device(dev))
> > > >> +#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
> > > >> +					struct rot_context, ippdrv);
> > > >> +#define rot_read(offset)		readl(rot->regs + (offset))
> > > >> +#define rot_write(cfg, offset)	writel(cfg, rot->regs +
(offset))
> > > >> +
> > > >> +enum rot_irq_status {
> > > >> +	ROT_IRQ_STATUS_COMPLETE	= 8,
> > > >> +	ROT_IRQ_STATUS_ILLEGAL	= 9,
> > > >> +};
> > > >> +
> > > >> +/*
> > > >> + * A structure of limitation.
> > > >> + *
> > > >> + * @min_w: minimum width.
> > > >> + * @min_h: minimum height.
> > > >> + * @max_w: maximum width.
> > > >> + * @max_h: maximum height.
> > > >> + * @align: align size.
> > > >> + */
> > > >> +struct rot_limit {
> > > >> +	u32	min_w;
> > > >> +	u32	min_h;
> > > >> +	u32	max_w;
> > > >> +	u32	max_h;
> > > >> +	u32	align;
> > > >> +};
> > > >> +
> > > >> +/*
> > > >> + * A structure of limitation table.
> > > >> + *
> > > >> + * @ycbcr420_2p: case of YUV.
> > > >> + * @rgb888: case of RGB.
> > > >> + */
> > > >> +struct rot_limit_table {
> > > >> +	struct rot_limit	ycbcr420_2p;
> > > >> +	struct rot_limit	rgb888;
> > > >> +};
> > > >> +
> > > >> +/*
> > > >> + * A structure of rotator context.
> > > >> + * @ippdrv: prepare initialization using ippdrv.
> > > >> + * @regs_res: register resources.
> > > >> + * @regs: memory mapped io registers.
> > > >> + * @clock: rotator gate clock.
> > > >> + * @limit_tbl: limitation of rotator.
> > > >> + * @irq: irq number.
> > > >> + * @cur_buf_id: current operation buffer id.
> > > >> + * @suspended: suspended state.
> > > >> + */
> > > >> +struct rot_context {
> > > >> +	struct exynos_drm_ippdrv	ippdrv;
> > > >> +	struct resource	*regs_res;
> > > >> +	void __iomem	*regs;
> > > >> +	struct clk	*clock;
> > > >> +	struct rot_limit_table	*limit_tbl;
> > > >> +	int	irq;
> > > >> +	int	cur_buf_id[EXYNOS_DRM_OPS_MAX];
> > > >> +	bool	suspended;
> > > >> +};
> > > >> +
> > > >> +static void rotator_reg_set_irq(struct rot_context *rot, bool
> enable)
> > > >> +{
> > > >> +	u32 val = rot_read(ROT_CONFIG);
> > > >> +
> > > >> +	if (enable == true)
> > > >> +		val |= ROT_CONFIG_IRQ;
> > > >> +	else
> > > >> +		val &= ~ROT_CONFIG_IRQ;
> > > >> +
> > > >> +	rot_write(val, ROT_CONFIG);
> > > >> +}
> > > >> +
> > > >> +static u32 rotator_reg_get_format(struct rot_context *rot)
> > > >> +{
> > > >> +	u32 val = rot_read(ROT_CONTROL);
> > > >> +
> > > >> +	val &= ROT_CONTROL_FMT_MASK;
> > > >> +
> > > >> +	return val;
> > > >> +}
> > > >> +
> > > >> +static enum rot_irq_status rotator_reg_get_irq_status(struct
> > > rot_context
> > > >> *rot)
> > > >> +{
> > > >> +	u32 val = rot_read(ROT_STATUS);
> > > >> +
> > > >> +	val = ROT_STATUS_IRQ(val);
> > > >> +
> > > >> +	if (val == ROT_STATUS_IRQ_VAL_COMPLETE)
> > > >> +		return ROT_IRQ_STATUS_COMPLETE;
> > > >> +	else
> > > >
> > > > Remove else.
> > >
> > > - done.
> > >
> > > >
> > > >> +		return ROT_IRQ_STATUS_ILLEGAL;
> > > >> +}
> > > >> +
> > > >> +static irqreturn_t rotator_irq_handler(int irq, void *arg)
> > > >> +{
> > > >> +	struct rot_context *rot = arg;
> > > >> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> > > >> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
> > > >> +	struct drm_exynos_ipp_event_work *event_work =
> c_node->event_work;
> > > >> +	enum rot_irq_status irq_status;
> > > >> +	u32 val;
> > > >> +
> > > >> +	/* Get execution result */
> > > >> +	irq_status = rotator_reg_get_irq_status(rot);
> > > >> +
> > > >> +	/* clear status */
> > > >> +	val = rot_read(ROT_STATUS);
> > > >> +	val |= ROT_STATUS_IRQ_PENDING((u32)irq_status);
> > > >> +	rot_write(val, ROT_STATUS);
> > > >> +
> > > >> +	if (irq_status == ROT_IRQ_STATUS_COMPLETE) {
> > > >> +		event_work->ippdrv = ippdrv;
> > > >> +		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
> > > >> +			rot->cur_buf_id[EXYNOS_DRM_OPS_DST];
> > > >> +		queue_work(ippdrv->event_workq,
> > > >> +			(struct work_struct *)event_work);
> > > >> +	} else
> > > >> +		DRM_ERROR("the SFR is set illegally\n");
> > > >> +
> > > >> +	return IRQ_HANDLED;
> > > >> +}
> > > >> +
> > > >> +static void rotator_align_size(struct rot_context *rot, u32 fmt,
> u32
> > > >> *hsize,
> > > >> +		u32 *vsize)
> > > >> +{
> > > >> +	struct rot_limit_table *limit_tbl = rot->limit_tbl;
> > > >> +	struct rot_limit *limit;
> > > >> +	u32 mask, val;
> > > >> +
> > > >> +	/* Get size limit */
> > > >> +	if (fmt == ROT_CONTROL_FMT_RGB888)
> > > >> +		limit = &limit_tbl->rgb888;
> > > >> +	else
> > > >> +		limit = &limit_tbl->ycbcr420_2p;
> > > >> +
> > > >> +	/* Get mask for rounding to nearest aligned val */
> > > >> +	mask = ~((1 << limit->align) - 1);
> > > >> +
> > > >> +	/* Set aligned width */
> > > >> +	val = ROT_ALIGN(*hsize, limit->align, mask);
> > > >> +	if (val < limit->min_w)
> > > >> +		*hsize = ROT_MIN(limit->min_w, mask);
> > > >> +	else if (val > limit->max_w)
> > > >> +		*hsize = ROT_MAX(limit->max_w, mask);
> > > >> +	else
> > > >> +		*hsize = val;
> > > >> +
> > > >> +	/* Set aligned height */
> > > >> +	val = ROT_ALIGN(*vsize, limit->align, mask);
> > > >> +	if (val < limit->min_h)
> > > >> +		*vsize = ROT_MIN(limit->min_h, mask);
> > > >> +	else if (val > limit->max_h)
> > > >> +		*vsize = ROT_MAX(limit->max_h, mask);
> > > >> +	else
> > > >> +		*vsize = val;
> > > >> +}
> > > >> +
> > > >> +static int rotator_src_set_fmt(struct device *dev, u32 fmt)
> > > >> +{
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +	u32 val;
> > > >> +
> > > >> +	val = rot_read(ROT_CONTROL);
> > > >> +	val &= ~ROT_CONTROL_FMT_MASK;
> > > >> +
> > > >> +	switch (fmt) {
> > > >> +	case DRM_FORMAT_NV12:
> > > >> +		val |= ROT_CONTROL_FMT_YCBCR420_2P;
> > > >> +		break;
> > > >> +	case DRM_FORMAT_XRGB8888:
> > > >> +		val |= ROT_CONTROL_FMT_RGB888;
> > > >> +		break;
> > > >> +	default:
> > > >> +		DRM_ERROR("invalid image format\n");
> > > >> +		return -EINVAL;
> > > >> +	}
> > > >> +
> > > >> +	rot_write(val, ROT_CONTROL);
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +static int rotator_src_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;
> > > >> +	u32 val;
> > > >> +
> > > >> +	/* 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 */
> > > >> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> > > >> +	rot_write(val, ROT_SRC_BUF_SIZE);
> > > >> +
> > > >> +	/* Set crop image position configuration */
> > > >> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> > > >> +	rot_write(val, ROT_SRC_CROP_POS);
> > > >> +	val = ROT_SRC_CROP_SIZE_H(pos->h) |
> ROT_SRC_CROP_SIZE_W(pos->w);
> > > >> +	rot_write(val, ROT_SRC_CROP_SIZE);
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +static int rotator_src_set_addr(struct device *dev,
> > > >> +		struct drm_exynos_ipp_buf_info *buf_info,
> > > >> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> > > >> +{
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> > > >> +	u32 val, fmt, hsize, vsize;
> > > >> +	int i;
> > > >> +
> > > >> +	/* Set current buf_id */
> > > >> +	rot->cur_buf_id[EXYNOS_DRM_OPS_SRC] = buf_id;
> > > >> +
> > > >> +	switch (buf_type) {
> > > >> +	case IPP_BUF_ENQUEUE:
> > > >> +		/* Set address configuration */
> > > >> +		for_each_ipp_planar(i)
> > > >> +			addr[i] = buf_info->base[i];
> > > >
> > > > Check NULL.
> > >
> > > - If not copy this state, we need to memset about addr.
> > >    no need check null.
> > >
> > > >
> > > >> +
> > > >> +		/* Get format */
> > > >> +		fmt = rotator_reg_get_format(rot);
> > > >> +
> > > >> +		/* Re-set cb planar for NV12 format */
> > > >> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> > > >> +					(addr[EXYNOS_DRM_PLANAR_CB]
> ==
> > > > 0x00)) {
> > > >
> > > > What is 0x00?
> > >
> > > - It is NULL, I changed !addr instead of addr == 0x00
> > >
> > > >
> > > >> +
> > > >> +			val = rot_read(ROT_SRC_BUF_SIZE);
> > > >> +			hsize = ROT_GET_BUF_SIZE_W(val);
> > > >> +			vsize = ROT_GET_BUF_SIZE_H(val);
> > > >> +
> > > >> +			/* Set cb planar */
> > > >> +			addr[EXYNOS_DRM_PLANAR_CB] =
> > > >> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize *
> vsize;
> > > >> +		}
> > > >> +
> > > >> +		for_each_ipp_planar(i)
> > > >> +			rot_write(addr[i], ROT_SRC_BUF_ADDR(i));
> > > >> +		break;
> > > >> +	case IPP_BUF_DEQUEUE:
> > > >> +		for_each_ipp_planar(i)
> > > >> +			rot_write(0x0, ROT_SRC_BUF_ADDR(i));
> > > >> +		break;
> > > >> +	default:
> > > >> +		/* Nothing to do */
> > > >> +		break;
> > > >> +	}
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +static int rotator_dst_set_transf(struct device *dev,
> > > >> +		enum drm_exynos_degree degree,
> > > >> +		enum drm_exynos_flip flip)
> > > >> +{
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +	u32 val;
> > > >> +
> > > >> +	/* Set transform configuration */
> > > >> +	val = rot_read(ROT_CONTROL);
> > > >> +	val &= ~ROT_CONTROL_FLIP_MASK;
> > > >> +
> > > >> +	switch (flip) {
> > > >> +	case EXYNOS_DRM_FLIP_VERTICAL:
> > > >> +		val |= ROT_CONTROL_FLIP_VERTICAL;
> > > >> +		break;
> > > >> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> > > >> +		val |= ROT_CONTROL_FLIP_HORIZONTAL;
> > > >> +		break;
> > > >> +	default:
> > > >> +		/* Flip None */
> > > >> +		break;
> > > >> +	}
> > > >> +
> > > >> +	val &= ~ROT_CONTROL_ROT_MASK;
> > > >> +
> > > >> +	switch (degree) {
> > > >> +	case EXYNOS_DRM_DEGREE_90:
> > > >> +		val |= ROT_CONTROL_ROT_90;
> > > >> +		break;
> > > >> +	case EXYNOS_DRM_DEGREE_180:
> > > >> +		val |= ROT_CONTROL_ROT_180;
> > > >> +		break;
> > > >> +	case EXYNOS_DRM_DEGREE_270:
> > > >> +		val |= ROT_CONTROL_ROT_270;
> > > >> +		break;
> > > >> +	default:
> > > >> +		/* Rotation 0 Degree */
> > > >> +		break;
> > > >> +	}
> > > >> +
> > > >> +	rot_write(val, ROT_CONTROL);
> > > >> +
> > > >> +	/* Check degree for setting buffer size swap */
> > > >> +	if ((degree == EXYNOS_DRM_DEGREE_90) ||
> > > >> +		(degree == EXYNOS_DRM_DEGREE_270))
> > > >> +		return 1;
> > > >
> > > > Correct return type. This function should return 0 or negative.
> > >
> > > - no ~ this return type is boolean true or false.
> > >    but we need to error handling so, we use integer as you know
> > >    we reviewed this routine at our local git from our team(you and
me).
> > >
> > > >
> > > >> +	else
> > > >> +		return 0;
> > > >
> > > > Ditto.
> > >
> > > - ditto.
> > >
> > > >
> > > >> +}
> > > >> +
> > > >> +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 val, fmt, hsize, vsize;
> > > >> +
> > > >> +	/* Get format */
> > > >> +	fmt = rotator_reg_get_format(rot);
> > > >
> > > > Check if fmt is valid or not.
> > >
> > > - added rotator_check_fmt()
> > >
> > > >
> > > >> +
> > > >> +	/* Align buffer size */
> > > >> +	hsize = sz->hsize;
> > > >> +	vsize = sz->vsize;
> > > >> +	rotator_align_size(rot, fmt, &hsize, &vsize);
> > > >> +
> > > >> +	/* Set buffer size configuration */
> > > >> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
> > > >> +	rot_write(val, ROT_DST_BUF_SIZE);
> > > >> +
> > > >> +	/* Set crop image position configuration */
> > > >> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
> > > >> +	rot_write(val, ROT_DST_CROP_POS);
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +static int rotator_dst_set_addr(struct device *dev,
> > > >> +		struct drm_exynos_ipp_buf_info *buf_info,
> > > >> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
> > > >> +{
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
> > > >> +	u32 val, fmt, hsize, vsize;
> > > >> +	int i;
> > > >> +
> > > >> +	/* Set current buf_id */
> > > >> +	rot->cur_buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
> > > >> +
> > > >> +	switch (buf_type) {
> > > >> +	case IPP_BUF_ENQUEUE:
> > > >> +		/* Set address configuration */
> > > >> +		for_each_ipp_planar(i)
> > > >> +			addr[i] = buf_info->base[i];
> > > >> +
> > > >> +		/* Get format */
> > > >> +		fmt = rotator_reg_get_format(rot);
> > > >
> > > > Check if fmt is valid or not.
> > >
> > > - done.
> > >
> > > >
> > > >> +
> > > >> +		/* Re-set cb planar for NV12 format */
> > > >> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
> > > >> +					(addr[EXYNOS_DRM_PLANAR_CB]
> ==
> > > > 0x00)) {
> > > >> +			/* Get buf size */
> > > >> +			val = rot_read(ROT_DST_BUF_SIZE);
> > > >> +
> > > >> +			hsize = ROT_GET_BUF_SIZE_W(val);
> > > >> +			vsize = ROT_GET_BUF_SIZE_H(val);
> > > >> +
> > > >> +			/* Set cb planar */
> > > >> +			addr[EXYNOS_DRM_PLANAR_CB] =
> > > >> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize *
> vsize;
> > > >> +		}
> > > >> +
> > > >> +		for_each_ipp_planar(i)
> > > >> +			rot_write(addr[i], ROT_DST_BUF_ADDR(i));
> > > >> +		break;
> > > >> +	case IPP_BUF_DEQUEUE:
> > > >> +		for_each_ipp_planar(i)
> > > >> +			rot_write(0x0, ROT_DST_BUF_ADDR(i));
> > > >> +		break;
> > > >> +	default:
> > > >> +		/* Nothing to do */
> > > >> +		break;
> > > >> +	}
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +static struct exynos_drm_ipp_ops rot_src_ops = {
> > > >> +	.set_fmt	=	rotator_src_set_fmt,
> > > >> +	.set_size	=	rotator_src_set_size,
> > > >> +	.set_addr	=	rotator_src_set_addr,
> > > >> +};
> > > >> +
> > > >> +static struct exynos_drm_ipp_ops rot_dst_ops = {
> > > >> +	.set_transf	=	rotator_dst_set_transf,
> > > >> +	.set_size	=	rotator_dst_set_size,
> > > >> +	.set_addr	=	rotator_dst_set_addr,
> > > >> +};
> > > >> +
> > > >> +static int rotator_init_prop_list(struct exynos_drm_ippdrv
*ippdrv)
> > > >> +{
> > > >> +	struct drm_exynos_ipp_prop_list *prop_list;
> > > >> +
> > > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > > >> +
> > > >> +	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
> > > >> +	if (!prop_list) {
> > > >> +		DRM_ERROR("failed to alloc property list.\n");
> > > >> +		return -ENOMEM;
> > > >> +	}
> > > >> +
> > > >> +	/*ToDo fix support function list*/
> > > >> +
> > > >> +	prop_list->version = 1;
> > > >> +	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
> > > >> +				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
> > > >> +	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
> > > >> +				(1 << EXYNOS_DRM_DEGREE_90) |
> > > >> +				(1 << EXYNOS_DRM_DEGREE_180) |
> > > >> +				(1 << EXYNOS_DRM_DEGREE_270);
> > > >> +	prop_list->csc = 0;
> > > >> +	prop_list->crop = 0;
> > > >> +	prop_list->scale = 0;
> > > >> +
> > > >> +	ippdrv->prop_list = prop_list;
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +static int rotator_ippdrv_check_property(struct device *dev,
> > > >> +		struct drm_exynos_ipp_property *property)
> > > >> +{
> > > >> +	struct drm_exynos_ipp_config *src_config =
> > > >> +
> > > > &property->config[EXYNOS_DRM_OPS_SRC];
> > > >> +	struct drm_exynos_ipp_config *dst_config =
> > > >> +
> > > > &property->config[EXYNOS_DRM_OPS_DST];
> > > >> +	struct drm_exynos_pos *src_pos = &src_config->pos;
> > > >> +	struct drm_exynos_pos *dst_pos = &dst_config->pos;
> > > >> +	struct drm_exynos_sz *src_sz = &src_config->sz;
> > > >> +	struct drm_exynos_sz *dst_sz = &dst_config->sz;
> > > >> +	bool swap = false;
> > > >> +
> > > >> +	/* Check format configuration */
> > > >> +	if (src_config->fmt != dst_config->fmt) {
> > > >> +		DRM_DEBUG_KMS("%s:not support csc feature\n",
> __func__);
> > > >> +		return -EINVAL;
> > > >> +	}
> > > >> +
> > > >> +	switch (src_config->fmt) {
> > > >> +	case DRM_FORMAT_XRGB8888:
> > > >> +	case DRM_FORMAT_NV12:
> > > >> +		/* No problem */
> > > >> +		break;
> > > >> +	default:
> > > >> +		DRM_DEBUG_KMS("%s:not support format\n", __func__);
> > > >> +		return -EINVAL;
> > > >> +	}
> > > >
> > > > Use macro instead of switch-case. this just checks only format type.
> > >
> > > - I don't thing so, If we make macro about this.
> > >    then we got some confusion about this macro at next change.
> > >    this case switch-case is better.
> > >    Do you prefer this ? please one more comment.
> > >
> > > #define drm_check_fmt(fmt) if (fmt == DRM_FORMAT_XRGB8888 || fmt ==
> > > DRM_FORMAT_NV12) \
> > > 					return true;
> >
> > #define drm_check_fmt(fmt)		((fmt & (DRM_FORMAT_XRGB8888 |
> > DRM_FORMAT_NV12)) ? true : false)
> >
> > if (drm_check_fmt(src_config->fmt))
> > 	Something;
> > else
> > 	Something;
> 
> Again,
> 
> #define DRM_FORMAT_MASK			(DRM_FORMAT_XRGB888 |
> DRM_FORMAT_NV12)
>  #define drm_check_fmt(fmt)		(((fmt & DRM_FORMAT_MASK) &
> (DRM_FORMAT_XRGB8888 | \
> 
> DRM_FORMAT_NV12)) ? true : false)
> 
>  if (drm_check_fmt(src_config->fmt))
>  	Something;
>  else
>  	Something;
> 

Ah, these format types have no bit field base. Just use switch-case and make
this code  to one function. And then just call that function.


> 
> >
> > >
> > > >
> > > >> +
> > > >> +	/* Check transform configuration */
> > > >> +	if (src_config->degree != EXYNOS_DRM_DEGREE_0) {
> > > >> +		DRM_DEBUG_KMS("%s:not support source-side
> rotation\n",
> > > >> +
> __func__);
> > > >> +		return -EINVAL;
> > > >> +	}
> > > >> +
> > > >> +	switch (dst_config->degree) {
> > > >> +	case EXYNOS_DRM_DEGREE_90:
> > > >> +	case EXYNOS_DRM_DEGREE_270:
> > > >> +		swap = true;
> > > >> +	case EXYNOS_DRM_DEGREE_0:
> > > >> +	case EXYNOS_DRM_DEGREE_180:
> > > >> +		/* No problem */
> > > >> +		break;
> > > >> +	default:
> > > >> +		DRM_DEBUG_KMS("%s:invalid degree\n", __func__);
> > > >> +		return -EINVAL;
> > > >> +	}
> > > >> +
> > > >> +	if (src_config->flip != EXYNOS_DRM_FLIP_NONE) {
> > > >> +		DRM_DEBUG_KMS("%s:not support source-side flip\n",
> > > > __func__);
> > > >> +		return -EINVAL;
> > > >> +	}
> > > >> +
> > > >> +	switch (dst_config->flip) {
> > > >> +	case EXYNOS_DRM_FLIP_NONE:
> > > >> +	case EXYNOS_DRM_FLIP_VERTICAL:
> > > >> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
> > > >> +		/* No problem */
> > > >> +		break;
> > > >> +	default:
> > > >> +		DRM_DEBUG_KMS("%s:invalid flip\n", __func__);
> > > >> +		return -EINVAL;
> > > >> +	}
> > > >
> > > > Use macro instead of switch-case. this just checks only flip type.
> > >
> > > - ditto. please one more comment.
> > >   in my opinion: I prefer enumeration use switch-case.
> >
> > What does each case do? Just check? If so, use macro as I mentioned. We
> > can't accept this codes.
> >
> > >
> > > >
> > > >> +
> > > >> +	/* Check size configuration */
> > > >> +	if ((src_pos->x + src_pos->w > src_sz->hsize) ||
> > > >> +		(src_pos->y + src_pos->h > src_sz->vsize)) {
> > > >> +		DRM_DEBUG_KMS("%s:out of source buffer bound\n",
> __func__);
> > > >> +		return -EINVAL;
> > > >> +	}
> > > >> +
> > > >> +	if (swap) {
> > > >> +		if ((dst_pos->x + dst_pos->h > dst_sz->vsize) ||
> > > >> +			(dst_pos->y + dst_pos->w > dst_sz->hsize)) {
> > > >> +			DRM_DEBUG_KMS("%s:out of destination buffer
> > > > bound\n",
> > > >> +
> __func__);
> > > >> +			return -EINVAL;
> > > >> +		}
> > > >> +
> > > >> +		if ((src_pos->w != dst_pos->h) || (src_pos->h !=
> > > > dst_pos->w))
> > > >> {
> > > >> +			DRM_DEBUG_KMS("%s:not support scale
> feature\n",
> > > >> +
> __func__);
> > > >> +			return -EINVAL;
> > > >> +		}
> > > >> +	} else {
> > > >> +		if ((dst_pos->x + dst_pos->w > dst_sz->hsize) ||
> > > >> +			(dst_pos->y + dst_pos->h > dst_sz->vsize)) {
> > > >> +			DRM_DEBUG_KMS("%s:out of destination buffer
> > > > bound\n",
> > > >> +
> __func__);
> > > >> +			return -EINVAL;
> > > >> +		}
> > > >> +
> > > >> +		if ((src_pos->w != dst_pos->w) || (src_pos->h !=
> > > > dst_pos->h))
> > > >> {
> > > >> +			DRM_DEBUG_KMS("%s:not support scale
> feature\n",
> > > >> +
> __func__);
> > > >> +			return -EINVAL;
> > > >> +		}
> > > >> +	}
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +static int rotator_ippdrv_start(struct device *dev, enum
> > > >> drm_exynos_ipp_cmd cmd)
> > > >> +{
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +	u32 val;
> > > >> +
> > > >> +	if (rot->suspended) {
> > > >> +		DRM_ERROR("suspended state\n");
> > > >> +		return -EPERM;
> > > >> +	}
> > > >> +
> > > >> +	if (cmd != IPP_CMD_M2M) {
> > > >> +		DRM_ERROR("not support cmd: %d\n", cmd);
> > > >> +		return -EINVAL;
> > > >> +	}
> > > >> +
> > > >> +	/* Set interrupt enable */
> > > >> +	rotator_reg_set_irq(rot, true);
> > > >> +
> > > >> +	val = rot_read(ROT_CONTROL);
> > > >> +	val |= ROT_CONTROL_START;
> > > >> +
> > > >> +	rot_write(val, ROT_CONTROL);
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +static int __devinit rotator_probe(struct platform_device *pdev)
> > > >> +{
> > > >> +	struct device *dev = &pdev->dev;
> > > >> +	struct rot_context *rot;
> > > >> +	struct resource *res;
> > > >> +	struct exynos_drm_ippdrv *ippdrv;
> > > >> +	int ret;
> > > >> +
> > > >> +	rot = kzalloc(sizeof(*rot), GFP_KERNEL);
> > > >> +	if (!rot) {
> > > >> +		dev_err(dev, "failed to allocate rot\n");
> > > >> +		return -ENOMEM;
> > > >> +	}
> > > >> +
> > > >> +	rot->limit_tbl = (struct rot_limit_table *)
> > > >> +
> platform_get_device_id(pdev)->driver_data;
> > > >> +
> > > >> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > >> +	if (!res) {
> > > >> +		dev_err(dev, "failed to find registers\n");
> > > >> +		ret = -ENOENT;
> > > >> +		goto err_get_resource;
> > > >> +	}
> > > >> +
> > > >> +	rot->regs_res = request_mem_region(res->start,
> resource_size(res),
> > > >> +
> > > > dev_name(dev));
> > > >> +	if (!rot->regs_res) {
> > > >> +		dev_err(dev, "failed to claim register region\n");
> > > >> +		ret = -ENOENT;
> > > >> +		goto err_get_resource;
> > > >> +	}
> > > >> +
> > > >> +	rot->regs = ioremap(res->start, resource_size(res));
> > > >> +	if (!rot->regs) {
> > > >> +		dev_err(dev, "failed to map register\n");
> > > >> +		ret = -ENXIO;
> > > >> +		goto err_ioremap;
> > > >> +	}
> > > >> +
> > > >> +	rot->irq = platform_get_irq(pdev, 0);
> > > >> +	if (rot->irq < 0) {
> > > >> +		dev_err(dev, "failed to get irq\n");
> > > >> +		ret = rot->irq;
> > > >> +		goto err_get_irq;
> > > >> +	}
> > > >> +
> > > >> +	ret = request_threaded_irq(rot->irq, NULL,
> rotator_irq_handler,
> > > >> +					IRQF_ONESHOT, "drm_rotator",
> rot);
> > > >> +	if (ret < 0) {
> > > >> +		dev_err(dev, "failed to request irq\n");
> > > >> +		goto err_get_irq;
> > > >> +	}
> > > >> +
> > > >> +	rot->clock = clk_get(dev, "rotator");
> > > >> +	if (IS_ERR_OR_NULL(rot->clock)) {
> > > >> +		dev_err(dev, "failed to get clock\n");
> > > >> +		ret = PTR_ERR(rot->clock);
> > > >> +		goto err_clk_get;
> > > >> +	}
> > > >> +
> > > >> +	pm_runtime_enable(dev);
> > > >> +
> > > >> +	ippdrv = &rot->ippdrv;
> > > >> +	ippdrv->dev = dev;
> > > >> +	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &rot_src_ops;
> > > >> +	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &rot_dst_ops;
> > > >> +	ippdrv->check_property = rotator_ippdrv_check_property;
> > > >> +	ippdrv->start = rotator_ippdrv_start;
> > > >> +	ret = rotator_init_prop_list(ippdrv);
> > > >> +	if (ret < 0) {
> > > >> +		dev_err(dev, "failed to init property list.\n");
> > > >> +		goto err_ippdrv_register;
> > > >> +	}
> > > >> +
> > > >> +	DRM_DEBUG_KMS("%s:ippdrv[0x%x]\n", __func__, (int)ippdrv);
> > > >> +
> > > >> +	platform_set_drvdata(pdev, rot);
> > > >> +
> > > >> +	ret = exynos_drm_ippdrv_register(ippdrv);
> > > >> +	if (ret < 0) {
> > > >> +		dev_err(dev, "failed to register drm rotator
> device\n");
> > > >> +		kfree(ippdrv->prop_list);
> > > >> +		goto err_ippdrv_register;
> > > >> +	}
> > > >> +
> > > >> +	dev_info(dev, "The exynos rotator is probed
> successfully\n");
> > > >> +
> > > >> +	return 0;
> > > >> +
> > > >> +err_ippdrv_register:
> > > >> +	pm_runtime_disable(dev);
> > > >> +	clk_put(rot->clock);
> > > >> +err_clk_get:
> > > >> +	free_irq(rot->irq, rot);
> > > >> +err_get_irq:
> > > >> +	iounmap(rot->regs);
> > > >> +err_ioremap:
> > > >> +	release_resource(rot->regs_res);
> > > >> +	kfree(rot->regs_res);
> > > >> +err_get_resource:
> > > >> +	kfree(rot);
> > > >> +	return ret;
> > > >> +}
> > > >> +
> > > >> +static int __devexit rotator_remove(struct platform_device *pdev)
> > > >> +{
> > > >> +	struct device *dev = &pdev->dev;
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
> > > >> +
> > > >> +	kfree(ippdrv->prop_list);
> > > >> +	exynos_drm_ippdrv_unregister(ippdrv);
> > > >> +
> > > >> +	pm_runtime_disable(dev);
> > > >> +	clk_put(rot->clock);
> > > >> +
> > > >> +	free_irq(rot->irq, rot);
> > > >> +
> > > >> +	iounmap(rot->regs);
> > > >> +
> > > >> +	release_resource(rot->regs_res);
> > > >> +	kfree(rot->regs_res);
> > > >> +
> > > >> +	kfree(rot);
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +struct rot_limit_table rot_limit_tbl = {
> > > >> +	.ycbcr420_2p = {
> > > >> +		.min_w = 32,
> > > >> +		.min_h = 32,
> > > >> +		.max_w = SZ_32K,
> > > >> +		.max_h = SZ_32K,
> > > >> +		.align = 3,
> > > >> +	},
> > > >> +	.rgb888 = {
> > > >> +		.min_w = 8,
> > > >> +		.min_h = 8,
> > > >> +		.max_w = SZ_8K,
> > > >> +		.max_h = SZ_8K,
> > > >> +		.align = 2,
> > > >> +	},
> > > >> +};
> > > >> +
> > > >> +struct platform_device_id rotator_driver_ids[] = {
> > > >> +	{
> > > >> +		.name		= "exynos-rot",
> > > >> +		.driver_data	= (unsigned long)&rot_limit_tbl,
> > > >> +	},
> > > >> +	{},
> > > >> +};
> > > >> +
> > > >> +static int rotator_clk_crtl(struct rot_context *rot, bool enable)
> > > >> +{
> > > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > > >> +
> > > >> +	if (enable) {
> > > >> +		clk_enable(rot->clock);
> > > >> +		rot->suspended = false;
> > > >> +	} else {
> > > >> +		clk_disable(rot->clock);
> > > >> +		rot->suspended = true;
> > > >> +	}
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +
> > > >> +
> > > >> +#ifdef CONFIG_PM_SLEEP
> > > >> +static int rotator_suspend(struct device *dev)
> > > >> +{
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +
> > > >> +	/* ToDo */
> > > >> +
> > > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > > >> +
> > > >> +	if (pm_runtime_suspended(dev))
> > > >> +		return 0;
> > > >> +
> > > >> +	return rotator_clk_crtl(rot, false);
> > > >> +}
> > > >> +
> > > >> +static int rotator_resume(struct device *dev)
> > > >> +{
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +
> > > >> +	/* ToDo */
> > > >> +
> > > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > > >> +
> > > >> +	if (!pm_runtime_suspended(dev))
> > > >> +		return rotator_clk_crtl(rot, true);
> > > >> +
> > > >> +	return 0;
> > > >> +}
> > > >> +#endif
> > > >> +
> > > >> +#ifdef CONFIG_PM_RUNTIME
> > > >> +static int rotator_runtime_suspend(struct device *dev)
> > > >> +{
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +
> > > >> +	/* ToDo */
> > > >> +
> > > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > > >> +
> > > >> +	return  rotator_clk_crtl(rot, false);
> > > >> +}
> > > >> +
> > > >> +static int rotator_runtime_resume(struct device *dev)
> > > >> +{
> > > >> +	struct rot_context *rot = dev_get_drvdata(dev);
> > > >> +
> > > >> +	/* ToDo */
> > > >> +
> > > >> +	DRM_DEBUG_KMS("%s\n", __func__);
> > > >> +
> > > >> +	return  rotator_clk_crtl(rot, true);
> > > >> +}
> > > >> +#endif
> > > >> +
> > > >> +static const struct dev_pm_ops rotator_pm_ops = {
> > > >> +	SET_SYSTEM_SLEEP_PM_OPS(rotator_suspend, rotator_resume)
> > > >> +	SET_RUNTIME_PM_OPS(rotator_runtime_suspend,
> rotator_runtime_resume,
> > > >> +
> > > > NULL)
> > > >> +};
> > > >> +
> > > >> +struct platform_driver rotator_driver = {
> > > >> +	.probe		= rotator_probe,
> > > >> +	.remove		= __devexit_p(rotator_remove),
> > > >> +	.id_table	= rotator_driver_ids,
> > > >> +	.driver		= {
> > > >> +		.name	= "exynos-rot",
> > > >> +		.owner	= THIS_MODULE,
> > > >> +		.pm	= &rotator_pm_ops,
> > > >> +	},
> > > >> +};
> > > >> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> > > >> b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> > > >> new file mode 100644
> > > >> index 0000000..fe929c9
> > > >> --- /dev/null
> > > >> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
> > > >> @@ -0,0 +1,13 @@
> > > >> +/*
> > > >> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> > > >> + * Authors: YoungJun Cho <yj44.cho@samsung.com>
> > > >> + *
> > > >> + * This program is free software; you can redistribute it and/or
> > > modify
> > > >> + * it under the terms of the GNU General Public License version 2
> as
> > > >> + * published by the Free Software Foundationr
> > > >> + */
> > > >> +
> > > >> +#ifndef	_EXYNOS_DRM_ROTATOR_H_
> > > >> +#define	_EXYNOS_DRM_ROTATOR_H_
> > > >> +
> > > >> +#endif
> > > >> diff --git a/drivers/gpu/drm/exynos/regs-rotator.h
> > > >> b/drivers/gpu/drm/exynos/regs-rotator.h
> > > >> new file mode 100644
> > > >> index 0000000..a09ac6e
> > > >> --- /dev/null
> > > >> +++ b/drivers/gpu/drm/exynos/regs-rotator.h
> > > >> @@ -0,0 +1,73 @@
> > > >> +/* drivers/gpu/drm/exynos/regs-rotator.h
> > > >> + *
> > > >> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> > > >> + *		http://www.samsung.com/
> > > >> + *
> > > >> + * Register definition file for Samsung Rotator Interface
(Rotator)
> > > >> driver
> > > >> + *
> > > >> + * This program is free software; you can redistribute it and/or
> > > modify
> > > >> + * it under the terms of the GNU General Public License version 2
> as
> > > >> + * published by the Free Software Foundation.
> > > >> +*/
> > > >> +
> > > >> +#ifndef EXYNOS_REGS_ROTATOR_H
> > > >> +#define EXYNOS_REGS_ROTATOR_H
> > > >> +
> > > >> +/* Configuration */
> > > >> +#define ROT_CONFIG			0x00
> > > >> +#define ROT_CONFIG_IRQ			(3 << 8)
> > > >> +
> > > >> +/* Image Control */
> > > >> +#define ROT_CONTROL			0x10
> > > >> +#define ROT_CONTROL_PATTERN_WRITE	(1 << 16)
> > > >> +#define ROT_CONTROL_FMT_YCBCR420_2P	(1 << 8)
> > > >> +#define ROT_CONTROL_FMT_RGB888		(6 << 8)
> > > >> +#define ROT_CONTROL_FMT_MASK		(7 << 8)
> > > >> +#define ROT_CONTROL_FLIP_VERTICAL	(2 << 6)
> > > >> +#define ROT_CONTROL_FLIP_HORIZONTAL	(3 << 6)
> > > >> +#define ROT_CONTROL_FLIP_MASK		(3 << 6)
> > > >> +#define ROT_CONTROL_ROT_90		(1 << 4)
> > > >> +#define ROT_CONTROL_ROT_180		(2 << 4)
> > > >> +#define ROT_CONTROL_ROT_270		(3 << 4)
> > > >> +#define ROT_CONTROL_ROT_MASK		(3 << 4)
> > > >> +#define ROT_CONTROL_START		(1 << 0)
> > > >> +
> > > >> +/* Status */
> > > >> +#define ROT_STATUS			0x20
> > > >> +#define ROT_STATUS_IRQ_PENDING(x)	(1 << (x))
> > > >> +#define ROT_STATUS_IRQ(x)		(((x) >> 8) & 0x3)
> > > >> +#define ROT_STATUS_IRQ_VAL_COMPLETE	1
> > > >> +#define ROT_STATUS_IRQ_VAL_ILLEGAL	2
> > > >> +
> > > >> +/* Buffer Address */
> > > >> +#define ROT_SRC_BUF_ADDR(n)		(0x30 + ((n) << 2))
> > > >> +#define ROT_DST_BUF_ADDR(n)		(0x50 + ((n) << 2))
> > > >> +
> > > >> +/* Buffer Size */
> > > >> +#define ROT_SRC_BUF_SIZE		0x3c
> > > >> +#define ROT_DST_BUF_SIZE		0x5c
> > > >> +#define ROT_SET_BUF_SIZE_H(x)		((x) << 16)
> > > >> +#define ROT_SET_BUF_SIZE_W(x)		((x) << 0)
> > > >> +#define ROT_GET_BUF_SIZE_H(x)		((x) >> 16)
> > > >> +#define ROT_GET_BUF_SIZE_W(x)		((x) & 0xffff)
> > > >> +
> > > >> +/* Crop Position */
> > > >> +#define ROT_SRC_CROP_POS		0x40
> > > >> +#define ROT_DST_CROP_POS		0x60
> > > >> +#define ROT_CROP_POS_Y(x)		((x) << 16)
> > > >> +#define ROT_CROP_POS_X(x)		((x) << 0)
> > > >> +
> > > >> +/* Source Crop Size */
> > > >> +#define ROT_SRC_CROP_SIZE		0x44
> > > >> +#define ROT_SRC_CROP_SIZE_H(x)		((x) << 16)
> > > >> +#define ROT_SRC_CROP_SIZE_W(x)		((x) << 0)
> > > >> +
> > > >> +/* Round to nearest aligned value */
> > > >> +#define ROT_ALIGN(x, align, mask)	(((x) + (1 << ((align) -
> 1))) &
> > > >> (mask))
> > > >> +/* Minimum limit value */
> > > >> +#define ROT_MIN(min, mask)		(((min) + ~(mask)) & (mask))
> > > >> +/* Maximum limit value */
> > > >> +#define ROT_MAX(max, mask)		((max) & (mask))
> > > >> +
> > > >> +#endif /* EXYNOS_REGS_ROTATOR_H */
> > > >> +
> > > >> --
> > > >> 1.7.0.4
> > > >
> > > >
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC v3 4/5] drm/exynos: add rotator ipp driver
  2012-12-12 10:39           ` Inki Dae
@ 2012-12-12 10:51             ` Eunchul Kim
  0 siblings, 0 replies; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12 10:51 UTC (permalink / raw)
  To: Inki Dae
  Cc: jy0.jeon, sw0312.kim, jaejoon.seo, dri-devel, kyungmin.park, jmock.shin

Thank's your comment

BR
Eunchul Kim

On 12/12/2012 07:39 PM, Inki Dae wrote:
>
>
>> -----Original Message-----
>> From: Inki Dae [mailto:inki.dae@samsung.com]
>> Sent: Wednesday, December 12, 2012 7:01 PM
>> To: 'Inki Dae'; 'Eunchul Kim'
>> Cc: jy0.jeon@samsung.com; sw0312.kim@samsung.com; jaejoon.seo@samsung.com;
>> kyungmin.park@samsung.com; dri-devel@lists.freedesktop.org;
>> jmock.shin@samsung.com
>> Subject: RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
>>
>>
>>
>>> -----Original Message-----
>>> From: dri-devel-bounces+inki.dae=samsung.com@lists.freedesktop.org
>>> [mailto:dri-devel-bounces+inki.dae=samsung.com@lists.freedesktop.org] On
>>> Behalf Of Inki Dae
>>> Sent: Wednesday, December 12, 2012 6:42 PM
>>> To: 'Eunchul Kim'
>>> Cc: jy0.jeon@samsung.com; sw0312.kim@samsung.com;
>> jaejoon.seo@samsung.com;
>>> kyungmin.park@samsung.com; dri-devel@lists.freedesktop.org;
>>> jmock.shin@samsung.com
>>> Subject: RE: [RFC v3 4/5] drm/exynos: add rotator ipp driver
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
>>>> Sent: Wednesday, December 12, 2012 6:26 PM
>>>> To: Inki Dae
>>>> Cc: dri-devel@lists.freedesktop.org; jy0.jeon@samsung.com;
>>>> yj44.cho@samsung.com; jmock.shin@samsung.com; jaejoon.seo@samsung.com;
>>>> kyungmin.park@samsung.com; sw0312.kim@samsung.com; Joonyoung Shim
>>>> Subject: Re: [RFC v3 4/5] drm/exynos: add rotator ipp driver
>>>>
>>>> Thank's your comment.
>>>>
>>>> I answer your comment. please check that.
>>>>
>>>> Thank's
>>>>
>>>> BR
>>>> Eunchul Kim
>>>>
>>>> On 12/12/2012 05:29 PM, Inki Dae wrote:
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
>>>>>> Sent: Wednesday, December 12, 2012 4:35 PM
>>>>>> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
>>>>>> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com;
>>> jmock.shin@samsung.com;
>>>>>> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
>>>>>> chulspro.kim@samsung.com
>>>>>> Subject: [RFC v3 4/5] drm/exynos: add rotator ipp driver
>>>>>>
>>>>>> Rotator supports rotation/crop/flip and input/output DMA operations
>>>>>> Rotator ipp driver supports 90,180,270 degree rotaion and vertical,
>>>>>> horizontal flip.
>>>>>> and has some limitations(source and destination format have to be
>>> same,
>>>> no
>>>>>> scaler)
>>>>>>
>>>>>> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
>>>>>> Signed-off-by: Youngjun Cho <yj44.cho@samsung.com>
>>>>>> ---
>>>>>>    drivers/gpu/drm/exynos/Kconfig              |    7 +
>>>>>>    drivers/gpu/drm/exynos/Makefile             |    1 +
>>>>>>    drivers/gpu/drm/exynos/exynos_drm_drv.c     |   15 +
>>>>>>    drivers/gpu/drm/exynos/exynos_drm_drv.h     |    1 +
>>>>>>    drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829
>>>>>> +++++++++++++++++++++++++++
>>>>>>    drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
>>>>>>    drivers/gpu/drm/exynos/regs-rotator.h       |   73 +++
>>>>>>    7 files changed, 939 insertions(+), 0 deletions(-)
>>>>>>    create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
>>>>>>    create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
>>>>>>    create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
>>>>>>
>>>>>> diff --git a/drivers/gpu/drm/exynos/Kconfig
>>>>>> b/drivers/gpu/drm/exynos/Kconfig
>>>>>> index 4915ab6..4860835 100644
>>>>>> --- a/drivers/gpu/drm/exynos/Kconfig
>>>>>> +++ b/drivers/gpu/drm/exynos/Kconfig
>>>>>> @@ -57,3 +57,10 @@ config DRM_EXYNOS_FIMC
>>>>>>    	depends on DRM_EXYNOS_IPP
>>>>>>    	help
>>>>>>    	  Choose this option if you want to use Exynos FIMC for DRM.
>>>>>> +
>>>>>> +config DRM_EXYNOS_ROTATOR
>>>>>> +	bool "Exynos DRM Rotator"
>>>>>> +	depends on DRM_EXYNOS_IPP
>>>>>> +	help
>>>>>> +	  Choose this option if you want to use Exynos Rotator for
>> DRM.
>>>>>> +
>>>>>> diff --git a/drivers/gpu/drm/exynos/Makefile
>>>>>> b/drivers/gpu/drm/exynos/Makefile
>>>>>> index 9710024..3b70668 100644
>>>>>> --- a/drivers/gpu/drm/exynos/Makefile
>>>>>> +++ b/drivers/gpu/drm/exynos/Makefile
>>>>>> @@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+=
>>>>>> exynos_drm_vidi.o
>>>>>>    exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
>>>>>>    exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
>>>>>>    exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
>>>>>> +exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+=
> exynos_drm_rotator.o
>>>>>>
>>>>>>    obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
>>>>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>>>> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>>>> index 73f02ac..09d884b 100644
>>>>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>>>> @@ -378,6 +378,12 @@ static int __init exynos_drm_init(void)
>>>>>>    		goto out_fimc;
>>>>>>    #endif
>>>>>>
>>>>>> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>>>>> +	ret = platform_driver_register(&rotator_driver);
>>>>>> +	if (ret < 0)
>>>>>> +		goto out_rotator;
>>>>>> +#endif
>>>>>> +
>>>>>>    #ifdef CONFIG_DRM_EXYNOS_IPP
>>>>>>    	ret = platform_driver_register(&ipp_driver);
>>>>>>    	if (ret < 0)
>>>>>> @@ -406,6 +412,11 @@ out_drm:
>>>>>>    out_ipp:
>>>>>>    #endif
>>>>>>
>>>>>> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>>>>> +	platform_driver_unregister(&rotator_driver);
>>>>>> +out_rotator:
>>>>>> +#endif
>>>>>> +
>>>>>>    #ifdef CONFIG_DRM_EXYNOS_FIMC
>>>>>>    	platform_driver_unregister(&fimc_driver);
>>>>>>    out_fimc:
>>>>>> @@ -451,6 +462,10 @@ static void __exit exynos_drm_exit(void)
>>>>>>    	platform_driver_unregister(&ipp_driver);
>>>>>>    #endif
>>>>>>
>>>>>> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>>>>> +	platform_driver_unregister(&rotator_driver);
>>>>>> +#endif
>>>>>> +
>>>>>>    #ifdef CONFIG_DRM_EXYNOS_FIMC
>>>>>>    	platform_driver_unregister(&fimc_driver);
>>>>>>    #endif
>>>>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>>>>> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>>>>> index 14f9490..a74e37c 100644
>>>>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>>>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>>>>> @@ -353,5 +353,6 @@ extern struct platform_driver
>>>>>> exynos_drm_common_hdmi_driver;
>>>>>>    extern struct platform_driver vidi_driver;
>>>>>>    extern struct platform_driver g2d_driver;
>>>>>>    extern struct platform_driver fimc_driver;
>>>>>> +extern struct platform_driver rotator_driver;
>>>>>>    extern struct platform_driver ipp_driver;
>>>>>>    #endif
>>>>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
>>>>>> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
>>>>>> new file mode 100644
>>>>>> index 0000000..121569c
>>>>>> --- /dev/null
>>>>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
>>>>>> @@ -0,0 +1,829 @@
>>>>>> +/*
>>>>>> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
>>>>>> + * Authors:
>>>>>> + *	YoungJun Cho <yj44.cho@samsung.com>
>>>>>> + *	Eunchul Kim <chulspro.kim@samsung.com>
>>>>>> + *
>>>>>> + * This program is free software; you can redistribute it and/or
>>>> modify
>>>>>> + * it under the terms of the GNU General Public License version 2
>> as
>>>>>> + * published by the Free Software Foundationr
>>>>>> + */
>>>>>> +
>>>>>> +#include <linux/kernel.h>
>>>>>> +#include <linux/module.h>
>>>>>> +#include <linux/err.h>
>>>>>> +#include <linux/interrupt.h>
>>>>>> +#include <linux/io.h>
>>>>>> +#include <linux/platform_device.h>
>>>>>> +#include <linux/clk.h>
>>>>>> +#include <linux/pm_runtime.h>
>>>>>> +
>>>>>> +#include <drm/drmP.h>
>>>>>> +#include <drm/exynos_drm.h>
>>>>>> +#include "regs-rotator.h"
>>>>>> +#include "exynos_drm.h"
>>>>>> +#include "exynos_drm_ipp.h"
>>>>>> +
>>>>>> +/*
>>>>>> + * Rotator supports image crop/rotator and input/output DMA
>>> operations.
>>>>>> + * input DMA reads image data from the memory.
>>>>>> + * output DMA writes image data to memory.
>>>>>> + */
>>>>>> +
>>>>>> +#define get_rot_context(dev)
>>>>>> 	platform_get_drvdata(to_platform_device(dev))
>>>>>> +#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
>>>>>> +					struct rot_context, ippdrv);
>>>>>> +#define rot_read(offset)		readl(rot->regs + (offset))
>>>>>> +#define rot_write(cfg, offset)	writel(cfg, rot->regs +
> (offset))
>>>>>> +
>>>>>> +enum rot_irq_status {
>>>>>> +	ROT_IRQ_STATUS_COMPLETE	= 8,
>>>>>> +	ROT_IRQ_STATUS_ILLEGAL	= 9,
>>>>>> +};
>>>>>> +
>>>>>> +/*
>>>>>> + * A structure of limitation.
>>>>>> + *
>>>>>> + * @min_w: minimum width.
>>>>>> + * @min_h: minimum height.
>>>>>> + * @max_w: maximum width.
>>>>>> + * @max_h: maximum height.
>>>>>> + * @align: align size.
>>>>>> + */
>>>>>> +struct rot_limit {
>>>>>> +	u32	min_w;
>>>>>> +	u32	min_h;
>>>>>> +	u32	max_w;
>>>>>> +	u32	max_h;
>>>>>> +	u32	align;
>>>>>> +};
>>>>>> +
>>>>>> +/*
>>>>>> + * A structure of limitation table.
>>>>>> + *
>>>>>> + * @ycbcr420_2p: case of YUV.
>>>>>> + * @rgb888: case of RGB.
>>>>>> + */
>>>>>> +struct rot_limit_table {
>>>>>> +	struct rot_limit	ycbcr420_2p;
>>>>>> +	struct rot_limit	rgb888;
>>>>>> +};
>>>>>> +
>>>>>> +/*
>>>>>> + * A structure of rotator context.
>>>>>> + * @ippdrv: prepare initialization using ippdrv.
>>>>>> + * @regs_res: register resources.
>>>>>> + * @regs: memory mapped io registers.
>>>>>> + * @clock: rotator gate clock.
>>>>>> + * @limit_tbl: limitation of rotator.
>>>>>> + * @irq: irq number.
>>>>>> + * @cur_buf_id: current operation buffer id.
>>>>>> + * @suspended: suspended state.
>>>>>> + */
>>>>>> +struct rot_context {
>>>>>> +	struct exynos_drm_ippdrv	ippdrv;
>>>>>> +	struct resource	*regs_res;
>>>>>> +	void __iomem	*regs;
>>>>>> +	struct clk	*clock;
>>>>>> +	struct rot_limit_table	*limit_tbl;
>>>>>> +	int	irq;
>>>>>> +	int	cur_buf_id[EXYNOS_DRM_OPS_MAX];
>>>>>> +	bool	suspended;
>>>>>> +};
>>>>>> +
>>>>>> +static void rotator_reg_set_irq(struct rot_context *rot, bool
>> enable)
>>>>>> +{
>>>>>> +	u32 val = rot_read(ROT_CONFIG);
>>>>>> +
>>>>>> +	if (enable == true)
>>>>>> +		val |= ROT_CONFIG_IRQ;
>>>>>> +	else
>>>>>> +		val &= ~ROT_CONFIG_IRQ;
>>>>>> +
>>>>>> +	rot_write(val, ROT_CONFIG);
>>>>>> +}
>>>>>> +
>>>>>> +static u32 rotator_reg_get_format(struct rot_context *rot)
>>>>>> +{
>>>>>> +	u32 val = rot_read(ROT_CONTROL);
>>>>>> +
>>>>>> +	val &= ROT_CONTROL_FMT_MASK;
>>>>>> +
>>>>>> +	return val;
>>>>>> +}
>>>>>> +
>>>>>> +static enum rot_irq_status rotator_reg_get_irq_status(struct
>>>> rot_context
>>>>>> *rot)
>>>>>> +{
>>>>>> +	u32 val = rot_read(ROT_STATUS);
>>>>>> +
>>>>>> +	val = ROT_STATUS_IRQ(val);
>>>>>> +
>>>>>> +	if (val == ROT_STATUS_IRQ_VAL_COMPLETE)
>>>>>> +		return ROT_IRQ_STATUS_COMPLETE;
>>>>>> +	else
>>>>>
>>>>> Remove else.
>>>>
>>>> - done.
>>>>
>>>>>
>>>>>> +		return ROT_IRQ_STATUS_ILLEGAL;
>>>>>> +}
>>>>>> +
>>>>>> +static irqreturn_t rotator_irq_handler(int irq, void *arg)
>>>>>> +{
>>>>>> +	struct rot_context *rot = arg;
>>>>>> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
>>>>>> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
>>>>>> +	struct drm_exynos_ipp_event_work *event_work =
>> c_node->event_work;
>>>>>> +	enum rot_irq_status irq_status;
>>>>>> +	u32 val;
>>>>>> +
>>>>>> +	/* Get execution result */
>>>>>> +	irq_status = rotator_reg_get_irq_status(rot);
>>>>>> +
>>>>>> +	/* clear status */
>>>>>> +	val = rot_read(ROT_STATUS);
>>>>>> +	val |= ROT_STATUS_IRQ_PENDING((u32)irq_status);
>>>>>> +	rot_write(val, ROT_STATUS);
>>>>>> +
>>>>>> +	if (irq_status == ROT_IRQ_STATUS_COMPLETE) {
>>>>>> +		event_work->ippdrv = ippdrv;
>>>>>> +		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
>>>>>> +			rot->cur_buf_id[EXYNOS_DRM_OPS_DST];
>>>>>> +		queue_work(ippdrv->event_workq,
>>>>>> +			(struct work_struct *)event_work);
>>>>>> +	} else
>>>>>> +		DRM_ERROR("the SFR is set illegally\n");
>>>>>> +
>>>>>> +	return IRQ_HANDLED;
>>>>>> +}
>>>>>> +
>>>>>> +static void rotator_align_size(struct rot_context *rot, u32 fmt,
>> u32
>>>>>> *hsize,
>>>>>> +		u32 *vsize)
>>>>>> +{
>>>>>> +	struct rot_limit_table *limit_tbl = rot->limit_tbl;
>>>>>> +	struct rot_limit *limit;
>>>>>> +	u32 mask, val;
>>>>>> +
>>>>>> +	/* Get size limit */
>>>>>> +	if (fmt == ROT_CONTROL_FMT_RGB888)
>>>>>> +		limit = &limit_tbl->rgb888;
>>>>>> +	else
>>>>>> +		limit = &limit_tbl->ycbcr420_2p;
>>>>>> +
>>>>>> +	/* Get mask for rounding to nearest aligned val */
>>>>>> +	mask = ~((1 << limit->align) - 1);
>>>>>> +
>>>>>> +	/* Set aligned width */
>>>>>> +	val = ROT_ALIGN(*hsize, limit->align, mask);
>>>>>> +	if (val < limit->min_w)
>>>>>> +		*hsize = ROT_MIN(limit->min_w, mask);
>>>>>> +	else if (val > limit->max_w)
>>>>>> +		*hsize = ROT_MAX(limit->max_w, mask);
>>>>>> +	else
>>>>>> +		*hsize = val;
>>>>>> +
>>>>>> +	/* Set aligned height */
>>>>>> +	val = ROT_ALIGN(*vsize, limit->align, mask);
>>>>>> +	if (val < limit->min_h)
>>>>>> +		*vsize = ROT_MIN(limit->min_h, mask);
>>>>>> +	else if (val > limit->max_h)
>>>>>> +		*vsize = ROT_MAX(limit->max_h, mask);
>>>>>> +	else
>>>>>> +		*vsize = val;
>>>>>> +}
>>>>>> +
>>>>>> +static int rotator_src_set_fmt(struct device *dev, u32 fmt)
>>>>>> +{
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +	u32 val;
>>>>>> +
>>>>>> +	val = rot_read(ROT_CONTROL);
>>>>>> +	val &= ~ROT_CONTROL_FMT_MASK;
>>>>>> +
>>>>>> +	switch (fmt) {
>>>>>> +	case DRM_FORMAT_NV12:
>>>>>> +		val |= ROT_CONTROL_FMT_YCBCR420_2P;
>>>>>> +		break;
>>>>>> +	case DRM_FORMAT_XRGB8888:
>>>>>> +		val |= ROT_CONTROL_FMT_RGB888;
>>>>>> +		break;
>>>>>> +	default:
>>>>>> +		DRM_ERROR("invalid image format\n");
>>>>>> +		return -EINVAL;
>>>>>> +	}
>>>>>> +
>>>>>> +	rot_write(val, ROT_CONTROL);
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +static int rotator_src_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;
>>>>>> +	u32 val;
>>>>>> +
>>>>>> +	/* 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 */
>>>>>> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
>>>>>> +	rot_write(val, ROT_SRC_BUF_SIZE);
>>>>>> +
>>>>>> +	/* Set crop image position configuration */
>>>>>> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
>>>>>> +	rot_write(val, ROT_SRC_CROP_POS);
>>>>>> +	val = ROT_SRC_CROP_SIZE_H(pos->h) |
>> ROT_SRC_CROP_SIZE_W(pos->w);
>>>>>> +	rot_write(val, ROT_SRC_CROP_SIZE);
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +static int rotator_src_set_addr(struct device *dev,
>>>>>> +		struct drm_exynos_ipp_buf_info *buf_info,
>>>>>> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
>>>>>> +{
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
>>>>>> +	u32 val, fmt, hsize, vsize;
>>>>>> +	int i;
>>>>>> +
>>>>>> +	/* Set current buf_id */
>>>>>> +	rot->cur_buf_id[EXYNOS_DRM_OPS_SRC] = buf_id;
>>>>>> +
>>>>>> +	switch (buf_type) {
>>>>>> +	case IPP_BUF_ENQUEUE:
>>>>>> +		/* Set address configuration */
>>>>>> +		for_each_ipp_planar(i)
>>>>>> +			addr[i] = buf_info->base[i];
>>>>>
>>>>> Check NULL.
>>>>
>>>> - If not copy this state, we need to memset about addr.
>>>>     no need check null.
>>>>
>>>>>
>>>>>> +
>>>>>> +		/* Get format */
>>>>>> +		fmt = rotator_reg_get_format(rot);
>>>>>> +
>>>>>> +		/* Re-set cb planar for NV12 format */
>>>>>> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
>>>>>> +					(addr[EXYNOS_DRM_PLANAR_CB]
>> ==
>>>>> 0x00)) {
>>>>>
>>>>> What is 0x00?
>>>>
>>>> - It is NULL, I changed !addr instead of addr == 0x00
>>>>
>>>>>
>>>>>> +
>>>>>> +			val = rot_read(ROT_SRC_BUF_SIZE);
>>>>>> +			hsize = ROT_GET_BUF_SIZE_W(val);
>>>>>> +			vsize = ROT_GET_BUF_SIZE_H(val);
>>>>>> +
>>>>>> +			/* Set cb planar */
>>>>>> +			addr[EXYNOS_DRM_PLANAR_CB] =
>>>>>> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize *
>> vsize;
>>>>>> +		}
>>>>>> +
>>>>>> +		for_each_ipp_planar(i)
>>>>>> +			rot_write(addr[i], ROT_SRC_BUF_ADDR(i));
>>>>>> +		break;
>>>>>> +	case IPP_BUF_DEQUEUE:
>>>>>> +		for_each_ipp_planar(i)
>>>>>> +			rot_write(0x0, ROT_SRC_BUF_ADDR(i));
>>>>>> +		break;
>>>>>> +	default:
>>>>>> +		/* Nothing to do */
>>>>>> +		break;
>>>>>> +	}
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +static int rotator_dst_set_transf(struct device *dev,
>>>>>> +		enum drm_exynos_degree degree,
>>>>>> +		enum drm_exynos_flip flip)
>>>>>> +{
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +	u32 val;
>>>>>> +
>>>>>> +	/* Set transform configuration */
>>>>>> +	val = rot_read(ROT_CONTROL);
>>>>>> +	val &= ~ROT_CONTROL_FLIP_MASK;
>>>>>> +
>>>>>> +	switch (flip) {
>>>>>> +	case EXYNOS_DRM_FLIP_VERTICAL:
>>>>>> +		val |= ROT_CONTROL_FLIP_VERTICAL;
>>>>>> +		break;
>>>>>> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
>>>>>> +		val |= ROT_CONTROL_FLIP_HORIZONTAL;
>>>>>> +		break;
>>>>>> +	default:
>>>>>> +		/* Flip None */
>>>>>> +		break;
>>>>>> +	}
>>>>>> +
>>>>>> +	val &= ~ROT_CONTROL_ROT_MASK;
>>>>>> +
>>>>>> +	switch (degree) {
>>>>>> +	case EXYNOS_DRM_DEGREE_90:
>>>>>> +		val |= ROT_CONTROL_ROT_90;
>>>>>> +		break;
>>>>>> +	case EXYNOS_DRM_DEGREE_180:
>>>>>> +		val |= ROT_CONTROL_ROT_180;
>>>>>> +		break;
>>>>>> +	case EXYNOS_DRM_DEGREE_270:
>>>>>> +		val |= ROT_CONTROL_ROT_270;
>>>>>> +		break;
>>>>>> +	default:
>>>>>> +		/* Rotation 0 Degree */
>>>>>> +		break;
>>>>>> +	}
>>>>>> +
>>>>>> +	rot_write(val, ROT_CONTROL);
>>>>>> +
>>>>>> +	/* Check degree for setting buffer size swap */
>>>>>> +	if ((degree == EXYNOS_DRM_DEGREE_90) ||
>>>>>> +		(degree == EXYNOS_DRM_DEGREE_270))
>>>>>> +		return 1;
>>>>>
>>>>> Correct return type. This function should return 0 or negative.
>>>>
>>>> - no ~ this return type is boolean true or false.
>>>>     but we need to error handling so, we use integer as you know
>>>>     we reviewed this routine at our local git from our team(you and
> me).
>>>>
>>>>>
>>>>>> +	else
>>>>>> +		return 0;
>>>>>
>>>>> Ditto.
>>>>
>>>> - ditto.

- modified it.

>>>>
>>>>>
>>>>>> +}
>>>>>> +
>>>>>> +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 val, fmt, hsize, vsize;
>>>>>> +
>>>>>> +	/* Get format */
>>>>>> +	fmt = rotator_reg_get_format(rot);
>>>>>
>>>>> Check if fmt is valid or not.
>>>>
>>>> - added rotator_check_fmt()
>>>>
>>>>>
>>>>>> +
>>>>>> +	/* Align buffer size */
>>>>>> +	hsize = sz->hsize;
>>>>>> +	vsize = sz->vsize;
>>>>>> +	rotator_align_size(rot, fmt, &hsize, &vsize);
>>>>>> +
>>>>>> +	/* Set buffer size configuration */
>>>>>> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
>>>>>> +	rot_write(val, ROT_DST_BUF_SIZE);
>>>>>> +
>>>>>> +	/* Set crop image position configuration */
>>>>>> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
>>>>>> +	rot_write(val, ROT_DST_CROP_POS);
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +static int rotator_dst_set_addr(struct device *dev,
>>>>>> +		struct drm_exynos_ipp_buf_info *buf_info,
>>>>>> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
>>>>>> +{
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
>>>>>> +	u32 val, fmt, hsize, vsize;
>>>>>> +	int i;
>>>>>> +
>>>>>> +	/* Set current buf_id */
>>>>>> +	rot->cur_buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
>>>>>> +
>>>>>> +	switch (buf_type) {
>>>>>> +	case IPP_BUF_ENQUEUE:
>>>>>> +		/* Set address configuration */
>>>>>> +		for_each_ipp_planar(i)
>>>>>> +			addr[i] = buf_info->base[i];
>>>>>> +
>>>>>> +		/* Get format */
>>>>>> +		fmt = rotator_reg_get_format(rot);
>>>>>
>>>>> Check if fmt is valid or not.
>>>>
>>>> - done.
>>>>
>>>>>
>>>>>> +
>>>>>> +		/* Re-set cb planar for NV12 format */
>>>>>> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
>>>>>> +					(addr[EXYNOS_DRM_PLANAR_CB]
>> ==
>>>>> 0x00)) {
>>>>>> +			/* Get buf size */
>>>>>> +			val = rot_read(ROT_DST_BUF_SIZE);
>>>>>> +
>>>>>> +			hsize = ROT_GET_BUF_SIZE_W(val);
>>>>>> +			vsize = ROT_GET_BUF_SIZE_H(val);
>>>>>> +
>>>>>> +			/* Set cb planar */
>>>>>> +			addr[EXYNOS_DRM_PLANAR_CB] =
>>>>>> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize *
>> vsize;
>>>>>> +		}
>>>>>> +
>>>>>> +		for_each_ipp_planar(i)
>>>>>> +			rot_write(addr[i], ROT_DST_BUF_ADDR(i));
>>>>>> +		break;
>>>>>> +	case IPP_BUF_DEQUEUE:
>>>>>> +		for_each_ipp_planar(i)
>>>>>> +			rot_write(0x0, ROT_DST_BUF_ADDR(i));
>>>>>> +		break;
>>>>>> +	default:
>>>>>> +		/* Nothing to do */
>>>>>> +		break;
>>>>>> +	}
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +static struct exynos_drm_ipp_ops rot_src_ops = {
>>>>>> +	.set_fmt	=	rotator_src_set_fmt,
>>>>>> +	.set_size	=	rotator_src_set_size,
>>>>>> +	.set_addr	=	rotator_src_set_addr,
>>>>>> +};
>>>>>> +
>>>>>> +static struct exynos_drm_ipp_ops rot_dst_ops = {
>>>>>> +	.set_transf	=	rotator_dst_set_transf,
>>>>>> +	.set_size	=	rotator_dst_set_size,
>>>>>> +	.set_addr	=	rotator_dst_set_addr,
>>>>>> +};
>>>>>> +
>>>>>> +static int rotator_init_prop_list(struct exynos_drm_ippdrv
> *ippdrv)
>>>>>> +{
>>>>>> +	struct drm_exynos_ipp_prop_list *prop_list;
>>>>>> +
>>>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>>>> +
>>>>>> +	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
>>>>>> +	if (!prop_list) {
>>>>>> +		DRM_ERROR("failed to alloc property list.\n");
>>>>>> +		return -ENOMEM;
>>>>>> +	}
>>>>>> +
>>>>>> +	/*ToDo fix support function list*/
>>>>>> +
>>>>>> +	prop_list->version = 1;
>>>>>> +	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
>>>>>> +				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
>>>>>> +	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
>>>>>> +				(1 << EXYNOS_DRM_DEGREE_90) |
>>>>>> +				(1 << EXYNOS_DRM_DEGREE_180) |
>>>>>> +				(1 << EXYNOS_DRM_DEGREE_270);
>>>>>> +	prop_list->csc = 0;
>>>>>> +	prop_list->crop = 0;
>>>>>> +	prop_list->scale = 0;
>>>>>> +
>>>>>> +	ippdrv->prop_list = prop_list;
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +static int rotator_ippdrv_check_property(struct device *dev,
>>>>>> +		struct drm_exynos_ipp_property *property)
>>>>>> +{
>>>>>> +	struct drm_exynos_ipp_config *src_config =
>>>>>> +
>>>>> &property->config[EXYNOS_DRM_OPS_SRC];
>>>>>> +	struct drm_exynos_ipp_config *dst_config =
>>>>>> +
>>>>> &property->config[EXYNOS_DRM_OPS_DST];
>>>>>> +	struct drm_exynos_pos *src_pos = &src_config->pos;
>>>>>> +	struct drm_exynos_pos *dst_pos = &dst_config->pos;
>>>>>> +	struct drm_exynos_sz *src_sz = &src_config->sz;
>>>>>> +	struct drm_exynos_sz *dst_sz = &dst_config->sz;
>>>>>> +	bool swap = false;
>>>>>> +
>>>>>> +	/* Check format configuration */
>>>>>> +	if (src_config->fmt != dst_config->fmt) {
>>>>>> +		DRM_DEBUG_KMS("%s:not support csc feature\n",
>> __func__);
>>>>>> +		return -EINVAL;
>>>>>> +	}
>>>>>> +
>>>>>> +	switch (src_config->fmt) {
>>>>>> +	case DRM_FORMAT_XRGB8888:
>>>>>> +	case DRM_FORMAT_NV12:
>>>>>> +		/* No problem */
>>>>>> +		break;
>>>>>> +	default:
>>>>>> +		DRM_DEBUG_KMS("%s:not support format\n", __func__);
>>>>>> +		return -EINVAL;
>>>>>> +	}
>>>>>
>>>>> Use macro instead of switch-case. this just checks only format type.
>>>>
>>>> - I don't thing so, If we make macro about this.
>>>>     then we got some confusion about this macro at next change.
>>>>     this case switch-case is better.
>>>>     Do you prefer this ? please one more comment.
>>>>
>>>> #define drm_check_fmt(fmt) if (fmt == DRM_FORMAT_XRGB8888 || fmt ==
>>>> DRM_FORMAT_NV12) \
>>>> 					return true;
>>>
>>> #define drm_check_fmt(fmt)		((fmt & (DRM_FORMAT_XRGB8888 |
>>> DRM_FORMAT_NV12)) ? true : false)
>>>
>>> if (drm_check_fmt(src_config->fmt))
>>> 	Something;
>>> else
>>> 	Something;
>>
>> Again,
>>
>> #define DRM_FORMAT_MASK			(DRM_FORMAT_XRGB888 |
>> DRM_FORMAT_NV12)
>>   #define drm_check_fmt(fmt)		(((fmt & DRM_FORMAT_MASK) &
>> (DRM_FORMAT_XRGB8888 | \
>>
>> DRM_FORMAT_NV12)) ? true : false)
>>
>>   if (drm_check_fmt(src_config->fmt))
>>   	Something;
>>   else
>>   	Something;
>>
>
> Ah, these format types have no bit field base. Just use switch-case and make
> this code  to one function. And then just call that function.

- OK I make one function and used it.

>
>
>>
>>>
>>>>
>>>>>
>>>>>> +
>>>>>> +	/* Check transform configuration */
>>>>>> +	if (src_config->degree != EXYNOS_DRM_DEGREE_0) {
>>>>>> +		DRM_DEBUG_KMS("%s:not support source-side
>> rotation\n",
>>>>>> +
>> __func__);
>>>>>> +		return -EINVAL;
>>>>>> +	}
>>>>>> +
>>>>>> +	switch (dst_config->degree) {
>>>>>> +	case EXYNOS_DRM_DEGREE_90:
>>>>>> +	case EXYNOS_DRM_DEGREE_270:
>>>>>> +		swap = true;
>>>>>> +	case EXYNOS_DRM_DEGREE_0:
>>>>>> +	case EXYNOS_DRM_DEGREE_180:
>>>>>> +		/* No problem */
>>>>>> +		break;
>>>>>> +	default:
>>>>>> +		DRM_DEBUG_KMS("%s:invalid degree\n", __func__);
>>>>>> +		return -EINVAL;
>>>>>> +	}
>>>>>> +
>>>>>> +	if (src_config->flip != EXYNOS_DRM_FLIP_NONE) {
>>>>>> +		DRM_DEBUG_KMS("%s:not support source-side flip\n",
>>>>> __func__);
>>>>>> +		return -EINVAL;
>>>>>> +	}
>>>>>> +
>>>>>> +	switch (dst_config->flip) {
>>>>>> +	case EXYNOS_DRM_FLIP_NONE:
>>>>>> +	case EXYNOS_DRM_FLIP_VERTICAL:
>>>>>> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
>>>>>> +		/* No problem */
>>>>>> +		break;
>>>>>> +	default:
>>>>>> +		DRM_DEBUG_KMS("%s:invalid flip\n", __func__);
>>>>>> +		return -EINVAL;
>>>>>> +	}
>>>>>
>>>>> Use macro instead of switch-case. this just checks only flip type.
>>>>
>>>> - ditto. please one more comment.
>>>>    in my opinion: I prefer enumeration use switch-case.
>>>
>>> What does each case do? Just check? If so, use macro as I mentioned. We
>>> can't accept this codes.

- ditto.

>>>
>>>>
>>>>>
>>>>>> +
>>>>>> +	/* Check size configuration */
>>>>>> +	if ((src_pos->x + src_pos->w > src_sz->hsize) ||
>>>>>> +		(src_pos->y + src_pos->h > src_sz->vsize)) {
>>>>>> +		DRM_DEBUG_KMS("%s:out of source buffer bound\n",
>> __func__);
>>>>>> +		return -EINVAL;
>>>>>> +	}
>>>>>> +
>>>>>> +	if (swap) {
>>>>>> +		if ((dst_pos->x + dst_pos->h > dst_sz->vsize) ||
>>>>>> +			(dst_pos->y + dst_pos->w > dst_sz->hsize)) {
>>>>>> +			DRM_DEBUG_KMS("%s:out of destination buffer
>>>>> bound\n",
>>>>>> +
>> __func__);
>>>>>> +			return -EINVAL;
>>>>>> +		}
>>>>>> +
>>>>>> +		if ((src_pos->w != dst_pos->h) || (src_pos->h !=
>>>>> dst_pos->w))
>>>>>> {
>>>>>> +			DRM_DEBUG_KMS("%s:not support scale
>> feature\n",
>>>>>> +
>> __func__);
>>>>>> +			return -EINVAL;
>>>>>> +		}
>>>>>> +	} else {
>>>>>> +		if ((dst_pos->x + dst_pos->w > dst_sz->hsize) ||
>>>>>> +			(dst_pos->y + dst_pos->h > dst_sz->vsize)) {
>>>>>> +			DRM_DEBUG_KMS("%s:out of destination buffer
>>>>> bound\n",
>>>>>> +
>> __func__);
>>>>>> +			return -EINVAL;
>>>>>> +		}
>>>>>> +
>>>>>> +		if ((src_pos->w != dst_pos->w) || (src_pos->h !=
>>>>> dst_pos->h))
>>>>>> {
>>>>>> +			DRM_DEBUG_KMS("%s:not support scale
>> feature\n",
>>>>>> +
>> __func__);
>>>>>> +			return -EINVAL;
>>>>>> +		}
>>>>>> +	}
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +static int rotator_ippdrv_start(struct device *dev, enum
>>>>>> drm_exynos_ipp_cmd cmd)
>>>>>> +{
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +	u32 val;
>>>>>> +
>>>>>> +	if (rot->suspended) {
>>>>>> +		DRM_ERROR("suspended state\n");
>>>>>> +		return -EPERM;
>>>>>> +	}
>>>>>> +
>>>>>> +	if (cmd != IPP_CMD_M2M) {
>>>>>> +		DRM_ERROR("not support cmd: %d\n", cmd);
>>>>>> +		return -EINVAL;
>>>>>> +	}
>>>>>> +
>>>>>> +	/* Set interrupt enable */
>>>>>> +	rotator_reg_set_irq(rot, true);
>>>>>> +
>>>>>> +	val = rot_read(ROT_CONTROL);
>>>>>> +	val |= ROT_CONTROL_START;
>>>>>> +
>>>>>> +	rot_write(val, ROT_CONTROL);
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +static int __devinit rotator_probe(struct platform_device *pdev)
>>>>>> +{
>>>>>> +	struct device *dev = &pdev->dev;
>>>>>> +	struct rot_context *rot;
>>>>>> +	struct resource *res;
>>>>>> +	struct exynos_drm_ippdrv *ippdrv;
>>>>>> +	int ret;
>>>>>> +
>>>>>> +	rot = kzalloc(sizeof(*rot), GFP_KERNEL);
>>>>>> +	if (!rot) {
>>>>>> +		dev_err(dev, "failed to allocate rot\n");
>>>>>> +		return -ENOMEM;
>>>>>> +	}
>>>>>> +
>>>>>> +	rot->limit_tbl = (struct rot_limit_table *)
>>>>>> +
>> platform_get_device_id(pdev)->driver_data;
>>>>>> +
>>>>>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>>>> +	if (!res) {
>>>>>> +		dev_err(dev, "failed to find registers\n");
>>>>>> +		ret = -ENOENT;
>>>>>> +		goto err_get_resource;
>>>>>> +	}
>>>>>> +
>>>>>> +	rot->regs_res = request_mem_region(res->start,
>> resource_size(res),
>>>>>> +
>>>>> dev_name(dev));
>>>>>> +	if (!rot->regs_res) {
>>>>>> +		dev_err(dev, "failed to claim register region\n");
>>>>>> +		ret = -ENOENT;
>>>>>> +		goto err_get_resource;
>>>>>> +	}
>>>>>> +
>>>>>> +	rot->regs = ioremap(res->start, resource_size(res));
>>>>>> +	if (!rot->regs) {
>>>>>> +		dev_err(dev, "failed to map register\n");
>>>>>> +		ret = -ENXIO;
>>>>>> +		goto err_ioremap;
>>>>>> +	}
>>>>>> +
>>>>>> +	rot->irq = platform_get_irq(pdev, 0);
>>>>>> +	if (rot->irq < 0) {
>>>>>> +		dev_err(dev, "failed to get irq\n");
>>>>>> +		ret = rot->irq;
>>>>>> +		goto err_get_irq;
>>>>>> +	}
>>>>>> +
>>>>>> +	ret = request_threaded_irq(rot->irq, NULL,
>> rotator_irq_handler,
>>>>>> +					IRQF_ONESHOT, "drm_rotator",
>> rot);
>>>>>> +	if (ret < 0) {
>>>>>> +		dev_err(dev, "failed to request irq\n");
>>>>>> +		goto err_get_irq;
>>>>>> +	}
>>>>>> +
>>>>>> +	rot->clock = clk_get(dev, "rotator");
>>>>>> +	if (IS_ERR_OR_NULL(rot->clock)) {
>>>>>> +		dev_err(dev, "failed to get clock\n");
>>>>>> +		ret = PTR_ERR(rot->clock);
>>>>>> +		goto err_clk_get;
>>>>>> +	}
>>>>>> +
>>>>>> +	pm_runtime_enable(dev);
>>>>>> +
>>>>>> +	ippdrv = &rot->ippdrv;
>>>>>> +	ippdrv->dev = dev;
>>>>>> +	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &rot_src_ops;
>>>>>> +	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &rot_dst_ops;
>>>>>> +	ippdrv->check_property = rotator_ippdrv_check_property;
>>>>>> +	ippdrv->start = rotator_ippdrv_start;
>>>>>> +	ret = rotator_init_prop_list(ippdrv);
>>>>>> +	if (ret < 0) {
>>>>>> +		dev_err(dev, "failed to init property list.\n");
>>>>>> +		goto err_ippdrv_register;
>>>>>> +	}
>>>>>> +
>>>>>> +	DRM_DEBUG_KMS("%s:ippdrv[0x%x]\n", __func__, (int)ippdrv);
>>>>>> +
>>>>>> +	platform_set_drvdata(pdev, rot);
>>>>>> +
>>>>>> +	ret = exynos_drm_ippdrv_register(ippdrv);
>>>>>> +	if (ret < 0) {
>>>>>> +		dev_err(dev, "failed to register drm rotator
>> device\n");
>>>>>> +		kfree(ippdrv->prop_list);
>>>>>> +		goto err_ippdrv_register;
>>>>>> +	}
>>>>>> +
>>>>>> +	dev_info(dev, "The exynos rotator is probed
>> successfully\n");
>>>>>> +
>>>>>> +	return 0;
>>>>>> +
>>>>>> +err_ippdrv_register:
>>>>>> +	pm_runtime_disable(dev);
>>>>>> +	clk_put(rot->clock);
>>>>>> +err_clk_get:
>>>>>> +	free_irq(rot->irq, rot);
>>>>>> +err_get_irq:
>>>>>> +	iounmap(rot->regs);
>>>>>> +err_ioremap:
>>>>>> +	release_resource(rot->regs_res);
>>>>>> +	kfree(rot->regs_res);
>>>>>> +err_get_resource:
>>>>>> +	kfree(rot);
>>>>>> +	return ret;
>>>>>> +}
>>>>>> +
>>>>>> +static int __devexit rotator_remove(struct platform_device *pdev)
>>>>>> +{
>>>>>> +	struct device *dev = &pdev->dev;
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
>>>>>> +
>>>>>> +	kfree(ippdrv->prop_list);
>>>>>> +	exynos_drm_ippdrv_unregister(ippdrv);
>>>>>> +
>>>>>> +	pm_runtime_disable(dev);
>>>>>> +	clk_put(rot->clock);
>>>>>> +
>>>>>> +	free_irq(rot->irq, rot);
>>>>>> +
>>>>>> +	iounmap(rot->regs);
>>>>>> +
>>>>>> +	release_resource(rot->regs_res);
>>>>>> +	kfree(rot->regs_res);
>>>>>> +
>>>>>> +	kfree(rot);
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +struct rot_limit_table rot_limit_tbl = {
>>>>>> +	.ycbcr420_2p = {
>>>>>> +		.min_w = 32,
>>>>>> +		.min_h = 32,
>>>>>> +		.max_w = SZ_32K,
>>>>>> +		.max_h = SZ_32K,
>>>>>> +		.align = 3,
>>>>>> +	},
>>>>>> +	.rgb888 = {
>>>>>> +		.min_w = 8,
>>>>>> +		.min_h = 8,
>>>>>> +		.max_w = SZ_8K,
>>>>>> +		.max_h = SZ_8K,
>>>>>> +		.align = 2,
>>>>>> +	},
>>>>>> +};
>>>>>> +
>>>>>> +struct platform_device_id rotator_driver_ids[] = {
>>>>>> +	{
>>>>>> +		.name		= "exynos-rot",
>>>>>> +		.driver_data	= (unsigned long)&rot_limit_tbl,
>>>>>> +	},
>>>>>> +	{},
>>>>>> +};
>>>>>> +
>>>>>> +static int rotator_clk_crtl(struct rot_context *rot, bool enable)
>>>>>> +{
>>>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>>>> +
>>>>>> +	if (enable) {
>>>>>> +		clk_enable(rot->clock);
>>>>>> +		rot->suspended = false;
>>>>>> +	} else {
>>>>>> +		clk_disable(rot->clock);
>>>>>> +		rot->suspended = true;
>>>>>> +	}
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +
>>>>>> +
>>>>>> +#ifdef CONFIG_PM_SLEEP
>>>>>> +static int rotator_suspend(struct device *dev)
>>>>>> +{
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +
>>>>>> +	/* ToDo */
>>>>>> +
>>>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>>>> +
>>>>>> +	if (pm_runtime_suspended(dev))
>>>>>> +		return 0;
>>>>>> +
>>>>>> +	return rotator_clk_crtl(rot, false);
>>>>>> +}
>>>>>> +
>>>>>> +static int rotator_resume(struct device *dev)
>>>>>> +{
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +
>>>>>> +	/* ToDo */
>>>>>> +
>>>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>>>> +
>>>>>> +	if (!pm_runtime_suspended(dev))
>>>>>> +		return rotator_clk_crtl(rot, true);
>>>>>> +
>>>>>> +	return 0;
>>>>>> +}
>>>>>> +#endif
>>>>>> +
>>>>>> +#ifdef CONFIG_PM_RUNTIME
>>>>>> +static int rotator_runtime_suspend(struct device *dev)
>>>>>> +{
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +
>>>>>> +	/* ToDo */
>>>>>> +
>>>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>>>> +
>>>>>> +	return  rotator_clk_crtl(rot, false);
>>>>>> +}
>>>>>> +
>>>>>> +static int rotator_runtime_resume(struct device *dev)
>>>>>> +{
>>>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>>>> +
>>>>>> +	/* ToDo */
>>>>>> +
>>>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>>>> +
>>>>>> +	return  rotator_clk_crtl(rot, true);
>>>>>> +}
>>>>>> +#endif
>>>>>> +
>>>>>> +static const struct dev_pm_ops rotator_pm_ops = {
>>>>>> +	SET_SYSTEM_SLEEP_PM_OPS(rotator_suspend, rotator_resume)
>>>>>> +	SET_RUNTIME_PM_OPS(rotator_runtime_suspend,
>> rotator_runtime_resume,
>>>>>> +
>>>>> NULL)
>>>>>> +};
>>>>>> +
>>>>>> +struct platform_driver rotator_driver = {
>>>>>> +	.probe		= rotator_probe,
>>>>>> +	.remove		= __devexit_p(rotator_remove),
>>>>>> +	.id_table	= rotator_driver_ids,
>>>>>> +	.driver		= {
>>>>>> +		.name	= "exynos-rot",
>>>>>> +		.owner	= THIS_MODULE,
>>>>>> +		.pm	= &rotator_pm_ops,
>>>>>> +	},
>>>>>> +};
>>>>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h
>>>>>> b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
>>>>>> new file mode 100644
>>>>>> index 0000000..fe929c9
>>>>>> --- /dev/null
>>>>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
>>>>>> @@ -0,0 +1,13 @@
>>>>>> +/*
>>>>>> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
>>>>>> + * Authors: YoungJun Cho <yj44.cho@samsung.com>
>>>>>> + *
>>>>>> + * This program is free software; you can redistribute it and/or
>>>> modify
>>>>>> + * it under the terms of the GNU General Public License version 2
>> as
>>>>>> + * published by the Free Software Foundationr
>>>>>> + */
>>>>>> +
>>>>>> +#ifndef	_EXYNOS_DRM_ROTATOR_H_
>>>>>> +#define	_EXYNOS_DRM_ROTATOR_H_
>>>>>> +
>>>>>> +#endif
>>>>>> diff --git a/drivers/gpu/drm/exynos/regs-rotator.h
>>>>>> b/drivers/gpu/drm/exynos/regs-rotator.h
>>>>>> new file mode 100644
>>>>>> index 0000000..a09ac6e
>>>>>> --- /dev/null
>>>>>> +++ b/drivers/gpu/drm/exynos/regs-rotator.h
>>>>>> @@ -0,0 +1,73 @@
>>>>>> +/* drivers/gpu/drm/exynos/regs-rotator.h
>>>>>> + *
>>>>>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>>>>>> + *		http://www.samsung.com/
>>>>>> + *
>>>>>> + * Register definition file for Samsung Rotator Interface
> (Rotator)
>>>>>> driver
>>>>>> + *
>>>>>> + * This program is free software; you can redistribute it and/or
>>>> modify
>>>>>> + * it under the terms of the GNU General Public License version 2
>> as
>>>>>> + * published by the Free Software Foundation.
>>>>>> +*/
>>>>>> +
>>>>>> +#ifndef EXYNOS_REGS_ROTATOR_H
>>>>>> +#define EXYNOS_REGS_ROTATOR_H
>>>>>> +
>>>>>> +/* Configuration */
>>>>>> +#define ROT_CONFIG			0x00
>>>>>> +#define ROT_CONFIG_IRQ			(3 << 8)
>>>>>> +
>>>>>> +/* Image Control */
>>>>>> +#define ROT_CONTROL			0x10
>>>>>> +#define ROT_CONTROL_PATTERN_WRITE	(1 << 16)
>>>>>> +#define ROT_CONTROL_FMT_YCBCR420_2P	(1 << 8)
>>>>>> +#define ROT_CONTROL_FMT_RGB888		(6 << 8)
>>>>>> +#define ROT_CONTROL_FMT_MASK		(7 << 8)
>>>>>> +#define ROT_CONTROL_FLIP_VERTICAL	(2 << 6)
>>>>>> +#define ROT_CONTROL_FLIP_HORIZONTAL	(3 << 6)
>>>>>> +#define ROT_CONTROL_FLIP_MASK		(3 << 6)
>>>>>> +#define ROT_CONTROL_ROT_90		(1 << 4)
>>>>>> +#define ROT_CONTROL_ROT_180		(2 << 4)
>>>>>> +#define ROT_CONTROL_ROT_270		(3 << 4)
>>>>>> +#define ROT_CONTROL_ROT_MASK		(3 << 4)
>>>>>> +#define ROT_CONTROL_START		(1 << 0)
>>>>>> +
>>>>>> +/* Status */
>>>>>> +#define ROT_STATUS			0x20
>>>>>> +#define ROT_STATUS_IRQ_PENDING(x)	(1 << (x))
>>>>>> +#define ROT_STATUS_IRQ(x)		(((x) >> 8) & 0x3)
>>>>>> +#define ROT_STATUS_IRQ_VAL_COMPLETE	1
>>>>>> +#define ROT_STATUS_IRQ_VAL_ILLEGAL	2
>>>>>> +
>>>>>> +/* Buffer Address */
>>>>>> +#define ROT_SRC_BUF_ADDR(n)		(0x30 + ((n) << 2))
>>>>>> +#define ROT_DST_BUF_ADDR(n)		(0x50 + ((n) << 2))
>>>>>> +
>>>>>> +/* Buffer Size */
>>>>>> +#define ROT_SRC_BUF_SIZE		0x3c
>>>>>> +#define ROT_DST_BUF_SIZE		0x5c
>>>>>> +#define ROT_SET_BUF_SIZE_H(x)		((x) << 16)
>>>>>> +#define ROT_SET_BUF_SIZE_W(x)		((x) << 0)
>>>>>> +#define ROT_GET_BUF_SIZE_H(x)		((x) >> 16)
>>>>>> +#define ROT_GET_BUF_SIZE_W(x)		((x) & 0xffff)
>>>>>> +
>>>>>> +/* Crop Position */
>>>>>> +#define ROT_SRC_CROP_POS		0x40
>>>>>> +#define ROT_DST_CROP_POS		0x60
>>>>>> +#define ROT_CROP_POS_Y(x)		((x) << 16)
>>>>>> +#define ROT_CROP_POS_X(x)		((x) << 0)
>>>>>> +
>>>>>> +/* Source Crop Size */
>>>>>> +#define ROT_SRC_CROP_SIZE		0x44
>>>>>> +#define ROT_SRC_CROP_SIZE_H(x)		((x) << 16)
>>>>>> +#define ROT_SRC_CROP_SIZE_W(x)		((x) << 0)
>>>>>> +
>>>>>> +/* Round to nearest aligned value */
>>>>>> +#define ROT_ALIGN(x, align, mask)	(((x) + (1 << ((align) -
>> 1))) &
>>>>>> (mask))
>>>>>> +/* Minimum limit value */
>>>>>> +#define ROT_MIN(min, mask)		(((min) + ~(mask)) & (mask))
>>>>>> +/* Maximum limit value */
>>>>>> +#define ROT_MAX(max, mask)		((max) & (mask))
>>>>>> +
>>>>>> +#endif /* EXYNOS_REGS_ROTATOR_H */
>>>>>> +
>>>>>> --
>>>>>> 1.7.0.4
>>>>>
>>>>>
>>>
>>> _______________________________________________
>>> dri-devel mailing list
>>> dri-devel@lists.freedesktop.org
>>> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC v3 4/5] drm/exynos: add rotator ipp driver
  2012-12-12  9:46       ` Inki Dae
@ 2012-12-12 11:10         ` Eunchul Kim
  0 siblings, 0 replies; 18+ messages in thread
From: Eunchul Kim @ 2012-12-12 11:10 UTC (permalink / raw)
  To: Inki Dae
  Cc: jy0.jeon, sw0312.kim, jaejoon.seo, kyungmin.park, dri-devel, jmock.shin


Thank's for your comment.

BR
Eunchul Kim.

On 12/12/2012 06:46 PM, Inki Dae wrote:
>
> One more comment.
>
>
>> -----Original Message-----
>> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
>> Sent: Wednesday, December 12, 2012 6:26 PM
>> To: Inki Dae
>> Cc: dri-devel@lists.freedesktop.org; jy0.jeon@samsung.com;
>> yj44.cho@samsung.com; jmock.shin@samsung.com; jaejoon.seo@samsung.com;
>> kyungmin.park@samsung.com; sw0312.kim@samsung.com; Joonyoung Shim
>> Subject: Re: [RFC v3 4/5] drm/exynos: add rotator ipp driver
>>
>> Thank's your comment.
>>
>> I answer your comment. please check that.
>>
>> Thank's
>>
>> BR
>> Eunchul Kim
>>
>> On 12/12/2012 05:29 PM, Inki Dae wrote:
>>>
>>>
>>>> -----Original Message-----
>>>> From: Eunchul Kim [mailto:chulspro.kim@samsung.com]
>>>> Sent: Wednesday, December 12, 2012 4:35 PM
>>>> To: dri-devel@lists.freedesktop.org; inki.dae@samsung.com
>>>> Cc: jy0.jeon@samsung.com; yj44.cho@samsung.com; jmock.shin@samsung.com;
>>>> jaejoon.seo@samsung.com; kyungmin.park@samsung.com;
>>>> chulspro.kim@samsung.com
>>>> Subject: [RFC v3 4/5] drm/exynos: add rotator ipp driver
>>>>
>>>> Rotator supports rotation/crop/flip and input/output DMA operations
>>>> Rotator ipp driver supports 90,180,270 degree rotaion and vertical,
>>>> horizontal flip.
>>>> and has some limitations(source and destination format have to be same,
>> no
>>>> scaler)
>>>>
>>>> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
>>>> Signed-off-by: Youngjun Cho <yj44.cho@samsung.com>
>>>> ---
>>>>    drivers/gpu/drm/exynos/Kconfig              |    7 +
>>>>    drivers/gpu/drm/exynos/Makefile             |    1 +
>>>>    drivers/gpu/drm/exynos/exynos_drm_drv.c     |   15 +
>>>>    drivers/gpu/drm/exynos/exynos_drm_drv.h     |    1 +
>>>>    drivers/gpu/drm/exynos/exynos_drm_rotator.c |  829
>>>> +++++++++++++++++++++++++++
>>>>    drivers/gpu/drm/exynos/exynos_drm_rotator.h |   13 +
>>>>    drivers/gpu/drm/exynos/regs-rotator.h       |   73 +++
>>>>    7 files changed, 939 insertions(+), 0 deletions(-)
>>>>    create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c
>>>>    create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h
>>>>    create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
>>>>
>>>> diff --git a/drivers/gpu/drm/exynos/Kconfig
>>>> b/drivers/gpu/drm/exynos/Kconfig
>>>> index 4915ab6..4860835 100644
>>>> --- a/drivers/gpu/drm/exynos/Kconfig
>>>> +++ b/drivers/gpu/drm/exynos/Kconfig
>>>> @@ -57,3 +57,10 @@ config DRM_EXYNOS_FIMC
>>>>    	depends on DRM_EXYNOS_IPP
>>>>    	help
>>>>    	  Choose this option if you want to use Exynos FIMC for DRM.
>>>> +
>>>> +config DRM_EXYNOS_ROTATOR
>>>> +	bool "Exynos DRM Rotator"
>>>> +	depends on DRM_EXYNOS_IPP
>>>> +	help
>>>> +	  Choose this option if you want to use Exynos Rotator for DRM.
>>>> +
>>>> diff --git a/drivers/gpu/drm/exynos/Makefile
>>>> b/drivers/gpu/drm/exynos/Makefile
>>>> index 9710024..3b70668 100644
>>>> --- a/drivers/gpu/drm/exynos/Makefile
>>>> +++ b/drivers/gpu/drm/exynos/Makefile
>>>> @@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI)	+=
>>>> exynos_drm_vidi.o
>>>>    exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
>>>>    exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
>>>>    exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
>>>> +exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
>>>>
>>>>    obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
>>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>> index 73f02ac..09d884b 100644
>>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>>>> @@ -378,6 +378,12 @@ static int __init exynos_drm_init(void)
>>>>    		goto out_fimc;
>>>>    #endif
>>>>
>>>> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>>> +	ret = platform_driver_register(&rotator_driver);
>>>> +	if (ret < 0)
>>>> +		goto out_rotator;
>>>> +#endif
>>>> +
>>>>    #ifdef CONFIG_DRM_EXYNOS_IPP
>>>>    	ret = platform_driver_register(&ipp_driver);
>>>>    	if (ret < 0)
>>>> @@ -406,6 +412,11 @@ out_drm:
>>>>    out_ipp:
>>>>    #endif
>>>>
>>>> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>>> +	platform_driver_unregister(&rotator_driver);
>>>> +out_rotator:
>>>> +#endif
>>>> +
>>>>    #ifdef CONFIG_DRM_EXYNOS_FIMC
>>>>    	platform_driver_unregister(&fimc_driver);
>>>>    out_fimc:
>>>> @@ -451,6 +462,10 @@ static void __exit exynos_drm_exit(void)
>>>>    	platform_driver_unregister(&ipp_driver);
>>>>    #endif
>>>>
>>>> +#ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>>> +	platform_driver_unregister(&rotator_driver);
>>>> +#endif
>>>> +
>>>>    #ifdef CONFIG_DRM_EXYNOS_FIMC
>>>>    	platform_driver_unregister(&fimc_driver);
>>>>    #endif
>>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>>> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>>> index 14f9490..a74e37c 100644
>>>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>>>> @@ -353,5 +353,6 @@ extern struct platform_driver
>>>> exynos_drm_common_hdmi_driver;
>>>>    extern struct platform_driver vidi_driver;
>>>>    extern struct platform_driver g2d_driver;
>>>>    extern struct platform_driver fimc_driver;
>>>> +extern struct platform_driver rotator_driver;
>>>>    extern struct platform_driver ipp_driver;
>>>>    #endif
>>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.c
>>>> b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
>>>> new file mode 100644
>>>> index 0000000..121569c
>>>> --- /dev/null
>>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.c
>>>> @@ -0,0 +1,829 @@
>>>> +/*
>>>> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
>>>> + * Authors:
>>>> + *	YoungJun Cho <yj44.cho@samsung.com>
>>>> + *	Eunchul Kim <chulspro.kim@samsung.com>
>>>> + *
>>>> + * This program is free software; you can redistribute it and/or
>> modify
>>>> + * it under the terms of the GNU General Public License version 2 as
>>>> + * published by the Free Software Foundationr
>>>> + */
>>>> +
>>>> +#include <linux/kernel.h>
>>>> +#include <linux/module.h>
>>>> +#include <linux/err.h>
>>>> +#include <linux/interrupt.h>
>>>> +#include <linux/io.h>
>>>> +#include <linux/platform_device.h>
>>>> +#include <linux/clk.h>
>>>> +#include <linux/pm_runtime.h>
>>>> +
>>>> +#include <drm/drmP.h>
>>>> +#include <drm/exynos_drm.h>
>>>> +#include "regs-rotator.h"
>>>> +#include "exynos_drm.h"
>>>> +#include "exynos_drm_ipp.h"
>>>> +
>>>> +/*
>>>> + * Rotator supports image crop/rotator and input/output DMA
> operations.
>>>> + * input DMA reads image data from the memory.
>>>> + * output DMA writes image data to memory.
>>>> + */
>>>> +
>>>> +#define get_rot_context(dev)
>>>> 	platform_get_drvdata(to_platform_device(dev))
>>>> +#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
>>>> +					struct rot_context, ippdrv);
>>>> +#define rot_read(offset)		readl(rot->regs + (offset))
>>>> +#define rot_write(cfg, offset)	writel(cfg, rot->regs + (offset))
>>>> +
>>>> +enum rot_irq_status {
>>>> +	ROT_IRQ_STATUS_COMPLETE	= 8,
>>>> +	ROT_IRQ_STATUS_ILLEGAL	= 9,
>>>> +};
>>>> +
>>>> +/*
>>>> + * A structure of limitation.
>>>> + *
>>>> + * @min_w: minimum width.
>>>> + * @min_h: minimum height.
>>>> + * @max_w: maximum width.
>>>> + * @max_h: maximum height.
>>>> + * @align: align size.
>>>> + */
>>>> +struct rot_limit {
>>>> +	u32	min_w;
>>>> +	u32	min_h;
>>>> +	u32	max_w;
>>>> +	u32	max_h;
>>>> +	u32	align;
>>>> +};
>>>> +
>>>> +/*
>>>> + * A structure of limitation table.
>>>> + *
>>>> + * @ycbcr420_2p: case of YUV.
>>>> + * @rgb888: case of RGB.
>>>> + */
>>>> +struct rot_limit_table {
>>>> +	struct rot_limit	ycbcr420_2p;
>>>> +	struct rot_limit	rgb888;
>>>> +};
>>>> +
>>>> +/*
>>>> + * A structure of rotator context.
>>>> + * @ippdrv: prepare initialization using ippdrv.
>>>> + * @regs_res: register resources.
>>>> + * @regs: memory mapped io registers.
>>>> + * @clock: rotator gate clock.
>>>> + * @limit_tbl: limitation of rotator.
>>>> + * @irq: irq number.
>>>> + * @cur_buf_id: current operation buffer id.
>>>> + * @suspended: suspended state.
>>>> + */
>>>> +struct rot_context {
>>>> +	struct exynos_drm_ippdrv	ippdrv;
>>>> +	struct resource	*regs_res;
>>>> +	void __iomem	*regs;
>>>> +	struct clk	*clock;
>>>> +	struct rot_limit_table	*limit_tbl;
>>>> +	int	irq;
>>>> +	int	cur_buf_id[EXYNOS_DRM_OPS_MAX];
>>>> +	bool	suspended;
>>>> +};
>>>> +
>>>> +static void rotator_reg_set_irq(struct rot_context *rot, bool enable)
>>>> +{
>>>> +	u32 val = rot_read(ROT_CONFIG);
>>>> +
>>>> +	if (enable == true)
>>>> +		val |= ROT_CONFIG_IRQ;
>>>> +	else
>>>> +		val &= ~ROT_CONFIG_IRQ;
>>>> +
>>>> +	rot_write(val, ROT_CONFIG);
>>>> +}
>>>> +
>>>> +static u32 rotator_reg_get_format(struct rot_context *rot)
>>>> +{
>>>> +	u32 val = rot_read(ROT_CONTROL);
>>>> +
>>>> +	val &= ROT_CONTROL_FMT_MASK;
>>>> +
>>>> +	return val;
>>>> +}
>>>> +
>>>> +static enum rot_irq_status rotator_reg_get_irq_status(struct
>> rot_context
>>>> *rot)
>>>> +{
>>>> +	u32 val = rot_read(ROT_STATUS);
>>>> +
>>>> +	val = ROT_STATUS_IRQ(val);
>>>> +
>>>> +	if (val == ROT_STATUS_IRQ_VAL_COMPLETE)
>>>> +		return ROT_IRQ_STATUS_COMPLETE;
>>>> +	else
>>>
>>> Remove else.
>>
>> - done.
>>
>>>
>>>> +		return ROT_IRQ_STATUS_ILLEGAL;
>>>> +}
>>>> +
>>>> +static irqreturn_t rotator_irq_handler(int irq, void *arg)
>>>> +{
>>>> +	struct rot_context *rot = arg;
>>>> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
>>>> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
>>>> +	struct drm_exynos_ipp_event_work *event_work = c_node->event_work;
>>>> +	enum rot_irq_status irq_status;
>>>> +	u32 val;
>>>> +
>>>> +	/* Get execution result */
>>>> +	irq_status = rotator_reg_get_irq_status(rot);
>>>> +
>>>> +	/* clear status */
>>>> +	val = rot_read(ROT_STATUS);
>>>> +	val |= ROT_STATUS_IRQ_PENDING((u32)irq_status);
>>>> +	rot_write(val, ROT_STATUS);
>>>> +
>>>> +	if (irq_status == ROT_IRQ_STATUS_COMPLETE) {
>>>> +		event_work->ippdrv = ippdrv;
>>>> +		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
>>>> +			rot->cur_buf_id[EXYNOS_DRM_OPS_DST];
>>>> +		queue_work(ippdrv->event_workq,
>>>> +			(struct work_struct *)event_work);
>>>> +	} else
>>>> +		DRM_ERROR("the SFR is set illegally\n");
>>>> +
>>>> +	return IRQ_HANDLED;
>>>> +}
>>>> +
>>>> +static void rotator_align_size(struct rot_context *rot, u32 fmt, u32
>>>> *hsize,
>>>> +		u32 *vsize)
>>>> +{
>>>> +	struct rot_limit_table *limit_tbl = rot->limit_tbl;
>>>> +	struct rot_limit *limit;
>>>> +	u32 mask, val;
>>>> +
>>>> +	/* Get size limit */
>>>> +	if (fmt == ROT_CONTROL_FMT_RGB888)
>>>> +		limit = &limit_tbl->rgb888;
>>>> +	else
>>>> +		limit = &limit_tbl->ycbcr420_2p;
>>>> +
>>>> +	/* Get mask for rounding to nearest aligned val */
>>>> +	mask = ~((1 << limit->align) - 1);
>>>> +
>>>> +	/* Set aligned width */
>>>> +	val = ROT_ALIGN(*hsize, limit->align, mask);
>>>> +	if (val < limit->min_w)
>>>> +		*hsize = ROT_MIN(limit->min_w, mask);
>>>> +	else if (val > limit->max_w)
>>>> +		*hsize = ROT_MAX(limit->max_w, mask);
>>>> +	else
>>>> +		*hsize = val;
>>>> +
>>>> +	/* Set aligned height */
>>>> +	val = ROT_ALIGN(*vsize, limit->align, mask);
>>>> +	if (val < limit->min_h)
>>>> +		*vsize = ROT_MIN(limit->min_h, mask);
>>>> +	else if (val > limit->max_h)
>>>> +		*vsize = ROT_MAX(limit->max_h, mask);
>>>> +	else
>>>> +		*vsize = val;
>>>> +}
>>>> +
>>>> +static int rotator_src_set_fmt(struct device *dev, u32 fmt)
>>>> +{
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +	u32 val;
>>>> +
>>>> +	val = rot_read(ROT_CONTROL);
>>>> +	val &= ~ROT_CONTROL_FMT_MASK;
>>>> +
>>>> +	switch (fmt) {
>>>> +	case DRM_FORMAT_NV12:
>>>> +		val |= ROT_CONTROL_FMT_YCBCR420_2P;
>>>> +		break;
>>>> +	case DRM_FORMAT_XRGB8888:
>>>> +		val |= ROT_CONTROL_FMT_RGB888;
>>>> +		break;
>>>> +	default:
>>>> +		DRM_ERROR("invalid image format\n");
>>>> +		return -EINVAL;
>>>> +	}
>>>> +
>>>> +	rot_write(val, ROT_CONTROL);
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +static int rotator_src_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;
>>>> +	u32 val;
>>>> +
>>>> +	/* 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 */
>>>> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
>>>> +	rot_write(val, ROT_SRC_BUF_SIZE);
>>>> +
>>>> +	/* Set crop image position configuration */
>>>> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
>>>> +	rot_write(val, ROT_SRC_CROP_POS);
>>>> +	val = ROT_SRC_CROP_SIZE_H(pos->h) | ROT_SRC_CROP_SIZE_W(pos->w);
>>>> +	rot_write(val, ROT_SRC_CROP_SIZE);
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +static int rotator_src_set_addr(struct device *dev,
>>>> +		struct drm_exynos_ipp_buf_info *buf_info,
>>>> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
>>>> +{
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
>>>> +	u32 val, fmt, hsize, vsize;
>>>> +	int i;
>>>> +
>>>> +	/* Set current buf_id */
>>>> +	rot->cur_buf_id[EXYNOS_DRM_OPS_SRC] = buf_id;
>>>> +
>>>> +	switch (buf_type) {
>>>> +	case IPP_BUF_ENQUEUE:
>>>> +		/* Set address configuration */
>>>> +		for_each_ipp_planar(i)
>>>> +			addr[i] = buf_info->base[i];
>>>
>>> Check NULL.
>>
>> - If not copy this state, we need to memset about addr.
>>     no need check null.
>>
>>>
>>>> +
>>>> +		/* Get format */
>>>> +		fmt = rotator_reg_get_format(rot);
>>>> +
>>>> +		/* Re-set cb planar for NV12 format */
>>>> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
>>>> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
>>> 0x00)) {
>>>
>>> What is 0x00?
>>
>> - It is NULL, I changed !addr instead of addr == 0x00
>>
>>>
>>>> +
>>>> +			val = rot_read(ROT_SRC_BUF_SIZE);
>>>> +			hsize = ROT_GET_BUF_SIZE_W(val);
>>>> +			vsize = ROT_GET_BUF_SIZE_H(val);
>>>> +
>>>> +			/* Set cb planar */
>>>> +			addr[EXYNOS_DRM_PLANAR_CB] =
>>>> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
>>>> +		}
>>>> +
>>>> +		for_each_ipp_planar(i)
>>>> +			rot_write(addr[i], ROT_SRC_BUF_ADDR(i));
>>>> +		break;
>>>> +	case IPP_BUF_DEQUEUE:
>>>> +		for_each_ipp_planar(i)
>>>> +			rot_write(0x0, ROT_SRC_BUF_ADDR(i));
>>>> +		break;
>>>> +	default:
>>>> +		/* Nothing to do */
>>>> +		break;
>>>> +	}
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +static int rotator_dst_set_transf(struct device *dev,
>>>> +		enum drm_exynos_degree degree,
>>>> +		enum drm_exynos_flip flip)
>>>> +{
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +	u32 val;
>>>> +
>>>> +	/* Set transform configuration */
>>>> +	val = rot_read(ROT_CONTROL);
>>>> +	val &= ~ROT_CONTROL_FLIP_MASK;
>>>> +
>>>> +	switch (flip) {
>>>> +	case EXYNOS_DRM_FLIP_VERTICAL:
>>>> +		val |= ROT_CONTROL_FLIP_VERTICAL;
>>>> +		break;
>>>> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
>>>> +		val |= ROT_CONTROL_FLIP_HORIZONTAL;
>>>> +		break;
>>>> +	default:
>>>> +		/* Flip None */
>>>> +		break;
>>>> +	}
>>>> +
>>>> +	val &= ~ROT_CONTROL_ROT_MASK;
>>>> +
>>>> +	switch (degree) {
>>>> +	case EXYNOS_DRM_DEGREE_90:
>>>> +		val |= ROT_CONTROL_ROT_90;
>>>> +		break;
>>>> +	case EXYNOS_DRM_DEGREE_180:
>>>> +		val |= ROT_CONTROL_ROT_180;
>>>> +		break;
>>>> +	case EXYNOS_DRM_DEGREE_270:
>>>> +		val |= ROT_CONTROL_ROT_270;
>>>> +		break;
>>>> +	default:
>>>> +		/* Rotation 0 Degree */
>>>> +		break;
>>>> +	}
>>>> +
>>>> +	rot_write(val, ROT_CONTROL);
>>>> +
>>>> +	/* Check degree for setting buffer size swap */
>>>> +	if ((degree == EXYNOS_DRM_DEGREE_90) ||
>>>> +		(degree == EXYNOS_DRM_DEGREE_270))
>>>> +		return 1;
>>>
>>> Correct return type. This function should return 0 or negative.
>>
>> - no ~ this return type is boolean true or false.
>>     but we need to error handling so, we use integer as you know
>>     we reviewed this routine at our local git from our team(you and me).
>>
>
> Ok, then what do the below codes mean?
>
> 	/* set transform for rotation, flip */
> 	if (ops->set_transf) {
> 		swap = ops->set_transf(ippdrv->dev, config->degree,
> 			config->flip);
> 		if (swap < 0) {
> 			DRM_ERROR("not support tranf.\n");
> 			return -EINVAL;
> 		}
>
> If return value should be true or false then make sure error checking.

- modified it. using pointer.

>
>>>
>>>> +	else
>>>> +		return 0;
>>>
>>> Ditto.
>>
>> - ditto.
>>
>>>
>>>> +}
>>>> +
>>>> +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 val, fmt, hsize, vsize;
>>>> +
>>>> +	/* Get format */
>>>> +	fmt = rotator_reg_get_format(rot);
>>>
>>> Check if fmt is valid or not.
>>
>> - added rotator_check_fmt()
>>
>>>
>>>> +
>>>> +	/* Align buffer size */
>>>> +	hsize = sz->hsize;
>>>> +	vsize = sz->vsize;
>>>> +	rotator_align_size(rot, fmt, &hsize, &vsize);
>>>> +
>>>> +	/* Set buffer size configuration */
>>>> +	val = ROT_SET_BUF_SIZE_H(vsize) | ROT_SET_BUF_SIZE_W(hsize);
>>>> +	rot_write(val, ROT_DST_BUF_SIZE);
>>>> +
>>>> +	/* Set crop image position configuration */
>>>> +	val = ROT_CROP_POS_Y(pos->y) | ROT_CROP_POS_X(pos->x);
>>>> +	rot_write(val, ROT_DST_CROP_POS);
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +static int rotator_dst_set_addr(struct device *dev,
>>>> +		struct drm_exynos_ipp_buf_info *buf_info,
>>>> +		u32 buf_id, enum drm_exynos_ipp_buf_type buf_type)
>>>> +{
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +	dma_addr_t addr[EXYNOS_DRM_PLANAR_MAX];
>>>> +	u32 val, fmt, hsize, vsize;
>>>> +	int i;
>>>> +
>>>> +	/* Set current buf_id */
>>>> +	rot->cur_buf_id[EXYNOS_DRM_OPS_DST] = buf_id;
>>>> +
>>>> +	switch (buf_type) {
>>>> +	case IPP_BUF_ENQUEUE:
>>>> +		/* Set address configuration */
>>>> +		for_each_ipp_planar(i)
>>>> +			addr[i] = buf_info->base[i];
>>>> +
>>>> +		/* Get format */
>>>> +		fmt = rotator_reg_get_format(rot);
>>>
>>> Check if fmt is valid or not.
>>
>> - done.
>>
>>>
>>>> +
>>>> +		/* Re-set cb planar for NV12 format */
>>>> +		if ((fmt == ROT_CONTROL_FMT_YCBCR420_2P) &&
>>>> +					(addr[EXYNOS_DRM_PLANAR_CB] ==
>>> 0x00)) {
>>>> +			/* Get buf size */
>>>> +			val = rot_read(ROT_DST_BUF_SIZE);
>>>> +
>>>> +			hsize = ROT_GET_BUF_SIZE_W(val);
>>>> +			vsize = ROT_GET_BUF_SIZE_H(val);
>>>> +
>>>> +			/* Set cb planar */
>>>> +			addr[EXYNOS_DRM_PLANAR_CB] =
>>>> +				addr[EXYNOS_DRM_PLANAR_Y] + hsize * vsize;
>>>> +		}
>>>> +
>>>> +		for_each_ipp_planar(i)
>>>> +			rot_write(addr[i], ROT_DST_BUF_ADDR(i));
>>>> +		break;
>>>> +	case IPP_BUF_DEQUEUE:
>>>> +		for_each_ipp_planar(i)
>>>> +			rot_write(0x0, ROT_DST_BUF_ADDR(i));
>>>> +		break;
>>>> +	default:
>>>> +		/* Nothing to do */
>>>> +		break;
>>>> +	}
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +static struct exynos_drm_ipp_ops rot_src_ops = {
>>>> +	.set_fmt	=	rotator_src_set_fmt,
>>>> +	.set_size	=	rotator_src_set_size,
>>>> +	.set_addr	=	rotator_src_set_addr,
>>>> +};
>>>> +
>>>> +static struct exynos_drm_ipp_ops rot_dst_ops = {
>>>> +	.set_transf	=	rotator_dst_set_transf,
>>>> +	.set_size	=	rotator_dst_set_size,
>>>> +	.set_addr	=	rotator_dst_set_addr,
>>>> +};
>>>> +
>>>> +static int rotator_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
>>>> +{
>>>> +	struct drm_exynos_ipp_prop_list *prop_list;
>>>> +
>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>> +
>>>> +	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
>>>> +	if (!prop_list) {
>>>> +		DRM_ERROR("failed to alloc property list.\n");
>>>> +		return -ENOMEM;
>>>> +	}
>>>> +
>>>> +	/*ToDo fix support function list*/
>>>> +
>>>> +	prop_list->version = 1;
>>>> +	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
>>>> +				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
>>>> +	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
>>>> +				(1 << EXYNOS_DRM_DEGREE_90) |
>>>> +				(1 << EXYNOS_DRM_DEGREE_180) |
>>>> +				(1 << EXYNOS_DRM_DEGREE_270);
>>>> +	prop_list->csc = 0;
>>>> +	prop_list->crop = 0;
>>>> +	prop_list->scale = 0;
>>>> +
>>>> +	ippdrv->prop_list = prop_list;
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +static int rotator_ippdrv_check_property(struct device *dev,
>>>> +		struct drm_exynos_ipp_property *property)
>>>> +{
>>>> +	struct drm_exynos_ipp_config *src_config =
>>>> +
>>> &property->config[EXYNOS_DRM_OPS_SRC];
>>>> +	struct drm_exynos_ipp_config *dst_config =
>>>> +
>>> &property->config[EXYNOS_DRM_OPS_DST];
>>>> +	struct drm_exynos_pos *src_pos = &src_config->pos;
>>>> +	struct drm_exynos_pos *dst_pos = &dst_config->pos;
>>>> +	struct drm_exynos_sz *src_sz = &src_config->sz;
>>>> +	struct drm_exynos_sz *dst_sz = &dst_config->sz;
>>>> +	bool swap = false;
>>>> +
>>>> +	/* Check format configuration */
>>>> +	if (src_config->fmt != dst_config->fmt) {
>>>> +		DRM_DEBUG_KMS("%s:not support csc feature\n", __func__);
>>>> +		return -EINVAL;
>>>> +	}
>>>> +
>>>> +	switch (src_config->fmt) {
>>>> +	case DRM_FORMAT_XRGB8888:
>>>> +	case DRM_FORMAT_NV12:
>>>> +		/* No problem */
>>>> +		break;
>>>> +	default:
>>>> +		DRM_DEBUG_KMS("%s:not support format\n", __func__);
>>>> +		return -EINVAL;
>>>> +	}
>>>
>>> Use macro instead of switch-case. this just checks only format type.
>>
>> - I don't thing so, If we make macro about this.
>>     then we got some confusion about this macro at next change.
>>     this case switch-case is better.
>>     Do you prefer this ? please one more comment.
>>
>> #define drm_check_fmt(fmt) if (fmt == DRM_FORMAT_XRGB8888 || fmt ==
>> DRM_FORMAT_NV12) \
>> 					return true;
>>
>>>
>>>> +
>>>> +	/* Check transform configuration */
>>>> +	if (src_config->degree != EXYNOS_DRM_DEGREE_0) {
>>>> +		DRM_DEBUG_KMS("%s:not support source-side rotation\n",
>>>> +								__func__);
>>>> +		return -EINVAL;
>>>> +	}
>>>> +
>>>> +	switch (dst_config->degree) {
>>>> +	case EXYNOS_DRM_DEGREE_90:
>>>> +	case EXYNOS_DRM_DEGREE_270:
>>>> +		swap = true;
>>>> +	case EXYNOS_DRM_DEGREE_0:
>>>> +	case EXYNOS_DRM_DEGREE_180:
>>>> +		/* No problem */
>>>> +		break;
>>>> +	default:
>>>> +		DRM_DEBUG_KMS("%s:invalid degree\n", __func__);
>>>> +		return -EINVAL;
>>>> +	}
>>>> +
>>>> +	if (src_config->flip != EXYNOS_DRM_FLIP_NONE) {
>>>> +		DRM_DEBUG_KMS("%s:not support source-side flip\n",
>>> __func__);
>>>> +		return -EINVAL;
>>>> +	}
>>>> +
>>>> +	switch (dst_config->flip) {
>>>> +	case EXYNOS_DRM_FLIP_NONE:
>>>> +	case EXYNOS_DRM_FLIP_VERTICAL:
>>>> +	case EXYNOS_DRM_FLIP_HORIZONTAL:
>>>> +		/* No problem */
>>>> +		break;
>>>> +	default:
>>>> +		DRM_DEBUG_KMS("%s:invalid flip\n", __func__);
>>>> +		return -EINVAL;
>>>> +	}
>>>
>>> Use macro instead of switch-case. this just checks only flip type.
>>
>> - ditto. please one more comment.
>>    in my opinion: I prefer enumeration use switch-case.
>>
>>>
>>>> +
>>>> +	/* Check size configuration */
>>>> +	if ((src_pos->x + src_pos->w > src_sz->hsize) ||
>>>> +		(src_pos->y + src_pos->h > src_sz->vsize)) {
>>>> +		DRM_DEBUG_KMS("%s:out of source buffer bound\n", __func__);
>>>> +		return -EINVAL;
>>>> +	}
>>>> +
>>>> +	if (swap) {
>>>> +		if ((dst_pos->x + dst_pos->h > dst_sz->vsize) ||
>>>> +			(dst_pos->y + dst_pos->w > dst_sz->hsize)) {
>>>> +			DRM_DEBUG_KMS("%s:out of destination buffer
>>> bound\n",
>>>> +								__func__);
>>>> +			return -EINVAL;
>>>> +		}
>>>> +
>>>> +		if ((src_pos->w != dst_pos->h) || (src_pos->h !=
>>> dst_pos->w))
>>>> {
>>>> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
>>>> +								__func__);
>>>> +			return -EINVAL;
>>>> +		}
>>>> +	} else {
>>>> +		if ((dst_pos->x + dst_pos->w > dst_sz->hsize) ||
>>>> +			(dst_pos->y + dst_pos->h > dst_sz->vsize)) {
>>>> +			DRM_DEBUG_KMS("%s:out of destination buffer
>>> bound\n",
>>>> +								__func__);
>>>> +			return -EINVAL;
>>>> +		}
>>>> +
>>>> +		if ((src_pos->w != dst_pos->w) || (src_pos->h !=
>>> dst_pos->h))
>>>> {
>>>> +			DRM_DEBUG_KMS("%s:not support scale feature\n",
>>>> +								__func__);
>>>> +			return -EINVAL;
>>>> +		}
>>>> +	}
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +static int rotator_ippdrv_start(struct device *dev, enum
>>>> drm_exynos_ipp_cmd cmd)
>>>> +{
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +	u32 val;
>>>> +
>>>> +	if (rot->suspended) {
>>>> +		DRM_ERROR("suspended state\n");
>>>> +		return -EPERM;
>>>> +	}
>>>> +
>>>> +	if (cmd != IPP_CMD_M2M) {
>>>> +		DRM_ERROR("not support cmd: %d\n", cmd);
>>>> +		return -EINVAL;
>>>> +	}
>>>> +
>>>> +	/* Set interrupt enable */
>>>> +	rotator_reg_set_irq(rot, true);
>>>> +
>>>> +	val = rot_read(ROT_CONTROL);
>>>> +	val |= ROT_CONTROL_START;
>>>> +
>>>> +	rot_write(val, ROT_CONTROL);
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +static int __devinit rotator_probe(struct platform_device *pdev)
>>>> +{
>>>> +	struct device *dev = &pdev->dev;
>>>> +	struct rot_context *rot;
>>>> +	struct resource *res;
>>>> +	struct exynos_drm_ippdrv *ippdrv;
>>>> +	int ret;
>>>> +
>>>> +	rot = kzalloc(sizeof(*rot), GFP_KERNEL);
>>>> +	if (!rot) {
>>>> +		dev_err(dev, "failed to allocate rot\n");
>>>> +		return -ENOMEM;
>>>> +	}
>>>> +
>>>> +	rot->limit_tbl = (struct rot_limit_table *)
>>>> +				platform_get_device_id(pdev)->driver_data;
>>>> +
>>>> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>> +	if (!res) {
>>>> +		dev_err(dev, "failed to find registers\n");
>>>> +		ret = -ENOENT;
>>>> +		goto err_get_resource;
>>>> +	}
>>>> +
>>>> +	rot->regs_res = request_mem_region(res->start, resource_size(res),
>>>> +
>>> dev_name(dev));
>>>> +	if (!rot->regs_res) {
>>>> +		dev_err(dev, "failed to claim register region\n");
>>>> +		ret = -ENOENT;
>>>> +		goto err_get_resource;
>>>> +	}
>>>> +
>>>> +	rot->regs = ioremap(res->start, resource_size(res));
>>>> +	if (!rot->regs) {
>>>> +		dev_err(dev, "failed to map register\n");
>>>> +		ret = -ENXIO;
>>>> +		goto err_ioremap;
>>>> +	}
>>>> +
>>>> +	rot->irq = platform_get_irq(pdev, 0);
>>>> +	if (rot->irq < 0) {
>>>> +		dev_err(dev, "failed to get irq\n");
>>>> +		ret = rot->irq;
>>>> +		goto err_get_irq;
>>>> +	}
>>>> +
>>>> +	ret = request_threaded_irq(rot->irq, NULL, rotator_irq_handler,
>>>> +					IRQF_ONESHOT, "drm_rotator", rot);
>>>> +	if (ret < 0) {
>>>> +		dev_err(dev, "failed to request irq\n");
>>>> +		goto err_get_irq;
>>>> +	}
>>>> +
>>>> +	rot->clock = clk_get(dev, "rotator");
>>>> +	if (IS_ERR_OR_NULL(rot->clock)) {
>>>> +		dev_err(dev, "failed to get clock\n");
>>>> +		ret = PTR_ERR(rot->clock);
>>>> +		goto err_clk_get;
>>>> +	}
>>>> +
>>>> +	pm_runtime_enable(dev);
>>>> +
>>>> +	ippdrv = &rot->ippdrv;
>>>> +	ippdrv->dev = dev;
>>>> +	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &rot_src_ops;
>>>> +	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &rot_dst_ops;
>>>> +	ippdrv->check_property = rotator_ippdrv_check_property;
>>>> +	ippdrv->start = rotator_ippdrv_start;
>>>> +	ret = rotator_init_prop_list(ippdrv);
>>>> +	if (ret < 0) {
>>>> +		dev_err(dev, "failed to init property list.\n");
>>>> +		goto err_ippdrv_register;
>>>> +	}
>>>> +
>>>> +	DRM_DEBUG_KMS("%s:ippdrv[0x%x]\n", __func__, (int)ippdrv);
>>>> +
>>>> +	platform_set_drvdata(pdev, rot);
>>>> +
>>>> +	ret = exynos_drm_ippdrv_register(ippdrv);
>>>> +	if (ret < 0) {
>>>> +		dev_err(dev, "failed to register drm rotator device\n");
>>>> +		kfree(ippdrv->prop_list);
>>>> +		goto err_ippdrv_register;
>>>> +	}
>>>> +
>>>> +	dev_info(dev, "The exynos rotator is probed successfully\n");
>>>> +
>>>> +	return 0;
>>>> +
>>>> +err_ippdrv_register:
>>>> +	pm_runtime_disable(dev);
>>>> +	clk_put(rot->clock);
>>>> +err_clk_get:
>>>> +	free_irq(rot->irq, rot);
>>>> +err_get_irq:
>>>> +	iounmap(rot->regs);
>>>> +err_ioremap:
>>>> +	release_resource(rot->regs_res);
>>>> +	kfree(rot->regs_res);
>>>> +err_get_resource:
>>>> +	kfree(rot);
>>>> +	return ret;
>>>> +}
>>>> +
>>>> +static int __devexit rotator_remove(struct platform_device *pdev)
>>>> +{
>>>> +	struct device *dev = &pdev->dev;
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +	struct exynos_drm_ippdrv *ippdrv = &rot->ippdrv;
>>>> +
>>>> +	kfree(ippdrv->prop_list);
>>>> +	exynos_drm_ippdrv_unregister(ippdrv);
>>>> +
>>>> +	pm_runtime_disable(dev);
>>>> +	clk_put(rot->clock);
>>>> +
>>>> +	free_irq(rot->irq, rot);
>>>> +
>>>> +	iounmap(rot->regs);
>>>> +
>>>> +	release_resource(rot->regs_res);
>>>> +	kfree(rot->regs_res);
>>>> +
>>>> +	kfree(rot);
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +struct rot_limit_table rot_limit_tbl = {
>>>> +	.ycbcr420_2p = {
>>>> +		.min_w = 32,
>>>> +		.min_h = 32,
>>>> +		.max_w = SZ_32K,
>>>> +		.max_h = SZ_32K,
>>>> +		.align = 3,
>>>> +	},
>>>> +	.rgb888 = {
>>>> +		.min_w = 8,
>>>> +		.min_h = 8,
>>>> +		.max_w = SZ_8K,
>>>> +		.max_h = SZ_8K,
>>>> +		.align = 2,
>>>> +	},
>>>> +};
>>>> +
>>>> +struct platform_device_id rotator_driver_ids[] = {
>>>> +	{
>>>> +		.name		= "exynos-rot",
>>>> +		.driver_data	= (unsigned long)&rot_limit_tbl,
>>>> +	},
>>>> +	{},
>>>> +};
>>>> +
>>>> +static int rotator_clk_crtl(struct rot_context *rot, bool enable)
>>>> +{
>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>> +
>>>> +	if (enable) {
>>>> +		clk_enable(rot->clock);
>>>> +		rot->suspended = false;
>>>> +	} else {
>>>> +		clk_disable(rot->clock);
>>>> +		rot->suspended = true;
>>>> +	}
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +
>>>> +
>>>> +#ifdef CONFIG_PM_SLEEP
>>>> +static int rotator_suspend(struct device *dev)
>>>> +{
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +
>>>> +	/* ToDo */
>>>> +
>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>> +
>>>> +	if (pm_runtime_suspended(dev))
>>>> +		return 0;
>>>> +
>>>> +	return rotator_clk_crtl(rot, false);
>>>> +}
>>>> +
>>>> +static int rotator_resume(struct device *dev)
>>>> +{
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +
>>>> +	/* ToDo */
>>>> +
>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>> +
>>>> +	if (!pm_runtime_suspended(dev))
>>>> +		return rotator_clk_crtl(rot, true);
>>>> +
>>>> +	return 0;
>>>> +}
>>>> +#endif
>>>> +
>>>> +#ifdef CONFIG_PM_RUNTIME
>>>> +static int rotator_runtime_suspend(struct device *dev)
>>>> +{
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +
>>>> +	/* ToDo */
>>>> +
>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>> +
>>>> +	return  rotator_clk_crtl(rot, false);
>>>> +}
>>>> +
>>>> +static int rotator_runtime_resume(struct device *dev)
>>>> +{
>>>> +	struct rot_context *rot = dev_get_drvdata(dev);
>>>> +
>>>> +	/* ToDo */
>>>> +
>>>> +	DRM_DEBUG_KMS("%s\n", __func__);
>>>> +
>>>> +	return  rotator_clk_crtl(rot, true);
>>>> +}
>>>> +#endif
>>>> +
>>>> +static const struct dev_pm_ops rotator_pm_ops = {
>>>> +	SET_SYSTEM_SLEEP_PM_OPS(rotator_suspend, rotator_resume)
>>>> +	SET_RUNTIME_PM_OPS(rotator_runtime_suspend, rotator_runtime_resume,
>>>> +
>>> NULL)
>>>> +};
>>>> +
>>>> +struct platform_driver rotator_driver = {
>>>> +	.probe		= rotator_probe,
>>>> +	.remove		= __devexit_p(rotator_remove),
>>>> +	.id_table	= rotator_driver_ids,
>>>> +	.driver		= {
>>>> +		.name	= "exynos-rot",
>>>> +		.owner	= THIS_MODULE,
>>>> +		.pm	= &rotator_pm_ops,
>>>> +	},
>>>> +};
>>>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_rotator.h
>>>> b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
>>>> new file mode 100644
>>>> index 0000000..fe929c9
>>>> --- /dev/null
>>>> +++ b/drivers/gpu/drm/exynos/exynos_drm_rotator.h
>>>> @@ -0,0 +1,13 @@
>>>> +/*
>>>> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
>>>> + * Authors: YoungJun Cho <yj44.cho@samsung.com>
>>>> + *
>>>> + * This program is free software; you can redistribute it and/or
>> modify
>>>> + * it under the terms of the GNU General Public License version 2 as
>>>> + * published by the Free Software Foundationr
>>>> + */
>>>> +
>>>> +#ifndef	_EXYNOS_DRM_ROTATOR_H_
>>>> +#define	_EXYNOS_DRM_ROTATOR_H_
>>>> +
>>>> +#endif
>>>> diff --git a/drivers/gpu/drm/exynos/regs-rotator.h
>>>> b/drivers/gpu/drm/exynos/regs-rotator.h
>>>> new file mode 100644
>>>> index 0000000..a09ac6e
>>>> --- /dev/null
>>>> +++ b/drivers/gpu/drm/exynos/regs-rotator.h
>>>> @@ -0,0 +1,73 @@
>>>> +/* drivers/gpu/drm/exynos/regs-rotator.h
>>>> + *
>>>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>>>> + *		http://www.samsung.com/
>>>> + *
>>>> + * Register definition file for Samsung Rotator Interface (Rotator)
>>>> driver
>>>> + *
>>>> + * This program is free software; you can redistribute it and/or
>> modify
>>>> + * it under the terms of the GNU General Public License version 2 as
>>>> + * published by the Free Software Foundation.
>>>> +*/
>>>> +
>>>> +#ifndef EXYNOS_REGS_ROTATOR_H
>>>> +#define EXYNOS_REGS_ROTATOR_H
>>>> +
>>>> +/* Configuration */
>>>> +#define ROT_CONFIG			0x00
>>>> +#define ROT_CONFIG_IRQ			(3 << 8)
>>>> +
>>>> +/* Image Control */
>>>> +#define ROT_CONTROL			0x10
>>>> +#define ROT_CONTROL_PATTERN_WRITE	(1 << 16)
>>>> +#define ROT_CONTROL_FMT_YCBCR420_2P	(1 << 8)
>>>> +#define ROT_CONTROL_FMT_RGB888		(6 << 8)
>>>> +#define ROT_CONTROL_FMT_MASK		(7 << 8)
>>>> +#define ROT_CONTROL_FLIP_VERTICAL	(2 << 6)
>>>> +#define ROT_CONTROL_FLIP_HORIZONTAL	(3 << 6)
>>>> +#define ROT_CONTROL_FLIP_MASK		(3 << 6)
>>>> +#define ROT_CONTROL_ROT_90		(1 << 4)
>>>> +#define ROT_CONTROL_ROT_180		(2 << 4)
>>>> +#define ROT_CONTROL_ROT_270		(3 << 4)
>>>> +#define ROT_CONTROL_ROT_MASK		(3 << 4)
>>>> +#define ROT_CONTROL_START		(1 << 0)
>>>> +
>>>> +/* Status */
>>>> +#define ROT_STATUS			0x20
>>>> +#define ROT_STATUS_IRQ_PENDING(x)	(1 << (x))
>>>> +#define ROT_STATUS_IRQ(x)		(((x) >> 8) & 0x3)
>>>> +#define ROT_STATUS_IRQ_VAL_COMPLETE	1
>>>> +#define ROT_STATUS_IRQ_VAL_ILLEGAL	2
>>>> +
>>>> +/* Buffer Address */
>>>> +#define ROT_SRC_BUF_ADDR(n)		(0x30 + ((n) << 2))
>>>> +#define ROT_DST_BUF_ADDR(n)		(0x50 + ((n) << 2))
>>>> +
>>>> +/* Buffer Size */
>>>> +#define ROT_SRC_BUF_SIZE		0x3c
>>>> +#define ROT_DST_BUF_SIZE		0x5c
>>>> +#define ROT_SET_BUF_SIZE_H(x)		((x) << 16)
>>>> +#define ROT_SET_BUF_SIZE_W(x)		((x) << 0)
>>>> +#define ROT_GET_BUF_SIZE_H(x)		((x) >> 16)
>>>> +#define ROT_GET_BUF_SIZE_W(x)		((x) & 0xffff)
>>>> +
>>>> +/* Crop Position */
>>>> +#define ROT_SRC_CROP_POS		0x40
>>>> +#define ROT_DST_CROP_POS		0x60
>>>> +#define ROT_CROP_POS_Y(x)		((x) << 16)
>>>> +#define ROT_CROP_POS_X(x)		((x) << 0)
>>>> +
>>>> +/* Source Crop Size */
>>>> +#define ROT_SRC_CROP_SIZE		0x44
>>>> +#define ROT_SRC_CROP_SIZE_H(x)		((x) << 16)
>>>> +#define ROT_SRC_CROP_SIZE_W(x)		((x) << 0)
>>>> +
>>>> +/* Round to nearest aligned value */
>>>> +#define ROT_ALIGN(x, align, mask)	(((x) + (1 << ((align) - 1))) &
>>>> (mask))
>>>> +/* Minimum limit value */
>>>> +#define ROT_MIN(min, mask)		(((min) + ~(mask)) & (mask))
>>>> +/* Maximum limit value */
>>>> +#define ROT_MAX(max, mask)		((max) & (mask))
>>>> +
>>>> +#endif /* EXYNOS_REGS_ROTATOR_H */
>>>> +
>>>> --
>>>> 1.7.0.4
>>>
>>>
>
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC v3 5/5] drm/exynos: add gsc ipp driver
  2012-12-12  7:34 ` [RFC v3 5/5] drm/exynos: add gsc " Eunchul Kim
@ 2012-12-13  2:29   ` Joonyoung Shim
  2012-12-14  5:29     ` Eunchul Kim
  0 siblings, 1 reply; 18+ messages in thread
From: Joonyoung Shim @ 2012-12-13  2:29 UTC (permalink / raw)
  To: Eunchul Kim; +Cc: jy0.jeon, jaejoon.seo, dri-devel, kyungmin.park, jmock.shin

Hi,

I can't review about logic of driver because i don't know well but i 
feel there are too many checking codes and unused or big size defines.
Please refer v4l2 exynos gsc driver in drivers/media/platform/exynos-gsc/.

This v3 patch seems to add many codes than v2. Please write changelog in 
future.
Even if line is short, many lines are split to two lines. Please check 
it overall.

Thanks.

On 12/12/2012 04:34 PM, Eunchul Kim wrote:
> GSC is stand for General SCaler and supports supports

supports supports

> image scaler/rotator/crop/flip/csc and input/output DMA operations.
> input DMA reads image data from the memory.
> output DMA writes image data to memory.
> GSC supports image rotation and imag effect functions.

s/imag/image

> also supports writeback and display output operations.

There are to begin a new line unnecessarily. Could you rewrite 
detailedly how this driver operates?

>
> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
> Signed-off-by: Jinyoung Jeon <jy0.jeon@samsung.com>
> ---
>   drivers/gpu/drm/exynos/Kconfig          |    5 +
>   drivers/gpu/drm/exynos/Makefile         |    1 +
>   drivers/gpu/drm/exynos/exynos_drm_drv.c |   15 +
>   drivers/gpu/drm/exynos/exynos_drm_drv.h |    1 +
>   drivers/gpu/drm/exynos/exynos_drm_gsc.c | 1927 +++++++++++++++++++++++++++++++
>   drivers/gpu/drm/exynos/exynos_drm_gsc.h |   34 +
>   drivers/gpu/drm/exynos/regs-gsc.h       |  295 +++++
>   7 files changed, 2278 insertions(+), 0 deletions(-)
>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.c
>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.h
>   create mode 100644 drivers/gpu/drm/exynos/regs-gsc.h
>
> diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
> index 4860835..c93d776 100644
> --- a/drivers/gpu/drm/exynos/Kconfig
> +++ b/drivers/gpu/drm/exynos/Kconfig
> @@ -64,3 +64,8 @@ config DRM_EXYNOS_ROTATOR
>   	help
>   	  Choose this option if you want to use Exynos Rotator for DRM.
>   
> +config DRM_EXYNOS_GSC
> +	bool "Exynos DRM GSC"
> +	depends on DRM_EXYNOS_IPP && ARCH_EXYNOS5
> +	help
> +	  Choose this option if you want to use Exynos GSC for DRM.
> diff --git a/drivers/gpu/drm/exynos/Makefile b/drivers/gpu/drm/exynos/Makefile
> index 3b70668..639b49e 100644
> --- a/drivers/gpu/drm/exynos/Makefile
> +++ b/drivers/gpu/drm/exynos/Makefile
> @@ -19,5 +19,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)	+= exynos_drm_g2d.o
>   exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)	+= exynos_drm_ipp.o
>   exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)	+= exynos_drm_fimc.o
>   exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)	+= exynos_drm_rotator.o
> +exynosdrm-$(CONFIG_DRM_EXYNOS_GSC)	+= exynos_drm_gsc.o
>   
>   obj-$(CONFIG_DRM_EXYNOS)		+= exynosdrm.o
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> index 09d884b..e0a8e80 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
> @@ -384,6 +384,12 @@ static int __init exynos_drm_init(void)
>   		goto out_rotator;
>   #endif
>   
> +#ifdef CONFIG_DRM_EXYNOS_GSC
> +	ret = platform_driver_register(&gsc_driver);
> +	if (ret < 0)
> +		goto out_gsc;
> +#endif
> +
>   #ifdef CONFIG_DRM_EXYNOS_IPP
>   	ret = platform_driver_register(&ipp_driver);
>   	if (ret < 0)
> @@ -412,6 +418,11 @@ out_drm:
>   out_ipp:
>   #endif
>   
> +#ifdef CONFIG_DRM_EXYNOS_GSC
> +	platform_driver_unregister(&gsc_driver);
> +out_gsc:
> +#endif
> +
>   #ifdef CONFIG_DRM_EXYNOS_ROTATOR
>   	platform_driver_unregister(&rotator_driver);
>   out_rotator:
> @@ -462,6 +473,10 @@ static void __exit exynos_drm_exit(void)
>   	platform_driver_unregister(&ipp_driver);
>   #endif
>   
> +#ifdef CONFIG_DRM_EXYNOS_GSC
> +	platform_driver_unregister(&gsc_driver);
> +#endif
> +
>   #ifdef CONFIG_DRM_EXYNOS_ROTATOR
>   	platform_driver_unregister(&rotator_driver);
>   #endif
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> index a74e37c..afe556c 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
> @@ -354,5 +354,6 @@ extern struct platform_driver vidi_driver;
>   extern struct platform_driver g2d_driver;
>   extern struct platform_driver fimc_driver;
>   extern struct platform_driver rotator_driver;
> +extern struct platform_driver gsc_driver;
>   extern struct platform_driver ipp_driver;
>   #endif
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> new file mode 100644
> index 0000000..a4475b0
> --- /dev/null
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
> @@ -0,0 +1,1927 @@
> +/*
> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
> + * Authors:
> + *	Eunchul Kim <chulspro.kim@samsung.com>
> + *	Jinyoung Jeon <jy0.jeon@samsung.com>
> + *	Sangmin Lee <lsmin.lee@samsung.com>
> + *
> + * This program is free software; you can redistribute  it and/or modify it
> + * under  the terms of  the GNU General  Public License as published by the
> + * Free Software Foundation;  either version 2 of the  License, or (at your
> + * option) any later version.
> + *
> + */
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +#include <linux/clk.h>
> +#include <linux/pm_runtime.h>
> +#include <plat/map-base.h>
> +
> +#include <drm/drmP.h>
> +#include <drm/exynos_drm.h>
> +#include "regs-gsc.h"
> +#include "exynos_drm_ipp.h"
> +#include "exynos_drm_gsc.h"
> +
> +/*
> + * GSC is stand for General SCaler and
> + * supports image scaler/rotator and input/output DMA operations.
> + * input DMA reads image data from the memory.
> + * output DMA writes image data to memory.
> + * GSC supports image rotation and image effect functions.
> + */

Please see my comments about commit description.

> +
> +#define GSC_MAX_DEVS	4
> +#define GSC_MAX_SRC		4
> +#define GSC_MAX_DST		16
> +#define GSC_RESET_TIMEOUT	50
> +#define GSC_BUF_STOP	1
> +#define GSC_BUF_START	2
> +#define GSC_REG_SZ		16
> +#define GSC_WIDTH_ITU_709	1280
> +#define GSC_SC_UP_MAX_RATIO		65536
> +#define GSC_SC_DOWN_RATIO_7_8		74898
> +#define GSC_SC_DOWN_RATIO_6_8		87381
> +#define GSC_SC_DOWN_RATIO_5_8		104857
> +#define GSC_SC_DOWN_RATIO_4_8		131072
> +#define GSC_SC_DOWN_RATIO_3_8		174762
> +#define GSC_SC_DOWN_RATIO_2_8		262144
> +#define GSC_REFRESH_MIN	12
> +#define GSC_REFRESH_MAX	60
> +#define GSC_CROP_MAX	8192
> +#define GSC_CROP_MIN	32
> +#define GSC_SCALE_MAX	4224
> +#define GSC_SCALE_MIN	32
> +
> +#define get_gsc_context(dev)	platform_get_drvdata(to_platform_device(dev))
> +#define get_ctx_from_ippdrv(ippdrv)	container_of(ippdrv,\
> +					struct gsc_context, ippdrv);
> +#define gsc_read(offset)		readl(ctx->regs + (offset))
> +#define gsc_write(cfg, offset)	writel(cfg, ctx->regs + (offset))
> +
> +/*
> + * A structure of scaler.
> + *
> + * @range: narrow, wide.
> + * @pre_shfactor: pre sclaer shift factor.
> + * @pre_hratio: horizontal ratio of the prescaler.
> + * @pre_vratio: vertical ratio of the prescaler.
> + * @main_hratio: the main scaler's horizontal ratio.
> + * @main_vratio: the main scaler's vertical ratio.
> + */
> +struct gsc_scaler {
> +	bool	range;
> +	u32	pre_shfactor;
> +	u32	pre_hratio;
> +	u32	pre_vratio;
> +	unsigned long main_hratio;
> +	unsigned long main_vratio;
> +};
> +
> +/*
> + * A structure of scaler capability.
> + *
> + * find user manual 49.2 features.
> + * @tile_w: tile mode or rotation width.
> + * @tile_h: tile mode or rotation height.
> + * @w: other cases width.
> + * @h: other cases height.
> + */
> +struct gsc_capability {
> +	/* tile or rotation */
> +	u32	tile_w;
> +	u32	tile_h;
> +	/* other cases */
> +	u32	w;
> +	u32	h;
> +};
> +
> +/*
> + * A structure of gsc context.
> + *
> + * @ippdrv: prepare initialization using ippdrv.
> + * @regs_res: register resources.
> + * @regs: memory mapped io registers.
> + * @lock: locking of operations.
> + * @gsc_clk: gsc gate clock.
> + * @parent_clk: parent clock e.g aclk_300.
> + * @child_clk: child clock e.g dout_aclk_300.
> + * @sc: scaler infomations.
> + * @id: gsc id.
> + * @irq: irq number.
> + * @rotation: supports rotation of src.
> + * @suspended: qos operations.
> + */
> +struct gsc_context {
> +	struct exynos_drm_ippdrv	ippdrv;
> +	struct resource	*regs_res;
> +	void __iomem	*regs;
> +	struct mutex	lock;
> +	struct clk	*gsc_clk;
> +	struct clk	*parent_clk;
> +	struct clk	*child_clk;
> +	struct gsc_scaler	sc;
> +	int	id;
> +	int	irq;
> +	bool	rotation;
> +	bool	suspended;
> +};
> +
> +/* 8-tap Filter Coefficient */
> +const int h_coef_8t[7][16][8] = {

static? and it is unnecessary to be size of array.

> +	{	/* Ratio <= 65536 (~8:8) */
> +		{  0,  0,   0, 128,   0,   0,  0,  0 },/* 0 */
> +		{ -1,  2,  -6, 127,   7,  -2,  1,  0 },/* 1 */
> +		{ -1,  4, -12, 125,  16,  -5,  1,  0 },/* 2 */
> +		{ -1,  5, -15, 120,  25,  -8,  2,  0 },/* 3 */
> +		{ -1,  6, -18, 114,  35, -10,  3, -1 },/* 4 */
> +		{ -1,  6, -20, 107,  46, -13,  4, -1 },/* 5 */
> +		{ -2,  7, -21,  99,  57, -16,  5, -1 },/* 6 */
> +		{ -1,  6, -20,  89,  68, -18,  5, -1 },/* 7 */
> +		{ -1,  6, -20,  79,  79, -20,  6, -1 },/* 8 */
> +		{ -1,  5, -18,  68,  89, -20,  6, -1 },/* 9 */
> +		{ -1,  5, -16,  57,  99, -21,  7, -2 },/* 10 */
> +		{ -1,  4, -13,  46, 107, -20,  6, -1 },/* 11 */
> +		{ -1,  3, -10,  35, 114, -18,  6, -1 },/* 12 */
> +		{  0,  2,  -8,  25, 120, -15,  5, -1 },/* 13 */
> +		{  0,  1,  -5,  16, 125, -12,  4, -1 },/* 14 */
> +		{  0,  1,  -2,   7, 127,  -6,  2, -1 } /* 15 */

The comments for index seem unnecessary.

> +	}, {	/* 65536 < Ratio <= 74898 (~8:7) */
> +		{  3, -8,  14, 111,  13,  -8,  3,  0 },/* 0 */
> +		{  2, -6,   7, 112,  21, -10,  3, -1 },/* 1 */
> +		{  2, -4,   1, 110,  28, -12,  4, -1 },/* 2 */
> +		{  1, -2,  -3, 106,  36, -13,  4, -1 },/* 3 */
> +		{  1, -1,  -7, 103,  44, -15,  4, -1 },/* 4 */
> +		{  1,  1, -11,  97,  53, -16,  4, -1 },/* 5 */
> +		{  0,  2, -13,  91,  61, -16,  4, -1 },/* 6 */
> +		{  0,  3, -15,  85,  69, -17,  4, -1 },/* 7 */
> +		{  0,  3, -16,  77,  77, -16,  3,  0 },/* 8 */
> +		{ -1,  4, -17,  69,  85, -15,  3,  0 },/* 9 */
> +		{ -1,  4, -16,  61,  91, -13,  2,  0 },/* 10 */
> +		{ -1,  4, -16,  53,  97, -11,  1,  1 },/* 11 */
> +		{ -1,  4, -15,  44, 103,  -7, -1,  1 },/* 12 */
> +		{ -1,  4, -13,  36, 106,  -3, -2,  1 },/* 13 */
> +		{ -1,  4, -12,  28, 110,   1, -4,  2 },/* 14 */
> +		{ -1,  3, -10,  21, 112,   7, -6,  2 } /* 15 */
> +	}, {	/* 74898 < Ratio <= 87381 (~8:6) */
> +		{ 2, -11,  25,  96, 25, -11,   2,  0 },/* 0 */
> +		{ 2, -10,  19,  96, 31, -12,   2,  0 },/* 1 */
> +		{ 2,  -9,  14,  94, 37, -12,   2,  0 },/* 2 */
> +		{ 2,  -8,  10,  92, 43, -12,   1,  0 },/* 3 */
> +		{ 2,  -7,   5,  90, 49, -12,   1,  0 },/* 4 */
> +		{ 2,  -5,   1,  86, 55, -12,   0,  1 },/* 5 */
> +		{ 2,  -4,  -2,  82, 61, -11,  -1,  1 },/* 6 */
> +		{ 1,  -3,  -5,  77, 67,  -9,  -1,  1 },/* 7 */
> +		{ 1,  -2,  -7,  72, 72,  -7,  -2,  1 },/* 8 */
> +		{ 1,  -1,  -9,  67, 77,  -5,  -3,  1 },/* 9 */
> +		{ 1,  -1, -11,  61, 82,  -2,  -4,  2 },/* 10 */
> +		{ 1,   0, -12,  55, 86,   1,  -5,  2 },/* 11 */
> +		{ 0,   1, -12,  49, 90,   5,  -7,  2 },/* 12 */
> +		{ 0,   1, -12,  43, 92,  10,  -8,  2 },/* 13 */
> +		{ 0,   2, -12,  37, 94,  14,  -9,  2 },/* 14 */
> +		{ 0,   2, -12,  31, 96,  19, -10,  2 } /* 15 */
> +	}, {	/* 87381 < Ratio <= 104857 (~8:5) */
> +		{ -1,  -8, 33,  80, 33,  -8,  -1,  0 },/* 0 */
> +		{ -1,  -8, 28,  80, 37,  -7,  -2,  1 },/* 1 */
> +		{  0,  -8, 24,  79, 41,  -7,  -2,  1 },/* 2 */
> +		{  0,  -8, 20,  78, 46,  -6,  -3,  1 },/* 3 */
> +		{  0,  -8, 16,  76, 50,  -4,  -3,  1 },/* 4 */
> +		{  0,  -7, 13,  74, 54,  -3,  -4,  1 },/* 5 */
> +		{  1,  -7, 10,  71, 58,  -1,  -5,  1 },/* 6 */
> +		{  1,  -6,  6,  68, 62,   1,  -5,  1 },/* 7 */
> +		{  1,  -6,  4,  65, 65,   4,  -6,  1 },/* 8 */
> +		{  1,  -5,  1,  62, 68,   6,  -6,  1 },/* 9 */
> +		{  1,  -5, -1,  58, 71,  10,  -7,  1 },/* 10 */
> +		{  1,  -4, -3,  54, 74,  13,  -7,  0 },/* 11 */
> +		{  1,  -3, -4,  50, 76,  16,  -8,  0 },/* 12 */
> +		{  1,  -3, -6,  46, 78,  20,  -8,  0 },/* 13 */
> +		{  1,  -2, -7,  41, 79,  24,  -8,  0 },/* 14 */
> +		{  1,  -2, -7,  37, 80,  28,  -8, -1 } /* 15 */
> +	}, {	/* 104857 < Ratio <= 131072 (~8:4) */
> +		{ -3,   0, 35,  64, 35,   0,  -3,  0 },/* 0 */
> +		{ -3,  -1, 32,  64, 38,   1,  -3,  0 },/* 1 */
> +		{ -2,  -2, 29,  63, 41,   2,  -3,  0 },/* 2 */
> +		{ -2,  -3, 27,  63, 43,   4,  -4,  0 },/* 3 */
> +		{ -2,  -3, 24,  61, 46,   6,  -4,  0 },/* 4 */
> +		{ -2,  -3, 21,  60, 49,   7,  -4,  0 },/* 5 */
> +		{ -1,  -4, 19,  59, 51,   9,  -4, -1 },/* 6 */
> +		{ -1,  -4, 16,  57, 53,  12,  -4, -1 },/* 7 */
> +		{ -1,  -4, 14,  55, 55,  14,  -4, -1 },/* 8 */
> +		{ -1,  -4, 12,  53, 57,  16,  -4, -1 },/* 9 */
> +		{ -1,  -4,  9,  51, 59,  19,  -4, -1 },/* 10 */
> +		{  0,  -4,  7,  49, 60,  21,  -3, -2 },/* 11 */
> +		{  0,  -4,  6,  46, 61,  24,  -3, -2 },/* 12 */
> +		{  0,  -4,  4,  43, 63,  27,  -3, -2 },/* 13 */
> +		{  0,  -3,  2,  41, 63,  29,  -2, -2 },/* 14 */
> +		{  0,  -3,  1,  38, 64,  32,  -1, -3 } /* 15 */
> +	}, {	/* 131072 < Ratio <= 174762 (~8:3) */
> +		{ -1,   8, 33,  48, 33,   8,  -1,  0 },/* 0 */
> +		{ -1,   7, 31,  49, 35,   9,  -1, -1 },/* 1 */
> +		{ -1,   6, 30,  49, 36,  10,  -1, -1 },/* 2 */
> +		{ -1,   5, 28,  48, 38,  12,  -1, -1 },/* 3 */
> +		{ -1,   4, 26,  48, 39,  13,   0, -1 },/* 4 */
> +		{ -1,   3, 24,  47, 41,  15,   0, -1 },/* 5 */
> +		{ -1,   2, 23,  47, 42,  16,   0, -1 },/* 6 */
> +		{ -1,   2, 21,  45, 43,  18,   1, -1 },/* 7 */
> +		{ -1,   1, 19,  45, 45,  19,   1, -1 },/* 8 */
> +		{ -1,   1, 18,  43, 45,  21,   2, -1 },/* 9 */
> +		{ -1,   0, 16,  42, 47,  23,   2, -1 },/* 10 */
> +		{ -1,   0, 15,  41, 47,  24,   3, -1 },/* 11 */
> +		{ -1,   0, 13,  39, 48,  26,   4, -1 },/* 12 */
> +		{ -1,  -1, 12,  38, 48,  28,   5, -1 },/* 13 */
> +		{ -1,  -1, 10,  36, 49,  30,   6, -1 },/* 14 */
> +		{ -1,  -1,  9,  35, 49,  31,   7, -1 } /* 15 */
> +	}, {	/* 174762 < Ratio <= 262144 (~8:2) */
> +		{  2,  13, 30,  38, 30,  13,   2,  0 },/* 0 */
> +		{  2,  12, 29,  38, 30,  14,   3,  0 },/* 1 */
> +		{  2,  11, 28,  38, 31,  15,   3,  0 },/* 2 */
> +		{  2,  10, 26,  38, 32,  16,   4,  0 },/* 3 */
> +		{  1,  10, 26,  37, 33,  17,   4,  0 },/* 4 */
> +		{  1,   9, 24,  37, 34,  18,   5,  0 },/* 5 */
> +		{  1,   8, 24,  37, 34,  19,   5,  0 },/* 6 */
> +		{  1,   7, 22,  36, 35,  20,   6,  1 },/* 7 */
> +		{  1,   6, 21,  36, 36,  21,   6,  1 },/* 8 */
> +		{  1,   6, 20,  35, 36,  22,   7,  1 },/* 9 */
> +		{  0,   5, 19,  34, 37,  24,   8,  1 },/* 10 */
> +		{  0,   5, 18,  34, 37,  24,   9,  1 },/* 11 */
> +		{  0,   4, 17,  33, 37,  26,  10,  1 },/* 12 */
> +		{  0,   4, 16,  32, 38,  26,  10,  2 },/* 13 */
> +		{  0,   3, 15,  31, 38,  28,  11,  2 },/* 14 */
> +		{  0,   3, 14,  30, 38,  29,  12,  2 } /* 15 */
> +	}
> +};
> +
> +/* 4-tap Filter Coefficient */
> +const int v_coef_4t[7][16][4] = {
> +	{	/* Ratio <= 65536 (~8:8) */
> +		{  0, 128,   0,  0 },/* 0 */
> +		{ -4, 127,   5,  0 },/* 1 */
> +		{ -6, 124,  11, -1 },/* 2 */
> +		{ -8, 118,  19, -1 },/* 3 */
> +		{ -8, 111,  27, -2 },/* 4 */
> +		{ -8, 102,  37, -3 },/* 5 */
> +		{ -8,  92,  48, -4 },/* 6 */
> +		{ -7,  81,  59, -5 },/* 7 */
> +		{ -6,  70,  70, -6 },/* 8 */
> +		{ -5,  59,  81, -7 },/* 9 */
> +		{ -4,  48,  92, -8 },/* 10 */
> +		{ -3,  37, 102, -8 },/* 11 */
> +		{ -2,  27, 111, -8 },/* 12 */
> +		{ -1,  19, 118, -8 },/* 13 */
> +		{ -1,  11, 124, -6 },/* 14 */
> +		{  0,   5, 127, -4 } /* 15 */
> +	}, {	/* 65536 < Ratio <= 74898 (~8:7) */
> +		{  8, 112,   8,  0 },/* 0 */
> +		{  4, 111,  14, -1 },/* 1 */
> +		{  1, 109,  20, -2 },/* 2 */
> +		{ -2, 105,  27, -2 },/* 3 */
> +		{ -3, 100,  34, -3 },/* 4 */
> +		{ -5,  93,  43, -3 },/* 5 */
> +		{ -5,  86,  51, -4 },/* 6 */
> +		{ -5,  77,  60, -4 },/* 7 */
> +		{ -5,  69,  69, -5 },/* 8 */
> +		{ -4,  60,  77, -5 },/* 9 */
> +		{ -4,  51,  86, -5 },/* 10 */
> +		{ -3,  43,  93, -5 },/* 11 */
> +		{ -3,  34, 100, -3 },/* 12 */
> +		{ -2,  27, 105, -2 },/* 13 */
> +		{ -2,  20, 109,  1 },/* 14 */
> +		{ -1,  14, 111,  4 } /* 15 */
> +	}, {	/* 74898 < Ratio <= 87381 (~8:6) */
> +		{ 16,  96,  16,  0 },/* 0 */
> +		{ 12,  97,  21, -2 },/* 1 */
> +		{  8,  96,  26, -2 },/* 2 */
> +		{  5,  93,  32, -2 },/* 3 */
> +		{  2,  89,  39, -2 },/* 4 */
> +		{  0,  84,  46, -2 },/* 5 */
> +		{ -1,  79,  53, -3 },/* 6 */
> +		{ -2,  73,  59, -2 },/* 7 */
> +		{ -2,  66,  66, -2 },/* 8 */
> +		{ -2,  59,  73, -2 },/* 9 */
> +		{ -3,  53,  79, -1 },/* 10 */
> +		{ -2,  46,  84,  0 },/* 11 */
> +		{ -2,  39,  89,  2 },/* 12 */
> +		{ -2,  32,  93,  5 },/* 13 */
> +		{ -2,  26,  96,  8 },/* 14 */
> +		{ -2,  21,  97, 12 } /* 15 */
> +	}, {	/* 87381 < Ratio <= 104857 (~8:5) */
> +		{ 22,  84,  22,  0 },/* 0 */
> +		{ 18,  85,  26, -1 },/* 1 */
> +		{ 14,  84,  31, -1 },/* 2 */
> +		{ 11,  82,  36, -1 },/* 3 */
> +		{  8,  79,  42, -1 },/* 4 */
> +		{  6,  76,  47, -1 },/* 5 */
> +		{  4,  72,  52,  0 },/* 6 */
> +		{  2,  68,  58,  0 },/* 7 */
> +		{  1,  63,  63,  1 },/* 8 */
> +		{  0,  58,  68,  2 },/* 9 */
> +		{  0,  52,  72,  4 },/* 10 */
> +		{ -1,  47,  76,  6 },/* 11 */
> +		{ -1,  42,  79,  8 },/* 12 */
> +		{ -1,  36,  82, 11 },/* 13 */
> +		{ -1,  31,  84, 14 },/* 14 */
> +		{ -1,  26,  85, 18 } /* 15 */
> +	}, {	/* 104857 < Ratio <= 131072 (~8:4) */
> +		{ 26,  76,  26,  0 },/* 0 */
> +		{ 22,  76,  30,  0 },/* 1 */
> +		{ 19,  75,  34,  0 },/* 2 */
> +		{ 16,  73,  38,  1 },/* 3 */
> +		{ 13,  71,  43,  1 },/* 4 */
> +		{ 10,  69,  47,  2 },/* 5 */
> +		{  8,  66,  51,  3 },/* 6 */
> +		{  6,  63,  55,  4 },/* 7 */
> +		{  5,  59,  59,  5 },/* 8 */
> +		{  4,  55,  63,  6 },/* 9 */
> +		{  3,  51,  66,  8 },/* 10 */
> +		{  2,  47,  69, 10 },/* 11 */
> +		{  1,  43,  71, 13 },/* 12 */
> +		{  1,  38,  73, 16 },/* 13 */
> +		{  0,  34,  75, 19 },/* 14 */
> +		{  0,  30,  76, 22 } /* 15 */
> +	}, {	/* 131072 < Ratio <= 174762 (~8:3) */
> +		{ 29,  70,  29,  0 },/* 0 */
> +		{ 26,  68,  32,  2 },/* 1 */
> +		{ 23,  67,  36,  2 },/* 2 */
> +		{ 20,  66,  39,  3 },/* 3 */
> +		{ 17,  65,  43,  3 },/* 4 */
> +		{ 15,  63,  46,  4 },/* 5 */
> +		{ 12,  61,  50,  5 },/* 6 */
> +		{ 10,  58,  53,  7 },/* 7 */
> +		{  8,  56,  56,  8 },/* 8 */
> +		{  7,  53,  58, 10 },/* 9 */
> +		{  5,  50,  61, 12 },/* 10 */
> +		{  4,  46,  63, 15 },/* 11 */
> +		{  3,  43,  65, 17 },/* 12 */
> +		{  3,  39,  66, 20 },/* 13 */
> +		{  2,  36,  67, 23 },/* 14 */
> +		{  2,  32,  68, 26 } /* 15 */
> +	}, {	/* 174762 < Ratio <= 262144 (~8:2) */
> +		{ 32,  64,  32,  0 },/* 0 */
> +		{ 28,  63,  34,  3 },/* 1 */
> +		{ 25,  62,  37,  4 },/* 2 */
> +		{ 22,  62,  40,  4 },/* 3 */
> +		{ 19,  61,  43,  5 },/* 4 */
> +		{ 17,  59,  46,  6 },/* 5 */
> +		{ 15,  58,  48,  7 },/* 6 */
> +		{ 13,  55,  51,  9 },/* 7 */
> +		{ 11,  53,  53, 11 },/* 8 */
> +		{  9,  51,  55, 13 },/* 9 */
> +		{  7,  48,  58, 15 },/* 10 */
> +		{  6,  46,  59, 17 },/* 11 */
> +		{  5,  43,  61, 19 },/* 12 */
> +		{  4,  40,  62, 22 },/* 13 */
> +		{  4,  37,  62, 25 },/* 14 */
> +		{  3,  34,  63, 28 } /* 15 */
> +	}
> +};
> +
> +static int gsc_sw_reset(struct gsc_context *ctx)
> +{
> +	u32 cfg;
> +	int count = GSC_RESET_TIMEOUT;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	/* s/w reset */
> +	cfg = (GSC_SW_RESET_SRESET);
> +	gsc_write(cfg, GSC_SW_RESET);
> +
> +	/* wait s/w reset complete */
> +	while (count--) {
> +		cfg = gsc_read(GSC_SW_RESET);
> +		if (!cfg)
> +			break;
> +		usleep_range(1000, 2000);
> +	}
> +
> +	if (cfg) {
> +		DRM_ERROR("failed to reset gsc h/w.\n");
> +		return -EBUSY;
> +	}
> +
> +	/* display fifo reset */
> +	cfg = readl(SYSREG_GSCBLK_CFG0);
> +	/*
> +	 * GSCBLK Pixel asyncy FIFO S/W reset sequence
> +	 * set PXLASYNC_SW_RESET as 0 then,
> +	 * set PXLASYNC_SW_RESET as 1 again
> +	 */
> +	cfg &= ~GSC_PXLASYNC_RST(ctx->id);
> +	writel(cfg, SYSREG_GSCBLK_CFG0);
> +	cfg |= GSC_PXLASYNC_RST(ctx->id);
> +	writel(cfg, SYSREG_GSCBLK_CFG0);
> +
> +	/* pixel async reset */
> +	cfg = readl(SYSREG_DISP1BLK_CFG);
> +	/*
> +	 * DISPBLK1 FIFO S/W reset sequence
> +	 * set FIFORST_DISP1 as 0 then,
> +	 * set FIFORST_DISP1 as 1 again
> +	 */
> +	cfg &= ~FIFORST_DISP1;
> +	writel(cfg, SYSREG_DISP1BLK_CFG);
> +	cfg |= FIFORST_DISP1;
> +	writel(cfg, SYSREG_DISP1BLK_CFG);
> +
> +	/* reset sequence */
> +	cfg = gsc_read(GSC_IN_BASE_ADDR_Y_MASK);
> +	cfg |= (GSC_IN_BASE_ADDR_MASK |
> +		GSC_IN_BASE_ADDR_PINGPONG(0));
> +	gsc_write(cfg, GSC_IN_BASE_ADDR_Y_MASK);
> +	gsc_write(cfg, GSC_IN_BASE_ADDR_CB_MASK);
> +	gsc_write(cfg, GSC_IN_BASE_ADDR_CR_MASK);
> +
> +	cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
> +	cfg |= (GSC_OUT_BASE_ADDR_MASK |
> +		GSC_OUT_BASE_ADDR_PINGPONG(0));
> +	gsc_write(cfg, GSC_OUT_BASE_ADDR_Y_MASK);
> +	gsc_write(cfg, GSC_OUT_BASE_ADDR_CB_MASK);
> +	gsc_write(cfg, GSC_OUT_BASE_ADDR_CR_MASK);
> +
> +	return 0;
> +}
> +
> +static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)
> +{
> +	u32 gscblk_cfg;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	gscblk_cfg = readl(SYSREG_GSCBLK_CFG1);
> +
> +	if (enable)
> +		gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |
> +				GSC_BLK_GSCL_WB_IN_SRC_SEL(ctx->id) |
> +				GSC_BLK_SW_RESET_WB_DEST(ctx->id);
> +	else
> +		gscblk_cfg |= GSC_BLK_PXLASYNC_LO_MASK_WB(ctx->id);
> +
> +	writel(gscblk_cfg, SYSREG_GSCBLK_CFG1);
> +}
> +
> +static void gsc_handle_irq(struct gsc_context *ctx, bool enable,
> +		bool overflow, bool done)

Overflow and down argument are used to same value always in this driver. 
Is it right?

> +{
> +	u32 cfg;
> +
> +	DRM_DEBUG_KMS("%s:enable[%d]overflow[%d]level[%d]\n", __func__,
> +			enable, overflow, done);
> +
> +	cfg = gsc_read(GSC_IRQ);
> +	cfg |= (GSC_IRQ_OR_MASK | GSC_IRQ_FRMDONE_MASK);

Unnecessary initialization.

> +
> +	if (enable)
> +		cfg |= GSC_IRQ_ENABLE;
> +	else
> +		cfg &= ~GSC_IRQ_ENABLE;
> +
> +	if (overflow)
> +		cfg &= ~GSC_IRQ_OR_MASK;
> +	else
> +		cfg |= GSC_IRQ_OR_MASK;
> +
> +	if (done)
> +		cfg &= ~GSC_IRQ_FRMDONE_MASK;
> +	else
> +		cfg |= GSC_IRQ_FRMDONE_MASK;
> +
> +	gsc_write(cfg, GSC_IRQ);
> +}
> +
> +
> +static int gsc_src_set_fmt(struct device *dev, u32 fmt)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	u32 cfg;
> +
> +	DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
> +
> +	cfg = gsc_read(GSC_IN_CON);
> +	cfg &= ~(GSC_IN_RGB_TYPE_MASK | GSC_IN_YUV422_1P_ORDER_MASK |
> +		 GSC_IN_CHROMA_ORDER_MASK | GSC_IN_FORMAT_MASK |
> +		 GSC_IN_TILE_TYPE_MASK | GSC_IN_TILE_MODE |
> +		 GSC_IN_CHROM_STRIDE_SEL_MASK | GSC_IN_RB_SWAP_MASK);
> +
> +	switch (fmt) {
> +	case DRM_FORMAT_RGB565:
> +		cfg |= GSC_IN_RGB565;
> +		break;
> +	case DRM_FORMAT_XRGB8888:
> +		cfg |= GSC_IN_XRGB8888;
> +		break;
> +	case DRM_FORMAT_BGRX8888:
> +		cfg |= (GSC_IN_XRGB8888 | GSC_IN_RB_SWAP);
> +		break;
> +	case DRM_FORMAT_YUYV:
> +		cfg |= (GSC_IN_YUV422_1P |
> +			GSC_IN_YUV422_1P_ORDER_LSB_Y |
> +			GSC_IN_CHROMA_ORDER_CBCR);
> +		break;
> +	case DRM_FORMAT_YVYU:
> +		cfg |= (GSC_IN_YUV422_1P |
> +			GSC_IN_YUV422_1P_ORDER_LSB_Y |
> +			GSC_IN_CHROMA_ORDER_CRCB);
> +		break;
> +	case DRM_FORMAT_UYVY:
> +		cfg |= (GSC_IN_YUV422_1P |
> +			GSC_IN_YUV422_1P_OEDER_LSB_C |
> +			GSC_IN_CHROMA_ORDER_CBCR);
> +		break;
> +	case DRM_FORMAT_VYUY:
> +		cfg |= (GSC_IN_YUV422_1P |
> +			GSC_IN_YUV422_1P_OEDER_LSB_C |
> +			GSC_IN_CHROMA_ORDER_CRCB);
> +		break;
> +	case DRM_FORMAT_NV21:
> +	case DRM_FORMAT_NV61:
> +		cfg |= (GSC_IN_CHROMA_ORDER_CRCB |
> +			GSC_IN_YUV420_2P);
> +		break;
> +	case DRM_FORMAT_YUV422:
> +		cfg |= GSC_IN_YUV422_3P;
> +		break;
> +	case DRM_FORMAT_YUV420:
> +	case DRM_FORMAT_YVU420:
> +		cfg |= GSC_IN_YUV420_3P;
> +		break;
> +	case DRM_FORMAT_NV12:
> +	case DRM_FORMAT_NV16:
> +		cfg |= (GSC_IN_CHROMA_ORDER_CBCR |
> +			GSC_IN_YUV420_2P);
> +		break;
> +	case DRM_FORMAT_NV12MT:
> +		cfg |= (GSC_IN_TILE_C_16x8 | GSC_IN_TILE_MODE);
> +		break;
> +	default:
> +		dev_err(ippdrv->dev, "inavlid target yuv order 0x%x.\n", fmt);
> +		return -EINVAL;
> +	}
> +
> +	gsc_write(cfg, GSC_IN_CON);
> +
> +	return 0;
> +}
> +
> +static int gsc_src_set_transf(struct device *dev,
> +		enum drm_exynos_degree degree,
> +		enum drm_exynos_flip flip)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	u32 cfg;
> +
> +	DRM_DEBUG_KMS("%s:degree[%d]flip[0x%x]\n", __func__,
> +		degree, flip);
> +
> +	cfg = gsc_read(GSC_IN_CON);
> +	cfg &= ~GSC_IN_ROT_MASK;
> +
> +	switch (degree) {
> +	case EXYNOS_DRM_DEGREE_0:
> +		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
> +			cfg |= GSC_IN_ROT_XFLIP;
> +		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
> +			cfg |= GSC_IN_ROT_YFLIP;
> +		break;
> +	case EXYNOS_DRM_DEGREE_90:
> +		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
> +			cfg |= GSC_IN_ROT_90_XFLIP;
> +		else if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
> +			cfg |= GSC_IN_ROT_90_YFLIP;
> +		else
> +			cfg |= GSC_IN_ROT_90;
> +		break;
> +	case EXYNOS_DRM_DEGREE_180:
> +		cfg |= GSC_IN_ROT_180;
> +		break;
> +	case EXYNOS_DRM_DEGREE_270:
> +		cfg |= GSC_IN_ROT_270;
> +		break;
> +	default:
> +		dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
> +		return -EINVAL;
> +	}
> +
> +	gsc_write(cfg, GSC_IN_CON);
> +
> +	ctx->rotation = cfg &
> +		(GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
> +
> +	return ctx->rotation;
> +}
> +
> +static int gsc_src_set_size(struct device *dev, int swap,
> +		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct drm_exynos_pos img_pos = *pos;
> +	struct gsc_scaler *sc = &ctx->sc;
> +	u32 cfg;
> +
> +	DRM_DEBUG_KMS("%s:swap[%d]x[%d]y[%d]w[%d]h[%d]\n",
> +		__func__, swap, pos->x, pos->y, pos->w, pos->h);
> +
> +	if (swap) {
> +		img_pos.w = pos->h;
> +		img_pos.h = pos->w;
> +	}
> +
> +	/* pixel offset */
> +	cfg = (GSC_SRCIMG_OFFSET_X(img_pos.x) |
> +		GSC_SRCIMG_OFFSET_Y(img_pos.y));
> +	gsc_write(cfg, GSC_SRCIMG_OFFSET);
> +
> +	/* cropped size */
> +	cfg = (GSC_CROPPED_WIDTH(img_pos.w) |
> +		GSC_CROPPED_HEIGHT(img_pos.h));
> +	gsc_write(cfg, GSC_CROPPED_SIZE);
> +
> +	DRM_DEBUG_KMS("%s:hsize[%d]vsize[%d]\n",
> +		__func__, sz->hsize, sz->vsize);
> +
> +	/* original size */
> +	cfg = gsc_read(GSC_SRCIMG_SIZE);
> +	cfg &= ~(GSC_SRCIMG_HEIGHT_MASK |
> +		GSC_SRCIMG_WIDTH_MASK);
> +
> +	cfg |= (GSC_SRCIMG_WIDTH(sz->hsize) |
> +		GSC_SRCIMG_HEIGHT(sz->vsize));
> +
> +	gsc_write(cfg, GSC_SRCIMG_SIZE);
> +
> +	cfg = gsc_read(GSC_IN_CON);
> +	cfg &= ~GSC_IN_RGB_TYPE_MASK;
> +
> +	DRM_DEBUG_KMS("%s:width[%d]range[%d]\n",
> +		__func__, pos->w, sc->range);
> +
> +	if (pos->w >= GSC_WIDTH_ITU_709)
> +		if (sc->range)
> +			cfg |= GSC_IN_RGB_HD_WIDE;
> +		else
> +			cfg |= GSC_IN_RGB_HD_NARROW;
> +	else
> +		if (sc->range)
> +			cfg |= GSC_IN_RGB_SD_WIDE;
> +		else
> +			cfg |= GSC_IN_RGB_SD_NARROW;
> +
> +	gsc_write(cfg, GSC_IN_CON);
> +
> +	return 0;
> +}
> +
> +static int gsc_src_set_buf_seq(struct gsc_context *ctx, u32 buf_id,
> +		enum drm_exynos_ipp_buf_type buf_type)
> +{
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	bool masked;
> +	u32 cfg;
> +	u32 mask = 0x00000001 << buf_id;
> +
> +	DRM_DEBUG_KMS("%s:buf_id[%d]buf_type[%d]\n", __func__,
> +		buf_id, buf_type);
> +
> +	/* mask register set */
> +	cfg = gsc_read(GSC_IN_BASE_ADDR_Y_MASK);
> +
> +	switch (buf_type) {
> +	case IPP_BUF_ENQUEUE:
> +		masked = false;
> +		break;
> +	case IPP_BUF_DEQUEUE:
> +		masked = true;
> +		break;
> +	default:
> +		dev_err(ippdrv->dev, "invalid buf ctrl parameter.\n");
> +		return -EINVAL;
> +	}
> +
> +	/* sequence id */
> +	cfg &= (~mask);

Unnecessary parenthesis.

> +	cfg |= masked << buf_id;
> +	gsc_write(cfg, GSC_IN_BASE_ADDR_Y_MASK);
> +	gsc_write(cfg, GSC_IN_BASE_ADDR_CB_MASK);
> +	gsc_write(cfg, GSC_IN_BASE_ADDR_CR_MASK);
> +
> +	return 0;
> +}
> +
> +static int gsc_src_set_addr(struct device *dev,
> +		struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
> +		enum drm_exynos_ipp_buf_type buf_type)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
> +	struct drm_exynos_ipp_property *property;
> +
> +	if (!c_node) {
> +		DRM_ERROR("failed to get c_node.\n");
> +		return -EINVAL;

-EFAULT

> +	}
> +
> +	property = &c_node->property;
> +	if (!property) {
> +		DRM_ERROR("failed to get property.\n");
> +		return -EINVAL;

-EFAULT

> +	}
> +
> +	DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
> +		property->prop_id, buf_id, buf_type);
> +
> +	if (buf_id > GSC_MAX_SRC) {
> +		dev_info(ippdrv->dev, "inavlid buf_id %d.\n", buf_id);
> +		return -ENOMEM;

-EINVAL

> +	}
> +
> +	/* address register set */
> +	switch (buf_type) {
> +	case IPP_BUF_ENQUEUE:
> +		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
> +			GSC_IN_BASE_ADDR_Y(buf_id));
> +		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
> +			GSC_IN_BASE_ADDR_CB(buf_id));
> +		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
> +			GSC_IN_BASE_ADDR_CR(buf_id));
> +		break;
> +	case IPP_BUF_DEQUEUE:
> +		gsc_write(0x0, GSC_IN_BASE_ADDR_Y(buf_id));
> +		gsc_write(0x0, GSC_IN_BASE_ADDR_CB(buf_id));
> +		gsc_write(0x0, GSC_IN_BASE_ADDR_CR(buf_id));
> +		break;
> +	default:
> +		/* bypass */
> +		break;
> +	}
> +
> +	return gsc_src_set_buf_seq(ctx, buf_id, buf_type);
> +}
> +
> +static struct exynos_drm_ipp_ops gsc_src_ops = {
> +	.set_fmt = gsc_src_set_fmt,
> +	.set_transf = gsc_src_set_transf,
> +	.set_size = gsc_src_set_size,
> +	.set_addr = gsc_src_set_addr,
> +};
> +
> +static int gsc_dst_set_fmt(struct device *dev, u32 fmt)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	u32 cfg;
> +
> +	DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
> +
> +	cfg = gsc_read(GSC_OUT_CON);
> +	cfg &= ~(GSC_OUT_RGB_TYPE_MASK | GSC_OUT_YUV422_1P_ORDER_MASK |
> +		 GSC_OUT_CHROMA_ORDER_MASK | GSC_OUT_FORMAT_MASK |
> +		 GSC_OUT_CHROM_STRIDE_SEL_MASK | GSC_OUT_RB_SWAP_MASK |
> +		 GSC_OUT_GLOBAL_ALPHA_MASK);
> +
> +	switch (fmt) {
> +	case DRM_FORMAT_RGB565:
> +		cfg |= GSC_OUT_RGB565;
> +		break;
> +	case DRM_FORMAT_XRGB8888:
> +		cfg |= GSC_OUT_XRGB8888;
> +		break;
> +	case DRM_FORMAT_BGRX8888:
> +		cfg |= (GSC_OUT_XRGB8888 | GSC_OUT_RB_SWAP);
> +		break;
> +	case DRM_FORMAT_YUYV:
> +		cfg |= (GSC_OUT_YUV422_1P |
> +			GSC_OUT_YUV422_1P_ORDER_LSB_Y |
> +			GSC_OUT_CHROMA_ORDER_CBCR);
> +		break;
> +	case DRM_FORMAT_YVYU:
> +		cfg |= (GSC_OUT_YUV422_1P |
> +			GSC_OUT_YUV422_1P_ORDER_LSB_Y |
> +			GSC_OUT_CHROMA_ORDER_CRCB);
> +		break;
> +	case DRM_FORMAT_UYVY:
> +		cfg |= (GSC_OUT_YUV422_1P |
> +			GSC_OUT_YUV422_1P_OEDER_LSB_C |
> +			GSC_OUT_CHROMA_ORDER_CBCR);
> +		break;
> +	case DRM_FORMAT_VYUY:
> +		cfg |= (GSC_OUT_YUV422_1P |
> +			GSC_OUT_YUV422_1P_OEDER_LSB_C |
> +			GSC_OUT_CHROMA_ORDER_CRCB);
> +		break;
> +	case DRM_FORMAT_NV21:
> +	case DRM_FORMAT_NV61:
> +		cfg |= (GSC_OUT_CHROMA_ORDER_CRCB |
> +			GSC_OUT_YUV420_2P);

Please check to join to one line overall. This line can be in 80 character.

> +		break;
> +	case DRM_FORMAT_YUV422:
> +	case DRM_FORMAT_YUV420:
> +	case DRM_FORMAT_YVU420:
> +		cfg |= GSC_OUT_YUV420_3P;
> +		break;
> +	case DRM_FORMAT_NV12:
> +	case DRM_FORMAT_NV16:
> +		cfg |= (GSC_OUT_CHROMA_ORDER_CBCR |
> +			GSC_OUT_YUV420_2P);
> +		break;
> +	case DRM_FORMAT_NV12MT:
> +		cfg |= (GSC_OUT_TILE_C_16x8 | GSC_OUT_TILE_MODE);
> +		break;
> +	default:
> +		dev_err(ippdrv->dev, "inavlid target yuv order 0x%x.\n", fmt);
> +		return -EINVAL;
> +	}
> +
> +	gsc_write(cfg, GSC_OUT_CON);
> +
> +	return 0;
> +}
> +
> +static int gsc_dst_set_transf(struct device *dev,
> +		enum drm_exynos_degree degree,
> +		enum drm_exynos_flip flip)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	u32 cfg;
> +
> +	DRM_DEBUG_KMS("%s:degree[%d]flip[0x%x]\n", __func__,
> +		degree, flip);
> +
> +	cfg = gsc_read(GSC_IN_CON);
> +	cfg &= ~GSC_IN_ROT_MASK;
> +
> +	switch (degree) {
> +	case EXYNOS_DRM_DEGREE_0:
> +		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
> +			cfg |= GSC_IN_ROT_XFLIP;
> +		if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
> +			cfg |= GSC_IN_ROT_YFLIP;
> +		break;
> +	case EXYNOS_DRM_DEGREE_90:
> +		if (flip & EXYNOS_DRM_FLIP_VERTICAL)
> +			cfg |= GSC_IN_ROT_90_XFLIP;
> +		else if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
> +			cfg |= GSC_IN_ROT_90_YFLIP;
> +		else
> +			cfg |= GSC_IN_ROT_90;
> +		break;
> +	case EXYNOS_DRM_DEGREE_180:
> +		cfg |= GSC_IN_ROT_180;
> +		break;
> +	case EXYNOS_DRM_DEGREE_270:
> +		cfg |= GSC_IN_ROT_270;
> +		break;
> +	default:
> +		dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
> +		return -EINVAL;
> +	}
> +
> +	gsc_write(cfg, GSC_IN_CON);
> +
> +	ctx->rotation = cfg &
> +		(GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
> +
> +	return ctx->rotation;
> +}
> +
> +static int gsc_get_ratio_shift(u32 src, u32 dst, u32 *ratio)
> +{
> +	DRM_DEBUG_KMS("%s:src[%d]dst[%d]\n", __func__, src, dst);
> +
> +	if (src >= dst * 8) {
> +		DRM_ERROR("failed to make ratio and shift.\n");
> +		return -EINVAL;
> +	} else if (src >= dst * 4)
> +		*ratio = 4;
> +	else if (src >= dst * 2)
> +		*ratio = 2;
> +	else
> +		*ratio = 1;
> +
> +	return 0;
> +}
> +
> +static void gsc_get_prescaler_shfactor(u32 hratio, u32 vratio, u32 *shfactor)
> +{
> +	if (hratio == 4 && vratio == 4)
> +		*shfactor = 4;
> +	else if ((hratio == 4 && vratio == 2) ||
> +		 (hratio == 2 && vratio == 4))
> +		*shfactor = 3;
> +	else if ((hratio == 4 && vratio == 1) ||
> +		 (hratio == 1 && vratio == 4) ||
> +		 (hratio == 2 && vratio == 2))
> +		*shfactor = 2;
> +	else if (hratio == 1 && vratio == 1)
> +		*shfactor = 0;
> +	else
> +		*shfactor = 1;
> +}
> +
> +static int gsc_set_prescaler(struct gsc_context *ctx, struct gsc_scaler *sc,
> +		struct drm_exynos_pos *src, struct drm_exynos_pos *dst)
> +{
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	u32 cfg;
> +	u32 src_w, src_h, dst_w, dst_h;
> +	int ret = 0;
> +
> +	src_w = src->w;
> +	src_h = src->h;
> +
> +	if (ctx->rotation) {
> +		dst_w = dst->h;
> +		dst_h = dst->w;
> +	} else {
> +		dst_w = dst->w;
> +		dst_h = dst->h;
> +	}
> +
> +	ret = gsc_get_ratio_shift(src_w, dst_w, &sc->pre_hratio);
> +	if (ret) {
> +		dev_err(ippdrv->dev, "failed to get ratio horizontal.\n");
> +		return ret;
> +	}
> +
> +	ret = gsc_get_ratio_shift(src_h, dst_h, &sc->pre_vratio);
> +	if (ret) {
> +		dev_err(ippdrv->dev, "failed to get ratio vertical.\n");
> +		return ret;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:pre_hratio[%d]pre_vratio[%d]\n",
> +		__func__, sc->pre_hratio, sc->pre_vratio);
> +
> +	sc->main_hratio = (src_w << 16) / dst_w;
> +	sc->main_vratio = (src_h << 16) / dst_h;
> +
> +	DRM_DEBUG_KMS("%s:main_hratio[%ld]main_vratio[%ld]\n",
> +		__func__, sc->main_hratio, sc->main_vratio);
> +
> +	gsc_get_prescaler_shfactor(sc->pre_hratio, sc->pre_vratio,
> +		&sc->pre_shfactor);
> +
> +	DRM_DEBUG_KMS("%s:pre_shfactor[%d]\n", __func__,
> +		sc->pre_shfactor);
> +
> +	cfg = (GSC_PRESC_SHFACTOR(sc->pre_shfactor) |
> +		GSC_PRESC_H_RATIO(sc->pre_hratio) |
> +		GSC_PRESC_V_RATIO(sc->pre_vratio));
> +	gsc_write(cfg, GSC_PRE_SCALE_RATIO);
> +
> +	return ret;
> +}
> +
> +static void gsc_set_h_coef(struct gsc_context *ctx, unsigned long main_hratio)
> +{
> +	int i, j, k, sc_ratio;
> +
> +	if (main_hratio <= GSC_SC_UP_MAX_RATIO)
> +		sc_ratio = 0;
> +	else if (main_hratio <= GSC_SC_DOWN_RATIO_7_8)
> +		sc_ratio = 1;
> +	else if (main_hratio <= GSC_SC_DOWN_RATIO_6_8)
> +		sc_ratio = 2;
> +	else if (main_hratio <= GSC_SC_DOWN_RATIO_5_8)
> +		sc_ratio = 3;
> +	else if (main_hratio <= GSC_SC_DOWN_RATIO_4_8)
> +		sc_ratio = 4;
> +	else if (main_hratio <= GSC_SC_DOWN_RATIO_3_8)
> +		sc_ratio = 5;
> +	else
> +		sc_ratio = 6;
> +
> +	for (i = 0; i < 9; i++)
> +		for (j = 0; j < 8; j++)
> +			for (k = 0; k < 3; k++)
> +				gsc_write(h_coef_8t[sc_ratio][i][j],
> +					GSC_HCOEF(i, j, k));

Please define constants to macro or get array size.

> +}
> +
> +static void gsc_set_v_coef(struct gsc_context *ctx, unsigned long main_vratio)
> +{
> +	int i, j, k, sc_ratio = 0;

Unnecessary initialization.

> +
> +	if (main_vratio <= GSC_SC_UP_MAX_RATIO)
> +		sc_ratio = 0;
> +	else if (main_vratio <= GSC_SC_DOWN_RATIO_7_8)
> +		sc_ratio = 1;
> +	else if (main_vratio <= GSC_SC_DOWN_RATIO_6_8)
> +		sc_ratio = 2;
> +	else if (main_vratio <= GSC_SC_DOWN_RATIO_5_8)
> +		sc_ratio = 3;
> +	else if (main_vratio <= GSC_SC_DOWN_RATIO_4_8)
> +		sc_ratio = 4;
> +	else if (main_vratio <= GSC_SC_DOWN_RATIO_3_8)
> +		sc_ratio = 5;
> +	else
> +		sc_ratio = 6;
> +
> +	for (i = 0; i < 9; i++)
> +		for (j = 0; j < 4; j++)
> +			for (k = 0; k < 3; k++)
> +				gsc_write(v_coef_4t[sc_ratio][i][j],
> +					GSC_VCOEF(i, j, k));
> +}
> +
> +static void gsc_set_scaler(struct gsc_context *ctx, struct gsc_scaler *sc)
> +{
> +	u32 cfg;
> +
> +	DRM_DEBUG_KMS("%s:main_hratio[%ld]main_vratio[%ld]\n",
> +		__func__, sc->main_hratio, sc->main_vratio);
> +
> +	gsc_set_h_coef(ctx, sc->main_hratio);
> +	cfg = GSC_MAIN_H_RATIO_VALUE(sc->main_hratio);
> +	gsc_write(cfg, GSC_MAIN_H_RATIO);
> +
> +	gsc_set_v_coef(ctx, sc->main_vratio);
> +	cfg = GSC_MAIN_V_RATIO_VALUE(sc->main_vratio);
> +	gsc_write(cfg, GSC_MAIN_V_RATIO);
> +}
> +
> +static int gsc_dst_set_size(struct device *dev, int swap,
> +		struct drm_exynos_pos *pos, struct drm_exynos_sz *sz)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct drm_exynos_pos img_pos = *pos;
> +	struct gsc_scaler *sc = &ctx->sc;
> +	u32 cfg;
> +
> +	DRM_DEBUG_KMS("%s:swap[%d]x[%d]y[%d]w[%d]h[%d]\n",
> +		__func__, swap, pos->x, pos->y, pos->w, pos->h);
> +
> +	if (swap) {
> +		img_pos.w = pos->h;
> +		img_pos.h = pos->w;
> +	}
> +
> +	/* pixel offset */
> +	cfg = (GSC_DSTIMG_OFFSET_X(pos->x) |
> +		GSC_DSTIMG_OFFSET_Y(pos->y));
> +	gsc_write(cfg, GSC_DSTIMG_OFFSET);
> +
> +	/* scaled size */
> +	cfg = (GSC_SCALED_WIDTH(img_pos.w) | GSC_SCALED_HEIGHT(img_pos.h));
> +	gsc_write(cfg, GSC_SCALED_SIZE);
> +
> +	DRM_DEBUG_KMS("%s:hsize[%d]vsize[%d]\n",
> +		__func__, sz->hsize, sz->vsize);
> +
> +	/* original size */
> +	cfg = gsc_read(GSC_DSTIMG_SIZE);
> +	cfg &= ~(GSC_DSTIMG_HEIGHT_MASK |
> +		GSC_DSTIMG_WIDTH_MASK);
> +	cfg |= (GSC_DSTIMG_WIDTH(sz->hsize) |
> +		GSC_DSTIMG_HEIGHT(sz->vsize));
> +	gsc_write(cfg, GSC_DSTIMG_SIZE);
> +
> +	cfg = gsc_read(GSC_OUT_CON);
> +	cfg &= ~GSC_OUT_RGB_TYPE_MASK;
> +
> +	DRM_DEBUG_KMS("%s:width[%d]range[%d]\n",
> +		__func__, pos->w, sc->range);
> +
> +	if (pos->w >= GSC_WIDTH_ITU_709)
> +		if (sc->range)
> +			cfg |= GSC_OUT_RGB_HD_WIDE;
> +		else
> +			cfg |= GSC_OUT_RGB_HD_NARROW;
> +	else
> +		if (sc->range)
> +			cfg |= GSC_OUT_RGB_SD_WIDE;
> +		else
> +			cfg |= GSC_OUT_RGB_SD_NARROW;
> +
> +	gsc_write(cfg, GSC_OUT_CON);
> +
> +	return 0;
> +}
> +
> +static int gsc_dst_get_buf_seq(struct gsc_context *ctx)
> +{
> +	u32 cfg, i, buf_num = GSC_REG_SZ;
> +	u32 mask = 0x00000001;
> +
> +	cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
> +
> +	for (i = 0; i < GSC_REG_SZ; i++)
> +		if (cfg & (mask << i))
> +			buf_num--;
> +
> +	DRM_DEBUG_KMS("%s:buf_num[%d]\n", __func__, buf_num);
> +
> +	return buf_num;
> +}
> +
> +static int gsc_dst_set_buf_seq(struct gsc_context *ctx, u32 buf_id,
> +		enum drm_exynos_ipp_buf_type buf_type)
> +{
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	bool masked;
> +	u32 cfg;
> +	u32 mask = 0x00000001 << buf_id;
> +	int ret = 0;
> +
> +	DRM_DEBUG_KMS("%s:buf_id[%d]buf_type[%d]\n", __func__,
> +		buf_id, buf_type);
> +
> +	mutex_lock(&ctx->lock);
> +
> +	/* mask register set */
> +	cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
> +
> +	switch (buf_type) {
> +	case IPP_BUF_ENQUEUE:
> +		masked = false;
> +		break;
> +	case IPP_BUF_DEQUEUE:
> +		masked = true;
> +		break;
> +	default:
> +		dev_err(ippdrv->dev, "invalid buf ctrl parameter.\n");
> +		ret =  -EINVAL;
> +		goto err_unlock;
> +	}
> +
> +	/* sequence id */
> +	cfg &= (~mask);

Unnecessary parenthesis.

> +	cfg |= masked << buf_id;
> +	gsc_write(cfg, GSC_OUT_BASE_ADDR_Y_MASK);
> +	gsc_write(cfg, GSC_OUT_BASE_ADDR_CB_MASK);
> +	gsc_write(cfg, GSC_OUT_BASE_ADDR_CR_MASK);
> +
> +	/* interrupt enable */
> +	if (buf_type == IPP_BUF_ENQUEUE &&
> +	    gsc_dst_get_buf_seq(ctx) >= GSC_BUF_START)
> +		gsc_handle_irq(ctx, true, false, true);
> +
> +	/* interrupt disable */
> +	if (buf_type == IPP_BUF_DEQUEUE &&
> +	    gsc_dst_get_buf_seq(ctx) <= GSC_BUF_STOP)
> +		gsc_handle_irq(ctx, false, false, true);
> +
> +err_unlock:
> +	mutex_unlock(&ctx->lock);
> +	return ret;
> +}
> +
> +static int gsc_dst_set_addr(struct device *dev,
> +		struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
> +		enum drm_exynos_ipp_buf_type buf_type)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
> +	struct drm_exynos_ipp_property *property;
> +
> +	if (!c_node) {
> +		DRM_ERROR("failed to get c_node.\n");
> +		return -EINVAL;

-EFAULT

> +	}
> +
> +	property = &c_node->property;
> +	if (!property) {
> +		DRM_ERROR("failed to get property.\n");
> +		return -EINVAL;

-EFAULT

> +	}
> +
> +	DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
> +		property->prop_id, buf_id, buf_type);
> +
> +	if (buf_id > GSC_MAX_DST) {
> +		dev_info(ippdrv->dev, "inavlid buf_id %d.\n", buf_id);
> +		return -ENOMEM;

-EINVAL

> +	}
> +
> +	/* address register set */
> +	switch (buf_type) {
> +	case IPP_BUF_ENQUEUE:
> +		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
> +			GSC_OUT_BASE_ADDR_Y(buf_id));
> +		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
> +			GSC_OUT_BASE_ADDR_CB(buf_id));
> +		gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
> +			GSC_OUT_BASE_ADDR_CR(buf_id));
> +		break;
> +	case IPP_BUF_DEQUEUE:
> +		gsc_write(0x0, GSC_OUT_BASE_ADDR_Y(buf_id));
> +		gsc_write(0x0, GSC_OUT_BASE_ADDR_CB(buf_id));
> +		gsc_write(0x0, GSC_OUT_BASE_ADDR_CR(buf_id));
> +		break;
> +	default:
> +		/* bypass */
> +		break;
> +	}
> +
> +	return gsc_dst_set_buf_seq(ctx, buf_id, buf_type);
> +}
> +
> +static struct exynos_drm_ipp_ops gsc_dst_ops = {
> +	.set_fmt = gsc_dst_set_fmt,
> +	.set_transf = gsc_dst_set_transf,
> +	.set_size = gsc_dst_set_size,
> +	.set_addr = gsc_dst_set_addr,
> +};
> +
> +static int gsc_clk_ctrl(struct gsc_context *ctx, bool enable)
> +{
> +	DRM_INFO("%s:enable[%d]\n", __func__, enable);

DRM_DEBUG_KMS?

> +
> +	if (enable) {
> +		clk_set_parent(ctx->child_clk, ctx->parent_clk);

I think this is enough only to one operation.

> +		clk_enable(ctx->gsc_clk);
> +		ctx->suspended = false;
> +	} else {
> +		clk_disable(ctx->gsc_clk);
> +		ctx->suspended = true;
> +	}
> +
> +	return 0;
> +}
> +
> +static int gsc_get_src_buf_index(struct gsc_context *ctx)
> +{
> +	u32 cfg, curr_index, i;
> +	u32 buf_id = GSC_MAX_SRC;
> +
> +	DRM_DEBUG_KMS("%s:gsc id[%d]\n", __func__, ctx->id);
> +
> +	cfg = gsc_read(GSC_IN_BASE_ADDR_Y_MASK);
> +	curr_index = GSC_IN_CURR_GET_INDEX(cfg);
> +
> +	for (i = curr_index; i < GSC_MAX_SRC; i++) {
> +		if (!((cfg >> i) & 0x1)) {
> +			buf_id = i;
> +			break;
> +		}
> +	}
> +
> +	if (buf_id == GSC_MAX_SRC) {
> +		DRM_ERROR("failed to get in buffer index.\n");
> +		return -EIO;

Is this IO error?

> +	}
> +
> +	if (gsc_src_set_buf_seq(ctx, buf_id, IPP_BUF_DEQUEUE) < 0) {
> +		DRM_ERROR("failed to dequeue.\n");
> +		return IRQ_HANDLED;

Is IRQ_HANDLED right return value?

> +	}
> +
> +	DRM_DEBUG_KMS("%s:cfg[0x%x]curr_index[%d]buf_id[%d]\n", __func__, cfg,
> +		curr_index, buf_id);
> +
> +	return buf_id;
> +}
> +
> +static int gsc_get_dst_buf_index(struct gsc_context *ctx)
> +{
> +	u32 cfg, curr_index, i;
> +	u32 buf_id = GSC_MAX_DST;
> +
> +	DRM_DEBUG_KMS("%s:gsc id[%d]\n", __func__, ctx->id);
> +
> +	cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
> +	curr_index = GSC_OUT_CURR_GET_INDEX(cfg);
> +
> +	for (i = curr_index; i < GSC_MAX_DST; i++) {
> +		if (!((cfg >> i) & 0x1)) {
> +			buf_id = i;
> +			break;
> +		}
> +	}
> +
> +	if (buf_id == GSC_MAX_DST) {
> +		DRM_ERROR("failed to get out buffer index.\n");
> +		return -EIO;

Is this IO error?

> +	}
> +
> +	if (gsc_dst_set_buf_seq(ctx, buf_id, IPP_BUF_DEQUEUE) < 0) {
> +		DRM_ERROR("failed to dequeue.\n");
> +		return IRQ_HANDLED;

Is IRQ_HANDLED right return value?

> +	}
> +
> +	DRM_DEBUG_KMS("%s:cfg[0x%x]curr_index[%d]buf_id[%d]\n", __func__, cfg,
> +		curr_index, buf_id);
> +
> +	return buf_id;
> +}
> +
> +static irqreturn_t gsc_irq_handler(int irq, void *dev_id)
> +{
> +	struct gsc_context *ctx = dev_id;
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
> +	struct drm_exynos_ipp_event_work *event_work =
> +		c_node->event_work;
> +	u32 status;
> +	int buf_id[EXYNOS_DRM_OPS_MAX];
> +
> +	DRM_DEBUG_KMS("%s:gsc id[%d]\n", __func__, ctx->id);
> +
> +	status = gsc_read(GSC_IRQ);
> +	if (status & GSC_IRQ_STATUS_OR_IRQ) {
> +		dev_err(ippdrv->dev, "occured overflow at %d, status 0x%x.\n",
> +			ctx->id, status);
> +		return IRQ_NONE;
> +	}
> +
> +	if (status & GSC_IRQ_STATUS_OR_FRM_DONE) {
> +		dev_dbg(ippdrv->dev, "occured frame done at %d, status 0x%x.\n",
> +			ctx->id, status);
> +
> +		buf_id[EXYNOS_DRM_OPS_SRC] = gsc_get_src_buf_index(ctx);
> +		if (buf_id[EXYNOS_DRM_OPS_SRC] < 0)
> +			return IRQ_HANDLED;
> +
> +		buf_id[EXYNOS_DRM_OPS_DST] = gsc_get_dst_buf_index(ctx);
> +		if (buf_id[EXYNOS_DRM_OPS_DST] < 0)
> +			return IRQ_HANDLED;
> +
> +		DRM_DEBUG_KMS("%s:buf_id_src[%d]buf_id_dst[%d]\n", __func__,
> +			buf_id[EXYNOS_DRM_OPS_SRC], buf_id[EXYNOS_DRM_OPS_DST]);
> +
> +		event_work->ippdrv = ippdrv;
> +		event_work->buf_id[EXYNOS_DRM_OPS_SRC] =
> +			buf_id[EXYNOS_DRM_OPS_SRC];
> +		event_work->buf_id[EXYNOS_DRM_OPS_DST] =
> +			buf_id[EXYNOS_DRM_OPS_DST];
> +		queue_work(ippdrv->event_workq,
> +			(struct work_struct *)event_work);
> +	}
> +
> +	return IRQ_HANDLED;
> +}
> +
> +static int gsc_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
> +{
> +	struct drm_exynos_ipp_prop_list *prop_list;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
> +	if (!prop_list) {
> +		DRM_ERROR("failed to alloc property list.\n");
> +		return -ENOMEM;
> +	}
> +
> +	/*ToDo : fix supported function list*/

Please remove comments.

> +
> +	prop_list->version = 1;
> +	prop_list->writeback = 1;
> +	prop_list->refresh_min = GSC_REFRESH_MIN;
> +	prop_list->refresh_max = GSC_REFRESH_MAX;
> +	prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
> +				(1 << EXYNOS_DRM_FLIP_HORIZONTAL);
> +	prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
> +				(1 << EXYNOS_DRM_DEGREE_90) |
> +				(1 << EXYNOS_DRM_DEGREE_180) |
> +				(1 << EXYNOS_DRM_DEGREE_270);
> +	prop_list->csc = 1;
> +	prop_list->crop = 1;
> +	prop_list->crop_max.hsize = GSC_CROP_MAX;
> +	prop_list->crop_max.vsize = GSC_CROP_MAX;
> +	prop_list->crop_min.hsize = GSC_CROP_MIN;
> +	prop_list->crop_min.vsize = GSC_CROP_MIN;
> +	prop_list->scale = 1;

Hardcode. There are too much flags in prop_list and they are just 1 bit 
on/off flags,
so i think you can join them to one variable.

> +	prop_list->scale_max.hsize = GSC_SCALE_MAX;
> +	prop_list->scale_max.vsize = GSC_SCALE_MAX;
> +	prop_list->scale_min.hsize = GSC_SCALE_MIN;
> +	prop_list->scale_min.vsize = GSC_SCALE_MIN;
> +
> +	ippdrv->prop_list = prop_list;
> +
> +	return 0;
> +}
> +
> +static int gsc_ippdrv_check_property(struct device *dev,
> +		struct drm_exynos_ipp_property *property)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	struct drm_exynos_ipp_prop_list *pp = ippdrv->prop_list;
> +	struct drm_exynos_ipp_config *config;
> +	struct drm_exynos_pos *pos;
> +	struct drm_exynos_sz *sz;
> +	bool swap;
> +	int i;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	for_each_ipp_ops(i) {
> +		if ((i == EXYNOS_DRM_OPS_SRC) &&
> +			(property->cmd == IPP_CMD_WB))
> +			continue;
> +
> +		config = &property->config[i];
> +		pos = &config->pos;
> +		sz = &config->sz;
> +
> +		/* check for flip */
> +		switch (config->flip) {
> +		case EXYNOS_DRM_FLIP_NONE:
> +		case EXYNOS_DRM_FLIP_VERTICAL:
> +		case EXYNOS_DRM_FLIP_HORIZONTAL:
> +		case EXYNOS_DRM_FLIP_VERTICAL | EXYNOS_DRM_FLIP_HORIZONTAL:
> +			/* No problem */
> +			break;
> +		default:
> +			DRM_ERROR("invalid flip.\n");
> +			goto err_property;
> +		}
> +
> +		/* check for degree */
> +		switch (config->degree) {
> +		case EXYNOS_DRM_DEGREE_90:
> +		case EXYNOS_DRM_DEGREE_270:
> +			swap = true;
> +			break;
> +		case EXYNOS_DRM_DEGREE_0:
> +		case EXYNOS_DRM_DEGREE_180:
> +			swap = false;
> +			break;
> +		default:
> +			DRM_ERROR("invalid degree.\n");
> +			goto err_property;
> +		}
> +
> +		/* check for buffer bound */
> +		if ((pos->x + pos->w > sz->hsize) ||
> +			(pos->y + pos->h > sz->vsize)) {
> +			DRM_ERROR("out of buf bound.\n");
> +			goto err_property;
> +		}
> +
> +		/* check for crop */
> +		if ((i == EXYNOS_DRM_OPS_SRC) && (pp->crop)) {
> +			if (swap) {
> +				if ((pos->h < pp->crop_min.hsize) ||
> +					(sz->vsize > pp->crop_max.hsize) ||
> +					(pos->w < pp->crop_min.vsize) ||
> +					(sz->hsize > pp->crop_max.vsize)) {
> +					DRM_ERROR("out of crop size.\n");
> +					goto err_property;
> +				}
> +			} else {
> +				if ((pos->w < pp->crop_min.hsize) ||
> +					(sz->hsize > pp->crop_max.hsize) ||
> +					(pos->h < pp->crop_min.vsize) ||
> +					(sz->vsize > pp->crop_max.vsize)) {
> +					DRM_ERROR("out of crop size.\n");
> +					goto err_property;
> +				}
> +			}
> +		}
> +
> +		/* check for scale */
> +		if ((i == EXYNOS_DRM_OPS_DST) && (pp->scale)) {
> +			if (swap) {
> +				if ((pos->h < pp->scale_min.hsize) ||
> +					(sz->vsize > pp->scale_max.hsize) ||
> +					(pos->w < pp->scale_min.vsize) ||
> +					(sz->hsize > pp->scale_max.vsize)) {
> +					DRM_ERROR("out of scale size.\n");
> +					goto err_property;
> +				}
> +			} else {
> +				if ((pos->w < pp->scale_min.hsize) ||
> +					(sz->hsize > pp->scale_max.hsize) ||
> +					(pos->h < pp->scale_min.vsize) ||
> +					(sz->vsize > pp->scale_max.vsize)) {
> +					DRM_ERROR("out of scale size.\n");
> +					goto err_property;
> +				}
> +			}
> +		}
> +	}
> +
> +	return 0;
> +
> +err_property:
> +	for_each_ipp_ops(i) {
> +		if ((i == EXYNOS_DRM_OPS_SRC) &&
> +			(property->cmd == IPP_CMD_WB))
> +			continue;
> +
> +		config = &property->config[i];
> +		pos = &config->pos;
> +		sz = &config->sz;
> +
> +		DRM_ERROR("[%s]f[%d]r[%d]pos[%d %d %d %d]sz[%d %d]\n",
> +			i ? "dst" : "src", config->flip, config->degree,
> +			pos->x, pos->y, pos->w, pos->h,
> +			sz->hsize, sz->vsize);
> +	}
> +
> +	return -EINVAL;
> +}
> +
> +
> +static int gsc_ippdrv_reset(struct device *dev)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct gsc_scaler *sc = &ctx->sc;
> +	int ret;
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	/* reset h/w block */
> +	ret = gsc_sw_reset(ctx);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to reset hardware.\n");
> +		return ret;
> +	}
> +
> +	/* scaler setting */
> +	memset(&ctx->sc, 0x0, sizeof(ctx->sc));
> +	sc->range = true;
> +
> +	return 0;
> +}
> +
> +static int gsc_check_prepare(struct gsc_context *ctx)
> +{
> +	/* ToDo: check prepare using read register */
> +
> +	DRM_DEBUG_KMS("%s\n", __func__);
> +
> +	return 0;
> +}

I read your comments but i can't understand why this dummy function 
needs still.
Please remove and if implement it later, send additional patch.

> +
> +static int gsc_ippdrv_start(struct device *dev, enum drm_exynos_ipp_cmd cmd)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +	struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
> +	struct drm_exynos_ipp_property *property;
> +	struct drm_exynos_ipp_config *config;
> +	struct drm_exynos_pos	img_pos[EXYNOS_DRM_OPS_MAX];
> +	struct drm_exynos_ipp_set_wb set_wb;
> +	u32 cfg;
> +	int ret, i;
> +
> +	DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, cmd);
> +
> +	if (!c_node) {
> +		DRM_ERROR("failed to get c_node.\n");
> +		return -EINVAL;
> +	}
> +
> +	property = &c_node->property;
> +	if (!property) {
> +		DRM_ERROR("failed to get property.\n");
> +		return -EINVAL;
> +	}
> +
> +	ret = gsc_check_prepare(ctx);
> +	if (ret) {
> +		dev_err(dev, "failed to check prepare.\n");
> +		return ret;
> +	}

Please remove.

> +
> +	gsc_handle_irq(ctx, true, false, true);
> +
> +	/* ToDo: window size, prescaler config */

Please remove comment.

> +	for_each_ipp_ops(i) {
> +		config = &property->config[i];
> +		img_pos[i] = config->pos;
> +	}
> +
> +	switch (cmd) {
> +	case IPP_CMD_M2M:
> +		/* enable one shot */
> +		cfg = gsc_read(GSC_ENABLE);
> +		cfg &= ~(GSC_ENABLE_ON_CLEAR_MASK |
> +			GSC_ENABLE_CLK_GATE_MODE_MASK);
> +		cfg |= GSC_ENABLE_ON_CLEAR_ONESHOT;
> +		gsc_write(cfg, GSC_ENABLE);
> +
> +		/* src dma memory */
> +		cfg = gsc_read(GSC_IN_CON);
> +		cfg &= ~(GSC_IN_PATH_MASK | GSC_IN_LOCAL_SEL_MASK);
> +		cfg |= GSC_IN_PATH_MEMORY;
> +		gsc_write(cfg, GSC_IN_CON);
> +
> +		/* dst dma memory */
> +		cfg = gsc_read(GSC_OUT_CON);
> +		cfg |= GSC_OUT_PATH_MEMORY;
> +		gsc_write(cfg, GSC_OUT_CON);
> +		break;
> +	case IPP_CMD_WB:
> +		/* ToDo: need to replace the property structure. */
> +		set_wb.enable = 1;
> +		set_wb.refresh = property->refresh_rate;
> +		gsc_set_gscblk_fimd_wb(ctx, set_wb.enable);
> +		exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb);
> +
> +		/* src local path */
> +		cfg = readl(GSC_IN_CON);
> +		cfg &= ~(GSC_IN_PATH_MASK | GSC_IN_LOCAL_SEL_MASK);
> +		cfg |= (GSC_IN_PATH_LOCAL | GSC_IN_LOCAL_FIMD_WB);
> +		gsc_write(cfg, GSC_IN_CON);
> +
> +		/* dst dma memory */
> +		cfg = gsc_read(GSC_OUT_CON);
> +		cfg |= GSC_OUT_PATH_MEMORY;
> +		gsc_write(cfg, GSC_OUT_CON);
> +		break;
> +	case IPP_CMD_OUTPUT:
> +		/* src dma memory */
> +		cfg = gsc_read(GSC_IN_CON);
> +		cfg &= ~(GSC_IN_PATH_MASK | GSC_IN_LOCAL_SEL_MASK);
> +		cfg |= GSC_IN_PATH_MEMORY;
> +		gsc_write(cfg, GSC_IN_CON);
> +
> +		/* dst local path */
> +		cfg = gsc_read(GSC_OUT_CON);
> +		cfg |= GSC_OUT_PATH_MEMORY;
> +		gsc_write(cfg, GSC_OUT_CON);
> +		break;
> +	default:
> +		ret = -EINVAL;
> +		dev_err(dev, "invalid operations.\n");
> +		return ret;
> +	}
> +
> +	ret = gsc_set_prescaler(ctx, &ctx->sc,
> +		&img_pos[EXYNOS_DRM_OPS_SRC],
> +		&img_pos[EXYNOS_DRM_OPS_DST]);
> +	if (ret) {
> +		dev_err(dev, "failed to set precalser.\n");
> +		return ret;
> +	}
> +
> +	gsc_set_scaler(ctx, &ctx->sc);
> +
> +	cfg = gsc_read(GSC_ENABLE);
> +	cfg |= GSC_ENABLE_ON;
> +	gsc_write(cfg, GSC_ENABLE);
> +
> +	return 0;
> +}
> +
> +static void gsc_ippdrv_stop(struct device *dev, enum drm_exynos_ipp_cmd cmd)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct drm_exynos_ipp_set_wb set_wb = {0, 0};
> +	u32 cfg;
> +
> +	DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, cmd);
> +
> +	switch (cmd) {
> +	case IPP_CMD_M2M:
> +		/* bypass */
> +		break;
> +	case IPP_CMD_WB:
> +		gsc_set_gscblk_fimd_wb(ctx, set_wb.enable);
> +		exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb);
> +		break;
> +	case IPP_CMD_OUTPUT:
> +	default:
> +		dev_err(dev, "invalid operations.\n");
> +		break;
> +	}
> +
> +	gsc_handle_irq(ctx, false, false, true);
> +
> +	/* reset sequence */
> +	gsc_write(0xff, GSC_OUT_BASE_ADDR_Y_MASK);
> +	gsc_write(0xff, GSC_OUT_BASE_ADDR_CB_MASK);
> +	gsc_write(0xff, GSC_OUT_BASE_ADDR_CR_MASK);
> +
> +	cfg = gsc_read(GSC_ENABLE);
> +	cfg &= ~GSC_ENABLE_ON;
> +	gsc_write(cfg, GSC_ENABLE);
> +}
> +
> +static int __devinit gsc_probe(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct gsc_context *ctx;
> +	struct resource *res;
> +	struct exynos_drm_ippdrv *ippdrv;
> +	int ret;
> +
> +	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> +	if (!ctx)
> +		return -ENOMEM;
> +
> +	/* clock control */
> +	ctx->gsc_clk = clk_get(dev, "gscl");
> +	if (IS_ERR(ctx->gsc_clk)) {
> +		dev_err(dev, "failed to get gsc clock.\n");
> +		ret = PTR_ERR(ctx->gsc_clk);
> +		goto err_ctx;
> +	}
> +
> +	ctx->parent_clk = clk_get(NULL, "aclk_300_gscl");
> +	if (IS_ERR(ctx->parent_clk)) {
> +		dev_err(dev, "failed to get parent clock.\n");
> +		ret = PTR_ERR(ctx->parent_clk);
> +		clk_put(ctx->gsc_clk);
> +		goto err_ctx;
> +	}
> +
> +	ctx->child_clk = clk_get(NULL, "dout_aclk_300_gscl");
> +	if (IS_ERR(ctx->child_clk)) {
> +		dev_err(dev, "failed to get child clock.\n");
> +		ret = PTR_ERR(ctx->child_clk);
> +		clk_put(ctx->gsc_clk);
> +		clk_put(ctx->parent_clk);
> +		goto err_ctx;
> +	}

Why do these clocks need? Please don't decide specific clock source in 
driver.

> +
> +	/* resource memory */
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res) {
> +		dev_err(dev, "failed to find registers.\n");
> +		ret = -ENOENT;
> +		goto err_clk;
> +	}
> +
> +	ctx->regs_res = request_mem_region(res->start, resource_size(res),
> +					   dev_name(dev));
> +	if (!ctx->regs_res) {
> +		dev_err(dev, "failed to claim register region.\n");
> +		ret = -ENOENT;
> +		goto err_clk;
> +	}
> +
> +	ctx->regs = ioremap(res->start, resource_size(res));
> +	if (!ctx->regs) {
> +		dev_err(dev, "failed to map registers.\n");
> +		ret = -ENXIO;
> +		goto err_req_region;
> +	}

Use devm_request_and_ioremap()

> +
> +	/* resource irq */
> +	res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> +	if (!res) {
> +		dev_err(dev, "failed to request irq resource.\n");
> +		ret = -ENOENT;
> +		goto err_get_regs;
> +	}
> +
> +	ctx->irq = res->start;
> +	ret = request_threaded_irq(ctx->irq, NULL, gsc_irq_handler,
> +		IRQF_ONESHOT, "drm_gsc", ctx);

Use devm_request_irq

> +	if (ret < 0) {
> +		dev_err(dev, "failed to request irq.\n");
> +		goto err_get_regs;
> +	}
> +
> +	/* context initailization */
> +	ctx->id = pdev->id;
> +
> +	ippdrv = &ctx->ippdrv;
> +	ippdrv->dev = dev;
> +	ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &gsc_src_ops;
> +	ippdrv->ops[EXYNOS_DRM_OPS_DST] = &gsc_dst_ops;
> +	ippdrv->check_property = gsc_ippdrv_check_property;
> +	ippdrv->reset = gsc_ippdrv_reset;
> +	ippdrv->start = gsc_ippdrv_start;
> +	ippdrv->stop = gsc_ippdrv_stop;
> +	ret = gsc_init_prop_list(ippdrv);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to init property list.\n");
> +		goto err_get_irq;
> +	}
> +
> +	DRM_DEBUG_KMS("%s:id[%d]ippdrv[0x%x]\n", __func__, ctx->id,
> +		(int)ippdrv);
> +
> +	mutex_init(&ctx->lock);
> +	platform_set_drvdata(pdev, ctx);
> +
> +	pm_runtime_set_active(dev);
> +	pm_runtime_enable(dev);
> +
> +	ret = exynos_drm_ippdrv_register(ippdrv);
> +	if (ret < 0) {
> +		dev_err(dev, "failed to register drm gsc device.\n");
> +		goto err_ippdrv_register;
> +	}
> +
> +	dev_info(&pdev->dev, "drm gsc registered successfully.\n");
> +
> +	return 0;
> +
> +err_ippdrv_register:
> +	kfree(ippdrv->prop_list);
> +	pm_runtime_disable(dev);
> +	free_irq(ctx->irq, ctx);
> +err_get_irq:
> +	free_irq(ctx->irq, ctx);
> +err_get_regs:
> +	iounmap(ctx->regs);
> +err_req_region:
> +	release_resource(ctx->regs_res);
> +	kfree(ctx->regs_res);
> +err_clk:
> +	clk_put(ctx->child_clk);
> +	clk_put(ctx->parent_clk);
> +	clk_put(ctx->gsc_clk);
> +err_ctx:
> +	kfree(ctx);
> +	return ret;
> +}
> +
> +static int __devexit gsc_remove(struct platform_device *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +	struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
> +
> +	kfree(ippdrv->prop_list);
> +	exynos_drm_ippdrv_unregister(ippdrv);
> +	mutex_destroy(&ctx->lock);
> +
> +	pm_runtime_set_suspended(dev);
> +	pm_runtime_disable(dev);
> +
> +	free_irq(ctx->irq, ctx);
> +	iounmap(ctx->regs);
> +	release_resource(ctx->regs_res);
> +	kfree(ctx->regs_res);
> +
> +	clk_put(ctx->child_clk);
> +	clk_put(ctx->parent_clk);
> +	clk_put(ctx->gsc_clk);
> +
> +	kfree(ctx);
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_PM_SLEEP
> +static int gsc_suspend(struct device *dev)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +
> +	/* ToDo */

Remove.

> +
> +	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
> +
> +	if (pm_runtime_suspended(dev))
> +		return 0;
> +
> +	return gsc_clk_ctrl(ctx, false);
> +}
> +
> +static int gsc_resume(struct device *dev)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +
> +	/* ToDo */

Ditto.

> +
> +	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
> +
> +	if (!pm_runtime_suspended(dev))
> +		return gsc_clk_ctrl(ctx, true);
> +
> +	return 0;
> +}
> +#endif
> +
> +#ifdef CONFIG_PM_RUNTIME
> +static int gsc_runtime_suspend(struct device *dev)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +
> +	/* ToDo */

Ditto.

> +
> +	DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
> +
> +	return  gsc_clk_ctrl(ctx, false);
> +}
> +
> +static int gsc_runtime_resume(struct device *dev)
> +{
> +	struct gsc_context *ctx = get_gsc_context(dev);
> +
> +	/* ToDo */

Ditto.

> +
> +	DRM_DEBUG_KMS("%s:id[%d]\n", __FILE__, ctx->id);
> +
> +	return  gsc_clk_ctrl(ctx, true);

If runtime PM isn't enabled, how do you control clock?

> +}
> +#endif
> +
> +static const struct dev_pm_ops gsc_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(gsc_suspend, gsc_resume)
> +	SET_RUNTIME_PM_OPS(gsc_runtime_suspend, gsc_runtime_resume, NULL)
> +};
> +
> +/* ToDo: need to check use case platform_device_id */

Use "TODO" instead of "ToDo".

> +struct platform_driver gsc_driver = {
> +	.probe		= gsc_probe,
> +	.remove		= __devexit_p(gsc_remove),
> +	.driver		= {
> +		.name	= "exynos-drm-gsc",
> +		.owner	= THIS_MODULE,
> +		.pm	= &gsc_pm_ops,
> +	},
> +};
> +
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.h b/drivers/gpu/drm/exynos/exynos_drm_gsc.h
> new file mode 100644
> index 0000000..b3ef7a0
> --- /dev/null
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.h
> @@ -0,0 +1,34 @@
> +/*
> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> + *
> + * Authors:
> + *	Eunchul Kim <chulspro.kim@samsung.com>
> + *	Jinyoung Jeon <jy0.jeon@samsung.com>
> + *	Sangmin Lee <lsmin.lee@samsung.com>
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
> + * OTHER DEALINGS IN THE SOFTWARE.
> + */
> +
> +#ifndef _EXYNOS_DRM_GSC_H_
> +#define _EXYNOS_DRM_GSC_H_
> +
> +/* ToDo */
> +

Please remove this dummy header file.

> +#endif /* _EXYNOS_DRM_GSC_H_ */
> diff --git a/drivers/gpu/drm/exynos/regs-gsc.h b/drivers/gpu/drm/exynos/regs-gsc.h
> new file mode 100644
> index 0000000..ed297b5
> --- /dev/null
> +++ b/drivers/gpu/drm/exynos/regs-gsc.h
> @@ -0,0 +1,295 @@
> +/* linux/drivers/gpu/drm/exynos/regs-gsc.h
> + *
> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
> + *		http://www.samsung.com
> + *
> + * Register definition file for Samsung G-Scaler driver
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef EXYNOS_REGS_GSC_H_
> +#define EXYNOS_REGS_GSC_H_
> +
> +/* SYSCON. GSCBLK_CFG */
> +#include <plat/map-base.h>
> +#include <plat/cpu.h>
> +#define SYSREG_DISP1BLK_CFG		(S3C_VA_SYS + 0x0214)
> +#define FIFORST_DISP1			(1 << 23)
> +#define GSC_OUT_MIXER0			(1 << 7)
> +#define GSC_OUT_MIXER0_GSC3		(3 << 5)
> +#define SYSREG_GSCBLK_CFG0		(S3C_VA_SYS + 0x0220)
> +#define GSC_OUT_DST_FIMD_SEL(x)		(1 << (8 + 2 * (x)))
> +#define GSC_OUT_DST_MXR_SEL(x)		(2 << (8 + 2 * (x)))
> +#define GSC_PXLASYNC_RST(x)		(1 << (x))
> +#define PXLASYNC_LO_MASK_CAMIF_TOP	(1 << 20)
> +#define SYSREG_GSCBLK_CFG1		(S3C_VA_SYS + 0x0224)
> +#define GSC_BLK_DISP1WB_DEST(x)		(x << 10)
> +#define GSC_BLK_SW_RESET_WB_DEST(x)	(1 << (18 + x))
> +#define GSC_BLK_PXLASYNC_LO_MASK_WB(x)	(0 << (14 + x))
> +#define GSC_BLK_GSCL_WB_IN_SRC_SEL(x)	(1 << (2 * x))
> +#define SYSREG_GSCBLK_CFG2		(S3C_VA_SYS + 0x2000)
> +#define PXLASYNC_LO_MASK_CAMIF_GSCL(x)	(1 << (x))
> +
> +/* G-Scaler enable */
> +#define GSC_ENABLE			0x00
> +#define GSC_ENABLE_PP_UPDATE_TIME_MASK	(1 << 9)
> +#define GSC_ENABLE_PP_UPDATE_TIME_CURR	(0 << 9)
> +#define GSC_ENABLE_PP_UPDATE_TIME_EOPAS	(1 << 9)
> +#define GSC_ENABLE_CLK_GATE_MODE_MASK	(1 << 8)
> +#define GSC_ENABLE_CLK_GATE_MODE_FREE	(1 << 8)
> +#define GSC_ENABLE_IPC_MODE_MASK	(1 << 7)
> +#define GSC_ENABLE_NORM_MODE		(0 << 7)
> +#define GSC_ENABLE_IPC_MODE		(1 << 7)
> +#define GSC_ENABLE_PP_UPDATE_MODE_MASK	(1 << 6)
> +#define GSC_ENABLE_PP_UPDATE_FIRE_MODE	(1 << 6)
> +#define GSC_ENABLE_IN_PP_UPDATE		(1 << 5)
> +#define GSC_ENABLE_ON_CLEAR_MASK	(1 << 4)
> +#define GSC_ENABLE_ON_CLEAR_ONESHOT	(1 << 4)
> +#define GSC_ENABLE_QOS_ENABLE		(1 << 3)
> +#define GSC_ENABLE_OP_STATUS		(1 << 2)
> +#define GSC_ENABLE_SFR_UPDATE		(1 << 1)
> +#define GSC_ENABLE_ON			(1 << 0)
> +
> +/* G-Scaler S/W reset */
> +#define GSC_SW_RESET			0x04
> +#define GSC_SW_RESET_SRESET		(1 << 0)
> +
> +/* G-Scaler IRQ */
> +#define GSC_IRQ				0x08
> +#define GSC_IRQ_STATUS_OR_IRQ		(1 << 17)
> +#define GSC_IRQ_STATUS_OR_FRM_DONE	(1 << 16)
> +#define GSC_IRQ_OR_MASK			(1 << 2)
> +#define GSC_IRQ_FRMDONE_MASK		(1 << 1)
> +#define GSC_IRQ_ENABLE			(1 << 0)
> +
> +/* G-Scaler input control */
> +#define GSC_IN_CON			0x10
> +#define GSC_IN_CHROM_STRIDE_SEL_MASK	(1 << 20)
> +#define GSC_IN_CHROM_STRIDE_SEPAR	(1 << 20)
> +#define GSC_IN_RB_SWAP_MASK		(1 << 19)
> +#define GSC_IN_RB_SWAP			(1 << 19)
> +#define GSC_IN_ROT_MASK			(7 << 16)
> +#define GSC_IN_ROT_270			(7 << 16)
> +#define GSC_IN_ROT_90_YFLIP		(6 << 16)
> +#define GSC_IN_ROT_90_XFLIP		(5 << 16)
> +#define GSC_IN_ROT_90			(4 << 16)
> +#define GSC_IN_ROT_180			(3 << 16)
> +#define GSC_IN_ROT_YFLIP		(2 << 16)
> +#define GSC_IN_ROT_XFLIP		(1 << 16)
> +#define GSC_IN_RGB_TYPE_MASK		(3 << 14)
> +#define GSC_IN_RGB_HD_WIDE		(3 << 14)
> +#define GSC_IN_RGB_HD_NARROW		(2 << 14)
> +#define GSC_IN_RGB_SD_WIDE		(1 << 14)
> +#define GSC_IN_RGB_SD_NARROW		(0 << 14)
> +#define GSC_IN_YUV422_1P_ORDER_MASK	(1 << 13)
> +#define GSC_IN_YUV422_1P_ORDER_LSB_Y	(0 << 13)
> +#define GSC_IN_YUV422_1P_OEDER_LSB_C	(1 << 13)
> +#define GSC_IN_CHROMA_ORDER_MASK	(1 << 12)
> +#define GSC_IN_CHROMA_ORDER_CBCR	(0 << 12)
> +#define GSC_IN_CHROMA_ORDER_CRCB	(1 << 12)
> +#define GSC_IN_FORMAT_MASK		(7 << 8)
> +#define GSC_IN_XRGB8888			(0 << 8)
> +#define GSC_IN_RGB565			(1 << 8)
> +#define GSC_IN_YUV420_2P		(2 << 8)
> +#define GSC_IN_YUV420_3P		(3 << 8)
> +#define GSC_IN_YUV422_1P		(4 << 8)
> +#define GSC_IN_YUV422_2P		(5 << 8)
> +#define GSC_IN_YUV422_3P		(6 << 8)
> +#define GSC_IN_TILE_TYPE_MASK		(1 << 4)
> +#define GSC_IN_TILE_C_16x8		(0 << 4)
> +#define GSC_IN_TILE_C_16x16		(1 << 4)
> +#define GSC_IN_TILE_MODE		(1 << 3)
> +#define GSC_IN_LOCAL_SEL_MASK		(3 << 1)
> +#define GSC_IN_LOCAL_CAM3		(3 << 1)
> +#define GSC_IN_LOCAL_FIMD_WB		(2 << 1)
> +#define GSC_IN_LOCAL_CAM1		(1 << 1)
> +#define GSC_IN_LOCAL_CAM0		(0 << 1)
> +#define GSC_IN_PATH_MASK		(1 << 0)
> +#define GSC_IN_PATH_LOCAL		(1 << 0)
> +#define GSC_IN_PATH_MEMORY		(0 << 0)
> +
> +/* G-Scaler source image size */
> +#define GSC_SRCIMG_SIZE			0x14
> +#define GSC_SRCIMG_HEIGHT_MASK		(0x1fff << 16)
> +#define GSC_SRCIMG_HEIGHT(x)		((x) << 16)
> +#define GSC_SRCIMG_WIDTH_MASK		(0x3fff << 0)
> +#define GSC_SRCIMG_WIDTH(x)		((x) << 0)
> +
> +/* G-Scaler source image offset */
> +#define GSC_SRCIMG_OFFSET		0x18
> +#define GSC_SRCIMG_OFFSET_Y_MASK	(0x1fff << 16)
> +#define GSC_SRCIMG_OFFSET_Y(x)		((x) << 16)
> +#define GSC_SRCIMG_OFFSET_X_MASK	(0x1fff << 0)
> +#define GSC_SRCIMG_OFFSET_X(x)		((x) << 0)
> +
> +/* G-Scaler cropped source image size */
> +#define GSC_CROPPED_SIZE		0x1C
> +#define GSC_CROPPED_HEIGHT_MASK		(0x1fff << 16)
> +#define GSC_CROPPED_HEIGHT(x)		((x) << 16)
> +#define GSC_CROPPED_WIDTH_MASK		(0x1fff << 0)
> +#define GSC_CROPPED_WIDTH(x)		((x) << 0)
> +
> +/* G-Scaler output control */
> +#define GSC_OUT_CON			0x20
> +#define GSC_OUT_GLOBAL_ALPHA_MASK	(0xff << 24)
> +#define GSC_OUT_GLOBAL_ALPHA(x)		((x) << 24)
> +#define GSC_OUT_CHROM_STRIDE_SEL_MASK	(1 << 13)
> +#define GSC_OUT_CHROM_STRIDE_SEPAR	(1 << 13)
> +#define GSC_OUT_RB_SWAP_MASK		(1 << 12)
> +#define GSC_OUT_RB_SWAP			(1 << 12)
> +#define GSC_OUT_RGB_TYPE_MASK		(3 << 10)
> +#define GSC_OUT_RGB_HD_NARROW		(3 << 10)
> +#define GSC_OUT_RGB_HD_WIDE		(2 << 10)
> +#define GSC_OUT_RGB_SD_NARROW		(1 << 10)
> +#define GSC_OUT_RGB_SD_WIDE		(0 << 10)
> +#define GSC_OUT_YUV422_1P_ORDER_MASK	(1 << 9)
> +#define GSC_OUT_YUV422_1P_ORDER_LSB_Y	(0 << 9)
> +#define GSC_OUT_YUV422_1P_OEDER_LSB_C	(1 << 9)
> +#define GSC_OUT_CHROMA_ORDER_MASK	(1 << 8)
> +#define GSC_OUT_CHROMA_ORDER_CBCR	(0 << 8)
> +#define GSC_OUT_CHROMA_ORDER_CRCB	(1 << 8)
> +#define GSC_OUT_FORMAT_MASK		(7 << 4)
> +#define GSC_OUT_XRGB8888		(0 << 4)
> +#define GSC_OUT_RGB565			(1 << 4)
> +#define GSC_OUT_YUV420_2P		(2 << 4)
> +#define GSC_OUT_YUV420_3P		(3 << 4)
> +#define GSC_OUT_YUV422_1P		(4 << 4)
> +#define GSC_OUT_YUV422_2P		(5 << 4)
> +#define GSC_OUT_YUV444			(7 << 4)
> +#define GSC_OUT_TILE_TYPE_MASK		(1 << 2)
> +#define GSC_OUT_TILE_C_16x8		(0 << 2)
> +#define GSC_OUT_TILE_C_16x16		(1 << 2)
> +#define GSC_OUT_TILE_MODE		(1 << 1)
> +#define GSC_OUT_PATH_MASK		(1 << 0)
> +#define GSC_OUT_PATH_LOCAL		(1 << 0)
> +#define GSC_OUT_PATH_MEMORY		(0 << 0)
> +
> +/* G-Scaler scaled destination image size */
> +#define GSC_SCALED_SIZE			0x24
> +#define GSC_SCALED_HEIGHT_MASK		(0x1fff << 16)
> +#define GSC_SCALED_HEIGHT(x)		((x) << 16)
> +#define GSC_SCALED_WIDTH_MASK		(0x1fff << 0)
> +#define GSC_SCALED_WIDTH(x)		((x) << 0)
> +
> +/* G-Scaler pre scale ratio */
> +#define GSC_PRE_SCALE_RATIO		0x28
> +#define GSC_PRESC_SHFACTOR_MASK		(7 << 28)
> +#define GSC_PRESC_SHFACTOR(x)		((x) << 28)
> +#define GSC_PRESC_V_RATIO_MASK		(7 << 16)
> +#define GSC_PRESC_V_RATIO(x)		((x) << 16)
> +#define GSC_PRESC_H_RATIO_MASK		(7 << 0)
> +#define GSC_PRESC_H_RATIO(x)		((x) << 0)
> +
> +/* G-Scaler main scale horizontal ratio */
> +#define GSC_MAIN_H_RATIO		0x2C
> +#define GSC_MAIN_H_RATIO_MASK		(0xfffff << 0)
> +#define GSC_MAIN_H_RATIO_VALUE(x)	((x) << 0)
> +
> +/* G-Scaler main scale vertical ratio */
> +#define GSC_MAIN_V_RATIO		0x30
> +#define GSC_MAIN_V_RATIO_MASK		(0xfffff << 0)
> +#define GSC_MAIN_V_RATIO_VALUE(x)	((x) << 0)
> +
> +/* G-Scaler input chrominance stride */
> +#define GSC_IN_CHROM_STRIDE		0x3C
> +#define GSC_IN_CHROM_STRIDE_MASK	(0x3fff << 0)
> +#define GSC_IN_CHROM_STRIDE_VALUE(x)	((x) << 0)
> +
> +/* G-Scaler destination image size */
> +#define GSC_DSTIMG_SIZE			0x40
> +#define GSC_DSTIMG_HEIGHT_MASK		(0x1fff << 16)
> +#define GSC_DSTIMG_HEIGHT(x)		((x) << 16)
> +#define GSC_DSTIMG_WIDTH_MASK		(0x1fff << 0)
> +#define GSC_DSTIMG_WIDTH(x)		((x) << 0)
> +
> +/* G-Scaler destination image offset */
> +#define GSC_DSTIMG_OFFSET		0x44
> +#define GSC_DSTIMG_OFFSET_Y_MASK	(0x1fff << 16)
> +#define GSC_DSTIMG_OFFSET_Y(x)		((x) << 16)
> +#define GSC_DSTIMG_OFFSET_X_MASK	(0x1fff << 0)
> +#define GSC_DSTIMG_OFFSET_X(x)		((x) << 0)
> +
> +/* G-Scaler output chrominance stride */
> +#define GSC_OUT_CHROM_STRIDE		0x48
> +#define GSC_OUT_CHROM_STRIDE_MASK	(0x3fff << 0)
> +#define GSC_OUT_CHROM_STRIDE_VALUE(x)	((x) << 0)
> +
> +/* G-Scaler input y address mask */
> +#define GSC_IN_BASE_ADDR_Y_MASK		0x4C
> +/* G-Scaler input y base address */
> +#define GSC_IN_BASE_ADDR_Y(n)		(0x50 + (n) * 0x4)
> +/* G-Scaler input y base current address */
> +#define GSC_IN_BASE_ADDR_Y_CUR(n)	(0x60 + (n) * 0x4)
> +
> +/* G-Scaler input cb address mask */
> +#define GSC_IN_BASE_ADDR_CB_MASK	0x7C
> +/* G-Scaler input cb base address */
> +#define GSC_IN_BASE_ADDR_CB(n)		(0x80 + (n) * 0x4)
> +/* G-Scaler input cb base current address */
> +#define GSC_IN_BASE_ADDR_CB_CUR(n)	(0x90 + (n) * 0x4)
> +
> +/* G-Scaler input cr address mask */
> +#define GSC_IN_BASE_ADDR_CR_MASK	0xAC
> +/* G-Scaler input cr base address */
> +#define GSC_IN_BASE_ADDR_CR(n)		(0xB0 + (n) * 0x4)
> +/* G-Scaler input cr base current address */
> +#define GSC_IN_BASE_ADDR_CR_CUR(n)	(0xC0 + (n) * 0x4)
> +
> +/* G-Scaler input address mask */
> +#define GSC_IN_CURR_ADDR_INDEX	(0xf << 24)
> +#define GSC_IN_CURR_GET_INDEX(x)	((x) >> 24)
> +#define GSC_IN_BASE_ADDR_PINGPONG(x)	((x) << 16)
> +#define GSC_IN_BASE_ADDR_MASK		(0xff << 0)
> +
> +/* G-Scaler output y address mask */
> +#define GSC_OUT_BASE_ADDR_Y_MASK	0x10C
> +/* G-Scaler output y base address */
> +#define GSC_OUT_BASE_ADDR_Y(n)		(0x110 + (n) * 0x4)
> +
> +/* G-Scaler output cb address mask */
> +#define GSC_OUT_BASE_ADDR_CB_MASK	0x15C
> +/* G-Scaler output cb base address */
> +#define GSC_OUT_BASE_ADDR_CB(n)		(0x160 + (n) * 0x4)
> +
> +/* G-Scaler output cr address mask */
> +#define GSC_OUT_BASE_ADDR_CR_MASK	0x1AC
> +/* G-Scaler output cr base address */
> +#define GSC_OUT_BASE_ADDR_CR(n)		(0x1B0 + (n) * 0x4)
> +
> +/* G-Scaler output address mask */
> +#define GSC_OUT_CURR_ADDR_INDEX		(0xf << 24)
> +#define GSC_OUT_CURR_GET_INDEX(x)	((x) >> 24)
> +#define GSC_OUT_BASE_ADDR_PINGPONG(x)	((x) << 16)
> +#define GSC_OUT_BASE_ADDR_MASK		(0xffff << 0)
> +
> +/* G-Scaler horizontal scaling filter */
> +#define GSC_HCOEF(n, s, x)	(0x300 + (n) * 0x4 + (s) * 0x30 + (x) * 0x300)
> +
> +/* G-Scaler vertical scaling filter */
> +#define GSC_VCOEF(n, s, x)	(0x200 + (n) * 0x4 + (s) * 0x30 + (x) * 0x300)
> +
> +/* G-Scaler BUS control */
> +#define GSC_BUSCON			0xA78
> +#define GSC_BUSCON_INT_TIME_MASK	(1 << 8)
> +#define GSC_BUSCON_INT_DATA_TRANS	(0 << 8)
> +#define GSC_BUSCON_INT_AXI_RESPONSE	(1 << 8)
> +#define GSC_BUSCON_AWCACHE(x)		((x) << 4)
> +#define GSC_BUSCON_ARCACHE(x)		((x) << 0)
> +
> +/* G-Scaler V position */
> +#define GSC_VPOSITION			0xA7C
> +#define GSC_VPOS_F(x)			((x) << 0)
> +
> +
> +/* G-Scaler clock initial count */
> +#define GSC_CLK_INIT_COUNT		0xC00
> +#define GSC_CLK_GATE_MODE_INIT_CNT(x)	((x) << 0)
> +
> +/* G-Scaler clock snoop count */
> +#define GSC_CLK_SNOOP_COUNT		0xC04
> +#define GSC_CLK_GATE_MODE_SNOOP_CNT(x)	((x) << 0)
> +
> +#endif /* EXYNOS_REGS_GSC_H_ */

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC v3 5/5] drm/exynos: add gsc ipp driver
  2012-12-13  2:29   ` Joonyoung Shim
@ 2012-12-14  5:29     ` Eunchul Kim
  0 siblings, 0 replies; 18+ messages in thread
From: Eunchul Kim @ 2012-12-14  5:29 UTC (permalink / raw)
  To: Joonyoung Shim
  Cc: jy0.jeon, sw0312.kim, jaejoon.seo, dri-devel, kyungmin.park,
	jmock.shin, 이상민, 김태헌

Thank's for your comment.

please check my answer.

BR
Eunchul Kim

On 12/13/2012 11:29 AM, Joonyoung Shim wrote:
> Hi,
>
> I can't review about logic of driver because i don't know well but i
> feel there are too many checking codes and unused or big size defines.

- I think error handling need. and What is unused defines ?
   What is big size define ? you mean the coefficient value ?

> Please refer v4l2 exynos gsc driver in drivers/media/platform/exynos-gsc/.

- I will check exynos gsc.

>
> This v3 patch seems to add many codes than v2. Please write changelog in
> future.

- Thank's I don't have a lot of experience about posting.

> Even if line is short, many lines are split to two lines. Please check
> it overall.

- PATCH description ?

>
> Thanks.
>
> On 12/12/2012 04:34 PM, Eunchul Kim wrote:
>> GSC is stand for General SCaler and supports supports
>
> supports supports

- Thank's, done.

>
>> image scaler/rotator/crop/flip/csc and input/output DMA operations.
>> input DMA reads image data from the memory.
>> output DMA writes image data to memory.
>> GSC supports image rotation and imag effect functions.
>
> s/imag/image

- done.

>
>> also supports writeback and display output operations.
>
> There are to begin a new line unnecessarily. Could you rewrite
> detailedly how this driver operates?

- What kind of ? writeback ? output operation ?

>
>>
>> Signed-off-by: Eunchul Kim <chulspro.kim@samsung.com>
>> Signed-off-by: Jinyoung Jeon <jy0.jeon@samsung.com>
>> ---
>>   drivers/gpu/drm/exynos/Kconfig          |    5 +
>>   drivers/gpu/drm/exynos/Makefile         |    1 +
>>   drivers/gpu/drm/exynos/exynos_drm_drv.c |   15 +
>>   drivers/gpu/drm/exynos/exynos_drm_drv.h |    1 +
>>   drivers/gpu/drm/exynos/exynos_drm_gsc.c | 1927
>> +++++++++++++++++++++++++++++++
>>   drivers/gpu/drm/exynos/exynos_drm_gsc.h |   34 +
>>   drivers/gpu/drm/exynos/regs-gsc.h       |  295 +++++
>>   7 files changed, 2278 insertions(+), 0 deletions(-)
>>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.c
>>   create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.h
>>   create mode 100644 drivers/gpu/drm/exynos/regs-gsc.h
>>
>> diff --git a/drivers/gpu/drm/exynos/Kconfig
>> b/drivers/gpu/drm/exynos/Kconfig
>> index 4860835..c93d776 100644
>> --- a/drivers/gpu/drm/exynos/Kconfig
>> +++ b/drivers/gpu/drm/exynos/Kconfig
>> @@ -64,3 +64,8 @@ config DRM_EXYNOS_ROTATOR
>>       help
>>         Choose this option if you want to use Exynos Rotator for DRM.
>> +config DRM_EXYNOS_GSC
>> +    bool "Exynos DRM GSC"
>> +    depends on DRM_EXYNOS_IPP && ARCH_EXYNOS5
>> +    help
>> +      Choose this option if you want to use Exynos GSC for DRM.
>> diff --git a/drivers/gpu/drm/exynos/Makefile
>> b/drivers/gpu/drm/exynos/Makefile
>> index 3b70668..639b49e 100644
>> --- a/drivers/gpu/drm/exynos/Makefile
>> +++ b/drivers/gpu/drm/exynos/Makefile
>> @@ -19,5 +19,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_G2D)    +=
>> exynos_drm_g2d.o
>>   exynosdrm-$(CONFIG_DRM_EXYNOS_IPP)    += exynos_drm_ipp.o
>>   exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC)    += exynos_drm_fimc.o
>>   exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR)    += exynos_drm_rotator.o
>> +exynosdrm-$(CONFIG_DRM_EXYNOS_GSC)    += exynos_drm_gsc.o
>>   obj-$(CONFIG_DRM_EXYNOS)        += exynosdrm.o
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> index 09d884b..e0a8e80 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
>> @@ -384,6 +384,12 @@ static int __init exynos_drm_init(void)
>>           goto out_rotator;
>>   #endif
>> +#ifdef CONFIG_DRM_EXYNOS_GSC
>> +    ret = platform_driver_register(&gsc_driver);
>> +    if (ret < 0)
>> +        goto out_gsc;
>> +#endif
>> +
>>   #ifdef CONFIG_DRM_EXYNOS_IPP
>>       ret = platform_driver_register(&ipp_driver);
>>       if (ret < 0)
>> @@ -412,6 +418,11 @@ out_drm:
>>   out_ipp:
>>   #endif
>> +#ifdef CONFIG_DRM_EXYNOS_GSC
>> +    platform_driver_unregister(&gsc_driver);
>> +out_gsc:
>> +#endif
>> +
>>   #ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>       platform_driver_unregister(&rotator_driver);
>>   out_rotator:
>> @@ -462,6 +473,10 @@ static void __exit exynos_drm_exit(void)
>>       platform_driver_unregister(&ipp_driver);
>>   #endif
>> +#ifdef CONFIG_DRM_EXYNOS_GSC
>> +    platform_driver_unregister(&gsc_driver);
>> +#endif
>> +
>>   #ifdef CONFIG_DRM_EXYNOS_ROTATOR
>>       platform_driver_unregister(&rotator_driver);
>>   #endif
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> index a74e37c..afe556c 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
>> @@ -354,5 +354,6 @@ extern struct platform_driver vidi_driver;
>>   extern struct platform_driver g2d_driver;
>>   extern struct platform_driver fimc_driver;
>>   extern struct platform_driver rotator_driver;
>> +extern struct platform_driver gsc_driver;
>>   extern struct platform_driver ipp_driver;
>>   #endif
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
>> b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
>> new file mode 100644
>> index 0000000..a4475b0
>> --- /dev/null
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
>> @@ -0,0 +1,1927 @@
>> +/*
>> + * Copyright (C) 2012 Samsung Electronics Co.Ltd
>> + * Authors:
>> + *    Eunchul Kim <chulspro.kim@samsung.com>
>> + *    Jinyoung Jeon <jy0.jeon@samsung.com>
>> + *    Sangmin Lee <lsmin.lee@samsung.com>
>> + *
>> + * This program is free software; you can redistribute  it and/or
>> modify it
>> + * under  the terms of  the GNU General  Public License as published
>> by the
>> + * Free Software Foundation;  either version 2 of the  License, or
>> (at your
>> + * option) any later version.
>> + *
>> + */
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/clk.h>
>> +#include <linux/pm_runtime.h>
>> +#include <plat/map-base.h>
>> +
>> +#include <drm/drmP.h>
>> +#include <drm/exynos_drm.h>
>> +#include "regs-gsc.h"
>> +#include "exynos_drm_ipp.h"
>> +#include "exynos_drm_gsc.h"
>> +
>> +/*
>> + * GSC is stand for General SCaler and
>> + * supports image scaler/rotator and input/output DMA operations.
>> + * input DMA reads image data from the memory.
>> + * output DMA writes image data to memory.
>> + * GSC supports image rotation and image effect functions.
>> + */
>
> Please see my comments about commit description.

- operation description ?

>
>> +
>> +#define GSC_MAX_DEVS    4
>> +#define GSC_MAX_SRC        4
>> +#define GSC_MAX_DST        16
>> +#define GSC_RESET_TIMEOUT    50
>> +#define GSC_BUF_STOP    1
>> +#define GSC_BUF_START    2
>> +#define GSC_REG_SZ        16
>> +#define GSC_WIDTH_ITU_709    1280
>> +#define GSC_SC_UP_MAX_RATIO        65536
>> +#define GSC_SC_DOWN_RATIO_7_8        74898
>> +#define GSC_SC_DOWN_RATIO_6_8        87381
>> +#define GSC_SC_DOWN_RATIO_5_8        104857
>> +#define GSC_SC_DOWN_RATIO_4_8        131072
>> +#define GSC_SC_DOWN_RATIO_3_8        174762
>> +#define GSC_SC_DOWN_RATIO_2_8        262144
>> +#define GSC_REFRESH_MIN    12
>> +#define GSC_REFRESH_MAX    60
>> +#define GSC_CROP_MAX    8192
>> +#define GSC_CROP_MIN    32
>> +#define GSC_SCALE_MAX    4224
>> +#define GSC_SCALE_MIN    32
>> +
>> +#define get_gsc_context(dev)
>> platform_get_drvdata(to_platform_device(dev))
>> +#define get_ctx_from_ippdrv(ippdrv)    container_of(ippdrv,\
>> +                    struct gsc_context, ippdrv);
>> +#define gsc_read(offset)        readl(ctx->regs + (offset))
>> +#define gsc_write(cfg, offset)    writel(cfg, ctx->regs + (offset))
>> +
>> +/*
>> + * A structure of scaler.
>> + *
>> + * @range: narrow, wide.
>> + * @pre_shfactor: pre sclaer shift factor.
>> + * @pre_hratio: horizontal ratio of the prescaler.
>> + * @pre_vratio: vertical ratio of the prescaler.
>> + * @main_hratio: the main scaler's horizontal ratio.
>> + * @main_vratio: the main scaler's vertical ratio.
>> + */
>> +struct gsc_scaler {
>> +    bool    range;
>> +    u32    pre_shfactor;
>> +    u32    pre_hratio;
>> +    u32    pre_vratio;
>> +    unsigned long main_hratio;
>> +    unsigned long main_vratio;
>> +};
>> +
>> +/*
>> + * A structure of scaler capability.
>> + *
>> + * find user manual 49.2 features.
>> + * @tile_w: tile mode or rotation width.
>> + * @tile_h: tile mode or rotation height.
>> + * @w: other cases width.
>> + * @h: other cases height.
>> + */
>> +struct gsc_capability {
>> +    /* tile or rotation */
>> +    u32    tile_w;
>> +    u32    tile_h;
>> +    /* other cases */
>> +    u32    w;
>> +    u32    h;
>> +};
>> +
>> +/*
>> + * A structure of gsc context.
>> + *
>> + * @ippdrv: prepare initialization using ippdrv.
>> + * @regs_res: register resources.
>> + * @regs: memory mapped io registers.
>> + * @lock: locking of operations.
>> + * @gsc_clk: gsc gate clock.
>> + * @parent_clk: parent clock e.g aclk_300.
>> + * @child_clk: child clock e.g dout_aclk_300.
>> + * @sc: scaler infomations.
>> + * @id: gsc id.
>> + * @irq: irq number.
>> + * @rotation: supports rotation of src.
>> + * @suspended: qos operations.
>> + */
>> +struct gsc_context {
>> +    struct exynos_drm_ippdrv    ippdrv;
>> +    struct resource    *regs_res;
>> +    void __iomem    *regs;
>> +    struct mutex    lock;
>> +    struct clk    *gsc_clk;
>> +    struct clk    *parent_clk;
>> +    struct clk    *child_clk;
>> +    struct gsc_scaler    sc;
>> +    int    id;
>> +    int    irq;
>> +    bool    rotation;
>> +    bool    suspended;
>> +};
>> +
>> +/* 8-tap Filter Coefficient */
>> +const int h_coef_8t[7][16][8] = {
>
> static? and it is unnecessary to be size of array.

- static OK. if remove size, build error.
   what do you want ?

>
>> +    {    /* Ratio <= 65536 (~8:8) */
>> +        {  0,  0,   0, 128,   0,   0,  0,  0 },/* 0 */
>> +        { -1,  2,  -6, 127,   7,  -2,  1,  0 },/* 1 */
>> +        { -1,  4, -12, 125,  16,  -5,  1,  0 },/* 2 */
>> +        { -1,  5, -15, 120,  25,  -8,  2,  0 },/* 3 */
>> +        { -1,  6, -18, 114,  35, -10,  3, -1 },/* 4 */
>> +        { -1,  6, -20, 107,  46, -13,  4, -1 },/* 5 */
>> +        { -2,  7, -21,  99,  57, -16,  5, -1 },/* 6 */
>> +        { -1,  6, -20,  89,  68, -18,  5, -1 },/* 7 */
>> +        { -1,  6, -20,  79,  79, -20,  6, -1 },/* 8 */
>> +        { -1,  5, -18,  68,  89, -20,  6, -1 },/* 9 */
>> +        { -1,  5, -16,  57,  99, -21,  7, -2 },/* 10 */
>> +        { -1,  4, -13,  46, 107, -20,  6, -1 },/* 11 */
>> +        { -1,  3, -10,  35, 114, -18,  6, -1 },/* 12 */
>> +        {  0,  2,  -8,  25, 120, -15,  5, -1 },/* 13 */
>> +        {  0,  1,  -5,  16, 125, -12,  4, -1 },/* 14 */
>> +        {  0,  1,  -2,   7, 127,  -6,  2, -1 } /* 15 */
>
> The comments for index seem unnecessary.

- done.

>
>> +    }, {    /* 65536 < Ratio <= 74898 (~8:7) */
>> +        {  3, -8,  14, 111,  13,  -8,  3,  0 },/* 0 */
>> +        {  2, -6,   7, 112,  21, -10,  3, -1 },/* 1 */
>> +        {  2, -4,   1, 110,  28, -12,  4, -1 },/* 2 */
>> +        {  1, -2,  -3, 106,  36, -13,  4, -1 },/* 3 */
>> +        {  1, -1,  -7, 103,  44, -15,  4, -1 },/* 4 */
>> +        {  1,  1, -11,  97,  53, -16,  4, -1 },/* 5 */
>> +        {  0,  2, -13,  91,  61, -16,  4, -1 },/* 6 */
>> +        {  0,  3, -15,  85,  69, -17,  4, -1 },/* 7 */
>> +        {  0,  3, -16,  77,  77, -16,  3,  0 },/* 8 */
>> +        { -1,  4, -17,  69,  85, -15,  3,  0 },/* 9 */
>> +        { -1,  4, -16,  61,  91, -13,  2,  0 },/* 10 */
>> +        { -1,  4, -16,  53,  97, -11,  1,  1 },/* 11 */
>> +        { -1,  4, -15,  44, 103,  -7, -1,  1 },/* 12 */
>> +        { -1,  4, -13,  36, 106,  -3, -2,  1 },/* 13 */
>> +        { -1,  4, -12,  28, 110,   1, -4,  2 },/* 14 */
>> +        { -1,  3, -10,  21, 112,   7, -6,  2 } /* 15 */
>> +    }, {    /* 74898 < Ratio <= 87381 (~8:6) */
>> +        { 2, -11,  25,  96, 25, -11,   2,  0 },/* 0 */
>> +        { 2, -10,  19,  96, 31, -12,   2,  0 },/* 1 */
>> +        { 2,  -9,  14,  94, 37, -12,   2,  0 },/* 2 */
>> +        { 2,  -8,  10,  92, 43, -12,   1,  0 },/* 3 */
>> +        { 2,  -7,   5,  90, 49, -12,   1,  0 },/* 4 */
>> +        { 2,  -5,   1,  86, 55, -12,   0,  1 },/* 5 */
>> +        { 2,  -4,  -2,  82, 61, -11,  -1,  1 },/* 6 */
>> +        { 1,  -3,  -5,  77, 67,  -9,  -1,  1 },/* 7 */
>> +        { 1,  -2,  -7,  72, 72,  -7,  -2,  1 },/* 8 */
>> +        { 1,  -1,  -9,  67, 77,  -5,  -3,  1 },/* 9 */
>> +        { 1,  -1, -11,  61, 82,  -2,  -4,  2 },/* 10 */
>> +        { 1,   0, -12,  55, 86,   1,  -5,  2 },/* 11 */
>> +        { 0,   1, -12,  49, 90,   5,  -7,  2 },/* 12 */
>> +        { 0,   1, -12,  43, 92,  10,  -8,  2 },/* 13 */
>> +        { 0,   2, -12,  37, 94,  14,  -9,  2 },/* 14 */
>> +        { 0,   2, -12,  31, 96,  19, -10,  2 } /* 15 */
>> +    }, {    /* 87381 < Ratio <= 104857 (~8:5) */
>> +        { -1,  -8, 33,  80, 33,  -8,  -1,  0 },/* 0 */
>> +        { -1,  -8, 28,  80, 37,  -7,  -2,  1 },/* 1 */
>> +        {  0,  -8, 24,  79, 41,  -7,  -2,  1 },/* 2 */
>> +        {  0,  -8, 20,  78, 46,  -6,  -3,  1 },/* 3 */
>> +        {  0,  -8, 16,  76, 50,  -4,  -3,  1 },/* 4 */
>> +        {  0,  -7, 13,  74, 54,  -3,  -4,  1 },/* 5 */
>> +        {  1,  -7, 10,  71, 58,  -1,  -5,  1 },/* 6 */
>> +        {  1,  -6,  6,  68, 62,   1,  -5,  1 },/* 7 */
>> +        {  1,  -6,  4,  65, 65,   4,  -6,  1 },/* 8 */
>> +        {  1,  -5,  1,  62, 68,   6,  -6,  1 },/* 9 */
>> +        {  1,  -5, -1,  58, 71,  10,  -7,  1 },/* 10 */
>> +        {  1,  -4, -3,  54, 74,  13,  -7,  0 },/* 11 */
>> +        {  1,  -3, -4,  50, 76,  16,  -8,  0 },/* 12 */
>> +        {  1,  -3, -6,  46, 78,  20,  -8,  0 },/* 13 */
>> +        {  1,  -2, -7,  41, 79,  24,  -8,  0 },/* 14 */
>> +        {  1,  -2, -7,  37, 80,  28,  -8, -1 } /* 15 */
>> +    }, {    /* 104857 < Ratio <= 131072 (~8:4) */
>> +        { -3,   0, 35,  64, 35,   0,  -3,  0 },/* 0 */
>> +        { -3,  -1, 32,  64, 38,   1,  -3,  0 },/* 1 */
>> +        { -2,  -2, 29,  63, 41,   2,  -3,  0 },/* 2 */
>> +        { -2,  -3, 27,  63, 43,   4,  -4,  0 },/* 3 */
>> +        { -2,  -3, 24,  61, 46,   6,  -4,  0 },/* 4 */
>> +        { -2,  -3, 21,  60, 49,   7,  -4,  0 },/* 5 */
>> +        { -1,  -4, 19,  59, 51,   9,  -4, -1 },/* 6 */
>> +        { -1,  -4, 16,  57, 53,  12,  -4, -1 },/* 7 */
>> +        { -1,  -4, 14,  55, 55,  14,  -4, -1 },/* 8 */
>> +        { -1,  -4, 12,  53, 57,  16,  -4, -1 },/* 9 */
>> +        { -1,  -4,  9,  51, 59,  19,  -4, -1 },/* 10 */
>> +        {  0,  -4,  7,  49, 60,  21,  -3, -2 },/* 11 */
>> +        {  0,  -4,  6,  46, 61,  24,  -3, -2 },/* 12 */
>> +        {  0,  -4,  4,  43, 63,  27,  -3, -2 },/* 13 */
>> +        {  0,  -3,  2,  41, 63,  29,  -2, -2 },/* 14 */
>> +        {  0,  -3,  1,  38, 64,  32,  -1, -3 } /* 15 */
>> +    }, {    /* 131072 < Ratio <= 174762 (~8:3) */
>> +        { -1,   8, 33,  48, 33,   8,  -1,  0 },/* 0 */
>> +        { -1,   7, 31,  49, 35,   9,  -1, -1 },/* 1 */
>> +        { -1,   6, 30,  49, 36,  10,  -1, -1 },/* 2 */
>> +        { -1,   5, 28,  48, 38,  12,  -1, -1 },/* 3 */
>> +        { -1,   4, 26,  48, 39,  13,   0, -1 },/* 4 */
>> +        { -1,   3, 24,  47, 41,  15,   0, -1 },/* 5 */
>> +        { -1,   2, 23,  47, 42,  16,   0, -1 },/* 6 */
>> +        { -1,   2, 21,  45, 43,  18,   1, -1 },/* 7 */
>> +        { -1,   1, 19,  45, 45,  19,   1, -1 },/* 8 */
>> +        { -1,   1, 18,  43, 45,  21,   2, -1 },/* 9 */
>> +        { -1,   0, 16,  42, 47,  23,   2, -1 },/* 10 */
>> +        { -1,   0, 15,  41, 47,  24,   3, -1 },/* 11 */
>> +        { -1,   0, 13,  39, 48,  26,   4, -1 },/* 12 */
>> +        { -1,  -1, 12,  38, 48,  28,   5, -1 },/* 13 */
>> +        { -1,  -1, 10,  36, 49,  30,   6, -1 },/* 14 */
>> +        { -1,  -1,  9,  35, 49,  31,   7, -1 } /* 15 */
>> +    }, {    /* 174762 < Ratio <= 262144 (~8:2) */
>> +        {  2,  13, 30,  38, 30,  13,   2,  0 },/* 0 */
>> +        {  2,  12, 29,  38, 30,  14,   3,  0 },/* 1 */
>> +        {  2,  11, 28,  38, 31,  15,   3,  0 },/* 2 */
>> +        {  2,  10, 26,  38, 32,  16,   4,  0 },/* 3 */
>> +        {  1,  10, 26,  37, 33,  17,   4,  0 },/* 4 */
>> +        {  1,   9, 24,  37, 34,  18,   5,  0 },/* 5 */
>> +        {  1,   8, 24,  37, 34,  19,   5,  0 },/* 6 */
>> +        {  1,   7, 22,  36, 35,  20,   6,  1 },/* 7 */
>> +        {  1,   6, 21,  36, 36,  21,   6,  1 },/* 8 */
>> +        {  1,   6, 20,  35, 36,  22,   7,  1 },/* 9 */
>> +        {  0,   5, 19,  34, 37,  24,   8,  1 },/* 10 */
>> +        {  0,   5, 18,  34, 37,  24,   9,  1 },/* 11 */
>> +        {  0,   4, 17,  33, 37,  26,  10,  1 },/* 12 */
>> +        {  0,   4, 16,  32, 38,  26,  10,  2 },/* 13 */
>> +        {  0,   3, 15,  31, 38,  28,  11,  2 },/* 14 */
>> +        {  0,   3, 14,  30, 38,  29,  12,  2 } /* 15 */
>> +    }
>> +};
>> +
>> +/* 4-tap Filter Coefficient */
>> +const int v_coef_4t[7][16][4] = {
>> +    {    /* Ratio <= 65536 (~8:8) */
>> +        {  0, 128,   0,  0 },/* 0 */
>> +        { -4, 127,   5,  0 },/* 1 */
>> +        { -6, 124,  11, -1 },/* 2 */
>> +        { -8, 118,  19, -1 },/* 3 */
>> +        { -8, 111,  27, -2 },/* 4 */
>> +        { -8, 102,  37, -3 },/* 5 */
>> +        { -8,  92,  48, -4 },/* 6 */
>> +        { -7,  81,  59, -5 },/* 7 */
>> +        { -6,  70,  70, -6 },/* 8 */
>> +        { -5,  59,  81, -7 },/* 9 */
>> +        { -4,  48,  92, -8 },/* 10 */
>> +        { -3,  37, 102, -8 },/* 11 */
>> +        { -2,  27, 111, -8 },/* 12 */
>> +        { -1,  19, 118, -8 },/* 13 */
>> +        { -1,  11, 124, -6 },/* 14 */
>> +        {  0,   5, 127, -4 } /* 15 */
>> +    }, {    /* 65536 < Ratio <= 74898 (~8:7) */
>> +        {  8, 112,   8,  0 },/* 0 */
>> +        {  4, 111,  14, -1 },/* 1 */
>> +        {  1, 109,  20, -2 },/* 2 */
>> +        { -2, 105,  27, -2 },/* 3 */
>> +        { -3, 100,  34, -3 },/* 4 */
>> +        { -5,  93,  43, -3 },/* 5 */
>> +        { -5,  86,  51, -4 },/* 6 */
>> +        { -5,  77,  60, -4 },/* 7 */
>> +        { -5,  69,  69, -5 },/* 8 */
>> +        { -4,  60,  77, -5 },/* 9 */
>> +        { -4,  51,  86, -5 },/* 10 */
>> +        { -3,  43,  93, -5 },/* 11 */
>> +        { -3,  34, 100, -3 },/* 12 */
>> +        { -2,  27, 105, -2 },/* 13 */
>> +        { -2,  20, 109,  1 },/* 14 */
>> +        { -1,  14, 111,  4 } /* 15 */
>> +    }, {    /* 74898 < Ratio <= 87381 (~8:6) */
>> +        { 16,  96,  16,  0 },/* 0 */
>> +        { 12,  97,  21, -2 },/* 1 */
>> +        {  8,  96,  26, -2 },/* 2 */
>> +        {  5,  93,  32, -2 },/* 3 */
>> +        {  2,  89,  39, -2 },/* 4 */
>> +        {  0,  84,  46, -2 },/* 5 */
>> +        { -1,  79,  53, -3 },/* 6 */
>> +        { -2,  73,  59, -2 },/* 7 */
>> +        { -2,  66,  66, -2 },/* 8 */
>> +        { -2,  59,  73, -2 },/* 9 */
>> +        { -3,  53,  79, -1 },/* 10 */
>> +        { -2,  46,  84,  0 },/* 11 */
>> +        { -2,  39,  89,  2 },/* 12 */
>> +        { -2,  32,  93,  5 },/* 13 */
>> +        { -2,  26,  96,  8 },/* 14 */
>> +        { -2,  21,  97, 12 } /* 15 */
>> +    }, {    /* 87381 < Ratio <= 104857 (~8:5) */
>> +        { 22,  84,  22,  0 },/* 0 */
>> +        { 18,  85,  26, -1 },/* 1 */
>> +        { 14,  84,  31, -1 },/* 2 */
>> +        { 11,  82,  36, -1 },/* 3 */
>> +        {  8,  79,  42, -1 },/* 4 */
>> +        {  6,  76,  47, -1 },/* 5 */
>> +        {  4,  72,  52,  0 },/* 6 */
>> +        {  2,  68,  58,  0 },/* 7 */
>> +        {  1,  63,  63,  1 },/* 8 */
>> +        {  0,  58,  68,  2 },/* 9 */
>> +        {  0,  52,  72,  4 },/* 10 */
>> +        { -1,  47,  76,  6 },/* 11 */
>> +        { -1,  42,  79,  8 },/* 12 */
>> +        { -1,  36,  82, 11 },/* 13 */
>> +        { -1,  31,  84, 14 },/* 14 */
>> +        { -1,  26,  85, 18 } /* 15 */
>> +    }, {    /* 104857 < Ratio <= 131072 (~8:4) */
>> +        { 26,  76,  26,  0 },/* 0 */
>> +        { 22,  76,  30,  0 },/* 1 */
>> +        { 19,  75,  34,  0 },/* 2 */
>> +        { 16,  73,  38,  1 },/* 3 */
>> +        { 13,  71,  43,  1 },/* 4 */
>> +        { 10,  69,  47,  2 },/* 5 */
>> +        {  8,  66,  51,  3 },/* 6 */
>> +        {  6,  63,  55,  4 },/* 7 */
>> +        {  5,  59,  59,  5 },/* 8 */
>> +        {  4,  55,  63,  6 },/* 9 */
>> +        {  3,  51,  66,  8 },/* 10 */
>> +        {  2,  47,  69, 10 },/* 11 */
>> +        {  1,  43,  71, 13 },/* 12 */
>> +        {  1,  38,  73, 16 },/* 13 */
>> +        {  0,  34,  75, 19 },/* 14 */
>> +        {  0,  30,  76, 22 } /* 15 */
>> +    }, {    /* 131072 < Ratio <= 174762 (~8:3) */
>> +        { 29,  70,  29,  0 },/* 0 */
>> +        { 26,  68,  32,  2 },/* 1 */
>> +        { 23,  67,  36,  2 },/* 2 */
>> +        { 20,  66,  39,  3 },/* 3 */
>> +        { 17,  65,  43,  3 },/* 4 */
>> +        { 15,  63,  46,  4 },/* 5 */
>> +        { 12,  61,  50,  5 },/* 6 */
>> +        { 10,  58,  53,  7 },/* 7 */
>> +        {  8,  56,  56,  8 },/* 8 */
>> +        {  7,  53,  58, 10 },/* 9 */
>> +        {  5,  50,  61, 12 },/* 10 */
>> +        {  4,  46,  63, 15 },/* 11 */
>> +        {  3,  43,  65, 17 },/* 12 */
>> +        {  3,  39,  66, 20 },/* 13 */
>> +        {  2,  36,  67, 23 },/* 14 */
>> +        {  2,  32,  68, 26 } /* 15 */
>> +    }, {    /* 174762 < Ratio <= 262144 (~8:2) */
>> +        { 32,  64,  32,  0 },/* 0 */
>> +        { 28,  63,  34,  3 },/* 1 */
>> +        { 25,  62,  37,  4 },/* 2 */
>> +        { 22,  62,  40,  4 },/* 3 */
>> +        { 19,  61,  43,  5 },/* 4 */
>> +        { 17,  59,  46,  6 },/* 5 */
>> +        { 15,  58,  48,  7 },/* 6 */
>> +        { 13,  55,  51,  9 },/* 7 */
>> +        { 11,  53,  53, 11 },/* 8 */
>> +        {  9,  51,  55, 13 },/* 9 */
>> +        {  7,  48,  58, 15 },/* 10 */
>> +        {  6,  46,  59, 17 },/* 11 */
>> +        {  5,  43,  61, 19 },/* 12 */
>> +        {  4,  40,  62, 22 },/* 13 */
>> +        {  4,  37,  62, 25 },/* 14 */
>> +        {  3,  34,  63, 28 } /* 15 */
>> +    }
>> +};
>> +
>> +static int gsc_sw_reset(struct gsc_context *ctx)
>> +{
>> +    u32 cfg;
>> +    int count = GSC_RESET_TIMEOUT;
>> +
>> +    DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +    /* s/w reset */
>> +    cfg = (GSC_SW_RESET_SRESET);
>> +    gsc_write(cfg, GSC_SW_RESET);
>> +
>> +    /* wait s/w reset complete */
>> +    while (count--) {
>> +        cfg = gsc_read(GSC_SW_RESET);
>> +        if (!cfg)
>> +            break;
>> +        usleep_range(1000, 2000);
>> +    }
>> +
>> +    if (cfg) {
>> +        DRM_ERROR("failed to reset gsc h/w.\n");
>> +        return -EBUSY;
>> +    }
>> +
>> +    /* display fifo reset */
>> +    cfg = readl(SYSREG_GSCBLK_CFG0);
>> +    /*
>> +     * GSCBLK Pixel asyncy FIFO S/W reset sequence
>> +     * set PXLASYNC_SW_RESET as 0 then,
>> +     * set PXLASYNC_SW_RESET as 1 again
>> +     */
>> +    cfg &= ~GSC_PXLASYNC_RST(ctx->id);
>> +    writel(cfg, SYSREG_GSCBLK_CFG0);
>> +    cfg |= GSC_PXLASYNC_RST(ctx->id);
>> +    writel(cfg, SYSREG_GSCBLK_CFG0);
>> +
>> +    /* pixel async reset */
>> +    cfg = readl(SYSREG_DISP1BLK_CFG);
>> +    /*
>> +     * DISPBLK1 FIFO S/W reset sequence
>> +     * set FIFORST_DISP1 as 0 then,
>> +     * set FIFORST_DISP1 as 1 again
>> +     */
>> +    cfg &= ~FIFORST_DISP1;
>> +    writel(cfg, SYSREG_DISP1BLK_CFG);
>> +    cfg |= FIFORST_DISP1;
>> +    writel(cfg, SYSREG_DISP1BLK_CFG);
>> +
>> +    /* reset sequence */
>> +    cfg = gsc_read(GSC_IN_BASE_ADDR_Y_MASK);
>> +    cfg |= (GSC_IN_BASE_ADDR_MASK |
>> +        GSC_IN_BASE_ADDR_PINGPONG(0));
>> +    gsc_write(cfg, GSC_IN_BASE_ADDR_Y_MASK);
>> +    gsc_write(cfg, GSC_IN_BASE_ADDR_CB_MASK);
>> +    gsc_write(cfg, GSC_IN_BASE_ADDR_CR_MASK);
>> +
>> +    cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
>> +    cfg |= (GSC_OUT_BASE_ADDR_MASK |
>> +        GSC_OUT_BASE_ADDR_PINGPONG(0));
>> +    gsc_write(cfg, GSC_OUT_BASE_ADDR_Y_MASK);
>> +    gsc_write(cfg, GSC_OUT_BASE_ADDR_CB_MASK);
>> +    gsc_write(cfg, GSC_OUT_BASE_ADDR_CR_MASK);
>> +
>> +    return 0;
>> +}
>> +
>> +static void gsc_set_gscblk_fimd_wb(struct gsc_context *ctx, bool enable)
>> +{
>> +    u32 gscblk_cfg;
>> +
>> +    DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +    gscblk_cfg = readl(SYSREG_GSCBLK_CFG1);
>> +
>> +    if (enable)
>> +        gscblk_cfg |= GSC_BLK_DISP1WB_DEST(ctx->id) |
>> +                GSC_BLK_GSCL_WB_IN_SRC_SEL(ctx->id) |
>> +                GSC_BLK_SW_RESET_WB_DEST(ctx->id);
>> +    else
>> +        gscblk_cfg |= GSC_BLK_PXLASYNC_LO_MASK_WB(ctx->id);
>> +
>> +    writel(gscblk_cfg, SYSREG_GSCBLK_CFG1);
>> +}
>> +
>> +static void gsc_handle_irq(struct gsc_context *ctx, bool enable,
>> +        bool overflow, bool done)
>
> Overflow and down argument are used to same value always in this driver.
> Is it right?

- It is handle irq flag API. I want to handle irq flags using this api.
  so, I added enable/overflow/done argument.

>
>> +{
>> +    u32 cfg;
>> +
>> +    DRM_DEBUG_KMS("%s:enable[%d]overflow[%d]level[%d]\n", __func__,
>> +            enable, overflow, done);
>> +
>> +    cfg = gsc_read(GSC_IRQ);
>> +    cfg |= (GSC_IRQ_OR_MASK | GSC_IRQ_FRMDONE_MASK);
>
> Unnecessary initialization.

- It is just clear cfg flag. I think that is need.

>
>> +
>> +    if (enable)
>> +        cfg |= GSC_IRQ_ENABLE;
>> +    else
>> +        cfg &= ~GSC_IRQ_ENABLE;
>> +
>> +    if (overflow)
>> +        cfg &= ~GSC_IRQ_OR_MASK;
>> +    else
>> +        cfg |= GSC_IRQ_OR_MASK;
>> +
>> +    if (done)
>> +        cfg &= ~GSC_IRQ_FRMDONE_MASK;
>> +    else
>> +        cfg |= GSC_IRQ_FRMDONE_MASK;
>> +
>> +    gsc_write(cfg, GSC_IRQ);
>> +}
>> +
>> +
>> +static int gsc_src_set_fmt(struct device *dev, u32 fmt)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    u32 cfg;
>> +
>> +    DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
>> +
>> +    cfg = gsc_read(GSC_IN_CON);
>> +    cfg &= ~(GSC_IN_RGB_TYPE_MASK | GSC_IN_YUV422_1P_ORDER_MASK |
>> +         GSC_IN_CHROMA_ORDER_MASK | GSC_IN_FORMAT_MASK |
>> +         GSC_IN_TILE_TYPE_MASK | GSC_IN_TILE_MODE |
>> +         GSC_IN_CHROM_STRIDE_SEL_MASK | GSC_IN_RB_SWAP_MASK);
>> +
>> +    switch (fmt) {
>> +    case DRM_FORMAT_RGB565:
>> +        cfg |= GSC_IN_RGB565;
>> +        break;
>> +    case DRM_FORMAT_XRGB8888:
>> +        cfg |= GSC_IN_XRGB8888;
>> +        break;
>> +    case DRM_FORMAT_BGRX8888:
>> +        cfg |= (GSC_IN_XRGB8888 | GSC_IN_RB_SWAP);
>> +        break;
>> +    case DRM_FORMAT_YUYV:
>> +        cfg |= (GSC_IN_YUV422_1P |
>> +            GSC_IN_YUV422_1P_ORDER_LSB_Y |
>> +            GSC_IN_CHROMA_ORDER_CBCR);
>> +        break;
>> +    case DRM_FORMAT_YVYU:
>> +        cfg |= (GSC_IN_YUV422_1P |
>> +            GSC_IN_YUV422_1P_ORDER_LSB_Y |
>> +            GSC_IN_CHROMA_ORDER_CRCB);
>> +        break;
>> +    case DRM_FORMAT_UYVY:
>> +        cfg |= (GSC_IN_YUV422_1P |
>> +            GSC_IN_YUV422_1P_OEDER_LSB_C |
>> +            GSC_IN_CHROMA_ORDER_CBCR);
>> +        break;
>> +    case DRM_FORMAT_VYUY:
>> +        cfg |= (GSC_IN_YUV422_1P |
>> +            GSC_IN_YUV422_1P_OEDER_LSB_C |
>> +            GSC_IN_CHROMA_ORDER_CRCB);
>> +        break;
>> +    case DRM_FORMAT_NV21:
>> +    case DRM_FORMAT_NV61:
>> +        cfg |= (GSC_IN_CHROMA_ORDER_CRCB |
>> +            GSC_IN_YUV420_2P);
>> +        break;
>> +    case DRM_FORMAT_YUV422:
>> +        cfg |= GSC_IN_YUV422_3P;
>> +        break;
>> +    case DRM_FORMAT_YUV420:
>> +    case DRM_FORMAT_YVU420:
>> +        cfg |= GSC_IN_YUV420_3P;
>> +        break;
>> +    case DRM_FORMAT_NV12:
>> +    case DRM_FORMAT_NV16:
>> +        cfg |= (GSC_IN_CHROMA_ORDER_CBCR |
>> +            GSC_IN_YUV420_2P);
>> +        break;
>> +    case DRM_FORMAT_NV12MT:
>> +        cfg |= (GSC_IN_TILE_C_16x8 | GSC_IN_TILE_MODE);
>> +        break;
>> +    default:
>> +        dev_err(ippdrv->dev, "inavlid target yuv order 0x%x.\n", fmt);
>> +        return -EINVAL;
>> +    }
>> +
>> +    gsc_write(cfg, GSC_IN_CON);
>> +
>> +    return 0;
>> +}
>> +
>> +static int gsc_src_set_transf(struct device *dev,
>> +        enum drm_exynos_degree degree,
>> +        enum drm_exynos_flip flip)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    u32 cfg;
>> +
>> +    DRM_DEBUG_KMS("%s:degree[%d]flip[0x%x]\n", __func__,
>> +        degree, flip);
>> +
>> +    cfg = gsc_read(GSC_IN_CON);
>> +    cfg &= ~GSC_IN_ROT_MASK;
>> +
>> +    switch (degree) {
>> +    case EXYNOS_DRM_DEGREE_0:
>> +        if (flip & EXYNOS_DRM_FLIP_VERTICAL)
>> +            cfg |= GSC_IN_ROT_XFLIP;
>> +        if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
>> +            cfg |= GSC_IN_ROT_YFLIP;
>> +        break;
>> +    case EXYNOS_DRM_DEGREE_90:
>> +        if (flip & EXYNOS_DRM_FLIP_VERTICAL)
>> +            cfg |= GSC_IN_ROT_90_XFLIP;
>> +        else if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
>> +            cfg |= GSC_IN_ROT_90_YFLIP;
>> +        else
>> +            cfg |= GSC_IN_ROT_90;
>> +        break;
>> +    case EXYNOS_DRM_DEGREE_180:
>> +        cfg |= GSC_IN_ROT_180;
>> +        break;
>> +    case EXYNOS_DRM_DEGREE_270:
>> +        cfg |= GSC_IN_ROT_270;
>> +        break;
>> +    default:
>> +        dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
>> +        return -EINVAL;
>> +    }
>> +
>> +    gsc_write(cfg, GSC_IN_CON);
>> +
>> +    ctx->rotation = cfg &
>> +        (GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
>> +
>> +    return ctx->rotation;
>> +}
>> +
>> +static int gsc_src_set_size(struct device *dev, int swap,
>> +        struct drm_exynos_pos *pos, struct drm_exynos_sz *sz)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct drm_exynos_pos img_pos = *pos;
>> +    struct gsc_scaler *sc = &ctx->sc;
>> +    u32 cfg;
>> +
>> +    DRM_DEBUG_KMS("%s:swap[%d]x[%d]y[%d]w[%d]h[%d]\n",
>> +        __func__, swap, pos->x, pos->y, pos->w, pos->h);
>> +
>> +    if (swap) {
>> +        img_pos.w = pos->h;
>> +        img_pos.h = pos->w;
>> +    }
>> +
>> +    /* pixel offset */
>> +    cfg = (GSC_SRCIMG_OFFSET_X(img_pos.x) |
>> +        GSC_SRCIMG_OFFSET_Y(img_pos.y));
>> +    gsc_write(cfg, GSC_SRCIMG_OFFSET);
>> +
>> +    /* cropped size */
>> +    cfg = (GSC_CROPPED_WIDTH(img_pos.w) |
>> +        GSC_CROPPED_HEIGHT(img_pos.h));
>> +    gsc_write(cfg, GSC_CROPPED_SIZE);
>> +
>> +    DRM_DEBUG_KMS("%s:hsize[%d]vsize[%d]\n",
>> +        __func__, sz->hsize, sz->vsize);
>> +
>> +    /* original size */
>> +    cfg = gsc_read(GSC_SRCIMG_SIZE);
>> +    cfg &= ~(GSC_SRCIMG_HEIGHT_MASK |
>> +        GSC_SRCIMG_WIDTH_MASK);
>> +
>> +    cfg |= (GSC_SRCIMG_WIDTH(sz->hsize) |
>> +        GSC_SRCIMG_HEIGHT(sz->vsize));
>> +
>> +    gsc_write(cfg, GSC_SRCIMG_SIZE);
>> +
>> +    cfg = gsc_read(GSC_IN_CON);
>> +    cfg &= ~GSC_IN_RGB_TYPE_MASK;
>> +
>> +    DRM_DEBUG_KMS("%s:width[%d]range[%d]\n",
>> +        __func__, pos->w, sc->range);
>> +
>> +    if (pos->w >= GSC_WIDTH_ITU_709)
>> +        if (sc->range)
>> +            cfg |= GSC_IN_RGB_HD_WIDE;
>> +        else
>> +            cfg |= GSC_IN_RGB_HD_NARROW;
>> +    else
>> +        if (sc->range)
>> +            cfg |= GSC_IN_RGB_SD_WIDE;
>> +        else
>> +            cfg |= GSC_IN_RGB_SD_NARROW;
>> +
>> +    gsc_write(cfg, GSC_IN_CON);
>> +
>> +    return 0;
>> +}
>> +
>> +static int gsc_src_set_buf_seq(struct gsc_context *ctx, u32 buf_id,
>> +        enum drm_exynos_ipp_buf_type buf_type)
>> +{
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    bool masked;
>> +    u32 cfg;
>> +    u32 mask = 0x00000001 << buf_id;
>> +
>> +    DRM_DEBUG_KMS("%s:buf_id[%d]buf_type[%d]\n", __func__,
>> +        buf_id, buf_type);
>> +
>> +    /* mask register set */
>> +    cfg = gsc_read(GSC_IN_BASE_ADDR_Y_MASK);
>> +
>> +    switch (buf_type) {
>> +    case IPP_BUF_ENQUEUE:
>> +        masked = false;
>> +        break;
>> +    case IPP_BUF_DEQUEUE:
>> +        masked = true;
>> +        break;
>> +    default:
>> +        dev_err(ippdrv->dev, "invalid buf ctrl parameter.\n");
>> +        return -EINVAL;
>> +    }
>> +
>> +    /* sequence id */
>> +    cfg &= (~mask);
>
> Unnecessary parenthesis.

- done.

>
>> +    cfg |= masked << buf_id;
>> +    gsc_write(cfg, GSC_IN_BASE_ADDR_Y_MASK);
>> +    gsc_write(cfg, GSC_IN_BASE_ADDR_CB_MASK);
>> +    gsc_write(cfg, GSC_IN_BASE_ADDR_CR_MASK);
>> +
>> +    return 0;
>> +}
>> +
>> +static int gsc_src_set_addr(struct device *dev,
>> +        struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
>> +        enum drm_exynos_ipp_buf_type buf_type)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
>> +    struct drm_exynos_ipp_property *property;
>> +
>> +    if (!c_node) {
>> +        DRM_ERROR("failed to get c_node.\n");
>> +        return -EINVAL;
>
> -EFAULT

- done.

>
>> +    }
>> +
>> +    property = &c_node->property;
>> +    if (!property) {
>> +        DRM_ERROR("failed to get property.\n");
>> +        return -EINVAL;
>
> -EFAULT

- done.

>
>> +    }
>> +
>> +    DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
>> +        property->prop_id, buf_id, buf_type);
>> +
>> +    if (buf_id > GSC_MAX_SRC) {
>> +        dev_info(ippdrv->dev, "inavlid buf_id %d.\n", buf_id);
>> +        return -ENOMEM;
>
> -EINVAL

- done.

>
>> +    }
>> +
>> +    /* address register set */
>> +    switch (buf_type) {
>> +    case IPP_BUF_ENQUEUE:
>> +        gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
>> +            GSC_IN_BASE_ADDR_Y(buf_id));
>> +        gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
>> +            GSC_IN_BASE_ADDR_CB(buf_id));
>> +        gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
>> +            GSC_IN_BASE_ADDR_CR(buf_id));
>> +        break;
>> +    case IPP_BUF_DEQUEUE:
>> +        gsc_write(0x0, GSC_IN_BASE_ADDR_Y(buf_id));
>> +        gsc_write(0x0, GSC_IN_BASE_ADDR_CB(buf_id));
>> +        gsc_write(0x0, GSC_IN_BASE_ADDR_CR(buf_id));
>> +        break;
>> +    default:
>> +        /* bypass */
>> +        break;
>> +    }
>> +
>> +    return gsc_src_set_buf_seq(ctx, buf_id, buf_type);
>> +}
>> +
>> +static struct exynos_drm_ipp_ops gsc_src_ops = {
>> +    .set_fmt = gsc_src_set_fmt,
>> +    .set_transf = gsc_src_set_transf,
>> +    .set_size = gsc_src_set_size,
>> +    .set_addr = gsc_src_set_addr,
>> +};
>> +
>> +static int gsc_dst_set_fmt(struct device *dev, u32 fmt)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    u32 cfg;
>> +
>> +    DRM_DEBUG_KMS("%s:fmt[0x%x]\n", __func__, fmt);
>> +
>> +    cfg = gsc_read(GSC_OUT_CON);
>> +    cfg &= ~(GSC_OUT_RGB_TYPE_MASK | GSC_OUT_YUV422_1P_ORDER_MASK |
>> +         GSC_OUT_CHROMA_ORDER_MASK | GSC_OUT_FORMAT_MASK |
>> +         GSC_OUT_CHROM_STRIDE_SEL_MASK | GSC_OUT_RB_SWAP_MASK |
>> +         GSC_OUT_GLOBAL_ALPHA_MASK);
>> +
>> +    switch (fmt) {
>> +    case DRM_FORMAT_RGB565:
>> +        cfg |= GSC_OUT_RGB565;
>> +        break;
>> +    case DRM_FORMAT_XRGB8888:
>> +        cfg |= GSC_OUT_XRGB8888;
>> +        break;
>> +    case DRM_FORMAT_BGRX8888:
>> +        cfg |= (GSC_OUT_XRGB8888 | GSC_OUT_RB_SWAP);
>> +        break;
>> +    case DRM_FORMAT_YUYV:
>> +        cfg |= (GSC_OUT_YUV422_1P |
>> +            GSC_OUT_YUV422_1P_ORDER_LSB_Y |
>> +            GSC_OUT_CHROMA_ORDER_CBCR);
>> +        break;
>> +    case DRM_FORMAT_YVYU:
>> +        cfg |= (GSC_OUT_YUV422_1P |
>> +            GSC_OUT_YUV422_1P_ORDER_LSB_Y |
>> +            GSC_OUT_CHROMA_ORDER_CRCB);
>> +        break;
>> +    case DRM_FORMAT_UYVY:
>> +        cfg |= (GSC_OUT_YUV422_1P |
>> +            GSC_OUT_YUV422_1P_OEDER_LSB_C |
>> +            GSC_OUT_CHROMA_ORDER_CBCR);
>> +        break;
>> +    case DRM_FORMAT_VYUY:
>> +        cfg |= (GSC_OUT_YUV422_1P |
>> +            GSC_OUT_YUV422_1P_OEDER_LSB_C |
>> +            GSC_OUT_CHROMA_ORDER_CRCB);
>> +        break;
>> +    case DRM_FORMAT_NV21:
>> +    case DRM_FORMAT_NV61:
>> +        cfg |= (GSC_OUT_CHROMA_ORDER_CRCB |
>> +            GSC_OUT_YUV420_2P);
>
> Please check to join to one line overall. This line can be in 80 character.

- Thank's. done.

>
>> +        break;
>> +    case DRM_FORMAT_YUV422:
>> +    case DRM_FORMAT_YUV420:
>> +    case DRM_FORMAT_YVU420:
>> +        cfg |= GSC_OUT_YUV420_3P;
>> +        break;
>> +    case DRM_FORMAT_NV12:
>> +    case DRM_FORMAT_NV16:
>> +        cfg |= (GSC_OUT_CHROMA_ORDER_CBCR |
>> +            GSC_OUT_YUV420_2P);
>> +        break;
>> +    case DRM_FORMAT_NV12MT:
>> +        cfg |= (GSC_OUT_TILE_C_16x8 | GSC_OUT_TILE_MODE);
>> +        break;
>> +    default:
>> +        dev_err(ippdrv->dev, "inavlid target yuv order 0x%x.\n", fmt);
>> +        return -EINVAL;
>> +    }
>> +
>> +    gsc_write(cfg, GSC_OUT_CON);
>> +
>> +    return 0;
>> +}
>> +
>> +static int gsc_dst_set_transf(struct device *dev,
>> +        enum drm_exynos_degree degree,
>> +        enum drm_exynos_flip flip)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    u32 cfg;
>> +
>> +    DRM_DEBUG_KMS("%s:degree[%d]flip[0x%x]\n", __func__,
>> +        degree, flip);
>> +
>> +    cfg = gsc_read(GSC_IN_CON);
>> +    cfg &= ~GSC_IN_ROT_MASK;
>> +
>> +    switch (degree) {
>> +    case EXYNOS_DRM_DEGREE_0:
>> +        if (flip & EXYNOS_DRM_FLIP_VERTICAL)
>> +            cfg |= GSC_IN_ROT_XFLIP;
>> +        if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
>> +            cfg |= GSC_IN_ROT_YFLIP;
>> +        break;
>> +    case EXYNOS_DRM_DEGREE_90:
>> +        if (flip & EXYNOS_DRM_FLIP_VERTICAL)
>> +            cfg |= GSC_IN_ROT_90_XFLIP;
>> +        else if (flip & EXYNOS_DRM_FLIP_HORIZONTAL)
>> +            cfg |= GSC_IN_ROT_90_YFLIP;
>> +        else
>> +            cfg |= GSC_IN_ROT_90;
>> +        break;
>> +    case EXYNOS_DRM_DEGREE_180:
>> +        cfg |= GSC_IN_ROT_180;
>> +        break;
>> +    case EXYNOS_DRM_DEGREE_270:
>> +        cfg |= GSC_IN_ROT_270;
>> +        break;
>> +    default:
>> +        dev_err(ippdrv->dev, "inavlid degree value %d.\n", degree);
>> +        return -EINVAL;
>> +    }
>> +
>> +    gsc_write(cfg, GSC_IN_CON);
>> +
>> +    ctx->rotation = cfg &
>> +        (GSC_IN_ROT_90 | GSC_IN_ROT_270) ? 1 : 0;
>> +
>> +    return ctx->rotation;
>> +}
>> +
>> +static int gsc_get_ratio_shift(u32 src, u32 dst, u32 *ratio)
>> +{
>> +    DRM_DEBUG_KMS("%s:src[%d]dst[%d]\n", __func__, src, dst);
>> +
>> +    if (src >= dst * 8) {
>> +        DRM_ERROR("failed to make ratio and shift.\n");
>> +        return -EINVAL;
>> +    } else if (src >= dst * 4)
>> +        *ratio = 4;
>> +    else if (src >= dst * 2)
>> +        *ratio = 2;
>> +    else
>> +        *ratio = 1;
>> +
>> +    return 0;
>> +}
>> +
>> +static void gsc_get_prescaler_shfactor(u32 hratio, u32 vratio, u32
>> *shfactor)
>> +{
>> +    if (hratio == 4 && vratio == 4)
>> +        *shfactor = 4;
>> +    else if ((hratio == 4 && vratio == 2) ||
>> +         (hratio == 2 && vratio == 4))
>> +        *shfactor = 3;
>> +    else if ((hratio == 4 && vratio == 1) ||
>> +         (hratio == 1 && vratio == 4) ||
>> +         (hratio == 2 && vratio == 2))
>> +        *shfactor = 2;
>> +    else if (hratio == 1 && vratio == 1)
>> +        *shfactor = 0;
>> +    else
>> +        *shfactor = 1;
>> +}
>> +
>> +static int gsc_set_prescaler(struct gsc_context *ctx, struct
>> gsc_scaler *sc,
>> +        struct drm_exynos_pos *src, struct drm_exynos_pos *dst)
>> +{
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    u32 cfg;
>> +    u32 src_w, src_h, dst_w, dst_h;
>> +    int ret = 0;
>> +
>> +    src_w = src->w;
>> +    src_h = src->h;
>> +
>> +    if (ctx->rotation) {
>> +        dst_w = dst->h;
>> +        dst_h = dst->w;
>> +    } else {
>> +        dst_w = dst->w;
>> +        dst_h = dst->h;
>> +    }
>> +
>> +    ret = gsc_get_ratio_shift(src_w, dst_w, &sc->pre_hratio);
>> +    if (ret) {
>> +        dev_err(ippdrv->dev, "failed to get ratio horizontal.\n");
>> +        return ret;
>> +    }
>> +
>> +    ret = gsc_get_ratio_shift(src_h, dst_h, &sc->pre_vratio);
>> +    if (ret) {
>> +        dev_err(ippdrv->dev, "failed to get ratio vertical.\n");
>> +        return ret;
>> +    }
>> +
>> +    DRM_DEBUG_KMS("%s:pre_hratio[%d]pre_vratio[%d]\n",
>> +        __func__, sc->pre_hratio, sc->pre_vratio);
>> +
>> +    sc->main_hratio = (src_w << 16) / dst_w;
>> +    sc->main_vratio = (src_h << 16) / dst_h;
>> +
>> +    DRM_DEBUG_KMS("%s:main_hratio[%ld]main_vratio[%ld]\n",
>> +        __func__, sc->main_hratio, sc->main_vratio);
>> +
>> +    gsc_get_prescaler_shfactor(sc->pre_hratio, sc->pre_vratio,
>> +        &sc->pre_shfactor);
>> +
>> +    DRM_DEBUG_KMS("%s:pre_shfactor[%d]\n", __func__,
>> +        sc->pre_shfactor);
>> +
>> +    cfg = (GSC_PRESC_SHFACTOR(sc->pre_shfactor) |
>> +        GSC_PRESC_H_RATIO(sc->pre_hratio) |
>> +        GSC_PRESC_V_RATIO(sc->pre_vratio));
>> +    gsc_write(cfg, GSC_PRE_SCALE_RATIO);
>> +
>> +    return ret;
>> +}
>> +
>> +static void gsc_set_h_coef(struct gsc_context *ctx, unsigned long
>> main_hratio)
>> +{
>> +    int i, j, k, sc_ratio;
>> +
>> +    if (main_hratio <= GSC_SC_UP_MAX_RATIO)
>> +        sc_ratio = 0;
>> +    else if (main_hratio <= GSC_SC_DOWN_RATIO_7_8)
>> +        sc_ratio = 1;
>> +    else if (main_hratio <= GSC_SC_DOWN_RATIO_6_8)
>> +        sc_ratio = 2;
>> +    else if (main_hratio <= GSC_SC_DOWN_RATIO_5_8)
>> +        sc_ratio = 3;
>> +    else if (main_hratio <= GSC_SC_DOWN_RATIO_4_8)
>> +        sc_ratio = 4;
>> +    else if (main_hratio <= GSC_SC_DOWN_RATIO_3_8)
>> +        sc_ratio = 5;
>> +    else
>> +        sc_ratio = 6;
>> +
>> +    for (i = 0; i < 9; i++)
>> +        for (j = 0; j < 8; j++)
>> +            for (k = 0; k < 3; k++)
>> +                gsc_write(h_coef_8t[sc_ratio][i][j],
>> +                    GSC_HCOEF(i, j, k));
>
> Please define constants to macro or get array size.

- about for loop ? or value ?

>
>> +}
>> +
>> +static void gsc_set_v_coef(struct gsc_context *ctx, unsigned long
>> main_vratio)
>> +{
>> +    int i, j, k, sc_ratio = 0;
>
> Unnecessary initialization.

- done.

>
>> +
>> +    if (main_vratio <= GSC_SC_UP_MAX_RATIO)
>> +        sc_ratio = 0;
>> +    else if (main_vratio <= GSC_SC_DOWN_RATIO_7_8)
>> +        sc_ratio = 1;
>> +    else if (main_vratio <= GSC_SC_DOWN_RATIO_6_8)
>> +        sc_ratio = 2;
>> +    else if (main_vratio <= GSC_SC_DOWN_RATIO_5_8)
>> +        sc_ratio = 3;
>> +    else if (main_vratio <= GSC_SC_DOWN_RATIO_4_8)
>> +        sc_ratio = 4;
>> +    else if (main_vratio <= GSC_SC_DOWN_RATIO_3_8)
>> +        sc_ratio = 5;
>> +    else
>> +        sc_ratio = 6;
>> +
>> +    for (i = 0; i < 9; i++)
>> +        for (j = 0; j < 4; j++)
>> +            for (k = 0; k < 3; k++)
>> +                gsc_write(v_coef_4t[sc_ratio][i][j],
>> +                    GSC_VCOEF(i, j, k));
>> +}
>> +
>> +static void gsc_set_scaler(struct gsc_context *ctx, struct gsc_scaler
>> *sc)
>> +{
>> +    u32 cfg;
>> +
>> +    DRM_DEBUG_KMS("%s:main_hratio[%ld]main_vratio[%ld]\n",
>> +        __func__, sc->main_hratio, sc->main_vratio);
>> +
>> +    gsc_set_h_coef(ctx, sc->main_hratio);
>> +    cfg = GSC_MAIN_H_RATIO_VALUE(sc->main_hratio);
>> +    gsc_write(cfg, GSC_MAIN_H_RATIO);
>> +
>> +    gsc_set_v_coef(ctx, sc->main_vratio);
>> +    cfg = GSC_MAIN_V_RATIO_VALUE(sc->main_vratio);
>> +    gsc_write(cfg, GSC_MAIN_V_RATIO);
>> +}
>> +
>> +static int gsc_dst_set_size(struct device *dev, int swap,
>> +        struct drm_exynos_pos *pos, struct drm_exynos_sz *sz)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct drm_exynos_pos img_pos = *pos;
>> +    struct gsc_scaler *sc = &ctx->sc;
>> +    u32 cfg;
>> +
>> +    DRM_DEBUG_KMS("%s:swap[%d]x[%d]y[%d]w[%d]h[%d]\n",
>> +        __func__, swap, pos->x, pos->y, pos->w, pos->h);
>> +
>> +    if (swap) {
>> +        img_pos.w = pos->h;
>> +        img_pos.h = pos->w;
>> +    }
>> +
>> +    /* pixel offset */
>> +    cfg = (GSC_DSTIMG_OFFSET_X(pos->x) |
>> +        GSC_DSTIMG_OFFSET_Y(pos->y));
>> +    gsc_write(cfg, GSC_DSTIMG_OFFSET);
>> +
>> +    /* scaled size */
>> +    cfg = (GSC_SCALED_WIDTH(img_pos.w) | GSC_SCALED_HEIGHT(img_pos.h));
>> +    gsc_write(cfg, GSC_SCALED_SIZE);
>> +
>> +    DRM_DEBUG_KMS("%s:hsize[%d]vsize[%d]\n",
>> +        __func__, sz->hsize, sz->vsize);
>> +
>> +    /* original size */
>> +    cfg = gsc_read(GSC_DSTIMG_SIZE);
>> +    cfg &= ~(GSC_DSTIMG_HEIGHT_MASK |
>> +        GSC_DSTIMG_WIDTH_MASK);
>> +    cfg |= (GSC_DSTIMG_WIDTH(sz->hsize) |
>> +        GSC_DSTIMG_HEIGHT(sz->vsize));
>> +    gsc_write(cfg, GSC_DSTIMG_SIZE);
>> +
>> +    cfg = gsc_read(GSC_OUT_CON);
>> +    cfg &= ~GSC_OUT_RGB_TYPE_MASK;
>> +
>> +    DRM_DEBUG_KMS("%s:width[%d]range[%d]\n",
>> +        __func__, pos->w, sc->range);
>> +
>> +    if (pos->w >= GSC_WIDTH_ITU_709)
>> +        if (sc->range)
>> +            cfg |= GSC_OUT_RGB_HD_WIDE;
>> +        else
>> +            cfg |= GSC_OUT_RGB_HD_NARROW;
>> +    else
>> +        if (sc->range)
>> +            cfg |= GSC_OUT_RGB_SD_WIDE;
>> +        else
>> +            cfg |= GSC_OUT_RGB_SD_NARROW;
>> +
>> +    gsc_write(cfg, GSC_OUT_CON);
>> +
>> +    return 0;
>> +}
>> +
>> +static int gsc_dst_get_buf_seq(struct gsc_context *ctx)
>> +{
>> +    u32 cfg, i, buf_num = GSC_REG_SZ;
>> +    u32 mask = 0x00000001;
>> +
>> +    cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
>> +
>> +    for (i = 0; i < GSC_REG_SZ; i++)
>> +        if (cfg & (mask << i))
>> +            buf_num--;
>> +
>> +    DRM_DEBUG_KMS("%s:buf_num[%d]\n", __func__, buf_num);
>> +
>> +    return buf_num;
>> +}
>> +
>> +static int gsc_dst_set_buf_seq(struct gsc_context *ctx, u32 buf_id,
>> +        enum drm_exynos_ipp_buf_type buf_type)
>> +{
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    bool masked;
>> +    u32 cfg;
>> +    u32 mask = 0x00000001 << buf_id;
>> +    int ret = 0;
>> +
>> +    DRM_DEBUG_KMS("%s:buf_id[%d]buf_type[%d]\n", __func__,
>> +        buf_id, buf_type);
>> +
>> +    mutex_lock(&ctx->lock);
>> +
>> +    /* mask register set */
>> +    cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
>> +
>> +    switch (buf_type) {
>> +    case IPP_BUF_ENQUEUE:
>> +        masked = false;
>> +        break;
>> +    case IPP_BUF_DEQUEUE:
>> +        masked = true;
>> +        break;
>> +    default:
>> +        dev_err(ippdrv->dev, "invalid buf ctrl parameter.\n");
>> +        ret =  -EINVAL;
>> +        goto err_unlock;
>> +    }
>> +
>> +    /* sequence id */
>> +    cfg &= (~mask);
>
> Unnecessary parenthesis.

- done.

>
>> +    cfg |= masked << buf_id;
>> +    gsc_write(cfg, GSC_OUT_BASE_ADDR_Y_MASK);
>> +    gsc_write(cfg, GSC_OUT_BASE_ADDR_CB_MASK);
>> +    gsc_write(cfg, GSC_OUT_BASE_ADDR_CR_MASK);
>> +
>> +    /* interrupt enable */
>> +    if (buf_type == IPP_BUF_ENQUEUE &&
>> +        gsc_dst_get_buf_seq(ctx) >= GSC_BUF_START)
>> +        gsc_handle_irq(ctx, true, false, true);
>> +
>> +    /* interrupt disable */
>> +    if (buf_type == IPP_BUF_DEQUEUE &&
>> +        gsc_dst_get_buf_seq(ctx) <= GSC_BUF_STOP)
>> +        gsc_handle_irq(ctx, false, false, true);
>> +
>> +err_unlock:
>> +    mutex_unlock(&ctx->lock);
>> +    return ret;
>> +}
>> +
>> +static int gsc_dst_set_addr(struct device *dev,
>> +        struct drm_exynos_ipp_buf_info *buf_info, u32 buf_id,
>> +        enum drm_exynos_ipp_buf_type buf_type)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
>> +    struct drm_exynos_ipp_property *property;
>> +
>> +    if (!c_node) {
>> +        DRM_ERROR("failed to get c_node.\n");
>> +        return -EINVAL;
>
> -EFAULT

- done.

>
>> +    }
>> +
>> +    property = &c_node->property;
>> +    if (!property) {
>> +        DRM_ERROR("failed to get property.\n");
>> +        return -EINVAL;
>
> -EFAULT

- done.

>
>> +    }
>> +
>> +    DRM_DEBUG_KMS("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n", __func__,
>> +        property->prop_id, buf_id, buf_type);
>> +
>> +    if (buf_id > GSC_MAX_DST) {
>> +        dev_info(ippdrv->dev, "inavlid buf_id %d.\n", buf_id);
>> +        return -ENOMEM;
>
> -EINVAL

- done.

>
>> +    }
>> +
>> +    /* address register set */
>> +    switch (buf_type) {
>> +    case IPP_BUF_ENQUEUE:
>> +        gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_Y],
>> +            GSC_OUT_BASE_ADDR_Y(buf_id));
>> +        gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CB],
>> +            GSC_OUT_BASE_ADDR_CB(buf_id));
>> +        gsc_write(buf_info->base[EXYNOS_DRM_PLANAR_CR],
>> +            GSC_OUT_BASE_ADDR_CR(buf_id));
>> +        break;
>> +    case IPP_BUF_DEQUEUE:
>> +        gsc_write(0x0, GSC_OUT_BASE_ADDR_Y(buf_id));
>> +        gsc_write(0x0, GSC_OUT_BASE_ADDR_CB(buf_id));
>> +        gsc_write(0x0, GSC_OUT_BASE_ADDR_CR(buf_id));
>> +        break;
>> +    default:
>> +        /* bypass */
>> +        break;
>> +    }
>> +
>> +    return gsc_dst_set_buf_seq(ctx, buf_id, buf_type);
>> +}
>> +
>> +static struct exynos_drm_ipp_ops gsc_dst_ops = {
>> +    .set_fmt = gsc_dst_set_fmt,
>> +    .set_transf = gsc_dst_set_transf,
>> +    .set_size = gsc_dst_set_size,
>> +    .set_addr = gsc_dst_set_addr,
>> +};
>> +
>> +static int gsc_clk_ctrl(struct gsc_context *ctx, bool enable)
>> +{
>> +    DRM_INFO("%s:enable[%d]\n", __func__, enable);
>
> DRM_DEBUG_KMS?

- sorry my mistaken. done.

>
>> +
>> +    if (enable) {
>> +        clk_set_parent(ctx->child_clk, ctx->parent_clk);
>
> I think this is enough only to one operation.

- Thank's move to probe.

>
>> +        clk_enable(ctx->gsc_clk);
>> +        ctx->suspended = false;
>> +    } else {
>> +        clk_disable(ctx->gsc_clk);
>> +        ctx->suspended = true;
>> +    }
>> +
>> +    return 0;
>> +}
>> +
>> +static int gsc_get_src_buf_index(struct gsc_context *ctx)
>> +{
>> +    u32 cfg, curr_index, i;
>> +    u32 buf_id = GSC_MAX_SRC;
>> +
>> +    DRM_DEBUG_KMS("%s:gsc id[%d]\n", __func__, ctx->id);
>> +
>> +    cfg = gsc_read(GSC_IN_BASE_ADDR_Y_MASK);
>> +    curr_index = GSC_IN_CURR_GET_INDEX(cfg);
>> +
>> +    for (i = curr_index; i < GSC_MAX_SRC; i++) {
>> +        if (!((cfg >> i) & 0x1)) {
>> +            buf_id = i;
>> +            break;
>> +        }
>> +    }
>> +
>> +    if (buf_id == GSC_MAX_SRC) {
>> +        DRM_ERROR("failed to get in buffer index.\n");
>> +        return -EIO;
>
> Is this IO error?

- Do you want to EINVAL ?

>
>> +    }
>> +
>> +    if (gsc_src_set_buf_seq(ctx, buf_id, IPP_BUF_DEQUEUE) < 0) {
>> +        DRM_ERROR("failed to dequeue.\n");
>> +        return IRQ_HANDLED;
>
> Is IRQ_HANDLED right return value?

- my missing point. use 'ret' changed it.

>
>> +    }
>> +
>> +    DRM_DEBUG_KMS("%s:cfg[0x%x]curr_index[%d]buf_id[%d]\n", __func__,
>> cfg,
>> +        curr_index, buf_id);
>> +
>> +    return buf_id;
>> +}
>> +
>> +static int gsc_get_dst_buf_index(struct gsc_context *ctx)
>> +{
>> +    u32 cfg, curr_index, i;
>> +    u32 buf_id = GSC_MAX_DST;
>> +
>> +    DRM_DEBUG_KMS("%s:gsc id[%d]\n", __func__, ctx->id);
>> +
>> +    cfg = gsc_read(GSC_OUT_BASE_ADDR_Y_MASK);
>> +    curr_index = GSC_OUT_CURR_GET_INDEX(cfg);
>> +
>> +    for (i = curr_index; i < GSC_MAX_DST; i++) {
>> +        if (!((cfg >> i) & 0x1)) {
>> +            buf_id = i;
>> +            break;
>> +        }
>> +    }
>> +
>> +    if (buf_id == GSC_MAX_DST) {
>> +        DRM_ERROR("failed to get out buffer index.\n");
>> +        return -EIO;
>
> Is this IO error?

- EINVAL OK ?

>
>> +    }
>> +
>> +    if (gsc_dst_set_buf_seq(ctx, buf_id, IPP_BUF_DEQUEUE) < 0) {
>> +        DRM_ERROR("failed to dequeue.\n");
>> +        return IRQ_HANDLED;
>
> Is IRQ_HANDLED right return value?

- changed also.

>
>> +    }
>> +
>> +    DRM_DEBUG_KMS("%s:cfg[0x%x]curr_index[%d]buf_id[%d]\n", __func__,
>> cfg,
>> +        curr_index, buf_id);
>> +
>> +    return buf_id;
>> +}
>> +
>> +static irqreturn_t gsc_irq_handler(int irq, void *dev_id)
>> +{
>> +    struct gsc_context *ctx = dev_id;
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
>> +    struct drm_exynos_ipp_event_work *event_work =
>> +        c_node->event_work;
>> +    u32 status;
>> +    int buf_id[EXYNOS_DRM_OPS_MAX];
>> +
>> +    DRM_DEBUG_KMS("%s:gsc id[%d]\n", __func__, ctx->id);
>> +
>> +    status = gsc_read(GSC_IRQ);
>> +    if (status & GSC_IRQ_STATUS_OR_IRQ) {
>> +        dev_err(ippdrv->dev, "occured overflow at %d, status 0x%x.\n",
>> +            ctx->id, status);
>> +        return IRQ_NONE;
>> +    }
>> +
>> +    if (status & GSC_IRQ_STATUS_OR_FRM_DONE) {
>> +        dev_dbg(ippdrv->dev, "occured frame done at %d, status 0x%x.\n",
>> +            ctx->id, status);
>> +
>> +        buf_id[EXYNOS_DRM_OPS_SRC] = gsc_get_src_buf_index(ctx);
>> +        if (buf_id[EXYNOS_DRM_OPS_SRC] < 0)
>> +            return IRQ_HANDLED;
>> +
>> +        buf_id[EXYNOS_DRM_OPS_DST] = gsc_get_dst_buf_index(ctx);
>> +        if (buf_id[EXYNOS_DRM_OPS_DST] < 0)
>> +            return IRQ_HANDLED;
>> +
>> +        DRM_DEBUG_KMS("%s:buf_id_src[%d]buf_id_dst[%d]\n", __func__,
>> +            buf_id[EXYNOS_DRM_OPS_SRC], buf_id[EXYNOS_DRM_OPS_DST]);
>> +
>> +        event_work->ippdrv = ippdrv;
>> +        event_work->buf_id[EXYNOS_DRM_OPS_SRC] =
>> +            buf_id[EXYNOS_DRM_OPS_SRC];
>> +        event_work->buf_id[EXYNOS_DRM_OPS_DST] =
>> +            buf_id[EXYNOS_DRM_OPS_DST];
>> +        queue_work(ippdrv->event_workq,
>> +            (struct work_struct *)event_work);
>> +    }
>> +
>> +    return IRQ_HANDLED;
>> +}
>> +
>> +static int gsc_init_prop_list(struct exynos_drm_ippdrv *ippdrv)
>> +{
>> +    struct drm_exynos_ipp_prop_list *prop_list;
>> +
>> +    DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +    prop_list = kzalloc(sizeof(*prop_list), GFP_KERNEL);
>> +    if (!prop_list) {
>> +        DRM_ERROR("failed to alloc property list.\n");
>> +        return -ENOMEM;
>> +    }
>> +
>> +    /*ToDo : fix supported function list*/
>
> Please remove comments.

- removed it.

>
>> +
>> +    prop_list->version = 1;
>> +    prop_list->writeback = 1;
>> +    prop_list->refresh_min = GSC_REFRESH_MIN;
>> +    prop_list->refresh_max = GSC_REFRESH_MAX;
>> +    prop_list->flip = (1 << EXYNOS_DRM_FLIP_VERTICAL) |
>> +                (1 << EXYNOS_DRM_FLIP_HORIZONTAL);
>> +    prop_list->degree = (1 << EXYNOS_DRM_DEGREE_0) |
>> +                (1 << EXYNOS_DRM_DEGREE_90) |
>> +                (1 << EXYNOS_DRM_DEGREE_180) |
>> +                (1 << EXYNOS_DRM_DEGREE_270);
>> +    prop_list->csc = 1;
>> +    prop_list->crop = 1;
>> +    prop_list->crop_max.hsize = GSC_CROP_MAX;
>> +    prop_list->crop_max.vsize = GSC_CROP_MAX;
>> +    prop_list->crop_min.hsize = GSC_CROP_MIN;
>> +    prop_list->crop_min.vsize = GSC_CROP_MIN;
>> +    prop_list->scale = 1;
>
> Hardcode. There are too much flags in prop_list and they are just 1 bit
> on/off flags,
> so i think you can join them to one variable.

- I want to remain this one. If we use combine flags,
  userland always check bit and operation.
  I don't prefer that.

>
>> +    prop_list->scale_max.hsize = GSC_SCALE_MAX;
>> +    prop_list->scale_max.vsize = GSC_SCALE_MAX;
>> +    prop_list->scale_min.hsize = GSC_SCALE_MIN;
>> +    prop_list->scale_min.vsize = GSC_SCALE_MIN;
>> +
>> +    ippdrv->prop_list = prop_list;
>> +
>> +    return 0;
>> +}
>> +
>> +static int gsc_ippdrv_check_property(struct device *dev,
>> +        struct drm_exynos_ipp_property *property)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    struct drm_exynos_ipp_prop_list *pp = ippdrv->prop_list;
>> +    struct drm_exynos_ipp_config *config;
>> +    struct drm_exynos_pos *pos;
>> +    struct drm_exynos_sz *sz;
>> +    bool swap;
>> +    int i;
>> +
>> +    DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +    for_each_ipp_ops(i) {
>> +        if ((i == EXYNOS_DRM_OPS_SRC) &&
>> +            (property->cmd == IPP_CMD_WB))
>> +            continue;
>> +
>> +        config = &property->config[i];
>> +        pos = &config->pos;
>> +        sz = &config->sz;
>> +
>> +        /* check for flip */
>> +        switch (config->flip) {
>> +        case EXYNOS_DRM_FLIP_NONE:
>> +        case EXYNOS_DRM_FLIP_VERTICAL:
>> +        case EXYNOS_DRM_FLIP_HORIZONTAL:
>> +        case EXYNOS_DRM_FLIP_VERTICAL | EXYNOS_DRM_FLIP_HORIZONTAL:
>> +            /* No problem */
>> +            break;
>> +        default:
>> +            DRM_ERROR("invalid flip.\n");
>> +            goto err_property;
>> +        }
>> +
>> +        /* check for degree */
>> +        switch (config->degree) {
>> +        case EXYNOS_DRM_DEGREE_90:
>> +        case EXYNOS_DRM_DEGREE_270:
>> +            swap = true;
>> +            break;
>> +        case EXYNOS_DRM_DEGREE_0:
>> +        case EXYNOS_DRM_DEGREE_180:
>> +            swap = false;
>> +            break;
>> +        default:
>> +            DRM_ERROR("invalid degree.\n");
>> +            goto err_property;
>> +        }
>> +
>> +        /* check for buffer bound */
>> +        if ((pos->x + pos->w > sz->hsize) ||
>> +            (pos->y + pos->h > sz->vsize)) {
>> +            DRM_ERROR("out of buf bound.\n");
>> +            goto err_property;
>> +        }
>> +
>> +        /* check for crop */
>> +        if ((i == EXYNOS_DRM_OPS_SRC) && (pp->crop)) {
>> +            if (swap) {
>> +                if ((pos->h < pp->crop_min.hsize) ||
>> +                    (sz->vsize > pp->crop_max.hsize) ||
>> +                    (pos->w < pp->crop_min.vsize) ||
>> +                    (sz->hsize > pp->crop_max.vsize)) {
>> +                    DRM_ERROR("out of crop size.\n");
>> +                    goto err_property;
>> +                }
>> +            } else {
>> +                if ((pos->w < pp->crop_min.hsize) ||
>> +                    (sz->hsize > pp->crop_max.hsize) ||
>> +                    (pos->h < pp->crop_min.vsize) ||
>> +                    (sz->vsize > pp->crop_max.vsize)) {
>> +                    DRM_ERROR("out of crop size.\n");
>> +                    goto err_property;
>> +                }
>> +            }
>> +        }
>> +
>> +        /* check for scale */
>> +        if ((i == EXYNOS_DRM_OPS_DST) && (pp->scale)) {
>> +            if (swap) {
>> +                if ((pos->h < pp->scale_min.hsize) ||
>> +                    (sz->vsize > pp->scale_max.hsize) ||
>> +                    (pos->w < pp->scale_min.vsize) ||
>> +                    (sz->hsize > pp->scale_max.vsize)) {
>> +                    DRM_ERROR("out of scale size.\n");
>> +                    goto err_property;
>> +                }
>> +            } else {
>> +                if ((pos->w < pp->scale_min.hsize) ||
>> +                    (sz->hsize > pp->scale_max.hsize) ||
>> +                    (pos->h < pp->scale_min.vsize) ||
>> +                    (sz->vsize > pp->scale_max.vsize)) {
>> +                    DRM_ERROR("out of scale size.\n");
>> +                    goto err_property;
>> +                }
>> +            }
>> +        }
>> +    }
>> +
>> +    return 0;
>> +
>> +err_property:
>> +    for_each_ipp_ops(i) {
>> +        if ((i == EXYNOS_DRM_OPS_SRC) &&
>> +            (property->cmd == IPP_CMD_WB))
>> +            continue;
>> +
>> +        config = &property->config[i];
>> +        pos = &config->pos;
>> +        sz = &config->sz;
>> +
>> +        DRM_ERROR("[%s]f[%d]r[%d]pos[%d %d %d %d]sz[%d %d]\n",
>> +            i ? "dst" : "src", config->flip, config->degree,
>> +            pos->x, pos->y, pos->w, pos->h,
>> +            sz->hsize, sz->vsize);
>> +    }
>> +
>> +    return -EINVAL;
>> +}
>> +
>> +
>> +static int gsc_ippdrv_reset(struct device *dev)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct gsc_scaler *sc = &ctx->sc;
>> +    int ret;
>> +
>> +    DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +    /* reset h/w block */
>> +    ret = gsc_sw_reset(ctx);
>> +    if (ret < 0) {
>> +        dev_err(dev, "failed to reset hardware.\n");
>> +        return ret;
>> +    }
>> +
>> +    /* scaler setting */
>> +    memset(&ctx->sc, 0x0, sizeof(ctx->sc));
>> +    sc->range = true;
>> +
>> +    return 0;
>> +}
>> +
>> +static int gsc_check_prepare(struct gsc_context *ctx)
>> +{
>> +    /* ToDo: check prepare using read register */
>> +
>> +    DRM_DEBUG_KMS("%s\n", __func__);
>> +
>> +    return 0;
>> +}
>
> I read your comments but i can't understand why this dummy function
> needs still.
> Please remove and if implement it later, send additional patch.

- removed it. please see the v4 patch.

>
>> +
>> +static int gsc_ippdrv_start(struct device *dev, enum
>> drm_exynos_ipp_cmd cmd)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +    struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd;
>> +    struct drm_exynos_ipp_property *property;
>> +    struct drm_exynos_ipp_config *config;
>> +    struct drm_exynos_pos    img_pos[EXYNOS_DRM_OPS_MAX];
>> +    struct drm_exynos_ipp_set_wb set_wb;
>> +    u32 cfg;
>> +    int ret, i;
>> +
>> +    DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, cmd);
>> +
>> +    if (!c_node) {
>> +        DRM_ERROR("failed to get c_node.\n");
>> +        return -EINVAL;
>> +    }
>> +
>> +    property = &c_node->property;
>> +    if (!property) {
>> +        DRM_ERROR("failed to get property.\n");
>> +        return -EINVAL;
>> +    }
>> +
>> +    ret = gsc_check_prepare(ctx);
>> +    if (ret) {
>> +        dev_err(dev, "failed to check prepare.\n");
>> +        return ret;
>> +    }
>
> Please remove.

- removed it. please see the v4 patch

>
>> +
>> +    gsc_handle_irq(ctx, true, false, true);
>> +
>> +    /* ToDo: window size, prescaler config */
>
> Please remove comment.

- done.

>
>> +    for_each_ipp_ops(i) {
>> +        config = &property->config[i];
>> +        img_pos[i] = config->pos;
>> +    }
>> +
>> +    switch (cmd) {
>> +    case IPP_CMD_M2M:
>> +        /* enable one shot */
>> +        cfg = gsc_read(GSC_ENABLE);
>> +        cfg &= ~(GSC_ENABLE_ON_CLEAR_MASK |
>> +            GSC_ENABLE_CLK_GATE_MODE_MASK);
>> +        cfg |= GSC_ENABLE_ON_CLEAR_ONESHOT;
>> +        gsc_write(cfg, GSC_ENABLE);
>> +
>> +        /* src dma memory */
>> +        cfg = gsc_read(GSC_IN_CON);
>> +        cfg &= ~(GSC_IN_PATH_MASK | GSC_IN_LOCAL_SEL_MASK);
>> +        cfg |= GSC_IN_PATH_MEMORY;
>> +        gsc_write(cfg, GSC_IN_CON);
>> +
>> +        /* dst dma memory */
>> +        cfg = gsc_read(GSC_OUT_CON);
>> +        cfg |= GSC_OUT_PATH_MEMORY;
>> +        gsc_write(cfg, GSC_OUT_CON);
>> +        break;
>> +    case IPP_CMD_WB:
>> +        /* ToDo: need to replace the property structure. */
>> +        set_wb.enable = 1;
>> +        set_wb.refresh = property->refresh_rate;
>> +        gsc_set_gscblk_fimd_wb(ctx, set_wb.enable);
>> +        exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb);
>> +
>> +        /* src local path */
>> +        cfg = readl(GSC_IN_CON);
>> +        cfg &= ~(GSC_IN_PATH_MASK | GSC_IN_LOCAL_SEL_MASK);
>> +        cfg |= (GSC_IN_PATH_LOCAL | GSC_IN_LOCAL_FIMD_WB);
>> +        gsc_write(cfg, GSC_IN_CON);
>> +
>> +        /* dst dma memory */
>> +        cfg = gsc_read(GSC_OUT_CON);
>> +        cfg |= GSC_OUT_PATH_MEMORY;
>> +        gsc_write(cfg, GSC_OUT_CON);
>> +        break;
>> +    case IPP_CMD_OUTPUT:
>> +        /* src dma memory */
>> +        cfg = gsc_read(GSC_IN_CON);
>> +        cfg &= ~(GSC_IN_PATH_MASK | GSC_IN_LOCAL_SEL_MASK);
>> +        cfg |= GSC_IN_PATH_MEMORY;
>> +        gsc_write(cfg, GSC_IN_CON);
>> +
>> +        /* dst local path */
>> +        cfg = gsc_read(GSC_OUT_CON);
>> +        cfg |= GSC_OUT_PATH_MEMORY;
>> +        gsc_write(cfg, GSC_OUT_CON);
>> +        break;
>> +    default:
>> +        ret = -EINVAL;
>> +        dev_err(dev, "invalid operations.\n");
>> +        return ret;
>> +    }
>> +
>> +    ret = gsc_set_prescaler(ctx, &ctx->sc,
>> +        &img_pos[EXYNOS_DRM_OPS_SRC],
>> +        &img_pos[EXYNOS_DRM_OPS_DST]);
>> +    if (ret) {
>> +        dev_err(dev, "failed to set precalser.\n");
>> +        return ret;
>> +    }
>> +
>> +    gsc_set_scaler(ctx, &ctx->sc);
>> +
>> +    cfg = gsc_read(GSC_ENABLE);
>> +    cfg |= GSC_ENABLE_ON;
>> +    gsc_write(cfg, GSC_ENABLE);
>> +
>> +    return 0;
>> +}
>> +
>> +static void gsc_ippdrv_stop(struct device *dev, enum
>> drm_exynos_ipp_cmd cmd)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct drm_exynos_ipp_set_wb set_wb = {0, 0};
>> +    u32 cfg;
>> +
>> +    DRM_DEBUG_KMS("%s:cmd[%d]\n", __func__, cmd);
>> +
>> +    switch (cmd) {
>> +    case IPP_CMD_M2M:
>> +        /* bypass */
>> +        break;
>> +    case IPP_CMD_WB:
>> +        gsc_set_gscblk_fimd_wb(ctx, set_wb.enable);
>> +        exynos_drm_ippnb_send_event(IPP_SET_WRITEBACK, (void *)&set_wb);
>> +        break;
>> +    case IPP_CMD_OUTPUT:
>> +    default:
>> +        dev_err(dev, "invalid operations.\n");
>> +        break;
>> +    }
>> +
>> +    gsc_handle_irq(ctx, false, false, true);
>> +
>> +    /* reset sequence */
>> +    gsc_write(0xff, GSC_OUT_BASE_ADDR_Y_MASK);
>> +    gsc_write(0xff, GSC_OUT_BASE_ADDR_CB_MASK);
>> +    gsc_write(0xff, GSC_OUT_BASE_ADDR_CR_MASK);
>> +
>> +    cfg = gsc_read(GSC_ENABLE);
>> +    cfg &= ~GSC_ENABLE_ON;
>> +    gsc_write(cfg, GSC_ENABLE);
>> +}
>> +
>> +static int __devinit gsc_probe(struct platform_device *pdev)
>> +{
>> +    struct device *dev = &pdev->dev;
>> +    struct gsc_context *ctx;
>> +    struct resource *res;
>> +    struct exynos_drm_ippdrv *ippdrv;
>> +    int ret;
>> +
>> +    ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
>> +    if (!ctx)
>> +        return -ENOMEM;
>> +
>> +    /* clock control */
>> +    ctx->gsc_clk = clk_get(dev, "gscl");
>> +    if (IS_ERR(ctx->gsc_clk)) {
>> +        dev_err(dev, "failed to get gsc clock.\n");
>> +        ret = PTR_ERR(ctx->gsc_clk);
>> +        goto err_ctx;
>> +    }
>> +
>> +    ctx->parent_clk = clk_get(NULL, "aclk_300_gscl");
>> +    if (IS_ERR(ctx->parent_clk)) {
>> +        dev_err(dev, "failed to get parent clock.\n");
>> +        ret = PTR_ERR(ctx->parent_clk);
>> +        clk_put(ctx->gsc_clk);
>> +        goto err_ctx;
>> +    }
>> +
>> +    ctx->child_clk = clk_get(NULL, "dout_aclk_300_gscl");
>> +    if (IS_ERR(ctx->child_clk)) {
>> +        dev_err(dev, "failed to get child clock.\n");
>> +        ret = PTR_ERR(ctx->child_clk);
>> +        clk_put(ctx->gsc_clk);
>> +        clk_put(ctx->parent_clk);
>> +        goto err_ctx;
>> +    }
>
> Why do these clocks need? Please don't decide specific clock source in
> driver.

- we need to parent clk, child clk link at this point if we enable GSC 
block.

>
>> +
>> +    /* resource memory */
>> +    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> +    if (!res) {
>> +        dev_err(dev, "failed to find registers.\n");
>> +        ret = -ENOENT;
>> +        goto err_clk;
>> +    }
>> +
>> +    ctx->regs_res = request_mem_region(res->start, resource_size(res),
>> +                       dev_name(dev));
>> +    if (!ctx->regs_res) {
>> +        dev_err(dev, "failed to claim register region.\n");
>> +        ret = -ENOENT;
>> +        goto err_clk;
>> +    }
>> +
>> +    ctx->regs = ioremap(res->start, resource_size(res));
>> +    if (!ctx->regs) {
>> +        dev_err(dev, "failed to map registers.\n");
>> +        ret = -ENXIO;
>> +        goto err_req_region;
>> +    }
>
> Use devm_request_and_ioremap()

- Why request devm_request_and_ioremap() in this patch.
   I think Exynos DRM module not changed devm_ at current.
   so, I think this patch merge at first.
   and changed it about all Exynos DRM drivers. I think that is better.

>
>> +
>> +    /* resource irq */
>> +    res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
>> +    if (!res) {
>> +        dev_err(dev, "failed to request irq resource.\n");
>> +        ret = -ENOENT;
>> +        goto err_get_regs;
>> +    }
>> +
>> +    ctx->irq = res->start;
>> +    ret = request_threaded_irq(ctx->irq, NULL, gsc_irq_handler,
>> +        IRQF_ONESHOT, "drm_gsc", ctx);
>
> Use devm_request_irq

- ditto.

>
>> +    if (ret < 0) {
>> +        dev_err(dev, "failed to request irq.\n");
>> +        goto err_get_regs;
>> +    }
>> +
>> +    /* context initailization */
>> +    ctx->id = pdev->id;
>> +
>> +    ippdrv = &ctx->ippdrv;
>> +    ippdrv->dev = dev;
>> +    ippdrv->ops[EXYNOS_DRM_OPS_SRC] = &gsc_src_ops;
>> +    ippdrv->ops[EXYNOS_DRM_OPS_DST] = &gsc_dst_ops;
>> +    ippdrv->check_property = gsc_ippdrv_check_property;
>> +    ippdrv->reset = gsc_ippdrv_reset;
>> +    ippdrv->start = gsc_ippdrv_start;
>> +    ippdrv->stop = gsc_ippdrv_stop;
>> +    ret = gsc_init_prop_list(ippdrv);
>> +    if (ret < 0) {
>> +        dev_err(dev, "failed to init property list.\n");
>> +        goto err_get_irq;
>> +    }
>> +
>> +    DRM_DEBUG_KMS("%s:id[%d]ippdrv[0x%x]\n", __func__, ctx->id,
>> +        (int)ippdrv);
>> +
>> +    mutex_init(&ctx->lock);
>> +    platform_set_drvdata(pdev, ctx);
>> +
>> +    pm_runtime_set_active(dev);
>> +    pm_runtime_enable(dev);
>> +
>> +    ret = exynos_drm_ippdrv_register(ippdrv);
>> +    if (ret < 0) {
>> +        dev_err(dev, "failed to register drm gsc device.\n");
>> +        goto err_ippdrv_register;
>> +    }
>> +
>> +    dev_info(&pdev->dev, "drm gsc registered successfully.\n");
>> +
>> +    return 0;
>> +
>> +err_ippdrv_register:
>> +    kfree(ippdrv->prop_list);
>> +    pm_runtime_disable(dev);
>> +    free_irq(ctx->irq, ctx);
>> +err_get_irq:
>> +    free_irq(ctx->irq, ctx);
>> +err_get_regs:
>> +    iounmap(ctx->regs);
>> +err_req_region:
>> +    release_resource(ctx->regs_res);
>> +    kfree(ctx->regs_res);
>> +err_clk:
>> +    clk_put(ctx->child_clk);
>> +    clk_put(ctx->parent_clk);
>> +    clk_put(ctx->gsc_clk);
>> +err_ctx:
>> +    kfree(ctx);
>> +    return ret;
>> +}
>> +
>> +static int __devexit gsc_remove(struct platform_device *pdev)
>> +{
>> +    struct device *dev = &pdev->dev;
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +    struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv;
>> +
>> +    kfree(ippdrv->prop_list);
>> +    exynos_drm_ippdrv_unregister(ippdrv);
>> +    mutex_destroy(&ctx->lock);
>> +
>> +    pm_runtime_set_suspended(dev);
>> +    pm_runtime_disable(dev);
>> +
>> +    free_irq(ctx->irq, ctx);
>> +    iounmap(ctx->regs);
>> +    release_resource(ctx->regs_res);
>> +    kfree(ctx->regs_res);
>> +
>> +    clk_put(ctx->child_clk);
>> +    clk_put(ctx->parent_clk);
>> +    clk_put(ctx->gsc_clk);
>> +
>> +    kfree(ctx);
>> +
>> +    return 0;
>> +}
>> +
>> +#ifdef CONFIG_PM_SLEEP
>> +static int gsc_suspend(struct device *dev)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +
>> +    /* ToDo */
>
> Remove.

- Why? you request to me about above to top.
   so, I moved it. TODO needed

>
>> +
>> +    DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
>> +
>> +    if (pm_runtime_suspended(dev))
>> +        return 0;
>> +
>> +    return gsc_clk_ctrl(ctx, false);
>> +}
>> +
>> +static int gsc_resume(struct device *dev)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +
>> +    /* ToDo */
>
> Ditto.

- ditto.

>
>> +
>> +    DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
>> +
>> +    if (!pm_runtime_suspended(dev))
>> +        return gsc_clk_ctrl(ctx, true);
>> +
>> +    return 0;
>> +}
>> +#endif
>> +
>> +#ifdef CONFIG_PM_RUNTIME
>> +static int gsc_runtime_suspend(struct device *dev)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +
>> +    /* ToDo */
>
> Ditto.

- ditto.

>
>> +
>> +    DRM_DEBUG_KMS("%s:id[%d]\n", __func__, ctx->id);
>> +
>> +    return  gsc_clk_ctrl(ctx, false);
>> +}
>> +
>> +static int gsc_runtime_resume(struct device *dev)
>> +{
>> +    struct gsc_context *ctx = get_gsc_context(dev);
>> +
>> +    /* ToDo */
>
> Ditto.

- ditto.

>
>> +
>> +    DRM_DEBUG_KMS("%s:id[%d]\n", __FILE__, ctx->id);
>> +
>> +    return  gsc_clk_ctrl(ctx, true);
>
> If runtime PM isn't enabled, how do you control clock?

- Good point. hmm ~ what is standard ? please recommand your knowledge 
to me.

>
>> +}
>> +#endif
>> +
>> +static const struct dev_pm_ops gsc_pm_ops = {
>> +    SET_SYSTEM_SLEEP_PM_OPS(gsc_suspend, gsc_resume)
>> +    SET_RUNTIME_PM_OPS(gsc_runtime_suspend, gsc_runtime_resume, NULL)
>> +};
>> +
>> +/* ToDo: need to check use case platform_device_id */
>
> Use "TODO" instead of "ToDo".

- removed it.

>
>> +struct platform_driver gsc_driver = {
>> +    .probe        = gsc_probe,
>> +    .remove        = __devexit_p(gsc_remove),
>> +    .driver        = {
>> +        .name    = "exynos-drm-gsc",
>> +        .owner    = THIS_MODULE,
>> +        .pm    = &gsc_pm_ops,
>> +    },
>> +};
>> +
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.h
>> b/drivers/gpu/drm/exynos/exynos_drm_gsc.h
>> new file mode 100644
>> index 0000000..b3ef7a0
>> --- /dev/null
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.h
>> @@ -0,0 +1,34 @@
>> +/*
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *
>> + * Authors:
>> + *    Eunchul Kim <chulspro.kim@samsung.com>
>> + *    Jinyoung Jeon <jy0.jeon@samsung.com>
>> + *    Sangmin Lee <lsmin.lee@samsung.com>
>> + *
>> + * Permission is hereby granted, free of charge, to any person
>> obtaining a
>> + * copy of this software and associated documentation files (the
>> "Software"),
>> + * to deal in the Software without restriction, including without
>> limitation
>> + * the rights to use, copy, modify, merge, publish, distribute,
>> sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including
>> the next
>> + * paragraph) shall be included in all copies or substantial portions
>> of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
>> EXPRESS OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
>> MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT
>> SHALL
>> + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
>> DAMAGES OR
>> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
>> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
>> + * OTHER DEALINGS IN THE SOFTWARE.
>> + */
>> +
>> +#ifndef _EXYNOS_DRM_GSC_H_
>> +#define _EXYNOS_DRM_GSC_H_
>> +
>> +/* ToDo */
>> +
>
> Please remove this dummy header file.

- I want to finish file creation in this patch.
   We need to link with MIxer so, I prepared it.

>
>> +#endif /* _EXYNOS_DRM_GSC_H_ */
>> diff --git a/drivers/gpu/drm/exynos/regs-gsc.h
>> b/drivers/gpu/drm/exynos/regs-gsc.h
>> new file mode 100644
>> index 0000000..ed297b5
>> --- /dev/null
>> +++ b/drivers/gpu/drm/exynos/regs-gsc.h
>> @@ -0,0 +1,295 @@
>> +/* linux/drivers/gpu/drm/exynos/regs-gsc.h
>> + *
>> + * Copyright (c) 2012 Samsung Electronics Co., Ltd.
>> + *        http://www.samsung.com
>> + *
>> + * Register definition file for Samsung G-Scaler driver
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +
>> +#ifndef EXYNOS_REGS_GSC_H_
>> +#define EXYNOS_REGS_GSC_H_
>> +
>> +/* SYSCON. GSCBLK_CFG */
>> +#include <plat/map-base.h>
>> +#include <plat/cpu.h>
>> +#define SYSREG_DISP1BLK_CFG        (S3C_VA_SYS + 0x0214)
>> +#define FIFORST_DISP1            (1 << 23)
>> +#define GSC_OUT_MIXER0            (1 << 7)
>> +#define GSC_OUT_MIXER0_GSC3        (3 << 5)
>> +#define SYSREG_GSCBLK_CFG0        (S3C_VA_SYS + 0x0220)
>> +#define GSC_OUT_DST_FIMD_SEL(x)        (1 << (8 + 2 * (x)))
>> +#define GSC_OUT_DST_MXR_SEL(x)        (2 << (8 + 2 * (x)))
>> +#define GSC_PXLASYNC_RST(x)        (1 << (x))
>> +#define PXLASYNC_LO_MASK_CAMIF_TOP    (1 << 20)
>> +#define SYSREG_GSCBLK_CFG1        (S3C_VA_SYS + 0x0224)
>> +#define GSC_BLK_DISP1WB_DEST(x)        (x << 10)
>> +#define GSC_BLK_SW_RESET_WB_DEST(x)    (1 << (18 + x))
>> +#define GSC_BLK_PXLASYNC_LO_MASK_WB(x)    (0 << (14 + x))
>> +#define GSC_BLK_GSCL_WB_IN_SRC_SEL(x)    (1 << (2 * x))
>> +#define SYSREG_GSCBLK_CFG2        (S3C_VA_SYS + 0x2000)
>> +#define PXLASYNC_LO_MASK_CAMIF_GSCL(x)    (1 << (x))
>> +
>> +/* G-Scaler enable */
>> +#define GSC_ENABLE            0x00
>> +#define GSC_ENABLE_PP_UPDATE_TIME_MASK    (1 << 9)
>> +#define GSC_ENABLE_PP_UPDATE_TIME_CURR    (0 << 9)
>> +#define GSC_ENABLE_PP_UPDATE_TIME_EOPAS    (1 << 9)
>> +#define GSC_ENABLE_CLK_GATE_MODE_MASK    (1 << 8)
>> +#define GSC_ENABLE_CLK_GATE_MODE_FREE    (1 << 8)
>> +#define GSC_ENABLE_IPC_MODE_MASK    (1 << 7)
>> +#define GSC_ENABLE_NORM_MODE        (0 << 7)
>> +#define GSC_ENABLE_IPC_MODE        (1 << 7)
>> +#define GSC_ENABLE_PP_UPDATE_MODE_MASK    (1 << 6)
>> +#define GSC_ENABLE_PP_UPDATE_FIRE_MODE    (1 << 6)
>> +#define GSC_ENABLE_IN_PP_UPDATE        (1 << 5)
>> +#define GSC_ENABLE_ON_CLEAR_MASK    (1 << 4)
>> +#define GSC_ENABLE_ON_CLEAR_ONESHOT    (1 << 4)
>> +#define GSC_ENABLE_QOS_ENABLE        (1 << 3)
>> +#define GSC_ENABLE_OP_STATUS        (1 << 2)
>> +#define GSC_ENABLE_SFR_UPDATE        (1 << 1)
>> +#define GSC_ENABLE_ON            (1 << 0)
>> +
>> +/* G-Scaler S/W reset */
>> +#define GSC_SW_RESET            0x04
>> +#define GSC_SW_RESET_SRESET        (1 << 0)
>> +
>> +/* G-Scaler IRQ */
>> +#define GSC_IRQ                0x08
>> +#define GSC_IRQ_STATUS_OR_IRQ        (1 << 17)
>> +#define GSC_IRQ_STATUS_OR_FRM_DONE    (1 << 16)
>> +#define GSC_IRQ_OR_MASK            (1 << 2)
>> +#define GSC_IRQ_FRMDONE_MASK        (1 << 1)
>> +#define GSC_IRQ_ENABLE            (1 << 0)
>> +
>> +/* G-Scaler input control */
>> +#define GSC_IN_CON            0x10
>> +#define GSC_IN_CHROM_STRIDE_SEL_MASK    (1 << 20)
>> +#define GSC_IN_CHROM_STRIDE_SEPAR    (1 << 20)
>> +#define GSC_IN_RB_SWAP_MASK        (1 << 19)
>> +#define GSC_IN_RB_SWAP            (1 << 19)
>> +#define GSC_IN_ROT_MASK            (7 << 16)
>> +#define GSC_IN_ROT_270            (7 << 16)
>> +#define GSC_IN_ROT_90_YFLIP        (6 << 16)
>> +#define GSC_IN_ROT_90_XFLIP        (5 << 16)
>> +#define GSC_IN_ROT_90            (4 << 16)
>> +#define GSC_IN_ROT_180            (3 << 16)
>> +#define GSC_IN_ROT_YFLIP        (2 << 16)
>> +#define GSC_IN_ROT_XFLIP        (1 << 16)
>> +#define GSC_IN_RGB_TYPE_MASK        (3 << 14)
>> +#define GSC_IN_RGB_HD_WIDE        (3 << 14)
>> +#define GSC_IN_RGB_HD_NARROW        (2 << 14)
>> +#define GSC_IN_RGB_SD_WIDE        (1 << 14)
>> +#define GSC_IN_RGB_SD_NARROW        (0 << 14)
>> +#define GSC_IN_YUV422_1P_ORDER_MASK    (1 << 13)
>> +#define GSC_IN_YUV422_1P_ORDER_LSB_Y    (0 << 13)
>> +#define GSC_IN_YUV422_1P_OEDER_LSB_C    (1 << 13)
>> +#define GSC_IN_CHROMA_ORDER_MASK    (1 << 12)
>> +#define GSC_IN_CHROMA_ORDER_CBCR    (0 << 12)
>> +#define GSC_IN_CHROMA_ORDER_CRCB    (1 << 12)
>> +#define GSC_IN_FORMAT_MASK        (7 << 8)
>> +#define GSC_IN_XRGB8888            (0 << 8)
>> +#define GSC_IN_RGB565            (1 << 8)
>> +#define GSC_IN_YUV420_2P        (2 << 8)
>> +#define GSC_IN_YUV420_3P        (3 << 8)
>> +#define GSC_IN_YUV422_1P        (4 << 8)
>> +#define GSC_IN_YUV422_2P        (5 << 8)
>> +#define GSC_IN_YUV422_3P        (6 << 8)
>> +#define GSC_IN_TILE_TYPE_MASK        (1 << 4)
>> +#define GSC_IN_TILE_C_16x8        (0 << 4)
>> +#define GSC_IN_TILE_C_16x16        (1 << 4)
>> +#define GSC_IN_TILE_MODE        (1 << 3)
>> +#define GSC_IN_LOCAL_SEL_MASK        (3 << 1)
>> +#define GSC_IN_LOCAL_CAM3        (3 << 1)
>> +#define GSC_IN_LOCAL_FIMD_WB        (2 << 1)
>> +#define GSC_IN_LOCAL_CAM1        (1 << 1)
>> +#define GSC_IN_LOCAL_CAM0        (0 << 1)
>> +#define GSC_IN_PATH_MASK        (1 << 0)
>> +#define GSC_IN_PATH_LOCAL        (1 << 0)
>> +#define GSC_IN_PATH_MEMORY        (0 << 0)
>> +
>> +/* G-Scaler source image size */
>> +#define GSC_SRCIMG_SIZE            0x14
>> +#define GSC_SRCIMG_HEIGHT_MASK        (0x1fff << 16)
>> +#define GSC_SRCIMG_HEIGHT(x)        ((x) << 16)
>> +#define GSC_SRCIMG_WIDTH_MASK        (0x3fff << 0)
>> +#define GSC_SRCIMG_WIDTH(x)        ((x) << 0)
>> +
>> +/* G-Scaler source image offset */
>> +#define GSC_SRCIMG_OFFSET        0x18
>> +#define GSC_SRCIMG_OFFSET_Y_MASK    (0x1fff << 16)
>> +#define GSC_SRCIMG_OFFSET_Y(x)        ((x) << 16)
>> +#define GSC_SRCIMG_OFFSET_X_MASK    (0x1fff << 0)
>> +#define GSC_SRCIMG_OFFSET_X(x)        ((x) << 0)
>> +
>> +/* G-Scaler cropped source image size */
>> +#define GSC_CROPPED_SIZE        0x1C
>> +#define GSC_CROPPED_HEIGHT_MASK        (0x1fff << 16)
>> +#define GSC_CROPPED_HEIGHT(x)        ((x) << 16)
>> +#define GSC_CROPPED_WIDTH_MASK        (0x1fff << 0)
>> +#define GSC_CROPPED_WIDTH(x)        ((x) << 0)
>> +
>> +/* G-Scaler output control */
>> +#define GSC_OUT_CON            0x20
>> +#define GSC_OUT_GLOBAL_ALPHA_MASK    (0xff << 24)
>> +#define GSC_OUT_GLOBAL_ALPHA(x)        ((x) << 24)
>> +#define GSC_OUT_CHROM_STRIDE_SEL_MASK    (1 << 13)
>> +#define GSC_OUT_CHROM_STRIDE_SEPAR    (1 << 13)
>> +#define GSC_OUT_RB_SWAP_MASK        (1 << 12)
>> +#define GSC_OUT_RB_SWAP            (1 << 12)
>> +#define GSC_OUT_RGB_TYPE_MASK        (3 << 10)
>> +#define GSC_OUT_RGB_HD_NARROW        (3 << 10)
>> +#define GSC_OUT_RGB_HD_WIDE        (2 << 10)
>> +#define GSC_OUT_RGB_SD_NARROW        (1 << 10)
>> +#define GSC_OUT_RGB_SD_WIDE        (0 << 10)
>> +#define GSC_OUT_YUV422_1P_ORDER_MASK    (1 << 9)
>> +#define GSC_OUT_YUV422_1P_ORDER_LSB_Y    (0 << 9)
>> +#define GSC_OUT_YUV422_1P_OEDER_LSB_C    (1 << 9)
>> +#define GSC_OUT_CHROMA_ORDER_MASK    (1 << 8)
>> +#define GSC_OUT_CHROMA_ORDER_CBCR    (0 << 8)
>> +#define GSC_OUT_CHROMA_ORDER_CRCB    (1 << 8)
>> +#define GSC_OUT_FORMAT_MASK        (7 << 4)
>> +#define GSC_OUT_XRGB8888        (0 << 4)
>> +#define GSC_OUT_RGB565            (1 << 4)
>> +#define GSC_OUT_YUV420_2P        (2 << 4)
>> +#define GSC_OUT_YUV420_3P        (3 << 4)
>> +#define GSC_OUT_YUV422_1P        (4 << 4)
>> +#define GSC_OUT_YUV422_2P        (5 << 4)
>> +#define GSC_OUT_YUV444            (7 << 4)
>> +#define GSC_OUT_TILE_TYPE_MASK        (1 << 2)
>> +#define GSC_OUT_TILE_C_16x8        (0 << 2)
>> +#define GSC_OUT_TILE_C_16x16        (1 << 2)
>> +#define GSC_OUT_TILE_MODE        (1 << 1)
>> +#define GSC_OUT_PATH_MASK        (1 << 0)
>> +#define GSC_OUT_PATH_LOCAL        (1 << 0)
>> +#define GSC_OUT_PATH_MEMORY        (0 << 0)
>> +
>> +/* G-Scaler scaled destination image size */
>> +#define GSC_SCALED_SIZE            0x24
>> +#define GSC_SCALED_HEIGHT_MASK        (0x1fff << 16)
>> +#define GSC_SCALED_HEIGHT(x)        ((x) << 16)
>> +#define GSC_SCALED_WIDTH_MASK        (0x1fff << 0)
>> +#define GSC_SCALED_WIDTH(x)        ((x) << 0)
>> +
>> +/* G-Scaler pre scale ratio */
>> +#define GSC_PRE_SCALE_RATIO        0x28
>> +#define GSC_PRESC_SHFACTOR_MASK        (7 << 28)
>> +#define GSC_PRESC_SHFACTOR(x)        ((x) << 28)
>> +#define GSC_PRESC_V_RATIO_MASK        (7 << 16)
>> +#define GSC_PRESC_V_RATIO(x)        ((x) << 16)
>> +#define GSC_PRESC_H_RATIO_MASK        (7 << 0)
>> +#define GSC_PRESC_H_RATIO(x)        ((x) << 0)
>> +
>> +/* G-Scaler main scale horizontal ratio */
>> +#define GSC_MAIN_H_RATIO        0x2C
>> +#define GSC_MAIN_H_RATIO_MASK        (0xfffff << 0)
>> +#define GSC_MAIN_H_RATIO_VALUE(x)    ((x) << 0)
>> +
>> +/* G-Scaler main scale vertical ratio */
>> +#define GSC_MAIN_V_RATIO        0x30
>> +#define GSC_MAIN_V_RATIO_MASK        (0xfffff << 0)
>> +#define GSC_MAIN_V_RATIO_VALUE(x)    ((x) << 0)
>> +
>> +/* G-Scaler input chrominance stride */
>> +#define GSC_IN_CHROM_STRIDE        0x3C
>> +#define GSC_IN_CHROM_STRIDE_MASK    (0x3fff << 0)
>> +#define GSC_IN_CHROM_STRIDE_VALUE(x)    ((x) << 0)
>> +
>> +/* G-Scaler destination image size */
>> +#define GSC_DSTIMG_SIZE            0x40
>> +#define GSC_DSTIMG_HEIGHT_MASK        (0x1fff << 16)
>> +#define GSC_DSTIMG_HEIGHT(x)        ((x) << 16)
>> +#define GSC_DSTIMG_WIDTH_MASK        (0x1fff << 0)
>> +#define GSC_DSTIMG_WIDTH(x)        ((x) << 0)
>> +
>> +/* G-Scaler destination image offset */
>> +#define GSC_DSTIMG_OFFSET        0x44
>> +#define GSC_DSTIMG_OFFSET_Y_MASK    (0x1fff << 16)
>> +#define GSC_DSTIMG_OFFSET_Y(x)        ((x) << 16)
>> +#define GSC_DSTIMG_OFFSET_X_MASK    (0x1fff << 0)
>> +#define GSC_DSTIMG_OFFSET_X(x)        ((x) << 0)
>> +
>> +/* G-Scaler output chrominance stride */
>> +#define GSC_OUT_CHROM_STRIDE        0x48
>> +#define GSC_OUT_CHROM_STRIDE_MASK    (0x3fff << 0)
>> +#define GSC_OUT_CHROM_STRIDE_VALUE(x)    ((x) << 0)
>> +
>> +/* G-Scaler input y address mask */
>> +#define GSC_IN_BASE_ADDR_Y_MASK        0x4C
>> +/* G-Scaler input y base address */
>> +#define GSC_IN_BASE_ADDR_Y(n)        (0x50 + (n) * 0x4)
>> +/* G-Scaler input y base current address */
>> +#define GSC_IN_BASE_ADDR_Y_CUR(n)    (0x60 + (n) * 0x4)
>> +
>> +/* G-Scaler input cb address mask */
>> +#define GSC_IN_BASE_ADDR_CB_MASK    0x7C
>> +/* G-Scaler input cb base address */
>> +#define GSC_IN_BASE_ADDR_CB(n)        (0x80 + (n) * 0x4)
>> +/* G-Scaler input cb base current address */
>> +#define GSC_IN_BASE_ADDR_CB_CUR(n)    (0x90 + (n) * 0x4)
>> +
>> +/* G-Scaler input cr address mask */
>> +#define GSC_IN_BASE_ADDR_CR_MASK    0xAC
>> +/* G-Scaler input cr base address */
>> +#define GSC_IN_BASE_ADDR_CR(n)        (0xB0 + (n) * 0x4)
>> +/* G-Scaler input cr base current address */
>> +#define GSC_IN_BASE_ADDR_CR_CUR(n)    (0xC0 + (n) * 0x4)
>> +
>> +/* G-Scaler input address mask */
>> +#define GSC_IN_CURR_ADDR_INDEX    (0xf << 24)
>> +#define GSC_IN_CURR_GET_INDEX(x)    ((x) >> 24)
>> +#define GSC_IN_BASE_ADDR_PINGPONG(x)    ((x) << 16)
>> +#define GSC_IN_BASE_ADDR_MASK        (0xff << 0)
>> +
>> +/* G-Scaler output y address mask */
>> +#define GSC_OUT_BASE_ADDR_Y_MASK    0x10C
>> +/* G-Scaler output y base address */
>> +#define GSC_OUT_BASE_ADDR_Y(n)        (0x110 + (n) * 0x4)
>> +
>> +/* G-Scaler output cb address mask */
>> +#define GSC_OUT_BASE_ADDR_CB_MASK    0x15C
>> +/* G-Scaler output cb base address */
>> +#define GSC_OUT_BASE_ADDR_CB(n)        (0x160 + (n) * 0x4)
>> +
>> +/* G-Scaler output cr address mask */
>> +#define GSC_OUT_BASE_ADDR_CR_MASK    0x1AC
>> +/* G-Scaler output cr base address */
>> +#define GSC_OUT_BASE_ADDR_CR(n)        (0x1B0 + (n) * 0x4)
>> +
>> +/* G-Scaler output address mask */
>> +#define GSC_OUT_CURR_ADDR_INDEX        (0xf << 24)
>> +#define GSC_OUT_CURR_GET_INDEX(x)    ((x) >> 24)
>> +#define GSC_OUT_BASE_ADDR_PINGPONG(x)    ((x) << 16)
>> +#define GSC_OUT_BASE_ADDR_MASK        (0xffff << 0)
>> +
>> +/* G-Scaler horizontal scaling filter */
>> +#define GSC_HCOEF(n, s, x)    (0x300 + (n) * 0x4 + (s) * 0x30 + (x) *
>> 0x300)
>> +
>> +/* G-Scaler vertical scaling filter */
>> +#define GSC_VCOEF(n, s, x)    (0x200 + (n) * 0x4 + (s) * 0x30 + (x) *
>> 0x300)
>> +
>> +/* G-Scaler BUS control */
>> +#define GSC_BUSCON            0xA78
>> +#define GSC_BUSCON_INT_TIME_MASK    (1 << 8)
>> +#define GSC_BUSCON_INT_DATA_TRANS    (0 << 8)
>> +#define GSC_BUSCON_INT_AXI_RESPONSE    (1 << 8)
>> +#define GSC_BUSCON_AWCACHE(x)        ((x) << 4)
>> +#define GSC_BUSCON_ARCACHE(x)        ((x) << 0)
>> +
>> +/* G-Scaler V position */
>> +#define GSC_VPOSITION            0xA7C
>> +#define GSC_VPOS_F(x)            ((x) << 0)
>> +
>> +
>> +/* G-Scaler clock initial count */
>> +#define GSC_CLK_INIT_COUNT        0xC00
>> +#define GSC_CLK_GATE_MODE_INIT_CNT(x)    ((x) << 0)
>> +
>> +/* G-Scaler clock snoop count */
>> +#define GSC_CLK_SNOOP_COUNT        0xC04
>> +#define GSC_CLK_GATE_MODE_SNOOP_CNT(x)    ((x) << 0)
>> +
>> +#endif /* EXYNOS_REGS_GSC_H_ */
>
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2012-12-14  5:29 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-12  7:34 [RFC v3 0/5] drm/exynos: add ipp subsystem and each ipp drivers Eunchul Kim
2012-12-12  7:34 ` [RFC v3 1/5] drm/exynos: add ipp subsystem Eunchul Kim
2012-12-12  8:18   ` Inki Dae
2012-12-12  9:02     ` Eunchul Kim
2012-12-12  7:34 ` [RFC v3 2/5] drm/exynos: add iommu support for ipp Eunchul Kim
2012-12-12  7:34 ` [RFC v3 3/5] drm/exynos: add fimc ipp driver Eunchul Kim
2012-12-12  7:34 ` [RFC v3 4/5] drm/exynos: add rotator " Eunchul Kim
2012-12-12  8:29   ` Inki Dae
2012-12-12  9:26     ` Eunchul Kim
2012-12-12  9:41       ` Inki Dae
2012-12-12 10:00         ` Inki Dae
2012-12-12 10:39           ` Inki Dae
2012-12-12 10:51             ` Eunchul Kim
2012-12-12  9:46       ` Inki Dae
2012-12-12 11:10         ` Eunchul Kim
2012-12-12  7:34 ` [RFC v3 5/5] drm/exynos: add gsc " Eunchul Kim
2012-12-13  2:29   ` Joonyoung Shim
2012-12-14  5:29     ` Eunchul Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).