fix typo error
[tas2555sw-android/tas2555-util.git] / main.c
1 /*
2 ** =============================================================================
3 ** Copyright (c) 2016  Texas Instruments Inc.
4 **
5 ** This program is free software; you can redistribute it and/or modify it under
6 ** the terms of the GNU General Public License as published by the Free Software 
7 ** Foundation; version 2.
8 **
9 ** This program is distributed in the hope that it will be useful, but WITHOUT
10 ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 ** FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 **
13 ** You should have received a copy of the GNU General Public License along with
14 ** this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15 ** Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 **
17 ** File:
18 **     main.c
19 **
20 ** Description:
21 **     test program for TAS2555 Android Linux drivers
22 **
23 ** =============================================================================
24 */
26 #include <sys/cdefs.h>
27 #include <sys/stat.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <time.h>
31 #include <math.h>
32 #include <ctype.h>
33 #include <stdio.h>
34 #include <unistd.h>
35 #include <errno.h>
36 #include <stdarg.h>
37 #include <fcntl.h>
38 #include "ti_audio.h"
40 static void usage(){
42         fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
43                 "usage: ti_audio -r book page register [count]               (read, hexdecimal)",
44                 "       ti_audio -w book page register value1 [value2 ...]  (write, hexdecimal)",
45                 "       ti_audio -d on                            (turn on the debug msg, bool)",
46                 "       ti_audio -p [n]                        (get/[set] DSP program, decimal)",
47                 "       ti_audio -c [n]                  (get/[set] DSP configuration, decimal)",
48                 "       ti_audio -s [n]                        (get/[set] sample rate, decimal)",
49                 "       ti_audio -b [n]                           (get/[set] bit rate, decimal)",
50                 "       ti_audio -v [n]                             (get/[set] volume, decimal)",
51                 "       ti_audio -f                                   (trigger firmware reload)",               
52                 "       ti_audio -o on                              (turn on/off TAS2555, bool)",
53                 "       ti_audio -t                                    (get firmware timestamp)",
54                 TIAUDIO_VERSION);       
55 }
57 static int str2hexchar(char *argv, unsigned char *pUInt8_Val){
58         int str_len = strlen(argv), i, result = -1, j;
59         unsigned char val[2] = {0};
61         if(str_len > 2){
62                 fprintf(stderr, "invalid parameters\n");
63                 goto err;
64         }
66         for(i = (str_len-1), j=0; i >= 0; i--, j++){
67                 if((argv[i] <= '9')&&(argv[i] >= '0')){
68                         val[j] = argv[i] - 0x30;
69                 }else if((argv[i] <='f')&&(argv[i]>= 'a')){
70                         val[j] = argv[i] - 0x57;
71                 }else if((argv[i] <='F')&&(argv[i]>= 'A')){
72                         val[j] = argv[i] - 0x37;
73                 }else{
74                         fprintf(stderr, "reg/data out of range\n");
75                         goto err;
76                 }
77         }
78         
79         *pUInt8_Val = (unsigned char)(val[0]|(val[1]<<4));
80         result = 0;
81         
82 err:
83         return result;
84 }
86 /*
87 static int str2hexshort(char *argv, unsigned short *pUInt16_Val){
88         int str_len = strlen(argv), i, j, result = -1;
89         unsigned char val[4] = {0};
91         if(str_len > 4){
92                 fprintf(stderr, "invalid parameters\n");
93                 goto err;
94         }
96         for(i = (str_len-1), j=0; i >= 0; i--, j++){
97                 if((argv[i] <= '9')&&(argv[i] >= '0')){
98                         val[j] = argv[i] - 0x30;
99                 }else if((argv[i] <='f')&&(argv[i]>= 'a')){
100                         val[j] = argv[i] - 0x57;
101                 }else if((argv[i] <='F')&&(argv[i]>= 'A')){
102                         val[j] = argv[i] - 0x37;
103                 }else{
104                         fprintf(stderr, "reg/data out of range\n");
105                         goto err;
106                 }
107         }
108         
109         *pUInt16_Val = (unsigned short)(val[0]|(val[1]<<4)|(val[2]<<8)|(val[3]<<12));
110         result = 0;
112 err:
113         return result;
115 */
117 static int str2decimal(char *argv, unsigned int *pUInt32_Val){
118         int max_len = strlen(MAX_INT_STR), i, result = -1, j;
119         int str_len = strlen(argv);
120         unsigned int nValue = 0;
121         unsigned char temp;
123         if(str_len > max_len){
124                 fprintf(stderr, "invalid parameters\n");
125                 goto err;
126         }
127         
128         for(i = (str_len-1), j=0; i >= 0; i--, j++){
129                 if((argv[i] <= '9')&&(argv[i] >= '0')){
130                         temp = argv[i] - 0x30;
131                         nValue += (temp * pow(10, j));
132                 }else{
133                         fprintf(stderr, "reg/data out of range\n");
134                         goto err;
135                 }
136         }
137         
138         *pUInt32_Val = nValue;
139         result = 0;
140         
141 err:
142         return result;
145 static int TiAudio_Reg_Write(int fileHandle, int argc, char **argv){
146         int err = -1;
147         unsigned char *pBuff = NULL, book, page, reg,value;
148         unsigned int whole_reg = 0;
149         unsigned int temp_reg = 0;
150         int i=0, reg_count = 0;
151         
152         if(argc < 6){
153                 fprintf(stderr, "invalid para numbers\n");
154                 goto err;
155         }
156         
157         reg_count = argc - 5;
159         pBuff = (unsigned char *)malloc(reg_count + 5);
160         if(pBuff == NULL){
161                 fprintf(stderr, "not enough mem\n");
162                 goto err;               
163         }
164         
165         pBuff[0] = TIAUDIO_CMD_REG_WITE;
166         
167         err = str2hexchar(argv[2], &book);
168         if(err < 0){
169                 goto err;
170         }
171         
172         err = str2hexchar(argv[3], &page);
173         if(err < 0){
174                 goto err;
175         }
176         
177         err = str2hexchar(argv[4], &reg);
178         if(err < 0){
179                 goto err;
180         }
181         
182         whole_reg = TAS2555_REG(book, page, reg);
183         pBuff[1] = (whole_reg & 0xff000000) >> 24;
184         pBuff[2] = (whole_reg & 0x00ff0000) >> 16;
185         pBuff[3] = (whole_reg & 0x0000ff00) >> 8;
186         pBuff[4] = (whole_reg & 0x000000ff) ;
187         
188         for(i=0; i< reg_count; i++){
189                 err = str2hexchar(argv[i+5], &value);
190                 if(err < 0){
191                         goto err;
192                 }
193                 pBuff[i + 5] = value;
194         }
195         
196         err = write(fileHandle, pBuff, reg_count+5);
197         if(err != (reg_count+5)){
198                 fprintf(stderr, "write err=%d\n", err);
199         }else{
200                 for(i=0; i< reg_count; i++){
201                         temp_reg = whole_reg + i;
202                         fprintf(stderr, "W B[%d]P[%d]R[%d]=0x%x\n", TAS2555_BOOK_ID(temp_reg), TAS2555_PAGE_ID(temp_reg), TAS2555_PAGE_REG(temp_reg), pBuff[i + 5] );
203                 }
204         }       
206 err:
207         if(pBuff != NULL)
208                 free(pBuff);    
209         
210         return err;
213 static int TiAudio_Reg_Read(int fileHandle, int argc, char **argv){
214         int err = -1;
215         unsigned char *pBuff = NULL, book, page, reg, len;
216         unsigned int whole_reg = 0;
217         unsigned int temp_reg = 0;
218         int i=0, reg_count = 0;
219         
220         if((argc != 5) &&(argc != 6))  {
221                 fprintf(stderr, "invalid para numbers\n");
222                 goto err;
223         }
224         
225         if(argc == 5)
226                 reg_count = 1;
227         else{
228                 err = str2hexchar(argv[5], &len);
229                 if(err < 0){
230                         goto err;
231                 }
232                 reg_count = len;
233         }
234         
235         pBuff = (unsigned char *)malloc(reg_count + 5);
236         if(pBuff == NULL){
237                 fprintf(stderr, "not enough mem\n");
238                 goto err;               
239         }
240         
241         pBuff[0] = TIAUDIO_CMD_REG_READ;
242         
243         err = str2hexchar(argv[2], &book);
244         if(err < 0){
245                 goto err;
246         }
247         
248         err = str2hexchar(argv[3], &page);
249         if(err < 0){
250                 goto err;
251         }
252         
253         err = str2hexchar(argv[4], &reg);
254         if(err < 0){
255                 goto err;
256         }
257         
258         whole_reg = TAS2555_REG(book, page, reg);
259         pBuff[1] = (whole_reg & 0xff000000) >> 24;
260         pBuff[2] = (whole_reg & 0x00ff0000) >> 16;
261         pBuff[3] = (whole_reg & 0x0000ff00) >> 8;
262         pBuff[4] = (whole_reg & 0x000000ff) ;
263                 
264         err = write(fileHandle, pBuff, 5);
265         if(err != 5){
266                 fprintf(stderr, "read err=%d\n", err);
267                 goto err;
268         }
269         
270         err = read(fileHandle, pBuff, reg_count);
271         if(err != reg_count){
272                 fprintf(stderr, "read err=%d\n", err);
273                 goto err;
274         }else{
275                 for(i=0; i< reg_count; i++){
276                         temp_reg = whole_reg + i;
277                         fprintf(stderr, "R B[%d]P[%d]R[%d]=0x%x\n", TAS2555_BOOK_ID(temp_reg), TAS2555_PAGE_ID(temp_reg), TAS2555_PAGE_REG(temp_reg), pBuff[i]);
278                 }
279         }       
281 err:
282         if(pBuff != NULL)
283                 free(pBuff);    
284         
285         return err;
288 static int TiAudio_Debug_On(int fileHandle, int argc, char **argv){
289         int err = -1;
290         unsigned char pBuff[2], on;
291         
292         if(argc != 3) {
293                 fprintf(stderr, "invalid para numbers\n");
294                 goto err;
295         }
296         
297         pBuff[0] = TIAUDIO_CMD_DEBUG_ON;
298         
299         err = str2hexchar(argv[2], &on);
300         if(err < 0){
301                 goto err;
302         }
303         
304         pBuff[1] = on; 
305         
306         err = write(fileHandle, pBuff, 2);
307         if(err != 2){
308                 fprintf(stderr, "set err=%d\n", err);
309                 goto err;
310         }
311         
312         if(on == 0){
313                 fprintf(stderr, "DBG msg Off\n");
314         }else{
315                 fprintf(stderr, "DBG msg On\n");
316         }
317         
318 err:
320         return err;
323 static int TiAudio_Program(int fileHandle, int argc, char **argv){
324         int err = -1;
325         unsigned char pBuff[PROGRAM_BUF_SIZE], bSet = 0;
326         unsigned int nProgram;
327         
328         if(argc == 2){
329                 bSet = 0;
330         }else if(argc == 3){
331                 bSet = 1;
332         }else{
333                 fprintf(stderr, "invalid para numbers\n");
334                 goto err;
335         }
336         
337         pBuff[0] = TIAUDIO_CMD_PROGRAM;
338         
339         if(bSet == 1){
340                 err = str2decimal(argv[2], &nProgram);
341                 if(err < 0){
342                         fprintf(stderr, "invalid para numbers\n");              
343                         goto err;
344                 }
345                 
346                 pBuff[1] = nProgram;
347         }
348         
349         err = write(fileHandle, pBuff, (1+bSet));
350         if(err != (bSet+1)){
351                 fprintf(stderr, "write err=%d\n", err);
352                 goto err;
353         }
354         
355         if(bSet == 1){
356                 fprintf(stderr, "Program Set to %d\n", nProgram);
357         }else{
358                 err = read(fileHandle, pBuff, PROGRAM_BUF_SIZE);
359                 if(err != PROGRAM_BUF_SIZE){
360                         fprintf(stderr, "read err=%d\n", err);
361                         goto err;
362                 }else{
363                         unsigned char nPrograms = pBuff[0];
364                         unsigned char nCurProgram = pBuff[1];
365                         unsigned char *pName = &pBuff[2];
366                         unsigned char *pDescription = &pBuff[2 + FW_NAME_SIZE];
367                         fprintf(stderr, "Total Programs   : %d\n", nPrograms);
368                         fprintf(stderr, "Current Programs : %d\n", nCurProgram);
369                         fprintf(stderr, "\t Name: %s\n", pName);
370                         fprintf(stderr, "\t Description : %s\n", pDescription);
371                 }
372         }
374 err:
376         return err;
379 static int TiAudio_Configuration(int fileHandle, int argc, char **argv){
380         int err = -1;
381         unsigned char pBuff[CONFIGURATION_BUF_SIZE], bSet = 0;
382         unsigned int nConfiguration;
383         
384         if(argc == 2){
385                 bSet = 0;
386         }else if(argc == 3){
387                 bSet = 1;
388         }else{
389                 fprintf(stderr, "invalid para numbers\n");
390                 goto err;
391         }
392         
393         pBuff[0] = TIAUDIO_CMD_CONFIGURATION;
394         
395         if(bSet == 1){
396                 err = str2decimal(argv[2], &nConfiguration);
397                 if(err < 0){
398                         goto err;
399                 }
400                 
401                 pBuff[1] = nConfiguration;
402         }
403         
404         err = write(fileHandle, pBuff, (1+bSet));
405         if(err != (bSet+1)){
406                 fprintf(stderr, "write err=%d\n", err);
407                 goto err;
408         }
409         
410         if(bSet == 1){
411                 fprintf(stderr, "Configuration Set to %d\n", nConfiguration);
412         }else{
413                 err = read(fileHandle, pBuff, CONFIGURATION_BUF_SIZE);
414                 if(err != CONFIGURATION_BUF_SIZE){
415                         fprintf(stderr, "read err=%d\n", err);
416                         goto err;
417                 }else{
418                         unsigned char nConfigurations = pBuff[0];
419                         unsigned char nCurConfiguration = pBuff[1];
420                         unsigned char *pName = &pBuff[2];
421                         unsigned char nProgram = pBuff[2 + FW_NAME_SIZE];
422                         unsigned char nPLL = pBuff[3 + FW_NAME_SIZE];
423                         unsigned int nSampleRate = pBuff[4 + FW_NAME_SIZE] + 
424                                 ((unsigned int)pBuff[5 + FW_NAME_SIZE] << 8) +
425                                 ((unsigned int)pBuff[6 + FW_NAME_SIZE] << 16) +
426                                 ((unsigned int)pBuff[7 + FW_NAME_SIZE] << 24);                  
427                         unsigned char *pDescription = &pBuff[8 + FW_NAME_SIZE];
428                         fprintf(stderr, "Total Configurations : %d\n", nConfigurations);
429                         fprintf(stderr, "Current Configuration: %d\n", nCurConfiguration);
430                         fprintf(stderr, "\t Name: %s\n", pName);
431                         fprintf(stderr, "\t Description : %s\n", pDescription);
432                         fprintf(stderr, "\t nProgram: %d\n", nProgram);
433                         fprintf(stderr, "\t nPLL: %d\n", nPLL);
434                         fprintf(stderr, "\t nSampleRate: %d\n", nSampleRate);
435                 }
436         }
438 err:
440         return err;
443 static int TiAudio_SampleRate(int fileHandle, int argc, char **argv){
444         int err = -1;
445         unsigned char pBuff[5];
446         unsigned char bSet = 0;
447         unsigned int nSampleRate;
448         int nLen;
449         
450         if(argc == 2){
451                 bSet = 0;
452         }else if(argc == 3){
453                 bSet = 1;
454         }else{
455                 fprintf(stderr, "invalid para numbers\n");
456                 goto err;
457         }
458         
459         pBuff[0] = TIAUDIO_CMD_SAMPLERATE;
460         
461         if(bSet == 1){
462                 if(strcmp(argv[2], SR_STR_48K) == 0)
463                         nSampleRate = SR_NUM_48K;
464                 else if(strcmp(argv[2], SR_STR_44K) == 0)
465                         nSampleRate = SR_NUM_44K;
466                 else if(strcmp(argv[2], SR_STR_16K) == 0)
467                         nSampleRate = SR_NUM_16K;
468                 else{
469                         fprintf(stderr, "invalid para numbers\n");
470                         goto err;
471                 }
472                 
473                 pBuff[1] = (nSampleRate&0xff000000)>>24;
474                 pBuff[2] = (nSampleRate&0x00ff0000)>>16;
475                 pBuff[3] = (nSampleRate&0x0000ff00)>>8;
476                 pBuff[4] = (nSampleRate&0x000000ff);
477         }
478         
479         if(bSet) nLen = 5; 
480         else nLen = 1;
481         
482         err = write(fileHandle, pBuff, nLen);
483         if(err != nLen){
484                 fprintf(stderr, "write err=%d\n", err);
485                 goto err;
486         }
487         
488         if(bSet == 1){
489                 fprintf(stderr, "Sample Rate Set to %d\n", nSampleRate);
490         }else{
491                 err = read(fileHandle, pBuff, 4);
492                 if(err != 4){
493                         fprintf(stderr, "read err=%d\n", err);
494                         goto err;
495                 }else{
496                         nSampleRate = pBuff[0] + 
497                                 ((unsigned int)pBuff[1] << 8) +
498                                 ((unsigned int)pBuff[2] << 16) +
499                                 ((unsigned int)pBuff[3] << 24);                 
500                         fprintf(stderr, "\t nSampleRate: %d\n", nSampleRate);
501                 }
502         }
504 err:
506         return err;
509 static int TiAudio_BitRate(int fileHandle, int argc, char **argv){
510         int err = -1;
511         unsigned char pBuff[5];
512         unsigned char bSet = 0;
513         unsigned int nBitRate;
514         
515         if(argc == 2){
516                 bSet = 0;
517         }else if(argc == 3){
518                 bSet = 1;
519         }else{
520                 fprintf(stderr, "invalid para numbers\n");
521                 goto err;
522         }
523         
524         pBuff[0] = TIAUDIO_CMD_BITRATE;
525         
526         if(bSet == 1){
527                 if(strcmp(argv[2], "32") == 0)
528                         nBitRate = 32;
529                 else if(strcmp(argv[2], "24") == 0)
530                         nBitRate = 24;
531                 else if(strcmp(argv[2], "20") == 0)
532                         nBitRate = 20;
533                 else if(strcmp(argv[2], "16") == 0)
534                         nBitRate = 16;                  
535                 else{
536                         fprintf(stderr, "invalid para numbers\n");
537                         goto err;
538                 }
539                 
540                 pBuff[1] = nBitRate;
541         }
542         
543         err = write(fileHandle, pBuff, (1+bSet));
544         if(err != (1+bSet)){
545                 fprintf(stderr, "write err=%d\n", err);
546                 goto err;
547         }
548         
549         if(bSet == 1){
550                 fprintf(stderr, "BitRate Set to %d\n", nBitRate);
551         }else{
552                 err = read(fileHandle, pBuff, 1);
553                 if(err != 1){
554                         fprintf(stderr, "read err=%d\n", err);
555                         goto err;
556                 }else{
557                         nBitRate = pBuff[0];
558                         fprintf(stderr, "\t BitRate: %d\n", nBitRate);
559                 }
560         }
562 err:
564         return err;
567 static int TiAudio_DACVolume(int fileHandle, int argc, char **argv){
568         int err = -1;
569         unsigned char pBuff[5];
570         unsigned char bSet = 0;
571         unsigned int nVol;
572         
573         if(argc == 2){
574                 bSet = 0;
575         }else if(argc == 3){
576                 bSet = 1;
577         }else{
578                 fprintf(stderr, "invalid para numbers\n");
579                 goto err;
580         }
581         
582         pBuff[0] = TIAUDIO_CMD_DACVOLUME;
583         
584         if(bSet == 1){
585                 err = str2decimal(argv[2], &nVol);
586                 if(err < 0){
587                         goto err;
588                 }
589                 
590                 pBuff[1] = nVol;
591         }
592         
593         err = write(fileHandle, pBuff, (1+bSet));
594         if(err != (1+bSet)){
595                 fprintf(stderr, "write err=%d\n", err);
596                 goto err;
597         }
598         
599         if(bSet == 1){
600                 fprintf(stderr, "DAC Volume Set to %d\n", nVol);
601         }else{
602                 err = read(fileHandle, pBuff, 1);
603                 if(err != 1){
604                         fprintf(stderr, "read err=%d\n", err);
605                         goto err;
606                 }else{
607                         nVol = pBuff[0];                
608                         fprintf(stderr, "\t DAC Volume: %d\n", nVol);
609                 }
610         }
612 err:
614         return err;
617 static int TiAudio_SpeakerOn(int fileHandle, int argc, char **argv){
618         int err = -1;
619         unsigned char pBuff[2], on;
620         
621         if(argc != 3) {
622                 fprintf(stderr, "invalid para numbers\n");
623                 goto err;
624         }
625         
626         pBuff[0] = TIAUDIO_CMD_SPEAKER;
627         
628         err = str2hexchar(argv[2], &on);
629         if(err < 0){
630                 goto err;
631         }
632         
633         pBuff[1] = on; 
634         
635         err = write(fileHandle, pBuff, 2);
636         if(err != 2){
637                 fprintf(stderr, "set err=%d\n", err);
638                 goto err;
639         }
640         
641         if(on == 0){
642                 fprintf(stderr, "TAS2555 Power Off\n");
643         }else{
644                 fprintf(stderr, "TAS2555 Power On\n");
645         }
646         
647 err:
649         return err;
652 static int TiAudio_Timestamp(int fileHandle, int argc, char **argv){
653         int err = -1;
654         unsigned char pBuff[4];
655         
656         pBuff[0] = TIAUDIO_CMD_FW_TIMESTAMP;
657         
658         err = write(fileHandle, pBuff, 1);
659         if(err != 1){
660                 fprintf(stderr, "write err=%d\n", err);
661                 goto err;
662         }
663         
664         err = read(fileHandle, pBuff, 4);
665         if(err != 4){
666                 fprintf(stderr, "read err=%d\n", err);
667                 goto err;
668         }else{
669                 unsigned int nTimestamp = pBuff[0] + 
670                         ((unsigned int)pBuff[1] << 8) +
671                         ((unsigned int)pBuff[2] << 16) +
672                         ((unsigned int)pBuff[3] << 24);
673         
674                 time_t t = (time_t)nTimestamp;  
675                 struct tm *p;  
676                 p=localtime(&t);  
677                 char s[100];  
678                 strftime(s, sizeof(s), "%Y-%m-%d %H:%M:%S", p);  
679                 fprintf(stderr, "FW Timestamp : %d: %s\n", (int)t, s); 
680         }
682 err:
684         return err;
687 static int TiAudio_TriggerFWReload(int fileHandle, int argc, char **argv){
688         int err = -1;
689         unsigned char pBuff[4]; 
690         pBuff[0] = TIAUDIO_CMD_FW_RELOAD;
691         
692         err = write(fileHandle, pBuff, 1);
693         if(err != 1){
694                 fprintf(stderr, "write err=%d\n", err);
695                 goto err;
696         }
697         
698         fprintf(stderr, "Firmware Reload Triggered\n"); 
699         
700 err:
702         return err;
705 static int getDevHandle(){
706         int fileHandle = -1;
707         fileHandle = open(TI_AUDIO_NAME, O_RDWR);
708         if(fileHandle < 0 ){
709                 fprintf(stderr, "[ERROR]file(%s) open_RDWR error\n", TI_AUDIO_NAME);
710         }               
712         return fileHandle;
715 int main(int argc, char **argv)
717         int ret = 0;
718         int ch;
719         int fileHandle = -1;
721         fileHandle = getDevHandle();
722         if(fileHandle < 0 ){
723                 fprintf(stderr, " file handle err=%d\n", fileHandle);
724                 return ret;
725         }
726         
727         if(argc == 1){
728                 usage();
729                 return 0;
730         }
732         while ((ch = getopt(argc, argv, "wrdpcsbvotf")) != -1) {
733                 switch (ch) {
734                 case 'w': 
735                         ret = TiAudio_Reg_Write(fileHandle, argc, argv);                        
736                         break;
737                 case 'r':
738                         ret = TiAudio_Reg_Read(fileHandle, argc, argv);
739                         break;
740                 case 'd':
741                         ret = TiAudio_Debug_On(fileHandle, argc, argv);
742                         break;          
743                 case 'p':
744                         ret = TiAudio_Program(fileHandle, argc, argv);
745                         break;                                  
746                 case 'c':
747                         ret = TiAudio_Configuration(fileHandle, argc, argv);
748                         break;          
749                 case 's':
750                         ret = TiAudio_SampleRate(fileHandle, argc, argv);
751                         break;          
752                 case 'b':
753                         ret = TiAudio_BitRate(fileHandle, argc, argv);
754                         break;
755                 case 'v':
756                         ret = TiAudio_DACVolume(fileHandle, argc, argv);
757                         break;          
758                 case 'o':
759                         ret = TiAudio_SpeakerOn(fileHandle, argc, argv);
760                         break;                          
761                 case 't':
762                         ret = TiAudio_Timestamp(fileHandle, argc, argv);
763                         break;          
764                 case 'f':
765                         ret = TiAudio_TriggerFWReload(fileHandle, argc, argv);
766                         break;
767                 default:
768                         usage();
769                         break;
770                 }
771         }
773         if(fileHandle > 0 )
774                 close(fileHandle);
775         
776         return ret;