Add rotation support for Rockchip

Fixes #878
This commit is contained in:
Cameron Gutman 2024-02-18 14:48:13 -06:00
parent a9d6f17d5e
commit d6c9650a32
2 changed files with 19 additions and 1 deletions

View File

@ -195,7 +195,7 @@ static void help() {
printf("\t-4k\t\t\tUse 3840x2160 resolution\n");
printf("\t-width <width>\t\tHorizontal resolution (default 1280)\n");
printf("\t-height <height>\tVertical resolution (default 720)\n");
#if defined(HAVE_PI) | defined(HAVE_MMAL)
#ifdef HAVE_EMBEDDED
printf("\t-rotate <angle>\tRotate display: 0/90/180/270 (default 0)\n");
#endif
printf("\t-fps <fps>\t\tSpecify the fps to use (default 60)\n");

View File

@ -502,6 +502,24 @@ int rk_setup(int videoFormat, int width, int height, int redrawRate, void* conte
}
assert(plane_id);
// DRM defines rotation in degrees counter-clockwise while we define
// rotation in degrees clockwise, so we swap the 90 and 270 cases
int displayRotation = drFlags & DISPLAY_ROTATE_MASK;
switch (displayRotation) {
case DISPLAY_ROTATE_90:
set_property(plane_id, DRM_MODE_OBJECT_PLANE, plane_props, "rotation", DRM_MODE_ROTATE_270);
break;
case DISPLAY_ROTATE_180:
set_property(plane_id, DRM_MODE_OBJECT_PLANE, plane_props, "rotation", DRM_MODE_ROTATE_180);
break;
case DISPLAY_ROTATE_270:
set_property(plane_id, DRM_MODE_OBJECT_PLANE, plane_props, "rotation", DRM_MODE_ROTATE_90);
break;
default:
set_property(plane_id, DRM_MODE_OBJECT_PLANE, plane_props, "rotation", DRM_MODE_ROTATE_0);
break;
}
// hide cursor by move in left lower corner
drmModeMoveCursor(fd, crtc_id, 0, crtc_height);