| 1 | /* |
| 2 | Copyright (c) 2012, Broadcom Europe Ltd |
| 3 | All rights reserved. |
| 4 | |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions are met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above copyright |
| 10 | notice, this list of conditions and the following disclaimer in the |
| 11 | documentation and/or other materials provided with the distribution. |
| 12 | * Neither the name of the copyright holder nor the |
| 13 | names of its contributors may be used to endorse or promote products |
| 14 | derived from this software without specific prior written permission. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
| 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | // Display manager service API |
| 29 | |
| 30 | #ifndef _VC_DISPMANX_H_ |
| 31 | #define _VC_DISPMANX_H_ |
| 32 | |
| 33 | #include "interface/vcos/vcos.h" |
| 34 | #include "interface/vctypes/vc_image_types.h" |
| 35 | #include "vc_dispservice_x_defs.h" |
| 36 | #include "interface/vmcs_host/vc_dispmanx_types.h" |
| 37 | #include "interface/vchi/vchi.h" |
| 38 | |
| 39 | #ifdef __cplusplus |
| 40 | extern "C" { |
| 41 | #endif |
| 42 | // Same function as above, to aid migration of code. |
| 43 | VCHPRE_ int VCHPOST_ vc_dispman_init( void ); |
| 44 | // Stop the service from being used |
| 45 | VCHPRE_ void VCHPOST_ vc_dispmanx_stop( void ); |
| 46 | // Set the entries in the rect structure |
| 47 | VCHPRE_ int VCHPOST_ vc_dispmanx_rect_set( VC_RECT_T *rect, uint32_t x_offset, uint32_t y_offset, uint32_t width, uint32_t height ); |
| 48 | // Resources |
| 49 | // Create a new resource |
| 50 | VCHPRE_ DISPMANX_RESOURCE_HANDLE_T VCHPOST_ vc_dispmanx_resource_create( VC_IMAGE_TYPE_T type, uint32_t width, uint32_t height, uint32_t *native_image_handle ); |
| 51 | // Write the bitmap data to VideoCore memory |
| 52 | VCHPRE_ int VCHPOST_ vc_dispmanx_resource_write_data( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, void * src_address, const VC_RECT_T * rect ); |
| 53 | VCHPRE_ int VCHPOST_ vc_dispmanx_resource_write_data_handle( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, VCHI_MEM_HANDLE_T handle, uint32_t offset, const VC_RECT_T * rect ); |
| 54 | VCHPRE_ int VCHPOST_ vc_dispmanx_resource_read_data( |
| 55 | DISPMANX_RESOURCE_HANDLE_T handle, |
| 56 | const VC_RECT_T* p_rect, |
| 57 | void * dst_address, |
| 58 | uint32_t dst_pitch ); |
| 59 | // Delete a resource |
| 60 | VCHPRE_ int VCHPOST_ vc_dispmanx_resource_delete( DISPMANX_RESOURCE_HANDLE_T res ); |
| 61 | |
| 62 | // Displays |
| 63 | // Opens a display on the given device |
| 64 | VCHPRE_ DISPMANX_DISPLAY_HANDLE_T VCHPOST_ vc_dispmanx_display_open( uint32_t device ); |
| 65 | // Opens a display on the given device in the request mode |
| 66 | VCHPRE_ DISPMANX_DISPLAY_HANDLE_T VCHPOST_ vc_dispmanx_display_open_mode( uint32_t device, uint32_t mode ); |
| 67 | // Open an offscreen display |
| 68 | VCHPRE_ DISPMANX_DISPLAY_HANDLE_T VCHPOST_ vc_dispmanx_display_open_offscreen( DISPMANX_RESOURCE_HANDLE_T dest, DISPMANX_TRANSFORM_T orientation ); |
| 69 | // Change the mode of a display |
| 70 | VCHPRE_ int VCHPOST_ vc_dispmanx_display_reconfigure( DISPMANX_DISPLAY_HANDLE_T display, uint32_t mode ); |
| 71 | // Sets the desstination of the display to be the given resource |
| 72 | VCHPRE_ int VCHPOST_ vc_dispmanx_display_set_destination( DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_RESOURCE_HANDLE_T dest ); |
| 73 | // Set the background colour of the display |
| 74 | VCHPRE_ int VCHPOST_ vc_dispmanx_display_set_background( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display, |
| 75 | uint8_t red, uint8_t green, uint8_t blue ); |
| 76 | // get the width, height, frame rate and aspect ratio of the display |
| 77 | VCHPRE_ int VCHPOST_ vc_dispmanx_display_get_info( DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_MODEINFO_T * pinfo ); |
| 78 | // Closes a display |
| 79 | VCHPRE_ int VCHPOST_ vc_dispmanx_display_close( DISPMANX_DISPLAY_HANDLE_T display ); |
| 80 | |
| 81 | // Updates |
| 82 | // Start a new update, DISPMANX_NO_HANDLE on error |
| 83 | VCHPRE_ DISPMANX_UPDATE_HANDLE_T VCHPOST_ vc_dispmanx_update_start( int32_t priority ); |
| 84 | // Add an elment to a display as part of an update |
| 85 | VCHPRE_ DISPMANX_ELEMENT_HANDLE_T VCHPOST_ vc_dispmanx_element_add ( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display, |
| 86 | int32_t layer, const VC_RECT_T *dest_rect, DISPMANX_RESOURCE_HANDLE_T src, |
| 87 | const VC_RECT_T *src_rect, DISPMANX_PROTECTION_T protection, |
| 88 | VC_DISPMANX_ALPHA_T *alpha, |
| 89 | DISPMANX_CLAMP_T *clamp, DISPMANX_TRANSFORM_T transform ); |
| 90 | // Change the source image of a display element |
| 91 | VCHPRE_ int VCHPOST_ vc_dispmanx_element_change_source( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element, |
| 92 | DISPMANX_RESOURCE_HANDLE_T src ); |
| 93 | // Change the layer number of a display element |
| 94 | VCHPRE_ int VCHPOST_ vc_dispmanx_element_change_layer ( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element, |
| 95 | int32_t layer ); |
| 96 | // Signal that a region of the bitmap has been modified |
| 97 | VCHPRE_ int VCHPOST_ vc_dispmanx_element_modified( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element, const VC_RECT_T * rect ); |
| 98 | // Remove a display element from its display |
| 99 | VCHPRE_ int VCHPOST_ vc_dispmanx_element_remove( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element ); |
| 100 | // Ends an update |
| 101 | VCHPRE_ int VCHPOST_ vc_dispmanx_update_submit( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_CALLBACK_FUNC_T cb_func, void *cb_arg ); |
| 102 | // End an update and wait for it to complete |
| 103 | VCHPRE_ int VCHPOST_ vc_dispmanx_update_submit_sync( DISPMANX_UPDATE_HANDLE_T update ); |
| 104 | // Query the image formats supported in the VMCS build |
| 105 | VCHPRE_ int VCHPOST_ vc_dispmanx_query_image_formats( uint32_t *supported_formats ); |
| 106 | |
| 107 | //New function added to VCHI to change attributes, set_opacity does not work there. |
| 108 | VCHPRE_ int VCHPOST_ vc_dispmanx_element_change_attributes( DISPMANX_UPDATE_HANDLE_T update, |
| 109 | DISPMANX_ELEMENT_HANDLE_T element, |
| 110 | uint32_t change_flags, |
| 111 | int32_t layer, |
| 112 | uint8_t opacity, |
| 113 | const VC_RECT_T *dest_rect, |
| 114 | const VC_RECT_T *src_rect, |
| 115 | DISPMANX_RESOURCE_HANDLE_T mask, |
| 116 | DISPMANX_TRANSFORM_T transform ); |
| 117 | |
| 118 | //xxx hack to get the image pointer from a resource handle, will be obsolete real soon |
| 119 | VCHPRE_ uint32_t VCHPOST_ vc_dispmanx_resource_get_image_handle( DISPMANX_RESOURCE_HANDLE_T res); |
| 120 | |
| 121 | //Call this instead of vc_dispman_init |
| 122 | VCHPRE_ void VCHPOST_ vc_vchi_dispmanx_init (VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections ); |
| 123 | |
| 124 | // Take a snapshot of a display in its current state. |
| 125 | // This call may block for a time; when it completes, the snapshot is ready. |
| 126 | // only transform=0 is supported |
| 127 | VCHPRE_ int VCHPOST_ vc_dispmanx_snapshot( DISPMANX_DISPLAY_HANDLE_T display, |
| 128 | DISPMANX_RESOURCE_HANDLE_T snapshot_resource, |
| 129 | DISPMANX_TRANSFORM_T transform ); |
| 130 | |
| 131 | // Set the resource palette (for VC_IMAGE_4BPP and VC_IMAGE_8BPP) |
| 132 | VCHPRE_ int VCHPOST_ vc_dispmanx_resource_set_palette( DISPMANX_RESOURCE_HANDLE_T handle, |
| 133 | void * src_address, int offset, int size); |
| 134 | |
| 135 | // Start triggering callbacks synced to vsync |
| 136 | VCHPRE_ int VCHPOST_ vc_dispmanx_vsync_callback( DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_CALLBACK_FUNC_T cb_func, void *cb_arg ); |
| 137 | |
| 138 | #ifdef __cplusplus |
| 139 | } |
| 140 | #endif |
| 141 | |
| 142 | #endif // _VC_DISPMANX_H_ |
| 143 | |