Skip to contentSkip to conversation

drm/ast: Support timings, 1280x720/1280x960/1600x900

PATCH Superseded Jammy Huang 2 participants 3 messages Dec 24, 2024

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/ast: Support timings, 1280x720/1280x960/1600x900

In this patch, 3 new timings are added into support list.

If you want to have new timings, 1280x720 and 1280x960 on DisplayPort, your dp-fw should be newer than version, 20240502.

---
v2:
- Fix build errors.

---
 drivers/gpu/drm/ast/ast_dp.c     |  9 ++++++++-
 drivers/gpu/drm/ast/ast_drv.h    |  3 +++
 drivers/gpu/drm/ast/ast_mode.c   | 14 ++++++++++++++
 drivers/gpu/drm/ast/ast_tables.h | 18 ++++++++++++++++++
 4 files changed, 43 insertions(+), 1 deletion(-)
drivers/gpu/drm/ast/ast_dp.c +8 -1
index 0e282b7b167c..0b56f0335871 100644
@@ -255,6 +255,10 @@ static void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *v
 	case 1280:
 		if (crtc->mode.crtc_vdisplay == 800)
 			ModeIdx = (ASTDP_1280x800_60_RB - (u8) ulRefreshRateIndex);
+		else if (crtc->mode.crtc_vdisplay == 720)
+			ModeIdx = ASTDP_1280x720_60;
+		else if (crtc->mode.crtc_vdisplay == 960)
+			ModeIdx = ASTDP_1280x960_60;
 		else		// 1024
 			ModeIdx = (ASTDP_1280x1024_60 + (u8) ulRefreshRateIndex);
 		break;
@@ -267,7 +271,10 @@ static void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *v
 		break;
 	case 1600:
 		if (crtc->mode.crtc_vdisplay == 900)
-			ModeIdx = (ASTDP_1600x900_60_RB - (u8) ulRefreshRateIndex);
+			if (ulRefreshRateIndex == 2)
+				ModeIdx = ASTDP_1600x900_60_DMT;
+			else
+				ModeIdx = (ASTDP_1600x900_60_RB - (u8) ulRefreshRateIndex);
 		else		//1200
 			ModeIdx = ASTDP_1600x1200_60;
 		break;
drivers/gpu/drm/ast/ast_drv.h +3 -0
index 21ce3769bf0d..e7cef334b3ec 100644
@@ -442,6 +442,9 @@ int ast_mode_config_init(struct ast_device *ast);
 #define ASTDP_1600x900_60_RB	0x1D
 #define ASTDP_1366x768_60		0x1E
 #define ASTDP_1152x864_75		0x1F
+#define ASTDP_1600x900_60_DMT		0x51
+#define ASTDP_1280x720_60		0x52
+#define ASTDP_1280x960_60		0x53
 
 int ast_mm_init(struct ast_device *ast);
 
