Updated fastboot bits
Subsystems (2)
Still need to mash these into the pipe_config bits, but with the PCH PLL readout, at least they don't crash after DPMS anymore. So that patch may be ok to apply as-is; I think the main bits needing rework involve the mode readout checks in intel_fb.c. They belong in intel_display.c as part of the state readout into an adjusted_mode struct.
Jesse
PATCH 1/13 drm/i915: Skip modifying PCH DREF if not changing clock sources
From: Chris Wilson <[email protected]>
Modifying the clock sources (via the DREF control on the PCH) is a slow multi-stage process as we need to let the clocks stabilise between each stage. If we are not actually changing the clock sources, then we can return early.
--- drivers/gpu/drm/i915/intel_display.c | 83 +++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/intel_display.c +61 -22
@@ -4833,7 +4833,7 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)struct drm_i915_private *dev_priv = dev->dev_private;struct drm_mode_config *mode_config = &dev->mode_config;struct intel_encoder *encoder; -u32 temp; +u32 val, final;bool has_lvds = false;bool has_cpu_edp = false;bool has_pch_edp = false;
@@ -4876,70 +4876,109 @@ static void ironlake_init_pch_refclk(struct drm_device *dev)* PCH B stepping, previous chipset stepping should be * ignoring this setting. */ - temp =I915_READ (PCH_DREF_CONTROL ); + val =I915_READ (PCH_DREF_CONTROL ); + +/* As we must carefully and slowly disable/enable each source in turn, +* compute the final state we want first and check if we need to +* make any changes at all. +*/ + final = val; + final &= ~DREF_NONSPREAD_SOURCE_MASK ; +if (has_ck505) + final |=DREF_NONSPREAD_CK505_ENABLE ; +else + final |=DREF_NONSPREAD_SOURCE_ENABLE ; + + final &= ~DREF_SSC_SOURCE_MASK ; + final &= ~DREF_CPU_SOURCE_OUTPUT_MASK ; + final &= ~DREF_SSC1_ENABLE ; + +if (has_panel) { + final |=DREF_SSC_SOURCE_ENABLE ; + +if (intel_panel_use_ssc (dev_priv) && can_ssc) + final |=DREF_SSC1_ENABLE ; + +if (has_cpu_edp) { +if (intel_panel_use_ssc (dev_priv) && can_ssc) + final |=DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD ; +else + final |=DREF_CPU_SOURCE_OUTPUT_NONSPREAD ; + }else + final |=DREF_CPU_SOURCE_OUTPUT_DISABLE ; + }else { + final |=DREF_SSC_SOURCE_DISABLE ; + final |=DREF_CPU_SOURCE_OUTPUT_DISABLE ; + } + +if (final == val) +return ; +/* Always enable nonspread source */ - temp &= ~DREF_NONSPREAD_SOURCE_MASK ; + val &= ~DREF_NONSPREAD_SOURCE_MASK ;if (has_ck505) - temp |=DREF_NONSPREAD_CK505_ENABLE ; + val |=DREF_NONSPREAD_CK505_ENABLE ;else - temp |=DREF_NONSPREAD_SOURCE_ENABLE ; + val |=DREF_NONSPREAD_SOURCE_ENABLE ;if (has_panel) { - temp &= ~DREF_SSC_SOURCE_MASK ; - temp |=DREF_SSC_SOURCE_ENABLE ; + val &= ~DREF_SSC_SOURCE_MASK ; + val |=DREF_SSC_SOURCE_ENABLE ;/* SSC must be turned on before enabling the CPU output */ if (intel_panel_use_ssc (dev_priv) && can_ssc) {DRM_DEBUG_KMS ("Using SSC on panel\n" ); - temp |=DREF_SSC1_ENABLE ; + val |=DREF_SSC1_ENABLE ; }else - temp &= ~DREF_SSC1_ENABLE ; + val &= ~DREF_SSC1_ENABLE ;/* Get SSC going before enabling the outputs */ -I915_WRITE (PCH_DREF_CONTROL , temp); +I915_WRITE (PCH_DREF_CONTROL , val);POSTING_READ (PCH_DREF_CONTROL );udelay (200 ); - temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK ; + val &= ~DREF_CPU_SOURCE_OUTPUT_MASK ;/* Enable CPU source on CPU attached eDP */ if (has_cpu_edp) {if (intel_panel_use_ssc (dev_priv) && can_ssc) {DRM_DEBUG_KMS ("Using SSC on eDP\n" ); - temp |=DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD ; + val |=DREF_CPU_SOURCE_OUTPUT_DOWNSPREAD ; }else - temp |=DREF_CPU_SOURCE_OUTPUT_NONSPREAD ; + val |=DREF_CPU_SOURCE_OUTPUT_NONSPREAD ; }else - temp |=DREF_CPU_SOURCE_OUTPUT_DISABLE ; + val |=DREF_CPU_SOURCE_OUTPUT_DISABLE ; -I915_WRITE (PCH_DREF_CONTROL , temp); +I915_WRITE (PCH_DREF_CONTROL , val);POSTING_READ (PCH_DREF_CONTROL );udelay (200 ); }else {DRM_DEBUG_KMS ("Disabling SSC entirely\n" ); - temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK ; + val &= ~DREF_CPU_SOURCE_OUTPUT_MASK ;/* Turn off CPU output */ - temp |=DREF_CPU_SOURCE_OUTPUT_DISABLE ; + val |=DREF_CPU_SOURCE_OUTPUT_DISABLE ; -I915_WRITE (PCH_DREF_CONTROL , temp); +I915_WRITE (PCH_DREF_CONTROL , val);POSTING_READ (PCH_DREF_CONTROL );udelay (200 );/* Turn off the SSC source */ - temp &= ~DREF_SSC_SOURCE_MASK ; - temp |=DREF_SSC_SOURCE_DISABLE ; + val &= ~DREF_SSC_SOURCE_MASK ; + val |=DREF_SSC_SOURCE_DISABLE ;/* Turn off SSC1 */ - temp &= ~DREF_SSC1_ENABLE ; + val &= ~DREF_SSC1_ENABLE ; -I915_WRITE (PCH_DREF_CONTROL , temp); +I915_WRITE (PCH_DREF_CONTROL , val);POSTING_READ (PCH_DREF_CONTROL );udelay (200 ); } + +BUG_ON (val != final); }/* Sequence to enable CLKOUT_DP for FDI usage and configure PCH FDI I/O. */
Signature · 1 line
1.7.9.5
PATCH 2/13 drm/i915: Split the framebuffer_info creation into a separate routine
In reply to Jesse BarnesThis will be shared with wrapping the BIOS framebuffer into the fbdev later. In the meantime, we can tidy the code slightly and improve the error path handling.
--- drivers/gpu/drm/i915/intel_display.c | 7 -- drivers/gpu/drm/i915/intel_drv.h | 7 ++ drivers/gpu/drm/i915/intel_fb.c | 154 ++++++++++++++++++---------------- 3 files changed, 91 insertions(+), 77 deletions(-)
drivers/gpu/drm/i915/intel_display.c +0 -7
@@ -6552,13 +6552,6 @@ intel_framebuffer_create(struct drm_device *dev, }static u32 -intel_framebuffer_pitch_for_width (int width,int bpp) -{ -u32 pitch =DIV_ROUND_UP (width * bpp,8 ); -return ALIGN (pitch,64 ); -} - -static u32 intel_framebuffer_size_for_mode (struct drm_display_mode *mode,int bpp) {u32 pitch =intel_framebuffer_pitch_for_width (mode->hdisplay, bpp);
drivers/gpu/drm/i915/intel_drv.h +7 -0
@@ -134,6 +134,13 @@ struct intel_framebuffer {struct drm_i915_gem_object *obj; }; +inline static u32 +intel_framebuffer_pitch_for_width (int width,int bpp) +{ +u32 pitch =DIV_ROUND_UP (width * bpp,8 ); +return ALIGN (pitch,64 ); +} +struct intel_fbdev {struct drm_fb_helper helper;struct intel_framebuffer ifb;
drivers/gpu/drm/i915/intel_fb.c +84 -70
197 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH 02/13] drm/i915: Split the framebuffer_info creation into a separate routine
drivers/gpu/drm/i915/intel_display.c intel_framebuffer_create(struct drm_device *dev, · line 6559
Quoted 6 lines · Jesse Barnes
static u32
drivers/gpu/drm/i915/intel_display.c +0
-5-intel_framebuffer_pitch_for_width(int width, int bpp) -{ -u32 pitch =DIV_ROUND_UP (width * bpp,8 ); -return ALIGN (pitch,64 ); -}
Before this patch we need:
statuc u32 intel_framebuffer_pitch_for_width(int width, int bpp)
{
u32 pitch = width * DIV_ROUND_UP(bpp, 8);
return ALIGN(pitch, 64);
}to address the issue Imre pointed out earlier.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 3/13 drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v3
In reply to Jesse Barnesv2: check for non-native modes and adjust (Jesse)
fixup aperture and cmap frees (Imre)
use unlocked unref if init_bios fails (Jesse)
fix curly brace around DSPADDR check (Imre)
comment failure path for pin_and_fence (Imre)
v3: fixup fixup of aperture frees (Chris)
--- drivers/gpu/drm/i915/i915_dma.c | 8 +- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_display.c | 14 +- drivers/gpu/drm/i915/intel_drv.h | 4 + drivers/gpu/drm/i915/intel_fb.c | 295 ++++++++++++++++++++++++++++++++-- 5 files changed, 304 insertions(+), 19 deletions(-)
drivers/gpu/drm/i915/i915_dma.c +7 -1
@@ -1273,6 +1273,7 @@ static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {static int i915_load_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +bool was_vga_enabled;int ret; ret =intel_parse_bios (dev);
@@ -1309,7 +1310,11 @@ static int i915_load_modeset_init(struct drm_device *dev)/* Important: The output setup functions called by modeset_init need * working irqs for e.g. gmbus and dp aux transfers. */ -intel_modeset_init (dev); +intel_modeset_init (dev, &was_vga_enabled); + +/* Wrap existing BIOS mode configuration prior to GEM takeover */ +if (!was_vga_enabled) +intel_fbdev_init_bios (dev); ret =i915_gem_init (dev);if (ret)
@@ -1323,6 +1328,7 @@ static int i915_load_modeset_init(struct drm_device *dev)/* FIXME: do pre/post-mode set stuff in core KMS code */ dev->vblank_disable_allowed =1 ; +/* Install a default KMS/GEM fbcon if we failed to wrap the BIOS fb */ ret =intel_fbdev_init (dev);if (ret) goto cleanup_gem;
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -1806,7 +1806,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }/* modesetting */ extern void intel_modeset_init_hw (struct drm_device *dev); -extern void intel_modeset_init (struct drm_device *dev); +extern void intel_modeset_init (struct drm_device *dev,bool *was_vga_enabled);extern void intel_modeset_gem_init (struct drm_device *dev);extern void intel_modeset_cleanup (struct drm_device *dev);extern int intel_modeset_vga_set_state (struct drm_device *dev,bool state);
drivers/gpu/drm/i915/intel_display.c +11 -3
@@ -8854,12 +8854,17 @@ static void intel_init_quirks(struct drm_device *dev) }/* Disable the VGA plane that we never use */ -static void i915_disable_vga (struct drm_device *dev) +static bool i915_disable_vga (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +bool was_enabled;u8 sr1;u32 vga_reg =i915_vgacntrl_reg (dev); + was_enabled = !(I915_READ (vga_reg) &VGA_DISP_DISABLE ); +DRM_DEBUG_KMS ("VGA output is currently %s\n" , + was_enabled ?"enabled" :"disabled" ); +vga_get_uninterruptible (dev->pdev,VGA_RSRC_LEGACY_IO );outb (SR01 ,VGA_SR_INDEX ); sr1 =inb (VGA_SR_DATA );
@@ -8869,6 +8874,8 @@ static void i915_disable_vga(struct drm_device *dev)I915_WRITE (vga_reg,VGA_DISP_DISABLE );POSTING_READ (vga_reg); + +return was_enabled; }void intel_modeset_init_hw (struct drm_device *dev)
@@ -8884,7 +8891,8 @@ void intel_modeset_init_hw(struct drm_device *dev)mutex_unlock (&dev->struct_mutex); } -void intel_modeset_init (struct drm_device *dev) +void intel_modeset_init (struct drm_device *dev, +bool *was_vga_enabled) {struct drm_i915_private *dev_priv = dev->dev_private;int i, ret;
@@ -8932,7 +8940,7 @@ void intel_modeset_init(struct drm_device *dev)intel_pch_pll_init (dev);/* Just disable it once at startup */ -i915_disable_vga (dev); + *was_vga_enabled =i915_disable_vga (dev);intel_setup_outputs (dev);/* Just in case the BIOS is doing something questionable. */
drivers/gpu/drm/i915/intel_drv.h +4 -0
@@ -146,6 +146,8 @@ struct intel_fbdev {struct intel_framebuffer ifb;struct list_head fbdev_list;struct drm_display_mode *our_mode; +bool stolen; +int preferred_bpp; };struct intel_encoder {
@@ -212,6 +214,7 @@ struct intel_crtc {enum plane plane;enum transcoder cpu_transcoder;u8 lut_r[256 ], lut_g[256 ], lut_b[256 ]; +bool mode_valid;/* * Whether the crtc and the connected output pipeline is active. Implies * that crtc->enabled is set, i.e. the current mode configuration has
@@ -621,6 +624,7 @@ extern int intel_framebuffer_init(struct drm_device *dev,struct intel_framebuffer *ifb, struct drm_mode_fb_cmd2 *mode_cmd, struct drm_i915_gem_object *obj); +extern void intel_fbdev_init_bios (struct drm_device *dev);extern int intel_fbdev_init (struct drm_device *dev);extern void intel_fbdev_initial_config (struct drm_device *dev);extern void intel_fbdev_fini (struct drm_device *dev);
drivers/gpu/drm/i915/intel_fb.c +281 -14
351 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH 03/13] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v3
Quoted 30 lines · Jesse Barnes
v2: check for non-native modes and adjust (Jesse)
fixup aperture and cmap frees (Imre)
use unlocked unref ifinit_biosfails (Jesse)
fix curly brace around DSPADDR check (Imre)
comment failure path forpin_and_fence(Imre)
v3: fixup fixup of aperture frees (Chris)Signed-off-by Chris Wilson <[email protected]>Signed-off-by Jesse Barnes <[email protected]>--- drivers/gpu/drm/i915/i915_dma.c | 8 +- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_display.c | 14 +- drivers/gpu/drm/i915/intel_drv.h | 4 + drivers/gpu/drm/i915/intel_fb.c | 295 ++++++++++++++++++++++++++++++++-- 5 files changed, 304 insertions(+), 19 deletions(-)drivers/gpu/drm/i915/i915_dma.c +1
-0@@ -1273,6 +1273,7 @@ static const struct vga_switcheroo_client_ops i915_switcheroo_ops = {static int i915_load_modeset_init (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +bool was_vga_enabled;int ret; ret =intel_parse_bios (dev);
drivers/gpu/drm/i915/i915_dma.c static int i915_load_modeset_init(struct drm_device *dev) · line 1317
Quoted 9 lines
drivers/gpu/drm/i915/i915_dma.c +5
-1@@ -1309,7 +1310,11 @@ static int i915_load_modeset_init(struct drm_device *dev)/* Important: The output setup functions called by modeset_init need * working irqs for e.g. gmbus and dp aux transfers. */ -intel_modeset_init (dev); +intel_modeset_init (dev, &was_vga_enabled); + +/* Wrap existing BIOS mode configuration prior to GEM takeover */ +if (!was_vga_enabled) +intel_fbdev_init_bios (dev);
I'm not really happy that the fbdev is initialized at different points here depending upon whether. Also this seems to tie the bios fb reconstruction quite heavily into our fbdev code ...
Can't we instead reconstruct the bios fb in intel_modeset_setup_hw_state and assign it to each active crtc if we detect one? The fbdev init code down below could then check whether the in-use fbs are suitable or not.
That would also make it easier to move some of the pipe state readout into the pipe_config hw state checking/read out infrastructure. Since that's only setup up at the end of modeset_gem_init. Or do I miss a delicate ordering constraint here?
-Daniel
Quoted 473 lines
drivers/gpu/drm/i915/i915_dma.c +1
-0ret =i915_gem_init (dev);if (ret)@@ -1323,6 +1328,7 @@ static int i915_load_modeset_init(struct drm_device *dev)/* FIXME: do pre/post-mode set stuff in core KMS code */ dev->vblank_disable_allowed =1 ; +/* Install a default KMS/GEM fbcon if we failed to wrap the BIOS fb */ ret =intel_fbdev_init (dev);if (ret) goto cleanup_gem;drivers/gpu/drm/i915/i915_drv.h +1
-1@@ -1806,7 +1806,7 @@ static inline void intel_unregister_dsm_handler(void) { return; }/* modesetting */ extern void intel_modeset_init_hw (struct drm_device *dev); -extern void intel_modeset_init (struct drm_device *dev); +extern void intel_modeset_init (struct drm_device *dev,bool *was_vga_enabled);extern void intel_modeset_gem_init (struct drm_device *dev);extern void intel_modeset_cleanup (struct drm_device *dev);extern int intel_modeset_vga_set_state (struct drm_device *dev,bool state);drivers/gpu/drm/i915/intel_display.c +11
-3@@ -8854,12 +8854,17 @@ static void intel_init_quirks(struct drm_device *dev) }/* Disable the VGA plane that we never use */ -static void i915_disable_vga (struct drm_device *dev) +static bool i915_disable_vga (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private; +bool was_enabled;u8 sr1;u32 vga_reg =i915_vgacntrl_reg (dev); + was_enabled = !(I915_READ (vga_reg) &VGA_DISP_DISABLE ); +DRM_DEBUG_KMS ("VGA output is currently %s\n" , + was_enabled ?"enabled" :"disabled" ); +vga_get_uninterruptible (dev->pdev,VGA_RSRC_LEGACY_IO );outb (SR01 ,VGA_SR_INDEX ); sr1 =inb (VGA_SR_DATA );@@ -8869,6 +8874,8 @@ static void i915_disable_vga(struct drm_device *dev)I915_WRITE (vga_reg,VGA_DISP_DISABLE );POSTING_READ (vga_reg); + +return was_enabled; }void intel_modeset_init_hw (struct drm_device *dev)@@ -8884,7 +8891,8 @@ void intel_modeset_init_hw(struct drm_device *dev)mutex_unlock (&dev->struct_mutex); } -void intel_modeset_init (struct drm_device *dev) +void intel_modeset_init (struct drm_device *dev, +bool *was_vga_enabled) {struct drm_i915_private *dev_priv = dev->dev_private;int i, ret;@@ -8932,7 +8940,7 @@ void intel_modeset_init(struct drm_device *dev)intel_pch_pll_init (dev);/* Just disable it once at startup */ -i915_disable_vga (dev); + *was_vga_enabled =i915_disable_vga (dev);intel_setup_outputs (dev);/* Just in case the BIOS is doing something questionable. */ drivers/gpu/drm/i915/intel_drv.h +4
-0@@ -146,6 +146,8 @@ struct intel_fbdev {struct intel_framebuffer ifb;struct list_head fbdev_list;struct drm_display_mode *our_mode; +bool stolen; +int preferred_bpp; };struct intel_encoder {@@ -212,6 +214,7 @@ struct intel_crtc {enum plane plane;enum transcoder cpu_transcoder;u8 lut_r[256 ], lut_g[256 ], lut_b[256 ]; +bool mode_valid;/* * Whether the crtc and the connected output pipeline is active. Implies * that crtc->enabled is set, i.e. the current mode configuration has @@ -621,6 +624,7 @@ extern int intel_framebuffer_init(struct drm_device *dev,struct intel_framebuffer *ifb, struct drm_mode_fb_cmd2 *mode_cmd, struct drm_i915_gem_object *obj); +extern void intel_fbdev_init_bios (struct drm_device *dev);extern int intel_fbdev_init (struct drm_device *dev);extern void intel_fbdev_initial_config (struct drm_device *dev);extern void intel_fbdev_fini (struct drm_device *dev);drivers/gpu/drm/i915/intel_fb.c +281
-14@@ -118,8 +118,7 @@ static struct fb_info *intelfb_create_info(struct intel_fbdev *ifbdev)return info; err_cmap: -if (info->cmap.len) -fb_dealloc_cmap (&info->cmap); +fb_dealloc_cmap (&info->cmap); err_info:framebuffer_release (info);return NULL ;@@ -183,9 +182,7 @@ static int intelfb_create(struct drm_fb_helper *helper, goto out_unpin; } -mutex_unlock (&dev->struct_mutex); -vga_switcheroo_client_fb_set (dev->pdev, info);return 0 ; out_unpin:@@ -197,6 +194,69 @@ out:return ret; } +static struct drm_fb_helper_crtc * +intel_fb_helper_crtc (struct drm_fb_helper *fb_helper,struct drm_crtc *crtc) +{ +int i; + +for (i =0 ; i < fb_helper->crtc_count; i++) +if (fb_helper->crtc_info[i].mode_set.crtc == crtc) +return &fb_helper->crtc_info[i]; + +return NULL ; +} + +static bool intel_fb_initial_config (struct drm_fb_helper *fb_helper, +struct drm_fb_helper_crtc **crtcs, +struct drm_display_mode **modes, +bool *enabled,int width,int height) +{ +int i; + +for (i =0 ; i < fb_helper->connector_count; i++) { +struct drm_connector *connector; +struct drm_encoder *encoder; + + connector = fb_helper->connector_info[i]->connector; +if (!enabled[i]) { +DRM_DEBUG_KMS ("connector %d not enabled, skipping\n" , + connector->base.id); +continue ; + } + + encoder = connector->encoder; +if (!encoder || !encoder->crtc) { +DRM_DEBUG_KMS ("connector %d has no encoder or crtc, skipping\n" , + connector->base.id); +continue ; + } + +if (WARN_ON (!encoder->crtc->enabled)) { +DRM_DEBUG_KMS ("connector %s on crtc %d has inconsistent state, aborting\n" , +drm_get_connector_name (connector), + encoder->crtc->base.id); +return false; + } + +if (!to_intel_crtc (encoder->crtc)->mode_valid) { +DRM_DEBUG_KMS ("connector %s on crtc %d has an invalid mode, aborting\n" , +drm_get_connector_name (connector), + encoder->crtc->base.id); +return false; + } + + modes[i] = &encoder->crtc->mode; + crtcs[i] =intel_fb_helper_crtc (fb_helper, encoder->crtc); + +DRM_DEBUG_KMS ("connector %s on crtc %d: %s\n" , +drm_get_connector_name (connector), + encoder->crtc->base.id, + modes[i]->name); + } + +return true; +} +static struct drm_fb_helper_funcs intel_fb_helper_funcs = { .gamma_set = intel_crtc_fb_gamma_set, .gamma_get = intel_crtc_fb_gamma_get,@@ -213,8 +273,7 @@ static void intel_fbdev_destroy(struct drm_device *dev,unregister_framebuffer (info);iounmap (info->screen_base); -if (info->cmap.len) -fb_dealloc_cmap (&info->cmap); +fb_dealloc_cmap (&info->cmap);framebuffer_release (info); }@@ -228,23 +287,229 @@ static void intel_fbdev_destroy(struct drm_device *dev, } } -int intel_fbdev_init (struct drm_device *dev) +static bool pipe_enabled (struct drm_i915_private *dev_priv,enum pipe pipe) { +enum transcoder cpu_transcoder = +intel_pipe_to_cpu_transcoder (dev_priv, pipe); +return !!(I915_READ (PIPECONF (cpu_transcoder)) &PIPECONF_ENABLE ); +} + +/* +* Try to read the BIOS display configuration and use it for the initial +* fb configuration. +* +* The BIOS or boot loader will generally create an initial display +* configuration for us that includes some set of active pipes and displays. +* This routine tries to figure out which pipes are active, what resolutions +* are being displayed, and then allocates a framebuffer and initial fb +* config based on that data. +* +* If the BIOS or boot loader leaves the display in VGA mode, there's not +* much we can do; switching out of that mode involves allocating a new, +* high res buffer, and also recalculating bandwidth requirements for the +* new bpp configuration. +* +* However, if we're loaded into an existing, high res mode, we should +* be able to allocate a buffer big enough to handle the largest active +* mode, create a mode_set for it, and pass it to the fb helper to create +* the configuration. +*/ +void intel_fbdev_init_bios (struct drm_device *dev) +{ +struct drm_i915_private *dev_priv = dev->dev_private;struct intel_fbdev *ifbdev; -drm_i915_private_t *dev_priv = dev->dev_private; -int ret; +struct drm_crtc *crtc; +struct drm_mode_fb_cmd2 mode_cmd = {0 }; +struct drm_i915_gem_object *obj; +u32 obj_offset =0 ; +int mode_bpp =0 ; +u32 active =0 ; + +list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { +struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +int pipe = intel_crtc->pipe, plane = intel_crtc->plane; +u32 val, bpp, offset, format; +int pitch, width, height; + +if (!pipe_enabled (dev_priv, pipe)) { +DRM_DEBUG_KMS ("pipe %c not active, skipping\n" , +pipe_name (pipe)); +continue ; + } + + val =I915_READ (DSPCNTR (plane)); + +if (INTEL_INFO (dev)->gen >=4 ) { +if (val &DISPPLANE_TILED ) { +DRM_DEBUG_KMS ("tiled BIOS fb?\n" ); +continue ;/* unexpected! */ + } + } + +switch (val &DISPPLANE_PIXFORMAT_MASK ) { +case DISPPLANE_YUV422 : +default : +DRM_DEBUG_KMS ("pipe %c unsupported pixel format %x, skipping\n" , +pipe_name (pipe), (val &DISPPLANE_PIXFORMAT_MASK ) >>26 ); +continue ; +case DISPPLANE_8BPP : + format =DRM_FORMAT_C8 ; + bpp =8 ; +break ; +case DISPPLANE_BGRX555 : + format =DRM_FORMAT_XRGB1555 ; + bpp =16 ; +break ; +case DISPPLANE_BGRX565 : + format =DRM_FORMAT_RGB565 ; + bpp =16 ; +break ; +case DISPPLANE_BGRX888 : + format =DRM_FORMAT_XRGB8888 ; + bpp =32 ; +break ; + } + +if (mode_cmd.pixel_format ==0 ) { + mode_bpp = bpp; + mode_cmd.pixel_format = format; + } + +if (mode_cmd.pixel_format != format) { +DRM_DEBUG_KMS ("pipe %c has format/bpp (%d, %d) mismatch: skipping\n" , +pipe_name (pipe), format, bpp); +continue ; + } + +if (INTEL_INFO (dev)->gen >=4 ) { +if (I915_READ (DSPTILEOFF (plane))) { +DRM_DEBUG_KMS ("pipe %c is offset: skipping\n" , +pipe_name (pipe)); +continue ; + } + + offset =I915_READ (DSPSURF (plane)); + }else { + offset =I915_READ (DSPADDR (plane)); + } +if (!obj_offset) + obj_offset = offset; + +if (offset != obj_offset) { +DRM_DEBUG_KMS ("multiple pipe setup not in clone mode, skipping\n" ); +continue ; + } + + val =I915_READ (PIPESRC (pipe)); + width = ((val >>16 ) &0xfff ) +1 ; + height = ((val >>0 ) &0xfff ) +1 ; + +/* Adjust fitted modes */ + val =I915_READ (HTOTAL (pipe)); +if (((val &0xffff ) +1 ) != width) { +DRM_DEBUG_DRIVER ("BIOS fb not native width (%d vs %d), overriding\n" , width, (val &0xffff ) +1 ); + width = (val &0xffff ) +1 ; + } + val =I915_READ (VTOTAL (pipe)); +if (((val &0xffff ) +1 ) != height) { +DRM_DEBUG_DRIVER ("BIOS fb not native height (%d vs %d), overriding\n" , height, (val &0xffff ) +1 ); + height = (val &0xffff ) +1 ; + } + +DRM_DEBUG_KMS ("Found active pipe [%d/%d]: size=%dx%d@%d, offset=%x\n" , + pipe, plane, width, height, bpp, offset); + +if (width > mode_cmd.width) + mode_cmd.width = width; + +if (height > mode_cmd.height) + mode_cmd.height = height; + + pitch =intel_framebuffer_pitch_for_width (width, bpp); +if (pitch > mode_cmd.pitches[0 ]) + mode_cmd.pitches[0 ] = pitch; + + active |=1 << pipe; + } + +if (active ==0 ) { +DRM_DEBUG_KMS ("no active pipes found, not using BIOS config\n" ); +return ; + } ifbdev =kzalloc (sizeof (struct intel_fbdev ),GFP_KERNEL ); -if (!ifbdev) -return -ENOMEM ; +if (ifbdev ==NULL ) { +DRM_DEBUG_KMS ("failed to alloc intel fbdev\n" ); +return ; + } - dev_priv->fbdev = ifbdev; + ifbdev->stolen = true; + ifbdev->preferred_bpp = mode_bpp; ifbdev->helper.funcs = &intel_fb_helper_funcs; + ifbdev->helper.funcs->initial_config = intel_fb_initial_config; + +/* assume a 1:1 linear mapping between stolen and GTT */ + obj =i915_gem_object_create_stolen_for_preallocated (dev, + obj_offset, + obj_offset, +ALIGN (mode_cmd.pitches[0 ] * mode_cmd.height,PAGE_SIZE )); +if (obj ==NULL ) { +DRM_DEBUG_KMS ("failed to create stolen fb\n" ); + goto out_free_ifbdev; + } + +if (intel_framebuffer_init (dev, &ifbdev->ifb, &mode_cmd, obj)) { +DRM_DEBUG_KMS ("intel fb init failed\n" ); + goto out_unref_obj; + } + +list_for_each_entry (crtc, &dev->mode_config.crtc_list, head) { +if ((active & (1 <<to_intel_crtc (crtc)->pipe)) ==0 ) +continue ; + +/* +* This should only fail on the first one so we don't need +* to cleanup any secondary crtc->fbs +*/ +if (intel_pin_and_fence_fb_obj (dev, obj,NULL )) + goto out_unref_obj; + + crtc->fb = &ifbdev->ifb.base; + } + + dev_priv->fbdev = ifbdev; + +DRM_DEBUG_KMS ("using BIOS fb for initial console\n" ); +return ; + +out_unref_obj: +drm_gem_object_unreference_unlocked (&obj->base); +out_free_ifbdev: +kfree (ifbdev); +} + +int intel_fbdev_init (struct drm_device *dev) +{ +drm_i915_private_t *dev_priv = dev->dev_private; +struct intel_fbdev *ifbdev; +int ret; + +if ((ifbdev = dev_priv->fbdev) ==NULL ) { + ifbdev =kzalloc (sizeof (struct intel_fbdev ),GFP_KERNEL ); +if (ifbdev ==NULL ) +return -ENOMEM ; + + ifbdev->helper.funcs = &intel_fb_helper_funcs; + ifbdev->preferred_bpp =32 ; + + dev_priv->fbdev = ifbdev; + } ret =drm_fb_helper_init (dev, &ifbdev->helper,INTEL_INFO (dev)->num_pipes,INTELFB_CONN_LIMIT );if (ret) { + dev_priv->fbdev =NULL ;kfree (ifbdev);return ret; }@@ -257,9 +522,10 @@ int intel_fbdev_init(struct drm_device *dev)void intel_fbdev_initial_config (struct drm_device *dev) {drm_i915_private_t *dev_priv = dev->dev_private; +struct intel_fbdev *ifbdev = dev_priv->fbdev;/* Due to peculiar init order wrt to hpd handling this is separate. */ -drm_fb_helper_initial_config (&dev_priv->fbdev->helper,32 ); +drm_fb_helper_initial_config (&ifbdev->helper, ifbdev->preferred_bpp); }void intel_fbdev_fini (struct drm_device *dev)@@ -287,7 +553,8 @@ MODULE_LICENSE("GPL and additional rights");void intel_fb_output_poll_changed (struct drm_device *dev) {drm_i915_private_t *dev_priv = dev->dev_private; -drm_fb_helper_hotplug_event (&dev_priv->fbdev->helper); +if (dev_priv->fbdev) +drm_fb_helper_hotplug_event (&dev_priv->fbdev->helper); }void intel_fb_restore_mode (struct drm_device *dev)Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 4/13 drm/i915: Retrieve the current mode upon KMS takeover v2
In reply to Jesse BarnesRead the current hardware state to retrieve the active mode and populate our CRTC config if that mode matches our presumptions.
v2: check that get_hw_state gave us a valid pipe (Imre)
add clock_get for ILK+ (Jesse)
--- drivers/gpu/drm/i915/i915_drv.h | 2 + drivers/gpu/drm/i915/intel_crt.c | 27 ++++++- drivers/gpu/drm/i915/intel_display.c | 139 +++++++++++++++++++++++++++------- drivers/gpu/drm/i915/intel_dp.c | 22 ++++++ drivers/gpu/drm/i915/intel_drv.h | 7 +- drivers/gpu/drm/i915/intel_dvo.c | 36 ++++++--- drivers/gpu/drm/i915/intel_hdmi.c | 22 ++++++ drivers/gpu/drm/i915/intel_lvds.c | 27 ++++++- drivers/gpu/drm/i915/intel_sdvo.c | 23 ++++++ 9 files changed, 262 insertions(+), 43 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -283,6 +283,8 @@ struct drm_i915_display_funcs {void (*update_linetime_wm)(struct drm_device *dev,int pipe,struct drm_display_mode *mode);void (*modeset_global_resources)(struct drm_device *dev); +bool (*crtc_get_mode)(struct drm_crtc *crtc, +struct drm_display_mode *mode); int (*crtc_mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode,
drivers/gpu/drm/i915/intel_crt.c +25 -2
@@ -81,6 +81,27 @@ static bool intel_crt_get_hw_state(struct intel_encoder *encoder,return true; } +static unsigned intel_crt_get_mode_flags (struct intel_encoder *encoder) +{ +struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; +struct intel_crt *crt =intel_encoder_to_crt (encoder); +u32 tmp, flags =0 ; + + tmp =I915_READ (crt->adpa_reg); + +if (tmp &ADPA_HSYNC_ACTIVE_HIGH ) + flags |=DRM_MODE_FLAG_PHSYNC ; +else + flags |=DRM_MODE_FLAG_NHSYNC ; + +if (tmp &ADPA_VSYNC_ACTIVE_HIGH ) + flags |=DRM_MODE_FLAG_PVSYNC ; +else + flags |=DRM_MODE_FLAG_NVSYNC ; + +return flags; +} +static void intel_disable_crt (struct intel_encoder *encoder) {struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
@@ -776,10 +797,12 @@ void intel_crt_init(struct drm_device *dev) crt->base.disable = intel_disable_crt; crt->base.enable = intel_enable_crt; -if (HAS_DDI (dev)) +if (HAS_DDI (dev)) { crt->base.get_hw_state = intel_ddi_get_hw_state; -else + }else { crt->base.get_hw_state = intel_crt_get_hw_state; + crt->base.get_mode_flags = intel_crt_get_mode_flags; + } intel_connector->get_hw_state = intel_connector_get_hw_state;drm_encoder_helper_add (&crt->base.base, &crt_encoder_funcs);
drivers/gpu/drm/i915/intel_display.c +112 -27
194 lines not on this page · raw message
drivers/gpu/drm/i915/intel_dp.c +22 -0
@@ -1369,6 +1369,27 @@ static bool intel_dp_get_hw_state(struct intel_encoder *encoder,return true; } +static unsigned intel_dp_get_mode_flags (struct intel_encoder *encoder) +{ +struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base); +struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; +u32 tmp, flags =0 ; + + tmp =I915_READ (intel_dp->output_reg); + +if (tmp &DP_SYNC_HS_HIGH ) + flags |=DRM_MODE_FLAG_PHSYNC ; +else + flags |=DRM_MODE_FLAG_NHSYNC ; + +if (tmp &DP_SYNC_VS_HIGH ) + flags |=DRM_MODE_FLAG_PVSYNC ; +else + flags |=DRM_MODE_FLAG_NVSYNC ; + +return flags; +} +static void intel_disable_dp (struct intel_encoder *encoder) {struct intel_dp *intel_dp =enc_to_intel_dp (&encoder->base);
@@ -2951,6 +2972,7 @@ intel_dp_init(struct drm_device *dev, int output_reg, enum port port) intel_encoder->disable = intel_disable_dp; intel_encoder->post_disable = intel_post_disable_dp; intel_encoder->get_hw_state = intel_dp_get_hw_state; + intel_encoder->get_mode_flags = intel_dp_get_mode_flags; intel_dig_port->port = port; intel_dig_port->dp.output_reg = output_reg;
drivers/gpu/drm/i915/intel_drv.h +5 -2
@@ -176,6 +176,9 @@ struct intel_encoder {* the encoder is active. If the encoder is enabled it also set the pipe * it is connected to in the pipe parameter. */ bool (*get_hw_state)(struct intel_encoder *,enum pipe *pipe); +/* Reconstructs the equivalent mode flags for the current hardware +* state. */ +unsigned (*get_mode_flags)(struct intel_encoder *);int crtc_mask; };
@@ -586,8 +589,8 @@ extern void intel_connector_attach_encoder(struct intel_connector *connector, struct intel_encoder *encoder);extern struct drm_encoder *intel_best_encoder (struct drm_connector *connector); -extern struct drm_display_mode *intel_crtc_mode_get (struct drm_device *dev, -struct drm_crtc *crtc); +extern bool intel_crtc_get_mode (struct drm_crtc *crtc, +struct drm_display_mode *mode);int intel_get_pipe_from_crtc_id (struct drm_device *dev,void *data,struct drm_file *file_priv); extern enum transcoder
drivers/gpu/drm/i915/intel_dvo.c +25 -11
@@ -129,6 +129,22 @@ static bool intel_dvo_get_hw_state(struct intel_encoder *encoder,return true; } +static unsigned +intel_dvo_get_mode_flags (struct intel_encoder *encoder) +{ +struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; +struct intel_dvo *intel_dvo =enc_to_intel_dvo (&encoder->base); +u32 tmp, flags =0 ; + + tmp =I915_READ (intel_dvo->dev.dvo_reg); +if (tmp &DVO_HSYNC_ACTIVE_HIGH ) + flags |=DRM_MODE_FLAG_PHSYNC ; +if (tmp &DVO_VSYNC_ACTIVE_HIGH ) + flags |=DRM_MODE_FLAG_PVSYNC ; + +return flags; +} +static void intel_disable_dvo (struct intel_encoder *encoder) {struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
@@ -389,29 +405,26 @@ intel_dvo_get_current_mode(struct drm_connector *connector)struct drm_i915_private *dev_priv = dev->dev_private;struct intel_dvo *intel_dvo =intel_attached_dvo (connector);uint32_t dvo_val =I915_READ (intel_dvo->dev.dvo_reg); -struct drm_display_mode *mode =NULL ; +struct drm_display_mode *fixed_mode =NULL ;/* If the DVO port is active, that'll be the LVDS, so we can pull out * its timings to get how the BIOS set up the panel. */ if (dvo_val &DVO_ENABLE ) { +struct drm_display_mode mode;struct drm_crtc *crtc;int pipe = (dvo_val &DVO_PIPE_B_SELECT ) ?1 :0 ; crtc =intel_get_crtc_for_pipe (dev, pipe); -if (crtc) { - mode =intel_crtc_mode_get (dev, crtc); -if (mode) { - mode->type |=DRM_MODE_TYPE_PREFERRED ; -if (dvo_val &DVO_HSYNC_ACTIVE_HIGH ) - mode->flags |=DRM_MODE_FLAG_PHSYNC ; -if (dvo_val &DVO_VSYNC_ACTIVE_HIGH ) - mode->flags |=DRM_MODE_FLAG_PVSYNC ; - } +if (intel_crtc_get_mode (crtc, &mode)) + fixed_mode =drm_mode_duplicate (dev, &mode); +if (fixed_mode) { + fixed_mode->type |=DRM_MODE_TYPE_PREFERRED ; + fixed_mode->flags =intel_dvo_get_mode_flags (&intel_dvo->base); } } -return mode; +return fixed_mode; }void intel_dvo_init (struct drm_device *dev)
@@ -440,6 +453,7 @@ void intel_dvo_init(struct drm_device *dev) intel_encoder->disable = intel_disable_dvo; intel_encoder->enable = intel_enable_dvo; intel_encoder->get_hw_state = intel_dvo_get_hw_state; + intel_encoder->get_mode_flags = intel_dvo_get_mode_flags; intel_connector->get_hw_state = intel_dvo_connector_get_hw_state;/* Now, try to find a controller */
drivers/gpu/drm/i915/intel_hdmi.c +22 -0
@@ -657,6 +657,27 @@ static bool intel_hdmi_get_hw_state(struct intel_encoder *encoder,return true; } +static unsigned intel_hdmi_get_mode_flags (struct intel_encoder *encoder) +{ +struct intel_hdmi *intel_hdmi =enc_to_intel_hdmi (&encoder->base); +struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; +u32 tmp, flags =0 ; + + tmp =I915_READ (intel_hdmi->hdmi_reg); + +if (tmp &SDVO_HSYNC_ACTIVE_HIGH ) + flags |=DRM_MODE_FLAG_PHSYNC ; +else + flags |=DRM_MODE_FLAG_NHSYNC ; + +if (tmp &SDVO_VSYNC_ACTIVE_HIGH ) + flags |=DRM_MODE_FLAG_PVSYNC ; +else + flags |=DRM_MODE_FLAG_NVSYNC ; + +return flags; +} +static void intel_enable_hdmi (struct intel_encoder *encoder) {struct drm_device *dev = encoder->base.dev;
@@ -1068,6 +1089,7 @@ void intel_hdmi_init(struct drm_device *dev, int hdmi_reg, enum port port) intel_encoder->enable = intel_enable_hdmi; intel_encoder->disable = intel_disable_hdmi; intel_encoder->get_hw_state = intel_hdmi_get_hw_state; + intel_encoder->get_mode_flags = intel_hdmi_get_mode_flags; intel_encoder->type =INTEL_OUTPUT_HDMI ; intel_encoder->crtc_mask = (1 <<0 ) | (1 <<1 ) | (1 <<2 );
drivers/gpu/drm/i915/intel_lvds.c +26 -1
@@ -88,6 +88,26 @@ static bool intel_lvds_get_hw_state(struct intel_encoder *encoder,return true; } +static unsigned intel_lvds_get_mode_flags (struct intel_encoder *encoder) +{ +struct drm_device *dev = encoder->base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +u32 lvds_reg, tmp, flags =0 ; + +if (HAS_PCH_SPLIT (dev)) + lvds_reg =PCH_LVDS ; +else + lvds_reg =LVDS ; + + tmp =I915_READ (lvds_reg); +if (tmp &LVDS_HSYNC_POLARITY ) + flags |=DRM_MODE_FLAG_NHSYNC ; +if (tmp &LVDS_VSYNC_POLARITY ) + flags |=DRM_MODE_FLAG_NVSYNC ; + +return flags; +} +/* The LVDS pin pair needs to be on before the DPLLs are enabled. * This is an exception to the general rule that mode_set doesn't turn * things on.
@@ -1107,6 +1127,7 @@ bool intel_lvds_init(struct drm_device *dev) intel_encoder->pre_pll_enable = intel_pre_pll_enable_lvds; intel_encoder->disable = intel_disable_lvds; intel_encoder->get_hw_state = intel_lvds_get_hw_state; + intel_encoder->get_mode_flags = intel_lvds_get_mode_flags; intel_connector->get_hw_state = intel_connector_get_hw_state;intel_connector_attach_encoder (intel_connector, intel_encoder);
@@ -1218,11 +1239,15 @@ bool intel_lvds_init(struct drm_device *dev) crtc =intel_get_crtc_for_pipe (dev, pipe);if (crtc && (lvds &LVDS_PORT_EN )) { - fixed_mode =intel_crtc_mode_get (dev, crtc); +struct drm_display_mode mode; + +if (intel_crtc_get_mode (crtc, &mode)) + fixed_mode =drm_mode_duplicate (dev, &mode);if (fixed_mode) {DRM_DEBUG_KMS ("using current (BIOS) mode: " );drm_mode_debug_printmodeline (fixed_mode); fixed_mode->type |=DRM_MODE_TYPE_PREFERRED ; + fixed_mode->flags =intel_lvds_get_mode_flags (intel_encoder); goto out; } }
drivers/gpu/drm/i915/intel_sdvo.c +23 -0
@@ -1254,6 +1254,27 @@ static bool intel_sdvo_get_hw_state(struct intel_encoder *encoder,return true; } +static unsigned intel_sdvo_get_mode_flags (struct intel_encoder *encoder) +{ +struct intel_sdvo *intel_sdvo =to_intel_sdvo (&encoder->base); +struct drm_i915_private *dev_priv = encoder->base.dev->dev_private; +u32 tmp, flags =0 ; + + tmp =I915_READ (intel_sdvo->sdvo_reg); + +if (tmp &SDVO_HSYNC_ACTIVE_HIGH ) + flags |=DRM_MODE_FLAG_PHSYNC ; +else + flags |=DRM_MODE_FLAG_NHSYNC ; + +if (tmp &SDVO_VSYNC_ACTIVE_HIGH ) + flags |=DRM_MODE_FLAG_PVSYNC ; +else + flags |=DRM_MODE_FLAG_NVSYNC ; + +return flags; +} +static void intel_disable_sdvo (struct intel_encoder *encoder) {struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
@@ -2784,6 +2805,8 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob) intel_encoder->disable = intel_disable_sdvo; intel_encoder->enable = intel_enable_sdvo; intel_encoder->get_hw_state = intel_sdvo_get_hw_state; +if (INTEL_INFO (dev)->gen >=4 ) + intel_encoder->get_mode_flags = intel_sdvo_get_mode_flags;/* In default case sdvo lvds is false */ if (!intel_sdvo_get_capabilities (intel_sdvo, &intel_sdvo->caps))
Signature · 1 line
1.7.9.5
PATCH 5/13 drm/i915: Only preserve the BIOS modes if they are the preferred ones
In reply to Jesse BarnesFrom: Chris Wilson <[email protected]>
--- drivers/gpu/drm/i915/intel_display.c | 9 +++++++++ drivers/gpu/drm/i915/intel_dp.c | 1 + drivers/gpu/drm/i915/intel_drv.h | 8 ++++++++ drivers/gpu/drm/i915/intel_fb.c | 9 +++++++++ drivers/gpu/drm/i915/intel_lvds.c | 1 + drivers/gpu/drm/i915/intel_panel.c | 10 ++++++++++ 6 files changed, 38 insertions(+)
drivers/gpu/drm/i915/intel_display.c +9 -0
@@ -9424,6 +9424,15 @@ void intel_connector_attach_encoder(struct intel_connector *connector, &encoder->base); } +bool intel_connector_get_preferred_mode (struct intel_connector *connector, +struct drm_display_mode *mode) +{ +if (!connector->get_preferred_mode) +return false; + +return connector->get_preferred_mode (connector, mode); +} +/* * set vga decode state - true == enable VGA decode */
drivers/gpu/drm/i915/intel_dp.c +1 -0
@@ -2926,6 +2926,7 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port, }if (is_edp (intel_dp)) { + intel_connector->get_preferred_mode = intel_connector_get_panel_fixed_mode;intel_panel_init (&intel_connector->panel, fixed_mode);intel_panel_setup_backlight (connector); }
drivers/gpu/drm/i915/intel_drv.h +8 -0
@@ -204,6 +204,9 @@ struct intel_connector {* and active (i.e. dpms ON state). */ bool (*get_hw_state)(struct intel_connector *); +bool (*get_preferred_mode)(struct intel_connector *, +struct drm_display_mode *); +/* Panel info for eDP and LVDS */ struct intel_panel panel;
@@ -514,6 +517,9 @@ extern int intel_panel_init(struct intel_panel *panel, struct drm_display_mode *fixed_mode);extern void intel_panel_fini (struct intel_panel *panel); +extern bool intel_connector_get_panel_fixed_mode (struct intel_connector *connector, +struct drm_display_mode *mode); +extern void intel_fixed_panel_mode (struct drm_display_mode *fixed_mode,struct drm_display_mode *adjusted_mode); extern void intel_pch_panel_fitting(struct drm_device *dev,
@@ -585,6 +591,8 @@ hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)bool ibx_digital_port_connected (struct drm_i915_private *dev_priv,struct intel_digital_port *port); +extern bool intel_connector_get_preferred_mode (struct intel_connector *connector, +struct drm_display_mode *mode);extern void intel_connector_attach_encoder (struct intel_connector *connector,struct intel_encoder *encoder);extern struct drm_encoder *intel_best_encoder (struct drm_connector *connector);
drivers/gpu/drm/i915/intel_fb.c +9 -0
@@ -216,6 +216,7 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,for (i =0 ; i < fb_helper->connector_count; i++) {struct drm_connector *connector;struct drm_encoder *encoder; +struct drm_display_mode mode; connector = fb_helper->connector_info[i]->connector;if (!enabled[i]) {
@@ -245,6 +246,14 @@ static bool intel_fb_initial_config(struct drm_fb_helper *fb_helper,return false; } +if (intel_connector_get_preferred_mode (to_intel_connector (connector), &mode) && + !drm_mode_equal (&mode, &encoder->crtc->mode)) { +DRM_DEBUG_KMS ("connector %s on crtc %d has an non-native mode, aborting\n" , +drm_get_connector_name (connector), + encoder->crtc->base.id); +return false; + } + modes[i] = &encoder->crtc->mode; crtcs[i] =intel_fb_helper_crtc (fb_helper, encoder->crtc);
drivers/gpu/drm/i915/intel_lvds.c +1 -0
@@ -1129,6 +1129,7 @@ bool intel_lvds_init(struct drm_device *dev) intel_encoder->get_hw_state = intel_lvds_get_hw_state; intel_encoder->get_mode_flags = intel_lvds_get_mode_flags; intel_connector->get_hw_state = intel_connector_get_hw_state; + intel_connector->get_preferred_mode = intel_connector_get_panel_fixed_mode;intel_connector_attach_encoder (intel_connector, intel_encoder); intel_encoder->type =INTEL_OUTPUT_LVDS ;
drivers/gpu/drm/i915/intel_panel.c +10 -0
@@ -35,6 +35,16 @@#define PCI_LBPC 0xf4/* legacy/combination backlight modes */ +bool intel_connector_get_panel_fixed_mode (struct intel_connector *connector, +struct drm_display_mode *mode) +{ +if (!connector->panel.fixed_mode) +return false; + + *mode = *connector->panel.fixed_mode; +return true; +} +void intel_fixed_panel_mode (struct drm_display_mode *fixed_mode,struct drm_display_mode *adjusted_mode)
Signature · 1 line
1.7.9.5
PATCH 6/13 drm/i915: Validate that the framebuffer accommodates the current mode
In reply to Jesse BarnesFrom: Chris Wilson <[email protected]>
As we retrieve the mode from the BIOS it may be constructed using different assumptions for its configuration, such as utilizing the panel fitter in a conflicting manner. As such the associated framebuffer may be insufficient for our setup, and so we need to reject the current mode and install our own.
Jesse: This should probably be put into a new state readout function separate from the fb code
--- drivers/gpu/drm/i915/intel_display.c | 38 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/intel_display.c +28 -10
@@ -6580,27 +6580,40 @@ intel_framebuffer_create_for_mode(struct drm_device *dev,return intel_framebuffer_create (dev, &mode_cmd, obj); } +static bool +mode_fits_in_fb (struct drm_display_mode *mode, +struct drm_framebuffer *fb) +{ +struct drm_i915_gem_object *obj; +int min_pitch; + + min_pitch =intel_framebuffer_pitch_for_width (mode->hdisplay, + fb->bits_per_pixel); +if (fb->pitches[0 ] < min_pitch) +return false; + + obj =to_intel_framebuffer (fb)->obj; +if (obj ==NULL ) +return false; + +if (obj->base.size < mode->vdisplay * fb->pitches[0 ]) +return false; + +return true; +} +static struct drm_framebuffer *mode_fits_in_fbdev (struct drm_device *dev,struct drm_display_mode *mode) {struct drm_i915_private *dev_priv = dev->dev_private; -struct drm_i915_gem_object *obj;struct drm_framebuffer *fb;if (dev_priv->fbdev ==NULL )return NULL ; - obj = dev_priv->fbdev->ifb.obj; -if (obj ==NULL ) -return NULL ; - fb = &dev_priv->fbdev->ifb.base; -if (fb->pitches[0 ] <intel_framebuffer_pitch_for_width (mode->hdisplay, - fb->bits_per_pixel)) -return NULL ; - -if (obj->base.size < mode->vdisplay * fb->pitches[0 ]) +if (!mode_fits_in_fb (mode, fb))return NULL ;return fb;
@@ -9277,6 +9290,11 @@ setup_pipes:if (crtc->base.enabled) crtc->mode_valid =intel_crtc_get_mode (&crtc->base, &crtc->base.mode); + +if (crtc->base.fb && + !mode_fits_in_fb (&crtc->base.mode, crtc->base.fb)) + crtc->mode_valid = false; +if (crtc->mode_valid) {DRM_DEBUG_KMS ("found active mode: " );drm_mode_debug_printmodeline (&crtc->base.mode);
Signature · 1 line
1.7.9.5
PATCH 7/13 drm/i915: check panel fit status at update_plane time v2
In reply to Jesse BarnesWe may need to disable the panel when flipping to a new buffer, so check the state here and zero it out if needed, otherwise leave it alone.
v2: fixup pipe_set_base check (Imre)
--- drivers/gpu/drm/i915/intel_display.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/i915/intel_display.c +12 -0
@@ -2363,6 +2363,18 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,return ret; } +/* Update pipe size and adjust fitter if needed */ +I915_WRITE (PIPESRC (intel_crtc->pipe), + ((crtc->mode.hdisplay -1 ) <<16 ) | + (crtc->mode.vdisplay -1 )); +if (!dev_priv->pch_pf_size && + (intel_pipe_has_type (crtc,INTEL_OUTPUT_LVDS ) || +intel_pipe_has_type (crtc,INTEL_OUTPUT_EDP ))) { +I915_WRITE (PF_CTL (intel_crtc->pipe),0 ); +I915_WRITE (PF_WIN_POS (intel_crtc->pipe),0 ); +I915_WRITE (PF_WIN_SZ (intel_crtc->pipe),0 ); + } + ret = dev_priv->display.update_plane (crtc, fb, x, y);if (ret) {intel_unpin_fb_obj (to_intel_framebuffer (fb)->obj);
Signature · 1 line
1.7.9.5
Re: [PATCH 07/13] drm/i915: check panel fit status at update_plane time v2
Quoted 6 lines · Jesse Barnes
We may need to disable the panel when flipping to a new buffer, so check the state here and zero it out if needed, otherwise leave it alone.
v2: fixup
pipe_set_basecheck (Imre)Signed-off-by Jesse Barnes <[email protected]>
tbh I have no idea yet how we should best handle this and the following patch. My current guess is that we need a special pipe_update path, which sits in between the fb_update and the full modeset we currently have. A bunch of things we might want to do in that case:
- kill the vga plane
- update watermarks to our (hopefully power-efficient) ones
- adjust pfit state (the bios tends to enable that even on non-lvds/edp outputs)
- update other/global pm state (power well, refclocks, ...)
- update infoframes/audio bits (not relevant for panels luckily)
Of course I'd prefer if the code is somehow shared between the update_pipe path and the full modeset, since we'll inevitably get something wrong ... -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 07/13] drm/i915: check panel fit status at update_plane time v2
Quoted 19 lines · On Tue, 2 Apr 2013 19:58:37 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 6 lines · Jesse Barnes
We may need to disable the panel when flipping to a new buffer, so check the state here and zero it out if needed, otherwise leave it alone.
v2: fixup
pipe_set_basecheck (Imre)Signed-off-by Jesse Barnes <[email protected]>tbh I have no idea yet how we should best handle this and the following patch. My current guess is that we need a special
pipe_updatepath, which sits in between thefb_updateand the full modeset we currently have. A bunch of things we might want to do in that case:
- kill the vga plane
- update watermarks to our (hopefully power-efficient) ones
- adjust pfit state (the bios tends to enable that even on non-lvds/edp outputs)
- update other/global pm state (power well, refclocks, ...)
- update infoframes/audio bits (not relevant for panels luckily)
Quoted 2 lines
Of course I'd prefer if the code is somehow shared between the
update_pipepath and the full modeset, since we'll inevitably get something wrong ...
Agree that we should share code paths where possible.
I think we could add new paths in enable/disable crtc for adjusting the global state. pfit would probably fit better there anyway, since it's not really panel specific.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
PATCH 8/13 drm/i915: treat no fb -> fb as simple flip instead of full mode set
In reply to Jesse BarnesIn case we don't get an fb from the BIOS, we may still be able to re-use existing state and flip a new buffer.
Jesse: Do we want a macro for "no mode set" or just a new check for crtc->active here?
--- drivers/gpu/drm/i915/intel_display.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -3
@@ -8109,10 +8109,8 @@ intel_set_config_compute_mode_changes(struct drm_mode_set *set,/* We should be able to check here if the fb has the same properties * and then just flip_or_move it */ if (set->crtc->fb != set->fb) { -/* If we have no fb then treat it as a full mode set */ if (set->crtc->fb ==NULL ) { -DRM_DEBUG_KMS ("crtc has no fb, full mode set\n" ); - config->mode_changed = true; + config->fb_changed = true; }else if (set->fb ==NULL ) { config->mode_changed = true; }else if (set->fb->depth != set->crtc->fb->depth) {
Signature · 1 line
1.7.9.5
PATCH 9/13 drm/i915: add debug messages for mode_valid checks
In reply to Jesse BarnesLets us see what's going on if we slowboot instead of fastboot.
--- drivers/gpu/drm/i915/intel_display.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_display.c +9 -2
@@ -9298,12 +9298,19 @@ setup_pipes: crtc->active ? "enabled" : "disabled"); -if (crtc->base.enabled) +if (crtc->base.enabled) { crtc->mode_valid =intel_crtc_get_mode (&crtc->base, &crtc->base.mode); +DRM_DEBUG_KMS ("[CRTC:%d]: mode valid? %s\n" , + crtc->base.base.id, + crtc->mode_valid ?"yes" :"no" ); + }if (crtc->base.fb && - !mode_fits_in_fb (&crtc->base.mode, crtc->base.fb)) + !mode_fits_in_fb (&crtc->base.mode, crtc->base.fb)) { crtc->mode_valid = false; +DRM_DEBUG_KMS ("[CRTC:%d] mode doesn't fit in fb\n" , + crtc->base.base.id); + }if (crtc->mode_valid) {DRM_DEBUG_KMS ("found active mode: " );
Signature · 1 line
1.7.9.5
PATCH 10/13 drm/i915: fetch PCH PLL state at init time
In reply to Jesse BarnesWe need to properly track PCH PLL sharing configs, and generally set up PCH PLL state at init time as part of the state readout process.
--- drivers/gpu/drm/i915/intel_display.c | 51 ++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/gpu/drm/i915/intel_display.c +51 -0
@@ -6915,6 +6915,54 @@ static int ironlake_crtc_clock_get(struct drm_crtc *crtc)return clock; } +static bool ironlake_crtc_pll_get (struct drm_crtc *crtc) +{ +struct drm_i915_private *dev_priv = crtc->dev->dev_private; +struct intel_crtc *intel_crtc =to_intel_crtc (crtc); +u32 dpll_sel; + +if (HAS_PCH_IBX (dev_priv->dev)) + intel_crtc->pch_pll = &dev_priv->pch_plls[intel_crtc->pipe]; + +if (HAS_PCH_CPT (dev_priv->dev)) { + dpll_sel =I915_READ (PCH_DPLL_SEL ); + +switch (intel_crtc->pipe) { +case PIPE_A : +if ((dpll_sel &TRANSA_DPLL_ENABLE ) && + (dpll_sel &TRANSA_DPLLB_SEL )) + intel_crtc->pch_pll = &dev_priv->pch_plls[1 ]; +else if (dpll_sel &TRANSA_DPLL_ENABLE ) + intel_crtc->pch_pll = &dev_priv->pch_plls[0 ]; +break ; +case PIPE_B : +if ((dpll_sel &TRANSB_DPLL_ENABLE ) && + (dpll_sel &TRANSB_DPLLB_SEL )) + intel_crtc->pch_pll = &dev_priv->pch_plls[1 ]; +else if (dpll_sel &TRANSB_DPLL_ENABLE ) + intel_crtc->pch_pll = &dev_priv->pch_plls[0 ]; +break ; +case PIPE_C : +if ((dpll_sel &TRANSC_DPLL_ENABLE ) && + (dpll_sel &TRANSC_DPLLB_SEL )) + intel_crtc->pch_pll = &dev_priv->pch_plls[1 ]; +else if (dpll_sel &TRANSC_DPLL_ENABLE ) + intel_crtc->pch_pll = &dev_priv->pch_plls[0 ]; +break ; +default : +break ; + } + } + +if (intel_crtc->pch_pll) { + intel_crtc->pch_pll->refcount++; + intel_crtc->pch_pll->active =1 ; +return true; + } + +return false; +} +static bool ironlake_crtc_get_mode (struct drm_crtc *crtc,struct drm_display_mode *mode) {
@@ -6943,6 +6991,9 @@ static bool ironlake_crtc_get_mode(struct drm_crtc *crtc, mode->clock =ironlake_crtc_clock_get (crtc); +if (!ironlake_crtc_pll_get (crtc)) +return false; +drm_mode_set_name (mode);return true;
Signature · 1 line
1.7.9.5
PATCH 11/13 drm/i915: fix DDI get_hw_state return value
In reply to Jesse BarnesIf we couldn't find a pipe we shouldn't return true. This might be even better as a WARN though, since it should be impossible to have the port enabled without a pipe selected.
--- drivers/gpu/drm/i915/intel_ddi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_ddi.c +1 -1
@@ -1153,7 +1153,7 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,DRM_DEBUG_KMS ("No pipe for ddi port %i found\n" , port); -return true; +return false; } static uint32_t intel_ddi_get_crtc_pll(struct drm_i915_private *dev_priv,
Signature · 1 line
1.7.9.5
PATCH 12/13 drm/i915: fix DP get_hw_state return value
In reply to Jesse BarnesIf we couldn't find a pipe we shouldn't return true. This might be even better as a WARN though, since it should be impossible to have the port enabled without a pipe selected.
--- drivers/gpu/drm/i915/intel_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_dp.c +1 -1
@@ -1366,7 +1366,7 @@ static bool intel_dp_get_hw_state(struct intel_encoder *encoder, intel_dp->output_reg); } -return true; +return false; }static unsigned intel_dp_get_mode_flags (struct intel_encoder *encoder)
Signature · 1 line
1.7.9.5
Re: [PATCH 12/13] drm/i915: fix DP get_hw_state return value
Quoted 5 lines · Jesse Barnes
If we couldn't find a pipe we shouldn't return true. This might be even better as a WARN though, since it should be impossible to have the port enabled without a pipe selected.
Signed-off-by Jesse Barnes <[email protected]>
These two fixes are merged for -next, thanks.
-Daniel
Quoted 24 lines
--- drivers/gpu/drm/i915/intel_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/i915/intel_dp.c +1
-1@@ -1366,7 +1366,7 @@ static bool intel_dp_get_hw_state(struct intel_encoder *encoder, intel_dp->output_reg); } -return true; +return false; }static unsigned intel_dp_get_mode_flags (struct intel_encoder *encoder)Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 12/13] drm/i915: fix DP get_hw_state return value
Quoted 8 lines · Daniel Vetter
Quoted 5 lines · Jesse Barnes
If we couldn't find a pipe we shouldn't return true. This might be even better as a WARN though, since it should be impossible to have the port enabled without a pipe selected.
Signed-off-by Jesse Barnes <[email protected]>These two fixes are merged for -next, thanks.
Actually this one here is broken, so I've had to revert it. -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 12/13] drm/i915: fix DP get_hw_state return value
Quoted 11 lines · Daniel Vetter
Quoted 8 lines · Daniel Vetter
Quoted 5 lines · Jesse Barnes
If we couldn't find a pipe we shouldn't return true. This might be even better as a WARN though, since it should be impossible to have the port enabled without a pipe selected.
Signed-off-by Jesse Barnes <[email protected]>These two fixes are merged for -next, thanks.
Actually this one here is broken, so I've had to revert it.
I'm also a bit unsure about the DDI one, since if we ever have a port enabled with a bogus pipe link, we probably still want to shut down the port. At least that part is pretty important to not end up with a black screen in a lot of cases, atm Egbert Eich is debugging such a case for sdvo ...
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 12/13] drm/i915: fix DP get_hw_state return value
In reply to Daniel VetterQuoted 11 lines · On Thu, 4 Apr 2013 01:15:28 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 8 lines · Daniel Vetter
Quoted 5 lines · Jesse Barnes
If we couldn't find a pipe we shouldn't return true. This might be even better as a WARN though, since it should be impossible to have the port enabled without a pipe selected.
Signed-off-by Jesse Barnes <[email protected]>These two fixes are merged for -next, thanks.
Actually this one here is broken, so I've had to revert it.
What failed? How is it possible we'd have a DP port without a pipe? Every pattern in the register field should correspond to a pipe right?
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Re: [PATCH 12/13] drm/i915: fix DP get_hw_state return value
Quoted 9 lines · Jesse Barnes
Quoted 6 lines · On Thu, 4 Apr 2013 01:15:28 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 5 lines · Daniel Vetter
Quoted 4 lines · Jesse Barnes
If we couldn't find a pipe we shouldn't return true. This might be even better as a WARN though, since it should be impossible to have the port enabled without a pipe selected.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Jesse Barnes <[email protected]>These two fixes are merged for -next, thanks.
Actually this one here is broken, so I've had to revert it.
What failed? How is it possible we'd have a DP port without a pipe? Every pattern in the register field should correspond to a pipe right?
Review failed on my side - you've changed the return which is used by all the success cases ... There's another return for one failure case, and the no-pipe one just falls through. The only case this patch did _not_ break is pch ports on cpt/ppt.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Re: [PATCH 12/13] drm/i915: fix DP get_hw_state return value
Quoted 16 lines · On Thu, 4 Apr 2013 09:56:07 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 15 lines · Jesse Barnes
Quoted 11 lines · On Thu, 4 Apr 2013 01:15:28 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 8 lines · Daniel Vetter
Quoted 5 lines · Jesse Barnes
If we couldn't find a pipe we shouldn't return true. This might be even better as a WARN though, since it should be impossible to have the port enabled without a pipe selected.
Signed-off-by Jesse Barnes <[email protected]>These two fixes are merged for -next, thanks.
Actually this one here is broken, so I've had to revert it.
Quoted 7 lines
Quoted 2 lines
What failed? How is it possible we'd have a DP port without a pipe? Every pattern in the register field should correspond to a pipe right?
Review failed on my side - you've changed the return which is used by all the success cases ... There's another return for one failure case, and the no-pipe one just falls through. The only case this patch did _not_ break is pch ports on cpt/ppt.
Testing fail on my part; I was testing PCH ports but not DP with the config I had.
Jesse
PATCH 13/13 drm/i915: drop check for invalid pipe after fetching current hw state
In reply to Jesse BarnesShouldn't be possible with return value fixes.
--- drivers/gpu/drm/i915/intel_display.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -3
@@ -9374,9 +9374,7 @@ setup_pipes:list_for_each_entry (encoder, &dev->mode_config.encoder_list, base.head) { - pipe =-1 ; - -if (encoder->get_hw_state (encoder, &pipe) && pipe !=-1 ) { +if (encoder->get_hw_state (encoder, &pipe)) { crtc =to_intel_crtc (dev_priv->pipe_to_crtc_mapping[pipe]);if (crtc->mode_valid && encoder->get_mode_flags) crtc->base.mode.flags |= encoder->get_mode_flags (encoder);
Signature · 1 line
1.7.9.5