### Install SRM on Debian-based Systems (Ubuntu, Linux Mint) Source: https://cuarzosoftware.github.io/SRM/downloads_page This snippet details the steps to install SRM on Debian-based systems. It includes installing necessary development packages using apt, cloning the SRM repository, setting up the build environment with Meson, installing the built project, and updating the dynamic linker cache. ```bash sudo apt install build-essential meson seat-dev libinput-dev libudev-dev libdrm-dev libgbm-dev libegl1-mesa-dev libgles2-mesa-dev hwinfo libdisplay-info-dev git clone https://github.com/CuarzoSoftware/SRM.git cd SRM/src meson setup build cd build meson install sudo ldconfig ``` -------------------------------- ### Install SRM on RedHat-based Systems (Fedora, CentOS, openSUSE) Source: https://cuarzosoftware.github.io/SRM/downloads_page This snippet outlines the process for installing SRM on RedHat-based systems. It involves installing development tools and specific libraries using dnf, cloning the SRM repository, configuring the build with Meson, installing the compiled project, and updating the dynamic linker cache. ```bash sudo dnf install @development-tools sudo dnf install meson hwinfo libseat-devel mesa-libEGL-devel libglvnd-devel libudev-devel libdrm-devel libgbm-devel libdisplay-info-devel libinput-devel git clone https://github.com/CuarzoSoftware/SRM.git cd SRM/src meson setup build cd build meson install sudo ldconfig ``` -------------------------------- ### Fragment Shader Example for GL_TEXTURE_EXTERNAL_OES Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_buffer An example fragment shader demonstrating how to use a texture with the GL_TEXTURE_EXTERNAL_OES target. This requires the GL_OES_EGL_image_external extension. ```glsl #extension GL_OES_EGL_image_external : require uniform samplerExternalOES texture; varying vec2 v_texcoord; void main() { gl_FragColor = texture2D(texture, v_texcoord); } ``` -------------------------------- ### SRMConnectorGetContentType Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Gets the content type hint. ```APIDOC ## srmConnectorGetContentType ### Description Gets the content type hint. ### Method N/A (C function) ### Endpoint N/A (C function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage: // SRMConnector *connector; // SRM_CONNECTOR_CONTENT_TYPE contentType = srmConnectorGetContentType(connector); ``` ### Response #### Success Response (200) `SRM_CONNECTOR_CONTENT_TYPE` representing the content type hint. #### Response Example ```json { "return_value": "SRM_CONNECTOR_CONTENT_TYPE_GRAPHICS" } ``` ``` -------------------------------- ### Get GL Extensions (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Returns a structure indicating which OpenGL extensions the device supports. This helps in determining available OpenGL features. It requires a pointer to the SRMDevice instance. ```c const SRMGLDeviceExtensions * srmDeviceGetGLExtensions(SRMDevice * _device_) { // Implementation details... return NULL; } ``` -------------------------------- ### Get EGL Extensions (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Returns a structure indicating which EGL extensions the device supports. This helps in determining available EGL features. It requires a pointer to the SRMDevice instance. ```c const SRMEGLDeviceExtensions * srmDeviceGetEGLExtensions(SRMDevice * _device_) { // Implementation details... return NULL; } ``` -------------------------------- ### Get EGL Functions (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Returns a structure containing pointers to available EGL functions. This allows dynamic access to EGL functionality. It requires a pointer to the SRMDevice instance. ```c const SRMEGLDeviceFunctions * srmDeviceGetEGLFunctions(SRMDevice * _device_) { // Implementation details... return NULL; } ``` -------------------------------- ### SRMDevice Rendering Information Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Functions related to checking if a device can render, getting the rendering device, and its rendering mode. ```APIDOC ## UInt8 srmDeviceIsRenderer (SRMDevice *device) ### Description Checks if the device can perform rendering. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (UInt8) Returns 1 if the device is a renderer, 0 otherwise. #### Response Example N/A ## SRMDevice * srmDeviceGetRendererDevice (SRMDevice *device) ### Description Gets the device that performs rendering for this device. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (SRMDevice *) Returns a pointer to the rendering device. #### Response Example N/A ## SRM_RENDER_MODE srmDeviceGetRenderMode (SRMDevice *device) ### Description Gets the rendering mode of the device. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (SRM_RENDER_MODE) Returns the rendering mode of the device. #### Response Example N/A ``` -------------------------------- ### Get EGL Display (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Retrieves the EGLDisplay associated with the device. This is essential for EGL operations. It requires a pointer to the SRMDevice instance. ```c EGLDisplay * srmDeviceGetEGLDisplay(SRMDevice * _device_) { // Implementation details... return NULL; } ``` -------------------------------- ### SRM OpenGL Initialization and Viewport Setup Source: https://cuarzosoftware.github.io/SRM/tutorial_page Initializes OpenGL for a connector by setting the viewport dimensions based on the current connector mode. It also schedules a repaint to trigger the paintGL event. This function should not be called directly for drawing. ```c static void initializeGL(SRMConnector *connector, void *userData) { SRM_UNUSED(userData); /* You must not do any drawing here as it won't make it to * the screen. */ SRMConnectorMode *mode = srmConnectorGetCurrentMode(connector); glViewport(0, 0, srmConnectorModeGetWidth(mode), srmConnectorModeGetHeight(mode)); // Schedule a repaint (this eventually calls paintGL() later, not directly) srmConnectorRepaint(connector); } ``` -------------------------------- ### Get EGL Context (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Retrieves the EGLContext associated with the device. This context is used for rendering operations. It requires a pointer to the SRMDevice instance. ```c EGLContext * srmDeviceGetEGLContext(SRMDevice * _device_) { // Implementation details... return NULL; } ``` -------------------------------- ### Get Connector's Device (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Retrieves the SRMDevice to which the given connector belongs. This device might not always be the same as the rendering device, especially in certain rendering modes. ```c SRMDevice * srmConnectorGetDevice(SRMConnector * _connector_); ``` -------------------------------- ### Get DMA Texture Formats (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Retrieves a list of all DMA (Direct Memory Access) texture formats supported by the device. This includes both render and external formats. It requires a pointer to the SRMDevice instance. ```c SRMList * srmDeviceGetDMATextureFormats(SRMDevice * _device_) { // Implementation details... return NULL; } ``` -------------------------------- ### Get DMA Render Formats (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Retrieves a list of DMA (Direct Memory Access) render formats supported by the device. Render formats are associated with the GL_TEXTURE_2D target. It requires a pointer to the SRMDevice instance. ```c SRMList * srmDeviceGetDMARenderFormats(SRMDevice * _device_) { // Implementation details... return NULL; } ``` -------------------------------- ### Get Connector's Renderer Device (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Retrieves the SRMDevice responsible for rendering operations for the connector. This device can differ from the connector's primary device in modes like PRIME, DUMB, or CPU rendering. ```c SRMDevice * srmConnectorGetRendererDevice(SRMConnector * _connector_); ``` -------------------------------- ### Get DMA External Formats (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Retrieves a list of DMA (Direct Memory Access) external formats supported by the device. External formats are associated with the GL_TEXTURE_EXTERNAL_OES target. It requires a pointer to the SRMDevice instance. ```c SRMList * srmDeviceGetDMAExternalFormats(SRMDevice * _device_) { // Implementation details... return NULL; } ``` -------------------------------- ### OpenGL Event Handling Interface for SRMConnector Source: https://cuarzosoftware.github.io/SRM/struct_s_r_m_connector_interface Defines an interface for managing OpenGL events within the SRMConnector. This includes setup and teardown for rendering, handling frame updates, detecting page flips, and responding to viewport resizing. It's designed to be integrated with the srmConnectorInitialize() function. ```c #include void(* initializeGL )(SRMConnector *connector, void *data); void(* paintGL )(SRMConnector *connector, void *data); void(* pageFlipped )(SRMConnector *connector, void *data); void(* resizeGL )(SRMConnector *connector, void *data); void(* uninitializeGL )(SRMConnector *connector, void *data); ``` -------------------------------- ### Project Setup with Meson Build System Source: https://cuarzosoftware.github.io/SRM/tutorial_page This snippet demonstrates how to set up a C project using the Meson build system, including finding dependencies for OpenGL ES 2.0 (glesv2), SRM, and the math library. It defines the project name, version, and the main executable source file. ```meson project('srm-example', 'c', version : '0.1.0') c = meson.get_compiler('c') pkg = import('pkgconfig') glesv2_dep = dependency('glesv2') srm_dep = dependency('SRM') m_dep = c.find_library('m') sources = ['main.c'] executable( 'srm-example', sources, dependencies: [glesv2_dep, srm_dep, m_dep]) ``` -------------------------------- ### Get SRM Connector Content Type Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Gets the content type hint that was previously set for the SRM connector using srmConnectorSetContentType(). ```c SRM_CONNECTOR_CONTENT_TYPE srmConnectorGetContentType(SRMConnector * _connector_) // Gets the content type hint. ``` -------------------------------- ### Enumerate Devices and Connectors (C) Source: https://cuarzosoftware.github.io/SRM/tutorial_page This C code snippet demonstrates how to initialize the SRMCore, iterate through all available devices (GPUs), and then iterate through the connectors (displays) for each device. It prints detailed information about each connector, such as its ID, name, model, and manufacturer. The code requires the SRM library and assumes its proper initialization. ```c int main() { SRMCore *core = srmCoreCreate(&srmInterface, NULL); if (!core) { SRMFatal("[srm-example] Failed to create SRMCore."); return 0; } // Loop each GPU (device) SRMListForeach (deviceIt, srmCoreGetDevices(core)) { SRMDevice *device = srmListItemGetData(deviceIt); SRMLog("[srm-example] Device %s connectors:", srmDeviceGetName(device)); // Loop each GPU connector (screen) SRMListForeach (connectorIt, srmDeviceGetConnectors(device)) { SRMConnector *connector = srmListItemGetData(connectorIt); SRMLog("[srm-example] - Connector %d %s %s %s.", srmConnectorGetID(connector), srmConnectorGetName(connector), srmConnectorGetModel(connector), srmConnectorGetManufacturer(connector)); } } srmCoreDestroy(core); return 0; } ``` -------------------------------- ### SRMCore Initialization and Destruction in C Source: https://cuarzosoftware.github.io/SRM/tutorial_page Demonstrates the creation and destruction of an SRMCore instance using the provided SRMInterface. It includes error handling for SRMCore creation and ensures proper cleanup by calling `srmCoreDestroy`. ```c #include #include #include #include #include #include #include #include #include #include #include /* Opens a DRM device */ static int openRestricted(const char *path, int flags, void *userData) { SRM_UNUSED(userData); // Here something like libseat could be used instead return open(path, flags); } /* Closes a DRM device */ static void closeRestricted(int fd, void *userData) { SRM_UNUSED(userData); close(fd); } static SRMInterface srmInterface = { .openRestricted = &openRestricted, .closeRestricted = &closeRestricted }; SRM_UNUSED #define SRM_UNUSED(var) int main() { SRMCore *core = srmCoreCreate(&srmInterface, NULL); if (!core) { SRMFatal("[srm-example] Failed to create SRMCore."); return 1; } srmCoreDestroy(core); return 0; } ``` -------------------------------- ### Get SRM Connector Presentation Clock ID Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Gets the clock ID used for timestamps returned by srmConnectorGetPresentationTime(). The clock ID can be either CLOCK_MONOTONIC or CLOCK_REALTIME, indicating the type of time source used for presentation. ```c clockid_t srmConnectorGetPresentationClock(SRMConnector * _connector_) // Gets the clock ID used for the timestamps returned by srmConnectorGetPresentationTime(). ``` -------------------------------- ### Initialize SRM Connectors with C Source: https://cuarzosoftware.github.io/SRM/tutorial_page This C code snippet demonstrates initializing all connected SRM connectors. It iterates through each device and its connectors, checks if a display is attached using `srmConnectorIsConnected`, and then initializes the connector with `srmConnectorInitialize`. This process requires the `SRMCore` and relevant interfaces. ```c int main() { SRMCore *core = srmCoreCreate(&srmInterface, NULL); if (!core) { SRMFatal("[srm-example] Failed to create SRMCore."); return 1; } // Loop each GPU (device) SRMListForeach (deviceIt, srmCoreGetDevices(core)) { SRMDevice *device = srmListItemGetData(deviceIt); SRMLog("[srm-example] Device %s connectors:", srmDeviceGetName(device)); // Loop each GPU connector (screen) SRMListForeach (connectorIt, srmDeviceGetConnectors(device)) { SRMConnector *connector = srmListItemGetData(connectorIt); SRMLog("[srm-example] - Connector %d %s %s %s.", srmConnectorGetID(connector), srmConnectorGetName(connector), srmConnectorGetModel(connector), srmConnectorGetManufacturer(connector)); // Check if there is a display attached if (srmConnectorIsConnected(connector)) { // Initialize the connector if (!srmConnectorInitialize(connector, &connectorInterface, NULL)) { SRMError("[srm-example] Failed to initialize connector %s", srmConnectorGetName(connector)); } } } } // Sleep 10 secs usleep(10000000); srmCoreDestroy(core); return 0; } ``` -------------------------------- ### SRMConnectorGetSubPixel Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Get the subpixel layout associated with a connector. ```APIDOC ## srmConnectorGetSubPixel ### Description Get the subpixel layout associated with a connector. ### Method N/A (C function) ### Endpoint N/A (C function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage: // SRMConnector *connector; // SRM_CONNECTOR_SUBPIXEL subpixel = srmConnectorGetSubPixel(connector); ``` ### Response #### Success Response (200) `SRM_CONNECTOR_SUBPIXEL` value representing the subpixel layout. #### Response Example ```json { "return_value": "SRM_CONNECTOR_SUBPIXEL_RGB" } ``` ``` -------------------------------- ### Make Device Current (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Sets the EGL display and context for the specified device as current for the calling thread. If no existing EGL context is associated with the calling thread, a new one is created and made current. It requires a pointer to the SRMDevice instance. ```c void srmDeviceMakeCurrent(SRMDevice * _device_) { // Implementation details... } ``` -------------------------------- ### SRMConnectorGetPresentationClock Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Gets the clock ID used for the timestamps returned by srmConnectorGetPresentationTime(). ```APIDOC ## srmConnectorGetPresentationClock ### Description Gets the clock ID used for the timestamps returned by `srmConnectorGetPresentationTime()`. ### Method N/A (C function) ### Endpoint N/A (C function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage: // SRMConnector *connector; // clockid_t clock_id = srmConnectorGetPresentationClock(connector); ``` ### Response #### Success Response (200) `clockid_t` representing the clock ID. #### Response Example ```json { "return_value": "CLOCK_MONOTONIC" } ``` ``` -------------------------------- ### Create SRM Buffer from Main Memory (C/C++) Source: https://cuarzosoftware.github.io/SRM/tutorial_page Demonstrates how to create an SRM buffer from a CPU-accessible memory buffer. It takes the SRM core, allocator device (NULL for sharing across all devices), dimensions, stride, pixel data, and format as input. The output is an SRMBuffer object. ```c++ #include // ... // 128 x 256 ARGB8 image in main memory UInt8 pixelsSource[128 * 256 * 4]; // Pass NULL as the allocator device to share the buffer across all devices SRMBuffer *buffer = srmBufferCreateFromCPU( core, // SRM core NULL, // allocator device 128, // src width 256, // src height 128 * 4, // src stride pixelsSource, DRM_FORMAT_ARGB8888); if (!buffer) { SRMError("Failed to create a buffer from main memory."); exit(1); } // ... ``` -------------------------------- ### Wait for Device Sync (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Ensures that all pending rendering commands are completed before continuing execution. This is useful for synchronizing rendering operations. It requires a pointer to the SRMDevice instance. ```c void srmDeviceSyncWait(SRMDevice * _device_) { // Implementation details... } ``` -------------------------------- ### SRMConnectorGetGammaSize Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Gets the number of elements used to represent each RGB gamma correction curve. ```APIDOC ## srmConnectorGetGammaSize ### Description Gets the number of elements used to represent each RGB gamma correction curve. ### Method N/A (C function) ### Endpoint N/A (C function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage: // SRMConnector *connector; // Int32 size = srmConnectorGetGammaSize(connector); ``` ### Response #### Success Response (200) `UInt64` representing the number of elements per gamma curve. #### Response Example ```json { "return_value": 1024 } ``` ``` -------------------------------- ### SRMConnector Device Information Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Functions to get the device and renderer device associated with an SRMConnector. ```APIDOC ## srmConnectorGetDevice ### Description Gets the device this connector belongs to. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c SRMDevice *device = srmConnectorGetDevice(connector); ``` ### Response #### Success Response (SRMDevice *) Returns a pointer to the SRMDevice object. #### Response Example ```c // Example usage if SRMDevice has members // int deviceId = device->id; ``` ## srmConnectorGetRendererDevice ### Description Retrieve the renderer device associated with the connector. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c SRMDevice *rendererDevice = srmConnectorGetRendererDevice(connector); ``` ### Response #### Success Response (SRMDevice *) Returns a pointer to the SRMDevice object representing the renderer. #### Response Example ```c // Example usage // if (rendererDevice) { ... } ``` ``` -------------------------------- ### Basic C main function Source: https://cuarzosoftware.github.io/SRM/tutorial_page A minimal C program entry point that returns an integer status code. This serves as the basic structure for a C application, often used in conjunction with build systems like Meson. ```c int main() { return 0; } ``` -------------------------------- ### SRMConnector Rendering Pipeline Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Functions to get the current encoder, CRTC, and planes associated with the connector. ```APIDOC ## srmConnectorGetCurrentEncoder ### Description Get the currently used encoder for the connector. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c SRMEncoder *encoder = srmConnectorGetCurrentEncoder(connector); ``` ### Response #### Success Response (SRMEncoder *) Returns a pointer to the current SRMEncoder object. #### Response Example ```c // Example usage // if (encoder) { ... } ``` ## srmConnectorGetCurrentCrtc ### Description Get the currently used CRT controller (CRTC) for the connector. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c SRMCrtc *crtc = srmConnectorGetCurrentCrtc(connector); ``` ### Response #### Success Response (SRMCrtc *) Returns a pointer to the current SRMCrtc object. #### Response Example ```c // Example usage // if (crtc) { ... } ``` ## srmConnectorGetCurrentPrimaryPlane ### Description Get the currently used primary plane for the connector. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c SRMPlane *primaryPlane = srmConnectorGetCurrentPrimaryPlane(connector); ``` ### Response #### Success Response (SRMPlane *) Returns a pointer to the current SRMPlane object for the primary plane. #### Response Example ```c // Example usage // if (primaryPlane) { ... } ``` ## srmConnectorGetCurrentCursorPlane ### Description Get the currently used cursor plane for the connector. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c SRMPlane *cursorPlane = srmConnectorGetCurrentCursorPlane(connector); ``` ### Response #### Success Response (SRMPlane *) Returns a pointer to the current SRMPlane object for the cursor plane. #### Response Example ```c // Example usage // if (cursorPlane) { ... } ``` ``` -------------------------------- ### Initialize SRM Connector Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Initializes a given SRMConnector, setting up its rendering thread and invoking `initializeGL()`. It requires a pointer to the connector, an interface struct for event handling, and user data. Returns 1 on success, 0 on error. Ensure the SRMConnectorInterface is correctly set up to avoid crashes. ```c UInt8 srmConnectorInitialize(SRMConnector *connector, SRMConnectorInterface *interface, void *userData) { // Implementation details... return 1; // Success } ``` -------------------------------- ### Get SRM Connector Framebuffer ID Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Retrieves the ID of the currently bound OpenGL framebuffer associated with the SRMConnector. ```c UInt32 srmConnectorGetFramebufferID(SRMConnector *connector) { // Implementation details... return 0; // Example return value } ``` -------------------------------- ### SRMDevice Context and Synchronization Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Functions to make the EGL context current and to wait for rendering commands to complete. ```APIDOC ## void srmDeviceMakeCurrent (SRMDevice *device) ### Description Sets the EGL display and context for the specified device as current for the calling thread. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ## void srmDeviceSyncWait (SRMDevice *device) ### Description Ensures that all pending rendering commands are completed before continuing. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (void) N/A #### Response Example N/A ``` -------------------------------- ### SRMConnector Physical Dimensions and Type Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Functions to get the physical dimensions (width, height) and DRM type of the connector. ```APIDOC ## srmConnectorGetmmWidth ### Description Get the physical width of the connector in millimeters. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c UInt32 width = srmConnectorGetmmWidth(connector); ``` ### Response #### Success Response (UInt32) Returns the width in millimeters. #### Response Example ```c printf("Connector width: %u mm\n", width); ``` ## srmConnectorGetmmHeight ### Description Get the physical height of the connector in millimeters. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c UInt32 height = srmConnectorGetmmHeight(connector); ``` ### Response #### Success Response (UInt32) Returns the height in millimeters. #### Response Example ```c printf("Connector height: %u mm\n", height); ``` ## srmConnectorGetType ### Description Get the DRM type of the connector. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c UInt32 type = srmConnectorGetType(connector); ``` ### Response #### Success Response (UInt32) Returns the DRM type of the connector. #### Response Example ```c // Example: Check for a specific type // if (type == DRM_MODE_CONNECTOR_HDMIA) { ... } ``` ``` -------------------------------- ### SRMConnector Initialization and Lifecycle Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Functions for initializing, repainting, uninitializing, suspending, and resuming the connector. ```APIDOC ## srmConnectorInitialize ### Description Initializes a connector, creating its rendering thread and invoking `initializeGL()` once initialized. ### Method (Initialization function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c SRMConnectorInterface interface = { ... }; // Define the interface structure UInt8 success = srmConnectorInitialize(connector, &interface, userData); ``` ### Response #### Success Response (UInt8) Returns 1 on success, 0 on failure. #### Response Example ```c if (srmConnectorInitialize(myConnector, &myInterface, myUserData)) { printf("Connector initialized.\n"); } else { printf("Failed to initialize connector.\n"); } ``` ## srmConnectorRepaint ### Description Schedules a new rendering frame. ### Method (Rendering function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c srmConnectorRepaint(connector); ``` ### Response #### Success Response (UInt8) Returns 1 on success, 0 on failure. #### Response Example ```c if (srmConnectorRepaint(connector)) { printf("Repaint scheduled.\n"); } else { printf("Failed to schedule repaint.\n"); } ``` ## srmConnectorUninitialize ### Description Uninitializes the connector. ### Method (Cleanup function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c srmConnectorUninitialize(connector); ``` ### Response #### Success Response (void) No return value. #### Response Example N/A ## srmConnectorSuspend ### Description Locks the rendering thread until `srmConnectorResume()` is called. ### Method (Control function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c srmConnectorSuspend(connector); ``` ### Response #### Success Response (UInt8) Returns 1 on success, 0 on failure. #### Response Example ```c if (srmConnectorSuspend(connector)) { printf("Connector suspended.\n"); } else { printf("Failed to suspend connector.\n"); } ``` ## srmConnectorResume ### Description Unlocks the rendering thread if previously locked with `srmConnectorSuspend()`. ### Method (Control function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c srmConnectorResume(connector); ``` ### Response #### Success Response (UInt8) Returns 1 on success, 0 on failure. #### Response Example ```c if (srmConnectorResume(connector)) { printf("Connector resumed.\n"); } else { printf("Failed to resume connector.\n"); } ``` ``` -------------------------------- ### SRMDevice Core and Name Access Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Functions to get the SRMCore instance and the DRM device name associated with an SRMDevice. ```APIDOC ## SRMCore * srmDeviceGetCore (SRMDevice *device) ### Description Gets the SRMCore instance to which this device belongs. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (SRMCore *) Returns a pointer to the SRMCore instance. #### Response Example N/A ## const char * srmDeviceGetName (SRMDevice *device) ### Description Gets the DRM device name (e.g., `/dev/dri/card0`) associated with this device. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (const char *) Returns the DRM device name as a C-style string. #### Response Example N/A ``` -------------------------------- ### srmConnectorGetGammaSize() Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Gets the number of elements used to represent each RGB gamma correction curve. This function should be called after the connector is initialized. ```APIDOC ## srmConnectorGetGammaSize() ### Description Gets the number of elements used to represent each RGB gamma correction curve. This function retrieves the number of elements (N) used to represent each RGB gamma correction curve, where N is the count of UInt16 elements for red, green, and blue curves. Note: This method should only be called once the connector is assigned a CRTC, meaning after the connector is initialized. If called when uninitialized, it returns 0. If the connector is initialized and this method returns 0, it indicates that the driver does not support gamma correction. ### Method GET (Conceptual - this is a function call, not a REST API) ### Endpoint N/A (Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c SRMConnector *connector; UInt64 gamma_size = srmConnectorGetGammaSize(connector); ``` ### Response #### Success Response - **UInt64** - The number of elements used to represent each RGB gamma correction curve, or 0 if the connector is uninitialized or if the driver does not support gamma correction. #### Response Example ```json { "gamma_size": 1024 } ``` ``` -------------------------------- ### Initialize SRM Connector with C Source: https://cuarzosoftware.github.io/SRM/tutorial_page The `srmConnectorInitialize` function in C initializes an SRM connector. This involves creating its rendering thread and executing an `initializeGL()` function once the initialization is complete. It takes the connector, an interface structure, and optional user data as parameters. ```c UInt8 srmConnectorInitialize(SRMConnector *connector, SRMConnectorInterface *interface, void *userData) Initializes a connector, creating its rendering thread and invoking initializeGL() once initialized. ``` -------------------------------- ### Get SRM Connector Current Buffer Age Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Retrieves the age of the current buffer for the SRMConnector, as defined by the EGL_EXT_buffer_age extension specification. ```c UInt32 srmConnectorGetCurrentBufferAge(SRMConnector *connector) { // Implementation details... return 0; // Example return value } ``` -------------------------------- ### SRM Connector Interface Definition Source: https://cuarzosoftware.github.io/SRM/tutorial_page Defines the structure for handling OpenGL events by providing function pointers for initialization, painting, resizing, page flipping, and uninitialization. ```c static SRMConnectorInterface connectorInterface = { .initializeGL = &initializeGL, .paintGL = &paintGL, .resizeGL = &resizeGL, .pageFlipped = &pageFlipped, .uninitializeGL = &uninitializeGL }; ``` -------------------------------- ### Connector Plugged Event Listener Source: https://cuarzosoftware.github.io/SRM/tutorial_page Registers a new listener to be invoked when a new connector is plugged. The provided callback function will be executed, allowing for initialization of the new connector. ```APIDOC ## srmCoreAddConnectorPluggedEventListener ### Description Registers a new listener to be invoked when a new connector is plugged (e.g., plugging an HDMI display). ### Method `srmCoreAddConnectorPluggedEventListener` ### Parameters - **core** (`SRMCore *`) - The SRMCore instance. - **callback** (`void(*)(SRMListener *, SRMConnector *)`) - The function to be called when a connector is plugged. - **userData** (`void *`) - Optional user data to pass to the callback. ### Return Value - **SRMListener *** - A pointer to the registered listener. ### Example Usage ```c // Assuming 'core' is an initialized SRMCore instance SRMListener *pluggedListener = srmCoreAddConnectorPluggedEventListener(core, connectorPluggedEventHandler, NULL); ``` ### Associated Event Handler Example ```c static void connectorPluggedEventHandler(SRMListener *listener, SRMConnector *connector) { SRM_UNUSED(listener); /* This is called when a new connector is available (E.g. Plugging an HDMI display). */ /* Got a new connector, let's render on it */ if (!srmConnectorInitialize(connector, &connectorInterface, NULL)) SRMError("[srm-example] Failed to initialize connector %s", srmConnectorGetName(connector)); } ``` ``` -------------------------------- ### Get Connector ID (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Retrieves the unique DRM connector ID associated with the SRMConnector. This ID is a system-level identifier for the connector. ```c UInt32 srmConnectorGetID(SRMConnector * _connector_); ``` -------------------------------- ### SRMConnector Framebuffer and Buffer Information Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Functions to get OpenGL framebuffer ID, EGL context, buffer age, and buffer details. ```APIDOC ## srmConnectorGetFramebufferID ### Description Retrieves the ID of the currently bound OpenGL framebuffer. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c UInt32 fbId = srmConnectorGetFramebufferID(connector); ``` ### Response #### Success Response (UInt32) Returns the OpenGL framebuffer ID. #### Response Example ```c printf("Framebuffer ID: %u\n", fbId); ``` ## srmConnectorGetContext ### Description Retrieves the `EGLContext` associated with the rendering thread. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c EGLContext ctx = srmConnectorGetContext(connector); ``` ### Response #### Success Response (EGLContext) Returns the `EGLContext`. #### Response Example ```c // Example usage: if (ctx) { ... } ``` ## srmConnectorGetCurrentBufferAge ### Description Retrieves the age of the current buffer. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c UInt32 bufferAge = srmConnectorGetCurrentBufferAge(connector); ``` ### Response #### Success Response (UInt32) Returns the age of the current buffer. #### Response Example ```c printf("Current buffer age: %u\n", bufferAge); ``` ## srmConnectorGetCurrentBufferIndex ### Description Returns the current framebuffer index. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c UInt32 bufferIndex = srmConnectorGetCurrentBufferIndex(connector); ``` ### Response #### Success Response (UInt32) Returns the index of the current framebuffer. #### Response Example ```c printf("Current buffer index: %u\n", bufferIndex); ``` ## srmConnectorGetBuffersCount ### Description Returns the number of framebuffers. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c UInt32 bufferCount = srmConnectorGetBuffersCount(connector); ``` ### Response #### Success Response (UInt32) Returns the total number of framebuffers. #### Response Example ```c printf("Total buffers: %u\n", bufferCount); ``` ## srmConnectorGetBuffer ### Description Returns the buffer of a specific framebuffer index, usable as a texture for rendering. ### Method (Getter function) ### Endpoint N/A (Function call) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c UInt32 index = 0; SRMBuffer *buffer = srmConnectorGetBuffer(connector, index); ``` ### Response #### Success Response (SRMBuffer *) Returns a pointer to the SRMBuffer object at the specified index. #### Response Example ```c // Example usage // if (buffer) { ... } ``` ``` -------------------------------- ### SRMDevice EGL and GL Information Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_device Functions to access EGLDisplay, EGLContext, EGL extensions, EGL functions, and OpenGL extensions. ```APIDOC ## EGLDisplay * srmDeviceGetEGLDisplay (SRMDevice *device) ### Description Gets the `EGLDisplay` associated with the device. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (EGLDisplay *) Returns the `EGLDisplay` object. #### Response Example N/A ## EGLContext * srmDeviceGetEGLContext (SRMDevice *device) ### Description Gets the `EGLContext` associated with the device. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (EGLContext *) Returns the `EGLContext` object. #### Response Example N/A ## const SRMEGLDeviceExtensions * srmDeviceGetEGLExtensions (SRMDevice *device) ### Description Returns a structure with boolean variables indicating which EGL extensions the device supports. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (const SRMEGLDeviceExtensions *) Returns a pointer to a structure detailing EGL extension support. #### Response Example N/A ## const SRMEGLDeviceFunctions * srmDeviceGetEGLFunctions (SRMDevice *device) ### Description Returns a structure with pointers to many available EGL functions. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (const SRMEGLDeviceFunctions *) Returns a pointer to a structure containing EGL function pointers. #### Response Example N/A ## const SRMGLDeviceExtensions * srmDeviceGetGLExtensions (SRMDevice *device) ### Description Returns a structure with boolean variables indicating which OpenGL extensions the device supports. ### Method N/A (Function) ### Endpoint N/A (Function) ### Parameters #### Path Parameters N/A #### Query Parameters N/A #### Request Body N/A ### Request Example N/A ### Response #### Success Response (const SRMGLDeviceExtensions *) Returns a pointer to a structure detailing OpenGL extension support. #### Response Example N/A ``` -------------------------------- ### SRMCore Instance Creation and Management Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_core Creates and manages a single SRMCore instance per process. Ensure only one instance is created to avoid undefined behavior. The SRMCore is responsible for DRM device setup, allocator selection, rendering mode configuration, and listening to udev hotplugging events. ```c SRMInterface *interface; void *userData; // Create SRMCore instance SRMCore *core = srmCoreCreate(interface, userData); // ... use SRMCore functions ... // Destroy SRMCore instance when done srmCoreDestroy(core); ``` -------------------------------- ### Get Connector State (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Retrieves the current state of the SRMConnector. The state indicates the operational status of the connector, such as whether it is initialized or uninitialized. ```c SRM_CONNECTOR_STATE srmConnectorGetState(SRMConnector * _connector_); ``` -------------------------------- ### SRMConnectorEnableVSync Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Enable or disable vsync. ```APIDOC ## srmConnectorEnableVSync ### Description Enable or disable vsync. ### Method N/A (C function) ### Endpoint N/A (C function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Example usage: // SRMConnector *connector; // UInt8 enabled = 1; // 1 to enable, 0 to disable // srmConnectorEnableVSync(connector, enabled); ``` ### Response #### Success Response (200) `UInt8` indicating success (typically 0 for success, non-zero for failure). #### Response Example ```json { "return_value": 0 } ``` ``` -------------------------------- ### Get SRM Connector EGL Context Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Retrieves the `EGLContext` associated with the rendering thread of the SRMConnector. It returns the `EGLContext` on success, or `EGL_NO_CONTEXT` if the connector is uninitialized. ```c EGLContext srmConnectorGetContext(SRMConnector *connector) { // Implementation details... return EGL_NO_CONTEXT; // Example return value } ``` -------------------------------- ### C: Get the length of a linked list Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_list Returns the number of items currently present in the linked list. ```c UInt32 srmListGetLength (SRMList *list); ``` -------------------------------- ### SRM OpenGL Uninitialization and Resource Cleanup Source: https://cuarzosoftware.github.io/SRM/tutorial_page Frees OpenGL resources that were created during the initializeGL event just before the connector is uninitialized. No drawing operations should occur here. ```c static void uninitializeGL(SRMConnector *connector, void *userData) { SRM_UNUSED(connector); SRM_UNUSED(userData); /* You must not do any drawing here as it won't make it to * the screen. * Here you should free any resource created on initializeGL() * like shaders, programs, textures, etc. */ } ``` -------------------------------- ### Get Connector User Data (C) Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_connector Retrieves the user data previously associated with an SRMConnector. This function is distinct from initialization data and allows for custom data to be retrieved from a connector. ```c void * srmConnectorGetUserData(SRMConnector * _connector_); ``` -------------------------------- ### C: Create a new empty linked list Source: https://cuarzosoftware.github.io/SRM/group___s_r_m_list Initializes and returns a new, empty linked list. This function is the entry point for using the SRMList data structure. ```c SRMList * srmListCreate (); ```