Changeset 04803bf in mainline for uspace/srv/hid/fb/fb.c


Ignore:
Timestamp:
2011-03-21T22:00:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
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.
Message:

Merge mainline changes (needs fixes).

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/fb/fb.c

    rb50b5af2 r04803bf  
    4141#include <stdlib.h>
    4242#include <unistd.h>
    43 #include <string.h>
     43#include <str.h>
    4444#include <ddi.h>
    4545#include <sysinfo.h>
     
    4747#include <as.h>
    4848#include <ipc/fb.h>
    49 #include <ipc/ipc.h>
    5049#include <ipc/ns.h>
    5150#include <ipc/services.h>
     
    5958#include <stdio.h>
    6059#include <byteorder.h>
     60#include <io/screenbuffer.h>
    6161
    6262#include "font-8x16.h"
    6363#include "fb.h"
    6464#include "main.h"
    65 #include "../console/screenbuffer.h"
    6665#include "ppm.h"
    6766
     
    7271#define DEFAULT_FGCOLOR  0x000000
    7372
    74 #define GLYPH_UNAVAIL    '?'
    75 
    76 #define MAX_ANIM_LEN     8
    77 #define MAX_ANIMATIONS   4
    78 #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 */
    8079
    8180/** Function to render a pixel from a RGB value. */
     
    199198static int rgb_from_attr(attr_rgb_t *rgb, const attrs_t *a);
    200199static 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);
     200static int rgb_from_idx(attr_rgb_t *rgb, sysarg_t fg_color,
     201    sysarg_t bg_color, sysarg_t flags);
     202
     203static int fb_set_color(viewport_t *vport, sysarg_t fg_color,
     204    sysarg_t bg_color, sysarg_t attr);
    206205
    207206static void draw_glyph_aligned(unsigned int x, unsigned int y, bool cursor,
     
    956955        bb_cell_t *bbp;
    957956        attrs_t *a;
    958         attr_rgb_t rgb;
    959957       
    960958        for (j = 0; j < h; j++) {
     
    966964                       
    967965                        a = &data[j * w + i].attrs;
     966                       
     967                        attr_rgb_t rgb;
     968                        rgb.fg_color = 0;
     969                        rgb.bg_color = 0;
    968970                        rgb_from_attr(&rgb, a);
    969971                       
     
    10691071       
    10701072        static unsigned char *shm = NULL;
    1071         static ipcarg_t shm_id = 0;
     1073        static sysarg_t shm_id = 0;
    10721074        static size_t shm_size;
    10731075       
     
    10801082        unsigned int h;
    10811083       
    1082         switch (IPC_GET_METHOD(*call)) {
     1084        switch (IPC_GET_IMETHOD(*call)) {
    10831085        case IPC_M_SHARE_OUT:
    10841086                /* We accept one area for data interchange */
     
    10861088                        void *dest = as_get_mappable_page(IPC_GET_ARG2(*call));
    10871089                        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)) {
    10891091                                shm_id = 0;
    10901092                                return false;
     
    11631165       
    11641166        if (handled)
    1165                 ipc_answer_0(callid, retval);
     1167                async_answer_0(callid, retval);
    11661168        return handled;
    11671169}
     
    13441346{
    13451347        mouse_hide();
    1346         pointer_x = x;
    1347         pointer_y = y;
     1348        pointer_x = x % screen.xres;
     1349        pointer_y = y % screen.yres;
    13481350        mouse_show();
    13491351}
     
    13571359        int newval;
    13581360       
    1359         switch (IPC_GET_METHOD(*call)) {
     1361        switch (IPC_GET_IMETHOD(*call)) {
    13601362        case FB_ANIM_CREATE:
    13611363                nvp = IPC_GET_ARG1(*call);
     
    14321434                        break;
    14331435                }
    1434                 newval = (IPC_GET_METHOD(*call) == FB_ANIM_START);
     1436                newval = (IPC_GET_IMETHOD(*call) == FB_ANIM_START);
    14351437                if (newval ^ animations[i].enabled) {
    14361438                        animations[i].enabled = newval;
     
    14421444        }
    14431445        if (handled)
    1444                 ipc_answer_0(callid, retval);
     1446                async_answer_0(callid, retval);
    14451447        return handled;
    14461448}
     
    14561458        int i, nvp;
    14571459       
    1458         switch (IPC_GET_METHOD(*call)) {
     1460        switch (IPC_GET_IMETHOD(*call)) {
    14591461        case FB_VP_DRAW_PIXMAP:
    14601462                nvp = IPC_GET_ARG1(*call);
     
    14951497       
    14961498        if (handled)
    1497                 ipc_answer_0(callid, retval);
     1499                async_answer_0(callid, retval);
    14981500        return handled;
    14991501       
     
    15111513                rgb->bg_color = color_table[COLOR_WHITE];
    15121514                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;
    15131523        default:
    15141524                return EINVAL;
    15151525        }
    1516 
     1526       
    15171527        return EOK;
    15181528}
    15191529
    1520 static int rgb_from_idx(attr_rgb_t *rgb, ipcarg_t fg_color,
    1521     ipcarg_t bg_color, ipcarg_t flags)
     1530static int rgb_from_idx(attr_rgb_t *rgb, sysarg_t fg_color,
     1531    sysarg_t bg_color, sysarg_t flags)
    15221532{
    15231533        fg_color = (fg_color & 7) | ((flags & CATTR_BRIGHT) ? 8 : 0);
     
    15511561}
    15521562
    1553 static int fb_set_style(viewport_t *vport, ipcarg_t style)
     1563static int fb_set_style(viewport_t *vport, sysarg_t style)
    15541564{
    15551565        return rgb_from_style(&vport->attr, (int) style);
    15561566}
    15571567
    1558 static int fb_set_color(viewport_t *vport, ipcarg_t fg_color,
    1559     ipcarg_t bg_color, ipcarg_t flags)
     1568static int fb_set_color(viewport_t *vport, sysarg_t fg_color,
     1569    sysarg_t bg_color, sysarg_t flags)
    15601570{
    15611571        return rgb_from_idx(&vport->attr, fg_color, bg_color, flags);
     
    15711581       
    15721582        if (client_connected) {
    1573                 ipc_answer_0(iid, ELIMIT);
     1583                async_answer_0(iid, ELIMIT);
    15741584                return;
    15751585        }
     
    15771587        /* Accept connection */
    15781588        client_connected = true;
    1579         ipc_answer_0(iid, EOK);
     1589        async_answer_0(iid, EOK);
    15801590       
    15811591        while (true) {
     
    16101620                        continue;
    16111621               
    1612                 switch (IPC_GET_METHOD(call)) {
     1622                switch (IPC_GET_IMETHOD(call)) {
    16131623                case IPC_M_PHONE_HUNGUP:
    16141624                        client_connected = false;
     
    16301640                                break;
    16311641                        }
    1632                         ipc_answer_0(callid, EOK);
     1642                        async_answer_0(callid, EOK);
    16331643                       
    16341644                        draw_char(vport, ch, col, row);
     
    16631673                        break;
    16641674                case FB_GET_CSIZE:
    1665                         ipc_answer_2(callid, EOK, vport->cols, vport->rows);
     1675                        async_answer_2(callid, EOK, vport->cols, vport->rows);
    16661676                        continue;
    16671677                case FB_GET_COLOR_CAP:
    1668                         ipc_answer_1(callid, EOK, FB_CCAP_RGB);
     1678                        async_answer_1(callid, EOK, FB_CCAP_RGB);
    16691679                        continue;
    16701680                case FB_SCROLL:
     
    17311741                        break;
    17321742                case FB_GET_RESOLUTION:
    1733                         ipc_answer_2(callid, EOK, screen.xres, screen.yres);
     1743                        async_answer_2(callid, EOK, screen.xres, screen.yres);
    17341744                        continue;
    17351745                case FB_POINTER_MOVE:
     
    17451755                        retval = ENOENT;
    17461756                }
    1747                 ipc_answer_0(callid, retval);
     1757                async_answer_0(callid, retval);
    17481758        }
    17491759}
     
    17561766        async_set_client_connection(fb_client_connection);
    17571767       
    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;
    17661793        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,
    17691796            ALIGN_UP(fbsize, PAGE_SIZE) >> PAGE_WIDTH, AS_AREA_READ | AS_AREA_WRITE) != 0)
    17701797                return -1;
    1771 
     1798       
    17721799        if (screen_init(fb_addr, fb_width, fb_height, fb_scanline, fb_visual))
    17731800                return 0;
    1774 
     1801       
    17751802        return -1;
    17761803}
Note: See TracChangeset for help on using the changeset viewer.