1 /*
2 * Copyright (c) 2017-2021, 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     mos_util_user_interface.h
24 //! \brief    Common MOS util user feature key service across different platform
25 //! \details  Common MOS util user feature key service across different platform
26 //!
27 #ifndef __MOS_UTIL_USER_INTERFACE_H__
28 #define __MOS_UTIL_USER_INTERFACE_H__
29 
30 #include "igfxfmid.h"
31 #include "mos_utilities.h"
32 #include <map>
33 
34 using UserFeatureValueMapType = std::map<uint32_t, PMOS_USER_FEATURE_VALUE>;
35 
36 class MosUtilUserInterface
37 {
38 public:
39     MosUtilUserInterface() = default;
40     virtual ~MosUtilUserInterface() = default;
41 
42     //!
43     //! \brief    Add a user feature key to the m_userFeatureKeyMap
44     //! \details  Each component call MosUtilities::MosDeclareUserFeatureKeysFromDescFields to add their specifc user key vlaue to the m_userFeatureKeyMap
45     //! \return   MOS_STATUS
46     //!           Returns one of the MOS_STATUS error codes if failed,
47     //!           else MOS_STATUS_SUCCESS
48     //!
49     static MOS_STATUS AddEntry(uint32_t keyId, PMOS_USER_FEATURE_VALUE userFeatureKey);
50 
51     //!
52     //! \brief    Del a user feature key from the m_userFeatureKeyMap
53     //! \details  Each component call MosUtilities::MosDestroyUserFeatureKeysFromDescFields to delete their regostered user key from the m_userFeatureKeyMap
54     //! \return   MOS_STATUS
55     //!           Returns one of the MOS_STATUS error codes if failed,
56     //!           else MOS_STATUS_SUCCESS
57     //!
58     static MOS_STATUS DelEntry(uint32_t keyId);
59 
60     //!
61     //! \brief    Get a user feature key from the m_userFeatureKeyMap
62     //! \details  Get a user feature key from the m_userFeatureKeyMap
63     //! \return   MOS_STATUS
64     //!           Returns one of the MOS_STATUS error codes if failed,
65     //!           else MOS_STATUS_SUCCESS
66     //!
67     static PMOS_USER_FEATURE_VALUE GetValue(uint32_t keyId);
68 
69     //!
70     //! \brief    Get user feature key map
71     //! \details  Get user feature key map
72     //! \return   UserFeatureValueMapType
73     //!           Returns the map of user feature keys.
74     //!
GetUserFeatureKeyMap()75     static UserFeatureValueMapType& GetUserFeatureKeyMap()
76     {
77         return m_userFeatureKeyMap;
78     }
79 
80 private:
81     static std::map<uint32_t, PMOS_USER_FEATURE_VALUE>  m_userFeatureKeyMap;
82     static MosMutex                                     m_mosMutex;
83 };
84 
85 
86 #endif // __MOS_UTIL_USER_INTERFACE_H__
87