Initialize
[sdk/emulator/qemu.git] / tizen / src / hw / maru_codec.h
1 /*
2  * Virtual Codec device
3  *
4  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
5  *
6  * Contact:
7  *  Kitae Kim <kt920.kim@samsung.com>
8  *  SeokYeon Hwang <syeon.hwang@samsung.com>
9  *  DongKyun Yun <dk77.yun@samsung.com>
10  *  YeongKyoon Lee <yeongkyoon.lee@samsung.com>
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
25  *
26  * Contributors:
27  * - S-Core Co., Ltd
28  *
29  */
30
31 #include <stdio.h>
32 #include <pthread.h>
33 #include <sys/types.h>
34 #include "hw.h"
35 #include "kvm.h"
36 #include "pci.h"
37 #include "pci_ids.h"
38 #include "tizen/src/debug_ch.h"
39
40 #include <libavformat/avformat.h>
41 #include <libswscale/swscale.h>
42
43 // #define CODEC_HOST
44
45 /*
46  *  Codec Device Structures
47  */
48
49 typedef struct _SVCodecParam {
50     uint32_t        func_num;
51     uint32_t        in_args[20];
52     uint32_t        ret_args;
53 } SVCodecParam;
54
55
56 typedef struct _SVCodecState {
57     PCIDevice           dev;
58     SVCodecParam        codecParam;
59
60     int                 mmioIndex;
61
62     uint8_t*            vaddr;
63     ram_addr_t          vram_offset;
64
65     uint32_t            mem_addr;
66     uint32_t            mmio_addr;
67
68     int                 index;
69 } SVCodecState;
70
71 enum {
72     FUNC_NUM            = 0x00,
73     IN_ARGS             = 0x04,
74     RET_STR             = 0x08,
75 };
76
77 enum {
78     EMUL_AV_REGISTER_ALL = 1,
79     EMUL_AVCODEC_OPEN,
80     EMUL_AVCODEC_CLOSE,
81     EMUL_AVCODEC_ALLOC_CONTEXT,
82     EMUL_AVCODEC_ALLOC_FRAME,
83     EMUL_AV_FREE_CONTEXT,
84     EMUL_AV_FREE_FRAME,
85     EMUL_AV_FREE_PALCTRL,
86     EMUL_AV_FREE_EXTRADATA,
87     EMUL_AVCODEC_FLUSH_BUFFERS,
88     EMUL_AVCODEC_DECODE_VIDEO,
89     EMUL_AVCODEC_ENCODE_VIDEO,
90     EMUL_AV_PICTURE_COPY,
91     EMUL_AV_PARSER_INIT,
92     EMUL_AV_PARSER_PARSE,
93     EMUL_AV_PARSER_CLOSE,
94 };
95
96
97 /*
98  *  Codec Device APIs
99  */
100 int pci_codec_init (PCIBus *bus);
101 static int codec_operate(uint32_t value, SVCodecState *opaque);
102
103 /*
104  *  FFMPEG APIs
105  */
106
107 void qemu_parser_init (void);
108
109 void qemu_restore_context (AVCodecContext *dst, AVCodecContext *src);
110
111 void qemu_av_register_all (void);
112
113 int qemu_avcodec_open (SVCodecState *s);
114
115 int qemu_avcodec_close (SVCodecState *s);
116
117 void qemu_avcodec_alloc_context (void);
118
119 void qemu_avcodec_alloc_frame (void);
120
121 void qemu_av_free_context (void);
122
123 void qemu_av_free_picture (void);
124
125 void qemu_av_free_palctrl (void);
126
127 void qemu_av_free_extradata (void);
128
129 void qemu_avcodec_flush_buffers (void);
130
131 int qemu_avcodec_decode_video (SVCodecState *s);
132
133 int qemu_avcodec_encode_video (SVCodecState *s);
134
135 void qemu_av_picture_copy (SVCodecState *s);
136
137 void qemu_av_parser_init (SVCodecState *s);
138
139 int qemu_av_parser_parse (SVCodecState *s);
140
141 void qemu_av_parser_close (void);
142
143 int qemu_avcodec_get_buffer (AVCodecContext *context, AVFrame *picture);
144
145 void qemu_avcodec_release_buffer (AVCodecContext *context, AVFrame *picture);
146