2 * Copyright 2012-15 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
27 #include "reg_helper.h"
28 #include "dcn10_optc.h"
38 #define FN(reg_name, field_name) \
39 optc1->tg_shift->field_name, optc1->tg_mask->field_name
41 #define STATIC_SCREEN_EVENT_MASK_RANGETIMING_DOUBLE_BUFFER_UPDATE_EN 0x100
44 * apply_front_porch_workaround TODO FPGA still need?
46 * This is a workaround for a bug that has existed since R5xx and has not been
47 * fixed keep Front porch at minimum 2 for Interlaced mode or 1 for progressive.
49 static void optc1_apply_front_porch_workaround(
50 struct timing_generator *optc,
51 struct dc_crtc_timing *timing)
53 if (timing->flags.INTERLACE == 1) {
54 if (timing->v_front_porch < 2)
55 timing->v_front_porch = 2;
57 if (timing->v_front_porch < 1)
58 timing->v_front_porch = 1;
62 void optc1_program_global_sync(
63 struct timing_generator *optc)
65 struct optc *optc1 = DCN10TG_FROM_TG(optc);
67 if (optc->dlg_otg_param.vstartup_start == 0) {
72 REG_SET(OTG_VSTARTUP_PARAM, 0,
73 VSTARTUP_START, optc->dlg_otg_param.vstartup_start);
75 REG_SET_2(OTG_VUPDATE_PARAM, 0,
76 VUPDATE_OFFSET, optc->dlg_otg_param.vupdate_offset,
77 VUPDATE_WIDTH, optc->dlg_otg_param.vupdate_width);
79 REG_SET(OTG_VREADY_PARAM, 0,
80 VREADY_OFFSET, optc->dlg_otg_param.vready_offset);
83 static void optc1_disable_stereo(struct timing_generator *optc)
85 struct optc *optc1 = DCN10TG_FROM_TG(optc);
87 REG_SET(OTG_STEREO_CONTROL, 0,
90 REG_SET_3(OTG_3D_STRUCTURE_CONTROL, 0,
91 OTG_3D_STRUCTURE_EN, 0,
92 OTG_3D_STRUCTURE_V_UPDATE_MODE, 0,
93 OTG_3D_STRUCTURE_STEREO_SEL_OVR, 0);
96 static uint32_t get_start_vline(struct timing_generator *optc, const struct dc_crtc_timing *dc_crtc_timing)
98 struct dc_crtc_timing patched_crtc_timing;
101 int interlace_factor;
102 int vertical_line_start;
104 patched_crtc_timing = *dc_crtc_timing;
105 optc1_apply_front_porch_workaround(optc, &patched_crtc_timing);
107 vesa_sync_start = patched_crtc_timing.h_addressable +
108 patched_crtc_timing.h_border_right +
109 patched_crtc_timing.h_front_porch;
111 asic_blank_end = patched_crtc_timing.h_total -
113 patched_crtc_timing.h_border_left;
115 interlace_factor = patched_crtc_timing.flags.INTERLACE ? 2 : 1;
117 vesa_sync_start = patched_crtc_timing.v_addressable +
118 patched_crtc_timing.v_border_bottom +
119 patched_crtc_timing.v_front_porch;
121 asic_blank_end = (patched_crtc_timing.v_total -
123 patched_crtc_timing.v_border_top)
126 vertical_line_start = asic_blank_end - optc->dlg_otg_param.vstartup_start + 1;
127 if (vertical_line_start < 0) {
129 vertical_line_start = 0;
132 return vertical_line_start;
135 void optc1_program_vline_interrupt(
136 struct timing_generator *optc,
137 const struct dc_crtc_timing *dc_crtc_timing,
138 unsigned long long vsync_delta)
141 struct optc *optc1 = DCN10TG_FROM_TG(optc);
143 unsigned long long req_delta_tens_of_usec = div64_u64((vsync_delta + 9999), 10000);
144 unsigned long long pix_clk_hundreds_khz = div64_u64((dc_crtc_timing->pix_clk_khz + 99), 100);
145 uint32_t req_delta_lines = (uint32_t) div64_u64(
146 (req_delta_tens_of_usec * pix_clk_hundreds_khz + dc_crtc_timing->h_total - 1),
147 dc_crtc_timing->h_total);
149 uint32_t vsync_line = get_start_vline(optc, dc_crtc_timing);
150 uint32_t start_line = 0;
151 uint32_t endLine = 0;
153 if (req_delta_lines != 0)
156 if (req_delta_lines > vsync_line)
157 start_line = dc_crtc_timing->v_total - (req_delta_lines - vsync_line) - 1;
159 start_line = vsync_line - req_delta_lines;
161 endLine = start_line + 2;
163 if (endLine >= dc_crtc_timing->v_total)
166 REG_SET_2(OTG_VERTICAL_INTERRUPT0_POSITION, 0,
167 OTG_VERTICAL_INTERRUPT0_LINE_START, start_line,
168 OTG_VERTICAL_INTERRUPT0_LINE_END, endLine);
172 * program_timing_generator used by mode timing set
173 * Program CRTC Timing Registers - OTG_H_*, OTG_V_*, Pixel repetition.
174 * Including SYNC. Call BIOS command table to program Timings.
176 void optc1_program_timing(
177 struct timing_generator *optc,
178 const struct dc_crtc_timing *dc_crtc_timing,
181 struct dc_crtc_timing patched_crtc_timing;
182 uint32_t vesa_sync_start;
183 uint32_t asic_blank_end;
184 uint32_t asic_blank_start;
187 uint32_t v_init, v_fp2;
188 uint32_t h_sync_polarity, v_sync_polarity;
189 uint32_t interlace_factor;
190 uint32_t start_point = 0;
191 uint32_t field_num = 0;
193 int32_t vertical_line_start;
195 struct optc *optc1 = DCN10TG_FROM_TG(optc);
197 patched_crtc_timing = *dc_crtc_timing;
198 optc1_apply_front_porch_workaround(optc, &patched_crtc_timing);
200 /* Load horizontal timing */
202 /* CRTC_H_TOTAL = vesa.h_total - 1 */
203 REG_SET(OTG_H_TOTAL, 0,
204 OTG_H_TOTAL, patched_crtc_timing.h_total - 1);
206 /* h_sync_start = 0, h_sync_end = vesa.h_sync_width */
207 REG_UPDATE_2(OTG_H_SYNC_A,
208 OTG_H_SYNC_A_START, 0,
209 OTG_H_SYNC_A_END, patched_crtc_timing.h_sync_width);
211 /* asic_h_blank_end = HsyncWidth + HbackPorch =
212 * vesa. usHorizontalTotal - vesa. usHorizontalSyncStart -
215 vesa_sync_start = patched_crtc_timing.h_addressable +
216 patched_crtc_timing.h_border_right +
217 patched_crtc_timing.h_front_porch;
219 asic_blank_end = patched_crtc_timing.h_total -
221 patched_crtc_timing.h_border_left;
223 /* h_blank_start = v_blank_end + v_active */
224 asic_blank_start = asic_blank_end +
225 patched_crtc_timing.h_border_left +
226 patched_crtc_timing.h_addressable +
227 patched_crtc_timing.h_border_right;
229 REG_UPDATE_2(OTG_H_BLANK_START_END,
230 OTG_H_BLANK_START, asic_blank_start,
231 OTG_H_BLANK_END, asic_blank_end);
233 /* h_sync polarity */
234 h_sync_polarity = patched_crtc_timing.flags.HSYNC_POSITIVE_POLARITY ?
237 REG_UPDATE(OTG_H_SYNC_A_CNTL,
238 OTG_H_SYNC_A_POL, h_sync_polarity);
240 /* Load vertical timing */
242 /* CRTC_V_TOTAL = v_total - 1 */
243 if (patched_crtc_timing.flags.INTERLACE) {
244 interlace_factor = 2;
245 v_total = 2 * patched_crtc_timing.v_total;
247 interlace_factor = 1;
248 v_total = patched_crtc_timing.v_total - 1;
250 REG_SET(OTG_V_TOTAL, 0,
251 OTG_V_TOTAL, v_total);
253 /* In case of V_TOTAL_CONTROL is on, make sure OTG_V_TOTAL_MAX and
254 * OTG_V_TOTAL_MIN are equal to V_TOTAL.
256 REG_SET(OTG_V_TOTAL_MAX, 0,
257 OTG_V_TOTAL_MAX, v_total);
258 REG_SET(OTG_V_TOTAL_MIN, 0,
259 OTG_V_TOTAL_MIN, v_total);
261 /* v_sync_start = 0, v_sync_end = v_sync_width */
262 v_sync_end = patched_crtc_timing.v_sync_width * interlace_factor;
264 REG_UPDATE_2(OTG_V_SYNC_A,
265 OTG_V_SYNC_A_START, 0,
266 OTG_V_SYNC_A_END, v_sync_end);
268 vesa_sync_start = patched_crtc_timing.v_addressable +
269 patched_crtc_timing.v_border_bottom +
270 patched_crtc_timing.v_front_porch;
272 asic_blank_end = (patched_crtc_timing.v_total -
274 patched_crtc_timing.v_border_top)
277 /* v_blank_start = v_blank_end + v_active */
278 asic_blank_start = asic_blank_end +
279 (patched_crtc_timing.v_border_top +
280 patched_crtc_timing.v_addressable +
281 patched_crtc_timing.v_border_bottom)
284 REG_UPDATE_2(OTG_V_BLANK_START_END,
285 OTG_V_BLANK_START, asic_blank_start,
286 OTG_V_BLANK_END, asic_blank_end);
288 /* Use OTG_VERTICAL_INTERRUPT2 replace VUPDATE interrupt,
289 * program the reg for interrupt postition.
291 vertical_line_start = asic_blank_end - optc->dlg_otg_param.vstartup_start + 1;
292 if (vertical_line_start < 0) {
294 vertical_line_start = 0;
296 REG_SET(OTG_VERTICAL_INTERRUPT2_POSITION, 0,
297 OTG_VERTICAL_INTERRUPT2_LINE_START, vertical_line_start);
299 /* v_sync polarity */
300 v_sync_polarity = patched_crtc_timing.flags.VSYNC_POSITIVE_POLARITY ?
303 REG_UPDATE(OTG_V_SYNC_A_CNTL,
304 OTG_V_SYNC_A_POL, v_sync_polarity);
306 v_init = asic_blank_start;
307 if (optc->dlg_otg_param.signal == SIGNAL_TYPE_DISPLAY_PORT ||
308 optc->dlg_otg_param.signal == SIGNAL_TYPE_DISPLAY_PORT_MST ||
309 optc->dlg_otg_param.signal == SIGNAL_TYPE_EDP) {
311 if (patched_crtc_timing.flags.INTERLACE == 1)
315 if (optc->dlg_otg_param.vstartup_start > asic_blank_end)
316 v_fp2 = optc->dlg_otg_param.vstartup_start > asic_blank_end;
319 if (patched_crtc_timing.flags.INTERLACE == 1) {
320 REG_UPDATE(OTG_INTERLACE_CONTROL,
321 OTG_INTERLACE_ENABLE, 1);
323 if ((optc->dlg_otg_param.vstartup_start/2)*2 > asic_blank_end)
326 REG_UPDATE(OTG_INTERLACE_CONTROL,
327 OTG_INTERLACE_ENABLE, 0);
330 /* VTG enable set to 0 first VInit */
334 REG_UPDATE_2(CONTROL,
336 VTG0_VCOUNT_INIT, v_init);
338 /* original code is using VTG offset to address OTG reg, seems wrong */
339 REG_UPDATE_2(OTG_CONTROL,
340 OTG_START_POINT_CNTL, start_point,
341 OTG_FIELD_NUMBER_CNTL, field_num);
343 optc1_program_global_sync(optc);
346 * patched_crtc_timing.flags.HORZ_COUNT_BY_TWO == 1
347 * program_horz_count_by_2
348 * for DVI 30bpp mode, 0 otherwise
349 * program_horz_count_by_2(optc, &patched_crtc_timing);
352 /* Enable stereo - only when we need to pack 3D frame. Other types
353 * of stereo handled in explicit call
355 h_div_2 = (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_YCBCR420) ?
358 REG_UPDATE(OTG_H_TIMING_CNTL,
359 OTG_H_TIMING_DIV_BY2, h_div_2);
363 void optc1_set_blank_data_double_buffer(struct timing_generator *optc, bool enable)
365 struct optc *optc1 = DCN10TG_FROM_TG(optc);
367 uint32_t blank_data_double_buffer_enable = enable ? 1 : 0;
369 REG_UPDATE(OTG_DOUBLE_BUFFER_CONTROL,
370 OTG_BLANK_DATA_DOUBLE_BUFFER_EN, blank_data_double_buffer_enable);
375 * Call ASIC Control Object to UnBlank CRTC.
377 static void optc1_unblank_crtc(struct timing_generator *optc)
379 struct optc *optc1 = DCN10TG_FROM_TG(optc);
380 uint32_t vertical_interrupt_enable = 0;
382 REG_GET(OTG_VERTICAL_INTERRUPT2_CONTROL,
383 OTG_VERTICAL_INTERRUPT2_INT_ENABLE, &vertical_interrupt_enable);
385 /* temporary work around for vertical interrupt, once vertical interrupt enabled,
386 * this check will be removed.
388 if (vertical_interrupt_enable)
389 optc1_set_blank_data_double_buffer(optc, true);
391 REG_UPDATE_2(OTG_BLANK_CONTROL,
392 OTG_BLANK_DATA_EN, 0,
393 OTG_BLANK_DE_MODE, 0);
398 * Call ASIC Control Object to Blank CRTC.
401 static void optc1_blank_crtc(struct timing_generator *optc)
403 struct optc *optc1 = DCN10TG_FROM_TG(optc);
405 REG_UPDATE_2(OTG_BLANK_CONTROL,
406 OTG_BLANK_DATA_EN, 1,
407 OTG_BLANK_DE_MODE, 0);
409 optc1_set_blank_data_double_buffer(optc, false);
412 void optc1_set_blank(struct timing_generator *optc,
413 bool enable_blanking)
416 optc1_blank_crtc(optc);
418 optc1_unblank_crtc(optc);
421 bool optc1_is_blanked(struct timing_generator *optc)
423 struct optc *optc1 = DCN10TG_FROM_TG(optc);
425 uint32_t blank_state;
427 REG_GET_2(OTG_BLANK_CONTROL,
428 OTG_BLANK_DATA_EN, &blank_en,
429 OTG_CURRENT_BLANK_STATE, &blank_state);
431 return blank_en && blank_state;
434 void optc1_enable_optc_clock(struct timing_generator *optc, bool enable)
436 struct optc *optc1 = DCN10TG_FROM_TG(optc);
439 REG_UPDATE_2(OPTC_INPUT_CLOCK_CONTROL,
440 OPTC_INPUT_CLK_EN, 1,
441 OPTC_INPUT_CLK_GATE_DIS, 1);
443 REG_WAIT(OPTC_INPUT_CLOCK_CONTROL,
444 OPTC_INPUT_CLK_ON, 1,
448 REG_UPDATE_2(OTG_CLOCK_CONTROL,
450 OTG_CLOCK_GATE_DIS, 1);
451 REG_WAIT(OTG_CLOCK_CONTROL,
456 //last chance to clear underflow, otherwise, it will always there due to clock is off.
457 if (optc->funcs->is_optc_underflow_occurred(optc) == true)
458 optc->funcs->clear_optc_underflow(optc);
460 REG_UPDATE_2(OTG_CLOCK_CONTROL,
461 OTG_CLOCK_GATE_DIS, 0,
464 REG_UPDATE_2(OPTC_INPUT_CLOCK_CONTROL,
465 OPTC_INPUT_CLK_GATE_DIS, 0,
466 OPTC_INPUT_CLK_EN, 0);
472 * Enable CRTC - call ASIC Control Object to enable Timing generator.
474 static bool optc1_enable_crtc(struct timing_generator *optc)
476 /* TODO FPGA wait for answer
477 * OTG_MASTER_UPDATE_MODE != CRTC_MASTER_UPDATE_MODE
478 * OTG_MASTER_UPDATE_LOCK != CRTC_MASTER_UPDATE_LOCK
480 struct optc *optc1 = DCN10TG_FROM_TG(optc);
482 /* opp instance for OTG. For DCN1.0, ODM is remoed.
483 * OPP and OPTC should 1:1 mapping
485 REG_UPDATE(OPTC_DATA_SOURCE_SELECT,
486 OPTC_SRC_SEL, optc->inst);
488 /* VTG enable first is for HW workaround */
493 REG_UPDATE_2(OTG_CONTROL,
494 OTG_DISABLE_POINT_CNTL, 3,
500 /* disable_crtc - call ASIC Control Object to disable Timing generator. */
501 bool optc1_disable_crtc(struct timing_generator *optc)
503 struct optc *optc1 = DCN10TG_FROM_TG(optc);
505 /* disable otg request until end of the first line
506 * in the vertical blank region
508 REG_UPDATE_2(OTG_CONTROL,
509 OTG_DISABLE_POINT_CNTL, 3,
515 /* CRTC disabled, so disable clock. */
516 REG_WAIT(OTG_CLOCK_CONTROL,
524 void optc1_program_blank_color(
525 struct timing_generator *optc,
526 const struct tg_color *black_color)
528 struct optc *optc1 = DCN10TG_FROM_TG(optc);
530 REG_SET_3(OTG_BLACK_COLOR, 0,
531 OTG_BLACK_COLOR_B_CB, black_color->color_b_cb,
532 OTG_BLACK_COLOR_G_Y, black_color->color_g_y,
533 OTG_BLACK_COLOR_R_CR, black_color->color_r_cr);
536 bool optc1_validate_timing(
537 struct timing_generator *optc,
538 const struct dc_crtc_timing *timing)
540 uint32_t interlace_factor;
543 uint32_t min_v_blank;
544 struct optc *optc1 = DCN10TG_FROM_TG(optc);
546 ASSERT(timing != NULL);
548 interlace_factor = timing->flags.INTERLACE ? 2 : 1;
549 v_blank = (timing->v_total - timing->v_addressable -
550 timing->v_border_top - timing->v_border_bottom) *
553 h_blank = (timing->h_total - timing->h_addressable -
554 timing->h_border_right -
555 timing->h_border_left);
557 if (timing->timing_3d_format != TIMING_3D_FORMAT_NONE &&
558 timing->timing_3d_format != TIMING_3D_FORMAT_HW_FRAME_PACKING &&
559 timing->timing_3d_format != TIMING_3D_FORMAT_TOP_AND_BOTTOM &&
560 timing->timing_3d_format != TIMING_3D_FORMAT_SIDE_BY_SIDE &&
561 timing->timing_3d_format != TIMING_3D_FORMAT_FRAME_ALTERNATE &&
562 timing->timing_3d_format != TIMING_3D_FORMAT_INBAND_FA)
565 /* Temporarily blocking interlacing mode until it's supported */
566 if (timing->flags.INTERLACE == 1)
569 /* Check maximum number of pixels supported by Timing Generator
570 * (Currently will never fail, in order to fail needs display which
571 * needs more than 8192 horizontal and
572 * more than 8192 vertical total pixels)
574 if (timing->h_total > optc1->max_h_total ||
575 timing->v_total > optc1->max_v_total)
579 if (h_blank < optc1->min_h_blank)
582 if (timing->h_sync_width < optc1->min_h_sync_width ||
583 timing->v_sync_width < optc1->min_v_sync_width)
586 min_v_blank = timing->flags.INTERLACE?optc1->min_v_blank_interlace:optc1->min_v_blank;
588 if (v_blank < min_v_blank)
599 * Get counter for vertical blanks. use register CRTC_STATUS_FRAME_COUNT which
600 * holds the counter of frames.
603 * struct timing_generator *optc - [in] timing generator which controls the
607 * Counter of frames, which should equal to number of vblanks.
609 uint32_t optc1_get_vblank_counter(struct timing_generator *optc)
611 struct optc *optc1 = DCN10TG_FROM_TG(optc);
612 uint32_t frame_count;
614 REG_GET(OTG_STATUS_FRAME_COUNT,
615 OTG_FRAME_COUNT, &frame_count);
620 void optc1_lock(struct timing_generator *optc)
622 struct optc *optc1 = DCN10TG_FROM_TG(optc);
624 REG_SET(OTG_GLOBAL_CONTROL0, 0,
625 OTG_MASTER_UPDATE_LOCK_SEL, optc->inst);
626 REG_SET(OTG_MASTER_UPDATE_LOCK, 0,
627 OTG_MASTER_UPDATE_LOCK, 1);
629 /* Should be fast, status does not update on maximus */
630 if (optc->ctx->dce_environment != DCE_ENV_FPGA_MAXIMUS)
631 REG_WAIT(OTG_MASTER_UPDATE_LOCK,
632 UPDATE_LOCK_STATUS, 1,
636 void optc1_unlock(struct timing_generator *optc)
638 struct optc *optc1 = DCN10TG_FROM_TG(optc);
640 REG_SET(OTG_MASTER_UPDATE_LOCK, 0,
641 OTG_MASTER_UPDATE_LOCK, 0);
644 void optc1_get_position(struct timing_generator *optc,
645 struct crtc_position *position)
647 struct optc *optc1 = DCN10TG_FROM_TG(optc);
649 REG_GET_2(OTG_STATUS_POSITION,
650 OTG_HORZ_COUNT, &position->horizontal_count,
651 OTG_VERT_COUNT, &position->vertical_count);
653 REG_GET(OTG_NOM_VERT_POSITION,
654 OTG_VERT_COUNT_NOM, &position->nominal_vcount);
657 bool optc1_is_counter_moving(struct timing_generator *optc)
659 struct crtc_position position1, position2;
661 optc->funcs->get_position(optc, &position1);
662 optc->funcs->get_position(optc, &position2);
664 if (position1.horizontal_count == position2.horizontal_count &&
665 position1.vertical_count == position2.vertical_count)
671 bool optc1_did_triggered_reset_occur(
672 struct timing_generator *optc)
674 struct optc *optc1 = DCN10TG_FROM_TG(optc);
675 uint32_t occurred_force, occurred_vsync;
677 REG_GET(OTG_FORCE_COUNT_NOW_CNTL,
678 OTG_FORCE_COUNT_NOW_OCCURRED, &occurred_force);
680 REG_GET(OTG_VERT_SYNC_CONTROL,
681 OTG_FORCE_VSYNC_NEXT_LINE_OCCURRED, &occurred_vsync);
683 return occurred_vsync != 0 || occurred_force != 0;
686 void optc1_disable_reset_trigger(struct timing_generator *optc)
688 struct optc *optc1 = DCN10TG_FROM_TG(optc);
690 REG_WRITE(OTG_TRIGA_CNTL, 0);
692 REG_SET(OTG_FORCE_COUNT_NOW_CNTL, 0,
693 OTG_FORCE_COUNT_NOW_CLEAR, 1);
695 REG_SET(OTG_VERT_SYNC_CONTROL, 0,
696 OTG_FORCE_VSYNC_NEXT_LINE_CLEAR, 1);
699 void optc1_enable_reset_trigger(struct timing_generator *optc, int source_tg_inst)
701 struct optc *optc1 = DCN10TG_FROM_TG(optc);
702 uint32_t falling_edge;
704 REG_GET(OTG_V_SYNC_A_CNTL,
705 OTG_V_SYNC_A_POL, &falling_edge);
708 REG_SET_3(OTG_TRIGA_CNTL, 0,
709 /* vsync signal from selected OTG pipe based
710 * on OTG_TRIG_SOURCE_PIPE_SELECT setting
712 OTG_TRIGA_SOURCE_SELECT, 20,
713 OTG_TRIGA_SOURCE_PIPE_SELECT, source_tg_inst,
714 /* always detect falling edge */
715 OTG_TRIGA_FALLING_EDGE_DETECT_CNTL, 1);
717 REG_SET_3(OTG_TRIGA_CNTL, 0,
718 /* vsync signal from selected OTG pipe based
719 * on OTG_TRIG_SOURCE_PIPE_SELECT setting
721 OTG_TRIGA_SOURCE_SELECT, 20,
722 OTG_TRIGA_SOURCE_PIPE_SELECT, source_tg_inst,
723 /* always detect rising edge */
724 OTG_TRIGA_RISING_EDGE_DETECT_CNTL, 1);
726 REG_SET(OTG_FORCE_COUNT_NOW_CNTL, 0,
727 /* force H count to H_TOTAL and V count to V_TOTAL in
728 * progressive mode and V_TOTAL-1 in interlaced mode
730 OTG_FORCE_COUNT_NOW_MODE, 2);
733 void optc1_enable_crtc_reset(
734 struct timing_generator *optc,
736 struct crtc_trigger_info *crtc_tp)
738 struct optc *optc1 = DCN10TG_FROM_TG(optc);
739 uint32_t falling_edge = 0;
740 uint32_t rising_edge = 0;
742 switch (crtc_tp->event) {
744 case CRTC_EVENT_VSYNC_RISING:
748 case CRTC_EVENT_VSYNC_FALLING:
753 REG_SET_4(OTG_TRIGA_CNTL, 0,
754 /* vsync signal from selected OTG pipe based
755 * on OTG_TRIG_SOURCE_PIPE_SELECT setting
757 OTG_TRIGA_SOURCE_SELECT, 20,
758 OTG_TRIGA_SOURCE_PIPE_SELECT, source_tg_inst,
759 /* always detect falling edge */
760 OTG_TRIGA_RISING_EDGE_DETECT_CNTL, rising_edge,
761 OTG_TRIGA_FALLING_EDGE_DETECT_CNTL, falling_edge);
763 switch (crtc_tp->delay) {
764 case TRIGGER_DELAY_NEXT_LINE:
765 REG_SET(OTG_VERT_SYNC_CONTROL, 0,
766 OTG_AUTO_FORCE_VSYNC_MODE, 1);
768 case TRIGGER_DELAY_NEXT_PIXEL:
769 REG_SET(OTG_FORCE_COUNT_NOW_CNTL, 0,
770 /* force H count to H_TOTAL and V count to V_TOTAL in
771 * progressive mode and V_TOTAL-1 in interlaced mode
773 OTG_FORCE_COUNT_NOW_MODE, 2);
778 void optc1_wait_for_state(struct timing_generator *optc,
779 enum crtc_state state)
781 struct optc *optc1 = DCN10TG_FROM_TG(optc);
784 case CRTC_STATE_VBLANK:
787 1, 100000); /* 1 vupdate at 10hz */
790 case CRTC_STATE_VACTIVE:
792 OTG_V_ACTIVE_DISP, 1,
793 1, 100000); /* 1 vupdate at 10hz */
801 void optc1_set_early_control(
802 struct timing_generator *optc,
805 /* asic design change, do not need this control
806 * empty for share caller logic
811 void optc1_set_static_screen_control(
812 struct timing_generator *optc,
815 struct optc *optc1 = DCN10TG_FROM_TG(optc);
817 /* Bit 8 is no longer applicable in RV for PSR case,
818 * set bit 8 to 0 if given
820 if ((value & STATIC_SCREEN_EVENT_MASK_RANGETIMING_DOUBLE_BUFFER_UPDATE_EN)
823 ~STATIC_SCREEN_EVENT_MASK_RANGETIMING_DOUBLE_BUFFER_UPDATE_EN;
825 REG_SET_2(OTG_STATIC_SCREEN_CONTROL, 0,
826 OTG_STATIC_SCREEN_EVENT_MASK, value,
827 OTG_STATIC_SCREEN_FRAME_COUNT, 2);
832 *****************************************************************************
836 * Program dynamic refresh rate registers m_OTGx_OTG_V_TOTAL_*.
838 *****************************************************************************
841 struct timing_generator *optc,
842 const struct drr_params *params)
844 struct optc *optc1 = DCN10TG_FROM_TG(optc);
846 if (params != NULL &&
847 params->vertical_total_max > 0 &&
848 params->vertical_total_min > 0) {
850 REG_SET(OTG_V_TOTAL_MAX, 0,
851 OTG_V_TOTAL_MAX, params->vertical_total_max - 1);
853 REG_SET(OTG_V_TOTAL_MIN, 0,
854 OTG_V_TOTAL_MIN, params->vertical_total_min - 1);
856 REG_UPDATE_5(OTG_V_TOTAL_CONTROL,
857 OTG_V_TOTAL_MIN_SEL, 1,
858 OTG_V_TOTAL_MAX_SEL, 1,
859 OTG_FORCE_LOCK_ON_EVENT, 0,
860 OTG_SET_V_TOTAL_MIN_MASK_EN, 0,
861 OTG_SET_V_TOTAL_MIN_MASK, 0);
863 REG_UPDATE_4(OTG_V_TOTAL_CONTROL,
864 OTG_SET_V_TOTAL_MIN_MASK, 0,
865 OTG_V_TOTAL_MIN_SEL, 0,
866 OTG_V_TOTAL_MAX_SEL, 0,
867 OTG_FORCE_LOCK_ON_EVENT, 0);
869 REG_SET(OTG_V_TOTAL_MIN, 0,
872 REG_SET(OTG_V_TOTAL_MAX, 0,
877 static void optc1_set_test_pattern(
878 struct timing_generator *optc,
879 /* TODO: replace 'controller_dp_test_pattern' by 'test_pattern_mode'
880 * because this is not DP-specific (which is probably somewhere in DP
882 enum controller_dp_test_pattern test_pattern,
883 enum dc_color_depth color_depth)
885 struct optc *optc1 = DCN10TG_FROM_TG(optc);
886 enum test_pattern_color_format bit_depth;
887 enum test_pattern_dyn_range dyn_range;
888 enum test_pattern_mode mode;
889 uint32_t pattern_mask;
890 uint32_t pattern_data;
891 /* color ramp generator mixes 16-bits color */
892 uint32_t src_bpc = 16;
896 /* RGB values of the color bars.
897 * Produce two RGB colors: RGB0 - white (all Fs)
898 * and RGB1 - black (all 0s)
899 * (three RGB components for two colors)
901 uint16_t src_color[6] = {0xFFFF, 0xFFFF, 0xFFFF, 0x0000,
903 /* dest color (converted to the specified color format) */
904 uint16_t dst_color[6];
907 /* translate to bit depth */
908 switch (color_depth) {
909 case COLOR_DEPTH_666:
910 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_6;
912 case COLOR_DEPTH_888:
913 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_8;
915 case COLOR_DEPTH_101010:
916 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_10;
918 case COLOR_DEPTH_121212:
919 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_12;
922 bit_depth = TEST_PATTERN_COLOR_FORMAT_BPC_8;
926 switch (test_pattern) {
927 case CONTROLLER_DP_TEST_PATTERN_COLORSQUARES:
928 case CONTROLLER_DP_TEST_PATTERN_COLORSQUARES_CEA:
930 dyn_range = (test_pattern ==
931 CONTROLLER_DP_TEST_PATTERN_COLORSQUARES_CEA ?
932 TEST_PATTERN_DYN_RANGE_CEA :
933 TEST_PATTERN_DYN_RANGE_VESA);
934 mode = TEST_PATTERN_MODE_COLORSQUARES_RGB;
936 REG_UPDATE_2(OTG_TEST_PATTERN_PARAMETERS,
937 OTG_TEST_PATTERN_VRES, 6,
938 OTG_TEST_PATTERN_HRES, 6);
940 REG_UPDATE_4(OTG_TEST_PATTERN_CONTROL,
941 OTG_TEST_PATTERN_EN, 1,
942 OTG_TEST_PATTERN_MODE, mode,
943 OTG_TEST_PATTERN_DYNAMIC_RANGE, dyn_range,
944 OTG_TEST_PATTERN_COLOR_FORMAT, bit_depth);
948 case CONTROLLER_DP_TEST_PATTERN_VERTICALBARS:
949 case CONTROLLER_DP_TEST_PATTERN_HORIZONTALBARS:
951 mode = (test_pattern ==
952 CONTROLLER_DP_TEST_PATTERN_VERTICALBARS ?
953 TEST_PATTERN_MODE_VERTICALBARS :
954 TEST_PATTERN_MODE_HORIZONTALBARS);
957 case TEST_PATTERN_COLOR_FORMAT_BPC_6:
960 case TEST_PATTERN_COLOR_FORMAT_BPC_8:
963 case TEST_PATTERN_COLOR_FORMAT_BPC_10:
971 /* adjust color to the required colorFormat */
972 for (index = 0; index < 6; index++) {
973 /* dst = 2^dstBpc * src / 2^srcBpc = src >>
977 src_color[index] >> (src_bpc - dst_bpc);
978 /* CRTC_TEST_PATTERN_DATA has 16 bits,
979 * lowest 6 are hardwired to ZERO
980 * color bits should be left aligned aligned to MSB
981 * XXXXXXXXXX000000 for 10 bit,
982 * XXXXXXXX00000000 for 8 bit and XXXXXX0000000000 for 6
984 dst_color[index] <<= (16 - dst_bpc);
987 REG_WRITE(OTG_TEST_PATTERN_PARAMETERS, 0);
989 /* We have to write the mask before data, similar to pipeline.
990 * For example, for 8 bpc, if we want RGB0 to be magenta,
991 * and RGB1 to be cyan,
992 * we need to make 7 writes:
994 * 000001 00000000 00000000 set mask to R0
995 * 000010 11111111 00000000 R0 255, 0xFF00, set mask to G0
996 * 000100 00000000 00000000 G0 0, 0x0000, set mask to B0
997 * 001000 11111111 00000000 B0 255, 0xFF00, set mask to R1
998 * 010000 00000000 00000000 R1 0, 0x0000, set mask to G1
999 * 100000 11111111 00000000 G1 255, 0xFF00, set mask to B1
1000 * 100000 11111111 00000000 B1 255, 0xFF00
1002 * we will make a loop of 6 in which we prepare the mask,
1003 * then write, then prepare the color for next write.
1004 * first iteration will write mask only,
1005 * but each next iteration color prepared in
1006 * previous iteration will be written within new mask,
1007 * the last component will written separately,
1008 * mask is not changing between 6th and 7th write
1009 * and color will be prepared by last iteration
1012 /* write color, color values mask in CRTC_TEST_PATTERN_MASK
1013 * is B1, G1, R1, B0, G0, R0
1016 for (index = 0; index < 6; index++) {
1017 /* prepare color mask, first write PATTERN_DATA
1018 * will have all zeros
1020 pattern_mask = (1 << index);
1022 /* write color component */
1023 REG_SET_2(OTG_TEST_PATTERN_COLOR, 0,
1024 OTG_TEST_PATTERN_MASK, pattern_mask,
1025 OTG_TEST_PATTERN_DATA, pattern_data);
1027 /* prepare next color component,
1028 * will be written in the next iteration
1030 pattern_data = dst_color[index];
1032 /* write last color component,
1033 * it's been already prepared in the loop
1035 REG_SET_2(OTG_TEST_PATTERN_COLOR, 0,
1036 OTG_TEST_PATTERN_MASK, pattern_mask,
1037 OTG_TEST_PATTERN_DATA, pattern_data);
1039 /* enable test pattern */
1040 REG_UPDATE_4(OTG_TEST_PATTERN_CONTROL,
1041 OTG_TEST_PATTERN_EN, 1,
1042 OTG_TEST_PATTERN_MODE, mode,
1043 OTG_TEST_PATTERN_DYNAMIC_RANGE, 0,
1044 OTG_TEST_PATTERN_COLOR_FORMAT, bit_depth);
1048 case CONTROLLER_DP_TEST_PATTERN_COLORRAMP:
1050 mode = (bit_depth ==
1051 TEST_PATTERN_COLOR_FORMAT_BPC_10 ?
1052 TEST_PATTERN_MODE_DUALRAMP_RGB :
1053 TEST_PATTERN_MODE_SINGLERAMP_RGB);
1055 switch (bit_depth) {
1056 case TEST_PATTERN_COLOR_FORMAT_BPC_6:
1059 case TEST_PATTERN_COLOR_FORMAT_BPC_8:
1062 case TEST_PATTERN_COLOR_FORMAT_BPC_10:
1070 /* increment for the first ramp for one color gradation
1071 * 1 gradation for 6-bit color is 2^10
1072 * gradations in 16-bit color
1074 inc_base = (src_bpc - dst_bpc);
1076 switch (bit_depth) {
1077 case TEST_PATTERN_COLOR_FORMAT_BPC_6:
1079 REG_UPDATE_5(OTG_TEST_PATTERN_PARAMETERS,
1080 OTG_TEST_PATTERN_INC0, inc_base,
1081 OTG_TEST_PATTERN_INC1, 0,
1082 OTG_TEST_PATTERN_HRES, 6,
1083 OTG_TEST_PATTERN_VRES, 6,
1084 OTG_TEST_PATTERN_RAMP0_OFFSET, 0);
1087 case TEST_PATTERN_COLOR_FORMAT_BPC_8:
1089 REG_UPDATE_5(OTG_TEST_PATTERN_PARAMETERS,
1090 OTG_TEST_PATTERN_INC0, inc_base,
1091 OTG_TEST_PATTERN_INC1, 0,
1092 OTG_TEST_PATTERN_HRES, 8,
1093 OTG_TEST_PATTERN_VRES, 6,
1094 OTG_TEST_PATTERN_RAMP0_OFFSET, 0);
1097 case TEST_PATTERN_COLOR_FORMAT_BPC_10:
1099 REG_UPDATE_5(OTG_TEST_PATTERN_PARAMETERS,
1100 OTG_TEST_PATTERN_INC0, inc_base,
1101 OTG_TEST_PATTERN_INC1, inc_base + 2,
1102 OTG_TEST_PATTERN_HRES, 8,
1103 OTG_TEST_PATTERN_VRES, 5,
1104 OTG_TEST_PATTERN_RAMP0_OFFSET, 384 << 6);
1111 REG_WRITE(OTG_TEST_PATTERN_COLOR, 0);
1113 /* enable test pattern */
1114 REG_WRITE(OTG_TEST_PATTERN_CONTROL, 0);
1116 REG_SET_4(OTG_TEST_PATTERN_CONTROL, 0,
1117 OTG_TEST_PATTERN_EN, 1,
1118 OTG_TEST_PATTERN_MODE, mode,
1119 OTG_TEST_PATTERN_DYNAMIC_RANGE, 0,
1120 OTG_TEST_PATTERN_COLOR_FORMAT, bit_depth);
1123 case CONTROLLER_DP_TEST_PATTERN_VIDEOMODE:
1125 REG_WRITE(OTG_TEST_PATTERN_CONTROL, 0);
1126 REG_WRITE(OTG_TEST_PATTERN_COLOR, 0);
1127 REG_WRITE(OTG_TEST_PATTERN_PARAMETERS, 0);
1136 void optc1_get_crtc_scanoutpos(
1137 struct timing_generator *optc,
1138 uint32_t *v_blank_start,
1139 uint32_t *v_blank_end,
1140 uint32_t *h_position,
1141 uint32_t *v_position)
1143 struct optc *optc1 = DCN10TG_FROM_TG(optc);
1144 struct crtc_position position;
1146 REG_GET_2(OTG_V_BLANK_START_END,
1147 OTG_V_BLANK_START, v_blank_start,
1148 OTG_V_BLANK_END, v_blank_end);
1150 optc1_get_position(optc, &position);
1152 *h_position = position.horizontal_count;
1153 *v_position = position.vertical_count;
1156 static void optc1_enable_stereo(struct timing_generator *optc,
1157 const struct dc_crtc_timing *timing, struct crtc_stereo_flags *flags)
1159 struct optc *optc1 = DCN10TG_FROM_TG(optc);
1163 stereo_en = flags->FRAME_PACKED == 0 ? 1 : 0;
1165 if (flags->PROGRAM_STEREO)
1166 REG_UPDATE_3(OTG_STEREO_CONTROL,
1167 OTG_STEREO_EN, stereo_en,
1168 OTG_STEREO_SYNC_OUTPUT_LINE_NUM, 0,
1169 OTG_STEREO_SYNC_OUTPUT_POLARITY, 0);
1171 if (flags->PROGRAM_POLARITY)
1172 REG_UPDATE(OTG_STEREO_CONTROL,
1173 OTG_STEREO_EYE_FLAG_POLARITY,
1174 flags->RIGHT_EYE_POLARITY == 0 ? 0 : 1);
1176 if (flags->DISABLE_STEREO_DP_SYNC)
1177 REG_UPDATE(OTG_STEREO_CONTROL,
1178 OTG_DISABLE_STEREOSYNC_OUTPUT_FOR_DP, 1);
1180 if (flags->PROGRAM_STEREO)
1181 REG_UPDATE_3(OTG_3D_STRUCTURE_CONTROL,
1182 OTG_3D_STRUCTURE_EN, flags->FRAME_PACKED,
1183 OTG_3D_STRUCTURE_V_UPDATE_MODE, flags->FRAME_PACKED,
1184 OTG_3D_STRUCTURE_STEREO_SEL_OVR, flags->FRAME_PACKED);
1189 void optc1_program_stereo(struct timing_generator *optc,
1190 const struct dc_crtc_timing *timing, struct crtc_stereo_flags *flags)
1192 if (flags->PROGRAM_STEREO)
1193 optc1_enable_stereo(optc, timing, flags);
1195 optc1_disable_stereo(optc);
1199 bool optc1_is_stereo_left_eye(struct timing_generator *optc)
1202 uint32_t left_eye = 0;
1203 struct optc *optc1 = DCN10TG_FROM_TG(optc);
1205 REG_GET(OTG_STEREO_STATUS,
1206 OTG_STEREO_CURRENT_EYE, &left_eye);
1215 void optc1_read_otg_state(struct optc *optc1,
1216 struct dcn_otg_state *s)
1218 REG_GET(OTG_CONTROL,
1219 OTG_MASTER_EN, &s->otg_enabled);
1221 REG_GET_2(OTG_V_BLANK_START_END,
1222 OTG_V_BLANK_START, &s->v_blank_start,
1223 OTG_V_BLANK_END, &s->v_blank_end);
1225 REG_GET(OTG_V_SYNC_A_CNTL,
1226 OTG_V_SYNC_A_POL, &s->v_sync_a_pol);
1228 REG_GET(OTG_V_TOTAL,
1229 OTG_V_TOTAL, &s->v_total);
1231 REG_GET(OTG_V_TOTAL_MAX,
1232 OTG_V_TOTAL_MAX, &s->v_total_max);
1234 REG_GET(OTG_V_TOTAL_MIN,
1235 OTG_V_TOTAL_MIN, &s->v_total_min);
1237 REG_GET(OTG_V_TOTAL_CONTROL,
1238 OTG_V_TOTAL_MAX_SEL, &s->v_total_max_sel);
1240 REG_GET(OTG_V_TOTAL_CONTROL,
1241 OTG_V_TOTAL_MIN_SEL, &s->v_total_min_sel);
1243 REG_GET_2(OTG_V_SYNC_A,
1244 OTG_V_SYNC_A_START, &s->v_sync_a_start,
1245 OTG_V_SYNC_A_END, &s->v_sync_a_end);
1247 REG_GET_2(OTG_H_BLANK_START_END,
1248 OTG_H_BLANK_START, &s->h_blank_start,
1249 OTG_H_BLANK_END, &s->h_blank_end);
1251 REG_GET_2(OTG_H_SYNC_A,
1252 OTG_H_SYNC_A_START, &s->h_sync_a_start,
1253 OTG_H_SYNC_A_END, &s->h_sync_a_end);
1255 REG_GET(OTG_H_SYNC_A_CNTL,
1256 OTG_H_SYNC_A_POL, &s->h_sync_a_pol);
1258 REG_GET(OTG_H_TOTAL,
1259 OTG_H_TOTAL, &s->h_total);
1261 REG_GET(OPTC_INPUT_GLOBAL_CONTROL,
1262 OPTC_UNDERFLOW_OCCURRED_STATUS, &s->underflow_occurred_status);
1265 bool optc1_get_otg_active_size(struct timing_generator *optc,
1266 uint32_t *otg_active_width,
1267 uint32_t *otg_active_height)
1269 uint32_t otg_enabled;
1270 uint32_t v_blank_start;
1271 uint32_t v_blank_end;
1272 uint32_t h_blank_start;
1273 uint32_t h_blank_end;
1274 struct optc *optc1 = DCN10TG_FROM_TG(optc);
1277 REG_GET(OTG_CONTROL,
1278 OTG_MASTER_EN, &otg_enabled);
1280 if (otg_enabled == 0)
1283 REG_GET_2(OTG_V_BLANK_START_END,
1284 OTG_V_BLANK_START, &v_blank_start,
1285 OTG_V_BLANK_END, &v_blank_end);
1287 REG_GET_2(OTG_H_BLANK_START_END,
1288 OTG_H_BLANK_START, &h_blank_start,
1289 OTG_H_BLANK_END, &h_blank_end);
1291 *otg_active_width = v_blank_start - v_blank_end;
1292 *otg_active_height = h_blank_start - h_blank_end;
1296 void optc1_clear_optc_underflow(struct timing_generator *optc)
1298 struct optc *optc1 = DCN10TG_FROM_TG(optc);
1300 REG_UPDATE(OPTC_INPUT_GLOBAL_CONTROL, OPTC_UNDERFLOW_CLEAR, 1);
1303 void optc1_tg_init(struct timing_generator *optc)
1305 optc1_set_blank_data_double_buffer(optc, true);
1306 optc1_clear_optc_underflow(optc);
1309 bool optc1_is_tg_enabled(struct timing_generator *optc)
1311 struct optc *optc1 = DCN10TG_FROM_TG(optc);
1312 uint32_t otg_enabled = 0;
1314 REG_GET(OTG_CONTROL, OTG_MASTER_EN, &otg_enabled);
1316 return (otg_enabled != 0);
1320 bool optc1_is_optc_underflow_occurred(struct timing_generator *optc)
1322 struct optc *optc1 = DCN10TG_FROM_TG(optc);
1323 uint32_t underflow_occurred = 0;
1325 REG_GET(OPTC_INPUT_GLOBAL_CONTROL,
1326 OPTC_UNDERFLOW_OCCURRED_STATUS,
1327 &underflow_occurred);
1329 return (underflow_occurred == 1);
1332 bool optc1_configure_crc(struct timing_generator *optc,
1333 const struct crc_params *params)
1335 struct optc *optc1 = DCN10TG_FROM_TG(optc);
1337 /* Cannot configure crc on a CRTC that is disabled */
1338 if (!optc1_is_tg_enabled(optc))
1341 REG_WRITE(OTG_CRC_CNTL, 0);
1343 if (!params->enable)
1346 /* Program frame boundaries */
1347 /* Window A x axis start and end. */
1348 REG_UPDATE_2(OTG_CRC0_WINDOWA_X_CONTROL,
1349 OTG_CRC0_WINDOWA_X_START, params->windowa_x_start,
1350 OTG_CRC0_WINDOWA_X_END, params->windowa_x_end);
1352 /* Window A y axis start and end. */
1353 REG_UPDATE_2(OTG_CRC0_WINDOWA_Y_CONTROL,
1354 OTG_CRC0_WINDOWA_Y_START, params->windowa_y_start,
1355 OTG_CRC0_WINDOWA_Y_END, params->windowa_y_end);
1357 /* Window B x axis start and end. */
1358 REG_UPDATE_2(OTG_CRC0_WINDOWB_X_CONTROL,
1359 OTG_CRC0_WINDOWB_X_START, params->windowb_x_start,
1360 OTG_CRC0_WINDOWB_X_END, params->windowb_x_end);
1362 /* Window B y axis start and end. */
1363 REG_UPDATE_2(OTG_CRC0_WINDOWB_Y_CONTROL,
1364 OTG_CRC0_WINDOWB_Y_START, params->windowb_y_start,
1365 OTG_CRC0_WINDOWB_Y_END, params->windowb_y_end);
1367 /* Set crc mode and selection, and enable. Only using CRC0*/
1368 REG_UPDATE_3(OTG_CRC_CNTL,
1369 OTG_CRC_CONT_EN, params->continuous_mode ? 1 : 0,
1370 OTG_CRC0_SELECT, params->selection,
1376 bool optc1_get_crc(struct timing_generator *optc,
1377 uint32_t *r_cr, uint32_t *g_y, uint32_t *b_cb)
1380 struct optc *optc1 = DCN10TG_FROM_TG(optc);
1382 REG_GET(OTG_CRC_CNTL, OTG_CRC_EN, &field);
1384 /* Early return if CRC is not enabled for this CRTC */
1388 REG_GET_2(OTG_CRC0_DATA_RG,
1392 REG_GET(OTG_CRC0_DATA_B,
1398 static const struct timing_generator_funcs dcn10_tg_funcs = {
1399 .validate_timing = optc1_validate_timing,
1400 .program_timing = optc1_program_timing,
1401 .program_vline_interrupt = optc1_program_vline_interrupt,
1402 .program_global_sync = optc1_program_global_sync,
1403 .enable_crtc = optc1_enable_crtc,
1404 .disable_crtc = optc1_disable_crtc,
1405 /* used by enable_timing_synchronization. Not need for FPGA */
1406 .is_counter_moving = optc1_is_counter_moving,
1407 .get_position = optc1_get_position,
1408 .get_frame_count = optc1_get_vblank_counter,
1409 .get_scanoutpos = optc1_get_crtc_scanoutpos,
1410 .get_otg_active_size = optc1_get_otg_active_size,
1411 .set_early_control = optc1_set_early_control,
1412 /* used by enable_timing_synchronization. Not need for FPGA */
1413 .wait_for_state = optc1_wait_for_state,
1414 .set_blank = optc1_set_blank,
1415 .is_blanked = optc1_is_blanked,
1416 .set_blank_color = optc1_program_blank_color,
1417 .did_triggered_reset_occur = optc1_did_triggered_reset_occur,
1418 .enable_reset_trigger = optc1_enable_reset_trigger,
1419 .enable_crtc_reset = optc1_enable_crtc_reset,
1420 .disable_reset_trigger = optc1_disable_reset_trigger,
1422 .unlock = optc1_unlock,
1423 .enable_optc_clock = optc1_enable_optc_clock,
1424 .set_drr = optc1_set_drr,
1425 .set_static_screen_control = optc1_set_static_screen_control,
1426 .set_test_pattern = optc1_set_test_pattern,
1427 .program_stereo = optc1_program_stereo,
1428 .is_stereo_left_eye = optc1_is_stereo_left_eye,
1429 .set_blank_data_double_buffer = optc1_set_blank_data_double_buffer,
1430 .tg_init = optc1_tg_init,
1431 .is_tg_enabled = optc1_is_tg_enabled,
1432 .is_optc_underflow_occurred = optc1_is_optc_underflow_occurred,
1433 .clear_optc_underflow = optc1_clear_optc_underflow,
1434 .get_crc = optc1_get_crc,
1435 .configure_crc = optc1_configure_crc,
1438 void dcn10_timing_generator_init(struct optc *optc1)
1440 optc1->base.funcs = &dcn10_tg_funcs;
1442 optc1->max_h_total = optc1->tg_mask->OTG_H_TOTAL + 1;
1443 optc1->max_v_total = optc1->tg_mask->OTG_V_TOTAL + 1;
1445 optc1->min_h_blank = 32;
1446 optc1->min_v_blank = 3;
1447 optc1->min_v_blank_interlace = 5;
1448 optc1->min_h_sync_width = 8;
1449 optc1->min_v_sync_width = 1;