Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2618 → Rev 2619

/trunk/uspace/srv/fb/main.c
44,7 → 44,7
void *dest;
 
dest = as_get_mappable_page(IPC_GET_ARG2(*call));
if (ipc_answer_fast(callid, 0, (sysarg_t) dest, 0) == 0) {
if (ipc_answer_1(callid, EOK, (sysarg_t) dest) == 0) {
if (*area)
as_area_destroy(*area);
*area = dest;
/trunk/uspace/srv/fb/sysio.c
117,69 → 117,69
int i;
 
if (client_connected) {
ipc_answer_fast(iid, ELIMIT, 0,0);
ipc_answer_0(iid, ELIMIT);
return;
}
client_connected = 1;
ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
ipc_answer_0(iid, EOK); /* Accept connection */
while (1) {
callid = async_get_call(&call);
switch (IPC_GET_METHOD(call)) {
case IPC_M_PHONE_HUNGUP:
client_connected = 0;
ipc_answer_fast(callid, 0, 0, 0);
return; /* Exit thread */
case FB_PUTCHAR:
c = IPC_GET_ARG1(call);
newrow = IPC_GET_ARG2(call);
newcol = IPC_GET_ARG3(call);
if ((lastcol != newcol) || (lastrow != newrow))
curs_goto(newrow, newcol);
lastcol = newcol + 1;
lastrow = newrow;
sysput(c);
retval = 0;
break;
case FB_CURSOR_GOTO:
newrow = IPC_GET_ARG1(call);
newcol = IPC_GET_ARG2(call);
case IPC_M_PHONE_HUNGUP:
client_connected = 0;
ipc_answer_0(callid, EOK);
return; /* Exit thread */
case FB_PUTCHAR:
c = IPC_GET_ARG1(call);
newrow = IPC_GET_ARG2(call);
newcol = IPC_GET_ARG3(call);
if ((lastcol != newcol) || (lastrow != newrow))
curs_goto(newrow, newcol);
lastrow = newrow;
lastcol = newcol;
retval = 0;
lastcol = newcol + 1;
lastrow = newrow;
sysput(c);
retval = 0;
break;
case FB_CURSOR_GOTO:
newrow = IPC_GET_ARG1(call);
newcol = IPC_GET_ARG2(call);
curs_goto(newrow, newcol);
lastrow = newrow;
lastcol = newcol;
retval = 0;
break;
case FB_GET_CSIZE:
ipc_answer_2(callid, EOK, HEIGHT, WIDTH);
continue;
case FB_CLEAR:
clrscr();
retval = 0;
break;
case FB_SET_STYLE:
fgcolor = IPC_GET_ARG1(call);
bgcolor = IPC_GET_ARG2(call);
if (fgcolor < bgcolor)
set_style(0);
else
set_style(7);
retval = 0;
break;
case FB_SCROLL:
i = IPC_GET_ARG1(call);
if ((i > HEIGHT) || (i < -HEIGHT)) {
retval = EINVAL;
break;
case FB_GET_CSIZE:
ipc_answer_fast(callid, 0, HEIGHT, WIDTH);
continue;
case FB_CLEAR:
clrscr();
retval = 0;
break;
case FB_SET_STYLE:
fgcolor = IPC_GET_ARG1(call);
bgcolor = IPC_GET_ARG2(call);
if (fgcolor < bgcolor)
set_style(0);
else
set_style(7);
retval = 0;
break;
case FB_SCROLL:
i = IPC_GET_ARG1(call);
if ((i > HEIGHT) || (i < -HEIGHT)) {
retval = EINVAL;
break;
}
scroll(i);
curs_goto(lastrow, lastcol);
retval = 0;
break;
default:
retval = ENOENT;
}
scroll(i);
curs_goto(lastrow, lastcol);
retval = 0;
break;
default:
retval = ENOENT;
}
ipc_answer_fast(callid, retval, 0, 0);
ipc_answer_0(callid, retval);
}
}
 
/trunk/uspace/srv/fb/fb.c
165,7 → 165,7
bgr_byte0888(void *dst, int rgb)
{
*((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 |
RED(rgb, 8);
RED(rgb, 8);
}
 
static int
173,7 → 173,7
{
int color = *(uint32_t *)(src);
return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) |
((color >> 16) & 0xff);
((color >> 16) & 0xff);
}
 
static void
208,7 → 208,7
{
/* 5-bit, 5-bits, 5-bits */
*((uint16_t *)(dst)) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 |
BLUE(rgb, 5);
BLUE(rgb, 5);
}
 
/** 16-bit depth (5:5:5) */
217,7 → 217,7
{
int color = *(uint16_t *)(src);
return (((color >> 10) & 0x1f) << (16 + 3)) |
(((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3);
(((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3);
}
 
/** 16-bit depth (5:6:5) */
226,7 → 226,7
{
/* 5-bit, 6-bits, 5-bits */
*((uint16_t *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 |
BLUE(rgb, 5);
BLUE(rgb, 5);
}
 
/** 16-bit depth (5:6:5) */
235,7 → 235,7
{
int color = *(uint16_t *)(src);
return (((color >> 11) & 0x1f) << (16 + 3)) |
(((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
(((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3);
}
 
/** Put pixel - 8-bit depth (3:2:3) */
251,7 → 251,7
{
int color = *(uint8_t *)src;
return (((color >> 5) & 0x7) << (16 + 5)) |
(((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
(((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5);
}
 
/** Put pixel into viewport
269,7 → 269,7
 
if (! (vport->paused && vport->dbdata))
(*screen.rgb2scr)(&screen.fbaddress[POINTPOS(dx,dy)],
COLOR(color));
COLOR(color));
 
if (vport->dbdata) {
int dline = (y + vport->dboffset) % vport->height;
291,7 → 291,7
static inline void
putpixel_mem(char *mem, unsigned int x, unsigned int y, int color)
{
(*screen.rgb2scr)(&mem[POINTPOS(x,y)], COLOR(color));
(*screen.rgb2scr)(&mem[POINTPOS(x, y)], COLOR(color));
}
 
static void
302,7 → 302,7
static void *tmpline;
 
if (!tmpline)
tmpline = malloc(screen.scanline*screen.pixelbytes);
tmpline = malloc(screen.scanline * screen.pixelbytes);
 
/* Clear first line */
for (x = 0; x < width; x++)
315,15 → 315,15
/* Copy the rest */
for (y = sy;y < sy+height; y++)
memcpy(&screen.fbaddress[POINTPOS(sx,y)], tmpline,
screen.pixelbytes * width);
screen.pixelbytes * width);
}
if (vport->dbdata) {
for (y = sy; y < sy + height; y++) {
int rline = (y + vport->dboffset) % vport->height;
int rpos = (rline * vport->width + sx) *
screen.pixelbytes;
screen.pixelbytes;
memcpy(&vport->dbdata[rpos], tmpline,
screen.pixelbytes * width);
screen.pixelbytes * width);
}
}
 
334,7 → 334,7
clear_port(viewport_t *vport)
{
draw_rectangle(vport, 0, 0, vport->width, vport->height,
vport->style.bg_color);
vport->style.bg_color);
}
 
/** Scroll unbuffered viewport up/down
350,19 → 350,18
if (lines > 0) {
for (y = vport->y; y < vport->y+vport->height - lines; y++)
memcpy(&screen.fbaddress[POINTPOS(vport->x,y)],
&screen.fbaddress[POINTPOS(vport->x,y + lines)],
screen.pixelbytes * vport->width);
&screen.fbaddress[POINTPOS(vport->x,y + lines)],
screen.pixelbytes * vport->width);
draw_rectangle(vport, 0, vport->height - lines, vport->width,
lines, vport->style.bg_color);
lines, vport->style.bg_color);
} else if (lines < 0) {
lines = -lines;
for (y = vport->y + vport->height-1; y >= vport->y + lines;
y--)
for (y = vport->y + vport->height-1; y >= vport->y + lines; y--)
memcpy(&screen.fbaddress[POINTPOS(vport->x,y)],
&screen.fbaddress[POINTPOS(vport->x,y - lines)],
screen.pixelbytes * vport->width);
&screen.fbaddress[POINTPOS(vport->x,y - lines)],
screen.pixelbytes * vport->width);
draw_rectangle(vport, 0, 0, vport->width, lines,
vport->style.bg_color);
vport->style.bg_color);
}
}
 
380,8 → 379,7
dsty = vport->y + y;
 
memcpy(&screen.fbaddress[POINTPOS(dstx,dsty)],
&vport->dbdata[srcoff],
vport->width*screen.pixelbytes);
&vport->dbdata[srcoff], vport->width * screen.pixelbytes);
}
}
 
392,14 → 390,13
++vport->paused;
if (lines > 0) {
draw_rectangle(vport, 0, 0, vport->width, lines,
vport->style.bg_color);
vport->style.bg_color);
vport->dboffset += lines;
vport->dboffset %= vport->height;
} else if (lines < 0) {
lines = -lines;
draw_rectangle(vport, 0, vport->height-lines,
vport->width, lines,
vport->style.bg_color);
draw_rectangle(vport, 0, vport->height-lines, vport->width,
lines, vport->style.bg_color);
 
if (vport->dboffset < lines)
vport->dboffset += vport->height;
441,8 → 438,8
* @param transparent If false, print background color
*/
static void
draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx,
unsigned int sy, style_t style, int transparent)
draw_glyph(viewport_t *vport,uint8_t glyph, unsigned int sx, unsigned int sy,
style_t style, int transparent)
{
int i;
unsigned int y;
452,11 → 449,9
glline = fb_font[glyph * FONT_SCANLINES + y];
for (i = 0; i < 8; i++) {
if (glline & (1 << (7 - i)))
putpixel(vport, sx + i, sy + y,
style.fg_color);
putpixel(vport, sx + i, sy + y, style.fg_color);
else if (!transparent)
putpixel(vport, sx + i, sy + y,
style.bg_color);
putpixel(vport, sx + i, sy + y, style.bg_color);
}
}
}
471,7 → 466,7
for (x = 0; x < COL_WIDTH; x++)
for (y = 0; y < FONT_SCANLINES; y++)
invert_pixel(vport, col * COL_WIDTH + x, row *
FONT_SCANLINES + y);
FONT_SCANLINES + y);
}
 
/***************************************************************/
630,7 → 625,7
invert_char(vport, vport->cur_row, vport->cur_col);
draw_glyph(vport, c, col * COL_WIDTH, row * FONT_SCANLINES, style,
transparent);
transparent);
 
vport->cur_col = col;
vport->cur_row = row;
659,13 → 654,13
clear_port(vport);
for (i = 0; i < vport->cols * vport->rows; i++) {
if (data[i].character == ' ' && style_same(data[i].style,
vport->style))
vport->style))
continue;
col = i % vport->cols;
row = i / vport->cols;
draw_glyph(vport, data[i].character, col * COL_WIDTH, row *
FONT_SCANLINES, data[i].style,
style_same(data[i].style,vport->style));
FONT_SCANLINES, data[i].style, style_same(data[i].style,
vport->style));
}
cursor_print(vport);
}
711,7 → 706,7
return ENOMEM;
 
ppm_draw(shm, size, 0, 0, pmap->width, pmap->height,
(putpixel_cb_t)putpixel_pixmap, (void *)pm);
(putpixel_cb_t)putpixel_pixmap, (void *)pm);
 
return pm;
}
757,7 → 752,7
if (IPC_GET_ARG1(*call) == shm_id) {
void *dest = as_get_mappable_page(IPC_GET_ARG2(*call));
shm_size = IPC_GET_ARG2(*call);
if (!ipc_answer_fast(callid, 0, (sysarg_t) dest, 0))
if (!ipc_answer_1(callid, EOK, (sysarg_t) dest))
shm = dest;
else
shm_id = 0;
805,8 → 800,8
}
ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),
IPC_GET_ARG2(*call), vport->width - x,
vport->height - y, (putpixel_cb_t)putpixel, vport);
IPC_GET_ARG2(*call), vport->width - x, vport->height - y,
(putpixel_cb_t)putpixel, vport);
break;
case FB_DRAW_TEXT_DATA:
if (!interbuffer) {
814,7 → 809,7
break;
}
if (intersize < vport->cols * vport->rows *
sizeof(*interbuffer)) {
sizeof(*interbuffer)) {
retval = EINVAL;
break;
}
825,7 → 820,7
}
if (handled)
ipc_answer_fast(callid, retval, 0, 0);
ipc_answer_0(callid, retval);
return handled;
}
 
