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.

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

  1. DM816X 实现 USB HID Gadget 鼠标键盘功能【转】

    转自:https://my.oschina.net/renyongke/blog/410695 开发环境: 平台: DM8168 内核 :linux 2.6.32 RDK:DVRRDK_04.00.0 ...

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

    微软近期Open的职位: SDE2 (Windows driver) Job title: Software Development Engineer 2 Location: Shanghai, Ch ...

  3. Android USB gadget configfs学习笔记总结

    1.一个config_item 是通过显式用户空间mkdir操作创建的,通过rmdir销毁.属性(文件)在mkdir之后出现,可以通过read和write读取或修改属性文件.与sysfs一样,read ...

  4. USB gadget 驱动 printer.c 分析

    1. modprobe g_printer idVendor=0x0525 idProduct=0xa4a8 modprobe后面也可以加模块参数 2. prn_example从stdout获取数据然 ...

  5. Linux usb gadget框架概述

    很幸运,在公司开发了gadget相关驱动,总结下来,大大小小开发了四个与gadget相关的驱动,字符驱动.g_multi.g_ether.g_zero,在这里把自己对gadget的开发中自己的感悟记录 ...

  6. Linux gadget驱动分析1------驱动加载过程

    为了解决一个问题,简单看了一遍linux gadget驱动的加载流程.做一下记录. 使用的内核为linux 2.6.35 硬件为芯唐NUC950. gadget是在UDC驱动上面的一层,如果要编写ga ...

  7. Driver对 (一对两对的对):specific/mini VS general

    老是听说miniport,port,在这里算是搞清楚了.mini就是specific(特殊)的意思.在微软的驱动层次里面,最底层的一般都是比较特殊的,但是为了满足系统的可拓展.可维护.通用等要求,微软 ...

  8. Android系统启动过程-uBoot+Kernel+Android

    摘要:本文是参考大量网上资源在结合自己查看源代码总结出来的,让自己同时也让大家加深对Android系统启动过程有一个更加深入的了解!再次强调,本文的大多数功劳应归功于那些原创者们,同时一些必要的参考链 ...

  9. Android 系统启动过程详解

    android 使用 linux 内核,一般运行在 ARM 体系架构上,android 设备启动的过程,应用层之下基本等同于linux, 从应用层第一个程序init开始有所区别,下面开始介绍. ste ...

随机推荐

  1. 【无线安全实践入门】破解WiFi密码的多个方法

    本文希望可以帮助到想要学习接触此方面.或兴趣使然的你,让你有个大概的印象. 文中可能存在错误操作或错误理解,望大家不吝指正. !阅前须知! 本文是基于我几年前的一本笔记本,上面记录了我学习网络基础时的 ...

  2. 【miscellaneous】多播的实现和需要注意的问题

    多播的实现和需要注意的问题          前段时间研究了一小段时间的网络多播问题,自己很有感触,把自己的经历写出来,希望有需要的可以少走一些弯路.          先说一下原理,我觉得这个还是需 ...

  3. IE11报错:[vuex] vuex requires a Promise polyfill in this browser的问题解决

    昨天其他同事反馈IE浏览器无法打开线上的应用,查看了一下,发现控制台报以下错误: 发现和vuex有关系,去其官网查看了一下文档,发现关于IE浏览器的Promise的问题: 在vue-cli(webpa ...

  4. 一篇学习完rabbitmq基础知识,springboot整合rabbitmq

    一   rabbitmq 介绍 MQ全称为Message Queue,即消息队列, RabbitMQ是由erlang语言开发,基于AMQP(Advanced MessageQueue 高级消息队列协议 ...

  5. DAY 吐

    今天所学: 一,Linux的文件和目录管理 #1 cd( 变更用户所在目录)直接运行cd会进入root的/root下,后面跟目录名,会进入指定目录下( 后面只能是目录名,不能跟文件名). #2 pwd ...

  6. ES6中Set和Map

    1.Set 实例的创建 Set实例它类似于数组,但是成员的值都是唯一的,没有重复的值. Set本身是一个构造函数用来生成Set数据结构. Set 函数可以接受一个数组(或者具有 iterable 接口 ...

  7. 2019牛客暑期多校训练营(第八场)-C CDMA(递归构造)

    题目链接:https://ac.nowcoder.com/acm/contest/888/C 题意:输入m(为2的n次幂,n<=10),构造一个m*m的矩阵满足任意不同的两行的元素乘积和为0. ...

  8. sd卡挂载方法:

    cd mnt//Sdcard创建目录mkdir -m 777 Sdcard//节点挂载mount /dev/msa1  /mnt/Sdcard//抓包./tcpdump -i eth0 tcp por ...

  9. 详解mysql复制机制--异步复制,半同步复制和并行复制

    图4 那么如何并行化,并行IO线程,还是并行SQL线程?其实两方面都可以并行,但是并行SQL线程的收益更大,因为SQL线程做的事情更多(解析,执行).并行IO线程,可以将从Master拉取和写Rela ...

  10. 小记--------sparksql和DataFrame的小小案例java、scala版本

    sparksql是spark中的一个模块,主要用于进行结构化数据的处理,他提供的最核心的编程抽象,就是DataFrame.同时,sparksql还可以作为分布式的sql查询引擎. 最最重要的功能就是从 ...