| 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_composite_g12.cpp |
| 24 | //! \brief Composite related VPHAL functions |
| 25 | //! \details Unified VP HAL Composite module including render initialization, |
| 26 | //! resource allocation/free and rendering |
| 27 | //! |
| 28 | #include "vphal_render_composite_g12.h" |
| 29 | |
| 30 | void CompositeStateG12::SubmitStatesFillGenSpecificStaticData( |
| 31 | PVPHAL_RENDERING_DATA_COMPOSITE pRenderingData, |
| 32 | PVPHAL_SURFACE pTarget, |
| 33 | MEDIA_OBJECT_KA2_STATIC_DATA *pStatic) |
| 34 | { |
| 35 | PVPHAL_SURFACE pSurface; |
| 36 | |
| 37 | //Set shift offset for interlace scaling |
| 38 | //Vertical Frame Origin for Layer 0 - Layer 7 |
| 39 | //Format = Single precision floating point |
| 40 | pSurface = pRenderingData->pLayers[0]; // only using primary layer [0] |
| 41 | |
| 42 | if (nullptr != pSurface && pSurface->bInterlacedScaling) |
| 43 | { |
| 44 | if (pSurface->SampleType == SAMPLE_INTERLEAVED_EVEN_FIRST_TOP_FIELD || pSurface->SampleType == SAMPLE_INTERLEAVED_ODD_FIRST_TOP_FIELD) |
| 45 | { |
| 46 | //use the cropping size, not the surface size |
| 47 | pStatic->DW12.TopBottomDelta = (float)(1.0 / (pSurface->rcDst.bottom - pSurface->rcDst.top) - 1.0 / (pSurface->rcSrc.bottom - pSurface->rcSrc.top)); |
| 48 | } |
| 49 | else |
| 50 | { |
| 51 | pStatic->DW12.TopBottomDelta = (float)(-(1.0 / (pSurface->rcDst.bottom - pSurface->rcDst.top) - 1.0 / (pSurface->rcSrc.bottom - pSurface->rcSrc.top))); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // Set ChromaSitting |
| 56 | pStatic->DW10.ObjKa2Gen9.ChromaSitingLocation = GetOutputChromaSitting(pTarget); |
| 57 | |
| 58 | if (pRenderingData->iLayers > 0) |
| 59 | { |
| 60 | // IEFBypass bit is changed to MBZ bit for Gen12 in HW interface, so driver should always set BypassIEF to be 0 in CURBE. |
| 61 | pStatic->DW09.ObjKa2Gen9.IEFByPassEnable = false; |
| 62 | } |
| 63 | |
| 64 | // Set alpha calculation flag. The bit definitions are different for GEN8 and GEN9+. |
| 65 | // Set Bit-18 |
| 66 | pStatic->DW09.ObjKa2Gen9.AlphaChannelCalculation = pRenderingData->bAlphaCalculateEnable ? true : false; |
| 67 | } |
| 68 | |
| 69 | //! |
| 70 | //! \brief Judge whether Bob Di should be enabled |
| 71 | //! \details Judge whether Bob Di should be enabled according to the parameter |
| 72 | //! of pDeinterlaceParams and the height of the input surface |
| 73 | //! \param [in] pSrc |
| 74 | //! Pointer to Source Surface |
| 75 | //! \return bool |
| 76 | //! Return true if Bob DI should be enabled, otherwise false |
| 77 | //! |
| 78 | bool CompositeStateG12::IsBobDiEnabled(PVPHAL_SURFACE pSrc) |
| 79 | { |
| 80 | bool bRet = false; |
| 81 | |
| 82 | VPHAL_RENDER_CHK_NULL_NO_STATUS(m_pOsInterface); |
| 83 | |
| 84 | // Kernel support inderlaced Y410/Y210 as input format |
| 85 | bRet = (pSrc->pDeinterlaceParams && |
| 86 | !VpHal_RndrCommonIsAlignmentWANeeded(pSrc, m_pOsInterface->CurrentGpuContextOrdinal)); |
| 87 | |
| 88 | finish: |
| 89 | return bRet; |
| 90 | } |
| 91 | |
| 92 | bool CompositeStateG12::IsDisableAVSSampler( |
| 93 | int32_t iSources, |
| 94 | bool isTargetY) |
| 95 | { |
| 96 | if (isTargetY) |
| 97 | { |
| 98 | return true; |
| 99 | } |
| 100 | |
| 101 | return false; |
| 102 | } |