851,9 → 846,9
for (y = 0; y < realheight; y++) {
tmp = (vport->y + y) * screen.scanline +
vport->x * screen.pixelbytes;
vport->x * screen.pixelbytes;
memcpy(pmap->data + srcrowsize * y, screen.fbaddress + tmp,
realrowsize);
realrowsize);
}
}
 
912,9 → 907,9
 
for (y = 0; y < realheight; y++) {
tmp = (vport->y + y) * screen.scanline +
vport->x * screen.pixelbytes;
vport->x * screen.pixelbytes;
memcpy(screen.fbaddress + tmp, pmap->data + y * srcrowsize,
realrowsize);
realrowsize);
}
return 0;
}
933,12 → 928,12
 
for (i = 0; i < MAX_ANIMATIONS; i++) {
if (!animations[i].animlen || !animations[i].initialized ||
!animations[i].enabled)
!animations[i].enabled)
continue;
draw_pixmap(animations[i].vp,
animations[i].pixmaps[animations[i].pos]);
animations[i].pixmaps[animations[i].pos]);
animations[i].pos = (animations[i].pos + 1) %
animations[i].animlen;
animations[i].animlen;
}
}
 
962,7 → 957,7
/* Save image under the cursor */
if (pointer_vport == -1) {
pointer_vport = viewport_create(pointer_x, pointer_y,
pointer_width, pointer_height);
pointer_width, pointer_height);
if (pointer_vport < 0)
return;
} else {
974,7 → 969,7
pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]);
else
copy_vp_to_pixmap(&viewports[pointer_vport],
&pixmaps[pointer_pixmap]);
&pixmaps[pointer_pixmap]);
 
