mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2025-06-18 16:45:39 -04:00
Add mask based filtering for cypress devices
This commit is contained in:
parent
cbd0d9d77a
commit
dae56b1989
Binary file not shown.
Binary file not shown.
@ -50,8 +50,8 @@ struct cy_device_usb_device {
|
|||||||
const void* full_data;
|
const void* full_data;
|
||||||
cy_get_serial_function get_serial_fn;
|
cy_get_serial_function get_serial_fn;
|
||||||
cy_create_device_function create_device_fn;
|
cy_create_device_function create_device_fn;
|
||||||
bool filter_for_product;
|
uint16_t bcd_device_mask;
|
||||||
std::string wanted_product_str;
|
uint16_t bcd_device_wanted_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cy_device_device_handlers {
|
struct cy_device_device_handlers {
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
#define FTD2_INTRA_PACKET_HEADER_SIZE 2
|
#define FTD2_INTRA_PACKET_HEADER_SIZE 2
|
||||||
#define MAX_PACKET_SIZE_FTD2 (MAX_PACKET_SIZE_USB2 - FTD2_INTRA_PACKET_HEADER_SIZE)
|
#define MAX_PACKET_SIZE_FTD2 (MAX_PACKET_SIZE_USB2 - FTD2_INTRA_PACKET_HEADER_SIZE)
|
||||||
|
|
||||||
#define OPTIMIZE_NEW_3DS_ALTERNATIVE_PRODUCT_NAME "N3DSCC"
|
|
||||||
|
|
||||||
#define OPTIMIZE_NEW_3DS_AUDIO_BUFFER_MAX_SIZE 0x200
|
#define OPTIMIZE_NEW_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_NEW_OPTIMIZE };
|
||||||
|
@ -333,7 +333,7 @@ static std::string cypress_driver_get_device_path(HDEVINFO DeviceInfoSet, SP_DEV
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cypress_driver_get_device_pid_vid_ids(HANDLE handle, uint16_t& out_vid, uint16_t& out_pid, UCHAR &imanufacturer, UCHAR &iproduct, UCHAR &iserial, USHORT &bcdDevice) {
|
static bool cypress_driver_get_device_pid_vid_ids(HANDLE handle, uint16_t& out_vid, uint16_t& out_pid, UCHAR &imanufacturer, UCHAR &iserial, USHORT &bcdDevice) {
|
||||||
if (handle == INVALID_HANDLE_VALUE)
|
if (handle == INVALID_HANDLE_VALUE)
|
||||||
return false;
|
return false;
|
||||||
USB_DEVICE_DESCRIPTOR out_descriptor;
|
USB_DEVICE_DESCRIPTOR out_descriptor;
|
||||||
@ -345,27 +345,30 @@ static bool cypress_driver_get_device_pid_vid_ids(HANDLE handle, uint16_t& out_v
|
|||||||
out_vid = out_descriptor.idVendor;
|
out_vid = out_descriptor.idVendor;
|
||||||
out_pid = out_descriptor.idProduct;
|
out_pid = out_descriptor.idProduct;
|
||||||
imanufacturer = out_descriptor.iManufacturer;
|
imanufacturer = out_descriptor.iManufacturer;
|
||||||
iproduct = out_descriptor.iProduct;
|
//iproduct = out_descriptor.iProduct;
|
||||||
iserial = out_descriptor.iSerialNumber;
|
iserial = out_descriptor.iSerialNumber;
|
||||||
bcdDevice = out_descriptor.bcdDevice;
|
bcdDevice = out_descriptor.bcdDevice;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool cypress_driver_get_device_pid_vid_manufacturer_product_serial_number(std::string path, uint16_t& out_vid, uint16_t& out_pid, std::string &manufacturer, std::string &product, std::string &serial, uint16_t& bcd_device) {
|
static bool cypress_driver_get_device_pid_vid_imanufacturer_iserial_number(std::string path, uint16_t& out_vid, uint16_t& out_pid, UCHAR &imanufacturer, UCHAR &iserial, USHORT &bcd_device) {
|
||||||
HANDLE handle = CreateFile(path.c_str(), (GENERIC_READ | GENERIC_WRITE), (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, 0, NULL);
|
HANDLE handle = CreateFile(path.c_str(), (GENERIC_READ | GENERIC_WRITE), (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, 0, NULL);
|
||||||
if (handle == INVALID_HANDLE_VALUE)
|
if (handle == INVALID_HANDLE_VALUE)
|
||||||
return false;
|
return false;
|
||||||
UCHAR imanufacturer;
|
bool result = cypress_driver_get_device_pid_vid_ids(handle, out_vid, out_pid, imanufacturer, iserial, bcd_device);
|
||||||
UCHAR iproduct;
|
CloseHandle(handle);
|
||||||
UCHAR iserial;
|
if(!result)
|
||||||
if(!cypress_driver_get_device_pid_vid_ids(handle, out_vid, out_pid, imanufacturer, iproduct, iserial, bcd_device)) {
|
return false;
|
||||||
CloseHandle(handle);
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool cypress_driver_get_device_string_manufacturer_product_serial_number(std::string path, std::string &manufacturer, std::string &serial, UCHAR &imanufacturer, UCHAR &iserial) {
|
||||||
|
HANDLE handle = CreateFile(path.c_str(), (GENERIC_READ | GENERIC_WRITE), (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, 0, NULL);
|
||||||
|
if (handle == INVALID_HANDLE_VALUE)
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
USHORT language = 0;
|
USHORT language = 0;
|
||||||
cypress_driver_get_string_language_info(handle, language);
|
cypress_driver_get_string_language_info(handle, language);
|
||||||
cypress_driver_get_string_info(handle, imanufacturer, language, manufacturer);
|
cypress_driver_get_string_info(handle, imanufacturer, language, manufacturer);
|
||||||
cypress_driver_get_string_info(handle, iproduct, language, product);
|
|
||||||
cypress_driver_get_string_info(handle, iserial, language, serial);
|
cypress_driver_get_string_info(handle, iserial, language, serial);
|
||||||
CloseHandle(handle);
|
CloseHandle(handle);
|
||||||
return true;
|
return true;
|
||||||
@ -461,15 +464,20 @@ void cypress_driver_list_devices(std::vector<CaptureDevice> &devices_list, bool*
|
|||||||
continue;
|
continue;
|
||||||
uint16_t vid = 0;
|
uint16_t vid = 0;
|
||||||
uint16_t pid = 0;
|
uint16_t pid = 0;
|
||||||
uint16_t bcd_device = 0;
|
USHORT bcd_device = 0;
|
||||||
std::string manufacturer;
|
UCHAR imanufacturer = 0;
|
||||||
std::string product;
|
UCHAR iserial = 0;
|
||||||
std::string serial;
|
if(!cypress_driver_get_device_pid_vid_imanufacturer_iserial_number(path, vid, pid, imanufacturer, iserial, bcd_device))
|
||||||
if(!cypress_driver_get_device_pid_vid_manufacturer_product_serial_number(path, vid, pid, manufacturer, product, serial, bcd_device))
|
|
||||||
continue;
|
continue;
|
||||||
for (int j = 0; j < device_descriptions.size(); j++) {
|
for (int j = 0; j < device_descriptions.size(); j++) {
|
||||||
const cy_device_usb_device* usb_device_desc = device_descriptions[j];
|
const cy_device_usb_device* usb_device_desc = device_descriptions[j];
|
||||||
if(not_supported_elems[j] && (usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && ((!usb_device_desc->filter_for_product) || (usb_device_desc->wanted_product_str == product))) {
|
uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value;
|
||||||
|
if(not_supported_elems[j] && (usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && (masked_wanted_bcd_device == (bcd_device & usb_device_desc->bcd_device_mask))) {
|
||||||
|
std::string manufacturer;
|
||||||
|
std::string serial;
|
||||||
|
bool result = cypress_driver_get_device_string_manufacturer_product_serial_number(path, manufacturer, serial, imanufacturer, iserial);
|
||||||
|
if(!result)
|
||||||
|
continue;
|
||||||
cy_device_device_handlers handlers;
|
cy_device_device_handlers handlers;
|
||||||
bool result_conn_check = cypress_driver_setup_connection(&handlers, path, usb_device_desc->do_pipe_clear_reset);
|
bool result_conn_check = cypress_driver_setup_connection(&handlers, path, usb_device_desc->do_pipe_clear_reset);
|
||||||
cypress_driver_end_connection(&handlers);
|
cypress_driver_end_connection(&handlers);
|
||||||
@ -501,6 +509,7 @@ cy_device_device_handlers* cypress_driver_find_by_serial_number(const cy_device_
|
|||||||
ZeroMemory(&DeviceInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA));
|
ZeroMemory(&DeviceInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA));
|
||||||
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value;
|
||||||
while(SetupDiEnumDeviceInterfaces(DeviceInfoSet, NULL, to_check_guid, i++, &DeviceInterfaceData)) {
|
while(SetupDiEnumDeviceInterfaces(DeviceInfoSet, NULL, to_check_guid, i++, &DeviceInterfaceData)) {
|
||||||
std::string path = cypress_driver_get_device_path(DeviceInfoSet, &DeviceInterfaceData);
|
std::string path = cypress_driver_get_device_path(DeviceInfoSet, &DeviceInterfaceData);
|
||||||
if (path == "")
|
if (path == "")
|
||||||
@ -508,13 +517,18 @@ cy_device_device_handlers* cypress_driver_find_by_serial_number(const cy_device_
|
|||||||
uint16_t vid = 0;
|
uint16_t vid = 0;
|
||||||
uint16_t pid = 0;
|
uint16_t pid = 0;
|
||||||
uint16_t bcd_device = 0;
|
uint16_t bcd_device = 0;
|
||||||
std::string manufacturer;
|
UCHAR imanufacturer = 0;
|
||||||
std::string product;
|
UCHAR iserial = 0;
|
||||||
std::string serial;
|
if(!cypress_driver_get_device_pid_vid_imanufacturer_iserial_number(path, vid, pid, imanufacturer, iserial, bcd_device))
|
||||||
if(!cypress_driver_get_device_pid_vid_manufacturer_product_serial_number(path, vid, pid, manufacturer, product, serial, bcd_device))
|
|
||||||
continue;
|
continue;
|
||||||
std::string read_serial = cypress_get_serial(usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
if((usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && (masked_wanted_bcd_device == (bcd_device & usb_device_desc->bcd_device_mask))) {
|
||||||
if((usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && (wanted_serial_number == read_serial) && ((!usb_device_desc->filter_for_product) || (usb_device_desc->wanted_product_str == product))) {
|
std::string manufacturer;
|
||||||
|
std::string serial;
|
||||||
|
if(!cypress_driver_get_device_string_manufacturer_product_serial_number(path, manufacturer, serial, imanufacturer, iserial))
|
||||||
|
continue;
|
||||||
|
std::string read_serial = cypress_get_serial(usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
||||||
|
if(wanted_serial_number != read_serial)
|
||||||
|
continue;
|
||||||
cy_device_device_handlers handlers;
|
cy_device_device_handlers handlers;
|
||||||
if(cypress_driver_setup_connection(&handlers, path, usb_device_desc->do_pipe_clear_reset)) {
|
if(cypress_driver_setup_connection(&handlers, path, usb_device_desc->do_pipe_clear_reset)) {
|
||||||
final_handlers = new cy_device_device_handlers;
|
final_handlers = new cy_device_device_handlers;
|
||||||
@ -634,6 +648,7 @@ void cypress_driver_find_used_serial(const cy_device_usb_device* usb_device_desc
|
|||||||
ZeroMemory(&DeviceInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA));
|
ZeroMemory(&DeviceInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA));
|
||||||
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value;
|
||||||
while(SetupDiEnumDeviceInterfaces(DeviceInfoSet, NULL, to_check_guid, i++, &DeviceInterfaceData)) {
|
while(SetupDiEnumDeviceInterfaces(DeviceInfoSet, NULL, to_check_guid, i++, &DeviceInterfaceData)) {
|
||||||
std::string path = cypress_driver_get_device_path(DeviceInfoSet, &DeviceInterfaceData);
|
std::string path = cypress_driver_get_device_path(DeviceInfoSet, &DeviceInterfaceData);
|
||||||
if (path == "")
|
if (path == "")
|
||||||
@ -641,13 +656,16 @@ void cypress_driver_find_used_serial(const cy_device_usb_device* usb_device_desc
|
|||||||
uint16_t vid = 0;
|
uint16_t vid = 0;
|
||||||
uint16_t pid = 0;
|
uint16_t pid = 0;
|
||||||
uint16_t bcd_device = 0;
|
uint16_t bcd_device = 0;
|
||||||
std::string manufacturer;
|
UCHAR imanufacturer = 0;
|
||||||
std::string product;
|
UCHAR iserial = 0;
|
||||||
std::string serial;
|
if(!cypress_driver_get_device_pid_vid_imanufacturer_iserial_number(path, vid, pid, imanufacturer, iserial, bcd_device))
|
||||||
if(!cypress_driver_get_device_pid_vid_manufacturer_product_serial_number(path, vid, pid, manufacturer, product, serial, bcd_device))
|
|
||||||
continue;
|
continue;
|
||||||
std::string read_serial = cypress_get_serial(usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
if((usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && (masked_wanted_bcd_device == (bcd_device & usb_device_desc->bcd_device_mask))) {
|
||||||
if((usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && ((!usb_device_desc->filter_for_product) || (usb_device_desc->wanted_product_str == product))) {
|
std::string manufacturer;
|
||||||
|
std::string serial;
|
||||||
|
if(!cypress_driver_get_device_string_manufacturer_product_serial_number(path, manufacturer, serial, imanufacturer, iserial))
|
||||||
|
continue;
|
||||||
|
std::string read_serial = cypress_get_serial(usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
||||||
try {
|
try {
|
||||||
int pos = std::stoi(read_serial);
|
int pos = std::stoi(read_serial);
|
||||||
if((pos < 0) || (pos >= num_free_fw_ids))
|
if((pos < 0) || (pos >= num_free_fw_ids))
|
||||||
|
@ -97,15 +97,12 @@ static bool cypress_libusb_setup_connection(libusb_device_handle* handle, const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void read_strings(libusb_device_handle *handle, libusb_device_descriptor *usb_descriptor, char* manufacturer, char* product, char* serial) {
|
static void read_strings(libusb_device_handle *handle, libusb_device_descriptor *usb_descriptor, char* manufacturer, char* serial) {
|
||||||
manufacturer[0] = 0;
|
manufacturer[0] = 0;
|
||||||
product[0] = 0;
|
|
||||||
serial[0] = 0;
|
serial[0] = 0;
|
||||||
libusb_get_string_descriptor_ascii(handle, usb_descriptor->iManufacturer, (uint8_t*)manufacturer, 0x100);
|
libusb_get_string_descriptor_ascii(handle, usb_descriptor->iManufacturer, (uint8_t*)manufacturer, 0x100);
|
||||||
libusb_get_string_descriptor_ascii(handle, usb_descriptor->iProduct, (uint8_t*)product, 0x100);
|
|
||||||
libusb_get_string_descriptor_ascii(handle, usb_descriptor->iSerialNumber, (uint8_t*)serial, 0x100);
|
libusb_get_string_descriptor_ascii(handle, usb_descriptor->iSerialNumber, (uint8_t*)serial, 0x100);
|
||||||
manufacturer[0xFF] = 0;
|
manufacturer[0xFF] = 0;
|
||||||
product[0xFF] = 0;
|
|
||||||
serial[0xFF] = 0;
|
serial[0xFF] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,18 +110,15 @@ static int cypress_libusb_insert_device(std::vector<CaptureDevice> &devices_list
|
|||||||
libusb_device_handle *handle = NULL;
|
libusb_device_handle *handle = NULL;
|
||||||
if((usb_descriptor->idVendor != usb_device_desc->vid) || (usb_descriptor->idProduct != usb_device_desc->pid))
|
if((usb_descriptor->idVendor != usb_device_desc->vid) || (usb_descriptor->idProduct != usb_device_desc->pid))
|
||||||
return LIBUSB_ERROR_NOT_FOUND;
|
return LIBUSB_ERROR_NOT_FOUND;
|
||||||
|
uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value;
|
||||||
|
if(masked_wanted_bcd_device != (usb_descriptor->bcdDevice & usb_device_desc->bcd_device_mask))
|
||||||
|
return LIBUSB_ERROR_NOT_FOUND;
|
||||||
int result = libusb_open(usb_device, &handle);
|
int result = libusb_open(usb_device, &handle);
|
||||||
if((result < 0) || (handle == NULL))
|
if((result < 0) || (handle == NULL))
|
||||||
return result;
|
return result;
|
||||||
char manufacturer[0x100];
|
char manufacturer[0x100];
|
||||||
char product[0x100];
|
|
||||||
char serial[0x100];
|
char serial[0x100];
|
||||||
read_strings(handle, usb_descriptor, manufacturer, product, serial);
|
read_strings(handle, usb_descriptor, manufacturer, serial);
|
||||||
std::string product_str = (std::string)product;
|
|
||||||
if(usb_device_desc->filter_for_product && (usb_device_desc->wanted_product_str != product_str)) {
|
|
||||||
libusb_close(handle);
|
|
||||||
return LIBUSB_ERROR_NOT_FOUND;
|
|
||||||
}
|
|
||||||
bool claimed = false;
|
bool claimed = false;
|
||||||
bool result_setup = cypress_libusb_setup_connection(handle, usb_device_desc, &claimed);
|
bool result_setup = cypress_libusb_setup_connection(handle, usb_device_desc, &claimed);
|
||||||
if(result_setup)
|
if(result_setup)
|
||||||
@ -150,18 +144,15 @@ cy_device_device_handlers* cypress_libusb_serial_reconnection(const cy_device_us
|
|||||||
continue;
|
continue;
|
||||||
if((usb_descriptor.idVendor != usb_device_desc->vid) || (usb_descriptor.idProduct != usb_device_desc->pid))
|
if((usb_descriptor.idVendor != usb_device_desc->vid) || (usb_descriptor.idProduct != usb_device_desc->pid))
|
||||||
continue;
|
continue;
|
||||||
|
uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value;
|
||||||
|
if(masked_wanted_bcd_device != (usb_descriptor.bcdDevice & usb_device_desc->bcd_device_mask))
|
||||||
|
continue;
|
||||||
result = libusb_open(usb_devices[i], &handlers.usb_handle);
|
result = libusb_open(usb_devices[i], &handlers.usb_handle);
|
||||||
if((result < 0) || (handlers.usb_handle == NULL))
|
if((result < 0) || (handlers.usb_handle == NULL))
|
||||||
continue;
|
continue;
|
||||||
char manufacturer[0x100];
|
char manufacturer[0x100];
|
||||||
char product[0x100];
|
|
||||||
char serial[0x100];
|
char serial[0x100];
|
||||||
read_strings(handlers.usb_handle, &usb_descriptor, manufacturer, product, serial);
|
read_strings(handlers.usb_handle, &usb_descriptor, manufacturer, serial);
|
||||||
std::string product_str = (std::string)product;
|
|
||||||
if(usb_device_desc->filter_for_product && (usb_device_desc->wanted_product_str != product_str)) {
|
|
||||||
libusb_close(handlers.usb_handle);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::string device_serial_number = cypress_get_serial(usb_device_desc, (std::string)(serial), usb_descriptor.bcdDevice, curr_serial_extra_id);
|
std::string device_serial_number = cypress_get_serial(usb_device_desc, (std::string)(serial), usb_descriptor.bcdDevice, curr_serial_extra_id);
|
||||||
bool claimed = false;
|
bool claimed = false;
|
||||||
if((wanted_serial_number == device_serial_number) && (cypress_libusb_setup_connection(handlers.usb_handle, usb_device_desc, &claimed))) {
|
if((wanted_serial_number == device_serial_number) && (cypress_libusb_setup_connection(handlers.usb_handle, usb_device_desc, &claimed))) {
|
||||||
@ -204,17 +195,16 @@ void cypress_libusb_find_used_serial(const cy_device_usb_device* usb_device_desc
|
|||||||
continue;
|
continue;
|
||||||
if((usb_descriptor.idVendor != usb_device_desc->vid) || (usb_descriptor.idProduct != usb_device_desc->pid))
|
if((usb_descriptor.idVendor != usb_device_desc->vid) || (usb_descriptor.idProduct != usb_device_desc->pid))
|
||||||
continue;
|
continue;
|
||||||
|
uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value;
|
||||||
|
if(masked_wanted_bcd_device != (usb_descriptor.bcdDevice & usb_device_desc->bcd_device_mask))
|
||||||
|
continue;
|
||||||
result = libusb_open(usb_devices[i], &handlers.usb_handle);
|
result = libusb_open(usb_devices[i], &handlers.usb_handle);
|
||||||
if(result || (handlers.usb_handle == NULL))
|
if(result || (handlers.usb_handle == NULL))
|
||||||
continue;
|
continue;
|
||||||
char manufacturer[0x100];
|
char manufacturer[0x100];
|
||||||
char product[0x100];
|
|
||||||
char serial[0x100];
|
char serial[0x100];
|
||||||
read_strings(handlers.usb_handle, &usb_descriptor, manufacturer, product, serial);
|
read_strings(handlers.usb_handle, &usb_descriptor, manufacturer, serial);
|
||||||
libusb_close(handlers.usb_handle);
|
libusb_close(handlers.usb_handle);
|
||||||
std::string product_str = (std::string)product;
|
|
||||||
if(usb_device_desc->filter_for_product && (usb_device_desc->wanted_product_str != product_str))
|
|
||||||
continue;
|
|
||||||
std::string device_serial_number = cypress_get_serial(usb_device_desc, (std::string)(serial), usb_descriptor.bcdDevice, curr_serial_extra_id);
|
std::string device_serial_number = cypress_get_serial(usb_device_desc, (std::string)(serial), usb_descriptor.bcdDevice, curr_serial_extra_id);
|
||||||
try {
|
try {
|
||||||
int pos = std::stoi(device_serial_number);
|
int pos = std::stoi(device_serial_number);
|
||||||
|
@ -30,8 +30,10 @@
|
|||||||
#define PIO_RESET 0x10
|
#define PIO_RESET 0x10
|
||||||
#define PIO_DIR 0x08
|
#define PIO_DIR 0x08
|
||||||
|
|
||||||
|
#define NISETRO_DS_WANTED_VALUE_BASE 0xFF00
|
||||||
|
|
||||||
static const cyni_device_usb_device cypress_fx2_generic_device = {
|
static const cyni_device_usb_device cypress_fx2_generic_device = {
|
||||||
.name = "EZ-USB FX2", .long_name = "EZ-USB FX2",
|
.name = "EZ-USB -> Nisetro DS", .long_name = "EZ-USB -> Nisetro DS",
|
||||||
.device_type = CYPRESS_NISETRO_BLANK_DEVICE,
|
.device_type = CYPRESS_NISETRO_BLANK_DEVICE,
|
||||||
.video_data_type = VIDEO_DATA_RGB,
|
.video_data_type = VIDEO_DATA_RGB,
|
||||||
.firmware_to_load = nisetro_ds_fw, .firmware_size = nisetro_ds_fw_len,
|
.firmware_to_load = nisetro_ds_fw, .firmware_size = nisetro_ds_fw_len,
|
||||||
@ -49,8 +51,8 @@ static const cyni_device_usb_device cypress_fx2_generic_device = {
|
|||||||
.full_data = &cypress_fx2_generic_device,
|
.full_data = &cypress_fx2_generic_device,
|
||||||
.get_serial_fn = cypress_nisetro_get_serial,
|
.get_serial_fn = cypress_nisetro_get_serial,
|
||||||
.create_device_fn = cypress_nisetro_create_device,
|
.create_device_fn = cypress_nisetro_create_device,
|
||||||
.filter_for_product = false,
|
.bcd_device_mask = 0x0000,
|
||||||
.wanted_product_str = ""
|
.bcd_device_wanted_value = 0x0000
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -73,8 +75,8 @@ static const cyni_device_usb_device cypress_fx2_nisetro_ds_device = {
|
|||||||
.full_data = &cypress_fx2_nisetro_ds_device,
|
.full_data = &cypress_fx2_nisetro_ds_device,
|
||||||
.get_serial_fn = cypress_nisetro_get_serial,
|
.get_serial_fn = cypress_nisetro_get_serial,
|
||||||
.create_device_fn = cypress_nisetro_create_device,
|
.create_device_fn = cypress_nisetro_create_device,
|
||||||
.filter_for_product = false,
|
.bcd_device_mask = 0xFF00,
|
||||||
.wanted_product_str = ""
|
.bcd_device_wanted_value = NISETRO_DS_WANTED_VALUE_BASE
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -124,7 +126,7 @@ bool load_firmware(cy_device_device_handlers* handlers, const cyni_device_usb_de
|
|||||||
int num_patches = read_le16(fw_data, 1);
|
int num_patches = read_le16(fw_data, 1);
|
||||||
for(int i = 0; i < num_patches; i++) {
|
for(int i = 0; i < num_patches; i++) {
|
||||||
int pos_patch = read_le16(fw_data, 2 + i);
|
int pos_patch = read_le16(fw_data, 2 + i);
|
||||||
write_le16(fw_data + pos_patch, patch_id | 0xFF00);
|
write_le16(fw_data + pos_patch, patch_id | NISETRO_DS_WANTED_VALUE_BASE);
|
||||||
}
|
}
|
||||||
uint8_t buffer[0x8000];
|
uint8_t buffer[0x8000];
|
||||||
buffer[0] = 1;
|
buffer[0] = 1;
|
||||||
|
@ -18,16 +18,10 @@
|
|||||||
// Such an action is allowed under EU law.
|
// Such an action is allowed under EU law.
|
||||||
// No reverse engineering of the original software was done to create this.
|
// No reverse engineering of the original software was done to create this.
|
||||||
|
|
||||||
#define NUM_CAPTURE_RECEIVED_DATA_BUFFERS NUM_CONCURRENT_DATA_BUFFER_WRITERS
|
#define SINGLE_RING_BUFFER_SLICE_SIZE 0x10000
|
||||||
|
#define NUM_TOTAL_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS 64
|
||||||
|
|
||||||
// The driver only seems to support up to 4 concurrent reads. Not more...
|
#define NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS 4
|
||||||
#ifdef NUM_CAPTURE_RECEIVED_DATA_BUFFERS
|
|
||||||
#if NUM_CAPTURE_RECEIVED_DATA_BUFFERS > 4
|
|
||||||
#define NUM_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS 4
|
|
||||||
#else
|
|
||||||
#define NUM_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS NUM_CAPTURE_RECEIVED_DATA_BUFFERS
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAX_TIME_WAIT 1.0
|
#define MAX_TIME_WAIT 1.0
|
||||||
|
|
||||||
@ -39,6 +33,12 @@ struct CypressOptimizeNew3DSDeviceCaptureReceivedData {
|
|||||||
SharedConsumerMutex* is_buffer_free_shared_mutex;
|
SharedConsumerMutex* is_buffer_free_shared_mutex;
|
||||||
int* status;
|
int* status;
|
||||||
uint32_t* last_index;
|
uint32_t* last_index;
|
||||||
|
uint8_t* buffer_slice;
|
||||||
|
int buffer_slice_index;
|
||||||
|
int* last_used_buffer_slice_index;
|
||||||
|
size_t* last_used_buffer_slice_pos;
|
||||||
|
bool* is_buffer_slice_in_use;
|
||||||
|
bool* is_buffer_slice_ready;
|
||||||
CaptureData* capture_data;
|
CaptureData* capture_data;
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock>* clock_start;
|
std::chrono::time_point<std::chrono::high_resolution_clock>* clock_start;
|
||||||
cy_async_callback_data cb_data;
|
cy_async_callback_data cb_data;
|
||||||
@ -242,7 +242,7 @@ static void cypress_device_read_frame_cb(void* user_data, int transfer_length, i
|
|||||||
|
|
||||||
static int cypress_device_get_num_free_buffers(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
static int cypress_device_get_num_free_buffers(CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||||
int num_free = 0;
|
int num_free = 0;
|
||||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++)
|
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||||
if(!cypress_device_capture_recv_data[i].in_use)
|
if(!cypress_device_capture_recv_data[i].in_use)
|
||||||
num_free += 1;
|
num_free += 1;
|
||||||
return num_free;
|
return num_free;
|
||||||
@ -254,7 +254,7 @@ static void close_all_reads_error(CaptureData* capture_data, CypressOptimizeNew3
|
|||||||
if(get_cypress_device_status(cypress_device_capture_recv_data) < 0) {
|
if(get_cypress_device_status(cypress_device_capture_recv_data) < 0) {
|
||||||
if(!async_read_closed) {
|
if(!async_read_closed) {
|
||||||
if(handlers->usb_handle) {
|
if(handlers->usb_handle) {
|
||||||
for (int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++)
|
for (int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||||
CypressCloseAsyncRead(handlers, get_cy_usb_info(usb_device_desc), &cypress_device_capture_recv_data[i].cb_data);
|
CypressCloseAsyncRead(handlers, get_cy_usb_info(usb_device_desc), &cypress_device_capture_recv_data[i].cb_data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -284,7 +284,7 @@ static void wait_all_cypress_device_buffers_free(CaptureData* capture_data, Cypr
|
|||||||
bool async_read_closed = false;
|
bool async_read_closed = false;
|
||||||
close_all_reads_error(capture_data, cypress_device_capture_recv_data, async_read_closed);
|
close_all_reads_error(capture_data, cypress_device_capture_recv_data, async_read_closed);
|
||||||
const auto start_time = std::chrono::high_resolution_clock::now();
|
const auto start_time = std::chrono::high_resolution_clock::now();
|
||||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++)
|
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||||
while(cypress_device_capture_recv_data[i].in_use) {
|
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);
|
error_too_much_time_passed(capture_data, cypress_device_capture_recv_data, async_read_closed, start_time);
|
||||||
cypress_device_capture_recv_data[i].is_buffer_free_shared_mutex->specific_timed_lock(i);
|
cypress_device_capture_recv_data[i].is_buffer_free_shared_mutex->specific_timed_lock(i);
|
||||||
@ -296,7 +296,7 @@ static void wait_one_cypress_device_buffer_free(CaptureData* capture_data, Cypre
|
|||||||
bool done = false;
|
bool done = false;
|
||||||
const auto start_time = std::chrono::high_resolution_clock::now();
|
const auto start_time = std::chrono::high_resolution_clock::now();
|
||||||
while(!done) {
|
while(!done) {
|
||||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++) {
|
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) {
|
||||||
if(!cypress_device_capture_recv_data[i].in_use)
|
if(!cypress_device_capture_recv_data[i].in_use)
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
@ -330,14 +330,14 @@ 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) {
|
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_BUFFERS;
|
return cypress_device_get_num_free_buffers(cypress_device_capture_recv_data) == NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_get_free_buffer(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
static CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_get_free_buffer(CaptureData* capture_data, CypressOptimizeNew3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data) {
|
||||||
wait_one_cypress_device_buffer_free(capture_data, 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)
|
if(get_cypress_device_status(cypress_device_capture_recv_data) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++)
|
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++)
|
||||||
if(!cypress_device_capture_recv_data[i].in_use) {
|
if(!cypress_device_capture_recv_data[i].in_use) {
|
||||||
cypress_device_capture_recv_data[i].is_buffer_free_shared_mutex->specific_try_lock(i);
|
cypress_device_capture_recv_data[i].is_buffer_free_shared_mutex->specific_try_lock(i);
|
||||||
cypress_device_capture_recv_data[i].in_use = true;
|
cypress_device_capture_recv_data[i].in_use = true;
|
||||||
@ -378,7 +378,7 @@ static bool cyopn_device_acquisition_loop(CaptureData* capture_data, CypressOpti
|
|||||||
}
|
}
|
||||||
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), cyopn_device_get_video_in_size(stored_is_3d, stored_video_data_type));
|
||||||
auto clock_last_reset = std::chrono::high_resolution_clock::now();
|
auto clock_last_reset = std::chrono::high_resolution_clock::now();
|
||||||
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS; i++) {
|
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);
|
CypressOptimizeNew3DSDeviceCaptureReceivedData* 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);
|
ret = cypress_device_read_frame_request(capture_data, chosen_buffer, index++, stored_is_3d, stored_video_data_type);
|
||||||
if(ret < 0) {
|
if(ret < 0) {
|
||||||
@ -422,12 +422,12 @@ void cyopn_device_acquisition_main_loop(CaptureData* capture_data) {
|
|||||||
uint32_t last_index = -1;
|
uint32_t last_index = -1;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
std::vector<cy_async_callback_data*> cb_queue;
|
std::vector<cy_async_callback_data*> cb_queue;
|
||||||
SharedConsumerMutex is_buffer_free_shared_mutex(NUM_OPTIMIZE_NEW_3DS_CYPRESS_BUFFERS);
|
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_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_BUFFERS);
|
SharedConsumerMutex is_transfer_data_ready_shared_mutex(NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS);
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> clock_start = std::chrono::high_resolution_clock::now();
|
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_BUFFERS];
|
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_BUFFERS; i++) {
|
for(int i = 0; i < NUM_OPTIMIZE_NEW_3DS_CYPRESS_CONCURRENTLY_RUNNING_BUFFERS; i++) {
|
||||||
cypress_device_capture_recv_data[i].in_use = false;
|
cypress_device_capture_recv_data[i].in_use = false;
|
||||||
cypress_device_capture_recv_data[i].index = i;
|
cypress_device_capture_recv_data[i].index = i;
|
||||||
cypress_device_capture_recv_data[i].capture_data = capture_data;
|
cypress_device_capture_recv_data[i].capture_data = capture_data;
|
||||||
|
@ -24,8 +24,10 @@
|
|||||||
#define CYPRESS_BASE_USB_PACKET_LIMIT 64
|
#define CYPRESS_BASE_USB_PACKET_LIMIT 64
|
||||||
#define CYPRESS_OPTIMIZE_NEW_3DS_USB_PACKET_LIMIT 512
|
#define CYPRESS_OPTIMIZE_NEW_3DS_USB_PACKET_LIMIT 512
|
||||||
|
|
||||||
|
#define OPTIMIZE_NEW_3DS_WANTED_VALUE_BASE 0xFE00
|
||||||
|
|
||||||
static const cyopn_device_usb_device cypress_optimize_new_3ds_generic_device = {
|
static const cyopn_device_usb_device cypress_optimize_new_3ds_generic_device = {
|
||||||
.name = "EZ-USB Optimize New 3DS", .long_name = "EZ-USB Optimize New 3DS",
|
.name = "EZ-USB -> Optimize New 3DS", .long_name = "EZ-USB -> Optimize New 3DS",
|
||||||
.device_type = CYPRESS_OPTIMIZE_NEW_3DS_BLANK_DEVICE,
|
.device_type = CYPRESS_OPTIMIZE_NEW_3DS_BLANK_DEVICE,
|
||||||
.firmware_to_load = optimize_new_3ds_fw, .firmware_size = optimize_new_3ds_fw_len,
|
.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 = NULL, .fpga_pl_565_size = 0,
|
||||||
@ -46,8 +48,8 @@ static const cyopn_device_usb_device cypress_optimize_new_3ds_generic_device = {
|
|||||||
.full_data = &cypress_optimize_new_3ds_generic_device,
|
.full_data = &cypress_optimize_new_3ds_generic_device,
|
||||||
.get_serial_fn = cypress_optimize_new_3ds_get_serial,
|
.get_serial_fn = cypress_optimize_new_3ds_get_serial,
|
||||||
.create_device_fn = cypress_optimize_new_3ds_create_device,
|
.create_device_fn = cypress_optimize_new_3ds_create_device,
|
||||||
.filter_for_product = false,
|
.bcd_device_mask = 0x0000,
|
||||||
.wanted_product_str = ""
|
.bcd_device_wanted_value = 0x0000
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ static const cyopn_device_usb_device cypress_optimize_new_3ds_instantiated_devic
|
|||||||
.next_device = CYPRESS_OPTIMIZE_NEW_3DS_INSTANTIATED_DEVICE,
|
.next_device = CYPRESS_OPTIMIZE_NEW_3DS_INSTANTIATED_DEVICE,
|
||||||
.has_bcd_device_serial = true,
|
.has_bcd_device_serial = true,
|
||||||
.usb_device_info = {
|
.usb_device_info = {
|
||||||
.vid = 0x16d0, .pid = 0x06a3,
|
.vid = 0x04B4, .pid = 0x1004,
|
||||||
.default_config = 1, .default_interface = 0,
|
.default_config = 1, .default_interface = 0,
|
||||||
.bulk_timeout = 500,
|
.bulk_timeout = 500,
|
||||||
.ep_ctrl_bulk_in = 1 | LIBUSB_ENDPOINT_IN, .ep_ctrl_bulk_out = 1 | LIBUSB_ENDPOINT_OUT,
|
.ep_ctrl_bulk_in = 1 | LIBUSB_ENDPOINT_IN, .ep_ctrl_bulk_out = 1 | LIBUSB_ENDPOINT_OUT,
|
||||||
@ -73,8 +75,8 @@ static const cyopn_device_usb_device cypress_optimize_new_3ds_instantiated_devic
|
|||||||
.full_data = &cypress_optimize_new_3ds_instantiated_device,
|
.full_data = &cypress_optimize_new_3ds_instantiated_device,
|
||||||
.get_serial_fn = cypress_optimize_new_3ds_get_serial,
|
.get_serial_fn = cypress_optimize_new_3ds_get_serial,
|
||||||
.create_device_fn = cypress_optimize_new_3ds_create_device,
|
.create_device_fn = cypress_optimize_new_3ds_create_device,
|
||||||
.filter_for_product = true,
|
.bcd_device_mask = 0xFF00,
|
||||||
.wanted_product_str = OPTIMIZE_NEW_3DS_ALTERNATIVE_PRODUCT_NAME
|
.bcd_device_wanted_value = OPTIMIZE_NEW_3DS_WANTED_VALUE_BASE
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -124,7 +126,7 @@ bool load_firmware(cy_device_device_handlers* handlers, const cyopn_device_usb_d
|
|||||||
int num_patches = read_le16(fw_data, 1);
|
int num_patches = read_le16(fw_data, 1);
|
||||||
for(int i = 0; i < num_patches; i++) {
|
for(int i = 0; i < num_patches; i++) {
|
||||||
int pos_patch = read_le16(fw_data, 2 + i);
|
int pos_patch = read_le16(fw_data, 2 + i);
|
||||||
write_le16(fw_data + pos_patch, patch_id | 0xFF00);
|
write_le16(fw_data + pos_patch, patch_id | OPTIMIZE_NEW_3DS_WANTED_VALUE_BASE);
|
||||||
}
|
}
|
||||||
uint8_t buffer[0x8000];
|
uint8_t buffer[0x8000];
|
||||||
buffer[0] = 1;
|
buffer[0] = 1;
|
||||||
@ -299,7 +301,7 @@ static int fpga_pl_load(cy_device_device_handlers* handlers, const cyopn_device_
|
|||||||
if(remaining_size > fpga_pl_transfer_piece_size)
|
if(remaining_size > fpga_pl_transfer_piece_size)
|
||||||
remaining_size = fpga_pl_transfer_piece_size;
|
remaining_size = fpga_pl_transfer_piece_size;
|
||||||
memcpy(pl_buffer + fpga_pl_transfer_header_size, fpga_pl + (fpga_pl_transfer_piece_size * i), remaining_size);
|
memcpy(pl_buffer + fpga_pl_transfer_header_size, fpga_pl + (fpga_pl_transfer_piece_size * i), remaining_size);
|
||||||
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), pl_buffer, sizeof(pl_buffer), &transferred);
|
ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), pl_buffer, remaining_size + fpga_pl_transfer_header_size, &transferred);
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -132,16 +132,6 @@ static std::string get_serial(libusb_device_handle *handle, libusb_device_descri
|
|||||||
return serial_str;
|
return serial_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool check_product_usable(libusb_device_handle *handle, libusb_device_descriptor *usb_descriptor) {
|
|
||||||
uint8_t data[PRODUCT_SIZE + 1];
|
|
||||||
std::string product_str = "";
|
|
||||||
if(libusb_get_string_descriptor_ascii(handle, usb_descriptor->iProduct, data, PRODUCT_SIZE-1) >= 0) {
|
|
||||||
data[PRODUCT_SIZE] = '\0';
|
|
||||||
product_str = std::string((const char*)data);
|
|
||||||
}
|
|
||||||
return product_str != OPTIMIZE_NEW_3DS_ALTERNATIVE_PRODUCT_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int do_usb_config_device(libusb_device_handle *handle, const usb_device* usb_device_desc) {
|
static int do_usb_config_device(libusb_device_handle *handle, const usb_device* usb_device_desc) {
|
||||||
libusb_check_and_detach_kernel_driver(handle, usb_device_desc->capture_interface);
|
libusb_check_and_detach_kernel_driver(handle, usb_device_desc->capture_interface);
|
||||||
int result = libusb_check_and_set_configuration(handle, usb_device_desc->default_config);
|
int result = libusb_check_and_set_configuration(handle, usb_device_desc->default_config);
|
||||||
@ -171,10 +161,6 @@ static int insert_device(std::vector<CaptureDevice> &devices_list, const usb_dev
|
|||||||
libusb_close(handle);
|
libusb_close(handle);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if(!check_product_usable(handle, usb_descriptor)) {
|
|
||||||
libusb_close(handle);
|
|
||||||
return LIBUSB_ERROR_NOT_FOUND;
|
|
||||||
}
|
|
||||||
std::string serial_str = get_serial(handle, usb_descriptor, curr_serial_extra_id);
|
std::string serial_str = get_serial(handle, usb_descriptor, curr_serial_extra_id);
|
||||||
if(usb_device_desc->is_3ds)
|
if(usb_device_desc->is_3ds)
|
||||||
devices_list.emplace_back(serial_str, "3DS", CAPTURE_CONN_USB, (void*)usb_device_desc, true, capture_get_has_3d(handle, usb_device_desc), true, HEIGHT_3DS, TOP_WIDTH_3DS + BOT_WIDTH_3DS, O3DS_SAMPLES_IN, 90, 0, 0, TOP_WIDTH_3DS, 0, VIDEO_DATA_RGB);
|
devices_list.emplace_back(serial_str, "3DS", CAPTURE_CONN_USB, (void*)usb_device_desc, true, capture_get_has_3d(handle, usb_device_desc), true, HEIGHT_3DS, TOP_WIDTH_3DS + BOT_WIDTH_3DS, O3DS_SAMPLES_IN, 90, 0, 0, TOP_WIDTH_3DS, 0, VIDEO_DATA_RGB);
|
||||||
@ -204,10 +190,6 @@ static libusb_device_handle* usb_find_by_serial_number(const usb_device* usb_dev
|
|||||||
result = libusb_open(usb_devices[i], &handle);
|
result = libusb_open(usb_devices[i], &handle);
|
||||||
if(result || (handle == NULL))
|
if(result || (handle == NULL))
|
||||||
continue;
|
continue;
|
||||||
if(!check_product_usable(handle, &usb_descriptor)) {
|
|
||||||
libusb_close(handle);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::string device_serial_number = get_serial(handle, &usb_descriptor, curr_serial_extra_id);
|
std::string device_serial_number = get_serial(handle, &usb_descriptor, curr_serial_extra_id);
|
||||||
if(serial_number == device_serial_number) {
|
if(serial_number == device_serial_number) {
|
||||||
final_handle = handle;
|
final_handle = handle;
|
||||||
|
@ -1 +1,3 @@
|
|||||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="0752", ATTRS{idProduct}=="8613", MODE="0666"
|
SUBSYSTEM=="usb", ATTRS{idVendor}=="0752", ATTRS{idProduct}=="8613", MODE="0666"
|
||||||
|
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="8613", MODE="0666"
|
||||||
|
SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="1004", MODE="0666"
|
||||||
|
Loading…
Reference in New Issue
Block a user