mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2025-06-18 08:35:33 -04:00
Old Optimize CC output
This commit is contained in:
parent
6f4b2b8798
commit
0240e53681
@ -11,13 +11,13 @@ set(NEW_DS_LOOPY_SUPPORT 1)
|
||||
set(IS_DEVICES_SUPPORT 1)
|
||||
set(OLD_DS_3DS_LOOPY_SUPPORT 1)
|
||||
set(CYPRESS_NISETRO_SUPPORT 1)
|
||||
set(OPTIMIZE_NEW3DS_SUPPORT 1)
|
||||
set(OPTIMIZE_3DS_SUPPORT 1)
|
||||
|
||||
set(USE_FTD2XX_FOR_NEW_DS_LOOPY ${NEW_DS_LOOPY_SUPPORT})
|
||||
set(USE_LIBUSB_FOR_NEW_DS_LOOPY ${NEW_DS_LOOPY_SUPPORT})
|
||||
set(USE_FTD3XX_FOR_N3DSXL_LOOPY ${N3DSXL_LOOPY_SUPPORT})
|
||||
set(USE_LIBUSB_FOR_N3DSXL_LOOPY ${N3DSXL_LOOPY_SUPPORT})
|
||||
set(USE_CYPRESS_USB_SUPPORT ${CYPRESS_NISETRO_SUPPORT} OR ${OPTIMIZE_NEW3DS_SUPPORT})
|
||||
set(USE_CYPRESS_USB_SUPPORT ${CYPRESS_NISETRO_SUPPORT} OR ${OPTIMIZE_3DS_SUPPORT})
|
||||
set(USE_LIBUSB_SUPPORT ${IS_DEVICES_SUPPORT} OR ${OLD_DS_3DS_LOOPY_SUPPORT} OR ${USE_LIBUSB_FOR_NEW_DS_LOOPY} OR ${USE_LIBUSB_FOR_N3DSXL_LOOPY} OR ${USE_CYPRESS_USB_SUPPORT})
|
||||
if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Windows"))
|
||||
#Performance outside of Windows is very bad for the official drivers...
|
||||
@ -307,7 +307,7 @@ set(SOURCE_CPP_FTD2_FILES_BASE_PATH "${SOURCE_CPP_DEVICE_FILES_BASE_PATH}/DSCapt
|
||||
set(SOURCE_CPP_FTD3_FILES_BASE_PATH "${SOURCE_CPP_DEVICE_FILES_BASE_PATH}/3DSCapture_FTD3")
|
||||
set(SOURCE_CPP_CYPRESS_USB_FILES_BASE_PATH "${SOURCE_CPP_DEVICE_FILES_BASE_PATH}/CypressShared")
|
||||
set(SOURCE_CPP_CYPRESS_NISETRO_DEVICES_FILES_BASE_PATH "${SOURCE_CPP_DEVICE_FILES_BASE_PATH}/Nisetro")
|
||||
set(SOURCE_CPP_CYPRESS_NEW_OPTIMIZE_3DS_FILES_BASE_PATH "${SOURCE_CPP_DEVICE_FILES_BASE_PATH}/Optimize_New_3DS")
|
||||
set(SOURCE_CPP_CYPRESS_OPTIMIZE_3DS_FILES_BASE_PATH "${SOURCE_CPP_DEVICE_FILES_BASE_PATH}/Optimize_3DS")
|
||||
if(N3DSXL_LOOPY_SUPPORT)
|
||||
list(APPEND SOURCE_CPP_EXTRA_FILES ${SOURCE_CPP_FTD3_FILES_BASE_PATH}/3dscapture_ftd3_shared.cpp ${SOURCE_CPP_FTD3_FILES_BASE_PATH}/3dscapture_ftd3_compatibility.cpp)
|
||||
if(MSVC)
|
||||
@ -370,12 +370,12 @@ if(CYPRESS_NISETRO_SUPPORT)
|
||||
list(APPEND EXTRA_CXX_FLAGS "-DUSE_CYNI_USB")
|
||||
endif()
|
||||
endif()
|
||||
if(OPTIMIZE_NEW3DS_SUPPORT)
|
||||
list(APPEND SOURCE_CPP_EXTRA_FILES ${SOURCE_CPP_CYPRESS_NEW_OPTIMIZE_3DS_FILES_BASE_PATH}/cypress_optimize_new_3ds_communications.cpp ${SOURCE_CPP_CYPRESS_NEW_OPTIMIZE_3DS_FILES_BASE_PATH}/cypress_optimize_new_3ds_acquisition.cpp ${TOOLS_DATA_DIR}/optimize_new_3ds_fw.cpp ${TOOLS_DATA_DIR}/optimize_new_3ds_565_fpga_pl.cpp ${TOOLS_DATA_DIR}/optimize_new_3ds_888_fpga_pl.cpp)
|
||||
if(OPTIMIZE_3DS_SUPPORT)
|
||||
list(APPEND SOURCE_CPP_EXTRA_FILES ${SOURCE_CPP_CYPRESS_OPTIMIZE_3DS_FILES_BASE_PATH}/cypress_optimize_3ds_communications.cpp ${SOURCE_CPP_CYPRESS_OPTIMIZE_3DS_FILES_BASE_PATH}/cypress_optimize_3ds_acquisition.cpp ${TOOLS_DATA_DIR}/optimize_new_3ds_fw.cpp ${TOOLS_DATA_DIR}/optimize_new_3ds_565_fpga_pl.cpp ${TOOLS_DATA_DIR}/optimize_new_3ds_888_fpga_pl.cpp ${TOOLS_DATA_DIR}/optimize_old_3ds_fw.cpp ${TOOLS_DATA_DIR}/optimize_old_3ds_565_fpga_pl.cpp ${TOOLS_DATA_DIR}/optimize_old_3ds_888_fpga_pl.cpp)
|
||||
if(MSVC)
|
||||
list(APPEND EXTRA_CXX_FLAGS "/DUSE_CYPRESS_NEW_OPTIMIZE")
|
||||
list(APPEND EXTRA_CXX_FLAGS "/DUSE_CYPRESS_OPTIMIZE")
|
||||
else()
|
||||
list(APPEND EXTRA_CXX_FLAGS "-DUSE_CYPRESS_NEW_OPTIMIZE")
|
||||
list(APPEND EXTRA_CXX_FLAGS "-DUSE_CYPRESS_OPTIMIZE")
|
||||
endif()
|
||||
endif()
|
||||
if(NEW_DS_LOOPY_SUPPORT)
|
||||
@ -537,7 +537,7 @@ endif()
|
||||
if(USE_FTD2XX_FOR_NEW_DS_LOOPY)
|
||||
target_link_libraries(${OUTPUT_NAME} PRIVATE ${ftd2xx_BINARY_DIR}/${FTD2XX_SUBFOLDER}/${FTD2XX_LIB})
|
||||
endif()
|
||||
target_include_directories(${OUTPUT_NAME} PRIVATE ${EXTRA_INCLUDE_DIRECTORIES} ${TOOLS_DATA_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/Menus ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/ISDevices ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/Nisetro ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/Optimize_New_3DS ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/CypressShared ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/3DSCapture_FTD3 ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/DSCapture_FTD2)
|
||||
target_include_directories(${OUTPUT_NAME} PRIVATE ${EXTRA_INCLUDE_DIRECTORIES} ${TOOLS_DATA_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/Menus ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/ISDevices ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/Nisetro ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/Optimize_3DS ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/CypressShared ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/3DSCapture_FTD3 ${CMAKE_SOURCE_DIR}/include/CaptureDeviceSpecific/DSCapture_FTD2)
|
||||
target_compile_features(${OUTPUT_NAME} PRIVATE cxx_std_20)
|
||||
target_compile_options(${OUTPUT_NAME} PRIVATE ${EXTRA_CXX_FLAGS})
|
||||
|
||||
@ -604,6 +604,27 @@ add_custom_command(
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/bin/optimize_new_3ds_888_fpga_pl.bin ${TOOLS_DATA_DIR}/CMakeBin2C${HOST_FINAL_EXTENSION}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${TOOLS_DATA_DIR}/optimize_old_3ds_fw.cpp
|
||||
COMMENT "Convert fw binary to C - Optimize Old 3DS"
|
||||
COMMAND ${TOOLS_DATA_DIR}/CMakeBin2C${HOST_FINAL_EXTENSION} ${CMAKE_SOURCE_DIR}/bin/optimize_old_3ds_fw.bin ${TOOLS_DATA_DIR} optimize_old_3ds_fw optimize_old_3ds_fw
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/bin/optimize_old_3ds_fw.bin ${TOOLS_DATA_DIR}/CMakeBin2C${HOST_FINAL_EXTENSION}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${TOOLS_DATA_DIR}/optimize_old_3ds_565_fpga_pl.cpp
|
||||
COMMENT "Convert FPGA 565 PL binary to C - Optimize Old 3DS"
|
||||
COMMAND ${TOOLS_DATA_DIR}/CMakeBin2C${HOST_FINAL_EXTENSION} ${CMAKE_SOURCE_DIR}/bin/optimize_old_3ds_565_fpga_pl.bin ${TOOLS_DATA_DIR} optimize_old_3ds_565_fpga_pl optimize_old_3ds_565_fpga_pl
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/bin/optimize_old_3ds_565_fpga_pl.bin ${TOOLS_DATA_DIR}/CMakeBin2C${HOST_FINAL_EXTENSION}
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${TOOLS_DATA_DIR}/optimize_old_3ds_888_fpga_pl.cpp
|
||||
COMMENT "Convert FPGA 888 PL binary to C - Optimize Old 3DS"
|
||||
COMMAND ${TOOLS_DATA_DIR}/CMakeBin2C${HOST_FINAL_EXTENSION} ${CMAKE_SOURCE_DIR}/bin/optimize_old_3ds_888_fpga_pl.bin ${TOOLS_DATA_DIR} optimize_old_3ds_888_fpga_pl optimize_old_3ds_888_fpga_pl
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/bin/optimize_old_3ds_888_fpga_pl.bin ${TOOLS_DATA_DIR}/CMakeBin2C${HOST_FINAL_EXTENSION}
|
||||
)
|
||||
|
||||
set(SHADERS_LIST "")
|
||||
list(APPEND SHADERS_LIST ${CMAKE_SOURCE_DIR}/shaders/bit_crusher_fragment_shader.2_to_x_1_7.frag ${CMAKE_SOURCE_DIR}/shaders/bit_merger_crusher_fragment_shader.2_to_x_1_6.frag ${CMAKE_SOURCE_DIR}/shaders/bit_merger_crusher_fragment_shader_7.frag ${CMAKE_SOURCE_DIR}/shaders/bit_merger_fragment_shader.2_to_x_0_6.frag ${CMAKE_SOURCE_DIR}/shaders/bit_merger_fragment_shader_7.frag ${CMAKE_SOURCE_DIR}/shaders/frame_blending_bit_crusher_fragment_shader.2_to_x_1_7.frag ${CMAKE_SOURCE_DIR}/shaders/frame_blending_fragment_shader.frag ${CMAKE_SOURCE_DIR}/shaders/no_effect_fragment_shader.frag ${CMAKE_SOURCE_DIR}/shaders/color_emulation_fragment_shader.frag)
|
||||
|
||||
|
BIN
bin/optimize_old_3ds_565_fpga_pl.bin
Normal file
BIN
bin/optimize_old_3ds_565_fpga_pl.bin
Normal file
Binary file not shown.
BIN
bin/optimize_old_3ds_888_fpga_pl.bin
Normal file
BIN
bin/optimize_old_3ds_888_fpga_pl.bin
Normal file
Binary file not shown.
BIN
bin/optimize_old_3ds_fw.bin
Normal file
BIN
bin/optimize_old_3ds_fw.bin
Normal file
Binary file not shown.
@ -6,7 +6,7 @@
|
||||
#include "utils.hpp"
|
||||
#include "cypress_shared_communications.hpp"
|
||||
|
||||
enum CypressWindowsDriversEnum { CYPRESS_WINDOWS_DEFAULT_USB_DRIVER, CYPRESS_WINDOWS_OPTIMIZE_NEW_USB_DRIVER };
|
||||
enum CypressWindowsDriversEnum { CYPRESS_WINDOWS_DEFAULT_USB_DRIVER, CYPRESS_WINDOWS_OPTIMIZE_USB_DRIVER };
|
||||
|
||||
void cypress_driver_list_devices(std::vector<CaptureDevice>& devices_list, bool* not_supported_elems, int* curr_serial_extra_id_cypress, std::vector<const cy_device_usb_device*> &device_descriptions, CypressWindowsDriversEnum driver);
|
||||
void cypress_driver_find_used_serial(const cy_device_usb_device* usb_device_desc, bool* found, size_t num_free_fw_ids, int &curr_serial_extra_id, CypressWindowsDriversEnum driver);
|
||||
|
@ -0,0 +1,20 @@
|
||||
#ifndef __CYPRESS_OPTIMIZE_3DS_ACQUISITION_HPP
|
||||
#define __CYPRESS_OPTIMIZE_3DS_ACQUISITION_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "utils.hpp"
|
||||
#include "hw_defs.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
#include "display_structs.hpp"
|
||||
#include "devicecapture.hpp"
|
||||
|
||||
void list_devices_cyop_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list);
|
||||
bool cyop_device_connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
|
||||
uint64_t cyop_device_get_video_in_size(CaptureStatus* status, bool is_3d, InputVideoDataType video_data_type);
|
||||
uint64_t cyop_device_get_video_in_size(CaptureData* capture_data, bool is_3d, InputVideoDataType video_data_type);
|
||||
void cyop_device_acquisition_main_loop(CaptureData* capture_data);
|
||||
void usb_cyop_device_acquisition_cleanup(CaptureData* capture_data);
|
||||
void usb_cyop_device_init();
|
||||
void usb_cyop_device_close();
|
||||
|
||||
#endif
|
@ -0,0 +1,10 @@
|
||||
#ifndef __CYPRESS_OPTIMIZE_3DS_ACQUISITION_GENERAL_HPP
|
||||
#define __CYPRESS_OPTIMIZE_3DS_ACQUISITION_GENERAL_HPP
|
||||
|
||||
#include "cypress_shared_communications.hpp"
|
||||
#include "cypress_optimize_3ds_communications.hpp"
|
||||
|
||||
std::string cypress_optimize_3ds_get_serial(const void* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id);
|
||||
CaptureDevice cypress_optimize_3ds_create_device(const void* usb_device_desc, std::string serial, std::string path);
|
||||
|
||||
#endif
|
@ -0,0 +1,48 @@
|
||||
#ifndef __CYPRESS_OPTIMIZE_3DS_DEVICE_COMMUNICATIONS_HPP
|
||||
#define __CYPRESS_OPTIMIZE_3DS_DEVICE_COMMUNICATIONS_HPP
|
||||
|
||||
#include <libusb.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include "utils.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
#include "cypress_shared_communications.hpp"
|
||||
|
||||
enum cypress_optimize_device_type {
|
||||
CYPRESS_OPTIMIZE_NEW_3DS_BLANK_DEVICE,
|
||||
CYPRESS_OPTIMIZE_NEW_3DS_INSTANTIATED_DEVICE,
|
||||
CYPRESS_OPTIMIZE_OLD_3DS_BLANK_DEVICE,
|
||||
CYPRESS_OPTIMIZE_OLD_3DS_INSTANTIATED_DEVICE,
|
||||
};
|
||||
|
||||
struct cyop_device_usb_device {
|
||||
std::string name;
|
||||
std::string long_name;
|
||||
cypress_optimize_device_type device_type;
|
||||
uint8_t* firmware_to_load;
|
||||
size_t firmware_size;
|
||||
uint8_t* fpga_pl_565;
|
||||
size_t fpga_pl_565_size;
|
||||
uint8_t* fpga_pl_888;
|
||||
size_t fpga_pl_888_size;
|
||||
bool is_new_device;
|
||||
cypress_optimize_device_type next_device;
|
||||
bool has_bcd_device_serial;
|
||||
cy_device_usb_device usb_device_info;
|
||||
};
|
||||
|
||||
|
||||
int GetNumCyOpDeviceDesc(void);
|
||||
const cyop_device_usb_device* GetCyOpDeviceDesc(int index);
|
||||
const cyop_device_usb_device* GetNextDeviceDesc(const cyop_device_usb_device* device);
|
||||
const cy_device_usb_device* get_cy_usb_info(const cyop_device_usb_device* usb_device_desc);
|
||||
bool has_to_load_firmware(const cyop_device_usb_device* device);
|
||||
bool load_firmware(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, uint8_t patch_id);
|
||||
int capture_start(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_first_load, bool is_rgb888);
|
||||
int StartCaptureDma(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_rgb888);
|
||||
int capture_end(cy_device_device_handlers* handlers, const cyop_device_usb_device* device);
|
||||
int ReadFrame(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyop_device_usb_device* device_desc);
|
||||
int ReadFrameAsync(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyop_device_usb_device* device_desc, cy_async_callback_data* cb_data);
|
||||
|
||||
#endif
|
@ -1,20 +0,0 @@
|
||||
#ifndef __CYPRESS_OPTIMIZE_NEW_3DS_ACQUISITION_HPP
|
||||
#define __CYPRESS_OPTIMIZE_NEW_3DS_ACQUISITION_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "utils.hpp"
|
||||
#include "hw_defs.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
#include "display_structs.hpp"
|
||||
#include "devicecapture.hpp"
|
||||
|
||||
void list_devices_cyopn_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list);
|
||||
bool cyopn_device_connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
|
||||
uint64_t cyopn_device_get_video_in_size(CaptureStatus* status, bool is_3d, InputVideoDataType video_data_type);
|
||||
uint64_t cyopn_device_get_video_in_size(CaptureData* capture_data, bool is_3d, InputVideoDataType video_data_type);
|
||||
void cyopn_device_acquisition_main_loop(CaptureData* capture_data);
|
||||
void usb_cyopn_device_acquisition_cleanup(CaptureData* capture_data);
|
||||
void usb_cyopn_device_init();
|
||||
void usb_cyopn_device_close();
|
||||
|
||||
#endif
|
@ -1,10 +0,0 @@
|
||||
#ifndef __CYPRESS_OPTIMIZE_NEW_3DS_ACQUISITION_GENERAL_HPP
|
||||
#define __CYPRESS_OPTIMIZE_NEW_3DS_ACQUISITION_GENERAL_HPP
|
||||
|
||||
#include "cypress_shared_communications.hpp"
|
||||
#include "cypress_optimize_new_3ds_communications.hpp"
|
||||
|
||||
std::string cypress_optimize_new_3ds_get_serial(const void* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id);
|
||||
CaptureDevice cypress_optimize_new_3ds_create_device(const void* usb_device_desc, std::string serial, std::string path);
|
||||
|
||||
#endif
|
@ -1,49 +0,0 @@
|
||||
#ifndef __CYPRESS_OPTIMIZE_NEW_3DS_DEVICE_COMMUNICATIONS_HPP
|
||||
#define __CYPRESS_OPTIMIZE_NEW_3DS_DEVICE_COMMUNICATIONS_HPP
|
||||
|
||||
#include <libusb.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include "utils.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
#include "cypress_shared_communications.hpp"
|
||||
|
||||
enum cypress_optimize_new_device_type {
|
||||
CYPRESS_OPTIMIZE_NEW_3DS_BLANK_DEVICE,
|
||||
CYPRESS_OPTIMIZE_NEW_3DS_INSTANTIATED_DEVICE,
|
||||
};
|
||||
|
||||
struct cyopn_device_usb_device {
|
||||
std::string name;
|
||||
std::string long_name;
|
||||
cypress_optimize_new_device_type device_type;
|
||||
uint8_t* firmware_to_load;
|
||||
size_t firmware_size;
|
||||
uint8_t* fpga_pl_565;
|
||||
size_t fpga_pl_565_size;
|
||||
uint8_t* fpga_pl_565_3d;
|
||||
size_t fpga_pl_565_3d_size;
|
||||
uint8_t* fpga_pl_888;
|
||||
size_t fpga_pl_888_size;
|
||||
uint8_t* fpga_pl_888_3d;
|
||||
size_t fpga_pl_888_3d_size;
|
||||
cypress_optimize_new_device_type next_device;
|
||||
bool has_bcd_device_serial;
|
||||
cy_device_usb_device usb_device_info;
|
||||
};
|
||||
|
||||
|
||||
int GetNumCyOpNDeviceDesc(void);
|
||||
const cyopn_device_usb_device* GetCyOpNDeviceDesc(int index);
|
||||
const cyopn_device_usb_device* GetNextDeviceDesc(const cyopn_device_usb_device* device);
|
||||
const cy_device_usb_device* get_cy_usb_info(const cyopn_device_usb_device* usb_device_desc);
|
||||
bool has_to_load_firmware(const cyopn_device_usb_device* device);
|
||||
bool load_firmware(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, uint8_t patch_id);
|
||||
int capture_start(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, bool is_first_load, bool is_rgb888);
|
||||
int StartCaptureDma(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, bool is_rgb888);
|
||||
int capture_end(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device);
|
||||
int ReadFrame(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyopn_device_usb_device* device_desc);
|
||||
int ReadFrameAsync(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyopn_device_usb_device* device_desc, cy_async_callback_data* cb_data);
|
||||
|
||||
#endif
|
@ -20,9 +20,9 @@
|
||||
#define FTD2_INTRA_PACKET_HEADER_SIZE 2
|
||||
#define MAX_PACKET_SIZE_FTD2 (MAX_PACKET_SIZE_USB2 - FTD2_INTRA_PACKET_HEADER_SIZE)
|
||||
|
||||
#define OPTIMIZE_NEW_3DS_AUDIO_BUFFER_MAX_SIZE 0x200
|
||||
#define OPTIMIZE_3DS_AUDIO_BUFFER_MAX_SIZE 0x200
|
||||
|
||||
enum CaptureConnectionType { CAPTURE_CONN_FTD3, CAPTURE_CONN_USB, CAPTURE_CONN_FTD2, CAPTURE_CONN_IS_NITRO, CAPTURE_CONN_CYPRESS_NISETRO, CAPTURE_CONN_CYPRESS_NEW_OPTIMIZE };
|
||||
enum CaptureConnectionType { CAPTURE_CONN_FTD3, CAPTURE_CONN_USB, CAPTURE_CONN_FTD2, CAPTURE_CONN_IS_NITRO, CAPTURE_CONN_CYPRESS_NISETRO, CAPTURE_CONN_CYPRESS_OPTIMIZE };
|
||||
enum InputVideoDataType { VIDEO_DATA_RGB, VIDEO_DATA_BGR, VIDEO_DATA_RGB16, VIDEO_DATA_BGR16 };
|
||||
enum CaptureScreensType { CAPTURE_SCREENS_BOTH, CAPTURE_SCREENS_TOP, CAPTURE_SCREENS_BOTTOM, CAPTURE_SCREENS_ENUM_END };
|
||||
enum CaptureSpeedsType { CAPTURE_SPEEDS_FULL, CAPTURE_SPEEDS_HALF, CAPTURE_SPEEDS_THIRD, CAPTURE_SPEEDS_QUARTER, CAPTURE_SPEEDS_ENUM_END };
|
||||
@ -60,56 +60,56 @@ struct PACKED USBOldDSVideoInputData {
|
||||
USBOldDSPixelData screen_data[IN_VIDEO_SIZE_DS];
|
||||
};
|
||||
|
||||
#define OPTIMIZE_NEW_3DS_PIXEL_R_BITS 5
|
||||
#define OPTIMIZE_NEW_3DS_PIXEL_G_BITS 6
|
||||
#define OPTIMIZE_NEW_3DS_PIXEL_B_BITS 5
|
||||
#define OPTIMIZE_3DS_PIXEL_R_BITS 5
|
||||
#define OPTIMIZE_3DS_PIXEL_G_BITS 6
|
||||
#define OPTIMIZE_3DS_PIXEL_B_BITS 5
|
||||
|
||||
struct PACKED USB565New3DSOptimizePixelData {
|
||||
uint16_t r : OPTIMIZE_NEW_3DS_PIXEL_R_BITS;
|
||||
uint16_t g : OPTIMIZE_NEW_3DS_PIXEL_G_BITS;
|
||||
uint16_t b : OPTIMIZE_NEW_3DS_PIXEL_B_BITS;
|
||||
struct PACKED USB5653DSOptimizePixelData {
|
||||
uint16_t r : OPTIMIZE_3DS_PIXEL_R_BITS;
|
||||
uint16_t g : OPTIMIZE_3DS_PIXEL_G_BITS;
|
||||
uint16_t b : OPTIMIZE_3DS_PIXEL_B_BITS;
|
||||
};
|
||||
|
||||
struct PACKED USB888New3DSOptimizePixelData {
|
||||
struct PACKED USB8883DSOptimizePixelData {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
};
|
||||
|
||||
struct PACKED USBNew3DSOptimizeSingleSoundData {
|
||||
struct PACKED USB3DSOptimizeSingleSoundData {
|
||||
uint16_t sample_index;
|
||||
uint16_t sample_l;
|
||||
uint16_t sample_r;
|
||||
};
|
||||
|
||||
struct PACKED USBNew3DSOptimizeHeaderSoundData {
|
||||
struct PACKED USB3DSOptimizeHeaderSoundData {
|
||||
// Order is Little Endian
|
||||
uint16_t magic;
|
||||
uint16_t unk_fixed_1 : 1;
|
||||
uint16_t buffer_num : 1;
|
||||
uint16_t unk : 4;
|
||||
uint16_t column_index : 10;
|
||||
USBNew3DSOptimizeSingleSoundData samples[2];
|
||||
USB3DSOptimizeSingleSoundData samples[2];
|
||||
};
|
||||
|
||||
struct PACKED USB565New3DSOptimizeInputColumnData {
|
||||
USBNew3DSOptimizeHeaderSoundData header_sound;
|
||||
USB565New3DSOptimizePixelData pixel[HEIGHT_3DS][2];
|
||||
struct PACKED USB5653DSOptimizeInputColumnData {
|
||||
USB3DSOptimizeHeaderSoundData header_sound;
|
||||
USB5653DSOptimizePixelData pixel[HEIGHT_3DS][2];
|
||||
};
|
||||
|
||||
struct PACKED USB565New3DSOptimizeInputColumnData3D {
|
||||
USBNew3DSOptimizeHeaderSoundData header_sound;
|
||||
USB565New3DSOptimizePixelData pixel[HEIGHT_3DS][3];
|
||||
struct PACKED USB5653DSOptimizeInputColumnData3D {
|
||||
USB3DSOptimizeHeaderSoundData header_sound;
|
||||
USB5653DSOptimizePixelData pixel[HEIGHT_3DS][3];
|
||||
};
|
||||
|
||||
struct PACKED USB888New3DSOptimizeInputColumnData {
|
||||
USBNew3DSOptimizeHeaderSoundData header_sound;
|
||||
USB888New3DSOptimizePixelData pixel[HEIGHT_3DS][2];
|
||||
struct PACKED USB8883DSOptimizeInputColumnData {
|
||||
USB3DSOptimizeHeaderSoundData header_sound;
|
||||
USB8883DSOptimizePixelData pixel[HEIGHT_3DS][2];
|
||||
};
|
||||
|
||||
struct PACKED USB888New3DSOptimizeInputColumnData3D {
|
||||
USBNew3DSOptimizeHeaderSoundData header_sound;
|
||||
USB888New3DSOptimizePixelData pixel[HEIGHT_3DS][3];
|
||||
struct PACKED USB8883DSOptimizeInputColumnData3D {
|
||||
USB3DSOptimizeHeaderSoundData header_sound;
|
||||
USB8883DSOptimizePixelData pixel[HEIGHT_3DS][3];
|
||||
};
|
||||
|
||||
struct PACKED ISNitroEmulatorVideoInputData {
|
||||
@ -202,24 +202,24 @@ struct ALIGNED(16) PACKED ISTWLCaptureReceived {
|
||||
ISTWLCaptureAudioReceived audio_capture_in[TWL_CAPTURE_MAX_SAMPLES_CHUNK_NUM];
|
||||
};
|
||||
|
||||
struct ALIGNED(16) PACKED USB565New3DSOptimizeCaptureReceived {
|
||||
USB565New3DSOptimizeInputColumnData columns_data[TOP_WIDTH_3DS];
|
||||
USB565New3DSOptimizePixelData bottom_only_column[HEIGHT_3DS][2];
|
||||
struct ALIGNED(16) PACKED USB5653DSOptimizeCaptureReceived {
|
||||
USB5653DSOptimizeInputColumnData columns_data[TOP_WIDTH_3DS];
|
||||
USB5653DSOptimizePixelData bottom_only_column[HEIGHT_3DS][2];
|
||||
};
|
||||
|
||||
struct ALIGNED(16) PACKED USB565New3DSOptimizeCaptureReceived_3D {
|
||||
USB565New3DSOptimizeInputColumnData3D columns_data[TOP_WIDTH_3DS];
|
||||
USB565New3DSOptimizePixelData bottom_only_column[HEIGHT_3DS][3];
|
||||
struct ALIGNED(16) PACKED USB5653DSOptimizeCaptureReceived_3D {
|
||||
USB5653DSOptimizeInputColumnData3D columns_data[TOP_WIDTH_3DS];
|
||||
USB5653DSOptimizePixelData bottom_only_column[HEIGHT_3DS][3];
|
||||
};
|
||||
|
||||
struct ALIGNED(16) PACKED USB888New3DSOptimizeCaptureReceived {
|
||||
USB888New3DSOptimizeInputColumnData columns_data[TOP_WIDTH_3DS];
|
||||
USB888New3DSOptimizePixelData bottom_only_column[HEIGHT_3DS][2];
|
||||
struct ALIGNED(16) PACKED USB8883DSOptimizeCaptureReceived {
|
||||
USB8883DSOptimizeInputColumnData columns_data[TOP_WIDTH_3DS];
|
||||
USB8883DSOptimizePixelData bottom_only_column[HEIGHT_3DS][2];
|
||||
};
|
||||
|
||||
struct ALIGNED(16) PACKED USB888New3DSOptimizeCaptureReceived_3D {
|
||||
USB888New3DSOptimizeInputColumnData3D columns_data[TOP_WIDTH_3DS];
|
||||
USB888New3DSOptimizePixelData bottom_only_column[HEIGHT_3DS][3];
|
||||
struct ALIGNED(16) PACKED USB8883DSOptimizeCaptureReceived_3D {
|
||||
USB8883DSOptimizeInputColumnData3D columns_data[TOP_WIDTH_3DS];
|
||||
USB8883DSOptimizePixelData bottom_only_column[HEIGHT_3DS][3];
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
@ -240,10 +240,10 @@ union CaptureReceived {
|
||||
ISNitroCaptureReceived is_nitro_capture_received;
|
||||
ISTWLCaptureReceived is_twl_capture_received;
|
||||
CypressNisetroDSCaptureReceived cypress_nisetro_capture_received;
|
||||
USB565New3DSOptimizeCaptureReceived cypress_new_optimize_received_565;
|
||||
USB565New3DSOptimizeCaptureReceived_3D cypress_new_optimize_received_565_3d;
|
||||
USB888New3DSOptimizeCaptureReceived cypress_new_optimize_received_888;
|
||||
USB888New3DSOptimizeCaptureReceived_3D cypress_new_optimize_received_888_3d;
|
||||
USB5653DSOptimizeCaptureReceived cypress_optimize_received_565;
|
||||
USB5653DSOptimizeCaptureReceived_3D cypress_optimize_received_565_3d;
|
||||
USB8883DSOptimizeCaptureReceived cypress_optimize_received_888;
|
||||
USB8883DSOptimizeCaptureReceived_3D cypress_optimize_received_888_3d;
|
||||
};
|
||||
|
||||
struct CaptureDevice {
|
||||
|
@ -138,14 +138,14 @@ struct PACKED CYPRESS_SET_TRANSFER_SIZE_INFO {
|
||||
#pragma pack(pop)
|
||||
|
||||
static GUID cypress_driver_guid = {.Data1 = 0xae18aa60, .Data2 = 0x7f6a, .Data3 = 0x11d4, .Data4 = {0x97, 0xdd, 0x0, 0x1, 0x2, 0x29, 0xb9, 0x59}};
|
||||
static GUID cypress_optimize_new_driver_guid = {.Data1 = 0xae18aa60, .Data2 = 0x7f6a, .Data3 = 0x11d4, .Data4 = {0x97, 0xdd, 0x0, 0x1, 0x2, 0x29, 0xb9, 0x59}};
|
||||
static GUID cypress_optimize_driver_guid = {.Data1 = 0xae18aa60, .Data2 = 0x7f6a, .Data3 = 0x11d4, .Data4 = {0x97, 0xdd, 0x0, 0x1, 0x2, 0x29, 0xb9, 0x59}};
|
||||
|
||||
static GUID* get_driver_guid(CypressWindowsDriversEnum driver) {
|
||||
switch(driver) {
|
||||
case CYPRESS_WINDOWS_DEFAULT_USB_DRIVER:
|
||||
return &cypress_driver_guid;
|
||||
case CYPRESS_WINDOWS_OPTIMIZE_NEW_USB_DRIVER:
|
||||
return &cypress_optimize_new_driver_guid;
|
||||
case CYPRESS_WINDOWS_OPTIMIZE_USB_DRIVER:
|
||||
return &cypress_optimize_driver_guid;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
#include "cypress_shared_driver_comms.hpp"
|
||||
#include "cypress_shared_libusb_comms.hpp"
|
||||
#include "cypress_shared_communications.hpp"
|
||||
#include "cypress_optimize_new_3ds_communications.hpp"
|
||||
#include "cypress_optimize_new_3ds_acquisition.hpp"
|
||||
#include "cypress_optimize_new_3ds_acquisition_general.hpp"
|
||||
#include "cypress_optimize_3ds_communications.hpp"
|
||||
#include "cypress_optimize_3ds_acquisition.hpp"
|
||||
#include "cypress_optimize_3ds_acquisition_general.hpp"
|
||||
#include "usb_generic.hpp"
|
||||
|
||||
#include <libusb.h>
|
||||
@ -21,16 +21,16 @@
|
||||
#define SYNCH_VALUE_OPTIMIZE 0xCC33
|
||||
|
||||
#define SINGLE_RING_BUFFER_SLICE_SIZE 0x10000
|
||||
#define NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS 16
|
||||
#define NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS 16
|
||||
|
||||
#define NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS (3 * NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS)
|
||||
#define NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS (3 * NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS)
|
||||
|
||||
#define MAX_TIME_WAIT 1.0
|
||||
|
||||
#define OPTIMIZE_NEW_3DS_CYPRESS_USB_WINDOWS_DRIVER CYPRESS_WINDOWS_OPTIMIZE_NEW_USB_DRIVER
|
||||
#define OPTIMIZE_3DS_CYPRESS_USB_WINDOWS_DRIVER CYPRESS_WINDOWS_OPTIMIZE_USB_DRIVER
|
||||
|
||||
struct CypressOptimizeNew3DSDeviceCaptureReceivedData {
|
||||
CypressOptimizeNew3DSDeviceCaptureReceivedData* array_ptr;
|
||||
struct CypressOptimize3DSDeviceCaptureReceivedData {
|
||||
CypressOptimize3DSDeviceCaptureReceivedData* array_ptr;
|
||||
volatile bool in_use;
|
||||
volatile bool to_process;
|
||||
uint32_t index;
|
||||
@ -53,27 +53,27 @@ struct CypressOptimizeNew3DSDeviceCaptureReceivedData {
|
||||
};
|
||||
|
||||
static void cypress_device_read_frame_cb(void* user_data, int transfer_length, int transfer_status);
|
||||
static int get_cypress_device_status(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data);
|
||||
static void error_cypress_device_status(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, int error_val);
|
||||
static int get_cypress_device_status(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data);
|
||||
static void error_cypress_device_status(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, int error_val);
|
||||
|
||||
static cy_device_device_handlers* usb_find_by_serial_number(const cyopn_device_usb_device* usb_device_desc, std::string wanted_serial_number, CaptureDevice* new_device) {
|
||||
static cy_device_device_handlers* usb_find_by_serial_number(const cyop_device_usb_device* usb_device_desc, std::string wanted_serial_number, CaptureDevice* new_device) {
|
||||
cy_device_device_handlers* final_handlers = NULL;
|
||||
int curr_serial_extra_id = 0;
|
||||
final_handlers = cypress_libusb_serial_reconnection(get_cy_usb_info(usb_device_desc), wanted_serial_number, curr_serial_extra_id, new_device);
|
||||
|
||||
if(final_handlers == NULL)
|
||||
final_handlers = cypress_driver_find_by_serial_number(get_cy_usb_info(usb_device_desc), wanted_serial_number, curr_serial_extra_id, new_device, OPTIMIZE_NEW_3DS_CYPRESS_USB_WINDOWS_DRIVER);
|
||||
final_handlers = cypress_driver_find_by_serial_number(get_cy_usb_info(usb_device_desc), wanted_serial_number, curr_serial_extra_id, new_device, OPTIMIZE_3DS_CYPRESS_USB_WINDOWS_DRIVER);
|
||||
return final_handlers;
|
||||
}
|
||||
|
||||
static int usb_find_free_fw_id(const cyopn_device_usb_device* usb_device_desc) {
|
||||
static int usb_find_free_fw_id(const cyop_device_usb_device* usb_device_desc) {
|
||||
int curr_serial_extra_id = 0;
|
||||
const int num_free_fw_ids = 0x100;
|
||||
bool found[num_free_fw_ids];
|
||||
for(int i = 0; i < num_free_fw_ids; i++)
|
||||
found[i] = false;
|
||||
cypress_libusb_find_used_serial(get_cy_usb_info(usb_device_desc), found, num_free_fw_ids, curr_serial_extra_id);
|
||||
cypress_driver_find_used_serial(get_cy_usb_info(usb_device_desc), found, num_free_fw_ids, curr_serial_extra_id, OPTIMIZE_NEW_3DS_CYPRESS_USB_WINDOWS_DRIVER);
|
||||
cypress_driver_find_used_serial(get_cy_usb_info(usb_device_desc), found, num_free_fw_ids, curr_serial_extra_id, OPTIMIZE_3DS_CYPRESS_USB_WINDOWS_DRIVER);
|
||||
|
||||
for(int i = 0; i < num_free_fw_ids; i++)
|
||||
if(!found[i])
|
||||
@ -81,7 +81,7 @@ static int usb_find_free_fw_id(const cyopn_device_usb_device* usb_device_desc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cy_device_device_handlers* usb_reconnect(const cyopn_device_usb_device* usb_device_desc, CaptureDevice* device) {
|
||||
static cy_device_device_handlers* usb_reconnect(const cyop_device_usb_device* usb_device_desc, CaptureDevice* device) {
|
||||
cy_device_device_handlers* final_handlers = NULL;
|
||||
int curr_serial_extra_id = 0;
|
||||
final_handlers = cypress_libusb_serial_reconnection(get_cy_usb_info(usb_device_desc), device->serial_number, curr_serial_extra_id, NULL);
|
||||
@ -91,7 +91,7 @@ static cy_device_device_handlers* usb_reconnect(const cyopn_device_usb_device* u
|
||||
return final_handlers;
|
||||
}
|
||||
|
||||
static std::string _cypress_optimize_new_3ds_get_serial(const cyopn_device_usb_device* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id) {
|
||||
static std::string _cypress_optimize_3ds_get_serial(const cyop_device_usb_device* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id) {
|
||||
if((!usb_device_desc->has_bcd_device_serial) && (serial != ""))
|
||||
return serial;
|
||||
if(usb_device_desc->has_bcd_device_serial)
|
||||
@ -99,23 +99,23 @@ static std::string _cypress_optimize_new_3ds_get_serial(const cyopn_device_usb_d
|
||||
return std::to_string((curr_serial_extra_id++) + 1);
|
||||
}
|
||||
|
||||
std::string cypress_optimize_new_3ds_get_serial(const void* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id) {
|
||||
std::string cypress_optimize_3ds_get_serial(const void* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id) {
|
||||
if(usb_device_desc == NULL)
|
||||
return "";
|
||||
return _cypress_optimize_new_3ds_get_serial((const cyopn_device_usb_device*)usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
||||
return _cypress_optimize_3ds_get_serial((const cyop_device_usb_device*)usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
||||
}
|
||||
|
||||
static CaptureDevice _cypress_optimize_new_3ds_create_device(const cyopn_device_usb_device* usb_device_desc, std::string serial, std::string path) {
|
||||
return CaptureDevice(serial, usb_device_desc->name, usb_device_desc->long_name, CAPTURE_CONN_CYPRESS_NEW_OPTIMIZE, (void*)usb_device_desc, true, true, true, HEIGHT_3DS, TOP_WIDTH_3DS + BOT_WIDTH_3DS, HEIGHT_3DS, (TOP_WIDTH_3DS * 2) + BOT_WIDTH_3DS, OPTIMIZE_NEW_3DS_AUDIO_BUFFER_MAX_SIZE * 8, 90, BOT_WIDTH_3DS, 0, BOT_WIDTH_3DS + TOP_WIDTH_3DS, 0, 0, 0, false, VIDEO_DATA_RGB16, 0x200, path);
|
||||
static CaptureDevice _cypress_optimize_3ds_create_device(const cyop_device_usb_device* usb_device_desc, std::string serial, std::string path) {
|
||||
return CaptureDevice(serial, usb_device_desc->name, usb_device_desc->long_name, CAPTURE_CONN_CYPRESS_OPTIMIZE, (void*)usb_device_desc, true, true, true, HEIGHT_3DS, TOP_WIDTH_3DS + BOT_WIDTH_3DS, HEIGHT_3DS, (TOP_WIDTH_3DS * 2) + BOT_WIDTH_3DS, OPTIMIZE_3DS_AUDIO_BUFFER_MAX_SIZE * 8, 90, BOT_WIDTH_3DS, 0, BOT_WIDTH_3DS + TOP_WIDTH_3DS, 0, 0, 0, false, VIDEO_DATA_RGB16, 0x200, path);
|
||||
}
|
||||
|
||||
CaptureDevice cypress_optimize_new_3ds_create_device(const void* usb_device_desc, std::string serial, std::string path) {
|
||||
CaptureDevice cypress_optimize_3ds_create_device(const void* usb_device_desc, std::string serial, std::string path) {
|
||||
if(usb_device_desc == NULL)
|
||||
return CaptureDevice();
|
||||
return _cypress_optimize_new_3ds_create_device((const cyopn_device_usb_device*)usb_device_desc, serial, path);
|
||||
return _cypress_optimize_3ds_create_device((const cyop_device_usb_device*)usb_device_desc, serial, path);
|
||||
}
|
||||
|
||||
static void cypress_optimize_new_3ds_connection_end(cy_device_device_handlers* handlers, const cyopn_device_usb_device *device_desc, bool interface_claimed = true) {
|
||||
static void cypress_optimize_3ds_connection_end(cy_device_device_handlers* handlers, const cyop_device_usb_device *device_desc, bool interface_claimed = true) {
|
||||
if (handlers == NULL)
|
||||
return;
|
||||
if (handlers->usb_handle)
|
||||
@ -125,51 +125,51 @@ static void cypress_optimize_new_3ds_connection_end(cy_device_device_handlers* h
|
||||
delete handlers;
|
||||
}
|
||||
|
||||
void list_devices_cyopn_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list) {
|
||||
const size_t num_cyopn_device_desc = GetNumCyOpNDeviceDesc();
|
||||
int* curr_serial_extra_id_cyopn_device = new int[num_cyopn_device_desc];
|
||||
bool* no_access_elems = new bool[num_cyopn_device_desc];
|
||||
bool* not_supported_elems = new bool[num_cyopn_device_desc];
|
||||
void list_devices_cyop_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list) {
|
||||
const size_t num_cyop_device_desc = GetNumCyOpDeviceDesc();
|
||||
int* curr_serial_extra_id_cyop_device = new int[num_cyop_device_desc];
|
||||
bool* no_access_elems = new bool[num_cyop_device_desc];
|
||||
bool* not_supported_elems = new bool[num_cyop_device_desc];
|
||||
std::vector<const cy_device_usb_device*> usb_devices_to_check;
|
||||
for (int i = 0; i < num_cyopn_device_desc; i++) {
|
||||
for (int i = 0; i < num_cyop_device_desc; i++) {
|
||||
no_access_elems[i] = false;
|
||||
not_supported_elems[i] = false;
|
||||
curr_serial_extra_id_cyopn_device[i] = 0;
|
||||
const cyopn_device_usb_device* curr_device_desc = GetCyOpNDeviceDesc(i);
|
||||
curr_serial_extra_id_cyop_device[i] = 0;
|
||||
const cyop_device_usb_device* curr_device_desc = GetCyOpDeviceDesc(i);
|
||||
usb_devices_to_check.push_back(get_cy_usb_info(curr_device_desc));
|
||||
}
|
||||
cypress_libusb_list_devices(devices_list, no_access_elems, not_supported_elems, curr_serial_extra_id_cyopn_device, usb_devices_to_check);
|
||||
cypress_libusb_list_devices(devices_list, no_access_elems, not_supported_elems, curr_serial_extra_id_cyop_device, usb_devices_to_check);
|
||||
|
||||
bool any_not_supported = false;
|
||||
for(int i = 0; i < num_cyopn_device_desc; i++)
|
||||
for(int i = 0; i < num_cyop_device_desc; i++)
|
||||
any_not_supported |= not_supported_elems[i];
|
||||
for(int i = 0; i < num_cyopn_device_desc; i++)
|
||||
for(int i = 0; i < num_cyop_device_desc; i++)
|
||||
if(no_access_elems[i])
|
||||
no_access_list.emplace_back(usb_devices_to_check[i]->vid, usb_devices_to_check[i]->pid);
|
||||
if(any_not_supported)
|
||||
cypress_driver_list_devices(devices_list, not_supported_elems, curr_serial_extra_id_cyopn_device, usb_devices_to_check, OPTIMIZE_NEW_3DS_CYPRESS_USB_WINDOWS_DRIVER);
|
||||
cypress_driver_list_devices(devices_list, not_supported_elems, curr_serial_extra_id_cyop_device, usb_devices_to_check, OPTIMIZE_3DS_CYPRESS_USB_WINDOWS_DRIVER);
|
||||
|
||||
delete[] curr_serial_extra_id_cyopn_device;
|
||||
delete[] curr_serial_extra_id_cyop_device;
|
||||
delete[] no_access_elems;
|
||||
delete[] not_supported_elems;
|
||||
}
|
||||
|
||||
bool cyopn_device_connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device) {
|
||||
const cyopn_device_usb_device* usb_device_info = (const cyopn_device_usb_device*)device->descriptor;
|
||||
bool cyop_device_connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device) {
|
||||
const cyop_device_usb_device* usb_device_info = (const cyop_device_usb_device*)device->descriptor;
|
||||
cy_device_device_handlers* handlers = usb_reconnect(usb_device_info, device);
|
||||
if(handlers == NULL) {
|
||||
capture_error_print(true, capture_data, "Device not found");
|
||||
return false;
|
||||
}
|
||||
if(has_to_load_firmware(usb_device_info)) {
|
||||
const cyopn_device_usb_device* next_usb_device_info = GetNextDeviceDesc(usb_device_info);
|
||||
const cyop_device_usb_device* next_usb_device_info = GetNextDeviceDesc(usb_device_info);
|
||||
int free_fw_id = usb_find_free_fw_id(next_usb_device_info);
|
||||
int ret = load_firmware(handlers, usb_device_info, free_fw_id);
|
||||
if(!ret) {
|
||||
capture_error_print(true, capture_data, "Firmware load error");
|
||||
return false;
|
||||
}
|
||||
cypress_optimize_new_3ds_connection_end(handlers, usb_device_info);
|
||||
cypress_optimize_3ds_connection_end(handlers, usb_device_info);
|
||||
std::string new_serial_number = std::to_string(free_fw_id);
|
||||
CaptureDevice new_device;
|
||||
for(int i = 0; i < 20; i++) {
|
||||
@ -189,39 +189,39 @@ bool cyopn_device_connect_usb(bool print_failed, CaptureData* capture_data, Capt
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t cyopn_device_get_video_in_size(bool is_3d, InputVideoDataType video_data_type) {
|
||||
uint64_t cyop_device_get_video_in_size(bool is_3d, InputVideoDataType video_data_type) {
|
||||
bool is_rgb888 = video_data_type == VIDEO_DATA_RGB;
|
||||
if(is_rgb888) {
|
||||
if(is_3d)
|
||||
return sizeof(USB888New3DSOptimizeCaptureReceived_3D);
|
||||
return sizeof(USB888New3DSOptimizeCaptureReceived);
|
||||
return sizeof(USB8883DSOptimizeCaptureReceived_3D);
|
||||
return sizeof(USB8883DSOptimizeCaptureReceived);
|
||||
}
|
||||
if(is_3d)
|
||||
return sizeof(USB565New3DSOptimizeCaptureReceived_3D);
|
||||
return sizeof(USB565New3DSOptimizeCaptureReceived);
|
||||
return sizeof(USB5653DSOptimizeCaptureReceived_3D);
|
||||
return sizeof(USB5653DSOptimizeCaptureReceived);
|
||||
}
|
||||
|
||||
|
||||
uint64_t cyopn_device_get_video_in_size(CaptureStatus* status, bool is_3d, InputVideoDataType video_data_type) {
|
||||
return cyopn_device_get_video_in_size(is_3d, video_data_type);
|
||||
uint64_t cyop_device_get_video_in_size(CaptureStatus* status, bool is_3d, InputVideoDataType video_data_type) {
|
||||
return cyop_device_get_video_in_size(is_3d, video_data_type);
|
||||
}
|
||||
|
||||
|
||||
uint64_t cyopn_device_get_video_in_size(CaptureData* capture_data, bool is_3d, InputVideoDataType video_data_type) {
|
||||
return cyopn_device_get_video_in_size(&capture_data->status, is_3d, video_data_type);
|
||||
uint64_t cyop_device_get_video_in_size(CaptureData* capture_data, bool is_3d, InputVideoDataType video_data_type) {
|
||||
return cyop_device_get_video_in_size(&capture_data->status, is_3d, video_data_type);
|
||||
}
|
||||
|
||||
static int cypress_device_read_frame_request(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, uint32_t index, bool is_3d, InputVideoDataType video_data_type) {
|
||||
static int cypress_device_read_frame_request(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, uint32_t index, bool is_3d, InputVideoDataType video_data_type) {
|
||||
if(cypress_device_capture_recv_data == NULL)
|
||||
return LIBUSB_SUCCESS;
|
||||
if((*cypress_device_capture_recv_data->status) < 0)
|
||||
return LIBUSB_SUCCESS;
|
||||
const cyopn_device_usb_device* usb_device_info = (const cyopn_device_usb_device*)capture_data->status.device.descriptor;
|
||||
const cyop_device_usb_device* usb_device_info = (const cyop_device_usb_device*)capture_data->status.device.descriptor;
|
||||
cypress_device_capture_recv_data->index = index;
|
||||
cypress_device_capture_recv_data->cb_data.function = cypress_device_read_frame_cb;
|
||||
//size_t read_size = cyopn_device_get_video_in_size(is_3d, video_data_type);
|
||||
//size_t read_size = cyop_device_get_video_in_size(is_3d, video_data_type);
|
||||
size_t read_size = SINGLE_RING_BUFFER_SLICE_SIZE;
|
||||
int new_buffer_slice_index = ((*cypress_device_capture_recv_data->last_ring_buffer_slice_allocated) + 1) % NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS;
|
||||
int new_buffer_slice_index = ((*cypress_device_capture_recv_data->last_ring_buffer_slice_allocated) + 1) % NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS;
|
||||
uint8_t* buffer = &cypress_device_capture_recv_data->ring_slice_buffer_arr[new_buffer_slice_index * SINGLE_RING_BUFFER_SLICE_SIZE];
|
||||
cypress_device_capture_recv_data->is_ring_buffer_slice_data_ready_arr[new_buffer_slice_index] = false;
|
||||
cypress_device_capture_recv_data->is_ring_buffer_slice_data_in_use_arr[new_buffer_slice_index] = true;
|
||||
@ -234,7 +234,7 @@ static int cypress_device_read_frame_request(CaptureData* capture_data, CypressO
|
||||
return ReadFrameAsync((cy_device_device_handlers*)capture_data->handle, buffer, read_size, usb_device_info, &cypress_device_capture_recv_data->cb_data);
|
||||
}
|
||||
|
||||
static void unlock_buffer_directly(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data_real) {
|
||||
static void unlock_buffer_directly(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data_real) {
|
||||
int slice_index = cypress_device_capture_recv_data_real->ring_buffer_slice_index;
|
||||
cypress_device_capture_recv_data_real->is_ring_buffer_slice_data_ready_arr[slice_index] = false;
|
||||
cypress_device_capture_recv_data_real->is_ring_buffer_slice_data_in_use_arr[slice_index] = false;
|
||||
@ -243,14 +243,14 @@ static void unlock_buffer_directly(CypressOptimizeNew3DSDeviceCaptureReceivedDat
|
||||
cypress_device_capture_recv_data_real->is_buffer_free_shared_mutex->specific_unlock(cypress_device_capture_recv_data_real->cb_data.internal_index);
|
||||
}
|
||||
|
||||
static void unlock_buffer_slice_index(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, int slice_index) {
|
||||
static void unlock_buffer_slice_index(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, int slice_index) {
|
||||
int index = cypress_device_capture_recv_data->buffer_ring_slice_to_array_ptr[slice_index];
|
||||
if(index == -1)
|
||||
return;
|
||||
unlock_buffer_directly(&cypress_device_capture_recv_data->array_ptr[index]);
|
||||
}
|
||||
|
||||
static void end_cypress_device_read_frame_cb(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, bool to_unlock) {
|
||||
static void end_cypress_device_read_frame_cb(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, bool to_unlock) {
|
||||
cypress_device_capture_recv_data->to_process = false;
|
||||
if(to_unlock)
|
||||
unlock_buffer_directly(cypress_device_capture_recv_data);
|
||||
@ -266,24 +266,24 @@ static size_t get_pos_first_synch_in_buffer(uint8_t* buffer) {
|
||||
return SINGLE_RING_BUFFER_SLICE_SIZE + 1;
|
||||
}
|
||||
|
||||
static int get_num_consecutive_ready_ring_buffer_slices(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, int start_index) {
|
||||
for(int i = 0; i < NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++) {
|
||||
int index_check = (start_index + i) % NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS;
|
||||
static int get_num_consecutive_ready_ring_buffer_slices(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, int start_index) {
|
||||
for(int i = 0; i < NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS; i++) {
|
||||
int index_check = (start_index + i) % NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS;
|
||||
if(!cypress_device_capture_recv_data->is_ring_buffer_slice_data_ready_arr[index_check])
|
||||
return i;
|
||||
}
|
||||
// Should never happen
|
||||
return NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS;
|
||||
return NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS;
|
||||
}
|
||||
|
||||
static void cypress_output_to_thread(CaptureData* capture_data, uint8_t *buffer_arr, size_t start_slice_index, size_t start_slice_pos, int internal_index, std::chrono::time_point<std::chrono::high_resolution_clock>* clock_start, size_t read_size) {
|
||||
// Output to the other threads...
|
||||
CaptureDataSingleBuffer* data_buf = capture_data->data_buffers.GetWriterBuffer(internal_index);
|
||||
size_t start_byte = (start_slice_index * SINGLE_RING_BUFFER_SLICE_SIZE) + start_slice_pos;
|
||||
if((start_byte + read_size) <= (NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS * SINGLE_RING_BUFFER_SLICE_SIZE))
|
||||
if((start_byte + read_size) <= (NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS * SINGLE_RING_BUFFER_SLICE_SIZE))
|
||||
memcpy(&data_buf->capture_buf, buffer_arr + start_byte, read_size);
|
||||
else {
|
||||
size_t upper_read_size = (NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS * SINGLE_RING_BUFFER_SLICE_SIZE) - start_byte;
|
||||
size_t upper_read_size = (NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS * SINGLE_RING_BUFFER_SLICE_SIZE) - start_byte;
|
||||
size_t start_read_size = read_size - upper_read_size;
|
||||
memcpy(&data_buf->capture_buf, buffer_arr + start_byte, upper_read_size);
|
||||
memcpy(((uint8_t*)&data_buf->capture_buf) + upper_read_size, buffer_arr, start_read_size);
|
||||
@ -299,7 +299,7 @@ static void cypress_output_to_thread(CaptureData* capture_data, uint8_t *buffer_
|
||||
}
|
||||
|
||||
static void cypress_device_read_frame_cb(void* user_data, int transfer_length, int transfer_status) {
|
||||
CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data = (CypressOptimizeNew3DSDeviceCaptureReceivedData*)user_data;
|
||||
CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data = (CypressOptimize3DSDeviceCaptureReceivedData*)user_data;
|
||||
if((*cypress_device_capture_recv_data->status) < 0)
|
||||
return end_cypress_device_read_frame_cb(cypress_device_capture_recv_data, true);
|
||||
if((transfer_status != LIBUSB_TRANSFER_COMPLETED) || (transfer_length < SINGLE_RING_BUFFER_SLICE_SIZE)) {
|
||||
@ -315,19 +315,19 @@ static void cypress_device_read_frame_cb(void* user_data, int transfer_length, i
|
||||
volatile int read_slice_index = *cypress_device_capture_recv_data->last_used_ring_buffer_slice_index;
|
||||
if(read_slice_index == -1) {
|
||||
size_t first_to_check = 0;
|
||||
for(int i = 0; i < NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++) {
|
||||
for(int i = 0; i < NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS; i++) {
|
||||
if(!cypress_device_capture_recv_data->is_ring_buffer_slice_data_in_use_arr[i])
|
||||
first_to_check++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if(first_to_check > NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS) {
|
||||
if(first_to_check > NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS) {
|
||||
int error = LIBUSB_ERROR_OTHER;
|
||||
*cypress_device_capture_recv_data->status = error;
|
||||
return end_cypress_device_read_frame_cb(cypress_device_capture_recv_data, true);
|
||||
}
|
||||
for(int i = 0; i < NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++) {
|
||||
size_t check_index = (first_to_check + i) % NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS;
|
||||
for(int i = 0; i < NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS; i++) {
|
||||
size_t check_index = (first_to_check + i) % NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS;
|
||||
if(cypress_device_capture_recv_data->is_ring_buffer_slice_data_ready_arr[check_index]) {
|
||||
size_t result = get_pos_first_synch_in_buffer(&cypress_device_capture_recv_data->ring_slice_buffer_arr[check_index * SINGLE_RING_BUFFER_SLICE_SIZE]);
|
||||
if(result >= SINGLE_RING_BUFFER_SLICE_SIZE) {
|
||||
@ -348,7 +348,7 @@ static void cypress_device_read_frame_cb(void* user_data, int transfer_length, i
|
||||
volatile size_t read_slice_pos = *cypress_device_capture_recv_data->last_used_ring_buffer_slice_pos;
|
||||
if(read_slice_index != -1) {
|
||||
int num_consecutive_ready_buffers = get_num_consecutive_ready_ring_buffer_slices(cypress_device_capture_recv_data, read_slice_index);
|
||||
size_t video_in_size = cyopn_device_get_video_in_size(*cypress_device_capture_recv_data->stored_is_3d, *cypress_device_capture_recv_data->stored_video_data_type);
|
||||
size_t video_in_size = cyop_device_get_video_in_size(*cypress_device_capture_recv_data->stored_is_3d, *cypress_device_capture_recv_data->stored_video_data_type);
|
||||
size_t raw_new_pos = read_slice_pos + video_in_size;
|
||||
int num_needed_buffers = (raw_new_pos + SINGLE_RING_BUFFER_SLICE_SIZE - 1) / SINGLE_RING_BUFFER_SLICE_SIZE;
|
||||
if(num_consecutive_ready_buffers >= num_needed_buffers) {
|
||||
@ -359,12 +359,12 @@ static void cypress_device_read_frame_cb(void* user_data, int transfer_length, i
|
||||
size_t new_slice_pos = raw_new_pos % SINGLE_RING_BUFFER_SLICE_SIZE;
|
||||
if(new_slice_pos == 0)
|
||||
new_slice_index += 1;
|
||||
new_slice_index %= NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS;
|
||||
new_slice_index %= NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS;
|
||||
// Unlock the buffers already processed
|
||||
int pos_to_unlock = read_slice_index;
|
||||
while(pos_to_unlock != new_slice_index) {
|
||||
unlock_buffer_slice_index(cypress_device_capture_recv_data, pos_to_unlock);
|
||||
pos_to_unlock = (pos_to_unlock + 1) % NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS;
|
||||
pos_to_unlock = (pos_to_unlock + 1) % NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS;
|
||||
}
|
||||
// Update the position of the data
|
||||
*cypress_device_capture_recv_data->last_used_ring_buffer_slice_index = new_slice_index;
|
||||
@ -374,21 +374,21 @@ static void cypress_device_read_frame_cb(void* user_data, int transfer_length, i
|
||||
return end_cypress_device_read_frame_cb(cypress_device_capture_recv_data, to_free);
|
||||
}
|
||||
|
||||
static int cypress_device_get_num_free_buffers(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
static int cypress_device_get_num_free_buffers(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
int num_free = 0;
|
||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||
for(int i = 0; i < NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||
if(!cypress_device_capture_recv_data[i].in_use)
|
||||
num_free += 1;
|
||||
return num_free;
|
||||
}
|
||||
|
||||
static void close_all_reads_error(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, bool &async_read_closed) {
|
||||
static void close_all_reads_error(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, bool &async_read_closed) {
|
||||
cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle;
|
||||
const cyopn_device_usb_device* usb_device_desc = (const cyopn_device_usb_device*)capture_data->status.device.descriptor;
|
||||
const cyop_device_usb_device* usb_device_desc = (const cyop_device_usb_device*)capture_data->status.device.descriptor;
|
||||
if(get_cypress_device_status(cypress_device_capture_recv_data) < 0) {
|
||||
if(!async_read_closed) {
|
||||
if(handlers->usb_handle) {
|
||||
for (int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||
for (int i = 0; i < NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||
CypressCloseAsyncRead(handlers, get_cy_usb_info(usb_device_desc), &cypress_device_capture_recv_data[i].cb_data);
|
||||
}
|
||||
else
|
||||
@ -404,28 +404,28 @@ static bool has_too_much_time_passed(const std::chrono::time_point<std::chrono::
|
||||
return diff.count() > MAX_TIME_WAIT;
|
||||
}
|
||||
|
||||
static void error_too_much_time_passed(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, bool &async_read_closed, const std::chrono::time_point<std::chrono::high_resolution_clock> &start_time) {
|
||||
static void error_too_much_time_passed(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, bool &async_read_closed, const std::chrono::time_point<std::chrono::high_resolution_clock> &start_time) {
|
||||
if(has_too_much_time_passed(start_time)) {
|
||||
error_cypress_device_status(cypress_device_capture_recv_data, -1);
|
||||
close_all_reads_error(capture_data, cypress_device_capture_recv_data, async_read_closed);
|
||||
}
|
||||
}
|
||||
|
||||
static void check_unlock_waiting_with_error(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
static void check_unlock_waiting_with_error(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
if(get_cypress_device_status(cypress_device_capture_recv_data) < 0) {
|
||||
if(cypress_device_capture_recv_data->is_ring_buffer_slice_data_ready_arr[cypress_device_capture_recv_data->ring_buffer_slice_index])
|
||||
unlock_buffer_directly(cypress_device_capture_recv_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void wait_all_cypress_device_buffers_free(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
static void wait_all_cypress_device_buffers_free(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
if(cypress_device_capture_recv_data == NULL)
|
||||
return;
|
||||
cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle;
|
||||
bool async_read_closed = false;
|
||||
close_all_reads_error(capture_data, cypress_device_capture_recv_data, async_read_closed);
|
||||
const auto start_time = std::chrono::high_resolution_clock::now();
|
||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||
for(int i = 0; i < NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||
while(cypress_device_capture_recv_data[i].in_use) {
|
||||
error_too_much_time_passed(capture_data, cypress_device_capture_recv_data, async_read_closed, start_time);
|
||||
check_unlock_waiting_with_error(&cypress_device_capture_recv_data[i]);
|
||||
@ -433,12 +433,12 @@ static void wait_all_cypress_device_buffers_free(CaptureData* capture_data, Cypr
|
||||
}
|
||||
}
|
||||
|
||||
static void wait_one_cypress_device_buffer_free(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
static void wait_one_cypress_device_buffer_free(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle;
|
||||
bool done = false;
|
||||
const auto start_time = std::chrono::high_resolution_clock::now();
|
||||
while(!done) {
|
||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) {
|
||||
for(int i = 0; i < NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) {
|
||||
if(!cypress_device_capture_recv_data[i].in_use)
|
||||
done = true;
|
||||
}
|
||||
@ -453,7 +453,7 @@ static void wait_one_cypress_device_buffer_free(CaptureData* capture_data, Cypre
|
||||
}
|
||||
}
|
||||
|
||||
static void wait_specific_cypress_device_buffer_free(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
static void wait_specific_cypress_device_buffer_free(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle;
|
||||
bool done = false;
|
||||
const auto start_time = std::chrono::high_resolution_clock::now();
|
||||
@ -471,26 +471,26 @@ static void wait_specific_cypress_device_buffer_free(CaptureData* capture_data,
|
||||
}
|
||||
}
|
||||
|
||||
static bool cypress_device_are_buffers_all_free(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
return cypress_device_get_num_free_buffers(cypress_device_capture_recv_data) == NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS;
|
||||
static bool cypress_device_are_buffers_all_free(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
return cypress_device_get_num_free_buffers(cypress_device_capture_recv_data) == NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS;
|
||||
}
|
||||
|
||||
static CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_get_free_buffer(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
static CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_get_free_buffer(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
wait_one_cypress_device_buffer_free(capture_data, cypress_device_capture_recv_data);
|
||||
if(get_cypress_device_status(cypress_device_capture_recv_data) < 0)
|
||||
return NULL;
|
||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||
for(int i = 0; i < NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||
if(!cypress_device_capture_recv_data[i].in_use) {
|
||||
return &cypress_device_capture_recv_data[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int get_cypress_device_status(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
static int get_cypress_device_status(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
return *cypress_device_capture_recv_data[0].status;
|
||||
}
|
||||
|
||||
static void error_cypress_device_status(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, int error_val) {
|
||||
static void error_cypress_device_status(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, int error_val) {
|
||||
if((error_val == 0) || (get_cypress_device_status(cypress_device_capture_recv_data) == 0))
|
||||
*cypress_device_capture_recv_data[0].status = error_val;
|
||||
}
|
||||
@ -498,26 +498,26 @@ static void error_cypress_device_status(CypressOptimizeNew3DSDeviceCaptureReceiv
|
||||
static void exported_error_cypress_device_status(void* data, int error_val) {
|
||||
if(data == NULL)
|
||||
return;
|
||||
return error_cypress_device_status((CypressOptimizeNew3DSDeviceCaptureReceivedData*)data, error_val);
|
||||
return error_cypress_device_status((CypressOptimize3DSDeviceCaptureReceivedData*)data, error_val);
|
||||
}
|
||||
|
||||
static void reset_cypress_device_status(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
static void reset_cypress_device_status(CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||
error_cypress_device_status(cypress_device_capture_recv_data, 0);
|
||||
}
|
||||
|
||||
static bool cyopn_device_acquisition_loop(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, InputVideoDataType &stored_video_data_type, bool &stored_is_3d) {
|
||||
static bool cyop_device_acquisition_loop(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, InputVideoDataType &stored_video_data_type, bool &stored_is_3d) {
|
||||
cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle;
|
||||
const cyopn_device_usb_device* usb_device_desc = (const cyopn_device_usb_device*)capture_data->status.device.descriptor;
|
||||
const cyop_device_usb_device* usb_device_desc = (const cyop_device_usb_device*)capture_data->status.device.descriptor;
|
||||
uint32_t index = 0;
|
||||
int ret = capture_start(handlers, usb_device_desc, true, stored_video_data_type == VIDEO_DATA_RGB);
|
||||
if (ret < 0) {
|
||||
capture_error_print(true, capture_data, "Capture Start: Failed");
|
||||
return false;
|
||||
}
|
||||
CypressSetMaxTransferSize(handlers, get_cy_usb_info(usb_device_desc), cyopn_device_get_video_in_size(stored_is_3d, stored_video_data_type));
|
||||
CypressSetMaxTransferSize(handlers, get_cy_usb_info(usb_device_desc), cyop_device_get_video_in_size(stored_is_3d, stored_video_data_type));
|
||||
auto clock_last_reset = std::chrono::high_resolution_clock::now();
|
||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) {
|
||||
CypressOptimizeNew3DSDeviceCaptureReceivedData* chosen_buffer = cypress_device_get_free_buffer(capture_data, cypress_device_capture_recv_data);
|
||||
for(int i = 0; i < NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) {
|
||||
CypressOptimize3DSDeviceCaptureReceivedData* chosen_buffer = cypress_device_get_free_buffer(capture_data, cypress_device_capture_recv_data);
|
||||
ret = cypress_device_read_frame_request(capture_data, chosen_buffer, index++, stored_is_3d, stored_video_data_type);
|
||||
if(ret < 0) {
|
||||
chosen_buffer->in_use = false;
|
||||
@ -536,7 +536,7 @@ static bool cyopn_device_acquisition_loop(CaptureData* capture_data, CypressOpti
|
||||
capture_error_print(true, capture_data, "Disconnected: Read error");
|
||||
return false;
|
||||
}
|
||||
CypressOptimizeNew3DSDeviceCaptureReceivedData* chosen_buffer = cypress_device_get_free_buffer(capture_data, cypress_device_capture_recv_data);
|
||||
CypressOptimize3DSDeviceCaptureReceivedData* chosen_buffer = cypress_device_get_free_buffer(capture_data, cypress_device_capture_recv_data);
|
||||
if(chosen_buffer == NULL)
|
||||
error_cypress_device_status(cypress_device_capture_recv_data, LIBUSB_ERROR_TIMEOUT);
|
||||
ret = cypress_device_read_frame_request(capture_data, chosen_buffer, index++, stored_is_3d, stored_video_data_type);
|
||||
@ -551,24 +551,24 @@ static bool cyopn_device_acquisition_loop(CaptureData* capture_data, CypressOpti
|
||||
return true;
|
||||
}
|
||||
|
||||
void cyopn_device_acquisition_main_loop(CaptureData* capture_data) {
|
||||
void cyop_device_acquisition_main_loop(CaptureData* capture_data) {
|
||||
if(!usb_is_initialized())
|
||||
return;
|
||||
bool is_done_thread;
|
||||
std::thread async_processing_thread;
|
||||
cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle;
|
||||
const cyopn_device_usb_device* usb_device_desc = (const cyopn_device_usb_device*)capture_data->status.device.descriptor;
|
||||
const cyop_device_usb_device* usb_device_desc = (const cyop_device_usb_device*)capture_data->status.device.descriptor;
|
||||
|
||||
uint32_t last_index = -1;
|
||||
int status = 0;
|
||||
InputVideoDataType stored_video_data_type = capture_data->status.device.video_data_type;
|
||||
bool stored_is_3d = false;
|
||||
|
||||
uint8_t *ring_slice_buffer = new uint8_t[NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS * SINGLE_RING_BUFFER_SLICE_SIZE];
|
||||
bool *is_ring_buffer_slice_data_ready = new bool[NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS];
|
||||
bool *is_ring_buffer_slice_data_in_use = new bool[NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS];
|
||||
int *buffer_ring_slice_to_array = new int[NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS];
|
||||
for(int i = 0; i < NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++) {
|
||||
uint8_t *ring_slice_buffer = new uint8_t[NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS * SINGLE_RING_BUFFER_SLICE_SIZE];
|
||||
bool *is_ring_buffer_slice_data_ready = new bool[NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS];
|
||||
bool *is_ring_buffer_slice_data_in_use = new bool[NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS];
|
||||
int *buffer_ring_slice_to_array = new int[NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS];
|
||||
for(int i = 0; i < NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS; i++) {
|
||||
is_ring_buffer_slice_data_ready[i] = false;
|
||||
is_ring_buffer_slice_data_in_use[i] = false;
|
||||
buffer_ring_slice_to_array[i] = -1;
|
||||
@ -578,12 +578,12 @@ void cyopn_device_acquisition_main_loop(CaptureData* capture_data) {
|
||||
int last_ring_buffer_slice_allocated = -1;
|
||||
|
||||
std::vector<cy_async_callback_data*> cb_queue;
|
||||
SharedConsumerMutex is_buffer_free_shared_mutex(NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS);
|
||||
SharedConsumerMutex is_transfer_done_shared_mutex(NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS);
|
||||
SharedConsumerMutex is_transfer_data_ready_shared_mutex(NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS);
|
||||
SharedConsumerMutex is_buffer_free_shared_mutex(NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS);
|
||||
SharedConsumerMutex is_transfer_done_shared_mutex(NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS);
|
||||
SharedConsumerMutex is_transfer_data_ready_shared_mutex(NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS);
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> clock_start = std::chrono::high_resolution_clock::now();
|
||||
CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data = new CypressOptimizeNew3DSDeviceCaptureReceivedData[NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS];
|
||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) {
|
||||
CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data = new CypressOptimize3DSDeviceCaptureReceivedData[NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS];
|
||||
for(int i = 0; i < NUM_OPTIMIZE_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) {
|
||||
cypress_device_capture_recv_data[i].array_ptr = cypress_device_capture_recv_data;
|
||||
cypress_device_capture_recv_data[i].in_use = false;
|
||||
cypress_device_capture_recv_data[i].to_process = false;
|
||||
@ -613,7 +613,7 @@ void cyopn_device_acquisition_main_loop(CaptureData* capture_data) {
|
||||
cb_queue.push_back(&cypress_device_capture_recv_data[i].cb_data);
|
||||
}
|
||||
CypressSetupCypressDeviceAsyncThread(handlers, cb_queue, &async_processing_thread, &is_done_thread);
|
||||
bool proper_return = cyopn_device_acquisition_loop(capture_data, cypress_device_capture_recv_data, stored_video_data_type, stored_is_3d);
|
||||
bool proper_return = cyop_device_acquisition_loop(capture_data, cypress_device_capture_recv_data, stored_video_data_type, stored_is_3d);
|
||||
wait_all_cypress_device_buffers_free(capture_data, cypress_device_capture_recv_data);
|
||||
CypressEndCypressDeviceAsyncThread(handlers, cb_queue, &async_processing_thread, &is_done_thread);
|
||||
delete []cypress_device_capture_recv_data;
|
||||
@ -626,18 +626,18 @@ void cyopn_device_acquisition_main_loop(CaptureData* capture_data) {
|
||||
capture_end(handlers, usb_device_desc);
|
||||
}
|
||||
|
||||
void usb_cyopn_device_acquisition_cleanup(CaptureData* capture_data) {
|
||||
void usb_cyop_device_acquisition_cleanup(CaptureData* capture_data) {
|
||||
if(!usb_is_initialized())
|
||||
return;
|
||||
|
||||
cypress_optimize_new_3ds_connection_end((cy_device_device_handlers*)capture_data->handle, (const cyopn_device_usb_device*)capture_data->status.device.descriptor);
|
||||
cypress_optimize_3ds_connection_end((cy_device_device_handlers*)capture_data->handle, (const cyop_device_usb_device*)capture_data->status.device.descriptor);
|
||||
capture_data->handle = NULL;
|
||||
}
|
||||
void usb_cyopn_device_init() {
|
||||
void usb_cyop_device_init() {
|
||||
return usb_init();
|
||||
}
|
||||
|
||||
void usb_cyopn_device_close() {
|
||||
void usb_cyop_device_close() {
|
||||
usb_close();
|
||||
}
|
||||
|
@ -1,13 +1,17 @@
|
||||
#include "frontend.hpp"
|
||||
#include "cypress_optimize_new_3ds_communications.hpp"
|
||||
#include "cypress_optimize_3ds_communications.hpp"
|
||||
#include "cypress_shared_communications.hpp"
|
||||
#include "cypress_optimize_new_3ds_acquisition_general.hpp"
|
||||
#include "cypress_optimize_3ds_acquisition_general.hpp"
|
||||
#include "usb_generic.hpp"
|
||||
|
||||
#include "optimize_new_3ds_fw.h"
|
||||
#include "optimize_new_3ds_565_fpga_pl.h"
|
||||
#include "optimize_new_3ds_888_fpga_pl.h"
|
||||
|
||||
#include "optimize_old_3ds_fw.h"
|
||||
#include "optimize_old_3ds_565_fpga_pl.h"
|
||||
#include "optimize_old_3ds_888_fpga_pl.h"
|
||||
|
||||
#include <libusb.h>
|
||||
#include <cstring>
|
||||
#include <thread>
|
||||
@ -23,17 +27,23 @@
|
||||
|
||||
#define CYPRESS_BASE_USB_PACKET_LIMIT 64
|
||||
#define CYPRESS_OPTIMIZE_NEW_3DS_USB_PACKET_LIMIT 512
|
||||
#define CYPRESS_OPTIMIZE_OLD_3DS_USB_PACKET_LIMIT 512
|
||||
|
||||
#define OPTIMIZE_NEW_3DS_WANTED_VALUE_BASE 0xFE00
|
||||
#define OPTIMIZE_OLD_3DS_WANTED_VALUE_BASE 0xFD00
|
||||
|
||||
static const cyopn_device_usb_device cypress_optimize_new_3ds_generic_device = {
|
||||
const uint8_t start_capture_third_buffer_565_new[] = { 0x61, 0x07, 0x00, 0x0F, 0x00, 0x3E, 0x00, 0xF8, 0x00, 0x38, 0x00, 0x51, 0x80, 0x5C, 0x01, 0x00 };
|
||||
const uint8_t start_capture_third_buffer_888_new[] = { 0x61, 0x07, 0x00, 0xA6, 0x00, 0x28, 0x00, 0x62, 0x00, 0x3A, 0x00, 0x51, 0x80, 0x5C, 0x01, 0x00 };
|
||||
const uint8_t start_capture_third_buffer_565_old[] = { 0x61, 0x07, 0x00, 0x26, 0x00, 0x22, 0x00, 0x98, 0x00, 0x08, 0x00, 0xDE, 0x00, 0xF9, 0x18, 0x0F };
|
||||
const uint8_t start_capture_third_buffer_888_old[] = { 0x61, 0x07, 0x00, 0xA6, 0x00, 0x20, 0x00, 0x98, 0x00, 0x08, 0x00, 0xDE, 0x00, 0xF9, 0x18, 0x0F };
|
||||
|
||||
static const cyop_device_usb_device cypress_optimize_new_3ds_generic_device = {
|
||||
.name = "EZ-USB -> Optimize New 3DS", .long_name = "EZ-USB -> Optimize New 3DS",
|
||||
.device_type = CYPRESS_OPTIMIZE_NEW_3DS_BLANK_DEVICE,
|
||||
.firmware_to_load = optimize_new_3ds_fw, .firmware_size = optimize_new_3ds_fw_len,
|
||||
.fpga_pl_565 = NULL, .fpga_pl_565_size = 0,
|
||||
.fpga_pl_565_3d = NULL, .fpga_pl_565_3d_size = 0,
|
||||
.fpga_pl_888 = NULL, .fpga_pl_888_size = 0,
|
||||
.fpga_pl_888_3d = NULL, .fpga_pl_888_3d_size = 0,
|
||||
.is_new_device = true,
|
||||
.next_device = CYPRESS_OPTIMIZE_NEW_3DS_INSTANTIATED_DEVICE,
|
||||
.has_bcd_device_serial = false,
|
||||
.usb_device_info = {
|
||||
@ -46,21 +56,20 @@ static const cyopn_device_usb_device cypress_optimize_new_3ds_generic_device = {
|
||||
.do_pipe_clear_reset = false,
|
||||
.alt_interface = 1,
|
||||
.full_data = &cypress_optimize_new_3ds_generic_device,
|
||||
.get_serial_fn = cypress_optimize_new_3ds_get_serial,
|
||||
.create_device_fn = cypress_optimize_new_3ds_create_device,
|
||||
.get_serial_fn = cypress_optimize_3ds_get_serial,
|
||||
.create_device_fn = cypress_optimize_3ds_create_device,
|
||||
.bcd_device_mask = 0x0000,
|
||||
.bcd_device_wanted_value = 0x0000
|
||||
}
|
||||
};
|
||||
|
||||
static const cyopn_device_usb_device cypress_optimize_new_3ds_instantiated_device = {
|
||||
static const cyop_device_usb_device cypress_optimize_new_3ds_instantiated_device = {
|
||||
.name = "Optimize New 3DS", .long_name = "Optimize New 3DS",
|
||||
.device_type = CYPRESS_OPTIMIZE_NEW_3DS_INSTANTIATED_DEVICE,
|
||||
.firmware_to_load = NULL, .firmware_size = 0,
|
||||
.fpga_pl_565 = optimize_new_3ds_565_fpga_pl, .fpga_pl_565_size = optimize_new_3ds_565_fpga_pl_len,
|
||||
.fpga_pl_565_3d = NULL, .fpga_pl_565_3d_size = 0,
|
||||
.fpga_pl_888 = optimize_new_3ds_888_fpga_pl, .fpga_pl_888_size = optimize_new_3ds_888_fpga_pl_len,
|
||||
.fpga_pl_888_3d = NULL, .fpga_pl_888_3d_size = 0,
|
||||
.is_new_device = true,
|
||||
.next_device = CYPRESS_OPTIMIZE_NEW_3DS_INSTANTIATED_DEVICE,
|
||||
.has_bcd_device_serial = true,
|
||||
.usb_device_info = {
|
||||
@ -73,42 +82,96 @@ static const cyopn_device_usb_device cypress_optimize_new_3ds_instantiated_devic
|
||||
.do_pipe_clear_reset = true,
|
||||
.alt_interface = 0,
|
||||
.full_data = &cypress_optimize_new_3ds_instantiated_device,
|
||||
.get_serial_fn = cypress_optimize_new_3ds_get_serial,
|
||||
.create_device_fn = cypress_optimize_new_3ds_create_device,
|
||||
.get_serial_fn = cypress_optimize_3ds_get_serial,
|
||||
.create_device_fn = cypress_optimize_3ds_create_device,
|
||||
.bcd_device_mask = 0xFF00,
|
||||
.bcd_device_wanted_value = OPTIMIZE_NEW_3DS_WANTED_VALUE_BASE
|
||||
}
|
||||
};
|
||||
|
||||
static const cyopn_device_usb_device* all_usb_cyopn_device_devices_desc[] = {
|
||||
&cypress_optimize_new_3ds_generic_device,
|
||||
&cypress_optimize_new_3ds_instantiated_device,
|
||||
static const cyop_device_usb_device cypress_optimize_old_3ds_generic_device = {
|
||||
.name = "EZ-USB -> Optimize Old 3DS", .long_name = "EZ-USB -> Optimize Old 3DS",
|
||||
.device_type = CYPRESS_OPTIMIZE_OLD_3DS_BLANK_DEVICE,
|
||||
.firmware_to_load = optimize_old_3ds_fw, .firmware_size = optimize_old_3ds_fw_len,
|
||||
.fpga_pl_565 = NULL, .fpga_pl_565_size = 0,
|
||||
.fpga_pl_888 = NULL, .fpga_pl_888_size = 0,
|
||||
.is_new_device = false,
|
||||
.next_device = CYPRESS_OPTIMIZE_OLD_3DS_INSTANTIATED_DEVICE,
|
||||
.has_bcd_device_serial = false,
|
||||
.usb_device_info = {
|
||||
.vid = 0x04B4, .pid = 0x8613,
|
||||
.default_config = 1, .default_interface = 0,
|
||||
.bulk_timeout = 500,
|
||||
.ep_ctrl_bulk_in = 0, .ep_ctrl_bulk_out = 0,
|
||||
.ep_bulk_in = 0,
|
||||
.max_usb_packet_size = CYPRESS_BASE_USB_PACKET_LIMIT,
|
||||
.do_pipe_clear_reset = false,
|
||||
.alt_interface = 1,
|
||||
.full_data = &cypress_optimize_old_3ds_generic_device,
|
||||
.get_serial_fn = cypress_optimize_3ds_get_serial,
|
||||
.create_device_fn = cypress_optimize_3ds_create_device,
|
||||
.bcd_device_mask = 0x0000,
|
||||
.bcd_device_wanted_value = 0x0000
|
||||
}
|
||||
};
|
||||
|
||||
const cy_device_usb_device* get_cy_usb_info(const cyopn_device_usb_device* usb_device_desc) {
|
||||
static const cyop_device_usb_device cypress_optimize_old_3ds_instantiated_device = {
|
||||
.name = "Optimize Old 3DS", .long_name = "Optimize Old 3DS",
|
||||
.device_type = CYPRESS_OPTIMIZE_OLD_3DS_INSTANTIATED_DEVICE,
|
||||
.firmware_to_load = NULL, .firmware_size = 0,
|
||||
.fpga_pl_565 = optimize_old_3ds_565_fpga_pl, .fpga_pl_565_size = optimize_old_3ds_565_fpga_pl_len,
|
||||
.fpga_pl_888 = optimize_old_3ds_888_fpga_pl, .fpga_pl_888_size = optimize_old_3ds_888_fpga_pl_len,
|
||||
.is_new_device = false,
|
||||
.next_device = CYPRESS_OPTIMIZE_OLD_3DS_INSTANTIATED_DEVICE,
|
||||
.has_bcd_device_serial = true,
|
||||
.usb_device_info = {
|
||||
.vid = 0x04B4, .pid = 0x1004,
|
||||
.default_config = 1, .default_interface = 0,
|
||||
.bulk_timeout = 500,
|
||||
.ep_ctrl_bulk_in = 1 | LIBUSB_ENDPOINT_IN, .ep_ctrl_bulk_out = 1 | LIBUSB_ENDPOINT_OUT,
|
||||
.ep_bulk_in = 2 | LIBUSB_ENDPOINT_IN,
|
||||
.max_usb_packet_size = CYPRESS_OPTIMIZE_OLD_3DS_USB_PACKET_LIMIT,
|
||||
.do_pipe_clear_reset = true,
|
||||
.alt_interface = 0,
|
||||
.full_data = &cypress_optimize_old_3ds_instantiated_device,
|
||||
.get_serial_fn = cypress_optimize_3ds_get_serial,
|
||||
.create_device_fn = cypress_optimize_3ds_create_device,
|
||||
.bcd_device_mask = 0xFF00,
|
||||
.bcd_device_wanted_value = OPTIMIZE_OLD_3DS_WANTED_VALUE_BASE
|
||||
}
|
||||
};
|
||||
|
||||
static const cyop_device_usb_device* all_usb_cyop_device_devices_desc[] = {
|
||||
&cypress_optimize_new_3ds_generic_device,
|
||||
&cypress_optimize_new_3ds_instantiated_device,
|
||||
&cypress_optimize_old_3ds_generic_device,
|
||||
&cypress_optimize_old_3ds_instantiated_device,
|
||||
};
|
||||
|
||||
const cy_device_usb_device* get_cy_usb_info(const cyop_device_usb_device* usb_device_desc) {
|
||||
return &usb_device_desc->usb_device_info;
|
||||
}
|
||||
|
||||
int GetNumCyOpNDeviceDesc() {
|
||||
return sizeof(all_usb_cyopn_device_devices_desc) / sizeof(all_usb_cyopn_device_devices_desc[0]);
|
||||
int GetNumCyOpDeviceDesc() {
|
||||
return sizeof(all_usb_cyop_device_devices_desc) / sizeof(all_usb_cyop_device_devices_desc[0]);
|
||||
}
|
||||
|
||||
const cyopn_device_usb_device* GetCyOpNDeviceDesc(int index) {
|
||||
if((index < 0) || (index >= GetNumCyOpNDeviceDesc()))
|
||||
const cyop_device_usb_device* GetCyOpDeviceDesc(int index) {
|
||||
if((index < 0) || (index >= GetNumCyOpDeviceDesc()))
|
||||
index = 0;
|
||||
return all_usb_cyopn_device_devices_desc[index];
|
||||
return all_usb_cyop_device_devices_desc[index];
|
||||
}
|
||||
|
||||
const cyopn_device_usb_device* GetNextDeviceDesc(const cyopn_device_usb_device* device) {
|
||||
for(int i = 0; i < GetNumCyOpNDeviceDesc(); i++) {
|
||||
const cyopn_device_usb_device* examined_device = GetCyOpNDeviceDesc(i);
|
||||
const cyop_device_usb_device* GetNextDeviceDesc(const cyop_device_usb_device* device) {
|
||||
for(int i = 0; i < GetNumCyOpDeviceDesc(); i++) {
|
||||
const cyop_device_usb_device* examined_device = GetCyOpDeviceDesc(i);
|
||||
if(examined_device->device_type == device->next_device)
|
||||
return examined_device;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool has_to_load_firmware(const cyopn_device_usb_device* device) {
|
||||
bool has_to_load_firmware(const cyop_device_usb_device* device) {
|
||||
return !((device->firmware_to_load == NULL) || (device->firmware_size == 0));
|
||||
}
|
||||
|
||||
@ -117,16 +180,20 @@ static bool free_firmware_and_return(uint8_t* fw_data, bool retval) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
bool load_firmware(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, uint8_t patch_id) {
|
||||
bool load_firmware(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, uint8_t patch_id) {
|
||||
if(!has_to_load_firmware(device))
|
||||
return true;
|
||||
const cyop_device_usb_device* next_device = GetNextDeviceDesc(device);
|
||||
if((next_device == NULL) || (next_device == device))
|
||||
return true;
|
||||
int transferred = 0;
|
||||
uint16_t base_patch_value = next_device->usb_device_info.bcd_device_wanted_value;
|
||||
uint8_t* fw_data = new uint8_t[device->firmware_size];
|
||||
memcpy(fw_data, device->firmware_to_load, device->firmware_size);
|
||||
int num_patches = read_le16(fw_data, 1);
|
||||
for(int i = 0; i < num_patches; i++) {
|
||||
int pos_patch = read_le16(fw_data, 2 + i);
|
||||
write_le16(fw_data + pos_patch, patch_id | OPTIMIZE_NEW_3DS_WANTED_VALUE_BASE);
|
||||
write_le16(fw_data + pos_patch, patch_id | base_patch_value);
|
||||
}
|
||||
uint8_t buffer[0x8000];
|
||||
buffer[0] = 1;
|
||||
@ -157,19 +224,16 @@ bool load_firmware(cy_device_device_handlers* handlers, const cyopn_device_usb_d
|
||||
return free_firmware_and_return(fw_data, true);
|
||||
}
|
||||
|
||||
static int read_device_info(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device) {
|
||||
const uint8_t first_out_buffer[] = { 0x65 };
|
||||
static int read_device_info(cy_device_device_handlers* handlers, const cyop_device_usb_device* device) {
|
||||
const int read_block_size = 0x10;
|
||||
const int num_reads = 8;
|
||||
uint8_t in_buffer[read_block_size * num_reads];
|
||||
int transferred = 0;
|
||||
int ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), first_out_buffer, sizeof(first_out_buffer), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
uint8_t second_out_buffer[] = { 0x38, 0x00, 0x10, 0x30 };
|
||||
int ret = 0;
|
||||
uint8_t first_out_buffer[] = { 0x38, 0x00, 0x10, 0x30 };
|
||||
for(int i = 0; i < num_reads; i++) {
|
||||
second_out_buffer[1] = i * read_block_size;
|
||||
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), second_out_buffer, sizeof(second_out_buffer), &transferred);
|
||||
first_out_buffer[1] = i * read_block_size;
|
||||
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), first_out_buffer, sizeof(first_out_buffer), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
ret = cypress_ctrl_bulk_in_transfer(handlers, get_cy_usb_info(device), in_buffer + (i * read_block_size), read_block_size, &transferred);
|
||||
@ -181,7 +245,7 @@ static int read_device_info(cy_device_device_handlers* handlers, const cyopn_dev
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int read_second_device_id(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, uint64_t &second_device_id) {
|
||||
static int read_second_device_id(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, uint64_t &second_device_id) {
|
||||
const uint8_t first_out_buffer[] = { 0x60, 0x02, 0x30, 0xFF, 0x60, 0xD0, 0x60, 0x02, 0x30, 0xFF, 0x60, 0xCB, 0x60, 0x02, 0x00, 0xFF, 0x00, 0xFF };
|
||||
uint8_t in_buffer[sizeof(uint64_t)];
|
||||
int transferred = 0;
|
||||
@ -201,7 +265,7 @@ static int read_second_device_id(cy_device_device_handlers* handlers, const cyop
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int read_device_id(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, uint64_t &device_id, bool &is_full_0s) {
|
||||
static int read_device_id(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, uint64_t &device_id, bool &is_full_0s) {
|
||||
const uint8_t out_buffer[] = { 0x70 };
|
||||
uint8_t in_buffer[0x10];
|
||||
int transferred = 0;
|
||||
@ -223,7 +287,7 @@ static int read_device_id(cy_device_device_handlers* handlers, const cyopn_devic
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int read_first_unk_value(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, uint32_t &value) {
|
||||
static int read_first_unk_value(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, uint32_t &value) {
|
||||
const uint8_t out_buffer[] = { 0x60, 0x02, 0x30, 0xFF, 0x60, 0xC9, 0x60, 0x01, 0x20, 0xFF, 0x61, 0x04, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x80, 0xFF, 0x60, 0x01, 0x01, 0xFF };
|
||||
uint8_t in_buffer[sizeof(uint32_t)];
|
||||
int transferred = 0;
|
||||
@ -239,18 +303,29 @@ static int read_first_unk_value(cy_device_device_handlers* handlers, const cyopn
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dual_first_unk_value_setup_read(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, uint32_t &value32, uint64_t &device_id, uint64_t &second_device_id) {
|
||||
static int start_command_send(cy_device_device_handlers* handlers, const cyop_device_usb_device* device) {
|
||||
int transferred = 0;
|
||||
const uint8_t mono_out_buffer [] = { 0x65 };
|
||||
int ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), mono_out_buffer, sizeof(mono_out_buffer), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int dual_first_unk_value_setup_read(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, uint32_t &value32, uint64_t &device_id, uint64_t &second_device_id) {
|
||||
const uint8_t first_buffer[] = { 0x64, 0x60, 0x01, 0xFF, 0xFF, 0x60, 0x02, 0x00, 0xFF, 0x00, 0xFF };
|
||||
int transferred = 0;
|
||||
int ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), first_buffer, sizeof(first_buffer), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
ret = read_first_unk_value(handlers, device, value32);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
ret = read_first_unk_value(handlers, device, value32);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
if(device->is_new_device) {
|
||||
ret = read_first_unk_value(handlers, device, value32);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
ret = read_first_unk_value(handlers, device, value32);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
}
|
||||
bool is_full_0s = false;
|
||||
ret = read_device_id(handlers, device, device_id, is_full_0s);
|
||||
if(ret < 0)
|
||||
@ -262,7 +337,7 @@ static int dual_first_unk_value_setup_read(cy_device_device_handlers* handlers,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int fpga_pl_load(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, uint8_t* fpga_pl, size_t fpga_pl_size) {
|
||||
static int fpga_pl_load(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, uint8_t* fpga_pl, size_t fpga_pl_size) {
|
||||
const uint8_t first_buffer[] = { 0x60, 0x02, 0x00, 0xFF, 0x00, 0xFF, 0x60, 0x02, 0x30, 0xFF, 0x60, 0xCB, 0x60, 0x02, 0x30, 0xFF, 0x60, 0xC5, 0x66, 0x64, 0x60, 0x02, 0x30, 0xFF, 0x60, 0xC5 };
|
||||
int transferred = 0;
|
||||
int ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), first_buffer, sizeof(first_buffer), &transferred);
|
||||
@ -329,21 +404,25 @@ static int fpga_pl_load(cy_device_device_handlers* handlers, const cyopn_device_
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int insert_device_id(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, uint64_t device_id) {
|
||||
static int insert_device_id(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, uint64_t device_id) {
|
||||
const uint8_t first_buffer[] = { 0x60, 0x02, 0x30, 0xFF, 0x60, 0xCC, 0x60, 0x02, 0x00, 0xFF, 0x00, 0xFF, 0x60, 0x02, 0x30, 0xFF, 0x60, 0xFF, 0x60, 0x02, 0x30, 0xFF, 0x60, 0xFF };
|
||||
int transferred = 0;
|
||||
int ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), first_buffer, sizeof(first_buffer), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
uint8_t device_id_buffer[] = {0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xC3, 0x00, 0x00, 0x02, 0x30, 0xFF, 0x60, 0x65 };
|
||||
write_le64(device_id_buffer + 1, device_id);
|
||||
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), device_id_buffer, sizeof(device_id_buffer), &transferred);
|
||||
uint8_t device_id_buffer_new_3ds[] = {0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xC3, 0x00, 0x00, 0x02, 0x30, 0xFF, 0x60, 0x65 };
|
||||
uint8_t device_id_buffer_old_3ds[] = {0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, 0x0B, 0x01, 0x00, 0x02, 0x30, 0xFF, 0x60, 0x65 };
|
||||
uint8_t* target_device_id_buffer = device_id_buffer_new_3ds;
|
||||
if(!device->is_new_device)
|
||||
target_device_id_buffer = device_id_buffer_old_3ds;
|
||||
write_le64(target_device_id_buffer + 1, device_id);
|
||||
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), target_device_id_buffer, sizeof(device_id_buffer_new_3ds), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int final_capture_start_transfer(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device) {
|
||||
static int final_capture_start_transfer(cy_device_device_handlers* handlers, const cyop_device_usb_device* device) {
|
||||
const uint8_t first_buffer[] = { 0x5B, 0x59, 0x03 };
|
||||
int transferred = 0;
|
||||
int ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), first_buffer, sizeof(first_buffer), &transferred);
|
||||
@ -352,7 +431,7 @@ static int final_capture_start_transfer(cy_device_device_handlers* handlers, con
|
||||
return ret;
|
||||
}
|
||||
|
||||
int capture_start(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, bool is_first_load, bool is_rgb888) {
|
||||
int capture_start(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_first_load, bool is_rgb888) {
|
||||
int transferred = 0;
|
||||
int ret = 0;
|
||||
uint32_t value32 = 0;
|
||||
@ -367,9 +446,14 @@ int capture_start(cy_device_device_handlers* handlers, const cyopn_device_usb_de
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
}
|
||||
ret = read_device_info(handlers, device);
|
||||
ret = start_command_send(handlers, device);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
if(device->is_new_device) {
|
||||
ret = read_device_info(handlers, device);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
}
|
||||
cypress_pipe_reset_ctrl_bulk_in(handlers, get_cy_usb_info(device));
|
||||
cypress_pipe_reset_ctrl_bulk_out(handlers, get_cy_usb_info(device));
|
||||
ret = dual_first_unk_value_setup_read(handlers, device, value32, device_id, second_device_id);
|
||||
@ -400,10 +484,20 @@ int capture_start(cy_device_device_handlers* handlers, const cyopn_device_usb_de
|
||||
return ret;
|
||||
}
|
||||
|
||||
int StartCaptureDma(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device, bool is_rgb888) {
|
||||
uint8_t mono_buffer[0x1];
|
||||
static const uint8_t* get_start_capture_third_buffer(const cyop_device_usb_device* device, bool is_rgb888) {
|
||||
if(device->is_new_device) {
|
||||
if(is_rgb888)
|
||||
return start_capture_third_buffer_888_new;
|
||||
return start_capture_third_buffer_565_new;
|
||||
}
|
||||
if(is_rgb888)
|
||||
return start_capture_third_buffer_888_old;
|
||||
return start_capture_third_buffer_565_old;
|
||||
}
|
||||
|
||||
int StartCaptureDma(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_rgb888) {
|
||||
const uint8_t mono_buffer[] = { 0x40 };
|
||||
int transferred = 0;
|
||||
mono_buffer[0] = 0x40;
|
||||
int ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), mono_buffer, sizeof(mono_buffer), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
@ -411,26 +505,23 @@ int StartCaptureDma(cy_device_device_handlers* handlers, const cyopn_device_usb_
|
||||
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), second_buffer, sizeof(second_buffer), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
const uint8_t third_buffer_565[] = { 0x61, 0x07, 0x00, 0x0F, 0x00, 0x3E, 0x00, 0xF8, 0x00, 0x38, 0x00, 0x51, 0x80, 0x5C, 0x01, 0x00 };
|
||||
const uint8_t third_buffer_888[] = { 0x61, 0x07, 0x00, 0xA6, 0x00, 0x28, 0x00, 0x62, 0x00, 0x3A, 0x00, 0x51, 0x80, 0x5C, 0x01, 0x00 };
|
||||
const uint8_t* third_buffer = third_buffer_565;
|
||||
if(is_rgb888)
|
||||
third_buffer = third_buffer_888;
|
||||
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), third_buffer, sizeof(third_buffer_565), &transferred);
|
||||
const uint8_t* third_buffer = get_start_capture_third_buffer(device, is_rgb888);
|
||||
uint8_t real_third_buffer[sizeof(start_capture_third_buffer_888_new)];
|
||||
memcpy(real_third_buffer, third_buffer, sizeof(real_third_buffer));
|
||||
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), real_third_buffer, sizeof(real_third_buffer), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
uint8_t in_buffer[7];
|
||||
ret = cypress_ctrl_bulk_in_transfer(handlers, get_cy_usb_info(device), in_buffer, sizeof(in_buffer), &transferred);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
mono_buffer[0] = 0x65;
|
||||
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), mono_buffer, sizeof(mono_buffer), &transferred);
|
||||
ret = start_command_send(handlers, device);
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int capture_end(cy_device_device_handlers* handlers, const cyopn_device_usb_device* device) {
|
||||
int capture_end(cy_device_device_handlers* handlers, const cyop_device_usb_device* device) {
|
||||
int transferred = 0;
|
||||
uint8_t buffer[] = { 0x41 };
|
||||
int ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), buffer, sizeof(buffer), &transferred);
|
||||
@ -442,7 +533,7 @@ int capture_end(cy_device_device_handlers* handlers, const cyopn_device_usb_devi
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ReadFrame(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyopn_device_usb_device* device_desc) {
|
||||
int ReadFrame(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyop_device_usb_device* device_desc) {
|
||||
// Maybe making this async would be better for lower end hardware...
|
||||
int num_bytes = 0;
|
||||
int ret = cypress_bulk_in_transfer(handlers, get_cy_usb_info(device_desc), buf, length, &num_bytes);
|
||||
@ -451,6 +542,6 @@ int ReadFrame(cy_device_device_handlers* handlers, uint8_t* buf, int length, con
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ReadFrameAsync(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyopn_device_usb_device* device_desc, cy_async_callback_data* cb_data) {
|
||||
int ReadFrameAsync(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyop_device_usb_device* device_desc, cy_async_callback_data* cb_data) {
|
||||
return cypress_bulk_in_async(handlers, get_cy_usb_info(device_desc), buf, length, cb_data);
|
||||
}
|
@ -68,8 +68,6 @@ struct twl_2bit_pixels {
|
||||
uint8_t fourth_b : 1;
|
||||
};
|
||||
|
||||
static void usb_new_3ds_optimize_convertVideoToOutput(CaptureReceived *p_in, VideoOutputData *p_out, bool enabled_3d, const bool is_big_endian, bool interleaved_3d, bool requested_3d, bool is_rgb888);
|
||||
|
||||
// Optimized de-interleave methods...
|
||||
|
||||
static inline uint16_t _reverse_endianness(uint16_t data) {
|
||||
@ -436,7 +434,7 @@ static inline void usb_oldDSconvertVideoToOutputHalfLineDirectOptBE(USBOldDSCapt
|
||||
usb_rgb565convertInterleaveVideoToOutputDirectOptBE(out_ptr_top, out_ptr_bottom, in_ptr, halfline_iters, input_halfline, output_halfline);
|
||||
}
|
||||
|
||||
static inline void usb_new3DS565OptimizeconvertVideoToOutputLineDirectOptLE(USB565New3DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, int column) {
|
||||
static inline void usb_3DS565OptimizeconvertVideoToOutputLineDirectOptLE(USB5653DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, int column) {
|
||||
//de-interleave pixels
|
||||
const int pixels_size = 2;
|
||||
const int num_screens = 2;
|
||||
@ -464,7 +462,7 @@ static inline void usb_new3DS565OptimizeconvertVideoToOutputLineDirectOptLE(USB5
|
||||
}
|
||||
}
|
||||
|
||||
static inline void usb_new3DS565OptimizeconvertVideoToOutputLineDirectOptBE(USB565New3DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, int column) {
|
||||
static inline void usb_3DS565OptimizeconvertVideoToOutputLineDirectOptBE(USB5653DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, int column) {
|
||||
//de-interleave pixels
|
||||
const int pixels_size = 2;
|
||||
const int num_screens = 2;
|
||||
@ -492,7 +490,7 @@ static inline void usb_new3DS565OptimizeconvertVideoToOutputLineDirectOptBE(USB5
|
||||
}
|
||||
}
|
||||
|
||||
static inline void usb_new3DS565Optimizeconvert3DVideoToOutputLineDirectOptLE(USB565New3DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, int column, bool interleaved_3d) {
|
||||
static inline void usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptLE(USB5653DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, int column, bool interleaved_3d) {
|
||||
//de-interleave pixels
|
||||
const int pixels_size = 2;
|
||||
const int num_screens = 3;
|
||||
@ -527,7 +525,7 @@ static inline void usb_new3DS565Optimizeconvert3DVideoToOutputLineDirectOptLE(US
|
||||
}
|
||||
}
|
||||
|
||||
static inline void usb_new3DS565Optimizeconvert3DVideoToOutputLineDirectOptBE(USB565New3DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, int column, bool interleaved_3d) {
|
||||
static inline void usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptBE(USB5653DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, int column, bool interleaved_3d) {
|
||||
//de-interleave pixels
|
||||
const int pixels_size = 2;
|
||||
const int num_screens = 3;
|
||||
@ -562,7 +560,7 @@ static inline void usb_new3DS565Optimizeconvert3DVideoToOutputLineDirectOptBE(US
|
||||
}
|
||||
}
|
||||
|
||||
static inline void usb_new3DS888OptimizeconvertVideoToOutputLineDirectOpt(USB888New3DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, int column) {
|
||||
static inline void usb_3DS888OptimizeconvertVideoToOutputLineDirectOpt(USB8883DSOptimizeCaptureReceived *p_in, VideoOutputData *p_out, int column) {
|
||||
//de-interleave pixels
|
||||
const int pixels_size = 3;
|
||||
const size_t column_start_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2) + 2;
|
||||
@ -589,7 +587,7 @@ static inline void usb_new3DS888OptimizeconvertVideoToOutputLineDirectOpt(USB888
|
||||
}
|
||||
}
|
||||
|
||||
static inline void usb_new3DS888Optimizeconvert3DVideoToOutputLineDirectOpt(USB888New3DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, int column, bool interleaved_3d) {
|
||||
static inline void usb_3DS888Optimizeconvert3DVideoToOutputLineDirectOpt(USB8883DSOptimizeCaptureReceived_3D *p_in, VideoOutputData *p_out, int column, bool interleaved_3d) {
|
||||
//de-interleave pixels
|
||||
const int pixels_size = 3;
|
||||
const size_t column_start_bot_pos = (SCREEN_WIDTH_FIRST_PIXEL_BOTTOM_3DS * 2) + 2;
|
||||
@ -720,35 +718,35 @@ static void usb_cypress_nisetro_ds_convertVideoToOutput(CaptureReceived *p_in, V
|
||||
}
|
||||
}
|
||||
|
||||
static void usb_new_3ds_optimize_convertVideoToOutput(CaptureReceived *p_in, VideoOutputData *p_out, bool enabled_3d, const bool is_big_endian, bool interleaved_3d, bool requested_3d, bool is_rgb888) {
|
||||
static void usb_3ds_optimize_convertVideoToOutput(CaptureReceived *p_in, VideoOutputData *p_out, bool enabled_3d, const bool is_big_endian, bool interleaved_3d, bool requested_3d, bool is_rgb888) {
|
||||
if(!is_rgb888) {
|
||||
if(!enabled_3d) {
|
||||
if(!is_big_endian)
|
||||
for(int i = 0; i < (TOP_WIDTH_3DS + 1); i++)
|
||||
usb_new3DS565OptimizeconvertVideoToOutputLineDirectOptLE(&p_in->cypress_new_optimize_received_565, p_out, i);
|
||||
usb_3DS565OptimizeconvertVideoToOutputLineDirectOptLE(&p_in->cypress_optimize_received_565, p_out, i);
|
||||
else
|
||||
for(int i = 0; i < (TOP_WIDTH_3DS + 1); i++)
|
||||
usb_new3DS565OptimizeconvertVideoToOutputLineDirectOptBE(&p_in->cypress_new_optimize_received_565, p_out, i);
|
||||
usb_3DS565OptimizeconvertVideoToOutputLineDirectOptBE(&p_in->cypress_optimize_received_565, p_out, i);
|
||||
expand_2d_to_3d_convertVideoToOutput((uint8_t*)p_out->screen_data, 2, interleaved_3d, requested_3d);
|
||||
}
|
||||
else {
|
||||
if(!is_big_endian)
|
||||
for(int i = 0; i < (TOP_WIDTH_3DS + 1); i++)
|
||||
usb_new3DS565Optimizeconvert3DVideoToOutputLineDirectOptLE(&p_in->cypress_new_optimize_received_565_3d, p_out, i, interleaved_3d);
|
||||
usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptLE(&p_in->cypress_optimize_received_565_3d, p_out, i, interleaved_3d);
|
||||
else
|
||||
for(int i = 0; i < (TOP_WIDTH_3DS + 1); i++)
|
||||
usb_new3DS565Optimizeconvert3DVideoToOutputLineDirectOptBE(&p_in->cypress_new_optimize_received_565_3d, p_out, i, interleaved_3d);
|
||||
usb_3DS565Optimizeconvert3DVideoToOutputLineDirectOptBE(&p_in->cypress_optimize_received_565_3d, p_out, i, interleaved_3d);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!enabled_3d) {
|
||||
for(int i = 0; i < (TOP_WIDTH_3DS + 1); i++)
|
||||
usb_new3DS888OptimizeconvertVideoToOutputLineDirectOpt(&p_in->cypress_new_optimize_received_888, p_out, i);
|
||||
usb_3DS888OptimizeconvertVideoToOutputLineDirectOpt(&p_in->cypress_optimize_received_888, p_out, i);
|
||||
expand_2d_to_3d_convertVideoToOutput((uint8_t*)p_out->screen_data, 3, interleaved_3d, requested_3d);
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < (TOP_WIDTH_3DS + 1); i++)
|
||||
usb_new3DS888Optimizeconvert3DVideoToOutputLineDirectOpt(&p_in->cypress_new_optimize_received_888_3d, p_out, i, interleaved_3d);
|
||||
usb_3DS888Optimizeconvert3DVideoToOutputLineDirectOpt(&p_in->cypress_optimize_received_888_3d, p_out, i, interleaved_3d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -839,37 +837,37 @@ bool convertVideoToOutput(VideoOutputData *p_out, const bool is_big_endian, Capt
|
||||
converted = true;
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
if(status->device.cc_type == CAPTURE_CONN_CYPRESS_NEW_OPTIMIZE) {
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
if(status->device.cc_type == CAPTURE_CONN_CYPRESS_OPTIMIZE) {
|
||||
bool is_rgb888 = video_data_type == VIDEO_DATA_RGB;
|
||||
usb_new_3ds_optimize_convertVideoToOutput(p_in, p_out, is_data_3d, is_big_endian, interleaved_3d, is_3d_requested, is_rgb888);
|
||||
usb_3ds_optimize_convertVideoToOutput(p_in, p_out, is_data_3d, is_big_endian, interleaved_3d, is_3d_requested, is_rgb888);
|
||||
converted = true;
|
||||
}
|
||||
#endif
|
||||
return converted;
|
||||
}
|
||||
|
||||
static USBNew3DSOptimizeHeaderSoundData* getAudioHeaderPtrNewOptimize3DS(CaptureReceived* buffer, bool is_rgb888, bool is_data_3d, int column) {
|
||||
static USB3DSOptimizeHeaderSoundData* getAudioHeaderPtrOptimize3DS(CaptureReceived* buffer, bool is_rgb888, bool is_data_3d, int column) {
|
||||
if(!is_rgb888) {
|
||||
if(!is_data_3d)
|
||||
return &buffer->cypress_new_optimize_received_565.columns_data[column].header_sound;
|
||||
return &buffer->cypress_new_optimize_received_565_3d.columns_data[column].header_sound;
|
||||
return &buffer->cypress_optimize_received_565.columns_data[column].header_sound;
|
||||
return &buffer->cypress_optimize_received_565_3d.columns_data[column].header_sound;
|
||||
}
|
||||
if(!is_data_3d)
|
||||
return &buffer->cypress_new_optimize_received_888.columns_data[column].header_sound;
|
||||
return &buffer->cypress_new_optimize_received_888_3d.columns_data[column].header_sound;
|
||||
return &buffer->cypress_optimize_received_888.columns_data[column].header_sound;
|
||||
return &buffer->cypress_optimize_received_888_3d.columns_data[column].header_sound;
|
||||
}
|
||||
|
||||
static inline uint16_t read_sample_indexLE(USBNew3DSOptimizeSingleSoundData* sample) {
|
||||
return sample->sample_index % OPTIMIZE_NEW_3DS_AUDIO_BUFFER_MAX_SIZE;
|
||||
static inline uint16_t read_sample_indexLE(USB3DSOptimizeSingleSoundData* sample) {
|
||||
return sample->sample_index % OPTIMIZE_3DS_AUDIO_BUFFER_MAX_SIZE;
|
||||
}
|
||||
|
||||
static inline uint16_t read_sample_indexBE(USBNew3DSOptimizeSingleSoundData* sample) {
|
||||
return _reverse_endianness(sample->sample_index) % OPTIMIZE_NEW_3DS_AUDIO_BUFFER_MAX_SIZE;
|
||||
static inline uint16_t read_sample_indexBE(USB3DSOptimizeSingleSoundData* sample) {
|
||||
return _reverse_endianness(sample->sample_index) % OPTIMIZE_3DS_AUDIO_BUFFER_MAX_SIZE;
|
||||
}
|
||||
|
||||
static inline void copyAudioFromSoundDataNewOptimize3DSLE(std::int16_t *p_out, USBNew3DSOptimizeSingleSoundData* sample, uint64_t& num_inserted, int& last_inserted_index) {
|
||||
uint16_t read_index = read_sample_indexLE(sample) % OPTIMIZE_NEW_3DS_AUDIO_BUFFER_MAX_SIZE;
|
||||
static inline void copyAudioFromSoundDataOptimize3DSLE(std::int16_t *p_out, USB3DSOptimizeSingleSoundData* sample, uint64_t& num_inserted, int& last_inserted_index) {
|
||||
uint16_t read_index = read_sample_indexLE(sample) % OPTIMIZE_3DS_AUDIO_BUFFER_MAX_SIZE;
|
||||
if(read_index == last_inserted_index)
|
||||
return;
|
||||
p_out[num_inserted * 2] = sample->sample_l;
|
||||
@ -878,8 +876,8 @@ static inline void copyAudioFromSoundDataNewOptimize3DSLE(std::int16_t *p_out, U
|
||||
last_inserted_index = read_index;
|
||||
}
|
||||
|
||||
static inline void copyAudioFromSoundDataNewOptimize3DSBE(std::int16_t *p_out, USBNew3DSOptimizeSingleSoundData* sample, uint64_t& num_inserted, int& last_inserted_index) {
|
||||
uint16_t read_index = read_sample_indexBE(sample) % OPTIMIZE_NEW_3DS_AUDIO_BUFFER_MAX_SIZE;
|
||||
static inline void copyAudioFromSoundDataOptimize3DSBE(std::int16_t *p_out, USB3DSOptimizeSingleSoundData* sample, uint64_t& num_inserted, int& last_inserted_index) {
|
||||
uint16_t read_index = read_sample_indexBE(sample) % OPTIMIZE_3DS_AUDIO_BUFFER_MAX_SIZE;
|
||||
if(read_index == last_inserted_index)
|
||||
return;
|
||||
p_out[num_inserted * 2] = _reverse_endianness(sample->sample_l);
|
||||
@ -888,27 +886,27 @@ static inline void copyAudioFromSoundDataNewOptimize3DSBE(std::int16_t *p_out, U
|
||||
last_inserted_index = read_index;
|
||||
}
|
||||
|
||||
static void copyAudioNewOptimize3DSLE(std::int16_t *p_out, uint64_t &n_samples, uint16_t &last_buffer_index, CaptureReceived* buffer, bool is_rgb888, bool is_data_3d) {
|
||||
USBNew3DSOptimizeHeaderSoundData* first_column_data = getAudioHeaderPtrNewOptimize3DS(buffer, is_rgb888, is_data_3d, 0);
|
||||
static void copyAudioOptimize3DSLE(std::int16_t *p_out, uint64_t &n_samples, uint16_t &last_buffer_index, CaptureReceived* buffer, bool is_rgb888, bool is_data_3d) {
|
||||
USB3DSOptimizeHeaderSoundData* first_column_data = getAudioHeaderPtrOptimize3DS(buffer, is_rgb888, is_data_3d, 0);
|
||||
uint64_t num_inserted = 0;
|
||||
int last_inserted_index = last_buffer_index;
|
||||
for(int i = 0; i < TOP_WIDTH_3DS; i++) {
|
||||
USBNew3DSOptimizeHeaderSoundData* curr_column_data = getAudioHeaderPtrNewOptimize3DS(buffer, is_rgb888, is_data_3d, i);
|
||||
copyAudioFromSoundDataNewOptimize3DSLE(p_out, &curr_column_data->samples[0], num_inserted, last_inserted_index);
|
||||
copyAudioFromSoundDataNewOptimize3DSLE(p_out, &curr_column_data->samples[1], num_inserted, last_inserted_index);
|
||||
USB3DSOptimizeHeaderSoundData* curr_column_data = getAudioHeaderPtrOptimize3DS(buffer, is_rgb888, is_data_3d, i);
|
||||
copyAudioFromSoundDataOptimize3DSLE(p_out, &curr_column_data->samples[0], num_inserted, last_inserted_index);
|
||||
copyAudioFromSoundDataOptimize3DSLE(p_out, &curr_column_data->samples[1], num_inserted, last_inserted_index);
|
||||
}
|
||||
last_buffer_index = last_inserted_index;
|
||||
n_samples = num_inserted * 2;
|
||||
}
|
||||
|
||||
static void copyAudioNewOptimize3DSBE(std::int16_t *p_out, uint64_t &n_samples, uint16_t &last_buffer_index, CaptureReceived* buffer, bool is_rgb888, bool is_data_3d) {
|
||||
USBNew3DSOptimizeHeaderSoundData* first_column_data = getAudioHeaderPtrNewOptimize3DS(buffer, is_rgb888, is_data_3d, 0);
|
||||
static void copyAudioOptimize3DSBE(std::int16_t *p_out, uint64_t &n_samples, uint16_t &last_buffer_index, CaptureReceived* buffer, bool is_rgb888, bool is_data_3d) {
|
||||
USB3DSOptimizeHeaderSoundData* first_column_data = getAudioHeaderPtrOptimize3DS(buffer, is_rgb888, is_data_3d, 0);
|
||||
uint64_t num_inserted = 0;
|
||||
int last_inserted_index = last_buffer_index;
|
||||
for(int i = 0; i < TOP_WIDTH_3DS; i++) {
|
||||
USBNew3DSOptimizeHeaderSoundData* curr_column_data = getAudioHeaderPtrNewOptimize3DS(buffer, is_rgb888, is_data_3d, i);
|
||||
copyAudioFromSoundDataNewOptimize3DSBE(p_out, &curr_column_data->samples[0], num_inserted, last_inserted_index);
|
||||
copyAudioFromSoundDataNewOptimize3DSBE(p_out, &curr_column_data->samples[1], num_inserted, last_inserted_index);
|
||||
USB3DSOptimizeHeaderSoundData* curr_column_data = getAudioHeaderPtrOptimize3DS(buffer, is_rgb888, is_data_3d, i);
|
||||
copyAudioFromSoundDataOptimize3DSBE(p_out, &curr_column_data->samples[0], num_inserted, last_inserted_index);
|
||||
copyAudioFromSoundDataOptimize3DSBE(p_out, &curr_column_data->samples[1], num_inserted, last_inserted_index);
|
||||
}
|
||||
last_buffer_index = last_inserted_index;
|
||||
n_samples = num_inserted * 2;
|
||||
@ -959,13 +957,13 @@ bool convertAudioToOutput(std::int16_t *p_out, uint64_t &n_samples, uint16_t &la
|
||||
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
if(status->device.cc_type == CAPTURE_CONN_CYPRESS_NEW_OPTIMIZE) {
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
if(status->device.cc_type == CAPTURE_CONN_CYPRESS_OPTIMIZE) {
|
||||
bool is_rgb888 = video_data_type == VIDEO_DATA_RGB;
|
||||
if(is_big_endian)
|
||||
copyAudioNewOptimize3DSBE(p_out, n_samples, last_buffer_index, &data_buffer->capture_buf, is_rgb888, is_data_3d);
|
||||
copyAudioOptimize3DSBE(p_out, n_samples, last_buffer_index, &data_buffer->capture_buf, is_rgb888, is_data_3d);
|
||||
else
|
||||
copyAudioNewOptimize3DSLE(p_out, n_samples, last_buffer_index, &data_buffer->capture_buf, is_rgb888, is_data_3d);
|
||||
copyAudioOptimize3DSLE(p_out, n_samples, last_buffer_index, &data_buffer->capture_buf, is_rgb888, is_data_3d);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "usb_ds_3ds_capture.hpp"
|
||||
#include "usb_is_device_acquisition.hpp"
|
||||
#include "cypress_nisetro_acquisition.hpp"
|
||||
#include "cypress_optimize_new_3ds_acquisition.hpp"
|
||||
#include "cypress_optimize_3ds_acquisition.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
@ -88,8 +88,8 @@ bool connect(bool print_failed, CaptureData* capture_data, FrontendData* fronten
|
||||
#ifdef USE_CYNI_USB
|
||||
list_devices_cyni_device(devices_list, no_access_list);
|
||||
#endif
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
list_devices_cyopn_device(devices_list, no_access_list);
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
list_devices_cyop_device(devices_list, no_access_list);
|
||||
#endif
|
||||
#ifdef USE_FTD3
|
||||
list_devices_ftd3(devices_list, no_access_list);
|
||||
@ -132,8 +132,8 @@ bool connect(bool print_failed, CaptureData* capture_data, FrontendData* fronten
|
||||
if((devices_list[chosen_device].cc_type == CAPTURE_CONN_CYPRESS_NISETRO) && (!cyni_device_connect_usb(print_failed, capture_data, &devices_list[chosen_device])))
|
||||
return false;
|
||||
#endif
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
if((devices_list[chosen_device].cc_type == CAPTURE_CONN_CYPRESS_NEW_OPTIMIZE) && (!cyopn_device_connect_usb(print_failed, capture_data, &devices_list[chosen_device])))
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
if((devices_list[chosen_device].cc_type == CAPTURE_CONN_CYPRESS_OPTIMIZE) && (!cyop_device_connect_usb(print_failed, capture_data, &devices_list[chosen_device])))
|
||||
return false;
|
||||
#endif
|
||||
#ifdef USE_FTD3
|
||||
@ -176,9 +176,9 @@ void captureCall(CaptureData* capture_data) {
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_NISETRO)
|
||||
cyni_device_acquisition_main_loop(capture_data);
|
||||
#endif
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_NEW_OPTIMIZE)
|
||||
cyopn_device_acquisition_main_loop(capture_data);
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_OPTIMIZE)
|
||||
cyop_device_acquisition_main_loop(capture_data);
|
||||
#endif
|
||||
#ifdef USE_FTD3
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_FTD3)
|
||||
@ -210,9 +210,9 @@ void captureCall(CaptureData* capture_data) {
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_NISETRO)
|
||||
usb_cyni_device_acquisition_cleanup(capture_data);
|
||||
#endif
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_NEW_OPTIMIZE)
|
||||
usb_cyopn_device_acquisition_cleanup(capture_data);
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_OPTIMIZE)
|
||||
usb_cyop_device_acquisition_cleanup(capture_data);
|
||||
#endif
|
||||
#ifdef USE_FTD3
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_FTD3)
|
||||
@ -241,8 +241,8 @@ void captureCall(CaptureData* capture_data) {
|
||||
uint64_t get_audio_n_samples(CaptureData* capture_data, CaptureDataSingleBuffer* data_buffer) {
|
||||
if(!capture_data->status.device.has_audio)
|
||||
return 0;
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_NEW_OPTIMIZE)
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_OPTIMIZE)
|
||||
return -1;
|
||||
#endif
|
||||
uint64_t n_samples = (data_buffer->read - get_video_in_size(capture_data, data_buffer->is_3d, data_buffer->buffer_video_data_type)) / 2;
|
||||
@ -259,9 +259,9 @@ uint64_t get_video_in_size(CaptureData* capture_data, bool is_3d, InputVideoData
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_NISETRO)
|
||||
return cyni_device_get_video_in_size(capture_data);
|
||||
#endif
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_NEW_OPTIMIZE)
|
||||
return cyopn_device_get_video_in_size(capture_data, is_3d, video_data_type);
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_CYPRESS_OPTIMIZE)
|
||||
return cyop_device_get_video_in_size(capture_data, is_3d, video_data_type);
|
||||
#endif
|
||||
#ifdef USE_FTD3
|
||||
if(capture_data->status.device.cc_type == CAPTURE_CONN_FTD3)
|
||||
@ -364,8 +364,8 @@ void capture_init() {
|
||||
#ifdef USE_CYNI_USB
|
||||
usb_cyni_device_init();
|
||||
#endif
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
usb_cyopn_device_init();
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
usb_cyop_device_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -382,7 +382,7 @@ void capture_close() {
|
||||
#ifdef USE_CYNI_USB
|
||||
usb_cyni_device_close();
|
||||
#endif
|
||||
#ifdef USE_CYPRESS_NEW_OPTIMIZE
|
||||
usb_cyopn_device_close();
|
||||
#ifdef USE_CYPRESS_OPTIMIZE
|
||||
usb_cyop_device_close();
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user