This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fcntl.h> | |
#include <sys/ioctl.h> | |
#include <hwdep.h> | |
#include <error.h> | |
#include <stdio.h> | |
#include "rt56xx_ioctl.h" | |
int main() | |
{ | |
snd_hwdep_t *hwdep; | |
int err; | |
int i; | |
struct rt56xx_cmd cmd; | |
int buf[0x80]; | |
cmd.buf = &buf; | |
if ((err = snd_hwdep_open(&hwdep, "hw:3,0", O_RDWR)) < 0) { | |
printf("snd_hwdep open failed! %s\n",snd_strerror(err)); | |
return -1; | |
} | |
if ((err = snd_hwdep_ioctl(hwdep,RT_READ_ALL_CODEC_REG_IOCTL, &cmd)) < 0 ) { | |
printf("snd_hwdep ioctl failed! %s\n",snd_strerror(err)); | |
return -1; | |
} | |
for(i=0;i<0x80;i++){ | |
printf("%03X, %08X\n",i,buf[i]); | |
} | |
return 0; | |
} |
Android.mk :
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_CFLAGS := \ -fPIC -D_POSIX_SOURCE \ -DALSA_CONFIG_DIR=\"/system/usr/share/alsa\" \ -DALSA_PLUGIN_DIR=\"/system/usr/lib/alsa-lib\" \ -DALSA_DEVICE_DIRECTORY=\"/dev/snd/\" LOCAL_C_INCLUDES := \ external/alsa-lib/include LOCAL_SRC_FILES := \ asound_ioctl.c LOCAL_MODULE_TAGS := eng LOCAL_MODULE := asound_ioctl LOCAL_SHARED_LIBRARIES := \ libaudio \ libasound \ libc include $(BUILD_EXECUTABLE)
要給alsa-lib 的 path
...
...
其中 rt56xx_ioctl.h 就是 alsa device rt56xx 的 driver header, 從 kernel code copy 出來的..
#include <linux/ioctl.h> struct rt56xx_cmd { size_t number; int *buf; }; enum { RT_READ_CODEC_REG_IOCTL = _IOR('R', 0x01, struct rt56xx_cmd), RT_WRITE_CODEC_REG_IOCTL = _IOW('R', 0x01, struct rt56xx_cmd), RT_READ_ALL_CODEC_REG_IOCTL = _IOR('R', 0x02, struct rt56xx_cmd), RT_READ_CODEC_INDEX_IOCTL = _IOR('R', 0x03, struct rt56xx_cmd), RT_WRITE_CODEC_INDEX_IOCTL = _IOW('R', 0x03, struct rt56xx_cmd), RT_READ_CODEC_DSP_IOCTL = _IOR('R', 0x04, struct rt56xx_cmd), RT_WRITE_CODEC_DSP_IOCTL = _IOW('R', 0x04, struct rt56xx_cmd), RT_SET_CODEC_HWEQ_IOCTL = _IOW('R', 0x05, struct rt56xx_cmd), RT_GET_CODEC_HWEQ_IOCTL = _IOR('R', 0x05, struct rt56xx_cmd), RT_SET_CODEC_SPK_VOL_IOCTL = _IOW('R', 0x06, struct rt56xx_cmd), RT_GET_CODEC_SPK_VOL_IOCTL = _IOR('R', 0x06, struct rt56xx_cmd), RT_SET_CODEC_MIC_GAIN_IOCTL = _IOW('R', 0x07, struct rt56xx_cmd), RT_GET_CODEC_MIC_GAIN_IOCTL = _IOR('R', 0x07, struct rt56xx_cmd), RT_SET_CODEC_3D_SPK_IOCTL = _IOW('R', 0x08, struct rt56xx_cmd), RT_GET_CODEC_3D_SPK_IOCTL = _IOR('R', 0x08, struct rt56xx_cmd), RT_SET_CODEC_MP3PLUS_IOCTL = _IOW('R', 0x09, struct rt56xx_cmd), RT_GET_CODEC_MP3PLUS_IOCTL = _IOR('R', 0x09, struct rt56xx_cmd), RT_SET_CODEC_3D_HEADPHONE_IOCTL = _IOW('R', 0x0a, struct rt56xx_cmd), RT_GET_CODEC_3D_HEADPHONE_IOCTL = _IOR('R', 0x0a, struct rt56xx_cmd), RT_SET_CODEC_BASS_BACK_IOCTL = _IOW('R', 0x0b, struct rt56xx_cmd), RT_GET_CODEC_BASS_BACK_IOCTL = _IOR('R', 0x0b, struct rt56xx_cmd), RT_SET_CODEC_DIPOLE_SPK_IOCTL = _IOW('R', 0x0c, struct rt56xx_cmd), RT_GET_CODEC_DIPOLE_SPK_IOCTL = _IOR('R', 0x0c, struct rt56xx_cmd), RT_SET_CODEC_DRC_AGC_ENABLE_IOCTL = _IOW('R', 0x0d, struct rt56xx_cmd), RT_GET_CODEC_DRC_AGC_ENABLE_IOCTL = _IOR('R', 0x0d, struct rt56xx_cmd), RT_SET_CODEC_DSP_MODE_IOCTL = _IOW('R', 0x0e, struct rt56xx_cmd), RT_GET_CODEC_DSP_MODE_IOCTL = _IOR('R', 0x0e, struct rt56xx_cmd), RT_SET_CODEC_WNR_ENABLE_IOCTL = _IOW('R', 0x0f, struct rt56xx_cmd), ....
沒有留言:
張貼留言