st/va: skeleton VAAPI state tracker
[mesa.git] / src / gallium / state_trackers / va / context.c
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 "pipe/p_screen.h"
30 #include "pipe/p_video_codec.h"
31
32 #include "util/u_memory.h"
33 #include "vl/vl_winsys.h"
34
35 #include "va_private.h"
36
37 static struct VADriverVTable vtable =
38 {
39 &vlVaTerminate,
40 &vlVaQueryConfigProfiles,
41 &vlVaQueryConfigEntrypoints,
42 &vlVaGetConfigAttributes,
43 &vlVaCreateConfig,
44 &vlVaDestroyConfig,
45 &vlVaQueryConfigAttributes,
46 &vlVaCreateSurfaces,
47 &vlVaDestroySurfaces,
48 &vlVaCreateContext,
49 &vlVaDestroyContext,
50 &vlVaCreateBuffer,
51 &vlVaBufferSetNumElements,
52 &vlVaMapBuffer,
53 &vlVaUnmapBuffer,
54 &vlVaDestroyBuffer,
55 &vlVaBeginPicture,
56 &vlVaRenderPicture,
57 &vlVaEndPicture,
58 &vlVaSyncSurface,
59 &vlVaQuerySurfaceStatus,
60 &vlVaQuerySurfaceError,
61 &vlVaPutSurface,
62 &vlVaQueryImageFormats,
63 &vlVaCreateImage,
64 &vlVaDeriveImage,
65 &vlVaDestroyImage,
66 &vlVaSetImagePalette,
67 &vlVaGetImage,
68 &vlVaPutImage,
69 &vlVaQuerySubpictureFormats,
70 &vlVaCreateSubpicture,
71 &vlVaDestroySubpicture,
72 &vlVaSubpictureImage,
73 &vlVaSetSubpictureChromakey,
74 &vlVaSetSubpictureGlobalAlpha,
75 &vlVaAssociateSubpicture,
76 &vlVaDeassociateSubpicture,
77 &vlVaQueryDisplayAttributes,
78 &vlVaGetDisplayAttributes,
79 &vlVaSetDisplayAttributes,
80 &vlVaBufferInfo,
81 &vlVaLockSurface,
82 &vlVaUnlockSurface
83 };
84
85 PUBLIC VAStatus
86 VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
87 {
88 vlVaDriver *drv;
89
90 if (!ctx)
91 return VA_STATUS_ERROR_INVALID_CONTEXT;
92
93 drv = CALLOC(1, sizeof(vlVaDriver));
94 if (!drv)
95 return VA_STATUS_ERROR_ALLOCATION_FAILED;
96
97 drv->vscreen = vl_screen_create(ctx->native_dpy, ctx->x11_screen);
98 if (!drv->vscreen) {
99 FREE(drv);
100 return VA_STATUS_ERROR_ALLOCATION_FAILED;
101 }
102
103 ctx->pDriverData = (void *)drv;
104 ctx->version_major = 0;
105 ctx->version_minor = 1;
106 *ctx->vtable = vtable;
107 ctx->max_profiles = 1;
108 ctx->max_entrypoints = 1;
109 ctx->max_attributes = 1;
110 ctx->max_image_formats = 1;
111 ctx->max_subpic_formats = 1;
112 ctx->max_display_attributes = 1;
113 ctx->str_vendor = "mesa gallium vaapi";
114
115 return VA_STATUS_SUCCESS;
116 }
117
118 VAStatus
119 vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
120 int picture_height, int flag, VASurfaceID *render_targets,
121 int num_render_targets, VAContextID *conext)
122 {
123 if (!ctx)
124 return VA_STATUS_ERROR_INVALID_CONTEXT;
125
126 return VA_STATUS_ERROR_UNIMPLEMENTED;
127 }
128
129 VAStatus
130 vlVaDestroyContext(VADriverContextP ctx, VAContextID context)
131 {
132 if (!ctx)
133 return VA_STATUS_ERROR_INVALID_CONTEXT;
134
135 return VA_STATUS_ERROR_UNIMPLEMENTED;
136 }
137
138 VAStatus
139 vlVaTerminate(VADriverContextP ctx)
140 {
141 vlVaDriver *drv;
142
143 if (!ctx)
144 return VA_STATUS_ERROR_INVALID_CONTEXT;
145
146 drv = ctx->pDriverData;
147 vl_screen_destroy(drv->vscreen);
148 FREE(drv);
149
150 return VA_STATUS_SUCCESS;
151 }