From 54ddd869afe9caa1511bc75a74254d013eeae984 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Fri, 25 Apr 2025 16:57:49 +0200 Subject: [PATCH] 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. --- src/deltacast_common.cpp | 28 ++++++++++++++++++++++++++++ src/deltacast_common.hpp | 4 +++- src/video_capture/deltacast_dvi.cpp | 27 ++++++++------------------- 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/deltacast_common.cpp b/src/deltacast_common.cpp index 4a0563b1c..8bcdb467f 100644 --- a/src/deltacast_common.cpp +++ b/src/deltacast_common.cpp @@ -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; +} diff --git a/src/deltacast_common.hpp b/src/deltacast_common.hpp index 9166164f5..dda376f23 100644 --- a/src/deltacast_common.hpp +++ b/src/deltacast_common.hpp @@ -38,6 +38,8 @@ #ifndef DELTACAST_COMMON_HPP #define DELTACAST_COMMON_HPP +#define MAX_DELTA_CH 7 ///< maximal supported channel index + #include #include #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 diff --git a/src/video_capture/deltacast_dvi.cpp b/src/video_capture/deltacast_dvi.cpp index 9fa8a3b73..87f193ae5 100644 --- a/src/video_capture/deltacast_dvi.cpp +++ b/src/video_capture/deltacast_dvi.cpp @@ -131,8 +131,10 @@ static void usage(void) col() << SBOLD("\t") << " - index of DVI card\n"; print_available_delta_boards(false); - col() << SBOLD("\t") << " may be channel index (for cards which have multiple inputs, max 4)\n"; - + col() << SBOLD("\t") + << " may be channel index (for cards which have multiple inputs, 0-" + << MAX_DELTA_CH << ")\n"; + col() << SBOLD("\t") << " 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,