Changeset 8ff0bd2 in mainline for uspace/srv/hid/input/port/chardev.c


Ignore:
Timestamp:
2011-09-04T11:30:58Z (15 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, 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

File:
1 moved

Legend:

Unmodified
Added
Removed
  • 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:
Note: See TracChangeset for help on using the changeset viewer.