drm: radeon: remove dead code and pointless local lut storage
authorPeter Rosin <peda@axentia.se>
Thu, 13 Jul 2017 16:25:36 +0000 (18:25 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 4 Aug 2017 09:36:17 +0000 (11:36 +0200)
The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
no longer used. Remove the dead code and hook up the crtc .gamma_set
to use the crtc gamma_store directly instead of duplicating that
info locally.

Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Peter Rosin <peda@axentia.se>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20170713162538.22788-13-peda@axentia.se
drivers/gpu/drm/radeon/atombios_crtc.c
drivers/gpu/drm/radeon/radeon_connectors.c
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/radeon_fb.c
drivers/gpu/drm/radeon/radeon_legacy_crtc.c
drivers/gpu/drm/radeon/radeon_mode.h

index 3c492a0aa6bd4813ee3683c9fdff8aadb0cf5929..02baaaf20e9d07a09b957ebcc957fc8393bfae41 100644 (file)
@@ -2217,7 +2217,6 @@ static const struct drm_crtc_helper_funcs atombios_helper_funcs = {
        .mode_set_base_atomic = atombios_crtc_set_base_atomic,
        .prepare = atombios_crtc_prepare,
        .commit = atombios_crtc_commit,
-       .load_lut = radeon_crtc_load_lut,
        .disable = atombios_crtc_disable,
 };
 
index 27affbde058c626eec6ae5b5b77cd9a2d4601ba9..2f642cbefd8eaa2223205f99bdac474d658a076c 100644 (file)
@@ -773,12 +773,15 @@ static int radeon_connector_set_property(struct drm_connector *connector, struct
 
                if (connector->encoder->crtc) {
                        struct drm_crtc *crtc  = connector->encoder->crtc;
-                       const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
                        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
 
                        radeon_crtc->output_csc = radeon_encoder->output_csc;
 
-                       (*crtc_funcs->load_lut)(crtc);
+                       /*
+                        * Our .gamma_set assumes the .gamma_store has been
+                        * prefilled and don't care about its arguments.
+                        */
+                       crtc->funcs->gamma_set(crtc, NULL, NULL, NULL, 0, NULL);
                }
        }
 
index 17d3dafc8319881eae56c83a1ac1a00b169f945e..8b7d7a0d3ca8e7ca325727a0fcd2cd16ca084780 100644 (file)
@@ -42,6 +42,7 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
+       u16 *r, *g, *b;
        int i;
 
        DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -60,11 +61,14 @@ static void avivo_crtc_load_lut(struct drm_crtc *crtc)
        WREG32(AVIVO_DC_LUT_WRITE_EN_MASK, 0x0000003f);
 
        WREG8(AVIVO_DC_LUT_RW_INDEX, 0);
+       r = crtc->gamma_store;
+       g = r + crtc->gamma_size;
+       b = g + crtc->gamma_size;
        for (i = 0; i < 256; i++) {
                WREG32(AVIVO_DC_LUT_30_COLOR,
-                            (radeon_crtc->lut_r[i] << 20) |
-                            (radeon_crtc->lut_g[i] << 10) |
-                            (radeon_crtc->lut_b[i] << 0));
+                      ((*r++ & 0xffc0) << 14) |
+                      ((*g++ & 0xffc0) << 4) |
+                      (*b++ >> 6));
        }
 
        /* Only change bit 0 of LUT_SEL, other bits are set elsewhere */
@@ -76,6 +80,7 @@ static void dce4_crtc_load_lut(struct drm_crtc *crtc)
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
+       u16 *r, *g, *b;
        int i;
 
        DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -93,11 +98,14 @@ static void dce4_crtc_load_lut(struct drm_crtc *crtc)
        WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + radeon_crtc->crtc_offset, 0x00000007);
 
        WREG32(EVERGREEN_DC_LUT_RW_INDEX + radeon_crtc->crtc_offset, 0);
+       r = crtc->gamma_store;
+       g = r + crtc->gamma_size;
+       b = g + crtc->gamma_size;
        for (i = 0; i < 256; i++) {
                WREG32(EVERGREEN_DC_LUT_30_COLOR + radeon_crtc->crtc_offset,
-                      (radeon_crtc->lut_r[i] << 20) |
-                      (radeon_crtc->lut_g[i] << 10) |
-                      (radeon_crtc->lut_b[i] << 0));
+                      ((*r++ & 0xffc0) << 14) |
+                      ((*g++ & 0xffc0) << 4) |
+                      (*b++ >> 6));
        }
 }
 
@@ -106,6 +114,7 @@ static void dce5_crtc_load_lut(struct drm_crtc *crtc)
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
+       u16 *r, *g, *b;
        int i;
 
        DRM_DEBUG_KMS("%d\n", radeon_crtc->crtc_id);
@@ -135,11 +144,14 @@ static void dce5_crtc_load_lut(struct drm_crtc *crtc)
        WREG32(EVERGREEN_DC_LUT_WRITE_EN_MASK + radeon_crtc->crtc_offset, 0x00000007);
 
        WREG32(EVERGREEN_DC_LUT_RW_INDEX + radeon_crtc->crtc_offset, 0);
