• Home
  • Raw
  • Download

Lines Matching full:dev

315   Teco_Scanner *dev;  in teco_init()  local
320 dev = malloc (sizeof (Teco_Scanner)); in teco_init()
321 if (dev == NULL) in teco_init()
326 memset (dev, 0, sizeof (Teco_Scanner)); in teco_init()
329 dev->buffer_size = 64 * 1024; in teco_init()
330 dev->buffer = malloc (dev->buffer_size); in teco_init()
331 if (dev->buffer == NULL) in teco_init()
333 free (dev); in teco_init()
338 dev->image_size = 64 * 1024; /* enough for 1 line at max res */ in teco_init()
339 dev->image = malloc (dev->image_size); in teco_init()
340 if (dev->image == NULL) in teco_init()
342 free (dev->buffer); in teco_init()
343 free (dev); in teco_init()
347 dev->sfd = -1; in teco_init()
351 return (dev); in teco_init()
356 teco_close (Teco_Scanner * dev) in teco_close() argument
360 if (dev->sfd != -1) in teco_close()
362 sanei_scsi_close (dev->sfd); in teco_close()
363 dev->sfd = -1; in teco_close()
371 teco_free (Teco_Scanner * dev) in teco_free() argument
377 if (dev == NULL) in teco_free()
380 teco_close (dev); in teco_free()
381 if (dev->devicename) in teco_free()
383 free (dev->devicename); in teco_free()
385 if (dev->buffer) in teco_free()
387 free (dev->buffer); in teco_free()
389 if (dev->image) in teco_free()
391 free (dev->image); in teco_free()
395 if (dev->opt[i].type == SANE_TYPE_STRING && dev->val[i].s) in teco_free()
397 free (dev->val[i].s); in teco_free()
401 free (dev); in teco_free()
408 teco_identify_scanner (Teco_Scanner * dev) in teco_identify_scanner() argument
419 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_identify_scanner()
420 NULL, 0, dev->buffer, &size); in teco_identify_scanner()
453 memcpy (dev->buffer, table, sizeof (table)); in teco_identify_scanner()
457 size = dev->buffer[4] + 5; /* total length of the inquiry data */ in teco_identify_scanner()
460 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_identify_scanner()
461 NULL, 0, dev->buffer, &size); in teco_identify_scanner()
472 if (memcmp (dev->buffer + 0x08, "DF-600M ", 8) == 0) in teco_identify_scanner()
474 memcpy (dev->buffer + 0x29, "\0TECO VM3510", 12); in teco_identify_scanner()
475 dev->buffer[4] = 0x30; /* change length */ in teco_identify_scanner()
486 hexdump (DBG_info2, "inquiry", dev->buffer, size); in teco_identify_scanner()
488 dev->scsi_type = dev->buffer[0] & 0x1f; in teco_identify_scanner()
489 memcpy (dev->scsi_vendor, dev->buffer + 0x08, 0x08); in teco_identify_scanner()
490 dev->scsi_vendor[0x08] = 0; in teco_identify_scanner()
491 memcpy (dev->scsi_product, dev->buffer + 0x10, 0x010); in teco_identify_scanner()
492 dev->scsi_product[0x10] = 0; in teco_identify_scanner()
493 memcpy (dev->scsi_version, dev->buffer + 0x20, 0x04); in teco_identify_scanner()
494 dev->scsi_version[0x04] = 0; in teco_identify_scanner()
495 memcpy (dev->scsi_teco_name, dev->buffer + 0x2A, 0x0B); in teco_identify_scanner()
496 dev->scsi_teco_name[0x0B] = 0; in teco_identify_scanner()
499 dev->scsi_vendor, dev->scsi_product, dev->scsi_version, in teco_identify_scanner()
500 dev->scsi_teco_name); in teco_identify_scanner()
507 if (dev->scsi_type == scanners[i].scsi_type && in teco_identify_scanner()
508 strcmp (dev->scsi_teco_name, scanners[i].scsi_teco_name) == 0) in teco_identify_scanner()
513 dev->def = &(scanners[i]); in teco_identify_scanner()
526 teco_get_inquiry_82 (Teco_Scanner * dev) in teco_get_inquiry_82() argument
539 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_get_inquiry_82()
540 NULL, 0, dev->buffer, &size); in teco_get_inquiry_82()
550 size = dev->buffer[3] + 4; in teco_get_inquiry_82()
555 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_get_inquiry_82()
556 NULL, 0, dev->buffer, &size); in teco_get_inquiry_82()
566 hexdump (DBG_info2, "inquiry page 0x82", dev->buffer, size); in teco_get_inquiry_82()
616 teco_mode_select (Teco_Scanner * dev) in teco_mode_select() argument
632 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_mode_select()
642 teco_set_window (Teco_Scanner * dev) in teco_set_window() argument
652 size = dev->def->window_size; in teco_set_window()
662 Ito16 (dev->x_resolution, &window[10]); in teco_set_window()
663 Ito16 (dev->y_resolution, &window[12]); in teco_set_window()
666 Ito32 (dev->x_tl, &window[14]); in teco_set_window()
667 Ito32 (dev->y_tl, &window[18]); in teco_set_window()
670 Ito32 (dev->width, &window[22]); in teco_set_window()
671 Ito32 (dev->length, &window[26]); in teco_set_window()
674 switch (dev->scan_mode) in teco_set_window()
678 i = get_string_list_index (dither_list, dev->val[OPT_DITHER].s); in teco_set_window()
690 window[34] = dev->depth; in teco_set_window()
714 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_set_window()
724 get_filled_data_length (Teco_Scanner * dev, size_t * to_read) in get_filled_data_length() argument
736 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in get_filled_data_length()
737 NULL, 0, dev->buffer, &size); in get_filled_data_length()
746 hexdump (DBG_info2, "get_filled_data_length return", dev->buffer, size); in get_filled_data_length()
748 *to_read = B24TOI (&dev->buffer[9]); in get_filled_data_length()
751 dev->params.lines, B16TOI (&dev->buffer[12]), in get_filled_data_length()
752 dev->params.bytes_per_line, B16TOI (&dev->buffer[14])); in get_filled_data_length()
754 if (dev->real_bytes_left == 0) in get_filled_data_length()
757 dev->params.lines = B16TOI (&dev->buffer[12]); in get_filled_data_length()
759 switch (dev->scan_mode) in get_filled_data_length()
762 dev->params.bytes_per_line = B16TOI (&dev->buffer[14]); in get_filled_data_length()
763 dev->params.pixels_per_line = dev->params.bytes_per_line * 8; in get_filled_data_length()
767 dev->params.pixels_per_line = B16TOI (&dev->buffer[14]); in get_filled_data_length()
768 dev->params.bytes_per_line = dev->params.pixels_per_line; in get_filled_data_length()
772 dev->params.pixels_per_line = B16TOI (&dev->buffer[14]); in get_filled_data_length()
773 if (dev->def->pass == 3) in get_filled_data_length()
775 dev->params.bytes_per_line = dev->params.pixels_per_line; in get_filled_data_length()
779 dev->params.bytes_per_line = dev->params.pixels_per_line * 3; in get_filled_data_length()
794 teco_scan (Teco_Scanner * dev) in teco_scan() argument
803 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL); in teco_scan()
813 teco_vendor_spec (Teco_Scanner * dev)
831 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len,
832 NULL, 0, dev->buffer, &size);
834 /*hexdump (DBG_info2, "calibration:", dev->buffer, size); */
844 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, NULL, 0, NULL, NULL);
857 teco_send_gamma (Teco_Scanner * dev) in teco_send_gamma() argument
874 if (dev->val[OPT_CUSTOM_GAMMA].w) in teco_send_gamma()
877 if (dev->scan_mode == TECO_GRAYSCALE) in teco_send_gamma()
883 param.gamma[1 * GAMMA_LENGTH + i] = dev->gamma_GRAY[i]; in teco_send_gamma()
893 param.gamma[0 * GAMMA_LENGTH + i] = dev->gamma_R[i]; in teco_send_gamma()
894 param.gamma[1 * GAMMA_LENGTH + i] = dev->gamma_G[i]; in teco_send_gamma()
895 param.gamma[2 * GAMMA_LENGTH + i] = dev->gamma_B[i]; in teco_send_gamma()
902 if (dev->scan_mode == TECO_BW) in teco_send_gamma()
907 dev->val[OPT_THRESHOLD].w * (GAMMA_LENGTH / 256); in teco_send_gamma()
941 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_send_gamma()
953 Teco_Scanner *dev; in attach_scanner() local
962 for (dev = first_dev; dev; dev = dev->next) in attach_scanner()
964 if (strcmp (dev->sane.name, devicename) == 0) in attach_scanner()
968 *devp = dev; in attach_scanner()
976 dev = teco_init (); in attach_scanner()
977 if (dev == NULL) in attach_scanner()
985 if (sanei_scsi_open (devicename, &sfd, teco_sense_handler, dev) != 0) in attach_scanner()
988 teco_free (dev); in attach_scanner()
993 dev->devicename = strdup (devicename); in attach_scanner()
994 dev->sfd = sfd; in attach_scanner()
997 if (teco_identify_scanner (dev) == SANE_FALSE) in attach_scanner()
1001 teco_free (dev); in attach_scanner()
1006 teco_get_inquiry_82 (dev); in attach_scanner()
1008 teco_close (dev); in attach_scanner()
1011 dev->sane.name = dev->devicename; in attach_scanner()
1012 dev->sane.vendor = dev->def->real_vendor; in attach_scanner()
1013 dev->sane.model = dev->def->real_product; in attach_scanner()
1014 dev->sane.type = "flatbed scanner"; in attach_scanner()
1017 dev->next = first_dev; in attach_scanner()
1018 first_dev = dev; in attach_scanner()
1022 *devp = dev; in attach_scanner()
1033 attach_one (const char *dev) in attach_one() argument
1035 attach_scanner (dev, NULL); in attach_one()
1041 teco_init_options (Teco_Scanner * dev) in teco_init_options() argument
1046 memset (dev->opt, 0, sizeof (dev->opt)); in teco_init_options()
1047 memset (dev->val, 0, sizeof (dev->val)); in teco_init_options()
1051 dev->opt[i].size = sizeof (SANE_Word); in teco_init_options()
1052 dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; in teco_init_options()
1056 dev->opt[OPT_NUM_OPTS].name = ""; in teco_init_options()
1057 dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; in teco_init_options()
1058 dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; in teco_init_options()
1059 dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; in teco_init_options()
1060 dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; in teco_init_options()
1061 dev->val[OPT_NUM_OPTS].w = OPT_NUM_OPTIONS; in teco_init_options()
1064 dev->opt[OPT_MODE_GROUP].title = SANE_TITLE_SCAN_MODE; in teco_init_options()
1065 dev->opt[OPT_MODE_GROUP].desc = ""; /* not valid for a group */ in teco_init_options()
1066 dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; in teco_init_options()
1067 dev->opt[OPT_MODE_GROUP].cap = 0; in teco_init_options()
1068 dev->opt[OPT_MODE_GROUP].size = 0; in teco_init_options()
1069 dev->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; in teco_init_options()
1072 dev->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; in teco_init_options()
1073 dev->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; in teco_init_options()
1074 dev->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; in teco_init_options()
1075 dev->opt[OPT_MODE].type = SANE_TYPE_STRING; in teco_init_options()
1076 dev->opt[OPT_MODE].size = max_string_size (scan_mode_list); in teco_init_options()
1077 dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; in teco_init_options()
1078 dev->opt[OPT_MODE].constraint.string_list = scan_mode_list; in teco_init_options()
1079 dev->val[OPT_MODE].s = (SANE_Char *) strdup (""); /* will be set later */ in teco_init_options()
1082 dev->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; in teco_init_options()
1083 dev->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; in teco_init_options()
1084 dev->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; in teco_init_options()
1085 dev->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; in teco_init_options()
1086 dev->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; in teco_init_options()
1087 dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1088 dev->opt[OPT_RESOLUTION].constraint.range = &dev->def->res_range; in teco_init_options()
1089 dev->val[OPT_RESOLUTION].w = 100; in teco_init_options()
1092 dev->opt[OPT_GEOMETRY_GROUP].title = SANE_I18N ("Geometry"); in teco_init_options()
1093 dev->opt[OPT_GEOMETRY_GROUP].desc = ""; /* not valid for a group */ in teco_init_options()
1094 dev->opt[OPT_GEOMETRY_GROUP].type = SANE_TYPE_GROUP; in teco_init_options()
1095 dev->opt[OPT_GEOMETRY_GROUP].cap = 0; in teco_init_options()
1096 dev->opt[OPT_GEOMETRY_GROUP].size = 0; in teco_init_options()
1097 dev->opt[OPT_GEOMETRY_GROUP].constraint_type = SANE_CONSTRAINT_NONE; in teco_init_options()
1100 dev->opt[OPT_TL_X].name = SANE_NAME_SCAN_TL_X; in teco_init_options()
1101 dev->opt[OPT_TL_X].title = SANE_TITLE_SCAN_TL_X; in teco_init_options()
1102 dev->opt[OPT_TL_X].desc = SANE_DESC_SCAN_TL_X; in teco_init_options()
1103 dev->opt[OPT_TL_X].type = SANE_TYPE_FIXED; in teco_init_options()
1104 dev->opt[OPT_TL_X].unit = SANE_UNIT_MM; in teco_init_options()
1105 dev->opt[OPT_TL_X].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1106 dev->opt[OPT_TL_X].constraint.range = &x_range; in teco_init_options()
1107 dev->val[OPT_TL_X].w = x_range.min; in teco_init_options()
1110 dev->opt[OPT_TL_Y].name = SANE_NAME_SCAN_TL_Y; in teco_init_options()
1111 dev->opt[OPT_TL_Y].title = SANE_TITLE_SCAN_TL_Y; in teco_init_options()
1112 dev->opt[OPT_TL_Y].desc = SANE_DESC_SCAN_TL_Y; in teco_init_options()
1113 dev->opt[OPT_TL_Y].type = SANE_TYPE_FIXED; in teco_init_options()
1114 dev->opt[OPT_TL_Y].unit = SANE_UNIT_MM; in teco_init_options()
1115 dev->opt[OPT_TL_Y].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1116 dev->opt[OPT_TL_Y].constraint.range = &y_range; in teco_init_options()
1117 dev->val[OPT_TL_Y].w = y_range.min; in teco_init_options()
1120 dev->opt[OPT_BR_X].name = SANE_NAME_SCAN_BR_X; in teco_init_options()
1121 dev->opt[OPT_BR_X].title = SANE_TITLE_SCAN_BR_X; in teco_init_options()
1122 dev->opt[OPT_BR_X].desc = SANE_DESC_SCAN_BR_X; in teco_init_options()
1123 dev->opt[OPT_BR_X].type = SANE_TYPE_FIXED; in teco_init_options()
1124 dev->opt[OPT_BR_X].unit = SANE_UNIT_MM; in teco_init_options()
1125 dev->opt[OPT_BR_X].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1126 dev->opt[OPT_BR_X].constraint.range = &x_range; in teco_init_options()
1127 dev->val[OPT_BR_X].w = x_range.max; in teco_init_options()
1130 dev->opt[OPT_BR_Y].name = SANE_NAME_SCAN_BR_Y; in teco_init_options()
1131 dev->opt[OPT_BR_Y].title = SANE_TITLE_SCAN_BR_Y; in teco_init_options()
1132 dev->opt[OPT_BR_Y].desc = SANE_DESC_SCAN_BR_Y; in teco_init_options()
1133 dev->opt[OPT_BR_Y].type = SANE_TYPE_FIXED; in teco_init_options()
1134 dev->opt[OPT_BR_Y].unit = SANE_UNIT_MM; in teco_init_options()
1135 dev->opt[OPT_BR_Y].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1136 dev->opt[OPT_BR_Y].constraint.range = &y_range; in teco_init_options()
1137 dev->val[OPT_BR_Y].w = y_range.max; in teco_init_options()
1140 dev->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); in teco_init_options()
1141 dev->opt[OPT_ENHANCEMENT_GROUP].desc = ""; /* not valid for a group */ in teco_init_options()
1142 dev->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; in teco_init_options()
1143 dev->opt[OPT_ENHANCEMENT_GROUP].cap = SANE_CAP_ADVANCED; in teco_init_options()
1144 dev->opt[OPT_ENHANCEMENT_GROUP].size = 0; in teco_init_options()
1145 dev->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; in teco_init_options()
1148 dev->opt[OPT_DITHER].name = "dither"; in teco_init_options()
1149 dev->opt[OPT_DITHER].title = SANE_I18N ("Dither"); in teco_init_options()
1150 dev->opt[OPT_DITHER].desc = SANE_I18N ("Dither"); in teco_init_options()
1151 dev->opt[OPT_DITHER].type = SANE_TYPE_STRING; in teco_init_options()
1152 dev->opt[OPT_DITHER].size = max_string_size (dither_list); in teco_init_options()
1153 dev->opt[OPT_DITHER].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1154 dev->opt[OPT_DITHER].constraint_type = SANE_CONSTRAINT_STRING_LIST; in teco_init_options()
1155 dev->opt[OPT_DITHER].constraint.string_list = dither_list; in teco_init_options()
1156 dev->val[OPT_DITHER].s = strdup (dither_list[0]); in teco_init_options()
1159 dev->opt[OPT_CUSTOM_GAMMA].name = SANE_NAME_CUSTOM_GAMMA; in teco_init_options()
1160 dev->opt[OPT_CUSTOM_GAMMA].title = SANE_TITLE_CUSTOM_GAMMA; in teco_init_options()
1161 dev->opt[OPT_CUSTOM_GAMMA].desc = SANE_DESC_CUSTOM_GAMMA; in teco_init_options()
1162 dev->opt[OPT_CUSTOM_GAMMA].type = SANE_TYPE_BOOL; in teco_init_options()
1163 dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1164 dev->val[OPT_CUSTOM_GAMMA].w = SANE_FALSE; in teco_init_options()
1167 dev->opt[OPT_GAMMA_VECTOR_R].name = SANE_NAME_GAMMA_VECTOR_R; in teco_init_options()
1168 dev->opt[OPT_GAMMA_VECTOR_R].title = SANE_TITLE_GAMMA_VECTOR_R; in teco_init_options()
1169 dev->opt[OPT_GAMMA_VECTOR_R].desc = SANE_DESC_GAMMA_VECTOR_R; in teco_init_options()
1170 dev->opt[OPT_GAMMA_VECTOR_R].type = SANE_TYPE_INT; in teco_init_options()
1171 dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1172 dev->opt[OPT_GAMMA_VECTOR_R].unit = SANE_UNIT_NONE; in teco_init_options()
1173 dev->opt[OPT_GAMMA_VECTOR_R].size = GAMMA_LENGTH * sizeof (SANE_Word); in teco_init_options()
1174 dev->opt[OPT_GAMMA_VECTOR_R].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1175 dev->opt[OPT_GAMMA_VECTOR_R].constraint.range = &gamma_range; in teco_init_options()
1176 dev->val[OPT_GAMMA_VECTOR_R].wa = dev->gamma_R; in teco_init_options()
1179 dev->opt[OPT_GAMMA_VECTOR_G].name = SANE_NAME_GAMMA_VECTOR_G; in teco_init_options()
1180 dev->opt[OPT_GAMMA_VECTOR_G].title = SANE_TITLE_GAMMA_VECTOR_G; in teco_init_options()
1181 dev->opt[OPT_GAMMA_VECTOR_G].desc = SANE_DESC_GAMMA_VECTOR_G; in teco_init_options()
1182 dev->opt[OPT_GAMMA_VECTOR_G].type = SANE_TYPE_INT; in teco_init_options()
1183 dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1184 dev->opt[OPT_GAMMA_VECTOR_G].unit = SANE_UNIT_NONE; in teco_init_options()
1185 dev->opt[OPT_GAMMA_VECTOR_G].size = GAMMA_LENGTH * sizeof (SANE_Word); in teco_init_options()
1186 dev->opt[OPT_GAMMA_VECTOR_G].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1187 dev->opt[OPT_GAMMA_VECTOR_G].constraint.range = &gamma_range; in teco_init_options()
1188 dev->val[OPT_GAMMA_VECTOR_G].wa = dev->gamma_G; in teco_init_options()
1191 dev->opt[OPT_GAMMA_VECTOR_B].name = SANE_NAME_GAMMA_VECTOR_B; in teco_init_options()
1192 dev->opt[OPT_GAMMA_VECTOR_B].title = SANE_TITLE_GAMMA_VECTOR_B; in teco_init_options()
1193 dev->opt[OPT_GAMMA_VECTOR_B].desc = SANE_DESC_GAMMA_VECTOR_B; in teco_init_options()
1194 dev->opt[OPT_GAMMA_VECTOR_B].type = SANE_TYPE_INT; in teco_init_options()
1195 dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1196 dev->opt[OPT_GAMMA_VECTOR_B].unit = SANE_UNIT_NONE; in teco_init_options()
1197 dev->opt[OPT_GAMMA_VECTOR_B].size = GAMMA_LENGTH * sizeof (SANE_Word); in teco_init_options()
1198 dev->opt[OPT_GAMMA_VECTOR_B].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1199 dev->opt[OPT_GAMMA_VECTOR_B].constraint.range = &gamma_range; in teco_init_options()
1200 dev->val[OPT_GAMMA_VECTOR_B].wa = dev->gamma_B; in teco_init_options()
1203 dev->opt[OPT_GAMMA_VECTOR_GRAY].name = SANE_NAME_GAMMA_VECTOR; in teco_init_options()
1204 dev->opt[OPT_GAMMA_VECTOR_GRAY].title = SANE_TITLE_GAMMA_VECTOR; in teco_init_options()
1205 dev->opt[OPT_GAMMA_VECTOR_GRAY].desc = SANE_DESC_GAMMA_VECTOR; in teco_init_options()
1206 dev->opt[OPT_GAMMA_VECTOR_GRAY].type = SANE_TYPE_INT; in teco_init_options()
1207 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1208 dev->opt[OPT_GAMMA_VECTOR_GRAY].unit = SANE_UNIT_NONE; in teco_init_options()
1209 dev->opt[OPT_GAMMA_VECTOR_GRAY].size = GAMMA_LENGTH * sizeof (SANE_Word); in teco_init_options()
1210 dev->opt[OPT_GAMMA_VECTOR_GRAY].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1211 dev->opt[OPT_GAMMA_VECTOR_GRAY].constraint.range = &gamma_range; in teco_init_options()
1212 dev->val[OPT_GAMMA_VECTOR_GRAY].wa = dev->gamma_GRAY; in teco_init_options()
1215 dev->opt[OPT_THRESHOLD].name = SANE_NAME_THRESHOLD; in teco_init_options()
1216 dev->opt[OPT_THRESHOLD].title = SANE_TITLE_THRESHOLD; in teco_init_options()
1217 dev->opt[OPT_THRESHOLD].desc = SANE_DESC_THRESHOLD; in teco_init_options()
1218 dev->opt[OPT_THRESHOLD].type = SANE_TYPE_INT; in teco_init_options()
1219 dev->opt[OPT_THRESHOLD].unit = SANE_UNIT_NONE; in teco_init_options()
1220 dev->opt[OPT_THRESHOLD].size = sizeof (SANE_Int); in teco_init_options()
1221 dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; in teco_init_options()
1222 dev->opt[OPT_THRESHOLD].constraint_type = SANE_CONSTRAINT_RANGE; in teco_init_options()
1223 dev->opt[OPT_THRESHOLD].constraint.range = &threshold_range; in teco_init_options()
1224 dev->val[OPT_THRESHOLD].w = 128; in teco_init_options()
1227 dev->opt[OPT_PREVIEW].name = SANE_NAME_PREVIEW; in teco_init_options()
1228 dev->opt[OPT_PREVIEW].title = SANE_TITLE_PREVIEW; in teco_init_options()
1229 dev->opt[OPT_PREVIEW].desc = SANE_DESC_PREVIEW; in teco_init_options()
1230 dev->opt[OPT_PREVIEW].type = SANE_TYPE_BOOL; in teco_init_options()
1231 dev->opt[OPT_PREVIEW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_SOFT_SELECT; in teco_init_options()
1232 dev->val[OPT_PREVIEW].w = SANE_FALSE; in teco_init_options()
1236 sane_control_option (dev, OPT_MODE, SANE_ACTION_SET_VALUE, in teco_init_options()
1244 teco_wait_scanner (Teco_Scanner * dev) in teco_wait_scanner() argument
1261 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_wait_scanner()
1278 teco_fill_image (Teco_Scanner * dev) in teco_fill_image() argument
1287 assert (dev->image_begin == dev->image_end); in teco_fill_image()
1288 assert (dev->real_bytes_left > 0); in teco_fill_image()
1290 dev->image_begin = 0; in teco_fill_image()
1291 dev->image_end = 0; in teco_fill_image()
1293 while (dev->real_bytes_left) in teco_fill_image()
1301 status = get_filled_data_length (dev, &size); in teco_fill_image()
1308 if (size > dev->real_bytes_left) in teco_fill_image()
1309 size = dev->real_bytes_left; in teco_fill_image()
1310 if (size > dev->image_size - dev->image_end) in teco_fill_image()
1311 size = dev->image_size - dev->image_end; in teco_fill_image()
1314 size = size - (size % dev->params.bytes_per_line); in teco_fill_image()
1320 assert (dev->image_end != 0); in teco_fill_image()
1325 (long) size, dev->params.bytes_per_line); in teco_fill_image()
1331 image = dev->image + dev->image_end; in teco_fill_image()
1333 status = sanei_scsi_cmd2 (dev->sfd, cdb.data, cdb.len, in teco_fill_image()
1343 assert ((size % dev->params.bytes_per_line) == 0); in teco_fill_image()
1346 (long) dev->real_bytes_left); in teco_fill_image()
1348 if (dev->scan_mode == TECO_COLOR) in teco_fill_image()
1350 if (dev->def->pass == 1) in teco_fill_image()
1356 int nb_lines = size / dev->params.bytes_per_line; in teco_fill_image()
1362 unsigned char *dest = dev->buffer; in teco_fill_image()
1364 for (j = 0; j < dev->params.pixels_per_line; j++) in teco_fill_image()
1366 *dest = src[j + 0 * dev->params.pixels_per_line]; in teco_fill_image()
1368 *dest = src[j + 1 * dev->params.pixels_per_line]; in teco_fill_image()
1370 *dest = src[j + 2 * dev->params.pixels_per_line]; in teco_fill_image()
1375 memcpy (src, dev->buffer, dev->params.bytes_per_line); in teco_fill_image()
1377 src += dev->params.bytes_per_line; in teco_fill_image()
1382 dev->image_end += size; in teco_fill_image()
1383 dev->real_bytes_left -= size; in teco_fill_image()
1395 teco_copy_raw_to_frontend (Teco_Scanner * dev, SANE_Byte * buf, size_t * len) in teco_copy_raw_to_frontend() argument
1399 size = dev->image_end - dev->image_begin; in teco_copy_raw_to_frontend()
1406 switch (dev->scan_mode) in teco_copy_raw_to_frontend()
1411 unsigned char *src = dev->image + dev->image_begin; in teco_copy_raw_to_frontend()
1425 memcpy (buf, dev->image + dev->image_begin, size); in teco_copy_raw_to_frontend()
1429 dev->image_begin += size; in teco_copy_raw_to_frontend()
1434 do_cancel (Teco_Scanner * dev) in do_cancel() argument
1438 if (dev->scanning == SANE_TRUE) in do_cancel()
1442 dev->x_resolution = 300; in do_cancel()
1443 dev->y_resolution = 300; in do_cancel()
1444 dev->x_tl = 0; in do_cancel()
1445 dev->y_tl = 0; in do_cancel()
1446 dev->width = 0; in do_cancel()
1447 dev->length = 0; in do_cancel()
1449 teco_set_window (dev); in do_cancel()
1451 teco_scan (dev); in do_cancel()
1453 teco_close (dev); in do_cancel()
1456 dev->scanning = SANE_FALSE; in do_cancel()
1490 /* default to /dev/scanner instead of insisting on config file */ in sane_init()
1491 attach_scanner ("/dev/scanner", 0); in sane_init()
1517 Teco_Scanner *dev; in sane_get_devices() local
1530 for (dev = first_dev; i < num_devices; dev = dev->next) in sane_get_devices()
1531 devlist[i++] = &dev->sane; in sane_get_devices()
1544 Teco_Scanner *dev; in sane_open() local
1554 for (dev = first_dev; dev; dev = dev->next) in sane_open()
1556 if (strcmp (dev->sane.name, devicename) == 0) in sane_open()
1562 if (!dev) in sane_open()
1564 status = attach_scanner (devicename, &dev); in sane_open()
1574 dev = first_dev; /* empty devicename -> use first device */ in sane_open()
1577 if (!dev) in sane_open()
1584 teco_init_options (dev); in sane_open()
1597 dev->gamma_R[i] = i / shift; in sane_open()
1598 dev->gamma_G[i] = i / shift; in sane_open()
1599 dev->gamma_B[i] = i / shift; in sane_open()
1600 dev->gamma_GRAY[i] = i / shift; in sane_open()
1604 *handle = dev; in sane_open()
1614 Teco_Scanner *dev = handle; in sane_get_option_descriptor() local
1625 return dev->opt + option; in sane_get_option_descriptor()
1632 Teco_Scanner *dev = handle; in sane_control_option() local
1645 if (dev->scanning) in sane_control_option()
1655 cap = dev->opt[option].cap; in sane_control_option()
1661 name = dev->opt[option].name; in sane_control_option()
1681 *(SANE_Word *) val = dev->val[option].w; in sane_control_option()
1687 strcpy (val, dev->val[option].s); in sane_control_option()
1695 memcpy (val, dev->val[option].wa, dev->opt[option].size); in sane_control_option()
1711 status = sanei_constrain_value (dev->opt + option, val, info); in sane_control_option()
1731 dev->val[option].w = *(SANE_Word *) val; in sane_control_option()
1737 dev->val[option].w = *(SANE_Word *) val; in sane_control_option()
1742 free (dev->val[option].s); in sane_control_option()
1743 dev->val[option].s = (SANE_String) strdup (val); in sane_control_option()
1748 if (strcmp (dev->val[option].s, val) == 0) in sane_control_option()
1751 free (dev->val[OPT_MODE].s); in sane_control_option()
1752 dev->val[OPT_MODE].s = (SANE_Char *) strdup (val); in sane_control_option()
1754 dev->opt[OPT_DITHER].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1755 dev->opt[OPT_CUSTOM_GAMMA].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1756 dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1757 dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1758 dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1759 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1760 dev->opt[OPT_THRESHOLD].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1762 if (strcmp (dev->val[OPT_MODE].s, BLACK_WHITE_STR) == 0) in sane_control_option()
1764 dev->depth = 8; in sane_control_option()
1765 dev->scan_mode = TECO_BW; in sane_control_option()
1766 dev->opt[OPT_DITHER].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1767 dev->opt[OPT_THRESHOLD].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1769 else if (strcmp (dev->val[OPT_MODE].s, GRAY_STR) == 0) in sane_control_option()
1771 dev->scan_mode = TECO_GRAYSCALE; in sane_control_option()
1772 dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1773 if (dev->val[OPT_CUSTOM_GAMMA].w) in sane_control_option()
1775 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1777 dev->depth = 8; in sane_control_option()
1779 else if (strcmp (dev->val[OPT_MODE].s, COLOR_STR) == 0) in sane_control_option()
1781 dev->scan_mode = TECO_COLOR; in sane_control_option()
1782 dev->opt[OPT_CUSTOM_GAMMA].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1783 if (dev->val[OPT_CUSTOM_GAMMA].w) in sane_control_option()
1785 dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1786 dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1787 dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1789 dev->depth = 8; in sane_control_option()
1802 memcpy (dev->val[option].wa, val, dev->opt[option].size); in sane_control_option()
1806 dev->val[OPT_CUSTOM_GAMMA].w = *(SANE_Word *) val; in sane_control_option()
1807 if (dev->val[OPT_CUSTOM_GAMMA].w) in sane_control_option()
1810 if (dev->scan_mode == TECO_GRAYSCALE) in sane_control_option()
1812 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1817 dev->opt[OPT_GAMMA_VECTOR_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1818 dev->opt[OPT_GAMMA_VECTOR_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1819 dev->opt[OPT_GAMMA_VECTOR_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1824 dev->opt[OPT_GAMMA_VECTOR_R].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1825 dev->opt[OPT_GAMMA_VECTOR_G].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1826 dev->opt[OPT_GAMMA_VECTOR_B].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1827 dev->opt[OPT_GAMMA_VECTOR_GRAY].cap |= SANE_CAP_INACTIVE; in sane_control_option()
1848 Teco_Scanner *dev = handle; in sane_get_parameters() local
1852 if (!(dev->scanning)) in sane_get_parameters()
1857 if (dev->val[OPT_PREVIEW].w == SANE_TRUE) in sane_get_parameters()
1859 dev->x_resolution = 22; in sane_get_parameters()
1860 dev->y_resolution = 22; in sane_get_parameters()
1861 dev->x_tl = 0; in sane_get_parameters()
1862 dev->y_tl = 0; in sane_get_parameters()
1863 dev->x_br = mmToIlu (SANE_UNFIX (x_range.max)); in sane_get_parameters()
1864 dev->y_br = mmToIlu (SANE_UNFIX (y_range.max)); in sane_get_parameters()
1868 dev->x_resolution = dev->val[OPT_RESOLUTION].w; in sane_get_parameters()
1869 dev->y_resolution = dev->val[OPT_RESOLUTION].w; in sane_get_parameters()
1870 if (dev->x_resolution > dev->def->x_resolution_max) in sane_get_parameters()
1872 dev->x_resolution = dev->def->x_resolution_max; in sane_get_parameters()
1875 dev->x_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_X].w)); in sane_get_parameters()
1876 dev->y_tl = mmToIlu (SANE_UNFIX (dev->val[OPT_TL_Y].w)); in sane_get_parameters()
1877 dev->x_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_X].w)); in sane_get_parameters()
1878 dev->y_br = mmToIlu (SANE_UNFIX (dev->val[OPT_BR_Y].w)); in sane_get_parameters()
1882 if (dev->x_tl > dev->x_br) in sane_get_parameters()
1885 s = dev->x_tl; in sane_get_parameters()
1886 dev->x_tl = dev->x_br; in sane_get_parameters()
1887 dev->x_br = s; in sane_get_parameters()
1889 if (dev->y_tl > dev->y_br) in sane_get_parameters()
1892 s = dev->y_tl; in sane_get_parameters()
1893 dev->y_tl = dev->y_br; in sane_get_parameters()
1894 dev->y_br = s; in sane_get_parameters()
1897 dev->width = dev->x_br - dev->x_tl; in sane_get_parameters()
1898 dev->length = dev->y_br - dev->y_tl; in sane_get_parameters()
1901 memset (&dev->params, 0, sizeof (SANE_Parameters)); in sane_get_parameters()
1903 dev->params.last_frame = SANE_TRUE; in sane_get_parameters()
1905 switch (dev->scan_mode) in sane_get_parameters()
1908 dev->params.format = SANE_FRAME_GRAY; in sane_get_parameters()
1909 dev->params.pixels_per_line = in sane_get_parameters()
1910 ((dev->width * dev->x_resolution) / 300) & ~0x7; in sane_get_parameters()
1911 dev->params.bytes_per_line = dev->params.pixels_per_line / 8; in sane_get_parameters()
1912 dev->params.depth = 1; in sane_get_parameters()
1913 dev->pass = 1; in sane_get_parameters()
1916 dev->params.format = SANE_FRAME_GRAY; in sane_get_parameters()
1917 dev->params.pixels_per_line = in sane_get_parameters()
1918 ((dev->width * dev->x_resolution) / 300); in sane_get_parameters()
1919 dev->params.bytes_per_line = dev->params.pixels_per_line; in sane_get_parameters()
1920 dev->params.depth = 8; in sane_get_parameters()
1921 dev->pass = 1; in sane_get_parameters()
1924 dev->params.format = SANE_FRAME_RGB; in sane_get_parameters()
1925 dev->params.pixels_per_line = in sane_get_parameters()
1926 ((dev->width * dev->x_resolution) / 300); in sane_get_parameters()
1927 dev->pass = dev->def->pass; in sane_get_parameters()
1928 dev->params.bytes_per_line = dev->params.pixels_per_line * 3; in sane_get_parameters()
1929 dev->params.depth = 8; in sane_get_parameters()
1933 dev->params.lines = (dev->length * dev->y_resolution) / 300; in sane_get_parameters()
1939 *params = (dev->params); in sane_get_parameters()
1950 Teco_Scanner *dev = handle; in sane_start() local
1956 if (!(dev->scanning)) in sane_start()
1961 (dev->devicename, &(dev->sfd), teco_sense_handler, dev) != 0) in sane_start()
1968 sane_get_parameters (dev, NULL); in sane_start()
1971 status = teco_wait_scanner (dev); in sane_start()
1974 teco_close (dev); in sane_start()
1978 status = teco_mode_select (dev); in sane_start()
1981 teco_close (dev); in sane_start()
1985 if (dev->scan_mode == TECO_COLOR) in sane_start()
1987 dev->pass = dev->def->pass; in sane_start()
1991 dev->pass = 1; in sane_start()
1994 if (dev->def->tecoref != TECO_VM3510) in sane_start()
1996 status = teco_set_window (dev); in sane_start()
1999 teco_close (dev); in sane_start()
2003 dev->real_bytes_left = 0; in sane_start()
2004 status = get_filled_data_length (dev, &size); in sane_start()
2007 teco_close (dev); in sane_start()
2014 teco_vendor_spec (dev); in sane_start()
2017 teco_close (dev); in sane_start()
2022 status = teco_send_gamma (dev); in sane_start()
2025 teco_close (dev); in sane_start()
2029 status = teco_set_window (dev); in sane_start()
2032 teco_close (dev); in sane_start()
2036 status = teco_scan (dev); in sane_start()
2039 teco_close (dev); in sane_start()
2043 if (dev->def->tecoref == TECO_VM3510) in sane_start()
2045 dev->real_bytes_left = 0; in sane_start()
2046 status = get_filled_data_length (dev, &size); in sane_start()
2049 teco_close (dev); in sane_start()
2057 dev->pass--; in sane_start()
2061 if (dev->scan_mode == TECO_COLOR && dev->def->pass > 1) in sane_start()
2066 dev->params.format = frames[dev->pass]; in sane_start()
2070 if (dev->pass > 1) in sane_start()
2072 dev->params.last_frame = SANE_FALSE; in sane_start()
2076 dev->params.last_frame = SANE_TRUE; in sane_start()
2079 dev->image_end = 0; in sane_start()
2080 dev->image_begin = 0; in sane_start()
2082 dev->bytes_left = dev->params.bytes_per_line * dev->params.lines; in sane_start()
2083 dev->real_bytes_left = dev->params.bytes_per_line * dev->params.lines; in sane_start()
2085 dev->scanning = SANE_TRUE; in sane_start()
2097 Teco_Scanner *dev = handle; in sane_read() local
2105 if (!(dev->scanning)) in sane_read()
2108 return do_cancel (dev); in sane_read()
2111 if (dev->bytes_left <= 0) in sane_read()
2120 if (dev->image_begin == dev->image_end) in sane_read()
2123 status = teco_fill_image (dev); in sane_read()
2131 if (dev->image_begin == dev->image_end) in sane_read()
2139 if (size > dev->bytes_left) in sane_read()
2141 size = dev->bytes_left; in sane_read()
2143 teco_copy_raw_to_frontend (dev, buf + buf_offset, &size); in sane_read()
2147 dev->bytes_left -= size; in sane_read()
2151 while ((buf_offset != max_len) && dev->bytes_left); in sane_read()
2154 (long) dev->bytes_left); in sane_read()
2163 Teco_Scanner *dev = handle; in sane_set_io_mode() local
2167 if (dev->scanning == SANE_FALSE) in sane_set_io_mode()
2199 Teco_Scanner *dev = handle; in sane_cancel() local
2203 do_cancel (dev); in sane_cancel()
2211 Teco_Scanner *dev = handle; in sane_close() local
2216 do_cancel (dev); in sane_close()
2217 teco_close (dev); in sane_close()
2219 /* Unlink dev. */ in sane_close()
2220 if (first_dev == dev) in sane_close()
2222 first_dev = dev->next; in sane_close()
2227 while (dev_tmp->next && dev_tmp->next != dev) in sane_close()
2237 teco_free (dev); in sane_close()