drm: Add acquire ctx to ->gamma_set hook
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 3 Apr 2017 08:33:01 +0000 (10:33 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 6 Apr 2017 08:21:55 +0000 (10:21 +0200)
Atomic helpers really want this instead of the hacked-up legacy
backoff trick, which unfortunately prevents drivers from using their
own private drm_modeset_locks.

Aside: There's a few atomic drivers (nv50, vc4, soon vmwgfx) which
don't yet use the new atomic color mgmt/gamma table stuff. Would be
nice if they could switch over and just hook up
drm_atomic_helper_legacy_gamma_set() instead.

Cc: Dave Airlie <airlied@redhat.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Sinclair Yeh <syeh@vmware.com>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Eric Anholt <eric@anholt.net>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170403083304.9083-13-daniel.vetter@ffwll.ch
21 files changed:
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
drivers/gpu/drm/amd/amdgpu/dce_virtual.c
drivers/gpu/drm/ast/ast_mode.c
drivers/gpu/drm/cirrus/cirrus_mode.c
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_color_mgmt.c
drivers/gpu/drm/drm_fb_helper.c
drivers/gpu/drm/gma500/gma_display.c
drivers/gpu/drm/gma500/gma_display.h
drivers/gpu/drm/mgag200/mgag200_mode.c
drivers/gpu/drm/nouveau/dispnv04/crtc.c
drivers/gpu/drm/nouveau/nv50_display.c
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/vc4/vc4_crtc.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
include/drm/drm_atomic_helper.h
include/drm/drm_crtc.h

index f525ae4e057627617d94863998f4fb1d423efffa..daf003dd2351b465fa92aea0820ac15c3b7e2df4 100644 (file)
@@ -2631,7 +2631,8 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
 }
 
 static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                   u16 *blue, uint32_t size)
+                                   u16 *blue, uint32_t size,
+                                   struct drm_modeset_acquire_ctx *ctx)
 {
        struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
        int i;
index 3eac27f24d9424c4f959b6286f7d4d5f08a4b0c7..3a729672445742a05551625b780e7a725647dc4b 100644 (file)
@@ -2651,7 +2651,8 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
 }
 
 static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                   u16 *blue, uint32_t size)
+                                   u16 *blue, uint32_t size,
+                                   struct drm_modeset_acquire_ctx *ctx)
 {
        struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
        int i;
index 838cf1a778f2f034b4e5964108794f6c3a1a5074..8ccada5d6f392039927c2d12055bafd7537f8273 100644 (file)
@@ -1998,7 +1998,8 @@ static void dce_v6_0_cursor_reset(struct drm_crtc *crtc)
 }
 
 static int dce_v6_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                  u16 *blue, uint32_t size)
+                                  u16 *blue, uint32_t size,
+                                  struct drm_modeset_acquire_ctx *ctx)
 {
        struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
        int i;
index 1b0717b11efeac78914c52f7c40688c458e2bca9..6943f2641c9042134f7148168f8f78ebd5db4f19 100644 (file)
@@ -2482,7 +2482,8 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
 }
 
 static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                  u16 *blue, uint32_t size)
+                                  u16 *blue, uint32_t size,
+                                  struct drm_modeset_acquire_ctx *ctx)
 {
        struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
        int i;
index 5c51f9a97811ea8db63fb914fc7f944dcf0ca316..81a24b6b484625bfc76916be44e6bd4e9ba53dcf 100644 (file)
@@ -165,7 +165,8 @@ static void dce_virtual_bandwidth_update(struct amdgpu_device *adev)
 }
 
 static int dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,
-                                     u16 *green, u16 *blue, uint32_t size)
+                                     u16 *green, u16 *blue, uint32_t size,
+                                     struct drm_modeset_acquire_ctx *ctx)
 {
        struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
        int i;
index 47b78e52691cb33bb7cc3b189d92f35b11510340..aaef0a652f10fdf145b272dc4f28782abfb8701a 100644 (file)
@@ -645,7 +645,8 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
 }
 
 static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                             u16 *blue, uint32_t size)
+                             u16 *blue, uint32_t size,
+                             struct drm_modeset_acquire_ctx *ctx)
 {
        struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
        int i;
index ed43ab10ac993d16e7ce44767cbaa87522e1e1cc..53f6f0f84206f03143522d345627c7782164c6fb 100644 (file)
@@ -327,7 +327,8 @@ static void cirrus_crtc_commit(struct drm_crtc *crtc)
  * but it's a requirement that we provide the function
  */
 static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                u16 *blue, uint32_t size)
+                                u16 *blue, uint32_t size,
+                                struct drm_modeset_acquire_ctx *ctx)
 {
        struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
        int i;
index 0a3d91c51d611b1b233df9d1cbf9ec29c46bc22b..25569e5b3adcede3d9e9d4bd42461a4d8091da53 100644 (file)
@@ -3479,6 +3479,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
  * @green: green correction table
  * @blue: green correction table
  * @size: size of the tables
+ * @ctx: lock acquire context
  *
  * Implements support for legacy gamma correction table for drivers
  * that support color management through the DEGAMMA_LUT/GAMMA_LUT
@@ -3486,7 +3487,8 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
  */
 int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
                                       u16 *red, u16 *green, u16 *blue,
-                                      uint32_t size)
+                                      uint32_t size,
+                                      struct drm_modeset_acquire_ctx *ctx)
 {
        struct drm_device *dev = crtc->dev;
        struct drm_mode_config *config = &dev->mode_config;
index e1b4084c3d16b9cd8b40c343e0a5d63c9eea54a8..b81dcb1d4cb3b7227c71ba77a98eb2af4ddb2a08 100644 (file)
@@ -261,7 +261,8 @@ retry:
                goto out;
        }
 
