Changeset 1affcdf3 in mainline for uspace/srv/hid/kbd/port/chardev.c


Ignore:
Timestamp:
2011-06-10T19:33:41Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1878386
Parents:
13ecdac9 (diff), 79a141a (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/kbd/port/chardev.c

    r13ecdac9 r1affcdf3  
    3030 * @ingroup kbd
    3131 * @{
    32  */ 
     32 */
    3333/** @file
    3434 * @brief Chardev keyboard port driver.
     
    3737#include <ipc/char.h>
    3838#include <async.h>
     39#include <async_obsolete.h>
    3940#include <kbd_port.h>
    4041#include <kbd.h>
    41 #include <vfs/vfs.h>
    42 #include <sys/stat.h>
    43 #include <fcntl.h>
     42#include <devmap.h>
     43#include <devmap_obsolete.h>
    4444#include <errno.h>
     45#include <stdio.h>
     46
     47#define NAME  "kbd/chardev"
    4548
    4649static void kbd_port_events(ipc_callid_t iid, ipc_call_t *icall);
     
    4851static int dev_phone;
    4952
    50 #define NAME "kbd"
    51 
    5253/** List of devices to try connecting to. */
    5354static const char *in_devs[] = {
    54         "/dev/char/ps2a",
    55         "/dev/char/s3c24ser"
     55        "char/ps2a",
     56        "char/s3c24ser"
    5657};
    5758
    58 static const int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);
     59static const unsigned int num_devs = sizeof(in_devs) / sizeof(in_devs[0]);
    5960
    6061int kbd_port_init(void)
    6162{
    62         int input_fd;
    63         int i;
    64 
    65         input_fd = -1;
     63        devmap_handle_t handle;
     64        unsigned int i;
     65        int rc;
     66       
    6667        for (i = 0; i < num_devs; i++) {
    67                 struct stat s;
    68 
    69                 if (stat(in_devs[i], &s) == EOK)
     68                rc = devmap_device_get_handle(in_devs[i], &handle, 0);
     69                if (rc == EOK)
    7070                        break;
    7171        }
    72 
     72       
    7373        if (i >= num_devs) {
    74                 printf(NAME ": Could not find any suitable input device.\n");
     74                printf("%s: Could not find any suitable input device\n", NAME);
    7575                return -1;
    7676        }
    77 
    78         input_fd = open(in_devs[i], O_RDONLY);
    79         if (input_fd < 0) {
    80                 printf(NAME ": failed opening device %s (%d).\n", in_devs[i],
    81                     input_fd);
    82                 return -1;
     77       
     78        dev_phone = devmap_obsolete_device_connect(handle, IPC_FLAG_BLOCKING);
     79        if (dev_phone < 0) {
     80                printf("%s: Failed connecting to device\n", NAME);
     81                return ENOENT;
    8382        }
    84 
    85         dev_phone = fd_phone(input_fd);
    86         if (dev_phone < 0) {
    87                 printf(NAME ": Failed connecting to device\n");
    88                 return -1;
    89         }
    90 
     83       
    9184        /* NB: The callback connection is slotted for removal */
    92         if (async_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
     85        if (async_obsolete_connect_to_me(dev_phone, 0, 0, 0, kbd_port_events) != 0) {
    9386                printf(NAME ": Failed to create callback from device\n");
    9487                return -1;
     
    108101void kbd_port_write(uint8_t data)
    109102{
    110         async_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
     103        async_obsolete_msg_1(dev_phone, CHAR_WRITE_BYTE, data);
    111104}
    112105
     
    118111                ipc_call_t call;
    119112                ipc_callid_t callid = async_get_call(&call);
     113               
     114                if (!IPC_GET_IMETHOD(call)) {
     115                        /* TODO: Handle hangup */
     116                        return;
     117                }
    120118
    121119                int retval;
    122120
    123121                switch (IPC_GET_IMETHOD(call)) {
    124                 case IPC_M_PHONE_HUNGUP:
    125                         /* TODO: Handle hangup */
    126                         return;
    127122                case CHAR_NOTIF_BYTE:
    128123                        kbd_push_scancode(IPC_GET_ARG1(call));
Note: See TracChangeset for help on using the changeset viewer.