1 /*
2 * Copyright (c) 2018-2020, 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 //!
24 //! \file     media_scalability_defs.h
25 //! \brief    Defines the structures for media scalability
26 
27 #ifndef __MEDIA_SCALABILITY_DEFS_H__
28 #define __MEDIA_SCALABILITY_DEFS_H__
29 
30 #include "mos_util_debug.h"
31 #include "mos_os.h"
32 
33 #define SCALABILITY_CHK_NULL_RETURN(_ptr) \
34     MOS_CHK_NULL_RETURN(MOS_COMPONENT_SCALABILITY, 0, _ptr)
35 
36 #define SCALABILITY_CHK_STATUS_RETURN(_stmt) \
37     MOS_CHK_STATUS_RETURN(MOS_COMPONENT_SCALABILITY, 0, _stmt)
38 
39 #define SCALABILITY_CHK_STATUS_MESSAGE_RETURN(_stmt, _message, ...) \
40     MOS_CHK_STATUS_MESSAGE_RETURN(MOS_COMPONENT_SCALABILITY, 0, _stmt, _message, ##__VA_ARGS__)
41 
42 #define SCALABILITY_ASSERTMESSAGE(_message, ...) \
43     MOS_ASSERTMESSAGE(MOS_COMPONENT_SCALABILITY, 0, _message, ##__VA_ARGS__)
44 
45 #define SCALABILITY_NORMALMESSAGE(_message, ...) \
46     MOS_NORMALMESSAGE(MOS_COMPONENT_SCALABILITY, 0, _message, ##__VA_ARGS__)
47 
48 #define SCALABILITY_VERBOSEMESSAGE(_message, ...) \
49     MOS_VERBOSEMESSAGE(MOS_COMPONENT_SCALABILITY, 0, _message, ##__VA_ARGS__)
50 
51 #define SCALABILITY_ASSERT(_expr) \
52     MOS_ASSERT(MOS_COMPONENT_SCALABILITY, 0, _expr)
53 
54 #define SCALABILITY_COND_CHECK(_expr, _message, ...) \
55     MOS_CHK_COND_RETURN(MOS_COMPONENT_SCALABILITY, 0, _expr, _message, ##__VA_ARGS__)
56 
57 enum ScalabilityComponentType
58 {
59     scalabilityEncoder = 0,
60     scalabilityDecoder = 1,
61     scalabilityVp      = 2,
62     scalabilityTotal,
63 };
64 enum ScalabilitySyncType
65 {
66     syncAllPipes          = 0,
67     syncOnePipeWaitOthers = 1,
68     syncOnePipeForAnother = 2,
69     syncOtherPipesForOne  = 3,
70 };
71 
72 struct ScalabilityPars : public ContextRequirement
73 {
74     bool    enableVE       = false;
75     bool    forceMultiPipe = false;
76 
77     uint32_t frameWidth  = 0;
78     uint32_t frameHeight = 0;
79 
80     uint8_t numVdbox     = 0;
81     uint16_t numTileRows = 0;
82     uint16_t numTileColumns = 0;
83 
84     uint8_t numVebox = 0;
85     bool    enableTileReplay = false;
86     uint32_t raMode = 0;
87     uint32_t protectMode = 0;
88     bool     allowSwArbitarySplit = false;
89 };
90 
91 class ScalabilityTrace
92 {
93 public:
ScalabilityTrace(const char * name)94     ScalabilityTrace(const char *name) : m_name(name)
95     {
96         SCALABILITY_VERBOSEMESSAGE("Enter function:%s\r\n", name);
97     }
98 
~ScalabilityTrace()99     ~ScalabilityTrace()
100     {
101         SCALABILITY_VERBOSEMESSAGE("Exit function:%s\r\n", m_name);
102     }
103 
104 protected:
105     const char *m_name;
106 };
107 
108 #define SCALABILITY_FUNCTION_ENTER ScalabilityTrace _trace(__FUNCTION__);
109 
110 struct ComponentState
111 {
112 };
113 
114 class MediaStatusReport;
115 struct StateParams
116 {
117     uint8_t            currentPipe = 0;
118     uint16_t           currentPass = 0;
119     uint8_t            currentRow = 0;
120     uint8_t            currentSubPass = 0;
121     uint8_t            pipeIndexForSubmit = 0;
122     bool               singleTaskPhaseSupported = false;
123     MediaStatusReport *statusReport = nullptr;
124     ComponentState    *componentState = nullptr;
125 };
126 
127 #endif  // !__MEDIA_SCALABILITY_H__
128