Changeset e4f8c77 in mainline for uspace/srv/hid/input/port/adb.c


Ignore:
Timestamp:
2011-07-13T22:39:18Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6910c8
Parents:
5974661 (diff), 8ecef91 (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 libposix.

File:
1 moved

Legend:

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

    r5974661 re4f8c77  
    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>
     
    4444#include <errno.h>
    4545#include <devmap.h>
    46 #include <devmap_obsolete.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";
    5868        devmap_handle_t handle;
     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 = devmap_device_get_handle(dev, &handle, 0);
     75        if (rc != EOK)
    6876                return rc;
    6977       
     78        dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 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
Note: See TracChangeset for help on using the changeset viewer.