1 //<MStar Software> 2 //****************************************************************************** 3 // MStar Software 4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved. 5 // All software, firmware and related documentation herein ("MStar Software") are 6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by 7 // law, including, but not limited to, copyright law and international treaties. 8 // Any use, modification, reproduction, retransmission, or republication of all 9 // or part of MStar Software is expressly prohibited, unless prior written 10 // permission has been granted by MStar. 11 // 12 // By accessing, browsing and/or using MStar Software, you acknowledge that you 13 // have read, understood, and agree, to be bound by below terms ("Terms") and to 14 // comply with all applicable laws and regulations: 15 // 16 // 1. MStar shall retain any and all right, ownership and interest to MStar 17 // Software and any modification/derivatives thereof. 18 // No right, ownership, or interest to MStar Software and any 19 // modification/derivatives thereof is transferred to you under Terms. 20 // 21 // 2. You understand that MStar Software might include, incorporate or be 22 // supplied together with third party`s software and the use of MStar 23 // Software may require additional licenses from third parties. 24 // Therefore, you hereby agree it is your sole responsibility to separately 25 // obtain any and all third party right and license necessary for your use of 26 // such third party`s software. 27 // 28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as 29 // MStar`s confidential information and you agree to keep MStar`s 30 // confidential information in strictest confidence and not disclose to any 31 // third party. 32 // 33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any 34 // kind. Any warranties are hereby expressly disclaimed by MStar, including 35 // without limitation, any warranties of merchantability, non-infringement of 36 // intellectual property rights, fitness for a particular purpose, error free 37 // and in conformity with any international standard. You agree to waive any 38 // claim against MStar for any loss, damage, cost or expense that you may 39 // incur related to your use of MStar Software. 40 // In no event shall MStar be liable for any direct, indirect, incidental or 41 // consequential damages, including without limitation, lost of profit or 42 // revenues, lost or damage of data, and unauthorized system use. 43 // You agree that this Section 4 shall still apply without being affected 44 // even if MStar Software has been modified by MStar in accordance with your 45 // request or instruction for your use, except otherwise agreed by both 46 // parties in writing. 47 // 48 // 5. If requested, MStar may from time to time provide technical supports or 49 // services in relation with MStar Software to you for your use of 50 // MStar Software in conjunction with your or your customer`s product 51 // ("Services"). 52 // You understand and agree that, except otherwise agreed by both parties in 53 // writing, Services are provided on an "AS IS" basis and the warranty 54 // disclaimer set forth in Section 4 above shall apply. 55 // 56 // 6. Nothing contained herein shall be construed as by implication, estoppels 57 // or otherwise: 58 // (a) conferring any license or right to use MStar name, trademark, service 59 // mark, symbol or any other identification; 60 // (b) obligating MStar or any of its affiliates to furnish any person, 61 // including without limitation, you and your customers, any assistance 62 // of any kind whatsoever, or any information; or 63 // (c) conferring any license or right under any intellectual property right. 64 // 65 // 7. These terms shall be governed by and construed in accordance with the laws 66 // of Taiwan, R.O.C., excluding its conflict of law rules. 67 // Any and all dispute arising out hereof or related hereto shall be finally 68 // settled by arbitration referred to the Chinese Arbitration Association, 69 // Taipei in accordance with the ROC Arbitration Law and the Arbitration 70 // Rules of the Association by three (3) arbitrators appointed in accordance 71 // with the said Rules. 72 // The place of arbitration shall be in Taipei, Taiwan and the language shall 73 // be English. 74 // The arbitration award shall be final and binding to both parties. 75 // 76 //****************************************************************************** 77 //<MStar Software> 78 //Copyright (C) 2008 MStar All Rights Reserved. 79 80 /*! \file drvUsbPTPLib.h 81 \brief Library for PTP functions. 82 83 84 \n\b History: 85 \n\b Date: 2008/8/18 86 \n\b Author: Colin Tsai 87 \n\b Reason: Create 88 \n 89 */ 90 //============================================================================= 91 92 #ifndef DRVUSBPTPLIB_H 93 #define DRVUSBPTPLIB_H 94 95 #include "datatype.h" 96 //#include "..\source\drvUSBHost_PTP.h" 97 98 typedef enum PTP_OPERATION_CODE 99 { 100 PTP_UnDefined = 0x1000, 101 PTP_GetDeviceInfo, 102 PTP_OpenSession, 103 PTP_CloseSession, 104 PTP_GetStorageIDs, 105 PTP_GetStorageInfo, 106 PTP_GetNumObjects, 107 PTP_GetObjectHandles, 108 PTP_GetObjectInfo, 109 PTP_GetObject, 110 PTP_GetThumb, 111 PTP_DeleteObject, 112 PTP_SendObjectInfo, 113 PTP_SendObject, 114 PTP_InitiateCapture, 115 PTP_FormatStore, 116 PTP_ResetDevice, 117 PTP_SelfTest, 118 PTP_SetObjectProtection, 119 PTP_PowerDown, 120 PTP_GetDevicePropDesc, 121 PTP_GetDevicePropValue, 122 PTP_SetDevicePropValue, 123 PTP_ResetDevicePropValue, 124 PTP_TerminateOpenCapture, 125 PTP_MoveObject, 126 PTP_CopyObject, 127 PTP_GetPartialObject, 128 PTP_InitiateOpenCapture 129 }ePTP_OPERATION_CODE; 130 131 enum 132 { 133 UnKnownFile, 134 JpegFile, 135 OtherFile 136 }; 137 138 139 enum 140 { 141 PTP_OK=0, 142 PTP_RESP_FAIL 143 144 }; 145 146 typedef enum PTP_OBJECTFORMATCODE 147 { 148 OBJ_UNDEFINED_NON_IMAGE = 0x3000, 149 OBJ_ASSOCIATION, 150 OBJ_SCRIPT, 151 OBJ_EXECUTABLE, 152 OBJ_TEXT, 153 OBJ_HTML, 154 OBJ_DPOF, 155 OBJ_AIFF, 156 OBJ_WAV, 157 OBJ_MP3, 158 OBJ_AVI, 159 OBJ_MPEG, 160 OBJ_ASF, 161 OBJ_UNDIFINED_IMAGE = 0x3800, 162 OBJ_JPEG, 163 OBJ_TIFF_EP, 164 OBJ_FLASHPIX, 165 OBJ_BMP, 166 OBJ_CIFF, 167 OBJ_UNDIFFINED_RESERVED_0, 168 OBJ_GIF, 169 OBJ_JFIF, 170 OBJ_PCD, 171 OBJ_PICT, 172 OBJ_PNG, 173 OBJ_UNDIFFINED_RESERVED_1, 174 OBJ_TIFF, 175 OBJ_TIFF_IT, 176 OBJ_JP2, 177 OBJ_JPX 178 179 }ePTP_OBJECTFORMATCODE; 180 181 typedef struct _DATETIME { 182 183 U8 bDateTime[5]; // 5+2+2+2 = 13 bytes 184 U16 wTemp; 185 //------------------------------------------------------- 186 // bit 0- bit 4 Day (1-31) 187 // bit 5- bit 8 Month (1-12) 188 // bit 9- bit f Year relative to 1980 189 //------------------------------------------------------- 190 U16 wDate; 191 //------------------------------------------------------- 192 // bit 0- bit 4 binary numbers of 2 secs increament 0-58 193 // bit 5- bit a binary numbers of minutes 0-59 194 // bit b- bit f binary numbers of hours 0-23 195 //------------------------------------------------------- 196 U16 wTime; 197 198 } DATETIME, *PDATETIME; 199 200 typedef struct _PTP_OBJECTINFO 201 { 202 U16 ObjectFormat; 203 U32 ObjectCompressedSize; 204 U16 ThumbFormat; 205 U32 ThumbCompressedSize; 206 U32 ThumbPixWidth; 207 U32 ThumbPixHeight; 208 U32 ImagePixWidth; 209 U32 ImagePixHeight; 210 U32 ParentObject; 211 U16 Filename[13]; // 8 + . + 3 + null 212 struct _DATETIME sDateTime; 213 } PTP_OBJECTINFO, *PPTP_OBJECTINFO; 214 215 //Function_Name: drvUsbPTP_GetObjectHandles( ) 216 /*! \brief Gather all object handles according to parameters passed in. 217 218 This function will try to gather all object handles according to parameters passed in. 219 The handles are stored in memory of PTP library. 220 221 \param u8UsbPort The USB port number. 222 223 \param u16ObjFormat The object format code you want to get. All handles returned 224 will belong to this format. The value 0 means "Dont care" 225 226 \param u32AssociObjHandle The associate object handle. All handles returned will 227 be its children. The value 0 means "Don't case", 228 and 0xFFFFFFFF means the "Root" 229 230 \return The number of object handles it got. 231 */ 232 U32 drvUsbPTP_GetObjectHandles(U8 u8UsbPort, U16 u16ObjFormat, U32 u32AssociObjHandle); 233 234 //Function_Name: drvUsbPTP_GetObjectHandleByIndex( ) 235 /*! \brief Get real object handle from PTP library memory. 236 237 This function will try to get the real object handle from PTP library memory. It should be 238 called after the function msAPI_PTP_GetObjectHandles. 239 240 \param u8UsbPort The USB port number. 241 242 \param u32Index The object index you want to get. 243 244 \return Object handle or 0xFFFFFFFF for invalid object handle. 245 */ 246 U32 drvUsbPTP_GetObjectHandleByIndex(U8 u8UsbPort, U32 u32Index); 247 248 //Function_Name: drvUsbPTP_GetObjectInfo( ) 249 /*! \brief Get PTP object information. 250 251 This function will try to get object information. 252 253 \param u8UsbPort The USB port number. 254 \param u32ObjectHandle The object handle you want to get. 255 256 \return Pointer for ObjectInfo. 257 */ 258 PTP_OBJECTINFO * drvUsbPTP_GetObjectInfo(U8 u8UsbPort, U32 u32ObjectHandle); 259 260 //Function_Name: drvUsbPTP_GetThumb( ) 261 /*! \brief Get the thumbnail of object. 262 263 This function will try to get the thumbnail of object. 264 265 \param u8UsbPort The USB port number. 266 \param u32ObjectHandle The object handle you want to get. 267 \param u32Offset The start offset you want to get. 268 \param u32Length The buffer size. 269 \param u32BufAddr The buffer address. 270 271 \return acutal thumb size it got. 272 */ 273 U32 drvUsbPTP_GetThumb(U8 u8UsbPort, U32 u32ObjectHandle, U32 u32Offset, U32 u32Length, U32 u32BufAddr); 274 275 //Function_Name: drvUsbPTP_GetObject( ) 276 /*! \brief Get the object. 277 278 This function will try to get content of object. 279 280 Please follow the offset sequence to get the object data. When the u32Offset is zero, 281 PTP USB driver will issue PTP command (GetObject) to the camera , and get the first bank of data. 282 For example, if the AP has a 16K buffer to get image data, the operation sequence is as follow. 283 1st : offset 0 , length 16K 284 2nd: offset 16K, length 16K 285 3rd: offset 32K, length 16K 286 .. 287 If users want to stop or issue other commands before the end of the object data stream, 288 driver has to read all data at the camera side, it may take a period of time. 289 290 \param u8UsbPort The USB port number. 291 \param u32ObjectHandle The object handle you want to get. 292 \param u32Offset The start offset you want to get. 293 \param u32Length The size you want to get. 294 \param u32BufAddr Buffer address. 295 296 \return acutal object size it got. 297 */ 298 U32 drvUsbPTP_GetObject(U8 u8UsbPort, U32 u32ObjectHandle, U32 u32Offset, U32 u32Length, U32 u32BufAddr); 299 300 301 //Function_Name: drvUsbPTP_GetObjectEnd( ) 302 /*! \brief Terminate the operation of getting object. 303 304 This function will try to terminate the operation of getting object. 305 306 \param u8UsbPort The USB port number. 307 \param u32ObjectHandle The object handle you want to get. 308 \param u32BufAddr The buffer address. (buffer size must be 16KB at least) 309 310 \return none. 311 */ 312 void drvUsbPTP_GetObjectEnd(U8 u8UsbPort, U32 u32ObjectHandle, U32 u32BufAddr); 313 314 //Function_Name: drvUsbPTP_GetError( ) 315 /*! \brief Get the error code of PTP. 316 317 This function will try to get the error code of PTP library. 318 319 \param u8UsbPort The USB port number. 320 321 \return USB error code. 322 #define HOST20_OK 0x00 323 #define HOST20_FAIL 0x01 324 #define HOST20_FATAL 0x02 325 #define HOST20_DEVICE_STALL 0x03 326 #define HOST20_TRANSACTION_ERROR 0x04 327 */ 328 U8 drvUsbPTP_GetError(U8 u8UsbPort); 329 330 #endif // #ifndef DRVUSBPTPLIB_H 331 332