drm/i915: Redo intel_tile_height() as intel_tile_size() / intel_tile_width()
I find more usual to think about tile widths than heights, so changing the intel_tile_height() to calculate the tile height as tile_size/tile_width is easier than the opposite to the poor brain. v2: Reorder arguments for consistency Constify dev_priv arguments Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1452625717-9713-4-git-send-email-ville.syrjala@linux.intel.com
This commit is contained in:
parent
7b49f94839
commit
832be82f87
@ -2223,6 +2223,11 @@ static bool need_vtd_wa(struct drm_device *dev)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned int intel_tile_size(const struct drm_i915_private *dev_priv)
|
||||||
|
{
|
||||||
|
return IS_GEN2(dev_priv) ? 2048 : 4096;
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned int intel_tile_width(const struct drm_i915_private *dev_priv,
|
static unsigned int intel_tile_width(const struct drm_i915_private *dev_priv,
|
||||||
uint64_t fb_modifier, unsigned int cpp)
|
uint64_t fb_modifier, unsigned int cpp)
|
||||||
{
|
{
|
||||||
@ -2260,67 +2265,34 @@ static unsigned int intel_tile_width(const struct drm_i915_private *dev_priv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int intel_tile_height(const struct drm_i915_private *dev_priv,
|
||||||
intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
|
uint64_t fb_modifier, unsigned int cpp)
|
||||||
uint64_t fb_format_modifier, unsigned int plane)
|
|
||||||
{
|
{
|
||||||
unsigned int tile_height;
|
if (fb_modifier == DRM_FORMAT_MOD_NONE)
|
||||||
uint32_t pixel_bytes;
|
return 1;
|
||||||
|
else
|
||||||
switch (fb_format_modifier) {
|
return intel_tile_size(dev_priv) /
|
||||||
case DRM_FORMAT_MOD_NONE:
|
intel_tile_width(dev_priv, fb_modifier, cpp);
|
||||||
tile_height = 1;
|
|
||||||
break;
|
|
||||||
case I915_FORMAT_MOD_X_TILED:
|
|
||||||
tile_height = IS_GEN2(dev) ? 16 : 8;
|
|
||||||
break;
|
|
||||||
case I915_FORMAT_MOD_Y_TILED:
|
|
||||||
tile_height = 32;
|
|
||||||
break;
|
|
||||||
case I915_FORMAT_MOD_Yf_TILED:
|
|
||||||
pixel_bytes = drm_format_plane_cpp(pixel_format, plane);
|
|
||||||
switch (pixel_bytes) {
|
|
||||||
default:
|
|
||||||
case 1:
|
|
||||||
tile_height = 64;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
case 4:
|
|
||||||
tile_height = 32;
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
tile_height = 16;
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
WARN_ONCE(1,
|
|
||||||
"128-bit pixels are not supported for display!");
|
|
||||||
tile_height = 16;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
MISSING_CASE(fb_format_modifier);
|
|
||||||
tile_height = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tile_height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
intel_fb_align_height(struct drm_device *dev, unsigned int height,
|
intel_fb_align_height(struct drm_device *dev, unsigned int height,
|
||||||
uint32_t pixel_format, uint64_t fb_format_modifier)
|
uint32_t pixel_format, uint64_t fb_modifier)
|
||||||
{
|
{
|
||||||
return ALIGN(height, intel_tile_height(dev, pixel_format,
|
unsigned int cpp = drm_format_plane_cpp(pixel_format, 0);
|
||||||
fb_format_modifier, 0));
|
unsigned int tile_height = intel_tile_height(to_i915(dev), fb_modifier, cpp);
|
||||||
|
|
||||||
|
return ALIGN(height, tile_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb,
|
intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb,
|
||||||
const struct drm_plane_state *plane_state)
|
const struct drm_plane_state *plane_state)
|
||||||
{
|
{
|
||||||
|
struct drm_i915_private *dev_priv = to_i915(fb->dev);
|
||||||
struct intel_rotation_info *info = &view->params.rotation_info;
|
struct intel_rotation_info *info = &view->params.rotation_info;
|
||||||
unsigned int tile_height, tile_pitch;
|
unsigned int tile_height, tile_pitch;
|
||||||
|
unsigned int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
|
||||||
|
|
||||||
*view = i915_ggtt_view_normal;
|
*view = i915_ggtt_view_normal;
|
||||||
|
|
||||||
@ -2338,22 +2310,19 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb,
|
|||||||
info->uv_offset = fb->offsets[1];
|
info->uv_offset = fb->offsets[1];
|
||||||
info->fb_modifier = fb->modifier[0];
|
info->fb_modifier = fb->modifier[0];
|
||||||
|
|
||||||
tile_height = intel_tile_height(fb->dev, fb->pixel_format,
|
tile_height = intel_tile_height(dev_priv, fb->modifier[0], cpp);
|
||||||
fb->modifier[0], 0);
|
|
||||||
tile_pitch = PAGE_SIZE / tile_height;
|
tile_pitch = PAGE_SIZE / tile_height;
|
||||||
info->width_pages = DIV_ROUND_UP(fb->pitches[0], tile_pitch);
|
info->width_pages = DIV_ROUND_UP(fb->pitches[0], tile_pitch);
|
||||||
info->height_pages = DIV_ROUND_UP(fb->height, tile_height);
|
info->height_pages = DIV_ROUND_UP(fb->height, tile_height);
|
||||||
info->size = info->width_pages * info->height_pages * PAGE_SIZE;
|
info->size = info->width_pages * info->height_pages * PAGE_SIZE;
|
||||||
|
|
||||||
if (info->pixel_format == DRM_FORMAT_NV12) {
|
if (info->pixel_format == DRM_FORMAT_NV12) {
|
||||||
tile_height = intel_tile_height(fb->dev, fb->pixel_format,
|
cpp = drm_format_plane_cpp(fb->pixel_format, 1);
|
||||||
fb->modifier[0], 1);
|
tile_height = intel_tile_height(dev_priv, fb->modifier[1], cpp);
|
||||||
tile_pitch = PAGE_SIZE / tile_height;
|
tile_pitch = PAGE_SIZE / tile_height;
|
||||||
info->width_pages_uv = DIV_ROUND_UP(fb->pitches[0], tile_pitch);
|
info->width_pages_uv = DIV_ROUND_UP(fb->pitches[1], tile_pitch);
|
||||||
info->height_pages_uv = DIV_ROUND_UP(fb->height / 2,
|
info->height_pages_uv = DIV_ROUND_UP(fb->height / 2, tile_height);
|
||||||
tile_height);
|
info->size_uv = info->width_pages_uv * info->height_pages_uv * PAGE_SIZE;
|
||||||
info->size_uv = info->width_pages_uv * info->height_pages_uv *
|
|
||||||
PAGE_SIZE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3140,9 +3109,10 @@ static void skylake_update_primary_plane(struct drm_plane *plane,
|
|||||||
WARN_ON(drm_rect_width(&plane_state->src) == 0);
|
WARN_ON(drm_rect_width(&plane_state->src) == 0);
|
||||||
|
|
||||||
if (intel_rotation_90_or_270(rotation)) {
|
if (intel_rotation_90_or_270(rotation)) {
|
||||||
|
int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
|
||||||
|
|
||||||
/* stride = Surface height in tiles */
|
/* stride = Surface height in tiles */
|
||||||
tile_height = intel_tile_height(dev, fb->pixel_format,
|
tile_height = intel_tile_height(dev_priv, fb->modifier[0], cpp);
|
||||||
fb->modifier[0], 0);
|
|
||||||
stride = DIV_ROUND_UP(fb->height, tile_height);
|
stride = DIV_ROUND_UP(fb->height, tile_height);
|
||||||
x_offset = stride * tile_height - src_y - src_h;
|
x_offset = stride * tile_height - src_y - src_h;
|
||||||
y_offset = src_x;
|
y_offset = src_x;
|
||||||
@ -11401,8 +11371,7 @@ static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
|
|||||||
*/
|
*/
|
||||||
if (intel_rotation_90_or_270(rotation)) {
|
if (intel_rotation_90_or_270(rotation)) {
|
||||||
/* stride = Surface height in tiles */
|
/* stride = Surface height in tiles */
|
||||||
tile_height = intel_tile_height(dev, fb->pixel_format,
|
tile_height = intel_tile_height(dev_priv, fb->modifier[0], 0);
|
||||||
fb->modifier[0], 0);
|
|
||||||
stride = DIV_ROUND_UP(fb->height, tile_height);
|
stride = DIV_ROUND_UP(fb->height, tile_height);
|
||||||
} else {
|
} else {
|
||||||
stride = fb->pitches[0] /
|
stride = fb->pitches[0] /
|
||||||
|
@ -1155,9 +1155,8 @@ int intel_plane_atomic_set_property(struct drm_plane *plane,
|
|||||||
int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
|
int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
|
||||||
struct drm_plane_state *plane_state);
|
struct drm_plane_state *plane_state);
|
||||||
|
|
||||||
unsigned int
|
unsigned int intel_tile_height(const struct drm_i915_private *dev_priv,
|
||||||
intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
|
uint64_t fb_modifier, unsigned int cpp);
|
||||||
uint64_t fb_format_modifier, unsigned int plane);
|
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
intel_rotation_90_or_270(unsigned int rotation)
|
intel_rotation_90_or_270(unsigned int rotation)
|
||||||
|
@ -239,9 +239,10 @@ skl_update_plane(struct drm_plane *drm_plane,
|
|||||||
surf_addr = intel_plane_obj_offset(intel_plane, obj, 0);
|
surf_addr = intel_plane_obj_offset(intel_plane, obj, 0);
|
||||||
|
|
||||||
if (intel_rotation_90_or_270(rotation)) {
|
if (intel_rotation_90_or_270(rotation)) {
|
||||||
|
int cpp = drm_format_plane_cpp(fb->pixel_format, 0);
|
||||||
|
|
||||||
/* stride: Surface height in tiles */
|
/* stride: Surface height in tiles */
|
||||||
tile_height = intel_tile_height(dev, fb->pixel_format,
|
tile_height = intel_tile_height(dev_priv, fb->modifier[0], cpp);
|
||||||
fb->modifier[0], 0);
|
|
||||||
stride = DIV_ROUND_UP(fb->height, tile_height);
|
stride = DIV_ROUND_UP(fb->height, tile_height);
|
||||||
plane_size = (src_w << 16) | src_h;
|
plane_size = (src_w << 16) | src_h;
|
||||||
x_offset = stride * tile_height - y - (src_h + 1);
|
x_offset = stride * tile_height - y - (src_h + 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user