+       r = crtc->gamma_store;
+       g = r + crtc->gamma_size;
+       b = g + crtc->gamma_size;
        for (i = 0; i < 256; i++) {
                WREG32(EVERGREEN_DC_LUT_30_COLOR + radeon_crtc->crtc_offset,
-                      (radeon_crtc->lut_r[i] << 20) |
-                      (radeon_crtc->lut_g[i] << 10) |
-                      (radeon_crtc->lut_b[i] << 0));
+                      ((*r++ & 0xffc0) << 14) |
+                      ((*g++ & 0xffc0) << 4) |
+                      (*b++ >> 6));
        }
 
        WREG32(NI_DEGAMMA_CONTROL + radeon_crtc->crtc_offset,
@@ -172,6 +184,7 @@ static void legacy_crtc_load_lut(struct drm_crtc *crtc)
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
        struct drm_device *dev = crtc->dev;
        struct radeon_device *rdev = dev->dev_private;
+       u16 *r, *g, *b;
        int i;
        uint32_t dac2_cntl;
 
@@ -183,11 +196,14 @@ static void legacy_crtc_load_lut(struct drm_crtc *crtc)
        WREG32(RADEON_DAC_CNTL2, dac2_cntl);
 
        WREG8(RADEON_PALETTE_INDEX, 0);
+       r = crtc->gamma_store;
+       g = r + crtc->gamma_size;
+       b = g + crtc->gamma_size;
        for (i = 0; i < 256; i++) {
                WREG32(RADEON_PALETTE_30_DATA,
-                            (radeon_crtc->lut_r[i] << 20) |
-                            (radeon_crtc->lut_g[i] << 10) |
-                            (radeon_crtc->lut_b[i] << 0));
+                      ((*r++ & 0xffc0) << 14) |
+                      ((*g++ & 0xffc0) << 4) |
+                      (*b++ >> 6));
        }
 }
 
@@ -209,41 +225,10 @@ void radeon_crtc_load_lut(struct drm_crtc *crtc)
                legacy_crtc_load_lut(crtc);
 }
 
-/** Sets the color ramps on behalf of fbcon */
-void radeon_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-                             u16 blue, int regno)
-{
-       struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-
-       radeon_crtc->lut_r[regno] = red >> 6;
-       radeon_crtc->lut_g[regno] = green >> 6;
-       radeon_crtc->lut_b[regno] = blue >> 6;
-}
-
-/** Gets the color ramps on behalf of fbcon */
-void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-                             u16 *blue, int regno)
-{
-       struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-
-       *red = radeon_crtc->lut_r[regno] << 6;
-       *green = radeon_crtc->lut_g[regno] << 6;
-       *blue = radeon_crtc->lut_b[regno] << 6;
-}
-
 static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
                                 u16 *blue, uint32_t size,
                                 struct drm_modeset_acquire_ctx *ctx)
 {
-       struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-       int i;
-
-       /* userspace palettes are always correct as is */
-       for (i = 0; i < size; i++) {
-               radeon_crtc->lut_r[i] = red[i] >> 6;
-               radeon_crtc->lut_g[i] = green[i] >> 6;
-               radeon_crtc->lut_b[i] = blue[i] >> 6;
-       }
        radeon_crtc_load_lut(crtc);
 
        return 0;
index e141fcd5e8e136f481605dbe1bcbcb518f5c325e..4b8f072d480a382ea8533932e04550ab879ee227 100644 (file)
@@ -331,8 +331,6 @@ static int radeon_fbdev_destroy(struct drm_device *dev, struct radeon_fbdev *rfb
 }
 
 static const struct drm_fb_helper_funcs radeon_fb_helper_funcs = {
-       .gamma_set = radeon_crtc_fb_gamma_set,
-       .gamma_get = radeon_crtc_fb_gamma_get,
        .fb_probe = radeonfb_create,
 };
 
index ce6cb66662127aade60da663e38aedb5fddf3824..1f1856e0b1e06bd8dbd2d613fbf05aa9892f0c50 100644 (file)
@@ -1116,7 +1116,6 @@ static const struct drm_crtc_helper_funcs legacy_helper_funcs = {
        .mode_set_base_atomic = radeon_crtc_set_base_atomic,
        .prepare = radeon_crtc_prepare,
        .commit = radeon_crtc_commit,
-       .load_lut = radeon_crtc_load_lut,
        .disable = radeon_crtc_disable
 };
 
index 00f5ec5c12c7afba423876584648aa0ce7d05131..da44ac234f6410731d0207ee3d25ed15f8b778c0 100644 (file)
@@ -935,10 +935,6 @@ extern void
 radeon_combios_encoder_crtc_scratch_regs(struct drm_encoder *encoder, int crtc);
 extern void
 radeon_combios_encoder_dpms_scratch_regs(struct drm_encoder *encoder, bool on);
-extern void radeon_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-                                    u16 blue, int regno);
-extern void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                    u16 *blue, int regno);
 int radeon_framebuffer_init(struct drm_device *dev,
                             struct radeon_framebuffer *rfb,
                             const struct drm_mode_fb_cmd2 *mode_cmd,