Skip to contentSkip to conversation

drm/core: Change declaration for gamma_set.

PATCH Superseded Maarten Lankhorst 7 participants 13 messages Jun 6, 2016 – Jun 7, 2016

Subsystems (9)
lore
Share & tools
lore

Maarten Lankhorst

author maintainer
#0 lore raw

PATCH 1/1 drm/core: Change declaration for gamma_set.

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David Airlie <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Eric Anholt <[email protected]>
Cc VMware Graphics <[email protected]>
Cc Mathieu Larouche <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++++++----
 drivers/gpu/drm/ast/ast_mode.c          | 10 ++++++----
 drivers/gpu/drm/cirrus/cirrus_mode.c    |  8 +++++---
 drivers/gpu/drm/drm_atomic_helper.c     | 13 ++++++-------
 drivers/gpu/drm/drm_crtc.c              |  2 +-
 drivers/gpu/drm/drm_fb_helper.c         |  4 +---
 drivers/gpu/drm/gma500/gma_display.c    |  9 +++++----
 drivers/gpu/drm/gma500/gma_display.h    |  4 ++--
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +++++----
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++++++-----
 drivers/gpu/drm/nouveau/nv50_display.c  |  9 +++++----
 drivers/gpu/drm/radeon/radeon_display.c | 11 +++++++----
 drivers/gpu/drm/vc4/vc4_crtc.c          |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c     |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h     |  4 ++--
 include/drm/drm_atomic_helper.h         |  6 +++---
 include/drm/drm_crtc.h                  |  4 ++--
 19 files changed, 85 insertions(+), 66 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +6 -4
index 8227344d2ff6..16de862ea51f 100644
@@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v10_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +6 -4
index af26ec0bc59d..6e0ae8e2e65c 100644
@@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v11_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +6 -4
index 3fb65e41a6ef..7b5fae4c74f1 100644
@@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				   u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v8_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/ast/ast_mode.c +6 -4
index c337922606e3..5957c3e659fe 100644
@@ -624,19 +624,21 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
 
 }
 
-static void ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				 u16 *blue, uint32_t start, uint32_t size)
+static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, uint32_t size)
 {
 	struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 
drivers/gpu/drm/cirrus/cirrus_mode.c +5 -3
index 0b1a411cb89e..17c915d9a03e 100644
@@ -325,18 +325,20 @@ static void cirrus_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				 u16 *blue, uint32_t size)
 {
 	struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
 	int i;
 
-	for (i = 0; i < CIRRUS_LUT_SIZE; 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];
 	}
 	cirrus_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/drm_atomic_helper.c +6 -7
index 939df900dcaa..266c11018a19 100644
@@ -2933,16 +2933,15 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
  * @red: red correction table
  * @green: green correction table
  * @blue: green correction table
- * @start:
  * @size: size of the tables
  *
  * Implements support for legacy gamma correction table for drivers
  * that support color management through the DEGAMMA_LUT/GAMMA_LUT
  * properties.
  */
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size)
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_mode_config *config = &dev->mode_config;
@@ -2954,7 +2953,7 @@ void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 
 	state = drm_atomic_state_alloc(crtc->dev);
 	if (!state)
-		return;
+		return -ENOMEM;
 
 	blob = drm_property_create_blob(dev,
 					sizeof(struct drm_color_lut) * size,
@@ -3005,7 +3004,7 @@ retry:
 
 	drm_property_unreference_blob(blob);
 
-	return;
+	return 0;
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -3013,7 +3012,7 @@ fail:
 	drm_atomic_state_free(state);
 	drm_property_unreference_blob(blob);
 
-	return;
+	return ret;
 backoff:
 	drm_atomic_state_clear(state);
 	drm_atomic_legacy_backoff(state);
drivers/gpu/drm/drm_crtc.c +1 -1
index d2a6d958ca76..4d61ceae789c 100644
@@ -5215,7 +5215,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
 		goto out;
 	}
 
-	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size);
+	ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 
 out:
 	drm_modeset_unlock_all(dev);
drivers/gpu/drm/drm_fb_helper.c +1 -3
index 7590df5e2e72..4accf6039058 100644
@@ -227,7 +227,7 @@ 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, 0, crtc->gamma_size);
+	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 }
 
 /**
@@ -1076,8 +1076,6 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 	WARN_ON(fb->bits_per_pixel != 8);
 
 	fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
-	return 0;
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.c +5 -4
index c95406e6f44d..5b636bf0b467 100644
@@ -175,20 +175,21 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
 	}
 }
 
-void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
-			u32 start, u32 size)
+int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
+		       u32 size)
 {
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
 	int i;
-	int end = (start + size > 256) ? 256 : start + size;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		gma_crtc->lut_r[i] = red[i] >> 8;
 		gma_crtc->lut_g[i] = green[i] >> 8;
 		gma_crtc->lut_b[i] = blue[i] >> 8;
 	}
 
 	gma_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.h +2 -2
index b2491c65f053..e72dd08b701b 100644
@@ -72,8 +72,8 @@ extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
 			       uint32_t width, uint32_t height);
 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_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-			       u16 *blue, u32 start, u32 size);
+extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, u32 size);
 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);
drivers/gpu/drm/mgag200/mgag200_mode.c +5 -4
index 14e64e08909e..f6d5892d03f1 100644
@@ -1344,19 +1344,20 @@ static void mga_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, uint32_t size)
 {
 	struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-	int end = (start + size > MGAG200_LUT_SIZE) ? MGAG200_LUT_SIZE : start + size;
 	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		mga_crtc->lut_r[i] = red[i] >> 8;
 		mga_crtc->lut_g[i] = green[i] >> 8;
 		mga_crtc->lut_b[i] = blue[i] >> 8;
 	}
 	mga_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/nouveau/dispnv04/crtc.c +7 -5
index 6f318c54da33..0cb7a18cde26 100644
@@ -785,14 +785,14 @@ nv_crtc_disable(struct drm_crtc *crtc)
 	nouveau_bo_ref(NULL, &disp->image[nv_crtc->index]);
 }
 
-static void
-nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
+static int
+nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
 		  uint32_t size)
 {
-	int end = (start + size > 256) ? 256 : start + size, i;
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
+	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
@@ -805,10 +805,12 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
 	 */
 	if (!nv_crtc->base.primary->fb) {
 		nv_crtc->lut.depth = 0;
-		return;
+		return 0;
 	}
 
 	nv_crtc_gamma_load(crtc);
+
+	return 0;
 }
 
 static int
drivers/gpu/drm/nouveau/nv50_display.c +5 -4
index 3ffc2b0057bf..7a7788212df7 100644
@@ -1346,21 +1346,22 @@ nv50_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 	return 0;
 }
 
-static void
+static int
 nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		    uint32_t start, uint32_t size)
+		    uint32_t size)
 {
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-	u32 end = min_t(u32, start + size, 256);
 	u32 i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
 	}
 
 	nv50_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static void
drivers/gpu/drm/radeon/radeon_display.c +7 -4
index 6a41b4982647..80f06db1dd34 100644
@@ -231,19 +231,21 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
 	*blue = radeon_crtc->lut_b[regno] << 6;
 }
 
-static void radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				 u16 *blue, uint32_t size)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 static void radeon_crtc_destroy(struct drm_crtc *crtc)
@@ -688,6 +690,7 @@ radeon_crtc_set_config(struct drm_mode_set *set)
 	pm_runtime_put_autosuspend(dev->dev);
 	return ret;
 }
+
 static const struct drm_crtc_funcs radeon_crtc_funcs = {
 	.cursor_set2 = radeon_crtc_cursor_set2,
 	.cursor_move = radeon_crtc_cursor_move,
drivers/gpu/drm/vc4/vc4_crtc.c +5 -3
index 904d0754ad78..4e34f054da5c 100644
@@ -175,20 +175,22 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)
 		HVS_WRITE(SCALER_GAMDATA, vc4_crtc->lut_b[i]);
 }
 
-static void
+static int
 vc4_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		   uint32_t start, uint32_t size)
+		   uint32_t size)
 {
 	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 	u32 i;
 
-	for (i = start; i < start + size; i++) {
+	for (i = 0; i < size; i++) {
 		vc4_crtc->lut_r[i] = r[i] >> 8;
 		vc4_crtc->lut_g[i] = g[i] >> 8;
 		vc4_crtc->lut_b[i] = b[i] >> 8;
 	}
 
 	vc4_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static u32 vc4_get_fifo_full_level(u32 format)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +5 -3
index 55231cce73a0..8a69d4da40b5 100644
@@ -1404,9 +1404,9 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
 	return 0;
 }
 
-void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
-			   u16 *r, u16 *g, u16 *b,
-			   uint32_t start, uint32_t size)
+int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
+			  u16 *r, u16 *g, u16 *b,
+			  uint32_t size)
 {
 	struct vmw_private *dev_priv = vmw_priv(crtc->dev);
 	int i;
@@ -1418,6 +1418,8 @@ void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 1, g[i] >> 8);
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 2, b[i] >> 8);
 	}
+
+	return 0;
 }
 
 int vmw_du_connector_dpms(struct drm_connector *connector, int mode)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +2 -2
index 57203212c501..ff4803c107bc 100644
@@ -195,9 +195,9 @@ struct vmw_display_unit {
 void vmw_du_cleanup(struct vmw_display_unit *du);
 void vmw_du_crtc_save(struct drm_crtc *crtc);
 void vmw_du_crtc_restore(struct drm_crtc *crtc);
-void 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,
-			   uint32_t start, uint32_t size);
+			   uint32_t size);
 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);
