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

Commit 2ecbe055 authored by tianrunlong's avatar tianrunlong Committed by lio.chen
Browse files

LCD: Fix switch framerate conflict set backlight

Change-Id: I4c3d8a7974df2e2ce8bffa79f58667ec3dea620c
parent 52c85526
Loading
Loading
Loading
Loading
+34 −3
Original line number Diff line number Diff line
@@ -130,6 +130,9 @@ static unsigned int partial_y_offset;
static unsigned int partial_height;
unsigned int seg_id_dbg;

extern bool delay_first_set_backlight;
struct delayed_work set_first_backlight_by_workqueue;

struct logger_buffer {
	char **buffer_ptr;
	unsigned int len;
@@ -138,6 +141,15 @@ struct logger_buffer {
	const unsigned int size;
};

struct brightness_buffer {
	unsigned int level;
	unsigned int panel_ext_param;
	unsigned int cfg_flag;
	struct drm_crtc *crtc;
};

static struct brightness_buffer bl_buffer;

static DEFINE_SPINLOCK(dprec_err_logger_spinlock);
static DEFINE_SPINLOCK(dprec_fence_logger_spinlock);
static DEFINE_SPINLOCK(dprec_dbg_logger_spinlock);
@@ -510,6 +522,11 @@ int mtkfb_set_backlight_level_AOD(unsigned int level)
}
EXPORT_SYMBOL(mtkfb_set_backlight_level_AOD);

void set_first_backlight_work(struct work_struct *work)
{
	mtk_drm_setbacklight(bl_buffer.crtc, bl_buffer.level, bl_buffer.panel_ext_param, bl_buffer.cfg_flag, 1);
}

int __mtkfb_set_backlight_level(unsigned int level, unsigned int panel_ext_param,
			       unsigned int cfg_flag, bool group)
{
@@ -528,10 +545,21 @@ int __mtkfb_set_backlight_level(unsigned int level, unsigned int panel_ext_param
		DDPPR_ERR("%s failed to find crtc\n", __func__);
		return -EINVAL;
	}
	if (group == true)

	if (group == true) {
		ret = mtk_drm_setbacklight_grp(crtc, level, panel_ext_param, cfg_flag);
	else
	} else {
		if (delay_first_set_backlight) {
			bl_buffer.level = level;
			bl_buffer.panel_ext_param = panel_ext_param;
			bl_buffer.cfg_flag = cfg_flag;
			bl_buffer.crtc = crtc;
			schedule_delayed_work(&set_first_backlight_by_workqueue, msecs_to_jiffies(35));
			ret = 0;
		} else {
			ret = mtk_drm_setbacklight(crtc, level, panel_ext_param, cfg_flag, 1);
		}
	}

	return ret;
}
@@ -5745,6 +5773,8 @@ void disp_dbg_init(struct drm_device *dev)
	else
		DDPMSG("%s, disp debug init\n", __func__);

	INIT_DELAYED_WORK(&set_first_backlight_by_workqueue, set_first_backlight_work);

	drm_dev = dev;
	init_completion(&cwb_cmp);

@@ -5773,6 +5803,7 @@ void disp_dbg_deinit(void)
#ifdef MTK_DPINFO
	mtk_dp_debugfs_deinit();
#endif
	cancel_delayed_work_sync(&set_first_backlight_by_workqueue);
}

