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

Wyświetl plik

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

Wyświetl plik

@ -391,19 +391,6 @@ struct Genesys_Frontend
{
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
uint8_t fe_id = 0;
@ -1878,5 +1865,6 @@ private:
extern StaticInit<std::vector<Genesys_Sensor>> s_sensors;
void genesys_init_sensor_tables();
void genesys_init_frontend_tables();
#endif /* not GENESYS_LOW_H */