diff options
author | Chris Michael <cp.michael@samsung.com> | 2016-09-22 11:07:17 -0400 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2016-09-22 14:20:24 -0400 |
commit | f8e28f37dc79ab8e6c03d6d7efd6a82bc0c287ad (patch) | |
tree | 3e818d55f27543fc225db3ee785610d6369c186a /src/lib/ecore_drm2/ecore_drm2_device.c | |
parent | 91739d10b0337342bcc41e05fc13e40e44cbc30c (diff) |
ecore-drm2: Add code to fill Plane Atomic state
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/ecore_drm2/ecore_drm2_device.c')
-rw-r--r-- | src/lib/ecore_drm2/ecore_drm2_device.c | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c index 4b4bbd4464..262de80dba 100644 --- a/src/lib/ecore_drm2/ecore_drm2_device.c +++ b/src/lib/ecore_drm2/ecore_drm2_device.c | |||
@@ -346,14 +346,149 @@ cont: | |||
346 | } | 346 | } |
347 | 347 | ||
348 | static void | 348 | static void |
349 | _drm2_atomic_state_plane_fill(Ecore_Drm2_Plane_State *pstate, int fd) | ||
350 | { | ||
351 | drmModeObjectPropertiesPtr oprops; | ||
352 | unsigned int i = 0; | ||
353 | int k = 0; | ||
354 | |||
355 | DBG("Atomic State Plane Fill"); | ||
356 | |||
357 | oprops = | ||
358 | drmModeObjectGetProperties(fd, pstate->obj_id, DRM_MODE_OBJECT_PLANE); | ||
359 | if (!oprops) return; | ||
360 | |||
361 | DBG("\tPlane: %d", pstate->obj_id); | ||
362 | |||
363 | for (i = 0; i < oprops->count_props; i++) | ||
364 | { | ||
365 | drmModePropertyPtr prop; | ||
366 | |||
367 | prop = drmModeGetProperty(fd, oprops->props[i]); | ||
368 | if (!prop) continue; | ||
369 | |||
370 | DBG("\t\tProperty: %s", prop->name); | ||
371 | |||
372 | if (!strcmp(prop->name, "CRTC_ID")) | ||
373 | { | ||
374 | pstate->cid.id = prop->prop_id; | ||
375 | pstate->cid.value = oprops->prop_values[i]; | ||
376 | } | ||
377 | else if (!strcmp(prop->name, "FB_ID")) | ||
378 | { | ||
379 | pstate->fid.id = prop->prop_id; | ||
380 | pstate->fid.value = oprops->prop_values[i]; | ||
381 | } | ||
382 | else if (!strcmp(prop->name, "CRTC_X")) | ||
383 | { | ||
384 | pstate->cx.id = prop->prop_id; | ||
385 | pstate->cx.value = oprops->prop_values[i]; | ||
386 | } | ||
387 | else if (!strcmp(prop->name, "CRTC_Y")) | ||
388 | { | ||
389 | pstate->cy.id = prop->prop_id; | ||
390 | pstate->cy.value = oprops->prop_values[i]; | ||
391 | } | ||
392 | else if (!strcmp(prop->name, "CRTC_W")) | ||
393 | { | ||
394 | pstate->cw.id = prop->prop_id; | ||
395 | pstate->cw.value = oprops->prop_values[i]; | ||
396 | } | ||
397 | else if (!strcmp(prop->name, "CRTC_H")) | ||
398 | { | ||
399 | pstate->ch.id = prop->prop_id; | ||
400 | pstate->ch.value = oprops->prop_values[i]; | ||
401 | } | ||
402 | else if (!strcmp(prop->name, "SRC_X")) | ||
403 | { | ||
404 | pstate->sx.id = prop->prop_id; | ||
405 | pstate->sx.value = oprops->prop_values[i]; | ||
406 | } | ||
407 | else if (!strcmp(prop->name, "SRC_Y")) | ||
408 | { | ||
409 | pstate->sy.id = prop->prop_id; | ||
410 | pstate->sy.value = oprops->prop_values[i]; | ||
411 | } | ||
412 | else if (!strcmp(prop->name, "SRC_W")) | ||
413 | { | ||
414 | pstate->sw.id = prop->prop_id; | ||
415 | pstate->sw.value = oprops->prop_values[i]; | ||
416 | } | ||
417 | else if (!strcmp(prop->name, "SRC_H")) | ||
418 | { | ||
419 | pstate->sh.id = prop->prop_id; | ||
420 | pstate->sh.value = oprops->prop_values[i]; | ||
421 | } | ||
422 | else if (!strcmp(prop->name, "type")) | ||
423 | { | ||
424 | pstate->type.id = prop->prop_id; | ||
425 | pstate->type.value = oprops->prop_values[i]; | ||
426 | switch (pstate->type.value) | ||
427 | { | ||
428 | case DRM_PLANE_TYPE_OVERLAY: | ||
429 | DBG("\t\t\tOverlay Type"); | ||
430 | break; | ||
431 | case DRM_PLANE_TYPE_PRIMARY: | ||
432 | DBG("\t\t\tPrimary Type"); | ||
433 | break; | ||
434 | case DRM_PLANE_TYPE_CURSOR: | ||
435 | DBG("\t\t\tCursor Type"); | ||
436 | break; | ||
437 | default: | ||
438 | DBG("\t\t\tValue: %d", pstate->type.value); | ||
439 | break; | ||
440 | } | ||
441 | } | ||
442 | else if (!strcmp(prop->name, "rotation")) | ||
443 | { | ||
444 | pstate->rotation.id = prop->prop_id; | ||
445 | pstate->rotation.value = oprops->prop_values[i]; | ||
446 | |||
447 | for (k = 0; k < prop->count_enums; k++) | ||
448 | { | ||
449 | int r = -1; | ||
450 | |||
451 | if (!strcmp(prop->enums[k].name, "rotate-0")) | ||
452 | r = ECORE_DRM2_ROTATION_NORMAL; | ||
453 | else if (!strcmp(prop->enums[k].name, "rotate-90")) | ||
454 | r = ECORE_DRM2_ROTATION_90; | ||
455 | else if (!strcmp(prop->enums[k].name, "rotate-180")) | ||
456 | r = ECORE_DRM2_ROTATION_180; | ||
457 | else if (!strcmp(prop->enums[k].name, "rotate-270")) | ||
458 | r = ECORE_DRM2_ROTATION_270; | ||
459 | else if (!strcmp(prop->enums[k].name, "reflect-x")) | ||
460 | r = ECORE_DRM2_ROTATION_REFLECT_X; | ||
461 | else if (!strcmp(prop->enums[k].name, "reflect-y")) | ||
462 | r = ECORE_DRM2_ROTATION_REFLECT_Y; | ||
463 | |||
464 | if (r != -1) | ||
465 | { | ||
466 | pstate->supported_rotations |= r; | ||
467 | pstate->rotation_map[ffs(r)] = | ||
468 | 1 << prop->enums[k].value; | ||
469 | } | ||
470 | } | ||
471 | } | ||
472 | |||
473 | drmModeFreeProperty(prop); | ||
474 | } | ||
475 | |||
476 | drmModeFreeObjectProperties(oprops); | ||
477 | } | ||
478 | |||
479 | static void | ||
349 | _drm2_atomic_state_fill(Ecore_Drm2_Atomic_State *state, int fd) | 480 | _drm2_atomic_state_fill(Ecore_Drm2_Atomic_State *state, int fd) |
350 | { | 481 | { |
351 | int i = 0; | 482 | int i = 0; |
352 | drmModeResPtr res; | 483 | drmModeResPtr res; |
484 | drmModePlaneResPtr pres; | ||
353 | 485 | ||
354 | res = drmModeGetResources(fd); | 486 | res = drmModeGetResources(fd); |
355 | if (!res) return; | 487 | if (!res) return; |
356 | 488 | ||
489 | pres = drmModeGetPlaneResources(fd); | ||
490 | if (!pres) goto err; | ||
491 | |||
357 | state->crtcs = res->count_crtcs; | 492 | state->crtcs = res->count_crtcs; |
358 | state->crtc_states = calloc(state->crtcs, sizeof(Ecore_Drm2_Crtc_State)); | 493 | state->crtc_states = calloc(state->crtcs, sizeof(Ecore_Drm2_Crtc_State)); |
359 | if (state->crtc_states) | 494 | if (state->crtc_states) |
@@ -386,6 +521,30 @@ _drm2_atomic_state_fill(Ecore_Drm2_Atomic_State *state, int fd) | |||
386 | } | 521 | } |
387 | } | 522 | } |
388 | 523 | ||
524 | state->planes = pres->count_planes; | ||
525 | state->plane_states = calloc(state->planes, sizeof(Ecore_Drm2_Plane_State)); | ||
526 | if (state->plane_states) | ||
527 | { | ||
528 | for (i = 0; i < state->planes; i++) | ||
529 | { | ||
530 | drmModePlanePtr plane; | ||
531 | Ecore_Drm2_Plane_State *pstate; | ||
532 | |||
533 | plane = drmModeGetPlane(fd, pres->planes[i]); | ||
534 | if (!plane) continue; | ||
535 | |||
536 | pstate = &state->plane_states[i]; | ||
537 | pstate->obj_id = pres->planes[i]; | ||
538 | pstate->mask = plane->possible_crtcs; | ||
539 | |||
540 | drmModeFreePlane(plane); | ||
541 | |||
542 | _drm2_atomic_state_plane_fill(pstate, fd); | ||
543 | } | ||
544 | } | ||
545 | |||
546 | drmModeFreePlaneResources(pres); | ||
547 | |||
389 | err: | 548 | err: |
390 | drmModeFreeResources(res); | 549 | drmModeFreeResources(res); |
391 | } | 550 | } |