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
68 /* encoder configuration info */
69 struct encoder_config_info
{
71 /* Is this an i2c device ? */
72 unsigned int is_i2c
:1;
73 /* i2c subdevice board info */
74 struct i2c_board_info board_info
;
77 /* structure for defining vpbe display subsystem components */
80 /* i2c bus adapter no */
82 struct osd_config_info osd
;
83 struct encoder_config_info venc
;
84 /* external encoder information goes here */
86 struct encoder_config_info
*ext_encoders
;
88 /* Order is venc outputs followed by LCD and then external encoders */
89 struct vpbe_output
*outputs
;
94 struct vpbe_device_ops
{
95 /* crop cap for the display */
96 int (*g_cropcap
)(struct vpbe_device
*vpbe_dev
,
97 struct v4l2_cropcap
*cropcap
);
99 /* Enumerate the outputs */
100 int (*enum_outputs
)(struct vpbe_device
*vpbe_dev
,
101 struct v4l2_output
*output
);
103 /* Set output to the given index */
104 int (*set_output
)(struct vpbe_device
*vpbe_dev
,
107 /* Get current output */
108 unsigned int (*get_output
)(struct vpbe_device
*vpbe_dev
);
110 /* Set DV preset at current output */
111 int (*s_dv_preset
)(struct vpbe_device
*vpbe_dev
,
112 struct v4l2_dv_preset
*dv_preset
);
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
);
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
);
122 /* Set std at the output */
123 int (*s_std
)(struct vpbe_device
*vpbe_dev
, v4l2_std_id
*std_id
);
125 /* Get the current std at the output */
126 int (*g_std
)(struct vpbe_device
*vpbe_dev
, v4l2_std_id
*std_id
);
128 /* initialize the device */
129 int (*initialize
)(struct device
*dev
, struct vpbe_device
*vpbe_dev
);
131 /* De-initialize the device */
132 void (*deinitialize
)(struct device
*dev
, struct vpbe_device
*vpbe_dev
);
134 /* Get the current mode info */
135 int (*get_mode_info
)(struct vpbe_device
*vpbe_dev
,
136 struct vpbe_enc_mode_info
*);
139 * Set the current mode in the encoder. Alternate way of setting
140 * standard or DV preset or custom timings in the encoder
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
);
149 /* struct for vpbe device */
152 struct v4l2_device v4l2_dev
;
153 /* vpbe dispay controller cfg */
154 struct vpbe_config
*cfg
;
157 /* external encoder v4l2 sub devices */
158 struct v4l2_subdev
**encoders
;
159 /* current encoder index */
160 int current_sd_index
;
162 /* device initialized */
166 /* osd_device pointer */
167 struct osd_state
*osd_device
;
169 * fields below are accessed by users of vpbe_device. Not the
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
;