drm: ast: remove dead code and pointless local lut storage
authorPeter Rosin <peda@axentia.se>
Thu, 13 Jul 2017 16:25:30 +0000 (18:25 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 4 Aug 2017 09:35:39 +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-7-peda@axentia.se
drivers/gpu/drm/ast/ast_drv.h
drivers/gpu/drm/ast/ast_fb.c
drivers/gpu/drm/ast/ast_mode.c

index 8880f0b62e9c2832845d7df2f40e0e77817a9f91..569a1484d52319e945d96c85e04908b04efd847d 100644 (file)
@@ -245,7 +245,6 @@ struct ast_connector {
 
 struct ast_crtc {
        struct drm_crtc base;
-       u8 lut_r[256], lut_g[256], lut_b[256];
        struct drm_gem_object *cursor_bo;
        uint64_t cursor_addr;
        int cursor_width, cursor_height;
index 53ca6d0992341572cd6a351f845d08cffa73d8dd..9052ebeae8d0ac79aae1c8b13cb66abdd3a7a57d 100644 (file)
@@ -254,27 +254,7 @@ out:
        return ret;
 }
 
-static void ast_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
-                              u16 blue, int regno)
-{
-       struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-       ast_crtc->lut_r[regno] = red >> 8;
-       ast_crtc->lut_g[regno] = green >> 8;
-       ast_crtc->lut_b[regno] = blue >> 8;
-}
-
-static void ast_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
-                              u16 *blue, int regno)
-{
-       struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-       *red = ast_crtc->lut_r[regno] << 8;
-       *green = ast_crtc->lut_g[regno] << 8;
-       *blue = ast_crtc->lut_b[regno] << 8;
-}
-
 static const struct drm_fb_helper_funcs ast_fb_helper_funcs = {
-       .gamma_set = ast_fb_gamma_set,
-       .gamma_get = ast_fb_gamma_get,
        .fb_probe = astfb_create,
 };
 
index aaef0a652f10fdf145b272dc4f28782abfb8701a..724c16bb6a621b5b90d031a7a2d565792f00be82 100644 (file)
@@ -63,15 +63,18 @@ static inline void ast_load_palette_index(struct ast_private *ast,
 static void ast_crtc_load_lut(struct drm_crtc *crtc)
 {
        struct ast_private *ast = crtc->dev->dev_private;
-       struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
+       u16 *r, *g, *b;
        int i;
 
        if (!crtc->enabled)
                return;
 
+       r = crtc->gamma_store;
+       g = r + crtc->gamma_size;
+       b = g + crtc->gamma_size;
+
        for (i = 0; i < 256; i++)
-               ast_load_palette_index(ast, i, ast_crtc->lut_r[i],
-                                      ast_crtc->lut_g[i], ast_crtc->lut_b[i]);
+               ast_load_palette_index(ast, i, *r++ >> 8, *g++ >> 8, *b++ >> 8);
 }
 
 static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mode *mode,
@@ -633,7 +636,6 @@ static const struct drm_crtc_helper_funcs ast_crtc_helper_funcs = {
        .mode_set = ast_crtc_mode_set,
        .mode_set_base = ast_crtc_mode_set_base,
        .disable = ast_crtc_disable,
-       .load_lut = ast_crtc_load_lut,
        .prepare = ast_crtc_prepare,
        .commit = ast_crtc_commit,
 
@@ -648,15 +650,6 @@ static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
                              u16 *blue, uint32_t size,
                              struct drm_modeset_acquire_ctx *ctx)
 {
-       struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-       int i;
-
-       /* userspace palettes are always correct as is */
-       for (i = 0; i < size; i++) {
-               ast_crtc->lut_r[i] = red[i] >> 8;
-               ast_crtc->lut_g[i] = green[i] >> 8;
-               ast_crtc->lut_b[i] = blue[i] >> 8;
-       }
        ast_crtc_load_lut(crtc);
 
        return 0;
@@ -681,7 +674,6 @@ static const struct drm_crtc_funcs ast_crtc_funcs = {
 static int ast_crtc_init(struct drm_device *dev)
 {
        struct ast_crtc *crtc;
-       int i;
 
        crtc = kzalloc(sizeof(struct ast_crtc), GFP_KERNEL);
        if (!crtc)
@@ -690,12 +682,6 @@ static int ast_crtc_init(struct drm_device *dev)
        drm_crtc_init(dev, &crtc->base, &ast_crtc_funcs);
        drm_mode_crtc_set_gamma_size(&crtc->base, 256);
        drm_crtc_helper_add(&crtc->base, &ast_crtc_helper_funcs);
-
-       for (i = 0; i < 256; i++) {
-               crtc->lut_r[i] = i;
-               crtc->lut_g[i] = i;
-               crtc->lut_b[i] = i;
-       }
        return 0;
 }