Commit fbefb84d authored by Philipp Zabel's avatar Philipp Zabel

gpu: ipu-v3: image-convert: move tile burst alignment out of loop

Burst aligned input and output width can be calculated once per column,
instead of repeatedly for each tile in the column. The same goes for
input and output height per row. Also don't round up the same values
repeatedly.
Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
parent 5fb8b650
...@@ -1121,6 +1121,7 @@ static void calc_tile_resize_coefficients(struct ipu_image_convert_ctx *ctx) ...@@ -1121,6 +1121,7 @@ static void calc_tile_resize_coefficients(struct ipu_image_convert_ctx *ctx)
!(ctx->rot_mode & IPU_ROT_BIT_HFLIP); !(ctx->rot_mode & IPU_ROT_BIT_HFLIP);
u32 resized_width; u32 resized_width;
u32 resize_coeff_h; u32 resize_coeff_h;
u32 in_width;
tile_idx = col; tile_idx = col;
in_tile = &ctx->in.tile[tile_idx]; in_tile = &ctx->in.tile[tile_idx];
...@@ -1138,33 +1139,35 @@ static void calc_tile_resize_coefficients(struct ipu_image_convert_ctx *ctx) ...@@ -1138,33 +1139,35 @@ static void calc_tile_resize_coefficients(struct ipu_image_convert_ctx *ctx)
dev_dbg(priv->ipu->dev, "%s: column %u hscale: *8192/%u\n", dev_dbg(priv->ipu->dev, "%s: column %u hscale: *8192/%u\n",
__func__, col, resize_coeff_h); __func__, col, resize_coeff_h);
/*
* With the horizontal scaling factor known, round up resized
* width (output width or height) to burst size.
*/
resized_width = round_up(resized_width, 8);
/*
* Calculate input width from the last accessed input pixel
* given resized width and scaling coefficients. Round up to
* burst size.
*/
last_output = resized_width - 1;
if (closest)
last_output++;
in_width = round_up(
(DIV_ROUND_UP(last_output * resize_coeff_h, 8192) + 1)
<< ctx->downsize_coeff_h, 8);
for (row = 0; row < ctx->in.num_rows; row++) { for (row = 0; row < ctx->in.num_rows; row++) {
tile_idx = row * ctx->in.num_cols + col; tile_idx = row * ctx->in.num_cols + col;
in_tile = &ctx->in.tile[tile_idx]; in_tile = &ctx->in.tile[tile_idx];
out_tile = &ctx->out.tile[ctx->out_tile_map[tile_idx]]; out_tile = &ctx->out.tile[ctx->out_tile_map[tile_idx]];
/*
* With the horizontal scaling factor known, round up
* resized width (output width or height) to burst size.
*/
if (ipu_rot_mode_is_irt(ctx->rot_mode)) if (ipu_rot_mode_is_irt(ctx->rot_mode))
out_tile->height = round_up(resized_width, 8); out_tile->height = resized_width;
else else
out_tile->width = round_up(resized_width, 8); out_tile->width = resized_width;
/* in_tile->width = in_width;
* Calculate input width from the last accessed input
* pixel given resized width and scaling coefficients.
* Round up to burst size.
*/
last_output = round_up(resized_width, 8) - 1;
if (closest)
last_output++;
in_tile->width = round_up(
(DIV_ROUND_UP(last_output * resize_coeff_h,
8192) + 1)
<< ctx->downsize_coeff_h, 8);
} }
ctx->resize_coeffs_h[col] = resize_coeff_h; ctx->resize_coeffs_h[col] = resize_coeff_h;
...@@ -1175,6 +1178,7 @@ static void calc_tile_resize_coefficients(struct ipu_image_convert_ctx *ctx) ...@@ -1175,6 +1178,7 @@ static void calc_tile_resize_coefficients(struct ipu_image_convert_ctx *ctx)
!(ctx->rot_mode & IPU_ROT_BIT_VFLIP); !(ctx->rot_mode & IPU_ROT_BIT_VFLIP);
u32 resized_height; u32 resized_height;
u32 resize_coeff_v; u32 resize_coeff_v;
u32 in_height;
tile_idx = row * ctx->in.num_cols; tile_idx = row * ctx->in.num_cols;
in_tile = &ctx->in.tile[tile_idx]; in_tile = &ctx->in.tile[tile_idx];
...@@ -1192,33 +1196,35 @@ static void calc_tile_resize_coefficients(struct ipu_image_convert_ctx *ctx) ...@@ -1192,33 +1196,35 @@ static void calc_tile_resize_coefficients(struct ipu_image_convert_ctx *ctx)
dev_dbg(priv->ipu->dev, "%s: row %u vscale: *8192/%u\n", dev_dbg(priv->ipu->dev, "%s: row %u vscale: *8192/%u\n",
__func__, row, resize_coeff_v); __func__, row, resize_coeff_v);
/*
* With the vertical scaling factor known, round up resized
* height (output width or height) to IDMAC limitations.
*/
resized_height = round_up(resized_height, 2);
/*
* Calculate input width from the last accessed input pixel
* given resized height and scaling coefficients. Align to
* IDMAC restrictions.
*/
last_output = resized_height - 1;
if (closest)
last_output++;
in_height = round_up(
(DIV_ROUND_UP(last_output * resize_coeff_v, 8192) + 1)
<< ctx->downsize_coeff_v, 2);
for (col = 0; col < ctx->in.num_cols; col++) { for (col = 0; col < ctx->in.num_cols; col++) {
tile_idx = row * ctx->in.num_cols + col; tile_idx = row * ctx->in.num_cols + col;
in_tile = &ctx->in.tile[tile_idx]; in_tile = &ctx->in.tile[tile_idx];
out_tile = &ctx->out.tile[ctx->out_tile_map[tile_idx]]; out_tile = &ctx->out.tile[ctx->out_tile_map[tile_idx]];
/*
* With the vertical scaling factor known, round up
* resized height (output width or height) to IDMAC
* limitations.
*/
if (ipu_rot_mode_is_irt(ctx->rot_mode)) if (ipu_rot_mode_is_irt(ctx->rot_mode))
out_tile->width = round_up(resized_height, 2); out_tile->width = resized_height;
else else
out_tile->height = round_up(resized_height, 2); out_tile->height = resized_height;
/* in_tile->height = in_height;
* Calculate input width from the last accessed input
* pixel given resized height and scaling coefficients.
* Align to IDMAC restrictions.
*/
last_output = round_up(resized_height, 2) - 1;
if (closest)
last_output++;
in_tile->height = round_up(
(DIV_ROUND_UP(last_output * resize_coeff_v,
8192) + 1)
<< ctx->downsize_coeff_v, 2);
} }
ctx->resize_coeffs_v[row] = resize_coeff_v; ctx->resize_coeffs_v[row] = resize_coeff_v;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment