genesys: Move setup of read buffer to a single function

merge-requests/177/head
Povilas Kanapickas 2019-09-13 11:36:54 +03:00
rodzic 28d15784e4
commit 05ed63fa34
6 zmienionych plików z 33 dodań i 11 usunięć

Wyświetl plik

@ -951,9 +951,7 @@ static void gl124_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
// BUG: we shouldn't multiply by channels here
dev->oe_buffer.clear();
dev->oe_buffer.alloc(session.output_line_bytes_raw * session.params.channels);
build_image_pipeline(dev, session);
// MAXWD is expressed in 2 words unit

Wyświetl plik

@ -1301,8 +1301,7 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
dev->out_buffer.clear();
dev->out_buffer.alloc(session.buffer_size_out);
dev->oe_buffer.clear();
dev->oe_buffer.alloc(session.output_line_bytes_raw * 2);
build_image_pipeline(dev, session);
dev->read_bytes_left_after_deseg = session.output_line_bytes * session.output_line_count;

Wyświetl plik

@ -821,9 +821,7 @@ static void gl846_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
// BUG: we shouldn't multiply by channels here
dev->oe_buffer.clear();
dev->oe_buffer.alloc(session.output_line_bytes_raw * session.params.channels);
build_image_pipeline(dev, session);
/* MAXWD is expressed in 4 words unit */
// BUG: we shouldn't multiply by channels here

Wyświetl plik

@ -838,9 +838,7 @@ static void gl847_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sens
DBG (DBG_io2, "%s: pixels =%d\n", __func__, session.optical_pixels);
DBG (DBG_io2, "%s: depth =%d\n", __func__, session.params.depth);
// BUG: we shouldn't multiply by channels here
dev->oe_buffer.clear();
dev->oe_buffer.alloc(session.output_line_bytes_raw * session.params.channels);
build_image_pipeline(dev, session);
/* MAXWD is expressed in 4 words unit */
// BUG: we shouldn't multiply by channels here

Wyświetl plik

@ -1387,6 +1387,33 @@ void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor&
compute_session_buffer_sizes(dev->model->asic_type, s);
}
static std::size_t get_usb_buffer_read_size(AsicType asic, const ScanSession& session)
{
switch (asic) {
case AsicType::GL646:
// buffer not used on this chip set
return 1;
case AsicType::GL124:
case AsicType::GL846:
case AsicType::GL847:
// BUG: we shouldn't multiply by channels here
return session.output_line_bytes_raw * session.params.channels;
case AsicType::GL843:
return session.output_line_bytes_raw * 2;
default:
throw SaneException("Unknown asic type");
}
}
void build_image_pipeline(Genesys_Device* dev, const ScanSession& session)
{
dev->oe_buffer.clear();
dev->oe_buffer.alloc(get_usb_buffer_read_size(dev->model->asic_type, session));
}
const SensorProfile& get_sensor_profile(AsicType asic_type, const Genesys_Sensor& sensor,
unsigned dpi, unsigned ccd_size_divisor)
{

Wyświetl plik

@ -638,6 +638,8 @@ extern void sanei_genesys_generate_gamma_buffer(Genesys_Device* dev,
void compute_session(Genesys_Device* dev, ScanSession& s, const Genesys_Sensor& sensor);
void build_image_pipeline(Genesys_Device* dev, const ScanSession& session);
void genesys_fill_segmented_buffer(Genesys_Device* dev, uint8_t* work_buffer_dst, size_t size);
const SensorProfile& get_sensor_profile(AsicType asic_type, const Genesys_Sensor& sensor,