Skip to content

Commit cf48e29

Browse files
committed
drm: Initialize a linear gamma table by default
Code stolen from gma500. This is just a minor bit of safety code that I spotted and figured it might be useful if we put it into the core. This is to make the get_gamma ioctl reflect likely reality even before the first set_gamma ioctl call. v2 on irc: Extend commit message per Maarten's suggestions. Reviewed-by: Maarten Lankhorst <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1bd816f commit cf48e29

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

drivers/gpu/drm/drm_crtc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5139,6 +5139,9 @@ EXPORT_SYMBOL(drm_mode_connector_attach_encoder);
51395139
int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
51405140
int gamma_size)
51415141
{
5142+
uint16_t *r_base, *g_base, *b_base;
5143+
int i;
5144+
51425145
crtc->gamma_size = gamma_size;
51435146

51445147
crtc->gamma_store = kcalloc(gamma_size, sizeof(uint16_t) * 3,
@@ -5148,6 +5151,16 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
51485151
return -ENOMEM;
51495152
}
51505153

5154+
r_base = crtc->gamma_store;
5155+
g_base = r_base + gamma_size;
5156+
b_base = g_base + gamma_size;
5157+
for (i = 0; i < gamma_size; i++) {
5158+
r_base[i] = i << 8;
5159+
g_base[i] = i << 8;
5160+
b_base[i] = i << 8;
5161+
}
5162+
5163+
51515164
return 0;
51525165
}
51535166
EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size);

drivers/gpu/drm/gma500/psb_intel_display.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,6 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
491491
struct drm_psb_private *dev_priv = dev->dev_private;
492492
struct gma_crtc *gma_crtc;
493493
int i;
494-
uint16_t *r_base, *g_base, *b_base;
495494

496495
/* We allocate a extra array of drm_connector pointers
497496
* for fbdev after the crtc */
@@ -519,16 +518,10 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
519518
gma_crtc->pipe = pipe;
520519
gma_crtc->plane = pipe;
521520

522-
r_base = gma_crtc->base.gamma_store;
523-
g_base = r_base + 256;
524-
b_base = g_base + 256;
525521
for (i = 0; i < 256; i++) {
526522
gma_crtc->lut_r[i] = i;
527523
gma_crtc->lut_g[i] = i;
528524
gma_crtc->lut_b[i] = i;
529-
r_base[i] = i << 8;
530-
g_base[i] = i << 8;
531-
b_base[i] = i << 8;
532525

533526
gma_crtc->lut_adj[i] = 0;
534527
}

0 commit comments

Comments
 (0)