| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright © 2013 Intel Corporation | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Permission is hereby granted, free of charge, to any person obtaining a | 
					
						
							|  |  |  |  * copy of this software and associated documentation files (the "Software"), | 
					
						
							|  |  |  |  * to deal in the Software without restriction, including without limitation | 
					
						
							|  |  |  |  * the rights to use, copy, modify, merge, publish, distribute, sublicense, | 
					
						
							|  |  |  |  * and/or sell copies of the Software, and to permit persons to whom the | 
					
						
							|  |  |  |  * Software is furnished to do so, subject to the following conditions: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The above copyright notice and this permission notice (including the next | 
					
						
							|  |  |  |  * paragraph) shall be included in all copies or substantial portions of the | 
					
						
							|  |  |  |  * Software. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 
					
						
							|  |  |  |  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
					
						
							|  |  |  |  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL | 
					
						
							|  |  |  |  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 
					
						
							|  |  |  |  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 
					
						
							|  |  |  |  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 
					
						
							|  |  |  |  * DEALINGS IN THE SOFTWARE. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef _INTEL_DSI_H
 | 
					
						
							|  |  |  | #define _INTEL_DSI_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <drm/drmP.h>
 | 
					
						
							|  |  |  | #include <drm/drm_crtc.h>
 | 
					
						
							|  |  |  | #include "intel_drv.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-05 14:13:41 +05:30
										 |  |  | /* Dual Link support */ | 
					
						
							|  |  |  | #define DSI_DUAL_LINK_NONE		0
 | 
					
						
							|  |  |  | #define DSI_DUAL_LINK_FRONT_BACK	1
 | 
					
						
							|  |  |  | #define DSI_DUAL_LINK_PIXEL_ALT		2
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | struct intel_dsi_device { | 
					
						
							|  |  |  | 	unsigned int panel_id; | 
					
						
							|  |  |  | 	const char *name; | 
					
						
							|  |  |  | 	const struct intel_dsi_dev_ops *dev_ops; | 
					
						
							|  |  |  | 	void *dev_priv; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct intel_dsi_dev_ops { | 
					
						
							|  |  |  | 	bool (*init)(struct intel_dsi_device *dsi); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-10 12:14:54 +05:30
										 |  |  | 	void (*panel_reset)(struct intel_dsi_device *dsi); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-11 17:52:05 +05:30
										 |  |  | 	void (*disable_panel_power)(struct intel_dsi_device *dsi); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-10 12:14:54 +05:30
										 |  |  | 	/* one time programmable commands if needed */ | 
					
						
							|  |  |  | 	void (*send_otp_cmds)(struct intel_dsi_device *dsi); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | 	/* This callback must be able to assume DSI commands can be sent */ | 
					
						
							|  |  |  | 	void (*enable)(struct intel_dsi_device *dsi); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* This callback must be able to assume DSI commands can be sent */ | 
					
						
							|  |  |  | 	void (*disable)(struct intel_dsi_device *dsi); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int (*mode_valid)(struct intel_dsi_device *dsi, | 
					
						
							|  |  |  | 			  struct drm_display_mode *mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool (*mode_fixup)(struct intel_dsi_device *dsi, | 
					
						
							|  |  |  | 			   const struct drm_display_mode *mode, | 
					
						
							|  |  |  | 			   struct drm_display_mode *adjusted_mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void (*mode_set)(struct intel_dsi_device *dsi, | 
					
						
							|  |  |  | 			 struct drm_display_mode *mode, | 
					
						
							|  |  |  | 			 struct drm_display_mode *adjusted_mode); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum drm_connector_status (*detect)(struct intel_dsi_device *dsi); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool (*get_hw_state)(struct intel_dsi_device *dev); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct drm_display_mode *(*get_modes)(struct intel_dsi_device *dsi); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void (*destroy) (struct intel_dsi_device *dsi); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct intel_dsi { | 
					
						
							|  |  |  | 	struct intel_encoder base; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct intel_dsi_device dev; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	struct intel_connector *attached_connector; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 16:54:22 +02:00
										 |  |  | 	/* bit mask of ports being driven */ | 
					
						
							|  |  |  | 	u16 ports; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | 	/* if true, use HS mode, otherwise LP */ | 
					
						
							|  |  |  | 	bool hs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* virtual channel */ | 
					
						
							|  |  |  | 	int channel; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-14 11:18:24 +05:30
										 |  |  | 	/* Video mode or command mode */ | 
					
						
							|  |  |  | 	u16 operation_mode; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | 	/* number of DSI lanes */ | 
					
						
							|  |  |  | 	unsigned int lane_count; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* video mode pixel format for MIPI_DSI_FUNC_PRG register */ | 
					
						
							|  |  |  | 	u32 pixel_format; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* video mode format for MIPI_VIDEO_MODE_FORMAT register */ | 
					
						
							|  |  |  | 	u32 video_mode_format; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* eot for MIPI_EOT_DISABLE register */ | 
					
						
							| 
									
										
										
										
											2014-04-09 13:59:33 +05:30
										 |  |  | 	u8 eotp_pkt; | 
					
						
							|  |  |  | 	u8 clock_stop; | 
					
						
							| 
									
										
										
										
											2013-12-10 12:15:00 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-09 13:59:33 +05:30
										 |  |  | 	u8 escape_clk_div; | 
					
						
							| 
									
										
										
										
											2014-12-05 14:09:28 +05:30
										 |  |  | 	u8 dual_link; | 
					
						
							| 
									
										
										
										
											2014-12-05 14:13:41 +05:30
										 |  |  | 	u8 pixel_overlap; | 
					
						
							| 
									
										
										
										
											2013-12-10 12:15:00 +05:30
										 |  |  | 	u32 port_bits; | 
					
						
							|  |  |  | 	u32 bw_timer; | 
					
						
							|  |  |  | 	u32 dphy_reg; | 
					
						
							|  |  |  | 	u32 video_frmt_cfg_bits; | 
					
						
							|  |  |  | 	u16 lp_byte_clk; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* timeouts in byte clocks */ | 
					
						
							|  |  |  | 	u16 lp_rx_timeout; | 
					
						
							|  |  |  | 	u16 turn_arnd_val; | 
					
						
							|  |  |  | 	u16 rst_timer_val; | 
					
						
							|  |  |  | 	u16 hs_to_lp_count; | 
					
						
							|  |  |  | 	u16 clk_lp_to_hs_count; | 
					
						
							|  |  |  | 	u16 clk_hs_to_lp_count; | 
					
						
							| 
									
										
										
										
											2014-04-14 11:18:25 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 	u16 init_count; | 
					
						
							| 
									
										
										
										
											2014-07-30 20:34:57 +05:30
										 |  |  | 	u32 pclk; | 
					
						
							|  |  |  | 	u16 burst_mode_ratio; | 
					
						
							| 
									
										
										
										
											2014-04-14 11:18:26 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* all delays in ms */ | 
					
						
							|  |  |  | 	u16 backlight_off_delay; | 
					
						
							|  |  |  | 	u16 backlight_on_delay; | 
					
						
							|  |  |  | 	u16 panel_on_delay; | 
					
						
							|  |  |  | 	u16 panel_off_delay; | 
					
						
							|  |  |  | 	u16 panel_pwr_cycle_delay; | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-14 16:54:21 +02:00
										 |  |  | /* XXX: Transitional before dual port configuration */ | 
					
						
							|  |  |  | static inline enum port intel_dsi_pipe_to_port(enum pipe pipe) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (pipe == PIPE_A) | 
					
						
							|  |  |  | 		return PORT_A; | 
					
						
							|  |  |  | 	else if (pipe == PIPE_B) | 
					
						
							|  |  |  | 		return PORT_C; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	WARN(1, "DSI on pipe %c, assuming port C\n", pipe_name(pipe)); | 
					
						
							|  |  |  | 	return PORT_C; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define for_each_dsi_port(__port, __ports_mask) \
 | 
					
						
							|  |  |  | 	for ((__port) = PORT_A; (__port) < I915_MAX_PORTS; (__port)++)	\ | 
					
						
							|  |  |  | 		if ((__ports_mask) & (1 << (__port))) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return container_of(encoder, struct intel_dsi, base.base); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 23:40:56 +03:00
										 |  |  | extern void vlv_enable_dsi_pll(struct intel_encoder *encoder); | 
					
						
							|  |  |  | extern void vlv_disable_dsi_pll(struct intel_encoder *encoder); | 
					
						
							| 
									
										
										
										
											2014-07-30 20:32:37 +05:30
										 |  |  | extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp); | 
					
						
							| 
									
										
										
										
											2013-08-27 23:40:56 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-23 21:35:27 +05:30
										 |  |  | extern struct intel_dsi_dev_ops vbt_generic_dsi_display_ops; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-27 15:12:18 +03:00
										 |  |  | #endif /* _INTEL_DSI_H */
 |