/* Draw cursor */
for (i = 0; i < pointer_height; i++)
981,14 → 976,14
for (j = 0; j < pointer_width; j++) {
bytepos = i * ((pointer_width - 1) / 8 + 1) + j / 8;
visibility = pointer_mask_bits[bytepos] &
(1 << (j % 8));
(1 << (j % 8));
if (visibility) {
color = pointer_bits[bytepos] & (1 << (j % 8))
? 0 : 0xffffff;
color = pointer_bits[bytepos] &
(1 << (j % 8)) ? 0 : 0xffffff;
if (pointer_x + j < screen.xres && pointer_y +
i < screen.yres)
i < screen.yres)
putpixel(&viewports[0], pointer_x + j,
pointer_y + i, color);
pointer_y + i, color);
}
}
pointer_shown = 1;
1106,7 → 1101,7
handled = 0;
}
if (handled)
ipc_answer_fast(callid, retval, 0, 0);
ipc_answer_0(callid, retval);
return handled;
}
 
1157,7 → 1152,7
}
 
if (handled)
ipc_answer_fast(callid, retval, 0, 0);
ipc_answer_0(callid, retval);
return handled;
}
1179,11 → 1174,11
viewport_t *vport = &viewports[0];
 
if (client_connected) {
ipc_answer_fast(iid, ELIMIT, 0,0);
ipc_answer_0(iid, ELIMIT);
return;
}
client_connected = 1;
ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
ipc_answer_0(iid, EOK); /* Accept connection */
 
