kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Turn Genesys_USB_Device_Entry into a class
rodzic
b89751605f
commit
0bdce7928f
|
@ -283,7 +283,7 @@ struct Genesys_Device
|
||||||
// acquiring the positions of the black and white strips and the actual scan area
|
// acquiring the positions of the black and white strips and the actual scan area
|
||||||
bool ignore_offsets = false;
|
bool ignore_offsets = false;
|
||||||
|
|
||||||
Genesys_Model *model = nullptr;
|
const Genesys_Model* model = nullptr;
|
||||||
|
|
||||||
// pointers to low level functions
|
// pointers to low level functions
|
||||||
std::unique_ptr<CommandSet> cmd_set;
|
std::unique_ptr<CommandSet> cmd_set;
|
||||||
|
|
|
@ -86,7 +86,7 @@ struct Pixel;
|
||||||
struct RawPixel;
|
struct RawPixel;
|
||||||
|
|
||||||
// low.h
|
// low.h
|
||||||
struct Genesys_USB_Device_Entry;
|
struct UsbDeviceEntry;
|
||||||
|
|
||||||
// motor.h
|
// motor.h
|
||||||
struct Genesys_Motor;
|
struct Genesys_Motor;
|
||||||
|
|
|
@ -4231,7 +4231,7 @@ static void init_options(Genesys_Scanner* s)
|
||||||
{
|
{
|
||||||
DBG_HELPER(dbg);
|
DBG_HELPER(dbg);
|
||||||
SANE_Int option;
|
SANE_Int option;
|
||||||
Genesys_Model *model = s->dev->model;
|
const Genesys_Model* model = s->dev->model;
|
||||||
|
|
||||||
memset (s->opt, 0, sizeof (s->opt));
|
memset (s->opt, 0, sizeof (s->opt));
|
||||||
|
|
||||||
|
@ -4796,10 +4796,10 @@ check_present (SANE_String_Const devname) noexcept
|
||||||
static Genesys_Device* attach_usb_device(const char* devname,
|
static Genesys_Device* attach_usb_device(const char* devname,
|
||||||
std::uint16_t vendor_id, std::uint16_t product_id)
|
std::uint16_t vendor_id, std::uint16_t product_id)
|
||||||
{
|
{
|
||||||
Genesys_USB_Device_Entry* found_usb_dev = nullptr;
|
UsbDeviceEntry* found_usb_dev = nullptr;
|
||||||
for (auto& usb_dev : *s_usb_devices) {
|
for (auto& usb_dev : *s_usb_devices) {
|
||||||
if (usb_dev.vendor == vendor_id &&
|
if (usb_dev.vendor_id() == vendor_id &&
|
||||||
usb_dev.product == product_id)
|
usb_dev.product_id() == product_id)
|
||||||
{
|
{
|
||||||
found_usb_dev = &usb_dev;
|
found_usb_dev = &usb_dev;
|
||||||
break;
|
break;
|
||||||
|
@ -4815,9 +4815,9 @@ static Genesys_Device* attach_usb_device(const char* devname,
|
||||||
Genesys_Device* dev = &s_devices->back();
|
Genesys_Device* dev = &s_devices->back();
|
||||||
dev->file_name = devname;
|
dev->file_name = devname;
|
||||||
|
|
||||||
dev->model = &found_usb_dev->model;
|
dev->model = &found_usb_dev->model();
|
||||||
dev->vendorId = found_usb_dev->vendor;
|
dev->vendorId = found_usb_dev->vendor_id();
|
||||||
dev->productId = found_usb_dev->product;
|
dev->productId = found_usb_dev->product_id();
|
||||||
dev->usb_mode = 0; // i.e. unset
|
dev->usb_mode = 0; // i.e. unset
|
||||||
dev->already_initialized = false;
|
dev->already_initialized = false;
|
||||||
return dev;
|
return dev;
|
||||||
|
|
|
@ -168,18 +168,25 @@
|
||||||
|
|
||||||
namespace genesys {
|
namespace genesys {
|
||||||
|
|
||||||
struct Genesys_USB_Device_Entry {
|
class UsbDeviceEntry {
|
||||||
|
public:
|
||||||
|
|
||||||
Genesys_USB_Device_Entry(unsigned v, unsigned p, const Genesys_Model& m) :
|
UsbDeviceEntry(std::uint16_t vendor_id, std::uint16_t product_id,
|
||||||
vendor(v), product(p), model(m)
|
const Genesys_Model& model) :
|
||||||
|
vendor_{vendor_id}, product_{product_id}, model_{model}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
std::uint16_t vendor_id() const { return vendor_; }
|
||||||
|
std::uint16_t product_id() const { return product_; }
|
||||||
|
const Genesys_Model& model() const { return model_; }
|
||||||
|
|
||||||
|
private:
|
||||||
// USB vendor identifier
|
// USB vendor identifier
|
||||||
std::uint16_t vendor;
|
std::uint16_t vendor_;
|
||||||
// USB product identifier
|
// USB product identifier
|
||||||
std::uint16_t product;
|
std::uint16_t product_;
|
||||||
// Scanner model information
|
// Scanner model information
|
||||||
Genesys_Model model;
|
Genesys_Model model_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
@ -467,7 +474,7 @@ extern StaticInit<std::vector<Genesys_Frontend>> s_frontends;
|
||||||
extern StaticInit<std::vector<Genesys_Gpo>> s_gpo;
|
extern StaticInit<std::vector<Genesys_Gpo>> s_gpo;
|
||||||
extern StaticInit<std::vector<MemoryLayout>> s_memory_layout;
|
extern StaticInit<std::vector<MemoryLayout>> s_memory_layout;
|
||||||
extern StaticInit<std::vector<Genesys_Motor>> s_motors;
|
extern StaticInit<std::vector<Genesys_Motor>> s_motors;
|
||||||
extern StaticInit<std::vector<Genesys_USB_Device_Entry>> s_usb_devices;
|
extern StaticInit<std::vector<UsbDeviceEntry>> s_usb_devices;
|
||||||
|
|
||||||
void genesys_init_sensor_tables();
|
void genesys_init_sensor_tables();
|
||||||
void genesys_init_frontend_tables();
|
void genesys_init_frontend_tables();
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
namespace genesys {
|
namespace genesys {
|
||||||
|
|
||||||
StaticInit<std::vector<Genesys_USB_Device_Entry>> s_usb_devices;
|
StaticInit<std::vector<UsbDeviceEntry>> s_usb_devices;
|
||||||
|
|
||||||
void genesys_init_usb_device_tables()
|
void genesys_init_usb_device_tables()
|
||||||
{
|
{
|
||||||
|
@ -2760,7 +2760,7 @@ void genesys_init_usb_device_tables()
|
||||||
void verify_usb_device_tables()
|
void verify_usb_device_tables()
|
||||||
{
|
{
|
||||||
for (const auto& device : *s_usb_devices) {
|
for (const auto& device : *s_usb_devices) {
|
||||||
const auto& model = device.model;
|
const auto& model = device.model();
|
||||||
|
|
||||||
if (model.x_size_calib_mm == 0.0f) {
|
if (model.x_size_calib_mm == 0.0f) {
|
||||||
throw SaneException("Calibration width can't be zero");
|
throw SaneException("Calibration width can't be zero");
|
||||||
|
|
|
@ -3651,7 +3651,7 @@ void verify_sensor_tables()
|
||||||
{
|
{
|
||||||
std::map<SensorId, AsicType> sensor_to_asic;
|
std::map<SensorId, AsicType> sensor_to_asic;
|
||||||
for (const auto& device : *s_usb_devices) {
|
for (const auto& device : *s_usb_devices) {
|
||||||
sensor_to_asic[device.model.sensor_id] = device.model.asic_type;
|
sensor_to_asic[device.model().sensor_id] = device.model().asic_type;
|
||||||
}
|
}
|
||||||
for (const auto& sensor : *s_sensors) {
|
for (const auto& sensor : *s_sensors) {
|
||||||
if (sensor_to_asic.count(sensor.sensor_id) == 0) {
|
if (sensor_to_asic.count(sensor.sensor_id) == 0) {
|
||||||
|
|
|
@ -397,30 +397,33 @@ std::vector<TestConfig> get_all_test_configs()
|
||||||
std::unordered_set<std::string> model_names;
|
std::unordered_set<std::string> model_names;
|
||||||
|
|
||||||
for (const auto& usb_dev : *genesys::s_usb_devices) {
|
for (const auto& usb_dev : *genesys::s_usb_devices) {
|
||||||
if (genesys::has_flag(usb_dev.model.flags, genesys::ModelFlag::UNTESTED)) {
|
|
||||||
|
const auto& model = usb_dev.model();
|
||||||
|
|
||||||
|
if (genesys::has_flag(model.flags, genesys::ModelFlag::UNTESTED)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (model_names.find(usb_dev.model.name) != model_names.end()) {
|
if (model_names.find(model.name) != model_names.end()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
model_names.insert(usb_dev.model.name);
|
model_names.insert(model.name);
|
||||||
|
|
||||||
for (auto scan_mode : { genesys::ScanColorMode::LINEART,
|
for (auto scan_mode : { genesys::ScanColorMode::LINEART,
|
||||||
genesys::ScanColorMode::GRAY,
|
genesys::ScanColorMode::GRAY,
|
||||||
genesys::ScanColorMode::COLOR_SINGLE_PASS }) {
|
genesys::ScanColorMode::COLOR_SINGLE_PASS }) {
|
||||||
|
|
||||||
auto depth_values = usb_dev.model.bpp_gray_values;
|
auto depth_values = model.bpp_gray_values;
|
||||||
if (scan_mode == genesys::ScanColorMode::COLOR_SINGLE_PASS) {
|
if (scan_mode == genesys::ScanColorMode::COLOR_SINGLE_PASS) {
|
||||||
depth_values = usb_dev.model.bpp_color_values;
|
depth_values = model.bpp_color_values;
|
||||||
}
|
}
|
||||||
for (unsigned depth : depth_values) {
|
for (unsigned depth : depth_values) {
|
||||||
for (auto method_resolutions : usb_dev.model.resolutions) {
|
for (auto method_resolutions : model.resolutions) {
|
||||||
for (auto method : method_resolutions.methods) {
|
for (auto method : method_resolutions.methods) {
|
||||||
for (unsigned resolution : method_resolutions.get_resolutions()) {
|
for (unsigned resolution : method_resolutions.get_resolutions()) {
|
||||||
TestConfig config;
|
TestConfig config;
|
||||||
config.vendor_id = usb_dev.vendor;
|
config.vendor_id = usb_dev.vendor_id();
|
||||||
config.product_id = usb_dev.product;
|
config.product_id = usb_dev.product_id();
|
||||||
config.model_name = usb_dev.model.name;
|
config.model_name = model.name;
|
||||||
config.method = method;
|
config.method = method;
|
||||||
config.depth = depth;
|
config.depth = depth;
|
||||||
config.resolution = resolution;
|
config.resolution = resolution;
|
||||||
|
|
Ładowanie…
Reference in New Issue