樹莓派聲音︰ I2S

什麼是 I2S 呢?維基百科詞條這麼講︰

I²S

I²SI2S英語:Inter-IC SoundIntegrated Interchip Sound)是IC間傳輸數位音訊資料的一種介面標準,採用序列的方式傳輸2組(左右聲道)資料。I2S常被使用在傳送CDPCM音訊資料到CD播放器的DAC中。由於I2S將資料訊號和時脈訊號分開傳送,它的抖動jitter)失真十分地小。

實有來歷的哩︰

History

This standard was introduced in 1986 by Philips (now NXP) and was last revised in 1996.[1]

Details

The I²S protocol outlines one specific type of PCM digital audio communication with defined parameters outlined in the Philips specification.

The bit clock pulses once for each discrete bit of data on the data lines. The bit clock frequency is the product of the sample rate, the number of bits per channel and the number of channels. So, for example, CD Audio with a sample frequency of 44.1 kHz, with 16 bits of precision and two channels (stereo) has a bit clock frequency of:

44.1 kHz × 16 × 2 = 1.4112 MHz

The word select clock lets the device know whether channel 1 or channel 2 is currently being sent, since I²S allows two channels to be sent on the same data line. For stereo material, the I²S specification states that left audio is transmitted on the low cycle of the word select clock and the right channel is transmitted on the high cycle. The word select clock is a 50% duty-cycle signal that has the same frequency as the sample frequency.

Data are encoded in two’s complement with the MSB (most significant bit) first.[1]:2

The bus consists of at least three lines:

  1. Bit clock line
  2. Word clock line – also called word select (WS) or left right clock (LRCLK)
  3. At least one multiplexed data line

It may also include the following lines:

  1. Master clock (typical 256 x LRCLK)
  2. A multiplexed data line for upload

In audio equipment the I²S sometimes forms an external link between the CD transport and a separate DAC box, contrary to purely internal connection within one player box. This may form an alternative to the commonly used AES/EBU or Toslink or S/PDIF standards. There is no standard interconnecting cable for this application. Some manufacturers provide simply three BNC connectors, an 8P8C (“RJ45”) socket or a DE-9 connector. Others like Audio Alchemy (now defunct) used DIN connectors.

樹莓派之 I2S 規格在 BROADCOM

 

DataSheet 的第一百一拾九頁。

接法及接腳請參照

archphile-logo-minimal

Introduction to Archphile

Summary:
Archphile is an Archlinux ARM/MPD based distribution for Raspberry Pi (B, B+ and 2), Udoo Quad (also dual with some extra steps)  and Cubox-i targeted to users with USB and I2S Dacs.

Some of its features:

  • support for USB and I2S Dacs
  • recompiled mpd 0.19.13 (mpd-archphile) based on mpd-light from AUR  – niceness is set to -16 and lots of mpd features are disabled in each version (press mpd -V for more info)
  • ympd web interface
  • usb disk/flash automounting using udevil.
  • upnp/dlna support using upmpdcli
  • Airplay/shairport using shairport-sync
  • dchp enabled by default
  • reachable with url http://archphile.local if zeroconf is enabled. Windows users please download this package to enable. In any other situation you can find the ip from your router
  • samba/cifs/nfs support – you have configure /etc/fstab  according to your own needs  by modifying the sample lines
  • default credentials:

username: root
password: archphile

  • various webradios based on Volumio github repository.
  • mixer is disabled by default. Use your amp to change the volume level. Ensure that system level is set to 100% using alsamixer command.

 

之說明文件︰

I2S Dacs and the Raspberry Pi

Let’s start with some nice schematics  showing the connections needed:

– Raspberry Pi model B

raspberrypi_i2s_p5-1

 

raspberrypi_i2s_p5_2

 

– Rasbperry Pi model B+ and model 2

raspberrypi_B_plus_i2s_1

 

raspberrypi_B_plus_i2s_2

 

有興趣讀寫驅動程式者,請到這來︰

Linux/sound/soc/bcm/bcm2835-i2s.c

1 /*
2 * ALSA SoC I2S Audio Layer for Broadcom BCM2835 SoC
3 *
4 * Author: Florian Meier <florian.meier@koalo.de>
5 * Copyright 2013
6 *
7 * Based on
8 * Raspberry Pi PCM I2S ALSA Driver
9 * Copyright (c) by Phil Poole 2013
10 *
11 * ALSA SoC I2S (McBSP) Audio Layer for TI DAVINCI processor
12 * Vladimir Barinov, <vbarinov@embeddedalley.com>
13 * Copyright (C) 2007 MontaVista Software, Inc., <source@mvista.com>
14 *
15 * OMAP ALSA SoC DAI driver using McBSP port
16 * Copyright (C) 2008 Nokia Corporation
17 * Contact: Jarkko Nikula <jarkko.nikula@bitmer.com>
18 * Peter Ujfalusi <peter.ujfalusi@ti.com>
19 *
20 * Freescale SSI ALSA SoC Digital Audio Interface (DAI) driver
21 * Author: Timur Tabi <timur@freescale.com>
22 * Copyright 2007-2010 Freescale Semiconductor, Inc.
23 *
24 * This program is free software; you can redistribute it and/or
25 * modify it under the terms of the GNU General Public License
26 * version 2 as published by the Free Software Foundation.
27 *
28 * This program is distributed in the hope that it will be useful, but
29 * WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31 * General Public License for more details.
32 */
33