Skip to content

Commit d6460bd

Browse files
author
Thomas Zimmermann
committed
drm/mgag200: Add dedicated variables for blanking fields
Represent fields for horizontal and vertical blanking with <hblkstr>, <hblkend>, <vblkstr> and <vblkend>. Aligns the code with the Matrox programming manuals. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Jocelyn Falempe <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e8f834b commit d6460bd

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

drivers/gpu/drm/mgag200/mgag200_mode.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -204,23 +204,26 @@ void mgag200_init_registers(struct mga_device *mdev)
204204
void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode,
205205
bool set_vidrst)
206206
{
207-
unsigned int hdispend, hsyncstr, hsyncend, htotal;
208-
unsigned int vdispend, vsyncstr, vsyncend, vtotal;
207+
unsigned int hdispend, hsyncstr, hsyncend, htotal, hblkstr, hblkend;
208+
unsigned int vdispend, vsyncstr, vsyncend, vtotal, vblkstr, vblkend;
209209
u8 misc, crtcext1, crtcext2, crtcext5;
210210

211211
hdispend = mode->crtc_hdisplay / 8 - 1;
212212
hsyncstr = mode->crtc_hsync_start / 8 - 1;
213213
hsyncend = mode->crtc_hsync_end / 8 - 1;
214214
htotal = mode->crtc_htotal / 8 - 1;
215-
216215
/* Work around hardware quirk */
217216
if ((htotal & 0x07) == 0x06 || (htotal & 0x07) == 0x04)
218217
htotal++;
218+
hblkstr = mode->crtc_hblank_start / 8 - 1;
219+
hblkend = htotal;
219220

220221
vdispend = mode->crtc_vdisplay - 1;
221222
vsyncstr = mode->crtc_vsync_start - 1;
222223
vsyncend = mode->crtc_vsync_end - 1;
223224
vtotal = mode->crtc_vtotal - 2;
225+
vblkstr = mode->crtc_vblank_start;
226+
vblkend = vtotal + 1;
224227

225228
misc = RREG8(MGA_MISC_IN);
226229

@@ -235,43 +238,43 @@ void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mod
235238
misc &= ~MGAREG_MISC_VSYNCPOL;
236239

237240
crtcext1 = (((htotal - 4) & 0x100) >> 8) |
238-
((hdispend & 0x100) >> 7) |
241+
((hblkstr & 0x100) >> 7) |
239242
((hsyncstr & 0x100) >> 6) |
240-
(htotal & 0x40);
243+
(hblkend & 0x40);
241244
if (set_vidrst)
242245
crtcext1 |= MGAREG_CRTCEXT1_VRSTEN |
243246
MGAREG_CRTCEXT1_HRSTEN;
244247

245248
crtcext2 = ((vtotal & 0xc00) >> 10) |
246249
((vdispend & 0x400) >> 8) |
247-
((vdispend & 0xc00) >> 7) |
250+
((vblkstr & 0xc00) >> 7) |
248251
((vsyncstr & 0xc00) >> 5) |
249252
((vdispend & 0x400) >> 3);
250253
crtcext5 = 0x00;
251254

252255
WREG_CRT(0x00, htotal - 4);
253256
WREG_CRT(0x01, hdispend);
254-
WREG_CRT(0x02, hdispend);
255-
WREG_CRT(0x03, (htotal & 0x1f) | 0x80);
257+
WREG_CRT(0x02, hblkstr);
258+
WREG_CRT(0x03, (hblkend & 0x1f) | 0x80);
256259
WREG_CRT(0x04, hsyncstr);
257-
WREG_CRT(0x05, ((htotal & 0x20) << 2) | (hsyncend & 0x1f));
260+
WREG_CRT(0x05, ((hblkend & 0x20) << 2) | (hsyncend & 0x1f));
258261
WREG_CRT(0x06, vtotal & 0xff);
259262
WREG_CRT(0x07, ((vtotal & 0x100) >> 8) |
260263
((vdispend & 0x100) >> 7) |
261264
((vsyncstr & 0x100) >> 6) |
262-
((vdispend & 0x100) >> 5) |
265+
((vblkstr & 0x100) >> 5) |
263266
((vdispend & 0x100) >> 4) | /* linecomp */
264267
((vtotal & 0x200) >> 4) |
265268
((vdispend & 0x200) >> 3) |
266269
((vsyncstr & 0x200) >> 2));
267-
WREG_CRT(0x09, ((vdispend & 0x200) >> 4) |
270+
WREG_CRT(0x09, ((vblkstr & 0x200) >> 4) |
268271
((vdispend & 0x200) >> 3));
269272
WREG_CRT(0x10, vsyncstr & 0xff);
270273
WREG_CRT(0x11, (vsyncend & 0x0f) | 0x20);
271274
WREG_CRT(0x12, vdispend & 0xff);
272275
WREG_CRT(0x14, 0);
273-
WREG_CRT(0x15, vdispend & 0xff);
274-
WREG_CRT(0x16, (vtotal + 1) & 0xff);
276+
WREG_CRT(0x15, vblkstr & 0xff);
277+
WREG_CRT(0x16, vblkend & 0xff);
275278
WREG_CRT(0x17, 0xc3);
276279
WREG_CRT(0x18, vdispend & 0xff);
277280

0 commit comments

Comments
 (0)