Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 1 | /* |
| 2 | * ti_hdmi.h |
| 3 | * |
| 4 | * HDMI driver definition for TI OMAP4, DM81xx, DM38xx Processor. |
| 5 | * |
| 6 | * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/ |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License version 2 as published by |
| 10 | * the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 15 | * more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #ifndef _TI_HDMI_H |
| 22 | #define _TI_HDMI_H |
| 23 | |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame^] | 24 | #include <linux/platform_device.h> |
| 25 | |
Mythri P K | 60634a2 | 2011-09-08 19:06:26 +0530 | [diff] [blame] | 26 | struct hdmi_ip_data; |
| 27 | |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 28 | enum hdmi_pll_pwr { |
| 29 | HDMI_PLLPWRCMD_ALLOFF = 0, |
| 30 | HDMI_PLLPWRCMD_PLLONLY = 1, |
| 31 | HDMI_PLLPWRCMD_BOTHON_ALLCLKS = 2, |
| 32 | HDMI_PLLPWRCMD_BOTHON_NOPHYCLK = 3 |
| 33 | }; |
| 34 | |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame^] | 35 | enum hdmi_phy_pwr { |
| 36 | HDMI_PHYPWRCMD_OFF = 0, |
| 37 | HDMI_PHYPWRCMD_LDOON = 1, |
| 38 | HDMI_PHYPWRCMD_TXON = 2 |
| 39 | }; |
| 40 | |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 41 | enum hdmi_core_hdmi_dvi { |
| 42 | HDMI_DVI = 0, |
| 43 | HDMI_HDMI = 1 |
| 44 | }; |
| 45 | |
| 46 | enum hdmi_clk_refsel { |
| 47 | HDMI_REFSEL_PCLK = 0, |
| 48 | HDMI_REFSEL_REF1 = 1, |
| 49 | HDMI_REFSEL_REF2 = 2, |
| 50 | HDMI_REFSEL_SYSCLK = 3 |
| 51 | }; |
| 52 | |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame^] | 53 | enum hdmi_packing_mode { |
| 54 | HDMI_PACK_10b_RGB_YUV444 = 0, |
| 55 | HDMI_PACK_24b_RGB_YUV444_YUV422 = 1, |
| 56 | HDMI_PACK_20b_YUV422 = 2, |
| 57 | HDMI_PACK_ALREADYPACKED = 7 |
| 58 | }; |
| 59 | |
| 60 | enum hdmi_stereo_channels { |
| 61 | HDMI_AUDIO_STEREO_NOCHANNELS = 0, |
| 62 | HDMI_AUDIO_STEREO_ONECHANNEL = 1, |
| 63 | HDMI_AUDIO_STEREO_TWOCHANNELS = 2, |
| 64 | HDMI_AUDIO_STEREO_THREECHANNELS = 3, |
| 65 | HDMI_AUDIO_STEREO_FOURCHANNELS = 4 |
| 66 | }; |
| 67 | |
| 68 | enum hdmi_audio_type { |
| 69 | HDMI_AUDIO_TYPE_LPCM = 0, |
| 70 | HDMI_AUDIO_TYPE_IEC = 1 |
| 71 | }; |
| 72 | |
| 73 | enum hdmi_audio_justify { |
| 74 | HDMI_AUDIO_JUSTIFY_LEFT = 0, |
| 75 | HDMI_AUDIO_JUSTIFY_RIGHT = 1 |
| 76 | }; |
| 77 | |
| 78 | enum hdmi_audio_sample_order { |
| 79 | HDMI_AUDIO_SAMPLE_RIGHT_FIRST = 0, |
| 80 | HDMI_AUDIO_SAMPLE_LEFT_FIRST = 1 |
| 81 | }; |
| 82 | |
| 83 | enum hdmi_audio_samples_perword { |
| 84 | HDMI_AUDIO_ONEWORD_ONESAMPLE = 0, |
| 85 | HDMI_AUDIO_ONEWORD_TWOSAMPLES = 1 |
| 86 | }; |
| 87 | |
| 88 | enum hdmi_audio_sample_size { |
| 89 | HDMI_AUDIO_SAMPLE_16BITS = 0, |
| 90 | HDMI_AUDIO_SAMPLE_24BITS = 1 |
| 91 | }; |
| 92 | |
| 93 | enum hdmi_audio_transf_mode { |
| 94 | HDMI_AUDIO_TRANSF_DMA = 0, |
| 95 | HDMI_AUDIO_TRANSF_IRQ = 1 |
| 96 | }; |
| 97 | |
| 98 | enum hdmi_audio_blk_strt_end_sig { |
| 99 | HDMI_AUDIO_BLOCK_SIG_STARTEND_ON = 0, |
| 100 | HDMI_AUDIO_BLOCK_SIG_STARTEND_OFF = 1 |
| 101 | }; |
| 102 | |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 103 | struct hdmi_cm { |
| 104 | int code; |
| 105 | int mode; |
| 106 | }; |
| 107 | |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame^] | 108 | struct hdmi_video_format { |
| 109 | enum hdmi_packing_mode packing_mode; |
| 110 | u32 y_res; /* Line per panel */ |
| 111 | u32 x_res; /* pixel per line */ |
| 112 | }; |
| 113 | |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 114 | struct hdmi_config { |
Archit Taneja | cc937e5 | 2012-06-24 13:08:10 +0530 | [diff] [blame] | 115 | struct omap_video_timings timings; |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 116 | struct hdmi_cm cm; |
| 117 | }; |
| 118 | |
| 119 | /* HDMI PLL structure */ |
| 120 | struct hdmi_pll_info { |
| 121 | u16 regn; |
| 122 | u16 regm; |
| 123 | u32 regmf; |
| 124 | u16 regm2; |
| 125 | u16 regsd; |
| 126 | u16 dcofreq; |
| 127 | enum hdmi_clk_refsel refsel; |
| 128 | }; |
| 129 | |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame^] | 130 | struct hdmi_audio_format { |
| 131 | enum hdmi_stereo_channels stereo_channels; |
| 132 | u8 active_chnnls_msk; |
| 133 | enum hdmi_audio_type type; |
| 134 | enum hdmi_audio_justify justification; |
| 135 | enum hdmi_audio_sample_order sample_order; |
| 136 | enum hdmi_audio_samples_perword samples_per_word; |
| 137 | enum hdmi_audio_sample_size sample_size; |
| 138 | enum hdmi_audio_blk_strt_end_sig en_sig_blk_strt_end; |
| 139 | }; |
| 140 | |
| 141 | struct hdmi_audio_dma { |
| 142 | u8 transfer_size; |
| 143 | u8 block_size; |
| 144 | enum hdmi_audio_transf_mode mode; |
| 145 | u16 fifo_threshold; |
| 146 | }; |
| 147 | |
Mythri P K | 60634a2 | 2011-09-08 19:06:26 +0530 | [diff] [blame] | 148 | struct ti_hdmi_ip_ops { |
| 149 | |
| 150 | void (*video_configure)(struct hdmi_ip_data *ip_data); |
| 151 | |
| 152 | int (*phy_enable)(struct hdmi_ip_data *ip_data); |
| 153 | |
| 154 | void (*phy_disable)(struct hdmi_ip_data *ip_data); |
| 155 | |
Tomi Valkeinen | 937fce1 | 2011-08-31 11:12:40 +0300 | [diff] [blame] | 156 | int (*read_edid)(struct hdmi_ip_data *ip_data, u8 *edid, int len); |
Mythri P K | 60634a2 | 2011-09-08 19:06:26 +0530 | [diff] [blame] | 157 | |
| 158 | int (*pll_enable)(struct hdmi_ip_data *ip_data); |
| 159 | |
| 160 | void (*pll_disable)(struct hdmi_ip_data *ip_data); |
| 161 | |
Mythri P K | 162874d | 2011-09-22 13:37:45 +0530 | [diff] [blame] | 162 | void (*dump_core)(struct hdmi_ip_data *ip_data, struct seq_file *s); |
| 163 | |
| 164 | void (*dump_pll)(struct hdmi_ip_data *ip_data, struct seq_file *s); |
| 165 | |
| 166 | void (*dump_phy)(struct hdmi_ip_data *ip_data, struct seq_file *s); |
| 167 | |
Ricardo Neri | 7e151f7 | 2012-03-15 14:08:03 -0600 | [diff] [blame] | 168 | #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO) |
Axel Castaneda Gonzalez | 3df9fb5 | 2012-05-03 09:00:21 -0500 | [diff] [blame] | 169 | int (*audio_start)(struct hdmi_ip_data *ip_data); |
| 170 | |
| 171 | void (*audio_stop)(struct hdmi_ip_data *ip_data); |
Ricardo Neri | 6ec355d | 2012-03-21 12:38:15 -0600 | [diff] [blame] | 172 | |
| 173 | int (*audio_config)(struct hdmi_ip_data *ip_data, |
| 174 | struct omap_dss_audio *audio); |
Ricardo Neri | d7b6f44 | 2012-11-06 00:19:16 -0600 | [diff] [blame] | 175 | |
| 176 | int (*audio_get_dma_port)(u32 *offset, u32 *size); |
Ricardo Neri | 80a4859 | 2011-11-27 16:09:58 -0600 | [diff] [blame] | 177 | #endif |
| 178 | |
Mythri P K | 60634a2 | 2011-09-08 19:06:26 +0530 | [diff] [blame] | 179 | }; |
| 180 | |
Mythri P K | da8f14f | 2012-02-08 11:54:19 +0530 | [diff] [blame] | 181 | /* |
| 182 | * Refer to section 8.2 in HDMI 1.3 specification for |
| 183 | * details about infoframe databytes |
| 184 | */ |
| 185 | struct hdmi_core_infoframe_avi { |
| 186 | /* Y0, Y1 rgb,yCbCr */ |
| 187 | u8 db1_format; |
| 188 | /* A0 Active information Present */ |
| 189 | u8 db1_active_info; |
| 190 | /* B0, B1 Bar info data valid */ |
| 191 | u8 db1_bar_info_dv; |
| 192 | /* S0, S1 scan information */ |
| 193 | u8 db1_scan_info; |
| 194 | /* C0, C1 colorimetry */ |
| 195 | u8 db2_colorimetry; |
| 196 | /* M0, M1 Aspect ratio (4:3, 16:9) */ |
| 197 | u8 db2_aspect_ratio; |
| 198 | /* R0...R3 Active format aspect ratio */ |
| 199 | u8 db2_active_fmt_ar; |
| 200 | /* ITC IT content. */ |
| 201 | u8 db3_itc; |
| 202 | /* EC0, EC1, EC2 Extended colorimetry */ |
| 203 | u8 db3_ec; |
| 204 | /* Q1, Q0 Quantization range */ |
| 205 | u8 db3_q_range; |
| 206 | /* SC1, SC0 Non-uniform picture scaling */ |
| 207 | u8 db3_nup_scaling; |
| 208 | /* VIC0..6 Video format identification */ |
| 209 | u8 db4_videocode; |
| 210 | /* PR0..PR3 Pixel repetition factor */ |
| 211 | u8 db5_pixel_repeat; |
| 212 | /* Line number end of top bar */ |
| 213 | u16 db6_7_line_eoftop; |
| 214 | /* Line number start of bottom bar */ |
| 215 | u16 db8_9_line_sofbottom; |
| 216 | /* Pixel number end of left bar */ |
| 217 | u16 db10_11_pixel_eofleft; |
| 218 | /* Pixel number start of right bar */ |
| 219 | u16 db12_13_pixel_sofright; |
| 220 | }; |
| 221 | |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame^] | 222 | struct hdmi_wp_data { |
| 223 | void __iomem *base; |
| 224 | }; |
| 225 | |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 226 | struct hdmi_ip_data { |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame^] | 227 | struct hdmi_wp_data wp; |
| 228 | |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 229 | unsigned long core_sys_offset; |
| 230 | unsigned long core_av_offset; |
| 231 | unsigned long pll_offset; |
| 232 | unsigned long phy_offset; |
Tomi Valkeinen | ddb1d5c | 2013-06-06 13:08:35 +0300 | [diff] [blame] | 233 | int irq; |
Mythri P K | 60634a2 | 2011-09-08 19:06:26 +0530 | [diff] [blame] | 234 | const struct ti_hdmi_ip_ops *ops; |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 235 | struct hdmi_config cfg; |
| 236 | struct hdmi_pll_info pll_data; |
Mythri P K | da8f14f | 2012-02-08 11:54:19 +0530 | [diff] [blame] | 237 | struct hdmi_core_infoframe_avi avi_cfg; |
Tomi Valkeinen | c49d005 | 2012-01-17 11:09:57 +0200 | [diff] [blame] | 238 | |
| 239 | /* ti_hdmi_4xxx_ip private data. These should be in a separate struct */ |
Jassi Brar | 3a5383a | 2012-06-27 19:34:56 +0530 | [diff] [blame] | 240 | struct mutex lock; |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 241 | }; |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame^] | 242 | |
| 243 | /* HDMI wrapper funcs */ |
| 244 | int hdmi_wp_video_start(struct hdmi_wp_data *wp); |
| 245 | void hdmi_wp_video_stop(struct hdmi_wp_data *wp); |
| 246 | void hdmi_wp_dump(struct hdmi_wp_data *wp, struct seq_file *s); |
| 247 | u32 hdmi_wp_get_irqstatus(struct hdmi_wp_data *wp); |
| 248 | void hdmi_wp_set_irqstatus(struct hdmi_wp_data *wp, u32 irqstatus); |
| 249 | void hdmi_wp_set_irqenable(struct hdmi_wp_data *wp, u32 mask); |
| 250 | void hdmi_wp_clear_irqenable(struct hdmi_wp_data *wp, u32 mask); |
| 251 | int hdmi_wp_set_phy_pwr(struct hdmi_wp_data *wp, enum hdmi_phy_pwr val); |
| 252 | int hdmi_wp_set_pll_pwr(struct hdmi_wp_data *wp, enum hdmi_pll_pwr val); |
| 253 | void hdmi_wp_video_config_format(struct hdmi_wp_data *wp, |
| 254 | struct hdmi_video_format *video_fmt); |
| 255 | void hdmi_wp_video_config_interface(struct hdmi_wp_data *wp, |
| 256 | struct omap_video_timings *timings); |
| 257 | void hdmi_wp_video_config_timing(struct hdmi_wp_data *wp, |
| 258 | struct omap_video_timings *timings); |
| 259 | void hdmi_wp_init_vid_fmt_timings(struct hdmi_video_format *video_fmt, |
| 260 | struct omap_video_timings *timings, struct hdmi_config *param); |
| 261 | int hdmi_wp_init(struct platform_device *pdev, struct hdmi_wp_data *wp); |
| 262 | |
Mythri P K | 176b578 | 2011-09-08 19:06:25 +0530 | [diff] [blame] | 263 | int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data); |
| 264 | void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data); |
Tomi Valkeinen | 937fce1 | 2011-08-31 11:12:40 +0300 | [diff] [blame] | 265 | int ti_hdmi_4xxx_read_edid(struct hdmi_ip_data *ip_data, u8 *edid, int len); |
Mythri P K | 176b578 | 2011-09-08 19:06:25 +0530 | [diff] [blame] | 266 | int ti_hdmi_4xxx_pll_enable(struct hdmi_ip_data *ip_data); |
| 267 | void ti_hdmi_4xxx_pll_disable(struct hdmi_ip_data *ip_data); |
| 268 | void ti_hdmi_4xxx_basic_configure(struct hdmi_ip_data *ip_data); |
Mythri P K | 162874d | 2011-09-22 13:37:45 +0530 | [diff] [blame] | 269 | void ti_hdmi_4xxx_pll_dump(struct hdmi_ip_data *ip_data, struct seq_file *s); |
| 270 | void ti_hdmi_4xxx_core_dump(struct hdmi_ip_data *ip_data, struct seq_file *s); |
| 271 | void ti_hdmi_4xxx_phy_dump(struct hdmi_ip_data *ip_data, struct seq_file *s); |
Ricardo Neri | 7e151f7 | 2012-03-15 14:08:03 -0600 | [diff] [blame] | 272 | #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO) |
Ricardo Neri | 3554762 | 2012-03-20 21:02:01 -0600 | [diff] [blame] | 273 | int hdmi_compute_acr(u32 sample_freq, u32 *n, u32 *cts); |
Archit Taneja | f382d9e | 2013-08-06 14:56:55 +0530 | [diff] [blame^] | 274 | int hdmi_wp_audio_enable(struct hdmi_wp_data *wp, bool enable); |
| 275 | int hdmi_wp_audio_core_req_enable(struct hdmi_wp_data *wp, bool enable); |
| 276 | void hdmi_wp_audio_config_format(struct hdmi_wp_data *wp, |
| 277 | struct hdmi_audio_format *aud_fmt); |
| 278 | void hdmi_wp_audio_config_dma(struct hdmi_wp_data *wp, |
| 279 | struct hdmi_audio_dma *aud_dma); |
Axel Castaneda Gonzalez | 3df9fb5 | 2012-05-03 09:00:21 -0500 | [diff] [blame] | 280 | int ti_hdmi_4xxx_audio_start(struct hdmi_ip_data *ip_data); |
| 281 | void ti_hdmi_4xxx_audio_stop(struct hdmi_ip_data *ip_data); |
Ricardo Neri | 6ec355d | 2012-03-21 12:38:15 -0600 | [diff] [blame] | 282 | int ti_hdmi_4xxx_audio_config(struct hdmi_ip_data *ip_data, |
| 283 | struct omap_dss_audio *audio); |
Ricardo Neri | d7b6f44 | 2012-11-06 00:19:16 -0600 | [diff] [blame] | 284 | int ti_hdmi_4xxx_audio_get_dma_port(u32 *offset, u32 *size); |
Ricardo Neri | 80a4859 | 2011-11-27 16:09:58 -0600 | [diff] [blame] | 285 | #endif |
Mythri P K | 94c5298 | 2011-09-08 19:06:21 +0530 | [diff] [blame] | 286 | #endif |