Commit bae781b2 authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Daniel Vetter

drm: Nuke modifier[1-3]

It has been suggested that having per-plane modifiers is making life
more difficult for userspace, so let's just retire modifier[1-3] and
use modifier[0] to apply to the entire framebuffer.

Obviosuly this means that if individual planes need different tiling
layouts and whatnot we will need a new modifier for each combination
of planes with different tiling layouts.

For a bit of extra backwards compatilbilty the kernel will allow
non-zero modifier[1+] but it require that they will match modifier[0].
This in case there's existing userspace out there that sets
modifier[1+] to something non-zero with planar formats.

Mostly a cocci job, with a bit of manual stuff mixed in.

@@
struct drm_framebuffer *fb;
expression E;
@@
- fb->modifier[E]
+ fb->modifier

@@
struct drm_framebuffer fb;
expression E;
@@
- fb.modifier[E]
+ fb.modifier

Cc: Kristian Høgsberg <hoegsberg@gmail.com>
Cc: Ben Widawsky <benjamin.widawsky@intel.com>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Tomeu Vizoso <tomeu@tomeuvizoso.net>
Cc: dczaplejewicz@collabora.co.uk
Suggested-by: default avatarKristian Høgsberg <hoegsberg@gmail.com>
Acked-by: default avatarBen Widawsky <ben@bwidawsk.net>
Acked-by: default avatarDaniel Stone <daniels@collabora.com>
Acked-by: default avatarRob Clark <robdclark@gmail.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1479295996-26246-1-git-send-email-ville.syrjala@linux.intel.com
parent 0b46fcdb
...@@ -965,12 +965,12 @@ static void drm_atomic_plane_print_state(struct drm_printer *p, ...@@ -965,12 +965,12 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,
drm_printf(p, "\t\tformat=%s\n", drm_printf(p, "\t\tformat=%s\n",
drm_get_format_name(fb->pixel_format, &format_name)); drm_get_format_name(fb->pixel_format, &format_name));
drm_printf(p, "\t\t\tmodifier=0x%llx\n", fb->modifier);
drm_printf(p, "\t\tsize=%dx%d\n", fb->width, fb->height); drm_printf(p, "\t\tsize=%dx%d\n", fb->width, fb->height);
drm_printf(p, "\t\tlayers:\n"); drm_printf(p, "\t\tlayers:\n");
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
drm_printf(p, "\t\t\tpitch[%d]=%u\n", i, fb->pitches[i]); drm_printf(p, "\t\t\tpitch[%d]=%u\n", i, fb->pitches[i]);
drm_printf(p, "\t\t\toffset[%d]=%u\n", i, fb->offsets[i]); drm_printf(p, "\t\t\toffset[%d]=%u\n", i, fb->offsets[i]);
drm_printf(p, "\t\t\tmodifier[%d]=0x%llx\n", i, fb->modifier[i]);
} }
} }
drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest)); drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest));
......
...@@ -177,6 +177,13 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r) ...@@ -177,6 +177,13 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
return -EINVAL; return -EINVAL;
} }
if (r->flags & DRM_MODE_FB_MODIFIERS &&
r->modifier[i] != r->modifier[0]) {
DRM_DEBUG_KMS("bad fb modifier %llu for plane %d\n",
r->modifier[i], i);
return -EINVAL;
}
/* modifier specific checks: */ /* modifier specific checks: */
switch (r->modifier[i]) { switch (r->modifier[i]) {
case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE: case DRM_FORMAT_MOD_SAMSUNG_64_32_TILE:
......
...@@ -93,8 +93,8 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, ...@@ -93,8 +93,8 @@ void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
fb->pitches[i] = mode_cmd->pitches[i]; fb->pitches[i] = mode_cmd->pitches[i];
fb->offsets[i] = mode_cmd->offsets[i]; fb->offsets[i] = mode_cmd->offsets[i];
fb->modifier[i] = mode_cmd->modifier[i];
} }
fb->modifier = mode_cmd->modifier[0];
fb->pixel_format = mode_cmd->pixel_format; fb->pixel_format = mode_cmd->pixel_format;
fb->flags = mode_cmd->flags; fb->flags = mode_cmd->flags;
} }
......
...@@ -1896,7 +1896,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data) ...@@ -1896,7 +1896,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
fbdev_fb->base.height, fbdev_fb->base.height,
fbdev_fb->base.depth, fbdev_fb->base.depth,
fbdev_fb->base.bits_per_pixel, fbdev_fb->base.bits_per_pixel,
fbdev_fb->base.modifier[0], fbdev_fb->base.modifier,
drm_framebuffer_read_refcount(&fbdev_fb->base)); drm_framebuffer_read_refcount(&fbdev_fb->base));
describe_obj(m, fbdev_fb->obj); describe_obj(m, fbdev_fb->obj);
seq_putc(m, '\n'); seq_putc(m, '\n');
...@@ -1914,7 +1914,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data) ...@@ -1914,7 +1914,7 @@ static int i915_gem_framebuffer_info(struct seq_file *m, void *data)
fb->base.height, fb->base.height,
fb->base.depth, fb->base.depth,
fb->base.bits_per_pixel, fb->base.bits_per_pixel,
fb->base.modifier[0], fb->base.modifier,
drm_framebuffer_read_refcount(&fb->base)); drm_framebuffer_read_refcount(&fb->base));
describe_obj(m, fb->obj); describe_obj(m, fb->obj);
seq_putc(m, '\n'); seq_putc(m, '\n');
......
...@@ -143,8 +143,8 @@ static int intel_plane_atomic_check(struct drm_plane *plane, ...@@ -143,8 +143,8 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
if (state->fb && drm_rotation_90_or_270(state->rotation)) { if (state->fb && drm_rotation_90_or_270(state->rotation)) {
struct drm_format_name_buf format_name; struct drm_format_name_buf format_name;
if (!(state->fb->modifier[0] == I915_FORMAT_MOD_Y_TILED || if (state->fb->modifier != I915_FORMAT_MOD_Y_TILED &&
state->fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED)) { state->fb->modifier != I915_FORMAT_MOD_Yf_TILED) {
DRM_DEBUG_KMS("Y/Yf tiling required for 90/270!\n"); DRM_DEBUG_KMS("Y/Yf tiling required for 90/270!\n");
return -EINVAL; return -EINVAL;
} }
......
This diff is collapsed.
...@@ -633,7 +633,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev, ...@@ -633,7 +633,7 @@ static bool intel_fbdev_init_bios(struct drm_device *dev,
cur_size = intel_crtc->config->base.adjusted_mode.crtc_vdisplay; cur_size = intel_crtc->config->base.adjusted_mode.crtc_vdisplay;
cur_size = intel_fb_align_height(dev, cur_size, cur_size = intel_fb_align_height(dev, cur_size,
fb->base.pixel_format, fb->base.pixel_format,
fb->base.modifier[0]); fb->base.modifier);
cur_size *= fb->base.pitches[0]; cur_size *= fb->base.pitches[0];
DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n", DRM_DEBUG_KMS("pipe %c area: %dx%d, bpp: %d, size: %d\n",
pipe_name(intel_crtc->pipe), pipe_name(intel_crtc->pipe),
......
...@@ -3063,7 +3063,7 @@ bool intel_can_enable_sagv(struct drm_atomic_state *state) ...@@ -3063,7 +3063,7 @@ bool intel_can_enable_sagv(struct drm_atomic_state *state)
latency = dev_priv->wm.skl_latency[level]; latency = dev_priv->wm.skl_latency[level];
if (skl_needs_memory_bw_wa(intel_state) && if (skl_needs_memory_bw_wa(intel_state) &&
plane->base.state->fb->modifier[0] == plane->base.state->fb->modifier ==
I915_FORMAT_MOD_X_TILED) I915_FORMAT_MOD_X_TILED)
latency += 15; latency += 15;
...@@ -3319,8 +3319,8 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate, ...@@ -3319,8 +3319,8 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,
return 0; return 0;
/* For Non Y-tile return 8-blocks */ /* For Non Y-tile return 8-blocks */
if (fb->modifier[0] != I915_FORMAT_MOD_Y_TILED && if (fb->modifier != I915_FORMAT_MOD_Y_TILED &&
fb->modifier[0] != I915_FORMAT_MOD_Yf_TILED) fb->modifier != I915_FORMAT_MOD_Yf_TILED)
return 8; return 8;
src_w = drm_rect_width(&intel_pstate->base.src) >> 16; src_w = drm_rect_width(&intel_pstate->base.src) >> 16;
...@@ -3589,7 +3589,7 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, ...@@ -3589,7 +3589,7 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
return 0; return 0;
} }
if (apply_memory_bw_wa && fb->modifier[0] == I915_FORMAT_MOD_X_TILED) if (apply_memory_bw_wa && fb->modifier == I915_FORMAT_MOD_X_TILED)
latency += 15; latency += 15;
width = drm_rect_width(&intel_pstate->base.src) >> 16; width = drm_rect_width(&intel_pstate->base.src) >> 16;
...@@ -3625,12 +3625,12 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, ...@@ -3625,12 +3625,12 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
} }
plane_bytes_per_line = width * cpp; plane_bytes_per_line = width * cpp;
if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED || if (fb->modifier == I915_FORMAT_MOD_Y_TILED ||
fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED) { fb->modifier == I915_FORMAT_MOD_Yf_TILED) {
plane_blocks_per_line = plane_blocks_per_line =
DIV_ROUND_UP(plane_bytes_per_line * y_min_scanlines, 512); DIV_ROUND_UP(plane_bytes_per_line * y_min_scanlines, 512);
plane_blocks_per_line /= y_min_scanlines; plane_blocks_per_line /= y_min_scanlines;
} else if (fb->modifier[0] == DRM_FORMAT_MOD_NONE) { } else if (fb->modifier == DRM_FORMAT_MOD_NONE) {
plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512) plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512)
+ 1; + 1;
} else { } else {
...@@ -3647,8 +3647,8 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, ...@@ -3647,8 +3647,8 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
if (apply_memory_bw_wa) if (apply_memory_bw_wa)
y_tile_minimum *= 2; y_tile_minimum *= 2;
if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED || if (fb->modifier == I915_FORMAT_MOD_Y_TILED ||
fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED) { fb->modifier == I915_FORMAT_MOD_Yf_TILED) {
selected_result = max(method2, y_tile_minimum); selected_result = max(method2, y_tile_minimum);
} else { } else {
if ((cpp * cstate->base.adjusted_mode.crtc_htotal / 512 < 1) && if ((cpp * cstate->base.adjusted_mode.crtc_htotal / 512 < 1) &&
...@@ -3664,8 +3664,8 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, ...@@ -3664,8 +3664,8 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
res_lines = DIV_ROUND_UP(selected_result, plane_blocks_per_line); res_lines = DIV_ROUND_UP(selected_result, plane_blocks_per_line);
if (level >= 1 && level <= 7) { if (level >= 1 && level <= 7) {
if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED || if (fb->modifier == I915_FORMAT_MOD_Y_TILED ||
fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED) { fb->modifier == I915_FORMAT_MOD_Yf_TILED) {
res_blocks += y_tile_minimum; res_blocks += y_tile_minimum;
res_lines += y_min_scanlines; res_lines += y_min_scanlines;
} else { } else {
......
...@@ -229,7 +229,7 @@ skl_update_plane(struct drm_plane *drm_plane, ...@@ -229,7 +229,7 @@ skl_update_plane(struct drm_plane *drm_plane,
PLANE_CTL_PIPE_CSC_ENABLE; PLANE_CTL_PIPE_CSC_ENABLE;
plane_ctl |= skl_plane_ctl_format(fb->pixel_format); plane_ctl |= skl_plane_ctl_format(fb->pixel_format);
plane_ctl |= skl_plane_ctl_tiling(fb->modifier[0]); plane_ctl |= skl_plane_ctl_tiling(fb->modifier);
plane_ctl |= skl_plane_ctl_rotation(rotation); plane_ctl |= skl_plane_ctl_rotation(rotation);
...@@ -424,7 +424,7 @@ vlv_update_plane(struct drm_plane *dplane, ...@@ -424,7 +424,7 @@ vlv_update_plane(struct drm_plane *dplane,
*/ */
sprctl |= SP_GAMMA_ENABLE; sprctl |= SP_GAMMA_ENABLE;
if (fb->modifier[0] == I915_FORMAT_MOD_X_TILED) if (fb->modifier == I915_FORMAT_MOD_X_TILED)
sprctl |= SP_TILED; sprctl |= SP_TILED;
/* Sizes are 0 based */ /* Sizes are 0 based */
...@@ -460,7 +460,7 @@ vlv_update_plane(struct drm_plane *dplane, ...@@ -460,7 +460,7 @@ vlv_update_plane(struct drm_plane *dplane,
I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]); I915_WRITE(SPSTRIDE(pipe, plane), fb->pitches[0]);
I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x); I915_WRITE(SPPOS(pipe, plane), (crtc_y << 16) | crtc_x);
if (fb->modifier[0] == I915_FORMAT_MOD_X_TILED) if (fb->modifier == I915_FORMAT_MOD_X_TILED)
I915_WRITE(SPTILEOFF(pipe, plane), (y << 16) | x); I915_WRITE(SPTILEOFF(pipe, plane), (y << 16) | x);
else else
I915_WRITE(SPLINOFF(pipe, plane), linear_offset); I915_WRITE(SPLINOFF(pipe, plane), linear_offset);
...@@ -543,7 +543,7 @@ ivb_update_plane(struct drm_plane *plane, ...@@ -543,7 +543,7 @@ ivb_update_plane(struct drm_plane *plane,
*/ */
sprctl |= SPRITE_GAMMA_ENABLE; sprctl |= SPRITE_GAMMA_ENABLE;
if (fb->modifier[0] == I915_FORMAT_MOD_X_TILED) if (fb->modifier == I915_FORMAT_MOD_X_TILED)
sprctl |= SPRITE_TILED; sprctl |= SPRITE_TILED;
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
...@@ -596,7 +596,7 @@ ivb_update_plane(struct drm_plane *plane, ...@@ -596,7 +596,7 @@ ivb_update_plane(struct drm_plane *plane,
* register */ * register */
if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv))
I915_WRITE(SPROFFSET(pipe), (y << 16) | x); I915_WRITE(SPROFFSET(pipe), (y << 16) | x);
else if (fb->modifier[0] == I915_FORMAT_MOD_X_TILED) else if (fb->modifier == I915_FORMAT_MOD_X_TILED)
I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x); I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x);
else else
I915_WRITE(SPRLINOFF(pipe), linear_offset); I915_WRITE(SPRLINOFF(pipe), linear_offset);
...@@ -681,7 +681,7 @@ ilk_update_plane(struct drm_plane *plane, ...@@ -681,7 +681,7 @@ ilk_update_plane(struct drm_plane *plane,
*/ */
dvscntr |= DVS_GAMMA_ENABLE; dvscntr |= DVS_GAMMA_ENABLE;
if (fb->modifier[0] == I915_FORMAT_MOD_X_TILED) if (fb->modifier == I915_FORMAT_MOD_X_TILED)
dvscntr |= DVS_TILED; dvscntr |= DVS_TILED;
if (IS_GEN6(dev_priv)) if (IS_GEN6(dev_priv))
...@@ -723,7 +723,7 @@ ilk_update_plane(struct drm_plane *plane, ...@@ -723,7 +723,7 @@ ilk_update_plane(struct drm_plane *plane,
I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]); I915_WRITE(DVSSTRIDE(pipe), fb->pitches[0]);
I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x); I915_WRITE(DVSPOS(pipe), (crtc_y << 16) | crtc_x);
if (fb->modifier[0] == I915_FORMAT_MOD_X_TILED) if (fb->modifier == I915_FORMAT_MOD_X_TILED)
I915_WRITE(DVSTILEOFF(pipe), (y << 16) | x); I915_WRITE(DVSTILEOFF(pipe), (y << 16) | x);
else else
I915_WRITE(DVSLINOFF(pipe), linear_offset); I915_WRITE(DVSLINOFF(pipe), linear_offset);
......
...@@ -40,7 +40,7 @@ enum mdp4_frame_format mdp4_get_frame_format(struct drm_framebuffer *fb) ...@@ -40,7 +40,7 @@ enum mdp4_frame_format mdp4_get_frame_format(struct drm_framebuffer *fb)
{ {
bool is_tile = false; bool is_tile = false;
if (fb->modifier[1] == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE) if (fb->modifier == DRM_FORMAT_MOD_SAMSUNG_64_32_TILE)
is_tile = true; is_tile = true;
if (fb->pixel_format == DRM_FORMAT_NV12 && is_tile) if (fb->pixel_format == DRM_FORMAT_NV12 && is_tile)
......
...@@ -149,12 +149,12 @@ struct drm_framebuffer { ...@@ -149,12 +149,12 @@ struct drm_framebuffer {
*/ */
unsigned int offsets[4]; unsigned int offsets[4];
/** /**
* @modifier: Data layout modifier, per buffer. This is used to describe * @modifier: Data layout modifier. This is used to describe
* tiling, or also special layouts (like compression) of auxiliary * tiling, or also special layouts (like compression) of auxiliary
* buffers. For userspace created object this is copied from * buffers. For userspace created object this is copied from
* drm_mode_fb_cmd2. * drm_mode_fb_cmd2.
*/ */
uint64_t modifier[4]; uint64_t modifier;
/** /**
* @width: Logical width of the visible area of the framebuffer, in * @width: Logical width of the visible area of the framebuffer, in
* pixels. * pixels.
......
...@@ -408,17 +408,20 @@ struct drm_mode_fb_cmd2 { ...@@ -408,17 +408,20 @@ struct drm_mode_fb_cmd2 {
* offsets[1]. Note that offsets[0] will generally * offsets[1]. Note that offsets[0] will generally
* be 0 (but this is not required). * be 0 (but this is not required).
* *
* To accommodate tiled, compressed, etc formats, a per-plane * To accommodate tiled, compressed, etc formats, a
* modifier can be specified. The default value of zero * modifier can be specified. The default value of zero
* indicates "native" format as specified by the fourcc. * indicates "native" format as specified by the fourcc.
* Vendor specific modifier token. This allows, for example, * Vendor specific modifier token. Note that even though
* different tiling/swizzling pattern on different planes. * it looks like we have a modifier per-plane, we in fact
* See discussion above of DRM_FORMAT_MOD_xxx. * do not. The modifier for each plane must be identical.
* Thus all combinations of different data layouts for
* multi plane formats must be enumerated as separate
* modifiers.
*/ */
__u32 handles[4]; __u32 handles[4];
__u32 pitches[4]; /* pitch for each plane */ __u32 pitches[4]; /* pitch for each plane */
__u32 offsets[4]; /* offset of each plane */ __u32 offsets[4]; /* offset of each plane */
__u64 modifier[4]; /* ie, tiling, compressed (per plane) */ __u64 modifier[4]; /* ie, tiling, compress */
}; };
#define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01 #define DRM_MODE_FB_DIRTY_ANNOTATE_COPY 0x01
......
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