e_hwc: add some e_client_hwc api 56/200156/3
authorSooChan Lim <sc1.lim@samsung.com>
Thu, 14 Feb 2019 09:57:04 +0000 (18:57 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 7 Mar 2019 08:17:00 +0000 (08:17 +0000)
e modules can set and get the hwc properties.
The apis are below.
E_API Eina_Bool       e_client_hwc_available_properties_get(E_Client *ec, const hwc_prop **props, int *count);
E_API Eina_Bool       e_client_hwc_property_get(E_Client *ec, unsigned int id, hwc_value *value);
E_API Eina_Bool       e_client_hwc_property_set(E_Client *ec, unsigned int id, hwc_value value);

Change-Id: I88cbd2f2d6b967fda1e6ab2443d42c033b277d48

src/bin/e_hwc.c
src/bin/e_hwc.h

index 532e7cad7f057c0ddc60e3a8a63ec87d21210db6..ec70487e9f8ee17ea18aa106039796c2e57312e2 100644 (file)
@@ -473,3 +473,125 @@ e_hwc_client_is_above_hwc(E_Client *ec, E_Client *hwc_ec)
 
    return EINA_FALSE;
 }
+
+E_API Eina_Bool
+e_client_hwc_available_properties_get(E_Client *ec, const hwc_prop **props, int *count)
+{
+   E_Hwc *hwc;
+   E_Output *output;
+   E_Zone *zone;
+   E_Hwc_Window *hwc_window;
+   E_Hwc_Window_State state;
+   const tdm_prop *tprops;
+   int i;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(count, EINA_FALSE);
+   zone = ec->zone;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(zone, EINA_FALSE);
+   output = e_output_find(zone->output_id);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(output, EINA_FALSE);
+   hwc = output->hwc;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc, EINA_FALSE);
+   hwc_window = ec->hwc_window;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_window, EINA_FALSE);
+
+   state = e_hwc_window_state_get(hwc_window);
+   if (state == E_HWC_WINDOW_STATE_VIDEO)
+     {
+        if (!e_hwc_windows_get_video_available_properties(hwc, &tprops, count))
+          {
+             ERR("e_hwc_windows_get_video_available_properties failed");
+             return EINA_FALSE;
+          }
+     }
+   else
+     {
+        if (!e_hwc_windows_get_available_properties(hwc, &tprops, count))
+          {
+             ERR("e_hwc_windows_get_available_properties failed");
+             return EINA_FALSE;
+          }
+     }
+
+   *props = (hwc_prop *)tprops;
+
+   if (state == E_HWC_WINDOW_STATE_VIDEO)
+     ELOGF("HWC", ">>>>>>>> Available VIDEO props : count = %d", NULL, NULL, *count);
+   else
+     ELOGF("HWC", ">>>>>>>> Available UI props : count = %d", NULL, NULL, *count);
+   for (i = 0; i < *count; i++)
+     ELOGF("HWC", "   [%d] %s, %u", NULL, NULL, i, tprops[i].name, tprops[i].id);
+
+   return EINA_TRUE;
+}
+
+E_API Eina_Bool
+e_client_hwc_property_get(E_Client *ec, unsigned int id, hwc_value *value)
+{
+   E_Hwc_Window *hwc_window;
+   tdm_value tvalue;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(value, EINA_FALSE);
+   hwc_window = ec->hwc_window;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_window, EINA_FALSE);
+
+   if (!e_hwc_window_get_property(hwc_window, id, &tvalue))
+     {
+        ERR("e_hwc_window_get_property failed");
+        return EINA_FALSE;
+     }
+
+   memcpy(&value->ptr, &tvalue.ptr, sizeof(tdm_value));
+
+   return EINA_TRUE;
+}
+
+const char *
+_e_client_hwc_prop_name_get_by_id(E_Client *ec, unsigned int id)
+{
+   const hwc_prop *props;
+   int i, count = 0;
+
+   if (!e_client_hwc_available_properties_get(ec, &props, &count))
+     {
+        ERR("e_client_hwc_available_properties_get failed.");
+        return EINA_FALSE;
+     }
+
+   for (i = 0; i < count; i++)
+     {
+        if (props[i].id == id)
+          return props[i].name;
+     }
+
+   ERR("No available property: id %d", id);
+
+   return NULL;
+}
+
+E_API Eina_Bool
+e_client_hwc_property_set(E_Client *ec, unsigned int id, hwc_value value)
+{
+   E_Hwc_Window *hwc_window;
+   const char *name;
+   tdm_value tvalue;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+   hwc_window = ec->hwc_window;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(hwc_window, EINA_FALSE);
+
+   name = _e_client_hwc_prop_name_get_by_id(ec, id);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
+
+   memcpy(&tvalue.ptr, &value.ptr, sizeof(hwc_value));
+
+   if (!e_hwc_window_set_property(hwc_window, id, name, tvalue, EINA_TRUE))
+     {
+        ERR("e_hwc_window_set_property failed");
+        return EINA_FALSE;
+     }
+
+   return EINA_TRUE;
+}
index 4cd1d6eb701073db0a4f4dcfb0b349d768290e60..30d627d211124e1017d3709837572a4e5af0d0b0 100644 (file)
@@ -2,6 +2,8 @@
 
 typedef struct _E_Hwc     E_Hwc;
 
