diff options
author | Sunita Nadampalli | 2020-01-20 14:32:00 -0600 |
---|---|---|
committer | Sunita Nadampalli | 2020-01-20 14:32:00 -0600 |
commit | 31a547e8ec53876f9351029e7b5a329c904a7f32 (patch) | |
tree | 7130832773f92c44b1869f703c1a18491305c2a7 | |
parent | 279667fcffba30fa299c107f784281f544f057fc (diff) | |
download | ti-img-encode-decode-31a547e8ec53876f9351029e7b5a329c904a7f32.tar.gz ti-img-encode-decode-31a547e8ec53876f9351029e7b5a329c904a7f32.tar.xz ti-img-encode-decode-31a547e8ec53876f9351029e7b5a329c904a7f32.zip |
tirtos: encoder: Fix mutex usage issue
This patch fixes logic issue with using the driver mutex
and also cleans up unused contenxt variables.
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
-rw-r--r-- | driver/encoder/vxe_enc.h | 5 | ||||
-rw-r--r-- | osal/src/tirtos/osa_workqueue.c | 2 | ||||
-rw-r--r-- | timmlib/decoder/mm_dec_create.c | 1 | ||||
-rw-r--r-- | timmlib/encoder/mm_enc_create.c | 25 | ||||
-rw-r--r-- | timmlib/encoder/mm_enc_init.c | 5 |
5 files changed, 7 insertions, 31 deletions
diff --git a/driver/encoder/vxe_enc.h b/driver/encoder/vxe_enc.h index 3fe12ef..4f1c870 100644 --- a/driver/encoder/vxe_enc.h +++ b/driver/encoder/vxe_enc.h | |||
@@ -195,12 +195,7 @@ struct vxe_enc_ctx { | |||
195 | void *mm_return_resource; /* Place holder for CB to application */ | 195 | void *mm_return_resource; /* Place holder for CB to application */ |
196 | void *stream_worker_queue_handle; | 196 | void *stream_worker_queue_handle; |
197 | void *stream_worker_queue_sem_handle; | 197 | void *stream_worker_queue_sem_handle; |
198 | // lock is used to synchronize the stream worker and process function | ||
199 | void *lock; | ||
200 | /* "sem_eos" this semaphore variable used to wait until all frame decoded */ | ||
201 | void *sem_eos; | ||
202 | void *work; | 198 | void *work; |
203 | uint8 stop_initiated; | ||
204 | struct vxe_enc_q_data q_data[2]; | 199 | struct vxe_enc_q_data q_data[2]; |
205 | #ifdef ENABLE_PROFILING | 200 | #ifdef ENABLE_PROFILING |
206 | struct enc_drv_latency drv_lat; | 201 | struct enc_drv_latency drv_lat; |
diff --git a/osal/src/tirtos/osa_workqueue.c b/osal/src/tirtos/osa_workqueue.c index ecfa345..bc903dd 100644 --- a/osal/src/tirtos/osa_workqueue.c +++ b/osal/src/tirtos/osa_workqueue.c | |||
@@ -100,7 +100,7 @@ void osa_init_work(void **work_args, void *work_fn, uint8_t hwa_id) | |||
100 | (*work)->work_complete = FALSE; | 100 | (*work)->work_complete = FALSE; |
101 | (*work)->queue_handle = str_ctx->vxe_ctx->stream_worker_queue_handle; | 101 | (*work)->queue_handle = str_ctx->vxe_ctx->stream_worker_queue_handle; |
102 | (*work)->workq_sem_handle = str_ctx->vxe_ctx->stream_worker_queue_sem_handle; | 102 | (*work)->workq_sem_handle = str_ctx->vxe_ctx->stream_worker_queue_sem_handle; |
103 | (*work)->lock = str_ctx->vxe_ctx->lock; | 103 | (*work)->lock = str_ctx->vxe_ctx->mutex; |
104 | } | 104 | } |
105 | break; | 105 | break; |
106 | 106 | ||
diff --git a/timmlib/decoder/mm_dec_create.c b/timmlib/decoder/mm_dec_create.c index e3c1dce..6d3de05 100644 --- a/timmlib/decoder/mm_dec_create.c +++ b/timmlib/decoder/mm_dec_create.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "osal/inc/osa_semaphore.h" | 27 | #include "osal/inc/osa_semaphore.h" |
28 | #include "osal/inc/osa_queue.h" | 28 | #include "osal/inc/osa_queue.h" |
29 | #include "osal/inc/osa_task.h" | 29 | #include "osal/inc/osa_task.h" |
30 | #include "osal/inc/osa_queue.h" | ||
31 | #include "mm_dec_priv.h" | 30 | #include "mm_dec_priv.h" |
32 | #include "mm_dec.h" | 31 | #include "mm_dec.h" |
33 | 32 | ||
diff --git a/timmlib/encoder/mm_enc_create.c b/timmlib/encoder/mm_enc_create.c index 7f919e8..ed52814 100644 --- a/timmlib/encoder/mm_enc_create.c +++ b/timmlib/encoder/mm_enc_create.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "osal/inc/osa_semaphore.h" | 24 | #include "osal/inc/osa_semaphore.h" |
25 | #include "osal/inc/osa_queue.h" | 25 | #include "osal/inc/osa_queue.h" |
26 | #include "osal/inc/osa_task.h" | 26 | #include "osal/inc/osa_task.h" |
27 | #include "osal/inc/osa_queue.h" | ||
28 | #include "osal/inc/osa_types.h" | 27 | #include "osal/inc/osa_types.h" |
29 | #include "osal/inc/osa_mutex.h" | 28 | #include "osal/inc/osa_mutex.h" |
30 | #include "osal/inc/osa_workqueue.h" | 29 | #include "osal/inc/osa_workqueue.h" |
@@ -347,7 +346,7 @@ int32_t MM_ENC_BufPrepare(struct mm_buffer *buffer, uint32_t chId) | |||
347 | 346 | ||
348 | if (vxe_buf != NULL) | 347 | if (vxe_buf != NULL) |
349 | { | 348 | { |
350 | OSA_PR_ERR("%s:This buffer is already mapped\n",__func__); | 349 | OSA_PR_INFO("%s:This buffer is already mapped\n",__func__); |
351 | return 0; | 350 | return 0; |
352 | } | 351 | } |
353 | 352 | ||
@@ -662,8 +661,8 @@ int32_t MM_ENC_Create(mm_vid_create_params *params, uint32_t *ch_Id) | |||
662 | g_MM_ENC_Inst.ch_obj[chId].mm_buf = mm_buf; | 661 | g_MM_ENC_Inst.ch_obj[chId].mm_buf = mm_buf; |
663 | mm_buf->vxe_buf_index = 0; | 662 | mm_buf->vxe_buf_index = 0; |
664 | 663 | ||
665 | osa_mutex_create(&ctx->lock); | 664 | osa_mutex_create(&ctx->mutex); |
666 | if(NULL == ctx->lock) | 665 | if(NULL == ctx->mutex) |
667 | { | 666 | { |
668 | osa_free(ctx); | 667 | osa_free(ctx); |
669 | osa_free(mm_buf); | 668 | osa_free(mm_buf); |
@@ -676,7 +675,7 @@ int32_t MM_ENC_Create(mm_vid_create_params *params, uint32_t *ch_Id) | |||
676 | osa_free(ctx); | 675 | osa_free(ctx); |
677 | osa_free(mm_buf); | 676 | osa_free(mm_buf); |
678 | enc_release_stream_workqueue_resource(chId); | 677 | enc_release_stream_workqueue_resource(chId); |
679 | osa_mutex_destroy(&ctx->lock); | 678 | osa_mutex_destroy(&ctx->mutex); |
680 | osa_mutex_unlock(vxe->mutex); | 679 | osa_mutex_unlock(vxe->mutex); |
681 | return ret; | 680 | return ret; |
682 | } | 681 | } |
@@ -732,7 +731,7 @@ int32_t MM_ENC_Create(mm_vid_create_params *params, uint32_t *ch_Id) | |||
732 | osa_free(ctx); | 731 | osa_free(ctx); |
733 | osa_free(mm_buf); | 732 | osa_free(mm_buf); |
734 | enc_release_stream_workqueue_resource(chId); | 733 | enc_release_stream_workqueue_resource(chId); |
735 | osa_mutex_destroy(&ctx->lock); | 734 | osa_mutex_destroy(&ctx->mutex); |
736 | osa_mutex_unlock(vxe->mutex); | 735 | osa_mutex_unlock(vxe->mutex); |
737 | return ret; | 736 | return ret; |
738 | } | 737 | } |
@@ -755,22 +754,11 @@ int32_t MM_ENC_Create(mm_vid_create_params *params, uint32_t *ch_Id) | |||
755 | osa_free(ctx); | 754 | osa_free(ctx); |
756 | osa_free(mm_buf); | 755 | osa_free(mm_buf); |
757 | enc_release_stream_workqueue_resource(chId); | 756 | enc_release_stream_workqueue_resource(chId); |
758 | osa_mutex_destroy(&ctx->lock); | 757 | osa_mutex_destroy(&ctx->mutex); |
759 | osa_mutex_unlock(vxe->mutex); | 758 | osa_mutex_unlock(vxe->mutex); |
760 | return ret; | 759 | return ret; |
761 | } | 760 | } |
762 | 761 | ||
763 | ctx->sem_eos = osa_semaphore_create(osa_semaphore_mode_binary, 0); | ||
764 | if(NULL == ctx->sem_eos) | ||
765 | { | ||
766 | osa_free(ctx); | ||
767 | osa_free(mm_buf); | ||
768 | enc_release_stream_workqueue_resource(chId); | ||
769 | osa_mutex_destroy(&ctx->lock); | ||
770 | osa_mutex_unlock(vxe->mutex); | ||
771 | return -OSA_ENOMEM; | ||
772 | } | ||
773 | |||
774 | osa_mutex_unlock(vxe->mutex); | 762 | osa_mutex_unlock(vxe->mutex); |
775 | return 0; | 763 | return 0; |
776 | } | 764 | } |
@@ -807,7 +795,6 @@ int32_t MM_ENC_Destroy(uint32_t chId) | |||
807 | 795 | ||
808 | osa_free(mm_buf); | 796 | osa_free(mm_buf); |
809 | enc_release_stream_workqueue_resource(chId); | 797 | enc_release_stream_workqueue_resource(chId); |
810 | osa_semaphore_delete(ctx->sem_eos); | ||
811 | osa_mutex_destroy(&ctx->mutex); | 798 | osa_mutex_destroy(&ctx->mutex); |
812 | 799 | ||
813 | osa_free(ctx); | 800 | osa_free(ctx); |
diff --git a/timmlib/encoder/mm_enc_init.c b/timmlib/encoder/mm_enc_init.c index b576c8a..5530c62 100644 --- a/timmlib/encoder/mm_enc_init.c +++ b/timmlib/encoder/mm_enc_init.c | |||
@@ -84,11 +84,6 @@ static void vxe_return_resource(void *ctx_handle, enum vxe_cb_type type, | |||
84 | 84 | ||
85 | mm_ret_resource = (void (*)(struct mm_buffer *buf, mm_enc_process_cb cb_type))ctx->mm_return_resource; | 85 | mm_ret_resource = (void (*)(struct mm_buffer *buf, mm_enc_process_cb cb_type))ctx->mm_return_resource; |
86 | 86 | ||
87 | if((osa_true == ctx->stop_initiated) && (0 == ctx->frames_encoding)) //TO DO is it frames_encoding? | ||
88 | { | ||
89 | osa_semaphore_post(ctx->sem_eos); | ||
90 | } | ||
91 | |||
92 | switch (type) { | 87 | switch (type) { |
93 | case VXE_CB_CODED_BUFF_READY: | 88 | case VXE_CB_CODED_BUFF_READY: |
94 | if (!img_buf_ref) | 89 | if (!img_buf_ref) |