From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BB8D4A2A59 for ; Tue, 1 Sep 2026 19:05:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788289517; cv=none; b=AK1fQvmuZUng4CFZ9pglbL1gP7ZspukQ/NkaJhow9xOuND11qJ3WIgc4NGuN+1VeBTw+CfPh8SCgIODvm4abdHP4EXq3ogq2FXzGIiVD0dw/frRx2P/EvH21oR8oSC1DIpwL+crEHxlR6aJi16ekxEAL6KH19xjpWxazcllLcA4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788289517; c=relaxed/simple; bh=CGqSku8s6I9xNM49fj0vJ+QHoL2Fr7Pt+BZAaxIjnVY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WnNkCuGuqY48KVccZ9JOBxDmtg9+8RlUxrsEGafi5pf6Xbl7mAtXCVCximRzP9fn8deNq+yNvpCIE0cPUsoQm91S2kLT7UxCi39bmrJJ8lqKSlx0RLOl8ws6QSWSo8VyTlzrQ8ZRpBtLl5KQeszdTUGvzS4z0w+/PxNORbUqR9E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=n6w0qPIb; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n6w0qPIb" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4980fe6b3beso11340325e9.0 for ; Tue, 01 Sep 2026 12:05:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788289509; x=1788894309; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ZxYVuNTHZtvBWJm7YqYSyMDBs6saulAawUQpfC7rrKY=; b=n6w0qPIbxAUjjw4b6D3O/eugWpQ8+pHTPkR0k8cE/WCTa1+Sxp9OBSXlViX8uBlD+L idiKZomBHP6PQtn6spHbMcLHtY0aXwWOBmt4gsmufFwqhBsYn5ieoR7eQshkQyyvLR86 LTJnoBo6a6/sm5XPbkEEy6gvo9Cy2u3givh99amIGSjoeubyzyaZV9OUz3/UnE1hIg/B woZFATmU+ulLHucBaktwLElLdmxtKXH5TVbc46EG5PiAeTGWJ7qq6HxFGTvk3E68oVzO LzM4JMK65TSmhCsuwY/2LqLVzo6CezHXGcfD8tOyMWyL85LSmiSo32bUPlLDwimmOZJp xQEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788289509; x=1788894309; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ZxYVuNTHZtvBWJm7YqYSyMDBs6saulAawUQpfC7rrKY=; b=Q7S+W58BuC7kY7iSKpx2Lw7Fol+neYgj5rQdYCVR++w/XznNn0ZhzPt7rMNsnWgtBN +E6vwryufcxqSvEAO+w7xrOEOyrm+fOQwkR+Uqawmvr1ltjdTeYsg3MXyaImhB/69MbI i6fFTPz1unmgz9zmfCeJatL4+nLwQyVbj0xxko/3rA8KiwYVwp19e+sBWtRMFhB4XwNC a6rqzoskz/vbZ5zMEDOqCMnwtE4TzMv7EsoE0+CJDIGo+TSS07c6ys9iL6DBvVfRe5JF eTvTGDR0VRyoBQ8PBsktZ9ydmGmoxCyt63xDkCPAO41ZomAnkb73W8rl59KIUWy+IcTW J1UQ== X-Forwarded-Encrypted: i=1; AHgh+RoxywPp5O5OVMRrd/S24NQ/l2ZwMIR+FA34MRuq/TuXASc1UMRi9nl4M7B3KbQ/StPVvCxHe8JVWV6YV/g=@vger.kernel.org X-Gm-Message-State: AFuF++nEYLVBSd+pXL8niT3HFd/HlD20UvSuqKhZEWzzngG508Ta1f1h NLr3AJzZw0Wz7/OtZZwwZAhXoHvZSx03D4Yaib6wc4ni186bIKEGtZD9 X-Gm-Gg: AR+sD13Wkc/MOWIKgX0k+nLFngQQpcuXoj5YjJHN9cBKOecYyJFuRRpzY8LIg+A2rKd VFQeSb7ewD0WoG8ga5MMYbiZ1Da6cCj0AI6gHV1+LrfNSR8ncfhAUkcQ8Fd0S1jgC+6WPfTWy5u na2w64ZVMLB41O32/Be14iVK12q+9Vc03O7pqyfklO/pwuOyWKhu4RdBwRnS5PEfpwEfJyZNCC3 z8NDiluHNfARL07HpWQZp5nlSRapzKx0IgmZ5ck2VFhOR0cpN8kKcyLdHTmB+RQaGqq3f4ONRtY TIDR8TAIz9NNdgxDnGlm+CAJUdYLiDOk5N3t13oDmfRgyBi5IxxFH2uGhKIFmUWy5ZEBDGNwK3v iF8EnZ4qmLvN09nJOVs/5yI2CjCiYIemw0gS4Lh04pz5942YahiFfJfQXWEOyvxSwnzT14wifdf JGRwOAIygx1W3ScFmTXAiKE3ECUn0eTe/L4BUI2HQ0ONpRDMggCw0AT+kz6ZedYZXZn7iYqgNJF Fpz8pBpQVVTVuhlO+XtIY4HhvbaLeJZMk42Zl0m8g== X-Received: by 2002:a05:600c:530e:b0:49c:dd27:14b4 with SMTP id 5b1f17b1804b1-49cdd4200bamr136408575e9.7.1788289508839; Tue, 01 Sep 2026 12:05:08 -0700 (PDT) Received: from 1Z10 ([78.213.73.56]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cdce10148sm85481985e9.5.2026.09.01.12.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 12:05:08 -0700 (PDT) From: Maurizio Casciano To: mchehab@kernel.org, linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, bingbu.cao@amd.com, jacopo.mondi@ideasonboard.com, nicholas@rothemail.net, andy@kernel.org, andriy.shevchenko@intel.com, hansg@kernel.org, gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v6 14/16] media: atomisp: Use struct v4l2_area for padding Date: Tue, 1 Sep 2026 21:04:36 +0200 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The padding helper passes width and height as four separate scalar arguments even though they form two logical dimensions. Pass the requested size and returned padding as struct v4l2_area values. This makes the dimensions explicit and simplifies all three callers. Suggested-by: Andy Shevchenko Signed-off-by: Maurizio Casciano --- .../staging/media/atomisp/pci/atomisp_cmd.c | 68 +++++++++++-------- .../staging/media/atomisp/pci/atomisp_cmd.h | 6 +- .../staging/media/atomisp/pci/atomisp_ioctl.c | 15 ++-- .../media/atomisp/pci/atomisp_subdev.c | 4 +- .../media/atomisp/pci/atomisp_subdev.h | 3 +- 5 files changed, 53 insertions(+), 43 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 6cd500d9fd26..759effdb2e8d 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -3562,9 +3562,9 @@ static void atomisp_fill_pix_format(struct v4l2_pix_format *f, f->xfer_func = V4L2_XFER_FUNC_709; } -/* Get sensor padding values for the non padded width x height resolution */ -void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height, - u32 *padding_w, u32 *padding_h) +/* Get sensor padding values for the non-padded size */ +void atomisp_get_padding(struct atomisp_device *isp, struct v4l2_area size, + struct v4l2_area *pad) { struct atomisp_input_subdev *input = &isp->inputs[isp->asd.input_curr]; struct v4l2_rect native_rect = input->native_rect; @@ -3574,22 +3574,23 @@ void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height, struct v4l2_mbus_framefmt *sink; if (!input->crop_support) { - *padding_w = pad_w; - *padding_h = pad_h; + pad->width = pad_w; + pad->height = pad_h; return; } - width = min(width, input->active_rect.width); - height = min(height, input->active_rect.height); + size.width = min(size.width, input->active_rect.width); + size.height = min(size.height, input->active_rect.height); - if (input->binning_support && width <= (input->active_rect.width / 2) && - height <= (input->active_rect.height / 2)) { + if (input->binning_support && + size.width <= (input->active_rect.width / 2) && + size.height <= (input->active_rect.height / 2)) { native_rect.width /= 2; native_rect.height /= 2; } - *padding_w = min_t(u32, (native_rect.width - width) & ~1, pad_w); - *padding_h = min_t(u32, (native_rect.height - height) & ~1, pad_h); + pad->width = min_t(u32, (native_rect.width - size.width) & ~1, pad_w); + pad->height = min_t(u32, (native_rect.height - size.height) & ~1, pad_h); /* The below minimum padding requirements are for BYT / ISP2400 only */ if (IS_ISP2401) @@ -3617,8 +3618,18 @@ void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height, min_pad_h += 2; apply_min_padding: - *padding_w = max_t(u32, *padding_w, min_pad_w); - *padding_h = max_t(u32, *padding_h, min_pad_h); + pad->width = max_t(u32, pad->width, min_pad_w); + pad->height = max_t(u32, pad->height, min_pad_h); +} + +static inline void +atomisp_get_pix_padding(struct atomisp_device *isp, + struct v4l2_pix_format *f, + struct v4l2_area *pad) +{ + struct v4l2_area size = { .width = f->width, .height = f->height }; + + atomisp_get_padding(isp, size, pad); } int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool on) @@ -3800,7 +3811,7 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, const struct atomisp_format_bridge *fmt, *snr_fmt; struct atomisp_sub_device *asd = &isp->asd; struct v4l2_mbus_framefmt ffmt = { }; - u32 padding_w, padding_h; + struct v4l2_area padding; int ret; fmt = atomisp_get_format_bridge(f->pixelformat); @@ -3827,10 +3838,10 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, * resolution + padding. Add padding here and remove it again after * the set_fmt call, like atomisp_set_fmt_to_snr() does. */ - atomisp_get_padding(isp, f->width, f->height, &padding_w, &padding_h); + atomisp_get_pix_padding(isp, f, &padding); v4l2_fill_mbus_format(&ffmt, f, fmt->mbus_code); - ffmt.width += padding_w; - ffmt.height += padding_h; + ffmt.width += padding.width; + ffmt.height += padding.height; dev_dbg(isp->dev, "try_mbus_fmt: try %ux%u\n", ffmt.width, ffmt.height); @@ -3847,8 +3858,8 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, return -EINVAL; } - f->width = ffmt.width - padding_w; - f->height = ffmt.height - padding_h; + f->width = ffmt.width - padding.width; + f->height = ffmt.height - padding.height; /* * If the format is jpeg or custom RAW, then the width and height will @@ -4268,11 +4279,12 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, const struct v4l2_p return -EINVAL; v4l2_fill_mbus_format(&ffmt, f, format->mbus_code); - ffmt.height += asd->sink_pad_padding_h + dvs_env_h; - ffmt.width += asd->sink_pad_padding_w + dvs_env_w; + ffmt.height += asd->sink_pad_padding.height + dvs_env_h; + ffmt.width += asd->sink_pad_padding.width + dvs_env_w; dev_dbg(isp->dev, "s_mbus_fmt: ask %ux%u (padding %ux%u, dvs %ux%u)\n", - ffmt.width, ffmt.height, asd->sink_pad_padding_w, asd->sink_pad_padding_h, + ffmt.width, ffmt.height, asd->sink_pad_padding.width, + asd->sink_pad_padding.height, dvs_env_w, dvs_env_h); __atomisp_init_stream_info(ATOMISP_INPUT_STREAM_GENERAL, stream_info); @@ -4365,13 +4377,11 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f) V4L2_SUBDEV_FORMAT_ACTIVE, ATOMISP_SUBDEV_PAD_SOURCE, &isp_source_fmt); - if (atomisp_subdev_format_conversion(asd)) { - atomisp_get_padding(isp, f->fmt.pix.width, f->fmt.pix.height, - &asd->sink_pad_padding_w, &asd->sink_pad_padding_h); - } else { - asd->sink_pad_padding_w = 0; - asd->sink_pad_padding_h = 0; - } + if (atomisp_subdev_format_conversion(asd)) + atomisp_get_pix_padding(isp, &f->fmt.pix, + &asd->sink_pad_padding); + else + asd->sink_pad_padding = (struct v4l2_area) { }; atomisp_get_dis_envelop(asd, f->fmt.pix.width, f->fmt.pix.height, &dvs_env_w, &dvs_env_h); diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.h b/drivers/staging/media/atomisp/pci/atomisp_cmd.h index d3d1f2574e77..8a84e774f4d5 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.h +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.h @@ -225,9 +225,9 @@ int atomisp_makeup_css_parameters(struct atomisp_sub_device *asd, int atomisp_compare_grid(struct atomisp_sub_device *asd, struct atomisp_grid_info *atomgrid); -/* Get sensor padding values for the non padded width x height resolution */ -void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height, - u32 *padding_w, u32 *padding_h); +/* Get sensor padding values for the non-padded size */ +void atomisp_get_padding(struct atomisp_device *isp, struct v4l2_area size, + struct v4l2_area *pad); /* Set sensor power (no-op if already on/off) */ int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool on); diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 50366bf10f32..87c29a940f9b 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -457,7 +457,7 @@ static int atomisp_enum_framesizes_crop_inner(struct atomisp_device *isp, const struct v4l2_rect *native, int *valid_sizes) { - static const struct v4l2_frmsize_discrete frame_sizes[] = { + static const struct v4l2_area frame_sizes[] = { { 1920, 1440 }, { 1920, 1200 }, { 1920, 1080 }, @@ -470,15 +470,15 @@ static int atomisp_enum_framesizes_crop_inner(struct atomisp_device *isp, { 800, 600 }, { 640, 480 }, }; - u32 padding_w, padding_h; int i; for (i = 0; i < ARRAY_SIZE(frame_sizes); i++) { - atomisp_get_padding(isp, frame_sizes[i].width, frame_sizes[i].height, - &padding_w, &padding_h); + struct v4l2_area padding; - if ((frame_sizes[i].width + padding_w) > native->width || - (frame_sizes[i].height + padding_h) > native->height) + atomisp_get_padding(isp, frame_sizes[i], &padding); + + if ((frame_sizes[i].width + padding.width) > native->width || + (frame_sizes[i].height + padding.height) > native->height) continue; /* @@ -491,7 +491,8 @@ static int atomisp_enum_framesizes_crop_inner(struct atomisp_device *isp, if (*valid_sizes == fsize->index) { fsize->type = V4L2_FRMSIZE_TYPE_DISCRETE; - fsize->discrete = frame_sizes[i]; + fsize->discrete.width = frame_sizes[i].width; + fsize->discrete.height = frame_sizes[i].height; return 0; } diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index 9de9cd884d99..ad97e4691d9a 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -326,8 +326,8 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd, if (atomisp_subdev_format_conversion(isp_sd) && crop[pad]->width && crop[pad]->height) { - crop[pad]->width -= isp_sd->sink_pad_padding_w; - crop[pad]->height -= isp_sd->sink_pad_padding_h; + crop[pad]->width -= isp_sd->sink_pad_padding.width; + crop[pad]->height -= isp_sd->sink_pad_padding.height; } if (isp_sd->params.video_dis_en && diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.h b/drivers/staging/media/atomisp/pci/atomisp_subdev.h index b12bb65be3f2..0045f380de74 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.h +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.h @@ -214,8 +214,7 @@ struct atomisp_sub_device { struct media_pad pads[ATOMISP_SUBDEV_PADS_NUM]; struct atomisp_pad_format fmt[ATOMISP_SUBDEV_PADS_NUM]; /* Padding for currently set sink-pad fmt */ - u32 sink_pad_padding_w; - u32 sink_pad_padding_h; + struct v4l2_area sink_pad_padding; unsigned int output; struct atomisp_video_pipe video_out; -- 2.53.0