include/drm/drm_atomic_helper.h +3 -3
index d473dcc91f54..11896c84c4f8 100644
@@ -147,9 +147,9 @@ void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state);
 void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
 					  struct drm_connector_state *state);
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size);
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size);
 
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
include/drm/drm_crtc.h +2 -2
index d1559cd04e3d..8622bb2f4f25 100644
@@ -478,8 +478,8 @@ struct drm_crtc_funcs {
 	 * going on, which should eventually be unified to just one set of
 	 * hooks.
 	 */
-	void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-			  uint32_t start, uint32_t size);
+	int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
+			 uint32_t size);
 
 	/**
 	 * @destroy:
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

✗ Ro.CI.BAT: failure for drm/core: Change declaration for gamma_set.

== Series Details ==

== Series Details ==

Series: drm/core: Change declaration for gamma_set.
URL : https://patchwork.freedesktop.org/series/8332/
State : failure

== Summary ==

Applying: drm/core: Change declaration for gamma_set.
Using index info to reconstruct a base tree...
M drivers/gpu/drm/drm_atomic_helper.c
M drivers/gpu/drm/drm_crtc.c
M drivers/gpu/drm/mgag200/mgag200_mode.c
M drivers/gpu/drm/vc4/vc4_crtc.c
M include/drm/drm_atomic_helper.h
M include/drm/drm_crtc.h
Falling back to patching base and 3-way merge...
Auto-merging include/drm/drm_crtc.h
Auto-merging include/drm/drm_atomic_helper.h
Auto-merging drivers/gpu/drm/vc4/vc4_crtc.c
Auto-merging drivers/gpu/drm/mgag200/mgag200_mode.c Auto-merging drivers/gpu/drm/drm_crtc.c
Auto-merging drivers/gpu/drm/drm_atomic_helper.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/drm_atomic_helper.c
error: Failed to merge in the changes.
Patch failed at 0001 drm/core: Change declaration for gamma_set. The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw
In reply to Maarten Lankhorst
Quoted 3 lines · Maarten Lankhorst

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

Commit message should explain why we suddenly need to pass up the error code, too:

"This is needed for atomic drivers, where an atomic commit can fail with EAGAIN and should be restarted."

I'll add that when merging, but will wait for a bit more acks/r-b first. -Daniel

Quoted 558 lines
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David Airlie <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Eric Anholt <[email protected]>
Cc VMware Graphics <[email protected]>
Cc Mathieu Larouche <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++++++----
 drivers/gpu/drm/ast/ast_mode.c          | 10 ++++++----
 drivers/gpu/drm/cirrus/cirrus_mode.c    |  8 +++++---
 drivers/gpu/drm/drm_atomic_helper.c     | 13 ++++++-------
 drivers/gpu/drm/drm_crtc.c              |  2 +-
 drivers/gpu/drm/drm_fb_helper.c         |  4 +---
 drivers/gpu/drm/gma500/gma_display.c    |  9 +++++----
 drivers/gpu/drm/gma500/gma_display.h    |  4 ++--
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +++++----
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++++++-----
 drivers/gpu/drm/nouveau/nv50_display.c  |  9 +++++----
 drivers/gpu/drm/radeon/radeon_display.c | 11 +++++++----
 drivers/gpu/drm/vc4/vc4_crtc.c          |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c     |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h     |  4 ++--
 include/drm/drm_atomic_helper.h         |  6 +++---
 include/drm/drm_crtc.h                  |  4 ++--
 19 files changed, 85 insertions(+), 66 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +6 -4
index 8227344d2ff6..16de862ea51f 100644
@@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v10_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +6 -4
index af26ec0bc59d..6e0ae8e2e65c 100644
@@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v11_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +6 -4
index 3fb65e41a6ef..7b5fae4c74f1 100644
@@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				   u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v8_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/ast/ast_mode.c +6 -4
index c337922606e3..5957c3e659fe 100644
@@ -624,19 +624,21 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
 
 }
 
-static void ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				 u16 *blue, uint32_t start, uint32_t size)
+static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, uint32_t size)
 {
 	struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 
drivers/gpu/drm/cirrus/cirrus_mode.c +5 -3
index 0b1a411cb89e..17c915d9a03e 100644
@@ -325,18 +325,20 @@ static void cirrus_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				 u16 *blue, uint32_t size)
 {
 	struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
 	int i;
 
-	for (i = 0; i < CIRRUS_LUT_SIZE; 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];
 	}
 	cirrus_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/drm_atomic_helper.c +6 -7
index 939df900dcaa..266c11018a19 100644
@@ -2933,16 +2933,15 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
  * @red: red correction table
  * @green: green correction table
  * @blue: green correction table
- * @start:
  * @size: size of the tables
  *
  * Implements support for legacy gamma correction table for drivers
  * that support color management through the DEGAMMA_LUT/GAMMA_LUT
  * properties.
  */
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size)
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_mode_config *config = &dev->mode_config;
@@ -2954,7 +2953,7 @@ void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 
 	state = drm_atomic_state_alloc(crtc->dev);
 	if (!state)
-		return;
+		return -ENOMEM;
 
 	blob = drm_property_create_blob(dev,
 					sizeof(struct drm_color_lut) * size,
@@ -3005,7 +3004,7 @@ retry:
 
 	drm_property_unreference_blob(blob);
 
-	return;
+	return 0;
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -3013,7 +3012,7 @@ fail:
 	drm_atomic_state_free(state);
 	drm_property_unreference_blob(blob);
 
-	return;
+	return ret;
 backoff:
 	drm_atomic_state_clear(state);
 	drm_atomic_legacy_backoff(state);
drivers/gpu/drm/drm_crtc.c +1 -1
index d2a6d958ca76..4d61ceae789c 100644
@@ -5215,7 +5215,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
 		goto out;
 	}
 
-	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size);
+	ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 
 out:
 	drm_modeset_unlock_all(dev);
drivers/gpu/drm/drm_fb_helper.c +1 -3
index 7590df5e2e72..4accf6039058 100644
@@ -227,7 +227,7 @@ 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, 0, crtc->gamma_size);
+	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 }
 
 /**
@@ -1076,8 +1076,6 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
 	WARN_ON(fb->bits_per_pixel != 8);
 
 	fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
-	return 0;
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.c +5 -4
index c95406e6f44d..5b636bf0b467 100644
@@ -175,20 +175,21 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
 	}
 }
 
-void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
-			u32 start, u32 size)
+int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
+		       u32 size)
 {
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
 	int i;
-	int end = (start + size > 256) ? 256 : start + size;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		gma_crtc->lut_r[i] = red[i] >> 8;
 		gma_crtc->lut_g[i] = green[i] >> 8;
 		gma_crtc->lut_b[i] = blue[i] >> 8;
 	}
 
 	gma_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.h +2 -2
index b2491c65f053..e72dd08b701b 100644
@@ -72,8 +72,8 @@ extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
 			       uint32_t width, uint32_t height);
 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_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-			       u16 *blue, u32 start, u32 size);
+extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, u32 size);
 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);
drivers/gpu/drm/mgag200/mgag200_mode.c +5 -4
index 14e64e08909e..f6d5892d03f1 100644
@@ -1344,19 +1344,20 @@ static void mga_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, uint32_t size)
 {
 	struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-	int end = (start + size > MGAG200_LUT_SIZE) ? MGAG200_LUT_SIZE : start + size;
 	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		mga_crtc->lut_r[i] = red[i] >> 8;
 		mga_crtc->lut_g[i] = green[i] >> 8;
 		mga_crtc->lut_b[i] = blue[i] >> 8;
 	}
 	mga_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/nouveau/dispnv04/crtc.c +7 -5
index 6f318c54da33..0cb7a18cde26 100644
@@ -785,14 +785,14 @@ nv_crtc_disable(struct drm_crtc *crtc)
 	nouveau_bo_ref(NULL, &disp->image[nv_crtc->index]);
 }
 
-static void
-nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
+static int
+nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
 		  uint32_t size)
 {
-	int end = (start + size > 256) ? 256 : start + size, i;
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
+	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
@@ -805,10 +805,12 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
 	 */
 	if (!nv_crtc->base.primary->fb) {
 		nv_crtc->lut.depth = 0;
-		return;
+		return 0;
 	}
 
 	nv_crtc_gamma_load(crtc);
+
+	return 0;
 }
 
 static int
drivers/gpu/drm/nouveau/nv50_display.c +5 -4
index 3ffc2b0057bf..7a7788212df7 100644
@@ -1346,21 +1346,22 @@ nv50_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 	return 0;
 }
 
-static void
+static int
 nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		    uint32_t start, uint32_t size)
+		    uint32_t size)
 {
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-	u32 end = min_t(u32, start + size, 256);
 	u32 i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
 	}
 
 	nv50_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static void
drivers/gpu/drm/radeon/radeon_display.c +7 -4
index 6a41b4982647..80f06db1dd34 100644
@@ -231,19 +231,21 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
 	*blue = radeon_crtc->lut_b[regno] << 6;
 }
 
-static void radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				 u16 *blue, uint32_t size)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 static void radeon_crtc_destroy(struct drm_crtc *crtc)
@@ -688,6 +690,7 @@ radeon_crtc_set_config(struct drm_mode_set *set)
 	pm_runtime_put_autosuspend(dev->dev);
 	return ret;
 }
+
 static const struct drm_crtc_funcs radeon_crtc_funcs = {
 	.cursor_set2 = radeon_crtc_cursor_set2,
 	.cursor_move = radeon_crtc_cursor_move,
drivers/gpu/drm/vc4/vc4_crtc.c +5 -3
index 904d0754ad78..4e34f054da5c 100644
@@ -175,20 +175,22 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)
 		HVS_WRITE(SCALER_GAMDATA, vc4_crtc->lut_b[i]);
 }
 
-static void
+static int
 vc4_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		   uint32_t start, uint32_t size)
+		   uint32_t size)
 {
 	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 	u32 i;
 
-	for (i = start; i < start + size; i++) {
+	for (i = 0; i < size; i++) {
 		vc4_crtc->lut_r[i] = r[i] >> 8;
 		vc4_crtc->lut_g[i] = g[i] >> 8;
 		vc4_crtc->lut_b[i] = b[i] >> 8;
 	}
 
 	vc4_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static u32 vc4_get_fifo_full_level(u32 format)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +5 -3
index 55231cce73a0..8a69d4da40b5 100644
@@ -1404,9 +1404,9 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
 	return 0;
 }
 
-void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
-			   u16 *r, u16 *g, u16 *b,
-			   uint32_t start, uint32_t size)
+int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
+			  u16 *r, u16 *g, u16 *b,
+			  uint32_t size)
 {
 	struct vmw_private *dev_priv = vmw_priv(crtc->dev);
 	int i;
@@ -1418,6 +1418,8 @@ void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 1, g[i] >> 8);
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 2, b[i] >> 8);
 	}
+
+	return 0;
 }
 
 int vmw_du_connector_dpms(struct drm_connector *connector, int mode)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +2 -2
index 57203212c501..ff4803c107bc 100644
@@ -195,9 +195,9 @@ struct vmw_display_unit {
 void vmw_du_cleanup(struct vmw_display_unit *du);
 void vmw_du_crtc_save(struct drm_crtc *crtc);
 void vmw_du_crtc_restore(struct drm_crtc *crtc);
-void 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,
-			   uint32_t start, uint32_t size);
+			   uint32_t size);
 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);
