pipe.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <cstddef>
  6. #include <vector>
  7. #include "common/common_types.h"
  8. namespace DSP {
  9. namespace HLE {
  10. /// Reset the pipes by setting pipe positions back to the beginning.
  11. void ResetPipes();
  12. enum class DspPipe {
  13. Debug = 0,
  14. Dma = 1,
  15. Audio = 2,
  16. Binary = 3,
  17. };
  18. constexpr size_t NUM_DSP_PIPE = 8;
  19. /**
  20. * Reads `length` bytes from the DSP pipe identified with `pipe_number`.
  21. * @note Can read up to the maximum value of a u16 in bytes (65,535).
  22. * @note IF an error is encoutered with either an invalid `pipe_number` or `length` value, an empty
  23. * vector will be returned.
  24. * @note IF `length` is set to 0, an empty vector will be returned.
  25. * @note IF `length` is greater than the amount of data available, this function will only read the
  26. * available amount.
  27. * @param pipe_number a `DspPipe`
  28. * @param length the number of bytes to read. The max is 65,535 (max of u16).
  29. * @returns a vector of bytes from the specified pipe. On error, will be empty.
  30. */
  31. std::vector<u8> PipeRead(DspPipe pipe_number, u32 length);
  32. /**
  33. * How much data is left in pipe
  34. * @param pipe_number The Pipe ID
  35. * @return The amount of data remaning in the pipe. This is the maximum length PipeRead will return.
  36. */
  37. size_t GetPipeReadableSize(DspPipe pipe_number);
  38. /**
  39. * Write to a DSP pipe.
  40. * @param pipe_number The Pipe ID
  41. * @param buffer The data to write to the pipe.
  42. */
  43. void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer);
  44. enum class DspState {
  45. Off,
  46. On,
  47. Sleeping,
  48. };
  49. /// Get the state of the DSP
  50. DspState GetDspState();
  51. } // namespace HLE
  52. } // namespace DSP