while (1) {
if (vport->cursor_active || anims_enabled)
1222,10 → 1217,10
retval = EINVAL;
break;
}
ipc_answer_fast(callid, 0, 0, 0);
ipc_answer_0(callid, EOK);
 
draw_char(vport, c, row, col, vport->style,
IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR);
IPC_GET_METHOD(call) == FB_TRANS_PUTCHAR);
continue; /* msg already answered */
case FB_CLEAR:
clear_port(vport);
1252,7 → 1247,7
retval = 0;
break;
case FB_GET_CSIZE:
ipc_answer_fast(callid, 0, vport->rows, vport->cols);
ipc_answer_2(callid, EOK, vport->rows, vport->cols);
continue;
case FB_SCROLL:
i = IPC_GET_ARG1(call);
1274,17 → 1269,17
retval = EINVAL;
break;
}
if (! viewports[i].initialized ) {
if (!viewports[i].initialized ) {
retval = EADDRNOTAVAIL;
break;
}
viewports[i].dboffset = 0;
if (IPC_GET_ARG2(call) == 1 && !viewports[i].dbdata)
viewports[i].dbdata = malloc(screen.pixelbytes
* viewports[i].width *
viewports[i].height);
viewports[i].dbdata =
malloc(screen.pixelbytes *
viewports[i].width * viewports[i].height);
else if (IPC_GET_ARG2(call) == 0 &&
viewports[i].dbdata) {
viewports[i].dbdata) {
free(viewports[i].dbdata);
viewports[i].dbdata = NULL;
}
1308,9 → 1303,9
break;
case FB_VIEWPORT_CREATE:
retval = viewport_create(IPC_GET_ARG1(call) >> 16,
IPC_GET_ARG1(call) & 0xffff,
IPC_GET_ARG2(call) >> 16,
IPC_GET_ARG2(call) & 0xffff);
IPC_GET_ARG1(call) & 0xffff,
IPC_GET_ARG2(call) >> 16,
IPC_GET_ARG2(call) & 0xffff);
break;
case FB_VIEWPORT_DELETE:
i = IPC_GET_ARG1(call);
1335,7 → 1330,7
retval = 0;
break;
case FB_GET_RESOLUTION:
ipc_answer_fast(callid, 0, screen.xres,screen.yres);
ipc_answer_2(callid, EOK, screen.xres, screen.yres);
continue;
case FB_POINTER_MOVE:
pointer_enabled = 1;
1345,7 → 1340,7
default:
retval = ENOENT;
}
ipc_answer_fast(callid,retval, 0, 0);
ipc_answer_0(callid, retval);
}
}
 
