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