blob: 4376beeb28c2c9b2db4efe2dbb0a8869bd6ecd93 [file] [log] [blame]
Manjunath Hadli66715cd2011-06-17 04:01:32 -03001/*
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 /*
Hans Verkuil36864082012-10-01 11:39:46 -030038 * If output capabilities include dv_timings, list supported timings
Manjunath Hadli66715cd2011-06-17 04:01:32 -030039 * 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 */
Boris BREZILLON27ffaeb2014-11-10 14:28:31 -030066 u32 if_params;
Manjunath Hadli66715cd2011-06-17 04:01:32 -030067};
68
69/* encoder configuration info */
70struct encoder_config_info {
71 char module_name[32];
72 /* Is this an i2c device ? */
73 unsigned int is_i2c:1;
74 /* i2c subdevice board info */
75 struct i2c_board_info board_info;
76};
77
Manjunath Hadli9a7f95a2011-04-30 03:01:40 -030078/*amplifier configuration info */
79struct amp_config_info {
80 char module_name[32];
81 /* Is this an i2c device ? */
82 unsigned int is_i2c:1;
83 /* i2c subdevice board info */
84 struct i2c_board_info board_info;
85};
86
Manjunath Hadli66715cd2011-06-17 04:01:32 -030087/* structure for defining vpbe display subsystem components */
88struct vpbe_config {
89 char module_name[32];
90 /* i2c bus adapter no */
91 int i2c_adapter_id;
92 struct osd_config_info osd;
93 struct encoder_config_info venc;
94 /* external encoder information goes here */
95 int num_ext_encoders;
96 struct encoder_config_info *ext_encoders;
Manjunath Hadli9a7f95a2011-04-30 03:01:40 -030097 /* amplifier information goes here */
98 struct amp_config_info *amp;
Manjunath Hadli66715cd2011-06-17 04:01:32 -030099 int num_outputs;
100 /* Order is venc outputs followed by LCD and then external encoders */
101 struct vpbe_output *outputs;
102};
103
104struct vpbe_device;
105
106struct vpbe_device_ops {
107 /* crop cap for the display */
108 int (*g_cropcap)(struct vpbe_device *vpbe_dev,
109 struct v4l2_cropcap *cropcap);
110
111 /* Enumerate the outputs */
112 int (*enum_outputs)(struct vpbe_device *vpbe_dev,
113 struct v4l2_output *output);
114
115 /* Set output to the given index */
116 int (*set_output)(struct vpbe_device *vpbe_dev,
117 int index);
118
119 /* Get current output */
120 unsigned int (*get_output)(struct vpbe_device *vpbe_dev);
121
122 /* Set DV preset at current output */
Hans Verkuil36864082012-10-01 11:39:46 -0300123 int (*s_dv_timings)(struct vpbe_device *vpbe_dev,
124 struct v4l2_dv_timings *dv_timings);
Manjunath Hadli66715cd2011-06-17 04:01:32 -0300125
126 /* Get DV presets supported at the output */
Hans Verkuil36864082012-10-01 11:39:46 -0300127 int (*g_dv_timings)(struct vpbe_device *vpbe_dev,
128 struct v4l2_dv_timings *dv_timings);
Manjunath Hadli66715cd2011-06-17 04:01:32 -0300129
130 /* Enumerate the DV Presets supported at the output */
Hans Verkuil36864082012-10-01 11:39:46 -0300131 int (*enum_dv_timings)(struct vpbe_device *vpbe_dev,
132 struct v4l2_enum_dv_timings *timings_info);
Manjunath Hadli66715cd2011-06-17 04:01:32 -0300133
134 /* Set std at the output */
Hans Verkuil314527a2013-03-15 06:10:40 -0300135 int (*s_std)(struct vpbe_device *vpbe_dev, v4l2_std_id std_id);
Manjunath Hadli66715cd2011-06-17 04:01:32 -0300136
137 /* Get the current std at the output */
138 int (*g_std)(struct vpbe_device *vpbe_dev, v4l2_std_id *std_id);
139
140 /* initialize the device */
141 int (*initialize)(struct device *dev, struct vpbe_device *vpbe_dev);
142
143 /* De-initialize the device */
144 void (*deinitialize)(struct device *dev, struct vpbe_device *vpbe_dev);
145
146 /* Get the current mode info */
147 int (*get_mode_info)(struct vpbe_device *vpbe_dev,
148 struct vpbe_enc_mode_info*);
149
150 /*
151 * Set the current mode in the encoder. Alternate way of setting
152 * standard or DV preset or custom timings in the encoder
153 */
154 int (*set_mode)(struct vpbe_device *vpbe_dev,
155 struct vpbe_enc_mode_info*);
156 /* Power management operations */
157 int (*suspend)(struct vpbe_device *vpbe_dev);
158 int (*resume)(struct vpbe_device *vpbe_dev);
159};
160
161/* struct for vpbe device */
162struct vpbe_device {
163 /* V4l2 device */
164 struct v4l2_device v4l2_dev;
165 /* vpbe dispay controller cfg */
166 struct vpbe_config *cfg;
167 /* parent device */
168 struct device *pdev;
169 /* external encoder v4l2 sub devices */
170 struct v4l2_subdev **encoders;
171 /* current encoder index */
172 int current_sd_index;
Manjunath Hadli9a7f95a2011-04-30 03:01:40 -0300173 /* external amplifier v4l2 subdevice */
174 struct v4l2_subdev *amp;
Manjunath Hadli66715cd2011-06-17 04:01:32 -0300175 struct mutex lock;
176 /* device initialized */
177 int initialized;
178 /* vpbe dac clock */
179 struct clk *dac_clk;
180 /* osd_device pointer */
181 struct osd_state *osd_device;
Manjunath Hadli9a7f95a2011-04-30 03:01:40 -0300182 /* venc device pointer */
183 struct venc_platform_data *venc_device;
Manjunath Hadli66715cd2011-06-17 04:01:32 -0300184 /*
185 * fields below are accessed by users of vpbe_device. Not the
186 * ones above
187 */
188
189 /* current output */
190 int current_out_index;
191 /* lock used by caller to do atomic operation on vpbe device */
192 /* current timings set in the controller */
193 struct vpbe_enc_mode_info current_timings;
194 /* venc sub device */
195 struct v4l2_subdev *venc;
196 /* device operations below */
197 struct vpbe_device_ops ops;
198};
199
200#endif