SP5C11X: libcamera: #ifdef/#defines cleanup

Remove a bunch of #ifdef conditionals to cleanup the code.  The #else
cases have generally not been tested for months now and we don't use
them, and this makes it easier to follow for the next round of logic
cleanup coming up.

Change-Id: I4a78901916ed9393ef9b904a1e8037cd645be3b4
Signed-off-by: Mike J. Chen <mjchen@sta.samsung.com>
diff --git a/libcamera/Android.mk b/libcamera/Android.mk
index ebbd37b..7e58b2b 100644
--- a/libcamera/Android.mk
+++ b/libcamera/Android.mk
@@ -9,8 +9,6 @@
 
 LOCAL_CFLAGS:=-fno-short-enums
 LOCAL_CFLAGS+=-DDLOPEN_LIBSECCAMERA=$(DLOPEN_LIBSECCAMERA)
-LOCAL_CFLAGS += -DSWP1_CAMERA_ADD_ADVANCED_FUNCTION
-
 
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
 LOCAL_C_INCLUDES += $(LOCAL_PATH)/../libs3cjpeg
@@ -25,15 +23,6 @@
 LOCAL_SHARED_LIBRARIES+= libs3cjpeg
 LOCAL_SHARED_LIBRARIES+= libcamera_client
 
-#Enable the below code to show the video output (without GUI) on TV
-#ifeq ($(BOARD_USES_HDMI), true)
-#LOCAL_CFLAGS+=-DENABLE_HDMI_DISPLAY \
-#        -DBOARD_HDMI_STD=$(BOARD_HDMI_STD)
-#
-#LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
-#LOCAL_SHARED_LIBRARIES+= libhdmi
-#endif
-
 ifeq ($(BOARD_USES_OVERLAY),true)
 LOCAL_CFLAGS += -DBOARD_USES_OVERLAY
 endif
diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp
index 6f14198..38f675c 100755
--- a/libcamera/SecCamera.cpp
+++ b/libcamera/SecCamera.cpp
@@ -25,7 +25,6 @@
 
 //#define LOG_NDEBUG 0
 #define LOG_TAG "SecCamera"
-#define ADD_THUMB_IMG 1
 
 #include <utils/Log.h>
 
@@ -37,9 +36,6 @@
 
 using namespace android;
 
-//#define PERFORMANCE //Uncomment to measure performance
-//#define DUMP_YUV    //Uncomment to take a dump of YUV frame during capture
-
 #define CHECK(return_value)                                          \
     if (return_value < 0) {                                          \
         LOGE("%s::%d fail. errno: %s, m_camera_id = %d\n",           \
@@ -85,27 +81,6 @@
     return time;
 }
 
-static inline unsigned long check_performance()
-{
-    unsigned long time = 0;
-    static unsigned long max = 0;
-    static unsigned long min = 0xffffffff;
-
-    if (time_start.tv_sec == 0 && time_start.tv_usec == 0) {
-        gettimeofday(&time_start, NULL);
-    } else {
-        gettimeofday(&time_stop, NULL);
-        time = measure_time(&time_start, &time_stop);
-        if (max < time) max = time;
-        if (min > time) min = time;
-        LOGV("Interval: %lu us (%2.2lf fps), min:%2.2lf fps, max:%2.2lf fps\n",
-                time, 1000000.0 / time, 1000000.0 / max, 1000000.0 / min);
-        gettimeofday(&time_start, NULL);
-    }
-
-    return time;
-}
-
 static int close_buffers(struct fimc_buffer *buffers)
 {
     int i;
@@ -203,7 +178,6 @@
     return ret;
 }
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
 static int fimc_esd_poll(struct pollfd *events)
 {
     int ret;
@@ -222,44 +196,6 @@
 
     return ret;
 }
-#endif  /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
-
-#ifdef DUMP_YUV
-static int save_yuv(struct fimc_buffer *m_buffers_c, int width, int height, int depth, int index, int frame_count)
-{
-    FILE *yuv_fp = NULL;
-    char filename[100], *buffer = NULL;
-
-    /* file create/open, note to "wb" */
-    yuv_fp = fopen("/data/main.yuv", "wb");
-    if (yuv_fp == NULL) {
-        LOGE("Save YUV] file open error");
-        return -1;
-    }
-
-    buffer = (char *) malloc(m_buffers_c[index].length);
-    if (buffer == NULL) {
-        LOGE("Save YUV] buffer alloc failed");
-        if (yuv_fp) fclose(yuv_fp);
-        return -1;
-    }
-
-    memcpy(buffer, m_buffers_c[index].start, m_buffers_c[index].length);
-
-    fflush(stdout);
-
-    fwrite(buffer, 1, m_buffers_c[index].length, yuv_fp);
-
-    fflush(yuv_fp);
-
-    if (yuv_fp)
-        fclose(yuv_fp);
-    if (buffer)
-        free(buffer);
-
-    return 0;
-}
-#endif //DUMP_YUV
 
 static int fimc_v4l2_querycap(int fp)
 {
@@ -444,18 +380,6 @@
             }
 
             //LOGV("buffers[%d].start = %p v4l2_buf.length = %d", i, buffers[i].start, v4l2_buf.length);
-        } else {
-
-#if defined DUMP_YUV || defined (SEND_YUV_RECORD_DATA)
-            buffers[i].length = v4l2_buf.length;
-            if ((buffers[i].start = (char *)mmap(0, v4l2_buf.length, PROT_READ | PROT_WRITE, MAP_SHARED,
-                                                    fp, v4l2_buf.m.offset)) < 0) {
-                LOGE("%s %d] mmap() failed\n",__func__, __LINE__);
-                return -1;
-            }
-
-            //LOGV("buffers[%d].start = %p v4l2_buf.length = %d", i, buffers[i].start, v4l2_buf.length);
-#endif
         }
     }
 
@@ -481,9 +405,7 @@
     enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
     int ret;
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     LOGV("%s :", __func__);
-#endif
     ret = ioctl(fp, VIDIOC_STREAMOFF, &type);
     if (ret < 0) {
         LOGE("ERR(%s):VIDIOC_STREAMOFF failed\n", __func__);
@@ -564,7 +486,6 @@
     return ctrl.value;
 }
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
 static int fimc_v4l2_s_ext_ctrl(int fp, unsigned int id, void *value)
 {
     struct v4l2_ext_controls ctrls;
@@ -584,7 +505,6 @@
 
     return ret;
 }
