Skip to content

Commit 7ea7728

Browse files
mlankhorstdanvet
authored andcommitted
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. This is needed for atomic drivers, where an atomic commit can fail with -EINTR or -ENOMEM and should be restarted. This is already and issue for drm_atomic_helper_legacy_set_gamma, which this patch fixes up. Changes since v1: - Fix compiler warning. (Emil) - Fix commit message (Daniel) Cc: Alex Deucher <alexander.deucher@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Cc: Christian König <christian.koenig@amd.com> Cc: David Airlie <airlied@linux.ie> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Cc: Ben Skeggs <bskeggs@redhat.com> Cc: Eric Anholt <eric@anholt.net> Cc: VMware Graphics <linux-graphics-maintainer@vmware.com> Cc: Mathieu Larouche <mathieu.larouche@matrox.com> Cc: Thierry Reding <treding@nvidia.com> Acked-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> [danvet: Improve commit message a bit more, mention that this fixes the helper.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/742944bc-9f41-1acb-df4f-0fd4c8a10168@linux.intel.com
1 parent ddac4b5 commit 7ea7728

File tree

19 files changed

+85
-64
lines changed

19 files changed

+85
-64
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc *crtc)
26672667
}
26682668
}
26692669

2670-
static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
2671-
u16 *blue, uint32_t start, uint32_t size)
2670+
static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
2671+
u16 *blue, uint32_t size)
26722672
{
26732673
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2674-
int end = (start + size > 256) ? 256 : start + size, i;
2674+
int i;
26752675

26762676
/* userspace palettes are always correct as is */
2677-
for (i = start; i < end; i++) {
2677+
for (i = 0; i < size; i++) {
26782678
amdgpu_crtc->lut_r[i] = red[i] >> 6;
26792679
amdgpu_crtc->lut_g[i] = green[i] >> 6;
26802680
amdgpu_crtc->lut_b[i] = blue[i] >> 6;
26812681
}
26822682
dce_v10_0_crtc_load_lut(crtc);
2683+
2684+
return 0;
26832685
}
26842686

26852687
static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc *crtc)
26782678
}
26792679
}
26802680

2681-
static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
2682-
u16 *blue, uint32_t start, uint32_t size)
2681+
static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
2682+
u16 *blue, uint32_t size)
26832683
{
26842684
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2685-
int end = (start + size > 256) ? 256 : start + size, i;
2685+
int i;
26862686

26872687
/* userspace palettes are always correct as is */
2688-
for (i = start; i < end; i++) {
2688+
for (i = 0; i < size; i++) {
26892689
amdgpu_crtc->lut_r[i] = red[i] >> 6;
26902690
amdgpu_crtc->lut_g[i] = green[i] >> 6;
26912691
amdgpu_crtc->lut_b[i] = blue[i] >> 6;
26922692
}
26932693
dce_v11_0_crtc_load_lut(crtc);
2694+
2695+
return 0;
26942696
}
26952697

26962698
static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2574,19 +2574,21 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
25742574
}
25752575
}
25762576

2577-
static void dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
2578-
u16 *blue, uint32_t start, uint32_t size)
2577+
static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
2578+
u16 *blue, uint32_t size)
25792579
{
25802580
struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
2581-
int end = (start + size > 256) ? 256 : start + size, i;
2581+
int i;
25822582

25832583
/* userspace palettes are always correct as is */
2584-
for (i = start; i < end; i++) {
2584+
for (i = 0; i < size; i++) {
25852585
amdgpu_crtc->lut_r[i] = red[i] >> 6;
25862586
amdgpu_crtc->lut_g[i] = green[i] >> 6;
25872587
amdgpu_crtc->lut_b[i] = blue[i] >> 6;
25882588
}
25892589
dce_v8_0_crtc_load_lut(crtc);
2590+
2591+
return 0;
25902592
}
25912593

25922594
static void dce_v8_0_crtc_destroy(struct drm_crtc *crtc)

drivers/gpu/drm/ast/ast_mode.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -624,19 +624,21 @@ static void ast_crtc_reset(struct drm_crtc *crtc)
624624

625625
}
626626

