@@ -200,14 +200,14 @@ static void iris_hfi_gen1_event_seq_changed(struct iris_inst *inst,
200200
201201 iris_hfi_gen1_read_changed_params (inst , pkt );
202202
203- if (inst -> state != IRIS_INST_ERROR ) {
204- reinit_completion (& inst -> flush_completion );
203+ if (inst -> state != IRIS_INST_ERROR && !(inst -> sub_state & IRIS_INST_SUB_FIRST_IPSC )) {
205204
206205 flush_pkt .shdr .hdr .size = sizeof (struct hfi_session_flush_pkt );
207206 flush_pkt .shdr .hdr .pkt_type = HFI_CMD_SESSION_FLUSH ;
208207 flush_pkt .shdr .session_id = inst -> session_id ;
209208 flush_pkt .flush_type = HFI_FLUSH_OUTPUT ;
210- iris_hfi_queue_cmd_write (inst -> core , & flush_pkt , flush_pkt .shdr .hdr .size );
209+ if (!iris_hfi_queue_cmd_write (inst -> core , & flush_pkt , flush_pkt .shdr .hdr .size ))
210+ inst -> flush_responses_pending ++ ;
211211 }
212212
213213 iris_vdec_src_change (inst );
@@ -348,6 +348,10 @@ static void iris_hfi_gen1_session_etb_done(struct iris_inst *inst, void *packet)
348348 struct iris_buffer * buf = NULL ;
349349 bool found = false;
350350
351+ /* EOS buffer sent via drain won't be in v4l2 buffer list */
352+ if (pkt -> packet_buffer == 0xdeadb000 )
353+ return ;
354+
351355 v4l2_m2m_for_each_src_buf_safe (m2m_ctx , m2m_buffer , n ) {
352356 buf = to_iris_buffer (& m2m_buffer -> vb );
353357 if (buf -> index == pkt -> input_tag ) {
@@ -408,7 +412,9 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_inst *inst, void *packet)
408412 flush_pkt .shdr .hdr .pkt_type = HFI_CMD_SESSION_FLUSH ;
409413 flush_pkt .shdr .session_id = inst -> session_id ;
410414 flush_pkt .flush_type = HFI_FLUSH_OUTPUT ;
411- iris_hfi_queue_cmd_write (core , & flush_pkt , flush_pkt .shdr .hdr .size );
415+ if (!iris_hfi_queue_cmd_write (core , & flush_pkt , flush_pkt .shdr .hdr .size ))
416+ inst -> flush_responses_pending ++ ;
417+
412418 iris_inst_sub_state_change_drain_last (inst );
413419
414420 return ;
@@ -455,7 +461,12 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_inst *inst, void *packet)
455461 timestamp_us = timestamp_hi ;
456462 timestamp_us = (timestamp_us << 32 ) | timestamp_lo ;
457463 } else {
458- flags |= V4L2_BUF_FLAG_LAST ;
464+ if (pkt -> stream_id == 1 && !inst -> last_buffer_dequeued ) {
465+ if (iris_drc_pending (inst )) {
466+ flags |= V4L2_BUF_FLAG_LAST ;
467+ inst -> last_buffer_dequeued = true;
468+ }
469+ }
459470 }
460471 buf -> timestamp = timestamp_us ;
461472
@@ -481,6 +492,12 @@ static void iris_hfi_gen1_session_ftb_done(struct iris_inst *inst, void *packet)
481492 buf -> attr |= BUF_ATTR_DEQUEUED ;
482493 buf -> attr |= BUF_ATTR_BUFFER_DONE ;
483494
495+ if (hfi_flags & HFI_BUFFERFLAG_DATACORRUPT )
496+ flags |= V4L2_BUF_FLAG_ERROR ;
497+
498+ if (hfi_flags & HFI_BUFFERFLAG_DROP_FRAME )
499+ flags |= V4L2_BUF_FLAG_ERROR ;
500+
484501 buf -> flags |= flags ;
485502
486503 iris_vb2_buffer_done (inst , buf );
@@ -558,7 +575,6 @@ static void iris_hfi_gen1_handle_response(struct iris_core *core, void *response
558575 const struct iris_hfi_gen1_response_pkt_info * pkt_info ;
559576 struct device * dev = core -> dev ;
560577 struct hfi_session_pkt * pkt ;
561- struct completion * done ;
562578 struct iris_inst * inst ;
563579 bool found = false;
564580 u32 i ;
@@ -619,9 +635,12 @@ static void iris_hfi_gen1_handle_response(struct iris_core *core, void *response
619635 if (shdr -> error_type != HFI_ERR_NONE )
620636 iris_inst_change_state (inst , IRIS_INST_ERROR );
621637
622- done = pkt_info -> pkt == HFI_MSG_SESSION_FLUSH ?
623- & inst -> flush_completion : & inst -> completion ;
624- complete (done );
638+ if (pkt_info -> pkt == HFI_MSG_SESSION_FLUSH ) {
639+ if (!(-- inst -> flush_responses_pending ))
640+ complete (& inst -> flush_completion );
641+ } else {
642+ complete (& inst -> completion );
643+ }
625644 }
626645 mutex_unlock (& inst -> lock );
627646
0 commit comments