Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b3eeae5 in mainline


Ignore:
Timestamp:
2023-01-15T09:24:50Z (3 weeks ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
46a47c0
Parents:
46b02cb
Message:

Assigning devices to seats

Location:
uspace
Files:
3 added
13 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/disp/disp.c

    r46b02cb rb3eeae5  
    5454        printf("  %s create-seat <name>\n", NAME);
    5555        printf("  %s delete-seat <name>\n", NAME);
     56        printf("  %s assign-dev <device> <seat>\n", NAME);
     57        printf("  %s unassign-dev <device>\n", NAME);
    5658}
    5759
     
    273275}
    274276
     277/** Assign device subcommand.
     278 *
     279 * @param dcfg_svc Display configuration service name
     280 * @param argc Number of arguments
     281 * @param argv Arguments
     282 * @return EOK on success or an erro code
     283 */
     284static errno_t dev_assign(const char *dcfg_svc, int argc, char *argv[])
     285{
     286        dispcfg_t *dispcfg;
     287        char *dev_name;
     288        service_id_t svc_id;
     289        char *seat_name;
     290        sysarg_t seat_id;
     291        errno_t rc;
     292
     293        if (argc < 2) {
     294                printf(NAME ": Missing arguments.\n");
     295                print_syntax();
     296                return EINVAL;
     297        }
     298
     299        if (argc > 2) {
     300                printf(NAME ": Too many arguments.\n");
     301                print_syntax();
     302                return EINVAL;
     303        }
     304
     305        dev_name = argv[0];
     306        seat_name = argv[1];
     307
     308        rc = loc_service_get_id(dev_name, &svc_id, 0);
     309        if (rc != EOK) {
     310                printf(NAME ": Device service '%s' not found.\n",
     311                    dev_name);
     312                return ENOENT;
     313        }
     314
     315        rc = dispcfg_open(dcfg_svc, NULL, NULL, &dispcfg);
     316        if (rc != EOK) {
     317                printf(NAME ": Failed connecting to display configuration "
     318                    "service: %s.\n", str_error(rc));
     319                return rc;
     320        }
     321
     322        rc = seat_find_by_name(dispcfg, seat_name, &seat_id);
     323        if (rc != EOK) {
     324                printf(NAME ": Seat '%s' not found.\n", seat_name);
     325                dispcfg_close(dispcfg);
     326                return ENOENT;
     327        }
     328
     329        rc = dispcfg_dev_assign(dispcfg, svc_id, seat_id);
     330        if (rc != EOK) {
     331                printf(NAME ": Failed assigning device '%s' to seat '%s': "
     332                    "%s\n", dev_name, seat_name, str_error(rc));
     333                dispcfg_close(dispcfg);
     334                return EIO;
     335        }
     336
     337        dispcfg_close(dispcfg);
     338        return EOK;
     339}
     340
     341/** Unassign device subcommand.
     342 *
     343 * @param dcfg_svc Display configuration service name
     344 * @param argc Number of arguments
     345 * @param argv Arguments
     346 * @return EOK on success or an erro code
     347 */
     348static errno_t dev_unassign(const char *dcfg_svc, int argc, char *argv[])
     349{
     350        dispcfg_t *dispcfg;
     351        char *dev_name;
     352        service_id_t svc_id;
     353        errno_t rc;
     354
     355        if (argc < 1) {
     356                printf(NAME ": Missing arguments.\n");
     357                print_syntax();
     358                return EINVAL;
     359        }
     360
     361        if (argc > 1) {
     362                printf(NAME ": Too many arguments.\n");
     363                print_syntax();
     364                return EINVAL;
     365        }
     366
     367        dev_name = argv[0];
     368
     369        rc = loc_service_get_id(dev_name, &svc_id, 0);
     370        if (rc != EOK) {
     371                printf(NAME ": Device service '%s' not found.\n",
     372                    dev_name);
     373                return ENOENT;
     374        }
     375
     376        rc = dispcfg_open(dcfg_svc, NULL, NULL, &dispcfg);
     377        if (rc != EOK) {
     378                printf(NAME ": Failed connecting to display configuration "
     379                    "service: %s.\n", str_error(rc));
     380                return rc;
     381        }
     382
     383        rc = dispcfg_dev_unassign(dispcfg, svc_id);
     384        if (rc != EOK) {
     385                printf(NAME ": Failed unassigning device '%s': %s\n",
     386                    dev_name, str_error(rc));
     387                dispcfg_close(dispcfg);
     388                return EIO;
     389        }
     390
     391        dispcfg_close(dispcfg);
     392        return EOK;
     393}
     394
    275395int main(int argc, char *argv[])
    276396{
     
    295415                if (rc != EOK)
    296416                        return 1;
     417        } else if (str_cmp(argv[1], "assign-dev") == 0) {
     418                rc = dev_assign(dispcfg_svc, argc - 2, argv + 2);
     419                if (rc != EOK)
     420                        return 1;
     421        } else if (str_cmp(argv[1], "unassign-dev") == 0) {
     422                rc = dev_unassign(dispcfg_svc, argc - 2, argv + 2);
     423                if (rc != EOK)
     424                        return 1;
    297425        } else {
    298426                printf(NAME ": Unknown command '%s'.\n", argv[1]);
  • uspace/lib/dispcfg/include/dispcfg.h

    r46b02cb rb3eeae5  
    4949extern errno_t dispcfg_seat_create(dispcfg_t *, const char *, sysarg_t *);
    5050extern errno_t dispcfg_seat_delete(dispcfg_t *, sysarg_t);
     51extern errno_t dispcfg_dev_assign(dispcfg_t *, sysarg_t, sysarg_t);
     52extern errno_t dispcfg_dev_unassign(dispcfg_t *, sysarg_t);
    5153
    5254#endif
  • uspace/lib/dispcfg/include/dispcfg_srv.h

    r46b02cb rb3eeae5  
    5454        errno_t (*seat_create)(void *, const char *, sysarg_t *);
    5555        errno_t (*seat_delete)(void *, sysarg_t);
     56        errno_t (*dev_assign)(void *, sysarg_t, sysarg_t);
     57        errno_t (*dev_unassign)(void *, sysarg_t);
    5658        errno_t (*get_event)(void *, dispcfg_ev_t *);
    5759};
  • uspace/lib/dispcfg/include/ipc/dispcfg.h

    r46b02cb rb3eeae5  
    4444        DISPCFG_SEAT_CREATE,
    4545        DISPCFG_SEAT_DELETE,
     46        DISPCFG_DEV_ASSIGN,
     47        DISPCFG_DEV_UNASSIGN,
    4648        DISPCFG_GET_EVENT,
    4749} dispcfg_request_t;
  • uspace/lib/dispcfg/src/dispcfg.c

    r46b02cb rb3eeae5  
    335335        exch = async_exchange_begin(dispcfg->sess);
    336336        rc = async_req_1_0(exch, DISPCFG_SEAT_DELETE, seat_id);
     337
     338        async_exchange_end(exch);
     339        return rc;
     340}
     341
     342/** Assign device to seat.
     343 *
     344 * @param dispcfg Display configuration
     345 * @param svc_id Device service ID
     346 * @param seat_id Seat ID
     347 * @return EOK on success or an error code
     348 */
     349errno_t dispcfg_dev_assign(dispcfg_t *dispcfg, sysarg_t svc_id,
     350    sysarg_t seat_id)
     351{
     352        async_exch_t *exch;
     353        errno_t rc;
     354
     355        exch = async_exchange_begin(dispcfg->sess);
     356        rc = async_req_2_0(exch, DISPCFG_DEV_ASSIGN, svc_id, seat_id);
     357
     358        async_exchange_end(exch);
     359        return rc;
     360}
     361
     362/** Unassign device from any specific seat.
     363 *
     364 * The device will fall back to the default seat.
     365 *
     366 * @param dispcfg Display configuration
     367 * @param svc_id Device service ID
     368 * @return EOK on success or an error code
     369 */
     370errno_t dispcfg_dev_unassign(dispcfg_t *dispcfg, sysarg_t svc_id)
     371{
     372        async_exch_t *exch;
     373        errno_t rc;
     374
     375        exch = async_exchange_begin(dispcfg->sess);
     376        rc = async_req_1_0(exch, DISPCFG_DEV_UNASSIGN, svc_id);
    337377
    338378        async_exchange_end(exch);
  • uspace/lib/dispcfg/src/dispcfg_srv.c

    r46b02cb rb3eeae5  
    259259}
    260260
     261static void dispcfg_dev_assign_srv(dispcfg_srv_t *srv, ipc_call_t *icall)
     262{
     263        sysarg_t svc_id;
     264        sysarg_t seat_id;
     265        errno_t rc;
     266
     267        svc_id = ipc_get_arg1(icall);
     268        seat_id = ipc_get_arg2(icall);
     269
     270        if (srv->ops->dev_assign == NULL) {
     271                async_answer_0(icall, ENOTSUP);
     272                return;
     273        }
     274
     275        rc = srv->ops->dev_assign(srv->arg, svc_id, seat_id);
     276        async_answer_0(icall, rc);
     277}
     278
     279static void dispcfg_dev_unassign_srv(dispcfg_srv_t *srv, ipc_call_t *icall)
     280{
     281        sysarg_t svc_id;
     282        errno_t rc;
     283
     284        svc_id = ipc_get_arg1(icall);
     285
     286        if (srv->ops->dev_unassign == NULL) {
     287                async_answer_0(icall, ENOTSUP);
     288                return;
     289        }
     290
     291        rc = srv->ops->dev_unassign(srv->arg, svc_id);
     292        async_answer_0(icall, rc);
     293}
     294
    261295static void dispcfg_get_event_srv(dispcfg_srv_t *srv, ipc_call_t *icall)
    262296{
     
    332366                case DISPCFG_SEAT_DELETE:
    333367                        dispcfg_seat_delete_srv(srv, &call);
     368                        break;
     369                case DISPCFG_DEV_ASSIGN:
     370                        dispcfg_dev_assign_srv(srv, &call);
     371                        break;
     372                case DISPCFG_DEV_UNASSIGN:
     373                        dispcfg_dev_unassign_srv(srv, &call);
    334374                        break;
    335375                case DISPCFG_GET_EVENT:
  • uspace/lib/dispcfg/test/dispcfg.c

    r46b02cb rb3eeae5  
    5050static errno_t test_seat_create(void *, const char *, sysarg_t *);
    5151static errno_t test_seat_delete(void *, sysarg_t);
     52static errno_t test_dev_assign(void *, sysarg_t, sysarg_t);
     53static errno_t test_dev_unassign(void *, sysarg_t);
    5254static errno_t test_get_event(void *, dispcfg_ev_t *);
    5355
     
    6062        .seat_create = test_seat_create,
    6163        .seat_delete = test_seat_delete,
     64        .dev_assign = test_dev_assign,
     65        .dev_unassign = test_dev_unassign,
    6266        .get_event = test_get_event
    6367};
     
    9195        bool seat_delete_called;
    9296        sysarg_t seat_delete_seat_id;
     97
     98        bool dev_assign_called;
     99        sysarg_t dev_assign_svc_id;
     100        sysarg_t dev_assign_seat_id;
     101
     102        bool dev_unassign_called;
     103        sysarg_t dev_unassign_svc_id;
    93104
    94105        bool get_event_called;
     
    443454}
    444455
     456/** dispcfg_dev_assign() with server returning error response works */
     457PCUT_TEST(dev_assign_failure)
     458{
     459        errno_t rc;
     460        service_id_t sid;
     461        dispcfg_t *dispcfg = NULL;
     462        sysarg_t svc_id;
     463        sysarg_t seat_id;
     464        test_response_t resp;
     465
     466        async_set_fallback_port_handler(test_dispcfg_conn, &resp);
     467
     468        // FIXME This causes this test to be non-reentrant!
     469        rc = loc_server_register(test_dispcfg_server);
     470        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     471
     472        rc = loc_service_register(test_dispcfg_svc, &sid);
     473        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     474
     475        rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
     476        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     477        PCUT_ASSERT_NOT_NULL(dispcfg);
     478
     479        svc_id = 12;
     480        seat_id = 13;
     481        resp.rc = ENOMEM;
     482        resp.dev_assign_called = false;
     483
     484        rc = dispcfg_dev_assign(dispcfg, svc_id, seat_id);
     485        PCUT_ASSERT_TRUE(resp.dev_assign_called);
     486        PCUT_ASSERT_INT_EQUALS(svc_id, resp.dev_assign_svc_id);
     487        PCUT_ASSERT_INT_EQUALS(seat_id, resp.dev_assign_seat_id);
     488        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     489
     490        dispcfg_close(dispcfg);
     491        rc = loc_service_unregister(sid);
     492        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     493}
     494
     495/** dispcfg_dev_assign() with server returning success response works */
     496PCUT_TEST(dev_assign_success)
     497{
     498        errno_t rc;
     499        service_id_t sid;
     500        dispcfg_t *dispcfg = NULL;
     501        sysarg_t svc_id;
     502        sysarg_t seat_id;
     503        test_response_t resp;
     504
     505        async_set_fallback_port_handler(test_dispcfg_conn, &resp);
     506
     507        // FIXME This causes this test to be non-reentrant!
     508        rc = loc_server_register(test_dispcfg_server);
     509        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     510
     511        rc = loc_service_register(test_dispcfg_svc, &sid);
     512        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     513
     514        rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
     515        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     516        PCUT_ASSERT_NOT_NULL(dispcfg);
     517
     518        svc_id = 12;
     519        seat_id = 13;
     520        resp.rc = EOK;
     521        resp.dev_assign_called = false;
     522
     523        rc = dispcfg_dev_assign(dispcfg, svc_id, seat_id);
     524        PCUT_ASSERT_TRUE(resp.dev_assign_called);
     525        PCUT_ASSERT_INT_EQUALS(svc_id, resp.dev_assign_svc_id);
     526        PCUT_ASSERT_INT_EQUALS(seat_id, resp.dev_assign_seat_id);
     527        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     528
     529        dispcfg_close(dispcfg);
     530        rc = loc_service_unregister(sid);
     531        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     532}
     533
     534/** dispcfg_dev_unassign() with server returning error response works */
     535PCUT_TEST(dev_unassign_failure)
     536{
     537        errno_t rc;
     538        service_id_t sid;
     539        dispcfg_t *dispcfg = NULL;
     540        sysarg_t svc_id;
     541        test_response_t resp;
     542
     543        async_set_fallback_port_handler(test_dispcfg_conn, &resp);
     544
     545        // FIXME This causes this test to be non-reentrant!
     546        rc = loc_server_register(test_dispcfg_server);
     547        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     548
     549        rc = loc_service_register(test_dispcfg_svc, &sid);
     550        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     551
     552        rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
     553        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     554        PCUT_ASSERT_NOT_NULL(dispcfg);
     555
     556        svc_id = 12;
     557        resp.rc = ENOMEM;
     558        resp.dev_unassign_called = false;
     559
     560        rc = dispcfg_dev_unassign(dispcfg, svc_id);
     561        PCUT_ASSERT_TRUE(resp.dev_unassign_called);
     562        PCUT_ASSERT_INT_EQUALS(svc_id, resp.dev_unassign_svc_id);
     563        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     564
     565        dispcfg_close(dispcfg);
     566        rc = loc_service_unregister(sid);
     567        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     568}
     569
     570/** dispcfg_dev_unassign() with server returning success response works */
     571PCUT_TEST(dev_unassign_success)
     572{
     573        errno_t rc;
     574        service_id_t sid;
     575        dispcfg_t *dispcfg = NULL;
     576        sysarg_t svc_id;
     577        test_response_t resp;
     578
     579        async_set_fallback_port_handler(test_dispcfg_conn, &resp);
     580
     581        // FIXME This causes this test to be non-reentrant!
     582        rc = loc_server_register(test_dispcfg_server);
     583        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     584
     585        rc = loc_service_register(test_dispcfg_svc, &sid);
     586        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     587
     588        rc = dispcfg_open(test_dispcfg_svc, NULL, NULL, &dispcfg);
     589        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     590        PCUT_ASSERT_NOT_NULL(dispcfg);
     591
     592        svc_id = 12;
     593        resp.rc = EOK;
     594        resp.dev_unassign_called = false;
     595
     596        rc = dispcfg_dev_unassign(dispcfg, svc_id);
     597        PCUT_ASSERT_TRUE(resp.dev_unassign_called);
     598        PCUT_ASSERT_INT_EQUALS(svc_id, resp.dev_unassign_svc_id);
     599        PCUT_ASSERT_ERRNO_VAL(resp.rc, rc);
     600
     601        dispcfg_close(dispcfg);
     602        rc = loc_service_unregister(sid);
     603        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     604}
     605
    445606/** Window added event can be delivered from server to client callback function */
    446607PCUT_TEST(seat_added_deliver)
     
    628789}
    629790
     791static errno_t test_dev_assign(void *arg, sysarg_t svc_id, sysarg_t seat_id)
     792{
     793        test_response_t *resp = (test_response_t *) arg;
     794
     795        resp->dev_assign_called = true;
     796        resp->dev_assign_svc_id = svc_id;
     797        resp->dev_assign_seat_id = seat_id;
     798        return resp->rc;
     799}
     800
     801static errno_t test_dev_unassign(void *arg, sysarg_t svc_id)
     802{
     803        test_response_t *resp = (test_response_t *) arg;
     804
     805        resp->dev_unassign_called = true;
     806        resp->dev_unassign_svc_id = svc_id;
     807        return resp->rc;
     808}
     809
    630810static errno_t test_get_event(void *arg, dispcfg_ev_t *event)
    631811{
  • 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 *
  • uspace/srv/hid/display/display.c

    r46b02cb rb3eeae5  
    101101        disp->next_wnd_id = 1;
    102102        list_initialize(&disp->ddevs);
     103        list_initialize(&disp->idevcfgs);
    103104        list_initialize(&disp->seats);
    104105        list_initialize(&disp->windows);
     
    124125        assert(list_empty(&disp->seats));
    125126        assert(list_empty(&disp->ddevs));
     127        assert(list_empty(&disp->idevcfgs));
    126128        assert(list_empty(&disp->seats));
    127129        assert(list_empty(&disp->windows));
     
    623625ds_seat_t *ds_display_seat_by_idev(ds_display_t *disp, ds_idev_id_t idev_id)
    624626{
    625         // TODO Multi-seat
    626         (void) idev_id;
    627 
     627        ds_idevcfg_t *idevcfg;
     628
     629        /*
     630         * Find input device configuration entry that maps this input device
     631         * to a seat.
     632         */
     633        idevcfg = ds_display_first_idevcfg(disp);
     634        while (idevcfg != NULL) {
     635                if (idevcfg->svc_id == idev_id)
     636                        return idevcfg->seat;
     637
     638                idevcfg = ds_display_next_idevcfg(idevcfg);
     639        }
     640
     641        /* If none was found, return the default seat */
    628642        return ds_display_first_seat(disp);
    629643}
     
    772786
    773787        return list_get_instance(link, ds_ddev_t, lddevs);
     788}
     789
     790/** Add input device configuration entry to display.
     791 *
     792 * @param disp Display
     793 * @param idevcfg Input device configuration
     794 */
     795void ds_display_add_idevcfg(ds_display_t *disp, ds_idevcfg_t *idevcfg)
     796{
     797        assert(idevcfg->display == NULL);
     798        assert(!link_used(&idevcfg->lidevcfgs));
     799
     800        idevcfg->display = disp;
     801        list_append(&idevcfg->lidevcfgs, &disp->idevcfgs);
     802}
     803
     804/** Remove input device configuration entry from display.
     805 *
     806 * @param idevcfg Input device configuration entry
     807 */
     808void ds_display_remove_idevcfg(ds_idevcfg_t *idevcfg)
     809{
     810        list_remove(&idevcfg->lidevcfgs);
     811        idevcfg->display = NULL;
     812}
     813
     814/** Get first input device configuration entry in display.
     815 *
     816 * @param disp Display
     817 * @return First input device configuration entry or @c NULL if there is none
     818 */
     819ds_idevcfg_t *ds_display_first_idevcfg(ds_display_t *disp)
     820{
     821        link_t *link = list_first(&disp->idevcfgs);
     822
     823        if (link == NULL)
     824                return NULL;
     825
     826        return list_get_instance(link, ds_idevcfg_t, lidevcfgs);
     827}
     828
     829/** Get next input device configuration entry in display.
     830 *
     831 * @param idevcfg Current input device configuration entry
     832 * @return Next input device configuration entry or @c NULL if there is none
     833 */
     834ds_idevcfg_t *ds_display_next_idevcfg(ds_idevcfg_t *idevcfg)
     835{
     836        link_t *link = list_next(&idevcfg->lidevcfgs, &idevcfg->display->idevcfgs);
     837
     838        if (link == NULL)
     839                return NULL;
     840
     841        return list_get_instance(link, ds_idevcfg_t, lidevcfgs);
    774842}
    775843
  • uspace/srv/hid/display/display.h

    r46b02cb rb3eeae5  
    4848#include "types/display/display.h"
    4949#include "types/display/idev.h"
     50#include "types/display/idevcfg.h"
    5051#include "types/display/ptd_event.h"
    5152#include "types/display/seat.h"
     
    9091extern ds_ddev_t *ds_display_first_ddev(ds_display_t *);
    9192extern ds_ddev_t *ds_display_next_ddev(ds_ddev_t *);
     93extern void ds_display_add_idevcfg(ds_display_t *, ds_idevcfg_t *);
     94extern void ds_display_remove_idevcfg(ds_idevcfg_t *);
     95extern ds_idevcfg_t *ds_display_first_idevcfg(ds_display_t *);
     96extern ds_idevcfg_t *ds_display_next_idevcfg(ds_idevcfg_t *);
    9297extern void ds_display_add_cursor(ds_display_t *, ds_cursor_t *);
    9398extern void ds_display_remove_cursor(ds_cursor_t *);
  • uspace/srv/hid/display/meson.build

    r46b02cb rb3eeae5  
    3939        'display.c',
    4040        'dsops.c',
     41        'idevcfg.c',
    4142        'input.c',
    4243        'main.c',
     
    5657        'ddev.c',
    5758        'display.c',
     59        'idevcfg.c',
    5860        'seat.c',
    5961        'window.c',
  • uspace/srv/hid/display/test/display.c

    r46b02cb rb3eeae5  
    3535#include "../client.h"
    3636#include "../display.h"
     37#include "../idevcfg.h"
    3738#include "../seat.h"
    3839#include "../window.h"
     
    397398}
    398399
     400/** Basic idevcfg operation */
     401PCUT_TEST(display_idevcfg)
     402{
     403        ds_display_t *disp;
     404        ds_seat_t *seat;
     405        ds_idevcfg_t *idevcfg;
     406        errno_t rc;
     407
     408        rc = ds_display_create(NULL, df_none, &disp);
     409        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     410
     411        rc = ds_seat_create(disp, "Alice", &seat);
     412        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     413
     414        rc = ds_idevcfg_create(disp, 42, seat, &idevcfg);
     415        PCUT_ASSERT_ERRNO_VAL(EOK, rc);
     416
     417        ds_idevcfg_destroy(idevcfg);
     418
     419        ds_seat_destroy(seat);
     420        ds_display_destroy(disp);
     421}
     422
    399423/** Basic seat operation. */
    400424PCUT_TEST(display_seat)
  • uspace/srv/hid/display/types/display/display.h

    r46b02cb rb3eeae5  
    9090        list_t ddevs;
    9191
     92        /** Input device configuration entries (of ds_idevcfg_t) */
     93        list_t idevcfgs;
     94
    9295        /** Background color */
    9396        gfx_color_t *bg_color;
Note: See TracChangeset for help on using the changeset viewer.