This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch devs/devilhorns/apos
in repository efl.

View the commit online.

commit 6df482fa4ee4e5ce0c0ec7a7d0b4fc7ac8ed5d35
Author: Christopher Michael <devilho...@comcast.net>
AuthorDate: Tue Oct 18 10:34:18 2022 -0400

    ecore_drm2: Add start of explicit threading for crtc state
    
    NB: Pushing this so that the code is up there, but it is certainly
    going to change shortly
---
 src/lib/ecore_drm2/Ecore_Drm2.h          |  2 +
 src/lib/ecore_drm2/ecore_drm2_crtcs.c    | 88 ++++++++++++++++++++++++--------
 src/lib/ecore_drm2/ecore_drm2_displays.c | 10 ++++
 src/lib/ecore_drm2/ecore_drm2_private.h  |  2 +
 4 files changed, 80 insertions(+), 22 deletions(-)

diff --git a/src/lib/ecore_drm2/Ecore_Drm2.h b/src/lib/ecore_drm2/Ecore_Drm2.h
index 1b3307fdec..3c1a15f6d5 100644
--- a/src/lib/ecore_drm2/Ecore_Drm2.h
+++ b/src/lib/ecore_drm2/Ecore_Drm2.h
@@ -54,6 +54,8 @@ EAPI void ecore_drm2_device_close(Ecore_Drm2_Device *dev);
 EAPI void ecore_drm2_device_cursor_size_get(Ecore_Drm2_Device *dev, int *width, int *height);
 EAPI void ecore_drm2_device_preferred_depth_get(Ecore_Drm2_Device *dev, int *depth, int *bpp);
 
+EAPI void ecore_drm2_display_mode_set(Ecore_Drm2_Display *disp, Ecore_Drm2_Display_Mode *mode, int x, int y);
+
 # endif
 
 #endif
diff --git a/src/lib/ecore_drm2/ecore_drm2_crtcs.c b/src/lib/ecore_drm2/ecore_drm2_crtcs.c
index bafebaad8c..3569c97111 100644
--- a/src/lib/ecore_drm2/ecore_drm2_crtcs.c
+++ b/src/lib/ecore_drm2/ecore_drm2_crtcs.c
@@ -1,5 +1,28 @@
 #include "ecore_drm2_private.h"
 
+static Eina_Thread_Queue *thq = NULL;
+
+typedef struct
+{
+   Eina_Thread_Queue_Msg head;
+   Eina_Bool fill : 1;
+   Eina_Bool commit : 1;
+   Eina_Bool debug : 1;
+} Thread_Msg;
+
+static void
+_ecore_drm2_crtc_state_thread_send(Eina_Bool fill, Eina_Bool commit, Eina_Bool debug)
+{
+   Thread_Msg *msg;
+   void *ref;
+
+   msg = eina_thread_queue_send(thq, sizeof(Thread_Msg), &ref);
+   msg->fill = fill;
+   msg->commit = commit;
+   msg->debug = debug;
+   eina_thread_queue_send_done(thq, ref);
+}
+
 static void
 _ecore_drm2_crtc_state_debug(Ecore_Drm2_Crtc *crtc)
 {
@@ -93,39 +116,52 @@ cont:
      }
 
    sym_drmModeFreeObjectProperties(oprops);
+
+   /* send message to thread for debug printing crtc state */
+   _ecore_drm2_crtc_state_thread_send(EINA_FALSE, EINA_FALSE, EINA_TRUE);
 }
 
 static void
-_ecore_drm2_crtc_state_thread(void *data, Ecore_Thread *thread EINA_UNUSED)
+_ecore_drm2_crtc_state_commit(Ecore_Drm2_Crtc *crtc EINA_UNUSED)
+{
+   /* Ecore_Drm2_Crtc_State *cstate; */
+
+   /* cstate = crtc->state; */
+   /* DBG("CRTC State Commit"); */
+}
+
+static void
+_ecore_drm2_crtc_state_thread(void *data, Ecore_Thread *thread)
 {
    Ecore_Drm2_Crtc *crtc;
+   Thread_Msg *msg;
+   void *ref;
 
    crtc = data;
-   if (!crtc->state)
-     _ecore_drm2_crtc_state_fill(crtc);
-   else
+
+   eina_thread_name_set(eina_thread_self(), "Ecore-drm2-crtc");
+
+   while (!ecore_thread_check(thread))
      {
-        /* TODO: update atomic state for commit */
+        msg = eina_thread_queue_wait(thq, &ref);
+        if (msg)
+          {
+             if (msg->fill) _ecore_drm2_crtc_state_fill(crtc);
+             if (msg->commit) _ecore_drm2_crtc_state_commit(crtc);
+             if (msg->debug) _ecore_drm2_crtc_state_debug(crtc);
+             eina_thread_queue_wait_done(thq, ref);
+          }
      }
 }
 
 static void