drivers/gpu/drm/ast/ast_mode.c +14 -0
index 9d5321c81e68..097b462351e2 100644
@@ -147,6 +147,10 @@ static bool ast_get_vbios_mode_info(const struct drm_format_info *format,
 	case 1280:
 		if (mode->crtc_vdisplay == 800)
 			vbios_mode->enh_table = &res_1280x800[refresh_rate_index];
+		else if (crtc->mode.crtc_vdisplay == 720)
+			vbios_mode->enh_table = &res_1280x720[refresh_rate_index];
+		else if (crtc->mode.crtc_vdisplay == 960)
+			vbios_mode->enh_table = &res_1280x960[refresh_rate_index];
 		else
 			vbios_mode->enh_table = &res_1280x1024[refresh_rate_index];
 		break;
@@ -475,6 +479,12 @@ static void ast_set_dclk_reg(struct ast_device *ast,
 	ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xbb, 0x0f,
 			       (clk_info->param3 & 0xc0) |
 			       ((clk_info->param3 & 0x3) << 4));
+
+	/* Set SEQ; Half dclk for this timing */
+	if (vbios_mode->enh_table->flags & HalfDCLK)
+		ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xff, 0x08);
+	else
+		ast_set_index_reg_mask(ast, AST_IO_VGASRI, 0x01, 0xf7, 0x00);
 }
 
 static void ast_set_color_reg(struct ast_device *ast,
@@ -1027,8 +1037,12 @@ ast_crtc_helper_mode_valid(struct drm_crtc *crtc, const struct drm_display_mode
 	if (ast->support_wide_screen) {
 		if ((mode->hdisplay == 1680) && (mode->vdisplay == 1050))
 			return MODE_OK;
+		if ((mode->hdisplay == 1280) && (mode->vdisplay == 960))
+			return MODE_OK;
 		if ((mode->hdisplay == 1280) && (mode->vdisplay == 800))
 			return MODE_OK;
+		if ((mode->hdisplay == 1280) && (mode->vdisplay == 720))
+			return MODE_OK;
 		if ((mode->hdisplay == 1440) && (mode->vdisplay == 900))
 			return MODE_OK;
 		if ((mode->hdisplay == 1360) && (mode->vdisplay == 768))
drivers/gpu/drm/ast/ast_tables.h +18 -0
index 0378c9bc079b..329d6bac867b 100644
@@ -254,6 +254,13 @@ static const struct ast_vbios_enhtable res_1024x768[] = {
 	 (SyncPP | Charx8Dot), 0xFF, 4, 0x31 },
 };
 
+static const struct ast_vbios_enhtable res_1280x960[] = {
+	{1800, 1280, 96, 112, 1000, 960, 1, 3, VCLK108, /* 60Hz */
+	 (SyncPP | Charx8Dot), 60, 1, 0x3E },
+	{1800, 1280, 96, 112, 1000, 960, 1, 3, VCLK108, /* end */
+	 (SyncPP | Charx8Dot), 0xFF, 1, 0x3E },
+};
+
 static const struct ast_vbios_enhtable res_1280x1024[] = {
 	{1688, 1280, 48, 112, 1066, 1024, 1, 3, VCLK108,	/* 60Hz */
 	 (SyncPP | Charx8Dot), 60, 1, 0x32 },
@@ -280,6 +287,15 @@ static const struct ast_vbios_enhtable res_1152x864[] = {
 };
 
 /* 16:9 */
+static const struct ast_vbios_enhtable res_1280x720[] = {
+	{1650, 1280, 110, 40, 750, 720, 5, 5, VCLK148_5,	/* 60Hz */
+	 (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
+	  HalfDCLK), 60, 1, 0x3D },
+	{1650, 1280, 110, 40, 750, 720, 5, 5, VCLK148_5,	/* end */
+	 (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo |
+	  HalfDCLK), 0xFF, 1, 0x3D },
+};
+
 static const struct ast_vbios_enhtable res_1360x768[] = {
 	{1792, 1360, 64, 112, 795, 768, 3, 6, VCLK85_5,		/* 60Hz */
 	 (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x39 },
@@ -294,6 +310,8 @@ static const struct ast_vbios_enhtable res_1600x900[] = {
 	  AST2500PreCatchCRT), 60, 1, 0x3A },
 	{2112, 1600, 88, 168, 934, 900, 3, 5, VCLK118_25,	/* 60Hz CVT */
 	 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x3A },
+	{1800, 1600, 24, 80, 1000, 900, 1, 3, VCLK108,		/* 60Hz DMT */
+	 (SyncPP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 3, 0x3A },
 	{2112, 1600, 88, 168, 934, 900, 3, 5, VCLK118_25,	/* 60Hz CVT */
 	 (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x3A },
 };

base-commit: 4bbf9020becbfd8fc2c3da790855b7042fad455b

Signature · 1 line
2.25.1
#1 lore raw
kernel test robot noticed the following build errors:

Hi Jammy,

kernel test robot noticed the following build errors:

[auto build test ERROR on 4bbf9020becbfd8fc2c3da790855b7042fad455b]

url:    https://github.com/intel-lab-lkp/linux/commits/Jammy-Huang/drm-ast-Support-timings-1280x720-1280x960-1600x900/20241224-105552
base:   4bbf9020becbfd8fc2c3da790855b7042fad455b
patch link:    https://lore.kernel.org/r/20241224025430.3773224-1-jammy_huang%40aspeedtech.com
patch subject: [PATCH v2] drm/ast: Support timings, 1280x720/1280x960/1600x900
config: x86_64-buildonly-randconfig-002-20241224 (https://download.01.org/0day-ci/archive/20241224/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241224/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/gpu/drm/ast/ast_mode.c: In function 'ast_get_vbios_mode_info':

>> drivers/gpu/drm/ast/ast_mode.c:150:26: error: 'crtc' undeclared (first use in this function)
     150 |                 else if (crtc->mode.crtc_vdisplay == 720)
         |                          ^~~~

drivers/gpu/drm/ast/ast_mode.c:150:26: note: each undeclared identifier is reported only once for each function it appears in

vim +/crtc +150 drivers/gpu/drm/ast/ast_mode.c

108
109 static bool ast_get_vbios_mode_info(const struct drm_format_info *format,

   110					    const struct drm_display_mode *mode,
   111					    struct drm_display_mode *adjusted_mode,
   112					    struct ast_vbios_mode_info *vbios_mode)
   113	{
   114		u32 refresh_rate_index = 0, refresh_rate;
   115		const struct ast_vbios_enhtable *best = NULL;
   116		u32 hborder, vborder;
   117		bool check_sync;
   118	
   119		switch (format->cpp[0] * 8) {
   120		case 8:
   121			vbios_mode->std_table = &vbios_stdtable[VGAModeIndex];
   122			break;
   123		case 16:
   124			vbios_mode->std_table = &vbios_stdtable[HiCModeIndex];
   125			break;
   126		case 24:
   127		case 32:
   128			vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex];
   129			break;
   130		default:
   131			return false;
   132		}
   133	
   134		switch (mode->crtc_hdisplay) {
   135		case 640:
   136			vbios_mode->enh_table = &res_640x480[refresh_rate_index];
   137			break;
   138		case 800:
   139			vbios_mode->enh_table = &res_800x600[refresh_rate_index];
   140			break;
   141		case 1024:
   142			vbios_mode->enh_table = &res_1024x768[refresh_rate_index];
   143			break;
   144		case 1152:
   145			vbios_mode->enh_table = &res_1152x864[refresh_rate_index];
   146			break;
   147		case 1280:
   148			if (mode->crtc_vdisplay == 800)
   149				vbios_mode->enh_table = &res_1280x800[refresh_rate_index];
 > 150			else if (crtc->mode.crtc_vdisplay == 720)

151 vbios_mode->enh_table = &res_1280x720[refresh_rate_index];
152 else if (crtc->mode.crtc_vdisplay == 960)
153 vbios_mode->enh_table = &res_1280x960[refresh_rate_index];
154 else
155 vbios_mode->enh_table = &res_1280x1024[refresh_rate_index];
156 break;
157 case 1360:
158 vbios_mode->enh_table = &res_1360x768[refresh_rate_index];
159 break;
160 case 1440:
161 vbios_mode->enh_table = &res_1440x900[refresh_rate_index];
162 break;
163 case 1600:
164 if (mode->crtc_vdisplay == 900)
165 vbios_mode->enh_table = &res_1600x900[refresh_rate_index];
166 else
167 vbios_mode->enh_table = &res_1600x1200[refresh_rate_index];
168 break;
169 case 1680:
170 vbios_mode->enh_table = &res_1680x1050[refresh_rate_index];
171 break;
172 case 1920:
173 if (mode->crtc_vdisplay == 1080)
174 vbios_mode->enh_table = &res_1920x1080[refresh_rate_index];
175 else
176 vbios_mode->enh_table = &res_1920x1200[refresh_rate_index];
177 break;
178 default:
179 return false;
180 }
181
182 refresh_rate = drm_mode_vrefresh(mode);
183 check_sync = vbios_mode->enh_table->flags & WideScreenMode;
184
185 while (1) {
186 const struct ast_vbios_enhtable *loop = vbios_mode->enh_table;
187
188 while (loop->refresh_rate != 0xff) {
189 if ((check_sync) &&
190 (((mode->flags & DRM_MODE_FLAG_NVSYNC) &&
191 (loop->flags & PVSync)) ||
192 ((mode->flags & DRM_MODE_FLAG_PVSYNC) &&
193 (loop->flags & NVSync)) ||
194 ((mode->flags & DRM_MODE_FLAG_NHSYNC) &&
195 (loop->flags & PHSync)) ||
196 ((mode->flags & DRM_MODE_FLAG_PHSYNC) &&
197 (loop->flags & NHSync)))) {
198 loop++;
199 continue;
200 }
201 if (loop->refresh_rate <= refresh_rate
202 && (!best || loop->refresh_rate > best->refresh_rate))
203 best = loop;
204 loop++;
205 }
206 if (best || !check_sync)
207 break;
208 check_sync = 0;
209 }
210
211 if (best)
212 vbios_mode->enh_table = best;
213
214 hborder = (vbios_mode->enh_table->flags & HBorder) ? 8 : 0;
215 vborder = (vbios_mode->enh_table->flags & VBorder) ? 8 : 0;
216
217 adjusted_mode->crtc_htotal = vbios_mode->enh_table->ht;
218 adjusted_mode->crtc_hblank_start = vbios_mode->enh_table->hde + hborder;
219 adjusted_mode->crtc_hblank_end = vbios_mode->enh_table->ht - hborder;
220 adjusted_mode->crtc_hsync_start = vbios_mode->enh_table->hde + hborder +
221 vbios_mode->enh_table->hfp;
222 adjusted_mode->crtc_hsync_end = (vbios_mode->enh_table->hde + hborder +
223 vbios_mode->enh_table->hfp +
224 vbios_mode->enh_table->hsync);
225
226 adjusted_mode->crtc_vtotal = vbios_mode->enh_table->vt;
227 adjusted_mode->crtc_vblank_start = vbios_mode->enh_table->vde + vborder;
228 adjusted_mode->crtc_vblank_end = vbios_mode->enh_table->vt - vborder;
229 adjusted_mode->crtc_vsync_start = vbios_mode->enh_table->vde + vborder +
230 vbios_mode->enh_table->vfp;
231 adjusted_mode->crtc_vsync_end = (vbios_mode->enh_table->vde + vborder +
232 vbios_mode->enh_table->vfp +
233 vbios_mode->enh_table->vsync);
234
235 return true;
236 }
237

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#2 lore raw
In reply to Jammy Huang
kernel test robot noticed the following build errors:

Hi Jammy,

kernel test robot noticed the following build errors:

[auto build test ERROR on 4bbf9020becbfd8fc2c3da790855b7042fad455b]

url:    https://github.com/intel-lab-lkp/linux/commits/Jammy-Huang/drm-ast-Support-timings-1280x720-1280x960-1600x900/20241224-105552
base:   4bbf9020becbfd8fc2c3da790855b7042fad455b
patch link:    https://lore.kernel.org/r/20241224025430.3773224-1-jammy_huang%40aspeedtech.com
patch subject: [PATCH v2] drm/ast: Support timings, 1280x720/1280x960/1600x900
config: powerpc-randconfig-001-20241224 (https://download.01.org/0day-ci/archive/20241224/[email protected]/config)
compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241224/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/ast/ast_mode.c:150:12: error: use of undeclared identifier 'crtc'
                   else if (crtc->mode.crtc_vdisplay == 720)
                            ^
   drivers/gpu/drm/ast/ast_mode.c:152:12: error: use of undeclared identifier 'crtc'
                   else if (crtc->mode.crtc_vdisplay == 960)
                            ^

2 errors generated.

vim +/crtc +150 drivers/gpu/drm/ast/ast_mode.c

108
109 static bool ast_get_vbios_mode_info(const struct drm_format_info *format,

   110					    const struct drm_display_mode *mode,
   111					    struct drm_display_mode *adjusted_mode,
   112					    struct ast_vbios_mode_info *vbios_mode)
   113	{
   114		u32 refresh_rate_index = 0, refresh_rate;
   115		const struct ast_vbios_enhtable *best = NULL;
   116		u32 hborder, vborder;
   117		bool check_sync;
   118	
   119		switch (format->cpp[0] * 8) {
   120		case 8:
   121			vbios_mode->std_table = &vbios_stdtable[VGAModeIndex];
   122			break;
   123		case 16:
   124			vbios_mode->std_table = &vbios_stdtable[HiCModeIndex];
   125			break;
   126		case 24:
   127		case 32:
   128			vbios_mode->std_table = &vbios_stdtable[TrueCModeIndex];
   129			break;
   130		default:
   131			return false;
   132		}
   133	
   134		switch (mode->crtc_hdisplay) {
   135		case 640:
   136			vbios_mode->enh_table = &res_640x480[refresh_rate_index];
   137			break;
   138		case 800:
   139			vbios_mode->enh_table = &res_800x600[refresh_rate_index];
   140			break;
   141		case 1024:
   142			vbios_mode->enh_table = &res_1024x768[refresh_rate_index];
   143			break;
   144		case 1152:
   145			vbios_mode->enh_table = &res_1152x864[refresh_rate_index];
   146			break;
   147		case 1280:
   148			if (mode->crtc_vdisplay == 800)
   149				vbios_mode->enh_table = &res_1280x800[refresh_rate_index];
 > 150			else if (crtc->mode.crtc_vdisplay == 720)

151 vbios_mode->enh_table = &res_1280x720[refresh_rate_index];
152 else if (crtc->mode.crtc_vdisplay == 960)
153 vbios_mode->enh_table = &res_1280x960[refresh_rate_index];
154 else
155 vbios_mode->enh_table = &res_1280x1024[refresh_rate_index];
156 break;
157 case 1360:
158 vbios_mode->enh_table = &res_1360x768[refresh_rate_index];
159 break;
160 case 1440:
161 vbios_mode->enh_table = &res_1440x900[refresh_rate_index];
162 break;
163 case 1600:
164 if (mode->crtc_vdisplay == 900)
165 vbios_mode->enh_table = &res_1600x900[refresh_rate_index];
166 else
167 vbios_mode->enh_table = &res_1600x1200[refresh_rate_index];
168 break;
169 case 1680:
170 vbios_mode->enh_table = &res_1680x1050[refresh_rate_index];
171 break;
172 case 1920:
173 if (mode->crtc_vdisplay == 1080)
174 vbios_mode->enh_table = &res_1920x1080[refresh_rate_index];
175 else
176 vbios_mode->enh_table = &res_1920x1200[refresh_rate_index];
177 break;
178 default:
179 return false;
180 }
181
182 refresh_rate = drm_mode_vrefresh(mode);
183 check_sync = vbios_mode->enh_table->flags & WideScreenMode;
184
185 while (1) {
186 const struct ast_vbios_enhtable *loop = vbios_mode->enh_table;
187
188 while (loop->refresh_rate != 0xff) {
189 if ((check_sync) &&
190 (((mode->flags & DRM_MODE_FLAG_NVSYNC) &&
191 (loop->flags & PVSync)) ||
192 ((mode->flags & DRM_MODE_FLAG_PVSYNC) &&
193 (loop->flags & NVSync)) ||
194 ((mode->flags & DRM_MODE_FLAG_NHSYNC) &&
195 (loop->flags & PHSync)) ||
196 ((mode->flags & DRM_MODE_FLAG_PHSYNC) &&
197 (loop->flags & NHSync)))) {
198 loop++;
199 continue;
200 }
201 if (loop->refresh_rate <= refresh_rate
202 && (!best || loop->refresh_rate > best->refresh_rate))
203 best = loop;
204 loop++;
205 }
206 if (best || !check_sync)
207 break;
208 check_sync = 0;
209 }
210
211 if (best)
212 vbios_mode->enh_table = best;
213
214 hborder = (vbios_mode->enh_table->flags & HBorder) ? 8 : 0;
215 vborder = (vbios_mode->enh_table->flags & VBorder) ? 8 : 0;
216
217 adjusted_mode->crtc_htotal = vbios_mode->enh_table->ht;
218 adjusted_mode->crtc_hblank_start = vbios_mode->enh_table->hde + hborder;
219 adjusted_mode->crtc_hblank_end = vbios_mode->enh_table->ht - hborder;
220 adjusted_mode->crtc_hsync_start = vbios_mode->enh_table->hde + hborder +
221 vbios_mode->enh_table->hfp;
222 adjusted_mode->crtc_hsync_end = (vbios_mode->enh_table->hde + hborder +
223 vbios_mode->enh_table->hfp +
224 vbios_mode->enh_table->hsync);
225
226 adjusted_mode->crtc_vtotal = vbios_mode->enh_table->vt;
227 adjusted_mode->crtc_vblank_start = vbios_mode->enh_table->vde + vborder;
228 adjusted_mode->crtc_vblank_end = vbios_mode->enh_table->vt - vborder;
229 adjusted_mode->crtc_vsync_start = vbios_mode->enh_table->vde + vborder +
230 vbios_mode->enh_table->vfp;
231 adjusted_mode->crtc_vsync_end = (vbios_mode->enh_table->vde + vborder +
232 vbios_mode->enh_table->vfp +
233 vbios_mode->enh_table->vsync);
234
235 return true;
236 }
237

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki