xref: /aosp_15_r20/external/intel-media-driver/media_driver/linux/common/ddi/media_libva_apo_decision.cpp (revision ba62d9d3abf0e404f2022b4cd7a85e107f48596f)
1 /*
2 * Copyright (c) 2022, 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     media_libva_apo_desicion.cpp
24 //! \brief    libva apo desicion.
25 //!
26 
27 #include "media_libva_apo_decision.h"
28 #include "mos_os_specific.h"
29 #include "hwinfo_linux.h"
30 #include "media_libva_util.h"
31 
InitDdiApoState(int32_t devicefd,MediaUserSettingSharedPtr userSettingPtr)32 bool MediaLibvaApoDecision::InitDdiApoState(int32_t devicefd, MediaUserSettingSharedPtr userSettingPtr)
33 {
34     DDI_FUNCTION_ENTER();
35 
36     bool apoMosEnabled = SetupApoMosSwitch(devicefd, userSettingPtr);
37     bool apoDdiEnabled = SetupApoDdiSwitch(devicefd, userSettingPtr);
38     if (!apoMosEnabled || !apoDdiEnabled)
39     {
40         return false;
41     }
42 
43     // if media solo supported, use default path
44     bool mediaSoloEnabled = SetupMediaSoloSwitch();
45     if (mediaSoloEnabled)
46     {
47         if (!apoDdiEnabled)
48         {
49             MOS_OS_CRITICALMESSAGE("DDI is not apo path! Pls use APO DDI!");
50         }
51         if (!apoMosEnabled)
52         {
53             MOS_OS_CRITICALMESSAGE("MOS is not apo path! Pls use APO MOS!");
54         }
55         return apoDdiEnabled && apoMosEnabled;
56     }
57 
58     PRODUCT_FAMILY eProductFamily = IGFX_UNKNOWN;
59     HWInfo_GetGfxProductFamily(devicefd, eProductFamily);
60 
61     if (eProductFamily < IGFX_METEORLAKE)
62     {
63         apoDdiEnabled = false;
64     }
65 
66     return apoDdiEnabled && apoMosEnabled;
67 }