1 /* 2 * STV0680 Vision Camera Chipset Driver 3 * Copyright 2000 Adam Harrison <adam@antispin.org> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 * Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef STV0680_H 22 #define STV0680_H 23 24 #define CMDID_CLEAR_COMMS_ERROR 0x80 25 struct stv680_error_info { 26 unsigned char error; 27 #define CAMERR_OK 0 28 #define CAMERR_BUSY 1 29 #define CAMERR_TIMEOUT 2 30 #define CAMERR_V2W_ERROR 3 31 #define CAMERR_COMMS_ERROR 4 32 #define CAMERR_BAD_EXPOSURE 5 33 #define CAMERR_BAD_INDEX 6 34 #define CAMERR_CAMERA_FULL 7 35 #define CAMERR_BAD_COMMAND 8 36 #define CAMERR_BAD_PARAM 9 37 #define CAMERR_BAD_DATALEN 10 38 #define CAMERR_TASK_FAILED 11 39 #define CAMERR_FLASH_PROGRAM_FAILED 12 40 #define CAMERR_BAD_ADDRESS 13 41 #define CAMERR_BAD_PAGE 14 42 #define CAMERR_EXISTING_IMAGE_SMALLER 15 43 #define CAMERR_COMMAND_NOT_ALLOWED 16 44 #define CAMERR_NO_SENSOR_DETECTED 17 45 #define CAMERR_COLOUR_MATRIX_UNAVAILABLE 18 46 unsigned char info; 47 }; 48 49 #define CMDID_PING 0x88 50 51 #define CMDID_GET_CAMERA_INFO 0x85 52 struct stv680_camera_info { 53 unsigned char firmware_revision[2]; 54 unsigned char asic_revision[2]; 55 unsigned char sensor_id[2]; 56 unsigned char hardware_config; 57 58 #define HWCONFIG_COMMSLINK_MASK 0x01 59 #define HWCONFIG_COMMSLINK_USB 0x00 60 #define HWCONFIG_COMMSLINK_SERIAL 0x01 61 62 #define HWCONFIG_FLICKERFREQ_MASK 0x02 63 #define HWCONFIG_FLICKERFREQ_50HZ 0x00 64 #define HWCONFIG_FLICKERFREQ_60HZ 0x02 65 66 #define HWCONFIG_MEMSIZE_MASK 0x04 67 #define HWCONFIG_MEMSIZE_64MBIT 0x00 68 #define HWCONFIG_MEMSIZE_16MBIT 0x04 69 70 #define HWCONFIG_HAS_THUMBNAILS 0x08 71 #define HWCONFIG_HAS_VIDEO 0x10 72 #define HWCONFIG_STARTUP_COMPLETED 0x20 73 #define HWCONFIG_IS_MONOCHROME 0x40 74 #define HWCONFIG_MEM_FITTED 0x80 75 76 unsigned char capabilities; 77 #define CAP_CIF 1 78 #define CAP_VGA 2 79 #define CAP_QCIF 4 80 #define CAP_QVGA 8 81 82 unsigned char vendor_id[2]; 83 unsigned char product_id[2]; 84 85 unsigned char reserved[4]; 86 87 }; 88 89 #define CMDID_GET_CAMERA_MODE 0x87 90 struct stv680_camera_mode { 91 unsigned char format; 92 #define FORMAT_CIF 0 93 #define FORMAT_VGA 1 94 #define FORMAT_QCIF 2 95 #define FORMAT_QVGA 3 96 unsigned char reserved[7]; 97 }; 98 99 #define CMDID_GET_IMAGE_INFO 0x86 100 struct stv680_image_info { 101 unsigned char index[2]; 102 unsigned char maximages[2]; 103 unsigned char width[2]; 104 unsigned char height[2]; 105 unsigned char size[4]; 106 unsigned char thumb_width; 107 unsigned char thumb_height; 108 unsigned char thumb_size[2]; 109 }; 110 111 #define CMDID_UPLOAD_IMAGE 0x83 112 #define CMDID_UPLOAD_THUMBNAIL 0x84 113 #define CMDID_GET_IMAGE_HEADER 0x8f 114 struct stv680_image_header { /* For all upload and get image header */ 115 unsigned char size[4]; 116 unsigned char width[2]; 117 unsigned char height[2]; 118 unsigned char fine_exposure[2]; 119 unsigned char coarse_exposure[2]; 120 unsigned char sensor_gain; 121 unsigned char sensor_clkdiv; 122 unsigned char avg_pixel_value; 123 unsigned char flags; 124 #define IMAGE_IS_VALID 0x01 125 #define IMAGE_FROM_STREAM 0x04 126 #define IMAGE_FIRST_OF_MOVIE 0x10 127 }; 128 129 #define CMDID_GRAB_UPLOAD 0x89 130 struct stv680_image_header_small { 131 unsigned char size[4]; 132 unsigned char width[2]; 133 unsigned char height[2]; 134 }; 135 136 #define CMDID_GRAB_IMAGE 0x05 137 #define GRAB_UPDATE_INDEX 0x1000 138 #define GRAB_TO_LAST_LOCATION 0x2000 139 #define GRAB_SUPPRESS_BEEP 0x4000 140 #define GRAB_USE_CAMERA_INDEX 0x8000 141 142 #define CMDID_SET_IMAGE_INDEX 0x06 143 #define CMDID_START_VIDEO 0x09 144 #define CMDID_STOP_VIDEO 0x0a 145 146 #define CMDID_GET_USER_INFO 0x8d 147 struct stv680_user_info { 148 unsigned char buttonmask; 149 unsigned char camera_mode; 150 #define CAMERA_MODE_START 1 151 #define CAMERA_MODE_VIDEO 2 152 #define CAMERA_MODE_BUSY 4 153 #define CAMERA_MODE_IDLE 8 154 unsigned char index[2]; 155 unsigned char maximages[2]; 156 unsigned char current_format; 157 unsigned char reserved; 158 }; 159 160 #define STV0680_QCIF_WIDTH 178 161 #define STV0680_QCIF_HEIGHT 146 162 #define STV0680_CIF_WIDTH 356 163 #define STV0680_CIF_HEIGHT 292 164 #define STV0680_QVGA_WIDTH 324 165 #define STV0680_QVGA_HEIGHT 244 166 #define STV0680_VGA_WIDTH 644 167 #define STV0680_VGA_HEIGHT 484 168 169 int stv0680_try_cmd(GPPort *port, unsigned char cmd, 170 unsigned short data, 171 unsigned char *response, unsigned char response_len); 172 173 174 #endif 175