libcamera: byte_stream_buffer: Add Span<> support

Add support to write and read a Span<> to and from the ByteStreamBuffer
class.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Jacopo Mondi
2020-01-13 13:40:46 +01:00
committed by Laurent Pinchart
parent 34fc1f38bd
commit 8a1f0321dc
2 changed files with 35 additions and 0 deletions

View File

@@ -232,6 +232,15 @@ int ByteStreamBuffer::skip(size_t size)
* \retval -ENOSPC no more space is available in the managed memory buffer
*/
/**
* \fn template<typename T> int ByteStreamBuffer::read(const Span<T> &data)
* \brief Read data from the managed memory buffer into Span \a data
* \param[out] data Span representing the destination memory
* \return 0 on success, a negative error code otherwise
* \retval -EACCES attempting to read from a write buffer
* \retval -ENOSPC no more space is available in the managed memory buffer
*/
/**
* \fn template<typename T> int ByteStreamBuffer::write(const T *t)
* \brief Write \a t to the managed memory buffer
@@ -241,6 +250,15 @@ int ByteStreamBuffer::skip(size_t size)
* \retval -ENOSPC no more space is available in the managed memory buffer
*/
/**
* \fn template<typename T> int ByteStreamBuffer::write(const Span<T> &data)
* \brief Write \a data to the managed memory buffer
* \param[in] data The data to write to memory
* \return 0 on success, a negative error code otherwise
* \retval -EACCES attempting to write to a read buffer
* \retval -ENOSPC no more space is available in the managed memory buffer
*/
int ByteStreamBuffer::read(uint8_t *data, size_t size)
{
if (!read_)