@@ -64,6 +64,7 @@ static void usage(char *name)
6464 fprintf (stdout , " -n control id e.g. 22\n" );
6565 fprintf (stdout , " -s set data using ASCII CSV input file\n" );
6666 fprintf (stdout , " -b set/get control in binary mode(e.g. for set, use binary input file, for get, dump out in hex format)\n" );
67+ fprintf (stdout , " -r no abi header for the input file, or not dumping abi header for get.\n" );
6768}
6869
6970static void header_init (struct ctl_data * ctl_data )
@@ -81,8 +82,11 @@ static int read_setup(struct ctl_data *ctl_data)
8182 FILE * fh ;
8283 unsigned int x ;
8384 int n = 0 ;
85+ struct sof_abi_hdr * hdr =
86+ (struct sof_abi_hdr * )& ctl_data -> buffer [2 ];
8487 int n_max = ctl_data -> ctrl_size / sizeof (unsigned int );
8588 char * mode = ctl_data -> binary ? "rb" : "r" ;
89+ int abi_size = 0 ;
8690 int separator ;
8791
8892 /* open input file */
@@ -93,10 +97,24 @@ static int read_setup(struct ctl_data *ctl_data)
9397 }
9498
9599 if (ctl_data -> binary ) {
96- n = fread (& ctl_data -> buffer [2 ], sizeof (int ), n_max , fh );
100+ /* create abi header*/
101+ if (ctl_data -> no_abi ) {
102+ header_init (ctl_data );
103+ abi_size = sizeof (struct sof_abi_hdr ) / sizeof (int );
104+ }
105+
106+ n = fread (& ctl_data -> buffer [2 + abi_size ],
107+ sizeof (int ), n_max - abi_size , fh );
108+
109+ if (ctl_data -> no_abi ) {
110+ hdr -> size = n * sizeof (int );
111+ n += abi_size ;
112+ }
113+
97114 goto read_done ;
98115 }
99116
117+ /* reading for ASCII CSV txt */
100118 while (fscanf (fh , "%u" , & x ) != EOF ) {
101119 if (n < n_max )
102120 ctl_data -> buffer [2 + n ] = x ;
@@ -152,6 +170,14 @@ static void binary_data_dump(struct ctl_data *ctl_data)
152170 /* exclude the type and size header */
153171 int_offset = 2 ;
154172
173+ /* exclude abi header if '-r' specified */
174+ if (ctl_data -> no_abi ) {
175+ int_offset += sizeof (struct sof_abi_hdr ) /
176+ sizeof (uint32_t );
177+ n -= sizeof (struct sof_abi_hdr ) /
178+ sizeof (uint16_t );
179+ }
180+
155181 /* get the dumping start address */
156182 config = (uint16_t * )& ctl_data -> buffer [int_offset ];
157183
@@ -232,7 +258,7 @@ int main(int argc, char *argv[])
232258
233259 ctl_data -> dev = "hw:0" ;
234260
235- while ((opt = getopt (argc , argv , "hD:c:s:n:b " )) != -1 ) {
261+ while ((opt = getopt (argc , argv , "hD:c:s:n:br " )) != -1 ) {
236262 switch (opt ) {
237263 case 'D' :
238264 ctl_data -> dev = optarg ;
@@ -252,6 +278,9 @@ int main(int argc, char *argv[])
252278 case 'b' :
253279 ctl_data -> binary = true;
254280 break ;
281+ case 'r' :
282+ ctl_data -> no_abi = true;
283+ break ;
255284 case 'h' :
256285 usage (argv [0 ]);
257286 exit (0 );
@@ -314,6 +343,10 @@ int main(int argc, char *argv[])
314343 fprintf (stderr , "Error: Input file unavailable.\n" );
315344 exit (EXIT_FAILURE );
316345 }
346+
347+ /* need more space for raw data file(no header in the file) */
348+ if (ctl_data -> no_abi )
349+ ctl_data -> ctrl_size += sizeof (struct sof_abi_hdr );
317350 } else {
318351 /* Get control attributes from info. */
319352 ctl_data -> ctrl_size =
0 commit comments