1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
9 #include <linux/device.h>
10 #include <linux/dma-mapping.h>
11 #include <linux/iosys-map.h>
12 #include <linux/types.h>
14 struct tegra_ivc_header
;
21 unsigned int position
;
25 void (*notify
)(struct tegra_ivc
*ivc
, void *data
);
28 unsigned int num_frames
;
33 * tegra_ivc_read_get_next_frame - Peek at the next frame to receive
34 * @ivc pointer of the IVC channel
36 * Peek at the next frame to be received, without removing it from
39 * Returns a pointer to the frame, or an error encoded pointer.
41 int tegra_ivc_read_get_next_frame(struct tegra_ivc
*ivc
, struct iosys_map
*map
);
44 * tegra_ivc_read_advance - Advance the read queue
45 * @ivc pointer of the IVC channel
47 * Advance the read queue
49 * Returns 0, or a negative error value if failed.
51 int tegra_ivc_read_advance(struct tegra_ivc
*ivc
);
54 * tegra_ivc_write_get_next_frame - Poke at the next frame to transmit
55 * @ivc pointer of the IVC channel
57 * Get access to the next frame.
59 * Returns a pointer to the frame, or an error encoded pointer.
61 int tegra_ivc_write_get_next_frame(struct tegra_ivc
*ivc
, struct iosys_map
*map
);
64 * tegra_ivc_write_advance - Advance the write queue
65 * @ivc pointer of the IVC channel
67 * Advance the write queue
69 * Returns 0, or a negative error value if failed.
71 int tegra_ivc_write_advance(struct tegra_ivc
*ivc
);
74 * tegra_ivc_notified - handle internal messages
75 * @ivc pointer of the IVC channel
77 * This function must be called following every notification.
79 * Returns 0 if the channel is ready for communication, or -EAGAIN if a channel
80 * reset is in progress.
82 int tegra_ivc_notified(struct tegra_ivc
*ivc
);
85 * tegra_ivc_reset - initiates a reset of the shared memory state
86 * @ivc pointer of the IVC channel
88 * This function must be called after a channel is reserved before it is used
89 * for communication. The channel will be ready for use when a subsequent call
90 * to notify the remote of the channel reset.
92 void tegra_ivc_reset(struct tegra_ivc
*ivc
);
94 size_t tegra_ivc_align(size_t size
);
95 unsigned tegra_ivc_total_queue_size(unsigned queue_size
);
96 int tegra_ivc_init(struct tegra_ivc
*ivc
, struct device
*peer
, const struct iosys_map
*rx
,
97 dma_addr_t rx_phys
, const struct iosys_map
*tx
, dma_addr_t tx_phys
,
98 unsigned int num_frames
, size_t frame_size
,
99 void (*notify
)(struct tegra_ivc
*ivc
, void *data
),
101 void tegra_ivc_cleanup(struct tegra_ivc
*ivc
);
103 #endif /* __TEGRA_IVC_H */