/**************************************************************************
-
-libtdm
-
-Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
-
-Contact: Eunchul Kim <chulspro.kim@samsung.com>,
- JinYoung Jeon <jy0.jeon@samsung.com>,
- Taeheon Kim <th908.kim@samsung.com>,
- YoungJun Cho <yj44.cho@samsung.com>,
- SooChan Lim <sc1.lim@samsung.com>,
- Boram Park <sc1.lim@samsung.com>
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
+ *
+ * libtdm
+ *
+ * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved.
+ *
+ * Contact: Eunchul Kim <chulspro.kim@samsung.com>,
+ * JinYoung Jeon <jy0.jeon@samsung.com>,
+ * Taeheon Kim <th908.kim@samsung.com>,
+ * YoungJun Cho <yj44.cho@samsung.com>,
+ * SooChan Lim <sc1.lim@samsung.com>,
+ * Boram Park <sc1.lim@samsung.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
**************************************************************************/
#ifdef HAVE_CONFIG_H
static void
_tdm_server_send_done(tdm_server_vblank_info *vblank_info, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec);
+ unsigned int tv_sec, unsigned int tv_usec);
static tdm_error
_tdm_server_cb_timer(void *user_data)
tdm_server_vblank_info *vblank_info = (tdm_server_vblank_info*)user_data;
_tdm_server_send_done(vblank_info, 0,
- vblank_info->timer_target_sec,
- vblank_info->timer_target_usec);
+ vblank_info->timer_target_sec,
+ vblank_info->timer_target_usec);
return TDM_ERROR_NONE;
}
tdm_private_server *private_server = client_info->private_server;
tdm_private_loop *private_loop = private_server->private_loop;
unsigned long last, prev_req, req, curr, next;
- int ms_delay;
+ unsigned int ms_delay;
tdm_error ret;
ret = tdm_display_lock(private_loop->dpy);
if (!vblank_info->timer_source) {
vblank_info->timer_source =
tdm_event_loop_add_timer_handler(private_loop->dpy,
- _tdm_server_cb_timer,
- vblank_info,
- NULL);
+ _tdm_server_cb_timer,
+ vblank_info,
+ NULL);
if (!vblank_info->timer_source) {
TDM_ERR("couldn't add timer");
tdm_display_unlock(private_loop->dpy);
next += (unsigned long)client_info->vblank_gap;
TDM_DBG("last(%.6lu) req(%.6lu) curr(%.6lu) prev_req(%.6lu) next(%.6lu)",
- last, req, curr, prev_req, next);
+ last, req, curr, prev_req, next);
- ms_delay = (int)ceil((double)(next - curr) / 1000);
+ ms_delay = (unsigned int)ceil((double)(next - curr) / 1000);
if (ms_delay == 0)
ms_delay = 1;
static void
_tdm_server_send_done(tdm_server_vblank_info *vblank_info, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec)
+ unsigned int tv_sec, unsigned int tv_usec)
{
tdm_server_vblank_info *found;
tdm_server_client_info *client_info;
return;
LIST_FIND_ITEM(vblank_info, &keep_private_server->vblank_list,
- tdm_server_vblank_info, link, found);
+ tdm_server_vblank_info, link, found);
if (!found) {
TDM_DBG("vblank_info(%p) is destroyed", vblank_info);
return;
client_info->last_tv_usec = tv_usec;
TDM_DBG("wl_tdm_vblank@%d done. tv(%lu) curr(%lu)",
- wl_resource_get_id(vblank_info->resource), vtime, curr);
+ wl_resource_get_id(vblank_info->resource), vtime, curr);
if (tdm_debug_server) {
if (curr - vtime > 1000) /* 1ms */
static void
_tdm_server_cb_output_vblank(tdm_output *output, unsigned int sequence,
- unsigned int tv_sec, unsigned int tv_usec,
- void *user_data)
+ unsigned int tv_sec, unsigned int tv_usec,
+ void *user_data)
{
tdm_server_vblank_info *vblank_info = (tdm_server_vblank_info*)user_data;
static void
_tdm_server_client_cb_wait_vblank(struct wl_client *client,
- struct wl_resource *resource,
- uint32_t id, const char *name,
- int32_t sw_timer, int32_t interval,
- uint32_t req_sec, uint32_t req_usec)
+ struct wl_resource *resource,
+ uint32_t id, const char *name,
+ int32_t sw_timer, int32_t interval,
+ uint32_t req_sec, uint32_t req_usec)
{
tdm_server_client_info *client_info = wl_resource_get_user_data(resource);
tdm_private_server *private_server = client_info->private_server;
found = client_info->vblank_output;
}
+ if (!strncmp(name, "primary", TDM_NAME_LEN))
+ found = tdm_display_get_output(private_loop->dpy, 0, NULL);
+
if (!found) {
int count = 0, i;
tdm_display_get_output_count(private_loop->dpy, &count);
for (i = 0; i < count; i++) {
- tdm_output *output= tdm_display_get_output(private_loop->dpy, i, NULL);
+ tdm_output *output = tdm_display_get_output(private_loop->dpy, i, NULL);
tdm_output_conn_status status;
ret = tdm_output_get_conn_status(output, &status);
if (!found) {
wl_resource_post_error(resource, WL_TDM_CLIENT_ERROR_INVALID_NAME,
- "There is no '%s' output", name);
+ "There is no '%s' output", name);
TDM_ERR("There is no '%s' output", name);
return;
}
tdm_output_get_mode(client_info->vblank_output, &mode);
if (!mode || mode->vrefresh <= 0) {
wl_resource_post_error(resource, WL_TDM_CLIENT_ERROR_OPERATION_FAILED,
- "couldn't get mode of %s", name);
+ "couldn't get mode of %s", name);
TDM_ERR("couldn't get mode of %s", name);
return;
}
if (dpms_value != TDM_OUTPUT_DPMS_ON && !sw_timer) {
wl_resource_post_error(resource, WL_TDM_CLIENT_ERROR_DPMS_OFF,
- "dpms '%s'", tdm_get_dpms_str(dpms_value));
+ "dpms '%s'", tdm_get_dpms_str(dpms_value));
TDM_ERR("dpms '%s'", tdm_get_dpms_str(dpms_value));
return;
}
- vblank_info = calloc(1, sizeof *vblank_info);
+ vblank_info = calloc(1, sizeof * vblank_info);
if (!vblank_info) {
wl_resource_post_no_memory(resource);
TDM_ERR("alloc failed");
vblank_resource =
wl_resource_create(client, &wl_tdm_vblank_interface,
- wl_resource_get_version(resource), id);
+ wl_resource_get_version(resource), id);
if (!vblank_resource) {
wl_resource_post_no_memory(resource);
TDM_ERR("wl_resource_create failed");
if (dpms_value == TDM_OUTPUT_DPMS_ON) {
ret = tdm_output_wait_vblank(found, interval, 0,
- _tdm_server_cb_output_vblank, vblank_info);
+ _tdm_server_cb_output_vblank, vblank_info);
if (ret != TDM_ERROR_NONE) {
wl_resource_post_error(resource, WL_TDM_CLIENT_ERROR_OPERATION_FAILED,
- "couldn't wait vblank for %s", name);
+ "couldn't wait vblank for %s", name);
TDM_ERR("couldn't wait vblank for %s", name);
goto destroy_resource;
}
ret = _tdm_server_update_timer(vblank_info, interval);
if (ret != TDM_ERROR_NONE) {
wl_resource_post_error(resource, WL_TDM_CLIENT_ERROR_OPERATION_FAILED,
- "couldn't update timer for %s", name);
+ "couldn't update timer for %s", name);
TDM_ERR("couldn't update timer for %s", name);
goto destroy_resource;
}
} else {
wl_resource_post_error(resource, WL_TDM_CLIENT_ERROR_OPERATION_FAILED,
- "bad implementation");
+ "bad implementation");
TDM_NEVER_GET_HERE();
goto destroy_resource;
}
wl_resource_set_implementation(vblank_resource, NULL, vblank_info,
- destroy_vblank_callback);
+ destroy_vblank_callback);
LIST_ADDTAIL(&vblank_info->link, &private_server->vblank_list);
return;
static void
_tdm_server_cb_create_client(struct wl_client *client,
- struct wl_resource *resource, uint32_t id)
+ struct wl_resource *resource, uint32_t id)
{
tdm_private_server *private_server = wl_resource_get_user_data(resource);
tdm_server_client_info *client_info;
struct wl_resource *client_resource;
- client_info = calloc(1, sizeof *client_info);
+ client_info = calloc(1, sizeof * client_info);
if (!client_info) {
wl_resource_post_no_memory(resource);
TDM_ERR("alloc failed");
client_resource =
wl_resource_create(client, &wl_tdm_client_interface,
- wl_resource_get_version(resource), id);
+ wl_resource_get_version(resource), id);
if (!client_resource) {
wl_resource_post_no_memory(resource);
free(client_info);
client_info->resource = client_resource;
wl_resource_set_implementation(client_resource, &tdm_client_implementation,
- client_info, destroy_client_callback);
+ client_info, destroy_client_callback);
LIST_ADDTAIL(&client_info->link, &private_server->client_list);
}
static void
_tdm_server_bind(struct wl_client *client, void *data,
- uint32_t version, uint32_t id)
+ uint32_t version, uint32_t id)
{
struct wl_resource *resource;
TDM_RETURN_VAL_IF_FAIL(private_loop, TDM_ERROR_OPERATION_FAILED);
TDM_RETURN_VAL_IF_FAIL(private_loop->wl_display, TDM_ERROR_OPERATION_FAILED);
- if(wl_display_add_socket(private_loop->wl_display, "tdm-socket")) {
+ if (wl_display_add_socket(private_loop->wl_display, "tdm-socket")) {
TDM_ERR("createing a tdm-socket failed");
return TDM_ERROR_OPERATION_FAILED;
}
- private_server = calloc(1, sizeof *private_server);
+ private_server = calloc(1, sizeof * private_server);
if (!private_server) {
TDM_ERR("alloc failed");
return TDM_ERROR_OUT_OF_MEMORY;
LIST_INITHEAD(&private_server->vblank_list);
if (!wl_global_create(private_loop->wl_display, &wl_tdm_interface, 1,
- private_server, _tdm_server_bind)) {
+ private_server, _tdm_server_bind)) {
TDM_ERR("creating a global resource failed");
free(private_server);
return TDM_ERROR_OUT_OF_MEMORY;