diff options
| -rw-r--r-- | drivers/media/platform/msm/vidc/msm_vidc.c | 95 |
1 files changed, 28 insertions, 67 deletions
diff --git a/drivers/media/platform/msm/vidc/msm_vidc.c b/drivers/media/platform/msm/vidc/msm_vidc.c index a343bc2d59e4..02bfc459614f 100644 --- a/drivers/media/platform/msm/vidc/msm_vidc.c +++ b/drivers/media/platform/msm/vidc/msm_vidc.c @@ -516,7 +516,6 @@ static inline bool is_dynamic_output_buffer_mode(struct v4l2_buffer *b, inst->buffer_mode_set[CAPTURE_PORT] == HAL_BUFFER_MODE_DYNAMIC; } - static inline void save_v4l2_buffer(struct v4l2_buffer *b, struct buffer_info *binfo) { @@ -529,71 +528,22 @@ static inline void save_v4l2_buffer(struct v4l2_buffer *b, } populate_buf_info(binfo, b, i); } -} - -static int __map_and_update_binfo(struct msm_vidc_inst *inst, - struct buffer_info *binfo, - struct v4l2_buffer *b, u32 i) -{ - int rc = 0; - struct msm_smem *same_fd_handle = NULL; - - if (i >= VIDEO_MAX_PLANES) { - dprintk(VIDC_ERR, "Num planes exceeds max: %d, %d\n", - i, VIDEO_MAX_PLANES); - rc = -EINVAL; - goto exit; - } - - same_fd_handle = get_same_fd_buffer( - inst, b->m.planes[i].reserved[0]); - - if (same_fd_handle) { - binfo->device_addr[i] = - same_fd_handle->device_addr + binfo->buff_off[i]; - b->m.planes[i].m.userptr = binfo->device_addr[i]; - binfo->handle[i] = same_fd_handle; - } else { - binfo->handle[i] = map_buffer(inst, &b->m.planes[i], - get_hal_buffer_type(inst, b)); - if (!binfo->handle[i]) - return -EINVAL; - - binfo->mapped[i] = true; - binfo->device_addr[i] = binfo->handle[i]->device_addr + - binfo->buff_off[i]; - b->m.planes[i].m.userptr = binfo->device_addr[i]; - } - -exit: - return rc; -} - -static int __handle_fw_referenced_buffers(struct msm_vidc_inst *inst, - struct buffer_info *binfo, - struct v4l2_buffer *b) -{ - int rc = 0; - u32 i = 0; if (EXTRADATA_IDX(b->length)) { i = EXTRADATA_IDX(b->length); if (b->m.planes[i].length) - rc = __map_and_update_binfo(inst, binfo, b, i); + binfo->device_addr[i] = binfo->handle[i]->device_addr + + binfo->buff_off[i]; } - - if (rc) - dprintk(VIDC_ERR, "%s: Failed to map extradata\n", __func__); - - return rc; } int map_and_register_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b) { struct buffer_info *binfo = NULL; struct buffer_info *temp = NULL, *iterator = NULL; - int plane = 0, rc = 0; - u32 i = 0; + int plane = 0; + int i = 0, rc = 0; + struct msm_smem *same_fd_handle = NULL; if (!b || !inst) { dprintk(VIDC_ERR, "%s: invalid input\n", __func__); @@ -669,23 +619,39 @@ int map_and_register_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b) rc = 0; goto exit; } else if (rc == 2) { - rc = __handle_fw_referenced_buffers(inst, temp, b); - if (!rc) - rc = -EEXIST; + rc = -EEXIST; goto exit; } + same_fd_handle = get_same_fd_buffer( + inst, b->m.planes[i].reserved[0]); + populate_buf_info(binfo, b, i); + if (same_fd_handle) { + binfo->device_addr[i] = + same_fd_handle->device_addr + binfo->buff_off[i]; + b->m.planes[i].m.userptr = binfo->device_addr[i]; + binfo->mapped[i] = false; + binfo->handle[i] = same_fd_handle; + } else { + binfo->handle[i] = map_buffer(inst, &b->m.planes[i], + get_hal_buffer_type(inst, b)); + if (!binfo->handle[i]) { + rc = -EINVAL; + goto exit; + } - rc = __map_and_update_binfo(inst, binfo, b, i); - if (rc) - goto map_err; + binfo->mapped[i] = true; + binfo->device_addr[i] = binfo->handle[i]->device_addr + + binfo->buff_off[i]; + b->m.planes[i].m.userptr = binfo->device_addr[i]; + } /* We maintain one ref count for all planes*/ if (!i && is_dynamic_output_buffer_mode(b, inst)) { rc = buf_ref_get(inst, binfo); if (rc < 0) - goto map_err; + goto exit; } dprintk(VIDC_DBG, "%s: [MAP] binfo = %pK, handle[%d] = %pK, device_addr = %pa, fd = %d, offset = %d, mapped = %d\n", @@ -699,9 +665,6 @@ int map_and_register_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b) mutex_unlock(&inst->registeredbufs.lock); return 0; -map_err: - if (binfo->handle[0] && binfo->mapped[0]) - msm_comm_smem_free(inst, binfo->handle[0]); exit: kfree(binfo); return rc; @@ -771,7 +734,6 @@ int unmap_and_deregister_buf(struct msm_vidc_inst *inst, temp->handle[i] = 0; temp->device_addr[i] = 0; temp->uvaddr[i] = 0; - temp->mapped[i] = false; } } if (!keep_node) { @@ -786,7 +748,6 @@ exit: return 0; } - int qbuf_dynamic_buf(struct msm_vidc_inst *inst, struct buffer_info *binfo) { |
