Skip to contentSkip to conversation

gpu: ipu-v3: Use generic macro for rounding to nearest multiple

PATCH Superseded Devarsh Thakkar 3 participants 5 messages May 9, 2024 – May 11, 2024

Subsystems (3)

v7 of 14 Superseded Latest is v14 →

lore
Share & tools
lore
#0 lore raw

PATCH v7 8/8 gpu: ipu-v3: Use generic macro for rounding to nearest multiple

Use generic macro round_closest_up for rounding to nearest multiple instead of using local function.

---
V1->V6 (No change, patch introduced in V7)

---
 drivers/gpu/ipu-v3/ipu-image-convert.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/ipu-v3/ipu-image-convert.c +1 -3
index 841316582ea9..5192a8b5c02c 100644
@@ -477,8 +477,6 @@ static int calc_image_resize_coefficients(struct ipu_image_convert_ctx *ctx,
 	return 0;
 }
 
-#define round_closest(x, y) round_down((x) + (y)/2, (y))
-
 /*
  * Find the best aligned seam position for the given column / row index.
  * Rotation and image offsets are out of scope.
@@ -565,7 +563,7 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx,
 		 * The closest input sample position that we could actually
 		 * start the input tile at, 19.13 fixed point.
 		 */
-		in_pos_aligned = round_closest(in_pos, 8192U * in_align);
+		in_pos_aligned = round_closest_up(in_pos, 8192U * in_align);
 		/* Convert 19.13 fixed point to integer */
 		in_pos_rounded = in_pos_aligned / 8192U;
 
Signature · 1 line
2.39.1
#1 lore raw
Quoted 1 line · Devarsh Thakkar

Use generic macro round_closest_up for rounding to nearest multiple instead

round_closest_up()

We refer to the functions as func().

Quoted 1 line

of using local function.

...

drivers/gpu/ipu-v3/ipu-image-convert.c static void find_best_seam(struct ipu_image_convert_ctx *ctx, · line 568

Quoted 8 lines
drivers/gpu/ipu-v3/ipu-image-convert.c +1 -1
@@ -565,7 +563,7 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx,
 		 * The closest input sample position that we could actually
 		 * start the input tile at, 19.13 fixed point.
 		 */
-		in_pos_aligned = round_closest(in_pos, 8192U * in_align);
+		in_pos_aligned = round_closest_up(in_pos, 8192U * in_align);
 		/* Convert 19.13 fixed point to integer */
 		in_pos_rounded = in_pos_aligned / 8192U;

Oh, these seems to be better to use either ALIGN*(), or PFN_*() / PAGE_*() families of macros. What the semantic of 8192 is?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 11 lines · Andy Shevchenko
Quoted 1 line · Devarsh Thakkar

Use generic macro round_closest_up for rounding to nearest multiple instead

round_closest_up()

We refer to the functions as func().

Quoted 1 line

of using local function.

...

Quoted 11 lines

drivers/gpu/ipu-v3/ipu-image-convert.c static void find_best_seam(struct ipu_image_convert_ctx *ctx, · line 568

Quoted 8 lines
drivers/gpu/ipu-v3/ipu-image-convert.c +1 -1
@@ -565,7 +563,7 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx,
 		 * The closest input sample position that we could actually
 		 * start the input tile at, 19.13 fixed point.
 		 */
-		in_pos_aligned = round_closest(in_pos, 8192U * in_align);
+		in_pos_aligned = round_closest_up(in_pos, 8192U * in_align);
 		/* Convert 19.13 fixed point to integer */
 		in_pos_rounded = in_pos_aligned / 8192U;

Oh, these seems to be better to use either ALIGN*(), or PFN_*() / PAGE_*() families of macros. What the semantic of 8192 is?

The comment mentions 19.13 fixed point, so I assume that's the fractional part of the integer. It doesn't seem related to pages.

Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw
Quoted 9 lines · Laurent Pinchart
Quoted 8 lines · Andy Shevchenko
Quoted 1 line · Devarsh Thakkar

Use generic macro round_closest_up for rounding to nearest multiple instead

round_closest_up()

We refer to the functions as func().

Quoted 1 line

of using local function.

...

Quoted 12 lines
Quoted 11 lines

drivers/gpu/ipu-v3/ipu-image-convert.c static void find_best_seam(struct ipu_image_convert_ctx *ctx, · line 568

Quoted 8 lines
drivers/gpu/ipu-v3/ipu-image-convert.c +1 -1
@@ -565,7 +563,7 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx,
 		 * The closest input sample position that we could actually
 		 * start the input tile at, 19.13 fixed point.
 		 */
-		in_pos_aligned = round_closest(in_pos, 8192U * in_align);
+		in_pos_aligned = round_closest_up(in_pos, 8192U * in_align);
 		/* Convert 19.13 fixed point to integer */
 		in_pos_rounded = in_pos_aligned / 8192U;

Oh, these seems to be better to use either ALIGN*(), or PFN_*() / PAGE_*() families of macros. What the semantic of 8192 is?

Quoted 2 lines

The comment mentions 19.13 fixed point, so I assume that's the fractional part of the integer. It doesn't seem related to pages.

Okay, and align word in all those variable names?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
In reply to Andy Shevchenko

Hi Andy,

Thanks for the quick review.

Quoted 7 lines · Andy Shevchenko
Quoted 1 line · Devarsh Thakkar

Use generic macro round_closest_up for rounding to nearest multiple instead

round_closest_up()

We refer to the functions as func().

Agreed. Will fix commit msg to use round_closest_up()

Quoted 4 lines
Quoted 1 line

of using local function.

...

Quoted 12 lines

drivers/gpu/ipu-v3/ipu-image-convert.c static void find_best_seam(struct ipu_image_convert_ctx *ctx, · line 568

Quoted 8 lines
drivers/gpu/ipu-v3/ipu-image-convert.c +1 -1
@@ -565,7 +563,7 @@ static void find_best_seam(struct ipu_image_convert_ctx *ctx,
 		 * The closest input sample position that we could actually
 		 * start the input tile at, 19.13 fixed point.
 		 */
-		in_pos_aligned = round_closest(in_pos, 8192U * in_align);
+		in_pos_aligned = round_closest_up(in_pos, 8192U * in_align);
 		/* Convert 19.13 fixed point to integer */
 		in_pos_rounded = in_pos_aligned / 8192U;

Oh, these seems to be better to use either ALIGN*(), or PFN_*() / PAGE_*() families of macros. What the semantic of 8192 is?

As Laurent mentioned, it looks like the fractional part of the integer. But functionality wise, there is no change with the introduction of this patch. round_closest_up() does exactly the same thing as what the local function round_closest used to do before this patch.

Regards
Devarsh