kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Don't use C-style casts where possible
rodzic
6959c2d14e
commit
e20e73f434
|
@ -367,7 +367,7 @@ SANE_Int sanei_genesys_generate_slope_table(std::vector<uint16_t>& slope_table,
|
|||
t2 = vstart;
|
||||
for (i = 0; i < steps && i < use_steps - 1 && i < max_steps; i++, c++)
|
||||
{
|
||||
t = pow (((double) i) / ((double) (steps - 1)), g);
|
||||
t = std::pow(static_cast<double>(i) / static_cast<double>(steps - 1), g);
|
||||
t2 = vstart * (1 - t) + t * vend;
|
||||
if (t2 < stop_at) {
|
||||
break;
|
||||
|
@ -579,7 +579,7 @@ SANE_Int genesys_create_slope_table2(Genesys_Device* dev, std::vector<uint16_t>&
|
|||
{
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
t = pow (((double) i) / ((double) (steps - 1)), g);
|
||||
t = std::pow(static_cast<double>(i) / static_cast<double>(steps - 1), g);
|
||||
slope_table[i] = vstart * (1 - t) + t * vend;
|
||||
DBG (DBG_io, "slope_table[%3d] = %5d\n", i, slope_table[i]);
|
||||
sum += slope_table[i];
|
||||
|
@ -639,7 +639,7 @@ SANE_Int sanei_genesys_create_slope_table(Genesys_Device * dev, std::vector<uint
|
|||
{
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
slope_table[i] = (uint16_t) time_period;
|
||||
slope_table[i] = static_cast<std::uint16_t>(time_period);
|
||||
sum_time += time_period;
|
||||
|
||||
DBG (DBG_io, "slope_table[%d] = %d\n", i, time_period);
|
||||
|
@ -675,7 +675,7 @@ SANE_Int sanei_genesys_create_slope_table(Genesys_Device * dev, std::vector<uint
|
|||
|
||||
if (dev->model->motor_id == MotorId::ST24) {
|
||||
steps = 255;
|
||||
switch ((int) yres)
|
||||
switch (static_cast<int>(yres))
|
||||
{
|
||||
case 2400:
|
||||
g = 0.1672;
|
||||
|
@ -720,7 +720,7 @@ SANE_Int sanei_genesys_create_slope_table(Genesys_Device * dev, std::vector<uint
|
|||
|
||||
for (i = 0; i < same_step; i++)
|
||||
{
|
||||
slope_table[i] = (uint16_t) time_period;
|
||||
slope_table[i] = static_cast<std::uint16_t>(time_period);
|
||||
sum_time += time_period;
|
||||
|
||||
DBG (DBG_io, "slope_table[%d] = %d\n", i, time_period);
|
||||
|
@ -732,7 +732,7 @@ SANE_Int sanei_genesys_create_slope_table(Genesys_Device * dev, std::vector<uint
|
|||
|
||||
for (i = 0; i < steps; i++)
|
||||
{
|
||||
double j = ((double) i) - same_step + 1; /* start from 1/16 speed */
|
||||
double j = static_cast<double>(i) - same_step + 1; /* start from 1/16 speed */
|
||||
|
||||
if (j <= 0)
|
||||
t = 0;
|
||||
|
@ -745,10 +745,11 @@ SANE_Int sanei_genesys_create_slope_table(Genesys_Device * dev, std::vector<uint
|
|||
(start_speed + (1 - start_speed) * t));
|
||||
|
||||
time_period = time_period / divider;
|
||||
if (time_period > 65535)
|
||||
time_period = 65535;
|
||||
if (time_period > 65535) {
|
||||
time_period = 65535;
|
||||
}
|
||||
|
||||
slope_table[i] = (uint16_t) time_period;
|
||||
slope_table[i] = static_cast<std::uint16_t>(time_period);
|
||||
sum_time += time_period;
|
||||
|
||||
DBG (DBG_io, "slope_table[%d] = %d\n", i, slope_table[i]);
|
||||
|
@ -837,7 +838,7 @@ sanei_genesys_exposure_time2 (Genesys_Device * dev, float ydpi,
|
|||
exposure = exposure_by_led;
|
||||
|
||||
DBG(DBG_info, "%s: ydpi=%d, step=%d, endpixel=%d led=%d => exposure=%d\n", __func__,
|
||||
(int)ydpi, step_type, endpixel, exposure_by_led, exposure);
|
||||
static_cast<int>(ydpi), step_type, endpixel, exposure_by_led, exposure);
|
||||
return exposure;
|
||||
}
|
||||
|
||||
|
@ -1284,7 +1285,7 @@ static uint8_t genesys_adjust_gain(double* applied_multi, double multi, uint8_t
|
|||
|
||||
voltage *= multi;
|
||||
|
||||
new_gain = (uint8_t) ((voltage - 0.5) * 4);
|
||||
new_gain = static_cast<std::uint8_t>((voltage - 0.5) * 4);
|
||||
if (new_gain > 0x0e)
|
||||
new_gain = 0x0e;
|
||||
|
||||
|
@ -1383,7 +1384,7 @@ genesys_average_black (Genesys_Device * dev, int channel,
|
|||
|
||||
DBG(DBG_proc, "%s = %d\n", __func__, sum / pixels);
|
||||
|
||||
return (int) (sum / pixels);
|
||||
return sum / pixels;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1475,8 +1476,7 @@ static void genesys_coarse_calibration(Genesys_Device* dev, Genesys_Sensor& sens
|
|||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
|
||||
x =
|
||||
(double) (dark[(i - 2) * 3 + j] -
|
||||
x = static_cast<double>(dark[(i - 2) * 3 + j] -
|
||||
dark[(i - 1) * 3 + j]) * 254 / (offset[i - 1] / 2 -
|
||||
offset[i - 2] / 2);
|
||||
y = x - x * (offset[i - 1] / 2) / 254 - dark[(i - 1) * 3 + j];
|
||||
|
@ -1515,8 +1515,9 @@ static void genesys_coarse_calibration(Genesys_Device* dev, Genesys_Sensor& sens
|
|||
std::vector<uint8_t> all_data_8(size * 4 / 2);
|
||||
unsigned int count;
|
||||
|
||||
for (count = 0; count < (unsigned int) (size * 4 / 2); count++)
|
||||
all_data_8[count] = all_data[count * 2 + 1];
|
||||
for (count = 0; count < static_cast<unsigned>(size * 4 / 2); count++) {
|
||||
all_data_8[count] = all_data[count * 2 + 1];
|
||||
}
|
||||
sanei_genesys_write_pnm_file("gl_coarse.pnm", all_data_8.data(), 8, channels, size / 6, 4);
|
||||
}
|
||||
|
||||
|
@ -1803,12 +1804,11 @@ static void genesys_white_shading_calibration(Genesys_Device* dev, const Genesys
|
|||
static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
|
||||
const Genesys_Sensor& sensor)
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "lines = %d", (unsigned int)dev->calib_lines);
|
||||
DBG_HELPER_ARGS(dbg, "lines = %zu", dev->calib_lines);
|
||||
size_t size;
|
||||
uint32_t pixels_per_line;
|
||||
uint8_t channels;
|
||||
unsigned int x;
|
||||
int y;
|
||||
uint32_t dark, white, dark_sum, white_sum, dark_count, white_count, col,
|
||||
dif;
|
||||
|
||||
|
@ -1880,7 +1880,7 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
|
|||
dark = 0xffff;
|
||||
white = 0;
|
||||
|
||||
for (y = 0; y < (int)dev->calib_lines; y++)
|
||||
for (std::size_t y = 0; y < dev->calib_lines; y++)
|
||||
{
|
||||
col = calibration_data[(x + y * pixels_per_line * channels) * 2];
|
||||
col |=
|
||||
|
@ -1904,7 +1904,7 @@ static void genesys_dark_white_shading_calibration(Genesys_Device* dev,
|
|||
white_count = 0;
|
||||
white_sum = 0;
|
||||
|
||||
for (y = 0; y < (int)dev->calib_lines; y++)
|
||||
for (std::size_t y = 0; y < dev->calib_lines; y++)
|
||||
{
|
||||
col = calibration_data[(x + y * pixels_per_line * channels) * 2];
|
||||
col |=
|
||||
|
@ -3379,10 +3379,10 @@ static void genesys_read_ordered_data(Genesys_Device* dev, SANE_Byte* destinatio
|
|||
debug_dump(DBG_info, dev->current_setup);
|
||||
debug_dump(DBG_info, dev->session.params);
|
||||
|
||||
DBG(DBG_info, "%s: frontend requested %lu bytes\n", __func__, (u_long) * len);
|
||||
DBG(DBG_info, "%s: frontend requested %zu bytes\n", __func__, *len);
|
||||
DBG(DBG_info, "%s: bytes_to_read=%zu, total_bytes_read=%zu\n", __func__,
|
||||
dev->total_bytes_to_read, dev->total_bytes_read);
|
||||
|
||||
DBG(DBG_info, "%s: bytes_to_read=%lu, total_bytes_read=%lu\n", __func__,
|
||||
(u_long) dev->total_bytes_to_read, (u_long) dev->total_bytes_read);
|
||||
/* is there data left to scan */
|
||||
if (dev->total_bytes_read >= dev->total_bytes_to_read)
|
||||
{
|
||||
|
@ -3463,7 +3463,7 @@ Problems with the first approach:
|
|||
}
|
||||
}
|
||||
|
||||
DBG(DBG_proc, "%s: completed, %lu bytes read\n", __func__, (u_long) bytes);
|
||||
DBG(DBG_proc, "%s: completed, %zu bytes read\n", __func__, bytes);
|
||||
}
|
||||
|
||||
|
||||
|
@ -3957,7 +3957,7 @@ static void init_options(Genesys_Scanner* s)
|
|||
|
||||
unsigned min_dpi = *std::min_element(resolutions.begin(), resolutions.end());
|
||||
|
||||
dpi_list = (SANE_Word*) malloc((resolutions.size() + 1) * sizeof(SANE_Word));
|
||||
dpi_list = reinterpret_cast<SANE_Word*>(std::malloc((resolutions.size() + 1) * sizeof(SANE_Word)));
|
||||
if (!dpi_list) {
|
||||
throw SaneException(SANE_STATUS_NO_MEM);
|
||||
}
|
||||
|
@ -4919,7 +4919,7 @@ sane_get_devices_impl(const SANE_Device *** device_list, SANE_Bool local_only)
|
|||
}
|
||||
s_sane_devices_ptrs->push_back(nullptr);
|
||||
|
||||
*((SANE_Device ***)device_list) = s_sane_devices_ptrs->data();
|
||||
*const_cast<SANE_Device***>(device_list) = s_sane_devices_ptrs->data();
|
||||
|
||||
return SANE_STATUS_GOOD;
|
||||
}
|
||||
|
@ -5122,10 +5122,12 @@ void sane_close(SANE_Handle handle)
|
|||
const SANE_Option_Descriptor *
|
||||
sane_get_option_descriptor_impl(SANE_Handle handle, SANE_Int option)
|
||||
{
|
||||
Genesys_Scanner *s = (Genesys_Scanner*) handle;
|
||||
Genesys_Scanner* s = reinterpret_cast<Genesys_Scanner*>(handle);
|
||||
|
||||
if (static_cast<unsigned>(option) >= NUM_OPTIONS) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ((unsigned) option >= NUM_OPTIONS)
|
||||
return 0;
|
||||
DBG(DBG_io2, "%s: option = %s (%d)\n", __func__, s->opt[option].name, option);
|
||||
return s->opt + option;
|
||||
}
|
||||
|
@ -5536,8 +5538,8 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
|||
}
|
||||
|
||||
/* assign new values */
|
||||
free((void *)(size_t)s->opt[OPT_TL_X].constraint.range);
|
||||
free((void *)(size_t)s->opt[OPT_TL_Y].constraint.range);
|
||||
std::free(reinterpret_cast<void*>(const_cast<SANE_Range*>(s->opt[OPT_TL_X].constraint.range)));
|
||||
std::free(reinterpret_cast<void*>(const_cast<SANE_Range*>(s->opt[OPT_TL_Y].constraint.range)));
|
||||
s->opt[OPT_TL_X].constraint.range = x_range;
|
||||
s->pos_top_left_x = 0;
|
||||
s->opt[OPT_TL_Y].constraint.range = y_range;
|
||||
|
@ -5663,7 +5665,7 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
|||
break;
|
||||
|
||||
case OPT_GAMMA_VECTOR:
|
||||
table = (SANE_Word *) val;
|
||||
table = reinterpret_cast<SANE_Word*>(val);
|
||||
option_size = s->opt[option].size / sizeof (SANE_Word);
|
||||
|
||||
s->dev->gamma_override_tables[GENESYS_RED].resize(option_size);
|
||||
|
@ -5676,7 +5678,7 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
|||
}
|
||||
break;
|
||||
case OPT_GAMMA_VECTOR_R:
|
||||
table = (SANE_Word *) val;
|
||||
table = reinterpret_cast<SANE_Word*>(val);
|
||||
option_size = s->opt[option].size / sizeof (SANE_Word);
|
||||
s->dev->gamma_override_tables[GENESYS_RED].resize(option_size);
|
||||
for (i = 0; i < option_size; i++) {
|
||||
|
@ -5684,7 +5686,7 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
|||
}
|
||||
break;
|
||||
case OPT_GAMMA_VECTOR_G:
|
||||
table = (SANE_Word *) val;
|
||||
table = reinterpret_cast<SANE_Word*>(val);
|
||||
option_size = s->opt[option].size / sizeof (SANE_Word);
|
||||
s->dev->gamma_override_tables[GENESYS_GREEN].resize(option_size);
|
||||
for (i = 0; i < option_size; i++) {
|
||||
|
@ -5692,7 +5694,7 @@ set_option_value (Genesys_Scanner * s, int option, void *val,
|
|||
}
|
||||
break;
|
||||
case OPT_GAMMA_VECTOR_B:
|
||||
table = (SANE_Word *) val;
|
||||
table = reinterpret_cast<SANE_Word*>(val);
|
||||
option_size = s->opt[option].size / sizeof (SANE_Word);
|
||||
s->dev->gamma_override_tables[GENESYS_BLUE].resize(option_size);
|
||||
for (i = 0; i < option_size; i++) {
|
||||
|
@ -5748,7 +5750,7 @@ SANE_Status
|
|||
sane_control_option_impl(SANE_Handle handle, SANE_Int option,
|
||||
SANE_Action action, void *val, SANE_Int * info)
|
||||
{
|
||||
Genesys_Scanner *s = (Genesys_Scanner*) handle;
|
||||
Genesys_Scanner* s = reinterpret_cast<Genesys_Scanner*>(handle);
|
||||
auto action_str = (action == SANE_ACTION_GET_VALUE) ? "get" :
|
||||
(action == SANE_ACTION_SET_VALUE) ? "set" :
|
||||
(action == SANE_ACTION_SET_AUTO) ? "set_auto" : "unknown";
|
||||
|
@ -5838,7 +5840,7 @@ SANE_Status sane_control_option(SANE_Handle handle, SANE_Int option,
|
|||
SANE_Status sane_get_parameters_impl(SANE_Handle handle, SANE_Parameters* params)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
Genesys_Scanner *s = (Genesys_Scanner*) handle;
|
||||
Genesys_Scanner* s = reinterpret_cast<Genesys_Scanner*>(handle);
|
||||
|
||||
/* don't recompute parameters once data reading is active, ie during scan */
|
||||
if (!s->dev->read_active) {
|
||||
|
@ -5874,7 +5876,7 @@ SANE_Status sane_get_parameters(SANE_Handle handle, SANE_Parameters* params)
|
|||
SANE_Status sane_start_impl(SANE_Handle handle)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
Genesys_Scanner *s = (Genesys_Scanner*) handle;
|
||||
Genesys_Scanner* s = reinterpret_cast<Genesys_Scanner*>(handle);
|
||||
SANE_Status status=SANE_STATUS_GOOD;
|
||||
|
||||
if (s->pos_top_left_x >= s->pos_bottom_right_x)
|
||||
|
@ -5963,7 +5965,7 @@ SANE_Status
|
|||
sane_read_impl(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int* len)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
Genesys_Scanner *s = (Genesys_Scanner*) handle;
|
||||
Genesys_Scanner* s = reinterpret_cast<Genesys_Scanner*>(handle);
|
||||
Genesys_Device *dev;
|
||||
size_t local_len;
|
||||
|
||||
|
@ -6001,8 +6003,8 @@ sane_read_impl(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int*
|
|||
}
|
||||
|
||||
DBG(DBG_proc, "%s: start, %d maximum bytes required\n", __func__, max_len);
|
||||
DBG(DBG_io2, "%s: bytes_to_read=%lu, total_bytes_read=%lu\n", __func__,
|
||||
(u_long) dev->total_bytes_to_read, (u_long) dev->total_bytes_read);
|
||||
DBG(DBG_io2, "%s: bytes_to_read=%zu, total_bytes_read=%zu\n", __func__,
|
||||
dev->total_bytes_to_read, dev->total_bytes_read);
|
||||
|
||||
if(dev->total_bytes_read>=dev->total_bytes_to_read)
|
||||
{
|
||||
|
@ -6049,7 +6051,7 @@ sane_read_impl(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int*
|
|||
|
||||
/* return data from lineart buffer if any, up to the available amount */
|
||||
local_len = max_len;
|
||||
if((size_t)max_len>dev->binarize_buffer.avail())
|
||||
if (static_cast<std::size_t>(max_len) > dev->binarize_buffer.avail())
|
||||
{
|
||||
local_len=dev->binarize_buffer.avail();
|
||||
}
|
||||
|
@ -6076,8 +6078,7 @@ sane_read_impl(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SANE_Int*
|
|||
}
|
||||
|
||||
*len = local_len;
|
||||
if(local_len>(size_t)max_len)
|
||||
{
|
||||
if (local_len > static_cast<std::size_t>(max_len)) {
|
||||
fprintf (stderr, "[genesys] sane_read: returning incorrect length!!\n");
|
||||
}
|
||||
DBG(DBG_proc, "%s: %d bytes returned\n", __func__, *len);
|
||||
|
@ -6095,7 +6096,7 @@ SANE_Status sane_read(SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, SAN
|
|||
void sane_cancel_impl(SANE_Handle handle)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
Genesys_Scanner *s = (Genesys_Scanner*) handle;
|
||||
Genesys_Scanner* s = reinterpret_cast<Genesys_Scanner*>(handle);
|
||||
|
||||
// end binary logging if needed
|
||||
if (s->dev->binary != nullptr) {
|
||||
|
@ -6144,7 +6145,7 @@ sane_set_io_mode_impl(SANE_Handle handle, SANE_Bool non_blocking)
|
|||
{
|
||||
DBG_HELPER_ARGS(dbg, "handle = %p, non_blocking = %s", handle,
|
||||
non_blocking == SANE_TRUE ? "true" : "false");
|
||||
Genesys_Scanner *s = (Genesys_Scanner*) handle;
|
||||
Genesys_Scanner* s = reinterpret_cast<Genesys_Scanner*>(handle);
|
||||
|
||||
if (!s->scanning)
|
||||
{
|
||||
|
@ -6168,7 +6169,7 @@ sane_set_io_mode(SANE_Handle handle, SANE_Bool non_blocking)
|
|||
SANE_Status
|
||||
sane_get_select_fd_impl(SANE_Handle handle, SANE_Int * fd)
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "handle = %p, fd = %p", handle, (void *) fd);
|
||||
DBG_HELPER_ARGS(dbg, "handle = %p, fd = %p", handle, reinterpret_cast<void*>(fd));
|
||||
Genesys_Scanner *s = (Genesys_Scanner*) handle;
|
||||
|
||||
if (!s->scanning)
|
||||
|
|
|
@ -55,27 +55,27 @@
|
|||
|
||||
bool CommandSetGl124::get_fast_feed_bit(Genesys_Register_Set* regs) const
|
||||
{
|
||||
return (bool)(regs->get8(REG02) & REG02_FASTFED);
|
||||
return static_cast<bool>(regs->get8(REG02) & REG02_FASTFED);
|
||||
}
|
||||
|
||||
bool CommandSetGl124::get_filter_bit(Genesys_Register_Set* regs) const
|
||||
{
|
||||
return (bool)(regs->get8(REG04) & REG04_FILTER);
|
||||
return static_cast<bool>(regs->get8(REG04) & REG04_FILTER);
|
||||
}
|
||||
|
||||
bool CommandSetGl124::get_lineart_bit(Genesys_Register_Set* regs) const
|
||||
{
|
||||
return (bool)(regs->get8(REG04) & REG04_LINEART);
|
||||
return static_cast<bool>(regs->get8(REG04) & REG04_LINEART);
|
||||
}
|
||||
|
||||
bool CommandSetGl124::get_bitset_bit(Genesys_Register_Set* regs) const
|
||||
{
|
||||
return (bool)(regs->get8(REG04) & REG04_BITSET);
|
||||
return static_cast<bool>(regs->get8(REG04) & REG04_BITSET);
|
||||
}
|
||||
|
||||
bool CommandSetGl124::get_gain4_bit(Genesys_Register_Set* regs) const
|
||||
{
|
||||
return (bool)(regs->get8(REG06) & REG06_GAIN4);
|
||||
return static_cast<bool>(regs->get8(REG06) & REG06_GAIN4);
|
||||
}
|
||||
|
||||
bool CommandSetGl124::test_buffer_empty_bit(SANE_Byte val) const
|
||||
|
@ -1029,8 +1029,8 @@ static void gl124_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->total_bytes_read = 0;
|
||||
dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send to frontend = %lu\n", __func__,
|
||||
(u_long) dev->total_bytes_to_read);
|
||||
DBG(DBG_info, "%s: total bytes to send to frontend = %zu\n", __func__,
|
||||
dev->total_bytes_to_read);
|
||||
}
|
||||
|
||||
void CommandSetGl124::calculate_current_setup(Genesys_Device * dev,
|
||||
|
@ -1777,7 +1777,7 @@ void CommandSetGl124::send_shading_data(Genesys_Device* dev, const Genesys_Senso
|
|||
uint8_t *ptr, *src;
|
||||
|
||||
/* logical size of a color as seen by generic code of the frontend */
|
||||
length = (uint32_t) (size / 3);
|
||||
length = size / 3;
|
||||
std::uint32_t strpixel = dev->session.pixel_startx;
|
||||
std::uint32_t endpixel = dev->session.pixel_endx;
|
||||
segcnt = dev->reg.get24(REG_SEGCNT);
|
||||
|
@ -2362,7 +2362,7 @@ void CommandSetGl124::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
}
|
||||
max[j] = max[j] / (pixels/2);
|
||||
|
||||
gain[j] = ((float) sensor.gain_white_ref*coeff) / max[j];
|
||||
gain[j] = (static_cast<float>(sensor.gain_white_ref) * coeff) / max[j];
|
||||
|
||||
/* turn logical gain value into gain code, checking for overflow */
|
||||
code = 283 - 208 / gain[j];
|
||||
|
|
|
@ -1227,10 +1227,9 @@ void CommandSetGl646::set_powersaving(Genesys_Device* dev, int delay /* in minut
|
|||
local_reg.find_reg(0x03).value = (local_reg.get8(0x03) & 0xf0) | 0x0f; /* enable lampdog and set lamptime = 7 */
|
||||
|
||||
time = delay * 1000 * 60; /* -> msec */
|
||||
exposure_time =
|
||||
(uint32_t) (time * 32000.0 /
|
||||
exposure_time = static_cast<std::uint32_t>((time * 32000.0 /
|
||||
(24.0 * 64.0 * (local_reg.get8(0x03) & REG03_LAMPTIM) *
|
||||
1024.0) + 0.5);
|
||||
1024.0) + 0.5));
|
||||
/* 32000 = system clock, 24 = clocks per pixel */
|
||||
rate = (exposure_time + 65536) / 65536;
|
||||
if (rate > 4)
|
||||
|
@ -1415,8 +1414,8 @@ void CommandSetGl646::detect_document_end(Genesys_Device* dev) const
|
|||
* total_bytes_read is the number of bytes sent to frontend
|
||||
* read_bytes_left is the number of bytes to read from the scanner
|
||||
*/
|
||||
DBG(DBG_io, "%s: total_bytes_to_read=%lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
DBG(DBG_io, "%s: total_bytes_read =%lu\n", __func__, (u_long) dev->total_bytes_read);
|
||||
DBG(DBG_io, "%s: total_bytes_to_read=%zu\n", __func__, dev->total_bytes_to_read);
|
||||
DBG(DBG_io, "%s: total_bytes_read =%zu\n", __func__, dev->total_bytes_read);
|
||||
|
||||
// amount of data available from scanner is what to scan
|
||||
sanei_genesys_read_valid_words(dev, &bytes_left);
|
||||
|
@ -1435,8 +1434,8 @@ void CommandSetGl646::detect_document_end(Genesys_Device* dev) const
|
|||
dev->get_pipeline_source().set_remaining_bytes(bytes_left);
|
||||
dev->total_bytes_to_read = dev->total_bytes_read + bytes_left;
|
||||
}
|
||||
DBG(DBG_io, "%s: total_bytes_to_read=%lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
DBG(DBG_io, "%s: total_bytes_read =%lu\n", __func__, (u_long) dev->total_bytes_read);
|
||||
DBG(DBG_io, "%s: total_bytes_to_read=%zu\n", __func__, dev->total_bytes_to_read);
|
||||
DBG(DBG_io, "%s: total_bytes_read =%zu\n", __func__, dev->total_bytes_read);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2386,7 +2385,7 @@ static void ad_fe_offset_calibration(Genesys_Device* dev, const Genesys_Sensor&
|
|||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
char title[30];
|
||||
snprintf(title, 30, "gl646_offset%03d.pnm", (int)bottom);
|
||||
std::snprintf(title, 30, "gl646_offset%03d.pnm", static_cast<int>(bottom));
|
||||
sanei_genesys_write_pnm_file (title, line.data(), 8, channels,
|
||||
settings.pixels, settings.lines);
|
||||
}
|
||||
|
@ -2624,7 +2623,7 @@ static void ad_fe_coarse_gain_calibration(Genesys_Device* dev, const Genesys_Sen
|
|||
/* log scanning data */
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
sprintf (title, "gl646_alternative_gain%02d.pnm", (int)pass);
|
||||
sprintf (title, "gl646_alternative_gain%02d.pnm", pass);
|
||||
sanei_genesys_write_pnm_file(title, line.data(), 8, channels, settings.pixels,
|
||||
settings.lines);
|
||||
}
|
||||
|
@ -2757,7 +2756,7 @@ void CommandSetGl646::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
/* log scanning data */
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
sprintf (title, "gl646_gain%02d.pnm", (int)pass);
|
||||
std::sprintf(title, "gl646_gain%02d.pnm", pass);
|
||||
sanei_genesys_write_pnm_file(title, line.data(), 8, channels, settings.pixels,
|
||||
settings.lines);
|
||||
}
|
||||
|
@ -3444,8 +3443,8 @@ static void write_control(Genesys_Device* dev, const Genesys_Sensor& sensor, int
|
|||
{
|
||||
case MotorId::XP200:
|
||||
/* we put scan's dpi, not motor one */
|
||||
control[0] = LOBYTE (resolution);
|
||||
control[1] = HIBYTE (resolution);
|
||||
control[0] = resolution & 0xff;
|
||||
control[1] = (resolution >> 8) & 0xff;
|
||||
control[2] = dev->control[4];
|
||||
control[3] = dev->control[5];
|
||||
break;
|
||||
|
@ -3503,7 +3502,8 @@ bool CommandSetGl646::is_compatible_calibration(Genesys_Device* dev, const Genes
|
|||
* requested scan. In the case of CIS scanners, dpi isn't a criteria */
|
||||
if (!dev->model->is_cis) {
|
||||
compatible = (dev->session.params.channels == cache->params.channels) &&
|
||||
(((int) dev->current_setup.xres) == ((int) cache->used_setup.xres));
|
||||
(static_cast<int>(dev->current_setup.xres) ==
|
||||
static_cast<int>(cache->used_setup.xres));
|
||||
} else {
|
||||
compatible = dev->session.params.channels == cache->params.channels;
|
||||
}
|
||||
|
@ -3592,8 +3592,7 @@ void CommandSetGl646::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
sprintf (title, "gl646_search_strip_%s%02d.pnm", forward ? "fwd" : "bwd",
|
||||
(int)pass);
|
||||
std::sprintf(title, "gl646_search_strip_%s%02d.pnm", forward ? "fwd" : "bwd", pass);
|
||||
sanei_genesys_write_pnm_file (title, data.data(), settings.depth, 1,
|
||||
settings.pixels, settings.lines);
|
||||
}
|
||||
|
|
|
@ -1825,7 +1825,7 @@ dummy \ scanned lines
|
|||
dev->total_bytes_read = 0;
|
||||
dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
DBG(DBG_info, "%s: total bytes to send = %zu\n", __func__, dev->total_bytes_to_read);
|
||||
}
|
||||
|
||||
void CommandSetGl841::calculate_current_setup(Genesys_Device * dev,
|
||||
|
@ -2045,8 +2045,7 @@ void CommandSetGl841::set_powersaving(Genesys_Device* dev, int delay /* in minut
|
|||
}
|
||||
|
||||
time = delay * 1000 * 60; /* -> msec */
|
||||
exposure_time =
|
||||
(uint32_t) (time * 32000.0 /
|
||||
exposure_time = static_cast<std::uint32_t>(time * 32000.0 /
|
||||
(24.0 * 64.0 * (local_reg.find_reg(0x03).value & REG03_LAMPTIM) *
|
||||
1024.0) + 0.5);
|
||||
/* 32000 = system clock, 24 = clocks per pixel */
|
||||
|
@ -2678,7 +2677,7 @@ void CommandSetGl841::init_regs_for_coarse_calibration(Genesys_Device* dev,
|
|||
void CommandSetGl841::init_regs_for_shading(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||
Genesys_Register_Set& regs) const
|
||||
{
|
||||
DBG_HELPER_ARGS(dbg, "lines = %d", (int)(dev->calib_lines));
|
||||
DBG_HELPER_ARGS(dbg, "lines = %zu", dev->calib_lines);
|
||||
SANE_Int ydpi;
|
||||
float starty=0;
|
||||
|
||||
|
@ -3725,7 +3724,7 @@ void CommandSetGl841::init_regs_for_warmup(Genesys_Device* dev, const Genesys_Se
|
|||
int* total_size) const
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
int num_pixels = (int) (4 * 300);
|
||||
int num_pixels = 4 * 300;
|
||||
*local_reg = dev->reg;
|
||||
|
||||
/* okay.. these should be defaults stored somewhere */
|
||||
|
@ -4210,7 +4209,7 @@ void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Senso
|
|||
}
|
||||
|
||||
/* data is whole line, we extract only the part for the scanned area */
|
||||
length = (uint32_t) (size / 3);
|
||||
length = static_cast<std::uint32_t>(size / 3);
|
||||
unsigned strpixel = dev->session.pixel_startx;
|
||||
unsigned endpixel = dev->session.pixel_endx;
|
||||
|
||||
|
@ -4225,7 +4224,7 @@ void CommandSetGl841::send_shading_data(Genesys_Device* dev, const Genesys_Senso
|
|||
/* binary data logging */
|
||||
if(DBG_LEVEL>=DBG_data)
|
||||
{
|
||||
dev->binary=fopen("binary.pnm","wb");
|
||||
dev->binary = std::fopen("binary.pnm","wb");
|
||||
lines = dev->reg.get24(REG_LINCNT);
|
||||
channels = dev->session.params.channels;
|
||||
if (dev->binary != nullptr) {
|
||||
|
|
|
@ -1314,7 +1314,7 @@ static void gl843_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->total_bytes_read = 0;
|
||||
dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
DBG(DBG_info, "%s: total bytes to send = %zu\n", __func__, dev->total_bytes_to_read);
|
||||
}
|
||||
|
||||
void CommandSetGl843::calculate_current_setup(Genesys_Device * dev,
|
||||
|
@ -2812,7 +2812,8 @@ void CommandSetGl843::offset_calibration(Genesys_Device* dev, const Genesys_Sens
|
|||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
sanei_genesys_write_file("gl843_offset_all_desc.txt",
|
||||
(uint8_t*) debug_image_info.data(), debug_image_info.size());
|
||||
reinterpret_cast<const std::uint8_t*>(debug_image_info.data()),
|
||||
debug_image_info.size());
|
||||
sanei_genesys_write_pnm_file("gl843_offset_all.pnm",
|
||||
debug_image.data(), bpp, channels, pixels, debug_image_lines);
|
||||
}
|
||||
|
@ -2945,7 +2946,7 @@ void CommandSetGl843::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
dev->frontend.set_gain(ch, code);
|
||||
|
||||
DBG(DBG_proc, "%s: channel %d, max=%d, target=%d, setting:%d\n", __func__, ch, curr_output,
|
||||
(int) target_value, code);
|
||||
static_cast<int>(target_value), code);
|
||||
}
|
||||
|
||||
if (dev->model->is_cis) {
|
||||
|
@ -3297,8 +3298,8 @@ void CommandSetGl843::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
char fn[40];
|
||||
snprintf(fn, 40, "gl843_search_strip_%s_%s%02d.pnm",
|
||||
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
|
||||
std::snprintf(fn, 40, "gl843_search_strip_%s_%s%02d.pnm",
|
||||
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
|
||||
sanei_genesys_write_pnm_file(fn, data);
|
||||
}
|
||||
|
||||
|
|
|
@ -879,7 +879,7 @@ static void gl846_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->total_bytes_read = 0;
|
||||
dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
DBG(DBG_info, "%s: total bytes to send = %zu\n", __func__, dev->total_bytes_to_read);
|
||||
}
|
||||
|
||||
void CommandSetGl846::calculate_current_setup(Genesys_Device* dev,
|
||||
|
@ -1391,8 +1391,8 @@ void CommandSetGl846::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
if(dev->calib_resolution==4800)
|
||||
dev->calib_lines *= 2;
|
||||
dev->calib_pixels = (sensor.sensor_pixels*dev->calib_resolution)/sensor.optical_res;
|
||||
DBG(DBG_io, "%s: calib_lines = %d\n", __func__, (unsigned int)dev->calib_lines);
|
||||
DBG(DBG_io, "%s: calib_pixels = %d\n", __func__, (unsigned int)dev->calib_pixels);
|
||||
DBG(DBG_io, "%s: calib_lines = %zu\n", __func__, dev->calib_lines);
|
||||
DBG(DBG_io, "%s: calib_pixels = %zu\n", __func__, dev->calib_pixels);
|
||||
|
||||
/* this is aworkaround insufficent distance for slope
|
||||
* motor acceleration TODO special motor slope for shading */
|
||||
|
@ -1537,7 +1537,7 @@ void CommandSetGl846::send_shading_data(Genesys_Device* dev, const Genesys_Senso
|
|||
write(0x1003e000,0x00000dd8)
|
||||
write(0x10068000,0x00000dd8)
|
||||
*/
|
||||
length = (uint32_t) (size / 3);
|
||||
length = static_cast<uint32_t>(size / 3);
|
||||
unsigned strpixel = dev->session.pixel_startx;
|
||||
unsigned endpixel = dev->session.pixel_endx;
|
||||
|
||||
|
@ -1549,7 +1549,7 @@ void CommandSetGl846::send_shading_data(Genesys_Device* dev, const Genesys_Senso
|
|||
|
||||
if(DBG_LEVEL>=DBG_data)
|
||||
{
|
||||
dev->binary=fopen("binary.pnm","wb");
|
||||
dev->binary = std::fopen("binary.pnm", "wb");
|
||||
lines = dev->reg.get24(REG_LINCNT);
|
||||
unsigned channels = dev->session.params.channels;
|
||||
if (dev->binary != nullptr) {
|
||||
|
@ -2008,8 +2008,8 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
pass = 0;
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
|
||||
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
|
||||
std::sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
|
||||
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
|
||||
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
|
||||
}
|
||||
|
||||
|
@ -2031,8 +2031,8 @@ void CommandSetGl846::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
|
||||
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
|
||||
std::sprintf(title, "gl846_search_strip_%s_%s%02d.pnm",
|
||||
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
|
||||
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
|
||||
}
|
||||
|
||||
|
@ -2391,7 +2391,7 @@ void CommandSetGl846::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
}
|
||||
max[j] = max[j] / (pixels/2);
|
||||
|
||||
gain[j] = ((float) sensor.gain_white_ref*coeff) / max[j];
|
||||
gain[j] = (static_cast<float>(sensor.gain_white_ref) * coeff) / max[j];
|
||||
|
||||
/* turn logical gain value into gain code, checking for overflow */
|
||||
code = 283 - 208 / gain[j];
|
||||
|
|
|
@ -881,8 +881,7 @@ static void gl847_init_scan_regs(Genesys_Device* dev, const Genesys_Sensor& sens
|
|||
dev->total_bytes_read = 0;
|
||||
dev->total_bytes_to_read = session.output_line_bytes_requested * session.params.lines;
|
||||
|
||||
DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read);
|
||||
/* END TODO */
|
||||
DBG(DBG_info, "%s: total bytes to send = %zu\n", __func__, dev->total_bytes_to_read);
|
||||
}
|
||||
|
||||
void CommandSetGl847::calculate_current_setup(Genesys_Device * dev,
|
||||
|
@ -1432,8 +1431,8 @@ void CommandSetGl847::init_regs_for_shading(Genesys_Device* dev, const Genesys_S
|
|||
if(dev->calib_resolution==4800)
|
||||
dev->calib_lines *= 2;
|
||||
dev->calib_pixels = (sensor.sensor_pixels*dev->calib_resolution)/sensor.optical_res;
|
||||
DBG(DBG_io, "%s: calib_lines = %d\n", __func__, (int)dev->calib_lines);
|
||||
DBG(DBG_io, "%s: calib_pixels = %d\n", __func__, (int)dev->calib_pixels);
|
||||
DBG(DBG_io, "%s: calib_lines = %zu\n", __func__, dev->calib_lines);
|
||||
DBG(DBG_io, "%s: calib_pixels = %zu\n", __func__, dev->calib_pixels);
|
||||
|
||||
/* this is aworkaround insufficent distance for slope
|
||||
* motor acceleration TODO special motor slope for shading */
|
||||
|
@ -1589,7 +1588,7 @@ void CommandSetGl847::send_shading_data(Genesys_Device* dev, const Genesys_Senso
|
|||
|
||||
if(DBG_LEVEL>=DBG_data)
|
||||
{
|
||||
dev->binary=fopen("binary.pnm","wb");
|
||||
dev->binary = std::fopen("binary.pnm", "wb");
|
||||
lines = dev->reg.get24(REG_LINCNT);
|
||||
unsigned channels = dev->session.params.channels;
|
||||
if (dev->binary != nullptr) {
|
||||
|
@ -2084,8 +2083,8 @@ void CommandSetGl847::search_strip(Genesys_Device* dev, const Genesys_Sensor& se
|
|||
pass = 0;
|
||||
if (DBG_LEVEL >= DBG_data)
|
||||
{
|
||||
sprintf(title, "gl847_search_strip_%s_%s%02d.pnm",
|
||||
black ? "black" : "white", forward ? "fwd" : "bwd", (int)pass);
|
||||
std::sprintf(title, "gl847_search_strip_%s_%s%02d.pnm",
|
||||
black ? "black" : "white", forward ? "fwd" : "bwd", pass);
|
||||
sanei_genesys_write_pnm_file(title, data.data(), depth, channels, pixels, lines);
|
||||
}
|
||||
|
||||
|
@ -2479,7 +2478,7 @@ void CommandSetGl847::coarse_gain_calibration(Genesys_Device* dev, const Genesys
|
|||
}
|
||||
max[j] = max[j] / (pixels/2);
|
||||
|
||||
gain[j] = ((float) sensor.gain_white_ref*coeff) / max[j];
|
||||
gain[j] = (static_cast<float>(sensor.gain_white_ref) * coeff) / max[j];
|
||||
|
||||
/* turn logical gain value into gain code, checking for overflow */
|
||||
code = 283 - 208 / gain[j];
|
||||
|
|
|
@ -84,7 +84,7 @@ void sanei_genesys_init_cmd_set(Genesys_Device* dev)
|
|||
/* General IO and debugging functions */
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
void sanei_genesys_write_file(const char* filename, uint8_t* data, size_t length)
|
||||
void sanei_genesys_write_file(const char* filename, const std::uint8_t* data, size_t length)
|
||||
{
|
||||
DBG_HELPER(dbg);
|
||||
FILE *out;
|
||||
|
@ -286,9 +286,9 @@ void sanei_genesys_bulk_read_data(Genesys_Device * dev, uint8_t addr, uint8_t* d
|
|||
}
|
||||
|
||||
if (is_addr_used) {
|
||||
DBG(DBG_io, "%s: requesting %lu bytes from 0x%02x addr\n", __func__, (u_long) len, addr);
|
||||
DBG(DBG_io, "%s: requesting %zu bytes from 0x%02x addr\n", __func__, len, addr);
|
||||
} else {
|
||||
DBG(DBG_io, "%s: requesting %lu bytes\n", __func__, (u_long) len);
|
||||
DBG(DBG_io, "%s: requesting %zu bytes\n", __func__, len);
|
||||
}
|
||||
|
||||
if (len == 0)
|
||||
|
@ -320,12 +320,11 @@ void sanei_genesys_bulk_read_data(Genesys_Device * dev, uint8_t addr, uint8_t* d
|
|||
sanei_genesys_bulk_read_data_send_header(dev, size);
|
||||
}
|
||||
|
||||
DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) size);
|
||||
DBG(DBG_io2, "%s: trying to read %zu bytes of data\n", __func__, size);
|
||||
|
||||
dev->usb_dev.bulk_read(data, &size);
|
||||
|
||||
DBG(DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__,
|
||||
(u_long) size, (u_long) (target - size));
|
||||
DBG(DBG_io2, "%s: read %zu bytes, %zu remaining\n", __func__, size, target - size);
|
||||
|
||||
target -= size;
|
||||
data += size;
|
||||
|
|
|
@ -408,7 +408,7 @@ extern void sanei_genesys_search_reference_point(Genesys_Device* dev, Genesys_Se
|
|||
const uint8_t* src_data, int start_pixel, int dpi,
|
||||
int width, int height);
|
||||
|
||||
extern void sanei_genesys_write_file(const char* filename, uint8_t* data, size_t length);
|
||||
extern void sanei_genesys_write_file(const char* filename, const std::uint8_t* data, size_t length);
|
||||
|
||||
extern void sanei_genesys_write_pnm_file(const char* filename, const std::uint8_t* data, int depth,
|
||||
int channels, int pixels_per_line, int lines);
|
||||
|
|
Ładowanie…
Reference in New Issue