ivc.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
  4. */
  5. #ifndef __TEGRA_IVC_H
  6. #define __TEGRA_IVC_H
  7. #include <linux/device.h>
  8. #include <linux/dma-mapping.h>
  9. #include <linux/iosys-map.h>
  10. #include <linux/types.h>
  11. struct tegra_ivc_header;
  12. struct tegra_ivc {
  13. struct device *peer;
  14. struct {
  15. struct iosys_map map;
  16. unsigned int position;
  17. dma_addr_t phys;
  18. } rx, tx;
  19. void (*notify)(struct tegra_ivc *ivc, void *data);
  20. void *notify_data;
  21. unsigned int num_frames;
  22. size_t frame_size;
  23. };
  24. /**
  25. * tegra_ivc_read_get_next_frame - Peek at the next frame to receive
  26. * @ivc pointer of the IVC channel
  27. *
  28. * Peek at the next frame to be received, without removing it from
  29. * the queue.
  30. *
  31. * Returns a pointer to the frame, or an error encoded pointer.
  32. */
  33. int tegra_ivc_read_get_next_frame(struct tegra_ivc *ivc, struct iosys_map *map);
  34. /**
  35. * tegra_ivc_read_advance - Advance the read queue
  36. * @ivc pointer of the IVC channel
  37. *
  38. * Advance the read queue
  39. *
  40. * Returns 0, or a negative error value if failed.
  41. */
  42. int tegra_ivc_read_advance(struct tegra_ivc *ivc);
  43. /**
  44. * tegra_ivc_write_get_next_frame - Poke at the next frame to transmit
  45. * @ivc pointer of the IVC channel
  46. *
  47. * Get access to the next frame.
  48. *
  49. * Returns a pointer to the frame, or an error encoded pointer.
  50. */
  51. int tegra_ivc_write_get_next_frame(struct tegra_ivc *ivc, struct iosys_map *map);
  52. /**
  53. * tegra_ivc_write_advance - Advance the write queue
  54. * @ivc pointer of the IVC channel
  55. *
  56. * Advance the write queue
  57. *
  58. * Returns 0, or a negative error value if failed.
  59. */
  60. int tegra_ivc_write_advance(struct tegra_ivc *ivc);
  61. /**
  62. * tegra_ivc_notified - handle internal messages
  63. * @ivc pointer of the IVC channel
  64. *
  65. * This function must be called following every notification.
  66. *
  67. * Returns 0 if the channel is ready for communication, or -EAGAIN if a channel
  68. * reset is in progress.
  69. */
  70. int tegra_ivc_notified(struct tegra_ivc *ivc);
  71. /**
  72. * tegra_ivc_reset - initiates a reset of the shared memory state
  73. * @ivc pointer of the IVC channel
  74. *
  75. * This function must be called after a channel is reserved before it is used
  76. * for communication. The channel will be ready for use when a subsequent call
  77. * to notify the remote of the channel reset.
  78. */
  79. void tegra_ivc_reset(struct tegra_ivc *ivc);
  80. size_t tegra_ivc_align(size_t size);
  81. unsigned tegra_ivc_total_queue_size(unsigned queue_size);
  82. int tegra_ivc_init(struct tegra_ivc *ivc, struct device *peer, const struct iosys_map *rx,
  83. dma_addr_t rx_phys, const struct iosys_map *tx, dma_addr_t tx_phys,
  84. unsigned int num_frames, size_t frame_size,
  85. void (*notify)(struct tegra_ivc *ivc, void *data),
  86. void *data);
  87. void tegra_ivc_cleanup(struct tegra_ivc *ivc);
  88. #endif /* __TEGRA_IVC_H */