1375,10 → 1370,10
fb_addr = as_get_mappable_page(asz);
physmem_map(fb_ph_addr, fb_addr, ALIGN_UP(asz, PAGE_SIZE) >>
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
 
if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual,
fb_invert_colors))
fb_invert_colors))
return 0;
return -1;
/trunk/uspace/srv/fb/ega.c
82,7 → 82,7
{
int i;
for (i = 0; i < scr_width*scr_height; i++) {
for (i = 0; i < scr_width * scr_height; i++) {
scr_addr[i * 2] = ' ';
scr_addr[i * 2 + 1] = style;
}
125,13 → 125,13
int i;
if (rows > 0) {
memcpy(scr_addr, ((char *) scr_addr) + rows * scr_width * 2,
scr_width * scr_height * 2 - rows * scr_width * 2);
scr_width * scr_height * 2 - rows * scr_width * 2);
for (i = 0; i < rows * scr_width; i++)
(((short *) scr_addr) + scr_width * scr_height - rows *
scr_width)[i] = ((style << 8) + ' ');
scr_width)[i] = ((style << 8) + ' ');
} else if (rows < 0) {
memcpy(((char *)scr_addr) - rows * scr_width * 2, scr_addr,
scr_width * scr_height * 2 + rows * scr_width * 2);
scr_width * scr_height * 2 + rows * scr_width * 2);
for (i = 0; i < -rows * scr_width; i++)
((short *)scr_addr)[i] = ((style << 8 ) + ' ');
}
152,7 → 152,7
for (i = 0; i < scr_width * scr_height; i++) {
scr_addr[i * 2] = data[i].character;
scr_addr[i * 2 + 1] = EGA_STYLE(data[i].style.fg_color,
data[i].style.bg_color);
data[i].style.bg_color);
}
}
 
160,7 → 160,7
{
int i;
 
for (i=0; (i < MAX_SAVED_SCREENS) && (saved_screens[i].data); i++)
for (i = 0; (i < MAX_SAVED_SCREENS) && (saved_screens[i].data); i++)
;
if (i == MAX_SAVED_SCREENS)
return EINVAL;
175,7 → 175,7
{
if (saved_screens[i].data)
memcpy(scr_addr, saved_screens[i].data, 2 * scr_width *
scr_height);
scr_height);
else
return EINVAL;
return i;
195,11 → 195,11
int i;
 
if (client_connected) {
ipc_answer_fast(iid, ELIMIT, 0,0);
ipc_answer_0(iid, ELIMIT);
return;
}
client_connected = 1;
ipc_answer_fast(iid, 0, 0, 0); /* Accept connection */
ipc_answer_0(iid, EOK); /* Accept connection */
 
while (1) {
callid = async_get_call(&call);
206,15 → 206,15
switch (IPC_GET_METHOD(call)) {
case IPC_M_PHONE_HUNGUP:
client_connected = 0;
ipc_answer_fast(callid, 0, 0, 0);
ipc_answer_0(callid, EOK);
return; /* Exit thread */
case IPC_M_AS_AREA_SEND:
/* We accept one area for data interchange */
intersize = IPC_GET_ARG2(call);
if (intersize >= scr_width * scr_height *
sizeof(*interbuf)) {
receive_comm_area(callid, &call, (void *)
&interbuf);
sizeof(*interbuf)) {
receive_comm_area(callid, &call,
(void *) &interbuf);
continue;
}
retval = EINVAL;
228,7 → 228,7
retval = 0;
break;
case FB_GET_CSIZE:
ipc_answer_fast(callid, 0, scr_height, scr_width);
ipc_answer_2(callid, EOK, scr_height, scr_width);
continue;
case FB_CLEAR:
clrscr();
300,7 → 300,7
default:
retval = ENOENT;
}
ipc_answer_fast(callid, retval, 0, 0);
ipc_answer_0(callid, retval);
}
}
 
318,7 → 318,7
scr_addr = as_get_mappable_page(sz);
 
physmem_map(ega_ph_addr, scr_addr, ALIGN_UP(sz, PAGE_SIZE) >>
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE);
 
async_set_client_connection(ega_client_connection);