(九)How to use the audio gadget driver

Contents

[hide]

Introduction

This document explains how to enable and use the audio gadget driver, this driver allows to use you board as a audio gadget device for either to work as a audio capture device such as a microphone or to work as an audio receiver device such as speakers.

Audio Gadget Driver 1.0

This driver comes by default into the kernel and is compatible with the USB Audio Class specification 1.0. The current driver allows audio playback mode only and comes wired to the sound system so it automatically uses the default audio decoder to reproduce the audio that is coming from the host machine.

Enabling the audio gadget driver

1. Go to you SDK and open the configuration window make config

2. Go to

-> Kernel configuration
   -> Device Drivers
       -> USB support (USB_SUPPORT [=y])

and activate the Inventra Highspeed Dual Role Controller (TI, ADI, ...) option to be built in the kernel (press space util it shows a * symbol on it).

Once you have selected it you have to change the Driver Mode option to USB Peripheral (gadget stack).

3. Now activate the USB Gadget Support option (check it as built in the kernel) on

-> Kernel configuration
   -> Device Drivers
       -> USB support (USB_SUPPORT [=y])

4. Go to

-> Kernel configuration
   -> Device Drivers
      -> USB support (USB_SUPPORT [=y])
         -> USB Gadget Support (USB_GADGET [=y])

and change the USB Peripheral Controller option to Inventra HDRC USB Peripheral (TI, ADI, ...).

5. Activate the USB Gadget Drivers option as a module (M) in

-> Kernel configuration
   -> Device Drivers
      -> USB support (USB_SUPPORT [=y])
         -> USB Gadget Support (USB_GADGET [=y])

6. Activate the Audio Gadget (EXPERIMENTAL) option as a module (M) in

-> Kernel configuration
   -> Device Drivers
      -> USB support (USB_SUPPORT [=y])
         -> USB Gadget Support (USB_GADGET [=y])

7. Save the changes and exit from the configuration window.

8. Built your SDK (make).

Using the audio gadget driver

Once you have built the driver it is ready to be used. In this example we are using the LeopardBoard DM368. Before start your board you need to change its jumper configuration to device mode instead of host mode, you can do that by removing the jumper J1 and installing jumper between Pin1 and Pin2 on J4.

After booting up the board you can see the following output

Advanced Linux Sound Architecture Driver Version 1.0.21.
No device for DAI tlv320aic3x
No device for DAI davinci-i2s
asoc: tlv320aic3x <-> davinci-i2s mapping ok
ALSA device list:
  #0: DaVinci DM365 EVM (tlv320aic3x)

Then in the board‘s terminal you must load the audio gadget module by running the following command

modprobe g_audio

If everything is fine you will see an output like this

/ # modprobe g_audio
g_audio gadget: Hardware params: access 3, format 2, channels 2, rate 48000
g_audio gadget: audio_buf_size 48000, req_buf_size 200, req_count 256
g_audio gadget: Linux USB Audio Gadget, version: Dec 18, 2008
g_audio gadget: g_audio ready

This way the module has been loaded and the driver is ready to be used. In order to test it you can connect the board to a PC using a USB cable and send an audio streaming to the board.

Once you have connected the board to the PC you can see if it was recognized correctly by running the following command:

cat /proc/asound/cards

the you will get an output like this

~$ cat /proc/asound/cards
 0 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xfe024000 irq 22
 1 [Gadget         ]: USB-Audio - Linux USB Audio Gadget
                      Linux 2.6.32-17-ridgerun with musb_hdrc Linux USB Audio Gadget at usb-0000:00:0

So you can see that the board as been detected as a Linux USB Audio Gadget with ID 1. Now we can playback an audio file using the audio gadget device by running the following command:

aplay -D plug:hw:1 audio_file.wav

Be aware that you must use the same hardware ID we got for the gadget device. After that you will be able to hear the audio content in your board‘s audio output.

原文地址:https://www.cnblogs.com/zhangshenghui/p/11179345.html

时间: 2024-10-13 10:24:07

(九)How to use the audio gadget driver的相关文章

DM816X 实现 USB HID Gadget 鼠标键盘功能

