summaryrefslogtreecommitdiff
path: root/backend/genesys/gl847.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backend/genesys/gl847.cpp')
-rw-r--r--backend/genesys/gl847.cpp77
1 files changed, 48 insertions, 29 deletions
diff --git a/backend/genesys/gl847.cpp b/backend/genesys/gl847.cpp
index 13f9dd9..14d1fd0 100644
--- a/backend/genesys/gl847.cpp
+++ b/backend/genesys/gl847.cpp
@@ -51,7 +51,7 @@ gl847_init_registers (Genesys_Device * dev)
{
DBG_HELPER(dbg);
int lide700=0;
- uint8_t val;
+ std::uint8_t val;
/* 700F class needs some different initial settings */
if (dev->model->model_id == ModelId::CANON_LIDE_700F) {
@@ -233,7 +233,8 @@ gl847_init_registers (Genesys_Device * dev)
}
// Set values of analog frontend
-void CommandSetGl847::set_fe(Genesys_Device* dev, const Genesys_Sensor& sensor, uint8_t set) const
+void CommandSetGl847::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" :
@@ -389,7 +390,7 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev,
unsigned tgtime = 1 << (reg->get8(REG_0x1C) & REG_0x1C_TGTIME);
// hi res motor speed GPIO
- uint8_t effective = dev->interface->read_register(REG_0x6C);
+ std::uint8_t effective = dev->interface->read_register(REG_0x6C);
// if quarter step, bipolar Vref2
@@ -624,7 +625,7 @@ void CommandSetGl847::init_regs_for_scan_session(Genesys_Device* dev, const Gene
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;
DBG(DBG_info, "%s: total bytes to send = %zu\n", __func__, dev->total_bytes_to_read);
}
@@ -722,7 +723,7 @@ void CommandSetGl847::begin_scan(Genesys_Device* dev, const Genesys_Sensor& sens
{
DBG_HELPER(dbg);
(void) sensor;
- uint8_t val;
+ std::uint8_t val;
if (reg->state.is_xpa_on && reg->state.is_lamp_on) {
dev->cmd_set->set_xpa_lamp_power(*dev, true);
@@ -879,11 +880,10 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
* for all the channels.
*/
void CommandSetGl847::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);
std::uint32_t addr, i;
- uint8_t val,*ptr,*src;
unsigned length = static_cast<unsigned>(size / 3);
@@ -901,7 +901,7 @@ void CommandSetGl847::send_shading_data(Genesys_Device* dev, const Genesys_Senso
dev->interface->record_key_value("shading_length", std::to_string(length));
dev->interface->record_key_value("shading_factor", std::to_string(sensor.shading_factor));
- std::vector<uint8_t> buffer(pixels, 0);
+ std::vector<std::uint8_t> buffer(pixels, 0);
DBG(DBG_io2, "%s: using chunks of %d (0x%04x) bytes\n", __func__, pixels, pixels);
@@ -917,12 +917,12 @@ void CommandSetGl847::send_shading_data(Genesys_Device* dev, const Genesys_Senso
{
/* build up actual shading data by copying the part from the full width one
* to the one corresponding to SHDAREA */
- ptr = buffer.data();
+ std::uint8_t* ptr = buffer.data();
// iterate on both sensor segment
for (unsigned x = 0; x < pixels; x += 4 * sensor.shading_factor) {
- /* coefficient source */
- src = (data + offset + i * length) + x;
+ // coefficient source
+ std::uint8_t* src = (data + offset + i * length) + x;
/* coefficient copy */
ptr[0]=src[0];
@@ -934,7 +934,7 @@ void CommandSetGl847::send_shading_data(Genesys_Device* dev, const Genesys_Senso
ptr+=4;
}
- val = dev->interface->read_register(0xd0+i);
+ std::uint8_t val = dev->interface->read_register(0xd0+i);
addr = val * 8192 + 0x10000000;
dev->interface->write_ahb(addr, pixels, buffer.data());
}
@@ -1030,7 +1030,7 @@ void CommandSetGl847::asic_boot(Genesys_Device* dev, bool cold) const
}
// test CHKVER
- uint8_t val = dev->interface->read_register(REG_0x40);
+ std::uint8_t val = dev->interface->read_register(REG_0x40);
if (val & REG_0x40_CHKVER) {
val = dev->interface->read_register(0x00);
DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val);
@@ -1089,27 +1089,46 @@ void CommandSetGl847::update_hardware_sensors(Genesys_Scanner* s) const
/* do what is needed to get a new set of events, but try to not lose
any of them.
*/
- uint8_t val;
- uint8_t scan, file, email, copy;
+ std::uint8_t val;
switch(s->dev->model->gpio_id) {
case GpioId::CANON_LIDE_700F:
- scan=0x04;
- file=0x02;
- email=0x01;
- copy=0x08;
+ val = s->dev->interface->read_register(REG_0x6D);
+ DBG(DBG_io, "%s: read buttons_gpio value=0x%x\n", __func__, (int)val);
+
+ s->buttons[BUTTON_SCAN_SW].write((val & 0x04) == 0);
+ s->buttons[BUTTON_FILE_SW].write((val & 0x02) == 0);
+ s->buttons[BUTTON_EMAIL_SW].write((val & 0x01) == 0);
+ s->buttons[BUTTON_COPY_SW].write((val & 0x08) == 0);
+ break;
+
+ case GpioId::CANON_5600F:
+ val = s->dev->interface->read_register(REG_0x6D);
+ DBG(DBG_io, "%s: read buttons_gpio 0x6d value=0x%x\n", __func__, (int)val);
+ s->buttons[BUTTON_SCAN_SW].write((val & 0x02) == 0);
+ s->buttons[BUTTON_EMAIL_SW].write((val & 0x01) == 0);
+ s->buttons[BUTTON_COPY_SW].write((val & 0x08) == 0);
+ s->buttons[BUTTON_PDF4_SW].write((val & 0x04) == 0);
+
+ val = s->dev->interface->read_register(REG_0xA6);
+ DBG(DBG_io, "%s: read buttons_gpio 0xa6 value=0x%x\n", __func__, (int)val);
+ s->buttons[BUTTON_PDF1_SW].write((val & 0x03) == 0x01);
+ s->buttons[BUTTON_PDF2_SW].write((val & 0x03) == 0x02);
+
+ val = s->dev->interface->read_register(REG_0x6C);
+ DBG(DBG_io, "%s: read buttons_gpio 0x6c value=0x%x\n", __func__, (int)val);
+ s->buttons[BUTTON_PDF3_SW].write((val & 0x80) == 0x00);
break;
+
default:
- scan=0x01;
- file=0x02;
- email=0x04;
- copy=0x08;
- }
- val = s->dev->interface->read_register(REG_0x6D);
+ val = s->dev->interface->read_register(REG_0x6D);
+ DBG(DBG_io, "%s: read buttons_gpio value=0x%x\n", __func__, (int)val);
- s->buttons[BUTTON_SCAN_SW].write((val & scan) == 0);
- s->buttons[BUTTON_FILE_SW].write((val & file) == 0);
- s->buttons[BUTTON_EMAIL_SW].write((val & email) == 0);
- s->buttons[BUTTON_COPY_SW].write((val & copy) == 0);
+ s->buttons[BUTTON_SCAN_SW].write((val & 0x01) == 0);
+ s->buttons[BUTTON_FILE_SW].write((val & 0x02) == 0);
+ s->buttons[BUTTON_EMAIL_SW].write((val & 0x04) == 0);
+ s->buttons[BUTTON_COPY_SW].write((val & 0x08) == 0);
+ break;
+ }
}
void CommandSetGl847::update_home_sensor_gpio(Genesys_Device& dev) const