Message ID | 20240604105335.2257629-1-devarsht@ti.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Add V4L2 M2M Driver for E5010 JPEG Encoder | expand |
Hey, On 04.06.2024 16:23, Devarsh Thakkar wrote: >If neither of the flags to round down (V4L2_SEL_FLAG_LE) or round up >(V4L2_SEL_FLAG_GE) are specified by the user, then round to nearest >multiple of requested value while updating the crop rectangle coordinates. > >Use the rounding macro which gives preference to rounding down in case two >nearest values (high and low) are possible to raise the probability of >cropping rectangle falling inside the bound region. > >This complies with the VIDIOC_G_SELECTION, VIDIOC_S_SELECTION ioctl >description as documented in v4l uapi [1] which specifies that driver >should choose crop rectangle as close as possible if no flags are passed by >user-space, as quoted below : > >"``0`` - The driver can adjust the rectangle size freely and shall choose a >crop/compose rectangle as close as possible to the requested > one." > >Link: https://www.kernel.org/doc/Documentation/userspace-api/media/v4l/vidioc-g-selection.rst [1] >Signed-off-by: Devarsh Thakkar <devarsht@ti.com> Acked-by: Sebastian Fricke <sebastian.fricke@collabora.com> Can, whoever picks up the math changes, pick up this change as well? I will send 1-6 via the media subsystem. Regards, Sebastian >--- >V12: No change >V11: No change >V10: No change >V9: No change >V8: Update commit message with specification reference >V1->V7 (No change, patch introduced in V7) >--- > drivers/media/platform/imagination/e5010-jpeg-enc.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > >diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c >index e701d573a26a..d65646f0c38c 100644 >--- a/drivers/media/platform/imagination/e5010-jpeg-enc.c >+++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c >@@ -517,10 +517,10 @@ static int e5010_s_selection(struct file *file, void *fh, struct v4l2_selection > > switch (s->flags) { > case 0: >- s->r.width = round_down(s->r.width, queue->fmt->frmsize.step_width); >- s->r.height = round_down(s->r.height, queue->fmt->frmsize.step_height); >- s->r.left = round_down(s->r.left, queue->fmt->frmsize.step_width); >- s->r.top = round_down(s->r.top, 2); >+ s->r.width = round_closest_down(s->r.width, queue->fmt->frmsize.step_width); >+ s->r.height = round_closest_down(s->r.height, queue->fmt->frmsize.step_height); >+ s->r.left = round_closest_down(s->r.left, queue->fmt->frmsize.step_width); >+ s->r.top = round_closest_down(s->r.top, 2); > > if (s->r.left + s->r.width > queue->width) > s->r.width = round_down(s->r.width + s->r.left - queue->width, >-- >2.39.1 >
Hi Sebastian Thanks for the update. On 06/06/24 17:14, Sebastian Fricke wrote: > Hey, > > On 04.06.2024 16:23, Devarsh Thakkar wrote: >> If neither of the flags to round down (V4L2_SEL_FLAG_LE) or round up >> (V4L2_SEL_FLAG_GE) are specified by the user, then round to nearest >> multiple of requested value while updating the crop rectangle coordinates. >> >> Use the rounding macro which gives preference to rounding down in case two >> nearest values (high and low) are possible to raise the probability of >> cropping rectangle falling inside the bound region. >> >> This complies with the VIDIOC_G_SELECTION, VIDIOC_S_SELECTION ioctl >> description as documented in v4l uapi [1] which specifies that driver >> should choose crop rectangle as close as possible if no flags are passed by >> user-space, as quoted below : >> >> "``0`` - The driver can adjust the rectangle size freely and shall choose a >> crop/compose rectangle as close as possible to the requested >> one." >> >> Link: >> https://www.kernel.org/doc/Documentation/userspace-api/media/v4l/vidioc-g-selection.rst [1] >> Signed-off-by: Devarsh Thakkar <devarsht@ti.com> > > Acked-by: Sebastian Fricke <sebastian.fricke@collabora.com> > > Can, whoever picks up the math changes, pick up this change as well? > I will send 1-6 via the media subsystem. > For [PATCH 1/13] to [PATCH 6/13] patches from the series, I see few warnings reported to me offline for some of the patches which were caught from using smatch/sparse related automation scripts which were somehow missed by my equivalent test script. The fixes should be trivial though and I will be rolling out a v13 soon to fix them up. The rest of the patches (PATCH 7/13 to PATCH 13/13) no smatch/sparse related warnings were caught for these though, and are good to go in. Although, I can still include them in V13 too just to avoid any confusion. Regards Devarsh
On Thu, Jun 06, 2024 at 01:44:59PM +0200, Sebastian Fricke wrote: > Hey, > > On 04.06.2024 16:23, Devarsh Thakkar wrote: > > If neither of the flags to round down (V4L2_SEL_FLAG_LE) or round up > > (V4L2_SEL_FLAG_GE) are specified by the user, then round to nearest > > multiple of requested value while updating the crop rectangle coordinates. > > > > Use the rounding macro which gives preference to rounding down in case two > > nearest values (high and low) are possible to raise the probability of > > cropping rectangle falling inside the bound region. > > > > This complies with the VIDIOC_G_SELECTION, VIDIOC_S_SELECTION ioctl > > description as documented in v4l uapi [1] which specifies that driver > > should choose crop rectangle as close as possible if no flags are passed by > > user-space, as quoted below : > > > > "``0`` - The driver can adjust the rectangle size freely and shall choose a > > crop/compose rectangle as close as possible to the requested > > one." > > > > Link: https://www.kernel.org/doc/Documentation/userspace-api/media/v4l/vidioc-g-selection.rst [1] > > Signed-off-by: Devarsh Thakkar <devarsht@ti.com> > > Acked-by: Sebastian Fricke <sebastian.fricke@collabora.com> > > Can, whoever picks up the math changes, pick up this change as well? > I will send 1-6 via the media subsystem. math.h is orphaned, meaning any Tier-1 maintainer may push this through. So, there is nobody behind it.
diff --git a/drivers/media/platform/imagination/e5010-jpeg-enc.c b/drivers/media/platform/imagination/e5010-jpeg-enc.c index e701d573a26a..d65646f0c38c 100644 --- a/drivers/media/platform/imagination/e5010-jpeg-enc.c +++ b/drivers/media/platform/imagination/e5010-jpeg-enc.c @@ -517,10 +517,10 @@ static int e5010_s_selection(struct file *file, void *fh, struct v4l2_selection switch (s->flags) { case 0: - s->r.width = round_down(s->r.width, queue->fmt->frmsize.step_width); - s->r.height = round_down(s->r.height, queue->fmt->frmsize.step_height); - s->r.left = round_down(s->r.left, queue->fmt->frmsize.step_width); - s->r.top = round_down(s->r.top, 2); + s->r.width = round_closest_down(s->r.width, queue->fmt->frmsize.step_width); + s->r.height = round_closest_down(s->r.height, queue->fmt->frmsize.step_height); + s->r.left = round_closest_down(s->r.left, queue->fmt->frmsize.step_width); + s->r.top = round_closest_down(s->r.top, 2); if (s->r.left + s->r.width > queue->width) s->r.width = round_down(s->r.width + s->r.left - queue->width,
If neither of the flags to round down (V4L2_SEL_FLAG_LE) or round up (V4L2_SEL_FLAG_GE) are specified by the user, then round to nearest multiple of requested value while updating the crop rectangle coordinates. Use the rounding macro which gives preference to rounding down in case two nearest values (high and low) are possible to raise the probability of cropping rectangle falling inside the bound region. This complies with the VIDIOC_G_SELECTION, VIDIOC_S_SELECTION ioctl description as documented in v4l uapi [1] which specifies that driver should choose crop rectangle as close as possible if no flags are passed by user-space, as quoted below : "``0`` - The driver can adjust the rectangle size freely and shall choose a crop/compose rectangle as close as possible to the requested one." Link: https://www.kernel.org/doc/Documentation/userspace-api/media/v4l/vidioc-g-selection.rst [1] Signed-off-by: Devarsh Thakkar <devarsht@ti.com> --- V12: No change V11: No change V10: No change V9: No change V8: Update commit message with specification reference V1->V7 (No change, patch introduced in V7) --- drivers/media/platform/imagination/e5010-jpeg-enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)