From 938a4489d34cc57ec0517cb243c3bdf7fa5a1f10 Mon Sep 17 00:00:00 2001 From: Xiaotian Wu Date: Tue, 26 Mar 2024 20:56:15 +0800 Subject: [PATCH 14/22] UniVT: Add several function for Univt. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 定义一些与Univt操作相关的函数。 Provide several essential functions for Univt. Signed-off-by: Shi Pujin --- drivers/tty/vt/vt.c | 7 +++++++ drivers/video/fbdev/core/bitblit.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 38f44e0f04ac..31317e0d3e61 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -300,6 +300,13 @@ static inline unsigned short *screenpos(const struct vc_data *vc, int offset, return p; } +static inline u16 *screenpos_utf8(const struct vc_data *vc, int offset, bool viewed) +{ + unsigned long origin = viewed ? vc->vc_visible_origin : vc->vc_origin; + + return (u16 *)(origin + offset + vc->vc_screenbuf_size); +} + /* Called from the keyboard irq path.. */ static inline void scrolldelta(int lines) { diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c index 8587c9da0670..583b864a31bc 100644 --- a/drivers/video/fbdev/core/bitblit.c +++ b/drivers/video/fbdev/core/bitblit.c @@ -43,6 +43,20 @@ static void update_attr(u8 *dst, u8 *src, int attribute, } } +u16 utf8_pos(struct vc_data *vc, const unsigned short *utf8) +{ + unsigned long p = (long)utf8; + if (vc->vc_font.charcount <= 512) return 0; + if (p >= vc->vc_origin && p < vc->vc_scr_end) { + return scr_readw((unsigned short *)(p + vc->vc_screenbuf_size)); + } else { + u16 extra_c; + int c = *(int*)utf8; + extra_c = (c >> 16 ) & 0x0000ffff; + return extra_c; + } +} + static void bit_bmove(struct vc_data *vc, struct fb_info *info, int sy, int sx, int dy, int dx, int height, int width) { -- 2.34.3