### Complete Video Player Example (C) Source: https://context7.com/milosladni/libuapi/llms.txt Demonstrates a full camera capture to display pipeline with rotation support using libuapi. It initializes a display port, configures video parameters, allocates memory, and sets up the display pipeline. The example uses a dequeue/queue mechanism for zero-copy rendering and includes a basic rendering loop. ```c #include #include #include #include int main() { // Create and initialize display port dispOutPort *vout = CreateVideoOutport(0); if (!vout) { printf("Failed to create video port\n"); return -1; } // Initialize for 720p display VoutRect rect = {0, 0, 1280, 720}; if (DispInit(vout, 1, ROTATION_ANGLE_0, &rect) != 0) { printf("Display init failed\n"); DestroyVideoOutport(vout); return -1; } // Configure video source parameters videoParam param; memset(¶m, 0, sizeof(videoParam)); param.srcInfo.w = 1280; param.srcInfo.h = 720; param.srcInfo.crop_x = 0; param.srcInfo.crop_y = 0; param.srcInfo.crop_w = 1280; param.srcInfo.crop_h = 720; param.srcInfo.format = VIDEO_PIXEL_FORMAT_NV21; param.srcInfo.color_space = VIDEO_BT709; // Allocate video memory buffers if (DispAllocateVideoMem(vout, ¶m) != 0) { printf("Video memory allocation failed\n"); DispDeinit(vout); DestroyVideoOutport(vout); return -1; } // Set video source route (from camera) DispSetRoute(vout, VIDEO_SRC_FROM_CAM); // Set layer to top DispSetZorder(vout, VIDEO_ZORDER_TOP); // Enable display DispSetEnable(vout, 1); // Main rendering loop using dequeue/queue int frame_size = 1280 * 720 * 3 / 2; renderBuf rbuf; for (int i = 0; i < 300; i++) { // 300 frames // Get buffer from pool if (DispDequeue(vout, &rbuf) != 0) { printf("Dequeue failed\n"); break; } // Fill buffer with frame data // In real usage: read from camera/decoder memset((void*)rbuf.vir_addr, 128, frame_size); // Submit buffer for display if (DispQueueToDisplay(vout, frame_size, ¶m, &rbuf) != 0) { printf("Queue failed\n"); break; } usleep(33333); // ~30fps } // Cleanup DispSetEnable(vout, 0); DispFreeVideoMem(vout); DispDeinit(vout); DestroyVideoOutport(vout); printf("Playback complete\n"); return 0; } ``` -------------------------------- ### DispInit - Initialize Display Layer and Screen (C) Source: https://context7.com/milosladni/libuapi/llms.txt Initializes the display subsystem, opens the /dev/disp device, and configures a display layer. It sets the screen rectangle, rotation, and enables the display. This function returns 0 on success and a negative error code on failure. It also provides functions to get screen dimensions. ```c #include int main() { dispOutPort *vout = CreateVideoOutport(0); VoutRect rect; // Set display region to full screen rect.x = 0; rect.y = 0; rect.width = 1280; rect.height = 720; // Initialize: enable=1, no rotation, full screen int ret = DispInit(vout, 1, ROTATION_ANGLE_0, &rect); if (ret != 0) { printf("Display init failed: %d\n", ret); return -1; } // Get actual screen dimensions int width = DispGetScreenWidth(vout); int height = DispGetScreenHeight(vout); printf("Screen: %dx%d\n", width, height); DispDeinit(vout); DestroyVideoOutport(vout); return 0; } ``` -------------------------------- ### DispInit - Initialize Display Layer Source: https://context7.com/milosladni/libuapi/llms.txt Initializes the display subsystem, opens the `/dev/disp` device, requests a display layer, and configures initial parameters including screen rectangle and rotation. This function must be called after creating a video output port. ```APIDOC ## POST /api/display/init ### Description Initializes the display subsystem, including opening the `/dev/disp` device, requesting a display layer, and configuring initial display parameters such as screen rectangle and rotation. ### Method POST ### Endpoint /api/display/init ### Parameters #### Path Parameters None #### Query Parameters - **vout** (pointer to dispOutPort) - Required - The video output port handle obtained from `CreateVideoOutport`. - **enable** (integer) - Required - Flag to enable or disable the display (1 for enable, 0 for disable). - **rotate** (integer) - Required - The rotation angle for the display (e.g., `ROTATION_ANGLE_0`, `ROTATION_ANGLE_90`). - **rect** (VoutRect) - Required - A structure defining the display rectangle {x, y, width, height}. #### Request Body None ### Request Example None ### Response #### Success Response (200) - **ret** (integer) - 0 on success, a negative value on failure. #### Response Example ```json { "ret": 0 } ``` ``` -------------------------------- ### CreateVideoOutport - Initialize Display Output Port (C) Source: https://context7.com/milosladni/libuapi/llms.txt Creates and initializes a display output port instance, returning a handle to a dispOutPort structure. This function is the primary entry point for interacting with the display subsystem. It requires the display index as input and returns a pointer to the initialized port or NULL on failure. ```c #include int main() { // Create video output port instance (index 0 for primary display) dispOutPort *vout = CreateVideoOutport(0); if (vout == NULL) { printf("Failed to create video output port\n"); return -1; } // Initialize display with default rectangle VoutRect rect = {0, 0, 1920, 1080}; int enable = 1; int rotate = ROTATION_ANGLE_0; vout->init(vout, enable, rotate, &rect); // ... use display ... vout->deinit(vout); DestroyVideoOutport(vout); return 0; } ``` -------------------------------- ### DispSetIoctl - Direct Display IOCTL Control Source: https://context7.com/milosladni/libuapi/llms.txt Provides direct access to display driver IOCTL commands for advanced control like brightness, contrast, and video enhancement. ```APIDOC ## DispSetIoctl - Direct Display IOCTL Control ### Description Provides direct access to display driver IOCTL commands for advanced control like brightness, contrast, and video enhancement. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 1920, 1080}; DispInit(vout, 1, ROTATION_ANGLE_0, &rect); unsigned long brightness = 200; DispSetIoctl(vout, VIDEO_CMD_SET_BRIGHTNESS, brightness); unsigned long enhance_mode = 1; DispSetIoctl(vout, VIDEO_CMD_SET_VEDIO_ENHANCE_DEFAULT, enhance_mode); // Available commands: // VIDEO_CMD_SET_BRIGHTNESS // VIDEO_CMD_SET_CONTRAST // VIDEO_CMD_SET_HUE // VIDEO_CMD_SET_SATURATION // VIDEO_CMD_SET_VEDIO_ENHANCE_DEFAULT DispDeinit(vout); DestroyVideoOutport(vout); ``` ### Response #### Success Response (No specific return value documented, assumed to be 0 on success) #### Response Example (None) ``` -------------------------------- ### Zero-Copy Display Pipeline with DispDequeue/DispQueueToDisplay (C) Source: https://context7.com/milosladni/libuapi/llms.txt Implements a high-performance, zero-copy video playback pipeline using DispDequeue and DispQueueToDisplay. This pattern avoids memory copies by directly accessing and filling display buffers. It requires allocating double buffers and managing the dequeue/queue cycle. ```c #include void render_video_stream(dispOutPort *vout, videoParam *param) { renderBuf rbuf; int frame_size = param->srcInfo.w * param->srcInfo.h * 3 / 2; // Allocate internal double buffers DispAllocateVideoMem(vout, param); while (1) { // Dequeue a free buffer int ret = DispDequeue(vout, &rbuf); if (ret != 0) { printf("Dequeue failed\n"); break; } // Fill buffer with video frame data (direct memory access) // rbuf.vir_addr points to virtual address // rbuf.phy_addr points to physical address unsigned char *buf = (unsigned char *)rbuf.vir_addr; // Read frame from decoder/camera into buffer // read_frame_from_source(buf, frame_size); // Queue buffer for display ret = DispQueueToDisplay(vout, frame_size, param, &rbuf); if (ret != 0) { printf("Queue to display failed\n"); break; } } DispFreeVideoMem(vout); } int main() { dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 1920, 1080}; DispInit(vout, 1, ROTATION_ANGLE_0, &rect); videoParam param = {0}; param.srcInfo.w = 1920; param.srcInfo.h = 1080; param.srcInfo.crop_w = 1920; param.srcInfo.crop_h = 1080; param.srcInfo.format = VIDEO_PIXEL_FORMAT_NV21; param.srcInfo.color_space = VIDEO_BT709; DispSetRoute(vout, VIDEO_SRC_FROM_VE); render_video_stream(vout, ¶m); DispDeinit(vout); DestroyVideoOutport(vout); return 0; } ``` -------------------------------- ### Direct Display IOCTL Control (C) Source: https://context7.com/milosladni/libuapi/llms.txt Provides direct access to display driver IOCTL commands for advanced control. Requires videoOutPort.h. Used for adjusting parameters like brightness, contrast, and video enhancement. ```c #include int main() { dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 1920, 1080}; DispInit(vout, 1, ROTATION_ANGLE_0, &rect); // Set LCD brightness (value typically 0-255) unsigned long brightness = 200; DispSetIoctl(vout, VIDEO_CMD_SET_BRIGHTNESS, brightness); // Set video enhancement mode to default unsigned long enhance_mode = 1; DispSetIoctl(vout, VIDEO_CMD_SET_VEDIO_ENHANCE_DEFAULT, enhance_mode); // Available commands: // VIDEO_CMD_SET_BRIGHTNESS // VIDEO_CMD_SET_CONTRAST // VIDEO_CMD_SET_HUE // VIDEO_CMD_SET_SATURATION // VIDEO_CMD_SET_VEDIO_ENHANCE_DEFAULT DispDeinit(vout); DestroyVideoOutport(vout); return 0; } ``` -------------------------------- ### CreateVideoOutport - Create Display Output Port Instance Source: https://context7.com/milosladni/libuapi/llms.txt Creates and initializes a new video output port handle, serving as the entry point for display subsystem operations. It returns a pointer to a `dispOutPort` structure containing function pointers for all display operations. ```APIDOC ## POST /api/videoOutPort/create ### Description Creates and initializes a new video output port instance. This function is the primary entry point for interacting with the display subsystem. ### Method POST ### Endpoint /api/videoOutPort/create ### Parameters #### Path Parameters None #### Query Parameters - **index** (integer) - Required - The index of the video output port to create (e.g., 0 for the primary display). #### Request Body None ### Request Example None ### Response #### Success Response (200) - **vout** (pointer to dispOutPort) - A pointer to the initialized `dispOutPort` structure containing function pointers for display operations. #### Response Example ```json { "vout": "" } ``` ``` -------------------------------- ### Configure Display and Source Rectangles using DispSetRect/DispSetSrcRect (C) Source: https://context7.com/milosladni/libuapi/llms.txt Configures the destination rectangle on the display and the source crop rectangle from the input frame using DispSetRect and DispSetSrcRect. This allows for precise control over the visible area and the portion of the source frame to be displayed, useful for picture-in-picture or cropping. ```c #include int main() { dispOutPort *vout = CreateVideoOutport(0); VoutRect init_rect = {0, 0, 1920, 1080}; DispInit(vout, 1, ROTATION_ANGLE_0, &init_rect); // Set display window (Picture-in-Picture example) VoutRect pip_rect; pip_rect.x = 1280; // Position at right side pip_rect.y = 0; pip_rect.width = 640; // Quarter screen width pip_rect.height = 360; // Quarter screen height int ret = DispSetRect(vout, &pip_rect); if (ret != 0) { printf("SetRect failed\n"); } // Set source crop (crop center 720p from 1080p source) VoutRect src_crop; src_crop.x = 600; // Start x src_crop.y = 180; // Start y src_crop.width = 1280; // Crop width src_crop.height = 720; // Crop height ret = DispSetSrcRect(vout, &src_crop); DispDeinit(vout); DestroyVideoOutport(vout); return 0; } ``` -------------------------------- ### DispDequeue / DispQueueToDisplay - Zero-Copy Display Pipeline Source: https://context7.com/milosladni/libuapi/llms.txt Enables high-performance video playback using a dequeue/queue pattern to avoid memory copies. Dequeue obtains a buffer, which is then filled with data and queued for display. ```APIDOC ## DispDequeue / DispQueueToDisplay - Zero-Copy Display Pipeline ### Description For high-performance video playback, use the dequeue/queue pattern to avoid memory copies. Dequeue gets a buffer, fill it with data, then queue it for display. ### Method (Not explicitly defined, likely function calls within C code) ### Endpoint (Not applicable, this is C code) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (Parameters are passed to functions like DispDequeue and DispQueueToDisplay) - **vout** (dispOutPort *) - Pointer to the display output port. - **rbuf** (renderBuf *) - Structure to hold buffer information (virtual and physical addresses). - **param** (videoParam *) - Pointer to video parameters. - **frame_size** (int) - The size of the frame data in bytes. ### Request Example ```c // Example usage within C code void render_video_stream(dispOutPort *vout, videoParam *param) { renderBuf rbuf; int frame_size = param->srcInfo.w * param->srcInfo.h * 3 / 2; DispAllocateVideoMem(vout, param); while (1) { int ret = DispDequeue(vout, &rbuf); if (ret != 0) { printf("Dequeue failed\n"); break; } unsigned char *buf = (unsigned char *)rbuf.vir_addr; // Read frame from decoder/camera into buffer // read_frame_from_source(buf, frame_size); ret = DispQueueToDisplay(vout, frame_size, param, &rbuf); if (ret != 0) { printf("Queue to display failed\n"); break; } } DispFreeVideoMem(vout); } // ... in main function ... dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 1920, 1080}; DispInit(vout, 1, ROTATION_ANGLE_0, &rect); videoParam param = {0}; param.srcInfo.w = 1920; param.srcInfo.h = 1080; param.srcInfo.format = VIDEO_PIXEL_FORMAT_NV21; DispSetRoute(vout, VIDEO_SRC_FROM_VE); render_video_stream(vout, ¶m); DispDeinit(vout); DestroyVideoOutport(vout); ``` ### Response #### Success Response - **ret** (int) - 0 indicates success for DispDequeue and DispQueueToDisplay. #### Response Example (No explicit response body, return values of DispDequeue and DispQueueToDisplay indicate success or failure) ``` -------------------------------- ### DispSetRect / DispSetSrcRect - Configure Display and Source Rectangles Source: https://context7.com/milosladni/libuapi/llms.txt Sets the destination rectangle on the screen and the source crop rectangle from the input frame. Allows for defining specific areas for display and cropping. ```APIDOC ## DispSetRect / DispSetSrcRect - Configure Display and Source Rectangles ### Description Sets the destination rectangle on screen and source crop rectangle from the input frame. ### Method (Not explicitly defined, likely function calls within C code) ### Endpoint (Not applicable, this is C code) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (Parameters are passed as structures to the functions) - **vout** (dispOutPort *) - Pointer to the display output port. - **pip_rect** (VoutRect *) - Structure defining the destination rectangle on the screen. - **src_crop** (VoutRect *) - Structure defining the source crop rectangle from the input frame. ### Request Example ```c // Example usage within C code dispOutPort *vout = CreateVideoOutport(0); VoutRect init_rect = {0, 0, 1920, 1080}; DispInit(vout, 1, ROTATION_ANGLE_0, &init_rect); // Set display window (Picture-in-Picture example) VoutRect pip_rect; pip_rect.x = 1280; pip_rect.y = 0; pip_rect.width = 640; pip_rect.height = 360; int ret = DispSetRect(vout, &pip_rect); if (ret != 0) { printf("SetRect failed\n"); } // Set source crop (crop center 720p from 1080p source) VoutRect src_crop; src_crop.x = 600; src_crop.y = 180; src_crop.width = 1280; src_crop.height = 720; ret = DispSetSrcRect(vout, &src_crop); DispDeinit(vout); DestroyVideoOutport(vout); ``` ### Response #### Success Response - **ret** (int) - 0 indicates success for DispSetRect and DispSetSrcRect. #### Error Response - **ret** (int) - Non-zero indicates an error. The specific error code may vary. #### Response Example (No explicit response body, return values of DispSetRect and DispSetSrcRect indicate success or failure) ``` -------------------------------- ### Set Display Layer Z-Order (C) Source: https://context7.com/milosladni/libuapi/llms.txt Controls the stacking order of display layers for multi-layer compositing. Requires videoOutPort.h. Sets layers to top, middle, or bottom positions relative to each other. ```c #include int main() { // Create multiple video output ports for multi-layer display dispOutPort *video_layer = CreateVideoOutport(0); dispOutPort *ui_layer = CreateVideoOutport(1); VoutRect full_rect = {0, 0, 1920, 1080}; VoutRect pip_rect = {100, 100, 640, 360}; DispInit(video_layer, 1, ROTATION_ANGLE_0, &full_rect); DispInit(ui_layer, 1, ROTATION_ANGLE_0, &pip_rect); // Set video at bottom, UI overlay on top DispSetZorder(video_layer, VIDEO_ZORDER_BOTTOM); DispSetZorder(ui_layer, VIDEO_ZORDER_TOP); // Z-order options: // VIDEO_ZORDER_TOP - Topmost layer (visible over others) // VIDEO_ZORDER_MIDDLE - Middle layer // VIDEO_ZORDER_BOTTOM - Bottom layer (behind others) DispDeinit(ui_layer); DispDeinit(video_layer); DestroyVideoOutport(ui_layer); DestroyVideoOutport(video_layer); return 0; } ``` -------------------------------- ### Software YUV Frame Rotation (C) Source: https://context7.com/milosladni/libuapi/llms.txt Provides software-based rotation for NV12/NV21 YUV frames when hardware rotation is unavailable. It requires the 'yuv_rotate.h' header and standard C library functions like malloc and free. The function takes frame dimensions and source/destination buffers as input, performing 90 or 270-degree clockwise rotations. ```c #include "yuv_rotate.h" #include int main() { unsigned int width = 1920; unsigned int height = 1080; // Allocate source and destination buffers // NV12/NV21 size = width * height * 1.5 int frame_size = width * height * 3 / 2; unsigned char *src = malloc(frame_size); unsigned char *dst = malloc(frame_size); // Fill source with video data // ... read_frame(src, frame_size); // Rotate 90 degrees clockwise // Note: Output dimensions are swapped (height x width) nv_rotage90(width, height, src, dst); // Or rotate 270 degrees clockwise (90 counter-clockwise) nv_rotage270(width, height, src, dst); free(src); free(dst); return 0; } ``` -------------------------------- ### DispAllocateVideoMem / DispFreeVideoMem - Video Memory Management Source: https://context7.com/milosladni/libuapi/llms.txt Manages ION-backed video memory buffers required for frame rendering. `DispAllocateVideoMem` allocates memory, and `DispFreeVideoMem` releases it. The library typically uses double buffering internally for smooth playback. ```APIDOC ## POST /api/videoMem/allocate ### Description Allocates ION-backed video memory buffers for frame rendering. This function is crucial for preparing memory to hold video frames. It typically allocates a double buffer internally. ### Method POST ### Endpoint /api/videoMem/allocate ### Parameters #### Path Parameters None #### Query Parameters - **vout** (pointer to dispOutPort) - Required - The video output port handle. - **param** (videoParam) - Required - A structure containing video parameters, including source information (width, height, format, color space) and cropping details. #### Request Body None ### Request Example None ### Response #### Success Response (200) - **ret** (integer) - 0 on success, a negative value on failure. #### Response Example ```json { "ret": 0 } ``` ## DELETE /api/videoMem/free ### Description Frees the previously allocated ION-backed video memory buffers. ### Method DELETE ### Endpoint /api/videoMem/free ### Parameters #### Path Parameters None #### Query Parameters - **vout** (pointer to dispOutPort) - Required - The video output port handle. #### Request Body None ### Request Example None ### Response #### Success Response (200) - **ret** (integer) - 0 on success, a negative value on failure. #### Response Example ```json { "ret": 0 } ``` ``` -------------------------------- ### DispAllocateVideoMem / DispFreeVideoMem - Manage Video Memory (C) Source: https://context7.com/milosladni/libuapi/llms.txt Allocates and frees ION-backed video memory buffers required for frame rendering. This function configures video parameters such as source resolution, cropping, and pixel format. It supports double buffering for smooth playback and returns 0 on success. ```c #include int main() { dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 1920, 1080}; DispInit(vout, 1, ROTATION_ANGLE_0, &rect); // Configure video parameters videoParam param; memset(¶m, 0, sizeof(videoParam)); param.srcInfo.w = 1920; param.srcInfo.h = 1080; param.srcInfo.crop_x = 0; param.srcInfo.crop_y = 0; param.srcInfo.crop_w = 1920; param.srcInfo.crop_h = 1080; param.srcInfo.format = VIDEO_PIXEL_FORMAT_NV21; param.srcInfo.color_space = VIDEO_BT709; // Allocate double buffer for 1080p NV21 video int ret = DispAllocateVideoMem(vout, ¶m); if (ret != 0) { printf("Video memory allocation failed\n"); return -1; } // ... render frames ... // Free video memory DispFreeVideoMem(vout); DispDeinit(vout); DestroyVideoOutport(vout); return 0; } ``` -------------------------------- ### Enable/Disable Display Layer (C) Source: https://context7.com/milosladni/libuapi/llms.txt Manages the visibility of a display layer without deallocating its resources. Requires videoOutPort.h. Can be used to temporarily hide or show content. ```c #include int main() { dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 1920, 1080}; DispInit(vout, 0, ROTATION_ANGLE_0, &rect); // Start disabled // Enable display when ready to show content DispSetEnable(vout, 1); // ... display video ... // Temporarily hide layer (keeps buffers allocated) DispSetEnable(vout, 0); // Show again DispSetEnable(vout, 1); DispDeinit(vout); DestroyVideoOutport(vout); return 0; } ``` -------------------------------- ### ION Memory Allocator Interface (C) Source: https://context7.com/milosladni/libuapi/llms.txt Low-level memory operations for allocating physically contiguous memory via the ION allocator. Requires ion_mem_alloc.h. Essential for DMA operations with the display engine, providing virtual and physical addresses, and file descriptors. ```c #include int main() { // Get memory adapter operations struct SunxiMemOpsS *memops = GetMemAdapterOpsS(); // Open ION allocator int ret = SunxiMemOpen(memops); if (ret != 0) { printf("Failed to open ION allocator\n"); return -1; } // Allocate 1MB physically contiguous buffer int size = 1024 * 1024; void *vir_addr = SunxiMemPalloc(memops, size); if (vir_addr == NULL) { printf("Memory allocation failed\n"); SunxiMemClose(memops); return -1; } // Get physical address for DMA void *phy_addr = SunxiMemGetPhysicAddressCpu(memops, vir_addr); printf("Virtual: %p, Physical: %p\n", vir_addr, phy_addr); // Get DMA-buf file descriptor for sharing int buf_fd = SunxiMemGetBufferFd(memops, vir_addr); printf("Buffer FD: %d\n", buf_fd); // Flush cache before DMA operation SunxiMemFlushCache(memops, vir_addr, size); // Free memory SunxiMemPfree(memops, vir_addr); SunxiMemClose(memops); return 0; } ``` -------------------------------- ### DispSetZorder - Set Layer Z-Order Source: https://context7.com/milosladni/libuapi/llms.txt Controls the stacking order of display layers for multi-layer compositing scenarios. ```APIDOC ## DispSetZorder - Set Layer Z-Order ### Description Controls the stacking order of display layers for multi-layer compositing scenarios. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include dispOutPort *video_layer = CreateVideoOutport(0); dispOutPort *ui_layer = CreateVideoOutport(1); VoutRect full_rect = {0, 0, 1920, 1080}; VoutRect pip_rect = {100, 100, 640, 360}; DispInit(video_layer, 1, ROTATION_ANGLE_0, &full_rect); DispInit(ui_layer, 1, ROTATION_ANGLE_0, &pip_rect); DispSetZorder(video_layer, VIDEO_ZORDER_BOTTOM); DispSetZorder(ui_layer, VIDEO_ZORDER_TOP); // Z-order options: // VIDEO_ZORDER_TOP - Topmost layer (visible over others) // VIDEO_ZORDER_MIDDLE - Middle layer // VIDEO_ZORDER_BOTTOM - Bottom layer (behind others) DispDeinit(ui_layer); DispDeinit(video_layer); DestroyVideoOutport(ui_layer); DestroyVideoOutport(video_layer); ``` ### Response #### Success Response (No specific return value documented, assumed to be 0 on success) #### Response Example (None) ``` -------------------------------- ### DispSetEnable - Enable/Disable Display Layer Source: https://context7.com/milosladni/libuapi/llms.txt Enables or disables the display layer visibility without releasing resources. ```APIDOC ## DispSetEnable - Enable/Disable Display Layer ### Description Enables or disables the display layer visibility without releasing resources. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 1920, 1080}; DispInit(vout, 0, ROTATION_ANGLE_0, &rect); // Start disabled DispSetEnable(vout, 1); // ... display video ... DispSetEnable(vout, 0); DispSetEnable(vout, 1); DispDeinit(vout); DestroyVideoOutport(vout); ``` ### Response #### Success Response (No specific return value documented, assumed to be 0 on success) #### Response Example (None) ``` -------------------------------- ### SunxiMemOpsS - ION Memory Allocator Interface Source: https://context7.com/milosladni/libuapi/llms.txt Low-level memory operations for allocating physically contiguous memory via the ION allocator, required for DMA operations with the display engine. ```APIDOC ## SunxiMemOpsS - ION Memory Allocator Interface ### Description Low-level memory operations for allocating physically contiguous memory via the ION allocator, required for DMA operations with the display engine. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include struct SunxiMemOpsS *memops = GetMemAdapterOpsS(); int ret = SunxiMemOpen(memops); if (ret != 0) { printf("Failed to open ION allocator\n"); return -1; } int size = 1024 * 1024; void *vir_addr = SunxiMemPalloc(memops, size); if (vir_addr == NULL) { printf("Memory allocation failed\n"); SunxiMemClose(memops); return -1; } void *phy_addr = SunxiMemGetPhysicAddressCpu(memops, vir_addr); printf("Virtual: %p, Physical: %p\n", vir_addr, phy_addr); int buf_fd = SunxiMemGetBufferFd(memops, vir_addr); printf("Buffer FD: %d\n", buf_fd); SunxiMemFlushCache(memops, vir_addr, size); SunxiMemPfree(memops, vir_addr); SunxiMemClose(memops); ``` ### Response #### Success Response (No specific return value documented, assumed to be 0 on success for operations like Open, Close, Palloc, Pfree) #### Response Example (None) ``` -------------------------------- ### Set Display Rotation Angle (C) Source: https://context7.com/milosladni/libuapi/llms.txt Configures the rotation angle for video output. Supports 0, 90, 180, and 270 degrees. Requires the videoOutPort.h header. Initializes or dynamically changes rotation for a display output port. ```c #include int main() { dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 1080, 1920}; // Portrait mode dimensions // Initialize with 90 degree rotation for portrait display DispInit(vout, 1, ROTATION_ANGLE_90, &rect); // Or change rotation dynamically DispSetRotateAngel(vout, ROTATION_ANGLE_270); // Rotation options: // ROTATION_ANGLE_0 - No rotation // ROTATION_ANGLE_90 - 90 degrees clockwise // ROTATION_ANGLE_180 - 180 degrees // ROTATION_ANGLE_270 - 270 degrees clockwise DispDeinit(vout); DestroyVideoOutport(vout); return 0; } ``` -------------------------------- ### Write Frame Data to Display using DispWriteData (C) Source: https://context7.com/milosladni/libuapi/llms.txt Writes raw video frame data directly to the display layer using the DispWriteData function. It handles internal format conversion and optional rotation. This function requires initialization of the display output port and allocation of video memory. ```c #include #include int main() { dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 640, 480}; DispInit(vout, 1, ROTATION_ANGLE_0, &rect); videoParam param; memset(¶m, 0, sizeof(videoParam)); param.srcInfo.w = 640; param.srcInfo.h = 480; param.srcInfo.crop_x = 0; param.srcInfo.crop_y = 0; param.srcInfo.crop_w = 640; param.srcInfo.crop_h = 480; param.srcInfo.format = VIDEO_PIXEL_FORMAT_NV12; param.srcInfo.color_space = VIDEO_BT601; // Allocate internal buffers DispAllocateVideoMem(vout, ¶m); // Set video source route DispSetRoute(vout, VIDEO_SRC_FROM_CAM); // Frame size for NV12: width * height * 1.5 int frame_size = 640 * 480 * 3 / 2; unsigned char *frame_data = malloc(frame_size); // Write frame to display (copies data to internal buffer and renders) int ret = DispWriteData(vout, frame_data, frame_size, ¶m); if (ret != 0) { printf("Write data failed: %d\n", ret); } free(frame_data); DispFreeVideoMem(vout); DispDeinit(vout); DestroyVideoOutport(vout); return 0; } ``` -------------------------------- ### DispSetRotateAngel - Set Display Rotation Source: https://context7.com/milosladni/libuapi/llms.txt Configures the rotation angle for the video output. Supports 0°, 90°, 180°, and 270° rotation. ```APIDOC ## DispSetRotateAngel - Set Display Rotation ### Description Configures rotation for the video output. Supports 0°, 90°, 180°, and 270° rotation. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, this is a library function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Request Example ```c #include dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 1080, 1920}; // Portrait mode dimensions DispInit(vout, 1, ROTATION_ANGLE_90, &rect); DispSetRotateAngel(vout, ROTATION_ANGLE_270); // Rotation options: // ROTATION_ANGLE_0 - No rotation // ROTATION_ANGLE_90 - 90 degrees clockwise // ROTATION_ANGLE_180 - 180 degrees // ROTATION_ANGLE_270 - 270 degrees clockwise DispDeinit(vout); DestroyVideoOutport(vout); ``` ### Response #### Success Response (No specific return value documented, assumed to be 0 on success) #### Response Example (None) ``` -------------------------------- ### DispWriteData - Write Frame Data to Display Source: https://context7.com/milosladni/libuapi/llms.txt Writes raw video frame data directly to the display layer. This function handles format conversion and optional rotation internally. ```APIDOC ## DispWriteData - Write Frame Data to Display ### Description Writes raw video frame data directly to the display layer. Handles format conversion and optional rotation internally. ### Method (Not explicitly defined, likely a function call within C code) ### Endpoint (Not applicable, this is a C function) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body - **vout** (dispOutPort *) - Pointer to the display output port. - **frame_data** (unsigned char *) - Pointer to the raw video frame data. - **frame_size** (int) - The size of the frame data in bytes. - **param** (videoParam *) - Pointer to video parameters including source information and format. ### Request Example ```c // Example usage within C code dispOutPort *vout = CreateVideoOutport(0); VoutRect rect = {0, 0, 640, 480}; DispInit(vout, 1, ROTATION_ANGLE_0, &rect); videoParam param; memset(¶m, 0, sizeof(videoParam)); param.srcInfo.w = 640; param.srcInfo.h = 480; param.srcInfo.format = VIDEO_PIXEL_FORMAT_NV12; DispAllocateVideoMem(vout, ¶m); DispSetRoute(vout, VIDEO_SRC_FROM_CAM); int frame_size = 640 * 480 * 3 / 2; unsigned char *frame_data = malloc(frame_size); // Assume frame_data is populated with video content int ret = DispWriteData(vout, frame_data, frame_size, ¶m); if (ret != 0) { printf("Write data failed: %d\n", ret); } free(frame_data); DispFreeVideoMem(vout); DispDeinit(vout); DestroyVideoOutport(vout); ``` ### Response #### Success Response (0) - **ret** (int) - 0 indicates success. #### Error Response - **ret** (int) - Non-zero indicates an error. The specific error code may vary. #### Response Example (No explicit response body, return value indicates success or failure) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.