627-
static void ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
628-
u16 *blue, uint32_t start, uint32_t size)
627+
static int ast_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
628+
u16 *blue, uint32_t size)
629629
{
630630
struct ast_crtc *ast_crtc = to_ast_crtc(crtc);
631-
int end = (start + size > 256) ? 256 : start + size, i;
631+
int i;
632632

633633
/* userspace palettes are always correct as is */
634-
for (i = start; i < end; i++) {
634+
for (i = 0; i < size; i++) {
635635
ast_crtc->lut_r[i] = red[i] >> 8;
636636
ast_crtc->lut_g[i] = green[i] >> 8;
637637
ast_crtc->lut_b[i] = blue[i] >> 8;
638638
}
639639
ast_crtc_load_lut(crtc);
640+
641+
return 0;
640642
}
641643

642644

drivers/gpu/drm/cirrus/cirrus_mode.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,18 +325,20 @@ static void cirrus_crtc_commit(struct drm_crtc *crtc)
325325
* use this for 8-bit mode so can't perform smooth fades on deeper modes,
326326
* but it's a requirement that we provide the function
327327
*/
328-
static void cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
329-
u16 *blue, uint32_t start, uint32_t size)
328+
static int cirrus_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
329+
u16 *blue, uint32_t size)
330330
{
331331
struct cirrus_crtc *cirrus_crtc = to_cirrus_crtc(crtc);
332332
int i;
333333

334-
for (i = 0; i < CIRRUS_LUT_SIZE; i++) {
334+
for (i = 0; i < size; i++) {
335335
cirrus_crtc->lut_r[i] = red[i];
336336
cirrus_crtc->lut_g[i] = green[i];
337337
cirrus_crtc->lut_b[i] = blue[i];
338338
}
339339
cirrus_crtc_load_lut(crtc);
340+
341+
return 0;
340342
}
341343

342344
/* Simple cleanup function */

drivers/gpu/drm/drm_atomic_helper.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,16 +2920,15 @@ EXPORT_SYMBOL(drm_atomic_helper_connector_destroy_state);
29202920
* @red: red correction table
29212921
* @green: green correction table
29222922
* @blue: green correction table
2923-
* @start: first entry, must always be 0
29242923
* @size: size of the tables
29252924
*
29262925
* Implements support for legacy gamma correction table for drivers
29272926
* that support color management through the DEGAMMA_LUT/GAMMA_LUT
29282927
* properties.
29292928
*/
2930-
void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
2931-
u16 *red, u16 *green, u16 *blue,
2932-
uint32_t start, uint32_t size)
2929+
int drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
2930+
u16 *red, u16 *green, u16 *blue,
2931+
uint32_t size)
29332932
{
29342933
struct drm_device *dev = crtc->dev;
29352934
struct drm_mode_config *config = &dev->mode_config;
@@ -2941,7 +2940,7 @@ void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
29412940

29422941
state = drm_atomic_state_alloc(crtc->dev);
29432942
if (!state)
2944-
return;
2943+
return -ENOMEM;
29452944

29462945
blob = drm_property_create_blob(dev,
29472946
sizeof(struct drm_color_lut) * size,
@@ -2992,15 +2991,15 @@ void drm_atomic_helper_legacy_gamma_set(struct drm_crtc *crtc,
29922991

29932992
drm_property_unreference_blob(blob);
29942993

2995-
return;
2994+
return 0;
29962995
fail:
29972996
if (ret == -EDEADLK)
29982997
goto backoff;
29992998

30002999
drm_atomic_state_free(state);
30013000
drm_property_unreference_blob(blob);
30023001

3003-
return;
3002+
return ret;
30043003
backoff:
30053004
drm_atomic_state_clear(state);
30063005
drm_atomic_legacy_backoff(state);

drivers/gpu/drm/drm_crtc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5172,7 +5172,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
51725172
goto out;
51735173
}
51745174

5175-
crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size);
5175+
ret = crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
51765176

51775177
out:
51785178
drm_modeset_unlock_all(dev);

drivers/gpu/drm/drm_fb_helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static void drm_fb_helper_restore_lut_atomic(struct drm_crtc *crtc)
227227
g_base = r_base + crtc->gamma_size;
228228
b_base = g_base + crtc->gamma_size;
229229

230-
crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, 0, crtc->gamma_size);
230+
crtc->funcs->gamma_set(crtc, r_base, g_base, b_base, crtc->gamma_size);
231231
}
232232

