• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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      */
73     int extra_info[8];
74     int size;
75     unsigned int bc_buffer;
76     void *handle;
77 };
78 
79 /*
80  * Create surface
81  */
82 VAStatus psb_surface_create(psb_driver_data_p driver_data,
83                             int width, int height, int fourcc, unsigned int flags,
84                             psb_surface_p psb_surface /* out */
85                            );
86 
87 
88 #define SET_SURFACE_INFO_rotate(psb_surface, rotate) psb_surface->extra_info[5] = (uint32_t) rotate;
89 #define GET_SURFACE_INFO_rotate(psb_surface) ((int) psb_surface->extra_info[5])
90 #define GET_SURFACE_INFO_protect(psb_surface) ((int) psb_surface->extra_info[6])
91 #define SET_SURFACE_INFO_protect(psb_surface, protect) (psb_surface->extra_info[6] = protect)
92 #define SET_SURFACE_INFO_tiling(psb_surface, tiling) psb_surface->extra_info[7] = (uint32_t) tiling;
93 #define GET_SURFACE_INFO_tiling(psb_surface) ((unsigned long) psb_surface->extra_info[7])
94 
95 
96 /*
97  * Temporarily map surface and set all chroma values of surface to 'chroma'
98  */
99 VAStatus psb_surface_set_chroma(psb_surface_p psb_surface, int chroma);
100 
101 /*
102  * Destroy surface
103  */
104 void psb_surface_destroy(psb_surface_p psb_surface);
105 
106 /*
107  * Wait for surface to become idle
108  */
109 VAStatus psb_surface_sync(psb_surface_p psb_surface);
110 
111 /*
112  * Return surface status
113  */
114 VAStatus psb_surface_query_status(psb_surface_p psb_surface, VASurfaceStatus *status);
115 
116 /*
117  * Set current displaying surface info to kernel
118  */
119 int psb_surface_set_displaying(psb_driver_data_p driver_data,
120                                int width, int height,
121                                psb_surface_p psb_surface);
122 
123 #endif /* _PSB_SURFACE_H_ */
124