Changeset 8ff0bd2 in mainline for uspace/srv/hid


Ignore:
Timestamp:
2011-09-04T11:30:58Z (15 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/fix-logger-deadlock, topic/msim-upgrade, topic/simplify-dev-export
Children:
03bc76a
Parents:
d2c67e7 (diff), deac215e (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

Location:
uspace/srv/hid
Files:
21 added
17 deleted
14 edited
31 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/console/Makefile

    rd2c67e7 r8ff0bd2  
    2929
    3030USPACE_PREFIX = ../../..
     31LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a
     32EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX)
    3133BINARY = console
    3234
    33 GENERIC_SOURCES = \
     35SOURCES = \
    3436        console.c \
    3537        keybuffer.c \
     38        images.c \
    3639        gcons.c
    3740
    3841IMAGES = \
    39         gfx/helenos.ppm \
    40         gfx/nameic.ppm \
    41         gfx/cons_selected.ppm \
    42         gfx/cons_idle.ppm \
    43         gfx/cons_has_data.ppm \
    44         gfx/cons_kernel.ppm \
    45         gfx/anim_1.ppm \
    46         gfx/anim_2.ppm \
    47         gfx/anim_3.ppm \
    48         gfx/anim_4.ppm
     42        gfx/helenos.tga \
     43        gfx/nameic.tga \
     44        gfx/cons_selected.tga \
     45        gfx/cons_idle.tga \
     46        gfx/cons_has_data.tga \
     47        gfx/cons_kernel.tga \
     48        gfx/anim_1.tga \
     49        gfx/anim_2.tga \
     50        gfx/anim_3.tga \
     51        gfx/anim_4.tga
    4952
    50 SOURCES = \
    51         $(GENERIC_SOURCES) \
    52         $(IMAGES)
     53PRE_DEPEND = images.c images.h
     54EXTRA_CLEAN = images.c images.h
    5355
    5456include $(USPACE_PREFIX)/Makefile.common
    5557
    56 %.o: %.ppm
    57         $(OBJCOPY) -I binary -O $(BFD_NAME) -B $(BFD_ARCH) $< $@
     58images.c images.h: $(IMAGES)
     59        $(ROOT_PATH)/tools/mkarray.py images CONSOLE_IMAGES $^
  • uspace/srv/hid/console/console.c

    rd2c67e7 r8ff0bd2  
    11/*
    22 * Copyright (c) 2006 Josef Cejka
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3435
    3536#include <libc.h>
    36 #include <ipc/kbd.h>
     37#include <ipc/input.h>
    3738#include <io/keycode.h>
    38 #include <ipc/mouse.h>
    3939#include <ipc/fb.h>
    4040#include <ipc/services.h>
     
    5353#include <sysinfo.h>
    5454#include <event.h>
    55 #include <devmap.h>
    56 #include <devmap_obsolete.h>
     55#include <loc.h>
    5756#include <fcntl.h>
    5857#include <vfs/vfs.h>
     
    6059#include <io/style.h>
    6160#include <io/screenbuffer.h>
    62 #include <inttypes.h>
    6361
    6462#include "console.h"
     
    6664#include "keybuffer.h"
    6765
    68 // FIXME: remove this header
    69 #include <kernel/ipc/ipc_methods.h>
    70 
    7166#define NAME       "console"
    7267#define NAMESPACE  "term"
    7368
    74 /** Interval for checking for new keyboard (1/4s). */
    75 #define HOTPLUG_WATCH_INTERVAL (1000 * 250)
    76 
    77 /* Kernel defines 32 but does not export it. */
    78 #define MAX_IPC_OUTGOING_PHONES 128
    79 
    80 /** To allow proper phone closing. */
    81 static ipc_callid_t driver_phones[MAX_IPC_OUTGOING_PHONES] = { 0 };
    82 
    83 /** Phone to the keyboard driver. */
    84 static int kbd_phone;
    85 
    86 /** Phone to the mouse driver. */
    87 static int mouse_phone;
     69/** Session with the input server. */
     70static async_sess_t *input_sess;
    8871
    8972/** Information about framebuffer */
     
    9881        size_t index;             /**< Console index */
    9982        size_t refcount;          /**< Connection reference count */
    100         devmap_handle_t devmap_handle;  /**< Device handle */
     83        service_id_t service_id;  /**< Service ID */
    10184        keybuffer_t keybuffer;    /**< Buffer for incoming keys. */
    10285        screenbuffer_t scr;       /**< Screenbuffer for saving screen
     
    125108static FIBRIL_CONDVAR_INITIALIZE(input_cv);
    126109
     110static FIBRIL_MUTEX_INITIALIZE(big_console_lock);
     111
     112static void console_serialize_start(void)
     113{
     114        fibril_mutex_lock(&big_console_lock);
     115}
     116
     117static void console_serialize_end(void)
     118{
     119        fibril_mutex_unlock(&big_console_lock);
     120}
     121
    127122static void curs_visibility(bool visible)
    128123{
     
    155150}
    156151
    157 static void kbd_yield(void)
    158 {
    159         async_obsolete_req_0_0(kbd_phone, KBD_YIELD);
    160 }
    161 
    162 static void kbd_reclaim(void)
    163 {
    164         async_obsolete_req_0_0(kbd_phone, KBD_RECLAIM);
     152static void input_yield(void)
     153{
     154        async_exch_t *exch = async_exchange_begin(input_sess);
     155        if (exch == NULL) {
     156                printf("%s: Failed starting exchange with input device.\n",
     157                    NAME);
     158                return;
     159        }
     160       
     161        async_req_0_0(exch, INPUT_YIELD);
     162        async_exchange_end(exch);
     163}
     164
     165static void input_reclaim(void)
     166{
     167        async_exch_t *exch = async_exchange_begin(input_sess);
     168        if (exch == NULL) {
     169                printf("%s: Failed starting exchange with input device.\n",
     170                    NAME);
     171                return;
     172        }
     173       
     174        async_req_0_0(exch, INPUT_RECLAIM);
     175        async_exchange_end(exch);
    165176}
    166177
     
    339350       
    340351        if (cons == kernel_console) {
    341                 async_obsolete_serialize_start();
     352                console_serialize_start();
    342353                curs_hide_sync();
    343354                gcons_in_kernel();
    344355                screen_yield();
    345                 kbd_yield();
    346                 async_obsolete_serialize_end();
    347                
    348                 if (__SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE)) {
     356                input_yield();
     357                console_serialize_end();
     358               
     359                if (console_kcon()) {
    349360                        prev_console = active_console;
    350361                        active_console = kernel_console;
     
    354365       
    355366        if (cons != kernel_console) {
    356                 async_obsolete_serialize_start();
     367                console_serialize_start();
    357368               
    358369                if (active_console == kernel_console) {
    359370                        screen_reclaim();
    360                         kbd_reclaim();
     371                        input_reclaim();
    361372                        gcons_redraw_console();
    362373                }
     
    409420                curs_visibility(cons->scr.is_cursor_visible);
    410421               
    411                 async_obsolete_serialize_end();
    412         }
    413 }
    414 
    415 static void close_driver_phone(ipc_callid_t hash)
    416 {
    417         int i;
    418         for (i = 0; i < MAX_IPC_OUTGOING_PHONES; i++) {
    419                 if (driver_phones[i] == hash) {
    420                         printf("Device %" PRIxn " gone.\n", hash);
    421                         driver_phones[i] = 0;
    422                         async_obsolete_hangup(i);
    423                         return;
    424                 }
    425         }
    426 }
    427 
    428 /** Handler for keyboard */
    429 static void keyboard_events(ipc_callid_t iid, ipc_call_t *icall)
     422                console_serialize_end();
     423        }
     424}
     425
     426/** Handler for input events */
     427static void input_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    430428{
    431429        /* Ignore parameters, the connection is already opened */
     
    439437                if (!IPC_GET_IMETHOD(call)) {
    440438                        /* TODO: Handle hangup */
    441                         close_driver_phone(iid);
     439                        async_hangup(input_sess);
    442440                        return;
    443441                }
    444442               
    445443                switch (IPC_GET_IMETHOD(call)) {
    446                 case KBD_EVENT:
    447                         /* Got event from keyboard driver. */
     444                case INPUT_EVENT_KEY:
     445                        /* Got key press/release event */
    448446                        retval = 0;
    449447                        ev.type = IPC_GET_ARG1(call);
     
    466464                        fibril_mutex_unlock(&input_mutex);
    467465                        break;
    468                 default:
    469                         retval = ENOENT;
    470                 }
    471                 async_answer_0(callid, retval);
    472         }
    473 }
    474 
    475 /** Handler for mouse events */
    476 static void mouse_events(ipc_callid_t iid, ipc_call_t *icall)
    477 {
    478         /* Ignore parameters, the connection is already opened */
    479         while (true) {
    480                 ipc_call_t call;
    481                 ipc_callid_t callid = async_get_call(&call);
    482                
    483                 int retval;
    484                
    485                 if (!IPC_GET_IMETHOD(call)) {
    486                         /* TODO: Handle hangup */
    487                         close_driver_phone(iid);
    488                         return;
    489                 }
    490                
    491                 switch (IPC_GET_IMETHOD(call)) {
    492                 case MEVENT_BUTTON:
     466                case INPUT_EVENT_MOVE:
     467                        /* Got pointer move event */
     468                        gcons_mouse_move((int) IPC_GET_ARG1(call),
     469                            (int) IPC_GET_ARG2(call));
     470                        retval = 0;
     471                        break;
     472                case INPUT_EVENT_BUTTON:
     473                        /* Got pointer button press/release event */
    493474                        if (IPC_GET_ARG1(call) == 1) {
    494475                                int newcon = gcons_mouse_btn((bool) IPC_GET_ARG2(call));
     
    498479                        retval = 0;
    499480                        break;
    500                 case MEVENT_MOVE:
    501                         gcons_mouse_move((int) IPC_GET_ARG1(call),
    502                             (int) IPC_GET_ARG2(call));
    503                         retval = 0;
    504                         break;
    505481                default:
    506482                        retval = ENOENT;
     
    522498        }
    523499       
    524         async_obsolete_serialize_start();
     500        console_serialize_start();
    525501       
    526502        size_t off = 0;
     
    530506        }
    531507       
    532         async_obsolete_serialize_end();
     508        console_serialize_end();
    533509       
    534510        gcons_notify_char(cons->index);
     
    597573
    598574/** Default thread for new connections */
    599 static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
     575static void client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    600576{
    601577        console_t *cons = NULL;
     
    606582                        continue;
    607583               
    608                 if (consoles[i].devmap_handle == (devmap_handle_t) IPC_GET_ARG1(*icall)) {
     584                if (consoles[i].service_id == (service_id_t) IPC_GET_ARG1(*icall)) {
    609585                        cons = &consoles[i];
    610586                        break;
     
    625601        int rc;
    626602       
    627         async_obsolete_serialize_start();
     603        console_serialize_start();
    628604        if (cons->refcount == 0)
    629605                gcons_notify_connect(cons->index);
     
    635611       
    636612        while (true) {
    637                 async_obsolete_serialize_end();
     613                console_serialize_end();
    638614                callid = async_get_call(&call);
    639                 async_obsolete_serialize_start();
     615                console_serialize_start();
    640616               
    641617                arg1 = 0;
     
    647623                        if (cons->refcount == 0)
    648624                                gcons_notify_disconnect(cons->index);
     625                        console_serialize_end();
    649626                        return;
    650627                }
     
    652629                switch (IPC_GET_IMETHOD(call)) {
    653630                case VFS_OUT_READ:
    654                         async_obsolete_serialize_end();
     631                        console_serialize_end();
    655632                        cons_read(cons, callid, &call);
    656                         async_obsolete_serialize_start();
     633                        console_serialize_start();
    657634                        continue;
    658635                case VFS_OUT_WRITE:
    659                         async_obsolete_serialize_end();
     636                        console_serialize_end();
    660637                        cons_write(cons, callid, &call);
    661                         async_obsolete_serialize_start();
     638                        console_serialize_start();
    662639                        continue;
    663640                case VFS_OUT_SYNC:
     
    730707                        break;
    731708                case CONSOLE_GET_EVENT:
    732                         async_obsolete_serialize_end();
     709                        console_serialize_end();
    733710                        cons_get_event(cons, callid, &call);
    734                         async_obsolete_serialize_start();
     711                        console_serialize_start();
    735712                        continue;
    736                 case CONSOLE_KCON_ENABLE:
    737                         change_console(kernel_console);
    738                         break;
    739713                }
    740714                async_answer_3(callid, EOK, arg1, arg2, arg3);
     
    747721}
    748722
    749 static int async_connect_to_me_hack(int phone, sysarg_t arg1, sysarg_t arg2,
    750     sysarg_t arg3, async_client_conn_t client_receiver, ipc_callid_t *hash)
    751 {
    752         sysarg_t task_hash;
    753         sysarg_t phone_hash;
    754         int rc = async_obsolete_req_3_5(phone, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3,
    755             NULL, NULL, NULL, &task_hash, &phone_hash);
    756         if (rc != EOK)
    757                 return rc;
    758        
    759         if (client_receiver != NULL)
    760                 async_new_connection(task_hash, phone_hash, phone_hash, NULL,
    761                     client_receiver);
    762        
    763         if (hash != NULL)
    764                 *hash = phone_hash;
    765        
    766         return EOK;
    767 }
    768 
    769 static int connect_keyboard_or_mouse(const char *devname,
    770     async_client_conn_t handler, const char *dev)
    771 {
    772         int phone;
    773         devmap_handle_t handle;
    774        
    775         int rc = devmap_device_get_handle(dev, &handle, 0);
     723static async_sess_t *connect_input(const char *svc_path)
     724{
     725        async_sess_t *sess;
     726        async_exch_t *exch;
     727        service_id_t service_id;
     728       
     729        int rc = loc_service_get_id(svc_path, &service_id, 0);
    776730        if (rc == EOK) {
    777                 phone = devmap_obsolete_device_connect(handle, 0);
    778                 if (phone < 0) {
    779                         printf("%s: Failed to connect to input device\n", NAME);
    780                         return phone;
    781                 }
    782         } else
    783                 return rc;
     731                sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
     732                if (sess == NULL) {
     733                        printf("%s: Failed to connect to input server\n", NAME);
     734                        return NULL;
     735                }
     736        } else {
     737                return NULL;
     738        }
     739       
     740        exch = async_exchange_begin(sess);
     741        if (exch == NULL) {
     742                printf("%s: Failed to create callback from input server.\n", NAME);
     743                return NULL;
     744        }
    784745       
    785746        /* NB: The callback connection is slotted for removal */
    786         ipc_callid_t hash;
    787         rc = async_connect_to_me_hack(phone, SERVICE_CONSOLE, 0, phone,
    788             handler, &hash);
     747        rc = async_connect_to_me(exch, 0, 0, 0, input_events, NULL);
     748
     749        async_exchange_end(exch);
     750
    789751        if (rc != EOK) {
    790                 async_obsolete_hangup(phone);
    791                 printf("%s: Failed to create callback from input device (%s).\n",
     752                async_hangup(sess);
     753                printf("%s: Failed to create callback from input server (%s).\n",
    792754                    NAME, str_error(rc));
    793                 return rc;
    794         }
    795        
    796         driver_phones[phone] = hash;
    797         printf("%s: found %s \"%s\" (%" PRIxn ").\n", NAME, devname, dev, hash);
    798         return phone;
    799 }
    800 
    801 static int connect_keyboard(const char *dev)
    802 {
    803         return connect_keyboard_or_mouse("keyboard", keyboard_events, dev);
    804 }
    805 
    806 static int connect_mouse(const char *dev)
    807 {
    808         return connect_keyboard_or_mouse("mouse", mouse_events, dev);
    809 }
    810 
    811 struct hid_class_info {
    812         char *classname;
    813         int (*connection_func)(const char *);
    814 };
    815 
    816 /** Periodically check for new keyboards in /dev/class/.
    817  *
    818  * @param arg Class name.
    819  *
    820  * @return This function should never exit.
    821  *
    822  */
    823 static int check_new_device_fibril(void *arg)
    824 {
    825         struct hid_class_info *dev_info = (struct hid_class_info *) arg;
    826        
    827         size_t index = 1;
    828        
    829         while (true) {
    830                 async_usleep(HOTPLUG_WATCH_INTERVAL);
    831                
    832                 char *dev;
    833                 int rc = asprintf(&dev, "class/%s\\%zu",
    834                     dev_info->classname, index);
    835                 if (rc < 0)
    836                         continue;
    837                
    838                 rc = dev_info->connection_func(dev);
    839                 if (rc > 0) {
    840                         /* We do not allow unplug. */
    841                         index++;
    842                 }
    843                
    844                 free(dev);
    845         }
    846        
    847         return EOK;
    848 }
    849 
    850 /** Start a fibril monitoring hot-plugged keyboards.
    851  */
    852 static void check_new_devices_in_background(int (*connection_func)(const char *),
    853     const char *classname)
    854 {
    855         struct hid_class_info *dev_info = malloc(sizeof(struct hid_class_info));
    856         if (dev_info == NULL) {
    857                 printf("%s: Out of memory, no hot-plug support.\n", NAME);
    858                 return;
    859         }
    860        
    861         int rc = asprintf(&dev_info->classname, "%s", classname);
    862         if (rc < 0) {
    863                 printf("%s: Failed to format classname: %s.\n", NAME,
    864                     str_error(rc));
    865                 return;
    866         }
    867        
    868         dev_info->connection_func = connection_func;
    869        
    870         fid_t fid = fibril_create(check_new_device_fibril, (void *) dev_info);
    871         if (!fid) {
    872                 printf("%s: Failed to create hot-plug fibril for %s.\n", NAME,
    873                     classname);
    874                 return;
    875         }
    876        
    877         fibril_add_ready(fid);
    878 }
    879 
    880 static bool console_srv_init(char *kdev)
    881 {
    882         /* Connect to input device */
    883         kbd_phone = connect_keyboard(kdev);
    884         if (kbd_phone < 0)
     755                return NULL;
     756        }
     757       
     758        return sess;
     759}
     760
     761static bool console_srv_init(char *input_dev)
     762{
     763        /* Connect to input server */
     764        input_sess = connect_input(input_dev);
     765        if (input_sess == NULL)
    885766                return false;
    886        
    887         mouse_phone = connect_mouse("hid_in/mouse");
    888         if (mouse_phone < 0) {
    889                 printf("%s: Failed to connect to mouse device %s\n", NAME,
    890                     str_error(mouse_phone));
    891         }
    892767       
    893768        /* Connect to framebuffer driver */
     
    898773        }
    899774       
    900         /* Register driver */
    901         int rc = devmap_driver_register(NAME, client_connection);
     775        /* Register server */
     776        int rc = loc_server_register(NAME, client_connection);
    902777        if (rc < 0) {
    903                 printf("%s: Unable to register driver (%d)\n", NAME, rc);
     778                printf("%s: Unable to register server (%d)\n", NAME, rc);
    904779                return false;
    905780        }
     
    945820                        consoles[i].refcount = 0;
    946821                       
    947                         char vc[DEVMAP_NAME_MAXLEN + 1];
    948                         snprintf(vc, DEVMAP_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
     822                        char vc[LOC_NAME_MAXLEN + 1];
     823                        snprintf(vc, LOC_NAME_MAXLEN, "%s/vc%zu", NAMESPACE, i);
    949824                       
    950                         if (devmap_device_register(vc, &consoles[i].devmap_handle) != EOK) {
    951                                 printf("%s: Unable to register device %s\n", NAME, vc);
     825                        if (loc_service_register(vc, &consoles[i].service_id) != EOK) {
     826                                printf("%s: Unable to register service %s\n", NAME, vc);
    952827                                return false;
    953828                        }
     
    955830        }
    956831       
    957         /* Disable kernel output to the console */
    958         __SYSCALL0(SYS_DEBUG_DISABLE_CONSOLE);
    959        
    960832        /* Initialize the screen */
    961         async_obsolete_serialize_start();
     833        console_serialize_start();
    962834        gcons_redraw_console();
    963835        set_style(STYLE_NORMAL);
     
    965837        curs_goto(0, 0);
    966838        curs_visibility(active_console->scr.is_cursor_visible);
    967         async_obsolete_serialize_end();
     839        console_serialize_end();
    968840       
    969841        /* Receive kernel notifications */
     
    972844                printf("%s: Error registering kconsole notifications\n", NAME);
    973845       
    974         /* Start fibril for checking on hot-plugged keyboards. */
    975         check_new_devices_in_background(connect_keyboard, "keyboard");
    976         check_new_devices_in_background(connect_mouse, "mouse");
    977        
    978846        return true;
    979847}
     
    981849static void usage(void)
    982850{
    983         printf("Usage: console <input>\n");
     851        printf("Usage: console <input_dev>\n");
    984852}
    985853
  • uspace/srv/hid/console/gcons.c

    rd2c67e7 r8ff0bd2  
    4141#include <align.h>
    4242#include <bool.h>
     43#include <imgmap.h>
    4344
    4445#include "console.h"
    4546#include "gcons.h"
     47#include "images.h"
    4648
    4749#define CONSOLE_TOP     66
     
    5860#define COLOR_BACKGROUND  0xffffff
    5961
    60 extern char _binary_gfx_helenos_ppm_start[0];
    61 extern int _binary_gfx_helenos_ppm_size;
    62 extern char _binary_gfx_nameic_ppm_start[0];
    63 extern int _binary_gfx_nameic_ppm_size;
    64 
    65 extern char _binary_gfx_anim_1_ppm_start[0];
    66 extern int _binary_gfx_anim_1_ppm_size;
    67 extern char _binary_gfx_anim_2_ppm_start[0];
    68 extern int _binary_gfx_anim_2_ppm_size;
    69 extern char _binary_gfx_anim_3_ppm_start[0];
    70 extern int _binary_gfx_anim_3_ppm_size;
    71 extern char _binary_gfx_anim_4_ppm_start[0];
    72 extern int _binary_gfx_anim_4_ppm_size;
    73 
    74 extern char _binary_gfx_cons_selected_ppm_start[0];
    75 extern int _binary_gfx_cons_selected_ppm_size;
    76 extern char _binary_gfx_cons_idle_ppm_start[0];
    77 extern int _binary_gfx_cons_idle_ppm_size;
    78 extern char _binary_gfx_cons_has_data_ppm_start[0];
    79 extern int _binary_gfx_cons_has_data_ppm_size;
    80 extern char _binary_gfx_cons_kernel_ppm_start[0];
    81 extern int _binary_gfx_cons_kernel_ppm_size;
    82 
    8362static bool use_gcons = false;
    8463static sysarg_t xres;
    8564static sysarg_t yres;
     65
     66static imgmap_t *helenos_img;
     67static imgmap_t *nameic_img;
     68
     69static imgmap_t *anim_1_img;
     70static imgmap_t *anim_2_img;
     71static imgmap_t *anim_3_img;
     72static imgmap_t *anim_4_img;
     73
     74static imgmap_t *cons_has_data_img;
     75static imgmap_t *cons_idle_img;
     76static imgmap_t *cons_kernel_img;
     77static imgmap_t *cons_selected_img;
    8678
    8779enum butstate {
     
    10193static int fbphone;
    10294
    103 /** List of pixmaps identifying these icons */
    104 static int ic_pixmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
     95/** List of image maps identifying these icons */
     96static int ic_imgmaps[CONS_LAST] = {-1, -1, -1, -1, -1, -1};
    10597static int animation = -1;
    10698
     
    149141        enum butstate state = console_state[index];
    150142       
    151         if (ic_pixmaps[state] != -1)
    152                 async_obsolete_msg_2(fbphone, FB_VP_DRAW_PIXMAP, cstatus_vp[index],
    153                     ic_pixmaps[state]);
     143        if (ic_imgmaps[state] != -1)
     144                async_obsolete_msg_2(fbphone, FB_VP_DRAW_IMGMAP, cstatus_vp[index],
     145                    ic_imgmaps[state]);
    154146       
    155147        if ((state != CONS_DISCONNECTED) && (state != CONS_KERNEL)
     
    168160void gcons_change_console(size_t index)
    169161{
    170         if (!use_gcons)
    171                 return;
     162        if (!use_gcons) {
     163                active_console = index;
     164                return;
     165        }
    172166       
    173167        if (active_console == KERNEL_CONSOLE) {
     
    356350}
    357351
    358 /** Draw a PPM pixmap to framebuffer
    359  *
    360  * @param logo Pointer to PPM data
    361  * @param size Size of PPM data
    362  * @param x Coordinate of upper left corner
    363  * @param y Coordinate of upper left corner
    364  *
    365  */
    366 static void draw_pixmap(char *logo, size_t size, sysarg_t x, sysarg_t y)
    367 {
     352/** Draw an image map to framebuffer
     353 *
     354 * @param img  Image map
     355 * @param x    Coordinate of upper left corner
     356 * @param y    Coordinate of upper left corner
     357 *
     358 */
     359static void draw_imgmap(imgmap_t *img, sysarg_t x, sysarg_t y)
     360{
     361        if (img == NULL)
     362                return;
     363       
    368364        /* Create area */
    369         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
     365        char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    370366            MAP_ANONYMOUS, 0, 0);
    371367        if (shm == MAP_FAILED)
    372368                return;
    373369       
    374         memcpy(shm, logo, size);
     370        memcpy(shm, img, img->size);
    375371       
    376372        /* Send area */
     
    384380       
    385381        /* Draw logo */
    386         async_obsolete_msg_2(fbphone, FB_DRAW_PPM, x, y);
     382        async_obsolete_msg_2(fbphone, FB_DRAW_IMGMAP, x, y);
    387383       
    388384drop:
     
    392388exit:
    393389        /* Remove area */
    394         munmap(shm, size);
     390        munmap(shm, img->size);
    395391}
    396392
     
    404400        set_rgb_color(COLOR_MAIN, COLOR_MAIN);
    405401        clear();
    406         draw_pixmap(_binary_gfx_helenos_ppm_start,
    407             (size_t) &_binary_gfx_helenos_ppm_size, xres - 66, 2);
    408         draw_pixmap(_binary_gfx_nameic_ppm_start,
    409             (size_t) &_binary_gfx_nameic_ppm_size, 5, 17);
     402        draw_imgmap(helenos_img, xres - 66, 2);
     403        draw_imgmap(nameic_img, 5, 17);
    410404       
    411405        unsigned int i;
     
    416410}
    417411
    418 /** Creates a pixmap on framebuffer
    419  *
    420  * @param data PPM data
    421  * @param size PPM data size
    422  *
    423  * @return Pixmap identification
    424  *
    425  */
    426 static int make_pixmap(char *data, size_t size)
    427 {
     412/** Create an image map on framebuffer
     413 *
     414 * @param img Image map.
     415 *
     416 * @return Image map identification
     417 *
     418 */
     419static int make_imgmap(imgmap_t *img)
     420{
     421        if (img == NULL)
     422                return -1;
     423       
    428424        /* Create area */
    429         char *shm = mmap(NULL, size, PROTO_READ | PROTO_WRITE, MAP_SHARED |
    430             MAP_ANONYMOUS, 0, 0);
     425        char *shm = mmap(NULL, img->size, PROTO_READ | PROTO_WRITE,
     426            MAP_SHARED | MAP_ANONYMOUS, 0, 0);
    431427        if (shm == MAP_FAILED)
    432428                return -1;
    433429       
    434         memcpy(shm, data, size);
    435        
    436         int pxid = -1;
     430        memcpy(shm, img, img->size);
     431       
     432        int id = -1;
    437433       
    438434        /* Send area */
     
    445441                goto drop;
    446442       
    447         /* Obtain pixmap */
    448         rc = async_obsolete_req_0_0(fbphone, FB_SHM2PIXMAP);
     443        /* Obtain image map identifier */
     444        rc = async_obsolete_req_0_0(fbphone, FB_SHM2IMGMAP);
    449445        if (rc < 0)
    450446                goto drop;
    451447       
    452         pxid = rc;
     448        id = rc;
    453449       
    454450drop:
     
    458454exit:
    459455        /* Remove area */
    460         munmap(shm, size);
    461        
    462         return pxid;
     456        munmap(shm, img->size);
     457       
     458        return id;
    463459}
    464460
     
    470466                return;
    471467       
    472         int pm = make_pixmap(_binary_gfx_anim_1_ppm_start,
    473             (size_t) &_binary_gfx_anim_1_ppm_size);
    474         async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    475        
    476         pm = make_pixmap(_binary_gfx_anim_2_ppm_start,
    477             (size_t) &_binary_gfx_anim_2_ppm_size);
    478         async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    479        
    480         pm = make_pixmap(_binary_gfx_anim_3_ppm_start,
    481             (size_t) &_binary_gfx_anim_3_ppm_size);
    482         async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
    483        
    484         pm = make_pixmap(_binary_gfx_anim_4_ppm_start,
    485             (size_t) &_binary_gfx_anim_4_ppm_size);
    486         async_obsolete_msg_2(fbphone, FB_ANIM_ADDPIXMAP, an, pm);
     468        int pm = make_imgmap(anim_1_img);
     469        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     470       
     471        pm = make_imgmap(anim_2_img);
     472        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     473       
     474        pm = make_imgmap(anim_3_img);
     475        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
     476       
     477        pm = make_imgmap(anim_4_img);
     478        async_obsolete_msg_2(fbphone, FB_ANIM_ADDIMGMAP, an, pm);
    487479       
    488480        async_obsolete_msg_1(fbphone, FB_ANIM_START, an);
     
    502494        if ((xres < 800) || (yres < 600))
    503495                return;
     496       
     497        /* Create image maps */
     498        helenos_img = imgmap_decode_tga((void *) helenos_tga,
     499            helenos_tga_size);
     500        nameic_img = imgmap_decode_tga((void *) nameic_tga,
     501            nameic_tga_size);
     502       
     503        anim_1_img = imgmap_decode_tga((void *) anim_1_tga,
     504            anim_1_tga_size);
     505        anim_2_img = imgmap_decode_tga((void *) anim_2_tga,
     506            anim_2_tga_size);
     507        anim_3_img = imgmap_decode_tga((void *) anim_3_tga,
     508            anim_3_tga_size);
     509        anim_4_img = imgmap_decode_tga((void *) anim_4_tga,
     510            anim_4_tga_size);
     511       
     512        cons_has_data_img = imgmap_decode_tga((void *) cons_has_data_tga,
     513            cons_has_data_tga_size);
     514        cons_idle_img = imgmap_decode_tga((void *) cons_idle_tga,
     515            cons_idle_tga_size);
     516        cons_kernel_img = imgmap_decode_tga((void *) cons_kernel_tga,
     517            cons_kernel_tga_size);
     518        cons_selected_img = imgmap_decode_tga((void *) cons_selected_tga,
     519            cons_selected_tga_size);
    504520       
    505521        /* Create console viewport */
     
    529545       
    530546        /* Initialize icons */
    531         ic_pixmaps[CONS_SELECTED] =
    532             make_pixmap(_binary_gfx_cons_selected_ppm_start,
    533             (size_t) &_binary_gfx_cons_selected_ppm_size);
    534         ic_pixmaps[CONS_IDLE] =
    535             make_pixmap(_binary_gfx_cons_idle_ppm_start,
    536             (size_t) &_binary_gfx_cons_idle_ppm_size);
    537         ic_pixmaps[CONS_HAS_DATA] =
    538             make_pixmap(_binary_gfx_cons_has_data_ppm_start,
    539             (size_t) &_binary_gfx_cons_has_data_ppm_size);
    540         ic_pixmaps[CONS_DISCONNECTED] =
    541             make_pixmap(_binary_gfx_cons_idle_ppm_start,
    542             (size_t) &_binary_gfx_cons_idle_ppm_size);
    543         ic_pixmaps[CONS_KERNEL] =
    544             make_pixmap(_binary_gfx_cons_kernel_ppm_start,
    545             (size_t) &_binary_gfx_cons_kernel_ppm_size);
    546         ic_pixmaps[CONS_DISCONNECTED_SEL] = ic_pixmaps[CONS_SELECTED];
     547        ic_imgmaps[CONS_SELECTED] = make_imgmap(cons_selected_img);
     548        ic_imgmaps[CONS_IDLE] = make_imgmap(cons_idle_img);
     549        ic_imgmaps[CONS_HAS_DATA] = make_imgmap(cons_has_data_img);
     550        ic_imgmaps[CONS_DISCONNECTED] = make_imgmap(cons_idle_img);
     551        ic_imgmaps[CONS_KERNEL] = make_imgmap(cons_kernel_img);
     552        ic_imgmaps[CONS_DISCONNECTED_SEL] = ic_imgmaps[CONS_SELECTED];
    547553       
    548554        make_anim();
  • uspace/srv/hid/fb/Makefile

    rd2c67e7 r8ff0bd2  
    4040
    4141SOURCES = \
    42         main.c \
    43         ppm.c
     42        main.c
    4443
    4544ifneq ($(UARCH),ia64)
     
    8483                EXTRA_CFLAGS += -DNIAGARA_ENABLED
    8584        endif
    86        
    87         ifeq ($(MACHINE),serengeti)
    88                 SOURCES += \
    89                         sgcn.c \
    90                         serial_console.c
    91                 EXTRA_CFLAGS += -DSGCN_ENABLED
    92         endif
    9385endif
    9486
    95 EXTRA_CFLAGS += -D$(UARCH)
     87LIBS = $(LIBIMGMAP_PREFIX)/libimgmap.a
     88EXTRA_CFLAGS += -I$(LIBIMGMAP_PREFIX) -D$(UARCH)
    9689
    9790include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/hid/fb/ega.c

    rd2c67e7 r8ff0bd2  
    5656
    5757// FIXME: remove this header
    58 #include <kernel/ipc/ipc_methods.h>
     58#include <abi/ipc/methods.h>
    5959
    6060#define MAX_SAVED_SCREENS  256
     
    256256}
    257257
    258 static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     258static void ega_client_connection(ipc_callid_t iid, ipc_call_t *icall,
     259    void *arg)
    259260{
    260261        size_t intersize = 0;
     
    413414                        retval = 0;
    414415                        break;
    415                 case FB_VP_DRAW_PIXMAP:
     416                case FB_VP_DRAW_IMGMAP:
    416417                        scr = IPC_GET_ARG2(call);
    417418                        retval = print_screen(scr);
    418419                        break;
    419                 case FB_VP2PIXMAP:
     420                case FB_VP2IMGMAP:
    420421                        retval = save_screen();
    421422                        break;
    422                 case FB_DROP_PIXMAP:
     423                case FB_DROP_IMGMAP:
    423424                        scr = IPC_GET_ARG1(call);
    424425                       
  • uspace/srv/hid/fb/fb.c

    rd2c67e7 r8ff0bd2  
    4949#include <ipc/ns.h>
    5050#include <ipc/services.h>
    51 #include <kernel/errno.h>
    52 #include <kernel/genarch/fb/visuals.h>
     51#include <errno.h>
     52#include <abi/fb/visuals.h>
    5353#include <io/color.h>
    5454#include <io/style.h>
     
    5959#include <byteorder.h>
    6060#include <io/screenbuffer.h>
     61#include <imgmap.h>
    6162#include "font-8x16.h"
    6263#include "fb.h"
    6364#include "main.h"
    64 #include "ppm.h"
    6565#include "pointer.xbm"
    6666#include "pointer_mask.xbm"
    6767
    6868// FIXME: remove this header
    69 #include <kernel/ipc/ipc_methods.h>
     69#include <abi/ipc/methods.h>
    7070
    7171#define DEFAULT_BGCOLOR  0xf0f0f0
     
    7676#define MAX_ANIM_LEN    8
    7777#define MAX_ANIMATIONS  4
    78 #define MAX_PIXMAPS     256  /**< Maximum number of saved pixmaps */
     78#define MAX_IMGMAPS     256  /**< Maximum number of saved image maps */
    7979#define MAX_VIEWPORTS   128  /**< Viewport is a rectangular area on the screen */
    8080
     
    160160        unsigned int pos;
    161161        unsigned int animlen;
    162         unsigned int pixmaps[MAX_ANIM_LEN];
     162        unsigned int imgmaps[MAX_ANIM_LEN];
    163163} animation_t;
    164164
     
    166166static bool anims_enabled;
    167167
    168 typedef struct {
    169         unsigned int width;
    170         unsigned int height;
    171         uint8_t *data;
    172 } pixmap_t;
    173 
    174 static pixmap_t pixmaps[MAX_PIXMAPS];
     168static imgmap_t *imgmaps[MAX_IMGMAPS];
    175169static viewport_t viewports[128];
    176170
     
    212206static void draw_vp_glyph(viewport_t *vport, bool cursor, unsigned int col,
    213207    unsigned int row);
    214 
    215208
    216209#define RED(x, bits)                 (((x) >> (8 + 8 + 8 - (bits))) & ((1 << (bits)) - 1))
     
    875868}
    876869
    877 
    878870/** Show cursor if cursor showing is enabled
    879871 *
     
    888880}
    889881
    890 
    891882/** Invert cursor, if it is enabled
    892883 *
     
    899890                cursor_show(vport);
    900891}
    901 
    902892
    903893/** Draw character at given position relative to viewport
     
    981971}
    982972
    983 
    984 static void putpixel_pixmap(void *data, unsigned int x, unsigned int y, uint32_t color)
    985 {
    986         int pm = *((int *) data);
    987         pixmap_t *pmap = &pixmaps[pm];
    988         unsigned int pos = (y * pmap->width + x) * screen.pixelbytes;
    989        
    990         screen.rgb_conv(&pmap->data[pos], color);
    991 }
    992 
    993 
    994 static void putpixel(void *data, unsigned int x, unsigned int y, uint32_t color)
    995 {
    996         viewport_t *vport = (viewport_t *) data;
     973static void putpixel(viewport_t *vport, unsigned int x, unsigned int y,
     974    uint32_t color)
     975{
    997976        unsigned int dx = vport->x + x;
    998977        unsigned int dy = vport->y + y;
     
    1001980}
    1002981
    1003 
    1004 /** Return first free pixmap
    1005  *
    1006  */
    1007 static int find_free_pixmap(void)
     982/** Draw image map
     983 *
     984 * @param[in] img       Image map.
     985 * @param[in] sx        Coordinate of upper left corner.
     986 * @param[in] sy        Coordinate of upper left corner.
     987 * @param[in] maxwidth  Maximum allowed width for picture.
     988 * @param[in] maxheight Maximum allowed height for picture.
     989 * @param[in] vport     Viewport.
     990 *
     991 * @return EOK on success.
     992 *
     993 */
     994static int imgmap_draw(imgmap_t *img, unsigned int sx, unsigned int sy,
     995    unsigned int maxwidth, unsigned int maxheight, void *vport)
     996{
     997        if (img->visual != VISUAL_BGR_8_8_8)
     998                return EINVAL;
     999       
     1000        uint8_t *data = (uint8_t *) img->data;
     1001       
     1002        for (sysarg_t y = 0; y < img->height; y++) {
     1003                for (sysarg_t x = 0; x < img->width; x++) {
     1004                        if ((x > maxwidth) || (y > maxheight)) {
     1005                                data += 3;
     1006                                continue;
     1007                        }
     1008                       
     1009                        uint32_t color = (data[2] << 16) + (data[1] << 8) + data[0];
     1010                       
     1011                        putpixel(vport, sx + x, sy + y, color);
     1012                        data += 3;
     1013                }
     1014        }
     1015       
     1016        return EOK;
     1017}
     1018
     1019/** Return first free image map
     1020 *
     1021 */
     1022static int find_free_imgmap(void)
    10081023{
    10091024        unsigned int i;
    10101025       
    1011         for (i = 0; i < MAX_PIXMAPS; i++)
    1012                 if (!pixmaps[i].data)
     1026        for (i = 0; i < MAX_IMGMAPS; i++)
     1027                if (!imgmaps[i])
    10131028                        return i;
    10141029       
     
    10161031}
    10171032
    1018 
    1019 /** Create a new pixmap and return appropriate ID
    1020  *
    1021  */
    1022 static int shm2pixmap(unsigned char *shm, size_t size)
    1023 {
    1024         int pm;
    1025         pixmap_t *pmap;
    1026        
    1027         pm = find_free_pixmap();
    1028         if (pm == -1)
     1033/** Create a new image map and return appropriate ID
     1034 *
     1035 */
     1036static int shm2imgmap(imgmap_t *shm, size_t size)
     1037{
     1038        int im = find_free_imgmap();
     1039        if (im == -1)
    10291040                return ELIMIT;
    10301041       
    1031         pmap = &pixmaps[pm];
    1032        
    1033         if (ppm_get_data(shm, size, &pmap->width, &pmap->height))
    1034                 return EINVAL;
    1035        
    1036         pmap->data = malloc(pmap->width * pmap->height * screen.pixelbytes);
    1037         if (!pmap->data)
     1042        imgmap_t *imap = malloc(size);
     1043        if (!imap)
    10381044                return ENOMEM;
    10391045       
    1040         ppm_draw(shm, size, 0, 0, pmap->width, pmap->height, putpixel_pixmap, (void *) &pm);
    1041        
    1042         return pm;
    1043 }
    1044 
     1046        memcpy(imap, shm, size);
     1047        imgmaps[im] = imap;
     1048        return im;
     1049}
    10451050
    10461051/** Handle shared memory communication calls
    10471052 *
    1048  * Protocol for drawing pixmaps:
     1053 * Protocol for drawing image maps:
    10491054 * - FB_PREPARE_SHM(client shm identification)
    10501055 * - IPC_M_AS_AREA_SEND
    1051  * - FB_DRAW_PPM(startx, starty)
     1056 * - FB_DRAW_IMGMAP(startx, starty)
    10521057 * - FB_DROP_SHM
    10531058 *
     
    10711076        static size_t intersize = 0;
    10721077       
    1073         static unsigned char *shm = NULL;
     1078        static imgmap_t *shm = NULL;
    10741079        static sysarg_t shm_id = 0;
    10751080        static size_t shm_size;
     
    10931098                                return false;
    10941099                        }
     1100                       
    10951101                        shm = dest;
    1096                        
    1097                         if (shm[0] != 'P')
    1098                                 return false;
    1099                        
    11001102                        return true;
    11011103                } else {
     
    11071109                if (shm_id)
    11081110                        retval = EBUSY;
    1109                 else 
     1111                else
    11101112                        shm_id = IPC_GET_ARG1(*call);
    11111113                break;
    1112                
    11131114        case FB_DROP_SHM:
    11141115                if (shm) {
     
    11181119                shm_id = 0;
    11191120                break;
    1120                
    1121         case FB_SHM2PIXMAP:
     1121        case FB_SHM2IMGMAP:
    11221122                if (!shm) {
    11231123                        retval = EINVAL;
    11241124                        break;
    11251125                }
    1126                 retval = shm2pixmap(shm, shm_size);
    1127                 break;
    1128         case FB_DRAW_PPM:
     1126                retval = shm2imgmap(shm, shm_size);
     1127                break;
     1128        case FB_DRAW_IMGMAP:
    11291129                if (!shm) {
    11301130                        retval = EINVAL;
    11311131                        break;
    11321132                }
     1133               
    11331134                x = IPC_GET_ARG1(*call);
    11341135                y = IPC_GET_ARG2(*call);
     
    11391140                }
    11401141               
    1141                 ppm_draw(shm, shm_size, IPC_GET_ARG1(*call),
    1142                     IPC_GET_ARG2(*call), vport->width - x, vport->height - y, putpixel, (void *) vport);
     1142                imgmap_draw(shm, IPC_GET_ARG1(*call), IPC_GET_ARG2(*call),
     1143                    vport->width - x, vport->height - y, vport);
    11431144                break;
    11441145        case FB_DRAW_TEXT_DATA:
     
    11671168        if (handled)
    11681169                async_answer_0(callid, retval);
     1170       
    11691171        return handled;
    11701172}
    11711173
    1172 
    1173 static void copy_vp_to_pixmap(viewport_t *vport, pixmap_t *pmap)
     1174static void copy_vp_to_imgmap(viewport_t *vport, imgmap_t *imap)
    11741175{
    11751176        unsigned int width = vport->width;
     
    11781179        if (width + vport->x > screen.xres)
    11791180                width = screen.xres - vport->x;
     1181       
    11801182        if (height + vport->y > screen.yres)
    11811183                height = screen.yres - vport->y;
    11821184       
    1183         unsigned int realwidth = pmap->width <= width ? pmap->width : width;
    1184         unsigned int realheight = pmap->height <= height ? pmap->height : height;
     1185        unsigned int realwidth = imap->width <= width ? imap->width : width;
     1186        unsigned int realheight = imap->height <= height ? imap->height : height;
    11851187       
    11861188        unsigned int srcrowsize = vport->width * screen.pixelbytes;
     
    11901192        for (y = 0; y < realheight; y++) {
    11911193                unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
    1192                 memcpy(pmap->data + srcrowsize * y, screen.fb_addr + tmp, realrowsize);
    1193         }
    1194 }
    1195 
    1196 
    1197 /** Save viewport to pixmap
    1198  *
    1199  */
    1200 static int save_vp_to_pixmap(viewport_t *vport)
    1201 {
    1202         int pm;
    1203         pixmap_t *pmap;
    1204        
    1205         pm = find_free_pixmap();
    1206         if (pm == -1)
     1194                memcpy(imap->data + srcrowsize * y, screen.fb_addr + tmp, realrowsize);
     1195        }
     1196}
     1197
     1198/** Save viewport to image map
     1199 *
     1200 */
     1201static int save_vp_to_imgmap(viewport_t *vport)
     1202{
     1203        int im = find_free_imgmap();
     1204        if (im == -1)
    12071205                return ELIMIT;
    12081206       
    1209         pmap = &pixmaps[pm];
    1210         pmap->data = malloc(screen.pixelbytes * vport->width * vport->height);
    1211         if (!pmap->data)
     1207        size_t size = screen.pixelbytes * vport->width * vport->height;
     1208        imgmap_t *imap = malloc(sizeof(imgmap_t) + size);
     1209        if (!imap)
    12121210                return ENOMEM;
    12131211       
    1214         pmap->width = vport->width;
    1215         pmap->height = vport->height;
    1216        
    1217         copy_vp_to_pixmap(vport, pmap);
    1218        
    1219         return pm;
    1220 }
    1221 
    1222 
    1223 /** Draw pixmap on screen
    1224  *
    1225  * @param vp Viewport to draw on
    1226  * @param pm Pixmap identifier
    1227  *
    1228  */
    1229 static int draw_pixmap(int vp, int pm)
    1230 {
    1231         pixmap_t *pmap = &pixmaps[pm];
     1212        imap->size = sizeof(imgmap_t) + size;
     1213        imap->width = vport->width;
     1214        imap->height = vport->height;
     1215        imap->visual = (visual_t) -1;
     1216       
     1217        copy_vp_to_imgmap(vport, imap);
     1218        imgmaps[im] = imap;
     1219        return im;
     1220}
     1221
     1222/** Draw image map to screen
     1223 *
     1224 * @param vp Viewport to draw to
     1225 * @param im Image map identifier
     1226 *
     1227 */
     1228static int draw_imgmap(int vp, int im)
     1229{
     1230        imgmap_t *imap = imgmaps[im];
     1231        if (!imap)
     1232                return EINVAL;
     1233       
    12321234        viewport_t *vport = &viewports[vp];
    12331235       
     
    12371239        if (width + vport->x > screen.xres)
    12381240                width = screen.xres - vport->x;
     1241       
    12391242        if (height + vport->y > screen.yres)
    12401243                height = screen.yres - vport->y;
    12411244       
    1242         if (!pmap->data)
    1243                 return EINVAL;
    1244        
    1245         unsigned int realwidth = pmap->width <= width ? pmap->width : width;
    1246         unsigned int realheight = pmap->height <= height ? pmap->height : height;
    1247        
    1248         unsigned int srcrowsize = vport->width * screen.pixelbytes;
    1249         unsigned int realrowsize = realwidth * screen.pixelbytes;
    1250        
    1251         unsigned int y;
    1252         for (y = 0; y < realheight; y++) {
    1253                 unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
    1254                 memcpy(screen.fb_addr + tmp, pmap->data + y * srcrowsize, realrowsize);
    1255         }
     1245        unsigned int realwidth = imap->width <= width ? imap->width : width;
     1246        unsigned int realheight = imap->height <= height ? imap->height : height;
     1247       
     1248        if (imap->visual == (visual_t) -1) {
     1249                unsigned int srcrowsize = vport->width * screen.pixelbytes;
     1250                unsigned int realrowsize = realwidth * screen.pixelbytes;
     1251               
     1252                unsigned int y;
     1253                for (y = 0; y < realheight; y++) {
     1254                        unsigned int tmp = (vport->y + y) * screen.scanline + vport->x * screen.pixelbytes;
     1255                        memcpy(screen.fb_addr + tmp, imap->data + y * srcrowsize, realrowsize);
     1256                }
     1257        } else
     1258                imgmap_draw(imap, 0, 0, realwidth, realheight, vport);
    12561259       
    12571260        return EOK;
    12581261}
    1259 
    12601262
    12611263/** Tick animation one step forward
     
    12771279                        continue;
    12781280               
    1279                 draw_pixmap(animations[i].vp, animations[i].pixmaps[animations[i].pos]);
     1281                draw_imgmap(animations[i].vp, animations[i].imgmaps[animations[i].pos]);
    12801282                animations[i].pos = (animations[i].pos + 1) % animations[i].animlen;
    12811283        }
     
    12871289static bool pointer_shown, pointer_enabled;
    12881290static int pointer_vport = -1;
    1289 static int pointer_pixmap = -1;
     1291static int pointer_imgmap = -1;
    12901292
    12911293
     
    13101312        }
    13111313       
    1312         if (pointer_pixmap == -1)
    1313                 pointer_pixmap = save_vp_to_pixmap(&viewports[pointer_vport]);
     1314        if (pointer_imgmap == -1)
     1315                pointer_imgmap = save_vp_to_imgmap(&viewports[pointer_vport]);
    13141316        else
    1315                 copy_vp_to_pixmap(&viewports[pointer_vport], &pixmaps[pointer_pixmap]);
     1317                copy_vp_to_imgmap(&viewports[pointer_vport], imgmaps[pointer_imgmap]);
    13161318       
    13171319        /* Draw mouse pointer. */
     
    13381340        /* Restore image under the pointer. */
    13391341        if (pointer_shown) {
    1340                 draw_pixmap(pointer_vport, pointer_pixmap);
     1342                draw_imgmap(pointer_vport, pointer_imgmap);
    13411343                pointer_shown = 0;
    13421344        }
     
    13931395                animations[i].initialized = 0;
    13941396                break;
    1395         case FB_ANIM_ADDPIXMAP:
     1397        case FB_ANIM_ADDIMGMAP:
    13961398                i = IPC_GET_ARG1(*call);
    13971399                if (i >= MAX_ANIMATIONS || i < 0 ||
     
    14051407                }
    14061408                newval = IPC_GET_ARG2(*call);
    1407                 if (newval < 0 || newval > MAX_PIXMAPS ||
    1408                         !pixmaps[newval].data) {
     1409                if (newval < 0 || newval > MAX_IMGMAPS ||
     1410                        !imgmaps[newval]) {
    14091411                        retval = EINVAL;
    14101412                        break;
    14111413                }
    1412                 animations[i].pixmaps[animations[i].animlen++] = newval;
     1414                animations[i].imgmaps[animations[i].animlen++] = newval;
    14131415                break;
    14141416        case FB_ANIM_CHGVP:
     
    14491451}
    14501452
    1451 
    1452 /** Handler for messages concerning pixmap handling
    1453  *
    1454  */
    1455 static int pixmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
     1453/** Handler for messages concerning image map handling
     1454 *
     1455 */
     1456static int imgmap_handle(ipc_callid_t callid, ipc_call_t *call, int vp)
    14561457{
    14571458        bool handled = true;
     
    14601461       
    14611462        switch (IPC_GET_IMETHOD(*call)) {
    1462         case FB_VP_DRAW_PIXMAP:
     1463        case FB_VP_DRAW_IMGMAP:
    14631464                nvp = IPC_GET_ARG1(*call);
    14641465                if (nvp == -1)
    14651466                        nvp = vp;
     1467               
    14661468                if (nvp < 0 || nvp >= MAX_VIEWPORTS ||
    1467                         !viewports[nvp].initialized) {
     1469                    !viewports[nvp].initialized) {
    14681470                        retval = EINVAL;
    14691471                        break;
    14701472                }
     1473               
    14711474                i = IPC_GET_ARG2(*call);
    1472                 retval = draw_pixmap(nvp, i);
    1473                 break;
    1474         case FB_VP2PIXMAP:
     1475                retval = draw_imgmap(nvp, i);
     1476                break;
     1477        case FB_VP2IMGMAP:
    14751478                nvp = IPC_GET_ARG1(*call);
    14761479                if (nvp == -1)
    14771480                        nvp = vp;
     1481               
    14781482                if (nvp < 0 || nvp >= MAX_VIEWPORTS ||
    1479                         !viewports[nvp].initialized)
     1483                    !viewports[nvp].initialized) {
    14801484                        retval = EINVAL;
    1481                 else
    1482                         retval = save_vp_to_pixmap(&viewports[nvp]);
    1483                 break;
    1484         case FB_DROP_PIXMAP:
     1485                        break;
     1486                }
     1487               
     1488                retval = save_vp_to_imgmap(&viewports[nvp]);
     1489                break;
     1490        case FB_DROP_IMGMAP:
    14851491                i = IPC_GET_ARG1(*call);
    1486                 if (i >= MAX_PIXMAPS) {
     1492                if (i >= MAX_IMGMAPS) {
    14871493                        retval = EINVAL;
    14881494                        break;
    14891495                }
    1490                 if (pixmaps[i].data) {
    1491                         free(pixmaps[i].data);
    1492                         pixmaps[i].data = NULL;
    1493                 }
     1496               
     1497                if (imgmaps[i]) {
     1498                        free(imgmaps[i]);
     1499                        imgmaps[i] = NULL;
     1500                }
     1501               
    14941502                break;
    14951503        default:
     
    15761584 *
    15771585 */
    1578 static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     1586static void fb_client_connection(ipc_callid_t iid, ipc_call_t *icall,
     1587    void *arg)
    15791588{
    15801589        unsigned int vp = 0;
     
    16151624                        continue;
    16161625               
    1617                 if (pixmap_handle(callid, &call, vp))
     1626                if (imgmap_handle(callid, &call, vp))
    16181627                        continue;
    16191628               
  • uspace/srv/hid/fb/fb.h

    rd2c67e7 r8ff0bd2  
    3939#include <stdint.h>
    4040
    41 typedef void (* putpixel_cb_t)(void *, unsigned int, unsigned int, uint32_t);
    42 
    4341extern int fb_init(void);
    4442
  • uspace/srv/hid/fb/main.c

    rd2c67e7 r8ff0bd2  
    4040#include "msim.h"
    4141#include "ski.h"
    42 #include "sgcn.h"
    4342#include "niagara.h"
    4443#include "main.h"
     
    9291        }
    9392#endif
    94 #ifdef SGCN_ENABLED
    95         if ((!initialized) && (fb_kind == 4)) {
    96                 if (sgcn_init() == 0)
    97                         initialized = true;
    98         }
    99 #endif
    10093#ifdef NIAGARA_ENABLED
    10194        if ((!initialized) && (fb_kind == 5)) {
  • uspace/srv/hid/fb/niagara.c

    rd2c67e7 r8ff0bd2  
    2929 */
    3030
    31 /** @defgroup niagarafb SGCN
     31/** @defgroup niagarafb
    3232 * @brief       userland driver of the Niagara console output
    3333 * @{
  • uspace/srv/hid/fb/niagara.h

    rd2c67e7 r8ff0bd2  
    2727 */
    2828
    29 /** @defgroup sgcnfb SGCN
    30  * @brief       userland driver of the Serengeti console output
     29/** @defgroup niagarafb
     30 * @brief       userland driver of the Niagara console output
    3131 * @{
    3232 */
  • uspace/srv/hid/fb/serial_console.c

    rd2c67e7 r8ff0bd2  
    5353
    5454// FIXME: remove this header
    55 #include <kernel/ipc/ipc_methods.h>
     55#include <abi/ipc/methods.h>
    5656
    5757#define MAX_CONTROL 20
     
    315315 * Main function of the thread serving client connections.
    316316 */
    317 void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall)
     317void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    318318{
    319319        keyfield_t *interbuf = NULL;
  • uspace/srv/hid/fb/serial_console.h

    rd2c67e7 r8ff0bd2  
    5252extern void serial_set_scroll_region(sysarg_t);
    5353extern void serial_console_init(putc_function_t, sysarg_t, sysarg_t);
    54 extern void serial_client_connection(ipc_callid_t, ipc_call_t *);
     54extern void serial_client_connection(ipc_callid_t, ipc_call_t *, void *arg);
    5555
    5656#endif
  • uspace/srv/hid/input/ctl/apple.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     30 * @ingroup input
    3131 * @{
    3232 */
    3333/**
    3434 * @file
    35  * @brief       Apple ADB keyboard controller driver.
     35 * @brief Apple ADB keyboard controller driver.
    3636 */
    3737
     
    4040#include <io/keycode.h>
    4141#include <kbd_ctl.h>
     42#include <kbd_port.h>
     43
     44static void apple_ctl_parse(sysarg_t);
     45static int apple_ctl_init(kbd_dev_t *);
     46static void apple_ctl_set_ind(kbd_dev_t *, unsigned int);
     47
     48kbd_ctl_ops_t apple_ctl = {
     49        .parse = apple_ctl_parse,
     50        .init = apple_ctl_init,
     51        .set_ind = apple_ctl_set_ind
     52};
    4253
    4354#define KBD_KEY_RELEASE         0x80
    4455
     56static kbd_dev_t *kbd_dev;
     57
    4558static int scanmap[];
    4659
    47 int kbd_ctl_init(void)
     60static int apple_ctl_init(kbd_dev_t *kdev)
    4861{
     62        kbd_dev = kdev;
    4963        return 0;
    5064}
    5165
    52 void kbd_ctl_parse_scancode(int scancode)
     66static void apple_ctl_parse(sysarg_t scancode)
    5367{
    5468        kbd_event_type_t type;
    5569        unsigned int key;
    5670
    57         if (scancode < 0 || scancode >= 0x100)
     71        if (scancode >= 0x100)
    5872                return;
    5973
     
    6781        key = scanmap[scancode];
    6882        if (key != 0)
    69                 kbd_push_ev(type, key);
     83                kbd_push_event(kbd_dev, type, key);
    7084}
    7185
    72 void kbd_ctl_set_ind(unsigned mods)
     86static void apple_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    7387{
    7488        (void) mods;
  • uspace/srv/hid/input/ctl/gxe_fb.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     30 * @ingroup input
    3131 * @{
    3232 */
     
    4040#include <io/keycode.h>
    4141#include <kbd_ctl.h>
     42#include <kbd_port.h>
    4243#include <gsp.h>
    4344#include <stroke.h>
    4445
     46static void gxe_fb_ctl_parse(sysarg_t);
     47static int gxe_fb_ctl_init(kbd_dev_t *);
     48static void gxe_fb_ctl_set_ind(kbd_dev_t *, unsigned int);
     49
     50kbd_ctl_ops_t gxe_fb_ctl = {
     51        .parse = gxe_fb_ctl_parse,
     52        .init = gxe_fb_ctl_init,
     53        .set_ind = gxe_fb_ctl_set_ind
     54};
     55
     56static kbd_dev_t *kbd_dev;
     57
    4558/** Scancode parser */
    4659static gsp_t sp;
     
    5164#include <stdio.h>
    5265
    53 int seq_defs[] = {
     66static int seq_defs[] = {
    5467        /* Not shifted */
    5568
     
    207220};
    208221
    209 int kbd_ctl_init(void)
     222static int gxe_fb_ctl_init(kbd_dev_t *kdev)
    210223{
     224        kbd_dev = kdev;
    211225        ds = 0;
    212226
     
    215229}
    216230
    217 void kbd_ctl_parse_scancode(int scancode)
     231static void gxe_fb_ctl_parse(sysarg_t scancode)
    218232{
    219233        unsigned mods, key;
     
    221235        ds = gsp_step(&sp, ds, scancode, &mods, &key);
    222236        if (key != 0) {
    223                 stroke_sim(mods, key);
     237                stroke_sim(kbd_dev, mods, key);
    224238        }
    225239}
    226240
    227 void kbd_ctl_set_ind(unsigned mods)
     241static void gxe_fb_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    228242{
    229243        (void) mods;
  • uspace/srv/hid/input/ctl/pc.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     30 * @ingroup input
    3131 * @{
    3232 */
     
    4343#include <gsp.h>
    4444
     45static void pc_ctl_parse(sysarg_t);
     46static int pc_ctl_init(kbd_dev_t *);
     47static void pc_ctl_set_ind(kbd_dev_t *, unsigned int);
     48
     49kbd_ctl_ops_t pc_ctl = {
     50        .parse = pc_ctl_parse,
     51        .init = pc_ctl_init,
     52        .set_ind = pc_ctl_set_ind
     53};
     54
    4555enum dec_state {
    4656        ds_s,
     
    6474
    6575static enum dec_state ds;
     76static kbd_dev_t *kbd_dev;
    6677
    6778static int scanmap_simple[] = {
     
    197208};
    198209
    199 int kbd_ctl_init(void)
     210static int pc_ctl_init(kbd_dev_t *kdev)
    200211{
     212        kbd_dev = kdev;
    201213        ds = ds_s;
    202214        return 0;
    203215}
    204216
    205 void kbd_ctl_parse_scancode(int scancode)
     217static void pc_ctl_parse(sysarg_t scancode)
    206218{
    207219        kbd_event_type_t type;
     
    245257        }
    246258
    247         if ((scancode < 0) || ((size_t) scancode >= map_length))
     259        if ((size_t) scancode >= map_length)
    248260                return;
    249261
    250262        key = map[scancode];
    251263        if (key != 0)
    252                 kbd_push_ev(type, key);
     264                kbd_push_event(kbd_dev, type, key);
    253265}
    254266
    255 void kbd_ctl_set_ind(unsigned mods)
     267static void pc_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    256268{
    257269        uint8_t b;
     
    265277                b = b | LI_SCROLL;
    266278
    267         kbd_port_write(KBD_CMD_SET_LEDS);
    268         kbd_port_write(b);
     279        (*kbd_dev->port_ops->write)(KBD_CMD_SET_LEDS);
     280        (*kbd_dev->port_ops->write)(b);
    269281}
    270282
  • uspace/srv/hid/input/ctl/stty.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2828
    2929/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     30 * @ingroup input
    3131 * @{
    3232 */
    3333/**
    3434 * @file
    35  * @brief       Serial TTY-like keyboard controller driver.
     35 * @brief Serial TTY-like keyboard controller driver.
     36 *
     37 * Keyboard emulation on a serial terminal.
    3638 */
    3739
     
    3941#include <io/keycode.h>
    4042#include <kbd_ctl.h>
     43#include <kbd_port.h>
    4144#include <gsp.h>
    4245#include <stroke.h>
    4346
     47static void stty_ctl_parse(sysarg_t);
     48static int stty_ctl_init(kbd_dev_t *);
     49static void stty_ctl_set_ind(kbd_dev_t *, unsigned int);
     50
     51kbd_ctl_ops_t stty_ctl = {
     52        .parse = stty_ctl_parse,
     53        .init = stty_ctl_init,
     54        .set_ind = stty_ctl_set_ind
     55};
     56
     57static kbd_dev_t *kbd_dev;
     58
    4459/** Scancode parser */
    4560static gsp_t sp;
     
    5065#include <stdio.h>
    5166
    52 int seq_defs[] = {
     67/**
     68 * Sequnece definitions are primarily for Xterm. Additionally we define
     69 * sequences that are unique to Gnome terminal -- most are the same but
     70 * some differ.
     71 */
     72static int seq_defs[] = {
    5373        /* Not shifted */
    5474
     
    6888        0,      KC_MINUS,       0x2d, GSP_END,
    6989        0,      KC_EQUALS,      0x3d, GSP_END,
     90
    7091        0,      KC_BACKSPACE,   0x08, GSP_END,
    7192
     
    203224        0,      KC_RIGHT,       0x1b, 0x5b, 0x43, GSP_END,
    204225
     226        /*
     227         * Sequences specific to Gnome terminal
     228         */
     229        0,      KC_BACKSPACE,   0x7f, GSP_END, /* ASCII DEL */
     230        0,      KC_HOME,        0x1b, 0x4f, 0x48, GSP_END,
     231        0,      KC_END,         0x1b, 0x4f, 0x46, GSP_END,
     232
    205233        0,      0
    206234};
    207235
    208 int kbd_ctl_init(void)
     236static int stty_ctl_init(kbd_dev_t *kdev)
    209237{
     238        kbd_dev = kdev;
    210239        ds = 0;
    211240
     
    214243}
    215244
    216 void kbd_ctl_parse_scancode(int scancode)
     245static void stty_ctl_parse(sysarg_t scancode)
    217246{
    218247        unsigned mods, key;
     
    220249        ds = gsp_step(&sp, ds, scancode, &mods, &key);
    221250        if (key != 0) {
    222                 stroke_sim(mods, key);
     251                stroke_sim(kbd_dev, mods, key);
    223252        }
    224253}
    225254
    226 void kbd_ctl_set_ind(unsigned mods)
     255static void stty_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    227256{
    228257        (void) mods;
  • uspace/srv/hid/input/ctl/sun.c

    rd2c67e7 r8ff0bd2  
    11/*
    22 * Copyright (c) 2006 Jakub Jermar
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    2829
    2930/** @addtogroup kbd_ctl
    30  * @ingroup kbd
     31 * @ingroup input
    3132 * @{
    3233 */
    3334/**
    3435 * @file
    35  * @brief       Sun keyboard controller driver.
     36 * @brief Sun keyboard controller driver.
    3637 */
    3738
     
    4041#include <io/keycode.h>
    4142#include <kbd_ctl.h>
     43#include <kbd_port.h>
     44
     45static void sun_ctl_parse(sysarg_t);
     46static int sun_ctl_init(kbd_dev_t *);
     47static void sun_ctl_set_ind(kbd_dev_t *, unsigned int);
     48
     49kbd_ctl_ops_t sun_ctl = {
     50        .parse = sun_ctl_parse,
     51        .init = sun_ctl_init,
     52        .set_ind = sun_ctl_set_ind
     53};
     54
     55static kbd_dev_t *kbd_dev;
    4256
    4357#define KBD_KEY_RELEASE         0x80
     
    4660static int scanmap_simple[];
    4761
    48 int kbd_ctl_init(void)
     62static int sun_ctl_init(kbd_dev_t *kdev)
    4963{
     64        kbd_dev = kdev;
    5065        return 0;
    5166}
    5267
    53 void kbd_ctl_parse_scancode(int scancode)
     68static void sun_ctl_parse(sysarg_t scancode)
    5469{
    5570        kbd_event_type_t type;
    5671        unsigned int key;
    5772
    58         if (scancode < 0 || scancode >= 0x100)
     73        if (scancode >= 0x100)
    5974                return;
    6075
     
    7186        key = scanmap_simple[scancode];
    7287        if (key != 0)
    73                 kbd_push_ev(type, key);
     88                kbd_push_event(kbd_dev, type, key);
    7489}
    7590
    76 void kbd_ctl_set_ind(unsigned mods)
     91static void sun_ctl_set_ind(kbd_dev_t *kdev, unsigned mods)
    7792{
    7893        (void) mods;
  • uspace/srv/hid/input/generic/gsp.c

    rd2c67e7 r8ff0bd2  
    2929/**
    3030 * @addtogroup kbdgen generic
    31  * @ingroup  kbd
     31 * @ingroup  input
    3232 * @{
    3333 */
     
    104104                if (key == 0) break;
    105105
    106                 /* Insert one sequence. */             
     106                /* Insert one sequence. */
    107107                rc = gsp_insert_seq(p, dp, mods, key);
    108108                if (rc != 0)
     
    197197
    198198        if (t == NULL) {
    199                 printf("gsp_step: not found\n");
     199                printf("gsp_step: not found, state=%d, input=0x%x\n",
     200                    state, input);
    200201                *mods = 0;
    201202                *key = 0;
     
    205206        *mods = t->out_mods;
    206207        *key = t->out_key;
     208
    207209        return t->new_state;
    208210}
  • uspace/srv/hid/input/generic/stroke.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbd
     29/** @addtogroup input
    3030 * @{
    3131 */
     
    5252
    5353/** Simulate keystroke using sequences of key presses and releases. */
    54 void stroke_sim(unsigned mod, unsigned key)
     54void stroke_sim(kbd_dev_t *kdev, unsigned mod, unsigned key)
    5555{
    5656        int i;
     
    6060        while (mods_keys[i][0] != 0) {
    6161                if (mod & mods_keys[i][0]) {
    62                         kbd_push_ev(KEY_PRESS, mods_keys[i][1]);
     62                        kbd_push_event(kdev, KEY_PRESS, mods_keys[i][1]);
    6363                }
    6464                ++i;
     
    6767        /* Simulate key press and release. */
    6868        if (key != 0) {
    69                 kbd_push_ev(KEY_PRESS, key);
    70                 kbd_push_ev(KEY_RELEASE, key);
     69                kbd_push_event(kdev, KEY_PRESS, key);
     70                kbd_push_event(kdev, KEY_RELEASE, key);
    7171        }
    7272
     
    7575        while (mods_keys[i][0] != 0) {
    7676                if (mod & mods_keys[i][0]) {
    77                         kbd_push_ev(KEY_RELEASE, mods_keys[i][1]);
     77                        kbd_push_event(kdev, KEY_RELEASE, mods_keys[i][1]);
    7878                }
    7979                ++i;
  • uspace/srv/hid/input/include/gsp.h

    rd2c67e7 r8ff0bd2  
    2727 */
    2828
    29 /** @addtogroup kbdgen generic
     29/** @addtogroup inputgen generic
    3030 * @brief       Generic scancode parser.
    31  * @ingroup  kbd
     31 * @ingroup  input
    3232 * @{
    33  */ 
     33 */
    3434/** @file
    3535 */
  • uspace/srv/hid/input/include/input.h

    rd2c67e7 r8ff0bd2  
    11/*
    22 * Copyright (c) 2006 Josef Cejka
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    2728 */
    2829
    29 /** @addtogroup kbdgen generic
    30  * @brief HelenOS generic uspace keyboard handler.
    31  * @ingroup kbd
     30/** @addtogroup inputgen generic
     31 * @brief HelenOS input server.
     32 * @ingroup input
    3233 * @{
    3334 */
     
    3536 */
    3637
    37 #ifndef KBD_KBD_H_
    38 #define KBD_KBD_H_
     38#ifndef INPUT_H_
     39#define INPUT_H_
    3940
    4041#include <bool.h>
    4142
     43#define NAME       "input"
     44#define NAMESPACE  "hid"
     45
    4246extern bool irc_service;
    4347extern int irc_phone;
    44 
    45 extern void kbd_push_scancode(int);
    46 extern void kbd_push_ev(int, unsigned int);
    4748
    4849#endif
  • uspace/srv/hid/input/include/kbd_ctl.h

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbdgen generic
    30  * @brief       HelenOS generic uspace keyboard handler.
    31  * @ingroup  kbd
     29/** @addtogroup inputgen generic
     30 * @brief Keyboard controller driver interface.
     31 * @ingroup input
    3232 * @{
    33  */ 
     33 */
    3434/** @file
    3535 */
     
    3838#define KBD_CTL_H_
    3939
    40 extern void kbd_ctl_parse_scancode(int);
    41 extern int kbd_ctl_init(void);
    42 extern void kbd_ctl_set_ind(unsigned);
     40#include <kbd_port.h>
     41
     42struct kbd_dev;
     43
     44typedef struct kbd_ctl_ops {
     45        void (*parse)(sysarg_t);
     46        int (*init)(struct kbd_dev *);
     47        void (*set_ind)(struct kbd_dev *, unsigned int);
     48} kbd_ctl_ops_t;
     49
     50extern kbd_ctl_ops_t apple_ctl;
     51extern kbd_ctl_ops_t gxe_fb_ctl;
     52extern kbd_ctl_ops_t kbdev_ctl;
     53extern kbd_ctl_ops_t pc_ctl;
     54extern kbd_ctl_ops_t stty_ctl;
     55extern kbd_ctl_ops_t sun_ctl;
    4356
    4457#endif
     
    4659/**
    4760 * @}
    48  */
    49 
     61 */
  • uspace/srv/hid/input/include/mouse_port.h

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
    30  * @brief
     29/** @addtogroup inputgen generic
     30 * @brief Mouse port driver interface.
     31 * @ingroup input
    3132 * @{
    3233 */
     
    3940#include <sys/types.h>
    4041
    41 extern int mouse_port_init(void);
    42 extern void mouse_port_yield(void);
    43 extern void mouse_port_reclaim(void);
    44 extern void mouse_port_write(uint8_t);
     42struct mouse_dev;
     43
     44typedef struct mouse_port_ops {
     45        int (*init)(struct mouse_dev *);
     46        void (*yield)(void);
     47        void (*reclaim)(void);
     48        void (*write)(uint8_t);
     49} mouse_port_ops_t;
     50
     51extern mouse_port_ops_t adb_mouse_port;
     52extern mouse_port_ops_t chardev_mouse_port;
    4553
    4654#endif
     
    4856/**
    4957 * @}
    50  */
    51 
     58 */
  • uspace/srv/hid/input/include/mouse_proto.h

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
    30  * @brief
     29/** @addtogroup inputgen generic
     30 * @brief Mouse protocol driver interface.
     31 * @ingroup input
    3132 * @{
    3233 */
     
    3738#define MOUSE_PROTO_H_
    3839
    39 extern void mouse_proto_parse_byte(int);
    40 extern int mouse_proto_init(void);
     40#include <mouse_port.h>
     41
     42struct mouse_dev;
     43
     44typedef struct mouse_proto_ops {
     45        void (*parse)(sysarg_t);
     46        int (*init)(struct mouse_dev *);
     47} mouse_proto_ops_t;
     48
     49extern mouse_proto_ops_t adb_proto;
     50extern mouse_proto_ops_t ps2_proto;
     51extern mouse_proto_ops_t mousedev_proto;
    4152
    4253#endif
  • uspace/srv/hid/input/include/stroke.h

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbdgen generic
     29/** @addtogroup inputgen generic
    3030 * @brief       Generic scancode parser.
    31  * @ingroup  kbd
     31 * @ingroup  input
    3232 * @{
    3333 */
     
    3838#define KBD_STROKE_H_
    3939
    40 extern void stroke_sim(unsigned, unsigned);
     40#include <kbd.h>
     41
     42extern void stroke_sim(kbd_dev_t *, unsigned, unsigned);
    4143
    4244#endif
  • uspace/srv/hid/input/layout/cz.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbd
     29/** @addtogroup input
    3030 * @brief Czech QWERTZ layout.
    3131 * @{
    3232 */
    3333
    34 #include <kbd.h>
     34#include <errno.h>
     35#include <input.h>
    3536#include <io/console.h>
    3637#include <io/keycode.h>
    3738#include <bool.h>
    3839#include <layout.h>
    39 
    40 static void layout_reset(void);
    41 static wchar_t layout_parse_ev(kbd_event_t *ev);
     40#include <stdlib.h>
     41
     42static int cz_create(layout_t *);
     43static void cz_destroy(layout_t *);
     44static wchar_t cz_parse_ev(layout_t *, kbd_event_t *ev);
    4245
    4346enum m_state {
     
    4750};
    4851
    49 static enum m_state mstate;
    50 
    51 layout_op_t cz_op = {
    52         layout_reset,
    53         layout_parse_ev
     52typedef struct {
     53        enum m_state mstate;
     54} layout_cz_t;
     55
     56layout_ops_t cz_ops = {
     57        .create = cz_create,
     58        .destroy = cz_destroy,
     59        .parse_ev = cz_parse_ev
    5460};
    5561
     
    273279}
    274280
    275 static wchar_t parse_ms_hacek(kbd_event_t *ev)
     281static wchar_t parse_ms_hacek(layout_cz_t *cz_state, kbd_event_t *ev)
    276282{
    277283        wchar_t c;
    278284
    279         mstate = ms_start;
     285        cz_state->mstate = ms_start;
    280286
    281287        /* Produce no characters when Ctrl or Alt is pressed. */
     
    291297}
    292298
    293 static wchar_t parse_ms_carka(kbd_event_t *ev)
     299static wchar_t parse_ms_carka(layout_cz_t *cz_state, kbd_event_t *ev)
    294300{
    295301        wchar_t c;
    296302
    297         mstate = ms_start;
     303        cz_state->mstate = ms_start;
    298304
    299305        /* Produce no characters when Ctrl or Alt is pressed. */
     
    309315}
    310316
    311 static wchar_t parse_ms_start(kbd_event_t *ev)
     317static wchar_t parse_ms_start(layout_cz_t *cz_state, kbd_event_t *ev)
    312318{
    313319        wchar_t c;
     
    319325        if (ev->key == KC_EQUALS) {
    320326                if ((ev->mods & KM_SHIFT) != 0)
    321                         mstate = ms_hacek;
     327                        cz_state->mstate = ms_hacek;
    322328                else
    323                         mstate = ms_carka;
     329                        cz_state->mstate = ms_carka;
    324330
    325331                return 0;
     
    379385}
    380386
    381 static void layout_reset(void)
    382 {
    383         mstate = ms_start;
    384 }
    385 
    386 static wchar_t layout_parse_ev(kbd_event_t *ev)
    387 {
     387static int cz_create(layout_t *state)
     388{
     389        layout_cz_t *cz_state;
     390
     391        cz_state = malloc(sizeof(layout_cz_t));
     392        if (cz_state == NULL) {
     393                printf("%s: Out of memory.\n", NAME);
     394                return ENOMEM;
     395        }
     396
     397        cz_state->mstate = ms_start;
     398        state->layout_priv = (void *) cz_state;
     399
     400        return EOK;
     401}
     402
     403static void cz_destroy(layout_t *state)
     404{
     405        free(state->layout_priv);
     406}
     407
     408static wchar_t cz_parse_ev(layout_t *state, kbd_event_t *ev)
     409{
     410        layout_cz_t *cz_state = (layout_cz_t *) state->layout_priv;
     411
    388412        if (ev->type != KEY_PRESS)
    389413                return 0;
     
    392416                return 0;
    393417       
    394         switch (mstate) {
     418        switch (cz_state->mstate) {
    395419        case ms_start:
    396                 return parse_ms_start(ev);
     420                return parse_ms_start(cz_state, ev);
    397421        case ms_hacek:
    398                 return parse_ms_hacek(ev);
     422                return parse_ms_hacek(cz_state, ev);
    399423        case ms_carka:
    400                 return parse_ms_carka(ev);
     424                return parse_ms_carka(cz_state, ev);
    401425        }
    402426       
  • uspace/srv/hid/input/layout/us_dvorak.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbd
     29/** @addtogroup input
    3030 * @brief US Dvorak Simplified Keyboard layout.
    3131 * @{
    3232 */
    3333
     34#include <errno.h>
    3435#include <kbd.h>
    3536#include <io/console.h>
     
    3738#include <layout.h>
    3839
    39 static void layout_reset(void);
    40 static wchar_t layout_parse_ev(kbd_event_t *ev);
    41 
    42 layout_op_t us_dvorak_op = {
    43         layout_reset,
    44         layout_parse_ev
     40static int us_dvorak_create(layout_t *);
     41static void us_dvorak_destroy(layout_t *);
     42static wchar_t us_dvorak_parse_ev(layout_t *, kbd_event_t *ev);
     43
     44layout_ops_t us_dvorak_ops = {
     45        .create = us_dvorak_create,
     46        .destroy = us_dvorak_destroy,
     47        .parse_ev = us_dvorak_parse_ev
    4548};
    4649
     
    206209}
    207210
    208 static void layout_reset(void)
    209 {
    210 }
    211 
    212 static wchar_t layout_parse_ev(kbd_event_t *ev)
     211static int us_dvorak_create(layout_t *state)
     212{
     213        return EOK;
     214}
     215
     216static void us_dvorak_destroy(layout_t *state)
     217{
     218}
     219
     220static wchar_t us_dvorak_parse_ev(layout_t *state, kbd_event_t *ev)
    213221{
    214222        wchar_t c;
  • uspace/srv/hid/input/layout/us_qwerty.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup kbd
     29/** @addtogroup input
    3030 * @brief       US QWERTY layout.
    3131 * @{
    32  */
    33 
     32 */
     33
     34#include <errno.h>
    3435#include <kbd.h>
    3536#include <io/console.h>
     
    3738#include <layout.h>
    3839
    39 static void layout_reset(void);
    40 static wchar_t layout_parse_ev(kbd_event_t *ev);
    41 
    42 layout_op_t us_qwerty_op = {
    43         layout_reset,
    44         layout_parse_ev
     40static int us_qwerty_create(layout_t *);
     41static void us_qwerty_destroy(layout_t *);
     42static wchar_t us_qwerty_parse_ev(layout_t *, kbd_event_t *ev);
     43
     44layout_ops_t us_qwerty_ops = {
     45        .create = us_qwerty_create,
     46        .destroy = us_qwerty_destroy,
     47        .parse_ev = us_qwerty_parse_ev
    4548};
    4649
     
    200203}
    201204
    202 static void layout_reset(void)
    203 {
    204 }
    205 
    206 static wchar_t layout_parse_ev(kbd_event_t *ev)
     205static int us_qwerty_create(layout_t *state)
     206{
     207        return EOK;
     208}
     209
     210static void us_qwerty_destroy(layout_t *state)
     211{
     212}
     213
     214static wchar_t us_qwerty_parse_ev(layout_t *state, kbd_event_t *ev)
    207215{
    208216        wchar_t c;
  • uspace/srv/hid/input/port/adb.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3737#include <ipc/adb.h>
    3838#include <async.h>
    39 #include <async_obsolete.h>
     39#include <input.h>
    4040#include <kbd_port.h>
    4141#include <kbd.h>
     
    4343#include <fcntl.h>
    4444#include <errno.h>
    45 #include <devmap.h>
    46 #include <devmap_obsolete.h>
     45#include <loc.h>
    4746
    48 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall);
     47static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    4948static void adb_kbd_reg0_data(uint16_t data);
    5049
    51 static int dev_phone;
     50static int adb_port_init(kbd_dev_t *);
     51static void adb_port_yield(void);
     52static void adb_port_reclaim(void);
     53static void adb_port_write(uint8_t data);
    5254
    53 #define NAME "kbd"
     55kbd_port_ops_t adb_port = {
     56        .init = adb_port_init,
     57        .yield = adb_port_yield,
     58        .reclaim = adb_port_reclaim,
     59        .write = adb_port_write
     60};
    5461
    55 int kbd_port_init(void)
     62static kbd_dev_t *kbd_dev;
     63static async_sess_t *dev_sess;
     64
     65static int adb_port_init(kbd_dev_t *kdev)
    5666{
    5767        const char *dev = "adb/kbd";
    58         devmap_handle_t handle;
     68        service_id_t service_id;
     69        async_exch_t *exch;
     70        int rc;
    5971       
    60         int rc = devmap_device_get_handle(dev, &handle, 0);
    61         if (rc == EOK) {
    62                 dev_phone = devmap_obsolete_device_connect(handle, 0);
    63                 if (dev_phone < 0) {
    64                         printf("%s: Failed to connect to device\n", NAME);
    65                         return dev_phone;
    66                 }
    67         } else
     72        kbd_dev = kdev;
     73       
     74        rc = loc_service_get_id(dev, &service_id, 0);
     75        if (rc != EOK)
    6876                return rc;
    6977       
     78        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
     79        if (dev_sess == NULL) {
     80                printf("%s: Failed to connect to device\n", NAME);
     81                return ENOENT;
     82        }
     83       
     84        exch = async_exchange_begin(dev_sess);
     85        if (exch == NULL) {
     86                printf("%s: Failed starting exchange with device\n", NAME);
     87                async_hangup(dev_sess);
     88                return ENOMEM;
     89        }
     90       
    7091        /* NB: The callback connection is slotted for removal */
    71         rc = async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events);
     92        rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
     93        async_exchange_end(exch);
    7294        if (rc != EOK) {
    73                 printf(NAME ": Failed to create callback from device\n");
     95                printf("%s: Failed to create callback from device\n", NAME);
     96                async_hangup(dev_sess);
    7497                return rc;
    7598        }
     
    78101}
    79102
    80 void kbd_port_yield(void)
     103static void adb_port_yield(void)
    81104{
    82105}
    83106
    84 void kbd_port_reclaim(void)
     107static void adb_port_reclaim(void)
    85108{
    86109}
    87110
    88 void kbd_port_write(uint8_t data)
     111static void adb_port_write(uint8_t data)
    89112{
    90113        /*async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);*/
    91114}
    92115
    93 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall)
     116static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    94117{
    95118        /* Ignore parameters, the connection is already opened */
     
    119142static void adb_kbd_reg0_data(uint16_t data)
    120143{
    121         uint8_t b0, b1;
    122 
    123         b0 = (data >> 8) & 0xff;
    124         b1 = data & 0xff;
    125 
     144        uint8_t b0 = (data >> 8) & 0xff;
     145        uint8_t b1 = data & 0xff;
     146       
    126147        if (b0 != 0xff)
    127                 kbd_push_scancode(b0);
     148                kbd_push_data(kbd_dev, b0);
     149       
    128150        if (b1 != 0xff)
    129                 kbd_push_scancode(b1);
     151                kbd_push_data(kbd_dev, b1);
    130152}
    131153
  • uspace/srv/hid/input/port/adb_mouse.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
     29/** @addtogroup mouse_port
     30 * @ingroup mouse
    3031 * @{
    31  */ 
     32 */
    3233/** @file
    33  * @brief
     34 * @brief ADB mouse port driver.
    3435 */
    3536
    36 #include <ipc/char.h>
     37#include <ipc/adb.h>
    3738#include <async.h>
    38 #include <async_obsolete.h>
    39 #include <vfs/vfs.h>
    40 #include <fcntl.h>
     39#include <input.h>
     40#include <mouse_port.h>
     41#include <mouse.h>
    4142#include <errno.h>
    42 #include <devmap.h>
    43 #include <devmap_obsolete.h>
    44 #include <char_mouse.h>
    45 #include <mouse_port.h>
     43#include <loc.h>
     44#include <stdio.h>
    4645
    47 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall);
     46static mouse_dev_t *mouse_dev;
     47static async_sess_t *dev_sess;
    4848
    49 static int dev_phone;
    50 
    51 #define NAME "char_mouse"
    52 
    53 int mouse_port_init(void)
    54 {
    55         devmap_handle_t handle;
    56         int rc = devmap_device_get_handle("char/ps2b", &handle,
    57             IPC_FLAG_BLOCKING);
    58        
    59         if (rc != EOK) {
    60                 printf("%s: Failed resolving PS/2\n", NAME);
    61                 return rc;
    62         }
    63        
    64         dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING);
    65         if (dev_phone < 0) {
    66                 printf("%s: Failed connecting to PS/2\n", NAME);
    67                 return ENOENT;
    68         }
    69        
    70         /* NB: The callback connection is slotted for removal */
    71         if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, chardev_events) != 0) {
    72                 printf(NAME ": Failed to create callback from device\n");
    73                 return false;
    74         }
    75        
    76         return 0;
    77 }
    78 
    79 void mouse_port_yield(void)
    80 {
    81 }
    82 
    83 void mouse_port_reclaim(void)
    84 {
    85 }
    86 
    87 void mouse_port_write(uint8_t data)
    88 {
    89         async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
    90 }
    91 
    92 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall)
     49static void mouse_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    9350{
    9451        /* Ignore parameters, the connection is already opened */
    9552        while (true) {
    96 
    9753                ipc_call_t call;
    9854                ipc_callid_t callid = async_get_call(&call);
    99 
     55               
    10056                int retval;
    10157               
     
    10460                        return;
    10561                }
    106 
     62               
    10763                switch (IPC_GET_IMETHOD(call)) {
    108                 case IPC_FIRST_USER_METHOD:
    109                         mouse_handle_byte(IPC_GET_ARG1(call));
     64                case ADB_REG_NOTIF:
     65                        mouse_push_data(mouse_dev, IPC_GET_ARG1(call));
    11066                        break;
    11167                default:
    11268                        retval = ENOENT;
    11369                }
     70               
    11471                async_answer_0(callid, retval);
    11572        }
    11673}
    11774
     75static int adb_port_init(mouse_dev_t *mdev)
     76{
     77        const char *dev = "adb/mouse";
     78       
     79        mouse_dev = mdev;
     80       
     81        service_id_t service_id;
     82        int rc = loc_service_get_id(dev, &service_id, 0);
     83        if (rc != EOK)
     84                return rc;
     85       
     86        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id, 0);
     87        if (dev_sess == NULL) {
     88                printf("%s: Failed to connect to device\n", NAME);
     89                return ENOENT;
     90        }
     91       
     92        async_exch_t *exch = async_exchange_begin(dev_sess);
     93        if (exch == NULL) {
     94                printf("%s: Failed starting exchange with device\n", NAME);
     95                async_hangup(dev_sess);
     96                return ENOMEM;
     97        }
     98       
     99        /* NB: The callback connection is slotted for removal */
     100        rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL);
     101        async_exchange_end(exch);
     102        if (rc != EOK) {
     103                printf("%s: Failed to create callback from device\n", NAME);
     104                async_hangup(dev_sess);
     105                return rc;
     106        }
     107       
     108        return EOK;
     109}
     110
     111static void adb_port_yield(void)
     112{
     113}
     114
     115static void adb_port_reclaim(void)
     116{
     117}
     118
     119static void adb_port_write(uint8_t data)
     120{
     121}
     122
     123mouse_port_ops_t adb_mouse_port = {
     124        .init = adb_port_init,
     125        .yield = adb_port_yield,
     126        .reclaim = adb_port_reclaim,
     127        .write = adb_port_write
     128};
     129
    118130/**
    119131 * @}
  • uspace/srv/hid/input/port/chardev.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2009 Jiri Svoboda
     2 * Copyright (c) 2011 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3737#include <ipc/char.h>
    3838#include <async.h>
    39 #include <async_obsolete.h>
     39#include <input.h>
    4040#include <kbd_port.h>
    4141#include <kbd.h>
    42 #include <devmap.h>
    43 #include <devmap_obsolete.h>
     42#include <loc.h>
    4443#include <errno.h>
    4544#include <stdio.h>
    4645
    47 #define NAME  "kbd/chardev"
     46static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    4847
    49 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall);
     48static int chardev_port_init(kbd_dev_t *);
     49static void chardev_port_yield(void);
     50static void chardev_port_reclaim(void);
     51static void chardev_port_write(uint8_t data);
    5052
    51 static int dev_phone;
     53kbd_port_ops_t chardev_port = {
     54        .init = chardev_port_init,
     55        .yield = chardev_port_yield,
     56        .reclaim = chardev_port_reclaim,
     57        .write = chardev_port_write
     58};
     59
     60static kbd_dev_t *kbd_dev;
     61static async_sess_t *dev_sess;
    5262
    5363/** List of devices to try connecting to. */
     
    5969static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);
    6070
    61 int kbd_port_init(void)
     71static int chardev_port_init(kbd_dev_t *kdev)
    6272{
    63         devmap_handle_t handle;
     73        service_id_t service_id;
     74        async_exch_t *exch;
    6475        unsigned int i;
    6576        int rc;
    6677       
     78        kbd_dev = kdev;
     79       
    6780        for (i = 0; i < num_devs; i++) {
    68                 rc = devmap_device_get_handle(in_devs[i], &handle, 0);
     81                rc = loc_service_get_id(in_devs[i], &service_id, 0);
    6982                if (rc == EOK)
    7083                        break;
     
    7689        }
    7790       
    78         dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING);
    79         if (dev_phone < 0) {
     91        dev_sess = loc_service_connect(EXCHANGE_ATOMIC, service_id,
     92            IPC_FLAG_BLOCKING);
     93        if (dev_sess == NULL) {
    8094                printf("%s: Failed connecting to device\n", NAME);
    8195                return ENOENT;
    8296        }
    8397       
     98        exch = async_exchange_begin(dev_sess);
     99        if (exch == NULL) {
     100                printf("%s: Failed starting exchange with device\n", NAME);
     101                async_hangup(dev_sess);
     102                return ENOMEM;
     103        }
     104       
    84105        /* NB: The callback connection is slotted for removal */
    85         if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
    86                 printf(NAME ": Failed to create callback from device\n");
     106        rc = async_connect_to_me(exch, 0, 0, 0, kbd_port_events, NULL);
     107        async_exchange_end(exch);
     108       
     109        if (rc != 0) {
     110                printf("%s: Failed to create callback from device\n", NAME);
     111                async_hangup(dev_sess);
    87112                return -1;
    88113        }
    89 
     114       
    90115        return 0;
    91116}
    92117
    93 void kbd_port_yield(void)
     118static void chardev_port_yield(void)
    94119{
    95120}
    96121
    97 void kbd_port_reclaim(void)
     122static void chardev_port_reclaim(void)
    98123{
    99124}
    100125
    101 void kbd_port_write(uint8_t data)
     126static void chardev_port_write(uint8_t data)
    102127{
    103         async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
     128        async_exch_t *exch = async_exchange_begin(dev_sess);
     129        if (exch == NULL) {
     130                printf("%s: Failed starting exchange with device\n", NAME);
     131                return;
     132        }
     133
     134        async_msg_1(exch, CHAR_WRITE_BYTE, data);
     135        async_exchange_end(exch);
    104136}
    105137
    106 static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall)
     138static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    107139{
    108140        /* Ignore parameters, the connection is already opened */
     
    121153                switch (IPC_GET_IMETHOD(call)) {
    122154                case CHAR_NOTIF_BYTE:
    123                         kbd_push_scancode(IPC_GET_ARG1(call));
     155                        kbd_push_data(kbd_dev, IPC_GET_ARG1(call));
    124156                        break;
    125157                default:
  • uspace/srv/hid/input/port/gxemul.c

    rd2c67e7 r8ff0bd2  
    11/*
    22 * Copyright (c) 2007 Michal Kebrt
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4243#include <errno.h>
    4344
     45static int gxemul_port_init(kbd_dev_t *);
     46static void gxemul_port_yield(void);
     47static void gxemul_port_reclaim(void);
     48static void gxemul_port_write(uint8_t data);
     49
     50kbd_port_ops_t gxemul_port = {
     51        .init = gxemul_port_init,
     52        .yield = gxemul_port_yield,
     53        .reclaim = gxemul_port_reclaim,
     54        .write = gxemul_port_write
     55};
     56
     57static kbd_dev_t *kbd_dev;
     58
    4459static irq_cmd_t gxemul_cmds[] = {
    4560        {
     
    6176
    6277/** Initializes keyboard handler. */
    63 int kbd_port_init(void)
     78static int gxemul_port_init(kbd_dev_t *kdev)
    6479{
     80        kbd_dev = kdev;
     81       
    6582        sysarg_t addr;
    6683        if (sysinfo_get_value("kbd.address.virtual", &addr) != EOK)
     
    7794}
    7895
    79 void kbd_port_yield(void)
     96static void gxemul_port_yield(void)
    8097{
    8198}
    8299
    83 void kbd_port_reclaim(void)
     100static void gxemul_port_reclaim(void)
    84101{
    85102}
    86103
    87 void kbd_port_write(uint8_t data)
     104static void gxemul_port_write(uint8_t data)
    88105{
    89106        (void) data;
     
    91108
    92109/** Process data sent when a key is pressed.
    93  * 
    94  *  @param keybuffer Buffer of pressed keys.
    95  *  @param call      IPC call.
    96110 *
    97  *  @return Always 1.
     111 * @param keybuffer Buffer of pressed keys.
     112 * @param call      IPC call.
     113 *
    98114 */
    99115static void gxemul_irq_handler(ipc_callid_t iid, ipc_call_t *call)
    100116{
    101         int scan_code = IPC_GET_ARG2(*call);
    102 
    103         kbd_push_scancode(scan_code);
     117        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    104118}
    105119
  • uspace/srv/hid/input/port/msim.c

    rd2c67e7 r8ff0bd2  
    11/*
    22 * Copyright (c) 2006 Josef Cejka
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4243#include <errno.h>
    4344
    44 irq_cmd_t msim_cmds[] = {
     45static int msim_port_init(kbd_dev_t *);
     46static void msim_port_yield(void);
     47static void msim_port_reclaim(void);
     48static void msim_port_write(uint8_t data);
     49
     50kbd_port_ops_t msim_port = {
     51        .init = msim_port_init,
     52        .yield = msim_port_yield,
     53        .reclaim = msim_port_reclaim,
     54        .write = msim_port_write
     55};
     56
     57static kbd_dev_t *kbd_dev;
     58
     59static irq_cmd_t msim_cmds[] = {
    4560        {
    4661                .cmd = CMD_PIO_READ_8,
     
    5166                .cmd = CMD_ACCEPT
    5267        }
    53        
    5468};
    5569
    56 irq_code_t msim_kbd = {
     70static irq_code_t msim_kbd = {
    5771        sizeof(msim_cmds) / sizeof(irq_cmd_t),
    5872        msim_cmds
     
    6175static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    6276
    63 int kbd_port_init(void)
     77static int msim_port_init(kbd_dev_t *kdev)
    6478{
     79        kbd_dev = kdev;
     80
    6581        sysarg_t vaddr;
    6682        if (sysinfo_get_value("kbd.address.virtual", &vaddr) != EOK)
     
    7894}
    7995
    80 void kbd_port_yield(void)
     96static void msim_port_yield(void)
    8197{
    8298}
    8399
    84 void kbd_port_reclaim(void)
     100static void msim_port_reclaim(void)
    85101{
    86102}
    87103
    88 void kbd_port_write(uint8_t data)
     104static void msim_port_write(uint8_t data)
    89105{
    90106        (void) data;
     
    93109static void msim_irq_handler(ipc_callid_t iid, ipc_call_t *call)
    94110{
    95         int scan_code = IPC_GET_ARG2(*call);
    96         kbd_push_scancode(scan_code);
     111        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    97112}
    98113
    99114/** @}
    100 */
     115 */
  • uspace/srv/hid/input/port/niagara.c

    rd2c67e7 r8ff0bd2  
    11/*
    22 * Copyright (c) 2008 Pavel Rimsky
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4647#include <errno.h>
    4748
     49static int niagara_port_init(kbd_dev_t *);
     50static void niagara_port_yield(void);
     51static void niagara_port_reclaim(void);
     52static void niagara_port_write(uint8_t data);
     53
     54kbd_port_ops_t niagara_port = {
     55        .init = niagara_port_init,
     56        .yield = niagara_port_yield,
     57        .reclaim = niagara_port_reclaim,
     58        .write = niagara_port_write
     59};
     60
     61static kbd_dev_t *kbd_dev;
     62
    4863#define POLL_INTERVAL  10000
    4964
     
    7085
    7186/* virtual address of the shared buffer */
    72 input_buffer_t input_buffer;
     87static input_buffer_t input_buffer;
    7388
    7489static volatile bool polling_disabled = false;
     
    7994 * Maps the shared buffer and creates the polling thread.
    8095 */
    81 int kbd_port_init(void)
     96static int niagara_port_init(kbd_dev_t *kdev)
    8297{
     98        kbd_dev = kdev;
     99       
    83100        sysarg_t paddr;
    84101        if (sysinfo_get_value("niagara.inbuf.address", &paddr) != EOK)
     
    105122}
    106123
    107 void kbd_port_yield(void)
     124static void niagara_port_yield(void)
    108125{
    109126        polling_disabled = true;
    110127}
    111128
    112 void kbd_port_reclaim(void)
     129static void niagara_port_reclaim(void)
    113130{
    114131        polling_disabled = false;
    115132}
    116133
    117 void kbd_port_write(uint8_t data)
     134static void niagara_port_write(uint8_t data)
    118135{
    119136        (void) data;
     
    131148                c = input_buffer->data[input_buffer->read_ptr];
    132149                input_buffer->read_ptr =
    133                         ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE;
    134                 kbd_push_scancode(c);
     150                    ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE;
     151                kbd_push_data(kbd_dev, c);
    135152        }
    136153}
    137154
    138155/**
    139  * Thread to poll SGCN for keypresses.
     156 * Thread to poll Niagara console for keypresses.
    140157 */
    141158static void niagara_thread_impl(void *arg)
  • uspace/srv/hid/input/port/ns16550.c

    rd2c67e7 r8ff0bd2  
    11/*
    22 * Copyright (c) 2006 Josef Cejka
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    3940#include <async_obsolete.h>
    4041#include <sysinfo.h>
     42#include <input.h>
    4143#include <kbd.h>
    4244#include <kbd_port.h>
    43 #include <sun.h>
    4445#include <ddi.h>
    4546#include <errno.h>
     47
     48static int ns16550_port_init(kbd_dev_t *);
     49static void ns16550_port_yield(void);
     50static void ns16550_port_reclaim(void);
     51static void ns16550_port_write(uint8_t data);
     52
     53kbd_port_ops_t ns16550_port = {
     54        .init = ns16550_port_init,
     55        .yield = ns16550_port_yield,
     56        .reclaim = ns16550_port_reclaim,
     57        .write = ns16550_port_write
     58};
     59
     60static kbd_dev_t *kbd_dev;
    4661
    4762/* NS16550 registers */
     
    91106
    92107static uintptr_t ns16550_physical;
    93 static uintptr_t ns16550_kernel; 
     108static uintptr_t ns16550_kernel;
    94109
    95 int ns16550_port_init(void)
     110static kbd_dev_t *kbd_dev;
     111
     112static int ns16550_port_init(kbd_dev_t *kdev)
    96113{
    97114        void *vaddr;
    98 
     115       
     116        kbd_dev = kdev;
     117       
     118        sysarg_t ns16550;
     119        if (sysinfo_get_value("kbd.type.ns16550", &ns16550) != EOK)
     120                return -1;
     121        if (!ns16550)
     122                return -1;
     123       
    99124        if (sysinfo_get_value("kbd.address.physical", &ns16550_physical) != EOK)
    100125                return -1;
     
    116141}
    117142
     143static void ns16550_port_yield(void)
     144{
     145}
     146
     147static void ns16550_port_reclaim(void)
     148{
     149}
     150
     151static void ns16550_port_write(uint8_t data)
     152{
     153        (void) data;
     154}
     155
    118156static void ns16550_irq_handler(ipc_callid_t iid, ipc_call_t *call)
    119157{
    120         int scan_code = IPC_GET_ARG2(*call);
    121         kbd_push_scancode(scan_code);
     158        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    122159       
    123160        if (irc_service)
  • uspace/srv/hid/input/port/pl050.c

    rd2c67e7 r8ff0bd2  
    11/*
    22 * Copyright (c) 2009 Vineeth Pillai
     3 * Copyright (c) 2011 Jiri Svoboda
    34 * All rights reserved.
    45 *
     
    4647#include <errno.h>
    4748
     49static int pl050_port_init(kbd_dev_t *);
     50static void pl050_port_yield(void);
     51static void pl050_port_reclaim(void);
     52static void pl050_port_write(uint8_t data);
     53
     54kbd_port_ops_t pl050_port = {
     55        .init = pl050_port_init,
     56        .yield = pl050_port_yield,
     57        .reclaim = pl050_port_reclaim,
     58        .write = pl050_port_write
     59};
     60
     61static kbd_dev_t *kbd_dev;
     62
    4863#define PL050_STAT_RXFULL  (1 << 4)
    4964
     
    8297static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    8398
    84 int kbd_port_init(void)
     99static int pl050_port_init(kbd_dev_t *kdev)
    85100{
     101        kbd_dev = kdev;
     102       
    86103        sysarg_t addr;
    87104        if (sysinfo_get_value("kbd.address.status", &addr) != EOK)
     
    105122}
    106123
    107 void kbd_port_yield(void)
     124static void pl050_port_yield(void)
    108125{
    109126}
    110127
    111 void kbd_port_reclaim(void)
     128static void pl050_port_reclaim(void)
    112129{
    113130}
    114131
    115 void kbd_port_write(uint8_t data)
     132static void pl050_port_write(uint8_t data)
    116133{
    117134        (void) data;
     
    120137static void pl050_irq_handler(ipc_callid_t iid, ipc_call_t *call)
    121138{
    122         int scan_code = IPC_GET_ARG2(*call);
    123 
    124         kbd_push_scancode(scan_code);
    125         return;
     139        kbd_push_data(kbd_dev, IPC_GET_ARG2(*call));
    126140}
    127141
    128142/**
    129143 * @}
    130  */ 
     144 */
  • uspace/srv/hid/input/port/ski.c

    rd2c67e7 r8ff0bd2  
    11/*
    22 * Copyright (c) 2005 Jakub Jermar
    3  * Copyright (c) 2009 Jiri Svoboda
     3 * Copyright (c) 2011 Jiri Svoboda
    44 * All rights reserved.
    55 *
     
    4545#include <bool.h>
    4646
     47static int ski_port_init(kbd_dev_t *);
     48static void ski_port_yield(void);
     49static void ski_port_reclaim(void);
     50static void ski_port_write(uint8_t data);
     51
     52kbd_port_ops_t ski_port = {
     53        .init = ski_port_init,
     54        .yield = ski_port_yield,
     55        .reclaim = ski_port_reclaim,
     56        .write = ski_port_write
     57};
     58
     59static kbd_dev_t *kbd_dev;
     60
    4761#define SKI_GETCHAR             21
    4862
     
    5569
    5670/** Initialize Ski port driver. */
    57 int kbd_port_init(void)
     71static int ski_port_init(kbd_dev_t *kdev)
    5872{
    5973        thread_id_t tid;
    6074        int rc;
     75
     76        kbd_dev = kdev;
    6177
    6278        rc = thread_create(ski_thread_impl, NULL, "kbd_poll", &tid);
     
    6884}
    6985
    70 void kbd_port_yield(void)
     86static void ski_port_yield(void)
    7187{
    7288        polling_disabled = true;
    7389}
    7490
    75 void kbd_port_reclaim(void)
     91static void ski_port_reclaim(void)
    7692{
    7793        polling_disabled = false;
    7894}
    7995
    80 void kbd_port_write(uint8_t data)
     96static void ski_port_write(uint8_t data)
    8197{
    8298        (void) data;
     
    94110                        if (c == 0)
    95111                                break;
    96                         kbd_push_scancode(c);
     112                        kbd_push_data(kbd_dev, c);
    97113                }
    98114
     
    112128        uint64_t ch;
    113129       
     130#ifdef UARCH_ia64
    114131        asm volatile (
    115132                "mov r15 = %1\n"
     
    121138                : "r15", "r8"
    122139        );
    123 
     140#else
     141        ch = 0;
     142#endif
    124143        return (int32_t) ch;
    125144}
  • uspace/srv/hid/input/proto/ps2.c

    rd2c67e7 r8ff0bd2  
    11/*
    2  * Copyright (c) 2006 Ondrej Palkovsky
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
     29/** @addtogroup mouse_proto
     30 * @ingroup input
    3031 * @{
    3132 */
    3233/**
    3334 * @file
    34  * @brief PS/2 mouse protocol driver.
     35 * @brief PS/2 protocol driver.
    3536 */
    3637
    37 #include <stdio.h>
     38#include <mouse.h>
    3839#include <mouse_port.h>
    39 #include <char_mouse.h>
    4040#include <mouse_proto.h>
    41 
    42 #define BUFSIZE 3
    4341
    4442#define PS2_MOUSE_OUT_INIT  0xf4
    4543#define PS2_MOUSE_ACK       0xfa
     44
     45#define BUFSIZE 3
    4646
    4747typedef struct {
     
    4949                unsigned char data[BUFSIZE];
    5050                struct {
    51                         unsigned leftbtn : 1;
    52                         unsigned rightbtn : 1;
    53                         unsigned middlebtn : 1;
    54                         unsigned isone : 1; /* Always one */
    55                         unsigned xsign : 1;
    56                         unsigned ysign : 1;
    57                         unsigned xovfl : 1;
    58                         unsigned yovfl : 1;
     51                        unsigned int leftbtn : 1;
     52                        unsigned int rightbtn : 1;
     53                        unsigned int middlebtn : 1;
     54                        unsigned int isone : 1; /* Always one */
     55                        unsigned int xsign : 1;
     56                        unsigned int ysign : 1;
     57                        unsigned int xovfl : 1;
     58                        unsigned int yovfl : 1;
    5959                        unsigned char x;
    6060                        unsigned char y;
     
    6464
    6565static ps2packet_t buf;
    66 static int bufpos = 0;
    67 static int leftbtn = 0;
    68 static int rightbtn = 0;
    69 static int middlebtn = 0;
     66static unsigned int bufpos;
     67static unsigned int leftbtn;
     68static unsigned int rightbtn;
     69static unsigned int middlebtn;
    7070
    71 int mouse_proto_init(void)
     71static mouse_dev_t *mouse_dev;
     72
     73static int ps2_proto_init(mouse_dev_t *mdev)
    7274{
    73         mouse_port_write(PS2_MOUSE_OUT_INIT);
     75        mouse_dev = mdev;
     76        bufpos = 0;
     77        leftbtn = 0;
     78        rightbtn = 0;
     79       
     80        mouse_dev->port_ops->write(PS2_MOUSE_OUT_INIT);
    7481        return 0;
    7582}
     
    7986{
    8087        int tmp;
    81 
     88       
    8289        if (!sign)
    8390                return data;
    84 
    85         tmp = ((unsigned char)~data) + 1;
     91       
     92        tmp = ((unsigned char) ~data) + 1;
    8693        return -tmp;
    8794}
    8895
    8996/** Process mouse data */
    90 void mouse_proto_parse_byte(int data)
     97static void ps2_proto_parse(sysarg_t data)
    9198{
    9299        int x, y;
    93 
     100       
    94101        /* Check that we have not lost synchronization */
    95102        if (bufpos == 0 && !(data & 0x8))
    96103                return; /* Synchro lost, ignore byte */
    97 
     104       
    98105        buf.u.data[bufpos++] = data;
    99106        if (bufpos == BUFSIZE) {
    100107                bufpos = 0;
    101 
     108               
    102109                if (buf.u.val.leftbtn ^ leftbtn) {
    103110                        leftbtn = buf.u.val.leftbtn;
    104                         mouse_ev_btn(1, leftbtn);
     111                        mouse_push_event_button(mouse_dev, 1, leftbtn);
    105112                }
    106 
     113               
    107114                if (buf.u.val.rightbtn ^ rightbtn) {
    108115                        rightbtn = buf.u.val.rightbtn;
    109                         mouse_ev_btn(2, rightbtn);
     116                        mouse_push_event_button(mouse_dev, 2, rightbtn);
    110117                }
    111 
     118               
    112119                if (buf.u.val.middlebtn ^ middlebtn) {
    113120                        middlebtn = buf.u.val.middlebtn;
    114                         mouse_ev_btn(3, middlebtn);
     121                        mouse_push_event_button(mouse_dev, 3, middlebtn);
    115122                }
     123               
     124                x = bit9toint(buf.u.val.xsign, buf.u.val.x);
     125                y = -bit9toint(buf.u.val.ysign, buf.u.val.y);
     126               
     127                if (x != 0 || y != 0)
     128                        mouse_push_event_move(mouse_dev, x, y);
     129        }
     130}
    116131
    117                 x =   bit9toint(buf.u.val.xsign, buf.u.val.x);
    118                 y = - bit9toint(buf.u.val.ysign, buf.u.val.y);
    119 
    120                 if (x != 0 || y != 0) {
    121                         mouse_ev_move(x, y);
    122                 }
    123         }
    124 
    125         return;
    126 }
     132mouse_proto_ops_t ps2_proto = {
     133        .parse = ps2_proto_parse,
     134        .init = ps2_proto_init
     135};
    127136
    128137/**
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    rd2c67e7 r8ff0bd2  
    3939#include <ddi.h>
    4040#include <libarch/ddi.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <io/console.h>
    4343#include <vfs/vfs.h>
    44 #include <ipc/mouse.h>
     44#include <ipc/mouseev.h>
    4545#include <async.h>
    4646#include <async_obsolete.h>
     
    5454
    5555// FIXME: remove this header
    56 #include <kernel/ipc/ipc_methods.h>
     56#include <abi/ipc/methods.h>
    5757
    5858#define NAME "s3c24ser"
    59 #define NAMESPACE "hid_in"
     59#define NAMESPACE "hid"
    6060
    6161static irq_cmd_t ts_irq_cmds[] = {
     
    7373static s3c24xx_ts_t *ts;
    7474
    75 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall);
     75static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall,
     76    void *arg);
    7677static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    7778static void s3c24xx_ts_pen_down(s3c24xx_ts_t *ts);
     
    8990        printf(NAME ": S3C24xx touchscreen driver\n");
    9091
    91         rc = devmap_driver_register(NAME, s3c24xx_ts_connection);
     92        rc = loc_server_register(NAME, s3c24xx_ts_connection);
    9293        if (rc < 0) {
    9394                printf(NAME ": Unable to register driver.\n");
     
    102103                return -1;
    103104
    104         rc = devmap_device_register(NAMESPACE "/mouse", &ts->devmap_handle);
     105        rc = loc_service_register(NAMESPACE "/mouse", &ts->service_id);
    105106        if (rc != EOK) {
    106107                printf(NAME ": Unable to register device %s.\n",
     
    283284        button = 1;
    284285        press = 0;
    285         async_obsolete_msg_2(ts->client_phone, MEVENT_BUTTON, button, press);
     286        async_obsolete_msg_2(ts->client_phone, MOUSEEV_BUTTON_EVENT, button, press);
    286287
    287288        s3c24xx_ts_wait_for_int_mode(ts, updn_down);
     
    324325
    325326        /* Send notifications to client. */
    326         async_obsolete_msg_2(ts->client_phone, MEVENT_MOVE, dx, dy);
    327         async_obsolete_msg_2(ts->client_phone, MEVENT_BUTTON, button, press);
     327        async_obsolete_msg_2(ts->client_phone, MOUSEEV_MOVE_EVENT, dx, dy);
     328        async_obsolete_msg_2(ts->client_phone, MOUSEEV_BUTTON_EVENT, button, press);
    328329
    329330        ts->last_x = x_pos;
     
    373374
    374375/** Handle mouse client connection. */
    375 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall)
     376static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall,
     377    void *arg)
    376378{
    377379        ipc_callid_t callid;
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.h

    rd2c67e7 r8ff0bd2  
    124124        int client_phone;
    125125
    126         /** Device handle */
    127         devmap_handle_t devmap_handle;
     126        /** Service ID */
     127        service_id_t service_id;
    128128
    129129        /** Device/driver state */
Note: See TracChangeset for help on using the changeset viewer.