Skip to content

Commit 3107f42

Browse files
committed
drm/vc4: Extend BROADCOM_SAND modifier to handle computing automatically
The vc4 HVS can handle almost any column height in the SAND format, and this was signalled via the vendor bits in DRM_FORMAT_MOD_BROADCOM_SAND128. DRM is now requiring that all potential modifier values are reported, not just the canonical version of them. It is not feasible to report all the potential column heights, therefore add an option to go for a lowest common denominator calculation that computes the column height as height * 3/2 as it is YUV420. Signed-off-by: Dave Stevenson <[email protected]>
1 parent 78e2292 commit 3107f42

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

drivers/gpu/drm/vc4/vc4_plane.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,9 @@ static int vc4_plane_mode_set(struct drm_plane *plane,
12481248
case DRM_FORMAT_MOD_BROADCOM_SAND256: {
12491249
uint32_t param = fourcc_mod_broadcom_param(fb->modifier);
12501250

1251+
if (param == SAND_AUTO_HEIGHT)
1252+
param = (fb->height * 3) >> 1;
1253+
12511254
if (param > SCALER_TILE_HEIGHT_MASK) {
12521255
DRM_DEBUG_KMS("SAND height too large (%d)\n",
12531256
param);
@@ -1711,6 +1714,9 @@ static int vc6_plane_mode_set(struct drm_plane *plane,
17111714
u32 starting_offset;
17121715
u32 fetch_count;
17131716

1717+
if (param == SAND_AUTO_HEIGHT)
1718+
param = (fb->height * 3) >> 1;
1719+
17141720
if (param > SCALER_TILE_HEIGHT_MASK) {
17151721
DRM_DEBUG_KMS("SAND height too large (%d)\n",
17161722
param);
@@ -2395,8 +2401,11 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev,
23952401
static const uint64_t modifiers[] = {
23962402
DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED,
23972403
DRM_FORMAT_MOD_BROADCOM_SAND128,
2404+
DRM_FORMAT_MOD_BROADCOM_SAND128_AUTO_HEIGHT,
23982405
DRM_FORMAT_MOD_BROADCOM_SAND64,
2406+
DRM_FORMAT_MOD_BROADCOM_SAND64_AUTO_HEIGHT,
23992407
DRM_FORMAT_MOD_BROADCOM_SAND256,
2408+
DRM_FORMAT_MOD_BROADCOM_SAND256_AUTO_HEIGHT,
24002409
DRM_FORMAT_MOD_LINEAR,
24012410
DRM_FORMAT_MOD_INVALID
24022411
};

include/uapi/drm/drm_fourcc.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,14 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
10351035
* to various core checks that look at it , so you should set the
10361036
* stride to width*cpp).
10371037
*
1038+
* As DRM is now mandating that all modifiers must be reported, not
1039+
* just the canonical version, the use of
1040+
* DRM_FORMAT_MOD_BROADCOM_SANDxx_COL_HEIGHT(DRM_MODIFIER_SAND_AUTO_HEIGHT)
1041+
* is used to make the driver derive the column height as
1042+
* image_height * 3 / 2 lines as it is a YUV4:2:0 image.
1043+
* The old explicit specification of column height is still accepted, but
1044+
* is not reported other than in canonicalised form.
1045+
*
10381046
* Note that the column height for this format modifier is the same
10391047
* for all of the planes, assuming that each column contains both Y
10401048
* and UV. Some SAND-using hardware stores UV in a separate tiled
@@ -1046,6 +1054,8 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
10461054
* wide, but as this is a 10 bpp format that translates to 96 pixels.
10471055
*/
10481056

1057+
#define SAND_AUTO_HEIGHT 0x7fffffffULL
1058+
10491059
#define DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(v) \
10501060
fourcc_mod_broadcom_code(2, v)
10511061
#define DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(v) \
@@ -1057,12 +1067,20 @@ drm_fourcc_canonicalize_nvidia_format_mod(__u64 modifier)
10571067

10581068
#define DRM_FORMAT_MOD_BROADCOM_SAND32 \
10591069
DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(0)
1070+
#define DRM_FORMAT_MOD_BROADCOM_SAND32_AUTO_HEIGHT \
1071+
DRM_FORMAT_MOD_BROADCOM_SAND32_COL_HEIGHT(SAND_AUTO_HEIGHT)
10601072
#define DRM_FORMAT_MOD_BROADCOM_SAND64 \
10611073
DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(0)
1074+
#define DRM_FORMAT_MOD_BROADCOM_SAND64_AUTO_HEIGHT \
1075+
DRM_FORMAT_MOD_BROADCOM_SAND64_COL_HEIGHT(SAND_AUTO_HEIGHT)
10621076
#define DRM_FORMAT_MOD_BROADCOM_SAND128 \
10631077
DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(0)
1078+
#define DRM_FORMAT_MOD_BROADCOM_SAND128_AUTO_HEIGHT \
1079+
DRM_FORMAT_MOD_BROADCOM_SAND128_COL_HEIGHT(SAND_AUTO_HEIGHT)
10641080
#define DRM_FORMAT_MOD_BROADCOM_SAND256 \
10651081
DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(0)
1082+
#define DRM_FORMAT_MOD_BROADCOM_SAND256_AUTO_HEIGHT \
1083+
DRM_FORMAT_MOD_BROADCOM_SAND256_COL_HEIGHT(SAND_AUTO_HEIGHT)
10661084

10671085
/* Broadcom UIF format
10681086
*

0 commit comments

Comments
 (0)