233233
/**

drivers/gpu/drm/gma500/gma_display.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,21 @@ void gma_crtc_load_lut(struct drm_crtc *crtc)
175175
}
176176
}
177177

178-
void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
179-
u32 start, u32 size)
178+
int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, u16 *blue,
179+
u32 size)
180180
{
181181
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
182182
int i;
183-
int end = (start + size > 256) ? 256 : start + size;
184183

185-
for (i = start; i < end; i++) {
184+
for (i = 0; i < size; i++) {
186185
gma_crtc->lut_r[i] = red[i] >> 8;
187186
gma_crtc->lut_g[i] = green[i] >> 8;
188187
gma_crtc->lut_b[i] = blue[i] >> 8;
189188
}
190189

191190
gma_crtc_load_lut(crtc);
191+
192+
return 0;
192193
}
193194

194195
/**

drivers/gpu/drm/gma500/gma_display.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ extern int gma_crtc_cursor_set(struct drm_crtc *crtc,
7272
uint32_t width, uint32_t height);
7373
extern int gma_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
7474
extern void gma_crtc_load_lut(struct drm_crtc *crtc);
75-
extern void gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
76-
u16 *blue, u32 start, u32 size);
75+
extern int gma_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
76+
u16 *blue, u32 size);
7777
extern void gma_crtc_dpms(struct drm_crtc *crtc, int mode);
7878
extern void gma_crtc_prepare(struct drm_crtc *crtc);
7979
extern void gma_crtc_commit(struct drm_crtc *crtc);

drivers/gpu/drm/mgag200/mgag200_mode.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,19 +1344,20 @@ static void mga_crtc_commit(struct drm_crtc *crtc)
13441344
* use this for 8-bit mode so can't perform smooth fades on deeper modes,
13451345
* but it's a requirement that we provide the function
13461346
*/
1347-
static void mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
1348-
u16 *blue, uint32_t start, uint32_t size)
1347+
static int mga_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
1348+
u16 *blue, uint32_t size)
13491349
{
13501350
struct mga_crtc *mga_crtc = to_mga_crtc(crtc);
1351-
int end = (start + size > MGAG200_LUT_SIZE) ? MGAG200_LUT_SIZE : start + size;
13521351
int i;
13531352

1354-
for (i = start; i < end; i++) {
1353+
for (i = 0; i < size; i++) {
13551354
mga_crtc->lut_r[i] = red[i] >> 8;
13561355
mga_crtc->lut_g[i] = green[i] >> 8;
13571356
mga_crtc->lut_b[i] = blue[i] >> 8;
13581357
}
13591358
mga_crtc_load_lut(crtc);
1359+
1360+
return 0;
13601361
}
13611362

13621363
/* Simple cleanup function */

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,14 +785,14 @@ nv_crtc_disable(struct drm_crtc *crtc)
785785
nouveau_bo_ref(NULL, &disp->image[nv_crtc->index]);
786786
}
787787

