linux/drivers/staging/media/ipu3/ipu3-css.c

// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2018 Intel Corporation

#include <linux/device.h>
#include <linux/iopoll.h>
#include <linux/slab.h>

#include "ipu3.h"
#include "ipu3-css.h"
#include "ipu3-css-fw.h"
#include "ipu3-css-params.h"
#include "ipu3-dmamap.h"
#include "ipu3-tables.h"

/* IRQ configuration */
#define IMGU_IRQCTRL_IRQ_MASK

#define IPU3_CSS_FORMAT_BPP_DEN

/* Some sane limits for resolutions */
#define IPU3_CSS_MIN_RES
#define IPU3_CSS_MAX_H
#define IPU3_CSS_MAX_W

/* minimal envelope size(GDC in - out) should be 4 */
#define MIN_ENVELOPE

/*
 * pre-allocated buffer size for CSS ABI, auxiliary frames
 * after BDS and before GDC. Those values should be tuned
 * to big enough to avoid buffer re-allocation when
 * streaming to lower streaming latency.
 */
#define CSS_ABI_SIZE
#define CSS_BDS_SIZE
#define CSS_GDC_SIZE

#define IPU3_CSS_QUEUE_TO_FLAGS(q)
#define IPU3_CSS_FORMAT_FL_IN
#define IPU3_CSS_FORMAT_FL_OUT
#define IPU3_CSS_FORMAT_FL_VF

/* Formats supported by IPU3 Camera Sub System */
static const struct imgu_css_format imgu_css_formats[] =;

static const struct {} imgu_css_queues[IPU3_CSS_QUEUES] =;

/* Initialize queue based on given format, adjust format as needed */
static int imgu_css_queue_init(struct imgu_css_queue *queue,
			       struct v4l2_pix_format_mplane *fmt, u32 flags)
{}

static bool imgu_css_queue_enabled(struct imgu_css_queue *q)
{}

/******************* css hw *******************/

/* In the style of writesl() defined in include/asm-generic/io.h */
static inline void writes(const void *mem, ssize_t count, void __iomem *addr)
{}

/* Wait until register `reg', masked with `mask', becomes `cmp' */
static int imgu_hw_wait(void __iomem *base, int reg, u32 mask, u32 cmp)
{}

/* Initialize the IPU3 CSS hardware and associated h/w blocks */

int imgu_css_set_powerup(struct device *dev, void __iomem *base,
			 unsigned int freq)
{}

void imgu_css_set_powerdown(struct device *dev, void __iomem *base)
{}

static void imgu_css_hw_enable_irq(struct imgu_css *css)
{}

static int imgu_css_hw_init(struct imgu_css *css)
{}

/* Boot the given IPU3 CSS SP */
static int imgu_css_hw_start_sp(struct imgu_css *css, int sp)
{}

/* Start the IPU3 CSS ImgU (Imaging Unit) and all the SPs */
static int imgu_css_hw_start(struct imgu_css *css)
{}

static void imgu_css_hw_stop(struct imgu_css *css)
{}

static void imgu_css_hw_cleanup(struct imgu_css *css)
{}

static void imgu_css_pipeline_cleanup(struct imgu_css *css, unsigned int pipe)
{}

/*
 * This function initializes various stages of the
 * IPU3 CSS ISP pipeline
 */
static int imgu_css_pipeline_init(struct imgu_css *css, unsigned int pipe)
{}

static u8 imgu_css_queue_pos(struct imgu_css *css, int queue, int thread)
{}

/* Sent data to sp using given buffer queue, or if queue < 0, event queue. */
static int imgu_css_queue_data(struct imgu_css *css,
			       int queue, int thread, u32 data)
{}

/* Receive data using given buffer queue, or if queue < 0, event queue. */
static int imgu_css_dequeue_data(struct imgu_css *css, int queue, u32 *data)
{}

/* Free binary-specific resources */
static void imgu_css_binary_cleanup(struct imgu_css *css, unsigned int pipe)
{}

static int imgu_css_binary_preallocate(struct imgu_css *css, unsigned int pipe)
{}

/* allocate binary-specific resources */
static int imgu_css_binary_setup(struct imgu_css *css, unsigned int pipe)
{}

int imgu_css_start_streaming(struct imgu_css *css)
{}

void imgu_css_stop_streaming(struct imgu_css *css)
{}

bool imgu_css_pipe_queue_empty(struct imgu_css *css, unsigned int pipe)
{}

bool imgu_css_queue_empty(struct imgu_css *css)
{}

bool imgu_css_is_streaming(struct imgu_css *css)
{}

static int imgu_css_map_init(struct imgu_css *css, unsigned int pipe)
{}

static void imgu_css_pipe_cleanup(struct imgu_css *css, unsigned int pipe)
{}

void imgu_css_cleanup(struct imgu_css *css)
{}

int imgu_css_init(struct device *dev, struct imgu_css *css,
		  void __iomem *base, int length)
{}

static u32 imgu_css_adjust(u32 res, u32 align)
{}

/* Select a binary matching the required resolutions and formats */
static int imgu_css_find_binary(struct imgu_css *css,
				unsigned int pipe,
				struct imgu_css_queue queue[IPU3_CSS_QUEUES],
				struct v4l2_rect rects[IPU3_CSS_RECTS])
{}

/*
 * Check that there is a binary matching requirements. Parameters may be
 * NULL indicating disabled input/output. Return negative if given
 * parameters can not be supported or on error, zero or positive indicating
 * found binary number. May modify the given parameters if not exact match
 * is found.
 */
int imgu_css_fmt_try(struct imgu_css *css,
		     struct v4l2_pix_format_mplane *fmts[IPU3_CSS_QUEUES],
		     struct v4l2_rect *rects[IPU3_CSS_RECTS],
		     unsigned int pipe)
{}

int imgu_css_fmt_set(struct imgu_css *css,
		     struct v4l2_pix_format_mplane *fmts[IPU3_CSS_QUEUES],
		     struct v4l2_rect *rects[IPU3_CSS_RECTS],
		     unsigned int pipe)
{}

int imgu_css_meta_fmt_set(struct v4l2_meta_format *fmt)
{}

/*
 * Queue given buffer to CSS. imgu_css_buf_prepare() must have been first
 * called for the buffer. May be called from interrupt context.
 * Returns 0 on success, -EBUSY if the buffer queue is full, or some other
 * code on error conditions.
 */
int imgu_css_buf_queue(struct imgu_css *css, unsigned int pipe,
		       struct imgu_css_buffer *b)
{}

/*
 * Get next ready CSS buffer. Returns -EAGAIN in which case the function
 * should be called again, or -EBUSY which means that there are no more
 * buffers available. May be called from interrupt context.
 */
struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css)
{}

/*
 * Get a new set of parameters from pool and initialize them based on
 * the parameters params, gdc, and obgrid. Any of these may be NULL,
 * in which case the previously set parameters are used.
 * If parameters haven't been set previously, initialize from scratch.
 *
 * Return index to css->parameter_set_info which has the newly created
 * parameters or negative value on error.
 */
int imgu_css_set_parameters(struct imgu_css *css, unsigned int pipe,
			    struct ipu3_uapi_params *set_params)
{}

int imgu_css_irq_ack(struct imgu_css *css)
{}