include/drm/drm_atomic_helper.h +3 -3
index d473dcc91f54..11896c84c4f8 100644
@@ -147,9 +147,9 @@ void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state);
 void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
 					  struct drm_connector_state *state);
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size);
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size);
 
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
include/drm/drm_crtc.h +2 -2
index d1559cd04e3d..8622bb2f4f25 100644
@@ -478,8 +478,8 @@ struct drm_crtc_funcs {
 	 * going on, which should eventually be unified to just one set of
 	 * hooks.
 	 */
-	void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-			  uint32_t start, uint32_t size);
+	int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
+			 uint32_t size);
 
 	/**
 	 * @destroy:
Signature · 6 lines
2.5.5

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Acked-by
#3 lore raw
Quoted 15 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, June 06, 2016 12:00 PM
To: Maarten Lankhorst
Cc: [email protected]; [email protected]; Mathieu Larouche; VMware Graphics; Ben Skeggs; Deucher, Alexander; Thierry Reding; Koenig, Christian
Subject: Re: [PATCH] drm/core: Change declaration for gamma_set.

Quoted 3 lines · Maarten Lankhorst

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

Quoted 7 lines

Commit message should explain why we suddenly need to pass up the error code, too:

"This is needed for atomic drivers, where an atomic commit can fail with EAGAIN and should be restarted."

I'll add that when merging, but will wait for a bit more acks/r-b first.

Thanks. I was just about to ask why this was necessary. Patch is:

Quoted 622 lines

-Daniel

Quoted 33 lines
Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David Airlie <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Eric Anholt <[email protected]>
Cc VMware Graphics <[email protected]>
Cc Mathieu Larouche <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++++++----
 drivers/gpu/drm/ast/ast_mode.c          | 10 ++++++----
 drivers/gpu/drm/cirrus/cirrus_mode.c    |  8 +++++---
 drivers/gpu/drm/drm_atomic_helper.c     | 13 ++++++-------
 drivers/gpu/drm/drm_crtc.c              |  2 +-
 drivers/gpu/drm/drm_fb_helper.c         |  4 +---
 drivers/gpu/drm/gma500/gma_display.c    |  9 +++++----
 drivers/gpu/drm/gma500/gma_display.h    |  4 ++--
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +++++----
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++++++-----
 drivers/gpu/drm/nouveau/nv50_display.c  |  9 +++++----
 drivers/gpu/drm/radeon/radeon_display.c | 11 +++++++----
 drivers/gpu/drm/vc4/vc4_crtc.c          |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c     |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h     |  4 ++--
 include/drm/drm_atomic_helper.h         |  6 +++---
 include/drm/drm_crtc.h                  |  4 ++--
 19 files changed, 85 insertions(+), 66 deletions(-)

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c

drivers/gpu/drm/amd/amdgpu/dce_v10_0.c static void dce_v10_0_cursor_reset(struct

Quoted 4 lines

index 8227344d2ff6..16de862ea51f 100644

drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +0 -0
@@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct

drm_crtc *crtc)

drivers/gpu/drm/amd/amdgpu/dce_v10_0.c static void dce_v10_0_cursor_reset(struct · line 2670

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +0 -1
 	}
 }
 
-static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,

u16 *green,

drivers/gpu/drm/amd/amdgpu/dce_v10_0.c static void dce_v10_0_cursor_reset(struct · line 2670

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +1 -1
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

Review

Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +5 -2
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v10_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c

drivers/gpu/drm/amd/amdgpu/dce_v11_0.c static void dce_v11_0_cursor_reset(struct

Quoted 4 lines

index af26ec0bc59d..6e0ae8e2e65c 100644

drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +0 -0
@@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct

drm_crtc *crtc)

drivers/gpu/drm/amd/amdgpu/dce_v11_0.c static void dce_v11_0_cursor_reset(struct · line 2681

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +0 -1
 	}
 }
 
-static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red,

u16 *green,

drivers/gpu/drm/amd/amdgpu/dce_v11_0.c static void dce_v11_0_cursor_reset(struct · line 2681

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +1 -1
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

Review

Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +5 -2
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v11_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c

drivers/gpu/drm/amd/amdgpu/dce_v8_0.c static void dce_v8_0_cursor_reset(struct

Quoted 4 lines

index 3fb65e41a6ef..7b5fae4c74f1 100644

drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +0 -0
@@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct

drm_crtc *crtc)

drivers/gpu/drm/amd/amdgpu/dce_v8_0.c static void dce_v8_0_cursor_reset(struct · line 2577

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +0 -1
 	}
 }
 
-static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

drivers/gpu/drm/amd/amdgpu/dce_v8_0.c static void dce_v8_0_cursor_reset(struct · line 2577

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +1 -1
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

Review

Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +5 -2
+				   u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v8_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)
(quoted diff) +0 -0

b/drivers/gpu/drm/ast/ast_mode.c

drivers/gpu/drm/ast/ast_mode.c static void ast_crtc_reset(struct drm_crtc *crtc) · line 627

Quoted 8 lines

index c337922606e3..5957c3e659fe 100644

drivers/gpu/drm/ast/ast_mode.c +0 -1
@@ -624,19 +624,21 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
 
 }
 
-static void ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

drivers/gpu/drm/ast/ast_mode.c static void ast_crtc_reset(struct drm_crtc *crtc) · line 627

Quoted 2 lines
drivers/gpu/drm/ast/ast_mode.c +1 -1
-				 u16 *blue, uint32_t start, uint32_t size)
+static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

Review

Quoted 20 lines
drivers/gpu/drm/ast/ast_mode.c +5 -2
+			      u16 *blue, uint32_t size)
 {
 	struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 
(quoted diff) +0 -0

b/drivers/gpu/drm/cirrus/cirrus_mode.c

drivers/gpu/drm/cirrus/cirrus_mode.c static void cirrus_crtc_commit(struct drm_crtc

Quoted 4 lines

index 0b1a411cb89e..17c915d9a03e 100644

drivers/gpu/drm/cirrus/cirrus_mode.c +0 -0
@@ -325,18 +325,20 @@ static void cirrus_crtc_commit(struct drm_crtc

*crtc)

drivers/gpu/drm/cirrus/cirrus_mode.c static void cirrus_crtc_commit(struct drm_crtc · line 325

Quoted 1 line
drivers/gpu/drm/cirrus/cirrus_mode.c +0 -0
  * use this for 8-bit mode so can't perform smooth fades on deeper

modes,

drivers/gpu/drm/cirrus/cirrus_mode.c static void cirrus_crtc_commit(struct drm_crtc *crtc)

Quoted 3 lines
drivers/gpu/drm/cirrus/cirrus_mode.c +0 -1
  * but it's a requirement that we provide the function
  */
-static void cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

drivers/gpu/drm/cirrus/cirrus_mode.c static void cirrus_crtc_commit(struct drm_crtc · line 328

Quoted 2 lines
drivers/gpu/drm/cirrus/cirrus_mode.c +1 -1
-				  u16 *blue, uint32_t start, uint32_t size)
+static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

Review

Quoted 18 lines
drivers/gpu/drm/cirrus/cirrus_mode.c +4 -1
+				 u16 *blue, uint32_t size)
 {
 	struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
 	int i;
 
-	for (i = 0; i < CIRRUS_LUT_SIZE; 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];
 	}
 	cirrus_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_atomic_helper.c

drivers/gpu/drm/drm_atomic_helper.c

Quoted 4 lines

index 939df900dcaa..266c11018a19 100644

drivers/gpu/drm/drm_atomic_helper.c +0 -0
@@ -2933,16 +2933,15 @@

EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);

drivers/gpu/drm/drm_atomic_helper.c EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);

Quoted 8 lines
drivers/gpu/drm/drm_atomic_helper.c +0 -1
  * @red: red correction table
  * @green: green correction table
  * @blue: green correction table
- * @start:
  * @size: size of the tables
  *
  * Implements support for legacy gamma correction table for drivers
  * that support color management through the

DEGAMMA_LUT/GAMMA_LUT

drivers/gpu/drm/drm_atomic_helper.c void

Quoted 12 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -3
  * properties.
  */
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size)
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_mode_config *config = &dev->mode_config;
@@ -2954,7 +2953,7 @@ void

drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,

drivers/gpu/drm/drm_crtc.c int drm_mode_gamma_set_ioctl(struct

Quoted 31 lines
drivers/gpu/drm/drm_atomic_helper.c +3 -3
 	state = drm_atomic_state_alloc(crtc->dev);
 	if (!state)
-		return;
+		return -ENOMEM;
 
 	blob = drm_property_create_blob(dev,
 					sizeof(struct drm_color_lut) * size,
@@ -3005,7 +3004,7 @@ retry:
 
 	drm_property_unreference_blob(blob);
 
-	return;
+	return 0;
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -3013,7 +3012,7 @@ fail:
 	drm_atomic_state_free(state);
 	drm_property_unreference_blob(blob);
 
-	return;
+	return ret;
 backoff:
 	drm_atomic_state_clear(state);
 	drm_atomic_legacy_backoff(state);
drivers/gpu/drm/drm_crtc.c +0 -0
index d2a6d958ca76..4d61ceae789c 100644
@@ -5215,7 +5215,7 @@ int drm_mode_gamma_set_ioctl(struct

drm_device *dev,

Review

Quoted 11 lines
drivers/gpu/drm/drm_crtc.c +1 -1
 		goto out;
 	}
 
-	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc-
 gamma_size);
+	ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc-
 gamma_size);
 

out:

drivers/gpu/drm/drm_crtc.c +0 -0
 	drm_modeset_unlock_all(dev);
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_fb_helper.c

drivers/gpu/drm/drm_fb_helper.c static void

Quoted 4 lines

index 7590df5e2e72..4accf6039058 100644

drivers/gpu/drm/drm_fb_helper.c +0 -0
@@ -227,7 +227,7 @@ static void

drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)

drivers/gpu/drm/drm_fb_helper.c static int setcolreg(struct drm_crtc *crtc, u16 red,

Quoted 11 lines
drivers/gpu/drm/drm_fb_helper.c +1 -1
 	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, 0, crtc-
 gamma_size);
+	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc-
 gamma_size);
 }

