1 /*
2  * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
3  * Copyright (c) Imagination Technologies Limited, UK
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sub license, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial portions
15  * of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  * Authors:
26  *    Waldo Bastian <waldo.bastian@intel.com>
27  */
28 
29 #ifndef _PSB_SURFACE_H_
30 #define _PSB_SURFACE_H_
31 
32 #include <va/va.h>
33 #include <va/va_tpi.h>
34 #include "psb_buffer.h"
35 //#include "xf86mm.h"
36 
37 /* MSVDX specific */
38 typedef enum {
39     STRIDE_352  = 0,
40     STRIDE_720  = 1,
41     STRIDE_1280 = 2,
42     STRIDE_1920 = 3,
43     STRIDE_512  = 4,
44     STRIDE_1024 = 5,
45     STRIDE_2048 = 6,
46     STRIDE_4096 = 7,
47     STRIDE_NA,
48     STRIDE_UNDEFINED,
49 } psb_surface_stride_t;
50 
51 typedef enum {
52     IS_PROTECTED = 0x1,
53     IS_ROTATED   = 0x2,
54 } psb_surface_flags_t;
55 
56 typedef struct psb_surface_s *psb_surface_p;
57 
58 struct psb_surface_s {
59     struct psb_buffer_s buf;
60     struct psb_buffer_s *in_loop_buf;
61     struct psb_buffer_s *ref_buf;
62     psb_surface_stride_t stride_mode;
63     unsigned int stride;
64     unsigned int luma_offset;
65     unsigned int chroma_offset;
66     /* Used to store driver private data, e.g. decoder specific intermediate status data
67      * extra_info[0-3]: used for decode
68      * extra_info[4]: surface fourcc
69      * extra_info[5]: surface skippeded or not for encode, rotate info for decode
70      * extra_info[6]: mfld protected surface
71      * extra_info[7]: linear or tiled
72      * extra_info[8]: the fourcc set by application
73      */
74     int extra_info[9];
75     int size;
76     unsigned int bc_buffer;
77     void *handle;
78 };
79 
80 /*
81  * Create surface
82  */
83 VAStatus psb_surface_create(psb_driver_data_p driver_data,
84                             int width, int height, int fourcc, unsigned int flags,
85                             psb_surface_p psb_surface /* out */
86                            );
87 
88 
89 #define SET_SURFACE_INFO_rotate(psb_surface, rotate) psb_surface->extra_info[5] = (uint32_t) rotate;
90 #define GET_SURFACE_INFO_rotate(psb_surface) ((int) psb_surface->extra_info[5])
91 #define GET_SURFACE_INFO_protect(psb_surface) ((int) psb_surface->extra_info[6])
92 #define SET_SURFACE_INFO_protect(psb_surface, protect) (psb_surface->extra_info[6] = protect)
93 #define SET_SURFACE_INFO_tiling(psb_surface, tiling) psb_surface->extra_info[7] = (uint32_t) tiling;
94 #define GET_SURFACE_INFO_tiling(psb_surface) ((unsigned long) psb_surface->extra_info[7])
95 
96 
97 /*
98  * Temporarily map surface and set all chroma values of surface to 'chroma'
99  */
100 VAStatus psb_surface_set_chroma(psb_surface_p psb_surface, int chroma);
101 
102 /*
103  * Destroy surface
104  */
105 void psb_surface_destroy(psb_surface_p psb_surface);
106 
107 /*
108  * Wait for surface to become idle
109  */
110 VAStatus psb_surface_sync(psb_surface_p psb_surface);
111 
112 /*
113  * Return surface status
114  */
115 VAStatus psb_surface_query_status(psb_surface_p psb_surface, VASurfaceStatus *status);
116 
117 /*
118  * Set current displaying surface info to kernel
119  */
120 int psb_surface_set_displaying(psb_driver_data_p driver_data,
121                                int width, int height,
122                                psb_surface_p psb_surface);
123 
124 #endif /* _PSB_SURFACE_H_ */
125