diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2016-01-12 14:08:33 -0500 |
---|---|---|
committer | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2016-01-13 11:46:29 -0500 |
commit | 832be82f87c2bf711d8d7aaeb59da925b4573f6c (patch) | |
tree | 1a3c63f5b4e205a5e2948518e0182e618fb41513 | |
parent | 7b49f94839660a82f1f40ee95cfe70245b4444d7 (diff) |
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
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 89 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_drv.h | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_sprite.c | 5 |
3 files changed, 34 insertions, 65 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index d86e47a9cf6f..9c20c2ee742f 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -2223,6 +2223,11 @@ static bool need_vtd_wa(struct drm_device *dev) | |||
2223 | return false; | 2223 | return false; |
2224 | } | 2224 | } |
2225 | 2225 | ||
2226 | static unsigned int intel_tile_size(const struct drm_i915_private *dev_priv) | ||
2227 | { | ||
2228 | return IS_GEN2(dev_priv) ? 2048 : 4096; | ||
2229 | } | ||
2230 | |||
2226 | static unsigned int intel_tile_width(const struct drm_i915_private *dev_priv, | 2231 | static unsigned int intel_tile_width(const struct drm_i915_private *dev_priv, |
2227 | uint64_t fb_modifier, unsigned int cpp) | 2232 | uint64_t fb_modifier, unsigned int cpp) |
2228 | { | 2233 | { |
@@ -2260,67 +2265,34 @@ static unsigned int intel_tile_width(const struct drm_i915_private *dev_priv, | |||
2260 | } | 2265 | } |
2261 | } | 2266 | } |
2262 | 2267 | ||
2263 | unsigned int | 2268 | unsigned int intel_tile_height(const struct drm_i915_private *dev_priv, |
2264 | intel_tile_height(struct drm_device *dev, uint32_t pixel_format, | 2269 | uint64_t fb_modifier, unsigned int cpp) |
2265 | uint64_t fb_format_modifier, unsigned int plane) | ||
2266 | { | 2270 | { |
2267 | unsigned int tile_height; | 2271 | if (fb_modifier == DRM_FORMAT_MOD_NONE) |
2268 | uint32_t pixel_bytes; | 2272 | return 1; |
2269 | 2273 | else | |
2270 | switch (fb_format_modifier) { | 2274 | return intel_tile_size(dev_priv) / |
2271 | case DRM_FORMAT_MOD_NONE: | 2275 | intel_tile_width(dev_priv, fb_modifier, cpp); |
2272 | tile_height = 1; | ||
2273 | break; | ||
2274 | case I915_FORMAT_MOD_X_TILED: | ||
2275 | tile_height = IS_GEN2(dev) ? 16 : 8; | ||
2276 | break; | ||
2277 | case I915_FORMAT_MOD_Y_TILED: | ||
2278 | tile_height = 32; | ||
2279 | break; | ||
2280 | case I915_FORMAT_MOD_Yf_TILED: | ||
2281 | pixel_bytes = drm_format_plane_cpp(pixel_format, plane); | ||
2282 | switch (pixel_bytes) { | ||
2283 | default: | ||
2284 | case 1: | ||
2285 | tile_height = 64; | ||
2286 | break; | ||
2287 | case 2: | ||
2288 | case 4: | ||
2289 | tile_height = 32; | ||
2290 | break; | ||
2291 | case 8: | ||
2292 | tile_height = 16; | ||
2293 | break; | ||
2294 | case 16: | ||
2295 | WARN_ONCE(1, | ||
2296 | "128-bit pixels are not supported for display!"); | ||
2297 | tile_height = 16; | ||
2298 | break; | ||
2299 | } | ||
2300 | break; | ||
2301 | default: | ||
2302 | MISSING_CASE(fb_format_modifier); | ||
2303 | tile_height = 1; | ||
2304 | break; | ||
2305 | } | ||
2306 | |||
2307 | return tile_height; | ||
2308 | } | 2276 | } |
2309 | 2277 | ||
2310 | unsigned int | 2278 | unsigned int |
2311 | intel_fb_align_height(struct drm_device *dev, unsigned int height, | 2279 | intel_fb_align_height(struct drm_device *dev, unsigned int height, |
2312 | uint32_t pixel_format, uint64_t fb_format_modifier) | 2280 | uint32_t pixel_format, uint64_t fb_modifier) |
2313 | { | 2281 | { |
2314 | return ALIGN(height, intel_tile_height(dev, pixel_format, | 2282 | unsigned int cpp = drm_format_plane_cpp(pixel_format, 0); |
2315 | fb_format_modifier, 0)); | 2283 | unsigned int tile_height = intel_tile_height(to_i915(dev), fb_modifier, cpp); |
2284 | |||
2285 | return ALIGN(height, tile_height); | ||
2316 | } | 2286 | } |
2317 | 2287 | ||
2318 | static void | 2288 | static void |
2319 | intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb, | 2289 | intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb, |
2320 | const struct drm_plane_state *plane_state) | 2290 | const struct drm_plane_state *plane_state) |
2321 | { | 2291 | { |
2292 | struct drm_i915_private *dev_priv = to_i915(fb->dev); | ||
2322 | struct intel_rotation_info *info = &view->params.rotation_info; | 2293 | struct intel_rotation_info *info = &view->params.rotation_info; |
2323 | unsigned int tile_height, tile_pitch; | 2294 | unsigned int tile_height, tile_pitch; |
2295 | unsigned int cpp = drm_format_plane_cpp(fb->pixel_format, 0); | ||
2324 | 2296 | ||
2325 | *view = i915_ggtt_view_normal; | 2297 | *view = i915_ggtt_view_normal; |
2326 | 2298 | ||
@@ -2338,22 +2310,19 @@ intel_fill_fb_ggtt_view(struct i915_ggtt_view *view, struct drm_framebuffer *fb, | |||
2338 | info->uv_offset = fb->offsets[1]; | 2310 | info->uv_offset = fb->offsets[1]; |
2339 | info->fb_modifier = fb->modifier[0]; | 2311 | info->fb_modifier = fb->modifier[0]; |
2340 | 2312 | ||
2341 | tile_height = intel_tile_height(fb->dev, fb->pixel_format, | 2313 | tile_height = intel_tile_height(dev_priv, fb->modifier[0], cpp); |
2342 | fb->modifier[0], 0); | ||
2343 | tile_pitch = PAGE_SIZE / tile_height; | 2314 | tile_pitch = PAGE_SIZE / tile_height; |
2344 | info->width_pages = DIV_ROUND_UP(fb->pitches[0], tile_pitch); | 2315 | info->width_pages = DIV_ROUND_UP(fb->pitches[0], tile_pitch); |
2345 | info->height_pages = DIV_ROUND_UP(fb->height, tile_height); | 2316 | info->height_pages = DIV_ROUND_UP(fb->height, tile_height); |
2346 | info->size = info->width_pages * info->height_pages * PAGE_SIZE; | 2317 | info->size = info->width_pages * info->height_pages * PAGE_SIZE; |
2347 | 2318 | ||
2348 | if (info->pixel_format == DRM_FORMAT_NV12) { | 2319 | if (info->pixel_format == DRM_FORMAT_NV12) { |
2349 | tile_height = intel_tile_height(fb->dev, fb->pixel_format, | 2320 | cpp = drm_format_plane_cpp(fb->pixel_format, 1); |
2350 | fb->modifier[0], 1); | 2321 | tile_height = intel_tile_height(dev_priv, fb->modifier[1], cpp); |
2351 | tile_pitch = PAGE_SIZE / tile_height; | 2322 | tile_pitch = PAGE_SIZE / tile_height; |
2352 | info->width_pages_uv = DIV_ROUND_UP(fb->pitches[0], tile_pitch); | 2323 | info->width_pages_uv = DIV_ROUND_UP(fb->pitches[1], tile_pitch); |
2353 | info->height_pages_uv = DIV_ROUND_UP(fb->height / 2, | 2324 | info->height_pages_uv = DIV_ROUND_UP(fb->height / 2, tile_height); |
2354 | tile_height); | 2325 | info->size_uv = info->width_pages_uv * info->height_pages_uv * PAGE_SIZE; |
2355 | info->size_uv = info->width_pages_uv * info->height_pages_uv * | ||
2356 | PAGE_SIZE; | ||
2357 | } | 2326 | } |
2358 | } | 2327 | } |
2359 | 2328 | ||
@@ -3140,9 +3109,10 @@ static void skylake_update_primary_plane(struct drm_plane *plane, | |||
3140 | WARN_ON(drm_rect_width(&plane_state->src) == 0); | 3109 | WARN_ON(drm_rect_width(&plane_state->src) == 0); |
3141 | 3110 | ||
3142 | if (intel_rotation_90_or_270(rotation)) { | 3111 | if (intel_rotation_90_or_270(rotation)) { |
3112 | int cpp = drm_format_plane_cpp(fb->pixel_format, 0); | ||
3113 | |||
3143 | /* stride = Surface height in tiles */ | 3114 | /* stride = Surface height in tiles */ |
3144 | tile_height = intel_tile_height(dev, fb->pixel_format, | 3115 | tile_height = intel_tile_height(dev_priv, fb->modifier[0], cpp); |
3145 | fb->modifier[0], 0); | ||
3146 | stride = DIV_ROUND_UP(fb->height, tile_height); | 3116 | stride = DIV_ROUND_UP(fb->height, tile_height); |
3147 | x_offset = stride * tile_height - src_y - src_h; | 3117 | x_offset = stride * tile_height - src_y - src_h; |
3148 | y_offset = src_x; | 3118 | y_offset = src_x; |
@@ -11401,8 +11371,7 @@ static void skl_do_mmio_flip(struct intel_crtc *intel_crtc, | |||
11401 | */ | 11371 | */ |
11402 | if (intel_rotation_90_or_270(rotation)) { | 11372 | if (intel_rotation_90_or_270(rotation)) { |
11403 | /* stride = Surface height in tiles */ | 11373 | /* stride = Surface height in tiles */ |
11404 | tile_height = intel_tile_height(dev, fb->pixel_format, | 11374 | tile_height = intel_tile_height(dev_priv, fb->modifier[0], 0); |
11405 | fb->modifier[0], 0); | ||
11406 | stride = DIV_ROUND_UP(fb->height, tile_height); | 11375 | stride = DIV_ROUND_UP(fb->height, tile_height); |
11407 | } else { | 11376 | } else { |
11408 | stride = fb->pitches[0] / | 11377 | stride = fb->pitches[0] / |
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index 9a8075b785ac..6aaaa8d3b81a 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
@@ -1155,9 +1155,8 @@ int intel_plane_atomic_set_property(struct drm_plane *plane, | |||
1155 | int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state, | 1155 | int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state, |
1156 | struct drm_plane_state *plane_state); | 1156 | struct drm_plane_state *plane_state); |
1157 | 1157 | ||
1158 | unsigned int | 1158 | unsigned int intel_tile_height(const struct drm_i915_private *dev_priv, |
1159 | intel_tile_height(struct drm_device *dev, uint32_t pixel_format, | 1159 | uint64_t fb_modifier, unsigned int cpp); |
1160 | uint64_t fb_format_modifier, unsigned int plane); | ||
1161 | 1160 | ||
1162 | static inline bool | 1161 | static inline bool |
1163 | intel_rotation_90_or_270(unsigned int rotation) | 1162 | intel_rotation_90_or_270(unsigned int rotation) |
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index 766c33ad0309..64083d720a00 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c | |||
@@ -239,9 +239,10 @@ skl_update_plane(struct drm_plane *drm_plane, | |||
239 | surf_addr = intel_plane_obj_offset(intel_plane, obj, 0); | 239 | surf_addr = intel_plane_obj_offset(intel_plane, obj, 0); |
240 | 240 | ||
241 | if (intel_rotation_90_or_270(rotation)) { | 241 | if (intel_rotation_90_or_270(rotation)) { |
242 | int cpp = drm_format_plane_cpp(fb->pixel_format, 0); | ||
243 | |||
242 | /* stride: Surface height in tiles */ | 244 | /* stride: Surface height in tiles */ |
243 | tile_height = intel_tile_height(dev, fb->pixel_format, | 245 | tile_height = intel_tile_height(dev_priv, fb->modifier[0], cpp); |
244 | fb->modifier[0], 0); | ||
245 | stride = DIV_ROUND_UP(fb->height, tile_height); | 246 | stride = DIV_ROUND_UP(fb->height, tile_height); |
246 | plane_size = (src_w << 16) | src_h; | 247 | plane_size = (src_w << 16) | src_h; |
247 | x_offset = stride * tile_height - y - (src_h + 1); | 248 | x_offset = stride * tile_height - y - (src_h + 1); |