1 /* 2 * Copyright (c) 2019, Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 //! 23 //! \file vphal_render_hdr_g11.h 24 //! \brief Common interface and structure used in HDR for GEN11 25 //! \details Common interface and structure used in HDR for GEN11 Fixed Function Vebox 3DLut 26 //! 27 #ifndef __VPHAL_RENDER_HDR_G11_H__ 28 #define __VPHAL_RENDER_HDR_G11_H__ 29 30 #if !EMUL 31 #include "vphal_common.h" 32 #include "vphal_mdf_wrapper.h" 33 34 //! 35 //! \brief Tone Mapping Source Type, Please don't change the Enmu Value. 36 //! \details These Enmu Values are passed to media kernel for further processing. 37 //! 38 typedef enum _TONE_MAPPING_SOURCE_TYPE 39 { 40 TONE_MAPPING_SOURCE_NONE = 0, 41 TONE_MAPPING_SOURCE_RGB = 1, 42 TONE_MAPPING_SOURCE_PSEUDO_Y_BT2020 = 2, 43 TONE_MAPPING_SOURCE_FULL_Y_BT2020 = 3, 44 TONE_MAPPING_SOURCE_FULL_Y_BT709 = 4, 45 TONE_MAPPING_SOURCE_PSEUDO_Y_BT709 = 5 46 } TONE_MAPPING_SOURCE_TYPE; 47 48 //! 49 //! \brief Tone Mapping Mode. 50 //! \details These Enmu Values are passed to media kernel for further processing. 51 //! 52 typedef enum _TONE_MAPPING_MODE 53 { 54 TONE_MAPPING_MODE_H2H = 0, 55 TONE_MAPPING_MODE_H2S = 1 56 } TONE_MAPPING_MODE; 57 58 //! 59 //! \brief OETF Type. 60 //! \details These Enmu Values are passed to media kernel for further processing. 61 //! 62 typedef enum _OETF_CURVE_TYPE 63 { 64 OETF_CURVE_SDR_709 = 0, 65 OETF_CURVE_HDR_2084 = 1, 66 OETF_SRGB = 2 67 } OETF_CURVE_TYPE; 68 69 class Hdr3DLutCmRender : public VPCmRenderer 70 { 71 public: 72 struct Hdr3DLutPayload 73 { 74 VpCmSurfaceHolder<CmSurface2D> *hdr3DLutSurface; 75 VpCmSurfaceHolder<CmSurface2D> *hdrCoefSurface; 76 uint16_t hdr3DLutSurfaceWidth; 77 uint16_t hdr3DLutSurfaceHeight; 78 }; 79 80 Hdr3DLutCmRender(uint32_t *kernelBinary, uint32_t kernelSize, CmContext *cmContext); 81 Hdr3DLutCmRender(const Hdr3DLutCmRender&) = delete; 82 Hdr3DLutCmRender& operator=(const Hdr3DLutCmRender&) = delete; 83 virtual ~Hdr3DLutCmRender(); 84 85 private: 86 virtual void AttachPayload(void *payload); 87 virtual CmKernel *GetKernelToRun(std::string &name); 88 virtual void GetThreadSpaceDimension(int &tsWidth, int &tsHeight, int &tsColor); 89 virtual void PrepareKernel(CmKernel *kernel); 90 91 CmProgram *m_cmProgram = nullptr; 92 CmKernel *m_cmKernel = nullptr; 93 Hdr3DLutPayload *m_cmPayload = nullptr; 94 }; 95 96 class Hdr3DLutGenerator 97 { 98 public: 99 explicit Hdr3DLutGenerator(PRENDERHAL_INTERFACE vphalRenderer, uint32_t *kernelBinary, uint32_t kernelSize); 100 Hdr3DLutGenerator(const Hdr3DLutGenerator &) = delete; 101 Hdr3DLutGenerator &operator=(const Hdr3DLutGenerator &) = delete; 102 virtual ~Hdr3DLutGenerator(); 103 104 void Render(const uint32_t maxDLL, const uint32_t maxCLL, const VPHAL_HDR_MODE hdrMode, const PVPHAL_SURFACE p3DLutSurface); 105 106 private: 107 void AllocateResources(); 108 void FreeResources(); 109 110 void InitCoefSurface(const uint32_t maxDLL, const uint32_t maxCLL, const VPHAL_HDR_MODE hdrMode); 111 void Init3DLutSurface(); 112 113 EventManager *m_eventManager = nullptr; 114 115 PRENDERHAL_INTERFACE m_renderHal = nullptr; 116 VpCmSurfaceHolder<CmSurface2D> *m_hdr3DLutSurface = nullptr; 117 VpCmSurfaceHolder<CmSurface2D> *m_hdrCoefSurface = nullptr; 118 Hdr3DLutCmRender *m_hdr3DLutCmRender = nullptr; 119 float *m_hdrcoefBuffer = nullptr; 120 uint8_t *m_hdr3DLutSysBuffer = nullptr; 121 CmContext *m_cmContext = nullptr; 122 123 bool m_bHdr3DLutInit = false; 124 uint32_t m_savedMaxDLL = 1000; 125 uint32_t m_savedMaxCLL = 4000; 126 VPHAL_HDR_MODE m_savedHdrMode = VPHAL_HDR_MODE_NONE; 127 128 // Default to 65^3 129 const uint32_t m_segSize = 65; 130 const uint32_t m_mulSize = 128; 131 const uint32_t m_lutSizeInBytes = m_segSize * m_segSize * m_mulSize * 4 * 2; 132 133 uint32_t* m_kernelBinary = nullptr; 134 uint32_t m_kernelSize = 0; 135 }; 136 #else 137 #include "vphal_render_hdr.h" 138 class Hdr3DLutGenerator 139 { 140 public: Hdr3DLutGenerator(PRENDERHAL_INTERFACE vphalRenderer,uint32_t * kernelBinary,uint32_t kernelSize)141 explicit Hdr3DLutGenerator(PRENDERHAL_INTERFACE vphalRenderer, uint32_t* kernelBinary, uint32_t kernelSize) 142 { 143 MOS_UNUSED(vphalRenderer); 144 MOS_UNUSED(kernelBinary); 145 MOS_UNUSED(kernelSize); 146 }; 147 148 Hdr3DLutGenerator(const Hdr3DLutGenerator &) = delete; 149 Hdr3DLutGenerator &operator=(const Hdr3DLutGenerator &) = delete; ~Hdr3DLutGenerator()150 virtual ~Hdr3DLutGenerator() {}; 151 Render(const uint32_t maxDLL,const uint32_t maxCLL,const VPHAL_HDR_MODE hdrMode,const PVPHAL_SURFACE p3DLutSurface)152 void Render(const uint32_t maxDLL, const uint32_t maxCLL, const VPHAL_HDR_MODE hdrMode, const PVPHAL_SURFACE p3DLutSurface) 153 { 154 return ; 155 }; 156 }; 157 #endif 158 #endif // __VPHAL_RENDER_HDR_G11_H__