Merge "msm: vdec: Allocate max internal buffers"
This commit is contained in:
commit
7aa065cbc4
4 changed files with 47 additions and 65 deletions
drivers/media/platform/msm/vidc
|
@ -1571,9 +1571,10 @@ exit:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static inline int set_max_internal_buffers_size(struct msm_vidc_inst *inst)
|
||||
static int set_max_internal_buffers_size(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int rc = 0;
|
||||
struct msm_vidc_list *buf_list = &inst->scratchbufs;
|
||||
struct {
|
||||
enum hal_buffer type;
|
||||
struct hal_buffer_requirements *req;
|
||||
|
@ -1581,13 +1582,17 @@ static inline int set_max_internal_buffers_size(struct msm_vidc_inst *inst)
|
|||
} internal_buffers[] = {
|
||||
{ HAL_BUFFER_INTERNAL_SCRATCH, NULL, 0},
|
||||
{ HAL_BUFFER_INTERNAL_SCRATCH_1, NULL, 0},
|
||||
{ HAL_BUFFER_INTERNAL_SCRATCH_2, NULL, 0},
|
||||
{ HAL_BUFFER_INTERNAL_PERSIST, NULL, 0},
|
||||
{ HAL_BUFFER_INTERNAL_PERSIST_1, NULL, 0},
|
||||
};
|
||||
|
||||
struct hal_frame_size frame_sz;
|
||||
int i;
|
||||
mutex_lock(&buf_list->lock);
|
||||
if (!list_empty(&buf_list->list)) {
|
||||
dprintk(VIDC_DBG, "Scratch list already has allocated buf\n");
|
||||
mutex_unlock(&buf_list->lock);
|
||||
return 0;
|
||||
}
|
||||
mutex_unlock(&buf_list->lock);
|
||||
|
||||
frame_sz.buffer_type = HAL_BUFFER_INPUT;
|
||||
frame_sz.width = inst->capability.width.max;
|
||||
|
@ -1613,6 +1618,15 @@ static inline int set_max_internal_buffers_size(struct msm_vidc_inst *inst)
|
|||
get_buff_req_buffer(inst, internal_buffers[i].type);
|
||||
internal_buffers[i].size = internal_buffers[i].req ?
|
||||
internal_buffers[i].req->buffer_size : 0;
|
||||
|
||||
rc = allocate_and_set_internal_bufs(inst,
|
||||
internal_buffers[i].req,
|
||||
&inst->scratchbufs, false);
|
||||
if (rc)
|
||||
goto alloc_fail;
|
||||
dprintk(VIDC_DBG,
|
||||
"Allocated scratch type : %d size to : %zd\n",
|
||||
internal_buffers[i].type, internal_buffers[i].size);
|
||||
}
|
||||
|
||||
frame_sz.buffer_type = HAL_BUFFER_INPUT;
|
||||
|
@ -1625,25 +1639,18 @@ static inline int set_max_internal_buffers_size(struct msm_vidc_inst *inst)
|
|||
dprintk(VIDC_ERR,
|
||||
"%s Failed to get back old buf req, %d\n",
|
||||
__func__, rc);
|
||||
return rc;
|
||||
goto alloc_fail;
|
||||
}
|
||||
|
||||
dprintk(VIDC_DBG,
|
||||
"Old buffer reqs, buffer type = %d width = %d, height = %d\n",
|
||||
frame_sz.buffer_type, frame_sz.width,
|
||||
frame_sz.height);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(internal_buffers); i++) {
|
||||
if (internal_buffers[i].req) {
|
||||
internal_buffers[i].req->buffer_size =
|
||||
internal_buffers[i].size;
|
||||
dprintk(VIDC_DBG,
|
||||
"Changing buffer type : %d size to : %zd\n",
|
||||
internal_buffers[i].type,
|
||||
internal_buffers[i].size);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
alloc_fail:
|
||||
msm_comm_release_scratch_buffers(inst, false);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static inline int start_streaming(struct msm_vidc_inst *inst)
|
||||
|
@ -1654,6 +1661,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
|
|||
struct hal_buffer_size_minimum b;
|
||||
unsigned int buffer_size;
|
||||
struct msm_vidc_format *fmt = NULL;
|
||||
bool max_internal_buf = false;
|
||||
|
||||
fmt = &inst->fmts[CAPTURE_PORT];
|
||||
buffer_size = fmt->get_frame_size(0,
|
||||
|
@ -1677,8 +1685,9 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
|
|||
dprintk(VIDC_ERR, "H/w scaling is not in valid range\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((inst->flags & VIDC_SECURE) && !inst->in_reconfig &&
|
||||
!slave_side_cp) {
|
||||
max_internal_buf = (inst->flags & VIDC_SECURE) && !slave_side_cp
|
||||
&& (inst->session_type == MSM_VIDC_DECODER);
|
||||
if (max_internal_buf) {
|
||||
rc = set_max_internal_buffers_size(inst);
|
||||
if (rc) {
|
||||
dprintk(VIDC_ERR,
|
||||
|
@ -1687,7 +1696,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
|
|||
goto fail_start;
|
||||
}
|
||||
}
|
||||
rc = msm_comm_set_scratch_buffers(inst);
|
||||
rc = msm_comm_set_scratch_buffers(inst, max_internal_buf);
|
||||
if (rc) {
|
||||
dprintk(VIDC_ERR,
|
||||
"Failed to set scratch buffers: %d\n", rc);
|
||||
|
|
|
@ -1868,7 +1868,7 @@ static inline int start_streaming(struct msm_vidc_inst *inst)
|
|||
"Failed to get Buffer Requirements : %d\n", rc);
|
||||
goto fail_start;
|
||||
}
|
||||
rc = msm_comm_set_scratch_buffers(inst);
|
||||
rc = msm_comm_set_scratch_buffers(inst, false);
|
||||
if (rc) {
|
||||
dprintk(VIDC_ERR, "Failed to set scratch buffers: %d\n", rc);
|
||||
goto fail_start;
|
||||
|
|
|
@ -3342,9 +3342,9 @@ static bool reuse_internal_buffers(struct msm_vidc_inst *inst,
|
|||
return reused;
|
||||
}
|
||||
|
||||
static int allocate_and_set_internal_bufs(struct msm_vidc_inst *inst,
|
||||
int allocate_and_set_internal_bufs(struct msm_vidc_inst *inst,
|
||||
struct hal_buffer_requirements *internal_bufreq,
|
||||
struct msm_vidc_list *buf_list)
|
||||
struct msm_vidc_list *buf_list, bool set_on_fw)
|
||||
{
|
||||
struct msm_smem *handle;
|
||||
struct internal_buf *binfo;
|
||||
|
@ -3381,11 +3381,13 @@ static int allocate_and_set_internal_bufs(struct msm_vidc_inst *inst,
|
|||
binfo->handle = handle;
|
||||
binfo->buffer_type = internal_bufreq->buffer_type;
|
||||
|
||||
rc = set_internal_buf_on_fw(inst, internal_bufreq->buffer_type,
|
||||
handle, false);
|
||||
if (rc)
|
||||
goto fail_set_buffers;
|
||||
|
||||
if (set_on_fw) {
|
||||
rc = set_internal_buf_on_fw(inst,
|
||||
internal_bufreq->buffer_type,
|
||||
handle, false);
|
||||
if (rc)
|
||||
goto fail_set_buffers;
|
||||
}
|
||||
mutex_lock(&buf_list->lock);
|
||||
list_add_tail(&binfo->list, &buf_list->list);
|
||||
mutex_unlock(&buf_list->lock);
|
||||
|
@ -3426,7 +3428,7 @@ static int set_internal_buffers(struct msm_vidc_inst *inst,
|
|||
return 0;
|
||||
|
||||
return allocate_and_set_internal_bufs(inst, internal_buf,
|
||||
buf_list);
|
||||
buf_list, true);
|
||||
}
|
||||
|
||||
int msm_comm_try_state(struct msm_vidc_inst *inst, int state)
|
||||
|
@ -3587,39 +3589,6 @@ int msm_vidc_comm_cmd(void *instance, union msm_v4l2_cmd *cmd)
|
|||
"Failed to flush buffers: %d\n", rc);
|
||||
}
|
||||
break;
|
||||
case V4L2_DEC_QCOM_CMD_RECONFIG_HINT:
|
||||
{
|
||||
u32 *ptr = NULL;
|
||||
struct hal_buffer_requirements *output_buf;
|
||||
|
||||
rc = msm_comm_try_get_bufreqs(inst);
|
||||
if (rc) {
|
||||
dprintk(VIDC_ERR,
|
||||
"Getting buffer requirements failed: %d\n",
|
||||
rc);
|
||||
break;
|
||||
}
|
||||
|
||||
output_buf = get_buff_req_buffer(inst,
|
||||
msm_comm_get_hal_output_buffer(inst));
|
||||
if (output_buf) {
|
||||
if (dec) {
|
||||
ptr = (u32 *)dec->raw.data;
|
||||
ptr[0] = output_buf->buffer_size;
|
||||
ptr[1] = output_buf->buffer_count_actual;
|
||||
dprintk(VIDC_DBG,
|
||||
"Reconfig hint, size is %u, count is %u\n",
|
||||
ptr[0], ptr[1]);
|
||||
} else {
|
||||
dprintk(VIDC_ERR, "Null decoder\n");
|
||||
}
|
||||
} else {
|
||||
dprintk(VIDC_DBG,
|
||||
"This output buffer not required, buffer_type: %x\n",
|
||||
HAL_BUFFER_OUTPUT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
dprintk(VIDC_ERR, "Unknown Command %d\n", which_cmd);
|
||||
rc = -ENOTSUPP;
|
||||
|
@ -4453,15 +4422,15 @@ error:
|
|||
return rc;
|
||||
}
|
||||
|
||||
int msm_comm_set_scratch_buffers(struct msm_vidc_inst *inst)
|
||||
{
|
||||
int msm_comm_set_scratch_buffers(struct msm_vidc_inst *inst,
|
||||
bool max_int_buffer) {
|
||||
int rc = 0;
|
||||
if (!inst || !inst->core || !inst->core->device) {
|
||||
dprintk(VIDC_ERR, "%s invalid parameters\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (msm_comm_release_scratch_buffers(inst, true))
|
||||
if (!max_int_buffer && msm_comm_release_scratch_buffers(inst, true))
|
||||
dprintk(VIDC_WARN, "Failed to release scratch buffers\n");
|
||||
|
||||
rc = set_internal_buffers(inst, HAL_BUFFER_INTERNAL_SCRATCH,
|
||||
|
|
|
@ -41,9 +41,13 @@ int msm_comm_try_set_prop(struct msm_vidc_inst *inst,
|
|||
enum hal_property ptype, void *pdata);
|
||||
int msm_comm_try_get_prop(struct msm_vidc_inst *inst,
|
||||
enum hal_property ptype, union hal_get_property *hprop);
|
||||
int msm_comm_set_scratch_buffers(struct msm_vidc_inst *inst);
|
||||
int msm_comm_set_scratch_buffers(struct msm_vidc_inst *inst,
|
||||
bool max_int_buffer);
|
||||
int msm_comm_set_persist_buffers(struct msm_vidc_inst *inst);
|
||||
int msm_comm_set_output_buffers(struct msm_vidc_inst *inst);
|
||||
int allocate_and_set_internal_bufs(struct msm_vidc_inst *inst,
|
||||
struct hal_buffer_requirements *internal_bufreq,
|
||||
struct msm_vidc_list *buf_list, bool set_on_fw);
|
||||
int msm_comm_queue_output_buffers(struct msm_vidc_inst *inst);
|
||||
int msm_comm_qbuf(struct msm_vidc_inst *inst, struct vb2_buffer *vb);
|
||||
void msm_comm_scale_clocks_and_bus(struct msm_vidc_inst *inst);
|
||||
|
|
Loading…
Add table
Reference in a new issue