-#endif
 
 static int fimc_v4l2_g_parm(int fp, struct v4l2_streamparm *streamparm)
 {
@@ -637,7 +557,6 @@
             m_snapshot_max_width  (MAX_BACK_CAMERA_SNAPSHOT_WIDTH),
             m_snapshot_max_height (MAX_BACK_CAMERA_SNAPSHOT_HEIGHT),
             m_angle(-1),
-            #ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
             m_anti_banding(-1),
             m_wdr(-1),
             m_anti_shake(-1),
@@ -660,9 +579,6 @@
             m_video_gamma(-1),
             m_slow_ae(-1),
             m_camera_af_flag(-1),
-            #else
-            m_autofocus(-1),
-            #endif
             m_flag_camera_start(0),
             m_jpeg_thumbnail_width (0),
             m_jpeg_thumbnail_height(0),
@@ -714,25 +630,12 @@
          */
         m_camera_af_flag = -1;
 
-#ifndef JPEG_FROM_SENSOR
-        m_jpeg_fd = SsbSipJPEGEncodeInit();
-        LOGD("(%s):JPEG device open ID = %d\n", __func__, m_jpeg_fd);
-        if (m_jpeg_fd < 0) {
-            m_jpeg_fd = 0;
-            LOGE("ERR(%s):Cannot open a jpeg device file\n", __func__);
-            return -1;
-        }
-#endif
-
         m_cam_fd_temp = -1;
         m_cam_fd2_temp = -1;
 
         m_cam_fd = open(CAMERA_DEV_NAME, O_RDWR);
         if (m_cam_fd < 0) {
             LOGE("ERR(%s):Cannot open %s (error : %s)\n", __func__, CAMERA_DEV_NAME, strerror(errno));
-#ifndef JPEG_FROM_SENSOR
-            SsbSipJPEGEncodeDeInit(m_jpeg_fd);
-#endif
             return -1;
         }
 
@@ -774,7 +677,6 @@
         ret = fimc_v4l2_s_input(m_cam_fd, index);
         CHECK(ret);
 
-#ifdef DUAL_PORT_RECORDING
         m_cam_fd2 = open(CAMERA_DEV_NAME2, O_RDWR);
         if (m_cam_fd2 < 0) {
             LOGE("ERR(%s):Cannot open %s (error : %s)\n", __func__, CAMERA_DEV_NAME2, strerror(errno));
@@ -829,7 +731,7 @@
             return -1;
         ret = fimc_v4l2_s_input(m_cam_fd2, index);
         CHECK(ret);
-#endif
+
         m_camera_id = index;
 
         setExifFixedAttribute();
@@ -851,35 +753,23 @@
     LOGV("%s :", __func__);
 
     if (m_flag_init) {
-#ifndef JPEG_FROM_SENSOR
-        if (m_jpeg_fd > 0) {
-            if (SsbSipJPEGEncodeDeInit(m_jpeg_fd) != JPEG_OK) {
-                LOGE("ERR(%s):Fail on SsbSipJPEGEncodeDeInit\n", __func__);
-            }
-            m_jpeg_fd = 0;
-        }
-#endif
 
-#ifdef DUAL_PORT_RECORDING
         stopRecord();
-#endif
 
 	/* close m_cam_fd after stopRecord() because stopRecord()
 	 * uses m_cam_fd to change frame rate
 	 */
-        LOGE("DeinitCamera: m_cam_fd(%d)", m_cam_fd);
+        LOGI("DeinitCamera: m_cam_fd(%d)", m_cam_fd);
         if (m_cam_fd > -1) {
             close(m_cam_fd);
             m_cam_fd = -1;
         }
 
-#ifdef DUAL_PORT_RECORDING
-        LOGE("DeinitCamera: m_cam_fd2(%d)", m_cam_fd2);
+        LOGI("DeinitCamera: m_cam_fd2(%d)", m_cam_fd2);
         if (m_cam_fd2 > -1) {
             close(m_cam_fd2);
             m_cam_fd2 = -1;
         }
-#endif
 
         if (m_cam_fd_temp != -1) {
             close(m_cam_fd_temp);
@@ -904,23 +794,12 @@
 // ======================================================================
 // Preview
 
-int SecCamera::flagPreviewStart(void)
-{
-    LOGV("%s:started(%d)", __func__, m_flag_camera_start);
-
-    return m_flag_camera_start > 0;
-}
-
 int SecCamera::startPreview(void)
 {
     v4l2_streamparm streamparm;
     struct sec_cam_parm *parms;
     parms = (struct sec_cam_parm*)&streamparm.parm.raw_data;
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     LOGV("%s :", __func__);
-#else   /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
-    LOGE("%s :", __func__);
-#endif  /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
 
     // aleady started
     if (m_flag_camera_start > 0) {
@@ -949,7 +828,6 @@
     ret = fimc_v4l2_querybuf(m_cam_fd, m_buffers_c, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
     CHECK(ret);
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     LOGV("%s : m_preview_width: %d m_preview_height: %d m_angle: %d\n",
             __func__, m_preview_width, m_preview_height, m_angle);
 
@@ -963,7 +841,6 @@
         CHECK(ret);
     }
 
-#endif
     /* start with all buffers in queue */
     for (int i = 0; i < MAX_BUFFERS; i++) {
         ret = fimc_v4l2_qbuf(m_cam_fd, i);
@@ -973,7 +850,6 @@
     ret = fimc_v4l2_streamon(m_cam_fd);
     CHECK(ret);
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     m_flag_camera_start = 1;
 
     ret = fimc_v4l2_s_parm(m_cam_fd, &m_streamparm);
@@ -986,7 +862,6 @@
                                m_blur_level);
         CHECK(ret);
     }
-#endif
 
     // It is a delay for a new frame, not to show the previous bigger ugly picture frame.
     ret = fimc_poll(&m_events_c);
@@ -994,24 +869,15 @@
     ret = fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_RETURN_FOCUS, 0);
     CHECK(ret);
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     LOGV("%s: got the first frame of the preview\n", __func__);
-#endif  /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
 
-#ifndef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
-    m_flag_camera_start = 1;
-#endif  /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
-
-#ifdef ENABLE_HDMI_DISPLAY
-    hdmi_initialize(m_preview_width,m_preview_height);
-    hdmi_gl_initialize(0);
-    hdmi_gl_streamoff(0);
-#endif
     return 0;
 }
 
 int SecCamera::stopPreview(void)
 {
+    int ret;
+
     LOGV("%s :", __func__);
 
     close_buffers(m_buffers_c);
@@ -1024,17 +890,12 @@
     if (m_params->flash_mode == FLASH_MODE_TORCH)
         setFlashMode(FLASH_MODE_OFF);
 
-#ifdef ENABLE_HDMI_DISPLAY
-    hdmi_deinitialize();
-    hdmi_gl_streamon(0);
-#endif
-
     if (m_cam_fd <= 0) {
         LOGE("ERR(%s):Camera was closed\n", __func__);
         return -1;
     }
 
-    int ret = fimc_v4l2_streamoff(m_cam_fd);
+    ret = fimc_v4l2_streamoff(m_cam_fd);
 
     m_flag_camera_start = 0;
     CHECK(ret);
@@ -1043,7 +904,6 @@
 }
 
 //Recording
-#ifdef DUAL_PORT_RECORDING
 int SecCamera::startRecord(void)
 {
     LOGV("%s :", __func__);
@@ -1068,7 +928,6 @@
     int ret = fimc_v4l2_enum_fmt(m_cam_fd2,m_record_v4lformat);
     CHECK(ret);
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     LOGE("%s: m_recording_width = %d, m_recording_height = %d\n", __func__, m_recording_width, m_recording_height);
 
     ret = fimc_v4l2_s_fmt(m_cam_fd2, m_recording_width, m_recording_height, m_record_v4lformat, 0);
@@ -1076,12 +935,6 @@
     CHECK(ret);
 
     init_yuv_buffers(m_buffers_c2, m_recording_width, m_recording_height, m_record_v4lformat);
-#else   /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
-    ret = fimc_v4l2_s_fmt(m_cam_fd2, m_preview_width, m_preview_height, m_record_v4lformat, 0);
-    CHECK(ret);
-
-    init_yuv_buffers(m_buffers_c2, m_preview_width, m_preview_height, m_record_v4lformat);
-#endif  /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
 
     ret = fimc_v4l2_reqbufs(m_cam_fd2, V4L2_BUF_TYPE_VIDEO_CAPTURE, MAX_BUFFERS);
     CHECK(ret);
@@ -1108,6 +961,8 @@
 
 int SecCamera::stopRecord(void)
 {
+    int ret;
+
     if (m_flag_record_start == 0)
         return 0;
 
@@ -1120,7 +975,7 @@
         return -1;
     }
 
-    int ret = fimc_v4l2_streamoff(m_cam_fd2);
+    ret = fimc_v4l2_streamoff(m_cam_fd2);
 
     m_flag_record_start = 0;
     CHECK(ret);
@@ -1145,7 +1000,6 @@
     CHECK((int)addr_c);
     return addr_c;
 }
-#endif //DUAL_PORT_RECORDING
 
 unsigned int SecCamera::getPhyAddrY(int index)
 {
@@ -1165,17 +1019,6 @@
     return addr_c;
 }
 
-#ifdef SEND_YUV_RECORD_DATA
-#define PAGE_ALIGN(x)   (((x) + 0xFFF) & (~0xFFF)) // Set as multiple of 4K
-void SecCamera::getYUVBuffers(unsigned char **virYAddr, unsigned char **virCAddr, int index)
-{
-    *virYAddr = (unsigned char*)m_buffers_c[index].start;
-    //*virCAddr = (unsigned char*)m_buffers_c[index].start + PAGE_ALIGN(m_preview_width * m_preview_height);
-    *virCAddr = (unsigned char*)m_buffers_c[index].start +
-                    ALIGN_TO_8KB(ALIGN_TO_128B(m_preview_width) * ALIGN_TO_32B(m_preview_height));
-}
-#endif
-
 void SecCamera::pausePreview()
 {
     fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_STREAM_PAUSE, 0);
@@ -1184,9 +1027,7 @@
 int SecCamera::getPreview()
 {
     int index;
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     int ret;
-#endif
 
 #ifdef ENABLE_ESD_PREVIEW_CHECK
     int status = 0;
@@ -1197,24 +1038,6 @@
     }
 #endif // ENABLE_ESD_PREVIEW_CHECK
 
-#ifdef PERFORMANCE
-
-    LOG_TIME_DEFINE(0)
-    LOG_TIME_DEFINE(1)
-
-    LOG_TIME_START(0)
-    fimc_poll(&m_events_c);
-    LOG_TIME_END(0)
-    LOG_CAMERA("fimc_poll interval: %lu us", LOG_TIME(0));
-
-    LOG_TIME_START(1)
-    index = fimc_v4l2_dqbuf(m_cam_fd);
-    LOG_TIME_END(1)
-    LOG_CAMERA("fimc_dqbuf interval: %lu us", LOG_TIME(1));
-
-#else
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
-
 #ifdef ENABLE_ESD_PREVIEW_CHECK
     if (m_flag_camera_start == 0 || fimc_esd_poll(&m_events_c) == 0 || status) {
 #else
@@ -1236,74 +1059,35 @@
             return -1;
         ret = fimc_v4l2_s_input(m_cam_fd, 1000);
         CHECK(ret);
-        //setCameraSensorReset();
         ret = startPreview();
 
-#ifdef ENABLE_ESD_PREVIEW_CHECK
-        m_esd_check_count = 0;
-#endif // ENABLE_ESD_PREVIEW_CHECK
-
         if (ret < 0) {
             LOGE("ERR(%s): startPreview() return %d\n", __func__, ret);
             return 0;
         }
     }
-#else   /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
-    fimc_poll(&m_events_c);
-#endif  /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
     index = fimc_v4l2_dqbuf(m_cam_fd);
-#endif
     if (!(0 <= index && index < MAX_BUFFERS)) {
         LOGE("ERR(%s):wrong index = %d\n", __func__, index);
         return -1;
     }
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     ret = fimc_v4l2_qbuf(m_cam_fd, index);
-#else   /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
-    int ret = fimc_v4l2_qbuf(m_cam_fd, index);
-#endif  /* SWP1_CAMERA_ADD_ADVANCED_FUNCTION */
-
     CHECK(ret);
 
-#ifdef ENABLE_HDMI_DISPLAY
-    hdmi_set_v_param(getPhyAddrY(index), getPhyAddrC (index), m_preview_width, m_preview_height);
-#endif
     return index;
-
 }
 
-#ifdef DUAL_PORT_RECORDING
 int SecCamera::getRecord()
 {
     int index;
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     if (m_flag_record_start == 0) {
         LOGE("%s: m_flag_record_start is 0", __func__);
         startRecord();
     }
-#endif
-
-#ifdef PERFORMANCE
-
-    LOG_TIME_DEFINE(0)
-    LOG_TIME_DEFINE(1)
-
-    LOG_TIME_START(0)
-    fimc_poll(&m_events_c2);
-    LOG_TIME_END(0)
-    LOG_CAMERA("fimc_poll interval: %lu us", LOG_TIME(0));
-
-    LOG_TIME_START(1)
-    index = fimc_v4l2_dqbuf(m_cam_fd2);
-    LOG_TIME_END(1)
-    LOG_CAMERA("fimc_dqbuf interval: %lu us", LOG_TIME(1));
-
-#else
     fimc_poll(&m_events_c2);
     index = fimc_v4l2_dqbuf(m_cam_fd2);
-#endif
     if (!(0 <= index && index < MAX_BUFFERS)) {
         LOGE("ERR(%s):wrong index = %d\n", __func__, index);
         return -1;
@@ -1314,7 +1098,6 @@
 
     return index;
 }
-#endif //DUAL_PORT_RECORDING
 
 int SecCamera::setPreviewSize(int width, int height, int pixel_format)
 {
@@ -1372,7 +1155,6 @@
 
 // ======================================================================
 // Snapshot
-#ifdef JPEG_FROM_SENSOR
 /*
  * Devide getJpeg() as two funcs, setSnapshotCmd() & getJpeg() because of the shutter sound timing.
  * Here, just send the capture cmd to camera ISP to start JPEG capture.
@@ -1437,7 +1219,6 @@
 
     LOG_TIME_DEFINE(2)
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     // capture
     ret = fimc_poll(&m_events_c);
     CHECK_PTR(ret);
@@ -1446,7 +1227,6 @@
         LOGE("ERR(%s):wrong index = %d\n", __func__, index);
         return NULL;
     }
-#endif
 
     *jpeg_size = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAM_JPEG_MAIN_SIZE);
     CHECK_PTR(*jpeg_size);
@@ -1475,7 +1255,7 @@
 int SecCamera::getExif(unsigned char *pExifDst, unsigned char *pThumbSrc)
 {
     JpegEncoder jpgEnc;
-#if ADD_THUMB_IMG
+
     LOGV("%s : m_jpeg_thumbnail_width = %d, height = %d",
          __func__, m_jpeg_thumbnail_width, m_jpeg_thumbnail_height);
     if ((m_jpeg_thumbnail_width > 0) && (m_jpeg_thumbnail_height > 0)) {
@@ -1527,9 +1307,6 @@
         LOGV("%s : enableThumb set to false", __func__);
         mExifInfo.enableThumb = false;
     }
-#else
-    mExifInfo.enableThumb = false;
-#endif
 
     unsigned int exifSize;
 
@@ -1573,25 +1350,10 @@
     }
 }
 
-#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
 int SecCamera::getPostViewOffset(void)
 {
     return m_postview_offset;
 }
-#endif
-
-#else //#ifdef JPEG_FROM_SENSOR
-int SecCamera::getJpegFd(void)
-{
-    return m_jpeg_fd;
-}
-
-void SecCamera::SetJpgAddr(unsigned char *addr)
-{
-    SetMapAddr(addr);
-}
-
-#endif
 
 int SecCamera::getSnapshotAndJpeg(unsigned char *yuv_buf, unsigned char *jpeg_buf,
                                             unsigned int *output_size)
@@ -1676,17 +1438,11 @@
     LOGV("\nsnapshot dequeued buffer = %d snapshot_width = %d snapshot_height = %d\n\n",
             index, m_snapshot_width, m_snapshot_height);
 
-#ifdef DUMP_YUV
-    save_yuv(m_buffers_c, m_snapshot_width, m_snapshot_height, 16, index, 0);
-#endif
     LOG_TIME_END(2)
 
     memcpy(yuv_buf, (unsigned char*)m_buffers_c[index].start, m_snapshot_width * m_snapshot_height * 2);
     LOG_TIME_START(5) // post
     fimc_v4l2_streamoff(m_cam_fd);
-#ifdef DUMP_YUV
-    close_buffers(m_buffers_c);
-#endif
     LOG_TIME_END(5)
 
     LOG_CAMERA("getSnapshotAndJpeg intervals : stopPreview(%lu), prepare(%lu),"
@@ -1900,7 +1656,6 @@
 {
     LOGV("%s :", __func__);
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     if (m_cam_fd <= 0) {
         LOGE("ERR(%s):Camera was closed\n", __func__);
         return -1;
@@ -1911,17 +1666,9 @@
         return -1;
     }
 
-#else
-    // kcoolsw : turn on setAutofocus initially..
-    if (m_autofocus != AUTO_FOCUS_ON) {
-        m_autofocus = AUTO_FOCUS_ON;
-    }
-#endif
-
     return 0;
 }
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
 int SecCamera::getAutoFocusResult(void)
 {
     int af_result;
@@ -1932,6 +1679,7 @@
 
     return af_result;
 }
+
 int SecCamera::cancelAutofocus(void)
 {
     LOGV("%s :", __func__);
@@ -1948,7 +1696,7 @@
 
     return 0;
 }
-#endif
+
 // -----------------------------------
 
 int SecCamera::zoomIn(void)
@@ -1968,7 +1716,6 @@
 int SecCamera::SetRotate(int angle)
 {
     LOGE("%s(angle(%d))", __func__, angle);
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
 
     if (m_angle != angle) {
         switch (angle) {
@@ -2005,7 +1752,6 @@
             }
         }
     }
-#endif
     return 0;
 }
 
@@ -2017,7 +1763,6 @@
 
 int SecCamera::setFrameRate(int frame_rate)
 {
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     LOGV("%s(FrameRate(%d))", __func__, frame_rate);
 
     if (frame_rate < FRAME_RATE_AUTO || FRAME_RATE_MAX < frame_rate )
@@ -2032,9 +1777,6 @@
             }
         }
     }
-#else
-    m_params->capture.timeperframe.denominator = frame_rate;
-#endif
     return 0;
 }
 
@@ -2080,25 +1822,19 @@
 {
     LOGV("%s(white_balance(%d))", __func__, white_balance);
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     if (white_balance <= WHITE_BALANCE_BASE || WHITE_BALANCE_MAX <= white_balance) {
-#else
-    if (white_balance < WHITE_BALANCE_AUTO || WHITE_BALANCE_SUNNY < white_balance) {
-#endif
         LOGE("ERR(%s):Invalid white_balance(%d)", __func__, white_balance);
         return -1;
     }
 
     if (m_params->white_balance != white_balance) {
         m_params->white_balance = white_balance;
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
         if (m_flag_camera_start) {
             if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_WHITE_BALANCE, white_balance) < 0) {
                 LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_WHITE_BALANCE", __func__);
                 return -1;
             }
         }
-#endif
     }
 
     return 0;
@@ -2125,14 +1861,12 @@
 
     if (m_params->brightness != brightness) {
         m_params->brightness = brightness;
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
         if (m_flag_camera_start) {
             if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_BRIGHTNESS, brightness) < 0) {
                 LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_BRIGHTNESS", __func__);
                 return -1;
             }
         }
-#endif
     }
 
     return 0;
@@ -2150,25 +1884,19 @@
 {
     LOGV("%s(image_effect(%d))", __func__, image_effect);
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     if (image_effect <= IMAGE_EFFECT_BASE || IMAGE_EFFECT_MAX <= image_effect) {
-#else
-    if (image_effect < IMAGE_EFFECT_ORIGINAL || IMAGE_EFFECT_SILHOUETTE < image_effect) {
-#endif
         LOGE("ERR(%s):Invalid image_effect(%d)", __func__, image_effect);
         return -1;
     }
 
     if (m_params->effects != image_effect) {
         m_params->effects = image_effect;
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
         if (m_flag_camera_start) {
             if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_EFFECT, image_effect) < 0) {
                 LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_EFFECT", __func__);
                 return -1;
             }
         }
-#endif
     }
 
     return 0;
@@ -2181,7 +1909,6 @@
 }
 
 // ======================================================================
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
 int SecCamera::setAntiBanding(int anti_banding)
 {
     LOGV("%s(anti_banding(%d))", __func__, anti_banding);
@@ -3056,8 +2783,6 @@
     return 0;
 }
 
-#endif
-
 const __u8* SecCamera::getCameraSensorName(void)
 {
     LOGV("%s", __func__);
@@ -3080,187 +2805,6 @@
 // ======================================================================
 // Jpeg
 
-#ifndef JPEG_FROM_SENSOR
-unsigned char* SecCamera::getJpeg(unsigned char *snapshot_data, int snapshot_size, int *size)
-{
-    LOGV("%s :", __func__);
-
-    if (m_cam_fd <= 0) {
-        LOGE("ERR(%s):Camera was closed\n", __func__);
-        return NULL;
-    }
-
-    unsigned char *jpeg_data = NULL;
-    int            jpeg_size = 0;
-
-    jpeg_data = yuv2Jpeg(snapshot_data, snapshot_size, &jpeg_size,
-                            m_snapshot_width, m_snapshot_height, m_snapshot_v4lformat);
-
-    *size = jpeg_size;
-    return jpeg_data;
-}
-#endif
-
-#ifndef JPEG_FROM_SENSOR
-unsigned char* SecCamera::yuv2Jpeg(unsigned char *raw_data, int raw_size, int *jpeg_size,
-                                    int width, int height, int pixel_format)
-{
-    LOGV("%s:raw_data(%p), raw_size(%d), jpeg_size(%d), width(%d), height(%d), format(%d)",
-        __func__, raw_data, raw_size, *jpeg_size, width, height, pixel_format);
-
-    if (m_jpeg_fd <= 0) {
-        LOGE("ERR(%s):JPEG device was closed\n", __func__);
-        return NULL;
-    }
-    if (pixel_format == V4L2_PIX_FMT_RGB565) {
-        LOGE("ERR(%s):It doesn't support V4L2_PIX_FMT_RGB565\n", __func__);
-        return NULL;
-    }
-
-    unsigned char       *InBuf = NULL;
-    unsigned char       *OutBuf = NULL;
-    unsigned char       *jpeg_data = NULL;
-    long                frameSize;
-    exif_file_info_t    ExifInfo;
-
-    int input_file_format = JPG_MODESEL_YCBCR;
-
-    int out_file_format = JPG_422;
-
-    switch (pixel_format) {
-    case V4L2_PIX_FMT_NV12:
-    case V4L2_PIX_FMT_NV21:
-    case V4L2_PIX_FMT_NV12T:
-    case V4L2_PIX_FMT_YUV420:
-        out_file_format = JPG_420;
-        break;
-    case V4L2_PIX_FMT_YUYV:
-    case V4L2_PIX_FMT_UYVY:
-    case V4L2_PIX_FMT_YUV422P:
-        out_file_format = JPG_422;
-        break;
-    }
-
-    //////////////////////////////////////////////////////////////
-    // 2. set encode config.                                    //
-    //////////////////////////////////////////////////////////////
-    LOGV("Step 1 : JPEG_SET_ENCODE_IN_FORMAT(JPG_MODESEL_YCBCR)");
-    if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_IN_FORMAT, input_file_format) != JPEG_OK) {
-        LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_IN_FORMAT\n", __func__);
-        goto YUV2JPEG_END;
-    }
-
-    LOGV("Step 2 : JPEG_SET_SAMPING_MODE(JPG_422)");
-    if (SsbSipJPEGSetEncConfig(JPEG_SET_SAMPING_MODE, out_file_format) != JPEG_OK) {
-        LOGE("ERR(%s):Fail on JPEG_SET_SAMPING_MODE\n", __func__);
-        goto YUV2JPEG_END;
-    }
-
-    LOGV("Step 3 : JPEG_SET_ENCODE_WIDTH(%d)", width);
-    if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_WIDTH, width) != JPEG_OK) {
-        LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_WIDTH \n", __func__);
-        goto YUV2JPEG_END;
-    }
-
-    LOGV("Step 4 : JPEG_SET_ENCODE_HEIGHT(%d)", height);
-    if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_HEIGHT, height) != JPEG_OK) {
-        LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_HEIGHT \n", __func__);
-        goto YUV2JPEG_END;
-    }
-
-    LOGV("Step 5 : JPEG_SET_ENCODE_QUALITY(JPG_QUALITY_LEVEL_2)");
-    if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_QUALITY, JPG_QUALITY_LEVEL_2) != JPEG_OK) {
-        LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_QUALITY \n", __func__);
-        goto YUV2JPEG_END;
-    }
-
-#if (INCLUDE_JPEG_THUMBNAIL == 1)
-
-    LOGV("Step 6a : JPEG_SET_ENCODE_THUMBNAIL(TRUE)");
-    if (SsbSipJPEGSetEncConfig(JPEG_SET_ENCODE_THUMBNAIL, TRUE) != JPEG_OK) {
-        LOGE("ERR(%s):Fail on JPEG_SET_ENCODE_THUMBNAIL \n", __func__);
-        goto YUV2JPEG_END;
-    }
-
-    LOGV("Step 6b : JPEG_SET_THUMBNAIL_WIDTH(%d)", m_jpeg_thumbnail_width);
-    if (SsbSipJPEGSetEncConfig(JPEG_SET_THUMBNAIL_WIDTH, m_jpeg_thumbnail_width) != JPEG_OK) {
-        LOGE("ERR(%s):Fail on JPEG_SET_THUMBNAIL_WIDTH(%d) \n", __func__, m_jpeg_thumbnail_height);
-        goto YUV2JPEG_END;
-    }
-
-    LOGV("Step 6c : JPEG_SET_THUMBNAIL_HEIGHT(%d)", m_jpeg_thumbnail_height);
-    if (SsbSipJPEGSetEncConfig(JPEG_SET_THUMBNAIL_HEIGHT, m_jpeg_thumbnail_height) != JPEG_OK) {
-        LOGE("ERR(%s):Fail on JPEG_SET_THUMBNAIL_HEIGHT(%d) \n", __func__, m_jpeg_thumbnail_height);
-        goto YUV2JPEG_END;
-    }
-
-#endif
-
-    if (raw_size == 0) {
-        unsigned int addr_y;
-        int width, height,frame_size;
-        getSnapshotSize(&width, &height, &frame_size);
-        if (raw_data == NULL) {
-            LOGE("%s %d] Raw data is NULL \n", __func__, __LINE__);
-            goto YUV2JPEG_END;
-        } else {
-            addr_y = (unsigned int)raw_data;
-        }
-
-        SsbSipJPEGSetEncodeInBuf(m_jpeg_fd, addr_y, frame_size);
-    } else {
-        //////////////////////////////////////////////////////////////
-        // 4. get Input buffer address                              //
-        //////////////////////////////////////////////////////////////
-        LOGV("Step 7 : Input buffer size(0x%X", raw_size);
-        InBuf = (unsigned char *)SsbSipJPEGGetEncodeInBuf(m_jpeg_fd, raw_size);
-        if (InBuf == NULL) {
-            LOGE("ERR(%s):Fail on SsbSipJPEGGetEncodeInBuf \n", __func__);
-            goto YUV2JPEG_END;
-        }
-        //////////////////////////////////////////////////////////////
-        // 5. put YUV stream to Input buffer
-        //////////////////////////////////////////////////////////////
-        LOGV("Step 8: memcpy(InBuf(%p), raw_data(%p), raw_size(%d)", InBuf, raw_data, raw_size);
-        memcpy(InBuf, raw_data, raw_size);
-    }
-
-    //////////////////////////////////////////////////////////////
-    // 6. Make Exif info parameters
-    //////////////////////////////////////////////////////////////
-    LOGV("Step 9: m_makeExifParam()");
-    memset(&ExifInfo, 0x00, sizeof(exif_file_info_t));
-    m_makeExifParam(&ExifInfo);
-
-    //////////////////////////////////////////////////////////////
-    // 7. Encode YUV stream
-    //////////////////////////////////////////////////////////////
-    LOGV("Step a: SsbSipJPEGEncodeExe()");
-    if (SsbSipJPEGEncodeExe(m_jpeg_fd, &ExifInfo, JPEG_USE_SW_SCALER) != JPEG_OK) {   //with Exif
-        LOGE("ERR(%s):Fail on SsbSipJPEGEncodeExe \n", __func__);
-        goto YUV2JPEG_END;
-    }
-    //////////////////////////////////////////////////////////////
-    // 8. get output buffer address
-    //////////////////////////////////////////////////////////////
-    LOGV("Step b: SsbSipJPEGGetEncodeOutBuf()");
-    OutBuf = (unsigned char *)SsbSipJPEGGetEncodeOutBuf(m_jpeg_fd, &frameSize);
-    if (OutBuf == NULL) {
-        LOGE("ERR(%s):Fail on SsbSipJPEGGetEncodeOutBuf \n", __func__);
-        goto YUV2JPEG_END;
-    }
-    //////////////////////////////////////////////////////////////
-    // 9. write JPEG result file
-    //////////////////////////////////////////////////////////////
-    LOGV("Done");
-    jpeg_data  = OutBuf;
-    *jpeg_size = (int)frameSize;
-
-YUV2JPEG_END:
-    return jpeg_data;
-}
-#endif
-
 int SecCamera::setJpegThumbnailSize(int width, int height)
 {
     LOGV("%s(width(%d), height(%d))", __func__, width, height);
diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h
index e1460b9..7710ce4 100644
--- a/libcamera/SecCamera.h
+++ b/libcamera/SecCamera.h
@@ -34,40 +34,16 @@
 #include <sys/stat.h>
 
 #include <linux/videodev2.h>
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
 #include <videodev2_samsung.h>
-#endif
 
 #include "JpegEncoder.h"
 
-#ifdef ENABLE_HDMI_DISPLAY
-#include "hdmi_lib.h"
-#endif
-
 #include <camera/CameraHardwareInterface.h>
 
 namespace android {
-//Define this if the preview data is to be shared using memory mapped technique instead of passing physical address.
-#define PREVIEW_USING_MMAP
-//Define this if the JPEG images are obtained directly from camera sensor. Else on chip JPEG encoder will be used.
-#define JPEG_FROM_SENSOR
-
-//#define DUAL_PORT_RECORDING //Define this if 2 fimc ports are needed for recording.
-
-//#define SEND_YUV_RECORD_DATA //Define this to copy YUV data to encoder instead of sharing the physical address.
 
 #define ENABLE_ESD_PREVIEW_CHECK
 
-#define INCLUDE_JPEG_THUMBNAIL 1 //Valid only for on chip JPEG encoder
-
-#if defined PREVIEW_USING_MMAP
-#define DUAL_PORT_RECORDING
-#endif
-
-#if defined JPEG_FROM_SENSOR
-#define DIRECT_DELIVERY_OF_POSTVIEW_DATA //Define this if postview data is needed in buffer instead of zero copy.
-#endif
-
 #if defined(LOG_NDEBUG) && LOG_NDEBUG == 0
 #define LOG_CAMERA LOGD
 #define LOG_CAMERA_PREVIEW LOGD
@@ -160,10 +136,8 @@
 #define DEFAULT_JPEG_THUMBNAIL_HEIGHT       192
 
 #define CAMERA_DEV_NAME   "/dev/video0"
-
-#ifdef DUAL_PORT_RECORDING
 #define CAMERA_DEV_NAME2  "/dev/video2"
-#endif
+
 #define CAMERA_DEV_NAME_TEMP "/data/videotmp_000"
 #define CAMERA_DEV_NAME2_TEMP "/data/videotemp_002"
 
@@ -235,7 +209,6 @@
         CAMERA_ID_FRONT = 1,
     };
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     enum JPEG_QUALITY {
         JPEG_QUALITY_ECONOMY    = 0,
         JPEG_QUALITY_NORMAL     = 50,
@@ -279,7 +252,6 @@
 
     int m_touch_af_start_stop;
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     struct gps_info_latiude {
         unsigned int    north_south;
         unsigned int    dgree;
@@ -298,10 +270,6 @@
         unsigned int    minute;
         unsigned int    second;
     } gpsInfoAltitude;
-#endif
-
-
-#endif
 
     SecCamera();
     ~SecCamera();
@@ -321,15 +289,14 @@
 
     int             startPreview(void);
     int             stopPreview(void);
-#ifdef DUAL_PORT_RECORDING
+
     int             startRecord(void);
     int             stopRecord(void);
     int             getRecord(void);
     unsigned int    getRecPhyAddrY(int);
     unsigned int    getRecPhyAddrC(int);
-#endif
+
     int             cancelPicture(void);
-    int             flagPreviewStart(void);
     int             getPreview(void);
     int             setPreviewSize(int width, int height, int pixel_format);
     int             getPreviewSize(int *width, int *height, int *frame_size);
@@ -369,7 +336,7 @@
 
     int             setImageEffect(int image_effect);
     int             getImageEffect(void);
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
+
     int             setSceneMode(int scene_mode);
     int             getSceneMode(void);
 
@@ -460,7 +427,6 @@
 #ifdef ENABLE_ESD_PREVIEW_CHECK
     int             getCameraSensorESDStatus(void);
 #endif // ENABLE_ESD_PREVIEW_CHECK
-#endif
 
     int setFrameRate(int frame_rate);
     unsigned char*  getJpeg(int*, unsigned int*);
@@ -468,22 +434,15 @@
                                         unsigned int *output_size);
     int             getExif(unsigned char *pExifDst, unsigned char *pThumbSrc);
 
-#ifdef JPEG_FROM_SENSOR
     void            getPostViewConfig(int*, int*, int*);
-#endif
     void            getThumbnailConfig(int *width, int *height, int *size);
 
-#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
     int             getPostViewOffset(void);
-#endif
     int             getCameraFd(void);
     int             getJpegFd(void);
     void            SetJpgAddr(unsigned char *addr);
     unsigned int    getPhyAddrY(int);
     unsigned int    getPhyAddrC(int);
-#ifdef SEND_YUV_RECORD_DATA
-    void            getYUVBuffers(unsigned char **virYAddr, unsigned char **virCaddr, int index);
-#endif
     void            pausePreview();
     int             initCamera(int index);
     void            DeinitCamera();
@@ -532,12 +491,11 @@
 
     int             m_cam_fd_temp;
     int             m_cam_fd2_temp;
-#ifdef DUAL_PORT_RECORDING
+
     int             m_cam_fd2;
     struct pollfd   m_events_c2;
     int             m_flag_record_start;
     struct          fimc_buffer m_buffers_c2[MAX_BUFFERS];
-#endif
 
     int             m_preview_v4lformat;
     int             m_preview_width;
@@ -552,10 +510,6 @@
     int             m_snapshot_max_height;
 
     int             m_angle;
-#ifndef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
-    int             m_autofocus;
-#endif
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     int             m_anti_banding;
     int             m_wdr;
     int             m_anti_shake;
@@ -583,7 +537,6 @@
     int             m_caf_on_off;
     int             m_default_imei;
     int             m_camera_af_flag;
-#endif
 
     int             m_flag_camera_start;
 
diff --git a/libcamera/SecCameraHWInterface.cpp b/libcamera/SecCameraHWInterface.cpp
index 4938587..bbbb48c 100644
--- a/libcamera/SecCameraHWInterface.cpp
+++ b/libcamera/SecCameraHWInterface.cpp
@@ -32,15 +32,6 @@
 #define ALL_BUFFERS_FLUSHED     -66
 #endif
 
-#ifdef SEND_YUV_RECORD_DATA
-#define ALIGN_TO_32B(x)   ((((x) + (1 <<  5) - 1) >>  5) <<  5)
-#define ALIGN_TO_128B(x)  ((((x) + (1 <<  7) - 1) >>  7) <<  7)
-#define ALIGN_TO_8KB(x)   ((((x) + (1 << 13) - 1) >> 13) << 13)
-#define RECORD_HEAP_SIZE (ALIGN_TO_8KB(ALIGN_TO_128B(1280) *        \
-            ALIGN_TO_32B(720)) + ALIGN_TO_8KB(ALIGN_TO_128B(1280) * \
-            ALIGN_TO_32B(720 / 2)))
-#endif
-
 #define VIDEO_COMMENT_MARKER_H          0xFFBE
 #define VIDEO_COMMENT_MARKER_L          0xFFBF
 #define VIDEO_COMMENT_MARKER_LENGTH     4
@@ -81,9 +72,6 @@
           mRecordHeap(0),
           mJpegHeap(0),
           mSecCamera(NULL),
-          mPreviewFrameSize(0),
-          mRawFrameSize(0),
-          mPreviewFrameRateMicrosec(33000),
           mCameraSensorName(NULL),
           mSkipFrame(0),
 #if defined(BOARD_USES_OVERLAY)
@@ -95,14 +83,10 @@
           mDataCbTimestamp(0),
           mCallbackCookie(0),
           mMsgEnabled(0),
-          mCurrentPreviewFrame(0),
-          mRecordRunning(false)
-#ifdef JPEG_FROM_SENSOR
-          ,
+          mRecordRunning(false),
           mPostViewWidth(0),
           mPostViewHeight(0),
           mPostViewSize(0)
-#endif
 {
     LOGV("%s :", __func__);
     int ret = 0;
@@ -122,22 +106,7 @@
         LOGE("ERR(%s):Fail on mSecCamera->flagCreate()", __func__);
     }
 
-#ifndef PREVIEW_USING_MMAP
-    int previewHeapSize = sizeof(struct addrs) * kBufferCount;
-
-    LOGV("mPreviewHeap : MemoryHeapBase(previewHeapSize(%d))", previewHeapSize);
-    mPreviewHeap = new MemoryHeapBase(previewHeapSize);
-    if (mPreviewHeap->getHeapID() < 0) {
-        LOGE("ERR(%s): Preview heap creation fail", __func__);
-        mPreviewHeap.clear();
-    }
-#endif
-
-#ifdef SEND_YUV_RECORD_DATA
-    int recordHeapSize = RECORD_HEAP_SIZE;
-#else
     int recordHeapSize = sizeof(struct addrs) * kBufferCount;
-#endif
     LOGV("mRecordHeap : MemoryHeapBase(recordHeapSize(%d))", recordHeapSize);
     mRecordHeap = new MemoryHeapBase(recordHeapSize);
     if (mRecordHeap->getHeapID() < 0) {
@@ -145,17 +114,11 @@
         mRecordHeap.clear();
     }
 
-#ifdef JPEG_FROM_SENSOR
     mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
     LOGV("mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",
             mPostViewWidth,mPostViewHeight,mPostViewSize);
-#endif
 
-#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
     int rawHeapSize = mPostViewSize;
-#else
-    int rawHeapSize = sizeof(struct addrs_cap);
-#endif
     LOGV("mRawHeap : MemoryHeapBase(previewHeapSize(%d))", rawHeapSize);
     mRawHeap = new MemoryHeapBase(rawHeapSize);
     if (mRawHeap->getHeapID() < 0) {
@@ -214,17 +177,13 @@
         LOGE("getSnapshotMaxSize fail (%d / %d) \n",
              snapshot_max_width, snapshot_max_height);
 
-#ifdef PREVIEW_USING_MMAP
     p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP);
-#else
-    p.setPreviewFormat("yuv420sp_custom");
-#endif
     p.setPreviewSize(preview_max_width, preview_max_height);
 
     p.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG);
     p.setPictureSize(snapshot_max_width, snapshot_max_height);
     p.set(CameraParameters::KEY_JPEG_QUALITY, "100"); // maximum quality
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
+
     p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS,
           CameraParameters::PIXEL_FORMAT_YUV420SP);
     p.set(CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS,
@@ -348,13 +307,12 @@
     ip.set("saturation-max", 4);
     ip.set("contrast-min", 0);
     ip.set("contrast-max", 4);
-#endif
 
     p.set(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY, "100");
 
     p.set(CameraParameters::KEY_ROTATION, 0);
     p.set(CameraParameters::KEY_WHITE_BALANCE, CameraParameters::WHITE_BALANCE_AUTO);
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
+
     p.set(CameraParameters::KEY_EFFECT, CameraParameters::EFFECT_NONE);
 
     ip.set("sharpness", SHARPNESS_DEFAULT);
@@ -369,10 +327,6 @@
         ip.set("vtmode", 0);
         ip.set("blur", 0);
     }
-#else
-    ip.set("image-effects", "original");
-#endif
-
 
     p.set(CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, "51.2");
     p.set(CameraParameters::KEY_VERTICAL_VIEW_ANGLE, "39.4");
@@ -479,7 +433,6 @@
 
     nsecs_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
 
-#ifdef PREVIEW_USING_MMAP
     int width, height, frame_size, offset;
 
     mSecCamera->getPreviewSize(&width, &height, &frame_size);
@@ -528,42 +481,12 @@
 OverlayEnd:
 #endif
 
-#else
-    unsigned int phyYAddr = mSecCamera->getPhyAddrY(index);
-    unsigned int phyCAddr = mSecCamera->getPhyAddrC(index);
-
-    if (phyYAddr == 0xffffffff || phyCAddr == 0xffffffff) {
-        LOGE("ERR(%s):Fail on SecCamera getPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr);
-        return UNKNOWN_ERROR;
-    }
-    struct addrs *addrs = (struct addrs *)mPreviewHeap->base();
-
-    sp<MemoryBase> buffer = new MemoryBase(mPreviewHeap, index * sizeof(struct addrs), sizeof(struct addrs));
-    addrs[index].addr_y = phyYAddr;
-    addrs[index].addr_cbcr = phyCAddr;
-#endif //PREVIEW_USING_MMAP
-
     // Notify the client of a new frame.
     if (mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME) {
         mDataCb(CAMERA_MSG_PREVIEW_FRAME, buffer, mCallbackCookie);
     }
 
     if (mRecordRunning == true) {
-#ifdef SEND_YUV_RECORD_DATA
-        int width, height, frame_size;
-        unsigned char *virYAddr;
-        unsigned char *virCAddr;
-
-        mSecCamera->getPreviewSize(&width, &height, &frame_size);
-        mSecCamera->getYUVBuffers(&virYAddr, &virCAddr, index);
-        sp<MemoryBase> buffer = new MemoryBase(mRecordHeap, 0, frame_size);
-        //memcpy(mRecordHeap->base(), (void*)virYAddr, width * height);
-        //memcpy(mRecordHeap->base() + (width*height),(void*)virCAddr, width * height * 0.5);
-        memcpy(mRecordHeap->base(), (void*)virYAddr, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)));
-        memcpy(mRecordHeap->base() + ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height)),
-                (void*)virCAddr, ALIGN_TO_8KB(ALIGN_TO_128B(width) * ALIGN_TO_32B(height / 2)));
-#else
-#ifdef DUAL_PORT_RECORDING
         int index = mSecCamera->getRecord();
 
         if (index < 0) {
@@ -578,38 +501,22 @@
             LOGE("ERR(%s):Fail on SecCamera getRectPhyAddr Y addr = %0x C addr = %0x", __func__, phyYAddr, phyCAddr);
             return UNKNOWN_ERROR;
         }
-#endif//DUAL_PORT_RECORDING
         struct addrs *addrs = (struct addrs *)mRecordHeap->base();
 
         sp<MemoryBase> buffer = new MemoryBase(mRecordHeap, index * sizeof(struct addrs), sizeof(struct addrs));
         addrs[index].addr_y = phyYAddr;
         addrs[index].addr_cbcr = phyCAddr;
-#endif
+
         // Notify the client of a new frame.
         if (mMsgEnabled & CAMERA_MSG_VIDEO_FRAME) {
             //nsecs_t timestamp = systemTime(SYSTEM_TIME_MONOTONIC);
             mDataCbTimestamp(timestamp, CAMERA_MSG_VIDEO_FRAME, buffer, mCallbackCookie);
         }
-#ifdef DUAL_PORT_RECORDING
     } else if (mRecordRunning == false) {
         if (mSecCamera->stopRecord() < 0) {
             LOGE("ERR(%s):Fail on mSecCamera->stopRecord()", __func__);
             return UNKNOWN_ERROR;
         }
-#endif
-    }
-
-    // Wait for it...
-    if (mTimeStart.tv_sec == 0 && mTimeStart.tv_usec == 0) {
-        gettimeofday(&mTimeStart, NULL);
-    } else {
-        gettimeofday(&mTimeStop, NULL);
-        long time = measure_time(&mTimeStart, &mTimeStop);
-        int delay = (mPreviewFrameRateMicrosec > time) ? mPreviewFrameRateMicrosec - time : 0;
-
-        usleep(delay);
-        //LOG_CAMERA_PREVIEW("delay = %d time = %ld us\n ", delay, time);
-        gettimeofday(&mTimeStart, NULL);
     }
 
     return NO_ERROR;
@@ -633,9 +540,6 @@
         return INVALID_OPERATION;
     }
 
-    memset(&mTimeStart, 0, sizeof(mTimeStart));
-    memset(&mTimeStop, 0, sizeof(mTimeStop));
-
     mSecCamera->stopPreview();
 
     setSkipFrame(INITIAL_SKIP_FRAME);
@@ -648,7 +552,6 @@
         return -1; //UNKNOWN_ERROR;
     }
 
-#ifdef PREVIEW_USING_MMAP
     if (mPreviewHeap != NULL)
         mPreviewHeap.clear();
 
@@ -660,24 +563,9 @@
 
     LOGD("MemoryHeapBase(fd(%d), size(%d), width(%d), height(%d))", (int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), width, height);
     mPreviewHeap = new MemoryHeapBase((int)mSecCamera->getCameraFd(), (size_t)(previewHeapSize), (uint32_t)0);
-#endif
 
-#ifdef JPEG_FROM_SENSOR
     mSecCamera->getPostViewConfig(&mPostViewWidth, &mPostViewHeight, &mPostViewSize);
     LOGV("CameraHardwareSec: mPostViewWidth = %d mPostViewHeight = %d mPostViewSize = %d",mPostViewWidth,mPostViewHeight,mPostViewSize);
-#endif
-
-#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
-    int rawHeapSize = mPostViewSize;
-#else
-    int rawHeapSize = sizeof(struct addrs_cap);
-#endif
-    LOGV("CameraHardwareSec: mRawHeap : MemoryHeapBase(previewHeapSize(%d))", rawHeapSize);
-    mRawHeap = new MemoryHeapBase(rawHeapSize);
-    if (mRawHeap->getHeapID() < 0) {
-        LOGE("ERR(%s): Raw heap creation fail", __func__);
-        mRawHeap.clear();
-    }
 
     mPreviewRunning = true;
     mPreviewThread->run("CameraPreviewThread", PRIORITY_URGENT_DISPLAY);
@@ -776,14 +664,13 @@
 {
     LOGV("%s :", __func__);
 
-#ifdef DUAL_PORT_RECORDING
+    if (mRecordRunning == false) {
         if (mSecCamera->startRecord() < 0) {
             LOGE("ERR(%s):Fail on mSecCamera->startRecord()", __func__);
             return UNKNOWN_ERROR;
         }
-#endif
-
-    mRecordRunning = true;
+        mRecordRunning = true;
+    }
     return NO_ERROR;
 }
 
@@ -818,10 +705,8 @@
 
 int CameraHardwareSec::autoFocusThread()
 {
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     int count =0;
     int af_status =0 ;
-#endif
 
     LOGV("%s : starting", __func__);
 
@@ -845,7 +730,6 @@
         return UNKNOWN_ERROR;
     }
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     af_status = mSecCamera->getAutoFocusResult();
 
     if (af_status == 0x01) {
@@ -867,10 +751,6 @@
         if (mMsgEnabled & CAMERA_MSG_FOCUS)
             mNotifyCb(CAMERA_MSG_FOCUS, false, 0, mCallbackCookie);
     }
-#else
-    if (mMsgEnabled & CAMERA_MSG_FOCUS)
-        mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie);
-#endif
 
     return NO_ERROR;
 }
@@ -886,14 +766,12 @@
 /* 2009.10.14 by icarus for added interface */
 status_t CameraHardwareSec::cancelAutoFocus()
 {
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     LOGV("%s :", __func__);
 
     if (mSecCamera->cancelAutofocus() < 0) {
         LOGE("ERR(%s):Fail on mSecCamera->cancelAutofocus()", __func__);
         return UNKNOWN_ERROR;
     }
-#endif
 
     return NO_ERROR;
 }
@@ -1055,21 +933,13 @@
 
     LOG_TIME_DEFINE(0)
     LOG_TIME_START(0)
-#ifdef DIRECT_DELIVERY_OF_POSTVIEW_DATA
     sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, mPostViewSize + 8);
-#else
-    sp<MemoryBase> buffer = new MemoryBase(mRawHeap, 0, sizeof(struct addrs_cap));
-#endif
 
     struct addrs_cap *addrs = (struct addrs_cap *)mRawHeap->base();
 
-#ifdef JPEG_FROM_SENSOR
     addrs[0].width = mPostViewWidth;
     addrs[0].height = mPostViewHeight;
     LOGV("[5B] mPostViewWidth = %d mPostViewHeight = %d\n",mPostViewWidth,mPostViewHeight);
-#else
-    mParameters.getPictureSize((int*)&addrs[0].width, (int*)&addrs[0].height);
-#endif
 
     sp<MemoryHeapBase> JpegHeap = new MemoryHeapBase(mJpegHeapSize);
     sp<MemoryHeapBase> PostviewHeap = new MemoryHeapBase(mPostViewSize);
@@ -1084,15 +954,13 @@
         int picture_format = mSecCamera->getSnapshotPixelFormat();
 
         unsigned int phyAddr;
-#ifdef JPEG_FROM_SENSOR
+
         // Modified the shutter sound timing for Jpeg capture
         if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK)
             mSecCamera->setSnapshotCmd();
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
         if (mMsgEnabled & CAMERA_MSG_SHUTTER) {
             mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie);
         }
-#endif
 
         if (mSecCamera->getCameraId() == SecCamera::CAMERA_ID_BACK){
             jpeg_data = mSecCamera->getJpeg(&jpeg_size, &phyAddr);
@@ -1110,23 +978,6 @@
             }
             LOGI("snapshotandjpeg done\n");
         }
