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


Ignore:
Timestamp:
2023-04-19T11:13:06Z (20 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
37087c8
Parents:
ec8ef12
Message:

UI display configuration utility

In addition to the command-line utility 'disp', we introduce its UI
equivalent 'display-cfg'. Currently this allows the user to configure
seats in a very comfortable way.

File:
1 edited

Legend:

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

    rec8ef12 rc0757e1f  
    5050static errno_t dispc_dev_assign(void *, sysarg_t, sysarg_t);
    5151static errno_t dispc_dev_unassign(void *, sysarg_t);
     52static errno_t dispc_get_asgn_dev_list(void *, sysarg_t, dispcfg_dev_list_t **);
    5253static errno_t dispc_get_event(void *, dispcfg_ev_t *);
    5354
     
    5960        .dev_assign = dispc_dev_assign,
    6061        .dev_unassign = dispc_dev_unassign,
     62        .get_asgn_dev_list = dispc_get_asgn_dev_list,
    6163        .get_event = dispc_get_event,
    6264};
     
    281283}
    282284
     285/** Get assigned device list.
     286 *
     287 * @param arg Argument (CFG client)
     288 * @param seat_id Seat ID
     289 * @param rlist Place to store pointer to new list
     290 * @return EOK on success or an error code
     291 */
     292static errno_t dispc_get_asgn_dev_list(void *arg, sysarg_t seat_id,
     293    dispcfg_dev_list_t **rlist)
     294{
     295        ds_cfgclient_t *cfgclient = (ds_cfgclient_t *)arg;
     296        dispcfg_dev_list_t *list;
     297        ds_seat_t *seat;
     298        ds_idevcfg_t *idevcfg;
     299        unsigned i;
     300
     301        log_msg(LOG_DEFAULT, LVL_DEBUG, "dispcfg_get_asgn_dev_list()");
     302
     303        list = calloc(1, sizeof(dispcfg_dev_list_t));
     304        if (list == NULL)
     305                return ENOMEM;
     306
     307        ds_display_lock(cfgclient->display);
     308
     309        seat = ds_display_find_seat(cfgclient->display, seat_id);
     310        if (seat == NULL) {
     311                ds_display_unlock(cfgclient->display);
     312                free(list);
     313                return ENOENT;
     314        }
     315
     316        /* Count the number of devices */
     317        list->ndevs = 0;
     318        idevcfg = ds_seat_first_idevcfg(seat);
     319        while (idevcfg != NULL) {
     320                ++list->ndevs;
     321                idevcfg = ds_display_next_idevcfg(idevcfg);
     322        }
     323
     324        /* Allocate array for device IDs */
     325        list->devs = calloc(list->ndevs, sizeof(sysarg_t));
     326        if (list->devs == NULL) {
     327                ds_display_unlock(cfgclient->display);
     328                free(list);
     329                return ENOMEM;
     330        }
     331
     332        /* Fill in device IDs */
     333        i = 0;
     334        idevcfg = ds_seat_first_idevcfg(seat);
     335        while (idevcfg != NULL) {
     336                list->devs[i++] = idevcfg->svc_id;
     337                idevcfg = ds_display_next_idevcfg(idevcfg);
     338        }
     339
     340        ds_display_unlock(cfgclient->display);
     341        *rlist = list;
     342        return EOK;
     343}
     344
    283345/** Get display configuration event.
    284346 *
Note: See TracChangeset for help on using the changeset viewer.