On Wed, Jun 07, 2023 at 06:47:07PM +0200, Hans de Goede 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. ... > + /* Limit set_fmt max size to crop width / height */ > + width = clamp_t(unsigned int, ALIGN(format->format.width, 2), > + OV2680_MIN_CROP_WIDTH, crop->width); > + height = clamp_t(unsigned int, ALIGN(format->format.height, 2), > + OV2680_MIN_CROP_HEIGHT, crop->height); I'm wondering if clamp_val() would work here. ... > + rect.left = clamp(ALIGN(sel->r.left, 2), OV2680_NATIVE_START_LEFT, > + OV2680_NATIVE_WIDTH); > + rect.top = clamp(ALIGN(sel->r.top, 2), OV2680_NATIVE_START_TOP, > + OV2680_NATIVE_HEIGHT); > + rect.width = clamp_t(unsigned int, ALIGN(sel->r.width, 2), > + OV2680_MIN_CROP_WIDTH, OV2680_NATIVE_WIDTH); > + rect.height = clamp_t(unsigned int, ALIGN(sel->r.height, 2), > + OV2680_MIN_CROP_HEIGHT, OV2680_NATIVE_HEIGHT); Ditto. -- With Best Regards, Andy Shevchenko