radeonfb: Whack the PCI PM register until it sticks
[sfrench/cifs-2.6.git] / drivers / video / cfbfillrect.c
index 71623b4f8ca26581dbf4f8258734685fbd55e079..64b35766b2a26bf28ccb1cfb55990c159008ca45 100644 (file)
      */
 
 static void
-bitfill_aligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat, unsigned n, int bits)
+bitfill_aligned(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
+               unsigned long pat, unsigned n, int bits, u32 bswapmask)
 {
        unsigned long first, last;
 
        if (!n)
                return;
 
-       first = FB_SHIFT_HIGH(~0UL, dst_idx);
-       last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits));
+       first = fb_shifted_pixels_mask_long(p, dst_idx, bswapmask);
+       last = ~fb_shifted_pixels_mask_long(p, (dst_idx+n) % bits, bswapmask);
 
        if (dst_idx+n <= bits) {
                // Single word
@@ -92,16 +93,16 @@ bitfill_aligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat, unsi
      */
 
 static void
-bitfill_unaligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
-                       int left, int right, unsigned n, int bits)
+bitfill_unaligned(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
+                 unsigned long pat, int left, int right, unsigned n, int bits)
 {
        unsigned long first, last;
 
        if (!n)
                return;
 
-       first = FB_SHIFT_HIGH(~0UL, dst_idx);
-       last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits));
+       first = FB_SHIFT_HIGH(p, ~0UL, dst_idx);
+       last = ~(FB_SHIFT_HIGH(p, ~0UL, (dst_idx+n) % bits));
 
        if (dst_idx+n <= bits) {
                // Single word
@@ -146,7 +147,9 @@ bitfill_unaligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
      *  Aligned pattern invert using 32/64-bit memory accesses
      */
 static void
-bitfill_aligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat, unsigned n, int bits)
+bitfill_aligned_rev(struct fb_info *p, unsigned long __iomem *dst,
+                   int dst_idx, unsigned long pat, unsigned n, int bits,
+                   u32 bswapmask)
 {
        unsigned long val = pat, dat;
        unsigned long first, last;
@@ -154,8 +157,8 @@ bitfill_aligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
        if (!n)
                return;
 
-       first = FB_SHIFT_HIGH(~0UL, dst_idx);
-       last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits));
+       first = fb_shifted_pixels_mask_long(p, dst_idx, bswapmask);
+       last = ~fb_shifted_pixels_mask_long(p, (dst_idx+n) % bits, bswapmask);
 
        if (dst_idx+n <= bits) {
                // Single word
@@ -215,16 +218,17 @@ bitfill_aligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
      */
 
 static void
-bitfill_unaligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
-                       int left, int right, unsigned n, int bits)
+bitfill_unaligned_rev(struct fb_info *p, unsigned long __iomem *dst,
+                     int dst_idx, unsigned long pat, int left, int right,
+                     unsigned n, int bits)
 {
        unsigned long first, last, dat;
 
        if (!n)
                return;
 
-       first = FB_SHIFT_HIGH(~0UL, dst_idx);
-       last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits));
+       first = FB_SHIFT_HIGH(p, ~0UL, dst_idx);
+       last = ~(FB_SHIFT_HIGH(p, ~0UL, (dst_idx+n) % bits));
 
        if (dst_idx+n <= bits) {
                // Single word
@@ -303,8 +307,11 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
        if (p->fbops->fb_sync)
                p->fbops->fb_sync(p);
        if (!left) {
-               void (*fill_op32)(unsigned long __iomem *dst, int dst_idx,
-                                 unsigned long pat, unsigned n, int bits) = NULL;
+               u32 bswapmask = fb_compute_bswapmask(p);
+               void (*fill_op32)(struct fb_info *p,
+                                 unsigned long __iomem *dst, int dst_idx,
+                                 unsigned long pat, unsigned n, int bits,
+                                 u32 bswapmask) = NULL;
 
                switch (rect->rop) {
                case ROP_XOR:
@@ -321,16 +328,17 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
                while (height--) {
                        dst += dst_idx >> (ffs(bits) - 1);
                        dst_idx &= (bits - 1);
-                       fill_op32(dst, dst_idx, pat, width*bpp, bits);
+                       fill_op32(p, dst, dst_idx, pat, width*bpp, bits,
+                                 bswapmask);
                        dst_idx += p->fix.line_length*8;
                }
        } else {
                int right;
                int r;
                int rot = (left-dst_idx) % bpp;
-               void (*fill_op)(unsigned long __iomem *dst, int dst_idx,
-                               unsigned long pat, int left, int right,
-                               unsigned n, int bits) = NULL;
+               void (*fill_op)(struct fb_info *p, unsigned long __iomem *dst,
+                               int dst_idx, unsigned long pat, int left,
+                               int right, unsigned n, int bits) = NULL;
 
                /* rotate pattern to correct start position */
                pat = pat << rot | pat >> (bpp-rot);
@@ -351,7 +359,7 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
                while (height--) {
                        dst += dst_idx >> (ffs(bits) - 1);
                        dst_idx &= (bits - 1);
-                       fill_op(dst, dst_idx, pat, left, right,
+                       fill_op(p, dst, dst_idx, pat, left, right,
                                width*bpp, bits);
                        r = (p->fix.line_length*8) % bpp;
                        pat = pat << (bpp-r) | pat >> r;