/**

drivers/gpu/drm/drm_fb_helper.c +0 -0
@@ -1076,8 +1076,6 @@ static int setcolreg(struct drm_crtc *crtc, u16 red,

u16 green,

Review

Quoted 9 lines
drivers/gpu/drm/drm_fb_helper.c +0 -2
 	WARN_ON(fb->bits_per_pixel != 8);
 
 	fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
-	return 0;
 }
 
 /**
(quoted diff) +0 -0

b/drivers/gpu/drm/gma500/gma_display.c

drivers/gpu/drm/gma500/gma_display.c void gma_crtc_load_lut(struct drm_crtc *crtc) · line 178

Quoted 8 lines

index c95406e6f44d..5b636bf0b467 100644

drivers/gpu/drm/gma500/gma_display.c +0 -1
@@ -175,20 +175,21 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
 	}
 }
 
-void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,

u16 *blue,

drivers/gpu/drm/gma500/gma_display.c void gma_crtc_load_lut(struct drm_crtc *crtc) · line 178

Quoted 2 lines
drivers/gpu/drm/gma500/gma_display.c +1 -1
-			u32 start, u32 size)
+int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,

u16 *blue,

Review

Quoted 20 lines
drivers/gpu/drm/gma500/gma_display.c +4 -2
+		       u32 size)
 {
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
 	int i;
-	int end = (start + size > 256) ? 256 : start + size;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		gma_crtc->lut_r[i] = red[i] >> 8;
 		gma_crtc->lut_g[i] = green[i] >> 8;
 		gma_crtc->lut_b[i] = blue[i] >> 8;
 	}
 
 	gma_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /**
(quoted diff) +0 -0

b/drivers/gpu/drm/gma500/gma_display.h

drivers/gpu/drm/gma500/gma_display.h extern int gma_crtc_cursor_set(struct drm_crtc *crtc, · line 75

Quoted 8 lines

index b2491c65f053..e72dd08b701b 100644

drivers/gpu/drm/gma500/gma_display.h +0 -1
@@ -72,8 +72,8 @@ extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
 			       uint32_t width, uint32_t height);
 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_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

drivers/gpu/drm/gma500/gma_display.h extern int gma_crtc_cursor_set(struct drm_crtc *crtc, · line 75

Quoted 2 lines
drivers/gpu/drm/gma500/gma_display.h +1 -1
-			       u16 *blue, u32 start, u32 size);
+extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

Review

Quoted 5 lines
drivers/gpu/drm/gma500/gma_display.h +1 -0
+			      u16 *blue, u32 size);
 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);
(quoted diff) +0 -0

b/drivers/gpu/drm/mgag200/mgag200_mode.c

drivers/gpu/drm/mgag200/mgag200_mode.c static void mga_crtc_commit(struct drm_crtc

Quoted 4 lines

index 14e64e08909e..f6d5892d03f1 100644

drivers/gpu/drm/mgag200/mgag200_mode.c +0 -0
@@ -1344,19 +1344,20 @@ static void mga_crtc_commit(struct drm_crtc

*crtc)

drivers/gpu/drm/mgag200/mgag200_mode.c static void mga_crtc_commit(struct drm_crtc · line 1344

Quoted 1 line
drivers/gpu/drm/mgag200/mgag200_mode.c +0 -0
  * use this for 8-bit mode so can't perform smooth fades on deeper

modes,

drivers/gpu/drm/mgag200/mgag200_mode.c static void mga_crtc_commit(struct drm_crtc · line 1347

Quoted 3 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +0 -1
  * but it's a requirement that we provide the function
  */
-static void mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

drivers/gpu/drm/mgag200/mgag200_mode.c static void mga_crtc_commit(struct drm_crtc · line 1347

Quoted 2 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -1
-				  u16 *blue, uint32_t start, uint32_t size)
+static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

drivers/gpu/drm/mgag200/mgag200_mode.c static void mga_crtc_commit(struct drm_crtc *crtc)

Quoted 4 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +1 -1
+			      u16 *blue, uint32_t size)
 {
 	struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-	int end = (start + size > MGAG200_LUT_SIZE) ? MGAG200_LUT_SIZE :

start + size;

Review

Quoted 15 lines
drivers/gpu/drm/mgag200/mgag200_mode.c +3 -1
 	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		mga_crtc->lut_r[i] = red[i] >> 8;
 		mga_crtc->lut_g[i] = green[i] >> 8;
 		mga_crtc->lut_b[i] = blue[i] >> 8;
 	}
 	mga_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
(quoted diff) +0 -0

b/drivers/gpu/drm/nouveau/dispnv04/crtc.c

drivers/gpu/drm/nouveau/dispnv04/crtc.c nv_crtc_disable(struct drm_crtc *crtc) · line 789

Quoted 9 lines

index 6f318c54da33..0cb7a18cde26 100644

drivers/gpu/drm/nouveau/dispnv04/crtc.c +0 -2
@@ -785,14 +785,14 @@ nv_crtc_disable(struct drm_crtc *crtc)
 	nouveau_bo_ref(NULL, &disp->image[nv_crtc->index]);
 }
 
-static void
-nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t

start,

drivers/gpu/drm/nouveau/dispnv04/crtc.c nv_crtc_gamma_set(struct drm_crtc *crtc, u16

Quoted 14 lines
drivers/gpu/drm/nouveau/dispnv04/crtc.c +4 -2
+static int
+nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
 		  uint32_t size)
 {
-	int end = (start + size > 256) ? 256 : start + size, i;
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
+	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
@@ -805,10 +805,12 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16

*r, u16 *g, u16 *b, uint32_t start,

Review

Quoted 14 lines
drivers/gpu/drm/nouveau/dispnv04/crtc.c +3 -1
 	 */
 	if (!nv_crtc->base.primary->fb) {
 		nv_crtc->lut.depth = 0;
-		return;
+		return 0;
 	}
 
 	nv_crtc_gamma_load(crtc);
+
+	return 0;
 }
 
 static int
(quoted diff) +0 -0

b/drivers/gpu/drm/nouveau/nv50_display.c

drivers/gpu/drm/nouveau/nv50_display.c nv50_crtc_cursor_move(struct drm_crtc *crtc,

Quoted 4 lines

index 3ffc2b0057bf..7a7788212df7 100644

drivers/gpu/drm/nouveau/nv50_display.c +0 -0
@@ -1346,21 +1346,22 @@ nv50_crtc_cursor_move(struct drm_crtc *crtc,

int x, int y)

Review

Quoted 27 lines
drivers/gpu/drm/nouveau/nv50_display.c +5 -4
 	return 0;
 }
 
-static void
+static int
 nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		    uint32_t start, uint32_t size)
+		    uint32_t size)
 {
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-	u32 end = min_t(u32, start + size, 256);
 	u32 i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
 	}
 
 	nv50_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static void
(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/radeon_display.c

drivers/gpu/drm/radeon/radeon_display.c void radeon_crtc_fb_gamma_get(struct drm_crtc

Quoted 4 lines

index 6a41b4982647..80f06db1dd34 100644

drivers/gpu/drm/radeon/radeon_display.c +0 -0
@@ -231,19 +231,21 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc

*crtc, u16 *red, u16 *green,

drivers/gpu/drm/radeon/radeon_display.c void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,

Quoted 4 lines
drivers/gpu/drm/radeon/radeon_display.c +0 -1
 	*blue = radeon_crtc->lut_b[regno] << 6;
 }
 
-static void radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

drivers/gpu/drm/radeon/radeon_display.c void radeon_crtc_fb_gamma_get(struct drm_crtc · line 234

Quoted 2 lines
drivers/gpu/drm/radeon/radeon_display.c +1 -1
-				  u16 *blue, uint32_t start, uint32_t size)
+static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16

*green,

drivers/gpu/drm/radeon/radeon_display.c radeon_crtc_set_config(struct drm_mode_set

Quoted 20 lines
drivers/gpu/drm/radeon/radeon_display.c +5 -2
+				 u16 *blue, uint32_t size)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 static void radeon_crtc_destroy(struct drm_crtc *crtc)
@@ -688,6 +690,7 @@ radeon_crtc_set_config(struct drm_mode_set

*set)

Review

Quoted 8 lines
drivers/gpu/drm/radeon/radeon_display.c +1 -0
 	pm_runtime_put_autosuspend(dev->dev);
 	return ret;
 }
+
 static const struct drm_crtc_funcs radeon_crtc_funcs = {
 	.cursor_set2 = radeon_crtc_cursor_set2,
 	.cursor_move = radeon_crtc_cursor_move,
(quoted diff) +0 -0

b/drivers/gpu/drm/vc4/vc4_crtc.c

Review

Quoted 30 lines

index 904d0754ad78..4e34f054da5c 100644

drivers/gpu/drm/vc4/vc4_crtc.c +5 -3
@@ -175,20 +175,22 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)
 		HVS_WRITE(SCALER_GAMDATA, vc4_crtc->lut_b[i]);
 }
 
-static void
+static int
 vc4_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		   uint32_t start, uint32_t size)
+		   uint32_t size)
 {
 	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 	u32 i;
 
-	for (i = start; i < start + size; i++) {
+	for (i = 0; i < size; i++) {
 		vc4_crtc->lut_r[i] = r[i] >> 8;
 		vc4_crtc->lut_g[i] = g[i] >> 8;
 		vc4_crtc->lut_b[i] = b[i] >> 8;
 	}
 
 	vc4_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static u32 vc4_get_fifo_full_level(u32 format)
(quoted diff) +0 -0

b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c static int vmw_du_update_layout(struct

Quoted 4 lines

index 55231cce73a0..8a69d4da40b5 100644

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -0
@@ -1404,9 +1404,9 @@ static int vmw_du_update_layout(struct

vmw_private *dev_priv, unsigned num,

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c void vmw_du_crtc_gamma_set(struct drm_crtc

Quoted 13 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +3 -3
 	return 0;
 }
 
-void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
-			   u16 *r, u16 *g, u16 *b,
-			   uint32_t start, uint32_t size)
+int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
+			  u16 *r, u16 *g, u16 *b,
+			  uint32_t size)
 {
 	struct vmw_private *dev_priv = vmw_priv(crtc->dev);
 	int i;
@@ -1418,6 +1418,8 @@ void vmw_du_crtc_gamma_set(struct drm_crtc

*crtc,

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c void vmw_du_crtc_gamma_set(struct drm_crtc · line 1418

Quoted 1 line
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0 -0
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 1, g[i] >>

8);

Quoted 8 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2 -0
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 2, b[i]
 > 8);
 	}
+
+	return 0;
 }
 

int vmw_du_connector_dpms(struct drm_connector *connector, int

mode)

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h

drivers/gpu/drm/vmwgfx/vmwgfx_kms.h struct vmw_display_unit { · line 201

Quoted 13 lines

index 57203212c501..ff4803c107bc 100644

drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +2 -2
@@ -195,9 +195,9 @@ struct vmw_display_unit {
 void vmw_du_cleanup(struct vmw_display_unit *du);
 void vmw_du_crtc_save(struct drm_crtc *crtc);
 void vmw_du_crtc_restore(struct drm_crtc *crtc);
-void 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,
-			   uint32_t start, uint32_t size);
+			   uint32_t size);
 int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file

*file_priv,

Review

Quoted 3 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +0 -0
 			    uint32_t handle, uint32_t width, uint32_t height,
 			    int32_t hot_x, int32_t hot_y);
(quoted diff) +0 -0

b/include/drm/drm_atomic_helper.h

include/drm/drm_atomic_helper.h void · line 147

