• 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  *    Elaine Wang <elaine.wang@intel.com>
27  *
28  */
29 
30 #include <stdio.h>
31 
32 #include "JPEGMasterFirmware_bin.h"
33 #include "JPEGSlaveFirmware_bin.h"
34 
35 #include "H263MasterFirmware_bin.h"
36 #include "H263MasterFirmwareCBR_bin.h"
37 #include "H263MasterFirmwareVBR_bin.h"
38 #include "H264MasterFirmware_bin.h"
39 #include "H264MasterFirmwareCBR_bin.h"
40 #include "H264MasterFirmwareVCM_bin.h"
41 #include "H264MasterFirmwareVBR_bin.h"
42 #include "MPG4MasterFirmware_bin.h"
43 #include "MPG4MasterFirmwareCBR_bin.h"
44 #include "MPG4MasterFirmwareVBR_bin.h"
45 
46 #include "H263SlaveFirmware_bin.h"
47 #include "H263SlaveFirmwareCBR_bin.h"
48 #include "H263SlaveFirmwareVBR_bin.h"
49 #include "H264SlaveFirmware_bin.h"
50 #include "H264SlaveFirmwareCBR_bin.h"
51 #include "H264SlaveFirmwareVBR_bin.h"
52 #include "H264SlaveFirmwareVCM_bin.h"
53 #include "MPG4SlaveFirmware_bin.h"
54 #include "MPG4SlaveFirmwareCBR_bin.h"
55 #include "MPG4SlaveFirmwareVBR_bin.h"
56 
57 
58 #define FW_VER 0x60
59 #define FW_FILE_NAME "topazsc_fw.bin"
60 
61 #define FW_MASTER_INFO(codec,prefix) \
62         { FW_MASTER_##codec,\
63           { FW_VER,\
64             FW_MASTER_##codec,\
65             ui32##prefix##_MasterMTXTOPAZFWTextSize,\
66             ui32##prefix##_MasterMTXTOPAZFWDataSize,\
67             ui32##prefix##_MasterMTXTOPAZFWDataOrigin\
68           },\
69           aui32##prefix##_MasterMTXTOPAZFWText, aui32##prefix##_MasterMTXTOPAZFWData \
70         }
71 
72 #define FW_SLAVE_INFO(codec,prefix) \
73         { FW_SLAVE_##codec,\
74           { FW_VER,\
75             FW_SLAVE_##codec,\
76             ui32##prefix##_SlaveMTXTOPAZFWTextSize,\
77             ui32##prefix##_SlaveMTXTOPAZFWDataSize,\
78             ui32##prefix##_SlaveMTXTOPAZFWDataOrigin\
79           },\
80           aui32##prefix##_SlaveMTXTOPAZFWText, aui32##prefix##_SlaveMTXTOPAZFWData \
81         }
82 
83 
84 
85 struct topaz_fw_info_item_s {
86     unsigned short ver;
87     unsigned short codec;
88 
89     unsigned int  text_size;
90     unsigned int data_size;
91     unsigned int data_location;
92 };
93 typedef struct topaz_fw_info_item_s topaz_fw_info_item_t;
94 
95 enum topaz_fw_codec_e {
96     FW_MASTER_JPEG = 0,
97     FW_SLAVE_JPEG,
98     FW_MASTER_H264_NO_RC,
99     FW_SLAVE_H264_NO_RC,
100     FW_MASTER_H264_VBR,
101     FW_SLAVE_H264_VBR,
102     FW_MASTER_H264_CBR,
103     FW_SLAVE_H264_CBR,
104     FW_MASTER_H263_NO_RC,
105     FW_SLAVE_H263_NO_RC,
106     FW_MASTER_H263_VBR,
107     FW_SLAVE_H263_VBR,
108     FW_MASTER_H263_CBR,
109     FW_SLAVE_H263_CBR,
110     FW_MASTER_MPEG4_NO_RC,
111     FW_SLAVE_MPEG4_NO_RC,
112     FW_MASTER_MPEG4_VBR,
113     FW_SLAVE_MPEG4_VBR,
114     FW_MASTER_MPEG4_CBR,
115     FW_SLAVE_MPEG4_CBR,
116     FW_MASTER_H264_VCM,
117     FW_SLAVE_H264_VCM,
118     FW_NUM
119 };
120 typedef enum topaz_fw_codec_e topaz_fw_codec_t;
121 
122 struct fw_table_s {
123     topaz_fw_codec_t index;
124     topaz_fw_info_item_t header;
125     unsigned int *fw_text;
126     unsigned int *fw_data;
127 };
128 typedef struct fw_table_s fw_table_t;
129 
main()130 int main()
131 {
132     FILE *fp = NULL;
133     topaz_fw_codec_t iter = FW_MASTER_JPEG;
134     unsigned int size = 0;
135     unsigned int i;
136 
137     fw_table_t topaz_fw_table[] = {
138         /* index   header
139          * { ver, codec, text_size, data_size, date_location }
140          * fw_text fw_data */
141         FW_MASTER_INFO(JPEG, JPEG),
142         FW_SLAVE_INFO(JPEG, JPEG),
143 
144         FW_MASTER_INFO(H264_NO_RC, H264),
145         FW_SLAVE_INFO(H264_NO_RC, H264),
146         FW_MASTER_INFO(H264_VBR, H264VBR),
147         FW_SLAVE_INFO(H264_VBR, H264VBR),
148         FW_MASTER_INFO(H264_CBR, H264CBR),
149         FW_SLAVE_INFO(H264_CBR, H264CBR),
150 
151         FW_MASTER_INFO(H263_NO_RC, H263),
152         FW_SLAVE_INFO(H263_NO_RC, H263),
153         FW_MASTER_INFO(H263_VBR, H263VBR),
154         FW_SLAVE_INFO(H263_VBR, H263VBR),
155         FW_MASTER_INFO(H263_CBR, H263CBR),
156         FW_SLAVE_INFO(H263_CBR, H263CBR),
157 
158         FW_MASTER_INFO(MPEG4_NO_RC, MPG4),
159         FW_SLAVE_INFO(MPEG4_NO_RC, MPG4),
160         FW_MASTER_INFO(MPEG4_VBR, MPG4VBR),
161         FW_SLAVE_INFO(MPEG4_VBR, MPG4VBR),
162         FW_MASTER_INFO(MPEG4_CBR, MPG4CBR),
163         FW_SLAVE_INFO(MPEG4_CBR, MPG4CBR),
164 
165         FW_MASTER_INFO(H264_VCM, H264VCM),
166         FW_SLAVE_INFO(H264_VCM, H264VCM),
167     };
168 
169     /* open file  */
170     fp = fopen(FW_FILE_NAME, "w");
171 
172     if (NULL == fp)
173         return -1;
174 
175     /* write fw table into the file */
176     while (iter < FW_NUM) {
177         /* record the size use bytes */
178         topaz_fw_table[iter].header.data_size *= 4;
179         topaz_fw_table[iter].header.text_size *= 4;
180 
181         /* write header */
182         fwrite(&(topaz_fw_table[iter].header), sizeof(topaz_fw_table[iter].header), 1, fp);
183 
184         /* write text */
185         size = topaz_fw_table[iter].header.text_size;
186         fwrite(topaz_fw_table[iter].fw_text, 1, size, fp);
187 
188         /* write data */
189         size = topaz_fw_table[iter].header.data_size;
190         fwrite(topaz_fw_table[iter].fw_data, 1, size, fp);
191 
192         ++iter;
193     }
194 
195     /* close file */
196     fclose(fp);
197 
198     return 0;
199 }
200