1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 06:29:22 +02:00

m1/patches/rtems: milkymist-audio-add-support-mic-boost.patch remove the mic boost ioctl

This commit is contained in:
Xiangfu 2012-03-29 16:22:22 +08:00
parent 56adfdeb4d
commit 9aeb2f976f

View File

@ -1,16 +1,40 @@
Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c
===================================================================
--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c 2012-03-27 14:03:04.065264002 +0800
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c 2012-03-27 19:24:29.329264002 +0800
@@ -47,6 +47,7 @@
static int play_produce;
static int play_consume;
static int play_level;
+static int mic_boost;
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c 2012-03-29 15:58:14.440242001 +0800
@@ -316,6 +316,7 @@
unsigned int chan, int mono)
{
unsigned int *val = (unsigned int *)buf;
+ int mic_boost;
int codec;
int left, right;
/* buffers played, for application to collect */
static rtems_id play_q_done;
@@ -347,7 +348,7 @@
@@ -328,12 +329,14 @@
return RTEMS_SUCCESSFUL;
}
if (mono) {
- right = left = 100-(((codec & 0x1f) + 1)*100)/32;
+ left = 100-(((codec & 0x1f) + 1)*100)/32;
+ mic_boost = (codec & (1 << 6)) >> 6;
+ *val = left | mic_boost << 8;
} else {
right = 100-(((codec & 0x1f) + 1)*100)/32;
left = 100-((((codec & 0x1f00) >> 8) + 1)*100)/32;
+ *val = left | (right << 8);
}
- *val = left | (right << 8);
return RTEMS_SUCCESSFUL;
}
@@ -341,21 +344,23 @@
unsigned int chan, int mono)
{
unsigned int *val = (unsigned int *)buf;
+ int mic_boost;
int left, right;
int codec;
rtems_status_code sc;
left = *val & 0xff;
left = (left*32)/100 - 1;
@ -18,9 +42,12 @@ Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c
+ if (left < 0)
left = 0;
if (mono)
@@ -355,7 +356,7 @@
else {
- if (mono)
+ if (mono) {
+ mic_boost = *val >> 8;
right = 31;
- else {
+ } else {
right = (*val >> 8) & 0xff;
right = (right*32)/100 - 1;
- if(right < 0)
@ -28,7 +55,7 @@ Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c
right = 0;
}
@@ -365,6 +366,13 @@
@@ -365,6 +370,13 @@
else
codec = (31-left) | ((31-right) << 8);
@ -42,74 +69,3 @@ Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c
if (!write_cr(chan, codec))
sc = RTEMS_UNSATISFIED;
else
@@ -372,6 +380,41 @@
return sc;
}
+static rtems_status_code ioctl_read_mic_boost(void *buf, unsigned int chan)
+{
+ unsigned int *val = (unsigned int *)buf;
+ int codec;
+
+ codec = read_cr(chan);
+ if (codec < 0)
+ return RTEMS_UNSATISFIED;
+
+ *val = (codec & (1 << 6)) >> 6;
+ return RTEMS_SUCCESSFUL;
+}
+
+static rtems_status_code ioctl_write_mic_boost(void *buf, unsigned int chan)
+{
+ unsigned int *val = (unsigned int *)buf;
+ int codec;
+
+ codec = read_cr(chan);
+ if (codec < 0)
+ return RTEMS_UNSATISFIED;
+
+ if (*val)
+ codec |= (1 << 6);
+ else
+ codec &= ~(1 << 6);
+
+ if (!write_cr(chan, codec))
+ return RTEMS_UNSATISFIED;
+
+ mic_boost = codec;
+
+ return RTEMS_SUCCESSFUL;
+}
+
rtems_device_driver ac97_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
@@ -419,6 +462,16 @@
if(sc == RTEMS_SUCCESSFUL)
args->ioctl_return = 0;
return sc;
+ case SOUND_MIXER_READ(SOUND_MIXER_MIC_BOOST):
+ sc = ioctl_read_mic_boost(args->buffer, 0x0e);
+ if(sc == RTEMS_SUCCESSFUL)
+ args->ioctl_return = 0;
+ return sc;
+ case SOUND_MIXER_WRITE(SOUND_MIXER_MIC_BOOST):
+ sc = ioctl_write_mic_boost(args->buffer, 0x0e);
+ if(sc == RTEMS_SUCCESSFUL)
+ args->ioctl_return = 0;
+ return sc;
default:
return RTEMS_UNSATISFIED;
}
Index: rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/milkymist_ac97.h
===================================================================
--- rtems.orig/c/src/lib/libbsp/lm32/shared/milkymist_ac97/milkymist_ac97.h 2012-03-27 14:03:04.085264002 +0800
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/milkymist_ac97.h 2012-03-27 14:03:21.753264002 +0800
@@ -21,6 +21,7 @@
/* Ioctls. 0x41 is 'A' */
#define SOUND_MIXER_MIC 0x0
#define SOUND_MIXER_LINE 0x1
+#define SOUND_MIXER_MIC_BOOST 0x2
#define SOUND_MIXER_READ(x) (0x4100+x)
#define SOUND_MIXER_WRITE(x) (0x4110+x)