1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-15 08:19:41 +02:00

m1/patches/rtems/: Milkymist driver: add mic-boost support

This commit is contained in:
Xiangfu 2012-03-20 17:15:46 +08:00
parent e228723187
commit 901a4836cb
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,73 @@
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)

View File

@ -24,3 +24,4 @@ export-shell-fns.patch # https://www.rtems.org/bugzilla/show_bug.cgi?id=2030
bootp-dhcp-cleanup.patch # https://www.rtems.org/bugzilla/show_bug.cgi?id=2031 bootp-dhcp-cleanup.patch # https://www.rtems.org/bugzilla/show_bug.cgi?id=2031
# usb-firmware-ioctl.patch - applied 2012-03-04 # usb-firmware-ioctl.patch - applied 2012-03-04
# fix-pmem-size.patch - applied 2012-03-06 # fix-pmem-size.patch - applied 2012-03-06
milkymist-audio-add-support-mic-boost.patch