Commit beac8290 authored by Stanimir Varbanov's avatar Stanimir Varbanov Committed by Mauro Carvalho Chehab

media: venus: make decoder compliant with stateful codec API

This refactors code for start/stop streaming vb2 operations and
adds a state machine handling similar to the one in stateful codec
API documentation. One major change is that now the HFI session is
started on STREAMON(OUTPUT) and stopped on REQBUF(OUTPUT,count=0),
during that time STREAMOFF(CAP,OUT) just flush buffers but doesn't
stop the session. The other major change is that now the capture
and output queues are completely separated.
Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent be76f150
......@@ -209,6 +209,17 @@ struct venus_buffer {
#define to_venus_buffer(ptr) container_of(ptr, struct venus_buffer, vb)
enum venus_dec_state {
VENUS_DEC_STATE_DEINIT = 0,
VENUS_DEC_STATE_INIT = 1,
VENUS_DEC_STATE_CAPTURE_SETUP = 2,
VENUS_DEC_STATE_STOPPED = 3,
VENUS_DEC_STATE_SEEK = 4,
VENUS_DEC_STATE_DRAIN = 5,
VENUS_DEC_STATE_DECODING = 6,
VENUS_DEC_STATE_DRC = 7
};
/**
* struct venus_inst - holds per instance parameters
*
......@@ -232,6 +243,10 @@ struct venus_buffer {
* @colorspace: current color space
* @quantization: current quantization
* @xfer_func: current xfer function
* @codec_state: current codec API state (see DEC/ENC_STATE_)
* @reconf_wait: wait queue for resolution change event
* @subscriptions: used to hold current events subscriptions
* @buf_count: used to count number of buffers (reqbuf(0))
* @fps: holds current FPS
* @timeperframe: holds current time per frame structure
* @fmt_out: a reference to output format structure
......@@ -246,8 +261,6 @@ struct venus_buffer {
* @opb_buftype: output picture buffer type
* @opb_fmt: output picture buffer raw format
* @reconfig: a flag raised by decoder when the stream resolution changed
* @reconfig_width: holds the new width
* @reconfig_height: holds the new height
* @hfi_codec: current codec for this instance in HFI space
* @sequence_cap: a sequence counter for capture queue
* @sequence_out: a sequence counter for output queue
......@@ -287,6 +300,10 @@ struct venus_inst {
u8 ycbcr_enc;
u8 quantization;
u8 xfer_func;
enum venus_dec_state codec_state;
wait_queue_head_t reconf_wait;
unsigned int subscriptions;
int buf_count;
u64 fps;
struct v4l2_fract timeperframe;
const struct venus_format *fmt_out;
......@@ -301,8 +318,6 @@ struct venus_inst {
u32 opb_buftype;
u32 opb_fmt;
bool reconfig;
u32 reconfig_width;
u32 reconfig_height;
u32 hfi_codec;
u32 sequence_cap;
u32 sequence_out;
......
......@@ -1021,16 +1021,19 @@ void venus_helper_vb2_buf_queue(struct vb2_buffer *vb)
v4l2_m2m_buf_queue(m2m_ctx, vbuf);
if (!(inst->streamon_out & inst->streamon_cap))
if (inst->session_type == VIDC_SESSION_TYPE_ENC &&
!(inst->streamon_out && inst->streamon_cap))
goto unlock;
ret = is_buf_refed(inst, vbuf);
if (ret)
goto unlock;
if (vb2_start_streaming_called(vb->vb2_queue)) {
ret = is_buf_refed(inst, vbuf);
if (ret)
goto unlock;
ret = session_process_buf(inst, vbuf);
if (ret)
return_buf_error(inst, vbuf);
ret = session_process_buf(inst, vbuf);
if (ret)
return_buf_error(inst, vbuf);
}
unlock:
mutex_unlock(&inst->lock);
......@@ -1146,14 +1149,8 @@ int venus_helper_vb2_start_streaming(struct venus_inst *inst)
if (ret)
goto err_unload_res;
ret = venus_helper_queue_dpb_bufs(inst);
if (ret)
goto err_session_stop;
return 0;
err_session_stop:
hfi_session_stop(inst);
err_unload_res:
hfi_session_unload_res(inst);
err_unreg_bufs:
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment