summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2016-09-22 10:58:27 -0400
committerChris Michael <cp.michael@samsung.com>2016-09-22 13:33:57 -0400
commitd63b36318de26a560a986bc6e58497d562c5d9f6 (patch)
treee2bf679bfe0c2d3871dcbc562b485413fdad7ae7
parentad3ca31b01cab158e5b486a56dd17ba0de7ebf8a (diff)
ecore-drm2: Add code to fill Atomic Crtc State
This patch adds code to enable Atomic Modesetting support (via ioctl) and to fill in Atomic Crtc state during startup. Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_device.c123
1 files changed, 121 insertions, 2 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c
index 1ee7871f5a..0e138694fd 100644
--- a/src/lib/ecore_drm2/ecore_drm2_device.c
+++ b/src/lib/ecore_drm2/ecore_drm2_device.c
@@ -151,7 +151,7 @@ out:
151 151
152#ifdef HAVE_ATOMIC_DRM 152#ifdef HAVE_ATOMIC_DRM
153static Eina_Bool 153static Eina_Bool
154_ecore_drm2_atomic_usable(int fd) 154_drm2_atomic_usable(int fd)
155{ 155{
156 drmVersion *drmver; 156 drmVersion *drmver;
157 Eina_Bool ret = EINA_FALSE; 157 Eina_Bool ret = EINA_FALSE;
@@ -191,6 +191,104 @@ _ecore_drm2_atomic_usable(int fd)
191 191
192 return ret; 192 return ret;
193} 193}
194
195static void
196_drm2_atomic_state_crtc_fill(Ecore_Drm2_Crtc_State *cstate, int fd)
197{
198 drmModeObjectPropertiesPtr oprops;
199 unsigned int i = 0;
200
201 DBG("Atomic State Crtc Fill");
202
203 oprops =
204 drmModeObjectGetProperties(fd, cstate->obj_id, DRM_MODE_OBJECT_CRTC);
205 if (!oprops) return;
206
207 DBG("\tCrtc %d", cstate->obj_id);
208
209 for (i = 0; i < oprops->count_props; i++)
210 {
211 drmModePropertyPtr prop;
212
213 prop = drmModeGetProperty(fd, oprops->props[i]);
214 if (!prop) continue;
215
216 DBG("\t\tProperty: %s %d", prop->name, i);
217
218 if (!strcmp(prop->name, "MODE_ID"))
219 {
220 drmModePropertyBlobPtr bp;
221
222 cstate->mode.id = prop->prop_id;
223 cstate->mode.value = oprops->prop_values[i];
224 DBG("\t\t\tValue: %d", cstate->mode.value);
225
226 if (!cstate->mode.value)
227 {
228 cstate->mode.len = 0;
229 goto cont;
230 }
231
232 bp = drmModeGetPropertyBlob(fd, cstate->mode.value);
233 if (!bp) goto cont;
234
235 if ((!cstate->mode.data) ||
236 memcmp(cstate->mode.data, bp->data, bp->length) != 0)
237 {
238 cstate->mode.data =
239 eina_memdup(bp->data, bp->length, 1);
240 }
241
242 cstate->mode.len = bp->length;
243
244 if (cstate->mode.value != 0)
245 drmModeCreatePropertyBlob(fd, bp->data, bp->length,
246 &cstate->mode.value);
247
248 drmModeFreePropertyBlob(bp);
249 }
250 else if (!strcmp(prop->name, "ACTIVE"))
251 {
252 cstate->active.id = prop->prop_id;
253 cstate->active.value = oprops->prop_values[i];
254 DBG("\t\t\tValue: %d", cstate->active.value);
255 }
256
257cont:
258 drmModeFreeProperty(prop);
259 }
260
261 drmModeFreeObjectProperties(oprops);
262}
263
264static void
265_drm2_atomic_state_fill(Ecore_Drm2_Atomic_State *state, int fd)
266{
267 int i = 0;
268 drmModeResPtr res;
269
270 res = drmModeGetResources(fd);
271 if (!res) return;
272
273 state->crtcs = res->count_crtcs;
274 state->crtc_states = calloc(state->crtcs, sizeof(Ecore_Drm2_Crtc_State));
275 if (state->crtc_states)
276 {
277 for (i = 0; i < state->crtcs; i++)
278 {
279 Ecore_Drm2_Crtc_State *cstate;
280
281 cstate = &state->crtc_states[i];
282 cstate->obj_id = res->crtcs[i];
283 cstate->index = i;
284
285 _drm2_atomic_state_crtc_fill(cstate, fd);
286 }
287 }
288
289err:
290 drmModeFreeResources(res);
291}
194#endif 292#endif
195 293
196EAPI Ecore_Drm2_Device * 294EAPI Ecore_Drm2_Device *
@@ -243,7 +341,28 @@ ecore_drm2_device_open(Ecore_Drm2_Device *device)
243 341
244#ifdef HAVE_ATOMIC_DRM 342#ifdef HAVE_ATOMIC_DRM
245 /* check that this system can do atomic */ 343 /* check that this system can do atomic */
246 _ecore_drm2_use_atomic = _ecore_drm2_atomic_usable(device->fd); 344 _ecore_drm2_use_atomic = _drm2_atomic_usable(device->fd);
345 if (_ecore_drm2_use_atomic)
346 {
347 if (drmSetClientCap(device->fd, DRM_CLIENT_CAP_ATOMIC, 1) < 0)
348 {
349 WRN("Could not enable Atomic Modesetting support");
350 _ecore_drm2_use_atomic = EINA_FALSE;
351 }
352 else
353 {
354 if (drmSetClientCap(device->fd,
355 DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1) < 0)
356 WRN("Could not enable Universal Plane support");
357 else
358 {
359 /* atomic & planes are usable */
360 device->state = calloc(1, sizeof(Ecore_Drm2_Atomic_State));
361 if (device->state)
362 _drm2_atomic_state_fill(device->state, device->fd);
363 }
364 }
365 }
247#endif 366#endif
248 367
249 device->active_hdlr = 368 device->active_hdlr =