声卡芯片的数据通道一般都是IIS接口,但是控制音量等控制信息的接口都不相同

(新内核在linux-3.4.2\sound\soc\codecs\uda134x.c)

uda134x_codec_probe

  snd_soc_register_codec

    snd_soc_register_dais

      snd_soc_instantiate_cards

        snd_soc_instantiate_card

          snd_card_register

sound\soc\s3c24xx\s3c2410-uda1341.c(新内核在linux-3.4.2\sound\soc\codecs\uda134x.c)
s3c2410_uda1341_init
  driver_register(&s3c2410iis_driver);
    .....
    s3c2410iis_probe
      /* 使能时钟 */
      /* 配置GPIO */

      /* 设置S3C2440的IIS控制器 */
      init_s3c2410_iis_bus

      /* 使用L3接口初始化uda1341芯片 */
      init_uda1341();

      /* 设置两个DMA通道:一个用于播放,另一个用于录音 */
.....

      register_sound_dsp(&smdk2410_audio_fops, -1);
         sound_insert_unit(&chains[3], fops, dev, 3, 131, "dsp", S_IWUSR | S_IRUSR, NULL); // /dev/dsp

      register_sound_mixer(&smdk2410_mixer_fops, -1);
        sound_insert_unit(&chains[0], fops, dev, 0, 128, "mixer", S_IRUSR | S_IWUSR, NULL); // /dev/mixer

/dev/dsp: 用于播放/录音
/dev/mixer: 调整音量

register_sound_mixer和register_sound_dsp所在的文件A,其会做下面工作,在register的时候会把新的file_operation告诉A这一层,在A中注册的时候其file_operation只有一个open函数,在open的时候,会找到register的时候关联的新的file_operation
2. 提供file_operations
3. 注册register_chrdev

app: open () // 假设主设备号为14
-------------------------------------------
  soundcore_open
    int unit = iminor(inode);
    s = __look_for_unit(chain, unit);
      // 从chains数组里得到, 谁来设置这个数组?

    new_fops = fops_get(s->unit_fops);
    file->f_op = new_fops;
    err = file->f_op->open(inode,file);

录音:
app: read
----------------------
file->f_op->read

播放:
app: write
-------------------------
file->f_op->write

测试:
1. 确定内核里已经配置了sound\soc\s3c24xx\s3c2410-uda1341.c
-> Device Drivers
  -> Sound
    -> Advanced Linux Sound Architecture
      -> Advanced Linux Sound Architecture
        -> System on Chip audio support
        <*> I2S of the Samsung S3C24XX chips

2. make uImage
  使用新内核启动

3. ls -l /dev/dsp /dev/mixer
4. 播放:
  在WINDOWS PC里找一个wav文件,放到开发板根文件系统里
  cat Windows.wav > /dev/dsp
5. 录音:
  cat /dev/dsp > sound.bin
然后对着麦克风说话
ctrl+c退出
cat sound.bin > /dev/dsp // 就可以听到录下的声音

怎么写WM8976驱动程序?
1. IIS部分一样,保持不变
2. 控制部分不同,重写

(WM8976当控制接口设置成两线模式的时候就是IIC接口,三线模式的时候则是特殊的接口模式)

测试WM8976:
1. 确定内核里已经配置了sound\soc\s3c24xx\s3c2410-uda1341.c
-> Device Drivers
  -> Sound
    -> Advanced Linux Sound Architecture // 兼容OSS
      -> Advanced Linux Sound Architecture
        -> System on Chip audio support
        <*> I2S of the Samsung S3C24XX chips

2. 修改sound/soc/s3c24xx/Makefile
obj-y += s3c2410-uda1341.o
改为:
obj-y += s3c-wm8976.o

3. make uImage
使用新内核启动

4. ls -l /dev/dsp /dev/mixer
5. 播放:
在WINDOWS PC里找一个wav文件,放到开发板根文件系统里
cat Windows.wav > /dev/dsp
6. 录音:
cat /dev/dsp > sound.bin
然后对着麦克风说话
ctrl+c退出
cat sound.bin > /dev/dsp // 就可以听到录下的声音

(mp3是压缩的声音文件,wav是原始的声音文件,用声卡播放的时候需要解压缩mp3声音文件)

使用madplay测试声卡:
1. 解压:
tar xzf libid3tag-0.15.1b.tar.gz // 库
tar xzf libmad-0.15.1b.tar.gz // 库
tar xzf madplay-0.15.2b.tar.gz // APP

2. 编译 libid3tag-0.15.1b
mkdir tmp
cd libid3tag-0.15.1b
./configure --host=arm-linux --prefix=/work/drivers_and_test/21th_sound/app/tmp
make
make install

3. 编译 libmad-0.15.1b
cd libmad-0.15.1b
./configure --host=arm-linux --prefix=/work/drivers_and_test/21th_sound/app/tmp
make
make install

4. 编译madplay(./configure --help可以查看编译帮助)
cd madplay-0.15.2b/
./configure --host=arm-linux --prefix=/work/drivers_and_test/21th_sound/app/tmp LDFLAGS="-L/work/drivers_and_test/21th_sound/app/tmp/lib" CFLAGS="-I /work/drivers_and_test/21th_sound/app/tmp/include"
make
make install

