Commit 21324daa authored by James Simmons's avatar James Simmons

Cleaned up the cursor api. Now it uses fb_imaeg which makes sense since a...

Cleaned up the cursor api. Now it uses fb_imaeg which makes sense since a cursor is a image.More code cleanup for fbcon.c. Removal of excess elements passed into functions. 
parent 52540260
......@@ -17,9 +17,9 @@
#include <asm/uaccess.h>
#include <asm/io.h>
int cfb_cursor(struct fb_info *info, struct fbcursor *cursor)
int cfb_cursor(struct fb_info *info, struct fb_cursor *cursor)
{
int i, size = ((cursor->size.x + 7) / 8) * cursor->size.y;
int i, size = ((cursor->image.width + 7) / 8) * cursor->image.height;
struct fb_image image;
static char data[64];
......@@ -27,7 +27,7 @@ int cfb_cursor(struct fb_info *info, struct fbcursor *cursor)
switch (cursor->rop) {
case ROP_XOR:
for (i = 0; i < size; i++)
data[i] = (cursor->image[i] &
data[i] = (cursor->image.data[i] &
cursor->mask[i]) ^
cursor->dest[i];
break;
......@@ -35,22 +35,19 @@ int cfb_cursor(struct fb_info *info, struct fbcursor *cursor)
default:
for (i = 0; i < size; i++)
data[i] =
cursor->image[i] & cursor->mask[i];
cursor->image.data[i] & cursor->mask[i];
break;
}
} else
memcpy(data, cursor->dest, size);
if (cursor->depth == 1) {
image.bg_color = cursor->index->entry[0];
image.fg_color = cursor->index->entry[1];
}
image.dx = cursor->pos.x;
image.dy = cursor->pos.y;
image.width = cursor->size.x;
image.height = cursor->size.y;
image.depth = cursor->depth;
image.bg_color = cursor->image.bg_color;
image.fg_color = cursor->image.fg_color;
image.dx = cursor->image.dx;
image.dy = cursor->image.dy;
image.width = cursor->image.width;
image.height = cursor->image.height;
image.depth = cursor->image.depth;
image.data = data;
if (info->fbops->fb_imageblit)
......
......@@ -149,12 +149,11 @@ void fbcon_accel_clear_margins(struct vc_data *vc, struct display *p,
void fbcon_accel_cursor(struct display *p, int flags, int xx, int yy)
{
static u32 palette_index[2];
static struct fb_index index = { 2, palette_index };
static char mask[64], image[64], *dest;
struct vc_data *vc = p->conp;
static int fgcolor, bgcolor, shape, width, height;
struct fb_info *info = p->fb_info;
struct fbcursor cursor;
struct fb_cursor cursor;
int c;
char *font;
......@@ -165,18 +164,20 @@ void fbcon_accel_cursor(struct display *p, int flags, int xx, int yy)
cursor.set |= FB_CUR_SETSIZE;
}
if ((p->conp->vc_cursor_type & 0x0f) != shape) {
shape = p->conp->vc_cursor_type & 0x0f;
if ((vc->vc_cursor_type & 0x0f) != shape) {
shape = vc->vc_cursor_type & 0x0f;
cursor.set |= FB_CUR_SETSHAPE;
}
c = scr_readw((u16 *) p->cursor_pos);
c = scr_readw((u16 *) vc->vc_pos);
if (fgcolor != (int) attr_fgcol(p, c) ||
bgcolor != (int) attr_bgcol(p, c)) {
fgcolor = (int) attr_fgcol(p, c);
bgcolor = (int) attr_bgcol(p, c);
cursor.set |= FB_CUR_SETCMAP;
cursor.image.bg_color = bgcolor;
cursor.image.fg_color = fgcolor;
}
c &= p->charmask;
......@@ -191,11 +192,6 @@ void fbcon_accel_cursor(struct display *p, int flags, int xx, int yy)
else
cursor.enable = 0;
if (cursor.set & FB_CUR_SETCMAP) {
palette_index[0] = bgcolor;
palette_index[1] = fgcolor;
}
if (cursor.set & FB_CUR_SETSIZE) {
memset(image, 0xff, 64);
cursor.set |= FB_CUR_SETSHAPE;
......@@ -236,16 +232,15 @@ void fbcon_accel_cursor(struct display *p, int flags, int xx, int yy)
mask[i++] = 0xff;
}
cursor.size.x = width;
cursor.size.y = height;
cursor.pos.x = xx * width;
cursor.pos.y = yy * height;
cursor.image = image;
cursor.image.width = width;
cursor.image.height = height;
cursor.image.dx = xx * width;
cursor.image.dy = yy * height;
cursor.image.depth = 1;
cursor.image.data = image;
cursor.mask = mask;
cursor.dest = dest;
cursor.rop = ROP_XOR;
cursor.index = &index;
cursor.depth = 1;
if (info->fbops->fb_cursor)
info->fbops->fb_cursor(info, &cursor);
......
......@@ -205,14 +205,14 @@ static void fbcon_set_display(int con, int init, int logo);
static __inline__ int real_y(struct display *p, int ypos);
static void fbcon_vbl_handler(int irq, void *dummy, struct pt_regs *fp);
static __inline__ void updatescrollmode(struct display *p);
static __inline__ void ywrap_up(int unit, struct vc_data *vc,
struct display *p, int count);
static __inline__ void ywrap_down(int unit, struct vc_data *vc,
struct display *p, int count);
static __inline__ void ypan_up(int unit, struct vc_data *vc,
struct display *p, int count);
static __inline__ void ypan_down(int unit, struct vc_data *vc,
struct display *p, int count);
static __inline__ void ywrap_up(struct display *p, struct vc_data *vc,
int count);
static __inline__ void ywrap_down(struct display *p, struct vc_data *vc,
int count);
static __inline__ void ypan_up(struct display *p, struct vc_data *vc,
int count);
static __inline__ void ypan_down(struct display *p, struct vc_data *vc,
int count);
static void fbcon_bmove_rec(struct display *p, int sy, int sx, int dy,
int dx, int height, int width, u_int y_break);
......@@ -974,8 +974,8 @@ int update_var(int con, struct fb_info *info)
return 0;
}
static __inline__ void ywrap_up(int unit, struct vc_data *vc,
struct display *p, int count)
static __inline__ void ywrap_up(struct display *p, struct vc_data *vc,
int count)
{
struct fb_info *info = p->fb_info;
......@@ -985,15 +985,15 @@ static __inline__ void ywrap_up(int unit, struct vc_data *vc,
info->var.xoffset = 0;
info->var.yoffset = p->yscroll * fontheight(p);
info->var.vmode |= FB_VMODE_YWRAP;
update_var(unit, info);
update_var(vc->vc_num, info);
scrollback_max += count;
if (scrollback_max > scrollback_phys_max)
scrollback_max = scrollback_phys_max;
scrollback_current = 0;
}
static __inline__ void ywrap_down(int unit, struct vc_data *vc,
struct display *p, int count)
static __inline__ void ywrap_down(struct display *p, struct vc_data *vc,
int count)
{
struct fb_info *info = p->fb_info;
......@@ -1003,15 +1003,15 @@ static __inline__ void ywrap_down(int unit, struct vc_data *vc,
info->var.xoffset = 0;
info->var.yoffset = p->yscroll * fontheight(p);
info->var.vmode |= FB_VMODE_YWRAP;
update_var(unit, info);
update_var(vc->vc_num, info);
scrollback_max -= count;
if (scrollback_max < 0)
scrollback_max = 0;
scrollback_current = 0;
}
static __inline__ void ypan_up(int unit, struct vc_data *vc,
struct display *p, int count)
static __inline__ void ypan_up(struct display *p, struct vc_data *vc,
int count)
{
struct fb_info *info = p->fb_info;
......@@ -1024,7 +1024,7 @@ static __inline__ void ypan_up(int unit, struct vc_data *vc,
info->var.xoffset = 0;
info->var.yoffset = p->yscroll * fontheight(p);
info->var.vmode &= ~FB_VMODE_YWRAP;
update_var(unit, info);
update_var(vc->vc_num, info);
if (p->dispsw->clear_margins)
p->dispsw->clear_margins(vc, p, 1);
scrollback_max += count;
......@@ -1034,8 +1034,8 @@ static __inline__ void ypan_up(int unit, struct vc_data *vc,
}
static __inline__ void ypan_down(int unit, struct vc_data *vc,
struct display *p, int count)
static __inline__ void ypan_down(struct display *p, struct vc_data *vc,
int count)
{
struct fb_info *info = p->fb_info;
......@@ -1048,7 +1048,7 @@ static __inline__ void ypan_down(int unit, struct vc_data *vc,
info->var.xoffset = 0;
info->var.yoffset = p->yscroll * fontheight(p);
info->var.vmode &= ~FB_VMODE_YWRAP;
update_var(unit, info);
update_var(vc->vc_num, info);
if (p->dispsw->clear_margins)
p->dispsw->clear_margins(vc, p, 1);
scrollback_max -= count;
......@@ -1257,7 +1257,7 @@ void fbcon_redraw_clear(struct vc_data *vc, struct display *p, int sy,
*
*/
void fbcon_redraw_bmove(struct display *p, int sy, int sx, int dy, int dx,
void fbcon_redraw_bmove(struct vc_data *vc, struct display *p, int sy, int sx, int dy, int dx,
int h, int w)
{
if (sy != dy)
......@@ -1265,7 +1265,6 @@ void fbcon_redraw_bmove(struct display *p, int sy, int sx, int dy, int dx,
/* h will be always 1, but it does not matter if we are more generic */
while (h-- > 0) {
struct vc_data *vc = p->conp;
unsigned short *d = (unsigned short *)
(vc->vc_origin + vc->vc_size_row * dy + dx * 2);
unsigned short *s = d + (dx - sx);
......@@ -1375,7 +1374,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
if (t > 0)
fbcon_bmove(vc, 0, 0, count, 0, t,
vc->vc_cols);
ywrap_up(unit, vc, p, count);
ywrap_up(p, vc, count);
if (vc->vc_rows - b > 0)
fbcon_bmove(vc, b - count, 0, b, 0,
vc->vc_rows - b,
......@@ -1398,7 +1397,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
if (t > 0)
fbcon_bmove(vc, 0, 0, count, 0, t,
vc->vc_cols);
ypan_up(unit, vc, p, count);
ypan_up(p, vc, count);
if (vc->vc_rows - b > 0)
fbcon_bmove(vc, b - count, 0, b, 0,
vc->vc_rows - b,
......@@ -1442,7 +1441,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
fbcon_bmove(vc, b, 0, b - count, 0,
vc->vc_rows - b,
vc->vc_cols);
ywrap_down(unit, vc, p, count);
ywrap_down(p, vc, count);
if (t > 0)
fbcon_bmove(vc, count, 0, 0, 0, t,
vc->vc_cols);
......@@ -1464,7 +1463,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
fbcon_bmove(vc, b, 0, b - count, 0,
vc->vc_rows - b,
vc->vc_cols);
ypan_down(unit, vc, p, count);
ypan_down(p, vc, count);
if (t > 0)
fbcon_bmove(vc, count, 0, 0, 0, t,
vc->vc_cols);
......@@ -1635,52 +1634,42 @@ static int fbcon_blank(struct vc_data *vc, int blank)
if (blank < 0) /* Entering graphics mode */
return 0;
fbcon_cursor(p->conp, blank ? CM_ERASE : CM_DRAW);
fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW);
if (!p->can_soft_blank) {
if (blank) {
if (info->fix.visual == FB_VISUAL_MONO01) {
/*
if (info->screen_base)
fb_memset255(info->screen_base,
info->var.xres_virtual*info->var.yres_virtual*
info->var.bits_per_pixel>>3);
*/
} else {
unsigned short oldc;
u_int height;
u_int y_break;
oldc = vc->vc_video_erase_char;
vc->vc_video_erase_char &= p->charmask;
height = vc->vc_rows;
y_break = p->vrows - p->yscroll;
if (height > y_break) {
p->dispsw->clear(vc, p,
real_y(p, 0), 0,
y_break,
vc->vc_cols);
p->dispsw->clear(vc, p,
real_y(p,
y_break),
0,
height - y_break,
vc->vc_cols);
} else
p->dispsw->clear(vc, p,
real_y(p, 0), 0,
height,
vc->vc_cols);
vc->vc_video_erase_char = oldc;
}
return 0;
} else {
/* Tell console.c that it has to restore the screen itself */
return 1;
unsigned short oldc;
u_int height;
u_int y_break;
oldc = vc->vc_video_erase_char;
vc->vc_video_erase_char &= p->charmask;
height = vc->vc_rows;
y_break = p->vrows - p->yscroll;
if (height > y_break) {
p->dispsw->clear(vc, p,
real_y(p, 0), 0,
y_break,
vc->vc_cols);
p->dispsw->clear(vc, p,
real_y(p,
y_break),
0,
height - y_break,
vc->vc_cols);
} else
p->dispsw->clear(vc, p,
real_y(p, 0), 0,
height,
vc->vc_cols);
vc->vc_video_erase_char = oldc;
}
return 0;
} else {
/* Tell console.c that it has to restore the screen itself */
return 1;
}
if (info->fbops->fb_blank)
(*info->fbops->fb_blank) (blank, info);
fb_blank(blank, info);
return 0;
}
......@@ -1692,9 +1681,9 @@ static void fbcon_free_font(struct display *p)
p->userfont = 0;
}
static inline int fbcon_get_font(int unit, struct console_font_op *op)
static inline int fbcon_get_font(struct vc_data *vc, struct console_font_op *op)
{
struct display *p = &fb_display[unit];
struct display *p = &fb_display[vc->vc_num];
u8 *data = op->data;
u8 *fontdata = p->fontdata;
int i, j;
......@@ -1751,10 +1740,10 @@ static inline int fbcon_get_font(int unit, struct console_font_op *op)
return 0;
}
static int fbcon_do_set_font(int unit, struct console_font_op *op,
static int fbcon_do_set_font(struct vc_data *vc, struct console_font_op *op,
u8 * data, int userfont)
{
struct display *p = &fb_display[unit];
struct display *p = &fb_display[vc->vc_num];
struct fb_info *info = p->fb_info;
int resize;
int w = op->width;
......@@ -1856,7 +1845,7 @@ static int fbcon_do_set_font(int unit, struct console_font_op *op,
&& (info->var.yres_virtual % h < info->var.yres % h))
p->vrows--;
updatescrollmode(p);
vc_resize(unit, info->var.xres / w, info->var.yres / h);
vc_resize(vc->vc_num, info->var.xres / w, info->var.yres / h);
if (CON_IS_VISIBLE(vc) && softback_buf) {
int l = fbcon_softback_size / vc->vc_size_row;
if (l > 5)
......@@ -1869,36 +1858,35 @@ static int fbcon_do_set_font(int unit, struct console_font_op *op,
}
}
} else if (CON_IS_VISIBLE(p->conp)
&& vt_cons[unit]->vc_mode == KD_TEXT) {
&& vt_cons[vc->vc_num]->vc_mode == KD_TEXT) {
if (p->dispsw->clear_margins)
p->dispsw->clear_margins(p->conp, p, 0);
update_screen(unit);
update_screen(vc->vc_num);
}
if (old_data && (--REFCOUNT(old_data) == 0))
kfree(old_data - FONT_EXTRA_WORDS * sizeof(int));
return 0;
}
static inline int fbcon_copy_font(int unit, struct console_font_op *op)
static inline int fbcon_copy_font(struct vc_data *vc, struct console_font_op *op)
{
struct display *od, *p = &fb_display[unit];
struct display *od, *p = &fb_display[vc->vc_num];
int h = op->height;
if (h < 0 || !vc_cons_allocated(h))
return -ENOTTY;
if (h == unit)
if (h == vc->vc_num)
return 0; /* nothing to do */
od = &fb_display[h];
if (od->fontdata == p->fontdata)
return 0; /* already the same font... */
op->width = fontwidth(od);
op->height = fontheight(od);
return fbcon_do_set_font(unit, op, od->fontdata, od->userfont);
return fbcon_do_set_font(vc, op, od->fontdata, od->userfont);
}
static inline int fbcon_set_font(int unit, struct console_font_op *op)
static inline int fbcon_set_font(struct vc_data *vc, struct console_font_op *op)
{
int w = op->width;
int h = op->height;
......@@ -1986,14 +1974,14 @@ static inline int fbcon_set_font(int unit, struct console_font_op *op)
break;
}
}
return fbcon_do_set_font(unit, op, new_data, 1);
return fbcon_do_set_font(vc, op, new_data, 1);
}
static inline int fbcon_set_def_font(int unit, struct console_font_op *op)
static inline int fbcon_set_def_font(struct vc_data *vc, struct console_font_op *op)
{
char name[MAX_FONT_NAME];
struct fbcon_font_desc *f;
struct display *p = &fb_display[unit];
struct display *p = &fb_display[vc->vc_num];
struct fb_info *info = p->fb_info;
if (!op->data)
......@@ -2007,22 +1995,20 @@ static inline int fbcon_set_def_font(int unit, struct console_font_op *op)
}
op->width = f->width;
op->height = f->height;
return fbcon_do_set_font(unit, op, f->data, 0);
return fbcon_do_set_font(vc, op, f->data, 0);
}
static int fbcon_font_op(struct vc_data *vc, struct console_font_op *op)
{
int unit = vc->vc_num;
switch (op->op) {
case KD_FONT_OP_SET:
return fbcon_set_font(unit, op);
return fbcon_set_font(vc, op);
case KD_FONT_OP_GET:
return fbcon_get_font(unit, op);
return fbcon_get_font(vc, op);
case KD_FONT_OP_SET_DEFAULT:
return fbcon_set_def_font(unit, op);
return fbcon_set_def_font(vc, op);
case KD_FONT_OP_COPY:
return fbcon_copy_font(unit, op);
return fbcon_copy_font(vc, op);
default:
return -ENOSYS;
}
......
......@@ -57,12 +57,6 @@ struct display {
struct display_switch *dispsw; /* low level operations */
void *dispsw_data; /* optional dispsw helper data */
#if 0
struct fb_fix_cursorinfo fcrsr;
struct fb_var_cursorinfo *vcrsr;
struct fb_cursorstate crsrstate;
#endif
/* Filled in by the low-level console driver */
struct vc_data *conp; /* pointer to console data */
struct fb_info *fb_info; /* frame buffer for this console */
......@@ -181,6 +175,6 @@ extern void set_con2fb_map(int unit, int newidx);
#define SCROLL_YNOPARTIAL __SCROLL_YNOPARTIAL
extern void fbcon_redraw_clear(struct vc_data *, struct display *, int, int, int, int);
extern void fbcon_redraw_bmove(struct display *, int, int, int, int, int, int);
extern void fbcon_redraw_bmove(struct vc_data *, struct display *, int, int, int, int, int, int);
#endif /* _VIDEO_FBCON_H */
......@@ -18,7 +18,7 @@
#define FBIOGETCMAP 0x4604
#define FBIOPUTCMAP 0x4605
#define FBIOPAN_DISPLAY 0x4606
#define FBIO_CURSOR _IOWR('F', 0x08, struct fbcursor)
#define FBIO_CURSOR _IOWR('F', 0x08, struct fb_cursor)
/* 0x4607-0x460B are defined below */
/* #define FBIOGET_MONITORSPEC 0x460C */
/* #define FBIOPUT_MONITORSPEC 0x460D */
......@@ -223,11 +223,6 @@ struct fb_cmap {
__u16 *transp; /* transparency, can be NULL */
};
struct fb_index {
__u32 len; /* number of entries */
__u32 *entry; /* "pseudopalette" color index entries */
};
struct fb_con2fbmap {
__u32 console;
__u32 framebuffer;
......@@ -265,38 +260,6 @@ struct fb_vblank {
__u32 reserved[4]; /* reserved for future compatibility */
};
/*
* hardware cursor control
*/
#define FB_CUR_SETCUR 0x01
#define FB_CUR_SETPOS 0x02
#define FB_CUR_SETHOT 0x04
#define FB_CUR_SETCMAP 0x08
#define FB_CUR_SETSHAPE 0x10
#define FB_CUR_SETDEST 0x20
#define FB_CUR_SETSIZE 0x40
#define FB_CUR_SETALL 0xFF
struct fbcurpos {
__u16 x, y;
};
struct fbcursor {
__u16 set; /* what to set */
__u16 enable; /* cursor on/off */
__u8 rop; /* bitop operation */
__u8 depth; /* color depth of image */
struct fbcurpos pos; /* cursor position */
struct fbcurpos hot; /* cursor hot spot */
struct fbcurpos size; /* cursor bit map size */
struct fb_cmap cmap; /* color map info */
struct fb_index *index;
char *image; /* cursor image bits */
char *mask; /* cursor mask bits */
char *dest; /* destination */
};
/* Internal HW accel */
#define ROP_COPY 0
#define ROP_XOR 1
......@@ -320,14 +283,42 @@ struct fb_fillrect {
};
struct fb_image {
__u32 dx; /* Where to place image */
__u32 dx; /* Where to place image */
__u32 dy;
__u32 width; /* Size of image */
__u32 width; /* Size of image */
__u32 height;
__u32 fg_color; /* Only used when a mono bitmap */
__u32 fg_color; /* Only used when a mono bitmap */
__u32 bg_color;
__u8 depth; /* Depth of the image */
char *data; /* Pointer to image data */
__u8 depth; /* Depth of the image */
char *data; /* Pointer to image data */
struct fb_cmap cmap; /* color map info */
};
/*
* hardware cursor control
*/
#define FB_CUR_SETCUR 0x01
#define FB_CUR_SETPOS 0x02
#define FB_CUR_SETHOT 0x04
#define FB_CUR_SETCMAP 0x08
#define FB_CUR_SETSHAPE 0x10
#define FB_CUR_SETDEST 0x20
#define FB_CUR_SETSIZE 0x40
#define FB_CUR_SETALL 0xFF
struct fbcurpos {
__u16 x, y;
};
struct fb_cursor {
__u16 set; /* what to set */
__u16 enable; /* cursor on/off */
__u16 rop; /* bitop operation */
char *mask; /* cursor mask bits */
char *dest; /* destination */
struct fbcurpos hot; /* cursor hot spot */
struct fb_image image; /* Cursor image */
};
#ifdef __KERNEL__
......@@ -371,7 +362,7 @@ struct fb_ops {
/* Draws a image to the display */
void (*fb_imageblit)(struct fb_info *info, struct fb_image *image);
/* Draws cursor */
int (*fb_cursor)(struct fb_info *info, struct fbcursor *cursor);
int (*fb_cursor)(struct fb_info *info, struct fb_cursor *cursor);
/* Rotates the display */
void (*fb_rotate)(struct fb_info *info, int angle);
/* perform polling on fb device */
......@@ -393,7 +384,7 @@ struct fb_info {
struct fb_var_screeninfo var; /* Current var */
struct fb_fix_screeninfo fix; /* Current fix */
struct fb_monspecs monspecs; /* Current Monitor specs */
struct fbcursor cursor; /* Current cursor */
struct fb_cursor cursor; /* Current cursor */
struct fb_cmap cmap; /* Current cmap */
struct fb_ops *fbops;
char *screen_base; /* Virtual address */
......@@ -457,7 +448,7 @@ struct fb_info {
extern int fb_set_var(struct fb_var_screeninfo *var, struct fb_info *info);
extern int fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info);
extern int fb_blank(int blank, struct fb_info *info);
extern int cfb_cursor(struct fb_info *info, struct fbcursor *cursor);
extern int cfb_cursor(struct fb_info *info, struct fb_cursor *cursor);
extern void cfb_fillrect(struct fb_info *info, struct fb_fillrect *rect);
extern void cfb_copyarea(struct fb_info *info, struct fb_copyarea *area);
extern void cfb_imageblit(struct fb_info *info, struct fb_image *image);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment