linux/drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * TI CSI2RX Shim Wrapper Driver
 *
 * Copyright (C) 2023 Texas Instruments Incorporated - https://www.ti.com/
 *
 * Author: Pratyush Yadav <[email protected]>
 * Author: Jai Luthra <[email protected]>
 */

#include <linux/bitfield.h>
#include <linux/dmaengine.h>
#include <linux/module.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>

#include <media/mipi-csi2.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-mc.h>
#include <media/videobuf2-dma-contig.h>

#define TI_CSI2RX_MODULE_NAME

#define SHIM_CNTL
#define SHIM_CNTL_PIX_RST

#define SHIM_DMACNTX
#define SHIM_DMACNTX_EN
#define SHIM_DMACNTX_YUV422
#define SHIM_DMACNTX_SIZE
#define SHIM_DMACNTX_FMT
#define SHIM_DMACNTX_YUV422_MODE_11
#define SHIM_DMACNTX_SIZE_8
#define SHIM_DMACNTX_SIZE_16
#define SHIM_DMACNTX_SIZE_32

#define SHIM_PSI_CFG0
#define SHIM_PSI_CFG0_SRC_TAG
#define SHIM_PSI_CFG0_DST_TAG

#define PSIL_WORD_SIZE_BYTES
/*
 * There are no hard limits on the width or height. The DMA engine can handle
 * all sizes. The max width and height are arbitrary numbers for this driver.
 * Use 16K * 16K as the arbitrary limit. It is large enough that it is unlikely
 * the limit will be hit in practice.
 */
#define MAX_WIDTH_BYTES
#define MAX_HEIGHT_LINES

#define DRAIN_TIMEOUT_MS
#define DRAIN_BUFFER_SIZE

struct ti_csi2rx_fmt {};

struct ti_csi2rx_buffer {};

enum ti_csi2rx_dma_state {};

struct ti_csi2rx_dma {};

struct ti_csi2rx_dev {};

static const struct ti_csi2rx_fmt ti_csi2rx_formats[] =;

/* Forward declaration needed by ti_csi2rx_dma_callback. */
static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *csi,
			       struct ti_csi2rx_buffer *buf);

static const struct ti_csi2rx_fmt *find_format_by_fourcc(u32 pixelformat)
{}

static const struct ti_csi2rx_fmt *find_format_by_code(u32 code)
{}

static void ti_csi2rx_fill_fmt(const struct ti_csi2rx_fmt *csi_fmt,
			       struct v4l2_format *v4l2_fmt)
{}

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

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

static int ti_csi2rx_g_fmt_vid_cap(struct file *file, void *prov,
				   struct v4l2_format *f)
{}

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

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

static int ti_csi2rx_enum_framesizes(struct file *file, void *fh,
				     struct v4l2_frmsizeenum *fsize)
{}

static const struct v4l2_ioctl_ops csi_ioctl_ops =;

static const struct v4l2_file_operations csi_fops =;

static int csi_async_notifier_bound(struct v4l2_async_notifier *notifier,
				    struct v4l2_subdev *subdev,
				    struct v4l2_async_connection *asc)
{}

static int csi_async_notifier_complete(struct v4l2_async_notifier *notifier)
{}

static const struct v4l2_async_notifier_operations csi_async_notifier_ops =;

static int ti_csi2rx_notifier_register(struct ti_csi2rx_dev *csi)
{}

static void ti_csi2rx_setup_shim(struct ti_csi2rx_dev *csi)
{}

static void ti_csi2rx_drain_callback(void *param)
{}

/*
 * Drain the stale data left at the PSI-L endpoint.
 *
 * This might happen if no buffers are queued in time but source is still
 * streaming. In multi-stream scenarios this can happen when one stream is
 * stopped but other is still streaming, and thus module-level pixel reset is
 * not asserted.
 *
 * To prevent that stale data corrupting the subsequent transactions, it is
 * required to issue DMA requests to drain it out.
 */
static int ti_csi2rx_drain_dma(struct ti_csi2rx_dev *csi)
{}

static void ti_csi2rx_dma_callback(void *param)
{}

static int ti_csi2rx_start_dma(struct ti_csi2rx_dev *csi,
			       struct ti_csi2rx_buffer *buf)
{}

static void ti_csi2rx_stop_dma(struct ti_csi2rx_dev *csi)
{}

static void ti_csi2rx_cleanup_buffers(struct ti_csi2rx_dev *csi,
				      enum vb2_buffer_state state)
{}

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

static int ti_csi2rx_buffer_prepare(struct vb2_buffer *vb)
{}

static void ti_csi2rx_buffer_queue(struct vb2_buffer *vb)
{}

static int ti_csi2rx_start_streaming(struct vb2_queue *vq, unsigned int count)
{}

static void ti_csi2rx_stop_streaming(struct vb2_queue *vq)
{}

static const struct vb2_ops csi_vb2_qops =;

static int ti_csi2rx_init_vb2q(struct ti_csi2rx_dev *csi)
{}

static int ti_csi2rx_link_validate(struct media_link *link)
{}

static const struct media_entity_operations ti_csi2rx_video_entity_ops =;

static int ti_csi2rx_init_dma(struct ti_csi2rx_dev *csi)
{}

static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi)
{}

static void ti_csi2rx_cleanup_dma(struct ti_csi2rx_dev *csi)
{}

static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi)
{}

static void ti_csi2rx_cleanup_subdev(struct ti_csi2rx_dev *csi)
{}

static void ti_csi2rx_cleanup_vb2q(struct ti_csi2rx_dev *csi)
{}

static int ti_csi2rx_probe(struct platform_device *pdev)
{}

static void ti_csi2rx_remove(struct platform_device *pdev)
{}

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

static struct platform_driver ti_csi2rx_pdrv =;

module_platform_driver();

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