1 #include "viddec_emitter.h"
2 #include "viddec_fw_workload.h"
3 #include "viddec_fw_debug.h"
4 
viddec_emit_flush_current_wkld(viddec_emitter * emit)5 int32_t viddec_emit_flush_current_wkld(viddec_emitter *emit)
6 {
7     if(emit->cur.data != NULL)
8     {
9         emit->cur.data->num_items = emit->cur.num_items;
10     }
11     if(emit->next.data != NULL)
12     {
13         emit->next.data->num_items = emit->next.num_items;
14     }
15     emit->cur.num_items = emit->next.num_items;
16     emit->next.num_items = 0;
17     if(emit->cur.data != NULL)
18     {
19         emit->cur.data->result = emit->cur.result;
20     }
21     if(emit->next.data != NULL)
22     {
23         emit->next.data->result = emit->next.result;
24     }
25     emit->cur.result = emit->next.result;
26     emit->next.result = 0;
27     return 1;
28 }
29 
viddec_emit_append(viddec_emitter_wkld * cxt,viddec_workload_item_t * item)30 int32_t viddec_emit_append(viddec_emitter_wkld *cxt, viddec_workload_item_t *item)
31 {
32     int32_t ret =0;
33     if((cxt->num_items < cxt->max_items) && (cxt->data != NULL))
34     {
35         cxt->data->item[cxt->num_items] = *item;
36         cxt->num_items++;
37         ret = 1;
38         CDEB(0, "%s: item(%02d) = [%08x %08x %08x %08x]\n",__FUNCTION__, cxt->num_items - 1, item->vwi_type, item->vwi_payload[0], item->vwi_payload[1], item->vwi_payload[2]);
39     }
40     else
41     {
42         cxt->result |= (VIDDEC_FW_WORKLOAD_ERR_ITEMS_OVERFLOW | VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE);
43         WRITE_SVEN(SVEN_MODULE_EVENT_GV_FW_FATAL_WKLD_OVERLFOW, (int)item->vwi_type, (int)(cxt->data), 0, 0, 0, 0);
44     }
45     return ret;
46 }
47 
viddec_emit_contr_tag(viddec_emitter * emit,viddec_input_buffer_t * ibuf,uint8_t incomplete,uint32_t using_next)48 int32_t viddec_emit_contr_tag(viddec_emitter *emit, viddec_input_buffer_t *ibuf, uint8_t incomplete, uint32_t using_next)
49 {
50     viddec_workload_item_t   item;
51     viddec_emitter_wkld *cur_wkld;
52 
53     cur_wkld = (using_next == 0)? &(emit->cur):&(emit->next);
54 
55     if(!incomplete)
56         item.vwi_type           = VIDDEC_WORKLOAD_IBUF_DONE;
57     else
58         item.vwi_type           = VIDDEC_WORKLOAD_IBUF_CONTINUED;
59     item.tag.tag_phys_addr  = ibuf->phys;
60     item.tag.tag_phys_len   = ibuf->len;
61     item.tag.tag_value      = ibuf->id;
62 
63     return viddec_emit_append(cur_wkld, &item);
64 }
65 
viddec_emit_assoc_tag(viddec_emitter * emit,uint32_t id,uint32_t using_next)66 int32_t viddec_emit_assoc_tag(viddec_emitter *emit, uint32_t id, uint32_t using_next)
67 {
68     viddec_workload_item_t   item;
69     viddec_emitter_wkld *cur_wkld;
70 
71     cur_wkld = (using_next == false)? &(emit->cur):&(emit->next);
72     item.vwi_type           = VIDDEC_WORKLOAD_TAG;
73     item.tag.tag_phys_addr  = -1;
74     item.tag.tag_phys_len   = -1;
75     item.tag.tag_value      = id;
76     return viddec_emit_append(cur_wkld, &item);
77 }
78 
79