Changeset c0757e1f in mainline for uspace/lib/dispcfg/src


Ignore:
Timestamp:
2023-04-19T11:13:06Z (3 years 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.

Location:
uspace/lib/dispcfg/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/dispcfg/src/dispcfg.c

    rec8ef12 rc0757e1f  
    206206/** Free seat list.
    207207 *
    208  * @param list Display configuration list
     208 * @param list Seat list
    209209 */
    210210void dispcfg_free_seat_list(dispcfg_seat_list_t *list)
     
    277277/** Free seat information.
    278278 *
    279  * @param info Display configuration information
     279 * @param info Seat information
    280280 */
    281281void dispcfg_free_seat_info(dispcfg_seat_info_t *info)
     
    378378        async_exchange_end(exch);
    379379        return rc;
     380}
     381
     382/** Get list of devices assigned to a seat.
     383 *
     384 * @param dispcfg Display configuration
     385 * @param seat_id Seat ID
     386 * @param rlist Place to store pointer to new device list structure
     387 * @return EOK on success or an error code
     388 */
     389errno_t dispcfg_get_asgn_dev_list(dispcfg_t *dispcfg, sysarg_t seat_id,
     390    dispcfg_dev_list_t **rlist)
     391{
     392        async_exch_t *exch;
     393        aid_t req;
     394        ipc_call_t answer;
     395        dispcfg_dev_list_t *list;
     396        sysarg_t ndevs;
     397        sysarg_t *devs;
     398        errno_t rc;
     399
     400        exch = async_exchange_begin(dispcfg->sess);
     401        req = async_send_1(exch, DISPCFG_GET_ASGN_DEV_LIST, seat_id, &answer);
     402
     403        /* Receive device list length */
     404        rc = async_data_read_start(exch, &ndevs, sizeof (ndevs));
     405        if (rc != EOK) {
     406                async_exchange_end(exch);
     407                async_wait_for(req, &rc);
     408                return rc;
     409        }
     410
     411        devs = calloc(ndevs, sizeof(sysarg_t));
     412        if (devs == NULL) {
     413                async_exchange_end(exch);
     414                async_forget(req);
     415                return ENOMEM;
     416        }
     417
     418        /* Receive device list */
     419        rc = async_data_read_start(exch, devs, ndevs * sizeof (sysarg_t));
     420        async_exchange_end(exch);
     421
     422        if (rc != EOK) {
     423                async_forget(req);
     424                return rc;
     425        }
     426
     427        async_wait_for(req, &rc);
     428        if (rc != EOK)
     429                return rc;
     430
     431        list = calloc(1, sizeof(dispcfg_dev_list_t));
     432        if (list == NULL)
     433                return ENOMEM;
     434
     435        list->ndevs = ndevs;
     436        list->devs = devs;
     437        *rlist = list;
     438        return EOK;
     439}
     440
     441/** Free device list.
     442 *
     443 * @param list Device list
     444 */
     445void dispcfg_free_dev_list(dispcfg_dev_list_t *list)
     446{
     447        free(list->devs);
     448        free(list);
    380449}
    381450
  • uspace/lib/dispcfg/src/dispcfg_srv.c

    rec8ef12 rc0757e1f  
    293293}
    294294
     295static void dispcfg_get_asgn_dev_list_srv(dispcfg_srv_t *srv, ipc_call_t *icall)
     296{
     297        sysarg_t seat_id;
     298        ipc_call_t call;
     299        dispcfg_dev_list_t *list = NULL;
     300        size_t size;
     301        errno_t rc;
     302
     303        seat_id = ipc_get_arg1(icall);
     304
     305        if (srv->ops->get_asgn_dev_list == NULL) {
     306                async_answer_0(icall, ENOTSUP);
     307                return;
     308        }
     309
     310        rc = srv->ops->get_asgn_dev_list(srv->arg, seat_id, &list);
     311        if (rc != EOK) {
     312                async_answer_0(icall, rc);
     313                return;
     314        }
     315
     316        /* Send list size */
     317
     318        if (!async_data_read_receive(&call, &size)) {
     319                dispcfg_free_dev_list(list);
     320                async_answer_0(&call, EREFUSED);
     321                async_answer_0(icall, EREFUSED);
     322                return;
     323        }
     324
     325        if (size != sizeof(list->ndevs)) {
     326                dispcfg_free_dev_list(list);
     327                async_answer_0(&call, EINVAL);
     328                async_answer_0(icall, EINVAL);
     329                return;
     330        }
     331
     332        rc = async_data_read_finalize(&call, &list->ndevs, size);
     333        if (rc != EOK) {
     334                dispcfg_free_dev_list(list);
     335                async_answer_0(&call, rc);
     336                async_answer_0(icall, rc);
     337                return;
     338        }
     339
     340        /* Send device list */
     341
     342        if (!async_data_read_receive(&call, &size)) {
     343                dispcfg_free_dev_list(list);
     344                async_answer_0(&call, EREFUSED);
     345                async_answer_0(icall, EREFUSED);
     346                return;
     347        }
     348
     349        if (size != list->ndevs * sizeof(sysarg_t)) {
     350                dispcfg_free_dev_list(list);
     351                async_answer_0(&call, EINVAL);
     352                async_answer_0(icall, EINVAL);
     353                return;
     354        }
     355
     356        rc = async_data_read_finalize(&call, list->devs, size);
     357        if (rc != EOK) {
     358                dispcfg_free_dev_list(list);
     359                async_answer_0(&call, rc);
     360                async_answer_0(icall, rc);
     361                return;
     362        }
     363
     364        async_answer_0(icall, EOK);
     365        dispcfg_free_dev_list(list);
     366}
     367
    295368static void dispcfg_get_event_srv(dispcfg_srv_t *srv, ipc_call_t *icall)
    296369{
     
    372445                case DISPCFG_DEV_UNASSIGN:
    373446                        dispcfg_dev_unassign_srv(srv, &call);
     447                        break;
     448                case DISPCFG_GET_ASGN_DEV_LIST:
     449                        dispcfg_get_asgn_dev_list_srv(srv, &call);
    374450                        break;
    375451                case DISPCFG_GET_EVENT:
Note: See TracChangeset for help on using the changeset viewer.