Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24a655e3 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

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

parents be58842c eaad7c00
Loading
Loading
Loading
Loading
+38 −27
Original line number Diff line number Diff line
@@ -1102,6 +1102,40 @@ 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;
	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);
}

int msm_comm_init_clocks_and_bus_data(struct msm_vidc_inst *inst)
{
	int rc = 0, j = 0;
@@ -1147,8 +1181,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",
@@ -1158,35 +1190,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;

		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);
	if (inst->session_type == MSM_VIDC_ENCODER &&
		inst->flags & VIDC_LOW_POWER)
		cycles = inst->clk_data.entry->low_power_cycles;

	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;

+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 */

#ifndef _MSM_VIDC_CLOCKS_H_
@@ -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);
+20 −5
Original line number Diff line number Diff line
@@ -1637,7 +1637,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;
	int extra_buff_count = 0;
	u32 codec;

@@ -1690,15 +1689,25 @@ 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;
		} else {
			if (fmt->count_min < event_notify->fw_min_cnt) {
				s_vpr_e(inst->sid,
				"%s: Firmware min count %d cannot be greater than driver min count %d\n",
					__func__, event_notify->fw_min_cnt,
					fmt->count_min);
				msm_vidc_queue_v4l2_event(inst,
					V4L2_EVENT_MSM_VIDC_HW_UNSUPPORTED);
				goto err_bad_event;
			}
			inst->entropy_mode = event_notify->entropy_mode;

			/* configure work mode considering low latency*/
@@ -1710,6 +1719,12 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
						"%s: Failed to decide work mode\n",
						__func__);
			}
			/* Update driver buffer counts */
			extra_buff_count = msm_vidc_get_extra_buff_count(inst,
					HAL_BUFFER_OUTPUT);
			fmt->count_min = event_notify->fw_min_cnt;
			fmt->count_min_host = fmt->count_min + extra_buff_count;
			msm_dcvs_reset(inst);
			s_vpr_h(inst->sid,
				"seq: No parameter change continue session\n");
			rc = call_hfi_op(hdev, session_continue,
@@ -1783,7 +1798,6 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
	ptr[MSM_VIDC_BIT_DEPTH] = event_notify->bit_depth;
	ptr[MSM_VIDC_PIC_STRUCT] = event_notify->pic_struct;
	ptr[MSM_VIDC_COLOR_SPACE] = event_notify->colour_space;
	ptr[MSM_VIDC_FW_MIN_COUNT] = event_notify->fw_min_cnt;

	s_vpr_h(inst->sid, "seq: height = %u width = %u\n",
		event_notify->height, event_notify->width);
@@ -1826,6 +1840,7 @@ static void handle_event_change(enum hal_command_response cmd, void *data)
			HAL_BUFFER_OUTPUT, fmt->count_min,
			fmt->count_min_host);
	}
	ptr[MSM_VIDC_FW_MIN_COUNT] = fmt->count_min_host;

	rc = msm_vidc_check_session_supported(inst);
	if (!rc) {