1141cc406Sopenharmony_ci#ifndef __KVS20XX_CMD_H 2141cc406Sopenharmony_ci#define __KVS20XX_CMD_H 3141cc406Sopenharmony_ci 4141cc406Sopenharmony_ci/* 5141cc406Sopenharmony_ci Copyright (C) 2008, Panasonic Russia Ltd. 6141cc406Sopenharmony_ci Copyright (C) 2010, m. allan noah 7141cc406Sopenharmony_ci*/ 8141cc406Sopenharmony_ci/* 9141cc406Sopenharmony_ci Panasonic KV-S20xx USB-SCSI scanners. 10141cc406Sopenharmony_ci*/ 11141cc406Sopenharmony_ci 12141cc406Sopenharmony_ci#ifdef HAVE_SYS_TYPES_H 13141cc406Sopenharmony_ci#include <sys/types.h> 14141cc406Sopenharmony_ci#endif 15141cc406Sopenharmony_ci 16141cc406Sopenharmony_ci#define COMMAND_BLOCK 1 17141cc406Sopenharmony_ci#define DATA_BLOCK 2 18141cc406Sopenharmony_ci#define RESPONSE_BLOCK 3 19141cc406Sopenharmony_ci 20141cc406Sopenharmony_ci#define COMMAND_CODE 0x9000 21141cc406Sopenharmony_ci#define DATA_CODE 0xb000 22141cc406Sopenharmony_ci#define RESPONSE_CODE 0xa000 23141cc406Sopenharmony_ci#define STATUS_SIZE 4 24141cc406Sopenharmony_ci 25141cc406Sopenharmony_cistruct bulk_header 26141cc406Sopenharmony_ci{ 27141cc406Sopenharmony_ci u32 length; 28141cc406Sopenharmony_ci u16 type; 29141cc406Sopenharmony_ci u16 code; 30141cc406Sopenharmony_ci u32 transaction_id; 31141cc406Sopenharmony_ci}; 32141cc406Sopenharmony_ci 33141cc406Sopenharmony_ci#define TEST_UNIT_READY 0x00 34141cc406Sopenharmony_ci#define INQUIRY 0x12 35141cc406Sopenharmony_ci#define SET_WINDOW 0x24 36141cc406Sopenharmony_ci#define SCAN 0x1B 37141cc406Sopenharmony_ci#define SEND_10 0x2A 38141cc406Sopenharmony_ci#define READ_10 0x28 39141cc406Sopenharmony_ci#define REQUEST_SENSE 0x03 40141cc406Sopenharmony_ci#define GET_BUFFER_STATUS 0x34 41141cc406Sopenharmony_ci#define SET_TIMEOUT 0xE1 42141cc406Sopenharmony_ci#define GET_ADJUST_DATA 0xE0 43141cc406Sopenharmony_ci#define GOOD 0 44141cc406Sopenharmony_ci#define CHECK_CONDITION 2 45141cc406Sopenharmony_ci 46141cc406Sopenharmony_citypedef enum 47141cc406Sopenharmony_ci{ 48141cc406Sopenharmony_ci CMD_NONE = 0, 49141cc406Sopenharmony_ci CMD_IN = 0x81, /* scanner to pc */ 50141cc406Sopenharmony_ci CMD_OUT = 0x02 /* pc to scanner */ 51141cc406Sopenharmony_ci} CMD_DIRECTION; /* equals to endpoint address */ 52141cc406Sopenharmony_ci 53141cc406Sopenharmony_ci#define RESPONSE_SIZE 0x12 54141cc406Sopenharmony_ci#define MAX_CMD_SIZE 12 55141cc406Sopenharmony_cistruct cmd 56141cc406Sopenharmony_ci{ 57141cc406Sopenharmony_ci unsigned char cmd[MAX_CMD_SIZE]; 58141cc406Sopenharmony_ci int cmd_size; 59141cc406Sopenharmony_ci void *data; 60141cc406Sopenharmony_ci int data_size; 61141cc406Sopenharmony_ci int dir; 62141cc406Sopenharmony_ci}; 63141cc406Sopenharmony_cistruct response 64141cc406Sopenharmony_ci{ 65141cc406Sopenharmony_ci int status; 66141cc406Sopenharmony_ci unsigned char data[RESPONSE_SIZE]; 67141cc406Sopenharmony_ci}; 68141cc406Sopenharmony_ci 69141cc406Sopenharmony_ci#define END_OF_MEDIUM (1<<6) 70141cc406Sopenharmony_ci#define INCORRECT_LENGTH_INDICATOR (1<<5) 71141cc406Sopenharmony_cistatic const struct 72141cc406Sopenharmony_ci{ 73141cc406Sopenharmony_ci unsigned sense, asc, ascq; 74141cc406Sopenharmony_ci SANE_Status st; 75141cc406Sopenharmony_ci} s_errors[] = 76141cc406Sopenharmony_ci{ 77141cc406Sopenharmony_ci { 78141cc406Sopenharmony_ci 0, 0, 0, SANE_STATUS_GOOD}, 79141cc406Sopenharmony_ci { 80141cc406Sopenharmony_ci 2, 0, 0, SANE_STATUS_DEVICE_BUSY}, 81141cc406Sopenharmony_ci { 82141cc406Sopenharmony_ci 2, 4, 1, SANE_STATUS_DEVICE_BUSY}, 83141cc406Sopenharmony_ci { 84141cc406Sopenharmony_ci 2, 4, 0x80, SANE_STATUS_COVER_OPEN}, 85141cc406Sopenharmony_ci { 86141cc406Sopenharmony_ci 2, 4, 0x81, SANE_STATUS_COVER_OPEN}, 87141cc406Sopenharmony_ci { 88141cc406Sopenharmony_ci 2, 4, 0x82, SANE_STATUS_COVER_OPEN}, 89141cc406Sopenharmony_ci { 90141cc406Sopenharmony_ci 2, 4, 0x83, SANE_STATUS_COVER_OPEN}, 91141cc406Sopenharmony_ci { 92141cc406Sopenharmony_ci 2, 4, 0x84, SANE_STATUS_COVER_OPEN}, 93141cc406Sopenharmony_ci { 94141cc406Sopenharmony_ci 2, 0x80, 1, SANE_STATUS_CANCELLED}, 95141cc406Sopenharmony_ci { 96141cc406Sopenharmony_ci 2, 0x80, 2, SANE_STATUS_CANCELLED}, 97141cc406Sopenharmony_ci { 98141cc406Sopenharmony_ci 3, 0x3a, 0, SANE_STATUS_NO_DOCS}, 99141cc406Sopenharmony_ci { 100141cc406Sopenharmony_ci 3, 0x80, 1, SANE_STATUS_JAMMED}, 101141cc406Sopenharmony_ci { 102141cc406Sopenharmony_ci 3, 0x80, 2, SANE_STATUS_JAMMED}, 103141cc406Sopenharmony_ci { 104141cc406Sopenharmony_ci 3, 0x80, 3, SANE_STATUS_JAMMED}, 105141cc406Sopenharmony_ci { 106141cc406Sopenharmony_ci 3, 0x80, 4, SANE_STATUS_JAMMED}, 107141cc406Sopenharmony_ci { 108141cc406Sopenharmony_ci 3, 0x80, 5, SANE_STATUS_JAMMED}, 109141cc406Sopenharmony_ci { 110141cc406Sopenharmony_ci 3, 0x80, 6, SANE_STATUS_JAMMED}, 111141cc406Sopenharmony_ci { 112141cc406Sopenharmony_ci 3, 0x80, 7, SANE_STATUS_JAMMED}, 113141cc406Sopenharmony_ci { 114141cc406Sopenharmony_ci 3, 0x80, 8, SANE_STATUS_JAMMED}, 115141cc406Sopenharmony_ci { 116141cc406Sopenharmony_ci3, 0x80, 9, SANE_STATUS_JAMMED},}; 117141cc406Sopenharmony_ci 118141cc406Sopenharmony_ciSANE_Status kvs20xx_scan (struct scanner *s); 119141cc406Sopenharmony_ciSANE_Status kvs20xx_test_unit_ready (struct scanner *s); 120141cc406Sopenharmony_ciSANE_Status kvs20xx_set_timeout (struct scanner *s, int timeout); 121141cc406Sopenharmony_ciSANE_Status kvs20xx_set_window (struct scanner *s, int wnd_id); 122141cc406Sopenharmony_ciSANE_Status kvs20xx_reset_window (struct scanner *s); 123141cc406Sopenharmony_ciSANE_Status kvs20xx_read_picture_element (struct scanner *s, unsigned side, 124141cc406Sopenharmony_ci SANE_Parameters * p); 125141cc406Sopenharmony_ciSANE_Status kvs20xx_read_image_data (struct scanner *s, unsigned page, 126141cc406Sopenharmony_ci unsigned side, void *buf, 127141cc406Sopenharmony_ci unsigned max_size, unsigned *size); 128141cc406Sopenharmony_ciSANE_Status kvs20xx_document_exist (struct scanner *s); 129141cc406Sopenharmony_ciSANE_Status get_adjust_data (struct scanner *s, unsigned *dummy_length); 130141cc406Sopenharmony_ciSANE_Status kvs20xx_sense_handler (int fd, u_char * sense_buffer, void *arg); 131141cc406Sopenharmony_ci 132141cc406Sopenharmony_ci#endif /*__KVS20XX_CMD_H*/ 133