linux/drivers/media/platform/nuvoton/npcm-video.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Driver for Video Capture/Differentiation Engine (VCD) and Encoding
 * Compression Engine (ECE) present on Nuvoton NPCM SoCs.
 *
 * Copyright (C) 2022 Nuvoton Technologies
 */

#include <linux/atomic.h>
#include <linux/bitfield.h>
#include <linux/bitmap.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/jiffies.h>
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/v4l2-controls.h>
#include <linux/videodev2.h>
#include <media/v4l2-ctrls.h>
#include <media/v4l2-dev.h>
#include <media/v4l2-device.h>
#include <media/v4l2-dv-timings.h>
#include <media/v4l2-event.h>
#include <media/v4l2-ioctl.h>
#include <media/videobuf2-dma-contig.h>
#include <uapi/linux/npcm-video.h>
#include "npcm-regs.h"

#define DEVICE_NAME
#define MAX_WIDTH
#define MAX_HEIGHT
#define MIN_WIDTH
#define MIN_HEIGHT
#define MIN_LP
#define MAX_LP
#define RECT_W
#define RECT_H
#define BITMAP_SIZE

struct npcm_video_addr {};

struct npcm_video_buffer {};

#define to_npcm_video_buffer(x)

/*
 * VIDEO_STREAMING:	a flag indicating if the video has started streaming
 * VIDEO_CAPTURING:	a flag indicating if the VCD is capturing a frame
 * VIDEO_RES_CHANGING:	a flag indicating if the resolution is changing
 * VIDEO_STOPPED:	a flag indicating if the video has stopped streaming
 */
enum {};

struct rect_list {};

struct rect_list_info {};

struct npcm_ece {};

struct npcm_video {};

#define to_npcm_video(x)

struct npcm_fmt {};

static const struct npcm_fmt npcm_fmt_list[] =;

#define NUM_FORMATS

static const struct v4l2_dv_timings_cap npcm_video_timings_cap =;

static DECLARE_BITMAP(bitmap, BITMAP_SIZE);

static const struct npcm_fmt *npcm_video_find_format(struct v4l2_format *f)
{}

static void npcm_video_ece_prepend_rect_header(void *addr, u16 x, u16 y, u16 w, u16 h)
{}

static unsigned int npcm_video_ece_get_ed_size(struct npcm_video *video,
					       unsigned int offset, void *addr)
{}

static void npcm_video_ece_enc_rect(struct npcm_video *video,
				    unsigned int r_off_x, unsigned int r_off_y,
				    unsigned int r_w, unsigned int r_h)
{}

static unsigned int npcm_video_ece_read_rect_offset(struct npcm_video *video)
{}

/*
 * Set the line pitch (in bytes) for the frame buffers.
 * Can be on of those values: 512, 1024, 2048, 2560 or 4096 bytes.
 */
static void npcm_video_ece_set_lp(struct npcm_video *video, unsigned int pitch)
{}

static inline void npcm_video_ece_set_fb_addr(struct npcm_video *video,
					      unsigned int buffer)
{}

static inline void npcm_video_ece_set_enc_dba(struct npcm_video *video,
					      unsigned int addr)
{}

static inline void npcm_video_ece_clear_rect_offset(struct npcm_video *video)
{}

static void npcm_video_ece_ctrl_reset(struct npcm_video *video)
{}

static void npcm_video_ece_ip_reset(struct npcm_video *video)
{}

static void npcm_video_ece_stop(struct npcm_video *video)
{}

static bool npcm_video_alloc_fb(struct npcm_video *video,
				struct npcm_video_addr *addr)
{}

static void npcm_video_free_fb(struct npcm_video *video,
			       struct npcm_video_addr *addr)
{}

static void npcm_video_free_diff_table(struct npcm_video *video)
{}

static unsigned int npcm_video_add_rect(struct npcm_video *video,
					unsigned int index,
					unsigned int x, unsigned int y,
					unsigned int w, unsigned int h)
{}

static void npcm_video_merge_rect(struct npcm_video *video,
				  struct rect_list_info *info)
{}

static struct rect_list *npcm_video_new_rect(struct npcm_video *video,
					     unsigned int offset,
					     unsigned int index)
{}

static int npcm_video_find_rect(struct npcm_video *video,
				struct rect_list_info *info,
				unsigned int offset)
{}

static int npcm_video_build_table(struct npcm_video *video,
				  struct rect_list_info *info)
{}

static void npcm_video_get_rect_list(struct npcm_video *video, unsigned int index)
{}

static unsigned int npcm_video_is_mga(struct npcm_video *video)
{}

static unsigned int npcm_video_hres(struct npcm_video *video)
{}

static unsigned int npcm_video_vres(struct npcm_video *video)
{}

static int npcm_video_capres(struct npcm_video *video, unsigned int hor_res,
			     unsigned int vert_res)
{}

static void npcm_video_vcd_ip_reset(struct npcm_video *video)
{}

static void npcm_video_vcd_state_machine_reset(struct npcm_video *video)
{}

static void npcm_video_gfx_reset(struct npcm_video *video)
{}

static void npcm_video_kvm_bw(struct npcm_video *video, bool set_bw)
{}

static unsigned int npcm_video_pclk(struct npcm_video *video)
{}

static unsigned int npcm_video_get_bpp(struct npcm_video *video)
{}

/*
 * Pitch must be a power of 2, >= linebytes,
 * at least 512, and no more than 4096.
 */
static void npcm_video_set_linepitch(struct npcm_video *video,
				     unsigned int linebytes)
{}

static unsigned int npcm_video_get_linepitch(struct npcm_video *video)
{}

static void npcm_video_command(struct npcm_video *video, unsigned int value)
{}

static void npcm_video_init_reg(struct npcm_video *video)
{}

static int npcm_video_start_frame(struct npcm_video *video)
{}

static void npcm_video_bufs_done(struct npcm_video *video,
				 enum vb2_buffer_state state)
{}

static void npcm_video_get_diff_rect(struct npcm_video *video, unsigned int index)
{}

static void npcm_video_detect_resolution(struct npcm_video *video)
{}

static int npcm_video_set_resolution(struct npcm_video *video,
				     struct v4l2_bt_timings *timing)
{}

static void npcm_video_start(struct npcm_video *video)
{}

static void npcm_video_stop(struct npcm_video *video)
{}

static unsigned int npcm_video_raw(struct npcm_video *video, int index, void *addr)
{}

static unsigned int npcm_video_hextile(struct npcm_video *video, unsigned int index,
				       unsigned int dma_addr, void *vaddr)
{}

static irqreturn_t npcm_video_irq(int irq, void *arg)
{}

static int npcm_video_querycap(struct file *file, void *fh,
			       struct v4l2_capability *cap)
{}

static int npcm_video_enum_format(struct file *file, void *fh,
				  struct v4l2_fmtdesc *f)
{}

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

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

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

static int npcm_video_enum_input(struct file *file, void *fh,
				 struct v4l2_input *inp)
{}

static int npcm_video_get_input(struct file *file, void *fh, unsigned int *i)
{}

static int npcm_video_set_input(struct file *file, void *fh, unsigned int i)
{}

static int npcm_video_set_dv_timings(struct file *file, void *fh,
				     struct v4l2_dv_timings *timings)
{}

static int npcm_video_get_dv_timings(struct file *file, void *fh,
				     struct v4l2_dv_timings *timings)
{}

static int npcm_video_query_dv_timings(struct file *file, void *fh,
				       struct v4l2_dv_timings *timings)
{}

static int npcm_video_enum_dv_timings(struct file *file, void *fh,
				      struct v4l2_enum_dv_timings *timings)
{}

static int npcm_video_dv_timings_cap(struct file *file, void *fh,
				     struct v4l2_dv_timings_cap *cap)
{}

static int npcm_video_sub_event(struct v4l2_fh *fh,
				const struct v4l2_event_subscription *sub)
{}

static const struct v4l2_ioctl_ops npcm_video_ioctls =;

static int npcm_video_set_ctrl(struct v4l2_ctrl *ctrl)
{}

static const struct v4l2_ctrl_ops npcm_video_ctrl_ops =;

static const char * const npcm_ctrl_capture_mode_menu[] =;

static const struct v4l2_ctrl_config npcm_ctrl_capture_mode =;

/*
 * This control value is set when a buffer is dequeued by userspace, i.e. in
 * npcm_video_buf_finish function.
 */
static const struct v4l2_ctrl_config npcm_ctrl_rect_count =;

static int npcm_video_open(struct file *file)
{}

static int npcm_video_release(struct file *file)
{}

static const struct v4l2_file_operations npcm_video_v4l2_fops =;

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

static int npcm_video_buf_prepare(struct vb2_buffer *vb)
{}

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

static void npcm_video_stop_streaming(struct vb2_queue *q)
{}

static void npcm_video_buf_queue(struct vb2_buffer *vb)
{}

static void npcm_video_buf_finish(struct vb2_buffer *vb)
{}

static const struct regmap_config npcm_video_regmap_cfg =;

static const struct regmap_config npcm_video_ece_regmap_cfg =;

static const struct vb2_ops npcm_video_vb2_ops =;

static int npcm_video_setup_video(struct npcm_video *video)
{}

static int npcm_video_ece_init(struct npcm_video *video)
{}

static int npcm_video_init(struct npcm_video *video)
{}

static int npcm_video_probe(struct platform_device *pdev)
{}

static void npcm_video_remove(struct platform_device *pdev)
{}

static const struct of_device_id npcm_video_match[] =;

MODULE_DEVICE_TABLE(of, npcm_video_match);

static struct platform_driver npcm_video_driver =;

module_platform_driver();

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