qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] pxa2xx_keypad: make single automatic scans work
@ 2012-01-12 19:30 Vasily Khoruzhick
  2012-01-12 19:30 ` [Qemu-devel] [PATCH 2/2] pxa2xx_lcd: fix palette parser Vasily Khoruzhick
  2012-01-17  0:49 ` [Qemu-devel] [PATCH 1/2] pxa2xx_keypad: make single automatic scans work andrzej zaborowski
  0 siblings, 2 replies; 4+ messages in thread
From: Vasily Khoruzhick @ 2012-01-12 19:30 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel@nongnu.org; +Cc: Vasily Khoruzhick

u-boot uses single automatic scans and polling in
pxa2xx_keypad driver, so clear KPC_AS bit immediately
and update keys state even if KPC_AS and KPC_ASACT are
cleared.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 hw/pxa2xx_keypad.c |   72 ++++++++++++++++++++++++++--------------------------
 1 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/hw/pxa2xx_keypad.c b/hw/pxa2xx_keypad.c
index f86323f..1b9abbb 100644
--- a/hw/pxa2xx_keypad.c
+++ b/hw/pxa2xx_keypad.c
@@ -126,48 +126,45 @@ static void pxa27x_keyboard_event (PXA2xxKeyPadState *kp, int keycode)
     if(!(kp->kpc & KPC_ME)) /* skip if not enabled */
         return;
 
