public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Peter Humphrey <peter@prh.myzen.co.uk>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.6 [was 6.3] onwards.
Date: Mon, 11 Mar 2024 10:47:43 +0000	[thread overview]
Message-ID: <2316312.ElGaqSPkdT@cube> (raw)
In-Reply-To: <ZbEAjZQLaHSerePp@ACM>

[-- Attachment #1: Type: text/plain, Size: 540 bytes --]

On Wednesday, 24 January 2024 12:20:29 GMT Alan Mackenzie wrote:
> Hello, Gentoo.
> 
> On Wed, Jan 24, 2024 at 10:00:37 +0000, Alan Mackenzie wrote:
> 
> [ .... ]
> 
> Please note the corrected subject line.  This version of the soft
> scrolling patch is for kernel 6.6.13, or thereabouts.

It works well here, Alan, up to kernel version 6.7.9, but one of the 15 or so 
new kernel parameters (since 6.7.8) seems to cause it to fail.

I've attached the reject file, /usr/src/linux-6.8.0-gentoo/drivers/tty/vt/
vt.c.rej.

-- 
Regards,
Peter.

[-- Attachment #2: vt.c.rej --]
[-- Type: text/x-reject, Size: 5293 bytes --]

--- drivers/tty/vt/vt.c
+++ drivers/tty/vt/vt.c
@@ -348,107 +377,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);
-	if (!uni_lines)
-		return NULL;
-
-	/* initial line pointers */
-	p = uni_lines + rows;
-	for (i = 0; i < rows; i++) {
-		uni_lines[i] = p;
-		p += col_size;
-	}
+	uint32_t *p;
+	unsigned int new_size;	/* In 32-bit characters */
 
-	return uni_lines;
-}
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_GPM
+	unsigned int num_scrollback_rows;
 
-static void vc_uniscr_free(u32 **uni_lines)
-{
-	vfree(uni_lines);
+	num_scrollback_rows = (console_soft_scrollback_size / 2) / cols;
+	new_size = cols * (num_scrollback_rows + rows + 1);
+#else
+	new_size = cols * (rows + 1); /* 1 row for the circular buffer admin */
+#endif
+	p = (uint32_t *)vzalloc (sizeof (uint32_t) * new_size);
+	if (!p)
+		return -ENOMEM;
+	vc->vc_uniscr_buf = p;
+	vc->vc_uniscr_curr = p;
+	vc->vc_uniscr_char_size = new_size;
+	memset32(p, ' ', new_size); /* Probably redundant. */
+	return 0;
 }
 
