DSS2: Swap field 0 and field 1 registers
[pandora-kernel.git] / drivers / video / omap2 / dss / dispc.c
index b8a3329..9bab6cf 100644 (file)
@@ -1029,12 +1029,12 @@ static void _dispc_set_vid_accu1(enum omap_plane plane, int haccu, int vaccu)
 static void _dispc_set_scaling(enum omap_plane plane,
                u16 orig_width, u16 orig_height,
                u16 out_width, u16 out_height,
-               bool ilace, bool five_taps)
+               bool ilace, bool five_taps,
+               bool fieldmode)
 {
        int fir_hinc;
        int fir_vinc;
        int hscaleup, vscaleup;
-       int fieldmode = 0;
        int accu0 = 0;
        int accu1 = 0;
        u32 l;
@@ -1072,17 +1072,16 @@ static void _dispc_set_scaling(enum omap_plane plane,
 
        dispc_write_reg(dispc_reg_att[plane], l);
 
-       if (ilace) {
-               if (fieldmode) {
-                       accu0 = fir_vinc / 2;
-                       accu1 = 0;
-               } else {
-                       accu0 = 0;
-                       accu1 = fir_vinc / 2;
-                       if (accu1 >= 1024/2) {
-                               accu0 = 1024/2;
-                               accu1 -= accu0;
-                       }
+       /*
+        * field 0 = even field = bottom field
+        * field 1 = odd field = top field
+        */
+       if (ilace && !fieldmode) {
+               accu1 = 0;
+               accu0 = fir_vinc / 2;
+               if (accu0 >= 1024/2) {
+                       accu1 = 1024/2;
+                       accu0 -= accu1;
                }
        }
 
@@ -1271,34 +1270,38 @@ static void calc_dma_rotation_offset(u8 rotation, bool mirror,
                fbh = width;
        }
 
+       /*
+        * field 0 = even field = bottom field
+        * field 1 = odd field = top field
+        */
        switch (rotation + mirror * 4) {
        case 0:
-               *offset0 = 0;
+               *offset1 = 0;
                if (fieldmode)
-                       *offset1 = screen_width * ps;
+                       *offset0 = screen_width * ps;
                else
-                       *offset1 = 0;
+                       *offset0 = 0;
                *row_inc = pixinc(1 + (screen_width - fbw) +
                                (fieldmode ? screen_width : 0),
                                ps);
                *pix_inc = pixinc(1, ps);
                break;
        case 1:
-               *offset0 = screen_width * (fbh - 1) * ps;
+               *offset1 = screen_width * (fbh - 1) * ps;
                if (fieldmode)
-                       *offset1 = *offset0 + ps;
+                       *offset0 = *offset1 + ps;
                else
-                       *offset1 = *offset0;
+                       *offset0 = *offset1;
                *row_inc = pixinc(screen_width * (fbh - 1) + 1 +
                                (fieldmode ? 1 : 0), ps);
                *pix_inc = pixinc(-screen_width, ps);
                break;
        case 2:
-               *offset0 = (screen_width * (fbh - 1) + fbw - 1) * ps;
+               *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps;
                if (fieldmode)
-                       *offset1 = *offset0 - screen_width * ps;
+                       *offset0 = *offset1 - screen_width * ps;
                else
-                       *offset1 = *offset0;
+                       *offset0 = *offset1;
                *row_inc = pixinc(-1 -
                                (screen_width - fbw) -
                                (fieldmode ? screen_width : 0),
@@ -1306,11 +1309,11 @@ static void calc_dma_rotation_offset(u8 rotation, bool mirror,
                *pix_inc = pixinc(-1, ps);
                break;
        case 3:
-               *offset0 = (fbw - 1) * ps;
+               *offset1 = (fbw - 1) * ps;
                if (fieldmode)
-                       *offset1 = *offset0 - ps;
+                       *offset0 = *offset1 - ps;
                else
-                       *offset1 = *offset0;
+                       *offset0 = *offset1;
                *row_inc = pixinc(-screen_width * (fbh - 1) - 1 -
                                (fieldmode ? 1 : 0), ps);
                *pix_inc = pixinc(screen_width, ps);
@@ -1318,11 +1321,11 @@ static void calc_dma_rotation_offset(u8 rotation, bool mirror,
 
        /* mirroring */
        case 0 + 4:
-               *offset0 = (fbw - 1) * ps;
+               *offset1 = (fbw - 1) * ps;
                if (fieldmode)
-                       *offset1 = *offset0 + screen_width * ps;
+                       *offset0 = *offset1 + screen_width * ps;
                else
-                       *offset1 = *offset0;
+                       *offset0 = *offset1;
                *row_inc = pixinc(screen_width * 2 - 1 +
                                (fieldmode ? screen_width : 0),
                                ps);
@@ -1330,11 +1333,11 @@ static void calc_dma_rotation_offset(u8 rotation, bool mirror,
                break;
 
        case 1 + 4:
-               *offset0 = 0;
+               *offset1 = 0;
                if (fieldmode)
-                       *offset1 = *offset0 + screen_width * ps;
+                       *offset0 = *offset1 + screen_width * ps;
                else
-                       *offset1 = *offset0;
+                       *offset0 = *offset1;
                *row_inc = pixinc(-screen_width * (fbh - 1) + 1 +
                                (fieldmode ? 1 : 0),
                                ps);
@@ -1342,11 +1345,11 @@ static void calc_dma_rotation_offset(u8 rotation, bool mirror,
                break;
 
        case 2 + 4:
-               *offset0 = screen_width * (fbh - 1) * ps;
+               *offset1 = screen_width * (fbh - 1) * ps;
                if (fieldmode)
-                       *offset1 = *offset0 + screen_width * ps;
+                       *offset0 = *offset1 + screen_width * ps;
                else
-                       *offset1 = *offset0;
+                       *offset0 = *offset1;
                *row_inc = pixinc(1 - screen_width * 2 -
                                (fieldmode ? screen_width : 0),
                                ps);
@@ -1354,11 +1357,11 @@ static void calc_dma_rotation_offset(u8 rotation, bool mirror,
                break;
 
        case 3 + 4:
-               *offset0 = (screen_width * (fbh - 1) + fbw - 1) * ps;
+               *offset1 = (screen_width * (fbh - 1) + fbw - 1) * ps;
                if (fieldmode)
-                       *offset1 = *offset0 + screen_width * ps;
+                       *offset0 = *offset1 + screen_width * ps;
                else
-                       *offset1 = *offset0;
+                       *offset0 = *offset1;
                *row_inc = pixinc(screen_width * (fbh - 1) - 1 -
                                (fieldmode ? 1 : 0),
                                ps);
@@ -1405,15 +1408,10 @@ static unsigned long calc_fclk_five_taps(u16 width, u16 height,
 }
 
 static unsigned long calc_fclk(u16 width, u16 height,
-               u16 out_width, u16 out_height,
-               enum omap_color_mode color_mode, bool five_taps)
+               u16 out_width, u16 out_height)
 {
        unsigned int hf, vf;
 
-       if (five_taps)
-               return calc_fclk_five_taps(width, height,
-                               out_width, out_height, color_mode);
-
        /*
         * FIXME how to determine the 'A' factor
         * for the no downscaling case ?
@@ -1460,7 +1458,7 @@ static int _dispc_setup_plane(enum omap_plane plane,
        if (paddr == 0)
                return -EINVAL;
 
-       if (ilace && height >= out_height)
+       if (ilace && height == out_height)
                fieldmode = 1;
 
        if (ilace) {
@@ -1494,7 +1492,7 @@ static int _dispc_setup_plane(enum omap_plane plane,
        } else {
                /* video plane */
 
-               unsigned long fclk;
+               unsigned long fclk = 0;
 
                if (out_width < width / maxdownscale ||
                   out_width > width * 8)
@@ -1530,20 +1528,22 @@ static int _dispc_setup_plane(enum omap_plane plane,
                /* Must use 5-tap filter? */
                five_taps = height > out_height * 2;
 
-               /* Try to use 5-tap filter whenever possible. */
-               if (cpu_is_omap34xx() && !five_taps &&
-                   height > out_height && width <= 1024) {
-                       fclk = calc_fclk_five_taps(width, height,
-                                       out_width, out_height, color_mode);
-                       if (fclk <= dispc_fclk_rate())
+               if (!five_taps) {
+                       fclk = calc_fclk(width, height,
+                                       out_width, out_height);
+
+                       /* Try 5-tap filter if 3-tap fclk is too high */
+                       if (cpu_is_omap34xx() && height > out_height &&
+                                       fclk > dispc_fclk_rate())
                                five_taps = true;
                }
 
                if (width > (2048 >> five_taps))
                        return -EINVAL;
 
-               fclk = calc_fclk(width, height, out_width, out_height,
-                               color_mode, five_taps);
+               if (five_taps)
+                       fclk = calc_fclk_five_taps(width, height,
+                                       out_width, out_height, color_mode);
 
                DSSDBG("required fclk rate = %lu Hz\n", fclk);
                DSSDBG("current fclk rate = %lu Hz\n", dispc_fclk_rate());
@@ -1585,7 +1585,7 @@ static int _dispc_setup_plane(enum omap_plane plane,
        if (plane != OMAP_DSS_GFX) {
                _dispc_set_scaling(plane, width, height,
                                   out_width, out_height,
-                                  ilace, five_taps);
+                                  ilace, five_taps, fieldmode);
                _dispc_set_vid_size(plane, out_width, out_height);
                _dispc_set_vid_color_conv(plane, cconv);
        }
@@ -1850,6 +1850,32 @@ void dispc_enable_trans_key(enum omap_channel ch, bool enable)
                REG_FLD_MOD(DISPC_CONFIG, enable, 12, 12);
        enable_clocks(0);
 }
+void dispc_enable_alpha_blending(enum omap_channel ch, bool enable)
+{
+       enable_clocks(1);
+       if (ch == OMAP_DSS_CHANNEL_LCD)
+               REG_FLD_MOD(DISPC_CONFIG, enable, 18, 18);
+       else /* OMAP_DSS_CHANNEL_DIGIT */
+               REG_FLD_MOD(DISPC_CONFIG, enable, 19, 19);
+       enable_clocks(0);
+}
+bool dispc_alpha_blending_enabled(enum omap_channel ch)
+{
+       bool enabled;
+
+       enable_clocks(1);
+       if (ch == OMAP_DSS_CHANNEL_LCD)
+               enabled = REG_GET(DISPC_CONFIG, 18, 18);
+       else if (ch == OMAP_DSS_CHANNEL_DIGIT)
+               enabled = REG_GET(DISPC_CONFIG, 18, 18);
+       else
+               BUG();
+       enable_clocks(0);
+
+       return enabled;
+
+}
+
 
 bool dispc_trans_key_enabled(enum omap_channel ch)
 {