On Thu, Oct 06, 2022 at 03:57:16PM +0100, Dave Stevenson wrote: > Hi Jacopo > > On Wed, 5 Oct 2022 at 20:06, Jacopo Mondi <jacopo@xxxxxxxxxx> wrote: > > > > Change the largest visibile resolution to 2592x1944, which corresponds > > to the active pixel array area size. Take into account the horizontal > > and vertical limits when programming the visible sizes to skip > > dummy/inactive pixels. > > > > Signed-off-by: Jacopo Mondi <jacopo@xxxxxxxxxx> > > --- > > drivers/media/i2c/ar0521.c | 23 +++++++++++++++++------ > > 1 file changed, 17 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/media/i2c/ar0521.c b/drivers/media/i2c/ar0521.c > > index 581f5e42994d..2b19ba898ce8 100644 > > --- a/drivers/media/i2c/ar0521.c > > +++ b/drivers/media/i2c/ar0521.c > > @@ -28,10 +28,17 @@ > > #define AR0521_PIXEL_CLOCK_MIN (168 * 1000 * 1000) > > #define AR0521_PIXEL_CLOCK_MAX (414 * 1000 * 1000) > > > > +#define AR0521_NATIVE_WIDTH 2604u > > +#define AR0521_NATIVE_HEIGHT 1964u > > +#define AR0521_MIN_X_ADDR_START 4u > > +#define AR0521_MIN_Y_ADDR_START 4u > > +#define AR0521_MAX_X_ADDR_END 2603u > > +#define AR0521_MAX_Y_ADDR_END 1963u > > The register list I have (downloaded from OnSemi today) states that > y_addr_max is 0x07a3, or 1955, readable from register 0x1186. And it also states, in the documentation of y_addr_start, that legal values are [0, 2463]. Who do we trust ? :-) [0, 2463] sounds like a copy & paste mistake to me. Another data point is from the developer guide, which states on the first page that the maximum values for x_addr_start and y_addr_start are 2603 and 1963 respectively. 2603 matches the documentation of x_addr_max. It would be useful to dump the limits registers (0x1000 - 0x1300). > Otherwise this looks reasonable. > > > + > > #define AR0521_WIDTH_MIN 8u > > -#define AR0521_WIDTH_MAX 2608u > > +#define AR0521_WIDTH_MAX 2592u > > #define AR0521_HEIGHT_MIN 8u > > -#define AR0521_HEIGHT_MAX 1958u > > +#define AR0521_HEIGHT_MAX 1944u > > > > #define AR0521_WIDTH_BLANKING_MIN 572u > > #define AR0521_HEIGHT_BLANKING_MIN 38u /* must be even */ > > @@ -208,13 +215,17 @@ static int ar0521_read_reg(struct ar0521_dev *sensor, u16 reg, u16 *val) > > > > static int ar0521_set_geometry(struct ar0521_dev *sensor) > > { > > + /* Center the image in the visible ouput window. */ > > + u16 x = clamp((AR0521_WIDTH_MAX - sensor->fmt.width) / 2, > > + AR0521_MIN_X_ADDR_START, AR0521_MAX_X_ADDR_END); > > + u16 y = clamp(((AR0521_HEIGHT_MAX - sensor->fmt.height) / 2) & ~1, > > + AR0521_MIN_Y_ADDR_START, AR0521_MAX_Y_ADDR_END); > > + > > /* All dimensions are unsigned 12-bit integers */ > > - u16 x = (AR0521_WIDTH_MAX - sensor->fmt.width) / 2; > > - u16 y = ((AR0521_HEIGHT_MAX - sensor->fmt.height) / 2) & ~1; > > __be16 regs[] = { > > be(AR0521_REG_FRAME_LENGTH_LINES), > > - be(sensor->total_height), > > - be(sensor->total_width), > > + be(sensor->fmt.height + sensor->ctrls.vblank->val), > > + be(sensor->fmt.width + sensor->ctrls.hblank->val), > > be(x), > > be(y), > > be(x + sensor->fmt.width - 1), -- Regards, Laurent Pinchart