-#else
-        phyAddr = mSecCamera->getSnapshotAndJpeg();
-        if (phyAddr < 0) {
-            mStateLock.lock();
-            mCaptureInProgress = false;
-            mStateLock.unlock();
-            return UNKNOWN_ERROR;
-        }
-
-        jpeg_data = mSecCamera->yuv2Jpeg((unsigned char*)phyAddr, 0, &jpeg_size,
-                                        picture_width, picture_height, picture_format);
-#endif
-
-#ifndef DIRECT_DELIVERY_OF_POSTVIEW_DATA
-
-        addrs[0].addr_y = phyAddr;
-#endif
 
         LOG_TIME_END(1)
         LOG_CAMERA("getSnapshotAndJpeg interval: %lu us", LOG_TIME(1));
@@ -1166,9 +1017,6 @@
     scaleDownYuv422((char *)PostviewHeap->base(), mPostViewWidth, mPostViewHeight,
                     (char *)ThumbnailHeap->base(), mThumbWidth, mThumbHeight);
 
-#ifdef POSTVIEW_CALLBACK
-    sp<MemoryBase> postview = new MemoryBase(PostviewHeap, 0, postviewHeapSize);
-#endif
     memcpy(mRawHeap->base(),PostviewHeap->base(), postviewHeapSize);
 
 #if defined(BOARD_USES_OVERLAY)
