1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include "pa.h"
5 #include "pdsp_ver.h"
6 #include "paconst.c"
8 #define DEVICE_PA_NUM_PDSPS (6U)
9 #define PA_PDSP_CONST_NUM_REG (4U)
10 #define PASS_VER_STR_LEN (16U)
12 typedef uint32_t u32;
14 #include "pdsp_blob_hdr.h"
16 static char *versions[DEVICE_PA_NUM_PDSPS] = {
17 PASS_VERSION_STR,
18 PASS_VERSION_STR,
19 PASS_VERSION_STR,
20 PASS_VERSION_STR,
21 PASS_VERSION_STR,
22 PASS_VERSION_STR
23 };
24 static char *pdsp_in_file_names[DEVICE_PA_NUM_PDSPS] = {
25 "classify1_0.bib",
26 "classify1_1.bib",
27 "classify1_2.bib",
28 "classify2.bib",
29 "pam.bib",
30 "pam.bib",
31 };
33 static char *pdsp_out_file_names[DEVICE_PA_NUM_PDSPS] = {
34 "ks2_pa_pdsp0_classify1",
35 "ks2_pa_pdsp1_classify1",
36 "ks2_pa_pdsp2_classify1",
37 "ks2_pa_pdsp3_classify2",
38 "ks2_pa_pdsp4_pam",
39 "ks2_pa_pdsp5_pam",
40 };
42 int main(int argc, char **argv)
43 {
44 unsigned long b_sz, total = 0;
45 struct pa_pdsp_firmware pdsp;
46 char in_file_name[128];
47 char out_file_name[128];
48 char buf[1024];
49 char *pc;
50 FILE *outfp, *infp;
51 int j, i;
52 int size;
54 for (i = 0; i < DEVICE_PA_NUM_PDSPS; i++) {
55 if (!pdsp_in_file_names[i])
56 continue;
57 bzero(in_file_name, sizeof(in_file_name));
58 bzero(out_file_name, sizeof(out_file_name));
59 strcpy(in_file_name, (char *)pdsp_in_file_names[i]);
60 strcpy(out_file_name, (char *)pdsp_out_file_names[i]);
61 pc = &out_file_name[strlen(out_file_name)];
63 strcat(pc, ".bin");
64 outfp=fopen(out_file_name,"wb");
65 infp=fopen(in_file_name,"rb");
66 printf("input file: %s\n",in_file_name);
67 printf("output file: %s\n",out_file_name);
68 if (!outfp)
69 {
70 printf("Unable to open output file! %s", out_file_name);
71 exit(1);
72 }
74 if (!infp)
75 {
76 printf("Unable to open input file! %s", in_file_name);
77 fclose(outfp);
78 exit(2);
79 }
81 strncpy((char *)&pdsp.version[0], (char *)versions[i], PASS_VER_STR_LEN);
82 memcpy(&pdsp.constants[0], &pap_pdsp_const_reg_map[i][0], sizeof(u32) * PA_PDSP_CONST_NUM_REG);
83 fwrite(&pdsp, sizeof(pdsp), 1, outfp);
84 while(1) {
85 size = fread(buf, 1, 1024, infp);
86 if (size <= 0)
87 break;
88 fwrite(buf, size, 1, outfp);
89 }
90 fclose(outfp);
91 fclose(infp);
92 }
93 }