Quoted 5 lines

index d473dcc91f54..11896c84c4f8 100644

include/drm/drm_atomic_helper.h +0 -0
@@ -147,9 +147,9 @@ void
 __drm_atomic_helper_connector_destroy_state(struct

drm_connector_state *state);

include/drm/drm_atomic_helper.h void · line 148

Quoted 1 line
include/drm/drm_atomic_helper.h +0 -0
 void drm_atomic_helper_connector_destroy_state(struct drm_connector

*connector,

include/drm/drm_atomic_helper.h void

Quoted 10 lines
include/drm/drm_atomic_helper.h +3 -3
 					  struct drm_connector_state *state);
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size);
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size);
 
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently

attached to CRTC

Quoted 18 lines
include/drm/drm_crtc.h +2 -3
index d1559cd04e3d..8622bb2f4f25 100644
@@ -478,8 +478,8 @@ struct drm_crtc_funcs {
 	 * going on, which should eventually be unified to just one set of
 	 * hooks.
 	 */
-	void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-			  uint32_t start, uint32_t size);
+	int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
+			 uint32_t size);
 
 	/**
 	 * @destroy:
--

2.5.5

Quoted 9 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw
In reply to Daniel Vetter
Quoted 11 lines · Daniel Vetter
Quoted 3 lines · Maarten Lankhorst

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

Commit message should explain why we suddenly need to pass up the error code, too:

"This is needed for atomic drivers, where an atomic commit can fail with EAGAIN and should be restarted."

Since that can happen only on the DRM core side, shouldn't one refrain from adding the "always returns 0" return status for the drivers' .gamma_set hook ? Or there's is something in the works that would lead to drivers being able to return a non 0 value ?

Thanks
Emil
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author maintainer
#5 lore raw

Op 06-06-16 om 18:11 schreef Emil Velikov:

Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Maarten Lankhorst
Quoted 3 lines

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

Commit message should explain why we suddenly need to pass up the error code, too:

Quoted 7 lines
Quoted 3 lines

"This is needed for atomic drivers, where an atomic commit can fail with EAGAIN and should be restarted."

Since that can happen only on the DRM core side, shouldn't one refrain from adding the "always returns 0" return status for the drivers' .gamma_set hook ? Or there's is something in the works that would lead to drivers being able to return a non 0 value ?

Look at drm_atomic_helper.c :-)

Being implemented as an atomic update means any errno can be returned.

~Maarten
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw
Quoted 12 lines · Maarten Lankhorst

Op 06-06-16 om 18:11 schreef Emil Velikov:

Quoted 11 lines · Daniel Vetter
Quoted 10 lines · Maarten Lankhorst
Quoted 3 lines

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

Commit message should explain why we suddenly need to pass up the error code, too:

"This is needed for atomic drivers, where an atomic commit can fail with EAGAIN and should be restarted."

Quoted 8 lines
Quoted 4 lines

Since that can happen only on the DRM core side, shouldn't one refrain from adding the "always returns 0" return status for the drivers' .gamma_set hook ? Or there's is something in the works that would lead to drivers being able to return a non 0 value ?

Look at drm_atomic_helper.c :-)

Being implemented as an atomic update means any errno can be returned.

Ouch. Looks like only the i915 driver uses the helper while I was looking at other ATOMIC drivers. So things short circuited on my noggin'. I guess it's up-to the respective drivers to be updated and use the drm_atomic_helper_legacy_gamma_set helper.

Thanks for sticking with my silly question :-)
Emil
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author maintainer
#7 lore raw

Op 06-06-16 om 18:25 schreef Emil Velikov:

Quoted 20 lines
Quoted 18 lines · Maarten Lankhorst

Op 06-06-16 om 18:11 schreef Emil Velikov:

Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Maarten Lankhorst
Quoted 3 lines

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

Commit message should explain why we suddenly need to pass up the error code, too:

Quoted 7 lines
Quoted 3 lines

"This is needed for atomic drivers, where an atomic commit can fail with EAGAIN and should be restarted."

Since that can happen only on the DRM core side, shouldn't one refrain from adding the "always returns 0" return status for the drivers' .gamma_set hook ? Or there's is something in the works that would lead to drivers being able to return a non 0 value ?

Look at drm_atomic_helper.c :-)

Quoted 8 lines
Quoted 2 lines

Being implemented as an atomic update means any errno can be returned.

Ouch. Looks like only the i915 driver uses the helper while I was looking at other ATOMIC drivers. So things short circuited on my noggin'. I guess it's up-to the respective drivers to be updated and use the drm_atomic_helper_legacy_gamma_set helper.

Thanks for sticking with my silly question :-)

Feel free to convert some drivers over, would be nice to have more widespread support for changing gamma through atomic properties. :-)
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw
In reply to Maarten Lankhorst

Hi Maarten,

drivers/gpu/drm/drm_fb_helper.c static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, · line 1079

Quoted 10 lines · Maarten Lankhorst
drivers/gpu/drm/drm_fb_helper.c +0 -2
@@ -1076,8 +1076,6 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
        WARN_ON(fb->bits_per_pixel != 8);
 
        fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
-       return 0;
 }

This seems like unrelated change for which the compiler should give you a nice big warning :-)

Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#9 lore raw

Op 06-06-16 om 18:17 schreef Emil Velikov:

Quoted 17 lines

Hi Maarten,

drivers/gpu/drm/drm_fb_helper.c static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green, · line 1079

Quoted 9 lines · Maarten Lankhorst
drivers/gpu/drm/drm_fb_helper.c +0 -2
@@ -1076,8 +1076,6 @@ static int setcolreg(struct drm_crtc *crtc, u16 red, u16 green,
        WARN_ON(fb->bits_per_pixel != 8);
 
        fb_helper->funcs->gamma_set(crtc, red, green, blue, regno);
-
-       return 0;
 }

This seems like unrelated change for which the compiler should give you a nice big warning :-)

Quoted 2 lines

Thanks
Emil

Oops, was a leftover. Ignore this hunk.

I originally added a return, but fb_helper is left unchanged for now.

~Maarten

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author maintainer
#10 lore raw

PATCH v2 1/1 drm/core: Change declaration for gamma_set.

In reply to Maarten Lankhorst

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

This is needed for atomic drivers, where an atomic commit can fail with -EINTR or -ENOMEM and should be restarted.

Changes since v1:
- Fix compiler warning. (Emil)
- Fix commit message (Daniel)

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David Airlie <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Eric Anholt <[email protected]>
Cc VMware Graphics <[email protected]>
Cc Mathieu Larouche <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++++++----
 drivers/gpu/drm/ast/ast_mode.c          | 10 ++++++----
 drivers/gpu/drm/cirrus/cirrus_mode.c    |  8 +++++---
 drivers/gpu/drm/drm_atomic_helper.c     | 13 ++++++-------
 drivers/gpu/drm/drm_crtc.c              |  2 +-
 drivers/gpu/drm/drm_fb_helper.c         |  2 +-
 drivers/gpu/drm/gma500/gma_display.c    |  9 +++++----
 drivers/gpu/drm/gma500/gma_display.h    |  4 ++--
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +++++----
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++++++-----
 drivers/gpu/drm/nouveau/nv50_display.c  |  9 +++++----
 drivers/gpu/drm/radeon/radeon_display.c | 11 +++++++----
 drivers/gpu/drm/vc4/vc4_crtc.c          |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c     |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h     |  4 ++--
 include/drm/drm_atomic_helper.h         |  6 +++---
 include/drm/drm_crtc.h                  |  4 ++--
 19 files changed, 85 insertions(+), 64 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +6 -4
index 7e57447bf5f4..112e358f0f9b 100644
@@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v10_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +6 -4
index da101551960b..b522fa2435a8 100644
@@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v11_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +6 -4
index 41d9bc5f9c0e..b50ed72feedb 100644
@@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				   u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v8_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/ast/ast_mode.c +6 -4
index c337922606e3..5957c3e659fe 100644
@@ -624,19 +624,21 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
 
 }
 
-static void ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				 u16 *blue, uint32_t start, uint32_t size)
+static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, uint32_t size)
 {
 	struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 
drivers/gpu/drm/cirrus/cirrus_mode.c +5 -3
index 0b1a411cb89e..17c915d9a03e 100644
@@ -325,18 +325,20 @@ static void cirrus_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				 u16 *blue, uint32_t size)
 {
 	struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
 	int i;
 
-	for (i = 0; i < CIRRUS_LUT_SIZE; 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];
 	}
 	cirrus_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/drm_atomic_helper.c +6 -7
index 4342f3dfc0e1..191d84f12e67 100644
@@ -2920,16 +2920,15 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
  * @red: red correction table
  * @green: green correction table
  * @blue: green correction table
- * @start: first entry, must always be 0
  * @size: size of the tables
  *
  * Implements support for legacy gamma correction table for drivers
  * that support color management through the DEGAMMA_LUT/GAMMA_LUT
  * properties.
  */
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size)
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_mode_config *config = &dev->mode_config;
@@ -2941,7 +2940,7 @@ void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 
 	state = drm_atomic_state_alloc(crtc->dev);
 	if (!state)
-		return;
+		return -ENOMEM;
 
 	blob = drm_property_create_blob(dev,
 					sizeof(struct drm_color_lut) * size,
@@ -2992,7 +2991,7 @@ retry:
 
 	drm_property_unreference_blob(blob);
 
-	return;
+	return 0;
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -3000,7 +2999,7 @@ fail:
 	drm_atomic_state_free(state);
 	drm_property_unreference_blob(blob);
 
-	return;
+	return ret;
 backoff:
 	drm_atomic_state_clear(state);
 	drm_atomic_legacy_backoff(state);
drivers/gpu/drm/drm_crtc.c +1 -1
index a9cabef98f6b..da2f28ea5fad 100644
@@ -5171,7 +5171,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
 		goto out;
 	}
 
-	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size);
+	ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 
 out:
 	drm_modeset_unlock_all(dev);
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 7590df5e2e72..58ed6e6d4f12 100644
@@ -227,7 +227,7 @@ 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, 0, crtc->gamma_size);
+	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.c +5 -4
index c95406e6f44d..5b636bf0b467 100644
@@ -175,20 +175,21 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
 	}
 }
 
-void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
-			u32 start, u32 size)
+int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
+		       u32 size)
 {
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
 	int i;
-	int end = (start + size > 256) ? 256 : start + size;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		gma_crtc->lut_r[i] = red[i] >> 8;
 		gma_crtc->lut_g[i] = green[i] >> 8;
 		gma_crtc->lut_b[i] = blue[i] >> 8;
 	}
 
 	gma_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.h +2 -2
