SANE_Status esci_get_scanning_parameter(SANE_Handle handle, unsigned char *buf) { Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Status status; unsigned char params[2]; DBG(8, "%s\n", __func__); if (buf == NULL) return SANE_STATUS_INVAL; params[0] = FS; params[1] = 'S'; status = e2_txrx(s, params, 2, buf, 64); if (status != SANE_STATUS_GOOD) return status; DBG(10, "resolution of main scan : %lu\n", (u_long) le32atoh(&buf[0])); DBG(10, "resolution of sub scan : %lu\n", (u_long) le32atoh(&buf[4])); DBG(10, "offset length of main scan : %lu\n", (u_long) le32atoh(&buf[8])); DBG(10, "offset length of sub scan : %lu\n", (u_long) le32atoh(&buf[12])); DBG(10, "scanning length of main scan: %lu\n", (u_long) le32atoh(&buf[16])); DBG(10, "scanning length of sub scan : %lu\n", (u_long) le32atoh(&buf[20])); DBG(10, "scanning color : %d\n", buf[24]); DBG(10, "data format : %d\n", buf[25]); DBG(10, "option control : %d\n", buf[26]); DBG(10, "scanning mode : %d\n", buf[27]); DBG(10, "block line number : %d\n", buf[28]); DBG(10, "gamma correction : %d\n", buf[29]); DBG(10, "brightness : %d\n", buf[30]); DBG(10, "color correction : %d\n", buf[31]); DBG(10, "halftone processing : %d\n", buf[32]); DBG(10, "threshold : %d\n", buf[33]); DBG(10, "auto area segmentation : %d\n", buf[34]); DBG(10, "sharpness control : %d\n", buf[35]); DBG(10, "mirroring : %d\n", buf[36]); DBG(10, "film type : %d\n", buf[37]); DBG(10, "main lamp lighting mode : %d\n", buf[38]); return SANE_STATUS_GOOD; }
SANE_Status esci_request_extended_identity(SANE_Handle handle, unsigned char *buf) { unsigned char model[17]; Epson_Scanner *s = (Epson_Scanner *) handle; SANE_Status status; unsigned char params[2]; DBG(8, "%s\n", __func__); if (buf == NULL) return SANE_STATUS_INVAL; if (s->hw->cmd->request_extended_identity == 0) return SANE_STATUS_UNSUPPORTED; params[0] = FS; params[1] = s->hw->cmd->request_extended_identity; status = e2_txrx(s, params, 2, buf, 80); if (status != SANE_STATUS_GOOD) return status; DBG(1, " command level : %c%c\n", buf[0], buf[1]); DBG(1, " basic resolution: %lu\n", (unsigned long) le32atoh(&buf[4])); DBG(1, " min resolution : %lu\n", (unsigned long) le32atoh(&buf[8])); DBG(1, " max resolution : %lu\n", (unsigned long) le32atoh(&buf[12])); DBG(1, " max pixel num : %lu\n", (unsigned long) le32atoh(&buf[16])); DBG(1, " scan area : %lux%lu\n", (unsigned long) le32atoh(&buf[20]), (unsigned long) le32atoh(&buf[24])); DBG(1, " adf area : %lux%lu\n", (unsigned long) le32atoh(&buf[28]), (unsigned long) le32atoh(&buf[32])); DBG(1, " tpu area : %lux%lu\n", (unsigned long) le32atoh(&buf[36]), (unsigned long) le32atoh(&buf[40])); DBG(1, " capabilities (1): 0x%02x\n", buf[44]); DBG(1, " capabilities (2): 0x%02x\n", buf[45]); DBG(1, " input depth : %d\n", buf[66]); DBG(1, " max output depth: %d\n", buf[67]); DBG(1, " rom version : %c%c%c%c\n", buf[62], buf[63], buf[64], buf[65]); memcpy(model, &buf[46], 16); model[16] = '\0'; DBG(1, " model name : %s\n", model); DBG(1, "options:\n"); if (le32atoh(&buf[28]) > 0) DBG(1, " ADF detected\n"); if (le32atoh(&buf[36]) > 0) DBG(1, " TPU detected\n"); if (buf[44]) DBG(1, "capabilities (1):\n"); if (buf[44] & EXT_IDTY_CAP1_DLF) DBG(1, " main lamp change is supported\n"); if (buf[44] & EXT_IDTY_CAP1_NOTFBF) DBG(1, " the device is NOT flatbed\n"); if (buf[44] & EXT_IDTY_CAP1_ADFT) DBG(1, " page type ADF is installed\n"); if (buf[44] & EXT_IDTY_CAP1_ADFS) DBG(1, " ADF is duplex capable\n"); if (buf[44] & EXT_IDTY_CAP1_ADFO) DBG(1, " page type ADF loads from the first sheet\n"); if (buf[44] & EXT_IDTY_CAP1_LID) DBG(1, " lid type option is installed\n"); if (buf[44] & EXT_IDTY_CAP1_TPIR) DBG(1, " infrared scanning is supported\n"); if (buf[44] & EXT_IDTY_CAP1_PB) DBG(1, " push button is supported\n"); if (buf[45]) DBG(1, "capabilities (2):\n"); if (buf[45] & EXT_IDTY_CAP2_AFF) DBG(1, " ADF has auto form feed\n"); if (buf[45] & EXT_IDTY_CAP2_DFD) DBG(1, " ADF has double feed detection\n"); if (buf[45] & EXT_IDTY_CAP2_ADFAS) DBG(1, " ADF has auto scan\n"); return SANE_STATUS_GOOD; }
int pdrm11_get_file(CameraFilesystem *fs, const char *filename, CameraFileType type, CameraFile *file, GPPort *port, uint16_t picNum) { uint32_t size = 0; uint16_t thumbsize = 0; uint8_t buf[30]; uint8_t *image; uint8_t temp; int i; int ret; int file_type; gp_port_set_timeout(port,10000); CHECK( pdrm11_select_file(port, picNum) ); if(type == GP_FILE_TYPE_PREVIEW) { CHECK(gp_port_usb_msg_read(port, 0x01, PDRM11_CMD_GET_INFO, picNum, (char *)buf, 8)); file_type = buf[4]; CHECK( gp_port_usb_msg_read(port, 0x01, PDRM11_CMD_GET_THUMBSIZE, picNum, (char *)buf, 14) ); thumbsize = le16atoh( &buf[8] ); /* add 1 to file size only for jpeg thumbnails */ if(file_type == 1) { GP_DEBUG("thumbnail file_type: %s.", "jpeg"); size = (uint32_t)thumbsize + 1; } else if(file_type == 2) { /* NOTE: tiff thumbnails are 160x120 pixel 8bpc rgb images, NOT jpegs... */ GP_DEBUG("thumbnail file_type: %s.", "tiff"); size = (uint32_t)thumbsize; } else { GP_DEBUG("Unknown thumbnail file format!"); return(GP_ERROR_NOT_SUPPORTED); } } else if(type == GP_FILE_TYPE_NORMAL) { CHECK( gp_port_usb_msg_read(port, 0x01, PDRM11_CMD_GET_FILESIZE, picNum, (char *)buf, 26) ); size = le32atoh( &buf[18] ); } else { GP_DEBUG("Unsupported file type!"); return(GP_ERROR_NOT_SUPPORTED); } GP_DEBUG("size: %d 0x%x", size, size); image = malloc(sizeof(char)*size); if(!image) return(GP_ERROR_NO_MEMORY); if(type == GP_FILE_TYPE_PREVIEW) { CHECK_AND_FREE( gp_port_usb_msg_write(port, 0x01, PDRM11_CMD_GET_THUMB, picNum, NULL, 0), image ); } else { CHECK_AND_FREE( gp_port_usb_msg_write(port, 0x01, PDRM11_CMD_GET_PIC, picNum, NULL, 0), image ); } ret = gp_port_read(port, (char *)image, size); if(ret != size) { GP_DEBUG("failed to read from port. Giving it one more try..."); ret = gp_port_read(port, (char *)image, size); if(ret != size) { GP_DEBUG("gp_port_read returned %d 0x%x. size: %d 0x%x", ret, ret, size, size); free (image); return(GP_ERROR_IO_READ); } } /* swap the bytes for the thumbnail, but not the file */ if(type == GP_FILE_TYPE_PREVIEW) { for(i=0; i<size; i+=2) { temp = image[i]; image[i] = image[i+1]; image[i+1] = temp; } } gp_file_set_mime_type(file, GP_MIME_JPEG); gp_file_set_data_and_size(file, (char *)image, size); return(GP_OK); }