Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/compositor/compositor.c

    r8e4a408 r071fefec  
    5555#include <async.h>
    5656#include <loc.h>
     57#include <devman.h>
    5758
    5859#include <event.h>
     60#include <graph_iface.h>
    5961#include <io/keycode.h>
    6062#include <io/mode.h>
     
    11471149}
    11481150
    1149 static async_sess_t *vsl_connect(service_id_t sid, const char *svc)
     1151static async_sess_t *vsl_connect(const char *svc)
    11501152{
    11511153        int rc;
    11521154        async_sess_t *sess;
    1153 
    1154         sess = loc_service_connect(EXCHANGE_SERIALIZE, sid, 0);
    1155         if (sess == NULL) {
    1156                 printf("%s: Unable to connect to visualizer %s\n", NAME, svc);
     1155        service_id_t dsid;
     1156        devman_handle_t handle;
     1157
     1158        rc = loc_service_get_id(svc, &dsid, 0);
     1159        if (rc != EOK) {
    11571160                return NULL;
    11581161        }
    11591162
     1163        rc = devman_fun_sid_to_handle(dsid, &handle);
     1164        if (rc == EOK) {
     1165                sess = devman_device_connect(EXCHANGE_SERIALIZE, handle, 0);
     1166                if (sess == NULL) {
     1167                        printf("%s: Unable to connect to visualizer %s\n", NAME, svc);
     1168                        return NULL;
     1169                }
     1170                rc = graph_dev_connect(sess);
     1171                if (rc != EOK) {
     1172                        return NULL;
     1173                }
     1174        } else if (rc == ENOENT) {
     1175                sess = loc_service_connect(EXCHANGE_SERIALIZE, dsid, 0);
     1176                if (sess == NULL) {
     1177                        printf("%s: Unable to connect to visualizer %s\n", NAME, svc);
     1178                        return NULL;
     1179                }
     1180        } else {
     1181                return NULL;
     1182        }
     1183
    11601184        async_exch_t *exch = async_exchange_begin(sess);
    1161         rc = async_connect_to_me(exch, sid, 0, 0, vsl_notifications, NULL);
     1185        rc = async_connect_to_me(exch, dsid, 0, 0, vsl_notifications, NULL);
    11621186        async_exchange_end(exch);
    11631187
     
    11721196}
    11731197
    1174 static viewport_t *viewport_create(service_id_t sid)
     1198static viewport_t *viewport_create(const char *vsl_name)
    11751199{
    11761200        int rc;
    1177         char *vsl_name = NULL;
    1178         viewport_t *vp = NULL;
    1179         bool claimed = false;
    1180 
    1181         rc = loc_service_get_name(sid, &vsl_name);
    1182         if (rc != EOK)
    1183                 goto error;
    1184 
    1185         vp = (viewport_t *) calloc(1, sizeof(viewport_t));
    1186         if (!vp)
    1187                 goto error;
     1201
     1202        viewport_t *vp = (viewport_t *) malloc(sizeof(viewport_t));
     1203        if (!vp) {
     1204                return NULL;
     1205        }
    11881206
    11891207        link_initialize(&vp->link);
     
    11921210
    11931211        /* Establish output bidirectional connection. */
    1194         vp->dsid = sid;
    1195         vp->sess = vsl_connect(sid, vsl_name);
    1196         if (vp->sess == NULL)
    1197                 goto error;
     1212        vp->sess = vsl_connect(vsl_name);
     1213        rc = loc_service_get_id(vsl_name, &vp->dsid, 0);
     1214        if (vp->sess == NULL || rc != EOK) {
     1215                free(vp);
     1216                return NULL;
     1217        }
    11981218
    11991219        /* Claim the given visualizer. */
    12001220        rc = visualizer_claim(vp->sess, 0);
    12011221        if (rc != EOK) {
     1222                async_hangup(vp->sess);
     1223                free(vp);
    12021224                printf("%s: Unable to claim visualizer (%s)\n", NAME, str_error(rc));
    1203                 goto error;
    1204         }
    1205 
    1206         claimed = true;
     1225                return NULL;
     1226        }
    12071227
    12081228        /* Retrieve the default mode. */
    12091229        rc = visualizer_get_default_mode(vp->sess, &vp->mode);
    12101230        if (rc != EOK) {
     1231                visualizer_yield(vp->sess);
     1232                async_hangup(vp->sess);
     1233                free(vp);
    12111234                printf("%s: Unable to retrieve mode (%s)\n", NAME, str_error(rc));
    1212                 goto error;
     1235                return NULL;
    12131236        }
    12141237
     
    12171240            NULL, SURFACE_FLAG_SHARED);
    12181241        if (vp->surface == NULL) {
     1242                visualizer_yield(vp->sess);
     1243                async_hangup(vp->sess);
     1244                free(vp);
    12191245                printf("%s: Unable to create surface (%s)\n", NAME, str_error(rc));
    1220                 goto error;
     1246                return NULL;
    12211247        }
    12221248
     
    12251251                vp->mode.index, vp->mode.version, surface_direct_access(vp->surface));
    12261252        if (rc != EOK) {
     1253                visualizer_yield(vp->sess);
     1254                surface_destroy(vp->surface);
     1255                async_hangup(vp->sess);
     1256                free(vp);
    12271257                printf("%s: Unable to set mode (%s)\n", NAME, str_error(rc));
    1228                 goto error;
     1258                return NULL;
    12291259        }
    12301260
    12311261        return vp;
    1232 error:
    1233         if (claimed)
    1234                 visualizer_yield(vp->sess);
    1235         if (vp->sess != NULL)
    1236                 async_hangup(vp->sess);
    1237         free(vp);
    1238         free(vsl_name);
    1239         return NULL;
    12401262}
    12411263
     
    21682190                        continue;
    21692191               
    2170                 viewport_t *vp = viewport_create(svcs[i]);
    2171                 if (vp != NULL)
    2172                         list_append(&vp->link, &viewport_list);
     2192                char *svc_name;
     2193                rc = loc_service_get_name(svcs[i], &svc_name);
     2194                if (rc == EOK) {
     2195                        viewport_t *vp = viewport_create(svc_name);
     2196                        if (vp != NULL) {
     2197                                list_append(&vp->link, &viewport_list);
     2198                        }
     2199                }
    21732200        }
    21742201        fibril_mutex_unlock(&viewport_list_mtx);
Note: See TracChangeset for help on using the changeset viewer.