summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2017-03-27 10:53:01 -0400
committerChris Michael <cp.michael@samsung.com>2017-04-18 07:55:10 -0400
commit980ed70eb9af0e829a58e605351121685ac3e66a (patch)
tree5d2134c13ffa157ae21c3183cb1fbe8e19e68a59 /src/lib
parent4f8f41299fae4fdefb14b64ecbb02e371aa7c513 (diff)
ecore-drm2: Support multiple planes on a given output
Various hardware can support multiple planes on a given output. As such, we need to be able to store multiple plane states per-output. This small patch adds support for that. @feature Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_outputs.c104
-rw-r--r--src/lib/ecore_drm2/ecore_drm2_private.h2
2 files changed, 76 insertions, 30 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_outputs.c b/src/lib/ecore_drm2/ecore_drm2_outputs.c
index a36c4403c1..32350150e3 100644
--- a/src/lib/ecore_drm2/ecore_drm2_outputs.c
+++ b/src/lib/ecore_drm2/ecore_drm2_outputs.c
@@ -24,6 +24,7 @@ _output_debug(Ecore_Drm2_Output *output, const drmModeConnector *conn)
24{ 24{
25 Eina_List *l; 25 Eina_List *l;
26 Ecore_Drm2_Output_Mode *omode; 26 Ecore_Drm2_Output_Mode *omode;
27 Ecore_Drm2_Plane_State *pstate;
27 28
28 DBG("Created New Output At %d,%d", output->x, output->y); 29 DBG("Created New Output At %d,%d", output->x, output->y);
29 DBG("\tCrtc Pos: %d %d", output->ocrtc->x, output->ocrtc->y); 30 DBG("\tCrtc Pos: %d %d", output->ocrtc->x, output->ocrtc->y);
@@ -56,6 +57,14 @@ _output_debug(Ecore_Drm2_Output *output, const drmModeConnector *conn)
56 DBG("\t\tPath: %s", output->backlight.path); 57 DBG("\t\tPath: %s", output->backlight.path);
57 } 58 }
58 59
60#ifdef HAVE_ATOMIC_DRM
61 if (_ecore_drm2_use_atomic)
62 {
63 EINA_LIST_FOREACH(output->plane_states, l, pstate)
64 DBG("\tPossible Plane: %d", pstate->obj_id);
65 }
66#endif
67
59 EINA_LIST_FOREACH(output->modes, l, omode) 68 EINA_LIST_FOREACH(output->modes, l, omode)
60 { 69 {
61 DBG("\tAdded Mode: %dx%d@%d%s%s%s", 70 DBG("\tAdded Mode: %dx%d@%d%s%s%s",
@@ -655,23 +664,30 @@ _atomic_state_plane_duplicate(Ecore_Drm2_Plane_State *state)
655 return pstate; 664 return pstate;
656} 665}
657 666
658/* NB: For now, this function will only return primary planes. 667static Eina_List *
659 * We may need to adjust this later to pass in a desired plane type */ 668_output_plane_states_get(Ecore_Drm2_Atomic_State *state, unsigned int crtc_id, int index)
660static Ecore_Drm2_Plane_State *
661_output_plane_state_get(Ecore_Drm2_Atomic_State *state, unsigned int id)
662{ 669{
670 Eina_List *states = NULL;
663 Ecore_Drm2_Plane_State *pstate; 671 Ecore_Drm2_Plane_State *pstate;
672
664 int i = 0; 673 int i = 0;
665 674
666 for (; i < state->planes; i++) 675 for (; i < state->planes; i++)
667 { 676 {
668 pstate = &state->plane_states[i]; 677 pstate = &state->plane_states[i];
669 if (pstate->type.value != DRM_PLANE_TYPE_PRIMARY) continue; 678 if (pstate->cid.value == crtc_id)
670 if (pstate->cid.value != id) continue; 679 {
671 return _atomic_state_plane_duplicate(pstate); 680 states =
681 eina_list_append(states, _atomic_state_plane_duplicate(pstate));
682 }
683 else if (pstate->mask & (1 << index))
684 {
685 states =
686 eina_list_append(states, _atomic_state_plane_duplicate(pstate));
687 }
672 } 688 }
673 689
674 return NULL; 690 return states;
675} 691}
676#endif 692#endif
677 693
@@ -745,8 +761,8 @@ _output_create(Ecore_Drm2_Device *dev, const drmModeRes *res, const drmModeConne
745 _output_crtc_state_get(dev->state, output->crtc_id); 761 _output_crtc_state_get(dev->state, output->crtc_id);
746 output->conn_state = 762 output->conn_state =
747 _output_conn_state_get(dev->state, output->conn_id); 763 _output_conn_state_get(dev->state, output->conn_id);
748 output->plane_state = 764 output->plane_states =
749 _output_plane_state_get(dev->state, output->crtc_id); 765 _output_plane_states_get(dev->state, output->crtc_id, output->pipe);
750 } 766 }
751 else 767 else
752#endif 768#endif
@@ -887,6 +903,19 @@ _output_destroy(Ecore_Drm2_Device *dev, Ecore_Drm2_Output *output)
887{ 903{
888 Ecore_Drm2_Output_Mode *mode; 904 Ecore_Drm2_Output_Mode *mode;
889 905
906#ifdef HAVE_ATOMIC_DRM
907 if (_ecore_drm2_use_atomic)
908 {
909 Ecore_Drm2_Plane_State *pstate;
910
911 EINA_LIST_FREE(output->plane_states, pstate)
912 free(pstate);
913
914 free(output->conn_state);
915 free(output->crtc_state);
916 }
917#endif
918
890 EINA_LIST_FREE(output->modes, mode) 919 EINA_LIST_FREE(output->modes, mode)
891 { 920 {
892 if (mode->id) 921 if (mode->id)
@@ -1524,7 +1553,17 @@ ecore_drm2_output_supported_rotations_get(Ecore_Drm2_Output *output)
1524 1553
1525#ifdef HAVE_ATOMIC_DRM 1554#ifdef HAVE_ATOMIC_DRM
1526 if (_ecore_drm2_use_atomic) 1555 if (_ecore_drm2_use_atomic)
1527 ret = output->plane_state->supported_rotations; 1556 {
1557 Eina_List *l;
1558 Ecore_Drm2_Plane_State *pstate;
1559
1560 EINA_LIST_FOREACH(output->plane_states, l, pstate)
1561 {
1562 if (pstate->type.value != DRM_PLANE_TYPE_PRIMARY) continue;
1563 ret = pstate->supported_rotations;
1564 break;
1565 }
1566 }
1528#endif 1567#endif
1529 1568
1530 return ret; 1569 return ret;
@@ -1540,35 +1579,42 @@ ecore_drm2_output_rotation_set(Ecore_Drm2_Output *output, int rotation)
1540#ifdef HAVE_ATOMIC_DRM 1579#ifdef HAVE_ATOMIC_DRM
1541 if (_ecore_drm2_use_atomic) 1580 if (_ecore_drm2_use_atomic)
1542 { 1581 {
1543 Ecore_Drm2_Plane_State *pstate; 1582 Eina_List *l;
1583 Ecore_Drm2_Plane_State *pstate = NULL;
1544 drmModeAtomicReq *req = NULL; 1584 drmModeAtomicReq *req = NULL;
1545 int res = 0; 1585 int res = 0;
1546 uint32_t flags = 1586 uint32_t flags =
1547 DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT | 1587 DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT |
1548 DRM_MODE_ATOMIC_ALLOW_MODESET; 1588 DRM_MODE_ATOMIC_ALLOW_MODESET;
1549 1589
1550 pstate = output->plane_state; 1590 EINA_LIST_FOREACH(output->plane_states, l, pstate)
1551 if ((pstate->supported_rotations & rotation) == 0)
1552 { 1591 {
1553 WRN("Unsupported rotation"); 1592 if (pstate->type.value != DRM_PLANE_TYPE_PRIMARY) continue;
1554 return EINA_FALSE;
1555 }
1556 1593
1557 req = sym_drmModeAtomicAlloc(); 1594 if ((pstate->supported_rotations & rotation) == 0)
1558 if (!req) return EINA_FALSE; 1595 {
1596 WRN("Unsupported rotation");
1597 return EINA_FALSE;
1598 }
1559 1599
1560 sym_drmModeAtomicSetCursor(req, 0); 1600 req = sym_drmModeAtomicAlloc();
1601 if (!req) return EINA_FALSE;
1561 1602
1562 res = sym_drmModeAtomicAddProperty(req, pstate->obj_id, 1603 sym_drmModeAtomicSetCursor(req, 0);
1563 pstate->rotation.id, rotation);
1564 if (res < 0) goto err;
1565 1604
1566 res = sym_drmModeAtomicCommit(output->fd, req, flags, output->user_data); 1605 res = sym_drmModeAtomicAddProperty(req, pstate->obj_id,
1567 if (res < 0) goto err; 1606 pstate->rotation.id, rotation);
1568 else 1607 if (res < 0) goto err;
1569 { 1608
1570 ret = EINA_TRUE; 1609 res = sym_drmModeAtomicCommit(output->fd, req, flags,
1571 pstate->rotation.value = rotation; 1610 output->user_data);
1611 if (res < 0)
1612 goto err;
1613 else
1614 {
1615 ret = EINA_TRUE;
1616 pstate->rotation.value = rotation;
1617 }
1572 } 1618 }
1573 1619
1574err: 1620err:
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h
index 19c8df295d..60efbf7394 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -766,7 +766,7 @@ struct _Ecore_Drm2_Output
766# ifdef HAVE_ATOMIC_DRM 766# ifdef HAVE_ATOMIC_DRM
767 Ecore_Drm2_Crtc_State *crtc_state; 767 Ecore_Drm2_Crtc_State *crtc_state;
768 Ecore_Drm2_Connector_State *conn_state; 768 Ecore_Drm2_Connector_State *conn_state;
769 Ecore_Drm2_Plane_State *plane_state; 769 Eina_List *plane_states;
770# endif 770# endif
771 771
772 Eina_Bool connected : 1; 772 Eina_Bool connected : 1;