Skip to content

Commit c381cc5

Browse files
6by9popcornmix
authored andcommitted
drm/vc4: txp: Add a rotation property to the writeback connector
The txp block can implement transpose as it writes out the image data, so expose that through the new connector rotation property. Signed-off-by: Dave Stevenson <[email protected]> drm: vc4: txp: Do not allow 24bpp formats when transposing The hardware doesn't support transposing to 24bpp (RGB888/BGR888) formats. There's no way to advertise this through DRM, so block it from atomic_check instead. Signed-off-by: Dave Stevenson <[email protected]>
1 parent 96dd0e7 commit c381cc5

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

drivers/gpu/drm/vc4/vc4_txp.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <drm/drm_atomic.h>
1717
#include <drm/drm_atomic_helper.h>
18+
#include <drm/drm_blend.h>
1819
#include <drm/drm_drv.h>
1920
#include <drm/drm_edid.h>
2021
#include <drm/drm_fb_dma_helper.h>
@@ -259,10 +260,22 @@ static int vc4_txp_connector_atomic_check(struct drm_connector *conn,
259260
crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
260261

261262
fb = conn_state->writeback_job->fb;
262-
if (fb->width != crtc_state->mode.hdisplay ||
263-
fb->height != crtc_state->mode.vdisplay) {
264-
DRM_DEBUG_KMS("Invalid framebuffer size %ux%u\n",
265-
fb->width, fb->height);
263+
if ((conn_state->rotation == DRM_MODE_ROTATE_0 &&
264+
fb->width != crtc_state->mode.hdisplay &&
265+
fb->height != crtc_state->mode.vdisplay) ||
266+
(conn_state->rotation == (DRM_MODE_ROTATE_0 | DRM_MODE_TRANSPOSE) &&
267+
fb->width != crtc_state->mode.vdisplay &&
268+
fb->height != crtc_state->mode.hdisplay)) {
269+
DRM_DEBUG_KMS("Invalid framebuffer size %ux%u vs mode %ux%u\n",
270+
fb->width, fb->height,
271+
crtc_state->mode.hdisplay, crtc_state->mode.vdisplay);
272+
return -EINVAL;
273+
}
274+
275+
if (conn_state->rotation & DRM_MODE_TRANSPOSE &&
276+
(fb->format->format == DRM_FORMAT_RGB888 ||
277+
fb->format->format == DRM_FORMAT_BGR888)) {
278+
DRM_DEBUG_KMS("24bpp formats not supported when transposing\n");
266279
return -EINVAL;
267280
}
268281

@@ -330,6 +343,9 @@ static void vc4_txp_connector_atomic_commit(struct drm_connector *conn,
330343
*/
331344
ctrl |= TXP_ALPHA_INVERT;
332345

346+
if (conn_state->rotation & DRM_MODE_TRANSPOSE)
347+
ctrl |= TXP_TRANSPOSE;
348+
333349
if (!drm_dev_enter(drm, &idx))
334350
return;
335351

@@ -608,6 +624,10 @@ static int vc4_txp_bind(struct device *dev, struct device *master, void *data)
608624
if (ret)
609625
return ret;
610626

627+
drm_connector_create_rotation_property(&txp->connector.base, DRM_MODE_ROTATE_0,
628+
DRM_MODE_ROTATE_0 |
629+
DRM_MODE_TRANSPOSE);
630+
611631
ret = devm_request_irq(dev, irq, vc4_txp_interrupt, 0,
612632
dev_name(dev), txp);
613633
if (ret)

0 commit comments

Comments
 (0)