mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 12:03:54 +02:00
drm/i915: Clean up intel_fbdev_init_bios() a bit
Sort out the mess with the local variables in intel_fbdev_init_bios(). Get rid of all aliasing pointers, use standard naming/types, and introduce a few more locals in the loops to avoid the hard to read long struct walks. While at we also polish the debugs a bit to use the canonical [CRTC:%d:%s] style. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210609085632.22026-6-ville.syrjala@linux.intel.com Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
This commit is contained in:
parent
670c89eb6d
commit
08dfd243ab
|
|
@ -310,32 +310,43 @@ static void intel_fbdev_destroy(struct intel_fbdev *ifbdev)
|
||||||
* fbcon), so we just find the biggest and use that.
|
* fbcon), so we just find the biggest and use that.
|
||||||
*/
|
*/
|
||||||
static bool intel_fbdev_init_bios(struct drm_device *dev,
|
static bool intel_fbdev_init_bios(struct drm_device *dev,
|
||||||
struct intel_fbdev *ifbdev)
|
struct intel_fbdev *ifbdev)
|
||||||
{
|
{
|
||||||
struct drm_i915_private *i915 = to_i915(dev);
|
struct drm_i915_private *i915 = to_i915(dev);
|
||||||
struct intel_framebuffer *fb = NULL;
|
struct intel_framebuffer *fb = NULL;
|
||||||
struct drm_crtc *crtc;
|
struct intel_crtc *crtc;
|
||||||
struct intel_crtc *intel_crtc;
|
|
||||||
unsigned int max_size = 0;
|
unsigned int max_size = 0;
|
||||||
|
|
||||||
/* Find the largest fb */
|
/* Find the largest fb */
|
||||||
for_each_crtc(dev, crtc) {
|
for_each_intel_crtc(dev, crtc) {
|
||||||
|
struct intel_crtc_state *crtc_state =
|
||||||
|
to_intel_crtc_state(crtc->base.state);
|
||||||
|
struct intel_plane *plane =
|
||||||
|
to_intel_plane(crtc->base.primary);
|
||||||
|
struct intel_plane_state *plane_state =
|
||||||
|
to_intel_plane_state(plane->base.state);
|
||||||
struct drm_i915_gem_object *obj =
|
struct drm_i915_gem_object *obj =
|
||||||
intel_fb_obj(crtc->primary->state->fb);
|
intel_fb_obj(plane_state->uapi.fb);
|
||||||
intel_crtc = to_intel_crtc(crtc);
|
|
||||||
|
|
||||||
if (!crtc->state->active || !obj) {
|
if (!crtc_state->uapi.active) {
|
||||||
drm_dbg_kms(&i915->drm,
|
drm_dbg_kms(&i915->drm,
|
||||||
"pipe %c not active or no fb, skipping\n",
|
"[CRTC:%d:%s] not active, skipping\n",
|
||||||
pipe_name(intel_crtc->pipe));
|
crtc->base.base.id, crtc->base.name);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!obj) {
|
||||||
|
drm_dbg_kms(&i915->drm,
|
||||||
|
"[PLANE:%d:%s] no fb, skipping\n",
|
||||||
|
plane->base.base.id, plane->base.name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj->base.size > max_size) {
|
if (obj->base.size > max_size) {
|
||||||
drm_dbg_kms(&i915->drm,
|
drm_dbg_kms(&i915->drm,
|
||||||
"found possible fb from plane %c\n",
|
"found possible fb from [PLANE:%d:%s]\n",
|
||||||
pipe_name(intel_crtc->pipe));
|
plane->base.base.id, plane->base.name);
|
||||||
fb = to_intel_framebuffer(crtc->primary->state->fb);
|
fb = to_intel_framebuffer(plane_state->uapi.fb);
|
||||||
max_size = obj->base.size;
|
max_size = obj->base.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -347,60 +358,62 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now make sure all the pipes will fit into it */
|
/* Now make sure all the pipes will fit into it */
|
||||||
for_each_crtc(dev, crtc) {
|
for_each_intel_crtc(dev, crtc) {
|
||||||
|
struct intel_crtc_state *crtc_state =
|
||||||
|
to_intel_crtc_state(crtc->base.state);
|
||||||
|
struct intel_plane *plane =
|
||||||
|
to_intel_plane(crtc->base.primary);
|
||||||
unsigned int cur_size;
|
unsigned int cur_size;
|
||||||
|
|
||||||
intel_crtc = to_intel_crtc(crtc);
|
if (!crtc_state->uapi.active) {
|
||||||
|
|
||||||
if (!crtc->state->active) {
|
|
||||||
drm_dbg_kms(&i915->drm,
|
drm_dbg_kms(&i915->drm,
|
||||||
"pipe %c not active, skipping\n",
|
"[CRTC:%d:%s] not active, skipping\n",
|
||||||
pipe_name(intel_crtc->pipe));
|
crtc->base.base.id, crtc->base.name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_dbg_kms(&i915->drm, "checking plane %c for BIOS fb\n",
|
drm_dbg_kms(&i915->drm, "checking [PLANE:%d:%s] for BIOS fb\n",
|
||||||
pipe_name(intel_crtc->pipe));
|
plane->base.base.id, plane->base.name);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See if the plane fb we found above will fit on this
|
* See if the plane fb we found above will fit on this
|
||||||
* pipe. Note we need to use the selected fb's pitch and bpp
|
* pipe. Note we need to use the selected fb's pitch and bpp
|
||||||
* rather than the current pipe's, since they differ.
|
* rather than the current pipe's, since they differ.
|
||||||
*/
|
*/
|
||||||
cur_size = crtc->state->adjusted_mode.crtc_hdisplay;
|
cur_size = crtc_state->uapi.adjusted_mode.crtc_hdisplay;
|
||||||
cur_size = cur_size * fb->base.format->cpp[0];
|
cur_size = cur_size * fb->base.format->cpp[0];
|
||||||
if (fb->base.pitches[0] < cur_size) {
|
if (fb->base.pitches[0] < cur_size) {
|
||||||
drm_dbg_kms(&i915->drm,
|
drm_dbg_kms(&i915->drm,
|
||||||
"fb not wide enough for plane %c (%d vs %d)\n",
|
"fb not wide enough for [PLANE:%d:%s] (%d vs %d)\n",
|
||||||
pipe_name(intel_crtc->pipe),
|
plane->base.base.id, plane->base.name,
|
||||||
cur_size, fb->base.pitches[0]);
|
cur_size, fb->base.pitches[0]);
|
||||||
fb = NULL;
|
fb = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_size = crtc->state->adjusted_mode.crtc_vdisplay;
|
cur_size = crtc_state->uapi.adjusted_mode.crtc_vdisplay;
|
||||||
cur_size = intel_fb_align_height(&fb->base, 0, cur_size);
|
cur_size = intel_fb_align_height(&fb->base, 0, cur_size);
|
||||||
cur_size *= fb->base.pitches[0];
|
cur_size *= fb->base.pitches[0];
|
||||||
drm_dbg_kms(&i915->drm,
|
drm_dbg_kms(&i915->drm,
|
||||||
"pipe %c area: %dx%d, bpp: %d, size: %d\n",
|
"[CRTC:%d:%s] area: %dx%d, bpp: %d, size: %d\n",
|
||||||
pipe_name(intel_crtc->pipe),
|
crtc->base.base.id, crtc->base.name,
|
||||||
crtc->state->adjusted_mode.crtc_hdisplay,
|
crtc_state->uapi.adjusted_mode.crtc_hdisplay,
|
||||||
crtc->state->adjusted_mode.crtc_vdisplay,
|
crtc_state->uapi.adjusted_mode.crtc_vdisplay,
|
||||||
fb->base.format->cpp[0] * 8,
|
fb->base.format->cpp[0] * 8,
|
||||||
cur_size);
|
cur_size);
|
||||||
|
|
||||||
if (cur_size > max_size) {
|
if (cur_size > max_size) {
|
||||||
drm_dbg_kms(&i915->drm,
|
drm_dbg_kms(&i915->drm,
|
||||||
"fb not big enough for plane %c (%d vs %d)\n",
|
"fb not big enough for [PLANE:%d:%s] (%d vs %d)\n",
|
||||||
pipe_name(intel_crtc->pipe),
|
plane->base.base.id, plane->base.name,
|
||||||
cur_size, max_size);
|
cur_size, max_size);
|
||||||
fb = NULL;
|
fb = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
drm_dbg_kms(&i915->drm,
|
drm_dbg_kms(&i915->drm,
|
||||||
"fb big enough for plane %c (%d >= %d)\n",
|
"fb big enough [PLANE:%d:%s] (%d >= %d)\n",
|
||||||
pipe_name(intel_crtc->pipe),
|
plane->base.base.id, plane->base.name,
|
||||||
max_size, cur_size);
|
max_size, cur_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,15 +429,20 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
|
||||||
drm_framebuffer_get(&ifbdev->fb->base);
|
drm_framebuffer_get(&ifbdev->fb->base);
|
||||||
|
|
||||||
/* Final pass to check if any active pipes don't have fbs */
|
/* Final pass to check if any active pipes don't have fbs */
|
||||||
for_each_crtc(dev, crtc) {
|
for_each_intel_crtc(dev, crtc) {
|
||||||
intel_crtc = to_intel_crtc(crtc);
|
struct intel_crtc_state *crtc_state =
|
||||||
|
to_intel_crtc_state(crtc->base.state);
|
||||||
|
struct intel_plane *plane =
|
||||||
|
to_intel_plane(crtc->base.primary);
|
||||||
|
struct intel_plane_state *plane_state =
|
||||||
|
to_intel_plane_state(plane->base.state);
|
||||||
|
|
||||||
if (!crtc->state->active)
|
if (!crtc_state->uapi.active)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
drm_WARN(dev, !crtc->primary->state->fb,
|
drm_WARN(dev, !plane_state->uapi.fb,
|
||||||
"re-used BIOS config but lost an fb on crtc %d\n",
|
"re-used BIOS config but lost an fb on [PLANE:%d:%s]\n",
|
||||||
crtc->base.id);
|
plane->base.base.id, plane->base.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user