diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/video/softcursor.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/softcursor.c')
-rw-r--r-- | drivers/video/softcursor.c | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/drivers/video/softcursor.c b/drivers/video/softcursor.c new file mode 100644 index 000000000000..13a4511539a1 --- /dev/null +++ b/drivers/video/softcursor.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
2 | * linux/drivers/video/softcursor.c -- Generic software cursor for frame buffer devices | ||
3 | * | ||
4 | * Created 14 Nov 2002 by James Simmons | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General Public | ||
7 | * License. See the file COPYING in the main directory of this archive | ||
8 | * for more details. | ||
9 | */ | ||
10 | |||
11 | #include <linux/module.h> | ||
12 | #include <linux/string.h> | ||
13 | #include <linux/tty.h> | ||
14 | #include <linux/fb.h> | ||
15 | #include <linux/slab.h> | ||
16 | |||
17 | #include <asm/uaccess.h> | ||
18 | #include <asm/io.h> | ||
19 | |||
20 | int soft_cursor(struct fb_info *info, struct fb_cursor *cursor) | ||
21 | { | ||
22 | unsigned int scan_align = info->pixmap.scan_align - 1; | ||
23 | unsigned int buf_align = info->pixmap.buf_align - 1; | ||
24 | unsigned int i, size, dsize, s_pitch, d_pitch; | ||
25 | struct fb_image *image; | ||
26 | u8 *dst, *src; | ||
27 | |||
28 | if (info->state != FBINFO_STATE_RUNNING) | ||
29 | return 0; | ||
30 | |||
31 | s_pitch = (cursor->image.width + 7) >> 3; | ||
32 | dsize = s_pitch * cursor->image.height; | ||
33 | |||
34 | src = kmalloc(dsize + sizeof(struct fb_image), GFP_ATOMIC); | ||
35 | if (!src) | ||
36 | return -ENOMEM; | ||
37 | |||
38 | image = (struct fb_image *) (src + dsize); | ||
39 | *image = cursor->image; | ||
40 | d_pitch = (s_pitch + scan_align) & ~scan_align; | ||
41 | |||
42 | size = d_pitch * image->height + buf_align; | ||
43 | size &= ~buf_align; | ||
44 | dst = fb_get_buffer_offset(info, &info->pixmap, size); | ||
45 | |||
46 | if (cursor->enable) { | ||
47 | switch (cursor->rop) { | ||
48 | case ROP_XOR: | ||
49 | for (i = 0; i < dsize; i++) | ||
50 | src[i] = image->data[i] ^ cursor->mask[i]; | ||
51 | break; | ||
52 | case ROP_COPY: | ||
53 | default: | ||
54 | for (i = 0; i < dsize; i++) | ||
55 | src[i] = image->data[i] & cursor->mask[i]; | ||
56 | break; | ||
57 | } | ||
58 | } else | ||
59 | memcpy(src, image->data, dsize); | ||
60 | |||
61 | if (info->pixmap.outbuf) | ||
62 | fb_iomove_buf_aligned(info, &info->pixmap, dst, d_pitch, src, | ||
63 | s_pitch, image->height); | ||
64 | else | ||
65 | fb_sysmove_buf_aligned(info, &info->pixmap, dst, d_pitch, src, | ||
66 | s_pitch, image->height); | ||
67 | |||
68 | image->data = dst; | ||
69 | info->fbops->fb_imageblit(info, image); | ||
70 | kfree(src); | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | EXPORT_SYMBOL(soft_cursor); | ||
76 | |||
77 | MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>"); | ||
78 | MODULE_DESCRIPTION("Generic software cursor"); | ||
79 | MODULE_LICENSE("GPL"); | ||