Skip to content

Commit d5a42c5

Browse files
committed
vcap,vdisp/deltacast: add ch_layout option
For cards with bidirectional channels, it allow setting RX/TX layout (actually the ratio of RX/TX channel count, not arbitrary selection).
1 parent b80face commit d5a42c5

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

src/deltacast_common.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,23 @@ print_available_delta_boards(bool full)
299299
std::cout << "\n";
300300
}
301301

302+
void
303+
delta_print_ch_layout_help(bool full)
304+
{
305+
color_printf(
306+
"\t" TBOLD("ch_layout") " - configure bidirectional channels%s\n",
307+
full ? ":" : ", see \":fullhelp\" for details");
308+
if (full) {
309+
color_printf("\t\tSet the layout with a number in format RxTx, "
310+
"examples:\n"
311+
"\t\t\t- 80 - 8 Rx and 0 TX\n"
312+
"\t\t\t- 44 - 4 Rx and 4 TX\n"
313+
"\t\t\t- 13 - 1 Rx and 3 TX (4 channel device)\n"
314+
"\t\tIt is user responsibility to enter the valid "
315+
"number (not exceeding device channels).\n");
316+
}
317+
}
318+
302319
/// from SDK SetNbChannels()
303320
bool
304321
delta_set_nb_channels(ULONG BrdId, HANDLE BoardHandle, ULONG RequestedRx,
@@ -399,6 +416,8 @@ delta_set_nb_channels(ULONG BrdId, HANDLE BoardHandle, ULONG RequestedRx,
399416
"ERROR: Cannot set bidirectional channels. Result = "
400417
"0x%08" PRIX_ULONG "\n",
401418
Result);
419+
MSG(WARNING, "See also option \":ch_layout\" to switch "
420+
"bidirectional channels layout.\n");
402421
return false;
403422
}
404423

src/deltacast_common.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ static std::unordered_map<ULONG, std::string> board_type_map = {
206206
*/
207207
const char *delta_get_error_description(ULONG CodeError);
208208
std::string delta_format_version(uint32_t version, bool long_out);
209+
209210
void print_available_delta_boards(bool full);
211+
void delta_print_ch_layout_help(bool full);
212+
210213
bool delta_set_nb_channels(ULONG BrdId, HANDLE BoardHandle, ULONG RequestedRx, ULONG RequestedTx);
211214

212215
VHD_STREAMTYPE delta_rx_ch_to_stream_t(unsigned channel);

src/video_capture/deltacast.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,15 @@ usage(bool full)
9595
{
9696
color_printf("Usage:\n");
9797
color_printf("\t" TBOLD(TRED("-t "
98-
"deltacast") "[:device=<index>][:channel=<idx>][:mode=<mode>]["
98+
"deltacast") "[:device=<index>][:channel=<idx>][:ch_layout=RL][:mode=<mode>]["
9999
":codec=<codec>]") "\n");
100100
color_printf("\t" TBOLD("-t "
101101
"deltacast:[full]help") "\n");
102102

103103
printf("\nOptions:\n");
104104
color_printf("\t" TBOLD("device") " - board index\n");
105105
color_printf("\t" TBOLD("channel") " - card channel index (default 0)\n");
106+
delta_print_ch_layout_help(full);
106107
color_printf("\t" TBOLD("mode") " - capture mode (see below)\n");
107108
color_printf("\t" TBOLD("codec") " - pixel format to capture (see list below)\n");
108109

@@ -350,8 +351,8 @@ static bool wait_for_channel(struct vidcap_deltacast_state *s)
350351
return true;
351352
}
352353

353-
static bool
354-
parse_fmt(struct vidcap_deltacast_state *s, char *init_fmt, ULONG *BrdId)
354+
static bool parse_fmt(struct vidcap_deltacast_state *s, char *init_fmt,
355+
ULONG *BrdId, ULONG *NbRxRequired, ULONG *NbTxRequired)
355356
{
356357
char *save_ptr = NULL;
357358
char *tok = NULL;
@@ -385,6 +386,10 @@ parse_fmt(struct vidcap_deltacast_state *s, char *init_fmt, ULONG *BrdId)
385386
s->channel);
386387
return false;
387388
}
389+
} else if (IS_KEY_PREFIX(tok, "ch_layout")) {
390+
int val = stoi(strchr(tok, '=') + 1);
391+
*NbRxRequired = val / 10;
392+
*NbTxRequired = val % 10;
388393
} else {
389394
MSG(ERROR, "Wrong config option '%s'!\n", tok);
390395
usage(false);
@@ -402,6 +407,8 @@ vidcap_deltacast_init(struct vidcap_params *params, void **state)
402407
struct vidcap_deltacast_state *s = nullptr;
403408
ULONG Result,DllVersion,NbBoards,ChnType;
404409
ULONG BrdId = 0;
410+
ULONG NbRxRequired = 0;
411+
ULONG NbTxRequired = 0;
405412

406413
printf("vidcap_deltacast_init\n");
407414

@@ -431,7 +438,7 @@ vidcap_deltacast_init(struct vidcap_params *params, void **state)
431438
s->BoardHandle = s->StreamHandle = s->SlotHandle = NULL;
432439

433440
char *init_fmt = strdup(fmt);
434-
if (!parse_fmt(s, init_fmt, &BrdId)) {
441+
if (!parse_fmt(s, init_fmt, &BrdId, &NbRxRequired, &NbTxRequired)) {
435442
free(init_fmt);
436443
HANDLE_ERROR
437444
}
@@ -474,9 +481,12 @@ vidcap_deltacast_init(struct vidcap_params *params, void **state)
474481
HANDLE_ERROR
475482
}
476483

477-
assert(!s->quad_channel || s->channel == 0);
478-
ULONG NbRxRequired = s->quad_channel ? 4 : s->channel + 1;
479-
if (!delta_set_nb_channels(BrdId, s->BoardHandle, NbRxRequired, 0)) {
484+
if (NbRxRequired == 0 && NbTxRequired == 0) {
485+
assert(!s->quad_channel || s->channel == 0);
486+
NbRxRequired = s->quad_channel ? 4 : s->channel + 1;
487+
}
488+
if (!delta_set_nb_channels(BrdId, s->BoardHandle, NbRxRequired,
489+
NbTxRequired)) {
480490
HANDLE_ERROR
481491
}
482492

src/video_display/deltacast.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ show_help(bool full)
9898
{
9999
printf("deltacast (output) options:\n");
100100
color_printf("\t" TBOLD(
101-
TRED("-d deltacast") "[:device=<index>][:channel=<ch>]") "\n");
101+
TRED("-d deltacast") "[:device=<index>][:channel=<ch>]"
102+
"[:ch_layout=RT]") "\n");
102103
color_printf("\t" TBOLD("-d deltacast:[full]help") "\n");
103104

104105
printf("\nOptions:\n");
105106
color_printf("\t" TBOLD("device") " - board index\n");
106107
color_printf("\t" TBOLD("channel") " - card channel index (default 0)\n");
108+
delta_print_ch_layout_help(full);
107109

108110
print_available_delta_boards(full);
109111

@@ -331,7 +333,8 @@ static void display_deltacast_probe(struct device_info **available_cards, int *c
331333
}
332334

333335
static bool
334-
parse_fmt(struct state_deltacast *s, char *fmt, ULONG *BrdId)
336+
parse_fmt(struct state_deltacast *s, char *fmt, ULONG *BrdId,
337+
ULONG *NbRxRequired, ULONG *NbTxRequired)
335338
{
336339
char *save_ptr = nullptr;
337340
while (char *tok = strtok_r(fmt, ":", &save_ptr)) {
@@ -345,6 +348,10 @@ parse_fmt(struct state_deltacast *s, char *fmt, ULONG *BrdId)
345348
s->channel);
346349
return false;
347350
}
351+
} else if (IS_KEY_PREFIX(tok, "ch_layout")) {
352+
int val = std::stoi(strchr(tok, '=') + 1);
353+
*NbRxRequired = val / 10;
354+
*NbTxRequired = val % 10;
348355
} else {
349356
MSG(ERROR, "Unknown option: %s\n\n", tok);
350357
show_help(false);
@@ -361,6 +368,8 @@ static void *display_deltacast_init(struct module *parent, const char *fmt, unsi
361368
struct state_deltacast *s;
362369
ULONG Result,DllVersion,NbBoards,ChnType;
363370
ULONG BrdId = 0;
371+
ULONG NbRxRequired = 0;
372+
ULONG NbTxRequired = 0;
364373

365374
if (strcmp(fmt, "help") == 0 || strcmp(fmt, "fullhelp") == 0) {
366375
show_help(strcmp(fmt, "fullhelp") == 0);
@@ -388,7 +397,7 @@ static void *display_deltacast_init(struct module *parent, const char *fmt, unsi
388397
s->audio_configured = FALSE;
389398

390399
char *tmp = strdup(fmt);
391-
if (!parse_fmt(s, tmp, &BrdId)) {
400+
if (!parse_fmt(s, tmp, &BrdId, &NbRxRequired, &NbTxRequired)) {
392401
free(tmp);
393402
HANDLE_ERROR
394403
}
@@ -420,7 +429,11 @@ static void *display_deltacast_init(struct module *parent, const char *fmt, unsi
420429
HANDLE_ERROR
421430
}
422431

423-
if (!delta_set_nb_channels(BrdId, s->BoardHandle, 0, s->channel + 1)) {
432+
if (NbRxRequired == 0 && NbTxRequired == 0) {
433+
NbTxRequired = s->channel + 1;
434+
}
435+
if (!delta_set_nb_channels(BrdId, s->BoardHandle, NbRxRequired,
436+
NbTxRequired)) {
424437
HANDLE_ERROR
425438
}
426439

0 commit comments

Comments
 (0)