Cleanup local patchset.
[openpandora.oe.git] / packages / linux / omap3-pandora-kernel / 0001-Implement-downsampling-with-debugs.patch
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).
5
6 ---
7  drivers/video/omap/dispc.c |   75 +++++++++++++++++++++++++++++++++++++-------
8  1 files changed, 63 insertions(+), 12 deletions(-)
9
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
14 @@ -18,6 +18,8 @@
15   * with this program; if not, write to the Free Software Foundation, Inc.,
16   * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17   */
18 +#define DEBUG
19 +#define VERBOSE_DEBUG
20  #include <linux/kernel.h>
21  #include <linux/dma-mapping.h>
22  #include <linux/mm.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);
25  }
26  
27 +static void write_firv_reg(int plane, int reg, u32 value)
28 +{
29 +       u32 base;
30 +
31 +       if (plane == 1)
32 +               base = 0x1E0;
33 +       else
34 +               base = 0x1E0 + 0x20;
35 +       dispc_write_reg(base + reg * 4, value);
36 +}
37 +
38  static void set_upsampling_coef_table(int plane)
39  {
40         const u32 coef[][2] = {
41 @@ -565,6 +578,27 @@ static void set_upsampling_coef_table(int plane)
42         }
43  }
44  
45 +static void set_downsampling_coef_table(int plane)
46 +{
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 },
56 +       };
57 +       int i;
58 +
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]);
63 +       }
64 +}
65 +
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);
78                         enable_lcd_clocks(0);
79                         return -EINVAL;
80                 }
81                 set_upsampling_coef_table(plane);
82         } else if (orig_width > out_width) {
83 -               /* Downsampling not yet supported
84 -               */
85 -
86 -               enable_lcd_clocks(0);
87 -               return -EINVAL;
88 +               /*
89 +                * Downsampling.
90 +                * Currently you can only scale both dimensions in one way.
91 +                */
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);
101 +                       return -EINVAL;
102 +               }
103 +               set_downsampling_coef_table(plane);
104         }
105         if (!orig_width || orig_width == out_width)
106                 fir_hinc = 0;
107         else
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)
111                 fir_vinc = 0;
112         else
113 -               fir_vinc = 1024 * orig_height / out_height;
114 +               fir_vinc = 1024 * (orig_height-1) / (out_height -1 );
115 +
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);
120 +
121         dispc.fir_hinc[plane] = fir_hinc;
122         dispc.fir_vinc[plane] = fir_vinc;
123  
124 @@ -619,11 +675,6 @@ static int omap_dispc_set_scale(int plane,
125                     ((fir_vinc & 4095) << 16) |
126                     (fir_hinc & 4095));
127  
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);
132 -
133         MOD_REG_FLD(vs_reg[plane],
134                     FLD_MASK(16, 11) | FLD_MASK(0, 11),
135                     ((out_height - 1) << 16) | (out_width - 1));
136 -- 
137 1.5.6.5
138