kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Move all gpio settings to a single struct on GL843
rodzic
4a9738b719
commit
7872f87475
|
@ -217,6 +217,8 @@ gl843_init_registers (Genesys_Device * dev)
|
|||
// of the sensors definition and the actual value is set in
|
||||
// gl843_setup_sensor().
|
||||
|
||||
// 0x6c, 0x6d, 0x6e, 0x6f, 0xa6, 0xa7, 0xa8, 0xa9 are defined in the Gpo sensor struct
|
||||
|
||||
DBG_HELPER(dbg);
|
||||
|
||||
dev->reg.clear();
|
||||
|
@ -3329,28 +3331,10 @@ GPIO(0xa8)=0x3e
|
|||
static void gl843_init_gpio(Genesys_Device* dev)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
int idx;
|
||||
|
||||
dev->write_register(REG6E, dev->gpo.regs.get_value(0x6e));
|
||||
dev->write_register(REG6F, dev->gpo.regs.get_value(0x6f));
|
||||
dev->write_register(REG6C, dev->gpo.regs.get_value(0x6c));
|
||||
dev->write_register(REG6D, dev->gpo.regs.get_value(0x6d));
|
||||
|
||||
idx=0;
|
||||
while(dev->model->gpo_type != gpios[idx].gpo_type && gpios[idx].gpo_type!=0)
|
||||
apply_registers_ordered(dev->gpo.regs, { 0x6e, 0x6f }, [&](const GenesysRegisterSetting& reg)
|
||||
{
|
||||
idx++;
|
||||
}
|
||||
if (gpios[idx].gpo_type != 0) {
|
||||
dev->write_register(REGA6, gpios[idx].ra6);
|
||||
dev->write_register(REGA7, gpios[idx].ra7);
|
||||
dev->write_register(REGA8, gpios[idx].ra8);
|
||||
dev->write_register(REGA9, gpios[idx].ra9);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw SaneException("Unknown gpo type %d", dev->model->gpo_type);
|
||||
}
|
||||
dev->write_register(reg.address, reg.value);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -382,38 +382,3 @@
|
|||
#define SCAN_FLAG_DYNAMIC_LINEART 0x080
|
||||
|
||||
#define SETREG(adr,val) { dev->reg.init_reg(adr, val); }
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SANE_Int gpo_type;
|
||||
uint8_t ra6;
|
||||
uint8_t ra7;
|
||||
uint8_t ra8;
|
||||
uint8_t ra9;
|
||||
} Gpio_layout;
|
||||
|
||||
static Gpio_layout gpios[]={
|
||||
/* G4050 */
|
||||
{
|
||||
GPO_G4050, 0x08, 0x1e, 0x3e, 0x06
|
||||
},
|
||||
/* KV-SS080 */
|
||||
{
|
||||
GPO_KVSS080, 0x06, 0x0f, 0x00, 0x08
|
||||
},
|
||||
/* 4400F */
|
||||
{
|
||||
GPO_CS4400F, 0x00, 0xff, 0x07, 0x00
|
||||
},
|
||||
/* 8400F */
|
||||
{
|
||||
GPO_CS8400F, 0x00, 0x03, 0x00, 0x02
|
||||
},
|
||||
{
|
||||
GPO_CS8600F, 0x00, 0xff, 0x00, 0x00,
|
||||
},
|
||||
/* end marker */
|
||||
{
|
||||
0, 0, 0, 0, 0
|
||||
},
|
||||
};
|
||||
|
|
|
@ -293,6 +293,24 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
GenesysRegisterSetting& find_reg(uint16_t address)
|
||||
{
|
||||
int i = find_reg_index(address);
|
||||
if (i < 0) {
|
||||
throw std::runtime_error("the register does not exist");
|
||||
}
|
||||
return registers_[i];
|
||||
}
|
||||
|
||||
const GenesysRegisterSetting& find_reg(uint16_t address) const
|
||||
{
|
||||
int i = find_reg_index(address);
|
||||
if (i < 0) {
|
||||
throw std::runtime_error("the register does not exist");
|
||||
}
|
||||
return registers_[i];
|
||||
}
|
||||
|
||||
uint8_t get_value(uint16_t address) const
|
||||
{
|
||||
int index = find_reg_index(address);
|
||||
|
@ -348,4 +366,19 @@ inline void serialize(std::ostream& str, GenesysRegisterSettingSet& reg)
|
|||
serialize(str, reg.registers_);
|
||||
}
|
||||
|
||||
template<class F>
|
||||
void apply_registers_ordered(const GenesysRegisterSettingSet& set,
|
||||
std::initializer_list<uint16_t> order, F f)
|
||||
{
|
||||
for (uint16_t addr : order) {
|
||||
f(set.find_reg(addr));
|
||||
}
|
||||
for (const auto& reg : set) {
|
||||
if (std::find(order.begin(), order.end(), reg.address) != order.end()) {
|
||||
continue;
|
||||
}
|
||||
f(reg);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BACKEND_GENESYS_REGISTER_H
|
||||
|
|
|
@ -212,6 +212,10 @@ void genesys_init_gpo_tables()
|
|||
{ 0x6d, 0x20 },
|
||||
{ 0x6e, 0x7e },
|
||||
{ 0x6f, 0xa1 },
|
||||
{ 0xa6, 0x06 },
|
||||
{ 0xa7, 0x0f },
|
||||
{ 0xa8, 0x00 },
|
||||
{ 0xa9, 0x08 },
|
||||
};
|
||||
s_gpo->push_back(gpo);
|
||||
|
||||
|
@ -223,6 +227,10 @@ void genesys_init_gpo_tables()
|
|||
{ 0x6d, 0x00 },
|
||||
{ 0x6e, 0xfc },
|
||||
{ 0x6f, 0x00 },
|
||||
{ 0xa6, 0x08 },
|
||||
{ 0xa7, 0x1e },
|
||||
{ 0xa8, 0x3e },
|
||||
{ 0xa9, 0x06 },
|
||||
};
|
||||
s_gpo->push_back(gpo);
|
||||
|
||||
|
@ -289,6 +297,10 @@ void genesys_init_gpo_tables()
|
|||
{ 0x6d, 0x7f },
|
||||
{ 0x6e, 0xff },
|
||||
{ 0x6f, 0x00 },
|
||||
{ 0xa6, 0x00 },
|
||||
{ 0xa7, 0xff },
|
||||
{ 0xa8, 0x07 },
|
||||
{ 0xa9, 0x00 },
|
||||
};
|
||||
s_gpo->push_back(gpo);
|
||||
|
||||
|
@ -300,6 +312,10 @@ void genesys_init_gpo_tables()
|
|||
{ 0x6d, 0xdf },
|
||||
{ 0x6e, 0xfe },
|
||||
{ 0x6f, 0x60 },
|
||||
{ 0xa6, 0x00 },
|
||||
{ 0xa7, 0x03 },
|
||||
{ 0xa8, 0x00 },
|
||||
{ 0xa9, 0x02 },
|
||||
};
|
||||
s_gpo->push_back(gpo);
|
||||
|
||||
|
@ -311,6 +327,10 @@ void genesys_init_gpo_tables()
|
|||
{ 0x6d, 0x7c },
|
||||
{ 0x6e, 0xff },
|
||||
{ 0x6f, 0x00 },
|
||||
{ 0xa6, 0x00 },
|
||||
{ 0xa7, 0xff },
|
||||
{ 0xa8, 0x00 },
|
||||
{ 0xa9, 0x00 },
|
||||
};
|
||||
s_gpo->push_back(gpo);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue