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