1 /*
2 * Copyright (c) 2012-2017, 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_sfc_g9_base.cpp
24 //! \brief    VPHAL SFC Gen9 rendering component
25 //! \details  The SFC renderer supports Scaling, IEF, CSC/ColorFill and Rotation.
26 //!           It's responsible for setting up HW states and generating the SFC
27 //!           commands.
28 //!
29 #include "vphal_render_vebox_base.h"
30 #include "vphal_render_sfc_g9_base.h"
31 
32 #if __VPHAL_SFC_SUPPORTED
33 
IsInputFormatSupported(PVPHAL_SURFACE srcSurface)34 bool VphalSfcStateG9::IsInputFormatSupported(
35     PVPHAL_SURFACE              srcSurface)
36 {
37     bool ret = true;
38     // Check if Input Format is supported
39     if ((srcSurface->Format != Format_NV12)     &&
40         (srcSurface->Format != Format_AYUV)     &&
41         (srcSurface->Format != Format_P010)     &&
42         (srcSurface->Format != Format_P016)     &&
43         (srcSurface->Format != Format_A8B8G8R8) &&
44         (srcSurface->Format != Format_X8B8G8R8) &&
45         (srcSurface->Format != Format_A8R8G8B8) &&
46         (srcSurface->Format != Format_X8R8G8B8) &&
47         (!IS_PA_FORMAT(srcSurface->Format)      ||
48          (srcSurface->Format == Format_Y410)    ||    // Gen9 can't support Y410/Y416/Y210/Y216 Format
49          (srcSurface->Format == Format_Y416)    ||
50          (srcSurface->Format == Format_Y210)    ||
51          (srcSurface->Format == Format_Y216)))
52     {
53         VPHAL_RENDER_NORMALMESSAGE("Unsupported Source Format '0x%08x' for SFC.", srcSurface->Format);
54         ret = false;
55     }
56 
57     return ret;
58 }
59 
IsOutputFormatSupported(PVPHAL_SURFACE outSurface)60 bool VphalSfcStateG9::IsOutputFormatSupported(
61     PVPHAL_SURFACE              outSurface)
62 {
63     bool ret = true;
64     if (!IS_RGB32_FORMAT(outSurface->Format)   &&
65         // Remove RGB565 support due to quality issue, may reopen this after root cause in the future.
66         //!IS_RGB16_FORMAT(outSurface->Format)   &&
67         outSurface->Format != Format_NV12      &&
68         outSurface->Format != Format_YUY2      &&
69         outSurface->Format != Format_UYVY      &&
70         outSurface->Format != Format_AYUV)
71     {
72         VPHAL_RENDER_NORMALMESSAGE("Unsupported Render Target Format '0x%08x' for SFC Pipe.", outSurface->Format);
73 
74         ret = false;
75     }
76 
77     return ret;
78 }
79 
GetInputWidthHeightAlignUnit(MOS_FORMAT inputFormat,MOS_FORMAT outputFormat,uint16_t & widthAlignUnit,uint16_t & heightAlignUnit,bool isInterlacedScaling)80 void VphalSfcStateG9::GetInputWidthHeightAlignUnit(
81     MOS_FORMAT              inputFormat,
82     MOS_FORMAT              outputFormat,
83     uint16_t                &widthAlignUnit,
84     uint16_t                &heightAlignUnit,
85     bool                    isInterlacedScaling)
86 {
87     MOS_UNUSED(inputFormat);
88 
89     widthAlignUnit  = 1;
90     heightAlignUnit = 1;
91 
92     // Apply output alignment restriction to Region of the input frame.
93     GetOutputWidthHeightAlignUnit(outputFormat, widthAlignUnit, heightAlignUnit);
94 }
95 
96 #endif // __VPHAL_SFC_SUPPORTED