index b2491c65f053..e72dd08b701b 100644
@@ -72,8 +72,8 @@ extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
 			       uint32_t width, uint32_t height);
 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_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-			       u16 *blue, u32 start, u32 size);
+extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, u32 size);
 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);
drivers/gpu/drm/mgag200/mgag200_mode.c +5 -4
index d347dca17267..6b21cb27e1cc 100644
@@ -1352,19 +1352,20 @@ static void mga_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, uint32_t size)
 {
 	struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-	int end = (start + size > MGAG200_LUT_SIZE) ? MGAG200_LUT_SIZE : start + size;
 	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		mga_crtc->lut_r[i] = red[i] >> 8;
 		mga_crtc->lut_g[i] = green[i] >> 8;
 		mga_crtc->lut_b[i] = blue[i] >> 8;
 	}
 	mga_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/nouveau/dispnv04/crtc.c +7 -5
index 6f318c54da33..0cb7a18cde26 100644
@@ -785,14 +785,14 @@ nv_crtc_disable(struct drm_crtc *crtc)
 	nouveau_bo_ref(NULL, &disp->image[nv_crtc->index]);
 }
 
-static void
-nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
+static int
+nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
 		  uint32_t size)
 {
-	int end = (start + size > 256) ? 256 : start + size, i;
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
+	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
@@ -805,10 +805,12 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
 	 */
 	if (!nv_crtc->base.primary->fb) {
 		nv_crtc->lut.depth = 0;
-		return;
+		return 0;
 	}
 
 	nv_crtc_gamma_load(crtc);
+
+	return 0;
 }
 
 static int
drivers/gpu/drm/nouveau/nv50_display.c +5 -4
index 3ffc2b0057bf..7a7788212df7 100644
@@ -1346,21 +1346,22 @@ nv50_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 	return 0;
 }
 
-static void
+static int
 nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		    uint32_t start, uint32_t size)
+		    uint32_t size)
 {
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-	u32 end = min_t(u32, start + size, 256);
 	u32 i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
 	}
 
 	nv50_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static void
drivers/gpu/drm/radeon/radeon_display.c +7 -4
index 2fb18f13395c..e85c7a2f565b 100644
@@ -231,19 +231,21 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
 	*blue = radeon_crtc->lut_b[regno] << 6;
 }
 
-static void radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				 u16 *blue, uint32_t size)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 static void radeon_crtc_destroy(struct drm_crtc *crtc)
@@ -688,6 +690,7 @@ radeon_crtc_set_config(struct drm_mode_set *set)
 	pm_runtime_put_autosuspend(dev->dev);
 	return ret;
 }
+
 static const struct drm_crtc_funcs radeon_crtc_funcs = {
 	.cursor_set2 = radeon_crtc_cursor_set2,
 	.cursor_move = radeon_crtc_cursor_move,
drivers/gpu/drm/vc4/vc4_crtc.c +5 -3
index ba2e373ec901..4c0f26a644a3 100644
@@ -175,20 +175,22 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)
 		HVS_WRITE(SCALER_GAMDATA, vc4_crtc->lut_b[i]);
 }
 
-static void
+static int
 vc4_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		   uint32_t start, uint32_t size)
+		   uint32_t size)
 {
 	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 	u32 i;
 
-	for (i = start; i < start + size; i++) {
+	for (i = 0; i < size; i++) {
 		vc4_crtc->lut_r[i] = r[i] >> 8;
 		vc4_crtc->lut_g[i] = g[i] >> 8;
 		vc4_crtc->lut_b[i] = b[i] >> 8;
 	}
 
 	vc4_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static u32 vc4_get_fifo_full_level(u32 format)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +5 -3
index 55231cce73a0..8a69d4da40b5 100644
@@ -1404,9 +1404,9 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
 	return 0;
 }
 
-void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
-			   u16 *r, u16 *g, u16 *b,
-			   uint32_t start, uint32_t size)
+int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
+			  u16 *r, u16 *g, u16 *b,
+			  uint32_t size)
 {
 	struct vmw_private *dev_priv = vmw_priv(crtc->dev);
 	int i;
@@ -1418,6 +1418,8 @@ void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 1, g[i] >> 8);
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 2, b[i] >> 8);
 	}
+
+	return 0;
 }
 
 int vmw_du_connector_dpms(struct drm_connector *connector, int mode)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +2 -2
index 57203212c501..ff4803c107bc 100644
@@ -195,9 +195,9 @@ struct vmw_display_unit {
 void vmw_du_cleanup(struct vmw_display_unit *du);
 void vmw_du_crtc_save(struct drm_crtc *crtc);
 void vmw_du_crtc_restore(struct drm_crtc *crtc);
-void 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,
-			   uint32_t start, uint32_t size);
+			   uint32_t size);
 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);
include/drm/drm_atomic_helper.h +3 -3
index b03bd83703b4..1877a7c18d8e 100644
@@ -147,9 +147,9 @@ void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state);
 void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
 					  struct drm_connector_state *state);
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size);
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size);
 
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
include/drm/drm_crtc.h +2 -2
index f59d8a2d8920..411be4f45506 100644
@@ -479,8 +479,8 @@ struct drm_crtc_funcs {
 	 * going on, which should eventually be unified to just one set of
 	 * hooks.
 	 */
-	void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-			  uint32_t start, uint32_t size);
+	int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
+			 uint32_t size);
 
 	/**
 	 * @destroy:
Signature · 7 lines
2.5.5


_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Acked-by on v2 1/1
#11 lore raw
Quoted 554 lines · Maarten Lankhorst

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

This is needed for atomic drivers, where an atomic commit can fail with -EINTR or -ENOMEM and should be restarted.

Changes since v1:
- Fix compiler warning. (Emil)
- Fix commit message (Daniel)

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David Airlie <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Eric Anholt <[email protected]>
Cc VMware Graphics <[email protected]>
Cc Mathieu Larouche <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++++++----
 drivers/gpu/drm/ast/ast_mode.c          | 10 ++++++----
 drivers/gpu/drm/cirrus/cirrus_mode.c    |  8 +++++---
 drivers/gpu/drm/drm_atomic_helper.c     | 13 ++++++-------
 drivers/gpu/drm/drm_crtc.c              |  2 +-
 drivers/gpu/drm/drm_fb_helper.c         |  2 +-
 drivers/gpu/drm/gma500/gma_display.c    |  9 +++++----
 drivers/gpu/drm/gma500/gma_display.h    |  4 ++--
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +++++----
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++++++-----
 drivers/gpu/drm/nouveau/nv50_display.c  |  9 +++++----
 drivers/gpu/drm/radeon/radeon_display.c | 11 +++++++----
 drivers/gpu/drm/vc4/vc4_crtc.c          |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c     |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h     |  4 ++--
 include/drm/drm_atomic_helper.h         |  6 +++---
 include/drm/drm_crtc.h                  |  4 ++--
 19 files changed, 85 insertions(+), 64 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +6 -4
index 7e57447bf5f4..112e358f0f9b 100644
@@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
        }
 }
 
-static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                   u16 *blue, uint32_t start, uint32_t size)
+static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+                                   u16 *blue, uint32_t size)
 {
        struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-       int end = (start + size > 256) ? 256 : start + size, i;
+       int i;
 
        /* userspace palettes are always correct as is */
-       for (i = start; i < end; i++) {
+       for (i = 0; i < size; i++) {
                amdgpu_crtc->lut_r[i] = red[i] >> 6;
                amdgpu_crtc->lut_g[i] = green[i] >> 6;
                amdgpu_crtc->lut_b[i] = blue[i] >> 6;
        }
        dce_v10_0_crtc_load_lut(crtc);
+
+       return 0;
 }
 
 static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +6 -4
index da101551960b..b522fa2435a8 100644
@@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
        }
 }
 
-static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                   u16 *blue, uint32_t start, uint32_t size)
+static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+                                   u16 *blue, uint32_t size)
 {
        struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-       int end = (start + size > 256) ? 256 : start + size, i;
+       int i;
 
        /* userspace palettes are always correct as is */
-       for (i = start; i < end; i++) {
+       for (i = 0; i < size; i++) {
                amdgpu_crtc->lut_r[i] = red[i] >> 6;
                amdgpu_crtc->lut_g[i] = green[i] >> 6;
                amdgpu_crtc->lut_b[i] = blue[i] >> 6;
        }
        dce_v11_0_crtc_load_lut(crtc);
+
+       return 0;
 }
 
 static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +6 -4
index 41d9bc5f9c0e..b50ed72feedb 100644
@@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
        }
 }
 
-static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                   u16 *blue, uint32_t start, uint32_t size)
+static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+                                  u16 *blue, uint32_t size)
 {
        struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-       int end = (start + size > 256) ? 256 : start + size, i;
+       int i;
 
        /* userspace palettes are always correct as is */
-       for (i = start; i < end; i++) {
+       for (i = 0; i < size; i++) {
                amdgpu_crtc->lut_r[i] = red[i] >> 6;
                amdgpu_crtc->lut_g[i] = green[i] >> 6;
                amdgpu_crtc->lut_b[i] = blue[i] >> 6;
        }
        dce_v8_0_crtc_load_lut(crtc);
+
+       return 0;
 }
 
 static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/ast/ast_mode.c +6 -4
index c337922606e3..5957c3e659fe 100644
@@ -624,19 +624,21 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
 
 }
 
-static void ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                u16 *blue, uint32_t start, uint32_t size)
+static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+                             u16 *blue, uint32_t size)
 {
        struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-       int end = (start + size > 256) ? 256 : start + size, i;
+       int i;
 
        /* userspace palettes are always correct as is */
-       for (i = start; i < end; i++) {
+       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;
 }
 
 
drivers/gpu/drm/cirrus/cirrus_mode.c +5 -3
index 0b1a411cb89e..17c915d9a03e 100644
@@ -325,18 +325,20 @@ static void cirrus_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                 u16 *blue, uint32_t start, uint32_t size)
+static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+                                u16 *blue, uint32_t size)
 {
        struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
        int i;
 
-       for (i = 0; i < CIRRUS_LUT_SIZE; 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];
        }
        cirrus_crtc_load_lut(crtc);
+
+       return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/drm_atomic_helper.c +6 -7
index 4342f3dfc0e1..191d84f12e67 100644
@@ -2920,16 +2920,15 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
  * @red: red correction table
  * @green: green correction table
  * @blue: green correction table