-static void vc_uniscr_set(struct vc_data *vc, u32 **new_uni_lines)
+static void vc_uniscr_free(struct vc_data *vc)
 {
-	vc_uniscr_free(vc->vc_uni_lines);
-	vc->vc_uni_lines = new_uni_lines;
+	kvfree(vc->vc_uniscr_buf);
+	vc->vc_uniscr_buf = NULL;
 }
 
 static void vc_uniscr_putc(struct vc_data *vc, u32 uc)
 {
-	if (vc->vc_uni_lines)
-		vc->vc_uni_lines[vc->state.y][vc->state.x] = uc;
+	uint32_t *pos;
+
+	if (vc->vc_uniscr_buf) {
+		pos = vc->vc_uniscr_curr;
+		UNISCR_PLUS(pos, vc->state.y * vc->vc_cols + vc->state.x);
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_GPM
+		UNISCR_MINUS(pos, vc->vc_cols * (vc->vc_softback_lines + vc->vc_top));
+#endif
+		*pos = uc;
+	}
 }
 
 static void vc_uniscr_insert(struct vc_data *vc, unsigned int nr)
 {
-	if (vc->vc_uni_lines) {
-		u32 *ln = vc->vc_uni_lines[vc->state.y];
-		unsigned int x = vc->state.x, cols = vc->vc_cols;
+	unsigned int x = vc->state.x, y = vc->state.y, cols = vc->vc_cols;
+	uint32_t *ln = vc->vc_uniscr_curr;
 
-		memmove(&ln[x + nr], &ln[x], (cols - x - nr) * sizeof(*ln));
+	if (vc->vc_uniscr_buf) {
+		UNISCR_PLUS(ln, y * cols);
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_GPM
+		UNISCR_MINUS(ln, vc->vc_cols * (vc->vc_softback_lines + vc->vc_top));
+#endif
+		memmove(&ln[x + nr], &ln[x], (cols - x - nr) * sizeof(uint32_t));
 		memset32(&ln[x], ' ', nr);
 	}
 }
 
 static void vc_uniscr_delete(struct vc_data *vc, unsigned int nr)
 {
-	if (vc->vc_uni_lines) {
-		u32 *ln = vc->vc_uni_lines[vc->state.y];
-		unsigned int x = vc->state.x, cols = vc->vc_cols;
+	unsigned int x = vc->state.x, y = vc->state.y, cols = vc->vc_cols;
+	uint32_t *ln = vc->vc_uniscr_curr;
 
-		memcpy(&ln[x], &ln[x + nr], (cols - x - nr) * sizeof(*ln));
+	if (vc->vc_uniscr_buf) {
+		UNISCR_PLUS(ln, y * cols);
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_GPM
+		UNISCR_MINUS(ln, vc->vc_cols * (vc->vc_softback_lines + vc->vc_top));
+#endif
+		memcpy(&ln[x], &ln[x + nr], (cols - x - nr) * sizeof(uint32_t));
 		memset32(&ln[cols - nr], ' ', nr);
 	}
 }
 
+/* FIXME!!!  We need to check that NR never goes beyond the current line end.  !!! */
 static void vc_uniscr_clear_line(struct vc_data *vc, unsigned int x,
 				 unsigned int nr)
 {
-	if (vc->vc_uni_lines)
-		memset32(&vc->vc_uni_lines[vc->state.y][x], ' ', nr);
+	if (vc->vc_uniscr_buf) {
+		uint32_t *ln = vc->vc_uniscr_curr;
+
+		UNISCR_PLUS(ln, vc->state.y * vc->vc_cols);
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_GPM
+		UNISCR_MINUS(ln, vc->vc_cols * (vc->vc_softback_lines + vc->vc_top));
+#endif
+		memset32(&ln[x], ' ', nr);
+	}
 }
 
 static void vc_uniscr_clear_lines(struct vc_data *vc, unsigned int y,
 				  unsigned int nr)
 {
-	if (vc->vc_uni_lines)
-		while (nr--)
-			memset32(vc->vc_uni_lines[y++], ' ', vc->vc_cols);
-}
-
-/* juggling array rotation algorithm (complexity O(N), size complexity O(1)) */
-static void juggle_array(u32 **array, unsigned int size, unsigned int nr)
-{
-	unsigned int gcd_idx;
-
-	for (gcd_idx = 0; gcd_idx < gcd(nr, size); gcd_idx++) {
-		u32 *gcd_idx_val = array[gcd_idx];
-		unsigned int dst_idx = gcd_idx;
+	if (vc->vc_uniscr_buf) {
+		unsigned int cols = vc->vc_cols;
+		uint32_t *ln = vc->vc_uniscr_curr;
 
-		while (1) {
-			unsigned int src_idx = (dst_idx + nr) % size;
-			if (src_idx == gcd_idx)
-				break;
-
-			array[dst_idx] = array[src_idx];
-			dst_idx = src_idx;
+		UNISCR_PLUS(ln, y * cols);
+#ifdef CONFIG_FRAMEBUFFER_CONSOLE_SOFT_SCROLLBACK_GPM
+		UNISCR_MINUS(ln, vc->vc_cols * (vc->vc_softback_lines + vc->vc_top));
+#endif
+		while (nr--) {
+			memset32(ln, ' ', cols);
+			UNISCR_PLUS(ln, cols);
 		}
-
-		array[dst_idx] = gcd_idx_val;
 	}
 }
 

  reply	other threads:[~2024-03-11 10:47 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07 19:46 [gentoo-user] Soft scrolling on framebuffer consoles - New versions of the patches Alan Mackenzie
2021-10-08  7:37 ` Peter Humphrey
2022-12-12 18:23 ` [gentoo-user] Soft scrolling on framebuffer consoles - New version of the patch Alan Mackenzie
2022-12-12 19:29   ` Mike Civil
2022-12-12 19:43     ` Alan Mackenzie
2022-12-13  3:44   ` Peter Humphrey
2022-12-14 10:53     ` Alan Mackenzie
2022-12-29 19:50       ` [gentoo-user] Soft scrolling on framebuffer consoles - New version of the patch - with GPM handling Alan Mackenzie
2022-12-31  9:42         ` Peter Humphrey
2022-12-31 14:08           ` Alan Mackenzie
2022-12-31 15:47             ` Peter Humphrey
2022-12-31 16:13               ` Alan Mackenzie
2022-12-31 21:49                 ` David Rosenbaum
2023-01-01 15:13                 ` Alan Mackenzie
2023-01-01 15:38                   ` Peter Humphrey
2023-01-26 20:28                   ` Alan Mackenzie
2023-01-27 12:24                     ` Peter Humphrey
2023-01-27 22:31                       ` Alan Mackenzie
2023-01-28 14:41                         ` Peter Humphrey
2023-02-03 18:56                           ` [gentoo-user] Soft scrolling on framebuffer consoles - New (?final) " Alan Mackenzie
2023-10-04 13:16                             ` [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.3 onwards Alan Mackenzie
2023-10-04 14:41                               ` Peter Humphrey
2023-10-04 17:08                               ` Jorge Almeida
2023-10-04 18:59                                 ` Alan Mackenzie
2023-10-04 19:02                                   ` Jorge Almeida
2024-01-24 10:00                             ` Alan Mackenzie
2024-01-24 12:20                               ` [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.6 [was 6.3] onwards Alan Mackenzie
2024-03-11 10:47                                 ` Peter Humphrey [this message]
2024-04-04  8:05                                   ` [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.8.1 onwards Alan Mackenzie
2024-01-24 14:08                               ` [gentoo-user] Soft scrolling on framebuffer consoles - with GPM handling - version of the patch for kernel 6.3 onwards Peter Humphrey
2023-09-09 15:21                           ` [gentoo-user] Soft scrolling on framebuffer consoles - New version of the patch - with GPM handling David Rosenbaum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2316312.ElGaqSPkdT@cube \
    --to=peter@prh.myzen.co.uk \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox