aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/savage/savagefb_accel.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/video/savage/savagefb_accel.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/video/savage/savagefb_accel.c')
-rw-r--r--drivers/video/savage/savagefb_accel.c136
1 files changed, 136 insertions, 0 deletions
diff --git a/drivers/video/savage/savagefb_accel.c b/drivers/video/savage/savagefb_accel.c
new file mode 100644
index 000000000000..bac8ea3a0108
--- /dev/null
+++ b/drivers/video/savage/savagefb_accel.c
@@ -0,0 +1,136 @@
1/*-*- linux-c -*-
2 * linux/drivers/video/savage/savage_accel.c -- Hardware Acceleration
3 *
4 * Copyright (C) 2004 Antonino Daplas<adaplas@pol.net>
5 * All Rights Reserved
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#include <linux/kernel.h>
12#include <linux/string.h>
13#include <linux/fb.h>
14
15#include "savagefb.h"
16
17static u32 savagefb_rop[] = {
18 0xCC, /* ROP_COPY */
19 0x5A /* ROP_XOR */
20};
21
22int savagefb_sync(struct fb_info *info)
23{
24 struct savagefb_par *par = (struct savagefb_par *)info->par;
25
26 par->SavageWaitIdle(par);
27 return 0;
28}
29
30void savagefb_copyarea(struct fb_info *info, const struct fb_copyarea *region)
31{
32 struct savagefb_par *par = (struct savagefb_par *)info->par;
33 int sx = region->sx, dx = region->dx;
34 int sy = region->sy, dy = region->dy;
35 int cmd;
36
37 if (!region->width || !region->height)
38 return;
39 par->bci_ptr = 0;
40 cmd = BCI_CMD_RECT | BCI_CMD_DEST_GBD | BCI_CMD_SRC_GBD;
41 BCI_CMD_SET_ROP(cmd, savagefb_rop[0]);
42
43 if (dx <= sx) {
44 cmd |= BCI_CMD_RECT_XP;
45 } else {
46 sx += region->width - 1;
47 dx += region->width - 1;
48 }
49
50 if (dy <= sy) {
51 cmd |= BCI_CMD_RECT_YP;
52 } else {
53 sy += region->height - 1;
54 dy += region->height - 1;
55 }
56
57 par->SavageWaitFifo(par,4);
58 BCI_SEND(cmd);
59 BCI_SEND(BCI_X_Y(sx, sy));
60 BCI_SEND(BCI_X_Y(dx, dy));
61 BCI_SEND(BCI_W_H(region->width, region->height));
62}
63
64void savagefb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
65{
66 struct savagefb_par *par = (struct savagefb_par *)info->par;
67 int cmd, color;
68
69 if (!rect->width || !rect->height)
70 return;
71
72 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR)
73 color = rect->color;
74 else
75 color = ((u32 *)info->pseudo_palette)[rect->color];
76
77 cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP |
78 BCI_CMD_DEST_GBD | BCI_CMD_SRC_SOLID |
79 BCI_CMD_SEND_COLOR;
80
81 par->bci_ptr = 0;
82 BCI_CMD_SET_ROP(cmd, savagefb_rop[rect->rop]);
83
84 par->SavageWaitFifo(par,4);
85 BCI_SEND(cmd);
86 BCI_SEND(color);
87 BCI_SEND( BCI_X_Y(rect->dx, rect->dy) );
88 BCI_SEND( BCI_W_H(rect->width, rect->height) );
89}
90
91void savagefb_imageblit(struct fb_info *info, const struct fb_image *image)
92{
93 struct savagefb_par *par = (struct savagefb_par *)info->par;
94 int fg, bg, size, i, width;
95 int cmd;
96 u32 *src = (u32 *) image->data;
97
98 if (!image->width || !image->height)
99 return;
100
101 if (image->depth != 1) {
102 cfb_imageblit(info, image);
103 return;
104 }
105
106 if (info->fix.visual == FB_VISUAL_PSEUDOCOLOR) {
107 fg = image->fg_color;
108 bg = image->bg_color;
109 } else {
110 fg = ((u32 *)info->pseudo_palette)[image->fg_color];
111 bg = ((u32 *)info->pseudo_palette)[image->bg_color];
112 }
113
114 cmd = BCI_CMD_RECT | BCI_CMD_RECT_XP | BCI_CMD_RECT_YP |
115 BCI_CMD_CLIP_LR | BCI_CMD_DEST_GBD | BCI_CMD_SRC_MONO |
116 BCI_CMD_SEND_COLOR;
117
118 par->bci_ptr = 0;
119 BCI_CMD_SET_ROP(cmd, savagefb_rop[0]);
120
121 width = (image->width + 31) & ~31;
122 size = (width * image->height)/8;
123 size >>= 2;
124
125 par->SavageWaitFifo(par, size + 5);
126 BCI_SEND(cmd);
127 BCI_SEND(BCI_CLIP_LR(image->dx, image->dx + image->width - 1));
128 BCI_SEND(fg);
129 BCI_SEND(bg);
130 BCI_SEND(BCI_X_Y(image->dx, image->dy));
131 BCI_SEND(BCI_W_H(width, image->height));
132 for (i = 0; i < size; i++)
133 BCI_SEND(src[i]);
134}
135
136MODULE_LICENSE("GPL");