* [PATCH 01/10] drm/i915/vlv: add early DPIO init v3
@ 2013-12-17 22:46 Jesse Barnes
2013-12-17 22:46 ` [PATCH 02/10] drm/i915/vlv: split DPIO init and reset Jesse Barnes
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:46 UTC (permalink / raw)
To: intel-gfx
Just add an early init since we may need to access DPIO regs early on.
The init call in modeset_init_hw is also needed for the resume case,
when we need to reset DPIO to keep things happy.
v2: split reset and reg init
v3: split patches (Daniel)
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/gpu/drm/i915/intel_display.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index af3717a..24506be 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -10861,6 +10861,8 @@ void intel_modeset_init(struct drm_device *dev)
}
}
+ intel_init_dpio(dev);
+
intel_cpu_pll_init(dev);
intel_shared_dpll_init(dev);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 02/10] drm/i915/vlv: split DPIO init and reset
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
@ 2013-12-17 22:46 ` Jesse Barnes
2013-12-17 22:46 ` [PATCH 03/10] drm/i915: read out hw state earlier Jesse Barnes
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:46 UTC (permalink / raw)
To: intel-gfx
We only need to init the reg offset for DPIO once, but we need to reset
DPIO at resume time and at init time.
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/gpu/drm/i915/intel_display.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 24506be..aa935ae 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1368,6 +1368,15 @@ static void intel_init_dpio(struct drm_device *dev)
return;
DPIO_PHY_IOSF_PORT(DPIO_PHY0) = IOSF_PORT_DPIO;
+}
+
+static void intel_reset_dpio(struct drm_device *dev)
+{
+ struct drm_i915_private *dev_priv = dev->dev_private;
+
+ if (!IS_VALLEYVIEW(dev))
+ return;
+
/*
* From VLV2A0_DP_eDP_DPIO_driver_vbios_notes_10.docx -
* 6. De-assert cmn_reset/side_reset. Same as VLV X0.
@@ -10799,7 +10808,7 @@ void intel_modeset_init_hw(struct drm_device *dev)
I915_WRITE(DPLL(PIPE_B), I915_READ(DPLL(PIPE_B)) |
DPLL_INTEGRATED_CRI_CLK_VLV);
- intel_init_dpio(dev);
+ intel_reset_dpio(dev);
mutex_lock(&dev->struct_mutex);
intel_enable_gt_powersave(dev);
@@ -10862,6 +10871,7 @@ void intel_modeset_init(struct drm_device *dev)
}
intel_init_dpio(dev);
+ intel_reset_dpio(dev);
intel_cpu_pll_init(dev);
intel_shared_dpll_init(dev);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 03/10] drm/i915: read out hw state earlier
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
2013-12-17 22:46 ` [PATCH 02/10] drm/i915/vlv: split DPIO init and reset Jesse Barnes
@ 2013-12-17 22:46 ` Jesse Barnes
2013-12-17 22:46 ` [PATCH 04/10] drm/i915: split aligned height calculation out Jesse Barnes
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:46 UTC (permalink / raw)
To: intel-gfx
We want to do this early on before we try to fetch the plane config,
which depends on some of the pipe config state.
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/gpu/drm/i915/intel_display.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index aa935ae..0b8a058a 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -10882,6 +10882,11 @@ void intel_modeset_init(struct drm_device *dev)
/* Just in case the BIOS is doing something questionable. */
intel_disable_fbc(dev);
+
+ drm_modeset_lock_all(dev);
+ drm_mode_config_reset(dev);
+ intel_modeset_setup_hw_state(dev, false);
+ drm_modeset_unlock_all(dev);
}
static void
@@ -11249,11 +11254,6 @@ void intel_modeset_gem_init(struct drm_device *dev)
intel_modeset_init_hw(dev);
intel_setup_overlay(dev);
-
- drm_modeset_lock_all(dev);
- drm_mode_config_reset(dev);
- intel_modeset_setup_hw_state(dev, false);
- drm_modeset_unlock_all(dev);
}
void intel_modeset_cleanup(struct drm_device *dev)
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 04/10] drm/i915: split aligned height calculation out
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
2013-12-17 22:46 ` [PATCH 02/10] drm/i915/vlv: split DPIO init and reset Jesse Barnes
2013-12-17 22:46 ` [PATCH 03/10] drm/i915: read out hw state earlier Jesse Barnes
@ 2013-12-17 22:46 ` Jesse Barnes
2013-12-17 22:46 ` [PATCH 05/10] drm/i915: retrieve current fb config into new plane_config structure at init v8 Jesse Barnes
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:46 UTC (permalink / raw)
To: intel-gfx
For use by get_plane_config.
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/gpu/drm/i915/intel_display.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 0b8a058a..367d64d 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1921,6 +1921,14 @@ static bool need_vtd_wa(struct drm_device *dev)
return false;
}
+static int intel_align_height(struct drm_device *dev, int height, bool tiled)
+{
+ int tile_height;
+
+ tile_height = IS_GEN2(dev) ? 16 : 8;
+ return ALIGN(height, tiled ? tile_height : 1);
+}
+
int
intel_pin_and_fence_fb_obj(struct drm_device *dev,
struct drm_i915_gem_object *obj,
@@ -10392,7 +10400,7 @@ int intel_framebuffer_init(struct drm_device *dev,
struct drm_mode_fb_cmd2 *mode_cmd,
struct drm_i915_gem_object *obj)
{
- int aligned_height, tile_height;
+ int aligned_height;
int pitch_limit;
int ret;
@@ -10486,9 +10494,8 @@ int intel_framebuffer_init(struct drm_device *dev,
if (mode_cmd->offsets[0] != 0)
return -EINVAL;
- tile_height = IS_GEN2(dev) ? 16 : 8;
- aligned_height = ALIGN(mode_cmd->height,
- obj->tiling_mode ? tile_height : 1);
+ aligned_height = intel_align_height(dev, mode_cmd->height,
+ obj->tiling_mode);
/* FIXME drm helper for size checks (especially planar formats)? */
if (obj->base.size < aligned_height * mode_cmd->pitches[0])
return -EINVAL;
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 05/10] drm/i915: retrieve current fb config into new plane_config structure at init v8
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
` (2 preceding siblings ...)
2013-12-17 22:46 ` [PATCH 04/10] drm/i915: split aligned height calculation out Jesse Barnes
@ 2013-12-17 22:46 ` Jesse Barnes
2013-12-18 10:36 ` Jani Nikula
2013-12-17 22:46 ` [PATCH 06/10] drm/i915: alloc intel_fb in the intel_fbdev struct Jesse Barnes
` (4 subsequent siblings)
8 siblings, 1 reply; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:46 UTC (permalink / raw)
To: intel-gfx
Read out the current plane configuration at init time into a new
plane_config structure. This allows us to track any existing
framebuffers attached to the plane and potentially re-use them in our
fbdev code for a smooth handoff.
v2: update for new pitch_for_width function (Jesse)
comment how get_plane_config works with shared fbs (Jesse)
v3: s/ARGB/XRGB (Ville)
use pipesrc width/height (Ville)
fix fourcc comment (Bob)
use drm_format_plane_cpp (Ville)
v4: use fb for tracking fb data object (Ville)
v5: fix up gen2 pitch limits (Ville)
v6: read out stride as well (Daniel)
v7: split out init ordering changes (Daniel)
don't fetch config if !CONFIG_FB
v8: use proper height in get_plane_config (Chris)
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/gpu/drm/i915/i915_drv.h | 3 +
drivers/gpu/drm/i915/intel_display.c | 130 +++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/intel_drv.h | 8 +++
3 files changed, 141 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index efc57fe..2ea151d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -366,6 +366,7 @@ struct drm_i915_error_state {
struct intel_connector;
struct intel_crtc_config;
+struct intel_plane_config;
struct intel_crtc;
struct intel_limit;
struct dpll;
@@ -404,6 +405,8 @@ struct drm_i915_display_funcs {
* fills out the pipe-config with the hw state. */
bool (*get_pipe_config)(struct intel_crtc *,
struct intel_crtc_config *);
+ void (*get_plane_config)(struct intel_crtc *,
+ struct intel_plane_config *);
int (*crtc_mode_set)(struct drm_crtc *crtc,
int x, int y,
struct drm_framebuffer *old_fb);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 367d64d..6c38d03 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2025,6 +2025,27 @@ unsigned long intel_gen4_compute_page_offset(int *x, int *y,
}
}
+int intel_format_to_fourcc(int format)
+{
+ switch (format) {
+ case DISPPLANE_8BPP:
+ return DRM_FORMAT_C8;
+ case DISPPLANE_BGRX555:
+ return DRM_FORMAT_XRGB1555;
+ case DISPPLANE_BGRX565:
+ return DRM_FORMAT_RGB565;
+ default:
+ case DISPPLANE_BGRX888:
+ return DRM_FORMAT_XRGB8888;
+ case DISPPLANE_RGBX888:
+ return DRM_FORMAT_XBGR8888;
+ case DISPPLANE_BGRX101010:
+ return DRM_FORMAT_XRGB2101010;
+ case DISPPLANE_RGBX101010:
+ return DRM_FORMAT_XBGR2101010;
+ }
+}
+
static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
int x, int y)
{
@@ -5480,6 +5501,96 @@ static void vlv_crtc_clock_get(struct intel_crtc *crtc,
pipe_config->port_clock = clock.dot / 5;
}
+static void i9xx_get_plane_config(struct intel_crtc *crtc,
+ struct intel_plane_config *plane_config)
+{
+ struct drm_device *dev = crtc->base.dev;
+ struct drm_i915_private *dev_priv = dev->dev_private;
+ struct drm_i915_gem_object *obj = NULL;
+ struct drm_mode_fb_cmd2 mode_cmd = { 0 };
+ u32 val, base, offset;
+ int pipe = crtc->pipe, plane = crtc->plane;
+ int fourcc, pixel_format;
+ int aligned_height;
+
+ plane_config->fb = kzalloc(sizeof(*plane_config->fb), GFP_KERNEL);
+ if (!plane_config->fb) {
+ DRM_DEBUG_KMS("failed to alloc fb\n");
+ return;
+ }
+
+ val = I915_READ(DSPCNTR(plane));
+
+ if (INTEL_INFO(dev)->gen >= 4)
+ if (val & DISPPLANE_TILED)
+ plane_config->tiled = true;
+
+ pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
+ fourcc = intel_format_to_fourcc(pixel_format);
+ plane_config->fb->base.pixel_format = fourcc;
+ plane_config->fb->base.bits_per_pixel =
+ drm_format_plane_cpp(fourcc, 0) * 8;
+
+ if (INTEL_INFO(dev)->gen >= 4) {
+ if (plane_config->tiled)
+ offset = I915_READ(DSPTILEOFF(plane));
+ else
+ offset = I915_READ(DSPLINOFF(plane));
+ base = I915_READ(DSPSURF(plane)) & 0xfffff000;
+ } else {
+ base = I915_READ(DSPADDR(plane));
+ }
+
+ val = I915_READ(PIPESRC(pipe));
+ plane_config->fb->base.width = ((val >> 16) & 0xfff) + 1;
+ plane_config->fb->base.height = ((val >> 0) & 0xfff) + 1;
+
+ val = I915_READ(DSPSTRIDE(pipe));
+ plane_config->fb->base.pitches[0] = val & 0xffffff80;
+
+ aligned_height = intel_align_height(dev, plane_config->fb->base.height,
+ plane_config->tiled);
+
+ plane_config->size = ALIGN(plane_config->fb->base.pitches[0] *
+ aligned_height, PAGE_SIZE);
+
+ DRM_DEBUG_KMS("pipe/plane %d/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
+ pipe, plane, plane_config->fb->base.width,
+ plane_config->fb->base.height,
+ plane_config->fb->base.bits_per_pixel, base,
+ plane_config->fb->base.pitches[0],
+ plane_config->size);
+
+ /*
+ * If the fb is shared between multiple heads, we'll just get the
+ * first one.
+ */
+ obj = i915_gem_object_create_stolen_for_preallocated(dev, base, base,
+ plane_config->size);
+ if (!obj)
+ return;
+
+ mode_cmd.pixel_format = fourcc;
+ mode_cmd.width = plane_config->fb->base.width;
+ mode_cmd.height = plane_config->fb->base.height;
+ mode_cmd.pitches[0] = plane_config->fb->base.pitches[0];
+
+ mutex_lock(&dev->struct_mutex);
+
+ if (intel_framebuffer_init(dev, plane_config->fb, &mode_cmd, obj)) {
+ DRM_DEBUG_KMS("intel fb init failed\n");
+ goto out_unref_obj;
+ }
+
+ mutex_unlock(&dev->struct_mutex);
+ DRM_DEBUG_KMS("plane fb obj %p\n", plane_config->fb->obj);
+ return;
+
+out_unref_obj:
+ drm_gem_object_unreference(&obj->base);
+ mutex_unlock(&dev->struct_mutex);
+}
+
static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
struct intel_crtc_config *pipe_config)
{
@@ -10569,6 +10680,7 @@ static void intel_init_display(struct drm_device *dev)
dev_priv->display.update_plane = ironlake_update_plane;
} else if (IS_VALLEYVIEW(dev)) {
dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
+ dev_priv->display.get_plane_config = i9xx_get_plane_config;
dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
dev_priv->display.crtc_enable = valleyview_crtc_enable;
dev_priv->display.crtc_disable = i9xx_crtc_disable;
@@ -10576,6 +10688,7 @@ static void intel_init_display(struct drm_device *dev)
dev_priv->display.update_plane = i9xx_update_plane;
} else {
dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
+ dev_priv->display.get_plane_config = i9xx_get_plane_config;
dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
dev_priv->display.crtc_enable = i9xx_crtc_enable;
dev_priv->display.crtc_disable = i9xx_crtc_disable;
@@ -10830,6 +10943,7 @@ void intel_modeset_suspend_hw(struct drm_device *dev)
void intel_modeset_init(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
+ struct intel_crtc *crtc;
int i, j, ret;
drm_mode_config_init(dev);
@@ -10894,6 +11008,22 @@ void intel_modeset_init(struct drm_device *dev)
drm_mode_config_reset(dev);
intel_modeset_setup_hw_state(dev, false);
drm_modeset_unlock_all(dev);
+
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list,
+ base.head) {
+ if (!crtc->active)
+ continue;
+
+#ifdef CONFIG_FB
+ /*
+ * We don't have a good way of freeing the buffer w/o the FB
+ * layer owning it...
+ */
+ if (dev_priv->display.get_plane_config)
+ dev_priv->display.get_plane_config(crtc,
+ &crtc->plane_config);
+#endif
+ }
}
static void
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index ea62673..4787773 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -209,6 +209,12 @@ typedef struct dpll {
int p;
} intel_clock_t;
+struct intel_plane_config {
+ struct intel_framebuffer *fb; /* ends up managed by intel_fbdev.c */
+ bool tiled;
+ int size;
+};
+
struct intel_crtc_config {
/**
* quirks - bitfield with hw state readout quirks
@@ -358,6 +364,7 @@ struct intel_crtc {
bool cursor_visible;
struct intel_crtc_config config;
+ struct intel_plane_config plane_config;
uint32_t ddi_pll_sel;
@@ -707,6 +714,7 @@ void hsw_enable_ips(struct intel_crtc *crtc);
void hsw_disable_ips(struct intel_crtc *crtc);
void intel_display_set_init_power(struct drm_device *dev, bool enable);
int valleyview_get_vco(struct drm_i915_private *dev_priv);
+int intel_format_to_fourcc(int format);
/* intel_dp.c */
void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 06/10] drm/i915: alloc intel_fb in the intel_fbdev struct
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
` (3 preceding siblings ...)
2013-12-17 22:46 ` [PATCH 05/10] drm/i915: retrieve current fb config into new plane_config structure at init v8 Jesse Barnes
@ 2013-12-17 22:46 ` Jesse Barnes
2013-12-17 22:46 ` [PATCH 07/10] drm/i915: allow re-use BIOS connector config for initial fbdev config Jesse Barnes
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:46 UTC (permalink / raw)
To: intel-gfx
Allocate this struct instead, so we can re-use another allocated
elsewhere if needed.
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/gpu/drm/i915/intel_display.c | 4 ++--
drivers/gpu/drm/i915/intel_drv.h | 2 +-
drivers/gpu/drm/i915/intel_fbdev.c | 27 +++++++++++++++++++--------
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 6c38d03..97acb01 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -7838,11 +7838,11 @@ mode_fits_in_fbdev(struct drm_device *dev,
if (dev_priv->fbdev == NULL)
return NULL;
- obj = dev_priv->fbdev->ifb.obj;
+ obj = dev_priv->fbdev->fb->obj;
if (obj == NULL)
return NULL;
- fb = &dev_priv->fbdev->ifb.base;
+ fb = &dev_priv->fbdev->fb->base;
if (fb->pitches[0] < intel_framebuffer_pitch_for_width(mode->hdisplay,
fb->bits_per_pixel))
return NULL;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 4787773..182ba0a 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -110,7 +110,7 @@ struct intel_framebuffer {
struct intel_fbdev {
struct drm_fb_helper helper;
- struct intel_framebuffer ifb;
+ struct intel_framebuffer *fb;
struct list_head fbdev_list;
struct drm_display_mode *our_mode;
};
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 284c3eb..ee4b3c1 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -62,11 +62,20 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
{
struct intel_fbdev *ifbdev =
container_of(helper, struct intel_fbdev, helper);
+ struct intel_framebuffer *fb;
struct drm_device *dev = helper->dev;
struct drm_mode_fb_cmd2 mode_cmd = {};
struct drm_i915_gem_object *obj;
int size, ret;
+ fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+ if (!fb) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ ifbdev->fb = fb;
+
/* we don't do packed 24bpp */
if (sizes->surface_bpp == 24)
sizes->surface_bpp = 32;
@@ -97,7 +106,7 @@ static int intelfb_alloc(struct drm_fb_helper *helper,
goto out_unref;
}
- ret = intel_framebuffer_init(dev, &ifbdev->ifb, &mode_cmd, obj);
+ ret = intel_framebuffer_init(dev, ifbdev->fb, &mode_cmd, obj);
if (ret)
goto out_unpin;
@@ -116,7 +125,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
{
struct intel_fbdev *ifbdev =
container_of(helper, struct intel_fbdev, helper);
- struct intel_framebuffer *intel_fb = &ifbdev->ifb;
+ struct intel_framebuffer *intel_fb = ifbdev->fb;
struct drm_device *dev = helper->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
struct fb_info *info;
@@ -126,11 +135,12 @@ static int intelfb_create(struct drm_fb_helper *helper,
mutex_lock(&dev->struct_mutex);
- if (!intel_fb->obj) {
+ if (!intel_fb || !intel_fb->obj) {
DRM_DEBUG_KMS("no BIOS fb, allocating a new one\n");
ret = intelfb_alloc(helper, sizes);
if (ret)
goto out_unlock;
+ intel_fb = ifbdev->fb;
} else {
DRM_DEBUG_KMS("re-using BIOS fb\n");
sizes->fb_width = intel_fb->base.width;
@@ -148,7 +158,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
info->par = helper;
- fb = &ifbdev->ifb.base;
+ fb = &ifbdev->fb->base;
ifbdev->helper.fb = fb;
ifbdev->helper.fbdev = info;
@@ -194,7 +204,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
* If the object is stolen however, it will be full of whatever
* garbage was left in there.
*/
- if (ifbdev->ifb.obj->stolen)
+ if (ifbdev->fb->obj->stolen)
memset_io(info->screen_base, 0, info->screen_size);
/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
@@ -258,8 +268,9 @@ static void intel_fbdev_destroy(struct drm_device *dev,
drm_fb_helper_fini(&ifbdev->helper);
- drm_framebuffer_unregister_private(&ifbdev->ifb.base);
- intel_framebuffer_fini(&ifbdev->ifb);
+ drm_framebuffer_unregister_private(&ifbdev->fb->base);
+ intel_framebuffer_fini(ifbdev->fb);
+ kfree(ifbdev->fb);
}
int intel_fbdev_init(struct drm_device *dev)
@@ -322,7 +333,7 @@ void intel_fbdev_set_suspend(struct drm_device *dev, int state)
* been restored from swap. If the object is stolen however, it will be
* full of whatever garbage was left in there.
*/
- if (state == FBINFO_STATE_RUNNING && ifbdev->ifb.obj->stolen)
+ if (state == FBINFO_STATE_RUNNING && ifbdev->fb->obj->stolen)
memset_io(info->screen_base, 0, info->screen_size);
fb_set_suspend(info, state);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 07/10] drm/i915: allow re-use BIOS connector config for initial fbdev config
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
` (4 preceding siblings ...)
2013-12-17 22:46 ` [PATCH 06/10] drm/i915: alloc intel_fb in the intel_fbdev struct Jesse Barnes
@ 2013-12-17 22:46 ` Jesse Barnes
2013-12-17 22:46 ` [PATCH 08/10] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v8 Jesse Barnes
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:46 UTC (permalink / raw)
To: intel-gfx
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 and connectors
are active and stuffs them into the crtcs and modes array given to us by
the drm_fb_helper code.
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/gpu/drm/i915/intel_fbdev.c | 91 ++++++++++++++++++++++++++++++++++++++
1 file changed, 91 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index ee4b3c1..9e7f6d1 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -246,6 +246,97 @@ static void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green,
*blue = intel_crtc->lut_b[regno] << 8;
}
+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;
+}
+
+/*
+ * 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 and connectors are active
+ * and stuffs them into the crtcs and modes array given to us by the
+ * drm_fb_helper code.
+ *
+ * The overall sequence is:
+ * intel_fbdev_init - from driver load
+ * intel_fbdev_init_bios - initialize the intel_fbdev using BIOS data
+ * drm_fb_helper_init - build fb helper structs
+ * drm_fb_helper_single_add_all_connectors - more fb helper structs
+ * intel_fbdev_initial_config - apply the config
+ * drm_fb_helper_initial_config - call ->probe then register_framebuffer()
+ * drm_setup_crtcs - build crtc config for fbdev
+ * intel_fb_initial_config - find active connectors etc
+ * drm_fb_helper_single_fb_probe - set up fbdev
+ * intelfb_create - re-use or alloc fb, build out fbdev structs
+ *
+ * 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.
+ */
+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);
+ enabled[i] = false;
+ 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)->active) {
+ DRM_DEBUG_KMS("connector %s on inactive crtc %d, borting\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,
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 08/10] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v8
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
` (5 preceding siblings ...)
2013-12-17 22:46 ` [PATCH 07/10] drm/i915: allow re-use BIOS connector config for initial fbdev config Jesse Barnes
@ 2013-12-17 22:46 ` Jesse Barnes
2013-12-17 22:47 ` [PATCH 09/10] port hotplug status live fix for VLV Jesse Barnes
2013-12-17 22:47 ` [PATCH 10/10] convert to using crtc->fb for BIOS fb management Jesse Barnes
8 siblings, 0 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:46 UTC (permalink / raw)
To: intel-gfx
Retrieve current framebuffer config info from the regs and create an fb
object for the buffer the BIOS or boot loader left us. This should
allow for smooth transitions to userspace apps once we finish the
initial configuration construction.
v2: 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)
v4: update to current bits (locking & pin_and_fence hack) (Jesse)
v5: move fb config fetch to display code (Jesse)
re-order hw state readout on initial load to suit fb inherit (Jesse)
re-add pin_and_fence in fbdev code to make sure we refcount properly (Je
v6: rename to plane_config (Daniel)
check for valid object when initializing BIOS fb (Jesse)
split from plane_config readout and other display changes (Jesse)
drop use_bios_fb option (Chris)
update comments (Jesse)
rework fbdev_init_bios for clarity (Jesse)
drop fb obj ref under lock (Chris)
v7: use fb object from plane_config instead (Ville)
take ref on fb object (Jesse)
v8: put under i915_fastboot option (Jesse)
fix fb ptr checking (Jesse)
inform drm_fb_helper if we fail to enable a connector (Jesse)
drop unnecessary enabled[] modifications in failure cases (Chris)
split from BIOS connector config readout (Daniel)
don't memset the fb buffer if preallocated (Chris)
alloc ifbdev up front and pass to init_bios (Chris)
check for bad ifbdev in restore_mode too (Chris)
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
---
drivers/gpu/drm/i915/intel_drv.h | 1 +
drivers/gpu/drm/i915/intel_fbdev.c | 111 ++++++++++++++++++++++++++++++++++---
2 files changed, 103 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 182ba0a..d849a5c 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -113,6 +113,7 @@ struct intel_fbdev {
struct intel_framebuffer *fb;
struct list_head fbdev_list;
struct drm_display_mode *our_mode;
+ int preferred_bpp;
};
struct intel_encoder {
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index 9e7f6d1..a3e8156 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -132,6 +132,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
struct drm_framebuffer *fb;
struct drm_i915_gem_object *obj;
int size, ret;
+ bool prealloc = false;
mutex_lock(&dev->struct_mutex);
@@ -143,6 +144,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
intel_fb = ifbdev->fb;
} else {
DRM_DEBUG_KMS("re-using BIOS fb\n");
+ prealloc = true;
sizes->fb_width = intel_fb->base.width;
sizes->fb_height = intel_fb->base.height;
}
@@ -204,7 +206,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
* If the object is stolen however, it will be full of whatever
* garbage was left in there.
*/
- if (ifbdev->fb->obj->stolen)
+ if (ifbdev->fb->obj->stolen && !prealloc)
memset_io(info->screen_base, 0, info->screen_size);
/* Use default scratch pixmap (info->pixmap.flags = FB_PIXMAP_SYSTEM) */
@@ -364,23 +366,112 @@ static void intel_fbdev_destroy(struct drm_device *dev,
kfree(ifbdev->fb);
}
+/*
+ * Build an intel_fbdev struct using a BIOS allocated framebuffer, if possible.
+ * The core display code will have read out the current plane configuration,
+ * so we use that to figure out if there's an object for us to use as the
+ * fb, and if so, we re-use it for the fbdev configuration.
+ *
+ * Note we only support a single fb shared across pipes for boot (mostly for
+ * fbcon), so we just find the biggest and use that.
+ */
+static bool intel_fbdev_init_bios(struct drm_device *dev,
+ struct intel_fbdev *ifbdev)
+{
+ struct intel_framebuffer *fb = NULL;
+ struct drm_crtc *crtc;
+ struct intel_crtc *intel_crtc;
+ struct intel_plane_config *plane_config = NULL;
+ unsigned int last_size = 0;
+
+ /* Find the largest framebuffer to use, then free the others */
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ intel_crtc = to_intel_crtc(crtc);
+
+ if (!intel_crtc->active || !intel_crtc->plane_config.fb) {
+ DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n",
+ pipe_name(intel_crtc->pipe));
+ continue;
+ }
+
+ if (intel_crtc->plane_config.size > last_size) {
+ plane_config = &intel_crtc->plane_config;
+ last_size = plane_config->size;
+ fb = plane_config->fb;
+ }
+ }
+
+ /* Free unused fbs */
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ struct intel_framebuffer *cur_fb;
+
+ intel_crtc = to_intel_crtc(crtc);
+ cur_fb = intel_crtc->plane_config.fb;
+
+ if (cur_fb && cur_fb != fb)
+ intel_framebuffer_fini(cur_fb);
+ }
+
+ if (!fb) {
+ DRM_DEBUG_KMS("no active pipes found, not using BIOS config\n");
+ goto out_free;
+ }
+
+ ifbdev->preferred_bpp = plane_config->fb->base.bits_per_pixel;
+ ifbdev->helper.funcs = &intel_fb_helper_funcs;
+ ifbdev->helper.funcs->initial_config = intel_fb_initial_config;
+ ifbdev->fb = fb;
+
+ /* Assuming a single fb across all pipes here */
+ list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
+ intel_crtc = to_intel_crtc(crtc);
+
+ if (!intel_crtc->active)
+ 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, fb->obj, NULL))
+ goto out_unref_obj;
+
+ crtc->fb = &fb->base;
+ drm_gem_object_reference(&fb->obj->base);
+ drm_framebuffer_reference(&fb->base);
+ }
+
+ DRM_DEBUG_KMS("using BIOS fb for initial console\n");
+ return true;
+
+out_unref_obj:
+ intel_framebuffer_fini(fb);
+out_free:
+ kfree(ifbdev);
+
+ return false;
+}
+
int intel_fbdev_init(struct drm_device *dev)
{
struct intel_fbdev *ifbdev;
struct drm_i915_private *dev_priv = dev->dev_private;
int ret;
- ifbdev = kzalloc(sizeof(*ifbdev), GFP_KERNEL);
- if (!ifbdev)
+ ifbdev = kzalloc(sizeof(struct intel_fbdev), GFP_KERNEL);
+ if (ifbdev == NULL)
return -ENOMEM;
- dev_priv->fbdev = ifbdev;
ifbdev->helper.funcs = &intel_fb_helper_funcs;
+ dev_priv->fbdev = ifbdev;
+
+ if (i915_fastboot && !intel_fbdev_init_bios(dev, ifbdev))
+ ifbdev->preferred_bpp = 32;
ret = drm_fb_helper_init(dev, &ifbdev->helper,
- INTEL_INFO(dev)->num_pipes,
- 4);
+ INTEL_INFO(dev)->num_pipes, 4);
if (ret) {
+ dev_priv->fbdev = NULL;
kfree(ifbdev);
return ret;
}
@@ -393,9 +484,10 @@ int intel_fbdev_init(struct drm_device *dev)
void intel_fbdev_initial_config(struct drm_device *dev)
{
struct drm_i915_private *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)
@@ -435,7 +527,8 @@ MODULE_LICENSE("GPL and additional rights");
void intel_fbdev_output_poll_changed(struct drm_device *dev)
{
struct drm_i915_private *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_fbdev_restore_mode(struct drm_device *dev)
@@ -443,7 +536,7 @@ void intel_fbdev_restore_mode(struct drm_device *dev)
int ret;
struct drm_i915_private *dev_priv = dev->dev_private;
- if (INTEL_INFO(dev)->num_pipes == 0)
+ if (INTEL_INFO(dev)->num_pipes == 0 || !dev_priv->fbdev)
return;
drm_modeset_lock_all(dev);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 09/10] port hotplug status live fix for VLV
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
` (6 preceding siblings ...)
2013-12-17 22:46 ` [PATCH 08/10] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v8 Jesse Barnes
@ 2013-12-17 22:47 ` Jesse Barnes
2013-12-17 22:47 ` [PATCH 10/10] convert to using crtc->fb for BIOS fb management Jesse Barnes
8 siblings, 0 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:47 UTC (permalink / raw)
To: intel-gfx
---
drivers/gpu/drm/i915/i915_reg.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 2d20390..f91cb12 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -2119,9 +2119,9 @@
* Please check the detailed lore in the commit message for for experimental
* evidence.
*/
-#define PORTD_HOTPLUG_LIVE_STATUS (1 << 29)
+#define PORTB_HOTPLUG_LIVE_STATUS (1 << 29)
#define PORTC_HOTPLUG_LIVE_STATUS (1 << 28)
-#define PORTB_HOTPLUG_LIVE_STATUS (1 << 27)
+#define PORTD_HOTPLUG_LIVE_STATUS (1 << 27)
#define PORTD_HOTPLUG_INT_STATUS (3 << 21)
#define PORTC_HOTPLUG_INT_STATUS (3 << 19)
#define PORTB_HOTPLUG_INT_STATUS (3 << 17)
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 10/10] convert to using crtc->fb for BIOS fb management
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
` (7 preceding siblings ...)
2013-12-17 22:47 ` [PATCH 09/10] port hotplug status live fix for VLV Jesse Barnes
@ 2013-12-17 22:47 ` Jesse Barnes
8 siblings, 0 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-17 22:47 UTC (permalink / raw)
To: intel-gfx
Along with refcounting changes and breakage.
---
drivers/gpu/drm/i915/i915_gem_stolen.c | 2 ++
drivers/gpu/drm/i915/intel_display.c | 39 ++++++++++++++++++----------------
drivers/gpu/drm/i915/intel_drv.h | 1 -
drivers/gpu/drm/i915/intel_fbdev.c | 19 ++++-------------
4 files changed, 27 insertions(+), 34 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c
index d284d89..c1625e6 100644
--- a/drivers/gpu/drm/i915/i915_gem_stolen.c
+++ b/drivers/gpu/drm/i915/i915_gem_stolen.c
@@ -420,6 +420,8 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev,
list_add_tail(&obj->global_list, &dev_priv->mm.bound_list);
list_add_tail(&vma->mm_list, &ggtt->inactive_list);
+ /* the vma also holds a pages reference */
+ i915_gem_object_pin_pages(obj);
return obj;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 97acb01..e5821a0 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5508,13 +5508,14 @@ static void i9xx_get_plane_config(struct intel_crtc *crtc,
struct drm_i915_private *dev_priv = dev->dev_private;
struct drm_i915_gem_object *obj = NULL;
struct drm_mode_fb_cmd2 mode_cmd = { 0 };
+ struct intel_framebuffer *fb;
u32 val, base, offset;
int pipe = crtc->pipe, plane = crtc->plane;
int fourcc, pixel_format;
int aligned_height;
- plane_config->fb = kzalloc(sizeof(*plane_config->fb), GFP_KERNEL);
- if (!plane_config->fb) {
+ fb = kzalloc(sizeof(*fb), GFP_KERNEL);
+ if (!fb) {
DRM_DEBUG_KMS("failed to alloc fb\n");
return;
}
@@ -5527,8 +5528,8 @@ static void i9xx_get_plane_config(struct intel_crtc *crtc,
pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
fourcc = intel_format_to_fourcc(pixel_format);
- plane_config->fb->base.pixel_format = fourcc;
- plane_config->fb->base.bits_per_pixel =
+ fb->base.pixel_format = fourcc;
+ fb->base.bits_per_pixel =
drm_format_plane_cpp(fourcc, 0) * 8;
if (INTEL_INFO(dev)->gen >= 4) {
@@ -5542,23 +5543,23 @@ static void i9xx_get_plane_config(struct intel_crtc *crtc,
}
val = I915_READ(PIPESRC(pipe));
- plane_config->fb->base.width = ((val >> 16) & 0xfff) + 1;
- plane_config->fb->base.height = ((val >> 0) & 0xfff) + 1;
+ fb->base.width = ((val >> 16) & 0xfff) + 1;
+ fb->base.height = ((val >> 0) & 0xfff) + 1;
val = I915_READ(DSPSTRIDE(pipe));
- plane_config->fb->base.pitches[0] = val & 0xffffff80;
+ fb->base.pitches[0] = val & 0xffffff80;
- aligned_height = intel_align_height(dev, plane_config->fb->base.height,
+ aligned_height = intel_align_height(dev, fb->base.height,
plane_config->tiled);
- plane_config->size = ALIGN(plane_config->fb->base.pitches[0] *
+ plane_config->size = ALIGN(fb->base.pitches[0] *
aligned_height, PAGE_SIZE);
DRM_DEBUG_KMS("pipe/plane %d/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
- pipe, plane, plane_config->fb->base.width,
- plane_config->fb->base.height,
- plane_config->fb->base.bits_per_pixel, base,
- plane_config->fb->base.pitches[0],
+ pipe, plane, fb->base.width,
+ fb->base.height,
+ fb->base.bits_per_pixel, base,
+ fb->base.pitches[0],
plane_config->size);
/*
@@ -5571,19 +5572,21 @@ static void i9xx_get_plane_config(struct intel_crtc *crtc,
return;
mode_cmd.pixel_format = fourcc;
- mode_cmd.width = plane_config->fb->base.width;
- mode_cmd.height = plane_config->fb->base.height;
- mode_cmd.pitches[0] = plane_config->fb->base.pitches[0];
+ mode_cmd.width = fb->base.width;
+ mode_cmd.height = fb->base.height;
+ mode_cmd.pitches[0] = fb->base.pitches[0];
mutex_lock(&dev->struct_mutex);
- if (intel_framebuffer_init(dev, plane_config->fb, &mode_cmd, obj)) {
+ if (intel_framebuffer_init(dev, fb, &mode_cmd, obj)) {
DRM_DEBUG_KMS("intel fb init failed\n");
goto out_unref_obj;
}
+ crtc->base.fb = &fb->base;
+
mutex_unlock(&dev->struct_mutex);
- DRM_DEBUG_KMS("plane fb obj %p\n", plane_config->fb->obj);
+ DRM_DEBUG_KMS("plane fb obj %p\n", fb->obj);
return;
out_unref_obj:
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index d849a5c..a40109e 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -211,7 +211,6 @@ typedef struct dpll {
} intel_clock_t;
struct intel_plane_config {
- struct intel_framebuffer *fb; /* ends up managed by intel_fbdev.c */
bool tiled;
int size;
};
diff --git a/drivers/gpu/drm/i915/intel_fbdev.c b/drivers/gpu/drm/i915/intel_fbdev.c
index a3e8156..2cbfe72 100644
--- a/drivers/gpu/drm/i915/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/intel_fbdev.c
@@ -388,7 +388,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
intel_crtc = to_intel_crtc(crtc);
- if (!intel_crtc->active || !intel_crtc->plane_config.fb) {
+ if (!intel_crtc->active || !crtc->fb) {
DRM_DEBUG_KMS("pipe %c not active or no fb, skipping\n",
pipe_name(intel_crtc->pipe));
continue;
@@ -397,27 +397,16 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
if (intel_crtc->plane_config.size > last_size) {
plane_config = &intel_crtc->plane_config;
last_size = plane_config->size;
- fb = plane_config->fb;
+ fb = to_intel_framebuffer(crtc->fb);
}
}
- /* Free unused fbs */
- list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
- struct intel_framebuffer *cur_fb;
-
- intel_crtc = to_intel_crtc(crtc);
- cur_fb = intel_crtc->plane_config.fb;
-
- if (cur_fb && cur_fb != fb)
- intel_framebuffer_fini(cur_fb);
- }
-
if (!fb) {
DRM_DEBUG_KMS("no active pipes found, not using BIOS config\n");
goto out_free;
}
- ifbdev->preferred_bpp = plane_config->fb->base.bits_per_pixel;
+ ifbdev->preferred_bpp = fb->base.bits_per_pixel;
ifbdev->helper.funcs = &intel_fb_helper_funcs;
ifbdev->helper.funcs->initial_config = intel_fb_initial_config;
ifbdev->fb = fb;
@@ -437,7 +426,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
goto out_unref_obj;
crtc->fb = &fb->base;
- drm_gem_object_reference(&fb->obj->base);
+ /* Take a private ref on the fb for fbdev */
drm_framebuffer_reference(&fb->base);
}
--
1.8.4.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 05/10] drm/i915: retrieve current fb config into new plane_config structure at init v8
2013-12-17 22:46 ` [PATCH 05/10] drm/i915: retrieve current fb config into new plane_config structure at init v8 Jesse Barnes
@ 2013-12-18 10:36 ` Jani Nikula
2013-12-18 16:14 ` Jesse Barnes
0 siblings, 1 reply; 12+ messages in thread
From: Jani Nikula @ 2013-12-18 10:36 UTC (permalink / raw)
To: Jesse Barnes, intel-gfx
On Wed, 18 Dec 2013, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
> Read out the current plane configuration at init time into a new
> plane_config structure. This allows us to track any existing
> framebuffers attached to the plane and potentially re-use them in our
> fbdev code for a smooth handoff.
>
> v2: update for new pitch_for_width function (Jesse)
> comment how get_plane_config works with shared fbs (Jesse)
> v3: s/ARGB/XRGB (Ville)
> use pipesrc width/height (Ville)
> fix fourcc comment (Bob)
> use drm_format_plane_cpp (Ville)
> v4: use fb for tracking fb data object (Ville)
> v5: fix up gen2 pitch limits (Ville)
> v6: read out stride as well (Daniel)
> v7: split out init ordering changes (Daniel)
> don't fetch config if !CONFIG_FB
> v8: use proper height in get_plane_config (Chris)
>
> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 3 +
> drivers/gpu/drm/i915/intel_display.c | 130 +++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/i915/intel_drv.h | 8 +++
> 3 files changed, 141 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index efc57fe..2ea151d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -366,6 +366,7 @@ struct drm_i915_error_state {
>
> struct intel_connector;
> struct intel_crtc_config;
> +struct intel_plane_config;
> struct intel_crtc;
> struct intel_limit;
> struct dpll;
> @@ -404,6 +405,8 @@ struct drm_i915_display_funcs {
> * fills out the pipe-config with the hw state. */
> bool (*get_pipe_config)(struct intel_crtc *,
> struct intel_crtc_config *);
> + void (*get_plane_config)(struct intel_crtc *,
> + struct intel_plane_config *);
> int (*crtc_mode_set)(struct drm_crtc *crtc,
> int x, int y,
> struct drm_framebuffer *old_fb);
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 367d64d..6c38d03 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -2025,6 +2025,27 @@ unsigned long intel_gen4_compute_page_offset(int *x, int *y,
> }
> }
>
> +int intel_format_to_fourcc(int format)
> +{
> + switch (format) {
> + case DISPPLANE_8BPP:
> + return DRM_FORMAT_C8;
> + case DISPPLANE_BGRX555:
> + return DRM_FORMAT_XRGB1555;
> + case DISPPLANE_BGRX565:
> + return DRM_FORMAT_RGB565;
> + default:
> + case DISPPLANE_BGRX888:
> + return DRM_FORMAT_XRGB8888;
> + case DISPPLANE_RGBX888:
> + return DRM_FORMAT_XBGR8888;
> + case DISPPLANE_BGRX101010:
> + return DRM_FORMAT_XRGB2101010;
> + case DISPPLANE_RGBX101010:
> + return DRM_FORMAT_XBGR2101010;
> + }
> +}
> +
> static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
> int x, int y)
> {
> @@ -5480,6 +5501,96 @@ static void vlv_crtc_clock_get(struct intel_crtc *crtc,
> pipe_config->port_clock = clock.dot / 5;
> }
>
> +static void i9xx_get_plane_config(struct intel_crtc *crtc,
> + struct intel_plane_config *plane_config)
> +{
> + struct drm_device *dev = crtc->base.dev;
> + struct drm_i915_private *dev_priv = dev->dev_private;
> + struct drm_i915_gem_object *obj = NULL;
> + struct drm_mode_fb_cmd2 mode_cmd = { 0 };
> + u32 val, base, offset;
> + int pipe = crtc->pipe, plane = crtc->plane;
> + int fourcc, pixel_format;
> + int aligned_height;
> +
> + plane_config->fb = kzalloc(sizeof(*plane_config->fb), GFP_KERNEL);
> + if (!plane_config->fb) {
> + DRM_DEBUG_KMS("failed to alloc fb\n");
> + return;
> + }
> +
> + val = I915_READ(DSPCNTR(plane));
> +
> + if (INTEL_INFO(dev)->gen >= 4)
> + if (val & DISPPLANE_TILED)
> + plane_config->tiled = true;
> +
> + pixel_format = val & DISPPLANE_PIXFORMAT_MASK;
> + fourcc = intel_format_to_fourcc(pixel_format);
> + plane_config->fb->base.pixel_format = fourcc;
> + plane_config->fb->base.bits_per_pixel =
> + drm_format_plane_cpp(fourcc, 0) * 8;
> +
> + if (INTEL_INFO(dev)->gen >= 4) {
> + if (plane_config->tiled)
> + offset = I915_READ(DSPTILEOFF(plane));
> + else
> + offset = I915_READ(DSPLINOFF(plane));
> + base = I915_READ(DSPSURF(plane)) & 0xfffff000;
> + } else {
> + base = I915_READ(DSPADDR(plane));
> + }
> +
> + val = I915_READ(PIPESRC(pipe));
> + plane_config->fb->base.width = ((val >> 16) & 0xfff) + 1;
> + plane_config->fb->base.height = ((val >> 0) & 0xfff) + 1;
> +
> + val = I915_READ(DSPSTRIDE(pipe));
> + plane_config->fb->base.pitches[0] = val & 0xffffff80;
> +
> + aligned_height = intel_align_height(dev, plane_config->fb->base.height,
> + plane_config->tiled);
> +
> + plane_config->size = ALIGN(plane_config->fb->base.pitches[0] *
> + aligned_height, PAGE_SIZE);
> +
> + DRM_DEBUG_KMS("pipe/plane %d/%d with fb: size=%dx%d@%d, offset=%x, pitch %d, size 0x%x\n",
> + pipe, plane, plane_config->fb->base.width,
> + plane_config->fb->base.height,
> + plane_config->fb->base.bits_per_pixel, base,
> + plane_config->fb->base.pitches[0],
> + plane_config->size);
> +
> + /*
> + * If the fb is shared between multiple heads, we'll just get the
> + * first one.
> + */
> + obj = i915_gem_object_create_stolen_for_preallocated(dev, base, base,
> + plane_config->size);
> + if (!obj)
> + return;
> +
> + mode_cmd.pixel_format = fourcc;
> + mode_cmd.width = plane_config->fb->base.width;
> + mode_cmd.height = plane_config->fb->base.height;
> + mode_cmd.pitches[0] = plane_config->fb->base.pitches[0];
> +
> + mutex_lock(&dev->struct_mutex);
> +
> + if (intel_framebuffer_init(dev, plane_config->fb, &mode_cmd, obj)) {
> + DRM_DEBUG_KMS("intel fb init failed\n");
> + goto out_unref_obj;
> + }
> +
> + mutex_unlock(&dev->struct_mutex);
> + DRM_DEBUG_KMS("plane fb obj %p\n", plane_config->fb->obj);
> + return;
> +
> +out_unref_obj:
> + drm_gem_object_unreference(&obj->base);
> + mutex_unlock(&dev->struct_mutex);
> +}
> +
> static bool i9xx_get_pipe_config(struct intel_crtc *crtc,
> struct intel_crtc_config *pipe_config)
> {
> @@ -10569,6 +10680,7 @@ static void intel_init_display(struct drm_device *dev)
> dev_priv->display.update_plane = ironlake_update_plane;
> } else if (IS_VALLEYVIEW(dev)) {
> dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
> + dev_priv->display.get_plane_config = i9xx_get_plane_config;
> dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
> dev_priv->display.crtc_enable = valleyview_crtc_enable;
> dev_priv->display.crtc_disable = i9xx_crtc_disable;
> @@ -10576,6 +10688,7 @@ static void intel_init_display(struct drm_device *dev)
> dev_priv->display.update_plane = i9xx_update_plane;
> } else {
> dev_priv->display.get_pipe_config = i9xx_get_pipe_config;
> + dev_priv->display.get_plane_config = i9xx_get_plane_config;
> dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set;
> dev_priv->display.crtc_enable = i9xx_crtc_enable;
> dev_priv->display.crtc_disable = i9xx_crtc_disable;
> @@ -10830,6 +10943,7 @@ void intel_modeset_suspend_hw(struct drm_device *dev)
> void intel_modeset_init(struct drm_device *dev)
> {
> struct drm_i915_private *dev_priv = dev->dev_private;
> + struct intel_crtc *crtc;
> int i, j, ret;
>
> drm_mode_config_init(dev);
> @@ -10894,6 +11008,22 @@ void intel_modeset_init(struct drm_device *dev)
> drm_mode_config_reset(dev);
> intel_modeset_setup_hw_state(dev, false);
> drm_modeset_unlock_all(dev);
> +
> + list_for_each_entry(crtc, &dev->mode_config.crtc_list,
> + base.head) {
> + if (!crtc->active)
> + continue;
> +
> +#ifdef CONFIG_FB
Déjà vu, I just told Daniel the same thing:
#if IS_ENABLED(CONFIG_FB)
if you want this to work for CONFIG_FB=m too.
BR,
Jani.
> + /*
> + * We don't have a good way of freeing the buffer w/o the FB
> + * layer owning it...
> + */
> + if (dev_priv->display.get_plane_config)
> + dev_priv->display.get_plane_config(crtc,
> + &crtc->plane_config);
> +#endif
> + }
> }
>
> static void
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index ea62673..4787773 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -209,6 +209,12 @@ typedef struct dpll {
> int p;
> } intel_clock_t;
>
> +struct intel_plane_config {
> + struct intel_framebuffer *fb; /* ends up managed by intel_fbdev.c */
> + bool tiled;
> + int size;
> +};
> +
> struct intel_crtc_config {
> /**
> * quirks - bitfield with hw state readout quirks
> @@ -358,6 +364,7 @@ struct intel_crtc {
> bool cursor_visible;
>
> struct intel_crtc_config config;
> + struct intel_plane_config plane_config;
>
> uint32_t ddi_pll_sel;
>
> @@ -707,6 +714,7 @@ void hsw_enable_ips(struct intel_crtc *crtc);
> void hsw_disable_ips(struct intel_crtc *crtc);
> void intel_display_set_init_power(struct drm_device *dev, bool enable);
> int valleyview_get_vco(struct drm_i915_private *dev_priv);
> +int intel_format_to_fourcc(int format);
>
> /* intel_dp.c */
> void intel_dp_init(struct drm_device *dev, int output_reg, enum port port);
> --
> 1.8.4.2
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 05/10] drm/i915: retrieve current fb config into new plane_config structure at init v8
2013-12-18 10:36 ` Jani Nikula
@ 2013-12-18 16:14 ` Jesse Barnes
0 siblings, 0 replies; 12+ messages in thread
From: Jesse Barnes @ 2013-12-18 16:14 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx
On Wed, 18 Dec 2013 12:36:14 +0200
Jani Nikula <jani.nikula@linux.intel.com> wrote:
> > + continue;
> > +
> > +#ifdef CONFIG_FB
>
> Déjà vu, I just told Daniel the same thing:
>
> #if IS_ENABLED(CONFIG_FB)
>
> if you want this to work for CONFIG_FB=m too.
Ah yeah I even knew that when I was writing it... will fix.
--
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-12-18 16:12 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-17 22:46 [PATCH 01/10] drm/i915/vlv: add early DPIO init v3 Jesse Barnes
2013-12-17 22:46 ` [PATCH 02/10] drm/i915/vlv: split DPIO init and reset Jesse Barnes
2013-12-17 22:46 ` [PATCH 03/10] drm/i915: read out hw state earlier Jesse Barnes
2013-12-17 22:46 ` [PATCH 04/10] drm/i915: split aligned height calculation out Jesse Barnes
2013-12-17 22:46 ` [PATCH 05/10] drm/i915: retrieve current fb config into new plane_config structure at init v8 Jesse Barnes
2013-12-18 10:36 ` Jani Nikula
2013-12-18 16:14 ` Jesse Barnes
2013-12-17 22:46 ` [PATCH 06/10] drm/i915: alloc intel_fb in the intel_fbdev struct Jesse Barnes
2013-12-17 22:46 ` [PATCH 07/10] drm/i915: allow re-use BIOS connector config for initial fbdev config Jesse Barnes
2013-12-17 22:46 ` [PATCH 08/10] drm/i915: Wrap the preallocated BIOS framebuffer and preserve for KMS fbcon v8 Jesse Barnes
2013-12-17 22:47 ` [PATCH 09/10] port hotplug status live fix for VLV Jesse Barnes
2013-12-17 22:47 ` [PATCH 10/10] convert to using crtc->fb for BIOS fb management Jesse Barnes
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.