1 /*
2 * Copyright (c) 2009-2023, 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_vp_tools.c
24 //! \brief LibVA Video Processing tool functions implementation
25 //!
26
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <sys/time.h>
30
31 #include <va/va.h>
32 #include <va/va_vpp.h>
33 #include <va/va_backend.h>
34
35 #include "vphal.h"
36 #include "vphal_ddi.h"
37
38 #include "media_libva.h"
39 #include "media_libva_util.h"
40 #include "media_libva_vp.h"
41 #include "media_libva_vp_tools.h"
42
43 #if (_DEBUG || _RELEASE_INTERNAL)
44
VpInitDumpConfig(PDDI_VP_CONTEXT pVpCtx)45 VAStatus VpInitDumpConfig(
46 PDDI_VP_CONTEXT pVpCtx)
47 {
48 int32_t uSurfIndex;
49 VAStatus vaStatus = VA_STATUS_SUCCESS;
50
51 pVpCtx->pCurVpDumpDDIParam = nullptr;
52 pVpCtx->pPreVpDumpDDIParam = nullptr;
53
54 // allocate pCurVpDumpDDIParam
55 pVpCtx->pCurVpDumpDDIParam = (PDDI_VP_DUMP_PARAM)MOS_AllocAndZeroMemory(sizeof(DDI_VP_DUMP_PARAM));
56 if (pVpCtx->pCurVpDumpDDIParam)
57 {
58 for (uSurfIndex = 0; uSurfIndex < VPHAL_MAX_SOURCES; uSurfIndex++)
59 {
60 pVpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[uSurfIndex] = (VAProcPipelineParameterBuffer *)MOS_AllocAndZeroMemory(sizeof(VAProcPipelineParameterBuffer));
61 if (nullptr == pVpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[uSurfIndex])
62 {
63 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
64 goto FINISH;
65 }
66 }
67 }
68 // allocate pPreVpDumpDDIParam
69 pVpCtx->pPreVpDumpDDIParam = (PDDI_VP_DUMP_PARAM)MOS_AllocAndZeroMemory(sizeof(DDI_VP_DUMP_PARAM));
70 if (pVpCtx->pPreVpDumpDDIParam)
71 {
72 for (uSurfIndex = 0; uSurfIndex < VPHAL_MAX_SOURCES; uSurfIndex++)
73 {
74 pVpCtx->pPreVpDumpDDIParam->pPipelineParamBuffers[uSurfIndex] = (VAProcPipelineParameterBuffer *)MOS_AllocAndZeroMemory(sizeof(VAProcPipelineParameterBuffer));
75 if (nullptr == pVpCtx->pPreVpDumpDDIParam->pPipelineParamBuffers[uSurfIndex])
76 {
77 vaStatus = VA_STATUS_ERROR_ALLOCATION_FAILED;
78 goto FINISH;
79 }
80 }
81 }
82
83 FINISH:
84 pVpCtx->fpDumpFile = nullptr;
85 return vaStatus;
86 }
87
VpDestoryDumpConfig(PDDI_VP_CONTEXT pVpCtx)88 void VpDestoryDumpConfig(
89 PDDI_VP_CONTEXT pVpCtx)
90 {
91 int32_t uSurfIndex;
92 VAStatus vaStatus = VA_STATUS_SUCCESS;
93
94 if (pVpCtx->pCurVpDumpDDIParam)
95 {
96 for (uint32_t uSurfIndex = 0; uSurfIndex < VPHAL_MAX_SOURCES; uSurfIndex++)
97 {
98 if (nullptr != pVpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[uSurfIndex])
99 {
100 MOS_FreeMemAndSetNull(pVpCtx->pCurVpDumpDDIParam->pPipelineParamBuffers[uSurfIndex]);
101 }
102 }
103 MOS_FreeMemAndSetNull(pVpCtx->pCurVpDumpDDIParam);
104 }
105
106 if (nullptr != pVpCtx->pPreVpDumpDDIParam)
107 {
108 for (uint32_t uSurfIndex = 0; uSurfIndex < VPHAL_MAX_SOURCES; uSurfIndex++)
109 {
110 if (nullptr != pVpCtx->pPreVpDumpDDIParam->pPipelineParamBuffers[uSurfIndex])
111 {
112 MOS_FreeMemAndSetNull(pVpCtx->pPreVpDumpDDIParam->pPipelineParamBuffers[uSurfIndex]);
113 }
114 }
115 MOS_FreeMemAndSetNull(pVpCtx->pPreVpDumpDDIParam);
116 }
117
118 if (nullptr != pVpCtx->fpDumpFile)
119 {
120 fclose(pVpCtx->fpDumpFile);
121 pVpCtx->fpDumpFile = nullptr;
122 }
123 }
124
125 //!
126 //! \brief dump deinterlacing parameter
127 //! \param fpLog
128 //! [in] file pointer pointed to dumpped file
129 //! \param deint
130 //! [in] pointed to deinterlacing parameter
131 //!
VpDumpDeinterlacingParameterBuffer(FILE * fpLog,VAProcFilterParameterBufferDeinterlacing * deint)132 void VpDumpDeinterlacingParameterBuffer(
133 FILE *fpLog,
134 VAProcFilterParameterBufferDeinterlacing *deint)
135 {
136 if (deint && fpLog)
137 {
138 fprintf(fpLog, "\t type = %d\n", deint->type);
139 fprintf(fpLog, "\t algorithm = %d\n", deint->algorithm);
140 fprintf(fpLog, "\t flags = %d\n", deint->flags);
141 }
142 }
143
144 //!
145 //! \brief dump color balance parameter
146 //! \param fpLog
147 //! [in] file pointer pointed to dumpped file
148 //! \param colorbalance
149 //! [in] pointed to colorbalance parameter
150 //! \param uElementNum
151 //! [in] number of elements
152 //!
VpDumpColorBalanceParameterBuffer(FILE * fpLog,VAProcFilterParameterBufferColorBalance * colorbalance,uint32_t uElementNum)153 void VpDumpColorBalanceParameterBuffer(
154 FILE *fpLog,
155 VAProcFilterParameterBufferColorBalance *colorbalance,
156 uint32_t uElementNum)
157 {
158 for (uint32_t i = 0; i<uElementNum; i++)
159 {
160 if (fpLog && colorbalance)
161 {
162 fprintf(fpLog, "\t type = %d\n", colorbalance[i].type);
163 fprintf(fpLog, "\t attrib = %d\n", colorbalance[i].attrib);
164 fprintf(fpLog, "\t value = %f\n", colorbalance[i].value);
165 }
166 }
167 }
168
169 //!
170 //! \brief dump TCC parameter
171 //! \param fpLog
172 //! [in] file pointer pointed to dumpped file
173 //! \param filter_param
174 //! [in] pointed to TCC parameter
175 //! \param uElementNum
176 //! [in] number of elements
177 //!
VpDumpTotalColorCorrectionParameterBuffer(FILE * fpLog,VAProcFilterParameterBufferTotalColorCorrection * filter_param,uint32_t uElementNum)178 void VpDumpTotalColorCorrectionParameterBuffer(
179 FILE *fpLog,
180 VAProcFilterParameterBufferTotalColorCorrection *filter_param,
181 uint32_t uElementNum)
182 {
183 for (uint32_t i = 0; i<uElementNum; i++)
184 {
185 if (fpLog && filter_param)
186 {
187 fprintf(fpLog, "\t type = %d\n", filter_param[i].type);
188 fprintf(fpLog, "\t attrib = %d\n", filter_param[i].attrib);
189 fprintf(fpLog, "\t value = %f\n", filter_param[i].value);
190 }
191 }
192 }
193
194 //!
195 //! \brief dump filter parameter
196 //! \param fpLog
197 //! [in] file pointer pointed to dumpped file
198 //! \param buffer
199 //! [in] pointed to filter parameter
200 //!
VpDumpFilterParameterBuffer(FILE * fpLog,VAProcFilterParameterBuffer * buffer)201 void VpDumpFilterParameterBuffer(
202 FILE *fpLog,
203 VAProcFilterParameterBuffer *buffer)
204 {
205 if (fpLog && buffer)
206 {
207 fprintf(fpLog, "\t type = %d\n", buffer->type);
208 fprintf(fpLog, "\t value = %f\n", buffer->value);
209 }
210 }
211
212 //!
213 //! \brief dump filters parameter
214 //! \param fpLog
215 //! [in] file pointer pointed to dumpped file
216 //! \param pVaDrvCtx
217 //! [in] driver context
218 //! \param filters
219 //! [in] pointed to filters
220 //! \param num_filters
221 //! [in] number of filters
222 //!
VpDumpProcFiltersParameterBuffer(FILE * fpLog,VADriverContextP pVaDrvCtx,VABufferID * filters,unsigned int num_filters)223 void VpDumpProcFiltersParameterBuffer(
224 FILE *fpLog,
225 VADriverContextP pVaDrvCtx,
226 VABufferID *filters,
227 unsigned int num_filters)
228 {
229 VABufferType type;
230 unsigned int size;
231 unsigned int num_elements;
232 PDDI_MEDIA_CONTEXT pMediaCtx;
233 void *pData;
234 PDDI_MEDIA_BUFFER pFilterBuf;
235
236 size = 0;
237 num_elements = 0;
238 pFilterBuf = nullptr;
239 pMediaCtx = nullptr;
240 pData = nullptr;
241
242 if (nullptr == fpLog || nullptr == pVaDrvCtx)
243 {
244 return;
245 }
246
247 pMediaCtx = DdiMedia_GetMediaContext(pVaDrvCtx);
248
249 fprintf(fpLog, "\t num_filters = %d\n", num_filters);
250 fprintf(fpLog, "\t filters = %p\n", filters);
251
252 if (num_filters == 0 || filters == nullptr)
253 {
254 return;
255 }
256
257 // get buffer type information
258 for (int i = 0; i < num_filters; i++)
259 {
260 VABufferID filter = filters[i];
261 pFilterBuf = DdiMedia_GetBufferFromVABufferID(pMediaCtx, filter);
262
263 // Map Buffer data to virtual addres space
264 DdiMedia_MapBuffer(pVaDrvCtx, filter, &pData);
265
266 VAProcFilterParameterBufferBase* filter_param = (VAProcFilterParameterBufferBase*) pData;
267 if (nullptr != pFilterBuf)
268 {
269 fprintf(fpLog, "\t num_elements = %d\n", pFilterBuf->uiNumElements);
270 }
271
272 if (nullptr != filter_param)
273 {
274 switch (filter_param->type)
275 {
276 case VAProcFilterDeinterlacing:
277 VpDumpDeinterlacingParameterBuffer(fpLog, (VAProcFilterParameterBufferDeinterlacing *)pData);
278 break;
279
280 case VAProcFilterColorBalance:
281 if (nullptr != pFilterBuf)
282 {
283 VpDumpColorBalanceParameterBuffer(fpLog, (VAProcFilterParameterBufferColorBalance *)pData, pFilterBuf->uiNumElements);
284 }
285 break;
286
287 case VAProcFilterTotalColorCorrection:
288 if (nullptr != pFilterBuf)
289 {
290 VpDumpTotalColorCorrectionParameterBuffer(fpLog, (VAProcFilterParameterBufferTotalColorCorrection *)pData, pFilterBuf->uiNumElements);
291 }
292 break;
293
294 case VAProcFilterNoiseReduction:
295 VpDumpFilterParameterBuffer(fpLog, (VAProcFilterParameterBuffer *)pData);
296 break;
297
298 case VAProcFilterSharpening:
299 VpDumpFilterParameterBuffer(fpLog, (VAProcFilterParameterBuffer *)pData);
300 break;
301
302 case VAProcFilterSkinToneEnhancement:
303 VpDumpFilterParameterBuffer(fpLog, (VAProcFilterParameterBuffer *)pData);
304 break;
305
306 default:
307 fprintf(fpLog, "\t type = %d\n", filter_param->type);
308 break;
309 }
310 }
311 }
312 }
313
314 //!
315 //! \brief read a config "env" for vpddi.conf or from environment setting
316 //! \param env
317 //! [in] Pipeline parameters from application (VAProcPipelineParameterBuffer)
318 //! \param env_value
319 //! [out]
320 //! \return int
321 //! return 0, if the "env" is set, and the value is copied into env_value
322 //! return 1, if the env is not set
323 //!
VpParseLogConfig(const char * env,char * env_value)324 int VpParseLogConfig(
325 const char *env,
326 char *env_value)
327 {
328 char *token, *value, *saveptr;
329 char oneline[1024];
330 FILE *fp = nullptr;
331
332 if (env == nullptr)
333 {
334 return 1;
335 }
336
337 fp = fopen("/etc/vpddi.conf", "r");
338 while (fp && (fgets(oneline, 1024, fp) != nullptr))
339 {
340 if (strlen(oneline) == 1)
341 {
342 continue;
343 }
344
345 token = strtok_r(oneline, "=\n", &saveptr);
346 value = strtok_r(nullptr, "=\n", &saveptr);
347
348 if (nullptr == token || nullptr == value)
349 {
350 continue;
351 }
352
353 if (strcmp(token, env) == 0)
354 {
355 if (env_value)
356 {
357 strncpy(env_value, value, 1024);
358 }
359
360 fclose(fp);
361 fp = nullptr;
362 return 0;
363 }
364 }
365 if (fp)
366 {
367 fclose(fp);
368 fp = nullptr;
369 }
370
371 // no setting in config file, use env setting
372 value = getenv(env);
373 if (value)
374 {
375 if (env_value)
376 {
377 strncpy(env_value, value, 1024);
378 }
379
380 return 0;
381 }
382
383 return 1;
384 }
385
386 //!
387 //! \brief compare current dump parameters with the previous
388 //! \param pCur
389 //! [in] current dump parameters
390 //! \param pPre
391 //! [in] previous dump parameters
392 //! \return bool
393 //! return true, if current parameters and previous are same
394 //! return false, if current parameters and previous are different
395 //!
VpCmpDDIDumpParam(PDDI_VP_DUMP_PARAM pCur,PDDI_VP_DUMP_PARAM pPre)396 bool VpCmpDDIDumpParam(
397 PDDI_VP_DUMP_PARAM pCur,
398 PDDI_VP_DUMP_PARAM pPre)
399 {
400 bool bRet = true;
401
402 if (!pCur || !pPre)
403 {
404 return false;
405 }
406
407 if (memcmp(pCur->SrcFormat, pPre->SrcFormat, sizeof(MOS_FORMAT)*VPHAL_MAX_SOURCES) != 0)
408 {
409 bRet = false;
410 }
411
412 if (memcmp(pCur->TargetFormat, pPre->TargetFormat, sizeof(MOS_FORMAT)*VPHAL_MAX_TARGETS) != 0)
413 {
414 bRet = false;
415 }
416
417 for (uint32_t uSurfIndex = 0; uSurfIndex < VPHAL_MAX_SOURCES; uSurfIndex++)
418 {
419 if (memcmp(pCur->pPipelineParamBuffers[uSurfIndex], pPre->pPipelineParamBuffers[uSurfIndex], sizeof(VAProcPipelineParameterBuffer)) != 0)
420 {
421 bRet = false;
422 }
423 }
424
425 return bRet;
426 }
427
VpDumpProcPipelineParams(VADriverContextP pVaDrvCtx,PDDI_VP_CONTEXT pVpCtx)428 VAStatus VpDumpProcPipelineParams(
429 VADriverContextP pVaDrvCtx,
430 PDDI_VP_CONTEXT pVpCtx)
431 {
432 PDDI_MEDIA_CONTEXT pMediaCtx;
433 FILE *fpLog;
434 long suffix;
435 struct timeval time;
436 VPHAL_RENDER_PARAMS *pRenderParams;
437 PDDI_MEDIA_SURFACE pMediaSrcSurf;
438 bool bDumpToFile;
439 PDDI_VP_DUMP_PARAM pCurDDIParam;
440 PDDI_VP_DUMP_PARAM pPreDDIParam;
441 char env_value[1024];
442
443 DDI_CHK_NULL(pVaDrvCtx, "Null pVaDrvCtx.", VA_STATUS_ERROR_INVALID_CONTEXT);
444 DDI_CHK_NULL(pVpCtx, "Null pVpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT);
445 DDI_CHK_NULL(pVpCtx->pVpHalRenderParams, "Null Render Params.", VA_STATUS_ERROR_INVALID_PARAMETER);
446 DDI_CHK_NULL(pVpCtx->pCurVpDumpDDIParam, "Null Dump Params.", VA_STATUS_ERROR_INVALID_PARAMETER);
447 DDI_CHK_NULL(pVpCtx->pPreVpDumpDDIParam, "Null Dump Params.", VA_STATUS_ERROR_INVALID_PARAMETER);
448
449 for (uint32_t index = 0; index < pVpCtx->pVpHalRenderParams->uDstCount; index++)
450 {
451 pVpCtx->pCurVpDumpDDIParam->TargetFormat[index] = pVpCtx->pVpHalRenderParams->pTarget[index]->Format;
452 }
453
454 pCurDDIParam = pVpCtx->pCurVpDumpDDIParam;
455 pPreDDIParam = pVpCtx->pPreVpDumpDDIParam;
456
457 // If current ddi param is same with the previous, don't dump into file.
458 bDumpToFile = VpCmpDDIDumpParam(pCurDDIParam, pPreDDIParam);
459 if (bDumpToFile)
460 {
461 return VA_STATUS_SUCCESS;
462 }
463
464 fpLog = nullptr;
465 pMediaCtx = DdiMedia_GetMediaContext(pVaDrvCtx);
466 pRenderParams = pVpCtx->pVpHalRenderParams;
467 pMediaSrcSurf = nullptr;
468
469 gettimeofday(&time, nullptr);
470 suffix = ((long)time.tv_sec) * 1000 + (long)time.tv_usec / 1000;
471
472 if (pVpCtx->fpDumpFile == nullptr)
473 {
474 const char * pTraceName = "VPDDI_TRACE";
475 if (VpParseLogConfig(pTraceName, &env_value[0]) == 0)
476 {
477 int32_t tmp = strnlen(env_value, sizeof(env_value));
478 int32_t left = sizeof(env_value) - tmp;
479 snprintf(env_value+tmp, left, "%ld", suffix);
480 MosUtilities::MosSecureFileOpen(&pVpCtx->fpDumpFile, env_value, "w");
481 }
482 }
483 fpLog = pVpCtx->fpDumpFile;
484
485 if (fpLog)
486 {
487 fprintf(fpLog, "\t-------------------------------\n");
488 fprintf(fpLog, "\tTargetFormat Count = %d\n", pRenderParams->uDstCount);
489 for (uint32_t uDstIndex = 0; uDstIndex < pRenderParams->uDstCount; uDstIndex++)
490 {
491 fprintf(fpLog, "\tTargetFormat = %d\n", (int32_t)(pCurDDIParam->TargetFormat[uDstIndex]));
492 }
493 for (uint32_t uSurfIndex = 0; uSurfIndex < pRenderParams->uSrcCount; uSurfIndex++)
494 {
495 VAProcPipelineParameterBuffer *p = pCurDDIParam->pPipelineParamBuffers[uSurfIndex];
496 if (p)
497 {
498 fprintf(fpLog, "\t--VAProcPipelineParameterBuffer\n");
499 fprintf(fpLog, "\t surface = 0x%08x\n", p->surface);
500 fprintf(fpLog, "\t Format = %d\n", (int32_t)(pCurDDIParam->SrcFormat[uSurfIndex]));
501
502 if (p->surface_region)
503 {
504 fprintf(fpLog, "\t surface_region\n");
505 fprintf(fpLog, "\t x = %d\n", p->surface_region->x);
506 fprintf(fpLog, "\t y = %d\n", p->surface_region->y);
507 fprintf(fpLog, "\t width = %d\n", p->surface_region->width);
508 fprintf(fpLog, "\t height = %d\n", p->surface_region->height);
509 }
510
511 fprintf(fpLog, "\t surface_color_standard = %d\n", p->surface_color_standard);
512
513 if (p->output_region)
514 {
515 fprintf(fpLog, "\t output_region\n");
516 fprintf(fpLog, "\t x = %d\n", p->output_region->x);
517 fprintf(fpLog, "\t y = %d\n", p->output_region->y);
518 fprintf(fpLog, "\t width = %d\n", p->output_region->width);
519 fprintf(fpLog, "\t height = %d\n", p->output_region->height);
520 }
521
522 fprintf(fpLog, "\t output_background_color = 0x%08x\n", p->output_background_color);
523 fprintf(fpLog, "\t output_color_standard = %d\n", p->output_color_standard);
524 fprintf(fpLog, "\t pipeline_flags = 0x%08x\n", p->pipeline_flags);
525 fprintf(fpLog, "\t filter_flags = 0x%08x\n", p->filter_flags);
526
527 VpDumpProcFiltersParameterBuffer(fpLog, pVaDrvCtx, p->filters, p->num_filters);
528
529 fprintf(fpLog, "\t num_forward_references = 0x%08x\n", p->num_forward_references);
530
531 if (p->num_forward_references)
532 {
533 fprintf(fpLog, "\t forward_references\n");
534
535 if (p->forward_references)
536 {
537 /* only dump the first 5 forward references */
538 for (int32_t i = 0; i < p->num_forward_references && i < 5; i++)
539 {
540 fprintf(fpLog, "\t forward_references[%d] = 0x%08x\n", i, p->forward_references[i]);
541 }
542 }
543 else
544 {
545 for (int32_t i = 0; i < p->num_forward_references && i < 5; i++)
546 {
547 fprintf(fpLog, "\t forward_references[%d] = (nullptr)\n", i);
548 }
549 }
550 }
551
552 fprintf(fpLog, "\t num_backward_references = 0x%08x\n", p->num_backward_references);
553
554 if (p->num_backward_references)
555 {
556 fprintf(fpLog, "\t backward_references\n");
557
558 if (p->backward_references)
559 {
560 /* only dump the first 5 backward references */
561 for (int32_t i = 0; i < p->num_backward_references && i < 5; i++)
562 {
563 fprintf(fpLog, "\t backward_references[%d] = 0x%08x\n", i, p->backward_references[i]);
564 }
565 }
566 else
567 {
568 for (int32_t i = 0; i < p->num_backward_references && i < 5; i++)
569 {
570 fprintf(fpLog, "\t backward_references[%d] = (nullptr)\n", i);
571 }
572 }
573 }
574
575 fprintf(fpLog, "\t rotation_state = %d\n", p->rotation_state);
576 if (p->blend_state)
577 {
578 fprintf(fpLog, "\t blend_state\n");
579 fprintf(fpLog, "\t flags = %d\n", p->blend_state->flags);
580 fprintf(fpLog, "\t global_alpha = %f\n", p->blend_state->global_alpha);
581 fprintf(fpLog, "\t min_luma = %f\n", p->blend_state->min_luma);
582 fprintf(fpLog, "\t max_luma = %f\n", p->blend_state->max_luma);
583 }
584
585 fprintf(fpLog, "\t mirror_state = %d\n", p->mirror_state);
586 //fprintf(fpLog, "\t additional_outputs = 0x%08x\n", (unsigned int32_t)(*(p->additional_outputs)));
587 fprintf(fpLog, "\t num_additional_outputs = %d\n", p->num_additional_outputs);
588 #if (VA_MAJOR_VERSION < 1)
589 fprintf(fpLog, "\t chroma_siting_flag = %d\n", p->input_surface_flag & 0x3);
590 #else
591 fprintf(fpLog, "\t chroma_siting_flag = %d\n", p->input_color_properties.chroma_sample_location & 0x3);
592 #endif
593 }
594 }
595
596 MOS_SecureMemcpy(pPreDDIParam->SrcFormat, sizeof(MOS_FORMAT)*VPHAL_MAX_SOURCES, pCurDDIParam->SrcFormat, sizeof(MOS_FORMAT)*VPHAL_MAX_SOURCES);
597 MOS_SecureMemcpy(pPreDDIParam->TargetFormat, sizeof(MOS_FORMAT)*VPHAL_MAX_TARGETS, pCurDDIParam->TargetFormat, sizeof(MOS_FORMAT)*VPHAL_MAX_TARGETS);
598 for (uint32_t uSurfIndex = 0; uSurfIndex < VPHAL_MAX_SOURCES; uSurfIndex++)
599 {
600 MOS_SecureMemcpy(pPreDDIParam->pPipelineParamBuffers[uSurfIndex], sizeof(VAProcPipelineParameterBuffer), pCurDDIParam->pPipelineParamBuffers[uSurfIndex], sizeof(VAProcPipelineParameterBuffer));
601 }
602 }
603
604 return VA_STATUS_SUCCESS;
605 }
606
607 #endif //(_DEBUG || _RELEASE_INTERNAL)
608
609 //!
610 //! \brief initialize configuration values for Android
611 //! \param [in] pConfigValues
612 //! vp config values
613 //!
VpConfigValuesInit(PVP_CONFIG pConfigValues)614 void VpConfigValuesInit(
615 PVP_CONFIG pConfigValues)
616 {
617 if (nullptr == pConfigValues)
618 {
619 return;
620 }
621 pConfigValues->dwVpPath = 0;
622 pConfigValues->dwVpComponent = 0;
623 pConfigValues->dwReportedDeinterlaceMode = LIBVA_VP_CONFIG_NOT_REPORTED;
624 pConfigValues->dwReportedScalingMode = LIBVA_VP_CONFIG_NOT_REPORTED;
625 pConfigValues->dwReportedOutputPipeMode = LIBVA_VP_CONFIG_NOT_REPORTED;
626 pConfigValues->dwReportedVEFeatureInUse = LIBVA_VP_CONFIG_NOT_REPORTED;
627 pConfigValues->dwVPMMCInUseReported = LIBVA_VP_CONFIG_NOT_REPORTED;
628 pConfigValues->dwRTCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED;
629 pConfigValues->dwRTCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED;
630 pConfigValues->dwCapturePipeInUseReported = LIBVA_VP_CONFIG_NOT_REPORTED;
631 pConfigValues->dwReportedCompositionMode = LIBVA_VP_CONFIG_NOT_REPORTED;
632 pConfigValues->dwReportedHdrMode = LIBVA_VP_CONFIG_NOT_REPORTED;
633
634 pConfigValues->dwFFDICompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED;
635 pConfigValues->dwFFDICompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED;
636 pConfigValues->dwFFDNCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED;
637 pConfigValues->dwFFDNCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED;
638 pConfigValues->dwSTMMCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED;
639 pConfigValues->dwSTMMCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED;
640 pConfigValues->dwScalerCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED;
641 pConfigValues->dwScalerCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED;
642 pConfigValues->dwPrimaryCompressibleReported = LIBVA_VP_CONFIG_NOT_REPORTED;
643 pConfigValues->dwPrimaryCompressModeReported = LIBVA_VP_CONFIG_NOT_REPORTED;
644 pConfigValues->dwRTCacheSettingReported = LIBVA_VP_CONFIG_NOT_REPORTED;
645 #if (_DEBUG || _RELEASE_INTERNAL)
646 pConfigValues->dwRTOldCacheSettingReported = LIBVA_VP_CONFIG_NOT_REPORTED;
647 #endif
648 pConfigValues->dwReportedVeboxScalability = LIBVA_VP_CONFIG_NOT_REPORTED;
649 pConfigValues->dwReportedVPApogeios = LIBVA_VP_CONFIG_NOT_REPORTED;
650 }
651
VpFeatureReport(PVP_CONFIG pConfig,PDDI_VP_CONTEXT pVpCtx)652 void VpFeatureReport(
653 PVP_CONFIG pConfig,
654 PDDI_VP_CONTEXT pVpCtx)
655 {
656 MediaUserSettingSharedPtr userSettingPtr = pVpCtx ? pVpCtx->MosDrvCtx.m_userSettingPtr : nullptr;
657 ReportUserSetting(
658 userSettingPtr,
659 __VPHAL_VEBOX_OUTPUTPIPE_MODE,
660 pConfig->dwCurrentOutputPipeMode,
661 MediaUserSetting::Group::Sequence);
662
663 ReportUserSetting(
664 userSettingPtr,
665 __VPHAL_VEBOX_FEATURE_INUSE,
666 pConfig->dwCurrentVEFeatureInUse,
667 MediaUserSetting::Group::Sequence);
668
669 #if (_DEBUG || _RELEASE_INTERNAL)
670 ReportUserSettingForDebug(
671 userSettingPtr,
672 __VPHAL_VEBOX_HDR_MODE,
673 pConfig->dwCurrentHdrMode,
674 MediaUserSetting::Group::Sequence);
675
676 #ifdef _MMC_SUPPORTED
677 ReportUserSettingForDebug(
678 userSettingPtr,
679 __VPHAL_MMC_ENABLE,
680 pConfig->dwVPMMCInUse,
681 MediaUserSetting::Group::Sequence);
682 //VP Primary Surface Compress Mode Report
683 ReportUserSettingForDebug(
684 userSettingPtr,
685 __VPHAL_PRIMARY_MMC_COMPRESSMODE,
686 pConfig->dwPrimaryCompressMode,
687 MediaUserSetting::Group::Sequence);
688 //VP Primary Surface Compressible
689 ReportUserSettingForDebug(
690 userSettingPtr,
691 __VPHAL_PRIMARY_MMC_COMPRESSIBLE,
692 pConfig->dwPrimaryCompressible,
693 MediaUserSetting::Group::Sequence);
694 //VP RT Compress Mode
695 ReportUserSettingForDebug(
696 userSettingPtr,
697 __VPHAL_RT_MMC_COMPRESSMODE,
698 pConfig->dwRTCompressMode,
699 MediaUserSetting::Group::Sequence);
700 //VP RT Compressible
701 ReportUserSettingForDebug(
702 userSettingPtr,
703 __VPHAL_RT_MMC_COMPRESSIBLE,
704 pConfig->dwRTCompressible,
705 MediaUserSetting::Group::Sequence);
706 //VP RT Cache Usage
707 ReportUserSettingForDebug(
708 userSettingPtr,
709 __VPHAL_RT_Cache_Setting,
710 pConfig->dwRTCacheSetting,
711 MediaUserSetting::Group::Sequence);
712 //VP RT Old Cache Usage
713 ReportUserSettingForDebug(
714 userSettingPtr,
715 __VPHAL_RT_Old_Cache_Setting,
716 pConfig->dwRTOldCacheSetting,
717 MediaUserSetting::Group::Sequence);
718 #endif
719 #endif //(_DEBUG || _RELEASE_INTERNAL)
720
721 if (pConfig->dwCurrentVeboxScalability != pConfig->dwReportedVeboxScalability)
722 {
723 ReportUserSetting(
724 userSettingPtr,
725 __MEDIA_USER_FEATURE_VALUE_ENABLE_VEBOX_SCALABILITY_MODE,
726 pConfig->dwCurrentVeboxScalability,
727 MediaUserSetting::Group::Device);
728
729 pConfig->dwReportedVeboxScalability = pConfig->dwCurrentVeboxScalability;
730 }
731
732 if (pConfig->dwCurrentVPApogeios != pConfig->dwReportedVPApogeios)
733 {
734 ReportUserSetting(
735 userSettingPtr,
736 __MEDIA_USER_FEATURE_VALUE_VPP_APOGEIOS_ENABLE,
737 pConfig->dwCurrentVPApogeios,
738 MediaUserSetting::Group::Sequence);
739
740 pConfig->dwReportedVPApogeios = pConfig->dwCurrentVPApogeios;
741 }
742 }
743
VpReportFeatureMode(PDDI_VP_CONTEXT pVpCtx)744 VAStatus VpReportFeatureMode(PDDI_VP_CONTEXT pVpCtx)
745 {
746 VP_CONFIG ConfigValues = {};
747
748 DDI_CHK_NULL(pVpCtx, "Null pVpCtx.", VA_STATUS_ERROR_INVALID_CONTEXT);
749 DDI_CHK_NULL(pVpCtx->pVpHal, "Null pVpHal.", VA_STATUS_ERROR_INVALID_PARAMETER);
750
751 VpConfigValuesInit(&ConfigValues);
752
753 VpHal_DdiReportFeatureMode(pVpCtx->pVpHal, &ConfigValues);
754
755 VpFeatureReport(&ConfigValues, pVpCtx);
756
757 return VA_STATUS_SUCCESS;
758 }
759
760