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->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;
28 if (info->state != FBINFO_STATE_RUNNING)
31 s_pitch = (cursor->image.width + 7) >> 3;
32 dsize = s_pitch * cursor->image.height;
34 src = kmalloc(dsize + sizeof(struct fb_image), GFP_ATOMIC);
38 image = (struct fb_image *) (src + dsize);
39 *image = cursor->image;
40 d_pitch = (s_pitch + scan_align) & ~scan_align;
42 size = d_pitch * image->height + buf_align;
44 dst = fb_get_buffer_offset(info, &info->pixmap, size);
47 switch (cursor->rop) {
49 for (i = 0; i < dsize; i++)
50 src[i] = image->data[i] ^ cursor->mask[i];
54 for (i = 0; i < dsize; i++)
55 src[i] = image->data[i] & cursor->mask[i];
59 memcpy(src, image->data, dsize);
61 fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height);
63 info->fbops->fb_imageblit(info, image);
68 EXPORT_SYMBOL(soft_cursor);
70 MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
71 MODULE_DESCRIPTION("Generic software cursor");
72 MODULE_LICENSE("GPL");