788-
static void
789-
nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, uint32_t start,
788+
static int
789+
nv_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
790790
uint32_t size)
791791
{
792-
int end = (start + size > 256) ? 256 : start + size, i;
793792
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
793+
int i;
794794

795-
for (i = start; i < end; i++) {
795+
for (i = 0; i < size; i++) {
796796
nv_crtc->lut.r[i] = r[i];
797797
nv_crtc->lut.g[i] = g[i];
798798
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,
805805
*/
806806
if (!nv_crtc->base.primary->fb) {
807807
nv_crtc->lut.depth = 0;
808-
return;
808+
return 0;
809809
}
810810

811811
nv_crtc_gamma_load(crtc);
812+
813+
return 0;
812814
}
813815

814816
static int

drivers/gpu/drm/nouveau/nv50_display.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,21 +1346,22 @@ nv50_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
13461346
return 0;
13471347
}
13481348

1349-
static void
1349+
static int
13501350
nv50_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
1351-
uint32_t start, uint32_t size)
1351+
uint32_t size)
13521352
{
13531353
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
1354-
u32 end = min_t(u32, start + size, 256);
13551354
u32 i;
13561355

1357-
for (i = start; i < end; i++) {
1356+
for (i = 0; i < size; i++) {
13581357
nv_crtc->lut.r[i] = r[i];
13591358
nv_crtc->lut.g[i] = g[i];
13601359
nv_crtc->lut.b[i] = b[i];
13611360
}
13621361

13631362
nv50_crtc_lut_load(crtc);
1363+
1364+
return 0;
13641365
}
13651366

13661367
static void

drivers/gpu/drm/radeon/radeon_display.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,19 +231,21 @@ void radeon_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
231231
*blue = radeon_crtc->lut_b[regno] << 6;
232232
}
233233

234-
static void radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
235-
u16 *blue, uint32_t start, uint32_t size)
234+
static int radeon_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
235+
u16 *blue, uint32_t size)
236236
{
237237
struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
238-
int end = (start + size > 256) ? 256 : start + size, i;
238+
int i;
239239

240240
/* userspace palettes are always correct as is */
241-
for (i = start; i < end; i++) {
241+
for (i = 0; i < size; i++) {
242242
radeon_crtc->lut_r[i] = red[i] >> 6;
243243
radeon_crtc->lut_g[i] = green[i] >> 6;
244244
radeon_crtc->lut_b[i] = blue[i] >> 6;
245245
}
246246
radeon_crtc_load_lut(crtc);
247+
248+
return 0;
247249
}
248250

249251
static void radeon_crtc_destroy(struct drm_crtc *crtc)
@@ -688,6 +690,7 @@ radeon_crtc_set_config(struct drm_mode_set *set)
688690
pm_runtime_put_autosuspend(dev->dev);
689691
return ret;
690692
}
693+
691694
static const struct drm_crtc_funcs radeon_crtc_funcs = {
692695
.cursor_set2 = radeon_crtc_cursor_set2,
693696
.cursor_move = radeon_crtc_cursor_move,

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,22 @@ vc4_crtc_lut_load(struct drm_crtc *crtc)
175175
HVS_WRITE(SCALER_GAMDATA, vc4_crtc->lut_b[i]);
176176
}
177177

178-
static void
178+
static int
179179
vc4_crtc_gamma_set(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b,
180-
uint32_t start, uint32_t size)
180+
uint32_t size)
181181
{
182182
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
183183
u32 i;
184184

185-
for (i = start; i < start + size; i++) {
185+
for (i = 0; i < size; i++) {
186186
vc4_crtc->lut_r[i] = r[i] >> 8;
187187
vc4_crtc->lut_g[i] = g[i] >> 8;
188188
vc4_crtc->lut_b[i] = b[i] >> 8;
189189
}
190190

191191
vc4_crtc_lut_load(crtc);
192+
193+
return 0;
192194
}
193195

194196
static u32 vc4_get_fifo_full_level(u32 format)

drivers/gpu/drm/vmwgfx/vmwgfx_kms.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,9 +1404,9 @@ static int vmw_du_update_layout(struct vmw_private *dev_priv, unsigned num,
14041404
return 0;
14051405
}
14061406

1407-
void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
1408-
u16 *r, u16 *g, u16 *b,
1409-
uint32_t start, uint32_t size)
1407+
int vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
1408+
u16 *r, u16 *g, u16 *b,
1409+
uint32_t size)
14101410
{
14111411
struct vmw_private *dev_priv = vmw_priv(crtc->dev);
14121412
int i;
@@ -1418,6 +1418,8 @@ void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
14181418
vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 1, g[i] >> 8);
14191419
vmw_write(dev_priv, SVGA_PALETTE_BASE + i * 3 + 2, b[i] >> 8);
14201420
}
1421+
1422+
return 0;
14211423
}
14221424

14231425
int vmw_du_connector_dpms(struct drm_connector *connector, int mode)

0 commit comments

Comments
 (0)