summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2017-03-27 11:54:38 -0400
committerChris Michael <cp.michael@samsung.com>2017-04-18 07:55:10 -0400
commit19da4706f3763cf2c8eb333fbbc6e31e69d63850 (patch)
treedf4d2a8113194f45571189cb00699d356392ec13
parentf1525ecf35f25019268ee0a2d87567b6846be194 (diff)
ecore-drm2: Add hardware plane functions
This patch adds a new file where we can store any additional functions we may need to work with hardware planes. Currently the file contains a public function that can be used to assign a given Ecore_Drm2_Fb to a hardware plane @feature Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/Makefile_Ecore_Drm2.am1
-rw-r--r--src/lib/ecore_drm2/Ecore_Drm2.h20
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_plane.c105
3 files changed, 126 insertions, 0 deletions
diff --git a/src/Makefile_Ecore_Drm2.am b/src/Makefile_Ecore_Drm2.am
index 1c328e33de..8e9620d714 100644
--- a/src/Makefile_Ecore_Drm2.am
+++ b/src/Makefile_Ecore_Drm2.am
@@ -9,6 +9,7 @@ dist_installed_ecoredrm2mainheaders_DATA = \
9 lib/ecore_drm2/Ecore_Drm2.h 9 lib/ecore_drm2/Ecore_Drm2.h
10 10
11lib_ecore_drm2_libecore_drm2_la_SOURCES = \ 11lib_ecore_drm2_libecore_drm2_la_SOURCES = \
12lib/ecore_drm2/ecore_drm2_plane.c \
12lib/ecore_drm2/ecore_drm2_fb.c \ 13lib/ecore_drm2/ecore_drm2_fb.c \
13lib/ecore_drm2/ecore_drm2_outputs.c \ 14lib/ecore_drm2/ecore_drm2_outputs.c \
14lib/ecore_drm2/ecore_drm2_device.c \ 15lib/ecore_drm2/ecore_drm2_device.c \
diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index e75a57847e..62eebc1e52 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -99,6 +99,7 @@ typedef void (*Ecore_Drm2_Release_Handler)(void *data, Ecore_Drm2_Fb *b);
99 * @li @ref Ecore_Drm2_Device_Group 99 * @li @ref Ecore_Drm2_Device_Group
100 * @li @ref Ecore_Drm2_Output_Group 100 * @li @ref Ecore_Drm2_Output_Group
101 * @li @ref Ecore_Drm2_Fb_Group 101 * @li @ref Ecore_Drm2_Fb_Group
102 * @li @ref Ecore_Drm2_Plane_Group
102 */ 103 */
103 104
104/** 105/**
@@ -988,6 +989,25 @@ EAPI void *ecore_drm2_fb_bo_get(Ecore_Drm2_Fb *fb);
988 */ 989 */
989EAPI Ecore_Drm2_Fb *ecore_drm2_fb_dmabuf_import(int fd, int width, int height, int depth, int bpp, unsigned int format, unsigned int strides[4], int dmabuf_fd[4], int dmabuf_fd_count); 990EAPI Ecore_Drm2_Fb *ecore_drm2_fb_dmabuf_import(int fd, int width, int height, int depth, int bpp, unsigned int format, unsigned int strides[4], int dmabuf_fd[4], int dmabuf_fd_count);
990 991
992/**
993 * @defgroup Ecore_Drm2_Plane_Group Functions that deal with hardware planes
994 *
995 * Functions that deal with hardware plane manipulation
996 */
997
998/**
999 * Find a hardware plane where a given Ecore_Drm2_Fb can go based on format and size
1000 *
1001 * @param output
1002 * @param fb
1003 *
1004 * @return A newly allocated plane object, or NULL otherwise
1005 *
1006 * @ingroup Ecore_Drm2_Plane_Group
1007 * @since 1.20
1008 */
1009EAPI Ecore_Drm2_Plane *ecore_drm2_plane_assign(Ecore_Drm2_Output *output, Ecore_Drm2_Fb *fb);
1010
991# endif 1011# endif
992 1012
993#endif 1013#endif
diff --git a/src/lib/ecore_drm2/ecore_drm2_plane.c b/src/lib/ecore_drm2/ecore_drm2_plane.c
new file mode 100644
index 0000000000..3df0cbb63a
--- /dev/null
+++ b/src/lib/ecore_drm2/ecore_drm2_plane.c
@@ -0,0 +1,105 @@
1#include "ecore_drm2_private.h"
2
3static Eina_Bool
4_plane_format_supported(Ecore_Drm2_Plane_State *pstate, uint32_t format)
5{
6 Eina_Bool ret = EINA_FALSE;
7 unsigned int i = 0;
8
9 for (; i < pstate->num_formats; i++)
10 {
11 if (pstate->formats[i] == format)
12 {
13 ret = EINA_TRUE;
14 break;
15 }
16 }
17
18 return ret;
19}
20
21static void
22_plane_cursor_size_get(int fd, int *width, int *height)
23{
24 uint64_t caps;
25 int ret;
26
27 if (width)
28 {
29 *width = 64;
30 ret = sym_drmGetCap(fd, DRM_CAP_CURSOR_WIDTH, &caps);
31 if (ret == 0) *width = caps;
32 }
33 if (height)
34 {
35 *height = 64;
36 ret = sym_drmGetCap(fd, DRM_CAP_CURSOR_HEIGHT, &caps);
37 if (ret == 0) *height = caps;
38 }
39}
40
41EAPI Ecore_Drm2_Plane *
42ecore_drm2_plane_assign(Ecore_Drm2_Output *output, Ecore_Drm2_Fb *fb)
43{
44#ifdef HAVE_ATOMIC_DRM
45 Eina_List *l;
46 Ecore_Drm2_Plane *plane;
47 Ecore_Drm2_Plane_State *pstate;
48
49 if (!_ecore_drm2_use_atomic) return NULL;
50
51 /* use algo based on format, size, etc to find a plane this FB can go in */
52 EINA_LIST_FOREACH(output->plane_states, l, pstate)
53 {
54 /* test if this plane supports the given format */
55 if (!_plane_format_supported(pstate, fb->format))
56 continue;
57
58 if (pstate->type.value == DRM_PLANE_TYPE_CURSOR)
59 {
60 int cw, ch;
61
62 _plane_cursor_size_get(output->fd, &cw, &ch);
63
64 /* check that this fb can fit in cursor plane */
65 if ((fb->w > cw) || (fb->h > ch))
66 continue;
67
68 /* if we reach here, this FB can go on the cursor plane */
69 goto out;
70 }
71 else if (pstate->type.value == DRM_PLANE_TYPE_OVERLAY)
72 {
73 /* there are no size checks for an overlay plane */
74 goto out;
75 }
76 else if (pstate->type.value == DRM_PLANE_TYPE_PRIMARY)
77 {
78 if ((fb->w > output->current_mode->width) ||
79 (fb->h > output->current_mode->height))
80 continue;
81
82 /* if we reach here, this FB can go on the primary plane */
83 goto out;
84 }
85 }
86
87 return NULL;
88
89out:
90 /* create plane */
91 plane = calloc(1, sizeof(Ecore_Drm2_Plane));
92 if (!plane) return NULL;
93
94 plane->type = pstate->type.value;
95 plane->qfb = fb;
96 plane->state = pstate;
97
98 DBG("FB %d assigned to Plane %d", fb->id, pstate->obj_id);
99 output->planes = eina_list_append(output->planes, plane);
100
101 return plane;
102#else
103 return NULL;
104#endif
105}