summaryrefslogtreecommitdiff
path: root/src/lib/ecore_drm2/ecore_drm2_device.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2017-03-27 13:56:03 -0400
committerChris Michael <cp.michael@samsung.com>2017-04-18 07:55:10 -0400
commit345fefd3ef841381a6a0206297a24df88afd311a (patch)
tree8c83e459474082a9bdfbfcdece5a28a8546506de /src/lib/ecore_drm2/ecore_drm2_device.c
parent9d5c76e0d59588670a5125853c3fe17310bc9d17 (diff)
ecore-drm2: Add API functions for atomic commit test and commit
This patch adds 2 new API functions, one which we can use to test atomic commits before actually applying them, and another which does the actual Atomic commit. @feature 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.c158
1 files changed, 157 insertions, 1 deletions
diff --git a/src/lib/ecore_drm2/ecore_drm2_device.c b/src/lib/ecore_drm2/ecore_drm2_device.c
index fcd639eb7e..cb659ad4a5 100644
--- a/src/lib/ecore_drm2/ecore_drm2_device.c
+++ b/src/lib/ecore_drm2/ecore_drm2_device.c
@@ -676,7 +676,11 @@ ecore_drm2_device_free(Ecore_Drm2_Device *device)
676 676
677#ifdef HAVE_ATOMIC_DRM 677#ifdef HAVE_ATOMIC_DRM
678 if (_ecore_drm2_use_atomic) 678 if (_ecore_drm2_use_atomic)
679 _drm2_atomic_state_free(device->state); 679 {
680 _drm2_atomic_state_free(device->state);
681 if (device->atomic_req)
682 sym_drmModeAtomicFree(device->atomic_req);
683 }
680#endif 684#endif
681 685
682 ecore_event_handler_del(device->active_hdlr); 686 ecore_event_handler_del(device->active_hdlr);
@@ -848,3 +852,155 @@ ecore_drm2_device_prefer_shadow(Ecore_Drm2_Device *device)
848 else 852 else
849 return EINA_FALSE; 853 return EINA_FALSE;
850} 854}
855
856EAPI Eina_Bool
857ecore_drm2_atomic_commit_test(Ecore_Drm2_Device *device)
858{
859 Eina_Bool res = EINA_FALSE;
860#ifdef HAVE_ATOMIC_DRM
861 int ret = 0;
862 Eina_List *l, *ll;
863 Ecore_Drm2_Output *output;
864 Ecore_Drm2_Plane *plane;
865 Ecore_Drm2_Plane_State *pstate;
866 Ecore_Drm2_Crtc_State *cstate;
867 drmModeAtomicReq *req = NULL;
868 uint32_t flags = DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_ATOMIC_ALLOW_MODESET |
869 DRM_MODE_ATOMIC_TEST_ONLY;
870#endif
871
872 EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
873 EINA_SAFETY_ON_TRUE_RETURN_VAL((device->fd < 0), EINA_FALSE);
874
875#ifdef HAVE_ATOMIC_DRM
876 req = sym_drmModeAtomicAlloc();
877 if (!req) return EINA_FALSE;
878
879 sym_drmModeAtomicSetCursor(req, 0);
880
881 EINA_LIST_FOREACH(device->outputs, l, output)
882 {
883 cstate = output->crtc_state;
884
885 ret =
886 sym_drmModeAtomicAddProperty(req, cstate->obj_id, cstate->mode.id,
887 cstate->mode.value);
888 if (ret < 0) goto err;
889
890 ret =
891 sym_drmModeAtomicAddProperty(req, cstate->obj_id, cstate->active.id,
892 cstate->active.value);
893 if (ret < 0) goto err;
894
895 EINA_LIST_FOREACH(output->planes, ll, plane)
896 {
897 pstate = plane->state;
898
899 ret =
900 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
901 pstate->cid.id, pstate->cid.value);
902 if (ret < 0) goto err;
903
904 ret =
905 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
906 pstate->fid.id, pstate->fid.value);
907 if (ret < 0) goto err;
908
909 ret =
910 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
911 pstate->sx.id, pstate->sx.value);
912 if (ret < 0) goto err;
913
914 ret =
915 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
916 pstate->sy.id, pstate->sy.value);
917 if (ret < 0) goto err;
918
919 ret =
920 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
921 pstate->sw.id, pstate->sw.value);
922 if (ret < 0) goto err;
923
924 ret =
925 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
926 pstate->sh.id, pstate->sh.value);
927 if (ret < 0) goto err;
928
929 ret =
930 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
931 pstate->cx.id, pstate->cx.value);
932 if (ret < 0) goto err;
933
934 ret =
935 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
936 pstate->cy.id, pstate->cy.value);
937 if (ret < 0) goto err;
938
939 ret =
940 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
941 pstate->cw.id, pstate->cw.value);
942 if (ret < 0) goto err;
943
944 ret =
945 sym_drmModeAtomicAddProperty(req, pstate->obj_id,
946 pstate->ch.id, pstate->ch.value);
947 if (ret < 0) goto err;
948 }
949 }
950
951 ret =
952 sym_drmModeAtomicCommit(device->fd, req, flags, NULL);
953 if (ret < 0) ERR("Failed Atomic Commit Test: %m");
954 else res = EINA_TRUE;
955
956 if (res)
957 {
958 if (device->atomic_req)
959 {
960 /* merge this test commit with previous */
961 ret = sym_drmModeAtomicMerge(device->atomic_req, req);
962 if (ret < 0)
963 {
964 /* we failed to merge for some reason. just use this req */
965 device->atomic_req = req;
966 }
967 }
968 else
969 device->atomic_req = req;
970 }
971
972 return res;
973
974err:
975 sym_drmModeAtomicFree(req);
976#endif
977
978 return res;
979}
980
981EAPI Eina_Bool
982ecore_drm2_atomic_commit(Ecore_Drm2_Device *device)
983{
984#ifdef HAVE_ATOMIC_DRM
985 int res = 0;
986 uint32_t flags =
987 DRM_MODE_ATOMIC_NONBLOCK | DRM_MODE_PAGE_FLIP_EVENT |
988 DRM_MODE_ATOMIC_ALLOW_MODESET;
989#endif
990
991 EINA_SAFETY_ON_NULL_RETURN_VAL(device, EINA_FALSE);
992 EINA_SAFETY_ON_TRUE_RETURN_VAL((device->fd < 0), EINA_FALSE);
993
994#ifdef HAVE_ATOMIC_DRM
995 if (!device->atomic_req) return EINA_FALSE;
996
997 res =
998 sym_drmModeAtomicCommit(device->fd, device->atomic_req, flags, NULL);
999 if (res < 0)
1000 ERR("Failed Atomic Commit Test: %m");
1001 else
1002 return EINA_TRUE;
1003#endif
1004
1005 return EINA_FALSE;
1006}