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-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2010 Texas Instruments Inc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #ifndef _VPBE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #define _VPBE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <media/v4l2-dev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <media/v4l2-ioctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <media/v4l2-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <media/davinci/vpbe_osd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <media/davinci/vpbe_venc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <media/davinci/vpbe_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) /* OSD configuration info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) struct osd_config_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	char module_name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct vpbe_output {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	struct v4l2_output output;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	 * If output capabilities include dv_timings, list supported timings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	 * below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	char *subdev_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	 * defualt_mode identifies the default timings set at the venc or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	 * external encoder.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	char *default_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	 * Fields below are used for supporting multiple modes. For example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	 * LCD panel might support different modes and they are listed here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	 * Similarly for supporting external encoders, lcd controller port
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	 * requires a set of non-standard timing values to be listed here for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	 * each supported mode since venc is used in non-standard timing mode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	 * for interfacing with external encoder similar to configuring lcd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	 * panel timings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	unsigned int num_modes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct vpbe_enc_mode_info *modes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	 * Bus configuration goes here for external encoders. Some encoders
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	 * may require multiple interface types for each of the output. For
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	 * example, SD modes would use YCC8 where as HD mode would use YCC16.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	 * Not sure if this is needed on a per mode basis instead of per
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	 * output basis. If per mode is needed, we may have to move this to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	 * mode_info structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	u32 if_params;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) /* encoder configuration info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) struct encoder_config_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	char module_name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	/* Is this an i2c device ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	unsigned int is_i2c:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	/* i2c subdevice board info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct i2c_board_info board_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) /*amplifier configuration info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) struct amp_config_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	char module_name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	/* Is this an i2c device ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	unsigned int is_i2c:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	/* i2c subdevice board info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	struct i2c_board_info board_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) /* structure for defining vpbe display subsystem components */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) struct vpbe_config {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	char module_name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	/* i2c bus adapter no */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	int i2c_adapter_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct osd_config_info osd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	struct encoder_config_info venc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	/* external encoder information goes here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	int num_ext_encoders;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct encoder_config_info *ext_encoders;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/* amplifier information goes here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	struct amp_config_info *amp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	unsigned int num_outputs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	/* Order is venc outputs followed by LCD and then external encoders */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct vpbe_output *outputs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) struct vpbe_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) struct vpbe_device_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	/* Enumerate the outputs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	int (*enum_outputs)(struct vpbe_device *vpbe_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			    struct v4l2_output *output);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	/* Set output to the given index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	int (*set_output)(struct vpbe_device *vpbe_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			 int index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	/* Get current output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	unsigned int (*get_output)(struct vpbe_device *vpbe_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	/* Set DV preset at current output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	int (*s_dv_timings)(struct vpbe_device *vpbe_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			   struct v4l2_dv_timings *dv_timings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	/* Get DV presets supported at the output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	int (*g_dv_timings)(struct vpbe_device *vpbe_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			   struct v4l2_dv_timings *dv_timings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	/* Enumerate the DV Presets supported at the output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	int (*enum_dv_timings)(struct vpbe_device *vpbe_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			       struct v4l2_enum_dv_timings *timings_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	/* Set std at the output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	int (*s_std)(struct vpbe_device *vpbe_dev, v4l2_std_id std_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	/* Get the current std at the output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	int (*g_std)(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	/* initialize the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	int (*initialize)(struct device *dev, struct vpbe_device *vpbe_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	/* De-initialize the device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	void (*deinitialize)(struct device *dev, struct vpbe_device *vpbe_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	/* Get the current mode info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	int (*get_mode_info)(struct vpbe_device *vpbe_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			     struct vpbe_enc_mode_info*);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	 * Set the current mode in the encoder. Alternate way of setting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	 * standard or DV preset or custom timings in the encoder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	int (*set_mode)(struct vpbe_device *vpbe_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			struct vpbe_enc_mode_info*);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	/* Power management operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	int (*suspend)(struct vpbe_device *vpbe_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	int (*resume)(struct vpbe_device *vpbe_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* struct for vpbe device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct vpbe_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	/* V4l2 device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	struct v4l2_device v4l2_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	/* vpbe dispay controller cfg */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	struct vpbe_config *cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	/* parent device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	struct device *pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	/* external encoder v4l2 sub devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	struct v4l2_subdev **encoders;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	/* current encoder index */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	int current_sd_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	/* external amplifier v4l2 subdevice */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	struct v4l2_subdev *amp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	/* device initialized */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	int initialized;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	/* vpbe dac clock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	struct clk *dac_clk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	/* osd_device pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	struct osd_state *osd_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	/* venc device pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	struct venc_platform_data *venc_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	 * fields below are accessed by users of vpbe_device. Not the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	 * ones above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	/* current output */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	int current_out_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	/* lock used by caller to do atomic operation on vpbe device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	/* current timings set in the controller */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	struct vpbe_enc_mode_info current_timings;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	/* venc sub device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	struct v4l2_subdev *venc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	/* device operations below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	struct vpbe_device_ops ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #endif