1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2020 Intel Corporation
4  */
5 
6 #ifndef _INTEL_DDI_BUF_TRANS_H_
7 #define _INTEL_DDI_BUF_TRANS_H_
8 
9 #include <linux/types.h>
10 
11 struct drm_i915_private;
12 struct intel_encoder;
13 struct intel_crtc_state;
14 
15 struct hsw_ddi_buf_trans {
16 	u32 trans1;	/* balance leg enable, de-emph level */
17 	u32 trans2;	/* vref sel, vswing */
18 	u8 i_boost;	/* SKL: I_boost; valid: 0x0, 0x1, 0x3, 0x7 */
19 };
20 
21 struct bxt_ddi_buf_trans {
22 	u8 margin;	/* swing value */
23 	u8 scale;	/* scale value */
24 	u8 enable;	/* scale enable */
25 	u8 deemphasis;
26 };
27 
28 struct icl_ddi_buf_trans {
29 	u8 dw2_swing_sel;
30 	u8 dw7_n_scalar;
31 	u8 dw4_cursor_coeff;
32 	u8 dw4_post_cursor_2;
33 	u8 dw4_post_cursor_1;
34 };
35 
36 struct icl_mg_phy_ddi_buf_trans {
37 	u32 cri_txdeemph_override_11_6;
38 	u32 cri_txdeemph_override_5_0;
39 	u32 cri_txdeemph_override_17_12;
40 };
41 
42 struct tgl_dkl_phy_ddi_buf_trans {
43 	u32 dkl_vswing_control;
44 	u32 dkl_preshoot_control;
45 	u32 dkl_de_emphasis_control;
46 };
47 
48 union intel_ddi_buf_trans_entry {
49 	struct hsw_ddi_buf_trans hsw;
50 	struct bxt_ddi_buf_trans bxt;
51 	struct icl_ddi_buf_trans icl;
52 	struct icl_mg_phy_ddi_buf_trans mg;
53 	struct tgl_dkl_phy_ddi_buf_trans dkl;
54 };
55 
56 struct intel_ddi_buf_trans {
57 	const union intel_ddi_buf_trans_entry *entries;
58 	u8 num_entries;
59 	u8 hdmi_default_entry;
60 };
61 
62 bool is_hobl_buf_trans(const struct intel_ddi_buf_trans *table);
63 
64 int intel_ddi_hdmi_num_entries(struct intel_encoder *encoder,
65 			       const struct intel_crtc_state *crtc_state,
66 			       int *default_entry);
67 
68 void intel_ddi_buf_trans_init(struct intel_encoder *encoder);
69 
70 #endif
71