Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright © 2013 Intel Corporation
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice (including the next
0012  * paragraph) shall be included in all copies or substantial portions of the
0013  * Software.
0014  *
0015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0018  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0019  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
0020  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
0021  * DEALINGS IN THE SOFTWARE.
0022  */
0023 
0024 #ifndef _INTEL_DSI_H
0025 #define _INTEL_DSI_H
0026 
0027 #include <drm/drm_crtc.h>
0028 #include <drm/drm_mipi_dsi.h>
0029 
0030 #include "intel_display_types.h"
0031 
0032 #define INTEL_DSI_VIDEO_MODE    0
0033 #define INTEL_DSI_COMMAND_MODE  1
0034 
0035 /* Dual Link support */
0036 #define DSI_DUAL_LINK_NONE      0
0037 #define DSI_DUAL_LINK_FRONT_BACK    1
0038 #define DSI_DUAL_LINK_PIXEL_ALT     2
0039 
0040 struct intel_dsi_host;
0041 
0042 struct intel_dsi {
0043     struct intel_encoder base;
0044 
0045     struct intel_dsi_host *dsi_hosts[I915_MAX_PORTS];
0046     intel_wakeref_t io_wakeref[I915_MAX_PORTS];
0047 
0048     /* GPIO Desc for panel and backlight control */
0049     struct gpio_desc *gpio_panel;
0050     struct gpio_desc *gpio_backlight;
0051 
0052     struct intel_connector *attached_connector;
0053 
0054     /* bit mask of ports (vlv dsi) or phys (icl dsi) being driven */
0055     union {
0056         u16 ports;  /* VLV DSI */
0057         u16 phys;   /* ICL DSI */
0058     };
0059 
0060     /* if true, use HS mode, otherwise LP */
0061     bool hs;
0062 
0063     /* virtual channel */
0064     int channel;
0065 
0066     /* Video mode or command mode */
0067     u16 operation_mode;
0068 
0069     /* number of DSI lanes */
0070     unsigned int lane_count;
0071 
0072     /* i2c bus associated with the slave device */
0073     int i2c_bus_num;
0074 
0075     /*
0076      * video mode pixel format
0077      *
0078      * XXX: consolidate on .format in struct mipi_dsi_device.
0079      */
0080     enum mipi_dsi_pixel_format pixel_format;
0081 
0082     /* NON_BURST_SYNC_PULSE, NON_BURST_SYNC_EVENTS, or BURST_MODE */
0083     int video_mode;
0084 
0085     /* eot for MIPI_EOT_DISABLE register */
0086     u8 eotp_pkt;
0087     u8 clock_stop;
0088 
0089     u8 escape_clk_div;
0090     u8 dual_link;
0091 
0092     u16 dcs_backlight_ports;
0093     u16 dcs_cabc_ports;
0094 
0095     /* RGB or BGR */
0096     bool bgr_enabled;
0097 
0098     u8 pixel_overlap;
0099     u32 port_bits;
0100     u32 bw_timer;
0101     u32 dphy_reg;
0102 
0103     /* data lanes dphy timing */
0104     u32 dphy_data_lane_reg;
0105     u32 video_frmt_cfg_bits;
0106     u16 lp_byte_clk;
0107 
0108     /* timeouts in byte clocks */
0109     u16 hs_tx_timeout;
0110     u16 lp_rx_timeout;
0111     u16 turn_arnd_val;
0112     u16 rst_timer_val;
0113     u16 hs_to_lp_count;
0114     u16 clk_lp_to_hs_count;
0115     u16 clk_hs_to_lp_count;
0116 
0117     u16 init_count;
0118     u32 pclk;
0119     u16 burst_mode_ratio;
0120 
0121     /* all delays in ms */
0122     u16 backlight_off_delay;
0123     u16 backlight_on_delay;
0124     u16 panel_on_delay;
0125     u16 panel_off_delay;
0126     u16 panel_pwr_cycle_delay;
0127     ktime_t panel_power_off_time;
0128 };
0129 
0130 struct intel_dsi_host {
0131     struct mipi_dsi_host base;
0132     struct intel_dsi *intel_dsi;
0133     enum port port;
0134 
0135     /* our little hack */
0136     struct mipi_dsi_device *device;
0137 };
0138 
0139 static inline struct intel_dsi_host *to_intel_dsi_host(struct mipi_dsi_host *h)
0140 {
0141     return container_of(h, struct intel_dsi_host, base);
0142 }
0143 
0144 #define for_each_dsi_port(__port, __ports_mask) \
0145     for_each_port_masked(__port, __ports_mask)
0146 #define for_each_dsi_phy(__phy, __phys_mask) \
0147     for_each_phy_masked(__phy, __phys_mask)
0148 
0149 static inline struct intel_dsi *enc_to_intel_dsi(struct intel_encoder *encoder)
0150 {
0151     return container_of(&encoder->base, struct intel_dsi, base.base);
0152 }
0153 
0154 static inline bool is_vid_mode(struct intel_dsi *intel_dsi)
0155 {
0156     return intel_dsi->operation_mode == INTEL_DSI_VIDEO_MODE;
0157 }
0158 
0159 static inline bool is_cmd_mode(struct intel_dsi *intel_dsi)
0160 {
0161     return intel_dsi->operation_mode == INTEL_DSI_COMMAND_MODE;
0162 }
0163 
0164 static inline u16 intel_dsi_encoder_ports(struct intel_encoder *encoder)
0165 {
0166     return enc_to_intel_dsi(encoder)->ports;
0167 }
0168 
0169 int intel_dsi_bitrate(const struct intel_dsi *intel_dsi);
0170 int intel_dsi_tlpx_ns(const struct intel_dsi *intel_dsi);
0171 enum drm_panel_orientation
0172 intel_dsi_get_panel_orientation(struct intel_connector *connector);
0173 int intel_dsi_get_modes(struct drm_connector *connector);
0174 enum drm_mode_status intel_dsi_mode_valid(struct drm_connector *connector,
0175                       struct drm_display_mode *mode);
0176 struct intel_dsi_host *intel_dsi_host_init(struct intel_dsi *intel_dsi,
0177                        const struct mipi_dsi_host_ops *funcs,
0178                        enum port port);
0179 
0180 #endif /* _INTEL_DSI_H */