Merge "msm: vidc: Update DCVS thresholds for sufficient seq change"

This commit is contained in:
qctecmdr 2020-08-03 17:44:16 -07:00 • committed by Gerrit - the friendly Code Review server
commit a742fc9e9a
6 changed files with 86 additions and 46 deletions

View file

@ -1412,13 +1412,13 @@ static int try_get_ctrl_for_instance(struct msm_vidc_inst *inst,
break;
case V4L2_CID_MIN_BUFFERS_FOR_CAPTURE:
ctrl->val = inst->fmts[OUTPUT_PORT].count_min_host;
s_vpr_h(inst->sid, "g_min: hal_buffer %d min buffers %d\n",
HAL_BUFFER_OUTPUT, ctrl->val);
s_vpr_h(inst->sid, "g_min: OUTPUT_PORT count_min_host %d\n",
ctrl->val);
break;
case V4L2_CID_MIN_BUFFERS_FOR_OUTPUT:
ctrl->val = inst->fmts[INPUT_PORT].count_min_host;
s_vpr_h(inst->sid, "g_min: hal_buffer %d min buffers %d\n",
HAL_BUFFER_INPUT, ctrl->val);
s_vpr_h(inst->sid, "g_min: INPUT_PORT count_min_host %d\n",
ctrl->val);
break;
case V4L2_CID_MPEG_VIDC_VIDEO_EXTRADATA:
ctrl->val = inst->prop.extradata_ctrls;

View file

@ -790,11 +790,10 @@ static int msm_vidc_get_extra_input_buff_count(struct msm_vidc_inst *inst)
core = inst->core;
/*
* For a non-realtime session, extra buffers are not required.
* For thumbnail session, extra buffers are not required as
* neither dcvs nor batching will be enabled.
*/
if (!is_realtime_session(inst) || is_thumbnail_session(inst))
if (is_thumbnail_session(inst))
return extra_input_count;
if (is_decode_session(inst)) {

View file

@ -6,9 +6,9 @@
#ifndef __H_MSM_VIDC_BUFFER_MEM_DEFS_H__
#define __H_MSM_VIDC_BUFFER_MEM_DEFS_H__
/* extra o/p buffers in case of dcvs */
/* extra buffers in case of dcvs */
#define DCVS_DEC_EXTRA_OUTPUT_BUFFERS 4
#define DCVS_ENC_EXTRA_INPUT_BUFFERS DCVS_DEC_EXTRA_OUTPUT_BUFFERS
#define DCVS_ENC_EXTRA_INPUT_BUFFERS 4
struct msm_vidc_dec_buff_size_calculators {
u32 (*calculate_scratch_size)(struct msm_vidc_inst *inst, u32 width,

View file

@ -1008,6 +1008,53 @@ int msm_dcvs_try_enable(struct msm_vidc_inst *inst)
return 0;
}
void msm_dcvs_reset(struct msm_vidc_inst *inst)
{
struct msm_vidc_format *fmt;
struct clock_data *dcvs;
if (!inst) {
d_vpr_e("%s: Invalid params\n", __func__);
return;
}
dcvs = &inst->clk_data;
if (inst->session_type == MSM_VIDC_ENCODER) {
fmt = &inst->fmts[INPUT_PORT];
} else if (inst->session_type == MSM_VIDC_DECODER) {
fmt = &inst->fmts[OUTPUT_PORT];
} else {
s_vpr_e(inst->sid, "%s: invalid session type %#x\n",
__func__, inst->session_type);
return;
}
dcvs->min_threshold = fmt->count_min;
if (inst->session_type == MSM_VIDC_ENCODER)
dcvs->max_threshold =
min((fmt->count_min + DCVS_ENC_EXTRA_INPUT_BUFFERS),
fmt->count_actual);
else
dcvs->max_threshold =
min((fmt->count_min + DCVS_DEC_EXTRA_OUTPUT_BUFFERS),
fmt->count_actual);
dcvs->dcvs_window =
dcvs->max_threshold < dcvs->min_threshold ? 0 :
dcvs->max_threshold - dcvs->min_threshold;
dcvs->nom_threshold = dcvs->min_threshold +
(dcvs->dcvs_window ?
(dcvs->dcvs_window / 2) : 0);
dcvs->dcvs_flags = 0;
s_vpr_p(inst->sid, "DCVS: Th[%d %d %d] Flag %#x\n",
dcvs->min_threshold,
dcvs->nom_threshold, dcvs->max_threshold,
dcvs->dcvs_flags);
}
int msm_comm_init_clocks_and_bus_data(struct msm_vidc_inst *inst)
{
int rc = 0, j = 0;
@ -1048,8 +1095,6 @@ void msm_clock_data_reset(struct msm_vidc_inst *inst)
struct allowed_clock_rates_table *allowed_clks_tbl = NULL;
u64 total_freq = 0, rate = 0, load;
int cycles;
struct clock_data *dcvs;
struct msm_vidc_format *fmt;
if (!inst || !inst->core || !inst->clk_data.entry) {
d_vpr_e("%s: Invalid args: Inst = %pK\n",
@ -1059,35 +1104,14 @@ void msm_clock_data_reset(struct msm_vidc_inst *inst)
s_vpr_h(inst->sid, "Init DCVS Load\n");
core = inst->core;
dcvs = &inst->clk_data;
load = msm_comm_get_inst_load_per_core(inst, LOAD_POWER);
cycles = inst->clk_data.entry->vpp_cycles;
allowed_clks_tbl = core->resources.allowed_clks_tbl;
if (inst->session_type == MSM_VIDC_ENCODER) {
cycles = inst->flags & VIDC_LOW_POWER ?
inst->clk_data.entry->low_power_cycles :
cycles;
if (inst->session_type == MSM_VIDC_ENCODER &&
inst->flags & VIDC_LOW_POWER)
cycles = inst->clk_data.entry->low_power_cycles;
fmt = &inst->fmts[INPUT_PORT];
} else if (inst->session_type == MSM_VIDC_DECODER) {
fmt = &inst->fmts[OUTPUT_PORT];
} else {
s_vpr_e(inst->sid, "%s: invalid session type %#x\n",
__func__, inst->session_type);
return;
}
dcvs->min_threshold = fmt->count_min;
dcvs->max_threshold =
min((fmt->count_min + DCVS_DEC_EXTRA_OUTPUT_BUFFERS),
fmt->count_actual);
dcvs->dcvs_window =
dcvs->max_threshold < dcvs->min_threshold ? 0 :
dcvs->max_threshold - dcvs->min_threshold;
dcvs->nom_threshold = dcvs->min_threshold +
(dcvs->dcvs_window ?
(dcvs->dcvs_window / 2) : 0);
msm_dcvs_reset(inst);
total_freq = cycles * load;

View file

@ -8,6 +8,7 @@
#include "msm_vidc_internal.h"
void msm_clock_data_reset(struct msm_vidc_inst *inst);
void msm_dcvs_reset(struct msm_vidc_inst *inst);
int msm_vidc_set_clocks(struct msm_vidc_core *core, u32 sid);
int msm_comm_vote_bus(struct msm_vidc_inst *inst);
int msm_dcvs_try_enable(struct msm_vidc_inst *inst);

View file

@ -1598,7 +1598,6 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
struct hfi_device *hdev;
u32 *ptr = NULL;
struct msm_vidc_format *fmt;
struct v4l2_format *f;
u32 codec;
if (!event_notify) {
@ -1650,11 +1649,12 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
inst->pic_struct == MSM_VIDC_PIC_STRUCT_MAYBE_INTERLACED))
event_fields_changed = true;
f = &inst->fmts[OUTPUT_PORT].v4l2_fmt;
fmt = &inst->fmts[OUTPUT_PORT];
event_fields_changed |=
(f->fmt.pix_mp.height != event_notify->height);
(fmt->v4l2_fmt.fmt.pix_mp.height !=
event_notify->height);
event_fields_changed |=
(f->fmt.pix_mp.width != event_notify->width);
(fmt->v4l2_fmt.fmt.pix_mp.width != event_notify->width);
if (event_fields_changed) {
event = V4L2_EVENT_SEQ_CHANGED_INSUFFICIENT;
@ -1670,6 +1670,10 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
"%s: Failed to decide work mode\n",
__func__);
}
fmt->count_min = event_notify->fw_min_cnt;
msm_dcvs_reset(inst);
s_vpr_h(inst->sid,
"seq: No parameter change continue session\n");
rc = call_hfi_op(hdev, session_continue,
@ -2809,6 +2813,7 @@ bool is_batching_allowed(struct msm_vidc_inst *inst)
{
u32 op_pixelformat, fps, maxmbs, maxfps;
u32 ignore_flags = VIDC_THUMBNAIL;
u32 enable = 0;
if (!inst || !inst->core)
return false;
@ -2827,17 +2832,23 @@ bool is_batching_allowed(struct msm_vidc_inst *inst)
* as sufficient extra buffers (required for batch mode
* on both ports) may not have been updated to client.
*/
return (inst->batch.enable &&
enable = (inst->batch.enable &&
inst->core->resources.decode_batching &&
!is_low_latency_hint(inst) &&
is_single_session(inst, ignore_flags) &&
is_decode_session(inst) &&
!is_thumbnail_session(inst) &&
is_realtime_session(inst) &&
!inst->clk_data.low_latency_mode &&
(op_pixelformat == V4L2_PIX_FMT_NV12_UBWC ||
op_pixelformat == V4L2_PIX_FMT_NV12_TP10_UBWC) &&
fps <= maxfps &&
msm_vidc_get_mbs_per_frame(inst) <= maxmbs);
s_vpr_hp(inst->sid, "%s: batching %s\n",
__func__, enable ? "enabled" : "disabled");
return enable;
}
static int msm_comm_session_abort(struct msm_vidc_inst *inst)
@ -4941,7 +4952,10 @@ int msm_comm_try_get_bufreqs(struct msm_vidc_inst *inst)
for (i = 0; i < HAL_BUFFER_MAX; i++) {
struct hal_buffer_requirements req = inst->buff_req.buffer[i];
if (req.buffer_type != HAL_BUFFER_NONE) {
if (req.buffer_type != HAL_BUFFER_NONE &&
req.buffer_type != HAL_BUFFER_INPUT &&
req.buffer_type != HAL_BUFFER_OUTPUT &&
req.buffer_type != HAL_BUFFER_OUTPUT2) {
s_vpr_h(inst->sid, "%15s %8d %8d %8d %8d %8d\n",
get_buffer_name(req.buffer_type),
req.buffer_count_actual,
@ -5319,7 +5333,7 @@ int msm_comm_release_persist_buffers(struct msm_vidc_inst *inst)
}
int msm_comm_set_buffer_count(struct msm_vidc_inst *inst,
int host_count, int act_count, enum hal_buffer type)
int min_count, int act_count, enum hal_buffer type)
{
int rc = 0;
struct v4l2_ctrl *ctrl;
@ -5334,20 +5348,22 @@ int msm_comm_set_buffer_count(struct msm_vidc_inst *inst,
buf_count.buffer_type = get_hfi_buffer(type, inst->sid);
buf_count.buffer_count_actual = act_count;
buf_count.buffer_count_min_host = host_count;
buf_count.buffer_count_min_host = min_count;
/* set total superframe buffers count */
ctrl = get_ctrl(inst, V4L2_CID_MPEG_VIDC_SUPERFRAME);
if (ctrl->val)
buf_count.buffer_count_actual = act_count * ctrl->val;
s_vpr_h(inst->sid, "%s: hal_buffer %d min_host %d actual %d\n",
__func__, type, host_count, act_count);
s_vpr_h(inst->sid,
"%s: hal_buffer %d min %d actual %d superframe %d\n",
__func__, type, min_count,
buf_count.buffer_count_actual, ctrl->val);
rc = call_hfi_op(hdev, session_set_property,
inst->session, HFI_PROPERTY_PARAM_BUFFER_COUNT_ACTUAL,
&buf_count, sizeof(buf_count));
if (rc)
s_vpr_e(inst->sid,
"Failed to set actual buffer count %d for buffer type %d\n",
act_count, type);
buf_count.buffer_count_actual, type);
return rc;
}