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