From 7abf6aa50421d91a272aad7e19cf9d143e0ce2ea Mon Sep 17 00:00:00 2001 From: Abdulla Anam Date: Tue, 15 Nov 2016 20:41:10 +0530 Subject: [PATCH] msm: vidc: Add port information to flush_done event When video driver queues the flush event, it doesn't convey the port which is flushed. Due to this userspace content has to handle the event according to the flush status variables that it maintains. This handling can go wrong when there are concurrent flush commands from client. Address this by adding port detail to flush event. Change-Id: Ie9b7e35ad396ba8eed20dcca1f655b3e23f6626c Signed-off-by: Abdulla Anam --- .../platform/msm/vidc/hfi_response_handler.c | 16 ++++++++++ .../media/platform/msm/vidc/msm_vidc_common.c | 30 +++++++++++++++++-- .../media/platform/msm/vidc/vidc_hfi_api.h | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/msm/vidc/hfi_response_handler.c b/drivers/media/platform/msm/vidc/hfi_response_handler.c index 88a3b4b6f7ba..3835a2e45882 100644 --- a/drivers/media/platform/msm/vidc/hfi_response_handler.c +++ b/drivers/media/platform/msm/vidc/hfi_response_handler.c @@ -1369,6 +1369,22 @@ static int hfi_process_session_flush_done(u32 device_id, cmd_done.status = hfi_map_err_status(pkt->error_type); cmd_done.size = sizeof(u32); + switch (pkt->flush_type) { + case HFI_FLUSH_OUTPUT: + cmd_done.data.flush_type = HAL_FLUSH_OUTPUT; + break; + case HFI_FLUSH_INPUT: + cmd_done.data.flush_type = HAL_FLUSH_INPUT; + break; + case HFI_FLUSH_ALL: + cmd_done.data.flush_type = HAL_FLUSH_ALL; + break; + default: + dprintk(VIDC_ERR, + "%s: invalid flush type!", __func__); + return -EINVAL; + } + *info = (struct msm_vidc_cb_info) { .response_type = HAL_SESSION_FLUSH_DONE, .response.cmd = cmd_done, diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.c b/drivers/media/platform/msm/vidc/msm_vidc_common.c index a2edbb6a8270..55c75e869e30 100644 --- a/drivers/media/platform/msm/vidc/msm_vidc_common.c +++ b/drivers/media/platform/msm/vidc/msm_vidc_common.c @@ -1505,6 +1505,9 @@ static void handle_session_flush(enum hal_command_response cmd, void *data) { struct msm_vidc_cb_cmd_done *response = data; struct msm_vidc_inst *inst; + struct v4l2_event flush_event = {0}; + u32 *ptr = NULL; + enum hal_flush flush_type; int rc; if (!response) { @@ -1532,8 +1535,31 @@ static void handle_session_flush(enum hal_command_response cmd, void *data) } } atomic_dec(&inst->in_flush); - dprintk(VIDC_DBG, "Notify flush complete to client\n"); - msm_vidc_queue_v4l2_event(inst, V4L2_EVENT_MSM_VIDC_FLUSH_DONE); + flush_event.type = V4L2_EVENT_MSM_VIDC_FLUSH_DONE; + ptr = (u32 *)flush_event.u.data; + + flush_type = response->data.flush_type; + switch (flush_type) { + case HAL_FLUSH_INPUT: + ptr[0] = V4L2_QCOM_CMD_FLUSH_OUTPUT; + break; + case HAL_FLUSH_OUTPUT: + ptr[0] = V4L2_QCOM_CMD_FLUSH_CAPTURE; + break; + case HAL_FLUSH_ALL: + ptr[0] |= V4L2_QCOM_CMD_FLUSH_CAPTURE; + ptr[0] |= V4L2_QCOM_CMD_FLUSH_OUTPUT; + break; + default: + dprintk(VIDC_ERR, "Invalid flush type received!"); + goto exit; + } + + dprintk(VIDC_DBG, + "Notify flush complete, flush_type: %x\n", flush_type); + v4l2_event_queue_fh(&inst->event_handler, &flush_event); + +exit: put_inst(inst); } diff --git a/drivers/media/platform/msm/vidc/vidc_hfi_api.h b/drivers/media/platform/msm/vidc/vidc_hfi_api.h index 116ce12c8dba..820c8685a75b 100644 --- a/drivers/media/platform/msm/vidc/vidc_hfi_api.h +++ b/drivers/media/platform/msm/vidc/vidc_hfi_api.h @@ -1351,6 +1351,7 @@ struct msm_vidc_cb_cmd_done { struct vidc_hal_session_init_done session_init_done; struct hal_buffer_info buffer_info; union hal_get_property property; + enum hal_flush flush_type; } data; };