blob: fb9da4c2c13719251a076107978af86de8bf55f0 [file] [log] [blame]
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +05301/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
Shashank Mittal4bfb2e32012-04-16 10:56:27 -07002 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -080012 * * Neither the name of The Linux Foundation nor the names of its
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070013 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#ifndef _PLATFORM_MSM_SHARED_MSM_PANEL_H_
31#define _PLATFORM_MSM_SHARED_MSM_PANEL_H_
32
Channagoud Kadabifb6ff7e2015-07-13 20:13:05 -070033#include <sys/types.h>
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070034#include <stdint.h>
35#include <dev/fbcon.h>
Ujwal Patel41a665a2015-07-17 13:51:30 -070036#include <sys/types.h>
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070037
Padmanabhan Komandurueb5bf6c2016-02-29 18:54:35 +053038#define DFPS_MAX_FRAME_RATE 20
Huaibin Yangb9f15e52015-01-22 10:34:47 -080039#define DFPS_PLL_CODES_SIZE 0x1000 /* One page */
Huaibin Yang88540b32014-11-07 13:59:54 -080040
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070041/* panel type list */
42#define NO_PANEL 0xffff /* No Panel */
43#define MDDI_PANEL 1 /* MDDI */
44#define EBI2_PANEL 2 /* EBI2 */
45#define LCDC_PANEL 3 /* internal LCDC type */
46#define EXT_MDDI_PANEL 4 /* Ext.MDDI */
47#define TV_PANEL 5 /* TV */
48#define HDMI_PANEL 6 /* HDMI TV */
49#define DTV_PANEL 7 /* DTV */
50#define MIPI_VIDEO_PANEL 8 /* MIPI */
51#define MIPI_CMD_PANEL 9 /* MIPI */
52#define WRITEBACK_PANEL 10 /* Wifi display */
53#define LVDS_PANEL 11 /* LVDS */
Asaf Pensob8f524c2013-05-20 12:32:31 +030054#define EDP_PANEL 12 /* EDP */
Zohaib Alamb7b677f2014-10-24 15:54:42 -040055#define QPIC_PANEL 13 /* QPIC */
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070056
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -080057#define DISPLAY_UNKNOWN 0
58#define DISPLAY_1 1
59#define DISPLAY_2 2
60
Jayant Shekhar03e1a222014-05-22 11:03:53 +053061enum mdss_mdp_pipe_type {
62 MDSS_MDP_PIPE_TYPE_VIG,
63 MDSS_MDP_PIPE_TYPE_RGB,
64 MDSS_MDP_PIPE_TYPE_DMA,
65};
66
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070067enum msm_mdp_hw_revision {
68 MDP_REV_20 = 1,
69 MDP_REV_22,
70 MDP_REV_30,
71 MDP_REV_303,
Terence Hampsonf49ff4e2013-06-18 15:11:31 -040072 MDP_REV_304,
Shivaraj Shettyf9e10c42014-09-17 04:21:15 +053073 MDP_REV_305,
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070074 MDP_REV_31,
75 MDP_REV_40,
76 MDP_REV_41,
77 MDP_REV_42,
78 MDP_REV_43,
79 MDP_REV_44,
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -080080 MDP_REV_50,
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070081};
82
83/* panel info type */
84struct lcd_panel_info {
85 uint32_t vsync_enable;
86 uint32_t refx100;
87 uint32_t v_back_porch;
88 uint32_t v_front_porch;
89 uint32_t v_pulse_width;
90 uint32_t hw_vsync_mode;
91 uint32_t vsync_notifier_period;
92 uint32_t rev;
93};
94
Ajay Singh Parmar7c1cd522013-02-13 20:33:49 +053095struct hdmi_panel_info {
96 uint32_t h_back_porch;
97 uint32_t h_front_porch;
98 uint32_t h_pulse_width;
99 uint32_t v_back_porch;
100 uint32_t v_front_porch;
101 uint32_t v_pulse_width;
102};
103
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700104struct lcdc_panel_info {
105 uint32_t h_back_porch;
106 uint32_t h_front_porch;
107 uint32_t h_pulse_width;
108 uint32_t v_back_porch;
109 uint32_t v_front_porch;
110 uint32_t v_pulse_width;
111 uint32_t border_clr;
112 uint32_t underflow_clr;
113 uint32_t hsync_skew;
114 /* Pad width */
115 uint32_t xres_pad;
116 /* Pad height */
117 uint32_t yres_pad;
Siddhartha Agrawal547ce4a2013-05-23 14:10:43 -0700118 uint8_t dual_pipe;
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700119 uint8_t split_display;
Siddhartha Agrawal6ef1e222013-06-12 18:24:58 -0700120 uint8_t pipe_swap;
Vineet Bajaj4effb132014-07-24 16:55:41 +0530121 uint8_t dst_split;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700122};
123
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700124enum {
125 COMPRESSION_NONE,
126 COMPRESSION_DSC,
127 COMPRESSION_FBC
128};
129
130#define DCS_HDR_LEN 4
131#define DSC_PPS_LEN 128
132
133struct msm_panel_info;
134
135struct dsc_desc {
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700136 int initial_lines;
137 int slice_last_group_size;
138 int bpp; /* target bit per pixel */
139 int bpc; /* bit per component */
140 int line_buf_depth;
141 int config_by_manufacture_cmd;
142 int block_pred_enable;
143 int vbr_enable;
144 int enable_422;
145 int convert_rgb;
146 int input_10_bits;
147 int slice_per_pkt;
148
149 int major;
150 int minor;
151 int pps_id;
152
153 int pic_height;
154 int pic_width;
155 int slice_height;
156 int slice_width;
157 int chunk_size;
158
159 int pkt_per_line;
160 int bytes_in_slice;
161 int bytes_per_pkt;
162 int eol_byte_num;
163 int pclk_per_line; /* width */
164
165 int initial_dec_delay;
166 int initial_xmit_delay;
167
168 int initial_scale_value;
169 int scale_decrement_interval;
170 int scale_increment_interval;
171
172 int first_line_bpg_offset;
173 int nfl_bpg_offset;
174 int slice_bpg_offset;
175
176 int initial_offset;
177 int final_offset;
178
179 int rc_model_size; /* rate_buffer_size */
180
181 int det_thresh_flatness;
182 int max_qp_flatness;
183 int min_qp_flatness;
184 int edge_factor;
185 int quant_incr_limit0;
186 int quant_incr_limit1;
187 int tgt_offset_hi;
188 int tgt_offset_lo;
189 char *buf_thresh;
190 char *range_min_qp;
191 char *range_max_qp;
192 char *range_bpg_offset;
193 char pps_buf[DCS_HDR_LEN + DSC_PPS_LEN];
194
195 void (*parameter_calc) (struct msm_panel_info *pinfo);
196 int (*dsc2buf) (struct msm_panel_info *pinfo);
197 void (*dsi_dsc_config) (uint32_t base, int mode, struct dsc_desc *dsc);
Ujwal Patel41a665a2015-07-17 13:51:30 -0700198 void (*mdp_dsc_config) (struct msm_panel_info *pinfo,
199 unsigned int pp_base, unsigned int dsc_base,
200 bool mux, bool split_mode);
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700201};
202
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700203struct fbc_panel_info {
204 uint32_t enabled;
205 uint32_t comp_ratio;
206 uint32_t comp_mode;
207 uint32_t qerr_enable;
208 uint32_t cd_bias;
209 uint32_t pat_enable;
210 uint32_t vlc_enable;
211 uint32_t bflc_enable;
212
213 uint32_t line_x_budget;
214 uint32_t block_x_budget;
215 uint32_t block_budget;
216
217 uint32_t lossless_mode_thd;
218 uint32_t lossy_mode_thd;
219 uint32_t lossy_rgb_thd;
220 uint32_t lossy_mode_idx;
Jeevan Shriram1b07e372014-11-30 22:03:50 -0800221
222 uint32_t slice_height;
223 uint32_t pred_mode;
224 uint32_t max_pred_err;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700225};
226
Huaibin Yang88540b32014-11-07 13:59:54 -0800227
228struct dfps_panel_info {
229 uint32_t enabled;
230 uint32_t frame_rate_cnt;
231 uint32_t frame_rate[DFPS_MAX_FRAME_RATE];
232};
233
234struct dfps_pll_codes {
235 uint32_t codes[2];
236};
237
238struct dfps_codes_info {
239 uint32_t is_valid;
240 uint32_t frame_rate;
241 uint32_t clk_rate;
242 struct dfps_pll_codes pll_codes;
243};
244
245struct dfps_info {
246 struct dfps_panel_info panel_dfps;
247 struct dfps_codes_info codes_dfps[DFPS_MAX_FRAME_RATE];
248 void *dfps_fb_base;
249};
250
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700251/* intf timing settings */
252struct intf_timing_params {
253 uint32_t width;
254 uint32_t height;
255 uint32_t xres;
256 uint32_t yres;
257
258 uint32_t h_back_porch;
259 uint32_t h_front_porch;
260 uint32_t v_back_porch;
261 uint32_t v_front_porch;
262 uint32_t hsync_pulse_width;
263 uint32_t vsync_pulse_width;
264
265 uint32_t border_clr;
266 uint32_t underflow_clr;
267 uint32_t hsync_skew;
268};
269
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700270struct mipi_panel_info {
Siddhartha Agrawal007ea9e2014-10-14 15:02:48 -0700271 char cmds_post_tg; /* send on commands after tg on */
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700272 char mode; /* video/cmd */
273 char interleave_mode;
Arpita Banerjeef1a8ac92013-05-21 10:09:35 -0700274 int eof_bllp_power;
Arpita Banerjee2522bc62013-05-24 16:03:53 -0700275 uint32_t bitclock;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700276 char crc_check;
277 char ecc_check;
278 char dst_format; /* shared by video and command */
279 char num_of_lanes;
280 char data_lane0;
281 char data_lane1;
282 char data_lane2;
283 char data_lane3;
284 char dlane_swap; /* data lane swap */
285 char rgb_swap;
286 char b_sel;
287 char g_sel;
288 char r_sel;
289 char rx_eot_ignore;
290 char tx_eot_append;
291 char t_clk_post; /* 0xc0, DSI_CLKOUT_TIMING_CTRL */
292 char t_clk_pre; /* 0xc0, DSI_CLKOUT_TIMING_CTRL */
293 char vc; /* virtual channel */
294 struct mipi_dsi_phy_ctrl *dsi_phy_db;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800295 struct mdss_dsi_phy_ctrl *mdss_dsi_phy_db;
Arpita Banerjee2522bc62013-05-24 16:03:53 -0700296 struct mdss_dsi_pll_config *dsi_pll_config;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530297 struct mipi_dsi_cmd *panel_on_cmds;
298 int num_of_panel_on_cmds;
299 struct mipi_dsi_cmd *panel_off_cmds;
300 int num_of_panel_off_cmds;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700301 /* video mode */
302 char pulse_mode_hsa_he;
303 char hfp_power_stop;
304 char hbp_power_stop;
305 char hsa_power_stop;
306 char eof_bllp_power_stop;
307 char bllp_power_stop;
308 char traffic_mode;
309 char frame_rate;
310 /* command mode */
311 char interleave_max;
312 char insert_dcs_cmd;
313 char wr_mem_continue;
314 char wr_mem_start;
315 char te_sel;
316 char stream; /* 0 or 1 */
317 char mdp_trigger;
318 char dma_trigger;
319 uint32_t dsi_pclk_rate;
320 /* The packet-size should not bet changed */
321 char no_max_pkt_size;
322 /* Clock required during LP commands */
323 char force_clk_lane_hs;
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530324 char lane_swap;
Siddhartha Agrawal547ce4a2013-05-23 14:10:43 -0700325 uint8_t dual_dsi;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700326 uint8_t use_dsi1_pll;
Siddhartha Agrawal547ce4a2013-05-23 14:10:43 -0700327 uint8_t broadcast;
Dhaval Patel940e09c2013-08-08 20:47:05 -0700328 uint8_t mode_gpio_state;
Casey Piper84036752013-09-05 14:56:37 -0700329 uint32_t signature;
Aravind Venkateswaran27338a92013-11-04 17:27:05 -0800330 uint32_t use_enable_gpio;
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800331 uint32_t ctl_base;
332 uint32_t phy_base;
333 uint32_t sctl_base;
334 uint32_t sphy_base;
Jeevan Shriram01379322015-01-07 17:41:26 -0800335 uint32_t reg_base;
336 uint32_t sreg_base;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700337 uint32_t pll_base;
338 uint32_t spll_base;
Huaibin Yang88540b32014-11-07 13:59:54 -0800339
340 struct dfps_pll_codes pll_codes;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700341};
342
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700343struct edp_panel_info {
344 int max_lane_count;
345 unsigned long max_link_clk;
346};
347
Vineet Bajajc2272462015-05-07 17:35:03 +0530348struct dsi2HDMI_panel_info {
349 struct mipi_dsi_i2c_cmd *dsi_tg_i2c_cmd;
350 struct mipi_dsi_i2c_cmd *dsi_setup_cfg_i2c_cmd;
351 int num_of_tg_i2c_cmds;
352 int num_of_cfg_i2c_cmds;
353};
354
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700355enum lvds_mode {
356 LVDS_SINGLE_CHANNEL_MODE,
357 LVDS_DUAL_CHANNEL_MODE,
358};
359
360struct lvds_panel_info {
361 enum lvds_mode channel_mode;
362 /* Channel swap in dual mode */
363 char channel_swap;
364};
365
Kuogee Hsieh9747d9e2014-12-05 15:42:11 -0800366struct labibb_desc {
367 char amoled_panel; /* lcd = 0, amoled = 1*/
368 char force_config; /* 0 to use default value */
369 uint32_t ibb_min_volt;
370 uint32_t ibb_max_volt;
371 uint32_t lab_min_volt;
372 uint32_t lab_max_volt;
373 char pwr_up_delay; /* ndx to => 1250, 2500, 5000 and 10000 us */
374 char pwr_down_delay; /* ndx to => 1250, 2500, 5000 and 10000 us */
375 char ibb_discharge_en;
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530376 bool swire_control;
Kuogee Hsieh9747d9e2014-12-05 15:42:11 -0800377};
378
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700379struct msm_panel_info {
380 uint32_t xres;
381 uint32_t yres;
382 uint32_t bpp;
383 uint32_t type;
384 uint32_t wait_cycle;
385 uint32_t clk_rate;
Prashant Nukala64eeff92014-07-11 07:35:34 +0530386 uint32_t orientation;
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800387 uint32_t dest;
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700388 uint32_t compression_mode;
Jayant Shekhar03e1a222014-05-22 11:03:53 +0530389 /* Select pipe type for handoff */
390 uint32_t pipe_type;
Arpita Banerjeef1a8ac92013-05-21 10:09:35 -0700391 char lowpowerstop;
Kuogee Hsieh208736d2014-08-22 14:16:55 -0700392 char lcd_reg_en;
Kuogee Hsieh31b4ff92014-10-22 14:55:42 -0700393 uint32_t border_top;
394 uint32_t border_bottom;
395 uint32_t border_left;
396 uint32_t border_right;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700397
Ujwal Patel41a665a2015-07-17 13:51:30 -0700398 int lm_split[2];
399 int num_dsc_enc;
400
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700401 struct lcd_panel_info lcd;
402 struct lcdc_panel_info lcdc;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700403 struct fbc_panel_info fbc;
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700404 struct dsc_desc dsc;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700405 struct mipi_panel_info mipi;
406 struct lvds_panel_info lvds;
Ajay Singh Parmar7c1cd522013-02-13 20:33:49 +0530407 struct hdmi_panel_info hdmi;
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700408 struct edp_panel_info edp;
Vineet Bajajc2272462015-05-07 17:35:03 +0530409 struct dsi2HDMI_panel_info adv7533;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700410
Huaibin Yang88540b32014-11-07 13:59:54 -0800411 struct dfps_info dfps;
412
Kuogee Hsieh9747d9e2014-12-05 15:42:11 -0800413 struct labibb_desc *labibb;
414
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700415 int (*on) (void);
416 int (*off) (void);
Dhaval Patelaa081d32013-10-25 13:47:46 -0700417 int (*pre_on) (void);
418 int (*pre_off) (void);
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700419 int (*prepare) (void);
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300420 int (*early_config) (void *pdata);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700421 int (*config) (void *pdata);
Channagoud Kadabi01c91822012-06-06 15:53:30 +0530422 int (*rotate) (void);
Sandeep Panda6c24af72015-12-23 15:36:07 +0530423
424 char autorefresh_enable;
425 uint32_t autorefresh_framenum;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700426};
427
428struct msm_fb_panel_data {
429 struct msm_panel_info panel_info;
430 struct fbcon_config fb;
431 int mdp_rev;
Channagoud Kadabi01c91822012-06-06 15:53:30 +0530432 int rotate;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700433
434 /* function entry chain */
Veera Sundaram Sankarandb0b2bf2014-12-16 18:09:27 -0800435 int (*power_func) (uint8_t enable, struct msm_panel_info *);
436 uint32_t (*clk_func) (uint8_t enable, struct msm_panel_info *pinfo);
437 int (*bl_func) (uint8_t enable);
438 uint32_t (*pll_clk_func) (uint8_t enable, struct msm_panel_info *);
Huaibin Yang88540b32014-11-07 13:59:54 -0800439 int (*dfps_func)(struct msm_panel_info *);
Jayant Shekhare2e6b712013-11-20 16:54:20 +0530440 int (*post_power_func)(int enable);
Ray Zhang4c7e37f2013-12-03 17:04:55 +0800441 int (*pre_init_func)(void);
Casey Piper6c2f1132015-03-24 11:37:19 -0700442 int (*update_panel_info) (void);
Vineet Bajajc2272462015-05-07 17:35:03 +0530443 int (*dsi2HDMI_config) (struct msm_panel_info *);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700444};
445
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700446#endif