ecore_drm2: Add enums for state changes

This patch adds some enums so we can more easily track what has
changed in each objects state. This will allow us to selectively apply
Only what has been changed in each object
This commit is contained in:
Christopher Michael 2023-03-08 10:26:01 -05:00
parent 57caf9a1bb
commit 62f8ea49fa
5 changed files with 71 additions and 12 deletions

View File

@ -130,6 +130,11 @@ cont:
sym_drmModeFreeObjectProperties(oprops);
/* duplicate current state into pending so we can handle changes */
conn->state.pending = calloc(1, sizeof(Ecore_Drm2_Connector_State));
if (conn->state.pending)
memcpy(conn->state.pending, conn->state.current, sizeof(Ecore_Drm2_Connector_State));
/* send message to thread for debug printing connector state */
_ecore_drm2_connector_state_thread_send(ECORE_DRM2_THREAD_CODE_DEBUG);
}

View File

@ -115,6 +115,11 @@ cont:
sym_drmModeFreeObjectProperties(oprops);
/* duplicate current state into pending so we can handle changes */
crtc->state.pending = calloc(1, sizeof(Ecore_Drm2_Crtc_State));
if (crtc->state.pending)
memcpy(crtc->state.pending, crtc->state.current, sizeof(Ecore_Drm2_Crtc_State));
/* send message to thread for debug printing crtc state */
_ecore_drm2_crtc_state_thread_send(ECORE_DRM2_THREAD_CODE_DEBUG);
}

View File

@ -459,6 +459,11 @@ _ecore_drm2_display_state_fill(Ecore_Drm2_Display *disp)
/* get connected state */
disp->connected = (disp->conn->drmConn->connection == DRM_MODE_CONNECTED);
/* duplicate current state into pending so we can handle changes */
disp->state.pending = calloc(1, sizeof(Ecore_Drm2_Display_State));
if (disp->state.pending)
memcpy(disp->state.pending, disp->state.current, sizeof(Ecore_Drm2_Display_State));
/* send message to thread for debug printing display state */
_ecore_drm2_display_state_thread_send(ECORE_DRM2_THREAD_CODE_DEBUG);
}
@ -751,7 +756,11 @@ ecore_drm2_display_primary_set(Ecore_Drm2_Display *disp, Eina_Bool primary)
{
EINA_SAFETY_ON_NULL_RETURN(disp);
if (disp->state.current->primary == primary) return;
/* TODO, FIXME */
disp->state.pending->primary = primary;
disp->state.pending->changes |= ECORE_DRM2_DISPLAY_STATE_PRIMARY;
}
EAPI const Eina_List *
@ -809,5 +818,9 @@ ecore_drm2_display_rotation_set(Ecore_Drm2_Display *disp, uint64_t rotation)
if (disp->state.current->rotation == rotation) return EINA_TRUE;
/* TODO, FIXME */
disp->state.pending->rotation = rotation;
disp->state.pending->changes |= ECORE_DRM2_DISPLAY_STATE_ROTATION;
return EINA_FALSE;
}

View File

@ -203,6 +203,11 @@ _ecore_drm2_plane_state_fill(Ecore_Drm2_Plane *plane)
sym_drmModeFreeObjectProperties(oprops);
/* duplicate current state into pending so we can handle changes */
plane->state.pending = calloc(1, sizeof(Ecore_Drm2_Plane_State));
if (plane->state.pending)
memcpy(plane->state.pending, plane->state.current, sizeof(Ecore_Drm2_Plane_State));
/* send message to thread for debug printing plane state */
_ecore_drm2_plane_state_thread_send(ECORE_DRM2_THREAD_CODE_DEBUG);
}

View File