void get_disp_dbg_buffer(unsigned long *addr, unsigned long *size,
+5 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ struct timespec64 atomic_flush_tval;
struct timespec64 rdma_sof_tval;
static bool hrt_usage_status;
bool hdr_en;
extern bool delay_first_set_backlight;
static const char * const crtc_gce_client_str[] = {
	DECLARE_GCE_CLIENT(DECLARE_STR)};
@@ -1732,6 +1733,10 @@ int mtk_drm_setbacklight(struct drm_crtc *crtc, unsigned int level,
	if (lock)
		DDP_MUTEX_UNLOCK(&mtk_crtc->lock, __func__, __LINE__);
	if (delay_first_set_backlight) {
		delay_first_set_backlight = false;
	}
	CRTC_MMP_EVENT_END(index, backlight, (unsigned long)crtc,
			level);
+3 −0
Original line number Diff line number Diff line
@@ -666,6 +666,9 @@ enum DISP_SMC_CMD {
	DISP_CMD_MAX,
};

extern struct delayed_work set_first_backlight_by_workqueue;
void set_first_backlight_work(struct work_struct *work);

struct mtk_crtc_path_data {
	bool is_fake_path;
	bool is_discrete_path;
+64 −32
Original line number Diff line number Diff line
@@ -417,6 +417,8 @@ static struct mtk_drm_property mtk_connector_property[CONNECTOR_PROP_MAX] = {

ktime_t time_start;
s64 elapsed_ms[3] = {0};
bool delay_first_set_backlight = false;
EXPORT_SYMBOL(delay_first_set_backlight);

static u32 underrun_cnt;
module_param(underrun_cnt, uint, 0644);
@@ -3638,6 +3640,7 @@ static void mtk_output_dsi_enable(struct mtk_dsi *dsi,
		return;
	}

	delay_first_set_backlight = true;
	crtc_idx = drm_crtc_index(crtc);
	CRTC_MMP_EVENT_START(crtc_idx, dsi_enable,
				(unsigned long)crtc, crtc_idx);
@@ -6152,8 +6155,8 @@ static void mtk_dsi_cmdq_gce(struct mtk_dsi *dsi, struct cmdq_pkt *handle,
				DSI_CMDQ_SIZE, CMDQ_SIZE, handle);
	mtk_ddp_write_mask(&dsi->ddp_comp, CMDQ_SIZE_SEL,
				DSI_CMDQ_SIZE, CMDQ_SIZE_SEL, handle);
	DDPINFO("cmdq_size = %d,DSI_CMDQ_SIZE=0x%x\n", cmdq_size,
				readl(dsi->regs + DSI_CMDQ_SIZE));
	DDPINFO("set cmdqaddr %u, val:%x, mask %x\n", DSI_CMDQ_SIZE, cmdq_size,
			CMDQ_SIZE);
}

static void mtk_dsi_cmdq_pack_gce(struct mtk_dsi *dsi, struct cmdq_pkt *handle,
@@ -6540,6 +6543,14 @@ void mipi_dsi_dcs_write_gce(struct mtk_dsi *dsi, struct cmdq_pkt *handle,
			dsi->ddp_comp.regs_pa + DSI_INTSTA,
			VM_CMD_DONE_INT_EN, VM_CMD_DONE_INT_EN);

		cmdq_pkt_write(handle, dsi->ddp_comp.cmdq_base,
			dsi->ddp_comp.regs_pa + DSI_START, 0,
			VM_CMD_START);

		/* clear VM_CMD_DONE */
		cmdq_pkt_write(handle, dsi->ddp_comp.cmdq_base,
			dsi->ddp_comp.regs_pa + DSI_INTSTA, 0,
			VM_CMD_DONE_INT_EN);
	}

	mtk_dsi_power_keep_gce(dsi, handle, false);
@@ -9790,11 +9801,9 @@ void mtk_dsi_send_switch_cmd_nothing(struct mtk_dsi *dsi,
			struct mtk_drm_crtc *mtk_crtc, unsigned int cur_mode, unsigned int dst_mode)
{
	unsigned int i;
	int lcm_cmd_count = 0;
	struct dfps_switch_cmd *dfps_cmd = NULL;
	struct mtk_panel_params *params = NULL;
	struct drm_display_mode *old_mode = NULL;
	struct mtk_ddic_dsi_cmd send_cmd_to_ddic;

	old_mode = &(mtk_crtc->avail_modes[cur_mode]);

@@ -9802,33 +9811,11 @@ void mtk_dsi_send_switch_cmd_nothing(struct mtk_dsi *dsi,
		params = mtk_crtc->panel_ext->params;
	else /* can't find panel ext information,stop */
		return;

	for (i = 0; i < MAX_DYN_CMD_NUM; i++) {
		dfps_cmd = &params->dyn_fps.dfps_cmd_table[i];
		if (dfps_cmd->cmd_num == 0)
			break;
		lcm_cmd_count++;
	}

	if (lcm_cmd_count > MAX_TX_CMD_NUM_PACK) {
		pr_info("%s,out of mtk_ddic_dsi_cmd\n", __func__);
		return;
	}

	for (i = 0; i < lcm_cmd_count; i++) {
		send_cmd_to_ddic.mtk_ddic_cmd_table[i].cmd_num = params->dyn_fps.dfps_cmd_table[i].cmd_num;
		send_cmd_to_ddic.mtk_ddic_cmd_table[i].para_list = params->dyn_fps.dfps_cmd_table[i].para_list;
	}
	send_cmd_to_ddic.is_hs = 1;
	send_cmd_to_ddic.is_package = 1;
	send_cmd_to_ddic.cmd_count = lcm_cmd_count;

/*	if (dsi->slave_dsi)
		mtk_dsi_enter_idle(dsi->slave_dsi,1,false);
	if (dsi->slave_dsi)
		mtk_dsi_leave_idle(dsi->slave_dsi,1,false);
*/
/*
	for (i = 0; i < MAX_DYN_CMD_NUM; i++) {
		dfps_cmd = &params->dyn_fps.dfps_cmd_table[i];
		if (dfps_cmd->cmd_num == 0)
@@ -9838,9 +9825,6 @@ void mtk_dsi_send_switch_cmd_nothing(struct mtk_dsi *dsi,
			mipi_dsi_dcs_write_gce(dsi, handle, dfps_cmd->para_list,
				dfps_cmd->cmd_num);
	}
*/
	if (dfps_cmd->src_fps == 0 || drm_mode_vrefresh(old_mode) == dfps_cmd->src_fps)
		mtk_dsi_cmdq_pack_gce(dsi, handle, &send_cmd_to_ddic);
}
static void mtk_dsi_vdo_timing_change(struct mtk_dsi *dsi,
	struct mtk_drm_crtc *mtk_crtc, struct drm_crtc_state *old_state)
@@ -9985,6 +9969,7 @@ static void mtk_dsi_vdo_timing_change(struct mtk_dsi *dsi,
		mtk_dsi_trigger(comp, handle);
	} else if (fps_chg_index & MODE_DSI_VFP) {
		DDPINFO("%s, change VFP\n", __func__);

		cmdq_pkt_wait_no_clear(handle,
			mtk_crtc->gce_obj.event[EVENT_CMD_EOF]);
		comp = mtk_ddp_comp_request_output(mtk_crtc);
@@ -9995,6 +9980,38 @@ static void mtk_dsi_vdo_timing_change(struct mtk_dsi *dsi,
			return;
		}

		if (dsi && dsi->ext && dsi->ext->params
			&& dsi->ext->params->change_fps_by_vfp_send_cmd) {
			/*wait and clear EOF
			 * avoid other display related task break fps change task
			 * because fps change need stop & re-start vdo mode
			 */
			cmdq_pkt_wfe(handle,
				     mtk_crtc->gce_obj.event[EVENT_CMD_EOF]);
			/*1.1 send cmd: stop vdo mode*/
			mtk_dsi_stop_vdo_mode(dsi, handle);
			/* for crtc first enable,dyn fps fail*/
			if (dsi->data_rate == 0) {
				dsi->data_rate = mtk_dsi_default_rate(dsi);
				mtk_mipi_tx_pll_rate_set_adpt(dsi->phy, dsi->data_rate);
				if (dsi->ext->params->data_rate_khz)
					mtk_mipi_tx_pll_rate_khz_set_adpt(dsi->phy,
						dsi->ext->params->data_rate_khz);
				if (dsi->slave_dsi) {
					dsi->slave_dsi->data_rate = dsi->data_rate;
					mtk_mipi_tx_pll_rate_set_adpt(dsi->slave_dsi->phy, dsi->data_rate);
					if (dsi->ext->params->data_rate_khz)
						mtk_mipi_tx_pll_rate_khz_set_adpt(dsi->slave_dsi->phy,
							dsi->ext->params->data_rate_khz);
				}
				if (dsi->data_rate) {
					mtk_dsi_phy_timconfig(dsi, NULL);
					if (dsi->slave_dsi)
						mtk_dsi_phy_timconfig(dsi->slave_dsi, NULL);
				}
			}
		}

		if (dsi->mipi_hopping_sta && dsi->ext) {
			DDPINFO("%s,mipi_clk_change_sta\n", __func__);
			vfp = dsi->ext->params->dyn.vfp;
@@ -10005,8 +10022,6 @@ static void mtk_dsi_vdo_timing_change(struct mtk_dsi *dsi,
		if (dsi->slave_dsi)
			dsi->slave_dsi->vm.vfront_porch = vfp;

		mtk_dsi_send_switch_cmd_nothing(dsi, handle, mtk_crtc, src_mode,
					drm_mode_vrefresh(&adjusted_mode));
		/* Msync 2.0 ToDo: can we change vm.vfront_porch according msync?
		 * mmdvfs,dramdvfs according to vm.vfront_porch?
		 */
@@ -10037,6 +10052,23 @@ static void mtk_dsi_vdo_timing_change(struct mtk_dsi *dsi,
		if (dsi->slave_dsi)
			mtk_dsi_porch_setting(&dsi->slave_dsi->ddp_comp,
						handle, DSI_VFP, vfp);

		if (dsi && dsi->ext && dsi->ext->params
			&& dsi->ext->params->change_fps_by_vfp_send_cmd) {
			/*1.2 send cmd: send cmd*/
			mtk_dsi_send_switch_cmd(dsi, handle, mtk_crtc, src_mode,
						drm_mode_vrefresh(&adjusted_mode));
			/*1.3 send cmd: start vdo mode*/
			mtk_dsi_start_vdo_mode(comp, handle);
			/*clear EOF
			 * avoid config continue after we trigger vdo mode
			 */
			cmdq_pkt_clear_event(handle,
				     mtk_crtc->gce_obj.event[EVENT_CMD_EOF]);
			/*1.4 send cmd: trigger*/
			mtk_disp_mutex_trigger(comp->mtk_crtc->mutex[0], handle);
			mtk_dsi_trigger(comp, handle);
		}
	}

	if (mtk_crtc->qos_ctx)
+2 −1
Original line number Diff line number Diff line
@@ -202,6 +202,7 @@ static int samsung_set_backlight_pack(void *dsi, dcs_write_gce_pack cb,
	bl_tb0[1] = (level >> 8) & 0xFF;
	bl_tb0[2] = level & 0xFF;

	if (level != 0)
		g_level = level;

	if (g_ctx->hbm_stat == true || g_ctx->hbm_en == true) {
Loading