pipe.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 vector will be returned.
  23. * @note IF `length` is set to 0, an empty vector will be returned.
  24. * @note IF `length` is greater than the amount of data available, this function will only read the available amount.
  25. * @param pipe_number a `DspPipe`
  26. * @param length the number of bytes to read. The max is 65,535 (max of u16).
  27. * @returns a vector of bytes from the specified pipe. On error, will be empty.
  28. */
  29. std::vector<u8> PipeRead(DspPipe pipe_number, u32 length);
  30. /**
  31. * How much data is left in pipe
  32. * @param pipe_number The Pipe ID
  33. * @return The amount of data remaning in the pipe. This is the maximum length PipeRead will return.
  34. */
  35. size_t GetPipeReadableSize(DspPipe pipe_number);
  36. /**
  37. * Write to a DSP pipe.
  38. * @param pipe_number The Pipe ID
  39. * @param buffer The data to write to the pipe.
  40. */
  41. void PipeWrite(DspPipe pipe_number, const std::vector<u8>& buffer);
  42. enum class DspState {
  43. Off,
  44. On,
  45. Sleeping
  46. };
  47. /// Get the state of the DSP
  48. DspState GetDspState();
  49. } // namespace HLE
  50. } // namespace DSP