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 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
;
29 if (info
->state
!= FBINFO_STATE_RUNNING
)
32 s_pitch
= (cursor
->image
.width
+ 7) >> 3;
33 dsize
= s_pitch
* cursor
->image
.height
;
35 src
= kmalloc(dsize
+ sizeof(struct fb_image
), GFP_ATOMIC
);
39 image
= (struct fb_image
*) (src
+ dsize
);
40 *image
= cursor
->image
;
41 d_pitch
= (s_pitch
+ scan_align
) & ~scan_align
;
43 size
= d_pitch
* image
->height
+ buf_align
;
45 dst
= fb_get_buffer_offset(info
, &info
->pixmap
, size
);
48 switch (cursor
->rop
) {
50 for (i
= 0; i
< dsize
; i
++)
51 src
[i
] = image
->data
[i
] ^ cursor
->mask
[i
];
55 for (i
= 0; i
< dsize
; i
++)
56 src
[i
] = image
->data
[i
] & cursor
->mask
[i
];
60 memcpy(src
, image
->data
, dsize
);
62 fb_pad_aligned_buffer(dst
, d_pitch
, src
, s_pitch
, image
->height
);
64 info
->fbops
->fb_imageblit(info
, image
);
69 EXPORT_SYMBOL(soft_cursor
);
71 MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
72 MODULE_DESCRIPTION("Generic software cursor");
73 MODULE_LICENSE("GPL");