Skip to content

Commit 254a3f0

Browse files
6by9pelwell
authored andcommitted
drm: Add a rotation parameter to connectors.
Some connectors, particularly writeback, can implement flip or transpose operations as writing back to memory. Add a connector rotation property to control this. Signed-off-by: Dave Stevenson <[email protected]>
1 parent fe975d0 commit 254a3f0

File tree

4 files changed

+60
-10
lines changed

4 files changed

+60
-10
lines changed

drivers/gpu/drm/drm_atomic_uapi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
791791
state->privacy_screen_sw_state = val;
792792
} else if (property == connector->broadcast_rgb_property) {
793793
state->hdmi.broadcast_rgb = val;
794+
} else if (property == connector->rotation_property) {
795+
state->rotation = val;
794796
} else if (connector->funcs->atomic_set_property) {
795797
return connector->funcs->atomic_set_property(connector,
796798
state, property, val);
@@ -882,6 +884,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
882884
*val = state->privacy_screen_sw_state;
883885
} else if (property == connector->broadcast_rgb_property) {
884886
*val = state->hdmi.broadcast_rgb;
887+
} else if (property == connector->rotation_property) {
888+
*val = state->rotation;
885889
} else if (connector->funcs->atomic_get_property) {
886890
return connector->funcs->atomic_get_property(connector,
887891
state, property, val);

drivers/gpu/drm/drm_blend.c

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,16 @@ int drm_plane_create_alpha_property(struct drm_plane *plane)
235235
}
236236
EXPORT_SYMBOL(drm_plane_create_alpha_property);
237237

238+
static const struct drm_prop_enum_list drm_rotate_props[] = {
239+
{ __builtin_ffs(DRM_MODE_ROTATE_0) - 1, "rotate-0" },
240+
{ __builtin_ffs(DRM_MODE_ROTATE_90) - 1, "rotate-90" },
241+
{ __builtin_ffs(DRM_MODE_ROTATE_180) - 1, "rotate-180" },
242+
{ __builtin_ffs(DRM_MODE_ROTATE_270) - 1, "rotate-270" },
243+
{ __builtin_ffs(DRM_MODE_REFLECT_X) - 1, "reflect-x" },
244+
{ __builtin_ffs(DRM_MODE_REFLECT_Y) - 1, "reflect-y" },
245+
{ __builtin_ffs(DRM_MODE_TRANSPOSE) - 1, "transpose" },
246+
};
247+
238248
/**
239249
* drm_plane_create_rotation_property - create a new rotation property
240250
* @plane: drm plane
@@ -275,23 +285,15 @@ int drm_plane_create_rotation_property(struct drm_plane *plane,
275285
unsigned int rotation,
276286
unsigned int supported_rotations)
277287
{
278-
static const struct drm_prop_enum_list props[] = {
279-
{ __builtin_ffs(DRM_MODE_ROTATE_0) - 1, "rotate-0" },
280-
{ __builtin_ffs(DRM_MODE_ROTATE_90) - 1, "rotate-90" },
281-
{ __builtin_ffs(DRM_MODE_ROTATE_180) - 1, "rotate-180" },
282-
{ __builtin_ffs(DRM_MODE_ROTATE_270) - 1, "rotate-270" },
283-
{ __builtin_ffs(DRM_MODE_REFLECT_X) - 1, "reflect-x" },
284-
{ __builtin_ffs(DRM_MODE_REFLECT_Y) - 1, "reflect-y" },
285-
{ __builtin_ffs(DRM_MODE_TRANSPOSE) - 1, "transpose" },
286-
};
287288
struct drm_property *prop;
288289

289290
WARN_ON((supported_rotations & DRM_MODE_ROTATE_MASK) == 0);
290291
WARN_ON(!is_power_of_2(rotation & DRM_MODE_ROTATE_MASK));
291292
WARN_ON(rotation & ~supported_rotations);
292293

293294
prop = drm_property_create_bitmask(plane->dev, 0, "rotation",
294-
props, ARRAY_SIZE(props),
295+
drm_rotate_props,
296+
ARRAY_SIZE(drm_rotate_props),
295297
supported_rotations);
296298
if (!prop)
297299
return -ENOMEM;
@@ -307,6 +309,34 @@ int drm_plane_create_rotation_property(struct drm_plane *plane,
307309
}
308310
EXPORT_SYMBOL(drm_plane_create_rotation_property);
309311

312+
int drm_connector_create_rotation_property(struct drm_connector *conn,
313+
unsigned int rotation,
314+
unsigned int supported_rotations)
315+
{
316+
struct drm_property *prop;
317+
318+
WARN_ON((supported_rotations & DRM_MODE_ROTATE_MASK) == 0);
319+
WARN_ON(!is_power_of_2(rotation & DRM_MODE_ROTATE_MASK));
320+
WARN_ON(rotation & ~supported_rotations);
321+
322+
prop = drm_property_create_bitmask(conn->dev, 0, "rotation",
323+
drm_rotate_props,
324+
ARRAY_SIZE(drm_rotate_props),
325+
supported_rotations);
326+
if (!prop)
327+
return -ENOMEM;
328+
329+
drm_object_attach_property(&conn->base, prop, rotation);
330+
331+
if (conn->state)
332+
conn->state->rotation = rotation;
333+
334+
conn->rotation_property = prop;
335+
336+
return 0;
337+
}
338+
EXPORT_SYMBOL(drm_connector_create_rotation_property);
339+
310340
/**
311341
* drm_rotation_simplify() - Try to simplify the rotation
312342
* @rotation: Rotation to be simplified

include/drm/drm_blend.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
struct drm_device;
3535
struct drm_atomic_state;
3636
struct drm_plane;
37+
struct drm_connector;
3738

3839
static inline bool drm_rotation_90_or_270(unsigned int rotation)
3940
{
@@ -58,4 +59,8 @@ int drm_atomic_normalize_zpos(struct drm_device *dev,
5859
struct drm_atomic_state *state);
5960
int drm_plane_create_blend_mode_property(struct drm_plane *plane,
6061
unsigned int supported_modes);
62+
63+
int drm_connector_create_rotation_property(struct drm_connector *conn,
64+
unsigned int rotation,
65+
unsigned int supported_rotations);
6166
#endif

include/drm/drm_connector.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,11 @@ struct drm_connector_state {
11391139
* @drm_atomic_helper_connector_hdmi_check().
11401140
*/
11411141
struct drm_connector_hdmi_state hdmi;
1142+
1143+
/**
1144+
* @rotation: Connector property to rotate the maximum output image.
1145+
*/
1146+
u32 rotation;
11421147
};
11431148

11441149
/**
@@ -1926,6 +1931,12 @@ struct drm_connector {
19261931
*/
19271932
struct drm_property *broadcast_rgb_property;
19281933

1934+
/**
1935+
* @rotation_property: Optional DRM property controlling rotation of the
1936+
* output.
1937+
*/
1938+
struct drm_property *rotation_property;
1939+
19291940
#define DRM_CONNECTOR_POLL_HPD (1 << 0)
19301941
#define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
19311942
#define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)

0 commit comments

Comments
 (0)