• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
86     fw_table_t topaz_fw_table[] = {
87         /* index   header
88          * { ver, codec, text_size, data_size, date_location }
89          * fw_text fw_data */
90         { 0, {0, 0, 0, 0, 0}, NULL, NULL },
91         {
92             FW_H264_NO_RC,
93             {
94                 FW_VER,
95                 FW_H264_NO_RC,
96                 ui32H264_MTXTOPAZFWTextSize,
97                 ui32H264_MTXTOPAZFWDataSize,
98                 ui32H264_MTXTOPAZFWDataLocation
99             },
100             aui32H264_MTXTOPAZFWText, aui32H264_MTXTOPAZFWData
101         },
102 
103         {
104             FW_H264_VBR,
105             {
106                 FW_VER,
107                 FW_H264_VBR,
108                 ui32H264VBR_MTXTOPAZFWTextSize,
109                 ui32H264VBR_MTXTOPAZFWDataSize,
110                 ui32H264VBR_MTXTOPAZFWDataLocation
111             },
112             aui32H264VBR_MTXTOPAZFWText, aui32H264VBR_MTXTOPAZFWData
113         },
114 
115         {
116             FW_H264_CBR,
117             {
118                 FW_VER,
119                 FW_H264_CBR,
120                 ui32H264CBR_MTXTOPAZFWTextSize,
121                 ui32H264CBR_MTXTOPAZFWDataSize,
122                 ui32H264CBR_MTXTOPAZFWDataLocation
123             },
124             aui32H264CBR_MTXTOPAZFWText,
125             aui32H264CBR_MTXTOPAZFWData
126         },
127 
128         {
129             FW_H264_VCM,
130             {
131                 FW_VER,
132                 FW_H264_VCM,
133                 ui32H264VCM_MTXTOPAZFWTextSize,
134                 ui32H264VCM_MTXTOPAZFWDataSize,
135                 ui32H264VCM_MTXTOPAZFWDataLocation
136             },
137             aui32H264VCM_MTXTOPAZFWText,
138             aui32H264VCM_MTXTOPAZFWData
139         },
140 
141         {
142             FW_H263_NO_RC,
143             {
144                 FW_VER,
145                 FW_H263_NO_RC,
146                 ui32H263_MTXTOPAZFWTextSize,
147                 ui32H263_MTXTOPAZFWDataSize,
148                 ui32H263_MTXTOPAZFWDataLocation
149             },
150             aui32H263_MTXTOPAZFWText,
151             aui32H263_MTXTOPAZFWData
152         },
153 
154         {
155             FW_H263_VBR,
156             {
157                 FW_VER,
158                 FW_H263_VBR,
159                 ui32H263VBR_MTXTOPAZFWTextSize,
160                 ui32H263VBR_MTXTOPAZFWDataSize,
161                 ui32H263VBR_MTXTOPAZFWDataLocation
162             },
163             aui32H263VBR_MTXTOPAZFWText,
164             aui32H263VBR_MTXTOPAZFWData
165         },
166 
167         {
168             FW_H263_CBR,
169             {
170                 FW_VER,
171                 FW_H263_CBR,
172                 ui32H263CBR_MTXTOPAZFWTextSize,
173                 ui32H263CBR_MTXTOPAZFWDataSize,
174                 ui32H263CBR_MTXTOPAZFWDataLocation
175             },
176             aui32H263CBR_MTXTOPAZFWText,
177             aui32H263CBR_MTXTOPAZFWData
178         },
179 
180         {
181             FW_MPEG4_NO_RC,
182             {
183                 FW_VER,
184                 FW_MPEG4_NO_RC,
185                 ui32MPG4_MTXTOPAZFWTextSize,
186                 ui32MPG4_MTXTOPAZFWDataSize,
187                 ui32MPG4_MTXTOPAZFWDataLocation
188             },
189             aui32MPG4_MTXTOPAZFWText,
190             aui32MPG4_MTXTOPAZFWData
191         },
192 
193         {
194             FW_MPEG4_VBR,
195             {
196                 FW_VER,
197                 FW_MPEG4_VBR,
198                 ui32MPG4VBR_MTXTOPAZFWTextSize,
199                 ui32MPG4VBR_MTXTOPAZFWDataSize,
200                 ui32MPG4VBR_MTXTOPAZFWDataLocation
201             },
202             aui32MPG4VBR_MTXTOPAZFWText,
203             aui32MPG4VBR_MTXTOPAZFWData
204         },
205 
206         {
207             FW_MPEG4_CBR,
208             {
209                 FW_VER,
210                 FW_MPEG4_CBR,
211                 ui32MPG4CBR_MTXTOPAZFWTextSize,
212                 ui32MPG4CBR_MTXTOPAZFWDataSize,
213                 ui32MPG4CBR_MTXTOPAZFWDataLocation
214             },
215             aui32MPG4CBR_MTXTOPAZFWText,
216             aui32MPG4CBR_MTXTOPAZFWData
217         }
218     };
219 
220     /* open file  */
221     fp = fopen(FW_FILE_NAME, "w");
222 
223     if (NULL == fp)
224         return -1;
225     /* write fw table into the file */
226     while (iter < FW_NUM) {
227         /* record the size use bytes */
228         topaz_fw_table[iter].header.data_size *= 4;
229         topaz_fw_table[iter].header.text_size *= 4;
230 
231         /* write header */
232         fwrite(&(topaz_fw_table[iter].header), sizeof(topaz_fw_table[iter].header), 1, fp);
233 
234         /* write text */
235         size = topaz_fw_table[iter].header.text_size;
236         fwrite(topaz_fw_table[iter].fw_text, 1, size, fp);
237 
238         /* write data */
239         size = topaz_fw_table[iter].header.data_size;
240         fwrite(topaz_fw_table[iter].fw_data, 1, size, fp);
241 
242         ++iter;
243     }
244 
245     /* close file */
246     fclose(fp);
247 
248     return 0;
249 }
250