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