Re: [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.3 onwards.

2024-01-24 Thread Peter Humphrey
On Wednesday, 24 January 2024 10:00:37 GMT Alan Mackenzie wrote:

> I've adapted this patch for kernel 6.6.13.  All of the parent post still
> applies, with the exception of the version numbers.
> 
> The main patch for the new kernel is 6.6.13-GPM.20240123.diff.
> 
> Additionally I've attached a smaller patch which fixes what to me was a
> little glitch in the gpm utility.  This was that on a triple click to
> select a whole line (or sequence of lines), the (last) line got a
> linefeed appended to it.  The effect was that if you wanted to hoik a
> line out of some screen output and execute that from the bash command
> line, you couldn't edit it first.  So with this patch, you no longer get
> that annoying linefeed, and the highlighting is adjusted accordingly.
> This patch is (as far as I'm aware, without testing) independent of the
> main GPM patch.

Ever the star, Alan!

-- 
Regards,
Peter.






Re: [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.3 onwards.

2024-01-24 Thread Alan Mackenzie
Hello, Gentoo.

[ First an older post, but without quoting >s on the lines. ]

On Fri, Feb 03, 2023 at 18:56:27 +, Alan Mackenzie wrote:

The topic of this post is my kernel patch which enables soft scrolling
on Linux tty's with  and , and also enables
the GPM mouse utility on those scrolled regions.

Currently, the patch I posted some months ago works on all 6.1.x
kernels, and very likely works on 6.2.x, too.  In kernel 6.3.1, some
significant refactoring was done by the kernel people, necessitating a
new version of the patch, called 6.3.11-GPM.20231004.diff.  I've tested
this on 6.3.11 and 6.5.5.

Just a quick reminder of how to use these files for anybody else who
might be interested:
(i) cd /usr/src/linux-6.3.11-gentoo, or similar.  (Or ...-6.1.x-gentoo).
(ii) patch -p1 < 6.3.11-GPM.20231004.diff (or the other one).
(iii) Configure the kernel as normal.  Additionally, under Device
drivers/Graphic Support/Console display driver support, enable
CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK, set the buffer size to taste
(it's default is 128 kB) and accept the default enablement of
CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_GPM.
(iv) Build the kernel and install it into your boot manager.
(v) Reboot and enjoy!  You can now use GPM in scrolled consoles.

Just a warning: if you copy your kernel .config from a 6.1.x kernel, and
use make oldconfig to generate a new kernel for 6.3.x etc., you will
have to enable CONFIG_HID_SUPPORT, otherwise your USB keyboard and mouse
will be dead on bootup.  ;-(

The usual disclaimers apply, here.  If this patch breaks anything for
you, you get to join the pieces back together again.  But if this does
happen, please let me know, so that I can try to fix the bug.  My only
promise is that there's nothing malicious in the patch.

As well as 6.3.11-GPM.20231004.diff, I'm reposting
6.1.8-GPM.20230203.diff for anybody new here who wants to try it on the
current Gentoo 6.1.x kernel.

-- 
Alan Mackenzie (Nuremberg, Germany).

I've adapted this patch for kernel 6.6.13.  All of the parent post still
applies, with the exception of the version numbers.

The main patch for the new kernel is 6.6.13-GPM.20240123.diff.

Additionally I've attached a smaller patch which fixes what to me was a
little glitch in the gpm utility.  This was that on a triple click to
select a whole line (or sequence of lines), the (last) line got a
linefeed appended to it.  The effect was that if you wanted to hoik a
line out of some screen output and execute that from the bash command
line, you couldn't edit it first.  So with this patch, you no longer get
that annoying linefeed, and the highlighting is adjusted accordingly.
This patch is (as far as I'm aware, without testing) independent of the
main GPM patch.

If anybody still needs them, I've still got the patches for the 6.1
kernel, and the 6.3 and 6.5 kernels, and one or two earlier kernels too.

Have fun!

-- 
Alan Mackenzie (Nuremberg, Germany).

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 5c47f77804f0..3a901537d5b6 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -134,6 +134,11 @@ const struct consw *conswitchp;
 #define DEFAULT_BELL_DURATION  (HZ/8)
 #define DEFAULT_CURSOR_BLINK_MS200
 
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK
+static unsigned int console_soft_scrollback_size =
+   1024 * CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_SIZE;
+#endif
+
 struct vc vc_cons [MAX_NR_CONSOLES];
 EXPORT_SYMBOL(vc_cons);
 
@@ -289,8 +294,31 @@ static inline bool con_should_update(const struct vc_data 
*vc)
 static inline unsigned short *screenpos(const struct vc_data *vc, int offset,
bool viewed)
 {
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK
+   unsigned long softback_pos, scrolled_expanse;
+
+   if (vc->vc_softback_curr == vc->vc_origin) /* Should never happen! */
+   return (unsigned short *)(vc->vc_origin + offset);
+   else {
+   if (vc->vc_softback_in >= vc->vc_softback_curr)
+   scrolled_expanse = vc->vc_softback_in - 
vc->vc_softback_curr;
+   else
+   scrolled_expanse = vc->vc_softback_in - 
vc->vc_softback_curr
+   + vc->vc_softback_end - vc->vc_softback_buf;
+   if (offset >= scrolled_expanse)
+   return (unsigned short *)(vc->vc_origin
+ + (offset - 
scrolled_expanse));
+   else {
+   softback_pos = vc->vc_softback_curr + offset;
+   if (softback_pos >= vc->vc_softback_end)
+   softback_pos -= vc->vc_softback_end
+   - vc->vc_softback_buf;
+   }
+   }
+   return (unsigned short *)softback_pos;
+#else
unsigned short *p;
-   
+
if (!viewed)
p = (unsigned short *)(vc->vc_origin + offset);
else if 

Re: [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.3 onwards.

2023-10-04 Thread Jorge Almeida
On Wed, Oct 4, 2023 at 7:59 PM Alan Mackenzie  wrote:

>
> On Wed, Oct 04, 2023 at 18:08:20 +0100, Jorge Almeida wrote:
> >6.3.11-GPM.20231004.diff works fine with 6.5.5 (vanilla from
> >[1]kernel.org)
>
> Thanks for doing this testing.
>

Thank _you_ for making the patch :)


Re: [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.3 onwards.

2023-10-04 Thread Alan Mackenzie
Hello, Jorge.

On Wed, Oct 04, 2023 at 18:08:20 +0100, Jorge Almeida wrote:
>6.3.11-GPM.20231004.diff works fine with 6.5.5 (vanilla from
>[1]kernel.org)

Thanks for doing this testing.

> 
> References
> 
>1. http://kernel.org/

-- 
Alan Mackenzie (Nuremberg, Germany).



Re: [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.3 onwards.

2023-10-04 Thread Jorge Almeida
6.3.11-GPM.20231004.diff works fine with 6.5.5 (vanilla from kernel.org)

>
>


Re: [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.3 onwards.

2023-10-04 Thread Peter Humphrey
On Wednesday, 4 October 2023 14:16:44 BST Alan Mackenzie wrote:
> Hello, Gentoo.
> 
> On Fri, Feb 03, 2023 at 18:56:27 +, Alan Mackenzie wrote:
> 
> The topic of this post is my kernel patch which enables soft scrolling
> on Linux tty's with  and , and also enables
> the GPM mouse utility on those scrolled regions.
> 
> Currently, the patch I posted some months ago works on all 6.1.x
> kernels, and very likely works on 6.2.x, too.  In kernel 6.3.1, some
> significant refactoring was done by the kernel people, necessitating a
> new version of the patch, called 6.3.11-GPM.20231004.diff.  I've tested
> this on 6.3.11 and 6.5.5.
> 
> Just a quick reminder of how to use these files for anybody else who
> might be interested:
> (i) cd /usr/src/linux-6.3.11-gentoo, or similar.  (Or ...-6.1.x-gentoo).
> (ii) patch -p1 < 6.3.11-GPM.20231004.diff (or the other one).
> (iii) Configure the kernel as normal.  Additionally, under Device
> drivers/Graphic Support/Console display driver support, enable
> CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK, set the buffer size to 
taste
> (it's default is 128 kB) and accept the default enablement of
> CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_GPM.
> (iv) Build the kernel and install it into your boot manager.
> (v) Reboot and enjoy!  You can now use GPM in scrolled consoles.
> 
> Just a warning: if you copy your kernel .config from a 6.1.x kernel, and
> use make oldconfig to generate a new kernel for 6.3.x etc., you will
> have to enable CONFIG_HID_SUPPORT, otherwise your USB keyboard and 
mouse
> will be dead on bootup.  ;-(
> 
> The usual disclaimers apply, here.  If this patch breaks anything for
> you, you get to join the pieces back together again.  But if this does
> happen, please let me know, so that I can try to fix the bug.  My only
> promise is that there's nothing malicious in the patch.
> 
> As well as 6.3.11-GPM.20231004.diff, I'm reposting
> 6.1.8-GPM.20230203.diff for anybody new here who wants to try it on the
> current Gentoo 6.1.x kernel.

Many thanks again Alan. What a stalwart you are!

-- 
Regards,
Peter.






Re: [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.3 onwards.

2023-10-04 Thread Alan Mackenzie
Hello, Gentoo.

On Fri, Feb 03, 2023 at 18:56:27 +, Alan Mackenzie wrote:

The topic of this post is my kernel patch which enables soft scrolling
on Linux tty's with  and , and also enables
the GPM mouse utility on those scrolled regions.

Currently, the patch I posted some months ago works on all 6.1.x
kernels, and very likely works on 6.2.x, too.  In kernel 6.3.1, some
significant refactoring was done by the kernel people, necessitating a
new version of the patch, called 6.3.11-GPM.20231004.diff.  I've tested
this on 6.3.11 and 6.5.5.

Just a quick reminder of how to use these files for anybody else who
might be interested:
(i) cd /usr/src/linux-6.3.11-gentoo, or similar.  (Or ...-6.1.x-gentoo).
(ii) patch -p1 < 6.3.11-GPM.20231004.diff (or the other one).
(iii) Configure the kernel as normal.  Additionally, under Device
drivers/Graphic Support/Console display driver support, enable
CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK, set the buffer size to taste
(it's default is 128 kB) and accept the default enablement of
CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_GPM.
(iv) Build the kernel and install it into your boot manager.
(v) Reboot and enjoy!  You can now use GPM in scrolled consoles.

Just a warning: if you copy your kernel .config from a 6.1.x kernel, and
use make oldconfig to generate a new kernel for 6.3.x etc., you will
have to enable CONFIG_HID_SUPPORT, otherwise your USB keyboard and mouse
will be dead on bootup.  ;-(

The usual disclaimers apply, here.  If this patch breaks anything for
you, you get to join the pieces back together again.  But if this does
happen, please let me know, so that I can try to fix the bug.  My only
promise is that there's nothing malicious in the patch.

As well as 6.3.11-GPM.20231004.diff, I'm reposting
6.1.8-GPM.20230203.diff for anybody new here who wants to try it on the
current Gentoo 6.1.x kernel.

-- 
Alan Mackenzie (Nuremberg, Germany).

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 3c2ea9c098f7..51a3f0e7ffb5 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -134,6 +134,11 @@ const struct consw *conswitchp;
 #define DEFAULT_BELL_DURATION  (HZ/8)
 #define DEFAULT_CURSOR_BLINK_MS200
 
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK
+static unsigned int console_soft_scrollback_size =
+   1024 * CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_SIZE;
+#endif
+
 struct vc vc_cons [MAX_NR_CONSOLES];
 
 #ifndef VT_SINGLE_DRIVER
@@ -286,8 +291,31 @@ static inline bool con_should_update(const struct vc_data 
*vc)
 static inline unsigned short *screenpos(const struct vc_data *vc, int offset,
bool viewed)
 {
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK
+   unsigned long softback_pos, scrolled_expanse;
+
+   if (vc->vc_softback_curr == vc->vc_origin) /* Should never happen! */
+   return (unsigned short *)(vc->vc_origin + offset);
+   else {
+   if (vc->vc_softback_in >= vc->vc_softback_curr)
+   scrolled_expanse = vc->vc_softback_in - 
vc->vc_softback_curr;
+   else
+   scrolled_expanse = vc->vc_softback_in - 
vc->vc_softback_curr
+   + vc->vc_softback_end - vc->vc_softback_buf;
+   if (offset >= scrolled_expanse)
+   return (unsigned short *)(vc->vc_origin
+ + (offset - 
scrolled_expanse));
+   else {
+   softback_pos = vc->vc_softback_curr + offset;
+   if (softback_pos >= vc->vc_softback_end)
+   softback_pos -= vc->vc_softback_end
+   - vc->vc_softback_buf;
+   }
+   }
+   return (unsigned short *)softback_pos;
+#else
unsigned short *p;
-   
+
if (!viewed)
p = (unsigned short *)(vc->vc_origin + offset);
else if (!vc->vc_sw->con_screen_pos)
@@ -295,6 +323,7 @@ static inline unsigned short *screenpos(const struct 
vc_data *vc, int offset,
else
p = vc->vc_sw->con_screen_pos(vc, offset);
return p;
+#endif
 }
 
 /* Called  from the keyboard irq path.. */
@@ -316,107 +345,111 @@ void schedule_console_callback(void)
  * Code to manage unicode-based screen buffers
  */
 
-/*
- * Our screen buffer is preceded by an array of line pointers so that
- * scrolling only implies some pointer shuffling.
- */
+#define vc_uniscr_buf_end(vc) (vc->vc_uniscr_buf + vc->vc_uniscr_char_size)
 
-static u32 **vc_uniscr_alloc(unsigned int cols, unsigned int rows)
+static int vc_uniscr_alloc(struct vc_data *vc, unsigned int cols, unsigned int 
rows)
 {
-   u32 **uni_lines;
-   void *p;
-   unsigned int memsize, i, col_size = cols * sizeof(**uni_lines);
-
-   /* allocate everything in one go */
-   memsize = col_size * rows;
-   memsize += rows * sizeof(*uni_lines);
-   uni_lines = vzalloc(memsize);
-