@@ -1220,20 +1068,6 @@
     if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) {
         mDataCb(CAMERA_MSG_RAW_IMAGE, buffer, mCallbackCookie);
     }
-#ifdef POSTVIEW_CALLBACK
-    if (mMsgEnabled & CAMERA_MSG_POSTVIEW_FRAME) {
-        int postviewHeapSize = mPostViewSize;
-        sp<MemoryHeapBase> mPostviewHeap = new MemoryHeapBase(postviewHeapSize);
-
-        postview_data = jpeg_data + postview_offset;
-        sp<MemoryBase> postview = new MemoryBase(mPostviewHeap, 0, postviewHeapSize);
-
-        if (postview_data != NULL)
-            memcpy(mPostviewHeap->base(), postview_data, postviewHeapSize);
-
-        mDataCb(CAMERA_MSG_POSTVIEW_FRAME, postview, mCallbackCookie);
-    }
-#endif
     if (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE) {
         sp<MemoryHeapBase> ExifHeap = new MemoryHeapBase(EXIF_FILE_SIZE + JPG_STREAM_BUF_SIZE);
         JpegExifSize = mSecCamera->getExif((unsigned char *)ExifHeap->base(),
@@ -1533,7 +1367,7 @@
         mSecCamera->dump(fd, args);
         mParameters.dump(fd, args);
         mInternalParameters.dump(fd, args);
-        snprintf(buffer, 255, " preview frame(%d), size (%d), running(%s)\n", mCurrentPreviewFrame, mPreviewFrameSize, mPreviewRunning?"true": "false");
+        snprintf(buffer, 255, " preview running(%s)\n", mPreviewRunning?"true": "false");
         result.append(buffer);
     } else {
         result.append("No camera client yet.\n");
@@ -1642,9 +1476,7 @@
         else if (!strcmp(new_str_picture_format, "uyv422i")) //Non-zero copy UYVY format
             new_picture_format = V4L2_PIX_FMT_UYVY;
         else if (!strcmp(new_str_picture_format, CameraParameters::PIXEL_FORMAT_JPEG))
-#ifdef JPEG_FROM_SENSOR
             new_picture_format = V4L2_PIX_FMT_YUYV;
-#endif
         else if (!strcmp(new_str_picture_format, "yuv422p"))
             new_picture_format = V4L2_PIX_FMT_YUV422P;
         else
@@ -1658,7 +1490,6 @@
         }
     }
 
