Update camera mode switch mechanism

During mode change (resolution, framerate), as long as there's v_blank,
h_blank, and system clk update, the exposure time and gain would need
to be recomputed. The original conditional check was too simple and
incorrect. Since the call only happens at v4l VIDIOC_S_PARM ioctl, we
should be okay of not using the direct mode change at all.

In addition, the AE register need to be turned back on after the
exposure update. This was updated in upstream NxP codebase for a later
ov5647 driver, but never fixed in ov5640 version.

Bug: 144574941
Test: Columbia and Enterprise v4l with various resolutions and changing sequences.

Change-Id: Ic631472c872f550d75868e0867b1a9cbe6d3b698
diff --git a/drivers/media/platform/mxc/capture/ov5645_mipi_v2.c b/drivers/media/platform/mxc/capture/ov5645_mipi_v2.c
index 6ae6aa3..ab8da94 100644
--- a/drivers/media/platform/mxc/capture/ov5645_mipi_v2.c
+++ b/drivers/media/platform/mxc/capture/ov5645_mipi_v2.c
@@ -2895,11 +2895,14 @@
 	}
 	OV5645_set_shutter(cap_shutter);
 
+	/* turn on AE/AG */
+	OV5645_turn_on_AE_AG(1);
+
 err:
 	return retval;
 }
 
-/* if sensor changes inside scaling or subsampling
+/* if sensor changes inside the same cap_sysclk, HTS, and VTS,
  * change mode directly
  * */
 static int ov5645_change_mode_direct(enum ov5645_frame_rate frame_rate,
@@ -2976,15 +2979,8 @@
 
 		ov5645_dnld_af_fw();
 
-	} else if ((dn_mode == SUBSAMPLING && orig_dn_mode == SCALING) ||
-			(dn_mode == SCALING && orig_dn_mode == SUBSAMPLING)) {
-		/* change between subsampling and scaling
-		 * go through exposure calucation */
-		retval = ov5645_change_mode_exposure_calc(frame_rate, mode);
 	} else {
-		/* change inside subsampling or scaling
-		 * download firmware directly */
-		retval = ov5645_change_mode_direct(frame_rate, mode);
+		retval = ov5645_change_mode_exposure_calc(frame_rate, mode);
 	}
 
 	if (retval < 0)