All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] pxa2xx_lcd: add proper rotation support
@ 2011-05-31 14:16 Vasily Khoruzhick
  2011-05-31 14:16 ` [Qemu-devel] [PATCH 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
  0 siblings, 1 reply; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-05-31 14:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Vasily Khoruzhick

Until now, pxa2xx_lcd only supported 90deg rotation, but
some machines (for example Zipit Z2) needs 270deg rotation.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 hw/framebuffer.c |    2 +
 hw/pxa2xx_lcd.c  |   80 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 input.c          |   34 +++++++++++++++++------
 qemu-options.hx  |    9 ++++++
 vl.c             |   10 ++++++-
 5 files changed, 117 insertions(+), 18 deletions(-)

diff --git a/hw/framebuffer.c b/hw/framebuffer.c
index 24cdf25..486f7e4 100644
--- a/hw/framebuffer.c
+++ b/hw/framebuffer.c
@@ -78,6 +78,8 @@ void framebuffer_update_display(
     dest = ds_get_data(ds);
     if (dest_col_pitch < 0)
         dest -= dest_col_pitch * (cols - 1);
+    if (dest_row_pitch < 0)
+	dest -= dest_row_pitch * (rows - 1);
     first = -1;
     addr = pd;
 
diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c
index e524802..a076778 100644
--- a/hw/pxa2xx_lcd.c
+++ b/hw/pxa2xx_lcd.c
@@ -665,7 +665,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
     }
 }
 
-static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
+static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s,
                 target_phys_addr_t addr, int *miny, int *maxy)
 {
     int src_width, dest_width;
@@ -692,7 +692,7 @@ static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
                                fn, s->dma_ch[0].palette, miny, maxy);
 }
 
-static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
+static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s,
                target_phys_addr_t addr, int *miny, int *maxy)
 {
     int src_width, dest_width;
@@ -720,6 +720,61 @@ static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
                                miny, maxy);
 }
 
+static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
+                target_phys_addr_t addr, int *miny, int *maxy)
+{
+    int src_width, dest_width;
+    drawfn fn = NULL;
+    if (s->dest_width)
+        fn = s->line_fn[s->transp][s->bpp];
+    if (!fn)
+        return;
+
+    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
+    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp)
+        src_width *= 3;
+    else if (s->bpp > pxa_lcdc_16bpp)
+        src_width *= 4;
+    else if (s->bpp > pxa_lcdc_8bpp)
+        src_width *= 2;
+
+    dest_width = s->xres * s->dest_width;
+    *miny = 0;
+    framebuffer_update_display(s->ds,
+                               addr, s->xres, s->yres,
+                               src_width, -dest_width, -s->dest_width,
+                               s->invalidated,
+                               fn, s->dma_ch[0].palette, miny, maxy);
+}
+
+static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s,
+               target_phys_addr_t addr, int *miny, int *maxy)
+{
+    int src_width, dest_width;
+    drawfn fn = NULL;
+    if (s->dest_width)
+        fn = s->line_fn[s->transp][s->bpp];
+    if (!fn)
+        return;
+
+    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
+    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp)
+        src_width *= 3;
+    else if (s->bpp > pxa_lcdc_16bpp)
+        src_width *= 4;
+    else if (s->bpp > pxa_lcdc_8bpp)
+        src_width *= 2;
+
+    dest_width = s->yres * s->dest_width;
+    *miny = 0;
+    framebuffer_update_display(s->ds,
+                               addr, s->xres, s->yres,
+                               src_width, -s->dest_width, dest_width,
+                               s->invalidated,
+                               fn, s->dma_ch[0].palette,
+                               miny, maxy);
+}
+
 static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
 {
     int width, height;
@@ -730,7 +785,7 @@ static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
     height = LCCR2_LPP(s->control[2]) + 1;
 
     if (width != s->xres || height != s->yres) {
-        if (s->orientation)
+        if (s->orientation == 90 || s->orientation == 270)
             qemu_console_resize(s->ds, height, width);
         else
             qemu_console_resize(s->ds, width, height);
@@ -797,7 +852,7 @@ static void pxa2xx_update_display(void *opaque)
     }
 
     if (miny >= 0) {
-        if (s->orientation)
+        if (s->orientation == 90 || s->orientation == 270)
             dpy_update(s->ds, miny, 0, maxy - miny, s->xres);
         else
             dpy_update(s->ds, 0, miny, s->xres, maxy - miny);
@@ -822,10 +877,19 @@ static void pxa2xx_lcdc_orientation(void *opaque, int angle)
 {
     PXA2xxLCDState *s = (PXA2xxLCDState *) opaque;
 
-    if (angle) {
-        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_vert;
-    } else {
-        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_horiz;
+    switch (angle) {
+        case 0:
+            s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot0;
+            break;
+        case 90:
+            s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot90;
+            break;
+        case 180:
+            s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot180;
+            break;
+        case 270:
+            s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot270;
+            break;
     }
 
     s->orientation = angle;
diff --git a/input.c b/input.c
index 5664d3a..511831d 100644
--- a/input.c
+++ b/input.c
@@ -148,7 +148,7 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
     QEMUPutMouseEntry *entry;
     QEMUPutMouseEvent *mouse_event;
     void *mouse_event_opaque;
-    int width;
+    int width, height;
 
     if (QTAILQ_EMPTY(&mouse_handlers)) {
         return;
@@ -160,15 +160,31 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
     mouse_event_opaque = entry->qemu_put_mouse_event_opaque;
 
     if (mouse_event) {
-        if (graphic_rotate) {
-            if (entry->qemu_put_mouse_event_absolute) {
-                width = 0x7fff;
-            } else {
-                width = graphic_width - 1;
-            }
-            mouse_event(mouse_event_opaque, width - dy, dx, dz, buttons_state);
+        if (entry->qemu_put_mouse_event_absolute) {
+            width = 0x7fff;
+            height = 0x7fff;
         } else {
-            mouse_event(mouse_event_opaque, dx, dy, dz, buttons_state);
+            width = graphic_width - 1;
+            height = graphic_height - 1;
+        }
+
+        switch (graphic_rotate) {
+            case 0:
+                mouse_event(mouse_event_opaque,
+                            dx, dy, dz, buttons_state);
+                break;
+            case 90:
+                mouse_event(mouse_event_opaque,
+                            width - dy, dx, dz, buttons_state);
+                break;
+            case 180:
+                mouse_event(mouse_event_opaque,
+                            width - dx, height - dy, dz, buttons_state);
+                break;
+            case 270:
+                mouse_event(mouse_event_opaque,
+                            dy, height - dx, dz, buttons_state);
+                break;
         }
     }
 }
diff --git a/qemu-options.hx b/qemu-options.hx
index 82e085a..46d8f25 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -771,6 +771,15 @@ STEXI
 Rotate graphical output 90 deg left (only PXA LCD).
 ETEXI
 
+DEF("rotate", HAS_ARG, QEMU_OPTION_rotate,
+    "-rotate <deg>   rotate graphical output some deg left (only PXA LCD)\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -rotate
+@findex -rotate
+Rotate graphical output some deg left (only PXA LCD).
+ETEXI
+
 DEF("vga", HAS_ARG, QEMU_OPTION_vga,
     "-vga [std|cirrus|vmware|qxl|xenfb|none]\n"
     "                select video card type\n", QEMU_ARCH_ALL)
diff --git a/vl.c b/vl.c
index b362871..274d8fd 100644
--- a/vl.c
+++ b/vl.c
@@ -2289,7 +2289,15 @@ int main(int argc, char **argv, char **envp)
 #endif
                 break;
             case QEMU_OPTION_portrait:
-                graphic_rotate = 1;
+                graphic_rotate = 90;
+                break;
+            case QEMU_OPTION_rotate:
+                graphic_rotate = atoi(optarg);
+                if (graphic_rotate != 0 && graphic_rotate != 90 &&
+                    graphic_rotate != 180 && graphic_rotate != 270) {
+                    fprintf(stderr, "qemu: only 90, 180, 270 deg rotation is available\n");
+                    exit(1);
+                }
                 break;
             case QEMU_OPTION_kernel:
                 kernel_filename = optarg;
-- 
1.7.5.rc3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH 2/2] Add support for Zipit Z2 machine
  2011-05-31 14:16 [Qemu-devel] [PATCH 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
@ 2011-05-31 14:16 ` Vasily Khoruzhick
  2011-05-31 23:35   ` Peter Maydell
  0 siblings, 1 reply; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-05-31 14:16 UTC (permalink / raw)
  To: qemu-devel; +Cc: Vasily Khoruzhick

Zipit Z2 is small PXA270 based handheld.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 Makefile.target |    1 +
 hw/z2.c         |  302 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 303 insertions(+), 0 deletions(-)
 create mode 100644 hw/z2.c

diff --git a/Makefile.target b/Makefile.target
index 602d50d..5750499 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -358,6 +358,7 @@ obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
+obj-arm-y += z2.o
 obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o
 obj-arm-y += framebuffer.o
 obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
diff --git a/hw/z2.c b/hw/z2.c
new file mode 100644
index 0000000..fc22d4a
--- /dev/null
+++ b/hw/z2.c
@@ -0,0 +1,302 @@
+/*
+ * PXA270-based Zipit Z2 device
+ *
+ * Copyright (c) 2011 by Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * Code is based on mainstone platform.
+ *
+ * This code is licensed under the GNU GPL v2.
+ */
+
+#include "hw.h"
+#include "pxa.h"
+#include "arm-misc.h"
+#include "devices.h"
+#include "i2c.h"
+#include "ssi.h"
+#include "boards.h"
+#include "sysemu.h"
+#include "flash.h"
+#include "blockdev.h"
+#include "console.h"
+#include "audio/audio.h"
+
+static struct keymap map[0x100] = {
+    [0 ... 0xff] = { -1, -1 },
+    [0x3b] = {0,0}, /* Option = F1 */
+    [0xc8] = {0,1}, /* Up */
+    [0xd0] = {0,2}, /* Down */
+    [0xcb] = {0,3}, /* Left */
+    [0xcd] = {0,4}, /* Right */
+    [0xcf] = {0,5}, /* End */
+    [0x0d] = {0,6}, /* KPPLUS */
+    [0xc7] = {1,0}, /* Home */
+    [0x10] = {1,1}, /* Q */
+    [0x17] = {1,2}, /* I */
+    [0x22] = {1,3}, /* G */
+    [0x2d] = {1,4}, /* X */
+    [0x1c] = {1,5}, /* Enter */
+    [0x0c] = {1,6}, /* KPMINUS */
+    [0xc9] = {2,0}, /* PageUp */
+    [0x11] = {2,1}, /* W */
+    [0x18] = {2,2}, /* O */
+    [0x23] = {2,3}, /* H */
+    [0x2e] = {2,4}, /* C */
+    [0x38] = {2,5}, /* LeftAlt */
+    [0xd1] = {3,0}, /* PageDown */
+    [0x12] = {3,1}, /* E */
+    [0x19] = {3,2}, /* P */
+    [0x24] = {3,3}, /* J */
+    [0x2f] = {3,4}, /* V */
+    [0x2a] = {3,5}, /* LeftShift */
+    [0x01] = {4,0}, /* Esc */
+    [0x13] = {4,1}, /* R */
+    [0x1e] = {4,2}, /* A */
+    [0x25] = {4,3}, /* K */
+    [0x30] = {4,4}, /* B */
+    [0x1d] = {4,5}, /* LeftCtrl */
+    [0x0f] = {5,0}, /* Tab */
+    [0x14] = {5,1}, /* T */
+    [0x1f] = {5,2}, /* S */
+    [0x26] = {5,3}, /* L */
+    [0x31] = {5,4}, /* N */
+    [0x39] = {5,5}, /* Space */
+    [0x3c] = {6,0}, /* Stop = F2 */
+    [0x15] = {6,1}, /* Y */
+    [0x20] = {6,2}, /* D */
+    [0x0e] = {6,3}, /* Backspace */
+    [0x32] = {6,4}, /* M */
+    [0x33] = {6,5}, /* Comma */
+    [0x3d] = {7,0}, /* Play = F3 */
+    [0x16] = {7,1}, /* U */
+    [0x21] = {7,2}, /* F */
+    [0x2c] = {7,3}, /* Z */
+    [0x27] = {7,4}, /* Semicolon */
+    [0x34] = {7,5}, /* Dot */
+};
+
+#define Z2_RAM_SIZE     0x02000000
+#define Z2_FLASH_BASE   0x00000000
+#define Z2_FLASH_SIZE   0x00800000
+
+static struct arm_boot_info z2_binfo = {
+    .loader_start   = PXA2XX_SDRAM_BASE,
+    .ram_size       = Z2_RAM_SIZE,
+};
+
+#define Z2_GPIO_SD_DETECT   96
+#define Z2_GPIO_AC_IN       0
+#define Z2_GPIO_KEY_ON      1
+#define Z2_GPIO_LCD_CS      88
+
+typedef struct {
+    SSISlave ssidev;
+    int enabled;
+    uint8_t buf[3];
+    int pos;
+} ZipitLCD;
+
+static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    if (z->enabled) {
+        z->buf[z->pos] = value & 0xff;
+        z->pos++;
+    }
+    if (z->pos == 3) {
+        switch (z->buf[0]) {
+            case 0x74:
+                printf("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
+                break;
+            case 0x76:
+                printf("%s: value: 0x%.4x\n", __func__, z->buf[1] << 8 | z->buf[2]);
+                break;
+            default:
+                printf("%s: unknown command!\n", __func__);
+                break;
+        }
+        z->pos = 0;
+    }
+    return 0;
+}
+
+static void z2_lcd_cs(void *opaque, int line, int level)
+{
+    ZipitLCD *z2_lcd = opaque;
+    z2_lcd->enabled = !level;
+}
+
+static int zipit_lcd_init(SSISlave *dev)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    z->enabled = 0;
+    z->pos = 0;
+
+    return 0;
+}
+
+static SSISlaveInfo zipit_lcd_info = {
+    .qdev.name = "zipit-lcd",
+    .qdev.size = sizeof(ZipitLCD),
+    .init = zipit_lcd_init,
+    .transfer = zipit_lcd_transfer
+};
+
+typedef struct {
+    i2c_slave i2c;
+    int len;
+    char buf[3];
+} AER915State;
+
+static int aer915_send(i2c_slave *i2c, uint8_t data)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    s->buf[s->len] = data;
+    if (s->len ++ > 2) {
+        printf("%s: message too long (%i bytes)\n", __FUNCTION__, s->len);
+        return 1;
+    }
+
+    if (s->len == 2) {
+        printf("%s: reg %d value 0x%02x\n", __func__,
+                s->buf[0], s->buf[1]);
+    }
+
+    return 0;
+}
+
+static void aer915_event(i2c_slave *i2c, enum i2c_event event)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    switch (event) {
+    case I2C_START_SEND:
+        s->len = 0;
+        break;
+    case I2C_START_RECV:
+        if (s->len != 1)
+            printf("%s: short message!?\n", __func__);
+        break;
+    case I2C_FINISH:
+        break;
+    default:
+        break;
+    }
+}
+
+static int aer915_recv(i2c_slave *slave)
+{
+    int retval = 0x00;
+    AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
+
+    /* Hardcoded value */
+    switch (s->buf[0])
+    {
+        case 0x02:
+            retval = 0xf0;
+            break;
+        default:
+            break;
+    }
+
+    return retval;
+}
+
+static int aer915_init(i2c_slave *i2c)
+{
+    /* Nothing to do.  */
+    return 0;
+}
+
+static I2CSlaveInfo aer915_info = {
+    .qdev.name = "aer915",
+    .qdev.size = sizeof(AER915State),
+    .init = aer915_init,
+    .event = aer915_event,
+    .recv = aer915_recv,
+    .send = aer915_send
+};
+
+static void z2_init(ram_addr_t ram_size,
+                const char *boot_device,
+                const char *kernel_filename, const char *kernel_cmdline,
+                const char *initrd_filename, const char *cpu_model)
+{
+    uint32_t sector_len = 0x10000;
+    PXA2xxState *cpu;
+    DriveInfo *dinfo;
+    int be;
+    void *z2_lcd;
+    i2c_bus *bus;
+    DeviceState *wm;
+
+    if (!cpu_model)
+        cpu_model = "pxa270-c5";
+
+    /* Setup CPU & memory */
+    cpu = pxa270_init(z2_binfo.ram_size, cpu_model);
+
+#ifdef TARGET_WORDS_BIGENDIAN
+    be = 1;
+#else
+    be = 0;
+#endif
+    dinfo = drive_get(IF_PFLASH, 0, 0);
+    if (!dinfo) {
+        fprintf(stderr, "Flash image must be given with the "
+                "'pflash' parameter\n");
+        exit(1);
+    }
+
+    if (!pflash_cfi01_register(Z2_FLASH_BASE,
+                               qemu_ram_alloc(NULL, "z2.flash0", Z2_FLASH_SIZE),
+                               dinfo->bdrv, sector_len,
+                               Z2_FLASH_SIZE / sector_len, 4, 0, 0, 0, 0,
+                               be)) {
+        fprintf(stderr, "qemu: Error registering flash memory.\n");
+        exit(1);
+    }
+
+    /* setup keypad */
+    pxa27x_register_keypad(cpu->kp, map, 0x100);
+
+    /* MMC/SD host */
+    pxa2xx_mmci_handlers(cpu->mmc,
+        NULL,
+        qdev_get_gpio_in(cpu->gpio, Z2_GPIO_SD_DETECT));
+
+    ssi_register_slave(&zipit_lcd_info);
+    i2c_register_slave(&aer915_info);
+    z2_lcd = ssi_create_slave(cpu->ssp[1], "zipit-lcd");
+    bus = pxa2xx_i2c_bus(cpu->i2c[0]);
+    i2c_create_slave(bus, "aer915", 0x55);
+    wm = i2c_create_slave(bus, "wm8750", 0x1b);
+    /* .. and to the sound interface.  */
+    cpu->i2s->opaque = wm;
+    cpu->i2s->codec_out = wm8750_dac_dat;
+    cpu->i2s->codec_in = wm8750_adc_dat;
+    wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
+
+    qdev_connect_gpio_out(cpu->gpio, Z2_GPIO_LCD_CS,
+        qemu_allocate_irqs(z2_lcd_cs, z2_lcd, 1)[0]);
+
+    if (kernel_filename) {
+        z2_binfo.kernel_filename = kernel_filename;
+        z2_binfo.kernel_cmdline = kernel_cmdline;
+        z2_binfo.initrd_filename = initrd_filename;
+        z2_binfo.board_id = 0x6dd;
+        arm_load_kernel(cpu->env, &z2_binfo);
+    }
+}
+
+static QEMUMachine z2_machine = {
+    .name = "z2",
+    .desc = "Zipit Z2 (PXA27x)",
+    .init = z2_init,
+};
+
+static void z2_machine_init(void)
+{
+    qemu_register_machine(&z2_machine);
+}
+
+machine_init(z2_machine_init);
-- 
1.7.5.rc3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] Add support for Zipit Z2 machine
  2011-05-31 14:16 ` [Qemu-devel] [PATCH 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
@ 2011-05-31 23:35   ` Peter Maydell
  2011-06-01  6:25     ` Vasily Khoruzhick
  2011-06-01  9:28     ` [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
  0 siblings, 2 replies; 26+ messages in thread
From: Peter Maydell @ 2011-05-31 23:35 UTC (permalink / raw)
  To: Vasily Khoruzhick; +Cc: qemu-devel

On 31 May 2011 15:16, Vasily Khoruzhick <anarsoul@gmail.com> wrote:

> +static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value)
> +{
> +    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
> +    if (z->enabled) {
> +        z->buf[z->pos] = value & 0xff;
> +        z->pos++;
> +    }
> +    if (z->pos == 3) {
> +        switch (z->buf[0]) {
> +            case 0x74:
> +                printf("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
> +                break;
> +            case 0x76:
> +                printf("%s: value: 0x%.4x\n", __func__, z->buf[1] << 8 | z->buf[2]);
> +                break;
> +            default:
> +                printf("%s: unknown command!\n", __func__);
> +                break;
> +        }
> +        z->pos = 0;
> +    }
> +    return 0;
> +}

Presumably this is a stub for later functionality?
I don't think we should be printing the debug tracing by default.

> +static SSISlaveInfo zipit_lcd_info = {
> +    .qdev.name = "zipit-lcd",
> +    .qdev.size = sizeof(ZipitLCD),
> +    .init = zipit_lcd_init,
> +    .transfer = zipit_lcd_transfer
> +};

Not that the device does much, but it ought to have a
VMStateDescription structure to save/load its state.

> +    case I2C_START_RECV:
> +        if (s->len != 1)
> +            printf("%s: short message!?\n", __func__);

QEMU coding style demands braces here. Running through
scripts/checkpatch.pl should catch this kind of thing.

> +static int aer915_recv(i2c_slave *slave)
> +{
> +    int retval = 0x00;
> +    AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
> +
> +    /* Hardcoded value */

This comment isn't telling us anything we can't see from
the code. More interesting would be what the hardcoded
value actually means...

> +static I2CSlaveInfo aer915_info = {
> +    .qdev.name = "aer915",
> +    .qdev.size = sizeof(AER915State),
> +    .init = aer915_init,
> +    .event = aer915_event,
> +    .recv = aer915_recv,
> +    .send = aer915_send
> +};

Missing save/load support again.

> +    bus = pxa2xx_i2c_bus(cpu->i2c[0]);
> +    i2c_create_slave(bus, "aer915", 0x55);
> +    wm = i2c_create_slave(bus, "wm8750", 0x1b);
> +    /* .. and to the sound interface.  */

This comment has come from spitz.c, and it doesn't make
much sense here since you've not copied the preceding
comment which it is a continuation of:
    /* Attach a WM8750 to the bus */


-- PMM

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH 2/2] Add support for Zipit Z2 machine
  2011-05-31 23:35   ` Peter Maydell
@ 2011-06-01  6:25     ` Vasily Khoruzhick
  2011-06-01  9:28     ` [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
  1 sibling, 0 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-01  6:25 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Wednesday 01 June 2011 02:35:05 Peter Maydell wrote:
> On 31 May 2011 15:16, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> > +static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value)
> > +{
> > +    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
> > +    if (z->enabled) {
> > +        z->buf[z->pos] = value & 0xff;
> > +        z->pos++;
> > +    }
> > +    if (z->pos == 3) {
> > +        switch (z->buf[0]) {
> > +            case 0x74:
> > +                printf("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
> > +                break;
> > +            case 0x76:
> > +                printf("%s: value: 0x%.4x\n", __func__, z->buf[1] << 8 |
> > z->buf[2]); +                break;
> > +            default:
> > +                printf("%s: unknown command!\n", __func__);
> > +                break;
> > +        }
> > +        z->pos = 0;
> > +    }
> > +    return 0;
> > +}
> 
> Presumably this is a stub for later functionality?
> I don't think we should be printing the debug tracing by default.

Ok, will fix it

> > +static SSISlaveInfo zipit_lcd_info = {
> > +    .qdev.name = "zipit-lcd",
> > +    .qdev.size = sizeof(ZipitLCD),
> > +    .init = zipit_lcd_init,
> > +    .transfer = zipit_lcd_transfer
> > +};
> 
> Not that the device does much, but it ought to have a
> VMStateDescription structure to save/load its state.

Ok

> > +    case I2C_START_RECV:
> > +        if (s->len != 1)
> > +            printf("%s: short message!?\n", __func__);
> 
> QEMU coding style demands braces here. Running through
> scripts/checkpatch.pl should catch this kind of thing.

Ok

> > +static int aer915_recv(i2c_slave *slave)
> > +{
> > +    int retval = 0x00;
> > +    AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
> > +
> > +    /* Hardcoded value */
> 
> This comment isn't telling us anything we can't see from
> the code. More interesting would be what the hardcoded
> value actually means...

Ok

> > +static I2CSlaveInfo aer915_info = {
> > +    .qdev.name = "aer915",
> > +    .qdev.size = sizeof(AER915State),
> > +    .init = aer915_init,
> > +    .event = aer915_event,
> > +    .recv = aer915_recv,
> > +    .send = aer915_send
> > +};
> 
> Missing save/load support again.

This device is stateless, it only reports battery voltage (which is 
hardcoded), so nothing to save/load here.

> > +    bus = pxa2xx_i2c_bus(cpu->i2c[0]);
> > +    i2c_create_slave(bus, "aer915", 0x55);
> > +    wm = i2c_create_slave(bus, "wm8750", 0x1b);
> > +    /* .. and to the sound interface.  */
> 
> This comment has come from spitz.c, and it doesn't make
> much sense here since you've not copied the preceding
> comment which it is a continuation of:
>     /* Attach a WM8750 to the bus */

Ok, will remove it.

Thanks for review :)

Regards
Vasily

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support
  2011-05-31 23:35   ` Peter Maydell
  2011-06-01  6:25     ` Vasily Khoruzhick
@ 2011-06-01  9:28     ` Vasily Khoruzhick
  2011-06-01  9:28       ` [Qemu-devel] [PATCH v2 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
                         ` (2 more replies)
  1 sibling, 3 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-01  9:28 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Vasily Khoruzhick

Until now, pxa2xx_lcd only supported 90deg rotation, but
some machines (for example Zipit Z2) needs 270deg rotation.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
v2: codestyle fixes

 hw/framebuffer.c |    2 +
 hw/pxa2xx_lcd.c  |   86 +++++++++++++++++++++++++++++++++++++++++++++++------
 input.c          |   34 +++++++++++++++-----
 qemu-options.hx  |    9 +++++
 vl.c             |   11 ++++++-
 5 files changed, 122 insertions(+), 20 deletions(-)

diff --git a/hw/framebuffer.c b/hw/framebuffer.c
index 24cdf25..5e9ab5e 100644
--- a/hw/framebuffer.c
+++ b/hw/framebuffer.c
@@ -78,6 +78,8 @@ void framebuffer_update_display(
     dest = ds_get_data(ds);
     if (dest_col_pitch < 0)
         dest -= dest_col_pitch * (cols - 1);
+    if (dest_row_pitch < 0)
+        dest -= dest_row_pitch * (rows - 1);
     first = -1;
     addr = pd;
 
diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c
index e524802..a560bb0 100644
--- a/hw/pxa2xx_lcd.c
+++ b/hw/pxa2xx_lcd.c
@@ -665,7 +665,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
     }
 }
 
-static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
+static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s,
                 target_phys_addr_t addr, int *miny, int *maxy)
 {
     int src_width, dest_width;
@@ -692,7 +692,7 @@ static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
                                fn, s->dma_ch[0].palette, miny, maxy);
 }
 
-static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
+static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s,
                target_phys_addr_t addr, int *miny, int *maxy)
 {
     int src_width, dest_width;
@@ -720,6 +720,61 @@ static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
                                miny, maxy);
 }
 
+static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
+                target_phys_addr_t addr, int *miny, int *maxy)
+{
+    int src_width, dest_width;
+    drawfn fn = NULL;
+    if (s->dest_width)
+        fn = s->line_fn[s->transp][s->bpp];
+    if (!fn)
+        return;
+
+    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
+    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp)
+        src_width *= 3;
+    else if (s->bpp > pxa_lcdc_16bpp)
+        src_width *= 4;
+    else if (s->bpp > pxa_lcdc_8bpp)
+        src_width *= 2;
+
+    dest_width = s->xres * s->dest_width;
+    *miny = 0;
+    framebuffer_update_display(s->ds,
+                               addr, s->xres, s->yres,
+                               src_width, -dest_width, -s->dest_width,
+                               s->invalidated,
+                               fn, s->dma_ch[0].palette, miny, maxy);
+}
+
+static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s,
+               target_phys_addr_t addr, int *miny, int *maxy)
+{
+    int src_width, dest_width;
+    drawfn fn = NULL;
+    if (s->dest_width)
+        fn = s->line_fn[s->transp][s->bpp];
+    if (!fn)
+        return;
+
+    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
+    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp)
+        src_width *= 3;
+    else if (s->bpp > pxa_lcdc_16bpp)
+        src_width *= 4;
+    else if (s->bpp > pxa_lcdc_8bpp)
+        src_width *= 2;
+
+    dest_width = s->yres * s->dest_width;
+    *miny = 0;
+    framebuffer_update_display(s->ds,
+                               addr, s->xres, s->yres,
+                               src_width, -s->dest_width, dest_width,
+                               s->invalidated,
+                               fn, s->dma_ch[0].palette,
+                               miny, maxy);
+}
+
 static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
 {
     int width, height;
@@ -730,10 +785,11 @@ static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
     height = LCCR2_LPP(s->control[2]) + 1;
 
     if (width != s->xres || height != s->yres) {
-        if (s->orientation)
+        if (s->orientation == 90 || s->orientation == 270) {
             qemu_console_resize(s->ds, height, width);
-        else
+        } else {
             qemu_console_resize(s->ds, width, height);
+        }
         s->invalidated = 1;
         s->xres = width;
         s->yres = height;
@@ -797,10 +853,11 @@ static void pxa2xx_update_display(void *opaque)
     }
 
     if (miny >= 0) {
-        if (s->orientation)
+        if (s->orientation == 90 || s->orientation == 270) {
             dpy_update(s->ds, miny, 0, maxy - miny, s->xres);
-        else
+        } else {
             dpy_update(s->ds, 0, miny, s->xres, maxy - miny);
+        }
     }
     pxa2xx_lcdc_int_update(s);
 
@@ -822,10 +879,19 @@ static void pxa2xx_lcdc_orientation(void *opaque, int angle)
 {
     PXA2xxLCDState *s = (PXA2xxLCDState *) opaque;
 
-    if (angle) {
-        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_vert;
-    } else {
-        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_horiz;
+    switch (angle) {
+    case 0:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot0;
+        break;
+    case 90:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot90;
+        break;
+    case 180:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot180;
+        break;
+    case 270:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot270;
+        break;
     }
 
     s->orientation = angle;
diff --git a/input.c b/input.c
index 5664d3a..f0a02e7 100644
--- a/input.c
+++ b/input.c
@@ -148,7 +148,7 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
     QEMUPutMouseEntry *entry;
     QEMUPutMouseEvent *mouse_event;
     void *mouse_event_opaque;
-    int width;
+    int width, height;
 
     if (QTAILQ_EMPTY(&mouse_handlers)) {
         return;
@@ -160,15 +160,31 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
     mouse_event_opaque = entry->qemu_put_mouse_event_opaque;
 
     if (mouse_event) {
-        if (graphic_rotate) {
-            if (entry->qemu_put_mouse_event_absolute) {
-                width = 0x7fff;
-            } else {
-                width = graphic_width - 1;
-            }
-            mouse_event(mouse_event_opaque, width - dy, dx, dz, buttons_state);
+        if (entry->qemu_put_mouse_event_absolute) {
+            width = 0x7fff;
+            height = 0x7fff;
         } else {
-            mouse_event(mouse_event_opaque, dx, dy, dz, buttons_state);
+            width = graphic_width - 1;
+            height = graphic_height - 1;
+        }
+
+        switch (graphic_rotate) {
+        case 0:
+            mouse_event(mouse_event_opaque,
+                        dx, dy, dz, buttons_state);
+            break;
+        case 90:
+            mouse_event(mouse_event_opaque,
+                        width - dy, dx, dz, buttons_state);
+            break;
+        case 180:
+            mouse_event(mouse_event_opaque,
+                        width - dx, height - dy, dz, buttons_state);
+            break;
+        case 270:
+            mouse_event(mouse_event_opaque,
+                        dy, height - dx, dz, buttons_state);
+            break;
         }
     }
 }
diff --git a/qemu-options.hx b/qemu-options.hx
index 82e085a..46d8f25 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -771,6 +771,15 @@ STEXI
 Rotate graphical output 90 deg left (only PXA LCD).
 ETEXI
 
+DEF("rotate", HAS_ARG, QEMU_OPTION_rotate,
+    "-rotate <deg>   rotate graphical output some deg left (only PXA LCD)\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -rotate
+@findex -rotate
+Rotate graphical output some deg left (only PXA LCD).
+ETEXI
+
 DEF("vga", HAS_ARG, QEMU_OPTION_vga,
     "-vga [std|cirrus|vmware|qxl|xenfb|none]\n"
     "                select video card type\n", QEMU_ARCH_ALL)
diff --git a/vl.c b/vl.c
index b362871..5074bfe 100644
--- a/vl.c
+++ b/vl.c
@@ -2289,7 +2289,16 @@ int main(int argc, char **argv, char **envp)
 #endif
                 break;
             case QEMU_OPTION_portrait:
-                graphic_rotate = 1;
+                graphic_rotate = 90;
+                break;
+            case QEMU_OPTION_rotate:
+                graphic_rotate = atoi(optarg);
+                if (graphic_rotate != 0 && graphic_rotate != 90 &&
+                    graphic_rotate != 180 && graphic_rotate != 270) {
+                    fprintf(stderr,
+                        "qemu: only 90, 180, 270 deg rotation is available\n");
+                    exit(1);
+                }
                 break;
             case QEMU_OPTION_kernel:
                 kernel_filename = optarg;
-- 
1.7.5.rc3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] Add support for Zipit Z2 machine
  2011-06-01  9:28     ` [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
@ 2011-06-01  9:28       ` Vasily Khoruzhick
  2011-06-03 15:33       ` [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
  2011-06-03 15:36       ` [Qemu-devel] [PATCH v3 " Vasily Khoruzhick
  2 siblings, 0 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-01  9:28 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Vasily Khoruzhick

Zipit Z2 is small PXA270 based handheld.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
v2: codestyle fixes, added VMStateDescription for LCD device and AER915,
    traces clean up.

 Makefile.target |    1 +
 hw/z2.c         |  352 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 353 insertions(+), 0 deletions(-)
 create mode 100644 hw/z2.c

diff --git a/Makefile.target b/Makefile.target
index 602d50d..5750499 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -358,6 +358,7 @@ obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
+obj-arm-y += z2.o
 obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o
 obj-arm-y += framebuffer.o
 obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
diff --git a/hw/z2.c b/hw/z2.c
new file mode 100644
index 0000000..3e3591a
--- /dev/null
+++ b/hw/z2.c
@@ -0,0 +1,352 @@
+/*
+ * PXA270-based Zipit Z2 device
+ *
+ * Copyright (c) 2011 by Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * Code is based on mainstone platform.
+ *
+ * This code is licensed under the GNU GPL v2.
+ */
+
+#include "hw.h"
+#include "pxa.h"
+#include "arm-misc.h"
+#include "devices.h"
+#include "i2c.h"
+#include "ssi.h"
+#include "boards.h"
+#include "sysemu.h"
+#include "flash.h"
+#include "blockdev.h"
+#include "console.h"
+#include "audio/audio.h"
+
+#if 0
+#define DPRINTF(fmt, ...) \
+        printf(fmt, ## __VA_ARGS__)
+#else
+#define DPRINTF(fmt, ...)
+#endif
+
+static struct keymap map[0x100] = {
+    [0 ... 0xff] = { -1, -1 },
+    [0x3b] = {0, 0}, /* Option = F1 */
+    [0xc8] = {0, 1}, /* Up */
+    [0xd0] = {0, 2}, /* Down */
+    [0xcb] = {0, 3}, /* Left */
+    [0xcd] = {0, 4}, /* Right */
+    [0xcf] = {0, 5}, /* End */
+    [0x0d] = {0, 6}, /* KPPLUS */
+    [0xc7] = {1, 0}, /* Home */
+    [0x10] = {1, 1}, /* Q */
+    [0x17] = {1, 2}, /* I */
+    [0x22] = {1, 3}, /* G */
+    [0x2d] = {1, 4}, /* X */
+    [0x1c] = {1, 5}, /* Enter */
+    [0x0c] = {1, 6}, /* KPMINUS */
+    [0xc9] = {2, 0}, /* PageUp */
+    [0x11] = {2, 1}, /* W */
+    [0x18] = {2, 2}, /* O */
+    [0x23] = {2, 3}, /* H */
+    [0x2e] = {2, 4}, /* C */
+    [0x38] = {2, 5}, /* LeftAlt */
+    [0xd1] = {3, 0}, /* PageDown */
+    [0x12] = {3, 1}, /* E */
+    [0x19] = {3, 2}, /* P */
+    [0x24] = {3, 3}, /* J */
+    [0x2f] = {3, 4}, /* V */
+    [0x2a] = {3, 5}, /* LeftShift */
+    [0x01] = {4, 0}, /* Esc */
+    [0x13] = {4, 1}, /* R */
+    [0x1e] = {4, 2}, /* A */
+    [0x25] = {4, 3}, /* K */
+    [0x30] = {4, 4}, /* B */
+    [0x1d] = {4, 5}, /* LeftCtrl */
+    [0x0f] = {5, 0}, /* Tab */
+    [0x14] = {5, 1}, /* T */
+    [0x1f] = {5, 2}, /* S */
+    [0x26] = {5, 3}, /* L */
+    [0x31] = {5, 4}, /* N */
+    [0x39] = {5, 5}, /* Space */
+    [0x3c] = {6, 0}, /* Stop = F2 */
+    [0x15] = {6, 1}, /* Y */
+    [0x20] = {6, 2}, /* D */
+    [0x0e] = {6, 3}, /* Backspace */
+    [0x32] = {6, 4}, /* M */
+    [0x33] = {6, 5}, /* Comma */
+    [0x3d] = {7, 0}, /* Play = F3 */
+    [0x16] = {7, 1}, /* U */
+    [0x21] = {7, 2}, /* F */
+    [0x2c] = {7, 3}, /* Z */
+    [0x27] = {7, 4}, /* Semicolon */
+    [0x34] = {7, 5}, /* Dot */
+};
+
+#define Z2_RAM_SIZE     0x02000000
+#define Z2_FLASH_BASE   0x00000000
+#define Z2_FLASH_SIZE   0x00800000
+
+static struct arm_boot_info z2_binfo = {
+    .loader_start   = PXA2XX_SDRAM_BASE,
+    .ram_size       = Z2_RAM_SIZE,
+};
+
+#define Z2_GPIO_SD_DETECT   96
+#define Z2_GPIO_AC_IN       0
+#define Z2_GPIO_KEY_ON      1
+#define Z2_GPIO_LCD_CS      88
+
+typedef struct {
+    SSISlave ssidev;
+    int32_t selected;
+    int32_t enabled;
+    uint8_t buf[3];
+    uint32_t cur_reg;
+    int pos;
+} ZipitLCD;
+
+static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    uint16_t val;
+    if (z->selected) {
+        z->buf[z->pos] = value & 0xff;
+        z->pos++;
+    }
+    if (z->pos == 3) {
+        switch (z->buf[0]) {
+        case 0x74:
+            DPRINTF("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
+            z->cur_reg = z->buf[2];
+            break;
+        case 0x76:
+            val = z->buf[1] << 8 | z->buf[2];
+            DPRINTF("%s: value: 0x%.4x\n", __func__, val);
+            if (z->cur_reg == 0x22 && val == 0x0000) {
+                z->enabled = 1;
+                printf("%s: LCD enabled\n", __func__);
+            } else if (z->cur_reg == 0x10 && val == 0x0000) {
+                z->enabled = 0;
+                printf("%s: LCD disabled\n", __func__);
+            }
+            break;
+        default:
+            fprintf(stderr, "%s: unknown command!\n", __func__);
+            break;
+        }
+        z->pos = 0;
+    }
+    return 0;
+}
+
+static void z2_lcd_cs(void *opaque, int line, int level)
+{
+    ZipitLCD *z2_lcd = opaque;
+    z2_lcd->selected = !level;
+}
+
+static int zipit_lcd_init(SSISlave *dev)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    z->selected = 0;
+    z->enabled = 0;
+    z->pos = 0;
+
+    return 0;
+}
+
+static VMStateDescription vmstate_zipit_lcd_state = {
+    .name = "zipit-lcd",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(enabled, ZipitLCD),
+        VMSTATE_END_OF_LIST(),
+    }
+};
+
+static SSISlaveInfo zipit_lcd_info = {
+    .qdev.name = "zipit-lcd",
+    .qdev.size = sizeof(ZipitLCD),
+    .qdev.vmsd = &vmstate_zipit_lcd_state,
+    .init = zipit_lcd_init,
+    .transfer = zipit_lcd_transfer
+};
+
+typedef struct {
+    i2c_slave i2c;
+    int len;
+    char buf[3];
+} AER915State;
+
+static int aer915_send(i2c_slave *i2c, uint8_t data)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    s->buf[s->len] = data;
+    if (s->len++ > 2) {
+        fprintf(stderr, "%s: message too long (%i bytes)\n",
+            __func__, s->len);
+        return 1;
+    }
+
+    if (s->len == 2) {
+        DPRINTF("%s: reg %d value 0x%02x\n", __func__,
+                s->buf[0], s->buf[1]);
+    }
+
+    return 0;
+}
+
+static void aer915_event(i2c_slave *i2c, enum i2c_event event)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    switch (event) {
+    case I2C_START_SEND:
+        s->len = 0;
+        break;
+    case I2C_START_RECV:
+        if (s->len != 1) {
+            fprintf(stderr, "%s: short message!?\n", __func__);
+        }
+        break;
+    case I2C_FINISH:
+        break;
+    default:
+        break;
+    }
+}
+
+static int aer915_recv(i2c_slave *slave)
+{
+    int retval = 0x00;
+    AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
+
+    switch (s->buf[0]) {
+    /* Return hardcoded battery voltage,
+     * 0xf0 means ~4.1V
+     */
+    case 0x02:
+        retval = 0xf0;
+        break;
+    /* Return 0x00 for other regs,
+     * we don't know what they are for,
+     * anyway they return 0x00 on real hardware.
+     */
+    default:
+        break;
+    }
+
+    return retval;
+}
+
+static int aer915_init(i2c_slave *i2c)
+{
+    /* Nothing to do.  */
+    return 0;
+}
+
+static VMStateDescription vmstate_aer915_state = {
+    .name = "aer915",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_END_OF_LIST(),
+    }
+};
+
+static I2CSlaveInfo aer915_info = {
+    .qdev.name = "aer915",
+    .qdev.size = sizeof(AER915State),
+    .qdev.vmsd = &vmstate_aer915_state,
+    .init = aer915_init,
+    .event = aer915_event,
+    .recv = aer915_recv,
+    .send = aer915_send
+};
+
+static void z2_init(ram_addr_t ram_size,
+                const char *boot_device,
+                const char *kernel_filename, const char *kernel_cmdline,
+                const char *initrd_filename, const char *cpu_model)
+{
+    uint32_t sector_len = 0x10000;
+    PXA2xxState *cpu;
+    DriveInfo *dinfo;
+    int be;
+    void *z2_lcd;
+    i2c_bus *bus;
+    DeviceState *wm;
+
+    if (!cpu_model) {
+        cpu_model = "pxa270-c5";
+    }
+
+    /* Setup CPU & memory */
+    cpu = pxa270_init(z2_binfo.ram_size, cpu_model);
+
+#ifdef TARGET_WORDS_BIGENDIAN
+    be = 1;
+#else
+    be = 0;
+#endif
+    dinfo = drive_get(IF_PFLASH, 0, 0);
+    if (!dinfo) {
+        fprintf(stderr, "Flash image must be given with the "
+                "'pflash' parameter\n");
+        exit(1);
+    }
+
+    if (!pflash_cfi01_register(Z2_FLASH_BASE,
+                               qemu_ram_alloc(NULL, "z2.flash0", Z2_FLASH_SIZE),
+                               dinfo->bdrv, sector_len,
+                               Z2_FLASH_SIZE / sector_len, 4, 0, 0, 0, 0,
+                               be)) {
+        fprintf(stderr, "qemu: Error registering flash memory.\n");
+        exit(1);
+    }
+
+    /* setup keypad */
+    pxa27x_register_keypad(cpu->kp, map, 0x100);
+
+    /* MMC/SD host */
+    pxa2xx_mmci_handlers(cpu->mmc,
+        NULL,
+        qdev_get_gpio_in(cpu->gpio, Z2_GPIO_SD_DETECT));
+
+    ssi_register_slave(&zipit_lcd_info);
+    i2c_register_slave(&aer915_info);
+    z2_lcd = ssi_create_slave(cpu->ssp[1], "zipit-lcd");
+    bus = pxa2xx_i2c_bus(cpu->i2c[0]);
+    i2c_create_slave(bus, "aer915", 0x55);
+    wm = i2c_create_slave(bus, "wm8750", 0x1b);
+    cpu->i2s->opaque = wm;
+    cpu->i2s->codec_out = wm8750_dac_dat;
+    cpu->i2s->codec_in = wm8750_adc_dat;
+    wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
+
+    qdev_connect_gpio_out(cpu->gpio, Z2_GPIO_LCD_CS,
+        qemu_allocate_irqs(z2_lcd_cs, z2_lcd, 1)[0]);
+
+    if (kernel_filename) {
+        z2_binfo.kernel_filename = kernel_filename;
+        z2_binfo.kernel_cmdline = kernel_cmdline;
+        z2_binfo.initrd_filename = initrd_filename;
+        z2_binfo.board_id = 0x6dd;
+        arm_load_kernel(cpu->env, &z2_binfo);
+    }
+}
+
+static QEMUMachine z2_machine = {
+    .name = "z2",
+    .desc = "Zipit Z2 (PXA27x)",
+    .init = z2_init,
+};
+
+static void z2_machine_init(void)
+{
+    qemu_register_machine(&z2_machine);
+}
+
+machine_init(z2_machine_init);
-- 
1.7.5.rc3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support
  2011-06-01  9:28     ` [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
  2011-06-01  9:28       ` [Qemu-devel] [PATCH v2 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
@ 2011-06-03 15:33       ` Vasily Khoruzhick
  2011-06-03 15:36       ` [Qemu-devel] [PATCH v3 " Vasily Khoruzhick
  2 siblings, 0 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-03 15:33 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Wednesday 01 June 2011 12:28:06 Vasily Khoruzhick wrote:
> Until now, pxa2xx_lcd only supported 90deg rotation, but
> some machines (for example Zipit Z2) needs 270deg rotation.
> 
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
> v2: codestyle fixes
> 
>  hw/framebuffer.c |    2 +
>  hw/pxa2xx_lcd.c  |   86
> +++++++++++++++++++++++++++++++++++++++++++++++------ input.c          |  
> 34 +++++++++++++++-----
>  qemu-options.hx  |    9 +++++
>  vl.c             |   11 ++++++-
>  5 files changed, 122 insertions(+), 20 deletions(-)
> 
> diff --git a/hw/framebuffer.c b/hw/framebuffer.c
> index 24cdf25..5e9ab5e 100644
> --- a/hw/framebuffer.c
> +++ b/hw/framebuffer.c
> @@ -78,6 +78,8 @@ void framebuffer_update_display(
>      dest = ds_get_data(ds);
>      if (dest_col_pitch < 0)
>          dest -= dest_col_pitch * (cols - 1);
> +    if (dest_row_pitch < 0)
> +        dest -= dest_row_pitch * (rows - 1);
>      first = -1;
>      addr = pd;
> 
> diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c
> index e524802..a560bb0 100644
> --- a/hw/pxa2xx_lcd.c
> +++ b/hw/pxa2xx_lcd.c
> @@ -665,7 +665,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int
> ch, int bpp) }
>  }
> 
> -static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
> +static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s,
>                  target_phys_addr_t addr, int *miny, int *maxy)
>  {
>      int src_width, dest_width;
> @@ -692,7 +692,7 @@ static void
> pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s, fn, s->dma_ch[0].palette,
> miny, maxy); }
> 
> -static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
> +static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s,
>                 target_phys_addr_t addr, int *miny, int *maxy)
>  {
>      int src_width, dest_width;
> @@ -720,6 +720,61 @@ static void
> pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s, miny, maxy);
>  }
> 
> +static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
> +                target_phys_addr_t addr, int *miny, int *maxy)
> +{
> +    int src_width, dest_width;
> +    drawfn fn = NULL;
> +    if (s->dest_width)
> +        fn = s->line_fn[s->transp][s->bpp];
> +    if (!fn)
> +        return;
> +
> +    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
> +    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp)
> +        src_width *= 3;
> +    else if (s->bpp > pxa_lcdc_16bpp)
> +        src_width *= 4;
> +    else if (s->bpp > pxa_lcdc_8bpp)
> +        src_width *= 2;
> +
> +    dest_width = s->xres * s->dest_width;
> +    *miny = 0;
> +    framebuffer_update_display(s->ds,
> +                               addr, s->xres, s->yres,
> +                               src_width, -dest_width, -s->dest_width,
> +                               s->invalidated,
> +                               fn, s->dma_ch[0].palette, miny, maxy);
> +}
> +
> +static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s,
> +               target_phys_addr_t addr, int *miny, int *maxy)
> +{
> +    int src_width, dest_width;
> +    drawfn fn = NULL;
> +    if (s->dest_width)
> +        fn = s->line_fn[s->transp][s->bpp];
> +    if (!fn)
> +        return;
> +
> +    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
> +    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp)
> +        src_width *= 3;
> +    else if (s->bpp > pxa_lcdc_16bpp)
> +        src_width *= 4;
> +    else if (s->bpp > pxa_lcdc_8bpp)
> +        src_width *= 2;
> +
> +    dest_width = s->yres * s->dest_width;
> +    *miny = 0;
> +    framebuffer_update_display(s->ds,
> +                               addr, s->xres, s->yres,
> +                               src_width, -s->dest_width, dest_width,
> +                               s->invalidated,
> +                               fn, s->dma_ch[0].palette,
> +                               miny, maxy);
> +}
> +
>  static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
>  {
>      int width, height;
> @@ -730,10 +785,11 @@ static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
>      height = LCCR2_LPP(s->control[2]) + 1;
> 
>      if (width != s->xres || height != s->yres) {
> -        if (s->orientation)
> +        if (s->orientation == 90 || s->orientation == 270) {
>              qemu_console_resize(s->ds, height, width);
> -        else
> +        } else {
>              qemu_console_resize(s->ds, width, height);
> +        }
>          s->invalidated = 1;
>          s->xres = width;
>          s->yres = height;
> @@ -797,10 +853,11 @@ static void pxa2xx_update_display(void *opaque)
>      }
> 
>      if (miny >= 0) {
> -        if (s->orientation)
> +        if (s->orientation == 90 || s->orientation == 270) {
>              dpy_update(s->ds, miny, 0, maxy - miny, s->xres);
> -        else
> +        } else {
>              dpy_update(s->ds, 0, miny, s->xres, maxy - miny);
> +        }
>      }
>      pxa2xx_lcdc_int_update(s);
> 
> @@ -822,10 +879,19 @@ static void pxa2xx_lcdc_orientation(void *opaque, int
> angle) {
>      PXA2xxLCDState *s = (PXA2xxLCDState *) opaque;
> 
> -    if (angle) {
> -        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_vert;
> -    } else {
> -        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_horiz;
> +    switch (angle) {
> +    case 0:
> +        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot0;
> +        break;
> +    case 90:
> +        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot90;
> +        break;
> +    case 180:
> +        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot180;
> +        break;
> +    case 270:
> +        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot270;
> +        break;
>      }
> 
>      s->orientation = angle;
> diff --git a/input.c b/input.c
> index 5664d3a..f0a02e7 100644
> --- a/input.c
> +++ b/input.c
> @@ -148,7 +148,7 @@ void kbd_mouse_event(int dx, int dy, int dz, int
> buttons_state) QEMUPutMouseEntry *entry;
>      QEMUPutMouseEvent *mouse_event;
>      void *mouse_event_opaque;
> -    int width;
> +    int width, height;
> 
>      if (QTAILQ_EMPTY(&mouse_handlers)) {
>          return;
> @@ -160,15 +160,31 @@ void kbd_mouse_event(int dx, int dy, int dz, int
> buttons_state) mouse_event_opaque = entry->qemu_put_mouse_event_opaque;
> 
>      if (mouse_event) {
> -        if (graphic_rotate) {
> -            if (entry->qemu_put_mouse_event_absolute) {
> -                width = 0x7fff;
> -            } else {
> -                width = graphic_width - 1;
> -            }
> -            mouse_event(mouse_event_opaque, width - dy, dx, dz,
> buttons_state); +        if (entry->qemu_put_mouse_event_absolute) {
> +            width = 0x7fff;
> +            height = 0x7fff;
>          } else {
> -            mouse_event(mouse_event_opaque, dx, dy, dz, buttons_state);
> +            width = graphic_width - 1;
> +            height = graphic_height - 1;
> +        }
> +
> +        switch (graphic_rotate) {
> +        case 0:
> +            mouse_event(mouse_event_opaque,
> +                        dx, dy, dz, buttons_state);
> +            break;
> +        case 90:
> +            mouse_event(mouse_event_opaque,
> +                        width - dy, dx, dz, buttons_state);
> +            break;
> +        case 180:
> +            mouse_event(mouse_event_opaque,
> +                        width - dx, height - dy, dz, buttons_state);
> +            break;
> +        case 270:
> +            mouse_event(mouse_event_opaque,
> +                        dy, height - dx, dz, buttons_state);
> +            break;
>          }
>      }
>  }
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 82e085a..46d8f25 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -771,6 +771,15 @@ STEXI
>  Rotate graphical output 90 deg left (only PXA LCD).
>  ETEXI
> 
> +DEF("rotate", HAS_ARG, QEMU_OPTION_rotate,
> +    "-rotate <deg>   rotate graphical output some deg left (only PXA
> LCD)\n", +    QEMU_ARCH_ALL)
> +STEXI
> +@item -rotate
> +@findex -rotate
> +Rotate graphical output some deg left (only PXA LCD).
> +ETEXI
> +
>  DEF("vga", HAS_ARG, QEMU_OPTION_vga,
>      "-vga [std|cirrus|vmware|qxl|xenfb|none]\n"
>      "                select video card type\n", QEMU_ARCH_ALL)
> diff --git a/vl.c b/vl.c
> index b362871..5074bfe 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2289,7 +2289,16 @@ int main(int argc, char **argv, char **envp)
>  #endif
>                  break;
>              case QEMU_OPTION_portrait:
> -                graphic_rotate = 1;
> +                graphic_rotate = 90;
> +                break;
> +            case QEMU_OPTION_rotate:
> +                graphic_rotate = atoi(optarg);
> +                if (graphic_rotate != 0 && graphic_rotate != 90 &&
> +                    graphic_rotate != 180 && graphic_rotate != 270) {
> +                    fprintf(stderr,
> +                        "qemu: only 90, 180, 270 deg rotation is
> available\n"); +                    exit(1);
> +                }
>                  break;
>              case QEMU_OPTION_kernel:
>                  kernel_filename = optarg;

Ooops, I found a bug in rotation code, will resubmit fixed version soon.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support
  2011-06-01  9:28     ` [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
  2011-06-01  9:28       ` [Qemu-devel] [PATCH v2 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
  2011-06-03 15:33       ` [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
@ 2011-06-03 15:36       ` Vasily Khoruzhick
  2011-06-03 15:36         ` [Qemu-devel] [PATCH v3 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
                           ` (3 more replies)
  2 siblings, 4 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-03 15:36 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Vasily Khoruzhick

Until now, pxa2xx_lcd only supported 90deg rotation, but
some machines (for example Zipit Z2) needs 270deg rotation.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
v2: codestyle fixes
v3: fix dpy_update calls for 180 and 360 deg. rotation.

 hw/framebuffer.c |    2 +
 hw/pxa2xx_lcd.c  |  101 ++++++++++++++++++++++++++++++++++++++++++++++++------
 input.c          |   34 +++++++++++++-----
 qemu-options.hx  |    9 +++++
 vl.c             |   11 +++++-
 5 files changed, 136 insertions(+), 21 deletions(-)

diff --git a/hw/framebuffer.c b/hw/framebuffer.c
index 24cdf25..5e9ab5e 100644
--- a/hw/framebuffer.c
+++ b/hw/framebuffer.c
@@ -78,6 +78,8 @@ void framebuffer_update_display(
     dest = ds_get_data(ds);
     if (dest_col_pitch < 0)
         dest -= dest_col_pitch * (cols - 1);
+    if (dest_row_pitch < 0)
+        dest -= dest_row_pitch * (rows - 1);
     first = -1;
     addr = pd;
 
diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c
index e524802..3db900b 100644
--- a/hw/pxa2xx_lcd.c
+++ b/hw/pxa2xx_lcd.c
@@ -665,7 +665,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
     }
 }
 
-static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
+static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s,
                 target_phys_addr_t addr, int *miny, int *maxy)
 {
     int src_width, dest_width;
@@ -692,7 +692,7 @@ static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
                                fn, s->dma_ch[0].palette, miny, maxy);
 }
 
-static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
+static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s,
                target_phys_addr_t addr, int *miny, int *maxy)
 {
     int src_width, dest_width;
@@ -720,6 +720,61 @@ static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
                                miny, maxy);
 }
 
+static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
+                target_phys_addr_t addr, int *miny, int *maxy)
+{
+    int src_width, dest_width;
+    drawfn fn = NULL;
+    if (s->dest_width)
+        fn = s->line_fn[s->transp][s->bpp];
+    if (!fn)
+        return;
+
+    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
+    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp)
+        src_width *= 3;
+    else if (s->bpp > pxa_lcdc_16bpp)
+        src_width *= 4;
+    else if (s->bpp > pxa_lcdc_8bpp)
+        src_width *= 2;
+
+    dest_width = s->xres * s->dest_width;
+    *miny = 0;
+    framebuffer_update_display(s->ds,
+                               addr, s->xres, s->yres,
+                               src_width, -dest_width, -s->dest_width,
+                               s->invalidated,
+                               fn, s->dma_ch[0].palette, miny, maxy);
+}
+
+static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s,
+               target_phys_addr_t addr, int *miny, int *maxy)
+{
+    int src_width, dest_width;
+    drawfn fn = NULL;
+    if (s->dest_width)
+        fn = s->line_fn[s->transp][s->bpp];
+    if (!fn)
+        return;
+
+    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
+    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp)
+        src_width *= 3;
+    else if (s->bpp > pxa_lcdc_16bpp)
+        src_width *= 4;
+    else if (s->bpp > pxa_lcdc_8bpp)
+        src_width *= 2;
+
+    dest_width = s->yres * s->dest_width;
+    *miny = 0;
+    framebuffer_update_display(s->ds,
+                               addr, s->xres, s->yres,
+                               src_width, -s->dest_width, dest_width,
+                               s->invalidated,
+                               fn, s->dma_ch[0].palette,
+                               miny, maxy);
+}
+
 static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
 {
     int width, height;
@@ -730,10 +785,11 @@ static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
     height = LCCR2_LPP(s->control[2]) + 1;
 
     if (width != s->xres || height != s->yres) {
-        if (s->orientation)
+        if (s->orientation == 90 || s->orientation == 270) {
             qemu_console_resize(s->ds, height, width);
-        else
+        } else {
             qemu_console_resize(s->ds, width, height);
+        }
         s->invalidated = 1;
         s->xres = width;
         s->yres = height;
@@ -797,10 +853,24 @@ static void pxa2xx_update_display(void *opaque)
     }
 
     if (miny >= 0) {
-        if (s->orientation)
-            dpy_update(s->ds, miny, 0, maxy - miny, s->xres);
-        else
+        switch (s->orientation) {
+        case 0:
             dpy_update(s->ds, 0, miny, s->xres, maxy - miny);
+            break;
+        case 90:
+            dpy_update(s->ds, miny, 0, maxy - miny, s->xres);
+            break;
+        case 180:
+            maxy = s->yres - maxy;
+            miny = s->yres - miny;
+            dpy_update(s->ds, 0, maxy, s->xres, miny - maxy);
+            break;
+        case 270:
+            maxy = s->yres - maxy;
+            miny = s->yres - miny;
+            dpy_update(s->ds, maxy, 0, miny - maxy, s->xres);
+            break;
+        }
     }
     pxa2xx_lcdc_int_update(s);
 
@@ -822,10 +892,19 @@ static void pxa2xx_lcdc_orientation(void *opaque, int angle)
 {
     PXA2xxLCDState *s = (PXA2xxLCDState *) opaque;
 
-    if (angle) {
-        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_vert;
-    } else {
-        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_horiz;
+    switch (angle) {
+    case 0:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot0;
+        break;
+    case 90:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot90;
+        break;
+    case 180:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot180;
+        break;
+    case 270:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot270;
+        break;
     }
 
     s->orientation = angle;
diff --git a/input.c b/input.c
index 5664d3a..f0a02e7 100644
--- a/input.c
+++ b/input.c
@@ -148,7 +148,7 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
     QEMUPutMouseEntry *entry;
     QEMUPutMouseEvent *mouse_event;
     void *mouse_event_opaque;
-    int width;
+    int width, height;
 
     if (QTAILQ_EMPTY(&mouse_handlers)) {
         return;
@@ -160,15 +160,31 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
     mouse_event_opaque = entry->qemu_put_mouse_event_opaque;
 
     if (mouse_event) {
-        if (graphic_rotate) {
-            if (entry->qemu_put_mouse_event_absolute) {
-                width = 0x7fff;
-            } else {
-                width = graphic_width - 1;
-            }
-            mouse_event(mouse_event_opaque, width - dy, dx, dz, buttons_state);
+        if (entry->qemu_put_mouse_event_absolute) {
+            width = 0x7fff;
+            height = 0x7fff;
         } else {
-            mouse_event(mouse_event_opaque, dx, dy, dz, buttons_state);
+            width = graphic_width - 1;
+            height = graphic_height - 1;
+        }
+
+        switch (graphic_rotate) {
+        case 0:
+            mouse_event(mouse_event_opaque,
+                        dx, dy, dz, buttons_state);
+            break;
+        case 90:
+            mouse_event(mouse_event_opaque,
+                        width - dy, dx, dz, buttons_state);
+            break;
+        case 180:
+            mouse_event(mouse_event_opaque,
+                        width - dx, height - dy, dz, buttons_state);
+            break;
+        case 270:
+            mouse_event(mouse_event_opaque,
+                        dy, height - dx, dz, buttons_state);
+            break;
         }
     }
 }
diff --git a/qemu-options.hx b/qemu-options.hx
index 82e085a..46d8f25 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -771,6 +771,15 @@ STEXI
 Rotate graphical output 90 deg left (only PXA LCD).
 ETEXI
 
+DEF("rotate", HAS_ARG, QEMU_OPTION_rotate,
+    "-rotate <deg>   rotate graphical output some deg left (only PXA LCD)\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -rotate
+@findex -rotate
+Rotate graphical output some deg left (only PXA LCD).
+ETEXI
+
 DEF("vga", HAS_ARG, QEMU_OPTION_vga,
     "-vga [std|cirrus|vmware|qxl|xenfb|none]\n"
     "                select video card type\n", QEMU_ARCH_ALL)
diff --git a/vl.c b/vl.c
index b362871..5074bfe 100644
--- a/vl.c
+++ b/vl.c
@@ -2289,7 +2289,16 @@ int main(int argc, char **argv, char **envp)
 #endif
                 break;
             case QEMU_OPTION_portrait:
-                graphic_rotate = 1;
+                graphic_rotate = 90;
+                break;
+            case QEMU_OPTION_rotate:
+                graphic_rotate = atoi(optarg);
+                if (graphic_rotate != 0 && graphic_rotate != 90 &&
+                    graphic_rotate != 180 && graphic_rotate != 270) {
+                    fprintf(stderr,
+                        "qemu: only 90, 180, 270 deg rotation is available\n");
+                    exit(1);
+                }
                 break;
             case QEMU_OPTION_kernel:
                 kernel_filename = optarg;
-- 
1.7.5.rc3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH v3 2/2] Add support for Zipit Z2 machine
  2011-06-03 15:36       ` [Qemu-devel] [PATCH v3 " Vasily Khoruzhick
@ 2011-06-03 15:36         ` Vasily Khoruzhick
  2011-06-03 15:38         ` [Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
                           ` (2 subsequent siblings)
  3 siblings, 0 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-03 15:36 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Vasily Khoruzhick

Zipit Z2 is small PXA270 based handheld.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
v2: codestyle fixes, added VMStateDescription for LCD device and AER915,
    traces clean up.
v3: no changes
 Makefile.target |    1 +
 hw/z2.c         |  352 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 353 insertions(+), 0 deletions(-)
 create mode 100644 hw/z2.c

diff --git a/Makefile.target b/Makefile.target
index 602d50d..5750499 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -358,6 +358,7 @@ obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
+obj-arm-y += z2.o
 obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o
 obj-arm-y += framebuffer.o
 obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
diff --git a/hw/z2.c b/hw/z2.c
new file mode 100644
index 0000000..3e3591a
--- /dev/null
+++ b/hw/z2.c
@@ -0,0 +1,352 @@
+/*
+ * PXA270-based Zipit Z2 device
+ *
+ * Copyright (c) 2011 by Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * Code is based on mainstone platform.
+ *
+ * This code is licensed under the GNU GPL v2.
+ */
+
+#include "hw.h"
+#include "pxa.h"
+#include "arm-misc.h"
+#include "devices.h"
+#include "i2c.h"
+#include "ssi.h"
+#include "boards.h"
+#include "sysemu.h"
+#include "flash.h"
+#include "blockdev.h"
+#include "console.h"
+#include "audio/audio.h"
+
+#if 0
+#define DPRINTF(fmt, ...) \
+        printf(fmt, ## __VA_ARGS__)
+#else
+#define DPRINTF(fmt, ...)
+#endif
+
+static struct keymap map[0x100] = {
+    [0 ... 0xff] = { -1, -1 },
+    [0x3b] = {0, 0}, /* Option = F1 */
+    [0xc8] = {0, 1}, /* Up */
+    [0xd0] = {0, 2}, /* Down */
+    [0xcb] = {0, 3}, /* Left */
+    [0xcd] = {0, 4}, /* Right */
+    [0xcf] = {0, 5}, /* End */
+    [0x0d] = {0, 6}, /* KPPLUS */
+    [0xc7] = {1, 0}, /* Home */
+    [0x10] = {1, 1}, /* Q */
+    [0x17] = {1, 2}, /* I */
+    [0x22] = {1, 3}, /* G */
+    [0x2d] = {1, 4}, /* X */
+    [0x1c] = {1, 5}, /* Enter */
+    [0x0c] = {1, 6}, /* KPMINUS */
+    [0xc9] = {2, 0}, /* PageUp */
+    [0x11] = {2, 1}, /* W */
+    [0x18] = {2, 2}, /* O */
+    [0x23] = {2, 3}, /* H */
+    [0x2e] = {2, 4}, /* C */
+    [0x38] = {2, 5}, /* LeftAlt */
+    [0xd1] = {3, 0}, /* PageDown */
+    [0x12] = {3, 1}, /* E */
+    [0x19] = {3, 2}, /* P */
+    [0x24] = {3, 3}, /* J */
+    [0x2f] = {3, 4}, /* V */
+    [0x2a] = {3, 5}, /* LeftShift */
+    [0x01] = {4, 0}, /* Esc */
+    [0x13] = {4, 1}, /* R */
+    [0x1e] = {4, 2}, /* A */
+    [0x25] = {4, 3}, /* K */
+    [0x30] = {4, 4}, /* B */
+    [0x1d] = {4, 5}, /* LeftCtrl */
+    [0x0f] = {5, 0}, /* Tab */
+    [0x14] = {5, 1}, /* T */
+    [0x1f] = {5, 2}, /* S */
+    [0x26] = {5, 3}, /* L */
+    [0x31] = {5, 4}, /* N */
+    [0x39] = {5, 5}, /* Space */
+    [0x3c] = {6, 0}, /* Stop = F2 */
+    [0x15] = {6, 1}, /* Y */
+    [0x20] = {6, 2}, /* D */
+    [0x0e] = {6, 3}, /* Backspace */
+    [0x32] = {6, 4}, /* M */
+    [0x33] = {6, 5}, /* Comma */
+    [0x3d] = {7, 0}, /* Play = F3 */
+    [0x16] = {7, 1}, /* U */
+    [0x21] = {7, 2}, /* F */
+    [0x2c] = {7, 3}, /* Z */
+    [0x27] = {7, 4}, /* Semicolon */
+    [0x34] = {7, 5}, /* Dot */
+};
+
+#define Z2_RAM_SIZE     0x02000000
+#define Z2_FLASH_BASE   0x00000000
+#define Z2_FLASH_SIZE   0x00800000
+
+static struct arm_boot_info z2_binfo = {
+    .loader_start   = PXA2XX_SDRAM_BASE,
+    .ram_size       = Z2_RAM_SIZE,
+};
+
+#define Z2_GPIO_SD_DETECT   96
+#define Z2_GPIO_AC_IN       0
+#define Z2_GPIO_KEY_ON      1
+#define Z2_GPIO_LCD_CS      88
+
+typedef struct {
+    SSISlave ssidev;
+    int32_t selected;
+    int32_t enabled;
+    uint8_t buf[3];
+    uint32_t cur_reg;
+    int pos;
+} ZipitLCD;
+
+static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    uint16_t val;
+    if (z->selected) {
+        z->buf[z->pos] = value & 0xff;
+        z->pos++;
+    }
+    if (z->pos == 3) {
+        switch (z->buf[0]) {
+        case 0x74:
+            DPRINTF("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
+            z->cur_reg = z->buf[2];
+            break;
+        case 0x76:
+            val = z->buf[1] << 8 | z->buf[2];
+            DPRINTF("%s: value: 0x%.4x\n", __func__, val);
+            if (z->cur_reg == 0x22 && val == 0x0000) {
+                z->enabled = 1;
+                printf("%s: LCD enabled\n", __func__);
+            } else if (z->cur_reg == 0x10 && val == 0x0000) {
+                z->enabled = 0;
+                printf("%s: LCD disabled\n", __func__);
+            }
+            break;
+        default:
+            fprintf(stderr, "%s: unknown command!\n", __func__);
+            break;
+        }
+        z->pos = 0;
+    }
+    return 0;
+}
+
+static void z2_lcd_cs(void *opaque, int line, int level)
+{
+    ZipitLCD *z2_lcd = opaque;
+    z2_lcd->selected = !level;
+}
+
+static int zipit_lcd_init(SSISlave *dev)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    z->selected = 0;
+    z->enabled = 0;
+    z->pos = 0;
+
+    return 0;
+}
+
+static VMStateDescription vmstate_zipit_lcd_state = {
+    .name = "zipit-lcd",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(enabled, ZipitLCD),
+        VMSTATE_END_OF_LIST(),
+    }
+};
+
+static SSISlaveInfo zipit_lcd_info = {
+    .qdev.name = "zipit-lcd",
+    .qdev.size = sizeof(ZipitLCD),
+    .qdev.vmsd = &vmstate_zipit_lcd_state,
+    .init = zipit_lcd_init,
+    .transfer = zipit_lcd_transfer
+};
+
+typedef struct {
+    i2c_slave i2c;
+    int len;
+    char buf[3];
+} AER915State;
+
+static int aer915_send(i2c_slave *i2c, uint8_t data)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    s->buf[s->len] = data;
+    if (s->len++ > 2) {
+        fprintf(stderr, "%s: message too long (%i bytes)\n",
+            __func__, s->len);
+        return 1;
+    }
+
+    if (s->len == 2) {
+        DPRINTF("%s: reg %d value 0x%02x\n", __func__,
+                s->buf[0], s->buf[1]);
+    }
+
+    return 0;
+}
+
+static void aer915_event(i2c_slave *i2c, enum i2c_event event)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    switch (event) {
+    case I2C_START_SEND:
+        s->len = 0;
+        break;
+    case I2C_START_RECV:
+        if (s->len != 1) {
+            fprintf(stderr, "%s: short message!?\n", __func__);
+        }
+        break;
+    case I2C_FINISH:
+        break;
+    default:
+        break;
+    }
+}
+
+static int aer915_recv(i2c_slave *slave)
+{
+    int retval = 0x00;
+    AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
+
+    switch (s->buf[0]) {
+    /* Return hardcoded battery voltage,
+     * 0xf0 means ~4.1V
+     */
+    case 0x02:
+        retval = 0xf0;
+        break;
+    /* Return 0x00 for other regs,
+     * we don't know what they are for,
+     * anyway they return 0x00 on real hardware.
+     */
+    default:
+        break;
+    }
+
+    return retval;
+}
+
+static int aer915_init(i2c_slave *i2c)
+{
+    /* Nothing to do.  */
+    return 0;
+}
+
+static VMStateDescription vmstate_aer915_state = {
+    .name = "aer915",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_END_OF_LIST(),
+    }
+};
+
+static I2CSlaveInfo aer915_info = {
+    .qdev.name = "aer915",
+    .qdev.size = sizeof(AER915State),
+    .qdev.vmsd = &vmstate_aer915_state,
+    .init = aer915_init,
+    .event = aer915_event,
+    .recv = aer915_recv,
+    .send = aer915_send
+};
+
+static void z2_init(ram_addr_t ram_size,
+                const char *boot_device,
+                const char *kernel_filename, const char *kernel_cmdline,
+                const char *initrd_filename, const char *cpu_model)
+{
+    uint32_t sector_len = 0x10000;
+    PXA2xxState *cpu;
+    DriveInfo *dinfo;
+    int be;
+    void *z2_lcd;
+    i2c_bus *bus;
+    DeviceState *wm;
+
+    if (!cpu_model) {
+        cpu_model = "pxa270-c5";
+    }
+
+    /* Setup CPU & memory */
+    cpu = pxa270_init(z2_binfo.ram_size, cpu_model);
+
+#ifdef TARGET_WORDS_BIGENDIAN
+    be = 1;
+#else
+    be = 0;
+#endif
+    dinfo = drive_get(IF_PFLASH, 0, 0);
+    if (!dinfo) {
+        fprintf(stderr, "Flash image must be given with the "
+                "'pflash' parameter\n");
+        exit(1);
+    }
+
+    if (!pflash_cfi01_register(Z2_FLASH_BASE,
+                               qemu_ram_alloc(NULL, "z2.flash0", Z2_FLASH_SIZE),
+                               dinfo->bdrv, sector_len,
+                               Z2_FLASH_SIZE / sector_len, 4, 0, 0, 0, 0,
+                               be)) {
+        fprintf(stderr, "qemu: Error registering flash memory.\n");
+        exit(1);
+    }
+
+    /* setup keypad */
+    pxa27x_register_keypad(cpu->kp, map, 0x100);
+
+    /* MMC/SD host */
+    pxa2xx_mmci_handlers(cpu->mmc,
+        NULL,
+        qdev_get_gpio_in(cpu->gpio, Z2_GPIO_SD_DETECT));
+
+    ssi_register_slave(&zipit_lcd_info);
+    i2c_register_slave(&aer915_info);
+    z2_lcd = ssi_create_slave(cpu->ssp[1], "zipit-lcd");
+    bus = pxa2xx_i2c_bus(cpu->i2c[0]);
+    i2c_create_slave(bus, "aer915", 0x55);
+    wm = i2c_create_slave(bus, "wm8750", 0x1b);
+    cpu->i2s->opaque = wm;
+    cpu->i2s->codec_out = wm8750_dac_dat;
+    cpu->i2s->codec_in = wm8750_adc_dat;
+    wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
+
+    qdev_connect_gpio_out(cpu->gpio, Z2_GPIO_LCD_CS,
+        qemu_allocate_irqs(z2_lcd_cs, z2_lcd, 1)[0]);
+
+    if (kernel_filename) {
+        z2_binfo.kernel_filename = kernel_filename;
+        z2_binfo.kernel_cmdline = kernel_cmdline;
+        z2_binfo.initrd_filename = initrd_filename;
+        z2_binfo.board_id = 0x6dd;
+        arm_load_kernel(cpu->env, &z2_binfo);
+    }
+}
+
+static QEMUMachine z2_machine = {
+    .name = "z2",
+    .desc = "Zipit Z2 (PXA27x)",
+    .init = z2_init,
+};
+
+static void z2_machine_init(void)
+{
+    qemu_register_machine(&z2_machine);
+}
+
+machine_init(z2_machine_init);
-- 
1.7.5.rc3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support
  2011-06-03 15:36       ` [Qemu-devel] [PATCH v3 " Vasily Khoruzhick
  2011-06-03 15:36         ` [Qemu-devel] [PATCH v3 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
@ 2011-06-03 15:38         ` Vasily Khoruzhick
  2011-06-08  8:52         ` Vasily Khoruzhick
  2011-06-08  9:50         ` Peter Maydell
  3 siblings, 0 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-03 15:38 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Friday 03 June 2011 18:36:36 Vasily Khoruzhick wrote:
> Until now, pxa2xx_lcd only supported 90deg rotation, but
> some machines (for example Zipit Z2) needs 270deg rotation.
> 
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
> v2: codestyle fixes
> v3: fix dpy_update calls for 180 and 360 deg. rotation.

s/360/270

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support
  2011-06-03 15:36       ` [Qemu-devel] [PATCH v3 " Vasily Khoruzhick
  2011-06-03 15:36         ` [Qemu-devel] [PATCH v3 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
  2011-06-03 15:38         ` [Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
@ 2011-06-08  8:52         ` Vasily Khoruzhick
  2011-06-08  9:50         ` Peter Maydell
  3 siblings, 0 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-08  8:52 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Friday 03 June 2011 18:36:36 Vasily Khoruzhick wrote:
> Until now, pxa2xx_lcd only supported 90deg rotation, but
> some machines (for example Zipit Z2) needs 270deg rotation.
> 
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>

Ping

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support
  2011-06-03 15:36       ` [Qemu-devel] [PATCH v3 " Vasily Khoruzhick
                           ` (2 preceding siblings ...)
  2011-06-08  8:52         ` Vasily Khoruzhick
@ 2011-06-08  9:50         ` Peter Maydell
  2011-06-08 11:22           ` Vasily Khoruzhick
  3 siblings, 1 reply; 26+ messages in thread
From: Peter Maydell @ 2011-06-08  9:50 UTC (permalink / raw)
  To: Vasily Khoruzhick; +Cc: qemu-devel

On 3 June 2011 16:36, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> Until now, pxa2xx_lcd only supported 90deg rotation, but
> some machines (for example Zipit Z2) needs 270deg rotation.
>
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>

Still haven't tested this yet, but some very quick first
pass comments.


> +static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
> +                target_phys_addr_t addr, int *miny, int *maxy)
> +{
> +    int src_width, dest_width;
> +    drawfn fn = NULL;
> +    if (s->dest_width)
> +        fn = s->line_fn[s->transp][s->bpp];
> +    if (!fn)
> +        return;

Braces (here and elsewhere); if we're adding whole new functions
we might as well do them in accordance with the styl.

>             case QEMU_OPTION_portrait:
> -                graphic_rotate = 1;
> +                graphic_rotate = 90;
> +                break;
> +            case QEMU_OPTION_rotate:
> +                graphic_rotate = atoi(optarg);
> +                if (graphic_rotate != 0 && graphic_rotate != 90 &&
> +                    graphic_rotate != 180 && graphic_rotate != 270) {
> +                    fprintf(stderr,
> +                        "qemu: only 90, 180, 270 deg rotation is available\n");
> +                    exit(1);
> +                }

We seem to generally use strtol() for argument parsing rather
than atoi, might be nicer to be consistent.

The other bit of code that looks at graphic_rotate
is hw/spitz.c:spitz_keyboard_register(). Does that require
changes? It doesn't seem entirely right for us to assert
'tablet mode' for everything except 0deg rotation.

-- PMM

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support
  2011-06-08  9:50         ` Peter Maydell
@ 2011-06-08 11:22           ` Vasily Khoruzhick
  2011-06-17 10:04             ` [Qemu-devel] [PATCH v4 " Vasily Khoruzhick
  0 siblings, 1 reply; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-08 11:22 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Wednesday 08 June 2011 12:50:50 Peter Maydell wrote:
> On 3 June 2011 16:36, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> > Until now, pxa2xx_lcd only supported 90deg rotation, but
> > some machines (for example Zipit Z2) needs 270deg rotation.
> > 
> > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> 
> Still haven't tested this yet, but some very quick first
> pass comments.
> 
> > +static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
> > +                target_phys_addr_t addr, int *miny, int *maxy)
> > +{
> > +    int src_width, dest_width;
> > +    drawfn fn = NULL;
> > +    if (s->dest_width)
> > +        fn = s->line_fn[s->transp][s->bpp];
> > +    if (!fn)
> > +        return;
> 
> Braces (here and elsewhere); if we're adding whole new functions
> we might as well do them in accordance with the styl.

Oh, ok. I'll add patch to fix pxa2xx_lcd.c codestyle to the series, and then 
fix this patch.

> 
> >             case QEMU_OPTION_portrait:
> > -                graphic_rotate = 1;
> > +                graphic_rotate = 90;
> > +                break;
> > +            case QEMU_OPTION_rotate:
> > +                graphic_rotate = atoi(optarg);
> > +                if (graphic_rotate != 0 && graphic_rotate != 90 &&
> > +                    graphic_rotate != 180 && graphic_rotate != 270) {
> > +                    fprintf(stderr,
> > +                        "qemu: only 90, 180, 270 deg rotation is
> > available\n"); +                    exit(1);
> > +                }
> 
> We seem to generally use strtol() for argument parsing rather
> than atoi, might be nicer to be consistent.

Ok

> The other bit of code that looks at graphic_rotate
> is hw/spitz.c:spitz_keyboard_register(). Does that require
> changes? It doesn't seem entirely right for us to assert
> 'tablet mode' for everything except 0deg rotation.

Well, -portrait argument is preserved, so all old code should work fine 
(including scripts to start qemu). Passing -rotate 180 or -rotate 270 will 
produce unpredictable result (but not a crash). I have no spitz  image, so I 
can't test what happens.

Regards
Vasily

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH v4 1/2] pxa2xx_lcd: add proper rotation support
  2011-06-08 11:22           ` Vasily Khoruzhick
@ 2011-06-17 10:04             ` Vasily Khoruzhick
  2011-06-17 10:04               ` [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
                                 ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-17 10:04 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Vasily Khoruzhick

Until now, pxa2xx_lcd only supported 90deg rotation, but
some machines (for example Zipit Z2) needs 270deg rotation.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
v2: codestyle fixes
v3: fix dpy_update calls for 180 and 360 deg. rotation.
v4: codestyle fixes; replace atoi with strtol
 hw/framebuffer.c |    3 +
 hw/pxa2xx_lcd.c  |  109 ++++++++++++++++++++++++++++++++++++++++++++++++------
 input.c          |   34 ++++++++++++----
 qemu-options.hx  |    9 ++++
 vl.c             |   11 +++++-
 5 files changed, 144 insertions(+), 22 deletions(-)

diff --git a/hw/framebuffer.c b/hw/framebuffer.c
index 24cdf25..56cf16e 100644
--- a/hw/framebuffer.c
+++ b/hw/framebuffer.c
@@ -78,6 +78,9 @@ void framebuffer_update_display(
     dest = ds_get_data(ds);
     if (dest_col_pitch < 0)
         dest -= dest_col_pitch * (cols - 1);
+    if (dest_row_pitch < 0) {
+        dest -= dest_row_pitch * (rows - 1);
+    }
     first = -1;
     addr = pd;
 
diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c
index e524802..a5f8c51 100644
--- a/hw/pxa2xx_lcd.c
+++ b/hw/pxa2xx_lcd.c
@@ -665,7 +665,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
     }
 }
 
-static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
+static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s,
                 target_phys_addr_t addr, int *miny, int *maxy)
 {
     int src_width, dest_width;
@@ -692,7 +692,7 @@ static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
                                fn, s->dma_ch[0].palette, miny, maxy);
 }
 
-static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
+static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s,
                target_phys_addr_t addr, int *miny, int *maxy)
 {
     int src_width, dest_width;
@@ -720,6 +720,67 @@ static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
                                miny, maxy);
 }
 
+static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
+                target_phys_addr_t addr, int *miny, int *maxy)
+{
+    int src_width, dest_width;
+    drawfn fn = NULL;
+    if (s->dest_width) {
+        fn = s->line_fn[s->transp][s->bpp];
+    }
+    if (!fn) {
+        return;
+    }
+
+    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
+    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp) {
+        src_width *= 3;
+    } else if (s->bpp > pxa_lcdc_16bpp) {
+        src_width *= 4;
+    } else if (s->bpp > pxa_lcdc_8bpp) {
+        src_width *= 2;
+    }
+
+    dest_width = s->xres * s->dest_width;
+    *miny = 0;
+    framebuffer_update_display(s->ds,
+                               addr, s->xres, s->yres,
+                               src_width, -dest_width, -s->dest_width,
+                               s->invalidated,
+                               fn, s->dma_ch[0].palette, miny, maxy);
+}
+
+static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s,
+               target_phys_addr_t addr, int *miny, int *maxy)
+{
+    int src_width, dest_width;
+    drawfn fn = NULL;
+    if (s->dest_width) {
+        fn = s->line_fn[s->transp][s->bpp];
+    }
+    if (!fn) {
+        return;
+    }
+
+    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
+    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp) {
+        src_width *= 3;
+    } else if (s->bpp > pxa_lcdc_16bpp) {
+        src_width *= 4;
+    } else if (s->bpp > pxa_lcdc_8bpp) {
+        src_width *= 2;
+    }
+
+    dest_width = s->yres * s->dest_width;
+    *miny = 0;
+    framebuffer_update_display(s->ds,
+                               addr, s->xres, s->yres,
+                               src_width, -s->dest_width, dest_width,
+                               s->invalidated,
+                               fn, s->dma_ch[0].palette,
+                               miny, maxy);
+}
+
 static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
 {
     int width, height;
@@ -730,10 +791,11 @@ static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
     height = LCCR2_LPP(s->control[2]) + 1;
 
     if (width != s->xres || height != s->yres) {
-        if (s->orientation)
+        if (s->orientation == 90 || s->orientation == 270) {
             qemu_console_resize(s->ds, height, width);
-        else
+        } else {
             qemu_console_resize(s->ds, width, height);
+        }
         s->invalidated = 1;
         s->xres = width;
         s->yres = height;
@@ -797,10 +859,24 @@ static void pxa2xx_update_display(void *opaque)
     }
 
     if (miny >= 0) {
-        if (s->orientation)
-            dpy_update(s->ds, miny, 0, maxy - miny, s->xres);
-        else
-            dpy_update(s->ds, 0, miny, s->xres, maxy - miny);
+        switch (s->orientation) {
+        case 0:
+            dpy_update(s->ds, 0, miny, s->xres, maxy - miny + 1);
+            break;
+        case 90:
+            dpy_update(s->ds, miny, 0, maxy - miny + 1, s->xres);
+            break;
+        case 180:
+            maxy = s->yres - maxy - 1;
+            miny = s->yres - miny - 1;
+            dpy_update(s->ds, 0, maxy, s->xres, miny - maxy + 1);
+            break;
+        case 270:
+            maxy = s->yres - maxy - 1;
+            miny = s->yres - miny - 1;
+            dpy_update(s->ds, maxy, 0, miny - maxy + 1, s->xres);
+            break;
+        }
     }
     pxa2xx_lcdc_int_update(s);
 
@@ -822,10 +898,19 @@ static void pxa2xx_lcdc_orientation(void *opaque, int angle)
 {
     PXA2xxLCDState *s = (PXA2xxLCDState *) opaque;
 
-    if (angle) {
-        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_vert;
-    } else {
-        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_horiz;
+    switch (angle) {
+    case 0:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot0;
+        break;
+    case 90:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot90;
+        break;
+    case 180:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot180;
+        break;
+    case 270:
+        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot270;
+        break;
     }
 
     s->orientation = angle;
diff --git a/input.c b/input.c
index 5664d3a..f0a02e7 100644
--- a/input.c
+++ b/input.c
@@ -148,7 +148,7 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
     QEMUPutMouseEntry *entry;
     QEMUPutMouseEvent *mouse_event;
     void *mouse_event_opaque;
-    int width;
+    int width, height;
 
     if (QTAILQ_EMPTY(&mouse_handlers)) {
         return;
@@ -160,15 +160,31 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state)
     mouse_event_opaque = entry->qemu_put_mouse_event_opaque;
 
     if (mouse_event) {
-        if (graphic_rotate) {
-            if (entry->qemu_put_mouse_event_absolute) {
-                width = 0x7fff;
-            } else {
-                width = graphic_width - 1;
-            }
-            mouse_event(mouse_event_opaque, width - dy, dx, dz, buttons_state);
+        if (entry->qemu_put_mouse_event_absolute) {
+            width = 0x7fff;
+            height = 0x7fff;
         } else {
-            mouse_event(mouse_event_opaque, dx, dy, dz, buttons_state);
+            width = graphic_width - 1;
+            height = graphic_height - 1;
+        }
+
+        switch (graphic_rotate) {
+        case 0:
+            mouse_event(mouse_event_opaque,
+                        dx, dy, dz, buttons_state);
+            break;
+        case 90:
+            mouse_event(mouse_event_opaque,
+                        width - dy, dx, dz, buttons_state);
+            break;
+        case 180:
+            mouse_event(mouse_event_opaque,
+                        width - dx, height - dy, dz, buttons_state);
+            break;
+        case 270:
+            mouse_event(mouse_event_opaque,
+                        dy, height - dx, dz, buttons_state);
+            break;
         }
     }
 }
diff --git a/qemu-options.hx b/qemu-options.hx
index 82e085a..46d8f25 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -771,6 +771,15 @@ STEXI
 Rotate graphical output 90 deg left (only PXA LCD).
 ETEXI
 
+DEF("rotate", HAS_ARG, QEMU_OPTION_rotate,
+    "-rotate <deg>   rotate graphical output some deg left (only PXA LCD)\n",
+    QEMU_ARCH_ALL)
+STEXI
+@item -rotate
+@findex -rotate
+Rotate graphical output some deg left (only PXA LCD).
+ETEXI
+
 DEF("vga", HAS_ARG, QEMU_OPTION_vga,
     "-vga [std|cirrus|vmware|qxl|xenfb|none]\n"
     "                select video card type\n", QEMU_ARCH_ALL)
diff --git a/vl.c b/vl.c
index b362871..c11cc44 100644
--- a/vl.c
+++ b/vl.c
@@ -2289,7 +2289,16 @@ int main(int argc, char **argv, char **envp)
 #endif
                 break;
             case QEMU_OPTION_portrait:
-                graphic_rotate = 1;
+                graphic_rotate = 90;
+                break;
+            case QEMU_OPTION_rotate:
+                graphic_rotate = strtol(optarg, (char **)&optarg, 10);
+                if (graphic_rotate != 0 && graphic_rotate != 90 &&
+                    graphic_rotate != 180 && graphic_rotate != 270) {
+                    fprintf(stderr,
+                        "qemu: only 90, 180, 270 deg rotation is available\n");
+                    exit(1);
+                }
                 break;
             case QEMU_OPTION_kernel:
                 kernel_filename = optarg;
-- 
1.7.5.rc3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine
  2011-06-17 10:04             ` [Qemu-devel] [PATCH v4 " Vasily Khoruzhick
@ 2011-06-17 10:04               ` Vasily Khoruzhick
  2011-06-21  9:47                 ` Vasily Khoruzhick
  2011-06-24 14:45                 ` Peter Maydell
  2011-06-21  9:47               ` [Qemu-devel] [PATCH v4 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
  2011-07-04 20:11               ` andrzej zaborowski
  2 siblings, 2 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-17 10:04 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Vasily Khoruzhick

Zipit Z2 is small PXA270 based handheld.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
v2: codestyle fixes, added VMStateDescription for LCD device and AER915,
    traces clean up.
v3: no changes
v4: no changes
 Makefile.target |    1 +
 hw/z2.c         |  352 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 353 insertions(+), 0 deletions(-)
 create mode 100644 hw/z2.c

diff --git a/Makefile.target b/Makefile.target
index 602d50d..5750499 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -358,6 +358,7 @@ obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
+obj-arm-y += z2.o
 obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o
 obj-arm-y += framebuffer.o
 obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
diff --git a/hw/z2.c b/hw/z2.c
new file mode 100644
index 0000000..3e3591a
--- /dev/null
+++ b/hw/z2.c
@@ -0,0 +1,352 @@
+/*
+ * PXA270-based Zipit Z2 device
+ *
+ * Copyright (c) 2011 by Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * Code is based on mainstone platform.
+ *
+ * This code is licensed under the GNU GPL v2.
+ */
+
+#include "hw.h"
+#include "pxa.h"
+#include "arm-misc.h"
+#include "devices.h"
+#include "i2c.h"
+#include "ssi.h"
+#include "boards.h"
+#include "sysemu.h"
+#include "flash.h"
+#include "blockdev.h"
+#include "console.h"
+#include "audio/audio.h"
+
+#if 0
+#define DPRINTF(fmt, ...) \
+        printf(fmt, ## __VA_ARGS__)
+#else
+#define DPRINTF(fmt, ...)
+#endif
+
+static struct keymap map[0x100] = {
+    [0 ... 0xff] = { -1, -1 },
+    [0x3b] = {0, 0}, /* Option = F1 */
+    [0xc8] = {0, 1}, /* Up */
+    [0xd0] = {0, 2}, /* Down */
+    [0xcb] = {0, 3}, /* Left */
+    [0xcd] = {0, 4}, /* Right */
+    [0xcf] = {0, 5}, /* End */
+    [0x0d] = {0, 6}, /* KPPLUS */
+    [0xc7] = {1, 0}, /* Home */
+    [0x10] = {1, 1}, /* Q */
+    [0x17] = {1, 2}, /* I */
+    [0x22] = {1, 3}, /* G */
+    [0x2d] = {1, 4}, /* X */
+    [0x1c] = {1, 5}, /* Enter */
+    [0x0c] = {1, 6}, /* KPMINUS */
+    [0xc9] = {2, 0}, /* PageUp */
+    [0x11] = {2, 1}, /* W */
+    [0x18] = {2, 2}, /* O */
+    [0x23] = {2, 3}, /* H */
+    [0x2e] = {2, 4}, /* C */
+    [0x38] = {2, 5}, /* LeftAlt */
+    [0xd1] = {3, 0}, /* PageDown */
+    [0x12] = {3, 1}, /* E */
+    [0x19] = {3, 2}, /* P */
+    [0x24] = {3, 3}, /* J */
+    [0x2f] = {3, 4}, /* V */
+    [0x2a] = {3, 5}, /* LeftShift */
+    [0x01] = {4, 0}, /* Esc */
+    [0x13] = {4, 1}, /* R */
+    [0x1e] = {4, 2}, /* A */
+    [0x25] = {4, 3}, /* K */
+    [0x30] = {4, 4}, /* B */
+    [0x1d] = {4, 5}, /* LeftCtrl */
+    [0x0f] = {5, 0}, /* Tab */
+    [0x14] = {5, 1}, /* T */
+    [0x1f] = {5, 2}, /* S */
+    [0x26] = {5, 3}, /* L */
+    [0x31] = {5, 4}, /* N */
+    [0x39] = {5, 5}, /* Space */
+    [0x3c] = {6, 0}, /* Stop = F2 */
+    [0x15] = {6, 1}, /* Y */
+    [0x20] = {6, 2}, /* D */
+    [0x0e] = {6, 3}, /* Backspace */
+    [0x32] = {6, 4}, /* M */
+    [0x33] = {6, 5}, /* Comma */
+    [0x3d] = {7, 0}, /* Play = F3 */
+    [0x16] = {7, 1}, /* U */
+    [0x21] = {7, 2}, /* F */
+    [0x2c] = {7, 3}, /* Z */
+    [0x27] = {7, 4}, /* Semicolon */
+    [0x34] = {7, 5}, /* Dot */
+};
+
+#define Z2_RAM_SIZE     0x02000000
+#define Z2_FLASH_BASE   0x00000000
+#define Z2_FLASH_SIZE   0x00800000
+
+static struct arm_boot_info z2_binfo = {
+    .loader_start   = PXA2XX_SDRAM_BASE,
+    .ram_size       = Z2_RAM_SIZE,
+};
+
+#define Z2_GPIO_SD_DETECT   96
+#define Z2_GPIO_AC_IN       0
+#define Z2_GPIO_KEY_ON      1
+#define Z2_GPIO_LCD_CS      88
+
+typedef struct {
+    SSISlave ssidev;
+    int32_t selected;
+    int32_t enabled;
+    uint8_t buf[3];
+    uint32_t cur_reg;
+    int pos;
+} ZipitLCD;
+
+static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    uint16_t val;
+    if (z->selected) {
+        z->buf[z->pos] = value & 0xff;
+        z->pos++;
+    }
+    if (z->pos == 3) {
+        switch (z->buf[0]) {
+        case 0x74:
+            DPRINTF("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
+            z->cur_reg = z->buf[2];
+            break;
+        case 0x76:
+            val = z->buf[1] << 8 | z->buf[2];
+            DPRINTF("%s: value: 0x%.4x\n", __func__, val);
+            if (z->cur_reg == 0x22 && val == 0x0000) {
+                z->enabled = 1;
+                printf("%s: LCD enabled\n", __func__);
+            } else if (z->cur_reg == 0x10 && val == 0x0000) {
+                z->enabled = 0;
+                printf("%s: LCD disabled\n", __func__);
+            }
+            break;
+        default:
+            fprintf(stderr, "%s: unknown command!\n", __func__);
+            break;
+        }
+        z->pos = 0;
+    }
+    return 0;
+}
+
+static void z2_lcd_cs(void *opaque, int line, int level)
+{
+    ZipitLCD *z2_lcd = opaque;
+    z2_lcd->selected = !level;
+}
+
+static int zipit_lcd_init(SSISlave *dev)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    z->selected = 0;
+    z->enabled = 0;
+    z->pos = 0;
+
+    return 0;
+}
+
+static VMStateDescription vmstate_zipit_lcd_state = {
+    .name = "zipit-lcd",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(enabled, ZipitLCD),
+        VMSTATE_END_OF_LIST(),
+    }
+};
+
+static SSISlaveInfo zipit_lcd_info = {
+    .qdev.name = "zipit-lcd",
+    .qdev.size = sizeof(ZipitLCD),
+    .qdev.vmsd = &vmstate_zipit_lcd_state,
+    .init = zipit_lcd_init,
+    .transfer = zipit_lcd_transfer
+};
+
+typedef struct {
+    i2c_slave i2c;
+    int len;
+    char buf[3];
+} AER915State;
+
+static int aer915_send(i2c_slave *i2c, uint8_t data)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    s->buf[s->len] = data;
+    if (s->len++ > 2) {
+        fprintf(stderr, "%s: message too long (%i bytes)\n",
+            __func__, s->len);
+        return 1;
+    }
+
+    if (s->len == 2) {
+        DPRINTF("%s: reg %d value 0x%02x\n", __func__,
+                s->buf[0], s->buf[1]);
+    }
+
+    return 0;
+}
+
+static void aer915_event(i2c_slave *i2c, enum i2c_event event)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    switch (event) {
+    case I2C_START_SEND:
+        s->len = 0;
+        break;
+    case I2C_START_RECV:
+        if (s->len != 1) {
+            fprintf(stderr, "%s: short message!?\n", __func__);
+        }
+        break;
+    case I2C_FINISH:
+        break;
+    default:
+        break;
+    }
+}
+
+static int aer915_recv(i2c_slave *slave)
+{
+    int retval = 0x00;
+    AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
+
+    switch (s->buf[0]) {
+    /* Return hardcoded battery voltage,
+     * 0xf0 means ~4.1V
+     */
+    case 0x02:
+        retval = 0xf0;
+        break;
+    /* Return 0x00 for other regs,
+     * we don't know what they are for,
+     * anyway they return 0x00 on real hardware.
+     */
+    default:
+        break;
+    }
+
+    return retval;
+}
+
+static int aer915_init(i2c_slave *i2c)
+{
+    /* Nothing to do.  */
+    return 0;
+}
+
+static VMStateDescription vmstate_aer915_state = {
+    .name = "aer915",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_END_OF_LIST(),
+    }
+};
+
+static I2CSlaveInfo aer915_info = {
+    .qdev.name = "aer915",
+    .qdev.size = sizeof(AER915State),
+    .qdev.vmsd = &vmstate_aer915_state,
+    .init = aer915_init,
+    .event = aer915_event,
+    .recv = aer915_recv,
+    .send = aer915_send
+};
+
+static void z2_init(ram_addr_t ram_size,
+                const char *boot_device,
+                const char *kernel_filename, const char *kernel_cmdline,
+                const char *initrd_filename, const char *cpu_model)
+{
+    uint32_t sector_len = 0x10000;
+    PXA2xxState *cpu;
+    DriveInfo *dinfo;
+    int be;
+    void *z2_lcd;
+    i2c_bus *bus;
+    DeviceState *wm;
+
+    if (!cpu_model) {
+        cpu_model = "pxa270-c5";
+    }
+
+    /* Setup CPU & memory */
+    cpu = pxa270_init(z2_binfo.ram_size, cpu_model);
+
+#ifdef TARGET_WORDS_BIGENDIAN
+    be = 1;
+#else
+    be = 0;
+#endif
+    dinfo = drive_get(IF_PFLASH, 0, 0);
+    if (!dinfo) {
+        fprintf(stderr, "Flash image must be given with the "
+                "'pflash' parameter\n");
+        exit(1);
+    }
+
+    if (!pflash_cfi01_register(Z2_FLASH_BASE,
+                               qemu_ram_alloc(NULL, "z2.flash0", Z2_FLASH_SIZE),
+                               dinfo->bdrv, sector_len,
+                               Z2_FLASH_SIZE / sector_len, 4, 0, 0, 0, 0,
+                               be)) {
+        fprintf(stderr, "qemu: Error registering flash memory.\n");
+        exit(1);
+    }
+
+    /* setup keypad */
+    pxa27x_register_keypad(cpu->kp, map, 0x100);
+
+    /* MMC/SD host */
+    pxa2xx_mmci_handlers(cpu->mmc,
+        NULL,
+        qdev_get_gpio_in(cpu->gpio, Z2_GPIO_SD_DETECT));
+
+    ssi_register_slave(&zipit_lcd_info);
+    i2c_register_slave(&aer915_info);
+    z2_lcd = ssi_create_slave(cpu->ssp[1], "zipit-lcd");
+    bus = pxa2xx_i2c_bus(cpu->i2c[0]);
+    i2c_create_slave(bus, "aer915", 0x55);
+    wm = i2c_create_slave(bus, "wm8750", 0x1b);
+    cpu->i2s->opaque = wm;
+    cpu->i2s->codec_out = wm8750_dac_dat;
+    cpu->i2s->codec_in = wm8750_adc_dat;
+    wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
+
+    qdev_connect_gpio_out(cpu->gpio, Z2_GPIO_LCD_CS,
+        qemu_allocate_irqs(z2_lcd_cs, z2_lcd, 1)[0]);
+
+    if (kernel_filename) {
+        z2_binfo.kernel_filename = kernel_filename;
+        z2_binfo.kernel_cmdline = kernel_cmdline;
+        z2_binfo.initrd_filename = initrd_filename;
+        z2_binfo.board_id = 0x6dd;
+        arm_load_kernel(cpu->env, &z2_binfo);
+    }
+}
+
+static QEMUMachine z2_machine = {
+    .name = "z2",
+    .desc = "Zipit Z2 (PXA27x)",
+    .init = z2_init,
+};
+
+static void z2_machine_init(void)
+{
+    qemu_register_machine(&z2_machine);
+}
+
+machine_init(z2_machine_init);
-- 
1.7.5.rc3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/2] pxa2xx_lcd: add proper rotation support
  2011-06-17 10:04             ` [Qemu-devel] [PATCH v4 " Vasily Khoruzhick
  2011-06-17 10:04               ` [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
@ 2011-06-21  9:47               ` Vasily Khoruzhick
  2011-07-04 20:11               ` andrzej zaborowski
  2 siblings, 0 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-21  9:47 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Friday 17 June 2011 13:04:36 Vasily Khoruzhick wrote:
> Until now, pxa2xx_lcd only supported 90deg rotation, but
> some machines (for example Zipit Z2) needs 270deg rotation.

Ping

> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
> v2: codestyle fixes
> v3: fix dpy_update calls for 180 and 360 deg. rotation.
> v4: codestyle fixes; replace atoi with strtol
>  hw/framebuffer.c |    3 +
>  hw/pxa2xx_lcd.c  |  109
> ++++++++++++++++++++++++++++++++++++++++++++++++------ input.c          | 
>  34 ++++++++++++----
>  qemu-options.hx  |    9 ++++
>  vl.c             |   11 +++++-
>  5 files changed, 144 insertions(+), 22 deletions(-)
> 
> diff --git a/hw/framebuffer.c b/hw/framebuffer.c
> index 24cdf25..56cf16e 100644
> --- a/hw/framebuffer.c
> +++ b/hw/framebuffer.c
> @@ -78,6 +78,9 @@ void framebuffer_update_display(
>      dest = ds_get_data(ds);
>      if (dest_col_pitch < 0)
>          dest -= dest_col_pitch * (cols - 1);
> +    if (dest_row_pitch < 0) {
> +        dest -= dest_row_pitch * (rows - 1);
> +    }
>      first = -1;
>      addr = pd;
> 
> diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c
> index e524802..a5f8c51 100644
> --- a/hw/pxa2xx_lcd.c
> +++ b/hw/pxa2xx_lcd.c
> @@ -665,7 +665,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int
> ch, int bpp) }
>  }
> 
> -static void pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s,
> +static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s,
>                  target_phys_addr_t addr, int *miny, int *maxy)
>  {
>      int src_width, dest_width;
> @@ -692,7 +692,7 @@ static void
> pxa2xx_lcdc_dma0_redraw_horiz(PXA2xxLCDState *s, fn, s->dma_ch[0].palette,
> miny, maxy); }
> 
> -static void pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s,
> +static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s,
>                 target_phys_addr_t addr, int *miny, int *maxy)
>  {
>      int src_width, dest_width;
> @@ -720,6 +720,67 @@ static void
> pxa2xx_lcdc_dma0_redraw_vert(PXA2xxLCDState *s, miny, maxy);
>  }
> 
> +static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
> +                target_phys_addr_t addr, int *miny, int *maxy)
> +{
> +    int src_width, dest_width;
> +    drawfn fn = NULL;
> +    if (s->dest_width) {
> +        fn = s->line_fn[s->transp][s->bpp];
> +    }
> +    if (!fn) {
> +        return;
> +    }
> +
> +    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
> +    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp) {
> +        src_width *= 3;
> +    } else if (s->bpp > pxa_lcdc_16bpp) {
> +        src_width *= 4;
> +    } else if (s->bpp > pxa_lcdc_8bpp) {
> +        src_width *= 2;
> +    }
> +
> +    dest_width = s->xres * s->dest_width;
> +    *miny = 0;
> +    framebuffer_update_display(s->ds,
> +                               addr, s->xres, s->yres,
> +                               src_width, -dest_width, -s->dest_width,
> +                               s->invalidated,
> +                               fn, s->dma_ch[0].palette, miny, maxy);
> +}
> +
> +static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s,
> +               target_phys_addr_t addr, int *miny, int *maxy)
> +{
> +    int src_width, dest_width;
> +    drawfn fn = NULL;
> +    if (s->dest_width) {
> +        fn = s->line_fn[s->transp][s->bpp];
> +    }
> +    if (!fn) {
> +        return;
> +    }
> +
> +    src_width = (s->xres + 3) & ~3;     /* Pad to a 4 pixels multiple */
> +    if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp) {
> +        src_width *= 3;
> +    } else if (s->bpp > pxa_lcdc_16bpp) {
> +        src_width *= 4;
> +    } else if (s->bpp > pxa_lcdc_8bpp) {
> +        src_width *= 2;
> +    }
> +
> +    dest_width = s->yres * s->dest_width;
> +    *miny = 0;
> +    framebuffer_update_display(s->ds,
> +                               addr, s->xres, s->yres,
> +                               src_width, -s->dest_width, dest_width,
> +                               s->invalidated,
> +                               fn, s->dma_ch[0].palette,
> +                               miny, maxy);
> +}
> +
>  static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
>  {
>      int width, height;
> @@ -730,10 +791,11 @@ static void pxa2xx_lcdc_resize(PXA2xxLCDState *s)
>      height = LCCR2_LPP(s->control[2]) + 1;
> 
>      if (width != s->xres || height != s->yres) {
> -        if (s->orientation)
> +        if (s->orientation == 90 || s->orientation == 270) {
>              qemu_console_resize(s->ds, height, width);
> -        else
> +        } else {
>              qemu_console_resize(s->ds, width, height);
> +        }
>          s->invalidated = 1;
>          s->xres = width;
>          s->yres = height;
> @@ -797,10 +859,24 @@ static void pxa2xx_update_display(void *opaque)
>      }
> 
>      if (miny >= 0) {
> -        if (s->orientation)
> -            dpy_update(s->ds, miny, 0, maxy - miny, s->xres);
> -        else
> -            dpy_update(s->ds, 0, miny, s->xres, maxy - miny);
> +        switch (s->orientation) {
> +        case 0:
> +            dpy_update(s->ds, 0, miny, s->xres, maxy - miny + 1);
> +            break;
> +        case 90:
> +            dpy_update(s->ds, miny, 0, maxy - miny + 1, s->xres);
> +            break;
> +        case 180:
> +            maxy = s->yres - maxy - 1;
> +            miny = s->yres - miny - 1;
> +            dpy_update(s->ds, 0, maxy, s->xres, miny - maxy + 1);
> +            break;
> +        case 270:
> +            maxy = s->yres - maxy - 1;
> +            miny = s->yres - miny - 1;
> +            dpy_update(s->ds, maxy, 0, miny - maxy + 1, s->xres);
> +            break;
> +        }
>      }
>      pxa2xx_lcdc_int_update(s);
> 
> @@ -822,10 +898,19 @@ static void pxa2xx_lcdc_orientation(void *opaque, int
> angle) {
>      PXA2xxLCDState *s = (PXA2xxLCDState *) opaque;
> 
> -    if (angle) {
> -        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_vert;
> -    } else {
> -        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_horiz;
> +    switch (angle) {
> +    case 0:
> +        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot0;
> +        break;
> +    case 90:
> +        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot90;
> +        break;
> +    case 180:
> +        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot180;
> +        break;
> +    case 270:
> +        s->dma_ch[0].redraw = pxa2xx_lcdc_dma0_redraw_rot270;
> +        break;
>      }
> 
>      s->orientation = angle;
> diff --git a/input.c b/input.c
> index 5664d3a..f0a02e7 100644
> --- a/input.c
> +++ b/input.c
> @@ -148,7 +148,7 @@ void kbd_mouse_event(int dx, int dy, int dz, int
> buttons_state) QEMUPutMouseEntry *entry;
>      QEMUPutMouseEvent *mouse_event;
>      void *mouse_event_opaque;
> -    int width;
> +    int width, height;
> 
>      if (QTAILQ_EMPTY(&mouse_handlers)) {
>          return;
> @@ -160,15 +160,31 @@ void kbd_mouse_event(int dx, int dy, int dz, int
> buttons_state) mouse_event_opaque = entry->qemu_put_mouse_event_opaque;
> 
>      if (mouse_event) {
> -        if (graphic_rotate) {
> -            if (entry->qemu_put_mouse_event_absolute) {
> -                width = 0x7fff;
> -            } else {
> -                width = graphic_width - 1;
> -            }
> -            mouse_event(mouse_event_opaque, width - dy, dx, dz,
> buttons_state); +        if (entry->qemu_put_mouse_event_absolute) {
> +            width = 0x7fff;
> +            height = 0x7fff;
>          } else {
> -            mouse_event(mouse_event_opaque, dx, dy, dz, buttons_state);
> +            width = graphic_width - 1;
> +            height = graphic_height - 1;
> +        }
> +
> +        switch (graphic_rotate) {
> +        case 0:
> +            mouse_event(mouse_event_opaque,
> +                        dx, dy, dz, buttons_state);
> +            break;
> +        case 90:
> +            mouse_event(mouse_event_opaque,
> +                        width - dy, dx, dz, buttons_state);
> +            break;
> +        case 180:
> +            mouse_event(mouse_event_opaque,
> +                        width - dx, height - dy, dz, buttons_state);
> +            break;
> +        case 270:
> +            mouse_event(mouse_event_opaque,
> +                        dy, height - dx, dz, buttons_state);
> +            break;
>          }
>      }
>  }
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 82e085a..46d8f25 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -771,6 +771,15 @@ STEXI
>  Rotate graphical output 90 deg left (only PXA LCD).
>  ETEXI
> 
> +DEF("rotate", HAS_ARG, QEMU_OPTION_rotate,
> +    "-rotate <deg>   rotate graphical output some deg left (only PXA
> LCD)\n", +    QEMU_ARCH_ALL)
> +STEXI
> +@item -rotate
> +@findex -rotate
> +Rotate graphical output some deg left (only PXA LCD).
> +ETEXI
> +
>  DEF("vga", HAS_ARG, QEMU_OPTION_vga,
>      "-vga [std|cirrus|vmware|qxl|xenfb|none]\n"
>      "                select video card type\n", QEMU_ARCH_ALL)
> diff --git a/vl.c b/vl.c
> index b362871..c11cc44 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2289,7 +2289,16 @@ int main(int argc, char **argv, char **envp)
>  #endif
>                  break;
>              case QEMU_OPTION_portrait:
> -                graphic_rotate = 1;
> +                graphic_rotate = 90;
> +                break;
> +            case QEMU_OPTION_rotate:
> +                graphic_rotate = strtol(optarg, (char **)&optarg, 10);
> +                if (graphic_rotate != 0 && graphic_rotate != 90 &&
> +                    graphic_rotate != 180 && graphic_rotate != 270) {
> +                    fprintf(stderr,
> +                        "qemu: only 90, 180, 270 deg rotation is
> available\n"); +                    exit(1);
> +                }
>                  break;
>              case QEMU_OPTION_kernel:
>                  kernel_filename = optarg;

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine
  2011-06-17 10:04               ` [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
@ 2011-06-21  9:47                 ` Vasily Khoruzhick
  2011-06-24 14:45                 ` Peter Maydell
  1 sibling, 0 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-21  9:47 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Friday 17 June 2011 13:04:37 Vasily Khoruzhick wrote:
> Zipit Z2 is small PXA270 based handheld.

Ping

> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
> v2: codestyle fixes, added VMStateDescription for LCD device and AER915,
>     traces clean up.
> v3: no changes
> v4: no changes
>  Makefile.target |    1 +
>  hw/z2.c         |  352
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed,
> 353 insertions(+), 0 deletions(-)
>  create mode 100644 hw/z2.c
> 
> diff --git a/Makefile.target b/Makefile.target
> index 602d50d..5750499 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -358,6 +358,7 @@ obj-arm-y += omap2.o omap_dss.o soc_dma.o
> omap_gptimer.o omap_synctimer.o \ obj-arm-y += omap_sx1.o palm.o tsc210x.o
>  obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o
> usb-musb.o obj-arm-y += mst_fpga.o mainstone.o
> +obj-arm-y += z2.o
>  obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o
>  obj-arm-y += framebuffer.o
>  obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
> diff --git a/hw/z2.c b/hw/z2.c
> new file mode 100644
> index 0000000..3e3591a
> --- /dev/null
> +++ b/hw/z2.c
> @@ -0,0 +1,352 @@
> +/*
> + * PXA270-based Zipit Z2 device
> + *
> + * Copyright (c) 2011 by Vasily Khoruzhick <anarsoul@gmail.com>
> + *
> + * Code is based on mainstone platform.
> + *
> + * This code is licensed under the GNU GPL v2.
> + */
> +
> +#include "hw.h"
> +#include "pxa.h"
> +#include "arm-misc.h"
> +#include "devices.h"
> +#include "i2c.h"
> +#include "ssi.h"
> +#include "boards.h"
> +#include "sysemu.h"
> +#include "flash.h"
> +#include "blockdev.h"
> +#include "console.h"
> +#include "audio/audio.h"
> +
> +#if 0
> +#define DPRINTF(fmt, ...) \
> +        printf(fmt, ## __VA_ARGS__)
> +#else
> +#define DPRINTF(fmt, ...)
> +#endif
> +
> +static struct keymap map[0x100] = {
> +    [0 ... 0xff] = { -1, -1 },
> +    [0x3b] = {0, 0}, /* Option = F1 */
> +    [0xc8] = {0, 1}, /* Up */
> +    [0xd0] = {0, 2}, /* Down */
> +    [0xcb] = {0, 3}, /* Left */
> +    [0xcd] = {0, 4}, /* Right */
> +    [0xcf] = {0, 5}, /* End */
> +    [0x0d] = {0, 6}, /* KPPLUS */
> +    [0xc7] = {1, 0}, /* Home */
> +    [0x10] = {1, 1}, /* Q */
> +    [0x17] = {1, 2}, /* I */
> +    [0x22] = {1, 3}, /* G */
> +    [0x2d] = {1, 4}, /* X */
> +    [0x1c] = {1, 5}, /* Enter */
> +    [0x0c] = {1, 6}, /* KPMINUS */
> +    [0xc9] = {2, 0}, /* PageUp */
> +    [0x11] = {2, 1}, /* W */
> +    [0x18] = {2, 2}, /* O */
> +    [0x23] = {2, 3}, /* H */
> +    [0x2e] = {2, 4}, /* C */
> +    [0x38] = {2, 5}, /* LeftAlt */
> +    [0xd1] = {3, 0}, /* PageDown */
> +    [0x12] = {3, 1}, /* E */
> +    [0x19] = {3, 2}, /* P */
> +    [0x24] = {3, 3}, /* J */
> +    [0x2f] = {3, 4}, /* V */
> +    [0x2a] = {3, 5}, /* LeftShift */
> +    [0x01] = {4, 0}, /* Esc */
> +    [0x13] = {4, 1}, /* R */
> +    [0x1e] = {4, 2}, /* A */
> +    [0x25] = {4, 3}, /* K */
> +    [0x30] = {4, 4}, /* B */
> +    [0x1d] = {4, 5}, /* LeftCtrl */
> +    [0x0f] = {5, 0}, /* Tab */
> +    [0x14] = {5, 1}, /* T */
> +    [0x1f] = {5, 2}, /* S */
> +    [0x26] = {5, 3}, /* L */
> +    [0x31] = {5, 4}, /* N */
> +    [0x39] = {5, 5}, /* Space */
> +    [0x3c] = {6, 0}, /* Stop = F2 */
> +    [0x15] = {6, 1}, /* Y */
> +    [0x20] = {6, 2}, /* D */
> +    [0x0e] = {6, 3}, /* Backspace */
> +    [0x32] = {6, 4}, /* M */
> +    [0x33] = {6, 5}, /* Comma */
> +    [0x3d] = {7, 0}, /* Play = F3 */
> +    [0x16] = {7, 1}, /* U */
> +    [0x21] = {7, 2}, /* F */
> +    [0x2c] = {7, 3}, /* Z */
> +    [0x27] = {7, 4}, /* Semicolon */
> +    [0x34] = {7, 5}, /* Dot */
> +};
> +
> +#define Z2_RAM_SIZE     0x02000000
> +#define Z2_FLASH_BASE   0x00000000
> +#define Z2_FLASH_SIZE   0x00800000
> +
> +static struct arm_boot_info z2_binfo = {
> +    .loader_start   = PXA2XX_SDRAM_BASE,
> +    .ram_size       = Z2_RAM_SIZE,
> +};
> +
> +#define Z2_GPIO_SD_DETECT   96
> +#define Z2_GPIO_AC_IN       0
> +#define Z2_GPIO_KEY_ON      1
> +#define Z2_GPIO_LCD_CS      88
> +
> +typedef struct {
> +    SSISlave ssidev;
> +    int32_t selected;
> +    int32_t enabled;
> +    uint8_t buf[3];
> +    uint32_t cur_reg;
> +    int pos;
> +} ZipitLCD;
> +
> +static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value)
> +{
> +    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
> +    uint16_t val;
> +    if (z->selected) {
> +        z->buf[z->pos] = value & 0xff;
> +        z->pos++;
> +    }
> +    if (z->pos == 3) {
> +        switch (z->buf[0]) {
> +        case 0x74:
> +            DPRINTF("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
> +            z->cur_reg = z->buf[2];
> +            break;
> +        case 0x76:
> +            val = z->buf[1] << 8 | z->buf[2];
> +            DPRINTF("%s: value: 0x%.4x\n", __func__, val);
> +            if (z->cur_reg == 0x22 && val == 0x0000) {
> +                z->enabled = 1;
> +                printf("%s: LCD enabled\n", __func__);
> +            } else if (z->cur_reg == 0x10 && val == 0x0000) {
> +                z->enabled = 0;
> +                printf("%s: LCD disabled\n", __func__);
> +            }
> +            break;
> +        default:
> +            fprintf(stderr, "%s: unknown command!\n", __func__);
> +            break;
> +        }
> +        z->pos = 0;
> +    }
> +    return 0;
> +}
> +
> +static void z2_lcd_cs(void *opaque, int line, int level)
> +{
> +    ZipitLCD *z2_lcd = opaque;
> +    z2_lcd->selected = !level;
> +}
> +
> +static int zipit_lcd_init(SSISlave *dev)
> +{
> +    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
> +    z->selected = 0;
> +    z->enabled = 0;
> +    z->pos = 0;
> +
> +    return 0;
> +}
> +
> +static VMStateDescription vmstate_zipit_lcd_state = {
> +    .name = "zipit-lcd",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_INT32(enabled, ZipitLCD),
> +        VMSTATE_END_OF_LIST(),
> +    }
> +};
> +
> +static SSISlaveInfo zipit_lcd_info = {
> +    .qdev.name = "zipit-lcd",
> +    .qdev.size = sizeof(ZipitLCD),
> +    .qdev.vmsd = &vmstate_zipit_lcd_state,
> +    .init = zipit_lcd_init,
> +    .transfer = zipit_lcd_transfer
> +};
> +
> +typedef struct {
> +    i2c_slave i2c;
> +    int len;
> +    char buf[3];
> +} AER915State;
> +
> +static int aer915_send(i2c_slave *i2c, uint8_t data)
> +{
> +    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
> +    s->buf[s->len] = data;
> +    if (s->len++ > 2) {
> +        fprintf(stderr, "%s: message too long (%i bytes)\n",
> +            __func__, s->len);
> +        return 1;
> +    }
> +
> +    if (s->len == 2) {
> +        DPRINTF("%s: reg %d value 0x%02x\n", __func__,
> +                s->buf[0], s->buf[1]);
> +    }
> +
> +    return 0;
> +}
> +
> +static void aer915_event(i2c_slave *i2c, enum i2c_event event)
> +{
> +    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
> +    switch (event) {
> +    case I2C_START_SEND:
> +        s->len = 0;
> +        break;
> +    case I2C_START_RECV:
> +        if (s->len != 1) {
> +            fprintf(stderr, "%s: short message!?\n", __func__);
> +        }
> +        break;
> +    case I2C_FINISH:
> +        break;
> +    default:
> +        break;
> +    }
> +}
> +
> +static int aer915_recv(i2c_slave *slave)
> +{
> +    int retval = 0x00;
> +    AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
> +
> +    switch (s->buf[0]) {
> +    /* Return hardcoded battery voltage,
> +     * 0xf0 means ~4.1V
> +     */
> +    case 0x02:
> +        retval = 0xf0;
> +        break;
> +    /* Return 0x00 for other regs,
> +     * we don't know what they are for,
> +     * anyway they return 0x00 on real hardware.
> +     */
> +    default:
> +        break;
> +    }
> +
> +    return retval;
> +}
> +
> +static int aer915_init(i2c_slave *i2c)
> +{
> +    /* Nothing to do.  */
> +    return 0;
> +}
> +
> +static VMStateDescription vmstate_aer915_state = {
> +    .name = "aer915",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_END_OF_LIST(),
> +    }
> +};
> +
> +static I2CSlaveInfo aer915_info = {
> +    .qdev.name = "aer915",
> +    .qdev.size = sizeof(AER915State),
> +    .qdev.vmsd = &vmstate_aer915_state,
> +    .init = aer915_init,
> +    .event = aer915_event,
> +    .recv = aer915_recv,
> +    .send = aer915_send
> +};
> +
> +static void z2_init(ram_addr_t ram_size,
> +                const char *boot_device,
> +                const char *kernel_filename, const char *kernel_cmdline,
> +                const char *initrd_filename, const char *cpu_model)
> +{
> +    uint32_t sector_len = 0x10000;
> +    PXA2xxState *cpu;
> +    DriveInfo *dinfo;
> +    int be;
> +    void *z2_lcd;
> +    i2c_bus *bus;
> +    DeviceState *wm;
> +
> +    if (!cpu_model) {
> +        cpu_model = "pxa270-c5";
> +    }
> +
> +    /* Setup CPU & memory */
> +    cpu = pxa270_init(z2_binfo.ram_size, cpu_model);
> +
> +#ifdef TARGET_WORDS_BIGENDIAN
> +    be = 1;
> +#else
> +    be = 0;
> +#endif
> +    dinfo = drive_get(IF_PFLASH, 0, 0);
> +    if (!dinfo) {
> +        fprintf(stderr, "Flash image must be given with the "
> +                "'pflash' parameter\n");
> +        exit(1);
> +    }
> +
> +    if (!pflash_cfi01_register(Z2_FLASH_BASE,
> +                               qemu_ram_alloc(NULL, "z2.flash0",
> Z2_FLASH_SIZE), +                               dinfo->bdrv, sector_len,
> +                               Z2_FLASH_SIZE / sector_len, 4, 0, 0, 0, 0,
> +                               be)) {
> +        fprintf(stderr, "qemu: Error registering flash memory.\n");
> +        exit(1);
> +    }
> +
> +    /* setup keypad */
> +    pxa27x_register_keypad(cpu->kp, map, 0x100);
> +
> +    /* MMC/SD host */
> +    pxa2xx_mmci_handlers(cpu->mmc,
> +        NULL,
> +        qdev_get_gpio_in(cpu->gpio, Z2_GPIO_SD_DETECT));
> +
> +    ssi_register_slave(&zipit_lcd_info);
> +    i2c_register_slave(&aer915_info);
> +    z2_lcd = ssi_create_slave(cpu->ssp[1], "zipit-lcd");
> +    bus = pxa2xx_i2c_bus(cpu->i2c[0]);
> +    i2c_create_slave(bus, "aer915", 0x55);
> +    wm = i2c_create_slave(bus, "wm8750", 0x1b);
> +    cpu->i2s->opaque = wm;
> +    cpu->i2s->codec_out = wm8750_dac_dat;
> +    cpu->i2s->codec_in = wm8750_adc_dat;
> +    wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
> +
> +    qdev_connect_gpio_out(cpu->gpio, Z2_GPIO_LCD_CS,
> +        qemu_allocate_irqs(z2_lcd_cs, z2_lcd, 1)[0]);
> +
> +    if (kernel_filename) {
> +        z2_binfo.kernel_filename = kernel_filename;
> +        z2_binfo.kernel_cmdline = kernel_cmdline;
> +        z2_binfo.initrd_filename = initrd_filename;
> +        z2_binfo.board_id = 0x6dd;
> +        arm_load_kernel(cpu->env, &z2_binfo);
> +    }
> +}
> +
> +static QEMUMachine z2_machine = {
> +    .name = "z2",
> +    .desc = "Zipit Z2 (PXA27x)",
> +    .init = z2_init,
> +};
> +
> +static void z2_machine_init(void)
> +{
> +    qemu_register_machine(&z2_machine);
> +}
> +
> +machine_init(z2_machine_init);

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine
  2011-06-17 10:04               ` [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
  2011-06-21  9:47                 ` Vasily Khoruzhick
@ 2011-06-24 14:45                 ` Peter Maydell
  2011-06-24 17:06                   ` Vasily Khoruzhick
  1 sibling, 1 reply; 26+ messages in thread
From: Peter Maydell @ 2011-06-24 14:45 UTC (permalink / raw)
  To: Vasily Khoruzhick; +Cc: qemu-devel

On 17 June 2011 11:04, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> Zipit Z2 is small PXA270 based handheld.
>
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>

These patches are affected by the bug in current qemu master
which breaks cpu_physical_memory_map() so I haven't tested them yet.
Some minor nitpicks (nearly there now):

> +            if (z->cur_reg == 0x22 && val == 0x0000) {
> +                z->enabled = 1;
> +                printf("%s: LCD enabled\n", __func__);
> +            } else if (z->cur_reg == 0x10 && val == 0x0000) {
> +                z->enabled = 0;
> +                printf("%s: LCD disabled\n", __func__);
> +            }

Drop or use DPRINTF for these printfs, please.

> +            break;
> +        default:
> +            fprintf(stderr, "%s: unknown command!\n", __func__);

Ditto.

> +static VMStateDescription vmstate_zipit_lcd_state = {
> +    .name = "zipit-lcd",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_INT32(enabled, ZipitLCD),
> +        VMSTATE_END_OF_LIST(),
> +    }
> +};

This is missing fields for selected, buf[] and cur_reg.

> +    if (s->len++ > 2) {
> +        fprintf(stderr, "%s: message too long (%i bytes)\n",
> +            __func__, s->len);
> +        return 1;
> +    }

DPRINTF.

> +    case I2C_START_RECV:
> +        if (s->len != 1) {
> +            fprintf(stderr, "%s: short message!?\n", __func__);
> +        }
> +        break;

Ditto.

> +static VMStateDescription vmstate_aer915_state = {
> +    .name = "aer915",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_END_OF_LIST(),
> +    }
> +};

Missing fields for len and buf[].

Looks ok otherwise. (Patch 1 looks ok too.)

Have you tried vmload/vmsave, by the way? (I don't know if all the
devices the pxa2xx uses have save/load support implemented, it
would be interesting to check if you haven't already.)

-- PMM

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine
  2011-06-24 14:45                 ` Peter Maydell
@ 2011-06-24 17:06                   ` Vasily Khoruzhick
  2011-06-24 17:16                     ` Peter Maydell
  0 siblings, 1 reply; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-06-24 17:06 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Friday 24 June 2011 17:45:06 Peter Maydell wrote:
> On 17 June 2011 11:04, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> > Zipit Z2 is small PXA270 based handheld.
> > 
> > Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> 
> These patches are affected by the bug in current qemu master
> which breaks cpu_physical_memory_map() so I haven't tested them yet.
> 
> Some minor nitpicks (nearly there now):
> > +            if (z->cur_reg == 0x22 && val == 0x0000) {
> > +                z->enabled = 1;
> > +                printf("%s: LCD enabled\n", __func__);
> > +            } else if (z->cur_reg == 0x10 && val == 0x0000) {
> > +                z->enabled = 0;
> > +                printf("%s: LCD disabled\n", __func__);
> > +            }
> 
> Drop or use DPRINTF for these printfs, please.

Hm, I'd like to keep them to see then software enables or disables LCD.

> > +            break;
> > +        default:
> > +            fprintf(stderr, "%s: unknown command!\n", __func__);
> 
> Ditto.

Ok

> > +static VMStateDescription vmstate_zipit_lcd_state = {
> > +    .name = "zipit-lcd",
> > +    .version_id = 1,
> > +    .minimum_version_id = 1,
> > +    .minimum_version_id_old = 1,
> > +    .fields = (VMStateField[]) {
> > +        VMSTATE_INT32(enabled, ZipitLCD),
> > +        VMSTATE_END_OF_LIST(),
> > +    }
> > +};
> 
> This is missing fields for selected, buf[] and cur_reg.
> 
> > +    if (s->len++ > 2) {
> > +        fprintf(stderr, "%s: message too long (%i bytes)\n",
> > +            __func__, s->len);
> > +        return 1;
> > +    }
> 
> DPRINTF.

Ok

> > +    case I2C_START_RECV:
> > +        if (s->len != 1) {
> > +            fprintf(stderr, "%s: short message!?\n", __func__);
> > +        }
> > +        break;
> 
> Ditto.

Ok

> > +static VMStateDescription vmstate_aer915_state = {
> > +    .name = "aer915",
> > +    .version_id = 1,
> > +    .minimum_version_id = 1,
> > +    .minimum_version_id_old = 1,
> > +    .fields = (VMStateField[]) {
> > +        VMSTATE_END_OF_LIST(),
> > +    }
> > +};
> 
> Missing fields for len and buf[].
> 
> Looks ok otherwise. (Patch 1 looks ok too.)
> 
> Have you tried vmload/vmsave, by the way? (I don't know if all the
> devices the pxa2xx uses have save/load support implemented, it
> would be interesting to check if you haven't already.)

Nope, how to try vmload/vmsave?

> -- PMM

Thanks for review.

Regards
Vasily

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine
  2011-06-24 17:06                   ` Vasily Khoruzhick
@ 2011-06-24 17:16                     ` Peter Maydell
  2011-07-06 13:52                       ` [Qemu-devel] [PATCH v5] " Vasily Khoruzhick
  0 siblings, 1 reply; 26+ messages in thread
From: Peter Maydell @ 2011-06-24 17:16 UTC (permalink / raw)
  To: Vasily Khoruzhick; +Cc: qemu-devel

On 24 June 2011 18:06, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> On Friday 24 June 2011 17:45:06 Peter Maydell wrote:
>> Have you tried vmload/vmsave, by the way? (I don't know if all the
>> devices the pxa2xx uses have save/load support implemented, it
>> would be interesting to check if you haven't already.)
>
> Nope, how to try vmload/vmsave?

You'll need your sd card to be on an image format that supports
snapshots (use 'qemu-img convert' to convert it to qcow2). Then
you can use the monitor command 'savevm savename' to save a
snapshot at any time. Reload an old snapshot with 'loadvm savename'
or use the qemu command line '-loadvm savename' to start immediately
from a snapshot.

If the reloaded image hangs or otherwise behaves badly that's
probably a sign that some device somewhere isn't restoring all
its state; usually most easily determined by code inspection
of all the devices that your machine instantiates.

-- PMM

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/2] pxa2xx_lcd: add proper rotation support
  2011-06-17 10:04             ` [Qemu-devel] [PATCH v4 " Vasily Khoruzhick
  2011-06-17 10:04               ` [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
  2011-06-21  9:47               ` [Qemu-devel] [PATCH v4 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
@ 2011-07-04 20:11               ` andrzej zaborowski
  2 siblings, 0 replies; 26+ messages in thread
From: andrzej zaborowski @ 2011-07-04 20:11 UTC (permalink / raw)
  To: Vasily Khoruzhick; +Cc: Peter Maydell, qemu-devel

On 17 June 2011 12:04, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> Until now, pxa2xx_lcd only supported 90deg rotation, but
> some machines (for example Zipit Z2) needs 270deg rotation.
>
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
> v2: codestyle fixes
> v3: fix dpy_update calls for 180 and 360 deg. rotation.
> v4: codestyle fixes; replace atoi with strtol

Thanks, I pushed this version.

Cheers

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [Qemu-devel] [PATCH v5] Add support for Zipit Z2 machine
  2011-06-24 17:16                     ` Peter Maydell
@ 2011-07-06 13:52                       ` Vasily Khoruzhick
  2011-07-11 15:26                         ` Vasily Khoruzhick
                                           ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-07-06 13:52 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel; +Cc: Vasily Khoruzhick

Zipit Z2 is small PXA270 based handheld.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
v2: codestyle fixes, added VMStateDescription for LCD device and AER915,
    traces clean up.
v3: no changes
v4: no changes
v5: use DPRINTF for debug-related traces, add missing fields to VMStateDescription for
    LCD device and AER915

 Makefile.target |    1 +
 hw/z2.c         |  358 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 359 insertions(+), 0 deletions(-)
 create mode 100644 hw/z2.c

diff --git a/Makefile.target b/Makefile.target
index a53a2ff..9ed230d 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -360,6 +360,7 @@ obj-arm-y += omap2.o omap_dss.o soc_dma.o omap_gptimer.o omap_synctimer.o \
 obj-arm-y += omap_sx1.o palm.o tsc210x.o
 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
 obj-arm-y += mst_fpga.o mainstone.o
+obj-arm-y += z2.o
 obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o
 obj-arm-y += framebuffer.o
 obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
diff --git a/hw/z2.c b/hw/z2.c
new file mode 100644
index 0000000..f93a1bf
--- /dev/null
+++ b/hw/z2.c
@@ -0,0 +1,358 @@
+/*
+ * PXA270-based Zipit Z2 device
+ *
+ * Copyright (c) 2011 by Vasily Khoruzhick <anarsoul@gmail.com>
+ *
+ * Code is based on mainstone platform.
+ *
+ * This code is licensed under the GNU GPL v2.
+ */
+
+#include "hw.h"
+#include "pxa.h"
+#include "arm-misc.h"
+#include "devices.h"
+#include "i2c.h"
+#include "ssi.h"
+#include "boards.h"
+#include "sysemu.h"
+#include "flash.h"
+#include "blockdev.h"
+#include "console.h"
+#include "audio/audio.h"
+
+#ifdef DEBUG_Z2
+#define DPRINTF(fmt, ...) \
+        printf(fmt, ## __VA_ARGS__)
+#else
+#define DPRINTF(fmt, ...)
+#endif
+
+static struct keymap map[0x100] = {
+    [0 ... 0xff] = { -1, -1 },
+    [0x3b] = {0, 0}, /* Option = F1 */
+    [0xc8] = {0, 1}, /* Up */
+    [0xd0] = {0, 2}, /* Down */
+    [0xcb] = {0, 3}, /* Left */
+    [0xcd] = {0, 4}, /* Right */
+    [0xcf] = {0, 5}, /* End */
+    [0x0d] = {0, 6}, /* KPPLUS */
+    [0xc7] = {1, 0}, /* Home */
+    [0x10] = {1, 1}, /* Q */
+    [0x17] = {1, 2}, /* I */
+    [0x22] = {1, 3}, /* G */
+    [0x2d] = {1, 4}, /* X */
+    [0x1c] = {1, 5}, /* Enter */
+    [0x0c] = {1, 6}, /* KPMINUS */
+    [0xc9] = {2, 0}, /* PageUp */
+    [0x11] = {2, 1}, /* W */
+    [0x18] = {2, 2}, /* O */
+    [0x23] = {2, 3}, /* H */
+    [0x2e] = {2, 4}, /* C */
+    [0x38] = {2, 5}, /* LeftAlt */
+    [0xd1] = {3, 0}, /* PageDown */
+    [0x12] = {3, 1}, /* E */
+    [0x19] = {3, 2}, /* P */
+    [0x24] = {3, 3}, /* J */
+    [0x2f] = {3, 4}, /* V */
+    [0x2a] = {3, 5}, /* LeftShift */
+    [0x01] = {4, 0}, /* Esc */
+    [0x13] = {4, 1}, /* R */
+    [0x1e] = {4, 2}, /* A */
+    [0x25] = {4, 3}, /* K */
+    [0x30] = {4, 4}, /* B */
+    [0x1d] = {4, 5}, /* LeftCtrl */
+    [0x0f] = {5, 0}, /* Tab */
+    [0x14] = {5, 1}, /* T */
+    [0x1f] = {5, 2}, /* S */
+    [0x26] = {5, 3}, /* L */
+    [0x31] = {5, 4}, /* N */
+    [0x39] = {5, 5}, /* Space */
+    [0x3c] = {6, 0}, /* Stop = F2 */
+    [0x15] = {6, 1}, /* Y */
+    [0x20] = {6, 2}, /* D */
+    [0x0e] = {6, 3}, /* Backspace */
+    [0x32] = {6, 4}, /* M */
+    [0x33] = {6, 5}, /* Comma */
+    [0x3d] = {7, 0}, /* Play = F3 */
+    [0x16] = {7, 1}, /* U */
+    [0x21] = {7, 2}, /* F */
+    [0x2c] = {7, 3}, /* Z */
+    [0x27] = {7, 4}, /* Semicolon */
+    [0x34] = {7, 5}, /* Dot */
+};
+
+#define Z2_RAM_SIZE     0x02000000
+#define Z2_FLASH_BASE   0x00000000
+#define Z2_FLASH_SIZE   0x00800000
+
+static struct arm_boot_info z2_binfo = {
+    .loader_start   = PXA2XX_SDRAM_BASE,
+    .ram_size       = Z2_RAM_SIZE,
+};
+
+#define Z2_GPIO_SD_DETECT   96
+#define Z2_GPIO_AC_IN       0
+#define Z2_GPIO_KEY_ON      1
+#define Z2_GPIO_LCD_CS      88
+
+typedef struct {
+    SSISlave ssidev;
+    int32_t selected;
+    int32_t enabled;
+    uint8_t buf[3];
+    uint32_t cur_reg;
+    int pos;
+} ZipitLCD;
+
+static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    uint16_t val;
+    if (z->selected) {
+        z->buf[z->pos] = value & 0xff;
+        z->pos++;
+    }
+    if (z->pos == 3) {
+        switch (z->buf[0]) {
+        case 0x74:
+            DPRINTF("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
+            z->cur_reg = z->buf[2];
+            break;
+        case 0x76:
+            val = z->buf[1] << 8 | z->buf[2];
+            DPRINTF("%s: value: 0x%.4x\n", __func__, val);
+            if (z->cur_reg == 0x22 && val == 0x0000) {
+                z->enabled = 1;
+                printf("%s: LCD enabled\n", __func__);
+            } else if (z->cur_reg == 0x10 && val == 0x0000) {
+                z->enabled = 0;
+                printf("%s: LCD disabled\n", __func__);
+            }
+            break;
+        default:
+            DPRINTF("%s: unknown command!\n", __func__);
+            break;
+        }
+        z->pos = 0;
+    }
+    return 0;
+}
+
+static void z2_lcd_cs(void *opaque, int line, int level)
+{
+    ZipitLCD *z2_lcd = opaque;
+    z2_lcd->selected = !level;
+}
+
+static int zipit_lcd_init(SSISlave *dev)
+{
+    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
+    z->selected = 0;
+    z->enabled = 0;
+    z->pos = 0;
+
+    return 0;
+}
+
+static VMStateDescription vmstate_zipit_lcd_state = {
+    .name = "zipit-lcd",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(selected, ZipitLCD),
+        VMSTATE_INT32(enabled, ZipitLCD),
+        VMSTATE_BUFFER(buf, ZipitLCD),
+        VMSTATE_UINT32(cur_reg, ZipitLCD),
+        VMSTATE_INT32(pos, ZipitLCD),
+        VMSTATE_END_OF_LIST(),
+    }
+};
+
+static SSISlaveInfo zipit_lcd_info = {
+    .qdev.name = "zipit-lcd",
+    .qdev.size = sizeof(ZipitLCD),
+    .qdev.vmsd = &vmstate_zipit_lcd_state,
+    .init = zipit_lcd_init,
+    .transfer = zipit_lcd_transfer
+};
+
+typedef struct {
+    i2c_slave i2c;
+    int len;
+    uint8_t buf[3];
+} AER915State;
+
+static int aer915_send(i2c_slave *i2c, uint8_t data)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    s->buf[s->len] = data;
+    if (s->len++ > 2) {
+        DPRINTF("%s: message too long (%i bytes)\n",
+            __func__, s->len);
+        return 1;
+    }
+
+    if (s->len == 2) {
+        DPRINTF("%s: reg %d value 0x%02x\n", __func__,
+                s->buf[0], s->buf[1]);
+    }
+
+    return 0;
+}
+
+static void aer915_event(i2c_slave *i2c, enum i2c_event event)
+{
+    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
+    switch (event) {
+    case I2C_START_SEND:
+        s->len = 0;
+        break;
+    case I2C_START_RECV:
+        if (s->len != 1) {
+            DPRINTF("%s: short message!?\n", __func__);
+        }
+        break;
+    case I2C_FINISH:
+        break;
+    default:
+        break;
+    }
+}
+
+static int aer915_recv(i2c_slave *slave)
+{
+    int retval = 0x00;
+    AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
+
+    switch (s->buf[0]) {
+    /* Return hardcoded battery voltage,
+     * 0xf0 means ~4.1V
+     */
+    case 0x02:
+        retval = 0xf0;
+        break;
+    /* Return 0x00 for other regs,
+     * we don't know what they are for,
+     * anyway they return 0x00 on real hardware.
+     */
+    default:
+        break;
+    }
+
+    return retval;
+}
+
+static int aer915_init(i2c_slave *i2c)
+{
+    /* Nothing to do.  */
+    return 0;
+}
+
+static VMStateDescription vmstate_aer915_state = {
+    .name = "aer915",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .minimum_version_id_old = 1,
+    .fields = (VMStateField[]) {
+        VMSTATE_INT32(len, AER915State),
+        VMSTATE_BUFFER(buf, AER915State),
+        VMSTATE_END_OF_LIST(),
+    }
+};
+
+static I2CSlaveInfo aer915_info = {
+    .qdev.name = "aer915",
+    .qdev.size = sizeof(AER915State),
+    .qdev.vmsd = &vmstate_aer915_state,
+    .init = aer915_init,
+    .event = aer915_event,
+    .recv = aer915_recv,
+    .send = aer915_send
+};
+
+static void z2_init(ram_addr_t ram_size,
+                const char *boot_device,
+                const char *kernel_filename, const char *kernel_cmdline,
+                const char *initrd_filename, const char *cpu_model)
+{
+    uint32_t sector_len = 0x10000;
+    PXA2xxState *cpu;
+    DriveInfo *dinfo;
+    int be;
+    void *z2_lcd;
+    i2c_bus *bus;
+    DeviceState *wm;
+
+    if (!cpu_model) {
+        cpu_model = "pxa270-c5";
+    }
+
+    /* Setup CPU & memory */
+    cpu = pxa270_init(z2_binfo.ram_size, cpu_model);
+
+#ifdef TARGET_WORDS_BIGENDIAN
+    be = 1;
+#else
+    be = 0;
+#endif
+    dinfo = drive_get(IF_PFLASH, 0, 0);
+    if (!dinfo) {
+        fprintf(stderr, "Flash image must be given with the "
+                "'pflash' parameter\n");
+        exit(1);
+    }
+
+    if (!pflash_cfi01_register(Z2_FLASH_BASE,
+                               qemu_ram_alloc(NULL, "z2.flash0", Z2_FLASH_SIZE),
+                               dinfo->bdrv, sector_len,
+                               Z2_FLASH_SIZE / sector_len, 4, 0, 0, 0, 0,
+                               be)) {
+        fprintf(stderr, "qemu: Error registering flash memory.\n");
+        exit(1);
+    }
+
+    /* setup keypad */
+    pxa27x_register_keypad(cpu->kp, map, 0x100);
+
+    /* MMC/SD host */
+    pxa2xx_mmci_handlers(cpu->mmc,
+        NULL,
+        qdev_get_gpio_in(cpu->gpio, Z2_GPIO_SD_DETECT));
+
+    ssi_register_slave(&zipit_lcd_info);
+    i2c_register_slave(&aer915_info);
+    z2_lcd = ssi_create_slave(cpu->ssp[1], "zipit-lcd");
+    bus = pxa2xx_i2c_bus(cpu->i2c[0]);
+    i2c_create_slave(bus, "aer915", 0x55);
+    wm = i2c_create_slave(bus, "wm8750", 0x1b);
+    cpu->i2s->opaque = wm;
+    cpu->i2s->codec_out = wm8750_dac_dat;
+    cpu->i2s->codec_in = wm8750_adc_dat;
+    wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
+
+    qdev_connect_gpio_out(cpu->gpio, Z2_GPIO_LCD_CS,
+        qemu_allocate_irqs(z2_lcd_cs, z2_lcd, 1)[0]);
+
+    if (kernel_filename) {
+        z2_binfo.kernel_filename = kernel_filename;
+        z2_binfo.kernel_cmdline = kernel_cmdline;
+        z2_binfo.initrd_filename = initrd_filename;
+        z2_binfo.board_id = 0x6dd;
+        arm_load_kernel(cpu->env, &z2_binfo);
+    }
+}
+
+static QEMUMachine z2_machine = {
+    .name = "z2",
+    .desc = "Zipit Z2 (PXA27x)",
+    .init = z2_init,
+};
+
+static void z2_machine_init(void)
+{
+    qemu_register_machine(&z2_machine);
+}
+
+machine_init(z2_machine_init);
-- 
1.7.5.rc3

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v5] Add support for Zipit Z2 machine
  2011-07-06 13:52                       ` [Qemu-devel] [PATCH v5] " Vasily Khoruzhick
@ 2011-07-11 15:26                         ` Vasily Khoruzhick
  2011-07-28  8:19                           ` Vasily Khoruzhick
  2011-07-12 17:31                         ` Peter Maydell
  2011-07-30  5:04                         ` andrzej zaborowski
  2 siblings, 1 reply; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-07-11 15:26 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Wednesday 06 July 2011 16:52:49 Vasily Khoruzhick wrote:
> Zipit Z2 is small PXA270 based handheld.

Ping?

> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
> v2: codestyle fixes, added VMStateDescription for LCD device and AER915,
>     traces clean up.
> v3: no changes
> v4: no changes
> v5: use DPRINTF for debug-related traces, add missing fields to
> VMStateDescription for LCD device and AER915
> 
>  Makefile.target |    1 +
>  hw/z2.c         |  358
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed,
> 359 insertions(+), 0 deletions(-)
>  create mode 100644 hw/z2.c
> 
> diff --git a/Makefile.target b/Makefile.target
> index a53a2ff..9ed230d 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -360,6 +360,7 @@ obj-arm-y += omap2.o omap_dss.o soc_dma.o
> omap_gptimer.o omap_synctimer.o \ obj-arm-y += omap_sx1.o palm.o tsc210x.o
>  obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o
> usb-musb.o obj-arm-y += mst_fpga.o mainstone.o
> +obj-arm-y += z2.o
>  obj-arm-y += musicpal.o bitbang_i2c.o marvell_88w8618_audio.o
>  obj-arm-y += framebuffer.o
>  obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
> diff --git a/hw/z2.c b/hw/z2.c
> new file mode 100644
> index 0000000..f93a1bf
> --- /dev/null
> +++ b/hw/z2.c
> @@ -0,0 +1,358 @@
> +/*
> + * PXA270-based Zipit Z2 device
> + *
> + * Copyright (c) 2011 by Vasily Khoruzhick <anarsoul@gmail.com>
> + *
> + * Code is based on mainstone platform.
> + *
> + * This code is licensed under the GNU GPL v2.
> + */
> +
> +#include "hw.h"
> +#include "pxa.h"
> +#include "arm-misc.h"
> +#include "devices.h"
> +#include "i2c.h"
> +#include "ssi.h"
> +#include "boards.h"
> +#include "sysemu.h"
> +#include "flash.h"
> +#include "blockdev.h"
> +#include "console.h"
> +#include "audio/audio.h"
> +
> +#ifdef DEBUG_Z2
> +#define DPRINTF(fmt, ...) \
> +        printf(fmt, ## __VA_ARGS__)
> +#else
> +#define DPRINTF(fmt, ...)
> +#endif
> +
> +static struct keymap map[0x100] = {
> +    [0 ... 0xff] = { -1, -1 },
> +    [0x3b] = {0, 0}, /* Option = F1 */
> +    [0xc8] = {0, 1}, /* Up */
> +    [0xd0] = {0, 2}, /* Down */
> +    [0xcb] = {0, 3}, /* Left */
> +    [0xcd] = {0, 4}, /* Right */
> +    [0xcf] = {0, 5}, /* End */
> +    [0x0d] = {0, 6}, /* KPPLUS */
> +    [0xc7] = {1, 0}, /* Home */
> +    [0x10] = {1, 1}, /* Q */
> +    [0x17] = {1, 2}, /* I */
> +    [0x22] = {1, 3}, /* G */
> +    [0x2d] = {1, 4}, /* X */
> +    [0x1c] = {1, 5}, /* Enter */
> +    [0x0c] = {1, 6}, /* KPMINUS */
> +    [0xc9] = {2, 0}, /* PageUp */
> +    [0x11] = {2, 1}, /* W */
> +    [0x18] = {2, 2}, /* O */
> +    [0x23] = {2, 3}, /* H */
> +    [0x2e] = {2, 4}, /* C */
> +    [0x38] = {2, 5}, /* LeftAlt */
> +    [0xd1] = {3, 0}, /* PageDown */
> +    [0x12] = {3, 1}, /* E */
> +    [0x19] = {3, 2}, /* P */
> +    [0x24] = {3, 3}, /* J */
> +    [0x2f] = {3, 4}, /* V */
> +    [0x2a] = {3, 5}, /* LeftShift */
> +    [0x01] = {4, 0}, /* Esc */
> +    [0x13] = {4, 1}, /* R */
> +    [0x1e] = {4, 2}, /* A */
> +    [0x25] = {4, 3}, /* K */
> +    [0x30] = {4, 4}, /* B */
> +    [0x1d] = {4, 5}, /* LeftCtrl */
> +    [0x0f] = {5, 0}, /* Tab */
> +    [0x14] = {5, 1}, /* T */
> +    [0x1f] = {5, 2}, /* S */
> +    [0x26] = {5, 3}, /* L */
> +    [0x31] = {5, 4}, /* N */
> +    [0x39] = {5, 5}, /* Space */
> +    [0x3c] = {6, 0}, /* Stop = F2 */
> +    [0x15] = {6, 1}, /* Y */
> +    [0x20] = {6, 2}, /* D */
> +    [0x0e] = {6, 3}, /* Backspace */
> +    [0x32] = {6, 4}, /* M */
> +    [0x33] = {6, 5}, /* Comma */
> +    [0x3d] = {7, 0}, /* Play = F3 */
> +    [0x16] = {7, 1}, /* U */
> +    [0x21] = {7, 2}, /* F */
> +    [0x2c] = {7, 3}, /* Z */
> +    [0x27] = {7, 4}, /* Semicolon */
> +    [0x34] = {7, 5}, /* Dot */
> +};
> +
> +#define Z2_RAM_SIZE     0x02000000
> +#define Z2_FLASH_BASE   0x00000000
> +#define Z2_FLASH_SIZE   0x00800000
> +
> +static struct arm_boot_info z2_binfo = {
> +    .loader_start   = PXA2XX_SDRAM_BASE,
> +    .ram_size       = Z2_RAM_SIZE,
> +};
> +
> +#define Z2_GPIO_SD_DETECT   96
> +#define Z2_GPIO_AC_IN       0
> +#define Z2_GPIO_KEY_ON      1
> +#define Z2_GPIO_LCD_CS      88
> +
> +typedef struct {
> +    SSISlave ssidev;
> +    int32_t selected;
> +    int32_t enabled;
> +    uint8_t buf[3];
> +    uint32_t cur_reg;
> +    int pos;
> +} ZipitLCD;
> +
> +static uint32_t zipit_lcd_transfer(SSISlave *dev, uint32_t value)
> +{
> +    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
> +    uint16_t val;
> +    if (z->selected) {
> +        z->buf[z->pos] = value & 0xff;
> +        z->pos++;
> +    }
> +    if (z->pos == 3) {
> +        switch (z->buf[0]) {
> +        case 0x74:
> +            DPRINTF("%s: reg: 0x%.2x\n", __func__, z->buf[2]);
> +            z->cur_reg = z->buf[2];
> +            break;
> +        case 0x76:
> +            val = z->buf[1] << 8 | z->buf[2];
> +            DPRINTF("%s: value: 0x%.4x\n", __func__, val);
> +            if (z->cur_reg == 0x22 && val == 0x0000) {
> +                z->enabled = 1;
> +                printf("%s: LCD enabled\n", __func__);
> +            } else if (z->cur_reg == 0x10 && val == 0x0000) {
> +                z->enabled = 0;
> +                printf("%s: LCD disabled\n", __func__);
> +            }
> +            break;
> +        default:
> +            DPRINTF("%s: unknown command!\n", __func__);
> +            break;
> +        }
> +        z->pos = 0;
> +    }
> +    return 0;
> +}
> +
> +static void z2_lcd_cs(void *opaque, int line, int level)
> +{
> +    ZipitLCD *z2_lcd = opaque;
> +    z2_lcd->selected = !level;
> +}
> +
> +static int zipit_lcd_init(SSISlave *dev)
> +{
> +    ZipitLCD *z = FROM_SSI_SLAVE(ZipitLCD, dev);
> +    z->selected = 0;
> +    z->enabled = 0;
> +    z->pos = 0;
> +
> +    return 0;
> +}
> +
> +static VMStateDescription vmstate_zipit_lcd_state = {
> +    .name = "zipit-lcd",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_INT32(selected, ZipitLCD),
> +        VMSTATE_INT32(enabled, ZipitLCD),
> +        VMSTATE_BUFFER(buf, ZipitLCD),
> +        VMSTATE_UINT32(cur_reg, ZipitLCD),
> +        VMSTATE_INT32(pos, ZipitLCD),
> +        VMSTATE_END_OF_LIST(),
> +    }
> +};
> +
> +static SSISlaveInfo zipit_lcd_info = {
> +    .qdev.name = "zipit-lcd",
> +    .qdev.size = sizeof(ZipitLCD),
> +    .qdev.vmsd = &vmstate_zipit_lcd_state,
> +    .init = zipit_lcd_init,
> +    .transfer = zipit_lcd_transfer
> +};
> +
> +typedef struct {
> +    i2c_slave i2c;
> +    int len;
> +    uint8_t buf[3];
> +} AER915State;
> +
> +static int aer915_send(i2c_slave *i2c, uint8_t data)
> +{
> +    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
> +    s->buf[s->len] = data;
> +    if (s->len++ > 2) {
> +        DPRINTF("%s: message too long (%i bytes)\n",
> +            __func__, s->len);
> +        return 1;
> +    }
> +
> +    if (s->len == 2) {
> +        DPRINTF("%s: reg %d value 0x%02x\n", __func__,
> +                s->buf[0], s->buf[1]);
> +    }
> +
> +    return 0;
> +}
> +
> +static void aer915_event(i2c_slave *i2c, enum i2c_event event)
> +{
> +    AER915State *s = FROM_I2C_SLAVE(AER915State, i2c);
> +    switch (event) {
> +    case I2C_START_SEND:
> +        s->len = 0;
> +        break;
> +    case I2C_START_RECV:
> +        if (s->len != 1) {
> +            DPRINTF("%s: short message!?\n", __func__);
> +        }
> +        break;
> +    case I2C_FINISH:
> +        break;
> +    default:
> +        break;
> +    }
> +}
> +
> +static int aer915_recv(i2c_slave *slave)
> +{
> +    int retval = 0x00;
> +    AER915State *s = FROM_I2C_SLAVE(AER915State, slave);
> +
> +    switch (s->buf[0]) {
> +    /* Return hardcoded battery voltage,
> +     * 0xf0 means ~4.1V
> +     */
> +    case 0x02:
> +        retval = 0xf0;
> +        break;
> +    /* Return 0x00 for other regs,
> +     * we don't know what they are for,
> +     * anyway they return 0x00 on real hardware.
> +     */
> +    default:
> +        break;
> +    }
> +
> +    return retval;
> +}
> +
> +static int aer915_init(i2c_slave *i2c)
> +{
> +    /* Nothing to do.  */
> +    return 0;
> +}
> +
> +static VMStateDescription vmstate_aer915_state = {
> +    .name = "aer915",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .minimum_version_id_old = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_INT32(len, AER915State),
> +        VMSTATE_BUFFER(buf, AER915State),
> +        VMSTATE_END_OF_LIST(),
> +    }
> +};
> +
> +static I2CSlaveInfo aer915_info = {
> +    .qdev.name = "aer915",
> +    .qdev.size = sizeof(AER915State),
> +    .qdev.vmsd = &vmstate_aer915_state,
> +    .init = aer915_init,
> +    .event = aer915_event,
> +    .recv = aer915_recv,
> +    .send = aer915_send
> +};
> +
> +static void z2_init(ram_addr_t ram_size,
> +                const char *boot_device,
> +                const char *kernel_filename, const char *kernel_cmdline,
> +                const char *initrd_filename, const char *cpu_model)
> +{
> +    uint32_t sector_len = 0x10000;
> +    PXA2xxState *cpu;
> +    DriveInfo *dinfo;
> +    int be;
> +    void *z2_lcd;
> +    i2c_bus *bus;
> +    DeviceState *wm;
> +
> +    if (!cpu_model) {
> +        cpu_model = "pxa270-c5";
> +    }
> +
> +    /* Setup CPU & memory */
> +    cpu = pxa270_init(z2_binfo.ram_size, cpu_model);
> +
> +#ifdef TARGET_WORDS_BIGENDIAN
> +    be = 1;
> +#else
> +    be = 0;
> +#endif
> +    dinfo = drive_get(IF_PFLASH, 0, 0);
> +    if (!dinfo) {
> +        fprintf(stderr, "Flash image must be given with the "
> +                "'pflash' parameter\n");
> +        exit(1);
> +    }
> +
> +    if (!pflash_cfi01_register(Z2_FLASH_BASE,
> +                               qemu_ram_alloc(NULL, "z2.flash0",
> Z2_FLASH_SIZE), +                               dinfo->bdrv, sector_len,
> +                               Z2_FLASH_SIZE / sector_len, 4, 0, 0, 0, 0,
> +                               be)) {
> +        fprintf(stderr, "qemu: Error registering flash memory.\n");
> +        exit(1);
> +    }
> +
> +    /* setup keypad */
> +    pxa27x_register_keypad(cpu->kp, map, 0x100);
> +
> +    /* MMC/SD host */
> +    pxa2xx_mmci_handlers(cpu->mmc,
> +        NULL,
> +        qdev_get_gpio_in(cpu->gpio, Z2_GPIO_SD_DETECT));
> +
> +    ssi_register_slave(&zipit_lcd_info);
> +    i2c_register_slave(&aer915_info);
> +    z2_lcd = ssi_create_slave(cpu->ssp[1], "zipit-lcd");
> +    bus = pxa2xx_i2c_bus(cpu->i2c[0]);
> +    i2c_create_slave(bus, "aer915", 0x55);
> +    wm = i2c_create_slave(bus, "wm8750", 0x1b);
> +    cpu->i2s->opaque = wm;
> +    cpu->i2s->codec_out = wm8750_dac_dat;
> +    cpu->i2s->codec_in = wm8750_adc_dat;
> +    wm8750_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
> +
> +    qdev_connect_gpio_out(cpu->gpio, Z2_GPIO_LCD_CS,
> +        qemu_allocate_irqs(z2_lcd_cs, z2_lcd, 1)[0]);
> +
> +    if (kernel_filename) {
> +        z2_binfo.kernel_filename = kernel_filename;
> +        z2_binfo.kernel_cmdline = kernel_cmdline;
> +        z2_binfo.initrd_filename = initrd_filename;
> +        z2_binfo.board_id = 0x6dd;
> +        arm_load_kernel(cpu->env, &z2_binfo);
> +    }
> +}
> +
> +static QEMUMachine z2_machine = {
> +    .name = "z2",
> +    .desc = "Zipit Z2 (PXA27x)",
> +    .init = z2_init,
> +};
> +
> +static void z2_machine_init(void)
> +{
> +    qemu_register_machine(&z2_machine);
> +}
> +
> +machine_init(z2_machine_init);

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v5] Add support for Zipit Z2 machine
  2011-07-06 13:52                       ` [Qemu-devel] [PATCH v5] " Vasily Khoruzhick
  2011-07-11 15:26                         ` Vasily Khoruzhick
@ 2011-07-12 17:31                         ` Peter Maydell
  2011-07-30  5:04                         ` andrzej zaborowski
  2 siblings, 0 replies; 26+ messages in thread
From: Peter Maydell @ 2011-07-12 17:31 UTC (permalink / raw)
  To: Vasily Khoruzhick; +Cc: qemu-devel

On 6 July 2011 14:52, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> Zipit Z2 is small PXA270 based handheld.
>
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
> v2: codestyle fixes, added VMStateDescription for LCD device and AER915,
>    traces clean up.
> v3: no changes
> v4: no changes
> v5: use DPRINTF for debug-related traces, add missing fields to VMStateDescription for
>    LCD device and AER915

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

(Tested with master + cherry-pick of http://patchwork.ozlabs.org/patch/103356/
since we're still waiting for the xen pullreq to be merged.)

-- PMM

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v5] Add support for Zipit Z2 machine
  2011-07-11 15:26                         ` Vasily Khoruzhick
@ 2011-07-28  8:19                           ` Vasily Khoruzhick
  0 siblings, 0 replies; 26+ messages in thread
From: Vasily Khoruzhick @ 2011-07-28  8:19 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel

On Monday 11 July 2011 18:26:37 Vasily Khoruzhick wrote:
> On Wednesday 06 July 2011 16:52:49 Vasily Khoruzhick wrote:
> > Zipit Z2 is small PXA270 based handheld.
> 
> Ping?

One more ping.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [Qemu-devel] [PATCH v5] Add support for Zipit Z2 machine
  2011-07-06 13:52                       ` [Qemu-devel] [PATCH v5] " Vasily Khoruzhick
  2011-07-11 15:26                         ` Vasily Khoruzhick
  2011-07-12 17:31                         ` Peter Maydell
@ 2011-07-30  5:04                         ` andrzej zaborowski
  2 siblings, 0 replies; 26+ messages in thread
From: andrzej zaborowski @ 2011-07-30  5:04 UTC (permalink / raw)
  To: Vasily Khoruzhick; +Cc: Peter Maydell, qemu-devel

On 6 July 2011 15:52, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> Zipit Z2 is small PXA270 based handheld.

Thanks, I pushed this version.

Cheers

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2011-07-30  5:04 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-31 14:16 [Qemu-devel] [PATCH 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
2011-05-31 14:16 ` [Qemu-devel] [PATCH 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
2011-05-31 23:35   ` Peter Maydell
2011-06-01  6:25     ` Vasily Khoruzhick
2011-06-01  9:28     ` [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
2011-06-01  9:28       ` [Qemu-devel] [PATCH v2 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
2011-06-03 15:33       ` [Qemu-devel] [PATCH v2 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
2011-06-03 15:36       ` [Qemu-devel] [PATCH v3 " Vasily Khoruzhick
2011-06-03 15:36         ` [Qemu-devel] [PATCH v3 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
2011-06-03 15:38         ` [Qemu-devel] [PATCH v3 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
2011-06-08  8:52         ` Vasily Khoruzhick
2011-06-08  9:50         ` Peter Maydell
2011-06-08 11:22           ` Vasily Khoruzhick
2011-06-17 10:04             ` [Qemu-devel] [PATCH v4 " Vasily Khoruzhick
2011-06-17 10:04               ` [Qemu-devel] [PATCH v4 2/2] Add support for Zipit Z2 machine Vasily Khoruzhick
2011-06-21  9:47                 ` Vasily Khoruzhick
2011-06-24 14:45                 ` Peter Maydell
2011-06-24 17:06                   ` Vasily Khoruzhick
2011-06-24 17:16                     ` Peter Maydell
2011-07-06 13:52                       ` [Qemu-devel] [PATCH v5] " Vasily Khoruzhick
2011-07-11 15:26                         ` Vasily Khoruzhick
2011-07-28  8:19                           ` Vasily Khoruzhick
2011-07-12 17:31                         ` Peter Maydell
2011-07-30  5:04                         ` andrzej zaborowski
2011-06-21  9:47               ` [Qemu-devel] [PATCH v4 1/2] pxa2xx_lcd: add proper rotation support Vasily Khoruzhick
2011-07-04 20:11               ` andrzej zaborowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.