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 ddi_cp_interface_next.h
24 //! \brief This file defines the C++ class/interface for DDI interface of content protection
25 //! \details Other components will call this interface for content protection operations directly
26 //!
27
28 #ifndef __DDI_CP_INTERFACE_NEXT_H__
29 #define __DDI_CP_INTERFACE_NEXT_H__
30
31 #include <map>
32 #include "media_libva.h"
33 #include "cp_factory.h"
34 #include "mos_os.h"
35 #include "media_libva_util_next.h"
36
37 struct CodechalDecodeParams;
38 class CodechalSetting;
39 class DdiCpInterfaceNext;
40
41 namespace encode
42 {
43 typedef struct _DDI_ENCODE_STATUS_REPORT_INFO *PDDI_ENCODE_STATUS_REPORT_INFO;
44 }
45
46 namespace decode
47 {
48 struct DDI_DECODE_CONTEXT;
49 }
50
51 //core structure for CP DDI
52 typedef struct _DDI_CP_CONTEXT_NEXT
53 {
54 PDDI_MEDIA_CONTEXT pMediaCtx;
55 DdiCpInterfaceNext *pCpDdiInterface;
56 std::shared_ptr<void> pDrvPrivate;
57 std::multimap<uint32_t, void *> mapAttaching;
58 PERF_DATA perfData;
59 } DDI_CP_CONTEXT_NEXT, *PDDI_CP_CONTEXT_NEXT;
60
GetCpContextNextFromPVOID(void * cpCtx)61 static __inline PDDI_CP_CONTEXT_NEXT GetCpContextNextFromPVOID(void *cpCtx)
62 {
63 return (PDDI_CP_CONTEXT_NEXT)cpCtx;
64 }
65
66 #define DDI_CP_STUB_MESSAGE DDI_CP_NORMALMESSAGE("This function is stubbed as CP is not enabled.")
67 class DdiCpInterfaceNext
68 {
69 public:
DdiCpInterfaceNext(MOS_CONTEXT & mosCtx)70 DdiCpInterfaceNext(MOS_CONTEXT& mosCtx) {}
71
~DdiCpInterfaceNext()72 virtual ~DdiCpInterfaceNext() {}
73
SetCpParams(uint32_t encryptionType,CodechalSetting * setting)74 virtual void SetCpParams(uint32_t encryptionType, CodechalSetting *setting)
75 {
76 DDI_CP_STUB_MESSAGE;
77 }
78
RenderCencPicture(VADriverContextP vaDrvctx,VAContextID contextId,DDI_MEDIA_BUFFER * buf,void * data)79 virtual VAStatus RenderCencPicture(
80 VADriverContextP vaDrvctx,
81 VAContextID contextId,
82 DDI_MEDIA_BUFFER *buf,
83 void *data)
84 {
85 DDI_CP_STUB_MESSAGE;
86 return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE;
87 }
88
CreateBuffer(VABufferType type,DDI_MEDIA_BUFFER * buffer,uint32_t size,uint32_t num_elements)89 virtual VAStatus CreateBuffer(
90 VABufferType type,
91 DDI_MEDIA_BUFFER* buffer,
92 uint32_t size,
93 uint32_t num_elements)
94 {
95 DDI_CP_STUB_MESSAGE;
96 return VA_STATUS_ERROR_UNSUPPORTED_BUFFERTYPE;
97 }
98
InitHdcp2Buffer(DDI_CODEC_COM_BUFFER_MGR * bufMgr)99 virtual VAStatus InitHdcp2Buffer(DDI_CODEC_COM_BUFFER_MGR* bufMgr)
100 {
101 DDI_CP_STUB_MESSAGE;
102 return VA_STATUS_SUCCESS;
103 }
104
StatusReportForHdcp2Buffer(DDI_CODEC_COM_BUFFER_MGR * bufMgr,void * encodeStatusReport)105 virtual VAStatus StatusReportForHdcp2Buffer(
106 DDI_CODEC_COM_BUFFER_MGR *bufMgr,
107 void *encodeStatusReport)
108 {
109 DDI_CP_STUB_MESSAGE;
110 return VA_STATUS_SUCCESS;
111 }
112
FreeHdcp2Buffer(DDI_CODEC_COM_BUFFER_MGR * bufMgr)113 virtual void FreeHdcp2Buffer(DDI_CODEC_COM_BUFFER_MGR *bufMgr)
114 {
115 DDI_CP_STUB_MESSAGE;
116 return;
117 }
118
StoreCounterToStatusReport(encode::PDDI_ENCODE_STATUS_REPORT_INFO info)119 virtual MOS_STATUS StoreCounterToStatusReport(
120 encode::PDDI_ENCODE_STATUS_REPORT_INFO info)
121 {
122 DDI_CP_STUB_MESSAGE;
123 return MOS_STATUS_SUCCESS;
124 }
125
ParseCpParamsForEncode()126 virtual VAStatus ParseCpParamsForEncode()
127 {
128 DDI_CP_STUB_MESSAGE;
129 return VA_STATUS_SUCCESS;
130 }
131
SetCpFlags(int32_t flag)132 virtual void SetCpFlags(int32_t flag)
133 {
134 DDI_CP_STUB_MESSAGE;
135 }
136
IsHdcp2Enabled()137 virtual bool IsHdcp2Enabled()
138 {
139 DDI_CP_STUB_MESSAGE;
140 return false;
141 }
142
SetInputResourceEncryption(PMOS_INTERFACE osInterface,PMOS_RESOURCE resource)143 virtual void SetInputResourceEncryption(
144 PMOS_INTERFACE osInterface,
145 PMOS_RESOURCE resource)
146 {
147 DDI_CP_STUB_MESSAGE;
148 }
149
CreateCencDecode(CodechalDebugInterface * debugInterface,PMOS_CONTEXT osContext,CodechalSetting * settings)150 virtual VAStatus CreateCencDecode(
151 CodechalDebugInterface *debugInterface,
152 PMOS_CONTEXT osContext,
153 CodechalSetting *settings)
154 {
155 DDI_CP_STUB_MESSAGE;
156 return VA_STATUS_SUCCESS;
157 }
158
SetDecodeParams(decode::DDI_DECODE_CONTEXT * ddiDecodeContext,CodechalSetting * setting)159 virtual VAStatus SetDecodeParams(
160 decode::DDI_DECODE_CONTEXT *ddiDecodeContext,
161 CodechalSetting *setting)
162 {
163 DDI_CP_STUB_MESSAGE;
164 return VA_STATUS_SUCCESS;
165 }
166
IsCencProcessing()167 virtual bool IsCencProcessing()
168 {
169 DDI_CP_STUB_MESSAGE;
170 return false;
171 }
172
EndPicture(VADriverContextP ctx,VAContextID context)173 virtual VAStatus EndPicture(
174 VADriverContextP ctx,
175 VAContextID context)
176 {
177 DDI_CP_STUB_MESSAGE;
178 return VA_STATUS_SUCCESS;
179 }
180
IsAttachedSessionAlive()181 virtual VAStatus IsAttachedSessionAlive()
182 {
183 DDI_CP_STUB_MESSAGE;
184 return VA_STATUS_SUCCESS;
185 }
186
187 MEDIA_CLASS_DEFINE_END(DdiCpInterfaceNext)
188 };
189
190 enum DdiCpCreateType
191 {
192 CreateDdiCpInterface = 0,
193 CreateDdiCpImp = 1
194 };
195
196 typedef CpFactory<DdiCpInterfaceNext, MOS_CONTEXT&> DdiCpFactory;
197
198 DdiCpInterfaceNext* CreateDdiCpNext(MOS_CONTEXT* mosCtx);
199
200 #endif
201