linux/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c

// SPDX-License-Identifier: GPL-2.0
/*
 * PiSP Back End driver.
 * Copyright (c) 2021-2024 Raspberry Pi Limited.
 *
 */
#include <linux/clk.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/lockdep.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-dma-contig.h>
#include <media/videobuf2-vmalloc.h>

#include <uapi/linux/media/raspberrypi/pisp_be_config.h>

#include "pisp_be_formats.h"

/* Maximum number of config buffers possible */
#define PISP_BE_NUM_CONFIG_BUFFERS

#define PISPBE_NAME

/* Some ISP-BE registers */
#define PISP_BE_VERSION_REG
#define PISP_BE_CONTROL_REG
#define PISP_BE_CONTROL_COPY_CONFIG
#define PISP_BE_CONTROL_QUEUE_JOB
#define PISP_BE_CONTROL_NUM_TILES(n)
#define PISP_BE_TILE_ADDR_LO_REG
#define PISP_BE_TILE_ADDR_HI_REG
#define PISP_BE_STATUS_REG
#define PISP_BE_STATUS_QUEUED
#define PISP_BE_BATCH_STATUS_REG
#define PISP_BE_INTERRUPT_EN_REG
#define PISP_BE_INTERRUPT_STATUS_REG
#define PISP_BE_AXI_REG
#define PISP_BE_CONFIG_BASE_REG
#define PISP_BE_IO_ADDR_LOW(n)
#define PISP_BE_IO_ADDR_HIGH(n)
#define PISP_BE_GLOBAL_BAYER_ENABLE
#define PISP_BE_GLOBAL_RGB_ENABLE
#define N_HW_ADDRESSES
#define N_HW_ENABLES

#define PISP_BE_VERSION_2712
#define PISP_BE_VERSION_MINOR_BITS

/*
 * This maps our nodes onto the inputs/outputs of the actual PiSP Back End.
 * Be wary of the word "OUTPUT" which is used ambiguously here. In a V4L2
 * context it means an input to the hardware (source image or metadata).
 * Elsewhere it means an output from the hardware.
 */
enum pispbe_node_ids {};

struct pispbe_node_description {};

static const struct pispbe_node_description node_desc[PISPBE_NUM_NODES] =;

#define NODE_DESC_IS_OUTPUT(desc)

#define NODE_IS_META(node)
#define NODE_IS_OUTPUT(node)
#define NODE_IS_CAPTURE(node)
#define NODE_IS_MPLANE(node)

/*
 * Structure to describe a single node /dev/video<N> which represents a single
 * input or output queue to the PiSP Back End device.
 */
struct pispbe_node {};

/* For logging only, use the entity name with "pispbe" and separator removed */
#define NODE_NAME(node)

/* Records details of the jobs currently running or queued on the h/w. */
struct pispbe_job {};

struct pispbe_hw_enables {};

/* Records a job configuration and memory addresses. */
struct pispbe_job_descriptor {};

/*
 * Structure representing the entire PiSP Back End device, comprising several
 * nodes which share platform resources and a mutex for the actual HW.
 */
struct pispbe_dev {};

static u32 pispbe_rd(struct pispbe_dev *pispbe, unsigned int offset)
{}

static void pispbe_wr(struct pispbe_dev *pispbe, unsigned int offset, u32 val)
{}

/*
 * Queue a job to the h/w. If the h/w is idle it will begin immediately.
 * Caller must ensure it is "safe to queue", i.e. we don't already have a
 * queued, unstarted job.
 */
static void pispbe_queue_job(struct pispbe_dev *pispbe,
			     struct pispbe_job_descriptor *job)
{}

struct pispbe_buffer {};

static int pispbe_get_planes_addr(dma_addr_t addr[3], struct pispbe_buffer *buf,
				  struct pispbe_node *node)
{}

static dma_addr_t pispbe_get_addr(struct pispbe_buffer *buf)
{}

static void pispbe_xlate_addrs(struct pispbe_dev *pispbe,
			       struct pispbe_job_descriptor *job,
			       struct pispbe_buffer *buf[PISPBE_NUM_NODES])
{}

/*
 * Prepare a job description to be submitted to the HW.
 *
 * To schedule a job, we need all streaming nodes (apart from Output0,
 * Output1, Tdn and Stitch) to have a buffer ready, which must
 * include at least a config buffer and a main input image.
 *
 * For Output0, Output1, Tdn and Stitch, a buffer only needs to be
 * available if the blocks are enabled in the config.
 *
 * Needs to be called with hw_lock held.
 *
 * Returns 0 if a job has been successfully prepared, < 0 otherwise.
 */
