xref: /openbmc/linux/drivers/gpu/drm/msm/dp/dp_panel.h (revision 1c5f6051)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef _DP_PANEL_H_
7 #define _DP_PANEL_H_
8 
9 #include <drm/msm_drm.h>
10 
11 #include "dp_aux.h"
12 #include "dp_link.h"
13 
14 struct edid;
15 
16 #define DPRX_EXTENDED_DPCD_FIELD	0x2200
17 
18 #define DP_DOWNSTREAM_PORTS		4
19 #define DP_DOWNSTREAM_CAP_SIZE		4
20 
21 struct dp_display_mode {
22 	struct drm_display_mode drm_mode;
23 	u32 capabilities;
24 	u32 bpp;
25 	u32 h_active_low;
26 	u32 v_active_low;
27 };
28 
29 struct dp_panel_in {
30 	struct device *dev;
31 	struct drm_dp_aux *aux;
32 	struct dp_link *link;
33 	struct dp_catalog *catalog;
34 };
35 
36 struct dp_panel_psr {
37 	u8 version;
38 	u8 capabilities;
39 };
40 
41 struct dp_panel {
42 	/* dpcd raw data */
43 	u8 dpcd[DP_RECEIVER_CAP_SIZE + 1];
44 	u8 ds_cap_info[DP_DOWNSTREAM_PORTS * DP_DOWNSTREAM_CAP_SIZE];
45 	u32 ds_port_cnt;
46 	u32 dfp_present;
47 
48 	struct dp_link_info link_info;
49 	struct drm_dp_desc desc;
50 	struct edid *edid;
51 	struct drm_connector *connector;
52 	struct dp_display_mode dp_mode;
53 	struct dp_panel_psr psr_cap;
54 	bool video_test;
55 
56 	u32 vic;
57 	u32 max_dp_lanes;
58 	u32 max_dp_link_rate;
59 
60 	u32 max_bw_code;
61 };
62 
63 int dp_panel_init_panel_info(struct dp_panel *dp_panel);
64 int dp_panel_deinit(struct dp_panel *dp_panel);
65 int dp_panel_timing_cfg(struct dp_panel *dp_panel);
66 void dp_panel_dump_regs(struct dp_panel *dp_panel);
67 int dp_panel_read_sink_caps(struct dp_panel *dp_panel,
68 		struct drm_connector *connector);
69 u32 dp_panel_get_mode_bpp(struct dp_panel *dp_panel, u32 mode_max_bpp,
70 			u32 mode_pclk_khz);
71 int dp_panel_get_modes(struct dp_panel *dp_panel,
72 		struct drm_connector *connector);
73 void dp_panel_handle_sink_request(struct dp_panel *dp_panel);
74 void dp_panel_tpg_config(struct dp_panel *dp_panel, bool enable);
75 
76 /**
77  * is_link_rate_valid() - validates the link rate
78  * @lane_rate: link rate requested by the sink
79  *
80  * Returns true if the requested link rate is supported.
81  */
is_link_rate_valid(u32 bw_code)82 static inline bool is_link_rate_valid(u32 bw_code)
83 {
84 	return (bw_code == DP_LINK_BW_1_62 ||
85 		bw_code == DP_LINK_BW_2_7 ||
86 		bw_code == DP_LINK_BW_5_4 ||
87 		bw_code == DP_LINK_BW_8_1);
88 }
89 
90 /**
91  * dp_link_is_lane_count_valid() - validates the lane count
92  * @lane_count: lane count requested by the sink
93  *
94  * Returns true if the requested lane count is supported.
95  */
is_lane_count_valid(u32 lane_count)96 static inline bool is_lane_count_valid(u32 lane_count)
97 {
98 	return (lane_count == 1 ||
99 		lane_count == 2 ||
100 		lane_count == 4);
101 }
102 
103 struct dp_panel *dp_panel_get(struct dp_panel_in *in);
104 void dp_panel_put(struct dp_panel *dp_panel);
105 #endif /* _DP_PANEL_H_ */
106