Ignore:
Timestamp:
2011-11-06T22:21:05Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
898e847
Parents:
2bdf8313 (diff), 7b5f4c9 (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/s3c24xx_ts/s3c24xx_ts.c

    r2bdf8313 rb0f00a9  
    3939#include <ddi.h>
    4040#include <libarch/ddi.h>
    41 #include <devmap.h>
     41#include <loc.h>
    4242#include <io/console.h>
    4343#include <vfs/vfs.h>
    44 #include <ipc/mouse.h>
     44#include <ipc/mouseev.h>
    4545#include <async.h>
    4646#include <unistd.h>
     
    5050#include <errno.h>
    5151#include <inttypes.h>
    52 
    5352#include "s3c24xx_ts.h"
    5453
    55 #define NAME "s3c24ser"
    56 #define NAMESPACE "hid_in"
     54#define NAME       "s3c24ser"
     55#define NAMESPACE  "hid"
    5756
    5857static irq_cmd_t ts_irq_cmds[] = {
     
    7069static s3c24xx_ts_t *ts;
    7170
    72 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall);
     71static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall,
     72    void *arg);
    7373static void s3c24xx_ts_irq_handler(ipc_callid_t iid, ipc_call_t *call);
    7474static void s3c24xx_ts_pen_down(s3c24xx_ts_t *ts);
     
    8686        printf(NAME ": S3C24xx touchscreen driver\n");
    8787
    88         rc = devmap_driver_register(NAME, s3c24xx_ts_connection);
     88        rc = loc_server_register(NAME, s3c24xx_ts_connection);
    8989        if (rc < 0) {
    9090                printf(NAME ": Unable to register driver.\n");
     
    9999                return -1;
    100100
    101         rc = devmap_device_register(NAMESPACE "/mouse", &ts->devmap_handle);
     101        rc = loc_service_register(NAMESPACE "/mouse", &ts->service_id);
    102102        if (rc != EOK) {
    103103                printf(NAME ": Unable to register device %s.\n",
     
    130130
    131131        ts->io = vaddr;
    132         ts->client_phone = -1;
     132        ts->client_sess = NULL;
    133133        ts->state = ts_wait_pendown;
    134134        ts->last_x = 0;
     
    280280        button = 1;
    281281        press = 0;
    282         async_msg_2(ts->client_phone, MEVENT_BUTTON, button, press);
     282       
     283        async_exch_t *exch = async_exchange_begin(ts->client_sess);
     284        async_msg_2(exch, MOUSEEV_BUTTON_EVENT, button, press);
     285        async_exchange_end(exch);
    283286
    284287        s3c24xx_ts_wait_for_int_mode(ts, updn_down);
     
    321324
    322325        /* Send notifications to client. */
    323         async_msg_2(ts->client_phone, MEVENT_MOVE, dx, dy);
    324         async_msg_2(ts->client_phone, MEVENT_BUTTON, button, press);
     326        async_exch_t *exch = async_exchange_begin(ts->client_sess);
     327        async_msg_2(exch, MOUSEEV_MOVE_EVENT, dx, dy);
     328        async_msg_2(exch, MOUSEEV_BUTTON_EVENT, button, press);
     329        async_exchange_end(exch);
    325330
    326331        ts->last_x = x_pos;
     
    370375
    371376/** Handle mouse client connection. */
    372 static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall)
    373 {
    374         ipc_callid_t callid;
    375         ipc_call_t call;
    376         int retval;
    377 
     377static void s3c24xx_ts_connection(ipc_callid_t iid, ipc_call_t *icall,
     378    void *arg)
     379{
    378380        async_answer_0(iid, EOK);
    379 
    380         while (1) {
    381                 callid = async_get_call(&call);
    382                 switch (IPC_GET_IMETHOD(call)) {
    383                 case IPC_M_PHONE_HUNGUP:
    384                         if (ts->client_phone != -1) {
    385                                 async_hangup(ts->client_phone);
    386                                 ts->client_phone = -1;
     381       
     382        while (true) {
     383                ipc_call_t call;
     384                ipc_callid_t callid = async_get_call(&call);
     385               
     386                if (!IPC_GET_IMETHOD(call)) {
     387                        if (ts->client_sess != NULL) {
     388                                async_hangup(ts->client_sess);
     389                                ts->client_sess = NULL;
    387390                        }
    388 
     391                       
    389392                        async_answer_0(callid, EOK);
    390393                        return;
    391                 case IPC_M_CONNECT_TO_ME:
    392                         if (ts->client_phone != -1) {
    393                                 retval = ELIMIT;
    394                                 break;
    395                         }
    396                         ts->client_phone = IPC_GET_ARG5(call);
    397                         retval = 0;
    398                         break;
    399                 default:
    400                         retval = EINVAL;
    401394                }
    402                 async_answer_0(callid, retval);
     395               
     396                async_sess_t *sess =
     397                    async_callback_receive_start(EXCHANGE_SERIALIZE, &call);
     398                if (sess != NULL) {
     399                        if (ts->client_sess == NULL) {
     400                                ts->client_sess = sess;
     401                                async_answer_0(callid, EOK);
     402                        } else
     403                                async_answer_0(callid, ELIMIT);
     404                } else
     405                        async_answer_0(callid, EINVAL);
    403406        }
    404407}
Note: See TracChangeset for help on using the changeset viewer.