Skip to contentSkip to conversation

Patch to enable omapfb scaling

PATCH Tuomas Kulve 2 participants 3 messages Oct 31, 2008 – Nov 26, 2008 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

Hi

The attached patch enables omapfb scaling. Tested on omap3 based beagleboard with 2.6.27-omap1 kernel from linux-omap kernel tree.

The "if" is a leftover from this commit in linux-omap tree:
4139f42ea612e0ff53a4df41428040f777d0422c

Thanks,

Signature · 4 lines
Tuomas Kulve, Movial Creative Technologies Inc.
Porkkalankatu 13J, FI-00180 Helsinki
Fax +358 9 8567 6401, Tel +358 9 8567 6400
www.movial.com

From 886ddb31a1192fc324f1bc092766c918c5fd22fb Mon Sep 17 00:00:00 2001
From: Tuomas Kulve <[email protected]>
Date: Wed, 29 Oct 2008 10:54:06 +0200
Subject: [PATCH] Removed old contradictory leftover 'if' that prevents video scaling.

---
 drivers/video/omap/dispc.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
drivers/video/omap/dispc.c +0 -3
index 1e6e035..68bc887 100644
@@ -583,9 +583,6 @@ static int omap_dispc_set_scale(int plane,
 	if ((unsigned)plane > OMAPFB_PLANE_NUM)
 		return -ENODEV;
 
-	if (out_width != orig_width || out_height != orig_height)
-		return -EINVAL;
-
 	enable_lcd_clocks(1);
 	if (orig_width < out_width) {
 		/*
Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 4 lines · Tuomas Kulve

Hi

The attached patch enables omapfb scaling. Tested on omap3 based beagleboard with 2.6.27-omap1 kernel from linux-omap kernel tree.

The 0002 patch implements downscaling in omapfb. It seems to work on ES3.0 beagleboard and ES2.1 EVM but not on my rev B5 beagleboard.

The patch still needs cleanup but it should work with e.g. X.Org's XV extension:

http://gitweb.pingu.fi/?p=xf86-video-omapfb.git;a=summary

Signature · 4 lines
Tuomas Kulve, Movial Creative Technologies Inc.
Porkkalankatu 13J, FI-00180 Helsinki
Fax +358 9 8567 6401, Tel +358 9 8567 6400
www.movial.com

From 069ce763b1a7e936b7b2bdc288d94dd98e477d7e Mon Sep 17 00:00:00 2001
From: Tuomas Kulve <[email protected]>
Date: Mon, 3 Nov 2008 11:22:56 +0200
Subject: [PATCH] Implemented video downsampling in omapfb.

---
 drivers/video/omap/dispc.c |   58 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 53 insertions(+), 5 deletions(-)
drivers/video/omap/dispc.c +53 -5
index 68bc887..83f37bf 100644
@@ -545,6 +545,17 @@ static void write_firhv_reg(int plane, int reg, u32 value)
 	dispc_write_reg(base + reg * 8,	value);
 }
 
+static void write_firv_reg(int plane, int reg, u32 value)
+{
+	u32 base;
+
+	if (plane == 1)
+		base = 0x1E0;
+	else
+		base = 0x1E0 + 0x20;
+	dispc_write_reg(base + reg * 4,	value);
+}
+
 static void set_upsampling_coef_table(int plane)
 {
 	const u32 coef[][2] = {
@@ -565,6 +576,27 @@ static void set_upsampling_coef_table(int plane)
 	}
 }
 
+static void set_downsampling_coef_table(int plane)
+{
+	const u32 coef[][3] = {
+		{ 0x24382400, 0x24382400, 0x00000000 },
+		{ 0x28371FFE, 0x28391F04, 0x000004FE },
+		{ 0x2C361BFB, 0x2D381B08, 0x000008FB },
+		{ 0x303516F9, 0x3237170C, 0x00000CF9 },
+		{ 0x11343311, 0x123737F7, 0x0000F711 },
+		{ 0x1635300C, 0x173732F9, 0x0000F90C },
+		{ 0x1B362C08, 0x1B382DFB, 0x0000FB08 },
+		{ 0x1F372804, 0x1F3928FE, 0x0000FE04 },
+	};
+	int i;
+
+	for (i = 0; i < 8; i++) {
+		write_firh_reg(plane, i, coef[i][0]);
+		write_firhv_reg(plane, i, coef[i][1]);
+		write_firv_reg(plane, i, coef[i][2]);
+	}
+}
+
 static int omap_dispc_set_scale(int plane,
 				int orig_width, int orig_height,
 				int out_width, int out_height)
@@ -592,16 +624,32 @@ static int omap_dispc_set_scale(int plane,
 		if (orig_height > out_height ||
 		    orig_width * 8 < out_width ||
 		    orig_height * 8 < out_height) {
+			dev_dbg(dispc.fbdev->dev,
+				"Max upsampling is 8x, "
+				"tried: %dx%d -> %dx%d\n",
+				orig_width, orig_height,
+				out_width, out_height);
 			enable_lcd_clocks(0);
 			return -EINVAL;
 		}
 		set_upsampling_coef_table(plane);
 	} else if (orig_width > out_width) {
-		/* Downsampling not yet supported
-		*/
-
-		enable_lcd_clocks(0);
-		return -EINVAL;
+		/*
+		 * Downsampling.
+		 * Currently you can only scale both dimensions in one way.
+		 */
+		if (orig_height < out_height ||
+		    orig_width > out_width * 4 ||
+		    orig_height > out_height * 4) {
+			dev_dbg(dispc.fbdev->dev,
+				"Max downsampling is 4x, "
+				"tried: %dx%d -> %dx%d\n",
+				orig_width, orig_height,
+				out_width, out_height);
+			enable_lcd_clocks(0);
+			return -EINVAL;
+		}
+		set_downsampling_coef_table(plane);
 	}
 	if (!orig_width || orig_width == out_width)
 		fir_hinc = 0;
Signature · 1 line
1.5.6.5

From fd41a240a99de4c1408097bb39fa89cec4b7868d Mon Sep 17 00:00:00 2001
From: Tuomas Kulve <[email protected]>
Date: Fri, 31 Oct 2008 20:05:26 +0200
Subject: [PATCH] Calculate fir_*inc using resolution minus one in omapfb scaling.

---
 drivers/video/omap/dispc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/video/omap/dispc.c +2 -2
index 83f37bf..7ac4a86 100644
@@ -654,11 +654,11 @@ static int omap_dispc_set_scale(int plane,
 	if (!orig_width || orig_width == out_width)
 		fir_hinc = 0;
 	else
-		fir_hinc = 1024 * orig_width / out_width;
+		fir_hinc = 1024 * (orig_width - 1) / (out_width - 1);
 	if (!orig_height || orig_height == out_height)
 		fir_vinc = 0;
 	else
-		fir_vinc = 1024 * orig_height / out_height;
+		fir_vinc = 1024 * (orig_height - 1) / (out_height - 1);
 	dispc.fir_hinc[plane] = fir_hinc;
 	dispc.fir_vinc[plane] = fir_vinc;
 
Signature · 1 line
1.5.6.5
#2 lore raw
Quoted 6 lines · Tuomas Kulve
Quoted 4 lines · Tuomas Kulve

Hi

The attached patch enables omapfb scaling. Tested on omap3 based beagleboard with 2.6.27-omap1 kernel from linux-omap kernel tree.

Quoted 7 lines

The 0002 patch implements downscaling in omapfb. It seems to work on ES3.0 beagleboard and ES2.1 EVM but not on my rev B5 beagleboard.

The patch still needs cleanup but it should work with e.g. X.Org's XV extension:

http://gitweb.pingu.fi/?p=xf86-video-omapfb.git;a=summary

All, I'm not going to push any more omap video patches, those need to be discussed on fbdev mailing list. So please send the patches against the mainline kernel there and cc linux-omap mailing list.

Regards,

Tony

Quoted 139 lines
Signature · 14 lines
-- 
Tuomas Kulve, Movial Creative Technologies Inc.
Porkkalankatu 13J, FI-00180 Helsinki
Fax +358 9 8567 6401, Tel +358 9 8567 6400
www.movial.com

From 069ce763b1a7e936b7b2bdc288d94dd98e477d7e Mon Sep 17 00:00:00 2001
From: Tuomas Kulve <[email protected]>
Date: Mon, 3 Nov 2008 11:22:56 +0200
Subject: [PATCH] Implemented video downsampling in omapfb.

---
 drivers/video/omap/dispc.c |   58 ++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 53 insertions(+), 5 deletions(-)
drivers/video/omap/dispc.c +53 -5
index 68bc887..83f37bf 100644
@@ -545,6 +545,17 @@ static void write_firhv_reg(int plane, int reg, u32 value)
 	dispc_write_reg(base + reg * 8,	value);
 }
 
+static void write_firv_reg(int plane, int reg, u32 value)
+{
+	u32 base;
+
+	if (plane == 1)
+		base = 0x1E0;
+	else
+		base = 0x1E0 + 0x20;
+	dispc_write_reg(base + reg * 4,	value);
+}
+
 static void set_upsampling_coef_table(int plane)
 {
 	const u32 coef[][2] = {
@@ -565,6 +576,27 @@ static void set_upsampling_coef_table(int plane)
 	}
 }
 
+static void set_downsampling_coef_table(int plane)
+{
+	const u32 coef[][3] = {
+		{ 0x24382400, 0x24382400, 0x00000000 },
+		{ 0x28371FFE, 0x28391F04, 0x000004FE },
+		{ 0x2C361BFB, 0x2D381B08, 0x000008FB },
+		{ 0x303516F9, 0x3237170C, 0x00000CF9 },
+		{ 0x11343311, 0x123737F7, 0x0000F711 },
+		{ 0x1635300C, 0x173732F9, 0x0000F90C },
+		{ 0x1B362C08, 0x1B382DFB, 0x0000FB08 },
+		{ 0x1F372804, 0x1F3928FE, 0x0000FE04 },
+	};
+	int i;
+
+	for (i = 0; i < 8; i++) {
+		write_firh_reg(plane, i, coef[i][0]);
+		write_firhv_reg(plane, i, coef[i][1]);
+		write_firv_reg(plane, i, coef[i][2]);
+	}
+}
+
 static int omap_dispc_set_scale(int plane,
 				int orig_width, int orig_height,
 				int out_width, int out_height)
@@ -592,16 +624,32 @@ static int omap_dispc_set_scale(int plane,
 		if (orig_height > out_height ||
 		    orig_width * 8 < out_width ||
 		    orig_height * 8 < out_height) {
+			dev_dbg(dispc.fbdev->dev,
+				"Max upsampling is 8x, "
+				"tried: %dx%d -> %dx%d\n",
+				orig_width, orig_height,
+				out_width, out_height);
 			enable_lcd_clocks(0);
 			return -EINVAL;
 		}
 		set_upsampling_coef_table(plane);
 	} else if (orig_width > out_width) {
-		/* Downsampling not yet supported
-		*/
-
-		enable_lcd_clocks(0);
-		return -EINVAL;
+		/*
+		 * Downsampling.
+		 * Currently you can only scale both dimensions in one way.
+		 */
+		if (orig_height < out_height ||
+		    orig_width > out_width * 4 ||
+		    orig_height > out_height * 4) {
+			dev_dbg(dispc.fbdev->dev,
+				"Max downsampling is 4x, "
+				"tried: %dx%d -> %dx%d\n",
+				orig_width, orig_height,
+				out_width, out_height);
+			enable_lcd_clocks(0);
+			return -EINVAL;
+		}
+		set_downsampling_coef_table(plane);
 	}
 	if (!orig_width || orig_width == out_width)
 		fir_hinc = 0;
Signature · 11 lines
1.5.6.5


From fd41a240a99de4c1408097bb39fa89cec4b7868d Mon Sep 17 00:00:00 2001
From: Tuomas Kulve <[email protected]>
Date: Fri, 31 Oct 2008 20:05:26 +0200
Subject: [PATCH] Calculate fir_*inc using resolution minus one in omapfb scaling.

---
 drivers/video/omap/dispc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/video/omap/dispc.c +2 -2
index 83f37bf..7ac4a86 100644
@@ -654,11 +654,11 @@ static int omap_dispc_set_scale(int plane,
 	if (!orig_width || orig_width == out_width)
 		fir_hinc = 0;
 	else
-		fir_hinc = 1024 * orig_width / out_width;
+		fir_hinc = 1024 * (orig_width - 1) / (out_width - 1);
 	if (!orig_height || orig_height == out_height)
 		fir_vinc = 0;
 	else
-		fir_vinc = 1024 * orig_height / out_height;
+		fir_vinc = 1024 * (orig_height - 1) / (out_height - 1);
 	dispc.fir_hinc[plane] = fir_hinc;
 	dispc.fir_vinc[plane] = fir_vinc;
 
Signature · 1 line
1.5.6.5