1 From 1ef94095e9399a9a387b7b457b48f6c5de7013d8 Mon Sep 17 00:00:00 2001
2 From: Tuomas Kulve <tuomas.kulve@movial.com>
3 Date: Fri, 31 Oct 2008 14:23:57 +0200
4 Subject: [PATCH] Implement downsampling (with debugs).
7 drivers/video/omap/dispc.c | 75 +++++++++++++++++++++++++++++++++++++-------
8 1 files changed, 63 insertions(+), 12 deletions(-)
10 diff --git a/drivers/video/omap/dispc.c b/drivers/video/omap/dispc.c
11 index 68bc887..3640dbe 100644
12 --- a/drivers/video/omap/dispc.c
13 +++ b/drivers/video/omap/dispc.c
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 +#define VERBOSE_DEBUG
20 #include <linux/kernel.h>
21 #include <linux/dma-mapping.h>
23 @@ -545,6 +547,17 @@ static void write_firhv_reg(int plane, int reg, u32 value)
24 dispc_write_reg(base + reg * 8, value);
27 +static void write_firv_reg(int plane, int reg, u32 value)
34 + base = 0x1E0 + 0x20;
35 + dispc_write_reg(base + reg * 4, value);
38 static void set_upsampling_coef_table(int plane)
40 const u32 coef[][2] = {
41 @@ -565,6 +578,27 @@ static void set_upsampling_coef_table(int plane)
45 +static void set_downsampling_coef_table(int plane)
47 + const u32 coef[][3] = {
48 + { 0x24382400, 0x24382400, 0x00000000 },
49 + { 0x28371FFE, 0x28391F04, 0x000004FE },
50 + { 0x2C361BFB, 0x2D381B08, 0x000008FB },
51 + { 0x303516F9, 0x3237170C, 0x00000CF9 },
52 + { 0x11343311, 0x123737F7, 0x0000F711 },
53 + { 0x1635300C, 0x173732F9, 0x0000F90C },
54 + { 0x1B362C08, 0x1B382DFB, 0x0000FB08 },
55 + { 0x1F372804, 0x1F3928FE, 0x0000FE04 },
59 + for (i = 0; i < 8; i++) {
60 + write_firh_reg(plane, i, coef[i][0]);
61 + write_firhv_reg(plane, i, coef[i][1]);
62 + write_firv_reg(plane, i, coef[i][2]);
66 static int omap_dispc_set_scale(int plane,
67 int orig_width, int orig_height,
68 int out_width, int out_height)
69 @@ -592,25 +626,47 @@ static int omap_dispc_set_scale(int plane,
70 if (orig_height > out_height ||
71 orig_width * 8 < out_width ||
72 orig_height * 8 < out_height) {
73 + dev_dbg(dispc.fbdev->dev,
74 + "Max upsampling is 8x, "
75 + "tried: %dx%d -> %dx%d\n",
76 + orig_width, orig_height,
77 + out_width, out_height);
81 set_upsampling_coef_table(plane);
82 } else if (orig_width > out_width) {
83 - /* Downsampling not yet supported
86 - enable_lcd_clocks(0);
90 + * Currently you can only scale both dimensions in one way.
92 + if (orig_height < out_height ||
93 + orig_width > out_width * 4||
94 + orig_height > out_height * 4) {
95 + dev_dbg(dispc.fbdev->dev,
96 + "Max downsampling is 4x, "
97 + "tried: %dx%d -> %dx%d\n",
98 + orig_width, orig_height,
99 + out_width, out_height);
100 + enable_lcd_clocks(0);
103 + set_downsampling_coef_table(plane);
105 if (!orig_width || orig_width == out_width)
108 - fir_hinc = 1024 * orig_width / out_width;
109 + fir_hinc = 1024 * (orig_width -1)/ (out_width -1);
110 if (!orig_height || orig_height == out_height)
113 - fir_vinc = 1024 * orig_height / out_height;
114 + fir_vinc = 1024 * (orig_height-1) / (out_height -1 );
116 + dev_dbg(dispc.fbdev->dev, "out_width %d out_height %d orig_width %d "
117 + "orig_height %d fir_hinc %d fir_vinc %d\n",
118 + out_width, out_height, orig_width, orig_height,
119 + fir_hinc, fir_vinc);
121 dispc.fir_hinc[plane] = fir_hinc;
122 dispc.fir_vinc[plane] = fir_vinc;
124 @@ -619,11 +675,6 @@ static int omap_dispc_set_scale(int plane,
125 ((fir_vinc & 4095) << 16) |
128 - dev_dbg(dispc.fbdev->dev, "out_width %d out_height %d orig_width %d "
129 - "orig_height %d fir_hinc %d fir_vinc %d\n",
130 - out_width, out_height, orig_width, orig_height,
131 - fir_hinc, fir_vinc);
133 MOD_REG_FLD(vs_reg[plane],
134 FLD_MASK(16, 11) | FLD_MASK(0, 11),
135 ((out_height - 1) << 16) | (out_width - 1));