1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: y2r_Api.h 4 5 Copyright (C)2009 Nintendo Co., Ltd. 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 $Rev: 38552 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_Y2R_CTR_Y2R_API_H_ 17 #define NN_Y2R_CTR_Y2R_API_H_ 18 19 /* Please see man pages for details 20 21 */ 22 23 #include <nn/os.h> 24 #include <nn/y2r/CTR/y2r_Types.h> 25 26 #include <nn/y2r/CTR/y2r_Y2r.h> 27 28 namespace nn { 29 namespace y2r { 30 namespace CTR { 31 32 namespace detail 33 { 34 bool InitializeBase(Handle* pSession, const char* name); 35 bool PingProcess(u8* connectedNumber); 36 void FinalizeBase(Handle* pSession); 37 void SetInputFormat( InputFormat format ); 38 InputFormat GetInputFormat( void ); 39 void SetOutputFormat( OutputFormat format ); 40 OutputFormat GetOutputFormat( void ); 41 void SetRotation( Rotation rotation ); 42 Rotation GetRotation( void ); 43 void SetBlockAlignment( BlockAlignment align ); 44 BlockAlignment GetBlockAlignment( void ); 45 void SetSpacialDithering( bool enable ); 46 bool GetSpacialDithering( void ); 47 void SetTemporalDithering( bool enable ); 48 bool GetTemporalDithering( void ); 49 void SetTransferEndInterrupt( bool enable ); 50 bool GetTransferEndInterrupt( void ); 51 void GetTransferEndEvent( nn::os::Event* pEvent ); 52 void SetSendingY( u32 pSrc, size_t imageSize, s16 transferUnit, s16 transferStride ); 53 void SetSendingU( u32 pSrc, size_t imageSize, s16 transferUnit, s16 transferStride ); 54 void SetSendingV( u32 pSrc, size_t imageSize, s16 transferUnit, s16 transferStride ); 55 void SetSendingYuv( u32 pSrc, size_t imageSize, s16 transferUnit, s16 transferStride ); 56 bool IsFinishedSendingYuv( void ); 57 bool IsFinishedSendingY( void ); 58 bool IsFinishedSendingU( void ); 59 bool IsFinishedSendingV( void ); 60 void SetReceiving( u32 pDst, size_t imageSize, s16 transferUnit, s16 transferStride ); 61 bool IsFinishedReceiving( void ); 62 void SetInputLineWidth( s16 width ); 63 s16 GetInputLineWidth( void ); 64 void SetInputLines( s16 lines ); 65 s16 GetInputLines( void ); 66 size_t GetOutputFormatBytes( OutputFormat format ); 67 size_t GetOutputBlockSize( s16 lineWidth, OutputFormat format ); 68 size_t GetOutputImageSize( s16 lineWidth, s16 height, OutputFormat format ); 69 void SetCoefficientParams( CoefficientParams src ); 70 void GetCoefficientParams( CoefficientParams* pDst ); 71 void SetStandardCoefficient( StandardCoefficient no ); 72 void GetStandardCoefficientParams( CoefficientParams* pDst, StandardCoefficient no ); 73 void SetAlpha( s16 alpha ); 74 s16 GetAlpha( void ); 75 void SetDitheringWeightParams( const DitheringWeightParams & w ); 76 void GetDitheringWeightParams( DitheringWeightParams* pW ); 77 nn::Result StartConversion( void ); 78 void StopConversion( void ); 79 bool IsBusyConversion( void ); 80 81 // Utility functions for setting arguments all at once 82 void SetPackageParameter(const PackageParameter& param); 83 void GetPackageParameter(PackageParameter* pParam); 84 } 85 86 namespace 87 { 88 const char PORT_NAME_USER[] = "y2r:u"; 89 const u16 OUTPUT_BUF_SIZE = 24*1024; // Output buffer size 90 const u8 OUTPUT_LINES_NUM = 8; // Maximum number of lines that can be stored in the output buffer 91 } 92 93 /* Please see man pages for details 94 95 96 97 */ 98 bool Initialize(); 99 Initialize()100 inline bool Initialize() { return detail::InitializeBase(&detail::Y2r::s_Session, PORT_NAME_USER); } 101 102 /* Please see man pages for details 103 104 105 106 */ 107 void Finalize(); 108 Finalize()109 inline void Finalize() { detail::FinalizeBase(&detail::Y2r::s_Session); } 110 111 /* Please see man pages for details 112 113 114 115 116 */ SetInputFormat(InputFormat format)117 inline void SetInputFormat( InputFormat format ) 118 { 119 detail::SetInputFormat(format); 120 } 121 /* Please see man pages for details 122 123 124 125 */ GetInputFormat(void)126 inline InputFormat GetInputFormat( void ) 127 { 128 return detail::GetInputFormat(); 129 } 130 /* Please see man pages for details 131 132 133 134 135 */ SetOutputFormat(OutputFormat format)136 inline void SetOutputFormat( OutputFormat format ) 137 { 138 detail::SetOutputFormat(format); 139 } 140 /* Please see man pages for details 141 142 143 144 */ GetOutputFormat(void)145 inline OutputFormat GetOutputFormat( void ) 146 { 147 return detail::GetOutputFormat(); 148 } 149 /* Please see man pages for details 150 151 152 153 154 */ SetRotation(Rotation rotation)155 inline void SetRotation( Rotation rotation ) 156 { 157 detail::SetRotation(rotation); 158 } 159 /* Please see man pages for details 160 161 162 163 */ GetRotation(void)164 inline Rotation GetRotation( void ) 165 { 166 return detail::GetRotation(); 167 } 168 /* Please see man pages for details 169 170 171 172 173 */ SetBlockAlignment(BlockAlignment align)174 inline void SetBlockAlignment( BlockAlignment align ) 175 { 176 detail::SetBlockAlignment(align); 177 } 178 /* Please see man pages for details 179 180 181 182 */ GetBlockAlignment(void)183 inline BlockAlignment GetBlockAlignment( void ) 184 { 185 return detail::GetBlockAlignment(); 186 } 187 /* Please see man pages for details 188 189 190 191 192 */ SetSpacialDithering(bool enable)193 inline void SetSpacialDithering( bool enable ) 194 { 195 detail::SetSpacialDithering(enable); 196 } 197 /* Please see man pages for details 198 199 200 201 */ GetSpacialDithering(void)202 inline bool GetSpacialDithering( void ) 203 { 204 return detail::GetSpacialDithering(); 205 } 206 /* Please see man pages for details 207 208 209 210 211 212 */ SetTemporalDithering(bool enable)213 inline void SetTemporalDithering( bool enable ) 214 { 215 detail::SetTemporalDithering(enable); 216 } 217 /* Please see man pages for details 218 219 220 221 222 */ GetTemporalDithering(void)223 inline bool GetTemporalDithering( void ) 224 { 225 return detail::GetTemporalDithering(); 226 } 227 /* Please see man pages for details 228 229 230 231 232 233 */ SetTransferEndInterrupt(bool enable)234 inline void SetTransferEndInterrupt( bool enable ) 235 { 236 detail::SetTransferEndInterrupt(enable); 237 } 238 /* Please see man pages for details 239 240 241 242 */ GetTransferEndInterrupt(void)243 inline bool GetTransferEndInterrupt( void ) 244 { 245 return detail::GetTransferEndInterrupt(); 246 } 247 /* Please see man pages for details 248 249 250 251 252 */ GetTransferEndEvent(nn::os::Event * pEvent)253 inline void GetTransferEndEvent( nn::os::Event* pEvent ) 254 { 255 detail::GetTransferEndEvent(pEvent); 256 } 257 /* Please see man pages for details 258 259 260 261 262 263 264 265 266 */ 267 inline void SetSendingY( const void* pSrc, size_t imageSize, s16 transferUnit, s16 transferStride = 0 ) 268 { 269 detail::SetSendingY(reinterpret_cast<u32>(pSrc), imageSize, transferUnit, transferStride); 270 } 271 /* Please see man pages for details 272 273 274 275 276 277 278 279 */ 280 inline void SetSendingU( const void* pSrc, size_t imageSize, s16 transferUnit, s16 transferStride = 0 ) 281 { 282 detail::SetSendingU(reinterpret_cast<u32>(pSrc), imageSize, transferUnit, transferStride); 283 } 284 /* Please see man pages for details 285 286 287 288 289 290 291 292 */ 293 inline void SetSendingV( const void* pSrc, size_t imageSize, s16 transferUnit, s16 transferStride = 0 ) 294 { 295 detail::SetSendingV(reinterpret_cast<u32>(pSrc), imageSize, transferUnit, transferStride); 296 } 297 /* Please see man pages for details 298 299 300 301 302 303 304 305 */ 306 inline void SetSendingYuv( const void* pSrc, size_t imageSize, s16 transferUnit, s16 transferStride = 0 ) 307 { 308 detail::SetSendingYuv(reinterpret_cast<u32>(pSrc), imageSize, transferUnit, transferStride); 309 } 310 /* Please see man pages for details 311 312 313 314 */ IsFinishedSendingYuv(void)315 inline bool IsFinishedSendingYuv( void ) 316 { 317 return detail::IsFinishedSendingYuv(); 318 } 319 /* Please see man pages for details 320 321 322 323 */ IsFinishedSendingY(void)324 inline bool IsFinishedSendingY( void ) 325 { 326 return detail::IsFinishedSendingY(); 327 } 328 /* Please see man pages for details 329 330 331 332 */ IsFinishedSendingU(void)333 inline bool IsFinishedSendingU( void ) 334 { 335 return detail::IsFinishedSendingU(); 336 } 337 /* Please see man pages for details 338 339 340 341 */ IsFinishedSendingV(void)342 inline bool IsFinishedSendingV( void ) 343 { 344 return detail::IsFinishedSendingV(); 345 } 346 /* Please see man pages for details 347 348 349 350 351 352 353 354 355 */ 356 inline void SetReceiving( void* pDst, size_t imageSize, s16 transferUnit, s16 transferStride = 0 ) 357 { 358 detail::SetReceiving(reinterpret_cast<u32>(pDst), imageSize, transferUnit, transferStride); 359 } 360 /* Please see man pages for details 361 362 363 364 */ IsFinishedReceiving(void)365 inline bool IsFinishedReceiving( void ) 366 { 367 return detail::IsFinishedReceiving(); 368 } 369 /* Please see man pages for details 370 371 372 373 374 375 376 */ SetInputLineWidth(s16 width)377 inline void SetInputLineWidth( s16 width ) 378 { 379 detail::SetInputLineWidth(width); 380 } 381 /* Please see man pages for details 382 383 384 385 */ GetInputLineWidth(void)386 inline s16 GetInputLineWidth( void ) 387 { 388 return detail::GetInputLineWidth(); 389 } 390 /* Please see man pages for details 391 392 393 394 395 */ SetInputLines(s16 lines)396 inline void SetInputLines( s16 lines ) 397 { 398 detail::SetInputLines(lines); 399 } 400 /* Please see man pages for details 401 402 403 404 */ GetInputLines(void)405 inline s16 GetInputLines( void ) 406 { 407 return detail::GetInputLines(); 408 } 409 /* Please see man pages for details 410 411 412 413 414 */ GetOutputFormatBytes(OutputFormat format)415 inline size_t GetOutputFormatBytes( OutputFormat format ) 416 { 417 return detail::GetOutputFormatBytes(format); 418 } 419 /* Please see man pages for details 420 421 422 423 424 425 */ GetOutputBlockSize(s16 lineWidth,OutputFormat format)426 inline size_t GetOutputBlockSize( s16 lineWidth, OutputFormat format ) 427 { 428 return detail::GetOutputBlockSize(lineWidth, format); 429 } 430 /* Please see man pages for details 431 432 433 434 435 436 437 */ GetOutputImageSize(s16 lineWidth,s16 height,OutputFormat format)438 inline size_t GetOutputImageSize( s16 lineWidth, s16 height, OutputFormat format ) 439 { 440 return detail::GetOutputImageSize(lineWidth, height, format); 441 } 442 /* Please see man pages for details 443 444 445 446 447 448 449 */ SetCoefficientParams(CoefficientParams src)450 inline void SetCoefficientParams( CoefficientParams src ) 451 { 452 detail::SetCoefficientParams(src); 453 } 454 /* Please see man pages for details 455 456 457 458 459 460 461 */ GetCoefficientParams(CoefficientParams * pDst)462 inline void GetCoefficientParams( CoefficientParams* pDst ) 463 { 464 detail::GetCoefficientParams(pDst); 465 } 466 /* Please see man pages for details 467 468 469 470 471 */ SetStandardCoefficient(StandardCoefficient no)472 inline void SetStandardCoefficient( StandardCoefficient no ) 473 { 474 detail::SetStandardCoefficient(no); 475 } 476 /* Please see man pages for details 477 478 479 480 481 482 483 484 */ GetStandardCoefficientParams(CoefficientParams * pDst,StandardCoefficient no)485 inline void GetStandardCoefficientParams( CoefficientParams* pDst, StandardCoefficient no ) 486 { 487 detail::GetStandardCoefficientParams(pDst, no); 488 } 489 /* Please see man pages for details 490 491 492 493 494 */ SetAlpha(s16 alpha)495 inline void SetAlpha( s16 alpha ) 496 { 497 detail::SetAlpha(alpha); 498 } 499 /* Please see man pages for details 500 501 502 503 */ GetAlpha(void)504 inline s16 GetAlpha( void ) 505 { 506 return detail::GetAlpha(); 507 } 508 /* Please see man pages for details 509 510 511 512 513 */ SetDitheringWeightParams(const DitheringWeightParams & w)514 inline void SetDitheringWeightParams( const DitheringWeightParams & w ) 515 { 516 detail::SetDitheringWeightParams(w); 517 } 518 /* Please see man pages for details 519 520 521 522 523 */ GetDitheringWeightParams(DitheringWeightParams * pW)524 inline void GetDitheringWeightParams( DitheringWeightParams* pW ) 525 { 526 detail::GetDitheringWeightParams(pW); 527 } 528 /* Please see man pages for details 529 530 531 532 533 534 */ StartConversion(void)535 inline nn::Result StartConversion( void ) 536 { 537 return detail::StartConversion(); 538 } 539 /* Please see man pages for details 540 541 542 543 */ StopConversion(void)544 inline void StopConversion( void ) 545 { 546 detail::StopConversion(); 547 } 548 /* Please see man pages for details 549 550 551 552 */ IsBusyConversion(void)553 inline bool IsBusyConversion( void ) 554 { 555 return detail::IsBusyConversion(); 556 } 557 558 /* Please see man pages for details 559 560 561 562 563 */ SetPackageParameter(const PackageParameter & param)564 inline void SetPackageParameter(const PackageParameter& param) 565 { 566 return detail::SetPackageParameter( param ); 567 } 568 569 /* Please see man pages for details 570 571 572 573 574 */ GetPackageParameter(PackageParameter * pParam)575 inline void GetPackageParameter(PackageParameter* pParam) 576 { 577 return detail::GetPackageParameter( pParam ); 578 } 579 } 580 } 581 } 582 583 #endif // ifndef NN_Y2R_CTR_Y2R_API_H_ 584