summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar wwylele2017-05-24 12:50:19 +0300
committerGravatar wwylele2017-05-24 12:50:19 +0300
commit8cd9522526de290865094c7ff102db8e2872b471 (patch)
tree729c6eb848fca1ffc9e6144e6ff3d90e3905eac0 /src
parentcam: use IPCHelper (diff)
downloadyuzu-8cd9522526de290865094c7ff102db8e2872b471.tar.gz
yuzu-8cd9522526de290865094c7ff102db8e2872b471.tar.xz
yuzu-8cd9522526de290865094c7ff102db8e2872b471.zip
cam: move u32->u8 trancation to IPCHelper
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/cam/cam.cpp67
1 files changed, 33 insertions, 34 deletions
diff --git a/src/core/hle/service/cam/cam.cpp b/src/core/hle/service/cam/cam.cpp
index 957013d5b..342a0edeb 100644
--- a/src/core/hle/service/cam/cam.cpp
+++ b/src/core/hle/service/cam/cam.cpp
@@ -225,8 +225,7 @@ static void ActivatePort(int port_id, int camera_id) {
225template <int max_index> 225template <int max_index>
226class CommandParamBitSet : public BitSet8 { 226class CommandParamBitSet : public BitSet8 {
227public: 227public:
228 explicit CommandParamBitSet(u32 command_param) 228 explicit CommandParamBitSet(u8 command_param) : BitSet8(command_param) {}
229 : BitSet8(static_cast<u8>(command_param & 0xFF)) {}
230 229
231 bool IsValid() const { 230 bool IsValid() const {
232 return m_val < (1 << max_index); 231 return m_val < (1 << max_index);
@@ -245,7 +244,7 @@ using CameraSet = CommandParamBitSet<3>;
245 244
246void StartCapture(Service::Interface* self) { 245void StartCapture(Service::Interface* self) {
247 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x01, 1, 0); 246 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x01, 1, 0);
248 const PortSet port_select(rp.Pop<u32>()); 247 const PortSet port_select(rp.Pop<u8>());
249 248
250 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 249 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
251 250
@@ -279,7 +278,7 @@ void StartCapture(Service::Interface* self) {
279 278
280void StopCapture(Service::Interface* self) { 279void StopCapture(Service::Interface* self) {
281 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x02, 1, 0); 280 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x02, 1, 0);
282 const PortSet port_select(rp.Pop<u32>()); 281 const PortSet port_select(rp.Pop<u8>());
283 282
284 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 283 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
285 284
@@ -304,7 +303,7 @@ void StopCapture(Service::Interface* self) {
304 303
305void IsBusy(Service::Interface* self) { 304void IsBusy(Service::Interface* self) {
306 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x03, 1, 0); 305 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x03, 1, 0);
307 const PortSet port_select(rp.Pop<u32>()); 306 const PortSet port_select(rp.Pop<u8>());
308 307
309 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); 308 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
310 309
@@ -327,7 +326,7 @@ void IsBusy(Service::Interface* self) {
327 326
328void ClearBuffer(Service::Interface* self) { 327void ClearBuffer(Service::Interface* self) {
329 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x04, 1, 0); 328 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x04, 1, 0);
330 const PortSet port_select(rp.Pop<u32>()); 329 const PortSet port_select(rp.Pop<u8>());
331 330
332 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 331 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
333 rb.Push(RESULT_SUCCESS); 332 rb.Push(RESULT_SUCCESS);
@@ -337,7 +336,7 @@ void ClearBuffer(Service::Interface* self) {
337 336
338void GetVsyncInterruptEvent(Service::Interface* self) { 337void GetVsyncInterruptEvent(Service::Interface* self) {
339 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x05, 1, 0); 338 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x05, 1, 0);
340 const PortSet port_select(rp.Pop<u32>()); 339 const PortSet port_select(rp.Pop<u8>());
341 340
342 IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); 341 IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
343 if (port_select.IsSingle()) { 342 if (port_select.IsSingle()) {
@@ -356,7 +355,7 @@ void GetVsyncInterruptEvent(Service::Interface* self) {
356 355
357void GetBufferErrorInterruptEvent(Service::Interface* self) { 356void GetBufferErrorInterruptEvent(Service::Interface* self) {
358 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x06, 1, 0); 357 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x06, 1, 0);
359 const PortSet port_select(rp.Pop<u32>()); 358 const PortSet port_select(rp.Pop<u8>());
360 359
361 IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); 360 IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
362 if (port_select.IsSingle()) { 361 if (port_select.IsSingle()) {
@@ -376,7 +375,7 @@ void GetBufferErrorInterruptEvent(Service::Interface* self) {
376void SetReceiving(Service::Interface* self) { 375void SetReceiving(Service::Interface* self) {
377 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x07, 4, 2); 376 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x07, 4, 2);
378 const VAddr dest = rp.Pop<u32>(); 377 const VAddr dest = rp.Pop<u32>();
379 const PortSet port_select(rp.Pop<u32>()); 378 const PortSet port_select(rp.Pop<u8>());
380 const u32 image_size = rp.Pop<u32>(); 379 const u32 image_size = rp.Pop<u32>();
381 const u16 trans_unit = rp.Pop<u16>(); 380 const u16 trans_unit = rp.Pop<u16>();
382 rp.PopHandle(); // Handle to destination process. not used 381 rp.PopHandle(); // Handle to destination process. not used
@@ -409,7 +408,7 @@ void SetReceiving(Service::Interface* self) {
409 408
410void IsFinishedReceiving(Service::Interface* self) { 409void IsFinishedReceiving(Service::Interface* self) {
411 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x08, 1, 0); 410 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x08, 1, 0);
412 const PortSet port_select(rp.Pop<u32>()); 411 const PortSet port_select(rp.Pop<u8>());
413 412
414 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); 413 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
415 if (port_select.IsSingle()) { 414 if (port_select.IsSingle()) {
@@ -427,7 +426,7 @@ void IsFinishedReceiving(Service::Interface* self) {
427 426
428void SetTransferLines(Service::Interface* self) { 427void SetTransferLines(Service::Interface* self) {
429 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x09, 4, 0); 428 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x09, 4, 0);
430 const PortSet port_select(rp.Pop<u32>()); 429 const PortSet port_select(rp.Pop<u8>());
431 const u16 transfer_lines = rp.Pop<u16>(); 430 const u16 transfer_lines = rp.Pop<u16>();
432 const u16 width = rp.Pop<u16>(); 431 const u16 width = rp.Pop<u16>();
433 const u16 height = rp.Pop<u16>(); 432 const u16 height = rp.Pop<u16>();
@@ -482,7 +481,7 @@ void GetMaxLines(Service::Interface* self) {
482 481
483void SetTransferBytes(Service::Interface* self) { 482void SetTransferBytes(Service::Interface* self) {
484 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x0B, 4, 0); 483 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x0B, 4, 0);
485 const PortSet port_select(rp.Pop<u32>()); 484 const PortSet port_select(rp.Pop<u8>());
486 const u16 transfer_bytes = rp.Pop<u16>(); 485 const u16 transfer_bytes = rp.Pop<u16>();
487 const u16 width = rp.Pop<u16>(); 486 const u16 width = rp.Pop<u16>();
488 const u16 height = rp.Pop<u16>(); 487 const u16 height = rp.Pop<u16>();
@@ -504,7 +503,7 @@ void SetTransferBytes(Service::Interface* self) {
504 503
505void GetTransferBytes(Service::Interface* self) { 504void GetTransferBytes(Service::Interface* self) {
506 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x0C, 1, 0); 505 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x0C, 1, 0);
507 const PortSet port_select(rp.Pop<u32>()); 506 const PortSet port_select(rp.Pop<u8>());
508 507
509 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); 508 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
510 if (port_select.IsSingle()) { 509 if (port_select.IsSingle()) {
@@ -549,7 +548,7 @@ void GetMaxBytes(Service::Interface* self) {
549 548
550void SetTrimming(Service::Interface* self) { 549void SetTrimming(Service::Interface* self) {
551 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x0E, 2, 0); 550 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x0E, 2, 0);
552 const PortSet port_select(rp.Pop<u32>()); 551 const PortSet port_select(rp.Pop<u8>());
553 const bool trim = rp.Pop<bool>(); 552 const bool trim = rp.Pop<bool>();
554 553
555 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 554 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
@@ -568,7 +567,7 @@ void SetTrimming(Service::Interface* self) {
568 567
569void IsTrimming(Service::Interface* self) { 568void IsTrimming(Service::Interface* self) {
570 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x0F, 1, 0); 569 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x0F, 1, 0);
571 const PortSet port_select(rp.Pop<u32>()); 570 const PortSet port_select(rp.Pop<u8>());
572 571
573 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); 572 IPC::RequestBuilder rb = rp.MakeBuilder(2, 0);
574 if (port_select.IsSingle()) { 573 if (port_select.IsSingle()) {
@@ -586,7 +585,7 @@ void IsTrimming(Service::Interface* self) {
586 585
587void SetTrimmingParams(Service::Interface* self) { 586void SetTrimmingParams(Service::Interface* self) {
588 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x10, 5, 0); 587 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x10, 5, 0);
589 const PortSet port_select(rp.Pop<u32>()); 588 const PortSet port_select(rp.Pop<u8>());
590 const u16 x0 = rp.Pop<u16>(); 589 const u16 x0 = rp.Pop<u16>();
591 const u16 y0 = rp.Pop<u16>(); 590 const u16 y0 = rp.Pop<u16>();
592 const u16 x1 = rp.Pop<u16>(); 591 const u16 x1 = rp.Pop<u16>();
@@ -612,7 +611,7 @@ void SetTrimmingParams(Service::Interface* self) {
612 611
613void GetTrimmingParams(Service::Interface* self) { 612void GetTrimmingParams(Service::Interface* self) {
614 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x11, 1, 0); 613 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x11, 1, 0);
615 const PortSet port_select(rp.Pop<u32>()); 614 const PortSet port_select(rp.Pop<u8>());
616 615
617 IPC::RequestBuilder rb = rp.MakeBuilder(5, 0); 616 IPC::RequestBuilder rb = rp.MakeBuilder(5, 0);
618 if (port_select.IsSingle()) { 617 if (port_select.IsSingle()) {
@@ -633,7 +632,7 @@ void GetTrimmingParams(Service::Interface* self) {
633 632
634void SetTrimmingParamsCenter(Service::Interface* self) { 633void SetTrimmingParamsCenter(Service::Interface* self) {
635 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x12, 5, 0); 634 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x12, 5, 0);
636 const PortSet port_select(rp.Pop<u32>()); 635 const PortSet port_select(rp.Pop<u8>());
637 const u16 trim_w = rp.Pop<u16>(); 636 const u16 trim_w = rp.Pop<u16>();
638 const u16 trim_h = rp.Pop<u16>(); 637 const u16 trim_h = rp.Pop<u16>();
639 const u16 cam_w = rp.Pop<u16>(); 638 const u16 cam_w = rp.Pop<u16>();
@@ -659,7 +658,7 @@ void SetTrimmingParamsCenter(Service::Interface* self) {
659 658
660void Activate(Service::Interface* self) { 659void Activate(Service::Interface* self) {
661 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x13, 1, 0); 660 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x13, 1, 0);
662 const CameraSet camera_select(rp.Pop<u32>()); 661 const CameraSet camera_select(rp.Pop<u8>());
663 662
664 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 663 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
665 if (camera_select.IsValid()) { 664 if (camera_select.IsValid()) {
@@ -698,8 +697,8 @@ void Activate(Service::Interface* self) {
698 697
699void SwitchContext(Service::Interface* self) { 698void SwitchContext(Service::Interface* self) {
700 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x14, 2, 0); 699 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x14, 2, 0);
701 const CameraSet camera_select(rp.Pop<u32>()); 700 const CameraSet camera_select(rp.Pop<u8>());
702 const ContextSet context_select(rp.Pop<u32>()); 701 const ContextSet context_select(rp.Pop<u8>());
703 702
704 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 703 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
705 if (camera_select.IsValid() && context_select.IsSingle()) { 704 if (camera_select.IsValid() && context_select.IsSingle()) {
@@ -725,9 +724,9 @@ void SwitchContext(Service::Interface* self) {
725 724
726void FlipImage(Service::Interface* self) { 725void FlipImage(Service::Interface* self) {
727 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1D, 3, 0); 726 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1D, 3, 0);
728 const CameraSet camera_select(rp.Pop<u32>()); 727 const CameraSet camera_select(rp.Pop<u8>());
729 const Flip flip = static_cast<Flip>(rp.Pop<u8>()); 728 const Flip flip = static_cast<Flip>(rp.Pop<u8>());
730 const ContextSet context_select(rp.Pop<u32>()); 729 const ContextSet context_select(rp.Pop<u8>());
731 730
732 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 731 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
733 if (camera_select.IsValid() && context_select.IsValid()) { 732 if (camera_select.IsValid() && context_select.IsValid()) {
@@ -752,7 +751,7 @@ void FlipImage(Service::Interface* self) {
752 751
753void SetDetailSize(Service::Interface* self) { 752void SetDetailSize(Service::Interface* self) {
754 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1E, 8, 0); 753 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1E, 8, 0);
755 const CameraSet camera_select(rp.Pop<u32>()); 754 const CameraSet camera_select(rp.Pop<u8>());
756 Resolution resolution; 755 Resolution resolution;
757 resolution.width = rp.Pop<u16>(); 756 resolution.width = rp.Pop<u16>();
758 resolution.height = rp.Pop<u16>(); 757 resolution.height = rp.Pop<u16>();
@@ -760,7 +759,7 @@ void SetDetailSize(Service::Interface* self) {
760 resolution.crop_y0 = rp.Pop<u16>(); 759 resolution.crop_y0 = rp.Pop<u16>();
761 resolution.crop_x1 = rp.Pop<u16>(); 760 resolution.crop_x1 = rp.Pop<u16>();
762 resolution.crop_y1 = rp.Pop<u16>(); 761 resolution.crop_y1 = rp.Pop<u16>();
763 const ContextSet context_select(rp.Pop<u32>()); 762 const ContextSet context_select(rp.Pop<u8>());
764 763
765 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 764 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
766 if (camera_select.IsValid() && context_select.IsValid()) { 765 if (camera_select.IsValid() && context_select.IsValid()) {
@@ -787,9 +786,9 @@ void SetDetailSize(Service::Interface* self) {
787 786
788void SetSize(Service::Interface* self) { 787void SetSize(Service::Interface* self) {
789 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1F, 3, 0); 788 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x1F, 3, 0);
790 const CameraSet camera_select(rp.Pop<u32>()); 789 const CameraSet camera_select(rp.Pop<u8>());
791 const u8 size = rp.Pop<u8>(); 790 const u8 size = rp.Pop<u8>();
792 const ContextSet context_select(rp.Pop<u32>()); 791 const ContextSet context_select(rp.Pop<u8>());
793 792
794 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 793 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
795 if (camera_select.IsValid() && context_select.IsValid()) { 794 if (camera_select.IsValid() && context_select.IsValid()) {
@@ -814,7 +813,7 @@ void SetSize(Service::Interface* self) {
814 813
815void SetFrameRate(Service::Interface* self) { 814void SetFrameRate(Service::Interface* self) {
816 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x20, 2, 0); 815 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x20, 2, 0);
817 const CameraSet camera_select(rp.Pop<u32>()); 816 const CameraSet camera_select(rp.Pop<u8>());
818 const FrameRate frame_rate = static_cast<FrameRate>(rp.Pop<u8>()); 817 const FrameRate frame_rate = static_cast<FrameRate>(rp.Pop<u8>());
819 818
820 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 819 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
@@ -835,9 +834,9 @@ void SetFrameRate(Service::Interface* self) {
835 834
836void SetEffect(Service::Interface* self) { 835void SetEffect(Service::Interface* self) {
837 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x22, 3, 0); 836 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x22, 3, 0);
838 const CameraSet camera_select(rp.Pop<u32>()); 837 const CameraSet camera_select(rp.Pop<u8>());
839 const Effect effect = static_cast<Effect>(rp.Pop<u8>()); 838 const Effect effect = static_cast<Effect>(rp.Pop<u8>());
840 const ContextSet context_select(rp.Pop<u32>()); 839 const ContextSet context_select(rp.Pop<u8>());
841 840
842 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 841 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
843 if (camera_select.IsValid() && context_select.IsValid()) { 842 if (camera_select.IsValid() && context_select.IsValid()) {
@@ -862,9 +861,9 @@ void SetEffect(Service::Interface* self) {
862 861
863void SetOutputFormat(Service::Interface* self) { 862void SetOutputFormat(Service::Interface* self) {
864 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x25, 3, 0); 863 IPC::RequestParser rp(Kernel::GetCommandBuffer(), 0x25, 3, 0);
865 const CameraSet camera_select(rp.Pop<u32>()); 864 const CameraSet camera_select(rp.Pop<u8>());
866 const OutputFormat format = static_cast<OutputFormat>(rp.Pop<u8>()); 865 const OutputFormat format = static_cast<OutputFormat>(rp.Pop<u8>());
867 const ContextSet context_select(rp.Pop<u32>()); 866 const ContextSet context_select(rp.Pop<u8>());
868 867
869 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 868 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
870 if (camera_select.IsValid() && context_select.IsValid()) { 869 if (camera_select.IsValid() && context_select.IsValid()) {
@@ -947,8 +946,8 @@ static void SetPackageParameter() {
947 rp.PopRaw(package); 946 rp.PopRaw(package);
948 rp.Skip(param_length - (sizeof(PackageParameterType) + 3) / 4, false); 947 rp.Skip(param_length - (sizeof(PackageParameterType) + 3) / 4, false);
949 948
950 const CameraSet camera_select(static_cast<u32>(package.camera_select)); 949 const CameraSet camera_select(package.camera_select);
951 const ContextSet context_select(static_cast<u32>(package.context_select)); 950 const ContextSet context_select(package.context_select);
952 951
953 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); 952 IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
954 if (camera_select.IsValid() && context_select.IsValid()) { 953 if (camera_select.IsValid() && context_select.IsValid()) {