Ignore:
Timestamp:
2011-09-09T18:22:33Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
40a2af3
Parents:
980671e7 (diff), 5da7199 (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/drv/bus/usb/usbhid/multimedia/multimedia.c

    r980671e7 r3781092  
    4747#include <errno.h>
    4848#include <async.h>
    49 #include <async_obsolete.h>
    5049#include <str_error.h>
    5150
     
    5352#include <io/console.h>
    5453
    55 // FIXME: remove this header
    56 #include <abi/ipc/methods.h>
    57 
    58 #define NAME "multimedia-keys"
     54#define NAME  "multimedia-keys"
    5955
    6056/*----------------------------------------------------------------------------*/
     
    6965        /** Count of stored keys (i.e. number of keys in the report). */
    7066        //size_t key_count;     
    71         /** IPC phone to the console device (for sending key events). */
    72         int console_phone;
     67        /** IPC session to the console device (for sending key events). */
     68        async_sess_t *console_sess;
    7369} usb_multimedia_t;
    7470
     
    7975 *
    8076 * Currently recognizes only one method (IPC_M_CONNECT_TO_ME), in which case it
    81  * assumes the caller is the console and thus it stores IPC phone to it for
     77 * assumes the caller is the console and thus it stores IPC session to it for
    8278 * later use by the driver to notify about key events.
    8379 *
     
    9187        usb_log_debug(NAME " default_connection_handler()\n");
    9288       
    93         sysarg_t method = IPC_GET_IMETHOD(*icall);
    94        
    9589        usb_multimedia_t *multim_dev = (usb_multimedia_t *)fun->driver_data;
    9690       
     
    9993                return;
    10094        }
    101 
    102         if (method == IPC_M_CONNECT_TO_ME) {
    103                 int callback = IPC_GET_ARG5(*icall);
    104 
    105                 if (multim_dev->console_phone != -1) {
     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
    106105                        async_answer_0(icallid, ELIMIT);
    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);
     106        } else
     107                async_answer_0(icallid, EINVAL);
    117108}
    118109
     
    155146
    156147        usb_log_debug2(NAME " Sending key %d to the console\n", ev.key);
    157         if (multim_dev->console_phone < 0) {
     148        if (multim_dev->console_sess == NULL) {
    158149                usb_log_warning(
    159150                    "Connection to console not ready, key discarded.\n");
     
    161152        }
    162153       
    163         async_obsolete_msg_4(multim_dev->console_phone, KBDEV_EVENT, ev.type, ev.key,
    164             ev.mods, ev.c);
     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);
    165157}
    166158
     
    222214        }
    223215       
    224         multim_dev->console_phone = -1;
     216        multim_dev->console_sess = NULL;
    225217       
    226218        /*! @todo Autorepeat */
     
    250242        if (data != NULL) {
    251243                usb_multimedia_t *multim_dev = (usb_multimedia_t *)data;
    252                 // hangup phone to the console
    253                 async_obsolete_hangup(multim_dev->console_phone);
     244                // hangup session to the console
     245                async_hangup(multim_dev->console_sess);
    254246        }
    255247}
Note: See TracChangeset for help on using the changeset viewer.