Revert "Enable 4-channel input"

This reverts commit ccb51d0ce196e4fce17608a1e919c1970b4fd909.

Change-Id: I7a57bb120d32118713cad48fe3a626f857de4796
diff --git a/audio/hal/audio_hw.c b/audio/hal/audio_hw.c
index 28fdc28..83a623d 100644
--- a/audio/hal/audio_hw.c
+++ b/audio/hal/audio_hw.c
@@ -920,15 +920,13 @@
 
     if (has_additional_channels)
     {
-        // TODO do not hardcode 16-bit encoding, use audio_stream_out_frame_size() instead
         int16_t* src_buffer = (int16_t *)proc_buf_out;
         int16_t* dst_buffer = (int16_t *)buffer;
 
         if (dst_channels == 1) {
             for (i = frames_wr; i > 0; i--)
             {
-                *dst_buffer = *src_buffer;
-                dst_buffer += 1;
+                *dst_buffer++ = *src_buffer;
                 src_buffer += src_channels;
             }
         } else {
@@ -1535,7 +1533,7 @@
 {
     if (format != AUDIO_FORMAT_PCM_16_BIT) return -EINVAL;
 
-    if ((channel_count < 1) || (channel_count > 4)) return -EINVAL;
+    if ((channel_count < 1) || (channel_count > 2)) return -EINVAL;
 
     switch (sample_rate) {
     case 8000:
@@ -1831,10 +1829,6 @@
     unsigned char *data = NULL;
     struct pcm_config config;
 
-    size_t src_channels = audio_channel_count_from_out_mask(out->channel_mask);
-    size_t dst_channels = out->config.channels;
-    bool channel_remapping_needed = (dst_channels != src_channels);
-
     lock_output_stream(out);
     if (out->standby) {
         pthread_mutex_lock(&adev->lock);
@@ -1875,7 +1869,7 @@
             unsigned audio_bytes;
             const void *audio_data;
 
-            ALOGVV("%s: writing buffer (%zd bytes) to pcm device", __func__, bytes);
+            ALOGVV("%s: writing buffer (%d bytes) to pcm device", __func__, bytes);
             if (pcm_device->resampler && pcm_device->res_buffer) {
                 audio_data = pcm_device->res_buffer;
                 audio_bytes = frames_wr * frame_size;
@@ -1890,37 +1884,6 @@
              */
             apply_dsp(pcm_device, audio_data, audio_bytes/4);
 
-            if (channel_remapping_needed) {
-                unsigned remapped_audio_bytes;
-                const void *remapped_audio_data;
-                int i;
-                int frames_num = audio_bytes / frame_size;
-
-                audio_bytes = audio_bytes * dst_channels / src_channels;
-
-                /* With additional channels, we cannot use original buffer */
-                if (out->proc_buf_size < audio_bytes) {
-                    out->proc_buf_size = audio_bytes;
-                    out->proc_buf_out = (int16_t *)realloc(out->proc_buf_out, audio_bytes);
-                    ALOG_ASSERT((out->proc_buf_out != NULL),
-                                "out_write() failed to reallocate proc_buf_out");
-                }
-                remapped_audio_data = out->proc_buf_out;
-
-                // TODO do not hardcode 16-bit encoding, use audio_stream_out_frame_size() instead
-                int16_t* src_buffer = (int16_t *)audio_data;
-                int16_t* dst_buffer = (int16_t *)remapped_audio_data;
-
-                for (i = frames_num; i > 0; i--)
-                {
-                    memcpy(dst_buffer, src_buffer, src_channels*sizeof(int16_t));
-                    dst_buffer += dst_channels;
-                    src_buffer += src_channels;
-                }
-
-                audio_data = remapped_audio_data;
-            }
-
             pcm_device->status = pcm_write(pcm_device->pcm, audio_data, audio_bytes);
             if (pcm_device->status != 0)
                 ret = pcm_device->status;
@@ -2697,7 +2660,6 @@
     in->source = source;
     in->dev = adev;
     in->standby = 1;
-    config->channel_mask = AUDIO_CHANNEL_INDEX_MASK_2;
     in->main_channels = config->channel_mask;
     in->requested_rate = config->sample_rate;
     if (config->sample_rate != CAPTURE_DEFAULT_SAMPLING_RATE)
diff --git a/audio/hal/audio_hw.h b/audio/hal/audio_hw.h
index bdf89b0..92aff51 100644
--- a/audio/hal/audio_hw.h
+++ b/audio/hal/audio_hw.h
@@ -109,7 +109,7 @@
  */
 #define PLAYBACK_PERIOD_SIZE 512
 #define PLAYBACK_PERIOD_COUNT 2
-#define PLAYBACK_DEFAULT_CHANNEL_COUNT 4
+#define PLAYBACK_DEFAULT_CHANNEL_COUNT 2
 #define PLAYBACK_DEFAULT_SAMPLING_RATE 48000
 #define PLAYBACK_START_THRESHOLD ((PLAYBACK_PERIOD_SIZE * PLAYBACK_PERIOD_COUNT) - 1)
 #define PLAYBACK_STOP_THRESHOLD (PLAYBACK_PERIOD_SIZE * PLAYBACK_PERIOD_COUNT)
@@ -129,7 +129,7 @@
 #define CAPTURE_PERIOD_SIZE 1024
 #define CAPTURE_PERIOD_SIZE_LOW_LATENCY 512
 #define CAPTURE_PERIOD_COUNT 2
-#define CAPTURE_DEFAULT_CHANNEL_COUNT 4
+#define CAPTURE_DEFAULT_CHANNEL_COUNT 2
 #define CAPTURE_DEFAULT_SAMPLING_RATE 48000
 #define CAPTURE_START_THRESHOLD 1
 
@@ -229,8 +229,7 @@
     int                         send_new_metadata;
 
     struct audio_device*        dev;
-    int16_t *proc_buf_out;
-    size_t proc_buf_size;
+
 };
 
 struct stream_in {