]> www.infradead.org Git - users/willy/xarray.git/commitdiff
media: i2c: Use accessors for pad config 'try_*' fields
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Mon, 23 Oct 2023 21:40:10 +0000 (23:40 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Thu, 23 Nov 2023 17:24:32 +0000 (18:24 +0100)
The 'try_*' fields of the v4l2_subdev_pad_config structure are meant to
be accessed through helper functions. Replace direct access with usage
of the v4l2_subdev_get_pad_format(), v4l2_subdev_get_pad_crop() and
v4l2_subdev_get_pad_compose() helpers.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
15 files changed:
drivers/media/i2c/adv7183.c
drivers/media/i2c/imx274.c
drivers/media/i2c/mt9m001.c
drivers/media/i2c/mt9m111.c
drivers/media/i2c/mt9t112.c
drivers/media/i2c/mt9v011.c
drivers/media/i2c/mt9v111.c
drivers/media/i2c/ov2640.c
drivers/media/i2c/ov2680.c
drivers/media/i2c/ov6650.c
drivers/media/i2c/ov772x.c
drivers/media/i2c/ov9640.c
drivers/media/i2c/rj54n1cb0c.c
drivers/media/i2c/saa6752hs.c
drivers/media/i2c/tw9910.c

index 3659feafac69c8f22a0fc9a54c50025d047fc6a6..0754bfefa073ae667a9407deb07389b16f069142 100644 (file)
@@ -443,7 +443,7 @@ static int adv7183_set_fmt(struct v4l2_subdev *sd,
        if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
                decoder->fmt = *fmt;
        else
-               sd_state->pads->try_fmt = *fmt;
+               *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *fmt;
        return 0;
 }
 
index f33b692e6951ef64d264fa6d0094a3acfdd11f51..1886eaab1c247183bb845d578e70f7499c29336b 100644 (file)
@@ -1018,8 +1018,8 @@ static int __imx274_change_compose(struct stimx274 *imx274,
        int best_goodness = INT_MIN;
 
        if (which == V4L2_SUBDEV_FORMAT_TRY) {
-               cur_crop = &sd_state->pads->try_crop;
-               tgt_fmt = &sd_state->pads->try_fmt;
+               cur_crop = v4l2_subdev_get_pad_crop(&imx274->sd, sd_state, 0);
+               tgt_fmt = v4l2_subdev_get_pad_format(&imx274->sd, sd_state, 0);
        } else {
                cur_crop = &imx274->crop;
                tgt_fmt = &imx274->format;
@@ -1112,7 +1112,7 @@ static int imx274_set_fmt(struct v4l2_subdev *sd,
         */
        fmt->field = V4L2_FIELD_NONE;
        if (format->which == V4L2_SUBDEV_FORMAT_TRY)
-               sd_state->pads->try_fmt = *fmt;
+               *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *fmt;
        else
                imx274->format = *fmt;
 
@@ -1143,8 +1143,8 @@ static int imx274_get_selection(struct v4l2_subdev *sd,
        }
 
        if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
-               src_crop = &sd_state->pads->try_crop;
-               src_fmt = &sd_state->pads->try_fmt;
+               src_crop = v4l2_subdev_get_pad_crop(sd, sd_state, 0);
+               src_fmt = v4l2_subdev_get_pad_format(sd, sd_state, 0);
        } else {
                src_crop = &imx274->crop;
                src_fmt = &imx274->format;
@@ -1215,7 +1215,7 @@ static int imx274_set_selection_crop(struct stimx274 *imx274,
        sel->r = new_crop;
 
        if (sel->which == V4L2_SUBDEV_FORMAT_TRY)
-               tgt_crop = &sd_state->pads->try_crop;
+               tgt_crop = v4l2_subdev_get_pad_crop(&imx274->sd, sd_state, 0);
        else
                tgt_crop = &imx274->crop;
 
index 79192cf79d28745ffc9b6335d043c8321e7664cf..5c137fc2034e68f8dba80889060b812561894c8a 100644 (file)
@@ -405,7 +405,7 @@ static int mt9m001_set_fmt(struct v4l2_subdev *sd,
 
        if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
                return mt9m001_s_fmt(sd, fmt, mf);
-       sd_state->pads->try_fmt = *mf;
+       *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
        return 0;
 }
 
index 1f44b72e8a70c2c39ecc727613065122b87195cd..e17ff41ebba091b7d1c1abe2420d656df438e9dd 100644 (file)
@@ -671,7 +671,7 @@ static int mt9m111_set_fmt(struct v4l2_subdev *sd,
        mf->xfer_func   = V4L2_XFER_FUNC_DEFAULT;
 
        if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-               sd_state->pads->try_fmt = *mf;
+               *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
                return 0;
        }
 
index 93f34b767027afbd9c15c11515f4d8023a3b33e6..e3b9ff37450071bd0e7943a500fbc962390f44d8 100644 (file)
@@ -982,7 +982,7 @@ static int mt9t112_set_fmt(struct v4l2_subdev *sd,
 
        if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
                return mt9t112_s_fmt(sd, mf);
-       sd_state->pads->try_fmt = *mf;
+       *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
 
        return 0;
 }
index 37a634b92cd56884d38a51fcc9914a8d7f8bfe2e..7f313d731839be75f49045b60b263abb91661bcf 100644 (file)
@@ -356,7 +356,7 @@ static int mt9v011_set_fmt(struct v4l2_subdev *sd,
 
                set_res(sd);
        } else {
-               sd_state->pads->try_fmt = *fmt;
+               *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *fmt;
        }
 
        return 0;
index f859b49e13bf37cea817ef880da3379fbd6d7b2c..2c321e4884bea1631ca69efe039e89cc94fa27e2 100644 (file)
@@ -951,7 +951,7 @@ done:
 static int mt9v111_init_cfg(struct v4l2_subdev *subdev,
                            struct v4l2_subdev_state *sd_state)
 {
-       sd_state->pads->try_fmt = mt9v111_def_fmt;
+       *v4l2_subdev_get_pad_format(subdev, sd_state, 0) = mt9v111_def_fmt;
 
        return 0;
 }
index 28a01c6eff64f278717426031a3afa849ea952f4..389b6119ddecc23e6f2ffcf68722d685be69a498 100644 (file)
@@ -988,7 +988,7 @@ static int ov2640_set_fmt(struct v4l2_subdev *sd,
                /* select format */
                priv->cfmt_code = mf->code;
        } else {
-               sd_state->pads->try_fmt = *mf;
+               *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
        }
 out:
        mutex_unlock(&priv->lock);
index 72bab0ff8a36a90828843f145b2703967a9c5672..f58fa2eb86ee848e4bfdc9c452d0cf42be2ddfb0 100644 (file)
@@ -760,9 +760,9 @@ static int ov2680_init_cfg(struct v4l2_subdev *sd,
 {
        struct ov2680_dev *sensor = to_ov2680_dev(sd);
 
-       sd_state->pads[0].try_crop = ov2680_default_crop;
+       *v4l2_subdev_get_pad_crop(sd, sd_state, 0) = ov2680_default_crop;
 
-       ov2680_fill_format(sensor, &sd_state->pads[0].try_fmt,
+       ov2680_fill_format(sensor, v4l2_subdev_get_pad_format(sd, sd_state, 0),
                           OV2680_DEFAULT_WIDTH, OV2680_DEFAULT_HEIGHT);
        return 0;
 }
index 1ad07935f0465a9919fc5da4bbcfcb6d633f7e66..38d21b40f5d8158a175f94956c85972a36e8de70 100644 (file)
@@ -476,7 +476,7 @@ static int ov6650_get_selection(struct v4l2_subdev *sd,
 
        if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
                /* pre-select try crop rectangle */
-               rect = &sd_state->pads->try_crop;
+               rect = v4l2_subdev_get_pad_crop(sd, sd_state, 0);
 
        } else {
                /* pre-select active crop rectangle */
@@ -531,8 +531,10 @@ static int ov6650_set_selection(struct v4l2_subdev *sd,
        ov6650_bind_align_crop_rectangle(&sel->r);
 
        if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
-               struct v4l2_rect *crop = &sd_state->pads->try_crop;
-               struct v4l2_mbus_framefmt *mf = &sd_state->pads->try_fmt;
+               struct v4l2_rect *crop =
+                       v4l2_subdev_get_pad_crop(sd, sd_state, 0);
+               struct v4l2_mbus_framefmt *mf =
+                       v4l2_subdev_get_pad_format(sd, sd_state, 0);
                /* detect current pad config scaling factor */
                bool half_scale = !is_unscaled_ok(mf->width, mf->height, crop);
 
@@ -588,9 +590,12 @@ static int ov6650_get_fmt(struct v4l2_subdev *sd,
 
        /* update media bus format code and frame size */
        if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-               mf->width = sd_state->pads->try_fmt.width;
-               mf->height = sd_state->pads->try_fmt.height;
-               mf->code = sd_state->pads->try_fmt.code;
+               struct v4l2_mbus_framefmt *try_fmt =
+                       v4l2_subdev_get_pad_format(sd, sd_state, 0);
+
+               mf->width = try_fmt->width;
+               mf->height = try_fmt->height;
+               mf->code = try_fmt->code;
 
        } else {
                mf->width = priv->rect.width >> priv->half_scale;
@@ -717,23 +722,26 @@ static int ov6650_set_fmt(struct v4l2_subdev *sd,
        }
 
        if (format->which == V4L2_SUBDEV_FORMAT_TRY)
-               crop = &sd_state->pads->try_crop;
+               crop = v4l2_subdev_get_pad_crop(sd, sd_state, 0);
        else
                crop = &priv->rect;
 
        half_scale = !is_unscaled_ok(mf->width, mf->height, crop);
 
        if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
+               struct v4l2_mbus_framefmt *try_fmt =
+                       v4l2_subdev_get_pad_format(sd, sd_state, 0);
+
                /* store new mbus frame format code and size in pad config */
-               sd_state->pads->try_fmt.width = crop->width >> half_scale;
-               sd_state->pads->try_fmt.height = crop->height >> half_scale;
-               sd_state->pads->try_fmt.code = mf->code;
+               try_fmt->width = crop->width >> half_scale;
+               try_fmt->height = crop->height >> half_scale;
+               try_fmt->code = mf->code;
 
                /* return default mbus frame format updated with pad config */
                *mf = ov6650_def_fmt;
-               mf->width = sd_state->pads->try_fmt.width;
-               mf->height = sd_state->pads->try_fmt.height;
-               mf->code = sd_state->pads->try_fmt.code;
+               mf->width = try_fmt->width;
+               mf->height = try_fmt->height;
+               mf->code = try_fmt->code;
 
        } else {
                int ret = 0;
index 7618b58a7ad05380a82f2061faaded2f82c5bb1d..1fbf72152956acff1970d339056fe2c4919fe765 100644 (file)
@@ -1220,7 +1220,7 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
        mf->xfer_func = V4L2_XFER_FUNC_DEFAULT;
 
        if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-               sd_state->pads->try_fmt = *mf;
+               *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
                return 0;
        }
 
index cbaea049531d24cb74c8f5c2ba25cd70868d7046..a9adddde10064e106bea86281fe4619ff2398ac4 100644 (file)
@@ -547,7 +547,7 @@ static int ov9640_set_fmt(struct v4l2_subdev *sd,
        if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
                return ov9640_s_fmt(sd, mf);
 
-       sd_state->pads->try_fmt = *mf;
+       *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
 
        return 0;
 }
index b430046f9e2a9fcab40132686c75f05325053fbc..dbddb7a9f211204f608de393a7bb148e18b87b4c 100644 (file)
@@ -1009,7 +1009,7 @@ static int rj54n1_set_fmt(struct v4l2_subdev *sd,
                              &mf->height, 84, RJ54N1_MAX_HEIGHT, align, 0);
 
        if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-               sd_state->pads->try_fmt = *mf;
+               *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
                return 0;
        }
 
index c106e7a7d1f4edeb974b2c382b426591e5e918dc..82976aee5e860a33c92fea3309de4244193e1d24 100644 (file)
@@ -595,7 +595,7 @@ static int saa6752hs_set_fmt(struct v4l2_subdev *sd,
        f->colorspace = V4L2_COLORSPACE_SMPTE170M;
 
        if (format->which == V4L2_SUBDEV_FORMAT_TRY) {
-               sd_state->pads->try_fmt = *f;
+               *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *f;
                return 0;
        }
 
index 477a64d8f8ab6f81f423c2f797987655ae4bdf17..5233c33b93df215bbedcbe728c5ab31b63c36c3f 100644 (file)
@@ -829,7 +829,7 @@ static int tw9910_set_fmt(struct v4l2_subdev *sd,
        if (format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
                return tw9910_s_fmt(sd, mf);
 
-       sd_state->pads->try_fmt = *mf;
+       *v4l2_subdev_get_pad_format(sd, sd_state, 0) = *mf;
 
        return 0;
 }