drivers/staging/media/atomisp/pci/base/circbuf/interface/ia_css_circbuf_desc.h

Source file repositories/reference/linux-study-clean/drivers/staging/media/atomisp/pci/base/circbuf/interface/ia_css_circbuf_desc.h

File Facts

System
Linux kernel
Corpus path
drivers/staging/media/atomisp/pci/base/circbuf/interface/ia_css_circbuf_desc.h
Extension
.h
Size
3722 bytes
Lines
161
Domain
Driver Families
Bucket
drivers/staging
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

#ifndef _IA_CSS_CIRCBUF_DESC_H_
#define _IA_CSS_CIRCBUF_DESC_H_

#include <type_support.h>
#include <math_support.h>
#include <platform_support.h>
#include <sp.h>
#include "ia_css_circbuf_comm.h"
/****************************************************************
 *
 * Inline functions.
 *
 ****************************************************************/
/**
 * @brief Test if the circular buffer is empty.
 *
 * @param cb_desc The pointer to the circular buffer descriptor.
 *
 * @return
 *	- true when it is empty.
 *	- false when it is not empty.
 */
static inline bool ia_css_circbuf_desc_is_empty(
    ia_css_circbuf_desc_t *cb_desc)
{
	OP___assert(cb_desc);
	return (cb_desc->end == cb_desc->start);
}

/**
 * @brief Test if the circular buffer descriptor is full.
 *
 * @param cb_desc	The pointer to the circular buffer
 *			descriptor.
 *
 * @return
 *	- true when it is full.
 *	- false when it is not full.
 */
static inline bool ia_css_circbuf_desc_is_full(
    ia_css_circbuf_desc_t *cb_desc)
{
	OP___assert(cb_desc);
	return ((cb_desc->end + 1) % cb_desc->size) == cb_desc->start;
}

/**
 * @brief Initialize the circular buffer descriptor
 *
 * @param cb_desc	The pointer circular buffer descriptor
 * @param size		The size of the circular buffer
 */
static inline void ia_css_circbuf_desc_init(
    ia_css_circbuf_desc_t *cb_desc,
    int8_t size)
{
	OP___assert(cb_desc);
	cb_desc->size = size;
}

/**
 * @brief Get a position in the circular buffer descriptor.
 *
 * @param cb     The pointer to the circular buffer descriptor.
 * @param base   The base position.
 * @param offset The offset.
 *
 * @return the position in the circular buffer descriptor.
 */
static inline uint8_t ia_css_circbuf_desc_get_pos_at_offset(
    ia_css_circbuf_desc_t *cb_desc,
    u32 base,
    int offset)
{
	OP___assert(cb_desc);
	OP___assert(cb_desc->size > 0);

	/* step 1: adjust the offset  */
	while (offset < 0)
		offset += cb_desc->size;

	/* step 2: shift and round by the upper limit */
	return (base + offset) % cb_desc->size;
}

/**
 * @brief Get the offset between two positions in the circular buffer
 * descriptor.
 * Get the offset from the source position to the terminal position,
 * along the direction in which the new elements come in.

Annotation

Implementation Notes