-    if(kp->kpc & KPC_AS || kp->kpc & KPC_ASACT) {
-        if(kp->kpc & KPC_AS)
-            kp->kpc &= ~(KPC_AS);
-
-        rel = (keycode & 0x80) ? 1 : 0; /* key release from qemu */
-        keycode &= ~(0x80); /* strip qemu key release bit */
-        if (kp->alt_code) {
-            keycode |= 0x80;
-            kp->alt_code = 0;
-        }
+    rel = (keycode & 0x80) ? 1 : 0; /* key release from qemu */
+    keycode &= ~(0x80); /* strip qemu key release bit */
+    if (kp->alt_code) {
+        keycode |= 0x80;
+        kp->alt_code = 0;
+    }
 
-        row = kp->map[keycode].row;
-        col = kp->map[keycode].column;
-        if(row == -1 || col == -1)
-            return;
+    row = kp->map[keycode].row;
+    col = kp->map[keycode].column;
+    if (row == -1 || col == -1) {
+        return;
+    }
 
-        val = KPASMKPx_MKC(row, col);
-        if (rel) {
-            if (kp->kpasmkp[col / 2] & val) {
-                kp->kpasmkp[col / 2] &= ~val;
-                kp->pressed_cnt--;
-                assert_irq = 1;
-            }
-        } else {
-            if (!(kp->kpasmkp[col / 2] & val)) {
-                kp->kpasmkp[col / 2] |= val;
-                kp->pressed_cnt++;
-                assert_irq = 1;
-            }
+    val = KPASMKPx_MKC(row, col);
+    if (rel) {
+        if (kp->kpasmkp[col / 2] & val) {
+            kp->kpasmkp[col / 2] &= ~val;
+            kp->pressed_cnt--;
+            assert_irq = 1;
         }
-        kp->kpas = ((kp->pressed_cnt & 0x1f) << 26) | (0xf << 4) | 0xf;
-        if (kp->pressed_cnt == 1) {
-            kp->kpas &= ~((0xf << 4) | 0xf);
-            if (rel)
-                pxa27x_keypad_find_pressed_key(kp, &row, &col);
-            kp->kpas |= ((row & 0xf) << 4) | (col & 0xf);
+    } else {
+        if (!(kp->kpasmkp[col / 2] & val)) {
+            kp->kpasmkp[col / 2] |= val;
+            kp->pressed_cnt++;
+            assert_irq = 1;
         }
-        goto out;
     }
-    return;
+    kp->kpas = ((kp->pressed_cnt & 0x1f) << 26) | (0xf << 4) | 0xf;
+    if (kp->pressed_cnt == 1) {
+        kp->kpas &= ~((0xf << 4) | 0xf);
+        if (rel) {
+            pxa27x_keypad_find_pressed_key(kp, &row, &col);
+        }
+        kp->kpas |= ((row & 0xf) << 4) | (col & 0xf);
+    }
+
+    if (!(kp->kpc & KPC_AS || kp->kpc & KPC_ASACT))
+        assert_irq = 0;
 
-out:
     if (assert_irq && (kp->kpc & KPC_MIE)) {
         kp->kpc |= KPC_MI;
         qemu_irq_raise(kp->irq);
@@ -245,6 +242,9 @@ static void pxa2xx_keypad_write(void *opaque, target_phys_addr_t offset,
     switch (offset) {
     case KPC:
         s->kpc = value;
+        if (s->kpc & KPC_AS) {
+            s->kpc &= ~(KPC_AS);
+        }
         break;
     case KPDK:
         s->kpdk = value;
-- 
1.7.8.3

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

* [Qemu-devel] [PATCH 2/2] pxa2xx_lcd: fix palette parser
  2012-01-12 19:30 [Qemu-devel] [PATCH 1/2] pxa2xx_keypad: make single automatic scans work Vasily Khoruzhick
@ 2012-01-12 19:30 ` Vasily Khoruzhick
  2012-01-17  0:39   ` andrzej zaborowski
  2012-01-17  0:49 ` [Qemu-devel] [PATCH 1/2] pxa2xx_keypad: make single automatic scans work andrzej zaborowski
  1 sibling, 1 reply; 4+ messages in thread
From: Vasily Khoruzhick @ 2012-01-12 19:30 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel@nongnu.org; +Cc: Vasily Khoruzhick

Pallete entry size for 16bpp format is 2 bytes, not 4

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
---
 hw/pxa2xx_lcd.c |   51 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/hw/pxa2xx_lcd.c b/hw/pxa2xx_lcd.c
index 5dd4ef0..02e237e 100644
--- a/hw/pxa2xx_lcd.c
+++ b/hw/pxa2xx_lcd.c
@@ -574,7 +574,8 @@ static const MemoryRegionOps pxa2xx_lcdc_ops = {
 static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
 {
     int i, n, format, r, g, b, alpha;
-    uint32_t *dest, *src;
+    uint32_t *dest;
+    uint8_t *src;
     s->pal_for = LCCR4_PALFOR(s->control[4]);
     format = s->pal_for;
 
@@ -593,7 +594,7 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
         return;
     }
 
-    src = (uint32_t *) s->dma_ch[ch].pbuffer;
+    src = (uint8_t *) s->dma_ch[ch].pbuffer;
     dest = (uint32_t *) s->dma_ch[ch].palette;
     alpha = r = g = b = 0;
 
@@ -601,43 +602,48 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
         switch (format) {
         case 0: /* 16 bpp, no transparency */
             alpha = 0;
-            if (s->control[0] & LCCR0_CMS)
-                r = g = b = *src & 0xff;
+            if (s->control[0] & LCCR0_CMS) {
+                r = g = b = *(uint16_t *)src & 0xff;
+            }
             else {
-                r = (*src & 0xf800) >> 8;
-                g = (*src & 0x07e0) >> 3;
-                b = (*src & 0x001f) << 3;
+                r = (*(uint16_t *)src & 0xf800) >> 8;
+                g = (*(uint16_t *)src & 0x07e0) >> 3;
+                b = (*(uint16_t *)src & 0x001f) << 3;
             }
+            src += 2;
             break;
         case 1: /* 16 bpp plus transparency */
-            alpha = *src & (1 << 24);
+            alpha = *(uint16_t *)src & (1 << 24);
             if (s->control[0] & LCCR0_CMS)
-                r = g = b = *src & 0xff;
+                r = g = b = *(uint16_t *)src & 0xff;
             else {
-                r = (*src & 0xf800) >> 8;
-                g = (*src & 0x07e0) >> 3;
-                b = (*src & 0x001f) << 3;
+                r = (*(uint16_t *)src & 0xf800) >> 8;
+                g = (*(uint16_t *)src & 0x07e0) >> 3;
+                b = (*(uint16_t *)src & 0x001f) << 3;
             }
+            src += 2;
             break;
         case 2: /* 18 bpp plus transparency */
-            alpha = *src & (1 << 24);
+            alpha = *(uint32_t *)src & (1 << 24);
             if (s->control[0] & LCCR0_CMS)
-                r = g = b = *src & 0xff;
+                r = g = b = *(uint32_t *)src & 0xff;
             else {
-                r = (*src & 0xf80000) >> 16;
-                g = (*src & 0x00fc00) >> 8;
-                b = (*src & 0x0000f8);
+                r = (*(uint32_t *)src & 0xf80000) >> 16;
+                g = (*(uint32_t *)src & 0x00fc00) >> 8;
+                b = (*(uint32_t *)src & 0x0000f8);
             }
+            src += 4;
             break;
         case 3: /* 24 bpp plus transparency */
-            alpha = *src & (1 << 24);
+            alpha = *(uint32_t *)src & (1 << 24);
             if (s->control[0] & LCCR0_CMS)
-                r = g = b = *src & 0xff;
+                r = g = b = *(uint32_t *)src & 0xff;
             else {
-                r = (*src & 0xff0000) >> 16;
-                g = (*src & 0x00ff00) >> 8;
-                b = (*src & 0x0000ff);
+                r = (*(uint32_t *)src & 0xff0000) >> 16;
+                g = (*(uint32_t *)src & 0x00ff00) >> 8;
+                b = (*(uint32_t *)src & 0x0000ff);
             }
+            src += 4;
             break;
         }
         switch (ds_get_bits_per_pixel(s->ds)) {
@@ -657,7 +663,6 @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
             *dest = rgb_to_pixel32(r, g, b) | alpha;
             break;
         }
-        src ++;
         dest ++;
     }
 }
-- 
1.7.8.3

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

* Re: [Qemu-devel] [PATCH 2/2] pxa2xx_lcd: fix palette parser
  2012-01-12 19:30 ` [Qemu-devel] [PATCH 2/2] pxa2xx_lcd: fix palette parser Vasily Khoruzhick
@ 2012-01-17  0:39   ` andrzej zaborowski
  0 siblings, 0 replies; 4+ messages in thread
From: andrzej zaborowski @ 2012-01-17  0:39 UTC (permalink / raw)
  To: Vasily Khoruzhick; +Cc: Peter Maydell, qemu-devel@nongnu.org

On 12 January 2012 20:30, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> Pallete entry size for 16bpp format is 2 bytes, not 4
>
> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>

Thanks, applied, (with a style consistency change).

Cheers

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

* Re: [Qemu-devel] [PATCH 1/2] pxa2xx_keypad: make single automatic scans work
  2012-01-12 19:30 [Qemu-devel] [PATCH 1/2] pxa2xx_keypad: make single automatic scans work Vasily Khoruzhick
  2012-01-12 19:30 ` [Qemu-devel] [PATCH 2/2] pxa2xx_lcd: fix palette parser Vasily Khoruzhick
@ 2012-01-17  0:49 ` andrzej zaborowski
  1 sibling, 0 replies; 4+ messages in thread
From: andrzej zaborowski @ 2012-01-17  0:49 UTC (permalink / raw)
  To: Vasily Khoruzhick; +Cc: Peter Maydell, qemu-devel@nongnu.org

On 12 January 2012 20:30, Vasily Khoruzhick <anarsoul@gmail.com> wrote:
> u-boot uses single automatic scans and polling in
> pxa2xx_keypad driver, so clear KPC_AS bit immediately
> and update keys state even if KPC_AS and KPC_ASACT are
> cleared.

Thanks, applied.

Cheers

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

end of thread, other threads:[~2012-01-17  0:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-12 19:30 [Qemu-devel] [PATCH 1/2] pxa2xx_keypad: make single automatic scans work Vasily Khoruzhick
2012-01-12 19:30 ` [Qemu-devel] [PATCH 2/2] pxa2xx_lcd: fix palette parser Vasily Khoruzhick
2012-01-17  0:39   ` andrzej zaborowski
2012-01-17  0:49 ` [Qemu-devel] [PATCH 1/2] pxa2xx_keypad: make single automatic scans work andrzej zaborowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).