fbcon-accel.c 4.63 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
/*
 *  linux/drivers/video/fbcon-accel.c -- Framebuffer accel console wrapper
 *
 *      Created 20 Feb 2001 by James Simmons <jsimmons@users.sf.net>
 *
 *  This file is subject to the terms and conditions of the GNU General Public
 *  License.  See the file COPYING in the main directory of this archive for
 *  more details.
 */

#include <linux/module.h>
#include <linux/tty.h>
#include <linux/console.h>
#include <linux/string.h>
#include <linux/fb.h>

#include <video/fbcon.h>
#include "fbcon-accel.h"

void fbcon_accel_setup(struct display *p)
{
	p->next_line = p->fb_info->fix.line_length;
	p->next_plane = 0;
}

void fbcon_accel_bmove(struct display *p, int sy, int sx, int dy, int dx,
		       int height, int width)
{
	struct fb_info *info = p->fb_info;
	struct fb_copyarea area;

	area.sx = sx * fontwidth(p);
	area.sy = sy * fontheight(p);
	area.dx = dx * fontwidth(p);
	area.dy = dy * fontheight(p);
	area.height = height * fontheight(p);
	area.width  = width * fontwidth(p);

	info->fbops->fb_copyarea(info, &area);
}

void fbcon_accel_clear(struct vc_data *vc, struct display *p, int sy, int sx,
		       int height, int width)
{
	struct fb_info *info = p->fb_info;
	struct fb_fillrect region;

	region.color = attr_bgcol_ec(p,vc);
	region.dx = sx * fontwidth(p);
	region.dy = sy * fontheight(p);
	region.width = width * fontwidth(p);
	region.height = height * fontheight(p);
	region.rop = ROP_COPY;

	info->fbops->fb_fillrect(info, &region);
}

void fbcon_accel_putc(struct vc_data *vc, struct display *p, int c, int yy,
		      int xx)
{
	struct fb_info *info = p->fb_info;
	unsigned short charmask = p->charmask;
	unsigned int width = ((fontwidth(p)+7)>>3);
	struct fb_image image;

	image.fg_color = attr_fgcol(p, c);
	image.bg_color = attr_bgcol(p, c);
	image.dx = xx * fontwidth(p);
	image.dy = yy * fontheight(p);
	image.width = fontwidth(p);
	image.height = fontheight(p);
	image.depth = 1;
	image.data = p->fontdata + (c & charmask)*fontheight(p)*width;

	info->fbops->fb_imageblit(info, &image);
}

void fbcon_accel_putcs(struct vc_data *vc, struct display *p,
		       const unsigned short *s, int count, int yy, int xx)
{
	struct fb_info *info = p->fb_info;
	unsigned short charmask = p->charmask;
	unsigned int width = ((fontwidth(p)+7)>>3);
	struct fb_image image;

	image.fg_color = attr_fgcol(p, *s);
	image.bg_color = attr_bgcol(p, *s);
	image.dx = xx * fontwidth(p);
	image.dy = yy * fontheight(p);
	image.width = fontwidth(p);
	image.height = fontheight(p);
	image.depth = 1;

	while (count--) {
		image.data = p->fontdata +
			(scr_readw(s++) & charmask) * fontheight(p) * width;
		info->fbops->fb_imageblit(info, &image);
		image.dx += fontwidth(p);
	}
}

void fbcon_accel_revc(struct display *p, int xx, int yy)
{
	struct fb_info *info = p->fb_info;
	struct fb_fillrect region;

	region.color = attr_fgcol_ec(p, p->conp);
	region.dx = xx * fontwidth(p);
	region.dy = yy * fontheight(p);
	region.width  = fontwidth(p);
	region.height = fontheight(p); 
	region.rop = ROP_XOR;
	
	info->fbops->fb_fillrect(info, &region);
}

void fbcon_accel_clear_margins(struct vc_data *vc, struct display *p,
			       int bottom_only)
{
	struct fb_info *info = p->fb_info;
	unsigned int cw = fontwidth(p);
	unsigned int ch = fontheight(p);
	unsigned int rw = info->var.xres % cw;
	unsigned int bh = info->var.yres % ch;
	unsigned int rs = info->var.xres - rw;
	unsigned int bs = info->var.yres - bh;
	struct fb_fillrect region;

	region.color = attr_bgcol_ec(p,vc);
	region.rop = ROP_COPY;

	if (rw && !bottom_only) {
		region.dx = info->var.xoffset + rs;
		region.dy = 0;
		region.width  = rw;
		region.height = info->var.yres_virtual;
		info->fbops->fb_fillrect(info, &region); 
	}

	if (bh) {
		region.dx = info->var.xoffset;
                region.dy = info->var.yoffset + bs;
                region.width  = rs;
                region.height = bh;
		info->fbops->fb_fillrect(info, &region);
	}
}

    /*
     *  `switch' for the low level operations
     */

struct display_switch fbcon_accel = {
154 155 156 157 158 159 160 161
	.setup =	fbcon_accel_setup,
	.bmove =	fbcon_accel_bmove,
	.clear =	fbcon_accel_clear,
	.putc =		fbcon_accel_putc,
	.putcs =	fbcon_accel_putcs,
	.revc =		fbcon_accel_revc,
	.clear_margins =fbcon_accel_clear_margins,
	.fontwidthmask =FONTWIDTHRANGE(1, 16)	
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
};

#ifdef MODULE
MODULE_LICENSE("GPL");

int init_module(void)
{
    return 0;
}

void cleanup_module(void)
{}
#endif /* MODULE */


    /*
     *  Visible symbols for modules
     */

EXPORT_SYMBOL(fbcon_accel);
EXPORT_SYMBOL(fbcon_accel_setup);
EXPORT_SYMBOL(fbcon_accel_bmove);
EXPORT_SYMBOL(fbcon_accel_clear);
EXPORT_SYMBOL(fbcon_accel_putc);
EXPORT_SYMBOL(fbcon_accel_putcs);
EXPORT_SYMBOL(fbcon_accel_revc);
EXPORT_SYMBOL(fbcon_accel_clear_margins);