Skip to content

Commit 8fb756d

Browse files
committed
drm: Trust format_mod_supported() when it OKs a plane modifier.
For parameterized modifiers (Broadcom's SAND and UIF), we need to allow the parameter fields to be filled in, while exposing only the variant of the modifier with the parameter unfilled in the internal arrays and the format blob. Signed-off-by: Eric Anholt <eric@anholt.net> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180316220435.31416-1-eric@anholt.net Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
1 parent a38189c commit 8fb756d

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎drivers/gpu/drm/drm_plane.c‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -561,19 +561,20 @@ int drm_plane_check_pixel_format(struct drm_plane *plane,
561561
if (i == plane->format_count)
562562
return -EINVAL;
563563

564-
if (!plane->modifier_count)
565-
return 0;
564+
if (plane->funcs->format_mod_supported) {
565+
if (!plane->funcs->format_mod_supported(plane, format, modifier))
566+
return -EINVAL;
567+
} else {
568+
if (!plane->modifier_count)
569+
return 0;
566570

567-
for (i = 0; i < plane->modifier_count; i++) {
568-
if (modifier == plane->modifiers[i])
569-
break;
571+
for (i = 0; i < plane->modifier_count; i++) {
572+
if (modifier == plane->modifiers[i])
573+
break;
574+
}
575+
if (i == plane->modifier_count)
576+
return -EINVAL;
570577
}
571-
if (i == plane->modifier_count)
572-
return -EINVAL;
573-
574-
if (plane->funcs->format_mod_supported &&
575-
!plane->funcs->format_mod_supported(plane, format, modifier))
576-
return -EINVAL;
577578

578579
return 0;
579580
}

‎include/drm/drm_plane.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,10 @@ struct drm_plane_funcs {
431431
* This optional hook is used for the DRM to determine if the given
432432
* format/modifier combination is valid for the plane. This allows the
433433
* DRM to generate the correct format bitmask (which formats apply to
434-
* which modifier).
434+
* which modifier), and to valdiate modifiers at atomic_check time.
435+
*
436+
* If not present, then any modifier in the plane's modifier
437+
* list is allowed with any of the plane's formats.
435438
*
436439
* Returns:
437440
*

0 commit comments

Comments
 (0)