rk3288_USB_CAMERA+MIC_OK

1#code  ---->>vi  hardware/rk29/audio/AudioUsbAudioHardware.h

diff --git a/AudioUsbAudioHardware.h b/AudioUsbAudioHardware.h
index eadf0cf..1a771f5 100755
--- a/AudioUsbAudioHardware.h
+++ b/AudioUsbAudioHardware.h
@@ -12,7 +12,7 @@
 #include <utils/Log.h>
 #include <utils/String8.h>
 
-#define UA_Path "/proc/asound/card2/stream0"
+#define UA_Path "/proc/asound/card3/stream0"
 #define UA_Record_SampleRate 48000
 #define UA_Playback_SampleRate 48000
 #define RETRY_TIMES 10
@@ -32,7 +32,7 @@ bool has_USBAudio_Speaker_MIC(const char *type)
     for(int i = 0; i < RETRY_TIMES; i++) {
         fd = open(UA_Path,O_RDONLY);
         if(fd < 0) {
-            ALOGV("Can not open /proc/asound/card2/stream0, try time = %d", i + 1);
+            ALOGV("Can not open /proc/asound/card3/stream0, try time = %d", i + 1);
             usleep(RETRY_SLEEPTIME);
             continue;
         }
@@ -40,7 +40,7 @@ bool has_USBAudio_Speaker_MIC(const char *type)
     }
 
     if (fd < 0) {
-        ALOGE("Can't open /proc/asound/card2/stream0, giveup");
+        ALOGE("Can't open /proc/asound/card3/stream0, giveup");
         return false;
     }
 
@@ -68,7 +68,7 @@ uint32_t get_USBAudio_sampleRate(const char *type, uint32_t req_rate)
     for(int i = 0; i < RETRY_TIMES; i++) {
         fd = open(UA_Path,O_RDONLY);
         if(fd < 0) {
-            ALOGV("Can not open /proc/asound/card2/stream0, try time = %d", i + 1);
+            ALOGV("Can not open /proc/asound/card3/stream0, try time = %d", i + 1);
             usleep(RETRY_SLEEPTIME);
             continue;
         }
@@ -76,7 +76,7 @@ uint32_t get_USBAudio_sampleRate(const char *type, uint32_t req_rate)
     }
 
     if (fd < 0) {
-        ALOGE("Can't open /proc/asound/card2/stream0, giveup");
+        ALOGE("Can't open /proc/asound/card3/stream0, giveup");
         return 0;
     }
 
@@ -113,10 +113,15 @@ uint32_t get_USBAudio_sampleRate(const char *type, uint32_t req_rate)
 
         ALOGV("get_USBAudio_sampleRate() Get rate : %d", sampleRate);
 
-        if (sampleRate >= req_rate)
+        if (sampleRate == req_rate)
             break;
 
-        lastSampleRate = sampleRate;
+       if (abs(sampleRate - req_rate) <= abs(lastSampleRate - req_rate)) {
+            lastSampleRate = (sampleRate > req_rate) ? sampleRate : lastSampleRate;
+       }
+
+       if (lastSampleRate == 0)
+           lastSampleRate = sampleRate;
 
         while (nbytes > 0 && *str <= '9' && *str >= '0') {
             str++;
@@ -141,7 +146,7 @@ uint32_t get_USBAudio_Channels(const char *type, uint32_t req_channel)
     for (int i = 0; i < RETRY_TIMES; i++) {
         fd = open(UA_Path, O_RDONLY);
         if (fd < 0) {
-            ALOGD("Can not open /proc/asound/card2/stream0,try time =%d", i + 1);
+            ALOGD("Can not open /proc/asound/card3/stream0,try time =%d", i + 1);
             usleep(RETRY_SLEEPTIME);
             continue;
         }
@@ -149,7 +154,7 @@ uint32_t get_USBAudio_Channels(const char *type, uint32_t req_channel)
     }
 
     if (fd < 0) {
-        ALOGE("Can't open /proc/asound/card2/stream0,giveup");
+        ALOGE("Can't open /proc/asound/card3/stream0,giveup");
         return 0;
     }
 
diff --git a/alsa_audio.h b/alsa_audio.h
index 101fa2a..2076fbf 100755
--- a/alsa_audio.h
+++ b/alsa_audio.h
@@ -37,6 +37,7 @@
 #define PCM_CARD0      0x00000000
 #define PCM_CARD1      0x00000001
 #define PCM_CARD2      0x00000002
+#define PCM_CARD3      0x00000003
 #define PCM_CARD_MASK  0x0000000F
 #define PCM_CARD_SHIFT 0
 
diff --git a/alsa_route.c b/alsa_route.c
index 8e890b6..a567e01 100755
--- a/alsa_route.c
+++ b/alsa_route.c
@@ -434,6 +434,9 @@ struct pcm *route_pcm_open(unsigned route, unsigned int flags)
     case 2:
         flags |= PCM_CARD2;
         break;
+    case 3:
+        flags |= PCM_CARD3;
+        break;
     default:
         flags |= PCM_CARD0;
         break;
diff --git a/codec_config/default_config.h b/codec_config/default_config.h
index aee10fe..3522a73 100755
--- a/codec_config/default_config.h
+++ b/codec_config/default_config.h
@@ -419,12 +419,12 @@ const struct config_route_table default_config_table = {
 
     //usb audio
     .usb_normal = {
-        .sound_card = 2,
+        .sound_card = 3,
         .devices = DEVICES_0,
         .controls_count = 0,
     },
     .usb_capture = {
-        .sound_card = 2,
+        .sound_card = 3,
         .devices = DEVICES_0,
         .controls_count = 0,
     },
-- 
1.9.1



2#

module -->>WXSJ-2657-200W+MIC


评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值