Message ID | 20241003200129.1732122-16-harry.wentland@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Color Pipeline API w/ VKMS | expand |
On 03/10/24 - 16:00, Harry Wentland wrote: checkpatch: commit description - Add an appropriate one > Signed-off-by: Harry Wentland <harry.wentland@amd.com> > --- > drivers/gpu/drm/vkms/tests/vkms_color_test.c | 38 +++++++++++++++++++- > drivers/gpu/drm/vkms/vkms_composer.c | 15 ++------ > drivers/gpu/drm/vkms/vkms_composer.h | 13 +++++++ > 3 files changed, 53 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c > index efe139978860..c36e67c7909e 100644 > --- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c > +++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c > @@ -6,6 +6,7 @@ > #include <drm/drm_mode.h> > #include "../vkms_drv.h" > #include "../vkms_composer.h" > +#include "../vkms_luts.h" > > #define TEST_LUT_SIZE 16 > > @@ -36,7 +37,6 @@ const struct vkms_color_lut test_linear_lut = { > .channel_value2index_ratio = 0xf000fll > }; > > - > static void vkms_color_test_get_lut_index(struct kunit *test) > { > int i; > @@ -45,6 +45,19 @@ static void vkms_color_test_get_lut_index(struct kunit *test) > > for (i = 0; i < TEST_LUT_SIZE; i++) > KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&test_linear_lut, test_linear_array[i].red)), i); > + > + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_eotf, 0x0)), 0x0); > + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x0)), 0x0); > + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x101)), 0x1); > + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x202)), 0x2); > + > + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0); > + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0); > + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x101)), 0x1); > + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x202)), 0x2); > + > + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xfefe)), 0xfe); > + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xffff)), 0xff); > } > > static void vkms_color_test_lerp(struct kunit *test) > @@ -153,9 +166,32 @@ static void vkms_color_test_lerp(struct kunit *test) > KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x1, 0x80000000), 0x1); > } > > +static void vkms_color_test_linear(struct kunit *test) > +{ > + for (int i = 0; i < LUT_SIZE; i++) { > + int linear = apply_lut_to_channel_value(&linear_eotf, i * 0x101, LUT_RED); checkpatch: Missing a blank line after declarations > + KUNIT_EXPECT_EQ(test, DIV_ROUND_CLOSEST(linear, 0x101), i); > + } > +} > + > +static void vkms_color_srgb_inv_srgb(struct kunit *test) > +{ > + u16 srgb, final; > + > + for (int i = 0; i < LUT_SIZE; i++) { > + srgb = apply_lut_to_channel_value(&srgb_eotf, i * 0x101, LUT_RED); > + final = apply_lut_to_channel_value(&srgb_inv_eotf, srgb, LUT_RED); > + > + KUNIT_EXPECT_GE(test, final / 0x101, i-1); > + KUNIT_EXPECT_LE(test, final / 0x101, i+1); checkpatch: spaces preferred around that '-/+' (ctx:VxV) > + } > +} > + > static struct kunit_case vkms_color_test_cases[] = { > KUNIT_CASE(vkms_color_test_get_lut_index), > KUNIT_CASE(vkms_color_test_lerp), > + KUNIT_CASE(vkms_color_test_linear), > + KUNIT_CASE(vkms_color_srgb_inv_srgb), > {} > }; > > diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c > index a35466e68237..b4aaad2bf45f 100644 > --- a/drivers/gpu/drm/vkms/vkms_composer.c > +++ b/drivers/gpu/drm/vkms/vkms_composer.c > @@ -113,18 +113,7 @@ VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel > } > EXPORT_SYMBOL_IF_KUNIT(get_lut_index); > > -/* > - * This enum is related to the positions of the variables inside > - * `struct drm_color_lut`, so the order of both needs to be the same. > - */ > -enum lut_channel { > - LUT_RED = 0, > - LUT_GREEN, > - LUT_BLUE, > - LUT_RESERVED > -}; > - > -static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, > +VISIBLE_IF_KUNIT u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, > enum lut_channel channel) checkpatch: Alignment should match open parenthesis > { > s64 lut_index = get_lut_index(lut, channel_value); > @@ -150,6 +139,8 @@ static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 chan > return lerp_u16(floor_channel_value, ceil_channel_value, > lut_index & DRM_FIXED_DECIMAL_MASK); > } > +EXPORT_SYMBOL_IF_KUNIT(apply_lut_to_channel_value); > + > > static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buffer *output_buffer) > { > diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h > index 9316a053e7d7..67ae09913460 100644 > --- a/drivers/gpu/drm/vkms/vkms_composer.h > +++ b/drivers/gpu/drm/vkms/vkms_composer.h > @@ -5,9 +5,22 @@ > > #include <kunit/visibility.h> > > +/* > + * This enum is related to the positions of the variables inside > + * `struct drm_color_lut`, so the order of both needs to be the same. > + */ > +enum lut_channel { > + LUT_RED = 0, > + LUT_GREEN, > + LUT_BLUE, > + LUT_RESERVED > +}; > + Can you declare this enum here in your previous patch, so you don't have to move it here? With or without this and the checkpatch warning fixed: Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com> > #if IS_ENABLED(CONFIG_KUNIT) > u16 lerp_u16(u16 a, u16 b, s64 t); > s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value); > +u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, > + enum lut_channel channel); > #endif > > #endif /* _VKMS_COMPOSER_H_ */ > -- > 2.46.2 >
Hi Harry, kernel test robot noticed the following build errors: [auto build test ERROR on drm/drm-next] [also build test ERROR on drm-exynos/exynos-drm-next drm-misc/drm-misc-next linus/master v6.12-rc1 next-20241004] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Harry-Wentland/drm-Add-helper-for-conversion-from-signed-magnitude/20241004-040629 base: git://anongit.freedesktop.org/drm/drm drm-next patch link: https://lore.kernel.org/r/20241003200129.1732122-16-harry.wentland%40amd.com patch subject: [PATCH v6 15/44] drm/vkms: Add kunit tests for linear and sRGB LUTs config: x86_64-randconfig-101-20241005 (https://download.01.org/0day-ci/archive/20241005/202410051303.Vy1EjQPJ-lkp@intel.com/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241005/202410051303.Vy1EjQPJ-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202410051303.Vy1EjQPJ-lkp@intel.com/ All errors (new ones prefixed by >>, old ones prefixed by <<): WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/vkms/tests/vkms_color_test.o >> ERROR: modpost: "srgb_eotf" [drivers/gpu/drm/vkms/tests/vkms_color_test.ko] undefined! >> ERROR: modpost: "srgb_inv_eotf" [drivers/gpu/drm/vkms/tests/vkms_color_test.ko] undefined! >> ERROR: modpost: "linear_eotf" [drivers/gpu/drm/vkms/tests/vkms_color_test.ko] undefined!
diff --git a/drivers/gpu/drm/vkms/tests/vkms_color_test.c b/drivers/gpu/drm/vkms/tests/vkms_color_test.c index efe139978860..c36e67c7909e 100644 --- a/drivers/gpu/drm/vkms/tests/vkms_color_test.c +++ b/drivers/gpu/drm/vkms/tests/vkms_color_test.c @@ -6,6 +6,7 @@ #include <drm/drm_mode.h> #include "../vkms_drv.h" #include "../vkms_composer.h" +#include "../vkms_luts.h" #define TEST_LUT_SIZE 16 @@ -36,7 +37,6 @@ const struct vkms_color_lut test_linear_lut = { .channel_value2index_ratio = 0xf000fll }; - static void vkms_color_test_get_lut_index(struct kunit *test) { int i; @@ -45,6 +45,19 @@ static void vkms_color_test_get_lut_index(struct kunit *test) for (i = 0; i < TEST_LUT_SIZE; i++) KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&test_linear_lut, test_linear_array[i].red)), i); + + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x101)), 0x1); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0x202)), 0x2); + + KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x0)), 0x0); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x101)), 0x1); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_inv_eotf, 0x202)), 0x2); + + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xfefe)), 0xfe); + KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&srgb_eotf, 0xffff)), 0xff); } static void vkms_color_test_lerp(struct kunit *test) @@ -153,9 +166,32 @@ static void vkms_color_test_lerp(struct kunit *test) KUNIT_EXPECT_EQ(test, lerp_u16(0x0, 0x1, 0x80000000), 0x1); } +static void vkms_color_test_linear(struct kunit *test) +{ + for (int i = 0; i < LUT_SIZE; i++) { + int linear = apply_lut_to_channel_value(&linear_eotf, i * 0x101, LUT_RED); + KUNIT_EXPECT_EQ(test, DIV_ROUND_CLOSEST(linear, 0x101), i); + } +} + +static void vkms_color_srgb_inv_srgb(struct kunit *test) +{ + u16 srgb, final; + + for (int i = 0; i < LUT_SIZE; i++) { + srgb = apply_lut_to_channel_value(&srgb_eotf, i * 0x101, LUT_RED); + final = apply_lut_to_channel_value(&srgb_inv_eotf, srgb, LUT_RED); + + KUNIT_EXPECT_GE(test, final / 0x101, i-1); + KUNIT_EXPECT_LE(test, final / 0x101, i+1); + } +} + static struct kunit_case vkms_color_test_cases[] = { KUNIT_CASE(vkms_color_test_get_lut_index), KUNIT_CASE(vkms_color_test_lerp), + KUNIT_CASE(vkms_color_test_linear), + KUNIT_CASE(vkms_color_srgb_inv_srgb), {} }; diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index a35466e68237..b4aaad2bf45f 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -113,18 +113,7 @@ VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel } EXPORT_SYMBOL_IF_KUNIT(get_lut_index); -/* - * This enum is related to the positions of the variables inside - * `struct drm_color_lut`, so the order of both needs to be the same. - */ -enum lut_channel { - LUT_RED = 0, - LUT_GREEN, - LUT_BLUE, - LUT_RESERVED -}; - -static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, +VISIBLE_IF_KUNIT u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, enum lut_channel channel) { s64 lut_index = get_lut_index(lut, channel_value); @@ -150,6 +139,8 @@ static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 chan return lerp_u16(floor_channel_value, ceil_channel_value, lut_index & DRM_FIXED_DECIMAL_MASK); } +EXPORT_SYMBOL_IF_KUNIT(apply_lut_to_channel_value); + static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buffer *output_buffer) { diff --git a/drivers/gpu/drm/vkms/vkms_composer.h b/drivers/gpu/drm/vkms/vkms_composer.h index 9316a053e7d7..67ae09913460 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.h +++ b/drivers/gpu/drm/vkms/vkms_composer.h @@ -5,9 +5,22 @@ #include <kunit/visibility.h> +/* + * This enum is related to the positions of the variables inside + * `struct drm_color_lut`, so the order of both needs to be the same. + */ +enum lut_channel { + LUT_RED = 0, + LUT_GREEN, + LUT_BLUE, + LUT_RESERVED +}; + #if IS_ENABLED(CONFIG_KUNIT) u16 lerp_u16(u16 a, u16 b, s64 t); s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value); +u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, + enum lut_channel channel); #endif #endif /* _VKMS_COMPOSER_H_ */
Signed-off-by: Harry Wentland <harry.wentland@amd.com> --- drivers/gpu/drm/vkms/tests/vkms_color_test.c | 38 +++++++++++++++++++- drivers/gpu/drm/vkms/vkms_composer.c | 15 ++------ drivers/gpu/drm/vkms/vkms_composer.h | 13 +++++++ 3 files changed, 53 insertions(+), 13 deletions(-)