- * @start: first entry, must always be 0
  * @size: size of the tables
  *
  * Implements support for legacy gamma correction table for drivers
  * that support color management through the DEGAMMA_LUT/GAMMA_LUT
  * properties.
  */
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-                                       u16 *red, u16 *green, u16 *blue,
-                                       uint32_t start, uint32_t size)
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+                                      u16 *red, u16 *green, u16 *blue,
+                                      uint32_t size)
 {
        struct drm_device *dev = crtc->dev;
        struct drm_mode_config *config = &dev->mode_config;
@@ -2941,7 +2940,7 @@ void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 
        state = drm_atomic_state_alloc(crtc->dev);
        if (!state)
-               return;
+               return -ENOMEM;
 
        blob = drm_property_create_blob(dev,
                                        sizeof(struct drm_color_lut) * size,
@@ -2992,7 +2991,7 @@ retry:
 
        drm_property_unreference_blob(blob);
 
-       return;
+       return 0;
 fail:
        if (ret == -EDEADLK)
                goto backoff;
@@ -3000,7 +2999,7 @@ fail:
        drm_atomic_state_free(state);
        drm_property_unreference_blob(blob);
 
-       return;
+       return ret;
 backoff:
        drm_atomic_state_clear(state);
        drm_atomic_legacy_backoff(state);
drivers/gpu/drm/drm_crtc.c +1 -1
index a9cabef98f6b..da2f28ea5fad 100644
@@ -5171,7 +5171,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
                goto out;
        }
 
-       crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size);
+       ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 
 out:
        drm_modeset_unlock_all(dev);
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 7590df5e2e72..58ed6e6d4f12 100644
@@ -227,7 +227,7 @@ 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, 0, crtc->gamma_size);
+       crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.c +5 -4
index c95406e6f44d..5b636bf0b467 100644
@@ -175,20 +175,21 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
        }
 }
 
-void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
-                       u32 start, u32 size)
+int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
+                      u32 size)
 {
        struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
        int i;
-       int end = (start + size > 256) ? 256 : start + size;
 
-       for (i = start; i < end; i++) {
+       for (i = 0; i < size; i++) {
                gma_crtc->lut_r[i] = red[i] >> 8;
                gma_crtc->lut_g[i] = green[i] >> 8;
                gma_crtc->lut_b[i] = blue[i] >> 8;
        }
 
        gma_crtc_load_lut(crtc);
+
+       return 0;
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.h +2 -2
index b2491c65f053..e72dd08b701b 100644
@@ -72,8 +72,8 @@ extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
                               uint32_t width, uint32_t height);
 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_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                              u16 *blue, u32 start, u32 size);
+extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+                             u16 *blue, u32 size);
 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);
drivers/gpu/drm/mgag200/mgag200_mode.c +5 -4
index d347dca17267..6b21cb27e1cc 100644
@@ -1352,19 +1352,20 @@ static void mga_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                 u16 *blue, uint32_t start, uint32_t size)
+static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+                             u16 *blue, uint32_t size)
 {
        struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-       int end = (start + size > MGAG200_LUT_SIZE) ? MGAG200_LUT_SIZE : start + size;
        int i;
 
-       for (i = start; i < end; i++) {
+       for (i = 0; i < size; i++) {
                mga_crtc->lut_r[i] = red[i] >> 8;
                mga_crtc->lut_g[i] = green[i] >> 8;
                mga_crtc->lut_b[i] = blue[i] >> 8;
        }
        mga_crtc_load_lut(crtc);
+
+       return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/nouveau/dispnv04/crtc.c +7 -5
index 6f318c54da33..0cb7a18cde26 100644
@@ -785,14 +785,14 @@ nv_crtc_disable(struct drm_crtc *crtc)
        nouveau_bo_ref(NULL, &disp->image[nv_crtc->index]);
 }
 
-static void
-nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
+static int
+nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
                  uint32_t size)
 {
-       int end = (start + size > 256) ? 256 : start + size, i;
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
+       int i;
 
-       for (i = start; i < end; i++) {
+       for (i = 0; i < size; i++) {
                nv_crtc->lut.r[i] = r[i];
                nv_crtc->lut.g[i] = g[i];
                nv_crtc->lut.b[i] = b[i];
@@ -805,10 +805,12 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
         */
        if (!nv_crtc->base.primary->fb) {
                nv_crtc->lut.depth = 0;
-               return;
+               return 0;
        }
 
        nv_crtc_gamma_load(crtc);
+
+       return 0;
 }
 
 static int
drivers/gpu/drm/nouveau/nv50_display.c +5 -4
index 3ffc2b0057bf..7a7788212df7 100644
@@ -1346,21 +1346,22 @@ nv50_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
        return 0;
 }
 
-static void
+static int
 nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-                   uint32_t start, uint32_t size)
+                   uint32_t size)
 {
        struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-       u32 end = min_t(u32, start + size, 256);
        u32 i;
 
-       for (i = start; i < end; i++) {
+       for (i = 0; i < size; i++) {
                nv_crtc->lut.r[i] = r[i];
                nv_crtc->lut.g[i] = g[i];
                nv_crtc->lut.b[i] = b[i];
        }
 
        nv50_crtc_lut_load(crtc);
+
+       return 0;
 }
 
 static void
drivers/gpu/drm/radeon/radeon_display.c +7 -4
index 2fb18f13395c..e85c7a2f565b 100644
@@ -231,19 +231,21 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
        *blue = radeon_crtc->lut_b[regno] << 6;
 }
 
-static void radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-                                 u16 *blue, uint32_t start, uint32_t size)
+static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+                                u16 *blue, uint32_t size)
 {
        struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-       int end = (start + size > 256) ? 256 : start + size, i;
+       int i;
 
        /* userspace palettes are always correct as is */
-       for (i = start; i < end; i++) {
+       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;
 }
 
 static void radeon_crtc_destroy(struct drm_crtc *crtc)
@@ -688,6 +690,7 @@ radeon_crtc_set_config(struct drm_mode_set *set)
        pm_runtime_put_autosuspend(dev->dev);
        return ret;
 }
+
 static const struct drm_crtc_funcs radeon_crtc_funcs = {
        .cursor_set2 = radeon_crtc_cursor_set2,
        .cursor_move = radeon_crtc_cursor_move,
drivers/gpu/drm/vc4/vc4_crtc.c +5 -3
index ba2e373ec901..4c0f26a644a3 100644
@@ -175,20 +175,22 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)
                HVS_WRITE(SCALER_GAMDATA, vc4_crtc->lut_b[i]);
 }
 
-static void
+static int
 vc4_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-                  uint32_t start, uint32_t size)
+                  uint32_t size)
 {
        struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
        u32 i;
 
-       for (i = start; i < start + size; i++) {
+       for (i = 0; i < size; i++) {
                vc4_crtc->lut_r[i] = r[i] >> 8;
                vc4_crtc->lut_g[i] = g[i] >> 8;
                vc4_crtc->lut_b[i] = b[i] >> 8;
        }
 
        vc4_crtc_lut_load(crtc);
+
+       return 0;
 }
 
 static u32 vc4_get_fifo_full_level(u32 format)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +5 -3
index 55231cce73a0..8a69d4da40b5 100644
@@ -1404,9 +1404,9 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
        return 0;
 }
 
-void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
-                          u16 *r, u16 *g, u16 *b,
-                          uint32_t start, uint32_t size)
+int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
+                         u16 *r, u16 *g, u16 *b,
+                         uint32_t size)
 {
        struct vmw_private *dev_priv = vmw_priv(crtc->dev);
        int i;
@@ -1418,6 +1418,8 @@ void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
                vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 1, g[i] >> 8);
                vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 2, b[i] >> 8);
        }
+
+       return 0;
 }
 
 int vmw_du_connector_dpms(struct drm_connector *connector, int mode)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +2 -2
index 57203212c501..ff4803c107bc 100644
@@ -195,9 +195,9 @@ struct vmw_display_unit {
 void vmw_du_cleanup(struct vmw_display_unit *du);
 void vmw_du_crtc_save(struct drm_crtc *crtc);
 void vmw_du_crtc_restore(struct drm_crtc *crtc);
-void 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,
-                          uint32_t start, uint32_t size);
+                          uint32_t size);
 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);
