Rajavenu Kyatham | 9069910 | 2019-07-01 16:19:30 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without modification, are permitted |
| 5 | * provided that the following conditions are met: |
| 6 | * * Redistributions of source code must retain the above copyright notice, this list of |
| 7 | * conditions and the following disclaimer. |
| 8 | * * Redistributions in binary form must reproduce the above copyright notice, this list of |
| 9 | * conditions and the following disclaimer in the documentation and/or other materials provided |
| 10 | * with the distribution. |
| 11 | * * Neither the name of The Linux Foundation nor the names of its contributors may be used to |
| 12 | * endorse or promote products derived from this software without specific prior written |
| 13 | * permission. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 17 | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 18 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 19 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 20 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 21 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 22 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | */ |
| 24 | |
| 25 | #ifndef __FRAME_EXTN_INTF_H__ |
| 26 | #define __FRAME_EXTN_INTF_H__ |
| 27 | |
| 28 | #include <utils/Timers.h> |
| 29 | #include <sys/types.h> |
| 30 | #include <string> |
| 31 | |
| 32 | #define EXTENSION_LIBRARY_NAME "libframeextension.so" |
| 33 | #define CREATE_FRAME_EXTN_INTERFACE "CreateFrameExtnInterface" |
| 34 | #define DESTROY_FRAME_EXTN_INTERFACE "DestroyFrameExtnInterface" |
| 35 | |
| 36 | namespace composer { |
| 37 | |
| 38 | class FrameExtnIntf; |
| 39 | |
| 40 | // Function addresses queried at runtime using ::dlsym() |
| 41 | typedef bool (*CreateFrameExtnInterface)(FrameExtnIntf **interface); |
| 42 | typedef bool (*DestroyFrameExtnInterface)(FrameExtnIntf *interface); |
| 43 | |
| 44 | /*! @brief This structure defines extension version. |
| 45 | |
| 46 | @details It is used to avoid any mismatch of versions between frameextension library |
| 47 | implementation and its clients usage (like SurfaceFlinger). |
| 48 | |
| 49 | @sa FrameInfo |
| 50 | */ |
| 51 | struct Version { |
| 52 | uint8_t minor; |
| 53 | uint8_t major; |
| 54 | }; |
| 55 | |
| 56 | /*! @brief This structure defines the Frame info required by FrameExtnIntf. |
| 57 | |
| 58 | @sa FrameExtnIntf::SetFrameInfo |
| 59 | */ |
| 60 | struct FrameInfo { |
| 61 | Version version; |
| 62 | bool transparent_region; |
| 63 | int width; |
| 64 | int height; |
| 65 | int max_queued_frames; |
| 66 | int num_idle; |
| 67 | std::string max_queued_layer_name; |
| 68 | std::string layer_name; |
| 69 | nsecs_t current_timestamp; |
| 70 | nsecs_t previous_timestamp; |
| 71 | nsecs_t vsync_timestamp; |
| 72 | nsecs_t refresh_timestamp; |
| 73 | nsecs_t ref_latency; |
| 74 | nsecs_t vsync_period; |
| 75 | }; |
| 76 | |
| 77 | |
| 78 | /*! @brief This interface shall be implemented by frameextension library. |
| 79 | |
| 80 | @details This class declares prototype for frameextension public interfaces which must be |
| 81 | implemented by frameextension library. |
| 82 | */ |
| 83 | class FrameExtnIntf { |
| 84 | public: |
| 85 | /*! @brief Set the FrameInfo used by frameextension. |
| 86 | |
| 87 | @details This function is called once per refresh cycle so that required frame info are |
| 88 | feed to frameextension. |
| 89 | |
| 90 | @param[in] frameInfo \link FrameInfo \endlink |
| 91 | |
| 92 | @return \link int \endlink |
| 93 | */ |
| 94 | virtual int SetFrameInfo(FrameInfo &frameInfo) = 0; |
| 95 | |
| 96 | protected: |
| 97 | virtual ~FrameExtnIntf() { }; |
| 98 | }; |
| 99 | |
| 100 | } // namespace composer |
| 101 | |
| 102 | #endif // __FRAME_EXTN_INTF_H__ |