Skip to contentSkip to conversation

staging: fbtft: fb_st7789v: support setting offset

PATCH Superseded purofle 2 participants 4 messages Apr 5, 2024 – Apr 9, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

purofle

author
#0 lore raw

PATCH 1/1 staging: fbtft: fb_st7789v: support setting offset

Some screen sizes using st7789v chips are different from 240x320, and offsets need to be set to display all images properly.

---
 drivers/staging/fbtft/fb_st7789v.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/staging/fbtft/fb_st7789v.c +22 -0
index 861a15414..d47ab4262 100644
@@ -30,6 +30,12 @@
 
 #define HSD20_IPS 1
 
+#define WIDTH 240
+#define HEIGHT 320
+
+#define LEFT_OFFSET 0
+#define TOP_OFFSET 0
+
 /**
  * enum st7789v_command - ST7789V display controller commands
  *
@@ -349,6 +355,21 @@ static int set_gamma(struct fbtft_par *par, u32 *curves)
 	return 0;
 }
 
+static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
+{
+	unsigned int x = xs + TOP_OFFSET, y = xe + TOP_OFFSET;
+
+	write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS, (x >> 8) & 0xFF, xs & 0xFF,
+		  (y >> 8) & 0xFF, xe & 0xFF);
+
+	x = ys + LEFT_OFFSET, y = ye + LEFT_OFFSET;
+
+	write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS, (x >> 8) & 0xFF, ys & 0xFF,
+		  (y >> 8) & 0xFF, ye & 0xFF);
+
+	write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
+}
+
 /**
  * blank() - blank the display
  *
@@ -379,6 +400,7 @@ static struct fbtft_display display = {
 		.set_var = set_var,
 		.set_gamma = set_gamma,
 		.blank = blank,
+		.set_addr_win = set_addr_win,
 	},
 };
 
Signature · 1 line
2.44.0
maintainer
#1 lore raw
Quoted 4 lines · purofle

Some screen sizes using st7789v chips are different from 240x320, and offsets need to be set to display all images properly.

We need a semi-real name here please.

Quoted 9 lines
---
 drivers/staging/fbtft/fb_st7789v.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
drivers/staging/fbtft/fb_st7789v.c +0 -0
index 861a15414..d47ab4262 100644

drivers/staging/fbtft/fb_st7789v.c line 34

Quoted 5 lines
drivers/staging/fbtft/fb_st7789v.c +2 -0
@@ -30,6 +30,12 @@
 
 #define HSD20_IPS 1
 
+#define WIDTH 240
+#define HEIGHT 320

So you are now hard-coding the size?

drivers/staging/fbtft/fb_st7789v.c line 37

Quoted 3 lines
drivers/staging/fbtft/fb_st7789v.c +3 -0
+
+#define LEFT_OFFSET 0
+#define TOP_OFFSET 0

Is this always going to be 0, if so, why need it at all?

thanks,

greg k-h

author
#2 lore raw
Quoted 1 line · Greg KH

So you are now hard-coding the size?

Yes, the change just helps developers who want to adapt to different screen sizes.

Quoted 1 line

Is this always going to be 0, if so, why need it at all?

Not sure. For example, when HEIGHT and WIDTH are 240 and 280, LEFT_OFFSET is 20 and TOP_OFFSET is 0. Different screens may have different offsets.

In addition, do I need to resend the patch to modify the Signed-off-by?

thanks,
purofle

maintainer
#3 lore raw
Quoted 4 lines · Yuguo Pei
Quoted 1 line · Greg KH

So you are now hard-coding the size?

Yes, the change just helps developers who want to adapt to different screen sizes.

So there is no change? I don't understand.

Quoted 3 lines
Quoted 1 line

Is this always going to be 0, if so, why need it at all?

Not sure. For example, when HEIGHT and WIDTH are 240 and 280, LEFT_OFFSET is 20 and TOP_OFFSET is 0. Different screens may have different offsets.

Then why is this needed?

Don't make changes that are not needed by anyone, especially for code in drivers/staging/

Quoted 2 lines

In addition, do I need to resend the patch to modify the Signed-off-by?

Of course you do :)