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>
20 int soft_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
22 unsigned int scan_align
= info
->sprite
.scan_align
- 1;
23 unsigned int buf_align
= info
->sprite
.buf_align
- 1;
24 unsigned int i
, size
, dsize
, s_pitch
, d_pitch
;
25 struct fb_cursor
*cur
;
28 if (cursor
->set
& FB_CUR_SETSIZE
) {
29 info
->cursor
.image
.height
= cursor
->image
.height
;
30 info
->cursor
.image
.width
= cursor
->image
.width
;
33 if (cursor
->set
& FB_CUR_SETPOS
) {
34 info
->cursor
.image
.dx
= cursor
->image
.dx
;
35 info
->cursor
.image
.dy
= cursor
->image
.dy
;
38 if (cursor
->set
& FB_CUR_SETHOT
)
39 info
->cursor
.hot
= cursor
->hot
;
41 if (cursor
->set
& FB_CUR_SETCMAP
) {
42 if (cursor
->image
.depth
== 1) {
43 info
->cursor
.image
.bg_color
= cursor
->image
.bg_color
;
44 info
->cursor
.image
.fg_color
= cursor
->image
.fg_color
;
46 if (cursor
->image
.cmap
.len
)
47 fb_copy_cmap(&cursor
->image
.cmap
, &info
->cursor
.image
.cmap
);
49 info
->cursor
.image
.depth
= cursor
->image
.depth
;
52 info
->cursor
.image
.data
= cursor
->image
.data
;
54 if (info
->state
!= FBINFO_STATE_RUNNING
)
57 src
= kmalloc(64 + sizeof(struct fb_cursor
), GFP_ATOMIC
);
60 cur
= (struct fb_cursor
*) (src
+ 64);
63 s_pitch
= (info
->cursor
.image
.width
+ 7) >> 3;
64 dsize
= s_pitch
* info
->cursor
.image
.height
;
65 d_pitch
= (s_pitch
+ scan_align
) & ~scan_align
;
66 size
= d_pitch
* info
->cursor
.image
.height
+ buf_align
;
68 dst
= fb_get_buffer_offset(info
, &info
->sprite
, size
);
70 if (info
->cursor
.enable
) {
71 switch (info
->cursor
.rop
) {
73 for (i
= 0; i
< dsize
; i
++)
74 src
[i
] = cursor
->image
.data
[i
] ^ info
->cursor
.mask
[i
];
78 for (i
= 0; i
< dsize
; i
++)
79 src
[i
] = cursor
->image
.data
[i
] & info
->cursor
.mask
[i
];
83 memcpy(src
, cursor
->image
.data
, dsize
);
85 if (info
->sprite
.outbuf
)
86 fb_iomove_buf_aligned(info
, &info
->sprite
, dst
, d_pitch
, src
,
87 s_pitch
, info
->cursor
.image
.height
);
89 fb_sysmove_buf_aligned(info
, &info
->sprite
, dst
, d_pitch
, src
,
90 s_pitch
, info
->cursor
.image
.height
);
91 cur
->image
.data
= dst
;
93 info
->fbops
->fb_imageblit(info
, &cur
->image
);
100 EXPORT_SYMBOL(soft_cursor
);
102 MODULE_AUTHOR("James Simmons <jsimmons@users.sf.net>");
103 MODULE_DESCRIPTION("Generic software cursor");
104 MODULE_LICENSE("GPL");