Skip to content

Commit 714244e

Browse files
bwidawskfooishbar
authored andcommitted
drm/i915: Add format modifiers for Intel
This was based on a patch originally by Kristian. It has been modified pretty heavily to use the new callbacks from the previous patch. v2: - Add LINEAR and Yf modifiers to list (Ville) - Combine i8xx and i965 into one list of formats (Ville) - Allow 1010102 formats for Y/Yf tiled (Ville) v3: - Handle cursor formats (Ville) - Put handling for LINEAR in the mod_support functions (Ville) v4: - List each modifier explicitly in supported modifiers (Ville) - Handle the CURSOR plane (Ville) v5: - Split out cursor and sprite handling (Ville) v6: - Actually use the sprite funcs (Emil) - Use unreachable (Emil) v7: - Only allow Intel modifiers and LINEAR (Ben) v8 - Fix spite assert introduced in v6 (Daniel) v9 - Change vendor check logic to avoid magic 56 (Emil) - Reorder skl_mod_support (Ville) - make intel_plane_funcs static, could be done as of v5 (Ville) - rename local variable intel_format_modifiers to modifiers (Ville) - actually use sprite modifiers - split out modifier/formats by platform (Ville) v10: - Undo vendor check from v9 v11: - Squash CCS advertisement into this patch (daniels) - Don't advertise CCS on higher sprite planes (daniels) v12: - Don't advertise Y-tiled or CCS on any sprite planes, since we don't allocate enough DDB space for it to work. (daniels) Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com> (v8) Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Daniel Stone <daniels@collabora.com>
1 parent 2e2adb0 commit 714244e

3 files changed

Lines changed: 292 additions & 12 deletions

File tree

‎drivers/gpu/drm/i915/intel_display.c‎

Lines changed: 147 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ static const uint32_t i965_primary_formats[] = {
6767
DRM_FORMAT_XBGR2101010,
6868
};
6969

