xref: /aosp_15_r20/external/intel-media-driver/media_driver/agnostic/Xe_M/Xe_XPM/vp/kdll/hal_kerneldll_xe_xpm.c (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 20019, 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      hal_kerneldll_g12hp.c
24 //! \brief         Kernel Dynamic Linking/Loading routines for XeHP
25 //!
26 
27 #include "hal_kerneldll.h"
28 #include "vphal.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif // __cplusplus
33 
34 //---------------------------------------------------------------------------------------
35 // KernelDll_StartKernelSearch_g12hp - Starts kernel search
36 //
37 // Parameters:
38 //    Kdll_State       *pState       - [in]     Dynamic Linking State
39 //    Kdll_FilterEntry *pFilter      - [in]     Search filter (array of search entries)
40 //    int               iFilterSize  - [in]     Search filter size
41 //    Kdll_SearchState *pSearchState - [in/out] Kernel search state
42 //
43 // Output: none
44 //---------------------------------------------------------------------------------------
KernelDll_StartKernelSearch_g12hp(Kdll_State * pState,Kdll_SearchState * pSearchState,Kdll_FilterEntry * pFilter,int32_t iFilterSize,uint32_t uiIs64BInstrEnabled)45 void KernelDll_StartKernelSearch_g12hp(
46     Kdll_State       *pState,
47     Kdll_SearchState *pSearchState,
48     Kdll_FilterEntry *pFilter,
49     int32_t          iFilterSize,
50     uint32_t         uiIs64BInstrEnabled)
51 {
52     int32_t nLayer;
53 
54     VPHAL_RENDER_FUNCTION_ENTER;
55 
56     // Reset all states
57     MOS_ZeroMemory(pSearchState, sizeof(Kdll_SearchState));
58 
59     // Setup KDLL state
60     pSearchState->pKdllState    = pState;     // KDLL state
61 
62     // Cleanup kernel table
63     pSearchState->KernelCount   = 0;          // # of kernels
64 
65     // Cleanup patch data
66     memset(pSearchState->Patches ,  0, sizeof(pSearchState->Patches));
67     memset(pSearchState->PatchID , -1, sizeof(pSearchState->PatchID));
68     pSearchState->PatchCount = 0;
69 
70     // Copy original filter; filter will be modified as part of the search
71     if (pFilter && iFilterSize > 0)
72     {
73         MOS_SecureMemcpy(pSearchState->Filter, iFilterSize * sizeof(Kdll_FilterEntry), pFilter, iFilterSize * sizeof(Kdll_FilterEntry));
74         pSearchState->pFilter      = pSearchState->Filter;
75         pSearchState->iFilterSize  = iFilterSize;
76 
77         // Copy the render target format
78         pSearchState->target_format = pSearchState->pFilter[iFilterSize - 1].format;
79 
80         // Copy the render target tile type
81         pSearchState->target_tiletype = pSearchState->pFilter[iFilterSize - 1].tiletype;
82 
83         // Indicate whether to use 64B save kernel for render target surface
84         if (uiIs64BInstrEnabled                               &&
85             ((pSearchState->target_tiletype == MOS_TILE_X)    ||
86             (pSearchState->target_tiletype  == MOS_TILE_LINEAR)))
87         {
88             pSearchState->b64BSaveEnabled = true;
89         }
90     }
91 }
92 
93 #ifdef __cplusplus
94 }
95 #endif // __cplusplus
96 
KernelDll_ModifyFunctionPointers_g12hp(Kdll_State * pState)97 void KernelDll_ModifyFunctionPointers_g12hp(Kdll_State *pState)
98 {
99     pState->pfnStartKernelSearch = KernelDll_StartKernelSearch_g12hp;
100 }
101