[Galaxy 3 Android Development] cdesai:
Difference in sound folder

diff -crB linux/sound g3/sound > sound.patch

diff -crB linux/sound/core/pcm_lib.c g3/sound/core/pcm_lib.c
*** linux/sound/core/pcm_lib.c	2010-02-23 07:38:51.000000000 -0800
--- g3/sound/core/pcm_lib.c	2011-02-26 04:42:03.000000000 -0800
***************
*** 30,35 ****
--- 30,38 ----
#include <sound/pcm_params.h>
#include <sound/timer.h>

+ unsigned int ring_buf_index = 0;
+ unsigned int period_index = 0;
+
/*
* fill ring buffer with silence
* runtime->silence_start: starting pointer to silence area
***************
*** 167,177 ****
struct snd_pcm_runtime *runtime)
{
snd_pcm_uframes_t pos;

pos = substream->ops->pointer(substream);
if (pos == SNDRV_PCM_POS_XRUN)
return pos; /* XRUN */
!	if (pos >= runtime->buffer_size) {
if (printk_ratelimit()) {
char name[16];
pcm_debug_name(substream, name, sizeof(name));
--- 170,187 ----
struct snd_pcm_runtime *runtime)
{
snd_pcm_uframes_t pos;
+	snd_pcm_uframes_t buffer_size;

pos = substream->ops->pointer(substream);
if (pos == SNDRV_PCM_POS_XRUN)
return pos; /* XRUN */
!
!	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
!	buffer_size = runtime->buffer_size * CONFIG_ANDROID_BUF_NUM;
!	else
!	buffer_size = runtime->buffer_size;
!
!	if (pos >= buffer_size) {
if (printk_ratelimit()) {
char name[16];
pcm_debug_name(substream, name, sizeof(name));
***************
*** 190,195 ****
--- 200,206 ----
struct snd_pcm_runtime *runtime)
{
snd_pcm_uframes_t avail;
+	unsigned int stop_threshold;

if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
avail = snd_pcm_playback_avail(runtime);
***************
*** 197,212 ****
avail = snd_pcm_capture_avail(runtime);
if (avail > runtime->avail_max)
runtime->avail_max = avail;
!	if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
!	if (avail >= runtime->buffer_size) {
snd_pcm_drain_done(substream);
!	return -EPIPE;
!	}
!	} else {
!	if (avail >= runtime->stop_threshold) {
xrun(substream);
!	return -EPIPE;
!	}
}
if (avail >= runtime->control->avail_min)
wake_up(&runtime->sleep);
--- 208,225 ----
avail = snd_pcm_capture_avail(runtime);
if (avail > runtime->avail_max)
runtime->avail_max = avail;
!
!	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
!	stop_threshold = runtime->stop_threshold * CONFIG_ANDROID_BUF_NUM;
!	else
!	stop_threshold = runtime->stop_threshold;
!
!	if (avail >= stop_threshold) {
!	if (substream->runtime->status->state == SNDRV_PCM_STATE_DRAINING)
snd_pcm_drain_done(substream);
!	else
xrun(substream);
!	return -EPIPE;
}
if (avail >= runtime->control->avail_min)
wake_up(&runtime->sleep);
***************
*** 260,267 ****
delta = new_hw_ptr - hw_ptr_interrupt;
}
if (delta < 0) {
!	if (runtime->periods == 1 || new_hw_ptr < old_hw_ptr)
!	delta += runtime->buffer_size;
if (delta < 0) {
hw_ptr_error(substream,
"Unexpected hw_pointer value "
--- 273,284 ----
delta = new_hw_ptr - hw_ptr_interrupt;
}
if (delta < 0) {
!	if (runtime->periods == 1 || new_hw_ptr < old_hw_ptr) {
!	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
!	delta += runtime->buffer_size * CONFIG_ANDROID_BUF_NUM;
!	else
!	delta += runtime->buffer_size;
!	}
if (delta < 0) {
hw_ptr_error(substream,
"Unexpected hw_pointer value "
***************
*** 282,288 ****
delta = 0;
#endif
} else {
!	hw_base += runtime->buffer_size;
if (hw_base >= runtime->boundary)
hw_base = 0;
new_hw_ptr = hw_base + pos;
--- 299,308 ----
delta = 0;
#endif
} else {
!	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
!	hw_base += runtime->buffer_size * CONFIG_ANDROID_BUF_NUM;
!	else
!	hw_base += runtime->buffer_size;
if (hw_base >= runtime->boundary)
hw_base = 0;
new_hw_ptr = hw_base + pos;
***************
*** 322,328 ****
/* rebase to interrupt position */
hw_base = new_hw_ptr = hw_ptr_interrupt;
/* align hw_base to buffer_size */
!	hw_base -= hw_base % runtime->buffer_size;
delta = 0;
}
no_jiffies_check:
--- 342,351 ----
/* rebase to interrupt position */
hw_base = new_hw_ptr = hw_ptr_interrupt;
/* align hw_base to buffer_size */
!	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
!	hw_base -= hw_base % runtime->buffer_size * CONFIG_ANDROID_BUF_NUM;
!	else
!	hw_base -= hw_base % runtime->buffer_size;
delta = 0;
}
no_jiffies_check:
***************
*** 388,394 ****
delta = new_hw_ptr - old_hw_ptr;
jdelta = jiffies - runtime->hw_ptr_jiffies;
if (delta < 0) {
!	delta += runtime->buffer_size;
if (delta < 0) {
hw_ptr_error(substream,
"Unexpected hw_pointer value [2] "
--- 411,421 ----
delta = new_hw_ptr - old_hw_ptr;
jdelta = jiffies - runtime->hw_ptr_jiffies;
if (delta < 0) {
!	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
!	delta += runtime->buffer_size * CONFIG_ANDROID_BUF_NUM;
!	else
!	delta += runtime->buffer_size;
!
if (delta < 0) {
hw_ptr_error(substream,
"Unexpected hw_pointer value [2] "
***************
*** 397,403 ****
(long)old_hw_ptr, jdelta);
return 0;
}
!	hw_base += runtime->buffer_size;
if (hw_base >= runtime->boundary)
hw_base = 0;
new_hw_ptr = hw_base + pos;
--- 424,433 ----
(long)old_hw_ptr, jdelta);
return 0;
}
!	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
!	hw_base += runtime->buffer_size * CONFIG_ANDROID_BUF_NUM;
!	else
!	hw_base += runtime->buffer_size;
if (hw_base >= runtime->boundary)
hw_base = 0;
new_hw_ptr = hw_base + pos;
***************
*** 1529,1536 ****
unsigned long flags;
snd_pcm_stream_lock_irqsave(substream, flags);
if (snd_pcm_running(substream) &&
!	snd_pcm_update_hw_ptr(substream) >= 0)
!	runtime->status->hw_ptr %= runtime->buffer_size;
else
runtime->status->hw_ptr = 0;
snd_pcm_stream_unlock_irqrestore(substream, flags);
--- 1559,1570 ----
unsigned long flags;
snd_pcm_stream_lock_irqsave(substream, flags);
if (snd_pcm_running(substream) &&
! snd_pcm_update_hw_ptr(substream) >= 0) {
!	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
!	runtime->status->hw_ptr %= runtime->buffer_size * CONFIG_ANDROID_BUF_NUM;
!	else
!	runtime->status->hw_ptr %= runtime->buffer_size;
!	}
else
runtime->status->hw_ptr = 0;
snd_pcm_stream_unlock_irqrestore(substream, flags);
***************
*** 1734,1740 ****
if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0)
return err;
} else {
!	char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff);
if (copy_from_user(hwbuf, buf, frames_to_bytes(runtime, frames)))
return -EFAULT;
}
--- 1768,1787 ----
if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0)
return err;
} else {
!	char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff)
!	+ (ring_buf_index * frames_to_bytes(runtime, runtime->buffer_size));
!
!	if(frames == runtime->buffer_size)
!	ring_buf_index = (ring_buf_index + 1) % CONFIG_ANDROID_BUF_NUM;
!
!	else if(frames != runtime->buffer_size) {
!	period_index += frames;
!	if(period_index >= runtime->buffer_size) {
!	ring_buf_index = (ring_buf_index + 1) % CONFIG_ANDROID_BUF_NUM;
!	period_index -= runtime->buffer_size;
!	}
!	}
!
if (copy_from_user(hwbuf, buf, frames_to_bytes(runtime, frames)))
return -EFAULT;
}
***************
*** 1792,1797 ****
--- 1839,1848 ----
if (err < 0)
goto _end_unlock;
}
+
+	if(avail > runtime->buffer_size)
+	avail = runtime->buffer_size;
+
frames = size > avail ? avail : size;
cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size;
if (frames > cont)
diff -crB linux/sound/soc/codecs/Kconfig g3/sound/soc/codecs/Kconfig
*** linux/sound/soc/codecs/Kconfig	2010-02-23 07:38:51.000000000 -0800
--- g3/sound/soc/codecs/Kconfig	2011-02-26 04:42:04.000000000 -0800
***************
*** 51,56 ****
--- 51,57 ----
select SND_SOC_WM8988 if SND_SOC_I2C_AND_SPI
select SND_SOC_WM8990 if I2C
select SND_SOC_WM8993 if I2C
+	select SND_SOC_WM8994 if I2C
select SND_SOC_WM9081 if I2C
select SND_SOC_WM9705 if SND_SOC_AC97_BUS
select SND_SOC_WM9712 if SND_SOC_AC97_BUS
***************
*** 205,210 ****
--- 206,214 ----
config SND_SOC_WM8993
tristate

