summaryrefslogtreecommitdiff
path: root/drivers/tty
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-10-24 19:11:27 -1000
committerLinus Torvalds <torvalds@linux-foundation.org>2026-10-24 19:11:27 -1000
commit0dfc0090b925243490b5b71bc9a229517cda499a (patch)
tree5da880dd09d65579c35966af1b1191f79a8bb309 /drivers/tty
parent330517c63aa9b48227b6ab45f01003effac77ae4 (diff)
parent61e1a43ca5825acb137a10ac7d52746632bfb124 (diff)
Merge tag 'fbdev-for-7.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev
Pull fbdev updates from Helge Deller: "A whole lot of small fixes all over many drivers, but the majority of changes are related to code cleanups regarding the cursor handling in vt and fbcon. Fixes: - core: initialize modelist in framebuffer_alloc() - core: bitblit: fix glyph clipping when fbcon pans - fbcon: restore font geometry if font rotation fails - sh_mobile_lcdcfb: restore the per-overlay sysfs attributes - udlfb: don't rebuild the mode list while the framebuffer is in use - atmel_lcdfb: prevent FIFO work after removal Cleanups: - vt, fbcon, vgacon: cursor code rework & cleanups - MAINTAINERS: name the deller/linux-fbdev for-next branch - drop unused FB_IOMEM_HELPERS_DEFERRED Kconfig option - acornfb: remove unused code - atafb: fix sparse warnings and avoid casts - sstfb: use managed PCI device enable - gxt4500, kyro, nvidia: release write-combining handle on probe failure - various drivers: typo fixes in comments - various drivers: fix error path on fb_deferred_io_init() failure - various drivers: use FB blanking constants instead of VESA constants" * tag 'fbdev-for-7.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev: (53 commits) fbdev: xilinxfb: Use FB blanking constants fbdev: platinumfb: Use FB blanking constants fbdev: sa1100fb: Remove comment on VESA DPMS modes fbdev: i810fb: Use FB blanking constants fbdev: au1100fb: Use FB blanking constants fbcon: Retry rotated font allocation after failure fbcon: Rebuild rotated font buffer on font change fbcon: Include font geometry in the rotated font cache fbdev: bitblit: Fix glyph clipping when fbcon pans fbcon: Replace fbcon_fill_cursor_mask() with fbcon_cursor_glyph() lib/fonts: Add font_glyph_cursor() helper vgacon: Use vt_cursor_{start,end}() vgacon: Remove trailing whitespaces vt: Add cursor-size helpers MAINTAINERS: name the deller/linux-fbdev for-next branch fbdev: atafb: avoid cast when assigning buffer address pointer fbdev: atafb: fix sparse warnings fbdev: atyfb_base: fix typos in comments fbdev: aty128fb: fix typos in comments fbdev: mach64: fix typos in comments ...
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/vt/vt.c114
1 files changed, 114 insertions, 0 deletions
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 49a140b49eff..8415e274e4be 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -71,6 +71,7 @@
* by Adam Tla/lka <atlka@pg.gda.pl>, Aug 2006
*/
+#include <linux/compiler.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/sched/signal.h>
@@ -265,6 +266,119 @@ unsigned int vc_font_size(const struct vc_font *font)
EXPORT_SYMBOL_GPL(vc_font_size);
/*
+ * Cursors
+ */
+
+/**
+ * vc_cursor_valid_size - Computes a valid cursor size from the given value
+ * @cursor_size: The size constant of cursor pattern
+ *
+ * The argument given in @cursor_size is one of the CUR_ constants, as stored
+ * in struct @vc_data.vc_cursor_type. For unknown values, the helper draws the
+ * default cursor or an underline dash.
+ *
+ * Returns:
+ * A valid cursor size for the given size value
+ */
+unsigned int vc_cursor_valid_size(unsigned int cursor_size)
+{
+ const unsigned int cursor_default_size = CUR_SIZE(READ_ONCE(cur_default));
+
+ do {
+ switch (cursor_size) {
+ case CUR_NONE:
+ case CUR_UNDERLINE:
+ case CUR_LOWER_THIRD:
+ case CUR_LOWER_HALF:
+ case CUR_TWO_THIRDS:
+ case CUR_BLOCK:
+ return cursor_size;
+ default:
+ pr_warn_once("Unknown cursor %u\n", cursor_size);
+ fallthrough;
+ case CUR_DEF:
+ /*
+ * Use user-given default size, or underline if
+ * the given default is invalid.
+ */
+ if (cursor_size != cursor_default_size)
+ cursor_size = cursor_default_size;
+ else
+ cursor_size = CUR_UNDERLINE;
+ }
+ } while (true);
+}
+EXPORT_SYMBOL_GPL(vc_cursor_valid_size);
+
+/**
+ * vc_cursor_start - Calculates the cursor's first scanline within a character cell
+ * @cell_height: The overall height of the character cell
+ * @cursor_size: The size constant of cursor pattern
+ *
+ * The parameter @cell_height is the height of the character cell as
+ * displayed by the console. The argument given in @cursor_size is one
+ * of the CUR_ constants. See vc_cursor_valid_size() for how to get a
+ * valid cursor-size constant.
+ *
+ * Returns:
+ * The index of the cursor's first scanline within the character cell
+ */
+unsigned int vc_cursor_start(unsigned int cell_height, unsigned int cursor_size)
+{
+ switch (cursor_size) {
+ case CUR_NONE:
+ return cell_height;
+ case CUR_UNDERLINE:
+ default:
+ if (cell_height < 10)
+ return cell_height - 1;
+ else
+ return cell_height - 3;
+ case CUR_LOWER_THIRD:
+ return cell_height - cell_height / 3;
+ case CUR_LOWER_HALF:
+ return cell_height - cell_height / 2;
+ case CUR_TWO_THIRDS:
+ return cell_height - (cell_height * 2) / 3;
+ case CUR_BLOCK:
+ return 0;
+ }
+}
+EXPORT_SYMBOL_GPL(vc_cursor_start);
+
+/**
+ * vc_cursor_end - Calculates the first scanline after the cursor within a character cell
+ * @cell_height: The overall height of the character cell
+ * @cursor_size: The size constant of cursor pattern
+ *
+ * The parameter @cell_height is the height of the character cell as
+ * displayed by the console. The argument given in @cursor_size is one
+ * of the CUR_ constants. See vc_cursor_valid_size() for how to get a
+ * valid cursor-size constant.
+ *
+ * Returns:
+ * The index of the first scanline after the cursor within the character cell
+ */
+unsigned int vc_cursor_end(unsigned int cell_height, unsigned int cursor_size)
+{
+ switch (cursor_size) {
+ case CUR_UNDERLINE:
+ default:
+ if (cell_height < 10)
+ return cell_height;
+ else
+ return cell_height - 1;
+ case CUR_NONE:
+ case CUR_LOWER_THIRD:
+ case CUR_LOWER_HALF:
+ case CUR_TWO_THIRDS:
+ case CUR_BLOCK:
+ return cell_height;
+ }
+}
+EXPORT_SYMBOL_GPL(vc_cursor_end);
+
+/*
* /sys/class/tty/tty0/
*
* the attribute 'active' contains the name of the current vc