30 #define CH7017_TV_DISPLAY_MODE 0x00
31 #define CH7017_FLICKER_FILTER 0x01
32 #define CH7017_VIDEO_BANDWIDTH 0x02
33 #define CH7017_TEXT_ENHANCEMENT 0x03
34 #define CH7017_START_ACTIVE_VIDEO 0x04
35 #define CH7017_HORIZONTAL_POSITION 0x05
36 #define CH7017_VERTICAL_POSITION 0x06
37 #define CH7017_BLACK_LEVEL 0x07
38 #define CH7017_CONTRAST_ENHANCEMENT 0x08
39 #define CH7017_TV_PLL 0x09
40 #define CH7017_TV_PLL_M 0x0a
41 #define CH7017_TV_PLL_N 0x0b
42 #define CH7017_SUB_CARRIER_0 0x0c
43 #define CH7017_CIV_CONTROL 0x10
44 #define CH7017_CIV_0 0x11
45 #define CH7017_CHROMA_BOOST 0x14
46 #define CH7017_CLOCK_MODE 0x1c
47 #define CH7017_INPUT_CLOCK 0x1d
48 #define CH7017_GPIO_CONTROL 0x1e
49 #define CH7017_INPUT_DATA_FORMAT 0x1f
50 #define CH7017_CONNECTION_DETECT 0x20
51 #define CH7017_DAC_CONTROL 0x21
52 #define CH7017_BUFFERED_CLOCK_OUTPUT 0x22
53 #define CH7017_DEFEAT_VSYNC 0x47
54 #define CH7017_TEST_PATTERN 0x48
56 #define CH7017_POWER_MANAGEMENT 0x49
58 #define CH7017_TV_EN (1 << 0)
59 #define CH7017_DAC0_POWER_DOWN (1 << 1)
60 #define CH7017_DAC1_POWER_DOWN (1 << 2)
61 #define CH7017_DAC2_POWER_DOWN (1 << 3)
62 #define CH7017_DAC3_POWER_DOWN (1 << 4)
64 #define CH7017_TV_POWER_DOWN_EN (1 << 5)
66 #define CH7017_VERSION_ID 0x4a
68 #define CH7017_DEVICE_ID 0x4b
69 #define CH7017_DEVICE_ID_VALUE 0x1b
70 #define CH7018_DEVICE_ID_VALUE 0x1a
71 #define CH7019_DEVICE_ID_VALUE 0x19
73 #define CH7017_XCLK_D2_ADJUST 0x53
74 #define CH7017_UP_SCALER_COEFF_0 0x55
75 #define CH7017_UP_SCALER_COEFF_1 0x56
76 #define CH7017_UP_SCALER_COEFF_2 0x57
77 #define CH7017_UP_SCALER_COEFF_3 0x58
78 #define CH7017_UP_SCALER_COEFF_4 0x59
79 #define CH7017_UP_SCALER_VERTICAL_INC_0 0x5a
80 #define CH7017_UP_SCALER_VERTICAL_INC_1 0x5b
81 #define CH7017_GPIO_INVERT 0x5c
82 #define CH7017_UP_SCALER_HORIZONTAL_INC_0 0x5d
83 #define CH7017_UP_SCALER_HORIZONTAL_INC_1 0x5e
85 #define CH7017_HORIZONTAL_ACTIVE_PIXEL_INPUT 0x5f
88 #define CH7017_ACTIVE_INPUT_LINE_OUTPUT 0x60
90 #define CH7017_LVDS_HAP_INPUT_MASK (0x7 << 0)
92 #define CH7017_LVDS_VAL_HIGH_MASK (0x7 << 3)
94 #define CH7017_VERTICAL_ACTIVE_LINE_OUTPUT 0x61
97 #define CH7017_HORIZONTAL_ACTIVE_PIXEL_OUTPUT 0x62
100 #define CH7017_LVDS_POWER_DOWN 0x63
102 #define CH7017_LVDS_HAP_HIGH_MASK (0x7 << 0)
104 #define CH7017_LVDS_POWER_DOWN_EN (1 << 6)
106 #define CH7017_LVDS_UPSCALER_EN (1 << 7)
107 #define CH7017_LVDS_POWER_DOWN_DEFAULT_RESERVED 0x08
109 #define CH7017_LVDS_ENCODING 0x64
110 #define CH7017_LVDS_DITHER_2D (1 << 2)
111 #define CH7017_LVDS_DITHER_DIS (1 << 3)
112 #define CH7017_LVDS_DUAL_CHANNEL_EN (1 << 4)
113 #define CH7017_LVDS_24_BIT (1 << 5)
115 #define CH7017_LVDS_ENCODING_2 0x65
117 #define CH7017_LVDS_PLL_CONTROL 0x66
119 #define CH7017_LVDS_PANEN (1 << 0)
121 #define CH7017_LVDS_BKLEN (1 << 3)
123 #define CH7017_POWER_SEQUENCING_T1 0x67
124 #define CH7017_POWER_SEQUENCING_T2 0x68
125 #define CH7017_POWER_SEQUENCING_T3 0x69
126 #define CH7017_POWER_SEQUENCING_T4 0x6a
127 #define CH7017_POWER_SEQUENCING_T5 0x6b
128 #define CH7017_GPIO_DRIVER_TYPE 0x6c
129 #define CH7017_GPIO_DATA 0x6d
130 #define CH7017_GPIO_DIRECTION_CONTROL 0x6e
132 #define CH7017_LVDS_PLL_FEEDBACK_DIV 0x71
133 # define CH7017_LVDS_PLL_FEED_BACK_DIVIDER_SHIFT 4
134 # define CH7017_LVDS_PLL_FEED_FORWARD_DIVIDER_SHIFT 0
135 # define CH7017_LVDS_PLL_FEEDBACK_DEFAULT_RESERVED 0x80
137 #define CH7017_LVDS_PLL_VCO_CONTROL 0x72
138 # define CH7017_LVDS_PLL_VCO_DEFAULT_RESERVED 0x80
139 # define CH7017_LVDS_PLL_VCO_SHIFT 4
140 # define CH7017_LVDS_PLL_POST_SCALE_DIV_SHIFT 0
142 #define CH7017_OUTPUTS_ENABLE 0x73
143 # define CH7017_CHARGE_PUMP_LOW 0x0
144 # define CH7017_CHARGE_PUMP_HIGH 0x3
145 # define CH7017_LVDS_CHANNEL_A (1 << 3)
146 # define CH7017_LVDS_CHANNEL_B (1 << 4)
147 # define CH7017_TV_DAC_A (1 << 5)
148 # define CH7017_TV_DAC_B (1 << 6)
149 # define CH7017_DDC_SELECT_DC2 (1 << 7)
151 #define CH7017_LVDS_OUTPUT_AMPLITUDE 0x74
152 #define CH7017_LVDS_PLL_EMI_REDUCTION 0x75
153 #define CH7017_LVDS_POWER_DOWN_FLICKER 0x76
155 #define CH7017_LVDS_CONTROL_2 0x78
156 # define CH7017_LOOP_FILTER_SHIFT 5
157 # define CH7017_PHASE_DETECTOR_SHIFT 0
159 #define CH7017_BANG_LIMIT_CONTROL 0x7f
228 DRM_DEBUG_KMS(
"ch701x not detected, got %d: from %s "
234 DRM_DEBUG_KMS(
"%s detected on %s, addr %d\n",
251 if (mode->
clock > 160000)
261 uint8_t lvds_pll_feedback_div, lvds_pll_vco_control;
262 uint8_t outputs_enable, lvds_control_2, lvds_power_down;
263 uint8_t horizontal_active_pixel_input;
264 uint8_t horizontal_active_pixel_output, vertical_active_line_output;
265 uint8_t active_input_line_output;
267 DRM_DEBUG_KMS(
"Registers before mode setting\n");
268 ch7017_dump_regs(dvo);
271 if (mode->
clock < 100000) {
286 lvds_pll_feedback_div = 35;
301 horizontal_active_pixel_input = mode->
hdisplay & 0x00ff;
303 vertical_active_line_output = mode->
vdisplay & 0x00ff;
304 horizontal_active_pixel_output = mode->
hdisplay & 0x00ff;
306 active_input_line_output = ((mode->
hdisplay & 0x0700) >> 8) |
307 (((mode->
vdisplay & 0x0700) >> 8) << 3);
312 ch7017_dpms(dvo,
false);
314 horizontal_active_pixel_input);
316 horizontal_active_pixel_output);
318 vertical_active_line_output);
320 active_input_line_output);
329 DRM_DEBUG_KMS(
"Registers after mode setting\n");
330 ch7017_dump_regs(dvo);
380 ch7017_read(dvo, reg, &val); \
381 DRM_DEBUG_KMS(#reg ": %02x\n", val); \
407 .detect = ch7017_detect,
408 .mode_valid = ch7017_mode_valid,
409 .mode_set = ch7017_mode_set,
411 .get_hw_state = ch7017_get_hw_state,
412 .dump_regs = ch7017_dump_regs,
413 .destroy = ch7017_destroy,