diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-03-30 05:51:16 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-05-31 10:56:44 -0400 |
commit | cf48e2921ee95011a164dc31e8725022bd008666 (patch) | |
tree | 0a63daf92e6caa63994659d5480b599c70aa849b | |
parent | 1bd816f120718d578af7e4b623b9a0dec59c028c (diff) |
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 <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1459331485-28376-2-git-send-email-daniel.vetter@ffwll.ch
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 13 | ||||
-rw-r--r-- | drivers/gpu/drm/gma500/psb_intel_display.c | 7 |
2 files changed, 13 insertions, 7 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index d2a6d958ca76..37427b2bb9fc 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -5139,6 +5139,9 @@ EXPORT_SYMBOL(drm_mode_connector_attach_encoder); | |||
5139 | int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, | 5139 | int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
5140 | int gamma_size) | 5140 | int gamma_size) |
5141 | { | 5141 | { |
5142 | uint16_t *r_base, *g_base, *b_base; | ||
5143 | int i; | ||
5144 | |||
5142 | crtc->gamma_size = gamma_size; | 5145 | crtc->gamma_size = gamma_size; |
5143 | 5146 | ||
5144 | crtc->gamma_store = kcalloc(gamma_size, sizeof(uint16_t) * 3, | 5147 | 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, | |||
5148 | return -ENOMEM; | 5151 | return -ENOMEM; |
5149 | } | 5152 | } |
5150 | 5153 | ||
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 | |||
5151 | return 0; | 5164 | return 0; |
5152 | } | 5165 | } |
5153 | EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size); | 5166 | EXPORT_SYMBOL(drm_mode_crtc_set_gamma_size); |
diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c b/drivers/gpu/drm/gma500/psb_intel_display.c index 398015be87e4..7b6c84925098 100644 --- a/drivers/gpu/drm/gma500/psb_intel_display.c +++ b/drivers/gpu/drm/gma500/psb_intel_display.c | |||
@@ -491,7 +491,6 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe, | |||
491 | struct drm_psb_private *dev_priv = dev->dev_private; | 491 | struct drm_psb_private *dev_priv = dev->dev_private; |
492 | struct gma_crtc *gma_crtc; | 492 | struct gma_crtc *gma_crtc; |
493 | int i; | 493 | int i; |
494 | uint16_t *r_base, *g_base, *b_base; | ||
495 | 494 | ||
496 | /* We allocate a extra array of drm_connector pointers | 495 | /* We allocate a extra array of drm_connector pointers |
497 | * for fbdev after the crtc */ | 496 | * for fbdev after the crtc */ |
@@ -519,16 +518,10 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe, | |||
519 | gma_crtc->pipe = pipe; | 518 | gma_crtc->pipe = pipe; |
520 | gma_crtc->plane = pipe; | 519 | gma_crtc->plane = pipe; |
521 | 520 | ||
522 | r_base = gma_crtc->base.gamma_store; | ||
523 | g_base = r_base + 256; | ||
524 | b_base = g_base + 256; | ||
525 | for (i = 0; i < 256; i++) { | 521 | for (i = 0; i < 256; i++) { |
526 | gma_crtc->lut_r[i] = i; | 522 | gma_crtc->lut_r[i] = i; |
527 | gma_crtc->lut_g[i] = i; | 523 | gma_crtc->lut_g[i] = i; |
528 | gma_crtc->lut_b[i] = i; | 524 | gma_crtc->lut_b[i] = i; |
529 | r_base[i] = i << 8; | ||
530 | g_base[i] = i << 8; | ||
531 | b_base[i] = i << 8; | ||
532 | 525 | ||
533 | gma_crtc->lut_adj[i] = 0; | 526 | gma_crtc->lut_adj[i] = 0; |
534 | } | 527 | } |