summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/drm/evas_engine.h
blob: cf4e22206aeb9a7ca685fd9f6a0809c77a4715a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef EVAS_ENGINE_H
# define EVAS_ENGINE_H

#include "evas_common_private.h"
#include "evas_macros.h"
#include "evas_private.h"
#include "Evas.h"
#include "Evas_Engine_Drm.h"

#include <xf86drm.h>
#include <xf86drmMode.h>
#include <drm_fourcc.h>

#include <signal.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>

#include "../software_generic/Evas_Engine_Software_Generic.h"

extern int _evas_engine_drm_log_dom;

# ifdef ERR
#  undef ERR
# endif
# define ERR(...) EINA_LOG_DOM_ERR(_evas_engine_drm_log_dom, __VA_ARGS__)

# ifdef DBG
#  undef DBG
# endif
# define DBG(...) EINA_LOG_DOM_DBG(_evas_engine_drm_log_dom, __VA_ARGS__)

# ifdef INF
#  undef INF
# endif
# define INF(...) EINA_LOG_DOM_INFO(_evas_engine_drm_log_dom, __VA_ARGS__)

# ifdef WRN
#  undef WRN
# endif
# define WRN(...) EINA_LOG_DOM_WARN(_evas_engine_drm_log_dom, __VA_ARGS__)

# ifdef CRI
#  undef CRI
# endif
# define CRI(...) EINA_LOG_DOM_CRIT(_evas_engine_drm_log_dom, __VA_ARGS__)

/* define a maximum number of 'buffers' (double-buff, triple-buff, etc) */
# define NUM_BUFFERS 2

typedef struct _Buffer Buffer;
typedef struct _Plane Plane;
typedef struct _Outbuf Outbuf;

struct _Buffer
{
   int w, h;
   int stride, size;
   int handle;
   unsigned int fb;

   void *data; // used for software framebuffers

# ifdef HAVE_DRM_HW_ACCEL
   void *bo; // used for hardware framebuffers
# endif

   Eina_Bool valid : 1;
};

struct _Plane
{
   unsigned int id;
   unsigned int crtcs;

   struct 
     {
        unsigned int x, y;
        unsigned int w, h;
     } src, dst;

   unsigned int num_formats;
   unsigned int formats[];
};

struct _Outbuf
{
   Evas_Engine_Info_Drm *info;

   int w, h;
   int rotation;
   unsigned int depth;

   struct
   {
      Buffer buffer[NUM_BUFFERS];

      Eina_List *pending_writes;
      Eina_List *planes;

# ifdef HAVE_DRM_HW_ACCEL
      void *surface;
# endif

      int fd;
      unsigned int conn, crtc, fb;

      int curr, num;

      drmModeModeInfo mode;
      drmEventContext ctx;

      Eina_Bool pending_flip : 1;
   } priv;

   Eina_Bool destination_alpha : 1;
   Eina_Bool vsync : 1;
};

Outbuf *evas_outbuf_setup(Evas_Engine_Info_Drm *info, int w, int h);
void evas_outbuf_free(Outbuf *ob);
void evas_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth);
Render_Engine_Swap_Mode evas_outbuf_buffer_state_get(Outbuf *ob);
int evas_outbuf_get_rot(Outbuf *ob);
RGBA_Image *evas_outbuf_update_region_new(Outbuf *ob, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch);
void evas_outbuf_update_region_push(Outbuf *ob, RGBA_Image *update, int x, int y, int w, int h);
void evas_outbuf_update_region_free(Outbuf *ob, RGBA_Image *update);
void evas_outbuf_flush(Outbuf *ob);

Eina_Bool evas_drm_init(Evas_Engine_Info_Drm *info);
Eina_Bool evas_drm_shutdown(Evas_Engine_Info_Drm *info);

Eina_Bool evas_drm_outbuf_setup(Outbuf *ob);
void evas_drm_outbuf_framebuffer_set(Outbuf *ob, Buffer *buffer);
Eina_Bool evas_drm_framebuffer_create(int fd, Buffer *buffer, int depth);
void evas_drm_framebuffer_destroy(int fd, Buffer *buffer);
Eina_Bool evas_drm_framebuffer_send(Outbuf *ob, Buffer *buffer);

#endif