1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-12-19 19:52:48 +02:00
wernermisc/m1/patches/rtems/milkymist-audio-add-support-mic-boost.patch

74 lines
2.3 KiB
Diff

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-20 17:11:20.087160002 +0800
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/ac97.c 2012-03-20 17:12:23.731160001 +0800
@@ -372,6 +372,39 @@
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;
+
+ return RTEMS_SUCCESSFUL;
+}
+
rtems_device_driver ac97_control(
rtems_device_major_number major,
rtems_device_minor_number minor,
@@ -419,6 +452,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-20 17:11:23.791160002 +0800
+++ rtems/c/src/lib/libbsp/lm32/shared/milkymist_ac97/milkymist_ac97.h 2012-03-20 17:12:23.731160001 +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)