1 From 086525bfbf807d8c2792b18d35127c791289d0b8 Mon Sep 17 00:00:00 2001
2 From: David Herrmann <dh.herrmann@googlemail.com>
3 Date: Sat, 16 Jun 2012 23:01:41 +0200
4 Subject: [PATCH 04/10] fblog: implement fblog_redraw()
6 This mostly copies the functionality from drivers/video/console/bitblit.c
7 so we can draw the console content on all available framebuffers.
9 All speed optimizations have been removed for simplicity. The original
10 code depends heavily on CONFIG_VT so we cannot share the codebase here.
12 Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
14 drivers/video/console/fblog.c | 126 +++++++++++++++++++++++++++++++++++++++++
15 1 file changed, 126 insertions(+)
17 diff --git a/drivers/video/console/fblog.c b/drivers/video/console/fblog.c
18 index 8038dcc..e790971 100644
19 --- a/drivers/video/console/fblog.c
20 +++ b/drivers/video/console/fblog.c
21 @@ -197,6 +197,131 @@ static void fblog_buf_write(struct fblog_buf *buf, const char *str, size_t len)
25 +static void fblog_redraw_aligned(struct fblog_fb *fb, const char *s, u32 cnt,
26 + u32 d_pitch, u32 s_pitch, u32 cellsize,
27 + struct fb_image *image, u8 *dst)
29 + struct fb_info *info = fb->info;
30 + const struct font_desc *font = fb->font;
31 + u32 idx = font->width >> 3;
35 + src = (void*)(font->data + (*s++ & 0xff) * cellsize);
36 + fb_pad_aligned_buffer(dst, d_pitch, src, idx, image->height);
40 + info->fbops->fb_imageblit(info, image);
43 +static void fblog_redraw_unaligned(struct fblog_fb *fb, const char *s, u32 cnt,
44 + u32 d_pitch, u32 s_pitch, u32 cellsize,
45 + struct fb_image *image, u8 *dst)
47 + struct fb_info *info = fb->info;
48 + const struct font_desc *font = fb->font;
49 + u32 shift_low = 0, mod = font->width % 8;
51 + u32 idx = font->width >> 3;
55 + src = (void*)(font->data + (*s++ & 0xff) * cellsize);
56 + fb_pad_unaligned_buffer(dst, d_pitch, src, idx,
57 + image->height, shift_high,
60 + dst += (shift_low >= 8) ? s_pitch : s_pitch - 1;
62 + shift_high = 8 - shift_low;
65 + info->fbops->fb_imageblit(info, image);
68 +static void fblog_redraw_line(struct fblog_fb *fb, size_t line,
69 + const char *str, size_t len)
71 + struct fb_info *info = fb->info;
72 + const struct font_desc *font = fb->font;
73 + struct fb_image image;
74 + u32 width = DIV_ROUND_UP(font->width, 8);
75 + u32 cellsize = width * font->height;
76 + u32 maxcnt = info->pixmap.size / cellsize;
77 + u32 scan_align = info->pixmap.scan_align - 1;
78 + u32 buf_align = info->pixmap.buf_align - 1;
79 + u32 mod = font->width % 8;
80 + u32 cnt, pitch, size;
86 + image.dy = line * font->height;
87 + image.height = font->height;
96 + image.width = font->width * cnt;
97 + pitch = DIV_ROUND_UP(image.width, 8) + scan_align;
98 + pitch &= ~scan_align;
99 + size = pitch * image.height + buf_align;
100 + size &= ~buf_align;
101 + dst = fb_get_buffer_offset(info, &info->pixmap, size);
105 + fblog_redraw_aligned(fb, str, cnt, pitch, width,
106 + cellsize, &image, dst);
108 + fblog_redraw_unaligned(fb, str, cnt, pitch, width,
109 + cellsize, &image, dst);
111 + image.dx += cnt * font->width;
117 +static void fblog_redraw_clear(struct fblog_fb *fb)
119 + struct fb_fillrect region;
120 + struct fb_info *info = fb->info;
125 + region.width = info->var.xres;
126 + region.height = info->var.yres;
127 + region.rop = ROP_COPY;
129 + info->fbops->fb_fillrect(info, ®ion);
132 +static void fblog_redraw(struct fblog_fb *fb)
136 + if (!fb || !fb->font || test_bit(FBLOG_KILLED, &fb->flags) ||
137 + test_bit(FBLOG_SUSPENDED, &fb->flags) ||
138 + test_bit(FBLOG_BLANKED, &fb->flags))
141 + fblog_redraw_clear(fb);
143 + for (i = 0; i < fb->buf.height; ++i) {
144 + len = strnlen(fb->buf.lines[i], fb->buf.width);
146 + fblog_redraw_line(fb, i, fb->buf.lines[i], len);
150 static struct fblog_fb *fblog_info2fb(struct fb_info *info)
152 if (!info || info->node < 0 || info->node >= FB_MAX ||
153 @@ -244,6 +369,7 @@ static void fblog_register(struct fb_info *info)
154 width = info->var.xres / fb->font->width;
155 height = info->var.yres / fb->font->height;
156 fblog_buf_resize(&fb->buf, width, height);