Skip to content

Commit c2c446a

Browse files
Robert Fossdanvet
authored andcommitted
drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI
Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ defines to the UAPI as a convenience. Ideally the DRM_ROTATE_ and DRM_REFLECT_ property ids are looked up through the atomic API, but realizing that userspace is likely to take shortcuts and assume that the enum values are what is sent over the wire. As a result these defines are provided purely as a convenience to userspace applications. Changes since v3: - Switched away from past tense in comments - Add define name change to previously mis-spelled DRM_REFLECT_X comment - Improved the comment for the DRM_MODE_REFLECT_<axis> comment Changes since v2: - Changed define prefix from DRM_MODE_PROP_ to DRM_MODE_ - Fix compilation errors - Changed comment formatting - Deduplicated comment lines - Clarified DRM_MODE_PROP_REFLECT_ comment Changes since v1: - Moved defines from drm.h to drm_mode.h - Changed define prefix from DRM_ to DRM_MODE_PROP_ - Updated uses of the defines to the new prefix - Removed include from drm_rect.c - Stopped using the BIT() macro Signed-off-by: Robert Foss <robert.foss@collabora.com> Reviewed-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Sinclair Yeh <syeh@vmware.com> Acked-by: Liviu Dudau <Liviu.Dudau@arm.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20170519205017.23307-2-robert.foss@collabora.com
1 parent e8fa49b commit c2c446a

25 files changed

Lines changed: 202 additions & 171 deletions

‎drivers/gpu/drm/arm/malidp_drv.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ void malidp_de_planes_destroy(struct drm_device *drm);
6565
int malidp_crtc_init(struct drm_device *drm);
6666

6767
/* often used combination of rotational bits */
68-
#define MALIDP_ROTATED_MASK (DRM_ROTATE_90 | DRM_ROTATE_270)
68+
#define MALIDP_ROTATED_MASK (DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_270)
6969

7070
#endif /* __MALIDP_DRV_H__ */

‎drivers/gpu/drm/arm/malidp_planes.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static void malidp_plane_reset(struct drm_plane *plane)
8080
state = kzalloc(sizeof(*state), GFP_KERNEL);
8181
if (state) {
8282
state->base.plane = plane;
83-
state->base.rotation = DRM_ROTATE_0;
83+
state->base.rotation = DRM_MODE_ROTATE_0;
8484
plane->state = &state->base;
8585
}
8686
}
@@ -221,7 +221,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
221221
return ret;
222222

