From: Imre Deak <imre.deak@intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 5/8] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon
Date: Fri, 08 Mar 2013 14:05:48 +0200 [thread overview]
Message-ID: <1362744348.3988.8.camel@ideak-mobl> (raw)
In-Reply-To: <1360149028-13531-5-git-send-email-chris@chris-wilson.co.uk>
On Wed, 2013-02-06 at 11:10 +0000, Chris Wilson wrote:
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
> ---
> 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 | 305 +++++++++++++++++++++++++++++++---
> 5 files changed, 306 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
> index 4fa6beb..f2b7db7 100644
> --- a/drivers/gpu/drm/i915/i915_dma.c
> +++ b/drivers/gpu/drm/i915/i915_dma.c
> @@ -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;
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index fd8a495..6f4afbf 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1814,7 +1814,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);
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 8f9cdd7..7c4c7d5 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -8698,12 +8698,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);
> @@ -8713,6 +8718,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)
> @@ -8728,7 +8735,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;
> @@ -8775,7 +8783,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. */
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 07d95a1..985e9dd 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -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
> @@ -612,6 +615,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);
> diff --git a/drivers/gpu/drm/i915/intel_fb.c b/drivers/gpu/drm/i915/intel_fb.c
> index de0ac4c..ca6c8e6 100644
> --- a/drivers/gpu/drm/i915/intel_fb.c
> +++ b/drivers/gpu/drm/i915/intel_fb.c
> @@ -131,7 +131,6 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
> struct drm_device *dev = ifbdev->helper.dev;
> struct drm_mode_fb_cmd2 mode_cmd = { 0 };
> struct drm_i915_gem_object *obj;
> - struct fb_info *info;
> int size, ret;
>
> /* we don't do packed 24bpp */
> @@ -176,14 +175,7 @@ static int intelfb_create(struct intel_fbdev *ifbdev,
> mode_cmd.width, mode_cmd.height,
> obj->gtt_offset, obj);
>
> - info = intelfb_create_info(ifbdev);
> - if (info == NULL) {
> - ret = -ENOMEM;
> - goto out_unpin;
> - }
> -
> mutex_unlock(&dev->struct_mutex);
> - vga_switcheroo_client_fb_set(dev->pdev, info);
> return 0;
>
> out_unpin:
> @@ -200,17 +192,92 @@ static int intel_fb_find_or_create_single(struct drm_fb_helper *helper,
> {
> struct intel_fbdev *ifbdev = (struct intel_fbdev *)helper;
> int new_fb = 0;
> - int ret;
>
> if (!helper->fb) {
> - ret = intelfb_create(ifbdev, sizes);
> - if (ret)
> - return ret;
> + struct fb_info *info;
> +
> + if (!ifbdev->stolen) {
> + int ret = intelfb_create(ifbdev, sizes);
> + if (ret)
> + return ret;
> + }
> +
> + info = intelfb_create_info(ifbdev);
> + if (info == NULL) {
> + DRM_DEBUG_KMS("fb creation failed\n");
> + return -ENOMEM;
> + }
> + vga_switcheroo_client_fb_set(helper->dev->pdev, info);
> +
> new_fb = 1;
> }
> +
> return new_fb;
> }
>
> +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;
I might be missing something, but I can't see how crtc->mode will be
valid at this point. We'll get here through
intel_fb_initial_config()->drm_setup_crtcs() but as I understand
crtc->mode will only be set afterwards through
intel_fb_initial_config()->drm_fb_helper_single_fb_probe().
At least testing on my ILK I get here with mode_valid=false.
--Imre
next prev parent reply other threads:[~2013-03-08 12:05 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-06 11:10 [PATCH 1/8] drm/i915: Skip modifying PCH DREF if not changing clock sources Chris Wilson
2013-02-06 11:10 ` [PATCH 2/8] drm/i915: Introduce i915_gem_object_create_stolen_for_preallocated Chris Wilson
2013-02-07 5:09 ` Ben Widawsky
2013-02-07 14:32 ` Chris Wilson
2013-02-07 18:13 ` Ben Widawsky
2013-02-06 11:10 ` [PATCH 3/8] drm/i915: Split the framebuffer_info creation into a separate routine Chris Wilson
2013-03-07 14:49 ` Imre Deak
2013-02-06 11:10 ` [PATCH 4/8] drm: add initial_config function to fb helper Chris Wilson
2013-02-06 11:10 ` [PATCH 5/8] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon Chris Wilson
2013-03-08 12:05 ` Imre Deak [this message]
2013-02-06 11:10 ` [PATCH 6/8] drm/i915: Retrieve the current mode upon KMS takeover Chris Wilson
2013-02-07 12:58 ` Paulo Zanoni
2013-03-08 15:46 ` Imre Deak
2013-03-08 15:51 ` Imre Deak
2013-02-06 11:10 ` [PATCH 7/8] drm/i915: Only preserve the BIOS modes if they are the preferred ones Chris Wilson
2013-02-06 11:10 ` [PATCH 8/8] drm/i915: Validate that the framebuffer accommodates the current mode Chris Wilson
2013-02-06 12:46 ` [PATCH 1/8] drm/i915: Skip modifying PCH DREF if not changing clock sources Daniel Vetter
2013-02-07 12:45 ` Paulo Zanoni
2013-02-07 13:21 ` Daniel Vetter
2013-03-07 13:16 ` Imre Deak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1362744348.3988.8.camel@ideak-mobl \
--to=imre.deak@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.