diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-07-22 11:54:13 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-07-22 11:54:13 -0600 |
commit | cae177b59da01dc14732e18542445ce166753b70 (patch) | |
tree | 9bb30f644a084d3f8299642c9763811a35b9d66a /nuttx/configs/sama5d4-ek/src | |
parent | d1b503397b59eb9826f07b1b6c526e6a3ad96d79 (diff) | |
download | px4-nuttx-cae177b59da01dc14732e18542445ce166753b70.tar.gz px4-nuttx-cae177b59da01dc14732e18542445ce166753b70.tar.bz2 px4-nuttx-cae177b59da01dc14732e18542445ce166753b70.zip |
Add new framework for the PCM decoder. It is now a 'front end' for lower-level drivers like the WM8904 that performs the PCM decoding from end
Diffstat (limited to 'nuttx/configs/sama5d4-ek/src')
-rw-r--r-- | nuttx/configs/sama5d4-ek/src/sam_nsh.c | 24 | ||||
-rw-r--r-- | nuttx/configs/sama5d4-ek/src/sam_wm8904.c | 46 | ||||
-rw-r--r-- | nuttx/configs/sama5d4-ek/src/sama5d4-ek.h | 5 |
3 files changed, 54 insertions, 21 deletions
diff --git a/nuttx/configs/sama5d4-ek/src/sam_nsh.c b/nuttx/configs/sama5d4-ek/src/sam_nsh.c index aeb4fe75b..76ccb2824 100644 --- a/nuttx/configs/sama5d4-ek/src/sam_nsh.c +++ b/nuttx/configs/sama5d4-ek/src/sam_nsh.c @@ -87,7 +87,7 @@ int nsh_archinitialize(void) { #if defined(HAVE_NAND) || defined(HAVE_AT25) || defined(HAVE_HSMCI) || \ - defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) + defined(HAVE_USBHOST) || defined(HAVE_USBMONITOR) || defined(HAVE_WM8904) int ret; #endif @@ -98,7 +98,6 @@ int nsh_archinitialize(void) if (ret < 0) { message("ERROR: sam_nand_automount failed: %d\n", ret); - return ret; } #endif @@ -109,7 +108,6 @@ int nsh_archinitialize(void) if (ret < 0) { message("ERROR: sam_at25_automount failed: %d\n", ret); - return ret; } #endif @@ -122,7 +120,6 @@ int nsh_archinitialize(void) { message("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI0_SLOTNO, HSMCI0_MINOR, ret); - return ret; } #endif @@ -134,7 +131,6 @@ int nsh_archinitialize(void) { message("ERROR: sam_hsmci_initialize(%d,%d) failed: %d\n", HSMCI1_SLOTNO, HSMCI1_MINOR, ret); - return ret; } #endif #endif @@ -148,7 +144,6 @@ int nsh_archinitialize(void) if (ret != OK) { message("ERROR: Failed to initialize USB host: %d\n", ret); - return ret; } #endif @@ -158,9 +153,24 @@ int nsh_archinitialize(void) ret = usbmonitor_start(0, NULL); if (ret != OK) { - message("nsh_archinitialize: Start USB monitor: %d\n", ret); + message("ERROR: Failed to start the USB monitor: %d\n", ret); } #endif +#ifdef HAVE_WM8904 + /* Start the USB Monitor */ + + ret = sam_wm8904_initialize(0); + if (ret != OK) + { + message("ERROR: Failed to initialize WM8904 audio: %d\n", ret); + } +#endif + + /* If we got here then perhaps not all initialization was successful, but + * at least enough succeeded to bring-up NSH with perhaps reduced + * capabilities. + */ + return OK; } diff --git a/nuttx/configs/sama5d4-ek/src/sam_wm8904.c b/nuttx/configs/sama5d4-ek/src/sam_wm8904.c index 09ea542ff..012d33f82 100644 --- a/nuttx/configs/sama5d4-ek/src/sam_wm8904.c +++ b/nuttx/configs/sama5d4-ek/src/sam_wm8904.c @@ -48,6 +48,7 @@ #include <nuttx/i2c.h> #include <nuttx/audio/i2s.h> #include <nuttx/audio/wm8904.h> +#include <nuttx/audio/pcm_decode.h> #include <arch/board/board.h> @@ -220,11 +221,12 @@ static int wm8904_interrupt(int irq, FAR void *context) int sam_wm8904_initialize(int minor) { - FAR struct audio_lowerhalf_s *audio; + FAR struct audio_lowerhalf_s *wm8904; + FAR struct audio_lowerhalf_s *pcm; FAR struct i2c_dev_s *i2c; FAR struct i2s_dev_s *i2s; static bool initialized = false; - char devname[8]; + char devname[12]; int ret; auddbg("minor %d\n", minor); @@ -266,21 +268,20 @@ int sam_wm8904_initialize(int minor) * MW8904 which will return an audio interface. */ - audio = wm8904_initialize(i2c, i2s, &g_mxtinfo.lower, minor); - if (!audio) + wm8904 = wm8904_initialize(i2c, i2s, &g_mxtinfo.lower); + if (!wm8904) { auddbg("Failed to initialize the WM8904\n"); ret = -ENODEV; goto errout_with_i2s; } - /* Configure the DAC master clock. This clock is provided by PCK0 (PB26) - * that is connected to the WM8904 BCLK/GPIO4 and also drives the SSC - * TK0 input clock. + /* Configure the DAC master clock. This clock is provided by PCK2 (PB10) + * that is connected to the WM8904 MCLK. */ sam_sckc_enable(true); - (void)sam_pck_configure(PCK0, PCKSRC_SCK, BOARD_SLOWCLK_FREQUENCY); + (void)sam_pck_configure(PCK2, PCKSRC_SCK, BOARD_SLOWCLK_FREQUENCY); /* Enable the DAC master clock */ @@ -292,21 +293,37 @@ int sam_wm8904_initialize(int minor) ret = irq_attach(IRQ_INT_WM8904, wm8904_interrupt); if (ret < 0) { - auddbg("ERROR: Failed to register WM8904 device: %d\n", ret); + auddbg("ERROR: Failed to attach WM8904 interrupt: %d\n", ret); goto errout_with_audio; } + /* No we can embed the WM8904/I2C/I2S conglomerate into a PCM decoder + * instance so that we will have a PCM front end for the the WM8904 + * driver. + */ + + pcm = pcm_decode_initialize(wm8904); + if (!pcm) + { + auddbg("ERROR: Failed create the PCM decoder\n"); + ret = -ENODEV; + goto errout_with_irq; + } + /* Create a device name */ - snprintf(devname, 8, "wm8904%c", 'a' + minor); + snprintf(devname, 12, "pcm%d", minor); - /* Register the WM8904 audio device */ + /* Finally, we can register the PCM/WM8904/I2C/I2S audio device. + * + * Is anyone young enough to remember Rube Goldberg? + */ - ret = audio_register(devname, audio); + ret = audio_register(devname, pcm); if (ret < 0) { auddbg("ERROR: Failed to register /dev/%s device: %d\n", devname, ret); - goto errout_with_irq; + goto errout_with_pcm; } /* Now we are initialized */ @@ -317,9 +334,10 @@ int sam_wm8904_initialize(int minor) return OK; /* Error exits. Unfortunately there is no mechanism in place now to - * recover errors on initialization failures. + * recover from most errors on initialization failures. */ +errout_with_pcm: errout_with_irq: irq_detach(IRQ_INT_WM8904); errout_with_audio: diff --git a/nuttx/configs/sama5d4-ek/src/sama5d4-ek.h b/nuttx/configs/sama5d4-ek/src/sama5d4-ek.h index 5286716b5..5e6a71d94 100644 --- a/nuttx/configs/sama5d4-ek/src/sama5d4-ek.h +++ b/nuttx/configs/sama5d4-ek/src/sama5d4-ek.h @@ -334,6 +334,11 @@ # undef HAVE_WM8904 # endif +# ifndef CONFIG_AUDIO_FORMAT_PCM +# warning CONFIG_AUDIO_FORMAT_PCM is required for audio support +# undef HAVE_WM8904 +# endif + # ifndef CONFIG_SAMA5D4EK_WM8904_I2CFREQUENCY # warning Defaulting to maximum WM8904 I2C frequency # define CONFIG_SAMA5D4EK_WM8904_I2CFREQUENCY 400000 |