Skip to content

Conversation

sschueller
Copy link

This ads an overlay for the 1.14" pi hat like this one: https://www.aliexpress.com/item/1005001685753066.html

Works under Radxa ZERO 3 Debian Build 6 and Armbian distro

To use it under Armbian:

apt-get git build-dep --no-install-recommends -y .
git clone https://github.com/radxa-pkg/radxa-overlays.git
cd radxa-overlays
make all deb
make build-dtbo -j$(nproc) KERNELRELEASE=$(uname -r) CONFIG_CPU_RK3568=rockchip
mkdir -p /boot/overlay/
cp arch/arm64/boot/dts/rockchip/overlays/radxa-zero3-mini-pi-1.14-lcd-hat.dtbo /boot/overlay/
fdtoverlay -v -i /boot/dtb/rockchip/rk3566-radxa-zero3.dtb -o /boot/dtb/rockchip/rk3566-radxa-zero3-patched.dtb /boot/overlay/radxa-zero3-mini-pi-1.14-lcd-hat.dtbo

Edit your /boot/armbianEnv.txt

...
overlay_prefix=rk35xx
fdtfile=rockchip/rk3566-radxa-zero3-patched.dtb
...

Reboot

For the 135x240 to work with the correct offset the driver needs to be patched as well to support offsets:

apt install -y linux-source build-dep
tar -xf /usr/src/linux-source-*.tar.xz
cd linux-source-*/drivers/staging/fbtft/
git apply fb_st7789v.c.patch # patch with changes as file below
make -C /lib/modules/$(uname -r)/build M=$(pwd) fb_st7789v.ko
mv /usr/lib/modules/$(uname -r)/kernel/drivers/staging/fbtft/fb_st7789v.ko /usr/lib/modules/$(uname -r)/kernel/drivers/staging/fbtft/fb_st7789v.ko-old
cp fb_st7789v.ko /usr/lib/modules/$(uname -r)/kernel/drivers/staging/fbtft/.
reboot

fb_st7789v.c.patch

--- fb_st7789v-orig.c	2025-07-05 15:07:25.608286257 +0200
+++ fb_st7789v.c	2025-07-05 15:07:25.608286257 +0200
@@ -13,7 +13,7 @@
 #include <linux/interrupt.h>
 #include <linux/completion.h>
 #include <linux/module.h>
-
+#include <linux/moduleparam.h>
 #include <video/mipi_display.h>
 
 #include "fbtft.h"
@@ -30,6 +30,13 @@
 
 #define HSD20_IPS 1
 
+static int x_offset = 0;
+static int y_offset = 0;
+module_param(x_offset, int, 0444);
+MODULE_PARM_DESC(x_offset, "X offset of the display");
+module_param(y_offset, int, 0444);
+MODULE_PARM_DESC(y_offset, "Y offset of the display");
+
 /**
  * enum st7789v_command - ST7789V display controller commands
  *
@@ -142,6 +149,13 @@
  */
 static int init_display(struct fbtft_par *par)
 {
+	struct device *dev = par->info->device;
+
+	if (dev->of_node) {
+		of_property_read_u32(dev->of_node, "x-offset", &x_offset);
+		of_property_read_u32(dev->of_node, "y-offset", &y_offset);
+	}
+
 	int rc;
 
 	par->fbtftops.reset(par);
@@ -294,6 +308,33 @@
 }
 
 /**
+ * set_addr_win() - set the address window with optional offsets
+ *
+ * @par: FBTFT parameter object
+ * @xs: x start
+ * @ys: y start
+ * @xe: x end
+ * @ye: y end
+ */
+static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
+{
+	xs += x_offset;
+	xe += x_offset;
+	ys += y_offset;
+	ye += y_offset;
+
+	write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,
+		  (xs >> 8) & 0xFF, xs & 0xFF,
+		  (xe >> 8) & 0xFF, xe & 0xFF);
+
+	write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS,
+		  (ys >> 8) & 0xFF, ys & 0xFF,
+		  (ye >> 8) & 0xFF, ye & 0xFF);
+
+	write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
+}
+
+/**
  * set_gamma() - set gamma curves
  *
  * @par: FBTFT parameter object
@@ -379,6 +420,7 @@
 		.set_var = set_var,
 		.set_gamma = set_gamma,
 		.blank = blank,
+		.set_addr_win = set_addr_win,
 	},
 };
 
@@ -389,6 +431,6 @@
 MODULE_ALIAS("spi:st7789v");
 MODULE_ALIAS("platform:st7789v");
 
-MODULE_DESCRIPTION("FB driver for the ST7789V LCD Controller");
+MODULE_DESCRIPTION("FB driver for the ST7789V LCD Controller with offset");
 MODULE_AUTHOR("Dennis Menschel");
 MODULE_LICENSE("GPL");
\ No newline at end of file

@sschueller sschueller requested a review from RadxaYuntian as a code owner July 5, 2025 13:09
@sschueller sschueller requested a review from RadxaYuntian July 9, 2025 17:20
@sschueller sschueller requested a review from RadxaYuntian July 12, 2025 19:03
Copy link
Member

@RadxaYuntian RadxaYuntian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please squash your commits.

@sschueller
Copy link
Author

LGTM. Please squash your commits.

Thanks, isn't that an option when merging?

@RadxaYuntian
Copy link
Member

Not when you enabled merge queue, which it will only use the preconfigured action.

Copy link
Member

@RadxaYuntian RadxaYuntian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI reports build error.

dc-gpios = <&gpio3 RK_PC1 GPIO_ACTIVE_HIGH>;
backlight-gpios = <&gpio3 RK_PB0 GPIO_ACTIVE_HIGH>;
debug = <0>;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants