staging: sm750fb: change definition of DE_STRETCH_FORMAT fields
authorMike Rapoport <mike.rapoport@gmail.com>
Mon, 15 Feb 2016 17:54:02 +0000 (19:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 16 Feb 2016 02:26:17 +0000 (18:26 -0800)
Use stratight-forward definition of DE_STRETCH_FORMAT register fields
and use open-coded implementation for register manipulation

Signed-off-by: Mike Rapoport <mike.rapoport@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/sm750fb/sm750_accel.c
drivers/staging/sm750fb/sm750_accel.h

index 61666ce..88e39b8 100644 (file)
@@ -41,20 +41,16 @@ void hw_de_init(struct lynx_accel *accel)
        write_dpr(accel, DE_MASKS, 0xFFFFFFFF);
 
        /* dpr1c */
-       reg = FIELD_SET(0, DE_STRETCH_FORMAT, PATTERN_XY, NORMAL)|
-               FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_Y, 0)|
-               FIELD_VALUE(0, DE_STRETCH_FORMAT, PATTERN_X, 0)|
-               FIELD_SET(0, DE_STRETCH_FORMAT, ADDRESSING, XY)|
-               FIELD_VALUE(0, DE_STRETCH_FORMAT, SOURCE_HEIGHT, 3);
-
-       clr = FIELD_CLEAR(DE_STRETCH_FORMAT, PATTERN_XY)&
-               FIELD_CLEAR(DE_STRETCH_FORMAT, PATTERN_Y)&
-               FIELD_CLEAR(DE_STRETCH_FORMAT, PATTERN_X)&
-               FIELD_CLEAR(DE_STRETCH_FORMAT, ADDRESSING)&
-               FIELD_CLEAR(DE_STRETCH_FORMAT, SOURCE_HEIGHT);
+       reg =  0x3;
+
+       clr = DE_STRETCH_FORMAT_PATTERN_XY | DE_STRETCH_FORMAT_PATTERN_Y_MASK |
+               DE_STRETCH_FORMAT_PATTERN_X_MASK |
+               DE_STRETCH_FORMAT_ADDRESSING_MASK |
+               DE_STRETCH_FORMAT_SOURCE_HEIGHT_MASK;
 
        /* DE_STRETCH bpp format need be initialized in setMode routine */
-       write_dpr(accel, DE_STRETCH_FORMAT, (read_dpr(accel, DE_STRETCH_FORMAT) & clr) | reg);
+       write_dpr(accel, DE_STRETCH_FORMAT,
+                 (read_dpr(accel, DE_STRETCH_FORMAT) & ~clr) | reg);
 
        /* disable clipping and transparent */
        write_dpr(accel, DE_CLIP_TL, 0); /* dpr2c */
@@ -80,7 +76,9 @@ void hw_set2dformat(struct lynx_accel *accel, int fmt)
 
        /* fmt=0,1,2 for 8,16,32,bpp on sm718/750/502 */
        reg = read_dpr(accel, DE_STRETCH_FORMAT);
-       reg = FIELD_VALUE(reg, DE_STRETCH_FORMAT, PIXEL_FORMAT, fmt);
+       reg &= ~DE_STRETCH_FORMAT_PIXEL_FORMAT_MASK;
+       reg |= ((fmt << DE_STRETCH_FORMAT_PIXEL_FORMAT_SHIFT) &
+               DE_STRETCH_FORMAT_PIXEL_FORMAT_MASK);
        write_dpr(accel, DE_STRETCH_FORMAT, reg);
 }
 
index f14abb6..69aa47c 100644 (file)
 #define DE_BACKGROUND_COLOR                             31:0
 
 #define DE_STRETCH_FORMAT                               0x00001C
-#define DE_STRETCH_FORMAT_PATTERN_XY                    30:30
-#define DE_STRETCH_FORMAT_PATTERN_XY_NORMAL             0
-#define DE_STRETCH_FORMAT_PATTERN_XY_OVERWRITE          1
-#define DE_STRETCH_FORMAT_PATTERN_Y                     29:27
-#define DE_STRETCH_FORMAT_PATTERN_X                     25:23
-#define DE_STRETCH_FORMAT_PIXEL_FORMAT                  21:20
-#define DE_STRETCH_FORMAT_PIXEL_FORMAT_8                0
-#define DE_STRETCH_FORMAT_PIXEL_FORMAT_16               1
-#define DE_STRETCH_FORMAT_PIXEL_FORMAT_32               2
-#define DE_STRETCH_FORMAT_PIXEL_FORMAT_24               3
-
-#define DE_STRETCH_FORMAT_ADDRESSING                    19:16
-#define DE_STRETCH_FORMAT_ADDRESSING_XY                 0
-#define DE_STRETCH_FORMAT_ADDRESSING_LINEAR             15
-#define DE_STRETCH_FORMAT_SOURCE_HEIGHT                 11:0
+#define DE_STRETCH_FORMAT_PATTERN_XY                    BIT(30)
+#define DE_STRETCH_FORMAT_PATTERN_Y_SHIFT               27
+#define DE_STRETCH_FORMAT_PATTERN_Y_MASK                (0x7 << 27)
+#define DE_STRETCH_FORMAT_PATTERN_X_SHIFT               23
+#define DE_STRETCH_FORMAT_PATTERN_X_MASK                (0x7 << 23)
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_SHIFT            20
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_MASK             (0x3 << 20)
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_8                (0x0 << 20)
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_16               (0x1 << 20)
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_32               (0x2 << 20)
+#define DE_STRETCH_FORMAT_PIXEL_FORMAT_24               (0x3 << 20)
+#define DE_STRETCH_FORMAT_ADDRESSING_SHIFT              16
+#define DE_STRETCH_FORMAT_ADDRESSING_MASK               (0xf << 16)
+#define DE_STRETCH_FORMAT_ADDRESSING_XY                 (0x0 << 16)
+#define DE_STRETCH_FORMAT_ADDRESSING_LINEAR             (0xf << 16)
+#define DE_STRETCH_FORMAT_SOURCE_HEIGHT_MASK            0xfff
 
 #define DE_COLOR_COMPARE                                0x000020
 #define DE_COLOR_COMPARE_COLOR                          23:0