aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2012-04-01 13:16:18 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2012-04-26 12:56:26 -0400
commit6651819b4b4fc3caa6964c5d825eb4bb996f3905 (patch)
tree942e329c3752aeef7777df0ae325b4217741f907 /drivers
parent44afb3a04391a74309d16180d1e4f8386fdfa745 (diff)
drm/i915: handle input/output sdvo timings separately in mode_set
We seem to have a decent confusion between the output timings and the input timings of the sdvo encoder. If I understand the code correctly, we use the original mode unchanged for the output timings, safe for the lvds case. And we should use the adjusted mode for input timings. Clarify the situation by adding an explicit output_dtd to the sdvo mode_set function and streamline the code-flow by moving the input and output mode setting in the sdvo encode together. Furthermore testing showed that the sdvo input timing needs the unadjusted dotclock, the sdvo chip will automatically compute the required pixel multiplier to get a dotclock above 100 MHz. Fix this up when converting a drm mode to an sdvo dtd. This regression was introduced in commit c74696b9c890074c1e1ee3d7496fc71eb3680ced Author: Pavel Roskin <proski@gnu.org> Date: Thu Sep 2 14:46:34 2010 -0400 i915: revert some checks added by commit 32aad86f particularly the following hunk: diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c index 093e914..62d22ae 100644 --- a/drivers/gpu/drm/i915/intel_sdvo.c +++ b/drivers/gpu/drm/i915/intel_sdvo.c @@ -1122,11 +1123,9 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder, /* We have tried to get input timing in mode_fixup, and filled into adjusted_mode */ - if (intel_sdvo->is_tv || intel_sdvo->is_lvds) { - intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode); + intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode); + if (intel_sdvo->is_tv || intel_sdvo->is_lvds) input_dtd.part2.sdvo_flags = intel_sdvo->sdvo_flags; - } else - intel_sdvo_get_dtd_from_mode(&input_dtd, mode); /* If it's a TV, we already set the output timing in mode_fixup. * Otherwise, the output timing is equal to the input timing. Due to questions raised in review, below a more elaborate analysis of the bug at hand: Sdvo seems to have two timings, one is the output timing which will be sent over whatever is connected on the other side of the sdvo chip (panel, hdmi screen, tv), the other is the input timing which will be generated by the gmch pipe. It looks like sdvo is expected to scale between the two. To make things slightly more complicated, we have a bunch of special cases: - For lvds panel we always use a fixed output timing, namely intel_sdvo->sdvo_lvds_fixed_mode, hence that special case. - Sdvo has an interface to generate a preferred input timing for a given output timing. This is the confusing thing that I've tried to clear up with the follow-on patches. - A special requirement is that the input pixel clock needs to be between 100MHz and 200MHz (likely to keep it within the electromechanical design range of PCIe), 270MHz on later gen4+. Lower pixel clocks are doubled/quadrupled. The thing this patch tries to fix is that the pipe needs to be explicitly instructed to double/quadruple the pixels and needs the correspondingly higher pixel clock, whereas the sdvo adaptor seems to do that itself and needs the unadjusted pixel clock. For the sdvo encode side we already set the pixel mutliplier with a different command (0x21). This patch tries to fix this mess by: - Keeping the output mode timing in the unadjusted plain mode, safe for the lvds case. - Storing the input timing in the adjusted_mode with the adjusted pixel clock. This way we don't need to frob around with the core crtc mode set code. - Fixing up the pixelclock when constructing the sdvo dtd timing struct. This is why the first hunk of the patch is an integral part of the series. - Dropping the is_tv special case because input_dtd is equivalent to adjusted_mode after these changes. Follow-up patches clear this up further (by simply ripping out intel_sdvo->input_dtd because it's not needed). v2: Extend commit message with an in-depth bug analysis. Reported-and-Tested-by: Bernard Blackham <b-linuxgit@largestprime.net> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=48157 Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> Cc: stable@kernel.org Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index e36b171c1e7..232d77d07d8 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -731,6 +731,7 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
731 uint16_t width, height; 731 uint16_t width, height;
732 uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len; 732 uint16_t h_blank_len, h_sync_len, v_blank_len, v_sync_len;
733 uint16_t h_sync_offset, v_sync_offset; 733 uint16_t h_sync_offset, v_sync_offset;
734 int mode_clock;
734 735
735 width = mode->crtc_hdisplay; 736 width = mode->crtc_hdisplay;
736 height = mode->crtc_vdisplay; 737 height = mode->crtc_vdisplay;
@@ -745,7 +746,11 @@ static void intel_sdvo_get_dtd_from_mode(struct intel_sdvo_dtd *dtd,
745 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start; 746 h_sync_offset = mode->crtc_hsync_start - mode->crtc_hblank_start;
746 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start; 747 v_sync_offset = mode->crtc_vsync_start - mode->crtc_vblank_start;
747 748
748 dtd->part1.clock = mode->clock / 10; 749 mode_clock = mode->clock;
750 mode_clock /= intel_mode_get_pixel_multiplier(mode) ?: 1;
751 mode_clock /= 10;
752 dtd->part1.clock = mode_clock;
753
749 dtd->part1.h_active = width & 0xff; 754 dtd->part1.h_active = width & 0xff;
750 dtd->part1.h_blank = h_blank_len & 0xff; 755 dtd->part1.h_blank = h_blank_len & 0xff;
751 dtd->part1.h_high = (((width >> 8) & 0xf) << 4) | 756 dtd->part1.h_high = (((width >> 8) & 0xf) << 4) |
@@ -996,7 +1001,7 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
996 struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder); 1001 struct intel_sdvo *intel_sdvo = to_intel_sdvo(encoder);
997 u32 sdvox; 1002 u32 sdvox;
998 struct intel_sdvo_in_out_map in_out; 1003 struct intel_sdvo_in_out_map in_out;
999 struct intel_sdvo_dtd input_dtd; 1004 struct intel_sdvo_dtd input_dtd, output_dtd;
1000 int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode); 1005 int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode);
1001 int rate; 1006 int rate;
1002 1007
@@ -1021,20 +1026,13 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1021 intel_sdvo->attached_output)) 1026 intel_sdvo->attached_output))
1022 return; 1027 return;
1023 1028
1024 /* We have tried to get input timing in mode_fixup, and filled into 1029 /* lvds has a special fixed output timing. */
1025 * adjusted_mode. 1030 if (intel_sdvo->is_lvds)
1026 */ 1031 intel_sdvo_get_dtd_from_mode(&output_dtd,
1027 if (intel_sdvo->is_tv || intel_sdvo->is_lvds) { 1032 intel_sdvo->sdvo_lvds_fixed_mode);
1028 input_dtd = intel_sdvo->input_dtd; 1033 else
1029 } else { 1034 intel_sdvo_get_dtd_from_mode(&output_dtd, mode);
1030 /* Set the output timing to the screen */ 1035 (void) intel_sdvo_set_output_timing(intel_sdvo, &output_dtd);
1031 if (!intel_sdvo_set_target_output(intel_sdvo,
1032 intel_sdvo->attached_output))
1033 return;
1034
1035 intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
1036 (void) intel_sdvo_set_output_timing(intel_sdvo, &input_dtd);
1037 }
1038 1036
1039 /* Set the input timing to the screen. Assume always input 0. */ 1037 /* Set the input timing to the screen. Assume always input 0. */
1040 if (!intel_sdvo_set_target_input(intel_sdvo)) 1038 if (!intel_sdvo_set_target_input(intel_sdvo))
@@ -1052,6 +1050,10 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1052 !intel_sdvo_set_tv_format(intel_sdvo)) 1050 !intel_sdvo_set_tv_format(intel_sdvo))
1053 return; 1051 return;
1054 1052
1053 /* We have tried to get input timing in mode_fixup, and filled into
1054 * adjusted_mode.
1055 */
1056 intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
1055 (void) intel_sdvo_set_input_timing(intel_sdvo, &input_dtd); 1057 (void) intel_sdvo_set_input_timing(intel_sdvo, &input_dtd);
1056 1058
1057 switch (pixel_multiplier) { 1059 switch (pixel_multiplier) {