video: driver: ring buffer enhancements

1. use max of operating and frame rate for fps
2. vpp_cycles is considered close to frequency
   corner if vpp_min_freq is greater than max
   required frequency

Change-Id: I9dc995ca16e4eeae18497a8648dfef64e16dfbc2
Signed-off-by: Deepa Guthyappa Madivalara <quic_dmadival@quicinc.com>
This commit is contained in:
Deepa Guthyappa Madivalara
2023-04-26 15:43:34 -07:00
parent fdc186d299
commit def6b6328b
3 changed files with 54 additions and 30 deletions

View File

@@ -333,6 +333,7 @@ static int msm_vidc_set_ring_buffer_count_pineapple(void *instance,
struct v4l2_format *output_fmt, *input_fmt;
struct msm_vidc_core* core;
u32 count = 0, data_size = 0, pixel_count = 0, fps = 0;
u32 frame_rate = 0, operating_rate = 0;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
@@ -342,30 +343,39 @@ static int msm_vidc_set_ring_buffer_count_pineapple(void *instance,
output_fmt = &inst->fmts[OUTPUT_PORT];
input_fmt = &inst->fmts[INPUT_PORT];
fps = inst->capabilities[FRAME_RATE].value >> 16;
frame_rate = inst->capabilities[FRAME_RATE].value >> 16;
operating_rate = inst->capabilities[OPERATING_RATE].value >> 16;
fps = max(frame_rate, operating_rate);
pixel_count = output_fmt->fmt.pix_mp.width *
output_fmt->fmt.pix_mp.height;
/* check if current session supports ring buffer enablement */
if (!(pixel_count >= 7680 * 4320 && fps >= 30) &&
!(pixel_count >= 3840 * 2160 && fps >= 120) &&
!(pixel_count >= 1920 * 1080 && fps >= 480) &&
!(pixel_count >= 1280 * 720 && fps >= 960)) {
i_vpr_h(inst,
"%s: session %ux%u@%u fps does not support ring buffer\n",
__func__, output_fmt->fmt.pix_mp.width,
output_fmt->fmt.pix_mp.height, fps);
inst->capabilities[cap_id].value = 0;
} else {
/*
* try to enable ring buffer feature if
 * resolution >= 8k and fps >= 30fps and
 * resolution >= 4k and fps >= 120fps and
 * resolution >= 1080p and fps >= 480fps and
 * resolution >= 720p and fps >= 960fps
*/
if ((pixel_count >= 7680 * 4320 && fps >= 30) ||
(pixel_count >= 3840 * 2160 && fps >= 120) ||
(pixel_count >= 1920 * 1080 && fps >= 480) ||
(pixel_count >= 1280 * 720 && fps >= 960)) {
data_size = input_fmt->fmt.pix_mp.plane_fmt[0].sizeimage;
i_vpr_h(inst, "%s: calculate ring buffer count\n", __func__);
rc = call_session_op(core, ring_buf_count, inst, data_size);
if (rc) {
i_vpr_e(inst, "%s: failed to calculate ring buf count\n",
i_vpr_e(inst, "%s: failed to calculate ring buffer count\n",
__func__);
/* ignore error */
rc = 0;
inst->capabilities[cap_id].value = 0;
}
} else {
i_vpr_h(inst,
"%s: session %ux%u@%u fps does not support ring buffer\n",
__func__, output_fmt->fmt.pix_mp.width,
output_fmt->fmt.pix_mp.height, fps);
inst->capabilities[cap_id].value = 0;
}
count = inst->capabilities[cap_id].value;

View File

@@ -232,6 +232,7 @@ static int msm_vidc_set_ring_buffer_count_pineapple(void *instance,
struct v4l2_format *output_fmt, *input_fmt;
struct msm_vidc_core* core;
u32 count = 0, data_size = 0, pixel_count = 0, fps = 0;
u32 frame_rate = 0, operating_rate = 0;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
@@ -241,22 +242,25 @@ static int msm_vidc_set_ring_buffer_count_pineapple(void *instance,
output_fmt = &inst->fmts[OUTPUT_PORT];
input_fmt = &inst->fmts[INPUT_PORT];
fps = inst->capabilities[FRAME_RATE].value >> 16;
frame_rate = inst->capabilities[FRAME_RATE].value >> 16;
operating_rate = inst->capabilities[OPERATING_RATE].value >> 16;
fps = max(frame_rate, operating_rate);
pixel_count = output_fmt->fmt.pix_mp.width *
output_fmt->fmt.pix_mp.height;
/* check if current session supports ring buffer enablement */
if (!(pixel_count >= 7680 * 4320 && fps >= 30) &&
!(pixel_count >= 3840 * 2160 && fps >= 120) &&
!(pixel_count >= 1920 * 1080 && fps >= 480) &&
!(pixel_count >= 1280 * 720 && fps >= 960)) {
i_vpr_h(inst,
"%s: session %ux%u@%u fps does not support ring buffer\n",
__func__, output_fmt->fmt.pix_mp.width,
output_fmt->fmt.pix_mp.height, fps);
inst->capabilities[cap_id].value = 0;
} else {
/*
* try to enable ring buffer feature if
 * resolution >= 8k and fps >= 30fps and
 * resolution >= 4k and fps >= 120fps and
 * resolution >= 1080p and fps >= 480fps and
 * resolution >= 720p and fps >= 960fps
*/
if ((pixel_count >= 7680 * 4320 && fps >= 30) &&
(pixel_count >= 3840 * 2160 && fps >= 120) &&
(pixel_count >= 1920 * 1080 && fps >= 480) &&
(pixel_count >= 1280 * 720 && fps >= 960)) {
data_size = input_fmt->fmt.pix_mp.plane_fmt[0].sizeimage;
i_vpr_h(inst, "%s: calculate ring buffer count\n", __func__);
rc = call_session_op(core, ring_buf_count, inst, data_size);
if (rc) {
i_vpr_e(inst, "%s: failed to calculate ring buf count\n",
@@ -265,6 +269,12 @@ static int msm_vidc_set_ring_buffer_count_pineapple(void *instance,
rc = 0;
inst->capabilities[cap_id].value = 0;
}
} else {
i_vpr_h(inst,
"%s: session %ux%u@%u fps does not support ring buffer\n",
__func__, output_fmt->fmt.pix_mp.width,
output_fmt->fmt.pix_mp.height, fps);
inst->capabilities[cap_id].value = 0;
}
count = inst->capabilities[cap_id].value;

View File

@@ -380,8 +380,9 @@ static bool is_vpp_cycles_close_to_freq_corner(struct msm_vidc_core *core,
closest_freq_upper_corner =
core->resource->freq_set.freq_tbl[0].freq;
/* return true if vpp_min_freq is more than max frequency */
if (vpp_min_freq > closest_freq_upper_corner)
return false;
return true;
/* get the closest freq corner for vpp_min_freq */
for (i = 0; i < core->resource->freq_set.count; i++) {
@@ -1360,12 +1361,15 @@ int msm_vidc_ring_buf_count_iris33(struct msm_vidc_inst *inst, u32 data_size)
/* check if vpp_min_freq is exceeding closest freq corner margin */
if (is_vpp_cycles_close_to_freq_corner(core,
codec_output.vpp_min_freq))
/* enables ring buffer */
codec_output.vpp_min_freq)) {
/* enable ring buffer */
i_vpr_h(inst,
"%s: vpp_min_freq %d, ring_buffer_count %d\n",
__func__, codec_output.vpp_min_freq, MAX_ENC_RING_BUF_COUNT);
inst->capabilities[ENC_RING_BUFFER_COUNT].value =
MAX_ENC_RING_BUF_COUNT;
else
} else {
inst->capabilities[ENC_RING_BUFFER_COUNT].value = 0;
}
return 0;
}