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. c语言数组在作为参数传递时注意事项

    1.不能在[]给定大小 2.不要在被调用函数里使用sizeof(a)/sizeof(a[0])形式传递数组大小,直接给出数组长度,或者在 主调函数中使用sizeof(a)/sizeof(a[0])传递 ...

  2. Unity3D热更新之LuaFramework篇[05]--Lua脚本调用c#以及如何在Lua中使用Dotween

    在上一篇文章 Unity3D热更新之LuaFramework篇[04]--自定义UI监听方法 中,我对LuaBehaviour脚本进行了扩展,添加了两个新的UI监听方法,也提到最好能单写一个脚本处理此 ...

  3. Pytorch构建ResNet

    学了几天Pytorch,大致明白代码在干什么了,贴一下.. import torch from torch.utils.data import DataLoader from torchvision ...

  4. 一个提高照片质量的网站和一个改变照片DPI的方法

    相信很多童鞋都有遇到过,碰到一张很喜欢的图片,想用来做背景什么的,蛋似--因为画质太AV了怕引起误会,所以不敢使用!很气--!! 这时大神就会跳出来说,画质不好?PS是用来吃si的么! 我:我才不会用 ...

  5. 【VS开发】【C/C++开发】printf缓冲区刷新

    printf之缓冲区小结: 今天调试程序,发现了一个有趣的现象,printf函数没有按照预期的结果输出重复的字符串,单步调试显示代码的确走到了打印屏幕的分支,没有显示不由得想到了是不是缓冲区去刷新的问 ...

  6. 如何禁止谷歌浏览器隐藏url的www前缀

    若要将Chrome浏览器的设置恢复为隐藏HTTP.HTTPS以及WWW前缀,则只需再次进入此页面: chrome://flags/#omnibox-ui-hide-steady-state-url-s ...

  7. pmap 命令

    NAME pmap - report memory map of a process SYNOPSIS pmap [ -x | -d ] [ -q ] pids... pmap -V 常用参数: -x ...

  8. [转帖]intel发布会之前,漫谈CPU核心架构:CCX、Ring Bus、Mesh

    intel发布会之前,漫谈CPU核心架构:CCX.Ring Bus.Mesh https://baijiahao.baidu.com/s?id=1607585351741429318&wfr= ...

  9. [转帖]PKI技术原理(收集 整理 归纳)

    PKI技术原理(收集 整理 归纳) https://blog.51cto.com/3layer/20430 总结归纳的 灰常好.. 7layer关注8人评论39427人阅读2007-03-14 11: ...

  10. linux常用终端命令(三)远程管理命令

    三.远程管理常用命令 关机/重启 shutdown 查看或配置网卡信息 ifconfig ping 远程登录和复制文件 ssh scp 1.关机/重启 序号 命令 对应英文 作用 01 shutdow ...