223223
/* packed RGB888 / BGR888 can't be rotated or flipped */
224-
if (state->rotation != DRM_ROTATE_0 &&
224+
if (state->rotation != DRM_MODE_ROTATE_0 &&
225225
(fb->format->format == DRM_FORMAT_RGB888 ||
226226
fb->format->format == DRM_FORMAT_BGR888))
227227
return -EINVAL;
@@ -315,12 +315,12 @@ static void malidp_de_plane_update(struct drm_plane *plane,
315315
val &= ~LAYER_ROT_MASK;
316316

317317
/* setup the rotation and axis flip bits */
318-
if (plane->state->rotation & DRM_ROTATE_MASK)
319-
val |= ilog2(plane->state->rotation & DRM_ROTATE_MASK) <<
318+
if (plane->state->rotation & DRM_MODE_ROTATE_MASK)
319+
val |= ilog2(plane->state->rotation & DRM_MODE_ROTATE_MASK) <<
320320
LAYER_ROT_OFFSET;
321-
if (plane->state->rotation & DRM_REFLECT_X)
321+
if (plane->state->rotation & DRM_MODE_REFLECT_X)
322322
val |= LAYER_H_FLIP;
323-
if (plane->state->rotation & DRM_REFLECT_Y)
323+
if (plane->state->rotation & DRM_MODE_REFLECT_Y)
324324
val |= LAYER_V_FLIP;
325325

326326
/*
@@ -370,8 +370,8 @@ int malidp_de_planes_init(struct drm_device *drm)
370370
struct malidp_plane *plane = NULL;
371371
enum drm_plane_type plane_type;
372372
unsigned long crtcs = 1 << drm->mode_config.num_crtc;
373-
unsigned long flags = DRM_ROTATE_0 | DRM_ROTATE_90 | DRM_ROTATE_180 |
374-
DRM_ROTATE_270 | DRM_REFLECT_X | DRM_REFLECT_Y;
373+
unsigned long flags = DRM_MODE_ROTATE_0 | DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_180 |
374+
DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;
375375
u32 *formats;
376376
int ret, i, j, n;
377377

@@ -420,7 +420,7 @@ int malidp_de_planes_init(struct drm_device *drm)
420420
continue;
421421
}
422422

423-
drm_plane_create_rotation_property(&plane->base, DRM_ROTATE_0, flags);
423+
drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0, flags);
424424
malidp_hw_write(malidp->dev, MALIDP_ALPHA_LUT,
425425
plane->layer->base + MALIDP_LAYER_COMPOSE);
426426
}

‎drivers/gpu/drm/armada/armada_overlay.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
125125
src_x, src_y, src_w, src_h);
126126

127127
ret = drm_plane_helper_check_update(plane, crtc, fb, &src, &dest, &clip,
128-
DRM_ROTATE_0,
128+
DRM_MODE_ROTATE_0,
129129
0, INT_MAX, true, false, &visible);
130130
if (ret)
131131
return ret;

‎drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,8 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
678678
if (!state->bpp[i])
679679
return -EINVAL;
680680

681-
switch (state->base.rotation & DRM_ROTATE_MASK) {
682-
case DRM_ROTATE_90:
681+
switch (state->base.rotation & DRM_MODE_ROTATE_MASK) {
682+
case DRM_MODE_ROTATE_90:
683683
offset = ((y_offset + state->src_y + patched_src_w - 1) /
684684
ydiv) * fb->pitches[i];
685685
offset += ((x_offset + state->src_x) / xdiv) *
@@ -688,7 +688,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
688688
fb->pitches[i];
689689
state->pstride[i] = -fb->pitches[i] - state->bpp[i];
690690
break;
691-
case DRM_ROTATE_180:
691+
case DRM_MODE_ROTATE_180:
692692
offset = ((y_offset + state->src_y + patched_src_h - 1) /
693693
ydiv) * fb->pitches[i];
694694
offset += ((x_offset + state->src_x + patched_src_w - 1) /
@@ -697,7 +697,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
697697
state->bpp[i]) - fb->pitches[i];
698698
state->pstride[i] = -2 * state->bpp[i];
699699
break;
700-
case DRM_ROTATE_270:
700+
case DRM_MODE_ROTATE_270:
701701
offset = ((y_offset + state->src_y) / ydiv) *
702702
fb->pitches[i];
703703
offset += ((x_offset + state->src_x + patched_src_h - 1) /
@@ -707,7 +707,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
707707
(2 * state->bpp[i]);
708708
state->pstride[i] = fb->pitches[i] - state->bpp[i];
709709
break;
710-
case DRM_ROTATE_0:
710+
case DRM_MODE_ROTATE_0:
711711
default:
712712
offset = ((y_offset + state->src_y) / ydiv) *
713713
fb->pitches[i];
@@ -864,11 +864,11 @@ static int atmel_hlcdc_plane_init_properties(struct atmel_hlcdc_plane *plane,
864864
int ret;
865865

866866
ret = drm_plane_create_rotation_property(&plane->base,
867-
DRM_ROTATE_0,
868-
DRM_ROTATE_0 |
869-
DRM_ROTATE_90 |
870-
DRM_ROTATE_180 |
871-
DRM_ROTATE_270);
867+
DRM_MODE_ROTATE_0,
868+
DRM_MODE_ROTATE_0 |
869+
DRM_MODE_ROTATE_90 |
870+
DRM_MODE_ROTATE_180 |
871+
DRM_MODE_ROTATE_270);
872872
if (ret)
873873
return ret;
874874
}

‎drivers/gpu/drm/drm_atomic.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ int drm_atomic_plane_set_property(struct drm_plane *plane,
781781
} else if (property == config->prop_src_h) {
782782
state->src_h = val;
783783
} else if (property == plane->rotation_property) {
784-
if (!is_power_of_2(val & DRM_ROTATE_MASK))
784+
if (!is_power_of_2(val & DRM_MODE_ROTATE_MASK))
785785
return -EINVAL;
786786
state->rotation = val;
787787
} else if (property == plane->zpos_property) {

‎drivers/gpu/drm/drm_atomic_helper.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3225,7 +3225,7 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane)
32253225

32263226
if (plane->state) {
32273227
plane->state->plane = plane;
3228-
plane->state->rotation = DRM_ROTATE_0;
3228+
plane->state->rotation = DRM_MODE_ROTATE_0;
32293229
}
32303230
}
32313231
EXPORT_SYMBOL(drm_atomic_helper_plane_reset);

‎drivers/gpu/drm/drm_blend.c‎

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@
119119
* drm_property_create_bitmask()) called "rotation" and has the following
120120
* bitmask enumaration values:
121121
*
122-
* DRM_ROTATE_0:
122+
* DRM_MODE_ROTATE_0:
123123
* "rotate-0"
124-
* DRM_ROTATE_90:
124+
* DRM_MODE_ROTATE_90:
125125
* "rotate-90"
126-
* DRM_ROTATE_180:
126+
* DRM_MODE_ROTATE_180:
127127
* "rotate-180"
128-
* DRM_ROTATE_270:
128+
* DRM_MODE_ROTATE_270:
129129
* "rotate-270"
130-
* DRM_REFLECT_X:
130+
* DRM_MODE_REFLECT_X:
131131
* "reflect-x"
132-
* DRM_REFLECT_Y:
132+
* DRM_MODE_REFLECT_Y:
133133
* "reflect-y"
134134
*
135135
* Rotation is the specified amount in degrees in counter clockwise direction,
@@ -142,17 +142,17 @@ int drm_plane_create_rotation_property(struct drm_plane *plane,
142142
unsigned int supported_rotations)
143143
{
144144
static const struct drm_prop_enum_list props[] = {
145-
{ __builtin_ffs(DRM_ROTATE_0) - 1, "rotate-0" },
146-
{ __builtin_ffs(DRM_ROTATE_90) - 1, "rotate-90" },
147-
{ __builtin_ffs(DRM_ROTATE_180) - 1, "rotate-180" },
148-
{ __builtin_ffs(DRM_ROTATE_270) - 1, "rotate-270" },
149-
{ __builtin_ffs(DRM_REFLECT_X) - 1, "reflect-x" },
150-
{ __builtin_ffs(DRM_REFLECT_Y) - 1, "reflect-y" },
145+
{ __builtin_ffs(DRM_MODE_ROTATE_0) - 1, "rotate-0" },
146+
{ __builtin_ffs(DRM_MODE_ROTATE_90) - 1, "rotate-90" },
147+
{ __builtin_ffs(DRM_MODE_ROTATE_180) - 1, "rotate-180" },
148+
{ __builtin_ffs(DRM_MODE_ROTATE_270) - 1, "rotate-270" },
149+
{ __builtin_ffs(DRM_MODE_REFLECT_X) - 1, "reflect-x" },
150+
{ __builtin_ffs(DRM_MODE_REFLECT_Y) - 1, "reflect-y" },
151151
};
152152
struct drm_property *prop;
153153

154-
WARN_ON((supported_rotations & DRM_ROTATE_MASK) == 0);
155-
WARN_ON(!is_power_of_2(rotation & DRM_ROTATE_MASK));
154+
WARN_ON((supported_rotations & DRM_MODE_ROTATE_MASK) == 0);
155+
WARN_ON(!is_power_of_2(rotation & DRM_MODE_ROTATE_MASK));
156156
WARN_ON(rotation & ~supported_rotations);
157157

158158
prop = drm_property_create_bitmask(plane->dev, 0, "rotation",
@@ -178,14 +178,14 @@ EXPORT_SYMBOL(drm_plane_create_rotation_property);
178178
* @supported_rotations: Supported rotations
179179
*
180180
* Attempt to simplify the rotation to a form that is supported.
181-
* Eg. if the hardware supports everything except DRM_REFLECT_X
181+
* Eg. if the hardware supports everything except DRM_MODE_REFLECT_X
182182
* one could call this function like this:
183183
*
184-
* drm_rotation_simplify(rotation, DRM_ROTATE_0 |
185-
* DRM_ROTATE_90 | DRM_ROTATE_180 |
186-
* DRM_ROTATE_270 | DRM_REFLECT_Y);
184+
* drm_rotation_simplify(rotation, DRM_MODE_ROTATE_0 |
185+
* DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_180 |
186+
* DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_Y);
187187
*
188-
* to eliminate the DRM_ROTATE_X flag. Depending on what kind of
188+
* to eliminate the DRM_MODE_ROTATE_X flag. Depending on what kind of
189189
* transforms the hardware supports, this function may not
190190
* be able to produce a supported transform, so the caller should
191191
* check the result afterwards.
@@ -194,9 +194,10 @@ unsigned int drm_rotation_simplify(unsigned int rotation,
194194
unsigned int supported_rotations)
195195
{
196196
if (rotation & ~supported_rotations) {
197-
rotation ^= DRM_REFLECT_X | DRM_REFLECT_Y;
198-
rotation = (rotation & DRM_REFLECT_MASK) |
199-
BIT((ffs(rotation & DRM_ROTATE_MASK) + 1) % 4);
197+
rotation ^= DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y;
198+
rotation = (rotation & DRM_MODE_REFLECT_MASK) |
199+
BIT((ffs(rotation & DRM_MODE_ROTATE_MASK) + 1)
200+
% 4);
200201
}
201202

202203
return rotation;

‎drivers/gpu/drm/drm_fb_helper.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static int restore_fbdev_mode_atomic(struct drm_fb_helper *fb_helper)
378378
goto fail;
379379
}
380380

381-
plane_state->rotation = DRM_ROTATE_0;
381+
plane_state->rotation = DRM_MODE_ROTATE_0;
382382

383383
plane->old_fb = plane->fb;
384384
plane_mask |= 1 << drm_plane_index(plane);
@@ -431,7 +431,7 @@ static int restore_fbdev_mode_legacy(struct drm_fb_helper *fb_helper)
431431
if (plane->rotation_property)
432432
drm_mode_plane_set_obj_prop(plane,
433433
plane->rotation_property,
434-
DRM_ROTATE_0);
434+
DRM_MODE_ROTATE_0);
435435
}
436436

437437
for (i = 0; i < fb_helper->crtc_count; i++) {

‎drivers/gpu/drm/drm_plane_helper.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
336336

337337
ret = drm_plane_helper_check_update(plane, crtc, fb,
338338
&src, &dest, &clip,
339-
DRM_ROTATE_0,
339+
DRM_MODE_ROTATE_0,
340340
DRM_PLANE_HELPER_NO_SCALING,
341341
DRM_PLANE_HELPER_NO_SCALING,
342342
false, false, &visible);

‎drivers/gpu/drm/drm_rect.c‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -310,38 +310,38 @@ void drm_rect_rotate(struct drm_rect *r,
310310
{
311311
struct drm_rect tmp;
312312

313-
if (rotation & (DRM_REFLECT_X | DRM_REFLECT_Y)) {
313+
if (rotation & (DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y)) {
314314
tmp = *r;
315315

316-
if (rotation & DRM_REFLECT_X) {
316+
if (rotation & DRM_MODE_REFLECT_X) {
317317
r->x1 = width - tmp.x2;
318318
r->x2 = width - tmp.x1;
319319
}
320320

321-
if (rotation & DRM_REFLECT_Y) {
321+
if (rotation & DRM_MODE_REFLECT_Y) {
322322
r->y1 = height - tmp.y2;
323323
r->y2 = height - tmp.y1;
324324
}
325325
}
326326

327-
switch (rotation & DRM_ROTATE_MASK) {
328-
case DRM_ROTATE_0:
327+
switch (rotation & DRM_MODE_ROTATE_MASK) {
328+
case DRM_MODE_ROTATE_0:
329329
break;
330-
case DRM_ROTATE_90:
330+
case DRM_MODE_ROTATE_90:
331331
tmp = *r;
332332
r->x1 = tmp.y1;
333333
r->x2 = tmp.y2;
334334
r->y1 = width - tmp.x2;
335335
r->y2 = width - tmp.x1;
336336
break;
337-
case DRM_ROTATE_180:
337+
case DRM_MODE_ROTATE_180:
338338
tmp = *r;
339339
r->x1 = width - tmp.x2;
340340
r->x2 = width - tmp.x1;
341341
r->y1 = height - tmp.y2;
342342
r->y2 = height - tmp.y1;
343343
break;
344-
case DRM_ROTATE_270:
344+
case DRM_MODE_ROTATE_270:
345345
tmp = *r;
346346
r->x1 = height - tmp.y2;
347347
r->x2 = height - tmp.y1;
@@ -373,8 +373,8 @@ EXPORT_SYMBOL(drm_rect_rotate);
373373
* them when doing a rotatation and its inverse.
374374
* That is, if you do ::
375375
*
376-
* drm_rotate(&r, width, height, rotation);
377-
* drm_rotate_inv(&r, width, height, rotation);
376+
* DRM_MODE_PROP_ROTATE(&r, width, height, rotation);
377+
* DRM_MODE_ROTATE_inv(&r, width, height, rotation);
378378
*
379379
* you will always get back the original rectangle.
380380
*/
@@ -384,24 +384,24 @@ void drm_rect_rotate_inv(struct drm_rect *r,
384384
{
385385
struct drm_rect tmp;
386386

387-
switch (rotation & DRM_ROTATE_MASK) {
388-
case DRM_ROTATE_0:
387+
switch (rotation & DRM_MODE_ROTATE_MASK) {
388+
case DRM_MODE_ROTATE_0:
389389
break;
390-
case DRM_ROTATE_90:
390+
case DRM_MODE_ROTATE_90:
391391
tmp = *r;
392392
r->x1 = width - tmp.y2;
393393
r->x2 = width - tmp.y1;
394394
r->y1 = tmp.x1;
395395
r->y2 = tmp.x2;
396396
break;
397-
case DRM_ROTATE_180:
397+
case DRM_MODE_ROTATE_180:
398398
tmp = *r;
399399
r->x1 = width - tmp.x2;
400400
r->x2 = width - tmp.x1;
401401
r->y1 = height - tmp.y2;
402402
r->y2 = height - tmp.y1;
403403
break;
404-
case DRM_ROTATE_270:
404+
case DRM_MODE_ROTATE_270:
405405
tmp = *r;
406406
r->x1 = tmp.y1;
407407
r->x2 = tmp.y2;
@@ -412,15 +412,15 @@ void drm_rect_rotate_inv(struct drm_rect *r,
412412
break;
413413
}
414414

415-
if (rotation & (DRM_REFLECT_X | DRM_REFLECT_Y)) {
415+
if (rotation & (DRM_MODE_REFLECT_X | DRM_MODE_REFLECT_Y)) {
416416
tmp = *r;
417417

418-
if (rotation & DRM_REFLECT_X) {
418+
if (rotation & DRM_MODE_REFLECT_X) {
419419
r->x1 = width - tmp.x2;
420420
r->x2 = width - tmp.x1;
421421
}
422422

423-
if (rotation & DRM_REFLECT_Y) {
423+
if (rotation & DRM_MODE_REFLECT_Y) {
424424
r->y1 = height - tmp.y2;
425425
r->y2 = height - tmp.y1;
426426
}

0 commit comments

Comments
 (0)