Lines Matching full:dev
60 update 2005/07/29. Removed using teco_request_sense (dev) routine for VM3564
544 Teco_Scanner *dev; in teco_init() local
549 dev = malloc (sizeof (Teco_Scanner)); in teco_init()
550 if (dev == NULL) in teco_init()
555 memset (dev, 0, sizeof (Teco_Scanner)); in teco_init()
558 dev->buffer_size = 64 * 1024; in teco_init()
559 dev->buffer = malloc (dev->buffer_size); in teco_init()
560 if (dev->buffer == NULL) in teco_init()
562 free (dev); in teco_init()
566 dev->sfd = -1; in teco_init()
570 return (dev); in teco_init()
575 teco_close (Teco_Scanner * dev) in teco_close() argument
579 if (dev->sfd != -1) in teco_close()
581 sanei_scsi_close (dev->sfd); in teco_close()
582 dev->sfd = -1; in teco_close()
590 teco_free (Teco_Scanner * dev) in teco_free() argument
596 if (dev == NULL) in teco_free()
599 teco_close (dev); in teco_free()
600 if (dev->devicename) in teco_free()
602 free (dev->devicename); in teco_free()
604 if (dev->buffer) in teco_free()
606 free (dev->buffer); in teco_free()
610 if (dev->opt[i].type == SANE_TYPE_STRING && dev->val[i].s) in teco_free()
612 free (dev->val[i].s); in teco_free()
615 if (dev->resolutions_list) in teco_free()
616 free (dev->resolutions_list); in teco_free()
618 free (dev); in teco_free()
625 teco_identify_scanner (Teco_Scanner * dev) in teco_identify_scanner() argument
637 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_identify_scanner()
638 NULL, 0, dev->buffer, &size); in teco_identify_scanner()
648 size = dev->buffer[4] + 5; /* total length of the inquiry data */ in teco_identify_scanner()
726 memcpy (dev->buffer, table, sizeof (table)); in teco_identify_scanner()
732 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_identify_scanner()
733 NULL, 0, dev->buffer, &size); in teco_identify_scanner()
743 hexdump (DBG_info2, "inquiry", dev->buffer, size); in teco_identify_scanner()
745 dev->scsi_type = dev->buffer[0] & 0x1f; in teco_identify_scanner()
746 memcpy (dev->scsi_vendor, dev->buffer + 0x08, 0x08); in teco_identify_scanner()
747 dev->scsi_vendor[0x08] = 0; in teco_identify_scanner()
748 memcpy (dev->scsi_product, dev->buffer + 0x10, 0x010); in teco_identify_scanner()
749 dev->scsi_product[0x10] = 0; in teco_identify_scanner()
750 memcpy (dev->scsi_version, dev->buffer + 0x20, 0x04); in teco_identify_scanner()
751 dev->scsi_version[0x04] = 0; in teco_identify_scanner()
752 memcpy (dev->scsi_teco_name, dev->buffer + 0x2A, 0x0B); in teco_identify_scanner()
753 dev->scsi_teco_name[0x0B] = 0; in teco_identify_scanner()
756 dev->scsi_vendor, dev->scsi_product, dev->scsi_version, in teco_identify_scanner()
757 dev->scsi_teco_name); in teco_identify_scanner()
763 if (dev->scsi_type == scanners[i].scsi_type && in teco_identify_scanner()
764 strcmp (dev->scsi_teco_name, scanners[i].scsi_teco_name) == 0) in teco_identify_scanner()
771 if (strncmp (dev->scsi_vendor, "RELISYS", 1) == 0 || in teco_identify_scanner()
772 strncmp (dev->scsi_vendor, " ", 1) == 0) in teco_identify_scanner()
777 dev->def = &(scanners[i]); in teco_identify_scanner()
788 dev->def = &(scanners[i]); in teco_identify_scanner()
803 teco_set_window (Teco_Scanner * dev) in teco_set_window() argument
815 switch (dev->def->tecoref) in teco_set_window()
842 Ito16 (dev->x_resolution, &window[10]); in teco_set_window()
843 Ito16 (dev->y_resolution, &window[12]); in teco_set_window()
846 Ito32 (dev->x_tl, &window[14]); in teco_set_window()
847 Ito32 (dev->y_tl, &window[18]); in teco_set_window()
850 Ito32 (dev->width, &window[22]); in teco_set_window()
851 Ito32 (dev->length, &window[26]); in teco_set_window()
854 switch (dev->scan_mode) in teco_set_window()
857 window[31] = dev->val[OPT_THRESHOLD].w; in teco_set_window()
859 i = get_string_list_index (dither_list, dev->val[OPT_DITHER].s); in teco_set_window()
871 window[34] = dev->depth; in teco_set_window()
874 i = get_string_list_index (filter_color_list, dev->val[OPT_FILTER_COLOR].s); in teco_set_window()
882 if (dev->def->tecoref == TECO_VM656A || in teco_set_window()
883 dev->def->tecoref == TECO_VM6575 || dev->def->tecoref == TECO_VM6586) in teco_set_window()
886 switch (dev->scan_mode) in teco_set_window()
890 Ito16 (dev->params.bytes_per_line, &window[52]); in teco_set_window()
893 Ito16 (dev->params.bytes_per_line / 3, &window[52]); in teco_set_window()
896 Ito16 (dev->params.lines, &window[54]); in teco_set_window()
902 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_set_window()
912 teco_reset_window (Teco_Scanner * dev) in teco_reset_window() argument
922 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); in teco_reset_window()
936 teco_get_scan_size (Teco_Scanner * dev) in teco_get_scan_size() argument
947 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_get_scan_size()
948 NULL, 0, dev->buffer, &size); in teco_get_scan_size()
952 hexdump (DBG_info2, "teco_get_scan_size return", dev->buffer, size); in teco_get_scan_size()
955 dev->params.lines = B16TOI (&dev->buffer[12]); in teco_get_scan_size()
956 dev->bytes_per_raster = B16TOI (&dev->buffer[14]); in teco_get_scan_size()
958 switch (dev->scan_mode) in teco_get_scan_size()
961 dev->params.bytes_per_line = B16TOI (&dev->buffer[14]); in teco_get_scan_size()
962 dev->params.pixels_per_line = dev->params.bytes_per_line * 8; in teco_get_scan_size()
965 dev->params.pixels_per_line = B16TOI (&dev->buffer[14]); in teco_get_scan_size()
966 dev->params.bytes_per_line = dev->params.pixels_per_line; in teco_get_scan_size()
969 dev->params.pixels_per_line = B16TOI (&dev->buffer[14]); in teco_get_scan_size()
970 dev->params.bytes_per_line = dev->params.pixels_per_line * 3; in teco_get_scan_size()
979 switch (dev->def->tecoref) in teco_get_scan_size()
983 if (dev->scan_mode == TECO_GRAYSCALE) in teco_get_scan_size()
985 dev->params.pixels_per_line = 850; in teco_get_scan_size()
986 dev->params.bytes_per_line = 850; in teco_get_scan_size()
987 dev->params.lines = 1170; in teco_get_scan_size()
988 dev->bytes_per_raster = 850; in teco_get_scan_size()
995 switch (dev->val[OPT_RESOLUTION].w) in teco_get_scan_size()
998 dev->params.pixels_per_line = 425; in teco_get_scan_size()
999 dev->params.lines = 585; in teco_get_scan_size()
1003 dev->params.pixels_per_line = 510; in teco_get_scan_size()
1004 dev->params.lines = 702; in teco_get_scan_size()
1008 dev->params.pixels_per_line = 638; in teco_get_scan_size()
1009 dev->params.lines = 431; in teco_get_scan_size()
1013 dev->params.pixels_per_line = 402; in teco_get_scan_size()
1014 dev->params.lines = 575; in teco_get_scan_size()
1019 dev->params.bytes_per_line = dev->params.pixels_per_line * 3; in teco_get_scan_size()
1020 dev->bytes_per_raster = dev->params.pixels_per_line; in teco_get_scan_size()
1025 switch (dev->val[OPT_RESOLUTION].w) in teco_get_scan_size()
1028 dev->params.pixels_per_line = 297; in teco_get_scan_size()
1029 dev->params.lines = 296; in teco_get_scan_size()
1033 dev->params.pixels_per_line = 1186; in teco_get_scan_size()
1034 dev->params.lines = 1186; in teco_get_scan_size()
1039 dev->params.bytes_per_line = dev->params.pixels_per_line * 3; in teco_get_scan_size()
1040 dev->bytes_per_raster = dev->params.pixels_per_line; in teco_get_scan_size()
1044 s1 = dev->params.bytes_per_line * dev->params.lines; in teco_get_scan_size()
1067 teco_wait_for_data (Teco_Scanner * dev) in teco_wait_for_data() argument
1086 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_wait_for_data()
1087 NULL, 0, dev->buffer, &size); in teco_wait_for_data()
1091 hexdump (DBG_info2, "teco_wait_for_data return", dev->buffer, size); in teco_wait_for_data()
1093 switch (dev->def->tecoref) in teco_wait_for_data()
1097 if (dev->buffer[11] > 0x01) in teco_wait_for_data()
1106 if (dev->buffer[11] == 0x80) in teco_wait_for_data()
1145 teco_do_calibration (Teco_Scanner * dev) in teco_do_calibration() argument
1169 cal_algo = dev->def->cal_algo; in teco_do_calibration()
1180 switch (dev->def->tecoref) in teco_do_calibration()
1186 colsub0_1 = 240 + (dev->val[OPT_WHITE_LEVEL_R].w); in teco_do_calibration()
1187 colsub0_2 = 240 + (dev->val[OPT_WHITE_LEVEL_G].w); in teco_do_calibration()
1188 colsub0_0 = 240 + (dev->val[OPT_WHITE_LEVEL_B].w); in teco_do_calibration()
1190 colsub1_1 = 12720 + (40 * dev->val[OPT_WHITE_LEVEL_R].w); in teco_do_calibration()
1191 colsub1_2 = 12720 + (40 * dev->val[OPT_WHITE_LEVEL_G].w); in teco_do_calibration()
1192 colsub1_0 = 12720 + (40 * dev->val[OPT_WHITE_LEVEL_B].w); in teco_do_calibration()
1197 colsub0_1 = 4096 + (8 * dev->val[OPT_WHITE_LEVEL_R].w); in teco_do_calibration()
1198 colsub0_2 = 4096 + (8 * dev->val[OPT_WHITE_LEVEL_G].w); in teco_do_calibration()
1199 colsub0_0 = 4096 + (8 * dev->val[OPT_WHITE_LEVEL_B].w); in teco_do_calibration()
1201 colsub1_1 = 4078639 + (4000 * dev->val[OPT_WHITE_LEVEL_R].w); in teco_do_calibration()
1202 colsub1_2 = 4078639 + (4000 * dev->val[OPT_WHITE_LEVEL_G].w); in teco_do_calibration()
1203 colsub1_0 = 4078639 + (4000 * dev->val[OPT_WHITE_LEVEL_B].w); in teco_do_calibration()
1225 tmp_buf_size = dev->def->cal_length * 3 * sizeof (int); in teco_do_calibration()
1226 tmp_min_buf_size = dev->def->cal_length * 3 * sizeof (int); in teco_do_calibration()
1227 tmp_max_buf_size = dev->def->cal_length * 3 * sizeof (int); in teco_do_calibration()
1232 switch (dev->def->tecoref) in teco_do_calibration()
1255 for (i = 0; i < dev->def->cal_lines; i++) in teco_do_calibration()
1261 switch (dev->scan_mode) in teco_do_calibration()
1275 size = dev->def->cal_length * dev->def->cal_col_len; in teco_do_calibration()
1280 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_do_calibration()
1281 NULL, 0, dev->buffer, &size); in teco_do_calibration()
1292 for (j = 0; j < dev->def->cal_length; j++) in teco_do_calibration()
1294 dev->buffer[6 * j + 0] = 0x10; in teco_do_calibration()
1295 dev->buffer[6 * j + 1] = 0x12; in teco_do_calibration()
1296 dev->buffer[6 * j + 2] = 0x14; in teco_do_calibration()
1297 dev->buffer[6 * j + 3] = 0x16; in teco_do_calibration()
1298 dev->buffer[6 * j + 4] = 0x20; in teco_do_calibration()
1299 dev->buffer[6 * j + 5] = 0x25; in teco_do_calibration()
1302 /*hexdump (DBG_info2, "got calibration line:", dev->buffer, size); */ in teco_do_calibration()
1304 for (j = 0; j < dev->def->cal_length; j++) in teco_do_calibration()
1306 switch (dev->def->tecoref) in teco_do_calibration()
1313 (dev->buffer[6 * j + 1] << 8) + dev->buffer[6 * j + 0]; in teco_do_calibration()
1315 if (tmp_min_buf[3 * j + 0] >> ((dev->buffer[6 * j + 1] << 8) + dev->buffer[6 * j + 0])) in teco_do_calibration()
1317 tmp_min_buf[3 * j + 0] = (dev->buffer[6 * j + 1] << 8) + dev->buffer[6 * j + 0]; in teco_do_calibration()
1320 if (tmp_max_buf[3 * j + 0] < ((dev->buffer[6 * j + 1] << 8) + dev->buffer[6 * j + 0])) in teco_do_calibration()
1322 tmp_max_buf[3 * j + 0] = (dev->buffer[6 * j + 1] << 8) + dev->buffer[6 * j + 0]; in teco_do_calibration()
1325 (dev->buffer[6 * j + 3] << 8) + dev->buffer[6 * j + 2]; in teco_do_calibration()
1327 if (tmp_min_buf[3 * j + 1] >> ((dev->buffer[6 * j + 3] << 8) + dev->buffer[6 * j + 2])) in teco_do_calibration()
1329 tmp_min_buf[3 * j + 1] = (dev->buffer[6 * j + 3] << 8) + dev->buffer[6 * j + 2]; in teco_do_calibration()
1332 if (tmp_max_buf[3 * j + 1] < ((dev->buffer[6 * j + 3] << 8) + dev->buffer[6 * j + 2])) in teco_do_calibration()
1334 tmp_max_buf[3 * j + 1] = (dev->buffer[6 * j + 3] << 8) + dev->buffer[6 * j + 2]; in teco_do_calibration()
1337 (dev->buffer[6 * j + 5] << 8) + dev->buffer[6 * j + 4]; in teco_do_calibration()
1339 if (tmp_min_buf[3 * j + 2] >> ((dev->buffer[6 * j + 5] << 8) + dev->buffer[6 * j + 4])) in teco_do_calibration()
1341 tmp_min_buf[3 * j + 2] = (dev->buffer[6 * j + 5] << 8) + dev->buffer[6 * j + 4]; in teco_do_calibration()
1344 if (tmp_max_buf[3 * j + 2] < ((dev->buffer[6 * j + 5] << 8) + dev->buffer[6 * j + 4])) in teco_do_calibration()
1346 tmp_max_buf[3 * j + 2] = (dev->buffer[6 * j + 5] << 8) + dev->buffer[6 * j + 4]; in teco_do_calibration()
1351 tmp_buf[3 * j + 0] += dev->buffer[3 * j + 0]; in teco_do_calibration()
1353 if (tmp_min_buf[3 * j + 0] >> dev->buffer[3 * j + 0]) in teco_do_calibration()
1355 tmp_min_buf[3 * j + 0] = dev->buffer[3 * j + 0]; in teco_do_calibration()
1358 if (tmp_max_buf[3 * j + 0] < dev->buffer[3 * j + 0]) in teco_do_calibration()
1360 tmp_max_buf[3 * j + 0] = dev->buffer[3 * j + 0]; in teco_do_calibration()
1362 tmp_buf[3 * j + 1] += dev->buffer[3 * j + 1]; in teco_do_calibration()
1364 if (tmp_min_buf[3 * j + 1] >> dev->buffer[3 * j + 1]) in teco_do_calibration()
1366 tmp_min_buf[3 * j + 1] = dev->buffer[3 * j + 1]; in teco_do_calibration()
1369 if (tmp_max_buf[3 * j + 1] < dev->buffer[3 * j + 1]) in teco_do_calibration()
1371 tmp_max_buf[3 * j + 1] = dev->buffer[3 * j + 1]; in teco_do_calibration()
1373 tmp_buf[3 * j + 2] += dev->buffer[3 * j + 2]; in teco_do_calibration()
1375 if (tmp_min_buf[3 * j + 2] >> dev->buffer[3 * j + 2]) in teco_do_calibration()
1377 tmp_min_buf[3 * j + 2] = dev->buffer[3 * j + 2]; in teco_do_calibration()
1380 if (tmp_max_buf[3 * j + 2] < dev->buffer[3 * j + 2]) in teco_do_calibration()
1382 tmp_max_buf[3 * j + 2] = dev->buffer[3 * j + 2]; in teco_do_calibration()
1387 (dev->buffer[6 * j + 1] << 8) + dev->buffer[6 * j + 0]; in teco_do_calibration()
1389 (dev->buffer[6 * j + 3] << 8) + dev->buffer[6 * j + 2]; in teco_do_calibration()
1391 (dev->buffer[6 * j + 5] << 8) + dev->buffer[6 * j + 4]; in teco_do_calibration()
1404 switch (dev->def->tecoref) in teco_do_calibration()
1412 for (j = 0; j < dev->def->cal_length; j++) in teco_do_calibration()
1416 tmp_buf[j + dev->def->cal_length] = tmp_buf[j + dev->def->cal_length] in teco_do_calibration()
1417 - (tmp_min_buf[j + dev->def->cal_length] in teco_do_calibration()
1418 + tmp_max_buf[j + dev->def->cal_length]); in teco_do_calibration()
1419 tmp_buf[j + 2 * dev->def->cal_length] = tmp_buf[j + 2 * dev->def->cal_length] in teco_do_calibration()
1420 - (tmp_min_buf[j + 2 * dev->def->cal_length] in teco_do_calibration()
1421 + tmp_max_buf[j + 2 *dev->def->cal_length]); in teco_do_calibration()
1425 tmp_buf[j] = (colsub1_0 * (dev->def->cal_lines - 2)) / tmp_buf[j]; in teco_do_calibration()
1426 tmp_buf[j + dev->def->cal_length] = (colsub1_1 * (dev->def->cal_lines - 2)) in teco_do_calibration()
1427 / tmp_buf[j + dev->def->cal_length]; in teco_do_calibration()
1428 tmp_buf[j + 2 * dev->def->cal_length] = (colsub1_2 * (dev->def->cal_lines - 2)) in teco_do_calibration()
1429 / tmp_buf[j + 2 * dev->def->cal_length]; in teco_do_calibration()
1433 tmp_buf[j] = colsub0_0 - (tmp_buf[j] / (dev->def->cal_lines - 2)); in teco_do_calibration()
1434 tmp_buf[j + dev->def->cal_length] = colsub0_1 - (tmp_buf[j + dev->def->cal_length] in teco_do_calibration()
1435 / (dev->def->cal_lines - 2)); in teco_do_calibration()
1436 tmp_buf[j + 2 * dev->def->cal_length] = colsub0_2 in teco_do_calibration()
1437 - (tmp_buf[j + 2 * dev->def->cal_length] / (dev->def->cal_lines - 2)); in teco_do_calibration()
1442 for (j = 0; j < (3 * dev->def->cal_length); j++) in teco_do_calibration()
1445 tmp_buf[j] = (colsub1_1 * dev->def->cal_lines) / tmp_buf[j]; in teco_do_calibration()
1447 tmp_buf[j] = colsub0_1 - (tmp_buf[j] / dev->def->cal_lines); in teco_do_calibration()
1455 for (j = 0; j < dev->def->cal_length; j++) in teco_do_calibration()
1458 switch (dev->def->tecoref) in teco_do_calibration()
1464 dev->buffer[6 * j + 0] = in teco_do_calibration()
1465 (tmp_buf[0 * dev->def->cal_length + j] >> 0) & 0xff; in teco_do_calibration()
1466 dev->buffer[6 * j + 1] = in teco_do_calibration()
1467 (tmp_buf[0 * dev->def->cal_length + j] >> 8) & 0xff; in teco_do_calibration()
1469 dev->buffer[6 * j + 2] = in teco_do_calibration()
1470 (tmp_buf[1 * dev->def->cal_length + j] >> 0) & 0xff; in teco_do_calibration()
1471 dev->buffer[6 * j + 3] = in teco_do_calibration()
1472 (tmp_buf[1 * dev->def->cal_length + j] >> 8) & 0xff; in teco_do_calibration()
1474 dev->buffer[6 * j + 4] = in teco_do_calibration()
1475 (tmp_buf[2 * dev->def->cal_length + j] >> 0) & 0xff; in teco_do_calibration()
1476 dev->buffer[6 * j + 5] = in teco_do_calibration()
1477 (tmp_buf[2 * dev->def->cal_length + j] >> 8) & 0xff; in teco_do_calibration()
1481 dev->buffer[3 * j + 0] = (tmp_buf[3 * j + 0] >> 0) & 0xff; in teco_do_calibration()
1483 dev->buffer[3 * j + 1] = (tmp_buf[3 * j + 1] >> 0) & 0xff; in teco_do_calibration()
1485 dev->buffer[3 * j + 2] = (tmp_buf[3 * j + 2] >> 0) & 0xff; in teco_do_calibration()
1497 size = dev->def->cal_length * dev->def->cal_col_len; in teco_do_calibration()
1500 /*hexdump (DBG_info2, "calibration line sent:", dev->buffer, size); */ in teco_do_calibration()
1501 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_do_calibration()
1502 dev->buffer, size, NULL, NULL); in teco_do_calibration()
1518 teco_request_sense (Teco_Scanner * dev) in teco_request_sense() argument
1535 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_request_sense()
1536 NULL, 0, dev->buffer, &size); */ in teco_request_sense()
1537 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_request_sense()
1551 teco_send_gamma (Teco_Scanner * dev) in teco_send_gamma() argument
1571 if (dev->val[OPT_CUSTOM_GAMMA].w) in teco_send_gamma()
1574 if (dev->scan_mode == TECO_GRAYSCALE) in teco_send_gamma()
1579 param.gamma_R[i] = dev->gamma_GRAY[i]; in teco_send_gamma()
1580 param.gamma_G[i] = dev->gamma_GRAY[i]; in teco_send_gamma()
1581 param.gamma_B[i] = dev->gamma_GRAY[i]; in teco_send_gamma()
1589 param.gamma_R[i] = dev->gamma_R[i]; in teco_send_gamma()
1590 param.gamma_G[i] = dev->gamma_G[i]; in teco_send_gamma()
1591 param.gamma_B[i] = dev->gamma_B[i]; in teco_send_gamma()
1607 switch (dev->def->tecoref) in teco_send_gamma()
1614 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_send_gamma()
1624 teco_send_vendor_06 (Teco_Scanner * dev) in teco_send_vendor_06() argument
1637 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_send_vendor_06()
1638 NULL, 0, dev->buffer, &size); in teco_send_vendor_06()
1644 memset (dev->buffer, 0, size); in teco_send_vendor_06()
1647 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_send_vendor_06()
1648 dev->buffer, size, NULL, NULL); in teco_send_vendor_06()
1657 teco_scan (Teco_Scanner * dev) in teco_scan() argument
1667 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); in teco_scan()
1735 Teco_Scanner *dev; in attach_scanner() local
1744 for (dev = first_dev; dev; dev = dev->next) in attach_scanner()
1746 if (strcmp (dev->sane.name, devicename) == 0) in attach_scanner()
1750 *devp = dev; in attach_scanner()
1758 dev = teco_init (); in attach_scanner()
1759 if (dev == NULL) in attach_scanner()
1767 if (sanei_scsi_open (devicename, &sfd, teco_sense_handler, dev) != 0) in attach_scanner()
1770 teco_free (dev); in attach_scanner()
1779 dev->devicename = strdup (devicename); in attach_scanner()
1780 dev->sfd = sfd; in attach_scanner()
1783 if (teco_identify_scanner (dev) == SANE_FALSE) in attach_scanner()
1787 teco_free (dev); in attach_scanner()
1791 teco_close (dev); in attach_scanner()
1795 if (dev->def->color_adjust[0].resolution != 0) in attach_scanner()
1801 while (dev->def->color_adjust[num_entries].resolution != 0) in attach_scanner()
1804 dev->resolutions_list = malloc (sizeof (SANE_Word) * (num_entries + 1)); in attach_scanner()
1806 if (dev->resolutions_list == NULL) in attach_scanner()
1810 teco_free (dev); in attach_scanner()
1814 dev->resolutions_list[0] = num_entries; in attach_scanner()
1817 dev->resolutions_list[i + 1] = dev->def->color_adjust[i].resolution; in attach_scanner()
1822 dev->resolutions_list = NULL; in attach_scanner()
1826 dev->sane.name = dev->devicename; in attach_scanner()
1827 dev->sane.vendor = dev->def->real_vendor; in attach_scanner()
1828 dev->sane.model = dev->def->real_product; in attach_scanner()
1829 dev->sane.type = SANE_I18N ("flatbed scanner"); in attach_scanner()
1832 dev->next = first_dev; in attach_scanner()
1833 first_dev = dev; in attach_scanner()
1837 *devp = dev; in attach_scanner()
1848 attach_one (const char *dev) in attach_one() argument
1850 attach_scanner (dev, NULL); in attach_one()
1856 teco_init_options (Teco_Scanner * dev) in teco_init_options() argument
1861 memset (dev->opt, 0, sizeof (dev->opt)); in teco_init_options()
1862 memset (dev->val, 0, sizeof (dev->val)); in teco_init_options()
1866 dev->opt[i].size = sizeof (SANE_Word); in teco_init_options()
1867 dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; in teco_init_options()
1871 dev->opt[OPT_NUM_OPTS].name = ""; in teco_init_options()
1872 dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; in teco_init_options()
1873 dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; in teco_init_options()
1874 dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; in teco_init_options()
1875 dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; in teco_init_options()
1876 dev->val[OPT_NUM_OPTS].w = OPT_NUM_OPTIONS; in teco_init_options()
1879 dev->opt[OPT_MODE_GROUP].title = SANE_I18N ("Scan Mode"); in teco_init_options()
1880 dev->opt[OPT_MODE_GROUP].desc = ""; /* not valid for a group */ in teco_init_options()
1881 dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; in teco_init_options()
1882 dev->opt[OPT_MODE_GROUP].cap = 0; in teco_init_options()
1883 dev->opt[OPT_MODE_GROUP].size = 0; in teco_init_options()
1884 dev->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; in teco_init_options()
1887 dev->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; in teco_init_options()
1888 dev->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; in teco_init_options()
1889 dev->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; in teco_init_options()
1890 dev->opt[OPT_MODE].type = SANE_TYPE_STRING; in teco_init_options()
1891 dev->opt[OPT_MODE].size = max_string_size (scan_mode_list); in teco_init_options()
1892 dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; in teco_init_options()
1893 dev->opt[OPT_MODE].constraint.string_list = scan_mode_list; in teco_init_options()
1894 dev->val[OPT_MODE].s = (SANE_Char *) strdup (""); /* will be set later */ in teco_init_options()
1897 dev->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; in teco_init_options()
1898 dev->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; in teco_init_options()
1899 dev->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; in teco_init_options()
1900 dev->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; in teco_init_options()
1901 dev->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; in teco_init_options()
1902 dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1903 dev->opt[OPT_RESOLUTION].constraint.range = &dev->def->res_range; in teco_init_options()
1904 dev->val[OPT_RESOLUTION].w = DEF_RESOLUTION; in teco_init_options()
1907 dev->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); in teco_init_options()
1908 dev->opt[OPT_GEOMETRY_GROUP].desc = ""; /* not valid for a group */ in teco_init_options()
1909 dev->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; in teco_init_options()
1910 dev->opt[OPT_GEOMETRY_GROUP].cap = 0; in teco_init_options()
1911 dev->opt[OPT_GEOMETRY_GROUP].size = 0; in teco_init_options()
1912 dev->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; in teco_init_options()
1915 dev->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; in teco_init_options()
1916 dev->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; in teco_init_options()
1917 dev->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; in teco_init_options()
1918 dev->opt[OPT_TL_X].type = SANE_TYPE_FIXED; in teco_init_options()
1919 dev->opt[OPT_TL_X].unit = SANE_UNIT_MM; in teco_init_options()
1920 dev->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1921 dev->opt[OPT_TL_X].constraint.range = &dev->def->x_range; in teco_init_options()
1922 dev->val[OPT_TL_X].w = dev->def->x_range.min; in teco_init_options()
1925 dev->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; in teco_init_options()
1926 dev->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; in teco_init_options()
1927 dev->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; in teco_init_options()
1928 dev->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; in teco_init_options()
1929 dev->opt[OPT_TL_Y].unit = SANE_UNIT_MM; in teco_init_options()
1930 dev->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1931 dev->opt[OPT_TL_Y].constraint.range = &dev->def->y_range; in teco_init_options()
1932 dev->val[OPT_TL_Y].w = dev->def->y_range.min; in teco_init_options()
1935 dev->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; in teco_init_options()
1936 dev->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; in teco_init_options()
1937 dev->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; in teco_init_options()
1938 dev->opt[OPT_BR_X].type = SANE_TYPE_FIXED; in teco_init_options()
1939 dev->opt[OPT_BR_X].unit = SANE_UNIT_MM; in teco_init_options()
1940 dev->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1941 dev->opt[OPT_BR_X].constraint.range = &dev->def->x_range; in teco_init_options()
1942 dev->val[OPT_BR_X].w = dev->def->x_range.max; in teco_init_options()
1945 dev->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; in teco_init_options()
1946 dev->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; in teco_init_options()
1947 dev->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; in teco_init_options()
1948 dev->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; in teco_init_options()
1949 dev->opt[OPT_BR_Y].unit = SANE_UNIT_MM; in teco_init_options()
1950 dev->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1951 dev->opt[OPT_BR_Y].constraint.range = &dev->def->y_range; in teco_init_options()
1952 dev->val[OPT_BR_Y].w = dev->def->y_range.max; in teco_init_options()
1955 dev->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); in teco_init_options()
1956 dev->opt[OPT_ENHANCEMENT_GROUP].desc = ""; /* not valid for a group */ in teco_init_options()
1957 dev->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; in teco_init_options()
1958 dev->opt[OPT_ENHANCEMENT_GROUP].cap = SANE_CAP_ADVANCED; in teco_init_options()
1959 dev->opt[OPT_ENHANCEMENT_GROUP].size = 0; in teco_init_options()
1960 dev->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; in teco_init_options()
1963 dev->opt[OPT_DITHER].name = "dither"; in teco_init_options()
1964 dev->opt[OPT_DITHER].title = SANE_I18N ("Dither"); in teco_init_options()
1965 dev->opt[OPT_DITHER].desc = SANE_I18N ("Dither"); in teco_init_options()
1966 dev->opt[OPT_DITHER].type = SANE_TYPE_STRING; in teco_init_options()
1967 dev->opt[OPT_DITHER].size = max_string_size (dither_list); in teco_init_options()
1968 dev->opt[OPT_DITHER].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1969 dev->opt[OPT_DITHER].constraint_type = SANE_CONSTRAINT_STRING_LIST; in teco_init_options()
1970 dev->opt[OPT_DITHER].constraint.string_list = dither_list; in teco_init_options()
1971 dev->val[OPT_DITHER].s = strdup (dither_list[0]); in teco_init_options()
1974 dev->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; in teco_init_options()
1975 dev->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; in teco_init_options()
1976 dev->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; in teco_init_options()
1977 dev->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; in teco_init_options()
1978 dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1979 dev->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; in teco_init_options()
1982 dev->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; in teco_init_options()
1983 dev->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; in teco_init_options()
1984 dev->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; in teco_init_options()
1985 dev->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; in teco_init_options()
1986 dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1987 dev->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; in teco_init_options()
1988 dev->opt[OPT_GAMMA_VECTOR_R].size = GAMMA_LENGTH * sizeof (SANE_Word); in teco_init_options()
1989 dev->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1990 dev->opt[OPT_GAMMA_VECTOR_R].constraint.range = &gamma_range; in teco_init_options()
1991 dev->val[OPT_GAMMA_VECTOR_R].wa = dev->gamma_R; in teco_init_options()
1994 dev->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; in teco_init_options()
1995 dev->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; in teco_init_options()
1996 dev->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; in teco_init_options()
1997 dev->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; in teco_init_options()
1998 dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1999 dev->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; in teco_init_options()
2000 dev->opt[OPT_GAMMA_VECTOR_G].size = GAMMA_LENGTH * sizeof (SANE_Word); in teco_init_options()
2001 dev->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
2002 dev->opt[OPT_GAMMA_VECTOR_G].constraint.range = &gamma_range; in teco_init_options()
2003 dev->val[OPT_GAMMA_VECTOR_G].wa = dev->gamma_G; in teco_init_options()
2006 dev->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; in teco_init_options()
2007 dev->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; in teco_init_options()
2008 dev->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; in teco_init_options()
2009 dev->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; in teco_init_options()
2010 dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; in teco_init_options()
2011 dev->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; in teco_init_options()
2012 dev->opt[OPT_GAMMA_VECTOR_B].size = GAMMA_LENGTH * sizeof (SANE_Word); in teco_init_options()
2013 dev->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
2014 dev->opt[OPT_GAMMA_VECTOR_B].constraint.range = &gamma_range; in teco_init_options()
2015 dev->val[OPT_GAMMA_VECTOR_B].wa = dev->gamma_B; in teco_init_options()
2018 dev->opt[OPT_GAMMA_VECTOR_GRAY].name = SANE_NAME_GAMMA_VECTOR; in teco_init_options()
2019 dev->opt[OPT_GAMMA_VECTOR_GRAY].title = SANE_TITLE_GAMMA_VECTOR; in teco_init_options()
2020 dev->opt[OPT_GAMMA_VECTOR_GRAY].desc = SANE_DESC_GAMMA_VECTOR; in teco_init_options()
2021 dev->opt[OPT_GAMMA_VECTOR_GRAY].type = SANE_TYPE_INT; in teco_init_options()
2022 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; in teco_init_options()
2023 dev->opt[OPT_GAMMA_VECTOR_GRAY].unit = SANE_UNIT_NONE; in teco_init_options()
2024 dev->opt[OPT_GAMMA_VECTOR_GRAY].size = GAMMA_LENGTH * sizeof (SANE_Word); in teco_init_options()
2025 dev->opt[OPT_GAMMA_VECTOR_GRAY].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
2026 dev->opt[OPT_GAMMA_VECTOR_GRAY].constraint.range = &gamma_range; in teco_init_options()
2027 dev->val[OPT_GAMMA_VECTOR_GRAY].wa = dev->gamma_GRAY; in teco_init_options()
2030 dev->opt[OPT_FILTER_COLOR].name = "color-filter"; in teco_init_options()
2031 dev->opt[OPT_FILTER_COLOR].title = "Color dropout"; in teco_init_options()
2032 dev->opt[OPT_FILTER_COLOR].desc = "Color dropout"; in teco_init_options()
2033 dev->opt[OPT_FILTER_COLOR].type = SANE_TYPE_STRING; in teco_init_options()
2034 dev->opt[OPT_FILTER_COLOR].size = max_string_size (filter_color_list); in teco_init_options()
2035 dev->opt[OPT_FILTER_COLOR].cap |= SANE_CAP_INACTIVE; in teco_init_options()
2036 dev->opt[OPT_FILTER_COLOR].constraint_type = SANE_CONSTRAINT_STRING_LIST; in teco_init_options()
2037 dev->opt[OPT_FILTER_COLOR].constraint.string_list = filter_color_list; in teco_init_options()
2038 dev->val[OPT_FILTER_COLOR].s = (SANE_Char *) strdup (filter_color_list[0]); in teco_init_options()
2041 dev->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; in teco_init_options()
2042 dev->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; in teco_init_options()
2043 dev->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; in teco_init_options()
2044 dev->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; in teco_init_options()
2045 dev->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE; in teco_init_options()
2046 dev->opt[OPT_THRESHOLD].size = sizeof (SANE_Int); in teco_init_options()
2047 dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; in teco_init_options()
2048 dev->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
2049 dev->opt[OPT_THRESHOLD].constraint.range = &threshold_range; in teco_init_options()
2050 dev->val[OPT_THRESHOLD].w = 128; in teco_init_options()
2053 dev->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; in teco_init_options()
2054 dev->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; in teco_init_options()
2055 dev->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; in teco_init_options()
2056 dev->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; in teco_init_options()
2057 dev->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; in teco_init_options()
2058 dev->val[OPT_PREVIEW].w = SANE_FALSE; in teco_init_options()
2061 dev->opt[OPT_WHITE_LEVEL_R].name = SANE_NAME_WHITE_LEVEL_R; in teco_init_options()
2062 dev->opt[OPT_WHITE_LEVEL_R].title = SANE_TITLE_WHITE_LEVEL_R; in teco_init_options()
2063 dev->opt[OPT_WHITE_LEVEL_R].desc = SANE_DESC_WHITE_LEVEL_R; in teco_init_options()
2064 dev->opt[OPT_WHITE_LEVEL_R].type = SANE_TYPE_INT; in teco_init_options()
2065 dev->opt[OPT_WHITE_LEVEL_R].unit = SANE_UNIT_NONE; in teco_init_options()
2066 dev->opt[OPT_WHITE_LEVEL_R].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
2067 dev->opt[OPT_WHITE_LEVEL_R].constraint.range = &red_level_range; in teco_init_options()
2068 dev->val[OPT_WHITE_LEVEL_R].w = 32; /* to get middle value */ in teco_init_options()
2071 dev->opt[OPT_WHITE_LEVEL_G].name = SANE_NAME_WHITE_LEVEL_G; in teco_init_options()
2072 dev->opt[OPT_WHITE_LEVEL_G].title = SANE_TITLE_WHITE_LEVEL_G; in teco_init_options()
2073 dev->opt[OPT_WHITE_LEVEL_G].desc = SANE_DESC_WHITE_LEVEL_G; in teco_init_options()
2074 dev->opt[OPT_WHITE_LEVEL_G].type = SANE_TYPE_INT; in teco_init_options()
2075 dev->opt[OPT_WHITE_LEVEL_G].unit = SANE_UNIT_NONE; in teco_init_options()
2076 dev->opt[OPT_WHITE_LEVEL_G].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
2077 dev->opt[OPT_WHITE_LEVEL_G].constraint.range = &green_level_range; in teco_init_options()
2078 dev->val[OPT_WHITE_LEVEL_G].w = 32; /* to get middle value */ in teco_init_options()
2081 dev->opt[OPT_WHITE_LEVEL_B].name = SANE_NAME_WHITE_LEVEL_B; in teco_init_options()
2082 dev->opt[OPT_WHITE_LEVEL_B].title = SANE_TITLE_WHITE_LEVEL_B; in teco_init_options()
2083 dev->opt[OPT_WHITE_LEVEL_B].desc = SANE_DESC_WHITE_LEVEL_B; in teco_init_options()
2084 dev->opt[OPT_WHITE_LEVEL_B].type = SANE_TYPE_INT; in teco_init_options()
2085 dev->opt[OPT_WHITE_LEVEL_B].unit = SANE_UNIT_NONE; in teco_init_options()
2086 dev->opt[OPT_WHITE_LEVEL_B].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
2087 dev->opt[OPT_WHITE_LEVEL_B].constraint.range = &blue_level_range; in teco_init_options()
2088 dev->val[OPT_WHITE_LEVEL_B].w = 32; /* to get middle value */ in teco_init_options()
2092 sane_control_option (dev, OPT_MODE, SANE_ACTION_SET_VALUE, in teco_init_options()
2100 teco_wait_scanner (Teco_Scanner * dev) in teco_wait_scanner() argument
2118 status = sanei_scsi_cmd (dev->sfd, cdb.data, cdb.len, NULL, NULL); in teco_wait_scanner()
2158 * dev->buffer and write the output in dev->image. size_in the the
2159 * length of the valid data in dev->buffer. */
2166 teco_adjust_raster (Teco_Scanner * dev, size_t size_in) in teco_adjust_raster() argument
2168 int nb_rasters; /* number of rasters in dev->buffer */ in teco_adjust_raster()
2174 const struct dpi_color_adjust *color_adjust = dev->color_adjust; in teco_adjust_raster()
2180 assert (dev->scan_mode == TECO_COLOR); in teco_adjust_raster()
2181 assert ((size_in % dev->params.bytes_per_line) == 0); in teco_adjust_raster()
2193 nb_rasters = size_in / dev->raster_size; in teco_adjust_raster()
2202 if (dev->raster_num < color_adjust->color_shift) in teco_adjust_raster()
2213 line = dev->raster_num; in teco_adjust_raster()
2215 else if (dev->raster_num < (3 * color_adjust->color_shift)) in teco_adjust_raster()
2218 if ((dev->raster_num - color_adjust->color_shift) % 2) in teco_adjust_raster()
2221 line = (dev->raster_num - color_adjust->color_shift) / 2; in teco_adjust_raster()
2233 line = (dev->raster_num + color_adjust->color_shift) / 2; in teco_adjust_raster()
2236 else if (dev->raster_num >= in teco_adjust_raster()
2237 dev->raster_real - color_adjust->color_shift) in teco_adjust_raster()
2248 line = dev->line; in teco_adjust_raster()
2250 else if (dev->raster_num >= in teco_adjust_raster()
2251 dev->raster_real - 3 * color_adjust->color_shift) in teco_adjust_raster()
2254 if ((dev->raster_real - dev->raster_num - in teco_adjust_raster()
2260 line = dev->line; in teco_adjust_raster()
2265 line = dev->line + color_adjust->color_shift - 1; in teco_adjust_raster()
2273 line = dev->line + color_adjust->color_shift; in teco_adjust_raster()
2278 line = dev->line; in teco_adjust_raster()
2285 switch ((dev->raster_num) % 3) in teco_adjust_raster()
2290 line = dev->raster_num / 3 + color_adjust->color_shift; in teco_adjust_raster()
2292 line = dev->raster_num / 3 - color_adjust->color_shift; in teco_adjust_raster()
2296 line = dev->raster_num / 3; in teco_adjust_raster()
2301 line = dev->raster_num / 3 - color_adjust->color_shift; in teco_adjust_raster()
2303 line = dev->raster_num / 3 + color_adjust->color_shift; in teco_adjust_raster()
2309 line -= dev->line; in teco_adjust_raster()
2311 offset = dev->image_end + line * dev->params.bytes_per_line; in teco_adjust_raster()
2313 assert (offset <= (dev->image_size - dev->params.bytes_per_line)); in teco_adjust_raster()
2318 unsigned char *src = dev->buffer + raster * dev->raster_size; in teco_adjust_raster()
2319 unsigned char *dest = dev->image + offset + color; in teco_adjust_raster()
2321 for (i = 0; i < dev->raster_size; i++) in teco_adjust_raster()
2329 DBG (DBG_info, "raster=%d, line=%d, color=%d\n", dev->raster_num, in teco_adjust_raster()
2330 dev->line + line, color); in teco_adjust_raster()
2336 dev->line++; in teco_adjust_raster()
2337 dev->image_end += dev->params.bytes_per_line; in teco_adjust_raster()
2340 dev->raster_num++; in teco_adjust_raster()
2348 teco_fill_image (Teco_Scanner * dev) in teco_fill_image() argument
2356 assert (dev->image_begin == dev->image_end); in teco_fill_image()
2357 assert (dev->real_bytes_left > 0); in teco_fill_image()
2365 memmove (dev->image, dev->image + dev->image_begin, dev->raster_ahead); in teco_fill_image()
2367 dev->image_begin = 0; in teco_fill_image()
2368 dev->image_end = 0; in teco_fill_image()
2370 while (dev->real_bytes_left) in teco_fill_image()
2375 size = dev->real_bytes_left; in teco_fill_image()
2376 if (size > dev->image_size - dev->raster_ahead - dev->image_end) in teco_fill_image()
2378 size = dev->image_size - dev->raster_ahead - dev->image_end; in teco_fill_image()
2380 if (size > dev->buffer_size) in teco_fill_image()
2382 size = dev->buffer_size; in teco_fill_image()
2390 size = size - (size % dev->params.bytes_per_line); in teco_fill_image()
2396 assert (dev->image_end != 0); in teco_fill_image()
2401 (long) size, dev->params.bytes_per_line); in teco_fill_image()
2404 cdb.data[5] = size / dev->params.bytes_per_line; in teco_fill_image()
2409 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_fill_image()
2410 NULL, 0, dev->buffer, &size); in teco_fill_image()
2413 memcpy (dev->buffer, image_buf + image_buf_begin, size); in teco_fill_image()
2424 (long) dev->real_bytes_left); in teco_fill_image()
2426 if (dev->scan_mode == TECO_COLOR && in teco_fill_image()
2427 dev->def->tecoref != TECO_VM656A && raw_output == 0) in teco_fill_image()
2429 teco_adjust_raster (dev, size); in teco_fill_image()
2433 memcpy (dev->image + dev->image_end, dev->buffer, size); in teco_fill_image()
2434 dev->image_end += size; in teco_fill_image()
2436 dev->real_bytes_left -= size; in teco_fill_image()
2448 teco_copy_raw_to_frontend (Teco_Scanner * dev, SANE_Byte * buf, size_t * len) in teco_copy_raw_to_frontend() argument
2452 size = dev->image_end - dev->image_begin; in teco_copy_raw_to_frontend()
2459 switch (dev->scan_mode) in teco_copy_raw_to_frontend()
2464 unsigned char *src = dev->image + dev->image_begin; in teco_copy_raw_to_frontend()
2478 memcpy (buf, dev->image + dev->image_begin, size); in teco_copy_raw_to_frontend()
2482 dev->image_begin += size; in teco_copy_raw_to_frontend()
2487 do_cancel (Teco_Scanner * dev) in do_cancel() argument
2491 if (dev->scanning == SANE_TRUE) in do_cancel()
2495 teco_reset_window (dev); in do_cancel()
2496 teco_close (dev); in do_cancel()
2499 dev->scanning = SANE_FALSE; in do_cancel()
2533 /* default to /dev/scanner instead of insisting on config file */ in sane_init()
2534 attach_scanner ("/dev/scanner", 0); in sane_init()
2560 Teco_Scanner *dev; in sane_get_devices() local
2573 for (dev = first_dev; i < num_devices; dev = dev->next) in sane_get_devices()
2574 devlist[i++] = &dev->sane; in sane_get_devices()
2587 Teco_Scanner *dev; in sane_open() local
2598 for (dev = first_dev; dev; dev = dev->next) in sane_open()
2600 if (strcmp (dev->sane.name, devicename) == 0) in sane_open()
2606 if (!dev) in sane_open()
2608 status = attach_scanner (devicename, &dev); in sane_open()
2618 dev = first_dev; /* empty devicename -> use first device */ in sane_open()
2621 if (!dev) in sane_open()
2628 teco_init_options (dev); in sane_open()
2633 dev->gamma_R[i] = i / 4; in sane_open()
2634 dev->gamma_G[i] = i / 4; in sane_open()
2635 dev->gamma_B[i] = i / 4; in sane_open()
2636 dev->gamma_GRAY[i] = i / 4; in sane_open()
2639 *handle = dev; in sane_open()
2649 Teco_Scanner *dev = handle; in sane_get_option_descriptor() local
2660 return dev->opt + option; in sane_get_option_descriptor()
2667 Teco_Scanner *dev = handle; in sane_control_option() local
2679 if (dev->scanning) in sane_control_option()
2689 cap = dev->opt[option].cap; in sane_control_option()
2713 *(SANE_Word *) val = dev->val[option].w; in sane_control_option()
2720 strcpy (val, dev->val[option].s); in sane_control_option()
2728 memcpy (val, dev->val[option].wa, dev->opt[option].size); in sane_control_option()
2744 status = sanei_constrain_value (dev->opt + option, val, info); in sane_control_option()
2768 dev->val[option].w = *(SANE_Word *) val; in sane_control_option()
2773 dev->val[option].w = *(SANE_Word *) val; in sane_control_option()
2778 free (dev->val[option].s); in sane_control_option()
2779 dev->val[option].s = (SANE_String) strdup (val); in sane_control_option()
2783 free (dev->val[option].s); in sane_control_option()
2784 dev->val[option].s = (SANE_String) strdup (val); in sane_control_option()
2789 if (strcmp (dev->val[option].s, val) == 0) in sane_control_option()
2792 free (dev->val[OPT_MODE].s); in sane_control_option()
2793 dev->val[OPT_MODE].s = (SANE_Char *) strdup (val); in sane_control_option()
2795 dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2796 dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2797 dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2798 dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2799 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2800 dev->opt[OPT_DITHER].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2801 dev->opt[OPT_FILTER_COLOR].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2802 dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2803 dev->opt[OPT_WHITE_LEVEL_R].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2804 dev->opt[OPT_WHITE_LEVEL_G].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2805 dev->opt[OPT_WHITE_LEVEL_B].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2810 dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; in sane_control_option()
2811 dev->opt[OPT_RESOLUTION].constraint.range = &dev->def->res_range; in sane_control_option()
2813 if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_LINEART) == 0) in sane_control_option()
2815 dev->scan_mode = TECO_BW; in sane_control_option()
2816 dev->depth = 8; in sane_control_option()
2817 dev->opt[OPT_DITHER].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2818 dev->opt[OPT_FILTER_COLOR].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2819 dev->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2821 else if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_GRAY) == 0) in sane_control_option()
2823 dev->scan_mode = TECO_GRAYSCALE; in sane_control_option()
2824 dev->depth = 8; in sane_control_option()
2826 switch (dev->def->tecoref) in sane_control_option()
2830 dev->opt[OPT_WHITE_LEVEL_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2831 dev->opt[OPT_WHITE_LEVEL_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2832 dev->opt[OPT_WHITE_LEVEL_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2836 dev->opt[OPT_WHITE_LEVEL_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2837 dev->opt[OPT_WHITE_LEVEL_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2838 dev->opt[OPT_WHITE_LEVEL_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2839 dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2840 if (dev->val[OPT_CUSTOM_GAMMA].w) in sane_control_option()
2842 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap &= in sane_control_option()
2848 dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2849 if (dev->val[OPT_CUSTOM_GAMMA].w) in sane_control_option()
2851 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap &= in sane_control_option()
2856 dev->opt[OPT_FILTER_COLOR].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2858 else if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) == 0) in sane_control_option()
2860 dev->scan_mode = TECO_COLOR; in sane_control_option()
2861 dev->depth = 8; in sane_control_option()
2863 switch (dev->def->tecoref) in sane_control_option()
2867 dev->opt[OPT_WHITE_LEVEL_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2868 dev->opt[OPT_WHITE_LEVEL_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2869 dev->opt[OPT_WHITE_LEVEL_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2873 dev->opt[OPT_WHITE_LEVEL_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2874 dev->opt[OPT_WHITE_LEVEL_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2875 dev->opt[OPT_WHITE_LEVEL_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2876 dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2877 if (dev->val[OPT_CUSTOM_GAMMA].w) in sane_control_option()
2879 dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2880 dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2881 dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2886 dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2887 if (dev->val[OPT_CUSTOM_GAMMA].w) in sane_control_option()
2889 dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2890 dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2891 dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2897 if (dev->resolutions_list != NULL) in sane_control_option()
2901 dev->opt[OPT_RESOLUTION].constraint_type = in sane_control_option()
2903 dev->opt[OPT_RESOLUTION].constraint.word_list = in sane_control_option()
2904 dev->resolutions_list; in sane_control_option()
2907 for (i = 1; i <= dev->resolutions_list[0]; i++) in sane_control_option()
2909 if (dev->resolutions_list[i] >= in sane_control_option()
2910 dev->val[OPT_RESOLUTION].w) in sane_control_option()
2913 if (i > dev->resolutions_list[0]) in sane_control_option()
2916 dev->val[OPT_RESOLUTION].w = DEF_RESOLUTION; in sane_control_option()
2921 dev->val[OPT_RESOLUTION].w = dev->resolutions_list[i]; in sane_control_option()
2936 memcpy (dev->val[option].wa, val, dev->opt[option].size); in sane_control_option()
2940 dev->val[OPT_CUSTOM_GAMMA].w = *(SANE_Word *) val; in sane_control_option()
2941 if (dev->val[OPT_CUSTOM_GAMMA].w) in sane_control_option()
2944 if (dev->scan_mode == TECO_GRAYSCALE) in sane_control_option()
2946 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2951 dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2952 dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2953 dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
2958 dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2959 dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2960 dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; in sane_control_option()
2981 Teco_Scanner *dev = handle; in sane_get_parameters() local
2985 if (!(dev->scanning)) in sane_get_parameters()
2990 if (dev->val[OPT_PREVIEW].w == SANE_TRUE) in sane_get_parameters()
2994 switch (dev->def->tecoref) in sane_get_parameters()
2998 dev->x_resolution = 75; in sane_get_parameters()
2999 dev->y_resolution = 75; in sane_get_parameters()
3003 dev->x_resolution = 50; in sane_get_parameters()
3004 dev->y_resolution = 50; in sane_get_parameters()
3007 dev->x_tl = 0; in sane_get_parameters()
3008 dev->y_tl = 0; in sane_get_parameters()
3009 dev->x_br = mmToIlu (SANE_UNFIX (dev->def->x_range.max)); in sane_get_parameters()
3010 dev->y_br = mmToIlu (SANE_UNFIX (dev->def->y_range.max)); in sane_get_parameters()
3014 dev->x_resolution = dev->val[OPT_RESOLUTION].w; in sane_get_parameters()
3015 dev->y_resolution = dev->val[OPT_RESOLUTION].w; in sane_get_parameters()
3017 dev->x_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_X].w)); in sane_get_parameters()
3018 dev->y_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_Y].w)); in sane_get_parameters()
3019 dev->x_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_X].w)); in sane_get_parameters()
3020 dev->y_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_Y].w)); in sane_get_parameters()
3023 if (dev->x_resolution > dev->def->x_resolution_max) in sane_get_parameters()
3025 dev->x_resolution = dev->def->x_resolution_max; in sane_get_parameters()
3029 if (dev->x_tl > dev->x_br) in sane_get_parameters()
3032 s = dev->x_tl; in sane_get_parameters()
3033 dev->x_tl = dev->x_br; in sane_get_parameters()
3034 dev->x_br = s; in sane_get_parameters()
3036 if (dev->y_tl > dev->y_br) in sane_get_parameters()
3039 s = dev->y_tl; in sane_get_parameters()
3040 dev->y_tl = dev->y_br; in sane_get_parameters()
3041 dev->y_br = s; in sane_get_parameters()
3044 dev->width = dev->x_br - dev->x_tl; in sane_get_parameters()
3045 dev->length = dev->y_br - dev->y_tl; in sane_get_parameters()
3048 memset (&dev->params, 0, sizeof (SANE_Parameters)); in sane_get_parameters()
3050 dev->params.last_frame = SANE_TRUE; in sane_get_parameters()
3052 switch (dev->scan_mode) in sane_get_parameters()
3055 dev->params.format = SANE_FRAME_GRAY; in sane_get_parameters()
3056 dev->params.pixels_per_line = in sane_get_parameters()
3057 ((dev->width * dev->x_resolution) / in sane_get_parameters()
3058 dev->def->x_resolution_max) & ~0x7; in sane_get_parameters()
3059 dev->params.bytes_per_line = dev->params.pixels_per_line / 8; in sane_get_parameters()
3060 dev->params.depth = 1; in sane_get_parameters()
3061 dev->color_adjust = NULL; in sane_get_parameters()
3064 dev->params.format = SANE_FRAME_GRAY; in sane_get_parameters()
3065 dev->params.pixels_per_line = in sane_get_parameters()
3066 ((dev->width * dev->x_resolution) / dev->def->x_resolution_max); in sane_get_parameters()
3067 if ((dev->def->tecoref == TECO_VM656A in sane_get_parameters()
3068 || dev->def->tecoref == TECO_VM6586) in sane_get_parameters()
3069 && ((dev->width * dev->x_resolution) % in sane_get_parameters()
3070 dev->def->x_resolution_max != 0)) in sane_get_parameters()
3073 dev->params.pixels_per_line += 1; in sane_get_parameters()
3075 dev->params.bytes_per_line = dev->params.pixels_per_line; in sane_get_parameters()
3076 dev->params.depth = 8; in sane_get_parameters()
3077 dev->color_adjust = NULL; in sane_get_parameters()
3080 dev->params.format = SANE_FRAME_RGB; in sane_get_parameters()
3081 dev->params.pixels_per_line = in sane_get_parameters()
3082 ((dev->width * dev->x_resolution) / dev->def->x_resolution_max); in sane_get_parameters()
3083 if ((dev->def->tecoref == TECO_VM656A in sane_get_parameters()
3084 || dev->def->tecoref == TECO_VM6586) in sane_get_parameters()
3085 && ((dev->width * dev->x_resolution) % in sane_get_parameters()
3086 dev->def->x_resolution_max != 0)) in sane_get_parameters()
3089 dev->params.pixels_per_line += 1; in sane_get_parameters()
3091 dev->params.bytes_per_line = dev->params.pixels_per_line * 3; in sane_get_parameters()
3092 dev->params.depth = 8; in sane_get_parameters()
3094 if (dev->resolutions_list != NULL) in sane_get_parameters()
3102 dev->def->color_adjust[i].resolution != dev->y_resolution; in sane_get_parameters()
3105 dev->color_adjust = &dev->def->color_adjust[i]; in sane_get_parameters()
3109 dev->color_adjust = &dev->def->color_adjust[0]; in sane_get_parameters()
3114 dev->params.lines = in sane_get_parameters()
3115 (dev->length * dev->y_resolution) / dev->def->x_resolution_max; in sane_get_parameters()
3121 *params = (dev->params); in sane_get_parameters()
3132 Teco_Scanner *dev = handle; in sane_start() local
3137 if (!(dev->scanning)) in sane_start()
3140 sane_get_parameters (dev, NULL); in sane_start()
3144 (dev->devicename, &(dev->sfd), teco_sense_handler, dev) != 0) in sane_start()
3151 status = teco_wait_scanner (dev); in sane_start()
3154 teco_close (dev); in sane_start()
3158 status = teco_set_window (dev); in sane_start()
3161 teco_close (dev); in sane_start()
3165 status = teco_get_scan_size (dev); in sane_start()
3168 teco_close (dev); in sane_start()
3176 if (dev->color_adjust) in sane_start()
3178 dev->raster_ahead = in sane_start()
3179 (2 * dev->color_adjust->color_shift) * dev->params.bytes_per_line; in sane_start()
3183 dev->raster_ahead = 0; in sane_start()
3185 dev->image_size = dev->buffer_size + dev->raster_ahead; in sane_start()
3186 dev->image = malloc (dev->image_size); in sane_start()
3187 if (dev->image == NULL) in sane_start()
3193 dev->raster_size = dev->params.pixels_per_line; in sane_start()
3194 dev->raster_real = dev->params.lines * 3; in sane_start()
3195 dev->raster_num = 0; in sane_start()
3196 dev->line = 0; in sane_start()
3199 status = teco_do_calibration (dev); in sane_start()
3202 teco_close (dev); in sane_start()
3207 switch (dev->def->tecoref) in sane_start()
3212 status = teco_request_sense (dev); in sane_start()
3215 teco_close (dev); in sane_start()
3223 status = teco_send_gamma (dev); in sane_start()
3226 teco_close (dev); in sane_start()
3230 status = teco_set_window (dev); in sane_start()
3233 teco_close (dev); in sane_start()
3236 switch (dev->def->tecoref) in sane_start()
3242 status = teco_send_vendor_06 (dev); in sane_start()
3245 teco_close (dev); in sane_start()
3249 status = teco_scan (dev); in sane_start()
3252 teco_close (dev); in sane_start()
3256 status = teco_wait_for_data (dev); in sane_start()
3259 teco_close (dev); in sane_start()
3264 dev->image_end = 0; in sane_start()
3265 dev->image_begin = 0; in sane_start()
3267 dev->bytes_left = dev->params.bytes_per_line * dev->params.lines; in sane_start()
3268 dev->real_bytes_left = dev->params.bytes_per_line * dev->params.lines; in sane_start()
3270 dev->scanning = SANE_TRUE; in sane_start()
3282 Teco_Scanner *dev = handle; in sane_read() local
3290 if (!(dev->scanning)) in sane_read()
3293 return do_cancel (dev); in sane_read()
3296 if (dev->bytes_left <= 0) in sane_read()
3305 if (dev->image_begin == dev->image_end) in sane_read()
3308 status = teco_fill_image (dev); in sane_read()
3317 assert (dev->image_begin != dev->image_end); in sane_read()
3319 if (dev->image_begin == dev->image_end) in sane_read()
3328 if (size > dev->bytes_left) in sane_read()
3330 size = dev->bytes_left; in sane_read()
3332 teco_copy_raw_to_frontend (dev, buf + buf_offset, &size); in sane_read()
3336 dev->bytes_left -= size; in sane_read()
3340 while ((buf_offset != max_len) && dev->bytes_left); in sane_read()
3342 DBG (DBG_info, "sane_read: leave, bytes_left=%ld\n", (long) dev->bytes_left); in sane_read()
3351 Teco_Scanner *dev = handle; in sane_set_io_mode() local
3355 if (dev->scanning == SANE_FALSE) in sane_set_io_mode()
3387 Teco_Scanner *dev = handle; in sane_cancel() local
3391 do_cancel (dev); in sane_cancel()
3399 Teco_Scanner *dev = handle; in sane_close() local
3404 do_cancel (dev); in sane_close()
3405 teco_close (dev); in sane_close()
3407 /* Unlink dev. */ in sane_close()
3408 if (first_dev == dev) in sane_close()
3410 first_dev = dev->next; in sane_close()
3415 while (dev_tmp->next && dev_tmp->next != dev) in sane_close()
3425 teco_free (dev); in sane_close()