2 * Copyright (c) 2019 Jiri Svoboda
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <ipc/services.h>
34 #include <ipcgfx/client.h>
38 /** Open display device.
40 * @param ddname Display device service name
41 * @param rdisplay Place to store pointer to display session
42 * @return EOK on success or an error code
44 errno_t
ddev_open(const char *ddname
, ddev_t
**rddev
)
46 service_id_t ddev_svc
;
50 ddev
= calloc(1, sizeof(ddev_t
));
54 rc
= loc_service_get_id(ddname
, &ddev_svc
, IPC_FLAG_BLOCKING
);
60 ddev
->sess
= loc_service_connect(ddev_svc
, INTERFACE_DDEV
,
62 if (ddev
->sess
== NULL
) {
71 /** Close display device.
73 * @param ddev Display device session
75 void ddev_close(ddev_t
*ddev
)
77 async_hangup(ddev
->sess
);
81 /** Create graphics context for drawing to display device.
83 * @param ddev Display device
84 * @param rgc Place to store pointer to new graphics context
86 errno_t
ddev_get_gc(ddev_t
*ddev
, gfx_context_t
**rgc
)
95 exch
= async_exchange_begin(ddev
->sess
);
96 rc
= async_req_0_2(exch
, DDEV_GET_GC
, &arg2
, &arg3
);
98 async_exchange_end(exch
);
102 sess
= async_connect_me_to(exch
, INTERFACE_GC
, arg2
, arg3
, &rc
);
103 async_exchange_end(exch
);
108 rc
= ipc_gc_create(sess
, &gc
);
114 *rgc
= ipc_gc_get_ctx(gc
);
118 /** Get display device information.
120 * @param ddev Display device
121 * @param info Place to store information
123 errno_t
ddev_get_info(ddev_t
*ddev
, ddev_info_t
*info
)
129 exch
= async_exchange_begin(ddev
->sess
);
130 aid_t req
= async_send_0(exch
, DDEV_GET_INFO
, &answer
);
132 errno_t rc
= async_data_read_start(exch
, info
, sizeof(ddev_info_t
));
133 async_exchange_end(exch
);
139 async_wait_for(req
, &retval
);