Commit 435b3e7e authored by Imre Deak's avatar Imre Deak

drm/i915/intel_fb: Factor out calc_plane_aligned_offset()

Factor out to a new function the logic to convert the FB plane x/y
values to a tile size based offset and new x/y relative to this offset.
This makes intel_fill_fb_info() and intel_plane_remap_gtt() somewhat
more readable.
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210325214808.2071517-15-imre.deak@intel.com
parent d3c5e10b
...@@ -558,6 +558,20 @@ static int convert_plane_offset_to_xy(const struct intel_framebuffer *fb, int co ...@@ -558,6 +558,20 @@ static int convert_plane_offset_to_xy(const struct intel_framebuffer *fb, int co
return 0; return 0;
} }
static u32 calc_plane_aligned_offset(const struct intel_framebuffer *fb, int color_plane, int *x, int *y)
{
struct drm_i915_private *i915 = to_i915(fb->base.dev);
unsigned int tile_size = intel_tile_size(i915);
u32 offset;
offset = intel_compute_aligned_offset(i915, x, y, &fb->base, color_plane,
fb->base.pitches[color_plane],
DRM_MODE_ROTATE_0,
tile_size);
return offset / tile_size;
}
/* /*
* Setup the rotated view for an FB plane and return the size the GTT mapping * Setup the rotated view for an FB plane and return the size the GTT mapping
* requires for this view. * requires for this view.
...@@ -660,11 +674,7 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb ...@@ -660,11 +674,7 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct drm_framebuffer *fb
intel_fb->normal[i].x = x; intel_fb->normal[i].x = x;
intel_fb->normal[i].y = y; intel_fb->normal[i].y = y;
offset = intel_compute_aligned_offset(i915, &x, &y, fb, i, offset = calc_plane_aligned_offset(intel_fb, i, &x, &y);
fb->pitches[i],
DRM_MODE_ROTATE_0,
tile_size);
offset /= tile_size;
if (!is_surface_linear(fb, i)) { if (!is_surface_linear(fb, i)) {
struct intel_remapped_plane_info plane_info; struct intel_remapped_plane_info plane_info;
...@@ -773,10 +783,7 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state) ...@@ -773,10 +783,7 @@ static void intel_plane_remap_gtt(struct intel_plane_state *plane_state)
x += intel_fb->normal[i].x; x += intel_fb->normal[i].x;
y += intel_fb->normal[i].y; y += intel_fb->normal[i].y;
offset = intel_compute_aligned_offset(i915, &x, &y, offset = calc_plane_aligned_offset(intel_fb, i, &x, &y);
fb, i, fb->pitches[i],
DRM_MODE_ROTATE_0, tile_size);
offset /= tile_size;
drm_WARN_ON(&i915->drm, i >= ARRAY_SIZE(info->plane)); drm_WARN_ON(&i915->drm, i >= ARRAY_SIZE(info->plane));
info->plane[i].offset = offset; info->plane[i].offset = offset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment