Changeset 04803bf in mainline for uspace/srv/hid/fb/fb.c
- Timestamp:
- 2011-03-21T22:00:17Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 143932e3
- Parents:
- b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 moved
-
uspace/srv/hid/fb/fb.c (moved) (moved from uspace/srv/fb/fb.c ) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/fb/fb.c
rb50b5af2 r04803bf 41 41 #include <stdlib.h> 42 42 #include <unistd.h> 43 #include <str ing.h>43 #include <str.h> 44 44 #include <ddi.h> 45 45 #include <sysinfo.h> … … 47 47 #include <as.h> 48 48 #include <ipc/fb.h> 49 #include <ipc/ipc.h>50 49 #include <ipc/ns.h> 51 50 #include <ipc/services.h> … … 59 58 #include <stdio.h> 60 59 #include <byteorder.h> 60 #include <io/screenbuffer.h> 61 61 62 62 #include "font-8x16.h" 63 63 #include "fb.h" 64 64 #include "main.h" 65 #include "../console/screenbuffer.h"66 65 #include "ppm.h" 67 66 … … 72 71 #define DEFAULT_FGCOLOR 0x000000 73 72 74 #define GLYPH_UNAVAIL '?'75 76 #define MAX_ANIM_LEN 877 #define MAX_ANIMATIONS 478 #define MAX_PIXMAPS 256 /**< Maximum number of saved pixmaps */79 #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */73 #define GLYPH_UNAVAIL '?' 74 75 #define MAX_ANIM_LEN 8 76 #define MAX_ANIMATIONS 4 77 #define MAX_PIXMAPS 256 /**< Maximum number of saved pixmaps */ 78 #define MAX_VIEWPORTS 128 /**< Viewport is a rectangular area on the screen */ 80 79 81 80 /** Function to render a pixel from a RGB value. */ … … 199 198 static int rgb_from_attr(attr_rgb_t *rgb, const attrs_t *a); 200 199 static int rgb_from_style(attr_rgb_t *rgb, int style); 201 static int rgb_from_idx(attr_rgb_t *rgb, ipcarg_t fg_color,202 ipcarg_t bg_color, ipcarg_t flags);203 204 static int fb_set_color(viewport_t *vport, ipcarg_t fg_color,205 ipcarg_t bg_color, ipcarg_t attr);200 static int rgb_from_idx(attr_rgb_t *rgb, sysarg_t fg_color, 201 sysarg_t bg_color, sysarg_t flags); 202 203 static int fb_set_color(viewport_t *vport, sysarg_t fg_color, 204 sysarg_t bg_color, sysarg_t attr); 206 205 207 206 static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor, … … 956 955 bb_cell_t *bbp; 957 956 attrs_t *a; 958 attr_rgb_t rgb;959 957 960 958 for (j = 0; j < h; j++) { … … 966 964 967 965 a = &data[j * w + i].attrs; 966 967 attr_rgb_t rgb; 968 rgb.fg_color = 0; 969 rgb.bg_color = 0; 968 970 rgb_from_attr(&rgb, a); 969 971 … … 1069 1071 1070 1072 static unsigned char *shm = NULL; 1071 static ipcarg_t shm_id = 0;1073 static sysarg_t shm_id = 0; 1072 1074 static size_t shm_size; 1073 1075 … … 1080 1082 unsigned int h; 1081 1083 1082 switch (IPC_GET_ METHOD(*call)) {1084 switch (IPC_GET_IMETHOD(*call)) { 1083 1085 case IPC_M_SHARE_OUT: 1084 1086 /* We accept one area for data interchange */ … … 1086 1088 void *dest = as_get_mappable_page(IPC_GET_ARG2(*call)); 1087 1089 shm_size = IPC_GET_ARG2(*call); 1088 if ( ipc_answer_1(callid, EOK, (sysarg_t) dest)) {1090 if (async_answer_1(callid, EOK, (sysarg_t) dest)) { 1089 1091 shm_id = 0; 1090 1092 return false; … … 1163 1165 1164 1166 if (handled) 1165 ipc_answer_0(callid, retval);1167 async_answer_0(callid, retval); 1166 1168 return handled; 1167 1169 } … … 1344 1346 { 1345 1347 mouse_hide(); 1346 pointer_x = x ;1347 pointer_y = y ;1348 pointer_x = x % screen.xres; 1349 pointer_y = y % screen.yres; 1348 1350 mouse_show(); 1349 1351 } … … 1357 1359 int newval; 1358 1360 1359 switch (IPC_GET_ METHOD(*call)) {1361 switch (IPC_GET_IMETHOD(*call)) { 1360 1362 case FB_ANIM_CREATE: 1361 1363 nvp = IPC_GET_ARG1(*call); … … 1432 1434 break; 1433 1435 } 1434 newval = (IPC_GET_ METHOD(*call) == FB_ANIM_START);1436 newval = (IPC_GET_IMETHOD(*call) == FB_ANIM_START); 1435 1437 if (newval ^ animations[i].enabled) { 1436 1438 animations[i].enabled = newval; … … 1442 1444 } 1443 1445 if (handled) 1444 ipc_answer_0(callid, retval);1446 async_answer_0(callid, retval); 1445 1447 return handled; 1446 1448 } … … 1456 1458 int i, nvp; 1457 1459 1458 switch (IPC_GET_ METHOD(*call)) {1460 switch (IPC_GET_IMETHOD(*call)) { 1459 1461 case FB_VP_DRAW_PIXMAP: 1460 1462 nvp = IPC_GET_ARG1(*call); … … 1495 1497 1496 1498 if (handled) 1497 ipc_answer_0(callid, retval);1499 async_answer_0(callid, retval); 1498 1500 return handled; 1499 1501 … … 1511 1513 rgb->bg_color = color_table[COLOR_WHITE]; 1512 1514 break; 1515 case STYLE_INVERTED: 1516 rgb->fg_color = color_table[COLOR_WHITE]; 1517 rgb->bg_color = color_table[COLOR_BLACK]; 1518 break; 1519 case STYLE_SELECTED: 1520 rgb->fg_color = color_table[COLOR_WHITE]; 1521 rgb->bg_color = color_table[COLOR_RED]; 1522 break; 1513 1523 default: 1514 1524 return EINVAL; 1515 1525 } 1516 1526 1517 1527 return EOK; 1518 1528 } 1519 1529 1520 static int rgb_from_idx(attr_rgb_t *rgb, ipcarg_t fg_color,1521 ipcarg_t bg_color, ipcarg_t flags)1530 static int rgb_from_idx(attr_rgb_t *rgb, sysarg_t fg_color, 1531 sysarg_t bg_color, sysarg_t flags) 1522 1532 { 1523 1533 fg_color = (fg_color & 7) | ((flags & CATTR_BRIGHT) ? 8 : 0); … … 1551 1561 } 1552 1562 1553 static int fb_set_style(viewport_t *vport, ipcarg_t style)1563 static int fb_set_style(viewport_t *vport, sysarg_t style) 1554 1564 { 1555 1565 return rgb_from_style(&vport->attr, (int) style); 1556 1566 } 1557 1567 1558 static int fb_set_color(viewport_t *vport, ipcarg_t fg_color,1559 ipcarg_t bg_color, ipcarg_t flags)1568 static int fb_set_color(viewport_t *vport, sysarg_t fg_color, 1569 sysarg_t bg_color, sysarg_t flags) 1560 1570 { 1561 1571 return rgb_from_idx(&vport->attr, fg_color, bg_color, flags); … … 1571 1581 1572 1582 if (client_connected) { 1573 ipc_answer_0(iid, ELIMIT);1583 async_answer_0(iid, ELIMIT); 1574 1584 return; 1575 1585 } … … 1577 1587 /* Accept connection */ 1578 1588 client_connected = true; 1579 ipc_answer_0(iid, EOK);1589 async_answer_0(iid, EOK); 1580 1590 1581 1591 while (true) { … … 1610 1620 continue; 1611 1621 1612 switch (IPC_GET_ METHOD(call)) {1622 switch (IPC_GET_IMETHOD(call)) { 1613 1623 case IPC_M_PHONE_HUNGUP: 1614 1624 client_connected = false; … … 1630 1640 break; 1631 1641 } 1632 ipc_answer_0(callid, EOK);1642 async_answer_0(callid, EOK); 1633 1643 1634 1644 draw_char(vport, ch, col, row); … … 1663 1673 break; 1664 1674 case FB_GET_CSIZE: 1665 ipc_answer_2(callid, EOK, vport->cols, vport->rows);1675 async_answer_2(callid, EOK, vport->cols, vport->rows); 1666 1676 continue; 1667 1677 case FB_GET_COLOR_CAP: 1668 ipc_answer_1(callid, EOK, FB_CCAP_RGB);1678 async_answer_1(callid, EOK, FB_CCAP_RGB); 1669 1679 continue; 1670 1680 case FB_SCROLL: … … 1731 1741 break; 1732 1742 case FB_GET_RESOLUTION: 1733 ipc_answer_2(callid, EOK, screen.xres, screen.yres);1743 async_answer_2(callid, EOK, screen.xres, screen.yres); 1734 1744 continue; 1735 1745 case FB_POINTER_MOVE: … … 1745 1755 retval = ENOENT; 1746 1756 } 1747 ipc_answer_0(callid, retval);1757 async_answer_0(callid, retval); 1748 1758 } 1749 1759 } … … 1756 1766 async_set_client_connection(fb_client_connection); 1757 1767 1758 void *fb_ph_addr = (void *) sysinfo_value("fb.address.physical"); 1759 unsigned int fb_offset = sysinfo_value("fb.offset"); 1760 unsigned int fb_width = sysinfo_value("fb.width"); 1761 unsigned int fb_height = sysinfo_value("fb.height"); 1762 unsigned int fb_scanline = sysinfo_value("fb.scanline"); 1763 unsigned int fb_visual = sysinfo_value("fb.visual"); 1764 1765 unsigned int fbsize = fb_scanline * fb_height; 1768 sysarg_t fb_ph_addr; 1769 if (sysinfo_get_value("fb.address.physical", &fb_ph_addr) != EOK) 1770 return -1; 1771 1772 sysarg_t fb_offset; 1773 if (sysinfo_get_value("fb.offset", &fb_offset) != EOK) 1774 fb_offset = 0; 1775 1776 sysarg_t fb_width; 1777 if (sysinfo_get_value("fb.width", &fb_width) != EOK) 1778 return -1; 1779 1780 sysarg_t fb_height; 1781 if (sysinfo_get_value("fb.height", &fb_height) != EOK) 1782 return -1; 1783 1784 sysarg_t fb_scanline; 1785 if (sysinfo_get_value("fb.scanline", &fb_scanline) != EOK) 1786 return -1; 1787 1788 sysarg_t fb_visual; 1789 if (sysinfo_get_value("fb.visual", &fb_visual) != EOK) 1790 return -1; 1791 1792 sysarg_t fbsize = fb_scanline * fb_height; 1766 1793 void *fb_addr = as_get_mappable_page(fbsize); 1767 1768 if (physmem_map( fb_ph_addr + fb_offset, fb_addr,1794 1795 if (physmem_map((void *) fb_ph_addr + fb_offset, fb_addr, 1769 1796 ALIGN_UP(fbsize, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0) 1770 1797 return -1; 1771 1798 1772 1799 if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual)) 1773 1800 return 0; 1774 1801 1775 1802 return -1; 1776 1803 }
Note:
See TracChangeset
for help on using the changeset viewer.
