summaryrefslogtreecommitdiff
path: root/fw/topazsc_bin.c
blob: 3ec1fd026047996a2e6bb41fa21041102ab2bc38 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
 * Copyright (c) 2011 Intel Corporation. All Rights Reserved.
 * Copyright (c) Imagination Technologies Limited, UK
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Authors:
 *    Elaine Wang <elaine.wang@intel.com>
 *
 */

#include <stdio.h>

#include "JPEGMasterFirmware_bin.h"
#include "JPEGSlaveFirmware_bin.h"

#include "H263MasterFirmware_bin.h"
#include "H263MasterFirmwareCBR_bin.h"
#include "H263MasterFirmwareVBR_bin.h"
#include "H264MasterFirmware_bin.h"
#include "H264MasterFirmwareCBR_bin.h"
#include "H264MasterFirmwareVCM_bin.h"
#include "H264MasterFirmwareVBR_bin.h"
#include "MPG4MasterFirmware_bin.h"
#include "MPG4MasterFirmwareCBR_bin.h"
#include "MPG4MasterFirmwareVBR_bin.h"

#include "H263SlaveFirmware_bin.h"
#include "H263SlaveFirmwareCBR_bin.h"
#include "H263SlaveFirmwareVBR_bin.h"
#include "H264SlaveFirmware_bin.h"
#include "H264SlaveFirmwareCBR_bin.h"
#include "H264SlaveFirmwareVBR_bin.h"
#include "H264SlaveFirmwareVCM_bin.h"
#include "MPG4SlaveFirmware_bin.h"
#include "MPG4SlaveFirmwareCBR_bin.h"
#include "MPG4SlaveFirmwareVBR_bin.h"


#define FW_VER 0x5E
#define FW_FILE_NAME "topazsc_fw.bin"

#define FW_MASTER_INFO(codec,prefix) \
        { FW_MASTER_##codec,\
          { FW_VER,\
            FW_MASTER_##codec,\
            ui32##prefix##_MasterMTXTOPAZFWTextSize,\
            ui32##prefix##_MasterMTXTOPAZFWDataSize,\
            ui32##prefix##_MasterMTXTOPAZFWDataOrigin\
          },\
          aui32##prefix##_MasterMTXTOPAZFWText, aui32##prefix##_MasterMTXTOPAZFWData \
        }

#define FW_SLAVE_INFO(codec,prefix) \
        { FW_SLAVE_##codec,\
          { FW_VER,\
            FW_SLAVE_##codec,\
            ui32##prefix##_SlaveMTXTOPAZFWTextSize,\
            ui32##prefix##_SlaveMTXTOPAZFWDataSize,\
            ui32##prefix##_SlaveMTXTOPAZFWDataOrigin\
          },\
          aui32##prefix##_SlaveMTXTOPAZFWText, aui32##prefix##_SlaveMTXTOPAZFWData \
        }



struct topaz_fw_info_item_s {
    unsigned short ver;
    unsigned short codec;

    unsigned int  text_size;
    unsigned int data_size;
    unsigned int data_location;
};
typedef struct topaz_fw_info_item_s topaz_fw_info_item_t;

enum topaz_fw_codec_e {
    FW_MASTER_JPEG = 0,
    FW_SLAVE_JPEG,
    FW_MASTER_H264_NO_RC,
    FW_SLAVE_H264_NO_RC,
    FW_MASTER_H264_VBR,
    FW_SLAVE_H264_VBR,
    FW_MASTER_H264_CBR,
    FW_SLAVE_H264_CBR,
    FW_MASTER_H263_NO_RC,
    FW_SLAVE_H263_NO_RC,
    FW_MASTER_H263_VBR,
    FW_SLAVE_H263_VBR,
    FW_MASTER_H263_CBR,
    FW_SLAVE_H263_CBR,
    FW_MASTER_MPEG4_NO_RC,
    FW_SLAVE_MPEG4_NO_RC,
    FW_MASTER_MPEG4_VBR,
    FW_SLAVE_MPEG4_VBR,
    FW_MASTER_MPEG4_CBR,
    FW_SLAVE_MPEG4_CBR,
    FW_MASTER_H264_VCM,
    FW_SLAVE_H264_VCM,
    FW_NUM
};
typedef enum topaz_fw_codec_e topaz_fw_codec_t;

struct fw_table_s {
    topaz_fw_codec_t index;
    topaz_fw_info_item_t header;
    unsigned long *fw_text;
    unsigned long *fw_data;
};
typedef struct fw_table_s fw_table_t;

int main()
{
    FILE *fp = NULL;
    topaz_fw_codec_t iter = FW_MASTER_JPEG;
    unsigned int size = 0;
    unsigned int i;

    fw_table_t topaz_fw_table[] = {
        /* index   header
         * { ver, codec, text_size, data_size, date_location }
         * fw_text fw_data */
        FW_MASTER_INFO(JPEG, JPEG),
        FW_SLAVE_INFO(JPEG, JPEG),

        FW_MASTER_INFO(H264_NO_RC, H264),
        FW_SLAVE_INFO(H264_NO_RC, H264),
        FW_MASTER_INFO(H264_VBR, H264VBR),
        FW_SLAVE_INFO(H264_VBR, H264VBR),
        FW_MASTER_INFO(H264_CBR, H264CBR),
        FW_SLAVE_INFO(H264_CBR, H264CBR),

        FW_MASTER_INFO(H263_NO_RC, H263),
        FW_SLAVE_INFO(H263_NO_RC, H263),
        FW_MASTER_INFO(H263_VBR, H263VBR),
        FW_SLAVE_INFO(H263_VBR, H263VBR),
        FW_MASTER_INFO(H263_CBR, H263CBR),
        FW_SLAVE_INFO(H263_CBR, H263CBR),

        FW_MASTER_INFO(MPEG4_NO_RC, MPG4),
        FW_SLAVE_INFO(MPEG4_NO_RC, MPG4),
        FW_MASTER_INFO(MPEG4_VBR, MPG4VBR),
        FW_SLAVE_INFO(MPEG4_VBR, MPG4VBR),
        FW_MASTER_INFO(MPEG4_CBR, MPG4CBR),
        FW_SLAVE_INFO(MPEG4_CBR, MPG4CBR),

        FW_MASTER_INFO(H264_VCM, H264VCM),
        FW_SLAVE_INFO(H264_VCM, H264VCM),
    };

    /* open file  */
    fp = fopen(FW_FILE_NAME, "w");

    if (NULL == fp)
        return -1;

    /* write fw table into the file */
    while (iter < FW_NUM) {
        /* record the size use bytes */
        topaz_fw_table[iter].header.data_size *= 4;
        topaz_fw_table[iter].header.text_size *= 4;

        /* write header */
        fwrite(&(topaz_fw_table[iter].header), sizeof(topaz_fw_table[iter].header), 1, fp);

        /* write text */
        size = topaz_fw_table[iter].header.text_size;
        fwrite(topaz_fw_table[iter].fw_text, 1, size, fp);

        /* write data */
        size = topaz_fw_table[iter].header.data_size;
        fwrite(topaz_fw_table[iter].fw_data, 1, size, fp);

        ++iter;
    }

    /* close file */
    fclose(fp);

    return 0;
}