Commit 6d124ff8 authored by Daniel Vetter's avatar Daniel Vetter

drm: Add acquire ctx to ->gamma_set hook

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: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarSinclair Yeh <syeh@vmware.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170403083304.9083-13-daniel.vetter@ffwll.ch
parent ca659e0e
...@@ -2631,7 +2631,8 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc) ...@@ -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, 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); struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i; int i;
......
...@@ -2651,7 +2651,8 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc) ...@@ -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, 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); struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i; int i;
......
...@@ -1998,7 +1998,8 @@ static void dce_v6_0_cursor_reset(struct drm_crtc *crtc) ...@@ -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, 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); struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i; int i;
......
...@@ -2482,7 +2482,8 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc) ...@@ -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, 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); struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i; int i;
......
...@@ -165,7 +165,8 @@ static void dce_virtual_bandwidth_update(struct amdgpu_device *adev) ...@@ -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, 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); struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
int i; int i;
......
...@@ -645,7 +645,8 @@ static void ast_crtc_reset(struct drm_crtc *crtc) ...@@ -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, 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); struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
int i; int i;
......
...@@ -327,7 +327,8 @@ static void cirrus_crtc_commit(struct drm_crtc *crtc) ...@@ -327,7 +327,8 @@ static void cirrus_crtc_commit(struct drm_crtc *crtc)
* but it's a requirement that we provide the function * but it's a requirement that we provide the function
*/ */
static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, 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); struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
int i; int i;
......
...@@ -3479,6 +3479,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state); ...@@ -3479,6 +3479,7 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
* @green: green correction table * @green: green correction table
* @blue: green correction table * @blue: green correction table
* @size: size of the tables * @size: size of the tables
* @ctx: lock acquire context
* *
* Implements support for legacy gamma correction table for drivers * Implements support for legacy gamma correction table for drivers
* that support color management through the DEGAMMA_LUT/GAMMA_LUT * that support color management through the DEGAMMA_LUT/GAMMA_LUT
...@@ -3486,7 +3487,8 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state); ...@@ -3486,7 +3487,8 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
*/ */
int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
u16 *red, u16 *green, u16 *blue, 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_device *dev = crtc->dev;
struct drm_mode_config *config = &dev->mode_config; struct drm_mode_config *config = &dev->mode_config;
......
...@@ -261,7 +261,8 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev, ...@@ -261,7 +261,8 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
goto out; 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: out:
if (ret == -EDEADLK) { if (ret == -EDEADLK) {
......
...@@ -256,7 +256,8 @@ static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc) ...@@ -256,7 +256,8 @@ static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
g_base = r_base + crtc->gamma_size; g_base = r_base + crtc->gamma_size;
b_base = g_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);
} }
/** /**
......
...@@ -177,7 +177,8 @@ void gma_crtc_load_lut(struct drm_crtc *crtc) ...@@ -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, 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); struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
int i; int i;
......
...@@ -73,7 +73,8 @@ extern int gma_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -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 int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
extern void gma_crtc_load_lut(struct drm_crtc *crtc); extern void gma_crtc_load_lut(struct drm_crtc *crtc);
extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, 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_dpms(struct drm_crtc *crtc, int mode);
extern void gma_crtc_prepare(struct drm_crtc *crtc); extern void gma_crtc_prepare(struct drm_crtc *crtc);
extern void gma_crtc_commit(struct drm_crtc *crtc); extern void gma_crtc_commit(struct drm_crtc *crtc);
......
...@@ -1393,7 +1393,8 @@ static void mga_crtc_commit(struct drm_crtc *crtc) ...@@ -1393,7 +1393,8 @@ static void mga_crtc_commit(struct drm_crtc *crtc)
* but it's a requirement that we provide the function * but it's a requirement that we provide the function
*/ */
static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, 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); struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
int i; int i;
......
...@@ -788,7 +788,8 @@ nv_crtc_disable(struct drm_crtc *crtc) ...@@ -788,7 +788,8 @@ nv_crtc_disable(struct drm_crtc *crtc)
static int static int
nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, 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); struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
int i; int i;
......
...@@ -2218,7 +2218,8 @@ nv50_head_help = { ...@@ -2218,7 +2218,8 @@ nv50_head_help = {
static int static int
nv50_head_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, 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); struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
u32 i; u32 i;
......
...@@ -232,7 +232,8 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, ...@@ -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, 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); struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
int i; int i;
......
...@@ -314,7 +314,8 @@ vc4_crtc_lut_load(struct drm_crtc *crtc) ...@@ -314,7 +314,8 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)
static int static int
vc4_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, 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); struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
u32 i; u32 i;
......
...@@ -2026,7 +2026,8 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num, ...@@ -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, int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
u16 *r, u16 *g, u16 *b, 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); struct vmw_private *dev_priv = vmw_priv(crtc->dev);
int i; int i;
......
...@@ -254,7 +254,8 @@ void vmw_du_crtc_save(struct drm_crtc *crtc); ...@@ -254,7 +254,8 @@ void vmw_du_crtc_save(struct drm_crtc *crtc);
void vmw_du_crtc_restore(struct drm_crtc *crtc); void vmw_du_crtc_restore(struct drm_crtc *crtc);
int vmw_du_crtc_gamma_set(struct drm_crtc *crtc, int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
u16 *r, u16 *g, u16 *b, 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, int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
uint32_t handle, uint32_t width, uint32_t height, uint32_t handle, uint32_t width, uint32_t height,
int32_t hot_x, int32_t hot_y); int32_t hot_x, int32_t hot_y);
......
...@@ -176,7 +176,8 @@ void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector, ...@@ -176,7 +176,8 @@ void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
struct drm_connector_state *state); struct drm_connector_state *state);
int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc, int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
u16 *red, u16 *green, u16 *blue, 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 * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
......
...@@ -322,7 +322,8 @@ struct drm_crtc_funcs { ...@@ -322,7 +322,8 @@ struct drm_crtc_funcs {
* hooks. * hooks.
*/ */
int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, 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: * @destroy:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment