From a96653d12ad8b320812307b3d1d6cb8b35fe9e78 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 30 May 2016 11:04:45 +0900 Subject: [PATCH 01/16] apply tizen coding rule Change-Id: I4557e1e0aa1a8d1ed026444f0caf480a66bb9c28 --- client/tdm_client.c | 106 ++++++++-------- client/tdm_client.h | 127 ++++++++++--------- doc/tdm_doc.h | 172 +++++++++++++------------- include/tdm.h | 125 ++++++++++--------- include/tdm_backend.h | 255 +++++++++++++++++++------------------- include/tdm_helper.h | 64 +++++----- include/tdm_list.h | 16 +-- include/tdm_log.h | 70 +++++------ include/tdm_types.h | 94 +++++++------- src/tdm.c | 151 +++++++++++------------ src/tdm_backend.c | 78 ++++++------ src/tdm_buffer.c | 79 ++++++------ src/tdm_capture.c | 96 +++++++-------- src/tdm_display.c | 321 ++++++++++++++++++++++++------------------------ src/tdm_event_loop.c | 103 ++++++++-------- src/tdm_helper.c | 91 +++++++++----- src/tdm_macro.h | 141 +++++++++++---------- src/tdm_pp.c | 106 ++++++++-------- src/tdm_private.h | 92 +++++++------- src/tdm_server.c | 134 ++++++++++---------- src/tdm_thread.c | 103 ++++++++-------- tools/tdm_test_client.c | 66 +++++----- 22 files changed, 1299 insertions(+), 1291 deletions(-) diff --git a/client/tdm_client.c b/client/tdm_client.c index 5797af8..2560a87 100644 --- a/client/tdm_client.c +++ b/client/tdm_client.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -70,8 +70,8 @@ typedef struct _tdm_client_vblank_info { static void _tdm_client_cb_global(void *data, struct wl_registry *registry, - uint32_t name, const char *interface, - uint32_t version) + uint32_t name, const char *interface, + uint32_t version) { tdm_private_client *private_client = data; @@ -89,10 +89,9 @@ _tdm_client_cb_global_remove(void *data, struct wl_registry *registry, uint32_t { } -static const struct wl_registry_listener tdm_client_registry_listener = -{ - _tdm_client_cb_global, - _tdm_client_cb_global_remove +static const struct wl_registry_listener tdm_client_registry_listener = { + _tdm_client_cb_global, + _tdm_client_cb_global_remove }; tdm_client* @@ -105,7 +104,7 @@ tdm_client_create(tdm_client_error *error) if (debug && (strstr(debug, "1"))) tdm_debug = 1; - private_client = calloc(1, sizeof *private_client); + private_client = calloc(1, sizeof * private_client); if (!private_client) { TDM_ERR("alloc failed"); if (error) @@ -120,7 +119,7 @@ tdm_client_create(tdm_client_error *error) TDM_GOTO_IF_FAIL(private_client->registry != NULL, create_failed); wl_registry_add_listener(private_client->registry, - &tdm_client_registry_listener, private_client); + &tdm_client_registry_listener, private_client); wl_display_roundtrip(private_client->display); /* check global objects */ @@ -202,7 +201,7 @@ tdm_client_handle_events(tdm_client *client) static void _tdm_client_cb_vblank_done(void *data, struct wl_tdm_vblank *vblank, - uint32_t sequence, uint32_t tv_sec, uint32_t tv_usec) + uint32_t sequence, uint32_t tv_sec, uint32_t tv_usec) { tdm_client_vblank_info *vblank_info = (tdm_client_vblank_info*)data; @@ -212,11 +211,10 @@ _tdm_client_cb_vblank_done(void *data, struct wl_tdm_vblank *vblank, TDM_NEVER_GET_HERE(); TDM_DBG("vblank_info(%p) wl_tbm_vblank@%d", vblank_info, - wl_proxy_get_id((struct wl_proxy *)vblank)); + wl_proxy_get_id((struct wl_proxy *)vblank)); - if (vblank_info->func) { + if (vblank_info->func) vblank_info->func(sequence, tv_sec, tv_usec, vblank_info->user_data); - } if (vblank_info->need_free) { LIST_DEL(&vblank_info->link); @@ -232,8 +230,8 @@ static const struct wl_tdm_vblank_listener tdm_client_vblank_listener = { tdm_client_error tdm_client_wait_vblank(tdm_client *client, char *name, - int sw_timer, int interval, int sync, - tdm_client_vblank_handler func, void *user_data) + int sw_timer, int interval, int sync, + tdm_client_vblank_handler func, void *user_data) { tdm_private_client *private_client = (tdm_private_client*)client; tdm_client_vblank_info *vblank_info; @@ -246,7 +244,7 @@ tdm_client_wait_vblank(tdm_client *client, char *name, TDM_RETURN_VAL_IF_FAIL(private_client != NULL, TDM_CLIENT_ERROR_INVALID_PARAMETER); TDM_RETURN_VAL_IF_FAIL(private_client->tdm_client != NULL, TDM_CLIENT_ERROR_INVALID_PARAMETER); - vblank_info = calloc(1, sizeof *vblank_info); + vblank_info = calloc(1, sizeof * vblank_info); if (!vblank_info) { TDM_ERR("alloc failed"); return TDM_CLIENT_ERROR_OUT_OF_MEMORY; @@ -255,13 +253,13 @@ tdm_client_wait_vblank(tdm_client *client, char *name, clock_gettime(CLOCK_MONOTONIC, &tp); vblank_info->req_sec = (unsigned int)tp.tv_sec; - vblank_info->req_usec = (unsigned int)(tp.tv_nsec/1000); + vblank_info->req_usec = (unsigned int)(tp.tv_nsec / 1000); vblank_info->need_free = (sync) ? 0 : 1; vblank_info->vblank = wl_tdm_client_wait_vblank(private_client->tdm_client, - name, sw_timer, interval, - vblank_info->req_sec, vblank_info->req_usec); + name, sw_timer, interval, + vblank_info->req_sec, vblank_info->req_usec); if (!vblank_info->vblank) { TDM_ERR("couldn't create vblank resource"); free(vblank_info); @@ -269,10 +267,10 @@ tdm_client_wait_vblank(tdm_client *client, char *name, } TDM_DBG("vblank_info(%p) wl_tbm_vblank@%d", vblank_info, - wl_proxy_get_id((struct wl_proxy *)vblank_info->vblank)); + wl_proxy_get_id((struct wl_proxy *)vblank_info->vblank)); wl_tdm_vblank_add_listener(vblank_info->vblank, - &tdm_client_vblank_listener, vblank_info); + &tdm_client_vblank_listener, vblank_info); vblank_info->func = func; vblank_info->user_data = user_data; @@ -288,8 +286,8 @@ tdm_client_wait_vblank(tdm_client *client, char *name, clock_gettime(CLOCK_MONOTONIC, &tp); TDM_DBG("block during %d us", - ((unsigned int)(tp.tv_sec * 1000000) + (unsigned int)(tp.tv_nsec/1000)) - - (vblank_info->req_sec * 1000000 + vblank_info->req_usec)); + ((unsigned int)(tp.tv_sec * 1000000) + (unsigned int)(tp.tv_nsec / 1000)) + - (vblank_info->req_sec * 1000000 + vblank_info->req_usec)); LIST_DEL(&vblank_info->link); free(vblank_info); diff --git a/client/tdm_client.h b/client/tdm_client.h index 06e2c9b..a6a7a09 100644 --- a/client/tdm_client.h +++ b/client/tdm_client.h @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * **************************************************************************/ #ifndef _TDM_CLIENT_H_ @@ -45,15 +45,14 @@ extern "C" { * @brief The header file for a client of TDM. * @par Example * @code - #include //for a client of TDM + * #include //for a client of TDM * @endcode */ /** * @brief The client error enumeration */ -typedef enum -{ +typedef enum { TDM_CLIENT_ERROR_NONE = 0, /**< none */ TDM_CLIENT_ERROR_OPERATION_FAILED = -1, /**< operaion failed */ TDM_CLIENT_ERROR_INVALID_PARAMETER = -2, /**< wrong input parameter */ @@ -73,7 +72,7 @@ typedef void *tdm_client; */ typedef void (*tdm_client_vblank_handler)(unsigned int sequence, unsigned int tv_sec, - unsigned int tv_usec, void *user_data); + unsigned int tv_usec, void *user_data); /** * @brief Create a TDM client object. @@ -100,32 +99,32 @@ tdm_client_destroy(tdm_client *client); * @see #tdm_client_handle_events * @par Example * @code - #include //for a client of TDM - - err = tdm_client_get_fd(client, &fd); - if (err != TDM_CLIENT_ERROR_NONE) { - //error handling - } - - fds.events = POLLIN; - fds.fd = fd; - fds.revents = 0; - - while(1) { - ret = poll(&fds, 1, -1); - if (ret < 0) { - if (errno == EBUSY) - continue; - else { - //error handling - } - } - - err = tdm_client_handle_events(client); - if (err != TDM_CLIENT_ERROR_NONE) { - //error handling - } - } + * #include //for a client of TDM + * + * err = tdm_client_get_fd(client, &fd); + * if (err != TDM_CLIENT_ERROR_NONE) { + * //error handling + * } + * + * fds.events = POLLIN; + * fds.fd = fd; + * fds.revents = 0; + * + * while(1) { + * ret = poll(&fds, 1, -1); + * if (ret < 0) { + * if (errno == EBUSY) + * continue; + * else { + * //error handling + * } + * } + * + * err = tdm_client_handle_events(client); + * if (err != TDM_CLIENT_ERROR_NONE) { + * //error handling + * } + * } * @endcode */ tdm_client_error @@ -157,8 +156,8 @@ tdm_client_handle_events(tdm_client *client); */ tdm_client_error tdm_client_wait_vblank(tdm_client *client, char *name, - int sw_timer, int interval, int sync, - tdm_client_vblank_handler func, void *user_data); + int sw_timer, int interval, int sync, + tdm_client_vblank_handler func, void *user_data); #ifdef __cplusplus } diff --git a/doc/tdm_doc.h b/doc/tdm_doc.h index 4d60a64..1abca27 100644 --- a/doc/tdm_doc.h +++ b/doc/tdm_doc.h @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * **************************************************************************/ #ifndef _TDM_DOC_H_ @@ -73,60 +73,60 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * #tdm_backend_register_func_display(), #tdm_backend_register_func_output(), * #tdm_backend_register_func_layer() functions in initial time.\n * @code - #include - - static tdm_drm_data *drm_data; - - tdm_backend_data* - tdm_drm_init(tdm_display *dpy, tdm_error *error) - { - tdm_func_display drm_func_display; - tdm_func_output drm_func_output; - tdm_func_layer drm_func_layer; - - ... - drm_data = calloc(1, sizeof(tdm_drm_data)); - ... - - memset(&drm_func_display, 0, sizeof(drm_func_display)); - drm_func_display.display_get_capabilitiy = drm_display_get_capabilitiy; - ... - ret = tdm_backend_register_func_display(dpy, &drm_func_display); - if (ret != TDM_ERROR_NONE) - goto failed; - - memset(&drm_func_output, 0, sizeof(drm_func_output)); - drm_func_output.output_get_capability = drm_output_get_capability; - ... - ret = tdm_backend_register_func_output(dpy, &drm_func_output); - if (ret != TDM_ERROR_NONE) - goto failed; - - memset(&drm_func_layer, 0, sizeof(drm_func_layer)); - drm_func_layer.layer_get_capability = drm_layer_get_capability; - ... - ret = tdm_backend_register_func_layer(dpy, &drm_func_layer); - if (ret != TDM_ERROR_NONE) - goto failed; - ... - return (tdm_backend_data*)drm_data; - } - - void - tdm_drm_deinit(tdm_backend_data *bdata) - { - ... - free(bdata); - } - - tdm_backend_module tdm_backend_module_data = - { - "drm", - "Samsung", - TDM_BACKEND_SET_ABI_VERSION(1,2), - tdm_drm_init, - tdm_drm_deinit - }; + * #include + * + * static tdm_drm_data *drm_data; + * + * tdm_backend_data* + * tdm_drm_init(tdm_display *dpy, tdm_error *error) + * { + * tdm_func_display drm_func_display; + * tdm_func_output drm_func_output; + * tdm_func_layer drm_func_layer; + * + * ... + * drm_data = calloc(1, sizeof(tdm_drm_data)); + * ... + * + * memset(&drm_func_display, 0, sizeof(drm_func_display)); + * drm_func_display.display_get_capabilitiy = drm_display_get_capabilitiy; + * ... + * ret = tdm_backend_register_func_display(dpy, &drm_func_display); + * if (ret != TDM_ERROR_NONE) + * goto failed; + * + * memset(&drm_func_output, 0, sizeof(drm_func_output)); + * drm_func_output.output_get_capability = drm_output_get_capability; + * ... + * ret = tdm_backend_register_func_output(dpy, &drm_func_output); + * if (ret != TDM_ERROR_NONE) + * goto failed; + * + * memset(&drm_func_layer, 0, sizeof(drm_func_layer)); + * drm_func_layer.layer_get_capability = drm_layer_get_capability; + * ... + * ret = tdm_backend_register_func_layer(dpy, &drm_func_layer); + * if (ret != TDM_ERROR_NONE) + * goto failed; + * ... + * return (tdm_backend_data*)drm_data; + * } + * + * void + * tdm_drm_deinit(tdm_backend_data *bdata) + * { + * ... + * free(bdata); + * } + * + * tdm_backend_module tdm_backend_module_data = + * { + * "drm", + * "Samsung", + * TDM_BACKEND_SET_ABI_VERSION(1,2), + * tdm_drm_init, + * tdm_drm_deinit + * }; * @endcode * \n * A sample backend source code can be downloaded. diff --git a/include/tdm.h b/include/tdm.h index 9bea835..488a549 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * **************************************************************************/ #ifndef _TDM_H_ @@ -52,17 +52,16 @@ extern "C" { * @brief The header file for a frontend user. * @par Example * @code - #include //for a frontend user + * #include //for a frontend user * @endcode */ /** * @brief The display capability enumeration */ -typedef enum -{ - TDM_DISPLAY_CAPABILITY_PP = (1<<0), /**< if hardware supports pp operation */ - TDM_DISPLAY_CAPABILITY_CAPTURE = (1<<1), /**< if hardware supports capture operation */ +typedef enum { + TDM_DISPLAY_CAPABILITY_PP = (1 << 0), /**< if hardware supports pp operation */ + TDM_DISPLAY_CAPABILITY_CAPTURE = (1 << 1), /**< if hardware supports capture operation */ } tdm_display_capability; /** @@ -79,9 +78,9 @@ typedef enum { * changed in runtime. */ typedef void (*tdm_output_change_handler)(tdm_output *output, - tdm_output_change_type type, - tdm_value value, - void *user_data); + tdm_output_change_type type, + tdm_value value, + void *user_data); /** * @brief Initialize a display object @@ -140,7 +139,7 @@ tdm_display_handle_events(tdm_display *dpy); */ tdm_error tdm_display_get_capabilities(tdm_display *dpy, - tdm_display_capability *capabilities); + tdm_display_capability *capabilities); /** * @brief Get the pp capabilities of a display object. @@ -150,7 +149,7 @@ tdm_display_get_capabilities(tdm_display *dpy, */ tdm_error tdm_display_get_pp_capabilities(tdm_display *dpy, - tdm_pp_capability *capabilities); + tdm_pp_capability *capabilities); /** * @brief Get the pp available format array of a display object. @@ -161,7 +160,7 @@ tdm_display_get_pp_capabilities(tdm_display *dpy, */ tdm_error tdm_display_get_pp_available_formats(tdm_display *dpy, - const tbm_format **formats, int *count); + const tbm_format **formats, int *count); /** * @brief Get the pp available size of a display object. @@ -176,7 +175,7 @@ tdm_display_get_pp_available_formats(tdm_display *dpy, */ tdm_error tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h, - int *max_w, int *max_h, int *preferred_align); + int *max_w, int *max_h, int *preferred_align); /** * @brief Get the capture capabilities of a display object. @@ -186,7 +185,7 @@ tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h, */ tdm_error tdm_display_get_capture_capabilities(tdm_display *dpy, - tdm_capture_capability *capabilities); + tdm_capture_capability *capabilities); /** * @brief Get the capture available format array of a display object. @@ -197,7 +196,7 @@ tdm_display_get_capture_capabilities(tdm_display *dpy, */ tdm_error tdm_display_get_catpure_available_formats(tdm_display *dpy, - const tbm_format **formats, int *count); + const tbm_format **formats, int *count); /** * @brief Get the output counts which a display object has. @@ -240,7 +239,7 @@ tdm_display_create_pp(tdm_display *dpy, tdm_error *error); */ tdm_error tdm_output_get_model_info(tdm_output *output, const char **maker, - const char **model, const char **name); + const char **model, const char **name); /** * @brief Get the connection status of a output object. @@ -262,8 +261,8 @@ tdm_output_get_conn_status(tdm_output *output, tdm_output_conn_status *status); */ tdm_error tdm_output_add_change_handler(tdm_output *output, - tdm_output_change_handler func, - void *user_data); + tdm_output_change_handler func, + void *user_data); /** * @brief Remove a output change handler @@ -274,8 +273,8 @@ tdm_output_add_change_handler(tdm_output *output, */ void tdm_output_remove_change_handler(tdm_output *output, - tdm_output_change_handler func, - void *user_data); + tdm_output_change_handler func, + void *user_data); /** * @brief Get the connection type of a output object. @@ -316,7 +315,7 @@ tdm_output_get_layer(tdm_output *output, int index, tdm_error *error); */ tdm_error tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props, - int *count); + int *count); /** * @brief Get the available mode array of a output object. @@ -327,7 +326,7 @@ tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props, */ tdm_error tdm_output_get_available_modes(tdm_output *output, - const tdm_output_mode **modes, int *count); + const tdm_output_mode **modes, int *count); /** * @brief Get the available size of a output object. @@ -342,7 +341,7 @@ tdm_output_get_available_modes(tdm_output *output, */ tdm_error tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h, - int *max_w, int *max_h, int *preferred_align); + int *max_w, int *max_h, int *preferred_align); /** * @brief Get the physical size of a output object. @@ -353,7 +352,7 @@ tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h, */ tdm_error tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth, - unsigned int *mmHeight); + unsigned int *mmHeight); /** * @brief Get the subpixel of a output object. @@ -406,7 +405,7 @@ tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value); */ tdm_error tdm_output_wait_vblank(tdm_output *output, int interval, int sync, - tdm_output_vblank_handler func, void *user_data); + tdm_output_vblank_handler func, void *user_data); /** * @brief Commit changes for a output object @@ -420,7 +419,7 @@ tdm_output_wait_vblank(tdm_output *output, int interval, int sync, */ tdm_error tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, - void *user_data); + void *user_data); /** * @brief Set one of available modes of a output object @@ -476,7 +475,7 @@ tdm_output_create_capture(tdm_output *output, tdm_error *error); */ tdm_error tdm_layer_get_capabilities(tdm_layer *layer, - tdm_layer_capability *capabilities); + tdm_layer_capability *capabilities); /** * @brief Get the available format array of a layer object. @@ -487,7 +486,7 @@ tdm_layer_get_capabilities(tdm_layer *layer, */ tdm_error tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats, - int *count); + int *count); /** * @brief Get the available property array of a layer object. @@ -498,7 +497,7 @@ tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats, */ tdm_error tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props, - int *count); + int *count); /** * @brief Get the zpos of a layer object. @@ -733,7 +732,7 @@ tdm_capture_commit(tdm_capture *capture); * @see tdm_buffer_add_release_handler, tdm_buffer_remove_release_handler */ typedef void (*tdm_buffer_release_handler)(tbm_surface_h buffer, - void *user_data); + void *user_data); /** * @brief Add a release handler to a TDM buffer @@ -750,7 +749,7 @@ typedef void (*tdm_buffer_release_handler)(tbm_surface_h buffer, */ tdm_error tdm_buffer_add_release_handler(tbm_surface_h buffer, - tdm_buffer_release_handler func, void *user_data); + tdm_buffer_release_handler func, void *user_data); /** * @brief Remove a release handler from a TDM buffer @@ -761,7 +760,7 @@ tdm_buffer_add_release_handler(tbm_surface_h buffer, */ void tdm_buffer_remove_release_handler(tbm_surface_h buffer, - tdm_buffer_release_handler func, void *user_data); + tdm_buffer_release_handler func, void *user_data); #ifdef __cplusplus } diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 9a1ea41..8967b52 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * **************************************************************************/ #ifndef _TDM_BACKEND_H_ @@ -49,7 +49,7 @@ extern "C" { * @brief The backend header file of TDM to implement a TDM backend module. * @par Example * @code - #include + * #include * @endcode */ @@ -68,8 +68,8 @@ typedef void tdm_backend_data; * changed in runtime. */ typedef void (*tdm_output_status_handler)(tdm_output *output, - tdm_output_conn_status status, - void *user_data); + tdm_output_conn_status status, + void *user_data); /** * @brief The display capabilities structure of a backend module @@ -157,10 +157,11 @@ typedef struct _tdm_caps_pp { int max_h; /**< The maximum height. -1 means "not defined" */ int preferred_align; /**< The prefered align. -1 means "not defined" */ - int max_attach_count; /**< The attach count which a PP object can handle. - * -1 means "not defined". - * @since 1.2.0 - */ + /**< The attach count which a PP object can handle. + * -1 means "not defined". + * @since 1.2.0 + */ + int max_attach_count; } tdm_caps_pp; /** @@ -180,10 +181,11 @@ typedef struct _tdm_caps_capture { int max_h; /**< The maximum height. -1 means "not defined" */ int preferred_align; /**< The prefered align. -1 means "not defined" */ - int max_attach_count; /**< The attach count which a capture object can handle. - * -1 means "not defined". - * @since 1.2.0 - */ + /**< The attach count which a capture object can handle. + * -1 means "not defined". + * @since 1.2.0 + */ + int max_attach_count; } tdm_caps_capture; /** @@ -203,8 +205,7 @@ typedef struct _tdm_func_display { * a backend module can set the max count to max_layer_count of #tdm_caps_display * structure. Otherwise, set -1. */ - tdm_error (*display_get_capabilitiy)(tdm_backend_data *bdata, - tdm_caps_display *caps); + tdm_error (*display_get_capabilitiy)(tdm_backend_data *bdata, tdm_caps_display *caps); /** * @brief Get the pp capabilities of a backend module @@ -220,8 +221,7 @@ typedef struct _tdm_func_display { * @b SHOULD fill the #tdm_caps_pp data. #tdm_caps_pp contains the hardware * restriction information which a converting device can handle. ie, format, size, etc. */ - tdm_error (*display_get_pp_capability)(tdm_backend_data *bdata, - tdm_caps_pp *caps); + tdm_error (*display_get_pp_capability)(tdm_backend_data *bdata, tdm_caps_pp *caps); /** * @brief Get the capture capabilities of a backend module @@ -237,8 +237,7 @@ typedef struct _tdm_func_display { * #tdm_caps_capture data. #tdm_caps_capture contains the hardware restriction * information which a capture device can handle. ie, format, size, etc. */ - tdm_error (*display_get_capture_capability)(tdm_backend_data *bdata, - tdm_caps_capture *caps); + tdm_error (*display_get_capture_capability)(tdm_backend_data *bdata, tdm_caps_capture *caps); /** * @brief Get a output array of a backend module @@ -255,45 +254,45 @@ typedef struct _tdm_func_display { * "tdm_output*" data. It will be freed in frontend. * @par Example * @code - tdm_output** - drm_display_get_outputs(tdm_backend_data *bdata, int *count, tdm_error *error) - { - tdm_drm_data *drm_data = bdata; - tdm_drm_output_data *output_data = NULL; - tdm_output **outputs; - int i; - - (*count) = 0; - LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link) - (*count)++; - - if ((*count) == 0) - { - if (error) *error = TDM_ERROR_NONE; - return NULL; - } - - // will be freed in frontend - outputs = calloc(*count, sizeof(tdm_drm_output_data*)); - if (!outputs) - { - (*count) = 0; - if (error) *error = TDM_ERROR_OUT_OF_MEMORY; - return NULL; - } - - i = 0; - LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link) - outputs[i++] = output_data; - - if (error) *error = TDM_ERROR_NONE; - - return outputs; - } + * tdm_output** + * drm_display_get_outputs(tdm_backend_data *bdata, int *count, tdm_error *error) + * { + * tdm_drm_data *drm_data = bdata; + * tdm_drm_output_data *output_data = NULL; + * tdm_output **outputs; + * int i; + * + * (*count) = 0; + * LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link) + * (*count)++; + * + * if ((*count) == 0) + * { + * if (error) *error = TDM_ERROR_NONE; + * return NULL; + * } + * + * // will be freed in frontend + * outputs = calloc(*count, sizeof(tdm_drm_output_data*)); + * if (!outputs) + * { + * (*count) = 0; + * if (error) *error = TDM_ERROR_OUT_OF_MEMORY; + * return NULL; + * } + * + * i = 0; + * LIST_FOR_EACH_ENTRY(output_data, &drm_data->output_list, link) + * outputs[i++] = output_data; + * + * if (error) *error = TDM_ERROR_NONE; + * + * return outputs; + * } * @endcode */ tdm_output **(*display_get_outputs)(tdm_backend_data *bdata, int *count, - tdm_error *error); + tdm_error *error); /** * @brief Get the file descriptor of a backend module @@ -367,7 +366,7 @@ typedef struct _tdm_func_output { * "tdm_layer*" data. It will be freed in frontend. */ tdm_layer **(*output_get_layers)(tdm_output *output, int *count, - tdm_error *error); + tdm_error *error); /** * @brief Set the property which has a given id @@ -377,7 +376,7 @@ typedef struct _tdm_func_output { * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error (*output_set_property)(tdm_output *output, unsigned int id, - tdm_value value); + tdm_value value); /** * @brief Get the property which has a given id @@ -387,7 +386,7 @@ typedef struct _tdm_func_output { * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error (*output_get_property)(tdm_output *output, unsigned int id, - tdm_value *value); + tdm_value *value); /** * @brief Wait for VBLANK @@ -403,7 +402,7 @@ typedef struct _tdm_func_output { * vblanks. */ tdm_error (*output_wait_vblank)(tdm_output *output, int interval, int sync, - void *user_data); + void *user_data); /** * @brief Set a user vblank handler @@ -412,7 +411,7 @@ typedef struct _tdm_func_output { * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error (*output_set_vblank_handler)(tdm_output *output, - tdm_output_vblank_handler func); + tdm_output_vblank_handler func); /** * @brief Commit changes for a output object @@ -438,7 +437,7 @@ typedef struct _tdm_func_output { * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error (*output_set_commit_handler)(tdm_output *output, - tdm_output_commit_handler func); + tdm_output_commit_handler func); /** * @brief Set DPMS of a output object @@ -496,8 +495,8 @@ typedef struct _tdm_func_output { * @since 1.1.0 */ tdm_error (*output_set_status_handler)(tdm_output *output, - tdm_output_status_handler func, - void *user_data); + tdm_output_status_handler func, + void *user_data); void (*reserved1)(void); void (*reserved2)(void); @@ -534,7 +533,7 @@ typedef struct _tdm_func_layer { * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error (*layer_set_property)(tdm_layer *layer, unsigned int id, - tdm_value value); + tdm_value value); /** * @brief Get the property which has a given id. @@ -544,7 +543,7 @@ typedef struct _tdm_func_layer { * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ tdm_error (*layer_get_property)(tdm_layer *layer, unsigned int id, - tdm_value *value); + tdm_value *value); /** * @brief Set the geometry information to a layer object @@ -636,7 +635,7 @@ typedef struct _tdm_func_layer { * @brief The done handler of a pp object */ typedef void (*tdm_pp_done_handler)(tdm_pp *pp, tbm_surface_h src, - tbm_surface_h dst, void *user_data); + tbm_surface_h dst, void *user_data); /** * @brief The pp functions for a backend module. @@ -647,7 +646,7 @@ typedef struct _tdm_func_pp { * @param[in] pp A pp object * @see display_create_pp() function of #tdm_func_display */ - void (*pp_destroy)(tdm_pp *pp); + void (*pp_destroy)(tdm_pp *pp); /** * @brief Set the geometry information to a pp object @@ -658,7 +657,7 @@ typedef struct _tdm_func_pp { * @remark * A backend module would apply the geometry information when committed. */ - tdm_error (*pp_set_info)(tdm_pp *pp, tdm_info_pp *info); + tdm_error (*pp_set_info)(tdm_pp *pp, tdm_info_pp *info); /** * @brief Attach a source buffer and a destination buffer to a pp object @@ -675,14 +674,14 @@ typedef struct _tdm_func_pp { * #pp_set_info() of #tdm_func_pp. When done, a backend module @b SHOULD * return the source/destination buffer via tdm_pp_done_handler. */ - tdm_error (*pp_attach)(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst); + tdm_error (*pp_attach)(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst); /** * @brief Commit changes for a pp object * @param[in] pp A pp object * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ - tdm_error (*pp_commit)(tdm_pp *pp); + tdm_error (*pp_commit)(tdm_pp *pp); /** * @brief Set a user done handler to a pp object @@ -693,8 +692,8 @@ typedef struct _tdm_func_pp { * @remark * A backend module @b SHOULD call #tdm_pp_done_handler when converintg a image is done. */ - tdm_error (*pp_set_done_handler)(tdm_pp *pp, tdm_pp_done_handler func, - void *user_data); + tdm_error (*pp_set_done_handler)(tdm_pp *pp, tdm_pp_done_handler func, + void *user_data); void (*reserved1)(void); void (*reserved2)(void); @@ -710,7 +709,7 @@ typedef struct _tdm_func_pp { * @brief The done handler of a capture object */ typedef void (*tdm_capture_done_handler)(tdm_capture *capture, - tbm_surface_h buffer, void *user_data); + tbm_surface_h buffer, void *user_data); /** * @brief The capture functions for a backend module. @@ -722,7 +721,7 @@ typedef struct _tdm_func_capture { * @see output_create_capture() function of #tdm_func_output * @see layer_create_capture() function of #tdm_func_layer */ - void (*capture_destroy)(tdm_capture *capture); + void (*capture_destroy)(tdm_capture *capture); /** * @brief Set the geometry information to a capture object @@ -733,7 +732,7 @@ typedef struct _tdm_func_capture { * @remark * A backend module would apply the geometry information when committed. */ - tdm_error (*capture_set_info)(tdm_capture *capture, tdm_info_capture *info); + tdm_error (*capture_set_info)(tdm_capture *capture, tdm_info_capture *info); /** * @brief Attach a TDM buffer to a capture object @@ -751,14 +750,14 @@ typedef struct _tdm_func_capture { * of #tdm_func_capture. When done, a backend module @b SHOULD return the TDM * buffer via tdm_capture_done_handler. */ - tdm_error (*capture_attach)(tdm_capture *capture, tbm_surface_h buffer); + tdm_error (*capture_attach)(tdm_capture *capture, tbm_surface_h buffer); /** * @brief Commit changes for a capture object * @param[in] capture A capture object * @return #TDM_ERROR_NONE if success. Otherwise, error value. */ - tdm_error (*capture_commit)(tdm_capture *capture); + tdm_error (*capture_commit)(tdm_capture *capture); /** * @brief Set a user done handler to a capture object @@ -769,8 +768,8 @@ typedef struct _tdm_func_capture { * @remark * A backend module @b SHOULD call #tdm_capture_done_handler when capture operation is done. */ - tdm_error (*capture_set_done_handler)(tdm_capture *capture, - tdm_capture_done_handler func, void *user_data); + tdm_error (*capture_set_done_handler)(tdm_capture *capture, + tdm_capture_done_handler func, void *user_data); void (*reserved1)(void); void (*reserved2)(void); @@ -788,25 +787,25 @@ typedef struct _tdm_func_capture { #define TDM_BACKEND_GET_ABI_MAJOR(v) (((v) & TDM_BACKEND_MAJOR_VERSION_MASK) >> 16) /** - * @brief + * @brief * The ABI version of TDM backend module. It has a major and minor revision. * Modules using lower minor revisions will work with TDM frontend of a higher * minor revision. There is no compatibility between different major revisions. * The minor revision mask is 0x0000FFFF and the major revision mask is 0xFFFF0000. * @par Example * @code - tdm_backend_module tdm_backend_module_data = { - "drm", - "Samsung", - TDM_BACKEND_SET_ABI_VERSION(1,1), - tdm_drm_init, - tdm_drm_deinit - }; + * tdm_backend_module tdm_backend_module_data = { + * "drm", + * "Samsung", + * TDM_BACKEND_SET_ABI_VERSION(1,1), + * tdm_drm_init, + * tdm_drm_deinit + * }; * @endcode */ #define TDM_BACKEND_SET_ABI_VERSION(major, minor) \ - (((major) << 16) & TDM_BACKEND_MAJOR_VERSION_MASK) | \ - ((major) & TDM_BACKEND_MINOR_VERSION_MASK) + (((major) << 16) & TDM_BACKEND_MAJOR_VERSION_MASK) | \ + ((major) & TDM_BACKEND_MINOR_VERSION_MASK) /** * @brief @@ -856,7 +855,7 @@ typedef struct _tdm_backend_module { */ tdm_error tdm_backend_register_func_display(tdm_display *dpy, - tdm_func_display *func_display); + tdm_func_display *func_display); /** * @brief Register the backend output functions to a display @@ -869,7 +868,7 @@ tdm_backend_register_func_display(tdm_display *dpy, */ tdm_error tdm_backend_register_func_output(tdm_display *dpy, - tdm_func_output *func_output); + tdm_func_output *func_output); /** * @brief Register the backend layer functions to a display @@ -908,7 +907,7 @@ tdm_backend_register_func_pp(tdm_display *dpy, tdm_func_pp *func_pp); */ tdm_error tdm_backend_register_func_capture(tdm_display *dpy, - tdm_func_capture *func_capture); + tdm_func_capture *func_capture); /** * @brief Increase the ref_count of a TDM buffer @@ -943,7 +942,7 @@ tdm_buffer_unref_backend(tbm_surface_h buffer); * @see tdm_buffer_add_destroy_handler, tdm_buffer_remove_destroy_handler */ typedef void (*tdm_buffer_destroy_handler)(tbm_surface_h buffer, - void *user_data); + void *user_data); /** * @brief Add a destroy handler to a TDM buffer @@ -959,7 +958,7 @@ typedef void (*tdm_buffer_destroy_handler)(tbm_surface_h buffer, */ tdm_error tdm_buffer_add_destroy_handler(tbm_surface_h buffer, - tdm_buffer_destroy_handler func, void *user_data); + tdm_buffer_destroy_handler func, void *user_data); /** * @brief Remove a destroy handler from a TDM buffer @@ -970,7 +969,7 @@ tdm_buffer_add_destroy_handler(tbm_surface_h buffer, */ void tdm_buffer_remove_destroy_handler(tbm_surface_h buffer, - tdm_buffer_destroy_handler func, void *user_data); + tdm_buffer_destroy_handler func, void *user_data); /** * @brief Add a FD handler for activity on the given file descriptor @@ -985,8 +984,8 @@ tdm_buffer_remove_destroy_handler(tbm_surface_h buffer, */ tdm_event_loop_source* tdm_event_loop_add_fd_handler(tdm_display *dpy, int fd, tdm_event_loop_mask mask, - tdm_event_loop_fd_handler func, void *user_data, - tdm_error *error); + tdm_event_loop_fd_handler func, void *user_data, + tdm_error *error); /** * @brief Update the mask of the given FD event source @@ -1008,7 +1007,7 @@ tdm_event_loop_source_fd_update(tdm_event_loop_source *source, tdm_event_loop_ma */ tdm_event_loop_source* tdm_event_loop_add_timer_handler(tdm_display *dpy, tdm_event_loop_timer_handler func, - void *user_data, tdm_error *error); + void *user_data, tdm_error *error); /** * @brief Update the millisecond delay time of the given timer event source. diff --git a/include/tdm_helper.h b/include/tdm_helper.h index 254999a..0bde0b9 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * **************************************************************************/ #ifndef _TDM_HELPER_H_ diff --git a/include/tdm_list.h b/include/tdm_list.h index a6d6bbb..6255cd0 100644 --- a/include/tdm_list.h +++ b/include/tdm_list.h @@ -110,41 +110,41 @@ static inline int list_length(struct list_head *item) #define LIST_LENGTH(__item) list_length(__item) #define LIST_ENTRY(__type, __item, __field) \ - ((__type *)(((char *)(__item)) - offsetof(__type, __field))) + ((__type *)(((char *)(__item)) - offsetof(__type, __field))) #define LIST_IS_EMPTY(__list) \ - ((__list)->next == (__list)) + ((__list)->next == (__list)) #ifndef container_of #define container_of(ptr, sample, member) \ - (void *)((char *)(ptr) \ + (void *)((char *)(ptr) \ - ((char *)&(sample)->member - (char *)(sample))) #endif #define LIST_FOR_EACH_ENTRY(pos, head, member) \ - for (pos = container_of((head)->next, pos, member); \ + for (pos = container_of((head)->next, pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.next, pos, member)) #define LIST_FOR_EACH_ENTRY_SAFE(pos, storage, head, member) \ - for (pos = container_of((head)->next, pos, member), \ + for (pos = container_of((head)->next, pos, member), \ storage = container_of(pos->member.next, pos, member); \ &pos->member != (head); \ pos = storage, storage = container_of(storage->member.next, storage, member)) #define LIST_FOR_EACH_ENTRY_SAFE_REV(pos, storage, head, member) \ - for (pos = container_of((head)->prev, pos, member), \ + for (pos = container_of((head)->prev, pos, member), \ storage = container_of(pos->member.prev, pos, member); \ &pos->member != (head); \ pos = storage, storage = container_of(storage->member.prev, storage, member)) #define LIST_FOR_EACH_ENTRY_FROM(pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ + for (pos = container_of((start), pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.next, pos, member)) #define LIST_FOR_EACH_ENTRY_FROM_REV(pos, start, head, member) \ - for (pos = container_of((start), pos, member); \ + for (pos = container_of((start), pos, member); \ &pos->member != (head); \ pos = container_of(pos->member.prev, pos, member)) diff --git a/include/tdm_log.h b/include/tdm_log.h index ebfa1d7..02943c0 100644 --- a/include/tdm_log.h +++ b/include/tdm_log.h @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * **************************************************************************/ #ifndef _TDM_LOG_H_ @@ -54,7 +54,7 @@ extern "C" { * The TDM debug log can be enable by setting "TDM_DEBUG" enviroment * @par Example * @code - $ export TDM_DEBUG=1 + * $ export TDM_DEBUG=1 * @endcode */ extern int tdm_debug; @@ -79,7 +79,7 @@ extern int tdm_debug; #define LOG_TAG "TDM" #define TDM_DBG(fmt, args...) \ - if (tdm_debug) \ + if (tdm_debug) \ do { \ struct timespec ts; \ clock_gettime(CLOCK_MONOTONIC, &ts); \ @@ -125,7 +125,7 @@ extern int tdm_debug; #define COLOR_RESET "\x1b[0m" #define TDM_DBG(fmt, args...) \ - if (tdm_debug) \ + if (tdm_debug) \ do { \ struct timespec ts; \ clock_gettime(CLOCK_MONOTONIC, &ts); \ diff --git a/include/tdm_types.h b/include/tdm_types.h index f6fc5c4..a6b68fa 100755 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * **************************************************************************/ #ifndef _TDM_TYPES_H_ @@ -52,18 +52,17 @@ extern "C" { * include @ref tdm_types.h * @par Example * @code - #include //for a frontend user + * #include //for a frontend user * @endcode * @code - #include //for a vendor to implement a backend module + * #include //for a vendor to implement a backend module * @endcode */ /** * @brief The error enumeration */ -typedef enum -{ +typedef enum { TDM_ERROR_NONE = 0, /**< none */ TDM_ERROR_BAD_REQUEST = -1, /**< bad request */ TDM_ERROR_OPERATION_FAILED = -2, /**< operaion failed */ @@ -142,12 +141,12 @@ typedef enum { * SCALE and TRANSFORM capability.\n * @par Example * @code - //For example - capabilities = TDM_LAYER_CAPABILITY_PRIMARY | TDM_LAYER_CAPABILITY_GRAPHIC; - capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE; - capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE | TDM_LAYER_CAPABILITY_TRANSFORM; - capabilities = TDM_LAYER_CAPABILITY_CURSOR | TDM_LAYER_CAPABILITY_GRAPHIC; - capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_VIDEO; + * //For example + * capabilities = TDM_LAYER_CAPABILITY_PRIMARY | TDM_LAYER_CAPABILITY_GRAPHIC; + * capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE; + * capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_GRAPHIC | TDM_LAYER_CAPABILITY_SCALE | TDM_LAYER_CAPABILITY_TRANSFORM; + * capabilities = TDM_LAYER_CAPABILITY_CURSOR | TDM_LAYER_CAPABILITY_GRAPHIC; + * capabilities = TDM_LAYER_CAPABILITY_OVERLAY | TDM_LAYER_CAPABILITY_VIDEO; * @endcode * @remark * - When a video plays, in most of cases, video buffers will be displayed to @@ -225,8 +224,7 @@ typedef enum { TDM_OUTPUT_MODE_FLAG_CLKDIV2 = (1 << 13), } tdm_output_mode_flag; -typedef enum -{ +typedef enum { TDM_EVENT_LOOP_READABLE = (1 << 0), TDM_EVENT_LOOP_WRITABLE = (1 << 1), TDM_EVENT_LOOP_HANGUP = (1 << 2), @@ -353,16 +351,16 @@ typedef void tdm_pp; * @see output_set_vblank_handler() function of #tdm_func_display */ typedef void (*tdm_output_vblank_handler)(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); /** * @brief The commit handler * @see output_set_commit_handler() function of #tdm_func_display */ typedef void (*tdm_output_commit_handler)(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); /** * @brief The tdm event source diff --git a/src/tdm.c b/src/tdm.c index 24f3e52..996fb9a 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -47,7 +47,7 @@ int tdm_mutex_locked; static tdm_private_layer * _tdm_display_find_private_layer(tdm_private_output *private_output, - tdm_layer *layer_backend) + tdm_layer *layer_backend) { tdm_private_layer *private_layer = NULL; @@ -61,7 +61,7 @@ _tdm_display_find_private_layer(tdm_private_output *private_output, static tdm_private_output * _tdm_display_find_private_output(tdm_private_display *private_display, - tdm_output *output_backend) + tdm_output *output_backend) { tdm_private_output *private_output = NULL; @@ -75,7 +75,7 @@ _tdm_display_find_private_output(tdm_private_display *private_display, INTERN tdm_private_output * tdm_display_find_output_stamp(tdm_private_display *private_display, - unsigned long stamp) + unsigned long stamp) { tdm_private_output *private_output = NULL; @@ -216,7 +216,7 @@ _tdm_display_destroy_private_display(tdm_private_display *private_display) static tdm_error _tdm_display_update_caps_pp(tdm_private_display *private_display, - tdm_caps_pp *caps) + tdm_caps_pp *caps) { tdm_func_display *func_display = &private_display->func_display; char buf[1024]; @@ -254,7 +254,7 @@ _tdm_display_update_caps_pp(tdm_private_display *private_display, static tdm_error _tdm_display_update_caps_capture(tdm_private_display *private_display, - tdm_caps_capture *caps) + tdm_caps_capture *caps) { tdm_func_display *func_display = &private_display->func_display; char buf[1024]; @@ -272,8 +272,7 @@ _tdm_display_update_caps_capture(tdm_private_display *private_display, return TDM_ERROR_BAD_MODULE; } - ret = func_display->display_get_capture_capability(private_display->bdata, - caps); + ret = func_display->display_get_capture_capability(private_display->bdata, caps); if (ret != TDM_ERROR_NONE) { TDM_ERR("display_get_capture_capability() failed"); return TDM_ERROR_BAD_MODULE; @@ -289,7 +288,7 @@ _tdm_display_update_caps_capture(tdm_private_display *private_display, static tdm_error _tdm_display_update_caps_layer(tdm_private_display *private_display, - tdm_layer *layer_backend, tdm_caps_layer *caps) + tdm_layer *layer_backend, tdm_caps_layer *caps) { tdm_func_layer *func_layer = &private_display->func_layer; char buf[1024]; @@ -324,7 +323,7 @@ _tdm_display_update_caps_layer(tdm_private_display *private_display, static tdm_error _tdm_display_update_caps_output(tdm_private_display *private_display, int pipe, - tdm_output *output_backend, tdm_caps_output *caps) + tdm_output *output_backend, tdm_caps_output *caps) { tdm_func_output *func_output = &private_display->func_output; char temp[TDM_NAME_LEN]; @@ -355,14 +354,14 @@ _tdm_display_update_caps_output(tdm_private_display *private_display, int pipe, TDM_DBG("output props: %d, %s", caps->props[i].id, caps->props[i].name); for (i = 0; i < caps->mode_count; i++) { TDM_DBG("output modes: name(%s), clock(%d) vrefresh(%d), flags(%x), type(%d)", - caps->modes[i].name, caps->modes[i].clock, caps->modes[i].vrefresh, - caps->modes[i].flags, caps->modes[i].type); + caps->modes[i].name, caps->modes[i].clock, caps->modes[i].vrefresh, + caps->modes[i].flags, caps->modes[i].type); TDM_DBG("\t\t %d, %d, %d, %d, %d", - caps->modes[i].hdisplay, caps->modes[i].hsync_start, caps->modes[i].hsync_end, - caps->modes[i].htotal, caps->modes[i].hskew); + caps->modes[i].hdisplay, caps->modes[i].hsync_start, caps->modes[i].hsync_end, + caps->modes[i].htotal, caps->modes[i].hskew); TDM_DBG("\t\t %d, %d, %d, %d, %d", - caps->modes[i].vdisplay, caps->modes[i].vsync_start, caps->modes[i].vsync_end, - caps->modes[i].vtotal, caps->modes[i].vscan); + caps->modes[i].vdisplay, caps->modes[i].vsync_start, caps->modes[i].vsync_end, + caps->modes[i].vtotal, caps->modes[i].vscan); } TDM_DBG("output min : %dx%d", caps->min_w, caps->min_h); TDM_DBG("output max : %dx%d", caps->max_w, caps->max_h); @@ -373,8 +372,8 @@ _tdm_display_update_caps_output(tdm_private_display *private_display, int pipe, static tdm_error _tdm_display_update_layer(tdm_private_display *private_display, - tdm_private_output *private_output, - tdm_layer *layer_backend) + tdm_private_output *private_output, + tdm_layer *layer_backend) { tdm_private_layer *private_layer; tdm_error ret; @@ -396,7 +395,7 @@ _tdm_display_update_layer(tdm_private_display *private_display, _tdm_display_destroy_caps_layer(&private_layer->caps); ret = _tdm_display_update_caps_layer(private_display, layer_backend, - &private_layer->caps); + &private_layer->caps); if (ret != TDM_ERROR_NONE) goto failed_update; @@ -408,7 +407,7 @@ failed_update: INTERN tdm_error tdm_display_update_output(tdm_private_display *private_display, - tdm_output *output_backend, int pipe) + tdm_output *output_backend, int pipe) { tdm_func_output *func_output = &private_display->func_output; tdm_private_output *private_output = NULL; @@ -416,8 +415,7 @@ tdm_display_update_output(tdm_private_display *private_display, int layer_count = 0, i; tdm_error ret; - private_output = _tdm_display_find_private_output(private_display, - output_backend); + private_output = _tdm_display_find_private_output(private_display, output_backend); if (!private_output) { private_output = calloc(1, sizeof(tdm_private_output)); TDM_RETURN_VAL_IF_FAIL(private_output != NULL, TDM_ERROR_OUT_OF_MEMORY); @@ -442,8 +440,8 @@ tdm_display_update_output(tdm_private_display *private_display, if (func_output->output_set_status_handler) { func_output->output_set_status_handler(private_output->output_backend, - tdm_output_cb_status, - private_output); + tdm_output_cb_status, + private_output); private_output->regist_change_cb = 1; } @@ -451,7 +449,7 @@ tdm_display_update_output(tdm_private_display *private_display, _tdm_display_destroy_caps_output(&private_output->caps); ret = _tdm_display_update_caps_output(private_display, pipe, output_backend, - &private_output->caps); + &private_output->caps); if (ret != TDM_ERROR_NONE) return ret; @@ -507,8 +505,7 @@ _tdm_display_get_ordered_outputs(tdm_private_display *private_display, int *coun if (private_display->outputs) return private_display->outputs; - outputs = func_display->display_get_outputs(private_display->bdata, - &output_count, &ret); + outputs = func_display->display_get_outputs(private_display->bdata, &output_count, &ret); if (ret != TDM_ERROR_NONE) goto failed_get_outputs; @@ -558,7 +555,7 @@ _tdm_display_get_ordered_outputs(tdm_private_display *private_display, int *coun output_hdmib = outputs[i]; index_hdmib = i; break; - default : + default: break; } } @@ -609,7 +606,7 @@ failed_get_outputs: static tdm_error _tdm_display_update_internal(tdm_private_display *private_display, - int only_display) + int only_display) { tdm_output **outputs = NULL; int output_count = 0, i; @@ -625,7 +622,7 @@ _tdm_display_update_internal(tdm_private_display *private_display, goto failed_update; ret = _tdm_display_update_caps_capture(private_display, - &private_display->caps_capture); + &private_display->caps_capture); if (ret != TDM_ERROR_NONE) goto failed_update; } @@ -684,7 +681,7 @@ _tdm_display_check_module(tdm_backend_module *module) int major, minor; TDM_INFO("TDM ABI version : %d.%d", - TDM_MAJOR_VERSION, TDM_MINOR_VERSION); + TDM_MAJOR_VERSION, TDM_MINOR_VERSION); name = module->name ? module->name : "unknown"; vendor = module->vendor ? module->vendor : "unknown"; @@ -697,13 +694,13 @@ _tdm_display_check_module(tdm_backend_module *module) if (major != TDM_MAJOR_VERSION) { TDM_ERR("'%s' major version mismatch, %d != %d", - name, major, TDM_MAJOR_VERSION); + name, major, TDM_MAJOR_VERSION); return TDM_ERROR_BAD_MODULE; } if (minor > TDM_MINOR_VERSION) { TDM_ERR("'%s' minor version(%d) is newer than %d", - name, minor, TDM_MINOR_VERSION); + name, minor, TDM_MINOR_VERSION); return TDM_ERROR_BAD_MODULE; } @@ -731,16 +728,13 @@ _tdm_display_check_backend_functions(tdm_private_display *private_display) /* below functions should be implemented in backend side */ TDM_RETURN_VAL_IF_FAIL(func_display != NULL, TDM_ERROR_BAD_MODULE); - TDM_RETURN_VAL_IF_FAIL(func_display->display_get_capabilitiy, - TDM_ERROR_BAD_MODULE); + TDM_RETURN_VAL_IF_FAIL(func_display->display_get_capabilitiy, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_display->display_get_outputs, TDM_ERROR_BAD_MODULE); - TDM_RETURN_VAL_IF_FAIL(func_output->output_get_capability, - TDM_ERROR_BAD_MODULE); + TDM_RETURN_VAL_IF_FAIL(func_output->output_get_capability, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_output->output_get_layers, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_layer->layer_get_capability, TDM_ERROR_BAD_MODULE); - ret = func_display->display_get_capabilitiy(private_display->bdata, - &private_display->caps_display); + ret = func_display->display_get_capabilitiy(private_display->bdata, &private_display->caps_display); if (ret != TDM_ERROR_NONE) { TDM_ERR("display_get_capabilitiy() failed"); return TDM_ERROR_BAD_MODULE; @@ -748,8 +742,7 @@ _tdm_display_check_backend_functions(tdm_private_display *private_display) if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_PP) { tdm_func_pp *func_pp = &private_display->func_pp; - TDM_RETURN_VAL_IF_FAIL(func_display->display_get_pp_capability, - TDM_ERROR_BAD_MODULE); + TDM_RETURN_VAL_IF_FAIL(func_display->display_get_pp_capability, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_display->display_create_pp, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_pp->pp_destroy, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_pp->pp_commit, TDM_ERROR_BAD_MODULE); @@ -758,15 +751,12 @@ _tdm_display_check_backend_functions(tdm_private_display *private_display) if (private_display->capabilities & TDM_DISPLAY_CAPABILITY_CAPTURE) { tdm_func_capture *func_capture = &private_display->func_capture; - TDM_RETURN_VAL_IF_FAIL(func_display->display_get_capture_capability, - TDM_ERROR_BAD_MODULE); - TDM_RETURN_VAL_IF_FAIL(func_output->output_create_capture, - TDM_ERROR_BAD_MODULE); + TDM_RETURN_VAL_IF_FAIL(func_display->display_get_capture_capability, TDM_ERROR_BAD_MODULE); + TDM_RETURN_VAL_IF_FAIL(func_output->output_create_capture, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_layer->layer_create_capture, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_capture->capture_destroy, TDM_ERROR_BAD_MODULE); TDM_RETURN_VAL_IF_FAIL(func_capture->capture_commit, TDM_ERROR_BAD_MODULE); - TDM_RETURN_VAL_IF_FAIL(func_capture->capture_set_done_handler, - TDM_ERROR_BAD_MODULE); + TDM_RETURN_VAL_IF_FAIL(func_capture->capture_set_done_handler, TDM_ERROR_BAD_MODULE); } return TDM_ERROR_NONE; @@ -774,7 +764,7 @@ _tdm_display_check_backend_functions(tdm_private_display *private_display) static tdm_error _tdm_display_load_module_with_file(tdm_private_display *private_display, - const char *file) + const char *file) { char path[PATH_MAX] = {0,}; tdm_backend_module *module_data; @@ -812,8 +802,7 @@ _tdm_display_load_module_with_file(tdm_private_display *private_display, /* We don't care if backend_data is NULL or not. It's up to backend. */ TDM_TRACE_BEGIN(Init_Backend); - private_display->bdata = module_data->init((tdm_display *)private_display, - &ret); + private_display->bdata = module_data->init((tdm_display *)private_display, &ret); TDM_TRACE_END(); if (ret != TDM_ERROR_NONE) { TDM_ERR("'%s' init failed", file); diff --git a/src/tdm_backend.c b/src/tdm_backend.c index d7cfc8d..c83b3da 100644 --- a/src/tdm_backend.c +++ b/src/tdm_backend.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -42,9 +42,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tdm_private.h" #define BACKEND_FUNC_ENTRY() \ - tdm_private_display *private_display; \ - TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \ - private_display = (tdm_private_display*)dpy; + tdm_private_display *private_display; \ + TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \ + private_display = (tdm_private_display*)dpy; static int _check_abi_version(tdm_backend_module *module, int abimaj, int abimin) @@ -58,14 +58,14 @@ _check_abi_version(tdm_backend_module *module, int abimaj, int abimin) return 1; failed: TDM_ERR("The ABI version(%d.%d) of '%s' is less than %d.%d", - major, minor, module->name ? module->name : "unknown", - abimaj, abimin); + major, minor, module->name ? module->name : "unknown", + abimaj, abimin); return 0; } EXTERN tdm_error tdm_backend_register_func_display(tdm_display *dpy, - tdm_func_display *func_display) + tdm_func_display *func_display) { tdm_backend_module *module; @@ -145,7 +145,7 @@ tdm_backend_register_func_pp(tdm_display *dpy, tdm_func_pp *func_pp) EXTERN tdm_error tdm_backend_register_func_capture(tdm_display *dpy, - tdm_func_capture *func_capture) + tdm_func_capture *func_capture) { TDM_RETURN_VAL_IF_FAIL(TDM_MUTEX_IS_LOCKED(), TDM_ERROR_OPERATION_FAILED); diff --git a/src/tdm_buffer.c b/src/tdm_buffer.c index 9f17dd8..3c48e0e 100644 --- a/src/tdm_buffer.c +++ b/src/tdm_buffer.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -88,7 +88,7 @@ tdm_buffer_get_info(tbm_surface_h buffer) { tdm_buffer_info *buf_info = NULL; - if (!tbm_surface_internal_get_user_data(buffer, TDM_BUFFER_KEY,(void **)&buf_info)) { + if (!tbm_surface_internal_get_user_data(buffer, TDM_BUFFER_KEY, (void **)&buf_info)) { buf_info = calloc(1, sizeof(tdm_buffer_info)); TDM_RETURN_VAL_IF_FAIL(buf_info != NULL, NULL); @@ -116,7 +116,7 @@ tdm_buffer_get_info(tbm_surface_h buffer) EXTERN tdm_error tdm_buffer_add_release_handler(tbm_surface_h buffer, - tdm_buffer_release_handler func, void *user_data) + tdm_buffer_release_handler func, void *user_data) { tdm_buffer_info *buf_info; tdm_buffer_func_info *func_info; @@ -140,7 +140,7 @@ tdm_buffer_add_release_handler(tbm_surface_h buffer, EXTERN void tdm_buffer_remove_release_handler(tbm_surface_h buffer, - tdm_buffer_release_handler func, void *user_data) + tdm_buffer_release_handler func, void *user_data) { tdm_buffer_info *buf_info; tdm_buffer_func_info *func_info = NULL, *next = NULL; @@ -210,7 +210,7 @@ tdm_buffer_unref_backend(tbm_surface_h buffer) EXTERN tdm_error tdm_buffer_add_destroy_handler(tbm_surface_h buffer, - tdm_buffer_destroy_handler func, void *user_data) + tdm_buffer_destroy_handler func, void *user_data) { tdm_buffer_info *buf_info; tdm_buffer_func_info *func_info; @@ -234,7 +234,7 @@ tdm_buffer_add_destroy_handler(tbm_surface_h buffer, EXTERN void tdm_buffer_remove_destroy_handler(tbm_surface_h buffer, - tdm_buffer_destroy_handler func, void *user_data) + tdm_buffer_destroy_handler func, void *user_data) { tdm_buffer_info *buf_info; tdm_buffer_func_info *func_info = NULL, *next = NULL; @@ -273,7 +273,7 @@ tdm_buffer_list_dump(struct list_head *list) { tdm_buffer_info *buf_info = NULL; char str[256], *p; - int len = sizeof (str); + int len = sizeof(str); TDM_RETURN_IF_FAIL(list != NULL); @@ -283,8 +283,7 @@ tdm_buffer_list_dump(struct list_head *list) int l = snprintf(p, len, " %p", buf_info->buffer); p += l; len -= l; - } - else + } else break; } diff --git a/src/tdm_capture.c b/src/tdm_capture.c index 01f3e8b..ea67044 100644 --- a/src/tdm_capture.c +++ b/src/tdm_capture.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -42,18 +42,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tdm_private.h" #define CAPTURE_FUNC_ENTRY() \ - tdm_func_capture *func_capture; \ - tdm_private_display *private_display; \ - tdm_private_capture *private_capture; \ - tdm_error ret = TDM_ERROR_NONE; \ - TDM_RETURN_VAL_IF_FAIL(capture != NULL, TDM_ERROR_INVALID_PARAMETER); \ - private_capture = (tdm_private_capture*)capture; \ - private_display = private_capture->private_display; \ - func_capture = &private_display->func_capture + tdm_func_capture *func_capture; \ + tdm_private_display *private_display; \ + tdm_private_capture *private_capture; \ + tdm_error ret = TDM_ERROR_NONE; \ + TDM_RETURN_VAL_IF_FAIL(capture != NULL, TDM_ERROR_INVALID_PARAMETER); \ + private_capture = (tdm_private_capture*)capture; \ + private_display = private_capture->private_display; \ + func_capture = &private_display->func_capture static tdm_error _tdm_capture_check_if_exist(tdm_private_capture *private_capture, - tbm_surface_h buffer) + tbm_surface_h buffer) { tdm_buffer_info *buf_info = NULL; @@ -76,7 +76,7 @@ _tdm_capture_check_if_exist(tdm_private_capture *private_capture, INTERN void tdm_capture_cb_done(tdm_capture *capture_backend, tbm_surface_h buffer, - void *user_data) + void *user_data) { tdm_private_capture *private_capture = user_data; tdm_private_display *private_display = private_capture->private_display; @@ -136,7 +136,7 @@ tdm_capture_find_stamp(tdm_private_display *private_display, unsigned long stamp INTERN tdm_private_capture * tdm_capture_create_output_internal(tdm_private_output *private_output, - tdm_error *error) + tdm_error *error) { tdm_private_display *private_display = private_output->private_display; tdm_func_output *func_output = &private_display->func_output; @@ -155,7 +155,7 @@ tdm_capture_create_output_internal(tdm_private_output *private_output, } capture_backend = func_output->output_create_capture( - private_output->output_backend, &ret); + private_output->output_backend, &ret); if (ret != TDM_ERROR_NONE) { if (error) *error = ret; @@ -172,7 +172,7 @@ tdm_capture_create_output_internal(tdm_private_output *private_output, } ret = func_capture->capture_set_done_handler(capture_backend, - tdm_capture_cb_done, private_capture); + tdm_capture_cb_done, private_capture); if (ret != TDM_ERROR_NONE) { TDM_ERR("capture(%p) set capture_done_handler failed", private_capture); func_capture->capture_destroy(capture_backend); @@ -206,7 +206,7 @@ tdm_capture_create_output_internal(tdm_private_output *private_output, INTERN tdm_private_capture * tdm_capture_create_layer_internal(tdm_private_layer *private_layer, - tdm_error *error) + tdm_error *error) { tdm_private_output *private_output = private_layer->private_output; tdm_private_display *private_display = private_output->private_display; @@ -226,7 +226,7 @@ tdm_capture_create_layer_internal(tdm_private_layer *private_layer, } capture_backend = func_layer->layer_create_capture(private_layer->layer_backend, - &ret); + &ret); if (ret != TDM_ERROR_NONE) return NULL; @@ -403,7 +403,7 @@ tdm_capture_commit(tdm_capture *capture) private_output = private_capture->private_output; if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) { TDM_ERR("output(%d) dpms: %s", private_output->pipe, - dpms_str(private_output->current_dpms_value)); + dpms_str(private_output->current_dpms_value)); _pthread_mutex_unlock(&private_display->lock); return TDM_ERROR_BAD_REQUEST; } diff --git a/src/tdm_display.c b/src/tdm_display.c index 0148871..1790229 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -45,62 +45,62 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define COUNT_MAX 10 #define DISPLAY_FUNC_ENTRY() \ - tdm_private_display *private_display; \ - tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \ - private_display = (tdm_private_display*)dpy; + tdm_private_display *private_display; \ + tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ + TDM_RETURN_VAL_IF_FAIL(dpy != NULL, TDM_ERROR_INVALID_PARAMETER); \ + private_display = (tdm_private_display*)dpy; #define DISPLAY_FUNC_ENTRY_ERROR() \ - tdm_private_display *private_display; \ - tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(dpy != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ - private_display = (tdm_private_display*)dpy; + tdm_private_display *private_display; \ + tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(dpy != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ + private_display = (tdm_private_display*)dpy; #define OUTPUT_FUNC_ENTRY() \ - tdm_private_display *private_display; \ - tdm_private_output *private_output; \ - tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER); \ - private_output = (tdm_private_output*)output; \ - private_display = private_output->private_display + tdm_private_display *private_display; \ + tdm_private_output *private_output; \ + tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ + TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER); \ + private_output = (tdm_private_output*)output; \ + private_display = private_output->private_display #define OUTPUT_FUNC_ENTRY_ERROR() \ - tdm_private_display *private_display; \ - tdm_private_output *private_output; \ - tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(output != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ - private_output = (tdm_private_output*)output; \ - private_display = private_output->private_display + tdm_private_display *private_display; \ + tdm_private_output *private_output; \ + tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(output != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ + private_output = (tdm_private_output*)output; \ + private_display = private_output->private_display #define LAYER_FUNC_ENTRY() \ - tdm_private_display *private_display; \ - tdm_private_output *private_output; \ - tdm_private_layer *private_layer; \ - tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL(layer != NULL, TDM_ERROR_INVALID_PARAMETER); \ - private_layer = (tdm_private_layer*)layer; \ - private_output = private_layer->private_output; \ - private_display = private_output->private_display + tdm_private_display *private_display; \ + tdm_private_output *private_output; \ + tdm_private_layer *private_layer; \ + tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ + TDM_RETURN_VAL_IF_FAIL(layer != NULL, TDM_ERROR_INVALID_PARAMETER); \ + private_layer = (tdm_private_layer*)layer; \ + private_output = private_layer->private_output; \ + private_display = private_output->private_display #define LAYER_FUNC_ENTRY_ERROR() \ - tdm_private_display *private_display; \ - tdm_private_output *private_output; \ - tdm_private_layer *private_layer; \ - tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(layer != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ - private_layer = (tdm_private_layer*)layer; \ - private_output = private_layer->private_output; \ - private_display = private_output->private_display + tdm_private_display *private_display; \ + tdm_private_output *private_output; \ + tdm_private_layer *private_layer; \ + tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ + TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(layer != NULL, TDM_ERROR_INVALID_PARAMETER, NULL); \ + private_layer = (tdm_private_layer*)layer; \ + private_output = private_layer->private_output; \ + private_display = private_output->private_display #define LAYER_FUNC_ENTRY_VOID_RETURN() \ - tdm_private_display *private_display; \ - tdm_private_output *private_output; \ - tdm_private_layer *private_layer; \ - tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ - TDM_RETURN_IF_FAIL(layer != NULL); \ - private_layer = (tdm_private_layer*)layer; \ - private_output = private_layer->private_output; \ - private_display = private_output->private_display + tdm_private_display *private_display; \ + tdm_private_output *private_output; \ + tdm_private_layer *private_layer; \ + tdm_error ret = TDM_ERROR_NONE; /* default TDM_ERROR_NONE */\ + TDM_RETURN_IF_FAIL(layer != NULL); \ + private_layer = (tdm_private_layer*)layer; \ + private_output = private_layer->private_output; \ + private_display = private_output->private_display #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -110,7 +110,8 @@ struct type_name { }; #define type_name_fn(res) \ -const char * res##_str(int type) { \ +const char * res##_str(int type) \ +{ \ unsigned int i; \ for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ if (res##_names[i].type == type) \ @@ -185,7 +186,7 @@ _tdm_display_unlock(tdm_display *dpy, const char *func) EXTERN tdm_error tdm_display_get_capabilities(tdm_display *dpy, - tdm_display_capability *capabilities) + tdm_display_capability *capabilities) { DISPLAY_FUNC_ENTRY(); @@ -202,7 +203,7 @@ tdm_display_get_capabilities(tdm_display *dpy, EXTERN tdm_error tdm_display_get_pp_capabilities(tdm_display *dpy, - tdm_pp_capability *capabilities) + tdm_pp_capability *capabilities) { DISPLAY_FUNC_ENTRY(); @@ -225,7 +226,7 @@ tdm_display_get_pp_capabilities(tdm_display *dpy, EXTERN tdm_error tdm_display_get_pp_available_formats(tdm_display *dpy, - const tbm_format **formats, int *count) + const tbm_format **formats, int *count) { DISPLAY_FUNC_ENTRY(); @@ -250,7 +251,7 @@ tdm_display_get_pp_available_formats(tdm_display *dpy, EXTERN tdm_error tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h, - int *max_w, int *max_h, int *preferred_align) + int *max_w, int *max_h, int *preferred_align) { DISPLAY_FUNC_ENTRY(); @@ -280,7 +281,7 @@ tdm_display_get_pp_available_size(tdm_display *dpy, int *min_w, int *min_h, EXTERN tdm_error tdm_display_get_capture_capabilities(tdm_display *dpy, - tdm_capture_capability *capabilities) + tdm_capture_capability *capabilities) { DISPLAY_FUNC_ENTRY(); @@ -303,7 +304,7 @@ tdm_display_get_capture_capabilities(tdm_display *dpy, EXTERN tdm_error tdm_display_get_catpure_available_formats(tdm_display *dpy, - const tbm_format **formats, int *count) + const tbm_format **formats, int *count) { DISPLAY_FUNC_ENTRY(); @@ -454,7 +455,7 @@ tdm_display_create_pp(tdm_display *dpy, tdm_error *error) EXTERN tdm_error tdm_output_get_model_info(tdm_output *output, const char **maker, - const char **model, const char **name) + const char **model, const char **name) { OUTPUT_FUNC_ENTRY(); @@ -505,7 +506,7 @@ _tdm_output_update(tdm_output *output_backend, void *user_data) INTERN void tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, - void *user_data) + void *user_data) { tdm_private_display *private_display; tdm_private_output *private_output = user_data; @@ -530,9 +531,9 @@ tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, value.u32 = status; tdm_output_call_change_handler_internal(private_output, - &private_output->change_handler_list_sub, - TDM_OUTPUT_CHANGE_CONNECTION, - value); + &private_output->change_handler_list_sub, + TDM_OUTPUT_CHANGE_CONNECTION, + value); ret = tdm_thread_send_cb(private_display->private_loop, &output_status.base); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); @@ -545,15 +546,15 @@ tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, value.u32 = status; tdm_output_call_change_handler_internal(private_output, - &private_output->change_handler_list_main, - TDM_OUTPUT_CHANGE_CONNECTION, - value); + &private_output->change_handler_list_main, + TDM_OUTPUT_CHANGE_CONNECTION, + value); } EXTERN tdm_error tdm_output_add_change_handler(tdm_output *output, - tdm_output_change_handler func, - void *user_data) + tdm_output_change_handler func, + void *user_data) { tdm_private_change_handler *change_handler; OUTPUT_FUNC_ENTRY(); @@ -592,8 +593,8 @@ tdm_output_add_change_handler(tdm_output *output, EXTERN void tdm_output_remove_change_handler(tdm_output *output, - tdm_output_change_handler func, - void *user_data) + tdm_output_change_handler func, + void *user_data) { tdm_private_display *private_display; tdm_private_output *private_output; @@ -703,7 +704,7 @@ tdm_output_get_layer(tdm_output *output, int index, tdm_error *error) EXTERN tdm_error tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props, - int *count) + int *count) { OUTPUT_FUNC_ENTRY(); @@ -722,7 +723,7 @@ tdm_output_get_available_properties(tdm_output *output, const tdm_prop **props, EXTERN tdm_error tdm_output_get_available_modes(tdm_output *output, - const tdm_output_mode **modes, int *count) + const tdm_output_mode **modes, int *count) { OUTPUT_FUNC_ENTRY(); @@ -741,7 +742,7 @@ tdm_output_get_available_modes(tdm_output *output, EXTERN tdm_error tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h, - int *max_w, int *max_h, int *preferred_align) + int *max_w, int *max_h, int *preferred_align) { OUTPUT_FUNC_ENTRY(); @@ -765,7 +766,7 @@ tdm_output_get_available_size(tdm_output *output, int *min_w, int *min_h, EXTERN tdm_error tdm_output_get_physical_size(tdm_output *output, unsigned int *mmWidth, - unsigned int *mmHeight) + unsigned int *mmHeight) { OUTPUT_FUNC_ENTRY(); @@ -829,7 +830,7 @@ tdm_output_set_property(tdm_output *output, unsigned int id, tdm_value value) } ret = func_output->output_set_property(private_output->output_backend, id, - value); + value); _pthread_mutex_unlock(&private_display->lock); @@ -855,7 +856,7 @@ tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value) } ret = func_output->output_get_property(private_output->output_backend, id, - value); + value); _pthread_mutex_unlock(&private_display->lock); @@ -864,7 +865,7 @@ tdm_output_get_property(tdm_output *output, unsigned int id, tdm_value *value) INTERN void tdm_output_cb_vblank(tdm_output *output_backend, 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_private_vblank_handler *vblank_handler = user_data; tdm_private_display *private_display; @@ -898,7 +899,7 @@ tdm_output_cb_vblank(tdm_output *output_backend, unsigned int sequence, if (vblank_handler->func) { _pthread_mutex_unlock(&private_display->lock); vblank_handler->func(vblank_handler->private_output, sequence, - tv_sec, tv_usec, vblank_handler->user_data); + tv_sec, tv_usec, vblank_handler->user_data); _pthread_mutex_lock(&private_display->lock); } @@ -908,7 +909,7 @@ tdm_output_cb_vblank(tdm_output *output_backend, unsigned int sequence, INTERN void tdm_output_cb_commit(tdm_output *output_backend, 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_private_commit_handler *commit_handler = user_data; tdm_private_display *private_display; @@ -950,7 +951,7 @@ tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence, if (private_layer->buffer_queue) { tbm_surface_queue_release(private_layer->buffer_queue, - private_layer->showing_buffer); + private_layer->showing_buffer); } } @@ -959,14 +960,14 @@ tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence, if (tdm_debug_buffer) TDM_INFO("layer(%p) waiting_buffer(%p) showing_buffer(%p)", - private_layer, private_layer->waiting_buffer, - private_layer->showing_buffer); + private_layer, private_layer->waiting_buffer, + private_layer->showing_buffer); } if (commit_handler->func) { _pthread_mutex_unlock(&private_display->lock); commit_handler->func(private_output, sequence, - tv_sec, tv_usec, commit_handler->user_data); + tv_sec, tv_usec, commit_handler->user_data); _pthread_mutex_lock(&private_display->lock); } @@ -976,7 +977,7 @@ tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence, EXTERN tdm_error tdm_output_wait_vblank(tdm_output *output, int interval, int sync, - tdm_output_vblank_handler func, void *user_data) + tdm_output_vblank_handler func, void *user_data) { tdm_func_output *func_output; tdm_private_vblank_handler *vblank_handler; @@ -986,7 +987,7 @@ tdm_output_wait_vblank(tdm_output *output, int interval, int sync, if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) { TDM_ERR("output(%d) dpms: %s", private_output->pipe, - dpms_str(private_output->current_dpms_value)); + dpms_str(private_output->current_dpms_value)); _pthread_mutex_unlock(&private_display->lock); return TDM_ERROR_BAD_REQUEST; } @@ -1013,7 +1014,7 @@ tdm_output_wait_vblank(tdm_output *output, int interval, int sync, vblank_handler->owner_tid = syscall(SYS_gettid); ret = func_output->output_wait_vblank(private_output->output_backend, interval, - sync, vblank_handler); + sync, vblank_handler); if (ret != TDM_ERROR_NONE) { _pthread_mutex_unlock(&private_display->lock); return ret; @@ -1022,7 +1023,7 @@ tdm_output_wait_vblank(tdm_output *output, int interval, int sync, if (!private_output->regist_vblank_cb) { private_output->regist_vblank_cb = 1; ret = func_output->output_set_vblank_handler(private_output->output_backend, - tdm_output_cb_vblank); + tdm_output_cb_vblank); } _pthread_mutex_unlock(&private_display->lock); @@ -1032,7 +1033,7 @@ tdm_output_wait_vblank(tdm_output *output, int interval, int sync, static tdm_error _tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, - void *user_data) + void *user_data) { tdm_func_output *func_output; tdm_private_commit_handler *commit_handler; @@ -1058,13 +1059,13 @@ _tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, commit_handler->owner_tid = syscall(SYS_gettid); ret = func_output->output_commit(private_output->output_backend, sync, - commit_handler); + commit_handler); TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret); if (!private_output->regist_commit_cb) { private_output->regist_commit_cb = 1; ret = func_output->output_set_commit_handler(private_output->output_backend, - tdm_output_cb_commit); + tdm_output_cb_commit); } return ret; @@ -1072,7 +1073,7 @@ _tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, EXTERN tdm_error tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, - void *user_data) + void *user_data) { OUTPUT_FUNC_ENTRY(); @@ -1080,7 +1081,7 @@ tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) { TDM_ERR("output(%d) dpms: %s", private_output->pipe, - dpms_str(private_output->current_dpms_value)); + dpms_str(private_output->current_dpms_value)); _pthread_mutex_unlock(&private_display->lock); return TDM_ERROR_BAD_REQUEST; } @@ -1177,9 +1178,9 @@ tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value) value.u32 = dpms_value; tdm_output_call_change_handler_internal(private_output, - &private_output->change_handler_list_main, - TDM_OUTPUT_CHANGE_DPMS, - value); + &private_output->change_handler_list_main, + TDM_OUTPUT_CHANGE_DPMS, + value); } _pthread_mutex_unlock(&private_display->lock); @@ -1222,8 +1223,7 @@ tdm_output_create_capture(tdm_output *output, tdm_error *error) _pthread_mutex_lock(&private_display->lock); - capture = (tdm_capture *)tdm_capture_create_output_internal(private_output, - error); + capture = (tdm_capture *)tdm_capture_create_output_internal(private_output, error); _pthread_mutex_unlock(&private_display->lock); @@ -1232,9 +1232,9 @@ tdm_output_create_capture(tdm_output *output, tdm_error *error) INTERN void tdm_output_call_change_handler_internal(tdm_private_output *private_output, - struct list_head *change_handler_list, - tdm_output_change_type type, - tdm_value value) + struct list_head *change_handler_list, + tdm_output_change_type type, + tdm_value value) { tdm_private_display *private_display; tdm_private_change_handler *change_handler; @@ -1246,10 +1246,10 @@ tdm_output_call_change_handler_internal(tdm_private_output *private_output, if (!tdm_thread_in_display_thread(syscall(SYS_gettid))) { if (type & TDM_OUTPUT_CHANGE_CONNECTION) TDM_INFO("output(%d) changed: %s (%d)", - private_output->pipe, status_str(value.u32), value.u32); + private_output->pipe, status_str(value.u32), value.u32); if (type & TDM_OUTPUT_CHANGE_DPMS) TDM_INFO("output(%d) changed: dpms %s (%d)", - private_output->pipe, dpms_str(value.u32), value.u32); + private_output->pipe, dpms_str(value.u32), value.u32); } if (LIST_IS_EMPTY(change_handler_list)) @@ -1261,7 +1261,7 @@ tdm_output_call_change_handler_internal(tdm_private_output *private_output, _pthread_mutex_unlock(&private_display->lock); change_handler->func(private_output, type, - value, change_handler->user_data); + value, change_handler->user_data); _pthread_mutex_lock(&private_display->lock); } } @@ -1283,8 +1283,7 @@ tdm_layer_get_capabilities(tdm_layer *layer, tdm_layer_capability *capabilities) } EXTERN tdm_error -tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats, - int *count) +tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats, int *count) { LAYER_FUNC_ENTRY(); @@ -1302,8 +1301,7 @@ tdm_layer_get_available_formats(tdm_layer *layer, const tbm_format **formats, } EXTERN tdm_error -tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props, - int *count) +tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props, int *count) { LAYER_FUNC_ENTRY(); @@ -1405,13 +1403,13 @@ tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info) } TDM_INFO("layer(%p) info: src(%dx%d %d,%d %dx%d %c%c%c%c) dst(%d,%d %dx%d) trans(%d)", - private_layer, info->src_config.size.h, info->src_config.size.v, - info->src_config.pos.x, info->src_config.pos.y, - info->src_config.pos.w, info->src_config.pos.h, - FOURCC_STR(info->src_config.format), - info->dst_pos.x, info->dst_pos.y, - info->dst_pos.w, info->dst_pos.h, - info->transform); + private_layer, info->src_config.size.h, info->src_config.size.v, + info->src_config.pos.x, info->src_config.pos.y, + info->src_config.pos.w, info->src_config.pos.h, + FOURCC_STR(info->src_config.format), + info->dst_pos.x, info->dst_pos.y, + info->dst_pos.w, info->dst_pos.h, + info->transform); ret = func_layer->layer_set_info(private_layer->layer_backend, info); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); @@ -1507,7 +1505,7 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) private_layer->waiting_buffer = tdm_buffer_ref_backend(buffer); if (tdm_debug_buffer) TDM_INFO("layer(%p) waiting_buffer(%p)", - private_layer, private_layer->waiting_buffer); + private_layer, private_layer->waiting_buffer); } _pthread_mutex_unlock(&private_display->lock); @@ -1533,7 +1531,7 @@ tdm_layer_unset_buffer(tdm_layer *layer) if (tdm_debug_buffer) TDM_INFO("layer(%p) waiting_buffer(%p)", - private_layer, private_layer->waiting_buffer); + private_layer, private_layer->waiting_buffer); } if (private_layer->showing_buffer) { @@ -1544,7 +1542,7 @@ tdm_layer_unset_buffer(tdm_layer *layer) if (tdm_debug_buffer) TDM_INFO("layer(%p) showing_buffer(%p)", - private_layer, private_layer->showing_buffer); + private_layer, private_layer->showing_buffer); } private_layer->usable = 1; @@ -1580,8 +1578,7 @@ tdm_layer_get_displaying_buffer(tdm_layer *layer, tdm_error *error) if (error) *error = TDM_ERROR_OPERATION_FAILED; _pthread_mutex_unlock(&private_display->lock); - TDM_ERR("layer(%p) showing_buffer is null", - private_layer); + TDM_ERR("layer(%p) showing_buffer is null", private_layer); return NULL; } _pthread_mutex_unlock(&private_display->lock); @@ -1606,11 +1603,10 @@ _tbm_layer_queue_acquirable_cb(tbm_surface_queue_h surface_queue, void *data) return; } - if (TBM_SURFACE_QUEUE_ERROR_NONE != tbm_surface_queue_acquire( - private_layer->buffer_queue, &surface) || - surface == NULL) { + if (TBM_SURFACE_QUEUE_ERROR_NONE != tbm_surface_queue_acquire(private_layer->buffer_queue, &surface) || + surface == NULL) { TDM_ERR("layer(%p) tbm_surface_queue_acquire() failed surface:%p", - private_layer, surface); + private_layer, surface); _pthread_mutex_unlock(&private_display->lock); return; } @@ -1623,7 +1619,7 @@ _tbm_layer_queue_acquirable_cb(tbm_surface_queue_h surface_queue, void *data) _pthread_mutex_unlock(&private_display->lock); tdm_buffer_unref_backend(private_layer->waiting_buffer); tbm_surface_queue_release(private_layer->buffer_queue, - private_layer->waiting_buffer); + private_layer->waiting_buffer); _pthread_mutex_lock(&private_display->lock); } @@ -1631,7 +1627,7 @@ _tbm_layer_queue_acquirable_cb(tbm_surface_queue_h surface_queue, void *data) if (tdm_debug_buffer) TDM_INFO("layer(%p) waiting_buffer(%p)", - private_layer, private_layer->waiting_buffer); + private_layer, private_layer->waiting_buffer); ret = _tdm_output_commit(private_layer->private_output, 0, NULL, NULL); if (ret != TDM_ERROR_NONE) @@ -1655,7 +1651,7 @@ _tbm_layer_queue_destroy_cb(tbm_surface_queue_h surface_queue, void *data) _pthread_mutex_unlock(&private_display->lock); tdm_buffer_unref_backend(private_layer->waiting_buffer); tbm_surface_queue_release(private_layer->buffer_queue, - private_layer->waiting_buffer); + private_layer->waiting_buffer); _pthread_mutex_lock(&private_display->lock); } @@ -1693,22 +1689,22 @@ tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue) _pthread_mutex_unlock(&private_display->lock); tdm_buffer_unref_backend(private_layer->waiting_buffer); tbm_surface_queue_release(private_layer->buffer_queue, - private_layer->waiting_buffer); + private_layer->waiting_buffer); private_layer->waiting_buffer = NULL; _pthread_mutex_lock(&private_display->lock); if (tdm_debug_buffer) TDM_INFO("layer(%p) waiting_buffer(%p)", - private_layer, private_layer->waiting_buffer); + private_layer, private_layer->waiting_buffer); } private_layer->buffer_queue = buffer_queue; tbm_surface_queue_add_acquirable_cb(private_layer->buffer_queue, - _tbm_layer_queue_acquirable_cb, - layer); + _tbm_layer_queue_acquirable_cb, + layer); tbm_surface_queue_add_destroy_cb(private_layer->buffer_queue, - _tbm_layer_queue_destroy_cb, - layer); + _tbm_layer_queue_destroy_cb, + layer); _pthread_mutex_unlock(&private_display->lock); return ret; @@ -1728,26 +1724,26 @@ tdm_layer_unset_buffer_queue(tdm_layer *layer) _pthread_mutex_unlock(&private_display->lock); tdm_buffer_unref_backend(private_layer->waiting_buffer); tbm_surface_queue_release(private_layer->buffer_queue, - private_layer->waiting_buffer); + private_layer->waiting_buffer); private_layer->waiting_buffer = NULL; _pthread_mutex_lock(&private_display->lock); if (tdm_debug_buffer) TDM_INFO("layer(%p) waiting_buffer(%p)", - private_layer, private_layer->waiting_buffer); + private_layer, private_layer->waiting_buffer); } if (private_layer->showing_buffer) { _pthread_mutex_unlock(&private_display->lock); tdm_buffer_unref_backend(private_layer->showing_buffer); tbm_surface_queue_release(private_layer->buffer_queue, - private_layer->showing_buffer); + private_layer->showing_buffer); _pthread_mutex_lock(&private_display->lock); private_layer->showing_buffer = NULL; if (tdm_debug_buffer) TDM_INFO("layer(%p) showing_buffer(%p)", - private_layer, private_layer->showing_buffer); + private_layer, private_layer->showing_buffer); } tbm_surface_queue_remove_acquirable_cb(private_layer->buffer_queue, _tbm_layer_queue_acquirable_cb, layer); @@ -1822,8 +1818,7 @@ tdm_layer_create_capture(tdm_layer *layer, tdm_error *error) _pthread_mutex_lock(&private_display->lock); - capture = (tdm_capture *)tdm_capture_create_layer_internal(private_layer, - error); + capture = (tdm_capture *)tdm_capture_create_layer_internal(private_layer, error); _pthread_mutex_unlock(&private_display->lock); diff --git a/src/tdm_event_loop.c b/src/tdm_event_loop.c index d1eb6ea..51a8f55 100644 --- a/src/tdm_event_loop.c +++ b/src/tdm_event_loop.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -43,21 +43,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include -typedef struct _tdm_event_loop_source_base -{ +typedef struct _tdm_event_loop_source_base { struct wl_event_source *wl_source; } tdm_event_loop_source_base; -typedef struct _tdm_event_loop_source_fd -{ +typedef struct _tdm_event_loop_source_fd { tdm_event_loop_source_base base; tdm_private_display *private_display; tdm_event_loop_fd_handler func; void *user_data; } tdm_event_loop_source_fd; -typedef struct _tdm_event_loop_source_timer -{ +typedef struct _tdm_event_loop_source_timer { tdm_event_loop_source_base base; tdm_private_display *private_display; tdm_event_loop_timer_handler func; @@ -101,7 +98,7 @@ tdm_event_loop_init(tdm_private_display *private_display) if (private_display->private_loop) return TDM_ERROR_NONE; - private_loop = calloc(1, sizeof *private_loop); + private_loop = calloc(1, sizeof * private_loop); if (!private_loop) { TDM_ERR("alloc failed"); return TDM_ERROR_OUT_OF_MEMORY; @@ -193,9 +190,9 @@ tdm_event_loop_create_backend_source(tdm_private_display *private_display) private_loop->backend_source = tdm_event_loop_add_fd_handler(private_display, fd, - TDM_EVENT_LOOP_READABLE, - _tdm_event_loop_main_fd_handler, - private_display, &ret); + TDM_EVENT_LOOP_READABLE, + _tdm_event_loop_main_fd_handler, + private_display, &ret); if (!private_loop->backend_source) { TDM_ERR("no backend fd(%d) source", fd); return; @@ -231,7 +228,7 @@ tdm_event_loop_dispatch(tdm_private_display *private_display) TDM_INFO("dispatch"); if (tdm_thread_is_running() && - tdm_thread_in_display_thread(syscall(SYS_gettid))) { + tdm_thread_in_display_thread(syscall(SYS_gettid))) { TDM_NEVER_GET_HERE(); return TDM_ERROR_OPERATION_FAILED; } @@ -259,7 +256,7 @@ tdm_event_loop_flush(tdm_private_display *private_display) TDM_RETURN_IF_FAIL(private_loop->wl_display != NULL); if (tdm_thread_is_running() && - tdm_thread_in_display_thread(syscall(SYS_gettid))) { + tdm_thread_in_display_thread(syscall(SYS_gettid))) { TDM_NEVER_GET_HERE(); return; } @@ -297,10 +294,10 @@ _tdm_event_loop_fd_func(int fd, uint32_t wl_mask, void *data) return 1; } -EXTERN tdm_event_loop_source* +EXTERN tdm_event_loop_source * tdm_event_loop_add_fd_handler(tdm_display *dpy, int fd, tdm_event_loop_mask mask, - tdm_event_loop_fd_handler func, void *user_data, - tdm_error *error) + tdm_event_loop_fd_handler func, void *user_data, + tdm_error *error) { tdm_private_display *private_display; tdm_private_loop *private_loop; @@ -328,7 +325,7 @@ tdm_event_loop_add_fd_handler(tdm_display *dpy, int fd, tdm_event_loop_mask mask fd_source->base.wl_source = wl_event_loop_add_fd(private_loop->wl_loop, - fd, wl_mask, _tdm_event_loop_fd_func, fd_source); + fd, wl_mask, _tdm_event_loop_fd_func, fd_source); if (!fd_source->base.wl_source) { if (error) *error = TDM_ERROR_OUT_OF_MEMORY; @@ -343,7 +340,7 @@ tdm_event_loop_add_fd_handler(tdm_display *dpy, int fd, tdm_event_loop_mask mask if (error) *error = TDM_ERROR_NONE; - return (tdm_event_loop_source*)fd_source; + return (tdm_event_loop_source *)fd_source; } EXTERN tdm_error @@ -388,9 +385,9 @@ _tdm_event_loop_timer_func(void *data) return 1; } -EXTERN tdm_event_loop_source* +EXTERN tdm_event_loop_source * tdm_event_loop_add_timer_handler(tdm_display *dpy, tdm_event_loop_timer_handler func, - void *user_data, tdm_error *error) + void *user_data, tdm_error *error) { tdm_private_display *private_display; tdm_private_loop *private_loop; @@ -411,7 +408,7 @@ tdm_event_loop_add_timer_handler(tdm_display *dpy, tdm_event_loop_timer_handler timer_source->base.wl_source = wl_event_loop_add_timer(private_loop->wl_loop, - _tdm_event_loop_timer_func, timer_source); + _tdm_event_loop_timer_func, timer_source); if (!timer_source->base.wl_source) { if (error) *error = TDM_ERROR_OUT_OF_MEMORY; @@ -426,7 +423,7 @@ tdm_event_loop_add_timer_handler(tdm_display *dpy, tdm_event_loop_timer_handler if (error) *error = TDM_ERROR_NONE; - return (tdm_event_loop_source*)timer_source; + return (tdm_event_loop_source *)timer_source; } EXTERN tdm_error diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 2a77cea..a57a732 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -1,3 +1,38 @@ +/************************************************************************** + * + * libtdm + * + * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Eunchul Kim , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 #include "config.h" #endif @@ -42,7 +77,7 @@ tdm_helper_get_time_in_micros(void) static void _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2, - int size2, void *data3, int size3) + int size2, void *data3, int size3) { unsigned int *blocks; FILE *fp = fopen(file, "w+"); @@ -66,13 +101,13 @@ _tdm_helper_dump_raw(const char *file, void *data1, int size1, void *data2, static void _tdm_helper_dump_png(const char *file, const void *data, int width, - int height) + int height) { FILE *fp = fopen(file, "wb"); TDM_RETURN_IF_FAIL(fp != NULL); png_structp pPngStruct = - png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!pPngStruct) { fclose(fp); return; @@ -87,20 +122,20 @@ _tdm_helper_dump_png(const char *file, const void *data, int width, png_init_io(pPngStruct, fp); png_set_IHDR(pPngStruct, - pPngInfo, - width, - height, - PNG_DEPTH, - PNG_COLOR_TYPE_RGBA, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + pPngInfo, + width, + height, + PNG_DEPTH, + PNG_COLOR_TYPE_RGBA, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); png_set_bgr(pPngStruct); png_write_info(pPngStruct, pPngInfo); const int pixel_size = 4; // RGBA png_bytep *row_pointers = - png_malloc(pPngStruct, height * sizeof(png_byte *)); + png_malloc(pPngStruct, height * sizeof(png_byte *)); unsigned int *blocks = (unsigned int *)data; int y = 0; @@ -108,7 +143,7 @@ _tdm_helper_dump_png(const char *file, const void *data, int width, for (; y < height; ++y) { png_bytep row = - png_malloc(pPngStruct, sizeof(png_byte) * width * pixel_size); + png_malloc(pPngStruct, sizeof(png_byte) * width * pixel_size); row_pointers[y] = (png_bytep)row; for (x = 0; x < width; ++x) { unsigned int curBlock = blocks[y * width + x]; @@ -160,36 +195,36 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) case TBM_FORMAT_ARGB8888: case TBM_FORMAT_XRGB8888: _tdm_helper_dump_png(file, info.planes[0].ptr, - info.planes[0].stride >> 2, info.height); + info.planes[0].stride >> 2, info.height); break; case TBM_FORMAT_YVU420: case TBM_FORMAT_YUV420: _tdm_helper_dump_raw(file, - info.planes[0].ptr, - info.planes[0].stride * info.height, - info.planes[1].ptr, - info.planes[1].stride * (info.height >> 1), - info.planes[2].ptr, - info.planes[2].stride * (info.height >> 1)); + info.planes[0].ptr, + info.planes[0].stride * info.height, + info.planes[1].ptr, + info.planes[1].stride * (info.height >> 1), + info.planes[2].ptr, + info.planes[2].stride * (info.height >> 1)); break; case TBM_FORMAT_NV12: case TBM_FORMAT_NV21: _tdm_helper_dump_raw(file, - info.planes[0].ptr, - info.planes[0].stride * info.height, - info.planes[1].ptr, - info.planes[1].stride * (info.height >> 1), NULL, - 0); + info.planes[0].ptr, + info.planes[0].stride * info.height, + info.planes[1].ptr, + info.planes[1].stride * (info.height >> 1), NULL, + 0); break; case TBM_FORMAT_YUYV: case TBM_FORMAT_UYVY: _tdm_helper_dump_raw(file, - info.planes[0].ptr, - info.planes[0].stride * info.height, NULL, 0, - NULL, 0); + info.planes[0].ptr, + info.planes[0].stride * info.height, NULL, 0, + NULL, 0); break; default: - TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR (info.format)); + TDM_ERR("can't dump %c%c%c%c buffer", FOURCC_STR(info.format)); tbm_surface_unmap(buffer); return; } diff --git a/src/tdm_macro.h b/src/tdm_macro.h index a547c0a..b87b4a0 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * **************************************************************************/ #ifndef _TDM_MACRO_H_ @@ -68,55 +68,54 @@ extern "C" { #endif /* check condition */ -#define TDM_RETURN_IF_FAIL(cond) {\ - if (!(cond)) {\ - TDM_ERR ("'%s' failed", #cond);\ - return;\ - }\ +#define TDM_RETURN_IF_FAIL(cond) { \ + if (!(cond)) { \ + TDM_ERR("'%s' failed", #cond); \ + return; \ + } \ } -#define TDM_RETURN_VAL_IF_FAIL(cond, val) {\ - if (!(cond)) {\ - TDM_ERR ("'%s' failed", #cond);\ - return val;\ - }\ +#define TDM_RETURN_VAL_IF_FAIL(cond, val) { \ + if (!(cond)) { \ + TDM_ERR("'%s' failed", #cond); \ + return val; \ + } \ } -#define TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(cond, error_v, val) {\ - if (!(cond)) {\ - TDM_ERR ("'%s' failed", #cond);\ - ret = error_v;\ - if (error) *error = ret;\ - return val;\ - }\ +#define TDM_RETURN_VAL_IF_FAIL_WITH_ERROR(cond, error_v, val) { \ + if (!(cond)) { \ + TDM_ERR("'%s' failed", #cond); \ + ret = error_v; \ + if (error) *error = ret; \ + return val; \ + } \ } -#define TDM_WARNING_IF_FAIL(cond) {\ - if (!(cond))\ - TDM_ERR ("'%s' failed", #cond);\ +#define TDM_WARNING_IF_FAIL(cond) { \ + if (!(cond)) \ + TDM_ERR("'%s' failed", #cond); \ } -#define TDM_GOTO_IF_FAIL(cond, dst) {\ - if (!(cond)) {\ - TDM_ERR ("'%s' failed", #cond);\ - goto dst;\ - }\ +#define TDM_GOTO_IF_FAIL(cond, dst) { \ + if (!(cond)) { \ + TDM_ERR("'%s' failed", #cond); \ + goto dst; \ + } \ } #define TDM_NEVER_GET_HERE() TDM_ERR("** NEVER GET HERE **") #define TDM_SNPRINTF(p, len, fmt, ARG...) \ - do { \ - if (p && len && *len > 0) \ - { \ - int s = snprintf(p, *len, fmt, ##ARG); \ - p += s; \ - *len -= s; \ - } \ - } while (0) - -#define C(b,m) (((b) >> (m)) & 0xFF) -#define B(c,s) ((((unsigned int)(c)) & 0xff) << (s)) -#define FOURCC(a,b,c,d) (B(d,24) | B(c,16) | B(b,8) | B(a,0)) -#define FOURCC_STR(id) C(id,0), C(id,8), C(id,16), C(id,24) -#define FOURCC_ID(str) FOURCC(((char*)str)[0],((char*)str)[1],((char*)str)[2],((char*)str)[3]) + do { \ + if (p && len && *len > 0) { \ + int s = snprintf(p, *len, fmt, ##ARG); \ + p += s; \ + *len -= s; \ + } \ + } while (0) + +#define C(b, m) (((b) >> (m)) & 0xFF) +#define B(c, s) ((((unsigned int)(c)) & 0xff) << (s)) +#define FOURCC(a, b, c, d) (B(d, 24) | B(c, 16) | B(b, 8) | B(a, 0)) +#define FOURCC_STR(id) C(id, 0), C(id, 8), C(id, 16), C(id, 24) +#define FOURCC_ID(str) FOURCC(((char*)str)[0], ((char*)str)[1], ((char*)str)[2], ((char*)str)[3]) #ifdef __cplusplus } diff --git a/src/tdm_pp.c b/src/tdm_pp.c index c574d8a..2db7af4 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -42,18 +42,18 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tdm_private.h" #define PP_FUNC_ENTRY() \ - tdm_func_pp *func_pp; \ - tdm_private_display *private_display; \ - tdm_private_pp *private_pp; \ - tdm_error ret = TDM_ERROR_NONE; \ - TDM_RETURN_VAL_IF_FAIL(pp != NULL, TDM_ERROR_INVALID_PARAMETER); \ - private_pp = (tdm_private_pp*)pp; \ - private_display = private_pp->private_display; \ - func_pp = &private_display->func_pp + tdm_func_pp *func_pp; \ + tdm_private_display *private_display; \ + tdm_private_pp *private_pp; \ + tdm_error ret = TDM_ERROR_NONE; \ + TDM_RETURN_VAL_IF_FAIL(pp != NULL, TDM_ERROR_INVALID_PARAMETER); \ + private_pp = (tdm_private_pp*)pp; \ + private_display = private_pp->private_display; \ + func_pp = &private_display->func_pp static tdm_error _tdm_pp_check_if_exist(tdm_private_pp *private_pp, - tbm_surface_h src, tbm_surface_h dst) + tbm_surface_h src, tbm_surface_h dst) { tdm_buffer_info *buf_info = NULL; @@ -90,7 +90,7 @@ _tdm_pp_check_if_exist(tdm_private_pp *private_pp, INTERN void tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, - void *user_data) + void *user_data) { tdm_private_pp *private_pp = user_data; tdm_private_display *private_display = private_pp->private_display; @@ -326,15 +326,15 @@ tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info) } TDM_INFO("pp(%p) info: src(%dx%d %d,%d %dx%d %c%c%c%c) dst(%dx%d %d,%d %dx%d %c%c%c%c) trans(%d) sync(%d) flags(%x)", - private_pp, info->src_config.size.h, info->src_config.size.v, - info->src_config.pos.x, info->src_config.pos.y, - info->src_config.pos.w, info->src_config.pos.h, - FOURCC_STR(info->src_config.format), - info->dst_config.size.h, info->dst_config.size.v, - info->dst_config.pos.x, info->dst_config.pos.y, - info->dst_config.pos.w, info->dst_config.pos.h, - FOURCC_STR(info->dst_config.format), - info->transform, info->sync, info->flags); + private_pp, info->src_config.size.h, info->src_config.size.v, + info->src_config.pos.x, info->src_config.pos.y, + info->src_config.pos.w, info->src_config.pos.h, + FOURCC_STR(info->src_config.format), + info->dst_config.size.h, info->dst_config.size.v, + info->dst_config.pos.x, info->dst_config.pos.y, + info->dst_config.pos.w, info->dst_config.pos.h, + FOURCC_STR(info->dst_config.format), + info->transform, info->sync, info->flags); ret = func_pp->pp_set_info(private_pp->pp_backend, info); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); @@ -363,11 +363,11 @@ tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) if (tdm_display_check_module_abi(private_display, 1, 2) && private_display->caps_pp.max_attach_count > 0) { int length = LIST_LENGTH(&private_pp->src_pending_buffer_list) + - LIST_LENGTH(&private_pp->src_buffer_list); + LIST_LENGTH(&private_pp->src_buffer_list); if (length >= private_display->caps_pp.max_attach_count) { _pthread_mutex_unlock(&private_display->lock); TDM_DBG("failed: too many attached!! max_attach_count(%d)", - private_display->caps_pp.max_attach_count); + private_display->caps_pp.max_attach_count); return TDM_ERROR_BAD_REQUEST; } } diff --git a/src/tdm_private.h b/src/tdm_private.h index d751a81..8d07f03 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * **************************************************************************/ #ifndef _TDM_PRIVATE_H_ @@ -90,8 +90,8 @@ prototype_name_fn(dpms); prototype_name_fn(status); typedef enum { - TDM_CAPTURE_TARGET_OUTPUT, - TDM_CAPTURE_TARGET_LAYER, + TDM_CAPTURE_TARGET_OUTPUT, + TDM_CAPTURE_TARGET_LAYER, } tdm_capture_target; typedef struct _tdm_private_display tdm_private_display; @@ -314,7 +314,7 @@ tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, i tdm_private_output * tdm_display_find_output_stamp(tdm_private_display *private_display, - unsigned long stamp); + unsigned long stamp); tdm_private_pp * tdm_pp_find_stamp(tdm_private_display *private_display, unsigned long stamp); tdm_private_capture * @@ -322,25 +322,25 @@ tdm_capture_find_stamp(tdm_private_display *private_display, unsigned long stamp void tdm_output_cb_vblank(tdm_output *output_backend, 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); void tdm_output_cb_commit(tdm_output *output_backend, 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); void tdm_output_cb_status(tdm_output *output_backend, tdm_output_conn_status status, - void *user_data); + void *user_data); void tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, - void *user_data); + void *user_data); void tdm_capture_cb_done(tdm_capture *capture_backend, tbm_surface_h buffer, - void *user_data); + void *user_data); void tdm_output_call_change_handler_internal(tdm_private_output *private_output, - struct list_head *change_handler_list, - tdm_output_change_type type, - tdm_value value); + struct list_head *change_handler_list, + tdm_output_change_type type, + tdm_value value); tdm_private_pp * tdm_pp_create_internal(tdm_private_display *private_display, tdm_error *error); @@ -349,10 +349,10 @@ tdm_pp_destroy_internal(tdm_private_pp *private_pp); tdm_private_capture * tdm_capture_create_output_internal(tdm_private_output *private_output, - tdm_error *error); + tdm_error *error); tdm_private_capture * tdm_capture_create_layer_internal(tdm_private_layer *private_layer, - tdm_error *error); + tdm_error *error); void tdm_capture_destroy_internal(tdm_private_capture *private_capture); @@ -518,7 +518,7 @@ _tdm_display_unlock(tdm_display *dpy, const char *func); tdm_error tdm_display_update_output(tdm_private_display *private_display, - tdm_output *output_backend, int pipe); + tdm_output *output_backend, int pipe); #ifdef __cplusplus } diff --git a/src/tdm_server.c b/src/tdm_server.c index b053d47..99ff6d0 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -85,7 +85,7 @@ static int tdm_debug_server; 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) @@ -93,8 +93,8 @@ _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; } @@ -115,9 +115,9 @@ _tdm_server_update_timer(tdm_server_vblank_info *vblank_info, int interval) 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); @@ -136,7 +136,7 @@ _tdm_server_update_timer(tdm_server_vblank_info *vblank_info, int interval) 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 = (unsigned int)ceil((double)(next - curr) / 1000); if (ms_delay == 0) @@ -165,7 +165,7 @@ _tdm_server_update_timer(tdm_server_vblank_info *vblank_info, int interval) 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; @@ -176,7 +176,7 @@ _tdm_server_send_done(tdm_server_vblank_info *vblank_info, unsigned int sequence 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; @@ -187,7 +187,7 @@ _tdm_server_send_done(tdm_server_vblank_info *vblank_info, unsigned int sequence 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 */ @@ -200,8 +200,8 @@ _tdm_server_send_done(tdm_server_vblank_info *vblank_info, unsigned int sequence 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; @@ -233,10 +233,10 @@ _tdm_server_client_cb_destroy(struct wl_client *client, struct wl_resource *reso 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; @@ -270,7 +270,7 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, 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); @@ -292,7 +292,7 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, 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; } @@ -305,7 +305,7 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, 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; } @@ -318,12 +318,12 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, 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"); @@ -334,7 +334,7 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, 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"); @@ -348,10 +348,10 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, 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; } @@ -359,19 +359,19 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, 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; @@ -396,13 +396,13 @@ destroy_client_callback(struct wl_resource *resource) 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"); @@ -411,7 +411,7 @@ _tdm_server_cb_create_client(struct wl_client *client, 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); @@ -423,7 +423,7 @@ _tdm_server_cb_create_client(struct wl_client *client, 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); } @@ -434,7 +434,7 @@ static const struct wl_tdm_interface tdm_implementation = { 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; @@ -465,12 +465,12 @@ tdm_server_init(tdm_private_loop *private_loop) 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; @@ -480,7 +480,7 @@ tdm_server_init(tdm_private_loop *private_loop) 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; diff --git a/src/tdm_thread.c b/src/tdm_thread.c index 4dd33e4..aff3f39 100644 --- a/src/tdm_thread.c +++ b/src/tdm_thread.c @@ -1,36 +1,36 @@ /************************************************************************** - -libtdm - -Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: Eunchul Kim , - JinYoung Jeon , - Taeheon Kim , - YoungJun Cho , - SooChan Lim , - Boram Park - -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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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 @@ -73,7 +73,7 @@ _tdm_thread_main(void *data) private_thread->thread_tid = syscall(SYS_gettid); TDM_INFO("display_tid:%d, thread_tid: %d", - private_thread->display_tid, private_thread->thread_tid); + private_thread->display_tid, private_thread->thread_tid); fd = tdm_event_loop_get_fd(private_loop->dpy); if (fd < 0) { @@ -138,11 +138,11 @@ tdm_thread_init(tdm_private_loop *private_loop) /* enable as default */ thread = getenv("TDM_THREAD"); if (!thread || strncmp(thread, "1", 1)) { - TDM_INFO("not using a TDM event thread: %s", (thread)?thread:"none"); + TDM_INFO("not using a TDM event thread: %s", (thread) ? thread : "none"); return TDM_ERROR_NONE; } - private_thread = calloc(1, sizeof *private_thread); + private_thread = calloc(1, sizeof * private_thread); if (!private_thread) { TDM_ERR("alloc failed"); return TDM_ERROR_OUT_OF_MEMORY; @@ -160,12 +160,12 @@ tdm_thread_init(tdm_private_loop *private_loop) private_thread->display_tid = syscall(SYS_gettid); pthread_create(&private_thread->event_thread, NULL, _tdm_thread_main, - private_thread); + private_thread); keep_private_thread = private_thread; TDM_INFO("using a TDM event thread. pipe(%d,%d)", - private_thread->pipe[0], private_thread->pipe[1]); + private_thread->pipe[0], private_thread->pipe[1]); return TDM_ERROR_NONE; } @@ -222,7 +222,7 @@ tdm_thread_send_cb(tdm_private_loop *private_loop, tdm_thread_cb_base *base) if (tdm_debug_thread) TDM_INFO("fd(%d) type(%d), length(%d)", - private_thread->pipe[1], base->type, base->length); + private_thread->pipe[1], base->type, base->length); len = write(private_thread->pipe[1], base, base->length); if (len != base->length) { @@ -258,7 +258,7 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop) if (len == 0) return TDM_ERROR_NONE; - if (len < sizeof *base) { + if (len < sizeof * base) { TDM_NEVER_GET_HERE(); return TDM_ERROR_OPERATION_FAILED; } @@ -271,8 +271,7 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop) if (tdm_debug_thread) TDM_INFO("type(%d), length(%d)", base->type, base->length); switch (base->type) { - case TDM_THREAD_CB_OUTPUT_COMMIT: - { + case TDM_THREAD_CB_OUTPUT_COMMIT: { tdm_thread_cb_output_commit *output_commit = (tdm_thread_cb_output_commit*)base; tdm_output *output_backend = tdm_display_find_output_stamp(private_loop->dpy, output_commit->output_stamp); @@ -281,12 +280,11 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop) break; } tdm_output_cb_commit(output_backend, output_commit->sequence, - output_commit->tv_sec, output_commit->tv_usec, - output_commit->user_data); + output_commit->tv_sec, output_commit->tv_usec, + output_commit->user_data); break; } - case TDM_THREAD_CB_OUTPUT_VBLANK: - { + case TDM_THREAD_CB_OUTPUT_VBLANK: { tdm_thread_cb_output_vblank *output_vblank = (tdm_thread_cb_output_vblank*)base; tdm_output *output_backend = tdm_display_find_output_stamp(private_loop->dpy, output_vblank->output_stamp); @@ -295,12 +293,11 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop) break; } tdm_output_cb_vblank(output_backend, output_vblank->sequence, - output_vblank->tv_sec, output_vblank->tv_usec, - output_vblank->user_data); + output_vblank->tv_sec, output_vblank->tv_usec, + output_vblank->user_data); break; } - case TDM_THREAD_CB_OUTPUT_STATUS: - { + case TDM_THREAD_CB_OUTPUT_STATUS: { tdm_thread_cb_output_status *output_status = (tdm_thread_cb_output_status*)base; tdm_output *output_backend = tdm_display_find_output_stamp(private_loop->dpy, output_status->output_stamp); @@ -309,11 +306,10 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop) break; } tdm_output_cb_status(output_backend, output_status->status, - output_status->user_data); + output_status->user_data); break; } - case TDM_THREAD_CB_PP_DONE: - { + case TDM_THREAD_CB_PP_DONE: { tdm_thread_cb_pp_done *pp_done = (tdm_thread_cb_pp_done*)base; tdm_pp *pp_backend = tdm_pp_find_stamp(private_loop->dpy, pp_done->pp_stamp); @@ -324,8 +320,7 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop) tdm_pp_cb_done(pp_backend, pp_done->src, pp_done->dst, pp_done->user_data); break; } - case TDM_THREAD_CB_CAPTURE_DONE: - { + case TDM_THREAD_CB_CAPTURE_DONE: { tdm_thread_cb_capture_done *capture_done = (tdm_thread_cb_capture_done*)base; tdm_capture *capture_backend = tdm_capture_find_stamp(private_loop->dpy, capture_done->capture_stamp); diff --git a/tools/tdm_test_client.c b/tools/tdm_test_client.c index 5e1f1bb..499d1f5 100644 --- a/tools/tdm_test_client.c +++ b/tools/tdm_test_client.c @@ -1,31 +1,37 @@ -/* -Copyright (C) 2015 Samsung Electronics co., Ltd. All Rights Reserved. - -Contact: - Changyeon Lee , - JunKyeong Kim , - Boram Park , - SooChan Lim - -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, sublicense, -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 NONINFRINGEMENT. IN NO EVENT SHALL -THE AUTHORS OR COPYRIGHT HOLDERS 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 , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * +**************************************************************************/ #include #include @@ -50,7 +56,7 @@ get_time_in_micros(void) static void _client_vblank_handler(unsigned int sequence, unsigned int tv_sec, - unsigned int tv_usec, void *user_data) + unsigned int tv_usec, void *user_data) { int client, vblank; static int prev = 0; @@ -106,7 +112,7 @@ main(int argc, char *argv[]) int ret; error = tdm_client_wait_vblank(client, "unknown-0", 1, 1, sync, - _client_vblank_handler, NULL); + _client_vblank_handler, NULL); if (error != TDM_CLIENT_ERROR_NONE) { printf("tdm_client_wait_vblank failed\n"); goto done; -- 2.7.4 From 9b901bab29b2fe53d666b5939dafe87e591b939b Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Fri, 27 May 2016 16:12:07 +0300 Subject: [PATCH 02/16] move a registration of commit_cb before calling output_commit If TDM backend works without events (for example fbdev backend) then it should be able to call the commit handler function right after doing commit. Change-Id: I981a02bf257fda116861554db47e0bdf822bfa1f Signed-off-by: Roman Marchenko --- src/tdm_display.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tdm_display.c b/src/tdm_display.c index 1790229..969b227 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -1058,16 +1058,16 @@ _tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, commit_handler->user_data = user_data; commit_handler->owner_tid = syscall(SYS_gettid); - ret = func_output->output_commit(private_output->output_backend, sync, - commit_handler); - TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret); - if (!private_output->regist_commit_cb) { private_output->regist_commit_cb = 1; ret = func_output->output_set_commit_handler(private_output->output_backend, tdm_output_cb_commit); } + ret = func_output->output_commit(private_output->output_backend, sync, + commit_handler); + TDM_RETURN_VAL_IF_FAIL(ret == TDM_ERROR_NONE, ret); + return ret; } -- 2.7.4 From ad3d294b782be0e2b55887399e81084253886bf3 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 1 Jun 2016 16:14:55 +0900 Subject: [PATCH 03/16] erase tdm log macros semicolon Change-Id: Ic012277818e726da3bc9f3e92758e59a038d7c7c Signed-off-by: Junkyeong Kim --- include/tdm_log.h | 40 +++++++++++++++++++++------------------- src/tdm_display.c | 7 +++---- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/include/tdm_log.h b/include/tdm_log.h index 02943c0..c55acf6 100644 --- a/include/tdm_log.h +++ b/include/tdm_log.h @@ -79,14 +79,15 @@ extern int tdm_debug; #define LOG_TAG "TDM" #define TDM_DBG(fmt, args...) \ - if (tdm_debug) \ do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - LOGD("[%d.%06d] "fmt"\n", (int)ts.tv_sec, (int)ts.tv_nsec / 1000, ##args); \ - printf("[TDM_DBG][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); + if (tdm_debug) { \ + struct timespec ts; \ + clock_gettime(CLOCK_MONOTONIC, &ts); \ + LOGD("[%d.%06d] "fmt"\n", (int)ts.tv_sec, (int)ts.tv_nsec / 1000, ##args); \ + printf("[TDM_DBG][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ + (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ + } \ + } while (0) #define TDM_INFO(fmt, args...) \ do { \ @@ -95,7 +96,7 @@ extern int tdm_debug; LOGI("[%d.%06d] "fmt"\n", (int)ts.tv_sec, (int)ts.tv_nsec / 1000, ##args); \ printf("[TDM_INF][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); + } while (0) #define TDM_WRN(fmt, args...) \ do { \ @@ -104,7 +105,7 @@ extern int tdm_debug; LOGI("[%d.%06d] "fmt"\n", (int)ts.tv_sec, (int)ts.tv_nsec / 1000, ##args); \ printf("[TDM_WRN][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); + } while (0) #define TDM_ERR(fmt, args...) \ do { \ @@ -113,7 +114,7 @@ extern int tdm_debug; LOGE("[%d.%06d] "fmt"\n", (int)ts.tv_sec, (int)ts.tv_nsec / 1000, ##args); \ printf("[TDM_ERR][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); + } while (0) #else /* TDM_CONFIG_DLOG */ @@ -125,13 +126,14 @@ extern int tdm_debug; #define COLOR_RESET "\x1b[0m" #define TDM_DBG(fmt, args...) \ - if (tdm_debug) \ do { \ - struct timespec ts; \ - clock_gettime(CLOCK_MONOTONIC, &ts); \ - printf("[TDM_DBG][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ - (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); + if (tdm_debug) { \ + struct timespec ts; \ + clock_gettime(CLOCK_MONOTONIC, &ts); \ + printf("[TDM_DBG][%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ + (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ + } \ + } while (0) #define TDM_INFO(fmt, args...) \ do { \ @@ -139,7 +141,7 @@ extern int tdm_debug; clock_gettime(CLOCK_MONOTONIC, &ts); \ printf(COLOR_GREEN"[TDM_INF]"COLOR_RESET"[%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ - } while (0); + } while (0) #define TDM_WRN(fmt, args...) \ do { \ @@ -148,7 +150,7 @@ extern int tdm_debug; printf(COLOR_YELLOW"[TDM_WRN]"COLOR_RESET"[%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ TDM_ASSERT(0); \ - } while (0); + } while (0) #define TDM_ERR(fmt, args...) \ do { \ @@ -157,7 +159,7 @@ extern int tdm_debug; printf(COLOR_RED"[TDM_ERR]"COLOR_RESET"[%d.%06d][%d][%s %d] "fmt"\n", (int)ts.tv_sec, \ (int)ts.tv_nsec / 1000, (int)syscall(SYS_gettid), __func__, __LINE__, ##args); \ TDM_ASSERT(0); \ - } while (0); + } while (0) #endif /* TDM_CONFIG_DLOG */ diff --git a/src/tdm_display.c b/src/tdm_display.c index 969b227..2fdc486 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -154,11 +154,10 @@ _tdm_display_lock(tdm_display *dpy, const char *func) ret = pthread_mutex_trylock(&private_display->lock); if (ret < 0) { - if (ret == EBUSY) { + if (ret == EBUSY) TDM_ERR("mutex lock busy: %s", func); - } else { + else TDM_ERR("mutex lock failed: %s(%m)", func); - } return TDM_ERROR_OPERATION_FAILED; } @@ -1578,7 +1577,7 @@ tdm_layer_get_displaying_buffer(tdm_layer *layer, tdm_error *error) if (error) *error = TDM_ERROR_OPERATION_FAILED; _pthread_mutex_unlock(&private_display->lock); - TDM_ERR("layer(%p) showing_buffer is null", private_layer); + TDM_DBG("layer(%p) showing_buffer is null", private_layer); return NULL; } _pthread_mutex_unlock(&private_display->lock); -- 2.7.4 From bed1f05b96cd51546c1f6101832699008b72a2e8 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 7 Jun 2016 22:47:59 +0900 Subject: [PATCH 04/16] enhance log Change-Id: I0a8286733d527ba4c41f9b4301f701041ab751c5 --- src/tdm_display.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tdm_display.c b/src/tdm_display.c index 2fdc486..17d951e 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -1393,6 +1393,9 @@ tdm_layer_set_info(tdm_layer *layer, tdm_info_layer *info) func_layer = &private_display->func_layer; + if (private_layer->usable) + TDM_INFO("layer(%p) not usable", private_layer); + private_layer->usable = 0; if (!func_layer->layer_set_info) { @@ -1476,6 +1479,9 @@ tdm_layer_set_buffer(tdm_layer *layer, tbm_surface_h buffer) func_layer = &private_display->func_layer; + if (private_layer->usable) + TDM_INFO("layer(%p) not usable", private_layer); + private_layer->usable = 0; if (!func_layer->layer_set_buffer) { @@ -1546,6 +1552,9 @@ tdm_layer_unset_buffer(tdm_layer *layer) private_layer->usable = 1; + if (private_layer->usable) + TDM_INFO("layer(%p) now usable", private_layer); + if (!func_layer->layer_unset_buffer) { _pthread_mutex_unlock(&private_display->lock); TDM_ERR("not implemented!!"); @@ -1671,6 +1680,9 @@ tdm_layer_set_buffer_queue(tdm_layer *layer, tbm_surface_queue_h buffer_queue) func_layer = &private_display->func_layer; + if (private_layer->usable) + TDM_INFO("layer(%p) not usable", private_layer); + private_layer->usable = 0; if (!func_layer->layer_set_buffer) { @@ -1750,6 +1762,9 @@ tdm_layer_unset_buffer_queue(tdm_layer *layer) private_layer->buffer_queue = NULL; private_layer->usable = 1; + if (private_layer->usable) + TDM_INFO("layer(%p) now usable", private_layer); + if (!func_layer->layer_unset_buffer) { _pthread_mutex_unlock(&private_display->lock); TDM_ERR("not implemented!!"); -- 2.7.4 From d7b3a6fbc139908131ef977026a45b8a685596df Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 8 Jun 2016 21:20:57 +0900 Subject: [PATCH 05/16] add description for tdm protocol Change-Id: Idbb753a959e4237676806f43a701e4366843fa59 --- protocol/tdm.xml | 54 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/protocol/tdm.xml b/protocol/tdm.xml index 6fa7f3d..7564670 100644 --- a/protocol/tdm.xml +++ b/protocol/tdm.xml @@ -2,41 +2,59 @@ - + - - - - - + + TDM uses the wayland protocol to communicate between tdm client and tdm server. + + + + + + + TDM uses the wayland protocol to communicate between tdm client and tdm server. + + - - - + + + + + + When wl_tdm_client.wait_vblank is called, wl_tdm_vblank resource is created. + And when TDM server gets the HW vblank, TDM server will send the 'done' + event of wl_tdm_vblank interface to let the TDM client get the HW vblank. + If 'sw_timer' param is 1, TDM server will use the SW timer in case of DPMS off. + And TDM server will create the fake vblank event and send it to TDM client. + Otherwise, TDM server will return 'dpms_off' error. + + - - - - - + + + + + - + - - - + + + + + -- 2.7.4 From a3ae245fc52ea4e43684f77981b5cdc730c9e1ed Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 1 Jun 2016 16:20:27 +0900 Subject: [PATCH 06/16] add tdm_helper_capture_output API It makes composite image with output's all layers showing buffer. After composing, call tdm_helper_capture_handler function. Change-Id: I1ea7b939d77aeaf4f6d2c5347a3443ddac2b6d1d Signed-off-by: Junkyeong Kim --- configure.ac | 2 +- include/tdm_helper.h | 26 +++++++++ packaging/libtdm.spec | 1 + src/tdm_helper.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 184 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fa99a81..ff06dd9 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ fi PKG_CHECK_MODULES(WAYLAND_SCANNER, wayland-scanner >= 1.7.0) -PKG_CHECK_MODULES(TDM, dlog libtbm pthread-stubs libpng wayland-server) +PKG_CHECK_MODULES(TDM, dlog libtbm pthread-stubs libpng pixman-1 wayland-server) PKG_CHECK_MODULES(TTRACE, [ttrace], diff --git a/include/tdm_helper.h b/include/tdm_helper.h index 0bde0b9..e98ad9f 100644 --- a/include/tdm_helper.h +++ b/include/tdm_helper.h @@ -118,6 +118,32 @@ tdm_helper_dump_start(char *dumppath, int *count); void tdm_helper_dump_stop(void); +/** + * @brief The tdm helper capture handler + * @details + * This handler will be called when composit image produced. + * @see #tdm_helper_capture_output() function + */ +typedef void (*tdm_helper_capture_handler)(tbm_surface_h buffer, void *user_data); + +/** + * @brief Make an output's image surface. + * @details Composit specific output's all layer's buffer to dst_buffer surface. + * After composing, tdm_helper_capture_handler func will be called. + * @param[in] output A output object + * @param[in] dst_buffer A surface composite image saved + * @param[in] x A horizontal position of composite image on dst_buffer + * @param[in] y A vertical position of composite image on dst_buffer + * @param[in] w A composite image width + * @param[in] h A composite image height + * @param[in] func A composing done handler + * @param[in] user_data The user data + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer, + int x, int y, int w, int h, + tdm_helper_capture_handler func, void *data); #ifdef __cplusplus } #endif diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 881db02..077db23 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -11,6 +11,7 @@ BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(libpng) BuildRequires: pkgconfig(ttrace) BuildRequires: pkgconfig(wayland-server) +BuildRequires: pkgconfig(pixman-1) %description Common user library of Tizen Display Manager : libtdm front-end library diff --git a/src/tdm_helper.c b/src/tdm_helper.c index a57a732..354e2e8 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -43,9 +43,11 @@ #include #include #include +#include #include "tdm.h" #include "tdm_private.h" +#include "tdm_helper.h" #define PNG_DEPTH 8 @@ -308,3 +310,157 @@ tdm_helper_dump_stop(void) TDM_DBG("tdm_helper_dump stop."); } +static pixman_format_code_t +_tdm_helper_pixman_format_get(tbm_format format) +{ + switch (format) { + case TBM_FORMAT_ARGB8888: + return PIXMAN_a8r8g8b8; + case TBM_FORMAT_XRGB8888: + return PIXMAN_x8r8g8b8; + default: + return 0; + } + + return 0; +} + +static tdm_error +_tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf, + int dx, int dy, int dw, int dh, int count) +{ + pixman_image_t *src_img = NULL, *dst_img = NULL; + pixman_format_code_t src_format, dst_format; + pixman_transform_t t; + struct pixman_f_transform ft; + pixman_op_t op; + tbm_surface_info_s src_info = {0, }; + tbm_surface_info_s dst_info = {0, }; + int stride, width; + double scale_x, scale_y; + + TDM_RETURN_VAL_IF_FAIL(srcbuf != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(dstbuf != NULL, TDM_ERROR_INVALID_PARAMETER); + + if (tbm_surface_map(srcbuf, TBM_SURF_OPTION_READ, &src_info) + != TBM_SURFACE_ERROR_NONE) { + TDM_ERR("cannot mmap srcbuf\n"); + return TDM_ERROR_OPERATION_FAILED; + } + + if (tbm_surface_map(dstbuf, TBM_SURF_OPTION_WRITE, &dst_info) + != TBM_SURFACE_ERROR_NONE) { + TDM_ERR("cannot mmap dstbuf\n"); + tbm_surface_unmap(srcbuf); + return TDM_ERROR_OPERATION_FAILED; + } + TDM_GOTO_IF_FAIL(src_info.num_planes == 1, cant_convert); + TDM_GOTO_IF_FAIL(dst_info.num_planes == 1, cant_convert); + + /* src */ + src_format = _tdm_helper_pixman_format_get(src_info.format); + TDM_GOTO_IF_FAIL(src_format > 0, cant_convert); + + width = src_info.planes[0].stride / 4; + stride = src_info.planes[0].stride; + src_img = pixman_image_create_bits(src_format, width, src_info.height, + (uint32_t*)src_info.planes[0].ptr, stride); + TDM_GOTO_IF_FAIL(src_img != NULL, cant_convert); + + /* dst */ + dst_format = _tdm_helper_pixman_format_get(dst_info.format); + TDM_GOTO_IF_FAIL(dst_format > 0, cant_convert); + + width = dst_info.planes[0].stride / 4; + stride = dst_info.planes[0].stride; + dst_img = pixman_image_create_bits(dst_format, width, dst_info.height, + (uint32_t*)dst_info.planes[0].ptr, stride); + TDM_GOTO_IF_FAIL(dst_img != NULL, cant_convert); + + pixman_f_transform_init_identity(&ft); + + scale_x = (double)src_info.width / dw; + scale_y = (double)src_info.height / dh; + + pixman_f_transform_scale(&ft, NULL, scale_x, scale_y); + pixman_f_transform_translate(&ft, NULL, 0, 0); + pixman_transform_from_pixman_f_transform(&t, &ft); + pixman_image_set_transform(src_img, &t); + + if (count == 0) + op = PIXMAN_OP_SRC; + else + op = PIXMAN_OP_OVER; + + pixman_image_composite(op, src_img, NULL, dst_img, + 0, 0, 0, 0, dx, dy, dw, dh); + + if (src_img) + pixman_image_unref(src_img); + if (dst_img) + pixman_image_unref(dst_img); + + tbm_surface_unmap(srcbuf); + tbm_surface_unmap(dstbuf); + + return TDM_ERROR_NONE; + +cant_convert: + if (src_img) + pixman_image_unref(src_img); + if (dst_img) + pixman_image_unref(dst_img); + + tbm_surface_unmap(srcbuf); + tbm_surface_unmap(dstbuf); + + return TDM_ERROR_OPERATION_FAILED; +} + +EXTERN tdm_error +tdm_helper_capture_output(tdm_output *output, tbm_surface_h dst_buffer, + int x, int y, int w, int h, + tdm_helper_capture_handler func, void *data) +{ + tbm_surface_h surface; + tdm_error err; + int i, count, first = 0; + + TDM_RETURN_VAL_IF_FAIL(output != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(dst_buffer != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(x >= 0, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(y >= 0, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(w >= 0, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(h >= 0, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(func != NULL, TDM_ERROR_INVALID_PARAMETER); + TDM_RETURN_VAL_IF_FAIL(data != NULL, TDM_ERROR_INVALID_PARAMETER); + + err = tdm_output_get_layer_count(output, &count); + if (err != TDM_ERROR_NONE) { + TDM_ERR("tdm_output_get_layer_count fail(%d)\n", err); + return TDM_ERROR_OPERATION_FAILED; + } + if (count <= 0) { + TDM_ERR("tdm_output_get_layer_count err(%d, %d)\n", err, count); + return TDM_ERROR_BAD_MODULE; + } + + for (i = count - 1; i >= 0; i--) { + tdm_layer *layer = tdm_output_get_layer(output, i, NULL); + + surface = tdm_layer_get_displaying_buffer(layer, &err); + if (err != TDM_ERROR_NONE) + continue; + + err = _tdm_helper_buffer_convert(surface, dst_buffer, x, y, w, h, first++); + if (err != TDM_ERROR_NONE) + TDM_DBG("convert fail %d-layer buffer\n", i); + else + TDM_DBG("convert success %d-layer buffer\n", i); + } + + func(dst_buffer, data); + + return TDM_ERROR_NONE; +} + -- 2.7.4 From 86601c31209e1a3fbc9c2457d105227a57cdfbaa Mon Sep 17 00:00:00 2001 From: Boram Park Date: Thu, 9 Jun 2016 18:58:46 +0900 Subject: [PATCH 07/16] fix syntax error Change-Id: I4fd24640ca850fef42a7f804282e2a885e695db3 --- include/tdm.h | 2 +- src/tdm_display.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/tdm.h b/include/tdm.h index 488a549..4af34d7 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -519,7 +519,7 @@ tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props, * @see tdm_layer_set_video_pos, tdm_layer_capability */ tdm_error -tdm_layer_get_zpos(tdm_layer *layer, unsigned int *zpos); +tdm_layer_get_zpos(tdm_layer *layer, int *zpos); /** * @brief Set the property which has a given id. diff --git a/src/tdm_display.c b/src/tdm_display.c index 17d951e..ef0b1ca 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -1318,7 +1318,7 @@ tdm_layer_get_available_properties(tdm_layer *layer, const tdm_prop **props, int } EXTERN tdm_error -tdm_layer_get_zpos(tdm_layer *layer, unsigned int *zpos) +tdm_layer_get_zpos(tdm_layer *layer, int *zpos) { LAYER_FUNC_ENTRY(); -- 2.7.4 From 6a9387efb3425d378d316bb90b153baa368be5a9 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Thu, 9 Jun 2016 19:26:02 +0900 Subject: [PATCH 08/16] pp: allow twice attach Change-Id: I4f9d754f8e83f0c45604a821e06d1b52344b0713 --- src/tdm_pp.c | 221 ++++++++++++++++++++++++++---------------------------- src/tdm_private.h | 6 +- 2 files changed, 108 insertions(+), 119 deletions(-) diff --git a/src/tdm_pp.c b/src/tdm_pp.c index 2db7af4..a440c41 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -41,6 +41,13 @@ #include "tdm_backend.h" #include "tdm_private.h" +typedef struct _tdm_pp_private_buffer { + tbm_surface_h src; + tbm_surface_h dst; + struct list_head link; + struct list_head commit_link; +} tdm_pp_private_buffer; + #define PP_FUNC_ENTRY() \ tdm_func_pp *func_pp; \ tdm_private_display *private_display; \ @@ -51,41 +58,52 @@ private_display = private_pp->private_display; \ func_pp = &private_display->func_pp -static tdm_error -_tdm_pp_check_if_exist(tdm_private_pp *private_pp, - tbm_surface_h src, tbm_surface_h dst) +static void +_tdm_pp_print_list(struct list_head *list) { - tdm_buffer_info *buf_info = NULL; - - LIST_FOR_EACH_ENTRY(buf_info, &private_pp->src_buffer_list, link) { - if (buf_info->buffer == src) { - TDM_ERR("%p attached twice", src); - return TDM_ERROR_BAD_REQUEST; - } + tdm_pp_private_buffer *b = NULL; + char str[512], *p; + int len = sizeof(str); + + TDM_RETURN_IF_FAIL(list != NULL); + + p = str; + LIST_FOR_EACH_ENTRY(b, list, link) { + if (len > 0) { + int l = snprintf(p, len, " (%p,%p)", b->src, b->dst); + p += l; + len -= l; + } else + break; } - LIST_FOR_EACH_ENTRY(buf_info, &private_pp->src_pending_buffer_list, link) { - if (buf_info->buffer == src) { - TDM_ERR("%p attached twice", src); - return TDM_ERROR_BAD_REQUEST; - } - } + TDM_INFO("\t %s", str); +} - LIST_FOR_EACH_ENTRY(buf_info, &private_pp->dst_buffer_list, link) { - if (buf_info->buffer == dst) { - TDM_ERR("%p attached twice", dst); - return TDM_ERROR_BAD_REQUEST; - } +static tdm_pp_private_buffer * +_tdm_pp_find_tbm_buffers(struct list_head *list, tbm_surface_h src, tbm_surface_h dst) +{ + tdm_pp_private_buffer *b = NULL, *bb = NULL; + + LIST_FOR_EACH_ENTRY_SAFE(b, bb, list, link) { + if (b->src == src && b->dst == dst) + return b; } - LIST_FOR_EACH_ENTRY(buf_info, &private_pp->dst_pending_buffer_list, link) { - if (buf_info->buffer == dst) { - TDM_ERR("%p attached twice", dst); - return TDM_ERROR_BAD_REQUEST; - } + return NULL; +} + +static tdm_pp_private_buffer * +_tdm_pp_find_buffer(struct list_head *list, tdm_pp_private_buffer *pp_buffer) +{ + tdm_pp_private_buffer *b = NULL, *bb = NULL; + + LIST_FOR_EACH_ENTRY_SAFE(b, bb, list, link) { + if (b == pp_buffer) + return b; } - return TDM_ERROR_NONE; + return NULL; } INTERN void @@ -94,8 +112,7 @@ tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, { tdm_private_pp *private_pp = user_data; tdm_private_display *private_display = private_pp->private_display; - tdm_buffer_info *buf_info; - tbm_surface_h first_entry; + tdm_pp_private_buffer *pp_buffer, *first_entry; TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED()); @@ -122,24 +139,20 @@ tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, if (tdm_debug_buffer) TDM_INFO("pp(%p) done: src(%p) dst(%p)", private_pp, src, dst); - first_entry = tdm_buffer_list_get_first_entry(&private_pp->src_buffer_list); - if (first_entry != src) - TDM_ERR("src(%p) is skipped", first_entry); - - first_entry = tdm_buffer_list_get_first_entry(&private_pp->dst_buffer_list); - if (first_entry != dst) - TDM_ERR("dst(%p) is skipped", first_entry); + first_entry = container_of((&private_pp->buffer_list)->next, pp_buffer, link); + if (first_entry->src != src || first_entry->dst != dst) + TDM_ERR("buffer(%p,%p) is skipped", first_entry->src, first_entry->dst); - if ((buf_info = tdm_buffer_get_info(src))) - LIST_DEL(&buf_info->link); + if ((pp_buffer = _tdm_pp_find_tbm_buffers(&private_pp->buffer_list, src, dst))) { + LIST_DEL(&pp_buffer->link); - if ((buf_info = tdm_buffer_get_info(dst))) - LIST_DEL(&buf_info->link); + _pthread_mutex_unlock(&private_display->lock); + tdm_buffer_unref_backend(src); + tdm_buffer_unref_backend(dst); + _pthread_mutex_lock(&private_display->lock); - _pthread_mutex_unlock(&private_display->lock); - tdm_buffer_unref_backend(src); - tdm_buffer_unref_backend(dst); - _pthread_mutex_lock(&private_display->lock); + free(pp_buffer); + } } INTERN tdm_private_pp * @@ -212,10 +225,8 @@ tdm_pp_create_internal(tdm_private_display *private_display, tdm_error *error) private_pp->pp_backend = pp_backend; private_pp->owner_tid = syscall(SYS_gettid); - LIST_INITHEAD(&private_pp->src_pending_buffer_list); - LIST_INITHEAD(&private_pp->dst_pending_buffer_list); - LIST_INITHEAD(&private_pp->src_buffer_list); - LIST_INITHEAD(&private_pp->dst_buffer_list); + LIST_INITHEAD(&private_pp->pending_buffer_list); + LIST_INITHEAD(&private_pp->buffer_list); if (error) *error = TDM_ERROR_NONE; @@ -228,7 +239,7 @@ tdm_pp_destroy_internal(tdm_private_pp *private_pp) { tdm_private_display *private_display; tdm_func_pp *func_pp; - tdm_buffer_info *b = NULL, *bb = NULL; + tdm_pp_private_buffer *b = NULL, *bb = NULL; TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED()); @@ -242,50 +253,24 @@ tdm_pp_destroy_internal(tdm_private_pp *private_pp) func_pp->pp_destroy(private_pp->pp_backend); - if (!LIST_IS_EMPTY(&private_pp->src_pending_buffer_list)) { - TDM_WRN("pp(%p) not finished:", private_pp); - tdm_buffer_list_dump(&private_pp->src_pending_buffer_list); - - LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->src_pending_buffer_list, link) { - LIST_DEL(&b->link); - _pthread_mutex_unlock(&private_display->lock); - tdm_buffer_unref_backend(b->buffer); - _pthread_mutex_lock(&private_display->lock); - } - } - - if (!LIST_IS_EMPTY(&private_pp->dst_pending_buffer_list)) { + if (!LIST_IS_EMPTY(&private_pp->pending_buffer_list)) { TDM_WRN("pp(%p) not finished:", private_pp); - tdm_buffer_list_dump(&private_pp->dst_pending_buffer_list); + _tdm_pp_print_list(&private_pp->pending_buffer_list); - LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->dst_pending_buffer_list, link) { + LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->pending_buffer_list, link) { LIST_DEL(&b->link); - _pthread_mutex_unlock(&private_display->lock); - tdm_buffer_unref_backend(b->buffer); - _pthread_mutex_lock(&private_display->lock); } } - if (!LIST_IS_EMPTY(&private_pp->src_buffer_list)) { + if (!LIST_IS_EMPTY(&private_pp->buffer_list)) { TDM_WRN("pp(%p) not finished:", private_pp); - tdm_buffer_list_dump(&private_pp->src_buffer_list); + _tdm_pp_print_list(&private_pp->buffer_list); - LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->src_buffer_list, link) { + LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->buffer_list, link) { LIST_DEL(&b->link); _pthread_mutex_unlock(&private_display->lock); - tdm_buffer_unref_backend(b->buffer); - _pthread_mutex_lock(&private_display->lock); - } - } - - if (!LIST_IS_EMPTY(&private_pp->dst_buffer_list)) { - TDM_WRN("pp(%p) not finished:", private_pp); - tdm_buffer_list_dump(&private_pp->dst_buffer_list); - - LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->dst_buffer_list, link) { - LIST_DEL(&b->link); - _pthread_mutex_unlock(&private_display->lock); - tdm_buffer_unref_backend(b->buffer); + tdm_buffer_unref_backend(b->src); + tdm_buffer_unref_backend(b->dst); _pthread_mutex_lock(&private_display->lock); } } @@ -347,6 +332,8 @@ tdm_pp_set_info(tdm_pp *pp, tdm_info_pp *info) EXTERN tdm_error tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) { + tdm_pp_private_buffer *pp_buffer; + PP_FUNC_ENTRY(); TDM_RETURN_VAL_IF_FAIL(src != NULL, TDM_ERROR_INVALID_PARAMETER); @@ -362,8 +349,8 @@ tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) if (tdm_display_check_module_abi(private_display, 1, 2) && private_display->caps_pp.max_attach_count > 0) { - int length = LIST_LENGTH(&private_pp->src_pending_buffer_list) + - LIST_LENGTH(&private_pp->src_buffer_list); + int length = LIST_LENGTH(&private_pp->pending_buffer_list) + + LIST_LENGTH(&private_pp->buffer_list); if (length >= private_display->caps_pp.max_attach_count) { _pthread_mutex_unlock(&private_display->lock); TDM_DBG("failed: too many attached!! max_attach_count(%d)", @@ -372,29 +359,30 @@ tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) } } - ret = _tdm_pp_check_if_exist(private_pp, src, dst); - if (ret != TDM_ERROR_NONE) { + pp_buffer = calloc(1, sizeof *pp_buffer); + if (!pp_buffer) { _pthread_mutex_unlock(&private_display->lock); - return ret; + TDM_ERR("alloc failed"); + return TDM_ERROR_OUT_OF_MEMORY; } ret = func_pp->pp_attach(private_pp->pp_backend, src, dst); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); - if (ret == TDM_ERROR_NONE) { - tdm_buffer_info *buf_info; - - if ((buf_info = tdm_buffer_get_info(src))) - LIST_ADDTAIL(&buf_info->link, &private_pp->src_pending_buffer_list); + if (ret != TDM_ERROR_NONE) { + free(pp_buffer); + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("attach failed"); + return ret; + } - if ((buf_info = tdm_buffer_get_info(dst))) - LIST_ADDTAIL(&buf_info->link, &private_pp->dst_pending_buffer_list); + LIST_ADDTAIL(&pp_buffer->link, &private_pp->pending_buffer_list); + pp_buffer->src = tdm_buffer_ref_backend(src); + pp_buffer->dst = tdm_buffer_ref_backend(dst); - if (tdm_debug_buffer) { - TDM_INFO("pp(%p) attached:", private_pp); - tdm_buffer_list_dump(&private_pp->src_pending_buffer_list); - tdm_buffer_list_dump(&private_pp->dst_pending_buffer_list); - } + if (tdm_debug_buffer) { + TDM_INFO("pp(%p) attached:", private_pp); + _tdm_pp_print_list(&private_pp->pending_buffer_list); } _pthread_mutex_unlock(&private_display->lock); @@ -405,7 +393,8 @@ tdm_pp_attach(tdm_pp *pp, tbm_surface_h src, tbm_surface_h dst) EXTERN tdm_error tdm_pp_commit(tdm_pp *pp) { - tdm_buffer_info *b = NULL, *bb = NULL; + tdm_pp_private_buffer *b = NULL, *bb = NULL; + struct list_head commit_buffer_list; PP_FUNC_ENTRY(); @@ -417,26 +406,28 @@ tdm_pp_commit(tdm_pp *pp) return TDM_ERROR_NOT_IMPLEMENTED; } + LIST_INITHEAD(&commit_buffer_list); + + LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->pending_buffer_list, link) { + LIST_DEL(&b->link); + LIST_ADDTAIL(&b->link, &private_pp->buffer_list); + LIST_ADDTAIL(&b->commit_link, &commit_buffer_list); + } + ret = func_pp->pp_commit(private_pp->pp_backend); TDM_WARNING_IF_FAIL(ret == TDM_ERROR_NONE); - if (ret == TDM_ERROR_NONE) { - LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->src_pending_buffer_list, link) { - LIST_DEL(&b->link); - tdm_buffer_ref_backend(b->buffer); - LIST_ADDTAIL(&b->link, &private_pp->src_buffer_list); - } + LIST_FOR_EACH_ENTRY_SAFE(b, bb, &commit_buffer_list, commit_link) { + if (!_tdm_pp_find_buffer(&private_pp->buffer_list, b)) + continue; - LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->dst_pending_buffer_list, link) { + LIST_DEL(&b->commit_link); + + if (ret != TDM_ERROR_NONE) { + tdm_buffer_unref_backend(b->src); + tdm_buffer_unref_backend(b->dst); LIST_DEL(&b->link); - tdm_buffer_ref_backend(b->buffer); - LIST_ADDTAIL(&b->link, &private_pp->dst_buffer_list); } - } else { - LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->src_pending_buffer_list, link) - LIST_DEL(&b->link); - LIST_FOR_EACH_ENTRY_SAFE(b, bb, &private_pp->dst_pending_buffer_list, link) - LIST_DEL(&b->link); } _pthread_mutex_unlock(&private_display->lock); diff --git a/src/tdm_private.h b/src/tdm_private.h index 8d07f03..db7426e 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -203,10 +203,8 @@ struct _tdm_private_pp { tdm_pp *pp_backend; - struct list_head src_pending_buffer_list; - struct list_head dst_pending_buffer_list; - struct list_head src_buffer_list; - struct list_head dst_buffer_list; + struct list_head pending_buffer_list; + struct list_head buffer_list; pid_t owner_tid; }; -- 2.7.4 From b1c923196d528ec5202ddf5b44fbbc64ed708e91 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Tue, 14 Jun 2016 12:43:29 +0900 Subject: [PATCH 09/16] fix syntax error Change-Id: I00cb5908d5786e9013301c6e1f01eee47d26605d --- src/tdm_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 354e2e8..1363979 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -178,7 +178,7 @@ tdm_helper_dump_buffer(tbm_surface_h buffer, const char *file) TDM_RETURN_IF_FAIL(buffer != NULL); TDM_RETURN_IF_FAIL(file != NULL); - ret = tbm_surface_map(buffer, TBM_DEVICE_CPU, &info); + ret = tbm_surface_map(buffer, TBM_OPTION_READ, &info); TDM_RETURN_IF_FAIL(ret == TBM_SURFACE_ERROR_NONE); len = strnlen(file, 1024); -- 2.7.4 From 53e61274b17a6fe63de8d75059a9310c2289d1a6 Mon Sep 17 00:00:00 2001 From: Roman Marchenko Date: Wed, 15 Jun 2016 17:15:47 +0300 Subject: [PATCH 10/16] fix deadlock Change-Id: I426b1067f729db754611824642b13e9ced8a7a9b Signed-off-by: Roman Marchenko --- src/tdm_display.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tdm_display.c b/src/tdm_display.c index ef0b1ca..11e09bc 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -949,8 +949,10 @@ tdm_output_cb_commit(tdm_output *output_backend, unsigned int sequence, _pthread_mutex_lock(&private_display->lock); if (private_layer->buffer_queue) { + _pthread_mutex_unlock(&private_display->lock); tbm_surface_queue_release(private_layer->buffer_queue, private_layer->showing_buffer); + _pthread_mutex_lock(&private_display->lock); } } @@ -1624,6 +1626,7 @@ _tbm_layer_queue_acquirable_cb(tbm_surface_queue_h surface_queue, void *data) if (ret == TDM_ERROR_NONE) { if (private_layer->waiting_buffer) { + TDM_DBG("layer(%p) drop waiting_buffer(%p)", private_layer, private_layer->waiting_buffer); _pthread_mutex_unlock(&private_display->lock); tdm_buffer_unref_backend(private_layer->waiting_buffer); tbm_surface_queue_release(private_layer->buffer_queue, -- 2.7.4 From 22c00978a791c5234748071b162f9d33fdfa67e6 Mon Sep 17 00:00:00 2001 From: Changyeon Lee Date: Wed, 15 Jun 2016 19:51:09 +0900 Subject: [PATCH 11/16] Allow output name "primary" in tdm_client_wait_vblank Change-Id: I39b4e5fa789ccda07a7b1156ecc11482237818cf --- src/tdm_server.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tdm_server.c b/src/tdm_server.c index 99ff6d0..1233deb 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -264,6 +264,9 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, 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; -- 2.7.4 From 863ce920d44c0c1630c2dd0bdbb12a9bff23a19e Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Wed, 22 Jun 2016 21:44:19 +0900 Subject: [PATCH 12/16] fix some syntax errors initialize variables before using erase unreacherble codes Change-Id: I5ea6f89be8aeea2025950f0713fcc60dd43b1f7f Signed-off-by: Junkyeong Kim --- include/tdm_list.h | 2 +- src/tdm.c | 2 +- src/tdm_display.c | 6 ++---- src/tdm_helper.c | 2 -- src/tdm_pp.c | 2 +- src/tdm_thread.c | 2 +- 6 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/tdm_list.h b/include/tdm_list.h index 6255cd0..2fd1db0 100644 --- a/include/tdm_list.h +++ b/include/tdm_list.h @@ -150,7 +150,7 @@ static inline int list_length(struct list_head *item) #define LIST_FIND_ITEM(item, head, type, member, found) \ do { \ - type *pos; \ + type *pos = NULL; \ found = NULL; \ LIST_FOR_EACH_ENTRY(pos, head, member) \ if (pos == item) { found = item; break; } \ diff --git a/src/tdm.c b/src/tdm.c index 996fb9a..be9d26b 100644 --- a/src/tdm.c +++ b/src/tdm.c @@ -610,7 +610,7 @@ _tdm_display_update_internal(tdm_private_display *private_display, { tdm_output **outputs = NULL; int output_count = 0, i; - tdm_error ret; + tdm_error ret = TDM_ERROR_NONE; LIST_INITHEAD(&private_display->output_list); LIST_INITHEAD(&private_display->pp_list); diff --git a/src/tdm_display.c b/src/tdm_display.c index 11e09bc..e691501 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -1150,9 +1150,7 @@ tdm_output_set_dpms(tdm_output *output, tdm_output_dpms dpms_value) tdm_func_output *func_output; OUTPUT_FUNC_ENTRY(); - if (dpms_value < TDM_OUTPUT_DPMS_ON) - dpms_value = TDM_OUTPUT_DPMS_ON; - else if (dpms_value > TDM_OUTPUT_DPMS_OFF) + if (dpms_value > TDM_OUTPUT_DPMS_OFF) dpms_value = TDM_OUTPUT_DPMS_OFF; _pthread_mutex_lock(&private_display->lock); @@ -1238,7 +1236,7 @@ tdm_output_call_change_handler_internal(tdm_private_output *private_output, tdm_value value) { tdm_private_display *private_display; - tdm_private_change_handler *change_handler; + tdm_private_change_handler *change_handler = NULL; TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED()); TDM_RETURN_IF_FAIL(private_output); diff --git a/src/tdm_helper.c b/src/tdm_helper.c index 1363979..4172fe8 100644 --- a/src/tdm_helper.c +++ b/src/tdm_helper.c @@ -408,8 +408,6 @@ _tdm_helper_buffer_convert(tbm_surface_h srcbuf, tbm_surface_h dstbuf, cant_convert: if (src_img) pixman_image_unref(src_img); - if (dst_img) - pixman_image_unref(dst_img); tbm_surface_unmap(srcbuf); tbm_surface_unmap(dstbuf); diff --git a/src/tdm_pp.c b/src/tdm_pp.c index a440c41..9075c8b 100644 --- a/src/tdm_pp.c +++ b/src/tdm_pp.c @@ -112,7 +112,7 @@ tdm_pp_cb_done(tdm_pp *pp_backend, tbm_surface_h src, tbm_surface_h dst, { tdm_private_pp *private_pp = user_data; tdm_private_display *private_display = private_pp->private_display; - tdm_pp_private_buffer *pp_buffer, *first_entry; + tdm_pp_private_buffer *pp_buffer = NULL, *first_entry = NULL; TDM_RETURN_IF_FAIL(TDM_MUTEX_IS_LOCKED()); diff --git a/src/tdm_thread.c b/src/tdm_thread.c index aff3f39..0d24561 100644 --- a/src/tdm_thread.c +++ b/src/tdm_thread.c @@ -240,7 +240,7 @@ tdm_thread_handle_cb(tdm_private_loop *private_loop) tdm_private_thread *private_thread; tdm_thread_cb_base *base; char buffer[1024]; - int len, i; + unsigned int len, i; /* DON'T check TDM_MUTEX_IS_LOCKED here */ -- 2.7.4 From 0aa74b282285fd0d935a2347c668a68ff4a41276 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 27 Jun 2016 14:24:38 +0900 Subject: [PATCH 13/16] remove the pthread-stub dependency Change-Id: I78c92c2f6bef32161be2a1d0815c6774a7945905 --- configure.ac | 2 +- packaging/libtdm.spec | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index ff06dd9..66a57ec 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ fi PKG_CHECK_MODULES(WAYLAND_SCANNER, wayland-scanner >= 1.7.0) -PKG_CHECK_MODULES(TDM, dlog libtbm pthread-stubs libpng pixman-1 wayland-server) +PKG_CHECK_MODULES(TDM, dlog libtbm libpng pixman-1 wayland-server) PKG_CHECK_MODULES(TTRACE, [ttrace], diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 077db23..11cec9a 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -6,7 +6,6 @@ Group: Development/Libraries License: MIT Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest -BuildRequires: pkgconfig(pthread-stubs) BuildRequires: pkgconfig(libtbm) BuildRequires: pkgconfig(libpng) BuildRequires: pkgconfig(ttrace) -- 2.7.4 From 633c7139cfeb77dd009c0e99fb0d33498009b056 Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Mon, 27 Jun 2016 21:53:28 +0900 Subject: [PATCH 14/16] add tdm_layer_get_buffer_flags There can be the layer which can set and display the specific buffer with the specific flags. Therefore, tdm user has to know the buffer flags to create the buffer which can be set to the specified layer. Change-Id: I1df658f4cbb4ca6019a7df1fe72c77db3d6db401 --- include/tdm.h | 9 +++++++++ include/tdm_backend.h | 9 ++++++++- src/tdm_display.c | 23 +++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/include/tdm.h b/include/tdm.h index 4af34d7..6ba4996 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -653,6 +653,15 @@ tdm_capture * tdm_layer_create_capture(tdm_layer *layer, tdm_error *error); /** + * @brief Get buffer flags from a layer object + * @param[in] layer A layer object + * @param[out] flags a buffer flags value + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ +tdm_error +tdm_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags); + +/** * @brief Destroy a pp object * @param[in] pp A pp object * @see tdm_display_create_pp diff --git a/include/tdm_backend.h b/include/tdm_backend.h index 8967b52..0256e92 100644 --- a/include/tdm_backend.h +++ b/include/tdm_backend.h @@ -621,6 +621,14 @@ typedef struct _tdm_func_layer { */ tdm_capture *(*layer_create_capture)(tdm_layer *layer, tdm_error *error); + /** + * @brief Get buffer flags which the layer can support. + * @param[in] layer A layer object + * @param[out] flags The buffer flags which should be the tbm_bo flags + * @return #TDM_ERROR_NONE if success. Otherwise, error value. + */ + tdm_error (*layer_get_buffer_flags)(tdm_layer *layer, unsigned int *flags); + void (*reserved1)(void); void (*reserved2)(void); void (*reserved3)(void); @@ -628,7 +636,6 @@ typedef struct _tdm_func_layer { void (*reserved5)(void); void (*reserved6)(void); void (*reserved7)(void); - void (*reserved8)(void); } tdm_func_layer; /** diff --git a/src/tdm_display.c b/src/tdm_display.c index e691501..17c02aa 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -1839,3 +1839,26 @@ tdm_layer_create_capture(tdm_layer *layer, tdm_error *error) return capture; } + +EXTERN tdm_error +tdm_layer_get_buffer_flags(tdm_layer *layer, unsigned int *flags) +{ + tdm_func_layer *func_layer; + LAYER_FUNC_ENTRY(); + + _pthread_mutex_lock(&private_display->lock); + + func_layer = &private_display->func_layer; + + if (!func_layer->layer_get_buffer_flags) { + _pthread_mutex_unlock(&private_display->lock); + TDM_ERR("not implemented!!"); + return TDM_ERROR_NOT_IMPLEMENTED; + } + + ret = func_layer->layer_get_buffer_flags(private_layer->layer_backend, flags); + + _pthread_mutex_unlock(&private_display->lock); + + return ret; +} -- 2.7.4 From ee90ba719ca9dfe34a3bc2fc58a9ba93a0d95ab9 Mon Sep 17 00:00:00 2001 From: Boram Park Date: Wed, 22 Jun 2016 13:15:39 +0900 Subject: [PATCH 15/16] correct the retry condition of poll() Change-Id: I7b2cdd80ccc903811ed791dead112932b887469b --- client/tdm_client.h | 2 +- src/tdm_display.c | 2 +- src/tdm_thread.c | 2 +- tools/tdm_test_client.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/tdm_client.h b/client/tdm_client.h index a6a7a09..fff8808 100644 --- a/client/tdm_client.h +++ b/client/tdm_client.h @@ -113,7 +113,7 @@ tdm_client_destroy(tdm_client *client); * while(1) { * ret = poll(&fds, 1, -1); * if (ret < 0) { - * if (errno == EBUSY) + * if (errno == EINTR || errno == EAGAIN) * continue; * else { * //error handling diff --git a/src/tdm_display.c b/src/tdm_display.c index 17c02aa..cab04a6 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -417,7 +417,7 @@ tdm_display_handle_events(tdm_display *dpy) TDM_INFO("fd(%d) polling in", fd); while (poll(&fds, 1, -1) < 0) { - if (errno == EBUSY) /* normal case */ + if (errno == EINTR || errno == EAGAIN) /* normal case */ continue; else { TDM_ERR("poll failed: %m"); diff --git a/src/tdm_thread.c b/src/tdm_thread.c index 0d24561..3ae6d0b 100644 --- a/src/tdm_thread.c +++ b/src/tdm_thread.c @@ -99,7 +99,7 @@ _tdm_thread_main(void *data) TDM_INFO("fd(%d) polling out", fd); if (ret < 0) { - if (errno == EBUSY) /* normal case */ + if (errno == EINTR || errno == EAGAIN) /* normal case */ continue; else { TDM_ERR("poll failed: %m"); diff --git a/tools/tdm_test_client.c b/tools/tdm_test_client.c index 499d1f5..7268628 100644 --- a/tools/tdm_test_client.c +++ b/tools/tdm_test_client.c @@ -121,7 +121,7 @@ main(int argc, char *argv[]) if (!sync) { ret = poll(&fds, 1, -1); if (ret < 0) { - if (errno == EBUSY) /* normal case */ + if (errno == EINTR || errno == EAGAIN) /* normal case */ continue; else { printf("poll failed: %m\n"); -- 2.7.4 From 3c28bfc94c9f680bc7bb5f8c2ca2aaa4b7b5081c Mon Sep 17 00:00:00 2001 From: Boram Park Date: Mon, 27 Jun 2016 13:35:24 +0900 Subject: [PATCH 16/16] add tdm_common.h to share enumeration and structure with client Change-Id: I6c64905cb8363cc99f3742fe40934872d5d2cb33 --- include/Makefile.am | 1 + include/tdm.h | 8 --- include/tdm_common.h | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/tdm_types.h | 67 +------------------------- packaging/libtdm.spec | 2 + src/tdm_capture.c | 2 +- src/tdm_display.c | 49 ++----------------- src/tdm_macro.h | 38 +++++++++++++++ src/tdm_private.h | 9 +--- src/tdm_server.c | 4 +- 10 files changed, 181 insertions(+), 130 deletions(-) create mode 100644 include/tdm_common.h diff --git a/include/Makefile.am b/include/Makefile.am index b47ee00..aa1d502 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,6 +1,7 @@ libtdmincludedir = ${includedir} libtdminclude_HEADERS = \ tdm.h \ + tdm_common.h \ tdm_types.h \ tdm_list.h \ tdm_log.h \ diff --git a/include/tdm.h b/include/tdm.h index 6ba4996..47afc19 100644 --- a/include/tdm.h +++ b/include/tdm.h @@ -65,14 +65,6 @@ typedef enum { } tdm_display_capability; /** - * @brief The output change enumeration of #tdm_output_change_handler - */ -typedef enum { - TDM_OUTPUT_CHANGE_CONNECTION = (1 << 0), /**< connection chagne */ - TDM_OUTPUT_CHANGE_DPMS = (1 << 1), /**< dpms change */ -} tdm_output_change_type; - -/** * @brief The output change handler * @details This handler will be called when the status of a output object is * changed in runtime. diff --git a/include/tdm_common.h b/include/tdm_common.h new file mode 100644 index 0000000..79cdf69 --- /dev/null +++ b/include/tdm_common.h @@ -0,0 +1,131 @@ +/************************************************************************** + * + * libtdm + * + * Copyright 2015 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: Eunchul Kim , + * JinYoung Jeon , + * Taeheon Kim , + * YoungJun Cho , + * SooChan Lim , + * Boram Park + * + * 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. + * +**************************************************************************/ + +#ifndef _TDM_COMMON_H_ +#define _TDM_COMMON_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define TDM_NAME_LEN 64 + +/** + * @file tdm_common.h + * @brief The header file which defines Enumerations and Structures for TDM + * frontend, backend and client. + */ + +/** + * @brief The error enumeration + */ +typedef enum { + TDM_ERROR_NONE = 0, /**< none */ + TDM_ERROR_BAD_REQUEST = -1, /**< bad request */ + TDM_ERROR_OPERATION_FAILED = -2, /**< operaion failed */ + TDM_ERROR_INVALID_PARAMETER = -3, /**< wrong input parameter */ + TDM_ERROR_PERMISSION_DENIED = -4, /**< access denied */ + TDM_ERROR_BUSY = -5, /**< hardware resource busy */ + TDM_ERROR_OUT_OF_MEMORY = -6, /**< no free memory */ + TDM_ERROR_BAD_MODULE = -7, /**< bad backend module */ + TDM_ERROR_NOT_IMPLEMENTED = -8, /**< not implemented */ + TDM_ERROR_NO_CAPABILITY = -9, /**< no capability */ + TDM_ERROR_DPMS_OFF = -10, /**< dpms off */ +} tdm_error; + +/** + * @brief The output change enumeration of #tdm_output_change_handler + */ +typedef enum { + TDM_OUTPUT_CHANGE_CONNECTION = (1 << 0), /**< connection chagne */ + TDM_OUTPUT_CHANGE_DPMS = (1 << 1), /**< dpms change */ +} tdm_output_change_type; + +/** + * @brief The output connection status enumeration + */ +typedef enum { + TDM_OUTPUT_CONN_STATUS_DISCONNECTED, /**< output disconnected */ + TDM_OUTPUT_CONN_STATUS_CONNECTED, /**< output connected */ + TDM_OUTPUT_CONN_STATUS_MODE_SETTED, /**< output connected and setted a mode */ +} tdm_output_conn_status; + +/** + * @brief The DPMS enumeration + * @details bit compatible with the libdrm definitions. + */ +typedef enum { + TDM_OUTPUT_DPMS_ON, /**< On */ + TDM_OUTPUT_DPMS_STANDBY, /**< StandBy */ + TDM_OUTPUT_DPMS_SUSPEND, /**< Suspend */ + TDM_OUTPUT_DPMS_OFF, /**< Off */ +} tdm_output_dpms; + +/** + * @brief The size structure + */ +typedef struct _tdm_size { + unsigned int h; /**< width */ + unsigned int v; /**< height */ +} tdm_size; + +/** + * @brief The pos structure + */ +typedef struct _tdm_pos { + unsigned int x; + unsigned int y; + unsigned int w; + unsigned int h; +} tdm_pos; + +/** + * @brief The value union + */ +typedef union { + void *ptr; + int32_t s32; + uint32_t u32; + int64_t s64; + uint64_t u64; +} tdm_value; + +#ifdef __cplusplus +} +#endif + +#endif /* _TDM_COMMON_H_ */ diff --git a/include/tdm_types.h b/include/tdm_types.h index a6b68fa..53988f2 100755 --- a/include/tdm_types.h +++ b/include/tdm_types.h @@ -42,8 +42,6 @@ extern "C" { #endif -#define TDM_NAME_LEN 64 - /** * @file tdm_types.h * @brief The header file which defines Enumerations and Structures for frontend and backend. @@ -59,21 +57,7 @@ extern "C" { * @endcode */ -/** - * @brief The error enumeration - */ -typedef enum { - TDM_ERROR_NONE = 0, /**< none */ - TDM_ERROR_BAD_REQUEST = -1, /**< bad request */ - TDM_ERROR_OPERATION_FAILED = -2, /**< operaion failed */ - TDM_ERROR_INVALID_PARAMETER = -3, /**< wrong input parameter */ - TDM_ERROR_PERMISSION_DENIED = -4, /**< access denied */ - TDM_ERROR_BUSY = -5, /**< hardware resource busy */ - TDM_ERROR_OUT_OF_MEMORY = -6, /**< no free memory */ - TDM_ERROR_BAD_MODULE = -7, /**< bad backend module */ - TDM_ERROR_NOT_IMPLEMENTED = -8, /**< not implemented */ - TDM_ERROR_NO_CAPABILITY = -9, /**< no capability */ -} tdm_error; +#include /** * @brief The transform enumeration(rotate, flip) @@ -91,15 +75,6 @@ typedef enum { /** * @brief The output connection status enumeration - */ -typedef enum { - TDM_OUTPUT_CONN_STATUS_DISCONNECTED, /**< output disconnected */ - TDM_OUTPUT_CONN_STATUS_CONNECTED, /**< output connected */ - TDM_OUTPUT_CONN_STATUS_MODE_SETTED, /**< output connected and setted a mode */ -} tdm_output_conn_status; - -/** - * @brief The output connection status enumeration * @details bit compatible with the libdrm definitions. */ typedef enum { @@ -123,17 +98,6 @@ typedef enum { } tdm_output_type; /** - * @brief The DPMS enumeration - * @details bit compatible with the libdrm definitions. - */ -typedef enum { - TDM_OUTPUT_DPMS_ON, /**< On */ - TDM_OUTPUT_DPMS_STANDBY, /**< StandBy */ - TDM_OUTPUT_DPMS_SUSPEND, /**< Suspend */ - TDM_OUTPUT_DPMS_OFF, /**< Off */ -} tdm_output_dpms; - -/** * @brief The layer capability enumeration * @details * A layer can have one of CURSOR, PRIMARY and OVERLAY capability. And a layer @@ -253,35 +217,6 @@ typedef struct _tdm_prop { } tdm_prop; /** - * @brief The size structure - */ -typedef struct _tdm_size { - unsigned int h; /**< width */ - unsigned int v; /**< height */ -} tdm_size; - -/** - * @brief The pos structure - */ -typedef struct _tdm_pos { - unsigned int x; - unsigned int y; - unsigned int w; - unsigned int h; -} tdm_pos; - -/** - * @brief The value union - */ -typedef union { - void *ptr; - int32_t s32; - uint32_t u32; - int64_t s64; - uint64_t u64; -} tdm_value; - -/** * @brief The info config structure */ typedef struct _tdm_info_config { diff --git a/packaging/libtdm.spec b/packaging/libtdm.spec index 11cec9a..28bb692 100644 --- a/packaging/libtdm.spec +++ b/packaging/libtdm.spec @@ -35,6 +35,7 @@ Tizen Display Manager Client Library Summary: Client library for Tizen Display Manager Group: Development/Libraries Requires: libtdm-client = %{version} +Requires: libtdm-devel %description client-devel Tizen Display Manager Client Library headers @@ -100,6 +101,7 @@ rm -f %{_unitdir_user}/default.target.wants/tdm-socket-user.path %manifest %{name}.manifest %defattr(-,root,root,-) %{_includedir}/tdm.h +%{_includedir}/tdm_common.h %{_includedir}/tdm_backend.h %{_includedir}/tdm_helper.h %{_includedir}/tdm_list.h diff --git a/src/tdm_capture.c b/src/tdm_capture.c index ea67044..8f562ab 100644 --- a/src/tdm_capture.c +++ b/src/tdm_capture.c @@ -403,7 +403,7 @@ tdm_capture_commit(tdm_capture *capture) private_output = private_capture->private_output; if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) { TDM_ERR("output(%d) dpms: %s", private_output->pipe, - dpms_str(private_output->current_dpms_value)); + tdm_dpms_str(private_output->current_dpms_value)); _pthread_mutex_unlock(&private_display->lock); return TDM_ERROR_BAD_REQUEST; } diff --git a/src/tdm_display.c b/src/tdm_display.c index cab04a6..2c09442 100644 --- a/src/tdm_display.c +++ b/src/tdm_display.c @@ -102,47 +102,6 @@ private_output = private_layer->private_output; \ private_display = private_output->private_display -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) - -struct type_name { - int type; - const char *name; -}; - -#define type_name_fn(res) \ -const char * res##_str(int type) \ -{ \ - unsigned int i; \ - for (i = 0; i < ARRAY_SIZE(res##_names); i++) { \ - if (res##_names[i].type == type) \ - return res##_names[i].name; \ - } \ - return "(invalid)"; \ -} - -struct type_name dpms_names[] = { - { TDM_OUTPUT_DPMS_ON, "on" }, - { TDM_OUTPUT_DPMS_STANDBY, "standby" }, - { TDM_OUTPUT_DPMS_SUSPEND, "suspend" }, - { TDM_OUTPUT_DPMS_OFF, "off" }, -}; - -INTERN type_name_fn(dpms) - -struct type_name status_names[] = { - { TDM_OUTPUT_CONN_STATUS_DISCONNECTED, "disconnected" }, - { TDM_OUTPUT_CONN_STATUS_CONNECTED, "connected" }, - { TDM_OUTPUT_CONN_STATUS_MODE_SETTED, "mode_setted" }, -}; - -INTERN type_name_fn(status) - -INTERN const char* -tdm_get_dpms_str(tdm_output_dpms dpms_value) -{ - return dpms_str(dpms_value); -} - INTERN tdm_error _tdm_display_lock(tdm_display *dpy, const char *func) { @@ -988,7 +947,7 @@ tdm_output_wait_vblank(tdm_output *output, int interval, int sync, if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) { TDM_ERR("output(%d) dpms: %s", private_output->pipe, - dpms_str(private_output->current_dpms_value)); + tdm_dpms_str(private_output->current_dpms_value)); _pthread_mutex_unlock(&private_display->lock); return TDM_ERROR_BAD_REQUEST; } @@ -1082,7 +1041,7 @@ tdm_output_commit(tdm_output *output, int sync, tdm_output_commit_handler func, if (private_output->current_dpms_value > TDM_OUTPUT_DPMS_ON) { TDM_ERR("output(%d) dpms: %s", private_output->pipe, - dpms_str(private_output->current_dpms_value)); + tdm_dpms_str(private_output->current_dpms_value)); _pthread_mutex_unlock(&private_display->lock); return TDM_ERROR_BAD_REQUEST; } @@ -1245,10 +1204,10 @@ tdm_output_call_change_handler_internal(tdm_private_output *private_output, if (!tdm_thread_in_display_thread(syscall(SYS_gettid))) { if (type & TDM_OUTPUT_CHANGE_CONNECTION) TDM_INFO("output(%d) changed: %s (%d)", - private_output->pipe, status_str(value.u32), value.u32); + private_output->pipe, tdm_status_str(value.u32), value.u32); if (type & TDM_OUTPUT_CHANGE_DPMS) TDM_INFO("output(%d) changed: dpms %s (%d)", - private_output->pipe, dpms_str(value.u32), value.u32); + private_output->pipe, tdm_dpms_str(value.u32), value.u32); } if (LIST_IS_EMPTY(change_handler_list)) diff --git a/src/tdm_macro.h b/src/tdm_macro.h index b87b4a0..659ead3 100644 --- a/src/tdm_macro.h +++ b/src/tdm_macro.h @@ -41,6 +41,8 @@ #include #include +#include + #ifdef __cplusplus extern "C" { #endif @@ -117,6 +119,42 @@ extern "C" { #define FOURCC_STR(id) C(id, 0), C(id, 8), C(id, 16), C(id, 24) #define FOURCC_ID(str) FOURCC(((char*)str)[0], ((char*)str)[1], ((char*)str)[2], ((char*)str)[3]) + +#define TDM_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +struct tdm_type_name { + int type; + const char *name; +}; + +#define TDM_TYPE_NAME_FN(res) \ +static inline const char * tdm_##res##_str(int type) \ +{ \ + unsigned int i; \ + for (i = 0; i < TDM_ARRAY_SIZE(tdm_##res##_names); i++) { \ + if (tdm_##res##_names[i].type == type) \ + return tdm_##res##_names[i].name; \ + } \ + return "(invalid)"; \ +} + +static struct tdm_type_name tdm_dpms_names[] = { + { TDM_OUTPUT_DPMS_ON, "on" }, + { TDM_OUTPUT_DPMS_STANDBY, "standby" }, + { TDM_OUTPUT_DPMS_SUSPEND, "suspend" }, + { TDM_OUTPUT_DPMS_OFF, "off" }, +}; + +TDM_TYPE_NAME_FN(dpms) + +static struct tdm_type_name tdm_status_names[] = { + { TDM_OUTPUT_CONN_STATUS_DISCONNECTED, "disconnected" }, + { TDM_OUTPUT_CONN_STATUS_CONNECTED, "connected" }, + { TDM_OUTPUT_CONN_STATUS_MODE_SETTED, "mode_setted" }, +}; + +TDM_TYPE_NAME_FN(status) + #ifdef __cplusplus } #endif diff --git a/src/tdm_private.h b/src/tdm_private.h index db7426e..bdb1a20 100644 --- a/src/tdm_private.h +++ b/src/tdm_private.h @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -84,11 +85,6 @@ extern int tdm_debug_thread; #define TDM_TRACE_END() #endif -#define prototype_name_fn(res) const char * res##_str(int type) - -prototype_name_fn(dpms); -prototype_name_fn(status); - typedef enum { TDM_CAPTURE_TARGET_OUTPUT, TDM_CAPTURE_TARGET_LAYER, @@ -304,9 +300,6 @@ typedef struct _tdm_buffer_info { struct list_head link; } tdm_buffer_info; -const char* -tdm_get_dpms_str(tdm_output_dpms dpms_value); - int tdm_display_check_module_abi(tdm_private_display *private_display, int abimaj, int abimin); diff --git a/src/tdm_server.c b/src/tdm_server.c index 1233deb..b71c2a2 100644 --- a/src/tdm_server.c +++ b/src/tdm_server.c @@ -321,8 +321,8 @@ _tdm_server_client_cb_wait_vblank(struct wl_client *client, 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)); - TDM_ERR("dpms '%s'", tdm_get_dpms_str(dpms_value)); + "dpms '%s'", tdm_dpms_str(dpms_value)); + TDM_ERR("dpms '%s'", tdm_dpms_str(dpms_value)); return; } -- 2.7.4