linux/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Rockchip ISP1 Driver - V4l capture device
 *
 * Copyright (C) 2019 Collabora, Ltd.
 *
 * Based on Rockchip ISP1 driver by Rockchip Electronics Co., Ltd.
 * Copyright (C) 2017 Rockchip Electronics Co., Ltd.
 */

#include <linux/delay.h>
#include <linux/pm_runtime.h>
#include <media/v4l2-common.h>
#include <media/v4l2-event.h>
#include <media/v4l2-fh.h>
#include <media/v4l2-ioctl.h>
#include <media/v4l2-mc.h>
#include <media/v4l2-subdev.h>
#include <media/videobuf2-dma-contig.h>

#include "rkisp1-common.h"

/*
 * NOTE: There are two capture video devices in rkisp1, selfpath and mainpath.
 *
 * differences between selfpath and mainpath
 * available mp sink input: isp
 * available sp sink input : isp, dma(TODO)
 * available mp sink pad fmts: yuv422, raw
 * available sp sink pad fmts: yuv422, yuv420......
 * available mp source fmts: yuv, raw, jpeg(TODO)
 * available sp source fmts: yuv, rgb
 */

#define RKISP1_SP_DEV_NAME
#define RKISP1_MP_DEV_NAME

#define RKISP1_MIN_BUFFERS_NEEDED

enum rkisp1_plane {};

/*
 * @fourcc: pixel format
 * @fmt_type: helper filed for pixel format
 * @uv_swap: if cb cr swapped, for yuv
 * @yc_swap: if y and cb/cr swapped, for yuv
 * @byte_swap: if byte pairs are swapped, for raw
 * @write_format: defines how YCbCr self picture data is written to memory
 * @output_format: defines the output format (RKISP1_CIF_MI_INIT_MP_OUTPUT_* for
 *	the main path and RKISP1_MI_CTRL_SP_OUTPUT_* for the self path)
 * @mbus: the mbus code on the src resizer pad that matches the pixel format
 */
struct rkisp1_capture_fmt_cfg {};

struct rkisp1_capture_ops {};

struct rkisp1_capture_config {};

/*
 * The supported pixel formats for mainpath. NOTE, pixel formats with identical 'mbus'
 * are grouped together. This is assumed and used by the function rkisp1_cap_enum_mbus_codes
 */
static const struct rkisp1_capture_fmt_cfg rkisp1_mp_fmts[] =;

/*
 * The supported pixel formats for selfpath. NOTE, pixel formats with identical 'mbus'
 * are grouped together. This is assumed and used by the function rkisp1_cap_enum_mbus_codes
 */
static const struct rkisp1_capture_fmt_cfg rkisp1_sp_fmts[] =;

static const struct rkisp1_capture_config rkisp1_capture_config_mp =;

static const struct rkisp1_capture_config rkisp1_capture_config_sp =;

static inline struct rkisp1_vdev_node *
rkisp1_vdev_to_node(struct video_device *vdev)
{}

int rkisp1_cap_enum_mbus_codes(struct rkisp1_capture *cap,
			       struct v4l2_subdev_mbus_code_enum *code)
{}

/* ----------------------------------------------------------------------------
 * Stream operations for self-picture path (sp) and main-picture path (mp)
 */

static void rkisp1_mi_config_ctrl(struct rkisp1_capture *cap)
{}

static u32 rkisp1_pixfmt_comp_size(const struct v4l2_pix_format_mplane *pixm,
				   unsigned int component)
{}

static void rkisp1_irq_frame_end_enable(struct rkisp1_capture *cap)
{}

static void rkisp1_mp_config(struct rkisp1_capture *cap)
{}

static void rkisp1_sp_config(struct rkisp1_capture *cap)
{}

static void rkisp1_mp_disable(struct rkisp1_capture *cap)
{}

static void rkisp1_sp_disable(struct rkisp1_capture *cap)
{}

static void rkisp1_mp_enable(struct rkisp1_capture *cap)
{}

static void rkisp1_sp_enable(struct rkisp1_capture *cap)
{}

static void rkisp1_mp_sp_stop(struct rkisp1_capture *cap)
{}

static bool rkisp1_mp_is_stopped(struct rkisp1_capture *cap)
{}

static bool rkisp1_sp_is_stopped(struct rkisp1_capture *cap)
{}

static void rkisp1_mp_set_data_path(struct rkisp1_capture *cap)
{}

static void rkisp1_sp_set_data_path(struct rkisp1_capture *cap)
{}

static const struct rkisp1_capture_ops rkisp1_capture_ops_mp =;

static const struct rkisp1_capture_ops rkisp1_capture_ops_sp =;