5. 把tmp/bin/* tmp/lib/*so* 复制到根文件系统:

  cp ./bin/*  /work/nfs_root/first_fs/bin

  cp ./lib/*so*  /work/nfs_root/first_fs/lib -d(保持连接属性)

6. 把一个mp3文件复制到根文件系统

7. madplay --tty-control /1.mp3
播放过程中不断按小键盘的减号("-")会降低音量
不断按小键盘的加号("+")会降低音量

21、IIS声卡驱动程序的更多相关文章

  1. 36、ALSA声卡驱动和应用

    (注意:内核上电的时候会把一些没运行的控制器模块的时钟都关掉,所有在写驱动的时候需要在使用的使用使用clk_get和clk_enable使能时钟) (说明:与ALSA声卡对应的是OSS架构,第二期视频 ...

  2. ALSA声卡11_从零编写之调试——学习笔记

    1.调试 (1)把程序拷贝到服务器上进行编译 (2)把程序放到内核上面去 重新配置内核,吧原来的声卡驱动程序去掉 a. 修改语法错误 11th_myalsa b. 配置内核去掉原来的声卡驱动 -> ...

  3. Tiny6410声卡驱动——录音与回放

    在Linux下,音频设备程序的实现与文件系统的操作密切相关.Linux将各种设备以文件的形式给出统一的接口,这样的设计使得对设备的编程与对文件的操作基本相同,对Linux内核的系统调用也基本一致,从而 ...

  4. ALSA声卡12_从零编写之添加音量控制_学习笔记

    1.设置音量时应用程序的调用过程 (1)strace分析: amixer cset numid=1 30 (设置音量) /dev/snd/controlC0 open SNDRV_CTL_IOCTL_ ...

  5. ALSA声卡07_分析调用过程_学习笔记

    1.编译新的strace工具分析aplay和amixer应用程序对声卡的调用过程 (1)因为旧的strace工具不能识别不能识别alsa声卡驱动程序里面的ioctrl. (2)编译过程参考http:/ ...

  6. ALSA声卡笔记3--ASoC驱动重要结构体关系图

    1.ASoC中重要的数据结构之间的关联方式 (1)Kernel-2.6.35-ASoC中各个结构的静态关系 ASoC把声卡实现为一个Platform Device,然后利用Platform_devic ...

  7. ALSA声卡笔记1---ALSA驱动框架

    1.声卡驱动程序sound.c (1)入口函数里通过register_chrdev()函数注册file_operations 结构体 (2)file_operations 结构体,里面只有open函数 ...

  8. linux&nbsp;dev/dsp&nbsp;声卡学习笔记

    原文地址:dev/dsp 声卡学习笔记">linux dev/dsp 声卡学习笔记作者:ziyou飞翔       无论是从声卡读取数据,或是向声卡写入数据,事实上都具有特定的格式(f ...

  9. 如何以正确的顺序重新安装驱动程序 | Dell 中国

      购买 支持 社区 我的帐户     购买 支持 社区   如何以正确的顺序重新安装驱动程序 在戴尔笔记本电脑或台式机上手动重新安装Microsoft Windows操作系统后,您还必须以正确的顺序 ...

随机推荐

  1. PHP 7.1安装xhprof进行性能分析

    安装扩展该 xhprof扩展版本是从 https://github.com/longxinH/xhprof 获取的(第三方的一个库,官方版本不支持php7) 下载并编译xhprof扩展在web的htm ...

  2. 如何优雅的写UI——(5)选项卡功能实现

    先在我们的选项卡可以说能用了,每个标签页都能点进去,但是这还远远没到能用的地步,比如说你把窗口最大化后. 立马就露出马脚了,所以这篇我们要先讲讲tabctrl的最基本的功能实现 改变选项卡大小 上图的 ...

  3. 【CS Round #39 (Div. 2 only) B】Circle Elimination

    [Link]:https://csacademy.com/contest/round-39/task/circle-elimination/ [Description] [Solution] 把n个点 ...

  4. 一起talk C栗子吧(第三十四回:C语言实例--巧用溢出计算最值)

    各位看官们.大家好,上一回中咱们说的是巧用移位的样例,这一回咱们说的样例是:巧用溢出计算最值. 闲话休提,言归正转.让我们一起talk C栗子吧! 大家都知道,程序中的变量都有一个取值范围,这个范围也 ...

  5. 父子margin塌陷

    1.使用padding 2.给父级使用border 3.给父级添加属性 overflow:hidden 4.浮动 5.定位{absolute,fixed} 6.伪元素代码 .parent:before ...

  6. vector转数组

    vector转数组 由于vector内部的数据是存放在连续的存储空间,vector转数组事实上只需要获取vector中第一个数据的地址和数据的长度即可.如果仅仅是传参,无需任何操作,直接传地址即可,如 ...

  7. [Vue + TS] Use Properties in Vue Components Using @Prop Decorator with TypeScript

    With properties we can follow a one-way parent→child flow communication between components. This les ...

  8. 2lession-文件访问

    今天继续学习python,因为是根据网上的教程,里面用到了一些例子,包含有后面的知识点.但是,因为自己稍微有点c.java等语言基础,所以并没有严格按照教程来学习,反而是遇到知识点就记录下来. 代码如 ...

  9. sqlite3-查看数据库

    在做android开发的时候,有时候我们需要查看系统下的数据库,这时候我们可以使用下面的方法 1.数据库存放位置 data/data/package/databases/abc.db 2.导出数据库 ...

  10. RocketMQ集群消费的那些事

    说明 RocketMQ集群消费的时候,我们经常看到类似注释里面 (1,(2 的写法,已经有时候有同学没注意抛异常的情况就是(3 模拟的情况.那么这3种情况到底是怎么样的呢?你是否都了然于心呢?下面我们 ...