drm: cirrus: remove dead code and pointless local lut storage
authorPeter Rosin <peda@axentia.se>
Thu, 13 Jul 2017 16:25:31 +0000 (18:25 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 4 Aug 2017 09:35:44 +0000 (11:35 +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>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20170713162538.22788-8-peda@axentia.se
drivers/gpu/drm/cirrus/cirrus_drv.h
drivers/gpu/drm/cirrus/cirrus_fbdev.c
drivers/gpu/drm/cirrus/cirrus_mode.c

index 8690352d96f7b49c169fac7760e1fea1f36acbd1..be2d7e4880621a075b4d0f900d14cc204e86c262 100644 (file)
@@ -96,7 +96,6 @@
 
 struct cirrus_crtc {
        struct drm_crtc                 base;
-       u8                              lut_r[256], lut_g[256], lut_b[256];
        int                             last_dpms;
        bool                            enabled;
 };
@@ -180,13 +179,6 @@ cirrus_bo(struct ttm_buffer_object *bo)
 #define to_cirrus_obj(x) container_of(x, struct cirrus_gem_object, base)
 #define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)
 
-                               /* cirrus_mode.c */
-void cirrus_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-                            u16 blue, int regno);
-void cirrus_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-                            u16 *blue, int regno);
-
-
                                /* cirrus_main.c */
 int cirrus_device_init(struct cirrus_device *cdev,
                      struct drm_device *ddev,
index c69586163d92c25f72de5f38ccfed259cb0c18af..0f6815f35ad2dad59063e51946f2a86c1bf9b4d5 100644 (file)
@@ -264,8 +264,6 @@ static int cirrus_fbdev_destroy(struct drm_device *dev,
 }
 
 static const struct drm_fb_helper_funcs cirrus_fb_helper_funcs = {
-       .gamma_set = cirrus_crtc_fb_gamma_set,
-       .gamma_get = cirrus_crtc_fb_gamma_get,
        .fb_probe = cirrusfb_create,
 };
 
index 53f6f0f84206f03143522d345627c7782164c6fb..a4c4a465b38523e69abcc92e70578bc6f2e1db49 100644 (file)
  * This file contains setup code for the CRTC.
  */
 
-static void cirrus_crtc_load_lut(struct drm_crtc *crtc)
-{
-       struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-       struct drm_device *dev = crtc->dev;
-       struct cirrus_device *cdev = dev->dev_private;
-       int i;
-
-       if (!crtc->enabled)
-               return;
-
-       for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
-               /* VGA registers */
-               WREG8(PALETTE_INDEX, i);
-               WREG8(PALETTE_DATA, cirrus_crtc->lut_r[i]);
-               WREG8(PALETTE_DATA, cirrus_crtc->lut_g[i]);
-               WREG8(PALETTE_DATA, cirrus_crtc->lut_b[i]);
-       }
-}
-
 /*
  * The DRM core requires DPMS functions, but they make little sense in our
  * case and so are just stubs
@@ -330,15 +311,25 @@ static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
                                 u16 *blue, uint32_t size,
                                 struct drm_modeset_acquire_ctx *ctx)
 {
-       struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
+       struct drm_device *dev = crtc->dev;
+       struct cirrus_device *cdev = dev->dev_private;
+       u16 *r, *g, *b;
        int i;
 
-       for (i = 0; i < size; i++) {
-               cirrus_crtc->lut_r[i] = red[i];
-               cirrus_crtc->lut_g[i] = green[i];
-               cirrus_crtc->lut_b[i] = blue[i];
+       if (!crtc->enabled)
+               return 0;
+
+       r = crtc->gamma_store;
+       g = r + crtc->gamma_size;
+       b = g + crtc->gamma_size;
+
+       for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
+               /* VGA registers */
+               WREG8(PALETTE_INDEX, i);
+               WREG8(PALETTE_DATA, *r++ >> 8);
+               WREG8(PALETTE_DATA, *g++ >> 8);
+               WREG8(PALETTE_DATA, *b++ >> 8);
        }
-       cirrus_crtc_load_lut(crtc);
 
        return 0;
 }
@@ -365,7 +356,6 @@ static const struct drm_crtc_helper_funcs cirrus_helper_funcs = {
        .mode_set_base = cirrus_crtc_mode_set_base,
        .prepare = cirrus_crtc_prepare,
        .commit = cirrus_crtc_commit,
-       .load_lut = cirrus_crtc_load_lut,
 };
 
 /* CRTC setup */
@@ -373,7 +363,6 @@ static void cirrus_crtc_init(struct drm_device *dev)
 {
        struct cirrus_device *cdev = dev->dev_private;
        struct cirrus_crtc *cirrus_crtc;
-       int i;
 
        cirrus_crtc = kzalloc(sizeof(struct cirrus_crtc) +
                              (CIRRUSFB_CONN_LIMIT * sizeof(struct drm_connector *)),
@@ -387,37 +376,9 @@ static void cirrus_crtc_init(struct drm_device *dev)
        drm_mode_crtc_set_gamma_size(&cirrus_crtc->base, CIRRUS_LUT_SIZE);
        cdev->mode_info.crtc = cirrus_crtc;
 
-       for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
-               cirrus_crtc->lut_r[i] = i;
-               cirrus_crtc->lut_g[i] = i;
-               cirrus_crtc->lut_b[i] = i;
-       }
-
        drm_crtc_helper_add(&cirrus_crtc->base, &cirrus_helper_funcs);
 }
 
-/** Sets the color ramps on behalf of fbcon */
-void cirrus_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-                             u16 blue, int regno)
-{
-       struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-
-       cirrus_crtc->lut_r[regno] = red;
-       cirrus_crtc->lut_g[regno] = green;
-       cirrus_crtc->lut_b[regno] = blue;
-}
-
-/** Gets the color ramps on behalf of fbcon */
-void cirrus_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-                             u16 *blue, int regno)
-{
-       struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
-
-       *red = cirrus_crtc->lut_r[regno];
-       *green = cirrus_crtc->lut_g[regno];
-       *blue = cirrus_crtc->lut_b[regno];
-}
-
 static void cirrus_encoder_mode_set(struct drm_encoder *encoder,
                                struct drm_display_mode *mode,
                                struct drm_display_mode *adjusted_mode)