1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
/*
* Copyright (c) 2011 Intel Corporation. All Rights Reserved.
* Copyright (c) Imagination Technologies Limited, UK
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Waldo Bastian <waldo.bastian@intel.com>
* Zeng Li <zeng.li@intel.com>
*
*/
#ifndef _PNW_CMDBUF_H_
#define _PNW_CMDBUF_H_
#include "psb_drv_video.h"
#include "psb_surface.h"
#include "psb_buffer.h"
#include "psb_drm.h"
#include <stdint.h>
#define MTX_CMDWORD_ID_MASK (0x7f)
#define MTX_CMDWORD_ID_SHIFT (0)
#define MTX_CMDWORD_CORE_MASK (0xff)
#define MTX_CMDWORD_CORE_SHIFT (8)
#define MTX_CMDWORD_COUNT_MASK (0x7fff)
#define MTX_CMDWORD_COUNT_SHIFT (16)
#define MTX_CMDWORD_INT_SHIFT (7)
#define MTX_CMDWORD_INT_MASK (1)
#define PNW_CMDBUF_START_PIC_IDX (0)
#define PNW_CMDBUF_SEQ_HEADER_IDX (1)
#define PNW_CMDBUF_PIC_HEADER_IDX (2)
struct pnw_cmdbuf_s {
struct psb_buffer_s buf;
unsigned int size;
/* Relocation records */
unsigned char *reloc_base;
struct drm_psb_reloc *reloc_idx;
/* CMD stream data */
int cmd_count;
unsigned char *cmd_base;
unsigned char *cmd_start;
uint32_t *cmd_idx;
uint32_t *cmd_idx_saved[3]; /* idx saved for dual-core adjustion */
/* all frames share one topaz param buffer which contains InParamBase
* AboveParam/BellowParam, and the buffer allocated when the context is created
*/
struct psb_buffer_s *topaz_in_params_I;
unsigned char *topaz_in_params_I_p;
struct psb_buffer_s *topaz_in_params_P;
unsigned char *topaz_in_params_P_p;
struct psb_buffer_s *topaz_below_params;
unsigned char *topaz_below_params_p;
/* Every frame has its own PIC_PARAMS, SLICE_PARAMS and HEADER mem
*/
/* PicParams: */
struct psb_buffer_s pic_params;
unsigned char *pic_params_p;
/* SeqHeaderMem PicHeaderMem EOSeqHeaderMem EOStreamHeaderMem SliceHeaderMem[MAX_SLICES_PER_PICTURE]*/
struct psb_buffer_s header_mem;
unsigned char *header_mem_p;
/*SliceParams[MAX_SLICES_PER_PICTURE] */
struct psb_buffer_s slice_params;
unsigned char *slice_params_p;
/* AboveParams[MAX_TOPAZ_CORES]; */
struct psb_buffer_s *topaz_above_params;
unsigned char *topaz_above_params_p;
/* Referenced buffers */
psb_buffer_p *buffer_refs;
int buffer_refs_count;
int buffer_refs_allocated;
};
typedef struct pnw_cmdbuf_s *pnw_cmdbuf_p;
/*
* Create command buffer
*/
VAStatus pnw_cmdbuf_create(object_context_p obj_context,
psb_driver_data_p driver_data,
pnw_cmdbuf_p cmdbuf
);
/*
* Destroy buffer
*/
void pnw_cmdbuf_destroy(pnw_cmdbuf_p cmdbuf);
/*
* Reset buffer & map
*
* Returns 0 on success
*/
int pnw_cmdbuf_reset(pnw_cmdbuf_p cmdbuf);
/*
* Unmap buffer
*
* Returns 0 on success
*/
int pnw_cmdbuf_unmap(pnw_cmdbuf_p cmdbuf);
/*
* Reference an addtional buffer "buf" in the command stream
* Returns a reference index that can be used to refer to "buf" in
* relocation records, on error -1 is returned.
*/
int pnw_cmdbuf_buffer_ref(pnw_cmdbuf_p cmdbuf, psb_buffer_p buf);
/* Creates a relocation record for a DWORD in the mapped "cmdbuf" at address
* "addr_in_cmdbuf"
* The relocation is based on the device virtual address of "ref_buffer"
* "buf_offset" is be added to the device virtual address, and the sum is then
* right shifted with "align_shift".
* "mask" determines which bits of the target DWORD will be updated with the so
* constructed address. The remaining bits will be filled with bits from "background".
*/
void pnw_cmdbuf_add_relocation(pnw_cmdbuf_p cmdbuf,
uint32_t *addr_in_dst_buffer,/*addr of dst_buffer for the DWORD*/
psb_buffer_p ref_buffer,
uint32_t buf_offset,
uint32_t mask,
uint32_t background,
uint32_t align_shift,
uint32_t dst_buffer, /*Index of the list refered by cmdbuf->buffer_refs */
uint32_t *start_of_dst_buffer);
#define RELOC_CMDBUF_PNW(dest, offset, buf) pnw_cmdbuf_add_relocation(cmdbuf, (uint32_t*)(dest), buf, offset, 0XFFFFFFFF, 0, 0, 0, (uint32_t *)cmdbuf->cmd_start)
/* do relocation in PIC_PARAMS: src/dst Y/UV base, InParamsBase, CodeBase, BellowParamsBase, AboveParamsBase */
#define RELOC_PIC_PARAMS_PNW(dest, offset, buf) pnw_cmdbuf_add_relocation(cmdbuf, (uint32_t*)(dest), buf, offset, 0XFFFFFFFF, 0, 0, 1, (uint32_t *)cmdbuf->pic_params_p)
/* do relocation in SLICE_PARAMS: reference Y/UV base,CodedData */
#define RELOC_SLICE_PARAMS_PNW(dest, offset, buf) pnw_cmdbuf_add_relocation(cmdbuf, (uint32_t*)(dest), buf, offset, 0XFFFFFFFF, 0, 0, 2,(uint32_t *)cmdbuf->slice_params_p)
/* operation number is inserted by DRM */
/*
#define pnw_cmdbuf_insert_command(cmdbuf,cmdhdr,size,hint) \
do { *cmdbuf->cmd_idx++ = ((cmdhdr) << 1) | ((size)<<8) | ((hint)<<16); } while(0)
*/
#define pnw_cmdbuf_insert_command_param(param) \
do { *cmdbuf->cmd_idx++ = param; } while(0)
#define pnw_cmdbuf_insert_reg_write(base, offset, value) \
do { *cmdbuf->cmd_idx++ = base + offset; *cmdbuf->cmd_idx++ = value; count++; } while(0)
void pnw_cmdbuf_insert_command_package(object_context_p obj_context,
int32_t core,
uint32_t cmd_id,
psb_buffer_p command_data,
uint32_t offset);
/*
* Advances "obj_context" to the next cmdbuf
*
* Returns 0 on success
*/
int pnw_context_get_next_cmdbuf(object_context_p obj_context);
/*
* Submits the current cmdbuf
*
* Returns 0 on success
*/
int pnw_context_submit_cmdbuf(object_context_p obj_context);
/*
* Get a encode surface FRAMESKIP flag, and store it into frame_skip argument
*
* Returns 0 on success
*/
int pnw_surface_get_frameskip(psb_driver_data_p driver_data, psb_surface_p psb_surface, int *frame_skip);
/*
* Flushes the pending cmdbuf
*
* Return 0 on success
*/
int pnw_context_flush_cmdbuf(object_context_p obj_context);
/*
* Get the number of paralled cores used.
*
* Return the number of paralled cores used.
*/
int pnw_get_parallel_core_number(object_context_p obj_context);
#endif /* _PNW_CMDBUF_H_ */
|