mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2026-09-11 01:55:18 -05:00
Base Partner CTR commit with cypress shared
This commit is contained in:
@@ -10,9 +10,18 @@
|
||||
|
||||
typedef void (*cy_async_callback_function)(void* user_data, int transfer_length, int transfer_status);
|
||||
typedef void (*cy_error_function)(void* user_data, int error);
|
||||
typedef std::string (*cy_get_serial_function)(const void* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id);
|
||||
typedef CaptureDevice (*cy_create_device_function)(const void* usb_device_desc, std::string serial, std::string path);
|
||||
|
||||
struct cy_device_device_handlers {
|
||||
libusb_device_handle* usb_handle;
|
||||
void* read_handle;
|
||||
void* write_handle;
|
||||
void* mutex;
|
||||
std::string path;
|
||||
};
|
||||
|
||||
typedef std::string (*cy_get_serial_function)(cy_device_device_handlers* handlers, const void* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id);
|
||||
|
||||
struct cy_async_callback_data {
|
||||
cy_async_callback_function function;
|
||||
cy_error_function error_function;
|
||||
@@ -48,34 +57,27 @@ struct cy_device_usb_device {
|
||||
bool do_pipe_clear_reset;
|
||||
int alt_interface;
|
||||
const void* full_data;
|
||||
bool get_serial_requires_setup;
|
||||
cy_get_serial_function get_serial_fn;
|
||||
cy_create_device_function create_device_fn;
|
||||
uint16_t bcd_device_mask;
|
||||
uint16_t bcd_device_wanted_value;
|
||||
};
|
||||
|
||||
struct cy_device_device_handlers {
|
||||
libusb_device_handle* usb_handle;
|
||||
void* read_handle;
|
||||
void* write_handle;
|
||||
void* mutex;
|
||||
std::string path;
|
||||
};
|
||||
|
||||
// Helper methods
|
||||
CaptureDevice cypress_create_device(const cy_device_usb_device* usb_device_desc, std::string serial, std::string path = "");
|
||||
std::string cypress_get_serial(const cy_device_usb_device* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id);
|
||||
void cypress_insert_device(std::vector<CaptureDevice>& devices_list, const cy_device_usb_device* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id, std::string path = "");
|
||||
std::string cypress_get_serial(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id);
|
||||
void cypress_insert_device(std::vector<CaptureDevice>& devices_list, const cy_device_usb_device* usb_device_desc, std::string real_serial, std::string path = "");
|
||||
|
||||
int cypress_ctrl_in_transfer(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, uint8_t request, uint16_t value, uint16_t index, int* transferred);
|
||||
int cypress_ctrl_out_transfer(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, uint8_t request, uint16_t value, uint16_t index, int* transferred);
|
||||
int cypress_bulk_in_transfer(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int cypress_bulk_in_async(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t *buf, int length, cy_async_callback_data* cb_data);
|
||||
int cypress_ctrl_bulk_in_transfer(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int cypress_ctrl_bulk_out_transfer(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, const uint8_t* buf, int length, int* transferred);
|
||||
int cypress_ctrl_bulk_in_transfer(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred, int chosen_endpoint = -1);
|
||||
int cypress_ctrl_bulk_out_transfer(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, const uint8_t* buf, int length, int* transferred, int chosen_endpoint = -1);
|
||||
void cypress_pipe_reset_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc);
|
||||
void cypress_pipe_reset_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc);
|
||||
void cypress_pipe_reset_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc);
|
||||
void cypress_pipe_reset_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, int chosen_endpoint = -1);
|
||||
void cypress_pipe_reset_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, int chosen_endpoint = -1);
|
||||
void CypressSetMaxTransferSize(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, size_t new_max_transfer_size);
|
||||
void CypressCloseAsyncRead(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, cy_async_callback_data* cb_data);
|
||||
void CypressSetupCypressDeviceAsyncThread(cy_device_device_handlers* handlers, std::vector<cy_async_callback_data*> &cb_data_vector, std::thread* thread_ptr, bool* keep_going);
|
||||
|
||||
@@ -16,11 +16,11 @@ void cypress_driver_end_connection(cy_device_device_handlers* handlers);
|
||||
int cypress_driver_ctrl_transfer_in(cy_device_device_handlers* handlers, uint8_t* buffer, size_t inner_size, uint16_t value, uint16_t index, uint16_t request_code, int* num_read);
|
||||
int cypress_driver_ctrl_transfer_out(cy_device_device_handlers* handlers, uint8_t* buffer, size_t inner_size, uint16_t value, uint16_t index, uint16_t request_code, int* num_read);
|
||||
int cypress_driver_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int cypress_driver_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int cypress_driver_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int cypress_driver_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred, int chosen_endpoint = -1);
|
||||
int cypress_driver_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred, int chosen_endpoint = -1);
|
||||
void cypress_driver_pipe_reset_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc);
|
||||
void cypress_driver_pipe_reset_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc);
|
||||
void cypress_driver_pipe_reset_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc);
|
||||
void cypress_driver_pipe_reset_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, int chosen_endpoint = -1);
|
||||
void cypress_driver_pipe_reset_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, int chosen_endpoint = -1);
|
||||
int cypress_driver_async_in_start(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, cy_async_callback_data* cb_data);
|
||||
void cypress_driver_start_thread(std::thread* thread_ptr, bool* usb_thread_run, std::vector<cy_async_callback_data*> &cb_data_vector, cy_device_device_handlers* handlers);
|
||||
void cypress_driver_close_thread(std::thread* thread_ptr, bool* usb_thread_run, std::vector<cy_async_callback_data*> cb_data_vector);
|
||||
|
||||
@@ -10,11 +10,11 @@ cy_device_device_handlers* cypress_libusb_serial_reconnection(const cy_device_us
|
||||
void cypress_libusb_find_used_serial(const cy_device_usb_device* usb_device_desc, bool* found, size_t num_free_fw_ids, int &curr_serial_extra_id);
|
||||
void cypress_libusb_end_connection(cy_device_device_handlers* handlers, const cy_device_usb_device* device_desc, bool interface_claimed);
|
||||
int cypress_libusb_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int cypress_libusb_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int cypress_libusb_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int cypress_libusb_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred, int chosen_endpoint = -1);
|
||||
int cypress_libusb_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred, int chosen_endpoint = -1);
|
||||
void cypress_libusb_pipe_reset_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc);
|
||||
void cypress_libusb_pipe_reset_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc);
|
||||
void cypress_libusb_pipe_reset_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc);
|
||||
void cypress_libusb_pipe_reset_ctrl_bulk_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, int chosen_endpoint = -1);
|
||||
void cypress_libusb_pipe_reset_ctrl_bulk_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, int chosen_endpoint = -1);
|
||||
int cypress_libusb_ctrl_in(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, uint8_t request, uint16_t value, uint16_t index, int* transferred);
|
||||
int cypress_libusb_ctrl_out(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, uint8_t request, uint16_t value, uint16_t index, int* transferred);
|
||||
int cypress_libusb_async_in_start(cy_device_device_handlers* handlers, const cy_device_usb_device* usb_device_desc, uint8_t* buf, int length, cy_async_callback_data* cb_data);
|
||||
|
||||
@@ -100,7 +100,7 @@ int StopUsbCaptureDma(is_device_device_handlers* handlers, const is_device_usb_d
|
||||
int SetForwardFrameCount(is_device_device_handlers* handlers, uint16_t count, const is_device_usb_device* device_desc);
|
||||
int SetForwardFramePermanent(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int GetFrameCounter(is_device_device_handlers* handlers, uint16_t* out, const is_device_usb_device* device_desc);
|
||||
int GetDeviceSerial(is_device_device_handlers* handlers, uint8_t* buf, const is_device_usb_device* device_desc);
|
||||
int GetIsDeviceSerial(is_device_device_handlers* handlers, uint8_t* buf, const is_device_usb_device* device_desc);
|
||||
int UpdateFrameForwardConfig(is_device_device_handlers* handlers, is_device_forward_config_values_colors colors, is_device_forward_config_values_screens screens, is_device_forward_config_values_rate rate, const is_device_usb_device* device_desc);
|
||||
int UpdateFrameForwardEnable(is_device_device_handlers* handlers, bool enable, bool restart, const is_device_usb_device* device_desc);
|
||||
int ReadLidState(is_device_device_handlers* handlers, bool* out, const is_device_usb_device* device_desc);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "cypress_shared_communications.hpp"
|
||||
#include "cypress_nisetro_communications.hpp"
|
||||
|
||||
std::string cypress_nisetro_get_serial(const void* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id);
|
||||
std::string cypress_nisetro_get_serial(cy_device_device_handlers* handlers, const void* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id);
|
||||
CaptureDevice cypress_nisetro_create_device(const void* usb_device_desc, std::string serial, std::string path);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#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);
|
||||
std::string cypress_optimize_3ds_get_serial(cy_device_device_handlers* handlers, 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,20 @@
|
||||
#ifndef __CYPRESS_PARTNER_CTR_ACQUISITION_HPP
|
||||
#define __CYPRESS_PARTNER_CTR_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_cypart_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan);
|
||||
bool cypart_device_connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
|
||||
uint64_t cypart_device_get_video_in_size(CaptureStatus* status);
|
||||
uint64_t cypart_device_get_video_in_size(CaptureData* capture_data);
|
||||
void cypart_device_acquisition_main_loop(CaptureData* capture_data);
|
||||
void usb_cypart_device_acquisition_cleanup(CaptureData* capture_data);
|
||||
void usb_cypart_device_init();
|
||||
void usb_cypart_device_close();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef __CYPRESS_PARTNER_CTR_ACQUISITION_GENERAL_HPP
|
||||
#define __CYPRESS_PARTNER_CTR_ACQUISITION_GENERAL_HPP
|
||||
|
||||
#include "cypress_shared_communications.hpp"
|
||||
#include "cypress_partner_ctr_communications.hpp"
|
||||
|
||||
std::string cypress_partner_ctr_get_serial(cy_device_device_handlers* handlers, const void* usb_device_desc, std::string serial, uint16_t bcd_device, int& curr_serial_extra_id);
|
||||
CaptureDevice cypress_partner_ctr_create_device(const void* usb_device_desc, std::string serial, std::string path);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,31 @@
|
||||
#ifndef __CYPRESS_PARTNER_CTR_DEVICE_COMMUNICATIONS_HPP
|
||||
#define __CYPRESS_PARTNER_CTR_DEVICE_COMMUNICATIONS_HPP
|
||||
|
||||
#include <libusb.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include "utils.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
#include "cypress_shared_communications.hpp"
|
||||
|
||||
struct cypart_device_usb_device {
|
||||
std::string name;
|
||||
std::string long_name;
|
||||
InputVideoDataType video_data_type;
|
||||
PossibleCaptureDevices index_in_allowed_scan;
|
||||
int ep_ctrl_serial_io_pipe;
|
||||
cy_device_usb_device usb_device_info;
|
||||
};
|
||||
|
||||
int GetNumCyPartnerCTRDeviceDesc(void);
|
||||
const cypart_device_usb_device* GetCyPartnerCTRDeviceDesc(int index);
|
||||
const cy_device_usb_device* get_cy_usb_info(const cypart_device_usb_device* usb_device_desc);
|
||||
std::string read_serial_ctr_capture(cy_device_device_handlers* handlers, const cypart_device_usb_device* device);
|
||||
int capture_start(cy_device_device_handlers* handlers, const cypart_device_usb_device* device);
|
||||
int StartCaptureDma(cy_device_device_handlers* handlers, const cypart_device_usb_device* device);
|
||||
int capture_end(cy_device_device_handlers* handlers, const cypart_device_usb_device* device);
|
||||
int ReadFrame(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cypart_device_usb_device* device_desc);
|
||||
int ReadFrameAsync(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cypart_device_usb_device* device_desc, cy_async_callback_data* cb_data);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user