[igt-dev] [PATCH i-g-t] igt/kms_addfb_basic: Exercise legacy interface to addfb2

Chris Wilson chris at chris-wilson.co.uk
Wed Sep 5 10:18:39 UTC 2018


Quoting Chris Wilson (2018-09-05 11:05:22)
> The legacy interface passes in a single handle, and instead of providing
> the pixel_format fourcc, passes in a bpp/depth combination that the
> kernel translates into a fourcc. If that is an illegal combination, the
> kernel should be reporting EINVAL rather than pass an unknown
> framebuffer to the drivers.
> 
> As the number of possible permutations of bpp/depth (both are strictly
> u32 parameters) is huge, we simply fuzz the interface for 1s.
> 
> Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
> Cc: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  tests/kms_addfb_basic.c | 103 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 103 insertions(+)
> 
> diff --git a/tests/kms_addfb_basic.c b/tests/kms_addfb_basic.c
> index 7d8852f02..b1b143f12 100644
> --- a/tests/kms_addfb_basic.c
> +++ b/tests/kms_addfb_basic.c
> @@ -38,9 +38,35 @@
>  #include "drm.h"
>  #include "drm_fourcc.h"
>  
> +#include "igt_rand.h"
> +
>  uint32_t gem_bo;
>  uint32_t gem_bo_small;
>  
> +static int legacy_addfb(int fd, struct drm_mode_fb_cmd *arg)
> +{
> +       int err;
> +
> +       err = 0;
> +       if (igt_ioctl(fd, DRM_IOCTL_MODE_ADDFB, arg))
> +               err = -errno;
> +
> +       errno = 0;
> +       return err;
> +}
> +
> +static int rmfb(int fd, uint32_t id)
> +{
> +       int err;
> +
> +       err = 0;
> +       if (igt_ioctl(fd, DRM_IOCTL_MODE_RMFB, &id))
> +               err = -errno;
> +
> +       errno = 0;
> +       return err;
> +}
> +
>  static void invalid_tests(int fd)
>  {
>         struct local_drm_mode_fb_cmd2 f = {};
> @@ -113,6 +139,83 @@ static void invalid_tests(int fd)
>                 igt_assert(f.modifier[0] == 0);
>         }
>  
> +       igt_subtest("legacy-format") {
> +               struct {
> +                       /* drm_mode_legacy_fb_format() */
> +                       int bpp, depth;
> +                       int expect;
> +               } known_formats[] = {
> +                       { 8, 0 },   /* palette */
> +                       { 16, 15 }, /* x1r5g5b5 */
> +                       { 16, 16 }, /* r5g6b5 */

or a1r5g5b5

> +                       { 24, 24 }, /* r8g8b8 */
> +                       { 32, 24 }, /* x8r8g8b8 */
> +                       { 32, 30 }, /* x2r10g10b10 */
> +                       { 32, 32 }, /* a2r10g10b10 */

or a8r8g8b8

If I'm tagging them I might as well point out the ambiguity (hopefully
the rgb order is obvious enough).
-Chris


More information about the igt-dev mailing list