LoginSignup
12
12

More than 5 years have passed since last update.

Raspberry Pi2 に I2S DACを接続する

Last updated at Posted at 2016-11-10

Raspberry Pi2 で I2S DACを使ってみました。

Raspberry Pi 3 でも手順は一緒だと思います。

環境

  • Raspberry Pi 2 model B
    • OS:Raspbian
  • aliexepress で 7.59USDで売っている PCM5102Aのボード (URL)

Raspberry Pi2とDAC基板の接続

PCM5102A board Raspberry Pi2 J8
BCK 12 GPIO1 PCM_CLK
DATA 40 GPIO29 PCM_DOUT
LRCK 35 GPIO24 PCM_FS
GND 39 GND
GND 接続してない
VCC 02 5V
  • PCM5102は3.3V駆動ですが、PCM5102Aボードに載っているレギュレータで3.3Vを生成するためにボードには5Vを供給します。

RaspbianのI2S設定

  • HiFiBerry DACの設定を使います。

device treeの設定

  • /boot/config.txtを編集
  • ピンの設定をI2Sにして、ドライバとのマッピングをします。
dtoverlay=hifiberry-dac

ドライバの設定

  • 最近のRaspbianにはドライバが含まれているのカーネルのコンパイルは不要。
  • /etc/modulesを編集。
  • 起動時にドライバ snd_soc_hifiberry_dac をロードするようにします。
snd_soc_hifiberry_dac

I2Sのテスト

  • ドライバの確認
pi@raspberrypi:~ $ lsmod
Module                  Size  Used by
binfmt_misc             6388  1
cfg80211              427855  0
rfkill                 16037  1 cfg80211
snd_bcm2835            20511  0
bcm2835_gpiomem         3040  0
snd_soc_bcm2835_i2s     6354  2
bcm2835_wdt             3225  0
snd_soc_pcm5102a        1763  1
uio_pdrv_genirq         3164  0
uio                     8000  1 uio_pdrv_genirq
snd_soc_hifiberry_dac     2511  0
snd_soc_core          125885  3 snd_soc_bcm2835_i2s,snd_soc_hifiberry_dac,snd_soc_pcm5102a
snd_pcm_dmaengine       3391  1 snd_soc_core
snd_pcm                75698  4 snd_bcm2835,snd_soc_core,snd_soc_hifiberry_dac,snd_pcm_dmaengine
snd_timer              19160  1 snd_pcm
snd                    51844  4 snd_bcm2835,snd_soc_core,snd_timer,snd_pcm
i2c_dev                 5859  0
fuse                   83461  3
ipv6                  347530  34
  • サウンドデバイスの確認 card1に割り当てらています。
    • card 0, card 1の割り当てが起動毎に異なることがあります。
pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
  • 音の再生 card1を指定して再生します。
$ aplay -D hw:1,0 test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo

ドライバ

  • linux kernelのドライバは sound/soc/bcm のあたりにある。
  • PCM5102Aのドライバはsound/soc/codecs/pcm5102a.cにある。
12
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12