1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <ctype.h>
4 #include <errno.h>
5 #include <getopt.h>
6 #include <string.h>
7 #include "iaxxx_odsp_hw.h"
8
9
10 static struct option const long_options[] =
11 {
12 {"getpluginstatusinfo", no_argument, NULL, 's'},
13 {"getpluginendpointstatus", no_argument, NULL, 'e'},
14 {"plugininstanceid", required_argument, NULL, 'i'},
15 {"endpointindex", required_argument, NULL, 'n'},
16 {"endpointdirection", required_argument, NULL, 'd'},
17 {"blockid", required_argument, NULL, 'b'},
18 {"help", no_argument, NULL, 'h'},
19 {NULL, 0, NULL, 0}
20 };
21
22
usage()23 void usage() {
24 fputs("\
25 USAGE -\n\
26 -------\n\
27 1) getpluginstatus_test -s -i <plugin-instance-id> \n\
28 get status info from plugin.\n\
29 2) getpluginstatus_test -e -i <plugin-instance-id> -n <endpoint-index>"\
30 " -d <direction>\n\
31 get endpoint status info from plugin.\n\
32 3) getpluginstatus_test -r -b <processor-block-id>\n\
33 read if any error occurred in any of the plugins\n\n", stdout);
34
35 exit(0);
36 }
37
38
main(int argc,char ** argv)39 int main(int argc, char **argv)
40 {
41 struct iaxxx_odsp_hw* odsp_hw= NULL;
42 int err = 0;
43
44 int plugin_instance_id = -1;
45 int test_option = -1;
46 int enpoint_index = -1;
47 int enpoint_dir = -1;
48 int block_id = -1;
49 uint32_t error_code;
50 uint8_t error_instance;
51
52 /* getopt_long stores the option index here. */
53 int option_index = 0;
54 int ch;
55
56 struct iaxxx_plugin_status_data plugin_status_data;
57 struct iaxxx_plugin_endpoint_status_data plugin_ep_status_data;
58
59 if (argc <= 1) {
60 usage();
61 }
62
63 while(1) {
64 ch = getopt_long (argc, argv, "sei:n:d:rb:",
65 long_options, &option_index);
66
67 /* Detect the end of the options. */
68 if (ch == -1)
69 break;
70
71 switch (ch) {
72
73 case 's':
74 test_option = 1;
75 break;
76
77 case 'e':
78 test_option = 2;
79 break;
80
81 case 'r':
82 test_option = 3;
83 break;
84
85 case 'i':
86 plugin_instance_id = atoi(optarg);
87 break;
88
89 case 'n':
90 enpoint_index = atoi(optarg);
91 break;
92
93 case 'd':
94 enpoint_dir = atoi(optarg);
95 break;
96
97 case 'b':
98 block_id = atoi(optarg);
99 break;
100
101 case 'h':
102 default:
103 usage();
104 }
105 }
106
107 if(test_option == -1) {
108 fprintf(stderr,"\n No Test Option Parameter! \n");
109 usage();
110 }
111
112 if((odsp_hw = iaxxx_odsp_init()) == NULL) {
113 fprintf(stderr,"\n ODSP Init Failed! \n");
114 return 0;
115 }
116
117 if(test_option == 1) {
118 if(plugin_instance_id == -1) {
119 fprintf(stderr,"\n No Plugin_instance_id Parameter! \n");
120 usage();
121 }
122
123 if((odsp_hw = iaxxx_odsp_init()) == NULL) {
124 fprintf(stderr,"\n ODSP Init Failed! \n");
125 return 0;
126 }
127 err = iaxxx_odsp_plugin_get_status_info(odsp_hw,
128 plugin_instance_id, &plugin_status_data);
129
130 iaxxx_odsp_deinit(odsp_hw);
131 if(!err)
132 fprintf(stdout, "\n Plugin status:: "
133 "\n block_id:%u create_status:%u enable_status:%u"
134 "\n process_count:%u process_err_count:%u private_memsize:%u"
135 "\n in_frames_consumed:%u out_frames_produced:%u "
136 "\n frame_notification_mode:%u state_management_mode:%u ",
137 plugin_status_data.block_id,
138 plugin_status_data.create_status,
139 plugin_status_data.enable_status,
140 plugin_status_data.process_count,
141 plugin_status_data.process_err_count,
142 plugin_status_data.private_memsize,
143 plugin_status_data.in_frames_consumed,
144 plugin_status_data.out_frames_produced,
145 plugin_status_data.frame_notification_mode,
146 plugin_status_data.state_management_mode);
147
148 }
149 else
150 if(test_option == 2) {
151 if(plugin_instance_id == -1) {
152 fprintf(stderr,"\n No Plugin_instance_id Parameter! \n");
153 usage();
154 }
155
156 if(enpoint_index == -1) {
157 fprintf(stderr,"\n No Endpoint Index Parameter! \n");
158 usage();
159 }
160 if(enpoint_dir == -1) {
161 fprintf(stderr,"\n No Endpoint Direction Parameter! \n");
162 usage();
163 }
164
165 if((odsp_hw = iaxxx_odsp_init()) == NULL) {
166 fprintf(stderr,"\n ODSP Init Failed! \n");
167 return 0;
168 }
169 err = iaxxx_odsp_plugin_get_endpoint_status(odsp_hw,
170 plugin_instance_id, enpoint_index,
171 enpoint_dir, &plugin_ep_status_data);
172 iaxxx_odsp_deinit(odsp_hw);
173
174 if(!err) {
175 fprintf(stdout, "\nstatus:%u frame_status:%d endpoint_status:%d",
176 plugin_ep_status_data.status,
177 plugin_ep_status_data.frame_status,
178 plugin_ep_status_data.endpoint_status);
179
180 fprintf(stdout, "\nusage:%d mandatory:%d counter:%u",
181 plugin_ep_status_data.usage,
182 plugin_ep_status_data.mandatory,
183 plugin_ep_status_data.counter);
184
185 if(enpoint_dir)
186 fprintf(stdout,
187 "\nop_encoding:%d op_sample_rate:%d op_frame_length:%u",
188 plugin_ep_status_data.op_encoding,
189 plugin_ep_status_data.op_sample_rate,
190 plugin_ep_status_data.op_frame_length);
191 }
192 }
193 else {
194 if(block_id == -1) {
195 fprintf(stderr,"\n No block_id Parameter! \n");
196 usage();
197 }
198 if((odsp_hw = iaxxx_odsp_init()) == NULL) {
199 fprintf(stderr,"\n ODSP Init Failed! \n");
200 return 0;
201 }
202
203 err = iaxxx_odsp_plugin_read_error(odsp_hw,
204 block_id, &error_code, &error_instance);
205
206 iaxxx_odsp_deinit(odsp_hw);
207
208 if(!err) {
209 fprintf(stdout, "\nerror_code:%u", error_code);
210 if(error_code)
211 fprintf(stdout, "\ninstance_error_occured:%d",
212 error_instance);
213 }
214 }
215
216 if(err)
217 fprintf(stdout, "\n\n## plugin_status_test failed!! ##\n\n");
218 else
219 fprintf(stdout, "\n\n## plugin_status_test done. ##\n\n");
220
221 return 0;
222 }
223
224