summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2016-09-22 11:02:49 -0400
committerChris Michael <cp.michael@samsung.com>2016-09-22 13:33:57 -0400
commit3cbc0e949d992bf71fbd70366dd5052100e11c16 (patch)
tree147e00c43f9fcced19798e72479aaab896972cd8
parentd63b36318de26a560a986bc6e58497d562c5d9f6 (diff)
ecore-drm2: Add code to fill Connector Atomic state
Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_device.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c
index 0e138694fd..4b4bbd4464 100644
--- a/src/lib/ecore_drm2/ecore_drm2_device.c
+++ b/src/lib/ecore_drm2/ecore_drm2_device.c
@@ -262,6 +262,90 @@ cont:
262} 262}
263 263
264static void 264static void
265_drm2_atomic_state_conn_fill(Ecore_Drm2_Connector_State *cstate, int fd)
266{
267 drmModeObjectPropertiesPtr oprops;
268 unsigned int i = 0;
269
270 DBG("Atomic State Connector Fill");
271
272 oprops =
273 drmModeObjectGetProperties(fd, cstate->obj_id, DRM_MODE_OBJECT_CONNECTOR);
274 if (!oprops) return;
275
276 DBG("\tConnector: %d", cstate->obj_id);
277
278 for (i = 0; i < oprops->count_props; i++)
279 {
280 drmModePropertyPtr prop;
281
282 prop = drmModeGetProperty(fd, oprops->props[i]);
283 if (!prop) continue;
284
285 DBG("\t\tProperty: %s", prop->name);
286
287 if (!strcmp(prop->name, "CRTC_ID"))
288 {
289 cstate->crtc.id = prop->prop_id;
290 cstate->crtc.value = oprops->prop_values[i];
291 DBG("\t\t\tValue: %d", cstate->crtc.value);
292 }
293 else if (!strcmp(prop->name, "DPMS"))
294 {
295 cstate->dpms.id = prop->prop_id;
296 cstate->dpms.value = oprops->prop_values[i];
297 DBG("\t\t\tValue: %d", cstate->dpms.value);
298 }
299 else if (!strcmp(prop->name, "EDID"))
300 {
301 drmModePropertyBlobPtr bp;
302
303 cstate->edid.id = oprops->prop_values[i];
304 if (!cstate->edid.id)
305 {
306 cstate->edid.len = 0;
307 goto cont;
308 }
309
310 bp = drmModeGetPropertyBlob(fd, cstate->edid.id);
311 if (!bp) goto cont;
312
313 if ((!cstate->edid.data) ||
314 memcmp(cstate->edid.data, bp->data, bp->length) != 0)
315 {
316 cstate->edid.data =
317 eina_memdup(bp->data, bp->length, 1);
318 }
319
320 cstate->edid.len = bp->length;
321
322 if (cstate->edid.id != 0)
323 drmModeCreatePropertyBlob(fd, bp->data, bp->length,
324 &cstate->edid.id);
325
326 drmModeFreePropertyBlob(bp);
327 }
328 else if (!strcmp(prop->name, "aspect ratio"))
329 {
330 cstate->aspect.id = prop->prop_id;
331 cstate->aspect.value = oprops->prop_values[i];
332 DBG("\t\t\tValue: %d", cstate->aspect.value);
333 }
334 else if (!strcmp(prop->name, "scaling mode"))
335 {
336 cstate->scaling.id = prop->prop_id;
337 cstate->scaling.value = oprops->prop_values[i];
338 DBG("\t\t\tValue: %d", cstate->scaling.value);
339 }
340
341cont:
342 drmModeFreeProperty(prop);
343 }
344
345 drmModeFreeObjectProperties(oprops);
346}
347
348static void
265_drm2_atomic_state_fill(Ecore_Drm2_Atomic_State *state, int fd) 349_drm2_atomic_state_fill(Ecore_Drm2_Atomic_State *state, int fd)
266{ 350{
267 int i = 0; 351 int i = 0;
@@ -286,6 +370,22 @@ _drm2_atomic_state_fill(Ecore_Drm2_Atomic_State *state, int fd)
286 } 370 }
287 } 371 }
288 372
373 state->conns = res->count_connectors;
374 state->conn_states =
375 calloc(state->conns, sizeof(Ecore_Drm2_Connector_State));
376 if (state->conn_states)
377 {
378 for (i = 0; i < state->conns; i++)
379 {
380 Ecore_Drm2_Connector_State *cstate;
381
382 cstate = &state->conn_states[i];
383 cstate->obj_id = res->connectors[i];
384
385 _drm2_atomic_state_conn_fill(cstate, fd);
386 }
387 }
388
289err: 389err:
290 drmModeFreeResources(res); 390 drmModeFreeResources(res);
291} 391}