diff options
author | Chris Michael <cp.michael@samsung.com> | 2017-03-27 11:54:38 -0400 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2017-04-18 07:55:10 -0400 |
commit | 19da4706f3763cf2c8eb333fbbc6e31e69d63850 (patch) | |
tree | df4d2a8113194f45571189cb00699d356392ec13 /src/lib/ecore_drm2/ecore_drm2_plane.c | |
parent | f1525ecf35f25019268ee0a2d87567b6846be194 (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>
Diffstat (limited to '')
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_plane.c | 105 |
1 files changed, 105 insertions, 0 deletions
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 | |||
3 | static 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 | |||
21 | static 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 | |||
41 | EAPI Ecore_Drm2_Plane * | ||
42 | ecore_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 | |||
89 | out: | ||
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 | } | ||