• Home
  • Raw
  • Download

Lines Matching +full:debian +full:- +full:11 +full:- +full:mini

1 /* sane - Scanner Access Now Easy.
3 Copyright (C) 2004 - 2006 Gerard Klaver <gerard at gkall dot hobby dot nl>
18 (c) 1998-2002 Gerd Knorr (GNU GPL license 2).
34 ------------------------------------------------------------------
43 - sane_init() : initialize backend, attach vidcams
44 . - sane_get_devices() : query list of vidcam devices
45 . - sane_open() : open a particular vidcam device
46 . . - sane_set_io_mode : set blocking mode
47 . . - sane_get_select_fd : get vidcam fd
48 . . - sane_get_option_descriptor() : get option information
49 . . - sane_control_option() : change option values
51 . . - sane_start() : start image acquisition
52 . . - sane_get_parameters() : returns actual scan parameters
53 . . - sane_read() : read image data (from pipe)
57 . . - sane_cancel() : cancel operation
58 . - sane_close() : close opened vidcam device
59 - sane_exit() : terminate use of backend
61 /*--------------------------------------------------------------------------*/
63 #define BUILD 1 /* 2004/09/09 update 20-04-2006 */
67 /* --------------------- SANE INTERNATIONALISATION ------------------------ */
92 /* for add-text routine */
95 /*-----------------------*/
101 /*--------------------------------------------------------------------------*/
112 /*-----------------------------------------minium, maximum, quantization----*/
113 static const SANE_Range brightness_range = { -128, 128, 1 };
115 static const SANE_Range red_level_range = { -32, 32, 1 };
117 static const SANE_Range green_level_range = { -32, 32, 1 };
119 static const SANE_Range blue_level_range = { -32, 32, 1 };
121 /*--------------------------------------------------------------------------*/
126 {176, 144, 0, 1, 2}, /* QCIF selected by dev->CIF */
128 {160, 120, 0, 1, 2}, /* QSIF ,, dev->VGA */
142 "Konica", "e-mini",
150 "Creative", "WebCam Go mini",
160 /*----------------------------------------------------------- */
257 dev->windoww_size = 0x20; in stv680_init()
258 dev->windoww = malloc (dev->windoww_size); in stv680_init()
259 if (dev->windoww == NULL) in stv680_init()
266 dev->windowr_size = 0x20; in stv680_init()
267 dev->windowr = malloc (dev->windowr_size); in stv680_init()
268 if (dev->windowr == NULL) in stv680_init()
270 free (dev->windoww); in stv680_init()
275 dev->fd = -1; in stv680_init()
292 if (dev->CIF) in stv680_init_2()
293 dev->buffer_size = 356 * 292; in stv680_init_2()
294 if (dev->VGA) in stv680_init_2()
295 dev->buffer_size = 644 * 484; in stv680_init_2()
296 DBG (DBG_proc, "stv680_init_2: dev->buffer = 0x%lx\n", (unsigned long) (size_t) dev->buffer_size); in stv680_init_2()
298 dev->buffer = malloc (dev->buffer_size); in stv680_init_2()
300 if (dev->buffer == NULL) in stv680_init_2()
302 free (dev->windowr); in stv680_init_2()
303 free (dev->windoww); in stv680_init_2()
309 dev->output_size = dev->buffer_size * 3; in stv680_init_2()
311 dev->output = malloc (dev->output_size); in stv680_init_2()
312 if (dev->output == NULL) in stv680_init_2()
314 free (dev->windowr); in stv680_init_2()
315 free (dev->windoww); in stv680_init_2()
316 free (dev->buffer); in stv680_init_2()
321 dev->image_size = dev->buffer_size; in stv680_init_2()
323 dev->image = malloc (dev->image_size); in stv680_init_2()
324 if (dev->image == NULL) in stv680_init_2()
326 free (dev->windowr); in stv680_init_2()
327 free (dev->windoww); in stv680_init_2()
328 free (dev->buffer); in stv680_init_2()
329 free (dev->output); in stv680_init_2()
346 if (dev->fd != -1) in stv680_close()
349 DBG (DBG_proc, "stv680_close: fd !=-1 \n"); in stv680_close()
350 sanei_usb_close (dev->fd); in stv680_close()
351 dev->fd = -1; in stv680_close()
369 if (dev->devicename) in stv680_free()
371 free (dev->devicename); in stv680_free()
373 if (dev->buffer) in stv680_free()
375 free (dev->buffer); in stv680_free()
377 if (dev->output) in stv680_free()
379 free (dev->output); in stv680_free()
381 if (dev->image) in stv680_free()
383 free (dev->image); in stv680_free()
385 if (dev->windoww) in stv680_free()
387 free (dev->windoww); in stv680_free()
389 if (dev->windowr) in stv680_free()
391 free (dev->windowr); in stv680_free()
395 if (dev->opt[i].type == SANE_TYPE_STRING && dev->val[i].s) in stv680_free()
397 free (dev->val[i].s); in stv680_free()
400 if (dev->resolutions_list) in stv680_free()
401 free (dev->resolutions_list); in stv680_free()
414 /* seems a problem on some systems (Debian amd64 unstable 19042006) in stv680_set_config()
416 status = sanei_usb_set_configuration (dev->fd, configuration); in stv680_set_config()
425 status = sanei_usb_claim_interface (dev->fd, interface); in stv680_set_config()
433 status = sanei_usb_set_altinterface (dev->fd, alternate); in stv680_set_config()
459 sizew = dev->windoww_size; in stv680_reset_vidcam()
460 sizer = dev->windowr_size; in stv680_reset_vidcam()
462 memset (dev->windoww, 0, sizew); in stv680_reset_vidcam()
463 memset (dev->windowr, 0, sizer); in stv680_reset_vidcam()
467 sanei_usb_control_msg (dev->fd, 0x41, 0x0a, 0x0000, 0, sizew, in stv680_reset_vidcam()
468 dev->windoww); in stv680_reset_vidcam()
479 sanei_usb_control_msg (dev->fd, 0x41, 0x04, 0x0000, 0, sizew, in stv680_reset_vidcam()
480 dev->windoww); in stv680_reset_vidcam()
489 sanei_usb_control_msg (dev->fd, 0xc1, 0x80, 0x0000, 0, sizer, in stv680_reset_vidcam()
490 dev->windowr); in stv680_reset_vidcam()
496 dev->windowr[0], dev->windowr[1]); in stv680_reset_vidcam()
504 dev->windowr, sizer); in stv680_reset_vidcam()
534 status = sanei_usb_get_vendor_product (dev->fd, &vendor, &product); in stv680_identify_vidcam()
545 dev->hw = &(vidcams[i]); in stv680_identify_vidcam()
547 sizer = dev->windowr_size; in stv680_identify_vidcam()
548 memset (dev->windowr, 0, sizer); in stv680_identify_vidcam()
562 sanei_usb_control_msg (dev->fd, 0xc1, 0x88, 0x5678, 0, sizer, in stv680_identify_vidcam()
563 dev->windowr); in stv680_identify_vidcam()
571 if ((dev->windowr[0] != 0x56) || (dev->windowr[1] != 0x78)) in stv680_identify_vidcam()
576 hexdump (DBG_info2, "urb12 window", dev->windowr, sizer); in stv680_identify_vidcam()
580 hexdump (DBG_info2, "urb12 ping data", dev->windowr, sizer); in stv680_identify_vidcam()
584 sanei_usb_control_msg (dev->fd, 0xc1, 0x85, 0x0000, 0, sizer, in stv680_identify_vidcam()
585 dev->windowr); in stv680_identify_vidcam()
589 hexdump (DBG_info2, "urbxx CMDID_GET_CAMERA_INFO", dev->windowr, in stv680_identify_vidcam()
592 dev->SupportedModes = dev->windowr[7]; in stv680_identify_vidcam()
593 i = dev->SupportedModes; in stv680_identify_vidcam()
594 dev->QSIF = 0; in stv680_identify_vidcam()
595 dev->CIF = 0; in stv680_identify_vidcam()
596 dev->QCIF = 0; in stv680_identify_vidcam()
597 dev->VGA = 0; in stv680_identify_vidcam()
598 dev->QVGA = 0; in stv680_identify_vidcam()
600 dev->CIF = 1; in stv680_identify_vidcam()
602 dev->VGA = 1; in stv680_identify_vidcam()
604 dev->QVGA = 1; in stv680_identify_vidcam()
606 dev->QCIF = 1; in stv680_identify_vidcam()
607 dev->QSIF = dev->QVGA; /* for software subsample */ in stv680_identify_vidcam()
608 if (dev->SupportedModes == 0) in stv680_identify_vidcam()
612 i = -1; in stv680_identify_vidcam()
617 if (dev->VGA) in stv680_identify_vidcam()
619 if (dev->CIF) in stv680_identify_vidcam()
621 if (dev->QVGA) in stv680_identify_vidcam()
623 if (dev->QCIF) in stv680_identify_vidcam()
628 DBG (DBG_proc, "STV(i): Firmware rev is %i.%i\n", dev->windowr[0], in stv680_identify_vidcam()
629 dev->windowr[1]); in stv680_identify_vidcam()
630 DBG (DBG_proc, "STV(i): ASIC rev is %i.%i\n", dev->windowr[2], in stv680_identify_vidcam()
631 dev->windowr[3]); in stv680_identify_vidcam()
632 DBG (DBG_proc, "STV(i): Sensor ID is %i.%i\n", (dev->windowr[4]), in stv680_identify_vidcam()
633 (dev->windowr[5])); in stv680_identify_vidcam()
635 dev->HardwareConfig = dev->windowr[6]; in stv680_identify_vidcam()
636 i = dev->HardwareConfig; in stv680_identify_vidcam()
674 sanei_usb_control_msg (dev->fd, 0xc1, 0x86, 0x0000, 0, sizer, in stv680_identify_vidcam()
675 dev->windowr); in stv680_identify_vidcam()
680 hexdump (DBG_info2, "urb25 CMDID_GET_IMAGE_INFO", dev->windowr, in stv680_identify_vidcam()
683 ((dev->windowr[0] << 8) + (dev->windowr[1]))); in stv680_identify_vidcam()
687 ((dev->windowr[2] << 8) + (dev->windowr[3]))); in stv680_identify_vidcam()
689 ((dev->windowr[4] << 8) + (dev->windowr[5]))); in stv680_identify_vidcam()
691 ((dev->windowr[6] << 8) + (dev->windowr[7]))); in stv680_identify_vidcam()
693 ((dev->windowr[8] << 24) + (dev->windowr[9] << 16) + in stv680_identify_vidcam()
694 (dev->windowr[10] << 8) + (dev->windowr[11]))); in stv680_identify_vidcam()
725 sizew = dev->windoww_size; in stv680_vidcam_init()
726 sizer = dev->windowr_size; in stv680_vidcam_init()
728 memset (dev->windoww, 0, sizew); in stv680_vidcam_init()
729 memset (dev->windowr, 0, sizer); in stv680_vidcam_init()
732 dev->video_status = 0x04; /* dummy value busy */ in stv680_vidcam_init()
734 while (dev->video_status == 0x04) in stv680_vidcam_init()
738 sanei_usb_control_msg (dev->fd, 0xc1, 0x8d, 0x0000, 0, sizer, in stv680_vidcam_init()
739 dev->windowr); in stv680_vidcam_init()
744 dev->windowr, sizer); in stv680_vidcam_init()
746 dev->video_status = dev->windowr[1]; in stv680_vidcam_init()
747 if (dev->video_status == 0x02) in stv680_vidcam_init()
751 else if ((dev->video_status == 0x01) || (dev->video_status == 0x08)) in stv680_vidcam_init()
754 dev->video_status); in stv680_vidcam_init()
756 else if (dev->video_status != 0x04) in stv680_vidcam_init()
761 sanei_usb_control_msg (dev->fd, 0x41, 0x04, 0x0000, 0, 0, 0); in stv680_vidcam_init()
771 if (dev->video_status == 0x01 || dev->video_status == 0x08) in stv680_vidcam_init()
776 sanei_usb_control_msg (dev->fd, 0xc1, 0x8a, 0x0000, 0, sizer, in stv680_vidcam_init()
777 dev->windowr); in stv680_vidcam_init()
781 val = dev->windowr[0]; in stv680_vidcam_init()
783 dev->windowr, sizer); in stv680_vidcam_init()
784 if (dev->windowr[0] &= 0x00) in stv680_vidcam_init()
795 sanei_usb_control_msg (dev->fd, 0xc1, 0x8b, (i << 8), 0, sizer, in stv680_vidcam_init()
796 dev->windowr); in stv680_vidcam_init()
801 dev->windowr, sizer); in stv680_vidcam_init()
806 sanei_usb_control_msg (dev->fd, 0x80, 0x06, 0x0100, 0, sizer, in stv680_vidcam_init()
807 dev->windowr); in stv680_vidcam_init()
810 /* if (!(i > 0) && (dev->windowr[8] == 0x53) && (dev->windowr[9] == 0x05)) in stv680_vidcam_init()
817 dev->windowr, sizer); in stv680_vidcam_init()
832 sanei_usb_control_msg (dev->fd, 0x41, 0x09, dev->video_mode, 0, sizew, in stv680_vidcam_init()
833 dev->windoww); in stv680_vidcam_init()
837 dev->video_mode); in stv680_vidcam_init()
842 dev->video_mode); in stv680_vidcam_init()
844 if (dev->x_resolution == 176) in stv680_vidcam_init()
874 for (dev = first_dev; dev; dev = dev->next) in attach_vidcam()
876 if (strcmp (dev->sane.name, devicename) == 0) in attach_vidcam()
904 dev->devicename = strdup (devicename); in attach_vidcam()
905 dev->fd = fd; in attach_vidcam()
911 DBG (DBG_error, "ERROR: attach_vidcam: vidcam-identification failed\n"); in attach_vidcam()
931 if (dev->hw->color_adjust[0].resolution_x != 0) in attach_vidcam()
937 while (dev->hw->color_adjust[num_entries].resolution_x != 0) in attach_vidcam()
940 dev->resolutions_list = malloc (sizeof (SANE_Word) * (num_entries + 1)); in attach_vidcam()
942 if (dev->resolutions_list == NULL) in attach_vidcam()
950 if (dev->CIF) in attach_vidcam()
952 if (dev->VGA) in attach_vidcam()
954 dev->resolutions_list[0] = num_entries; in attach_vidcam()
958 dev->resolutions_list[i + 1 + dev->VGA + dev->QVGA] = in attach_vidcam()
959 dev->hw->color_adjust[i].resolution_x; in attach_vidcam()
964 dev->resolutions_list = NULL; in attach_vidcam()
968 dev->sane.name = dev->devicename; in attach_vidcam()
969 dev->sane.vendor = dev->hw->vendor_name; in attach_vidcam()
970 dev->sane.model = dev->hw->product_name; in attach_vidcam()
971 dev->sane.type = SANE_I18N ("webcam"); in attach_vidcam()
974 dev->next = first_dev; in attach_vidcam()
1006 /* Pre-initialize the options. */ in stv680_init_options()
1007 memset (dev->opt, 0, sizeof (dev->opt)); in stv680_init_options()
1008 memset (dev->val, 0, sizeof (dev->val)); in stv680_init_options()
1012 dev->opt[i].size = sizeof (SANE_Word); in stv680_init_options()
1013 dev->opt[i].cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT; in stv680_init_options()
1019 dev->opt[OPT_NUM_OPTS].name = ""; in stv680_init_options()
1020 dev->opt[OPT_NUM_OPTS].title = SANE_TITLE_NUM_OPTIONS; in stv680_init_options()
1021 dev->opt[OPT_NUM_OPTS].desc = SANE_DESC_NUM_OPTIONS; in stv680_init_options()
1022 dev->opt[OPT_NUM_OPTS].type = SANE_TYPE_INT; in stv680_init_options()
1023 dev->opt[OPT_NUM_OPTS].cap = SANE_CAP_SOFT_DETECT; in stv680_init_options()
1024 dev->val[OPT_NUM_OPTS].w = OPT_NUM_OPTIONS; in stv680_init_options()
1027 dev->opt[OPT_MODE_GROUP].title = SANE_I18N ("Scan Mode"); in stv680_init_options()
1028 dev->opt[OPT_MODE_GROUP].desc = ""; /* not valid for a group */ in stv680_init_options()
1029 dev->opt[OPT_MODE_GROUP].type = SANE_TYPE_GROUP; in stv680_init_options()
1030 dev->opt[OPT_MODE_GROUP].cap = 0; in stv680_init_options()
1031 dev->opt[OPT_MODE_GROUP].size = 0; in stv680_init_options()
1032 dev->opt[OPT_MODE_GROUP].constraint_type = SANE_CONSTRAINT_NONE; in stv680_init_options()
1035 dev->opt[OPT_MODE].name = SANE_NAME_SCAN_MODE; in stv680_init_options()
1036 dev->opt[OPT_MODE].title = SANE_TITLE_SCAN_MODE; in stv680_init_options()
1037 dev->opt[OPT_MODE].desc = SANE_DESC_SCAN_MODE; in stv680_init_options()
1038 dev->opt[OPT_MODE].type = SANE_TYPE_STRING; in stv680_init_options()
1039 dev->opt[OPT_MODE].size = max_string_size (scan_mode_list); in stv680_init_options()
1040 dev->opt[OPT_MODE].constraint_type = SANE_CONSTRAINT_STRING_LIST; in stv680_init_options()
1041 dev->opt[OPT_MODE].constraint.string_list = scan_mode_list; in stv680_init_options()
1042 dev->val[OPT_MODE].s = (SANE_Char *) strdup (""); /* will be set later */ in stv680_init_options()
1045 dev->opt[OPT_RESOLUTION].name = SANE_NAME_SCAN_RESOLUTION; in stv680_init_options()
1046 dev->opt[OPT_RESOLUTION].title = SANE_TITLE_SCAN_RESOLUTION; in stv680_init_options()
1047 dev->opt[OPT_RESOLUTION].desc = SANE_DESC_SCAN_RESOLUTION; in stv680_init_options()
1048 dev->opt[OPT_RESOLUTION].type = SANE_TYPE_INT; in stv680_init_options()
1049 dev->opt[OPT_RESOLUTION].unit = SANE_UNIT_DPI; in stv680_init_options()
1050 dev->opt[OPT_RESOLUTION].constraint_type = SANE_CONSTRAINT_RANGE; in stv680_init_options()
1051 …dev->val[OPT_RESOLUTION].w = dev->resolutions_list[dev->CIF + dev->QCIF + dev->VGA + dev->QVGA + d… in stv680_init_options()
1054 dev->opt[OPT_BRIGHTNESS].name = SANE_NAME_BRIGHTNESS; in stv680_init_options()
1055 dev->opt[OPT_BRIGHTNESS].title = SANE_TITLE_BRIGHTNESS; in stv680_init_options()
1056 dev->opt[OPT_BRIGHTNESS].desc = SANE_DESC_BRIGHTNESS; in stv680_init_options()
1057 dev->opt[OPT_BRIGHTNESS].type = SANE_TYPE_INT; in stv680_init_options()
1058 dev->opt[OPT_BRIGHTNESS].unit = SANE_UNIT_NONE; in stv680_init_options()
1059 dev->opt[OPT_BRIGHTNESS].constraint_type = SANE_CONSTRAINT_RANGE; in stv680_init_options()
1060 dev->opt[OPT_BRIGHTNESS].constraint.range = &brightness_range; in stv680_init_options()
1061 dev->val[OPT_BRIGHTNESS].w = 0; /* to get middle value */ in stv680_init_options()
1064 dev->opt[OPT_ENHANCEMENT_GROUP].title = SANE_I18N ("Enhancement"); in stv680_init_options()
1065 dev->opt[OPT_ENHANCEMENT_GROUP].desc = ""; /* not valid for a group */ in stv680_init_options()
1066 dev->opt[OPT_ENHANCEMENT_GROUP].type = SANE_TYPE_GROUP; in stv680_init_options()
1067 dev->opt[OPT_ENHANCEMENT_GROUP].cap = SANE_CAP_ADVANCED; in stv680_init_options()
1068 dev->opt[OPT_ENHANCEMENT_GROUP].size = 0; in stv680_init_options()
1069 dev->opt[OPT_ENHANCEMENT_GROUP].constraint_type = SANE_CONSTRAINT_NONE; in stv680_init_options()
1072 dev->opt[OPT_WHITE_LEVEL_R].name = SANE_NAME_WHITE_LEVEL_R; in stv680_init_options()
1073 dev->opt[OPT_WHITE_LEVEL_R].title = SANE_TITLE_WHITE_LEVEL_R; in stv680_init_options()
1074 dev->opt[OPT_WHITE_LEVEL_R].desc = SANE_DESC_WHITE_LEVEL_R; in stv680_init_options()
1075 dev->opt[OPT_WHITE_LEVEL_R].type = SANE_TYPE_INT; in stv680_init_options()
1076 dev->opt[OPT_WHITE_LEVEL_R].unit = SANE_UNIT_NONE; in stv680_init_options()
1077 dev->opt[OPT_WHITE_LEVEL_R].constraint_type = SANE_CONSTRAINT_RANGE; in stv680_init_options()
1078 dev->opt[OPT_WHITE_LEVEL_R].constraint.range = &red_level_range; in stv680_init_options()
1079 dev->val[OPT_WHITE_LEVEL_R].w = 00; /* to get middle value */ in stv680_init_options()
1082 dev->opt[OPT_WHITE_LEVEL_G].name = SANE_NAME_WHITE_LEVEL_G; in stv680_init_options()
1083 dev->opt[OPT_WHITE_LEVEL_G].title = SANE_TITLE_WHITE_LEVEL_G; in stv680_init_options()
1084 dev->opt[OPT_WHITE_LEVEL_G].desc = SANE_DESC_WHITE_LEVEL_G; in stv680_init_options()
1085 dev->opt[OPT_WHITE_LEVEL_G].type = SANE_TYPE_INT; in stv680_init_options()
1086 dev->opt[OPT_WHITE_LEVEL_G].unit = SANE_UNIT_NONE; in stv680_init_options()
1087 dev->opt[OPT_WHITE_LEVEL_G].constraint_type = SANE_CONSTRAINT_RANGE; in stv680_init_options()
1088 dev->opt[OPT_WHITE_LEVEL_G].constraint.range = &green_level_range; in stv680_init_options()
1089 dev->val[OPT_WHITE_LEVEL_G].w = 00; /* to get middle value */ in stv680_init_options()
1092 dev->opt[OPT_WHITE_LEVEL_B].name = SANE_NAME_WHITE_LEVEL_B; in stv680_init_options()
1093 dev->opt[OPT_WHITE_LEVEL_B].title = SANE_TITLE_WHITE_LEVEL_B; in stv680_init_options()
1094 dev->opt[OPT_WHITE_LEVEL_B].desc = SANE_DESC_WHITE_LEVEL_B; in stv680_init_options()
1095 dev->opt[OPT_WHITE_LEVEL_B].type = SANE_TYPE_INT; in stv680_init_options()
1096 dev->opt[OPT_WHITE_LEVEL_B].unit = SANE_UNIT_NONE; in stv680_init_options()
1097 dev->opt[OPT_WHITE_LEVEL_B].constraint_type = SANE_CONSTRAINT_RANGE; in stv680_init_options()
1098 dev->opt[OPT_WHITE_LEVEL_B].constraint.range = &blue_level_range; in stv680_init_options()
1099 dev->val[OPT_WHITE_LEVEL_B].w = 00; /* to get middle value */ in stv680_init_options()
1119 assert (dev->image_begin == dev->image_end); in stv680_fill_image()
1120 assert (dev->real_bytes_left > 0); in stv680_fill_image()
1125 (unsigned long) (size_t) dev->real_bytes_left); in stv680_fill_image()
1126 bulk_size_read = dev->real_bytes_left; in stv680_fill_image()
1128 while (dev->real_bytes_left) in stv680_fill_image()
1133 (unsigned long) (size_t) dev->real_bytes_left); in stv680_fill_image()
1135 size = dev->real_bytes_left; in stv680_fill_image()
1143 assert (dev->image_end != 0); in stv680_fill_image()
1150 "stv680_fill_image: dev->real_bytes_left: 0x%lx size: 0x%lx\n", in stv680_fill_image()
1151 (unsigned long) (size_t) dev->real_bytes_left, (unsigned long) (size_t) size); in stv680_fill_image()
1155 status = sanei_usb_read_bulk (dev->fd, dev->buffer, &size); in stv680_fill_image()
1164 (unsigned long) (size_t) size, (unsigned long) (size_t) dev->params.bytes_per_line); in stv680_fill_image()
1166 memcpy (dev->image + dev->image_end, dev->buffer, size); in stv680_fill_image()
1168 dev->image_end += size; in stv680_fill_image()
1170 if (dev->real_bytes_left > size) in stv680_fill_image()
1171 dev->real_bytes_left -= size; in stv680_fill_image()
1172 else if (dev->real_bytes_left <= size) /* last loop */ in stv680_fill_image()
1173 dev->real_bytes_left = 0; in stv680_fill_image()
1175 (unsigned long) (size_t) dev->real_bytes_left); in stv680_fill_image()
1179 return -1; */ in stv680_fill_image()
1189 #define TEXT_CHAR_HEIGHT 11
1202 char fmtstring[25] = " %Y-%m-%d %H:%M:%S"; in stv680_add_text()
1208 if (strlen (txt) > (MSG_MAXLEN - 23)) in stv680_add_text()
1209 strncpy (fmttxt, txt, (MSG_MAXLEN - 23)); in stv680_add_text()
1218 ptr = image + 3 * width * (height - TEXT_CHAR_HEIGHT - 2 + y) + 12; in stv680_add_text()
1223 for (i = TEXT_CHAR_WIDTH - 1; i >= 0; i--) in stv680_add_text()
1251 int w = dev->cwidth; in stv680_bayer_unshuffle()
1252 int vw = dev->x_resolution; in stv680_bayer_unshuffle()
1253 int vh = dev->y_resolution; in stv680_bayer_unshuffle()
1261 RED = dev->red_s; in stv680_bayer_unshuffle()
1262 GREEN = dev->green_s; in stv680_bayer_unshuffle()
1263 BLUE = dev->blue_s; in stv680_bayer_unshuffle()
1282 p = dev->image[y * w + (x >> 1)]; in stv680_bayer_unshuffle()
1286 p = dev->image[y * w + (x >> 1) + (w >> 1)]; in stv680_bayer_unshuffle()
1309 *(dev->output + i + colour) = (SANE_Byte) p; in stv680_bayer_unshuffle()
1319 if (dev->scan_mode == STV680_COLOR_RGB in stv680_bayer_unshuffle()
1320 || dev->scan_mode == STV680_COLOR_RGB_TEXT) in stv680_bayer_unshuffle()
1327 *(dev->output + i) = red_g[*(dev->output + i)]; in stv680_bayer_unshuffle()
1328 *(dev->output + i + 1) = green_g[*(dev->output + i + 1)]; in stv680_bayer_unshuffle()
1329 *(dev->output + i + 2) = blue_g[*(dev->output + i + 2)]; in stv680_bayer_unshuffle()
1335 if (dev->scan_mode != STV680_COLOR_RAW) in stv680_bayer_unshuffle()
1339 for (y = 1; y < (vh - 1); y++) in stv680_bayer_unshuffle()
1341 for (x = 1; x < (vw - 1); x++) in stv680_bayer_unshuffle()
1352 *(dev->output + AD (x, y, vw) + BLUE) = in stv680_bayer_unshuffle()
1353 ((int) *(dev->output + AD (x - 1, y, vw) + BLUE) + in stv680_bayer_unshuffle()
1354 (int) *(dev->output + AD (x + 1, y, vw) + BLUE)) >> 1; in stv680_bayer_unshuffle()
1355 *(dev->output + AD (x, y, vw) + RED) = in stv680_bayer_unshuffle()
1356 ((int) *(dev->output + AD (x, y - 1, vw) + RED) + in stv680_bayer_unshuffle()
1357 (int) *(dev->output + AD (x, y + 1, vw) + RED)) >> 1; in stv680_bayer_unshuffle()
1361 *(dev->output + AD (x, y, vw) + GREEN) = in stv680_bayer_unshuffle()
1362 ((int) *(dev->output + AD (x - 1, y, vw) + GREEN) + in stv680_bayer_unshuffle()
1363 (int) *(dev->output + AD (x + 1, y, vw) + GREEN) + in stv680_bayer_unshuffle()
1364 (int) *(dev->output + AD (x, y - 1, vw) + GREEN) + in stv680_bayer_unshuffle()
1365 (int) *(dev->output + AD (x, y + 1, vw) + GREEN)) >> 2; in stv680_bayer_unshuffle()
1366 *(dev->output + AD (x, y, vw) + RED) = in stv680_bayer_unshuffle()
1367 ((int) *(dev->output + AD (x - 1, y - 1, vw) + RED) + in stv680_bayer_unshuffle()
1368 (int) *(dev->output + AD (x - 1, y + 1, vw) + RED) + in stv680_bayer_unshuffle()
1369 (int) *(dev->output + AD (x + 1, y - 1, vw) + RED) + in stv680_bayer_unshuffle()
1370 (int) *(dev->output + AD (x + 1, y + 1, vw) + RED)) >> 2; in stv680_bayer_unshuffle()
1374 *(dev->output + AD (x, y, vw) + GREEN) = in stv680_bayer_unshuffle()
1375 ((int) *(dev->output + AD (x - 1, y, vw) + GREEN) + in stv680_bayer_unshuffle()
1376 (int) *(dev->output + AD (x + 1, y, vw) + GREEN) + in stv680_bayer_unshuffle()
1377 (int) *(dev->output + AD (x, y - 1, vw) + GREEN) + in stv680_bayer_unshuffle()
1378 (int) *(dev->output + AD (x, y + 1, vw) + GREEN)) >> 2; in stv680_bayer_unshuffle()
1379 *(dev->output + AD (x, y, vw) + BLUE) = in stv680_bayer_unshuffle()
1380 ((int) *(dev->output + AD (x - 1, y - 1, vw) + BLUE) + in stv680_bayer_unshuffle()
1381 (int) *(dev->output + AD (x + 1, y - 1, vw) + BLUE) + in stv680_bayer_unshuffle()
1382 (int) *(dev->output + AD (x - 1, y + 1, vw) + BLUE) + in stv680_bayer_unshuffle()
1383 (int) *(dev->output + AD (x + 1, y + 1, vw) + in stv680_bayer_unshuffle()
1388 *(dev->output + AD (x, y, vw) + RED) = in stv680_bayer_unshuffle()
1389 ((int) *(dev->output + AD (x - 1, y, vw) + RED) + in stv680_bayer_unshuffle()
1390 (int) *(dev->output + AD (x + 1, y, vw) + RED)) >> 1; in stv680_bayer_unshuffle()
1391 *(dev->output + AD (x, y, vw) + BLUE) = in stv680_bayer_unshuffle()
1392 ((int) *(dev->output + AD (x, y - 1, vw) + BLUE) + in stv680_bayer_unshuffle()
1393 (int) *(dev->output + AD (x, y + 1, vw) + BLUE)) >> 1; in stv680_bayer_unshuffle()
1397 } /* for y - end demosaic */ in stv680_bayer_unshuffle()
1403 memcpy (dev->output, (dev->output + i), i); in stv680_bayer_unshuffle()
1405 memcpy ((dev->output + (vh * i)), (dev->output + ((vh - 1) * i)), i); in stv680_bayer_unshuffle()
1411 memcpy ((dev->output + i), (dev->output + i + 3), 3); in stv680_bayer_unshuffle()
1412 memcpy ((dev->output + i + (vw * 3)), in stv680_bayer_unshuffle()
1413 (dev->output + i + (vw - 1) * 3), 3); in stv680_bayer_unshuffle()
1417 if (dev->subsample == 160) in stv680_bayer_unshuffle()
1429 *(dev->output + i) = *(dev->output + p); in stv680_bayer_unshuffle()
1430 *(dev->output + i + 1) = *(dev->output + p + 1); in stv680_bayer_unshuffle()
1431 *(dev->output + i + 2) = *(dev->output + p + 2); in stv680_bayer_unshuffle()
1442 if (dev->subsample == 160) in stv680_bayer_unshuffle()
1452 bright_red = (dev->val[OPT_BRIGHTNESS].w) + (dev->val[OPT_WHITE_LEVEL_R].w); in stv680_bayer_unshuffle()
1454 (dev->val[OPT_BRIGHTNESS].w) + (dev->val[OPT_WHITE_LEVEL_G].w); in stv680_bayer_unshuffle()
1456 (dev->val[OPT_BRIGHTNESS].w) + (dev->val[OPT_WHITE_LEVEL_B].w); in stv680_bayer_unshuffle()
1462 if ((*(dev->output + x) + bright_red) >= 255) in stv680_bayer_unshuffle()
1465 else if ((*(dev->output + x) + bright_red) <= 0) in stv680_bayer_unshuffle()
1468 *(buf + x) = (*(dev->output + x) + bright_red); in stv680_bayer_unshuffle()
1470 if ((*(dev->output + y) + bright_green) >= 255) in stv680_bayer_unshuffle()
1473 else if ((*(dev->output + y) + bright_green) <= 0) in stv680_bayer_unshuffle()
1476 *(buf + y) = (*(dev->output + y) + bright_green); in stv680_bayer_unshuffle()
1478 if ((*(dev->output + i) + bright_blue) >= 255) in stv680_bayer_unshuffle()
1481 else if ((*(dev->output + i) + bright_blue) <= 0) in stv680_bayer_unshuffle()
1484 *(buf + i) = (*(dev->output + i) + bright_blue); in stv680_bayer_unshuffle()
1489 if (dev->scan_mode == STV680_COLOR_RGB_TEXT) in stv680_bayer_unshuffle()
1491 strcpy (dev->picmsg_ps, "STVcam "); in stv680_bayer_unshuffle()
1493 status = stv680_add_text (buf, vw, vh, dev->picmsg_ps); in stv680_bayer_unshuffle()
1525 DBG (DBG_error, "This is sane-stv680 version %d.%d-%d\n", SANE_CURRENT_MAJOR, in sane_init()
1527 DBG (DBG_error, "(C) 2004-2006 by Gerard Klaver\n"); in sane_init()
1567 DBG (DBG_warning, "bad configuration line: \"%s\" - ignoring.\n", in sane_init()
1597 for (dev = first_dev; i < num_devices; dev = dev->next) in sane_get_devices()
1598 devlist[i++] = &dev->sane; in sane_get_devices()
1621 for (dev = first_dev; dev; dev = dev->next) in sane_open()
1623 if (strcmp (dev->sane.name, devicename) == 0) in sane_open()
1641 dev = first_dev; /* empty devicename -> use first device */ in sane_open()
1674 return dev->opt + option; in sane_get_option_descriptor()
1693 if (dev->scanning) in sane_control_option()
1703 cap = dev->opt[option].cap; in sane_control_option()
1721 *(SANE_Word *) val = dev->val[option].w; in sane_control_option()
1724 strcpy (val, dev->val[option].s); in sane_control_option()
1739 status = sanei_constrain_value (dev->opt + option, val, info); in sane_control_option()
1749 /* Numeric side-effect options */ in sane_control_option()
1759 dev->val[option].w = *(SANE_Word *) val; in sane_control_option()
1762 /* String side-effect options */ in sane_control_option()
1764 if (strcmp (dev->val[option].s, val) == 0) in sane_control_option()
1767 free (dev->val[OPT_MODE].s); in sane_control_option()
1768 dev->val[OPT_MODE].s = (SANE_Char *) strdup (val); in sane_control_option()
1770 dev->opt[OPT_WHITE_LEVEL_R].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1771 dev->opt[OPT_WHITE_LEVEL_G].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1772 dev->opt[OPT_WHITE_LEVEL_B].cap &= ~SANE_CAP_INACTIVE; in sane_control_option()
1774 if (strcmp (dev->val[OPT_MODE].s, COLOR_RAW_STR) == 0) in sane_control_option()
1776 dev->scan_mode = STV680_COLOR_RAW; in sane_control_option()
1778 else if (strcmp (dev->val[OPT_MODE].s, COLOR_RGB_STR) == 0) in sane_control_option()
1780 dev->scan_mode = STV680_COLOR_RGB; in sane_control_option()
1782 else if (strcmp (dev->val[OPT_MODE].s, SANE_VALUE_SCAN_MODE_COLOR) in sane_control_option()
1785 dev->scan_mode = STV680_COLOR; in sane_control_option()
1788 else if (strcmp (dev->val[OPT_MODE].s, COLOR_RGB_TEXT_STR) == 0) in sane_control_option()
1790 dev->scan_mode = STV680_COLOR_RGB_TEXT; in sane_control_option()
1797 dev->depth = 8; in sane_control_option()
1798 if (dev->resolutions_list != NULL) in sane_control_option()
1802 dev->opt[OPT_RESOLUTION].constraint_type = in sane_control_option()
1804 dev->opt[OPT_RESOLUTION].constraint.word_list = in sane_control_option()
1805 dev->resolutions_list; in sane_control_option()
1808 for (i = 1; i <= dev->resolutions_list[0]; i++) in sane_control_option()
1810 if (dev->resolutions_list[i] >= dev->val[OPT_RESOLUTION].w) in sane_control_option()
1813 if (i > dev->resolutions_list[0]) in sane_control_option()
1816 dev->val[OPT_RESOLUTION].w = dev->resolutions_list[1]; in sane_control_option()
1821 dev->val[OPT_RESOLUTION].w = dev->resolutions_list[i]; in sane_control_option()
1825 /* String side-effect options */ in sane_control_option()
1850 if (!(dev->scanning)) in sane_get_parameters()
1852 dev->x_resolution = dev->val[OPT_RESOLUTION].w; in sane_get_parameters()
1854 memset (&dev->params, 0, sizeof (SANE_Parameters)); in sane_get_parameters()
1856 dev->params.last_frame = SANE_TRUE; in sane_get_parameters()
1858 switch (dev->scan_mode) in sane_get_parameters()
1861 dev->bytes_pixel = 1; /* raw image is 422 code, 1 byte/pixel */ in sane_get_parameters()
1866 dev->bytes_pixel = 3; in sane_get_parameters()
1869 dev->params.format = SANE_FRAME_RGB; in sane_get_parameters()
1870 dev->params.pixels_per_line = dev->x_resolution; in sane_get_parameters()
1871 dev->params.bytes_per_line = in sane_get_parameters()
1872 dev->params.pixels_per_line * dev->bytes_pixel; in sane_get_parameters()
1873 dev->params.depth = 8; in sane_get_parameters()
1874 if (dev->resolutions_list != NULL) in sane_get_parameters()
1881 dev->hw->color_adjust[i].resolution_x != dev->x_resolution; in sane_get_parameters()
1884 dev->red_s = dev->hw->color_adjust[i].z1_color_0; in sane_get_parameters()
1885 dev->green_s = dev->hw->color_adjust[i].z1_color_1; in sane_get_parameters()
1886 dev->blue_s = dev->hw->color_adjust[i].z1_color_2; in sane_get_parameters()
1887 dev->y_resolution = dev->hw->color_adjust[i].resolution_y; in sane_get_parameters()
1889 dev->subsample = 0; in sane_get_parameters()
1890 switch (dev->val[OPT_RESOLUTION].w) in sane_get_parameters()
1893 dev->video_mode = 0x0200; in sane_get_parameters()
1894 dev->cwidth = dev->x_resolution + 2; in sane_get_parameters()
1895 dev->cheight = dev->y_resolution + 2; in sane_get_parameters()
1898 dev->x_resolution = 320; in sane_get_parameters()
1899 dev->y_resolution = 240; in sane_get_parameters()
1900 dev->video_mode = 0x0300; in sane_get_parameters()
1901 dev->cwidth = dev->x_resolution + 2; in sane_get_parameters()
1902 dev->cheight = dev->y_resolution + 2; in sane_get_parameters()
1903 dev->subsample = 160; in sane_get_parameters()
1906 dev->video_mode = 0x0300; in sane_get_parameters()
1907 dev->cwidth = dev->x_resolution + 2; in sane_get_parameters()
1908 dev->cheight = dev->y_resolution + 2; in sane_get_parameters()
1911 dev->video_mode = 0x0000; in sane_get_parameters()
1912 dev->cwidth = dev->x_resolution + 4; in sane_get_parameters()
1913 dev->cheight = dev->y_resolution + 4; in sane_get_parameters()
1916 dev->video_mode = 0x0100; in sane_get_parameters()
1917 dev->cwidth = dev->x_resolution + 4; in sane_get_parameters()
1918 dev->cheight = dev->y_resolution + 4; in sane_get_parameters()
1921 dev->params.pixels_per_line = dev->x_resolution; in sane_get_parameters()
1922 dev->params.lines = dev->y_resolution; in sane_get_parameters()
1923 DBG (DBG_info, "sane_get_parameters: x=%d, y=%d\n", dev->x_resolution, in sane_get_parameters()
1924 dev->y_resolution); in sane_get_parameters()
1930 *params = (dev->params); in sane_get_parameters()
1946 if (!(dev->scanning)) in sane_start()
1951 if (sanei_usb_open (dev->devicename, &(dev->fd)) != 0) in sane_start()
1968 dev->image_end = 0; in sane_start()
1969 dev->image_begin = 0; in sane_start()
1971 dev->real_bytes_left = dev->cwidth * dev->cheight; in sane_start()
1972 dev->bytes_left = dev->params.bytes_per_line * dev->params.lines; in sane_start()
1974 dev->scanning = SANE_TRUE; in sane_start()
1992 if (dev->deliver_eof) in sane_read()
1994 dev->deliver_eof = 0; in sane_read()
1998 if (!(dev->scanning)) in sane_read()
2003 dev->scanning = SANE_FALSE; in sane_read()
2007 if (dev->bytes_left <= 0) in sane_read()
2012 if (dev->image_begin == dev->image_end) in sane_read()
2024 if (dev->image_begin == dev->image_end) in sane_read()
2030 size = dev->bytes_left; in sane_read()
2036 if ((dev->image_end - dev->image_begin) > size) in sane_read()
2038 size = dev->image_end - dev->image_begin; in sane_read()
2039 DBG (DBG_proc, "sane_read: size < dev->image_end - dev->image_begin\n"); in sane_read()
2041 /* diff between size an dev->bytes_left because of 356/352 and 292/288 */ in sane_read()
2045 *len = dev->bytes_left; /* needed */ in sane_read()
2046 size = dev->bytes_left; in sane_read()
2047 dev->bytes_left = 0; /* needed for frontend or ? */ in sane_read()
2049 if (dev->scan_mode != STV680_COLOR_RAW) in sane_read()
2062 memcpy (buf, dev->image, size); in sane_read()
2106 if (dev->scanning == SANE_TRUE) in sane_cancel()
2112 dev->scanning = SANE_FALSE; in sane_cancel()
2113 dev->deliver_eof = 0; in sane_cancel()
2129 if (dev->scanning == SANE_TRUE) in sane_close()
2134 dev->scanning = SANE_FALSE; in sane_close()
2139 first_dev = dev->next; in sane_close()
2144 while (dev_tmp->next && dev_tmp->next != dev) in sane_close()
2146 dev_tmp = dev_tmp->next; in sane_close()
2148 if (dev_tmp->next != NULL) in sane_close()
2150 dev_tmp->next = dev_tmp->next->next; in sane_close()
2155 num_devices--; in sane_close()