summaryrefslogtreecommitdiff
path: root/backend/genesys/gl841.cpp
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2023-02-12 17:35:53 +0100
committerJörg Frings-Fürst <debian@jff.email>2023-02-12 17:35:53 +0100
commit84357741a6a6e6430f199b2c3f7498e0e97da9ad (patch)
tree23e8d66ede9506b94c76fb36910ca3c7dd15c74e /backend/genesys/gl841.cpp
parent302276dc1b90cfc972fb726ca94a23b18f4b0088 (diff)
New upstream version 1.2.1upstream/1.2.1
Diffstat (limited to 'backend/genesys/gl841.cpp')
-rw-r--r--backend/genesys/gl841.cpp119
1 files changed, 86 insertions, 33 deletions
diff --git a/backend/genesys/gl841.cpp b/backend/genesys/gl841.cpp
index 27a6a36..3b068d1 100644
--- a/backend/genesys/gl841.cpp
+++ b/backend/genesys/gl841.cpp
@@ -288,7 +288,7 @@ gl841_init_registers (Genesys_Device * dev)
}
}
-static void gl841_set_lide80_fe(Genesys_Device* dev, uint8_t set)
+static void gl841_set_lide80_fe(Genesys_Device* dev, std::uint8_t set)
{
DBG_HELPER(dbg);
@@ -311,7 +311,7 @@ static void gl841_set_lide80_fe(Genesys_Device* dev, uint8_t set)
}
// Set values of Analog Device type frontend
-static void gl841_set_ad_fe(Genesys_Device* dev, uint8_t set)
+static void gl841_set_ad_fe(Genesys_Device* dev, std::uint8_t set)
{
DBG_HELPER(dbg);
int i;
@@ -361,7 +361,8 @@ static void gl841_set_ad_fe(Genesys_Device* dev, uint8_t set)
}
// Set values of analog frontend
-void CommandSetGl841::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const
+void CommandSetGl841::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor,
+ std::uint8_t set) const
{
DBG_HELPER_ARGS(dbg, "%s", set == AFE_INIT ? "init" :
set == AFE_SET ? "set" :
@@ -369,7 +370,7 @@ void CommandSetGl841::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor,
(void) sensor;
/* Analog Device type frontend */
- uint8_t frontend_type = dev->reg.find_reg(0x04).value & REG_0x04_FESET;
+ std::uint8_t frontend_type = dev->reg.find_reg(0x04).value & REG_0x04_FESET;
if (frontend_type == 0x02) {
gl841_set_ad_fe(dev, set);
@@ -453,12 +454,68 @@ static void gl841_write_freq(Genesys_Device* dev, unsigned int ydpi)
{
DBG_HELPER(dbg);
/**< fast table */
-uint8_t tdefault[] = {0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0x36,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xb6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0xf6,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76,0x18,0x76};
-uint8_t t1200[] = {0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc7,0x31,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc0,0x11,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0xc7,0xb1,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0x07,0xe0,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc7,0xf1,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc0,0x51,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0xc7,0x71,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20,0x07,0x20};
-uint8_t t300[] = {0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x08,0x32,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x00,0x13,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x08,0xb2,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x0c,0xa0,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x08,0xf2,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x00,0xd3,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x08,0x72,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60,0x0c,0x60};
-uint8_t t150[] = {0x0c,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0xcf,0x33,0x40,0x14,0x80,0x15,0x80,0x15,0x80,0x15,0x80,0x15,0x80,0x15,0x80,0x15,0x80,0x15,0x0c,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0xcf,0xb3,0x11,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x16,0xa0,0x0c,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0xcf,0xf3,0x40,0xd4,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x80,0xd5,0x0c,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0xcf,0x73,0x11,0x60,0x16,0x60,0x16,0x60,0x16,0x60,0x16,0x60,0x16,0x60,0x16,0x60,0x16,0x60};
-
-uint8_t *table;
+ std::uint8_t tdefault[] = {
+ 0x18, 0x36, 0x18, 0x36, 0x18, 0x36, 0x18, 0x36, 0x18, 0x36,
+ 0x18, 0x36, 0x18, 0x36, 0x18, 0x36, 0x18, 0x36, 0x18, 0x36,
+ 0x18, 0x36, 0x18, 0x36, 0x18, 0x36, 0x18, 0x36, 0x18, 0x36,
+ 0x18, 0x36, 0x18, 0xb6, 0x18, 0xb6, 0x18, 0xb6, 0x18, 0xb6,
+ 0x18, 0xb6, 0x18, 0xb6, 0x18, 0xb6, 0x18, 0xb6, 0x18, 0xb6,
+ 0x18, 0xb6, 0x18, 0xb6, 0x18, 0xb6, 0x18, 0xb6, 0x18, 0xb6,
+ 0x18, 0xb6, 0x18, 0xb6, 0x18, 0xf6, 0x18, 0xf6, 0x18, 0xf6,
+ 0x18, 0xf6, 0x18, 0xf6, 0x18, 0xf6, 0x18, 0xf6, 0x18, 0xf6,
+ 0x18, 0xf6, 0x18, 0xf6, 0x18, 0xf6, 0x18, 0xf6, 0x18, 0xf6,
+ 0x18, 0xf6, 0x18, 0xf6, 0x18, 0xf6, 0x18, 0x76, 0x18, 0x76,
+ 0x18, 0x76, 0x18, 0x76, 0x18, 0x76, 0x18, 0x76, 0x18, 0x76,
+ 0x18, 0x76, 0x18, 0x76, 0x18, 0x76, 0x18, 0x76, 0x18, 0x76,
+ 0x18, 0x76, 0x18, 0x76, 0x18, 0x76, 0x18, 0x76
+ };
+ std::uint8_t t1200[] = {
+ 0xc7, 0x31, 0xc7, 0x31, 0xc7, 0x31, 0xc7, 0x31, 0xc7, 0x31,
+ 0xc7, 0x31, 0xc7, 0x31, 0xc7, 0x31, 0xc0, 0x11, 0xc0, 0x11,
+ 0xc0, 0x11, 0xc0, 0x11, 0xc0, 0x11, 0xc0, 0x11, 0xc0, 0x11,
+ 0xc0, 0x11, 0xc7, 0xb1, 0xc7, 0xb1, 0xc7, 0xb1, 0xc7, 0xb1,
+ 0xc7, 0xb1, 0xc7, 0xb1, 0xc7, 0xb1, 0xc7, 0xb1, 0x07, 0xe0,
+ 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xe0,
+ 0x07, 0xe0, 0x07, 0xe0, 0xc7, 0xf1, 0xc7, 0xf1, 0xc7, 0xf1,
+ 0xc7, 0xf1, 0xc7, 0xf1, 0xc7, 0xf1, 0xc7, 0xf1, 0xc7, 0xf1,
+ 0xc0, 0x51, 0xc0, 0x51, 0xc0, 0x51, 0xc0, 0x51, 0xc0, 0x51,
+ 0xc0, 0x51, 0xc0, 0x51, 0xc0, 0x51, 0xc7, 0x71, 0xc7, 0x71,
+ 0xc7, 0x71, 0xc7, 0x71, 0xc7, 0x71, 0xc7, 0x71, 0xc7, 0x71,
+ 0xc7, 0x71, 0x07, 0x20, 0x07, 0x20, 0x07, 0x20, 0x07, 0x20,
+ 0x07, 0x20, 0x07, 0x20, 0x07, 0x20, 0x07, 0x20
+ };
+ std::uint8_t t300[] = {
+ 0x08, 0x32, 0x08, 0x32, 0x08, 0x32, 0x08, 0x32, 0x08, 0x32,
+ 0x08, 0x32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0xa0,
+ 0x16, 0xa0, 0x16, 0xa0, 0x0c, 0xf3, 0xcf, 0xf3, 0xcf, 0xf3,
+ 0xcf, 0xf3, 0xcf, 0xf3, 0xcf, 0xf3, 0xcf, 0xf3, 0xcf, 0xf3,
+ 0x40, 0xd4, 0x80, 0xd5, 0x80, 0xd5, 0x80, 0xd5, 0x80, 0xd5,
+ 0x80, 0xd5, 0x80, 0xd5, 0x80, 0xd5, 0x0c, 0x73, 0xcf, 0x73,
+ 0xcf, 0x73, 0xcf, 0x73, 0xcf, 0x73, 0xcf, 0x73, 0xcf, 0x73,
+ 0xcf, 0x73, 0x11, 0x60, 0x16, 0x60, 0x16, 0x60, 0x16, 0x60,
+ 0x16, 0x60, 0x16, 0x60, 0x16, 0x60, 0x16, 0x60
+ };
+
+ std::uint8_t *table;
if(dev->model->motor_id == MotorId::CANON_LIDE_80) {
switch(ydpi)
@@ -495,7 +552,7 @@ static void gl841_init_motor_regs_feed(Genesys_Device* dev, const Genesys_Sensor
/*number of scan lines to add in a scan_lines line*/
{
- std::vector<uint16_t> table;
+ std::vector<std::uint16_t> table;
table.resize(256, 0xffff);
scanner_send_slope_table(dev, sensor, 0, table);
@@ -711,6 +768,7 @@ static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
const ScanSession& session)
{
DBG_HELPER_ARGS(dbg, "exposure_time=%d", exposure_time);
+
dev->cmd_set->set_fe(dev, sensor, AFE_SET);
/* gpio part.*/
@@ -920,7 +978,7 @@ dummy \ scanned lines
dev->session = session;
dev->total_bytes_read = 0;
- dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines;
+ dev->total_bytes_to_read = (size_t)session.output_line_bytes_requested * (size_t)session.params.lines;
if (session.use_host_side_gray) {
dev->total_bytes_to_read /= 3;
}
@@ -998,7 +1056,7 @@ void CommandSetGl841::save_power(Genesys_Device* dev, bool enable) const
/* final state: GPIO8 disabled, GPIO9 enabled, GPIO17 disabled,
GPIO18 disabled*/
- uint8_t val = dev->interface->read_register(REG_0x6D);
+ std::uint8_t val = dev->interface->read_register(REG_0x6D);
dev->interface->write_register(REG_0x6D, val | 0x80);
dev->interface->sleep_ms(1);
@@ -1023,7 +1081,7 @@ void CommandSetGl841::save_power(Genesys_Device* dev, bool enable) const
}
if (dev->model->gpio_id == GpioId::DP685)
{
- uint8_t val = dev->interface->read_register(REG_0x6B);
+ std::uint8_t val = dev->interface->read_register(REG_0x6B);
dev->interface->write_register(REG_0x6B, val & ~REG_0x6B_GPO17);
dev->reg.find_reg(0x6b).value &= ~REG_0x6B_GPO17;
dev->initial_regs.find_reg(0x6b).value &= ~REG_0x6B_GPO17;
@@ -1041,7 +1099,7 @@ void CommandSetGl841::save_power(Genesys_Device* dev, bool enable) const
/* final state: GPIO8 enabled, GPIO9 disabled, GPIO17 enabled,
GPIO18 enabled*/
- uint8_t val = dev->interface->read_register(REG_0x6D);
+ std::uint8_t val = dev->interface->read_register(REG_0x6D);
dev->interface->write_register(REG_0x6D, val | 0x80);
dev->interface->sleep_ms(10);
@@ -1070,7 +1128,7 @@ void CommandSetGl841::save_power(Genesys_Device* dev, bool enable) const
if (dev->model->gpio_id == GpioId::DP665
|| dev->model->gpio_id == GpioId::DP685)
{
- uint8_t val = dev->interface->read_register(REG_0x6B);
+ std::uint8_t val = dev->interface->read_register(REG_0x6B);
dev->interface->write_register(REG_0x6B, val | REG_0x6B_GPO17);
dev->reg.find_reg(0x6b).value |= REG_0x6B_GPO17;
dev->initial_regs.find_reg(0x6b).value |= REG_0x6B_GPO17;
@@ -1147,7 +1205,7 @@ static bool gl841_get_paper_sensor(Genesys_Device* dev)
{
DBG_HELPER(dbg);
- uint8_t val = dev->interface->read_register(REG_0x6D);
+ std::uint8_t val = dev->interface->read_register(REG_0x6D);
return (val & 0x1) == 0;
}
@@ -1365,7 +1423,7 @@ void CommandSetGl841::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sens
(void) sensor;
// FIXME: SEQUENTIAL not really needed in this case
Genesys_Register_Set local_reg(Genesys_Register_Set::SEQUENTIAL);
- uint8_t val;
+ std::uint8_t val;
if (dev->model->gpio_id == GpioId::CANON_LIDE_80) {
val = dev->interface->read_register(REG_0x6B);
@@ -1476,10 +1534,7 @@ void CommandSetGl841::send_gamma_table(Genesys_Device* dev, const Genesys_Sensor
size = 256;
- /* allocate temporary gamma tables: 16 bits words, 3 channels */
- std::vector<uint8_t> gamma(size * 2 * 3);
-
- sanei_genesys_generate_gamma_buffer(dev, sensor, 16, 65535, size, gamma.data());
+ auto gamma = generate_gamma_buffer(dev, sensor, 16, 65535, size);
dev->interface->write_gamma(0x28, 0x0000, gamma.data(), size * 2 * 3);
}
@@ -1549,7 +1604,7 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
// FIXME: we're reading twice as much data for no reason
std::size_t total_size = session.output_line_bytes * 2;
- std::vector<uint8_t> line(total_size);
+ std::vector<std::uint8_t> line(total_size);
dev->frontend.set_gain(0, 0);
dev->frontend.set_gain(1, 0);
@@ -2029,10 +2084,9 @@ void CommandSetGl841::init(Genesys_Device* dev) const
void CommandSetGl841::update_hardware_sensors(Genesys_Scanner* s) const
{
DBG_HELPER(dbg);
- /* do what is needed to get a new set of events, but try to not lose
- any of them.
- */
- uint8_t val;
+
+ // do what is needed to get a new set of events, but try to not lose any of them.
+ std::uint8_t val;
if (s->dev->model->gpio_id == GpioId::CANON_LIDE_35
|| s->dev->model->gpio_id == GpioId::CANON_LIDE_80)
@@ -2060,11 +2114,10 @@ void CommandSetGl841::update_hardware_sensors(Genesys_Scanner* s) const
* for all the channels.
*/
void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Sensor& sensor,
- uint8_t* data, int size) const
+ std::uint8_t* data, int size) const
{
DBG_HELPER_ARGS(dbg, "writing %d bytes of shading data", size);
- uint32_t length, x, pixels, i;
- uint8_t *ptr,*src;
+ std::uint32_t length, x, pixels, i;
/* old method if no SHDAREA */
if ((dev->reg.find_reg(0x01).value & REG_0x01_SHDAREA) == 0) {
@@ -2094,7 +2147,7 @@ void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Senso
DBG(DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n", __func__, length,
length/4);
- std::vector<uint8_t> buffer(pixels, 0);
+ std::vector<std::uint8_t> buffer(pixels, 0);
/* write actual shading data contigously
* channel by channel, starting at addr 0x0000
@@ -2103,14 +2156,14 @@ void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Senso
{
/* copy data to work buffer and process it */
/* coefficient destination */
- ptr=buffer.data();
+ std::uint8_t* ptr = buffer.data();
/* iterate on both sensor segment, data has been averaged,
* so is in the right order and we only have to copy it */
for(x=0;x<pixels;x+=4)
{
/* coefficient source */
- src = data + x + beginpixel + i * length;
+ std::uint8_t* src = data + x + beginpixel + i * length;
ptr[0]=src[0];
ptr[1]=src[1];
ptr[2]=src[2];