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

drm/mgag200: Fix LUT programming for 16bpp

Since there are only 32 (64) distinct color values for each color
in 16bpp Matrox hardware expects those in a 'dense' manner, ie in
the first 32 (64) entries of the respective color.

Signed-off-by: Egbert Eich <eich@suse.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>

authored by

Egbert Eich and committed by
Dave Airlie
de7500ea da558398

+23
+23
drivers/gpu/drm/mgag200/mgag200_mode.c
··· 29 29 struct mga_crtc *mga_crtc = to_mga_crtc(crtc); 30 30 struct drm_device *dev = crtc->dev; 31 31 struct mga_device *mdev = dev->dev_private; 32 + struct drm_framebuffer *fb = crtc->fb; 32 33 int i; 33 34 34 35 if (!crtc->enabled) ··· 37 36 38 37 WREG8(DAC_INDEX + MGA1064_INDEX, 0); 39 38 39 + if (fb && fb->bits_per_pixel == 16) { 40 + int inc = (fb->depth == 15) ? 8 : 4; 41 + u8 r, b; 42 + for (i = 0; i < MGAG200_LUT_SIZE; i += inc) { 43 + if (fb->depth == 16) { 44 + if (i > (MGAG200_LUT_SIZE >> 1)) { 45 + r = b = 0; 46 + } else { 47 + r = mga_crtc->lut_r[i << 1]; 48 + b = mga_crtc->lut_b[i << 1]; 49 + } 50 + } else { 51 + r = mga_crtc->lut_r[i]; 52 + b = mga_crtc->lut_b[i]; 53 + } 54 + /* VGA registers */ 55 + WREG8(DAC_INDEX + MGA1064_COL_PAL, r); 56 + WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_g[i]); 57 + WREG8(DAC_INDEX + MGA1064_COL_PAL, b); 58 + } 59 + return; 60 + } 40 61 for (i = 0; i < MGAG200_LUT_SIZE; i++) { 41 62 /* VGA registers */ 42 63 WREG8(DAC_INDEX + MGA1064_COL_PAL, mga_crtc->lut_r[i]);