summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <cp.michael@samsung.com>2019-01-29 12:13:34 -0500
committerChristopher Michael <cp.michael@samsung.com>2019-03-13 12:11:32 -0400
commit42fdab6f96defede0446040ef8bed7b62a8c9ceb (patch)
treec09a9d00f0a159ec61d253d0bda50804a23e4b39
parent8659f5979ca0762273ea04df040ae06c035477f7 (diff)
downloadefl-devs/devilhorns/evas_drm.tar.gz
evas-drm: Add start of new evas drm enginedevs/devilhorns/evas_drm
-rw-r--r--src/modules/evas/engines/drm/evas_engine.c155
-rw-r--r--src/modules/evas/engines/drm/evas_outbuf.c104
2 files changed, 259 insertions, 0 deletions
diff --git a/src/modules/evas/engines/drm/evas_engine.c b/src/modules/evas/engines/drm/evas_engine.c
new file mode 100644
index 0000000000..a8791ae8ee
--- /dev/null
+++ b/src/modules/evas/engines/drm/evas_engine.c
@@ -0,0 +1,155 @@
+#include "evas_engine.h"
+
+typedef struct _Render_Engine
+{
+ Render_Output_Software_Generic generic;
+} Render_Engine;
+
+static Evas_Func func, pfunc;
+
+int _evas_engine_drm_log_dom;
+
+/* engine functions we override */
+static void
+eng_output_info_setup(void *info)
+{
+ Evas_Engine_Info_Drm *einfo;
+
+ DBG("Engine Info Setup");
+
+ einfo = info;
+ einfo->render_mode = EVAS_RENDER_MODE_BLOCKING;
+}
+
+static void *
+eng_output_setup(void *engine, void *info, unsigned int w, unsigned int h)
+{
+ Evas_Engine_Info_Drm *einfo;
+ Render_Engine *re;
+ Outbuf *ob;
+
+ einfo = info;
+
+ re = calloc(1, sizeof(Render_Engine));
+ if (!re) return NULL;
+
+ ob = _outbuf_setup(einfo, w, h);
+ if (!ob) goto err;
+
+ if (!evas_render_engine_software_generic_init(engine, &re->generic, ob,
+ NULL, //swap_mode_get
+ _outbuf_get_rotation,
+ _outbuf_reconfigure,
+ NULL, //region_first_rect
+ NULL, //damage_region_set
+ _outbuf_new_region_for_update,
+ NULL, //push_updated_region
+ NULL, //free_region_for_update
+ NULL, //idle_flush
+ NULL, //flush
+ NULL, //redraws_clear
+ _outbuf_free, //free
+ w, h))
+ goto init_err;
+
+ evas_render_engine_software_generic_merge_mode_set(&re->generic);
+
+ re->generic.ob->info = einfo;
+
+ return re;
+
+init_err:
+ evas_render_engine_software_generic_clean(engine, &re->generic);
+err:
+ free(re);
+ return NULL;
+}
+
+static void
+eng_output_free(void *engine, void *data)
+{
+ Render_Engine *re;
+
+ re = data;
+ evas_render_engine_software_generic_clean(engine, &re->generic);
+ free(re);
+}
+
+static int
+eng_output_update(void *engine EINA_UNUSED, void *data, void *info, unsigned int w, unsigned int h)
+{
+ Outbuf *ob;
+ Render_Engine *re;
+ Evas_Engine_Info_Drm *einfo;
+
+ re = data;
+ einfo = info;
+ ob = re->generic.ob;
+
+ if ((ob->w != (int)w) || (ob->h != (int)h) ||
+ (ob->rotation != (int)einfo->info.rotation))
+ {
+ _outbuf_reconfigure(ob, w, h, einfo->info.rotation, einfo->info.depth);
+ evas_render_engine_software_generic_update(&re->generic, ob, w, h);
+ }
+
+ return 1;
+}
+
+/* module functions */
+static int
+module_open(Evas_Module *em)
+{
+ if (!em) return 0;
+
+ /* try to inherit functions from software_generic engine */
+ if (!_evas_module_engine_inherit(&pfunc, "software_generic",
+ sizeof(Evas_Engine_Info_Drm)))
+ return 0;
+
+ /* register eina logging domain */
+ _evas_engine_drm_log_dom =
+ eina_log_domain_register("evas-drm", EVAS_DEFAULT_LOG_COLOR);
+ if (_evas_engine_drm_log_dom < 0)
+ {
+ EINA_LOG_ERR("Could not create module log domain");
+ return 0;
+ }
+
+ /* store parent engine functions so we can override the ones we want */
+ func = pfunc;
+
+ /* override engine functions we provide */
+#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
+ ORD(output_info_setup);
+ ORD(output_setup);
+ ORD(output_free);
+ ORD(output_update);
+
+ /* advertise our engine functions */
+ em->functions = (void *)(&func);
+
+ return 1;
+}
+
+static void
+module_close(Evas_Module *em EINA_UNUSED)
+{
+ /* unregister eina logging domain */
+ if (_evas_engine_drm_log_dom >= 0)
+ {
+ eina_log_domain_unregister(_evas_engine_drm_log_dom);
+ _evas_engine_drm_log_dom = -1;
+ }
+}
+
+static Evas_Module_Api evas_modapi =
+{
+ EVAS_MODULE_API_VERSION, "drm", "none", { module_open, module_close }
+};
+
+EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, drm);
+
+#ifndef EVAS_STATIC_BUILD_DRM
+EVAS_EINA_MODULE_DEFINE(engine, drm);
+#endif
diff --git a/src/modules/evas/engines/drm/evas_outbuf.c b/src/modules/evas/engines/drm/evas_outbuf.c
new file mode 100644
index 0000000000..1731d56806
--- /dev/null
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -0,0 +1,104 @@
+#include "evas_engine.h"
+#include <drm_fourcc.h>
+
+Outbuf *
+_outbuf_setup(Evas_Engine_Info_Drm *einfo, int w, int h)
+{
+ Outbuf *ob;
+
+ ob = calloc(1, sizeof(Outbuf));
+ if (!ob) return NULL;
+
+ DBG("Outbuf %p Setup: %d %d", ob, w, h);
+
+ ob->w = w;
+ ob->h = h;
+ ob->bpp = einfo->info.bpp;
+ ob->depth = einfo->info.depth;
+ ob->alpha = einfo->info.alpha;
+ ob->format = einfo->info.format;
+ ob->rotation = einfo->info.rotation;
+
+ return ob;
+}
+
+void
+_outbuf_free(Outbuf *ob)
+{
+ DBG("Outbuf %p Free", ob);
+ free(ob);
+}
+
+int
+_outbuf_get_rotation(Outbuf *ob)
+{
+ return ob->rotation;
+}
+
+void
+_outbuf_reconfigure(Outbuf *ob, int w, int h, int rotation, Outbuf_Depth depth)
+{
+ unsigned int format = DRM_FORMAT_ARGB8888;
+
+ switch (depth)
+ {
+ case OUTBUF_DEPTH_RGB_16BPP_565_565_DITHERED:
+ format = DRM_FORMAT_RGB565;
+ break;
+ case OUTBUF_DEPTH_RGB_16BPP_555_555_DITHERED:
+ format = DRM_FORMAT_RGBX5551;
+ break;
+ case OUTBUF_DEPTH_RGB_16BPP_444_444_DITHERED:
+ format = DRM_FORMAT_RGBX4444;
+ break;
+ case OUTBUF_DEPTH_RGB_16BPP_565_444_DITHERED:
+ format = DRM_FORMAT_RGB565;
+ break;
+ case OUTBUF_DEPTH_RGB_32BPP_888_8888:
+ format = DRM_FORMAT_RGBX8888;
+ break;
+ case OUTBUF_DEPTH_ARGB_32BPP_8888_8888:
+ format = DRM_FORMAT_ARGB8888;
+ break;
+ case OUTBUF_DEPTH_BGRA_32BPP_8888_8888:
+ format = DRM_FORMAT_BGRA8888;
+ break;
+ case OUTBUF_DEPTH_BGR_32BPP_888_8888:
+ format = DRM_FORMAT_BGRX8888;
+ break;
+ case OUTBUF_DEPTH_RGB_24BPP_888_888:
+ format = DRM_FORMAT_RGB888;
+ break;
+ case OUTBUF_DEPTH_BGR_24BPP_888_888:
+ format = DRM_FORMAT_BGR888;
+ break;
+ case OUTBUF_DEPTH_INHERIT:
+ default:
+ depth = ob->depth;
+ format = ob->format;
+ break;
+ }
+
+ if ((ob->w == w) && (ob->h == h) && (ob->rotation == rotation) &&
+ (ob->depth == depth) && (ob->format == format))
+ return;
+
+ DBG("Outbuf %p Reconfigure: %d %d %d", ob, w, h, rotation);
+
+ ob->w = w;
+ ob->h = h;
+ ob->depth = depth;
+ ob->format = format;
+ ob->rotation = rotation;
+}
+
+void *
+_outbuf_new_region_for_update(Outbuf *ob, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch)
+{
+ DBG("Outbuf %p New Region: %d %d %d %d", ob, x, y, w, h);
+ if (cx) *cx = 0;
+ if (cy) *cy = 0;
+ if (cw) *cw = w;
+ if (ch) *ch = h;
+ return NULL;
+}