Message ID | 20230802173046.368434-1-hdegoede@redhat.com |
---|---|
Headers | show |
Series | media: ov2680: Bugfixes + ACPI + selection(crop-tgt) API support | expand |
On Wed, Aug 2, 2023 at 8:31 PM Hans de Goede <hdegoede@redhat.com> wrote: > > Implement selection support. Modelled after ov5693 selection support, > but allow setting sizes smaller than crop-size through set_fmt() since > that was already allowed. ... > struct ov2680_mode { > + struct v4l2_rect crop; > struct v4l2_mbus_framefmt fmt; > struct v4l2_fract frame_interval; > bool binning; > }; It might be useful to run pahole to check if you can make it shorter and for how many bytes. ... > - width = min_t(unsigned int, ALIGN(format->format.width, 2), > - OV2680_NATIVE_WIDTH); > - height = min_t(unsigned int, ALIGN(format->format.height, 2), > - OV2680_NATIVE_HEIGHT); Ah, short-live min_t(), but still... ... > + /* Make sure the crop rectangle isn't outside the bounds of the array */ > + rect.width = min_t(unsigned int, rect.width, > + OV2680_NATIVE_WIDTH - rect.left); > + rect.height = min_t(unsigned int, rect.height, > + OV2680_NATIVE_HEIGHT - rect.top); And here?
Hi, On 8/3/23 11:17, Hans de Goede wrote: > Hi, > > On 8/2/23 21:37, Andy Shevchenko wrote: <snip> >>> + width = min_t(unsigned int, ALIGN(format->format.width, 2), >>> + OV2680_NATIVE_WIDTH); >>> + height = min_t(unsigned int, ALIGN(format->format.height, 2), >>> + OV2680_NATIVE_HEIGHT); >> >> Wondering if you can switch these to use min() (with a strict type checking). >> It might require adding U/UL to the respective constants. > > > I'll try to switch to regular min() use here for v5. Ok, so I tried and failed. format->format.height is an __u32 and even if I add a 'u' suffix to OV2680_NATIVE_WIDTH regular min() does not like it: drivers/media/i2c/ov2680.c: In function ‘ov2680_calc_mode’: ./include/linux/minmax.h:20:35: warning: comparison of distinct pointer types lacks a cast 20 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) | ^~ Regards, Hans