Commit 1ea48bea authored by James Simmons's avatar James Simmons

[GENRIC ACCEL] Megred David Millers changes with my own.

[FBCON] Small scrolling fix. 
parent cbb7f426
......@@ -65,15 +65,14 @@ static void bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,
// Single word
if (last)
first &= last;
FB_WRITEL((FB_READL(src) & first) | (FB_READL(dst) & ~first),
dst);
FB_WRITEL((FB_READL(src) & first) | (FB_READL(dst) & ~first), dst);
} else {
// Multiple destination words
// Leading bits
if (first) {
FB_WRITEL((FB_READL(src) & first) | (FB_READL(dst) &
~first), dst);
FB_WRITEL((FB_READL(src) & first) |
(FB_READL(dst) & ~first), dst);
dst++;
src++;
n -= BITS_PER_LONG-dst_idx;
......@@ -96,8 +95,7 @@ static void bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,
FB_WRITEL(FB_READL(src++), dst++);
// Trailing bits
if (last)
FB_WRITEL((FB_READL(src) & last) | (FB_READL(dst) &
~last), dst);
FB_WRITEL((FB_READL(src) & last) | (FB_READL(dst) & ~last), dst);
}
} else {
// Different alignment for source and dest
......@@ -220,14 +218,12 @@ static void bitcpy_rev(unsigned long *dst, int dst_idx,
// Single word
if (last)
first &= last;
FB_WRITEL((FB_READL(src) & first) | (FB_READL(dst) & ~first),
dst);
FB_WRITEL((FB_READL(src) & first) | (FB_READL(dst) & ~first), dst);
} else {
// Multiple destination words
// Leading bits
if (first) {
FB_WRITEL((FB_READL(src) & first) | (FB_READL(dst) &
~first), dst);
FB_WRITEL((FB_READL(src) & first) | (FB_READL(dst) & ~first), dst);
dst--;
src--;
n -= dst_idx+1;
......@@ -251,8 +247,7 @@ static void bitcpy_rev(unsigned long *dst, int dst_idx,
// Trailing bits
if (last)
FB_WRITEL((FB_READL(src) & last) | (FB_READL(dst) &
~last), dst);
FB_WRITEL((FB_READL(src) & last) | (FB_READL(dst) & ~last), dst);
}
} else {
// Different alignment for source and dest
......@@ -342,8 +337,10 @@ static void bitcpy_rev(unsigned long *dst, int dst_idx,
}
}
void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
{
u32 dx = area->dx, dy = area->dy, sx = area->sx, sy = area->sy;
u32 height = area->height, width = area->width;
int x2, y2, old_dx, old_dy, vxres, vyres;
unsigned long next_line = p->fix.line_length;
int dst_idx = 0, src_idx = 0, rev_copy = 0;
......@@ -370,59 +367,57 @@ void cfb_copyarea(struct fb_info *p, struct fb_copyarea *area)
*/
x2 = area->dx + area->width;
y2 = area->dy + area->height;
area->dx = area->dx > 0 ? area->dx : 0;
area->dy = area->dy > 0 ? area->dy : 0;
dx = area->dx > 0 ? area->dx : 0;
dy = area->dy > 0 ? area->dy : 0;
x2 = x2 < vxres ? x2 : vxres;
y2 = y2 < vyres ? y2 : vyres;
area->width = x2 - area->dx;
area->height = y2 - area->dy;
width = x2 - dx;
height = y2 - dy;
/* update sx1,sy1 */
area->sx += (area->dx - old_dx);
area->sy += (area->dy - old_dy);
sx += (dx - old_dx);
sy += (dy - old_dy);
/* the source must be completely inside the virtual screen */
if (area->sx < 0 || area->sy < 0 ||
(area->sx + area->width) > vxres ||
(area->sy + area->height) > vyres)
if (sx < 0 || sy < 0 ||
(sx + width) > vxres ||
(sy + height) > vyres)
return;
if ((area->dy == area->sy && area->dx > area->sx) ||
(area->dy > area->sy)) {
area->dy += area->height;
area->sy += area->height;
if ((dy == sy && dx > sx) ||
(dy > sy)) {
dy += height;
sy += height;
rev_copy = 1;
}
dst = src = (unsigned long *)((unsigned long)p->screen_base &
~(BYTES_PER_LONG-1));
dst_idx = src_idx = (unsigned long)p->screen_base & (BYTES_PER_LONG-1);
dst_idx += area->dy*next_line*8 + area->dx*p->var.bits_per_pixel;
src_idx += area->sy*next_line*8 + area->sx*p->var.bits_per_pixel;
dst_idx += dy*next_line*8 + dx*p->var.bits_per_pixel;
src_idx += sy*next_line*8 + sx*p->var.bits_per_pixel;
if (p->fbops->fb_sync)
p->fbops->fb_sync(p);
if (rev_copy) {
while (area->height--) {
while (height--) {
dst_idx -= next_line*8;
src_idx -= next_line*8;
dst += dst_idx >> SHIFT_PER_LONG;
dst_idx &= (BYTES_PER_LONG-1);
src += src_idx >> SHIFT_PER_LONG;
src_idx &= (BYTES_PER_LONG-1);
bitcpy_rev(dst, dst_idx,
src, src_idx,
area->width*p->var.bits_per_pixel);
bitcpy_rev(dst, dst_idx, src, src_idx,
width*p->var.bits_per_pixel);
}
} else {
while (area->height--) {
while (height--) {
dst += dst_idx >> SHIFT_PER_LONG;
dst_idx &= (BYTES_PER_LONG-1);
src += src_idx >> SHIFT_PER_LONG;
src_idx &= (BYTES_PER_LONG-1);
bitcpy(dst, dst_idx,
src, src_idx,
area->width*p->var.bits_per_pixel);
bitcpy(dst, dst_idx, src, src_idx,
width*p->var.bits_per_pixel);
dst_idx += next_line*8;
src_idx += next_line*8;
}
......
......@@ -73,41 +73,57 @@ static u32 cfb_tab32[] = {
0x00000000, 0xffffffff
};
#define FB_WRITEL fb_writel
#define FB_READL fb_readl
#if defined (__BIG_ENDIAN)
#define LEFT_POS(bpp) (32 - bpp)
#define NEXT_POS(pos, bpp) ((pos) -= (bpp))
#define LEFT_POS(bpp) (BITS_PER_LONG - bpp)
#define SHIFT_HIGH(val, bits) ((val) >> (bits))
#define SHIFT_LOW(val, bits) ((val) << (bits))
#else
#define LEFT_POS(bpp) (0)
#define NEXT_POS(pos, bpp) ((pos) += (bpp))
#define SHIFT_HIGH(val, bits) ((val) << (bits))
#define SHIFT_LOW(val, bits) ((val) >> (bits))
#endif
static inline void color_imageblit(struct fb_image *image, struct fb_info *p,
u8 *dst1, u32 start_index,
u32 pitch_index)
#if BITS_PER_LONG == 32
#define FB_WRITEL fb_writel
#define FB_READL fb_readl
#define INIT_FASTPATH {}
#define FASTPATH fb_writel((end_mask & eorx)^bgx, dst++)
#else
#define FB_WRITEL fb_writeq
#define FB_READL fb_readq
#define INIT_FASTPATH unsigned long val = 0, bpl = 0
#define FASTPATH { \
val |= SHIFT_HIGH((end_mask & eorx)^bgx, bpl); \
bpl += 32; \
bpl &= BITS_PER_LONG - 1; \
if (!bpl) { \
FB_WRITEL(val, dst++); \
val = 0; \
} \
}
#endif
static inline void color_imageblit(const struct fb_image *image,
struct fb_info *p, u8 *dst1,
unsigned long start_index,
unsigned long pitch_index)
{
/* Draw the penguin */
u32 *dst, *dst2, color = 0, val, shift;
unsigned long *dst, *dst2, color = 0, val, shift;
int i, n, bpp = p->var.bits_per_pixel;
u32 null_bits = 32 - bpp;
unsigned long null_bits = BITS_PER_LONG - bpp;
u32 *palette = (u32 *) p->pseudo_palette;
u8 *src = image->data;
u8 *src = (u8 *) image->data;
dst2 = (u32 *) dst1;
dst2 = (unsigned long *) dst1;
for (i = image->height; i--; ) {
dst = (unsigned long *) dst1;
n = image->width;
dst = (u32 *) dst1;
shift = 0;
val = 0;
shift = val = 0;
if (start_index) {
u32 start_mask = ~(SHIFT_HIGH(~(u32)0, start_index));
unsigned long start_mask = ~(SHIFT_HIGH(~0UL,
start_index));
val = FB_READL(dst) & start_mask;
shift = start_index;
}
......@@ -123,14 +139,14 @@ static inline void color_imageblit(struct fb_image *image, struct fb_info *p,
FB_WRITEL(val, dst++);
val = (shift == null_bits) ? 0 :
SHIFT_LOW(color, 32 - shift);
SHIFT_LOW(color,BITS_PER_LONG - shift);
}
shift += bpp;
shift &= (32 - 1);
shift &= (BITS_PER_LONG - 1);
src++;
}
if (shift) {
u32 end_mask = SHIFT_HIGH(~(u32)0, shift);
unsigned long end_mask = SHIFT_HIGH(~0UL, shift);
FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
}
......@@ -138,39 +154,41 @@ static inline void color_imageblit(struct fb_image *image, struct fb_info *p,
if (pitch_index) {
dst2 += p->fix.line_length;
dst1 = (char *) dst2;
(unsigned long) dst1 &= ~(sizeof(u32) - 1);
(unsigned long) dst1 &= ~(sizeof(unsigned long) - 1);
start_index += pitch_index;
start_index &= 32 - 1;
start_index &= BITS_PER_LONG - 1;
}
}
}
static inline void slow_imageblit(struct fb_image *image, struct fb_info *p,
u8 *dst1, u32 fgcolor,
u32 bgcolor,
u32 start_index,
u32 pitch_index)
static inline void slow_imageblit(const struct fb_image *image,
struct fb_info *p, u8 *dst1,
unsigned long fgcolor,
unsigned long bgcolor,
unsigned long start_index,
unsigned long pitch_index)
{
u32 shift, color = 0, bpp = p->var.bits_per_pixel;
u32 *dst, *dst2, val, pitch = p->fix.line_length;
u32 null_bits = 32 - bpp;
u32 spitch = (image->width+7)/8;
u8 *src = image->data, *s;
u32 i, j, l;
unsigned long shift, color = 0, bpp = p->var.bits_per_pixel;
unsigned long *dst, *dst2, val, pitch = p->fix.line_length;
unsigned long null_bits = BITS_PER_LONG - bpp;
unsigned long spitch = (image->width+7)/8;
const char *src = image->data, *s;
unsigned long i, j, l;
dst2 = (u32 *) dst1;
dst2 = (unsigned long *) dst1;
for (i = image->height; i--; ) {
shift = val = 0;
l = 8;
dst = (unsigned long *) dst1;
j = image->width;
dst = (u32 *) dst1;
shift = val = 0;
s = src;
l = 8;
/* write leading bits */
if (start_index) {
u32 start_mask = ~(SHIFT_HIGH(~(u32)0, start_index));
unsigned long start_mask = ~(SHIFT_HIGH(~0UL,
start_index));
val = FB_READL(dst) & start_mask;
shift = start_index;
}
......@@ -185,16 +203,16 @@ static inline void slow_imageblit(struct fb_image *image, struct fb_info *p,
if (shift >= null_bits) {
FB_WRITEL(val, dst++);
val = (shift == null_bits) ? 0 :
SHIFT_LOW(color,32 - shift);
SHIFT_LOW(color,BITS_PER_LONG - shift);
}
shift += bpp;
shift &= (32 - 1);
shift &= (BITS_PER_LONG - 1);
if (!l) { l = 8; s++; };
}
/* write trailing bits */
if (shift) {
u32 end_mask = SHIFT_HIGH(~(u32)0, shift);
unsigned long end_mask = SHIFT_HIGH(~0UL, shift);
FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
}
......@@ -204,10 +222,10 @@ static inline void slow_imageblit(struct fb_image *image, struct fb_info *p,
if (pitch_index) {
dst2 += pitch;
dst1 = (char *) dst2;
(unsigned long) dst1 &= ~(sizeof(u32) - 1);
(unsigned long) dst1 &= ~(sizeof(unsigned long) - 1);
start_index += pitch_index;
start_index &= 32 - 1;
start_index &= BITS_PER_LONG - 1;
}
}
......@@ -221,15 +239,15 @@ static inline void slow_imageblit(struct fb_image *image, struct fb_info *p,
* fix->line_legth is divisible by 4;
* beginning and end of a scanline is dword aligned
*/
static inline void fast_imageblit(struct fb_image *image, struct fb_info *p,
u8 *dst1, u32 fgcolor,
u32 bgcolor)
static inline void fast_imageblit(const struct fb_image *image,
struct fb_info *p, u8 *dst1,
u32 fgcolor, u32 bgcolor)
{
u32 fgx = fgcolor, bgx = bgcolor, bpp = p->var.bits_per_pixel;
u32 ppw = 32/bpp, spitch = (image->width + 7)/8;
u32 ppw = BITS_PER_LONG/bpp, spitch = (image->width + 7)/8;
u32 bit_mask, end_mask, eorx, shift;
char *s = image->data, *src;
u32 *dst;
const char *s = image->data, *src;
unsigned long *dst;
u32 *tab = NULL;
int i, j, k;
......@@ -257,12 +275,13 @@ static inline void fast_imageblit(struct fb_image *image, struct fb_info *p,
k = image->width/ppw;
for (i = image->height; i--; ) {
dst = (u32 *) dst1, shift = 8; src = s;
dst = (unsigned long *) dst1, shift = 8; src = s;
INIT_FASTPATH;
for (j = k; j--; ) {
shift -= ppw;
end_mask = tab[(*src >> shift) & bit_mask];
FB_WRITEL((end_mask & eorx)^bgx, dst++);
FASTPATH;
if (!shift) { shift = 8; src++; }
}
dst1 += p->fix.line_length;
......@@ -270,10 +289,12 @@ static inline void fast_imageblit(struct fb_image *image, struct fb_info *p,
}
}
void cfb_imageblit(struct fb_info *p, struct fb_image *image)
void cfb_imageblit(struct fb_info *p, const struct fb_image *image)
{
u32 fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
u32 bpl = sizeof(u32), bpp = p->var.bits_per_pixel;
unsigned long fgcolor, bgcolor, start_index, bitstart, pitch_index = 0;
unsigned long bpl = sizeof(unsigned long), bpp = p->var.bits_per_pixel;
u32 width = image->width, height = image->height;
u32 dx = image->dx, dy = image->dy;
int x2, y2, vxres, vyres;
u8 *dst1;
......@@ -289,15 +310,15 @@ void cfb_imageblit(struct fb_info *p, struct fb_image *image)
x2 = image->dx + image->width;
y2 = image->dy + image->height;
image->dx = image->dx > 0 ? image->dx : 0;
image->dy = image->dy > 0 ? image->dy : 0;
dx = image->dx > 0 ? image->dx : 0;
dy = image->dy > 0 ? image->dy : 0;
x2 = x2 < vxres ? x2 : vxres;
y2 = y2 < vyres ? y2 : vyres;
image->width = x2 - image->dx;
image->height = y2 - image->dy;
width = x2 - dx;
height = y2 - dy;
bitstart = (image->dy * p->fix.line_length * 8) + (image->dx * bpp);
start_index = bitstart & (32 - 1);
bitstart = (dy * p->fix.line_length * 8) + (dx * bpp);
start_index = bitstart & (BITS_PER_LONG - 1);
pitch_index = (p->fix.line_length & (bpl - 1)) * 8;
bitstart /= 8;
......@@ -307,7 +328,7 @@ void cfb_imageblit(struct fb_info *p, struct fb_image *image)
if (p->fbops->fb_sync)
p->fbops->fb_sync(p);
if (image->depth == 1) {
if (image->depth == 0) {
if (p->fix.visual == FB_VISUAL_TRUECOLOR ||
p->fix.visual == FB_VISUAL_DIRECTCOLOR) {
fgcolor = ((u32*)(p->pseudo_palette))[image->fg_color];
......@@ -317,14 +338,14 @@ void cfb_imageblit(struct fb_info *p, struct fb_image *image)
bgcolor = image->bg_color;
}
if (32 % bpp == 0 && !start_index && !pitch_index &&
((image->width & (32/bpp-1)) == 0) &&
if (BITS_PER_LONG % bpp == 0 && !start_index && !pitch_index &&
((width & (BITS_PER_LONG/bpp-1)) == 0) &&
bpp >= 8 && bpp <= 32)
fast_imageblit(image, p, dst1, fgcolor, bgcolor);
else
slow_imageblit(image, p, dst1, fgcolor, bgcolor, start_index, pitch_index);
}
else if (image->depth == bpp)
slow_imageblit(image, p, dst1, fgcolor, bgcolor,
start_index, pitch_index);
} else if (image->depth == bpp)
color_imageblit(image, p, dst1, start_index, pitch_index);
}
......
......@@ -517,41 +517,41 @@ static void accel_putc(struct vc_data *vc, struct display *p,
int c, int ypos, int xpos)
{
struct fb_image image;
struct fb_info *info = p->fb_info;
unsigned short charmask = p->charmask;
unsigned int width = (vc->vc_font.width + 7)/8;
unsigned int size, pitch;
unsigned int scan_align = info->pixmap.scan_align - 1;
unsigned int buf_align = info->pixmap.buf_align - 1;
void (*move_data)(u8 *dst, u8 *src, u32 s_pitch, u32 d_pitch,
u32 height, struct fb_info *info);
u8 *src, *dst;
struct fb_info *info = p->fb_info;
unsigned short charmask = p->charmask;
unsigned int width = (vc->vc_font.width + 7)/8;
unsigned int size, pitch;
unsigned int scan_align = info->pixmap.scan_align - 1;
unsigned int buf_align = info->pixmap.buf_align - 1;
void (*move_data)(u8 *dst, u8 *src, u32 s_pitch, u32 d_pitch,
u32 height, struct fb_info *info);
u8 *src, *dst;
if (info->pixmap.outbuf != NULL)
move_data = iomove_buf_aligned;
else
move_data = sysmove_buf_aligned;
if (info->pixmap.outbuf != NULL)
move_data = iomove_buf_aligned;
else
move_data = sysmove_buf_aligned;
image.dx = xpos * vc->vc_font.width;
image.dy = ypos * vc->vc_font.height;
image.width = vc->vc_font.width;
image.height = vc->vc_font.height;
image.fg_color = attr_fgcol(p, c);
image.bg_color = attr_bgcol(p, c);
image.depth = 0;
pitch = width + scan_align;
pitch &= ~scan_align;
size = pitch * vc->vc_font.height;
size += buf_align;
size &= ~buf_align;
dst = info->pixmap.addr + fb_get_buffer_offset(info, size);
image.data = dst;
src = p->fontdata + (c & charmask) * vc->vc_font.height * width;
move_data(dst, src, pitch, width, image.height, info);
image.dx = xpos * vc->vc_font.width;
image.dy = ypos * vc->vc_font.height;
image.width = vc->vc_font.width;
image.height = vc->vc_font.height;
image.fg_color = attr_fgcol(p, c);
image.bg_color = attr_bgcol(p, c);
image.depth = 0;
pitch = width + scan_align;
pitch &= ~scan_align;
size = pitch * vc->vc_font.height;
size += buf_align;
size &= ~buf_align;
dst = info->pixmap.addr + fb_get_buffer_offset(info, size);
image.data = dst;
src = p->fontdata + (c & charmask) * vc->vc_font.height * width;
move_data(dst, src, pitch, width, image.height, info);
info->fbops->fb_imageblit(info, &image);
info->fbops->fb_imageblit(info, &image);
}
void accel_putcs(struct vc_data *vc, struct display *p,
......@@ -589,7 +589,7 @@ void accel_clear_margins(struct vc_data *vc, struct display *p,
region.color = attr_bgcol_ec(p, vc);
region.rop = ROP_COPY;
if (rw & !bottom_only) {
if (rw && !bottom_only) {
region.dx = info->var.xoffset + rs;
region.dy = 0;
region.width = rw;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment