genesys: Reuse common gpio code on gl846

pixma-axis-driver
Povilas Kanapickas 2020-03-14 23:19:32 +02:00
rodzic 31fecb8140
commit ea5047466c
3 zmienionych plików z 8 dodań i 52 usunięć

Wyświetl plik

@ -1128,29 +1128,10 @@ SensorExposure CommandSetGl846::led_calibration(Genesys_Device* dev, const Genes
static void gl846_init_gpio(Genesys_Device* dev)
{
DBG_HELPER(dbg);
int idx=0;
/* search GPIO profile */
while (gpios[idx].gpio_id != GpioId::UNKNOWN && dev->model->gpio_id != gpios[idx].gpio_id) {
idx++;
}
if (gpios[idx].gpio_id == GpioId::UNKNOWN)
apply_registers_ordered(dev->gpo.regs, { 0x6e, 0x6f }, [&](const GenesysRegisterSetting& reg)
{
throw SaneException("failed to find GPIO profile for sensor_id=%d",
static_cast<unsigned>(dev->model->sensor_id));
}
dev->interface->write_register(REG_0xA7, gpios[idx].ra7);
dev->interface->write_register(REG_0xA6, gpios[idx].ra6);
dev->interface->write_register(REG_0x6B, gpios[idx].r6b);
dev->interface->write_register(REG_0x6C, gpios[idx].r6c);
dev->interface->write_register(REG_0x6D, gpios[idx].r6d);
dev->interface->write_register(REG_0x6E, gpios[idx].r6e);
dev->interface->write_register(REG_0x6F, gpios[idx].r6f);
dev->interface->write_register(REG_0xA8, gpios[idx].ra8);
dev->interface->write_register(REG_0xA9, gpios[idx].ra9);
dev->interface->write_register(reg.address, reg.value);
});
}
/**
@ -1218,8 +1199,7 @@ void CommandSetGl846::asic_boot(Genesys_Device* dev, bool cold) const
DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val);
}
/* Set default values for registers */
gl846_init_registers (dev);
gl846_init_registers (dev);
// Write initial registers
dev->interface->write_registers(dev->reg);

Wyświetl plik

@ -50,26 +50,6 @@
namespace genesys {
namespace gl846 {
typedef struct
{
GpioId gpio_id;
uint8_t r6b;
uint8_t r6c;
uint8_t r6d;
uint8_t r6e;
uint8_t r6f;
uint8_t ra6;
uint8_t ra7;
uint8_t ra8;
uint8_t ra9;
} Gpio_Profile;
static Gpio_Profile gpios[]={
{ GpioId::IMG101, 0x72, 0x1f, 0xa4, 0x13, 0xa7, 0x11, 0xff, 0x19, 0x05},
{ GpioId::PLUSTEK_OPTICBOOK_3800, 0x30, 0x01, 0x80, 0x2d, 0x80, 0x0c, 0x8f, 0x08, 0x04},
{ GpioId::UNKNOWN, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
};
typedef struct
{
const char *model;

Wyświetl plik

@ -382,10 +382,8 @@ void genesys_init_gpo_tables()
gpo = Genesys_Gpo();
gpo.id = GpioId::IMG101;
gpo.regs = {
{ 0x6c, 0x41 },
{ 0x6d, 0xa4 },
{ 0x6e, 0x13 },
{ 0x6f, 0xa7 },
{ 0x6b, 0x72 }, { 0x6c, 0x1f }, { 0x6d, 0xa4 }, { 0x6e, 0x13 }, { 0x6f, 0xa7 },
{ 0xa6, 0x11 }, { 0xa7, 0xff }, { 0xa8, 0x19 }, { 0xa9, 0x05 },
};
s_gpo->push_back(gpo);
@ -393,10 +391,8 @@ void genesys_init_gpo_tables()
gpo = Genesys_Gpo();
gpo.id = GpioId::PLUSTEK_OPTICBOOK_3800;
gpo.regs = {
{ 0x6c, 0x41 },
{ 0x6d, 0xa4 },
{ 0x6e, 0x13 },
{ 0x6f, 0xa7 },
{ 0x6b, 0x30 }, { 0x6c, 0x01 }, { 0x6d, 0x80 }, { 0x6e, 0x2d }, { 0x6f, 0x80 },
{ 0xa6, 0x0c }, { 0xa7, 0x8f }, { 0xa8, 0x08 }, { 0xa9, 0x04 },
};
s_gpo->push_back(gpo);