Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2008-2009 Texas Instruments Inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef _VPFE_CAPTURE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define _VPFE_CAPTURE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #ifdef __KERNEL__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) /* Header files */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <media/v4l2-dev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/clk.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <media/v4l2-fh.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <media/v4l2-ioctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <media/v4l2-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <media/videobuf-dma-contig.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <media/davinci/vpfe_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #define VPFE_CAPTURE_NUM_DECODERS        5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /* Macros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define VPFE_MAJOR_RELEASE              0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define VPFE_MINOR_RELEASE              0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define VPFE_BUILD                      1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define VPFE_CAPTURE_VERSION_CODE       ((VPFE_MAJOR_RELEASE << 16) | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 					(VPFE_MINOR_RELEASE << 8)  | \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 					VPFE_BUILD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define CAPTURE_DRV_NAME		"vpfe-capture"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) struct vpfe_pixel_format {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u32 pixelformat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	/* bytes per pixel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	int bpp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) struct vpfe_std_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	int active_pixels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	int active_lines;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	/* current frame format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	int frame_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) struct vpfe_route {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u32 input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	u32 output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) struct vpfe_subdev_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	/* Sub device name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	char name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	/* Sub device group id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	int grp_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	/* Number of inputs supported */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	int num_inputs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	/* inputs available at the sub device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct v4l2_input *inputs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	/* Sub dev routing information for each input */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct vpfe_route *routes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	/* check if sub dev supports routing */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int can_route;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	/* ccdc bus/interface configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	struct vpfe_hw_if_param ccdc_if_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	/* i2c subdevice board info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct i2c_board_info board_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) struct vpfe_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	/* Number of sub devices connected to vpfe */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	int num_subdevs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	/* i2c bus adapter no */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	int i2c_adapter_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	/* information about each subdev */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	struct vpfe_subdev_info *sub_devs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	/* evm card info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	char *card_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	/* ccdc name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	char *ccdc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	/* vpfe clock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	struct clk *vpssclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct clk *slaveclk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/* Function for Clearing the interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	void (*clr_intr)(int vdint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) struct vpfe_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	/* V4l2 specific parameters */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	/* Identifies video device for this channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	struct video_device video_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	/* sub devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	struct v4l2_subdev **sd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	/* vpfe cfg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	struct vpfe_config *cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	/* V4l2 device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	struct v4l2_device v4l2_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	/* parent device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	struct device *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	/* number of open instances of the channel */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	u32 usrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	/* Indicates id of the field which is being displayed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	u32 field_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	/* flag to indicate whether decoder is initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	u8 initialized;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	/* current interface type */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	struct vpfe_hw_if_param vpfe_if_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	/* ptr to currently selected sub device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct vpfe_subdev_info *current_subdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	/* current input at the sub device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	int current_input;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	/* Keeps track of the information about the standard */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	struct vpfe_std_info std_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	/* std index into std table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	int std_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	/* CCDC IRQs used when CCDC/ISIF output to SDRAM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	unsigned int ccdc_irq0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	unsigned int ccdc_irq1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	/* number of buffers in fbuffers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	u32 numbuffers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	/* List of buffer pointers for storing frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	u8 *fbuffers[VIDEO_MAX_FRAME];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	/* Pointer pointing to current v4l2_buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	struct videobuf_buffer *cur_frm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	/* Pointer pointing to next v4l2_buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	struct videobuf_buffer *next_frm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	 * This field keeps track of type of buffer exchange mechanism
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	 * user has selected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	enum v4l2_memory memory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	/* Used to store pixel format */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	struct v4l2_format fmt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	 * used when IMP is chained to store the crop window which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	 * is different from the image window
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	struct v4l2_rect crop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	/* Buffer queue used in video-buf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct videobuf_queue buffer_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	/* Queue of filled frames */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	struct list_head dma_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	/* Used in video-buf */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	spinlock_t irqlock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	/* IRQ lock for DMA queue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	spinlock_t dma_queue_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	/* lock used to access this structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	/* number of users performing IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	u32 io_usrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	/* Indicates whether streaming started */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	u8 started;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	 * offset where second field starts from the starting of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	 * buffer for field separated YCbCr formats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	u32 field_off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /* File handle structure */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct vpfe_fh {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	struct v4l2_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	struct vpfe_device *vpfe_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	/* Indicates whether this file handle is doing IO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	u8 io_allowed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct vpfe_config_params {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	u8 min_numbuffers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	u8 numbuffers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	u32 min_bufsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	u32 device_bufsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) #endif				/* End of __KERNEL__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) #endif				/* _DAVINCI_VPFE_H */