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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
#include <stdio.h>
#include <stdarg.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <signal.h>
#include <unistd.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <vs4l.h>
#include <lib/vpul-errno.h>
#include "test-client.h"
#include "test-list.h"
#include "test-util.h"
#define EX1_DRAM_IN_BASE_ADDR_OFS 0x00000000
#define EX1_DRAM_OUT_BASE_ADDR_OFS 0x01000000
/* EXAMPLE 1: multiple sub chains and advanced PU's connection.
*
* TASK: 3 vertices (start -> 1 Process -> end).
* PROCESS 1: the process has 2 HW sub-chains. on of the second chain inputs is
* chain 1 output. (Chain 1 implement 2' compliment)
* SUBCHAIN 1: 3 PU (DMA IN -> SALB (inv) -> SALB (+1) -> DMA OUT)
* DATA: 0xFFFB 0x0004 0x0005
* SUBCHAIN 2: 5 PU (DMA IN -> SALB (sub) -> CALB (invert) -> DMA OUT).
* DMA_IN ->
* 0x0003 0x0002 0xFFFD
* 2+3 IO (fixed DRAM).
*/
const __u32 get_task_ds_size_params_ex1[4] = {3, 2, 9, 0};
const __u32 subchains_for_vertices_ex1[3] = {0, 2, 0};
const __u32 pus_for_subchains_ex1[2] = {4, 5};
#define EX1_IN_WIDTH 32
#define EX1_IN_HEIGHT 32
#define EX1_PIXEL_BYTES 2
#define EX1_IMG_DRAM_SIZE (EX1_IN_HEIGHT * EX1_IN_WIDTH * EX1_PIXEL_BYTES)
#define EX1_OUT_DRAM_SIZE EX1_IMG_DRAM_SIZE
#define EX1_DRAM_IN_SIZE (2 * EX1_IMG_DRAM_SIZE) /* two images */
#define EX1_EXT_IN_MEM_ADDRESSES 2
#define EX1_EXT_TMP_MEM_ADDRESSES 1
#define EX1_EXT_OUT_MEM_ADDRESSES 1
const __u32 EX1_EXT_IN_MEM_ADDR[] = {
EX1_DRAM_IN_BASE_ADDR_OFS,
EX1_DRAM_IN_BASE_ADDR_OFS + 1 * EX1_IMG_DRAM_SIZE};
const __u32 EX1_EXT_TMP_MEM_ADDR[] = {
EX1_DRAM_IN_BASE_ADDR_OFS + 2 * EX1_IMG_DRAM_SIZE};
const __u32 EX1_EXT_OUT_MEM_ADDR[] = {
EX1_DRAM_OUT_BASE_ADDR_OFS};
#define SC1_IN0_DATA -5
#define SC2_IN1_DATA 3
#define EXP_OUT_DATA 0xFFFD
enum ex1_process1_sizes {
EX1_P1_SIZES_IN_OUT = 0,
EX1_P1_SIZES_ALL
};
static __u32 vpu_example1_get_task_ds_size(void)
{
return vpu_translator_get_task_ds_size(
get_task_ds_size_params_ex1[0],
get_task_ds_size_params_ex1[1],
get_task_ds_size_params_ex1[2],
get_task_ds_size_params_ex1[3]
);
}
static __s32 vpu_example1_create_task_ds(
struct vpul_task *task, __u32 size_allocated)
{
return vpu_translator_create_task_ds_from_array(task, size_allocated,
get_task_ds_size_params_ex1[0],
get_task_ds_size_params_ex1[1],
get_task_ds_size_params_ex1[2],
get_task_ds_size_params_ex1[3],
subchains_for_vertices_ex1,
pus_for_subchains_ex1
);
}
static void example1_fill_task_data_structure(struct vpul_task *task)
{
struct vpul_vertex *vertices = fst_vtx_ptr(task);
struct vpul_vertex *vtx;
struct vpul_subchain *sc;
struct vpul_pu *pu;
/* task */
task->id = 3;
task->priority = 1;
/* vertex 1 - Start */
vtx = &vertices[0];
vtx->vtype = VPUL_VERTEXT_START;
vtx->n_out_edges = 1;
vtx->out_edges[0].dst_vtx_idx = 1;
vtx->loop.type = VPU_LOOP_NONE;
/* Vertex 2 - Process */
vtx = &vertices[1];
vtx->vtype = VPUL_VERTEXT_PROC;
/* output edges */
vtx->n_out_edges = 1;
vtx->out_edges[0].dst_vtx_idx = 2;
/* loop */
vtx->loop.type = VPU_LOOP_NONE;
/* set process */
vtx->proc.io.n_sizes_op = EX1_P1_SIZES_ALL;
/* input/output types */
vtx->proc.io.n_inout_types = 4;
vtx->proc.io.inout_types[0].is_dynamic = 0;
vtx->proc.io.inout_types[0].n_insets_per_dynamic_roi = 0; /* fixed ROI */
vtx->proc.io.inout_types[0].roi_index = 0;
vtx->proc.io.inout_types[1].is_dynamic = 0;
vtx->proc.io.inout_types[1].n_insets_per_dynamic_roi = 0; /* fixed ROI */
vtx->proc.io.inout_types[1].roi_index = 1;
vtx->proc.io.inout_types[2].is_dynamic = 0;
vtx->proc.io.inout_types[2].n_insets_per_dynamic_roi = 0; /* fixed ROI */
vtx->proc.io.inout_types[2].roi_index = 2;
vtx->proc.io.inout_types[3].is_dynamic = 0;
vtx->proc.io.inout_types[3].n_insets_per_dynamic_roi = 0; /* fixed ROI */
vtx->proc.io.inout_types[3].roi_index = 3;
/* ROIs */
vtx->proc.io.n_fixed_map_roi = 4;
vtx->proc.io.n_dynamic_map_rois = 0;
vtx->proc.io.fixed_map_roi[0].memmap_idx = 0;
vtx->proc.io.fixed_map_roi[0].use_roi = 0;
vtx->proc.io.fixed_map_roi[1].memmap_idx = 1;
vtx->proc.io.fixed_map_roi[1].use_roi = 0;
vtx->proc.io.fixed_map_roi[2].memmap_idx = 2;
vtx->proc.io.fixed_map_roi[2].use_roi = 0;
vtx->proc.io.fixed_map_roi[3].memmap_idx = 3;
vtx->proc.io.fixed_map_roi[3].use_roi = 0;
/* memory IO: two for input, two for output */
task->n_external_mem_addresses = 4;
task->external_mem_addr[0] = EX1_EXT_IN_MEM_ADDR[0];
task->external_mem_addr[1] = EX1_EXT_IN_MEM_ADDR[1];
task->external_mem_addr[2] = EX1_EXT_TMP_MEM_ADDR[0];
task->external_mem_addr[3] = EX1_EXT_OUT_MEM_ADDR[0];
task->n_memmap_desc = 4;
task->memmap_desc[0].mtype = VPUL_MEM_EXTERNAL;
task->memmap_desc[0].index = 0;
task->memmap_desc[0].image_sizes.width = EX1_IN_HEIGHT;
task->memmap_desc[0].image_sizes.height = EX1_IN_WIDTH;
task->memmap_desc[0].image_sizes.line_offset =
EX1_IN_WIDTH * EX1_PIXEL_BYTES;
task->memmap_desc[0].image_sizes.pixel_bytes = EX1_PIXEL_BYTES;
task->memmap_desc[1] = task->memmap_desc[0];
task->memmap_desc[1].index = 1;
task->memmap_desc[2] = task->memmap_desc[0];
task->memmap_desc[2].index = 2;
task->memmap_desc[3] = task->memmap_desc[0];
task->memmap_desc[3].index = 3;
/* sizes */
vtx->proc.io.n_sizes_op = 1;
vtx->proc.io.sizes[0].op_ind = 0;
vtx->proc.io.sizes[0].type = VPUL_SIZEOP_INOUT;
vtx->proc.io.n_tiles = 0;
vtx->proc.io.n_presets_map_desc = 0;
vtx->proc.io.n_insets = 1;
/* process input loops */
vtx->proc.io.n_invocations_per_input_tile = 1;
/* set sub-chains */
sc = fst_vtx_sc_ptr(task, vtx);
sc[0].stype = VPUL_SUB_CH_HW;
sc[0].id = 0x1234;
/* set pus */
pu = fst_pu_ptr(task);
/****** subchain 1 *****/
/* DMA In */
pu->instance = VPU_PU_DMAIN0;
pu->op_type = VPUL_OP_DMA;
pu->n_in_connect = 0;
pu->n_out_connect = 1;
pu->n_mprbs = 0;
pu->in_size_idx = EX1_P1_SIZES_IN_OUT;
pu->out_size_idx = EX1_P1_SIZES_IN_OUT;
pu->params.dma.inout_index = 0;
pu->params.dma.offset_lines_inc = 0;/*TBD*/
pu++;
/* SALB: u16: OUT = !IN */
pu->instance = VPU_PU_SALB0;
pu->op_type = VPUL_OP_FULL_SALB;
pu->n_in_connect = 1;
pu->in_connect[0].pu_idx = 0;
pu->in_connect[0].s_pu_out_idx = 0;
pu->n_out_connect = 1;
pu->n_mprbs = 0;
pu->in_size_idx = EX1_P1_SIZES_IN_OUT;
pu->out_size_idx = EX1_P1_SIZES_IN_OUT;
memset(&pu->params.salb, 0, sizeof(struct vpul_pu_salb));
pu->params.salb.bits_in0 = 1;
pu->params.salb.bits_in1 = 1;
pu->params.salb.bits_out0 = 1;
pu->params.salb.operation_code = 7; /* Out0 = Mask ? ~ SI : SI */
pu++;
/* SALB: u16: +1 */
pu->instance = VPU_PU_SALB1;
pu->op_type = VPUL_OP_FULL_SALB;
pu->n_in_connect = 1;
pu->in_connect[0].pu_idx = 1;
pu->in_connect[0].s_pu_out_idx = 0;
pu->n_out_connect = 1;
pu->n_mprbs = 0;
pu->in_size_idx = EX1_P1_SIZES_IN_OUT;
pu->out_size_idx = EX1_P1_SIZES_IN_OUT;
memset(&pu->params.salb, 0, sizeof(struct vpul_pu_salb));
pu->params.salb.bits_in0 = 1;
pu->params.salb.bits_in1 = 1;
pu->params.salb.bits_out0 = 1;
pu->params.salb.operation_code = 9; /* Out0=Mask?(SI + ValMed):SI */
pu->params.salb.val_med_filler = 1; /*puls 1*/
pu++;
/* DMA out */
pu->instance = VPU_PU_DMAOT0;
pu->op_type = VPUL_OP_DMA;
pu->n_in_connect = 1;
pu->in_connect[0].pu_idx = 2;
pu->in_connect[0].s_pu_out_idx = 0;
pu->n_out_connect = 0;
pu->n_mprbs = 0;
pu->in_size_idx = EX1_P1_SIZES_IN_OUT;
pu->out_size_idx = EX1_P1_SIZES_IN_OUT;
pu->params.dma.inout_index = 2;
pu->params.dma.offset_lines_inc = 0;/*TBD*/
pu++;
/****** subchain 2 *****/
sc[1].stype = VPUL_SUB_CH_HW;
sc[1].id = 0x1239;
/* DMA In */
pu->instance = VPU_PU_DMAIN0;
pu->op_type = VPUL_OP_DMA;
pu->n_in_connect = 0;
pu->n_out_connect = 1;
pu->n_mprbs = 0;
pu->in_size_idx = EX1_P1_SIZES_IN_OUT;
pu->out_size_idx = EX1_P1_SIZES_IN_OUT;
pu->params.dma.inout_index = 2;
pu->params.dma.offset_lines_inc = 0;/*TBD*/
pu++;
/* DMA In */
pu->instance = VPU_PU_DMAIN_MNM0;
pu->op_type = VPUL_OP_DMA;
pu->n_in_connect = 0;
pu->n_out_connect = 1;
pu->n_mprbs = 0;
pu->in_size_idx = EX1_P1_SIZES_IN_OUT;
pu->out_size_idx = EX1_P1_SIZES_IN_OUT;
pu->params.dma.inout_index = 1;
pu->params.dma.offset_lines_inc = 0;/*TBD*/
pu++;
/* SALB: u16: sub */
pu->instance = VPU_PU_SALB2;
pu->op_type = VPUL_OP_FULL_SALB;
pu->n_in_connect = 2;
pu->in_connect[0].pu_idx = 0;
pu->in_connect[0].s_pu_out_idx = 0;
pu->in_connect[1].pu_idx = 1;
pu->in_connect[1].s_pu_out_idx = 0;
pu->n_out_connect = 1;
pu->n_mprbs = 0;
pu->in_size_idx = EX1_P1_SIZES_IN_OUT;
pu->out_size_idx = EX1_P1_SIZES_IN_OUT;
memset(&pu->params.salb, 0, sizeof(struct vpul_pu_salb));
pu->params.salb.input_enable = 0x3;
pu->params.salb.bits_in0 = 1;
pu->params.salb.bits_in1 = 1;
pu->params.salb.bits_out0 = 1;
pu->params.salb.operation_code = 0; /* Out0 = Mask ? (In0 - In1) :SI */
pu++;
/* CALB: u16: invert */
pu->instance = VPU_PU_CALB0;
pu->op_type = VPUL_OP_FULL_CALB;
pu->n_in_connect = 1;
pu->in_connect[0].pu_idx = 2;
pu->in_connect[0].s_pu_out_idx = 0;
pu->n_out_connect = 1;
pu->n_mprbs = 0;
pu->in_size_idx = EX1_P1_SIZES_IN_OUT;
pu->out_size_idx = EX1_P1_SIZES_IN_OUT;
memset(&pu->params.calb, 0, sizeof(struct vpul_pu_calb));
pu->params.calb.bits_in0 = 1;
pu->params.calb.bits_in1 = 1;
pu->params.calb.bits_out0 = 1;
pu->params.calb.operation_code = 7; /* Out0 = Mask ? ~SI : SI*/
pu++;
/* DMA out */
pu->instance = VPU_PU_DMAOT0;
pu->op_type = VPUL_OP_DMA;
pu->n_in_connect = 1;
pu->in_connect[0].pu_idx = 3;
pu->in_connect[0].s_pu_out_idx = 0;
pu->n_out_connect = 0;
pu->n_mprbs = 0;
pu->in_size_idx = EX1_P1_SIZES_IN_OUT;
pu->out_size_idx = EX1_P1_SIZES_IN_OUT;
pu->params.dma.inout_index = 3;
pu->params.dma.offset_lines_inc = 0;/*TBD*/
pu++;
/* Vertex 3 - End */
vtx = &vertices[2];
vtx->vtype = VPUL_VERTEXT_END;
vtx->n_out_edges = 0;
vtx->loop.type = VPU_LOOP_NONE;
}
struct vpul_task * make_example1_task(int *size)
{
int status;
struct vpul_task *task = NULL;
__u32 needed_size;
/* Create Data structure */
needed_size = vpu_example1_get_task_ds_size();
task = malloc(needed_size + 4);
if (!task) {
printf("fail allocate task");
return NULL;
}
status = vpu_example1_create_task_ds(task, needed_size);
if (status != VPU_STATUS_SUCCESS) {
printf("vpu_translator_create_task_ds fail (%d)\n", status);
return NULL;
}
/* Driver fill task DS */
example1_fill_task_data_structure(task);
*size = needed_size + 4;
return task;
}
|