Lines Matching refs:sp

141 static int scanner_setup_params(unsigned char *buf, scanner_parameters *sp,
268 int sanei_canon_pp_init_scan(scanner_parameters *sp, scan_parameters *scanp)
288 scanner_setup_params(command_b+10, sp, scanp);
293 if (send_command(sp->port, command_b, 56, 50000, 1000000))
297 if (send_command(sp->port, cmd_buf_status, 10, 50000, 1000000))
301 sanei_canon_pp_read(sp->port, 6, buffer_info_block);
349 /* Wake the scanner, detect it, and fill sp with stuff */
350 int sanei_canon_pp_initialise(scanner_parameters *sp, int mode)
357 if (sanei_canon_pp_wake_scanner(sp->port, mode))
365 if (sanei_canon_pp_scanner_init(sp->port))
370 if (sanei_canon_pp_scanner_init(sp->port))
379 memset(sp->id_string, 0, sizeof sp->id_string);
380 if (send_command(sp->port, cmd_readid, 10, 10000, 100000))
382 sanei_canon_pp_read(sp->port, 38, (unsigned char *)(sp->id_string));
385 if (send_command(sp->port, cmd_readinfo, 10, 10000, 100000))
387 sanei_canon_pp_read(sp->port, 12, scanner_info);
395 sp->scanheadwidth = (scanner_info[2] << 8) | scanner_info[3];
401 if (!strncmp(sp->id_string+8, cur_id->id, strlen(cur_id->id)))
410 else if (sp->scanheadwidth == 5104)
415 else if (sp->scanheadwidth == 2552)
426 strcpy(sp->name, hw->name);
427 sp->natural_xresolution = hw->natural_xresolution;
428 sp->natural_yresolution = hw->natural_yresolution;
429 sp->scanbedlength = hw->scanbedlength;
431 sp->scanheadwidth = hw->scanheadwidth;
432 sp->type = hw->type;
438 int sanei_canon_pp_close_scanner(scanner_parameters *sp)
441 sanei_canon_pp_sleep_scanner(sp->port);
444 if (sp->blackweight != NULL)
446 free(sp->blackweight);
447 sp->blackweight = NULL;
449 if (sp->redweight != NULL)
451 free(sp->redweight);
452 sp->redweight = NULL;
454 if (sp->greenweight != NULL)
456 free(sp->greenweight);
457 sp->greenweight = NULL;
459 if (sp->blueweight != NULL)
461 free(sp->blueweight);
462 sp->blueweight = NULL;
469 int sanei_canon_pp_load_weights(const char *filename, scanner_parameters *sp)
472 int cal_data_size = sp->scanheadwidth * sizeof(unsigned long);
503 if (((sp->blueweight = malloc(cal_data_size)) == NULL)
504 || ((sp->redweight = malloc(cal_data_size)) == NULL)
505 || ((sp->greenweight = malloc(cal_data_size)) == NULL)
506 || ((sp->blackweight = malloc(cal_data_size)) == NULL))
512 if ((ret < 0) || (cal_file_size != sp->scanheadwidth))
520 if (safe_read(fd, (char *)(sp->blackweight), cal_data_size) < 0)
527 if (safe_read(fd, (char *)sp->redweight, cal_data_size) < 0)
534 if (safe_read(fd, (char *)sp->greenweight, cal_data_size) < 0)
541 if (safe_read(fd, (char *)sp->blueweight, cal_data_size) < 0)
550 if (safe_read(fd, (char *)&(sp->gamma), 32) < 0)
599 int sanei_canon_pp_read_segment(image_segment **dest, scanner_parameters *sp,
657 if (send_command(sp->port, packet_req_command, 10, 9000, 2000000))
665 if (sanei_canon_pp_read(sp->port, 4, packet_header))
684 if (sanei_canon_pp_read(sp->port, read_data_size, input_buffer))
693 if (sp->abort_now) goto error_out;
699 sanei_canon_pp_write(sp->port, 10, packet_req_command);
711 adjust_output(output_image, scanp, sp);
725 sp->abort_now = 0;
928 int sanei_canon_pp_calibrate(scanner_parameters *sp, char *cal_file)
947 scanline_size = sp->scanheadwidth * 1.25;
950 if (!(sp->type) ) scanline_count = 8;
953 if (sp->abort_now) return -1;
957 sp->scanheadwidth, scanline_count,
961 sp->blackweight = (unsigned long *)
962 calloc(sizeof(unsigned long), sp->scanheadwidth);
963 sp->redweight = (unsigned long *)
964 calloc(sizeof(unsigned long), sp->scanheadwidth);
965 sp->greenweight = (unsigned long *)
966 calloc(sizeof(unsigned long), sp->scanheadwidth);
967 sp->blueweight = (unsigned long *)
968 calloc(sizeof(unsigned long), sp->scanheadwidth);
971 * per colour, each sp->scanheadwidth x scanline_count */
975 image.image_data = malloc(scanline_count * sp->scanheadwidth * 2 *
977 image.width = sp->scanheadwidth;
993 if (sp->abort_now) return -1;
995 if (send_command(sp->port, command_buffer, 10, 100000, 5000000))
1005 sanei_canon_pp_read(sp->port, scanline_size * scanline_count,
1017 (scanlinenum * sp->scanheadwidth*2),
1018 sp->scanheadwidth, 1);
1022 for (count = 0; count < sp->scanheadwidth; count++)
1026 sp->blackweight[count] = (column_sum(&image, count) * 6)
1031 if (!(sp->type) )
1039 if (sp->abort_now) return -1;
1040 if (send_command(sp->port, cmd_cleargamma, 10, 100000, 5000000))
1053 if (send_command(sp->port, cmd_readgamma, 10, 100000, 10000000))
1063 sanei_canon_pp_read(sp->port, 32, sp->gamma);
1066 if (sp->abort_now) return -1;
1086 if (sp->abort_now) return -1;
1087 if (send_command(sp->port, command_buffer, 10,
1096 sanei_canon_pp_read(sp->port, scanline_size *
1109 (scanlinenum * sp->scanheadwidth * 2),
1110 sp->scanheadwidth, 1);
1113 /* Sum each column of the image and store the results in sp */
1114 for (count = 0; count < sp->scanheadwidth; count++)
1117 sp->redweight[count] =
1120 sp->greenweight[count] =
1123 sp->blueweight[count] =
1129 if (sp->abort_now) return -1;
1148 if (safe_write(outfile, (char *)&(sp->scanheadwidth),
1149 sizeof(sp->scanheadwidth)) < 0)
1151 if (safe_write(outfile, (char *)(sp->blackweight),
1152 sp->scanheadwidth * sizeof(long)) < 0)
1154 if (safe_write(outfile, (char *)(sp->redweight),
1155 sp->scanheadwidth * sizeof(long)) < 0)
1157 if (safe_write(outfile, (char *)(sp->greenweight),
1158 sp->scanheadwidth * sizeof(long)) < 0)
1160 if (safe_write(outfile, (char *)(sp->blueweight),
1161 sp->scanheadwidth * sizeof(long)) < 0)
1163 if (safe_write(outfile, (char *)(sp->gamma), 32) < 0)
1192 static int scanner_setup_params(unsigned char *buf, scanner_parameters *sp,
1199 if (sp->scanheadwidth == 2552)
1213 (sp->natural_xresolution - scanp->xresolution);
1216 (sp->natural_xresolution - scanp->xresolution);
1218 (sp->natural_xresolution - scanp->xresolution);
1220 (sp->natural_xresolution - scanp->xresolution);
1265 int sanei_canon_pp_abort_scan(scanner_parameters *sp)
1268 sanei_canon_pp_write(sp->port, 10, cmd_abort);
1269 sanei_canon_pp_check_status(sp->port);
1274 int sanei_canon_pp_adjust_gamma(scanner_parameters *sp)
1276 sp->gamma[31] = check8(sp->gamma, 31);
1277 if (sanei_canon_pp_write(sp->port, 10, cmd_setgamma))
1279 if (sanei_canon_pp_write(sp->port, 32, sp->gamma))