/* set the format we will capture in */ static int ov9640_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov9640_reg_alt alts = {0}; int ret; ov9640_alter_regs(mf->code, &alts); ov9640_reset(client); ret = ov9640_prog_dflt(client); if (ret) return ret; return ov9640_write_regs(client, mf->width, mf->code, &alts); }
/* set the format we will capture in */ static int ov9640_s_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *mf) { struct i2c_client *client = v4l2_get_subdevdata(sd); struct ov9640_reg_alt alts = {0}; enum v4l2_colorspace cspace; enum v4l2_mbus_pixelcode code = mf->code; int ret; ov9640_res_roundup(&mf->width, &mf->height); ov9640_alter_regs(mf->code, &alts); ov9640_reset(client); ret = ov9640_prog_dflt(client); if (ret) return ret; switch (code) { case V4L2_MBUS_FMT_RGB555_2X8_PADHI_LE: case V4L2_MBUS_FMT_RGB565_2X8_LE: cspace = V4L2_COLORSPACE_SRGB; break; default: code = V4L2_MBUS_FMT_UYVY8_2X8; case V4L2_MBUS_FMT_UYVY8_2X8: cspace = V4L2_COLORSPACE_JPEG; } ret = ov9640_write_regs(client, mf->width, code, &alts); if (!ret) { mf->code = code; mf->colorspace = cspace; } return ret; }