Ignore:
Timestamp:
2011-06-21T19:10:20Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
022d9f67
Parents:
a9d85df
Message:

input server improvements

  • integrate legacy port mouse drivers (PS/2, ADB) into the input server (to be on par with the legacy keyboard drivers)
  • create generic port/protocol layers for the mouse in the input server
  • rename the "hid_in" namespace to "hid" namespace (hid_in/input was rather redundant)
  • rename the mouse event IPC messages to be more consistent with the keyboard event messages
  • rename input server ops structure members to be more generic (parse_scancode → parse)
  • cstyle changes (newlines, comments, printouts)
File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/port/adb_mouse.c

    ra9d85df r1875a0c  
    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 <vfs/vfs.h>
    39 #include <fcntl.h>
     39#include <input.h>
     40#include <mouse_port.h>
     41#include <mouse.h>
    4042#include <errno.h>
    4143#include <devmap.h>
    42 #include <char_mouse.h>
    43 #include <mouse_port.h>
    4444
    45 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    46 
     45static mouse_dev_t *mouse_dev;
    4746static async_sess_t *dev_sess;
    4847
    49 #define NAME "char_mouse"
    50 
    51 int mouse_port_init(void)
    52 {
    53         devmap_handle_t handle;
    54         async_exch_t *exch;
    55         int rc;
    56        
    57         rc = devmap_device_get_handle("char/ps2b", &handle,
    58             IPC_FLAG_BLOCKING);
    59        
    60         if (rc != EOK) {
    61                 printf("%s: Failed resolving PS/2\n", NAME);
    62                 return rc;
    63         }
    64        
    65         dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle,
    66             IPC_FLAG_BLOCKING);
    67         if (dev_sess == NULL) {
    68                 printf("%s: Failed connecting to PS/2\n", NAME);
    69                 return ENOENT;
    70         }
    71        
    72         exch = async_exchange_begin(dev_sess);
    73         if (exch == NULL) {
    74                 printf("%s: Failed starting exchange with PS/2\n", NAME);
    75                 async_hangup(dev_sess);
    76                 return ENOMEM;
    77         }
    78        
    79         /* NB: The callback connection is slotted for removal */
    80         rc = async_connect_to_me(exch, 0, 0, 0, chardev_events, NULL);
    81         async_exchange_end(exch);
    82        
    83         if (rc != 0) {
    84                 printf(NAME ": Failed to create callback from device\n");
    85                 async_hangup(dev_sess);
    86                 return false;
    87         }
    88        
    89         return 0;
    90 }
    91 
    92 void mouse_port_yield(void)
    93 {
    94 }
    95 
    96 void mouse_port_reclaim(void)
    97 {
    98 }
    99 
    100 void mouse_port_write(uint8_t data)
    101 {
    102         async_exch_t *exch = async_exchange_begin(dev_sess);
    103         if (exch == NULL) {
    104                 printf("%s: Failed starting exchange with PS/2\n", NAME);
    105                 return;
    106         }
    107        
    108         async_msg_1(exch, CHAR_WRITE_BYTE, data);
    109        
    110         async_exchange_end(exch);
    111 }
    112 
    113 static void chardev_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     48static void mouse_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    11449{
    11550        /* Ignore parameters, the connection is already opened */
    11651        while (true) {
    117 
    11852                ipc_call_t call;
    11953                ipc_callid_t callid = async_get_call(&call);
    120 
     54               
    12155                int retval;
    12256               
     
    12559                        return;
    12660                }
    127 
     61               
    12862                switch (IPC_GET_IMETHOD(call)) {
    129                 case IPC_FIRST_USER_METHOD:
    130                         mouse_handle_byte(IPC_GET_ARG1(call));
     63                case ADB_REG_NOTIF:
     64                        mouse_push_data(mouse_dev, IPC_GET_ARG1(call));
    13165                        break;
    13266                default:
    13367                        retval = ENOENT;
    13468                }
     69               
    13570                async_answer_0(callid, retval);
    13671        }
    13772}
    13873
     74static int adb_port_init(mouse_dev_t *mdev)
     75{
     76        const char *dev = "adb/mouse";
     77       
     78        mouse_dev = mdev;
     79       
     80        devmap_handle_t handle;
     81        int rc = devmap_device_get_handle(dev, &handle, 0);
     82        if (rc != EOK)
     83                return rc;
     84       
     85        dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
     86        if (dev_sess == NULL) {
     87                printf("%s: Failed to connect to device\n", NAME);
     88                return ENOENT;
     89        }
     90       
     91        async_exch_t *exch = async_exchange_begin(dev_sess);
     92        if (exch == NULL) {
     93                printf("%s: Failed starting exchange with device\n", NAME);
     94                async_hangup(dev_sess);
     95                return ENOMEM;
     96        }
     97       
     98        /* NB: The callback connection is slotted for removal */
     99        rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL);
     100        async_exchange_end(exch);
     101        if (rc != EOK) {
     102                printf("%s: Failed to create callback from device\n", NAME);
     103                async_hangup(dev_sess);
     104                return rc;
     105        }
     106       
     107        return EOK;
     108}
     109
     110static void adb_port_yield(void)
     111{
     112}
     113
     114static void adb_port_reclaim(void)
     115{
     116}
     117
     118static void adb_port_write(uint8_t data)
     119{
     120}
     121
     122mouse_port_ops_t adb_mouse_port = {
     123        .init = adb_port_init,
     124        .yield = adb_port_yield,
     125        .reclaim = adb_port_reclaim,
     126        .write = adb_port_write
     127};
     128
    139129/**
    140130 * @}
Note: See TracChangeset for help on using the changeset viewer.