update source for tizen_2.1
[sdk/emulator/qemu.git] / tizen / src / hw / maru_camera_common.h
1 /*
2  * Common header of MARU Virtual Camera device.
3  *
4  * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
5  *
6  * Contact:
7  * JinHyung Jo <jinhyung.jo@samsung.com>
8  * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23  * MA  02110-1301, USA.
24  *
25  * Contributors:
26  * - S-Core Co., Ltd
27  *
28  */
29
30 #ifndef _MARU_CAMERA_COMMON_H_
31 #define _MARU_CAMERA_COMMON_H_
32
33 #include "pci.h"
34 #include "qemu-thread.h"
35
36 #define MARUCAM_MAX_PARAM    20
37 #define MARUCAM_SKIPFRAMES    2
38
39 /* must sync with GUEST camera_driver */
40 #define MARUCAM_CMD_INIT           0x00
41 #define MARUCAM_CMD_OPEN           0x04
42 #define MARUCAM_CMD_CLOSE          0x08
43 #define MARUCAM_CMD_ISR            0x0C
44 #define MARUCAM_CMD_START_PREVIEW  0x10
45 #define MARUCAM_CMD_STOP_PREVIEW   0x14
46 #define MARUCAM_CMD_S_PARAM        0x18
47 #define MARUCAM_CMD_G_PARAM        0x1C
48 #define MARUCAM_CMD_ENUM_FMT       0x20
49 #define MARUCAM_CMD_TRY_FMT        0x24
50 #define MARUCAM_CMD_S_FMT          0x28
51 #define MARUCAM_CMD_G_FMT          0x2C
52 #define MARUCAM_CMD_QCTRL          0x30
53 #define MARUCAM_CMD_S_CTRL         0x34
54 #define MARUCAM_CMD_G_CTRL         0x38
55 #define MARUCAM_CMD_ENUM_FSIZES    0x3C
56 #define MARUCAM_CMD_ENUM_FINTV     0x40
57 #define MARUCAM_CMD_S_DATA         0x44
58 #define MARUCAM_CMD_G_DATA         0x48
59 #define MARUCAM_CMD_DATACLR        0x50
60 #define MARUCAM_CMD_REQFRAME       0x54
61
62 typedef struct MaruCamState MaruCamState;
63 typedef struct MaruCamParam MaruCamParam;
64
65 struct MaruCamParam {
66     uint32_t    top;
67     uint32_t    retVal;
68     uint32_t    errCode;
69     uint32_t    stack[MARUCAM_MAX_PARAM];
70 };
71
72 struct MaruCamState {
73     PCIDevice           dev;
74     MaruCamParam        *param;
75     QemuThread          thread_id;
76     QemuMutex           thread_mutex;;
77     QemuCond            thread_cond;
78     QEMUBH              *tx_bh;
79
80     bool                destroying;
81     void                *vaddr;     /* vram ptr */
82     uint32_t            isr;
83     uint32_t            streamon;
84     uint32_t            buf_size;
85     uint32_t            req_frame;
86
87     MemoryRegion        vram;
88     MemoryRegion        mmio;
89 };
90
91 /* ------------------------------------------------------------------------- */
92 /* Fucntion prototype                                                        */
93 /* ------------------------------------------------------------------------- */
94 int marucam_device_check(int log_flag);
95 void marucam_device_init(MaruCamState *state);
96 void marucam_device_exit(MaruCamState *state);
97 void marucam_device_open(MaruCamState *state);
98 void marucam_device_close(MaruCamState *state);
99 void marucam_device_start_preview(MaruCamState *state);
100 void marucam_device_stop_preview(MaruCamState *state);
101 void marucam_device_s_param(MaruCamState *state);
102 void marucam_device_g_param(MaruCamState *state);
103 void marucam_device_s_fmt(MaruCamState *state);
104 void marucam_device_g_fmt(MaruCamState *state);
105 void marucam_device_try_fmt(MaruCamState *state);
106 void marucam_device_enum_fmt(MaruCamState *state);
107 void marucam_device_qctrl(MaruCamState *state);
108 void marucam_device_s_ctrl(MaruCamState *state);
109 void marucam_device_g_ctrl(MaruCamState *state);
110 void marucam_device_enum_fsizes(MaruCamState *state);
111 void marucam_device_enum_fintv(MaruCamState *state);
112
113 int maru_camera_pci_init(PCIBus *bus);
114
115 #endif  /* _MARU_CAMERA_COMMON_H_ */