ivc.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. */
  13. #ifndef __TEGRA_IVC_H
  14. #include <linux/device.h>
  15. #include <linux/dma-mapping.h>
  16. #include <linux/types.h>
  17. struct tegra_ivc_header;
  18. struct tegra_ivc {
  19. struct device *peer;
  20. struct {
  21. struct tegra_ivc_header *channel;
  22. unsigned int position;
  23. dma_addr_t phys;
  24. } rx, tx;
  25. void (*notify)(struct tegra_ivc *ivc, void *data);
  26. void *notify_data;
  27. unsigned int num_frames;
  28. size_t frame_size;
  29. };
  30. /**
  31. * tegra_ivc_read_get_next_frame - Peek at the next frame to receive
  32. * @ivc pointer of the IVC channel
  33. *
  34. * Peek at the next frame to be received, without removing it from
  35. * the queue.
  36. *
  37. * Returns a pointer to the frame, or an error encoded pointer.
  38. */
  39. void *tegra_ivc_read_get_next_frame(struct tegra_ivc *ivc);
  40. /**
  41. * tegra_ivc_read_advance - Advance the read queue
  42. * @ivc pointer of the IVC channel
  43. *
  44. * Advance the read queue
  45. *
  46. * Returns 0, or a negative error value if failed.
  47. */
  48. int tegra_ivc_read_advance(struct tegra_ivc *ivc);
  49. /**
  50. * tegra_ivc_write_get_next_frame - Poke at the next frame to transmit
  51. * @ivc pointer of the IVC channel
  52. *
  53. * Get access to the next frame.
  54. *
  55. * Returns a pointer to the frame, or an error encoded pointer.
  56. */
  57. void *tegra_ivc_write_get_next_frame(struct tegra_ivc *ivc);
  58. /**
  59. * tegra_ivc_write_advance - Advance the write queue
  60. * @ivc pointer of the IVC channel
  61. *
  62. * Advance the write queue
  63. *
  64. * Returns 0, or a negative error value if failed.
  65. */
  66. int tegra_ivc_write_advance(struct tegra_ivc *ivc);
  67. /**
  68. * tegra_ivc_notified - handle internal messages
  69. * @ivc pointer of the IVC channel
  70. *
  71. * This function must be called following every notification.
  72. *
  73. * Returns 0 if the channel is ready for communication, or -EAGAIN if a channel
  74. * reset is in progress.
  75. */
  76. int tegra_ivc_notified(struct tegra_ivc *ivc);
  77. /**
  78. * tegra_ivc_reset - initiates a reset of the shared memory state
  79. * @ivc pointer of the IVC channel
  80. *
  81. * This function must be called after a channel is reserved before it is used
  82. * for communication. The channel will be ready for use when a subsequent call
  83. * to notify the remote of the channel reset.
  84. */
  85. void tegra_ivc_reset(struct tegra_ivc *ivc);
  86. size_t tegra_ivc_align(size_t size);
  87. unsigned tegra_ivc_total_queue_size(unsigned queue_size);
  88. int tegra_ivc_init(struct tegra_ivc *ivc, struct device *peer, void *rx,
  89. dma_addr_t rx_phys, void *tx, dma_addr_t tx_phys,
  90. unsigned int num_frames, size_t frame_size,
  91. void (*notify)(struct tegra_ivc *ivc, void *data),
  92. void *data);
  93. void tegra_ivc_cleanup(struct tegra_ivc *ivc);
  94. #endif /* __TEGRA_IVC_H */