开发环境: 平台: DM8168 内核 :linux 2.6.32 RDK:DVRRDK_04.00.00.03 USB口:DM8168有两个USB口可供选择,因为特殊原因我选择的是USB1,请根据实际需要选择USB口 ,下面的配置会稍微有些不同. 1配置内核 依据参照http://processors.wiki.ti.com/index.php/DM81xx_AM38XX_USB_User_Guide#Introduction http://processors.wiki.ti.com/ind

USB Gadget API for Linux

USB Gadget API for Linux Author: David Brownell Date: 20 August 2004 Introduction This document presents a Linux-USB “Gadget” kernel mode API, for use within peripherals and other USB devices that embed Linux. It provides an overview of the API struc

微软职位内部推荐-SDE2 (Windows driver)

微软近期Open的职位: SDE2 (Windows driver) Job title: Software Development Engineer 2 Location: Shanghai, China Do you want to join Microsoft and work on the latest Windows devices? Do you want to impact hundreds of millions of Windows customers together wit

USB gadget 驱动 printer.c 分析

1. modprobe g_printer idVendor=0x0525 idProduct=0xa4a8 modprobe后面也可以加模块参数 2. prn_example从stdout获取数据然后通过USB发送出去,下面让他将文件中的内容发送出去: # cat data_file | prn_example -write_data 3.pdev = device_create(usb_gadget_class, NULL, devt, NULL, "g_printer%d", d

Android 系统启动过程详解

android 使用 linux 内核,一般运行在 ARM 体系架构上,android 设备启动的过程,应用层之下基本等同于linux, 从应用层第一个程序init开始有所区别,下面开始介绍. step1, boot rom 主要作用是加载 boot loader 进入内存并执行,boot rom 一般固化在芯片上,设备启动加电自检后从固定的地址开始执行 step2,boot loader 分2步执行,boot rom只加载了第一部分bootloader代码进入内存,这部分代码随即加载第二部分b

Android基础01

Android 系统架构: 1.Aplication层 应用层 (浏览器  QQ 微信  通讯录 )  JAVA程序开发 2.Aplication FrameWork应用框架层 (JAVA+JNI   java native interface   JNI是Java语言和底层LINUX C语言的调度器 ) 提供接口和类:包含很多模块 1. Activit (活动 ,四大组件之一)  2.Window Manager (对话框,分辨率) 3.Content provider(内容提供者,四大组件之

Android 4.4 Kitkat 使能 USB adb 功能

背景 在 Linux-3.8 以后,Android 的内核分支,便去掉了 f_adb,改使用 USB function FS,在用户空间实现 USB adb 功能.这篇文章根据原作者的 Google+ 文章,在 Atmel sama5 开发板上做了测试,将步骤记录如下,供需要使用的读者参考,你也可以查看作者原文:https://plus.google.com/111524780435806926688/posts/AaEccFjKNHE 在 Linux-3.10 上使能 USB ADB 编译内核

USB 驱动架构浅析

1.USB简介 USB,即Universal Serial Bus(通用串行总线)的缩写,是一个外部总线标准,用于规范电脑与外部设备的连接和通讯.USB接口支持设备的即插即用和热插拔功能.USB是在1994年底由英特尔.康柏.IBM等多家公司联合提出的.USB版本经历了多年的发展,现已经发展为3.1版本,成为当今PC中的标准扩展接口.当前主要采用USB2.0和USB3.0接口,USB各版本间能很好的兼容. USB采用四线电缆,其中两根是用来传送数据的串行通道,另两根为设备提供电源,对于任何已经成

Mali GPU OpenGL ES 应用性能优化--基本方法

1. 常用优化工具 2. 常用优化方案 OpenGL ES优化的主要工作是在图形管道中找到影响性能的bottleneck,其bottleneck一般表现在以下几方面: ? 在应用程序代码中,如冲突检测     ? GPU与主内存间的数据传输     ? 在VP(Vertex Processor)中的顶点处理     ? 在FP(Fragment Processor)中的片断处理 可通过DS-5 Streamline来定位性能瓶颈(Locate bottleneck).为了获取更好的性能,可从以下