Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhid/multimedia/multimedia.c

    r5da7199 r5f6e25e  
    4747#include <errno.h>
    4848#include <async.h>
     49#include <async_obsolete.h>
    4950#include <str_error.h>
    5051
     
    5253#include <io/console.h>
    5354
    54 #define NAME  "multimedia-keys"
     55// FIXME: remove this header
     56#include <abi/ipc/methods.h>
     57
     58#define NAME "multimedia-keys"
    5559
    5660/*----------------------------------------------------------------------------*/
     
    6569        /** Count of stored keys (i.e. number of keys in the report). */
    6670        //size_t key_count;     
    67         /** IPC session to the console device (for sending key events). */
    68         async_sess_t *console_sess;
     71        /** IPC phone to the console device (for sending key events). */
     72        int console_phone;
    6973} usb_multimedia_t;
    7074
     
    7579 *
    7680 * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
    77  * assumes the caller is the console and thus it stores IPC session to it for
     81 * assumes the caller is the console and thus it stores IPC phone to it for
    7882 * later use by the driver to notify about key events.
    7983 *
     
    8791        usb_log_debug(NAME " default_connection_handler()\n");
    8892       
     93        sysarg_t method = IPC_GET_IMETHOD(*icall);
     94       
    8995        usb_multimedia_t *multim_dev = (usb_multimedia_t *)fun->driver_data;
    9096       
     
    9399                return;
    94100        }
    95        
    96         async_sess_t *sess =
    97             async_callback_receive_start(EXCHANGE_SERIALIZE, icall);
    98         if (sess != NULL) {
    99                 if (multim_dev->console_sess == NULL) {
    100                         multim_dev->console_sess = sess;
    101                         usb_log_debug(NAME " Saved session to console: %p\n",
    102                             sess);
    103                         async_answer_0(icallid, EOK);
    104                 } else
     101
     102        if (method == IPC_M_CONNECT_TO_ME) {
     103                int callback = IPC_GET_ARG5(*icall);
     104
     105                if (multim_dev->console_phone != -1) {
    105106                        async_answer_0(icallid, ELIMIT);
    106         } else
    107                 async_answer_0(icallid, EINVAL);
     107                        return;
     108                }
     109
     110                multim_dev->console_phone = callback;
     111                usb_log_debug(NAME " Saved phone to console: %d\n", callback);
     112                async_answer_0(icallid, EOK);
     113                return;
     114        }
     115       
     116        async_answer_0(icallid, EINVAL);
    108117}
    109118
     
    146155
    147156        usb_log_debug2(NAME " Sending key %d to the console\n", ev.key);
    148         if (multim_dev->console_sess == NULL) {
     157        if (multim_dev->console_phone < 0) {
    149158                usb_log_warning(
    150159                    "Connection to console not ready, key discarded.\n");
     
    152161        }
    153162       
    154         async_exch_t *exch = async_exchange_begin(multim_dev->console_sess);
    155         async_msg_4(exch, KBDEV_EVENT, ev.type, ev.key, ev.mods, ev.c);
    156         async_exchange_end(exch);
     163        async_obsolete_msg_4(multim_dev->console_phone, KBDEV_EVENT, ev.type, ev.key,
     164            ev.mods, ev.c);
    157165}
    158166
     
    214222        }
    215223       
    216         multim_dev->console_sess = NULL;
     224        multim_dev->console_phone = -1;
    217225       
    218226        /*! @todo Autorepeat */
     
    242250        if (data != NULL) {
    243251                usb_multimedia_t *multim_dev = (usb_multimedia_t *)data;
    244                 // hangup session to the console
    245                 async_hangup(multim_dev->console_sess);
     252                // hangup phone to the console
     253                async_obsolete_hangup(multim_dev->console_phone);
    246254        }
    247255}
Note: See TracChangeset for help on using the changeset viewer.