LCOV - code coverage report
Current view: top level - drivers/gpu/drm/tests - drm_format_test.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 222 222 100.0 %
Date: 2023-03-27 20:00:47 Functions: 18 18 100.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0
       2             : /*
       3             :  * Test cases for the drm_format functions
       4             :  *
       5             :  * Copyright (c) 2022 MaĆ­ra Canal <mairacanal@riseup.net>
       6             :  */
       7             : 
       8             : #include <kunit/test.h>
       9             : 
      10             : #include <drm/drm_fourcc.h>
      11             : 
      12           1 : static void drm_test_format_block_width_invalid(struct kunit *test)
      13             : {
      14           1 :         const struct drm_format_info *info = NULL;
      15             : 
      16           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 0);
      17           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
      18           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0);
      19           1 : }
      20             : 
      21           1 : static void drm_test_format_block_width_one_plane(struct kunit *test)
      22             : {
      23           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444);
      24             : 
      25           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
      26             : 
      27           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1);
      28           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0);
      29           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
      30           1 : }
      31             : 
      32           1 : static void drm_test_format_block_width_two_plane(struct kunit *test)
      33             : {
      34           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12);
      35             : 
      36           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
      37             : 
      38           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1);
      39           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 1);
      40           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 2), 0);
      41           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
      42           1 : }
      43             : 
      44           1 : static void drm_test_format_block_width_three_plane(struct kunit *test)
      45             : {
      46           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422);
      47             : 
      48           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
      49             : 
      50           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1);
      51           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 1);
      52           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 2), 1);
      53           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 3), 0);
      54           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
      55           1 : }
      56             : 
      57           1 : static void drm_test_format_block_width_tiled(struct kunit *test)
      58             : {
      59           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L0);
      60             : 
      61           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
      62             : 
      63           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 2);
      64           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0);
      65           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0);
      66           1 : }
      67             : 
      68           1 : static void drm_test_format_block_height_invalid(struct kunit *test)
      69             : {
      70           1 :         const struct drm_format_info *info = NULL;
      71             : 
      72           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 0);
      73           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0);
      74           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0);
      75           1 : }
      76             : 
      77           1 : static void drm_test_format_block_height_one_plane(struct kunit *test)
      78             : {
      79           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444);
      80             : 
      81           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
      82             : 
      83           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1);
      84           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0);
      85           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0);
      86           1 : }
      87             : 
      88           1 : static void drm_test_format_block_height_two_plane(struct kunit *test)
      89             : {
      90           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12);
      91             : 
      92           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
      93             : 
      94           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1);
      95           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 1);
      96           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 2), 0);
      97           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0);
      98           1 : }
      99             : 
     100           1 : static void drm_test_format_block_height_three_plane(struct kunit *test)
     101             : {
     102           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422);
     103             : 
     104           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
     105             : 
     106           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1);
     107           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 1);
     108           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 2), 1);
     109           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 3), 0);
     110           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0);
     111           1 : }
     112             : 
     113           1 : static void drm_test_format_block_height_tiled(struct kunit *test)
     114             : {
     115           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L0);
     116             : 
     117           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
     118             : 
     119           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 2);
     120           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0);
     121           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0);
     122           1 : }
     123             : 
     124           1 : static void drm_test_format_min_pitch_invalid(struct kunit *test)
     125             : {
     126           1 :         const struct drm_format_info *info = NULL;
     127             : 
     128           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0);
     129           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0);
     130           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0);
     131           1 : }
     132             : 
     133           1 : static void drm_test_format_min_pitch_one_plane_8bpp(struct kunit *test)
     134             : {
     135           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_RGB332);
     136             : 
     137           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
     138             : 
     139           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0);
     140           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0);
     141           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0);
     142             : 
     143           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 1);
     144           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 2);
     145           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 640);
     146           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 1024);
     147           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 1920);
     148           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 4096);
     149           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 671);
     150           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX),
     151             :                         (uint64_t)UINT_MAX);
     152           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)),
     153             :                         (uint64_t)(UINT_MAX - 1));
     154           1 : }
     155             : 
     156           1 : static void drm_test_format_min_pitch_one_plane_16bpp(struct kunit *test)
     157             : {
     158           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444);
     159             : 
     160           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
     161             : 
     162           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0);
     163           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0);
     164           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0);
     165             : 
     166           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 2);
     167           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 4);
     168           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 1280);
     169           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 2048);
     170           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 3840);
     171           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 8192);
     172           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 1342);
     173           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX),
     174             :                         (uint64_t)UINT_MAX * 2);
     175           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)),
     176             :                         (uint64_t)(UINT_MAX - 1) * 2);
     177           1 : }
     178             : 
     179           1 : static void drm_test_format_min_pitch_one_plane_24bpp(struct kunit *test)
     180             : {
     181           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_RGB888);
     182             : 
     183           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
     184             : 
     185           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0);
     186           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0);
     187           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0);
     188             : 
     189           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 3);
     190           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 6);
     191           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 1920);
     192           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 3072);
     193           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 5760);
     194           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 12288);
     195           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 2013);
     196           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX),
     197             :                         (uint64_t)UINT_MAX * 3);
     198           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX - 1),
     199             :                         (uint64_t)(UINT_MAX - 1) * 3);
     200           1 : }
     201             : 
     202           1 : static void drm_test_format_min_pitch_one_plane_32bpp(struct kunit *test)
     203             : {
     204           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_ABGR8888);
     205             : 
     206           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
     207             : 
     208           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0);
     209           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0);
     210           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0);
     211             : 
     212           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 4);
     213           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 8);
     214           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 2560);
     215           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 4096);
     216           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 7680);
     217           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 16384);
     218           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 2684);
     219           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX),
     220             :                         (uint64_t)UINT_MAX * 4);
     221           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX - 1),
     222             :                         (uint64_t)(UINT_MAX - 1) * 4);
     223           1 : }
     224             : 
     225           1 : static void drm_test_format_min_pitch_two_plane(struct kunit *test)
     226             : {
     227           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12);
     228             : 
     229           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
     230             : 
     231           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0);
     232           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0);
     233           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0);
     234           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 0), 0);
     235             : 
     236           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 1);
     237           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 1), 2);
     238           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 2);
     239           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 1), 2);
     240           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 640);
     241           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 320), 640);
     242           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 1024);
     243           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 512), 1024);
     244           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 1920);
     245           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 960), 1920);
     246           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 4096);
     247           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 2048), 4096);
     248           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 671);
     249           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 336), 672);
     250           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX),
     251             :                         (uint64_t)UINT_MAX);
     252           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1),
     253             :                         (uint64_t)UINT_MAX + 1);
     254           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)),
     255             :                         (uint64_t)(UINT_MAX - 1));
     256           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) /  2),
     257             :                         (uint64_t)(UINT_MAX - 1));
     258           1 : }
     259             : 
     260           1 : static void drm_test_format_min_pitch_three_plane_8bpp(struct kunit *test)
     261             : {
     262           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422);
     263             : 
     264           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
     265             : 
     266           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0);
     267           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0);
     268           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 0), 0);
     269           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0);
     270           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 3, 0), 0);
     271             : 
     272           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 1);
     273           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 1), 1);
     274           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 1), 1);
     275           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 2);
     276           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 2), 2);
     277           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 2), 2);
     278           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 640);
     279           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 320), 320);
     280           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 320), 320);
     281           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 1024);
     282           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 512), 512);
     283           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 512), 512);
     284           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 1920);
     285           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 960), 960);
     286           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 960), 960);
     287           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 4096);
     288           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 2048), 2048);
     289           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 2048), 2048);
     290           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 671);
     291           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 336), 336);
     292           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 336), 336);
     293           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX),
     294             :                         (uint64_t)UINT_MAX);
     295           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1),
     296             :                         (uint64_t)UINT_MAX / 2 + 1);
     297           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, UINT_MAX / 2 + 1),
     298             :                         (uint64_t)UINT_MAX / 2 + 1);
     299           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1) / 2),
     300             :                         (uint64_t)(UINT_MAX - 1) / 2);
     301           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) / 2),
     302             :                         (uint64_t)(UINT_MAX - 1) / 2);
     303           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, (UINT_MAX - 1) / 2),
     304             :                         (uint64_t)(UINT_MAX - 1) / 2);
     305           1 : }
     306             : 
     307           1 : static void drm_test_format_min_pitch_tiled(struct kunit *test)
     308             : {
     309           1 :         const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L2);
     310             : 
     311           1 :         KUNIT_ASSERT_NOT_NULL(test, info);
     312             : 
     313           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0);
     314           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0);
     315           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0);
     316             : 
     317           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 2);
     318           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 4);
     319           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 1280);
     320           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 2048);
     321           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 3840);
     322           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 8192);
     323           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 1342);
     324           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX),
     325             :                         (uint64_t)UINT_MAX * 2);
     326           1 :         KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX - 1),
     327             :                         (uint64_t)(UINT_MAX - 1) * 2);
     328           1 : }
     329             : 
     330             : static struct kunit_case drm_format_tests[] = {
     331             :         KUNIT_CASE(drm_test_format_block_width_invalid),
     332             :         KUNIT_CASE(drm_test_format_block_width_one_plane),
     333             :         KUNIT_CASE(drm_test_format_block_width_two_plane),
     334             :         KUNIT_CASE(drm_test_format_block_width_three_plane),
     335             :         KUNIT_CASE(drm_test_format_block_width_tiled),
     336             :         KUNIT_CASE(drm_test_format_block_height_invalid),
     337             :         KUNIT_CASE(drm_test_format_block_height_one_plane),
     338             :         KUNIT_CASE(drm_test_format_block_height_two_plane),
     339             :         KUNIT_CASE(drm_test_format_block_height_three_plane),
     340             :         KUNIT_CASE(drm_test_format_block_height_tiled),
     341             :         KUNIT_CASE(drm_test_format_min_pitch_invalid),
     342             :         KUNIT_CASE(drm_test_format_min_pitch_one_plane_8bpp),
     343             :         KUNIT_CASE(drm_test_format_min_pitch_one_plane_16bpp),
     344             :         KUNIT_CASE(drm_test_format_min_pitch_one_plane_24bpp),
     345             :         KUNIT_CASE(drm_test_format_min_pitch_one_plane_32bpp),
     346             :         KUNIT_CASE(drm_test_format_min_pitch_two_plane),
     347             :         KUNIT_CASE(drm_test_format_min_pitch_three_plane_8bpp),
     348             :         KUNIT_CASE(drm_test_format_min_pitch_tiled),
     349             :         {}
     350             : };
     351             : 
     352             : static struct kunit_suite drm_format_test_suite = {
     353             :         .name = "drm_format",
     354             :         .test_cases = drm_format_tests,
     355             : };
     356             : 
     357             : kunit_test_suite(drm_format_test_suite);
     358             : 
     359             : MODULE_LICENSE("GPL");

Generated by: LCOV version 1.14