^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * linux/drivers/video/mfb.c -- Low level frame buffer operations for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * monochrome
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Created 5 Apr 1997 by Geert Uytterhoeven
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * License. See the file COPYING in the main directory of this archive for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/fb.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "atafb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "atafb_utils.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Monochrome
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) void atafb_mfb_copyarea(struct fb_info *info, u_long next_line,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) int sy, int sx, int dy, int dx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) int height, int width)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) u8 *src, *dest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) u_int rows;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) if (sx == 0 && dx == 0 && width == next_line) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) src = (u8 *)info->screen_base + sy * (width >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) dest = (u8 *)info->screen_base + dy * (width >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) fb_memmove(dest, src, height * (width >> 3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) } else if (dy <= sy) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) src = (u8 *)info->screen_base + sy * next_line + (sx >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) for (rows = height; rows--;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) fb_memmove(dest, src, width >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) src += next_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) dest += next_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) src = (u8 *)info->screen_base + (sy + height - 1) * next_line + (sx >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) dest = (u8 *)info->screen_base + (dy + height - 1) * next_line + (dx >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) for (rows = height; rows--;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) fb_memmove(dest, src, width >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) src -= next_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) dest -= next_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) int sy, int sx, int height, int width)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) u8 *dest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u_int rows;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) dest = (u8 *)info->screen_base + sy * next_line + (sx >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) if (sx == 0 && width == next_line) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) if (color)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) fb_memset255(dest, height * (width >> 3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) fb_memclear(dest, height * (width >> 3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) for (rows = height; rows--; dest += next_line) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) if (color)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) fb_memset255(dest, width >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) fb_memclear_small(dest, width >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) void atafb_mfb_linefill(struct fb_info *info, u_long next_line,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) int dy, int dx, u32 width,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) const u8 *data, u32 bgcolor, u32 fgcolor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) u8 *dest;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) u_int rows;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) for (rows = width / 8; rows--; /* check margins */ ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) // use fast_memmove or fb_memmove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) *dest++ = *data++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }