Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240718104551.575912-5-tzimmermann@suse.de

+16 -13
+16 -13
drivers/gpu/drm/mgag200/mgag200_mode.c
··· 204 204 void mgag200_set_mode_regs(struct mga_device *mdev, const struct drm_display_mode *mode, 205 205 bool set_vidrst) 206 206 { 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; 209 209 u8 misc, crtcext1, crtcext2, crtcext5; 210 210 211 211 hdispend = mode->crtc_hdisplay / 8 - 1; 212 212 hsyncstr = mode->crtc_hsync_start / 8 - 1; 213 213 hsyncend = mode->crtc_hsync_end / 8 - 1; 214 214 htotal = mode->crtc_htotal / 8 - 1; 215 - 216 215 /* Work around hardware quirk */ 217 216 if ((htotal & 0x07) == 0x06 || (htotal & 0x07) == 0x04) 218 217 htotal++; 218 + hblkstr = mode->crtc_hblank_start / 8 - 1; 219 + hblkend = htotal; 219 220 220 221 vdispend = mode->crtc_vdisplay - 1; 221 222 vsyncstr = mode->crtc_vsync_start - 1; 222 223 vsyncend = mode->crtc_vsync_end - 1; 223 224 vtotal = mode->crtc_vtotal - 2; 225 + vblkstr = mode->crtc_vblank_start; 226 + vblkend = vtotal + 1; 224 227 225 228 misc = RREG8(MGA_MISC_IN); 226 229 ··· 238 235 misc &= ~MGAREG_MISC_VSYNCPOL; 239 236 240 237 crtcext1 = (((htotal - 4) & 0x100) >> 8) | 241 - ((hdispend & 0x100) >> 7) | 238 + ((hblkstr & 0x100) >> 7) | 242 239 ((hsyncstr & 0x100) >> 6) | 243 - (htotal & 0x40); 240 + (hblkend & 0x40); 244 241 if (set_vidrst) 245 242 crtcext1 |= MGAREG_CRTCEXT1_VRSTEN | 246 243 MGAREG_CRTCEXT1_HRSTEN; 247 244 248 245 crtcext2 = ((vtotal & 0xc00) >> 10) | 249 246 ((vdispend & 0x400) >> 8) | 250 - ((vdispend & 0xc00) >> 7) | 247 + ((vblkstr & 0xc00) >> 7) | 251 248 ((vsyncstr & 0xc00) >> 5) | 252 249 ((vdispend & 0x400) >> 3); 253 250 crtcext5 = 0x00; 254 251 255 252 WREG_CRT(0x00, htotal - 4); 256 253 WREG_CRT(0x01, hdispend); 257 - WREG_CRT(0x02, hdispend); 258 - WREG_CRT(0x03, (htotal & 0x1f) | 0x80); 254 + WREG_CRT(0x02, hblkstr); 255 + WREG_CRT(0x03, (hblkend & 0x1f) | 0x80); 259 256 WREG_CRT(0x04, hsyncstr); 260 - WREG_CRT(0x05, ((htotal & 0x20) << 2) | (hsyncend & 0x1f)); 257 + WREG_CRT(0x05, ((hblkend & 0x20) << 2) | (hsyncend & 0x1f)); 261 258 WREG_CRT(0x06, vtotal & 0xff); 262 259 WREG_CRT(0x07, ((vtotal & 0x100) >> 8) | 263 260 ((vdispend & 0x100) >> 7) | 264 261 ((vsyncstr & 0x100) >> 6) | 265 - ((vdispend & 0x100) >> 5) | 262 + ((vblkstr & 0x100) >> 5) | 266 263 ((vdispend & 0x100) >> 4) | /* linecomp */ 267 264 ((vtotal & 0x200) >> 4) | 268 265 ((vdispend & 0x200) >> 3) | 269 266 ((vsyncstr & 0x200) >> 2)); 270 - WREG_CRT(0x09, ((vdispend & 0x200) >> 4) | 267 + WREG_CRT(0x09, ((vblkstr & 0x200) >> 4) | 271 268 ((vdispend & 0x200) >> 3)); 272 269 WREG_CRT(0x10, vsyncstr & 0xff); 273 270 WREG_CRT(0x11, (vsyncend & 0x0f) | 0x20); 274 271 WREG_CRT(0x12, vdispend & 0xff); 275 272 WREG_CRT(0x14, 0); 276 - WREG_CRT(0x15, vdispend & 0xff); 277 - WREG_CRT(0x16, (vtotal + 1) & 0xff); 273 + WREG_CRT(0x15, vblkstr & 0xff); 274 + WREG_CRT(0x16, vblkend & 0xff); 278 275 WREG_CRT(0x17, 0xc3); 279 276 WREG_CRT(0x18, vdispend & 0xff); 280 277