-       ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
+       ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base,
+                                    crtc->gamma_size, &ctx);
 
 out:
        if (ret == -EDEADLK) {
index 9147abb774e802c86c5baba7d8474096c99765bd..6dc5381e1c45d711cf4c6b27f9f7eff033146007 100644 (file)
@@ -256,7 +256,8 @@ static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
        g_base = r_base + crtc->gamma_size;
        b_base = g_base + crtc->gamma_size;
 
-       crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
+       crtc->funcs->gamma_set(crtc, r_base, g_base, b_base,
+                              crtc->gamma_size, NULL);
 }
 
 /**
index 93ff46535c046bb0bb698af909a68481033574ab..e7fd356acf2e2e7613127388c4f3900961a2f866 100644 (file)
@@ -177,7 +177,8 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
 }
 
 int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
-                      u32 size)
+                      u32 size,
+                      struct drm_modeset_acquire_ctx *ctx)
 {
        struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
        int i;
index 166e608923dbd589077f993432d6daa0499d0d25..239c374b61691e88458f7f67eb388b832ebd1f15 100644 (file)
@@ -73,7 +73,8 @@ extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
 extern int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
 extern void gma_crtc_load_lut(struct drm_crtc *crtc);
 extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                             u16 *blue, u32 size);
+                             u16 *blue, u32 size,
+                             struct drm_modeset_acquire_ctx *ctx);
 extern void gma_crtc_dpms(struct drm_crtc *crtc, int mode);
 extern void gma_crtc_prepare(struct drm_crtc *crtc);
 extern void gma_crtc_commit(struct drm_crtc *crtc);
index f2e9b2bc18a58da273a9d2b140737ff6db1f6bae..adb411a078e8237c0fcb5ecde76bdf1287f9df50 100644 (file)
@@ -1393,7 +1393,8 @@ static void mga_crtc_commit(struct drm_crtc *crtc)
  * but it's a requirement that we provide the function
  */
 static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                             u16 *blue, uint32_t size)
+                             u16 *blue, uint32_t size,
+                             struct drm_modeset_acquire_ctx *ctx)
 {
        struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
        int i;
index 43ab560de7f98884a4c5f018805093b9af69f7d6..4b4b0b49626218c087705f90c7090384cbbda70f 100644 (file)
@@ -788,7 +788,8 @@ nv_crtc_disable(struct drm_crtc *crtc)
 
 static int
 nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-                 uint32_t size)
+                 uint32_t size,
+                 struct drm_modeset_acquire_ctx *ctx)
 {
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
        int i;
index 3d381d5c82ce45d2bf19bdf7b0afcbbbf792ec38..bf504788bce6b45ef5c75980365fdeec37cc532f 100644 (file)
@@ -2218,7 +2218,8 @@ nv50_head_help = {
 
 static int
 nv50_head_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-                   uint32_t size)
+                   uint32_t size,
+                   struct drm_modeset_acquire_ctx *ctx)
 {
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
        u32 i;
index 146297a702ab0fe95752fa72e581f86c1d917954..981385eb5389b8e2132f46dcb28387d00f662d22 100644 (file)
@@ -232,7 +232,8 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
 }
 
 static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                u16 *blue, uint32_t size)
+                                u16 *blue, uint32_t size,
+                                struct drm_modeset_acquire_ctx *ctx)
 {
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
        int i;
index e8f28c9145a063e5bd3af3f035b25c1139018949..d86c8cce318270a0e34b09c3a1713d48e1a4ff0b 100644 (file)
@@ -314,7 +314,8 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)
 
 static int
 vc4_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-                  uint32_t size)
+                  uint32_t size,
+                  struct drm_modeset_acquire_ctx *ctx)
 {
        struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
        u32 i;
index 6078654d033b5af1f3be338ca1fa4fde9c9226d6..ef9f3a2a40303290287b5259b7a71d2a8791ddb4 100644 (file)
@@ -2026,7 +2026,8 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
 
 int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
                          u16 *r, u16 *g, u16 *b,
-                         uint32_t size)
+                         uint32_t size,
+                         struct drm_modeset_acquire_ctx *ctx)
 {
        struct vmw_private *dev_priv = vmw_priv(crtc->dev);
        int i;
index 0c226b2adea5e34f4007fad71395dcdae9b8e2ed..13f2f1d2818a755012098df126938989ba1fb297 100644 (file)
@@ -254,7 +254,8 @@ void vmw_du_crtc_save(struct drm_crtc *crtc);
 void vmw_du_crtc_restore(struct drm_crtc *crtc);
 int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
                           u16 *r, u16 *g, u16 *b,
-                          uint32_t size);
+                          uint32_t size,
+                          struct drm_modeset_acquire_ctx *ctx);
 int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
                            uint32_t handle, uint32_t width, uint32_t height,
                            int32_t hot_x, int32_t hot_y);
index fd395dc050ee36c56b38ff4e26ac30cffa988b14..f0a8678ae98e542c8632262437c3f5568ecf2398 100644 (file)
@@ -176,7 +176,8 @@ void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
                                          struct drm_connector_state *state);
 int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
                                       u16 *red, u16 *green, u16 *blue,
-                                      uint32_t size);
+                                      uint32_t size,
+                                      struct drm_modeset_acquire_ctx *ctx);
 
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
index ede60d67976ff3ca1e867e34a3457a3ac498f76a..a8176a836e25d2cb6599d45351d4b8068a8f76af 100644 (file)
@@ -322,7 +322,8 @@ struct drm_crtc_funcs {
         * hooks.
         */
        int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-                        uint32_t size);
+                        uint32_t size,
+                        struct drm_modeset_acquire_ctx *ctx);
 
        /**
         * @destroy: