1 // Copyright 2018 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 #include <zircon/pixelformat.h> 12 #include <zircon/types.h> 13 14 #define FB_INVALID_ID 0 15 16 // Binds to the display. |single_buffer| determines whether the connection 17 // is initialized in single buffer or page flip mode. 18 zx_status_t fb_bind(bool single_buffer, const char** err_msg); 19 20 void fb_release(void); 21 22 // Gets the framebuffer configuration. In single buffer mode, this is the 23 // configuration of the allocated buffer. In page flip mode, imported images 24 // must have this configuration. 25 void fb_get_config(uint32_t* width_out, uint32_t* height_out, 26 uint32_t* linear_stride_px_out, zx_pixel_format_t* format_out); 27 28 // single buffer mode functions 29 30 // Returns a VMO handle to the buffer being displayed. The client does not 31 // own the returned handle. 32 zx_handle_t fb_get_single_buffer(void); 33 34 // page flip mode functions 35 36 zx_status_t fb_alloc_image_buffer(zx_handle_t* vmo_out); 37 38 // Imports a VMO handle as an image. This function always consumes |handle|. On 39 // success, the returned handle is guaranteed to not equal FB_INVALID_ID. 40 // 41 // If |type| is 0, the imported image has a linear memory layout. For any other 42 // values, it is the responsibility of the image producer and display driver to 43 // coordinate the meaning of |type|. All imported images must have the same type. 44 zx_status_t fb_import_image(zx_handle_t handle, uint32_t type, uint64_t *id_out); 45 void fb_release_image(uint64_t id); 46 47 // Imports an event handle to use for image synchronization. This function 48 // always consumes |handle|. Id must be unique and not equal to FB_INVALID_ID. 49 zx_status_t fb_import_event(zx_handle_t handle, uint64_t id); 50 void fb_release_event(uint64_t id); 51 52 // TODO(stevensd): Migrate clients to fb_present_image2 and delete this 53 zx_status_t fb_present_image(uint64_t image_id, uint64_t wait_event_id, 54 uint64_t present_event_id, uint64_t signal_event_id); 55 56 // Presents the image identified by |image_id|. 57 // 58 // If |wait_event_id| corresponds to an imported event, then driver will wait for 59 // for ZX_EVENT_SIGNALED before using the buffer. If |signal_event_id| corresponds 60 // to an imported event, then the driver will signal ZX_EVENT_SIGNALED when it is 61 // done with the image. 62 zx_status_t fb_present_image2(uint64_t image_id, 63 uint64_t wait_event_id, uint64_t signal_event_id); 64 65 // vsync functions 66 67 // Enable vsync for page flip mode. 68 zx_status_t fb_enable_vsync(bool enable); 69 70 // Wait for vsync event. VSync time is returned in |timestamp| and scanned out 71 // image in |image_id|. 72 zx_status_t fb_wait_for_vsync(zx_time_t* timestamp, uint64_t* image_id); 73 74 #ifdef __cplusplus 75 } // extern "C" 76 #endif 77