From 7cb8ed8d13145ec031a7aa8771956b2f4a3c8978 Mon Sep 17 00:00:00 2001
From: Hardik Shah <hardik.shah@ti.com>
Date: Thu, 2 Apr 2009 17:03:34 +0530
Subject: [PATCH 1/1] DSS2: OMAPFB: Changed to support YUV VRFB rotation.

DSS2 requires the rotation_type to be passed by driver

Signed-off-by: Hardik Shah <hardik.shah@ti.com>
---
 drivers/video/omap2/omapfb/omapfb-main.c |   31 +++++++++++++++--------------
 drivers/video/omap2/omapfb/omapfb.h      |    7 +-----
 2 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
index ad2f0e3..e3fc71f 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -176,7 +176,7 @@ static unsigned omapfb_get_vrfb_offset(struct omapfb_info *ofbi, int rot)
 
 static u32 omapfb_get_region_rot_paddr(struct omapfb_info *ofbi)
 {
-	if (ofbi->rotation_type == OMAPFB_ROT_VRFB) {
+	if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
 		unsigned offset;
 		int rot;
 
@@ -192,7 +192,7 @@ static u32 omapfb_get_region_rot_paddr(struct omapfb_info *ofbi)
 
 u32 omapfb_get_region_paddr(struct omapfb_info *ofbi)
 {
-	if (ofbi->rotation_type == OMAPFB_ROT_VRFB)
+	if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
 		return ofbi->region.vrfb.paddr[0];
 	else
 		return ofbi->region.paddr;
@@ -200,7 +200,7 @@ u32 omapfb_get_region_paddr(struct omapfb_info *ofbi)
 
 void __iomem *omapfb_get_region_vaddr(struct omapfb_info *ofbi)
 {
-	if (ofbi->rotation_type == OMAPFB_ROT_VRFB)
+	if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
 		return ofbi->region.vrfb.vaddr[0];
 	else
 		return ofbi->region.vaddr;
@@ -383,7 +383,7 @@ void set_fb_fix(struct fb_info *fbi)
 	fbi->screen_base = (char __iomem *)omapfb_get_region_vaddr(ofbi);
 
 	/* used by mmap in fbmem.c */
-	if (ofbi->rotation_type == OMAPFB_ROT_VRFB)
+	if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
 		fix->line_length =
 			(OMAP_VRFB_LINE_LEN * var->bits_per_pixel) >> 3;
 	else
@@ -420,7 +420,7 @@ void set_fb_fix(struct fb_info *fbi)
 	fix->ypanstep = 1;
 
 	if (rg->size) {
-		if (ofbi->rotation_type == OMAPFB_ROT_VRFB)
+		if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
 			omap_vrfb_setup(&rg->vrfb, rg->paddr,
 					var->xres_virtual, var->yres_virtual,
 					var->bits_per_pixel >> 3);
@@ -512,7 +512,7 @@ int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var)
 	if (var->yres > var->yres_virtual)
 		var->yres = var->yres_virtual;
 
-	if (ofbi->rotation_type == OMAPFB_ROT_VRFB)
+	if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
 		line_size = OMAP_VRFB_LINE_LEN * bytespp;
 	else
 		line_size = var->xres_virtual * bytespp;
@@ -534,7 +534,7 @@ int check_fb_var(struct fb_info *fbi, struct fb_var_screeninfo *var)
 
 	if (line_size * var->yres_virtual > max_frame_size) {
 		DBG("can't fit FB into memory, reducing x\n");
-		if (ofbi->rotation_type == OMAPFB_ROT_VRFB)
+		if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB)
 			return -EINVAL;
 
 		var->xres_virtual = max_frame_size / var->yres_virtual /
@@ -673,7 +673,7 @@ static int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl,
 	offset = ((var->yoffset * var->xres_virtual +
 				var->xoffset) * var->bits_per_pixel) >> 3;
 
-	if (ofbi->rotation_type == OMAPFB_ROT_VRFB) {
+	if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
 		data_start_p = omapfb_get_region_rot_paddr(ofbi);
 		data_start_v = NULL;
 	} else {
@@ -695,8 +695,8 @@ static int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl,
 
 	ovl->get_overlay_info(ovl, &info);
 
-	if (ofbi->rotation_type == OMAPFB_ROT_VRFB) {
-		rot = 0;
+	if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
+		rot = ofbi->rotation;
 		mirror = 0;
 	} else {
 		rot = ofbi->rotation;
@@ -709,6 +709,7 @@ static int omapfb_setup_overlay(struct fb_info *fbi, struct omap_overlay *ovl,
 	info.width = xres;
 	info.height = yres;
 	info.color_mode = mode;
+	info.rotation_type = ofbi->rotation_type;
 	info.rotation = rot;
 	info.mirror = mirror;
 
@@ -1106,7 +1107,7 @@ static void omapfb_free_fbmem(struct fb_info *fbi)
 	if (rg->vaddr)
 		iounmap(rg->vaddr);
 
-	if (ofbi->rotation_type == OMAPFB_ROT_VRFB) {
+	if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
 		/* unmap the 0 angle rotation */
 		if (rg->vrfb.vaddr[0]) {
 			iounmap(rg->vrfb.vaddr[0]);
@@ -1166,7 +1167,7 @@ static int omapfb_alloc_fbmem(struct fb_info *fbi, unsigned long size,
 		return -ENOMEM;
 	}
 
-	if (ofbi->rotation_type != OMAPFB_ROT_VRFB) {
+	if (ofbi->rotation_type != OMAP_DSS_ROT_VRFB) {
 		vaddr = ioremap_wc(paddr, size);
 
 		if (!vaddr) {
@@ -1244,7 +1245,7 @@ static int omapfb_alloc_fbmem_display(struct fb_info *fbi, unsigned long size,
 
 		display->get_resolution(display, &w, &h);
 
-		if (ofbi->rotation_type == OMAPFB_ROT_VRFB) {
+		if (ofbi->rotation_type == OMAP_DSS_ROT_VRFB) {
 			int oldw = w, oldh = h;
 
 			omap_vrfb_adjust_size(&w, &h, bytespp);
@@ -1593,8 +1594,8 @@ static int omapfb_create_framebuffers(struct omapfb2_device *fbdev)
 		ofbi->id = i;
 
 		/* assign these early, so that fb alloc can use them */
-		ofbi->rotation_type = def_vrfb ? OMAPFB_ROT_VRFB :
-			OMAPFB_ROT_DMA;
+		ofbi->rotation_type = def_vrfb ? OMAP_DSS_ROT_VRFB :
+			OMAP_DSS_ROT_DMA;
 		ofbi->rotation = def_rotate;
 		ofbi->mirror = def_mirror;
 
diff --git a/drivers/video/omap2/omapfb/omapfb.h b/drivers/video/omap2/omapfb/omapfb.h
index 65e9e6e..88e7675 100644
--- a/drivers/video/omap2/omapfb/omapfb.h
+++ b/drivers/video/omap2/omapfb/omapfb.h
@@ -51,11 +51,6 @@ struct omapfb2_mem_region {
 	bool		map;		/* kernel mapped by the driver */
 };
 
-enum omapfb_rotation_type {
-	OMAPFB_ROT_DMA = 0,
-	OMAPFB_ROT_VRFB = 1,
-};
-
 /* appended to fb_info */
 struct omapfb_info {
 	int id;
@@ -64,7 +59,7 @@ struct omapfb_info {
 	int num_overlays;
 	struct omap_overlay *overlays[OMAPFB_MAX_OVL_PER_FB];
 	struct omapfb2_device *fbdev;
-	enum omapfb_rotation_type rotation_type;
+	enum omap_dss_rotation_type rotation_type;
 	u8 rotation;
 	bool mirror;
 };
-- 
1.6.0.3

