linux/drivers/media/platform/ti/cal/cal.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * TI Camera Access Layer (CAL)
 *
 * Copyright (c) 2015-2020 Texas Instruments Inc.
 *
 * Authors:
 *	Benoit Parrot <[email protected]>
 *	Laurent Pinchart <[email protected]>
 */
#ifndef __TI_CAL_H__
#define __TI_CAL_H__

#include <linux/bitfield.h>
#include <linux/io.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
#include <linux/videodev2.h>
#include <linux/wait.h>

#include <media/media-device.h>
#include <media/v4l2-async.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-device.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-subdev.h>
#include <media/videobuf2-v4l2.h>

#define CAL_MODULE_NAME
#define CAL_MAX_NUM_CONTEXT
#define CAL_NUM_CSI2_PORTS

/*
 * The width is limited by the size of the CAL_WR_DMA_XSIZE_j.XSIZE field,
 * expressed in multiples of 64 bits. The height is limited by the size of the
 * CAL_CSI2_CTXi_j.CTXi_LINES and CAL_WR_DMA_CTRL_j.YSIZE fields, expressed in
 * lines.
 */
#define CAL_MIN_WIDTH_BYTES
#define CAL_MAX_WIDTH_BYTES
#define CAL_MIN_HEIGHT_LINES
#define CAL_MAX_HEIGHT_LINES

#define CAL_CAMERARX_PAD_SINK
#define CAL_CAMERARX_PAD_FIRST_SOURCE
#define CAL_CAMERARX_NUM_SOURCE_PADS
#define CAL_CAMERARX_NUM_PADS

static inline bool cal_rx_pad_is_sink(u32 pad)
{}

static inline bool cal_rx_pad_is_source(u32 pad)
{}

struct device;
struct device_node;
struct resource;
struct regmap;
struct regmap_fied;

/* CTRL_CORE_CAMERRX_CONTROL register field id */
enum cal_camerarx_field {};

enum cal_dma_state {};

struct cal_format_info {};

/* buffer for one video frame */
struct cal_buffer {};

/**
 * struct cal_dmaqueue - Queue of DMA buffers
 */
struct cal_dmaqueue {};

struct cal_camerarx_data {};

struct cal_data {};

/*
 * The Camera Adaptation Layer (CAL) module is paired with one or more complex
 * I/O PHYs (CAMERARX). It contains multiple instances of CSI-2, processing and
 * DMA contexts.
 *
 * The cal_dev structure represents the whole subsystem, including the CAL and
 * the CAMERARX instances. Instances of struct cal_dev are named cal through the
 * driver.
 *
 * The cal_camerarx structure represents one CAMERARX instance. Instances of
 * cal_camerarx are named phy through the driver.
 *
 * The cal_ctx structure represents the combination of one CSI-2 context, one
 * processing context and one DMA context. Instance of struct cal_ctx are named
 * ctx through the driver.
 */

struct cal_camerarx {};

struct cal_dev {};

/*
 * There is one cal_ctx structure for each camera core context.
 */
struct cal_ctx {};

extern unsigned int cal_debug;
extern int cal_video_nr;
extern bool cal_mc_api;

#define cal_dbg(level, cal, fmt, arg...)
#define cal_info(cal, fmt, arg...)
#define cal_err(cal, fmt, arg...)

#define ctx_dbg(level, ctx, fmt, arg...)
#define ctx_info(ctx, fmt, arg...)
#define ctx_err(ctx, fmt, arg...)

#define phy_dbg(level, phy, fmt, arg...)
#define phy_info(phy, fmt, arg...)
#define phy_err(phy, fmt, arg...)

static inline u32 cal_read(struct cal_dev *cal, u32 offset)
{}

static inline void cal_write(struct cal_dev *cal, u32 offset, u32 val)
{}

static __always_inline u32 cal_read_field(struct cal_dev *cal, u32 offset, u32 mask)
{}

static inline void cal_write_field(struct cal_dev *cal, u32 offset, u32 value,
				   u32 mask)
{}

static inline void cal_set_field(u32 *valp, u32 field, u32 mask)
{}

extern const struct cal_format_info cal_formats[];
extern const unsigned int cal_num_formats;
const struct cal_format_info *cal_format_by_fourcc(u32 fourcc);
const struct cal_format_info *cal_format_by_code(u32 code);

void cal_quickdump_regs(struct cal_dev *cal);

void cal_camerarx_disable(struct cal_camerarx *phy);
void cal_camerarx_i913_errata(struct cal_camerarx *phy);
struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,
					 unsigned int instance);
void cal_camerarx_destroy(struct cal_camerarx *phy);

int cal_ctx_prepare(struct cal_ctx *ctx);
void cal_ctx_unprepare(struct cal_ctx *ctx);
void cal_ctx_set_dma_addr(struct cal_ctx *ctx, dma_addr_t addr);
void cal_ctx_start(struct cal_ctx *ctx);
void cal_ctx_stop(struct cal_ctx *ctx);

int cal_ctx_v4l2_register(struct cal_ctx *ctx);
void cal_ctx_v4l2_unregister(struct cal_ctx *ctx);
int cal_ctx_v4l2_init(struct cal_ctx *ctx);
void cal_ctx_v4l2_cleanup(struct cal_ctx *ctx);

#endif /* __TI_CAL_H__ */