+ config SND_SOC_WM8994
+	tristate
+
config SND_SOC_WM9081
tristate

diff -crB linux/sound/soc/codecs/Makefile g3/sound/soc/codecs/Makefile
*** linux/sound/soc/codecs/Makefile	2010-02-23 07:38:51.000000000 -0800
--- g3/sound/soc/codecs/Makefile	2011-02-26 04:42:04.000000000 -0800
***************
*** 31,36 ****
--- 31,37 ----
snd-soc-wm8776-objs := wm8776.o
snd-soc-wm8900-objs := wm8900.o
snd-soc-wm8903-objs := wm8903.o
+ snd-soc-wm8994-objs := wm8994.o wm8994_apollo.o wm8994_gain.o
snd-soc-wm8940-objs := wm8940.o
snd-soc-wm8960-objs := wm8960.o
snd-soc-wm8961-objs := wm8961.o
***************
*** 89,94 ****
--- 90,96 ----
obj-$(CONFIG_SND_SOC_WM8988)	+= snd-soc-wm8988.o
obj-$(CONFIG_SND_SOC_WM8990)	+= snd-soc-wm8990.o
obj-$(CONFIG_SND_SOC_WM8993)	+= snd-soc-wm8993.o
+ obj-$(CONFIG_SND_SOC_WM8994)	+= snd-soc-wm8994.o
obj-$(CONFIG_SND_SOC_WM9081)	+= snd-soc-wm9081.o
obj-$(CONFIG_SND_SOC_WM9705)	+= snd-soc-wm9705.o
obj-$(CONFIG_SND_SOC_WM9712)	+= snd-soc-wm9712.o
Only in g3/sound/soc/codecs: wm8994_apollo.c
Only in g3/sound/soc/codecs: wm8994.c
Only in g3/sound/soc/codecs: wm8994_def.h
Only in g3/sound/soc/codecs: wm8994_gain.c
Only in g3/sound/soc/codecs: wm8994_gain.h
diff -crB linux/sound/soc/Kconfig g3/sound/soc/Kconfig
*** linux/sound/soc/Kconfig	2010-02-23 07:38:51.000000000 -0800
--- g3/sound/soc/Kconfig	2011-02-26 04:42:04.000000000 -0800
***************
*** 34,39 ****
--- 34,41 ----
source "sound/soc/pxa/Kconfig"
source "sound/soc/s3c24xx/Kconfig"
source "sound/soc/s6000/Kconfig"
+ # 091211 Apollo(s5p6442) Sound Config
+ source "sound/soc/s5p/Kconfig"
source "sound/soc/sh/Kconfig"
source "sound/soc/txx9/Kconfig"

diff -crB linux/sound/soc/Makefile g3/sound/soc/Makefile
*** linux/sound/soc/Makefile	2010-02-23 07:38:51.000000000 -0800
--- g3/sound/soc/Makefile	2011-02-26 04:42:04.000000000 -0800
***************
*** 12,16 ****
--- 12,17 ----
obj-$(CONFIG_SND_SOC)	+= pxa/
obj-$(CONFIG_SND_SOC)	+= s3c24xx/
obj-$(CONFIG_SND_SOC)	+= s6000/
+ obj-$(CONFIG_SND_SOC)	+= s5p/
obj-$(CONFIG_SND_SOC)	+= sh/
obj-$(CONFIG_SND_SOC)	+= txx9/
Only in g3/sound/soc: s5p