Changeset b3eeae5 in mainline for uspace/srv/hid/display/cfgops.c


Ignore:
Timestamp:
2023-01-15T09:24:50Z (15 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
46a47c0
Parents:
46b02cb
Message:

Assigning devices to seats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/display/cfgops.c

    r46b02cb rb3eeae5  
    4040#include <dispcfg_srv.h>
    4141#include "display.h"
     42#include "idevcfg.h"
    4243#include "seat.h"
    4344#include "cfgclient.h"
     
    4748static errno_t dispc_seat_create(void *, const char *, sysarg_t *);
    4849static errno_t dispc_seat_delete(void *, sysarg_t);
     50static errno_t dispc_dev_assign(void *, sysarg_t, sysarg_t);
     51static errno_t dispc_dev_unassign(void *, sysarg_t);
    4952static errno_t dispc_get_event(void *, dispcfg_ev_t *);
    5053
     
    5457        .seat_create = dispc_seat_create,
    5558        .seat_delete = dispc_seat_delete,
     59        .dev_assign = dispc_dev_assign,
     60        .dev_unassign = dispc_dev_unassign,
    5661        .get_event = dispc_get_event,
    5762};
     
    207212}
    208213
     214/** Assign device to seat.
     215 *
     216 * @param arg Argument (CFG client)
     217 * @param svc_id Device service ID
     218 * @param seat_id Seat ID
     219 * @return EOK on success or an error code
     220 */
     221static errno_t dispc_dev_assign(void *arg, sysarg_t svc_id, sysarg_t seat_id)
     222{
     223        ds_cfgclient_t *cfgclient = (ds_cfgclient_t *)arg;
     224        ds_seat_t *seat;
     225        ds_idevcfg_t *idevcfg;
     226        errno_t rc;
     227
     228        log_msg(LOG_DEFAULT, LVL_DEBUG, "dispcfg_dev_assign()");
     229
     230        ds_display_lock(cfgclient->display);
     231        seat = ds_display_find_seat(cfgclient->display, seat_id);
     232        if (seat == NULL) {
     233                ds_display_unlock(cfgclient->display);
     234                return ENOENT;
     235        }
     236
     237        rc = ds_idevcfg_create(cfgclient->display, svc_id, seat, &idevcfg);
     238        if (rc != EOK) {
     239                assert(rc == ENOMEM);
     240                ds_display_unlock(cfgclient->display);
     241                return ENOMEM;
     242        }
     243
     244        (void)idevcfg;
     245
     246        ds_display_unlock(cfgclient->display);
     247        return EOK;
     248}
     249
     250/** Unassign device from any seat.
     251 *
     252 * @param arg Argument (CFG client)
     253 * @param svc_id Device service ID
     254 * @return EOK on success or an error code
     255 */
     256static errno_t dispc_dev_unassign(void *arg, sysarg_t svc_id)
     257{
     258        ds_cfgclient_t *cfgclient = (ds_cfgclient_t *)arg;
     259        ds_idevcfg_t *idevcfg;
     260
     261        log_msg(LOG_DEFAULT, LVL_DEBUG, "dispcfg_dev_unassign()");
     262
     263        ds_display_lock(cfgclient->display);
     264
     265        idevcfg = ds_display_first_idevcfg(cfgclient->display);
     266        while (idevcfg != NULL) {
     267                if (idevcfg->svc_id == svc_id)
     268                        break;
     269
     270                idevcfg = ds_display_next_idevcfg(idevcfg);
     271        }
     272
     273        if (idevcfg == NULL) {
     274                ds_display_unlock(cfgclient->display);
     275                return ENOENT;
     276        }
     277
     278        ds_idevcfg_destroy(idevcfg);
     279        ds_display_unlock(cfgclient->display);
     280        return EOK;
     281}
     282
    209283/** Get display configuration event.
    210284 *
Note: See TracChangeset for help on using the changeset viewer.