Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
0004  */
0005 
0006 #ifndef _DP_PANEL_H_
0007 #define _DP_PANEL_H_
0008 
0009 #include <drm/msm_drm.h>
0010 
0011 #include "dp_aux.h"
0012 #include "dp_link.h"
0013 #include "dp_hpd.h"
0014 
0015 struct edid;
0016 
0017 #define DPRX_EXTENDED_DPCD_FIELD    0x2200
0018 
0019 #define DP_DOWNSTREAM_PORTS     4
0020 #define DP_DOWNSTREAM_CAP_SIZE      4
0021 
0022 struct dp_display_mode {
0023     struct drm_display_mode drm_mode;
0024     u32 capabilities;
0025     u32 bpp;
0026     u32 h_active_low;
0027     u32 v_active_low;
0028 };
0029 
0030 struct dp_panel_in {
0031     struct device *dev;
0032     struct drm_dp_aux *aux;
0033     struct dp_link *link;
0034     struct dp_catalog *catalog;
0035 };
0036 
0037 struct dp_panel {
0038     /* dpcd raw data */
0039     u8 dpcd[DP_RECEIVER_CAP_SIZE + 1];
0040     u8 ds_cap_info[DP_DOWNSTREAM_PORTS * DP_DOWNSTREAM_CAP_SIZE];
0041     u32 ds_port_cnt;
0042     u32 dfp_present;
0043 
0044     struct dp_link_info link_info;
0045     struct drm_dp_desc desc;
0046     struct edid *edid;
0047     struct drm_connector *connector;
0048     struct dp_display_mode dp_mode;
0049     bool video_test;
0050 
0051     u32 vic;
0052     u32 max_dp_lanes;
0053 
0054     u32 max_bw_code;
0055 };
0056 
0057 int dp_panel_init_panel_info(struct dp_panel *dp_panel);
0058 int dp_panel_deinit(struct dp_panel *dp_panel);
0059 int dp_panel_timing_cfg(struct dp_panel *dp_panel);
0060 void dp_panel_dump_regs(struct dp_panel *dp_panel);
0061 int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
0062         struct drm_connector *connector);
0063 u32 dp_panel_get_mode_bpp(struct dp_panel *dp_panel, u32 mode_max_bpp,
0064             u32 mode_pclk_khz);
0065 int dp_panel_get_modes(struct dp_panel *dp_panel,
0066         struct drm_connector *connector);
0067 void dp_panel_handle_sink_request(struct dp_panel *dp_panel);
0068 void dp_panel_tpg_config(struct dp_panel *dp_panel, bool enable);
0069 
0070 /**
0071  * is_link_rate_valid() - validates the link rate
0072  * @lane_rate: link rate requested by the sink
0073  *
0074  * Returns true if the requested link rate is supported.
0075  */
0076 static inline bool is_link_rate_valid(u32 bw_code)
0077 {
0078     return (bw_code == DP_LINK_BW_1_62 ||
0079         bw_code == DP_LINK_BW_2_7 ||
0080         bw_code == DP_LINK_BW_5_4 ||
0081         bw_code == DP_LINK_BW_8_1);
0082 }
0083 
0084 /**
0085  * dp_link_is_lane_count_valid() - validates the lane count
0086  * @lane_count: lane count requested by the sink
0087  *
0088  * Returns true if the requested lane count is supported.
0089  */
0090 static inline bool is_lane_count_valid(u32 lane_count)
0091 {
0092     return (lane_count == 1 ||
0093         lane_count == 2 ||
0094         lane_count == 4);
0095 }
0096 
0097 struct dp_panel *dp_panel_get(struct dp_panel_in *in);
0098 void dp_panel_put(struct dp_panel *dp_panel);
0099 #endif /* _DP_PANEL_H_ */