blob: 6ca84acbf410d38822082aaa430b8d19b81b0a30 [file] [log] [blame]
Wenjun Zhang4e63ce42017-11-28 05:11:34 -05001/* Copyright (c) 2012-2018, 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 */
Wenjun Zhang4e63ce42017-11-28 05:11:34 -050056#define SPI_PANEL 14
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070057
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -080058#define DISPLAY_UNKNOWN 0
59#define DISPLAY_1 1
60#define DISPLAY_2 2
61
Jayant Shekhar03e1a222014-05-22 11:03:53 +053062enum mdss_mdp_pipe_type {
63 MDSS_MDP_PIPE_TYPE_VIG,
64 MDSS_MDP_PIPE_TYPE_RGB,
65 MDSS_MDP_PIPE_TYPE_DMA,
66};
67
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070068enum msm_mdp_hw_revision {
69 MDP_REV_20 = 1,
70 MDP_REV_22,
71 MDP_REV_30,
72 MDP_REV_303,
Terence Hampsonf49ff4e2013-06-18 15:11:31 -040073 MDP_REV_304,
Shivaraj Shettyf9e10c42014-09-17 04:21:15 +053074 MDP_REV_305,
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070075 MDP_REV_31,
76 MDP_REV_40,
77 MDP_REV_41,
78 MDP_REV_42,
79 MDP_REV_43,
80 MDP_REV_44,
Siddhartha Agrawal7e2e2152013-01-23 17:06:58 -080081 MDP_REV_50,
Shashank Mittal4bfb2e32012-04-16 10:56:27 -070082};
83
84/* panel info type */
85struct lcd_panel_info {
86 uint32_t vsync_enable;
87 uint32_t refx100;
88 uint32_t v_back_porch;
89 uint32_t v_front_porch;
90 uint32_t v_pulse_width;
91 uint32_t hw_vsync_mode;
92 uint32_t vsync_notifier_period;
93 uint32_t rev;
94};
95
Wenjun Zhang4e63ce42017-11-28 05:11:34 -050096struct mdss_spi_cmd {
97 int size;
98 char *payload;
99 int wait;
100 uint8_t cmds_post_tg;
101};
102
103struct spi_panel_info {
104 int num_of_panel_cmds;
105 struct mdss_spi_cmd *panel_cmds;
106 uint8_t *signature_addr;
107 uint8_t *signature;
108 uint8_t *signature_len;
109};
110
Ajay Singh Parmar7c1cd522013-02-13 20:33:49 +0530111struct hdmi_panel_info {
112 uint32_t h_back_porch;
113 uint32_t h_front_porch;
114 uint32_t h_pulse_width;
115 uint32_t v_back_porch;
116 uint32_t v_front_porch;
117 uint32_t v_pulse_width;
118};
119
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700120struct lcdc_panel_info {
121 uint32_t h_back_porch;
122 uint32_t h_front_porch;
123 uint32_t h_pulse_width;
124 uint32_t v_back_porch;
125 uint32_t v_front_porch;
126 uint32_t v_pulse_width;
127 uint32_t border_clr;
128 uint32_t underflow_clr;
129 uint32_t hsync_skew;
130 /* Pad width */
131 uint32_t xres_pad;
132 /* Pad height */
133 uint32_t yres_pad;
Siddhartha Agrawal547ce4a2013-05-23 14:10:43 -0700134 uint8_t dual_pipe;
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700135 uint8_t split_display;
Siddhartha Agrawal6ef1e222013-06-12 18:24:58 -0700136 uint8_t pipe_swap;
Vineet Bajaj4effb132014-07-24 16:55:41 +0530137 uint8_t dst_split;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700138};
139
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700140enum {
141 COMPRESSION_NONE,
142 COMPRESSION_DSC,
143 COMPRESSION_FBC
144};
145
146#define DCS_HDR_LEN 4
147#define DSC_PPS_LEN 128
148
149struct msm_panel_info;
150
151struct dsc_desc {
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700152 int initial_lines;
153 int slice_last_group_size;
154 int bpp; /* target bit per pixel */
155 int bpc; /* bit per component */
156 int line_buf_depth;
157 int config_by_manufacture_cmd;
158 int block_pred_enable;
159 int vbr_enable;
160 int enable_422;
161 int convert_rgb;
162 int input_10_bits;
163 int slice_per_pkt;
164
165 int major;
166 int minor;
Dhaval Patelc4135d82016-03-30 17:40:53 -0700167 int scr_rev;
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700168 int pps_id;
169
170 int pic_height;
171 int pic_width;
172 int slice_height;
173 int slice_width;
174 int chunk_size;
175
176 int pkt_per_line;
177 int bytes_in_slice;
178 int bytes_per_pkt;
179 int eol_byte_num;
180 int pclk_per_line; /* width */
181
182 int initial_dec_delay;
183 int initial_xmit_delay;
184
185 int initial_scale_value;
186 int scale_decrement_interval;
187 int scale_increment_interval;
188
189 int first_line_bpg_offset;
190 int nfl_bpg_offset;
191 int slice_bpg_offset;
192
193 int initial_offset;
194 int final_offset;
195
196 int rc_model_size; /* rate_buffer_size */
197
198 int det_thresh_flatness;
199 int max_qp_flatness;
200 int min_qp_flatness;
201 int edge_factor;
202 int quant_incr_limit0;
203 int quant_incr_limit1;
204 int tgt_offset_hi;
205 int tgt_offset_lo;
206 char *buf_thresh;
207 char *range_min_qp;
208 char *range_max_qp;
209 char *range_bpg_offset;
210 char pps_buf[DCS_HDR_LEN + DSC_PPS_LEN];
211
212 void (*parameter_calc) (struct msm_panel_info *pinfo);
213 int (*dsc2buf) (struct msm_panel_info *pinfo);
214 void (*dsi_dsc_config) (uint32_t base, int mode, struct dsc_desc *dsc);
Ujwal Patel41a665a2015-07-17 13:51:30 -0700215 void (*mdp_dsc_config) (struct msm_panel_info *pinfo,
216 unsigned int pp_base, unsigned int dsc_base,
217 bool mux, bool split_mode);
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700218};
219
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700220struct fbc_panel_info {
221 uint32_t enabled;
222 uint32_t comp_ratio;
223 uint32_t comp_mode;
224 uint32_t qerr_enable;
225 uint32_t cd_bias;
226 uint32_t pat_enable;
227 uint32_t vlc_enable;
228 uint32_t bflc_enable;
229
230 uint32_t line_x_budget;
231 uint32_t block_x_budget;
232 uint32_t block_budget;
233
234 uint32_t lossless_mode_thd;
235 uint32_t lossy_mode_thd;
236 uint32_t lossy_rgb_thd;
237 uint32_t lossy_mode_idx;
Jeevan Shriram1b07e372014-11-30 22:03:50 -0800238
239 uint32_t slice_height;
240 uint32_t pred_mode;
241 uint32_t max_pred_err;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700242};
243
Huaibin Yang88540b32014-11-07 13:59:54 -0800244
245struct dfps_panel_info {
246 uint32_t enabled;
247 uint32_t frame_rate_cnt;
248 uint32_t frame_rate[DFPS_MAX_FRAME_RATE];
249};
250
251struct dfps_pll_codes {
252 uint32_t codes[2];
253};
254
255struct dfps_codes_info {
256 uint32_t is_valid;
257 uint32_t frame_rate;
258 uint32_t clk_rate;
259 struct dfps_pll_codes pll_codes;
260};
261
262struct dfps_info {
263 struct dfps_panel_info panel_dfps;
264 struct dfps_codes_info codes_dfps[DFPS_MAX_FRAME_RATE];
265 void *dfps_fb_base;
Ashish Garg342420a2017-04-24 18:00:12 +0530266 uint32_t chip_serial;
Huaibin Yang88540b32014-11-07 13:59:54 -0800267};
268
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700269/* intf timing settings */
270struct intf_timing_params {
271 uint32_t width;
272 uint32_t height;
273 uint32_t xres;
274 uint32_t yres;
275
276 uint32_t h_back_porch;
277 uint32_t h_front_porch;
278 uint32_t v_back_porch;
279 uint32_t v_front_porch;
280 uint32_t hsync_pulse_width;
281 uint32_t vsync_pulse_width;
282
283 uint32_t border_clr;
284 uint32_t underflow_clr;
285 uint32_t hsync_skew;
286};
287
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700288struct mipi_panel_info {
Siddhartha Agrawal007ea9e2014-10-14 15:02:48 -0700289 char cmds_post_tg; /* send on commands after tg on */
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700290 char mode; /* video/cmd */
291 char interleave_mode;
Arpita Banerjeef1a8ac92013-05-21 10:09:35 -0700292 int eof_bllp_power;
Arpita Banerjee2522bc62013-05-24 16:03:53 -0700293 uint32_t bitclock;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700294 char crc_check;
295 char ecc_check;
296 char dst_format; /* shared by video and command */
297 char num_of_lanes;
298 char data_lane0;
299 char data_lane1;
300 char data_lane2;
301 char data_lane3;
302 char dlane_swap; /* data lane swap */
303 char rgb_swap;
304 char b_sel;
305 char g_sel;
306 char r_sel;
307 char rx_eot_ignore;
308 char tx_eot_append;
309 char t_clk_post; /* 0xc0, DSI_CLKOUT_TIMING_CTRL */
310 char t_clk_pre; /* 0xc0, DSI_CLKOUT_TIMING_CTRL */
311 char vc; /* virtual channel */
312 struct mipi_dsi_phy_ctrl *dsi_phy_db;
Siddhartha Agrawal3e694ea2013-01-23 17:01:31 -0800313 struct mdss_dsi_phy_ctrl *mdss_dsi_phy_db;
Arpita Banerjee2522bc62013-05-24 16:03:53 -0700314 struct mdss_dsi_pll_config *dsi_pll_config;
Padmanabhan Komandurub3d31842014-11-04 15:47:53 +0530315 struct mipi_dsi_cmd *panel_on_cmds;
316 int num_of_panel_on_cmds;
317 struct mipi_dsi_cmd *panel_off_cmds;
318 int num_of_panel_off_cmds;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700319 /* video mode */
320 char pulse_mode_hsa_he;
321 char hfp_power_stop;
322 char hbp_power_stop;
323 char hsa_power_stop;
324 char eof_bllp_power_stop;
325 char bllp_power_stop;
326 char traffic_mode;
327 char frame_rate;
328 /* command mode */
329 char interleave_max;
330 char insert_dcs_cmd;
331 char wr_mem_continue;
332 char wr_mem_start;
333 char te_sel;
334 char stream; /* 0 or 1 */
335 char mdp_trigger;
336 char dma_trigger;
337 uint32_t dsi_pclk_rate;
338 /* The packet-size should not bet changed */
339 char no_max_pkt_size;
340 /* Clock required during LP commands */
341 char force_clk_lane_hs;
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530342 char lane_swap;
Siddhartha Agrawal547ce4a2013-05-23 14:10:43 -0700343 uint8_t dual_dsi;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700344 uint8_t use_dsi1_pll;
Siddhartha Agrawal547ce4a2013-05-23 14:10:43 -0700345 uint8_t broadcast;
Dhaval Patel940e09c2013-08-08 20:47:05 -0700346 uint8_t mode_gpio_state;
Casey Piper84036752013-09-05 14:56:37 -0700347 uint32_t signature;
Aravind Venkateswaran27338a92013-11-04 17:27:05 -0800348 uint32_t use_enable_gpio;
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800349 uint32_t ctl_base;
350 uint32_t phy_base;
351 uint32_t sctl_base;
352 uint32_t sphy_base;
Jeevan Shriram01379322015-01-07 17:41:26 -0800353 uint32_t reg_base;
354 uint32_t sreg_base;
Padmanabhan Komanduruc0766c82015-04-27 16:39:15 -0700355 uint32_t pll_base;
356 uint32_t spll_base;
Huaibin Yang88540b32014-11-07 13:59:54 -0800357
358 struct dfps_pll_codes pll_codes;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700359};
360
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700361struct edp_panel_info {
362 int max_lane_count;
363 unsigned long max_link_clk;
364};
365
Vineet Bajajc2272462015-05-07 17:35:03 +0530366struct dsi2HDMI_panel_info {
367 struct mipi_dsi_i2c_cmd *dsi_tg_i2c_cmd;
368 struct mipi_dsi_i2c_cmd *dsi_setup_cfg_i2c_cmd;
369 int num_of_tg_i2c_cmds;
370 int num_of_cfg_i2c_cmds;
Siddharth Zaveriacaacc32015-12-12 15:10:33 -0500371 uint8_t i2c_main_addr;
372 uint8_t i2c_cec_addr;
373 bool program_i2c_addr;
Vineet Bajajc2272462015-05-07 17:35:03 +0530374};
375
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700376enum lvds_mode {
377 LVDS_SINGLE_CHANNEL_MODE,
378 LVDS_DUAL_CHANNEL_MODE,
379};
380
381struct lvds_panel_info {
382 enum lvds_mode channel_mode;
383 /* Channel swap in dual mode */
384 char channel_swap;
385};
386
Kuogee Hsieh9747d9e2014-12-05 15:42:11 -0800387struct labibb_desc {
388 char amoled_panel; /* lcd = 0, amoled = 1*/
389 char force_config; /* 0 to use default value */
390 uint32_t ibb_min_volt;
391 uint32_t ibb_max_volt;
392 uint32_t lab_min_volt;
393 uint32_t lab_max_volt;
394 char pwr_up_delay; /* ndx to => 1250, 2500, 5000 and 10000 us */
395 char pwr_down_delay; /* ndx to => 1250, 2500, 5000 and 10000 us */
396 char ibb_discharge_en;
Vishnuvardhan Prodduturi4aa8dc42015-10-20 21:20:43 +0530397 bool swire_control;
Kuogee Hsieh9747d9e2014-12-05 15:42:11 -0800398};
399
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700400struct msm_panel_info {
401 uint32_t xres;
402 uint32_t yres;
403 uint32_t bpp;
404 uint32_t type;
405 uint32_t wait_cycle;
406 uint32_t clk_rate;
Prashant Nukala64eeff92014-07-11 07:35:34 +0530407 uint32_t orientation;
Aravind Venkateswaranfec354c2014-12-04 18:10:14 -0800408 uint32_t dest;
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700409 uint32_t compression_mode;
Jayant Shekhar03e1a222014-05-22 11:03:53 +0530410 /* Select pipe type for handoff */
411 uint32_t pipe_type;
Arpita Banerjeef1a8ac92013-05-21 10:09:35 -0700412 char lowpowerstop;
Kuogee Hsieh208736d2014-08-22 14:16:55 -0700413 char lcd_reg_en;
Kuogee Hsieh31b4ff92014-10-22 14:55:42 -0700414 uint32_t border_top;
415 uint32_t border_bottom;
416 uint32_t border_left;
417 uint32_t border_right;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700418
Ujwal Patel41a665a2015-07-17 13:51:30 -0700419 int lm_split[2];
420 int num_dsc_enc;
421
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700422 struct lcd_panel_info lcd;
423 struct lcdc_panel_info lcdc;
Siddhartha Agrawalfe64dcb2014-10-07 12:41:01 -0700424 struct fbc_panel_info fbc;
Kuogee Hsiehd58c8092015-07-07 10:31:34 -0700425 struct dsc_desc dsc;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700426 struct mipi_panel_info mipi;
427 struct lvds_panel_info lvds;
Ajay Singh Parmar7c1cd522013-02-13 20:33:49 +0530428 struct hdmi_panel_info hdmi;
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700429 struct edp_panel_info edp;
Wenjun Zhang4e63ce42017-11-28 05:11:34 -0500430 struct spi_panel_info spi;
Vineet Bajajc2272462015-05-07 17:35:03 +0530431 struct dsi2HDMI_panel_info adv7533;
Siddharth Zaveriacaacc32015-12-12 15:10:33 -0500432 bool has_bridge_chip;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700433
Huaibin Yang88540b32014-11-07 13:59:54 -0800434 struct dfps_info dfps;
435
Kuogee Hsieh9747d9e2014-12-05 15:42:11 -0800436 struct labibb_desc *labibb;
437
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700438 int (*on) (void);
439 int (*off) (void);
Dhaval Patelaa081d32013-10-25 13:47:46 -0700440 int (*pre_on) (void);
441 int (*pre_off) (void);
Kuogee Hsiehad69c3c2013-08-01 14:34:29 -0700442 int (*prepare) (void);
Amir Samuelov2d4ba162012-07-22 11:53:14 +0300443 int (*early_config) (void *pdata);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700444 int (*config) (void *pdata);
Channagoud Kadabi01c91822012-06-06 15:53:30 +0530445 int (*rotate) (void);
Sandeep Panda6c24af72015-12-23 15:36:07 +0530446
447 char autorefresh_enable;
448 uint32_t autorefresh_framenum;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700449};
450
451struct msm_fb_panel_data {
452 struct msm_panel_info panel_info;
453 struct fbcon_config fb;
454 int mdp_rev;
Channagoud Kadabi01c91822012-06-06 15:53:30 +0530455 int rotate;
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700456
457 /* function entry chain */
Veera Sundaram Sankarandb0b2bf2014-12-16 18:09:27 -0800458 int (*power_func) (uint8_t enable, struct msm_panel_info *);
459 uint32_t (*clk_func) (uint8_t enable, struct msm_panel_info *pinfo);
460 int (*bl_func) (uint8_t enable);
461 uint32_t (*pll_clk_func) (uint8_t enable, struct msm_panel_info *);
Huaibin Yang88540b32014-11-07 13:59:54 -0800462 int (*dfps_func)(struct msm_panel_info *);
Jayant Shekhare2e6b712013-11-20 16:54:20 +0530463 int (*post_power_func)(int enable);
Ray Zhang4c7e37f2013-12-03 17:04:55 +0800464 int (*pre_init_func)(void);
Casey Piper6c2f1132015-03-24 11:37:19 -0700465 int (*update_panel_info) (void);
Vineet Bajajc2272462015-05-07 17:35:03 +0530466 int (*dsi2HDMI_config) (struct msm_panel_info *);
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700467};
468
Shashank Mittal4bfb2e32012-04-16 10:56:27 -0700469#endif