static int pispbe_prepare_job(struct pispbe_dev *pispbe,
			      struct pispbe_job_descriptor *job)
{}

static void pispbe_schedule(struct pispbe_dev *pispbe, bool clear_hw_busy)
{}

static void pispbe_isr_jobdone(struct pispbe_dev *pispbe,
			       struct pispbe_job *job)
{}

static irqreturn_t pispbe_isr(int irq, void *dev)
{}

static int pisp_be_validate_config(struct pispbe_dev *pispbe,
				   struct pisp_be_tiles_config *config)
{}

static int pispbe_node_queue_setup(struct vb2_queue *q, unsigned int *nbuffers,
				   unsigned int *nplanes, unsigned int sizes[],
				   struct device *alloc_devs[])
{}

static int pispbe_node_buffer_prepare(struct vb2_buffer *vb)
{}

static void pispbe_node_buffer_queue(struct vb2_buffer *buf)
{}

static int pispbe_node_start_streaming(struct vb2_queue *q, unsigned int count)
{}

static void pispbe_node_stop_streaming(struct vb2_queue *q)
{}

static const struct vb2_ops pispbe_node_queue_ops =;

static const struct v4l2_file_operations pispbe_fops =;

static int pispbe_node_querycap(struct file *file, void *priv,
				struct v4l2_capability *cap)
{}

static int pispbe_node_g_fmt_vid_cap(struct file *file, void *priv,
				     struct v4l2_format *f)
{}

static int pispbe_node_g_fmt_vid_out(struct file *file, void *priv,
				     struct v4l2_format *f)
{}

static int pispbe_node_g_fmt_meta_out(struct file *file, void *priv,
				      struct v4l2_format *f)
{}

static const struct pisp_be_format *pispbe_find_fmt(unsigned int fourcc)
{}

static void pispbe_set_plane_params(struct v4l2_format *f,
				    const struct pisp_be_format *fmt)
{}

static void pispbe_try_format(struct v4l2_format *f, struct pispbe_node *node)
{}

static int pispbe_node_try_fmt_vid_cap(struct file *file, void *priv,
				       struct v4l2_format *f)
{}

static int pispbe_node_try_fmt_vid_out(struct file *file, void *priv,
				       struct v4l2_format *f)
{}

static int pispbe_node_try_fmt_meta_out(struct file *file, void *priv,
					struct v4l2_format *f)
{}

static int pispbe_node_s_fmt_vid_cap(struct file *file, void *priv,
				     struct v4l2_format *f)
{}

static int pispbe_node_s_fmt_vid_out(struct file *file, void *priv,
				     struct v4l2_format *f)
{}

static int pispbe_node_s_fmt_meta_out(struct file *file, void *priv,
				      struct v4l2_format *f)
{}

static int pispbe_node_enum_fmt(struct file *file, void  *priv,
				struct v4l2_fmtdesc *f)
{}

static int pispbe_enum_framesizes(struct file *file, void *priv,
				  struct v4l2_frmsizeenum *fsize)
{}

static const struct v4l2_ioctl_ops pispbe_node_ioctl_ops =;

static const struct video_device pispbe_videodev =;

static void pispbe_node_def_fmt(struct pispbe_node *node)
{}

/*
 * Initialise a struct pispbe_node and register it as /dev/video<N>
 * to represent one of the PiSP Back End's input or output streams.
 */
static int pispbe_init_node(struct pispbe_dev *pispbe, unsigned int id)
{}

static const struct v4l2_subdev_pad_ops pispbe_pad_ops =;

static const struct v4l2_subdev_ops pispbe_sd_ops =;

static int pispbe_init_subdev(struct pispbe_dev *pispbe)
{}

static int pispbe_init_devices(struct pispbe_dev *pispbe)
{}

static void pispbe_destroy_devices(struct pispbe_dev *pispbe)
{}

static int pispbe_runtime_suspend(struct device *dev)
{}

static int pispbe_runtime_resume(struct device *dev)
{}

static int pispbe_hw_init(struct pispbe_dev *pispbe)
{}

/* Probe the ISP-BE hardware block, as a single platform device. */
static int pispbe_probe(struct platform_device *pdev)
{}

static void pispbe_remove(struct platform_device *pdev)
{}

static const struct dev_pm_ops pispbe_pm_ops =;

static const struct of_device_id pispbe_of_match[] =;
MODULE_DEVICE_TABLE(of, pispbe_of_match);

static struct platform_driver pispbe_pdrv =;

module_platform_driver();

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_LICENSE();