]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: atomisp: replace ia_css_region with v4l2_rect
authorKarthikey Kadati <karthikey3608@gmail.com>
Thu, 15 Jan 2026 03:12:07 +0000 (08:42 +0530)
committerSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 20 May 2026 08:29:30 +0000 (11:29 +0300)
The struct ia_css_region definition is redundant as struct v4l2_rect
provides the same functionality (left, top, width, height) and is the
standard V4L2 type.

Replace usage of ia_css_region with v4l2_rect in ia_css_dz_config
and remove the definition of ia_css_region from ia_css_types.h.

Also remove historical comments referencing the addition of zoom_region
and include <linux/videodev2.h> to support the v4l2_rect type.

Signed-off-by: Karthikey Kadati <karthikey3608@gmail.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
drivers/staging/media/atomisp/pci/atomisp_cmd.c
drivers/staging/media/atomisp/pci/ia_css_types.h
drivers/staging/media/atomisp/pci/sh_css_params.c

index e401c23a75759964a517e19fa1b1c1ae139cda3c..7ccd4205ed1eedde157d88cadbf8a8b1a9fbbfef 100644 (file)
@@ -1768,15 +1768,13 @@ int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
                return -EINVAL;
        }
 
-       if (dz_config->zoom_region.resolution.width
-           == asd->sensor_array_res.width
-           || dz_config->zoom_region.resolution.height
-           == asd->sensor_array_res.height) {
+       if (dz_config->zoom_region.width == asd->sensor_array_res.width ||
+           dz_config->zoom_region.height == asd->sensor_array_res.height) {
                /*no need crop region*/
-               dz_config->zoom_region.origin.x = 0;
-               dz_config->zoom_region.origin.y = 0;
-               dz_config->zoom_region.resolution.width = eff_res.width;
-               dz_config->zoom_region.resolution.height = eff_res.height;
+               dz_config->zoom_region.left = 0;
+               dz_config->zoom_region.top = 0;
+               dz_config->zoom_region.width = eff_res.width;
+               dz_config->zoom_region.height = eff_res.height;
                return 0;
        }
 
@@ -1787,18 +1785,14 @@ int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
         */
 
        if (!IS_ISP2401) {
-               dz_config->zoom_region.origin.x = dz_config->zoom_region.origin.x
-                                                 * eff_res.width
-                                                 / asd->sensor_array_res.width;
-               dz_config->zoom_region.origin.y = dz_config->zoom_region.origin.y
-                                                 * eff_res.height
-                                                 / asd->sensor_array_res.height;
-               dz_config->zoom_region.resolution.width = dz_config->zoom_region.resolution.width
-                                                         * eff_res.width
-                                                         / asd->sensor_array_res.width;
-               dz_config->zoom_region.resolution.height = dz_config->zoom_region.resolution.height
-                                                         * eff_res.height
-                                                         / asd->sensor_array_res.height;
+               dz_config->zoom_region.left = dz_config->zoom_region.left *
+                                             eff_res.width / asd->sensor_array_res.width;
+               dz_config->zoom_region.top = dz_config->zoom_region.top *
+                                            eff_res.height / asd->sensor_array_res.height;
+               dz_config->zoom_region.width = dz_config->zoom_region.width *
+                                              eff_res.width / asd->sensor_array_res.width;
+               dz_config->zoom_region.height = dz_config->zoom_region.height *
+                                               eff_res.height / asd->sensor_array_res.height;
                /*
                 * Set same ratio of crop region resolution and current pipe output
                 * resolution
@@ -1825,62 +1819,62 @@ int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
                                   - asd->sensor_array_res.width
                                   * out_res.height / out_res.width;
                        h_offset = h_offset / 2;
-                       if (dz_config->zoom_region.origin.y < h_offset)
-                               dz_config->zoom_region.origin.y = 0;
+                       if (dz_config->zoom_region.top < h_offset)
+                               dz_config->zoom_region.top = 0;
                        else
-                               dz_config->zoom_region.origin.y = dz_config->zoom_region.origin.y - h_offset;
+                               dz_config->zoom_region.top =
+                                       dz_config->zoom_region.top - h_offset;
                        w_offset = 0;
                } else {
                        w_offset = asd->sensor_array_res.width
                                   - asd->sensor_array_res.height
                                   * out_res.width / out_res.height;
                        w_offset = w_offset / 2;
-                       if (dz_config->zoom_region.origin.x < w_offset)
-                               dz_config->zoom_region.origin.x = 0;
+                       if (dz_config->zoom_region.left < w_offset)
+                               dz_config->zoom_region.left = 0;
                        else
-                               dz_config->zoom_region.origin.x = dz_config->zoom_region.origin.x - w_offset;
+                               dz_config->zoom_region.left =
+                                       dz_config->zoom_region.left - w_offset;
                        h_offset = 0;
                }
-               dz_config->zoom_region.origin.x = dz_config->zoom_region.origin.x
-                                                 * eff_res.width
-                                                 / (asd->sensor_array_res.width - 2 * w_offset);
-               dz_config->zoom_region.origin.y = dz_config->zoom_region.origin.y
-                                                 * eff_res.height
-                                                 / (asd->sensor_array_res.height - 2 * h_offset);
-               dz_config->zoom_region.resolution.width = dz_config->zoom_region.resolution.width
-                                                 * eff_res.width
-                                                 / (asd->sensor_array_res.width - 2 * w_offset);
-               dz_config->zoom_region.resolution.height = dz_config->zoom_region.resolution.height
-                                                 * eff_res.height
-                                                 / (asd->sensor_array_res.height - 2 * h_offset);
-       }
-
-       if (out_res.width * dz_config->zoom_region.resolution.height
-           > dz_config->zoom_region.resolution.width * out_res.height) {
-               dz_config->zoom_region.resolution.height =
-                   dz_config->zoom_region.resolution.width
-                   * out_res.height / out_res.width;
+               dz_config->zoom_region.left = dz_config->zoom_region.left *
+                       eff_res.width /
+                       (asd->sensor_array_res.width - 2 * w_offset);
+               dz_config->zoom_region.top = dz_config->zoom_region.top *
+                       eff_res.height /
+                       (asd->sensor_array_res.height - 2 * h_offset);
+               dz_config->zoom_region.width = dz_config->zoom_region.width *
+                       eff_res.width /
+                       (asd->sensor_array_res.width - 2 * w_offset);
+               dz_config->zoom_region.height = dz_config->zoom_region.height *
+                       eff_res.height /
+                       (asd->sensor_array_res.height - 2 * h_offset);
+       }
+
+       if (out_res.width * dz_config->zoom_region.height >
+           dz_config->zoom_region.width * out_res.height) {
+               dz_config->zoom_region.height = dz_config->zoom_region.width *
+                                               out_res.height / out_res.width;
        } else {
-               dz_config->zoom_region.resolution.width =
-                   dz_config->zoom_region.resolution.height
-                   * out_res.width / out_res.height;
+               dz_config->zoom_region.width = dz_config->zoom_region.height *
+                                              out_res.width / out_res.height;
        }
        dev_dbg(asd->isp->dev,
                "%s crop region:(%d,%d),(%d,%d) eff_res(%d, %d) array_size(%d,%d) out_res(%d, %d)\n",
-               __func__, dz_config->zoom_region.origin.x,
-               dz_config->zoom_region.origin.y,
-               dz_config->zoom_region.resolution.width,
-               dz_config->zoom_region.resolution.height,
+               __func__, dz_config->zoom_region.left,
+               dz_config->zoom_region.top,
+               dz_config->zoom_region.width,
+               dz_config->zoom_region.height,
                eff_res.width, eff_res.height,
                asd->sensor_array_res.width,
                asd->sensor_array_res.height,
                out_res.width, out_res.height);
 
-       if ((dz_config->zoom_region.origin.x +
-            dz_config->zoom_region.resolution.width
+       if ((dz_config->zoom_region.left +
+            dz_config->zoom_region.width
             > eff_res.width) ||
-           (dz_config->zoom_region.origin.y +
-            dz_config->zoom_region.resolution.height
+           (dz_config->zoom_region.top +
+            dz_config->zoom_region.height
             > eff_res.height))
                return -EINVAL;
 
@@ -1905,10 +1899,10 @@ static bool atomisp_check_zoom_region(
 
        config.width = asd->sensor_array_res.width;
        config.height = asd->sensor_array_res.height;
-       w = dz_config->zoom_region.origin.x +
-           dz_config->zoom_region.resolution.width;
-       h = dz_config->zoom_region.origin.y +
-           dz_config->zoom_region.resolution.height;
+       w = dz_config->zoom_region.left +
+           dz_config->zoom_region.width;
+       h = dz_config->zoom_region.top +
+           dz_config->zoom_region.height;
 
        if ((w <= config.width) && (h <= config.height) && w > 0 && h > 0)
                flag = true;
@@ -1916,10 +1910,10 @@ static bool atomisp_check_zoom_region(
                /* setting error zoom region */
                dev_err(asd->isp->dev,
                        "%s zoom region ERROR:dz_config:(%d,%d),(%d,%d)array_res(%d, %d)\n",
-                       __func__, dz_config->zoom_region.origin.x,
-                       dz_config->zoom_region.origin.y,
-                       dz_config->zoom_region.resolution.width,
-                       dz_config->zoom_region.resolution.height,
+                       __func__, dz_config->zoom_region.left,
+                       dz_config->zoom_region.top,
+                       dz_config->zoom_region.width,
+                       dz_config->zoom_region.height,
                        config.width, config.height);
 
        return flag;
index 676d7e20b282d21ad4b9bd98d8855aa5cb2e639a..2b7db9cda23abdb5bdf5edf9690963e1cb2074ae 100644 (file)
@@ -15,6 +15,8 @@
  * directly but still need to forward parameters for it.
  */
 
+#include <linux/videodev2.h>
+
 #include <type_support.h>
 
 #include "ia_css_frac.h"
@@ -427,14 +429,6 @@ struct ia_css_point {
        s32 y; /** y coordinate */
 };
 
-/**
- * This specifies the region
- */
-struct ia_css_region {
-       struct ia_css_point origin; /** Starting point coordinates for the region */
-       struct ia_css_resolution resolution; /** Region resolution */
-};
-
 /**
  * Digital zoom:
  * This feature is currently available only for video, but will become
@@ -442,7 +436,7 @@ struct ia_css_region {
  * Set the digital zoom factor, this is a logarithmic scale. The actual zoom
  * factor will be 64/x.
  * Setting dx or dy to 0 disables digital zoom for that direction.
- * New API change for Digital zoom:(added struct ia_css_region zoom_region)
+ *
  * zoom_region specifies the origin of the zoom region and width and
  * height of that region.
  * origin : This is the coordinate (x,y) within the effective input resolution
@@ -455,7 +449,7 @@ struct ia_css_region {
 struct ia_css_dz_config {
        u32 dx; /** Horizontal zoom factor */
        u32 dy; /** Vertical zoom factor */
-       struct ia_css_region zoom_region; /** region for zoom */
+       struct v4l2_rect zoom_region; /** region for zoom */
 };
 
 /* The still capture mode, this can be RAW (simply copy sensor input to DDR),
index 8cbb5d598005240bc7cc0e0524aa161c812d0ff1..b8d492115196b198c3d946177d7520694abf1637 100644 (file)
@@ -657,11 +657,7 @@ static const int zoom_table[4][HRT_GDC_N] = {
 static const struct ia_css_dz_config default_dz_config = {
        HRT_GDC_N,
        HRT_GDC_N,
-       {
-               \
-               {0, 0}, \
-               {0, 0}, \
-       }
+       { 0, 0, 0, 0 }
 };
 
 static const struct ia_css_vector default_motion_config = {
@@ -1210,8 +1206,8 @@ ia_css_process_zoom_and_motion(
                }
 
                assert(stage->stage_num < SH_CSS_MAX_STAGES);
-               if (params->dz_config.zoom_region.resolution.width == 0 &&
-                   params->dz_config.zoom_region.resolution.height == 0) {
+               if (params->dz_config.zoom_region.width == 0 &&
+                   params->dz_config.zoom_region.height == 0) {
                        sh_css_update_uds_and_crop_info(
                            &info->sp,
                            &binary->in_frame_info,
@@ -4092,10 +4088,10 @@ sh_css_update_uds_and_crop_info_based_on_zoom_region(
        assert(motion_vector);
        assert(uds);
        assert(sp_out_crop_pos);
-       x0 = zoom->zoom_region.origin.x;
-       y0 = zoom->zoom_region.origin.y;
-       x1 = zoom->zoom_region.resolution.width + x0;
-       y1 = zoom->zoom_region.resolution.height + y0;
+       x0 = zoom->zoom_region.left;
+       y0 = zoom->zoom_region.top;
+       x1 = zoom->zoom_region.width + x0;
+       y1 = zoom->zoom_region.height + y0;
 
        if ((x0 > x1) || (y0 > y1) || (x1 > pipe_in_res.width) || (y1 > pipe_in_res.height))
                return -EINVAL;