make use of the format.rect boundery values
Signed-off-by: Philipp Wiesner <[email protected]>
Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/media/video/mt9m111.c | 41 +++++++++++++++++++----------------------
1 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/drivers/media/video/mt9m111.c b/drivers/media/video/mt9m111.c
index 799a735..f472ca1 100644
--- a/drivers/media/video/mt9m111.c
+++ b/drivers/media/video/mt9m111.c
@@ -733,35 +733,32 @@ static int mt9m111_try_fmt(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *mf)
{
struct i2c_client *client = sd->priv;
+ struct mt9m111 *mt9m111 = to_mt9m111(client);
+ struct v4l2_rect rect = mt9m111->format.rect;
const struct mt9m111_datafmt *fmt;
- bool bayer = mf->code == V4L2_MBUS_FMT_SBGGR8_1X8 ||
- mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE;
fmt = mt9m111_find_datafmt(mf->code, mt9m111_colour_fmts,
ARRAY_SIZE(mt9m111_colour_fmts));
if (!fmt)
return -EINVAL;
- /*
- * With Bayer format enforce even side lengths, but let the user play
- * with the starting pixel
- */
+ mf->code = fmt->code;
+ mf->colorspace = fmt->colorspace;
+ mf->field = V4L2_FIELD_NONE;
- if (mf->height > MT9M111_MAX_HEIGHT)
- mf->height = MT9M111_MAX_HEIGHT;
- else if (mf->height < 2)
- mf->height = 2;
- else if (bayer)
- mf->height = ALIGN(mf->height, 2);
-
- if (mf->width > MT9M111_MAX_WIDTH)
- mf->width = MT9M111_MAX_WIDTH;
- else if (mf->width < 2)
- mf->width = 2;
- else if (bayer)
- mf->width = ALIGN(mf->width, 2);
-
- mf->colorspace = fmt->colorspace;
+ if (mf->code == V4L2_MBUS_FMT_SBGGR10_2X8_PADHI_LE) {
+ mf->width = rect.width;
+ mf->height = rect.height;
+ } else {
+ if (mf->width > rect.width)
+ mf->width = rect.width;
+ if (mf->height > rect.height)
+ mf->height = rect.height;
+ }
+
+ dev_dbg(&client->dev, "%s: mf: width=%d height=%d pixelcode=%d "
+ "field=%x colorspace=%x\n", __func__, mf->width, mf->height,
+ mf->code, mf->field, mf->colorspace);
return 0;
}
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html