From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CF11EEC0; Sun, 4 Oct 2026 09:16:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791105416; cv=none; b=HNXE/Xk3ldozcCOnPrb1HWJ8IDfYz7iF6tK8BHm+uHo7xK6b4QJUIsdZMzQU6beQ9k2V0aitNVBFAoAESpB17SLAlFQNn61lbsZEqM5DNF+qQCbTZMRFWnuzWydf2LTVEhwf3ZJ3FFZslw865HmATThS5/Xxkwz/LrAP2ClqwkQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791105416; c=relaxed/simple; bh=s0J8jpGcFGHV4AOczf24YcjhD3jDp8gujvZpm6R3mgE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=s0xbp33mJOdHcuip7fMm9KYAxGXNPj6s6CI2kqyWP56pxrDmAOInz8+HnSXjJehd9es6ecS+P6c8vDdUpFnxsiBFHJZuclpfUK14mbKHEk0RfvPkJQqJ72+Ov+xG1arH5C3DVKs3yuX7x86wKWw549Xfu/LUvuSrS29qwpqSsdA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=UbUqdXNq; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UbUqdXNq" Received: from ideasonboard.com (unknown [93.65.100.155]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8154B82A; Sun, 4 Oct 2026 11:14:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1791105297; bh=s0J8jpGcFGHV4AOczf24YcjhD3jDp8gujvZpm6R3mgE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UbUqdXNq22Bd3vdEalzZri/OmoFahQqtvjYNmc75GldXAd2+55yPXYfcpnA/uDUk+ ld7MIwi8PgXRri8+xuj5BIBKudAXT8kct5/2u2EM89FrGJPq1shbzUMDPeb4ibmbOd Y2UXwUitL9YnQzvwJYH+ZxtCGoEsNpP/z31psVSY= Date: Sun, 4 Oct 2026 11:16:48 +0200 From: Jacopo Mondi To: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Cc: Niklas =?utf-8?Q?S=C3=B6derlund?= , Mauro Carvalho Chehab , Geert Uytterhoeven , Magnus Damm , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] media: rcar-vin: Implement VIDIOC_ENUM_FRMSIZES Message-ID: References: <20261001085304.85930-1-barnabas.pocze+renesas@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261001085304.85930-1-barnabas.pocze+renesas@ideasonboard.com> Hi Barnabás On Thu, Oct 01, 2026 at 10:53:04AM +0200, Barnabás Pőcze wrote: > Currently there is no way for applications to query the available frame > sizes, so implement `VIDIOC_ENUM_FRMSIZES` based on what is allowed in > `rvin_format_align()`. > > Signed-off-by: Barnabás Pőcze > Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi > --- > changes in v2: > * drop ` from title > > v1: https://lore.kernel.org/linux-media/20260929133720.344955-1-barnabas.pocze+renesas@ideasonboard.com/ > --- > .../platform/renesas/rcar-vin/rcar-v4l2.c | 70 ++++++++++++++----- > 1 file changed, 51 insertions(+), 19 deletions(-) > > diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c > index 9d45e11898c13..4961d28f42c78 100644 > --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c > +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c > @@ -19,6 +19,8 @@ > #include "rcar-vin.h" > > #define RVIN_DEFAULT_FORMAT V4L2_PIX_FMT_YUYV > +#define RVIN_MIN_WIDTH 5 > +#define RVIN_MIN_HEIGHT 2 > #define RVIN_DEFAULT_WIDTH 800 > #define RVIN_DEFAULT_HEIGHT 600 > #define RVIN_DEFAULT_FIELD V4L2_FIELD_NONE > @@ -187,6 +189,24 @@ static u32 rvin_format_sizeimage(struct v4l2_pix_format *pix) > } > } > > +static u32 rvin_format_width_alignment(u32 pixelformat) > +{ > + /* Hardware limits width alignment based on format. */ > + switch (pixelformat) { > + /* Multiple of 32 (2^5) for NV12/16. */ > + case V4L2_PIX_FMT_NV12: > + case V4L2_PIX_FMT_NV16: > + return 5; > + /* Multiple of 2 (2^1) for YUV. */ > + case V4L2_PIX_FMT_YUYV: > + case V4L2_PIX_FMT_UYVY: > + return 1; > + /* No multiple for RGB. */ > + default: > + return 0; > + } > +} > + > static void rvin_format_align(struct rvin_dev *vin, struct v4l2_pix_format *pix) > { > u32 walign; > @@ -208,27 +228,12 @@ static void rvin_format_align(struct rvin_dev *vin, struct v4l2_pix_format *pix) > break; > } > > - /* Hardware limits width alignment based on format. */ > - switch (pix->pixelformat) { > - /* Multiple of 32 (2^5) for NV12/16. */ > - case V4L2_PIX_FMT_NV12: > - case V4L2_PIX_FMT_NV16: > - walign = 5; > - break; > - /* Multiple of 2 (2^1) for YUV. */ > - case V4L2_PIX_FMT_YUYV: > - case V4L2_PIX_FMT_UYVY: > - walign = 1; > - break; > - /* No multiple for RGB. */ > - default: > - walign = 0; > - break; > - } > + walign = rvin_format_width_alignment(pix->pixelformat); > > /* Limit to VIN capabilities */ > - v4l_bound_align_image(&pix->width, 5, vin->info->max_width, walign, > - &pix->height, 2, vin->info->max_height, 0, 0); > + v4l_bound_align_image(&pix->width, RVIN_MIN_WIDTH, vin->info->max_width, walign, > + &pix->height, RVIN_MIN_HEIGHT, vin->info->max_height, 0, > + 0); > > pix->bytesperline = rvin_format_bytesperline(vin, pix); > pix->sizeimage = rvin_format_sizeimage(pix); > @@ -343,6 +348,32 @@ static int rvin_enum_fmt_vid_cap(struct file *file, void *priv, > return -EINVAL; > } > > +static int rvin_enum_framesizes(struct file *file, void *priv, > + struct v4l2_frmsizeenum *fsize) > +{ > + struct rvin_dev *vin = video_drvdata(file); > + u32 wstep; > + > + if (fsize->index != 0) > + return -EINVAL; > + > + if (!rvin_format_from_pixel(vin, fsize->pixel_format)) > + return -EINVAL; > + > + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; > + > + wstep = 1u << rvin_format_width_alignment(fsize->pixel_format); > + fsize->stepwise.min_width = round_up(RVIN_MIN_WIDTH, wstep); > + fsize->stepwise.max_width = vin->info->max_width; > + fsize->stepwise.step_width = wstep; > + > + fsize->stepwise.min_height = RVIN_MIN_HEIGHT; > + fsize->stepwise.max_height = vin->info->max_height; > + fsize->stepwise.step_height = 1; > + > + return 0; > +} > + > static int rvin_remote_rectangle(struct rvin_dev *vin, struct v4l2_rect *rect) > { > struct media_pad *pad = media_pad_remote_pad_first(&vin->pad); > @@ -564,6 +595,7 @@ static const struct v4l2_ioctl_ops rvin_mc_ioctl_ops = { > .vidioc_g_fmt_vid_cap = rvin_g_fmt_vid_cap, > .vidioc_s_fmt_vid_cap = rvin_mc_s_fmt_vid_cap, > .vidioc_enum_fmt_vid_cap = rvin_enum_fmt_vid_cap, > + .vidioc_enum_framesizes = rvin_enum_framesizes, > > .vidioc_g_selection = rvin_g_selection, > .vidioc_s_selection = rvin_s_selection, > -- > 2.55.0 > >