From: jinhyung.jo Date: Fri, 10 Aug 2012 02:46:54 +0000 (+0900) Subject: [Title] modified interrupt routine using QEMU bottom half. and fix a bug that intterr... X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1528^2~13^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=722f09c8b2e290c1181af33429550edbb013f6c1;p=sdk%2Femulator%2Fqemu.git [Title] modified interrupt routine using QEMU bottom half. and fix a bug that intterrupt mismatch [Type] BugFix & Enhancement [Module] Emulator / Camera(QEMU) [Priority] Major [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/tizen/src/hw/maru_camera_common.h b/tizen/src/hw/maru_camera_common.h index 9abc9f0ec6..e5fd1e270c 100644 --- a/tizen/src/hw/maru_camera_common.h +++ b/tizen/src/hw/maru_camera_common.h @@ -73,6 +73,7 @@ struct MaruCamState { QemuThread thread_id; QemuMutex thread_mutex;; QemuCond thread_cond; + QEMUBH *tx_bh; void *vaddr; /* vram ptr */ uint32_t isr; diff --git a/tizen/src/hw/maru_camera_common_pci.c b/tizen/src/hw/maru_camera_common_pci.c index 4f187c9e32..75766e9396 100644 --- a/tizen/src/hw/maru_camera_common_pci.c +++ b/tizen/src/hw/maru_camera_common_pci.c @@ -63,8 +63,10 @@ static inline uint32_t marucam_mmio_read(void *opaque, target_phys_addr_t offset case MARUCAM_CMD_ISR: qemu_mutex_lock(&state->thread_mutex); ret = state->isr; - state->isr = 0; - qemu_irq_lower(state->dev.irq[2]); + if (ret != 0) { + qemu_irq_lower(state->dev.irq[2]); + state->isr = 0; + } qemu_mutex_unlock(&state->thread_mutex); break; case MARUCAM_CMD_G_DATA: @@ -179,6 +181,20 @@ static const MemoryRegionOps maru_camera_mmio_ops = { .endianness = DEVICE_LITTLE_ENDIAN, }; +/* + * QEMU bottom half funtion + */ +static void marucam_tx_bh(void *opaque) +{ + MaruCamState *state = (MaruCamState *)opaque; + + qemu_mutex_lock(&state->thread_mutex); + if (state->isr) { + qemu_irq_raise(state->dev.irq[2]); + } + qemu_mutex_unlock(&state->thread_mutex); +} + /* * Initialization function */ @@ -204,6 +220,8 @@ static int marucam_initfn(PCIDevice *dev) marucam_device_init(s); + s->tx_bh = qemu_bh_new(marucam_tx_bh, s); + return 0; } @@ -220,6 +238,8 @@ static int marucam_exitfn(PCIDevice *dev) memory_region_destroy (&s->vram); memory_region_destroy (&s->mmio); + + INFO("[%s] camera device was released.\n", __func__); return 0; } diff --git a/tizen/src/hw/maru_camera_linux_pci.c b/tizen/src/hw/maru_camera_linux_pci.c index c643a92f16..db08b8d7e7 100644 --- a/tizen/src/hw/maru_camera_linux_pci.c +++ b/tizen/src/hw/maru_camera_linux_pci.c @@ -193,7 +193,7 @@ static int __v4l2_grab(MaruCamState *state) if (state->req_frame) { state->req_frame = 0; // clear request state->isr |= 0x01; // set a flag of rasing a interrupt. - qemu_irq_raise(state->dev.irq[2]); + qemu_bh_schedule(state->tx_bh); } ret = 1; } else { diff --git a/tizen/src/hw/maru_camera_win32_pci.c b/tizen/src/hw/maru_camera_win32_pci.c index d014f2e641..26ddf36867 100644 --- a/tizen/src/hw/maru_camera_win32_pci.c +++ b/tizen/src/hw/maru_camera_win32_pci.c @@ -30,7 +30,6 @@ #include "qemu-common.h" #include "maru_camera_common.h" #include "tizen/src/debug_ch.h" -#include "tizen/src/mloop_event.h" #define CINTERFACE #define COBJMACROS @@ -1085,7 +1084,7 @@ static STDMETHODIMP marucam_device_callbackfn(ULONG dwSize, BYTE *pBuffer) if (g_state->req_frame) { g_state->req_frame = 0; // clear request g_state->isr |= 0x01; // set a flag raising a interrupt. - mloop_evcmd_raise_intr(g_state->dev.irq[2]); + qemu_bh_schedule(g_state->tx_bh); } } else { ++ready_count; // skip a frame cause first some frame are distorted.