- struct v4l2_pix_format *pix = &f->fmt.pix;
- bool bayer = pix->pixelformat == V4L2_PIX_FMT_UYVY ||
- pix->pixelformat == V4L2_PIX_FMT_YUYV;
-
- /*
- * With Bayer format enforce even side lengths, but let the user play
- * with the starting pixel
- */
-
- if (pix->height > SENSOR_MAX_HEIGHT)
- pix->height = SENSOR_MAX_HEIGHT;
- else if (pix->height < SENSOR_MIN_HEIGHT)
- pix->height = SENSOR_MIN_HEIGHT;
- else if (bayer)
- pix->height = ALIGN(pix->height, 2);
-
- if (pix->width > SENSOR_MAX_WIDTH)
- pix->width = SENSOR_MAX_WIDTH;
- else if (pix->width < SENSOR_MIN_WIDTH)
- pix->width = SENSOR_MIN_WIDTH;
- else if (bayer)
- pix->width = ALIGN(pix->width, 2);
+ struct i2c_client *client = v4l2_get_subdevdata(sd);
+ struct sensor *sensor = to_sensor(client);
+ const struct sensor_datafmt *fmt;
+ int ret = 0,set_w,set_h;
+
+ fmt = sensor_find_datafmt(mf->code, sensor_colour_fmts,
+ ARRAY_SIZE(sensor_colour_fmts));
+ if (fmt == NULL) {
+ fmt = &sensor->info_priv.fmt;
+ mf->code = fmt->code;
+ }
+
+ if (mf->height > SENSOR_MAX_HEIGHT)
+ mf->height = SENSOR_MAX_HEIGHT;
+ else if (mf->height < SENSOR_MIN_HEIGHT)
+ mf->height = SENSOR_MIN_HEIGHT;
+
+ if (mf->width > SENSOR_MAX_WIDTH)
+ mf->width = SENSOR_MAX_WIDTH;
+ else if (mf->width < SENSOR_MIN_WIDTH)
+ mf->width = SENSOR_MIN_WIDTH;
+
+ set_w = mf->width;
+ set_h = mf->height;