70+
static const uint64_t i9xx_format_modifiers[] = {
71+
I915_FORMAT_MOD_X_TILED,
72+
DRM_FORMAT_MOD_LINEAR,
73+
DRM_FORMAT_MOD_INVALID
74+
};
75+
7076
static const uint32_t skl_primary_formats[] = {
7177
DRM_FORMAT_C8,
7278
DRM_FORMAT_RGB565,
@@ -82,11 +88,34 @@ static const uint32_t skl_primary_formats[] = {
8288
DRM_FORMAT_VYUY,
8389
};
8490

91+
static const uint64_t skl_format_modifiers_noccs[] = {
92+
I915_FORMAT_MOD_Yf_TILED,
93+
I915_FORMAT_MOD_Y_TILED,
94+
I915_FORMAT_MOD_X_TILED,
95+
DRM_FORMAT_MOD_LINEAR,
96+
DRM_FORMAT_MOD_INVALID
97+
};
98+
99+
static const uint64_t skl_format_modifiers_ccs[] = {
100+
I915_FORMAT_MOD_Yf_TILED_CCS,
101+
I915_FORMAT_MOD_Y_TILED_CCS,
102+
I915_FORMAT_MOD_Yf_TILED,
103+
I915_FORMAT_MOD_Y_TILED,
104+
I915_FORMAT_MOD_X_TILED,
105+
DRM_FORMAT_MOD_LINEAR,
106+
DRM_FORMAT_MOD_INVALID
107+
};
108+
85109
/* Cursor formats */
86110
static const uint32_t intel_cursor_formats[] = {
87111
DRM_FORMAT_ARGB8888,
88112
};
89113

114+
static const uint64_t cursor_format_modifiers[] = {
115+
DRM_FORMAT_MOD_LINEAR,
116+
DRM_FORMAT_MOD_INVALID
117+
};
118+
90119
static void i9xx_crtc_clock_get(struct intel_crtc *crtc,
91120
struct intel_crtc_state *pipe_config);
92121
static void ironlake_pch_clock_get(struct intel_crtc *crtc,
@@ -12839,14 +12868,110 @@ void intel_plane_destroy(struct drm_plane *plane)
1283912868
kfree(to_intel_plane(plane));
1284012869
}
1284112870

12842-
const struct drm_plane_funcs intel_plane_funcs = {
12871+
static bool i8xx_mod_supported(uint32_t format, uint64_t modifier)
12872+
{
12873+
switch (format) {
12874+
case DRM_FORMAT_C8:
12875+
case DRM_FORMAT_RGB565:
12876+
case DRM_FORMAT_XRGB1555:
12877+
case DRM_FORMAT_XRGB8888:
12878+
return modifier == DRM_FORMAT_MOD_LINEAR ||
12879+
modifier == I915_FORMAT_MOD_X_TILED;
12880+
default:
12881+
return false;
12882+
}
12883+
}
12884+
12885+
static bool i965_mod_supported(uint32_t format, uint64_t modifier)
12886+
{
12887+
switch (format) {
12888+
case DRM_FORMAT_C8:
12889+
case DRM_FORMAT_RGB565:
12890+
case DRM_FORMAT_XRGB8888:
12891+
case DRM_FORMAT_XBGR8888:
12892+
case DRM_FORMAT_XRGB2101010:
12893+
case DRM_FORMAT_XBGR2101010:
12894+
return modifier == DRM_FORMAT_MOD_LINEAR ||
12895+
modifier == I915_FORMAT_MOD_X_TILED;
12896+
default:
12897+
return false;
12898+
}
12899+
}
12900+
12901+
static bool skl_mod_supported(uint32_t format, uint64_t modifier)
12902+
{
12903+
switch (format) {
12904+
case DRM_FORMAT_XRGB8888:
12905+
case DRM_FORMAT_XBGR8888:
12906+
case DRM_FORMAT_ARGB8888:
12907+
case DRM_FORMAT_ABGR8888:
12908+
if (modifier == I915_FORMAT_MOD_Yf_TILED_CCS ||
12909+
modifier == I915_FORMAT_MOD_Y_TILED_CCS)
12910+
return true;
12911+
/* fall through */
12912+
case DRM_FORMAT_RGB565:
12913+
case DRM_FORMAT_XRGB2101010:
12914+
case DRM_FORMAT_XBGR2101010:
12915+
case DRM_FORMAT_YUYV:
12916+
case DRM_FORMAT_YVYU:
12917+
case DRM_FORMAT_UYVY:
12918+
case DRM_FORMAT_VYUY:
12919+
if (modifier == I915_FORMAT_MOD_Yf_TILED)
12920+
return true;
12921+
/* fall through */
12922+
case DRM_FORMAT_C8:
12923+
if (modifier == DRM_FORMAT_MOD_LINEAR ||
12924+
modifier == I915_FORMAT_MOD_X_TILED ||
12925+
modifier == I915_FORMAT_MOD_Y_TILED)
12926+
return true;
12927+
/* fall through */
12928+
default:
12929+
return false;
12930+
}
12931+
}
12932+
12933+
static bool intel_primary_plane_format_mod_supported(struct drm_plane *plane,
12934+
uint32_t format,
12935+
uint64_t modifier)
12936+
{
12937+
struct drm_i915_private *dev_priv = to_i915(plane->dev);
12938+
12939+
if (WARN_ON(modifier == DRM_FORMAT_MOD_INVALID))
12940+
return false;
12941+
12942+
if ((modifier >> 56) != DRM_FORMAT_MOD_VENDOR_INTEL &&
12943+
modifier != DRM_FORMAT_MOD_LINEAR)
12944+
return false;
12945+
12946+
if (INTEL_GEN(dev_priv) >= 9)
12947+
return skl_mod_supported(format, modifier);
12948+
else if (INTEL_GEN(dev_priv) >= 4)
12949+
return i965_mod_supported(format, modifier);
12950+
else
12951+
return i8xx_mod_supported(format, modifier);
12952+
12953+
unreachable();
12954+
}
12955+
12956+
static bool intel_cursor_plane_format_mod_supported(struct drm_plane *plane,
12957+
uint32_t format,
12958+
uint64_t modifier)
12959+
{
12960+
if (WARN_ON(modifier == DRM_FORMAT_MOD_INVALID))
12961+
return false;
12962+
12963+
return modifier == DRM_FORMAT_MOD_LINEAR && format == DRM_FORMAT_ARGB8888;
12964+
}
12965+
12966+
static struct drm_plane_funcs intel_plane_funcs = {
1284312967
.update_plane = drm_atomic_helper_update_plane,
1284412968
.disable_plane = drm_atomic_helper_disable_plane,
1284512969
.destroy = intel_plane_destroy,
1284612970
.atomic_get_property = intel_plane_atomic_get_property,
1284712971
.atomic_set_property = intel_plane_atomic_set_property,
1284812972
.atomic_duplicate_state = intel_plane_duplicate_state,
1284912973
.atomic_destroy_state = intel_plane_destroy_state,
12974+
.format_mod_supported = intel_primary_plane_format_mod_supported,
1285012975
};
1285112976

1285212977
static int
@@ -12980,6 +13105,7 @@ static const struct drm_plane_funcs intel_cursor_plane_funcs = {
1298013105
.atomic_set_property = intel_plane_atomic_set_property,
1298113106
.atomic_duplicate_state = intel_plane_duplicate_state,
1298213107
.atomic_destroy_state = intel_plane_destroy_state,
13108+
.format_mod_supported = intel_cursor_plane_format_mod_supported,
1298313109
};
1298413110

1298513111
static struct intel_plane *
@@ -12990,6 +13116,7 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
1299013116
const uint32_t *intel_primary_formats;
1299113117
unsigned int supported_rotations;
1299213118
unsigned int num_formats;
13119+
const uint64_t *modifiers;
1299313120
int ret;
1299413121

1299513122
primary = kzalloc(sizeof(*primary), GFP_KERNEL);
@@ -13025,21 +13152,34 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
1302513152
primary->frontbuffer_bit = INTEL_FRONTBUFFER_PRIMARY(pipe);
1302613153
primary->check_plane = intel_check_primary_plane;
1302713154

13028-
if (INTEL_GEN(dev_priv) >= 9) {
13155+
if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv)) {
1302913156
intel_primary_formats = skl_primary_formats;
1303013157
num_formats = ARRAY_SIZE(skl_primary_formats);
13158+
modifiers = skl_format_modifiers_ccs;
13159+
13160+
primary->update_plane = skylake_update_primary_plane;
13161+
primary->disable_plane = skylake_disable_primary_plane;
13162+
} else if (INTEL_GEN(dev_priv) >= 9) {
13163+
intel_primary_formats = skl_primary_formats;
13164+
num_formats = ARRAY_SIZE(skl_primary_formats);
13165+
if (pipe < PIPE_C)
13166+
modifiers = skl_format_modifiers_ccs;
13167+
else
13168+
modifiers = skl_format_modifiers_noccs;
1303113169

1303213170
primary->update_plane = skylake_update_primary_plane;
1303313171
primary->disable_plane = skylake_disable_primary_plane;
1303413172
} else if (INTEL_GEN(dev_priv) >= 4) {
1303513173
intel_primary_formats = i965_primary_formats;
1303613174
num_formats = ARRAY_SIZE(i965_primary_formats);
13175+
modifiers = i9xx_format_modifiers;
1303713176

1303813177
primary->update_plane = i9xx_update_primary_plane;
1303913178
primary->disable_plane = i9xx_disable_primary_plane;
1304013179
} else {
1304113180
intel_primary_formats = i8xx_primary_formats;
1304213181
num_formats = ARRAY_SIZE(i8xx_primary_formats);
13182+
modifiers = i9xx_format_modifiers;
1304313183

1304413184
primary->update_plane = i9xx_update_primary_plane;
1304513185
primary->disable_plane = i9xx_disable_primary_plane;
@@ -13049,21 +13189,21 @@ intel_primary_plane_create(struct drm_i915_private *dev_priv, enum pipe pipe)
1304913189
ret = drm_universal_plane_init(&dev_priv->drm, &primary->base,
1305013190
0, &intel_plane_funcs,
1305113191
intel_primary_formats, num_formats,
13052-
NULL,
13192+
modifiers,
1305313193
DRM_PLANE_TYPE_PRIMARY,
1305413194
"plane 1%c", pipe_name(pipe));
1305513195
else if (INTEL_GEN(dev_priv) >= 5 || IS_G4X(dev_priv))
1305613196
ret = drm_universal_plane_init(&dev_priv->drm, &primary->base,
1305713197
0, &intel_plane_funcs,
1305813198
intel_primary_formats, num_formats,
13059-
NULL,
13199+
modifiers,
1306013200
DRM_PLANE_TYPE_PRIMARY,
1306113201
"primary %c", pipe_name(pipe));
1306213202
else
1306313203
ret = drm_universal_plane_init(&dev_priv->drm, &primary->base,
1306413204
0, &intel_plane_funcs,
1306513205
intel_primary_formats, num_formats,
13066-
NULL,
13206+
modifiers,
1306713207
DRM_PLANE_TYPE_PRIMARY,
1306813208
"plane %c", plane_name(primary->plane));
1306913209
if (ret)
@@ -13149,7 +13289,8 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv,
1314913289
0, &intel_cursor_plane_funcs,
1315013290
intel_cursor_formats,
1315113291
ARRAY_SIZE(intel_cursor_formats),
13152-
NULL, DRM_PLANE_TYPE_CURSOR,
13292+
cursor_format_modifiers,
13293+
DRM_PLANE_TYPE_CURSOR,
1315313294
"cursor %c", pipe_name(pipe));
1315413295
if (ret)
1315513296
goto fail;

‎drivers/gpu/drm/i915/intel_drv.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,6 @@ int vlv_get_cck_clock_hpll(struct drm_i915_private *dev_priv,
13161316
const char *name, u32 reg);
13171317
void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv);
13181318
void lpt_disable_iclkip(struct drm_i915_private *dev_priv);
1319-
extern const struct drm_plane_funcs intel_plane_funcs;
13201319
void intel_init_display_hooks(struct drm_i915_private *dev_priv);
13211320
unsigned int intel_fb_xy_to_linear(int x, int y,
13221321
const struct intel_plane_state *state,

0 commit comments

Comments
 (0)