/* 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,
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
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;
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;
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;
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)
{
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)
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;
goto err;
}
-
- return 1;
+ return EINA_TRUE;
err:
/*
* TODO: add deinitialization
*/
- return 0;
+ return EINA_FALSE;
}
static void
}
}
+ 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;
}
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
}
}
- if (!drm_output)
+ if (drm_output == NULL)
{
EOM_ERR("ERROR: drm output was not found\n");
return NULL;
}
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;
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;
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;
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;
* 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;
eom_data->dst_buffers[1] = buffer;
- return 1;
+ return EINA_TRUE;
err:
/*
* Add deinitialization
*/
- return 0;
+ return EINA_FALSE;
}
static enum wl_eom_type
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;
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
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
*/
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;
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)
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*/
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;
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);
{
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);
goto end;
}
- g_eom->wl_output = wl_output;
-
EINA_LIST_FOREACH(g_eom->eom_clients, l, resource_iterator)
{
if (resource_iterator)
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;
*/
/* 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;
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 */
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*/
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");
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;
if (g_eom->outputs)
{
Eina_List *l;
- E_EomOutputPtr output;
+ E_EomOutputPtr output = NULL;
EINA_LIST_FOREACH(g_eom->outputs, l, output)
{
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");
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;
_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);
if (g_eom->outputs)
{
Eina_List *l;
- E_EomOutputPtr output;
+ E_EomOutputPtr output = NULL;
EINA_LIST_FOREACH(g_eom->outputs, l, output)
{
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)
{
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)
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)
goto err;
}
- if (!output)
+ if (output == NULL)
{
EOM_ERR("tdm_display_get_output fail(no output:%d)", ret);
goto err;
continue;
new_output = E_NEW(E_EomOutput, 1);
- if (!new_output)
+ if (new_output == NULL)
{
EOM_ERR("calloc fail");
goto 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);