1/* 2 * Copyright (C) 2010 Texas Instruments Inc 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation version 2. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 */ 17#ifndef _VPBE_H 18#define _VPBE_H 19 20#include <linux/videodev2.h> 21#include <linux/i2c.h> 22 23#include <media/v4l2-dev.h> 24#include <media/v4l2-ioctl.h> 25#include <media/v4l2-device.h> 26#include <media/davinci/vpbe_osd.h> 27#include <media/davinci/vpbe_venc.h> 28#include <media/davinci/vpbe_types.h> 29 30/* OSD configuration info */ 31struct osd_config_info { 32 char module_name[32]; 33}; 34 35struct vpbe_output { 36 struct v4l2_output output; 37 /* 38 * If output capabilities include dv_preset, list supported presets 39 * below 40 */ 41 char *subdev_name; 42 /* 43 * defualt_mode identifies the default timings set at the venc or 44 * external encoder. 45 */ 46 char *default_mode; 47 /* 48 * Fields below are used for supporting multiple modes. For example, 49 * LCD panel might support different modes and they are listed here. 50 * Similarly for supporting external encoders, lcd controller port 51 * requires a set of non-standard timing values to be listed here for 52 * each supported mode since venc is used in non-standard timing mode 53 * for interfacing with external encoder similar to configuring lcd 54 * panel timings 55 */ 56 unsigned int num_modes; 57 struct vpbe_enc_mode_info *modes; 58 /* 59 * Bus configuration goes here for external encoders. Some encoders 60 * may require multiple interface types for each of the output. For 61 * example, SD modes would use YCC8 where as HD mode would use YCC16. 62 * Not sure if this is needed on a per mode basis instead of per 63 * output basis. If per mode is needed, we may have to move this to 64 * mode_info structure 65 */ 66}; 67 68/* encoder configuration info */ 69struct encoder_config_info { 70 char module_name[32]; 71 /* Is this an i2c device ? */ 72 unsigned int is_i2c:1; 73 /* i2c subdevice board info */ 74 struct i2c_board_info board_info; 75}; 76 77/* structure for defining vpbe display subsystem components */ 78struct vpbe_config { 79 char module_name[32]; 80 /* i2c bus adapter no */ 81 int i2c_adapter_id; 82 struct osd_config_info osd; 83 struct encoder_config_info venc; 84 /* external encoder information goes here */ 85 int num_ext_encoders; 86 struct encoder_config_info *ext_encoders; 87 int num_outputs; 88 /* Order is venc outputs followed by LCD and then external encoders */ 89 struct vpbe_output *outputs; 90}; 91 92struct vpbe_device; 93 94struct vpbe_device_ops { 95 /* crop cap for the display */ 96 int (*g_cropcap)(struct vpbe_device *vpbe_dev, 97 struct v4l2_cropcap *cropcap); 98 99 /* Enumerate the outputs */ 100 int (*enum_outputs)(struct vpbe_device *vpbe_dev, 101 struct v4l2_output *output); 102 103 /* Set output to the given index */ 104 int (*set_output)(struct vpbe_device *vpbe_dev, 105 int index); 106 107 /* Get current output */ 108 unsigned int (*get_output)(struct vpbe_device *vpbe_dev); 109 110 /* Set DV preset at current output */ 111 int (*s_dv_preset)(struct vpbe_device *vpbe_dev, 112 struct v4l2_dv_preset *dv_preset); 113 114 /* Get DV presets supported at the output */ 115 int (*g_dv_preset)(struct vpbe_device *vpbe_dev, 116 struct v4l2_dv_preset *dv_preset); 117 118 /* Enumerate the DV Presets supported at the output */ 119 int (*enum_dv_presets)(struct vpbe_device *vpbe_dev, 120 struct v4l2_dv_enum_preset *preset_info); 121 122 /* Set std at the output */ 123 int (*s_std)(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id); 124 125 /* Get the current std at the output */ 126 int (*g_std)(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id); 127 128 /* initialize the device */ 129 int (*initialize)(struct device *dev, struct vpbe_device *vpbe_dev); 130 131 /* De-initialize the device */ 132 void (*deinitialize)(struct device *dev, struct vpbe_device *vpbe_dev); 133 134 /* Get the current mode info */ 135 int (*get_mode_info)(struct vpbe_device *vpbe_dev, 136 struct vpbe_enc_mode_info*); 137 138 /* 139 * Set the current mode in the encoder. Alternate way of setting 140 * standard or DV preset or custom timings in the encoder 141 */ 142 int (*set_mode)(struct vpbe_device *vpbe_dev, 143 struct vpbe_enc_mode_info*); 144 /* Power management operations */ 145 int (*suspend)(struct vpbe_device *vpbe_dev); 146 int (*resume)(struct vpbe_device *vpbe_dev); 147}; 148 149/* struct for vpbe device */ 150struct vpbe_device { 151 /* V4l2 device */ 152 struct v4l2_device v4l2_dev; 153 /* vpbe dispay controller cfg */ 154 struct vpbe_config *cfg; 155 /* parent device */ 156 struct device *pdev; 157 /* external encoder v4l2 sub devices */ 158 struct v4l2_subdev **encoders; 159 /* current encoder index */ 160 int current_sd_index; 161 struct mutex lock; 162 /* device initialized */ 163 int initialized; 164 /* vpbe dac clock */ 165 struct clk *dac_clk; 166 /* osd_device pointer */ 167 struct osd_state *osd_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 185