/* ----------------------------------------------------------------------------
 * Frame buffer operations
 */

static int rkisp1_dummy_buf_create(struct rkisp1_capture *cap)
{}

static void rkisp1_dummy_buf_destroy(struct rkisp1_capture *cap)
{}

static void rkisp1_set_next_buf(struct rkisp1_capture *cap)
{}

/*
 * This function is called when a frame end comes. The next frame
 * is processing and we should set up buffer for next-next frame,
 * otherwise it will overflow.
 */
static void rkisp1_handle_buffer(struct rkisp1_capture *cap)
{}

irqreturn_t rkisp1_capture_isr(int irq, void *ctx)
{}

/* ----------------------------------------------------------------------------
 * Vb2 operations
 */

static int rkisp1_vb2_queue_setup(struct vb2_queue *queue,
				  unsigned int *num_buffers,
				  unsigned int *num_planes,
				  unsigned int sizes[],
				  struct device *alloc_devs[])
{}

static int rkisp1_vb2_buf_init(struct vb2_buffer *vb)
{}

static void rkisp1_vb2_buf_queue(struct vb2_buffer *vb)
{}

static int rkisp1_vb2_buf_prepare(struct vb2_buffer *vb)
{}

static void rkisp1_return_all_buffers(struct rkisp1_capture *cap,
				      enum vb2_buffer_state state)
{}

/*
 * Most registers inside the rockchip ISP1 have shadow register since
 * they must not be changed while processing a frame.
 * Usually, each sub-module updates its shadow register after
 * processing the last pixel of a frame.
 */
static void rkisp1_cap_stream_enable(struct rkisp1_capture *cap)
{}

static void rkisp1_cap_stream_disable(struct rkisp1_capture *cap)
{}

/*
 * rkisp1_pipeline_stream_disable - disable nodes in the pipeline
 *
 * Call s_stream(false) in the reverse order from
 * rkisp1_pipeline_stream_enable() and disable the DMA engine.
 * Should be called before video_device_pipeline_stop()
 */
static void rkisp1_pipeline_stream_disable(struct rkisp1_capture *cap)
	__must_hold(&cap->rkisp1->stream_lock)
{}

/*
 * rkisp1_pipeline_stream_enable - enable nodes in the pipeline
 *
 * Enable the DMA Engine and call s_stream(true) through the pipeline.
 * Should be called after video_device_pipeline_start()
 */
static int rkisp1_pipeline_stream_enable(struct rkisp1_capture *cap)
	__must_hold(&cap->rkisp1->stream_lock)
{}

static void rkisp1_vb2_stop_streaming(struct vb2_queue *queue)
{}

static int
rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count)
{}

static const struct vb2_ops rkisp1_vb2_ops =;

/* ----------------------------------------------------------------------------
 * IOCTLs operations
 */

static const struct v4l2_format_info *
rkisp1_fill_pixfmt(const struct rkisp1_capture *cap,
		   struct v4l2_pix_format_mplane *pixm)
{}

static const struct rkisp1_capture_fmt_cfg *
rkisp1_find_fmt_cfg(const struct rkisp1_capture *cap, const u32 pixelfmt)
{}

static void rkisp1_try_fmt(const struct rkisp1_capture *cap,
			   struct v4l2_pix_format_mplane *pixm,
			   const struct rkisp1_capture_fmt_cfg **fmt_cfg,
			   const struct v4l2_format_info **fmt_info)
{}

static void rkisp1_set_fmt(struct rkisp1_capture *cap,
			   struct v4l2_pix_format_mplane *pixm)
{}

static int rkisp1_try_fmt_vid_cap_mplane(struct file *file, void *fh,
					 struct v4l2_format *f)
{}

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

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

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

static int rkisp1_g_fmt_vid_cap_mplane(struct file *file, void *fh,
				       struct v4l2_format *f)
{}

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

static const struct v4l2_ioctl_ops rkisp1_v4l2_ioctl_ops =;

static int rkisp1_capture_link_validate(struct media_link *link)
{}

/* ----------------------------------------------------------------------------
 * core functions
 */

static const struct media_entity_operations rkisp1_media_ops =;

static const struct v4l2_file_operations rkisp1_fops =;

static void rkisp1_unregister_capture(struct rkisp1_capture *cap)
{}

void rkisp1_capture_devs_unregister(struct rkisp1_device *rkisp1)
{}

static int rkisp1_register_capture(struct rkisp1_capture *cap)
{}

static void
rkisp1_capture_init(struct rkisp1_device *rkisp1, enum rkisp1_stream_id id)
{}

int rkisp1_capture_devs_register(struct rkisp1_device *rkisp1)
{}