USB 音效卡驅動

    版本為 13:42, 23 Nov 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    網樂通雖然有內建 Audio 模組,不過找不到驅動的方式,所以只能使用外接 USB 音效卡方式。

    要能使用 USB 音效卡,需要的步驟如下:

    1. USB 音效裝置必須有支援 ALSA 驅動
    2. 交叉編譯 STLinux Kernel,使它支援 ALSA 音效裝置,並且編譯成模組
    3. 在網樂通裡,安裝啟動必要的 ALSA 相關驅動模組
    4. 安裝 ALSA 相關套件
      • stlinux23-sh4-alsa-lib
      • stlinux23-sh4-alsa-utils
      • stlinux23-sh4-alsaplayer
    5. 音效播放測試

    交叉編譯 Linux kernel

    編譯參數

    在原編譯檔 .config 的 General setup 上方加上 CONFIG_SOUND=m
    注意: 開始編譯後,會出現許多詢問項目,必須輸入 m 或 y

    CONFIG_SOUND=m
    #
    # General setup
    #
    ..... 
    

    Advanced Linux Sound Architecture (SND) [N/m/?] (NEW) m

     Sequencer support (SND_SEQUENCER) [N/m/?] (NEW) m
        Sequencer dummy client (SND_SEQ_DUMMY) [N/m/?] (NEW) m
      OSS Mixer API (SND_MIXER_OSS) [N/m/?] (NEW) m
      OSS PCM (digital audio) API (SND_PCM_OSS) [N/m/?] (NEW) m
      OSS PCM (digital audio) API - Include plugin system (SND_PCM_OSS_PLUGINS) [Y/n/?] (NEW) y
      OSS Sequencer API (SND_SEQUENCER_OSS) [N/y/?] (NEW) y
      Dynamic device file minor numbers (SND_DYNAMIC_MINORS) [N/y/?] (NEW) y
      Support old ALSA API (SND_SUPPORT_OLD_API) [Y/n/?] (NEW) y
      Verbose procfs contents (SND_VERBOSE_PROCFS) [Y/n/?] (NEW) y
      Verbose printk (SND_VERBOSE_PRINTK) [N/y/?] (NEW) y
     Debug (SND_DEBUG) [N/y/?] (NEW) n

      *
      * Generic devices
      *
      Dummy (/dev/null) soundcard (SND_DUMMY) [N/m/?] (NEW) m
      Virtual MIDI soundcard (SND_VIRMIDI) [N/m/?] (NEW) m
      MOTU MidiTimePiece AV multiport MIDI (SND_MTPAV) [N/m/?] (NEW) m
      UART16550 serial MIDI driver (SND_SERIAL_U16550) [N/m/?] (NEW) m
      Generic MPU-401 UART driver (SND_MPU401) [N/m/?] (NEW) m

    *
    * USB devices
    *
    USB Audio/MIDI driver (SND_USB_AUDIO) [N/m/?] (NEW) m
    Native Instruments USB audio devices (SND_USB_CAIAQ) [N/m/?] (NEW) m
      enable input device for controllers (SND_USB_CAIAQ_INPUT) [N/y/?] (NEW) y

    *
    * System on Chip audio support
    *
    ALSA for SoC audio support (SND_SOC) [N/m/?] (NEW) m
    *
    * STMicroelectronics SoCs support
    *
    STMicroelectronics SoCs support (SND_STM) [N/m/?] (NEW) m
      Name of BPA2 partition to allocate buffers from (SND_STM_BPA2_PARTITION_NAME) [audio] (NEW)
      STx7100 and STx7109 support (SND_STM_STX710X) [N/m/?] (NEW) m
      STx7105 support (SND_STM_STX7105) [M/n/?] (NEW) m
      STx7111 support (SND_STM_STX7111) [N/m/?] (NEW) m
      STx7141 support (SND_STM_STX7141) [N/m/?] (NEW) m
      STx7200 support (SND_STM_STX7200) [N/m/?] (NEW) m
      Dummy converter driver (SND_STM_CONV_DUMMY) [N/m/?] (NEW) m
      Generic GPIO-controlled converter driver (SND_STM_CONV_GPIO) [N/m/?] (NEW) m
      Generic I2C-controlled converter driver (SND_STM_CONV_I2C) [N/m/?] (NEW) m

    *
    * Open Sound System
    *
    Open Sound System (DEPRECATED) (SOUND_PRIME) [N/m/?] (NEW) n

    開始編譯

    make ARCH=sh CROSS_COMPILE=sh4-linux- vmlinux
    make ARCH=sh CROSS_COMPILE=sh4-linux- modules
    make ARCH=sh CROSS_COMPILE=sh4-linux- modules_install INSTALL_MOD_PATH=./modules_install
    

    make the vmlinux.ub

    sh4-linux-objcopy -O binary vmlinux vmlinux.bin
    gzip --best --force vmlinux.bin
    mkimage -A sh -O linux -T kernel -C gzip -a 0x80800000 -e 0x80801000 -n "Linux 2.6" -d vmlinux.bin.gz vmlinux.ub
    

    交叉編譯 ALSA-Lib 與 ALSA-Utils 套件

    套件下載: http://www.alsa-project.org/main/index.php/Download

    alsa-lib

    CC=sh4-linux-gcc \
    ./configure --host=sh4-linux
    
    make
    make install DESTDIR=/home/alang/STLinux_Cross-Compile/build_opt/alsa-lib
    

    alsa-utils

    CC=sh4-linux-gcc \
    ./configure --host=sh4-linux
    
    make
    make install DESTDIR=/home/alang/STLinux_Cross-Compile/build_opt/alsa-utils
    

    安裝 ALSA 驅動模組

    安裝模組檔至以下目錄
    /lib/modules/2.6.23.17_stm23_A18B-PDK7105-32BITS-A18B/kernel/sound
    
    啟動模組
    modprobe snd-usb-audio
    modprobe snd-pcm-oss
    

    TIP:

    如果啟動失敗,必須執行 depmod -a

    檢視安裝後的模組列表

    15:16:12[0]root@sh4twbox ~ # lsmod
    Module                  Size  Used by    Not tainted
    snd_rawmidi            22496  1 snd_usb_lib
    snd_usb_lib            15712  1 snd_usb_audio
    snd_page_alloc          6376  1 snd_pcm
    snd_timer              21060  1 snd_pcm
    snd_mixer_oss          15680  1 snd_pcm_oss
    snd_seq_device          6860  1 snd_rawmidi
    snd_hwdep               7492  1 snd_usb_audio
    snd_pcm                78373  2 snd_pcm_oss,snd_usb_audio
    snd_pcm_oss            47360  0
    snd                    49972  9 snd_pcm_oss,snd_mixer_oss,snd_usb_audio,snd_pcm,snd_timer,snd_usb_lib,snd_rawmidi,snd_seq_device,snd_hwdep
    snd_usb_audio          80128  0
    
    Powered by MindTouch Core