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 */
37VAStatus 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    int fd,
43    unsigned int flags
44);
45
46VAStatus psb_surface_create_for_userptr(
47    psb_driver_data_p driver_data,
48    int width, int height,
49    unsigned size, /* total buffer size need to be allocated */
50    unsigned int fourcc, /* expected fourcc */
51    unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
52    unsigned int chroma_u_stride, /* chroma stride */
53    unsigned int chroma_v_stride,
54    unsigned int luma_offset, /* could be 0 */
55    unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
56    unsigned int chroma_v_offset,
57    psb_surface_p psb_surface /* out */
58);
59
60VAStatus psb_surface_create_from_kbuf(
61    psb_driver_data_p driver_data,
62    int width, int height,
63    unsigned size, /* total buffer size need to be allocated */
64    unsigned int fourcc, /* expected fourcc */
65    int kbuf_handle, /*kernel handle */
66    unsigned int luma_stride, /* luma stride, could be width aligned with a special value */
67    unsigned int chroma_u_stride, /* chroma stride */
68    unsigned int chroma_v_stride,
69    unsigned int luma_offset, /* could be 0 */
70    unsigned int chroma_u_offset, /* UV offset from the beginning of the memory */
71    unsigned int chroma_v_offset,
72    psb_surface_p psb_surface /* out */
73);
74
75
76VAStatus psb_surface_create_camera(
77    psb_driver_data_p driver_data,
78    int width, int height, int stride, int size,
79    psb_surface_p psb_surface, /* out */
80    int is_v4l2,
81    unsigned int id_or_ofs
82);
83
84/* id_or_ofs: it is frame ID or frame offset in camear device memory
85 *     for CI frame: it it always frame offset currently
86 *     for v4l2 buf: it is offset used in V4L2 buffer mmap
87 * user_ptr: virtual address of user buffer.
88 */
89VAStatus psb_surface_create_camera_from_ub(
90    psb_driver_data_p driver_data,
91    int width, int height, int stride, int size,
92    psb_surface_p psb_surface, /* out */
93    int is_v4l2,
94    unsigned int id_or_ofs,
95    const unsigned long *user_ptr
96);
97
98#ifdef ANDROID
99
100VAStatus psb_DestroySurfaceGralloc(object_surface_p obj_surface);
101
102
103VAStatus psb_CreateSurfacesFromGralloc(
104    VADriverContextP ctx,
105    int width,
106    int height,
107    int format,
108    int num_surfaces,
109    VASurfaceID *surface_list,        /* out */
110    PsbSurfaceAttributeTPI *attribute_tpi
111);
112
113#else
114
115static VAStatus psb_DestroySurfaceGralloc(object_surface_p obj_surface)
116{
117    return VA_STATUS_ERROR_INVALID_PARAMETER;
118}
119
120static VAStatus psb_CreateSurfacesFromGralloc(
121    VADriverContextP ctx,
122    int width,
123    int height,
124    int format,
125    int num_surfaces,
126    VASurfaceID *surface_list,        /* out */
127    PsbSurfaceAttributeTPI *attribute_tpi
128)
129{
130    return VA_STATUS_ERROR_INVALID_PARAMETER;
131}
132
133#endif
134
135
136VAStatus psb_CreateSurfacesWithAttribute(
137    VADriverContextP ctx,
138    int width,
139    int height,
140    int format,
141    int num_surfaces,
142    VASurfaceID *surface_list,        /* out */
143    VASurfaceAttributeTPI *attribute_tpi
144);
145
146#endif
147
148