The 'stream_pos' in sess is automatically changed auto by uadk after a stream request is end. But sometimes users want to drop an old request and send a new request with the old sess.
So add the interface 'wd_comp_reset_sess' to allow the user set the 'stream_pos' to 'WD_COMP_STREAM_NEW' whenever they want.
Signed-off-by: Yang Shen shenyang39@huawei.com --- include/wd_comp.h | 6 ++++++ wd_comp.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+)
diff --git a/include/wd_comp.h b/include/wd_comp.h index 460cfa7..af874d8 100644 --- a/include/wd_comp.h +++ b/include/wd_comp.h @@ -135,6 +135,12 @@ handle_t wd_comp_alloc_sess(struct wd_comp_sess_setup *setup); */ void wd_comp_free_sess(handle_t h_sess);
+/** + * wd_comp_reset_sess() - Reset a wd comp session. + * @h_sess: The sess to be reset. + */ +int wd_comp_reset_sess(handle_t h_sess); + /** * wd_do_comp_sync() - Send a sync compression request. * @h_sess: The session which request will be sent to. diff --git a/wd_comp.c b/wd_comp.c index 3bd7f43..b94e107 100644 --- a/wd_comp.c +++ b/wd_comp.c @@ -317,6 +317,21 @@ void wd_comp_free_sess(handle_t h_sess) free(sess); }
+int wd_comp_reset_sess(handle_t h_sess) +{ + struct wd_comp_sess *sess = (struct wd_comp_sess *)h_sess; + + if (!sess) { + WD_ERR("invalid: sess is NULL!\n"); + return -WD_EINVAL; + } + + sess->stream_pos = WD_COMP_STREAM_NEW; + memset(sess->ctx_buf, 0, HW_CTX_SIZE); + + return 0; +} + static void fill_comp_msg(struct wd_comp_sess *sess, struct wd_comp_msg *msg, struct wd_comp_req *req) {