1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - TCL - include 3 File: api.h 4 5 Copyright 2008-2009 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: 2009-06-04#$ 14 $Rev: 10698 $ 15 $Author: okubata_ryoma $ 16 *---------------------------------------------------------------------------*/ 17 #ifndef TWL_TCL_API_H_ 18 #define TWL_TCL_API_H_ 19 20 #include <twl/misc.h> 21 #include <twl/types.h> 22 #include <nitro/fs.h> 23 #include <twl/tcl/ARM9/types.h> 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /*-------------------------------------------------------------------------* 30 Name: TCL_GetTableBufferSize 31 32 Description: Buffer size needed to load the management file. 33 34 Arguments: 35 36 Returns: Buffer size. 37 *-------------------------------------------------------------------------*/ 38 extern u32 TCL_GetTableBufferSize( void ); 39 40 /*-------------------------------------------------------------------------* 41 Name: TCL_GetWorkBufferSize 42 43 Description: Working buffer size needed to use the management file. 44 45 Arguments: 46 47 Returns: Buffer size. 48 *-------------------------------------------------------------------------*/ 49 extern u32 TCL_GetWorkBufferSize( void ); 50 51 /*-------------------------------------------------------------------------* 52 Name: TCL_LoadTable 53 54 Description: Loads the management table. 55 Allocate a 32-byte aligned buffer. 56 57 Arguments: pAccessor: Accessor 58 tableBuffer: Loading buffer 59 tableBufferSize: Buffer size. 60 (The size provided by the TCL_GetTableBufferSize function.) 61 workBuffer: Working buffer 62 workBufferSize: Working buffer size. 63 (The size provided by the TCL_GetWorkBufferSize function.) 64 pFSResult: Where the FSResult is stored when an error is generated by an FS function. 65 66 Returns: TCLResult. 67 *-------------------------------------------------------------------------*/ 68 extern TCLResult TCL_LoadTable( TCLAccessor* pAccessor , 69 void* tableBuffer , 70 u32 tableBufferSize , 71 void* workBuffer , 72 u32 workBufferSize , 73 FSResult* pFSResult ); 74 75 /*-------------------------------------------------------------------------* 76 Name: TCL_CreateTable 77 78 Description: Creates management table. 79 Allocate a 32-byte aligned buffer. 80 81 Arguments: pAccessor: Accessor 82 tableBuffer: Loading buffer 83 tableBufferSize: Buffer size. 84 (The size provided by the TCL_GetTableBufferSize function.) 85 workBuffer: Working buffer 86 workBufferSize: Working buffer size. 87 (The size provided by the TCL_GetWorkBufferSize function.) 88 pFSResult: Where the FSResult is stored when an error is generated by an FS function. 89 90 Returns: TCLResult. 91 *-------------------------------------------------------------------------*/ 92 extern TCLResult TCL_CreateTable( TCLAccessor* pAccessor , 93 void* tableBuffer , 94 u32 tableBufferSize , 95 void* workBuffer , 96 u32 workBufferSize , 97 FSResult* pFSResult ); 98 99 /*-------------------------------------------------------------------------* 100 Name: TCL_RepairTable 101 102 Description: Restores management table. 103 104 Arguments: pAccessor: Accessor 105 pFSResult: Where the FSResult is stored when an error is generated by an FS function. 106 107 Returns: TCLResult. 108 *-------------------------------------------------------------------------*/ 109 extern TCLResult TCL_RepairTable( TCLAccessor* pAccessor , FSResult* pFSResult ); 110 111 /*-------------------------------------------------------------------------* 112 Name: TCL_SortTable 113 114 Description: Sorts management table. 115 116 Arguments: pAccessor: Accessor 117 sortType: Sort type 118 119 Returns: None. 120 *-------------------------------------------------------------------------*/ 121 extern void TCL_SortTable( TCLAccessor* pAccessor , TCLSortType sortType ); 122 123 /*-------------------------------------------------------------------------* 124 Name: TCL_InitSearchObject 125 126 Description: Initializes search object. 127 128 Arguments: pSearchObj: Search object 129 condition: Search condition 130 131 Returns: None. 132 *-------------------------------------------------------------------------*/ 133 extern void TCL_InitSearchObject( TCLSearchObject* pSearchObj , u32 condition ); 134 135 /*-------------------------------------------------------------------------* 136 Name: TCL_GetNumPictures 137 138 Description: How many photos match the search conditions? 139 140 Arguments: pAccessor: Accessor 141 pSearchObj: Search object 142 143 Returns: Number of photos. 144 *-------------------------------------------------------------------------*/ 145 extern int TCL_GetNumPictures( const TCLAccessor* pAccessor , const TCLSearchObject* pSearchObj ); 146 147 /*-------------------------------------------------------------------------* 148 Name: TCL_SearchNextPictureInfo 149 150 Description: Gets the next piece of photo information that matches the search conditions. 151 152 Arguments: pAccessor: Accessor 153 ppPicInfo: Photo information storage location 154 pSearchObj: Search object 155 156 Returns: TCLResult. 157 *-------------------------------------------------------------------------*/ 158 extern TCLResult TCL_SearchNextPictureInfo( const TCLAccessor* pAccessor , 159 const TCLPictureInfo** ppPicInfo , 160 TCLSearchObject* pSearchObj ); 161 162 /*-------------------------------------------------------------------------* 163 Name: TCL_SearchPictureInfoByIndex 164 165 Description: Gets photo information that matches the search conditions at the specified index. 166 167 168 Arguments: pAccessor: Accessor 169 ppPicInfo: Photo information storage location 170 pSearchObj: Search object 171 index: Index 172 173 Returns: TCLResult. 174 *-------------------------------------------------------------------------*/ 175 extern TCLResult TCL_SearchPictureInfoByIndex( const TCLAccessor* pAccessor , 176 const TCLPictureInfo** ppPicInfo , 177 const TCLSearchObject* pSearchObj , 178 int index ); 179 180 /*-------------------------------------------------------------------------* 181 Name: TCL_SearchNextPicturePath 182 183 Description: Gets the next photo path that matches the search conditions. 184 185 Arguments: pAccessor: Accessor 186 path: Path storage location 187 len: Path length 188 pSearchObj: Search object 189 190 Returns: TCLResult. 191 *-------------------------------------------------------------------------*/ 192 extern TCLResult TCL_SearchNextPicturePath( const TCLAccessor* pAccessor , 193 char* path , 194 size_t len , 195 TCLSearchObject* pSearchObj ); 196 197 /*-------------------------------------------------------------------------* 198 Name: TCL_SearchPicturePathByIndex 199 200 Description: Gets the photo path that matches the search conditions at the specified index. 201 202 203 Arguments: pAccessor: Accessor 204 path: Path storage location 205 len: Path length 206 pSearchObj: Search object 207 index: Index 208 209 Returns: TCLResult. 210 *-------------------------------------------------------------------------*/ 211 extern TCLResult TCL_SearchPicturePathByIndex( const TCLAccessor* pAccessor , 212 char* path , 213 size_t len , 214 const TCLSearchObject* pSearchObj , 215 int index ); 216 217 /*-------------------------------------------------------------------------* 218 Name: TCL_PrintPicturePath 219 220 Description: Gets photo path. 221 222 Arguments: path: Path storage location 223 len: Path length 224 pPicInfo: Photo information 225 226 Returns: STD_TSNPrintf return value. 227 *-------------------------------------------------------------------------*/ 228 extern int TCL_PrintPicturePath( char* path , 229 size_t len , 230 const TCLPictureInfo* pPicInfo ); 231 232 /*-------------------------------------------------------------------------* 233 Name: TCL_GetPictureInfoFromPath 234 235 Description: Gets photo information from a path. 236 237 Arguments: pAccessor: Accessor 238 pPicInfo: Photo information 239 path: Path storage location 240 len: Path length 241 242 Returns: Returns TRUE if it could be obtained. 243 *-------------------------------------------------------------------------*/ 244 extern BOOL TCL_GetPictureInfoFromPath( const TCLAccessor* pAccessor , 245 TCLPictureInfo** ppPicInfo , 246 const char* path , 247 size_t len ); 248 249 /*-------------------------------------------------------------------------* 250 Name: TCL_CalcNumEnableToTakePictures 251 252 Description: Calculates how many photos can be taken. 253 254 Arguments: pAccessor: Accessor 255 256 Returns: Number of photos that can be taken. (A negative number indicates some kind of failure.) 257 *-------------------------------------------------------------------------*/ 258 extern int TCL_CalcNumEnableToTakePictures( const TCLAccessor* pAccessor ); 259 260 /*-------------------------------------------------------------------------* 261 Name: TCL_GetJpegEncoderBufferSize 262 263 Description: Returns the buffer size required for JPEG encoding. 264 Calls the SSP_GetJpegEncoderBufferSize function. 265 266 Arguments: option: Option to pass to the SSP_GetJpegEncoderBufferSize function. 267 268 Returns: Return value of the SSP_GetJpegEncoderBufferSize function. 269 *-------------------------------------------------------------------------*/ 270 extern u32 TCL_GetJpegEncoderBufferSize( u32 option ); 271 272 /*-------------------------------------------------------------------------* 273 Name: TCL_EncodeAndWritePicture 274 275 Description: Performs JPEG encoding of image and saves it. Also updates the management file. 276 Calls the TCL_GetCurrentSecond function. 277 278 Arguments: pAccessor: Accessor 279 imageBuffer: Image buffer 280 jpegBuffer: JPEG buffer 281 jpegBufferSize: JPEG buffer size 282 workBuffer: Work buffer necessary for JPEG encoding 283 quality: JPEG encoding quality 284 option: JPEG encoding options 285 pFSResult: Where the FSResult is stored when an error is generated by an FS function 286 287 Returns: TCLResult. 288 *-------------------------------------------------------------------------*/ 289 extern TCLResult TCL_EncodeAndWritePicture( TCLAccessor* pAccessor , 290 const void* imageBuffer , 291 u8* jpegBuffer , 292 u32 jpegBufferSize , 293 u8* workBuffer , 294 u32 quality , 295 u32 option , 296 FSResult* pFSResult ); 297 298 /*-------------------------------------------------------------------------* 299 Name: TCL_EncodeAndWritePictureEx 300 301 Description: Performs JPEG encoding (user maker note settings) of image and saves it. Also updates the management file. 302 Calls the TCL_GetCurrentSecond function. 303 304 Arguments: pAccessor: Accessor 305 imageBuffer: Image buffer 306 jpegBuffer: JPEG buffer 307 jpegBufferSize: JPEG buffer size 308 workBuffer: Work buffer necessary for JPEG encoding 309 quality: JPEG encoding quality 310 option: JPEG encoding options 311 makerNoteBuffer: User maker note buffer 312 makerNoteBufferSize: User maker note buffer size 313 pFSResult: Where the FSResult is stored when an error is generated by an FS function 314 315 Returns: TCLResult. 316 *-------------------------------------------------------------------------*/ 317 extern TCLResult TCL_EncodeAndWritePictureEx( TCLAccessor* pAccessor , 318 const void* imageBuffer , 319 u8* jpegBuffer , 320 u32 jpegBufferSize , 321 u8* workBuffer , 322 u32 quality , 323 u32 option , 324 u8* makerNoteBuffer , 325 u16 makerNoteBufferSize , 326 FSResult* pFSResult ); 327 328 /*-------------------------------------------------------------------------* 329 Name: TCL_GetLastWrittenPicturePath 330 331 Description: Returns path of image written last. 332 333 Arguments: 334 335 Returns: Path of image last written. 336 *-------------------------------------------------------------------------*/ 337 extern const char* TCL_GetLastWrittenPicturePath( void ); 338 339 /*-------------------------------------------------------------------------* 340 Name: TCL_GetLastWrittenPictureInfo 341 342 Description: Returns TCLPictureInfo for the last image to be written. 343 344 Arguments: 345 346 Returns: TCLPictureInfo of the last image to be written. 347 *-------------------------------------------------------------------------*/ 348 extern const TCLPictureInfo* TCL_GetLastWrittenPictureInfo( void ); 349 350 /*-------------------------------------------------------------------------* 351 Name: TCL_DecodePicture 352 353 Description: Performs JPEG decoding. 354 355 Arguments: fileBuffer: File buffer 356 fileBufferSize: File buffer size 357 imageBuffer: Image buffer 358 width: Decode image width 359 height: Decode image height 360 decodeOption: Decode option 361 362 Returns: TCLResult. 363 *-------------------------------------------------------------------------*/ 364 extern TCLResult TCL_DecodePicture( u8* fileBuffer , 365 u32 fileBufferSize , 366 void* imageBuffer , 367 s16 width , 368 s16 height , 369 u32 decodeOption ); 370 371 /*-------------------------------------------------------------------------* 372 Name: TCL_DeletePicture 373 374 Description: Deletes a JPEG file. 375 376 Arguments: pAccessor: Accessor 377 pPicInfo: Photo information 378 pFSResult: Where the FSResult is stored when an error is generated by an FS function 379 380 Returns: TCLResult. 381 *-------------------------------------------------------------------------*/ 382 extern TCLResult TCL_DeletePicture( TCLAccessor* pAccessor , 383 const TCLPictureInfo* pPicInfo , 384 FSResult* pFSResult ); 385 386 /*-------------------------------------------------------------------------* 387 Name: TCL_IsSameImageType 388 389 Description: Whether recognized as same image type. 390 391 Arguments: pPicInfo: Photo information 392 pMakerNote: Manufacturer's notes 393 394 Returns: TRUE when recognized as same. 395 *-------------------------------------------------------------------------*/ 396 extern BOOL TCL_IsSameImageType( const TCLPictureInfo* pPicInfo , const TCLMakerNote* pMakerNote ); 397 398 /*-------------------------------------------------------------------------* 399 Name: TCL_GetCurrentSecond 400 401 Description: Gets the current time (in seconds). 402 Calls the RTC_GetDateTime function internally. 403 This function is defined with a weak symbol. 404 Redefine when exclusive processing for RTC is needed. 405 406 Arguments: 407 408 Returns: Current time (in seconds). 409 *-------------------------------------------------------------------------*/ 410 extern s64 TCL_GetCurrentSecond( void ); 411 412 #ifdef __cplusplus 413 } /* extern "C" */ 414 #endif 415 416 /* TWL_TCL_API_H_ */ 417 #endif 418