1 /*
2 * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
3 * Copyright (c) Imagination Technologies Limited, UK
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sub license, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial portions
15 * of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 * Authors:
26 * Zeng Li <zeng.li@intel.com>
27 *
28 */
29
30 #include <stdio.h>
31
32 #include "H263Firmware_bin.h"
33 #include "H263FirmwareCBR_bin.h"
34 #include "H263FirmwareVBR_bin.h"
35 #include "H264Firmware_bin.h"
36 #include "H264FirmwareCBR_bin.h"
37 #include "H264FirmwareVBR_bin.h"
38 #include "H264FirmwareVCM_bin.h"
39 #include "MPG4Firmware_bin.h"
40 #include "MPG4FirmwareCBR_bin.h"
41 #include "MPG4FirmwareVBR_bin.h"
42
43 #define FW_VER 146 /* DDKv146 release */
44 #define FW_FILE_NAME "topaz_fw.bin"
45
46 struct topaz_fw_info_item_s {
47 unsigned short ver;
48 unsigned short codec;
49
50 unsigned int text_size;
51 unsigned int data_size;
52 unsigned int data_location;
53 };
54 typedef struct topaz_fw_info_item_s topaz_fw_info_item_t;
55
56 enum topaz_fw_codec_e {
57 FW_JPEG = 0,
58 FW_H264_NO_RC,
59 FW_H264_VBR,
60 FW_H264_CBR,
61 FW_H264_VCM,
62 FW_H263_NO_RC,
63 FW_H263_VBR,
64 FW_H263_CBR,
65 FW_MPEG4_NO_RC,
66 FW_MPEG4_VBR,
67 FW_MPEG4_CBR,
68 FW_NUM
69 };
70 typedef enum topaz_fw_codec_e topaz_fw_codec_t;
71
72 struct fw_table_s {
73 topaz_fw_codec_t index;
74 topaz_fw_info_item_t header;
75 unsigned int *fw_text;
76 unsigned int *fw_data;
77 };
78 typedef struct fw_table_s fw_table_t;
79
main()80 int main()
81 {
82 FILE *fp = NULL;
83 topaz_fw_codec_t iter = FW_H264_NO_RC;
84 unsigned int size = 0;
85 unsigned int i;
86
87 fw_table_t topaz_fw_table[] = {
88 /* index header
89 * { ver, codec, text_size, data_size, date_location }
90 * fw_text fw_data */
91 { 0, {0, 0, 0, 0, 0}, NULL, NULL },
92 {
93 FW_H264_NO_RC,
94 {
95 FW_VER,
96 FW_H264_NO_RC,
97 ui32H264_MTXTOPAZFWTextSize,
98 ui32H264_MTXTOPAZFWDataSize,
99 ui32H264_MTXTOPAZFWDataLocation
100 },
101 aui32H264_MTXTOPAZFWText, aui32H264_MTXTOPAZFWData
102 },
103
104 {
105 FW_H264_VBR,
106 {
107 FW_VER,
108 FW_H264_VBR,
109 ui32H264VBR_MTXTOPAZFWTextSize,
110 ui32H264VBR_MTXTOPAZFWDataSize,
111 ui32H264VBR_MTXTOPAZFWDataLocation
112 },
113 aui32H264VBR_MTXTOPAZFWText, aui32H264VBR_MTXTOPAZFWData
114 },
115
116 {
117 FW_H264_CBR,
118 {
119 FW_VER,
120 FW_H264_CBR,
121 ui32H264CBR_MTXTOPAZFWTextSize,
122 ui32H264CBR_MTXTOPAZFWDataSize,
123 ui32H264CBR_MTXTOPAZFWDataLocation
124 },
125 aui32H264CBR_MTXTOPAZFWText,
126 aui32H264CBR_MTXTOPAZFWData
127 },
128
129 {
130 FW_H264_VCM,
131 {
132 FW_VER,
133 FW_H264_VCM,
134 ui32H264VCM_MTXTOPAZFWTextSize,
135 ui32H264VCM_MTXTOPAZFWDataSize,
136 ui32H264VCM_MTXTOPAZFWDataLocation
137 },
138 aui32H264VCM_MTXTOPAZFWText,
139 aui32H264VCM_MTXTOPAZFWData
140 },
141
142 {
143 FW_H263_NO_RC,
144 {
145 FW_VER,
146 FW_H263_NO_RC,
147 ui32H263_MTXTOPAZFWTextSize,
148 ui32H263_MTXTOPAZFWDataSize,
149 ui32H263_MTXTOPAZFWDataLocation
150 },
151 aui32H263_MTXTOPAZFWText,
152 aui32H263_MTXTOPAZFWData
153 },
154
155 {
156 FW_H263_VBR,
157 {
158 FW_VER,
159 FW_H263_VBR,
160 ui32H263VBR_MTXTOPAZFWTextSize,
161 ui32H263VBR_MTXTOPAZFWDataSize,
162 ui32H263VBR_MTXTOPAZFWDataLocation
163 },
164 aui32H263VBR_MTXTOPAZFWText,
165 aui32H263VBR_MTXTOPAZFWData
166 },
167
168 {
169 FW_H263_CBR,
170 {
171 FW_VER,
172 FW_H263_CBR,
173 ui32H263CBR_MTXTOPAZFWTextSize,
174 ui32H263CBR_MTXTOPAZFWDataSize,
175 ui32H263CBR_MTXTOPAZFWDataLocation
176 },
177 aui32H263CBR_MTXTOPAZFWText,
178 aui32H263CBR_MTXTOPAZFWData
179 },
180
181 {
182 FW_MPEG4_NO_RC,
183 {
184 FW_VER,
185 FW_MPEG4_NO_RC,
186 ui32MPG4_MTXTOPAZFWTextSize,
187 ui32MPG4_MTXTOPAZFWDataSize,
188 ui32MPG4_MTXTOPAZFWDataLocation
189 },
190 aui32MPG4_MTXTOPAZFWText,
191 aui32MPG4_MTXTOPAZFWData
192 },
193
194 {
195 FW_MPEG4_VBR,
196 {
197 FW_VER,
198 FW_MPEG4_VBR,
199 ui32MPG4VBR_MTXTOPAZFWTextSize,
200 ui32MPG4VBR_MTXTOPAZFWDataSize,
201 ui32MPG4VBR_MTXTOPAZFWDataLocation
202 },
203 aui32MPG4VBR_MTXTOPAZFWText,
204 aui32MPG4VBR_MTXTOPAZFWData
205 },
206
207 {
208 FW_MPEG4_CBR,
209 {
210 FW_VER,
211 FW_MPEG4_CBR,
212 ui32MPG4CBR_MTXTOPAZFWTextSize,
213 ui32MPG4CBR_MTXTOPAZFWDataSize,
214 ui32MPG4CBR_MTXTOPAZFWDataLocation
215 },
216 aui32MPG4CBR_MTXTOPAZFWText,
217 aui32MPG4CBR_MTXTOPAZFWData
218 }
219 };
220
221 /* open file */
222 fp = fopen(FW_FILE_NAME, "w");
223
224 if (NULL == fp)
225 return -1;
226 /* write fw table into the file */
227 while (iter < FW_NUM) {
228 /* record the size use bytes */
229 topaz_fw_table[iter].header.data_size *= 4;
230 topaz_fw_table[iter].header.text_size *= 4;
231
232 /* write header */
233 fwrite(&(topaz_fw_table[iter].header), sizeof(topaz_fw_table[iter].header), 1, fp);
234
235 /* write text */
236 size = topaz_fw_table[iter].header.text_size;
237 fwrite(topaz_fw_table[iter].fw_text, 1, size, fp);
238
239 /* write data */
240 size = topaz_fw_table[iter].header.data_size;
241 fwrite(topaz_fw_table[iter].fw_data, 1, size, fp);
242
243 ++iter;
244 }
245
246 /* close file */
247 fclose(fp);
248
249 return 0;
250 }
251