genesys: Refactor frontend table to initialize data explicitly

merge-requests/81/head
Povilas Kanapickas 2019-06-02 11:48:03 +03:00
rodzic 6305433210
commit 24853e657a
3 zmienionych plików z 252 dodań i 208 usunięć

Wyświetl plik

@ -240,9 +240,9 @@ sanei_genesys_init_structs (Genesys_Device * dev)
} }
} }
for (i = 0; i < sizeof (Wolfson) / sizeof (Genesys_Frontend); i++) { for (const auto& frontend : *s_frontends) {
if (dev->model->dac_type == Wolfson[i].fe_id) { if (dev->model->dac_type == frontend.fe_id) {
dev->frontend_initial = Wolfson[i]; dev->frontend_initial = frontend;
fe_ok = true; fe_ok = true;
break; break;
} }
@ -6297,6 +6297,7 @@ sane_init_impl(SANE_Int * version_code, SANE_Auth_Callback authorize)
s_sane_devices.init(); s_sane_devices.init();
s_sane_devices_ptrs.init(); s_sane_devices_ptrs.init();
genesys_init_sensor_tables(); genesys_init_sensor_tables();
genesys_init_frontend_tables();
DBG(DBG_info, "%s: %s endian machine\n", __func__, DBG(DBG_info, "%s: %s endian machine\n", __func__,
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN

Wyświetl plik

@ -57,198 +57,253 @@
#include "genesys_low.h" #include "genesys_low.h"
/** Setup table for various scanners using a Wolfson DAC StaticInit<std::vector<Genesys_Frontend>> s_frontends;
*/
static Genesys_Frontend Wolfson[] = { void genesys_init_frontend_tables()
{ DAC_WOLFSON_UMAX, {0x00, 0x03, 0x05, 0x11} {
, {0x00, 0x00, 0x00} s_frontends.init();
, {0x80, 0x80, 0x80}
, {0x02, 0x02, 0x02} Genesys_Frontend fe;
, {0x00, 0x00, 0x00} fe.fe_id = DAC_WOLFSON_UMAX;
} fe.reg = {0x00, 0x03, 0x05, 0x11};
, /* 0: UMAX */ fe.sign = {0x00, 0x00, 0x00};
{DAC_WOLFSON_ST12, {0x00, 0x03, 0x05, 0x03} fe.offset = {0x80, 0x80, 0x80};
, {0x00, 0x00, 0x00} fe.gain = {0x02, 0x02, 0x02};
, {0xc8, 0xc8, 0xc8} fe.reg2 = {0x00, 0x00, 0x00};
, {0x04, 0x04, 0x04} s_frontends->push_back(fe);
, {0x00, 0x00, 0x00}
}
, /* 1: ST12 */ fe = Genesys_Frontend();
{DAC_WOLFSON_ST24,{0x00, 0x03, 0x05, 0x21} fe.fe_id = DAC_WOLFSON_ST12;
, {0x00, 0x00, 0x00} fe.reg = {0x00, 0x03, 0x05, 0x03};
, {0xc8, 0xc8, 0xc8} fe.sign = {0x00, 0x00, 0x00};
, {0x06, 0x06, 0x06} fe.offset = {0xc8, 0xc8, 0xc8};
, {0x00, 0x00, 0x00} fe.gain = {0x04, 0x04, 0x04};
} fe.reg2 = {0x00, 0x00, 0x00};
, /* 2: ST24 */ s_frontends->push_back(fe);
{DAC_WOLFSON_5345,{0x00, 0x03, 0x05, 0x12}
, {0x00, 0x00, 0x00}
, {0xb8, 0xb8, 0xb8} fe = Genesys_Frontend();
, {0x04, 0x04, 0x04} fe.fe_id = DAC_WOLFSON_ST24;
, {0x00, 0x00, 0x00} fe.reg = {0x00, 0x03, 0x05, 0x21};
} fe.sign = {0x00, 0x00, 0x00};
, /* 3: MD6228/MD6471 */ fe.offset = {0xc8, 0xc8, 0xc8};
{DAC_WOLFSON_HP2400, fe.gain = {0x06, 0x06, 0x06};
/* reg0 reg1 reg2 reg3 */ fe.reg2 = {0x00, 0x00, 0x00};
{0x00, 0x03, 0x05, 0x02} /* reg3=0x02 for 50-600 dpi, 0x32 (0x12 also works well) at 1200 */ s_frontends->push_back(fe);
, {0x00, 0x00, 0x00}
, {0xb4, 0xb6, 0xbc}
, {0x06, 0x09, 0x08} fe = Genesys_Frontend();
, {0x00, 0x00, 0x00} fe.fe_id = DAC_WOLFSON_5345;
} fe.reg = {0x00, 0x03, 0x05, 0x12};
, /* 4: HP2400c */ fe.sign = {0x00, 0x00, 0x00};
{DAC_WOLFSON_HP2300, fe.offset = {0xb8, 0xb8, 0xb8};
{0x00, 0x03, 0x04, 0x02} fe.gain = {0x04, 0x04, 0x04};
, {0x00, 0x00, 0x00} fe.reg2 = {0x00, 0x00, 0x00};
, {0xbe, 0xbe, 0xbe} s_frontends->push_back(fe);
, {0x04, 0x04, 0x04}
, {0x00, 0x00, 0x00}
} // reg3=0x02 for 50-600 dpi, 0x32 (0x12 also works well) at 1200
, /* 5: HP2300c */ fe = Genesys_Frontend();
{DAC_CANONLIDE35,{0x00, 0x3d, 0x08, 0x00} fe.fe_id = DAC_WOLFSON_HP2400;
, {0x00, 0x00, 0x00} fe.reg = {0x00, 0x03, 0x05, 0x02};
, {0xe1, 0xe1, 0xe1} fe.sign = {0x00, 0x00, 0x00};
, {0x93, 0x93, 0x93} fe.offset = {0xb4, 0xb6, 0xbc};
, {0x00, 0x19, 0x06} fe.gain = {0x06, 0x09, 0x08};
} fe.reg2 = {0x00, 0x00, 0x00};
, /* 6: CANONLIDE35 */ s_frontends->push_back(fe);
{DAC_AD_XP200,
{0x58, 0x80, 0x00, 0x00} /* reg1=0x80 ? */
, {0x00, 0x00, 0x00} fe = Genesys_Frontend();
, {0x09, 0x09, 0x09} fe.fe_id = DAC_WOLFSON_HP2300;
, {0x09, 0x09, 0x09} fe.reg = {0x00, 0x03, 0x04, 0x02};
, {0x00, 0x00, 0x00} fe.sign = {0x00, 0x00, 0x00};
} fe.offset = {0xbe, 0xbe, 0xbe};
, fe.gain = {0x04, 0x04, 0x04};
{DAC_WOLFSON_XP300,{0x00, 0x35, 0x20, 0x14} /* 7: XP300 */ fe.reg2 = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} s_frontends->push_back(fe);
, {0xe1, 0xe1, 0xe1}
, {0x93, 0x93, 0x93}
, {0x07, 0x00, 0x00} fe = Genesys_Frontend();
} fe.fe_id = DAC_CANONLIDE35;
, /* 8: HP3670 */ fe.reg = {0x00, 0x3d, 0x08, 0x00};
{DAC_WOLFSON_HP3670, fe.sign = {0x00, 0x00, 0x00};
/* reg0 reg1 reg2 reg3 */ fe.offset = {0xe1, 0xe1, 0xe1};
{0x00, 0x03, 0x05, 0x32} /* reg3=0x32 for 100-300 dpi, 0x12 at 1200 */ fe.gain = {0x93, 0x93, 0x93};
, {0x00, 0x00, 0x00} /* sign */ fe.reg2 = {0x00, 0x19, 0x06};
, {0xba, 0xb8, 0xb8} /* offset */ s_frontends->push_back(fe);
, {0x06, 0x05, 0x04} /* gain 4,3,2 at 1200 ?*/
, {0x00, 0x00, 0x00}
} fe = Genesys_Frontend();
, fe.fe_id = DAC_AD_XP200;
{DAC_WOLFSON_DSM600,{0x00, 0x35, 0x20, 0x14} /* 9: DSMOBILE600 */ fe.reg = {0x58, 0x80, 0x00, 0x00}; /* reg1=0x80 ? */
, {0x00, 0x00, 0x00} fe.sign = {0x00, 0x00, 0x00};
, {0x85, 0x85, 0x85} fe.offset = {0x09, 0x09, 0x09};
, {0xa0, 0xa0, 0xa0} fe.gain = {0x09, 0x09, 0x09};
, {0x07, 0x00, 0x00} fe.reg2 = {0x00, 0x00, 0x00};
} s_frontends->push_back(fe);
,
{DAC_CANONLIDE200,
{0x9d, 0x91, 0x00, 0x00} fe = Genesys_Frontend();
, {0x00, 0x00, 0x00} fe.fe_id = DAC_WOLFSON_XP300;
, {0x00, 0x3f, 0x00} /* 0x00 0x3f 0x00 : offset/brigthness ? */ fe.reg = {0x00, 0x35, 0x20, 0x14}; /* 7: XP300 */
, {0x32, 0x04, 0x00} fe.sign = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} fe.offset = {0xe1, 0xe1, 0xe1};
} fe.gain = {0x93, 0x93, 0x93};
, fe.reg2 = {0x07, 0x00, 0x00};
{DAC_CANONLIDE700, s_frontends->push_back(fe);
{0x9d, 0x9e, 0x00, 0x00}
, {0x00, 0x00, 0x00}
, {0x00, 0x3f, 0x00} /* 0x00 0x3f 0x00 : offset/brigthness ? */ fe = Genesys_Frontend();
, {0x2f, 0x04, 0x00} fe.fe_id = DAC_WOLFSON_HP3670;
, {0x00, 0x00, 0x00} fe.reg = {0x00, 0x03, 0x05, 0x32}; /* reg3=0x32 for 100-300 dpi, 0x12 at 1200 */
} fe.sign = {0x00, 0x00, 0x00};
, /* KV-SS080 */ fe.offset = {0xba, 0xb8, 0xb8};
{DAC_KVSS080, fe.gain = {0x06, 0x05, 0x04}; /* gain 4,3,2 at 1200 ?*/
{0x00, 0x23, 0x24, 0x0f} fe.reg2 = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} s_frontends->push_back(fe);
, {0x80, 0x80, 0x80}
, {0x4b, 0x4b, 0x4b}
, {0x00,0x00,0x00} fe = Genesys_Frontend();
} fe.fe_id = DAC_WOLFSON_DSM600;
, fe.reg = {0x00, 0x35, 0x20, 0x14};
{DAC_G4050, fe.sign = {0x00, 0x00, 0x00};
{0x00, 0x23, 0x24, 0x1f} fe.offset = {0x85, 0x85, 0x85};
, {0x00, 0x00, 0x00} fe.gain = {0xa0, 0xa0, 0xa0};
, {0x45, 0x45, 0x45} /* 0x20, 0x21, 0x22 */ fe.reg2 = {0x07, 0x00, 0x00};
, {0x4b, 0x4b, 0x4b} /* 0x28, 0x29, 0x2a */ s_frontends->push_back(fe);
, {0x00,0x00,0x00}
}
, fe = Genesys_Frontend();
{DAC_CANONLIDE110, fe.fe_id = DAC_CANONLIDE200;
{0x80, 0x8a, 0x23, 0x4c} fe.reg = {0x9d, 0x91, 0x00, 0x00};
, {0x00, 0xca, 0x94} fe.sign = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} fe.offset = {0x00, 0x3f, 0x00}; /* 0x00 0x3f 0x00 : offset/brigthness ? */
, {0x00, 0x00, 0x00} fe.gain = {0x32, 0x04, 0x00};
, {0x00, 0x00, 0x00} fe.reg2 = {0x00, 0x00, 0x00};
} s_frontends->push_back(fe);
,
fe = Genesys_Frontend();
fe.fe_id = DAC_CANONLIDE700;
fe.reg = {0x9d, 0x9e, 0x00, 0x00};
fe.sign = {0x00, 0x00, 0x00};
fe.offset = {0x00, 0x3f, 0x00}; /* 0x00 0x3f 0x00 : offset/brigthness ? */
fe.gain = {0x2f, 0x04, 0x00};
fe.reg2 = {0x00, 0x00, 0x00};
s_frontends->push_back(fe);
fe = Genesys_Frontend();
fe.fe_id = DAC_KVSS080;
fe.reg = {0x00, 0x23, 0x24, 0x0f};
fe.sign = {0x00, 0x00, 0x00};
fe.offset = {0x80, 0x80, 0x80};
fe.gain = {0x4b, 0x4b, 0x4b};
fe.reg2 = {0x00,0x00,0x00};
s_frontends->push_back(fe);
fe = Genesys_Frontend();
fe.fe_id = DAC_G4050;
fe.reg = {0x00, 0x23, 0x24, 0x1f};
fe.sign = {0x00, 0x00, 0x00};
fe.offset = {0x45, 0x45, 0x45}; /* 0x20, 0x21, 0x22 */
fe.gain = {0x4b, 0x4b, 0x4b}; /* 0x28, 0x29, 0x2a */
fe.reg2 = {0x00,0x00,0x00};
s_frontends->push_back(fe);
fe = Genesys_Frontend();
fe.fe_id = DAC_CANONLIDE110;
fe.reg = {0x80, 0x8a, 0x23, 0x4c};
fe.sign = {0x00, 0xca, 0x94};
fe.offset = {0x00, 0x00, 0x00};
fe.gain = {0x00, 0x00, 0x00};
fe.reg2 = {0x00, 0x00, 0x00};
s_frontends->push_back(fe);
/** @brief GL124 special case /** @brief GL124 special case
* for GL124 based scanners, this struct is "abused" * for GL124 based scanners, this struct is "abused"
* in fact the fields are map like below to AFE registers * in fact the fields are map like below to AFE registers
* (from Texas Instrument or alike ?) * (from Texas Instrument or alike ?)
*/ */
{DAC_CANONLIDE120, fe = Genesys_Frontend();
{0x80, fe.fe_id = DAC_CANONLIDE120;
fe.reg = {0x80,
/* 0001 0002 0003 */ /* 0001 0002 0003 */
0xa3, 0x2b, 0x4c} 0xa3, 0x2b, 0x4c};
/* 0005 0006 0007 */ /* 0005 0006 0007 */
, {0x00, 0xca, 0x95} fe.sign = {0x00, 0xca, 0x95};
, {0x00, 0x00, 0x00} fe.offset = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} fe.gain = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} fe.reg2 = {0x00, 0x00, 0x00};
} s_frontends->push_back(fe);
,
{DAC_PLUSTEK_3600,
{0x70, 0x80, 0x00, 0x00} fe = Genesys_Frontend();
, {0x00, 0x00, 0x00} fe.fe_id = DAC_PLUSTEK_3600;
, {0x00, 0x00, 0x00} fe.reg = {0x70, 0x80, 0x00, 0x00};
, {0x3f, 0x3d, 0x3d} fe.sign = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} fe.offset = {0x00, 0x00, 0x00};
} fe.gain = {0x3f, 0x3d, 0x3d};
, fe.reg2 = {0x00, 0x00, 0x00};
{DAC_CS8400F, s_frontends->push_back(fe);
{0x00, 0x23, 0x24, 0x0f}
, {0x00, 0x00, 0x00}
, {0x60, 0x5c, 0x6c} /* 0x20, 0x21, 0x22 */ fe = Genesys_Frontend();
, {0x8a, 0x9f, 0xc2} /* 0x28, 0x29, 0x2a */ fe.fe_id = DAC_CS8400F;
, {0x00, 0x00, 0x00} fe.reg = {0x00, 0x23, 0x24, 0x0f};
}, fe.sign = {0x00, 0x00, 0x00};
{ fe.offset = {0x60, 0x5c, 0x6c};
DAC_CS8600F, fe.gain = {0x8a, 0x9f, 0xc2};
{ 0x00, 0x23, 0x24, 0x2f }, fe.reg2 = {0x00, 0x00, 0x00};
{ 0x00, 0x00, 0x00 }, s_frontends->push_back(fe);
{ 0x67, 0x69, 0x68 }, // 0x20, 0x21, 0x22
{ 0xdb, 0xda, 0xd7 }, // 0x28, 0x29, 0x2a
{ 0x00, 0x00, 0x00 }, fe = Genesys_Frontend();
}, fe.fe_id = DAC_CS8600F;
{DAC_IMG101, fe.reg = { 0x00, 0x23, 0x24, 0x2f };
{0x78, 0xf0, 0x00, 0x00} fe.sign = { 0x00, 0x00, 0x00 };
, {0x00, 0x00, 0x00} fe.offset = { 0x67, 0x69, 0x68 };
, {0x00, 0x00, 0x00} /* 0x20, 0x21, 0x22 */ fe.gain = { 0xdb, 0xda, 0xd7 };
, {0x00, 0x00, 0x00} /* 0x28, 0x29, 0x2a */ fe.reg2 = { 0x00, 0x00, 0x00 };
, {0x00, 0x00, 0x00} s_frontends->push_back(fe);
}
,
{DAC_PLUSTEK3800, fe = Genesys_Frontend();
{0x78, 0xf0, 0x00, 0x00} fe.fe_id = DAC_IMG101;
, {0x00, 0x00, 0x00} fe.reg = {0x78, 0xf0, 0x00, 0x00};
, {0x00, 0x00, 0x00} /* 0x20, 0x21, 0x22 */ fe.sign = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} /* 0x28, 0x29, 0x2a */ fe.offset = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} fe.gain = {0x00, 0x00, 0x00};
}, fe.reg2 = {0x00, 0x00, 0x00};
{DAC_CANONLIDE80, s_frontends->push_back(fe);
fe = Genesys_Frontend();
fe.fe_id = DAC_PLUSTEK3800;
fe.reg = {0x78, 0xf0, 0x00, 0x00};
fe.sign = {0x00, 0x00, 0x00};
fe.offset = {0x00, 0x00, 0x00};
fe.gain = {0x00, 0x00, 0x00};
fe.reg2 = {0x00, 0x00, 0x00};
s_frontends->push_back(fe);
/* reg0: control 74 data, 70 no data /* reg0: control 74 data, 70 no data
* reg3: offset * reg3: offset
* reg6: gain * reg6: gain
* reg0 , reg3, reg6 */ * reg0 , reg3, reg6 */
{0x70, 0x16, 0x60, 0x00} fe = Genesys_Frontend();
, {0x00, 0x00, 0x00} fe.fe_id = DAC_CANONLIDE80;
, {0x00, 0x00, 0x00} fe.reg = {0x70, 0x16, 0x60, 0x00};
, {0x00, 0x00, 0x00} fe.sign = {0x00, 0x00, 0x00};
, {0x00, 0x00, 0x00} fe.offset = {0x00, 0x00, 0x00};
fe.gain = {0x00, 0x00, 0x00};
fe.reg2 = {0x00, 0x00, 0x00};
s_frontends->push_back(fe);
} }
};
/** for setting up the sensor-specific settings: /** for setting up the sensor-specific settings:

Wyświetl plik

@ -391,19 +391,6 @@ struct Genesys_Frontend
{ {
Genesys_Frontend() = default; Genesys_Frontend() = default;
Genesys_Frontend(uint8_t p_fe_id, const std::array<uint8_t, 4>& p_reg,
const std::array<uint8_t, 3>& p_sign,
const std::array<uint8_t, 3>& p_offset,
const std::array<uint8_t, 3>& p_gain,
const std::array<uint8_t, 3>& p_reg2) :
fe_id(p_fe_id),
reg(p_reg),
sign(p_sign),
offset(p_offset),
gain(p_gain),
reg2(p_reg2)
{}
// id of the frontend description // id of the frontend description
uint8_t fe_id = 0; uint8_t fe_id = 0;
@ -1878,5 +1865,6 @@ private:
extern StaticInit<std::vector<Genesys_Sensor>> s_sensors; extern StaticInit<std::vector<Genesys_Sensor>> s_sensors;
void genesys_init_sensor_tables(); void genesys_init_sensor_tables();
void genesys_init_frontend_tables();
#endif /* not GENESYS_LOW_H */ #endif /* not GENESYS_LOW_H */