@ -61,12 +61,7 @@ extern int _ecore_drm2_log_dom;
# endif
# define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_drm2_log_dom, __VA_ARGS__)
typedef enum _Ecore_Drm2_Thread_Op_Code
{
ECORE_DRM2_THREAD_CODE_FILL,
ECORE_DRM2_THREAD_CODE_DEBUG
} Ecore_Drm2_Thread_Op_Code;
/* internal structures & enums (not exposed) */
typedef enum _Ecore_Drm2_Backlight_Type
{
ECORE_DRM2_BACKLIGHT_RAW,
@ -74,7 +69,43 @@ typedef enum _Ecore_Drm2_Backlight_Type
ECORE_DRM2_BACKLIGHT_FIRMWARE
} Ecore_Drm2_Backlight_Type;
/* internal structures (not exposed) */
typedef enum _Ecore_Drm2_Thread_Op_Code
{
ECORE_DRM2_THREAD_CODE_FILL,
ECORE_DRM2_THREAD_CODE_DEBUG
} Ecore_Drm2_Thread_Op_Code;
typedef enum _Ecore_Drm2_Connector_State_Changes
{
ECORE_DRM2_CONNECTOR_STATE_CRTC = (1 << 0),
ECORE_DRM2_CONNECTOR_STATE_DPMS = (1 << 1),
ECORE_DRM2_CONNECTOR_STATE_ASPECT = (1 << 2),
ECORE_DRM2_CONNECTOR_STATE_SCALING = (1 << 3),
} Ecore_Drm2_Connector_State_Changes;
typedef enum _Ecore_Drm2_Crtc_State_Changes
{
ECORE_DRM2_CRTC_STATE_ACTIVE = (1 << 0),
ECORE_DRM2_CRTC_STATE_MODE = (1 << 1),
} Ecore_Drm2_Crtc_State_Changes;
typedef enum _Ecore_Drm2_Plane_State_Changes
{
ECORE_DRM2_PLANE_STATE_CID = (1 << 0),
ECORE_DRM2_PLANE_STATE_FID = (1 << 1),
ECORE_DRM2_PLANE_STATE_ROTATION = (1 << 2),
} Ecore_Drm2_Plane_State_Changes;
typedef enum _Ecore_Drm2_Display_State_Changes
{
ECORE_DRM2_DISPLAY_STATE_GAMMA = (1 << 0),
ECORE_DRM2_DISPLAY_STATE_ROTATION = (1 << 1),
ECORE_DRM2_DISPLAY_STATE_BACKLIGHT = (1 << 2),
ECORE_DRM2_DISPLAY_STATE_MODE = (1 << 3),
ECORE_DRM2_DISPLAY_STATE_PRIMARY = (1 << 4),
ECORE_DRM2_DISPLAY_STATE_ENABLED = (1 << 5),
} Ecore_Drm2_Display_State_Changes;
typedef struct _Ecore_Drm2_Atomic_Blob
{
uint32_t id, value;
@ -96,7 +127,7 @@ typedef struct _Ecore_Drm2_Atomic_Range
typedef struct _Ecore_Drm2_Connector_State
{
uint32_t obj_id;
uint32_t obj_id, changes;
Ecore_Drm2_Atomic_Property crtc;
Ecore_Drm2_Atomic_Property dpms;
Ecore_Drm2_Atomic_Property aspect;
@ -121,7 +152,7 @@ typedef struct _Ecore_Drm2_Connector_State
typedef struct _Ecore_Drm2_Crtc_State
{
uint32_t obj_id;
uint32_t obj_id, changes;
/* int index; */
Ecore_Drm2_Atomic_Property active;
Ecore_Drm2_Atomic_Blob mode;
@ -139,9 +170,8 @@ typedef struct _Ecore_Drm2_Crtc_State
typedef struct _Ecore_Drm2_Plane_State
{
uint32_t obj_id, mask;
uint32_t num_formats;
uint32_t *formats;
uint32_t obj_id, mask, changes;
uint32_t num_formats, *formats;
Ecore_Drm2_Atomic_Property type;
Ecore_Drm2_Atomic_Property cid, fid;
@ -167,6 +197,7 @@ typedef struct _Ecore_Drm2_Plane_State
typedef struct _Ecore_Drm2_Display_State
{
uint32_t changes;
uint16_t gamma;
uint64_t rotation;
double backlight;