at v2.6.18 73 lines 1.8 kB view raw
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/fb.h> 14#include <linux/slab.h> 15 16#include <asm/uaccess.h> 17#include <asm/io.h> 18 19#include "fbcon.h" 20 21int soft_cursor(struct fb_info *info, struct fb_cursor *cursor) 22{ 23 unsigned int scan_align = info->pixmap.scan_align - 1; 24 unsigned int buf_align = info->pixmap.buf_align - 1; 25 unsigned int i, size, dsize, s_pitch, d_pitch; 26 struct fb_image *image; 27 u8 *dst, *src; 28 29 if (info->state != FBINFO_STATE_RUNNING) 30 return 0; 31 32 s_pitch = (cursor->image.width + 7) >> 3; 33 dsize = s_pitch * cursor->image.height; 34 35 src = kmalloc(dsize + sizeof(struct fb_image), GFP_ATOMIC); 36 if (!src) 37 return -ENOMEM; 38 39 image = (struct fb_image *) (src + dsize); 40 *image = cursor->image; 41 d_pitch = (s_pitch + scan_align) & ~scan_align; 42 43 size = d_pitch * image->height + buf_align; 44 size &= ~buf_align; 45 dst = fb_get_buffer_offset(info, &info->pixmap, size); 46 47 if (cursor->enable) { 48 switch (cursor->rop) { 49 case ROP_XOR: 50 for (i = 0; i < dsize; i++) 51 src[i] = image->data[i] ^ cursor->mask[i]; 52 break; 53 case ROP_COPY: 54 default: 55 for (i = 0; i < dsize; i++) 56 src[i] = image->data[i] & cursor->mask[i]; 57 break; 58 } 59 } else 60 memcpy(src, image->data, dsize); 61 62 fb_pad_aligned_buffer(dst, d_pitch, src, s_pitch, image->height); 63 image->data = dst; 64 info->fbops->fb_imageblit(info, image); 65 kfree(src); 66 return 0; 67} 68 69EXPORT_SYMBOL(soft_cursor); 70 71MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>"); 72MODULE_DESCRIPTION("Generic software cursor"); 73MODULE_LICENSE("GPL");