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.
16 #include <linux/videodev2.h>
17 #include <linux/i2c.h>
19 #include <media/v4l2-dev.h>
20 #include <media/v4l2-ioctl.h>
21 #include <media/v4l2-device.h>
22 #include <media/davinci/vpbe_osd.h>
23 #include <media/davinci/vpbe_venc.h>
24 #include <media/davinci/vpbe_types.h>
26 /* OSD configuration info */
27 struct osd_config_info
{
32 struct v4l2_output output
;
34 * If output capabilities include dv_timings, list supported timings
39 * defualt_mode identifies the default timings set at the venc or
44 * Fields below are used for supporting multiple modes. For example,
45 * LCD panel might support different modes and they are listed here.
46 * Similarly for supporting external encoders, lcd controller port
47 * requires a set of non-standard timing values to be listed here for
48 * each supported mode since venc is used in non-standard timing mode
49 * for interfacing with external encoder similar to configuring lcd
52 unsigned int num_modes
;
53 struct vpbe_enc_mode_info
*modes
;
55 * Bus configuration goes here for external encoders. Some encoders
56 * may require multiple interface types for each of the output. For
57 * example, SD modes would use YCC8 where as HD mode would use YCC16.
58 * Not sure if this is needed on a per mode basis instead of per
59 * output basis. If per mode is needed, we may have to move this to
65 /* encoder configuration info */
66 struct encoder_config_info
{
68 /* Is this an i2c device ? */
69 unsigned int is_i2c
:1;
70 /* i2c subdevice board info */
71 struct i2c_board_info board_info
;
74 /*amplifier configuration info */
75 struct amp_config_info
{
77 /* Is this an i2c device ? */
78 unsigned int is_i2c
:1;
79 /* i2c subdevice board info */
80 struct i2c_board_info board_info
;
83 /* structure for defining vpbe display subsystem components */
86 /* i2c bus adapter no */
88 struct osd_config_info osd
;
89 struct encoder_config_info venc
;
90 /* external encoder information goes here */
92 struct encoder_config_info
*ext_encoders
;
93 /* amplifier information goes here */
94 struct amp_config_info
*amp
;
96 /* Order is venc outputs followed by LCD and then external encoders */
97 struct vpbe_output
*outputs
;
102 struct vpbe_device_ops
{
103 /* crop cap for the display */
104 int (*g_cropcap
)(struct vpbe_device
*vpbe_dev
,
105 struct v4l2_cropcap
*cropcap
);
107 /* Enumerate the outputs */
108 int (*enum_outputs
)(struct vpbe_device
*vpbe_dev
,
109 struct v4l2_output
*output
);
111 /* Set output to the given index */
112 int (*set_output
)(struct vpbe_device
*vpbe_dev
,
115 /* Get current output */
116 unsigned int (*get_output
)(struct vpbe_device
*vpbe_dev
);
118 /* Set DV preset at current output */
119 int (*s_dv_timings
)(struct vpbe_device
*vpbe_dev
,
120 struct v4l2_dv_timings
*dv_timings
);
122 /* Get DV presets supported at the output */
123 int (*g_dv_timings
)(struct vpbe_device
*vpbe_dev
,
124 struct v4l2_dv_timings
*dv_timings
);
126 /* Enumerate the DV Presets supported at the output */
127 int (*enum_dv_timings
)(struct vpbe_device
*vpbe_dev
,
128 struct v4l2_enum_dv_timings
*timings_info
);
130 /* Set std at the output */
131 int (*s_std
)(struct vpbe_device
*vpbe_dev
, v4l2_std_id std_id
);
133 /* Get the current std at the output */
134 int (*g_std
)(struct vpbe_device
*vpbe_dev
, v4l2_std_id
*std_id
);
136 /* initialize the device */
137 int (*initialize
)(struct device
*dev
, struct vpbe_device
*vpbe_dev
);
139 /* De-initialize the device */
140 void (*deinitialize
)(struct device
*dev
, struct vpbe_device
*vpbe_dev
);
142 /* Get the current mode info */
143 int (*get_mode_info
)(struct vpbe_device
*vpbe_dev
,
144 struct vpbe_enc_mode_info
*);
147 * Set the current mode in the encoder. Alternate way of setting
148 * standard or DV preset or custom timings in the encoder
150 int (*set_mode
)(struct vpbe_device
*vpbe_dev
,
151 struct vpbe_enc_mode_info
*);
152 /* Power management operations */
153 int (*suspend
)(struct vpbe_device
*vpbe_dev
);
154 int (*resume
)(struct vpbe_device
*vpbe_dev
);
157 /* struct for vpbe device */
160 struct v4l2_device v4l2_dev
;
161 /* vpbe dispay controller cfg */
162 struct vpbe_config
*cfg
;
165 /* external encoder v4l2 sub devices */
166 struct v4l2_subdev
**encoders
;
167 /* current encoder index */
168 int current_sd_index
;
169 /* external amplifier v4l2 subdevice */
170 struct v4l2_subdev
*amp
;
172 /* device initialized */
176 /* osd_device pointer */
177 struct osd_state
*osd_device
;
178 /* venc device pointer */
179 struct venc_platform_data
*venc_device
;
181 * fields below are accessed by users of vpbe_device. Not the
186 int current_out_index
;
187 /* lock used by caller to do atomic operation on vpbe device */
188 /* current timings set in the controller */
189 struct vpbe_enc_mode_info current_timings
;
190 /* venc sub device */
191 struct v4l2_subdev
*venc
;
192 /* device operations below */
193 struct vpbe_device_ops ops
;