Skip to content
Snippets Groups Projects
Commit 3196e47d authored by Johannes Marbach's avatar Johannes Marbach
Browse files

Merge branch 'feature-unl0kr-swrot' into 'master'

Add software rotation to unl0kr

See merge request postmarketOS/buffybox!32
parents 6bf7a840 a410763f
Branches
Tags
1 merge request!32Add software rotation to unl0kr
Pipeline #217112 passed
......@@ -20,6 +20,7 @@ If a change only affects particular applications, they are listed in parentheses
- fix: Use usleep to release CPU when possible (!31, thanks @uninsane)
- feat(buffyboard): Add a buffyboard.service systemd service (!34, @uninsane)
- fix(unl0kr): Select an available DRM device instead of a hard-coded one (!35, thanks @Sorcus)
- feat(unl0kr): Enable software rotation (!32, thanks @xs5871 & @craftyguy)
## 3.2.0 (2024-06-03)
......
......@@ -34,6 +34,14 @@ password is printed to STDOUT. All other output happens on STDERR.
horizontally by X pixels and vertically by Y pixels.
*-d --dpi=N*
Override the display's DPI value.
*-r, --rotate=[0-3]*
Rotate the UI to the given orientation. The
values match the ones provided by the kernel in
/sys/class/graphics/fbcon/rotate.
* 0 - normal orientation (0 degree)
* 1 - clockwise orientation (90 degrees)
* 2 - upside down orientation (180 degrees)
* 3 - counterclockwise orientation (270 degrees)
*-h, --help*
Print this message and exit.
*-v, --verbose*
......
......@@ -61,6 +61,13 @@ Mandatory arguments to long options are mandatory for short options too.
vertical pixels, offset horizontally by X
pixels and vertically by Y pixels
-d --dpi=N Override the display's DPI value
-r, --rotate=[0-3] Rotate the UI to the given orientation. The
values match the ones provided by the kernel in
/sys/class/graphics/fbcon/rotate.
* 0 - normal orientation (0 degree)
* 1 - clockwise orientation (90 degrees)
* 2 - upside down orientation (180 degrees)
* 3 - counterclockwise orientation (270 degrees)
-h, --help Print this message and exit
-v, --verbose Enable more detailed logging output on STDERR
-V, --version Print the unl0kr version and exit
......
......@@ -44,6 +44,7 @@ static void init_opts(ul_cli_opts *opts) {
opts->x_offset = 0;
opts->y_offset = 0;
opts->dpi = 0;
opts->rotation = LV_DISPLAY_ROTATION_0;
opts->verbose = false;
}
......@@ -68,6 +69,13 @@ static void print_usage() {
" vertical pixels, offset horizontally by X\n"
" pixels and vertically by Y pixels\n"
" -d --dpi=N Override the display's DPI value\n"
" -r, --rotate=[0-3] Rotate the UI to the given orientation. The\n"
" values match the ones provided by the kernel in\n"
" /sys/class/graphics/fbcon/rotate.\n"
" * 0 - normal orientation (0 degree)\n"
" * 1 - clockwise orientation (90 degrees)\n"
" * 2 - upside down orientation (180 degrees)\n"
" * 3 - counterclockwise orientation (270 degrees)\n"
" -h, --help Print this message and exit\n"
" -v, --verbose Enable more detailed logging output on STDERR\n"
" -V, --version Print the unl0kr version and exit\n");
......@@ -86,6 +94,7 @@ void ul_cli_parse_opts(int argc, char *argv[], ul_cli_opts *opts) {
{ "config-override", required_argument, NULL, 'C' },
{ "geometry", required_argument, NULL, 'g' },
{ "dpi", required_argument, NULL, 'd' },
{ "rotate", required_argument, NULL, 'r' },
{ "help", no_argument, NULL, 'h' },
{ "verbose", no_argument, NULL, 'v' },
{ "version", no_argument, NULL, 'V' },
......@@ -94,7 +103,7 @@ void ul_cli_parse_opts(int argc, char *argv[], ul_cli_opts *opts) {
int opt, index = 0;
while ((opt = getopt_long(argc, argv, "C:g:d:hvV", long_opts, &index)) != -1) {
while ((opt = getopt_long(argc, argv, "C:g:d:r:hvV", long_opts, &index)) != -1) {
switch (opt) {
case 'C':
opts->config_files = realloc(opts->config_files, (opts->num_config_files + 1) * sizeof(char *));
......@@ -119,6 +128,28 @@ void ul_cli_parse_opts(int argc, char *argv[], ul_cli_opts *opts) {
exit(EXIT_FAILURE);
}
break;
case 'r': {
int orientation;
if (sscanf(optarg, "%i", &orientation) != 1 || orientation < 0 || orientation > 3) {
fprintf(stderr, "Invalid orientation argument \"%s\"\n", optarg);
exit(EXIT_FAILURE);
}
switch (orientation) {
case 0:
opts->rotation = LV_DISPLAY_ROTATION_0;
break;
case 1:
opts->rotation = LV_DISPLAY_ROTATION_270;
break;
case 2:
opts->rotation = LV_DISPLAY_ROTATION_180;
break;
case 3:
opts->rotation = LV_DISPLAY_ROTATION_90;
break;
}
break;
}
case 'h':
print_usage();
exit(EXIT_SUCCESS);
......
......@@ -8,6 +8,7 @@
#define UL_COMMAND_LINE_H
#include <stdbool.h>
#include "lvgl/lvgl.h"
/**
* Options parsed from command line arguments
......@@ -27,6 +28,8 @@ typedef struct {
int y_offset;
/* DPI */
int dpi;
/* Display rotation */
lv_display_rotation_t rotation;
/* Verbose mode. If true, provide more detailed logging output on STDERR. */
bool verbose;
} ul_cli_opts;
......
......@@ -509,7 +509,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
#define LV_USE_LINUX_FBDEV 1
#if LV_USE_LINUX_FBDEV
#define LV_LINUX_FBDEV_BSD 0
#define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT
#define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_PARTIAL
#define LV_LINUX_FBDEV_BUFFER_COUNT 0
#define LV_LINUX_FBDEV_BUFFER_SIZE 60
#endif
......
......@@ -455,6 +455,9 @@ int main(int argc, char *argv[]) {
lv_display_set_dpi(disp, cli_opts.dpi);
}
/* Set up display rotation */
lv_display_set_rotation(disp, cli_opts.rotation);
/* Store final display resolution for convenient later access */
const uint32_t hor_res = lv_disp_get_hor_res(disp);
const uint32_t ver_res = lv_disp_get_ver_res(disp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment