vcap/deltacast_dvi: move ch to stream t to fn

moved to common function to be used otherwise

Also increase the maximal index from 3 to 7.
This commit is contained in:
Martin Pulec
2025-04-25 16:57:49 +02:00
parent 59aefbc78d
commit 54ddd869af
3 changed files with 39 additions and 20 deletions

View File

@@ -391,3 +391,31 @@ delta_set_nb_channels(ULONG BrdId, HANDLE BoardHandle, ULONG RequestedRx,
Result);
return false;
}
/// @returns stream type corresponding channel ID or NB_VHD_STREAMTYPES if too
/// high
VHD_STREAMTYPE
delta_rx_ch_to_stream_t(unsigned channel)
{
switch (channel) {
case 0:
return VHD_ST_RX0;
case 1:
return VHD_ST_RX1;
case 2:
return VHD_ST_RX2;
case 3:
return VHD_ST_RX3;
case 4:
return VHD_ST_RX4;
case 5:
return VHD_ST_RX5;
case 6:
return VHD_ST_RX6;
case 7:
return VHD_ST_RX7;
}
log_msg(LOG_LEVEL_ERROR, "[DELTACAST] Channel index %u out of bound!\n",
channel);
return NB_VHD_STREAMTYPES;
}

View File

@@ -38,6 +38,8 @@
#ifndef DELTACAST_COMMON_HPP
#define DELTACAST_COMMON_HPP
#define MAX_DELTA_CH 7 ///< maximal supported channel index
#include <string>
#include <unordered_map>
#ifdef __APPLE__
@@ -201,6 +203,6 @@ const char *delta_get_error_description(ULONG CodeError);
std::string delta_format_version(uint32_t version, bool long_out);
void print_available_delta_boards(bool full);
bool delta_set_nb_channels(ULONG BrdId, HANDLE BoardHandle, ULONG RequestedRx, ULONG RequestedTx);
VHD_STREAMTYPE delta_rx_ch_to_stream_t(unsigned channel);
#endif // defined DELTACAST_COMMON_HPP

View File

@@ -131,8 +131,10 @@ static void usage(void)
col() << SBOLD("\t<index>") << " - index of DVI card\n";
print_available_delta_boards(false);
col() << SBOLD("\t<channel>") << " may be channel index (for cards which have multiple inputs, max 4)\n";
col() << SBOLD("\t<channel>")
<< " may be channel index (for cards which have multiple inputs, 0-"
<< MAX_DELTA_CH << ")\n";
col() << SBOLD("\t<preset>") << " may be one of following\n";
for (const auto &it : edid_presets) {
col() << SBOLD("\t\t " << setw(2) << it.first) << " - " << it.second << "\n";
@@ -577,23 +579,10 @@ vidcap_deltacast_dvi_init(struct vidcap_params *params, void **state)
log_msg(LOG_LEVEL_ERROR, "[DELTACAST] ERROR : The selected board is not an DVI or HDMI one\n");
goto bad_channel;
}
switch(channel) {
case 0:
ChannelId = VHD_ST_RX0;
break;
case 1:
ChannelId = VHD_ST_RX1;
break;
case 2:
ChannelId = VHD_ST_RX2;
break;
case 3:
ChannelId = VHD_ST_RX3;
break;
default:
log_msg(LOG_LEVEL_ERROR, "[DELTACAST] Bad channel index!\n");
goto no_stream;
ChannelId = delta_rx_ch_to_stream_t(channel);
if (ChannelId == NB_VHD_STREAMTYPES) {
goto no_stream;
}
Result = VHD_OpenStreamHandle(s->BoardHandle, ChannelId,
s->BoardType == VHD_BOARDTYPE_HDMI ? VHD_DV_STPROC_JOINED : VHD_DV_STPROC_DEFAULT,