1 /*
2 * Copyright (c) 2020-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     mhw_itf.h
24 //! \brief    MHW itf common defines
25 //! \details
26 //!
27 
28 #ifndef __MHW_ITF_H__
29 #define __MHW_ITF_H__
30 
31 #include "mhw_cmdpar.h"
32 
33 #if _MHW_HWCMDPARSER_SUPPORTED
34 #include "mhw_hwcmd_parser.h"
35 #endif
36 
37 //   [Macro Prefixes]                 |   [Macro Suffixes]
38 //   No Prefix: for external use      |   _T   : type
39 //   _        : for internal use      |   _F   : function name
40 //   __       : intermediate macros   |   _M   : class member name
41 //              only used by other    |   _DECL: declaration
42 //              macros                |   _DEF : definition
43 
44 #define __MHW_GETPAR_F(CMD) GETPAR_##CMD         // function name to get the pointer to MHW command parameter
45 #define MHW_GETPAR_F(CMD) __MHW_GETPAR_F(CMD)    // to support 2-level macro expanding
46 #define __MHW_GETSIZE_F(CMD) GETSIZE_##CMD       // function name to get MHW command size in byte
47 #define MHW_GETSIZE_F(CMD) __MHW_GETSIZE_F(CMD)  // to support 2-level macro expanding
48 #define __MHW_ADDCMD_F(CMD) ADDCMD_##CMD         // function name to add command
49 #define MHW_ADDCMD_F(CMD) __MHW_ADDCMD_F(CMD)    // to support 2-level macro expanding
50 #define __MHW_SETCMD_F(CMD) SETCMD_##CMD         // function name to set command data
51 
52 #define __MHW_GETPAR_DECL(CMD) _MHW_PAR_T(CMD) & MHW_GETPAR_F(CMD)()
53 #define __MHW_GETSIZE_DECL(CMD) size_t MHW_GETSIZE_F(CMD)() const
54 #define __MHW_ADDCMD_DECL(CMD) MOS_STATUS MHW_ADDCMD_F(CMD)(PMOS_COMMAND_BUFFER cmdBuf, PMHW_BATCH_BUFFER batchBuf = nullptr)
55 #define __MHW_SETCMD_DECL(CMD) MOS_STATUS __MHW_SETCMD_F(CMD)()
56 
57 #define _MHW_CMD_ALL_DEF_FOR_ITF(CMD)    \
58 public:                                  \
59     virtual __MHW_GETPAR_DECL(CMD)  = 0; \
60     virtual __MHW_GETSIZE_DECL(CMD) = 0; \
61     virtual __MHW_ADDCMD_DECL(CMD)  = 0; \
62                                          \
63 protected:                               \
64     virtual __MHW_SETCMD_DECL(CMD) { return MOS_STATUS_SUCCESS; }
65 
66 #endif  // __MHW_DEF_H__
67