[RK3128][Android7.1] android端强制使用固定分辨率显示内容

[RK3128][Android7.1] android端强制使用固定分辨率显示内容


Platform: Rockchip
OS: Android 7.1.2
Kernel: 3.10

最近使用480P小屏幕开发时,碰到某些第三方APP的屏幕适配有BUG,如果直接修改配置文件会导致屏幕显示异常,因些只能直接在android显示端做分辨率调整。

修改路径:kernel\drivers\video\rockchip\rk_fb.c

第一步:修改成需要的显示分辨率

int rk_fb_prase_timing_dt(struct device_node *np, struct rk_screen *screen)
{
	struct display_timings *disp_timing;
	struct display_timing *dt;

	disp_timing = of_get_display_timings(np);
	if (!disp_timing) {
		pr_err("parse display timing err\n");
		return -EINVAL;
	}
	dt = display_timings_get(disp_timing, disp_timing->native_mode);
	/* 修改屏幕显示分辨率*/
+	dt->hactive.typ = 1280;
+	dt->vactive.typ = 720;
	rk_fb_video_mode_from_timing(dt, screen);

	return 0;
}

第二步:修改显示分辨率后,会导致显示区域也被相对缩放,因此需要修改显示窗口缩放规则

static void rk_fb_update_win(struct rk_lcdc_driver *dev_drv,
			     struct rk_lcdc_win *win,
			     struct rk_fb_reg_win_data *reg_win_data)
{
...
} else {
					/* 对小于720P的屏幕不做缩放处理 */
+					if (reg_win_data->reg_area_data[i].xsize >= 1280 && reg_win_data->reg_area_data[i].ysize >= 720){
						win->area[i].xpos =
							reg_win_data->reg_area_data[i].xpos *
							cur_screen->mode.xres /
							primary_screen.mode.xres;
						win->area[i].ypos =
							reg_win_data->reg_area_data[i].ypos *
							cur_screen->mode.yres /
							primary_screen.mode.yres;
						win->area[i].xsize =
							reg_win_data->reg_area_data[i].xsize *
							cur_screen->mode.xres /
							primary_screen.mode.xres;
						win->area[i].ysize =
							reg_win_data->reg_area_data[i].ysize *
							cur_screen->mode.yres /
							primary_screen.mode.yres;
+					}

					/* recalc display size if set hdmi scaler when at ONE_DUAL mode */
					if (inf->disp_mode == ONE_DUAL && hdmi_switch_state) {
						if (cur_screen->xsize > 0 &&
						    cur_screen->xsize <= cur_screen->mode.xres) {
							win->area[i].xpos =
								((cur_screen->mode.xres - cur_screen->xsize) >> 1) +
								cur_screen->xsize * win->area[i].xpos / cur_screen->mode.xres;
							win->area[i].xsize =
								win->area[i].xsize * cur_screen->xsize / cur_screen->mode.xres;
						}
						if (cur_screen->ysize > 0 && cur_screen->ysize <= cur_screen->mode.yres) {
							win->area[i].ypos =
								((cur_screen->mode.yres - cur_screen->ysize) >> 1) +
								cur_screen->ysize * win->area[i].ypos / cur_screen->mode.yres;
							win->area[i].ysize =
								win->area[i].ysize * cur_screen->ysize / cur_screen->mode.yres;
						}
					}
				}
...
}

目前屏幕显示正常,无触摸屏,触摸屏触摸效果是否会有异常暂时未知

你可能感兴趣的:(Rockchip)