genesys: Use same buffer and gamma write method on all chipsets

merge-requests/340/head
Povilas Kanapickas 2020-02-16 10:41:26 +02:00
rodzic aca291906c
commit 498b52fe98
7 zmienionych plików z 20 dodań i 47 usunięć

Wyświetl plik

@ -779,8 +779,7 @@ uint8_t *table;
table=tdefault;
}
dev->interface->write_register(0x66, 0x00);
dev->interface->write_gamma(0x28, 0xc000, table, 128,
ScannerInterface::FLAG_SWAP_REGISTERS);
dev->interface->write_gamma(0x28, 0xc000, table, 128);
dev->interface->write_register(0x5b, 0x00);
dev->interface->write_register(0x5c, 0x00);
}

Wyświetl plik

@ -652,8 +652,7 @@ gl843_init_registers (Genesys_Device * dev)
0x6a, 0x73, 0x63, 0x68, 0x69, 0x65, 0x6e, 0x00,
};
dev->interface->write_buffer(0x3c, 0x3ff000, data, 32,
ScannerInterface::FLAG_SWAP_REGISTERS);
dev->interface->write_buffer(0x3c, 0x3ff000, data, 32);
}
}
@ -679,8 +678,7 @@ static void gl843_send_slope_table(Genesys_Device* dev, int table_nr,
// slope table addresses are fixed : 0x40000, 0x48000, 0x50000, 0x58000, 0x60000
// XXX STEF XXX USB 1.1 ? sanei_genesys_write_0x8c (dev, 0x0f, 0x14);
dev->interface->write_gamma(0x28, 0x40000 + 0x8000 * table_nr, table.data(), steps * 2,
ScannerInterface::FLAG_SWAP_REGISTERS);
dev->interface->write_gamma(0x28, 0x40000 + 0x8000 * table_nr, table.data(), steps * 2);
}
static void gl843_set_ad_fe(Genesys_Device* dev)
@ -1794,8 +1792,7 @@ void CommandSetGl843::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor
gamma[i * 2 + size * 4 + 1] = (bgamma[i] >> 8) & 0xff;
}
dev->interface->write_gamma(0x28, 0x0000, gamma.data(), size * 2 * 3,
ScannerInterface::FLAG_SWAP_REGISTERS);
dev->interface->write_gamma(0x28, 0x0000, gamma.data(), size * 2 * 3);
}
/* this function does the led calibration by scanning one line of the calibration
@ -2851,8 +2848,7 @@ void CommandSetGl843::send_shading_data(Genesys_Device* dev, const Genesys_Senso
}
}
dev->interface->write_buffer(0x3c, 0, final_data.data(), count,
ScannerInterface::FLAG_SMALL_ADDRESS);
dev->interface->write_buffer(0x3c, 0, final_data.data(), count);
}
bool CommandSetGl843::needs_home_before_init_regs_for_scan(Genesys_Device* dev) const

Wyświetl plik

@ -56,11 +56,6 @@ namespace genesys {
class ScannerInterface
{
public:
enum Flags {
FLAG_NONE = 0,
FLAG_SWAP_REGISTERS = 1 << 0,
FLAG_SMALL_ADDRESS = 1 << 1
};
virtual ~ScannerInterface();
@ -77,10 +72,10 @@ public:
// GL646, GL841, GL843 have different ways to write to RAM and to gamma tables
// FIXME: remove flags when updating tests
virtual void write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags = FLAG_NONE) = 0;
std::size_t size) = 0;
virtual void write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags = FLAG_NONE) = 0;
std::size_t size) = 0;
// GL845, GL846, GL847 and GL124 have a uniform way to write to RAM tables
virtual void write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data) = 0;

Wyświetl plik

@ -351,7 +351,7 @@ void ScannerInterfaceUsb::bulk_write_data(std::uint8_t addr, std::uint8_t* data,
}
void ScannerInterfaceUsb::write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags)
std::size_t size)
{
DBG_HELPER_ARGS(dbg, "type: 0x%02x, addr: 0x%08x, size: 0x%08zx", type, addr, size);
if (dev_->model->asic_type != AsicType::GL646 &&
@ -362,19 +362,9 @@ void ScannerInterfaceUsb::write_buffer(std::uint8_t type, std::uint32_t addr, st
}
if (dev_->model->asic_type == AsicType::GL843) {
if (flags & FLAG_SWAP_REGISTERS) {
if (!(flags & FLAG_SMALL_ADDRESS)) {
write_register(0x29, ((addr >> 20) & 0xff));
}
write_register(0x2a, ((addr >> 12) & 0xff));
write_register(0x2b, ((addr >> 4) & 0xff));
} else {
write_register(0x2b, ((addr >> 4) & 0xff));
write_register(0x2a, ((addr >> 12) & 0xff));
if (!(flags & FLAG_SMALL_ADDRESS)) {
write_register(0x29, ((addr >> 20) & 0xff));
}
}
write_register(0x2b, ((addr >> 4) & 0xff));
write_register(0x2a, ((addr >> 12) & 0xff));
write_register(0x29, ((addr >> 20) & 0xff));
} else {
write_register(0x2b, ((addr >> 4) & 0xff));
write_register(0x2a, ((addr >> 12) & 0xff));
@ -383,7 +373,7 @@ void ScannerInterfaceUsb::write_buffer(std::uint8_t type, std::uint32_t addr, st
}
void ScannerInterfaceUsb::write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags)
std::size_t size)
{
DBG_HELPER_ARGS(dbg, "type: 0x%02x, addr: 0x%08x, size: 0x%08zx", type, addr, size);
if (dev_->model->asic_type != AsicType::GL841 &&
@ -392,13 +382,8 @@ void ScannerInterfaceUsb::write_gamma(std::uint8_t type, std::uint32_t addr, std
throw SaneException("Unsupported transfer mode");
}
if (flags & FLAG_SWAP_REGISTERS) {
write_register(0x5b, ((addr >> 12) & 0xff));
write_register(0x5c, ((addr >> 4) & 0xff));
} else {
write_register(0x5c, ((addr >> 4) & 0xff));
write_register(0x5b, ((addr >> 12) & 0xff));
}
write_register(0x5b, ((addr >> 12) & 0xff));
write_register(0x5c, ((addr >> 4) & 0xff));
bulk_write_data(type, data, size);
if (dev_->model->asic_type == AsicType::GL843) {

Wyświetl plik

@ -67,9 +67,9 @@ public:
void bulk_write_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) override;
void write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags) override;
std::size_t size) override;
void write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags) override;
std::size_t size) override;
void write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data) override;

Wyświetl plik

@ -137,23 +137,21 @@ void TestScannerInterface::bulk_write_data(std::uint8_t addr, std::uint8_t* data
}
void TestScannerInterface::write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags)
std::size_t size)
{
(void) type;
(void) addr;
(void) data;
(void) size;
(void) flags;
}
void TestScannerInterface::write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags)
std::size_t size)
{
(void) type;
(void) addr;
(void) data;
(void) size;
(void) flags;
}
void TestScannerInterface::write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data)

Wyświetl plik

@ -74,9 +74,9 @@ public:
void bulk_write_data(std::uint8_t addr, std::uint8_t* data, std::size_t size) override;
void write_buffer(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags) override;
std::size_t size) override;
void write_gamma(std::uint8_t type, std::uint32_t addr, std::uint8_t* data,
std::size_t size, Flags flags) override;
std::size_t size) override;
void write_ahb(std::uint32_t addr, std::uint32_t size, std::uint8_t* data) override;
std::uint16_t read_fe_register(std::uint8_t address) override;