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>
22 int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
24 unsigned int scan_align = info->pixmap.scan_align - 1;
25 unsigned int buf_align = info->pixmap.buf_align - 1;
26 unsigned int i, size, dsize, s_pitch, d_pitch;
27 struct fb_image *image;
30 if (info->state != FBINFO_STATE_RUNNING)
33 s_pitch = (cursor->image.width + 7) >> 3;
34 dsize = s_pitch * cursor->image.height;
36 src = kmalloc(dsize + sizeof(struct fb_image), GFP_ATOMIC);
40 image = (struct fb_image *) (src + dsize);
41 *image = cursor->image;
42 d_pitch = (s_pitch + scan_align) & ~scan_align;
44 size = d_pitch * image->height + buf_align;
46 dst = fb_get_buffer_offset(info, &info->pixmap, size);
49 switch (cursor->rop) {
51 for (i = 0; i < dsize; i++)
52 src[i] = image->data[i] ^ cursor->mask[i];
56 for (i = 0; i < dsize; i++)
57 src[i] = image->data[i] & cursor->mask[i];
61 memcpy(src, image->data, dsize);
63 fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height);
65 info->fbops->fb_imageblit(info, image);
70 EXPORT_SYMBOL(soft_cursor);
72 MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
73 MODULE_DESCRIPTION("Generic software cursor");
74 MODULE_LICENSE("GPL");