libcamera: Fix setParameters crash when opening front camera.

bug fix: Duplicated setting of cameraid is caused that
         setParameters fail. So, operations about setting of camera
         id are moved for setting once.

bug:3512875

Change-Id: I48d0847644525a658b4415fffcf2910a83a65e43
Signed-off-by: Jeong-Seok Yang <jseok.yang@samsung.com>
diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp
index e17c878..4d0705a 100755
--- a/libcamera/SecCamera.cpp
+++ b/libcamera/SecCamera.cpp
@@ -736,6 +736,22 @@
 
         m_camera_id = index;
 
+        switch (m_camera_id) {
+        case CAMERA_ID_FRONT:
+            m_preview_max_width   = MAX_FRONT_CAMERA_PREVIEW_WIDTH;
+            m_preview_max_height  = MAX_FRONT_CAMERA_PREVIEW_HEIGHT;
+            m_snapshot_max_width  = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH;
+            m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT;
+            break;
+
+        case CAMERA_ID_BACK:
+            m_preview_max_width   = MAX_BACK_CAMERA_PREVIEW_WIDTH;
+            m_preview_max_height  = MAX_BACK_CAMERA_PREVIEW_HEIGHT;
+            m_snapshot_max_width  = MAX_BACK_CAMERA_SNAPSHOT_WIDTH;
+            m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT;
+            break;
+        }
+
         setExifFixedAttribute();
 
         m_flag_init = 1;
@@ -1615,40 +1631,6 @@
 // ======================================================================
 // Settings
 
-int SecCamera::setCameraId(int camera_id)
-{
-    if ((camera_id != CAMERA_ID_FRONT) && (camera_id != CAMERA_ID_BACK)) {
-        LOGE("ERR(%s)::Invalid camera id(%d)\n", __func__, camera_id);
-        return -1;
-    }
-    if (m_camera_id == camera_id)
-        return 0;
-
-    LOGV("%s(camera_id(%d))", __func__, camera_id);
-
-    switch (camera_id) {
-    case CAMERA_ID_FRONT:
-        m_preview_max_width   = MAX_FRONT_CAMERA_PREVIEW_WIDTH;
-        m_preview_max_height  = MAX_FRONT_CAMERA_PREVIEW_HEIGHT;
-        m_snapshot_max_width  = MAX_FRONT_CAMERA_SNAPSHOT_WIDTH;
-        m_snapshot_max_height = MAX_FRONT_CAMERA_SNAPSHOT_HEIGHT;
-        break;
-
-    case CAMERA_ID_BACK:
-        m_preview_max_width   = MAX_BACK_CAMERA_PREVIEW_WIDTH;
-        m_preview_max_height  = MAX_BACK_CAMERA_PREVIEW_HEIGHT;
-        m_snapshot_max_width  = MAX_BACK_CAMERA_SNAPSHOT_WIDTH;
-        m_snapshot_max_height = MAX_BACK_CAMERA_SNAPSHOT_HEIGHT;
-        break;
-    }
-
-    m_camera_id = camera_id;
-
-    resetCamera();
-
-    return 0;
-}
-
 int SecCamera::getCameraId(void)
 {
     return m_camera_id;
diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h
index f3a2166..c87a0f4 100644
--- a/libcamera/SecCamera.h
+++ b/libcamera/SecCamera.h
@@ -284,7 +284,6 @@
     int             flagCreate(void) const;
 
 
-    int             setCameraId(int camera_id);
     int             getCameraId(void);
 
     int             startPreview(void);
diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp
index 137653a..4a5b012 100644
--- a/libcamera/SecCameraHWInterface.cpp
+++ b/libcamera/SecCameraHWInterface.cpp
@@ -156,8 +156,6 @@
     int snapshot_max_width  = 0;
     int snapshot_max_height = 0;
 
-    /* set camera ID & reset camera */
-    mSecCamera->setCameraId(cameraId);
     if (cameraId == SecCamera::CAMERA_ID_BACK) {
         p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES,
               "720x480,640x480,352x288,176x144");