2 * linux/drivers/video/savage/savage_accel.c -- Hardware Acceleration
4 * Copyright (C) 2004 Antonino Daplas<adaplas@pol.net>
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
11 #include <linux/kernel.h>
12 #include <linux/string.h>
17 static u32 savagefb_rop[] = {
22 int savagefb_sync(struct fb_info *info)
24 struct savagefb_par *par = (struct savagefb_par *)info->par;
26 par->SavageWaitIdle(par);
29 EXPORT_SYMBOL(savagefb_sync);
31 void savagefb_copyarea(struct fb_info *info, const struct fb_copyarea *region)
33 struct savagefb_par *par = (struct savagefb_par *)info->par;
34 int sx = region->sx, dx = region->dx;
35 int sy = region->sy, dy = region->dy;
38 if (!region->width || !region->height)
41 cmd = BCI_CMD_RECT | BCI_CMD_DEST_GBD | BCI_CMD_SRC_GBD;
42 BCI_CMD_SET_ROP(cmd, savagefb_rop[0]);
45 cmd |= BCI_CMD_RECT_XP;
47 sx += region->width - 1;
48 dx += region->width - 1;
52 cmd |= BCI_CMD_RECT_YP;
54 sy += region->height - 1;
55 dy += region->height - 1;
58 par->SavageWaitFifo(par,4);
60 BCI_SEND(BCI_X_Y(sx, sy));
61 BCI_SEND(BCI_X_Y(dx, dy));
62 BCI_SEND(BCI_W_H(region->width, region->height));
64 EXPORT_SYMBOL(savagefb_copyarea);
66 void savagefb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
68 struct savagefb_par *par = (struct savagefb_par *)info->par;
71 if (!rect->width || !rect->height)
74 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR)
77 color = ((u32 *)info->pseudo_palette)[rect->color];
79 cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP |
80 BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID |
84 BCI_CMD_SET_ROP(cmd, savagefb_rop[rect->rop]);
86 par->SavageWaitFifo(par,4);
89 BCI_SEND( BCI_X_Y(rect->dx, rect->dy) );
90 BCI_SEND( BCI_W_H(rect->width, rect->height) );
92 EXPORT_SYMBOL(savagefb_fillrect);
94 void savagefb_imageblit(struct fb_info *info, const struct fb_image *image)
96 struct savagefb_par *par = (struct savagefb_par *)info->par;
97 int fg, bg, size, i, width;
99 u32 *src = (u32 *) image->data;
101 if (!image->width || !image->height)
104 if (image->depth != 1) {
105 cfb_imageblit(info, image);
109 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) {
110 fg = image->fg_color;
111 bg = image->bg_color;
113 fg = ((u32 *)info->pseudo_palette)[image->fg_color];
114 bg = ((u32 *)info->pseudo_palette)[image->bg_color];
117 cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP |
118 BCI_CMD_CLIP_LR | BCI_CMD_DEST_GBD | BCI_CMD_SRC_MONO |
122 BCI_CMD_SET_ROP(cmd, savagefb_rop[0]);
124 width = (image->width + 31) & ~31;
125 size = (width * image->height)/8;
128 par->SavageWaitFifo(par, size + 5);
130 BCI_SEND(BCI_CLIP_LR(image->dx, image->dx + image->width - 1));
133 BCI_SEND(BCI_X_Y(image->dx, image->dy));
134 BCI_SEND(BCI_W_H(width, image->height));
135 for (i = 0; i < size; i++)
138 EXPORT_SYMBOL(savagefb_imageblit);
140 MODULE_LICENSE("GPL");