xref: /aosp_15_r20/external/mesa3d/src/gallium/frontends/va/display.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /**************************************************************************
2  *
3  * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
4  * Copyright 2014 Advanced Micro Devices, Inc.
5  * All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sub license, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the
16  * next paragraph) shall be included in all copies or substantial portions
17  * of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22  * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
23  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  *
27  **************************************************************************/
28 
29 #include "vl/vl_winsys.h"
30 #include "va_private.h"
31 
32 VAStatus
vlVaQueryDisplayAttributes(VADriverContextP ctx,VADisplayAttribute * attr_list,int * num_attributes)33 vlVaQueryDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int *num_attributes)
34 {
35    if (!ctx)
36       return VA_STATUS_ERROR_INVALID_CONTEXT;
37 
38    if (ctx->max_display_attributes <= 0)
39       return VA_STATUS_ERROR_UNIMPLEMENTED;
40 
41    if (!(attr_list && num_attributes))
42       return VA_STATUS_ERROR_INVALID_PARAMETER;
43 
44    *num_attributes = 0;
45 
46 #if VA_CHECK_VERSION(1, 15, 0)
47    attr_list->type = VADisplayPCIID;
48    (*num_attributes)++;
49 #endif
50 
51    return vlVaGetDisplayAttributes(ctx, attr_list, *num_attributes);
52 }
53 
54 VAStatus
vlVaGetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute * attr_list,int num_attributes)55 vlVaGetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes)
56 {
57    struct pipe_screen *pscreen;
58 
59    if (!ctx)
60       return VA_STATUS_ERROR_INVALID_CONTEXT;
61 
62    if (ctx->max_display_attributes <= 0)
63       return VA_STATUS_ERROR_UNIMPLEMENTED;
64 
65    pscreen = VL_VA_PSCREEN(ctx);
66 
67    if (!pscreen)
68       return VA_STATUS_ERROR_INVALID_CONTEXT;
69 
70    if (!attr_list)
71       return VA_STATUS_ERROR_INVALID_PARAMETER;
72 
73    for (unsigned i = 0; i < num_attributes; i++) {
74       switch (attr_list->type) {
75 #if VA_CHECK_VERSION(1, 15, 0)
76       case VADisplayPCIID: {
77          uint32_t vendor_id = pscreen->get_param(pscreen, PIPE_CAP_VENDOR_ID);
78          uint32_t device_id = pscreen->get_param(pscreen, PIPE_CAP_DEVICE_ID);
79          attr_list->min_value = attr_list->max_value = attr_list->value = (vendor_id << 16) | (device_id & 0xFFFF);
80          attr_list->flags = VA_DISPLAY_ATTRIB_GETTABLE;
81          break;
82       }
83 #endif
84       default:
85          /* Only attributes returned with VA_DISPLAY_ATTRIB_GETTABLE set in the "flags" field
86           * from vaQueryDisplayAttributes() can have their values retrieved.
87           */
88          break;
89       }
90       attr_list++;
91    }
92 
93    return VA_STATUS_SUCCESS;
94 }
95 
96 VAStatus
vlVaSetDisplayAttributes(VADriverContextP ctx,VADisplayAttribute * attr_list,int num_attributes)97 vlVaSetDisplayAttributes(VADriverContextP ctx, VADisplayAttribute *attr_list, int num_attributes)
98 {
99    if (!ctx)
100       return VA_STATUS_ERROR_INVALID_CONTEXT;
101 
102    return VA_STATUS_ERROR_UNIMPLEMENTED;
103 }
104