-_ecore_drm2_crtc_state_thread_end(void *data, Ecore_Thread *thread EINA_UNUSED)
+_ecore_drm2_crtc_state_thread_notify(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED, void *msg)
 {
-   Ecore_Drm2_Crtc *crtc;
+   /* Ecore_Drm2_Crtc *crtc; */
 
-   crtc = data;
-   /* crtc->thread = NULL; */
-   _ecore_drm2_crtc_state_debug(crtc);
-}
+   /* crtc = data; */
 
-static void
-_ecore_drm2_crtc_state_thread_cancel(void *data, Ecore_Thread *thread EINA_UNUSED)
-{
-   Ecore_Drm2_Crtc *crtc;
-
-   crtc = data;
-   crtc->thread = NULL;
+   free(msg);
 }
 
 static Ecore_Drm2_Crtc *
@@ -178,12 +214,11 @@ _ecore_drm2_crtcs_create(Ecore_Drm2_Device *dev)
         if (!crtc) goto err;
 
         /* NB: Use an explicit thread to fill crtc atomic state */
+        thq = eina_thread_queue_new();
         crtc->thread =
           ecore_thread_feedback_run(_ecore_drm2_crtc_state_thread,
-                                    NULL, //_ecore_drm2_crtc_state_thread_notify,
-                                    _ecore_drm2_crtc_state_thread_end,
-                                    _ecore_drm2_crtc_state_thread_cancel,
-                                    crtc, EINA_TRUE);
+                                    _ecore_drm2_crtc_state_thread_notify,
+                                    NULL, NULL, crtc, EINA_TRUE);
      }
 
    sym_drmModeFreeResources(res);
@@ -209,3 +244,12 @@ _ecore_drm2_crtcs_destroy(Ecore_Drm2_Device *dev)
         free(crtc);
      }
 }
+
+void
+_ecore_drm2_crtc_mode_set(Ecore_Drm2_Crtc *crtc, Ecore_Drm2_Display_Mode *mode EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED)
+{
+   /* TODO: add code to actually set crtc mode */
+
+   /* send message to thread queue that we have work to do */
+   _ecore_drm2_crtc_state_thread_send(EINA_FALSE, EINA_TRUE, EINA_FALSE);
+}
diff --git a/src/lib/ecore_drm2/ecore_drm2_displays.c b/src/lib/ecore_drm2/ecore_drm2_displays.c
index b3ba81fbf6..2b17231c6a 100644
--- a/src/lib/ecore_drm2/ecore_drm2_displays.c
+++ b/src/lib/ecore_drm2/ecore_drm2_displays.c
@@ -491,3 +491,13 @@ _ecore_drm2_displays_destroy(Ecore_Drm2_Device *dev)
         free(disp);
      }
 }
+
+EAPI void
+ecore_drm2_display_mode_set(Ecore_Drm2_Display *disp, Ecore_Drm2_Display_Mode *mode, int x, int y)
+{
+   EINA_SAFETY_ON_NULL_RETURN(disp);
+   EINA_SAFETY_ON_NULL_RETURN(mode);
+   EINA_SAFETY_ON_NULL_RETURN(disp->crtc);
+
+   _ecore_drm2_crtc_mode_set(disp->crtc, mode, x, y);
+}
diff --git a/src/lib/ecore_drm2/ecore_drm2_private.h b/src/lib/ecore_drm2/ecore_drm2_private.h
index 1565870969..02b4c329bf 100644
--- a/src/lib/ecore_drm2/ecore_drm2_private.h
+++ b/src/lib/ecore_drm2/ecore_drm2_private.h
@@ -278,6 +278,8 @@ void _ecore_drm2_displays_destroy(Ecore_Drm2_Device *dev);
 Eina_Bool _ecore_drm2_planes_create(Ecore_Drm2_Device *dev);
 void _ecore_drm2_planes_destroy(Ecore_Drm2_Device *dev);
 
+void _ecore_drm2_crtc_mode_set(Ecore_Drm2_Crtc *crtc, Ecore_Drm2_Display_Mode *mode, int x, int y);
+
 /* external drm function prototypes (for dlopen) */
 extern void *(*sym_drmModeGetResources)(int fd);
 extern void (*sym_drmModeFreeResources)(drmModeResPtr ptr);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to