IntroductionIntel Edison board provides I2S interface, and the recent firmware adds the I2S support. The default image provides two machine drivers: The default "dummy" driver simply outputs PCM data using I2S in DSP format, 24-bit, 48000 samples per second. The other machine driver is for the WM8958 codec, which appears to be a fairly complicated codec intended to be used in phones and tablets. The straight forward way to add support for another codec (say popular WM8731) is to write a machine driver for it. And I am currently working on it. Meanwhile there is a simpler, but perhaps a bit more hackish way to get audio output working on Edison: by configuring the codec directly using I2C interface, and i2cset command in particular. Hardware SetupThe following hardware is required:
Connect the WM8731 codec to the Intel Edison board as indicated in the table below:
Note: It is likely that most codec breakout boards will have digital and analog power rails connected in some way (e.g. through an inductor based filter). In Edison's case digital I/O is 1.8V and so separate digital and analog supplies must be used. Modify your board accordingly. Note that maximal allowed analog supply voltage is 3.6V. My Prototype SetupSoftware ConfigurationFirst of all Intel Edison board needs to be upgraded to the latest firmware image with I2S support (release 2.1 at the time of writing). The images and instructions are available from Intel at this page. Connect the Intel Edison board with two micro USB cables to your PC, and run a terminal emulator (such as Putty on Windows or screen on Linux) and connect to USB-Serial port. Serial port settings are 115200 bps with 8 data bits and 1 stop bit, no parity. Login with user root, and run the i2cset commands below to configure the codec. Note that i2cset will return "Write failed" error if codec is not responding, e.g. if codec is not connected or powered properly. I2C Configuration Script#!/bin/sh # reset codec i2cset -y 1 0x1a 0x1e 0x00 # disable DAC and output powerdown i2cset -y 1 0x1a 0x0c 0x07 # set volume for headphone output (both channels) i2cset -y 1 0x1a 0x05 0x65 # analog audio path control (DAC enabled) i2cset -y 1 0x1a 0x08 0x12 # digital audio path control i2cset -y 1 0x1a 0x0a 0x00 # set sample rate (48000Hz, assuming 12.288MHz codec clock) i2cset -y 1 0x1a 0x10 0x00 # digital audio interface format set (DSP mode, 24 bit) i2cset -y 1 0x1a 0x0e 0x8b # activate interface i2cset -y 1 0x1a 0x12 0x01 Using the Audio DeviceThe codec is connected to ALSA device hw:1,0 . Refer to the software documentation on configuring the device name. For example in mpg123 player the audio device can be specified using -a switch:mpg123 -a hw:1,0 -v "Dave Brubeck - Take Five.mp3" AlexT's repository has several software packages that support audio output. Output volume can be adjusted by writing headphone out register at address 0x05 (both channels) or 0x04 (left channel) and 0x06 (right channel), e.g.: i2cset -y 1 0x1a 0x05 0x50 References |
Home > Sergey's Blog >