-#ifdef SWP1_CAMERA_ADD_ADVANCED_FUNCTION
     //JPEG image quality
     int new_jpeg_quality = params.getInt(CameraParameters::KEY_JPEG_QUALITY);
     LOGV("%s : new_jpeg_quality %d", __func__, new_jpeg_quality);
@@ -1671,17 +1502,6 @@
             mParameters.set(CameraParameters::KEY_JPEG_QUALITY, new_jpeg_quality);
         }
     }
-#else
-    //JPEG image quality
-    int new_jpeg_quality = params.getInt(CameraParameters::KEY_JPEG_QUALITY);
-    LOGV("%s : new_jpeg_quality %d", __func__, new_jpeg_quality);
-    if (new_jpeg_quality < 0) {
-        LOGW("JPEG-image quality is not specified or is negative, defaulting to 100");
-        new_jpeg_quality = 100;
-        mParameters.set(CameraParameters::KEY_JPEG_QUALITY, "100");
-    }
-    mSecCamera->setJpegQuality(new_jpeg_quality);
-#endif
 
     // JPEG thumbnail size
     int new_jpeg_thumbnail_width = params.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH);
diff --git a/libcamera/SecCameraHWInterface.h b/libcamera/SecCameraHWInterface.h
index 6f52ece..f416d9f 100644
--- a/libcamera/SecCameraHWInterface.h
+++ b/libcamera/SecCameraHWInterface.h
@@ -80,13 +80,7 @@
         CameraHardwareSec *mHardware;
     public:
         PreviewThread(CameraHardwareSec *hw):
-#ifdef SINGLE_PROCESS
-        // In single process mode this thread needs to be a java thread,
-        // since we won't be calling through the binder.
-        Thread(true),
-#else
         Thread(false),
-#endif
         mHardware(hw) { }
         virtual bool threadLoop() {
             int ret = mHardware->previewThread();
@@ -181,9 +175,6 @@
     sp<MemoryBase>      mRecordBuffers[kBufferCountForRecord];
 
             SecCamera   *mSecCamera;
-            int         mPreviewFrameSize;
-            int         mRawFrameSize;
-            int         mPreviewFrameRateMicrosec;
             const __u8  *mCameraSensorName;
 
     mutable Mutex       mSkipFrameLock;
@@ -202,20 +193,10 @@
 
             int32_t     mMsgEnabled;
 
-            // only used from PreviewThread
-            int         mCurrentPreviewFrame;
-            int         mCurrentRecordFrame;
-
             bool        mRecordRunning;
-#ifdef JPEG_FROM_SENSOR
             int         mPostViewWidth;
             int         mPostViewHeight;
             int         mPostViewSize;
-#endif
-
-    struct timeval      mTimeStart;
-    struct timeval      mTimeStop;
-
 };
 
 }; // namespace android