From 49936541ff03afe74382bf9a4e6da31077379278 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Thu, 24 Mar 2016 17:54:24 +0200 Subject: [PATCH 01/16] add page fliping between two buffers. refactor of _e_eom_ecore_drm_output_cb() Change-Id: I46d39be5eaf75c29ac33e5397e77b547bee4dcea Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 360 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 231 insertions(+), 129 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 77c502f..e3ded89 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -36,10 +36,13 @@ typedef struct { tdm_layer *layer; tdm_output *output; - tbm_surface_h dst_buffers; -} Eom_Event; -static Eom_Event g_eom_event; + tbm_surface_h dst_buffers[2]; + int current_buffer; + +} Eom_Data; + +static Eom_Data g_eom_data; E_EomPtr g_eom = NULL; @@ -78,66 +81,65 @@ _e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) * There is no external output */ if (num_outputs == 1) - return NULL; + { + EOM_DBG("ONE OUTPUT\n"); + return NULL; + } return output; } static tdm_output * -_e_eom_hal_output_get(const char *id, int primary_output_id) +_e_eom_hal_output_get(const char *id) { - Ecore_Drm_Output *drm_output; Ecore_Drm_Device *dev; - Eina_List *l; - int crtc_id = 0; - tdm_error err = TDM_ERROR_NONE; - - tdm_output *output = NULL; + Ecore_Drm_Output *drm_output, *o; + tdm_output *output; tdm_output_mode *modes; tdm_output_mode *big_mode; + tdm_error err = TDM_ERROR_NONE; + Eina_List *l, *ll; + int crtc_id = 0; int count = 0; - /* * Temporary take into account only HDMI */ - if (strcmp(id, "HDMI-A-0")) - { - EOM_DBG("not find output\n"); - return NULL; - } EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) { - drm_output = ecore_drm_device_output_name_find(dev, id); + EINA_LIST_FOREACH(dev->external_outputs, ll, o) + { + if ((ecore_drm_output_name_get(o)) && (!strcmp(id, ecore_drm_output_name_get(o)))) + drm_output = o; + } } if (!drm_output) { - EOM_DBG("not find drm output\n"); + EOM_DBG("ERROR: drm output was not found\n"); return NULL; } crtc_id = ecore_drm_output_crtc_id_get(drm_output); if (crtc_id == 0) { - EOM_DBG("crtc is 0\n"); + EOM_DBG("ERROR: crtc is 0\n"); return NULL; } output = tdm_display_get_output(g_eom->dpy, crtc_id, NULL); if (!output) { - EOM_DBG("there is no HAL output for:%d\n", crtc_id); + EOM_DBG("ERROR: there is no HAL output for:%d\n", crtc_id); return NULL; } int min_w, min_h, max_w, max_h, preferred_align; - err = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, - &preferred_align); + err = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, &preferred_align); if (err != TDM_ERROR_NONE) { - EOM_DBG("Gent get geometry for hal output"); + EOM_DBG("ERROR: Gent get geometry for hal output"); return NULL; } @@ -147,8 +149,6 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) /* * Force TDM to make setCrtc onto new buffer */ - - err = tdm_output_get_available_modes(output, &modes, &count); if (err != TDM_ERROR_NONE) { @@ -161,11 +161,8 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) int i = 0; for (i = 0; i < count; i++) { - if ((modes[i].vdisplay + modes[i].hdisplay) >= - (big_mode->vdisplay + big_mode->hdisplay)) - { - big_mode = &modes[i]; - } + if ((modes[i].vdisplay + modes[i].hdisplay) >= (big_mode->vdisplay + big_mode->hdisplay)) + big_mode = &modes[i]; } if (!big_mode) @@ -183,7 +180,7 @@ _e_eom_hal_output_get(const char *id, int primary_output_id) return NULL; } - EOM_DBG("find\n"); + EOM_DBG("Created output: %p\n", output); return output; } @@ -195,9 +192,9 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) tdm_layer *layer; tdm_error err = TDM_ERROR_NONE; tdm_layer_capability capa; - tdm_info_layer set_layer_info; + err = tdm_output_get_layer_count(output, &count); if (err != TDM_ERROR_NONE) { @@ -229,8 +226,8 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) } memset(&set_layer_info, 0x0, sizeof(tdm_info_layer)); - set_layer_info.src_config.size.h = 3840; - set_layer_info.src_config.size.v = 2560; + set_layer_info.src_config.size.h = width; + set_layer_info.src_config.size.v = height; set_layer_info.src_config.pos.x = 0; set_layer_info.src_config.pos.y = 0; set_layer_info.src_config.pos.w = width; @@ -292,55 +289,88 @@ _e_eom_root_window_tdm_surface_get() } static void -_e_eom_output_cb_commit(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, +_e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *user_data) { - Eom_Event *eom_event = (Eom_Event *)user_data; - tdm_error err = TDM_ERROR_NONE; + Eom_Data *eom_data; tbm_surface_h src_buffer; - tbm_surface_h dst_buffer; + tdm_error err = TDM_ERROR_NONE; + + EOM_DBG("Event 1\n"); + + if (!user_data) + { + EOM_ERR("ERROR: EVENT: user_data is NULL\n"); + return; + } + + eom_data = (Eom_Data *)user_data; - EOM_ERR("Event\n"); + EOM_DBG("Event 2\n"); +/* src_buffer = _e_eom_root_window_tdm_surface_get(); if (!src_buffer ) { EOM_ERR("Event: tdm_buffer is NULL\n"); return; } +*/ - dst_buffer = eom_event->dst_buffers; + if (eom_data->current_buffer == 1) + { + eom_data->current_buffer = 0; - /* Do clone */ - tdm_layer_set_buffer(eom_event->layer, dst_buffer); + err = tdm_layer_set_buffer(eom_data->layer, + eom_data->dst_buffers[eom_data->current_buffer]); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: set buffer 0\n"); + return; + } - err = tdm_output_commit(eom_event->output, 0, NULL, eom_event); + EOM_DBG("Event 3\n"); + } + else + { + eom_data->current_buffer = 1; + + err = tdm_layer_set_buffer(eom_data->layer, + eom_data->dst_buffers[eom_data->current_buffer]); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: set buffer 1\n"); + return; + } + + EOM_DBG("Event 4\n"); + } + + err = tdm_output_commit(eom_data->output, 0, _e_eom_output_commit_cb, eom_data); if (err != TDM_ERROR_NONE) { - EOM_ERR("Event: Cannot commit crtc\n"); + EOM_ERR("ERROR: EVENT: commit\n"); return; } + + EOM_DBG("Event 5\n"); } -static tbm_surface_h -_e_eom_create_extrenal_output_buffer(int width, int height) +static int +_e_eom_create_output_buffers(Eom_Data *eom_data, int width, int height) { tbm_surface_h buffer; tbm_surface_info_s buffer_info; - width = 3840; - height = 2560; - /* * TODO: Add support of other formats */ - buffer = tbm_surface_internal_create_with_flags(width, height, - TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); + buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); if (!buffer) { EOM_DBG("can not create dst_buffer\n"); - return NULL; + goto err; } /* @@ -348,17 +378,53 @@ _e_eom_create_extrenal_output_buffer(int width, int height) */ memset(&buffer_info, 0x0, sizeof(tbm_surface_info_s)); if (tbm_surface_map(buffer, - TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, - &buffer_info) != TBM_SURFACE_ERROR_NONE) + TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, + &buffer_info) != TBM_SURFACE_ERROR_NONE) { EOM_DBG("can not mmap buffer\n"); - return NULL; + goto err; } memset(buffer_info.planes[0].ptr, 0xff, buffer_info.planes[0].size); tbm_surface_unmap(buffer); - return buffer; + eom_data->dst_buffers[0] = buffer; + + /* + * TODO: Add support of other formats + */ + buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); + if (!buffer) + { + EOM_DBG("can not create dst_buffer\n"); + goto err; + } + + /* + * TODO: temp code for testing, actual convert will be in _e_eom_put_src_to_dst() + */ + memset(&buffer_info, 0x00, sizeof(tbm_surface_info_s)); + if (tbm_surface_map(buffer, + TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, + &buffer_info) != TBM_SURFACE_ERROR_NONE) + { + EOM_DBG("can not mmap buffer\n"); + goto err; + } + + memset(buffer_info.planes[0].ptr, 0x55, buffer_info.planes[0].size); + tbm_surface_unmap(buffer); + + eom_data->dst_buffers[1] = buffer; + + return 1; + +err: + +/* + * Add deinitialization + */ + return 0; } static void @@ -369,122 +435,157 @@ _e_eom_put_src_to_dst( tbm_surface_h src_buffer, tbm_surface_h dst_buffer) } -static Eina_Bool -_e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +static int +_e_eom_set_up_external_output(const char *output_name, int width, int height) { - Ecore_Drm_Event_Output *e; - E_EomPtr eom = data; - E_Comp_Wl_Output *wl_output; tdm_output *hal_output; tdm_layer *hal_layer; tdm_info_layer layer_info; - tbm_surface_h src_buffer; - tbm_surface_h dst_buffer; - tbm_surface_info_s src_buffer_info ; - Eina_List *l2; - Eom_Event *eom_event = &g_eom_event; - struct wl_resource *output_resource; - enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; - char buff[PATH_MAX]; tdm_error tdm_err = TDM_ERROR_NONE; - int tbm_err = 0; - - if (!(e = event)) goto end; - - if (!e->plug) goto end; - - EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s name:%s plug:%d\n", - e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->name, e->plug); + Eom_Data *eom_data = &g_eom_data; + int ret = 0; - snprintf(buff, sizeof(buff), "%s", e->name); - /* get the e_comp_wl_output */ - wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); - if (!wl_output) + hal_output = _e_eom_hal_output_get(output_name); + if (!hal_output) { - EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); - goto end; + EOM_ERR("ERROR: get hal output for, (%s)\n", output_name); + goto err; } - /* Get hal output */ - hal_output = _e_eom_hal_output_get(buff, e->id); - if (!hal_output) + hal_layer = _e_eom_hal_layer_get(hal_output, width, height); + if (!hal_layer) { - EOM_ERR("no hal outputs, (%s)\n", buff); - goto end; + EOM_ERR("ERROR: get hal layer\n"); + goto err; } - hal_layer = _e_eom_hal_layer_get(hal_output, e->w, e->h); - if (!hal_layer) + ret = _e_eom_create_output_buffers(eom_data, width, height); + if (!ret ) { - EOM_ERR("no hal layer\n"); - goto end; + EOM_ERR("ERROR: create buffers \n"); + goto err; } - /* Get main frame buffer */ - /* +/* src_buffer = _e_eom_root_window_tdm_surface_get(); if (!src_buffer ) - { + { EOM_ERR("no framebuffer\n"); - goto end; - } - */ - - - dst_buffer = _e_eom_create_extrenal_output_buffer(e->w, e->h); - if (!dst_buffer ) - { - EOM_ERR("no dst buffer\n"); - goto end; - } + goto end; + } +*/ - /* +/* tbm_surface_get_info(src_buffer, &src_buffer_info ); EOM_DBG("FRAMEBUFFER buffer: %dx%d bpp:%d size:%d", - src_buffer_info.width, - src_buffer_info.height, - src_buffer_info.bpp, - src_buffer_info.size); + src_buffer_info.width, + src_buffer_info.height, + src_buffer_info.bpp, + src_buffer_info.size); _e_eom_put_src_to_dst(src_buffer, dst_buffer); - */ +*/ tdm_err = tdm_layer_get_info(hal_layer, &layer_info); if (tdm_err != TDM_ERROR_NONE) { - EOM_ERR ("failed get layer info", tdm_err); - goto end; + EOM_ERR ("ERROR: get layer info: %d", tdm_err); + goto err; } EOM_DBG("LAYER INFO: %dx%d, pos (x:%d, y:%d, w:%d, h:%d, dpos (x:%d, y:%d, w:%d, h:%d))", - layer_info.src_config.size.h, layer_info.src_config.size.v, - layer_info.src_config.pos.x, layer_info.src_config.pos.y, - layer_info.src_config.pos.w, layer_info.src_config.pos.h, - layer_info.dst_pos.x, layer_info.dst_pos.y, - layer_info.dst_pos.w, layer_info.dst_pos.h); + layer_info.src_config.size.h, layer_info.src_config.size.v, + layer_info.src_config.pos.x, layer_info.src_config.pos.y, + layer_info.src_config.pos.w, layer_info.src_config.pos.h, + layer_info.dst_pos.x, layer_info.dst_pos.y, + layer_info.dst_pos.w, layer_info.dst_pos.h); + + eom_data->layer = hal_layer; + eom_data->output = hal_output; + eom_data->current_buffer = 0; - tdm_err = tdm_layer_set_buffer(hal_layer, dst_buffer); + tdm_err = tdm_layer_set_buffer(hal_layer, eom_data->dst_buffers[eom_data->current_buffer]); if (tdm_err != TDM_ERROR_NONE) { - EOM_ERR("Failed set buffer on layer:%d\n", tdm_err); + EOM_ERR("ERROR: set buffer on layer:%d\n", tdm_err); + goto err; + } + + tdm_err = tdm_output_commit(hal_output, 0, _e_eom_output_commit_cb, eom_data); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: commit crtc:%d\n", tdm_err); + goto err; + } + + return 1; + +err: +/* + * TODO: add deinitialization + */ + return 0; +} + +static Eina_Bool +_e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +{ + Ecore_Drm_Event_Output *e; + E_EomPtr eom = data; + E_Comp_Wl_Output *wl_output; + struct wl_resource *output_resource; + enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; + char buff[PATH_MAX]; + int ret = 0; + + if (!(e = event)) goto end; + + if (!e->plug) goto end; + + EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s name:%s plug:%d\n", + e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->name, e->plug); + + snprintf(buff, sizeof(buff), "%s", e->name); + + if (strcmp(e->name, "HDMI-A-0")) + { + EOM_DBG("Skip internal output\n"); goto end; } - eom_event->layer = hal_layer; - eom_event->output = hal_output; - eom_event->dst_buffers = dst_buffer; + /* + * Get e_comp_wl_output + */ +/* + wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); + if (!wl_output) + { + EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); + goto end; + } +*/ - tdm_err = tdm_output_commit(hal_output, 0, _e_eom_output_cb_commit, &eom_event); - if (tdm_err != TDM_ERROR_NONE) + /* + * Initialize external output + */ + ret = _e_eom_set_up_external_output(buff, e->w, e->h); + if (!ret) { - EOM_ERR("Cannot commit crtc:%d\n", tdm_err); + EOM_ERR("Failed initialize external output\n"); goto end; } + + /* Get main frame buffer */ + + + + + /* EINA_LIST_FOREACH(wl_output->resources, l2, output_resource) { if (e->plug) @@ -505,8 +606,9 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e WL_EOM_STATUS_DISCONNECTION); } } + */ + - EOM_DBG("8\n"); end: return ECORE_CALLBACK_PASS_ON; -- 2.7.4 From fb576a21d4b598c5199f60258c8d30159d36caf7 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Wed, 30 Mar 2016 18:54:58 +0300 Subject: [PATCH 02/16] grab and convert root window to external output. Working Mirror Change-Id: I08e0a5404b67965a397cf5e311ace6635d46b003 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 883 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 579 insertions(+), 304 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index e3ded89..0444a4e 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -13,7 +13,29 @@ #include +#define NUM_MAIN_BUF 2 +#define NUM_PP_BUF 3 + +/* + * TODO: remove "flag" + * TODO: add correct PP conversion of src to dst + * TODO !!!: remove flickering + * TODO : deinitialization, free memory + * TODO !!!: change mechanism of PP and output to external output + * TODO !!!: remove magic numbers on return and set current buffer and pp buffer + * TODO : remove EOM_DBG("1\n") etc. + */ + + typedef struct _E_Eom E_Eom, *E_EomPtr; +typedef struct _E_Eom_Out_Mode E_EomOutMode, *E_EomOutModePtr; +typedef struct _E_Eom_Data E_EomData, *E_EomDataPtr; + +struct _E_Eom_Out_Mode +{ + int w; + int h; +}; struct _E_Eom { @@ -21,28 +43,33 @@ struct _E_Eom struct wl_resource *resource; Eina_List *handlers; + int is_external_init; + int is_internal_grab; + tdm_display *dpy; tbm_bufmgr bufmgr; int fd; -}; -typedef struct _Ecore_Drm_Hal_Output -{ - tdm_output *output; - tdm_layer *primary_layer; -} Ecore_Drm_Hal_Output; + E_EomOutMode src_mode; + E_EomOutMode dst_mode; -typedef struct + char *ext_output_name; + char *int_output_name; +}; + +struct _E_Eom_Data { tdm_layer *layer; tdm_output *output; + tdm_pp *pp; - tbm_surface_h dst_buffers[2]; + tbm_surface_h dst_buffers[NUM_MAIN_BUF]; + tbm_surface_h pp_buffers[NUM_PP_BUF]; int current_buffer; + int pp_buffer; +}; -} Eom_Data; - -static Eom_Data g_eom_data; +static E_EomData g_eom_data; E_EomPtr g_eom = NULL; @@ -50,88 +77,345 @@ E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; static E_Client_Hook *fullscreen_pre_hook = NULL; + +/* tdm handlers */ +static void +_e_eom_pp_cb(tbm_surface_h surface, void *user_data); +static void +_e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, + unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, + void *user_data); + +/* handle external output */ static E_Comp_Wl_Output * -_e_eom_e_comp_wl_output_get(Eina_List *outputs, const char *id) +_e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id); + +static int +_e_eom_set_up_external_output(const char *output_name, int width, int height); + +static tdm_output * +_e_eom_hal_output_get(const char *id); + +static tdm_layer * +_e_eom_hal_layer_get(tdm_output *output, int width, int height); + +static int +_e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height); + +static enum wl_eom_type +_e_eom_output_name_to_eom_type(const char *output_name); + +/* handle internal output, pp */ +static int +_e_eom_root_internal_surface_get(const char *output_name, int width, int height); + +static tbm_surface_h +_e_eom_root_internal_tdm_surface_get(const char *name); + +static int +_e_eom_pp_src_to_dst( tbm_surface_h src_buffer); + + +static void +_e_eom_pp_cb(tbm_surface_h surface, void *user_data) { - Eina_List *l; - E_Comp_Wl_Output *output = NULL, *out; - int num_outputs = 0; + E_EomDataPtr eom_data = NULL; + tdm_error tdm_err = TDM_ERROR_NONE; - EINA_LIST_FOREACH(outputs, l, out) + EOM_DBG("PP EVENT: get\n"); + + if (!user_data) { - char *temp_id = NULL; - temp_id = strchr(out->id, '/'); - if (temp_id == NULL) - { - if (!strcmp(out->id, id)) - output = out; - } - else - { - int loc = temp_id - out->id; + EOM_DBG("ERROR: PP EVENT: user data is NULL\n"); + return; + } - if (!strncmp(out->id, id, loc)) - output = out; - } + eom_data = (E_EomDataPtr)user_data; - num_outputs += 1; + tdm_buffer_remove_release_handler(eom_data->dst_buffers[eom_data->pp_buffer], + _e_eom_pp_cb, eom_data); + + tbm_surface_h src_buffer; + src_buffer = _e_eom_root_internal_tdm_surface_get(g_eom->int_output_name); + if (!src_buffer ) + { + EOM_DBG("ERROR: PP EVENT: get root tdm surfcae\n"); + return; } - /* - * There is no external output - */ - if (num_outputs == 1) + g_eom_data.pp_buffer = !g_eom_data.current_buffer; + + tdm_err = tdm_buffer_add_release_handler(g_eom_data.dst_buffers[g_eom_data.pp_buffer], + _e_eom_pp_cb, &g_eom_data); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_DBG ("ERROR: PP EVENT: set pp hadler:%d\n", tdm_err ); + return; + } + + tdm_err = tdm_pp_attach(eom_data->pp, src_buffer, g_eom_data.dst_buffers[g_eom_data.pp_buffer]); + if (tdm_err != TDM_ERROR_NONE) + { + printf ("ERROR: pp attach:%d\n", tdm_err); + return; + } + + tdm_err = tdm_pp_commit(g_eom_data.pp); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_DBG ("ERROR: PP EVENT: pp commit:%d\n", tdm_err ); + return; + } + + EOM_DBG ("PP EVENT: ok\n"); +} + +static void +_e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, + unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, + void *user_data) +{ + E_EomDataPtr eom_data; + tdm_error err = TDM_ERROR_NONE; + + EOM_DBG("Event 1\n"); + + if (!user_data) { - EOM_DBG("ONE OUTPUT\n"); - return NULL; + EOM_ERR("ERROR: EVENT: user_data is NULL\n"); + return; } + eom_data = (E_EomDataPtr)user_data; + + EOM_DBG("Event 2\n"); + + if (eom_data->current_buffer == 1) + { + eom_data->current_buffer = 0; + + err = tdm_layer_set_buffer(eom_data->layer, + eom_data->dst_buffers[eom_data->current_buffer]); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: set buffer 0\n"); + return; + } + + EOM_DBG("Event 3\n"); + } + else + { + eom_data->current_buffer = 1; + + err = tdm_layer_set_buffer(eom_data->layer, + eom_data->dst_buffers[eom_data->current_buffer]); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: set buffer 1\n"); + return; + } + + EOM_DBG("Event 4\n"); + } + + err = tdm_output_commit(eom_data->output, 0, _e_eom_output_commit_cb, eom_data); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: commit\n"); + return; + } + + EOM_DBG("Event 5\n"); +} + +static E_Comp_Wl_Output * +_e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id) +{ + const Eina_List *l; + E_Comp_Wl_Output *output = NULL, *o; + int loc = 0; + + EINA_LIST_FOREACH(outputs, l, o) + { + char *temp_id = NULL; + temp_id = strchr(o->id, '/'); + + EOM_DBG("o->id=%s", o->id); + + if (temp_id == NULL) + { + if (strcmp(o->id, id) == 0) + output = o; + } + else + { + loc = temp_id - o->id; + + if (strncmp(o->id, id, loc) == 0) + output = o; + } + } + + if (!output) + return NULL; return output; } +static int +_e_eom_set_up_external_output(const char *output_name, int width, int height) +{ + tdm_output *hal_output; + tdm_layer *hal_layer; + tdm_info_layer layer_info; + tdm_error tdm_err = TDM_ERROR_NONE; + E_EomDataPtr eom_data = &g_eom_data; + int ret = 0; + + + hal_output = _e_eom_hal_output_get(output_name); + if (!hal_output) + { + EOM_ERR("ERROR: get hal output for, (%s)\n", output_name); + goto err; + } + + hal_layer = _e_eom_hal_layer_get(hal_output, width, height); + if (!hal_layer) + { + EOM_ERR("ERROR: get hal layer\n"); + goto err; + } + + ret = _e_eom_create_output_buffers(eom_data, width, height); + if (!ret ) + { + EOM_ERR("ERROR: create buffers \n"); + goto err; + } + + tdm_err = tdm_layer_get_info(hal_layer, &layer_info); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_ERR ("ERROR: get layer info: %d", tdm_err); + goto err; + } + + EOM_DBG("LAYER INFO: %dx%d, pos (x:%d, y:%d, w:%d, h:%d, dpos (x:%d, y:%d, w:%d, h:%d))", + layer_info.src_config.size.h, layer_info.src_config.size.v, + layer_info.src_config.pos.x, layer_info.src_config.pos.y, + layer_info.src_config.pos.w, layer_info.src_config.pos.h, + layer_info.dst_pos.x, layer_info.dst_pos.y, + layer_info.dst_pos.w, layer_info.dst_pos.h); + + g_eom->dst_mode.w = width; + g_eom->dst_mode.h = height; + /* TODO: free that memory */ + g_eom->ext_output_name = strdup(output_name); + + eom_data->layer = hal_layer; + eom_data->output = hal_output; + eom_data->current_buffer = 0; + + tdm_err = tdm_layer_set_buffer(hal_layer, eom_data->dst_buffers[eom_data->current_buffer]); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: set buffer on layer:%d\n", tdm_err); + goto err; + } + + /* TODO: it is commented because we do not have HDMI events + * temprary commit moved to pp section + */ + tdm_err = tdm_output_commit(hal_output, 0, _e_eom_output_commit_cb, eom_data); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: commit crtc:%d\n", tdm_err); + goto err; + } + + + return 1; + +err: +/* + * TODO: add deinitialization + */ + return 0; +} + +static void +_e_eom_deinit_external_output() +{ + tdm_error err = TDM_ERROR_NONE; + int i = 0; + + if (g_eom_data.layer) + { + err = tdm_layer_unset_buffer(g_eom_data.layer); + if (err != TDM_ERROR_NONE) + EOM_DBG("EXT OUTPUT DEINIT: fail unset buffer:%d\n", err); + else + EOM_DBG("EXT OUTPUT DEINIT: ok unset buffer:%d\n", err); + + err = tdm_output_commit(g_eom_data.output, 0, NULL, &g_eom_data); + if (err != TDM_ERROR_NONE) + EOM_DBG ("EXT OUTPUT DEINIT: fail commit:%d\n", err); + else + EOM_DBG("EXT OUTPUT DEINIT: ok commit:%d\n", err); + + for (i = 0; i < NUM_MAIN_BUF; i++) + { + tdm_buffer_remove_release_handler(g_eom_data.dst_buffers[i], + _e_eom_pp_cb, &g_eom_data); + if (g_eom_data.dst_buffers[i]) + tbm_surface_destroy(g_eom_data.dst_buffers[i]); + } + } +} + static tdm_output * _e_eom_hal_output_get(const char *id) { Ecore_Drm_Device *dev; - Ecore_Drm_Output *drm_output, *o; + Ecore_Drm_Output *drm_output = NULL, *o; tdm_output *output; - tdm_output_mode *modes; - tdm_output_mode *big_mode; + const tdm_output_mode *modes; + const tdm_output_mode *big_mode; tdm_error err = TDM_ERROR_NONE; - Eina_List *l, *ll; + const Eina_List *l, *ll; int crtc_id = 0; int count = 0; /* - * Temporary take into account only HDMI + * TODO: Temporary take into account only HDMI */ - EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) { EINA_LIST_FOREACH(dev->external_outputs, ll, o) { - if ((ecore_drm_output_name_get(o)) && (!strcmp(id, ecore_drm_output_name_get(o)))) + if ((ecore_drm_output_name_get(o)) && (strcmp(id, ecore_drm_output_name_get(o)) == 0)) drm_output = o; } } if (!drm_output) { - EOM_DBG("ERROR: drm output was not found\n"); + EOM_ERR("ERROR: drm output was not found\n"); return NULL; } crtc_id = ecore_drm_output_crtc_id_get(drm_output); if (crtc_id == 0) { - EOM_DBG("ERROR: crtc is 0\n"); + EOM_ERR("ERROR: crtc is 0\n"); return NULL; } output = tdm_display_get_output(g_eom->dpy, crtc_id, NULL); if (!output) { - EOM_DBG("ERROR: there is no HAL output for:%d\n", crtc_id); + EOM_ERR("ERROR: there is no HAL output for:%d\n", crtc_id); return NULL; } @@ -139,7 +423,7 @@ _e_eom_hal_output_get(const char *id) err = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, &preferred_align); if (err != TDM_ERROR_NONE) { - EOM_DBG("ERROR: Gent get geometry for hal output"); + EOM_ERR("ERROR: Gent get geometry for hal output"); return NULL; } @@ -152,7 +436,7 @@ _e_eom_hal_output_get(const char *id) err = tdm_output_get_available_modes(output, &modes, &count); if (err != TDM_ERROR_NONE) { - EOM_DBG("Get availvable modes filed\n"); + EOM_ERR("Get availvable modes filed\n"); return NULL; } @@ -167,7 +451,7 @@ _e_eom_hal_output_get(const char *id) if (!big_mode) { - EOM_DBG("no Big mode\n"); + EOM_ERR("no Big mode\n"); return NULL; } @@ -176,7 +460,7 @@ _e_eom_hal_output_get(const char *id) err = tdm_output_set_mode(output, big_mode); if (err != TDM_ERROR_NONE) { - EOM_DBG("set Mode failed\n"); + EOM_ERR("set Mode failed\n"); return NULL; } @@ -189,10 +473,10 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) { int i = 0; int count = 0; - tdm_layer *layer; + tdm_layer *layer = NULL; tdm_error err = TDM_ERROR_NONE; tdm_layer_capability capa; - tdm_info_layer set_layer_info; + tdm_info_layer layer_info; err = tdm_output_get_layer_count(output, &count); @@ -225,140 +509,32 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) } } - memset(&set_layer_info, 0x0, sizeof(tdm_info_layer)); - set_layer_info.src_config.size.h = width; - set_layer_info.src_config.size.v = height; - set_layer_info.src_config.pos.x = 0; - set_layer_info.src_config.pos.y = 0; - set_layer_info.src_config.pos.w = width; - set_layer_info.src_config.pos.h = height; - set_layer_info.src_config.format = TBM_FORMAT_ARGB8888; - set_layer_info.dst_pos.x = 0; - set_layer_info.dst_pos.y = 0; - set_layer_info.dst_pos.w = width; - set_layer_info.dst_pos.h = height; - set_layer_info.transform = TDM_TRANSFORM_NORMAL; - - err = tdm_layer_set_info(layer, &set_layer_info); - if (err != TDM_ERROR_NONE) - { - EOM_DBG ("tdm_layer_set_info fail(%d)\n", err); - return NULL; - } - - return layer; -} - -static tbm_surface_h -_e_eom_root_window_tdm_surface_get() -{ - Evas_Engine_Info_Drm *einfo; - Ecore_Drm_Fb* fb; - - if (!e_comp) - { - EOM_DBG("e_comp NULL\n"); - return NULL; - } - - if (!e_comp->evas) - { - EOM_DBG("e_comp->evas NULL"); - return NULL; - } - - einfo = (Evas_Engine_Info_Drm *)evas_engine_info_get(e_comp->evas); - - /* - fb = _ecore_drm_display_fb_find_with_id(einfo->info.buffer_id); - if (!fb) - { - EOM_DBG("no Ecore_Drm_Fb for dci_output_id:%d\n", einfo->info.buffer_id); - return NULL; - } - - if (!fb->hal_buffer) - { - EOM_DBG("no hal_buffer\n"); - return NULL; - } - - EOM_DBG("find hal_buffer"); - */ - return fb->hal_buffer; -} - -static void -_e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, - unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, - void *user_data) -{ - Eom_Data *eom_data; - tbm_surface_h src_buffer; - tdm_error err = TDM_ERROR_NONE; - - EOM_DBG("Event 1\n"); - - if (!user_data) - { - EOM_ERR("ERROR: EVENT: user_data is NULL\n"); - return; - } - - eom_data = (Eom_Data *)user_data; - - EOM_DBG("Event 2\n"); - -/* - src_buffer = _e_eom_root_window_tdm_surface_get(); - if (!src_buffer ) - { - EOM_ERR("Event: tdm_buffer is NULL\n"); - return; - } -*/ - - if (eom_data->current_buffer == 1) - { - eom_data->current_buffer = 0; - - err = tdm_layer_set_buffer(eom_data->layer, - eom_data->dst_buffers[eom_data->current_buffer]); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: EVENT: set buffer 0\n"); - return; - } - - EOM_DBG("Event 3\n"); - } - else - { - eom_data->current_buffer = 1; - - err = tdm_layer_set_buffer(eom_data->layer, - eom_data->dst_buffers[eom_data->current_buffer]); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: EVENT: set buffer 1\n"); - return; - } - - EOM_DBG("Event 4\n"); - } - - err = tdm_output_commit(eom_data->output, 0, _e_eom_output_commit_cb, eom_data); + memset(&layer_info, 0x0, sizeof(tdm_info_layer)); + layer_info.src_config.size.h = width; + layer_info.src_config.size.v = height; + layer_info.src_config.pos.x = 0; + layer_info.src_config.pos.y = 0; + layer_info.src_config.pos.w = width; + layer_info.src_config.pos.h = height; + layer_info.src_config.format = TBM_FORMAT_ARGB8888; + layer_info.dst_pos.x = 0; + layer_info.dst_pos.y = 0; + layer_info.dst_pos.w = width; + layer_info.dst_pos.h = height; + layer_info.transform = TDM_TRANSFORM_NORMAL; + + err = tdm_layer_set_info(layer, &layer_info); if (err != TDM_ERROR_NONE) { - EOM_ERR("ERROR: EVENT: commit\n"); - return; + EOM_DBG ("tdm_layer_set_info fail(%d)\n", err); + return NULL; } - EOM_DBG("Event 5\n"); + return layer; } static int -_e_eom_create_output_buffers(Eom_Data *eom_data, int width, int height) +_e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height) { tbm_surface_h buffer; tbm_surface_info_s buffer_info; @@ -376,6 +552,7 @@ _e_eom_create_output_buffers(Eom_Data *eom_data, int width, int height) /* * TODO: temp code for testing, actual convert will be in _e_eom_put_src_to_dst() */ + /* memset(&buffer_info, 0x0, sizeof(tbm_surface_info_s)); if (tbm_surface_map(buffer, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, @@ -387,6 +564,7 @@ _e_eom_create_output_buffers(Eom_Data *eom_data, int width, int height) memset(buffer_info.planes[0].ptr, 0xff, buffer_info.planes[0].size); tbm_surface_unmap(buffer); + */ eom_data->dst_buffers[0] = buffer; @@ -401,8 +579,10 @@ _e_eom_create_output_buffers(Eom_Data *eom_data, int width, int height) } /* + /* * TODO: temp code for testing, actual convert will be in _e_eom_put_src_to_dst() */ + /* memset(&buffer_info, 0x00, sizeof(tbm_surface_info_s)); if (tbm_surface_map(buffer, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, @@ -414,7 +594,7 @@ _e_eom_create_output_buffers(Eom_Data *eom_data, int width, int height) memset(buffer_info.planes[0].ptr, 0x55, buffer_info.planes[0].size); tbm_surface_unmap(buffer); - + */ eom_data->dst_buffers[1] = buffer; return 1; @@ -427,116 +607,198 @@ err: return 0; } -static void -_e_eom_put_src_to_dst( tbm_surface_h src_buffer, tbm_surface_h dst_buffer) +static enum wl_eom_type +_e_eom_output_name_to_eom_type(const char *output_name) { + enum wl_eom_type eom_type; + /* TODO: Add other external outputs */ + if (strcmp(output_name, "HDMI-A-0") == 0) + eom_type = WL_EOM_TYPE_HDMIA; + else + eom_type = WL_EOM_TYPE_NONE; - + return eom_type; } static int -_e_eom_set_up_external_output(const char *output_name, int width, int height) +_e_eom_root_internal_surface_get(const char *output_name, int width, int height) { - tdm_output *hal_output; - tdm_layer *hal_layer; - tdm_info_layer layer_info; - tdm_error tdm_err = TDM_ERROR_NONE; - Eom_Data *eom_data = &g_eom_data; + tbm_surface_h src_buffer; + tbm_surface_info_s src_buffer_info; int ret = 0; + src_buffer = _e_eom_root_internal_tdm_surface_get(output_name); + if (!src_buffer ) + { + EOM_ERR("ERROR: get root tdm surfcae\n"); + return 0; + } + + tbm_surface_get_info(src_buffer, &src_buffer_info ); - hal_output = _e_eom_hal_output_get(output_name); - if (!hal_output) + EOM_DBG("FRAMEBUFFER TDM: %dx%d bpp:%d size:%d", + src_buffer_info.width, + src_buffer_info.height, + src_buffer_info.bpp, + src_buffer_info.size); + + g_eom->src_mode.w = width; + g_eom->src_mode.h = height; + /* TODO: free that memory */ + g_eom->int_output_name = strdup(output_name); + + EOM_DBG("INT SURFACE: 1\n"); + + ret = _e_eom_pp_src_to_dst(src_buffer); + if (!ret ) { - EOM_ERR("ERROR: get hal output for, (%s)\n", output_name); - goto err; + EOM_ERR("ERROR: init pp\n"); + return 0; } - hal_layer = _e_eom_hal_layer_get(hal_output, width, height); - if (!hal_layer) + EOM_DBG("INT SURFACE: 2\n"); + + g_eom->is_internal_grab = 1; + + return 1; +} + +static tbm_surface_h +_e_eom_root_internal_tdm_surface_get(const char *name) +{ + Ecore_Drm_Output *primary_output = NULL; + Ecore_Drm_Device *dev; + const Eina_List *l; + Ecore_Drm_Fb *fb; + + EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) { - EOM_ERR("ERROR: get hal layer\n"); - goto err; + primary_output = ecore_drm_device_output_name_find(dev, name); } - ret = _e_eom_create_output_buffers(eom_data, width, height); - if (!ret ) + if (!primary_output) { - EOM_ERR("ERROR: create buffers \n"); - goto err; + EOM_ERR("ERROR: get primary output\n"); + return NULL; } + /* I think it is more convenient than one upon, but E took first + * output as primary and it can be not internal output + * + primary_output = ecore_drm_output_primary_get(); + if (!primary_output) + { + EOM_ERR("ERROR: get primary output\n"); + return NULL; + } + */ -/* - src_buffer = _e_eom_root_window_tdm_surface_get(); - if (!src_buffer ) - { - EOM_ERR("no framebuffer\n"); - goto end; - } -*/ + fb = ecore_drm_display_output_primary_layer_fb_get(primary_output); + if (!primary_output) + { + EOM_ERR("ERROR: get primary frambuffer\n"); + return NULL; + } -/* - tbm_surface_get_info(src_buffer, &src_buffer_info ); + EOM_DBG("FRAMEBUFFER ECORE_DRM: is_client:%d mode%dx%d\n", fb->from_client, fb->w, fb->h); - EOM_DBG("FRAMEBUFFER buffer: %dx%d bpp:%d size:%d", - src_buffer_info.width, - src_buffer_info.height, - src_buffer_info.bpp, - src_buffer_info.size); + return (tbm_surface_h)fb->hal_buffer; +} - _e_eom_put_src_to_dst(src_buffer, dst_buffer); -*/ +static int +_e_eom_pp_src_to_dst( tbm_surface_h src_buffer) +{ + tdm_pp *pp; + tdm_info_pp pp_info; + tdm_error err = TDM_ERROR_NONE; + EOM_DBG("PP: 1\n"); - tdm_err = tdm_layer_get_info(hal_layer, &layer_info); - if (tdm_err != TDM_ERROR_NONE) + pp = tdm_display_create_pp(g_eom->dpy, &err); + if (err != TDM_ERROR_NONE) { - EOM_ERR ("ERROR: get layer info: %d", tdm_err); - goto err; + EOM_ERR("ERROR: create pp:%d\n", err); + return 0; } - EOM_DBG("LAYER INFO: %dx%d, pos (x:%d, y:%d, w:%d, h:%d, dpos (x:%d, y:%d, w:%d, h:%d))", - layer_info.src_config.size.h, layer_info.src_config.size.v, - layer_info.src_config.pos.x, layer_info.src_config.pos.y, - layer_info.src_config.pos.w, layer_info.src_config.pos.h, - layer_info.dst_pos.x, layer_info.dst_pos.y, - layer_info.dst_pos.w, layer_info.dst_pos.h); + EOM_DBG("PP: 2\n"); + + g_eom_data.pp = pp; + + pp_info.src_config.size.h = g_eom->src_mode.w; /*1440*/ + pp_info.src_config.size.v = g_eom->src_mode.h; /*2560*/ + pp_info.src_config.pos.x = 0; + pp_info.src_config.pos.y = 0; + pp_info.src_config.pos.w = g_eom->src_mode.w; /*1440*/ + pp_info.src_config.pos.h = g_eom->src_mode.h; /*2560*/ + pp_info.src_config.format = TBM_FORMAT_ARGB8888; + pp_info.dst_config.size.h = g_eom->dst_mode.w; /*1960*/ + pp_info.dst_config.size.v = g_eom->dst_mode.h; /*1080*/ + pp_info.dst_config.pos.x = 0; + pp_info.dst_config.pos.y = 0; + pp_info.dst_config.pos.w = g_eom->dst_mode.w; /*1960*/ + pp_info.dst_config.pos.h = g_eom->dst_mode.h; /*1080*/ + pp_info.dst_config.format = TBM_FORMAT_ARGB8888; + pp_info.transform = TDM_TRANSFORM_NORMAL;/*TDM_TRANSFORM_NORMAL*/ + pp_info.sync = 0; + pp_info.flags = 0; + + EOM_DBG("PP: 3\n"); + + err = tdm_pp_set_info(pp, &pp_info); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: set pp info:%d\n", err); + return 0; + } - eom_data->layer = hal_layer; - eom_data->output = hal_output; - eom_data->current_buffer = 0; + EOM_DBG("PP: 4\n"); - tdm_err = tdm_layer_set_buffer(hal_layer, eom_data->dst_buffers[eom_data->current_buffer]); - if (tdm_err != TDM_ERROR_NONE) + g_eom_data.pp_buffer = !g_eom_data.current_buffer; + EOM_DBG("PP: curr:%d pp:%d\n", g_eom_data.current_buffer, g_eom_data.pp_buffer); + + err = tdm_buffer_add_release_handler(g_eom_data.dst_buffers[g_eom_data.pp_buffer], + _e_eom_pp_cb, &g_eom_data); + if (err != TDM_ERROR_NONE) { - EOM_ERR("ERROR: set buffer on layer:%d\n", tdm_err); - goto err; + EOM_ERR ("ERROR: set pp hadler:%d\n", err); + return 0; } - tdm_err = tdm_output_commit(hal_output, 0, _e_eom_output_commit_cb, eom_data); - if (tdm_err != TDM_ERROR_NONE) + EOM_DBG("PP: 5\n"); + + err = tdm_pp_attach(pp, src_buffer, g_eom_data.dst_buffers[g_eom_data.pp_buffer]); + if (err != TDM_ERROR_NONE) { - EOM_ERR("ERROR: commit crtc:%d\n", tdm_err); - goto err; + EOM_ERR("ERROR: pp attach:%d\n", err); + return 0; } - return 1; -err: -/* - * TODO: add deinitialization - */ - return 0; + EOM_DBG("PP: 6\n"); + + err = tdm_pp_commit(g_eom_data.pp); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: pp commit:%d\n", err); + return 0; + } + + EOM_DBG("PP: OK\n", err); + + return 1; } +static int flag = 0; + static Eina_Bool _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { Ecore_Drm_Event_Output *e; E_EomPtr eom = data; E_Comp_Wl_Output *wl_output; + const Eina_List *l; struct wl_resource *output_resource; enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; char buff[PATH_MAX]; @@ -551,63 +813,75 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e snprintf(buff, sizeof(buff), "%s", e->name); - if (strcmp(e->name, "HDMI-A-0")) - { - EOM_DBG("Skip internal output\n"); - goto end; - } - - /* - * Get e_comp_wl_output - */ -/* - wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); - if (!wl_output) + if (strcmp(e->name, "HDMI-A-0") == 0) { - EOM_ERR("no e_comp_wl_outputs. (%s)\n", buff); - goto end; - } -*/ - - /* - * Initialize external output - */ - ret = _e_eom_set_up_external_output(buff, e->w, e->h); - if (!ret) - { - EOM_ERR("Failed initialize external output\n"); - goto end; - } - - - /* Get main frame buffer */ - - - - - /* - EINA_LIST_FOREACH(wl_output->resources, l2, output_resource) - { - if (e->plug) + if (e->plug == 1) { - - wl_eom_send_output_type(eom->resource, - output_resource, - eom_type, - WL_EOM_STATUS_CONNECTION); + /* Get e_comp_wl_output */ + wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); + if (!wl_output) + { + EOM_ERR("ERROR: there is no wl_output:(%s)\n", buff); + goto end; + } + + /* Initialize external output */ + ret = _e_eom_set_up_external_output(buff, e->w, e->h); + if (!ret) + { + EOM_ERR("ERROR: initialize external output\n"); + goto end; + } + + g_eom->is_external_init = 1; } else { - EOM_DBG("7\n"); - - wl_eom_send_output_type(eom->resource, - output_resource, - eom_type, - WL_EOM_STATUS_DISCONNECTION); + _e_eom_deinit_external_output(); + g_eom->is_external_init = 0; + g_eom->is_internal_grab = 0; } + + eom_type = _e_eom_output_name_to_eom_type(buff); + if (eom_type == WL_EOM_TYPE_NONE) + { + EOM_ERR("ERROR: eom_type is NONE\n"); + goto end; + } + + EINA_LIST_FOREACH(wl_output->resources, l, output_resource) + { + if (e->plug) + { + EOM_DBG("e->plug:%d\n", e->plug); + + wl_eom_send_output_type(eom->resource, + output_resource, + eom_type, + WL_EOM_STATUS_CONNECTION); + } + else + { + EOM_DBG("e->plug:%d\n", e->plug); + + wl_eom_send_output_type(eom->resource, + output_resource, + eom_type, + WL_EOM_STATUS_DISCONNECTION); + } + } + } + else if (strcmp(e->name, "DSI-0") == 0 && g_eom->is_external_init && flag == 2) + { + ret = _e_eom_root_internal_surface_get(buff, e->w, e->h); + if (!ret) + { + EOM_ERR("ERROR: get root surfcae\n"); + goto end; + } } - */ + ++flag; end: @@ -615,6 +889,7 @@ end: } + void _e_eom_set_output(Ecore_Drm_Output * drm_output, tbm_surface_h surface) { @@ -626,7 +901,7 @@ _e_eom_get_drm_output_for_client(E_Client *ec) { Ecore_Drm_Output *drm_output; Ecore_Drm_Device *dev; - Eina_List *l; + const Eina_List *l; /* TODO: get real output, now we just return HDMI */ EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) @@ -638,6 +913,7 @@ _e_eom_get_drm_output_for_client(E_Client *ec) return NULL; } +/* static tbm_surface_h _e_eom_get_tbm_surface_for_client(E_Client *ec) { @@ -690,6 +966,7 @@ _e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) evas_event_callback_add(ec->frame, EVAS_CALLBACK_RENDER_POST, _e_eom_canvas_render_post, ec); } +*/ static Eina_Bool _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) { @@ -717,6 +994,8 @@ end: return ECORE_CALLBACK_PASS_ON; } + + /* wl_eom_set_keygrab request handler */ static void _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output, uint32_t attribute) @@ -802,8 +1081,6 @@ _e_eom_init_internal() { tdm_error err = TDM_ERROR_NONE; - EOM_DBG("1\n"); - g_eom->dpy = tdm_display_init(&err); if (err != TDM_ERROR_NONE) { @@ -811,8 +1088,6 @@ _e_eom_init_internal() goto err; } - EOM_DBG("2\n"); - err = tdm_display_get_fd(g_eom->dpy, &g_eom->fd); if (err != TDM_ERROR_NONE) { @@ -820,8 +1095,6 @@ _e_eom_init_internal() goto err; } - EOM_DBG("3\n"); - g_eom->bufmgr = tbm_bufmgr_init(g_eom->fd); if (!g_eom->bufmgr) { @@ -829,8 +1102,6 @@ _e_eom_init_internal() goto err; } - EOM_DBG("4\n"); - return 1; err: return 0; @@ -863,8 +1134,12 @@ _e_eom_init() E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom); E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_OUTPUT, _e_eom_ecore_drm_output_cb, g_eom); - +/* fullscreen_pre_hook = e_client_hook_add(E_CLIENT_HOOK_FULLSCREEN_PRE, _e_eom_fullscreen_pre_cb_hook, NULL); +*/ + + g_eom->is_external_init = 0; + g_eom->is_internal_grab = 0; return EINA_TRUE; -- 2.7.4 From 9ea26c6e594978db1d33abf9b66b3a59f3719c31 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Thu, 31 Mar 2016 12:45:48 +0300 Subject: [PATCH 03/16] remove flickering on external output durning Miror Mode Change-Id: I3cfbc3bf7b7666456f11fd14e2483dab43532f0e Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 0444a4e..58d1cd5 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -144,6 +144,7 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) } g_eom_data.pp_buffer = !g_eom_data.current_buffer; + EOM_DBG("ERROR: PP EVENT: pp:%d curr:%d\n", g_eom_data.pp_buffer, g_eom_data.current_buffer); tdm_err = tdm_buffer_add_release_handler(g_eom_data.dst_buffers[g_eom_data.pp_buffer], _e_eom_pp_cb, &g_eom_data); @@ -190,12 +191,14 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI EOM_DBG("Event 2\n"); + EOM_DBG("EVENT: pp:%d curr:%d\n", eom_data->pp_buffer, eom_data->current_buffer); + if (eom_data->current_buffer == 1) { eom_data->current_buffer = 0; err = tdm_layer_set_buffer(eom_data->layer, - eom_data->dst_buffers[eom_data->current_buffer]); + eom_data->dst_buffers[!eom_data->pp_buffer]); if (err != TDM_ERROR_NONE) { EOM_ERR("ERROR: EVENT: set buffer 0\n"); @@ -209,7 +212,7 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI eom_data->current_buffer = 1; err = tdm_layer_set_buffer(eom_data->layer, - eom_data->dst_buffers[eom_data->current_buffer]); + eom_data->dst_buffers[!eom_data->pp_buffer]); if (err != TDM_ERROR_NONE) { EOM_ERR("ERROR: EVENT: set buffer 1\n"); @@ -552,7 +555,7 @@ _e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height) /* * TODO: temp code for testing, actual convert will be in _e_eom_put_src_to_dst() */ - /* + memset(&buffer_info, 0x0, sizeof(tbm_surface_info_s)); if (tbm_surface_map(buffer, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, @@ -562,9 +565,9 @@ _e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height) goto err; } - memset(buffer_info.planes[0].ptr, 0xff, buffer_info.planes[0].size); + memset(buffer_info.planes[0].ptr, 0xFF, buffer_info.planes[0].size); tbm_surface_unmap(buffer); - */ + eom_data->dst_buffers[0] = buffer; @@ -579,10 +582,8 @@ _e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height) } /* - /* * TODO: temp code for testing, actual convert will be in _e_eom_put_src_to_dst() */ - /* memset(&buffer_info, 0x00, sizeof(tbm_surface_info_s)); if (tbm_surface_map(buffer, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, @@ -592,9 +593,9 @@ _e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height) goto err; } - memset(buffer_info.planes[0].ptr, 0x55, buffer_info.planes[0].size); + memset(buffer_info.planes[0].ptr, 0xFF, buffer_info.planes[0].size); tbm_surface_unmap(buffer); - */ + eom_data->dst_buffers[1] = buffer; return 1; -- 2.7.4 From 3b8e610f76c5a3ad948c0f6e6a84a572bc4cef72 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Tue, 5 Apr 2016 15:50:41 +0300 Subject: [PATCH 04/16] emmit events durning a client is binding to sever Change-Id: If00d72fbdbc6873b0ceca024193820aecc1d1908 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 148 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 98 insertions(+), 50 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 58d1cd5..4b160ed 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -43,18 +43,20 @@ struct _E_Eom struct wl_resource *resource; Eina_List *handlers; - int is_external_init; - int is_internal_grab; - tdm_display *dpy; tbm_bufmgr bufmgr; int fd; + /* external output data */ + char *ext_output_name; + int is_external_init; E_EomOutMode src_mode; - E_EomOutMode dst_mode; + E_Comp_Wl_Output *wl_output; - char *ext_output_name; + /* internal output data */ + int is_internal_grab; char *int_output_name; + E_EomOutMode dst_mode; }; struct _E_Eom_Data @@ -70,52 +72,27 @@ struct _E_Eom_Data }; static E_EomData g_eom_data; - E_EomPtr g_eom = NULL; - -E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; - static E_Client_Hook *fullscreen_pre_hook = NULL; +E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; - +/* handle external output */ +static E_Comp_Wl_Output *_e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id); +static int _e_eom_set_up_external_output(const char *output_name, int width, int height); +static tdm_output * _e_eom_hal_output_get(const char *id); +static tdm_layer * _e_eom_hal_layer_get(tdm_output *output, int width, int height); +static int _e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height); +static enum wl_eom_type _e_eom_output_name_to_eom_type(const char *output_name); +/* handle internal output, pp */ +static int _e_eom_root_internal_surface_get(const char *output_name, int width, int height); +static tbm_surface_h _e_eom_root_internal_tdm_surface_get(const char *name); +static int _e_eom_pp_src_to_dst( tbm_surface_h src_buffer); /* tdm handlers */ -static void -_e_eom_pp_cb(tbm_surface_h surface, void *user_data); -static void -_e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, +static void _e_eom_pp_cb(tbm_surface_h surface, void *user_data); +static void _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *user_data); -/* handle external output */ -static E_Comp_Wl_Output * -_e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id); - -static int -_e_eom_set_up_external_output(const char *output_name, int width, int height); - -static tdm_output * -_e_eom_hal_output_get(const char *id); - -static tdm_layer * -_e_eom_hal_layer_get(tdm_output *output, int width, int height); - -static int -_e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height); - -static enum wl_eom_type -_e_eom_output_name_to_eom_type(const char *output_name); - -/* handle internal output, pp */ -static int -_e_eom_root_internal_surface_get(const char *output_name, int width, int height); - -static tbm_surface_h -_e_eom_root_internal_tdm_surface_get(const char *name); - -static int -_e_eom_pp_src_to_dst( tbm_surface_h src_buffer); - - static void _e_eom_pp_cb(tbm_surface_h surface, void *user_data) { @@ -375,6 +352,9 @@ _e_eom_deinit_external_output() tbm_surface_destroy(g_eom_data.dst_buffers[i]); } } + + if (g_eom->wl_output) + g_eom->wl_output = NULL; } static tdm_output * @@ -786,7 +766,7 @@ _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) return 0; } - EOM_DBG("PP: OK\n", err); + EOM_DBG("PP: OK\n"); return 1; } @@ -850,6 +830,9 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e goto end; } + g_eom->wl_output = wl_output; + + /* EINA_LIST_FOREACH(wl_output->resources, l, output_resource) { if (e->plug) @@ -871,6 +854,8 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e WL_EOM_STATUS_DISCONNECTION); } } + */ + } else if (strcmp(e->name, "DSI-0") == 0 && g_eom->is_external_init && flag == 2) { @@ -914,10 +899,11 @@ _e_eom_get_drm_output_for_client(E_Client *ec) return NULL; } -/* + static tbm_surface_h _e_eom_get_tbm_surface_for_client(E_Client *ec) { + /* E_Pixmap *pixmap = ec->pixmap; E_Comp_Wl_Buffer *buffer = e_pixmap_resource_get(pixmap); tbm_surface_h tsurface = NULL; @@ -928,6 +914,7 @@ _e_eom_get_tbm_surface_for_client(E_Client *ec) tsurface = wayland_tbm_server_get_surface(wl_comp_data->tbm.server, buffer->resource); return tsurface; + */ } static void @@ -951,12 +938,32 @@ _e_eom_canvas_render_post(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *eve static void _e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) { + + /* + const Eina_List *l; + E_Comp_Wl_Output *ext_output = NULL; + int loc = 0; + Ecore_Drm_Output * drm_output; tbm_surface_h surface; EINA_SAFETY_ON_NULL_RETURN(ec != NULL); EINA_SAFETY_ON_NULL_RETURN(ec->frame != NULL); + + if (g_eom->is_external_init == 0 && + (ext_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, g_eom->ext_output_name)) == NULL) + { + EINA_LIST_FOREACH(ext_output->clients, l, o) + { + + } + } + + + + + drm_output = _e_eom_get_drm_output_for_client(ec); EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); @@ -965,9 +972,11 @@ _e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) _e_eom_set_output(drm_output, surface); evas_event_callback_add(ec->frame, EVAS_CALLBACK_RENDER_POST, _e_eom_canvas_render_post, ec); + + */ } -*/ + static Eina_Bool _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) { @@ -996,7 +1005,6 @@ end: } - /* wl_eom_set_keygrab request handler */ static void _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output, uint32_t attribute) @@ -1050,6 +1058,48 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 eom->resource = resource; + if (g_eom->is_external_init && g_eom->is_internal_grab) + { + E_Comp_Wl_Output *wl_output = NULL; + struct wl_resource *output_resource; + const Eina_List *l; + enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; + + EOM_DBG("send info of external output\n"); + + wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, g_eom->ext_output_name); + if (!wl_output) + { + EOM_DBG("failed to get wl_output\n"); + return; + } + + eom_type = _e_eom_output_name_to_eom_type(g_eom->ext_output_name); + if (eom_type == WL_EOM_TYPE_NONE) + { + EOM_DBG("create wl_eom global resource.\n"); + return; + } + + EINA_LIST_FOREACH(wl_output->resources, l, output_resource) + { + wl_eom_send_output_type(eom->resource, + output_resource, + eom_type, + WL_EOM_STATUS_CONNECTION); + + wl_eom_send_output_attribute(eom->resource, + output_resource, + WL_EOM_ATTRIBUTE_NORMAL, + WL_EOM_ATTRIBUTE_STATE_ACTIVE, + WL_EOM_ERROR_NONE); + + wl_eom_send_output_mode(eom->resource, + output_resource, + WL_EOM_MODE_MIRROR); + } + } + EOM_DBG("create wl_eom global resource.\n"); } @@ -1135,9 +1185,7 @@ _e_eom_init() E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom); E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_OUTPUT, _e_eom_ecore_drm_output_cb, g_eom); -/* fullscreen_pre_hook = e_client_hook_add(E_CLIENT_HOOK_FULLSCREEN_PRE, _e_eom_fullscreen_pre_cb_hook, NULL); -*/ g_eom->is_external_init = 0; g_eom->is_internal_grab = 0; -- 2.7.4 From 1b914cac6b57d6c176b4c2129403141cd2ef7b1d Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Tue, 5 Apr 2016 19:36:36 +0300 Subject: [PATCH 05/16] sketch of handling eom's attributes Change-Id: Id3bc6df5acebc51f7857a8e0aea03c5ff12a4f45 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 255 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 158 insertions(+), 97 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 4b160ed..3c3e15c 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -14,18 +14,7 @@ #include #define NUM_MAIN_BUF 2 -#define NUM_PP_BUF 3 - -/* - * TODO: remove "flag" - * TODO: add correct PP conversion of src to dst - * TODO !!!: remove flickering - * TODO : deinitialization, free memory - * TODO !!!: change mechanism of PP and output to external output - * TODO !!!: remove magic numbers on return and set current buffer and pp buffer - * TODO : remove EOM_DBG("1\n") etc. - */ - +#define NUM_ATTR 3 typedef struct _E_Eom E_Eom, *E_EomPtr; typedef struct _E_Eom_Out_Mode E_EomOutMode, *E_EomOutModePtr; @@ -47,6 +36,11 @@ struct _E_Eom tbm_bufmgr bufmgr; int fd; + enum wl_eom_mode eom_mode; + enum wl_eom_attribute eom_attribute; + enum wl_eom_attribute_state eom_attribute_state; + enum wl_eom_status eom_status; + /* external output data */ char *ext_output_name; int is_external_init; @@ -66,7 +60,6 @@ struct _E_Eom_Data tdm_pp *pp; tbm_surface_h dst_buffers[NUM_MAIN_BUF]; - tbm_surface_h pp_buffers[NUM_PP_BUF]; int current_buffer; int pp_buffer; }; @@ -75,6 +68,12 @@ static E_EomData g_eom_data; E_EomPtr g_eom = NULL; static E_Client_Hook *fullscreen_pre_hook = NULL; E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; +static int eom_output_attributes[NUM_ATTR][NUM_ATTR] = + { + {1, 1, 1}, + {0, 1, 1}, + {0, 0, 0}, + }; /* handle external output */ static E_Comp_Wl_Output *_e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id); @@ -93,6 +92,66 @@ static void _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *user_data); +static inline enum wl_eom_mode +_e_eom_get_eom_mode() +{ + return g_eom->eom_mode; +} + +static inline void +_e_eom_set_eom_mode(enum wl_eom_mode mode) +{ + g_eom->eom_mode = mode; +} + +static inline enum wl_eom_attribute_state +_e_eom_get_eom_attribute_state() +{ + return g_eom->eom_attribute_state; +} + +static inline void +_e_eom_set_eom_attribute_state(enum wl_eom_attribute_state attribute_state) +{ + g_eom->eom_attribute_state = attribute_state; +} + +static inline enum wl_eom_attribute +_e_eom_get_eom_attribute() +{ + return g_eom->eom_attribute; +} + +static inline int +_e_eom_set_eom_attribute(enum wl_eom_attribute attribute) +{ + if (attribute == WL_EOM_ATTRIBUTE_NONE) + { + g_eom->eom_attribute = attribute; + return 1; + } + + if (eom_output_attributes[g_eom->eom_attribute - 1][attribute - 1] == 1) + { + g_eom->eom_attribute = attribute; + return 1; + } + + return 0; +} + +static inline enum wl_eom_status +_e_eom_get_eom_status() +{ + return g_eom->eom_status; +} + +static inline void +_e_eom_set_eom_status(enum wl_eom_status status) +{ + g_eom->eom_status = status; +} + static void _e_eom_pp_cb(tbm_surface_h surface, void *user_data) { @@ -159,10 +218,10 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI EOM_DBG("Event 1\n"); if (!user_data) - { - EOM_ERR("ERROR: EVENT: user_data is NULL\n"); - return; - } + { + EOM_ERR("ERROR: EVENT: user_data is NULL\n"); + return; + } eom_data = (E_EomDataPtr)user_data; @@ -336,7 +395,7 @@ _e_eom_deinit_external_output() if (err != TDM_ERROR_NONE) EOM_DBG("EXT OUTPUT DEINIT: fail unset buffer:%d\n", err); else - EOM_DBG("EXT OUTPUT DEINIT: ok unset buffer:%d\n", err); + EOM_DBG("EXT OUTPUT DEINIT: ok unset buffer:%d\n", err); err = tdm_output_commit(g_eom_data.output, 0, NULL, &g_eom_data); if (err != TDM_ERROR_NONE) @@ -350,7 +409,7 @@ _e_eom_deinit_external_output() _e_eom_pp_cb, &g_eom_data); if (g_eom_data.dst_buffers[i]) tbm_surface_destroy(g_eom_data.dst_buffers[i]); - } + } } if (g_eom->wl_output) @@ -432,6 +491,7 @@ _e_eom_hal_output_get(const char *id) big_mode = &modes[i]; } + /*TODO: fix it*/ if (!big_mode) { EOM_ERR("no Big mode\n"); @@ -478,18 +538,18 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) return NULL; } - err = tdm_layer_get_capabilities(layer, &capa); - if (err != TDM_ERROR_NONE) - { - EOM_DBG ("tdm_layer_get_capabilities fail(%d)\n", err); - return NULL; - } - - if (capa & TDM_LAYER_CAPABILITY_PRIMARY) - { - EOM_DBG("TDM_LAYER_CAPABILITY_PRIMARY layer found : %d\n", i); - break; - } + err = tdm_layer_get_capabilities(layer, &capa); + if (err != TDM_ERROR_NONE) + { + EOM_DBG ("tdm_layer_get_capabilities fail(%d)\n", err); + return NULL; + } + + if (capa & TDM_LAYER_CAPABILITY_PRIMARY) + { + EOM_DBG("TDM_LAYER_CAPABILITY_PRIMARY layer found : %d\n", i); + break; + } } memset(&layer_info, 0x0, sizeof(tdm_info_layer)); @@ -548,7 +608,6 @@ _e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height) memset(buffer_info.planes[0].ptr, 0xFF, buffer_info.planes[0].size); tbm_surface_unmap(buffer); - eom_data->dst_buffers[0] = buffer; /* @@ -682,7 +741,7 @@ _e_eom_root_internal_tdm_surface_get(const char *name) return NULL; } - EOM_DBG("FRAMEBUFFER ECORE_DRM: is_client:%d mode%dx%d\n", fb->from_client, fb->w, fb->h); + //EOM_DBG("FRAMEBUFFER ECORE_DRM: is_client:%d mode%dx%d\n", fb->from_client, fb->w, fb->h); return (tbm_surface_h)fb->hal_buffer; } @@ -815,12 +874,23 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e } g_eom->is_external_init = 1; + + _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_ACTIVE); + _e_eom_set_eom_status(WL_EOM_STATUS_CONNECTION); + _e_eom_set_eom_attribute(WL_EOM_ATTRIBUTE_NONE); + _e_eom_set_eom_mode(WL_EOM_MODE_MIRROR); } else { - _e_eom_deinit_external_output(); g_eom->is_external_init = 0; g_eom->is_internal_grab = 0; + + _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_INACTIVE); + _e_eom_set_eom_status(WL_EOM_STATUS_DISCONNECTION); + _e_eom_set_eom_attribute(WL_EOM_ATTRIBUTE_NONE); + _e_eom_set_eom_mode(WL_EOM_MODE_NONE); + + _e_eom_deinit_external_output(); } eom_type = _e_eom_output_name_to_eom_type(buff); @@ -835,27 +905,25 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e /* EINA_LIST_FOREACH(wl_output->resources, l, output_resource) { - if (e->plug) - { - EOM_DBG("e->plug:%d\n", e->plug); - wl_eom_send_output_type(eom->resource, - output_resource, - eom_type, - WL_EOM_STATUS_CONNECTION); - } - else - { - EOM_DBG("e->plug:%d\n", e->plug); - - wl_eom_send_output_type(eom->resource, + EOM_DBG("e->plug:%d\n", e->plug); + + wl_eom_send_output_type(eom->resource, + output_resource, + eom_type, + _e_eom_get_eom_status()); + + wl_eom_send_output_attribute(eom->resource, output_resource, - eom_type, - WL_EOM_STATUS_DISCONNECTION); - } - } - */ + _e_eom_get_eom_attribute(), + _e_eom_get_eom_attribute_state(), + WL_EOM_ERROR_NONE); + wl_eom_send_output_mode(eom->resource, + output_resource, + _e_eom_get_eom_mode()); + } + */ } else if (strcmp(e->name, "DSI-0") == 0 && g_eom->is_external_init && flag == 2) { @@ -869,13 +937,11 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e ++flag; - end: return ECORE_CALLBACK_PASS_ON; } - void _e_eom_set_output(Ecore_Drm_Output * drm_output, tbm_surface_h surface) { @@ -896,6 +962,7 @@ _e_eom_get_drm_output_for_client(E_Client *ec) if (drm_output) return drm_output; } + return NULL; } @@ -938,7 +1005,6 @@ _e_eom_canvas_render_post(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *eve static void _e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) { - /* const Eina_List *l; E_Comp_Wl_Output *ext_output = NULL; @@ -956,14 +1022,10 @@ _e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) { EINA_LIST_FOREACH(ext_output->clients, l, o) { - + ; } } - - - - drm_output = _e_eom_get_drm_output_for_client(ec); EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); @@ -972,7 +1034,6 @@ _e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) _e_eom_set_output(drm_output, surface); evas_event_callback_add(ec->frame, EVAS_CALLBACK_RENDER_POST, _e_eom_canvas_render_post, ec); - */ } @@ -1037,8 +1098,12 @@ _e_eom_wl_resource_destory_cb(struct wl_resource *resource) static void _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id) { - E_EomPtr eom = data; + enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; + struct wl_resource *output_resource; + E_Comp_Wl_Output *wl_output = NULL; struct wl_resource *resource; + E_EomPtr eom = data; + const Eina_List *l; resource = wl_resource_create(client, &wl_eom_interface, @@ -1058,46 +1123,37 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 eom->resource = resource; - if (g_eom->is_external_init && g_eom->is_internal_grab) + wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, g_eom->ext_output_name); + if (!wl_output) { - E_Comp_Wl_Output *wl_output = NULL; - struct wl_resource *output_resource; - const Eina_List *l; - enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; - - EOM_DBG("send info of external output\n"); - - wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, g_eom->ext_output_name); - if (!wl_output) - { - EOM_DBG("failed to get wl_output\n"); - return; - } + EOM_DBG("failed to get wl_output\n"); + return; + } - eom_type = _e_eom_output_name_to_eom_type(g_eom->ext_output_name); - if (eom_type == WL_EOM_TYPE_NONE) - { - EOM_DBG("create wl_eom global resource.\n"); - return; - } + eom_type = _e_eom_output_name_to_eom_type(g_eom->ext_output_name); + if (eom_type == WL_EOM_TYPE_NONE) + { + EOM_DBG("create wl_eom global resource.\n"); + return; + } - EINA_LIST_FOREACH(wl_output->resources, l, output_resource) - { - wl_eom_send_output_type(eom->resource, - output_resource, - eom_type, - WL_EOM_STATUS_CONNECTION); + EINA_LIST_FOREACH(wl_output->resources, l, output_resource) + { + wl_eom_send_output_type(eom->resource, + output_resource, + eom_type, + _e_eom_get_eom_status()); - wl_eom_send_output_attribute(eom->resource, - output_resource, - WL_EOM_ATTRIBUTE_NORMAL, - WL_EOM_ATTRIBUTE_STATE_ACTIVE, - WL_EOM_ERROR_NONE); - wl_eom_send_output_mode(eom->resource, + wl_eom_send_output_attribute(eom->resource, output_resource, - WL_EOM_MODE_MIRROR); - } + _e_eom_get_eom_attribute(), + _e_eom_get_eom_attribute_state(), + WL_EOM_ERROR_NONE); + + wl_eom_send_output_mode(eom->resource, + output_resource, + _e_eom_get_eom_mode()); } EOM_DBG("create wl_eom global resource.\n"); @@ -1165,7 +1221,6 @@ _e_eom_init() EINA_SAFETY_ON_NULL_GOTO(e_comp_wl, err); - g_eom = E_NEW(E_Eom, 1); EINA_SAFETY_ON_NULL_RETURN_VAL(g_eom, EINA_FALSE); @@ -1174,6 +1229,7 @@ _e_eom_init() 1, g_eom, _e_eom_wl_bind_cb); + EINA_SAFETY_ON_NULL_GOTO(g_eom->global, err); ret = _e_eom_init_internal(); @@ -1190,6 +1246,11 @@ _e_eom_init() g_eom->is_external_init = 0; g_eom->is_internal_grab = 0; + _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_NONE); + _e_eom_set_eom_attribute(WL_EOM_ATTRIBUTE_NONE); + _e_eom_set_eom_status(WL_EOM_STATUS_NONE); + _e_eom_set_eom_mode(WL_EOM_MODE_NONE); + return EINA_TRUE; err: -- 2.7.4 From db74c2e37d6cc5f8ff61c7c214a706647e84131d Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Fri, 8 Apr 2016 19:26:08 +0300 Subject: [PATCH 06/16] send output id intead of wl_output. add handling of user requests Change-Id: I7a490a70a7e1e88b2867f3968be35ed0a810742a Signed-off-by: Roman Peresipkyn --- protocol/eom-client-protocol.h | 24 +++++++---- protocol/eom-protocol.c | 16 ++------ protocol/eom-server-protocol.h | 16 ++++---- protocol/eom.xml | 8 ++-- src/e_mod_main.c | 90 ++++++++++++++++++++++-------------------- 5 files changed, 80 insertions(+), 74 deletions(-) diff --git a/protocol/eom-client-protocol.h b/protocol/eom-client-protocol.h index 9f91c45..8b295fe 100644 --- a/protocol/eom-client-protocol.h +++ b/protocol/eom-client-protocol.h @@ -154,34 +154,34 @@ enum wl_eom_attribute_state { struct wl_eom_listener { /** * output_type - (none) - * @output: (none) + * @output_id: (none) * @type: (none) * @status: (none) */ void (*output_type)(void *data, struct wl_eom *wl_eom, - struct wl_output *output, + uint32_t output_id, uint32_t type, uint32_t status); /** * output_mode - (none) - * @output: (none) + * @output_id: (none) * @mode: (none) */ void (*output_mode)(void *data, struct wl_eom *wl_eom, - struct wl_output *output, + uint32_t output_id, uint32_t mode); /** * output_attribute - (none) - * @output: (none) + * @output_id: (none) * @attribute: (none) * @attribute_state: (none) * @error: (none) */ void (*output_attribute)(void *data, struct wl_eom *wl_eom, - struct wl_output *output, + uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error); @@ -197,6 +197,8 @@ wl_eom_add_listener(struct wl_eom *wl_eom, #define WL_EOM_SET_ATTRIBUTE 0 +#define WL_EOM_SET_ATTRIBUTE_SINCE_VERSION 1 + static inline void wl_eom_set_user_data(struct wl_eom *wl_eom, void *user_data) { @@ -209,6 +211,12 @@ wl_eom_get_user_data(struct wl_eom *wl_eom) return wl_proxy_get_user_data((struct wl_proxy *) wl_eom); } +static inline uint32_t +wl_eom_get_version(struct wl_eom *wl_eom) +{ + return wl_proxy_get_version((struct wl_proxy *) wl_eom); +} + static inline void wl_eom_destroy(struct wl_eom *wl_eom) { @@ -216,10 +224,10 @@ wl_eom_destroy(struct wl_eom *wl_eom) } static inline void -wl_eom_set_attribute(struct wl_eom *wl_eom, struct wl_output *output, uint32_t attribute) +wl_eom_set_attribute(struct wl_eom *wl_eom, uint32_t output_id, uint32_t attribute) { wl_proxy_marshal((struct wl_proxy *) wl_eom, - WL_EOM_SET_ATTRIBUTE, output, attribute); + WL_EOM_SET_ATTRIBUTE, output_id, attribute); } #ifdef __cplusplus diff --git a/protocol/eom-protocol.c b/protocol/eom-protocol.c index fc7ccc7..265c780 100644 --- a/protocol/eom-protocol.c +++ b/protocol/eom-protocol.c @@ -2,30 +2,22 @@ #include #include "wayland-util.h" -extern const struct wl_interface wl_output_interface; static const struct wl_interface *types[] = { - &wl_output_interface, NULL, - &wl_output_interface, - NULL, - NULL, - &wl_output_interface, - NULL, - &wl_output_interface, NULL, NULL, NULL, }; static const struct wl_message wl_eom_requests[] = { - { "set_attribute", "ou", types + 0 }, + { "set_attribute", "uu", types + 0 }, }; static const struct wl_message wl_eom_events[] = { - { "output_type", "ouu", types + 2 }, - { "output_mode", "ou", types + 5 }, - { "output_attribute", "ouuu", types + 7 }, + { "output_type", "uuu", types + 0 }, + { "output_mode", "uu", types + 0 }, + { "output_attribute", "uuuu", types + 0 }, }; WL_EXPORT const struct wl_interface wl_eom_interface = { diff --git a/protocol/eom-server-protocol.h b/protocol/eom-server-protocol.h index 18801cb..1fa8d74 100644 --- a/protocol/eom-server-protocol.h +++ b/protocol/eom-server-protocol.h @@ -152,12 +152,12 @@ enum wl_eom_attribute_state { struct wl_eom_interface { /** * set_attribute - (none) - * @output: (none) + * @output_id: (none) * @attribute: (none) */ void (*set_attribute)(struct wl_client *client, struct wl_resource *resource, - struct wl_resource *output, + uint32_t output_id, uint32_t attribute); }; @@ -170,21 +170,21 @@ struct wl_eom_interface { #define WL_EOM_OUTPUT_ATTRIBUTE_SINCE_VERSION 1 static inline void -wl_eom_send_output_type(struct wl_resource *resource_, struct wl_resource *output, uint32_t type, uint32_t status) +wl_eom_send_output_type(struct wl_resource *resource_, uint32_t output_id, uint32_t type, uint32_t status) { - wl_resource_post_event(resource_, WL_EOM_OUTPUT_TYPE, output, type, status); + wl_resource_post_event(resource_, WL_EOM_OUTPUT_TYPE, output_id, type, status); } static inline void -wl_eom_send_output_mode(struct wl_resource *resource_, struct wl_resource *output, uint32_t mode) +wl_eom_send_output_mode(struct wl_resource *resource_, uint32_t output_id, uint32_t mode) { - wl_resource_post_event(resource_, WL_EOM_OUTPUT_MODE, output, mode); + wl_resource_post_event(resource_, WL_EOM_OUTPUT_MODE, output_id, mode); } static inline void -wl_eom_send_output_attribute(struct wl_resource *resource_, struct wl_resource *output, uint32_t attribute, uint32_t attribute_state, uint32_t error) +wl_eom_send_output_attribute(struct wl_resource *resource_, uint32_t output_id, uint32_t attribute, uint32_t attribute_state, uint32_t error) { - wl_resource_post_event(resource_, WL_EOM_OUTPUT_ATTRIBUTE, output, attribute, attribute_state, error); + wl_resource_post_event(resource_, WL_EOM_OUTPUT_ATTRIBUTE, output_id, attribute, attribute_state, error); } #ifdef __cplusplus diff --git a/protocol/eom.xml b/protocol/eom.xml index 94d5ce6..b84cf7c 100644 --- a/protocol/eom.xml +++ b/protocol/eom.xml @@ -73,23 +73,23 @@ - + - + - + - + diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 3c3e15c..bbf0fce 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -36,6 +36,7 @@ struct _E_Eom tbm_bufmgr bufmgr; int fd; + /* eom state */ enum wl_eom_mode eom_mode; enum wl_eom_attribute eom_attribute; enum wl_eom_attribute_state eom_attribute_state; @@ -44,12 +45,13 @@ struct _E_Eom /* external output data */ char *ext_output_name; int is_external_init; + int id; E_EomOutMode src_mode; E_Comp_Wl_Output *wl_output; /* internal output data */ - int is_internal_grab; char *int_output_name; + int is_internal_grab; E_EomOutMode dst_mode; }; @@ -125,7 +127,7 @@ _e_eom_get_eom_attribute() static inline int _e_eom_set_eom_attribute(enum wl_eom_attribute attribute) { - if (attribute == WL_EOM_ATTRIBUTE_NONE) + if (attribute == WL_EOM_ATTRIBUTE_NONE || g_eom->eom_attribute == WL_EOM_ATTRIBUTE_NONE) { g_eom->eom_attribute = attribute; return 1; @@ -158,8 +160,6 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) E_EomDataPtr eom_data = NULL; tdm_error tdm_err = TDM_ERROR_NONE; - EOM_DBG("PP EVENT: get\n"); - if (!user_data) { EOM_DBG("ERROR: PP EVENT: user data is NULL\n"); @@ -180,7 +180,6 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) } g_eom_data.pp_buffer = !g_eom_data.current_buffer; - EOM_DBG("ERROR: PP EVENT: pp:%d curr:%d\n", g_eom_data.pp_buffer, g_eom_data.current_buffer); tdm_err = tdm_buffer_add_release_handler(g_eom_data.dst_buffers[g_eom_data.pp_buffer], _e_eom_pp_cb, &g_eom_data); @@ -203,8 +202,6 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) EOM_DBG ("ERROR: PP EVENT: pp commit:%d\n", tdm_err ); return; } - - EOM_DBG ("PP EVENT: ok\n"); } static void @@ -215,8 +212,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI E_EomDataPtr eom_data; tdm_error err = TDM_ERROR_NONE; - EOM_DBG("Event 1\n"); - if (!user_data) { EOM_ERR("ERROR: EVENT: user_data is NULL\n"); @@ -225,10 +220,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI eom_data = (E_EomDataPtr)user_data; - EOM_DBG("Event 2\n"); - - EOM_DBG("EVENT: pp:%d curr:%d\n", eom_data->pp_buffer, eom_data->current_buffer); - if (eom_data->current_buffer == 1) { eom_data->current_buffer = 0; @@ -240,8 +231,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI EOM_ERR("ERROR: EVENT: set buffer 0\n"); return; } - - EOM_DBG("Event 3\n"); } else { @@ -254,8 +243,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI EOM_ERR("ERROR: EVENT: set buffer 1\n"); return; } - - EOM_DBG("Event 4\n"); } err = tdm_output_commit(eom_data->output, 0, _e_eom_output_commit_cb, eom_data); @@ -264,8 +251,6 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI EOM_ERR("ERROR: EVENT: commit\n"); return; } - - EOM_DBG("Event 5\n"); } static E_Comp_Wl_Output * @@ -874,6 +859,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e } g_eom->is_external_init = 1; + g_eom->id = e->id; _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_ACTIVE); _e_eom_set_eom_status(WL_EOM_STATUS_CONNECTION); @@ -884,6 +870,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e { g_eom->is_external_init = 0; g_eom->is_internal_grab = 0; + g_eom->id = -1; _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_INACTIVE); _e_eom_set_eom_status(WL_EOM_STATUS_DISCONNECTION); @@ -1068,18 +1055,41 @@ end: /* wl_eom_set_keygrab request handler */ static void -_e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output, uint32_t attribute) +_e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, uint32_t output_id, uint32_t attribute) { + int ret = 0; + /* (void) client; (void) attribute; + */ + + EOM_DBG("attribute:%d +++ output:%d\n", attribute, output_id); + + /* + * TODO: check output_id + */ + ret = _e_eom_set_eom_attribute(attribute); + if (ret == 0) + { + EOM_DBG("set attribute FAILED\n"); - EOM_DBG("attribute:%d\n", attribute); + wl_eom_send_output_attribute(resource, + g_eom->id, + _e_eom_get_eom_attribute(), + _e_eom_get_eom_attribute_state(), + WL_EOM_ERROR_OUTPUT_OCCUPIED); + } + else + { + EOM_DBG("set attribute OK\n"); + + wl_eom_send_output_attribute(resource, + g_eom->id, + _e_eom_get_eom_attribute(), + _e_eom_get_eom_attribute_state(), + WL_EOM_ERROR_NONE); + } - wl_eom_send_output_attribute(resource, - output, - attribute, - WL_EOM_ATTRIBUTE_STATE_ACTIVE, - WL_EOM_ERROR_NONE); } static const struct wl_eom_interface _e_eom_wl_implementation = @@ -1137,24 +1147,20 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 return; } - EINA_LIST_FOREACH(wl_output->resources, l, output_resource) - { - wl_eom_send_output_type(eom->resource, - output_resource, - eom_type, - _e_eom_get_eom_status()); - + wl_eom_send_output_type(eom->resource, + eom->id, + eom_type, + _e_eom_get_eom_status()); - wl_eom_send_output_attribute(eom->resource, - output_resource, - _e_eom_get_eom_attribute(), - _e_eom_get_eom_attribute_state(), - WL_EOM_ERROR_NONE); + wl_eom_send_output_attribute(eom->resource, + eom->id, + _e_eom_get_eom_attribute(), + _e_eom_get_eom_attribute_state(), + WL_EOM_ERROR_NONE); - wl_eom_send_output_mode(eom->resource, - output_resource, - _e_eom_get_eom_mode()); - } + wl_eom_send_output_mode(eom->resource, + eom->id, + _e_eom_get_eom_mode()); EOM_DBG("create wl_eom global resource.\n"); } -- 2.7.4 From fe79c37b55fc8f8600b26996226e92c17adb0940 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 15 Apr 2016 12:48:11 +0900 Subject: [PATCH 07/16] fix build error Change-Id: I12d11bfd64616ee641e6ae96e5f0e758f86f26fb Signed-off-by: Junkyeong Kim --- src/e_mod_main.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index bbf0fce..8fc7773 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -419,7 +419,8 @@ _e_eom_hal_output_get(const char *id) */ EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) { - EINA_LIST_FOREACH(dev->external_outputs, ll, o) +/* EINA_LIST_FOREACH(dev->external_outputs, ll, o)*/ + EINA_LIST_FOREACH(dev->outputs, ll, o) { if ((ecore_drm_output_name_get(o)) && (strcmp(id, ecore_drm_output_name_get(o)) == 0)) drm_output = o; @@ -821,10 +822,10 @@ static Eina_Bool _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { Ecore_Drm_Event_Output *e; - E_EomPtr eom = data; +/* E_EomPtr eom = data;*/ E_Comp_Wl_Output *wl_output; - const Eina_List *l; - struct wl_resource *output_resource; +/* const Eina_List *l;*/ +/* struct wl_resource *output_resource;*/ enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; char buff[PATH_MAX]; int ret = 0; @@ -934,7 +935,7 @@ _e_eom_set_output(Ecore_Drm_Output * drm_output, tbm_surface_h surface) { /* TODO: chack save and commit*/ } - +#if 0 static Ecore_Drm_Output * _e_eom_get_drm_output_for_client(E_Client *ec) { @@ -953,7 +954,6 @@ _e_eom_get_drm_output_for_client(E_Client *ec) return NULL; } - static tbm_surface_h _e_eom_get_tbm_surface_for_client(E_Client *ec) { @@ -988,7 +988,7 @@ _e_eom_canvas_render_post(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *eve _e_eom_set_output(drm_output, surface); } - +#endif static void _e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) { @@ -1109,11 +1109,9 @@ static void _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id) { enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; - struct wl_resource *output_resource; E_Comp_Wl_Output *wl_output = NULL; struct wl_resource *resource; E_EomPtr eom = data; - const Eina_List *l; resource = wl_resource_create(client, &wl_eom_interface, -- 2.7.4 From ba4a831972b6fcf44c34923c77a86ea9bfd0b43e Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Fri, 15 Apr 2016 22:40:19 +0900 Subject: [PATCH 08/16] make external outputs list when server init send external outputs count and info to client when binding add wl_eom protocol to send external outputs info Change-Id: I6ae2491b6f5ae867ab5fc89a552f6439b259e816 Signed-off-by: Junkyeong Kim --- configure.ac | 2 +- packaging/e-mod-tizen-eom.spec | 1 + protocol/eom-client-protocol.h | 37 ++++++ protocol/eom-protocol.c | 10 +- protocol/eom-server-protocol.h | 28 ++++- protocol/eom.xml | 19 +++ src/e_mod_main.c | 266 ++++++++++++++++++++++++++++++++++++++--- 7 files changed, 340 insertions(+), 23 deletions(-) diff --git a/configure.ac b/configure.ac index cec8ae1..e46bc02 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ fi PKG_CHECK_MODULES(WAYLAND_SCANNER, wayland-scanner) PKG_CHECK_MODULES(WAYLAND, [wayland-server]) -PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment]) +PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment, eom]) dnl ======================================================================== # checks for wayland only argument diff --git a/packaging/e-mod-tizen-eom.spec b/packaging/e-mod-tizen-eom.spec index 68312d1..02242d1 100644 --- a/packaging/e-mod-tizen-eom.spec +++ b/packaging/e-mod-tizen-eom.spec @@ -10,6 +10,7 @@ Group: Graphics & UI Framework/Other Source0: %{name}-%{version}.tar.gz License: BSD-2-Clause BuildRequires: pkgconfig(enlightenment) +BuildRequires: pkgconfig(eom) BuildRequires: gettext %if %{with x} BuildRequires: pkgconfig(x11) diff --git a/protocol/eom-client-protocol.h b/protocol/eom-client-protocol.h index 8b295fe..d38e84a 100644 --- a/protocol/eom-client-protocol.h +++ b/protocol/eom-client-protocol.h @@ -153,6 +153,35 @@ enum wl_eom_attribute_state { */ struct wl_eom_listener { /** + * output_count - (none) + * @count: (none) + */ + void (*output_count)(void *data, + struct wl_eom *wl_eom, + uint32_t count); + /** + * output_info - (none) + * @output_id: (none) + * @type: (none) + * @mode: (none) + * @w: (none) + * @h: (none) + * @w_mm: (none) + * @h_mm: (none) + * @connection: (none) + */ + void (*output_info)(void *data, + struct wl_eom *wl_eom, + uint32_t output_id, + uint32_t type, + uint32_t mode, + uint32_t w, + uint32_t h, + uint32_t w_mm, + uint32_t h_mm, + uint32_t connection); + + /** * output_type - (none) * @output_id: (none) * @type: (none) @@ -196,6 +225,7 @@ wl_eom_add_listener(struct wl_eom *wl_eom, } #define WL_EOM_SET_ATTRIBUTE 0 +#define WL_EOM_GET_INFO 1 #define WL_EOM_SET_ATTRIBUTE_SINCE_VERSION 1 @@ -230,6 +260,13 @@ wl_eom_set_attribute(struct wl_eom *wl_eom, uint32_t output_id, uint32_t attribu WL_EOM_SET_ATTRIBUTE, output_id, attribute); } +static inline void +wl_eom_get_output_info(struct wl_eom *wl_eom, uint32_t output_id) +{ + wl_proxy_marshal((struct wl_proxy *) wl_eom, + WL_EOM_GET_INFO, output_id); +} + #ifdef __cplusplus } #endif diff --git a/protocol/eom-protocol.c b/protocol/eom-protocol.c index 265c780..ed56ef6 100644 --- a/protocol/eom-protocol.c +++ b/protocol/eom-protocol.c @@ -8,13 +8,19 @@ static const struct wl_interface *types[] = { NULL, NULL, NULL, + NULL, + NULL, + NULL, }; static const struct wl_message wl_eom_requests[] = { { "set_attribute", "uu", types + 0 }, + { "get_output_info", "u", types + 0 }, }; static const struct wl_message wl_eom_events[] = { + { "output_count", "u", types + 0 }, + { "output_info", "uuuuuuuu", types + 0 }, { "output_type", "uuu", types + 0 }, { "output_mode", "uu", types + 0 }, { "output_attribute", "uuuu", types + 0 }, @@ -22,7 +28,7 @@ static const struct wl_message wl_eom_events[] = { WL_EXPORT const struct wl_interface wl_eom_interface = { "wl_eom", 1, - 1, wl_eom_requests, - 3, wl_eom_events, + 2, wl_eom_requests, + 5, wl_eom_events, }; diff --git a/protocol/eom-server-protocol.h b/protocol/eom-server-protocol.h index 1fa8d74..8ee0777 100644 --- a/protocol/eom-server-protocol.h +++ b/protocol/eom-server-protocol.h @@ -159,17 +159,39 @@ struct wl_eom_interface { struct wl_resource *resource, uint32_t output_id, uint32_t attribute); + /** + * get_output_info - (none) + * @output_id: (none) + */ + void (*get_output_info)(struct wl_client *client, + struct wl_resource *resource, + uint32_t output_id); }; -#define WL_EOM_OUTPUT_TYPE 0 -#define WL_EOM_OUTPUT_MODE 1 -#define WL_EOM_OUTPUT_ATTRIBUTE 2 +#define WL_EOM_OUTPUT_COUNT 0 +#define WL_EOM_OUTPUT_INFO 1 +#define WL_EOM_OUTPUT_TYPE 2 +#define WL_EOM_OUTPUT_MODE 3 +#define WL_EOM_OUTPUT_ATTRIBUTE 4 #define WL_EOM_OUTPUT_TYPE_SINCE_VERSION 1 #define WL_EOM_OUTPUT_MODE_SINCE_VERSION 1 #define WL_EOM_OUTPUT_ATTRIBUTE_SINCE_VERSION 1 static inline void +wl_eom_send_output_count(struct wl_resource *resource_, uint32_t output_id, uint32_t count) +{ + wl_resource_post_event(resource_, WL_EOM_OUTPUT_COUNT, output_id, count); +} + +static inline void +wl_eom_send_output_info(struct wl_resource *resource_, uint32_t output_id, uint32_t type, uint32_t mode, + uint32_t w, uint32_t h, uint32_t w_mm, uint32_t h_mm, uint32_t connection) +{ + wl_resource_post_event(resource_, WL_EOM_OUTPUT_INFO, output_id, type, mode, w, h, w_mm, h_mm, connection); +} + +static inline void wl_eom_send_output_type(struct wl_resource *resource_, uint32_t output_id, uint32_t type, uint32_t status) { wl_resource_post_event(resource_, WL_EOM_OUTPUT_TYPE, output_id, type, status); diff --git a/protocol/eom.xml b/protocol/eom.xml index b84cf7c..32fff54 100644 --- a/protocol/eom.xml +++ b/protocol/eom.xml @@ -77,6 +77,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 8fc7773..668598e 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -12,6 +12,7 @@ #include #include +#include #define NUM_MAIN_BUF 2 #define NUM_ATTR 3 @@ -19,6 +20,7 @@ typedef struct _E_Eom E_Eom, *E_EomPtr; typedef struct _E_Eom_Out_Mode E_EomOutMode, *E_EomOutModePtr; typedef struct _E_Eom_Data E_EomData, *E_EomDataPtr; +typedef struct _E_Eom_Output E_EomOutput, *E_EomOutputPtr; struct _E_Eom_Out_Mode { @@ -26,6 +28,33 @@ struct _E_Eom_Out_Mode int h; }; +struct _E_Eom_Output +{ + unsigned int id; + eom_output_type_e type; + eom_output_mode_e mode; + unsigned int w; + unsigned int h; + unsigned int phys_width; + unsigned int phys_height; + + tdm_output_conn_status status; + unsigned int mirror_run; + eom_output_attribute_e attribute; + eom_output_attribute_state_e attribute_state; + + /* external output data */ + char *ext_output_name; + int is_external_init; + E_EomOutMode src_mode; + E_Comp_Wl_Output *wl_output; + + /* internal output data */ + char *int_output_name; + int is_internal_grab; + E_EomOutMode dst_mode; +}; + struct _E_Eom { struct wl_global *global; @@ -36,6 +65,10 @@ struct _E_Eom tbm_bufmgr bufmgr; int fd; + Eina_List *outputs; + unsigned int output_count; + +#if 1 /* eom state */ enum wl_eom_mode eom_mode; enum wl_eom_attribute eom_attribute; @@ -53,6 +86,7 @@ struct _E_Eom char *int_output_name; int is_internal_grab; E_EomOutMode dst_mode; +#endif }; struct _E_Eom_Data @@ -727,7 +761,7 @@ _e_eom_root_internal_tdm_surface_get(const char *name) return NULL; } - //EOM_DBG("FRAMEBUFFER ECORE_DRM: is_client:%d mode%dx%d\n", fb->from_client, fb->w, fb->h); + /*EOM_DBG("FRAMEBUFFER ECORE_DRM: is_client:%d mode%dx%d\n", fb->from_client, fb->w, fb->h);*/ return (tbm_surface_h)fb->hal_buffer; } @@ -1092,9 +1126,34 @@ _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource } +static void +_e_eom_wl_request_get_output_info_cb(struct wl_client *client, struct wl_resource *resource, uint32_t output_id) +{ + EOM_DBG("output:%d\n", output_id); + + if (g_eom->outputs) + { + Eina_List *l; + E_EomOutputPtr output; + + EINA_LIST_FOREACH(g_eom->outputs, l, output) + { + if (output->id == output_id) + { + EOM_DBG("send - id : %d, type : %d, mode : %d, w : %d, h : %d, w_mm : %d, h_mm : %d, conn : %d\n", + output->id, output->type, output->mode, output->w, output->h, + output->phys_width, output->phys_height, output->status); + wl_eom_send_output_info(resource, output->id, output->type, output->mode, output->w, output->h, + output->phys_width, output->phys_height, output->status); + } + } + } +} + static const struct wl_eom_interface _e_eom_wl_implementation = { - _e_eom_wl_request_set_attribute_cb + _e_eom_wl_request_set_attribute_cb, + _e_eom_wl_request_get_output_info_cb }; /* wl_eom global object destroy function */ @@ -1108,8 +1167,8 @@ _e_eom_wl_resource_destory_cb(struct wl_resource *resource) static void _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id) { - enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; - E_Comp_Wl_Output *wl_output = NULL; +/* enum wl_eom_type eom_type = WL_EOM_TYPE_NONE;*/ +/* E_Comp_Wl_Output *wl_output = NULL;*/ struct wl_resource *resource; E_EomPtr eom = data; @@ -1131,6 +1190,7 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 eom->resource = resource; +#if 0 wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, g_eom->ext_output_name); if (!wl_output) { @@ -1159,7 +1219,26 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 wl_eom_send_output_mode(eom->resource, eom->id, _e_eom_get_eom_mode()); +#else + EOM_DBG("send - output count : %d\n", g_eom->output_count); + wl_eom_send_output_count(eom->resource, + g_eom->output_count); + + if (g_eom->outputs) + { + Eina_List *l; + E_EomOutputPtr output; + EINA_LIST_FOREACH(g_eom->outputs, l, output) + { + EOM_DBG("send - id : %d, type : %d, mode : %d, w : %d, h : %d, w_mm : %d, h_mm : %d, conn : %d\n", + output->id, output->type, output->mode, output->w, output->h, + output->phys_width, output->phys_height, output->status); + wl_eom_send_output_info(resource, output->id, output->type, output->mode, output->w, output->h, + output->phys_width, output->phys_height, output->status); + } + } +#endif EOM_DBG("create wl_eom global resource.\n"); } @@ -1182,46 +1261,199 @@ _e_eom_deinit() fullscreen_pre_hook = NULL; } + if (g_eom->dpy) tdm_display_deinit(g_eom->dpy); + if (g_eom->bufmgr) tbm_bufmgr_deinit(g_eom->bufmgr); + if (g_eom->global) wl_global_destroy(g_eom->global); E_FREE(g_eom); } -int +static Eina_Bool +_e_eom_output_info_get(tdm_display *dpy) +{ + int i, count; + tdm_error ret = TDM_ERROR_NONE; + + ret = tdm_display_get_output_count(dpy, &count); + if (ret != TDM_ERROR_NONE) + { + EOM_ERR("tdm_display_get_output_count fail\n"); + return EINA_FALSE; + } + + if (count <= 1) + { + EOM_DBG("output count is 1. device doesn't support external outputs.\n"); + return EINA_FALSE; + } + + g_eom->output_count = count - 1; + EOM_DBG("external output count : %d\n", g_eom->output_count); + + for (i = 0; i < count; i++) + { + tdm_output *output = NULL; + E_EomOutputPtr new_output; + tdm_output_type type; + tdm_output_conn_status status; + unsigned int mmWidth, mmHeight; + const tdm_output_mode *mode; + + output = tdm_display_get_output(dpy, i, &ret); + if (ret != TDM_ERROR_NONE) + { + EOM_ERR("tdm_display_get_output fail(ret:%d)", ret); + goto err; + } + + if (!output) + { + EOM_ERR("tdm_display_get_output fail(no output:%d)", ret); + goto err; + } + + ret = tdm_output_get_output_type(output, &type); + if (ret != TDM_ERROR_NONE) + { + EOM_ERR("tdm_output_get_output_type fail(%d)", ret); + goto err; + } + /* skip main output */ + /* TODO: need more check about main display*/ + if ((type == TDM_OUTPUT_TYPE_DSI) || (type == TDM_OUTPUT_TYPE_LVDS)) + continue; + + new_output = E_NEW(E_EomOutput, 1); + if (!new_output) + { + EOM_ERR("calloc fail"); + goto err; + } + + ret = tdm_output_get_conn_status(output, &status); + if (ret != TDM_ERROR_NONE) + { + EOM_ERR("tdm_output_get_conn_status fail(%d)", ret); + free(new_output); + goto err; + } + new_output->id = i; + new_output->type = type; + new_output->status = status; + new_output->mode = EOM_OUTPUT_MODE_NONE; + + if (status == TDM_OUTPUT_CONN_STATUS_DISCONNECTED) + { + EOM_DBG("create(%d)output, type:%d, status:%d", + new_output->id, new_output->type, new_output->status); + g_eom->outputs = eina_list_append(g_eom->outputs, new_output); + continue; + } + new_output->status = TDM_OUTPUT_CONN_STATUS_CONNECTED; + + ret = tdm_output_get_mode(output, &mode); + if (ret != TDM_ERROR_NONE) + { + EOM_ERR("tdm_output_get_mode fail(%d)", ret); + free(new_output); + goto err; + } + if (mode == NULL) + { + new_output->w = 0; + new_output->h = 0; + } + else + { + new_output->w = mode->hdisplay; + new_output->h = mode->vdisplay; + } + + ret = tdm_output_get_physical_size(output, &mmWidth, &mmHeight); + if (ret != TDM_ERROR_NONE) + { + EOM_ERR("tdm_output_get_conn_status fail(%d)", ret); + free(new_output); + goto err; + } + new_output->phys_width = mmWidth; + new_output->phys_height = mmHeight; + + EOM_DBG("create(%d)output, type:%d, status:%d, w:%d, h:%d, mm_w:%d, mm_h:%d", + new_output->id, new_output->type, new_output->status, + new_output->w, new_output->h, new_output->phys_width, new_output->phys_height); + + g_eom->outputs = eina_list_append(g_eom->outputs, new_output); + } + + return EINA_TRUE; +err: + + if (g_eom->outputs) + { + Eina_List *l; + E_EomOutputPtr output; + + EINA_LIST_FOREACH(g_eom->outputs, l, output) + { + free(output); + } + eina_list_free(g_eom->outputs); + } + + return EINA_FALSE; +} + +static Eina_Bool _e_eom_init_internal() { - tdm_error err = TDM_ERROR_NONE; + tdm_error ret = TDM_ERROR_NONE; - g_eom->dpy = tdm_display_init(&err); - if (err != TDM_ERROR_NONE) + g_eom->dpy = tdm_display_init(&ret); + if (ret != TDM_ERROR_NONE) { - EOM_DBG("failed initialize TDM\n"); + EOM_ERR("tdm_display_init fail\n"); goto err; } - err = tdm_display_get_fd(g_eom->dpy, &g_eom->fd); - if (err != TDM_ERROR_NONE) + ret = tdm_display_get_fd(g_eom->dpy, &g_eom->fd); + if (ret != TDM_ERROR_NONE) { - EOM_DBG("failed get FD\n"); + EOM_ERR("tdm_display_get_fd fail\n"); goto err; } g_eom->bufmgr = tbm_bufmgr_init(g_eom->fd); if (!g_eom->bufmgr) { - EOM_DBG("failed initialize buffer manager\n"); + EOM_ERR("tbm_bufmgr_init fail\n"); goto err; } - return 1; + if (_e_eom_output_info_get(g_eom->dpy) != EINA_TRUE) + { + EOM_ERR("_e_eom_output_info_get fail\n"); + goto err; + } + + return EINA_TRUE; + err: - return 0; + if (g_eom->bufmgr) + tbm_bufmgr_deinit(g_eom->bufmgr); + + if (g_eom->dpy) + tdm_display_deinit(g_eom->dpy); + + return EINA_FALSE; + } static Eina_Bool _e_eom_init() { - int ret = 0; + Eina_Bool ret = 0; EINA_SAFETY_ON_NULL_GOTO(e_comp_wl, err); @@ -1237,7 +1469,7 @@ _e_eom_init() EINA_SAFETY_ON_NULL_GOTO(g_eom->global, err); ret = _e_eom_init_internal(); - if (!ret) + if (ret == EINA_FALSE) { EOM_ERR("failed init_internal()"); goto err; -- 2.7.4 From 2e3bf05801fa77658a73cdb2f637afdaec1a3adb Mon Sep 17 00:00:00 2001 From: SooChan Lim Date: Tue, 3 May 2016 11:02:26 +0900 Subject: [PATCH 09/16] set the null initialize. Change-Id: I0defb6e454c644b5bdeeee40f6d4225e298d7d3d --- src/e_mod_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 668598e..8527b1a 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -857,7 +857,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e { Ecore_Drm_Event_Output *e; /* E_EomPtr eom = data;*/ - E_Comp_Wl_Output *wl_output; + E_Comp_Wl_Output *wl_output = NULL; /* const Eina_List *l;*/ /* struct wl_resource *output_resource;*/ enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; -- 2.7.4 From 4c2b789ca38327ebfe2b16f97d74a9296da7e399 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Thu, 5 May 2016 13:52:45 +0300 Subject: [PATCH 10/16] fix build error: not found Change-Id: Idb74b44ab2a015ade6eb9609f07ad50018091d99 Signed-off-by: Roman Peresipkyn --- configure.ac | 2 +- packaging/e-mod-tizen-eom.spec | 1 + src/e_mod_main.c | 20 +++++++++++--------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index e46bc02..37a7a06 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ fi PKG_CHECK_MODULES(WAYLAND_SCANNER, wayland-scanner) PKG_CHECK_MODULES(WAYLAND, [wayland-server]) -PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment, eom]) +PKG_CHECK_MODULES(ENLIGHTENMENT, [enlightenment, elementary, eom]) dnl ======================================================================== # checks for wayland only argument diff --git a/packaging/e-mod-tizen-eom.spec b/packaging/e-mod-tizen-eom.spec index 02242d1..e0b15fa 100644 --- a/packaging/e-mod-tizen-eom.spec +++ b/packaging/e-mod-tizen-eom.spec @@ -10,6 +10,7 @@ Group: Graphics & UI Framework/Other Source0: %{name}-%{version}.tar.gz License: BSD-2-Clause BuildRequires: pkgconfig(enlightenment) +BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(eom) BuildRequires: gettext %if %{with x} diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 8527b1a..3c216e4 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -1,18 +1,20 @@ #define E_COMP_WL -#include "e.h" -#include "e_mod_main.h" -#include "eom-server-protocol.h" -#include -#include -#include -#include "Ecore_Drm.h" + +#include +#include #include #include #include #include +#include +#include +#include + +#include "e.h" +#include "e_mod_main.h" +#include "eom-server-protocol.h" +#include "Ecore_Drm.h" -#include -#include #define NUM_MAIN_BUF 2 #define NUM_ATTR 3 -- 2.7.4 From 80a4ad85a0a6c80c3e4a0725bab013c37266979e Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Thu, 5 May 2016 13:55:04 +0300 Subject: [PATCH 11/16] remove unused includes Change-Id: I46fec4da5120fa9591a0009988e4782507ea8ced Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 3c216e4..3dc5c24 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -2,13 +2,8 @@ #include #include -#include -#include #include #include -#include -#include -#include #include "e.h" #include "e_mod_main.h" -- 2.7.4 From 873ef9d1c6a0e14aacb25eec209118e85a29ade2 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Thu, 5 May 2016 15:55:27 +0300 Subject: [PATCH 12/16] extended mode on fake bufers. rename eom_data --> eom_event_data Change-Id: I39c373862ea552d519ddc6db7af75c4bd9edd8e9 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 567 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 411 insertions(+), 156 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 3dc5c24..4b851be 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -16,8 +16,11 @@ typedef struct _E_Eom E_Eom, *E_EomPtr; typedef struct _E_Eom_Out_Mode E_EomOutMode, *E_EomOutModePtr; -typedef struct _E_Eom_Data E_EomData, *E_EomDataPtr; +typedef struct _E_Eom_Event_Data E_EomEventData, *E_EomEventDataPtr; typedef struct _E_Eom_Output E_EomOutput, *E_EomOutputPtr; +typedef struct _E_Eom_Fake_Buffers E_EomFakeBuffers, *E_EomFakeBuffersPtr; +typedef struct _E_Eom_Client_Buffer E_EomClientBuffer, *E_EomClientBufferPtr; + struct _E_Eom_Out_Mode { @@ -72,6 +75,9 @@ struct _E_Eom enum wl_eom_attribute_state eom_attribute_state; enum wl_eom_status eom_status; + /*data related to cooperating with clients */ + int is_mirror_mode; + /* external output data */ char *ext_output_name; int is_external_init; @@ -86,20 +92,40 @@ struct _E_Eom #endif }; -struct _E_Eom_Data +struct _E_Eom_Event_Data { - tdm_layer *layer; tdm_output *output; + tdm_layer *layer; tdm_pp *pp; + /* mirror mode data*/ tbm_surface_h dst_buffers[NUM_MAIN_BUF]; int current_buffer; int pp_buffer; + + /* extended mode data */ + Eina_List *client_buffers_list; +}; + +struct _E_Eom_Client_Buffer +{ + E_Comp_Wl_Buffer *wl_buffer; + tbm_surface_h tbm_buffer; + + unsigned long stamp; +}; + +struct _E_Eom_Fake_Buffers +{ + tbm_surface_h fake_buffers[NUM_MAIN_BUF]; + int current_fake_buffer; }; -static E_EomData g_eom_data; + +static E_EomEventData g_eom_event_data; E_EomPtr g_eom = NULL; -static E_Client_Hook *fullscreen_pre_hook = NULL; +E_EomFakeBuffers fake_buffers; + E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; static int eom_output_attributes[NUM_ATTR][NUM_ATTR] = { @@ -113,18 +139,31 @@ static E_Comp_Wl_Output *_e_eom_e_comp_wl_output_get(const Eina_List *outputs, c static int _e_eom_set_up_external_output(const char *output_name, int width, int height); static tdm_output * _e_eom_hal_output_get(const char *id); static tdm_layer * _e_eom_hal_layer_get(tdm_output *output, int width, int height); -static int _e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height); +static int _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height); static enum wl_eom_type _e_eom_output_name_to_eom_type(const char *output_name); /* handle internal output, pp */ -static int _e_eom_root_internal_surface_get(const char *output_name, int width, int height); +static int _e_eom_mirror_start(const char *output_name, int width, int height); static tbm_surface_h _e_eom_root_internal_tdm_surface_get(const char *name); static int _e_eom_pp_src_to_dst( tbm_surface_h src_buffer); /* tdm handlers */ static void _e_eom_pp_cb(tbm_surface_h surface, void *user_data); -static void _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, +static void _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *user_data); +/* clients buffers */ +static E_EomClientBufferPtr _e_eom_create_client_buffer(E_Comp_Wl_Buffer *wl_buffer, tbm_surface_h tbm_buffer); +static void _e_eom_add_client_buffer_to_list(E_EomClientBufferPtr client_buffer); +static void _e_eom_client_buffers_list_free(); +static E_EomClientBufferPtr _e_eom_get_client_buffer_from_list(); + + +/*eom utils functions*/ +static int _e_eom_get_time_in_mseconds(); + + +static void _e_eom_create_fake_buffers(int width, int height); + static inline enum wl_eom_mode _e_eom_get_eom_mode() { @@ -188,7 +227,7 @@ _e_eom_set_eom_status(enum wl_eom_status status) static void _e_eom_pp_cb(tbm_surface_h surface, void *user_data) { - E_EomDataPtr eom_data = NULL; + E_EomEventDataPtr eom_data = NULL; tdm_error tdm_err = TDM_ERROR_NONE; if (!user_data) @@ -197,11 +236,21 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) return; } - eom_data = (E_EomDataPtr)user_data; + eom_data = (E_EomEventDataPtr)user_data; tdm_buffer_remove_release_handler(eom_data->dst_buffers[eom_data->pp_buffer], _e_eom_pp_cb, eom_data); + /* TODO: lock that flag??? */ + /* If a client has committed its buffer stop mirror mode */ + if (g_eom->is_mirror_mode == 0) + { + EOM_DBG("PP STOP\n"); + return; + } + + EOM_DBG("PP\n"); + tbm_surface_h src_buffer; src_buffer = _e_eom_root_internal_tdm_surface_get(g_eom->int_output_name); if (!src_buffer ) @@ -210,24 +259,24 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) return; } - g_eom_data.pp_buffer = !g_eom_data.current_buffer; + g_eom_event_data.pp_buffer = !g_eom_event_data.current_buffer; - tdm_err = tdm_buffer_add_release_handler(g_eom_data.dst_buffers[g_eom_data.pp_buffer], - _e_eom_pp_cb, &g_eom_data); - if (tdm_err != TDM_ERROR_NONE) + tdm_err = tdm_buffer_add_release_handler(g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer], + _e_eom_pp_cb, &g_eom_event_data); + if (tdm_err != TDM_ERROR_NONE) { EOM_DBG ("ERROR: PP EVENT: set pp hadler:%d\n", tdm_err ); return; } - tdm_err = tdm_pp_attach(eom_data->pp, src_buffer, g_eom_data.dst_buffers[g_eom_data.pp_buffer]); + tdm_err = tdm_pp_attach(eom_data->pp, src_buffer, g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer]); if (tdm_err != TDM_ERROR_NONE) { printf ("ERROR: pp attach:%d\n", tdm_err); return; } - tdm_err = tdm_pp_commit(g_eom_data.pp); + tdm_err = tdm_pp_commit(g_eom_event_data.pp); if (tdm_err != TDM_ERROR_NONE) { EOM_DBG ("ERROR: PP EVENT: pp commit:%d\n", tdm_err ); @@ -236,11 +285,12 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) } static void -_e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, +_e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *user_data) { - E_EomDataPtr eom_data; + E_EomEventDataPtr eom_data; + E_EomClientBufferPtr client_buffer; tdm_error err = TDM_ERROR_NONE; if (!user_data) @@ -249,38 +299,66 @@ _e_eom_output_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EI return; } - eom_data = (E_EomDataPtr)user_data; + eom_data = (E_EomEventDataPtr)user_data; - if (eom_data->current_buffer == 1) + /* TODO: Maybe better to separating that callback on to mirror and extended callbacks */ + if (g_eom->is_mirror_mode == 1) { - eom_data->current_buffer = 0; + EOM_ERR("MIRROR MODE\n"); - err = tdm_layer_set_buffer(eom_data->layer, - eom_data->dst_buffers[!eom_data->pp_buffer]); + if (eom_data->current_buffer == 1) + { + eom_data->current_buffer = 0; + + err = tdm_layer_set_buffer(eom_data->layer, + eom_data->dst_buffers[!eom_data->pp_buffer]); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: set buffer 0\n"); + return; + } + } + else + { + eom_data->current_buffer = 1; + + err = tdm_layer_set_buffer(eom_data->layer, + eom_data->dst_buffers[!eom_data->pp_buffer]); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: set buffer 1\n"); + return; + } + } + + err = tdm_output_commit(eom_data->output, 0, _e_eom_commit_cb, eom_data); if (err != TDM_ERROR_NONE) { - EOM_ERR("ERROR: EVENT: set buffer 0\n"); + EOM_ERR("ERROR: EVENT: commit\n"); return; } } else { - eom_data->current_buffer = 1; + EOM_DBG("EXTENDED MODE\n"); - err = tdm_layer_set_buffer(eom_data->layer, - eom_data->dst_buffers[!eom_data->pp_buffer]); + client_buffer = _e_eom_get_client_buffer_from_list(); + + EOM_DBG("EXTENDED MODE: client_buffer %p\n", client_buffer); + + err = tdm_layer_set_buffer(eom_data->layer, client_buffer->tbm_buffer); if (err != TDM_ERROR_NONE) { EOM_ERR("ERROR: EVENT: set buffer 1\n"); return; } - } - err = tdm_output_commit(eom_data->output, 0, _e_eom_output_commit_cb, eom_data); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: EVENT: commit\n"); - return; + err = tdm_output_commit(eom_data->output, 0, _e_eom_commit_cb, eom_data); + if (err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: EVENT: commit\n"); + return; + } } } @@ -324,10 +402,9 @@ _e_eom_set_up_external_output(const char *output_name, int width, int height) tdm_layer *hal_layer; tdm_info_layer layer_info; tdm_error tdm_err = TDM_ERROR_NONE; - E_EomDataPtr eom_data = &g_eom_data; + E_EomEventDataPtr eom_data = &g_eom_event_data; int ret = 0; - hal_output = _e_eom_hal_output_get(output_name); if (!hal_output) { @@ -349,6 +426,9 @@ _e_eom_set_up_external_output(const char *output_name, int width, int height) goto err; } + /* TODO: Models commited clients buffers */ + _e_eom_create_fake_buffers(width, height); + tdm_err = tdm_layer_get_info(hal_layer, &layer_info); if (tdm_err != TDM_ERROR_NONE) { @@ -379,10 +459,14 @@ _e_eom_set_up_external_output(const char *output_name, int width, int height) goto err; } - /* TODO: it is commented because we do not have HDMI events - * temprary commit moved to pp section - */ - tdm_err = tdm_output_commit(hal_output, 0, _e_eom_output_commit_cb, eom_data); + tdm_err = tdm_output_set_dpms(hal_output, TDM_OUTPUT_DPMS_ON); + if (tdm_err != TDM_ERROR_NONE) + { + EOM_ERR("ERROR: failed set DPMS on:%d\n", tdm_err); + goto err; + } + + tdm_err = tdm_output_commit(hal_output, 0, _e_eom_commit_cb, eom_data); if (tdm_err != TDM_ERROR_NONE) { EOM_ERR("ERROR: commit crtc:%d\n", tdm_err); @@ -405,26 +489,31 @@ _e_eom_deinit_external_output() tdm_error err = TDM_ERROR_NONE; int i = 0; - if (g_eom_data.layer) + if (g_eom_event_data.layer) { - err = tdm_layer_unset_buffer(g_eom_data.layer); + err = tdm_layer_unset_buffer(g_eom_event_data.layer); if (err != TDM_ERROR_NONE) EOM_DBG("EXT OUTPUT DEINIT: fail unset buffer:%d\n", err); else EOM_DBG("EXT OUTPUT DEINIT: ok unset buffer:%d\n", err); - err = tdm_output_commit(g_eom_data.output, 0, NULL, &g_eom_data); + err = tdm_output_commit(g_eom_event_data.output, 0, NULL, &g_eom_event_data); if (err != TDM_ERROR_NONE) EOM_DBG ("EXT OUTPUT DEINIT: fail commit:%d\n", err); else EOM_DBG("EXT OUTPUT DEINIT: ok commit:%d\n", err); + /* TODO: do I need to do DPMS off? */ + err = tdm_output_set_dpms(g_eom_event_data.output, TDM_OUTPUT_DPMS_OFF); + if (err != TDM_ERROR_NONE) + EOM_ERR("EXT OUTPUT DEINIT: failed set DPMS off:%d\n", err); + for (i = 0; i < NUM_MAIN_BUF; i++) { - tdm_buffer_remove_release_handler(g_eom_data.dst_buffers[i], - _e_eom_pp_cb, &g_eom_data); - if (g_eom_data.dst_buffers[i]) - tbm_surface_destroy(g_eom_data.dst_buffers[i]); + tdm_buffer_remove_release_handler(g_eom_event_data.dst_buffers[i], + _e_eom_pp_cb, &g_eom_event_data); + if (g_eom_event_data.dst_buffers[i]) + tbm_surface_destroy(g_eom_event_data.dst_buffers[i]); } } @@ -593,8 +682,41 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) return layer; } + +/* TODO: Models commited clients buffers */ +static void +_e_eom_create_fake_buffers(int width, int height) +{ + tbm_surface_h buffer; + tbm_surface_info_s buffer_info; + + buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); + if (!buffer) + { + EOM_DBG("can not create fake_buffer\n"); + goto err; + } + + memset(&buffer_info, 0x0, sizeof(tbm_surface_info_s)); + if (tbm_surface_map(buffer, + TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, + &buffer_info) != TBM_SURFACE_ERROR_NONE) + { + EOM_DBG("can not mmap fake_buffer\n"); + goto err; + } + + memset(buffer_info.planes[0].ptr, 0xFF, buffer_info.planes[0].size); + tbm_surface_unmap(buffer); + + fake_buffers.fake_buffers[0] = buffer; + +err: + return; +} + static int -_e_eom_create_output_buffers(E_EomDataPtr eom_data, int width, int height) +_e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height) { tbm_surface_h buffer; tbm_surface_info_s buffer_info; @@ -679,7 +801,7 @@ _e_eom_output_name_to_eom_type(const char *output_name) } static int -_e_eom_root_internal_surface_get(const char *output_name, int width, int height) +_e_eom_mirror_start(const char *output_name, int width, int height) { tbm_surface_h src_buffer; tbm_surface_info_s src_buffer_info; @@ -716,8 +838,6 @@ _e_eom_root_internal_surface_get(const char *output_name, int width, int height) EOM_DBG("INT SURFACE: 2\n"); - g_eom->is_internal_grab = 1; - return 1; } @@ -781,7 +901,7 @@ _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) EOM_DBG("PP: 2\n"); - g_eom_data.pp = pp; + g_eom_event_data.pp = pp; pp_info.src_config.size.h = g_eom->src_mode.w; /*1440*/ pp_info.src_config.size.v = g_eom->src_mode.h; /*2560*/ @@ -812,11 +932,11 @@ _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) EOM_DBG("PP: 4\n"); - g_eom_data.pp_buffer = !g_eom_data.current_buffer; - EOM_DBG("PP: curr:%d pp:%d\n", g_eom_data.current_buffer, g_eom_data.pp_buffer); + g_eom_event_data.pp_buffer = !g_eom_event_data.current_buffer; + EOM_DBG("PP: curr:%d pp:%d\n", g_eom_event_data.current_buffer, g_eom_event_data.pp_buffer); - err = tdm_buffer_add_release_handler(g_eom_data.dst_buffers[g_eom_data.pp_buffer], - _e_eom_pp_cb, &g_eom_data); + err = tdm_buffer_add_release_handler(g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer], + _e_eom_pp_cb, &g_eom_event_data); if (err != TDM_ERROR_NONE) { EOM_ERR ("ERROR: set pp hadler:%d\n", err); @@ -825,7 +945,7 @@ _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) EOM_DBG("PP: 5\n"); - err = tdm_pp_attach(pp, src_buffer, g_eom_data.dst_buffers[g_eom_data.pp_buffer]); + err = tdm_pp_attach(pp, src_buffer, g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer]); if (err != TDM_ERROR_NONE) { EOM_ERR("ERROR: pp attach:%d\n", err); @@ -835,10 +955,10 @@ _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) EOM_DBG("PP: 6\n"); - err = tdm_pp_commit(g_eom_data.pp); + err = tdm_pp_commit(g_eom_event_data.pp); if (err != TDM_ERROR_NONE) { - EOM_ERR("ERROR: pp commit:%d\n", err); + EOM_ERR("ERROR: pp commit:%d\n", err); return 0; } @@ -853,10 +973,12 @@ static Eina_Bool _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { Ecore_Drm_Event_Output *e; -/* E_EomPtr eom = data;*/ + /* + E_EomPtr eom = data; + const Eina_List *l; + struct wl_resource *output_resource; + */ E_Comp_Wl_Output *wl_output = NULL; -/* const Eina_List *l;*/ -/* struct wl_resource *output_resource;*/ enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; char buff[PATH_MAX]; int ret = 0; @@ -946,12 +1068,16 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e } else if (strcmp(e->name, "DSI-0") == 0 && g_eom->is_external_init && flag == 2) { - ret = _e_eom_root_internal_surface_get(buff, e->w, e->h); + /*TODO: add support of internal and external output of same size */ + ret = _e_eom_mirror_start(buff, e->w, e->h); if (!ret) { EOM_ERR("ERROR: get root surfcae\n"); goto end; } + + g_eom->is_internal_grab = 1; + g_eom->is_mirror_mode = 1; } ++flag; @@ -960,151 +1086,230 @@ end: return ECORE_CALLBACK_PASS_ON; } - -void -_e_eom_set_output(Ecore_Drm_Output * drm_output, tbm_surface_h surface) -{ - /* TODO: chack save and commit*/ -} -#if 0 -static Ecore_Drm_Output * -_e_eom_get_drm_output_for_client(E_Client *ec) +static Eina_Bool +_e_eom_client_buffer_change(void *data, int type, void *event) { - Ecore_Drm_Output *drm_output; - Ecore_Drm_Device *dev; - const Eina_List *l; + E_Client *ec; + E_Event_Client *ev = event; + E_Comp_Wl_Buffer *external_wl_buffer; + E_EomClientBufferPtr client_buffer; + /* + tbm_surface_h external_tbm_buffer; + tbm_surface_info_s surface_info; + int ret; + */ - /* TODO: get real output, now we just return HDMI */ - EINA_LIST_FOREACH(ecore_drm_devices_get(), l, dev) + EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON); + EINA_SAFETY_ON_NULL_RETURN_VAL(ev->ec, ECORE_CALLBACK_PASS_ON); + + ec = ev->ec; + if (e_object_is_del(E_OBJECT(ec))) { - drm_output = ecore_drm_device_output_name_find(dev, "HDMI-A-0"); - if (drm_output) - return drm_output; + EOM_ERR("ERROR: BUFF CHANGE: ec objects is del\n"); + return ECORE_CALLBACK_PASS_ON; } - return NULL; -} + /* TODO: Remove all 1, 0 etc. Write my own enume or use + * Eina_Troo etc. + * + * TODO: Make all goto same, not err, end, ret etc. + */ + /*We are not interested in non external clients*/ + if (e_client_is_external_output_client(ec) != EINA_TRUE) + { + EOM_ERR("ERROR: BUFF CHANGE: ec is not external\n"); + return ECORE_CALLBACK_PASS_ON; + } -static tbm_surface_h -_e_eom_get_tbm_surface_for_client(E_Client *ec) -{ - /* - E_Pixmap *pixmap = ec->pixmap; - E_Comp_Wl_Buffer *buffer = e_pixmap_resource_get(pixmap); - tbm_surface_h tsurface = NULL; - E_Comp_Wl_Data *wl_comp_data = (E_Comp_Wl_Data *) e_comp->wl_comp_data; + if (ec->pixmap == NULL) + return ECORE_CALLBACK_PASS_ON; + + external_wl_buffer = e_pixmap_resource_get(ec->pixmap); + if (external_wl_buffer == NULL) + { + EOM_ERR("ERROR:BUFF CHANGE: wl buffer is NULL\n"); + return ECORE_CALLBACK_PASS_ON; + } + + EOM_DBG("BUFF CHANGE: wl_buff:%dx%d", + external_wl_buffer->w, + external_wl_buffer->h); + + if (external_wl_buffer->w == 1 && external_wl_buffer->h == 1) + { + EOM_ERR("ERROR:BUFF CHANGE: skip first 1x1 client buffer\n"); + return ECORE_CALLBACK_PASS_ON; + } - EINA_SAFETY_ON_NULL_RETURN_VAL(buffer != NULL, NULL); + /*TODO: wayland_tbm_server_get_surface is implicit declarated */ + /*external_tbm_buffer = wayland_tbm_server_get_surface(NULL, + external_wl_buffer->resource); + if (external_tbm_buffer == NULL) + { + EOM_ERR("ERROR: BUFF CHANGE: client tbm buffer is NULL\n"); + return ECORE_CALLBACK_PASS_ON; + } + + EOM_DBG("BUFF CHANGE: tbm_buffer %p", external_tbm_buffer); + */ + + /* mmap that buffer to get width and height for test's sake */ + /* + memset(&surface_info, 0, sizeof(tbm_surface_info_s)); + ret = tbm_surface_map(external_tbm_buffer, TBM_SURF_OPTION_READ | + TBM_SURF_OPTION_WRITE, &surface_info); + if (ret != TBM_SURFACE_ERROR_NONE) + { + EOM_ERR("BUFF CHANGE: failed mmap buffer: %d", ret); + //return ECORE_CALLBACK_PASS_ON; + } - tsurface = wayland_tbm_server_get_surface(wl_comp_data->tbm.server, buffer->resource); + EOM_DBG("BUFF CHANGE: tbm_buffer: %dx%d", surface_info.width, surface_info.height); - return tsurface; + tbm_surface_unmap(external_tbm_buffer); */ + + /* TODO: Must find proper way of getting tbm_surface */ + /*client_buffer = _e_eom_create_client_buffer(external_wl_buffer, external_tbm_buffer);*/ + client_buffer = _e_eom_create_client_buffer(external_wl_buffer, fake_buffers.fake_buffers[0]); + if(client_buffer == NULL) + { + EOM_ERR("ERROR: BUFF CHANGE: alloc client buffer"); + return ECORE_CALLBACK_PASS_ON; + } + + _e_eom_add_client_buffer_to_list(client_buffer); + + /* Stop mirror mode */ + g_eom->is_mirror_mode = 0; + + return ECORE_CALLBACK_PASS_ON; } static void -_e_eom_canvas_render_post(void *data EINA_UNUSED, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED) +_e_eom_add_client_buffer_to_list(E_EomClientBufferPtr client_buffer) { - Ecore_Drm_Output * drm_output; - tbm_surface_h surface; + _e_eom_client_buffers_list_free(); - E_Client *ec = data; - EINA_SAFETY_ON_NULL_RETURN(ec != NULL); - EINA_SAFETY_ON_NULL_RETURN(ec->frame != NULL); + g_eom_event_data.client_buffers_list = eina_list_append(g_eom_event_data.client_buffers_list, client_buffer); +} + +static void +_e_eom_client_buffers_list_free() +{ + E_EomClientBufferPtr *buffer; + Eina_List *l; - drm_output = _e_eom_get_drm_output_for_client(ec); - EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); + /* TODO: I am not sure if it is thread safe */ + EINA_LIST_FOREACH(g_eom_event_data.client_buffers_list, l, buffer) + { + if (buffer) + { + /* I am not sure if it is necessary */ + /* tbm_surface_internal_unref(buffer->tbm_buffer); */ - surface = _e_eom_get_tbm_surface_for_client(ec); + /* TODO: Do we need reference that buffer? */ + /*e_comp_wl_buffer_reference(buffer->tbm_buffer, NULL);*/ - _e_eom_set_output(drm_output, surface); + g_eom_event_data.client_buffers_list = eina_list_remove(g_eom_event_data.client_buffers_list, buffer); + free(buffer); + } + } } -#endif -static void -_e_eom_fullscreen_pre_cb_hook(void *data, E_Client *ec) + +static E_EomClientBufferPtr +_e_eom_create_client_buffer(E_Comp_Wl_Buffer *wl_buffer, tbm_surface_h tbm_buffer) { - /* - const Eina_List *l; - E_Comp_Wl_Output *ext_output = NULL; - int loc = 0; + E_EomClientBufferPtr buffer = NULL; - Ecore_Drm_Output * drm_output; - tbm_surface_h surface; + buffer = malloc(sizeof(E_EomClientBuffer)); + if(buffer == NULL) + return NULL; - EINA_SAFETY_ON_NULL_RETURN(ec != NULL); - EINA_SAFETY_ON_NULL_RETURN(ec->frame != NULL); + buffer->wl_buffer = wl_buffer; + buffer->tbm_buffer = tbm_buffer; + /* TODO: It is not used right now */ + buffer->stamp = _e_eom_get_time_in_mseconds(); + /* I am not sure if it is necessary */ + /* tbm_surface_internal_ref(tbm_buffer); */ + + /* TODO: Do we need reference that buffer? */ + /*e_comp_wl_buffer_reference(buffer->tbm_buffer, NULL);*/ + + return buffer; +} - if (g_eom->is_external_init == 0 && - (ext_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, g_eom->ext_output_name)) == NULL) +static E_EomClientBufferPtr +_e_eom_get_client_buffer_from_list() +{ + E_EomClientBufferPtr buffer; + Eina_List *l; + + /* TODO: Have to describe how that list works*/ + /* There must be only one buffer */ + EINA_LIST_FOREACH(g_eom_event_data.client_buffers_list, l, buffer) { - EINA_LIST_FOREACH(ext_output->clients, l, o) - { - ; - } + if (buffer) + return buffer; } - drm_output = _e_eom_get_drm_output_for_client(ec); - EINA_SAFETY_ON_NULL_RETURN(drm_output != NULL); + return NULL; +} - surface = _e_eom_get_tbm_surface_for_client(ec); +static int +_e_eom_get_time_in_mseconds() +{ + struct timespec tp; - _e_eom_set_output(drm_output, surface); + clock_gettime(CLOCK_MONOTONIC, &tp); - evas_event_callback_add(ec->frame, EVAS_CALLBACK_RENDER_POST, _e_eom_canvas_render_post, ec); - */ + return ((tp.tv_sec * 1000) + (tp.tv_nsec / 1000)); } - static Eina_Bool _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) { + /* Ecore_Drm_Event_Activate *e = NULL; - /* E_EomPtr eom = NULL; */ + E_EomPtr eom = NULL; EOM_DBG("_e_eom_ecore_drm_activate_cb called\n"); if ((!event) || (!data)) goto end; e = event; - /* eom = data; */ + eom = data; EOM_DBG("e->active:%d\n", e->active); if (e->active) { - /* TODO: do something */ + } else { - /* TODO: do something */ + } end: + */ return ECORE_CALLBACK_PASS_ON; } - /* wl_eom_set_keygrab request handler */ static void _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, uint32_t output_id, uint32_t attribute) { int ret = 0; - /* - (void) client; - (void) attribute; - */ EOM_DBG("attribute:%d +++ output:%d\n", attribute, output_id); - /* - * TODO: check output_id - */ ret = _e_eom_set_eom_attribute(attribute); if (ret == 0) { - EOM_DBG("set attribute FAILED\n"); + EOM_DBG("set attribute FAILED\n"); - wl_eom_send_output_attribute(resource, + wl_eom_send_output_attribute(resource, g_eom->id, _e_eom_get_eom_attribute(), _e_eom_get_eom_attribute_state(), @@ -1112,15 +1317,36 @@ _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource } else { - EOM_DBG("set attribute OK\n"); + EOM_DBG("set attribute OK\n"); - wl_eom_send_output_attribute(resource, + wl_eom_send_output_attribute(resource, g_eom->id, _e_eom_get_eom_attribute(), _e_eom_get_eom_attribute_state(), WL_EOM_ERROR_NONE); + + /* If client has set WL_EOM_ATTRIBUTE_NONE, eom will be + * switched to mirror mode + */ + if (attribute == WL_EOM_ATTRIBUTE_NONE && g_eom->is_mirror_mode == 0) + { + g_eom->is_mirror_mode = 1; + + _e_eom_client_buffers_list_free(); + + ret = _e_eom_mirror_start(g_eom->int_output_name, + g_eom->src_mode.w, + g_eom->src_mode.h); + if (!ret) + { + EOM_ERR("ERROR: restore mirror mode after a client disconnection\n"); + goto err; + } + } } +err: + return; } static void @@ -1157,15 +1383,46 @@ static const struct wl_eom_interface _e_eom_wl_implementation = static void _e_eom_wl_resource_destory_cb(struct wl_resource *resource) { - /* TODO : destroy resources if exist */ + int ret; + EOM_DBG("client unbind\n"); + + ret = _e_eom_set_eom_attribute(WL_EOM_ATTRIBUTE_NONE); + if (ret != 1) + EOM_DBG("Restore attribute: Failed\n"); + else + EOM_DBG("Restore attribute: OK\n"); + + /* If a client has been disconnected and eom has not been + * restored to mirror mode, start mirror mode + */ + if (g_eom->is_mirror_mode == 0) + { + g_eom->is_mirror_mode = 1; + + _e_eom_client_buffers_list_free(); + + ret = _e_eom_mirror_start(g_eom->int_output_name, + g_eom->src_mode.w, + g_eom->src_mode.h); + if (!ret) + { + EOM_ERR("ERROR: restore mirror mode after a client disconnection\n"); + goto err; + } + } + + /*TODO: notify clients that EOM has just changed status*/ + +err: + return; } /* wl_eom global object bind function */ static void _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id) { -/* enum wl_eom_type eom_type = WL_EOM_TYPE_NONE;*/ -/* E_Comp_Wl_Output *wl_output = NULL;*/ + /* enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; */ + /* E_Comp_Wl_Output *wl_output = NULL; */ struct wl_resource *resource; E_EomPtr eom = data; @@ -1180,11 +1437,15 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 return; } + wl_resource_set_implementation(resource, - &_e_eom_wl_implementation, - eom, - _e_eom_wl_resource_destory_cb); + &_e_eom_wl_implementation, + eom, + _e_eom_wl_resource_destory_cb); + /*TODO: We have to store all clients in list to make it possible to send + * events when a client free external output or has been destroyed + */ eom->resource = resource; #if 0 @@ -1236,6 +1497,7 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 } } #endif + EOM_DBG("create wl_eom global resource.\n"); } @@ -1252,12 +1514,6 @@ _e_eom_deinit() ecore_event_handler_del(h); } - if (fullscreen_pre_hook) - { - e_client_hook_del(fullscreen_pre_hook); - fullscreen_pre_hook = NULL; - } - if (g_eom->dpy) tdm_display_deinit(g_eom->dpy); if (g_eom->bufmgr) tbm_bufmgr_deinit(g_eom->bufmgr); @@ -1444,7 +1700,6 @@ err: tdm_display_deinit(g_eom->dpy); return EINA_FALSE; - } static Eina_Bool @@ -1474,7 +1729,7 @@ _e_eom_init() E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom); E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_OUTPUT, _e_eom_ecore_drm_output_cb, g_eom); - fullscreen_pre_hook = e_client_hook_add(E_CLIENT_HOOK_FULLSCREEN_PRE, _e_eom_fullscreen_pre_cb_hook, NULL); + E_LIST_HANDLER_APPEND(g_eom->handlers, E_EVENT_CLIENT_BUFFER_CHANGE, _e_eom_client_buffer_change, NULL); g_eom->is_external_init = 0; g_eom->is_internal_grab = 0; -- 2.7.4 From ca549860d787aeb0ddfb30fa1165334acf1aa3ca Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Thu, 5 May 2016 17:11:50 +0300 Subject: [PATCH 13/16] correct notifications of clients Change-Id: I7f582f3025c39cd1effdf6f1ee3b01fb814e6016 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 115 ++++++++++++++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 60 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 4b851be..03a619a 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -10,7 +10,6 @@ #include "eom-server-protocol.h" #include "Ecore_Drm.h" - #define NUM_MAIN_BUF 2 #define NUM_ATTR 3 @@ -58,7 +57,7 @@ struct _E_Eom_Output struct _E_Eom { struct wl_global *global; - struct wl_resource *resource; + Eina_List *eom_clients; Eina_List *handlers; tdm_display *dpy; @@ -160,8 +159,6 @@ static E_EomClientBufferPtr _e_eom_get_client_buffer_from_list(); /*eom utils functions*/ static int _e_eom_get_time_in_mseconds(); - - static void _e_eom_create_fake_buffers(int width, int height); static inline enum wl_eom_mode @@ -245,12 +242,10 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) /* If a client has committed its buffer stop mirror mode */ if (g_eom->is_mirror_mode == 0) { - EOM_DBG("PP STOP\n"); + EOM_DBG("PP STOP\n"); return; } - EOM_DBG("PP\n"); - tbm_surface_h src_buffer; src_buffer = _e_eom_root_internal_tdm_surface_get(g_eom->int_output_name); if (!src_buffer ) @@ -304,8 +299,6 @@ _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUS /* TODO: Maybe better to separating that callback on to mirror and extended callbacks */ if (g_eom->is_mirror_mode == 1) { - EOM_ERR("MIRROR MODE\n"); - if (eom_data->current_buffer == 1) { eom_data->current_buffer = 0; @@ -340,12 +333,7 @@ _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUS } else { - EOM_DBG("EXTENDED MODE\n"); - - client_buffer = _e_eom_get_client_buffer_from_list(); - - EOM_DBG("EXTENDED MODE: client_buffer %p\n", client_buffer); - + client_buffer = _e_eom_get_client_buffer_from_list(); err = tdm_layer_set_buffer(eom_data->layer, client_buffer->tbm_buffer); if (err != TDM_ERROR_NONE) { @@ -972,15 +960,12 @@ static int flag = 0; static Eina_Bool _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) { - Ecore_Drm_Event_Output *e; - /* - E_EomPtr eom = data; - const Eina_List *l; - struct wl_resource *output_resource; - */ - E_Comp_Wl_Output *wl_output = NULL; enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; + struct wl_resource *resource_iterator; + E_Comp_Wl_Output *wl_output = NULL; + Ecore_Drm_Event_Output *e; char buff[PATH_MAX]; + Eina_List *l; int ret = 0; if (!(e = event)) goto end; @@ -1043,28 +1028,26 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e g_eom->wl_output = wl_output; - /* - EINA_LIST_FOREACH(wl_output->resources, l, output_resource) + EINA_LIST_FOREACH(g_eom->eom_clients, l, resource_iterator) { - - EOM_DBG("e->plug:%d\n", e->plug); - - wl_eom_send_output_type(eom->resource, - output_resource, - eom_type, - _e_eom_get_eom_status()); - - wl_eom_send_output_attribute(eom->resource, - output_resource, - _e_eom_get_eom_attribute(), - _e_eom_get_eom_attribute_state(), - WL_EOM_ERROR_NONE); - - wl_eom_send_output_mode(eom->resource, - output_resource, - _e_eom_get_eom_mode()); + if (resource_iterator) + { + wl_eom_send_output_type(resource_iterator, + g_eom->id, + eom_type, + _e_eom_get_eom_status()); + + wl_eom_send_output_attribute(resource_iterator, + g_eom->id, + _e_eom_get_eom_attribute(), + _e_eom_get_eom_attribute_state(), + WL_EOM_ERROR_NONE); + + wl_eom_send_output_mode(resource_iterator, + g_eom->id, + _e_eom_get_eom_mode()); + } } - */ } else if (strcmp(e->name, "DSI-0") == 0 && g_eom->is_external_init && flag == 2) { @@ -1217,6 +1200,7 @@ _e_eom_client_buffers_list_free() } } + static E_EomClientBufferPtr _e_eom_create_client_buffer(E_Comp_Wl_Buffer *wl_buffer, tbm_surface_h tbm_buffer) { @@ -1240,6 +1224,7 @@ _e_eom_create_client_buffer(E_Comp_Wl_Buffer *wl_buffer, tbm_surface_h tbm_buffe return buffer; } + static E_EomClientBufferPtr _e_eom_get_client_buffer_from_list() { @@ -1257,6 +1242,7 @@ _e_eom_get_client_buffer_from_list() return NULL; } + static int _e_eom_get_time_in_mseconds() { @@ -1267,6 +1253,7 @@ _e_eom_get_time_in_mseconds() return ((tp.tv_sec * 1000) + (tp.tv_nsec / 1000)); } + static Eina_Bool _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) { @@ -1296,7 +1283,7 @@ end: return ECORE_CALLBACK_PASS_ON; } -/* wl_eom_set_keygrab request handler */ + static void _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, uint32_t output_id, uint32_t attribute) { @@ -1304,6 +1291,7 @@ _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource EOM_DBG("attribute:%d +++ output:%d\n", attribute, output_id); + /* TODO: Add notifications when more prior client changes eom state */ ret = _e_eom_set_eom_attribute(attribute); if (ret == 0) { @@ -1383,7 +1371,10 @@ static const struct wl_eom_interface _e_eom_wl_implementation = static void _e_eom_wl_resource_destory_cb(struct wl_resource *resource) { + struct wl_resource *resource_iterator; + Eina_List *l; int ret; + EOM_DBG("client unbind\n"); ret = _e_eom_set_eom_attribute(WL_EOM_ATTRIBUTE_NONE); @@ -1402,19 +1393,28 @@ _e_eom_wl_resource_destory_cb(struct wl_resource *resource) _e_eom_client_buffers_list_free(); ret = _e_eom_mirror_start(g_eom->int_output_name, - g_eom->src_mode.w, - g_eom->src_mode.h); + g_eom->src_mode.w, + g_eom->src_mode.h); if (!ret) { EOM_ERR("ERROR: restore mirror mode after a client disconnection\n"); - goto err; + return; } - } - /*TODO: notify clients that EOM has just changed status*/ + /* Notify eom clients that eom state has been changed */ + EINA_LIST_FOREACH(g_eom->eom_clients, l, resource_iterator) + { + if (resource_iterator) + { + wl_eom_send_output_attribute(resource_iterator, + g_eom->id, + _e_eom_get_eom_attribute(), + _e_eom_get_eom_attribute_state(), + WL_EOM_ERROR_NONE); + } -err: - return; + } + } } /* wl_eom global object bind function */ @@ -1443,11 +1443,6 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 eom, _e_eom_wl_resource_destory_cb); - /*TODO: We have to store all clients in list to make it possible to send - * events when a client free external output or has been destroyed - */ - eom->resource = resource; - #if 0 wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, g_eom->ext_output_name); if (!wl_output) @@ -1463,23 +1458,23 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 return; } - wl_eom_send_output_type(eom->resource, + wl_eom_send_output_type(resource, eom->id, eom_type, _e_eom_get_eom_status()); - wl_eom_send_output_attribute(eom->resource, + wl_eom_send_output_attribute(resource, eom->id, _e_eom_get_eom_attribute(), _e_eom_get_eom_attribute_state(), WL_EOM_ERROR_NONE); - wl_eom_send_output_mode(eom->resource, + wl_eom_send_output_mode(resource, eom->id, _e_eom_get_eom_mode()); #else EOM_DBG("send - output count : %d\n", g_eom->output_count); - wl_eom_send_output_count(eom->resource, + wl_eom_send_output_count(resource, g_eom->output_count); if (g_eom->outputs) @@ -1498,7 +1493,7 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 } #endif - EOM_DBG("create wl_eom global resource.\n"); + g_eom->eom_clients = eina_list_append(g_eom->eom_clients, resource); } static void -- 2.7.4 From 4b6a30d30a0f1d86ba4e96606d2cc9395d5b8080 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Thu, 5 May 2016 20:29:07 +0300 Subject: [PATCH 14/16] allow clients binding to eom when there is no external output Change-Id: I6f131c6b8664a9617168ed7696d133c1673a08ae Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 03a619a..8f49b1c 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -357,13 +357,14 @@ _e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id) E_Comp_Wl_Output *output = NULL, *o; int loc = 0; + if (id == NULL) + return NULL; + EINA_LIST_FOREACH(outputs, l, o) { char *temp_id = NULL; temp_id = strchr(o->id, '/'); - EOM_DBG("o->id=%s", o->id); - if (temp_id == NULL) { if (strcmp(o->id, id) == 0) @@ -779,6 +780,9 @@ _e_eom_output_name_to_eom_type(const char *output_name) { enum wl_eom_type eom_type; + if (output_name == NULL) + return WL_EOM_TYPE_NONE; + /* TODO: Add other external outputs */ if (strcmp(output_name, "HDMI-A-0") == 0) eom_type = WL_EOM_TYPE_HDMIA; @@ -1200,7 +1204,6 @@ _e_eom_client_buffers_list_free() } } - static E_EomClientBufferPtr _e_eom_create_client_buffer(E_Comp_Wl_Buffer *wl_buffer, tbm_surface_h tbm_buffer) { @@ -1224,7 +1227,6 @@ _e_eom_create_client_buffer(E_Comp_Wl_Buffer *wl_buffer, tbm_surface_h tbm_buffe return buffer; } - static E_EomClientBufferPtr _e_eom_get_client_buffer_from_list() { @@ -1242,7 +1244,6 @@ _e_eom_get_client_buffer_from_list() return NULL; } - static int _e_eom_get_time_in_mseconds() { @@ -1253,7 +1254,6 @@ _e_eom_get_time_in_mseconds() return ((tp.tv_sec * 1000) + (tp.tv_nsec / 1000)); } - static Eina_Bool _e_eom_ecore_drm_activate_cb(void *data, int type EINA_UNUSED, void *event) { @@ -1283,14 +1283,11 @@ end: return ECORE_CALLBACK_PASS_ON; } - static void _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, uint32_t output_id, uint32_t attribute) { int ret = 0; - EOM_DBG("attribute:%d +++ output:%d\n", attribute, output_id); - /* TODO: Add notifications when more prior client changes eom state */ ret = _e_eom_set_eom_attribute(attribute); if (ret == 0) @@ -1421,8 +1418,7 @@ _e_eom_wl_resource_destory_cb(struct wl_resource *resource) static void _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id) { - /* enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; */ - /* E_Comp_Wl_Output *wl_output = NULL; */ + enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; struct wl_resource *resource; E_EomPtr eom = data; @@ -1437,26 +1433,12 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 return; } - wl_resource_set_implementation(resource, &_e_eom_wl_implementation, eom, _e_eom_wl_resource_destory_cb); -#if 0 - wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, g_eom->ext_output_name); - if (!wl_output) - { - EOM_DBG("failed to get wl_output\n"); - return; - } - eom_type = _e_eom_output_name_to_eom_type(g_eom->ext_output_name); - if (eom_type == WL_EOM_TYPE_NONE) - { - EOM_DBG("create wl_eom global resource.\n"); - return; - } wl_eom_send_output_type(resource, eom->id, @@ -1472,7 +1454,7 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 wl_eom_send_output_mode(resource, eom->id, _e_eom_get_eom_mode()); -#else + EOM_DBG("send - output count : %d\n", g_eom->output_count); wl_eom_send_output_count(resource, g_eom->output_count); @@ -1491,7 +1473,6 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 output->phys_width, output->phys_height, output->status); } } -#endif g_eom->eom_clients = eina_list_append(g_eom->eom_clients, resource); } @@ -1728,6 +1709,8 @@ _e_eom_init() g_eom->is_external_init = 0; g_eom->is_internal_grab = 0; + g_eom->ext_output_name = NULL; + g_eom->int_output_name = NULL; _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_NONE); _e_eom_set_eom_attribute(WL_EOM_ATTRIBUTE_NONE); -- 2.7.4 From 574fd03b3b54f928d041f56f292616bb6f173917 Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Fri, 6 May 2016 17:22:31 +0300 Subject: [PATCH 15/16] clean code Change-Id: I3d3b789253ff4f25a526f0a362378de6950b8b48 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 258 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 132 insertions(+), 126 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 8f49b1c..76564eb 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -135,15 +135,15 @@ static int eom_output_attributes[NUM_ATTR][NUM_ATTR] = /* handle external output */ static E_Comp_Wl_Output *_e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id); -static int _e_eom_set_up_external_output(const char *output_name, int width, int height); +static Eina_Bool _e_eom_set_up_external_output(const char *output_name, int width, int height); static tdm_output * _e_eom_hal_output_get(const char *id); static tdm_layer * _e_eom_hal_layer_get(tdm_output *output, int width, int height); -static int _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height); +static Eina_Bool _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height); static enum wl_eom_type _e_eom_output_name_to_eom_type(const char *output_name); /* handle internal output, pp */ -static int _e_eom_mirror_start(const char *output_name, int width, int height); +static Eina_Bool _e_eom_mirror_start(const char *output_name, int width, int height); static tbm_surface_h _e_eom_root_internal_tdm_surface_get(const char *name); -static int _e_eom_pp_src_to_dst( tbm_surface_h src_buffer); +static Eina_Bool _e_eom_pp_src_to_dst( tbm_surface_h src_buffer); /* tdm handlers */ static void _e_eom_pp_cb(tbm_surface_h surface, void *user_data); static void _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, @@ -191,22 +191,22 @@ _e_eom_get_eom_attribute() return g_eom->eom_attribute; } -static inline int +static inline Eina_Bool _e_eom_set_eom_attribute(enum wl_eom_attribute attribute) { if (attribute == WL_EOM_ATTRIBUTE_NONE || g_eom->eom_attribute == WL_EOM_ATTRIBUTE_NONE) { g_eom->eom_attribute = attribute; - return 1; + return EINA_TRUE; } if (eom_output_attributes[g_eom->eom_attribute - 1][attribute - 1] == 1) { g_eom->eom_attribute = attribute; - return 1; + return EINA_TRUE; } - return 0; + return EINA_FALSE; } static inline enum wl_eom_status @@ -224,10 +224,10 @@ _e_eom_set_eom_status(enum wl_eom_status status) static void _e_eom_pp_cb(tbm_surface_h surface, void *user_data) { - E_EomEventDataPtr eom_data = NULL; tdm_error tdm_err = TDM_ERROR_NONE; + E_EomEventDataPtr eom_data = NULL; - if (!user_data) + if (user_data == NULL) { EOM_DBG("ERROR: PP EVENT: user data is NULL\n"); return; @@ -236,19 +236,16 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) eom_data = (E_EomEventDataPtr)user_data; tdm_buffer_remove_release_handler(eom_data->dst_buffers[eom_data->pp_buffer], - _e_eom_pp_cb, eom_data); + _e_eom_pp_cb, eom_data); /* TODO: lock that flag??? */ /* If a client has committed its buffer stop mirror mode */ if (g_eom->is_mirror_mode == 0) - { - EOM_DBG("PP STOP\n"); - return; - } + return; tbm_surface_h src_buffer; src_buffer = _e_eom_root_internal_tdm_surface_get(g_eom->int_output_name); - if (!src_buffer ) + if (src_buffer == EINA_FALSE) { EOM_DBG("ERROR: PP EVENT: get root tdm surfcae\n"); return; @@ -284,11 +281,11 @@ _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUS unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *user_data) { - E_EomEventDataPtr eom_data; - E_EomClientBufferPtr client_buffer; + E_EomClientBufferPtr client_buffer = NULL; + E_EomEventDataPtr eom_data = NULL; tdm_error err = TDM_ERROR_NONE; - if (!user_data) + if (user_data == NULL) { EOM_ERR("ERROR: EVENT: user_data is NULL\n"); return; @@ -334,6 +331,12 @@ _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUS else { client_buffer = _e_eom_get_client_buffer_from_list(); + if (client_buffer == NULL) + { + EOM_ERR("ERROR: EVENT: client buffer is NULL\n"); + return; + } + err = tdm_layer_set_buffer(eom_data->layer, client_buffer->tbm_buffer); if (err != TDM_ERROR_NONE) { @@ -353,8 +356,8 @@ _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUS static E_Comp_Wl_Output * _e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id) { + E_Comp_Wl_Output *output = NULL, *o = NULL; const Eina_List *l; - E_Comp_Wl_Output *output = NULL, *o; int loc = 0; if (id == NULL) @@ -384,32 +387,34 @@ _e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id) return output; } -static int +static Eina_Bool _e_eom_set_up_external_output(const char *output_name, int width, int height) { - tdm_output *hal_output; - tdm_layer *hal_layer; - tdm_info_layer layer_info; tdm_error tdm_err = TDM_ERROR_NONE; - E_EomEventDataPtr eom_data = &g_eom_event_data; - int ret = 0; + E_EomEventDataPtr eom_data = NULL; + tdm_output *hal_output = NULL; + tdm_layer *hal_layer = NULL; + Eina_Bool ret = EINA_FALSE; + tdm_info_layer layer_info; + + eom_data = &g_eom_event_data; hal_output = _e_eom_hal_output_get(output_name); - if (!hal_output) + if (hal_output == NULL) { EOM_ERR("ERROR: get hal output for, (%s)\n", output_name); goto err; } hal_layer = _e_eom_hal_layer_get(hal_output, width, height); - if (!hal_layer) + if (hal_layer == NULL) { EOM_ERR("ERROR: get hal layer\n"); goto err; } ret = _e_eom_create_output_buffers(eom_data, width, height); - if (!ret ) + if (ret == EINA_FALSE) { EOM_ERR("ERROR: create buffers \n"); goto err; @@ -462,14 +467,13 @@ _e_eom_set_up_external_output(const char *output_name, int width, int height) goto err; } - - return 1; + return EINA_TRUE; err: /* * TODO: add deinitialization */ - return 0; + return EINA_FALSE; } static void @@ -506,6 +510,18 @@ _e_eom_deinit_external_output() } } + if (g_eom->int_output_name) + { + free(g_eom->int_output_name); + g_eom->int_output_name = NULL; + } + + if (g_eom->ext_output_name) + { + free(g_eom->ext_output_name); + g_eom->ext_output_name = NULL; + } + if (g_eom->wl_output) g_eom->wl_output = NULL; } @@ -513,15 +529,16 @@ _e_eom_deinit_external_output() static tdm_output * _e_eom_hal_output_get(const char *id) { - Ecore_Drm_Device *dev; - Ecore_Drm_Output *drm_output = NULL, *o; - tdm_output *output; - const tdm_output_mode *modes; - const tdm_output_mode *big_mode; + Ecore_Drm_Output *drm_output = NULL, *o = NULL; + const tdm_output_mode *big_mode = NULL; + const tdm_output_mode *modes = NULL; + Ecore_Drm_Device *dev = NULL; + tdm_output *output = NULL; tdm_error err = TDM_ERROR_NONE; const Eina_List *l, *ll; int crtc_id = 0; int count = 0; + int i = 0; /* * TODO: Temporary take into account only HDMI @@ -536,7 +553,7 @@ _e_eom_hal_output_get(const char *id) } } - if (!drm_output) + if (drm_output == NULL) { EOM_ERR("ERROR: drm output was not found\n"); return NULL; @@ -550,7 +567,7 @@ _e_eom_hal_output_get(const char *id) } output = tdm_display_get_output(g_eom->dpy, crtc_id, NULL); - if (!output) + if (output == NULL) { EOM_ERR("ERROR: there is no HAL output for:%d\n", crtc_id); return NULL; @@ -579,15 +596,14 @@ _e_eom_hal_output_get(const char *id) big_mode = &modes[0]; - int i = 0; for (i = 0; i < count; i++) { - if ((modes[i].vdisplay + modes[i].hdisplay) >= (big_mode->vdisplay + big_mode->hdisplay)) + if ((modes[i].vdisplay + modes[i].hdisplay) >= + (big_mode->vdisplay + big_mode->hdisplay)) big_mode = &modes[i]; } - /*TODO: fix it*/ - if (!big_mode) + if (big_mode == NULL) { EOM_ERR("no Big mode\n"); return NULL; @@ -676,11 +692,11 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) static void _e_eom_create_fake_buffers(int width, int height) { - tbm_surface_h buffer; tbm_surface_info_s buffer_info; + tbm_surface_h buffer = NULL; buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); - if (!buffer) + if (buffer == NULL) { EOM_DBG("can not create fake_buffer\n"); goto err; @@ -704,17 +720,17 @@ err: return; } -static int +static Eina_Bool _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height) { - tbm_surface_h buffer; tbm_surface_info_s buffer_info; + tbm_surface_h buffer = NULL; /* * TODO: Add support of other formats */ buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); - if (!buffer) + if (buffer == NULL) { EOM_DBG("can not create dst_buffer\n"); goto err; @@ -742,7 +758,7 @@ _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height) * TODO: Add support of other formats */ buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); - if (!buffer) + if (buffer == NULL) { EOM_DBG("can not create dst_buffer\n"); goto err; @@ -765,14 +781,14 @@ _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height) eom_data->dst_buffers[1] = buffer; - return 1; + return EINA_TRUE; err: /* * Add deinitialization */ - return 0; + return EINA_FALSE; } static enum wl_eom_type @@ -792,15 +808,15 @@ _e_eom_output_name_to_eom_type(const char *output_name) return eom_type; } -static int +static Eina_Bool _e_eom_mirror_start(const char *output_name, int width, int height) { - tbm_surface_h src_buffer; tbm_surface_info_s src_buffer_info; - int ret = 0; + tbm_surface_h src_buffer = NULL; + Eina_Bool ret = EINA_FALSE; src_buffer = _e_eom_root_internal_tdm_surface_get(output_name); - if (!src_buffer ) + if (src_buffer == NULL) { EOM_ERR("ERROR: get root tdm surfcae\n"); return 0; @@ -809,28 +825,22 @@ _e_eom_mirror_start(const char *output_name, int width, int height) tbm_surface_get_info(src_buffer, &src_buffer_info ); EOM_DBG("FRAMEBUFFER TDM: %dx%d bpp:%d size:%d", - src_buffer_info.width, - src_buffer_info.height, - src_buffer_info.bpp, - src_buffer_info.size); + src_buffer_info.width, src_buffer_info.height, + src_buffer_info.bpp, src_buffer_info.size); g_eom->src_mode.w = width; g_eom->src_mode.h = height; /* TODO: free that memory */ g_eom->int_output_name = strdup(output_name); - EOM_DBG("INT SURFACE: 1\n"); - ret = _e_eom_pp_src_to_dst(src_buffer); - if (!ret ) + if (ret == EINA_FALSE) { EOM_ERR("ERROR: init pp\n"); - return 0; + return ret == EINA_FALSE; } - EOM_DBG("INT SURFACE: 2\n"); - - return 1; + return EINA_TRUE; } static tbm_surface_h @@ -846,10 +856,10 @@ _e_eom_root_internal_tdm_surface_get(const char *name) primary_output = ecore_drm_device_output_name_find(dev, name); } - if (!primary_output) + if (primary_output == NULL) { - EOM_ERR("ERROR: get primary output\n"); - return NULL; + EOM_ERR("ERROR: get primary output\n"); + return NULL; } /* I think it is more convenient than one upon, but E took first @@ -864,7 +874,7 @@ _e_eom_root_internal_tdm_surface_get(const char *name) */ fb = ecore_drm_display_output_primary_layer_fb_get(primary_output); - if (!primary_output) + if (primary_output == NULL) { EOM_ERR("ERROR: get primary frambuffer\n"); return NULL; @@ -875,14 +885,12 @@ _e_eom_root_internal_tdm_surface_get(const char *name) return (tbm_surface_h)fb->hal_buffer; } -static int +static Eina_Bool _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) { - tdm_pp *pp; - tdm_info_pp pp_info; tdm_error err = TDM_ERROR_NONE; - - EOM_DBG("PP: 1\n"); + tdm_info_pp pp_info; + tdm_pp *pp = NULL; pp = tdm_display_create_pp(g_eom->dpy, &err); if (err != TDM_ERROR_NONE) @@ -891,8 +899,6 @@ _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) return 0; } - EOM_DBG("PP: 2\n"); - g_eom_event_data.pp = pp; pp_info.src_config.size.h = g_eom->src_mode.w; /*1440*/ @@ -913,50 +919,42 @@ _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) pp_info.sync = 0; pp_info.flags = 0; - EOM_DBG("PP: 3\n"); - err = tdm_pp_set_info(pp, &pp_info); if (err != TDM_ERROR_NONE) { EOM_ERR("ERROR: set pp info:%d\n", err); - return 0; + return EINA_FALSE; } - EOM_DBG("PP: 4\n"); - g_eom_event_data.pp_buffer = !g_eom_event_data.current_buffer; - EOM_DBG("PP: curr:%d pp:%d\n", g_eom_event_data.current_buffer, g_eom_event_data.pp_buffer); + EOM_DBG("PP: curr:%d pp:%d\n", + g_eom_event_data.current_buffer, + g_eom_event_data.pp_buffer); err = tdm_buffer_add_release_handler(g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer], _e_eom_pp_cb, &g_eom_event_data); if (err != TDM_ERROR_NONE) { EOM_ERR ("ERROR: set pp hadler:%d\n", err); - return 0; + return EINA_FALSE; } - EOM_DBG("PP: 5\n"); - - err = tdm_pp_attach(pp, src_buffer, g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer]); + err = tdm_pp_attach(pp, src_buffer, + g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer]); if (err != TDM_ERROR_NONE) { EOM_ERR("ERROR: pp attach:%d\n", err); - return 0; + return EINA_FALSE; } - - EOM_DBG("PP: 6\n"); - err = tdm_pp_commit(g_eom_event_data.pp); if (err != TDM_ERROR_NONE) { EOM_ERR("ERROR: pp commit:%d\n", err); - return 0; + return EINA_FALSE; } - EOM_DBG("PP: OK\n"); - - return 1; + return EINA_TRUE; } static int flag = 0; @@ -1003,6 +1001,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e g_eom->is_external_init = 1; g_eom->id = e->id; + g_eom->wl_output = wl_output; _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_ACTIVE); _e_eom_set_eom_status(WL_EOM_STATUS_CONNECTION); @@ -1013,6 +1012,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e { g_eom->is_external_init = 0; g_eom->is_internal_grab = 0; + g_eom->wl_output = NULL; g_eom->id = -1; _e_eom_set_eom_attribute_state(WL_EOM_ATTRIBUTE_STATE_INACTIVE); @@ -1030,8 +1030,6 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e goto end; } - g_eom->wl_output = wl_output; - EINA_LIST_FOREACH(g_eom->eom_clients, l, resource_iterator) { if (resource_iterator) @@ -1076,12 +1074,12 @@ end: static Eina_Bool _e_eom_client_buffer_change(void *data, int type, void *event) { - E_Client *ec; + E_Comp_Wl_Buffer *external_wl_buffer = NULL; + E_EomClientBufferPtr client_buffer = NULL; E_Event_Client *ev = event; - E_Comp_Wl_Buffer *external_wl_buffer; - E_EomClientBufferPtr client_buffer; + E_Client *ec = NULL; /* - tbm_surface_h external_tbm_buffer; + tbm_surface_h external_tbm_buffer = NULL; tbm_surface_info_s surface_info; int ret; */ @@ -1159,7 +1157,7 @@ _e_eom_client_buffer_change(void *data, int type, void *event) /* TODO: Must find proper way of getting tbm_surface */ /*client_buffer = _e_eom_create_client_buffer(external_wl_buffer, external_tbm_buffer);*/ client_buffer = _e_eom_create_client_buffer(external_wl_buffer, fake_buffers.fake_buffers[0]); - if(client_buffer == NULL) + if (client_buffer == NULL) { EOM_ERR("ERROR: BUFF CHANGE: alloc client buffer"); return ECORE_CALLBACK_PASS_ON; @@ -1184,7 +1182,7 @@ _e_eom_add_client_buffer_to_list(E_EomClientBufferPtr client_buffer) static void _e_eom_client_buffers_list_free() { - E_EomClientBufferPtr *buffer; + E_EomClientBufferPtr *buffer = NULL; Eina_List *l; /* TODO: I am not sure if it is thread safe */ @@ -1230,7 +1228,7 @@ _e_eom_create_client_buffer(E_Comp_Wl_Buffer *wl_buffer, tbm_surface_h tbm_buffe static E_EomClientBufferPtr _e_eom_get_client_buffer_from_list() { - E_EomClientBufferPtr buffer; + E_EomClientBufferPtr buffer = NULL; Eina_List *l; /* TODO: Have to describe how that list works*/ @@ -1286,11 +1284,11 @@ end: static void _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource *resource, uint32_t output_id, uint32_t attribute) { - int ret = 0; + Eina_Bool ret = EINA_FALSE; /* TODO: Add notifications when more prior client changes eom state */ ret = _e_eom_set_eom_attribute(attribute); - if (ret == 0) + if (ret == EINA_FALSE) { EOM_DBG("set attribute FAILED\n"); @@ -1322,7 +1320,7 @@ _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource ret = _e_eom_mirror_start(g_eom->int_output_name, g_eom->src_mode.w, g_eom->src_mode.h); - if (!ret) + if (ret == EINA_FALSE) { EOM_ERR("ERROR: restore mirror mode after a client disconnection\n"); goto err; @@ -1342,7 +1340,7 @@ _e_eom_wl_request_get_output_info_cb(struct wl_client *client, struct wl_resourc if (g_eom->outputs) { Eina_List *l; - E_EomOutputPtr output; + E_EomOutputPtr output = NULL; EINA_LIST_FOREACH(g_eom->outputs, l, output) { @@ -1368,14 +1366,14 @@ static const struct wl_eom_interface _e_eom_wl_implementation = static void _e_eom_wl_resource_destory_cb(struct wl_resource *resource) { - struct wl_resource *resource_iterator; - Eina_List *l; - int ret; + struct wl_resource *resource_iterator = NULL; + Eina_List *l = NULL; + Eina_Bool ret; EOM_DBG("client unbind\n"); ret = _e_eom_set_eom_attribute(WL_EOM_ATTRIBUTE_NONE); - if (ret != 1) + if (ret == EINA_FALSE) EOM_DBG("Restore attribute: Failed\n"); else EOM_DBG("Restore attribute: OK\n"); @@ -1392,7 +1390,7 @@ _e_eom_wl_resource_destory_cb(struct wl_resource *resource) ret = _e_eom_mirror_start(g_eom->int_output_name, g_eom->src_mode.w, g_eom->src_mode.h); - if (!ret) + if (ret == EINA_FALSE) { EOM_ERR("ERROR: restore mirror mode after a client disconnection\n"); return; @@ -1419,14 +1417,21 @@ static void _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32_t id) { enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; - struct wl_resource *resource; + struct wl_resource *resource = NULL; + + if (data == NULL) + { + EOM_ERR("ERROR: data is NULL"); + return; + } + E_EomPtr eom = data; resource = wl_resource_create(client, &wl_eom_interface, MIN(version, 1), id); - if (!resource) + if (resource == NULL) { EOM_ERR("error. resource is null. (version :%d, id:%d)\n", version, id); wl_client_post_no_memory(client); @@ -1462,7 +1467,7 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 if (g_eom->outputs) { Eina_List *l; - E_EomOutputPtr output; + E_EomOutputPtr output = NULL; EINA_LIST_FOREACH(g_eom->outputs, l, output) { @@ -1480,9 +1485,9 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 static void _e_eom_deinit() { - Ecore_Event_Handler *h; + Ecore_Event_Handler *h = NULL; - if (!g_eom) return; + if (g_eom == NULL) return; if (g_eom->handlers) { @@ -1501,8 +1506,9 @@ _e_eom_deinit() static Eina_Bool _e_eom_output_info_get(tdm_display *dpy) { - int i, count; tdm_error ret = TDM_ERROR_NONE; + int i, count; + ret = tdm_display_get_output_count(dpy, &count); if (ret != TDM_ERROR_NONE) @@ -1522,12 +1528,12 @@ _e_eom_output_info_get(tdm_display *dpy) for (i = 0; i < count; i++) { + const tdm_output_mode *mode = NULL; + E_EomOutputPtr new_output = NULL; + unsigned int mmWidth, mmHeight; + tdm_output_conn_status status; tdm_output *output = NULL; - E_EomOutputPtr new_output; tdm_output_type type; - tdm_output_conn_status status; - unsigned int mmWidth, mmHeight; - const tdm_output_mode *mode; output = tdm_display_get_output(dpy, i, &ret); if (ret != TDM_ERROR_NONE) @@ -1536,7 +1542,7 @@ _e_eom_output_info_get(tdm_display *dpy) goto err; } - if (!output) + if (output == NULL) { EOM_ERR("tdm_display_get_output fail(no output:%d)", ret); goto err; @@ -1554,7 +1560,7 @@ _e_eom_output_info_get(tdm_display *dpy) continue; new_output = E_NEW(E_EomOutput, 1); - if (!new_output) + if (new_output == NULL) { EOM_ERR("calloc fail"); goto err; @@ -1681,7 +1687,7 @@ err: static Eina_Bool _e_eom_init() { - Eina_Bool ret = 0; + Eina_Bool ret = EINA_FALSE; EINA_SAFETY_ON_NULL_GOTO(e_comp_wl, err); -- 2.7.4 From ed885131fab86d15d279609e056fd15098c84d5d Mon Sep 17 00:00:00 2001 From: Roman Peresipkyn Date: Tue, 10 May 2016 17:05:42 +0300 Subject: [PATCH 16/16] change error handling. move declarations to header Change-Id: I0dcc166eda8c19a7f92f209a373bb80c508131e3 Signed-off-by: Roman Peresipkyn --- src/e_mod_main.c | 667 +++++++++++++++---------------------------------------- src/e_mod_main.h | 177 ++++++++++++++- 2 files changed, 353 insertions(+), 491 deletions(-) diff --git a/src/e_mod_main.c b/src/e_mod_main.c index 76564eb..e1cb81e 100644 --- a/src/e_mod_main.c +++ b/src/e_mod_main.c @@ -10,122 +10,23 @@ #include "eom-server-protocol.h" #include "Ecore_Drm.h" -#define NUM_MAIN_BUF 2 -#define NUM_ATTR 3 - -typedef struct _E_Eom E_Eom, *E_EomPtr; -typedef struct _E_Eom_Out_Mode E_EomOutMode, *E_EomOutModePtr; -typedef struct _E_Eom_Event_Data E_EomEventData, *E_EomEventDataPtr; -typedef struct _E_Eom_Output E_EomOutput, *E_EomOutputPtr; -typedef struct _E_Eom_Fake_Buffers E_EomFakeBuffers, *E_EomFakeBuffersPtr; -typedef struct _E_Eom_Client_Buffer E_EomClientBuffer, *E_EomClientBufferPtr; - - -struct _E_Eom_Out_Mode -{ - int w; - int h; -}; - -struct _E_Eom_Output -{ - unsigned int id; - eom_output_type_e type; - eom_output_mode_e mode; - unsigned int w; - unsigned int h; - unsigned int phys_width; - unsigned int phys_height; - - tdm_output_conn_status status; - unsigned int mirror_run; - eom_output_attribute_e attribute; - eom_output_attribute_state_e attribute_state; - - /* external output data */ - char *ext_output_name; - int is_external_init; - E_EomOutMode src_mode; - E_Comp_Wl_Output *wl_output; - - /* internal output data */ - char *int_output_name; - int is_internal_grab; - E_EomOutMode dst_mode; -}; - -struct _E_Eom -{ - struct wl_global *global; - Eina_List *eom_clients; - Eina_List *handlers; - - tdm_display *dpy; - tbm_bufmgr bufmgr; - int fd; - - Eina_List *outputs; - unsigned int output_count; - -#if 1 - /* eom state */ - enum wl_eom_mode eom_mode; - enum wl_eom_attribute eom_attribute; - enum wl_eom_attribute_state eom_attribute_state; - enum wl_eom_status eom_status; - - /*data related to cooperating with clients */ - int is_mirror_mode; - - /* external output data */ - char *ext_output_name; - int is_external_init; - int id; - E_EomOutMode src_mode; - E_Comp_Wl_Output *wl_output; - - /* internal output data */ - char *int_output_name; - int is_internal_grab; - E_EomOutMode dst_mode; -#endif -}; - -struct _E_Eom_Event_Data -{ - tdm_output *output; - tdm_layer *layer; - tdm_pp *pp; - - /* mirror mode data*/ - tbm_surface_h dst_buffers[NUM_MAIN_BUF]; - int current_buffer; - int pp_buffer; - - /* extended mode data */ - Eina_List *client_buffers_list; -}; - -struct _E_Eom_Client_Buffer -{ - E_Comp_Wl_Buffer *wl_buffer; - tbm_surface_h tbm_buffer; - - unsigned long stamp; -}; - -struct _E_Eom_Fake_Buffers -{ - tbm_surface_h fake_buffers[NUM_MAIN_BUF]; - int current_fake_buffer; -}; - - -static E_EomEventData g_eom_event_data; -E_EomPtr g_eom = NULL; -E_EomFakeBuffers fake_buffers; - E_API E_Module_Api e_modapi = { E_MODULE_API_VERSION, "EOM Module" }; +static E_EomEventData g_eom_event_data; +static E_EomFakeBuffers fake_buffers; +static E_EomPtr g_eom = NULL; + +/* EOM Output Attributes + + +----------------+------------+----------------+-------------+ + | | normal | exclusiv_share | exclusive | + +----------------+------------+----------------+-------------+ + | normal | possible | possible | possible | + +----------------+------------+----------------+-------------+ + | exclusiv_share | impossible | possible | possible | + +----------------+------------+----------------+-------------+ + | exclusive | impossible | impossible | impossible | + +----------------+------------+----------------+-------------+ +*/ static int eom_output_attributes[NUM_ATTR][NUM_ATTR] = { {1, 1, 1}, @@ -133,34 +34,6 @@ static int eom_output_attributes[NUM_ATTR][NUM_ATTR] = {0, 0, 0}, }; -/* handle external output */ -static E_Comp_Wl_Output *_e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id); -static Eina_Bool _e_eom_set_up_external_output(const char *output_name, int width, int height); -static tdm_output * _e_eom_hal_output_get(const char *id); -static tdm_layer * _e_eom_hal_layer_get(tdm_output *output, int width, int height); -static Eina_Bool _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height); -static enum wl_eom_type _e_eom_output_name_to_eom_type(const char *output_name); -/* handle internal output, pp */ -static Eina_Bool _e_eom_mirror_start(const char *output_name, int width, int height); -static tbm_surface_h _e_eom_root_internal_tdm_surface_get(const char *name); -static Eina_Bool _e_eom_pp_src_to_dst( tbm_surface_h src_buffer); -/* tdm handlers */ -static void _e_eom_pp_cb(tbm_surface_h surface, void *user_data); -static void _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, - unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, - void *user_data); - -/* clients buffers */ -static E_EomClientBufferPtr _e_eom_create_client_buffer(E_Comp_Wl_Buffer *wl_buffer, tbm_surface_h tbm_buffer); -static void _e_eom_add_client_buffer_to_list(E_EomClientBufferPtr client_buffer); -static void _e_eom_client_buffers_list_free(); -static E_EomClientBufferPtr _e_eom_get_client_buffer_from_list(); - - -/*eom utils functions*/ -static int _e_eom_get_time_in_mseconds(); -static void _e_eom_create_fake_buffers(int width, int height); - static inline enum wl_eom_mode _e_eom_get_eom_mode() { @@ -227,11 +100,7 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) tdm_error tdm_err = TDM_ERROR_NONE; E_EomEventDataPtr eom_data = NULL; - if (user_data == NULL) - { - EOM_DBG("ERROR: PP EVENT: user data is NULL\n"); - return; - } + RETURNIFTRUE(user_data == NULL, "ERROR: PP EVENT: user data is NULL"); eom_data = (E_EomEventDataPtr)user_data; @@ -240,40 +109,24 @@ _e_eom_pp_cb(tbm_surface_h surface, void *user_data) /* TODO: lock that flag??? */ /* If a client has committed its buffer stop mirror mode */ - if (g_eom->is_mirror_mode == 0) + if (g_eom->is_mirror_mode == DOWN) return; tbm_surface_h src_buffer; src_buffer = _e_eom_root_internal_tdm_surface_get(g_eom->int_output_name); - if (src_buffer == EINA_FALSE) - { - EOM_DBG("ERROR: PP EVENT: get root tdm surfcae\n"); - return; - } + RETURNIFTRUE(src_buffer == NULL, "ERROR: PP EVENT: get root tdm surface"); g_eom_event_data.pp_buffer = !g_eom_event_data.current_buffer; tdm_err = tdm_buffer_add_release_handler(g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer], _e_eom_pp_cb, &g_eom_event_data); - if (tdm_err != TDM_ERROR_NONE) - { - EOM_DBG ("ERROR: PP EVENT: set pp hadler:%d\n", tdm_err ); - return; - } + RETURNIFTRUE(tdm_err != TDM_ERROR_NONE, "ERROR: PP EVENT: set pp hadler:%d", tdm_err ); tdm_err = tdm_pp_attach(eom_data->pp, src_buffer, g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer]); - if (tdm_err != TDM_ERROR_NONE) - { - printf ("ERROR: pp attach:%d\n", tdm_err); - return; - } + RETURNIFTRUE(tdm_err != TDM_ERROR_NONE, "ERROR: pp attach:%d\n", tdm_err); - tdm_err = tdm_pp_commit(g_eom_event_data.pp); - if (tdm_err != TDM_ERROR_NONE) - { - EOM_DBG ("ERROR: PP EVENT: pp commit:%d\n", tdm_err ); - return; - } + tdm_err = tdm_pp_commit(g_eom_event_data.pp); + RETURNIFTRUE(tdm_err != TDM_ERROR_NONE, "ERROR: PP EVENT: pp commit:%d", tdm_err ); } static void @@ -285,16 +138,12 @@ _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUS E_EomEventDataPtr eom_data = NULL; tdm_error err = TDM_ERROR_NONE; - if (user_data == NULL) - { - EOM_ERR("ERROR: EVENT: user_data is NULL\n"); - return; - } + RETURNIFTRUE(user_data == NULL, "ERROR: PP EVENT: user data is NULL"); eom_data = (E_EomEventDataPtr)user_data; /* TODO: Maybe better to separating that callback on to mirror and extended callbacks */ - if (g_eom->is_mirror_mode == 1) + if (g_eom->is_mirror_mode == UP) { if (eom_data->current_buffer == 1) { @@ -302,11 +151,7 @@ _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUS err = tdm_layer_set_buffer(eom_data->layer, eom_data->dst_buffers[!eom_data->pp_buffer]); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: EVENT: set buffer 0\n"); - return; - } + RETURNIFTRUE(err != TDM_ERROR_NONE, "ERROR: EVENT: set buffer 0 err:%d", err); } else { @@ -314,42 +159,22 @@ _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUS err = tdm_layer_set_buffer(eom_data->layer, eom_data->dst_buffers[!eom_data->pp_buffer]); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: EVENT: set buffer 1\n"); - return; - } + RETURNIFTRUE(err != TDM_ERROR_NONE, "ERROR: EVENT: set buffer 1 err:%d", err); } err = tdm_output_commit(eom_data->output, 0, _e_eom_commit_cb, eom_data); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: EVENT: commit\n"); - return; - } + RETURNIFTRUE(err != TDM_ERROR_NONE, "ERROR: EVENT commit"); } else { client_buffer = _e_eom_get_client_buffer_from_list(); - if (client_buffer == NULL) - { - EOM_ERR("ERROR: EVENT: client buffer is NULL\n"); - return; - } + RETURNIFTRUE(client_buffer == NULL, "ERROR: EVENT: client buffer is NULL"); err = tdm_layer_set_buffer(eom_data->layer, client_buffer->tbm_buffer); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: EVENT: set buffer 1\n"); - return; - } + RETURNIFTRUE(err != TDM_ERROR_NONE, "ERROR: EVENT: set buffer 1"); err = tdm_output_commit(eom_data->output, 0, _e_eom_commit_cb, eom_data); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: EVENT: commit\n"); - return; - } + RETURNIFTRUE(err != TDM_ERROR_NONE, "ERROR: EVENT: commit"); } } @@ -400,35 +225,19 @@ _e_eom_set_up_external_output(const char *output_name, int width, int height) eom_data = &g_eom_event_data; hal_output = _e_eom_hal_output_get(output_name); - if (hal_output == NULL) - { - EOM_ERR("ERROR: get hal output for, (%s)\n", output_name); - goto err; - } + GOTOIFTRUE(hal_output == NULL, err, "ERROR: get hal output for, (%s)", output_name); hal_layer = _e_eom_hal_layer_get(hal_output, width, height); - if (hal_layer == NULL) - { - EOM_ERR("ERROR: get hal layer\n"); - goto err; - } + GOTOIFTRUE(hal_layer == NULL, err, "ERROR: get hal layer"); ret = _e_eom_create_output_buffers(eom_data, width, height); - if (ret == EINA_FALSE) - { - EOM_ERR("ERROR: create buffers \n"); - goto err; - } + GOTOIFTRUE(ret == EINA_FALSE, err, "ERROR: create buffers"); /* TODO: Models commited clients buffers */ _e_eom_create_fake_buffers(width, height); tdm_err = tdm_layer_get_info(hal_layer, &layer_info); - if (tdm_err != TDM_ERROR_NONE) - { - EOM_ERR ("ERROR: get layer info: %d", tdm_err); - goto err; - } + GOTOIFTRUE(tdm_err != TDM_ERROR_NONE, err, "ERROR: get layer info: %d", tdm_err); EOM_DBG("LAYER INFO: %dx%d, pos (x:%d, y:%d, w:%d, h:%d, dpos (x:%d, y:%d, w:%d, h:%d))", layer_info.src_config.size.h, layer_info.src_config.size.v, @@ -439,7 +248,6 @@ _e_eom_set_up_external_output(const char *output_name, int width, int height) g_eom->dst_mode.w = width; g_eom->dst_mode.h = height; - /* TODO: free that memory */ g_eom->ext_output_name = strdup(output_name); eom_data->layer = hal_layer; @@ -447,25 +255,13 @@ _e_eom_set_up_external_output(const char *output_name, int width, int height) eom_data->current_buffer = 0; tdm_err = tdm_layer_set_buffer(hal_layer, eom_data->dst_buffers[eom_data->current_buffer]); - if (tdm_err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: set buffer on layer:%d\n", tdm_err); - goto err; - } + GOTOIFTRUE(tdm_err != TDM_ERROR_NONE, err, "ERROR: set buffer on layer:%d", tdm_err); tdm_err = tdm_output_set_dpms(hal_output, TDM_OUTPUT_DPMS_ON); - if (tdm_err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: failed set DPMS on:%d\n", tdm_err); - goto err; - } + GOTOIFTRUE(tdm_err != TDM_ERROR_NONE, err, "ERROR: failed set DPMS on:%d", tdm_err); tdm_err = tdm_output_commit(hal_output, 0, _e_eom_commit_cb, eom_data); - if (tdm_err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: commit crtc:%d\n", tdm_err); - goto err; - } + GOTOIFTRUE(tdm_err != TDM_ERROR_NONE, err, "ERROR: commit crtc:%d", tdm_err); return EINA_TRUE; @@ -553,33 +349,17 @@ _e_eom_hal_output_get(const char *id) } } - if (drm_output == NULL) - { - EOM_ERR("ERROR: drm output was not found\n"); - return NULL; - } + RETURNVALIFTRUE(drm_output == NULL, NULL, "ERROR: drm output was not found"); crtc_id = ecore_drm_output_crtc_id_get(drm_output); - if (crtc_id == 0) - { - EOM_ERR("ERROR: crtc is 0\n"); - return NULL; - } + RETURNVALIFTRUE(crtc_id == 0, NULL, "ERROR: crtc is 0\n"); output = tdm_display_get_output(g_eom->dpy, crtc_id, NULL); - if (output == NULL) - { - EOM_ERR("ERROR: there is no HAL output for:%d\n", crtc_id); - return NULL; - } + RETURNVALIFTRUE(output == NULL, NULL, "ERROR: there is no HAL output for:%d", crtc_id); int min_w, min_h, max_w, max_h, preferred_align; err = tdm_output_get_available_size(output, &min_w, &min_h, &max_w, &max_h, &preferred_align); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: Gent get geometry for hal output"); - return NULL; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, NULL, "ERROR: Gent get geometry for hal output"); EOM_DBG("HAL size min:%dx%d max:%dx%d alighn:%d\n", min_w, min_h, max_w, max_h, preferred_align); @@ -588,11 +368,7 @@ _e_eom_hal_output_get(const char *id) * Force TDM to make setCrtc onto new buffer */ err = tdm_output_get_available_modes(output, &modes, &count); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("Get availvable modes filed\n"); - return NULL; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, NULL, "Get availvable modes filed"); big_mode = &modes[0]; @@ -603,20 +379,12 @@ _e_eom_hal_output_get(const char *id) big_mode = &modes[i]; } - if (big_mode == NULL) - { - EOM_ERR("no Big mode\n"); - return NULL; - } + RETURNVALIFTRUE(big_mode == NULL, NULL, "no Big mode\n"); EOM_DBG("BIG_MODE: %dx%d\n", big_mode->hdisplay, big_mode->vdisplay); err = tdm_output_set_mode(output, big_mode); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("set Mode failed\n"); - return NULL; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, NULL, "set Mode failed"); EOM_DBG("Created output: %p\n", output); return output; @@ -643,18 +411,10 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) for (i = 0; i < count; i++) { layer = (tdm_layer *)tdm_output_get_layer(output, i, &err); - if (err != TDM_ERROR_NONE) - { - EOM_DBG ("tdm_output_get_layer fail(%d)\n", err); - return NULL; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, NULL, "tdm_output_get_layer fail(%d)\n", err); err = tdm_layer_get_capabilities(layer, &capa); - if (err != TDM_ERROR_NONE) - { - EOM_DBG ("tdm_layer_get_capabilities fail(%d)\n", err); - return NULL; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, NULL, "tdm_layer_get_capabilities fail(%d)\n", err); if (capa & TDM_LAYER_CAPABILITY_PRIMARY) { @@ -678,16 +438,11 @@ _e_eom_hal_layer_get(tdm_output *output, int width, int height) layer_info.transform = TDM_TRANSFORM_NORMAL; err = tdm_layer_set_info(layer, &layer_info); - if (err != TDM_ERROR_NONE) - { - EOM_DBG ("tdm_layer_set_info fail(%d)\n", err); - return NULL; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, NULL, "tdm_layer_set_info fail(%d)\n", err); return layer; } - /* TODO: Models commited clients buffers */ static void _e_eom_create_fake_buffers(int width, int height) @@ -696,11 +451,7 @@ _e_eom_create_fake_buffers(int width, int height) tbm_surface_h buffer = NULL; buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); - if (buffer == NULL) - { - EOM_DBG("can not create fake_buffer\n"); - goto err; - } + GOTOIFTRUE(buffer == NULL, err, "can not create fake_buffer\n"); memset(&buffer_info, 0x0, sizeof(tbm_surface_info_s)); if (tbm_surface_map(buffer, @@ -730,11 +481,7 @@ _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height) * TODO: Add support of other formats */ buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); - if (buffer == NULL) - { - EOM_DBG("can not create dst_buffer\n"); - goto err; - } + GOTOIFTRUE(buffer == NULL, err, "can not create dst_buffer 1"); /* * TODO: temp code for testing, actual convert will be in _e_eom_put_src_to_dst() @@ -758,11 +505,7 @@ _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height) * TODO: Add support of other formats */ buffer = tbm_surface_internal_create_with_flags(width, height, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT); - if (buffer == NULL) - { - EOM_DBG("can not create dst_buffer\n"); - goto err; - } + GOTOIFTRUE(buffer == NULL, err, "can not create dst_buffer 2"); /* * TODO: temp code for testing, actual convert will be in _e_eom_put_src_to_dst() @@ -816,11 +559,7 @@ _e_eom_mirror_start(const char *output_name, int width, int height) Eina_Bool ret = EINA_FALSE; src_buffer = _e_eom_root_internal_tdm_surface_get(output_name); - if (src_buffer == NULL) - { - EOM_ERR("ERROR: get root tdm surfcae\n"); - return 0; - } + RETURNVALIFTRUE(src_buffer == NULL, EINA_FALSE, "ERROR: get root tdm surfcae\n"); tbm_surface_get_info(src_buffer, &src_buffer_info ); @@ -830,15 +569,15 @@ _e_eom_mirror_start(const char *output_name, int width, int height) g_eom->src_mode.w = width; g_eom->src_mode.h = height; - /* TODO: free that memory */ g_eom->int_output_name = strdup(output_name); + /* TODO: if internal and external outputs are equal */ + ret = _e_eom_pp_is_needed(g_eom->src_mode.w, g_eom->src_mode.h, + g_eom->dst_mode.w, g_eom->dst_mode.h); + RETURNVALIFTRUE(ret == EINA_FALSE, EINA_TRUE, "pp is not required\n"); + ret = _e_eom_pp_src_to_dst(src_buffer); - if (ret == EINA_FALSE) - { - EOM_ERR("ERROR: init pp\n"); - return ret == EINA_FALSE; - } + RETURNVALIFTRUE(ret == EINA_FALSE, EINA_FALSE, "ERROR: init pp\n"); return EINA_TRUE; } @@ -856,29 +595,17 @@ _e_eom_root_internal_tdm_surface_get(const char *name) primary_output = ecore_drm_device_output_name_find(dev, name); } - if (primary_output == NULL) - { - EOM_ERR("ERROR: get primary output\n"); - return NULL; - } + RETURNVALIFTRUE(primary_output == NULL, NULL, "ERROR: get primary output\n"); /* I think it is more convenient than one upon, but E took first * output as primary and it can be not internal output * primary_output = ecore_drm_output_primary_get(); - if (!primary_output) - { - EOM_ERR("ERROR: get primary output\n"); - return NULL; - } + RETURNVALIFTRUE(primary_output == NULL, NULL, "ERROR: get primary output\n"); */ fb = ecore_drm_display_output_primary_layer_fb_get(primary_output); - if (primary_output == NULL) - { - EOM_ERR("ERROR: get primary frambuffer\n"); - return NULL; - } + RETURNVALIFTRUE(fb == NULL, NULL, "ERROR: get primary frambuffer\n"); /*EOM_DBG("FRAMEBUFFER ECORE_DRM: is_client:%d mode%dx%d\n", fb->from_client, fb->w, fb->h);*/ @@ -892,39 +619,43 @@ _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) tdm_info_pp pp_info; tdm_pp *pp = NULL; + int calc_x; + int calc_width; + pp = tdm_display_create_pp(g_eom->dpy, &err); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: create pp:%d\n", err); - return 0; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, EINA_FALSE, "ERROR: create pp:%d\n", err); + + _e_eom_pp_calculate_new_size(&calc_x, &calc_width, + g_eom->src_mode.w, g_eom->src_mode.h, + g_eom->dst_mode.w, g_eom->dst_mode.h); + + DBG("PP INFO: src:%dx%d dst:%dx%d calc_x:%d calc_width:%d", + g_eom->src_mode.w, g_eom->src_mode.h, + g_eom->dst_mode.w, g_eom->dst_mode.h, + calc_x, calc_width); g_eom_event_data.pp = pp; - pp_info.src_config.size.h = g_eom->src_mode.w; /*1440*/ - pp_info.src_config.size.v = g_eom->src_mode.h; /*2560*/ + pp_info.src_config.size.h = g_eom->src_mode.w; + pp_info.src_config.size.v = g_eom->src_mode.h; pp_info.src_config.pos.x = 0; pp_info.src_config.pos.y = 0; - pp_info.src_config.pos.w = g_eom->src_mode.w; /*1440*/ - pp_info.src_config.pos.h = g_eom->src_mode.h; /*2560*/ + pp_info.src_config.pos.w = g_eom->src_mode.w; + pp_info.src_config.pos.h = g_eom->src_mode.h; pp_info.src_config.format = TBM_FORMAT_ARGB8888; - pp_info.dst_config.size.h = g_eom->dst_mode.w; /*1960*/ - pp_info.dst_config.size.v = g_eom->dst_mode.h; /*1080*/ - pp_info.dst_config.pos.x = 0; + pp_info.dst_config.size.h = calc_width; + pp_info.dst_config.size.v = g_eom->dst_mode.h; + pp_info.dst_config.pos.x = calc_x; pp_info.dst_config.pos.y = 0; - pp_info.dst_config.pos.w = g_eom->dst_mode.w; /*1960*/ - pp_info.dst_config.pos.h = g_eom->dst_mode.h; /*1080*/ + pp_info.dst_config.pos.w = calc_width; + pp_info.dst_config.pos.h = g_eom->dst_mode.h; pp_info.dst_config.format = TBM_FORMAT_ARGB8888; - pp_info.transform = TDM_TRANSFORM_NORMAL;/*TDM_TRANSFORM_NORMAL*/ + pp_info.transform = TDM_TRANSFORM_NORMAL; pp_info.sync = 0; pp_info.flags = 0; err = tdm_pp_set_info(pp, &pp_info); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: set pp info:%d\n", err); - return EINA_FALSE; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, EINA_FALSE, "ERROR: set pp info:%d\n", err); g_eom_event_data.pp_buffer = !g_eom_event_data.current_buffer; EOM_DBG("PP: curr:%d pp:%d\n", @@ -933,30 +664,45 @@ _e_eom_pp_src_to_dst( tbm_surface_h src_buffer) err = tdm_buffer_add_release_handler(g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer], _e_eom_pp_cb, &g_eom_event_data); - if (err != TDM_ERROR_NONE) - { - EOM_ERR ("ERROR: set pp hadler:%d\n", err); - return EINA_FALSE; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, EINA_FALSE, "ERROR: set pp hadler:%d\n", err); err = tdm_pp_attach(pp, src_buffer, g_eom_event_data.dst_buffers[g_eom_event_data.pp_buffer]); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: pp attach:%d\n", err); - return EINA_FALSE; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, EINA_FALSE, "ERROR: pp attach:%d\n", err); err = tdm_pp_commit(g_eom_event_data.pp); - if (err != TDM_ERROR_NONE) - { - EOM_ERR("ERROR: pp commit:%d\n", err); - return EINA_FALSE; - } + RETURNVALIFTRUE(err != TDM_ERROR_NONE, EINA_FALSE, "ERROR: pp commit:%d\n", err); return EINA_TRUE; } +static Eina_Bool +_e_eom_pp_is_needed(int src_w, int src_h, int dst_w, int dst_h) +{ + if (src_w != dst_w) + return EINA_TRUE; + + if (src_h != dst_h) + return EINA_TRUE; + + return EINA_FALSE; +} + +static void +_e_eom_pp_calculate_new_size(int *x, int *new_w, int src_w, int src_h, int dst_w, int dst_h) +{ + float similatiry_coeficient = 0.0; + int mean_dst_width, mean_new_width; + + similatiry_coeficient = dst_h / src_h; + *new_w = (int)similatiry_coeficient * src_w; + + mean_dst_width = dst_w / 2; + mean_new_width = *new_w / 2; + + *x = mean_dst_width - mean_new_width; +} + static int flag = 0; static Eina_Bool @@ -970,9 +716,9 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e Eina_List *l; int ret = 0; - if (!(e = event)) goto end; + if (!(e = event)) goto err; - if (!e->plug) goto end; + if (!e->plug) goto err; EOM_DBG("id:%d (x,y,w,h):(%d,%d,%d,%d) (w_mm,h_mm):(%d,%d) refresh:%d subpixel_order:%d transform:%d make:%s model:%s name:%s plug:%d\n", e->id, e->x, e->y, e->w, e->h, e->phys_width, e->phys_height, e->refresh, e->subpixel_order, e->transform, e->make, e->model, e->name, e->plug); @@ -985,21 +731,13 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e { /* Get e_comp_wl_output */ wl_output = _e_eom_e_comp_wl_output_get(e_comp_wl->outputs, buff); - if (!wl_output) - { - EOM_ERR("ERROR: there is no wl_output:(%s)\n", buff); - goto end; - } + GOTOIFTRUE(wl_output == NULL, err, "ERROR: there is no wl_output:(%s)\n", buff); /* Initialize external output */ ret = _e_eom_set_up_external_output(buff, e->w, e->h); - if (!ret) - { - EOM_ERR("ERROR: initialize external output\n"); - goto end; - } + GOTOIFTRUE(ret == EINA_FALSE, err, "ERROR: initialize external output\n"); - g_eom->is_external_init = 1; + g_eom->is_external_init = UP; g_eom->id = e->id; g_eom->wl_output = wl_output; @@ -1010,8 +748,8 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e } else { - g_eom->is_external_init = 0; - g_eom->is_internal_grab = 0; + g_eom->is_external_init = DOWN; + g_eom->is_internal_grab = DOWN; g_eom->wl_output = NULL; g_eom->id = -1; @@ -1024,11 +762,7 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e } eom_type = _e_eom_output_name_to_eom_type(buff); - if (eom_type == WL_EOM_TYPE_NONE) - { - EOM_ERR("ERROR: eom_type is NONE\n"); - goto end; - } + GOTOIFTRUE(eom_type == WL_EOM_TYPE_NONE, err, "ERROR: eom_type is NONE\n"); EINA_LIST_FOREACH(g_eom->eom_clients, l, resource_iterator) { @@ -1051,23 +785,19 @@ _e_eom_ecore_drm_output_cb(void *data EINA_UNUSED, int type EINA_UNUSED, void *e } } } - else if (strcmp(e->name, "DSI-0") == 0 && g_eom->is_external_init && flag == 2) + else if (strcmp(e->name, "DSI-0") == 0 && g_eom->is_external_init == UP && flag == 2) { /*TODO: add support of internal and external output of same size */ ret = _e_eom_mirror_start(buff, e->w, e->h); - if (!ret) - { - EOM_ERR("ERROR: get root surfcae\n"); - goto end; - } + GOTOIFTRUE(ret == EINA_FALSE, err, "ERROR: get root surfcae\n"); - g_eom->is_internal_grab = 1; - g_eom->is_mirror_mode = 1; + g_eom->is_internal_grab = UP; + g_eom->is_mirror_mode = UP; } ++flag; -end: +err: return ECORE_CALLBACK_PASS_ON; } @@ -1078,6 +808,7 @@ _e_eom_client_buffer_change(void *data, int type, void *event) E_EomClientBufferPtr client_buffer = NULL; E_Event_Client *ev = event; E_Client *ec = NULL; + Eina_Bool ret_err; /* tbm_surface_h external_tbm_buffer = NULL; tbm_surface_info_s surface_info; @@ -1100,21 +831,18 @@ _e_eom_client_buffer_change(void *data, int type, void *event) * TODO: Make all goto same, not err, end, ret etc. */ /*We are not interested in non external clients*/ - if (e_client_is_external_output_client(ec) != EINA_TRUE) - { - EOM_ERR("ERROR: BUFF CHANGE: ec is not external\n"); - return ECORE_CALLBACK_PASS_ON; - } + ret_err = e_client_is_external_output_client(ec); + RETURNVALIFTRUE(ret_err != EINA_TRUE, + ECORE_CALLBACK_PASS_ON, + "ERROR: BUFF CHANGE: ec is not external\n"); if (ec->pixmap == NULL) return ECORE_CALLBACK_PASS_ON; external_wl_buffer = e_pixmap_resource_get(ec->pixmap); - if (external_wl_buffer == NULL) - { - EOM_ERR("ERROR:BUFF CHANGE: wl buffer is NULL\n"); - return ECORE_CALLBACK_PASS_ON; - } + RETURNVALIFTRUE(external_wl_buffer == NULL, + ECORE_CALLBACK_PASS_ON, + "ERROR:BUFF CHANGE: wl buffer is NULL\n"); EOM_DBG("BUFF CHANGE: wl_buff:%dx%d", external_wl_buffer->w, @@ -1157,16 +885,14 @@ _e_eom_client_buffer_change(void *data, int type, void *event) /* TODO: Must find proper way of getting tbm_surface */ /*client_buffer = _e_eom_create_client_buffer(external_wl_buffer, external_tbm_buffer);*/ client_buffer = _e_eom_create_client_buffer(external_wl_buffer, fake_buffers.fake_buffers[0]); - if (client_buffer == NULL) - { - EOM_ERR("ERROR: BUFF CHANGE: alloc client buffer"); - return ECORE_CALLBACK_PASS_ON; - } + RETURNVALIFTRUE(client_buffer == NULL, + ECORE_CALLBACK_PASS_ON, + "ERROR: BUFF CHANGE: alloc client buffer"); _e_eom_add_client_buffer_to_list(client_buffer); /* Stop mirror mode */ - g_eom->is_mirror_mode = 0; + g_eom->is_mirror_mode = DOWN; return ECORE_CALLBACK_PASS_ON; } @@ -1311,21 +1037,19 @@ _e_eom_wl_request_set_attribute_cb(struct wl_client *client, struct wl_resource /* If client has set WL_EOM_ATTRIBUTE_NONE, eom will be * switched to mirror mode */ - if (attribute == WL_EOM_ATTRIBUTE_NONE && g_eom->is_mirror_mode == 0) + if (attribute == WL_EOM_ATTRIBUTE_NONE && g_eom->is_mirror_mode == DOWN) { - g_eom->is_mirror_mode = 1; + g_eom->is_mirror_mode = UP; _e_eom_client_buffers_list_free(); ret = _e_eom_mirror_start(g_eom->int_output_name, g_eom->src_mode.w, g_eom->src_mode.h); - if (ret == EINA_FALSE) - { - EOM_ERR("ERROR: restore mirror mode after a client disconnection\n"); - goto err; - } - } + GOTOIFTRUE(ret == EINA_FALSE, + err, + "ERROR: restore mirror mode after a client disconnection\n"); + } } err: @@ -1381,20 +1105,17 @@ _e_eom_wl_resource_destory_cb(struct wl_resource *resource) /* If a client has been disconnected and eom has not been * restored to mirror mode, start mirror mode */ - if (g_eom->is_mirror_mode == 0) + if (g_eom->is_mirror_mode == DOWN) { - g_eom->is_mirror_mode = 1; + g_eom->is_mirror_mode = UP; _e_eom_client_buffers_list_free(); ret = _e_eom_mirror_start(g_eom->int_output_name, g_eom->src_mode.w, g_eom->src_mode.h); - if (ret == EINA_FALSE) - { - EOM_ERR("ERROR: restore mirror mode after a client disconnection\n"); - return; - } + RETURNIFTRUE(ret == EINA_FALSE, + "ERROR: restore mirror mode after a client disconnection\n"); /* Notify eom clients that eom state has been changed */ EINA_LIST_FOREACH(g_eom->eom_clients, l, resource_iterator) @@ -1419,11 +1140,7 @@ _e_eom_wl_bind_cb(struct wl_client *client, void *data, uint32_t version, uint32 enum wl_eom_type eom_type = WL_EOM_TYPE_NONE; struct wl_resource *resource = NULL; - if (data == NULL) - { - EOM_ERR("ERROR: data is NULL"); - return; - } + RETURNIFTRUE(data == NULL, "ERROR: data is NULL"); E_EomPtr eom = data; @@ -1511,17 +1228,12 @@ _e_eom_output_info_get(tdm_display *dpy) ret = tdm_display_get_output_count(dpy, &count); - if (ret != TDM_ERROR_NONE) - { - EOM_ERR("tdm_display_get_output_count fail\n"); - return EINA_FALSE; - } - - if (count <= 1) - { - EOM_DBG("output count is 1. device doesn't support external outputs.\n"); - return EINA_FALSE; - } + RETURNVALIFTRUE(ret != TDM_ERROR_NONE, + EINA_FALSE, + "tdm_display_get_output_count fail"); + RETURNVALIFTRUE(count <= 1, + EINA_FALSE, + "output count is 1. device doesn't support external outputs.\n"); g_eom->output_count = count - 1; EOM_DBG("external output count : %d\n", g_eom->output_count); @@ -1536,35 +1248,28 @@ _e_eom_output_info_get(tdm_display *dpy) tdm_output_type type; output = tdm_display_get_output(dpy, i, &ret); - if (ret != TDM_ERROR_NONE) - { - EOM_ERR("tdm_display_get_output fail(ret:%d)", ret); - goto err; - } + GOTOIFTRUE(ret != TDM_ERROR_NONE, + err, + "tdm_display_get_output fail(ret:%d)", ret); - if (output == NULL) - { - EOM_ERR("tdm_display_get_output fail(no output:%d)", ret); - goto err; - } + GOTOIFTRUE(output == NULL, + err, + "tdm_display_get_output fail(no output:%d)", ret); ret = tdm_output_get_output_type(output, &type); - if (ret != TDM_ERROR_NONE) - { - EOM_ERR("tdm_output_get_output_type fail(%d)", ret); - goto err; - } + GOTOIFTRUE(ret != TDM_ERROR_NONE, + err, + "tdm_output_get_output_type fail(%d)", ret); + /* skip main output */ /* TODO: need more check about main display*/ if ((type == TDM_OUTPUT_TYPE_DSI) || (type == TDM_OUTPUT_TYPE_LVDS)) continue; new_output = E_NEW(E_EomOutput, 1); - if (new_output == NULL) - { - EOM_ERR("calloc fail"); - goto err; - } + GOTOIFTRUE(new_output == NULL, + err, + "calloc fail"); ret = tdm_output_get_conn_status(output, &status); if (ret != TDM_ERROR_NONE) @@ -1594,11 +1299,13 @@ _e_eom_output_info_get(tdm_display *dpy) free(new_output); goto err; } + if (mode == NULL) { new_output->w = 0; new_output->h = 0; } + else { new_output->w = mode->hdisplay; @@ -1623,8 +1330,8 @@ _e_eom_output_info_get(tdm_display *dpy) } return EINA_TRUE; -err: +err: if (g_eom->outputs) { Eina_List *l; @@ -1646,25 +1353,13 @@ _e_eom_init_internal() tdm_error ret = TDM_ERROR_NONE; g_eom->dpy = tdm_display_init(&ret); - if (ret != TDM_ERROR_NONE) - { - EOM_ERR("tdm_display_init fail\n"); - goto err; - } + GOTOIFTRUE(ret != TDM_ERROR_NONE, err, "tdm_display_init fail"); ret = tdm_display_get_fd(g_eom->dpy, &g_eom->fd); - if (ret != TDM_ERROR_NONE) - { - EOM_ERR("tdm_display_get_fd fail\n"); - goto err; - } + GOTOIFTRUE(ret != TDM_ERROR_NONE, err, "tdm_display_get_fd fail"); g_eom->bufmgr = tbm_bufmgr_init(g_eom->fd); - if (!g_eom->bufmgr) - { - EOM_ERR("tbm_bufmgr_init fail\n"); - goto err; - } + GOTOIFTRUE(g_eom->bufmgr == NULL, err, "tbm_bufmgr_init fail"); if (_e_eom_output_info_get(g_eom->dpy) != EINA_TRUE) { @@ -1703,18 +1398,14 @@ _e_eom_init() EINA_SAFETY_ON_NULL_GOTO(g_eom->global, err); ret = _e_eom_init_internal(); - if (ret == EINA_FALSE) - { - EOM_ERR("failed init_internal()"); - goto err; - } + GOTOIFTRUE(ret == EINA_FALSE, err, "failed init_internal()"); E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_ACTIVATE, _e_eom_ecore_drm_activate_cb, g_eom); E_LIST_HANDLER_APPEND(g_eom->handlers, ECORE_DRM_EVENT_OUTPUT, _e_eom_ecore_drm_output_cb, g_eom); E_LIST_HANDLER_APPEND(g_eom->handlers, E_EVENT_CLIENT_BUFFER_CHANGE, _e_eom_client_buffer_change, NULL); - g_eom->is_external_init = 0; - g_eom->is_internal_grab = 0; + g_eom->is_external_init = DOWN; + g_eom->is_internal_grab = DOWN; g_eom->ext_output_name = NULL; g_eom->int_output_name = NULL; diff --git a/src/e_mod_main.h b/src/e_mod_main.h index 94675fc..b004dc6 100644 --- a/src/e_mod_main.h +++ b/src/e_mod_main.h @@ -1,14 +1,37 @@ #ifndef E_MOD_MAIN_H #define E_MOD_MAIN_H +#include "eom-server-protocol.h" + #define CHECK_ERR(val) if (WL_KEYROUTER_ERROR_NONE != val) return; #define CHECK_ERR_VAL(val) if (WL_KEYROUTER_ERROR_NONE != val) return val; #define CHECK_NULL(val) if (!val) return; #define CHECK_NULL_VAL(val) if (!val) return val; -#define EOM_ERR(msg, ARG...) ERR("[eom module][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) -#define EOM_WARN(msg, ARG...) WARN("[eom module][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) -#define EOM_DBG(msg, ARG...) DBG("[eom module][%s:%d] "msg, __FUNCTION__, __LINE__, ##ARG) +#define EOM_ERR(msg, ARG...) ERR("[eom module][%s:%d] "msg"\n", __FUNCTION__, __LINE__, ##ARG) +#define EOM_WARN(msg, ARG...) WARN("[eom module][%s:%d] "msg"\n", __FUNCTION__, __LINE__, ##ARG) +#define EOM_DBG(msg, ARG...) DBG("[eom module][%s:%d] "msg"\n", __FUNCTION__, __LINE__, ##ARG) + +#define RETURNIFTRUE(statement, msg, ARG...) \ +if (statement) \ +{ \ + EOM_ERR( msg, ##ARG); \ + return; \ +} + +#define RETURNVALIFTRUE(statement, ret, msg, ARG...) \ +if (statement) \ +{ \ + EOM_ERR( msg, ##ARG); \ + return ret; \ +} + +#define GOTOIFTRUE(statement, lable, msg, ARG...) \ +if (statement) \ +{ \ + EOM_ERR( msg, ##ARG); \ + goto lable; \ +} /* E Module */ E_API extern E_Module_Api e_modapi; @@ -16,4 +39,152 @@ E_API void *e_modapi_init(E_Module *m); E_API int e_modapi_shutdown(E_Module *m); E_API int e_modapi_save(E_Module *m); +#define NUM_MAIN_BUF 2 +#define NUM_ATTR 3 + +typedef struct _E_Eom E_Eom, *E_EomPtr; +typedef struct _E_Eom_Out_Mode E_EomOutMode, *E_EomOutModePtr; +typedef struct _E_Eom_Event_Data E_EomEventData, *E_EomEventDataPtr; +typedef struct _E_Eom_Output E_EomOutput, *E_EomOutputPtr; +typedef struct _E_Eom_Fake_Buffers E_EomFakeBuffers, *E_EomFakeBuffersPtr; +typedef struct _E_Eom_Client_Buffer E_EomClientBuffer, *E_EomClientBufferPtr; + +typedef enum +{ + DOWN = 0, + UP, +} E_EomFlag; + +struct _E_Eom_Out_Mode +{ + int w; + int h; +}; + +struct _E_Eom_Output +{ + unsigned int id; + eom_output_type_e type; + eom_output_mode_e mode; + unsigned int w; + unsigned int h; + unsigned int phys_width; + unsigned int phys_height; + + tdm_output_conn_status status; + E_EomFlag mirror_run; + eom_output_attribute_e attribute; + eom_output_attribute_state_e attribute_state; + + /* external output data */ + char *ext_output_name; + E_EomFlag is_external_init; + E_EomOutMode src_mode; + E_Comp_Wl_Output *wl_output; + + /* internal output data */ + char *int_output_name; + E_EomFlag is_internal_grab; + E_EomOutMode dst_mode; +}; + +struct _E_Eom +{ + struct wl_global *global; + Eina_List *eom_clients; + Eina_List *handlers; + + tdm_display *dpy; + tbm_bufmgr bufmgr; + int fd; + + Eina_List *outputs; + unsigned int output_count; + +#if 1 + /* eom state */ + enum wl_eom_mode eom_mode; + enum wl_eom_attribute eom_attribute; + enum wl_eom_attribute_state eom_attribute_state; + enum wl_eom_status eom_status; + + /*data related to cooperating with clients */ + E_EomFlag is_mirror_mode; + + /* external output data */ + char *ext_output_name; + E_EomFlag is_external_init; + int id; + E_EomOutMode src_mode; + E_Comp_Wl_Output *wl_output; + + /* internal output data */ + char *int_output_name; + E_EomFlag is_internal_grab; + E_EomOutMode dst_mode; +#endif +}; + +struct _E_Eom_Event_Data +{ + tdm_output *output; + tdm_layer *layer; + tdm_pp *pp; + + /* mirror mode data*/ + tbm_surface_h dst_buffers[NUM_MAIN_BUF]; + int current_buffer; + int pp_buffer; + + /* extended mode data */ + Eina_List *client_buffers_list; +}; + +struct _E_Eom_Client_Buffer +{ + E_Comp_Wl_Buffer *wl_buffer; + tbm_surface_h tbm_buffer; + + unsigned long stamp; +}; + +struct _E_Eom_Fake_Buffers +{ + tbm_surface_h fake_buffers[NUM_MAIN_BUF]; + int current_fake_buffer; +}; + + +/* handle external output */ +static E_Comp_Wl_Output *_e_eom_e_comp_wl_output_get(const Eina_List *outputs, const char *id); +static Eina_Bool _e_eom_set_up_external_output(const char *output_name, int width, int height); +static tdm_output * _e_eom_hal_output_get(const char *id); +static tdm_layer * _e_eom_hal_layer_get(tdm_output *output, int width, int height); +static Eina_Bool _e_eom_create_output_buffers(E_EomEventDataPtr eom_data, int width, int height); +static enum wl_eom_type _e_eom_output_name_to_eom_type(const char *output_name); + +/* handle internal output, pp */ +static Eina_Bool _e_eom_mirror_start(const char *output_name, int width, int height); +static tbm_surface_h _e_eom_root_internal_tdm_surface_get(const char *name); +static Eina_Bool _e_eom_pp_src_to_dst( tbm_surface_h src_buffer); +static Eina_Bool _e_eom_pp_is_needed(int src_w, int src_h, int dst_w, int dst_h); +static void _e_eom_pp_calculate_new_size(int *x, int *new_w, int src_w, int src_h, int dst_w, int dst_h); + +/* tdm handlers */ +static void _e_eom_pp_cb(tbm_surface_h surface, void *user_data); +static void _e_eom_commit_cb(tdm_output *output EINA_UNUSED, unsigned int sequence EINA_UNUSED, + unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, + void *user_data); + +/* clients buffers */ +static E_EomClientBufferPtr _e_eom_create_client_buffer(E_Comp_Wl_Buffer *wl_buffer, tbm_surface_h tbm_buffer); +static void _e_eom_add_client_buffer_to_list(E_EomClientBufferPtr client_buffer); +static void _e_eom_client_buffers_list_free(); +static E_EomClientBufferPtr _e_eom_get_client_buffer_from_list(); + +/*eom utils functions*/ +static int _e_eom_get_time_in_mseconds(); +static void _e_eom_create_fake_buffers(int width, int height); + + #endif -- 2.7.4