1 #ifndef VIDDEC_EMITTER_H
2 #define VIDDEC_EMITTER_H
3
4 #include <stdint.h>
5 #ifndef HOST_ONLY
6 #define DDR_MEM_MASK 0x80000000
7 #else
8 #define DDR_MEM_MASK 0x0
9 #endif
10 #include "viddec_fw_workload.h"
11 #include "viddec_fw_common_defs.h"
12 #include "viddec_fw_debug.h"
13
14 typedef struct
15 {
16 viddec_workload_t *data;
17 uint32_t max_items;
18 uint32_t num_items;
19 uint32_t result;
20 }viddec_emitter_wkld;
21
22 typedef struct
23 {
24 viddec_emitter_wkld cur;
25 viddec_emitter_wkld next;
26 }viddec_emitter;
27
28 /*
29 whats this for? Emitting current tag for ES buffer
30 */
31 int32_t viddec_emit_assoc_tag(viddec_emitter *emit, uint32_t id, uint32_t using_next);
32
33 int32_t viddec_emit_contr_tag(viddec_emitter *emit, viddec_input_buffer_t *ibuf, uint8_t incomplete, uint32_t using_next);
34
35 int32_t viddec_emit_flush_current_wkld(viddec_emitter *emit);
36
37 int32_t viddec_emit_append(viddec_emitter_wkld *cxt, viddec_workload_item_t *item);
38
39 /*
40 Init function for setting up emitter context.
41 */
viddec_emit_init(viddec_emitter * cxt)42 static inline void viddec_emit_init(viddec_emitter *cxt)
43 {
44 cxt->cur.data = cxt->next.data = 0;
45 cxt->cur.max_items = cxt->next.max_items = 0;
46 cxt->cur.num_items = cxt->next.num_items = 0;
47 cxt->cur.result = cxt->next.result = VIDDEC_FW_WORKLOAD_SUCCESS;
48 }
49
viddec_emit_update(viddec_emitter * cxt,uint32_t cur,uint32_t next,uint32_t cur_size,uint32_t next_size)50 static inline void viddec_emit_update(viddec_emitter *cxt, uint32_t cur, uint32_t next, uint32_t cur_size, uint32_t next_size)
51 {
52 cxt->cur.data = (cur != 0) ? (viddec_workload_t *)(cur | DDR_MEM_MASK) : NULL;
53 cxt->next.data = (next != 0) ? (viddec_workload_t *)(next | DDR_MEM_MASK): NULL;
54 cxt->cur.max_items = (cur_size - sizeof(viddec_workload_t))/sizeof(viddec_workload_item_t);
55 cxt->next.max_items = (next_size - sizeof(viddec_workload_t))/sizeof(viddec_workload_item_t);
56 }
57
viddec_emit_time(viddec_emitter * cxt,uint32_t time)58 static inline void viddec_emit_time(viddec_emitter *cxt, uint32_t time)
59 {
60 viddec_emitter_wkld *cur;
61 cur = &(cxt->cur);
62 cur->data->time = time;
63 }
64
viddec_emit_set_codec(viddec_emitter * emit,uint32_t codec_type)65 static inline void viddec_emit_set_codec(viddec_emitter *emit, uint32_t codec_type)
66 {
67 emit->cur.data->codec = codec_type;
68 }
69
viddec_emit_set_codec_errors(viddec_emitter * emit,uint32_t codec_error)70 static inline void viddec_emit_set_codec_errors(viddec_emitter *emit, uint32_t codec_error)
71 {
72 emit->cur.result |= codec_error;
73 WRITE_SVEN(SVEN_MODULE_EVENT_GV_FW_PM_WORKLOAD_STATUS, (int)emit->cur.result, (int)emit->cur.data,
74 (int)emit->cur.num_items, 0, 0, 0);
75 }
76
viddec_emit_set_workload_error(viddec_emitter * emit,uint32_t error,uint32_t using_next)77 static inline void viddec_emit_set_workload_error(viddec_emitter *emit, uint32_t error, uint32_t using_next)
78 {
79 viddec_emitter_wkld *cur_wkld;
80 cur_wkld = (using_next == false)? &(emit->cur):&(emit->next);
81 cur_wkld->result |= error;
82 WRITE_SVEN(SVEN_MODULE_EVENT_GV_FW_PM_WORKLOAD_STATUS, (int)cur_wkld->result, (int)cur_wkld->data,
83 (int)cur_wkld->num_items, using_next, 0, 0);
84 }
85
viddec_emit_set_inband_tag(viddec_emitter * emit,uint32_t type,uint32_t using_next)86 static inline void viddec_emit_set_inband_tag(viddec_emitter *emit, uint32_t type, uint32_t using_next)
87 {
88 viddec_emitter_wkld *cur_wkld;
89 viddec_workload_item_t item;
90 cur_wkld = (using_next == false)? &(emit->cur):&(emit->next);
91 item.vwi_type = type;
92 item.vwi_payload[0] = item.vwi_payload[1] = item.vwi_payload[2] = 0;
93 viddec_emit_append(cur_wkld, &item);
94 }
95
96 #endif /* VIDDEC_EMITTER_H */
97