include/drm/drm_atomic_helper.h +3 -3
index b03bd83703b4..1877a7c18d8e 100644
@@ -147,9 +147,9 @@ void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state);
 void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
                                          struct drm_connector_state *state);
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-                                       u16 *red, u16 *green, u16 *blue,
-                                       uint32_t start, uint32_t size);
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+                                      u16 *red, u16 *green, u16 *blue,
+                                      uint32_t size);
 
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
include/drm/drm_crtc.h +2 -3
index f59d8a2d8920..411be4f45506 100644
@@ -479,8 +479,8 @@ struct drm_crtc_funcs {
         * going on, which should eventually be unified to just one set of
         * hooks.
         */
-       void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-                         uint32_t start, uint32_t size);
+       int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
+                        uint32_t size);
 
        /**
         * @destroy:
--
Quoted 3 lines

2.5.5

Looks good

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Acked-by on v2 1/1
#12 lore raw
In reply to Maarten Lankhorst
Quoted 561 lines · Maarten Lankhorst

Change return value to int to propagate errors from gamma_set, and remove start parameter. Updates always use the full size, and some drivers even ignore the start parameter altogether.

This is needed for atomic drivers, where an atomic commit can fail with -EINTR or -ENOMEM and should be restarted.

Changes since v1:
- Fix compiler warning. (Emil)
- Fix commit message (Daniel)

Cc Alex Deucher <[email protected]>
Cc Christian König <[email protected]>
Cc David Airlie <[email protected]>
Cc Patrik Jakobsson <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Eric Anholt <[email protected]>
Cc VMware Graphics <[email protected]>
Cc Mathieu Larouche <[email protected]>
Cc Thierry Reding <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++++++----
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++++++----
 drivers/gpu/drm/ast/ast_mode.c          | 10 ++++++----
 drivers/gpu/drm/cirrus/cirrus_mode.c    |  8 +++++---
 drivers/gpu/drm/drm_atomic_helper.c     | 13 ++++++-------
 drivers/gpu/drm/drm_crtc.c              |  2 +-
 drivers/gpu/drm/drm_fb_helper.c         |  2 +-
 drivers/gpu/drm/gma500/gma_display.c    |  9 +++++----
 drivers/gpu/drm/gma500/gma_display.h    |  4 ++--
 drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +++++----
 drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++++++-----
 drivers/gpu/drm/nouveau/nv50_display.c  |  9 +++++----
 drivers/gpu/drm/radeon/radeon_display.c | 11 +++++++----
 drivers/gpu/drm/vc4/vc4_crtc.c          |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c     |  8 +++++---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h     |  4 ++--
 include/drm/drm_atomic_helper.h         |  6 +++---
 include/drm/drm_crtc.h                  |  4 ++--
 19 files changed, 85 insertions(+), 64 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +6 -4
index 7e57447bf5f4..112e358f0f9b 100644
@@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v10_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +6 -4
index da101551960b..b522fa2435a8 100644
@@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v11_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +6 -4
index 41d9bc5f9c0e..b50ed72feedb 100644
@@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
 	}
 }
 
-static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				    u16 *blue, uint32_t start, uint32_t size)
+static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				   u16 *blue, uint32_t size)
 {
 	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		amdgpu_crtc->lut_r[i] = red[i] >> 6;
 		amdgpu_crtc->lut_g[i] = green[i] >> 6;
 		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
 	}
 	dce_v8_0_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)
drivers/gpu/drm/ast/ast_mode.c +6 -4
index c337922606e3..5957c3e659fe 100644
@@ -624,19 +624,21 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
 
 }
 
-static void ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				 u16 *blue, uint32_t start, uint32_t size)
+static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, uint32_t size)
 {
 	struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 
drivers/gpu/drm/cirrus/cirrus_mode.c +5 -3
index 0b1a411cb89e..17c915d9a03e 100644
@@ -325,18 +325,20 @@ static void cirrus_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				 u16 *blue, uint32_t size)
 {
 	struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
 	int i;
 
-	for (i = 0; i < CIRRUS_LUT_SIZE; 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];
 	}
 	cirrus_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/drm_atomic_helper.c +6 -7
index 4342f3dfc0e1..191d84f12e67 100644
@@ -2920,16 +2920,15 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
  * @red: red correction table
  * @green: green correction table
  * @blue: green correction table
- * @start: first entry, must always be 0
  * @size: size of the tables
  *
  * Implements support for legacy gamma correction table for drivers
  * that support color management through the DEGAMMA_LUT/GAMMA_LUT
  * properties.
  */
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size)
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size)
 {
 	struct drm_device *dev = crtc->dev;
 	struct drm_mode_config *config = &dev->mode_config;
@@ -2941,7 +2940,7 @@ void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
 
 	state = drm_atomic_state_alloc(crtc->dev);
 	if (!state)
-		return;
+		return -ENOMEM;
 
 	blob = drm_property_create_blob(dev,
 					sizeof(struct drm_color_lut) * size,
@@ -2992,7 +2991,7 @@ retry:
 
 	drm_property_unreference_blob(blob);
 
-	return;
+	return 0;
 fail:
 	if (ret == -EDEADLK)
 		goto backoff;
@@ -3000,7 +2999,7 @@ fail:
 	drm_atomic_state_free(state);
 	drm_property_unreference_blob(blob);
 
-	return;
+	return ret;
 backoff:
 	drm_atomic_state_clear(state);
 	drm_atomic_legacy_backoff(state);
drivers/gpu/drm/drm_crtc.c +1 -1
index a9cabef98f6b..da2f28ea5fad 100644
@@ -5171,7 +5171,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
 		goto out;
 	}
 
-	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size);
+	ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 
 out:
 	drm_modeset_unlock_all(dev);
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 7590df5e2e72..58ed6e6d4f12 100644
@@ -227,7 +227,7 @@ 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, 0, crtc->gamma_size);
+	crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.c +5 -4
index c95406e6f44d..5b636bf0b467 100644
@@ -175,20 +175,21 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
 	}
 }
 
-void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
-			u32 start, u32 size)
+int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
+		       u32 size)
 {
 	struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
 	int i;
-	int end = (start + size > 256) ? 256 : start + size;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		gma_crtc->lut_r[i] = red[i] >> 8;
 		gma_crtc->lut_g[i] = green[i] >> 8;
 		gma_crtc->lut_b[i] = blue[i] >> 8;
 	}
 
 	gma_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /**
drivers/gpu/drm/gma500/gma_display.h +2 -2
index b2491c65f053..e72dd08b701b 100644
@@ -72,8 +72,8 @@ extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
 			       uint32_t width, uint32_t height);
 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_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-			       u16 *blue, u32 start, u32 size);
+extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, u32 size);
 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);
drivers/gpu/drm/mgag200/mgag200_mode.c +5 -4
index d347dca17267..6b21cb27e1cc 100644
@@ -1352,19 +1352,20 @@ static void mga_crtc_commit(struct drm_crtc *crtc)
  * use this for 8-bit mode so can't perform smooth fades on deeper modes,
  * but it's a requirement that we provide the function
  */
-static void mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+			      u16 *blue, uint32_t size)
 {
 	struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
-	int end = (start + size > MGAG200_LUT_SIZE) ? MGAG200_LUT_SIZE : start + size;
 	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		mga_crtc->lut_r[i] = red[i] >> 8;
 		mga_crtc->lut_g[i] = green[i] >> 8;
 		mga_crtc->lut_b[i] = blue[i] >> 8;
 	}
 	mga_crtc_load_lut(crtc);
+
+	return 0;
 }
 
 /* Simple cleanup function */
drivers/gpu/drm/nouveau/dispnv04/crtc.c +7 -5
index 6f318c54da33..0cb7a18cde26 100644
@@ -785,14 +785,14 @@ nv_crtc_disable(struct drm_crtc *crtc)
 	nouveau_bo_ref(NULL, &disp->image[nv_crtc->index]);
 }
 
-static void
-nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
+static int
+nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
 		  uint32_t size)
 {
-	int end = (start + size > 256) ? 256 : start + size, i;
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
+	int i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
@@ -805,10 +805,12 @@ nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
 	 */
 	if (!nv_crtc->base.primary->fb) {
 		nv_crtc->lut.depth = 0;
-		return;
+		return 0;
 	}
 
 	nv_crtc_gamma_load(crtc);
+
+	return 0;
 }
 
 static int
drivers/gpu/drm/nouveau/nv50_display.c +5 -4
index 3ffc2b0057bf..7a7788212df7 100644
@@ -1346,21 +1346,22 @@ nv50_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
 	return 0;
 }
 
-static void
+static int
 nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		    uint32_t start, uint32_t size)
+		    uint32_t size)
 {
 	struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
-	u32 end = min_t(u32, start + size, 256);
 	u32 i;
 
-	for (i = start; i < end; i++) {
+	for (i = 0; i < size; i++) {
 		nv_crtc->lut.r[i] = r[i];
 		nv_crtc->lut.g[i] = g[i];
 		nv_crtc->lut.b[i] = b[i];
 	}
 
 	nv50_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static void
drivers/gpu/drm/radeon/radeon_display.c +7 -4
index 2fb18f13395c..e85c7a2f565b 100644
@@ -231,19 +231,21 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
 	*blue = radeon_crtc->lut_b[regno] << 6;
 }
 
-static void radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
-				  u16 *blue, uint32_t start, uint32_t size)
+static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				 u16 *blue, uint32_t size)
 {
 	struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
-	int end = (start + size > 256) ? 256 : start + size, i;
+	int i;
 
 	/* userspace palettes are always correct as is */
-	for (i = start; i < end; i++) {
+	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;
 }
 
 static void radeon_crtc_destroy(struct drm_crtc *crtc)
@@ -688,6 +690,7 @@ radeon_crtc_set_config(struct drm_mode_set *set)
 	pm_runtime_put_autosuspend(dev->dev);
 	return ret;
 }
+
 static const struct drm_crtc_funcs radeon_crtc_funcs = {
 	.cursor_set2 = radeon_crtc_cursor_set2,
 	.cursor_move = radeon_crtc_cursor_move,
drivers/gpu/drm/vc4/vc4_crtc.c +5 -3
index ba2e373ec901..4c0f26a644a3 100644
@@ -175,20 +175,22 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)
 		HVS_WRITE(SCALER_GAMDATA, vc4_crtc->lut_b[i]);
 }
 
-static void
+static int
 vc4_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-		   uint32_t start, uint32_t size)
+		   uint32_t size)
 {
 	struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
 	u32 i;
 
-	for (i = start; i < start + size; i++) {
+	for (i = 0; i < size; i++) {
 		vc4_crtc->lut_r[i] = r[i] >> 8;
 		vc4_crtc->lut_g[i] = g[i] >> 8;
 		vc4_crtc->lut_b[i] = b[i] >> 8;
 	}
 
 	vc4_crtc_lut_load(crtc);
+
+	return 0;
 }
 
 static u32 vc4_get_fifo_full_level(u32 format)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +5 -3
index 55231cce73a0..8a69d4da40b5 100644
@@ -1404,9 +1404,9 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
 	return 0;
 }
 
-void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
-			   u16 *r, u16 *g, u16 *b,
-			   uint32_t start, uint32_t size)
+int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
+			  u16 *r, u16 *g, u16 *b,
+			  uint32_t size)
 {
 	struct vmw_private *dev_priv = vmw_priv(crtc->dev);
 	int i;
@@ -1418,6 +1418,8 @@ void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 1, g[i] >> 8);
 		vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 2, b[i] >> 8);
 	}
+
+	return 0;
 }
 
 int vmw_du_connector_dpms(struct drm_connector *connector, int mode)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +2 -2
index 57203212c501..ff4803c107bc 100644
@@ -195,9 +195,9 @@ struct vmw_display_unit {
 void vmw_du_cleanup(struct vmw_display_unit *du);
 void vmw_du_crtc_save(struct drm_crtc *crtc);
 void vmw_du_crtc_restore(struct drm_crtc *crtc);
-void 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,
-			   uint32_t start, uint32_t size);
+			   uint32_t size);
 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);
include/drm/drm_atomic_helper.h +3 -3
index b03bd83703b4..1877a7c18d8e 100644
@@ -147,9 +147,9 @@ void
 __drm_atomic_helper_connector_destroy_state(struct drm_connector_state *state);
 void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
 					  struct drm_connector_state *state);
-void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
-					u16 *red, u16 *green, u16 *blue,
-					uint32_t start, uint32_t size);
+int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
+				       u16 *red, u16 *green, u16 *blue,
+				       uint32_t size);
 
 /**
  * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC
include/drm/drm_crtc.h +2 -2
index f59d8a2d8920..411be4f45506 100644
@@ -479,8 +479,8 @@ struct drm_crtc_funcs {
 	 * going on, which should eventually be unified to just one set of
 	 * hooks.
 	 */
-	void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
-			  uint32_t start, uint32_t size);
+	int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
+			 uint32_t size);
 
 	/**
 	 * @destroy:
Signature · 7 lines
2.5.5


_______________________________________________
dri-devel mailing list
[email protected]
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_dri-2Ddevel&d=CwIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=w9Iu3o4zAy-3-s8MFvrNSQ&m=E2k0-heZyZyuh_E9CTOgohlm--0zW99fa2nCRrQxtmk&s=stuQ-I3negOfmIrMLBGVh9CgXZGNhU5TBxcfgrlSvUY&e= 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel