Merge "msm: vidc: Remove prepare and release buf implementation" into msm-4.9

This commit is contained in:
Kyle Yan 2017-02-28 15:17:22 -08:00 • committed by Gerrit - the friendly Code Review server
commit 7cb7aff92a
5 changed files with 0 additions and 370 deletions

View file

@ -621,155 +621,6 @@ int msm_vdec_streamoff(struct msm_vidc_inst *inst, enum v4l2_buf_type i)
return rc;
}
int msm_vdec_prepare_buf(struct msm_vidc_inst *inst,
struct v4l2_buffer *b)
{
int rc = 0;
struct vidc_buffer_addr_info buffer_info;
int extra_idx = 0;
int i;
struct hfi_device *hdev;
if (!inst || !inst->core || !inst->core->device) {
dprintk(VIDC_ERR, "%s invalid parameters\n", __func__);
return -EINVAL;
}
hdev = inst->core->device;
if (inst->state == MSM_VIDC_CORE_INVALID ||
inst->core->state == VIDC_CORE_INVALID) {
dprintk(VIDC_ERR,
"Core %pK in bad state, ignoring prepare buf\n",
inst->core);
goto exit;
}
switch (b->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
if (b->length != inst->fmts[CAPTURE_PORT].num_planes) {
dprintk(VIDC_ERR,
"Planes mismatch: needed: %d, allocated: %d\n",
inst->fmts[CAPTURE_PORT].num_planes,
b->length);
rc = -EINVAL;
break;
}
for (i = 0; i < min_t(int, b->length, VIDEO_MAX_PLANES); ++i) {
dprintk(VIDC_DBG,
"prepare plane: %d, device_addr = %#lx, size = %d\n",
i, b->m.planes[i].m.userptr,
b->m.planes[i].length);
}
buffer_info.buffer_size = b->m.planes[0].length;
buffer_info.buffer_type = msm_comm_get_hal_output_buffer(inst);
buffer_info.num_buffers = 1;
buffer_info.align_device_addr = b->m.planes[0].m.userptr;
extra_idx = EXTRADATA_IDX(b->length);
if (extra_idx && extra_idx < VIDEO_MAX_PLANES &&
b->m.planes[extra_idx].m.userptr) {
buffer_info.extradata_addr =
b->m.planes[extra_idx].m.userptr;
buffer_info.extradata_size =
b->m.planes[extra_idx].length;
dprintk(VIDC_DBG, "extradata: %pa, length = %d\n",
&buffer_info.extradata_addr,
buffer_info.extradata_size);
} else {
buffer_info.extradata_addr = 0;
buffer_info.extradata_size = 0;
}
rc = call_hfi_op(hdev, session_set_buffers,
(void *)inst->session, &buffer_info);
if (rc) {
dprintk(VIDC_ERR,
"vidc_hal_session_set_buffers failed\n");
}
break;
default:
dprintk(VIDC_ERR, "Buffer type not recognized: %d\n", b->type);
break;
}
exit:
return rc;
}
int msm_vdec_release_buf(struct msm_vidc_inst *inst,
struct v4l2_buffer *b)
{
int rc = 0;
struct vidc_buffer_addr_info buffer_info;
struct msm_vidc_core *core;
int extra_idx = 0;
int i;
struct hfi_device *hdev;
if (!inst || !inst->core || !inst->core->device) {
dprintk(VIDC_ERR, "%s invalid parameters\n", __func__);
return -EINVAL;
}
core = inst->core;
hdev = inst->core->device;
if (inst->state == MSM_VIDC_CORE_INVALID ||
core->state == VIDC_CORE_INVALID) {
dprintk(VIDC_ERR,
"Core %pK in bad state, ignoring release output buf\n",
core);
goto exit;
}
switch (b->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
if (b->length != inst->fmts[CAPTURE_PORT].num_planes) {
dprintk(VIDC_ERR,
"Planes mismatch: needed: %d, to release: %d\n",
inst->fmts[CAPTURE_PORT].num_planes, b->length);
rc = -EINVAL;
break;
}
for (i = 0; i < b->length; ++i) {
dprintk(VIDC_DBG,
"Release plane: %d device_addr = %#lx, size = %d\n",
i, b->m.planes[i].m.userptr,
b->m.planes[i].length);
}
buffer_info.buffer_size = b->m.planes[0].length;
buffer_info.buffer_type = msm_comm_get_hal_output_buffer(inst);
buffer_info.num_buffers = 1;
buffer_info.align_device_addr = b->m.planes[0].m.userptr;
buffer_info.response_required = false;
extra_idx = EXTRADATA_IDX(b->length);
if (extra_idx && extra_idx < VIDEO_MAX_PLANES
&& b->m.planes[extra_idx].m.userptr)
buffer_info.extradata_addr =
b->m.planes[extra_idx].m.userptr;
else
buffer_info.extradata_addr = 0;
rc = call_hfi_op(hdev, session_release_buffers,
(void *)inst->session, &buffer_info);
if (rc)
dprintk(VIDC_ERR,
"vidc_hal_session_release_buffers failed\n");
break;
default:
dprintk(VIDC_ERR, "Buffer type not recognized: %d\n", b->type);
break;
}
exit:
return rc;
}
int msm_vdec_qbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b)
{
struct buf_queue *q = NULL;

View file

@ -24,8 +24,6 @@ int msm_vdec_s_fmt(void *instance, struct v4l2_format *f);
int msm_vdec_g_fmt(void *instance, struct v4l2_format *f);
int msm_vdec_s_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
int msm_vdec_reqbufs(void *instance, struct v4l2_requestbuffers *b);
int msm_vdec_prepare_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_vdec_release_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_vdec_qbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_vdec_dqbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_vdec_streamon(struct msm_vidc_inst *inst, enum v4l2_buf_type i);

View file

@ -3211,144 +3211,6 @@ int msm_venc_reqbufs(struct msm_vidc_inst *inst, struct v4l2_requestbuffers *b)
return rc;
}
int msm_venc_prepare_buf(struct msm_vidc_inst *inst,
struct v4l2_buffer *b)
{
int rc = 0;
int i;
struct vidc_buffer_addr_info buffer_info = {0};
struct hfi_device *hdev;
int extra_idx = 0;
if (!inst || !inst->core || !inst->core->device) {
dprintk(VIDC_ERR, "%s invalid parameters\n", __func__);
return -EINVAL;
}
hdev = inst->core->device;
if (inst->state == MSM_VIDC_CORE_INVALID ||
inst->core->state == VIDC_CORE_INVALID) {
dprintk(VIDC_ERR,
"Core %pK in bad state, ignoring prepare buf\n",
inst->core);
goto exit;
}
switch (b->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:
if (b->length != inst->fmts[CAPTURE_PORT].num_planes) {
dprintk(VIDC_ERR,
"Planes mismatch: needed: %d, allocated: %d\n",
inst->fmts[CAPTURE_PORT].num_planes,
b->length);
rc = -EINVAL;
break;
}
for (i = 0; i < min_t(int, b->length, VIDEO_MAX_PLANES); i++) {
dprintk(VIDC_DBG, "device_addr = %#lx, size = %d\n",
b->m.planes[i].m.userptr,
b->m.planes[i].length);
}
buffer_info.buffer_size = b->m.planes[0].length;
buffer_info.buffer_type = HAL_BUFFER_OUTPUT;
buffer_info.num_buffers = 1;
buffer_info.align_device_addr =
b->m.planes[0].m.userptr;
extra_idx = EXTRADATA_IDX(b->length);
if (extra_idx && (extra_idx < VIDEO_MAX_PLANES)) {
buffer_info.extradata_addr =
b->m.planes[extra_idx].m.userptr;
dprintk(VIDC_DBG, "extradata: %#lx\n",
b->m.planes[extra_idx].m.userptr);
buffer_info.extradata_size =
b->m.planes[extra_idx].length;
}
rc = call_hfi_op(hdev, session_set_buffers,
(void *)inst->session, &buffer_info);
if (rc)
dprintk(VIDC_ERR,
"vidc_hal_session_set_buffers failed\n");
break;
default:
dprintk(VIDC_ERR,
"Buffer type not recognized: %d\n", b->type);
break;
}
exit:
return rc;
}
int msm_venc_release_buf(struct msm_vidc_inst *inst,
struct v4l2_buffer *b)
{
int i, rc = 0, extra_idx = 0;
struct vidc_buffer_addr_info buffer_info = {0};
struct hfi_device *hdev;
if (!inst || !inst->core || !inst->core->device) {
dprintk(VIDC_ERR, "%s invalid parameters\n", __func__);
return -EINVAL;
}
hdev = inst->core->device;
rc = msm_comm_try_state(inst, MSM_VIDC_RELEASE_RESOURCES_DONE);
if (rc) {
dprintk(VIDC_ERR,
"Failed to move inst: %pK to release res done state\n",
inst);
goto exit;
}
switch (b->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: {
if (b->length !=
inst->fmts[CAPTURE_PORT].num_planes) {
dprintk(VIDC_ERR,
"Planes mismatch: needed: %d, to release: %d\n",
inst->fmts[CAPTURE_PORT].num_planes,
b->length);
rc = -EINVAL;
break;
}
for (i = 0; i < b->length; i++) {
dprintk(VIDC_DBG,
"Release device_addr = %#lx, size = %d, %d\n",
b->m.planes[i].m.userptr,
b->m.planes[i].length, inst->state);
}
buffer_info.buffer_size = b->m.planes[0].length;
buffer_info.buffer_type = HAL_BUFFER_OUTPUT;
buffer_info.num_buffers = 1;
buffer_info.align_device_addr =
b->m.planes[0].m.userptr;
extra_idx = EXTRADATA_IDX(b->length);
if (extra_idx && (extra_idx < VIDEO_MAX_PLANES))
buffer_info.extradata_addr =
b->m.planes[extra_idx].m.userptr;
buffer_info.response_required = false;
rc = call_hfi_op(hdev, session_release_buffers,
(void *)inst->session, &buffer_info);
if (rc)
dprintk(VIDC_ERR,
"vidc_hal_session_release_buffers failed\n");
}
break;
default:
dprintk(VIDC_ERR, "Buffer type not recognized: %d\n", b->type);
break;
}
exit:
return rc;
}
int msm_venc_qbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b)
{
struct buf_queue *q = NULL;

View file

@ -24,8 +24,6 @@ int msm_venc_s_fmt(void *instance, struct v4l2_format *f);
int msm_venc_g_fmt(void *instance, struct v4l2_format *f);
int msm_venc_s_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
int msm_venc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
int msm_venc_prepare_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_venc_release_buf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_venc_qbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_venc_dqbuf(struct msm_vidc_inst *inst, struct v4l2_buffer *b);
int msm_venc_streamon(struct msm_vidc_inst *inst, enum v4l2_buf_type i);

View file

@ -692,37 +692,10 @@ static bool valid_v4l2_buffer(struct v4l2_buffer *b,
inst->fmts[port].num_planes == b->length;
}
int msm_vidc_prepare_buf(void *instance, struct v4l2_buffer *b)
{
struct msm_vidc_inst *inst = instance;
if (!inst || !inst->core || !b || !valid_v4l2_buffer(b, inst))
return -EINVAL;
if (inst->state == MSM_VIDC_CORE_INVALID ||
inst->core->state == VIDC_CORE_INVALID)
return -EINVAL;
if (is_dynamic_output_buffer_mode(b, inst))
return 0;
if (map_and_register_buf(inst, b))
return -EINVAL;
if (inst->session_type == MSM_VIDC_DECODER)
return msm_vdec_prepare_buf(instance, b);
if (inst->session_type == MSM_VIDC_ENCODER)
return msm_venc_prepare_buf(instance, b);
return -EINVAL;
}
EXPORT_SYMBOL(msm_vidc_prepare_buf);
int msm_vidc_release_buffers(void *instance, int buffer_type)
{
struct msm_vidc_inst *inst = instance;
struct buffer_info *bi, *dummy;
struct v4l2_buffer buffer_info;
struct v4l2_plane plane[VIDEO_MAX_PLANES];
int i, rc = 0;
if (!inst)
@ -739,58 +712,6 @@ int msm_vidc_release_buffers(void *instance, int buffer_type)
}
}
/*
* In dynamic buffer mode, driver needs to release resources,
* but not call release buffers on firmware, as the buffers
* were never registered with firmware.
*/
if (buffer_type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&
inst->buffer_mode_set[CAPTURE_PORT] ==
HAL_BUFFER_MODE_DYNAMIC) {
goto free_and_unmap;
}
mutex_lock(&inst->registeredbufs.lock);
list_for_each_entry(bi, &inst->registeredbufs.list, list) {
bool release_buf = false;
if (bi->type == buffer_type) {
buffer_info.type = bi->type;
for (i = 0; i < min(bi->num_planes, VIDEO_MAX_PLANES);
i++) {
plane[i].reserved[0] = bi->fd[i];
plane[i].reserved[1] = bi->buff_off[i];
plane[i].length = bi->size[i];
plane[i].m.userptr = bi->device_addr[i];
buffer_info.m.planes = plane;
dprintk(VIDC_DBG,
"Releasing buffer: %d, %d, %d\n",
buffer_info.m.planes[i].reserved[0],
buffer_info.m.planes[i].reserved[1],
buffer_info.m.planes[i].length);
}
buffer_info.length = bi->num_planes;
release_buf = true;
}
if (!release_buf)
continue;
if (inst->session_type == MSM_VIDC_DECODER)
rc = msm_vdec_release_buf(instance,
&buffer_info);
if (inst->session_type == MSM_VIDC_ENCODER)
rc = msm_venc_release_buf(instance,
&buffer_info);
if (rc)
dprintk(VIDC_ERR,
"Failed Release buffer: %d, %d, %d\n",
buffer_info.m.planes[0].reserved[0],
buffer_info.m.planes[0].reserved[1],
buffer_info.m.planes[0].length);
}
mutex_unlock(&inst->registeredbufs.lock);
free_and_unmap:
mutex_lock(&inst->registeredbufs.lock);
list_for_each_entry_safe(bi, dummy, &inst->registeredbufs.list, list) {
if (bi->type == buffer_type) {