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