162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * linux/drivers/video/mfb.c -- Low level frame buffer operations for 362306a36Sopenharmony_ci * monochrome 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Created 5 Apr 1997 by Geert Uytterhoeven 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 862306a36Sopenharmony_ci * License. See the file COPYING in the main directory of this archive for 962306a36Sopenharmony_ci * more details. 1062306a36Sopenharmony_ci */ 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <linux/string.h> 1362306a36Sopenharmony_ci#include <linux/fb.h> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci#include "atafb.h" 1662306a36Sopenharmony_ci#include "atafb_utils.h" 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci /* 2062306a36Sopenharmony_ci * Monochrome 2162306a36Sopenharmony_ci */ 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_civoid atafb_mfb_copyarea(struct fb_info *info, u_long next_line, 2462306a36Sopenharmony_ci int sy, int sx, int dy, int dx, 2562306a36Sopenharmony_ci int height, int width) 2662306a36Sopenharmony_ci{ 2762306a36Sopenharmony_ci u8 *src, *dest; 2862306a36Sopenharmony_ci u_int rows; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci if (sx == 0 && dx == 0 && width == next_line) { 3162306a36Sopenharmony_ci src = (u8 *)info->screen_base + sy * (width >> 3); 3262306a36Sopenharmony_ci dest = (u8 *)info->screen_base + dy * (width >> 3); 3362306a36Sopenharmony_ci fb_memmove(dest, src, height * (width >> 3)); 3462306a36Sopenharmony_ci } else if (dy <= sy) { 3562306a36Sopenharmony_ci src = (u8 *)info->screen_base + sy * next_line + (sx >> 3); 3662306a36Sopenharmony_ci dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3); 3762306a36Sopenharmony_ci for (rows = height; rows--;) { 3862306a36Sopenharmony_ci fb_memmove(dest, src, width >> 3); 3962306a36Sopenharmony_ci src += next_line; 4062306a36Sopenharmony_ci dest += next_line; 4162306a36Sopenharmony_ci } 4262306a36Sopenharmony_ci } else { 4362306a36Sopenharmony_ci src = (u8 *)info->screen_base + (sy + height - 1) * next_line + (sx >> 3); 4462306a36Sopenharmony_ci dest = (u8 *)info->screen_base + (dy + height - 1) * next_line + (dx >> 3); 4562306a36Sopenharmony_ci for (rows = height; rows--;) { 4662306a36Sopenharmony_ci fb_memmove(dest, src, width >> 3); 4762306a36Sopenharmony_ci src -= next_line; 4862306a36Sopenharmony_ci dest -= next_line; 4962306a36Sopenharmony_ci } 5062306a36Sopenharmony_ci } 5162306a36Sopenharmony_ci} 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_civoid atafb_mfb_fillrect(struct fb_info *info, u_long next_line, u32 color, 5462306a36Sopenharmony_ci int sy, int sx, int height, int width) 5562306a36Sopenharmony_ci{ 5662306a36Sopenharmony_ci u8 *dest; 5762306a36Sopenharmony_ci u_int rows; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci dest = (u8 *)info->screen_base + sy * next_line + (sx >> 3); 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci if (sx == 0 && width == next_line) { 6262306a36Sopenharmony_ci if (color) 6362306a36Sopenharmony_ci fb_memset255(dest, height * (width >> 3)); 6462306a36Sopenharmony_ci else 6562306a36Sopenharmony_ci fb_memclear(dest, height * (width >> 3)); 6662306a36Sopenharmony_ci } else { 6762306a36Sopenharmony_ci for (rows = height; rows--; dest += next_line) { 6862306a36Sopenharmony_ci if (color) 6962306a36Sopenharmony_ci fb_memset255(dest, width >> 3); 7062306a36Sopenharmony_ci else 7162306a36Sopenharmony_ci fb_memclear_small(dest, width >> 3); 7262306a36Sopenharmony_ci } 7362306a36Sopenharmony_ci } 7462306a36Sopenharmony_ci} 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_civoid atafb_mfb_linefill(struct fb_info *info, u_long next_line, 7762306a36Sopenharmony_ci int dy, int dx, u32 width, 7862306a36Sopenharmony_ci const u8 *data, u32 bgcolor, u32 fgcolor) 7962306a36Sopenharmony_ci{ 8062306a36Sopenharmony_ci u8 *dest; 8162306a36Sopenharmony_ci u_int rows; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci dest = (u8 *)info->screen_base + dy * next_line + (dx >> 3); 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ci for (rows = width / 8; rows--; /* check margins */ ) { 8662306a36Sopenharmony_ci // use fast_memmove or fb_memmove 8762306a36Sopenharmony_ci *dest++ = *data++; 8862306a36Sopenharmony_ci } 8962306a36Sopenharmony_ci} 90