2 * linux/drivers/video/softcursor.c -- Generic software cursor for frame buffer devices
4 * Created 14 Nov 2002 by James Simmons
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
11 #include <linux/module.h>
12 #include <linux/string.h>
13 #include <linux/tty.h>
15 #include <linux/slab.h>
17 #include <asm/uaccess.h>
20 int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
22 unsigned int scan_align = info->sprite.scan_align - 1;
23 unsigned int buf_align = info->sprite.buf_align - 1;
24 unsigned int i, size, dsize, s_pitch, d_pitch;
27 if (cursor->set & FB_CUR_SETSIZE) {
28 info->cursor.image.height = cursor->image.height;
29 info->cursor.image.width = cursor->image.width;
32 if (cursor->set & FB_CUR_SETPOS) {
33 info->cursor.image.dx = cursor->image.dx;
34 info->cursor.image.dy = cursor->image.dy;
37 if (cursor->set & FB_CUR_SETHOT)
38 info->cursor.hot = cursor->hot;
40 if (cursor->set & FB_CUR_SETCMAP) {
41 if (cursor->image.depth == 1) {
42 info->cursor.image.bg_color = cursor->image.bg_color;
43 info->cursor.image.fg_color = cursor->image.fg_color;
45 if (cursor->image.cmap.len)
46 fb_copy_cmap(&cursor->image.cmap, &info->cursor.image.cmap, 0);
48 info->cursor.image.depth = cursor->image.depth;
51 if (info->state != FBINFO_STATE_RUNNING)
54 s_pitch = (info->cursor.image.width + 7) >> 3;
55 dsize = s_pitch * info->cursor.image.height;
56 d_pitch = (s_pitch + scan_align) & ~scan_align;
57 size = d_pitch * info->cursor.image.height + buf_align;
59 dst = fb_get_buffer_offset(info, &info->sprite, size);
61 if (info->cursor.enable) {
62 switch (info->cursor.rop) {
64 for (i = 0; i < dsize; i++)
65 src[i] = cursor->image.data[i] ^ info->cursor.mask[i];
69 for (i = 0; i < dsize; i++)
70 src[i] = cursor->image.data[i] & info->cursor.mask[i];
74 memcpy(src, cursor->image.data, dsize);
76 fb_move_buf_aligned(info, &info->sprite, dst, d_pitch, src, s_pitch, info->cursor.image.height);
77 info->cursor.image.data = dst;
79 info->fbops->fb_imageblit(info, &info->cursor.image);
83 EXPORT_SYMBOL(soft_cursor);
85 MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
86 MODULE_DESCRIPTION("Generic software cursor");
87 MODULE_LICENSE("GPL");