summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@quicinc.com>2017-06-22 07:40:32 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2017-06-22 07:40:31 -0700
commit4f317411a409e2c9beac7fdb16d1bb7b67ba7cb1 (patch)
treebe6381622c991e38531cab6707a521d56db2c3c0
parentd9cc5d555c3e36f12702186084758c474d3b90af (diff)
parent375a4db6a3a1f56b4981b24657d119e98c359898 (diff)
Merge "msm: vidc: Recompute extradata address of buffers with ref 2"
-rw-r--r--drivers/media/platform/msm/vidc/msm_vidc.c78
1 files changed, 55 insertions, 23 deletions
diff --git a/drivers/media/platform/msm/vidc/msm_vidc.c b/drivers/media/platform/msm/vidc/msm_vidc.c
index f3d50c6a1e0c..7caf61cb6799 100644
--- a/drivers/media/platform/msm/vidc/msm_vidc.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc.c
@@ -531,13 +531,60 @@ static inline void save_v4l2_buffer(struct v4l2_buffer *b,
}
}
+static int __map_and_update_binfo(struct msm_vidc_inst *inst,
+ struct buffer_info *binfo,
+ struct v4l2_buffer *b, int i)
+{
+ int rc = 0;
+ struct msm_smem *same_fd_handle = NULL;
+
+ 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])
+ rc = -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];
+ }
+
+ return rc;
+}
+
+static int __handle_fw_referenced_buffers(struct msm_vidc_inst *inst,
+ struct buffer_info *binfo,
+ struct v4l2_buffer *b)
+{
+ int i = 0, rc = 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);
+ }
+
+ 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;
int i = 0, rc = 0;
- struct msm_smem *same_fd_handle = NULL;
if (!b || !inst) {
dprintk(VIDC_ERR, "%s: invalid input\n", __func__);
@@ -613,33 +660,17 @@ int map_and_register_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b)
rc = 0;
goto exit;
} else if (rc == 2) {
- rc = -EEXIST;
+ rc = __handle_fw_referenced_buffers(inst, temp, b);
+ if (!rc)
+ 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;
- }
- 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];
- }
+ rc = __map_and_update_binfo(inst, binfo, b, i);
+ if (rc)
+ goto exit;
/* We maintain one ref count for all planes*/
if (!i && is_dynamic_output_buffer_mode(b, inst)) {
@@ -727,6 +758,7 @@ 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) {