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>
14 #include <linux/slab.h>
16 #include <asm/uaccess.h>
21 int soft_cursor(struct fb_info *info, struct fb_cursor *cursor)
23 struct fbcon_ops *ops = info->fbcon_par;
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 if (dsize + sizeof(struct fb_image) != ops->cursor_size) {
37 if (ops->cursor_src != NULL)
38 kfree(ops->cursor_src);
39 ops->cursor_size = dsize + sizeof(struct fb_image);
41 ops->cursor_src = kmalloc(ops->cursor_size, GFP_ATOMIC);
42 if (!ops->cursor_src) {
48 image = (struct fb_image *) (ops->cursor_src + dsize);
49 *image = cursor->image;
50 d_pitch = (s_pitch + scan_align) & ~scan_align;
52 size = d_pitch * image->height + buf_align;
54 dst = fb_get_buffer_offset(info, &info->pixmap, size);
57 switch (cursor->rop) {
59 for (i = 0; i < dsize; i++)
60 ops->cursor_src[i] = image->data[i] ^
65 for (i = 0; i < dsize; i++)
66 ops->cursor_src[i] = image->data[i] &
71 memcpy(ops->cursor_src, image->data, dsize);
73 fb_pad_aligned_buffer(dst, d_pitch, ops->cursor_src, s_pitch,
76 info->fbops->fb_imageblit(info, image);
80 EXPORT_SYMBOL(soft_cursor);
82 MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
83 MODULE_DESCRIPTION("Generic software cursor");
84 MODULE_LICENSE("GPL");