desktop-files: Changed a few categories for the scripts
[openpandora.oe.git] / recipes / linux / omap3-pandora-kernel / mru-enable-overlay-optimalization.diff
1 From: Mans Rullgard <mans@mansr.com>
2 Date: Fri, 29 Aug 2008 01:45:26 +0000 (+0100)
3 Subject: OMAP: Enable overlay optimisation
4 X-Git-Url: http://git.mansr.com/?p=linux-omap;a=commitdiff_plain;h=7e052af7e4c73dc450412486ad37eb529e725dc7
5
6 OMAP: Enable overlay optimisation
7
8 This enables the overlay optimisation feature when the video
9 overlay is active. This reduces memory bandwidth used by the
10 display subsystem, improving overall performance.
11
12 Signed-off-by: Mans Rullgard <mans@mansr.com>
13 ---
14
15 diff --git a/drivers/video/omap/dispc.c b/drivers/video/omap/dispc.c
16 index 888d2c2..0f0b2e5 100644
17 --- a/drivers/video/omap/dispc.c
18 +++ b/drivers/video/omap/dispc.c
19 @@ -315,6 +315,60 @@ void omap_dispc_enable_digit_out(int enable)
20  }
21  EXPORT_SYMBOL(omap_dispc_enable_digit_out);
22  
23 +#define MIN(a, b) ((a)<(b)?(a):(b))
24 +#define MAX(a, b) ((a)>(b)?(a):(b))
25 +
26 +static void setup_overlay_opt(void)
27 +{
28 +       struct fb_info **fbi = dispc.fbdev->fb_info;
29 +       struct omapfb_plane_struct *gfx, *vid;
30 +       struct fb_var_screeninfo *gvar;
31 +       unsigned gx, gx2, gy, gy2, gw, gh;
32 +       unsigned vx, vx2, vy, vy2, vw, vh;
33 +       unsigned bpp, skip;
34 +       static unsigned last_skip;
35 +
36 +       if (!fbi[0] || !fbi[1])
37 +               return;
38 +
39 +       gfx = fbi[0]->par;
40 +       vid = fbi[1]->par;
41 +       gvar = &fbi[0]->var;
42 +
43 +       gx = gfx->info.pos_x;
44 +       gy = gfx->info.pos_y;
45 +       gw = gfx->info.out_width;
46 +       gh = gfx->info.out_height;
47 +       vx = vid->info.pos_x;
48 +       vy = vid->info.pos_y;
49 +       vw = vid->info.out_width;
50 +       vh = vid->info.out_height;
51 +       gx2 = gx + gw;
52 +       gy2 = gy + gh;
53 +       vx2 = vx + vw;
54 +       vy2 = vy + vh;
55 +       bpp = gvar->bits_per_pixel / 8;
56 +
57 +       if (!gfx->info.enabled || !vid->info.enabled ||
58 +           dispc.color_key.key_type != OMAPFB_COLOR_KEY_DISABLED) {
59 +               skip = 0;
60 +       } else if (vx <= gx && vx2 >= gx2) {
61 +               unsigned y = MIN(gy2, vy2) - MAX(gy, vy);
62 +               skip = y * gvar->xres_virtual * bpp;
63 +       } else if (vx <= gx || vx2 >= gx2) {
64 +               unsigned x = MIN(gx2, vx2) - MAX(gx, vx);
65 +               skip = x * bpp;
66 +       } else {
67 +               skip = vw * bpp + 1;
68 +       }
69 +
70 +       if (skip != last_skip) {
71 +               last_skip = skip;
72 +               dispc_write_reg(DISPC_GFX_WINDOW_SKIP, skip);
73 +               MOD_REG_FLD(DISPC_CONTROL, 1<<12, !!skip<<12);
74 +       }
75 +}
76 +
77  static inline int _setup_plane(int plane, int channel_out,
78                                   u32 paddr, int screen_width,
79                                   int pos_x, int pos_y, int width, int height,
80 @@ -437,6 +491,9 @@ static inline int _setup_plane(int plane, int channel_out,
81  
82         dispc_write_reg(ri_reg[plane], (screen_width - width) * bpp / 8 + 1);
83  
84 +       if (plane < 2)
85 +               setup_overlay_opt();
86 +
87         MOD_REG_FLD(DISPC_CONTROL, 1<<5, 1<<5);
88  
89         return height * screen_width * bpp / 8;
90 @@ -585,11 +642,19 @@ static int omap_dispc_enable_plane(int plane, int enable)
91         const u32 at_reg[] = { DISPC_GFX_ATTRIBUTES,
92                                 DISPC_VID1_BASE + DISPC_VID_ATTRIBUTES,
93                                 DISPC_VID2_BASE + DISPC_VID_ATTRIBUTES };
94 +       struct omapfb_plane_struct *pi;
95 +
96         if ((unsigned int)plane > dispc.mem_desc.region_cnt)
97                 return -EINVAL;
98  
99 +       pi = dispc.fbdev->fb_info[plane]->par;
100 +       pi->info.enabled = enable;
101 +
102         enable_lcd_clocks(1);
103         MOD_REG_FLD(at_reg[plane], 1, enable ? 1 : 0);
104 +       if (plane < 2)
105 +               setup_overlay_opt();
106 +       MOD_REG_FLD(DISPC_CONTROL, 1<<5, 1<<5);
107         enable_lcd_clocks(0);
108  
109         return 0;
110 @@ -633,6 +698,7 @@ static int omap_dispc_set_color_key(struct omapfb_color_key *ck)
111         if (val != 0)
112                 dispc_write_reg(tr_reg, ck->trans_key);
113         dispc_write_reg(df_reg, ck->background);
114 +       setup_overlay_opt();
115         enable_lcd_clocks(0);
116  
117         dispc.color_key = *ck;