|
@@ -42,6 +42,11 @@ static const struct option long_options[] = {
|
42
|
42
|
{ "version", no_argument, NULL, 'V' },
|
43
|
43
|
{ "info", no_argument, NULL, 'i' },
|
44
|
44
|
{ "monitor", no_argument, NULL, 'm' },
|
|
45
|
+ { "vi-name", required_argument, NULL, 1001 },
|
|
46
|
+ { "vo-name", required_argument, NULL, 1002 },
|
|
47
|
+ { "vo-route", required_argument, NULL, 1011 },
|
|
48
|
+ { "vo-lock", required_argument, NULL, 1021 },
|
|
49
|
+ { "vo-unlock", required_argument, NULL, 1022 },
|
45
|
50
|
{ 0, 0, 0, 0 }
|
46
|
51
|
};
|
47
|
52
|
|
|
@@ -63,10 +68,27 @@ static void show_help(struct videohub_data *data) {
|
63
|
68
|
printf(" -i --info | Show device info (default command).\n");
|
64
|
69
|
printf(" -m --monitor | Show real time monitor for config changes.\n");
|
65
|
70
|
printf("\n");
|
|
71
|
+ printf("Configuration:\n");
|
|
72
|
+ printf(" --vi-name <in_X> <name> | Set input <name> to input port X.\n");
|
|
73
|
+ printf(" --vo-name <out_X> <name> | Set output <name> to output port X.\n");
|
|
74
|
+ printf("\n");
|
|
75
|
+ printf(" --vo-route <out_X> <in_Y> | Connect output port X to input port Y.\n");
|
|
76
|
+ printf("\n");
|
|
77
|
+ printf(" --vo-lock <out_X> | Lock output port X.\n");
|
|
78
|
+ printf(" --vo-unlock <out_X> | Unlock output port X.\n");
|
|
79
|
+ printf("\n");
|
|
80
|
+ printf(" NOTE: For <in_X/out_X/in_Y> you may use port number or port name.\n");
|
|
81
|
+ printf("\n");
|
66
|
82
|
}
|
67
|
83
|
|
|
84
|
+static int num_parsed_cmds = 0;
|
|
85
|
+static struct run_cmds {
|
|
86
|
+ struct vcmd_entry entry[MAX_RUN_CMDS];
|
|
87
|
+} parsed_cmds;
|
|
88
|
+
|
68
|
89
|
static void parse_options(struct videohub_data *data, int argc, char **argv) {
|
69
|
90
|
int j, err = 0;
|
|
91
|
+ struct vcmd_entry *c = &parsed_cmds.entry[0];
|
70
|
92
|
// Set defaults
|
71
|
93
|
data->dev_port = "9990";
|
72
|
94
|
while ((j = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
|
@@ -93,6 +115,36 @@ static void parse_options(struct videohub_data *data, int argc, char **argv) {
|
93
|
115
|
case 'm': // --monitor
|
94
|
116
|
show_monitor = 1;
|
95
|
117
|
break;
|
|
118
|
+ case 1001: // --vi-name
|
|
119
|
+ case 1002: // --vo-name
|
|
120
|
+ case 1011: // --vi-route
|
|
121
|
+ case 1012: // --vo-route
|
|
122
|
+ if (num_parsed_cmds == ARRAY_SIZE(parsed_cmds.entry))
|
|
123
|
+ die("No more than %u commands are supported.", num_parsed_cmds);
|
|
124
|
+ if (optind == argc || argv[optind - 1][0] == '-' || argv[optind][0] == '-') {
|
|
125
|
+ fprintf(stderr, "%s: option '%s' requires two arguments\n", argv[0], argv[optind - 2]);
|
|
126
|
+ exit(EXIT_FAILURE);
|
|
127
|
+ }
|
|
128
|
+ switch (j) {
|
|
129
|
+ case 1001: c->cmd = CMD_INPUT_LABELS; break; // --vi-name
|
|
130
|
+ case 1002: c->cmd = CMD_OUTPUT_LABELS; break; // --vo-name
|
|
131
|
+ case 1011: c->cmd = CMD_VIDEO_OUTPUT_ROUTING; break; // --vo-route
|
|
132
|
+ }
|
|
133
|
+ c->param1 = argv[optind - 1];
|
|
134
|
+ c->param2 = argv[optind];
|
|
135
|
+ c->param1 = argv[optind - 1];
|
|
136
|
+ c->param2 = argv[optind];
|
|
137
|
+ c = &parsed_cmds.entry[++num_parsed_cmds];
|
|
138
|
+ break;
|
|
139
|
+ case 1021: // --vo-lock
|
|
140
|
+ case 1022: // --vo-unlock
|
|
141
|
+ if (num_parsed_cmds == ARRAY_SIZE(parsed_cmds.entry))
|
|
142
|
+ die("No more than %u commands are supported.", num_parsed_cmds);
|
|
143
|
+ c->cmd = CMD_VIDEO_OUTPUT_LOCKS;
|
|
144
|
+ c->param1 = argv[optind - 1];
|
|
145
|
+ c->do_lock = (j == 1021);
|
|
146
|
+ c = &parsed_cmds.entry[++num_parsed_cmds];
|
|
147
|
+ break;
|
96
|
148
|
case 'H': // --help
|
97
|
149
|
show_help(data);
|
98
|
150
|
exit(EXIT_SUCCESS);
|
|
@@ -199,7 +251,31 @@ int main(int argc, char **argv) {
|
199
|
251
|
die("The device supports %d outputs. Recompile the program with more MAX_OUTPUTS (currently %d)\n",
|
200
|
252
|
data->device.num_video_outputs, MAX_OUTPUTS);
|
201
|
253
|
|
202
|
|
- if (show_monitor) {
|
|
254
|
+ if (num_parsed_cmds) {
|
|
255
|
+ unsigned int i;
|
|
256
|
+ for (i = 0; i < ARRAY_SIZE(parsed_cmds.entry); i++) {
|
|
257
|
+ struct vcmd_entry *ve = &parsed_cmds.entry[i];
|
|
258
|
+ if (!ve->param1)
|
|
259
|
+ continue;
|
|
260
|
+ prepare_cmd_entry(data, &parsed_cmds.entry[i]);
|
|
261
|
+ }
|
|
262
|
+
|
|
263
|
+ //print_device_settings(data);
|
|
264
|
+ for (i = 0; i < ARRAY_SIZE(parsed_cmds.entry); i++) {
|
|
265
|
+ char cmd_buffer[1024];
|
|
266
|
+ struct vcmd_entry *ve = &parsed_cmds.entry[i];
|
|
267
|
+ if (!ve->param1)
|
|
268
|
+ continue;
|
|
269
|
+ format_cmd_text(ve, cmd_buffer, sizeof(cmd_buffer));
|
|
270
|
+ if (strlen(cmd_buffer)) {
|
|
271
|
+ printf("%s", cmd_buffer);
|
|
272
|
+ fdwrite(data->dev_fd, cmd_buffer, strlen(cmd_buffer));
|
|
273
|
+ }
|
|
274
|
+ }
|
|
275
|
+ //usleep(100000);
|
|
276
|
+ //read_device_command_stream(data);
|
|
277
|
+ //print_device_settings(data);
|
|
278
|
+ } else if (show_monitor) {
|
203
|
279
|
while (1) {
|
204
|
280
|
printf("\e[2J\e[H"); // Clear screen
|
205
|
281
|
printf("%s\n", program_id);
|