[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] tc6393xb: non-accelerated FB support
From: |
andrzej zaborowski |
Subject: |
Re: [Qemu-devel] [PATCH] tc6393xb: non-accelerated FB support |
Date: |
Sun, 2 Nov 2008 17:31:25 +0100 |
2008/11/2 Dmitry Baryshkov <address@hidden>:
> Signed-off-by: Dmitry Baryshkov <address@hidden>
> ---
> hw/devices.h | 2 +-
> hw/tc6393xb.c | 132
> +++++++++++++++++++++++++++++++++++++++++++++++-
> hw/tc6393xb_template.h | 52 +++++++++++++++++++
> hw/tosa.c | 4 +-
> 4 files changed, 187 insertions(+), 3 deletions(-)
> create mode 100644 hw/tc6393xb_template.h
>
> diff --git a/hw/devices.h b/hw/devices.h
> index 45fead9..e8fed68 100644
> --- a/hw/devices.h
> +++ b/hw/devices.h
> @@ -66,7 +66,7 @@ void tusb6010_power(struct tusb_s *s, int on);
>
> /* tc6393xb.c */
> struct tc6393xb_s;
> -struct tc6393xb_s *tc6393xb_init(uint32_t base, qemu_irq irq);
> +struct tc6393xb_s *tc6393xb_init(uint32_t base, qemu_irq irq, DisplayState
> *ds);
> void tc6393xb_gpio_out_set(struct tc6393xb_s *s, int line,
> qemu_irq handler);
> qemu_irq *tc6393xb_gpio_in_get(struct tc6393xb_s *s);
> diff --git a/hw/tc6393xb.c b/hw/tc6393xb.c
> index 919a922..e3897ff 100644
> --- a/hw/tc6393xb.c
> +++ b/hw/tc6393xb.c
> @@ -11,6 +11,8 @@
> #include "pxa.h"
> #include "devices.h"
> #include "flash.h"
> +#include "console.h"
> +#include "pixel_ops.h"
>
> #define IRQ_TC6393_NAND 0
> #define IRQ_TC6393_MMC 1
> @@ -119,6 +121,11 @@ struct tc6393xb_s {
> uint32_t nand_phys;
> struct nand_flash_s *flash;
> struct ecc_state_s ecc;
> +
> + DisplayState *ds;
> + QEMUConsole *console;
> + uint8_t *vram;
> + uint32_t scr_width, scr_height; /* in pixels */
> };
>
> qemu_irq *tc6393xb_gpio_in_get(struct tc6393xb_s *s)
> @@ -395,6 +402,111 @@ static void tc6393xb_nand_writeb(struct tc6393xb_s *s,
> target_phys_addr_t addr,
> (uint32_t) addr, value & 0xff);
> }
>
> +#define BITS 8
> +#define PIXEL_WIDTH 8
> +#include "tc6393xb_template.h"
> +#define BITS 15
> +#define PIXEL_WIDTH 16
> +#include "tc6393xb_template.h"
> +#define BITS 16
> +#define PIXEL_WIDTH 16
> +#include "tc6393xb_template.h"
> +#define BITS 24
> +#define PIXEL_WIDTH 32
> +#include "tc6393xb_template.h"
> +#define BITS 32
> +#define PIXEL_WIDTH 32
> +#include "tc6393xb_template.h"
> +
> +static void tc6393xb_draw_graphic(struct tc6393xb_s *s)
> +{
> + switch (s->ds->depth) {
> + case 8:
> + tc6393xb_draw_graphic8(s);
> + break;
> + case 15:
> + tc6393xb_draw_graphic15(s);
> + break;
> + case 16:
> + tc6393xb_draw_graphic16(s);
> + break;
> + case 24:
> + tc6393xb_draw_graphic24(s);
> + break;
> + case 32:
> + tc6393xb_draw_graphic32(s);
> + break;
> + default:
> + printf("tc6393xb: unknown depth %d\n", s->ds->depth);
> + return;
> + }
> +
> + dpy_update(s->ds, 0, 0, s->scr_width, s->scr_height);
> +}
> +
> +#if 0
> +static void tc6393xb_draw_blank(struct tc6393xb_s *s, int full_update)
> +{
> + int i, w;
> + uint8_t *d;
> +
> + if (!full_update)
> + return;
> +
> + w = s->scr_width * ((s->ds->depth + 7) >> 3);
> + d = s->ds->data;
> + for(i = 0; i < s->scr_height; i++) {
> + memset(d, 0, w);
> + d += s->ds->linesize;
> + }
> +
> + dpy_update(s->ds, 0, 0, s->scr_width, s->scr_height);
> +}
> +#endif
This assumes in 24bit mode a pixel occupies only 3 bytes (which iirc
is correct) and above PIXEL_WIDTH for 24 bits is set to 32.
> +
> +static void tc6393xb_update_display(void *opaque)
> +{
> + struct tc6393xb_s *s = opaque;
> +#if 0
> + int full_update, graphic_mode;
> +#endif
> +
> + if (s->scr_width == 0 || s->scr_height == 0)
> + return;
> +
> +#if 0
> + if (s->ctla & CTLA_FORCE_BLANK)
> + graphic_mode = GMODE_BLANK;
> + else
> + graphic_mode = GMODE_GRAPH;
> + full_update = 0;
> + if (graphic_mode != s->graphic_mode) {
> + s->graphic_mode = graphic_mode;
> + full_update = 1;
> + }
> +#endif
> + if (s->scr_width != s->ds->width || s->scr_height != s->ds->height) {
> + qemu_console_resize(s->console, s->scr_width, s->scr_height);
> +#if 0
> + full_update = 1;
> +#endif
> + }
> +#if 0
> + switch(graphic_mode) {
> + case GMODE_GRAPH:
> + tc6393xb_draw_graphic(s, full_update);
> + break;
> + case GMODE_BLANK:
> + default:
> + tc6393xb_draw_blank(s, full_update);
> + break;
> + }
> +#else
> + tc6393xb_draw_graphic(s);
> +#endif
> +}
Why's blank mode disabled?
> +
> +
> static uint32_t tc6393xb_readb(void *opaque, target_phys_addr_t addr) {
> struct tc6393xb_s *s = opaque;
> addr -= s->target_base;
> @@ -404,6 +516,8 @@ static uint32_t tc6393xb_readb(void *opaque,
> target_phys_addr_t addr) {
> return tc6393xb_scr_readb(s, addr & 0xff);
> case 1:
> return tc6393xb_nand_cfg_readb(s, addr & 0xff);
> + case 0x1000 ... 0x1fff:
> + return s->vram[addr - 0x100000];
> };
>
> if ((addr &~0xff) == s->nand_phys && s->nand_enable) {
> @@ -428,6 +542,9 @@ static void tc6393xb_writeb(void *opaque,
> target_phys_addr_t addr, uint32_t valu
> case 1:
> tc6393xb_nand_cfg_writeb(s, addr & 0xff, value);
> return;
> + case 0x1000 ... 0x1fff:
> + s->vram[addr - 0x100000] = value&0xff;
> + return;
> };
IIRC the page size is 0x400 on qemu-system-arm so you could register
this region as RAM, this sould give a speed-up. The indentation is
strange.
>
> if ((addr &~0xff) == s->nand_phys && s->nand_enable)
> @@ -465,7 +582,7 @@ static void tc6393xb_writel(void *opaque,
> target_phys_addr_t addr, uint32_t valu
> tc6393xb_writeb(opaque, addr + 3, value >> 24);
> }
>
> -struct tc6393xb_s *tc6393xb_init(uint32_t base, qemu_irq irq)
> +struct tc6393xb_s *tc6393xb_init(uint32_t base, qemu_irq irq, DisplayState
> *ds)
> {
> int iomemtype;
> struct tc6393xb_s *s;
> @@ -493,6 +610,19 @@ struct tc6393xb_s *tc6393xb_init(uint32_t base, qemu_irq
> irq)
> tc6393xb_writefn, s);
> cpu_register_physical_memory(s->target_base, 0x200000, iomemtype);
>
> + if (ds) {
> + s->ds = ds;
> + s->vram = qemu_mallocz(0x100000);
> + s->scr_width = 480;
> + s->scr_height = 640;
> + s->console = graphic_console_init(ds,
> + tc6393xb_update_display,
> + NULL, /* invalidate */
> + NULL, /* screen_dump */
> + NULL, /* text_update */
> + s);
> + }
> +
> return s;
> }
> /* vim:set shiftwidth=4 ts=4 et: */
> diff --git a/hw/tc6393xb_template.h b/hw/tc6393xb_template.h
> new file mode 100644
> index 0000000..1e0dcac
> --- /dev/null
> +++ b/hw/tc6393xb_template.h
> @@ -0,0 +1,52 @@
> +/*
> + * Toshiba TC6393XB I/O Controller.
> + * Found in Sharp Zaurus SL-6000 (tosa) or some
> + * Toshiba e-Series PDAs.
> + *
> + * FB support code. Based on G364 fb emulator
> + *
> + * Copyright (c) 2007 Hervé Poussineau
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +static void glue(tc6393xb_draw_graphic, BITS)(struct tc6393xb_s *s)
> +{
> + int i, j;
> + int w_display;
> + uint16_t *data_buffer;
> + uint8_t *data_display, *dd;
> +
> + data_buffer = (uint16_t*)s->vram;
> + w_display = s->scr_width * PIXEL_WIDTH / 8;
> + data_display = s->ds->data;
> + for(i = 0; i < s->scr_height; i++) {
> + dd = data_display;
> + for (j = 0; j < s->scr_width; j++, dd += PIXEL_WIDTH / 8,
> data_buffer++) {
> + uint16_t color = *data_buffer;
> + *((glue(glue(uint, PIXEL_WIDTH), _t) *)dd) = glue(rgb_to_pixel,
> BITS)(
> + ((color & 0xf800) * 0x108) >> 11,
> + ((color & 0x7e0) * 0x41) >> 9,
> + ((color & 0x1f) * 0x21) >> 2
> + );
This assumes power of two PIXEL_WIDTH (which is power-of-two but
possibly wrongly).
For the RGB565 host case you can possibly use memcpy.
Cheers
- [Qemu-devel] [PATCH] scoop: GPRR reports the state of GPIO lines, Dmitry Baryshkov, 2008/11/02
- [Qemu-devel] [PATCH] tc6393xb: initial support for nand, Dmitry Baryshkov, 2008/11/02
- [Qemu-devel] [PATCH] tosa: support leds, Dmitry Baryshkov, 2008/11/02
- [Qemu-devel] [PATCH] tosa: basic lcd support, Dmitry Baryshkov, 2008/11/02
- [Qemu-devel] [PATCH] tosa: provide correct IRQ to tc6393xb init, Dmitry Baryshkov, 2008/11/02
- [Qemu-devel] [PATCH] tosa: disable pxafb as it's not used on tosa., Dmitry Baryshkov, 2008/11/02
- [Qemu-devel] [PATCH] tc6393xb: non-accelerated FB support, Dmitry Baryshkov, 2008/11/02
- Re: [Qemu-devel] [PATCH] tc6393xb: non-accelerated FB support,
andrzej zaborowski <=
- Re: [Qemu-devel] [PATCH] tc6393xb: non-accelerated FB support, Dmitry Baryshkov, 2008/11/02
- Re: [Qemu-devel] [PATCH] tc6393xb: non-accelerated FB support, Dmitry Baryshkov, 2008/11/02
- Re: [Qemu-devel] [PATCH] tc6393xb: non-accelerated FB support, andrzej zaborowski, 2008/11/03
- Re: [Qemu-devel] [PATCH] tc6393xb: non-accelerated FB support, Dmitry, 2008/11/03
- Re: [Qemu-devel] [PATCH] tosa: basic lcd support, andrzej zaborowski, 2008/11/02
- Re: [Qemu-devel] [PATCH] tosa: basic lcd support, Dmitry Baryshkov, 2008/11/02
- Re: [Qemu-devel] [PATCH] tosa: basic lcd support, andrzej zaborowski, 2008/11/04
[Qemu-devel] Re: [PATCH] scoop: GPRR reports the state of GPIO lines, Dmitry Baryshkov, 2008/11/02