2 * linux/drivers/video/console/softcursor.c
4 * Generic software cursor for frame buffer devices
6 * Created 14 Nov 2002 by James Simmons
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file COPYING in the main directory of this
10 * archive for more details.
13 #include <linux/module.h>
14 #include <linux/string.h>
16 #include <linux/slab.h>
22 int soft_cursor(struct fb_info
*info
, struct fb_cursor
*cursor
)
24 struct fbcon_ops
*ops
= info
->fbcon_par
;
25 unsigned int scan_align
= info
->pixmap
.scan_align
- 1;
26 unsigned int buf_align
= info
->pixmap
.buf_align
- 1;
27 unsigned int i
, size
, dsize
, s_pitch
, d_pitch
;
28 struct fb_image
*image
;
31 if (info
->state
!= FBINFO_STATE_RUNNING
)
34 s_pitch
= (cursor
->image
.width
+ 7) >> 3;
35 dsize
= s_pitch
* cursor
->image
.height
;
37 if (dsize
+ sizeof(struct fb_image
) != ops
->cursor_size
) {
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 src
= ops
->cursor_src
+ sizeof(struct fb_image
);
49 image
= (struct fb_image
*)ops
->cursor_src
;
50 *image
= cursor
->image
;
51 d_pitch
= (s_pitch
+ scan_align
) & ~scan_align
;
53 size
= d_pitch
* image
->height
+ buf_align
;
55 dst
= fb_get_buffer_offset(info
, &info
->pixmap
, size
);
58 switch (cursor
->rop
) {
60 for (i
= 0; i
< dsize
; i
++)
61 src
[i
] = image
->data
[i
] ^ cursor
->mask
[i
];
65 for (i
= 0; i
< dsize
; i
++)
66 src
[i
] = image
->data
[i
] & cursor
->mask
[i
];
70 memcpy(src
, image
->data
, dsize
);
72 fb_pad_aligned_buffer(dst
, d_pitch
, src
, s_pitch
, image
->height
);
74 info
->fbops
->fb_imageblit(info
, image
);