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)
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 @@
1#include "evas_engine.h"
2
3typedef struct _Render_Engine
4{
5 Render_Output_Software_Generic generic;
6} Render_Engine;
7
8static Evas_Func func, pfunc;
9
10int _evas_engine_drm_log_dom;
11
12/* engine functions we override */
13static void
14eng_output_info_setup(void *info)
15{
16 Evas_Engine_Info_Drm *einfo;
17
18 DBG("Engine Info Setup");
19
20 einfo = info;
21 einfo->render_mode = EVAS_RENDER_MODE_BLOCKING;
22}
23
24static void *
25eng_output_setup(void *engine, void *info, unsigned int w, unsigned int h)
26{
27 Evas_Engine_Info_Drm *einfo;
28 Render_Engine *re;
29 Outbuf *ob;
30
31 einfo = info;
32
33 re = calloc(1, sizeof(Render_Engine));
34 if (!re) return NULL;
35
36 ob = _outbuf_setup(einfo, w, h);
37 if (!ob) goto err;
38
39 if (!evas_render_engine_software_generic_init(engine, &re->generic, ob,
40 NULL, //swap_mode_get
41 _outbuf_get_rotation,
42 _outbuf_reconfigure,
43 NULL, //region_first_rect
44 NULL, //damage_region_set
45 _outbuf_new_region_for_update,
46 NULL, //push_updated_region
47 NULL, //free_region_for_update
48 NULL, //idle_flush
49 NULL, //flush
50 NULL, //redraws_clear
51 _outbuf_free, //free
52 w, h))
53 goto init_err;
54
55 evas_render_engine_software_generic_merge_mode_set(&re->generic);
56
57 re->generic.ob->info = einfo;
58
59 return re;
60
61init_err:
62 evas_render_engine_software_generic_clean(engine, &re->generic);
63err:
64 free(re);
65 return NULL;
66}
67
68static void
69eng_output_free(void *engine, void *data)
70{
71 Render_Engine *re;
72
73 re = data;
74 evas_render_engine_software_generic_clean(engine, &re->generic);
75 free(re);
76}
77
78static int
79eng_output_update(void *engine EINA_UNUSED, void *data, void *info, unsigned int w, unsigned int h)
80{
81 Outbuf *ob;
82 Render_Engine *re;
83 Evas_Engine_Info_Drm *einfo;
84
85 re = data;
86 einfo = info;
87 ob = re->generic.ob;
88
89 if ((ob->w != (int)w) || (ob->h != (int)h) ||
90 (ob->rotation != (int)einfo->info.rotation))
91 {
92 _outbuf_reconfigure(ob, w, h, einfo->info.rotation, einfo->info.depth);
93 evas_render_engine_software_generic_update(&re->generic, ob, w, h);
94 }
95
96 return 1;
97}
98
99/* module functions */
100static int
101module_open(Evas_Module *em)
102{
103 if (!em) return 0;
104
105 /* try to inherit functions from software_generic engine */
106 if (!_evas_module_engine_inherit(&pfunc, "software_generic",
107 sizeof(Evas_Engine_Info_Drm)))
108 return 0;
109
110 /* register eina logging domain */
111 _evas_engine_drm_log_dom =
112 eina_log_domain_register("evas-drm", EVAS_DEFAULT_LOG_COLOR);
113 if (_evas_engine_drm_log_dom < 0)
114 {
115 EINA_LOG_ERR("Could not create module log domain");
116 return 0;
117 }
118
119 /* store parent engine functions so we can override the ones we want */
120 func = pfunc;
121
122 /* override engine functions we provide */
123#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
124 ORD(output_info_setup);
125 ORD(output_setup);
126 ORD(output_free);
127 ORD(output_update);
128
129 /* advertise our engine functions */
130 em->functions = (void *)(&func);
131
132 return 1;
133}
134
135static void
136module_close(Evas_Module *em EINA_UNUSED)
137{
138 /* unregister eina logging domain */
139 if (_evas_engine_drm_log_dom >= 0)
140 {
141 eina_log_domain_unregister(_evas_engine_drm_log_dom);
142 _evas_engine_drm_log_dom = -1;
143 }
144}
145
146static Evas_Module_Api evas_modapi =
147{
148 EVAS_MODULE_API_VERSION, "drm", "none", { module_open, module_close }
149};
150
151EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, drm);
152
153#ifndef EVAS_STATIC_BUILD_DRM
154EVAS_EINA_MODULE_DEFINE(engine, drm);
155#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 @@
1#include "evas_engine.h"
2#include <drm_fourcc.h>
3
4Outbuf *
5_outbuf_setup(Evas_Engine_Info_Drm *einfo, int w, int h)
6{
7 Outbuf *ob;
8
9 ob = calloc(1, sizeof(Outbuf));
10 if (!ob) return NULL;
11
12 DBG("Outbuf %p Setup: %d %d", ob, w, h);
13
14 ob->w = w;
15 ob->h = h;
16 ob->bpp = einfo->info.bpp;
17 ob->depth = einfo->info.depth;
18 ob->alpha = einfo->info.alpha;
19 ob->format = einfo->info.format;
20 ob->rotation = einfo->info.rotation;
21
22 return ob;
23}
24
25void
26_outbuf_free(Outbuf *ob)
27{
28 DBG("Outbuf %p Free", ob);
29 free(ob);
30}
31
32int
33_outbuf_get_rotation(Outbuf *ob)
34{
35 return ob->rotation;
36}
37
38void
39_outbuf_reconfigure(Outbuf *ob, int w, int h, int rotation, Outbuf_Depth depth)
40{
41 unsigned int format = DRM_FORMAT_ARGB8888;
42
43 switch (depth)
44 {
45 case OUTBUF_DEPTH_RGB_16BPP_565_565_DITHERED:
46 format = DRM_FORMAT_RGB565;
47 break;
48 case OUTBUF_DEPTH_RGB_16BPP_555_555_DITHERED:
49 format = DRM_FORMAT_RGBX5551;
50 break;
51 case OUTBUF_DEPTH_RGB_16BPP_444_444_DITHERED:
52 format = DRM_FORMAT_RGBX4444;
53 break;
54 case OUTBUF_DEPTH_RGB_16BPP_565_444_DITHERED:
55 format = DRM_FORMAT_RGB565;
56 break;
57 case OUTBUF_DEPTH_RGB_32BPP_888_8888:
58 format = DRM_FORMAT_RGBX8888;
59 break;
60 case OUTBUF_DEPTH_ARGB_32BPP_8888_8888:
61 format = DRM_FORMAT_ARGB8888;
62 break;
63 case OUTBUF_DEPTH_BGRA_32BPP_8888_8888:
64 format = DRM_FORMAT_BGRA8888;
65 break;
66 case OUTBUF_DEPTH_BGR_32BPP_888_8888:
67 format = DRM_FORMAT_BGRX8888;
68 break;
69 case OUTBUF_DEPTH_RGB_24BPP_888_888:
70 format = DRM_FORMAT_RGB888;
71 break;
72 case OUTBUF_DEPTH_BGR_24BPP_888_888:
73 format = DRM_FORMAT_BGR888;
74 break;
75 case OUTBUF_DEPTH_INHERIT:
76 default:
77 depth = ob->depth;
78 format = ob->format;
79 break;
80 }
81
82 if ((ob->w == w) && (ob->h == h) && (ob->rotation == rotation) &&
83 (ob->depth == depth) && (ob->format == format))
84 return;
85
86 DBG("Outbuf %p Reconfigure: %d %d %d", ob, w, h, rotation);
87
88 ob->w = w;
89 ob->h = h;
90 ob->depth = depth;
91 ob->format = format;
92 ob->rotation = rotation;
93}
94
95void *
96_outbuf_new_region_for_update(Outbuf *ob, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch)
97{
98 DBG("Outbuf %p New Region: %d %d %d %d", ob, x, y, w, h);
99 if (cx) *cx = 0;
100 if (cy) *cy = 0;
101 if (cw) *cw = w;
102 if (ch) *ch = h;
103 return NULL;
104}