+#define HWC_NAME_LEN 64
+
 typedef enum _E_Hwc_Mode
 {
    E_HWC_MODE_NONE = 0,
@@ -23,6 +25,32 @@ typedef enum _E_Hwc_Intercept_Hook_Point
    E_HWC_INTERCEPT_HOOK_LAST,
 } E_Hwc_Intercept_Hook_Point;
 
+/*The hwc value type enumeration */
+typedef enum {
+       HWC_VALUE_TYPE_UNKNOWN,
+       HWC_VALUE_TYPE_PTR,
+       HWC_VALUE_TYPE_INT32,
+       HWC_VALUE_TYPE_UINT32,
+       HWC_VALUE_TYPE_INT64,
+       HWC_VALUE_TYPE_UINT64,
+} hwc_value_type;
+
+/*brief The hwc value union */
+typedef union {
+       void     *ptr;
+       int32_t  s32;
+       uint32_t u32;
+       int64_t  s64;
+       uint64_t u64;
+} hwc_value;
+
+/* The property of the hwc client */
+typedef struct _hwc_prop {
+       unsigned int id;
+       char name[HWC_NAME_LEN];
+       hwc_value_type type;
+} hwc_prop;
+
 typedef Eina_Bool (*E_Hwc_Intercept_Hook_Cb)(void *data, E_Hwc *hwc);
 typedef struct _E_Hwc_Intercept_Hook E_Hwc_Intercept_Hook;
 
@@ -104,8 +132,12 @@ EINTERN Eina_Bool     e_hwc_client_is_above_hwc(E_Client *ec, E_Client *hwc_ec);
 
 EINTERN Eina_Bool     e_hwc_intercept_hook_call(E_Hwc_Intercept_Hook_Point hookpoint, E_Hwc *hwc);
 
-E_API E_Hwc_Intercept_Hook *e_hwc_intercept_hook_add(E_Hwc_Intercept_Hook_Point hookpoint, E_Hwc_Intercept_Hook_Cb func, const void *data);
-E_API void e_hwc_intercept_hook_del(E_Hwc_Intercept_Hook *ch);
+E_API E_Hwc_Intercept_Hook   *e_hwc_intercept_hook_add(E_Hwc_Intercept_Hook_Point hookpoint, E_Hwc_Intercept_Hook_Cb func, const void *data);
+E_API void                    e_hwc_intercept_hook_del(E_Hwc_Intercept_Hook *ch);
+
+E_API Eina_Bool       e_client_hwc_available_properties_get(E_Client *ec, const hwc_prop **props, int *count);
+E_API Eina_Bool       e_client_hwc_property_get(E_Client *ec, unsigned int id, hwc_value *value);
+E_API Eina_Bool       e_client_hwc_property_set(E_Client *ec, unsigned int id, hwc_value value);
 
 #endif
 #endif