[Title] modified interrupt routine using QEMU bottom half. and fix a bug that intterr...
authorjinhyung.jo <jinhyung.jo@samsung.com>
Fri, 10 Aug 2012 02:46:54 +0000 (11:46 +0900)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Fri, 10 Aug 2012 02:46:54 +0000 (11:46 +0900)
[Type] BugFix & Enhancement
[Module] Emulator / Camera(QEMU)
[Priority] Major
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/src/hw/maru_camera_common.h
tizen/src/hw/maru_camera_common_pci.c
tizen/src/hw/maru_camera_linux_pci.c
tizen/src/hw/maru_camera_win32_pci.c

index 9abc9f0ec651afd5a7836a170023155e9b94b0ab..e5fd1e270c817d4e0f17a304b08f12f947965fd1 100644 (file)
@@ -73,6 +73,7 @@ struct MaruCamState {
     QemuThread          thread_id;\r
     QemuMutex           thread_mutex;;\r
     QemuCond            thread_cond;\r
+    QEMUBH              *tx_bh;\r
 \r
     void                *vaddr;     /* vram ptr */\r
     uint32_t            isr;\r
index 4f187c9e32b3e35cc031a420afca89b6eb566d16..75766e9396be1441f8a81f90e7c0210ac853cb44 100644 (file)
@@ -63,8 +63,10 @@ static inline uint32_t marucam_mmio_read(void *opaque, target_phys_addr_t offset
     case MARUCAM_CMD_ISR:\r
         qemu_mutex_lock(&state->thread_mutex);\r
         ret = state->isr;\r
-        state->isr = 0;\r
-        qemu_irq_lower(state->dev.irq[2]);\r
+        if (ret != 0) {\r
+            qemu_irq_lower(state->dev.irq[2]);\r
+            state->isr = 0;\r
+        }\r
         qemu_mutex_unlock(&state->thread_mutex);\r
         break;\r
     case MARUCAM_CMD_G_DATA:\r
@@ -179,6 +181,20 @@ static const MemoryRegionOps maru_camera_mmio_ops = {
     .endianness = DEVICE_LITTLE_ENDIAN,\r
 };\r
 \r
+/*\r
+ *  QEMU bottom half funtion\r
+ */\r
+static void marucam_tx_bh(void *opaque)\r
+{\r
+    MaruCamState *state = (MaruCamState *)opaque;\r
+\r
+    qemu_mutex_lock(&state->thread_mutex);\r
+    if (state->isr) {\r
+        qemu_irq_raise(state->dev.irq[2]);\r
+    }\r
+    qemu_mutex_unlock(&state->thread_mutex);\r
+}\r
+\r
 /*\r
  *  Initialization function\r
  */\r
@@ -204,6 +220,8 @@ static int marucam_initfn(PCIDevice *dev)
 \r
     marucam_device_init(s);\r
 \r
+    s->tx_bh = qemu_bh_new(marucam_tx_bh, s);\r
+\r
     return 0;\r
 }\r
 \r
@@ -220,6 +238,8 @@ static int marucam_exitfn(PCIDevice *dev)
 \r
     memory_region_destroy (&s->vram);\r
     memory_region_destroy (&s->mmio);\r
+\r
+    INFO("[%s] camera device was released.\n", __func__);\r
     return 0;\r
 }\r
 \r
index c643a92f169ffbbe987c52dfe16a52ac2fc36626..db08b8d7e7afa617bd17ada1f092b3fea13af0e4 100644 (file)
@@ -193,7 +193,7 @@ static int __v4l2_grab(MaruCamState *state)
             if (state->req_frame) {\r
                 state->req_frame = 0; // clear request\r
                 state->isr |= 0x01; // set a flag of rasing a interrupt.\r
-                qemu_irq_raise(state->dev.irq[2]);\r
+                qemu_bh_schedule(state->tx_bh);\r
             }\r
             ret = 1;\r
         } else {\r
index d014f2e6412843a6d68cc9724b30aca2cdebbca7..26ddf36867457bf53ac8a950d19a92cb9698ced4 100644 (file)
@@ -30,7 +30,6 @@
 #include "qemu-common.h"\r
 #include "maru_camera_common.h"\r
 #include "tizen/src/debug_ch.h"\r
-#include "tizen/src/mloop_event.h"\r
 \r
 #define CINTERFACE\r
 #define COBJMACROS\r
@@ -1085,7 +1084,7 @@ static STDMETHODIMP marucam_device_callbackfn(ULONG dwSize, BYTE *pBuffer)
         if (g_state->req_frame) {\r
             g_state->req_frame = 0; // clear request\r
             g_state->isr |= 0x01; // set a flag raising a interrupt.\r
-            mloop_evcmd_raise_intr(g_state->dev.irq[2]);\r
+            qemu_bh_schedule(g_state->tx_bh);\r
         }\r
     } else {\r
         ++ready_count; // skip a frame cause first some frame are distorted.\r