1 /*
2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 */
25
26 #ifndef _PSB_SURFACE_ATTRIB_H_
27 #define _PSB_SURFACE_ATTRIB_H_
28
29 #include <va/va_tpi.h>
30 #include "psb_drv_video.h"
31 #include "psb_surface.h"
32
33 /*
34 * Create surface from virtual address
35 * flags: 0 indicates cache, PSB_USER_BUFFER_UNCACHED, PSB_USER_BUFFER_WC
36 */
37 VAStatus psb_surface_create_from_ub(
38 psb_driver_data_p driver_data,
39 int width, int height, int fourcc, VASurfaceAttributeTPI *graphic_buffers,
40 psb_surface_p psb_surface, /* out */
41 void *vaddr,
42 unsigned int flags
43 );
44
45 VAStatus psb_surface_create_for_userptr(
46 psb_driver_data_p driver_data,
47 int width, int height,
48 unsigned size, /* total buffer size need to be allocated */
49 unsigned int fourcc, /* expected fourcc */
50 unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
51 unsigned int chroma_u_stride, /* chroma stride */
52 unsigned int chroma_v_stride,
53 unsigned int luma_offset, /* could be 0 */
54 unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
55 unsigned int chroma_v_offset,
56 psb_surface_p psb_surface /* out */
57 );
58
59 VAStatus psb_surface_create_from_kbuf(
60 psb_driver_data_p driver_data,
61 int width, int height,
62 unsigned size, /* total buffer size need to be allocated */
63 unsigned int fourcc, /* expected fourcc */
64 int kbuf_handle, /*kernel handle */
65 unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
66 unsigned int chroma_u_stride, /* chroma stride */
67 unsigned int chroma_v_stride,
68 unsigned int luma_offset, /* could be 0 */
69 unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
70 unsigned int chroma_v_offset,
71 psb_surface_p psb_surface /* out */
72 );
73
74
75 VAStatus psb_surface_create_camera(
76 psb_driver_data_p driver_data,
77 int width, int height, int stride, int size,
78 psb_surface_p psb_surface, /* out */
79 int is_v4l2,
80 unsigned int id_or_ofs
81 );
82
83 /* id_or_ofs: it is frame ID or frame offset in camear device memory
84 * for CI frame: it it always frame offset currently
85 * for v4l2 buf: it is offset used in V4L2 buffer mmap
86 * user_ptr: virtual address of user buffer.
87 */
88 VAStatus psb_surface_create_camera_from_ub(
89 psb_driver_data_p driver_data,
90 int width, int height, int stride, int size,
91 psb_surface_p psb_surface, /* out */
92 int is_v4l2,
93 unsigned int id_or_ofs,
94 const unsigned long *user_ptr
95 );
96
97 #ifdef ANDROID
98
99 VAStatus psb_DestroySurfaceGralloc(object_surface_p obj_surface);
100
101
102 VAStatus psb_CreateSurfacesFromGralloc(
103 VADriverContextP ctx,
104 int width,
105 int height,
106 int format,
107 int num_surfaces,
108 VASurfaceID *surface_list, /* out */
109 PsbSurfaceAttributeTPI *attribute_tpi
110 );
111
112 #else
113
psb_DestroySurfaceGralloc(object_surface_p obj_surface)114 static VAStatus psb_DestroySurfaceGralloc(object_surface_p obj_surface)
115 {
116 return VA_STATUS_ERROR_INVALID_PARAMETER;
117 }
118
psb_CreateSurfacesFromGralloc(VADriverContextP ctx,int width,int height,int format,int num_surfaces,VASurfaceID * surface_list,PsbSurfaceAttributeTPI * attribute_tpi)119 static VAStatus psb_CreateSurfacesFromGralloc(
120 VADriverContextP ctx,
121 int width,
122 int height,
123 int format,
124 int num_surfaces,
125 VASurfaceID *surface_list, /* out */
126 PsbSurfaceAttributeTPI *attribute_tpi
127 )
128 {
129 return VA_STATUS_ERROR_INVALID_PARAMETER;
130 }
131
132 #endif
133
134
135 VAStatus psb_CreateSurfacesWithAttribute(
136 VADriverContextP ctx,
137 int width,
138 int height,
139 int format,
140 int num_surfaces,
141 VASurfaceID *surface_list, /* out */
142 VASurfaceAttributeTPI *attribute_tpi
143 );
144
145 #endif
146
147