2 * Copyright (C) 2010 Texas Instruments Inc
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.
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.
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
20 #include <linux/videodev2.h>
21 #include <linux/i2c.h>
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>
30 /* OSD configuration info */
31 struct osd_config_info
{
36 struct v4l2_output output
;
38 * If output capabilities include dv_preset, list supported presets
43 * defualt_mode identifies the default timings set at the venc or
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
56 unsigned int num_modes
;
57 struct vpbe_enc_mode_info
*modes
;
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
66 enum v4l2_mbus_pixelcode if_params
;
69 /* encoder configuration info */
70 struct encoder_config_info
{
72 /* Is this an i2c device ? */
73 unsigned int is_i2c
:1;
74 /* i2c subdevice board info */
75 struct i2c_board_info board_info
;
78 /*amplifier configuration info */
79 struct amp_config_info
{
81 /* Is this an i2c device ? */
82 unsigned int is_i2c
:1;
83 /* i2c subdevice board info */
84 struct i2c_board_info board_info
;
87 /* structure for defining vpbe display subsystem components */
90 /* i2c bus adapter no */
92 struct osd_config_info osd
;
93 struct encoder_config_info venc
;
94 /* external encoder information goes here */
96 struct encoder_config_info
*ext_encoders
;
97 /* amplifier information goes here */
98 struct amp_config_info
*amp
;
100 /* Order is venc outputs followed by LCD and then external encoders */
101 struct vpbe_output
*outputs
;
106 struct vpbe_device_ops
{
107 /* crop cap for the display */
108 int (*g_cropcap
)(struct vpbe_device
*vpbe_dev
,
109 struct v4l2_cropcap
*cropcap
);
111 /* Enumerate the outputs */
112 int (*enum_outputs
)(struct vpbe_device
*vpbe_dev
,
113 struct v4l2_output
*output
);
115 /* Set output to the given index */
116 int (*set_output
)(struct vpbe_device
*vpbe_dev
,
119 /* Get current output */
120 unsigned int (*get_output
)(struct vpbe_device
*vpbe_dev
);
122 /* Set DV preset at current output */
123 int (*s_dv_preset
)(struct vpbe_device
*vpbe_dev
,
124 struct v4l2_dv_preset
*dv_preset
);
126 /* Get DV presets supported at the output */
127 int (*g_dv_preset
)(struct vpbe_device
*vpbe_dev
,
128 struct v4l2_dv_preset
*dv_preset
);
130 /* Enumerate the DV Presets supported at the output */
131 int (*enum_dv_presets
)(struct vpbe_device
*vpbe_dev
,
132 struct v4l2_dv_enum_preset
*preset_info
);
134 /* Set std at the output */
135 int (*s_std
)(struct vpbe_device
*vpbe_dev
, v4l2_std_id
*std_id
);
137 /* Get the current std at the output */
138 int (*g_std
)(struct vpbe_device
*vpbe_dev
, v4l2_std_id
*std_id
);
140 /* initialize the device */
141 int (*initialize
)(struct device
*dev
, struct vpbe_device
*vpbe_dev
);
143 /* De-initialize the device */
144 void (*deinitialize
)(struct device
*dev
, struct vpbe_device
*vpbe_dev
);
146 /* Get the current mode info */
147 int (*get_mode_info
)(struct vpbe_device
*vpbe_dev
,
148 struct vpbe_enc_mode_info
*);
151 * Set the current mode in the encoder. Alternate way of setting
152 * standard or DV preset or custom timings in the encoder
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
);
161 /* struct for vpbe device */
164 struct v4l2_device v4l2_dev
;
165 /* vpbe dispay controller cfg */
166 struct vpbe_config
*cfg
;
169 /* external encoder v4l2 sub devices */
170 struct v4l2_subdev
**encoders
;
171 /* current encoder index */
172 int current_sd_index
;
173 /* external amplifier v4l2 subdevice */
174 struct v4l2_subdev
*amp
;
176 /* device initialized */
180 /* osd_device pointer */
181 struct osd_state
*osd_device
;
182 /* venc device pointer */
183 struct venc_platform_data
*venc_device
;
185 * fields below are accessed by users of vpbe_device. Not the
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
;