diff --git a/backend/genesys.c b/backend/genesys.c index 76b08f051..06102f55e 100644 --- a/backend/genesys.c +++ b/backend/genesys.c @@ -204,10 +204,8 @@ sanei_genesys_init_structs (Genesys_Device * dev) /* sanity check */ if (sensor_ok == 0 || motor_ok == 0 || gpo_ok == 0) { - DBG (DBG_error0, - "sanei_genesys_init_structs: bad description(s) for ccd/gpo/motor=%d/%d/%d\n", - dev->model->ccd_type, dev->model->gpo_type, - dev->model->motor_type); + DBG(DBG_error0, "%s: bad description(s) for ccd/gpo/motor=%d/%d/%d\n", __func__, + dev->model->ccd_type, dev->model->gpo_type, dev->model->motor_type); } /* set up initial line distance shift */ @@ -230,11 +228,9 @@ sanei_genesys_init_fe (Genesys_Device * dev) return; } } - DBG (DBG_error0, - "sanei_genesys_init_fe: failed to find description for dac_type %d\n", - dev->model->dac_type); - DBG (DBG_info, "sanei_genesys_init_fe: dac_type %d set up\n", - dev->model->dac_type); + DBG(DBG_error0, "%s: failed to find description for dac_type %d\n", __func__, + dev->model->dac_type); + DBG(DBG_info, "%s: dac_type %d set up\n", __func__, dev->model->dac_type); DBGCOMPLETED; } @@ -284,16 +280,12 @@ sanei_genesys_generate_slope_table (uint16_t * slope_table, if (!vfinal) vfinal = &_vfinal; - DBG (DBG_proc, "sanei_genesys_generate_slope_table: table size: %d\n", - max_steps); + DBG(DBG_proc, "%s: table size: %d\n", __func__, max_steps); - DBG (DBG_proc, - "sanei_genesys_generate_slope_table: stop at time: %d, use %d steps max\n", - stop_at, use_steps); + DBG(DBG_proc, "%s: stop at time: %d, use %d steps max\n", __func__, stop_at, use_steps); - DBG (DBG_proc, - "sanei_genesys_generate_slope_table: target slope: " - "vstart: %d, vend: %d, steps: %d, g: %g\n", vstart, vend, steps, g); + DBG(DBG_proc, "%s: target slope: vstart: %d, vend: %d, steps: %d, g: %g\n", __func__, vstart, + vend, steps, g); sum = 0; c = 0; @@ -317,10 +309,8 @@ sanei_genesys_generate_slope_table (uint16_t * slope_table, } if (t2 > stop_at) { - DBG (DBG_warn, "Can not reach target speed(%d) in %d steps.\n", - stop_at, use_steps); - DBG (DBG_warn, "Expect image to be distorted. " - "Ignore this if only feeding.\n"); + DBG(DBG_warn, "Can not reach target speed(%d) in %d steps.\n", stop_at, use_steps); + DBG(DBG_warn, "Expect image to be distorted. Ignore this if only feeding.\n"); } *vfinal = t2; *used_steps += i; @@ -338,9 +328,7 @@ sanei_genesys_generate_slope_table (uint16_t * slope_table, (*used_steps)++; sum += *vfinal; - DBG (DBG_proc, - "sanei_genesys_generate_slope_table: returns sum=%d, used %d steps, completed\n", - sum, *used_steps); + DBG(DBG_proc, "%s: returns sum=%d, used %d steps, completed\n", __func__, sum, *used_steps); return sum; } @@ -385,10 +373,8 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev, unsigned int vstart; unsigned int vfinal; - DBG (DBG_proc, - "%s: step_type = %d, " - "exposure_time = %d, yres = %g, power_mode = %d\n", __func__, step_type, - exposure_time, yres, power_mode); + DBG(DBG_proc, "%s: step_type = %d, exposure_time = %d, yres = %g, power_mode = %d\n", __func__, + step_type, exposure_time, yres, power_mode); /* final speed */ vtarget = (exposure_time * yres) / dev->motor.base_ydpi; @@ -422,9 +408,7 @@ sanei_genesys_create_slope_table3 (Genesys_Device * dev, if (final_exposure) *final_exposure = (vfinal * dev->motor.base_ydpi) / yres; - DBG (DBG_proc, - "sanei_genesys_create_slope_table: returns sum_time=%d, completed\n", - sum_time); + DBG(DBG_proc, "%s: returns sum_time=%d, completed\n", __func__, sum_time); return sum_time; } @@ -444,10 +428,9 @@ genesys_create_slope_table2 (Genesys_Device * dev, int vstart, vend; int i; - DBG (DBG_proc, - "sanei_genesys_create_slope_table2: %d steps, step_type = %d, " - "exposure_time = %d, same_speed = %d, yres = %.2f, power_mode = %d\n", - steps, step_type, exposure_time, same_speed, yres, power_mode); + DBG(DBG_proc, "%s: %d steps, step_type = %d, " + "exposure_time = %d, same_speed = %d, yres = %.2f, power_mode = %d\n", __func__, steps, + step_type, exposure_time, same_speed, yres, power_mode); /* start speed */ if (dev->model->motor_type == MOTOR_5345) @@ -546,8 +529,7 @@ genesys_create_slope_table2 (Genesys_Device * dev, } } - DBG (DBG_proc, - "sanei_genesys_create_slope_table2: returns sum=%d, completed\n", sum); + DBG(DBG_proc, "%s: returns sum=%d, completed\n", __func__, sum); return sum; } @@ -576,11 +558,9 @@ sanei_genesys_create_slope_table (Genesys_Device * dev, step_type, exposure_time, same_speed, yres, power_mode); - DBG (DBG_proc, - "sanei_genesys_create_slope_table: %d steps, step_type = %d, " - "exposure_time = %d, same_speed =%d\n", steps, step_type, - exposure_time, same_speed); - DBG (DBG_proc, "sanei_genesys_create_slope_table: yres = %.2f\n", yres); + DBG(DBG_proc, "%s: %d steps, step_type = %d, exposure_time = %d, same_speed =%d\n", __func__, + steps, step_type, exposure_time, same_speed); + DBG(DBG_proc, "%s: yres = %.2f\n", __func__, yres); g = 0.6; start_speed = 0.01; @@ -603,9 +583,7 @@ sanei_genesys_create_slope_table (Genesys_Device * dev, DBG (DBG_io, "slope_table[%d] = %d\n", i, time_period); } - DBG (DBG_info, - "sanei_genesys_create_slope_table: returns sum_time=%d, completed\n", - sum_time); + DBG(DBG_info, "%s: returns sum_time=%d, completed\n", __func__, sum_time); return sum_time; } @@ -688,9 +666,7 @@ sanei_genesys_create_slope_table (Genesys_Device * dev, DBG (DBG_io, "slope_table[%d] = %d\n", i, time_period); } - DBG (DBG_proc, - "sanei_genesys_create_slope_table: returns sum_time=%d, completed\n", - sum_time); + DBG(DBG_proc, "%s: returns sum_time=%d, completed\n", __func__, sum_time); return sum_time; } @@ -718,9 +694,7 @@ sanei_genesys_create_slope_table (Genesys_Device * dev, DBG (DBG_io, "slope_table[%d] = %d\n", i, slope_table[i]); } - DBG (DBG_proc, - "sanei_genesys_create_slope_table: returns sum_time=%d, completed\n", - sum_time); + DBG(DBG_proc, "%s: returns sum_time=%d, completed\n", __func__, sum_time); return sum_time; } @@ -744,13 +718,11 @@ sanei_genesys_create_gamma_table (uint16_t * gamma_table, int size, if(gamma_table==NULL) { - DBG (DBG_proc, "sanei_genesys_create_gamma_table: gamma table is NULL\n"); + DBG(DBG_proc, "%s: gamma table is NULL\n", __func__); return; } - DBG (DBG_proc, - "sanei_genesys_create_gamma_table: size = %d, " - "maximum = %g, gamma_max = %g, gamma = %g\n", - size, maximum, gamma_max, gamma); + DBG(DBG_proc, "%s: size = %d, ""maximum = %g, gamma_max = %g, gamma = %g\n", __func__, size, + maximum, gamma_max, gamma); for (i = 0; i < size; i++) { value = gamma_max * pow ((float) i / size, 1.0 / gamma); @@ -758,7 +730,7 @@ sanei_genesys_create_gamma_table (uint16_t * gamma_table, int size, value = maximum; gamma_table[i] = value; } - DBG (DBG_proc, "sanei_genesys_create_gamma_table: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); } @@ -791,8 +763,8 @@ sanei_genesys_exposure_time2 (Genesys_Device * dev, float ydpi, if (exposure < exposure_by_led && dev->model->is_cis) exposure = exposure_by_led; - DBG (DBG_info, "%s: ydpi=%d, step=%d, endpixel=%d led=%d, power=%d => exposure=%d\n", - __func__, (int)ydpi, step_type, endpixel, exposure_by_led, power_mode, exposure); + DBG(DBG_info, "%s: ydpi=%d, step=%d, endpixel=%d led=%d, power=%d => exposure=%d\n", __func__, + (int)ydpi, step_type, endpixel, exposure_by_led, power_mode, exposure); return exposure; } @@ -925,7 +897,7 @@ genesys_send_offset_and_shading (Genesys_Device * dev, uint8_t * data, int start_address; SANE_Status status; - DBG (DBG_proc, "%s: (size = %d)\n", __func__, size); + DBG(DBG_proc, "%s: (size = %d)\n", __func__, size); /* ASIC higher than gl843 doesn't have register 2A/2B, so we route to * a per ASIC shading data loading function if available. @@ -975,16 +947,14 @@ genesys_send_offset_and_shading (Genesys_Device * dev, uint8_t * data, status = sanei_genesys_set_buffer_address (dev, start_address); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set buffer address: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); return status; } status = dev->model->cmd_set->bulk_write_data (dev, 0x3c, data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading table: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send shading table: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1011,8 +981,7 @@ sanei_genesys_init_shading_data (Genesys_Device * dev, int pixels_per_line) || dev->model->cmd_set->send_shading_data!=NULL) return SANE_STATUS_GOOD; - DBG (DBG_proc, "sanei_genesys_init_shading_data (pixels_per_line = %d)\n", - pixels_per_line); + DBG(DBG_proc, "%s (pixels_per_line = %d)\n", __func__, pixels_per_line); if (dev->settings.scan_mode >= 2) /* 3 pass or single pass color */ channels = 3; @@ -1022,8 +991,7 @@ sanei_genesys_init_shading_data (Genesys_Device * dev, int pixels_per_line) shading_data = malloc (pixels_per_line * 4 * channels); /* 16 bit black, 16 bit white */ if (!shading_data) { - DBG (DBG_error, - "sanei_genesys_init_shading_data: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -1043,7 +1011,7 @@ sanei_genesys_init_shading_data (Genesys_Device * dev, int pixels_per_line) free (shading_data); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading data: %s\n", __func__, + DBG(DBG_error, "%s: failed to send shading data: %s\n", __func__, sane_strstatus (status)); } @@ -1075,8 +1043,7 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, uint8_t * data, image = malloc (size); if (!image) { - DBG (DBG_error, - "sanei_genesys_search_reference_point: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -1204,9 +1171,8 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, uint8_t * data, * will be moved into device struct if more such values are needed */ top += 10; dev->model->y_offset_calib = SANE_FIX ((top * MM_PER_INCH) / dpi); - DBG (DBG_info, - "sanei_genesys_search_reference_point: black stripe y_offset = %f mm \n", - SANE_UNFIX (dev->model->y_offset_calib)); + DBG(DBG_info, "%s: black stripe y_offset = %f mm \n", __func__, + SANE_UNFIX (dev->model->y_offset_calib)); } /* find white corner in dark area : TODO yet another flag */ @@ -1229,15 +1195,13 @@ sanei_genesys_search_reference_point (Genesys_Device * dev, uint8_t * data, } top = top / count; dev->model->y_offset_calib = SANE_FIX ((top * MM_PER_INCH) / dpi); - DBG (DBG_info, - "sanei_genesys_search_reference_point: white corner y_offset = %f mm\n", - SANE_UNFIX (dev->model->y_offset_calib)); + DBG(DBG_info, "%s: white corner y_offset = %f mm\n", __func__, + SANE_UNFIX (dev->model->y_offset_calib)); } free (image); - DBG (DBG_proc, - "sanei_genesys_search_reference_point: CCD_start_xoffset = %d, left = %d, top = %d\n", - dev->sensor.CCD_start_xoffset, left, top); + DBG(DBG_proc, "%s: CCD_start_xoffset = %d, left = %d, top = %d\n", __func__, + dev->sensor.CCD_start_xoffset, left, top); return SANE_STATUS_GOOD; } @@ -1253,7 +1217,7 @@ sanei_genesys_calculate_zmode2 (SANE_Bool two_table, { int i; int sum; - DBG (DBG_info, "sanei_genesys_calculate_zmode2: two_table=%d\n", two_table); + DBG(DBG_info, "%s: two_table=%d\n", __func__, two_table); /* acceleration total time */ sum = 0; @@ -1324,7 +1288,7 @@ genesys_adjust_gain (double *applied_multi, { double voltage, original_voltage; - DBG (DBG_proc, "genesys_adjust_gain: multi=%f, gain=%d\n", multi, gain); + DBG(DBG_proc, "%s: multi=%f, gain=%d\n", __func__, multi, gain); voltage = 0.5 + gain * 0.25; original_voltage = voltage; @@ -1339,10 +1303,8 @@ genesys_adjust_gain (double *applied_multi, *applied_multi = voltage / original_voltage; - DBG (DBG_proc, - "genesys_adjust_gain: orig voltage=%.2f, new voltage=%.2f, " - "*applied_multi=%f, *new_gain=%d\n", original_voltage, voltage, - *applied_multi, *new_gain); + DBG(DBG_proc, "%s: orig voltage=%.2f, new voltage=%.2f, *applied_multi=%f, *new_gain=%d\n", + __func__, original_voltage, voltage, *applied_multi, *new_gain); return; } @@ -1356,9 +1318,7 @@ genesys_average_white (Genesys_Device * dev, int channels, int channel, int average; int i; - DBG (DBG_proc, - "genesys_average_white: channels=%d, channel=%d, size=%d\n", - channels, channel, size); + DBG(DBG_proc, "%s: channels=%d, channel=%d, size=%d\n", __func__, channels, channel, size); range = size / 50; @@ -1391,9 +1351,8 @@ genesys_average_white (Genesys_Device * dev, int channels, int channel, *max_average = average; } - DBG (DBG_proc, - "genesys_average_white: max_average=%d, gain_white_ref = %d, finished\n", - *max_average, gain_white_ref); + DBG(DBG_proc, "%s: max_average=%d, gain_white_ref = %d, finished\n", __func__, *max_average, + gain_white_ref); if (*max_average >= gain_white_ref) return SANE_STATUS_INVAL; @@ -1410,8 +1369,7 @@ genesys_average_black (Genesys_Device * dev, int channel, int sum; int pixel_step; - DBG (DBG_proc, "genesys_average_black: channel=%d, pixels=%d\n", - channel, pixels); + DBG(DBG_proc, "%s: channel=%d, pixels=%d\n", __func__, channel, pixels); sum = 0; @@ -1433,7 +1391,7 @@ genesys_average_black (Genesys_Device * dev, int channel, data += pixel_step; } - DBG (DBG_proc, "genesys_average_black = %d\n", sum / pixels); + DBG(DBG_proc, "%s = %d\n", __func__, sum / pixels); return (int) (sum / pixels); } @@ -1454,8 +1412,7 @@ genesys_coarse_calibration (Genesys_Device * dev) int i, j; uint8_t *calibration_data, *all_data; - DBG (DBG_info, "genesys_coarse_calibration (scan_mode = %d)\n", - dev->settings.scan_mode); + DBG(DBG_info, "%s (scan_mode = %d)\n", __func__, dev->settings.scan_mode); black_pixels = dev->sensor.black_pixels * dev->settings.xres / dev->sensor.optical_res; @@ -1465,8 +1422,8 @@ genesys_coarse_calibration (Genesys_Device * dev) else channels = 1; - DBG (DBG_info, "channels %d y_size %d xres %d\n", - channels, dev->model->y_size, dev->settings.xres); + DBG(DBG_info, "channels %d y_size %d xres %d\n", channels, dev->model->y_size, + dev->settings.xres); size = channels * 2 * SANE_UNFIX (dev->model->y_size) * dev->settings.xres / 25.4; @@ -1475,9 +1432,7 @@ genesys_coarse_calibration (Genesys_Device * dev) calibration_data = malloc (size); if (!calibration_data) { - DBG (DBG_error, - "genesys_coarse_calibration: failed to allocate memory(%d bytes)\n", - size); + DBG(DBG_error, "%s: failed to allocate memory(%d bytes)\n", __func__, size); return SANE_STATUS_NO_MEM; } @@ -1486,8 +1441,7 @@ genesys_coarse_calibration (Genesys_Device * dev) status = dev->model->cmd_set->set_fe (dev, AFE_INIT); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set frontend: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus(status)); free(all_data); free(calibration_data); return status; @@ -1543,9 +1497,7 @@ genesys_coarse_calibration (Genesys_Device * dev) sanei_genesys_fe_write_data (dev, 0x28, dev->frontend.gain[0]); if (status != SANE_STATUS_GOOD) /* todo: this was 0x28 + 3 ? */ { - DBG (DBG_error, - "genesys_coarse_calibration: Failed to write gain[0]: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to write gain[0]: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1553,9 +1505,7 @@ genesys_coarse_calibration (Genesys_Device * dev) sanei_genesys_fe_write_data (dev, 0x29, dev->frontend.gain[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_coarse_calibration: Failed to write gain[1]: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to write gain[1]: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1563,9 +1513,7 @@ genesys_coarse_calibration (Genesys_Device * dev) sanei_genesys_fe_write_data (dev, 0x2a, dev->frontend.gain[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_coarse_calibration: Failed to write gain[2]: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to write gain[2]: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -1595,9 +1543,7 @@ genesys_coarse_calibration (Genesys_Device * dev) sanei_genesys_fe_write_data (dev, 0x20, dev->frontend.offset[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_coarse_calibration: Failed to write offset[0]: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to write offset[0]: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1605,9 +1551,7 @@ genesys_coarse_calibration (Genesys_Device * dev) sanei_genesys_fe_write_data (dev, 0x21, dev->frontend.offset[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_coarse_calibration: Failed to write offset[1]: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to write offset[1]: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1615,27 +1559,23 @@ genesys_coarse_calibration (Genesys_Device * dev) sanei_genesys_fe_write_data (dev, 0x22, dev->frontend.offset[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_coarse_calibration: Failed to write offset[2]: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to write offset[2]: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, - "genesys_coarse_calibration: doing scan: sign: %d/%d/%d, gain: %d/%d/%d, offset: %d/%d/%d\n", - dev->frontend.sign[0], dev->frontend.sign[1], - dev->frontend.sign[2], dev->frontend.gain[0], - dev->frontend.gain[1], dev->frontend.gain[2], - dev->frontend.offset[0], dev->frontend.offset[1], - dev->frontend.offset[2]); + DBG(DBG_info, + "%s: doing scan: sign: %d/%d/%d, gain: %d/%d/%d, offset: %d/%d/%d\n", __func__, + dev->frontend.sign[0], dev->frontend.sign[1], + dev->frontend.sign[2], dev->frontend.gain[0], + dev->frontend.gain[1], dev->frontend.gain[2], + dev->frontend.offset[0], dev->frontend.offset[1], + dev->frontend.offset[2]); status = dev->model->cmd_set->begin_scan (dev, dev->calib_reg, SANE_FALSE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_coarse_calibration: Failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1643,9 +1583,7 @@ genesys_coarse_calibration (Genesys_Device * dev) sanei_genesys_read_data_from_scanner (dev, calibration_data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_coarse_calibration: Failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1662,9 +1600,8 @@ genesys_coarse_calibration (Genesys_Device * dev) channels, size / 6, 4); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_coarse_calibration: sanei_genesys_write_pnm_file failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: sanei_genesys_write_pnm_file failed: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -1672,9 +1609,7 @@ genesys_coarse_calibration (Genesys_Device * dev) status = dev->model->cmd_set->end_scan (dev, dev->calib_reg, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_coarse_calibration: Failed to end scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */ @@ -1687,9 +1622,8 @@ genesys_coarse_calibration (Genesys_Device * dev) dark[i * 3 + j] = genesys_average_black (dev, j, calibration_data, black_pixels); - DBG (DBG_info, - "genesys_coarse_calibration: white[%d]=%d, black[%d]=%d\n", - i * 3 + j, white[i * 3 + j], i * 3 + j, dark[i * 3 + j]); + DBG(DBG_info, "%s: white[%d]=%d, black[%d]=%d\n", __func__, + i * 3 + j, white[i * 3 + j], i * 3 + j, dark[i * 3 + j]); } } else /* one color-component modes */ @@ -1745,12 +1679,11 @@ genesys_coarse_calibration (Genesys_Device * dev) } /* for (i = 0; i < 4; i++) */ free(all_data); - DBG (DBG_info, - "genesys_coarse_calibration: final: sign: %d/%d/%d, gain: %d/%d/%d, offset: %d/%d/%d\n", - dev->frontend.sign[0], dev->frontend.sign[1], dev->frontend.sign[2], - dev->frontend.gain[0], dev->frontend.gain[1], dev->frontend.gain[2], - dev->frontend.offset[0], dev->frontend.offset[1], - dev->frontend.offset[2]); + DBG(DBG_info, "%s: final: sign: %d/%d/%d, gain: %d/%d/%d, offset: %d/%d/%d\n", __func__, + dev->frontend.sign[0], dev->frontend.sign[1], dev->frontend.sign[2], + dev->frontend.gain[0], dev->frontend.gain[1], dev->frontend.gain[2], + dev->frontend.offset[0], dev->frontend.offset[1], + dev->frontend.offset[2]); DBGCOMPLETED; return status; @@ -1813,8 +1746,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev) dev->dark_average_data = malloc (dev->average_size); if (!dev->dark_average_data) { - DBG (DBG_error, - "genesys_dark_shading_calibration: failed to allocate average memory\n"); + DBG(DBG_error, "%s: failed to allocate average memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -1824,8 +1756,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev) calibration_data = malloc (size); if (!calibration_data) { - DBG (DBG_error, - "genesys_dark_shading_calibration: failed to allocate calibration data memory\n"); + DBG(DBG_error, "%s: failed to allocate calibration data memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -1855,9 +1786,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, - "genesys_dark_shading_calibration: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1867,9 +1796,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, - "genesys_dark_shading_calibration: Failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1877,9 +1804,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, - "genesys_dark_shading_calibration: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1887,9 +1812,7 @@ genesys_dark_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, - "genesys_dark_shading_calibration: failed to end scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1940,8 +1863,7 @@ genesys_dummy_dark_shading (Genesys_Device * dev) dev->dark_average_data = malloc (dev->average_size); if (!dev->dark_average_data) { - DBG (DBG_error, - "genesys_dummy_dark_shading: failed to allocate average memory\n"); + DBG(DBG_error, "%s: failed to allocate average memory\n", __func__); return SANE_STATUS_NO_MEM; } memset (dev->dark_average_data, 0x00, channels * 2 * pixels_per_line); @@ -1994,9 +1916,7 @@ genesys_dummy_dark_shading (Genesys_Device * dev) dummy2 /= (xend - skip); dummy3 /= (xend - skip); } - DBG (DBG_proc, - "genesys_dummy_dark_shading: dummy1=%d, dummy2=%d, dummy3=%d \n", - dummy1, dummy2, dummy3); + DBG(DBG_proc, "%s: dummy1=%d, dummy2=%d, dummy3=%d \n", __func__, dummy1, dummy2, dummy3); /* fill dark_average */ for (x = 0; x < pixels_per_line; x++) @@ -2027,8 +1947,7 @@ genesys_white_shading_calibration (Genesys_Device * dev) uint8_t channels; SANE_Bool motor; - DBG (DBG_proc, "genesys_white_shading_calibration (lines = %d)\n", - (unsigned int)dev->calib_lines); + DBG(DBG_proc, "%s (lines = %d)\n", __func__, (unsigned int)dev->calib_lines); pixels_per_line = dev->calib_pixels; channels = dev->calib_channels; @@ -2039,8 +1958,7 @@ genesys_white_shading_calibration (Genesys_Device * dev) dev->white_average_data = malloc (channels * 2 * pixels_per_line); if (!dev->white_average_data) { - DBG (DBG_error, - "genesys_white_shading_calibration: failed to allocate average memory\n"); + DBG(DBG_error, "%s: failed to allocate average memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2049,8 +1967,7 @@ genesys_white_shading_calibration (Genesys_Device * dev) calibration_data = malloc (size); if (!calibration_data) { - DBG (DBG_error, - "genesys_white_shading_calibration: failed to allocate calibration memory\n"); + DBG(DBG_error, "%s: failed to allocate calibration memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2082,9 +1999,7 @@ genesys_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, - "genesys_white_shading_calibration: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2095,9 +2010,7 @@ genesys_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, - "genesys_white_shading_calibration: Failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2105,9 +2018,7 @@ genesys_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, - "genesys_white_shading_calibration: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2115,9 +2026,7 @@ genesys_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, - "genesys_white_shading_calibration: failed to end scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2143,9 +2052,8 @@ genesys_white_shading_calibration (Genesys_Device * dev) status = genesys_dummy_dark_shading (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_white_shading_calibration: failed to do dummy dark shading calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do dummy dark shading calibration: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -2178,7 +2086,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) SANE_Bool motor; - DBG (DBG_proc, "%s: (lines = %d)\n", __func__, (unsigned int)dev->calib_lines); + DBG(DBG_proc, "%s: (lines = %d)\n", __func__, (unsigned int)dev->calib_lines); pixels_per_line = dev->calib_pixels; channels = dev->calib_channels; @@ -2191,7 +2099,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) dev->white_average_data = malloc (dev->average_size); if (!dev->white_average_data) { - DBG (DBG_error, "%s: failed to allocate white average memory\n", __func__); + DBG(DBG_error, "%s: failed to allocate white average memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2201,7 +2109,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) dev->dark_average_data = malloc (channels * 2 * pixels_per_line); if (!dev->dark_average_data) { - DBG (DBG_error, "%s: failed to allocate dark average memory\n", __func__); + DBG(DBG_error, "%s: failed to allocate dark average memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2210,7 +2118,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) calibration_data = malloc (size); if (!calibration_data) { - DBG (DBG_error, "%s: failed to allocate calibration memory\n", __func__); + DBG(DBG_error, "%s: failed to allocate calibration memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2231,8 +2139,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2241,8 +2148,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: failed to begin scan: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2250,8 +2156,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: failed to read data: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2259,8 +2164,7 @@ genesys_dark_white_shading_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (calibration_data); - DBG (DBG_error, "%s: Failed to end scan: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2429,7 +2333,7 @@ compute_averaged_planar (Genesys_Device * dev, unsigned int x, i, j, br, dk, res, avgpixels, basepixels, val; unsigned int fill,factor; - DBG (DBG_info, "%s: pixels=%d, offset=%d\n", __func__, pixels_per_line, o); + DBG(DBG_info, "%s: pixels=%d, offset=%d\n", __func__, pixels_per_line, o); /* initialize result */ memset (shading_data, 0xff, words_per_color * 3 * 2); @@ -2499,9 +2403,9 @@ compute_averaged_planar (Genesys_Device * dev, fill=1; } - DBG (DBG_info, "%s: averaging over %d pixels\n", __func__, avgpixels); - DBG (DBG_info, "%s: packing factor is %d\n", __func__, factor); - DBG (DBG_info, "%s: fill length is %d\n", __func__, fill); + DBG(DBG_info, "%s: averaging over %d pixels\n", __func__, avgpixels); + DBG(DBG_info, "%s: packing factor is %d\n", __func__, factor); + DBG(DBG_info, "%s: fill length is %d\n", __func__, fill); for (x = 0; x <= pixels_per_line - avgpixels; x += avgpixels) { @@ -2613,8 +2517,7 @@ compute_coefficients (Genesys_Device * dev, unsigned int val, br, dk; unsigned int start, end; - DBG (DBG_io, - "compute_coefficients: pixels_per_line=%d, coeff=0x%04x\n", pixels_per_line, coeff); + DBG(DBG_io, "%s: pixels_per_line=%d, coeff=0x%04x\n", __func__, pixels_per_line, coeff); /* compute start & end values depending of the offset */ if (offset < 0) @@ -2688,9 +2591,8 @@ compute_planar_coefficients (Genesys_Device * dev, uint32_t x, c, i; uint32_t val, dk, br; - DBG (DBG_io, - "compute_planar_coefficients: factor=%d, pixels_per_line=%d, words=0x%X, coeff=0x%04x\n", factor, - pixels_per_line, words_per_color, coeff); + DBG(DBG_io, "%s: factor=%d, pixels_per_line=%d, words=0x%X, coeff=0x%04x\n", __func__, factor, + pixels_per_line, words_per_color, coeff); for (c = 0; c < channels; c++) { /* shading data is larger than pixels_per_line so offset can be neglected */ @@ -2779,7 +2681,8 @@ compute_shifted_coefficients (Genesys_Device * dev, avgpixels = 12; else avgpixels = 15; - DBG (DBG_info, "compute_shifted_coefficients: pixels_per_line=%d, coeff=0x%04x, averaging over %d pixels\n", pixels_per_line, coeff, avgpixels); + DBG(DBG_info, "%s: pixels_per_line=%d, coeff=0x%04x, averaging over %d pixels\n", __func__, + pixels_per_line, coeff, avgpixels); for (x = 0; x <= pixels_per_line - avgpixels; x += avgpixels) { memset (&br_tmp, 0, sizeof(br_tmp)); @@ -3190,14 +3093,13 @@ genesys_restore_calibration (Genesys_Device * dev) status = genesys_send_shading_coefficient (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_restore_calibration: failed to send shading calibration coefficients: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send shading calibration coefficients: %s\n", + __func__, sane_strstatus(status)); return status; } } - DBG (DBG_proc, "genesys_restore_calibration: restored\n"); + DBG(DBG_proc, "%s: restored\n", __func__); return SANE_STATUS_GOOD; } @@ -3205,13 +3107,12 @@ genesys_restore_calibration (Genesys_Device * dev) * entry doesn't match, or an fatal error */ if (status != SANE_STATUS_UNSUPPORTED) { - DBG (DBG_error, - "genesys_restore_calibration: fail while checking compatibility: %s\n", - sane_strstatus (status)); - return status; + DBG(DBG_error, "%s: fail while checking compatibility: %s\n", __func__, + sane_strstatus(status)); + return status; } } - DBG (DBG_proc, "genesys_restore_calibration: completed(nothing found)\n"); + DBG(DBG_proc, "%s: completed(nothing found)\n", __func__); return SANE_STATUS_UNSUPPORTED; } @@ -3241,9 +3142,8 @@ genesys_save_calibration (Genesys_Device * dev) } else if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_save_calibration: fail while checking compatibility: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: fail while checking compatibility: %s\n", __func__, + sane_strstatus(status)); return status; } break; @@ -3310,7 +3210,7 @@ genesys_flatbed_calibration (Genesys_Device * dev) uint32_t pixels_per_line; int yres; - DBG (DBG_info, "genesys_flatbed_calibration\n"); + DBG(DBG_info, "%s\n", __func__); yres = dev->sensor.optical_res; if (dev->settings.yres <= dev->sensor.optical_res / 2) @@ -3322,9 +3222,7 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->offset_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: offset calibration failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: offset calibration failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3332,9 +3230,7 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->coarse_gain_calibration (dev, yres); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: coarse gain calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: coarse gain calibration: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3346,18 +3242,16 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->init_regs_for_coarse_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: failed to send calibration registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send calibration registers: %s\n", __func__, + sane_strstatus(status)); return status; } status = genesys_coarse_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: failed to do coarse gain calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do coarse gain calibration: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -3369,9 +3263,7 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->led_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: led calibration failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: led calibration failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3381,9 +3273,7 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->offset_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: offset calibration failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: offset calibration failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3392,9 +3282,7 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->coarse_gain_calibration (dev, yres); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: coarse gain calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: coarse gain calibration: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -3406,18 +3294,16 @@ genesys_flatbed_calibration (Genesys_Device * dev) dev->model->cmd_set->init_regs_for_coarse_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: failed to send calibration registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send calibration registers: %s\n", __func__, + sane_strstatus(status)); return status; } status = genesys_coarse_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: failed to do static calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do static calibration: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -3437,9 +3323,7 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = sanei_genesys_init_shading_data (dev, pixels_per_line); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: failed to init shading process: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to init shading process: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3447,8 +3331,8 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->init_regs_for_shading (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "genesys_flatbed_calibration: failed to send shading " - "registers: %s\n", sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send shading registers: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -3457,9 +3341,8 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = genesys_dark_white_shading_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: failed to do dark+white shading calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do dark+white shading calibration: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -3470,19 +3353,17 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = genesys_dark_shading_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: failed to do dark shading calibration: %s\n", - sane_strstatus (status)); - return status; + DBG(DBG_error, "%s: failed to do dark shading calibration: %s\n", __func__, + sane_strstatus(status)); + return status; } } status = genesys_white_shading_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: failed to do white shading calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do white shading calibration: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -3492,14 +3373,13 @@ genesys_flatbed_calibration (Genesys_Device * dev) status = genesys_send_shading_coefficient (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_flatbed_calibration: failed to send shading calibration coefficients: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send shading calibration coefficients: %s\n", __func__, + sane_strstatus(status)); return status; } } - DBG (DBG_info, "genesys_flatbed_calibration: completed\n"); + DBG(DBG_info, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -3524,8 +3404,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev) DBGSTART; if (dev->model->cmd_set->search_strip == NULL) { - DBG (DBG_error, - "genesys_sheetfed_calibration: no strip searching function available\n"); + DBG(DBG_error, "%s: no strip searching function available\n", __func__); return SANE_STATUS_UNSUPPORTED; } @@ -3533,14 +3412,12 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->load_document (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to load document: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to load document: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, "genesys_sheetfed_calibration\n"); + DBG(DBG_info, "%s\n", __func__); /* led, offset and gain calibration are influenced by scan * settings. So we set it to sensor resolution */ @@ -3557,9 +3434,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->search_strip (dev, forward, SANE_FALSE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to find white strip: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to find white strip: %s\n", __func__, sane_strstatus(status)); dev->model->cmd_set->eject_document (dev); return status; } @@ -3569,9 +3444,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->led_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: led calibration failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: led calibration failed: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -3582,9 +3455,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->offset_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: offset calibration failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: offset calibration failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3593,9 +3464,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->coarse_gain_calibration (dev, xres); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: coarse gain calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: coarse gain calibration: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -3607,18 +3476,15 @@ genesys_sheetfed_calibration (Genesys_Device * dev) dev->model->cmd_set->init_regs_for_coarse_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to send calibration registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send calibration registers: %s\n", __func__, + sane_strstatus(status)); return status; } status = genesys_coarse_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to do static calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do static calibration: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -3631,28 +3497,24 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->search_strip (dev, forward, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to find black strip: %s\n", - sane_strstatus (status)); - dev->model->cmd_set->eject_document (dev); + DBG(DBG_error, "%s: failed to find black strip: %s\n", __func__, sane_strstatus(status)); + dev->model->cmd_set->eject_document (dev); return status; } status = dev->model->cmd_set->init_regs_for_shading (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to do set up registers for shading calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do set up registers for shading calibration: %s\n", + __func__, sane_strstatus(status)); return status; } status = genesys_dark_shading_calibration (dev); if (status != SANE_STATUS_GOOD) { dev->model->cmd_set->eject_document (dev); - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to do dark shading calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do dark shading calibration: %s\n", __func__, + sane_strstatus(status)); return status; } forward = SANE_FALSE; @@ -3663,9 +3525,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->search_strip (dev, forward, SANE_FALSE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to find white strip: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to find white strip: %s\n", __func__, sane_strstatus(status)); dev->model->cmd_set->eject_document (dev); return status; } @@ -3673,17 +3533,15 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->init_regs_for_shading (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to do set up registers for shading calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do set up registers for shading calibration: %s\n", __func__, + sane_strstatus(status)); return status; } status = genesys_white_shading_calibration (dev); if (status != SANE_STATUS_GOOD) { dev->model->cmd_set->eject_document (dev); - DBG (DBG_error, "%s: failed eject target: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed eject target: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3710,9 +3568,8 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = genesys_send_shading_coefficient (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to send shading calibration coefficients: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send shading calibration coefficients: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -3724,9 +3581,7 @@ genesys_sheetfed_calibration (Genesys_Device * dev) status = dev->model->cmd_set->eject_document (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_sheetfed_calibration: failed to eject document: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to eject document: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3758,9 +3613,7 @@ genesys_wait_not_moving (Genesys_Device * dev, int mseconds) uint8_t value; SANE_Status status; - DBG (DBG_proc, - "genesys_wait_not_moving: waiting %d mseconds for motor to stop\n", - mseconds); + DBG(DBG_proc, "%s: waiting %d mseconds for motor to stop\n", __func__, mseconds); while (mseconds > 0) { RIE (sanei_genesys_get_status (dev, &value)); @@ -3769,20 +3622,16 @@ genesys_wait_not_moving (Genesys_Device * dev, int mseconds) { usleep (100 * 1000); mseconds -= 100; - DBG (DBG_io, - "genesys_wait_not_moving: motor is moving, %d mseconds to go\n", - mseconds); + DBG(DBG_io, "%s: motor is moving, %d mseconds to go\n", __func__, mseconds); } else { - DBG (DBG_info, - "genesys_wait_not_moving: motor is not moving, exiting\n"); + DBG(DBG_info, "%s: motor is not moving, exiting\n", __func__); return SANE_STATUS_GOOD; } } - DBG (DBG_error, - "genesys_wait_not_moving: motor is still moving, timeout exceeded\n"); + DBG(DBG_error, "%s: motor is still moving, timeout exceeded\n", __func__); return SANE_STATUS_DEVICE_BUSY; } #endif @@ -3814,7 +3663,7 @@ genesys_warmup_lamp (Genesys_Device * dev) /* check if the current chipset implements warmup */ if(dev->model->cmd_set->init_regs_for_warmup==NULL) { - DBG (DBG_error, "%s: init_regs_for_warmup not implemented\n", __func__); + DBG(DBG_error,"%s: init_regs_for_warmup not implemented\n", __func__); return status; } @@ -3833,7 +3682,7 @@ genesys_warmup_lamp (Genesys_Device * dev) do { - DBG (DBG_info, "genesys_warmup_lamp: one more loop\n"); + DBG(DBG_info, "%s: one more loop\n", __func__); RIEF2 (dev->model->cmd_set->begin_scan (dev, dev->reg, SANE_FALSE), first_line, second_line); do { @@ -3884,10 +3733,9 @@ genesys_warmup_lamp (Genesys_Device * dev) first_average /= pixel; second_average /= pixel; difference = fabs (first_average - second_average); - DBG (DBG_info, - "genesys_warmup_lamp: average = %.2f, diff = %.3f\n", - 100 * ((second_average) / (256 * 256)), - 100 * (difference / second_average)); + DBG(DBG_info, "%s: average = %.2f, diff = %.3f\n", __func__, + 100 * ((second_average) / (256 * 256)), + 100 * (difference / second_average)); if (second_average > (100 * 256) && (difference / second_average) < 0.002) @@ -3908,7 +3756,8 @@ genesys_warmup_lamp (Genesys_Device * dev) total_size / (lines * channels), lines); } - DBG (DBG_info, "genesys_warmup_lamp: average 1 = %.2f, average 2 = %.2f\n", first_average, second_average); + DBG(DBG_info, "%s: average 1 = %.2f, average 2 = %.2f\n", __func__, first_average, + second_average); /* if delta below 15/255 ~= 5.8%, lamp is considred warm enough */ if (fabs (first_average - second_average) < 15 && second_average > 55) @@ -3923,16 +3772,12 @@ genesys_warmup_lamp (Genesys_Device * dev) if (seconds >= WARMUP_TIME) { - DBG (DBG_error, - "genesys_warmup_lamp: warmup timed out after %d seconds. Lamp defective?\n", - seconds); + DBG(DBG_error, "%s: warmup timed out after %d seconds. Lamp defective?\n", __func__, seconds); status = SANE_STATUS_IO_ERROR; } else { - DBG (DBG_info, - "genesys_warmup_lamp: warmup succeeded after %d seconds\n", - seconds); + DBG(DBG_info, "%s: warmup succeeded after %d seconds\n", __func__, seconds); } free (first_line); @@ -3961,9 +3806,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = sanei_genesys_wait_for_home (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to wait for head to park: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to wait for head to park: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -3972,9 +3816,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = dev->model->cmd_set->save_power (dev, SANE_FALSE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to disable power saving mode: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to disable power saving mode: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -3996,9 +3839,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = dev->model->cmd_set->search_start_position (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to search start position: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to search start position: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -4006,9 +3848,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = dev->model->cmd_set->slow_back_home (dev, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to move scanhead to " - "home position: %s\n", sane_strstatus (status)); + DBG(DBG_error, "%s: failed to move scanhead to home position: %s\n", __func__, + sane_strstatus(status)); return status; } dev->scanhead_position_in_steps = 0; @@ -4022,9 +3863,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = dev->model->cmd_set->slow_back_home (dev, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to move scanhead to " - "home position: %s\n", sane_strstatus (status)); + DBG(DBG_error, "%s: failed to move scanhead to home position: %s\n", __func__, + sane_strstatus(status)); return status; } dev->scanhead_position_in_steps = 0; @@ -4038,9 +3878,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status=dev->model->cmd_set->move_to_ta(dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to move to start of transparency adapter: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to move to start of transparency adapter: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -4052,9 +3891,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = dev->model->cmd_set->load_document (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to load document: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to load document: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -4064,9 +3901,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = dev->model->cmd_set->send_gamma_table (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to init gamma table: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to init gamma table: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4082,9 +3917,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = genesys_scanner_calibration (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to do scanner calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do scanner calibration: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -4092,14 +3926,12 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) } else { - DBG (DBG_warn, "genesys_start_scan: no calibration done\n"); + DBG(DBG_warn, "%s: no calibration done\n", __func__); } } else if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to restore calibration: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to restore calibration: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4111,7 +3943,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) dev->settings.threshold-127); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "genesys_start_scan: failed to build lut\n"); + DBG(DBG_error, "%s: failed to build lut\n", __func__); return status; } } @@ -4119,9 +3951,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = dev->model->cmd_set->init_regs_for_scan (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to do init registers for scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do init registers for scan: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -4139,9 +3970,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = genesys_send_shading_coefficient (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to send shading calibration coefficients: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send shading calibration coefficients: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -4153,9 +3983,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) cmd_set->bulk_full_size ()); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to bulk write registers, status = %d\n", - status); + DBG(DBG_error, "%s: failed to bulk write registers, status = %d\n", __func__, status); return status; } @@ -4163,9 +3991,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = dev->model->cmd_set->begin_scan (dev, dev->reg, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } @@ -4182,9 +4008,7 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = sanei_genesys_read_feed_steps (dev, &steps); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: Failed to read feed steps: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to read feed steps: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -4216,9 +4040,8 @@ genesys_start_scan (Genesys_Device * dev, SANE_Bool lamp_off) status = sanei_genesys_read_valid_words (dev, &steps); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_start_scan: failed to read valid words: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read valid words: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -4308,9 +4131,8 @@ static SANE_Status accurate_line_read(Genesys_Device * dev, status = dev->model->cmd_set->bulk_read_data (dev, 0x45, buffer, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "accurate_line_read: failed to read %lu bytes (%s)\n", - (u_long) size, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) size, + sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } @@ -4338,9 +4160,8 @@ genesys_fill_line_interp_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, status = accurate_line_read(dev,dev->oe_buffer.buffer,dev->oe_buffer.size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __func__, - (u_long) dev->oe_buffer.size, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read %lu bytes (%s)\n", __func__, + (u_long) dev->oe_buffer.size, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } } @@ -4375,9 +4196,8 @@ genesys_fill_line_interp_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, status = accurate_line_read(dev,dev->oe_buffer.buffer,dev->oe_buffer.size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __func__, - (u_long) dev->oe_buffer.size, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read %lu bytes (%s)\n", __func__, + (u_long) dev->oe_buffer.size, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } } @@ -4409,9 +4229,8 @@ genesys_fill_segmented_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, s status = accurate_line_read(dev,dev->oe_buffer.buffer,dev->oe_buffer.size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __func__, - (u_long) dev->oe_buffer.size, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read %lu bytes (%s)\n", __func__, + (u_long) dev->oe_buffer.size, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } } @@ -4500,9 +4319,8 @@ genesys_fill_segmented_buffer (Genesys_Device * dev, uint8_t *work_buffer_dst, s status = accurate_line_read(dev,dev->oe_buffer.buffer,dev->oe_buffer.size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read %lu bytes (%s)\n", __func__, - (u_long) dev->oe_buffer.size, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read %lu bytes (%s)\n", __func__, + (u_long) dev->oe_buffer.size, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } } @@ -4558,8 +4376,7 @@ genesys_fill_read_buffer (Genesys_Device * dev) if (size == 0) return SANE_STATUS_GOOD; - DBG (DBG_io, "genesys_fill_read_buffer: reading %lu bytes\n", - (u_long) size); + DBG(DBG_io, "%s: reading %lu bytes\n", __func__, (u_long) size); /* size is already maxed to our needs. for most models bulk_read_data will read as much data as requested. */ @@ -4590,9 +4407,8 @@ genesys_fill_read_buffer (Genesys_Device * dev) } if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_fill_read_buffer: failed to read %lu bytes (%s)\n", - (u_long) size, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read %lu bytes (%s)\n", __func__, (u_long) size, + sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } @@ -4634,32 +4450,33 @@ genesys_read_ordered_data (Genesys_Device * dev, SANE_Byte * destination, DBGSTART; if (dev->read_active != SANE_TRUE) { - DBG (DBG_error, "genesys_read_ordered_data: read not active!\n"); + DBG(DBG_error, "%s: read not active!\n", __func__); *len = 0; return SANE_STATUS_INVAL; } - DBG (DBG_info, "genesys_read_ordered_data: dumping current_setup:\n" - "\tpixels: %d\n" - "\tlines: %d\n" - "\tdepth: %d\n" - "\tchannels: %d\n" - "\texposure_time: %d\n" - "\txres: %g\n" - "\tyres: %g\n" - "\thalf_ccd: %s\n" - "\tstagger: %d\n" - "\tmax_shift: %d\n", - dev->current_setup.pixels, - dev->current_setup.lines, - dev->current_setup.depth, - dev->current_setup.channels, - dev->current_setup.exposure_time, - dev->current_setup.xres, - dev->current_setup.yres, - dev->current_setup.half_ccd ? "yes" : "no", - dev->current_setup.stagger, dev->current_setup.max_shift); + DBG(DBG_info, "%s: dumping current_setup:\n" + "\tpixels: %d\n" + "\tlines: %d\n" + "\tdepth: %d\n" + "\tchannels: %d\n" + "\texposure_time: %d\n" + "\txres: %g\n" + "\tyres: %g\n" + "\thalf_ccd: %s\n" + "\tstagger: %d\n" + "\tmax_shift: %d\n", + __func__, + dev->current_setup.pixels, + dev->current_setup.lines, + dev->current_setup.depth, + dev->current_setup.channels, + dev->current_setup.exposure_time, + dev->current_setup.xres, + dev->current_setup.yres, + dev->current_setup.half_ccd ? "yes" : "no", + dev->current_setup.stagger, dev->current_setup.max_shift); /* prepare conversion */ /* current settings */ @@ -4686,25 +4503,20 @@ genesys_read_ordered_data (Genesys_Device * dev, SANE_Byte * destination, needs_shrink = dev->settings.pixels != src_pixels; needs_reverse = depth == 1; - DBG (DBG_info, - "genesys_read_ordered_data: using filters:%s%s%s%s\n", - needs_reorder ? " reorder" : "", - needs_ccd ? " ccd" : "", - needs_shrink ? " shrink" : "", - needs_reverse ? " reverse" : ""); + DBG(DBG_info, "%s: using filters:%s%s%s%s\n", __func__, + needs_reorder ? " reorder" : "", + needs_ccd ? " ccd" : "", + needs_shrink ? " shrink" : "", + needs_reverse ? " reverse" : ""); - DBG (DBG_info, - "genesys_read_ordered_data: frontend requested %lu bytes\n", - (u_long) * len); + DBG(DBG_info, "%s: frontend requested %lu bytes\n", __func__, (u_long) * len); - DBG (DBG_info, - "genesys_read_ordered_data: bytes_to_read=%lu, total_bytes_read=%lu\n", - (u_long) dev->total_bytes_to_read, (u_long) 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) { - DBG (DBG_proc, - "genesys_read_ordered_data: nothing more to scan: EOF\n"); + DBG(DBG_proc, "%s: nothing more to scan: EOF\n", __func__); *len = 0; /* issue park command immediatly in case scanner can handle it @@ -4719,10 +4531,10 @@ genesys_read_ordered_data (Genesys_Device * dev, SANE_Byte * destination, return SANE_STATUS_EOF; } - DBG (DBG_info, "genesys_read_ordered_data: %lu lines left by output\n", + DBG(DBG_info, "%s: %lu lines left by output\n", __func__, ((dev->total_bytes_to_read - dev->total_bytes_read) * 8UL) / (dev->settings.pixels * channels * depth)); - DBG (DBG_info, "genesys_read_ordered_data: %lu lines left by input\n", + DBG(DBG_info, "%s: %lu lines left by input\n", __func__, ((dev->read_bytes_left + dev->read_buffer.avail) * 8UL) / (src_pixels * channels * depth)); @@ -4783,8 +4595,7 @@ Problems with the first approach: if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_read_ordered_data: genesys_fill_read_buffer failed\n"); + DBG(DBG_error, "%s: genesys_fill_read_buffer failed\n", __func__); return status; } @@ -4796,7 +4607,7 @@ Problems with the first approach: /*not implemented for depth == 1.*/ if (depth == 1) { - DBG (DBG_error, "Can't reorder single bit data\n"); + DBG(DBG_error, "Can't reorder single bit data\n"); return SANE_STATUS_INVAL; } @@ -4816,8 +4627,7 @@ Problems with the first approach: work_buffer_dst = sanei_genesys_buffer_get_write_pos (dst_buffer, bytes); - DBG (DBG_info, "genesys_read_ordered_data: reordering %d lines\n", - dst_lines); + DBG(DBG_info, "%s: reordering %d lines\n", __func__, dst_lines); if (dst_lines != 0) { @@ -4911,9 +4721,8 @@ Problems with the first approach: if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_read_ordered_data: failed to convert byte ordering(%s)\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to convert byte ordering(%s)\n", __func__, + sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } @@ -4930,7 +4739,7 @@ Problems with the first approach: /*should not happen with depth == 1.*/ if (depth == 1) { - DBG (DBG_error, "Can't reverse ccd for single bit data\n"); + DBG(DBG_error, "Can't reverse ccd for single bit data\n"); return SANE_STATUS_INVAL; } @@ -4959,8 +4768,7 @@ Problems with the first approach: work_buffer_dst = sanei_genesys_buffer_get_write_pos (dst_buffer, bytes); - DBG (DBG_info, "genesys_read_ordered_data: un-ccd-ing %d lines\n", - dst_lines); + DBG(DBG_info, "%s: un-ccd-ing %d lines\n", __func__, dst_lines); if (dst_lines != 0) { @@ -4978,9 +4786,8 @@ Problems with the first approach: if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_read_ordered_data: failed to reverse ccd effects(%s)\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to reverse ccd effects(%s)\n", __func__, + sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } @@ -5015,8 +4822,7 @@ Problems with the first approach: work_buffer_dst = sanei_genesys_buffer_get_write_pos (dst_buffer, bytes); - DBG (DBG_info, "genesys_read_ordered_data: shrinking %d lines\n", - dst_lines); + DBG(DBG_info, "%s: shrinking %d lines\n", __func__, dst_lines); if (dst_lines != 0) { @@ -5042,9 +4848,7 @@ Problems with the first approach: if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_read_ordered_data: failed to shrink lines(%s)\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to shrink lines(%s)\n", __func__, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } @@ -5071,9 +4875,7 @@ Problems with the first approach: status = genesys_reverse_bits (work_buffer_src, destination, bytes); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_read_ordered_data: failed to reverse bits(%s)\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to reverse bits(%s)\n", __func__, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } *len = bytes; @@ -5104,8 +4906,7 @@ Problems with the first approach: } } - DBG (DBG_proc, "genesys_read_ordered_data: completed, %lu bytes read\n", - (u_long) bytes); + DBG(DBG_proc, "%s: completed, %lu bytes read\n", __func__, (u_long) bytes); return SANE_STATUS_GOOD; } @@ -5489,7 +5290,7 @@ GENESYS_STATIC char *calibration_filename(Genesys_Device *currdev) snprintf (tmpstr, PATH_MAX, "%s%c.sane%c%s", ptr, PATH_SEP, PATH_SEP, filename); } - DBG (DBG_info, "%s: calibration filename >%s<\n", __func__, tmpstr); + DBG(DBG_info, "%s: calibration filename >%s<\n", __func__, tmpstr); return tmpstr; } @@ -5711,7 +5512,7 @@ init_options (Genesys_Scanner * s) { s->opt[OPT_ENHANCEMENT_GROUP].cap |= SANE_CAP_INACTIVE; s->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; - DBG (DBG_info, "init_options: custom gamma disabled\n"); + DBG(DBG_info, "%s: custom gamma disabled\n", __func__); } /* software base image enhancements, these are consuming as many @@ -6114,7 +5915,7 @@ static SANE_Status check_present (SANE_String_Const devname) { present=SANE_TRUE; - DBG (DBG_io, "check_present: %s detected.\n",devname); + DBG(DBG_io, "%s: %s detected.\n", __func__, devname); return SANE_STATUS_GOOD; } @@ -6138,15 +5939,14 @@ attach (SANE_String_Const devname, Genesys_Device ** devp, SANE_Bool may_wait) unsigned int i; - DBG (DBG_proc, "attach: start: devp %s NULL, may_wait = %d\n", - devp ? "!=" : "==", may_wait); + DBG(DBG_proc, "%s: start: devp %s NULL, may_wait = %d\n", __func__, devp ? "!=" : "==", may_wait); if (devp) *devp = 0; if (!devname) { - DBG (DBG_error, "attach: devname == NULL\n"); + DBG(DBG_error, "%s: devname == NULL\n", __func__); return SANE_STATUS_INVAL; } @@ -6156,30 +5956,28 @@ attach (SANE_String_Const devname, Genesys_Device ** devp, SANE_Bool may_wait) { if (devp) *devp = dev; - DBG (DBG_info, "attach: device `%s' was already in device list\n", - devname); + DBG(DBG_info, "%s: device `%s' was already in device list\n", __func__, devname); return SANE_STATUS_GOOD; } } - DBG (DBG_info, "attach: trying to open device `%s'\n", devname); + DBG(DBG_info, "%s: trying to open device `%s'\n", __func__, devname); status = sanei_usb_open (devname, &dn); if (status != SANE_STATUS_GOOD) { - DBG (DBG_warn, "attach: couldn't open device `%s': %s\n", devname, + DBG(DBG_warn, "%s: couldn't open device `%s': %s\n", __func__, devname, sane_strstatus (status)); return status; } else - DBG (DBG_info, "attach: device `%s' successfully opened\n", devname); + DBG(DBG_info, "%s: device `%s' successfully opened\n", __func__, devname); status = sanei_usb_get_vendor_product (dn, &vendor, &product); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "attach: couldn't get vendor and product ids of device `%s': %s\n", - devname, sane_strstatus (status)); + DBG(DBG_error, "%s: couldn't get vendor and product ids of device `%s': %s\n", __func__, + devname, sane_strstatus (status)); return status; } @@ -6192,7 +5990,7 @@ attach (SANE_String_Const devname, Genesys_Device ** devp, SANE_Bool may_wait) sanei_usb_find_devices (vendor, 0x1010, check_present); if(present==SANE_FALSE) { - DBG (DBG_error,"attach: master device not present\n"); + DBG(DBG_error, "%s: master device not present\n", __func__); return SANE_STATUS_INVAL; } } @@ -6211,9 +6009,8 @@ attach (SANE_String_Const devname, Genesys_Device ** devp, SANE_Bool may_wait) if (!dev) { - DBG (DBG_error, - "attach: vendor %d product %d is not supported by this backend\n", - vendor, product); + DBG(DBG_error, "%s: vendor %d product %d is not supported by this backend\n", __func__, + vendor, product); return SANE_STATUS_INVAL; } @@ -6229,8 +6026,8 @@ attach (SANE_String_Const devname, Genesys_Device ** devp, SANE_Bool may_wait) dev->productId = genesys_usb_device_list[i].product; dev->already_initialized = SANE_FALSE; - DBG (DBG_info, "attach: found %s flatbed scanner %s at %s\n", - dev->model->vendor, dev->model->model, dev->file_name); + DBG(DBG_info, "%s: found %s flatbed scanner %s at %s\n", __func__, dev->model->vendor, + dev->model->model, dev->file_name); add_device(dev); if (devp) @@ -6271,7 +6068,7 @@ attach_one_device (SANE_String_Const devname) if (!new_dev) { FREE_IFNOT_NULL(tmp_dev) - DBG (DBG_error, "attach_one_device: out of memory\n"); + DBG(DBG_error, "%s: out of memory\n", __func__); return SANE_STATUS_NO_MEM; } } @@ -6354,7 +6151,7 @@ sanei_genesys_read_calibration (Genesys_Device * dev) fp = fopen (dev->calib_file, "rb"); if (!fp) { - DBG (DBG_info, "Calibration: Cannot open %s\n", dev->calib_file); + DBG(DBG_info, "%s: Cannot open %s\n", __func__, dev->calib_file); DBGCOMPLETED; return SANE_STATUS_IO_ERROR; } @@ -6363,7 +6160,7 @@ sanei_genesys_read_calibration (Genesys_Device * dev) fread (&vers, 1, 1, fp); if (vers != CALIBRATION_VERSION) { - DBG (DBG_info, "Calibration: Bad version\n"); + DBG(DBG_info, "%s: Bad version\n", __func__); fclose (fp); DBGCOMPLETED; return SANE_STATUS_INVAL; @@ -6371,8 +6168,7 @@ sanei_genesys_read_calibration (Genesys_Device * dev) fread (&size, 4, 1, fp); if (size != sizeof (struct Genesys_Calibration_Cache)) { - DBG (DBG_info, - "Calibration: Size of calibration cache struct differs\n"); + DBG(DBG_info, "%s: Size of calibration cache struct differs\n", __func__); fclose (fp); DBGCOMPLETED; return SANE_STATUS_INVAL; @@ -6389,13 +6185,12 @@ sanei_genesys_read_calibration (Genesys_Device * dev) /* loop on cache records in file */ while (!feof (fp) && status==SANE_STATUS_GOOD) { - DBG (DBG_info, "sanei_genesys_read_calibration: reading one record\n"); + DBG(DBG_info, "%s: reading one record\n", __func__); cache = (struct Genesys_Calibration_Cache *) malloc (sizeof (*cache)); if (!cache) { - DBG (DBG_error, - "sanei_genesys_read_calibration: could not allocate cache struct\n"); + DBG(DBG_error, "%s: could not allocate cache struct\n", __func__); break; } @@ -6405,7 +6200,7 @@ sanei_genesys_read_calibration (Genesys_Device * dev) if ((x) < 1) \ { \ free(cache); \ - DBG (DBG_warn, "sanei_genesys_read_calibration: partial calibration record\n"); \ + DBG(DBG_warn, "%s: partial calibration record\n", __func__); \ status=SANE_STATUS_EOF; \ break; \ } \ @@ -6435,15 +6230,14 @@ sanei_genesys_read_calibration (Genesys_Device * dev) FREE_IFNOT_NULL (cache->white_average_data); FREE_IFNOT_NULL (cache->dark_average_data); free (cache); - DBG (DBG_error, - "sanei_genesys_read_calibration: could not allocate space for average data\n"); + DBG(DBG_error, "%s: could not allocate space for average data\n", __func__); break; } if (fread (cache->white_average_data, cache->average_size, 1, fp) < 1) { status=SANE_STATUS_EOF; - DBG (DBG_warn, "sanei_genesys_read_calibration: partial calibration record\n"); + DBG(DBG_warn, "%s: partial calibration record\n", __func__); free (cache->white_average_data); free (cache->dark_average_data); free (cache); @@ -6451,7 +6245,7 @@ sanei_genesys_read_calibration (Genesys_Device * dev) } if (fread (cache->dark_average_data, cache->average_size, 1, fp) < 1) { - DBG (DBG_warn, "sanei_genesys_read_calibration: partial calibration record\n"); + DBG(DBG_warn, "%s: partial calibration record\n", __func__); free (cache->white_average_data); free (cache->dark_average_data); free (cache); @@ -6459,7 +6253,7 @@ sanei_genesys_read_calibration (Genesys_Device * dev) break; } #undef BILT1 - DBG (DBG_info, "sanei_genesys_read_calibration: adding record to list\n"); + DBG(DBG_info, "%s: adding record to list\n", __func__); cache->next = dev->calibration_cache; dev->calibration_cache = cache; } @@ -6481,7 +6275,7 @@ write_calibration (Genesys_Device * dev) fp = fopen (dev->calib_file, "wb"); if (!fp) { - DBG (DBG_info, "write_calibration: Cannot open %s for writing\n", dev->calib_file); + DBG(DBG_info, "%s: Cannot open %s for writing\n", __func__, dev->calib_file); return; } @@ -6535,8 +6329,8 @@ genesys_buffer_image(Genesys_Scanner *s) lines = (SANE_UNFIX (dev->model->y_size) * dev->settings.yres) / MM_PER_INCH; } - DBG (DBG_info, "%s: buffering %d lines of %d bytes\n", __func__, lines, - s->params.bytes_per_line); + DBG(DBG_info, "%s: buffering %d lines of %d bytes\n", __func__, lines, + s->params.bytes_per_line); /* maximum bytes to read */ maximum = s->params.bytes_per_line * lines; @@ -6556,9 +6350,8 @@ genesys_buffer_image(Genesys_Scanner *s) dev->img_buffer = (SANE_Byte *) malloc (size); if (dev->img_buffer == NULL) { - DBG (DBG_error, - "%s: digital processing requires too much memory.\nConsider disabling it\n", - __func__); + DBG(DBG_error, "%s: digital processing requires too much memory.\nConsider disabling it\n", + __func__); return SANE_STATUS_NO_MEM; } @@ -6575,8 +6368,7 @@ genesys_buffer_image(Genesys_Scanner *s) if (status != SANE_STATUS_EOF && status != SANE_STATUS_GOOD) { free (s->dev->img_buffer); - DBG (DBG_error, "%s: %s buffering failed\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: %s buffering failed\n", __func__, sane_strstatus(status)); return status; } total += len; @@ -6588,9 +6380,9 @@ genesys_buffer_image(Genesys_Scanner *s) dev->img_buffer = (SANE_Byte *) realloc (dev->img_buffer, size); if (dev->img_buffer == NULL) { - DBG (DBG_error0, - "%s: digital processing requires too much memory.\nConsider disabling it\n", - __func__); + DBG(DBG_error0, + "%s: digital processing requires too much memory.\nConsider disabling it\n", + __func__); return SANE_STATUS_NO_MEM; } } @@ -6615,9 +6407,9 @@ genesys_buffer_image(Genesys_Scanner *s) lineart=(SANE_Byte *)malloc(total); if (lineart == NULL) { - DBG (DBG_error0, - "%s: digital processing requires too much memory.\nConsider disabling it\n", - __func__); + DBG(DBG_error0, + "%s: digital processing requires too much memory.\nConsider disabling it\n", + __func__); return SANE_STATUS_NO_MEM; } genesys_gray_lineart (dev, @@ -6657,19 +6449,19 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) SANE_Status status; DBG_INIT (); - DBG (DBG_init, "SANE Genesys backend version %d.%d build %d from %s\n", - SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); + DBG(DBG_init, "SANE Genesys backend version %d.%d build %d from %s\n", + SANE_CURRENT_MAJOR, V_MINOR, BUILD, PACKAGE_STRING); #ifdef HAVE_LIBUSB - DBG (DBG_init, "SANE Genesys backend built with libusb-1.0\n"); + DBG(DBG_init, "SANE Genesys backend built with libusb-1.0\n"); #endif #ifdef HAVE_LIBUSB_LEGACY - DBG (DBG_init, "SANE Genesys backend built with libusb\n"); + DBG(DBG_init, "SANE Genesys backend built with libusb\n"); #endif if (version_code) *version_code = SANE_VERSION_CODE (SANE_CURRENT_MAJOR, V_MINOR, BUILD); - DBG (DBG_proc, "sane_init: authorize %s null\n", authorize ? "!=" : "=="); + DBG(DBG_proc, "%s: authorize %s null\n", __func__, authorize ? "!=" : "=="); /* init usb use */ sanei_usb_init (); @@ -6677,7 +6469,7 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) /* init sanei_magic */ sanei_magic_init(); - DBG (DBG_info, "sane_init: %s endian machine\n", + DBG(DBG_info, "%s: %s endian machine\n", __func__, #ifdef WORDS_BIGENDIAN "big" #else @@ -6731,8 +6523,8 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) SANE_Int index; SANE_Device *sane_device; - DBG (DBG_proc, "sane_get_devices: start: local_only = %s\n", - local_only == SANE_TRUE ? "true" : "false"); + DBG(DBG_proc, "%s: start: local_only = %s\n", __func__, + local_only == SANE_TRUE ? "true" : "false"); /* hot-plug case : detection of newly connected scanners */ sanei_usb_scan_devices (); @@ -6821,7 +6613,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) Genesys_Scanner *s; char *tmpstr; - DBG (DBG_proc, "sane_open: start (devicename = `%s')\n", devicename); + DBG(DBG_proc, "%s: start (devicename = `%s')\n", __func__, devicename); /* devicename="" or devicename="genesys" are default values that use * first available device @@ -6835,14 +6627,11 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) if (!dev) { - DBG (DBG_info, - "sane_open: couldn't find `%s' in devlist, trying attach\n", - devicename); + DBG(DBG_info, "%s: couldn't find `%s' in devlist, trying attach\n", __func__, devicename); RIE (attach (devicename, &dev, SANE_TRUE)); } else - DBG (DBG_info, "sane_open: found `%s' in devlist\n", - dev->model->name); + DBG(DBG_info, "%s: found `%s' in devlist\n", __func__, dev->model->name); } else { @@ -6851,8 +6640,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) if (dev) { devicename = dev->file_name; - DBG (DBG_info, "sane_open: empty devicename, trying `%s'\n", - devicename); + DBG(DBG_info, "%s: empty devicename, trying `%s'\n", __func__, devicename); } } @@ -6861,23 +6649,19 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) if (dev->model->flags & GENESYS_FLAG_UNTESTED) { - DBG (DBG_error0, - "WARNING: Your scanner is not fully supported or at least \n"); - DBG (DBG_error0, - " had only limited testing. Please be careful and \n"); - DBG (DBG_error0, " report any failure/success to \n"); - DBG (DBG_error0, - " sane-devel@alioth-lists.debian.net. Please provide as many\n"); - DBG (DBG_error0, - " details as possible, e.g. the exact name of your\n"); - DBG (DBG_error0, " scanner and what does (not) work.\n"); + DBG(DBG_error0, "WARNING: Your scanner is not fully supported or at least \n"); + DBG(DBG_error0, " had only limited testing. Please be careful and \n"); + DBG(DBG_error0, " report any failure/success to \n"); + DBG(DBG_error0, " sane-devel@alioth-lists.debian.net. Please provide as many\n"); + DBG(DBG_error0, " details as possible, e.g. the exact name of your\n"); + DBG(DBG_error0, " scanner and what does (not) work.\n"); } status = sanei_usb_open (dev->file_name, &dev->dn); if (status != SANE_STATUS_GOOD) { - DBG (DBG_warn, "sane_open: couldn't open device `%s': %s\n", - dev->file_name, sane_strstatus (status)); + DBG(DBG_warn, "%s: couldn't open device `%s': %s\n", __func__, dev->file_name, + sane_strstatus(status)); return status; } @@ -6919,7 +6703,7 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) if (sanei_genesys_init_cmd_set (s->dev) != SANE_STATUS_GOOD) { - DBG (DBG_error0, "This device doesn't have a valid command set!!\n"); + DBG(DBG_error0, "This device doesn't have a valid command set!!\n"); return SANE_STATUS_IO_ERROR; } @@ -6932,8 +6716,8 @@ sane_open (SANE_String_Const devicename, SANE_Handle * handle) tmpstr=calibration_filename(s->dev); s->val[OPT_CALIBRATION_FILE].s = strdup (tmpstr); s->dev->calib_file = strdup (tmpstr); - DBG (DBG_info, "%s: Calibration filename set to:\n", __func__); - DBG (DBG_info, "%s: >%s<\n", __func__, s->dev->calib_file); + DBG(DBG_info, "%s: Calibration filename set to:\n", __func__); + DBG(DBG_info, "%s: >%s<\n", __func__, s->dev->calib_file); free(tmpstr); /* now open file, fetch calibration records */ @@ -6963,7 +6747,7 @@ sane_close (SANE_Handle handle) } if (!s) { - DBG (DBG_error, "sane_close: invalid handle %p\n", handle); + DBG(DBG_error, "%s: invalid handle %p\n", __func__, handle); return; /* oops, not a handle we know about */ } @@ -6981,9 +6765,8 @@ sane_close (SANE_Handle handle) status = sanei_genesys_wait_for_home (s->dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sane_close: failed to wait for head to park: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to wait for head to park: %s\n", __func__, + sane_strstatus(status)); } } } @@ -6992,9 +6775,8 @@ sane_close (SANE_Handle handle) status = s->dev->model->cmd_set->save_power (s->dev, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sane_close: failed to enable power saving mode: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to enable power saving mode: %s\n", __func__, + sane_strstatus(status)); } /* here is the place to store calibration cache */ @@ -7061,8 +6843,7 @@ sane_get_option_descriptor (SANE_Handle handle, SANE_Int option) if ((unsigned) option >= NUM_OPTIONS) return 0; - DBG (DBG_io2, "sane_get_option_descriptor: option = %s (%d)\n", - s->opt[option].name, option); + DBG(DBG_io2, "%s: option = %s (%d)\n", __func__, s->opt[option].name, option); return s->opt + option; } @@ -7200,8 +6981,7 @@ get_option_value (Genesys_Scanner * s, int option, void *val) } break; default: - DBG (DBG_warn, "get_option_value: can't get unknown option %d\n", - option); + DBG(DBG_warn, "%s: can't get unknown option %d\n", __func__, option); } return status; } @@ -7238,8 +7018,8 @@ static SANE_Status set_calibration_value (Genesys_Scanner * s, int option, void if (tmp) free (tmp); dev->calib_file = strdup (val); - DBG (DBG_info, "%s: Calibration filename set to:\n", __func__); - DBG (DBG_info, "%s: >%s<\n", __func__, s->dev->calib_file); + DBG(DBG_info, "%s: Calibration filename set to:\n", __func__); + DBG(DBG_info, "%s: >%s<\n", __func__, s->dev->calib_file); DBGCOMPLETED; return SANE_STATUS_GOOD; @@ -7527,9 +7307,8 @@ set_option_value (Genesys_Scanner * s, int option, void *val, status = s->dev->model->cmd_set->save_power (s->dev, SANE_FALSE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to disable power saving mode: %s\n", - __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to disable power saving mode: %s\n", __func__, + sane_strstatus(status)); } else status = genesys_scanner_calibration (s->dev); @@ -7558,8 +7337,7 @@ set_option_value (Genesys_Scanner * s, int option, void *val, break; default: - DBG (DBG_warn, "set_option_value: can't set unknown option %d\n", - option); + DBG(DBG_warn, "%s: can't set unknown option %d\n", __func__, option); } return status; } @@ -7575,10 +7353,8 @@ sane_control_option (SANE_Handle handle, SANE_Int option, SANE_Word cap; SANE_Int myinfo = 0; - DBG (DBG_io2, - "sane_control_option: start: action = %s, option = %s (%d)\n", - (action == SANE_ACTION_GET_VALUE) ? "get" : (action == - SANE_ACTION_SET_VALUE) ? + DBG(DBG_io2, "%s: start: action = %s, option = %s (%d)\n", __func__, + (action == SANE_ACTION_GET_VALUE) ? "get" : (action == SANE_ACTION_SET_VALUE) ? "set" : (action == SANE_ACTION_SET_AUTO) ? "set_auto" : "unknown", s->opt[option].name, option); @@ -7587,16 +7363,14 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if (s->scanning) { - DBG (DBG_warn, "sane_control_option: don't call this function while " - "scanning (option = %s (%d))\n", s->opt[option].name, option); + DBG(DBG_warn, "%s: don't call this function while scanning (option = %s (%d))\n", __func__, + s->opt[option].name, option); return SANE_STATUS_DEVICE_BUSY; } if (option >= NUM_OPTIONS || option < 0) { - DBG (DBG_warn, - "sane_control_option: option %d >= NUM_OPTIONS || option < 0\n", - option); + DBG(DBG_warn, "%s: option %d >= NUM_OPTIONS || option < 0\n", __func__, option); return SANE_STATUS_INVAL; } @@ -7604,7 +7378,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if (!SANE_OPTION_IS_ACTIVE (cap)) { - DBG (DBG_warn, "sane_control_option: option %d is inactive\n", option); + DBG(DBG_warn, "%s: option %d is inactive\n", __func__, option); return SANE_STATUS_INVAL; } @@ -7617,17 +7391,15 @@ sane_control_option (SANE_Handle handle, SANE_Int option, case SANE_ACTION_SET_VALUE: if (!SANE_OPTION_IS_SETTABLE (cap)) { - DBG (DBG_warn, "sane_control_option: option %d is not settable\n", - option); + DBG(DBG_warn, "%s: option %d is not settable\n", __func__, option); return SANE_STATUS_INVAL; } status = sanei_constrain_value (s->opt + option, val, &myinfo); if (status != SANE_STATUS_GOOD) { - DBG (DBG_warn, - "sane_control_option: sanei_constrain_value returned %s\n", - sane_strstatus (status)); + DBG(DBG_warn, "%s: sanei_constrain_value returned %s\n", __func__, + sane_strstatus(status)); return status; } @@ -7635,14 +7407,14 @@ sane_control_option (SANE_Handle handle, SANE_Int option, break; case SANE_ACTION_SET_AUTO: - DBG (DBG_error, - "sane_control_option: SANE_ACTION_SET_AUTO unsupported since no option has SANE_CAP_AUTOMATIC\n"); + DBG(DBG_error, + "%s: SANE_ACTION_SET_AUTO unsupported since no option has SANE_CAP_AUTOMATIC\n", + __func__); status = SANE_STATUS_INVAL; break; default: - DBG (DBG_warn, "sane_control_option: unknown action %d for option %d\n", - action, option); + DBG(DBG_warn, "%s: unknown action %d for option %d\n", __func__, action, option); status = SANE_STATUS_INVAL; break; } @@ -7650,7 +7422,7 @@ sane_control_option (SANE_Handle handle, SANE_Int option, if (info) *info = myinfo; - DBG (DBG_io2, "sane_control_option: exit\n"); + DBG(DBG_io2, "%s: exit\n", __func__); return status; } @@ -7701,14 +7473,12 @@ sane_start (SANE_Handle handle) if (s->val[OPT_TL_X].w >= s->val[OPT_BR_X].w) { - DBG (DBG_error0, - "sane_start: top left x >= bottom right x --- exiting\n"); + DBG(DBG_error0, "%s: top left x >= bottom right x --- exiting\n", __func__); return SANE_STATUS_INVAL; } if (s->val[OPT_TL_Y].w >= s->val[OPT_BR_Y].w) { - DBG (DBG_error0, - "sane_start: top left y >= bottom right y --- exiting\n"); + DBG(DBG_error0, "%s: top left y >= bottom right y --- exiting\n", __func__); return SANE_STATUS_INVAL; } @@ -7748,7 +7518,7 @@ sane_start (SANE_Handle handle) { if (s->dev->model->is_sheetfed == SANE_TRUE) { - DBG (DBG_info, "sane_start: blank page, recurse\n"); + DBG(DBG_info, "%s: blank page, recurse\n", __func__); return sane_start(handle); } return status; @@ -7795,26 +7565,26 @@ sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, if (!s) { - DBG (DBG_error, "sane_read: handle is null!\n"); + DBG(DBG_error, "%s: handle is null!\n", __func__); return SANE_STATUS_INVAL; } dev=s->dev; if (!dev) { - DBG (DBG_error, "sane_read: dev is null!\n"); + DBG(DBG_error, "%s: dev is null!\n", __func__); return SANE_STATUS_INVAL; } if (!buf) { - DBG (DBG_error, "sane_read: buf is null!\n"); + DBG(DBG_error, "%s: buf is null!\n", __func__); return SANE_STATUS_INVAL; } if (!len) { - DBG (DBG_error, "sane_read: len is null!\n"); + DBG(DBG_error, "%s: len is null!\n", __func__); return SANE_STATUS_INVAL; } @@ -7822,19 +7592,18 @@ sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, if (!s->scanning) { - DBG (DBG_warn, "sane_read: scan was cancelled, is over or has not been " - "initiated yet\n"); + DBG(DBG_warn, "%s: scan was cancelled, is over or has not been initiated yet\n", __func__); return SANE_STATUS_CANCELLED; } - DBG (DBG_proc, "sane_read: start, %d maximum bytes required\n", max_len); - DBG (DBG_io2, "sane_read: bytes_to_read=%lu, total_bytes_read=%lu\n", - (u_long) dev->total_bytes_to_read, (u_long) dev->total_bytes_read); - DBG (DBG_io2, "sane_read: physical bytes to read = %lu\n", (u_long) dev->read_bytes_left); + 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: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left); if(dev->total_bytes_read>=dev->total_bytes_to_read) { - DBG (DBG_proc, "sane_read: nothing more to scan: EOF\n"); + DBG(DBG_proc, "%s: nothing more to scan: EOF\n", __func__); /* issue park command immediatly in case scanner can handle it * so we save time */ @@ -7915,7 +7684,7 @@ sane_read (SANE_Handle handle, SANE_Byte * buf, SANE_Int max_len, { fprintf (stderr, "[genesys] sane_read: returning incorrect length!!\n"); } - DBG (DBG_proc, "sane_read: %d bytes returned\n", *len); + DBG(DBG_proc, "%s: %d bytes returned\n", __func__, *len); return status; } @@ -7948,8 +7717,7 @@ sane_cancel (SANE_Handle handle) status = s->dev->model->cmd_set->end_scan (s->dev, s->dev->reg, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sane_cancel: failed to end scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to end scan: %s\n", __func__, sane_strstatus(status)); return; } } @@ -7962,9 +7730,8 @@ sane_cancel (SANE_Handle handle) status = s->dev->model->cmd_set->slow_back_home (s->dev, s->dev->model->flags & GENESYS_FLAG_MUST_WAIT); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sane_cancel: failed to move scanhead to home position: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to move scanhead to home position: %s\n", __func__, + sane_strstatus(status)); return; } s->dev->parking = !(s->dev->model->flags & GENESYS_FLAG_MUST_WAIT); @@ -7975,8 +7742,7 @@ sane_cancel (SANE_Handle handle) status = s->dev->model->cmd_set->eject_document (s->dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sane_cancel: failed to eject document: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to eject document: %s\n", __func__, sane_strstatus(status)); return; } } @@ -7987,8 +7753,8 @@ sane_cancel (SANE_Handle handle) status = s->dev->model->cmd_set->save_power (s->dev, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sane_cancel: failed to enable power saving mode: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to enable power saving mode: %s\n", __func__, + sane_strstatus(status)); return; } } @@ -8002,12 +7768,12 @@ sane_set_io_mode (SANE_Handle handle, SANE_Bool non_blocking) { Genesys_Scanner *s = handle; - DBG (DBG_proc, "sane_set_io_mode: handle = %p, non_blocking = %s\n", - handle, non_blocking == SANE_TRUE ? "true" : "false"); + DBG(DBG_proc, "%s: handle = %p, non_blocking = %s\n", __func__, handle, + non_blocking == SANE_TRUE ? "true" : "false"); if (!s->scanning) { - DBG (DBG_error, "sane_set_io_mode: not scanning\n"); + DBG(DBG_error, "%s: not scanning\n", __func__); return SANE_STATUS_INVAL; } if (non_blocking) @@ -8020,12 +7786,11 @@ sane_get_select_fd (SANE_Handle handle, SANE_Int * fd) { Genesys_Scanner *s = handle; - DBG (DBG_proc, "sane_get_select_fd: handle = %p, fd = %p\n", handle, - (void *) fd); + DBG(DBG_proc, "%s: handle = %p, fd = %p\n", __func__, handle, (void *) fd); if (!s->scanning) { - DBG (DBG_error, "sane_get_select_fd: not scanning\n"); + DBG(DBG_error, "%s: not scanning\n", __func__); return SANE_STATUS_INVAL; } return SANE_STATUS_UNSUPPORTED; diff --git a/backend/genesys_conv.c b/backend/genesys_conv.c index 61f466e88..7329a3cb1 100644 --- a/backend/genesys_conv.c +++ b/backend/genesys_conv.c @@ -194,9 +194,9 @@ genesys_gray_lineart( { size_t y; - DBG (DBG_io2, "genesys_gray_lineart: converting %lu lines of %lu pixels\n", - (unsigned long)lines, (unsigned long)pixels); - DBG (DBG_io2, "genesys_gray_lineart: threshold=%d\n",threshold); + DBG(DBG_io2, "%s: converting %lu lines of %lu pixels\n", __func__, (unsigned long)lines, + (unsigned long)pixels); + DBG(DBG_io2, "%s: threshold=%d\n", __func__, threshold); for (y = 0; y < lines; y++) { diff --git a/backend/genesys_gl124.c b/backend/genesys_gl124.c index effb70944..668663f60 100644 --- a/backend/genesys_gl124.c +++ b/backend/genesys_gl124.c @@ -73,7 +73,7 @@ gl124_bulk_read_data (Genesys_Device * dev, uint8_t addr, size_t size, target, read, done; uint8_t outdata[8], *buffer; - DBG (DBG_io, "gl124_bulk_read_data: requesting %lu bytes (unused addr=0x%02x)\n", (u_long) len,addr); + DBG(DBG_io, "%s: requesting %lu bytes (unused addr=0x%02x)\n", __func__, (u_long) len,addr); if (len == 0) return SANE_STATUS_GOOD; @@ -123,15 +123,12 @@ gl124_bulk_read_data (Genesys_Device * dev, uint8_t addr, if(read>0) { - DBG (DBG_io2, - "gl124_bulk_read_data: trying to read %lu bytes of data\n", - (u_long) read); + DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read); status = sanei_usb_read_bulk (dev->dn, data, &read); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_bulk_read_data failed while reading bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -141,15 +138,12 @@ gl124_bulk_read_data (Genesys_Device * dev, uint8_t addr, { done = read; read = size - read; - DBG (DBG_io2, - "gl124_bulk_read_data: trying to read remaining %lu bytes of data\n", - (u_long) read); + DBG(DBG_io2, "%s: trying to read remaining %lu bytes of data\n", __func__, (u_long) read); status = sanei_usb_read_bulk (dev->dn, data+done, &read); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_bulk_read_data failed while reading bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -744,9 +738,7 @@ gl124_set_ti_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, i, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to write reg %d: %s\n", __func__, i, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write reg %d: %s\n", __func__, i, sane_strstatus(status)); return status; } } @@ -802,14 +794,12 @@ gl124_set_fe (Genesys_Device * dev, uint8_t set) SANE_Status status; uint8_t val; - DBG (DBG_proc, "gl124_set_fe (%s)\n", - set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == - AFE_POWER_SAVE ? "powersave" : "huh?"); + DBG(DBG_proc, "%s (%s)\n", __func__, set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == + AFE_POWER_SAVE ? "powersave" : "huh?"); if (set == AFE_INIT) { - DBG (DBG_proc, "gl124_set_fe(): setting DAC %u\n", - dev->model->dac_type); + DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); sanei_genesys_init_fe (dev); } @@ -830,7 +820,7 @@ gl124_set_fe (Genesys_Device * dev, uint8_t set) case 1: case 2: default: - DBG (DBG_error, "%s: unsupported analog FE 0x%02x\n",__func__,val); + DBG(DBG_error, "%s: unsupported analog FE 0x%02x\n", __func__, val); status=SANE_STATUS_INVAL; break; } @@ -881,13 +871,9 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, unsigned int linesel; DBGSTART; - DBG (DBG_info, "gl124_init_motor_regs_scan : scan_exposure_time=%d, " - "scan_yres=%g, scan_step_type=%d, scan_lines=%d, scan_dummy=%d, " - "feed_steps=%d, scan_mode=%d, flags=%x\n", - scan_exposure_time, - scan_yres, - scan_step_type, - scan_lines, scan_dummy, feed_steps, scan_mode, flags); + DBG(DBG_info, "%s : scan_exposure_time=%d, scan_yres=%g, scan_step_type=%d, scan_lines=%d, " + "scan_dummy=%d, feed_steps=%d, scan_mode=%d, flags=%x\n", __func__, scan_exposure_time, + scan_yres, scan_step_type, scan_lines, scan_dummy, feed_steps, scan_mode, flags); /* we never use fast fed since we do manual feed for the scans */ use_fast_fed=0; @@ -1037,11 +1023,11 @@ gl124_init_motor_regs_scan (Genesys_Device * dev, &z1, &z2); - sanei_genesys_set_triple(reg,REG_Z1MOD,z1); - DBG (DBG_info, "gl124_init_motor_regs_scan: z1 = %d\n", z1); + sanei_genesys_set_triple(reg, REG_Z1MOD,z1); + DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); - sanei_genesys_set_triple(reg,REG_Z2MOD,z2); - DBG (DBG_info, "gl124_init_motor_regs_scan: z2 = %d\n", z2); + sanei_genesys_set_triple(reg, REG_Z2MOD, z2); + DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); /* LINESEL */ r = sanei_genesys_get_address (reg, REG1D); @@ -1219,10 +1205,9 @@ gl124_init_optical_regs_scan (Genesys_Device * dev, SANE_Status status; uint32_t expmax, exp; - DBG (DBG_proc, "%s : exposure_time=%d, " - "used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " - "half_ccd=%d, flags=%x\n", __func__, exposure_time, - used_res, start, pixels, channels, depth, half_ccd, flags); + DBG(DBG_proc, "%s : exposure_time=%d, used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " + "half_ccd=%d, flags=%x\n", __func__, exposure_time, used_res, start, pixels, channels, depth, + half_ccd, flags); /* resolution is divided according to CKSEL */ r = sanei_genesys_get_address (reg, REG18); @@ -1510,15 +1495,15 @@ gl124_init_scan_regs (Genesys_Device * dev, int optical_res; SANE_Status status; - DBG (DBG_info, - "gl124_init_scan_regs settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g/%g\n" - "Depth/Channels: %u/%u\n" - "Flags : %x\n\n", - xres, yres, lines, pixels, startx, starty, depth, channels, flags); + DBG(DBG_info, + "%s:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g/%g\n" + "Depth/Channels: %u/%u\n" + "Flags : %x\n\n", + __func__, xres, yres, lines, pixels, startx, starty, depth, channels, flags); half_ccd=compute_half_ccd(dev->model, xres); @@ -1591,8 +1576,8 @@ gl124_init_scan_regs (Genesys_Device * dev, scan_step_type = sanei_genesys_compute_step_type(motors, dev->model->motor_type, exposure_time); } - DBG (DBG_info, "gl124_init_scan_regs : exposure_time=%d pixels\n", exposure_time); - DBG (DBG_info, "gl124_init_scan_regs : scan_step_type=%d\n", scan_step_type); + DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); + DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type); /*** optical parameters ***/ /* in case of dynamic lineart, we use an internal 8 bit gray scan @@ -1645,7 +1630,7 @@ gl124_init_scan_regs (Genesys_Device * dev, /* add tl_y to base movement */ move = starty; - DBG (DBG_info, "gl124_init_scan_regs: move=%d steps\n", move); + DBG(DBG_info, "%s: move=%d steps\n", __func__, move); mflags=0; if(flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) @@ -1699,14 +1684,12 @@ gl124_init_scan_regs (Genesys_Device * dev, dev->read_bytes_left = bytes_per_line * lincnt; - DBG (DBG_info, - "gl124_init_scan_regs: physical bytes to read = %lu\n", - (u_long) dev->read_bytes_left); + DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left); dev->read_active = SANE_TRUE; dev->current_setup.pixels = (used_pixels * used_res) / optical_res; - DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); + DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.depth = depth; dev->current_setup.channels = channels; @@ -1727,8 +1710,7 @@ gl124_init_scan_regs (Genesys_Device * dev, dev->total_bytes_to_read = dev->settings.pixels * dev->settings.lines * channels * (depth / 8); - DBG (DBG_info, "gl124_init_scan_regs: total bytes to send = %lu\n", - (u_long) dev->total_bytes_to_read); + DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read); DBGCOMPLETED; return SANE_STATUS_GOOD; @@ -1759,16 +1741,17 @@ gl124_calculate_current_setup (Genesys_Device * dev) int optical_res; - DBG (DBG_info, - "gl124_calculate_current_setup settings:\n" - "Resolution: %ux%uDPI\n" - "Lines : %u\n" - "PPL : %u\n" - "Startpos : %.3f/%.3f\n" - "Scan mode : %d\n\n", - dev->settings.xres, - dev->settings.yres, dev->settings.lines, dev->settings.pixels, - dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); + DBG(DBG_info, + "%s:\n" + "Resolution: %ux%uDPI\n" + "Lines : %u\n" + "PPL : %u\n" + "Startpos : %.3f/%.3f\n" + "Scan mode : %d\n\n", + __func__, + dev->settings.xres, + dev->settings.yres, dev->settings.lines, dev->settings.pixels, + dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); /* channels */ if (dev->settings.scan_mode == 4) /* single pass color */ @@ -1795,15 +1778,15 @@ gl124_calculate_current_setup (Genesys_Device * dev) half_ccd=compute_half_ccd(dev->model, xres); - DBG (DBG_info, - "gl124_calculate_current_setup settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g\n" - "Half ccd : %d\n" - "Depth/Channels: %u/%u\n\n", - xres, yres, lines, pixels, startx, depth, half_ccd, channels); + DBG(DBG_info, + "%s:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g\n" + "Half ccd : %d\n" + "Depth/Channels: %u/%u\n\n", + __func__, xres, yres, lines, pixels, startx, depth, half_ccd, channels); /* optical_res */ optical_res = dev->sensor.optical_res; @@ -1864,7 +1847,7 @@ static void gl124_set_motor_power (Genesys_Register_Set * regs, SANE_Bool set) { - DBG (DBG_proc, "gl124_set_motor_power\n"); + DBG(DBG_proc, "%s\n", __func__); if (set) { @@ -1913,7 +1896,7 @@ gl124_set_lamp_power (Genesys_Device * dev, static SANE_Status gl124_save_power (Genesys_Device * dev, SANE_Bool enable) { - DBG (DBG_proc, "gl124_save_power: enable = %d\n", enable); + DBG(DBG_proc, "%s: enable = %d\n", __func__, enable); if (dev == NULL) return SANE_STATUS_INVAL; @@ -1926,7 +1909,7 @@ gl124_set_powersaving (Genesys_Device * dev, int delay /* in minutes */ ) { Genesys_Register_Set *r; - DBG (DBG_proc, "gl124_set_powersaving (delay = %d)\n", delay); + DBG(DBG_proc, "%s (delay = %d)\n", __func__, delay); r = sanei_genesys_get_address (dev->reg, REG03); r->value &= ~0xf0; @@ -1970,9 +1953,7 @@ gl124_stop_action (Genesys_Device * dev) status = sanei_genesys_read_register (dev, REG100, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read reg100: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read reg100: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2138,7 +2119,7 @@ gl124_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, { SANE_Status status; - DBG (DBG_proc, "gl124_end_scan (check_stop = %d)\n", check_stop); + DBG(DBG_proc, "%s (check_stop = %d)\n", __func__, check_stop); if (reg == NULL) return SANE_STATUS_INVAL; @@ -2151,9 +2132,7 @@ gl124_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, status = gl124_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_end_scan: failed to stop: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -2217,8 +2196,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) float resolution; int loop = 0; - DBG (DBG_proc, "gl124_slow_back_home (wait_until_home = %d)\n", - wait_until_home); + DBG(DBG_proc, "%s (wait_until_home = %d)\n", __func__, wait_until_home); if(dev->usb_mode<0) { @@ -2233,9 +2211,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io) @@ -2248,9 +2224,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io) @@ -2273,7 +2247,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl124_feed (dev, 20, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to do initial feed: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to do initial feed: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -2299,9 +2273,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_slow_back_home: failed to set up registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2320,9 +2292,7 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl124_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_slow_back_home: failed to start motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl124_stop_action (dev); /* restore original registers */ dev->model->cmd_set->bulk_write_register (dev, dev->reg, GENESYS_GL124_MAX_REGS); @@ -2340,15 +2310,14 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, + sane_strstatus(status)); return status; } if (val & HOMESNR) /* home sensor */ { - DBG (DBG_info, "gl124_slow_back_home: reached home position\n"); + DBG(DBG_info, "%s: reached home position\n", __func__); DBGCOMPLETED; dev->scanhead_position_in_steps = 0; return SANE_STATUS_GOOD; @@ -2359,12 +2328,11 @@ gl124_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* when we come here then the scanner needed too much time for this, so we better stop the motor */ gl124_stop_action (dev); - DBG (DBG_error, - "gl124_slow_back_home: timeout while waiting for scanhead to go home\n"); + DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); return SANE_STATUS_IO_ERROR; } - DBG (DBG_info, "gl124_slow_back_home: scanhead is still moving\n"); + DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -2506,9 +2474,7 @@ gl124_search_start_position (Genesys_Device * dev) SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE); if (status!=SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to init scan registers: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to init scan registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2516,9 +2482,7 @@ gl124_search_start_position (Genesys_Device * dev) status = dev->model->cmd_set->bulk_write_register (dev, local_reg, GENESYS_GL124_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_search_start_position: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2527,8 +2491,7 @@ gl124_search_start_position (Genesys_Device * dev) data = malloc (size); if (!data) { - DBG (DBG_error, - "gl124_search_start_position: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2536,9 +2499,7 @@ gl124_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl124_search_start_position: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2552,9 +2513,7 @@ gl124_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl124_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2566,9 +2525,7 @@ gl124_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl124_search_start_position: failed to end scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2582,9 +2539,8 @@ gl124_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl124_search_start_position: failed to set search reference point: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set search reference point: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -2632,23 +2588,18 @@ gl124_init_regs_for_coarse_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_init_register_for_coarse_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } gl124_set_motor_power (dev->calib_reg, SANE_FALSE); - DBG (DBG_info, - "gl124_init_register_for_coarse_calibration: optical sensor res: %d dpi, actual res: %d\n", - dev->sensor.optical_res / cksel, dev->settings.xres); + DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, + dev->sensor.optical_res / cksel, dev->settings.xres); status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL124_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_init_register_for_coarse_calibration: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2754,16 +2705,15 @@ gl124_init_regs_for_scan (Genesys_Device * dev) SANE_Status status; - DBG (DBG_info, - "gl124_init_regs_for_scan settings:\nResolution: %ux%uDPI\n" - "Lines : %u\npixels : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", - dev->settings.xres, - dev->settings.yres, - dev->settings.lines, - dev->settings.pixels, - dev->settings.tl_x, - dev->settings.tl_y, - dev->settings.scan_mode); + DBG(DBG_info, "%s:\nResolution: %ux%uDPI\n" + "Lines : %u\npixels : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", __func__, + dev->settings.xres, + dev->settings.yres, + dev->settings.lines, + dev->settings.pixels, + dev->settings.tl_x, + dev->settings.tl_y, + dev->settings.scan_mode); /* wait for motor to stop first */ status = sanei_genesys_get_status (dev, &val); @@ -2834,7 +2784,7 @@ gl124_init_regs_for_scan (Genesys_Device * dev) } move=500; } - DBG (DBG_info, "gl124_init_regs_for_scan: move=%f steps\n", move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ start = SANE_UNFIX (dev->model->x_offset); @@ -2991,8 +2941,7 @@ gl124_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = sanei_genesys_write_ahb (dev->dn, dev->usb_mode, addr, pixels*dev->segnb, buffer); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl124_send_shading_data; write to AHB failed (%s)\n", - sane_strstatus (status)); + DBG(DBG_error, "%s; write to AHB failed (%s)\n", __func__, sane_strstatus(status)); return status; } } @@ -3174,7 +3123,7 @@ gl124_led_calibration (Genesys_Device * dev) /* write registers and scan data */ RIEF (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL124_MAX_REGS), line); - DBG (DBG_info, "gl124_led_calibration: starting line reading\n"); + DBG(DBG_info, "%s: starting line reading\n", __func__); RIEF (gl124_begin_scan (dev, dev->calib_reg, SANE_TRUE), line); RIEF (sanei_genesys_read_data_from_scanner (dev, line, total_size), line); @@ -3207,7 +3156,7 @@ gl124_led_calibration (Genesys_Device * dev) avg[j] /= num_pixels; } - DBG (DBG_info, "gl124_led_calibration: average: %d,%d,%d\n", avg[0], avg[1], avg[2]); + DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); /* check if exposure gives average within the boundaries */ acceptable = SANE_TRUE; @@ -3225,7 +3174,7 @@ gl124_led_calibration (Genesys_Device * dev) } while (!acceptable && turn < 100); - DBG (DBG_info, "gl124_led_calibration: acceptable exposure: %d,%d,%d\n", exp[0], exp[1], exp[2]); + DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0], exp[1], exp[2]); /* set these values as final ones for scan */ sanei_genesys_set_triple(dev->reg,REG_EXPR,exp[0]); @@ -3274,13 +3223,13 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines, } if (count) avg[k] /= count; - DBG (DBG_info, "dark_average: avg[%d] = %d\n", k, avg[k]); + DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } average = 0; for (i = 0; i < channels; i++) average += avg[i]; average /= channels; - DBG (DBG_info, "dark_average: average = %d\n", average); + DBG(DBG_info, "%s: average = %d\n", __func__, average); return average; } @@ -3314,7 +3263,7 @@ gl124_offset_calibration (Genesys_Device * dev) bpp=8; pixels= (dev->sensor.sensor_pixels*resolution) / dev->sensor.optical_res; black_pixels = (dev->sensor.black_pixels * resolution) / dev->sensor.optical_res; - DBG (DBG_io2, "gl124_offset_calibration: black_pixels=%d\n", black_pixels); + DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); status = gl124_init_scan_regs (dev, dev->calib_reg, @@ -3335,9 +3284,7 @@ gl124_offset_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_offset_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } gl124_set_motor_power (dev->calib_reg, SANE_FALSE); @@ -3369,7 +3316,7 @@ gl124_offset_calibration (Genesys_Device * dev) RIEF2 (gl124_set_fe(dev, AFE_SET), first_line, second_line); RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL124_MAX_REGS), first_line, second_line); - DBG (DBG_info, "gl124_offset_calibration: starting first line reading\n"); + DBG(DBG_info, "%s: starting first line reading\n", __func__); RIEF2 (gl124_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, first_line, total_size), first_line, second_line); if (DBG_LEVEL >= DBG_data) @@ -3379,7 +3326,7 @@ gl124_offset_calibration (Genesys_Device * dev) } bottomavg = dark_average (first_line, pixels, lines, channels, black_pixels); - DBG (DBG_io2, "gl124_offset_calibration: bottom avg=%d\n", bottomavg); + DBG(DBG_io2, "%s: bottom avg=%d\n", __func__, bottomavg); /* now top value */ top = 255; @@ -3388,12 +3335,12 @@ gl124_offset_calibration (Genesys_Device * dev) dev->frontend.offset[2] = top; RIEF2 (gl124_set_fe(dev, AFE_SET), first_line, second_line); RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL124_MAX_REGS), first_line, second_line); - DBG (DBG_info, "gl124_offset_calibration: starting second line reading\n"); + DBG(DBG_info, "%s: starting second line reading\n", __func__); RIEF2 (gl124_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size), first_line, second_line); topavg = dark_average (second_line, pixels, lines, channels, black_pixels); - DBG (DBG_io2, "gl124_offset_calibration: top avg=%d\n", topavg); + DBG(DBG_io2, "%s: top avg=%d\n", __func__, topavg); /* loop until acceptable level */ while ((pass < 32) && (top - bottom > 1)) @@ -3408,7 +3355,7 @@ gl124_offset_calibration (Genesys_Device * dev) /* scan with no move */ RIEF2 (gl124_set_fe(dev, AFE_SET), first_line, second_line); RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL124_MAX_REGS), first_line, second_line); - DBG (DBG_info, "gl124_offset_calibration: starting second line reading\n"); + DBG(DBG_info, "%s: starting second line reading\n", __func__); RIEF2 (gl124_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size), first_line, second_line); @@ -3419,8 +3366,7 @@ gl124_offset_calibration (Genesys_Device * dev) } avg = dark_average (second_line, pixels, lines, channels, black_pixels); - DBG (DBG_info, "gl124_offset_calibration: avg=%d offset=%d\n", avg, - dev->frontend.offset[1]); + DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.offset[1]); /* compute new boundaries */ if (topavg == avg) @@ -3434,7 +3380,8 @@ gl124_offset_calibration (Genesys_Device * dev) bottom = dev->frontend.offset[1]; } } - DBG (DBG_info, "gl124_offset_calibration: offset=(%d,%d,%d)\n", dev->frontend.offset[0], dev->frontend.offset[1], dev->frontend.offset[2]); + DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0], + dev->frontend.offset[1], dev->frontend.offset[2]); /* cleanup before return */ free (first_line); @@ -3468,7 +3415,7 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, int dpi) int resolution; int bpp; - DBG (DBG_proc, "gl124_coarse_gain_calibration: dpi = %d\n", dpi); + DBG(DBG_proc, "%s: dpi = %d\n", __func__, dpi); /* no gain nor offset for TI AFE */ RIE (sanei_genesys_read_register (dev, REG0A, ®0a)); @@ -3518,9 +3465,7 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_coarse_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3579,9 +3524,8 @@ gl124_coarse_gain_calibration (Genesys_Device * dev, int dpi) code = 0; dev->frontend.gain[j] = code; - DBG (DBG_proc, - "gl124_coarse_gain_calibration: channel %d, max=%d, gain = %f, setting:%d\n", - j, max[j], gain[j], dev->frontend.gain[j]); + DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], + gain[j], dev->frontend.gain[j]); } if (dev->model->is_cis) @@ -3648,9 +3592,7 @@ gl124_init_regs_for_warmup (Genesys_Device * dev, if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl124_init_regs_for_warmup: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3826,9 +3768,7 @@ gl124_boot (Genesys_Device * dev, SANE_Bool cold) if (val & REG100_CHKVER) { RIE (sanei_genesys_read_register (dev, 0x00, &val)); - DBG (DBG_info, - "gl124_cold_boot: reported version for genesys chip is 0x%02x\n", - val); + DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ diff --git a/backend/genesys_gl646.c b/backend/genesys_gl646.c index 11f5b3361..521394508 100644 --- a/backend/genesys_gl646.c +++ b/backend/genesys_gl646.c @@ -113,8 +113,7 @@ gl646_bulk_write_register (Genesys_Device * dev, elems = i; size = i * 2; - DBG (DBG_io, "gl646_bulk_write_register (elems= %lu, size = %lu)\n", - (u_long) elems, (u_long) size); + DBG(DBG_io, "%s (elems= %lu, size = %lu)\n", __func__, (u_long) elems, (u_long) size); outdata[0] = BULK_OUT; @@ -131,9 +130,7 @@ gl646_bulk_write_register (Genesys_Device * dev, VALUE_BUFFER, INDEX, sizeof (outdata), outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_bulk_write_register: failed while writing command: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing command: %s\n", __func__, sane_strstatus(status)); return status; } @@ -147,9 +144,7 @@ gl646_bulk_write_register (Genesys_Device * dev, status = sanei_usb_write_bulk (dev->dn, buffer, &size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_bulk_write_register: failed while writing bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing bulk data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -157,32 +152,31 @@ gl646_bulk_write_register (Genesys_Device * dev, { for (i = 0; i < size; i += 2) { - DBG (DBG_io2, "reg[0x%02x] = 0x%02x\n", buffer[i], buffer[i + 1]); + DBG(DBG_io2, "reg[0x%02x] = 0x%02x\n", buffer[i], buffer[i + 1]); } /* when full size, decode register content */ if (elems > 60) { - DBG (DBG_io2, "DPISET =%d\n", - gl646_get_double_reg (reg, REG_DPISET)); - DBG (DBG_io2, "DUMMY =%d\n", - sanei_genesys_get_address (reg, REG_DUMMY)->value); - DBG (DBG_io2, "STRPIXEL =%d\n", - gl646_get_double_reg (reg, REG_STRPIXEL)); - DBG (DBG_io2, "ENDPIXEL =%d\n", - gl646_get_double_reg (reg, REG_ENDPIXEL)); - DBG (DBG_io2, "LINCNT =%d\n", - gl646_get_triple_reg (reg, REG_LINCNT)); - DBG (DBG_io2, "MAXWD =%d\n", - gl646_get_triple_reg (reg, REG_MAXWD)); - DBG (DBG_io2, "LPERIOD =%d\n", - gl646_get_double_reg (reg, REG_LPERIOD)); - DBG (DBG_io2, "FEEDL =%d\n", - gl646_get_triple_reg (reg, REG_FEEDL)); + DBG(DBG_io2, "DPISET =%d\n", + gl646_get_double_reg (reg, REG_DPISET)); + DBG(DBG_io2, "DUMMY =%d\n", + sanei_genesys_get_address (reg, REG_DUMMY)->value); + DBG(DBG_io2, "STRPIXEL =%d\n", + gl646_get_double_reg (reg, REG_STRPIXEL)); + DBG(DBG_io2, "ENDPIXEL =%d\n", + gl646_get_double_reg (reg, REG_ENDPIXEL)); + DBG(DBG_io2, "LINCNT =%d\n", + gl646_get_triple_reg (reg, REG_LINCNT)); + DBG(DBG_io2, "MAXWD =%d\n", + gl646_get_triple_reg (reg, REG_MAXWD)); + DBG(DBG_io2, "LPERIOD =%d\n", + gl646_get_double_reg (reg, REG_LPERIOD)); + DBG(DBG_io2, "FEEDL =%d\n", + gl646_get_triple_reg (reg, REG_FEEDL)); } } - DBG (DBG_io, "gl646_bulk_write_register: wrote %lu bytes, %lu registers\n", - (u_long) size, (u_long) elems); + DBG(DBG_io, "%s: wrote %lu bytes, %lu registers\n", __func__, (u_long) size, (u_long) elems); return status; } @@ -195,16 +189,14 @@ gl646_bulk_write_data (Genesys_Device * dev, uint8_t addr, size_t size; uint8_t outdata[8]; - DBG (DBG_io, "gl646_bulk_write_data writing %lu bytes\n", (u_long) len); + DBG(DBG_io, "%s writing %lu bytes\n", __func__, (u_long) len); status = sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, INDEX, 1, &addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_bulk_write_data failed while setting register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while setting register: %s\n", __func__, sane_strstatus(status)); return status; } @@ -230,30 +222,26 @@ gl646_bulk_write_data (Genesys_Device * dev, uint8_t addr, outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_bulk_write_data failed while writing command: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing command: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_usb_write_bulk (dev->dn, data, &size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_bulk_write_data failed while writing bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_io2, - "gl646_bulk_write_data wrote %lu bytes, %lu remaining\n", - (u_long) size, (u_long) (len - size)); + DBG(DBG_io2, "%s wrote %lu bytes, %lu remaining\n", __func__, (u_long) size, + (u_long) (len - size)); len -= size; data += size; } - DBG (DBG_io, "gl646_bulk_write_data: end\n"); + DBG(DBG_io, "%s: end\n", __func__); return status; } @@ -274,7 +262,7 @@ gl646_gpio_read (SANE_Int dn, uint8_t * value) static SANE_Status gl646_gpio_write (SANE_Int dn, uint8_t value) { - DBG (DBG_proc, "gl646_gpio_write(0x%02x)\n", value); + DBG(DBG_proc, "%s(0x%02x)\n", __func__, value); return sanei_usb_control_msg (dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, GPIO_WRITE, INDEX, 1, &value); @@ -286,7 +274,7 @@ gl646_gpio_write (SANE_Int dn, uint8_t value) static SANE_Status gl646_gpio_output_enable (SANE_Int dn, uint8_t value) { - DBG (DBG_proc, "gl646_gpio_output_enable(0x%02x)\n", value); + DBG(DBG_proc, "%s(0x%02x)\n", __func__, value); return sanei_usb_control_msg (dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, GPIO_OUTPUT_ENABLE, INDEX, 1, &value); @@ -301,7 +289,7 @@ gl646_bulk_read_data (Genesys_Device * dev, uint8_t addr, size_t size; uint8_t outdata[8]; - DBG (DBG_io, "gl646_bulk_read_data: requesting %lu bytes\n", (u_long) len); + DBG(DBG_io, "%s: requesting %lu bytes\n", __func__, (u_long) len); /* write requested size */ status = @@ -309,9 +297,7 @@ gl646_bulk_read_data (Genesys_Device * dev, uint8_t addr, VALUE_SET_REGISTER, INDEX, 1, &addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_bulk_read_data failed while setting register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while setting register: %s\n", __func__, sane_strstatus(status)); return status; } @@ -329,9 +315,7 @@ gl646_bulk_read_data (Genesys_Device * dev, uint8_t addr, VALUE_BUFFER, INDEX, sizeof (outdata), outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_bulk_read_data failed while writing command: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing command: %s\n", __func__, sane_strstatus(status)); return status; } @@ -342,21 +326,17 @@ gl646_bulk_read_data (Genesys_Device * dev, uint8_t addr, else size = len; - DBG (DBG_io2, - "gl646_bulk_read_data: trying to read %lu bytes of data\n", - (u_long) size); + DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) size); status = sanei_usb_read_bulk (dev->dn, data, &size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_bulk_read_data failed while reading bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_io2, - "gl646_bulk_read_data read %lu bytes, %lu remaining\n", - (u_long) size, (u_long) (len - size)); + DBG(DBG_io2, "%s read %lu bytes, %lu remaining\n", __func__, (u_long) size, + (u_long) (len - size)); len -= size; data += size; @@ -367,7 +347,7 @@ gl646_bulk_read_data (Genesys_Device * dev, uint8_t addr, gl646_detect_document_end (dev); } - DBG (DBG_io, "gl646_bulk_read_data: end\n"); + DBG(DBG_io, "%s: end\n", __func__); return status; } @@ -379,7 +359,7 @@ read_triple_reg (Genesys_Device * dev, int index, unsigned int *words) SANE_Status status; uint8_t value; - DBG (DBG_proc, "read_triple_reg\n"); + DBG(DBG_proc, "%s\n", __func__); RIE (sanei_genesys_read_register (dev, index + 2, &value)); *words = value; @@ -391,7 +371,7 @@ read_triple_reg (Genesys_Device * dev, int index, unsigned int *words) else *words += ((value & 0x0f) * 256 * 256); - DBG (DBG_proc, "read_triple_reg: value=%d\n", *words); + DBG(DBG_proc, "%s: value=%d\n", __func__, *words); return status; } #endif @@ -510,7 +490,7 @@ print_status (uint8_t val) val & REG41_LAMPSTS ? "LAMPSTS " : "", val & REG41_FEBUSY ? "FEBUSY " : "", val & REG41_MOTMFLG ? "MOTMFLG" : ""); - DBG (DBG_info, "status=%s\n", msg); + DBG(DBG_info, "status=%s\n", msg); } /** @@ -563,7 +543,7 @@ get_lowest_resolution (int sensor, SANE_Bool color) } i++; } - DBG (DBG_info, "get_lowest_resolution: %d\n", dpi); + DBG(DBG_info, "%s: %d\n", __func__, dpi); return dpi; } @@ -591,8 +571,7 @@ get_closest_resolution (int sensor, int required, SANE_Bool color) && sensor_master[i].dpi == required && sensor_master[i].color == color) { - DBG (DBG_info, "get_closest_resolution: match found for %d\n", - required); + DBG(DBG_info, "%s: match found for %d\n", __func__, required); return required; } /* computes distance and keep mode if it is closer than previous */ @@ -607,8 +586,7 @@ get_closest_resolution (int sensor, int required, SANE_Bool color) } i++; } - DBG (DBG_info, "get_closest_resolution: closest match for %d is %d\n", - required, dpi); + DBG(DBG_info, "%s: closest match for %d is %d\n", __func__, required, dpi); return dpi; } @@ -634,13 +612,13 @@ is_half_ccd (int sensor, int required, SANE_Bool color) && sensor_master[i].dpi == required && sensor_master[i].color == color) { - DBG (DBG_io, "is_half_ccd: match found for %d (half_ccd=%d)\n", - required, sensor_master[i].half_ccd); + DBG(DBG_io, "%s: match found for %d (half_ccd=%d)\n", __func__, required, + sensor_master[i].half_ccd); return sensor_master[i].half_ccd; } i++; } - DBG (DBG_info, "is_half_ccd: failed to find match for %d dpi\n", required); + DBG(DBG_info, "%s: failed to find match for %d dpi\n", __func__, required); return SANE_FALSE; } @@ -665,13 +643,13 @@ get_cksel (int sensor, int required, SANE_Bool color) && sensor_master[i].dpi == required && sensor_master[i].color == color) { - DBG (DBG_io, "get_cksel: match found for %d (cksel=%d)\n", - required, sensor_master[i].cksel); + DBG(DBG_io, "%s: match found for %d (cksel=%d)\n", __func__, required, + sensor_master[i].cksel); return sensor_master[i].cksel; } i++; } - DBG (DBG_error, "get_cksel: failed to find match for %d dpi\n", required); + DBG(DBG_error, "%s: failed to find match for %d dpi\n", __func__, required); /* fail safe fallback */ return 1; } @@ -728,9 +706,8 @@ gl646_setup_registers (Genesys_Device * dev, SANE_Int xresolution; int feedl; - DBG (DBG_proc, "gl646_setup_registers: start\n"); - DBG (DBG_info, "gl646_setup_registers: startx=%d, endx=%d, linecnt=%d\n", - startx, endx, linecnt); + DBG(DBG_proc, "%s: start\n", __func__); + DBG(DBG_info, "%s: startx=%d, endx=%d, linecnt=%d\n", __func__, startx, endx, linecnt); /* x resolution is capped by sensor's capability */ if (resolution > dev->sensor.optical_res) @@ -758,9 +735,8 @@ gl646_setup_registers (Genesys_Device * dev, } if (sensor == NULL) { - DBG (DBG_error, - "gl646_setup_registers: unable to find settings for sensor %d at %d dpi color=%d\n", - dev->model->ccd_type, xresolution, color); + DBG(DBG_error, "%s: unable to find settings for sensor %d at %d dpi color=%d\n", __func__, + dev->model->ccd_type, xresolution, color); return SANE_STATUS_INVAL; } @@ -780,9 +756,8 @@ gl646_setup_registers (Genesys_Device * dev, } if (motor == NULL) { - DBG (DBG_error, - "gl646_setup_registers: unable to find settings for motor %d at %d dpi, color=%d\n", - dev->model->motor_type, resolution, color); + DBG(DBG_error, "%s: unable to find settings for motor %d at %d dpi, color=%d\n", __func__, + dev->model->motor_type, resolution, color); return SANE_STATUS_INVAL; } @@ -800,9 +775,8 @@ gl646_setup_registers (Genesys_Device * dev, } if (settings == NULL) { - DBG (DBG_error, - "gl646_setup_registers: unable to find settings for sensor %d with '%d' ccd timing\n", - sensor->sensor, sensor->cksel); + DBG(DBG_error, "%s: unable to find settings for sensor %d with '%d' ccd timing\n", __func__, + sensor->sensor, sensor->cksel); return SANE_STATUS_INVAL; } @@ -1052,8 +1026,7 @@ gl646_setup_registers (Genesys_Device * dev, } linecnt += stagger; - DBG (DBG_info, "gl646_setup_registers : max_shift=%d, stagger=%d lines\n", - max_shift, stagger); + DBG(DBG_info, "%s : max_shift=%d, stagger=%d lines\n", __func__, max_shift, stagger); /* CIS scanners read one line per color channel * since gray mode use 'add' we also read 3 channels even not in @@ -1078,8 +1051,7 @@ gl646_setup_registers (Genesys_Device * dev, } gl646_set_double_reg (regs, REG_STRPIXEL, sx); gl646_set_double_reg (regs, REG_ENDPIXEL, ex); - DBG (DBG_info, "gl646_setup_registers: startx=%d, endx=%d, half_ccd=%d\n", - sx, ex, half_ccd); + DBG(DBG_info, "%s: startx=%d, endx=%d, half_ccd=%d\n", __func__, sx, ex, half_ccd); /* words_per_line must be computed according to the scan's resolution */ /* in fact, words_per_line _gives_ the actual scan resolution */ @@ -1098,7 +1070,7 @@ gl646_setup_registers (Genesys_Device * dev, words_per_line *= channels; dev->wpl = words_per_line; - DBG (DBG_info, "gl646_setup_registers: wpl=%d\n", words_per_line); + DBG(DBG_info, "%s: wpl=%d\n", __func__, words_per_line); gl646_set_triple_reg (regs, REG_MAXWD, words_per_line); gl646_set_double_reg (regs, REG_DPISET, sensor->dpiset); @@ -1125,9 +1097,9 @@ gl646_setup_registers (Genesys_Device * dev, { /* take into account the distance moved during calibration */ /* feedl -= dev->scanhead_position_in_steps; */ - DBG (DBG_info, "gl646_setup_registers: initial move=%d\n", feedl); - DBG (DBG_info, "gl646_setup_registers: scanhead_position_in_steps=%d\n", - dev->scanhead_position_in_steps); + DBG(DBG_info, "%s: initial move=%d\n", __func__, feedl); + DBG(DBG_info, "%s: scanhead_position_in_steps=%d\n", __func__, + dev->scanhead_position_in_steps); /* TODO clean up this when I'll fully understand. * for now, special casing each motor */ @@ -1225,7 +1197,7 @@ gl646_setup_registers (Genesys_Device * dev, feedl = 0; } - DBG (DBG_info, "gl646_setup_registers: final move=%d\n", feedl); + DBG(DBG_info, "%s: final move=%d\n", __func__, feedl); gl646_set_triple_reg (regs, REG_FEEDL, feedl); regs[reg_0x65].value = motor->mtrpwm; @@ -1280,9 +1252,7 @@ gl646_setup_registers (Genesys_Device * dev, /* scan bytes to read */ dev->read_bytes_left = words_per_line * linecnt; - DBG (DBG_info, - "gl646_setup_registers: physical bytes to read = %lu\n", - (u_long) dev->read_bytes_left); + DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left); dev->read_active = SANE_TRUE; dev->current_setup.pixels = @@ -1311,7 +1281,7 @@ gl646_setup_registers (Genesys_Device * dev, dev->total_bytes_to_read = scan_settings.pixels * scan_settings.lines * channels * bpp; - DBG (DBG_proc, "gl646_setup_registers: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return SANE_STATUS_GOOD; } @@ -1330,7 +1300,7 @@ gl646_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs) Genesys_Register_Set *r; int i; - DBG (DBG_proc, "gl646_setup_sensor: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); for (i = 0; i < 4; i++) { r = sanei_genesys_get_address (regs, 0x08 + i); @@ -1348,7 +1318,7 @@ gl646_setup_sensor (Genesys_Device * dev, Genesys_Register_Set * regs) r = sanei_genesys_get_address (regs, 0x52 + i); r->value = dev->sensor.regs_0x52_0x5e[i]; } - DBG (DBG_proc, "gl646_setup_sensor: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); } @@ -1364,48 +1334,44 @@ gl646_asic_test (Genesys_Device * dev) size_t size, verify_size; unsigned int i; - DBG (DBG_proc, "gl646_asic_test: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); /* set and read exposure time, compare if it's the same */ status = sanei_genesys_write_register (dev, 0x38, 0xde); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_asic_test: failed to write register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write register: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_write_register (dev, 0x39, 0xad); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_asic_test: failed to write register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write register: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_read_register (dev, 0x4e, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_asic_test: failed to read register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read register: %s\n", __func__, sane_strstatus(status)); return status; } if (val != 0xde) /* value of register 0x38 */ { - DBG (DBG_error, "gl646_asic_test: register contains invalid value\n"); + DBG(DBG_error, "%s: register contains invalid value\n", __func__); return SANE_STATUS_IO_ERROR; } status = sanei_genesys_read_register (dev, 0x4f, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_asic_test: failed to read register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read register: %s\n", __func__, sane_strstatus(status)); return status; } if (val != 0xad) /* value of register 0x39 */ { - DBG (DBG_error, "gl646_asic_test: register contains invalid value\n"); + DBG(DBG_error, "%s: register contains invalid value\n", __func__); return SANE_STATUS_IO_ERROR; } @@ -1419,7 +1385,7 @@ gl646_asic_test (Genesys_Device * dev) data = (uint8_t *) malloc (size); if (!data) { - DBG (DBG_error, "gl646_asic_test: could not allocate memory\n"); + DBG(DBG_error, "%s: could not allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -1427,7 +1393,7 @@ gl646_asic_test (Genesys_Device * dev) if (!verify_data) { free (data); - DBG (DBG_error, "gl646_asic_test: could not allocate memory\n"); + DBG(DBG_error, "%s: could not allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -1440,8 +1406,7 @@ gl646_asic_test (Genesys_Device * dev) status = sanei_genesys_set_buffer_address (dev, 0x0000); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_asic_test: failed to set buffer address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); free (data); free (verify_data); return status; @@ -1450,8 +1415,7 @@ gl646_asic_test (Genesys_Device * dev) status = gl646_bulk_write_data (dev, 0x3c, data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_asic_test: failed to bulk write data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write data: %s\n", __func__, sane_strstatus(status)); free (data); free (verify_data); return status; @@ -1460,8 +1424,7 @@ gl646_asic_test (Genesys_Device * dev) status = sanei_genesys_set_buffer_address (dev, 0x0000); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_asic_test: failed to set buffer address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); free (data); free (verify_data); return status; @@ -1471,8 +1434,7 @@ gl646_asic_test (Genesys_Device * dev) gl646_bulk_read_data (dev, 0x45, (uint8_t *) verify_data, verify_size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_asic_test: failed to bulk read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk read data: %s\n", __func__, sane_strstatus(status)); free (data); free (verify_data); return status; @@ -1484,7 +1446,7 @@ gl646_asic_test (Genesys_Device * dev) { if (verify_data[i + 2] != data[i]) { - DBG (DBG_error, "gl646_asic_test: data verification error\n"); + DBG(DBG_error, "%s: data verification error\n", __func__); free (data); free (verify_data); return SANE_STATUS_IO_ERROR; @@ -1494,7 +1456,7 @@ gl646_asic_test (Genesys_Device * dev) free (data); free (verify_data); - DBG (DBG_info, "gl646_asic_test: end\n"); + DBG(DBG_info, "%s: end\n", __func__); return SANE_STATUS_GOOD; } @@ -1515,7 +1477,7 @@ gl646_init_regs (Genesys_Device * dev) { int nr, addr; - DBG (DBG_proc, "gl646_init_regs\n"); + DBG(DBG_proc, "%s\n", __func__); nr = 0; memset (dev->reg, 0, GENESYS_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -1712,9 +1674,8 @@ gl646_send_slope_table (Genesys_Device * dev, int table_nr, int i; #endif - DBG (DBG_proc, - "gl646_send_slope_table (table_nr = %d, steps = %d)=%d .. %d\n", - table_nr, steps, slope_table[0], slope_table[steps - 1]); + DBG(DBG_proc, "%s (table_nr = %d, steps = %d)=%d .. %d\n", __func__, table_nr, steps, + slope_table[0], slope_table[steps - 1]); dpihw = dev->reg[reg_0x05].value >> 6; @@ -1745,9 +1706,7 @@ gl646_send_slope_table (Genesys_Device * dev, int table_nr, #ifdef WORDS_BIGENDIAN free (table); #endif - DBG (DBG_error, - "gl646_send_slope_table: failed to set buffer address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1757,16 +1716,14 @@ gl646_send_slope_table (Genesys_Device * dev, int table_nr, #ifdef WORDS_BIGENDIAN free (table); #endif - DBG (DBG_error, - "gl646_send_slope_table: failed to send slope table: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send slope table: %s\n", __func__, sane_strstatus(status)); return status; } #ifdef WORDS_BIGENDIAN free (table); #endif - DBG (DBG_proc, "gl646_send_slope_table: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -1778,11 +1735,10 @@ gl646_set_ad_fe (Genesys_Device * dev, uint8_t set) int i; uint16_t val; - DBG (DBG_proc, "gl646_set_ad_fe(): start\n"); + DBG(DBG_proc, "%s(): start\n", __func__); if (set == AFE_INIT) { - DBG (DBG_proc, "gl646_set_ad_fe(): setting DAC %u\n", - dev->model->dac_type); + DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); /* sets to default values */ sanei_genesys_init_fe (dev); @@ -1792,16 +1748,14 @@ gl646_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_ad_fe: failed to write reg0: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write reg0: %s\n", __func__, sane_strstatus(status)); return status; } val = dev->frontend.reg[1]; status = sanei_genesys_fe_write_data (dev, 0x01, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_ad_fe: failed to write reg1: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write reg1: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -1813,9 +1767,8 @@ gl646_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x02 + i, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_set_ad_fe: failed to write gain %d: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write gain %d: %s\n", __func__, i, + sane_strstatus(status)); return status; } } @@ -1825,9 +1778,8 @@ gl646_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x05 + i, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_set_ad_fe: failed to write offset %d: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write offset %d: %s\n", __func__, i, + sane_strstatus(status)); return status; } } @@ -1839,12 +1791,11 @@ gl646_set_ad_fe (Genesys_Device * dev, uint8_t set) sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0] | 0x04); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_ad_fe: failed to write reg0: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write reg0: %s\n", __func__, sane_strstatus(status)); return status; } } */ - DBG (DBG_proc, "gl646_set_ad_fe(): end\n"); + DBG(DBG_proc, "%s(): end\n", __func__); return status; } @@ -1869,8 +1820,7 @@ gl646_wm_hp3670 (Genesys_Device * dev, uint8_t set, int dpi) status = sanei_genesys_fe_write_data (dev, 0x04, 0x80); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_wm_hp3670: reset failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: reset failed: %s\n", __func__, sane_strstatus(status)); return status; } usleep (200000UL); @@ -1879,22 +1829,19 @@ gl646_wm_hp3670 (Genesys_Device * dev, uint8_t set, int dpi) status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_wm_hp3670: writing reg1 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg1 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x02, dev->frontend.reg[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_wm_hp3670: writing reg2 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg2 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = gl646_gpio_output_enable (dev->dn, 0x07); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_wm_hp3670: failed to enable GPIO: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to enable GPIO: %s\n", __func__, sane_strstatus(status)); return status; } break; @@ -1902,15 +1849,13 @@ gl646_wm_hp3670 (Genesys_Device * dev, uint8_t set, int dpi) status = sanei_genesys_fe_write_data (dev, 0x01, 0x06); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_wm_hp3670: writing reg1 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg1 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x06, 0x0f); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_wm_hp3670: writing reg6 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg6 failed: %s\n", __func__, sane_strstatus(status)); return status; } return status; @@ -1928,8 +1873,7 @@ gl646_wm_hp3670 (Genesys_Device * dev, uint8_t set, int dpi) status = sanei_genesys_fe_write_data (dev, 0x03, i); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_wm_hp3670: writing reg3 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg3 failed: %s\n", __func__, sane_strstatus(status)); return status; } /* offset and sign (or msb/lsb ?) */ @@ -1940,16 +1884,15 @@ gl646_wm_hp3670 (Genesys_Device * dev, uint8_t set, int dpi) dev->frontend.offset[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_wm_hp3670: writing offset%d failed: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing offset%d failed: %s\n", __func__, i, + sane_strstatus (status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x24 + i, dev->frontend.sign[i]); /* MSB/LSB ? */ if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_wm_hp3670: writing sign%d failed: %s\n", - i, sane_strstatus (status)); + DBG(DBG_error, "%s: writing sign%d failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } } @@ -1962,8 +1905,8 @@ gl646_wm_hp3670 (Genesys_Device * dev, uint8_t set, int dpi) dev->frontend.gain[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_wm_hp3670: writing gain%d failed: %s\n", - i, sane_strstatus (status)); + DBG(DBG_error, "%s: writing gain%d failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } } @@ -1985,9 +1928,8 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) int i; uint8_t val; - DBG (DBG_proc, "gl646_set_fe (%s,%d)\n", - set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == - AFE_POWER_SAVE ? "powersave" : "huh?", dpi); + DBG(DBG_proc, "%s (%s,%d)\n", __func__, set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == + AFE_POWER_SAVE ? "powersave" : "huh?", dpi); /* Analog Device type frontend */ if ((dev->reg[reg_0x04].value & REG04_FESET) == 0x02) @@ -1996,8 +1938,8 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) /* Wolfson type frontend */ if ((dev->reg[reg_0x04].value & REG04_FESET) != 0x03) { - DBG (DBG_proc, "gl646_set_fe(): unsupported frontend type %d\n", - dev->reg[reg_0x04].value & REG04_FESET); + DBG(DBG_proc, "%s(): unsupported frontend type %d\n", __func__, + dev->reg[reg_0x04].value & REG04_FESET); return SANE_STATUS_UNSUPPORTED; } @@ -2009,23 +1951,21 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) return gl646_wm_hp3670 (dev, set, dpi); break; default: - DBG (DBG_proc, "gl646_set_fe(): using old method\n"); + DBG(DBG_proc, "%s(): using old method\n", __func__); break; } /* initialize analog frontend */ if (set == AFE_INIT) { - DBG (DBG_proc, "gl646_set_fe(): setting DAC %u\n", - dev->model->dac_type); + DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); sanei_genesys_init_fe (dev); /* reset only done on init */ status = sanei_genesys_fe_write_data (dev, 0x04, 0x80); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_fe: init fe failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: init fe failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2036,9 +1976,7 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) status = gl646_gpio_output_enable (dev->dn, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_set_fe: failed to enable GPIO: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to enable GPIO: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -2051,8 +1989,7 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) status = sanei_genesys_fe_write_data (dev, 0x01, 0x02); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_fe: writing data failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing data failed: %s\n", __func__, sane_strstatus(status)); } return status; } @@ -2066,15 +2003,13 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_fe: writing reg0 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg0 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x02, dev->frontend.reg[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_fe: writing reg2 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg2 failed: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -2083,8 +2018,7 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.reg[3]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_fe: writing reg3 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg3 failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2098,8 +2032,8 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) dev->frontend.sign[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_fe: writing sign[%d] failed: %s\n", - i, sane_strstatus (status)); + DBG(DBG_error, "%s: writing sign[%d] failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } @@ -2108,8 +2042,8 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) dev->frontend.gain[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_fe: writing gain[%d] failed: %s\n", - i, sane_strstatus (status)); + DBG(DBG_error, "%s: writing gain[%d] failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } @@ -2118,9 +2052,8 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) dev->frontend.offset[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_set_fe: writing offset[%d] failed: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing offset[%d] failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } } @@ -2134,16 +2067,13 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) sanei_genesys_fe_write_data (dev, 0x23, dev->frontend.offset[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_set_fe: writing offset[1] failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing offset[1] failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x28, dev->frontend.gain[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_fe: writing gain[1] failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing gain[1] failed: %s\n", __func__, sane_strstatus (status)); return status; } break; */ @@ -2153,13 +2083,12 @@ gl646_set_fe (Genesys_Device * dev, uint8_t set, int dpi) status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_set_fe: writing reg1 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg1 failed: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_proc, "gl646_set_fe: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return SANE_STATUS_GOOD; } @@ -2229,7 +2158,7 @@ gl646_save_power (Genesys_Device * dev, SANE_Bool enable) { DBGSTART; - DBG (DBG_info, "gl646_save_power: enable = %d\n", enable); + DBG(DBG_info, "%s: enable = %d\n", __func__, enable); if (enable) { @@ -2251,7 +2180,7 @@ gl646_set_powersaving (Genesys_Device * dev, int delay /* in minutes */ ) Genesys_Register_Set local_reg[6]; int rate, exposure_time, tgtime, time; - DBG (DBG_proc, "gl646_set_powersaving (delay = %d)\n", delay); + DBG(DBG_proc, "%s (delay = %d)\n", __func__, delay); local_reg[0].address = 0x01; local_reg[0].value = sanei_genesys_read_reg_from_set (dev->reg, 0x01); /* disable fastmode */ @@ -2319,11 +2248,9 @@ gl646_set_powersaving (Genesys_Device * dev, int delay /* in minutes */ ) sizeof (local_reg) / sizeof (local_reg[0])); if (status != SANE_STATUS_GOOD) - DBG (DBG_error, - "gl646_set_powersaving: Failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); - DBG (DBG_proc, "gl646_set_powersaving: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -2347,22 +2274,20 @@ gl646_load_document (Genesys_Device * dev) uint16_t slope_table[255]; uint8_t val; - DBG (DBG_proc, "gl646_load_document: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); /* no need to load document is flatbed scanner */ if (dev->model->is_sheetfed == SANE_FALSE) { - DBG (DBG_proc, "gl646_load_document: nothing to load\n"); - DBG (DBG_proc, "gl646_load_document: end\n"); + DBG(DBG_proc, "%s: nothing to load\n", __func__); + DBG(DBG_proc, "%s: end\n", __func__); return SANE_STATUS_GOOD; } status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_load_document: failed to read status: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2377,15 +2302,14 @@ gl646_load_document (Genesys_Device * dev) status = gl646_gpio_read (dev->dn, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_load_document: failed to read paper sensor %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read paper sensor %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_info, "gl646_load_document: GPIO=0x%02x\n", val); + DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, val); if ((val & 0x04) != 0x04) { - DBG (DBG_warn, "gl646_load_document: no paper detected\n"); + DBG(DBG_warn, "%s: no paper detected\n", __func__); } usleep (200000UL); /* sleep 200 ms */ count++; @@ -2393,8 +2317,7 @@ gl646_load_document (Genesys_Device * dev) while (((val & 0x04) != 0x04) && (count < 300)); /* 1 min time out */ if (count == 300) { - DBG (DBG_error, - "gl646_load_document: timeout waiting for document\n"); + DBG(DBG_error, "%s: timeout waiting for document\n", __func__); return SANE_STATUS_NO_DOCS; } } @@ -2447,27 +2370,21 @@ gl646_load_document (Genesys_Device * dev) status = gl646_send_slope_table (dev, 1, slope_table, 50); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_load_document: failed to send slope table 1: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send slope table 1: %s\n", __func__, sane_strstatus(status)); return status; } status = gl646_bulk_write_register (dev, regs, sizeof (regs) / sizeof (regs[0])); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_load_document: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } status = gl646_start_motor (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_load_document: failed to start motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } @@ -2477,9 +2394,7 @@ gl646_load_document (Genesys_Device * dev) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_load_document: failed to read status: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status)); return status; } usleep (200000UL); /* sleep 200 ms */ @@ -2488,7 +2403,7 @@ gl646_load_document (Genesys_Device * dev) while ((val & REG41_MOTMFLG) && (count < 300)); if (count == 300) { - DBG (DBG_error, "gl646_load_document: can't load document\n"); + DBG(DBG_error, "%s: can't load document\n", __func__); return SANE_STATUS_JAMMED; } @@ -2503,13 +2418,12 @@ gl646_load_document (Genesys_Device * dev) gl646_bulk_write_register (dev, regs, sizeof (regs) / sizeof (regs[0])); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_load_document: failed to bulk write idle registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write idle registers: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_proc, "gl646_load_document: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -2526,7 +2440,7 @@ gl646_detect_document_end (Genesys_Device * dev) uint8_t val, gpio; unsigned int bytes_left, lines; - DBG (DBG_proc, "gl646_detect_document_end: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); /* test for document presence */ RIE (sanei_genesys_get_status (dev, &val)); @@ -2535,14 +2449,14 @@ gl646_detect_document_end (Genesys_Device * dev) print_status (val); } status = gl646_gpio_read (dev->dn, &gpio); - DBG (DBG_info, "gl646_detect_document_end: GPIO=0x%02x\n", gpio); + DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio); /* detect document event. There one event when the document go in, * then another when it leaves */ if ((dev->document == SANE_TRUE) && (gpio & 0x04) && (dev->total_bytes_read > 0)) { - DBG (DBG_info, "gl646_detect_document_end: no more document\n"); + DBG(DBG_info, "%s: no more document\n", __func__); dev->document = SANE_FALSE; /* adjust number of bytes to read: @@ -2550,12 +2464,9 @@ gl646_detect_document_end (Genesys_Device * dev) * 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, "gl646_detect_document_end: total_bytes_to_read=%lu\n", - (u_long) dev->total_bytes_to_read); - DBG (DBG_io, "gl646_detect_document_end: total_bytes_read =%lu\n", - (u_long) dev->total_bytes_read); - DBG (DBG_io, "gl646_detect_document_end: read_bytes_left =%lu\n", - (u_long) dev->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: read_bytes_left =%lu\n", __func__, (u_long) dev->read_bytes_left); /* amount of data available from scanner is what to scan */ status = sanei_genesys_read_valid_words (dev, &bytes_left); @@ -2564,8 +2475,7 @@ gl646_detect_document_end (Genesys_Device * dev) lines = (SANE_UNFIX (dev->model->y_offset) * dev->current_setup.yres) / MM_PER_INCH; - DBG (DBG_io, "gl646_detect_document_end: adding %d line to flush\n", - lines); + DBG(DBG_io, "%s: adding %d line to flush\n", __func__, lines); bytes_left += lines * dev->wpl; if (dev->current_setup.depth > 8) { @@ -2580,14 +2490,11 @@ gl646_detect_document_end (Genesys_Device * dev) dev->total_bytes_to_read = dev->total_bytes_read + bytes_left; dev->read_bytes_left = bytes_left; } - DBG (DBG_io, "gl646_detect_document_end: total_bytes_to_read=%lu\n", - (u_long) dev->total_bytes_to_read); - DBG (DBG_io, "gl646_detect_document_end: total_bytes_read =%lu\n", - (u_long) dev->total_bytes_read); - DBG (DBG_io, "gl646_detect_document_end: read_bytes_left =%lu\n", - (u_long) dev->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: read_bytes_left =%lu\n", __func__, (u_long) dev->read_bytes_left); } - DBG (DBG_proc, "gl646_detect_document_end: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -2607,7 +2514,7 @@ gl646_eject_document (Genesys_Device * dev) uint16_t slope_table[255]; uint8_t gpio, state; - DBG (DBG_proc, "gl646_eject_document: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); /* at the end there will be noe more document */ dev->document = SANE_FALSE; @@ -2616,23 +2523,19 @@ gl646_eject_document (Genesys_Device * dev) status = gl646_gpio_read (dev->dn, &gpio); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_eject_document: failed to read paper sensor %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read paper sensor %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, "gl646_eject_document: GPIO=0x%02x\n", gpio); + DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio); /* test status : paper event + HOMESNR -> no more doc ? */ status = sanei_genesys_get_status (dev, &state); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_eject_document: failed to read status: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, "gl646_eject_document: state=0x%02x\n", state); + DBG(DBG_info, "%s: state=0x%02x\n", __func__, state); if (DBG_LEVEL > DBG_info) { print_status (state); @@ -2642,8 +2545,8 @@ gl646_eject_document (Genesys_Device * dev) if ((state & REG41_HOMESNR) != 0) { dev->document = SANE_FALSE; - DBG (DBG_info, "gl646_eject_document: no more document to eject\n"); - DBG (DBG_proc, "gl646_eject_document: end\n"); + DBG(DBG_info, "%s: no more document to eject\n", __func__); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -2651,9 +2554,7 @@ gl646_eject_document (Genesys_Device * dev) status = sanei_genesys_write_register (dev, 0x01, 0xb0); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_eject_document: failed to write register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write register: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2664,9 +2565,7 @@ gl646_eject_document (Genesys_Device * dev) status = sanei_genesys_get_status (dev, &state); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_eject_document: failed to read status: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -2720,27 +2619,21 @@ gl646_eject_document (Genesys_Device * dev) status = gl646_send_slope_table (dev, 1, slope_table, 60); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_eject_document: failed to send slope table 1: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send slope table 1: %s\n", __func__, sane_strstatus(status)); return status; } status = gl646_bulk_write_register (dev, regs, sizeof (regs) / sizeof (regs[0])); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_eject_document: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } status = gl646_start_motor (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_eject_document: failed to start motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus (status)); return SANE_STATUS_IO_ERROR; } @@ -2753,9 +2646,7 @@ gl646_eject_document (Genesys_Device * dev) print_status (state); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_eject_document: failed to read status: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read status: %s\n", __func__, sane_strstatus(status)); return status; } usleep (200000UL); /* sleep 200 ms */ @@ -2767,14 +2658,12 @@ gl646_eject_document (Genesys_Device * dev) status = gl646_gpio_read (dev->dn, &gpio); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_eject_document: failed to read paper sensor %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read paper sensor %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, "gl646_eject_document: GPIO=0x%02x\n", gpio); + DBG(DBG_info, "%s: GPIO=0x%02x\n", __func__, gpio); - DBG (DBG_proc, "gl646_eject_document: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -2786,7 +2675,7 @@ gl646_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg, SANE_Status status; Genesys_Register_Set local_reg[3]; - DBG (DBG_proc, "gl646_begin_scan\n"); + DBG(DBG_proc, "%s\n", __func__); local_reg[0].address = 0x03; local_reg[0].value = sanei_genesys_read_reg_from_set (reg, 0x03); @@ -2806,13 +2695,11 @@ gl646_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg, if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_begin_scan: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_proc, "gl646_begin_scan: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -2827,8 +2714,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, int i = 0; uint8_t val, scanfsh = 0; - DBG (DBG_proc, "end_scan (check_stop = %d, eject = %d)\n", check_stop, - eject); + DBG(DBG_proc, "%s (check_stop = %d, eject = %d)\n", __func__, check_stop, eject); /* we need to compute scanfsh before cancelling scan */ if (dev->model->is_sheetfed == SANE_TRUE) @@ -2836,9 +2722,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "end_scan: failed to read register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read register: %s\n", __func__, sane_strstatus(status)); return status; } if (val & REG41_SCANFSH) @@ -2856,9 +2740,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, status = sanei_genesys_write_register (dev, 0x01, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "end_scan: failed to write register 01: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write register 01: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2870,7 +2752,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, status = gl646_eject_document (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "end_scan: failed to eject document\n"); + DBG(DBG_error, "%s: failed to eject document\n", __func__); return status; } } @@ -2881,9 +2763,8 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "end_scan: failed to read register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read register: %s\n", __func__, + sane_strstatus(status)); return status; } if (val & REG41_SCANFSH) @@ -2895,7 +2776,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, if (!(val & REG41_MOTMFLG) && (val & REG41_FEEDFSH) && scanfsh) { - DBG (DBG_proc, "end_scan: scanfeed finished\n"); + DBG(DBG_proc, "%s: scanfeed finished\n", __func__); break; /* leave for loop */ } @@ -2912,9 +2793,8 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "end_scan: failed to read register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read register: %s\n", __func__, + sane_strstatus(status)); return status; } if (val & REG41_SCANFSH) @@ -2926,13 +2806,13 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, if (!(val & REG41_MOTMFLG) && (val & REG41_FEEDFSH) && scanfsh) { - DBG (DBG_proc, "end_scan: scanfeed finished\n"); + DBG(DBG_proc, "%s: scanfeed finished\n", __func__); break; /* leave while loop */ } if ((!(val & REG41_MOTMFLG)) && (val & REG41_HOMESNR)) { - DBG (DBG_proc, "end_scan: head at home\n"); + DBG(DBG_proc, "%s: head at home\n", __func__); break; /* leave while loop */ } @@ -2941,7 +2821,7 @@ end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, } } - DBG (DBG_proc, "end_scan: end (i=%u)\n", i); + DBG(DBG_proc, "%s: end (i=%u)\n", __func__, i); return status; } @@ -2969,15 +2849,12 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) int i; int loop = 0; - DBG (DBG_proc, "gl646_slow_back_home: start , wait_until_home = %d\n", - wait_until_home); + DBG(DBG_proc, "%s: start , wait_until_home = %d\n", __func__, wait_until_home); status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL > DBG_io) @@ -2989,7 +2866,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) if (val & REG41_HOMESNR) /* is sensor at home? */ { - DBG (DBG_info, "gl646_slow_back_home: end since already at home\n"); + DBG(DBG_info, "%s: end since already at home\n", __func__); return SANE_STATUS_GOOD; } @@ -2999,31 +2876,27 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl646_stop_motor (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_slow_back_home: failed to stop motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop motor: %s\n", __func__, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } usleep (200000UL); } /* when scanhead is moving then wait until scanhead stops or timeout */ - DBG (DBG_info, "gl646_slow_back_home: ensuring that motor is off\n"); + DBG(DBG_info, "%s: ensuring that motor is off\n", __func__); val = REG41_MOTMFLG; for (i = 400; i > 0 && (val & REG41_MOTMFLG); i--) /* do not wait longer than 40 seconds, count down to get i = 0 when busy */ { status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_slow_back_home: Failed to read home sensor & motor status: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to read home sensor & motor status: %s\n", __func__, + sane_strstatus(status)); return status; } if (((val & (REG41_MOTMFLG | REG41_HOMESNR)) == REG41_HOMESNR)) /* at home and motor is off */ { - DBG (DBG_info, - "gl646_slow_back_home: already at home and not moving\n"); + DBG(DBG_info, "%s: already at home and not moving\n", __func__); return SANE_STATUS_GOOD; } usleep (100 * 1000); /* sleep 100 ms (todo: fixed to really sleep 100 ms) */ @@ -3031,8 +2904,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) if (!i) /* the loop counted down to 0, scanner still is busy */ { - DBG (DBG_error, - "gl646_slow_back_home: motor is still on: device busy\n"); + DBG(DBG_error, "%s: motor is still on: device busy\n", __func__); return SANE_STATUS_DEVICE_BUSY; } @@ -3056,9 +2928,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = setup_for_scan (dev, dev->reg, settings, SANE_TRUE, SANE_TRUE, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to setup for scan: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup for scan: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -3072,9 +2942,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl646_set_fe (dev, AFE_SET, settings.xres); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to set frontend: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -3084,14 +2952,12 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) sizeof (dev->reg) / sizeof (dev->reg[0])); if (status != SANE_STATUS_GOOD) - DBG (DBG_error, - "gl646_slow_back_home: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); /* registers are restored to an iddl state, give up if no head to park */ if (dev->model->is_sheetfed == SANE_TRUE) { - DBG (DBG_proc, "gl646_slow_back_home: end \n"); + DBG(DBG_proc, "%s: end \n", __func__); return SANE_STATUS_GOOD; } @@ -3099,7 +2965,7 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl646_begin_scan (dev, dev->reg, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_slow_back_home: failed to begin scan: \n"); + DBG(DBG_error, "%s: failed to begin scan: \n", __func__); return status; } @@ -3111,16 +2977,15 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_slow_back_home: Failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to read home sensor: %s\n", __func__, + sane_strstatus(status)); return status; } if (val & 0x08) /* home sensor */ { - DBG (DBG_info, "gl646_slow_back_home: reached home position\n"); - DBG (DBG_proc, "gl646_slow_back_home: end\n"); + DBG(DBG_info, "%s: reached home position\n", __func__); + DBG(DBG_proc, "%s: end\n", __func__); usleep (500000); /* sleep 500 ms before returning */ return SANE_STATUS_GOOD; } @@ -3131,13 +2996,12 @@ gl646_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* when we come here then the scanner needed too much time for this, so we better stop the motor */ gl646_stop_motor (dev); end_scan (dev, dev->reg, SANE_TRUE, SANE_FALSE); - DBG (DBG_error, - "gl646_slow_back_home: timeout while waiting for scanhead to go home\n"); + DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); return SANE_STATUS_IO_ERROR; } - DBG (DBG_info, "gl646_slow_back_home: scanhead is still moving\n"); + DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -3156,7 +3020,7 @@ gl646_search_start_position (Genesys_Device * dev) Genesys_Settings settings; unsigned int resolution, x, y; - DBG (DBG_proc, "gl646_search_start_position: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); /* we scan at 300 dpi */ resolution = get_closest_resolution (dev->model->ccd_type, 300, SANE_FALSE); @@ -3188,7 +3052,7 @@ gl646_search_start_position (Genesys_Device * dev) /* handle stagger case : reorder gray data and thus loose some lines */ if (dev->current_setup.stagger > 0) { - DBG (DBG_proc, "gl646_search_start_position: 'un-staggering'\n"); + DBG(DBG_proc, "%s: 'un-staggering'\n", __func__); for (y = 0; y < settings.lines - dev->current_setup.stagger; y++) { /* one point out of 2 is 'unaligned' */ @@ -3212,7 +3076,7 @@ gl646_search_start_position (Genesys_Device * dev) } else { - DBG (DBG_error, "gl646_search_start_position: simple_scan failed\n"); + DBG(DBG_error, "%s: simple_scan failed\n", __func__); free (data); DBGCOMPLETED; return status; @@ -3226,9 +3090,8 @@ gl646_search_start_position (Genesys_Device * dev) settings.lines); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_search_start_position: failed to set search reference point: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set search reference point: %s\n", __func__, + sane_strstatus(status)); } free (data); @@ -3243,8 +3106,8 @@ gl646_search_start_position (Genesys_Device * dev) static SANE_Status gl646_init_regs_for_coarse_calibration (Genesys_Device * dev) { - DBG (DBG_proc, "gl646_init_regs_for_coarse_calibration\n"); - DBG (DBG_proc, "gl646_init_register_for_coarse_calibration: end\n"); + DBG(DBG_proc, "%s\n", __func__); + DBG(DBG_proc, "%s: end\n", __func__); /* to make compilers happy ... */ if (!dev) @@ -3273,7 +3136,7 @@ gl646_init_regs_for_shading (Genesys_Device * dev) int half_ccd = 1; int cksel = 1; - DBG (DBG_proc, "gl646_init_register_for_shading: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); /* when shading all (full width) line, we must adapt to half_ccd case */ if (dev->model->flags & GENESYS_FLAG_HALF_CCD_MODE) @@ -3352,11 +3215,10 @@ gl646_init_regs_for_shading (Genesys_Device * dev) /* if we don't do this, cache will be identified at the shading calibration * dpi which is different from calibration one */ dev->current_setup.xres = dev->settings.xres; - DBG (DBG_info, - "gl646_init_register_for_shading:\n\tdev->settings.xres=%d\n\tdev->settings.yres=%d\n", - dev->settings.xres, dev->settings.yres); + DBG(DBG_info, "%s:\n\tdev->settings.xres=%d\n\tdev->settings.yres=%d\n", __func__, + dev->settings.xres, dev->settings.yres); - DBG (DBG_proc, "gl646_init_register_for_shading: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -3417,13 +3279,12 @@ setup_for_scan (Genesys_Device * dev, int move = 0; DBGSTART; - DBG (DBG_info, - "%s settings:\nResolution: %ux%uDPI\n" - "Lines : %u\nPixels : %u\nStartpos : %.3f/%.3f\nScan mode : %d\nScan method: %s\n\n", - __func__, - settings.xres, settings.yres, settings.lines, settings.pixels, - settings.tl_x, settings.tl_y, settings.scan_mode, - settings.scan_method == SCAN_METHOD_FLATBED ? "flatbed" : "XPA"); + DBG(DBG_info, "%s settings:\nResolution: %ux%uDPI\n" + "Lines : %u\nPixels : %u\nStartpos : %.3f/%.3f\nScan mode : %d\nScan method: %s\n\n", + __func__, + settings.xres, settings.yres, settings.lines, settings.pixels, + settings.tl_x, settings.tl_y, settings.scan_mode, + settings.scan_method == SCAN_METHOD_FLATBED ? "flatbed" : "XPA"); if (settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */ { @@ -3473,16 +3334,16 @@ setup_for_scan (Genesys_Device * dev, move += (settings.tl_y * dev->motor.optical_ydpi) / MM_PER_INCH; } - DBG (DBG_info, "%s: move=%d steps\n", __func__, move); + DBG(DBG_info, "%s: move=%d steps\n", __func__, move); /* security check */ if (move < 0) { - DBG (DBG_error, "%s: overriding negative move value %d\n", __func__, move); + DBG(DBG_error, "%s: overriding negative move value %d\n", __func__, move); move = 0; } } - DBG (DBG_info, "%s: move=%d steps\n", __func__, move); + DBG(DBG_info, "%s: move=%d steps\n", __func__, move); /* pixels are allways given at full CCD optical resolution */ /* use detected left margin and fixed value */ @@ -3541,7 +3402,7 @@ setup_for_scan (Genesys_Device * dev, depth); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed setup registers: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed setup registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3576,7 +3437,7 @@ setup_for_scan (Genesys_Device * dev, sanei_genesys_read_reg_from_set (regs, 0x21)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send slope table 0: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send slope table 0: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3585,7 +3446,7 @@ setup_for_scan (Genesys_Device * dev, sanei_genesys_read_reg_from_set (regs, 0x6b)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send slope table 1: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send slope table 1: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3650,9 +3511,7 @@ gl646_send_gamma_table (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (gamma); - DBG (DBG_error, - "gl646_send_gamma_table: failed to set buffer address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3661,9 +3520,7 @@ gl646_send_gamma_table (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (gamma); - DBG (DBG_error, - "gl646_send_gamma_table: failed to send gamma table: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send gamma table: %s\n", __func__, sane_strstatus(status)); return status; } free (gamma); @@ -3695,11 +3552,10 @@ gl646_led_calibration (Genesys_Device * dev) SANE_Bool acceptable = SANE_FALSE; - DBG (DBG_proc, "gl646_led_calibration\n"); + DBG(DBG_proc, "%s\n", __func__); if (!dev->model->is_cis) { - DBG (DBG_proc, - "gl646_led_calibration: not a cis scanner, nothing to do...\n"); + DBG(DBG_proc, "%s: not a cis scanner, nothing to do...\n", __func__); return SANE_STATUS_GOOD; } @@ -3744,8 +3600,7 @@ gl646_led_calibration (Genesys_Device * dev) line = malloc (total_size); if (!line) { - DBG (DBG_error, "gl646_led_calibration: failed to allocate %d bytes\n", - total_size); + DBG(DBG_error, "%s: failed to allocate %d bytes\n", __func__, total_size); return SANE_STATUS_NO_MEM; } @@ -3775,16 +3630,14 @@ gl646_led_calibration (Genesys_Device * dev) dev->sensor.regs_0x10_0x1d[4] = (expb >> 8) & 0xff; dev->sensor.regs_0x10_0x1d[5] = expb & 0xff; - DBG (DBG_info, "gl646_led_calibration: starting first line reading\n"); + DBG(DBG_info, "%s: starting first line reading\n", __func__); status = simple_scan (dev, settings, SANE_FALSE, SANE_TRUE, SANE_FALSE, &line); if (status != SANE_STATUS_GOOD) { free(line); - DBG (DBG_error, - "gl646_led_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3817,8 +3670,7 @@ gl646_led_calibration (Genesys_Device * dev) avg[j] /= settings.pixels; } - DBG (DBG_info, "gl646_led_calibration: average: " - "%d,%d,%d\n", avg[0], avg[1], avg[2]); + DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); acceptable = SANE_TRUE; @@ -3850,9 +3702,7 @@ gl646_led_calibration (Genesys_Device * dev) } while (!acceptable && turn < 100); - DBG (DBG_info, - "gl646_led_calibration: acceptable exposure: 0x%04x,0x%04x,0x%04x\n", - expr, expg, expb); + DBG(DBG_info,"%s: acceptable exposure: 0x%04x,0x%04x,0x%04x\n", __func__, expr, expg, expb); /* cleanup before return */ free (line); @@ -3888,13 +3738,13 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines, } if (count) avg[k] /= count; - DBG (DBG_info, "dark_average: avg[%d] = %d\n", k, avg[k]); + DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } average = 0; for (i = 0; i < channels; i++) average += avg[i]; average /= channels; - DBG (DBG_info, "dark_average: average = %d\n", average); + DBG(DBG_info, "%s: average = %d\n", __func__, average); return average; } @@ -3916,14 +3766,14 @@ ad_fe_offset_calibration (Genesys_Device * dev) unsigned int x, y, adr, min; unsigned int bottom, black_pixels; - DBG (DBG_proc, "ad_fe_offset_calibration: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); resolution = get_closest_resolution (dev->model->ccd_type, dev->sensor.optical_res, SANE_TRUE); channels = 3; black_pixels = (dev->sensor.black_pixels * resolution) / dev->sensor.optical_res; - DBG (DBG_io2, "ad_fe_offset_calibration: black_pixels=%d\n", black_pixels); + DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); settings.scan_method = SCAN_METHOD_FLATBED; settings.scan_mode = SCAN_MODE_COLOR; @@ -3960,8 +3810,7 @@ ad_fe_offset_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free(line); - DBG (DBG_error, - "ad_fe_offset_calibration: failed to scan first line\n"); + DBG(DBG_error, "%s: failed to scan first line\n", __func__); return status; } if (DBG_LEVEL >= DBG_data) @@ -3987,21 +3836,19 @@ ad_fe_offset_calibration (Genesys_Device * dev) } free (line); - DBG (DBG_io2, "ad_fe_offset_calibration: pass=%d, min=%d\n", pass, min); + DBG(DBG_io2, "%s: pass=%d, min=%d\n", __func__, pass, min); bottom++; } while (pass < 128 && min == 0); if (pass == 128) { - DBG (DBG_error, - "ad_fe_offset_calibration: failed to find correct offset\n"); + DBG(DBG_error, "%s: failed to find correct offset\n", __func__); return SANE_STATUS_INVAL; } - DBG (DBG_info, "ad_fe_offset_calibration: offset=(%d,%d,%d)\n", - dev->frontend.offset[0], dev->frontend.offset[1], - dev->frontend.offset[2]); - DBG (DBG_proc, "ad_fe_offset_calibration: end\n"); + DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0], + dev->frontend.offset[1], dev->frontend.offset[2]); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -4033,7 +3880,7 @@ gl646_offset_calibration (Genesys_Device * dev) return ad_fe_offset_calibration (dev); } - DBG (DBG_proc, "gl646_offset_calibration: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); /* setup for a RGB scan, one full sensor's width line */ /* resolution is the one from the final scan */ @@ -4052,7 +3899,7 @@ gl646_offset_calibration (Genesys_Device * dev) channels = 3; black_pixels = (dev->sensor.black_pixels * resolution) / dev->sensor.optical_res; - DBG (DBG_io2, "gl646_offset_calibration: black_pixels=%d\n", black_pixels); + DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); settings.scan_method = SCAN_METHOD_FLATBED; settings.scan_mode = SCAN_MODE_COLOR; @@ -4088,8 +3935,7 @@ gl646_offset_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free(first_line); - DBG (DBG_error, - "gl646_offset_calibration: failed to scan first line\n"); + DBG(DBG_error, "%s: failed to scan first line\n", __func__); return status; } if (DBG_LEVEL >= DBG_data) @@ -4102,7 +3948,7 @@ gl646_offset_calibration (Genesys_Device * dev) dark_average (first_line, settings.pixels, settings.lines, channels, black_pixels); free (first_line); - DBG (DBG_io2, "gl646_offset_calibration: bottom avg=%d\n", bottomavg); + DBG(DBG_io2, "%s: bottom avg=%d\n", __func__, bottomavg); /* now top value */ top = 231; @@ -4115,8 +3961,7 @@ gl646_offset_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free(second_line); - DBG (DBG_error, - "gl646_offset_calibration: failed to scan first line\n"); + DBG(DBG_error, "%s: failed to scan first line\n", __func__); return status; } @@ -4130,7 +3975,7 @@ gl646_offset_calibration (Genesys_Device * dev) dark_average (second_line, settings.pixels, settings.lines, channels, black_pixels); free (second_line); - DBG (DBG_io2, "gl646_offset_calibration: top avg=%d\n", topavg); + DBG(DBG_io2, "%s: top avg=%d\n", __func__, topavg); /* loop until acceptable level */ while ((pass < 32) && (top - bottom > 1)) @@ -4149,8 +3994,7 @@ gl646_offset_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free(second_line); - DBG (DBG_error, - "gl646_offset_calibration: failed to scan first line\n"); + DBG(DBG_error, "%s: failed to scan first line\n", __func__); return status; } @@ -4164,8 +4008,7 @@ gl646_offset_calibration (Genesys_Device * dev) avg = dark_average (second_line, settings.pixels, settings.lines, channels, black_pixels); - DBG (DBG_info, "gl646_offset_calibration: avg=%d offset=%d\n", avg, - dev->frontend.offset[1]); + DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.offset[1]); free (second_line); /* compute new boundaries */ @@ -4190,8 +4033,7 @@ gl646_offset_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free(second_line); - DBG (DBG_error, - "gl646_offset_calibration: failed to scan final line\n"); + DBG(DBG_error, "%s: failed to scan final line\n", __func__); return status; } sanei_genesys_write_pnm_file ("offset-final.pnm", second_line, 8, @@ -4200,10 +4042,9 @@ gl646_offset_calibration (Genesys_Device * dev) free (second_line); } - DBG (DBG_info, "gl646_offset_calibration: offset=(%d,%d,%d)\n", - dev->frontend.offset[0], dev->frontend.offset[1], - dev->frontend.offset[2]); - DBG (DBG_proc, "gl646_offset_calibration: end\n"); + DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0], + dev->frontend.offset[1], dev->frontend.offset[2]); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -4264,8 +4105,7 @@ ad_fe_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (status != SANE_STATUS_GOOD) { free(line); - DBG (DBG_error, - "ad_fe_coarse_gain_calibration: failed to scan first line\n"); + DBG(DBG_error, "%s: failed to scan first line\n", __func__); return status; } @@ -4296,14 +4136,12 @@ ad_fe_coarse_gain_calibration (Genesys_Device * dev, int dpi) dev->frontend.gain[1] = dev->frontend.gain[0]; dev->frontend.gain[2] = dev->frontend.gain[0]; - DBG (DBG_proc, - "ad_fe_coarse_gain_calibration: average = %.2f, gain = %d\n", - average, dev->frontend.gain[0]); + DBG(DBG_proc, "%s: average = %.2f, gain = %d\n", __func__, average, dev->frontend.gain[0]); free (line); } - DBG (DBG_info, "ad_fe_coarse_gain_calibration: gains=(%d,%d,%d)\n", - dev->frontend.gain[0], dev->frontend.gain[1], dev->frontend.gain[2]); + DBG(DBG_info, "%s: gains=(%d,%d,%d)\n", __func__, dev->frontend.gain[0], dev->frontend.gain[1], + dev->frontend.gain[2]); DBGCOMPLETED; return status; } @@ -4405,7 +4243,7 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (status != SANE_STATUS_GOOD) { free(line); - DBG (DBG_error, "%s: failed to scan first line\n", __func__); + DBG(DBG_error, "%s: failed to scan first line\n", __func__); return status; } @@ -4462,9 +4300,8 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (average[k] < dev->sensor.gain_white_ref) dev->frontend.gain[k]++; - DBG (DBG_proc, - "%s: channel %d, average = %.2f, gain = %d\n", __func__, - k, average[k], dev->frontend.gain[k]); + DBG(DBG_proc, "%s: channel %d, average = %.2f, gain = %d\n", __func__, k, average[k], + dev->frontend.gain[k]); } free (line); } @@ -4475,8 +4312,8 @@ gl646_coarse_gain_calibration (Genesys_Device * dev, int dpi) dev->frontend.gain[2] = dev->frontend.gain[0]; } - DBG (DBG_info, "%s: gains=(%d,%d,%d)\n", __func__, - dev->frontend.gain[0], dev->frontend.gain[1], dev->frontend.gain[2]); + DBG(DBG_info, "%s: gains=(%d,%d,%d)\n", __func__, dev->frontend.gain[0], dev->frontend.gain[1], + dev->frontend.gain[2]); DBGCOMPLETED; return status; } @@ -4494,7 +4331,7 @@ gl646_init_regs_for_warmup (Genesys_Device * dev, Genesys_Settings settings; int resolution, lines; - DBG (DBG_proc, "gl646_init_regs_for_warmup: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); sanei_genesys_init_fe (dev); @@ -4522,9 +4359,7 @@ gl646_init_regs_for_warmup (Genesys_Device * dev, status = setup_for_scan (dev, dev->reg, settings, SANE_TRUE, SANE_FALSE, SANE_FALSE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_init_regs_for_warmup: setup_for_scan failed (%s)\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: setup_for_scan failed (%s)\n", __func__, sane_strstatus(status)); return status; } @@ -4566,7 +4401,7 @@ gl646_repark_head (Genesys_Device * dev) Genesys_Settings settings; unsigned int expected, steps; - DBG (DBG_proc, "gl646_repark_head: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); settings.scan_method = SCAN_METHOD_FLATBED; settings.scan_mode = SCAN_MODE_COLOR; @@ -4588,9 +4423,7 @@ gl646_repark_head (Genesys_Device * dev) status = setup_for_scan (dev, dev->reg, settings, SANE_FALSE, SANE_FALSE, SANE_FALSE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_repark_head: failed to setup for scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup for scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4600,9 +4433,7 @@ gl646_repark_head (Genesys_Device * dev) status = gl646_bulk_write_register (dev, dev->reg, GENESYS_GL646_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_repark_head: failed to send registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4610,7 +4441,7 @@ gl646_repark_head (Genesys_Device * dev) status = gl646_begin_scan (dev, dev->reg, SANE_TRUE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_repark_head: failed to begin scan: \n"); + DBG(DBG_error, "%s: failed to begin scan: \n", __func__); return status; } @@ -4621,9 +4452,7 @@ gl646_repark_head (Genesys_Device * dev) status = sanei_genesys_read_feed_steps (dev, &steps); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_repark_head: failed to read feed steps: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read feed steps: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -4631,7 +4460,7 @@ gl646_repark_head (Genesys_Device * dev) /* toggle motor flag, put an huge step number and redo move backward */ status = gl646_slow_back_home (dev, 1); - DBG (DBG_proc, "gl646_repark_head: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -4652,22 +4481,22 @@ gl646_init (Genesys_Device * dev) size_t len; DBG_INIT (); - DBG (DBG_proc, "gl646_init: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); /* to detect real power up condition, we write to REG41 * with pwrbit set, then read it back. When scanner is cold (just replugged) * PWRBIT will be set in the returned value */ RIE (sanei_genesys_get_status (dev, &cold)); - DBG (DBG_info, "gl646_init: status=0x%02x\n", cold); + DBG(DBG_info, "%s: status=0x%02x\n", __func__, cold); cold = !(cold & REG41_PWRBIT); if (cold) { - DBG (DBG_info, "gl646_init: device is cold\n"); + DBG(DBG_info, "%s: device is cold\n", __func__); } else { - DBG (DBG_info, "gl646_init: device is hot\n"); + DBG(DBG_info, "%s: device is hot\n", __func__); } /* if scanning session hasn't been initialized, set it up */ @@ -4712,7 +4541,7 @@ gl646_init (Genesys_Device * dev) dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size); if (dev->sensor.gamma_table[i] == NULL) { - DBG (DBG_error, "gl646_init: could not allocate memory for gamma table %d\n",i); + DBG(DBG_error, "%s: could not allocate memory for gamma table %d\n", __func__, i); return SANE_STATUS_NO_MEM; } sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i], @@ -4734,7 +4563,7 @@ gl646_init (Genesys_Device * dev) /* execute physical unit init only if cold */ if (cold) { - DBG (DBG_info, "gl646_init: device is cold\n"); + DBG(DBG_info, "%s: device is cold\n", __func__); val = 0x04; RIE (sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_INIT, @@ -4757,9 +4586,8 @@ gl646_init (Genesys_Device * dev) status = gl646_send_gamma_table (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_init: failed to send generic gamma tables: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send generic gamma tables: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -4781,8 +4609,7 @@ gl646_init (Genesys_Device * dev) status = gl646_gpio_output_enable (dev->dn, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_init: GPO enable failed ... %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: GPO enable failed ... %s\n", __func__, sane_strstatus(status)); } val = 0; @@ -4790,16 +4617,14 @@ gl646_init (Genesys_Device * dev) status = gl646_gpio_write (dev->dn, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_init: GPO write failed ... %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: GPO write failed ... %s\n", __func__, sane_strstatus(status)); } /* clear GPIO enable */ status = gl646_gpio_output_enable (dev->dn, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_init: GPO disable failed ... %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: GPO disable failed ... %s\n", __func__, sane_strstatus(status)); } sanei_genesys_write_register (dev, 0x66, 0x10); sanei_genesys_write_register (dev, 0x66, 0x00); @@ -4826,7 +4651,7 @@ gl646_init (Genesys_Device * dev) status = sanei_genesys_set_buffer_address (dev, addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_init: failed to set up control address\n"); + DBG(DBG_error, "%s: failed to set up control address\n", __func__); return SANE_STATUS_INVAL; } sanei_usb_set_timeout (2 * 1000); @@ -4837,20 +4662,19 @@ gl646_init (Genesys_Device * dev) */ if (status != SANE_STATUS_GOOD) { - DBG (DBG_warn, "gl646_init: failed to read control\n"); + DBG(DBG_warn, "%s: failed to read control\n", __func__); status = gl646_bulk_read_data (dev, 0x45, dev->control, len); } if (status != SANE_STATUS_GOOD) { - DBG (DBG_warn, "gl646_init: failed to read control\n"); + DBG(DBG_warn, "%s: failed to read control\n", __func__); return SANE_STATUS_INVAL; } else { - DBG (DBG_info, - "gl646_init: control read=0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", - dev->control[0], dev->control[1], dev->control[2], - dev->control[3], dev->control[4], dev->control[5]); + DBG(DBG_info, "%s: control read=0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n", __func__, + dev->control[0], dev->control[1], dev->control[2], dev->control[3], dev->control[4], + dev->control[5]); } sanei_usb_set_timeout (30 * 1000); } @@ -4875,9 +4699,8 @@ gl646_init (Genesys_Device * dev) { if (status == SANE_STATUS_INVAL) { - DBG (DBG_error0, - "Your scanner is locked. Please move the lock switch " - "to the unlocked position\n"); + DBG(DBG_error0, "Your scanner is locked. Please move the lock switch to the " + "unlocked position\n"); #ifdef SANE_STATUS_HW_LOCKED return SANE_STATUS_HW_LOCKED; #else @@ -4885,9 +4708,8 @@ gl646_init (Genesys_Device * dev) #endif } else - DBG (DBG_error, - "gl646_init: gl646_repark_head failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: gl646_repark_head failed: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -4900,7 +4722,7 @@ gl646_init (Genesys_Device * dev) /* here session and device are initialized */ dev->already_initialized = SANE_TRUE; - DBG (DBG_proc, "gl646_init: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return SANE_STATUS_GOOD; } @@ -4914,8 +4736,7 @@ gl646_move_to_ta (Genesys_Device * dev) if (simple_move (dev, SANE_UNFIX (dev->model->y_offset_calib_ta)) != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_move_to_ta: failed to move to calibration area\n"); + DBG(DBG_error, "%s: failed to move to calibration area\n", __func__); return status; } DBGCOMPLETED; @@ -4945,9 +4766,8 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, int count; uint8_t val; - DBG (DBG_proc, "simple_scan: starting\n"); - DBG (DBG_io, "simple_scan: move=%d, forward=%d, shading=%d\n", move, - forward, shading); + DBG(DBG_proc, "%s: starting\n", __func__); + DBG(DBG_io, "%s: move=%d, forward=%d, shading=%d\n", __func__, move, forward, shading); /* round up to multiple of 3 in case of CIS scanner */ if (dev->model->is_cis == SANE_TRUE) @@ -4967,8 +4787,7 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, status = setup_for_scan (dev, dev->reg, settings, split, SANE_FALSE, SANE_FALSE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "simple_scan: setup_for_scan failed (%s)\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: setup_for_scan failed (%s)\n", __func__, sane_strstatus(status)); return status; } @@ -4992,12 +4811,10 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, *data = malloc (size); if (!*data) { - DBG (DBG_error, - "simple_scan: failed to allocate %d bytes of memory\n", size); + DBG(DBG_error, "%s: failed to allocate %d bytes of memory\n", __func__, size); return SANE_STATUS_NO_MEM; } - DBG (DBG_io, "simple_scan: allocated %d bytes of memory for %d lines\n", - size, lines); + DBG(DBG_io, "%s: allocated %d bytes of memory for %d lines\n", __func__, size, lines); /* put back real line number in settings */ settings.lines = lines; @@ -5007,9 +4824,7 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, if (status != SANE_STATUS_GOOD) { free (*data); - DBG (DBG_error, - "simple_scan: failed to set frontend: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus(status)); return status; } @@ -5055,9 +4870,7 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, sizeof (dev->reg[0])); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "simple_scan: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); free (*data); return status; } @@ -5067,7 +4880,7 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, if (status != SANE_STATUS_GOOD) { free (*data); - DBG (DBG_error, "simple_scan: failed to begin scan: \n"); + DBG(DBG_error, "%s: failed to begin scan: \n", __func__); return status; } @@ -5088,7 +4901,7 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, if (count == 1000) { free (*data); - DBG (DBG_error, "simple_scan: failed toread data\n"); + DBG(DBG_error, "%s: failed toread data\n", __func__); return SANE_STATUS_IO_ERROR; } @@ -5097,8 +4910,7 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, if (status != SANE_STATUS_GOOD) { free (*data); - DBG (DBG_error, - "simple_scan: failed to read data: %s\n", sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -5110,9 +4922,8 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, buffer = (unsigned char *) malloc (settings.pixels * 3 * bpp); if (buffer == NULL) { - DBG (DBG_error, - "simple_scan: failed to allocate %d bytes of memory\n", - settings.pixels * 3); + DBG(DBG_error, "%s: failed to allocate %d bytes of memory\n", __func__, + settings.pixels * 3); return SANE_STATUS_NO_MEM; } @@ -5172,12 +4983,11 @@ simple_scan (Genesys_Device * dev, Genesys_Settings settings, SANE_Bool move, if (status != SANE_STATUS_GOOD) { free (*data); - DBG (DBG_error, - "simple_scan: failed to end scan: %s\n", sane_strstatus (status)); + DBG(DBG_error, "%s: failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_proc, "simple_scan: end\n"); + DBG(DBG_proc, "%s: end\n", __func__); return status; } @@ -5195,7 +5005,7 @@ simple_move (Genesys_Device * dev, SANE_Int distance) unsigned char *data = NULL; Genesys_Settings settings; - DBG (DBG_proc, "simple_move: %d mm\n", distance); + DBG(DBG_proc, "%s: %d mm\n", __func__, distance); /* TODO give a no AGOHOME flag */ settings.scan_method = SCAN_METHOD_TRANSPARENCY; @@ -5218,7 +5028,7 @@ simple_move (Genesys_Device * dev, SANE_Int distance) status = simple_scan (dev, settings, SANE_TRUE, SANE_TRUE, SANE_FALSE, &data); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "simple_move: simple_scan failed\n"); + DBG(DBG_error, "%s: simple_scan failed\n", __func__); } free (data); @@ -5243,12 +5053,10 @@ gl646_update_hardware_sensors (Genesys_Scanner * session) status = gl646_gpio_read (dev->dn, &value); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl646_update_hardware_sensors: failed to read GPIO %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read GPIO %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_io, "gl646_update_hardware_sensors: GPIO=0x%02x\n", value); + DBG(DBG_io, "%s: GPIO=0x%02x\n", __func__, value); /* scan button */ if ((dev->model->buttons & GENESYS_HAS_SCAN_SW) @@ -5366,12 +5174,12 @@ gl646_update_hardware_sensors (Genesys_Scanner * session) /* test if XPA is plugged-in */ if ((value & 0x40) == 0) { - DBG (DBG_io, "gl646_update_hardware_sensors: enabling XPA\n"); + DBG(DBG_io, "%s: enabling XPA\n", __func__); session->opt[OPT_SOURCE].cap &= ~SANE_CAP_INACTIVE; } else { - DBG (DBG_io, "gl646_update_hardware_sensors: disabling XPA\n"); + DBG(DBG_io, "%s: disabling XPA\n", __func__); session->opt[OPT_SOURCE].cap |= SANE_CAP_INACTIVE; } break; @@ -5409,7 +5217,7 @@ write_control (Genesys_Device * dev, int resolution) addr = 0x1fa00; break; default: - DBG (DBG_error, "write_control: failed to compute control address\n"); + DBG(DBG_error, "%s: failed to compute control address\n", __func__); return SANE_STATUS_INVAL; } @@ -5434,19 +5242,18 @@ write_control (Genesys_Device * dev, int resolution) break; } - DBG (DBG_info, - "write_control: control write=0x%02x 0x%02x 0x%02x 0x%02x\n", - control[0], control[1], control[2], control[3]); + DBG(DBG_info, "%s: control write=0x%02x 0x%02x 0x%02x 0x%02x\n", __func__, control[0], control[1], + control[2], control[3]); status = sanei_genesys_set_buffer_address (dev, addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "write_control: failed to set up control address\n"); + DBG(DBG_error, "%s: failed to set up control address\n", __func__); return SANE_STATUS_INVAL; } status = gl646_bulk_write_data (dev, 0x3c, control, 4); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "write_control: failed to set up control\n"); + DBG(DBG_error, "%s: failed to set up control\n", __func__); return SANE_STATUS_INVAL; } return status; @@ -5470,9 +5277,7 @@ gl646_is_compatible_calibration (Genesys_Device * dev, #endif int compatible = 1; - DBG (DBG_proc, - "gl646_is_compatible_calibration: start (for_overwrite=%d)\n", - for_overwrite); + DBG(DBG_proc, "%s: start (for_overwrite=%d)\n", __func__, for_overwrite); if (cache == NULL) return SANE_STATUS_UNSUPPORTED; @@ -5491,10 +5296,8 @@ gl646_is_compatible_calibration (Genesys_Device * dev, dev->current_setup.xres = dev->settings.xres; dev->current_setup.scan_method = dev->settings.scan_method; - DBG (DBG_io, - "gl646_is_compatible_calibration: requested=(%d,%f), tested=(%d,%f)\n", - dev->current_setup.channels, dev->current_setup.xres, - cache->used_setup.channels, cache->used_setup.xres); + DBG(DBG_io, "%s: requested=(%d,%f), tested=(%d,%f)\n", __func__, dev->current_setup.channels, + dev->current_setup.xres, cache->used_setup.channels, cache->used_setup.xres); /* a calibration cache is compatible if color mode and x dpi match the user * requested scan. In the case of CIS scanners, dpi isn't a criteria */ @@ -5512,15 +5315,13 @@ gl646_is_compatible_calibration (Genesys_Device * dev, } if (dev->current_setup.scan_method != cache->used_setup.scan_method) { - DBG (DBG_io, - "gl646_is_compatible_calibration: current method=%d, used=%d\n", - dev->current_setup.scan_method, cache->used_setup.scan_method); + DBG(DBG_io, "%s: current method=%d, used=%d\n", __func__, dev->current_setup.scan_method, + cache->used_setup.scan_method); compatible = 0; } if (!compatible) { - DBG (DBG_proc, - "gl646_is_compatible_calibration: completed, non compatible cache\n"); + DBG(DBG_proc, "%s: completed, non compatible cache\n", __func__); return SANE_STATUS_UNSUPPORTED; } @@ -5533,15 +5334,13 @@ gl646_is_compatible_calibration (Genesys_Device * dev, if ((time.tv_sec - cache->last_calibration > 30 * 60) && (dev->model->is_sheetfed == SANE_FALSE)) { - DBG (DBG_proc, - "gl646_is_compatible_calibration: expired entry, non compatible cache\n"); + DBG(DBG_proc, "%s: expired entry, non compatible cache\n", __func__); return SANE_STATUS_UNSUPPORTED; } } #endif - DBG (DBG_proc, - "gl646_is_compatible_calibration: completed, cache compatible\n"); + DBG(DBG_proc, "%s: completed, cache compatible\n", __func__); return SANE_STATUS_GOOD; } @@ -5563,7 +5362,7 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) unsigned int pass, count, found, x, y; char title[80]; - DBG (DBG_proc, "gl646_search_strip: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); /* adapt to half_ccd case */ if (dev->model->flags & GENESYS_FLAG_HALF_CCD_MODE) { @@ -5611,7 +5410,7 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) simple_scan (dev, settings, SANE_TRUE, forward, SANE_FALSE, &data); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl646_search_strip: simple_scan failed\n"); + DBG(DBG_error, "%s: simple_scan failed\n", __func__); free (data); return status; } @@ -5653,14 +5452,12 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / settings.pixels < 3) { found = 1; - DBG (DBG_data, - "gl646_search_strip: strip found forward during pass %d at line %d\n", - pass, y); + DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, + pass, y); } else { - DBG (DBG_data, "gl646_search_strip: pixels=%d, count=%d\n", - settings.pixels, count); + DBG(DBG_data, "%s: pixels=%d, count=%d\n", __func__, settings.pixels, count); } } } @@ -5691,14 +5488,11 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / (settings.pixels * settings.lines) < 3) { found = 1; - DBG (DBG_data, - "gl646_search_strip: strip found backward during pass %d \n", - pass); + DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { - DBG (DBG_data, "gl646_search_strip: pixels=%d, count=%d\n", - settings.pixels, count); + DBG(DBG_data, "%s: pixels=%d, count=%d\n", __func__, settings.pixels, count); } } pass++; @@ -5707,12 +5501,12 @@ gl646_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (found) { status = SANE_STATUS_GOOD; - DBG (DBG_info, "gl646_search_strip: strip found\n"); + DBG(DBG_info, "%s: strip found\n", __func__); } else { status = SANE_STATUS_UNSUPPORTED; - DBG (DBG_info, "gl646_search_strip: strip not found\n"); + DBG(DBG_info, "%s: strip not found\n", __func__); } return status; } diff --git a/backend/genesys_gl841.c b/backend/genesys_gl841.c index 45f7d7f3d..67302473f 100644 --- a/backend/genesys_gl841.c +++ b/backend/genesys_gl841.c @@ -81,16 +81,14 @@ gl841_bulk_write_register (Genesys_Device * dev, elems = i; - DBG (DBG_io, "gl841_bulk_write_register (elems = %lu)\n", - (u_long) elems); + DBG(DBG_io, "%s (elems = %lu)\n", __func__, (u_long) elems); for (i = 0; i < elems; i++) { buffer[i * 2 + 0] = reg[i].address; buffer[i * 2 + 1] = reg[i].value; - DBG (DBG_io2, "reg[0x%02x] = 0x%02x\n", buffer[i * 2 + 0], - buffer[i * 2 + 1]); + DBG(DBG_io2, "reg[0x%02x] = 0x%02x\n", buffer[i * 2 + 0], buffer[i * 2 + 1]); } for (i = 0; i < elems;) { @@ -102,17 +100,15 @@ gl841_bulk_write_register (Genesys_Device * dev, VALUE_SET_REGISTER, INDEX, c * 2, buffer + i * 2); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_bulk_write_register: failed while writing command: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing command: %s\n", __func__, + sane_strstatus(status)); return status; } i += c; } - DBG (DBG_io, "gl841_bulk_write_register: wrote %lu registers\n", - (u_long) elems); + DBG(DBG_io, "%s: wrote %lu registers\n", __func__, (u_long) elems); return status; } @@ -125,17 +121,14 @@ gl841_bulk_write_data (Genesys_Device * dev, uint8_t addr, size_t size; uint8_t outdata[8]; - DBG (DBG_io, "gl841_bulk_write_data writing %lu bytes\n", - (u_long) len); + DBG(DBG_io, "%s writing %lu bytes\n", __func__, (u_long) len); status = sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, INDEX, 1, &addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_bulk_write_data failed while setting register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while setting register: %s\n", __func__, sane_strstatus(status)); return status; } @@ -161,30 +154,26 @@ gl841_bulk_write_data (Genesys_Device * dev, uint8_t addr, outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_bulk_write_data failed while writing command: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing command: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_usb_write_bulk (dev->dn, data, &size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_bulk_write_data failed while writing bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_io2, - "gl841_bulk_write_data wrote %lu bytes, %lu remaining\n", - (u_long) size, (u_long) (len - size)); + DBG(DBG_io2, "%s wrote %lu bytes, %lu remaining\n", __func__, (u_long) size, + (u_long) (len - size)); len -= size; data += size; } - DBG (DBG_io, "gl841_bulk_write_data: completed\n"); + DBG(DBG_io, "%s: completed\n", __func__); return status; } @@ -217,8 +206,7 @@ gl841_bulk_read_data (Genesys_Device * dev, uint8_t addr, size_t size, target; uint8_t outdata[8], *buffer; - DBG (DBG_io, "gl841_bulk_read_data: requesting %lu bytes\n", - (u_long) len); + DBG(DBG_io, "%s: requesting %lu bytes\n", __func__, (u_long) len); if (len == 0) return SANE_STATUS_GOOD; @@ -228,9 +216,7 @@ gl841_bulk_read_data (Genesys_Device * dev, uint8_t addr, VALUE_SET_REGISTER, INDEX, 1, &addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_bulk_read_data failed while setting register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while setting register: %s\n", __func__, sane_strstatus(status)); return status; } @@ -248,9 +234,7 @@ gl841_bulk_read_data (Genesys_Device * dev, uint8_t addr, VALUE_BUFFER, INDEX, sizeof (outdata), outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_bulk_read_data failed while writing command: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing command: %s\n", __func__, sane_strstatus(status)); return status; } @@ -263,23 +247,19 @@ gl841_bulk_read_data (Genesys_Device * dev, uint8_t addr, else size = target; - DBG (DBG_io2, - "gl841_bulk_read_data: trying to read %lu bytes of data\n", - (u_long) size); + DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) size); status = sanei_usb_read_bulk (dev->dn, data, &size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_bulk_read_data failed while reading bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_io2, - "gl841_bulk_read_data read %lu bytes, %lu remaining\n", - (u_long) size, (u_long) (target - size)); + DBG(DBG_io2, "%s read %lu bytes, %lu remaining\n", __func__, (u_long) size, + (u_long) (target - size)); target -= size; data += size; @@ -300,17 +280,14 @@ gl841_set_buffer_address_gamma (Genesys_Device * dev, uint32_t addr) { SANE_Status status; - DBG (DBG_io, "gl841_set_buffer_address_gamma: setting address to 0x%05x\n", - addr & 0xfffffff0); + DBG(DBG_io, "%s: setting address to 0x%05x\n", __func__, addr & 0xfffffff0); addr = addr >> 4; status = sanei_genesys_write_register (dev, 0x5c, (addr & 0xff)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_set_buffer_address_gamma: failed while writing low byte: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing low byte: %s\n", __func__, sane_strstatus(status)); return status; } @@ -318,13 +295,11 @@ gl841_set_buffer_address_gamma (Genesys_Device * dev, uint32_t addr) status = sanei_genesys_write_register (dev, 0x5b, (addr & 0xff)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_set_buffer_address_gamma: failed while writing high byte: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing high byte: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_io, "gl841_set_buffer_address_gamma: completed\n"); + DBG(DBG_io, "%s: completed\n", __func__); return status; } @@ -338,17 +313,14 @@ gl841_bulk_write_data_gamma (Genesys_Device * dev, uint8_t addr, size_t size; uint8_t outdata[8]; - DBG (DBG_io, "gl841_bulk_write_data_gamma writing %lu bytes\n", - (u_long) len); + DBG(DBG_io, "%s writing %lu bytes\n", __func__, (u_long) len); status = sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, INDEX, 1, &addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_bulk_write_data_gamma failed while setting register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while setting register: %s\n", __func__, sane_strstatus(status)); return status; } @@ -374,30 +346,26 @@ gl841_bulk_write_data_gamma (Genesys_Device * dev, uint8_t addr, outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_bulk_write_data_gamma failed while writing command: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing command: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_usb_write_bulk (dev->dn, data, &size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "genesys_bulk_write_data_gamma failed while writing bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_io2, - "genesys_bulk_write_data:gamma wrote %lu bytes, %lu remaining\n", - (u_long) size, (u_long) (len - size)); + DBG(DBG_io2, "%s:gamma wrote %lu bytes, %lu remaining\n", __func__, (u_long) size, + (u_long) (len - size)); len -= size; data += size; } - DBG (DBG_io, "genesys_bulk_write_data_gamma: completed\n"); + DBG(DBG_io, "%s: completed\n", __func__); return status; } @@ -519,7 +487,7 @@ sanei_gl841_setup_sensor (Genesys_Device * dev, Genesys_Register_Set *r; int i; - DBG (DBG_proc, "gl841_setup_sensor\n"); + DBG(DBG_proc, "%s\n", __func__); /* that one is tricky at least ....*/ r = sanei_genesys_get_address (regs, 0x70); @@ -624,7 +592,7 @@ sanei_gl841_asic_test (Genesys_Device * dev) size_t size, verify_size; unsigned int i; - DBG (DBG_proc, "sanei_gl841_asic_test\n"); + DBG(DBG_proc, "%s\n", __func__); return SANE_STATUS_INVAL; @@ -632,44 +600,38 @@ sanei_gl841_asic_test (Genesys_Device * dev) status = sanei_genesys_write_register (dev, 0x38, 0xde); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sanei_gl841_asic_test: failed to write register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write register: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_write_register (dev, 0x39, 0xad); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sanei_gl841_asic_test: failed to write register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write register: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_read_register (dev, 0x38, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sanei_gl841_asic_test: failed to read register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read register: %s\n", __func__, sane_strstatus(status)); return status; } if (val != 0xde) /* value of register 0x38 */ { - DBG (DBG_error, - "sanei_gl841_asic_test: register contains invalid value\n"); + DBG(DBG_error, "%s: register contains invalid value\n", __func__); return SANE_STATUS_IO_ERROR; } status = sanei_genesys_read_register (dev, 0x39, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sanei_gl841_asic_test: failed to read register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read register: %s\n", __func__, sane_strstatus(status)); return status; } if (val != 0xad) /* value of register 0x39 */ { - DBG (DBG_error, - "sanei_gl841_asic_test: register contains invalid value\n"); + DBG(DBG_error, "%s: register contains invalid value\n", __func__); return SANE_STATUS_IO_ERROR; } @@ -683,7 +645,7 @@ sanei_gl841_asic_test (Genesys_Device * dev) data = (uint8_t *) malloc (size); if (!data) { - DBG (DBG_error, "sanei_gl841_asic_test: could not allocate memory\n"); + DBG(DBG_error, "%s: could not allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -691,7 +653,7 @@ sanei_gl841_asic_test (Genesys_Device * dev) if (!verify_data) { free (data); - DBG (DBG_error, "sanei_gl841_asic_test: could not allocate memory\n"); + DBG(DBG_error, "%s: could not allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -704,9 +666,7 @@ sanei_gl841_asic_test (Genesys_Device * dev) status = sanei_genesys_set_buffer_address (dev, 0x0000); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_gl841_asic_test: failed to set buffer address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); free (data); free (verify_data); return status; @@ -715,9 +675,7 @@ sanei_gl841_asic_test (Genesys_Device * dev) /* status = gl841_bulk_write_data (dev, 0x3c, data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_gl841_asic_test: failed to bulk write data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write data: %s\n", __func__, sane_strstatus(status)); free (data); free (verify_data); return status; @@ -726,9 +684,7 @@ sanei_gl841_asic_test (Genesys_Device * dev) status = sanei_genesys_set_buffer_address (dev, 0x0000); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_gl841_asic_test: failed to set buffer address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); free (data); free (verify_data); return status; @@ -739,8 +695,7 @@ sanei_gl841_asic_test (Genesys_Device * dev) verify_size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sanei_gl841_asic_test: failed to bulk read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk read data: %s\n", __func__, sane_strstatus(status)); free (data); free (verify_data); return status; @@ -751,17 +706,17 @@ sanei_gl841_asic_test (Genesys_Device * dev) { if (verify_data[i] != data[i]) { - DBG (DBG_error, "sanei_gl841_asic_test: data verification error\n"); - DBG (DBG_info, "0x%.8x: got %.2x %.2x %.2x %.2x, expected %.2x %.2x %.2x %.2x\n", - i, - verify_data[i], - verify_data[i+1], - verify_data[i+2], - verify_data[i+3], - data[i], - data[i+1], - data[i+2], - data[i+3]); + DBG(DBG_error, "%s: data verification error\n", __func__); + DBG(DBG_info, "0x%.8x: got %.2x %.2x %.2x %.2x, expected %.2x %.2x %.2x %.2x\n", + i, + verify_data[i], + verify_data[i+1], + verify_data[i+2], + verify_data[i+3], + data[i], + data[i+1], + data[i+2], + data[i+3]); free (data); free (verify_data); return SANE_STATUS_IO_ERROR; @@ -771,7 +726,7 @@ sanei_gl841_asic_test (Genesys_Device * dev) free (data); free (verify_data); - DBG (DBG_info, "sanei_gl841_asic_test: completed\n"); + DBG(DBG_info, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -953,7 +908,7 @@ gl841_init_registers (Genesys_Device * dev) { int nr, addr; - DBG (DBG_proc, "gl841_init_registers\n"); + DBG(DBG_proc, "%s\n", __func__); nr = 0; memset (dev->reg, 0, GENESYS_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -1015,9 +970,8 @@ gl841_init_registers (Genesys_Device * dev) else { dev->reg[reg_0x05].value |= REG05_DPIHW_2400; - DBG (DBG_warn, - "gl841_init_registers: Cannot handle sensor pixel count %d\n", - dev->sensor.sensor_pixels); + DBG(DBG_warn, "%s: Cannot handle sensor pixel count %d\n", __func__, + dev->sensor.sensor_pixels); } @@ -1109,7 +1063,7 @@ gl841_init_registers (Genesys_Device * dev) dev->reg[reg_0x6b].value |= REG6B_GPO17|REG6B_GPO18; } - DBG (DBG_proc, "gl841_init_registers complete\n"); + DBG(DBG_proc, "%s complete\n", __func__); } /* Send slope table for motor movement @@ -1128,8 +1082,7 @@ gl841_send_slope_table (Genesys_Device * dev, int table_nr, int i; /*#endif*/ - DBG (DBG_proc, "gl841_send_slope_table (table_nr = %d, steps = %d)\n", - table_nr, steps); + DBG(DBG_proc, "%s (table_nr = %d, steps = %d)\n", __func__, table_nr, steps); dpihw = dev->reg[reg_0x05].value >> 6; @@ -1158,7 +1111,7 @@ gl841_send_slope_table (Genesys_Device * dev, int table_nr, { sprintf (msg+strlen(msg), ",%d", slope_table[i]); } - DBG (DBG_io, "%s: %s\n", __func__, msg); + DBG(DBG_io, "%s: %s\n", __func__, msg); } status = @@ -1168,9 +1121,7 @@ gl841_send_slope_table (Genesys_Device * dev, int table_nr, /*#ifdef WORDS_BIGENDIAN*/ free(table); /*#endif*/ - DBG (DBG_error, - "gl841_send_slope_table: failed to set buffer address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1182,16 +1133,14 @@ gl841_send_slope_table (Genesys_Device * dev, int table_nr, /*#ifdef WORDS_BIGENDIAN*/ free(table); /*#endif*/ - DBG (DBG_error, - "gl841_send_slope_table: failed to send slope table: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send slope table: %s\n", __func__, sane_strstatus(status)); return status; } /*#ifdef WORDS_BIGENDIAN*/ free(table); /*#endif*/ - DBG (DBG_proc, "gl841_send_slope_table: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -1204,8 +1153,7 @@ gl841_set_lide80_fe (Genesys_Device * dev, uint8_t set) if (set == AFE_INIT) { - DBG (DBG_proc, "%s(): setting DAC %u\n", __func__, - dev->model->dac_type); + DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); /* sets to default values */ sanei_genesys_init_fe (dev); @@ -1214,22 +1162,19 @@ gl841_set_lide80_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.reg[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing reg 0x03 failed: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg 0x03 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x06, dev->frontend.reg[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing reg 0x06 failed: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg 0x06 failed: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -1239,22 +1184,19 @@ gl841_set_lide80_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x06, dev->frontend.offset[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing offset failed: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing offset failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.gain[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: writing gain failed: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing gain failed: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -1276,11 +1218,10 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) return gl841_set_lide80_fe(dev, set); } - DBG (DBG_proc, "gl841_set_ad_fe(): start\n"); + DBG(DBG_proc, "%s(): start\n", __func__); if (set == AFE_INIT) { - DBG (DBG_proc, "gl841_set_ad_fe(): setting DAC %u\n", - dev->model->dac_type); + DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); /* sets to default values */ sanei_genesys_init_fe (dev); @@ -1289,16 +1230,14 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: writing reg 0x00 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: writing reg 0x01 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg 0x01 failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1308,9 +1247,8 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) sanei_genesys_fe_write_data (dev, 0x02 + i, 0x00); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_set_ad_fe: writing sign[%d] failed: %s\n", 0x02 + i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing sign[%d] failed: %s\n", __func__, 0x02 + i, + sane_strstatus(status)); return status; } } @@ -1321,16 +1259,14 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: writing reg 0x00 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg 0x00 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: writing reg 0x01 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg 0x01 failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1338,8 +1274,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x02, dev->frontend.gain[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: writing fe 0x02 (gain r) fail: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing fe 0x02 (gain r) fail: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1347,8 +1282,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.gain[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: writing fe 0x03 (gain g) fail: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing fe 0x03 (gain g) fail: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1356,8 +1290,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x04, dev->frontend.gain[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: writing fe 0x04 (gain b) fail: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing fe 0x04 (gain b) fail: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1366,8 +1299,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) sanei_genesys_fe_write_data (dev, 0x05, dev->frontend.offset[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: write fe 0x05 (offset r) fail: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: write fe 0x05 (offset r) fail: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1376,8 +1308,7 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) sanei_genesys_fe_write_data (dev, 0x06, dev->frontend.offset[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: write fe 0x06 (offset g) fail: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: write fe 0x06 (offset g) fail: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1386,12 +1317,11 @@ gl841_set_ad_fe (Genesys_Device * dev, uint8_t set) sanei_genesys_fe_write_data (dev, 0x07, dev->frontend.offset[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_ad_fe: write fe 0x07 (offset b) fail: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: write fe 0x07 (offset b) fail: %s\n", __func__, sane_strstatus(status)); return status; } } - DBG (DBG_proc, "gl841_set_ad_fe(): end\n"); + DBG(DBG_proc, "%s(): end\n", __func__); return status; } @@ -1403,9 +1333,9 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set) SANE_Status status; int i; - DBG (DBG_proc, "gl841_set_fe (%s)\n", - set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == - AFE_POWER_SAVE ? "powersave" : "huh?"); + DBG(DBG_proc, "%s (%s)\n", __func__, + set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == + AFE_POWER_SAVE ? "powersave" : "huh?"); /* Analog Device type frontend */ if ((dev->reg[reg_0x04].value & REG04_FESET) == 0x02) @@ -1415,23 +1345,21 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set) if ((dev->reg[reg_0x04].value & REG04_FESET) != 0x00) { - DBG (DBG_proc, "gl841_set_fe(): unsupported frontend type %d\n", - dev->reg[reg_0x04].value & REG04_FESET); + DBG(DBG_proc, "%s(): unsupported frontend type %d\n", __func__, + dev->reg[reg_0x04].value & REG04_FESET); return SANE_STATUS_UNSUPPORTED; } if (set == AFE_INIT) { - DBG (DBG_proc, "gl841_set_fe(): setting DAC %u\n", - dev->model->dac_type); + DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); sanei_genesys_init_fe (dev); /* reset only done on init */ status = sanei_genesys_fe_write_data (dev, 0x04, 0x80); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_fe: reset fe failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: reset fe failed: %s\n", __func__, sane_strstatus(status)); return status; /* if (dev->model->ccd_type == CCD_HP2300 @@ -1444,14 +1372,13 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set) INDEX, 1, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_set_fe failed resetting frontend: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed resetting frontend: %s\n", __func__, + sane_strstatus(status)); return status; } }*/ } - DBG (DBG_proc, "gl841_set_fe(): frontend reset complete\n"); + DBG(DBG_proc, "%s(): frontend reset complete\n", __func__); } @@ -1459,8 +1386,7 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set) { status = sanei_genesys_fe_write_data (dev, 0x01, 0x02); if (status != SANE_STATUS_GOOD) - DBG (DBG_error, "gl841_set_fe: writing data failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing data failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1471,15 +1397,13 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, dev->frontend.reg[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_fe: writing reg0 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg0 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x02, dev->frontend.reg[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_fe: writing reg2 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg2 failed: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -1487,40 +1411,35 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x01, dev->frontend.reg[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_fe: writing reg1 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg1 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x03, dev->frontend.reg[3]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_fe: writing reg3 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg3 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x06, dev->frontend.reg2[0]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_fe: writing reg6 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg6 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x08, dev->frontend.reg2[1]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_fe: writing reg8 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg8 failed: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_fe_write_data (dev, 0x09, dev->frontend.reg2[2]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_set_fe: writing reg9 failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg9 failed: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1530,9 +1449,8 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set) sanei_genesys_fe_write_data (dev, 0x24 + i, dev->frontend.sign[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_set_fe: writing sign[%d] failed: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing sign[%d] failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } @@ -1540,9 +1458,8 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set) sanei_genesys_fe_write_data (dev, 0x28 + i, dev->frontend.gain[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_set_fe: writing gain[%d] failed: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing gain[%d] failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } @@ -1551,15 +1468,14 @@ gl841_set_fe (Genesys_Device * dev, uint8_t set) dev->frontend.offset[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_set_fe: writing offset[%d] failed: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing offset[%d] failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } } - DBG (DBG_proc, "gl841_set_fe: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -1578,8 +1494,7 @@ gl841_init_motor_regs_off(Genesys_Register_Set * reg, unsigned int feedl; Genesys_Register_Set * r; - DBG (DBG_proc, "gl841_init_motor_regs_off : scan_lines=%d\n", - scan_lines); + DBG(DBG_proc, "%s : scan_lines=%d\n", __func__, scan_lines); feedl = 2; @@ -1706,10 +1621,7 @@ gl841_init_motor_regs(Genesys_Device * dev, Genesys_Register_Set * r; /*number of scan lines to add in a scan_lines line*/ - DBG (DBG_proc, "gl841_init_motor_regs : feed_steps=%d, action=%d, flags=%x\n", - feed_steps, - action, - flags); + DBG(DBG_proc, "%s : feed_steps=%d, action=%d, flags=%x\n", __func__, feed_steps, action, flags); memset(fast_slope_table,0xff,512); @@ -1731,7 +1643,7 @@ gl841_init_motor_regs(Genesys_Device * dev, 0, 0, &scan_power_mode); - DBG (DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure); + DBG(DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure); } if (action == MOTOR_ACTION_HOME_FREE) { @@ -1886,17 +1798,16 @@ gl841_init_motor_regs_scan(Genesys_Device * dev, unsigned int min_restep = 0x20; uint32_t z1, z2; - DBG (DBG_proc, "gl841_init_motor_regs_scan : scan_exposure_time=%d, " - "scan_yres=%g, scan_step_type=%d, scan_lines=%d, scan_dummy=%d, " - "feed_steps=%d, scan_power_mode=%d, flags=%x\n", - scan_exposure_time, - scan_yres, - scan_step_type, - scan_lines, - scan_dummy, - feed_steps, - scan_power_mode, - flags); + DBG(DBG_proc, "%s : scan_exposure_time=%d, scan_yres=%g, scan_step_type=%d, scan_lines=%d," + " scan_dummy=%d, feed_steps=%d, scan_power_mode=%d, flags=%x\n", __func__, + scan_exposure_time, + scan_yres, + scan_step_type, + scan_lines, + scan_dummy, + feed_steps, + scan_power_mode, + flags); fast_exposure = gl841_exposure_time(dev, dev->motor.base_ydpi / 4, @@ -1905,7 +1816,7 @@ gl841_init_motor_regs_scan(Genesys_Device * dev, 0, &dummy_power_mode); - DBG (DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure); + DBG(DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure); memset(slow_slope_table,0xff,512); @@ -1958,7 +1869,8 @@ gl841_init_motor_regs_scan(Genesys_Device * dev, fast_slope_steps = (feed_steps - (slow_slope_steps >> scan_step_type))/2; - DBG(DBG_info,"gl841_init_motor_regs_scan: Maximum allowed slope steps for fast slope: %d\n",fast_slope_steps); + DBG(DBG_info, "%s: Maximum allowed slope steps for fast slope: %d\n", __func__, + fast_slope_steps); fast_slope_time = sanei_genesys_create_slope_table3 ( dev, @@ -1981,7 +1893,7 @@ gl841_init_motor_regs_scan(Genesys_Device * dev, } else if (feed_steps < fast_slope_steps*2 + (slow_slope_steps >> scan_step_type)) { use_fast_fed = 0; - DBG(DBG_info,"gl841_init_motor_regs_scan: feed too short, slow move forced.\n"); + DBG(DBG_info, "%s: feed too short, slow move forced.\n", __func__); } else { /* for deciding whether we should use fast mode we need to check how long we need for (fast)accelerating, moving, decelerating, (TODO: stopping?) @@ -2001,10 +1913,8 @@ gl841_init_motor_regs_scan(Genesys_Device * dev, (feed_steps - (slow_slope_steps >> scan_step_type)) + slow_slope_time; - DBG(DBG_info,"gl841_init_motor_regs_scan: Time for slow move: %d\n", - slow_time); - DBG(DBG_info,"gl841_init_motor_regs_scan: Time for fast move: %d\n", - fast_time); + DBG(DBG_info, "%s: Time for slow move: %d\n", __func__, slow_time); + DBG(DBG_info, "%s: Time for fast move: %d\n", __func__, fast_time); use_fast_fed = fast_time < slow_time; } @@ -2017,8 +1927,7 @@ gl841_init_motor_regs_scan(Genesys_Device * dev, feedl = 0; else feedl = (feed_steps << scan_step_type) - slow_slope_steps; - DBG(DBG_info,"gl841_init_motor_regs_scan: Decided to use %s mode\n", - use_fast_fed?"fast feed":"slow feed"); + DBG(DBG_info, "%s: Decided to use %s mode\n", __func__, use_fast_fed?"fast feed":"slow feed"); /* all needed slopes available. we did even decide which mode to use. what next? @@ -2153,8 +2062,8 @@ HOME_FREE: 3 */ z1 = z2 = 0; - DBG (DBG_info, "gl841_init_motor_regs_scan: z1 = %d\n", z1); - DBG (DBG_info, "gl841_init_motor_regs_scan: z2 = %d\n", z2); + DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); + DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); r = sanei_genesys_get_address (reg, 0x60); r->value = ((z1 >> 16) & 0xff); r = sanei_genesys_get_address (reg, 0x61); @@ -2248,26 +2157,23 @@ gl841_init_optical_regs_scan(Genesys_Device * dev, SANE_Status status; uint16_t expavg, expr, expb, expg; - DBG (DBG_proc, "gl841_init_optical_regs_scan : exposure_time=%d, " - "used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " - "half_ccd=%d, flags=%x\n", - exposure_time, - used_res, - start, - pixels, - channels, - depth, - half_ccd, - flags); + DBG(DBG_proc, "%s : exposure_time=%d, used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " + "half_ccd=%d, flags=%x\n", __func__, + exposure_time, + used_res, + start, + pixels, + channels, + depth, + half_ccd, + flags); end = start + pixels; status = gl841_set_fe (dev, AFE_SET); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_init_optical_regs_scan: failed to set frontend: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2447,7 +2353,7 @@ gl841_init_optical_regs_scan(Genesys_Device * dev, sanei_genesys_set_double(reg, REG_DPISET, dpiset); sanei_genesys_set_double(reg, REG_STRPIXEL, start); sanei_genesys_set_double(reg, REG_ENDPIXEL, end); - DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d\n",__func__,start,end); + DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d\n", __func__, start, end); /* words(16bit) before gamma, conversion to 8 bit or lineart*/ words_per_line = (pixels * dpiset) / gl841_get_dpihw(dev); @@ -2619,18 +2525,18 @@ gl841_init_scan_regs (Genesys_Device * dev, SANE_Status status; unsigned int oflags; /**> optical flags */ - DBG (DBG_info, - "gl841_init_scan_regs settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g/%g\n" - "Depth/Channels: %u/%u\n" - "Flags : %x\n\n", - xres, yres, lines, pixels, - startx, starty, - depth, channels, - flags); + DBG(DBG_info, + "%s settings:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g/%g\n" + "Depth/Channels: %u/%u\n" + "Flags : %x\n\n", + __func__, xres, yres, lines, pixels, + startx, starty, + depth, channels, + flags); /* results: @@ -2682,8 +2588,7 @@ independent of our calculated values: stagger = (4 * yres) / dev->motor.base_ydpi; else stagger = 0; - DBG (DBG_info, "gl841_init_scan_regs : stagger=%d lines\n", - stagger); + DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger); /* used_res */ i = optical_res / xres; @@ -2788,7 +2693,7 @@ dummy \ scanned lines start, used_pixels, &scan_power_mode); - DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); + DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); /*** optical parameters ***/ /* in case of dynamic lineart, we use an internal 8 bit gray scan @@ -2842,11 +2747,11 @@ dummy \ scanned lines /* add tl_y to base movement */ move = starty; - DBG (DBG_info, "gl841_init_scan_regs: move=%d steps\n", move); + DBG(DBG_info, "%s: move=%d steps\n", __func__, move); /* subtract current head position */ move -= dev->scanhead_position_in_steps; - DBG (DBG_info, "gl841_init_scan_regs: move=%d steps\n", move); + DBG(DBG_info, "%s: move=%d steps\n", __func__, move); if (move < 0) move = 0; @@ -2854,7 +2759,7 @@ dummy \ scanned lines /* round it */ /* the move is not affected by dummy -- pierre */ /* move = ((move + dummy) / (dummy + 1)) * (dummy + 1); - DBG (DBG_info, "gl841_init_scan_regs: move=%d steps\n", move);*/ + DBG(DBG_info, "%s: move=%d steps\n", __func__, move);*/ if (flags & SCAN_FLAG_SINGLE_LINE) status = gl841_init_motor_regs_off(reg, dev->model->is_cis?lincnt*channels:lincnt); @@ -2909,9 +2814,7 @@ dummy \ scanned lines dev->read_bytes_left = bytes_per_line * lincnt; - DBG (DBG_info, - "gl841_init_scan_regs: physical bytes to read = %lu\n", - (u_long) dev->read_bytes_left); + DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left); dev->read_active = SANE_TRUE; @@ -2951,11 +2854,10 @@ dummy \ scanned lines dev->total_bytes_to_read = dev->settings.pixels * dev->settings.lines * channels * (depth / 8); - DBG (DBG_info, "gl841_init_scan_regs: total bytes to send = %lu\n", - (u_long) dev->total_bytes_to_read); + DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read); /* END TODO */ - DBG (DBG_proc, "gl841_init_scan_regs: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -2988,15 +2890,16 @@ gl841_calculate_current_setup (Genesys_Device * dev) SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */ int optical_res; - DBG (DBG_info, - "gl841_calculate_current_setup settings:\n" - "Resolution: %uDPI\n" - "Lines : %u\n" - "PPL : %u\n" - "Startpos : %.3f/%.3f\n" - "Scan mode : %d\n\n", - dev->settings.yres, dev->settings.lines, dev->settings.pixels, - dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); + DBG(DBG_info, + "%s:\n" + "Resolution: %uDPI\n" + "Lines : %u\n" + "PPL : %u\n" + "Startpos : %.3f/%.3f\n" + "Scan mode : %d\n\n", + __func__, + dev->settings.yres, dev->settings.lines, dev->settings.pixels, + dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); /* channels */ if (dev->settings.scan_mode == 4) /* single pass color */ @@ -3023,16 +2926,16 @@ gl841_calculate_current_setup (Genesys_Device * dev) pixels = dev->settings.pixels; lines = dev->settings.lines; - DBG (DBG_info, - "gl841_calculate_current_setup settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g\n" - "Depth/Channels: %u/%u\n\n", - xres, yres, lines, pixels, - startx, - depth, channels); + DBG(DBG_info, + "%s:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g\n" + "Depth/Channels: %u/%u\n\n", + __func__, xres, yres, lines, pixels, + startx, + depth, channels); /* half_ccd */ /* we have 2 domains for ccd: xres below or above half ccd max dpi */ @@ -3055,8 +2958,7 @@ gl841_calculate_current_setup (Genesys_Device * dev) stagger = (4 * yres) / dev->motor.base_ydpi; else stagger = 0; - DBG (DBG_info, "gl841_calculate_current_setup: stagger=%d lines\n", - stagger); + DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger); /* used_res */ i = optical_res / xres; @@ -3154,7 +3056,7 @@ dummy \ scanned lines start, used_pixels, &scan_power_mode); - DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); + DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); /* scanned area must be enlarged by max color shift needed */ max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0); @@ -3181,7 +3083,7 @@ static void gl841_set_motor_power (Genesys_Register_Set * regs, SANE_Bool set) { - DBG (DBG_proc, "gl841_set_motor_power\n"); + DBG(DBG_proc, "%s\n", __func__); if (set) { @@ -3244,7 +3146,7 @@ static SANE_Status gl841_save_power(Genesys_Device * dev, SANE_Bool enable) { uint8_t val; - DBG(DBG_proc, "gl841_save_power: enable = %d\n", enable); + DBG(DBG_proc, "%s: enable = %d\n", __func__, enable); if (enable) { @@ -3346,7 +3248,7 @@ gl841_set_powersaving (Genesys_Device * dev, Genesys_Register_Set local_reg[7]; int rate, exposure_time, tgtime, time; - DBG (DBG_proc, "gl841_set_powersaving (delay = %d)\n", delay); + DBG(DBG_proc, "%s (delay = %d)\n", __func__, delay); local_reg[0].address = 0x01; local_reg[0].value = sanei_genesys_read_reg_from_set (dev->reg, 0x01); /* disable fastmode */ @@ -3417,11 +3319,9 @@ gl841_set_powersaving (Genesys_Device * dev, gl841_bulk_write_register (dev, local_reg, sizeof (local_reg)/sizeof (local_reg[0])); if (status != SANE_STATUS_GOOD) - DBG (DBG_error, - "gl841_set_powersaving: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); - DBG (DBG_proc, "gl841_set_powersaving: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -3439,7 +3339,7 @@ gl841_stop_action (Genesys_Device * dev) uint8_t val40, val; unsigned int loop; - DBG (DBG_proc, "%s\n", __func__); + DBG(DBG_proc, "%s\n", __func__); status = sanei_genesys_get_status (dev, &val); if (DBG_LEVEL >= DBG_io) @@ -3450,9 +3350,7 @@ gl841_stop_action (Genesys_Device * dev) status = sanei_genesys_read_register(dev, 0x40, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read home sensor: %s\n",__func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -3460,7 +3358,7 @@ gl841_stop_action (Genesys_Device * dev) /* only stop action if needed */ if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG)) { - DBG (DBG_info, "%s: already stopped\n", __func__); + DBG(DBG_info, "%s: already stopped\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -3473,8 +3371,7 @@ gl841_stop_action (Genesys_Device * dev) status = gl841_bulk_write_register (dev, local_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3492,9 +3389,7 @@ gl841_stop_action (Genesys_Device * dev) } if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read home sensor: %s\n",__func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -3523,9 +3418,7 @@ gl841_get_paper_sensor(Genesys_Device * dev, SANE_Bool * paper_loaded) status = sanei_genesys_read_register(dev, REG6D, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_get_paper_sensor: failed to read gpio: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read gpio: %s\n", __func__, sane_strstatus(status)); return status; } *paper_loaded = (val & 0x1) == 0; @@ -3543,12 +3436,12 @@ gl841_eject_document (Genesys_Device * dev) float feed_mm; int loop; - DBG (DBG_proc, "gl841_eject_document\n"); + DBG(DBG_proc, "%s\n", __func__); if (dev->model->is_sheetfed == SANE_FALSE) { - DBG (DBG_proc, "gl841_eject_document: there is no \"eject sheet\"-concept for non sheet fed\n"); - DBG (DBG_proc, "gl841_eject_document: finished\n"); + DBG(DBG_proc, "%s: there is no \"eject sheet\"-concept for non sheet fed\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -3559,18 +3452,14 @@ gl841_eject_document (Genesys_Device * dev) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_eject_document: failed to read status register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read status register: %s\n", __func__, sane_strstatus(status)); return status; } status = gl841_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_eject_document: failed to stop motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop motor: %s\n", __func__, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } @@ -3585,18 +3474,14 @@ gl841_eject_document (Genesys_Device * dev) gl841_bulk_write_register (dev, local_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_eject_document: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } status = gl841_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_eject_document: failed to start motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl841_stop_action (dev); /* send original registers */ gl841_bulk_write_register (dev, dev->reg, GENESYS_GL841_MAX_REGS); @@ -3606,8 +3491,7 @@ gl841_eject_document (Genesys_Device * dev) RIE(gl841_get_paper_sensor(dev, &paper_loaded)); if (paper_loaded) { - DBG (DBG_info, - "gl841_eject_document: paper still loaded\n"); + DBG(DBG_info, "%s: paper still loaded\n", __func__); /* force document TRUE, because it is definitely present */ dev->document = SANE_TRUE; dev->scanhead_position_in_steps = 0; @@ -3620,9 +3504,8 @@ gl841_eject_document (Genesys_Device * dev) if (!paper_loaded) { - DBG (DBG_info, - "gl841_eject_document: reached home position\n"); - DBG (DBG_proc, "gl841_eject_document: finished\n"); + DBG(DBG_info, "%s: reached home position\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); break; } usleep (100000); /* sleep 100 ms */ @@ -3633,8 +3516,7 @@ gl841_eject_document (Genesys_Device * dev) { /* when we come here then the scanner needed too much time for this, so we better stop the motor */ gl841_stop_action (dev); - DBG (DBG_error, - "gl841_eject_document: timeout while waiting for scanhead to go home\n"); + DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); return SANE_STATUS_IO_ERROR; } } @@ -3648,9 +3530,7 @@ gl841_eject_document (Genesys_Device * dev) status = sanei_genesys_read_feed_steps(dev, &init_steps); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_eject_document: failed to read feed steps: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read feed steps: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3663,14 +3543,11 @@ gl841_eject_document (Genesys_Device * dev) status = sanei_genesys_read_feed_steps(dev, &steps); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_eject_document: failed to read feed steps: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read feed steps: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, "gl841_eject_document: init_steps: %d, steps: %d\n", - init_steps, steps); + DBG(DBG_info, "%s: init_steps: %d, steps: %d\n", __func__, init_steps, steps); if (steps > init_steps + (feed_mm * dev->motor.base_ydpi) / MM_PER_INCH) { @@ -3684,15 +3561,13 @@ gl841_eject_document (Genesys_Device * dev) status = gl841_stop_action(dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_eject_document: failed to stop motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop motor: %s\n", __func__, sane_strstatus(status)); return status; } dev->document = SANE_FALSE; - DBG (DBG_proc, "gl841_eject_document: finished\n"); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -3703,7 +3578,7 @@ gl841_load_document (Genesys_Device * dev) SANE_Status status; SANE_Bool paper_loaded; int loop = 300; - DBG (DBG_proc, "gl841_load_document\n"); + DBG(DBG_proc, "%s\n", __func__); while (loop > 0) /* do not wait longer then 30 seconds */ { @@ -3711,8 +3586,7 @@ gl841_load_document (Genesys_Device * dev) if (paper_loaded) { - DBG (DBG_info, - "gl841_load_document: document inserted\n"); + DBG(DBG_info, "%s: document inserted\n", __func__); /* when loading OK, document is here */ dev->document = SANE_TRUE; @@ -3727,12 +3601,11 @@ gl841_load_document (Genesys_Device * dev) if (loop == 0) { /* when we come here then the user needed to much time for this */ - DBG (DBG_error, - "gl841_load_document: timeout while waiting for document\n"); + DBG(DBG_error, "%s: timeout while waiting for document\n", __func__); return SANE_STATUS_IO_ERROR; } - DBG (DBG_proc, "gl841_load_document: finished\n"); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -3750,14 +3623,14 @@ gl841_detect_document_end (Genesys_Device * dev) uint8_t val; size_t total_bytes_to_read; - DBG (DBG_proc, "%s: begin\n", __func__); + DBG(DBG_proc, "%s: begin\n", __func__); RIE (gl841_get_paper_sensor (dev, &paper_loaded)); /* sheetfed scanner uses home sensor as paper present */ if ((dev->document == SANE_TRUE) && !paper_loaded) { - DBG (DBG_info, "%s: no more document\n", __func__); + DBG(DBG_info, "%s: no more document\n", __func__); dev->document = SANE_FALSE; /* we can't rely on total_bytes_to_read since the frontend @@ -3769,14 +3642,14 @@ gl841_detect_document_end (Genesys_Device * dev) { dev->total_bytes_to_read = dev->total_bytes_read; dev->read_bytes_left = 0; - DBG (DBG_proc, "%s: finished\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } if (dev->settings.scan_mode == SCAN_MODE_COLOR && dev->model->is_cis) { scancnt/=3; } - DBG (DBG_io, "%s: scancnt=%u lines\n",__func__, scancnt); + DBG(DBG_io, "%s: scancnt=%u lines\n", __func__, scancnt); RIE(sanei_genesys_read_register(dev, 0x25, &val)); lincnt=65536*val; @@ -3784,26 +3657,27 @@ gl841_detect_document_end (Genesys_Device * dev) lincnt+=256*val; RIE(sanei_genesys_read_register(dev, 0x27, &val)); lincnt+=val; - DBG (DBG_io, "%s: lincnt=%u lines\n",__func__, lincnt); + DBG(DBG_io, "%s: lincnt=%u lines\n", __func__, lincnt); postcnt=(SANE_UNFIX(dev->model->post_scan)/MM_PER_INCH)*dev->settings.yres; - DBG (DBG_io, "%s: postcnt=%u lines\n",__func__, postcnt); + DBG(DBG_io, "%s: postcnt=%u lines\n", __func__, postcnt); /* the current scancnt is also the final one, so we use it to * compute total bytes to read. We also add the line count to eject document */ total_bytes_to_read=(scancnt+postcnt)*dev->wpl; - DBG (DBG_io, "%s: old total_bytes_to_read=%u\n",__func__,(unsigned int)dev->total_bytes_to_read); - DBG (DBG_io, "%s: new total_bytes_to_read=%u\n",__func__,(unsigned int)total_bytes_to_read); + DBG(DBG_io, "%s: old total_bytes_to_read=%u\n", __func__, + (unsigned int)dev->total_bytes_to_read); + DBG(DBG_io, "%s: new total_bytes_to_read=%u\n", __func__, (unsigned int)total_bytes_to_read); /* assign new end value */ if(dev->total_bytes_to_read>total_bytes_to_read) { - DBG (DBG_io, "%s: scan shorten\n",__func__); + DBG(DBG_io, "%s: scan shorten\n", __func__); dev->total_bytes_to_read=total_bytes_to_read; } } - DBG (DBG_proc, "%s: finished\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -3817,7 +3691,7 @@ gl841_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg, Genesys_Register_Set local_reg[4]; uint8_t val; - DBG (DBG_proc, "gl841_begin_scan\n"); + DBG(DBG_proc, "%s\n", __func__); if (dev->model->gpo_type == GPO_CANONLIDE80) { @@ -3853,13 +3727,11 @@ gl841_begin_scan (Genesys_Device * dev, Genesys_Register_Set * reg, sizeof (local_reg)/sizeof (local_reg[0])); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_begin_scan: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_proc, "gl841_begin_scan: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -3872,7 +3744,7 @@ gl841_end_scan (Genesys_Device * dev, Genesys_Register_Set __sane_unused__ * reg { SANE_Status status; - DBG (DBG_proc, "gl841_end_scan (check_stop = %d)\n", check_stop); + DBG(DBG_proc, "%s (check_stop = %d)\n", __func__, check_stop); if (dev->model->is_sheetfed == SANE_TRUE) { @@ -3883,14 +3755,12 @@ gl841_end_scan (Genesys_Device * dev, Genesys_Register_Set __sane_unused__ * reg status = gl841_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_end_scan: failed to stop: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop: %s\n", __func__, sane_strstatus(status)); return status; } } - DBG (DBG_proc, "gl841_end_scan: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -3904,13 +3774,12 @@ gl841_feed (Genesys_Device * dev, int steps) uint8_t val; int loop; - DBG (DBG_proc, "gl841_feed (steps = %d)\n", steps); + DBG(DBG_proc, "%s (steps = %d)\n", __func__, steps); status = gl841_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl841_feed: failed to stop action: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop action: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3923,18 +3792,14 @@ gl841_feed (Genesys_Device * dev, int steps) status = gl841_bulk_write_register (dev, local_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_feed: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } status = gl841_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_feed: failed to start motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl841_stop_action (dev); /* send original registers */ gl841_bulk_write_register (dev, dev->reg, GENESYS_GL841_MAX_REGS); @@ -3947,15 +3812,13 @@ gl841_feed (Genesys_Device * dev, int steps) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_feed: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (!(val & REG41_MOTORENB)) /* motor enabled */ { - DBG (DBG_proc, "gl841_feed: finished\n"); + DBG(DBG_proc, "%s: finished\n", __func__); dev->scanhead_position_in_steps += steps; return SANE_STATUS_GOOD; } @@ -3966,8 +3829,7 @@ gl841_feed (Genesys_Device * dev, int steps) /* when we come here then the scanner needed too much time for this, so we better stop the motor */ gl841_stop_action (dev); - DBG (DBG_error, - "gl841_feed: timeout while waiting for scanhead to go home\n"); + DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); return SANE_STATUS_IO_ERROR; } @@ -3981,13 +3843,12 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) uint8_t val; int loop = 0; - DBG (DBG_proc, "gl841_slow_back_home (wait_until_home = %d)\n", - wait_until_home); + DBG(DBG_proc, "%s (wait_until_home = %d)\n", __func__, wait_until_home); if (dev->model->is_sheetfed == SANE_TRUE) { - DBG (DBG_proc, "gl841_slow_back_home: there is no \"home\"-concept for sheet fed\n"); - DBG (DBG_proc, "gl841_slow_back_home: finished\n"); + DBG(DBG_proc, "%s: there is no \"home\"-concept for sheet fed\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -4010,9 +3871,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io) @@ -4025,9 +3884,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io) @@ -4039,8 +3896,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) if (val & REG41_HOMESNR) /* is sensor at home? */ { - DBG (DBG_info, - "gl841_slow_back_home: already at home, completed\n"); + DBG(DBG_info, "%s: already at home, completed\n", __func__); dev->scanhead_position_in_steps = 0; return SANE_STATUS_GOOD; } @@ -4056,9 +3912,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl841_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_slow_back_home: failed to stop motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop motor: %s\n", __func__, sane_strstatus(status)); return SANE_STATUS_IO_ERROR; } } @@ -4078,9 +3932,7 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl841_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_slow_back_home: failed to start motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl841_stop_action (dev); /* send original registers */ gl841_bulk_write_register (dev, dev->reg, GENESYS_GL841_MAX_REGS); @@ -4094,16 +3946,15 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, + sane_strstatus(status)); return status; } if (val & REG41_HOMESNR) /* home sensor */ { - DBG (DBG_info, "gl841_slow_back_home: reached home position\n"); - DBG (DBG_proc, "gl841_slow_back_home: finished\n"); + DBG(DBG_info, "%s: reached home position\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } usleep (100000); /* sleep 100 ms */ @@ -4112,13 +3963,12 @@ gl841_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* when we come here then the scanner needed too much time for this, so we better stop the motor */ gl841_stop_action (dev); - DBG (DBG_error, - "gl841_slow_back_home: timeout while waiting for scanhead to go home\n"); + DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); return SANE_STATUS_IO_ERROR; } - DBG (DBG_info, "gl841_slow_back_home: scanhead is still moving\n"); - DBG (DBG_proc, "gl841_slow_back_home: finished\n"); + DBG(DBG_info, "%s: scanhead is still moving\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -4160,8 +4010,7 @@ gl841_search_start_position (Genesys_Device * dev) SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE); if(status!=SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to init scan registers: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to init scan registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4170,8 +4019,7 @@ gl841_search_start_position (Genesys_Device * dev) gl841_bulk_write_register (dev, local_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4180,8 +4028,7 @@ gl841_search_start_position (Genesys_Device * dev) data = malloc (size); if (!data) { - DBG (DBG_error, - "gl841_search_start_position: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -4189,9 +4036,7 @@ gl841_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl841_search_start_position: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4205,9 +4050,7 @@ gl841_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl841_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4219,9 +4062,7 @@ gl841_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl841_search_start_position: failed to end scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4236,9 +4077,8 @@ gl841_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl841_search_start_position: failed to set search reference point: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set search reference point: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -4284,23 +4124,18 @@ gl841_init_regs_for_coarse_calibration (Genesys_Device * dev) ); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_init_register_for_coarse_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, - "gl841_init_register_for_coarse_calibration: optical sensor res: %d dpi, actual res: %d\n", - dev->sensor.optical_res / cksel, dev->settings.xres); + DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, + dev->sensor.optical_res / cksel, dev->settings.xres); status = gl841_bulk_write_register (dev, dev->calib_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_init_register_for_coarse_calibration: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4322,7 +4157,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev) float starty=0; DBGSTART; - DBG (DBG_proc, "%s: lines = %d\n", __func__, (int)(dev->calib_lines)); + DBG(DBG_proc, "%s: lines = %d\n", __func__, (int)(dev->calib_lines)); /* initial calibration reg values */ memcpy (dev->calib_reg, dev->reg, GENESYS_GL841_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -4368,7 +4203,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4378,8 +4213,7 @@ gl841_init_regs_for_shading (Genesys_Device * dev) status = gl841_bulk_write_register (dev, dev->calib_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4401,11 +4235,10 @@ gl841_init_regs_for_scan (Genesys_Device * dev) SANE_Status status; - DBG (DBG_info, - "gl841_init_regs_for_scan settings:\nResolution: %uDPI\n" - "Lines : %u\nPPL : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", - dev->settings.yres, dev->settings.lines, dev->settings.pixels, - dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); + DBG(DBG_info, "%s:\nResolution: %uDPI\n" + "Lines : %u\nPPL : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", __func__, + dev->settings.yres, dev->settings.lines, dev->settings.pixels, dev->settings.tl_x, + dev->settings.tl_y, dev->settings.scan_mode); gl841_slow_back_home(dev,SANE_TRUE); @@ -4448,13 +4281,13 @@ gl841_init_regs_for_scan (Genesys_Device * dev) move += SANE_UNFIX (dev->model->y_offset_calib); } - DBG (DBG_info, "gl841_init_regs_for_scan: move=%f steps\n", move); + DBG(DBG_info, "%s move=%f steps\n", __func__, move); move += SANE_UNFIX (dev->model->y_offset); - DBG (DBG_info, "gl841_init_regs_for_scan: move=%f steps\n", move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); move += dev->settings.tl_y; - DBG (DBG_info, "gl841_init_regs_for_scan: move=%f steps\n", move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); move = (move * move_dpi) / MM_PER_INCH; @@ -4478,7 +4311,7 @@ gl841_init_regs_for_scan (Genesys_Device * dev) && dev->model->ccd_type != CIS_CANONLIDE80) { // on Lide 80 the LEDADD bit results in only red LED array being lit - DBG (DBG_io, "%s: activating LEDADD\n", __func__); + DBG(DBG_io, "%s: activating LEDADD\n", __func__); flags |= SCAN_FLAG_ENABLE_LEDADD; } @@ -4506,7 +4339,7 @@ gl841_init_regs_for_scan (Genesys_Device * dev) return status; - DBG (DBG_proc, "gl841_init_register_for_scan: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -4539,9 +4372,7 @@ gl841_send_gamma_table (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (gamma); - DBG (DBG_error, - "gl841_send_gamma_table: failed to set buffer address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4550,9 +4381,7 @@ gl841_send_gamma_table (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (gamma); - DBG (DBG_error, - "gl841_send_gamma_table: failed to send gamma table: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send gamma table: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4597,12 +4426,11 @@ gl841_led_calibration (Genesys_Device * dev) { move = SANE_UNFIX (dev->model->y_offset_calib); move = (move * (dev->motor.base_ydpi)) / MM_PER_INCH; - DBG (DBG_io, "%s: move=%d lines\n", __func__, move); + DBG(DBG_io, "%s: move=%d lines\n", __func__, move); status = gl841_feed(dev, move); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to feed: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to feed: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -4630,9 +4458,7 @@ gl841_led_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to setup scan: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4681,7 +4507,7 @@ gl841_led_calibration (Genesys_Device * dev) RIE (gl841_bulk_write_register (dev, dev->calib_reg, GENESYS_GL841_MAX_REGS)); - DBG (DBG_info, "%s: starting line reading\n", __func__); + DBG(DBG_info, "%s: starting line reading\n", __func__); RIE (gl841_begin_scan (dev, dev->calib_reg, SANE_TRUE)); RIE (sanei_genesys_read_data_from_scanner (dev, line, total_size)); @@ -4785,7 +4611,7 @@ gl841_led_calibration (Genesys_Device * dev) } while (!acceptable && turn < 100); - DBG(DBG_info,"%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0],exp[1],exp[2]); + DBG(DBG_info,"%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0], exp[1], exp[2]); /* cleanup before return */ free (line); @@ -4846,9 +4672,7 @@ ad_fe_offset_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_offset_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4878,7 +4702,7 @@ ad_fe_offset_calibration (Genesys_Device * dev) dev->frontend.offset[2] = (top+bottom)/2; /* scan line */ - DBG (DBG_info, "%s: starting line reading\n",__func__); + DBG(DBG_info, "%s: starting line reading\n", __func__); gl841_bulk_write_register (dev, dev->calib_reg, GENESYS_GL841_MAX_REGS); gl841_set_fe(dev, AFE_SET); gl841_begin_scan (dev, dev->calib_reg, SANE_TRUE); @@ -4896,7 +4720,7 @@ ad_fe_offset_calibration (Genesys_Device * dev) average+=line[i]; } average/=total_size; - DBG (DBG_data, "%s: average=%d\n", __func__, average); + DBG(DBG_data, "%s: average=%d\n", __func__, average); /* if min value is above target, the current value becomes the new top * else it is the new bottom */ @@ -4915,10 +4739,8 @@ ad_fe_offset_calibration (Genesys_Device * dev) dev->frontend.offset[1]=0; dev->frontend.offset[2]=0; free(line); - DBG (DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, - dev->frontend.offset[0], - dev->frontend.offset[1], - dev->frontend.offset[2]); + DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0], + dev->frontend.offset[1], dev->frontend.offset[2]); DBGCOMPLETED; return status; } @@ -4948,7 +4770,7 @@ gl841_offset_calibration (Genesys_Device * dev) SANE_Bool acceptable = SANE_FALSE; int mintgt = 0x400; - DBG (DBG_proc, "gl841_offset_calibration\n"); + DBG(DBG_proc, "%s\n", __func__); /* Analog Device fronted have a different calibration */ if ((dev->reg[reg_0x04].value & REG04_FESET) == 0x02) @@ -4980,9 +4802,7 @@ gl841_offset_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_offset_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -5045,14 +4865,11 @@ gl841_offset_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_offset_calibration: failed to setup frontend: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup frontend: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, - "gl841_offset_calibration: starting first line reading\n"); + DBG(DBG_info, "%s: starting first line reading\n", __func__); RIEF2 (gl841_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, first_line, total_size), first_line, second_line); @@ -5110,9 +4927,8 @@ gl841_offset_calibration (Genesys_Device * dev) } } - DBG(DBG_info,"gl841_offset_calibration: black/white pixels: " - "%d/%d,%d/%d,%d/%d\n", - cmin[0],cmax[0],cmin[1],cmax[1],cmin[2],cmax[2]); + DBG(DBG_info,"%s: black/white pixels: %d/%d,%d/%d,%d/%d\n", __func__, cmin[0], cmax[0], + cmin[1], cmax[1], cmin[2], cmax[2]); if (dev->model->is_cis) { offh[2] = offh[1] = offh[0]; @@ -5124,8 +4940,7 @@ gl841_offset_calibration (Genesys_Device * dev) turn++; } while (!acceptable && turn < 100); - DBG(DBG_info,"gl841_offset_calibration: acceptable offsets: %d,%d,%d\n", - off[0],off[1],off[2]); + DBG(DBG_info,"%s: acceptable offsets: %d,%d,%d\n", __func__, off[0], off[1], off[2]); for (j = 0; j < channels; j++) @@ -5168,14 +4983,11 @@ gl841_offset_calibration (Genesys_Device * dev) { free (first_line); free (second_line); - DBG (DBG_error, - "gl841_offset_calibration: failed to setup frontend: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup frontend: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, - "gl841_offset_calibration: starting second line reading\n"); + DBG(DBG_info, "%s: starting second line reading\n", __func__); RIEF2 (gl841_bulk_write_register (dev, dev->calib_reg, GENESYS_GL841_MAX_REGS), first_line, second_line); RIEF2 (gl841_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); @@ -5229,9 +5041,8 @@ gl841_offset_calibration (Genesys_Device * dev) } } - DBG(DBG_info,"gl841_offset_calibration: black/white pixels: " - "%d/%d,%d/%d,%d/%d\n", - cmin[0],cmax[0],cmin[1],cmax[1],cmin[2],cmax[2]); + DBG(DBG_info, "%s: black/white pixels: %d/%d,%d/%d,%d/%d\n", __func__, cmin[0], cmax[0], + cmin[1], cmax[1], cmin[2], cmax[2]); if (dev->model->is_cis) { offh[2] = offh[1] = offh[0]; @@ -5244,8 +5055,7 @@ gl841_offset_calibration (Genesys_Device * dev) } while (!acceptable && turn < 100); - DBG(DBG_info,"gl841_offset_calibration: acceptable offsets: %d,%d,%d\n", - off[0],off[1],off[2]); + DBG(DBG_info, "%s: acceptable offsets: %d,%d,%d\n", __func__, off[0], off[1], off[2]); for (j = 0; j < channels; j++) @@ -5269,11 +5079,11 @@ gl841_offset_calibration (Genesys_Device * dev) } } - DBG(DBG_info,"gl841_offset_calibration: first set: %d/%d,%d/%d,%d/%d\n", - off1[0],min1[0],off1[1],min1[1],off1[2],min1[2]); + DBG(DBG_info, "%s: first set: %d/%d,%d/%d,%d/%d\n", __func__, off1[0], min1[0], off1[1], min1[1], + off1[2], min1[2]); - DBG(DBG_info,"gl841_offset_calibration: second set: %d/%d,%d/%d,%d/%d\n", - off2[0],min2[0],off2[1],min2[1],off2[2],min2[2]); + DBG(DBG_info, "%s: second set: %d/%d,%d/%d,%d/%d\n", __func__, off2[0], min2[0], off2[1], min2[1], + off2[2], min2[2]); /* calculate offset for each channel @@ -5297,7 +5107,7 @@ gl841_offset_calibration (Genesys_Device * dev) { if (min2[j]-min1[j] == 0) { /*TODO: try to avoid this*/ - DBG(DBG_warn,"gl841_offset_calibration: difference too small\n"); + DBG(DBG_warn, "%s: difference too small\n", __func__); if (mintgt * (off1[j] - off2[j]) + min1[j] * off2[j] - min2[j] * off1[j] >= 0) off[j] = 0x0000; else @@ -5311,8 +5121,7 @@ gl841_offset_calibration (Genesys_Device * dev) dev->frontend.offset[j] = off[j]; } - DBG(DBG_info,"gl841_offset_calibration: final offsets: %d,%d,%d\n", - off[0],off[1],off[2]); + DBG(DBG_info, "%s: final offsets: %d,%d,%d\n", __func__, off[0], off[1], off[2]); if (dev->model->is_cis) { if (off[0] < off[1]) @@ -5333,7 +5142,7 @@ gl841_offset_calibration (Genesys_Device * dev) /* cleanup before return */ free (first_line); free (second_line); - DBG (DBG_proc, "gl841_offset_calibration: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -5361,19 +5170,18 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi) int lines=1; int move; - DBG (DBG_proc, "%s: dpi=%d\n", __func__, dpi); + DBG(DBG_proc, "%s: dpi=%d\n", __func__, dpi); /* feed to white strip if needed */ if (dev->model->y_offset_calib>0) { move = SANE_UNFIX (dev->model->y_offset_calib); move = (move * (dev->motor.base_ydpi)) / MM_PER_INCH; - DBG (DBG_io, "%s: move=%d lines\n", __func__, move); + DBG(DBG_io, "%s: move=%d lines\n", __func__, move); status = gl841_feed(dev, move); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to feed: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to feed: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -5401,8 +5209,7 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -5462,8 +5269,8 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi) dev->frontend.gain[j] = gain[j]*12; } - DBG (DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, - j, max[j], gain[j],dev->frontend.gain[j]); + DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j], + dev->frontend.gain[j]); } for (j = 0; j < channels; j++) @@ -5503,10 +5310,8 @@ gl841_coarse_gain_calibration (Genesys_Device * dev, int dpi) } free (line); - DBG (DBG_info, "%s: gain=(%d,%d,%d)\n", __func__, - dev->frontend.gain[0], - dev->frontend.gain[1], - dev->frontend.gain[2]); + DBG(DBG_info, "%s: gain=(%d,%d,%d)\n", __func__, dev->frontend.gain[0], dev->frontend.gain[1], + dev->frontend.gain[2]); RIE (gl841_stop_action (dev)); @@ -5528,7 +5333,7 @@ gl841_init_regs_for_warmup (Genesys_Device * dev, int num_pixels = (int) (4 * 300); SANE_Status status = SANE_STATUS_GOOD; - DBG (DBG_proc, "sanei_gl841_warmup_lamp\n"); + DBG(DBG_proc, "%s\n", __func__); memcpy (local_reg, dev->reg, (GENESYS_GL841_MAX_REGS + 1) * sizeof (Genesys_Register_Set)); @@ -5560,9 +5365,7 @@ gl841_init_regs_for_warmup (Genesys_Device * dev, if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_init_regs_for_warmup: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -5587,21 +5390,19 @@ sanei_gl841_repark_head (Genesys_Device * dev) { SANE_Status status; - DBG (DBG_proc, "sanei_gl841_repark_head\n"); + DBG(DBG_proc, "%s\n", __func__); status = gl841_feed(dev,232); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_repark_head: failed to feed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to feed: %s\n", __func__, sane_strstatus(status)); return status; } /* toggle motor flag, put an huge step number and redo move backward */ status = gl841_slow_back_home (dev, SANE_TRUE); - DBG (DBG_proc, "gl841_park_head: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -5627,13 +5428,12 @@ gl841_is_compatible_calibration (Genesys_Device * dev, if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_is_compatible_calibration: failed to calculate current setup: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to calculate current setup: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_proc, "gl841_is_compatible_calibration: checking\n"); + DBG(DBG_proc, "%s: checking\n", __func__); if (dev->current_setup.half_ccd != cache->used_setup.half_ccd) return SANE_STATUS_UNSUPPORTED; @@ -5647,7 +5447,7 @@ gl841_is_compatible_calibration (Genesys_Device * dev, if ((time.tv_sec - cache->last_calibration > 30 * 60) && (dev->model->is_sheetfed == SANE_FALSE)) { - DBG (DBG_proc, "%s: expired entry, non compatible cache\n",__func__); + DBG(DBG_proc, "%s: expired entry, non compatible cache\n", __func__); return SANE_STATUS_UNSUPPORTED; } } @@ -5681,7 +5481,7 @@ gl841_init (Genesys_Device * dev) RIE (sanei_genesys_get_status (dev, &val)); if (val & REG41_PWRBIT) { - DBG (DBG_info, "gl841_init: already initialized\n"); + DBG(DBG_info, "%s: already initialized\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -5724,13 +5524,11 @@ gl841_init (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { if (status == SANE_STATUS_INVAL) - DBG (DBG_error0, - "Your scanner is locked. Please move the lock switch " - "to the unlocked position\n"); + DBG(DBG_error0, "Your scanner is locked. Please move the lock switch to the unlocked " + "position\n"); else - DBG (DBG_error, - "gl841_init: sanei_gl841_repark_head failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: sanei_gl841_repark_head failed: %s\n", __func__, + sane_strstatus(status)); return status; } } @@ -5745,8 +5543,7 @@ gl841_init (Genesys_Device * dev) dev->sensor.gamma_table[i] = (uint16_t *) malloc (2 * size); if (dev->sensor.gamma_table[i] == NULL) { - DBG (DBG_error, - "gl841_init: could not allocate memory for gamma table %d\n",i); + DBG(DBG_error,"%s: could not allocate memory for gamma table %d\n", __func__, i); return SANE_STATUS_NO_MEM; } sanei_genesys_create_gamma_table (dev->sensor.gamma_table[i], @@ -5761,9 +5558,8 @@ gl841_init (Genesys_Device * dev) status = gl841_send_gamma_table (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_init: failed to send initial gamma tables: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send initial gamma tables: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -5797,8 +5593,7 @@ gl841_init (Genesys_Device * dev) if (!line) return SANE_STATUS_NO_MEM; - DBG (DBG_info, - "gl841_init: starting dummy data reading\n"); + DBG(DBG_info, "%s: starting dummy data reading\n", __func__); RIEF (gl841_begin_scan (dev, dev->calib_reg, SANE_TRUE), line); sanei_usb_set_timeout(1000);/* 1 second*/ @@ -5885,8 +5680,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) uint8_t white_level=90; /**< default white level to detect white dots */ uint8_t black_level=60; /**< default black level to detect black dots */ - DBG (DBG_proc, "gl841_search_strip %s %s\n", black ? "black" : "white", - forward ? "forward" : "reverse"); + DBG(DBG_proc, "%s %s %s\n", __func__, black ? "black" : "white", forward ? "forward" : "reverse"); /* use maximum gain when doing forward white strip detection * since we don't have calibrated the sensor yet */ @@ -5901,9 +5695,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) status = gl841_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_search_strip: failed to stop: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop: %s\n", __func__, sane_strstatus(status)); return status; } @@ -5926,7 +5718,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) data = malloc (size); if (!data) { - DBG (DBG_error, "gl841_search_strip: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -5953,8 +5745,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free(data); - DBG (DBG_error, "%s: failed to setup for scan: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup for scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -5970,9 +5761,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free(data); - DBG (DBG_error, - "gl841_search_strip: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -5980,9 +5769,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl841_search_strip: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -5996,9 +5783,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl841_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -6006,7 +5791,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, "gl841_search_strip: gl841_stop_action failed\n"); + DBG(DBG_error, "%s: gl841_stop_action failed\n", __func__); return status; } @@ -6027,9 +5812,8 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) gl841_bulk_write_register (dev, local_reg, GENESYS_GL841_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl841_search_strip: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -6038,9 +5822,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl841_search_strip: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error,"%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -6054,9 +5836,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl841_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "g%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -6064,7 +5844,7 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, "gl841_search_strip: gl841_stop_action failed\n"); + DBG(DBG_error, "%s: gl841_stop_action failed\n", __func__); return status; } @@ -6106,15 +5886,13 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / pixels < 3) { found = 1; - DBG (DBG_data, - "gl841_search_strip: strip found forward during pass %d at line %d\n", - pass, y); + DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, + pass, y); } else { - DBG (DBG_data, - "gl841_search_strip: pixels=%d, count=%d (%d%%)\n", - pixels, count, (100 * count) / pixels); + DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, + (100 * count) / pixels); } } } @@ -6145,15 +5923,12 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / (pixels * lines) < 3) { found = 1; - DBG (DBG_data, - "gl841_search_strip: strip found backward during pass %d \n", - pass); + DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { - DBG (DBG_data, - "gl841_search_strip: pixels=%d, count=%d (%d%%)\n", pixels, - count, (100 * count) / pixels); + DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, + (100 * count) / pixels); } } pass++; @@ -6162,17 +5937,15 @@ gl841_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (found) { status = SANE_STATUS_GOOD; - DBG (DBG_info, "gl841_search_strip: %s strip found\n", - black ? "black" : "white"); + DBG(DBG_info, "%s: %s strip found\n", __func__, black ? "black" : "white"); } else { status = SANE_STATUS_UNSUPPORTED; - DBG (DBG_info, "gl841_search_strip: %s strip not found\n", - black ? "black" : "white"); + DBG(DBG_info, "%s: %s strip not found\n", __func__, black ? "black" : "white"); } - DBG (DBG_proc, "gl841_search_strip: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -6192,7 +5965,7 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) uint8_t *buffer,*ptr,*src; DBGSTART; - DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__func__,size); + DBG(DBG_io2, "%s: writing %d bytes of shading data\n", __func__, size); /* old method if no SHDAREA */ if((dev->reg[reg_0x01].value & REG01_SHDAREA) == 0) @@ -6201,8 +5974,8 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = sanei_genesys_set_buffer_address (dev, 0x0000); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set buffer address: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -6210,8 +5983,8 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = dev->model->cmd_set->bulk_write_data (dev, 0x3c, data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading table: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send shading table: %s\n", __func__, + sane_strstatus(status)); return status; } DBGCOMPLETED; @@ -6222,14 +5995,16 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) length = (uint32_t) (size / 3); sanei_genesys_get_double(dev->reg,REG_STRPIXEL,&strpixel); sanei_genesys_get_double(dev->reg,REG_ENDPIXEL,&endpixel); - DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d\n",__func__,strpixel,endpixel,endpixel-strpixel); + DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d\n", __func__, strpixel, endpixel, + endpixel-strpixel); /* compute deletion/average factor */ sanei_genesys_get_double(dev->reg,REG_DPISET,&dpiset); dpihw = gl841_get_dpihw(dev); half=dev->current_setup.half_ccd+1; factor=dpihw/dpiset; - DBG( DBG_io2, "%s: dpihw=%d, dpiset=%d, half_ccd=%d, factor=%d\n",__func__,dpihw,dpiset,half-1,factor); + DBG(DBG_io2, "%s: dpihw=%d, dpiset=%d, half_ccd=%d, factor=%d\n", __func__, dpihw, dpiset, + half-1,factor); /* binary data logging */ if(DBG_LEVEL>=DBG_data) @@ -6255,9 +6030,10 @@ gl841_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) beginpixel += dev->sensor.dummy_pixel + 1; DBG(DBG_io2, "%s: ORIGIN PIXEL=%d\n", __func__, beginpixel); beginpixel = (strpixel-beginpixel*2*2)/factor; - DBG(DBG_io2, "%s: BEGIN PIXEL=%d\n",__func__,beginpixel/4); + DBG(DBG_io2, "%s: BEGIN PIXEL=%d\n", __func__, beginpixel/4); - DBG(DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n",__func__,length, length/4); + DBG(DBG_io2, "%s: using chunks of %d bytes (%d shading data pixels)\n", __func__, length, + length/4); buffer=(uint8_t *)malloc(pixels); memset(buffer,0,pixels); diff --git a/backend/genesys_gl843.c b/backend/genesys_gl843.c index 489e7c0e0..72d324417 100644 --- a/backend/genesys_gl843.c +++ b/backend/genesys_gl843.c @@ -67,16 +67,14 @@ gl843_bulk_write_data (Genesys_Device * dev, uint8_t addr, uint8_t outdata[8]; DBGSTART; - DBG (DBG_io, "gl843_bulk_write_data writing %lu bytes\n", (u_long) len); + DBG(DBG_io, "%s writing %lu bytes\n", __func__, (u_long) len); status = sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, INDEX, 1, &addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_bulk_write_data failed while setting register: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while setting register: %s\n", __func__, sane_strstatus(status)); return status; } @@ -102,24 +100,20 @@ gl843_bulk_write_data (Genesys_Device * dev, uint8_t addr, outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_bulk_write_data failed while writing command: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing command: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_usb_write_bulk (dev->dn, data, &size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_bulk_write_data failed while writing bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_io2, - "gl843_bulk_write_data: wrote %lu bytes, %lu remaining\n", - (u_long) size, (u_long) (len - size)); + DBG(DBG_io2, "%s: wrote %lu bytes, %lu remaining\n", __func__, (u_long) size, + (u_long) (len - size)); len -= size; data += size; @@ -135,28 +129,23 @@ gl843_set_buffer_address (Genesys_Device * dev, uint32_t addr) { SANE_Status status; - DBG (DBG_io, "gl843_set_buffer_address: setting address to 0x%05x\n", - addr & 0xffff); + DBG(DBG_io, "%s: setting address to 0x%05x\n", __func__, addr & 0xffff); status = sanei_genesys_write_register (dev, 0x5b, ((addr >> 8) & 0xff)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_set_buffer_address: failed while writing high byte: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing high byte: %s\n", __func__, sane_strstatus(status)); return status; } status = sanei_genesys_write_register (dev, 0x5c, (addr & 0xff)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_set_buffer_address: failed while writing low byte: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing low byte: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_io, "gl843_set_buffer_address: completed\n"); + DBG(DBG_io, "%s: completed\n", __func__); return status; } @@ -179,9 +168,8 @@ write_data (Genesys_Device * dev, uint32_t addr, uint32_t size, status = gl843_set_buffer_address (dev, addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "write_data: failed while setting address for bulk write data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while setting address for bulk write data: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -189,9 +177,8 @@ write_data (Genesys_Device * dev, uint32_t addr, uint32_t size, status = gl843_bulk_write_data (dev, 0x28, data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "write_data: failed while writing bulk write data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing bulk write data: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -199,9 +186,8 @@ write_data (Genesys_Device * dev, uint32_t addr, uint32_t size, status = gl843_set_buffer_address (dev, 0); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "write_data: failed setting to default RAM address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed setting to default RAM address: %s\n", __func__, + sane_strstatus(status)); return status; } DBGCOMPLETED; @@ -218,18 +204,14 @@ gl843_bulk_read_data (Genesys_Device * dev, uint8_t addr, uint8_t outdata[8]; DBGSTART; - DBG (DBG_io, - "gl843_bulk_read_data: requesting %lu bytes from 0x%02x addr\n", - (u_long) len, addr); + DBG(DBG_io, "%s: requesting %lu bytes from 0x%02x addr\n", __func__, (u_long) len, addr); status = sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, 0, 1, &addr); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "write_data: failed to set register address %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set register address %s\n", __func__, sane_strstatus(status)); return status; } @@ -250,9 +232,7 @@ gl843_bulk_read_data (Genesys_Device * dev, uint8_t addr, VALUE_BUFFER, INDEX, sizeof (outdata), outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_bulk_read_data failed while writing command: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing command: %s\n", __func__, sane_strstatus(status)); return status; } @@ -268,22 +248,18 @@ gl843_bulk_read_data (Genesys_Device * dev, uint8_t addr, size *= 512; } - DBG (DBG_io2, - "gl843_bulk_read_data: trying to read %lu bytes of data\n", - (u_long) size); + DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) size); status = sanei_usb_read_bulk (dev->dn, data, &size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_bulk_read_data failed while reading bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_io2, - "gl843_bulk_read_data read %lu bytes, %lu remaining\n", - (u_long) size, (u_long) (len - size)); + DBG(DBG_io2, "%s read %lu bytes, %lu remaining\n", __func__, (u_long) size, + (u_long) (len - size)); len -= size; data += size; @@ -376,7 +352,7 @@ gl843_get_step_multiplier (Genesys_Register_Set * regs) value = 1; } } - DBG (DBG_io, "%s: step multiplier is %d\n", __func__, value); + DBG(DBG_io, "%s: step multiplier is %d\n", __func__, value); return value; } @@ -452,7 +428,7 @@ static Sensor_Profile *get_sensor_profile(int sensor_type, int dpi, int flags) /* default fallback */ if(idx<0) { - DBG (DBG_warn,"%s: using default sensor profile\n",__func__); + DBG(DBG_warn,"%s: using default sensor profile\n", __func__); idx=0; } @@ -787,8 +763,7 @@ gl843_send_slope_table (Genesys_Device * dev, int table_nr, int i; char msg[10000]; - DBG (DBG_proc, "%s (table_nr = %d, steps = %d)\n", __func__, - table_nr, steps); + DBG(DBG_proc, "%s (table_nr = %d, steps = %d)\n", __func__, table_nr, steps); table = (uint8_t *) malloc (steps * 2); for (i = 0; i < steps; i++) @@ -804,7 +779,7 @@ gl843_send_slope_table (Genesys_Device * dev, int table_nr, { sprintf (msg+strlen(msg), "%d", slope_table[i]); } - DBG (DBG_io, "%s: %s\n", __func__, msg); + DBG(DBG_io, "%s: %s\n", __func__, msg); } @@ -813,9 +788,8 @@ gl843_send_slope_table (Genesys_Device * dev, int table_nr, status = write_data (dev, 0x4000 + 0x800 * table_nr, steps * 2, table); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: write data failed writing slope table %d (%s)\n", - __func__, table_nr, sane_strstatus (status)); + DBG(DBG_error, "%s: write data failed writing slope table %d (%s)\n", __func__, table_nr, + sane_strstatus(status)); } free (table); @@ -832,14 +806,12 @@ gl843_set_fe (Genesys_Device * dev, uint8_t set) uint8_t val; int i; - DBG (DBG_proc, "gl843_set_fe (%s)\n", - set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == - AFE_POWER_SAVE ? "powersave" : "huh?"); + DBG(DBG_proc, "%s (%s)\n", __func__, set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == + AFE_POWER_SAVE ? "powersave" : "huh?"); if (set == AFE_INIT) { - DBG (DBG_proc, "gl843_set_fe(): setting DAC %u\n", - dev->model->dac_type); + DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); sanei_genesys_init_fe (dev); } @@ -848,21 +820,19 @@ gl843_set_fe (Genesys_Device * dev, uint8_t set) if ((val & REG04_FESET) != 0x00) { /* for now there is no support for AD fe */ - DBG (DBG_proc, "gl843_set_fe(): unsupported frontend type %d\n", - dev->reg[reg_0x04].value & REG04_FESET); + DBG(DBG_proc, "%s(): unsupported frontend type %d\n", __func__, + dev->reg[reg_0x04].value & REG04_FESET); return SANE_STATUS_UNSUPPORTED; } - DBG (DBG_proc, "gl843_set_fe(): frontend reset complete\n"); + DBG(DBG_proc, "%s(): frontend reset complete\n", __func__); for (i = 1; i <= 3; i++) { status = sanei_genesys_fe_write_data (dev, i, dev->frontend.reg[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_set_fe: writing reg[%d] failed: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing reg[%d] failed: %s\n", __func__, i, sane_strstatus(status)); return status; } } @@ -873,9 +843,8 @@ gl843_set_fe (Genesys_Device * dev, uint8_t set) sanei_genesys_fe_write_data (dev, 0x20 + i, dev->frontend.offset[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_set_fe: writing offset[%d] failed: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing offset[%d] failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } } @@ -889,9 +858,8 @@ gl843_set_fe (Genesys_Device * dev, uint8_t set) dev->frontend.sign[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_set_fe: writing sign[%d] failed: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing sign[%d] failed: %s\n", __func__, i, + sane_strstatus(status)); return status; } } @@ -903,9 +871,7 @@ gl843_set_fe (Genesys_Device * dev, uint8_t set) sanei_genesys_fe_write_data (dev, 0x28 + i, dev->frontend.gain[i]); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_set_fe: writing gain[%d] failed: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: writing gain[%d] failed: %s\n", __func__, i, sane_strstatus(status)); return status; } } @@ -938,11 +904,9 @@ gl843_init_motor_regs_scan (Genesys_Device * dev, uint32_t z1, z2; DBGSTART; - DBG (DBG_info, "gl843_init_motor_regs_scan : exposure=%d, " - "scan_yres=%g, scan_step_type=%d, scan_lines=%d, scan_dummy=%d, " - "feed_steps=%d, scan_power_mode=%d, flags=%x\n", - exposure, scan_yres, scan_step_type, - scan_lines, scan_dummy, feed_steps, scan_power_mode, flags); + DBG(DBG_info, "%s : exposure=%d, scan_yres=%g, scan_step_type=%d, scan_lines=%d, scan_dummy=%d, " + "feed_steps=%d, scan_power_mode=%d, flags=%x\n", __func__, exposure, scan_yres, + scan_step_type, scan_lines, scan_dummy, feed_steps, scan_power_mode, flags); /* get step multiplier */ factor = gl843_get_step_multiplier (reg); @@ -954,7 +918,7 @@ gl843_init_motor_regs_scan (Genesys_Device * dev, lincnt=scan_lines; sanei_genesys_set_triple(reg,REG_LINCNT,lincnt); - DBG (DBG_io, "%s: lincnt=%d\n", __func__, lincnt); + DBG(DBG_io, "%s: lincnt=%d\n", __func__, lincnt); /* compute register 02 value */ r = sanei_genesys_get_address (reg, REG02); @@ -1033,7 +997,7 @@ gl843_init_motor_regs_scan (Genesys_Device * dev, { dist += fast_steps*2; } - DBG (DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); + DBG(DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); /* get sure when don't insane value : XXX STEF XXX in this case we should * fall back to single table move */ @@ -1043,7 +1007,7 @@ gl843_init_motor_regs_scan (Genesys_Device * dev, feedl = 1; sanei_genesys_set_triple(reg,REG_FEEDL,feedl); - DBG (DBG_io, "%s: feedl=%d\n", __func__, feedl); + DBG(DBG_io, "%s: feedl=%d\n", __func__, feedl); /* doesn't seem to matter that much */ sanei_genesys_calculate_zmode2 (use_fast_fed, @@ -1061,10 +1025,10 @@ gl843_init_motor_regs_scan (Genesys_Device * dev, } sanei_genesys_set_triple(reg,REG_Z1MOD,z1); - DBG (DBG_info, "gl843_init_motor_regs_scan: z1 = %d\n", z1); + DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); sanei_genesys_set_triple(reg,REG_Z2MOD,z2); - DBG (DBG_info, "gl843_init_motor_regs_scan: z2 = %d\n", z2); + DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); r = sanei_genesys_get_address (reg, REG1E); r->value &= 0xf0; /* 0 dummy lines */ @@ -1164,11 +1128,9 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, Genesys_Register_Set *r; SANE_Status status; - DBG (DBG_proc, "gl843_init_optical_regs_scan : exposure=%d, " - "used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " - "half_ccd=%d, flags=%x\n", - exposure, - used_res, start, pixels, channels, depth, half_ccd, flags); + DBG(DBG_proc, "%s : exposure=%d, used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " + "half_ccd=%d, flags=%x\n", __func__, exposure, used_res, start, pixels, channels, depth, + half_ccd, flags); /* tgtime */ tgtime=1; @@ -1176,13 +1138,13 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, { tgtime=2; } - DBG (DBG_io2, "%s: tgtime=%d\n", __func__, tgtime); + DBG(DBG_io2, "%s: tgtime=%d\n", __func__, tgtime); /* to manage high resolution device while keeping good * low resolution scanning speed, we make hardware dpi vary */ dpihw=sanei_genesys_compute_dpihw(dev, used_res); factor=dev->sensor.optical_res/dpihw; - DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); + DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); /* sensor parameters */ gl843_setup_sensor (dev, reg, dpihw, flags); @@ -1190,7 +1152,7 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, /* resolution is divided according to CKSEL which is known once sensor is set up */ r = sanei_genesys_get_address (reg, REG18); cksel= (r->value & REG18_CKSEL)+1; - DBG (DBG_io2, "%s: cksel=%d\n", __func__, cksel); + DBG(DBG_io2, "%s: cksel=%d\n", __func__, cksel); dpiset = used_res * cksel; /* start and end coordinate in optical dpi coordinates */ @@ -1215,8 +1177,7 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, status = gl843_set_fe (dev, AFE_SET); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set frontend: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1326,12 +1287,12 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, if(half_ccd) { sanei_genesys_set_double(reg,REG_DPISET,dpiset*4); - DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset*4); + DBG(DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset*4); } else { sanei_genesys_set_double(reg,REG_DPISET,dpiset); - DBG (DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset); + DBG(DBG_io2, "%s: dpiset used=%d\n", __func__, dpiset); } sanei_genesys_set_double(reg,REG_STRPIXEL,startx/tgtime); @@ -1352,22 +1313,22 @@ gl843_init_optical_regs_scan (Genesys_Device * dev, dev->wpl = words_per_line; dev->bpl = words_per_line; - DBG (DBG_io2, "%s: used_pixels=%d\n", __func__, used_pixels); - DBG (DBG_io2, "%s: pixels =%d\n", __func__, pixels); - DBG (DBG_io2, "%s: depth =%d\n", __func__, depth); - DBG (DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->bpl); - DBG (DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len); - DBG (DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist); + DBG(DBG_io2, "%s: used_pixels=%d\n", __func__, used_pixels); + DBG(DBG_io2, "%s: pixels =%d\n", __func__, pixels); + DBG(DBG_io2, "%s: depth =%d\n", __func__, depth); + DBG(DBG_io2, "%s: dev->bpl =%lu\n", __func__, (unsigned long) dev->bpl); + DBG(DBG_io2, "%s: dev->len =%lu\n", __func__, (unsigned long)dev->len); + DBG(DBG_io2, "%s: dev->dist =%lu\n", __func__, (unsigned long)dev->dist); words_per_line *= channels; /* MAXWD is expressed in 2 words unit */ /* nousedspace = (mem_bank_range * 1024 / 256 -1 ) * 4; */ sanei_genesys_set_triple(reg,REG_MAXWD,(words_per_line)>>1); - DBG (DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line); + DBG(DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line); sanei_genesys_set_double(reg,REG_LPERIOD,exposure/tgtime); - DBG (DBG_io2, "%s: exposure used=%d\n", __func__, exposure/tgtime); + DBG(DBG_io2, "%s: exposure used=%d\n", __func__, exposure/tgtime); r = sanei_genesys_get_address (reg, REG_DUMMY); r->value = dev->sensor.dummy_pixel * tgtime; @@ -1415,15 +1376,14 @@ gl843_init_scan_regs (Genesys_Device * dev, int optical_res; SANE_Status status; - DBG (DBG_info, - "gl843_init_scan_regs settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g/%g\n" - "Depth/Channels: %u/%u\n" - "Flags : %x\n\n", - xres, yres, lines, pixels, startx, starty, depth, channels, flags); + DBG(DBG_info, "%s:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g/%g\n" + "Depth/Channels: %u/%u\n" + "Flags : %x\n\n", + __func__, xres, yres, lines, pixels, startx, starty, depth, channels, flags); /* we have 2 domains for ccd: xres below or above half ccd max dpi */ @@ -1450,7 +1410,7 @@ gl843_init_scan_regs (Genesys_Device * dev, { stagger = (4 * yres) / dev->motor.base_ydpi; } - DBG (DBG_info, "%s : stagger=%d lines\n", __func__, stagger); + DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger); /* we enable true gray for cis scanners only, and just when doing * scan since color calibration is OK for this mode @@ -1492,7 +1452,7 @@ gl843_init_scan_regs (Genesys_Device * dev, /* compute correct pixels number */ used_pixels = (pixels * optical_res) / xres; - DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); + DBG(DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); /* round up pixels number if needed */ if (used_pixels * xres < pixels * optical_res) @@ -1525,8 +1485,8 @@ gl843_init_scan_regs (Genesys_Device * dev, scan_step_type = sanei_genesys_compute_step_type(gl843_motors, dev->model->motor_type, exposure); } - DBG (DBG_info, "%s : exposure=%d pixels\n", __func__, exposure); - DBG (DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type); + DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure); + DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type); /*** optical parameters ***/ /* in case of dynamic lineart, we use an internal 8 bit gray scan @@ -1582,7 +1542,7 @@ gl843_init_scan_regs (Genesys_Device * dev, /* add tl_y to base movement */ move = starty; - DBG (DBG_info, "gl843_init_scan_regs: move=%d steps\n", move); + DBG(DBG_info, "%s: move=%d steps\n", __func__, move); mflags=0; @@ -1639,14 +1599,12 @@ gl843_init_scan_regs (Genesys_Device * dev, dev->read_bytes_left = bytes_per_line * lincnt; - DBG (DBG_info, - "gl843_init_scan_regs: physical bytes to read = %lu\n", - (u_long) dev->read_bytes_left); + DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left); dev->read_active = SANE_TRUE; dev->current_setup.pixels = (used_pixels * used_res) / optical_res; - DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); + DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.depth = depth; dev->current_setup.channels = channels; @@ -1667,10 +1625,9 @@ gl843_init_scan_regs (Genesys_Device * dev, dev->total_bytes_to_read = dev->settings.pixels * dev->settings.lines * channels * (depth / 8); - DBG (DBG_info, "gl843_init_scan_regs: total bytes to send = %lu\n", - (u_long) dev->total_bytes_to_read); + DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read); - DBG (DBG_proc, "gl843_init_scan_regs: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -1699,16 +1656,15 @@ gl843_calculate_current_setup (Genesys_Device * dev) int optical_res; int oflags; - DBG (DBG_info, - "gl843_calculate_current_setup settings:\n" - "Resolution: %ux%uDPI\n" - "Lines : %u\n" - "PPL : %u\n" - "Startpos : %.3f/%.3f\n" - "Scan mode : %d\n\n", - dev->settings.xres, - dev->settings.yres, dev->settings.lines, dev->settings.pixels, - dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); + DBG(DBG_info, "%s settings:\n" + "Resolution: %ux%uDPI\n" + "Lines : %u\n" + "PPL : %u\n" + "Startpos : %.3f/%.3f\n" + "Scan mode : %d\n\n", __func__, + dev->settings.xres, + dev->settings.yres, dev->settings.lines, dev->settings.pixels, + dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); /* channels */ if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */ @@ -1739,14 +1695,13 @@ gl843_calculate_current_setup (Genesys_Device * dev) pixels = dev->settings.pixels; lines = dev->settings.lines; - DBG (DBG_info, - "gl843_calculate_current_setup settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g\n" - "Depth/Channels: %u/%u\n\n", - xres, yres, lines, pixels, startx, depth, channels); + DBG(DBG_info, "%s settings:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g\n" + "Depth/Channels: %u/%u\n\n", + __func__, xres, yres, lines, pixels, startx, depth, channels); /* half_ccd */ /* we have 2 domains for ccd: xres below or above half ccd max dpi */ @@ -1771,7 +1726,7 @@ gl843_calculate_current_setup (Genesys_Device * dev) stagger = (4 * yres) / dev->motor.base_ydpi; else stagger = 0; - DBG (DBG_info, "%s: stagger=%d lines\n", __func__, stagger); + DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger); if(xres<=optical_res) used_res = xres; @@ -1784,11 +1739,11 @@ gl843_calculate_current_setup (Genesys_Device * dev) /* compute correct pixels number */ used_pixels = (pixels * optical_res) / xres; - DBG (DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); + DBG(DBG_info, "%s: used_pixels=%d\n", __func__, used_pixels); /* exposure */ exposure = gl843_compute_exposure (dev, used_res, oflags); - DBG (DBG_info, "%s : exposure=%d pixels\n", __func__, exposure); + DBG(DBG_info, "%s : exposure=%d pixels\n", __func__, exposure); /* it seems base_dpi of the G4050 motor is changed above 600 dpi*/ if (dev->model->motor_type == MOTOR_G4050 && yres>600) @@ -1811,7 +1766,7 @@ gl843_calculate_current_setup (Genesys_Device * dev) lincnt = lines + max_shift + stagger; dev->current_setup.pixels = (used_pixels * used_res) / optical_res; - DBG (DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); + DBG(DBG_info, "%s: current_setup.pixels=%d\n", __func__, dev->current_setup.pixels); dev->current_setup.lines = lincnt; dev->current_setup.depth = depth; dev->current_setup.channels = channels; @@ -1822,7 +1777,7 @@ gl843_calculate_current_setup (Genesys_Device * dev) dev->current_setup.stagger = stagger; dev->current_setup.max_shift = max_shift + stagger; - DBG (DBG_proc, "gl843_calculate_current_setup: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -1830,7 +1785,7 @@ static void gl843_set_motor_power (Genesys_Register_Set * regs, SANE_Bool set) { - DBG (DBG_proc, "gl843_set_motor_power\n"); + DBG(DBG_proc, "%s\n", __func__); if (set) { @@ -1890,7 +1845,7 @@ gl843_save_power (Genesys_Device * dev, SANE_Bool enable) uint8_t val; SANE_Status status; - DBG (DBG_proc, "gl843_save_power: enable = %d\n", enable); + DBG(DBG_proc, "%s: enable = %d\n", __func__, enable); if (dev == NULL) return SANE_STATUS_INVAL; @@ -1914,7 +1869,7 @@ gl843_set_powersaving (Genesys_Device * dev, int delay /* in minutes */ ) { SANE_Status status = SANE_STATUS_GOOD; - DBG (DBG_proc, "gl843_set_powersaving (delay = %d)\n", delay); + DBG(DBG_proc, "%s (delay = %d)\n", __func__, delay); if (dev == NULL) return SANE_STATUS_INVAL; @@ -1935,7 +1890,7 @@ gl843_stop_action (Genesys_Device * dev) uint8_t val40, val; unsigned int loop; - DBG (DBG_proc, "%s\n", __func__); + DBG(DBG_proc, "%s\n", __func__); status = sanei_genesys_get_status (dev, &val); if (DBG_LEVEL >= DBG_io) @@ -1947,18 +1902,16 @@ gl843_stop_action (Genesys_Device * dev) status = sanei_genesys_read_register (dev, REG40, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __func__, - sane_strstatus (status)); - DBG (DBG_proc, "%s: completed\n", __func__); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } /* only stop action if needed */ if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG)) { - DBG (DBG_info, "%s: already stopped\n", __func__); - DBG (DBG_proc, "%s: completed\n", __func__); + DBG(DBG_info, "%s: already stopped\n", __func__); + DBG(DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } @@ -1969,8 +1922,7 @@ gl843_stop_action (Genesys_Device * dev) status = sanei_genesys_write_register (dev, REG01, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to write register 01: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write register 01: %s\n", __func__, sane_strstatus(status)); return status; } usleep (100 * 1000); @@ -1987,9 +1939,7 @@ gl843_stop_action (Genesys_Device * dev) status = sanei_genesys_read_register (dev, 0x40, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2019,9 +1969,7 @@ gl843_get_paper_sensor (Genesys_Device * dev, SANE_Bool * paper_loaded) status = sanei_genesys_read_register (dev, REG6D, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_get_paper_sensor: failed to read gpio: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read gpio: %s\n", __func__, sane_strstatus(status)); return status; } *paper_loaded = (val & 0x1) == 0; @@ -2033,7 +1981,7 @@ gl843_get_paper_sensor (Genesys_Device * dev, SANE_Bool * paper_loaded) static SANE_Status gl843_eject_document (Genesys_Device * dev) { - DBG (DBG_proc, "%s: not implemented \n", __func__); + DBG(DBG_proc, "%s: not implemented \n", __func__); if (dev == NULL) return SANE_STATUS_INVAL; return SANE_STATUS_GOOD; @@ -2043,7 +1991,7 @@ gl843_eject_document (Genesys_Device * dev) static SANE_Status gl843_load_document (Genesys_Device * dev) { - DBG (DBG_proc, "%s: not implemented \n", __func__); + DBG(DBG_proc, "%s: not implemented \n", __func__); if (dev == NULL) return SANE_STATUS_INVAL; return SANE_STATUS_GOOD; @@ -2062,21 +2010,20 @@ gl843_detect_document_end (Genesys_Device * dev) unsigned int scancnt = 0; int flines, channels, depth, bytes_remain, sublines, bytes_to_flush, lines, sub_bytes, tmp, read_bytes_left; - DBG (DBG_proc, "%s: begin\n", __func__); + DBG(DBG_proc, "%s: begin\n", __func__); RIE (gl843_get_paper_sensor (dev, &paper_loaded)); /* sheetfed scanner uses home sensor as paper present */ if ((dev->document == SANE_TRUE) && !paper_loaded) { - DBG (DBG_info, "%s: no more document\n", __func__); + DBG(DBG_info, "%s: no more document\n", __func__); dev->document = SANE_FALSE; channels = dev->current_setup.channels; depth = dev->current_setup.depth; read_bytes_left = (int) dev->read_bytes_left; - DBG (DBG_io, "gl843_detect_document_end: read_bytes_left=%d\n", - read_bytes_left); + DBG(DBG_io, "%s: read_bytes_left=%d\n", __func__, read_bytes_left); /* get lines read */ status = sanei_genesys_read_scancnt (dev, &scancnt); @@ -2096,9 +2043,7 @@ gl843_detect_document_end (Genesys_Device * dev) /* number of scanned lines, but no read yet */ flines = scancnt - flines; - DBG (DBG_io, - "gl843_detect_document_end: %d scanned but not read lines\n", - flines); + DBG(DBG_io, "%s: %d scanned but not read lines\n", __func__, flines); } /* adjust number of bytes to read @@ -2107,8 +2052,7 @@ gl843_detect_document_end (Genesys_Device * dev) lines = (SANE_UNFIX (dev->model->post_scan) * dev->current_setup.yres) / MM_PER_INCH + flines; - DBG (DBG_io, "gl843_detect_document_end: adding %d line to flush\n", - lines); + DBG(DBG_io, "%s: adding %d line to flush\n", __func__, lines); /* number of bytes to read from scanner to get document out of it after * end of document dectected by hardware sensor */ @@ -2119,13 +2063,11 @@ gl843_detect_document_end (Genesys_Device * dev) { /* we take all these step to work around an overflow on some plateforms */ tmp = (int) dev->total_bytes_read; - DBG (DBG_io, "gl843_detect_document_end: tmp=%d\n", tmp); + DBG (DBG_io, "%s: tmp=%d\n", __func__, tmp); bytes_remain = (int) dev->total_bytes_to_read; - DBG (DBG_io, "gl843_detect_document_end: bytes_remain=%d\n", - bytes_remain); + DBG(DBG_io, "%s: bytes_remain=%d\n", __func__, bytes_remain); bytes_remain = bytes_remain - tmp; - DBG (DBG_io, "gl843_detect_document_end: bytes_remain=%d\n", - bytes_remain); + DBG(DBG_io, "%s: bytes_remain=%d\n", __func__, bytes_remain); /* remaining lines to read by frontend for the current scan */ if (depth == 1 || dev->settings.scan_mode == SCAN_MODE_LINEART) @@ -2135,7 +2077,7 @@ gl843_detect_document_end (Genesys_Device * dev) else flines = bytes_remain / (depth / 8) / dev->settings.pixels / channels; - DBG (DBG_io, "gl843_detect_document_end: flines=%d\n", flines); + DBG(DBG_io, "%s: flines=%d\n", __func__, flines); if (flines > lines) { @@ -2166,25 +2108,20 @@ gl843_detect_document_end (Genesys_Device * dev) dev->read_bytes_left = 0; } - DBG (DBG_io, "gl843_detect_document_end: sublines=%d\n", - sublines); - DBG (DBG_io, "gl843_detect_document_end: subbytes=%d\n", - sub_bytes); - DBG (DBG_io, - "gl843_detect_document_end: total_bytes_to_read=%lu\n", - (unsigned long) dev->total_bytes_to_read); - DBG (DBG_io, - "gl843_detect_document_end: read_bytes_left=%d\n", - read_bytes_left); + DBG(DBG_io, "%s: sublines=%d\n", __func__, sublines); + DBG(DBG_io, "%s: subbytes=%d\n", __func__, sub_bytes); + DBG(DBG_io, "%s: total_bytes_to_read=%lu\n", __func__, + (unsigned long) dev->total_bytes_to_read); + DBG(DBG_io, "%s: read_bytes_left=%d\n", __func__, read_bytes_left); } } else { - DBG (DBG_io, "gl843_detect_document_end: no flushing needed\n"); + DBG(DBG_io, "%s: no flushing needed\n", __func__); } } - DBG (DBG_proc, "%s: finished\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -2383,7 +2320,7 @@ gl843_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, SANE_Status status; uint8_t val; - DBG (DBG_proc, "gl843_end_scan (check_stop = %d)\n", check_stop); + DBG(DBG_proc, "%s (check_stop = %d)\n", __func__, check_stop); if (reg == NULL) return SANE_STATUS_INVAL; @@ -2414,9 +2351,7 @@ gl843_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, status = gl843_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_end_scan: failed to stop: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -2459,7 +2394,7 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev) status = gl843_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to start motor: %s\n",__func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl843_stop_action (dev); /* restore original registers */ dev->model->cmd_set->bulk_write_register (dev, dev->reg, GENESYS_GL843_MAX_REGS); @@ -2471,9 +2406,8 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read home sensor: %s\n",__func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, + sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io2) @@ -2483,8 +2417,8 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev) if (val & REG41_HOMESNR) /* home sensor */ { - DBG (DBG_info, "%s: reached home position\n",__func__); - DBG (DBG_proc, "%s: finished\n",__func__); + DBG(DBG_info, "%s: reached home position\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); /* clear GPOADF to avoid reparking again */ sanei_genesys_read_register (dev, REG6B, &val); @@ -2500,7 +2434,7 @@ static SANE_Status gl843_park_xpa_lamp (Genesys_Device * dev) } /* we are not parked here.... should we fail ? */ - DBG (DBG_info, "%s: XPA lamp is not parked\n", __func__); + DBG(DBG_info, "%s: XPA lamp is not parked\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -2517,8 +2451,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) float resolution; int loop = 0; - DBG (DBG_proc, "gl843_slow_back_home (wait_until_home = %d)\n", - wait_until_home); + DBG(DBG_proc, "%s (wait_until_home = %d)\n", __func__, wait_until_home); if (dev->model->gpo_type == GPO_G4050) { @@ -2537,7 +2470,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } usleep (100000); /* sleep 100 ms */ @@ -2546,9 +2479,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io) @@ -2582,9 +2513,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_slow_back_home: failed to set up registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2603,9 +2532,7 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl843_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_slow_back_home: failed to start motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl843_stop_action (dev); /* restore original registers */ dev->model->cmd_set->bulk_write_register (dev, dev->reg, GENESYS_GL843_MAX_REGS); @@ -2620,9 +2547,8 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, + sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io2) @@ -2632,8 +2558,8 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) if (val & REG41_HOMESNR) /* home sensor */ { - DBG (DBG_info, "gl843_slow_back_home: reached home position\n"); - DBG (DBG_proc, "gl843_slow_back_home: finished\n"); + DBG(DBG_info, "%s: reached home position\n", __func__); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } usleep (100000); /* sleep 100 ms */ @@ -2642,12 +2568,11 @@ gl843_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* when we come here then the scanner needed too much time for this, so we better stop the motor */ gl843_stop_action (dev); - DBG (DBG_error, - "gl843_slow_back_home: timeout while waiting for scanhead to go home\n"); + DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); return SANE_STATUS_IO_ERROR; } - DBG (DBG_info, "%s: scanhead is still moving\n", __func__); + DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -2666,7 +2591,7 @@ gl843_search_start_position (Genesys_Device * dev) int pixels = 600; int dpi = 300; - DBG (DBG_proc, "gl843_search_start_position\n"); + DBG(DBG_proc, "%s\n", __func__); memcpy (local_reg, dev->reg, GENESYS_GL843_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -2691,9 +2616,7 @@ gl843_search_start_position (Genesys_Device * dev) SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_search_start_position: failed to bulk setup registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk setup registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2701,9 +2624,7 @@ gl843_search_start_position (Genesys_Device * dev) status = dev->model->cmd_set->bulk_write_register (dev, local_reg, GENESYS_GL843_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_search_start_position: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2712,8 +2633,7 @@ gl843_search_start_position (Genesys_Device * dev) data = malloc (size); if (!data) { - DBG (DBG_error, - "gl843_search_start_position: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2721,9 +2641,7 @@ gl843_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl843_search_start_position: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2737,9 +2655,7 @@ gl843_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl843_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2751,9 +2667,7 @@ gl843_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl843_search_start_position: failed to end scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2766,9 +2680,8 @@ gl843_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl843_search_start_position: failed to set search reference point: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set search reference point: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -2814,23 +2727,18 @@ gl843_init_regs_for_coarse_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_init_register_for_coarse_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } gl843_set_motor_power (dev->calib_reg, SANE_FALSE); - DBG (DBG_info, - "gl843_init_register_for_coarse_calibration: optical sensor res: %d dpi, actual res: %d\n", - dev->sensor.optical_res / cksel, dev->settings.xres); + DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, + dev->sensor.optical_res / cksel, dev->settings.xres); status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL843_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_init_register_for_coarse_calibration: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2875,9 +2783,7 @@ gl843_feed (Genesys_Device * dev, unsigned int steps) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_feed: failed to set up registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2896,7 +2802,7 @@ gl843_feed (Genesys_Device * dev, unsigned int steps) status = gl843_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl843_stop_action (dev); /* restore original registers */ @@ -2962,22 +2868,18 @@ gl843_init_regs_for_shading (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_init_registers_for_shading: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } dev->scanhead_position_in_steps += dev->calib_lines + move; sanei_genesys_get_double(dev->calib_reg,REG_STRPIXEL,&strpixel); - DBG (DBG_info, "%s: STRPIXEL=%d\n", __func__, strpixel); + DBG(DBG_info, "%s: STRPIXEL=%d\n", __func__, strpixel); status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL843_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_init_registers_for_shading: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2999,16 +2901,15 @@ gl843_init_regs_for_scan (Genesys_Device * dev) SANE_Status status; - DBG (DBG_info, - "gl843_init_regs_for_scan settings:\nResolution: %ux%uDPI\n" - "Lines : %u\npixels : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", - dev->settings.xres, - dev->settings.yres, - dev->settings.lines, - dev->settings.pixels, - dev->settings.tl_x, - dev->settings.tl_y, - dev->settings.scan_mode); + DBG(DBG_info, "%s settings:\nResolution: %ux%uDPI\n" + "Lines : %u\npixels : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", __func__, + dev->settings.xres, + dev->settings.yres, + dev->settings.lines, + dev->settings.pixels, + dev->settings.tl_x, + dev->settings.tl_y, + dev->settings.scan_mode); /* ensure head is parked in case of calibration */ gl843_slow_back_home (dev, SANE_TRUE); @@ -3029,7 +2930,7 @@ gl843_init_regs_for_scan (Genesys_Device * dev) move = SANE_UNFIX (dev->model->y_offset); move += dev->settings.tl_y; move = (move * move_dpi) / MM_PER_INCH; - DBG (DBG_info, "gl843_init_regs_for_scan: move=%f steps\n", move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ start = SANE_UNFIX (dev->model->x_offset); @@ -3102,9 +3003,7 @@ gl843_send_gamma_table (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (gamma); - DBG (DBG_error, - "gl843_send_gamma_table: failed to set buffer address: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3113,13 +3012,11 @@ gl843_send_gamma_table (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (gamma); - DBG (DBG_error, - "gl843_send_gamma_table: failed to send gamma table: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send gamma table: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_proc, "gl843_send_gamma_table: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); free (gamma); return SANE_STATUS_GOOD; } @@ -3148,7 +3045,7 @@ gl843_led_calibration (Genesys_Device * dev) SANE_Bool acceptable = SANE_FALSE; - DBG (DBG_proc, "gl843_led_calibration\n"); + DBG(DBG_proc, "%s\n", __func__); /* offset calibration is always done in color mode */ channels = 3; @@ -3180,9 +3077,7 @@ gl843_led_calibration (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_led_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3229,7 +3124,7 @@ gl843_led_calibration (Genesys_Device * dev) RIE (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL843_MAX_REGS)); - DBG (DBG_info, "gl843_led_calibration: starting first line reading\n"); + DBG(DBG_info, "%s: starting first line reading\n", __func__); RIE (gl843_begin_scan (dev, dev->calib_reg, SANE_TRUE)); RIE (sanei_genesys_read_data_from_scanner (dev, line, total_size)); @@ -3261,8 +3156,7 @@ gl843_led_calibration (Genesys_Device * dev) avg[j] /= num_pixels; } - DBG (DBG_info, "gl843_led_calibration: average: " - "%d,%d,%d\n", avg[0], avg[1], avg[2]); + DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); acceptable = SANE_TRUE; @@ -3309,15 +3203,14 @@ gl843_led_calibration (Genesys_Device * dev) } while (!acceptable && turn < 100); - DBG (DBG_info, "gl843_led_calibration: acceptable exposure: %d,%d,%d\n", - expr, expg, expb); + DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, expr, expg, expb); /* cleanup before return */ free (line); gl843_slow_back_home (dev, SANE_TRUE); - DBG (DBG_proc, "gl843_led_calibration: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -3350,9 +3243,9 @@ dark_average_channel (uint8_t * data, unsigned int pixels, unsigned int lines, } if (count) avg[k] /= count; - DBG (DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); + DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } - DBG (DBG_info, "%s: average = %d\n", __func__, avg[channel]); + DBG(DBG_info, "%s: average = %d\n", __func__, avg[channel]); return avg[channel]; } @@ -3385,11 +3278,11 @@ gl843_offset_calibration (Genesys_Device * dev) resolution = dpihw; pixels = dev->sensor.sensor_pixels / factor; black_pixels = dev->sensor.black_pixels / factor; - DBG (DBG_io, "gl843_offset_calibration: dpihw =%d\n", dpihw); - DBG (DBG_io, "gl843_offset_calibration: factor =%d\n", factor); - DBG (DBG_io, "gl843_offset_calibration: resolution =%d\n", resolution); - DBG (DBG_io, "gl843_offset_calibration: pixels =%d\n", pixels); - DBG (DBG_io, "gl843_offset_calibration: black_pixels=%d\n", black_pixels); + DBG(DBG_io, "%s: dpihw =%d\n", __func__, dpihw); + DBG(DBG_io, "%s: factor =%d\n", __func__, factor); + DBG(DBG_io, "%s: resolution =%d\n", __func__, resolution); + DBG(DBG_io, "%s: pixels =%d\n", __func__, pixels); + DBG(DBG_io, "%s: black_pixels=%d\n", __func__, black_pixels); status = gl843_init_scan_regs (dev, dev->calib_reg, @@ -3409,8 +3302,7 @@ gl843_offset_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl843_offset_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } gl843_set_motor_power (dev->calib_reg, SANE_FALSE); @@ -3440,7 +3332,7 @@ gl843_offset_calibration (Genesys_Device * dev) /* scan with obttom AFE settings */ RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL843_MAX_REGS), first_line, second_line); - DBG (DBG_info, "gl843_offset_calibration: starting first line reading\n"); + DBG(DBG_info, "%s: starting first line reading\n", __func__); RIEF2 (gl843_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, first_line, total_size), first_line, second_line); if (DBG_LEVEL >= DBG_data) @@ -3455,7 +3347,7 @@ gl843_offset_calibration (Genesys_Device * dev) for (i = 0; i < 3; i++) { bottomavg[i] = dark_average_channel (first_line, pixels, lines, channels, black_pixels, i); - DBG (DBG_io2, "gl843_offset_calibration: bottom avg %d=%d\n", i, bottomavg[i]); + DBG(DBG_io2, "%s: bottom avg %d=%d\n", __func__, i, bottomavg[i]); } /* now top value */ @@ -3468,14 +3360,14 @@ gl843_offset_calibration (Genesys_Device * dev) /* scan with top AFE values */ RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL843_MAX_REGS), first_line, second_line); - DBG (DBG_info, "gl843_offset_calibration: starting second line reading\n"); + DBG(DBG_info, "%s: starting second line reading\n", __func__); RIEF2 (gl843_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size), first_line, second_line); for (i = 0; i < 3; i++) { topavg[i] = dark_average_channel (second_line, pixels, lines, channels, black_pixels, i); - DBG (DBG_io2, "gl843_offset_calibration: top avg %d=%d\n", i, topavg[i]); + DBG(DBG_io2, "%s: top avg %d=%d\n", __func__, i, topavg[i]); } pass = 0; @@ -3499,7 +3391,7 @@ gl843_offset_calibration (Genesys_Device * dev) /* scan with no move */ RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL843_MAX_REGS), first_line, second_line); - DBG (DBG_info, "gl843_offset_calibration: starting second line reading\n"); + DBG(DBG_info, "%s: starting second line reading\n", __func__); RIEF2 (gl843_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size), first_line, second_line); @@ -3515,7 +3407,7 @@ gl843_offset_calibration (Genesys_Device * dev) for (i = 0; i < 3; i++) { avg[i] = dark_average_channel (second_line, pixels, lines, channels, black_pixels, i); - DBG (DBG_info, "gl843_offset_calibration: avg[%d]=%d offset=%d\n", i, avg[i], dev->frontend.offset[i]); + DBG(DBG_info, "%s: avg[%d]=%d offset=%d\n", __func__, i, avg[i], dev->frontend.offset[i]); } /* compute new boundaries */ @@ -3533,10 +3425,8 @@ gl843_offset_calibration (Genesys_Device * dev) } } } - DBG (DBG_info, "gl843_offset_calibration: offset=(%d,%d,%d)\n", - dev->frontend.offset[0], - dev->frontend.offset[1], - dev->frontend.offset[2]); + DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0], + dev->frontend.offset[1], dev->frontend.offset[2]); /* cleanup before return */ free (first_line); @@ -3570,7 +3460,7 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, int dpi) int resolution; int bpp; - DBG (DBG_proc, "gl843_coarse_gain_calibration: dpi = %d\n", dpi); + DBG(DBG_proc, "%s: dpi = %d\n", __func__, dpi); dpihw=sanei_genesys_compute_dpihw(dev, dpi); factor=dev->sensor.optical_res/dpihw; @@ -3618,9 +3508,7 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_coarse_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3679,9 +3567,8 @@ gl843_coarse_gain_calibration (Genesys_Device * dev, int dpi) code = 0; dev->frontend.gain[j] = code; - DBG (DBG_proc, - "gl843_coarse_gain_calibration: channel %d, max=%d, gain = %f, setting:%d\n", - j, max[j], gain[j], dev->frontend.gain[j]); + DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j], + dev->frontend.gain[j]); } if (dev->model->is_cis) @@ -3756,7 +3643,7 @@ gl843_init_regs_for_warmup (Genesys_Device * dev, if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3841,9 +3728,7 @@ gl843_boot (Genesys_Device * dev, SANE_Bool cold) if (val & REG40_CHKVER) { RIE (sanei_genesys_read_register (dev, 0x00, &val)); - DBG (DBG_info, - "%s: reported version for genesys chip is 0x%02x\n", __func__, - val); + DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ @@ -3961,7 +3846,7 @@ gl843_move_to_ta (Genesys_Device * dev) status = gl843_feed (dev, feed); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to move to XPA calibration area\n", __func__); + DBG(DBG_error, "%s: failed to move to XPA calibration area\n", __func__); return status; } @@ -3992,16 +3877,13 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) char title[80]; Genesys_Register_Set *r; - DBG (DBG_proc, "gl843_search_strip %s %s\n", black ? "black" : "white", - forward ? "forward" : "reverse"); + DBG(DBG_proc, "%s %s %s\n", __func__, black ? "black" : "white", forward ? "forward" : "reverse"); gl843_set_fe (dev, AFE_SET); status = gl843_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_search_strip: failed to stop: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4019,7 +3901,7 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) data = malloc (size); if (!data) { - DBG (DBG_error, "gl843_search_strip: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } dev->scanhead_position_in_steps = 0; @@ -4044,9 +3926,7 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free(data); - DBG (DBG_error, - "gl843_search_strip: failed to setup for scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup for scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4062,9 +3942,7 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free(data); - DBG (DBG_error, - "gl843_search_strip: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4072,9 +3950,7 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl843_search_strip: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4088,9 +3964,7 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl843_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4098,7 +3972,7 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, "gl843_search_strip: gl843_stop_action failed\n"); + DBG(DBG_error, "%s: gl843_stop_action failed\n", __func__); return status; } @@ -4119,9 +3993,8 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) dev->model->cmd_set->bulk_write_register (dev, local_reg, GENESYS_GL843_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl843_search_strip: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -4130,9 +4003,7 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl843_search_strip: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4146,9 +4017,7 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl843_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -4156,7 +4025,7 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, "gl843_search_strip: gl843_stop_action failed\n"); + DBG(DBG_error, "%s: gl843_stop_action failed\n", __func__); return status; } @@ -4198,15 +4067,13 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / pixels < 3) { found = 1; - DBG (DBG_data, - "gl843_search_strip: strip found forward during pass %d at line %d\n", - pass, y); + DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, + pass, y); } else { - DBG (DBG_data, - "gl843_search_strip: pixels=%d, count=%d (%d%%)\n", - pixels, count, (100 * count) / pixels); + DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, + (100 * count) / pixels); } } } @@ -4237,15 +4104,12 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / (pixels * lines) < 3) { found = 1; - DBG (DBG_data, - "gl843_search_strip: strip found backward during pass %d \n", - pass); + DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { - DBG (DBG_data, - "gl843_search_strip: pixels=%d, count=%d (%d%%)\n", - pixels, count, (100 * count) / pixels); + DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, + (100 * count) / pixels); } } pass++; @@ -4254,17 +4118,15 @@ gl843_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (found) { status = SANE_STATUS_GOOD; - DBG (DBG_info, "gl843_search_strip: %s strip found\n", - black ? "black" : "white"); + DBG(DBG_info, "%s: %s strip found\n", __func__, black ? "black" : "white"); } else { status = SANE_STATUS_UNSUPPORTED; - DBG (DBG_info, "gl843_search_strip: %s strip not found\n", - black ? "black" : "white"); + DBG(DBG_info, "%s: %s strip not found\n", __func__, black ? "black" : "white"); } - DBG (DBG_proc, "gl843_search_strip: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -4317,16 +4179,17 @@ gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* 16 bit words, 2 words per color, 3 color channels */ offset=(strpixel-startx)*2*2*3; length=(endpixel-strpixel)*2*2*3; - DBG (DBG_info, "%s: STRPIXEL=%d, ENDPIXEL=%d, startx=%d\n", __func__, strpixel, endpixel, startx); + DBG(DBG_info, "%s: STRPIXEL=%d, ENDPIXEL=%d, startx=%d\n", __func__, strpixel, endpixel, + startx); } /* compute and allocate size for final data */ final_size = ((length+251) / 252) * 256; - DBG (DBG_io, "%s: final shading size=%04x (length=%d)\n", __func__, final_size, length); + DBG(DBG_io, "%s: final shading size=%04x (length=%d)\n", __func__, final_size, length); final_data = (uint8_t *) malloc (final_size); if(final_data==NULL) { - DBG (DBG_error, "%s: failed to allocate memory for shading data\n", __func__); + DBG(DBG_error, "%s: failed to allocate memory for shading data\n", __func__); return SANE_STATUS_NO_MEM; } memset(final_data,0x00,final_size); @@ -4350,7 +4213,7 @@ gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = sanei_genesys_set_buffer_address (dev, 0); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set buffer address: %s\n", __func__, sane_strstatus(status)); free(final_data); return status; } @@ -4358,7 +4221,7 @@ gl843_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = dev->model->cmd_set->bulk_write_data (dev, 0x3c, final_data, count); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to send shading table: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to send shading table: %s\n", __func__, sane_strstatus(status)); } free(final_data); diff --git a/backend/genesys_gl846.c b/backend/genesys_gl846.c index 213f27f96..909bc9a47 100644 --- a/backend/genesys_gl846.c +++ b/backend/genesys_gl846.c @@ -78,7 +78,7 @@ gl846_bulk_read_data (Genesys_Device * dev, uint8_t addr, uint8_t outdata[8]; uint8_t *buffer; - DBG (DBG_io, "gl846_bulk_read_data: requesting %lu bytes at addr=0x%02x\n", (u_long) len, addr); + DBG(DBG_io, "%s: requesting %lu bytes at addr=0x%02x\n", __func__, (u_long) len, addr); if (len == 0) return SANE_STATUS_GOOD; @@ -129,41 +129,35 @@ gl846_bulk_read_data (Genesys_Device * dev, uint8_t addr, read *= 512; } - DBG (DBG_io2, - "gl846_bulk_read_data: trying to read %lu bytes of data\n", - (u_long) read); + DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read); status = sanei_usb_read_bulk (dev->dn, buffer, &read); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_bulk_read_data failed while reading bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } done=read; - DBG (DBG_io2, "gl846_bulk_read_data: %lu bytes of data read\n", (u_long) done); + DBG(DBG_io2, "%s: %lu bytes of data read\n", __func__, (u_long) done); /* read less than 512 bytes remainder */ if (read < size) { read = size - read; - DBG (DBG_io2, - "gl846_bulk_read_data: trying to read %lu bytes of data\n", - (u_long) read); + DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read); status = sanei_usb_read_bulk (dev->dn, buffer+done, &read); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_bulk_read_data failed while reading bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } done=read; - DBG (DBG_io2, "gl846_bulk_read_data: %lu bytes of data read\n", (u_long) done); + DBG(DBG_io2, "%s: %lu bytes of data read\n", __func__, (u_long) done); } - DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__, - (u_long) size, (u_long) (target - size)); + DBG(DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__, + (u_long) size, (u_long) (target - size)); target -= size; buffer += size; @@ -608,9 +602,8 @@ gl846_send_slope_table (Genesys_Device * dev, int table_nr, status = sanei_genesys_write_ahb (dev->dn, dev->usb_mode, 0x10000000 + 0x4000 * table_nr, steps * 2, table); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: write to AHB failed writing slope table %d (%s)\n", - __func__, table_nr, sane_strstatus (status)); + DBG(DBG_error, "%s: write to AHB failed writing slope table %d (%s)\n", __func__, table_nr, + sane_strstatus(status)); } free (table); @@ -713,8 +706,7 @@ gl846_set_fe (Genesys_Device * dev, uint8_t set) { SANE_Status status; - DBG(DBG_proc, "gl846_set_fe (%s)\n", - set == AFE_INIT ? "init" : set == AFE_SET ? "set" : + DBG(DBG_proc, "%s (%s)\n", __func__, set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == AFE_POWER_SAVE ? "powersave" : "huh?"); /* route to specific analog frontend setup */ @@ -724,7 +716,7 @@ gl846_set_fe (Genesys_Device * dev, uint8_t set) status = gl846_set_adi_fe(dev, set); break; default: - DBG(DBG_proc, "gl846_set_fe(): unsupported frontend type %d\n", + DBG(DBG_proc, "%s(): unsupported frontend type %d\n", __func__, dev->reg[reg_0x04].value & REG04_FESET); status = SANE_STATUS_UNSUPPORTED; } @@ -763,13 +755,9 @@ gl846_init_motor_regs_scan (Genesys_Device * dev, unsigned int ccdlmt,tgtime; DBGSTART; - DBG (DBG_proc, "gl846_init_motor_regs_scan : scan_exposure_time=%d, " - "scan_yres=%g, scan_step_type=%d, scan_lines=%d, scan_dummy=%d, " - "feed_steps=%d, scan_power_mode=%d, flags=%x\n", - scan_exposure_time, - scan_yres, - scan_step_type, - scan_lines, scan_dummy, feed_steps, scan_power_mode, flags); + DBG(DBG_proc, "%s : scan_exposure_time=%d, scan_yres=%g, scan_step_type=%d, scan_lines=%d, " + "scan_dummy=%d, feed_steps=%d, scan_power_mode=%d, flags=%x\n", __func__, scan_exposure_time, + scan_yres, scan_step_type, scan_lines, scan_dummy, feed_steps, scan_power_mode, flags); /* get step multiplier */ factor = gl846_get_step_multiplier (reg); @@ -943,10 +931,10 @@ gl846_init_motor_regs_scan (Genesys_Device * dev, &z1, &z2); - DBG (DBG_info, "gl846_init_motor_regs_scan: z1 = %d\n", z1); + DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); sanei_genesys_set_triple(reg, REG60, z1 | (scan_step_type << (16+REG60S_STEPSEL))); - DBG (DBG_info, "gl846_init_motor_regs_scan: z2 = %d\n", z2); + DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); sanei_genesys_set_triple(reg, REG63, z2 | (scan_step_type << (16+REG63S_FSTPSEL))); r = sanei_genesys_get_address (reg, 0x1e); @@ -1016,21 +1004,20 @@ gl846_init_optical_regs_scan (Genesys_Device * dev, SANE_Status status; Sensor_Profile *sensor; - DBG (DBG_proc, "gl846_init_optical_regs_scan : exposure_time=%d, " - "used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " - "half_ccd=%d, flags=%x\n", exposure_time, - used_res, start, pixels, channels, depth, half_ccd, flags); + DBG(DBG_proc, "%s : exposure_time=%d, used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " + "half_ccd=%d, flags=%x\n", __func__, exposure_time, used_res, start, pixels, channels, depth, + half_ccd, flags); /* resolution is divided according to CKSEL */ r = sanei_genesys_get_address (reg, REG18); cksel= (r->value & REG18_CKSEL)+1; - DBG (DBG_io2, "%s: cksel=%d\n", __func__, cksel); + DBG(DBG_io2, "%s: cksel=%d\n", __func__, cksel); /* to manage high resolution device while keeping good * low resolution scanning speed, we make hardware dpi vary */ dpihw=sanei_genesys_compute_dpihw(dev, used_res * cksel); factor=dev->sensor.optical_res/dpihw; - DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); + DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); /* sensor parameters */ sensor=get_sensor_profile(dev->model->ccd_type, dpihw); @@ -1077,9 +1064,7 @@ gl846_init_optical_regs_scan (Genesys_Device * dev, status = gl846_set_fe (dev, AFE_SET); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_init_optical_regs_scan: failed to set frontend: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1292,15 +1277,14 @@ gl846_init_scan_regs (Genesys_Device * dev, int optical_res; SANE_Status status; - DBG (DBG_info, - "gl846_init_scan_regs settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g/%g\n" - "Depth/Channels: %u/%u\n" - "Flags : %x\n\n", - xres, yres, lines, pixels, startx, starty, depth, channels, flags); + DBG(DBG_info, "%s settings:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g/%g\n" + "Depth/Channels: %u/%u\n" + "Flags : %x\n\n", + __func__, xres, yres, lines, pixels, startx, starty, depth, channels, flags); /* we may have 2 domains for ccd: xres below or above half ccd max dpi */ if (dev->sensor.optical_res < 2 * xres || @@ -1323,7 +1307,7 @@ gl846_init_scan_regs (Genesys_Device * dev, stagger = (4 * yres) / dev->motor.base_ydpi; else stagger = 0; - DBG (DBG_info, "gl846_init_scan_regs : stagger=%d lines\n", stagger); + DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger); /* used_res */ if (flags & SCAN_FLAG_USE_OPTICAL_RES) @@ -1369,8 +1353,8 @@ gl846_init_scan_regs (Genesys_Device * dev, exposure_time = gl846_compute_exposure (dev, used_res); scan_step_type = sanei_genesys_compute_step_type(gl846_motors, dev->model->motor_type, exposure_time); - DBG (DBG_info, "gl846_init_scan_regs : exposure_time=%d pixels\n", exposure_time); - DBG (DBG_info, "gl846_init_scan_regs : scan_step_type=%d\n", scan_step_type); + DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); + DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type); /*** optical parameters ***/ /* in case of dynamic lineart, we use an internal 8 bit gray scan @@ -1421,7 +1405,7 @@ gl846_init_scan_regs (Genesys_Device * dev, /* add tl_y to base movement */ move = starty; - DBG (DBG_info, "gl846_init_scan_regs: move=%d steps\n", move); + DBG(DBG_info, "%s: move=%d steps\n", __func__, move); mflags=0; if(flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) @@ -1479,9 +1463,7 @@ gl846_init_scan_regs (Genesys_Device * dev, dev->read_bytes_left = bytes_per_line * lincnt; - DBG (DBG_info, - "gl846_init_scan_regs: physical bytes to read = %lu\n", - (u_long) dev->read_bytes_left); + DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left); dev->read_active = SANE_TRUE; @@ -1521,8 +1503,7 @@ gl846_init_scan_regs (Genesys_Device * dev, dev->total_bytes_to_read = dev->settings.pixels * dev->settings.lines * channels * (depth / 8); - DBG (DBG_info, "gl846_init_scan_regs: total bytes to send = %lu\n", - (u_long) dev->total_bytes_to_read); + DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read); /* END TODO */ DBGCOMPLETED; @@ -1555,15 +1536,14 @@ gl846_calculate_current_setup (Genesys_Device * dev) SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */ int optical_res; - DBG (DBG_info, - "gl846_calculate_current_setup settings:\n" - "Resolution: %uDPI\n" - "Lines : %u\n" - "PPL : %u\n" - "Startpos : %.3f/%.3f\n" - "Scan mode : %d\n\n", - dev->settings.yres, dev->settings.lines, dev->settings.pixels, - dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); + DBG(DBG_info, "%s settings:\n" + "Resolution: %uDPI\n" + "Lines : %u\n" + "PPL : %u\n" + "Startpos : %.3f/%.3f\n" + "Scan mode : %d\n\n", __func__, + dev->settings.yres, dev->settings.lines, dev->settings.pixels, + dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); /* channels */ if (dev->settings.scan_mode == 4) /* single pass color */ @@ -1588,14 +1568,13 @@ gl846_calculate_current_setup (Genesys_Device * dev) pixels = dev->settings.pixels; lines = dev->settings.lines; - DBG (DBG_info, - "gl846_calculate_current_setup settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g\n" - "Depth/Channels: %u/%u\n\n", - xres, yres, lines, pixels, startx, depth, channels); + DBG(DBG_info, "%s settings:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g\n" + "Depth/Channels: %u/%u\n\n", + __func__, xres, yres, lines, pixels, startx, depth, channels); /* half_ccd */ /* we have 2 domains for ccd: xres below or above half ccd max dpi */ @@ -1617,8 +1596,7 @@ gl846_calculate_current_setup (Genesys_Device * dev) stagger = (4 * yres) / dev->motor.base_ydpi; else stagger = 0; - DBG (DBG_info, "gl846_calculate_current_setup: stagger=%d lines\n", - stagger); + DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger); /* resolution is choosen from a fixed list */ used_res = xres; @@ -1642,7 +1620,7 @@ gl846_calculate_current_setup (Genesys_Device * dev) slope_dpi = slope_dpi * (1 + dummy); exposure_time = gl846_compute_exposure (dev, used_res); - DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); + DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); /* max_shift */ max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0); @@ -1669,7 +1647,7 @@ static void gl846_set_motor_power (Genesys_Register_Set * regs, SANE_Bool set) { - DBG (DBG_proc, "gl846_set_motor_power\n"); + DBG(DBG_proc, "%s\n", __func__); if (set) { @@ -1709,7 +1687,7 @@ gl846_set_lamp_power (Genesys_Device __sane_unused__ * dev, static SANE_Status gl846_save_power (Genesys_Device * dev, SANE_Bool enable) { - DBG (DBG_proc, "gl846_save_power: enable = %d\n", enable); + DBG(DBG_proc, "%s: enable = %d\n", __func__, enable); if (dev == NULL) return SANE_STATUS_INVAL; @@ -1720,7 +1698,7 @@ gl846_save_power (Genesys_Device * dev, SANE_Bool enable) static SANE_Status gl846_set_powersaving (Genesys_Device * dev, int delay /* in minutes */ ) { - DBG (DBG_proc, "gl846_set_powersaving (delay = %d)\n", delay); + DBG(DBG_proc, "%s (delay = %d)\n", __func__, delay); if (dev == NULL) return SANE_STATUS_INVAL; @@ -1754,9 +1732,7 @@ gl846_stop_action (Genesys_Device * dev) status = sanei_genesys_read_register (dev, REG40, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -1764,7 +1740,7 @@ gl846_stop_action (Genesys_Device * dev) /* only stop action if needed */ if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG)) { - DBG (DBG_info, "%s: already stopped\n", __func__); + DBG(DBG_info, "%s: already stopped\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -1776,9 +1752,7 @@ gl846_stop_action (Genesys_Device * dev) status = sanei_genesys_write_register (dev, REG01, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to write register 01: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write register 01: %s\n", __func__, sane_strstatus(status)); return status; } usleep (100 * 1000); @@ -1794,9 +1768,7 @@ gl846_stop_action (Genesys_Device * dev) status = sanei_genesys_read_register (dev, REG40, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -1867,7 +1839,7 @@ gl846_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, { SANE_Status status; - DBG (DBG_proc, "gl846_end_scan (check_stop = %d)\n", check_stop); + DBG(DBG_proc, "%s (check_stop = %d)\n", __func__, check_stop); if (reg == NULL) return SANE_STATUS_INVAL; @@ -1880,9 +1852,7 @@ gl846_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, status = gl846_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_end_scan: failed to stop: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -1903,8 +1873,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) int loop = 0; int scan_mode; - DBG (DBG_proc, "gl846_slow_back_home (wait_until_home = %d)\n", - wait_until_home); + DBG(DBG_proc, "%s (wait_until_home = %d)\n", __func__, wait_until_home); if(dev->usb_mode<0) { @@ -1919,9 +1888,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io) @@ -1934,9 +1901,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io) @@ -1947,7 +1912,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* is sensor at home? */ if (val & HOMESNR) { - DBG (DBG_info, "%s: already at home, completed\n", __func__); + DBG(DBG_info, "%s: already at home, completed\n", __func__); dev->scanhead_position_in_steps = 0; DBGCOMPLETED; return SANE_STATUS_GOOD; @@ -1976,9 +1941,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_slow_back_home: failed to set up registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -1996,9 +1959,7 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl846_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_slow_back_home: failed to start motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl846_stop_action (dev); /* send original registers */ dev->model->cmd_set->bulk_write_register (dev, dev->reg, GENESYS_GL846_MAX_REGS); @@ -2015,15 +1976,14 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, + sane_strstatus(status)); return status; } if (val & HOMESNR) /* home sensor */ { - DBG (DBG_info, "gl846_slow_back_home: reached home position\n"); + DBG(DBG_info, "%s: reached home position\n", __func__); gl846_stop_action (dev); dev->scanhead_position_in_steps = 0; DBGCOMPLETED; @@ -2035,12 +1995,11 @@ gl846_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* when we come here then the scanner needed too much time for this, so we better stop the motor */ gl846_stop_action (dev); - DBG (DBG_error, - "gl846_slow_back_home: timeout while waiting for scanhead to go home\n"); + DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); return SANE_STATUS_IO_ERROR; } - DBG (DBG_info, "gl846_slow_back_home: scanhead is still moving\n"); + DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -2059,7 +2018,7 @@ gl846_search_start_position (Genesys_Device * dev) int pixels = 600; int dpi = 300; - DBG (DBG_proc, "gl846_search_start_position\n"); + DBG(DBG_proc, "%s\n", __func__); memcpy (local_reg, dev->reg, GENESYS_GL846_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -2074,9 +2033,7 @@ gl846_search_start_position (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_search_start_position: failed to set up registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2085,9 +2042,7 @@ gl846_search_start_position (Genesys_Device * dev) status = dev->model->cmd_set->bulk_write_register (dev, local_reg, GENESYS_GL846_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_search_start_position: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2097,8 +2052,7 @@ gl846_search_start_position (Genesys_Device * dev) data = malloc (size); if (!data) { - DBG (DBG_error, - "gl846_search_start_position: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2106,9 +2060,7 @@ gl846_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl846_search_start_position: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2122,9 +2074,7 @@ gl846_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl846_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2136,9 +2086,7 @@ gl846_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl846_search_start_position: failed to end scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2154,9 +2102,8 @@ gl846_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl846_search_start_position: failed to set search reference point: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set search reference point: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -2174,7 +2121,7 @@ gl846_init_regs_for_coarse_calibration (Genesys_Device * dev) uint8_t channels; uint8_t cksel; - DBG (DBG_proc, "gl846_init_regs_for_coarse_calibration\n"); + DBG(DBG_proc, "%s\n", __func__); cksel = (dev->calib_reg[reg_0x18].value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */ @@ -2202,22 +2149,17 @@ gl846_init_regs_for_coarse_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_init_register_for_coarse_calibration: Failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, - "gl846_init_register_for_coarse_calibration: optical sensor res: %d dpi, actual res: %d\n", - dev->sensor.optical_res / cksel, dev->settings.xres); + DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, + dev->sensor.optical_res / cksel, dev->settings.xres); status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL846_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_init_register_for_coarse_calibration: Failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2239,7 +2181,7 @@ gl846_feed (Genesys_Device * dev, unsigned int steps) uint8_t val; DBGSTART; - DBG (DBG_io, "%s: steps=%d\n", __func__, steps); + DBG(DBG_io, "%s: steps=%d\n", __func__, steps); /* prepare local registers */ memcpy (local_reg, dev->reg, GENESYS_GL846_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -2262,9 +2204,7 @@ gl846_feed (Genesys_Device * dev, unsigned int steps) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_feed: failed to set up registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2288,7 +2228,7 @@ gl846_feed (Genesys_Device * dev, unsigned int steps) status = gl846_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl846_stop_action (dev); /* restore original registers */ @@ -2330,8 +2270,8 @@ gl846_init_regs_for_shading (Genesys_Device * dev) if(dev->calib_resolution==4800) dev->calib_lines *= 2; dev->calib_pixels = (dev->sensor.sensor_pixels*dev->calib_resolution)/dev->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 = %d\n", __func__, (unsigned int)dev->calib_lines); + DBG(DBG_io, "%s: calib_pixels = %d\n", __func__, (unsigned int)dev->calib_pixels); /* this is aworkaround insufficent distance for slope * motor acceleration TODO special motor slope for shading */ @@ -2359,14 +2299,14 @@ gl846_init_regs_for_shading (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL846_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2391,11 +2331,10 @@ gl846_init_regs_for_scan (Genesys_Device * dev) SANE_Status status; - DBG (DBG_info, - "gl846_init_regs_for_scan settings:\nResolution: %uDPI\n" - "Lines : %u\nPPL : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", - dev->settings.yres, dev->settings.lines, dev->settings.pixels, - dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); + DBG(DBG_info, "%s settings:\nResolution: %uDPI\n" + "Lines : %u\nPPL : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", __func__, + dev->settings.yres, dev->settings.lines, dev->settings.pixels, + dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); /* channels */ if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */ @@ -2434,7 +2373,7 @@ gl846_init_regs_for_scan (Genesys_Device * dev) move += dev->settings.tl_y; move = (move * move_dpi) / MM_PER_INCH; move -= dev->scanhead_position_in_steps; - DBG (DBG_info, "%s: move=%f steps\n",__func__, move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* fast move to scan area */ /* we don't move fast the whole distance since it would involve @@ -2446,14 +2385,14 @@ gl846_init_regs_for_scan (Genesys_Device * dev) status = gl846_feed (dev, move-500); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to move to scan area\n",__func__); + DBG(DBG_error, "%s: failed to move to scan area\n", __func__); return status; } move=500; } - DBG (DBG_info, "gl846_init_regs_for_scan: move=%f steps\n", move); - DBG (DBG_info, "%s: move=%f steps\n", __func__, move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ start = SANE_UNFIX (dev->model->x_offset); @@ -2508,7 +2447,7 @@ gl846_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) uint8_t val,*buffer,*ptr,*src; DBGSTART; - DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__func__,size); + DBG(DBG_io2, "%s: writing %d bytes of shading data\n", __func__, size); /* shading data is plit in 3 (up to 5 with IR) areas write(0x10014000,0x00000dd8) @@ -2525,10 +2464,11 @@ gl846_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* compute deletion factor */ sanei_genesys_get_double(dev->reg,REG_DPISET,&tempo); dpiset=tempo; - DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n",__func__,strpixel,endpixel,endpixel-strpixel,dpiset); + DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n", __func__, strpixel, endpixel, + endpixel-strpixel, dpiset); dpihw=sanei_genesys_compute_dpihw(dev,dpiset); factor=dpihw/dpiset; - DBG( DBG_io2, "%s: factor=%d\n",__func__,factor); + DBG(DBG_io2, "%s: factor=%d\n", __func__, factor); if(DBG_LEVEL>=DBG_data) { @@ -2553,7 +2493,7 @@ gl846_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* allocate temporary buffer */ buffer=(uint8_t *)malloc(pixels); memset(buffer,0,pixels); - DBG( DBG_io2, "%s: using chunks of %d (0x%04x) bytes\n",__func__,pixels,pixels); + DBG(DBG_io2, "%s: using chunks of %d (0x%04x) bytes\n", __func__, pixels, pixels); /* base addr of data has been written in reg D0-D4 in 4K word, so AHB address * is 8192*reg value */ @@ -2586,8 +2526,7 @@ gl846_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = sanei_genesys_write_ahb (dev->dn, dev->usb_mode, addr, pixels, buffer); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl846_send_shading_data; write to AHB failed (%s)\n", - sane_strstatus (status)); + DBG(DBG_error, "%s; write to AHB failed (%s)\n", __func__, sane_strstatus(status)); free(buffer); return status; } @@ -2631,7 +2570,7 @@ gl846_led_calibration (Genesys_Device * dev) { RIE(gl846_feed (dev, move)); } - DBG (DBG_io, "%s: move=%f steps\n", __func__, move); + DBG(DBG_io, "%s: move=%f steps\n", __func__, move); /* offset calibration is always done in color mode */ channels = 3; @@ -2661,7 +2600,7 @@ gl846_led_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2697,7 +2636,7 @@ gl846_led_calibration (Genesys_Device * dev) /* write registers and scan data */ RIEF (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL846_MAX_REGS), line); - DBG (DBG_info, "gl846_led_calibration: starting line reading\n"); + DBG(DBG_info, "%s: starting line reading\n", __func__); RIEF (gl846_begin_scan (dev, dev->calib_reg, SANE_TRUE), line); RIEF (sanei_genesys_read_data_from_scanner (dev, line, total_size), line); @@ -2730,7 +2669,7 @@ gl846_led_calibration (Genesys_Device * dev) avg[j] /= num_pixels; } - DBG (DBG_info, "gl846_led_calibration: average: %d,%d,%d\n", avg[0], avg[1], avg[2]); + DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); /* check if exposure gives average within the boundaries */ acceptable = SANE_TRUE; @@ -2752,7 +2691,7 @@ gl846_led_calibration (Genesys_Device * dev) } while (!acceptable && turn < 100); - DBG (DBG_info, "gl846_led_calibration: acceptable exposure: %d,%d,%d\n", exp[0], exp[1], exp[2]); + DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0], exp[1], exp[2]); /* set these values as final ones for scan */ sanei_genesys_set_double(dev->reg,REG_EXPR,exp[0]); @@ -2798,7 +2737,8 @@ gl846_init_gpio (Genesys_Device * dev) } if(gpios[idx].sensor_id==0) { - DBG (DBG_error, "%s: failed to find GPIO profile for sensor_id=%d\n", __func__, dev->model->ccd_type); + DBG(DBG_error, "%s: failed to find GPIO profile for sensor_id=%d\n", __func__, + dev->model->ccd_type); return SANE_STATUS_INVAL; } @@ -2894,7 +2834,7 @@ gl846_boot (Genesys_Device * dev, SANE_Bool cold) if (val & REG40_CHKVER) { RIE (sanei_genesys_read_register (dev, 0x00, &val)); - DBG (DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); + DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ @@ -3003,24 +2943,19 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) char title[80]; Genesys_Register_Set *r; - DBG (DBG_proc, "gl846_search_strip %s %s\n", black ? "black" : "white", - forward ? "forward" : "reverse"); + DBG(DBG_proc, "%s %s %s\n", __func__, black ? "black" : "white", forward ? "forward" : "reverse"); status = gl846_set_fe (dev, AFE_SET); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_search_strip: gl846_set_fe() failed: %s\n", - sane_strstatus(status)); + DBG(DBG_error, "%s: gl846_set_fe() failed: %s\n", __func__, sane_strstatus(status)); return status; } status = gl846_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_search_strip: failed to stop: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3042,7 +2977,7 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) data = malloc (size); if (!data) { - DBG (DBG_error, "gl846_search_strip: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } dev->scanhead_position_in_steps = 0; @@ -3066,9 +3001,7 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free(data); - DBG (DBG_error, - "gl846_search_strip: failed to setup for scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup for scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3084,9 +3017,7 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free(data); - DBG (DBG_error, - "gl846_search_strip: Failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3094,9 +3025,7 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl846_search_strip: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3110,9 +3039,7 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl846_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3120,7 +3047,7 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, "gl846_search_strip: gl846_stop_action failed\n"); + DBG(DBG_error, "%s: gl846_stop_action failed\n", __func__); return status; } @@ -3140,9 +3067,8 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) status = dev->model->cmd_set->bulk_write_register (dev, local_reg, GENESYS_GL846_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_search_strip: Failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -3151,9 +3077,7 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl846_search_strip: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3167,9 +3091,7 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl846_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3177,7 +3099,7 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, "gl846_search_strip: gl846_stop_action failed\n"); + DBG(DBG_error, "%s: gl846_stop_action failed\n", __func__); return status; } @@ -3219,15 +3141,13 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / pixels < 3) { found = 1; - DBG (DBG_data, - "gl846_search_strip: strip found forward during pass %d at line %d\n", - pass, y); + DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, + pass, y); } else { - DBG (DBG_data, - "gl846_search_strip: pixels=%d, count=%d (%d%%)\n", - pixels, count, (100 * count) / pixels); + DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, + (100 * count) / pixels); } } } @@ -3258,15 +3178,12 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / (pixels * lines) < 3) { found = 1; - DBG (DBG_data, - "gl846_search_strip: strip found backward during pass %d \n", - pass); + DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { - DBG (DBG_data, - "gl846_search_strip: pixels=%d, count=%d (%d%%)\n", - pixels, count, (100 * count) / pixels); + DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, + (100 * count) / pixels); } } pass++; @@ -3275,14 +3192,12 @@ gl846_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (found) { status = SANE_STATUS_GOOD; - DBG (DBG_info, "gl846_search_strip: %s strip found\n", - black ? "black" : "white"); + DBG(DBG_info, "%s: %s strip found\n", __func__, black ? "black" : "white"); } else { status = SANE_STATUS_UNSUPPORTED; - DBG (DBG_info, "gl846_search_strip: %s strip not found\n", - black ? "black" : "white"); + DBG(DBG_info, "%s: %s strip not found\n", __func__, black ? "black" : "white"); } DBGCOMPLETED; @@ -3316,13 +3231,13 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines, } if (count) avg[k] /= count; - DBG (DBG_info, "dark_average: avg[%d] = %d\n", k, avg[k]); + DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } average = 0; for (i = 0; i < channels; i++) average += avg[i]; average /= channels; - DBG (DBG_info, "dark_average: average = %d\n", average); + DBG(DBG_info, "%s: average = %d\n", __func__, average); return average; } @@ -3355,7 +3270,7 @@ gl846_offset_calibration (Genesys_Device * dev) bpp=8; pixels= (dev->sensor.sensor_pixels*resolution) / dev->sensor.optical_res; black_pixels = (dev->sensor.black_pixels * resolution) / dev->sensor.optical_res; - DBG (DBG_io2, "gl846_offset_calibration: black_pixels=%d\n", black_pixels); + DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); status = gl846_init_scan_regs (dev, dev->calib_reg, @@ -3374,9 +3289,7 @@ gl846_offset_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_offset_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } gl846_set_motor_power (dev->calib_reg, SANE_FALSE); @@ -3408,7 +3321,7 @@ gl846_offset_calibration (Genesys_Device * dev) RIEF2 (gl846_set_fe(dev, AFE_SET), first_line, second_line); RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL846_MAX_REGS), first_line, second_line); - DBG (DBG_info, "gl846_offset_calibration: starting first line reading\n"); + DBG(DBG_info, "%s: starting first line reading\n", __func__); RIEF2 (gl846_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, first_line, total_size), first_line, second_line); if (DBG_LEVEL >= DBG_data) @@ -3418,7 +3331,7 @@ gl846_offset_calibration (Genesys_Device * dev) } bottomavg = dark_average (first_line, pixels, lines, channels, black_pixels); - DBG (DBG_io2, "gl846_offset_calibration: bottom avg=%d\n", bottomavg); + DBG(DBG_io2, "%s: bottom avg=%d\n", __func__, bottomavg); /* now top value */ top = 255; @@ -3427,12 +3340,12 @@ gl846_offset_calibration (Genesys_Device * dev) dev->frontend.offset[2] = top; RIEF2 (gl846_set_fe(dev, AFE_SET), first_line, second_line); RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL846_MAX_REGS), first_line, second_line); - DBG (DBG_info, "gl846_offset_calibration: starting second line reading\n"); + DBG(DBG_info, "%s: starting second line reading\n", __func__); RIEF2 (gl846_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size), first_line, second_line); topavg = dark_average (second_line, pixels, lines, channels, black_pixels); - DBG (DBG_io2, "gl846_offset_calibration: top avg=%d\n", topavg); + DBG(DBG_io2, "%s: top avg=%d\n", __func__, topavg); /* loop until acceptable level */ while ((pass < 32) && (top - bottom > 1)) @@ -3447,7 +3360,7 @@ gl846_offset_calibration (Genesys_Device * dev) /* scan with no move */ RIEF2 (gl846_set_fe(dev, AFE_SET), first_line, second_line); RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL846_MAX_REGS), first_line, second_line); - DBG (DBG_info, "gl846_offset_calibration: starting second line reading\n"); + DBG(DBG_info, "%s: starting second line reading\n", __func__); RIEF2 (gl846_begin_scan (dev, dev->calib_reg, SANE_TRUE), first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size), first_line, second_line); @@ -3458,8 +3371,7 @@ gl846_offset_calibration (Genesys_Device * dev) } avg = dark_average (second_line, pixels, lines, channels, black_pixels); - DBG (DBG_info, "gl846_offset_calibration: avg=%d offset=%d\n", avg, - dev->frontend.offset[1]); + DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.offset[1]); /* compute new boundaries */ if (topavg == avg) @@ -3473,7 +3385,8 @@ gl846_offset_calibration (Genesys_Device * dev) bottom = dev->frontend.offset[1]; } } - DBG (DBG_info, "gl846_offset_calibration: offset=(%d,%d,%d)\n", dev->frontend.offset[0], dev->frontend.offset[1], dev->frontend.offset[2]); + DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0], + dev->frontend.offset[1], dev->frontend.offset[2]); /* cleanup before return */ free (first_line); @@ -3497,7 +3410,7 @@ gl846_coarse_gain_calibration (Genesys_Device * dev, int dpi) int resolution; int bpp; - DBG (DBG_proc, "gl846_coarse_gain_calibration: dpi = %d\n", dpi); + DBG(DBG_proc, "%s: dpi = %d\n", __func__, dpi); /* no gain nor offset for AKM AFE */ RIE (sanei_genesys_read_register (dev, REG04, ®04)); @@ -3545,9 +3458,7 @@ gl846_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl846_coarse_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3592,9 +3503,8 @@ gl846_coarse_gain_calibration (Genesys_Device * dev, int dpi) code = 0; dev->frontend.gain[j] = code; - DBG (DBG_proc, - "gl846_coarse_gain_calibration: channel %d, max=%d, gain = %f, setting:%d\n", - j, max[j], gain[j], dev->frontend.gain[j]); + DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j], + dev->frontend.gain[j]); } if (dev->model->is_cis) diff --git a/backend/genesys_gl847.c b/backend/genesys_gl847.c index 82ff6b498..b5059713c 100644 --- a/backend/genesys_gl847.c +++ b/backend/genesys_gl847.c @@ -74,7 +74,7 @@ gl847_bulk_read_data (Genesys_Device * dev, uint8_t addr, uint8_t outdata[8]; uint8_t *buffer; - DBG (DBG_io, "gl847_bulk_read_data: requesting %lu bytes at addr=0x%02x\n", (u_long) len, addr); + DBG(DBG_io, "%s: requesting %lu bytes at addr=0x%02x\n", __func__, (u_long) len, addr); if (len == 0) return SANE_STATUS_GOOD; @@ -112,8 +112,7 @@ gl847_bulk_read_data (Genesys_Device * dev, uint8_t addr, outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s failed while writing command: %s\n", - __func__, sane_strstatus (status)); + DBG(DBG_error, "%s failed while writing command: %s\n", __func__, sane_strstatus(status)); return status; } @@ -125,41 +124,35 @@ gl847_bulk_read_data (Genesys_Device * dev, uint8_t addr, read *= 512; } - DBG (DBG_io2, - "gl847_bulk_read_data: trying to read %lu bytes of data\n", - (u_long) read); + DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read); status = sanei_usb_read_bulk (dev->dn, buffer, &read); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_bulk_read_data failed while reading bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } done=read; - DBG (DBG_io2, "gl847_bulk_read_data: %lu bytes of data read\n", (u_long) done); + DBG(DBG_io2, "%s: %lu bytes of data read\n", __func__, (u_long) done); /* read less than 512 bytes remainder */ if (read < size) { read = size - read; - DBG (DBG_io2, - "gl847_bulk_read_data: trying to read %lu bytes of data\n", - (u_long) read); + DBG(DBG_io2, "%s: trying to read %lu bytes of data\n", __func__, (u_long) read); status = sanei_usb_read_bulk (dev->dn, buffer+done, &read); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_bulk_read_data failed while reading bulk data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s failed while reading bulk data: %s\n", __func__, + sane_strstatus(status)); return status; } done=read; - DBG (DBG_io2, "gl847_bulk_read_data: %lu bytes of data read\n", (u_long) done); + DBG(DBG_io2, "%s: %lu bytes of data read\n", __func__, (u_long) done); } - DBG (DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__, - (u_long) size, (u_long) (target - size)); + DBG(DBG_io2, "%s: read %lu bytes, %lu remaining\n", __func__, (u_long) size, + (u_long) (target - size)); target -= size; buffer += size; @@ -632,9 +625,8 @@ gl847_send_slope_table (Genesys_Device * dev, int table_nr, sanei_genesys_write_ahb (dev->dn, dev->usb_mode, 0x10000000 + 0x4000 * table_nr, steps * 2, table); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: write to AHB failed writing slope table %d (%s)\n", - __func__, table_nr, sane_strstatus (status)); + DBG(DBG_error, "%s: write to AHB failed writing slope table %d (%s)\n", __func__, table_nr, + sane_strstatus(status)); } free (table); @@ -665,8 +657,7 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set) if (set == AFE_INIT) { - DBG (DBG_proc, "gl847_set_ad_fe(): setting DAC %u\n", - dev->model->dac_type); + DBG(DBG_proc, "%s(): setting DAC %u\n", __func__, dev->model->dac_type); /* sets to default values */ sanei_genesys_init_fe (dev); @@ -676,8 +667,7 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, 0x80); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl847_set_ad_fe: failed to write reg0: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write reg0: %s\n", __func__, sane_strstatus(status)); return status; } @@ -686,16 +676,14 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x00, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl847_set_ad_fe: failed to write reg0: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write reg0: %s\n", __func__, sane_strstatus(status)); return status; } val = dev->frontend.reg[1]; status = sanei_genesys_fe_write_data (dev, 0x01, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl847_set_ad_fe: failed to write reg1: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write reg1: %s\n", __func__, sane_strstatus(status)); return status; } @@ -705,9 +693,7 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x02 + i, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_set_ad_fe: failed to write gain %d: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write gain %d: %s\n", __func__, i, sane_strstatus(status)); return status; } } @@ -717,9 +703,8 @@ gl847_set_ad_fe (Genesys_Device * dev, uint8_t set) status = sanei_genesys_fe_write_data (dev, 0x05 + i, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_set_ad_fe: failed to write offset %d: %s\n", i, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write offset %d: %s\n", __func__, i, + sane_strstatus(status)); return status; } } @@ -756,9 +741,8 @@ gl847_set_fe (Genesys_Device * dev, uint8_t set) SANE_Status status; uint8_t val; - DBG (DBG_proc, "gl847_set_fe (%s)\n", - set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == - AFE_POWER_SAVE ? "powersave" : "huh?"); + DBG(DBG_proc, "%s (%s)\n", __func__, set == AFE_INIT ? "init" : set == AFE_SET ? "set" : set == + AFE_POWER_SAVE ? "powersave" : "huh?"); RIE (sanei_genesys_read_register (dev, REG04, &val)); @@ -769,8 +753,8 @@ gl847_set_fe (Genesys_Device * dev, uint8_t set) } /* for now there is no support yet for wolfson fe */ - DBG (DBG_proc, "gl847_set_fe(): unsupported frontend type %d\n", - dev->reg[reg_0x04].value & REG04_FESET); + DBG(DBG_proc, "%s(): unsupported frontend type %d\n", __func__, + dev->reg[reg_0x04].value & REG04_FESET); DBGCOMPLETED; return SANE_STATUS_UNSUPPORTED; @@ -806,13 +790,9 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, unsigned int ccdlmt,tgtime; DBGSTART; - DBG (DBG_proc, "gl847_init_motor_regs_scan : scan_exposure_time=%d, " - "scan_yres=%g, scan_step_type=%d, scan_lines=%d, scan_dummy=%d, " - "feed_steps=%d, scan_power_mode=%d, flags=%x\n", - scan_exposure_time, - scan_yres, - scan_step_type, - scan_lines, scan_dummy, feed_steps, scan_power_mode, flags); + DBG(DBG_proc, "%s : scan_exposure_time=%d, can_yres=%g, scan_step_type=%d, scan_lines=%d, " + "scan_dummy=%d, feed_steps=%d, scan_power_mode=%d, flags=%x\n", __func__, scan_exposure_time, + scan_yres, scan_step_type, scan_lines, scan_dummy, feed_steps, scan_power_mode, flags); /* get step multiplier */ factor = gl847_get_step_multiplier (reg); @@ -824,10 +804,10 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, { use_fast_fed=1; } - DBG (DBG_io, "%s: use_fast_fed=%d\n", __func__, use_fast_fed); + DBG(DBG_io, "%s: use_fast_fed=%d\n", __func__, use_fast_fed); sanei_genesys_set_triple(reg, REG_LINCNT, scan_lines); - DBG (DBG_io, "%s: lincnt=%d\n", __func__, scan_lines); + DBG(DBG_io, "%s: lincnt=%d\n", __func__, scan_lines); /* compute register 02 value */ r = sanei_genesys_get_address (reg, REG02); @@ -906,8 +886,8 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, if (flags & MOTOR_FLAG_FEED) dist *=2; } - DBG (DBG_io2, "%s: scan steps=%d\n", __func__, scan_steps); - DBG (DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); + DBG(DBG_io2, "%s: scan steps=%d\n", __func__, scan_steps); + DBG(DBG_io2, "%s: acceleration distance=%d\n", __func__, dist); /* check for overflow */ if(distvalue & REG0C_CCDLMT)+1; @@ -967,10 +947,10 @@ gl847_init_motor_regs_scan (Genesys_Device * dev, &z1, &z2); - DBG (DBG_info, "gl847_init_motor_regs_scan: z1 = %d\n", z1); + DBG(DBG_info, "%s: z1 = %d\n", __func__, z1); sanei_genesys_set_triple(reg, REG60, z1 | (scan_step_type << (16+REG60S_STEPSEL))); - DBG (DBG_info, "gl847_init_motor_regs_scan: z2 = %d\n", z2); + DBG(DBG_info, "%s: z2 = %d\n", __func__, z2); sanei_genesys_set_triple(reg, REG63, z2 | (scan_step_type << (16+REG63S_FSTPSEL))); r = sanei_genesys_get_address (reg, 0x1e); @@ -1040,21 +1020,20 @@ gl847_init_optical_regs_scan (Genesys_Device * dev, SANE_Status status; Sensor_Profile *sensor; - DBG (DBG_proc, "gl847_init_optical_regs_scan : exposure_time=%d, " - "used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " - "half_ccd=%d, flags=%x\n", exposure_time, - used_res, start, pixels, channels, depth, half_ccd, flags); + DBG(DBG_proc, "%s : exposure_time=%d, used_res=%d, start=%d, pixels=%d, channels=%d, depth=%d, " + "half_ccd=%d, flags=%x\n", __func__, exposure_time, used_res, start, pixels, channels, depth, + half_ccd, flags); /* resolution is divided according to CKSEL */ r = sanei_genesys_get_address (reg, REG18); cksel= (r->value & REG18_CKSEL)+1; - DBG (DBG_io2, "%s: cksel=%d\n", __func__, cksel); + DBG(DBG_io2, "%s: cksel=%d\n", __func__, cksel); /* to manage high resolution device while keeping good * low resolution scanning speed, we make hardware dpi vary */ dpihw=sanei_genesys_compute_dpihw(dev, used_res * cksel); factor=dev->sensor.optical_res/dpihw; - DBG (DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); + DBG(DBG_io2, "%s: dpihw=%d (factor=%d)\n", __func__, dpihw, factor); /* sensor parameters */ sensor=get_sensor_profile(dev->model->ccd_type, dpihw); @@ -1101,9 +1080,7 @@ gl847_init_optical_regs_scan (Genesys_Device * dev, status = gl847_set_fe (dev, AFE_SET); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_init_optical_regs_scan: failed to set frontend: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set frontend: %s\n", __func__, sane_strstatus(status)); return status; } @@ -1265,10 +1242,10 @@ gl847_init_optical_regs_scan (Genesys_Device * dev, /* MAXWD is expressed in 4 words unit */ sanei_genesys_set_triple(reg, REG_MAXWD, (words_per_line >> 2)); - DBG (DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line); + DBG(DBG_io2, "%s: words_per_line used=%d\n", __func__, words_per_line); sanei_genesys_set_double(reg, REG_LPERIOD, exposure_time); - DBG (DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time); + DBG(DBG_io2, "%s: exposure_time used=%d\n", __func__, exposure_time); r = sanei_genesys_get_address (reg, 0x34); r->value = dev->sensor.dummy_pixel; @@ -1316,15 +1293,14 @@ gl847_init_scan_regs (Genesys_Device * dev, int optical_res; SANE_Status status; - DBG (DBG_info, - "gl847_init_scan_regs settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g/%g\n" - "Depth/Channels: %u/%u\n" - "Flags : %x\n\n", - xres, yres, lines, pixels, startx, starty, depth, channels, flags); + DBG(DBG_info, "%s settings:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g/%g\n" + "Depth/Channels: %u/%u\n" + "Flags : %x\n\n", + __func__, xres, yres, lines, pixels, startx, starty, depth, channels, flags); /* we may have 2 domains for ccd: xres below or above half ccd max dpi */ if (dev->sensor.optical_res < 2 * xres || @@ -1347,7 +1323,7 @@ gl847_init_scan_regs (Genesys_Device * dev, stagger = (4 * yres) / dev->motor.base_ydpi; else stagger = 0; - DBG (DBG_info, "gl847_init_scan_regs : stagger=%d lines\n", stagger); + DBG(DBG_info, "%s : stagger=%d lines\n", __func__, stagger); /* used_res */ if (flags & SCAN_FLAG_USE_OPTICAL_RES) @@ -1393,8 +1369,8 @@ gl847_init_scan_regs (Genesys_Device * dev, exposure_time = gl847_compute_exposure (dev, used_res); scan_step_type = sanei_genesys_compute_step_type(gl847_motors, dev->model->motor_type, exposure_time); - DBG (DBG_info, "gl847_init_scan_regs : exposure_time=%d pixels\n", exposure_time); - DBG (DBG_info, "gl847_init_scan_regs : scan_step_type=%d\n", scan_step_type); + DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); + DBG(DBG_info, "%s : scan_step_type=%d\n", __func__, scan_step_type); /*** optical parameters ***/ /* in case of dynamic lineart, we use an internal 8 bit gray scan @@ -1445,7 +1421,7 @@ gl847_init_scan_regs (Genesys_Device * dev, /* add tl_y to base movement */ move = starty; - DBG (DBG_info, "gl847_init_scan_regs: move=%d steps\n", move); + DBG(DBG_info, "%s: move=%d steps\n", __func__, move); mflags=0; if(flags & SCAN_FLAG_DISABLE_BUFFER_FULL_MOVE) @@ -1503,9 +1479,7 @@ gl847_init_scan_regs (Genesys_Device * dev, dev->read_bytes_left = bytes_per_line * lincnt; - DBG (DBG_info, - "gl847_init_scan_regs: physical bytes to read = %lu\n", - (u_long) dev->read_bytes_left); + DBG(DBG_info, "%s: physical bytes to read = %lu\n", __func__, (u_long) dev->read_bytes_left); dev->read_active = SANE_TRUE; @@ -1545,8 +1519,7 @@ gl847_init_scan_regs (Genesys_Device * dev, dev->total_bytes_to_read = dev->settings.pixels * dev->settings.lines * channels * (depth / 8); - DBG (DBG_info, "gl847_init_scan_regs: total bytes to send = %lu\n", - (u_long) dev->total_bytes_to_read); + DBG(DBG_info, "%s: total bytes to send = %lu\n", __func__, (u_long) dev->total_bytes_to_read); /* END TODO */ DBGCOMPLETED; @@ -1579,15 +1552,14 @@ gl847_calculate_current_setup (Genesys_Device * dev) SANE_Bool half_ccd; /* false: full CCD res is used, true, half max CCD res is used */ int optical_res; - DBG (DBG_info, - "gl847_calculate_current_setup settings:\n" - "Resolution: %uDPI\n" - "Lines : %u\n" - "PPL : %u\n" - "Startpos : %.3f/%.3f\n" - "Scan mode : %d\n\n", - dev->settings.yres, dev->settings.lines, dev->settings.pixels, - dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); + DBG(DBG_info, "%s settings:\n" + "Resolution: %uDPI\n" + "Lines : %u\n" + "PPL : %u\n" + "Startpos : %.3f/%.3f\n" + "Scan mode : %d\n\n", __func__, + dev->settings.yres, dev->settings.lines, dev->settings.pixels, + dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); /* channels */ if (dev->settings.scan_mode == 4) /* single pass color */ @@ -1612,14 +1584,13 @@ gl847_calculate_current_setup (Genesys_Device * dev) pixels = dev->settings.pixels; lines = dev->settings.lines; - DBG (DBG_info, - "gl847_calculate_current_setup settings:\n" - "Resolution : %gDPI/%gDPI\n" - "Lines : %g\n" - "PPL : %g\n" - "Startpos : %g\n" - "Depth/Channels: %u/%u\n\n", - xres, yres, lines, pixels, startx, depth, channels); + DBG(DBG_info, "%s settings:\n" + "Resolution : %gDPI/%gDPI\n" + "Lines : %g\n" + "PPL : %g\n" + "Startpos : %g\n" + "Depth/Channels: %u/%u\n\n", + __func__, xres, yres, lines, pixels, startx, depth, channels); /* half_ccd */ /* we have 2 domains for ccd: xres below or above half ccd max dpi */ @@ -1641,8 +1612,7 @@ gl847_calculate_current_setup (Genesys_Device * dev) stagger = (4 * yres) / dev->motor.base_ydpi; else stagger = 0; - DBG (DBG_info, "gl847_calculate_current_setup: stagger=%d lines\n", - stagger); + DBG(DBG_info, "%s: stagger=%d lines\n", __func__, stagger); /* resolution is choosen from a fixed list */ used_res = xres; @@ -1666,7 +1636,7 @@ gl847_calculate_current_setup (Genesys_Device * dev) slope_dpi = slope_dpi * (1 + dummy); exposure_time = gl847_compute_exposure (dev, used_res); - DBG (DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); + DBG(DBG_info, "%s : exposure_time=%d pixels\n", __func__, exposure_time); /* max_shift */ max_shift=sanei_genesys_compute_max_shift(dev,channels,yres,0); @@ -1693,7 +1663,7 @@ static void gl847_set_motor_power (Genesys_Register_Set * regs, SANE_Bool set) { - DBG (DBG_proc, "gl847_set_motor_power\n"); + DBG(DBG_proc, "%s\n", __func__); if (set) { @@ -1733,7 +1703,7 @@ gl847_set_lamp_power (Genesys_Device __sane_unused__ * dev, static SANE_Status gl847_save_power (Genesys_Device * dev, SANE_Bool enable) { - DBG (DBG_proc, "gl847_save_power: enable = %d\n", enable); + DBG(DBG_proc, "%s: enable = %d\n", __func__, enable); if (dev == NULL) return SANE_STATUS_INVAL; @@ -1744,7 +1714,7 @@ gl847_save_power (Genesys_Device * dev, SANE_Bool enable) static SANE_Status gl847_set_powersaving (Genesys_Device * dev, int delay /* in minutes */ ) { - DBG (DBG_proc, "gl847_set_powersaving (delay = %d)\n", delay); + DBG(DBG_proc, "%s (delay = %d)\n", __func__, delay); if (dev == NULL) return SANE_STATUS_INVAL; @@ -1778,9 +1748,7 @@ gl847_stop_action (Genesys_Device * dev) status = sanei_genesys_read_register (dev, REG40, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -1788,7 +1756,7 @@ gl847_stop_action (Genesys_Device * dev) /* only stop action if needed */ if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG)) { - DBG (DBG_info, "%s: already stopped\n", __func__); + DBG(DBG_info, "%s: already stopped\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -1800,9 +1768,7 @@ gl847_stop_action (Genesys_Device * dev) status = sanei_genesys_write_register (dev, REG01, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to write register 01: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to write register 01: %s\n", __func__, sane_strstatus(status)); return status; } usleep (100 * 1000); @@ -1818,9 +1784,7 @@ gl847_stop_action (Genesys_Device * dev) status = sanei_genesys_read_register (dev, REG40, &val40); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "%s: failed to read home sensor: %s\n", __func__, - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -1893,7 +1857,7 @@ gl847_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, { SANE_Status status; - DBG (DBG_proc, "gl847_end_scan (check_stop = %d)\n", check_stop); + DBG(DBG_proc, "%s (check_stop = %d)\n", __func__, check_stop); if (reg == NULL) return SANE_STATUS_INVAL; @@ -1906,9 +1870,7 @@ gl847_end_scan (Genesys_Device * dev, Genesys_Register_Set * reg, status = gl847_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_end_scan: failed to stop: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop: %s\n", __func__, sane_strstatus(status)); return status; } } @@ -1974,8 +1936,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) int loop = 0; int scan_mode; - DBG (DBG_proc, "gl847_slow_back_home (wait_until_home = %d)\n", - wait_until_home); + DBG(DBG_proc, "%s (wait_until_home = %d)\n", __func__, wait_until_home); /* post scan gpio : without that HOMSNR is unreliable */ gl847_homsnr_gpio(dev); @@ -1984,9 +1945,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io) @@ -1999,9 +1958,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, sane_strstatus(status)); return status; } if (DBG_LEVEL >= DBG_io) @@ -2012,7 +1969,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* is sensor at home? */ if (val & HOMESNR) { - DBG (DBG_info, "%s: already at home, completed\n", __func__); + DBG(DBG_info, "%s: already at home, completed\n", __func__); dev->scanhead_position_in_steps = 0; DBGCOMPLETED; return SANE_STATUS_GOOD; @@ -2041,9 +1998,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_slow_back_home: failed to set up registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2062,9 +2017,7 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = gl847_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_slow_back_home: failed to start motor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl847_stop_action (dev); /* send original registers */ dev->model->cmd_set->bulk_write_register (dev, dev->reg, GENESYS_GL847_MAX_REGS); @@ -2081,15 +2034,14 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_slow_back_home: failed to read home sensor: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read home sensor: %s\n", __func__, + sane_strstatus(status)); return status; } if (val & HOMESNR) /* home sensor */ { - DBG (DBG_info, "gl847_slow_back_home: reached home position\n"); + DBG(DBG_info, "%s: reached home position\n", __func__); gl847_stop_action (dev); dev->scanhead_position_in_steps = 0; DBGCOMPLETED; @@ -2101,12 +2053,11 @@ gl847_slow_back_home (Genesys_Device * dev, SANE_Bool wait_until_home) /* when we come here then the scanner needed too much time for this, so we better stop the motor */ gl847_stop_action (dev); - DBG (DBG_error, - "gl847_slow_back_home: timeout while waiting for scanhead to go home\n"); + DBG(DBG_error, "%s: timeout while waiting for scanhead to go home\n", __func__); return SANE_STATUS_IO_ERROR; } - DBG (DBG_info, "gl847_slow_back_home: scanhead is still moving\n"); + DBG(DBG_info, "%s: scanhead is still moving\n", __func__); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -2125,7 +2076,7 @@ gl847_search_start_position (Genesys_Device * dev) int pixels = 600; int dpi = 300; - DBG (DBG_proc, "gl847_search_start_position\n"); + DBG(DBG_proc, "%s\n", __func__); memcpy (local_reg, dev->reg, GENESYS_GL847_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -2140,9 +2091,7 @@ gl847_search_start_position (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_search_start_position: failed to set up registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2151,9 +2100,7 @@ gl847_search_start_position (Genesys_Device * dev) status = dev->model->cmd_set->bulk_write_register (dev, local_reg, GENESYS_GL847_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_search_start_position: failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2163,8 +2110,7 @@ gl847_search_start_position (Genesys_Device * dev) data = malloc (size); if (!data) { - DBG (DBG_error, - "gl847_search_start_position: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } @@ -2172,9 +2118,7 @@ gl847_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl847_search_start_position: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2188,9 +2132,7 @@ gl847_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl847_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2202,9 +2144,7 @@ gl847_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl847_search_start_position: failed to end scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to end scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2220,9 +2160,8 @@ gl847_search_start_position (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl847_search_start_position: failed to set search reference point: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set search reference point: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -2240,7 +2179,7 @@ gl847_init_regs_for_coarse_calibration (Genesys_Device * dev) uint8_t channels; uint8_t cksel; - DBG (DBG_proc, "gl847_init_regs_for_coarse_calibration\n"); + DBG(DBG_proc, "%s\n", __func__); cksel = (dev->calib_reg[reg_0x18].value & REG18_CKSEL) + 1; /* clock speed = 1..4 clocks */ @@ -2268,23 +2207,18 @@ gl847_init_regs_for_coarse_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_init_register_for_coarse_calibration: Failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_info, - "gl847_init_register_for_coarse_calibration: optical sensor res: %d dpi, actual res: %d\n", - dev->sensor.optical_res / cksel, dev->settings.xres); + DBG(DBG_info, "%s: optical sensor res: %d dpi, actual res: %d\n", __func__, + dev->sensor.optical_res / cksel, dev->settings.xres); status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL847_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_init_register_for_coarse_calibration: Failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2306,7 +2240,7 @@ gl847_feed (Genesys_Device * dev, unsigned int steps) uint8_t val; DBGSTART; - DBG (DBG_io, "%s: steps=%d\n", __func__, steps); + DBG(DBG_io, "%s: steps=%d\n", __func__, steps); /* prepare local registers */ memcpy (local_reg, dev->reg, GENESYS_GL847_MAX_REGS * sizeof (Genesys_Register_Set)); @@ -2329,9 +2263,7 @@ gl847_feed (Genesys_Device * dev, unsigned int steps) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_feed: failed to set up registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to set up registers: %s\n", __func__, sane_strstatus(status)); DBGCOMPLETED; return status; } @@ -2355,7 +2287,7 @@ gl847_feed (Genesys_Device * dev, unsigned int steps) status = gl847_start_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to start motor: %s\n", __func__, sane_strstatus(status)); gl847_stop_action (dev); /* restore original registers */ @@ -2397,8 +2329,8 @@ gl847_init_regs_for_shading (Genesys_Device * dev) if(dev->calib_resolution==4800) dev->calib_lines *= 2; dev->calib_pixels = (dev->sensor.sensor_pixels*dev->calib_resolution)/dev->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 = %d\n", __func__, (int)dev->calib_lines); + DBG(DBG_io, "%s: calib_pixels = %d\n", __func__, (int)dev->calib_pixels); /* this is aworkaround insufficent distance for slope * motor acceleration TODO special motor slope for shading */ @@ -2426,14 +2358,14 @@ gl847_init_regs_for_shading (Genesys_Device * dev) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } status = dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL847_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2458,11 +2390,10 @@ gl847_init_regs_for_scan (Genesys_Device * dev) SANE_Status status; - DBG (DBG_info, - "gl847_init_regs_for_scan settings:\nResolution: %uDPI\n" - "Lines : %u\nPPL : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", - dev->settings.yres, dev->settings.lines, dev->settings.pixels, - dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); + DBG(DBG_info, "%s settings:\nResolution: %uDPI\n" + "Lines : %u\nPPL : %u\nStartpos : %.3f/%.3f\nScan mode : %d\n\n", __func__, + dev->settings.yres, dev->settings.lines, dev->settings.pixels, + dev->settings.tl_x, dev->settings.tl_y, dev->settings.scan_mode); /* channels */ if (dev->settings.scan_mode == SCAN_MODE_COLOR) /* single pass color */ @@ -2501,7 +2432,7 @@ gl847_init_regs_for_scan (Genesys_Device * dev) move += dev->settings.tl_y; move = (move * move_dpi) / MM_PER_INCH; move -= dev->scanhead_position_in_steps; - DBG (DBG_info, "%s: move=%f steps\n",__func__, move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* fast move to scan area */ /* we don't move fast the whole distance since it would involve @@ -2513,14 +2444,14 @@ gl847_init_regs_for_scan (Genesys_Device * dev) status = gl847_feed (dev, move-500); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to move to scan area\n",__func__); + DBG(DBG_error, "%s: failed to move to scan area\n", __func__); return status; } move=500; } - DBG (DBG_info, "gl847_init_regs_for_scan: move=%f steps\n", move); - DBG (DBG_info, "%s: move=%f steps\n", __func__, move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); + DBG(DBG_info, "%s: move=%f steps\n", __func__, move); /* start */ start = SANE_UNFIX (dev->model->x_offset); @@ -2575,7 +2506,7 @@ gl847_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) uint8_t val,*buffer,*ptr,*src; DBGSTART; - DBG( DBG_io2, "%s: writing %d bytes of shading data\n",__func__,size); + DBG(DBG_io2, "%s: writing %d bytes of shading data\n", __func__, size); /* shading data is plit in 3 (up to 5 with IR) areas write(0x10014000,0x00000dd8) @@ -2592,10 +2523,11 @@ gl847_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* compute deletion factor */ sanei_genesys_get_double(dev->reg,REG_DPISET,&tempo); dpiset=tempo; - DBG( DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n",__func__,strpixel,endpixel,endpixel-strpixel,dpiset); + DBG(DBG_io2, "%s: STRPIXEL=%d, ENDPIXEL=%d, PIXELS=%d, DPISET=%d\n", __func__, strpixel, endpixel, + endpixel-strpixel, dpiset); dpihw=sanei_genesys_compute_dpihw(dev,dpiset); factor=dpihw/dpiset; - DBG( DBG_io2, "%s: factor=%d\n",__func__,factor); + DBG(DBG_io2, "%s: factor=%d\n", __func__, factor); if(DBG_LEVEL>=DBG_data) { @@ -2620,7 +2552,7 @@ gl847_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) /* allocate temporary buffer */ buffer=(uint8_t *)malloc(pixels); memset(buffer,0,pixels); - DBG( DBG_io2, "%s: using chunks of %d (0x%04x) bytes\n",__func__,pixels,pixels); + DBG(DBG_io2, "%s: using chunks of %d (0x%04x) bytes\n", __func__, pixels, pixels); /* base addr of data has been written in reg D0-D4 in 4K word, so AHB address * is 8192*reg value */ @@ -2653,8 +2585,7 @@ gl847_send_shading_data (Genesys_Device * dev, uint8_t * data, int size) status = sanei_genesys_write_ahb (dev->dn, dev->usb_mode, addr, pixels, buffer); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "gl847_send_shading_data; write to AHB failed (%s)\n", - sane_strstatus (status)); + DBG(DBG_error, "%s; write to AHB failed (%s)\n", __func__, sane_strstatus(status)); return status; } } @@ -2697,7 +2628,7 @@ gl847_led_calibration (Genesys_Device * dev) { RIE(gl847_feed (dev, move)); } - DBG (DBG_io, "%s: move=%f steps\n", __func__, move); + DBG(DBG_io, "%s: move=%f steps\n", __func__, move); /* offset calibration is always done in color mode */ channels = 3; @@ -2727,7 +2658,7 @@ gl847_led_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -2763,7 +2694,7 @@ gl847_led_calibration (Genesys_Device * dev) /* write registers and scan data */ RIEF (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL847_MAX_REGS), line); - DBG (DBG_info, "gl847_led_calibration: starting line reading\n"); + DBG(DBG_info, "%s: starting line reading\n", __func__); RIEF (gl847_begin_scan (dev, dev->calib_reg, SANE_TRUE), line); RIEF (sanei_genesys_read_data_from_scanner (dev, line, total_size), line); @@ -2796,7 +2727,7 @@ gl847_led_calibration (Genesys_Device * dev) avg[j] /= num_pixels; } - DBG (DBG_info, "gl847_led_calibration: average: %d,%d,%d\n", avg[0], avg[1], avg[2]); + DBG(DBG_info, "%s: average: %d,%d,%d\n", __func__, avg[0], avg[1], avg[2]); /* check if exposure gives average within the boundaries */ acceptable = SANE_TRUE; @@ -2818,7 +2749,7 @@ gl847_led_calibration (Genesys_Device * dev) } while (!acceptable && turn < 100); - DBG (DBG_info, "gl847_led_calibration: acceptable exposure: %d,%d,%d\n", exp[0], exp[1], exp[2]); + DBG(DBG_info, "%s: acceptable exposure: %d,%d,%d\n", __func__, exp[0], exp[1], exp[2]); /* set these values as final ones for scan */ sanei_genesys_set_double(dev->reg,REG_EXPR,exp[0]); @@ -2864,7 +2795,8 @@ gl847_init_gpio (Genesys_Device * dev) } if(gpios[idx].sensor_id==0) { - DBG (DBG_error, "%s: failed to find GPIO profile for sensor_id=%d\n", __func__, dev->model->ccd_type); + DBG(DBG_error, "%s: failed to find GPIO profile for sensor_id=%d\n", __func__, + dev->model->ccd_type); return SANE_STATUS_INVAL; } @@ -2897,7 +2829,7 @@ gl847_init_memory_layout (Genesys_Device * dev) int idx = 0; uint8_t val; - DBG (DBG_proc, "gl847_init_memory_layout\n"); + DBG(DBG_proc, "%s\n" , __func__); /* point to per model memory layout */ idx = 0; @@ -2999,7 +2931,7 @@ gl847_boot (Genesys_Device * dev, SANE_Bool cold) if (val & REG40_CHKVER) { RIE (sanei_genesys_read_register (dev, 0x00, &val)); - DBG (DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); + DBG(DBG_info, "%s: reported version for genesys chip is 0x%02x\n", __func__, val); } /* Set default values for registers */ @@ -3111,16 +3043,13 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) char title[80]; Genesys_Register_Set *r; - DBG (DBG_proc, "gl847_search_strip %s %s\n", black ? "black" : "white", - forward ? "forward" : "reverse"); + DBG(DBG_proc, "%s %s %s\n", __func__, black ? "black" : "white", forward ? "forward" : "reverse"); gl847_set_fe (dev, AFE_SET); status = gl847_stop_action (dev); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_search_strip: failed to stop: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to stop: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3142,7 +3071,7 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) data = malloc (size); if (!data) { - DBG (DBG_error, "gl847_search_strip: failed to allocate memory\n"); + DBG(DBG_error, "%s: failed to allocate memory\n", __func__); return SANE_STATUS_NO_MEM; } dev->scanhead_position_in_steps = 0; @@ -3166,9 +3095,7 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free(data); - DBG (DBG_error, - "gl847_search_strip: failed to setup for scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup for scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3184,9 +3111,7 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free(data); - DBG (DBG_error, - "gl847_search_strip: Failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3194,9 +3119,7 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl847_search_strip: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3210,9 +3133,7 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl847_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3220,7 +3141,7 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, "gl847_search_strip: gl847_stop_action failed\n"); + DBG(DBG_error, "%s: gl847_stop_action failed\n", __func__); return status; } @@ -3241,9 +3162,8 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) dev->model->cmd_set->bulk_write_register (dev, local_reg, GENESYS_GL847_MAX_REGS); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_search_strip: Failed to bulk write registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: Failed to bulk write registers: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -3252,9 +3172,7 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl847_search_strip: failed to begin scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to begin scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3268,9 +3186,7 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, - "gl847_search_start_position: failed to read data: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read data: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3278,7 +3194,7 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (status != SANE_STATUS_GOOD) { free (data); - DBG (DBG_error, "gl847_search_strip: gl847_stop_action failed\n"); + DBG(DBG_error, "%s: gl847_stop_action failed\n", __func__); return status; } @@ -3320,15 +3236,13 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / pixels < 3) { found = 1; - DBG (DBG_data, - "gl847_search_strip: strip found forward during pass %d at line %d\n", - pass, y); + DBG(DBG_data, "%s: strip found forward during pass %d at line %d\n", __func__, + pass, y); } else { - DBG (DBG_data, - "gl847_search_strip: pixels=%d, count=%d (%d%%)\n", - pixels, count, (100 * count) / pixels); + DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, + (100 * count) / pixels); } } } @@ -3359,15 +3273,12 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if ((count * 100) / (pixels * lines) < 3) { found = 1; - DBG (DBG_data, - "gl847_search_strip: strip found backward during pass %d \n", - pass); + DBG(DBG_data, "%s: strip found backward during pass %d \n", __func__, pass); } else { - DBG (DBG_data, - "gl847_search_strip: pixels=%d, count=%d (%d%%)\n", - pixels, count, (100 * count) / pixels); + DBG(DBG_data, "%s: pixels=%d, count=%d (%d%%)\n", __func__, pixels, count, + (100 * count) / pixels); } } pass++; @@ -3376,14 +3287,12 @@ gl847_search_strip (Genesys_Device * dev, SANE_Bool forward, SANE_Bool black) if (found) { status = SANE_STATUS_GOOD; - DBG (DBG_info, "gl847_search_strip: %s strip found\n", - black ? "black" : "white"); + DBG(DBG_info, "%s: %s strip found\n", __func__, black ? "black" : "white"); } else { status = SANE_STATUS_UNSUPPORTED; - DBG (DBG_info, "gl847_search_strip: %s strip not found\n", - black ? "black" : "white"); + DBG(DBG_info, "%s: %s strip not found\n", __func__, black ? "black" : "white"); } DBGCOMPLETED; @@ -3417,13 +3326,13 @@ dark_average (uint8_t * data, unsigned int pixels, unsigned int lines, } if (count) avg[k] /= count; - DBG (DBG_info, "dark_average: avg[%d] = %d\n", k, avg[k]); + DBG(DBG_info, "%s: avg[%d] = %d\n", __func__, k, avg[k]); } average = 0; for (i = 0; i < channels; i++) average += avg[i]; average /= channels; - DBG (DBG_info, "dark_average: average = %d\n", average); + DBG(DBG_info, "%s: average = %d\n", __func__, average); return average; } @@ -3456,7 +3365,7 @@ gl847_offset_calibration (Genesys_Device * dev) bpp=8; pixels= (dev->sensor.sensor_pixels*resolution) / dev->sensor.optical_res; black_pixels = (dev->sensor.black_pixels * resolution) / dev->sensor.optical_res; - DBG (DBG_io2, "gl847_offset_calibration: black_pixels=%d\n", black_pixels); + DBG(DBG_io2, "%s: black_pixels=%d\n", __func__, black_pixels); status = gl847_init_scan_regs (dev, dev->calib_reg, @@ -3475,9 +3384,7 @@ gl847_offset_calibration (Genesys_Device * dev) SCAN_FLAG_IGNORE_LINE_DISTANCE); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_offset_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } gl847_set_motor_power (dev->calib_reg, SANE_FALSE); @@ -3509,7 +3416,7 @@ gl847_offset_calibration (Genesys_Device * dev) RIEF2 (gl847_set_fe(dev, AFE_SET),first_line, second_line); RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL847_MAX_REGS),first_line, second_line); - DBG (DBG_info, "gl847_offset_calibration: starting first line reading\n"); + DBG(DBG_info, "%s: starting first line reading\n", __func__); RIEF2 (gl847_begin_scan (dev, dev->calib_reg, SANE_TRUE),first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, first_line, total_size),first_line, second_line); if (DBG_LEVEL >= DBG_data) @@ -3519,7 +3426,7 @@ gl847_offset_calibration (Genesys_Device * dev) } bottomavg = dark_average (first_line, pixels, lines, channels, black_pixels); - DBG (DBG_io2, "gl847_offset_calibration: bottom avg=%d\n", bottomavg); + DBG(DBG_io2, "%s: bottom avg=%d\n", __func__, bottomavg); /* now top value */ top = 255; @@ -3528,12 +3435,12 @@ gl847_offset_calibration (Genesys_Device * dev) dev->frontend.offset[2] = top; RIEF2 (gl847_set_fe(dev, AFE_SET),first_line, second_line); RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL847_MAX_REGS),first_line, second_line); - DBG (DBG_info, "gl847_offset_calibration: starting second line reading\n"); + DBG(DBG_info, "%s: starting second line reading\n", __func__); RIEF2 (gl847_begin_scan (dev, dev->calib_reg, SANE_TRUE),first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size),first_line, second_line); topavg = dark_average (second_line, pixels, lines, channels, black_pixels); - DBG (DBG_io2, "gl847_offset_calibration: top avg=%d\n", topavg); + DBG(DBG_io2, "%s: top avg=%d\n", __func__, topavg); /* loop until acceptable level */ while ((pass < 32) && (top - bottom > 1)) @@ -3548,7 +3455,7 @@ gl847_offset_calibration (Genesys_Device * dev) /* scan with no move */ RIEF2 (gl847_set_fe(dev, AFE_SET),first_line, second_line); RIEF2 (dev->model->cmd_set->bulk_write_register (dev, dev->calib_reg, GENESYS_GL847_MAX_REGS),first_line, second_line); - DBG (DBG_info, "gl847_offset_calibration: starting second line reading\n"); + DBG(DBG_info, "%s: starting second line reading\n", __func__); RIEF2 (gl847_begin_scan (dev, dev->calib_reg, SANE_TRUE),first_line, second_line); RIEF2 (sanei_genesys_read_data_from_scanner (dev, second_line, total_size),first_line, second_line); @@ -3559,8 +3466,7 @@ gl847_offset_calibration (Genesys_Device * dev) } avg = dark_average (second_line, pixels, lines, channels, black_pixels); - DBG (DBG_info, "gl847_offset_calibration: avg=%d offset=%d\n", avg, - dev->frontend.offset[1]); + DBG(DBG_info, "%s: avg=%d offset=%d\n", __func__, avg, dev->frontend.offset[1]); /* compute new boundaries */ if (topavg == avg) @@ -3574,7 +3480,8 @@ gl847_offset_calibration (Genesys_Device * dev) bottom = dev->frontend.offset[1]; } } - DBG (DBG_info, "gl847_offset_calibration: offset=(%d,%d,%d)\n", dev->frontend.offset[0], dev->frontend.offset[1], dev->frontend.offset[2]); + DBG(DBG_info, "%s: offset=(%d,%d,%d)\n", __func__, dev->frontend.offset[0], + dev->frontend.offset[1], dev->frontend.offset[2]); /* cleanup before return */ free (first_line); @@ -3598,7 +3505,7 @@ gl847_coarse_gain_calibration (Genesys_Device * dev, int dpi) int resolution; int bpp; - DBG (DBG_proc, "gl847_coarse_gain_calibration: dpi = %d\n", dpi); + DBG(DBG_proc, "%s: dpi = %d\n", __func__, dpi); /* no gain nor offset for AKM AFE */ RIE (sanei_genesys_read_register (dev, REG04, ®04)); @@ -3646,9 +3553,7 @@ gl847_coarse_gain_calibration (Genesys_Device * dev, int dpi) if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "gl847_coarse_calibration: failed to setup scan: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to setup scan: %s\n", __func__, sane_strstatus(status)); return status; } @@ -3707,9 +3612,8 @@ gl847_coarse_gain_calibration (Genesys_Device * dev, int dpi) code = 0; dev->frontend.gain[j] = code; - DBG (DBG_proc, - "gl847_coarse_gain_calibration: channel %d, max=%d, gain = %f, setting:%d\n", - j, max[j], gain[j], dev->frontend.gain[j]); + DBG(DBG_proc, "%s: channel %d, max=%d, gain = %f, setting:%d\n", __func__, j, max[j], gain[j], + dev->frontend.gain[j]); } if (dev->model->is_cis) diff --git a/backend/genesys_low.c b/backend/genesys_low.c index c94fcf40c..a15103680 100644 --- a/backend/genesys_low.c +++ b/backend/genesys_low.c @@ -91,16 +91,14 @@ sanei_genesys_write_pnm_file (char *filename, uint8_t * data, int depth, FILE *out; int count; - DBG (DBG_info, - "sanei_genesys_write_pnm_file: depth=%d, channels=%d, ppl=%d, lines=%d\n", - depth, channels, pixels_per_line, lines); + DBG(DBG_info, "%s: depth=%d, channels=%d, ppl=%d, lines=%d\n", __func__,depth, channels, + pixels_per_line, lines); out = fopen (filename, "w"); if (!out) { - DBG (DBG_error, - "sanei_genesys_write_pnm_file: could nor open %s for writing: %s\n", - filename, strerror (errno)); + DBG(DBG_error, "%s: could nor open %s for writing: %s\n", __func__, filename, + strerror(errno)); return SANE_STATUS_INVAL; } if(depth==1) @@ -149,7 +147,7 @@ sanei_genesys_write_pnm_file (char *filename, uint8_t * data, int depth, } fclose (out); - DBG (DBG_proc, "sanei_genesys_write_pnm_file: finished\n"); + DBG(DBG_proc, "%s: finished\n", __func__); return SANE_STATUS_GOOD; } @@ -214,12 +212,12 @@ sanei_genesys_write_hregister (Genesys_Device * dev, uint16_t reg, uint8_t val) 0x100 | VALUE_SET_REGISTER, INDEX, 2, buffer); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sanei_genesys_write_hregister (0x%02x, 0x%02x): failed : %s\n", reg, val, sane_strstatus (status)); + DBG(DBG_error, "%s (0x%02x, 0x%02x): failed : %s\n", __func__, reg, val, + sane_strstatus(status)); return status; } - DBG (DBG_io, "sanei_genesys_write_hregister (0x%02x, 0x%02x) completed\n", - reg, val); + DBG(DBG_io, "%s (0x%02x, 0x%02x) completed\n", __func__, reg, val); return status; } @@ -242,18 +240,17 @@ sanei_genesys_read_hregister (Genesys_Device * dev, uint16_t reg, uint8_t * val) 0x100 | VALUE_GET_REGISTER, 0x22+((reg & 0xff)<<8), 2, value); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_read_hregister (0x%02x): failed while reading register: %s\n", - reg, sane_strstatus (status)); + DBG(DBG_error, "%s (0x%02x): failed while reading register: %s\n", __func__, reg, + sane_strstatus(status)); return status; } *val=value[0]; - DBG( DBG_io2, "sanei_genesys_read_hregister(0x%02x)=0x%02x\n",reg,*val); + DBG(DBG_io2, "%s(0x%02x)=0x%02x\n", __func__, reg, *val); /* check usb link status */ if((value[1] & 0xff) != 0x55) { - DBG (DBG_error,"sanei_genesys_read_hregister: invalid read, scanner unplugged ?\n"); + DBG(DBG_error,"%s: invalid read, scanner unplugged ?\n", __func__); status=SANE_STATUS_IO_ERROR; } return status; @@ -276,12 +273,12 @@ sanei_genesys_write_gl847_register (Genesys_Device * dev, uint8_t reg, uint8_t v VALUE_SET_REGISTER, INDEX, 2, buffer); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sanei_genesys_write_gl847_register (0x%02x, 0x%02x): failed : %s\n", reg, val, sane_strstatus (status)); + DBG(DBG_error, "%s (0x%02x, 0x%02x): failed : %s\n", __func__, reg, val, + sane_strstatus(status)); return status; } - DBG (DBG_io, "sanei_genesys_write_gl847_register (0x%02x, 0x%02x) completed\n", - reg, val); + DBG(DBG_io, "%s (0x%02x, 0x%02x) completed\n", __func__, reg, val); return status; } @@ -316,9 +313,8 @@ sanei_genesys_write_register (Genesys_Device * dev, uint16_t reg, uint8_t val) VALUE_SET_REGISTER, INDEX, 1, ®8); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_write_register (0x%02x, 0x%02x): failed while setting register: %s\n", - reg, val, sane_strstatus (status)); + DBG(DBG_error, "%s (0x%02x, 0x%02x): failed while setting register: %s\n", __func__, reg, val, + sane_strstatus(status)); return status; } @@ -327,14 +323,12 @@ sanei_genesys_write_register (Genesys_Device * dev, uint16_t reg, uint8_t val) VALUE_WRITE_REGISTER, INDEX, 1, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_write_register (0x%02x, 0x%02x): failed while writing register value: %s\n", - reg, val, sane_strstatus (status)); + DBG(DBG_error, "%s (0x%02x, 0x%02x): failed while writing register value: %s\n", __func__, + reg, val, sane_strstatus(status)); return status; } - DBG (DBG_io, "sanei_genesys_write_register (0x%02x, 0x%02x) completed\n", - reg, val); + DBG(DBG_io, "%s (0x%02x, 0x%02x) completed\n", __func__, reg, val); return status; } @@ -352,15 +346,14 @@ sanei_genesys_write_0x8c (Genesys_Device * dev, uint8_t index, uint8_t val) { SANE_Status status; - DBG (DBG_io, "sanei_genesys_write_0x8c: 0x%02x,0x%02x\n", index, val); + DBG(DBG_io, "%s: 0x%02x,0x%02x\n", __func__, index, val); status = sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_BUF_ENDACCESS, index, 1, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_write_0x8c: failed %s\n", sane_strstatus (status)); + DBG(DBG_error, "%s: failed %s\n", __func__, sane_strstatus(status)); } return status; } @@ -379,18 +372,17 @@ sanei_genesys_read_gl847_register (Genesys_Device * dev, uint16_t reg, uint8_t * VALUE_GET_REGISTER, 0x22+(reg<<8), 2, value); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_read_gl847_register (0x%02x): failed while setting register: %s\n", - reg, sane_strstatus (status)); + DBG(DBG_error, "%s (0x%02x): failed while setting register: %s\n", __func__, reg, + sane_strstatus(status)); return status; } *val=value[0]; - DBG( DBG_io2, "sanei_genesys_read_gl847_register(0x%02x)=0x%02x\n",reg,*val); + DBG(DBG_io2, "%s(0x%02x)=0x%02x\n", __func__, reg, *val); /* check usb link status */ if((value[1] & 0xff) != 0x55) { - DBG (DBG_error,"sanei_genesys_read_gl847_register: invalid read, scanner unplugged ?\n"); + DBG(DBG_error,"%s: invalid read, scanner unplugged ?\n", __func__); status=SANE_STATUS_IO_ERROR; } return status; @@ -423,9 +415,8 @@ sanei_genesys_read_register (Genesys_Device * dev, uint16_t reg, uint8_t * val) VALUE_SET_REGISTER, INDEX, 1, ®8); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_read_register (0x%02x, 0x%02x): failed while setting register: %s\n", - reg, *val, sane_strstatus (status)); + DBG(DBG_error, "%s (0x%02x, 0x%02x): failed while setting register: %s\n", __func__, + reg, *val, sane_strstatus(status)); return status; } @@ -436,14 +427,12 @@ sanei_genesys_read_register (Genesys_Device * dev, uint16_t reg, uint8_t * val) VALUE_READ_REGISTER, INDEX, 1, val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_read_register (0x%02x, 0x%02x): failed while reading register value: %s\n", - reg, *val, sane_strstatus (status)); + DBG(DBG_error, "%s (0x%02x, 0x%02x): failed while reading register value: %s\n", __func__, + reg, *val, sane_strstatus(status)); return status; } - DBG (DBG_io, "sanei_genesys_read_register (0x%02x, 0x%02x) completed\n", - reg, *val); + DBG(DBG_io, "%s (0x%02x, 0x%02x) completed\n", __func__, reg, *val); return status; } @@ -459,23 +448,18 @@ sanei_genesys_set_buffer_address (Genesys_Device * dev, uint32_t addr) || dev->model->asic_type==GENESYS_GL846 || dev->model->asic_type==GENESYS_GL124) { - DBG (DBG_warn, - "sanei_genesys_set_buffer_address: shouldn't be used for GL846+ ASICs\n"); + DBG(DBG_warn, "%s: shouldn't be used for GL846+ ASICs\n", __func__); return SANE_STATUS_GOOD; } - DBG (DBG_io, - "sanei_genesys_set_buffer_address: setting address to 0x%05x\n", - addr & 0xfffffff0); + DBG(DBG_io, "%s: setting address to 0x%05x\n", __func__, addr & 0xfffffff0); addr = addr >> 4; status = sanei_genesys_write_register (dev, 0x2b, (addr & 0xff)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_set_buffer_address: failed while writing low byte: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing low byte: %s\n", __func__, sane_strstatus(status)); return status; } @@ -483,13 +467,11 @@ sanei_genesys_set_buffer_address (Genesys_Device * dev, uint32_t addr) status = sanei_genesys_write_register (dev, 0x2a, (addr & 0xff)); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_set_buffer_address: failed while writing high byte: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while writing high byte: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_io, "sanei_genesys_set_buffer_address: completed\n"); + DBG(DBG_io, "%s: completed\n", __func__); return status; } @@ -509,7 +491,7 @@ sanei_genesys_fe_read_data (Genesys_Device * dev, uint8_t addr, Genesys_Register_Set reg[1]; - DBG (DBG_proc, "sanei_genesys_fe_read_data: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); reg[0].address = 0x50; reg[0].value = addr; @@ -518,9 +500,8 @@ sanei_genesys_fe_read_data (Genesys_Device * dev, uint8_t addr, status = dev->model->cmd_set->bulk_write_register (dev, reg, 1); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_fe_read_data: failed while bulk writing registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while bulk writing registers: %s\n", __func__, + sane_strstatus(status)); return status; } @@ -530,8 +511,8 @@ sanei_genesys_fe_read_data (Genesys_Device * dev, uint8_t addr, RIE (sanei_genesys_read_register (dev, 0x47, &value)); *data+=value; - DBG (DBG_io, "sanei_genesys_fe_read_data (0x%02x, 0x%04x)\n", addr, *data); - DBG (DBG_proc, "sanei_genesys_fe_read_data: completed\n"); + DBG(DBG_io, "%s (0x%02x, 0x%04x)\n", __func__, addr, *data); + DBG(DBG_proc, "%s: completed\n", __func__); return status; } @@ -550,7 +531,7 @@ sanei_genesys_fe_write_data (Genesys_Device * dev, uint8_t addr, SANE_Status status; Genesys_Register_Set reg[3]; - DBG (DBG_io, "sanei_genesys_fe_write_data (0x%02x, 0x%04x)\n", addr, data); + DBG(DBG_io, "%s (0x%02x, 0x%04x)\n", __func__, addr, data); reg[0].address = 0x51; reg[0].value = addr; @@ -567,13 +548,12 @@ sanei_genesys_fe_write_data (Genesys_Device * dev, uint8_t addr, status = dev->model->cmd_set->bulk_write_register (dev, reg, 3); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_fe_write_data: failed while bulk writing registers: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while bulk writing registers: %s\n", __func__, + sane_strstatus(status)); return status; } - DBG (DBG_io, "sanei_genesys_fe_write_data: completed\n"); + DBG(DBG_io, "%s: completed\n", __func__); return status; } @@ -609,7 +589,7 @@ void sanei_genesys_print_status (uint8_t val) val & LAMPSTS ? "LAMPSTS " : "", val & FEBUSY ? "FEBUSY " : "", val & MOTORENB ? "MOTORENB" : ""); - DBG (DBG_info, "status=%s\n", msg); + DBG(DBG_info, "status=%s\n", msg); } #if 0 @@ -706,7 +686,7 @@ sanei_genesys_read_valid_words (Genesys_Device * dev, unsigned int *words) *words += ((value & 0x0f) * 256 * 256); } - DBG (DBG_proc, "%s: %d words\n", __func__, *words); + DBG(DBG_proc, "%s: %d words\n", __func__, *words); DBGCOMPLETED; return SANE_STATUS_GOOD; } @@ -720,7 +700,7 @@ sanei_genesys_read_scancnt (Genesys_Device * dev, unsigned int *words) SANE_Status status; uint8_t value; - DBG (DBG_proc, "sanei_genesys_read_scancnt: start\n"); + DBG(DBG_proc, "%s: start\n", __func__); if (dev->model->asic_type == GENESYS_GL124) { @@ -744,7 +724,7 @@ sanei_genesys_read_scancnt (Genesys_Device * dev, unsigned int *words) *words += ((value & 0x0f) * 256 * 256); } - DBG (DBG_proc, "sanei_genesys_read_scancnt: %d lines\n", *words); + DBG(DBG_proc, "%s: %d lines\n", __func__, *words); return SANE_STATUS_GOOD; } @@ -764,7 +744,8 @@ sanei_genesys_get_address (Genesys_Register_Set * regs, uint16_t addr) if (regs[i].address == addr) return ®s[i]; } - DBG (DBG_error, "sanei_genesys_get_address: failed to find address for register 0x%02x, crash expected !\n",addr); + DBG(DBG_error, "%s: failed to find address for register 0x%02x, crash expected !\n", __func__, + addr); return NULL; } @@ -927,9 +908,7 @@ sanei_genesys_test_buffer_empty (Genesys_Device * dev, SANE_Bool * empty) status = sanei_genesys_get_status (dev, &val); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_test_buffer_empty: failed to read buffer status: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed to read buffer status: %s\n", __func__, sane_strstatus(status)); return status; } @@ -939,14 +918,14 @@ sanei_genesys_test_buffer_empty (Genesys_Device * dev, SANE_Bool * empty) * spotted by John S. Weber */ usleep(1000); - DBG (DBG_io2, "sanei_genesys_test_buffer_empty: buffer is empty\n"); + DBG(DBG_io2, "%s: buffer is empty\n", __func__); *empty = SANE_TRUE; return SANE_STATUS_GOOD; } *empty = SANE_FALSE; - DBG (DBG_io, "sanei_genesys_test_buffer_empty: buffer is filled\n"); + DBG(DBG_io, "%s: buffer is filled\n", __func__); return SANE_STATUS_GOOD; } @@ -960,12 +939,10 @@ sanei_genesys_read_data_from_scanner (Genesys_Device * dev, uint8_t * data, int time_count = 0; unsigned int words = 0; - DBG (DBG_proc, "sanei_genesys_read_data_from_scanner (size = %lu bytes)\n", - (u_long) size); + DBG(DBG_proc, "%s (size = %lu bytes)\n", __func__, (u_long) size); if (size & 1) - DBG (DBG_info, - "WARNING sanei_genesys_read_data_from_scanner: odd number of bytes\n"); + DBG(DBG_info, "WARNING %s: odd number of bytes\n", __func__); /* wait until buffer not empty for up to 5 seconds */ do @@ -973,9 +950,8 @@ sanei_genesys_read_data_from_scanner (Genesys_Device * dev, uint8_t * data, status = sanei_genesys_read_valid_words (dev, &words); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_read_data_from_scanner: checking for empty buffer failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: checking for empty buffer failed: %s\n", __func__, + sane_strstatus(status)); return status; } if (words == 0) @@ -988,21 +964,18 @@ sanei_genesys_read_data_from_scanner (Genesys_Device * dev, uint8_t * data, if (words == 0) /* timeout, buffer does not get filled */ { - DBG (DBG_error, - "sanei_genesys_read_data_from_scanner: timeout, buffer does not get filled\n"); + DBG(DBG_error, "%s: timeout, buffer does not get filled\n", __func__); return SANE_STATUS_IO_ERROR; } status = dev->model->cmd_set->bulk_read_data (dev, 0x45, data, size); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, - "sanei_genesys_read_data_from_scanner: reading bulk data failed: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: reading bulk data failed: %s\n", __func__, sane_strstatus(status)); return status; } - DBG (DBG_proc, "sanei_genesys_read_data_from_scanner: completed\n"); + DBG(DBG_proc, "%s: completed\n", __func__); return SANE_STATUS_GOOD; } SANE_Status @@ -1011,7 +984,7 @@ sanei_genesys_read_feed_steps (Genesys_Device * dev, unsigned int *steps) SANE_Status status; uint8_t value; - DBG (DBG_proc, "sanei_genesys_read_feed_steps\n"); + DBG(DBG_proc, "%s\n", __func__); if (dev->model->asic_type == GENESYS_GL124) { @@ -1037,7 +1010,7 @@ sanei_genesys_read_feed_steps (Genesys_Device * dev, unsigned int *steps) *steps += ((value & 0x1f) * 256 * 256); } - DBG (DBG_proc, "sanei_genesys_read_feed_steps: %d steps\n", *steps); + DBG(DBG_proc, "%s: %d steps\n", __func__, *steps); return SANE_STATUS_GOOD; } @@ -1122,8 +1095,8 @@ sanei_genesys_write_ahb (SANE_Int dn, int usb_mode, uint32_t addr, uint32_t size 0x01, 8, outdata); if (status != SANE_STATUS_GOOD) { - DBG (DBG_error, "sanei_genesys_write_ahb: failed while setting addr and size: %s\n", - sane_strstatus (status)); + DBG(DBG_error, "%s: failed while setting addr and size: %s\n", __func__, + sane_strstatus(status)); return status; }