l.yang | d8a9a30 | 2024-10-11 15:20:32 +0800 | [diff] [blame] | 1 | From afee7eee3c07cb19d97bd7a5da74979da4488f55 Mon Sep 17 00:00:00 2001 |
| 2 | From: l.yang <l.yang@mobiletek.cn> |
| 3 | Date: Thu, 10 Oct 2024 15:01:10 +0800 |
| 4 | Subject: [PATCH] [Feature][T106_eSDK]update from T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11.01 to T106-V2.01.01.02P56U06.AP.17.02_CAP.17.02.02 -- code |
| 5 | |
| 6 | Only Configure: No |
| 7 | Affected branch: master |
| 8 | Affected module: unknow |
| 9 | Is it affected on both ZXIC and MTK: only ZXIC |
| 10 | Self-test: Yes |
| 11 | Doc Update: No |
| 12 | |
| 13 | Change-Id: Ib96b45ce27a9cc1e8e774c42334dfb86aa0da634 |
| 14 | --- |
| 15 | |
| 16 | diff --git a/esdk/layers/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf b/esdk/layers/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf |
| 17 | index 55ad19c..e90d0da 100755 |
| 18 | --- a/esdk/layers/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf |
| 19 | +++ b/esdk/layers/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf |
| 20 | @@ -85,7 +85,8 @@ |
| 21 | #DISTRO_FEATURES += "MMI_LCD" |
| 22 | #è¯é³æ§å¶ |
| 23 | DISTRO_FEATURES += "voice_alsa" |
| 24 | -#DISTRO_FEATURES += "use_voice_buffer" |
| 25 | +DISTRO_FEATURES += "use_voice_buffer" |
| 26 | +#DISTRO_FEATURES += "voice_at" |
| 27 | |
| 28 | #cap_oem.img |
| 29 | DISTRO_FEATURES += " oemfs " |
| 30 | @@ -138,8 +139,10 @@ |
| 31 | CUSTOM_MACRO += " -D_USE_CODEC_ES8311 " |
| 32 | CUSTOM_MACRO += "${@bb.utils.contains('DISTRO_FEATURES', 'voice_alsa', '-D_USE_VOICE_ALSA', '', d)}" |
| 33 | CUSTOM_MACRO += "${@bb.utils.contains('DISTRO_FEATURES', 'use_voice_buffer', '-D_USE_VOICE_BUFFER', '', d)}" |
| 34 | +CUSTOM_MACRO += "${@bb.utils.contains('DISTRO_FEATURES', 'voice_at', '-D_USE_VOICE_AT', '', d)}" |
| 35 | #CONFIG_VB_TRANSMIT_INTF = "RTP" |
| 36 | #CONFIG_VB_TRANSMIT_INTF = "USB" |
| 37 | +CONFIG_VB_TRANSMIT_INTF = "NULL" |
| 38 | CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_VB_TRANSMIT_INTF', 'RTP', '-D_VB_TRANSMIT_INTF_RTP', '', d)}" |
| 39 | CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_VB_TRANSMIT_INTF', 'USB', '-D_VB_TRANSMIT_INTF_USB', '', d)}" |
| 40 | #wifi é
ç½® |
| 41 | @@ -153,6 +156,8 @@ |
| 42 | CONFIG_TEL_API_SUPPORT = "RIL" |
| 43 | |
| 44 | CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'BL', '-D_USE_BL', '', d)}" |
| 45 | + |
| 46 | +#RIL ATé鿝æRPMSGæ¨¡å¼ |
| 47 | CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', '-DZXIC_ATCHN_RPMSG_MODE', '', d)}" |
| 48 | CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', '-DUSE_CUSTOM_YK', '', d)}" |
| 49 | |
| 50 | @@ -163,6 +168,9 @@ |
| 51 | CONFIG_MSMSVR_CODEC_TYPE = "NONE" |
| 52 | CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_MSMSVR_CODEC_TYPE', 'FFMPEG', '-D_USE_FFMPEG', '', d)}" |
| 53 | |
| 54 | +#æ¯å¦ä½¿ç¨æ°çä¿¡å·å¼ºåº¦å½ä»¤ |
| 55 | +CONFIG_USE_NEW_SIGNAL_STRENGTH = "yes" |
| 56 | + |
| 57 | # app and libs é
ç½® |
| 58 | #normalççæ¬åºç¨ååº |
| 59 | zxic_lib += "\ |
| 60 | @@ -454,11 +462,11 @@ |
| 61 | MOBILETEK_ADB_LOGIN = "NO" |
| 62 | |
| 63 | #cz.li@20240221 add for MOBILETEK_GNSS_UPDATE_ENABLE value: "yes","no" |
| 64 | -MOBILETEK_GNSS_UPDATE_ENABLE = "no" |
| 65 | +MOBILETEK_GNSS_UPDATE_ENABLE = "yes" |
| 66 | |
| 67 | #xf.li@20240716 add for MOBILETEK_LOG_ENCRYPT value: "enable","disable" |
| 68 | MOBILETEK_LOG_ENCRYPT = "disable" |
| 69 | |
| 70 | LYNQ_CONFIG_COMMITID = "e2a3410390ff0ad762462ccb6af8faa5e16dcd61" |
| 71 | -LYNQ_CONFIG_VERSION = "T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11" |
| 72 | -LYNQ_CONFIG_SW_VERSION = "T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11.01" |
| 73 | +LYNQ_CONFIG_VERSION = "T106-V2.01.01.02P56U09.AP.17.02_CAP.17.02.02" |
| 74 | +LYNQ_CONFIG_SW_VERSION = "T106-V2.01.01.02P56U09.AP.17.02_CAP.17.02" |
| 75 | diff --git a/esdk/layers/meta-zxic-custom/conf/lynq_base.conf b/esdk/layers/meta-zxic-custom/conf/lynq_base.conf |
| 76 | index be8f374..e391546 100755 |
| 77 | --- a/esdk/layers/meta-zxic-custom/conf/lynq_base.conf |
| 78 | +++ b/esdk/layers/meta-zxic-custom/conf/lynq_base.conf |
| 79 | @@ -67,6 +67,6 @@ |
| 80 | #OEMAPP_CFG value:"PLATFORM","GSW" |
| 81 | MOBILETEK_OEMAPP_CFG = "PLATFORM" |
| 82 | |
| 83 | -LYNQ_CONFIG_COMMITID = "7495f7cb5c99259bdcbb21cdf89b9e0324ac444b" |
| 84 | -LYNQ_CONFIG_VERSION = "T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11" |
| 85 | -LYNQ_CONFIG_SW_VERSION = "T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11.01" |
| 86 | +LYNQ_CONFIG_COMMITID = "9aea88bb79cfb2fae9ddab87f8307126d618aec2" |
| 87 | +LYNQ_CONFIG_VERSION = "T106-V2.01.01.02P56U09.AP.17.02_CAP.17.02.02" |
| 88 | +LYNQ_CONFIG_SW_VERSION = "T106-V2.01.01.02P56U09.AP.17.02_CAP.17.02" |
| 89 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_sys b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 90 | index 636cedd..eade5dc 100755 |
| 91 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 92 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 93 | @@ -439,7 +439,6 @@ |
| 94 | NGECALL_FORTEST=0 |
| 95 | CUSTOMER_FLAG=0 |
| 96 | #for volte end |
| 97 | -DEBUG_INFO_DISABLE=0 |
| 98 | DEBUG_INFO_FILE_PATH=/mnt/userdata |
| 99 | DEBUG_INFO_FILE_NUM=2 |
| 100 | DEBUG_INFO_FILE_TOTAL_SIZE=1 |
| 101 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_user b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 102 | index 7839262..5234be8 100755 |
| 103 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 104 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 105 | @@ -78,6 +78,10 @@ |
| 106 | br_ipchange_flag= |
| 107 | br_node=usblan0+zvnet0 |
| 108 | br_node_cap=zvnet0 |
| 109 | +br_node_num= |
| 110 | +br_node0= |
| 111 | +br_node1= |
| 112 | +br_node2= |
| 113 | clat_fake_subnet=192.0.168.0 |
| 114 | clat_frag_collect_timeout=300 |
| 115 | clat_local_mapping_timeout=300 |
| 116 | @@ -490,7 +494,10 @@ |
| 117 | gw_in_cap=0 |
| 118 | #yes-on no-off |
| 119 | cc_at_debug=no |
| 120 | -xlat_enable=0 |
| 121 | +xlat_enable=1 |
| 122 | ecallmode=2 |
| 123 | telog_path_cap= |
| 124 | telog_path= |
| 125 | +zpsstate_detect=1 |
| 126 | +zpsstate_detect_period=60 |
| 127 | +zpsstate_restart=0 |
| 128 | \ No newline at end of file |
| 129 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_sys b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 130 | index 57c1ad7..014d309 100755 |
| 131 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 132 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 133 | @@ -439,7 +439,6 @@ |
| 134 | NGECALL_FORTEST=0 |
| 135 | CUSTOMER_FLAG=0 |
| 136 | #for volte end |
| 137 | -DEBUG_INFO_DISABLE=0 |
| 138 | DEBUG_INFO_FILE_PATH=/mnt/userdata |
| 139 | DEBUG_INFO_FILE_NUM=2 |
| 140 | DEBUG_INFO_FILE_TOTAL_SIZE=1 |
| 141 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_user b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 142 | index dc03706..7147993 100755 |
| 143 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 144 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_4Gb/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 145 | @@ -78,6 +78,10 @@ |
| 146 | br_ipchange_flag= |
| 147 | br_node=usblan0+zvnet0 |
| 148 | br_node_cap=zvnet0 |
| 149 | +br_node_num= |
| 150 | +br_node0= |
| 151 | +br_node1= |
| 152 | +br_node2= |
| 153 | clat_fake_subnet=192.0.168.0 |
| 154 | clat_frag_collect_timeout=300 |
| 155 | clat_local_mapping_timeout=300 |
| 156 | @@ -490,6 +494,9 @@ |
| 157 | gw_in_cap=0 |
| 158 | #yes-on no-off |
| 159 | cc_at_debug=no |
| 160 | -xlat_enable=0 |
| 161 | +xlat_enable=1 |
| 162 | telog_path_cap= |
| 163 | telog_path= |
| 164 | +zpsstate_detect=1 |
| 165 | +zpsstate_detect_period=60 |
| 166 | +zpsstate_restart=0 |
| 167 | \ No newline at end of file |
| 168 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/rcS b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/rcS |
| 169 | index e7959fe..0cb2386 100755 |
| 170 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/rcS |
| 171 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/rcS |
| 172 | @@ -35,5 +35,6 @@ |
| 173 | |
| 174 | . /etc/rc.local |
| 175 | |
| 176 | +sh /etc/lynq_monitor.sh & |
| 177 | exit 0 |
| 178 | |
| 179 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh |
| 180 | index 5c6648f..0d099dd 100755 |
| 181 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh |
| 182 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh |
| 183 | @@ -1,5 +1,31 @@ |
| 184 | #!/bin/sh |
| 185 | |
| 186 | +#jb.qi add for uci check start |
| 187 | +check_copy_file() { |
| 188 | + if [ $# -ne 2 ];then |
| 189 | + return |
| 190 | + fi |
| 191 | + |
| 192 | + diff $1 $2 > /dev/null |
| 193 | + if [ $? -ne 0 ]; then |
| 194 | + echo "cp $1 $2" > /dev/kmsg |
| 195 | + cp $1 $2 |
| 196 | + fi |
| 197 | +} |
| 198 | + |
| 199 | +check_uci() |
| 200 | +{ |
| 201 | + uci get lynq_uci.lynq_ril > /dev/null |
| 202 | + if [ $? -ne 0 ]; then |
| 203 | + echo "$TAG: lynq_uci config cant get" > /dev/kmsg |
| 204 | + cp /etc/config/lynq_uci /mnt/userdata/config/lynq_uci |
| 205 | + fi |
| 206 | +} |
| 207 | +mkdir /mnt/userdata/config |
| 208 | +check_uci |
| 209 | +check_copy_file /etc/config/lynq_uci_ro /mnt/userdata/config/lynq_uci_ro |
| 210 | + |
| 211 | +#jb.qi add for uci check end |
| 212 | ramdump_mode=`nv get ramdump_mode` |
| 213 | |
| 214 | if [ -e /proc/sys/ramdump_ap/ramdump_start_addr ]; then |
| 215 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/lynq_monitor.sh b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/lynq_monitor.sh |
| 216 | new file mode 100755 |
| 217 | index 0000000..72e61c7 |
| 218 | --- /dev/null |
| 219 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/lynq_monitor.sh |
| 220 | @@ -0,0 +1,60 @@ |
| 221 | +#!/bin/sh |
| 222 | +while true |
| 223 | +do |
| 224 | + sleep 30 |
| 225 | + ps -ef|grep lynq-sdk-ready |grep -v "grep" > /dev/null |
| 226 | + if [ $? -ne 0 ]; then |
| 227 | + echo "lynq-sdk-ready no exist" > /dev/kmsg |
| 228 | + sh /etc/init.d/lynq-sdk-ready.sh start |
| 229 | + else |
| 230 | + ps -A -ostat,pid,comm |grep lynq-sdk-ready| grep Z > /dev/null |
| 231 | + if [ $? -eq 0 ]; then |
| 232 | + echo "lynq-sdk-ready state is Z" > /dev/kmsg |
| 233 | + pid=$(ps -A -ostat,pid,comm |grep lynq-sdk-ready|grep Z|awk '{print $2}') |
| 234 | + kill -9 $pid |
| 235 | + sh /etc/init.d/lynq-sdk-ready.sh start |
| 236 | + fi |
| 237 | + fi |
| 238 | + |
| 239 | + ps -ef|grep lynq-atcid |grep -v "grep" > /dev/null |
| 240 | + if [ $? -ne 0 ]; then |
| 241 | + echo "lynq-atcid no exist" > /dev/kmsg |
| 242 | + sh /etc/init.d/lynq-atcid.sh start |
| 243 | + else |
| 244 | + ps -A -ostat,pid,comm |grep lynq-atcid| grep Z > /dev/null |
| 245 | + if [ $? -eq 0 ]; then |
| 246 | + echo "lynq-atcid state is Z" > /dev/kmsg |
| 247 | + pid=$(ps -A -ostat,pid,comm |grep lynq-atcid|grep Z|awk '{print $2}') |
| 248 | + kill -9 $pid |
| 249 | + sh /etc/init.d/lynq-atcid.sh start |
| 250 | + fi |
| 251 | + fi |
| 252 | + |
| 253 | + ps -ef|grep lynq-ril-service |grep -v "grep" > /dev/null |
| 254 | + if [ $? -ne 0 ]; then |
| 255 | + echo "lynq-ril-service no exist" > /dev/kmsg |
| 256 | + sh /etc/init.d/lynq-ril-service.sh start |
| 257 | + else |
| 258 | + ps -A -ostat,pid,comm |grep lynq-ril-service| grep Z > /dev/null |
| 259 | + if [ $? -eq 0 ]; then |
| 260 | + echo "lynq-ril-service state is Z" > /dev/kmsg |
| 261 | + pid=$(ps -A -ostat,pid,comm |grep lynq-ril-service|grep Z|awk '{print $2}') |
| 262 | + kill -9 $pid |
| 263 | + sh /etc/init.d/lynq-ril-service.sh start |
| 264 | + fi |
| 265 | + fi |
| 266 | + |
| 267 | + ps -ef|grep autosuspend |grep -v "grep" > /dev/null |
| 268 | + if [ $? -ne 0 ]; then |
| 269 | + echo "lynq-autosuspend no exist" > /dev/kmsg |
| 270 | + sh /etc/init.d/lynq-autosuspend.sh start |
| 271 | + else |
| 272 | + ps -A -ostat,pid,comm |grep autosuspend| grep Z > /dev/null |
| 273 | + if [ $? -eq 0 ]; then |
| 274 | + echo "lynq-autosuspend state is Z" > /dev/kmsg |
| 275 | + pid=$(ps -A -ostat,pid,comm |grep autosuspend|grep Z|awk '{print $2}') |
| 276 | + kill -9 $pid |
| 277 | + sh /etc/init.d/lynq-autosuspend.sh start |
| 278 | + fi |
| 279 | + fi |
| 280 | +done |
| 281 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/profile b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/profile |
| 282 | index d8cbfdf..ba1dfaf 100755 |
| 283 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/profile |
| 284 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/profile |
| 285 | @@ -1,2 +1,2 @@ |
| 286 | |
| 287 | -PATH="/sbin:/bin:/usr/sbin:/usr/bin:/mnt/oem/bin" |
| 288 | +PATH="/sbin:/usr/sbin:/bin:/usr/bin" |
| 289 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_sys b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 290 | index da7ced4..d5b8bbf 100755 |
| 291 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 292 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 293 | @@ -451,7 +451,6 @@ |
| 294 | NGECALL_FORTEST=0 |
| 295 | CUSTOMER_FLAG=0 |
| 296 | #for volte end |
| 297 | -DEBUG_INFO_DISABLE=0 |
| 298 | DEBUG_INFO_FILE_PATH=/mnt/userdata |
| 299 | DEBUG_INFO_FILE_NUM=2 |
| 300 | DEBUG_INFO_FILE_TOTAL_SIZE=1 |
| 301 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 302 | index d43a308..f082891 100755 |
| 303 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 304 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 305 | @@ -78,6 +78,10 @@ |
| 306 | br_ipchange_flag= |
| 307 | br_node=usblan0+zvnet0 |
| 308 | br_node_cap=zvnet0 |
| 309 | +br_node_num= |
| 310 | +br_node0= |
| 311 | +br_node1= |
| 312 | +br_node2= |
| 313 | clat_fake_subnet=192.0.168.0 |
| 314 | clat_frag_collect_timeout=300 |
| 315 | clat_local_mapping_timeout=300 |
| 316 | @@ -346,7 +350,7 @@ |
| 317 | ACL_mode=0 |
| 318 | AuthMode=WPA2PSK |
| 319 | Channel=0 |
| 320 | -wifi_acs_num=5 |
| 321 | +wifi_acs_num=3 |
| 322 | closeEnable=0 |
| 323 | closeTime= |
| 324 | CountryCode=CN |
| 325 | @@ -432,6 +436,26 @@ |
| 326 | wifi_profile8= |
| 327 | wifi_profile9= |
| 328 | wifi_profile_num=0 |
| 329 | +wifi_prof_ssid= |
| 330 | +wifi_prof_ssid1= |
| 331 | +wifi_prof_ssid2= |
| 332 | +wifi_prof_ssid3= |
| 333 | +wifi_prof_ssid4= |
| 334 | +wifi_prof_ssid5= |
| 335 | +wifi_prof_ssid6= |
| 336 | +wifi_prof_ssid7= |
| 337 | +wifi_prof_ssid8= |
| 338 | +wifi_prof_ssid9= |
| 339 | +wifi_prof_pw= |
| 340 | +wifi_prof_pw1= |
| 341 | +wifi_prof_pw2= |
| 342 | +wifi_prof_pw3= |
| 343 | +wifi_prof_pw4= |
| 344 | +wifi_prof_pw5= |
| 345 | +wifi_prof_pw6= |
| 346 | +wifi_prof_pw7= |
| 347 | +wifi_prof_pw8= |
| 348 | +wifi_prof_pw9= |
| 349 | wifi_root_dir= |
| 350 | wifi_sta_connection=0 |
| 351 | wifi_wps_index=1 |
| 352 | @@ -465,7 +489,9 @@ |
| 353 | wifi_11n_cap_5g=1 |
| 354 | WirelessMode_5g=6 |
| 355 | Channel_5g=0 |
| 356 | +# zw.wang [wifi] If the 5G hotspot is enabled, the country code cannot be obtained by calling qser_wifi_ap_channel_get on 20240829 start |
| 357 | CountryCode_5g=CN |
| 358 | +# zw.wang [wifi] If the 5G hotspot is enabled, the country code cannot be obtained by calling qser_wifi_ap_channel_get on 20240829 end |
| 359 | MAX_Access_num_5g=32 |
| 360 | m_MAX_Access_num_5g=0 |
| 361 | ACL_mode_5g=0 |
| 362 | @@ -511,7 +537,7 @@ |
| 363 | at_at_d= |
| 364 | at_ptsnum= |
| 365 | quick_dial=1 |
| 366 | -cap_port_name=/dev/ttyGS0 |
| 367 | +cap_port_name=/dev/ttyGS0+/dev/ttyGS1 |
| 368 | customIndCmdList= |
| 369 | defrt_cid=1 |
| 370 | MaxRtrAdvInterval=1800 |
| 371 | @@ -519,7 +545,10 @@ |
| 372 | gw_in_cap=0 |
| 373 | #yes-on no-off |
| 374 | cc_at_debug=no |
| 375 | -xlat_enable=0 |
| 376 | +xlat_enable=1 |
| 377 | ecallmode=2 |
| 378 | telog_path_cap= |
| 379 | telog_path= |
| 380 | +zpsstate_detect=1 |
| 381 | +zpsstate_detect_period=60 |
| 382 | +zpsstate_restart=0 |
| 383 | \ No newline at end of file |
| 384 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/sbin/fdisk_emmc.sh b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/sbin/fdisk_emmc.sh |
| 385 | index 492f934..ad96881 100755 |
| 386 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/sbin/fdisk_emmc.sh |
| 387 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/sbin/fdisk_emmc.sh |
| 388 | @@ -15,7 +15,7 @@ |
| 389 | p |
| 390 | 1 |
| 391 | |
| 392 | -+200M |
| 393 | ++256M |
| 394 | n |
| 395 | p |
| 396 | 2 |
| 397 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_systemd/fs/normal/rootfs/etc_ro/default/default_parameter_sys b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_systemd/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 398 | index 57c1ad7..014d309 100755 |
| 399 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_systemd/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 400 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_systemd/fs/normal/rootfs/etc_ro/default/default_parameter_sys |
| 401 | @@ -439,7 +439,6 @@ |
| 402 | NGECALL_FORTEST=0 |
| 403 | CUSTOMER_FLAG=0 |
| 404 | #for volte end |
| 405 | -DEBUG_INFO_DISABLE=0 |
| 406 | DEBUG_INFO_FILE_PATH=/mnt/userdata |
| 407 | DEBUG_INFO_FILE_NUM=2 |
| 408 | DEBUG_INFO_FILE_TOTAL_SIZE=1 |
| 409 | diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_systemd/fs/normal/rootfs/etc_ro/default/default_parameter_user b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_systemd/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 410 | index 3fbb096..92191d4 100755 |
| 411 | --- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_systemd/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 412 | +++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_systemd/fs/normal/rootfs/etc_ro/default/default_parameter_user |
| 413 | @@ -78,6 +78,10 @@ |
| 414 | br_ipchange_flag= |
| 415 | br_node=usblan0+zvnet0 |
| 416 | br_node_cap=zvnet0 |
| 417 | +br_node_num= |
| 418 | +br_node0= |
| 419 | +br_node1= |
| 420 | +br_node2= |
| 421 | clat_fake_subnet=192.0.168.0 |
| 422 | clat_frag_collect_timeout=300 |
| 423 | clat_local_mapping_timeout=300 |
| 424 | @@ -488,6 +492,6 @@ |
| 425 | MaxRtrAdvInterval=1800 |
| 426 | dhcps_in_cap=1 |
| 427 | gw_in_cap=0 |
| 428 | -xlat_enable=0 |
| 429 | +xlat_enable=1 |
| 430 | telog_path_cap= |
| 431 | telog_path= |
| 432 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb b/esdk/layers/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb |
| 433 | index 2eb9488..dd600c2 100755 |
| 434 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb |
| 435 | +++ b/esdk/layers/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb |
| 436 | @@ -50,11 +50,11 @@ |
| 437 | fi
|
| 438 | if [ "${MOBILETEK_GNSS_UPDATE_ENABLE}" = "yes" ]; then
|
| 439 | install -d ${D}/data/gnss_update
|
| 440 | - install -m 644 ${WORKONSRC}HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQALS.ANT.EPH.CFG.PPS13.240115R1.bin ${D}/data/gnss_update
|
| 441 | - install -m 644 ${WORKONSRC}HD8122.YIKE.GN3.115200.0037.dbd12.53ef0.GAQBS.B1C.ANT.EPH.CFG.PPS13.240416R1.bin ${D}/data/gnss_update
|
| 442 | + install -m 644 ${WORKONSRC}HD8122.YF.GN3.115200.10038.c8069.53ef0.231110R2.GALQS.PPS9.CFG.EPHSave.bin ${D}/data/gnss_update
|
| 443 | + install -m 644 ${WORKONSRC}HD8122.YIKE.GN3.115200.0041.a8fb4.53ef0.GAQBS.B1C.ANT.EPH.CFG.PPS13.240912R1.bin ${D}/data/gnss_update
|
| 444 | install -m 644 ${WORKONSRC}agps.conf ${D}/data/gnss_update
|
| 445 | - ln -sf ./HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQALS.ANT.EPH.CFG.PPS13.240115R1.bin ${D}/data/gnss_update/HD.bin
|
| 446 | - ln -sf ./HD8122.YIKE.GN3.115200.0037.dbd12.53ef0.GAQBS.B1C.ANT.EPH.CFG.PPS13.240416R1.bin ${D}/data/gnss_update/HD_BD.bin
|
| 447 | + ln -sf ./HD8122.YF.GN3.115200.10038.c8069.53ef0.231110R2.GALQS.PPS9.CFG.EPHSave.bin ${D}/data/gnss_update/HD.bin
|
| 448 | + ln -sf ./HD8122.YIKE.GN3.115200.0041.a8fb4.53ef0.GAQBS.B1C.ANT.EPH.CFG.PPS13.240912R1.bin ${D}/data/gnss_update/HD_BD.bin
|
| 449 | fi
|
| 450 | }
|
| 451 |
|
| 452 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/LICENSE b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/LICENSE |
| 453 | deleted file mode 100755 |
| 454 | index 1b15bd2..0000000 |
| 455 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/LICENSE |
| 456 | +++ /dev/null |
| 457 | @@ -1,31 +0,0 @@ |
| 458 | -opyright Statement: |
| 459 | - |
| 460 | -This software/firmware and related documentation ("MobileTek Software") are |
| 461 | -protected under relevant copyright laws. The information contained herein is |
| 462 | -confidential and proprietary to MobileTek Inc. and/or its licensors. Without |
| 463 | -the prior written permission of MobileTek inc. and/or its licensors, any |
| 464 | -reproduction, modification, use or disclosure of MobileTek Software, and |
| 465 | -information contained herein, in whole or in part, shall be strictly |
| 466 | -prohibited. |
| 467 | - |
| 468 | -MobileTek Inc. (C) 2015. All rights reserved. |
| 469 | - |
| 470 | -BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 471 | -THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MobileTek SOFTWARE") |
| 472 | -RECEIVED FROM MobileTek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER |
| 473 | -ON AN "AS-IS" BASIS ONLY. MobileTek EXPRESSLY DISCLAIMS ANY AND ALL |
| 474 | -WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED |
| 475 | -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR |
| 476 | -NONINFRINGEMENT. NEITHER DOES MobileTek PROVIDE ANY WARRANTY WHATSOEVER WITH |
| 477 | -RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, |
| 478 | -INCORPORATED IN, OR SUPPLIED WITH THE MobileTek SOFTWARE, AND RECEIVER AGREES |
| 479 | -TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. |
| 480 | -RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO |
| 481 | -OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MobileTek |
| 482 | -SOFTWARE. MobileTek SHALL ALSO NOT BE RESPONSIBLE FOR ANY MobileTek SOFTWARE |
| 483 | -RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR |
| 484 | -STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MobileTek'S |
| 485 | -ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MobileTek SOFTWARE |
| 486 | -RELEASED HEREUNDER WILL BE, AT MobileTek'S OPTION, TO REVISE OR REPLACE THE |
| 487 | -MobileTek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE |
| 488 | -CHARGE PAID BY RECEIVER TO MobileTek FOR SUCH MobileTek SOFTWARE AT ISSUE. |
| 489 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend.c b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend.c |
| 490 | deleted file mode 100755 |
| 491 | index ff653f6..0000000 |
| 492 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend.c |
| 493 | +++ /dev/null |
| 494 | @@ -1,101 +0,0 @@ |
| 495 | -/* |
| 496 | - * Copyright (C) 2012 The Android Open Source Project |
| 497 | - * |
| 498 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
| 499 | - * you may not use this file except in compliance with the License. |
| 500 | - * You may obtain a copy of the License at |
| 501 | - * |
| 502 | - * http://www.apache.org/licenses/LICENSE-2.0 |
| 503 | - * |
| 504 | - * Unless required by applicable law or agreed to in writing, software |
| 505 | - * distributed under the License is distributed on an "AS IS" BASIS, |
| 506 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 507 | - * See the License for the specific language governing permissions and |
| 508 | - * limitations under the License. |
| 509 | - */ |
| 510 | - |
| 511 | -#define LOG_TAG "AUTOSUSPEND" |
| 512 | - |
| 513 | -#include <stdbool.h> |
| 514 | - |
| 515 | -#include <log/log.h> |
| 516 | -#include <liblog/lynq_deflog.h> |
| 517 | - |
| 518 | -#include "autosuspend.h" |
| 519 | - |
| 520 | -#include "autosuspend_ops.h" |
| 521 | - |
| 522 | -static struct autosuspend_ops *autosuspend_ops; |
| 523 | -static bool autosuspend_enabled; |
| 524 | -static bool autosuspend_inited; |
| 525 | - |
| 526 | -static int autosuspend_init(void) |
| 527 | -{ |
| 528 | - if (autosuspend_inited) { |
| 529 | - return 0; |
| 530 | - } |
| 531 | - |
| 532 | - autosuspend_ops = autosuspend_wakeup_count_init(); |
| 533 | - if (autosuspend_ops) { |
| 534 | - goto out; |
| 535 | - } |
| 536 | - |
| 537 | - if (!autosuspend_ops) { |
| 538 | - ALOGI("failed to initialize autosuspend\n"); |
| 539 | - return -1; |
| 540 | - } |
| 541 | - |
| 542 | -out: |
| 543 | - autosuspend_inited = true; |
| 544 | - |
| 545 | - ALOGI("autosuspend initialized\n"); |
| 546 | - return 0; |
| 547 | -} |
| 548 | - |
| 549 | -int autosuspend_enable(void) |
| 550 | -{ |
| 551 | - int ret; |
| 552 | - |
| 553 | - ret = autosuspend_init(); |
| 554 | - if (ret) { |
| 555 | - return ret; |
| 556 | - } |
| 557 | - |
| 558 | - ALOGI("autosuspend_enable\n"); |
| 559 | - |
| 560 | - if (autosuspend_enabled) { |
| 561 | - return 0; |
| 562 | - } |
| 563 | - |
| 564 | - ret = autosuspend_ops->enable(); |
| 565 | - if (ret) { |
| 566 | - return ret; |
| 567 | - } |
| 568 | - |
| 569 | - autosuspend_enabled = true; |
| 570 | - return 0; |
| 571 | -} |
| 572 | - |
| 573 | -int autosuspend_disable(void) |
| 574 | -{ |
| 575 | - int ret; |
| 576 | - |
| 577 | - ret = autosuspend_init(); |
| 578 | - if (ret) { |
| 579 | - return ret; |
| 580 | - } |
| 581 | - |
| 582 | - ALOGI("autosuspend_disable\n"); |
| 583 | - |
| 584 | - if (!autosuspend_enabled) { |
| 585 | - return 0; |
| 586 | - } |
| 587 | - |
| 588 | - ret = autosuspend_ops->disable(); |
| 589 | - if (ret) { |
| 590 | - return ret; |
| 591 | - } |
| 592 | - |
| 593 | - autosuspend_enabled = false; |
| 594 | - return 0; |
| 595 | -} |
| 596 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend.h b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend.h |
| 597 | deleted file mode 100755 |
| 598 | index 59188a8..0000000 |
| 599 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend.h |
| 600 | +++ /dev/null |
| 601 | @@ -1,58 +0,0 @@ |
| 602 | -/* |
| 603 | - * Copyright (C) 2012 The Android Open Source Project |
| 604 | - * |
| 605 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
| 606 | - * you may not use this file except in compliance with the License. |
| 607 | - * You may obtain a copy of the License at |
| 608 | - * |
| 609 | - * http://www.apache.org/licenses/LICENSE-2.0 |
| 610 | - * |
| 611 | - * Unless required by applicable law or agreed to in writing, software |
| 612 | - * distributed under the License is distributed on an "AS IS" BASIS, |
| 613 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 614 | - * See the License for the specific language governing permissions and |
| 615 | - * limitations under the License. |
| 616 | - */ |
| 617 | - |
| 618 | -#ifndef _LIBSUSPEND_AUTOSUSPEND_H_ |
| 619 | -#define _LIBSUSPEND_AUTOSUSPEND_H_ |
| 620 | - |
| 621 | -#include <sys/cdefs.h> |
| 622 | -#include <stdbool.h> |
| 623 | - |
| 624 | -__BEGIN_DECLS |
| 625 | - |
| 626 | -/* |
| 627 | - * autosuspend_enable |
| 628 | - * |
| 629 | - * Turn on autosuspend in the kernel, allowing it to enter suspend if no |
| 630 | - * wakelocks/wakeup_sources are held. |
| 631 | - * |
| 632 | - * |
| 633 | - * |
| 634 | - * Returns 0 on success, -1 if autosuspend was not enabled. |
| 635 | - */ |
| 636 | -int autosuspend_enable(void); |
| 637 | - |
| 638 | -/* |
| 639 | - * autosuspend_disable |
| 640 | - * |
| 641 | - * Turn off autosuspend in the kernel, preventing suspend and synchronizing |
| 642 | - * with any in-progress resume. |
| 643 | - * |
| 644 | - * Returns 0 on success, -1 if autosuspend was not disabled. |
| 645 | - */ |
| 646 | -int autosuspend_disable(void); |
| 647 | - |
| 648 | -/* |
| 649 | - * set_wakeup_callback |
| 650 | - * |
| 651 | - * Set a function to be called each time the device returns from suspend. |
| 652 | - * success is true if the suspend was sucessful and false if the suspend |
| 653 | - * aborted due to some reason. |
| 654 | - */ |
| 655 | -void set_wakeup_callback(void (*func)(bool success)); |
| 656 | - |
| 657 | -__END_DECLS |
| 658 | - |
| 659 | -#endif |
| 660 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend.service b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend.service |
| 661 | deleted file mode 100755 |
| 662 | index 3cbb46c..0000000 |
| 663 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend.service |
| 664 | +++ /dev/null |
| 665 | @@ -1,10 +0,0 @@ |
| 666 | -[Unit] |
| 667 | -Description=lynq-autosuspend-service |
| 668 | - |
| 669 | -[Service] |
| 670 | -ExecStart=/usr/bin/autosuspend |
| 671 | -Type=simple |
| 672 | - |
| 673 | -[Install] |
| 674 | -WantedBy=multi-user.target |
| 675 | - |
| 676 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend_ops.h b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend_ops.h |
| 677 | deleted file mode 100755 |
| 678 | index 698e25b..0000000 |
| 679 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend_ops.h |
| 680 | +++ /dev/null |
| 681 | @@ -1,29 +0,0 @@ |
| 682 | -/* |
| 683 | - * Copyright (C) 2012 The Android Open Source Project |
| 684 | - * |
| 685 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
| 686 | - * you may not use this file except in compliance with the License. |
| 687 | - * You may obtain a copy of the License at |
| 688 | - * |
| 689 | - * http://www.apache.org/licenses/LICENSE-2.0 |
| 690 | - * |
| 691 | - * Unless required by applicable law or agreed to in writing, software |
| 692 | - * distributed under the License is distributed on an "AS IS" BASIS, |
| 693 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 694 | - * See the License for the specific language governing permissions and |
| 695 | - * limitations under the License. |
| 696 | - */ |
| 697 | - |
| 698 | -#ifndef _LIBSUSPEND_AUTOSUSPEND_OPS_H_ |
| 699 | -#define _LIBSUSPEND_AUTOSUSPEND_OPS_H_ |
| 700 | - |
| 701 | -struct autosuspend_ops { |
| 702 | - int (*enable)(void); |
| 703 | - int (*disable)(void); |
| 704 | -}; |
| 705 | - |
| 706 | -struct autosuspend_ops *autosuspend_autosleep_init(void); |
| 707 | -struct autosuspend_ops *autosuspend_earlysuspend_init(void); |
| 708 | -struct autosuspend_ops *autosuspend_wakeup_count_init(void); |
| 709 | - |
| 710 | -#endif |
| 711 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend_wakeup_count.c b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend_wakeup_count.c |
| 712 | deleted file mode 100755 |
| 713 | index c7cc274..0000000 |
| 714 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/autosuspend_wakeup_count.c |
| 715 | +++ /dev/null |
| 716 | @@ -1,765 +0,0 @@ |
| 717 | -/* |
| 718 | - * Copyright (C) 2012 The Android Open Source Project |
| 719 | - * |
| 720 | - * Licensed under the Apache License, Version 2.0 (the "License"); |
| 721 | - * you may not use this file except in compliance with the License. |
| 722 | - * You may obtain a copy of the License at |
| 723 | - * |
| 724 | - * http://www.apache.org/licenses/LICENSE-2.0 |
| 725 | - * |
| 726 | - * Unless required by applicable law or agreed to in writing, software |
| 727 | - * distributed under the License is distributed on an "AS IS" BASIS, |
| 728 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 729 | - * See the License for the specific language governing permissions and |
| 730 | - * limitations under the License. |
| 731 | - */ |
| 732 | - |
| 733 | -#define LOG_TAG "AUTOSUSPEND" |
| 734 | -//#define LOG_NDEBUG 0 |
| 735 | - |
| 736 | -#include <errno.h> |
| 737 | -#include <fcntl.h> |
| 738 | -#include <pthread.h> |
| 739 | -#include <semaphore.h> |
| 740 | -#include <stddef.h> |
| 741 | -#include <stdbool.h> |
| 742 | -#include <string.h> |
| 743 | -#include <sys/param.h> |
| 744 | -#include <sys/stat.h> |
| 745 | -#include <sys/types.h> |
| 746 | -#include <sys/time.h> |
| 747 | -#include <libsim/lynq_sim.h> |
| 748 | - |
| 749 | -#include <unistd.h> |
| 750 | -#include <dlfcn.h> |
| 751 | -//#include <cutils/properties.h> |
| 752 | -#define USER_LOG_TAG "PMS" |
| 753 | -#include <liblog/lynq_deflog.h> |
| 754 | -#include <include/lynq_uci.h> |
| 755 | - |
| 756 | -#include <log/log.h> |
| 757 | -#include <stdlib.h> |
| 758 | -#include "autosuspend_ops.h" |
| 759 | -#include <sc_mnet_whitelist.h> |
| 760 | -#include <sc_at.h> |
| 761 | -#define SYS_POWER_STATE "/sys/power/state" |
| 762 | - |
| 763 | -#define SYS_POWER_WAKEUP_COUNT "/sys/power/wakeup_count" |
| 764 | -#define SYS_POWER_SPM_SUSPEND_CRTL "/sys/power/spm/suspend_ctrl" |
| 765 | - |
| 766 | -#define BASE_SLEEP_TIME 100000 |
| 767 | -#define POSSIBLE_MAX_SLEEP_TIME 60000000 |
| 768 | -#define LOG_UCI_MODULE "lynq_autosuspend" |
| 769 | -#define LOG_UCI_FILE "lynq_uci" |
| 770 | - |
| 771 | -static int state_fd; |
| 772 | -static int wakeup_count_fd; |
| 773 | -static int suspend_ctrl_fd; |
| 774 | -static pthread_t suspend_thread; |
| 775 | -static sem_t suspend_lockout; |
| 776 | -extern pthread_cond_t feedback_cond; |
| 777 | -extern pthread_mutex_t feedback_mutex; |
| 778 | -extern pthread_mutex_t time_info_mutex; |
| 779 | -static const char *sleep_state = "mem"; |
| 780 | -#ifdef MOBILETEK_SUSPEND_CFG |
| 781 | -static const char *reg_netsys[5] = {"reg_netsys_srcclkena_mask_b 0", |
| 782 | - "reg_netsys_infra_req_mask_b 0", |
| 783 | - "reg_netsys_apsrc_req_mask_b 0", |
| 784 | - "reg_netsys_vrf18_req_mask_b 0", |
| 785 | - "reg_netsys_ddr_en_mask_b 0"}; |
| 786 | -#endif |
| 787 | -static void (*wakeup_func)(bool success) = NULL; |
| 788 | -static int sleep_time = BASE_SLEEP_TIME; |
| 789 | -static int possible_max_sleep_time = POSSIBLE_MAX_SLEEP_TIME; |
| 790 | - |
| 791 | -extern int adb_debug_mode; |
| 792 | - |
| 793 | -static long start_time; // åºéç¹ï¼time_info_t ç»æä½ä¸¤ä¸ªæå齿¯longï¼å æ¤è¿ä¸¤ä¸ªåéå¿
é¡»æ¯longåï¼ä¸è½å®ä¹æint |
| 794 | -static long end_time; |
| 795 | - |
| 796 | - |
| 797 | - |
| 798 | -# define TEMP_FAILURE_RETRY(expression) \ |
| 799 | - (__extension__ \ |
| 800 | - ({ long int __result; \ |
| 801 | - do __result = (long int) (expression); \ |
| 802 | - while (__result == -1L && errno == EINTR); \ |
| 803 | - __result; })) |
| 804 | - |
| 805 | - |
| 806 | -pid_t pid = 0; |
| 807 | - |
| 808 | -enum { |
| 809 | - PARTIAL_WAKE_LOCK = 1, // the cpu stays on, but the screen is off |
| 810 | - FULL_WAKE_LOCK = 2 // the screen is also on |
| 811 | -}; |
| 812 | - |
| 813 | -// while you have a lock held, the device will stay on at least at the |
| 814 | -// level you request. |
| 815 | - |
| 816 | -struct time_info_t |
| 817 | -{ |
| 818 | - long sleep_start_time; |
| 819 | - long wakeup_time; |
| 820 | -}; |
| 821 | - |
| 822 | -extern struct time_info_t time_info; |
| 823 | - |
| 824 | -struct timeval tv; |
| 825 | - |
| 826 | -#ifdef MOBILETEK_SUSPEND_CFG |
| 827 | -void *dlHandle_wakelock; |
| 828 | -void *dlHandle_log; |
| 829 | -void *dlHandle_network; |
| 830 | -static void* dlHandle_sim; |
| 831 | - |
| 832 | -int (*lynq_screen)(int num); |
| 833 | -int (*lynq_sim_init)(int utoken); |
| 834 | -int (*acquire_wake_lock)(int lock, const char* id); |
| 835 | -int (*release_wake_lock)(const char* id); |
| 836 | -int (*lynq_query_registration_state)(const char *type,int* regState,int* imsRegState,char * LAC,char * CID,int * |
| 837 | -netType,int *radioTechFam,int *errorCode); |
| 838 | -int (*lynq_network_init)(int utoken); |
| 839 | - |
| 840 | -void init_wakelock_func(void) |
| 841 | -{ |
| 842 | - const char *lynqLibPath_WakeLock = "/usr/lib64/libpower.so"; |
| 843 | - const char *lynqLibPath_Log = "/lib64/liblynq-log.so"; |
| 844 | - |
| 845 | - dlHandle_wakelock = dlopen(lynqLibPath_WakeLock, RTLD_NOW); |
| 846 | - if (dlHandle_wakelock == NULL) |
| 847 | - { |
| 848 | - ALOGI("dlopen lynqLibPath_WakeLock failed: %s", dlerror()); |
| 849 | - exit(EXIT_FAILURE); |
| 850 | - } |
| 851 | - dlHandle_log = dlopen(lynqLibPath_Log, RTLD_NOW); |
| 852 | - if (dlHandle_log == NULL) |
| 853 | - { |
| 854 | - ALOGI("dlopen dlHandle_log failed: %s", dlerror()); |
| 855 | - exit(EXIT_FAILURE); |
| 856 | - } |
| 857 | - acquire_wake_lock = (int(*)(int,const char*))dlsym(dlHandle_wakelock, "acquire_wake_lock"); |
| 858 | - if (acquire_wake_lock == NULL) { |
| 859 | - ALOGI("acquire_wake_lock not defined or exported in %s", lynqLibPath_WakeLock); |
| 860 | - exit(EXIT_FAILURE); |
| 861 | - } |
| 862 | - release_wake_lock = (int(*)( const char*))dlsym(dlHandle_wakelock, "release_wake_lock"); |
| 863 | - if (release_wake_lock == NULL) { |
| 864 | - ALOGI("release_wake_lock not defined or exported in %s", lynqLibPath_WakeLock); |
| 865 | - exit(EXIT_FAILURE); |
| 866 | - } |
| 867 | - dlerror(); // Clear any previous dlerror |
| 868 | - |
| 869 | - return; |
| 870 | -} |
| 871 | - |
| 872 | - void init_sim_func() |
| 873 | -{ |
| 874 | - int res; |
| 875 | - const char *lynqLibPath_Sim = "/lib64/liblynq-sim.so"; |
| 876 | - |
| 877 | - pid = getpid(); |
| 878 | - dlHandle_sim = dlopen(lynqLibPath_Sim, RTLD_NOW); |
| 879 | - if (dlHandle_sim == NULL) |
| 880 | - { |
| 881 | - ALOGI("dlopen lynqLibPath_Sim failed: %s", dlerror()); |
| 882 | - exit(EXIT_FAILURE); |
| 883 | - } |
| 884 | - |
| 885 | - lynq_screen = (int(*)(int))dlsym(dlHandle_sim, "lynq_screen"); |
| 886 | - if (lynq_screen == NULL) { |
| 887 | - ALOGI("lynq_screen not defined or exported in %s", lynqLibPath_Sim); |
| 888 | - exit(EXIT_FAILURE); |
| 889 | - } |
| 890 | - |
| 891 | - lynq_sim_init = (int(*)(int utoken))dlsym(dlHandle_sim,"lynq_sim_init"); |
| 892 | - if (lynq_sim_init == NULL) { |
| 893 | - ALOGI("lynq_sim_init not defined or exported in %s", lynqLibPath_Sim); |
| 894 | - exit(EXIT_FAILURE); |
| 895 | - } |
| 896 | - dlerror(); // Clear any previous dlerror |
| 897 | - |
| 898 | - res = lynq_sim_init((int)pid); |
| 899 | - if(res == 0) |
| 900 | - { |
| 901 | - ALOGI("Run lynq_sim_init\n"); |
| 902 | - }else{ |
| 903 | - ALOGI("lynq sim init error\n"); |
| 904 | - } |
| 905 | - sleep(1); |
| 906 | - |
| 907 | - return; |
| 908 | -} |
| 909 | - |
| 910 | - |
| 911 | -void init_network_func() |
| 912 | -{ |
| 913 | - int res; |
| 914 | - const char *lynqLibPath_Network = "/lib64/liblynq-network.so"; |
| 915 | - dlHandle_network = dlopen(lynqLibPath_Network, RTLD_NOW); |
| 916 | - if (dlHandle_network == NULL) |
| 917 | - { |
| 918 | - ALOGI("dlopen lynqLibPath_Network failed: %s", dlerror()); |
| 919 | - exit(EXIT_FAILURE); |
| 920 | - } |
| 921 | - |
| 922 | - lynq_query_registration_state = (int(*)(const char*,int*,int*,char *,char *,int *,int *,int*))dlsym( |
| 923 | -dlHandle_network, "lynq_query_registration_state"); |
| 924 | - if (lynq_query_registration_state == NULL) { |
| 925 | - ALOGI("lynq_query_registration_state not defined or exported in %s", lynqLibPath_Network); |
| 926 | - exit(EXIT_FAILURE); |
| 927 | - } |
| 928 | - |
| 929 | - lynq_network_init = (int(*)(int))dlsym(dlHandle_network, "lynq_network_init"); |
| 930 | - if (lynq_network_init == NULL) { |
| 931 | - ALOGI("lynq_network_init not defined or exported in %s", lynqLibPath_Network); |
| 932 | - exit(EXIT_FAILURE); |
| 933 | - } |
| 934 | - |
| 935 | - ALOGI("start lynq_network_init\n"); |
| 936 | - printf("start lynq_network_init\n"); |
| 937 | - res = lynq_network_init(2); |
| 938 | - sleep(10); |
| 939 | - |
| 940 | - if(res == 0) |
| 941 | - { |
| 942 | - ALOGI("Run lynq_network_init\n"); |
| 943 | - printf("Run lynq_network_init\n"); |
| 944 | - }else{ |
| 945 | - ALOGI("lynq_network_init error\n"); |
| 946 | - printf("lynq_network_init error\n"); |
| 947 | - } |
| 948 | - |
| 949 | - dlerror(); // Clear any previous dlerror |
| 950 | - return; |
| 951 | -} |
| 952 | -#endif |
| 953 | - |
| 954 | -#ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 955 | -int t106_set_lowpwr(int state) |
| 956 | -{ |
| 957 | - int ret; |
| 958 | - char rsp[128]; |
| 959 | - char cmdstr[32]; |
| 960 | - if(state == 0) |
| 961 | - { |
| 962 | - strcpy(cmdstr, "AT+ZLOWPWR=0\r\n"); |
| 963 | - } |
| 964 | - else |
| 965 | - { |
| 966 | - strcpy(cmdstr, "AT+ZLOWPWR=1\r\n"); |
| 967 | - } |
| 968 | - ret = sc_at_send(1,cmdstr,rsp,sizeof(rsp)); |
| 969 | - printf("AT+ZLOWPWR result:%d %s\n",ret,rsp); |
| 970 | - return ret; |
| 971 | -} |
| 972 | - |
| 973 | -int t106_set_blacklist(int blacklist_state) |
| 974 | -{ |
| 975 | - int ret; |
| 976 | - char rsp[128]; |
| 977 | - char cmdstr[128]; |
| 978 | - if(blacklist_state == 0) |
| 979 | - { |
| 980 | - strcpy(cmdstr, "AT+SHELL=echo \"+CREG:+CGREG:+CEREG:^MODE:\" > /sys/module/at_io/parameters/at_psm_filter\r\n"); |
| 981 | - } |
| 982 | - else |
| 983 | - { |
| 984 | - strcpy(cmdstr, "AT+SHELL=echo \"\" > /sys/module/at_io/parameters/at_psm_filter\r\n"); |
| 985 | - } |
| 986 | - ret = sc_at_send(1,cmdstr,rsp,sizeof(rsp)); |
| 987 | - printf("AT+SHELL=echo result:%d %s\n",ret,rsp); |
| 988 | - return ret; |
| 989 | - |
| 990 | -} |
| 991 | -int t106_set_whitelist(void) |
| 992 | -{ |
| 993 | - char tmp[8]; |
| 994 | - int ret; |
| 995 | - lynq_get_value(LOG_UCI_FILE, LOG_UCI_MODULE, "whitelist_state", tmp); |
| 996 | - if(strlen(tmp) != 4) |
| 997 | - { |
| 998 | - RLOGD("the whitelist len is error\n"); |
| 999 | - return 0; |
| 1000 | - } |
| 1001 | - if(tmp[0] == '1') |
| 1002 | - { |
| 1003 | - ret = sc_mnet_whitelist_add(1); |
| 1004 | - if(ret) |
| 1005 | - { |
| 1006 | - RLOGD("sc_mnet_whitelist_add 1 fail\n"); |
| 1007 | - return ret; |
| 1008 | - } |
| 1009 | - ret = sc_mnet_whitelist_add(5); |
| 1010 | - if(ret) |
| 1011 | - { |
| 1012 | - RLOGD("sc_mnet_whitelist_add 5 fail\n"); |
| 1013 | - return ret; |
| 1014 | - } |
| 1015 | - } |
| 1016 | - if(tmp[1] == '1') |
| 1017 | - { |
| 1018 | - ret = sc_mnet_whitelist_add(2); |
| 1019 | - if(ret) |
| 1020 | - { |
| 1021 | - RLOGD("sc_mnet_whitelist_add 2 fail\n"); |
| 1022 | - return ret; |
| 1023 | - } |
| 1024 | - } |
| 1025 | - if(tmp[2] == '1') |
| 1026 | - { |
| 1027 | - ret = sc_mnet_whitelist_add(3); |
| 1028 | - if(ret) |
| 1029 | - { |
| 1030 | - RLOGD("sc_mnet_whitelist_add 3 fail\n"); |
| 1031 | - return ret; |
| 1032 | - } |
| 1033 | - } |
| 1034 | - if(tmp[3] == '1') |
| 1035 | - { |
| 1036 | - ret = sc_mnet_whitelist_add(4); |
| 1037 | - if(ret) |
| 1038 | - { |
| 1039 | - RLOGD("sc_mnet_whitelist_add 4 fail\n"); |
| 1040 | - return ret; |
| 1041 | - } |
| 1042 | - } |
| 1043 | - |
| 1044 | - return 0; |
| 1045 | - |
| 1046 | -} |
| 1047 | -int t106_early_suspend(void) |
| 1048 | -{ |
| 1049 | - int ret; |
| 1050 | - |
| 1051 | - RLOGD("t106_early_suspend start\n"); |
| 1052 | - ret=lynq_sleep_status(0); |
| 1053 | - RLOGD("lynq_get_sleep_status ret=%d\n", ret); |
| 1054 | - ret = t106_set_lowpwr(1); |
| 1055 | - RLOGD("t106_set_lowpwr status ret=%d\n", ret); |
| 1056 | - system("zlog_nvctrl -m 1"); |
| 1057 | - ret = t106_set_whitelist(); |
| 1058 | - if(ret) |
| 1059 | - { |
| 1060 | - RLOGD("t106_set_whitelist ret=%d\n", ret); |
| 1061 | - return ret; |
| 1062 | - } |
| 1063 | - ret = t106_set_blacklist(0); |
| 1064 | - if(ret) |
| 1065 | - { |
| 1066 | - RLOGD("t106_set_blacklist ret=%d\n", ret); |
| 1067 | - return ret; |
| 1068 | - } |
| 1069 | - return 0; |
| 1070 | -} |
| 1071 | - |
| 1072 | -void t106_early_resume(void) |
| 1073 | -{ |
| 1074 | - int ret; |
| 1075 | - RLOGD("t106_early_resume start\n"); |
| 1076 | - ret = t106_set_blacklist(1); |
| 1077 | - if(ret) |
| 1078 | - { |
| 1079 | - RLOGD("t106_set_whitelist ret=%d\n", ret); |
| 1080 | - } |
| 1081 | - ret = sc_mnet_whitelist_clear(); |
| 1082 | - if(ret) |
| 1083 | - { |
| 1084 | - RLOGD("sc_mnet_whitelist_clear ret=%d\n", ret); |
| 1085 | - } |
| 1086 | - system("zlog_nvctrl -m 0"); |
| 1087 | - ret = t106_set_lowpwr(0); |
| 1088 | - RLOGD("t106_set_lowpwr status ret=%d\n", ret); |
| 1089 | - ret=lynq_sleep_status(1); |
| 1090 | - RLOGD("lynq_get_sleep_status ret=%d\n", ret); |
| 1091 | - |
| 1092 | - return NULL; |
| 1093 | -} |
| 1094 | -#endif |
| 1095 | - |
| 1096 | -#ifdef MOBILETEK_SUSPEND_CFG |
| 1097 | -int t800_early_suspend(char *wakeup_count, int wakeup_count_len) |
| 1098 | -{ |
| 1099 | - char buf[80]; |
| 1100 | - system("echo \"Sys standby mode\" >/dev/console"); |
| 1101 | - // sleep(1); |
| 1102 | - system("echo 7 | emdlogger_ctrl"); |
| 1103 | - // sleep(1); |
| 1104 | - |
| 1105 | - if (lynq_screen(0) != 0) //notify ril for screen off |
| 1106 | - { |
| 1107 | - ALOGI("lynq_screen off fail\n"); |
| 1108 | - return -1; |
| 1109 | - } |
| 1110 | - system("echo mode 4 0 >/sys/devices/platform/10005000.pinctrl/mt_gpio"); |
| 1111 | - system("echo out 4 1 >/sys/devices/platform/10005000.pinctrl/mt_gpio"); |
| 1112 | - RLOGD("ring GPIO PASS\n"); |
| 1113 | - system("hwclock -w"); |
| 1114 | - RLOGD("TIME: sys to rtc\n"); |
| 1115 | - lseek(wakeup_count_fd, 0, SEEK_SET); |
| 1116 | - system("echo \"autosuspend:Sys seek\" >/dev/console"); |
| 1117 | - wakeup_count_len = TEMP_FAILURE_RETRY(read(wakeup_count_fd, wakeup_count, |
| 1118 | - 200)); |
| 1119 | - ALOGE("%s: %d, write %s to wakeup_count\n", __func__, wakeup_count_len, wakeup_count); |
| 1120 | - if (wakeup_count_len < 0) { |
| 1121 | - strerror_r(errno, buf, sizeof(buf)); |
| 1122 | - ALOGE("Error reading from %s: %s\n", SYS_POWER_WAKEUP_COUNT, buf); |
| 1123 | - wakeup_count_len = 0; |
| 1124 | - return -1; |
| 1125 | - } |
| 1126 | - |
| 1127 | - for(int i = 0;i < 5;i++) //notify spm (other core) to handle pre-sleep configuration |
| 1128 | - { |
| 1129 | - if(TEMP_FAILURE_RETRY(write(suspend_ctrl_fd,reg_netsys[i],strlen(reg_netsys[i]))) < 0) |
| 1130 | - { |
| 1131 | - strerror_r(errno, buf, sizeof(buf)); |
| 1132 | - ALOGI("Error writing to %s: %s\n", SYS_POWER_SPM_SUSPEND_CRTL, buf); |
| 1133 | - return -1; |
| 1134 | - } |
| 1135 | - } |
| 1136 | - return 0; |
| 1137 | -} |
| 1138 | - |
| 1139 | -void t800_early_resume(bool success) |
| 1140 | -{ |
| 1141 | - system("hwclock -s"); |
| 1142 | - RLOGD("TIME: rtc to sys\n"); |
| 1143 | - if (!success) |
| 1144 | - { |
| 1145 | - |
| 1146 | - system("mdlogctl start"); |
| 1147 | - |
| 1148 | - system("echo 8 | emdlogger_ctrl"); |
| 1149 | - |
| 1150 | - usleep(200000); |
| 1151 | - ALOGI("Log on with failure\n"); |
| 1152 | - return ; |
| 1153 | - } |
| 1154 | - |
| 1155 | - if (lynq_screen(1) != 0) // notify ril for screen on |
| 1156 | - { |
| 1157 | - ALOGI("lynq_screen on fail\n"); |
| 1158 | - } |
| 1159 | - |
| 1160 | - system("mdlogctl start"); |
| 1161 | - |
| 1162 | - system("echo 8 | emdlogger_ctrl"); |
| 1163 | - usleep(300000); //delay 2s for ril handling screen on,at least 70ms |
| 1164 | - |
| 1165 | - return NULL; |
| 1166 | -} |
| 1167 | -#endif |
| 1168 | - |
| 1169 | - |
| 1170 | -static int suspend_ctrl(char *wakeup_count,int wakeup_count_len) |
| 1171 | -{ |
| 1172 | - |
| 1173 | - |
| 1174 | - char buf[80]; |
| 1175 | - int ret = 0; |
| 1176 | -#ifdef MOBILETEK_SUSPEND_CFG |
| 1177 | - ret = t800_early_suspend(char *wakeup_count, wakeup_count_len); |
| 1178 | - if(ret != 0) |
| 1179 | - { |
| 1180 | - ALOGD("t800_early_suspend fail\n"); |
| 1181 | - return -1; |
| 1182 | - } |
| 1183 | -#endif |
| 1184 | - |
| 1185 | - |
| 1186 | -#ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1187 | - ret = t106_early_suspend(); |
| 1188 | - if(ret != 0) |
| 1189 | - { |
| 1190 | - ALOGD("t106_early_suspend fail\n"); |
| 1191 | - return -1; |
| 1192 | - } |
| 1193 | -#endif |
| 1194 | - |
| 1195 | - system("echo \"autosuspend:Sys suspend\" >/dev/console"); |
| 1196 | - if(TEMP_FAILURE_RETRY(write(state_fd, sleep_state, strlen(sleep_state))) < 0) //enter suspend procedures in kernel |
| 1197 | - { |
| 1198 | - strerror_r(errno, buf, sizeof(buf)); |
| 1199 | - ALOGI("Error writing to %s: %s\n", SYS_POWER_STATE, buf); |
| 1200 | - return -1; |
| 1201 | - } |
| 1202 | - |
| 1203 | - return 0; |
| 1204 | -} |
| 1205 | - |
| 1206 | - |
| 1207 | -void wakeup_feedback(bool success) |
| 1208 | -{ |
| 1209 | - |
| 1210 | - char buf[80]; |
| 1211 | - long sleeptime = 0; |
| 1212 | - |
| 1213 | -#ifdef MOBILETEK_SUSPEND_CFG |
| 1214 | - t800_early_resume(bool success); |
| 1215 | -#endif |
| 1216 | - |
| 1217 | - |
| 1218 | -#ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1219 | - t106_early_resume(); |
| 1220 | -#endif |
| 1221 | - |
| 1222 | - pthread_mutex_lock(&time_info_mutex); |
| 1223 | - memset(&tv,0,sizeof(struct timeval)); |
| 1224 | - gettimeofday(&tv,NULL); |
| 1225 | - // time_info.wakeup_time = tv.tv_sec * 1000 + tv.tv_usec / 1000; |
| 1226 | - end_time = tv.tv_sec * 1000 + tv.tv_usec / 1000; |
| 1227 | - ALOGI("%s: wake up time: %ld ms\n", __func__,end_time); |
| 1228 | - |
| 1229 | - memset(&time_info,0,sizeof(struct time_info_t)); |
| 1230 | - |
| 1231 | - time_info.sleep_start_time = start_time; |
| 1232 | - time_info.wakeup_time = end_time; |
| 1233 | - sleeptime = end_time -start_time; |
| 1234 | - RLOGD("sleep time is %ld ms\n", sleeptime); |
| 1235 | - pthread_mutex_unlock(&time_info_mutex); |
| 1236 | - |
| 1237 | - if (pthread_cond_broadcast(&feedback_cond) != 0) { |
| 1238 | - strerror_r(errno, buf, sizeof(buf)); |
| 1239 | - ALOGI("Error broadcast cond: %s\n", buf); |
| 1240 | - } |
| 1241 | - |
| 1242 | - return ; |
| 1243 | - |
| 1244 | -} |
| 1245 | - |
| 1246 | -static void update_sleep_time(bool success) { |
| 1247 | - if (success) { |
| 1248 | - sleep_time = BASE_SLEEP_TIME; |
| 1249 | - return; |
| 1250 | - } |
| 1251 | - // double sleep time after each failure up to one minute |
| 1252 | - sleep_time = MIN(sleep_time * 2, possible_max_sleep_time); |
| 1253 | -} |
| 1254 | - |
| 1255 | -static void *suspend_thread_func(void *arg __attribute__((unused))) |
| 1256 | -{ |
| 1257 | - char buf[80]; |
| 1258 | - char wakeup_count[20]; |
| 1259 | - int wakeup_count_len; |
| 1260 | - int ret; |
| 1261 | - bool success = true; |
| 1262 | - |
| 1263 | - while (1) { |
| 1264 | - update_sleep_time(success); |
| 1265 | - usleep(sleep_time); |
| 1266 | - success = false; |
| 1267 | - |
| 1268 | - ALOGI("%s: wait\n", __func__); |
| 1269 | - ret = sem_wait(&suspend_lockout); |
| 1270 | - if (ret < 0) { |
| 1271 | - strerror_r(errno, buf, sizeof(buf)); |
| 1272 | - ALOGI("Error waiting on semaphore: %s\n", buf); |
| 1273 | - continue; |
| 1274 | - } |
| 1275 | - |
| 1276 | - ALOGV("%s: read wakeup_count\n", __func__); |
| 1277 | - lseek(wakeup_count_fd, 0, SEEK_SET); |
| 1278 | - wakeup_count_len = TEMP_FAILURE_RETRY(read(wakeup_count_fd, wakeup_count, |
| 1279 | - sizeof(wakeup_count))); |
| 1280 | - if (wakeup_count_len < 0) { |
| 1281 | - strerror_r(errno, buf, sizeof(buf)); |
| 1282 | - ALOGE("Error reading from %s: %s\n", SYS_POWER_WAKEUP_COUNT, buf); |
| 1283 | - wakeup_count_len = 0; |
| 1284 | - continue; |
| 1285 | - } |
| 1286 | - if (!wakeup_count_len) { |
| 1287 | - ALOGE("Empty wakeup count\n"); |
| 1288 | - continue; |
| 1289 | - } |
| 1290 | - |
| 1291 | - ALOGI("%s: start suspend_ctrl\n", __func__); |
| 1292 | - memset(&tv,0,sizeof(struct timeval)); |
| 1293 | - // memset(&time_info,0 ,sizeof(struct time_info_t)); |
| 1294 | - gettimeofday(&tv,NULL); |
| 1295 | - |
| 1296 | - start_time = tv.tv_sec * 1000 + tv.tv_usec / 1000; |
| 1297 | - ALOGI("%s: suspend start time: %ld ms\n", __func__,start_time); |
| 1298 | - // time_info.sleep_start_time = tv.tv_sec * 1000 + tv.tv_usec / 1000; |
| 1299 | - |
| 1300 | - ret = suspend_ctrl(wakeup_count,wakeup_count_len); |
| 1301 | - |
| 1302 | - if (ret >= 0) { |
| 1303 | - ALOGI("suspend_ctrl success.\n"); |
| 1304 | - success = true; |
| 1305 | - } |
| 1306 | - else |
| 1307 | - { |
| 1308 | - ALOGI("suspend_ctrl false.\n"); |
| 1309 | - success = false; |
| 1310 | - } |
| 1311 | - |
| 1312 | - void (*func)(bool success) = wakeup_func; |
| 1313 | - if (func != NULL) { |
| 1314 | - (*func)(success); //handling resume event for other libs /apps |
| 1315 | - } |
| 1316 | - |
| 1317 | - ALOGI("%s: release sem\n", __func__); |
| 1318 | - ret = sem_post(&suspend_lockout); |
| 1319 | - if (ret < 0) { |
| 1320 | - strerror_r(errno, buf, sizeof(buf)); |
| 1321 | - ALOGI("Error releasing semaphore: %s\n", buf); |
| 1322 | - } |
| 1323 | - |
| 1324 | - if(adb_debug_mode == 1) // it's neccessary to wait for autosuspend_disable function calling in debug mode when finish resume procedure. |
| 1325 | - { |
| 1326 | - sleep(40); |
| 1327 | - } |
| 1328 | - else |
| 1329 | - { |
| 1330 | - ALOGI("%s: adb_debug unsupported\n", __func__); |
| 1331 | - } |
| 1332 | - |
| 1333 | - ALOGI("%s: END SLEEP\n", __func__); |
| 1334 | - } |
| 1335 | - return NULL; |
| 1336 | -} |
| 1337 | - |
| 1338 | -static int autosuspend_wakeup_count_enable(void) |
| 1339 | -{ |
| 1340 | - char buf[80]; |
| 1341 | - int ret; |
| 1342 | - |
| 1343 | - ALOGI("autosuspend_wakeup_count_enable\n"); |
| 1344 | - |
| 1345 | - ret = sem_post(&suspend_lockout); |
| 1346 | - |
| 1347 | - if (ret < 0) { |
| 1348 | - strerror_r(errno, buf, sizeof(buf)); |
| 1349 | - ALOGI("Error changing semaphore: %s\n", buf); |
| 1350 | - } |
| 1351 | - |
| 1352 | - ALOGI("autosuspend_wakeup_count_enable done\n"); |
| 1353 | - |
| 1354 | - return ret; |
| 1355 | -} |
| 1356 | - |
| 1357 | -static int autosuspend_wakeup_count_disable(void) |
| 1358 | -{ |
| 1359 | - char buf[80]; |
| 1360 | - int ret; |
| 1361 | - |
| 1362 | - ALOGI("autosuspend_wakeup_count_disable\n"); |
| 1363 | - |
| 1364 | - ret = sem_wait(&suspend_lockout); |
| 1365 | - |
| 1366 | - if (ret < 0) { |
| 1367 | - strerror_r(errno, buf, sizeof(buf)); |
| 1368 | - ALOGI("Error changing semaphore: %s\n", buf); |
| 1369 | - } |
| 1370 | - |
| 1371 | - ALOGI("autosuspend_wakeup_count_disable done\n"); |
| 1372 | - |
| 1373 | - return ret; |
| 1374 | -} |
| 1375 | - |
| 1376 | -void set_wakeup_callback(void (*func)(bool success)) |
| 1377 | -{ |
| 1378 | - if (wakeup_func != NULL) { |
| 1379 | - ALOGI("Duplicate wakeup callback applied, keeping original"); |
| 1380 | - return; |
| 1381 | - } |
| 1382 | - wakeup_func = func; |
| 1383 | -} |
| 1384 | - |
| 1385 | -struct autosuspend_ops autosuspend_wakeup_count_ops = { |
| 1386 | - .enable = autosuspend_wakeup_count_enable, |
| 1387 | - .disable = autosuspend_wakeup_count_disable, |
| 1388 | -}; |
| 1389 | - |
| 1390 | -struct autosuspend_ops *autosuspend_wakeup_count_init(void) |
| 1391 | -{ |
| 1392 | - int ret; |
| 1393 | - char buf[80]; |
| 1394 | - char timeout_str[100]="100000"; |
| 1395 | - pid = getpid(); |
| 1396 | - char cmdstr[32]; |
| 1397 | - char rsp[128]; |
| 1398 | - //if (property_get("sys.autosuspend.timeout", timeout_str, NULL)) |
| 1399 | - { |
| 1400 | - possible_max_sleep_time = atoi(timeout_str); |
| 1401 | - ALOGI("autosuspend timeout is %d\n", possible_max_sleep_time); |
| 1402 | - } |
| 1403 | - |
| 1404 | - state_fd = TEMP_FAILURE_RETRY(open(SYS_POWER_STATE, O_RDWR)); |
| 1405 | - if (state_fd < 0) { |
| 1406 | - strerror_r(errno, buf, sizeof(buf)); |
| 1407 | - ALOGI("Error opening %s: %s\n", SYS_POWER_STATE, buf); |
| 1408 | - goto err_open_state; |
| 1409 | - } |
| 1410 | - |
| 1411 | - wakeup_count_fd = TEMP_FAILURE_RETRY(open(SYS_POWER_WAKEUP_COUNT, O_RDWR)); |
| 1412 | - if (wakeup_count_fd < 0) { |
| 1413 | - strerror_r(errno, buf, sizeof(buf)); |
| 1414 | - ALOGI("Error opening %s: %s\n", SYS_POWER_WAKEUP_COUNT, buf); |
| 1415 | - goto err_open_wakeup_count; |
| 1416 | - } |
| 1417 | -#ifdef MOBILETEK_SUSPEND_CFG |
| 1418 | - suspend_ctrl_fd = TEMP_FAILURE_RETRY(open(SYS_POWER_SPM_SUSPEND_CRTL, O_RDWR)); |
| 1419 | - if (suspend_ctrl_fd < 0) { |
| 1420 | - strerror_r(errno, buf, sizeof(buf)); |
| 1421 | - ALOGI("Error opening %s: %s\n", SYS_POWER_SPM_SUSPEND_CRTL, buf); |
| 1422 | - goto err_open_suspend_ctrl; |
| 1423 | - } |
| 1424 | -#endif |
| 1425 | - ret = sem_init(&suspend_lockout, 0, 0); |
| 1426 | - if (ret < 0) { |
| 1427 | - strerror_r(errno, buf, sizeof(buf)); |
| 1428 | - ALOGI("Error creating semaphore: %s\n", buf); |
| 1429 | - goto err_sem_init; |
| 1430 | - } |
| 1431 | -#ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1432 | - if(sc_at_init(1)){ |
| 1433 | - ALOGD("sc_at_init failed.\n"); |
| 1434 | - return NULL; |
| 1435 | - } |
| 1436 | - else |
| 1437 | - { |
| 1438 | - strcpy(cmdstr, "AT+ZPOWSTAT=1\r\n"); |
| 1439 | - printf("AUTOSUSPEND: cmd:%s\n",cmdstr); |
| 1440 | - ret = sc_at_send(1,cmdstr,rsp,sizeof(rsp)); |
| 1441 | - printf("AUTOSUSPEND: sc_at_send result:%d %s\n",ret,rsp); |
| 1442 | - |
| 1443 | - } |
| 1444 | - if(sc_mnet_whitelist_init() != 0) |
| 1445 | - { |
| 1446 | - ALOGD("sc_mnet_whitelist_init failed.\n"); |
| 1447 | - return NULL; |
| 1448 | - } |
| 1449 | -#endif |
| 1450 | - ret = lynq_sim_init((int)pid); |
| 1451 | - if(ret == 0) |
| 1452 | - { |
| 1453 | - ALOGD("Run lynq_sim_init\n"); |
| 1454 | - } |
| 1455 | - else |
| 1456 | - { |
| 1457 | - return NULL; |
| 1458 | - } |
| 1459 | - ret = pthread_create(&suspend_thread, NULL, suspend_thread_func, NULL); |
| 1460 | - if (ret) { |
| 1461 | - strerror_r(ret, buf, sizeof(buf)); |
| 1462 | - ALOGI("Error creating thread: %s\n", buf); |
| 1463 | - goto err_pthread_create; |
| 1464 | - } |
| 1465 | - |
| 1466 | - ALOGI("Selected wakeup count\n"); |
| 1467 | - return &autosuspend_wakeup_count_ops; |
| 1468 | - |
| 1469 | -err_pthread_create: |
| 1470 | - sem_destroy(&suspend_lockout); |
| 1471 | -err_sem_init: |
| 1472 | - close(wakeup_count_fd); |
| 1473 | -err_open_wakeup_count: |
| 1474 | - close(state_fd); |
| 1475 | -#ifdef MOBILETEK_SUSPEND_CFG |
| 1476 | -err_open_suspend_ctrl: |
| 1477 | - close(suspend_ctrl_fd); |
| 1478 | -#endif |
| 1479 | -err_open_state: |
| 1480 | - return NULL; |
| 1481 | -} |
| 1482 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/lynq-autosuspend.sh b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/lynq-autosuspend.sh |
| 1483 | deleted file mode 100755 |
| 1484 | index 8e96831..0000000 |
| 1485 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/lynq-autosuspend.sh |
| 1486 | +++ /dev/null |
| 1487 | @@ -1,39 +0,0 @@ |
| 1488 | -#!/bin/sh |
| 1489 | -# |
| 1490 | -# Run the daemon |
| 1491 | -# |
| 1492 | - |
| 1493 | -DAEMON="lynq-autosuspend-service" |
| 1494 | -PIDFILE="/var/run/$DAEMON.pid" |
| 1495 | -EXEC="/usr/bin/autosuspend" |
| 1496 | -EXEC_ARGS="" |
| 1497 | - |
| 1498 | - |
| 1499 | -start() { |
| 1500 | - echo -n "Starting $DAEMON... " |
| 1501 | - start-stop-daemon --no-close -S -b -m -p $PIDFILE -x $EXEC -- $EXEC_ARGS |
| 1502 | - [ $? -eq 0 ] && echo "OK" || echo "ERROR" |
| 1503 | -} |
| 1504 | - |
| 1505 | -stop() { |
| 1506 | - echo -n "Stopping $DAEMON... " |
| 1507 | - start-stop-daemon -K -p $PIDFILE |
| 1508 | - [ $? -eq 0 ] && echo "OK" || echo "ERROR" |
| 1509 | -} |
| 1510 | - |
| 1511 | -restart() { |
| 1512 | - stop |
| 1513 | - start |
| 1514 | -} |
| 1515 | - |
| 1516 | -case "$1" in |
| 1517 | - start|stop|restart) |
| 1518 | - "$1" |
| 1519 | - ;; |
| 1520 | - *) |
| 1521 | - echo "Usage: $0 {start|stop|restart}" |
| 1522 | - exit 1 |
| 1523 | -esac |
| 1524 | - |
| 1525 | -exit $? |
| 1526 | - |
| 1527 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/main.c b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/main.c |
| 1528 | deleted file mode 100755 |
| 1529 | index f706c9f..0000000 |
| 1530 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/main.c |
| 1531 | +++ /dev/null |
| 1532 | @@ -1,494 +0,0 @@ |
| 1533 | -/* //device/system/rild/rild.c |
| 1534 | -** |
| 1535 | -** Copyright 2006 The Android Open Source Project |
| 1536 | -** |
| 1537 | -** Licensed under the Apache License, Version 2.0 (the "License"); |
| 1538 | -** you may not use this file except in compliance with the License. |
| 1539 | -** You may obtain a copy of the License at |
| 1540 | -** |
| 1541 | -** http://www.apache.org/licenses/LICENSE-2.0 |
| 1542 | -** |
| 1543 | -** Unless required by applicable law or agreed to in writing, software |
| 1544 | -** distributed under the License is distributed on an "AS IS" BASIS, |
| 1545 | -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 1546 | -** See the License for the specific language governing permissions and |
| 1547 | -** limitations under the License. |
| 1548 | -*/ |
| 1549 | - |
| 1550 | -#include <stdio.h> |
| 1551 | -#include <stdlib.h> |
| 1552 | -#include <stdbool.h> |
| 1553 | -#include <dlfcn.h> |
| 1554 | -#include <string.h> |
| 1555 | -#include <pthread.h> |
| 1556 | -#include <stdint.h> |
| 1557 | -#include <unistd.h> |
| 1558 | -#include <fcntl.h> |
| 1559 | -#include <errno.h> |
| 1560 | -#include <log/log.h> |
| 1561 | -#include <liblog/lynq_deflog.h> |
| 1562 | -#include <include/lynq_uci.h> |
| 1563 | -#include <sys/socket.h> |
| 1564 | -#include <sys/un.h> |
| 1565 | -#include <signal.h> |
| 1566 | - |
| 1567 | - |
| 1568 | -#define LOG_UCI_MODULE "lynq_autosuspend" |
| 1569 | -#define LOG_UCI_FILE "lynq_uci" |
| 1570 | - |
| 1571 | -#define LOG_TAG "AUTOSUSPEND" |
| 1572 | - |
| 1573 | -#define USER_LOG_TAG "PMS" |
| 1574 | - |
| 1575 | -#define SOCK_PATH "/tmp/autosuspend.cmd.server" //ä¸è½å¨å½åè¿ä¸ªç®å½å建socketæä»¶ï¼å¦åæ¥éæ¾ä¸å°æä»¶(å¯è½æ¯å ä¸ºè¿æ¯å¨å
±äº«æä»¶å¤¹ä¸ï¼ä¸æ¯æå建socketæä»¶) |
| 1576 | - |
| 1577 | -#define SOCK_DATA_PATH "/tmp/autosuspend.data.server" |
| 1578 | - |
| 1579 | -// #define LYINFLOG(X...) lynq_log_global_output(LOG_INFO,X) |
| 1580 | - |
| 1581 | -#define TIME_OUT_TIME 30 |
| 1582 | - |
| 1583 | - |
| 1584 | -#define MAX_LIB_ARGS 16 |
| 1585 | - |
| 1586 | -int adb_debug_mode = 0; |
| 1587 | - |
| 1588 | - |
| 1589 | -pthread_cond_t feedback_cond = PTHREAD_COND_INITIALIZER; |
| 1590 | -pthread_mutex_t feedback_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 1591 | -pthread_mutex_t time_info_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 1592 | - |
| 1593 | -extern int autosuspend_enable(void); |
| 1594 | -extern int autosuspend_disable(void); |
| 1595 | -extern void init_wakelock_func(void); |
| 1596 | -extern void init_sim_func(); |
| 1597 | -extern void init_network_func(); |
| 1598 | -extern void set_wakeup_callback(void (*func)(bool success)); |
| 1599 | -extern void wakeup_feedback(bool success); |
| 1600 | -extern int (*lynq_screen)(int num); |
| 1601 | - |
| 1602 | -struct time_info_t |
| 1603 | -{ |
| 1604 | - long sleep_start_time; |
| 1605 | - long wakeup_time; |
| 1606 | -}; |
| 1607 | - |
| 1608 | -struct time_info_t time_info; |
| 1609 | - |
| 1610 | -static void usage(const char *argv0) { |
| 1611 | - fprintf(stderr, "Usage: %s -l <possible_max_sleep_time> [-- <args for Autosuspend Service>]\n", argv0); |
| 1612 | - exit(EXIT_FAILURE); |
| 1613 | -} |
| 1614 | - |
| 1615 | - |
| 1616 | - |
| 1617 | -static int make_argv(char * args, char ** argv) { |
| 1618 | - // Note: reserve argv[0] |
| 1619 | - int count = 1; |
| 1620 | - char * tok; |
| 1621 | - char * s = args; |
| 1622 | - |
| 1623 | - while ((tok = strtok(s, " \0"))) { |
| 1624 | - argv[count] = tok; |
| 1625 | - s = NULL; |
| 1626 | - count++; |
| 1627 | - } |
| 1628 | - return count; |
| 1629 | -} |
| 1630 | - |
| 1631 | -static int Accept(int fd, struct sockaddr *sa, socklen_t *salenptr) |
| 1632 | -{ |
| 1633 | - int n; |
| 1634 | - |
| 1635 | - while((n = accept(fd, sa, salenptr)) < 0) |
| 1636 | - { |
| 1637 | - if((errno == ECONNABORTED) || (errno == EINTR)) |
| 1638 | - continue; |
| 1639 | - else |
| 1640 | - { |
| 1641 | - ALOGI("accept error\n"); |
| 1642 | - return -1; |
| 1643 | - } |
| 1644 | - } |
| 1645 | - return n; |
| 1646 | -} |
| 1647 | - |
| 1648 | -static int Bind(int fd, const struct sockaddr *sa, socklen_t salen) |
| 1649 | -{ |
| 1650 | - if(bind(fd, sa, salen) < 0) |
| 1651 | - { |
| 1652 | - // ALOGI("bind error\n"); |
| 1653 | - perror("bind error"); |
| 1654 | - return -1; |
| 1655 | - } |
| 1656 | - return 0; |
| 1657 | -} |
| 1658 | - |
| 1659 | - |
| 1660 | -static int Socket(int family, int type, int protocol) |
| 1661 | -{ |
| 1662 | - int n; |
| 1663 | - |
| 1664 | - if ( (n = socket(family, type, protocol)) < 0) |
| 1665 | - { |
| 1666 | - ALOGI("socket error\n"); |
| 1667 | - return -1; |
| 1668 | - } |
| 1669 | - return n; |
| 1670 | -} |
| 1671 | - |
| 1672 | -static int Listen(int fd, int backlog) |
| 1673 | -{ |
| 1674 | - if(listen(fd, backlog) < 0) |
| 1675 | - { |
| 1676 | - ALOGI("listen error\n"); |
| 1677 | - return -1; |
| 1678 | - } |
| 1679 | - return 0; |
| 1680 | -} |
| 1681 | - |
| 1682 | - |
| 1683 | -static int listen_port(struct sockaddr_un *addr, char *sockpath) |
| 1684 | -{ |
| 1685 | - int listenfd; |
| 1686 | - listenfd = Socket(AF_UNIX,SOCK_STREAM,0); |
| 1687 | - if(listenfd == -1) |
| 1688 | - return -1; |
| 1689 | - memset(addr, 0, sizeof(struct sockaddr_un)); |
| 1690 | - addr->sun_family = AF_UNIX; |
| 1691 | - strcpy(addr->sun_path,sockpath); |
| 1692 | - // int opt = 1; |
| 1693 | - // if(setsockopt(listenfd, SOL_SOCKET,SO_REUSEADDR, (const void *)&opt, sizeof(opt)) == -1) |
| 1694 | - // { |
| 1695 | - // perror("setsockopt error"); |
| 1696 | - // return -1; |
| 1697 | - // } |
| 1698 | - |
| 1699 | -// 以䏿¹æ³å¯¹éç½ç»çæ¬å°socketæ æï¼åºè¯¥ç¨unlink彿°é¿å
Address already in useçé误 |
| 1700 | - |
| 1701 | - |
| 1702 | - unlink(sockpath); |
| 1703 | - if(Bind(listenfd,(struct sockaddr *)addr,sizeof(*addr)) == -1) |
| 1704 | - return -1; |
| 1705 | - |
| 1706 | - if(Listen(listenfd,20) == -1) |
| 1707 | - return -1; |
| 1708 | - |
| 1709 | - return listenfd; |
| 1710 | -} |
| 1711 | - |
| 1712 | -static ssize_t Read(int fd, void *ptr, size_t nbytes) |
| 1713 | -{ |
| 1714 | - ssize_t n; |
| 1715 | - |
| 1716 | - while((n = read(fd, ptr, nbytes)) == -1) |
| 1717 | - { |
| 1718 | - //printf("READ,%d\n",fd); |
| 1719 | - if (errno == EINTR) |
| 1720 | - { |
| 1721 | - ALOGI("read error eintr\n"); |
| 1722 | - continue; |
| 1723 | - } |
| 1724 | - else if(errno == EAGAIN || errno == EWOULDBLOCK) |
| 1725 | - { |
| 1726 | - ALOGI("read time out\n"); |
| 1727 | - return -1; |
| 1728 | - } |
| 1729 | - else |
| 1730 | - { |
| 1731 | - ALOGI("read error\n"); |
| 1732 | - return -1; |
| 1733 | - } |
| 1734 | - } |
| 1735 | - //sleep(2); |
| 1736 | - //printf("READ1,%d\n", fd); |
| 1737 | - return n; |
| 1738 | -} |
| 1739 | - |
| 1740 | -static ssize_t Write(int fd, const void *ptr, size_t nbytes) |
| 1741 | -{ |
| 1742 | - ssize_t n; |
| 1743 | - |
| 1744 | - while((n = write(fd, ptr, nbytes)) == -1) |
| 1745 | - { |
| 1746 | - if (errno == EINTR) |
| 1747 | - continue; |
| 1748 | - else if(errno == EPIPE) |
| 1749 | - { |
| 1750 | - ALOGI("write error epipe\n"); |
| 1751 | - return -1; |
| 1752 | - } |
| 1753 | - else |
| 1754 | - return -1; |
| 1755 | - } |
| 1756 | - return n; |
| 1757 | -} |
| 1758 | - |
| 1759 | -static int Close(int fd) |
| 1760 | -{ |
| 1761 | - if (close(fd) == -1) |
| 1762 | - { |
| 1763 | - ALOGI("close error\n"); |
| 1764 | - return -1; |
| 1765 | - } |
| 1766 | - return 0; |
| 1767 | -} |
| 1768 | - |
| 1769 | - |
| 1770 | -void *deal_autosuspend(void *sockfd) |
| 1771 | -{ |
| 1772 | - int commfd = *((int *)sockfd); |
| 1773 | - char buf[20]; |
| 1774 | - char res[15]; |
| 1775 | - |
| 1776 | - while(1) |
| 1777 | - { |
| 1778 | - memset(buf,0,sizeof(buf)); |
| 1779 | - ALOGI("deal_autosuspend start to read.\n"); |
| 1780 | - // é误ç¹ï¼read彿°å¨å¯¹ç«¯å
³éåï¼ä¹ä¼ç´æ¥è¿å0,ä¸ä¼é»å¡ï¼å æ¤è¦å¤ææ¯å¦è¿å0,è¿å0表示对端已ç»å
³éï¼æ¤æ¶è¦è·³åºwhile循ç¯ä¸åçå¬ |
| 1781 | - // 为ä»ä¹å¯¹ç«¯ä¼å
³éï¼å 为å¨å®¢æ·ç«¯æ²¡æç¨nohupæ¹å¼æå¼çæ
åµä¸ï¼ç³»ç»ç¡ç å客æ·ç«¯è¿è¡ä¼ç´æ¥è¢«ææ»ï¼å¯¹ç«¯ä¼å
³éï¼æä»¥ä¼å¯¼è´readä¸é»å¡ï¼ä¸æ»æ¯è¿å0çç°è±¡ |
| 1782 | - if(Read(commfd,buf,sizeof(buf)) <= 0) |
| 1783 | - { |
| 1784 | - ALOGI("service receive suspend_cmd fail or client is closed.\n"); |
| 1785 | - Close(commfd); |
| 1786 | - break; |
| 1787 | - } |
| 1788 | - if(strcmp(buf,"enable") == 0) |
| 1789 | - { |
| 1790 | - if(autosuspend_enable() < 0) |
| 1791 | - { |
| 1792 | - ALOGI("autosuspend_enable fail.\n"); |
| 1793 | - } |
| 1794 | - else |
| 1795 | - { |
| 1796 | - ALOGI("autosuspend_enable success.\n"); |
| 1797 | - } |
| 1798 | - } |
| 1799 | - else if(strcmp(buf,"disable") == 0) |
| 1800 | - { |
| 1801 | - if(autosuspend_disable() < 0) |
| 1802 | - { |
| 1803 | - ALOGI("autosuspend_disable fail.\n"); |
| 1804 | - } |
| 1805 | - else |
| 1806 | - { |
| 1807 | - ALOGI("autosuspend_disable success.\n"); |
| 1808 | - |
| 1809 | - } |
| 1810 | - } |
| 1811 | - |
| 1812 | - else |
| 1813 | - { |
| 1814 | - ALOGI("Unknown cmd : %s\n",buf); |
| 1815 | - } |
| 1816 | - |
| 1817 | - } |
| 1818 | - |
| 1819 | - |
| 1820 | - |
| 1821 | -} |
| 1822 | - |
| 1823 | -#ifdef GSW_SUSPEND_CFG |
| 1824 | -/*jb.qi add for service send when DTR is low on 20221111 start */ |
| 1825 | -void *dtr_wakeup() |
| 1826 | -{ |
| 1827 | - FILE *fp; |
| 1828 | - int ret; |
| 1829 | - bool success = true; |
| 1830 | - char buf[30]; |
| 1831 | - char dtr_buffer[25]; |
| 1832 | - RLOGD("dtr_wakeup start\n"); |
| 1833 | - while(1) |
| 1834 | - { |
| 1835 | - fp = popen("cat /sys/devices/platform/10005000.pinctrl/mt_gpio |grep 006:","r"); |
| 1836 | - fgets(dtr_buffer, sizeof(dtr_buffer), fp); |
| 1837 | - if(dtr_buffer[7] == '0') |
| 1838 | - { |
| 1839 | - time_info.sleep_start_time = 123; |
| 1840 | - time_info.wakeup_time = 123; |
| 1841 | - if (pthread_cond_broadcast(&feedback_cond) != 0) |
| 1842 | - { |
| 1843 | - strerror_r(errno, buf, sizeof(buf)); |
| 1844 | - ALOGI("Error broadcast cond: %s\n", buf); |
| 1845 | - } |
| 1846 | - RLOGD("dtr_wakeup success!\n"); |
| 1847 | - sleep(3); |
| 1848 | - } |
| 1849 | - usleep(500); |
| 1850 | - pclose(fp); |
| 1851 | - } |
| 1852 | -} |
| 1853 | -/*jb.qi add for service send when DTR is low on 20221111 end */ |
| 1854 | -#endif |
| 1855 | - |
| 1856 | -void *send_feedback(void *sockfd) |
| 1857 | -{ |
| 1858 | - int commfd = *((int *)sockfd); |
| 1859 | - char buf[80]; |
| 1860 | - |
| 1861 | - while (1) |
| 1862 | - { |
| 1863 | - memset(buf,0,sizeof(buf)); |
| 1864 | - ALOGI("send_feedback thread wait to send.\n"); |
| 1865 | - pthread_mutex_lock(&feedback_mutex); |
| 1866 | - pthread_cond_wait(&feedback_cond,&feedback_mutex); |
| 1867 | - |
| 1868 | - ALOGI("send_feedback thread is now sending the feedback to client.\n"); |
| 1869 | - pthread_mutex_lock(&time_info_mutex); |
| 1870 | - if(Write(commfd,&time_info,sizeof(struct time_info_t)) <= 0) |
| 1871 | - { |
| 1872 | - ALOGI("service send wakeup_feedback struct fail.\n"); |
| 1873 | - Close(commfd); |
| 1874 | - pthread_mutex_unlock(&time_info_mutex); |
| 1875 | - pthread_mutex_unlock(&feedback_mutex); |
| 1876 | -#ifdef GSW_SUSPEND_CFG |
| 1877 | - continue ;//jb.qi add for service send when DTR is low on 20221111 |
| 1878 | -#endif |
| 1879 | - |
| 1880 | -#ifdef MOBILETEK_SUSPEND_CFG |
| 1881 | - break ; |
| 1882 | -#endif |
| 1883 | - } |
| 1884 | - pthread_mutex_unlock(&time_info_mutex); |
| 1885 | - |
| 1886 | - pthread_mutex_unlock(&feedback_mutex); |
| 1887 | - |
| 1888 | - |
| 1889 | - |
| 1890 | - } |
| 1891 | - |
| 1892 | -} |
| 1893 | - |
| 1894 | - |
| 1895 | -int main(int argc, char **argv) { |
| 1896 | - |
| 1897 | - |
| 1898 | - // int i = 0; |
| 1899 | - // RLOGD("**Autosuspend Service Daemon Started**"); |
| 1900 | - // RLOGD("**Autosuspend Service param count=%d**", argc); |
| 1901 | - char tmp[20]; |
| 1902 | - |
| 1903 | - int commfd, commfd_data, server_sock, server_data_sock,len, len_data; |
| 1904 | - |
| 1905 | - struct sockaddr_un server_sockaddr; |
| 1906 | - struct sockaddr_un server_data_sockaddr; |
| 1907 | - struct sockaddr_un client_sockaddr; |
| 1908 | - |
| 1909 | - len = sizeof(server_sockaddr); |
| 1910 | - |
| 1911 | - |
| 1912 | - pthread_t tid; |
| 1913 | -#ifdef GSW_SUSPEND_CFG |
| 1914 | - pthread_t tid_1;//jb.qi add for service send when DTR is low on 20221111 |
| 1915 | -#endif |
| 1916 | - |
| 1917 | - LYLOGEINIT(USER_LOG_TAG); |
| 1918 | - LYLOGSET(LOG_DEBUG); |
| 1919 | - // LYLOGSET(LOG_ERROR); |
| 1920 | - |
| 1921 | - int auto_enable = 0; |
| 1922 | - |
| 1923 | - lynq_get_value(LOG_UCI_FILE, LOG_UCI_MODULE, "debug", tmp); // å³è·åç³»ç»å±é¢çç¯å¢åé |
| 1924 | - ALOGI("Autosuspend Service Daemon. debug %s\n",tmp); |
| 1925 | - adb_debug_mode=atoi(tmp); |
| 1926 | - lynq_get_value(LOG_UCI_FILE, LOG_UCI_MODULE, "auto_enable", tmp); |
| 1927 | - auto_enable=atoi(tmp); |
| 1928 | - ALOGI("Autosuspend Service Daemon. auto_enable %s\n",tmp); |
| 1929 | -#ifdef MOBILETEK_SUSPEND_CFG |
| 1930 | - init_wakelock_func(); |
| 1931 | - init_sim_func(); |
| 1932 | -#endif |
| 1933 | - signal(SIGPIPE,SIG_IGN); // 忽ç¥SIGPIPEä¿¡å·ï¼é²æ¢ç±äºå®¢æ·ç«¯å
³éï¼ç»§ç»å¾å®¢æ·ç«¯writeï¼ä¼å¯¼è´æå¡ç«¯æ¶å°SIGPIPEä¿¡å·èBroken pipe |
| 1934 | - |
| 1935 | - |
| 1936 | - // init_network_func(); |
| 1937 | - |
| 1938 | - // if(pthread_cond_init(&feedback_cond,NULL) != 0) |
| 1939 | - // { |
| 1940 | - // strerror_r(errno, buf, sizeof(buf)); |
| 1941 | - // ALOGI("Error creating cond: %s\n", buf); |
| 1942 | - // return -1; |
| 1943 | - // } |
| 1944 | - |
| 1945 | - set_wakeup_callback(wakeup_feedback); |
| 1946 | - // 注ååè°å½æ° |
| 1947 | - |
| 1948 | - if(auto_enable==0) |
| 1949 | - { |
| 1950 | - if(autosuspend_disable() < 0) |
| 1951 | - { |
| 1952 | - ALOGI("autosuspend_disable fail.\n"); |
| 1953 | - } |
| 1954 | - else |
| 1955 | - { |
| 1956 | - ALOGI("autosuspend_disable success.\n"); |
| 1957 | - } |
| 1958 | - } |
| 1959 | - if(auto_enable==1) |
| 1960 | - { |
| 1961 | - if(autosuspend_enable() < 0) |
| 1962 | - { |
| 1963 | - ALOGI("autosuspend_enable fail.\n"); |
| 1964 | - } |
| 1965 | - else |
| 1966 | - { |
| 1967 | - ALOGI("autosuspend_enable success.\n"); |
| 1968 | - } |
| 1969 | - } |
| 1970 | - |
| 1971 | - |
| 1972 | - server_sock = listen_port(&server_sockaddr,SOCK_PATH); |
| 1973 | - if(server_sock == -1) |
| 1974 | - return -1; |
| 1975 | - |
| 1976 | - server_data_sock = listen_port(&server_data_sockaddr,SOCK_DATA_PATH); |
| 1977 | - if(server_data_sock == -1) |
| 1978 | - return -1; |
| 1979 | -#ifdef GSW_SUSPEND_CFG |
| 1980 | - /*jb.qi add for service send when DTR is low on 20221111 start*/ |
| 1981 | - pthread_create(&tid_1,NULL,dtr_wakeup,NULL); |
| 1982 | - pthread_detach(tid_1); |
| 1983 | - /*jb.qi add for service send when DTR is low on 20221111 end*/ |
| 1984 | -#endif |
| 1985 | - |
| 1986 | - while (1) |
| 1987 | - { |
| 1988 | - ALOGI("service socket listening...\n"); |
| 1989 | - commfd = Accept(server_sock,(struct sockaddr *)&client_sockaddr,&len); |
| 1990 | - if(commfd == -1) |
| 1991 | - { |
| 1992 | - return -1; |
| 1993 | - } |
| 1994 | - if(getpeername(commfd, (struct sockaddr *)&client_sockaddr, &len) == -1) |
| 1995 | - { |
| 1996 | - ALOGI("GETPEERNAME ERROR.\n"); |
| 1997 | - // Close(server_sock); |
| 1998 | - Close(commfd); |
| 1999 | - continue; |
| 2000 | - } |
| 2001 | - else |
| 2002 | - { |
| 2003 | - ALOGI("Client socket filepath: %s\n", client_sockaddr.sun_path); |
| 2004 | - } |
| 2005 | - |
| 2006 | - commfd_data = Accept(server_data_sock,NULL,NULL); |
| 2007 | - if(commfd_data == -1) |
| 2008 | - { |
| 2009 | - return -1; |
| 2010 | - } |
| 2011 | - ALOGI("data channel connected.\n"); |
| 2012 | - |
| 2013 | - pthread_create(&tid,NULL,deal_autosuspend,(void*)&commfd);//è¿éå¾å®¹æéï¼æåä¸ä¸ªåæ°è¦åå°åï¼è¿æ¯ä¸ä¸ªæé |
| 2014 | - pthread_detach(tid); |
| 2015 | - |
| 2016 | - pthread_create(&tid,NULL,send_feedback,(void*)&commfd_data); |
| 2017 | - pthread_detach(tid); |
| 2018 | - |
| 2019 | - |
| 2020 | - } |
| 2021 | - |
| 2022 | - |
| 2023 | -} |
| 2024 | - |
| 2025 | -DEFINE_LYNQ_LIB_LOG(LYNQ_AUTOSUSPEND) |
| 2026 | - |
| 2027 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/makefile b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/makefile |
| 2028 | deleted file mode 100755 |
| 2029 | index ca263bf..0000000 |
| 2030 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/files/makefile |
| 2031 | +++ /dev/null |
| 2032 | @@ -1,71 +0,0 @@ |
| 2033 | -SHELL = /bin/sh |
| 2034 | -RM = rm -f |
| 2035 | - |
| 2036 | -LOCAL_CFLAGS := -Wall \ |
| 2037 | - -g -Os \ |
| 2038 | - -flto \ |
| 2039 | - -DRIL_SHLIB \ |
| 2040 | - -DATCI_PARSE \ |
| 2041 | - -DKEEP_ALIVE \ |
| 2042 | - -D__LINUX_OS__ \ |
| 2043 | - -DECALL_SUPPORT |
| 2044 | - |
| 2045 | - |
| 2046 | - |
| 2047 | -ifeq ($(strip $(TARGET_PLATFORM)), T106) |
| 2048 | -LOCAL_CFLAGS += -DHAVE_SYS_UIO_H -DRIL_TIME_CB |
| 2049 | -endif |
| 2050 | - |
| 2051 | -ifeq ($(strip $(TARGET_PLATFORM)), T106) |
| 2052 | - LOCAL_CFLAGS += -DMOBILETEK_TARGET_PLATFORM_T106 |
| 2053 | -endif |
| 2054 | - |
| 2055 | -ifeq ($(strip $(MOBILETEK_SUSPEND_CFG)), GSW) |
| 2056 | - LOCAL_CFLAGS += -DGSW_SUSPEND_CFG |
| 2057 | - |
| 2058 | -endif |
| 2059 | - |
| 2060 | -ifeq ($(strip $(MOBILETEK_SUSPEND_CFG)), PLATFORM) |
| 2061 | - LOCAL_CFLAGS += -DMOBILETEK_SUSPEND_CFG |
| 2062 | - |
| 2063 | -endif |
| 2064 | - |
| 2065 | - |
| 2066 | -LOCAL_PATH = . |
| 2067 | - |
| 2068 | -LOCAL_C_INCLUDES = \ |
| 2069 | - -I. -I$(ROOT)$(includedir)/liblog -I$(ROOT)$(includedir) \ |
| 2070 | - |
| 2071 | - |
| 2072 | - |
| 2073 | - |
| 2074 | -LOCAL_LIBS := \ |
| 2075 | - -L. \ |
| 2076 | - -ldl \ |
| 2077 | - -lpthread \ |
| 2078 | - -llynq-log \ |
| 2079 | - -llynq-uci \ |
| 2080 | - -llog \ |
| 2081 | - -lbsp \ |
| 2082 | - -lsctel \ |
| 2083 | - -latutils \ |
| 2084 | - -latreg \ |
| 2085 | - -llynq-sim \ |
| 2086 | - |
| 2087 | - |
| 2088 | -SOURCES = $(wildcard *.c ) |
| 2089 | - |
| 2090 | -EXECUTABLE = autosuspend |
| 2091 | - |
| 2092 | -OBJECTS=$(SOURCES:.c=.o) |
| 2093 | -all: $(EXECUTABLE) |
| 2094 | - |
| 2095 | -$(EXECUTABLE): $(OBJECTS) |
| 2096 | - $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@ |
| 2097 | - |
| 2098 | -%.o : %.c |
| 2099 | - $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $< |
| 2100 | - |
| 2101 | -.PHONY: clean |
| 2102 | -clean: |
| 2103 | - $(RM) $(OBJECTS) $(EXECUTABLE) |
| 2104 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/lynq-autosuspend.bb b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/lynq-autosuspend.bb |
| 2105 | index a3df67f..f4e38fc 100755 |
| 2106 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/lynq-autosuspend.bb |
| 2107 | +++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-autosuspend/lynq-autosuspend.bb |
| 2108 | @@ -1,68 +1,48 @@ |
| 2109 | inherit externalsrc package systemd |
| 2110 | |
| 2111 | DESCRIPTION = "autosuspend.service" |
| 2112 | +LICENSE = "CLOSED" |
| 2113 | |
| 2114 | -LICENSE = "MobileTekProprietary" |
| 2115 | LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=44d8d2b6296ca24bcd4894bb7155bf27" |
| 2116 | +DEPENDS += "${@bb.utils.contains('TARGET_PLATFORM', 'mt2735', 'audio-mixer-ctrl streamer1.0', '', d)} liblynq-log liblynq-uci libbsp libsctel libatutils libatreg liblynq-sim" |
| 2117 | |
| 2118 | -SRC_URI = "file://autosuspend.c file://LICENSE \ |
| 2119 | - file://autosuspend.h \ |
| 2120 | - file://autosuspend_ops.h \ |
| 2121 | - file://autosuspend_wakeup_count.c \ |
| 2122 | - file://main.c \ |
| 2123 | - file://autosuspend.service \ |
| 2124 | - file://lynq-autosuspend.sh \ |
| 2125 | - file://makefile \ |
| 2126 | -" |
| 2127 | - |
| 2128 | +WORKONSRC = "${TOPDIR}/../src/lynq/framework/lynq-autosuspend" |
| 2129 | +FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/framework/:" |
| 2130 | +SRC_URI = " \ |
| 2131 | + file://lynq-autosuspend \ |
| 2132 | + " |
| 2133 | +SRC-DIR = "${S}/../lynq-autosuspend" |
| 2134 | EXTRA_OEMAKE = "'TARGET_PLATFORM = ${TARGET_PLATFORM}'" |
| 2135 | |
| 2136 | TARGET_CC_ARCH += "${LDFLAGS}" |
| 2137 | - |
| 2138 | -LOCAL_C_INCLUDES = "-I. " |
| 2139 | - |
| 2140 | -DEPENDS = "liblynq-log liblynq-uci" |
| 2141 | -DEPENDS += "${@bb.utils.contains('TARGET_PLATFORM', 'mt2735', 'audio-mixer-ctrl streamer1.0', '', d)} liblynq-log liblynq-uci libbsp libsctel libatutils libatreg liblynq-sim" |
| 2142 | -LOCAL_LIBS = "-L. -ldl -lstdc++ -lpthread -llog" |
| 2143 | -SOURCES = "$(wildcard *.c )" |
| 2144 | - |
| 2145 | -OBJECTS = "$(SOURCES:.c=.o)" |
| 2146 | - |
| 2147 | -EXECUTABLE = "autosuspend" |
| 2148 | -S = "${WORKDIR}" |
| 2149 | -TARGET_CC_ARCH += "${LDFLAGS}" |
| 2150 | SYSTEMD_PACKAGES = "${PN}" |
| 2151 | SYSTEMD_SERVICE_${PN} = "autosuspend.service" |
| 2152 | FILES_${PN} += "${systemd_unitdir}/system/autosuspend.service" |
| 2153 | + |
| 2154 | #INHIBIT_PACKAGE_STRIP = "1" |
| 2155 | do_compile () { |
| 2156 | |
| 2157 | #${CXX} -Wall ${LOCAL_C_INCLUDES} autosuspend.c autosuspend_wakeup_count.c main.c ${LOCAL_LIBS} -o ${EXECUTABLE} |
| 2158 | if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then |
| 2159 | - oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float" |
| 2160 | + oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float" |
| 2161 | else |
| 2162 | - oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}" |
| 2163 | + oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}" |
| 2164 | fi |
| 2165 | } |
| 2166 | |
| 2167 | do_install() { |
| 2168 | install -d ${D}${bindir}/ |
| 2169 | - echo "Installing image PN ${PN}" |
| 2170 | - echo "Installing image systemd_unitdir ${systemd_unitdir}" |
| 2171 | - echo "Installing image D ${D}" |
| 2172 | - echo "Installing image B ${B}" |
| 2173 | + install -m 0755 ${SRC-DIR}/autosuspend ${D}${bindir}/ |
| 2174 | if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then |
| 2175 | install -d ${D}${systemd_unitdir}/system/ |
| 2176 | install -m 0644 ${B}/autosuspend.service ${D}${systemd_unitdir}/system |
| 2177 | - else |
| 2178 | + else |
| 2179 | install -d ${D}${sysconfdir}/init.d |
| 2180 | - install -m 0755 ${S}/lynq-autosuspend.sh ${D}${sysconfdir}/init.d/ |
| 2181 | - install -d ${D}${sysconfdir}/rcS.d |
| 2182 | - ln -s ../init.d/lynq-autosuspend.sh ${D}${sysconfdir}/rcS.d/S82lynq-autosuspend-service |
| 2183 | + install -m 0755 ${SRC-DIR}/lynq-autosuspend.sh ${D}${sysconfdir}/init.d/ |
| 2184 | + install -d ${D}${sysconfdir}/rcS.d |
| 2185 | + ln -s ../init.d/lynq-autosuspend.sh ${D}${sysconfdir}/rcS.d/S82lynq-autosuspend-service |
| 2186 | fi |
| 2187 | |
| 2188 | - install -m 0755 ${S}/autosuspend ${D}${bindir}/ |
| 2189 | - install -d ${D}${includedir} |
| 2190 | } |
| 2191 | |
| 2192 | |
| 2193 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/LICENSE b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/LICENSE |
| 2194 | deleted file mode 100755 |
| 2195 | index 0489348..0000000 |
| 2196 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/LICENSE |
| 2197 | +++ /dev/null |
| 2198 | @@ -1,31 +0,0 @@ |
| 2199 | -opyright Statement: |
| 2200 | - |
| 2201 | -This software/firmware and related documentation ("MobileTek Software") are |
| 2202 | -protected under relevant copyright laws. The information contained herein is |
| 2203 | -confidential and proprietary to MobileTek Inc. and/or its licensors. Without |
| 2204 | -the prior written permission of MobileTek inc. and/or its licensors, any |
| 2205 | -reproduction, modification, use or disclosure of MobileTek Software, and |
| 2206 | -information contained herein, in whole or in part, shall be strictly |
| 2207 | -prohibited. |
| 2208 | - |
| 2209 | -Mobiletek Inc. (C) 2015. All rights reserved. |
| 2210 | - |
| 2211 | -BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES |
| 2212 | -THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MobileTek SOFTWARE") |
| 2213 | -RECEIVED FROM MobileTek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER |
| 2214 | -ON AN "AS-IS" BASIS ONLY. MobileTek EXPRESSLY DISCLAIMS ANY AND ALL |
| 2215 | -WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED |
| 2216 | -WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR |
| 2217 | -NONINFRINGEMENT. NEITHER DOES MobileTek PROVIDE ANY WARRANTY WHATSOEVER WITH |
| 2218 | -RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, |
| 2219 | -INCORPORATED IN, OR SUPPLIED WITH THE MobileTek SOFTWARE, AND RECEIVER AGREES |
| 2220 | -TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. |
| 2221 | -RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO |
| 2222 | -OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MobileTek |
| 2223 | -SOFTWARE. MobileTek SHALL ALSO NOT BE RESPONSIBLE FOR ANY MobileTek SOFTWARE |
| 2224 | -RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR |
| 2225 | -STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MobileTek'S |
| 2226 | -ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MobileTek SOFTWARE |
| 2227 | -RELEASED HEREUNDER WILL BE, AT MobileTek'S OPTION, TO REVISE OR REPLACE THE |
| 2228 | -MobileTek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE |
| 2229 | -CHARGE PAID BY RECEIVER TO MobileTek FOR SUCH MobileTek SOFTWARE AT ISSUE. |
| 2230 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp |
| 2231 | deleted file mode 100755 |
| 2232 | index c2e7d1d..0000000 |
| 2233 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp |
| 2234 | +++ /dev/null |
| 2235 | @@ -1,259 +0,0 @@ |
| 2236 | -/*******************************************************
|
| 2237 | -*
|
| 2238 | -* @brief:
|
| 2239 | -* @details: add fota A/B backup service
|
| 2240 | -* @author: l.yang
|
| 2241 | -* @date: 2023.8.29
|
| 2242 | -* @version: V1.0
|
| 2243 | -* @copyrightï¼Copyright (c) MobileTek
|
| 2244 | -*
|
| 2245 | -*********************************************/
|
| 2246 | -
|
| 2247 | -
|
| 2248 | -#include <stdio.h>
|
| 2249 | -#include <stdlib.h>
|
| 2250 | -#include <stdbool.h>
|
| 2251 | -#include <dlfcn.h>
|
| 2252 | -#include <string.h>
|
| 2253 | -#include <pthread.h>
|
| 2254 | -#include <stdint.h>
|
| 2255 | -#include <unistd.h>
|
| 2256 | -#include <fcntl.h>
|
| 2257 | -#include <errno.h>
|
| 2258 | -#include <liblog/lynq_deflog.h>
|
| 2259 | -
|
| 2260 | -
|
| 2261 | -#ifdef __cplusplus
|
| 2262 | -extern "C" {
|
| 2263 | -#endif
|
| 2264 | -
|
| 2265 | -#define FOTA_REBOOT_FLAG "/mnt/userdata/.fota_reboot_flag"
|
| 2266 | -#define FOTA_FLAG_FILE "/mnt/userdata/.back_up_flag"
|
| 2267 | -#define FOTA_SYNC_FLAG 1
|
| 2268 | -#define FOTA_CURRENT_SYS "/mnt/userdata/.fota_current_sys"
|
| 2269 | -
|
| 2270 | -#define USER_LOG_TAG "LYNQ_FOTA_BACKUP"
|
| 2271 | -
|
| 2272 | -extern int lynq_sync_system();
|
| 2273 | -extern int lynq_fota_get_addr_value(char *tmp_value);
|
| 2274 | -extern int lynq_fota_set_addr_value(char *value,int size);
|
| 2275 | -extern int lynq_fota_nrestart(void);
|
| 2276 | -extern int lynq_get_current_system();
|
| 2277 | -
|
| 2278 | -
|
| 2279 | -#define REBOOT_DONE 1
|
| 2280 | -
|
| 2281 | -void set_upgrade_reboot_flag(void)
|
| 2282 | -{
|
| 2283 | - FILE *fp = NULL;
|
| 2284 | - int reboot_flag = REBOOT_DONE;
|
| 2285 | - fp = fopen(FOTA_REBOOT_FLAG,"w+");
|
| 2286 | - if(fp == NULL)
|
| 2287 | - {
|
| 2288 | - LYERRLOG("Open reboot flag file failed\n");
|
| 2289 | - return;
|
| 2290 | - }
|
| 2291 | -
|
| 2292 | - fwrite(&reboot_flag,sizeof(int),1,fp);
|
| 2293 | - fclose(fp);
|
| 2294 | - system("sync");
|
| 2295 | - return ;
|
| 2296 | -}
|
| 2297 | -
|
| 2298 | -int check_need_sync()
|
| 2299 | -{
|
| 2300 | - int current_sys = 0;
|
| 2301 | - int record_sys = 0;
|
| 2302 | - int ret = 0;
|
| 2303 | - char tmp_sys[8] = {0};
|
| 2304 | - FILE *fp = NULL;
|
| 2305 | -
|
| 2306 | - //not fota
|
| 2307 | - if(access(FOTA_FLAG_FILE, F_OK) == -1)
|
| 2308 | - {
|
| 2309 | - LYINFLOG("Fota flag file no exist\n");
|
| 2310 | -
|
| 2311 | - //file no exist,get current sys write to file
|
| 2312 | - if(access(FOTA_CURRENT_SYS,F_OK) == -1)
|
| 2313 | - {
|
| 2314 | - LYINFLOG("Record current sys file no exist\n");
|
| 2315 | -
|
| 2316 | - fp = fopen(FOTA_CURRENT_SYS,"w");
|
| 2317 | - if(fp == NULL)
|
| 2318 | - {
|
| 2319 | - LYERRLOG("creat record current file failed\n");
|
| 2320 | - return -1;
|
| 2321 | - }
|
| 2322 | - current_sys = lynq_get_current_system();
|
| 2323 | - if(current_sys < 0)
|
| 2324 | - {
|
| 2325 | - LYERRLOG("Get current system failed %d\n",current_sys);
|
| 2326 | - fclose(fp);
|
| 2327 | - return -1;
|
| 2328 | - }
|
| 2329 | - else
|
| 2330 | - {
|
| 2331 | -
|
| 2332 | - LYINFLOG("Get current system success %d\n",current_sys);
|
| 2333 | - fprintf(fp, "%d", current_sys);
|
| 2334 | - fclose(fp);
|
| 2335 | - system("sync");
|
| 2336 | -
|
| 2337 | - return 0;
|
| 2338 | - }
|
| 2339 | - }
|
| 2340 | - else
|
| 2341 | - {
|
| 2342 | - current_sys = lynq_get_current_system();
|
| 2343 | - if(current_sys < 0)
|
| 2344 | - {
|
| 2345 | - LYERRLOG("Get current system failed %d\n",current_sys);
|
| 2346 | - return -1;
|
| 2347 | - }
|
| 2348 | -
|
| 2349 | - LYINFLOG("Get current system success %d\n",current_sys);
|
| 2350 | -
|
| 2351 | - fp = fopen(FOTA_CURRENT_SYS,"r");
|
| 2352 | - if(fp == NULL)
|
| 2353 | - {
|
| 2354 | - LYERRLOG("read file failed \n");
|
| 2355 | - return -1;
|
| 2356 | - }
|
| 2357 | -
|
| 2358 | - if(fgets(tmp_sys, sizeof(tmp_sys), fp) != NULL)
|
| 2359 | - {
|
| 2360 | - record_sys = atoi(tmp_sys);
|
| 2361 | - }
|
| 2362 | - else
|
| 2363 | - {
|
| 2364 | - LYERRLOG("tmp_sys is NULL");
|
| 2365 | - fclose(fp);
|
| 2366 | - return -1;
|
| 2367 | - }
|
| 2368 | -
|
| 2369 | - if( record_sys == current_sys)
|
| 2370 | - {
|
| 2371 | - LYINFLOG("System not need sync \n");
|
| 2372 | - fclose(fp);
|
| 2373 | - return 0;
|
| 2374 | - }
|
| 2375 | - else
|
| 2376 | - {
|
| 2377 | - LYINFLOG("System need sync \n");
|
| 2378 | - ret = lynq_sync_system();
|
| 2379 | - if(ret < 0 )
|
| 2380 | - {
|
| 2381 | - LYERRLOG("A/B sync system failed \n");
|
| 2382 | - fclose(fp);
|
| 2383 | - return -1;
|
| 2384 | - }
|
| 2385 | - LYINFLOG("A/B sync system success,record current sys \n");
|
| 2386 | - fclose(fp);
|
| 2387 | - fp = fopen(FOTA_CURRENT_SYS,"w");
|
| 2388 | - if(fp == NULL)
|
| 2389 | - {
|
| 2390 | - LYERRLOG("creat file failed \n");
|
| 2391 | - return -1;
|
| 2392 | - }
|
| 2393 | -
|
| 2394 | - fprintf(fp,"%d",current_sys);
|
| 2395 | - fclose(fp);
|
| 2396 | - system("sync");
|
| 2397 | -
|
| 2398 | - return 0;
|
| 2399 | - }
|
| 2400 | - }
|
| 2401 | -
|
| 2402 | -
|
| 2403 | - }
|
| 2404 | - else
|
| 2405 | - {
|
| 2406 | - fp = fopen(FOTA_CURRENT_SYS,"w");
|
| 2407 | - if(fp == NULL)
|
| 2408 | - {
|
| 2409 | - LYERRLOG("Creat file failed \n");
|
| 2410 | - return -1;
|
| 2411 | - }
|
| 2412 | - LYINFLOG("fota flag file exist,record current sys \n");
|
| 2413 | - current_sys = lynq_get_current_system();
|
| 2414 | - if(current_sys < 0)
|
| 2415 | - {
|
| 2416 | - LYERRLOG("Get current system failed %d\n",current_sys);
|
| 2417 | - fclose(fp);
|
| 2418 | - return -1;
|
| 2419 | - }
|
| 2420 | -
|
| 2421 | - fprintf(fp,"%d",current_sys);
|
| 2422 | - fclose(fp);
|
| 2423 | - system("sync");
|
| 2424 | - return 0;
|
| 2425 | - }
|
| 2426 | -
|
| 2427 | -
|
| 2428 | -}
|
| 2429 | -
|
| 2430 | -int main()
|
| 2431 | -{
|
| 2432 | - int ret = 0 ;
|
| 2433 | - int sync_flag = 0;
|
| 2434 | - char tmp_addr[128] = {0};
|
| 2435 | - FILE *fp = NULL;
|
| 2436 | -
|
| 2437 | - check_need_sync();
|
| 2438 | -
|
| 2439 | - fp = fopen(FOTA_FLAG_FILE,"r");
|
| 2440 | - if(fp == NULL)
|
| 2441 | - {
|
| 2442 | - LYERRLOG("No need fota sync\n");
|
| 2443 | - return -1;
|
| 2444 | -
|
| 2445 | - }
|
| 2446 | -
|
| 2447 | - fread(&sync_flag,sizeof(int),1,fp);
|
| 2448 | - fclose(fp);
|
| 2449 | -
|
| 2450 | - set_upgrade_reboot_flag();
|
| 2451 | -
|
| 2452 | - if(sync_flag == FOTA_SYNC_FLAG)
|
| 2453 | - {
|
| 2454 | - ret = lynq_sync_system();
|
| 2455 | - if(ret != 0)
|
| 2456 | - {
|
| 2457 | - LYERRLOG("sync faild\n");
|
| 2458 | - }
|
| 2459 | - system("rm -rf /mnt/userdata/.back_up_flag");
|
| 2460 | -
|
| 2461 | - }
|
| 2462 | - else if(sync_flag != FOTA_SYNC_FLAG)
|
| 2463 | - {
|
| 2464 | - ret = lynq_fota_get_addr_value(tmp_addr);
|
| 2465 | - if(ret != 0)
|
| 2466 | - {
|
| 2467 | - LYERRLOG("Get addr failed\n");
|
| 2468 | - return -1;
|
| 2469 | - }
|
| 2470 | - LYINFLOG("tmp_addr is %s\n",tmp_addr);
|
| 2471 | - ret = lynq_fota_set_addr_value(tmp_addr,10);
|
| 2472 | - if(ret != 0)
|
| 2473 | - {
|
| 2474 | - LYERRLOG("Set addr failed\n");
|
| 2475 | - return -1;
|
| 2476 | - }
|
| 2477 | - ret = lynq_fota_nrestart();
|
| 2478 | - if(ret != 0)
|
| 2479 | - {
|
| 2480 | - LYERRLOG("Upgrade failed\n");
|
| 2481 | - return -1;
|
| 2482 | - }
|
| 2483 | -
|
| 2484 | - }
|
| 2485 | -
|
| 2486 | - return 0;
|
| 2487 | -
|
| 2488 | -}
|
| 2489 | -DEFINE_LYNQ_LIB_LOG(LYNQ_FOTA_BACKUP)
|
| 2490 | -
|
| 2491 | -#ifdef __cplusplus
|
| 2492 | -}
|
| 2493 | -#endif
|
| 2494 | -
|
| 2495 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.service b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.service |
| 2496 | deleted file mode 100755 |
| 2497 | index 28851ff..0000000 |
| 2498 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.service |
| 2499 | +++ /dev/null |
| 2500 | @@ -1,10 +0,0 @@ |
| 2501 | -[Unit] |
| 2502 | -Description=lynq-fota-backup-service |
| 2503 | - |
| 2504 | -[Service] |
| 2505 | -ExecStart=/usr/bin/lynq-fota-backup |
| 2506 | -Type=simple |
| 2507 | - |
| 2508 | -[Install] |
| 2509 | -WantedBy=multi-user.target |
| 2510 | - |
| 2511 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.sh b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.sh |
| 2512 | deleted file mode 100755 |
| 2513 | index 53eb20f..0000000 |
| 2514 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.sh |
| 2515 | +++ /dev/null |
| 2516 | @@ -1,39 +0,0 @@ |
| 2517 | -#!/bin/sh |
| 2518 | -# |
| 2519 | -# Run the daemon |
| 2520 | -# |
| 2521 | - |
| 2522 | -DAEMON="lynq-fota-backup-service" |
| 2523 | -PIDFILE="/var/run/$DAEMON.pid" |
| 2524 | -EXEC="/usr/bin/lynq-fota-backup" |
| 2525 | -EXEC_ARGS="" |
| 2526 | - |
| 2527 | - |
| 2528 | -start() { |
| 2529 | - echo -n "Starting $DAEMON... " |
| 2530 | - start-stop-daemon --no-close -S -b -m -p $PIDFILE -x $EXEC -- $EXEC_ARGS |
| 2531 | - [ $? -eq 0 ] && echo "OK" || echo "ERROR" |
| 2532 | -} |
| 2533 | - |
| 2534 | -stop() { |
| 2535 | - echo -n "Stopping $DAEMON... " |
| 2536 | - start-stop-daemon -K -p $PIDFILE |
| 2537 | - [ $? -eq 0 ] && echo "OK" || echo "ERROR" |
| 2538 | -} |
| 2539 | - |
| 2540 | -restart() { |
| 2541 | - stop |
| 2542 | - start |
| 2543 | -} |
| 2544 | - |
| 2545 | -case "$1" in |
| 2546 | - start|stop|restart) |
| 2547 | - "$1" |
| 2548 | - ;; |
| 2549 | - *) |
| 2550 | - echo "Usage: $0 {start|stop|restart}" |
| 2551 | - exit 1 |
| 2552 | -esac |
| 2553 | - |
| 2554 | -exit $? |
| 2555 | - |
| 2556 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/makefile b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/makefile |
| 2557 | deleted file mode 100755 |
| 2558 | index 0a349d3..0000000 |
| 2559 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/makefile |
| 2560 | +++ /dev/null |
| 2561 | @@ -1,57 +0,0 @@ |
| 2562 | -SHELL = /bin/sh
|
| 2563 | -RM = rm -f
|
| 2564 | -
|
| 2565 | -LOCAL_CFLAGS := -Wall \
|
| 2566 | - -std=gnu++14 \
|
| 2567 | - -g -Os \
|
| 2568 | - -flto \
|
| 2569 | - -fPIC \
|
| 2570 | -
|
| 2571 | -
|
| 2572 | -
|
| 2573 | -ifeq ($(strip $(TARGET_PLATFORM)), T106)
|
| 2574 | -LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
|
| 2575 | -endif
|
| 2576 | -
|
| 2577 | -LOCAL_CFLAGS += -Werror=format-security
|
| 2578 | -
|
| 2579 | -$(warning ################# rock ROOT: $(ROOT),includedir:$(includedir),)
|
| 2580 | -
|
| 2581 | -LOCAL_PATH = .
|
| 2582 | -
|
| 2583 | -LOCAL_C_INCLUDES = \
|
| 2584 | - -I. \
|
| 2585 | - -I$(LOCAL_PATH)/include \
|
| 2586 | - -I$(ROOT)$(includedir)/logger \
|
| 2587 | - -I$(ROOT)$(includedir)/liblog \
|
| 2588 | - -I$(ROOT)$(includedir)/glib-2.0 \
|
| 2589 | - -I$(ROOT)$(libdir)/glib-2.0/include \
|
| 2590 | - -I$(ROOT)$(includedir) \
|
| 2591 | -
|
| 2592 | -
|
| 2593 | -
|
| 2594 | -LOCAL_LIBS := \
|
| 2595 | - -L. \
|
| 2596 | - -ldl \
|
| 2597 | - -lstdc++ \
|
| 2598 | - -llynq-log \
|
| 2599 | - -llynq-fota \
|
| 2600 | -
|
| 2601 | -SOURCES = lynq-fota-backup.cpp
|
| 2602 | -
|
| 2603 | -EXECUTABLE = lynq-fota-backup
|
| 2604 | -
|
| 2605 | -OBJECTS=$(SOURCES:.cpp=.o)
|
| 2606 | -
|
| 2607 | -all: $(EXECUTABLE)
|
| 2608 | -$(EXECUTABLE): $(OBJECTS)
|
| 2609 | - $(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
|
| 2610 | -
|
| 2611 | -%.o : %.cpp
|
| 2612 | - $(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
|
| 2613 | -
|
| 2614 | -.PHONY: clean
|
| 2615 | -clean:
|
| 2616 | - $(RM) $(OBJECTS) $(EXECUTABLE)
|
| 2617 | - $(RM) $(OBJECTS_TOOL) $(EXECUTABLE)
|
| 2618 | -
|
| 2619 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/lynq-fota-backup.bb b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/lynq-fota-backup.bb |
| 2620 | index b89f7ab..89ed7f6 100755 |
| 2621 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/lynq-fota-backup.bb |
| 2622 | +++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/lynq-fota-backup.bb |
| 2623 | @@ -2,31 +2,28 @@ |
| 2624 | |
| 2625 | DESCRIPTION = "lynq-fota-backup.service" |
| 2626 | |
| 2627 | -LICENSE = "MIT" |
| 2628 | +LICENSE = "CLOSED" |
| 2629 | ##License checksum file is always required |
| 2630 | LIC_FILES_CHKSUM = "file://${WORKDIR}/LICENSE;md5=c794e8ff1acd3b7f156a6497e780dd54" |
| 2631 | |
| 2632 | -SRC_URI = "file://lynq-fota-backup.cpp \ |
| 2633 | - file://lynq-fota-backup.sh \ |
| 2634 | - file://makefile \ |
| 2635 | - file://lynq-fota-backup.service \ |
| 2636 | - file://LICENSE \ |
| 2637 | -" |
| 2638 | +WORKONSRC = "${TOPDIR}/../src/lynq/framework/lynq-fota-backup" |
| 2639 | |
| 2640 | - |
| 2641 | +FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/framework/:" |
| 2642 | +SRC_URI = " \ |
| 2643 | + file://lynq-fota-backup \ |
| 2644 | + " |
| 2645 | +SRC-DIR = "${S}/../lynq-fota-backup" |
| 2646 | TARGET_CC_ARCH += "${LDFLAGS}" |
| 2647 | - |
| 2648 | - |
| 2649 | DEPENDS += "liblynq-log liblynq-uci liblynq-qser-fota" |
| 2650 | -S = "${WORKDIR}" |
| 2651 | + |
| 2652 | #INHIBIT_PACKAGE_STRIP = "1" |
| 2653 | do_compile () { |
| 2654 | |
| 2655 | |
| 2656 | if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then |
| 2657 | - oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float" |
| 2658 | + oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float" |
| 2659 | else |
| 2660 | - oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}" |
| 2661 | + oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}" |
| 2662 | fi |
| 2663 | } |
| 2664 | #INHIBIT_PACKAGE_STRIP = "1" |
| 2665 | @@ -34,21 +31,16 @@ |
| 2666 | |
| 2667 | do_install() { |
| 2668 | install -d ${D}${bindir}/ |
| 2669 | - echo "Installing image PN ${PN}" |
| 2670 | - echo "Installing image systemd_unitdir ${systemd_unitdir}" |
| 2671 | - echo "Installing image D ${D}" |
| 2672 | - echo "Installing image B ${B}" |
| 2673 | + install -m 0755 ${SRC-DIR}/lynq-fota-backup ${D}${bindir}/ |
| 2674 | |
| 2675 | if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then |
| 2676 | install -d ${D}${systemd_unitdir}/system/ |
| 2677 | install -m 0644 ${B}/lynq-fota-backup.service ${D}${systemd_unitdir}/system |
| 2678 | else |
| 2679 | install -d ${D}${sysconfdir}/init.d |
| 2680 | - install -m 0755 ${S}/lynq-fota-backup.sh ${D}${sysconfdir}/init.d/ |
| 2681 | + install -m 0755 ${SRC-DIR}/lynq-fota-backup.sh ${D}${sysconfdir}/init.d/ |
| 2682 | install -d ${D}${sysconfdir}/rcS.d |
| 2683 | ln -s ../init.d/lynq-fota-backup.sh ${D}${sysconfdir}/rcS.d/S82lynq-fota-backup-service |
| 2684 | fi |
| 2685 | |
| 2686 | - install -m 0755 ${S}/lynq-fota-backup ${D}${bindir}/ |
| 2687 | - install -d ${D}${includedir} |
| 2688 | } |
| 2689 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/main.c b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/main.c |
| 2690 | index 6b9fddd..c7752c6 100755 |
| 2691 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/main.c |
| 2692 | +++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-gnss-update/files/main.c |
| 2693 | @@ -203,6 +203,9 @@ |
| 2694 | }
|
| 2695 |
|
| 2696 | /*go to boot-mode need change pin status*/
|
| 2697 | + lynq_gpio_init(84,1,0,0);
|
| 2698 | + lynq_gpio_value_set(84,1);
|
| 2699 | + usleep(500000);//500ms
|
| 2700 | lynq_gpio_init(15,1,0,0);
|
| 2701 | lynq_gpio_value_set(15, 0);
|
| 2702 | usleep(100000);//100ms
|
| 2703 | @@ -213,6 +216,7 @@ |
| 2704 | usleep(100000);//100ms
|
| 2705 | lynq_gpio_direction_set(15, 0);
|
| 2706 | lynq_gpio_pullsel_set(15, 0);
|
| 2707 | + lynq_gpio_deinit(84);
|
| 2708 | lynq_gpio_deinit(15);
|
| 2709 | lynq_gpio_deinit(126);
|
| 2710 |
|
| 2711 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-qser-voice-demo/files/lynq-qser-voice-demo.cpp b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-qser-voice-demo/files/lynq-qser-voice-demo.cpp |
| 2712 | index 41c5c97..e7eebc3 100755 |
| 2713 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-qser-voice-demo/files/lynq-qser-voice-demo.cpp |
| 2714 | +++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-qser-voice-demo/files/lynq-qser-voice-demo.cpp |
| 2715 | @@ -29,6 +29,8 @@ |
| 2716 | {7, "qser_voice_set_test_num"},
|
| 2717 | {8, "qser_voice_fast_ecall"},
|
| 2718 | #endif
|
| 2719 | + {9, "qser_voice_set_audio_mode"},
|
| 2720 | + {10, "qser_voice_get_audio_mode"},
|
| 2721 | {-1, NULL}
|
| 2722 | };
|
| 2723 |
|
| 2724 | @@ -51,6 +53,9 @@ |
| 2725 | int (*qser_voice_set_speech_volume)(const int volume);
|
| 2726 | int (*qser_voice_get_speech_volume)(int *volume);
|
| 2727 | int (*qser_voice_set_dtmf)(const char callnum);
|
| 2728 | +int (*qser_voice_set_audio_mode)(const int audio_mode);
|
| 2729 | +int (*qser_voice_get_audio_mode)(int* audio_mode);
|
| 2730 | +
|
| 2731 |
|
| 2732 | #ifdef ECALL_SUPPORT
|
| 2733 | int (*qser_voice_set_test_num)(voice_client_handle_type* h_voice,E_QSER_VOICE_ECALL_SET_TYPE_T type, const char *test_num, int test_num_length);
|
| 2734 | @@ -119,6 +124,7 @@ |
| 2735 | int ret = 0;
|
| 2736 | int voice_call_id = 0;
|
| 2737 | voice_client_handle_type h_voice = 0;
|
| 2738 | + int audio_mode = 0;
|
| 2739 |
|
| 2740 | const char *lynqLibPath_Call = "/lib/liblynq-qser-voice.so";
|
| 2741 | dlHandle_call = dlopen(lynqLibPath_Call, RTLD_NOW);
|
| 2742 | @@ -230,7 +236,23 @@ |
| 2743 | printf("qser_voice_add_ecall_indhandler not defined or exported in %s\n", lynqLibPath_Call);
|
| 2744 | return -1;
|
| 2745 | }
|
| 2746 | -#endif
|
| 2747 | +#endif
|
| 2748 | +
|
| 2749 | + qser_voice_set_audio_mode = (int(*)(const int audio_mode))dlsym(dlHandle_call, "qser_voice_set_audio_mode");
|
| 2750 | + if(qser_voice_set_audio_mode == NULL)
|
| 2751 | + {
|
| 2752 | + printf("qser_voice_set_audio_mode not defined or exported in %s\n", lynqLibPath_Call);
|
| 2753 | + return -1;
|
| 2754 | + }
|
| 2755 | +
|
| 2756 | +
|
| 2757 | + qser_voice_get_audio_mode = (int(*)(int* audio_mode))dlsym(dlHandle_call, "qser_voice_get_audio_mode");
|
| 2758 | + if(qser_voice_get_audio_mode == NULL)
|
| 2759 | + {
|
| 2760 | + printf("qser_voice_get_audio_mode not defined or exported in %s\n", lynqLibPath_Call);
|
| 2761 | + return -1;
|
| 2762 | + }
|
| 2763 | +
|
| 2764 |
|
| 2765 | ret = qser_voice_call_client_init(&h_voice);
|
| 2766 | if(ret != 0 )
|
| 2767 | @@ -349,8 +371,12 @@ |
| 2768 | case 7:
|
| 2769 | {
|
| 2770 | char PhoneNum[32] = {0};
|
| 2771 | - printf("please input test phone number: \n");
|
| 2772 | - scanf("%s", PhoneNum);
|
| 2773 | + printf("please input test phone number(input null means \"\"): \n");
|
| 2774 | + scanf("%s", PhoneNum);
|
| 2775 | + if(0 == strcmp(PhoneNum, "null"))
|
| 2776 | + {
|
| 2777 | + PhoneNum[0]='\0';
|
| 2778 | + }
|
| 2779 | ret = qser_voice_set_test_num(&h_voice, E_QSER_VOICE_ECALL_SET_NUMBER, PhoneNum, strlen(PhoneNum)+1);
|
| 2780 | printf("qser_voice_set_test_num ret = %d\n", ret);
|
| 2781 | break;
|
| 2782 | @@ -378,6 +404,22 @@ |
| 2783 | break;
|
| 2784 | }
|
| 2785 | #endif
|
| 2786 | + case 9:
|
| 2787 | + {
|
| 2788 | +
|
| 2789 | + printf("please input voice audio mode: 0 codec, 1 rtp\n");
|
| 2790 | + scanf("%d", &audio_mode);
|
| 2791 | + ret = qser_voice_set_audio_mode(audio_mode);
|
| 2792 | + printf("qser_voice_set_audio_mode ret = %d, audio_mode is %d\n", ret, audio_mode);
|
| 2793 | + break;
|
| 2794 | + }
|
| 2795 | + case 10:
|
| 2796 | + {
|
| 2797 | + ret = qser_voice_get_audio_mode(&audio_mode);
|
| 2798 | + printf("qser_voice_get_audio_mode ret = %d, audio_mode is %d\n", ret, audio_mode);
|
| 2799 | + break;
|
| 2800 | + }
|
| 2801 | +
|
| 2802 | default:
|
| 2803 | print_help();
|
| 2804 | break;
|
| 2805 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c |
| 2806 | new file mode 100755 |
| 2807 | index 0000000..fc94d2a |
| 2808 | --- /dev/null |
| 2809 | +++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c |
| 2810 | @@ -0,0 +1,770 @@ |
| 2811 | +#include <stdio.h>
|
| 2812 | +#include <unistd.h>
|
| 2813 | +#include <string.h>
|
| 2814 | +#include <stdlib.h>
|
| 2815 | +#include <stdint.h>
|
| 2816 | +#include <sys/ioctl.h>
|
| 2817 | +#include <fcntl.h>
|
| 2818 | +//#include "voice_ipc.h"
|
| 2819 | +
|
| 2820 | +#define _USE_VOICE_BUFFER
|
| 2821 | +#include "voice_lib.h"
|
| 2822 | +#include <fcntl.h>
|
| 2823 | +#include <signal.h>
|
| 2824 | +#include <semaphore.h>
|
| 2825 | +#include <sys/types.h>
|
| 2826 | +#include <pthread.h>
|
| 2827 | +
|
| 2828 | +/*command max len*/
|
| 2829 | +#define VOICE_CMD_MAX_LEN 64
|
| 2830 | +
|
| 2831 | +#define EXIT_CMD_STOP "stop\n"
|
| 2832 | +#define EXIT_CMD_Q "q\n"
|
| 2833 | +#define EXIT_CMD_EXIT "exit\n"
|
| 2834 | +
|
| 2835 | +#define REQ_VOICE_BUFFER_TEST_START "voice_buffer_test_start"
|
| 2836 | +#define REQ_VOICE_BUFFER_TEST_STOP "voice_buffer_test_stop"
|
| 2837 | +#define REQ_VOICE_BUFFER_LOOP_TEST_START "voice_buffer_loop_test_start"
|
| 2838 | +#define REQ_VOICE_BUFFER_LOOP_TEST_STOP "voice_buffer_loop_test_stop"
|
| 2839 | +#define REQ_VOICE_BUFFER_RTP_TEST_START "voice_buffer_rtp_test_start"
|
| 2840 | +#define REQ_VOICE_BUFFER_RTP_TEST_STOP "voice_buffer_rtp_test_stop"
|
| 2841 | +
|
| 2842 | +
|
| 2843 | +
|
| 2844 | +#define VBUFFER_TX_FILE_NAME "/mnt/userdata/tx.pcm"
|
| 2845 | +#define VBUFFER_RX_FILE_NAME "/mnt/userdata/rx.pcm"
|
| 2846 | +#define VBUFFER_TX16_FILE_NAME "/mnt/userdata/tx16.pcm"
|
| 2847 | +#define VBUFFER_RX16_FILE_NAME "/mnt/userdata/rx16.pcm"
|
| 2848 | +
|
| 2849 | +
|
| 2850 | +
|
| 2851 | +#define VB_MAX_INT 0x7fffffff
|
| 2852 | +#define VB_MIN_INT 0
|
| 2853 | +#define VB_INT_OVERFLOW(x) if((x < VB_MIN_INT)||(x > VB_MAX_INT)) x = 0;
|
| 2854 | +
|
| 2855 | +#define RX_FILE_LEN_MAX 0x100000
|
| 2856 | +
|
| 2857 | +
|
| 2858 | +
|
| 2859 | +typedef int (vb_thread_proc)(void*);
|
| 2860 | +struct vbuf_info_t
|
| 2861 | +{
|
| 2862 | + int fd;
|
| 2863 | + pthread_t rx_test_thread;
|
| 2864 | + pthread_t tx_test_thread;
|
| 2865 | + pthread_t loop_test_thread;
|
| 2866 | + int quit;
|
| 2867 | + char *tx_buf;
|
| 2868 | + char *rx_buf;
|
| 2869 | + int buf_size;
|
| 2870 | + char *tx_filename;
|
| 2871 | + char *rx_filename;
|
| 2872 | + FILE *tx_file;
|
| 2873 | + FILE *rx_file;
|
| 2874 | + int tx_filesize;
|
| 2875 | + int rx_filesize;
|
| 2876 | + int fs;
|
| 2877 | +};
|
| 2878 | +
|
| 2879 | +static struct vbuf_info_t vbuf_rec;
|
| 2880 | +
|
| 2881 | +static void printUsage(const char *Opt)
|
| 2882 | +{
|
| 2883 | + printf("Usage: %s\n", Opt);
|
| 2884 | +
|
| 2885 | + printf("voice_buffer_test_start value: 8000,16000\n");
|
| 2886 | + printf("voice_buffer_test_stop no value input\n");
|
| 2887 | + printf("voice_buffer_loop_test_start value: 8000,16000\n");
|
| 2888 | + printf("voice_buffer_loop_test_stop no value input\n");
|
| 2889 | + printf("\n");
|
| 2890 | +}
|
| 2891 | +
|
| 2892 | +static int vbuffer_start_flag = 0;
|
| 2893 | +static int tx_optcount = 0;
|
| 2894 | +static int rx_optcount = 0;
|
| 2895 | +static int first_rderr_flag = 0;
|
| 2896 | +static int first_wrerr_flag = 0;
|
| 2897 | +
|
| 2898 | +static int vb_close_fd_release_buf()
|
| 2899 | +{
|
| 2900 | + int ret = voice_buffer_close(vbuf_rec.fd);
|
| 2901 | + if(ret != 0)
|
| 2902 | + {
|
| 2903 | + printf("%s : vb close fail \n",__func__);
|
| 2904 | + }
|
| 2905 | + vbuf_rec.fd = -1;
|
| 2906 | +
|
| 2907 | + if(vbuf_rec.rx_buf)
|
| 2908 | + {
|
| 2909 | + free(vbuf_rec.rx_buf);
|
| 2910 | + vbuf_rec.rx_buf = NULL;
|
| 2911 | + }
|
| 2912 | +
|
| 2913 | + if(vbuf_rec.tx_buf)
|
| 2914 | + {
|
| 2915 | + free(vbuf_rec.tx_buf);
|
| 2916 | + vbuf_rec.tx_buf = NULL;
|
| 2917 | + }
|
| 2918 | +
|
| 2919 | + vbuffer_start_flag = 0;
|
| 2920 | + printf("close buf fd and release buf end\n");
|
| 2921 | + return ret;
|
| 2922 | +}
|
| 2923 | +
|
| 2924 | +
|
| 2925 | +
|
| 2926 | +//whole rx path
|
| 2927 | +static int vb_rx_test_thread_func(void *arg)
|
| 2928 | +{
|
| 2929 | + int ret;
|
| 2930 | +
|
| 2931 | + char* buf = vbuf_rec.rx_buf;
|
| 2932 | + int size = vbuf_rec.buf_size;
|
| 2933 | + int bytes_read = 0;
|
| 2934 | + int r_size;
|
| 2935 | +
|
| 2936 | +
|
| 2937 | + printf( "%s: start size=%d! \n",__func__,size);
|
| 2938 | + memset (buf,0, size);
|
| 2939 | +
|
| 2940 | + while (!vbuf_rec.quit)
|
| 2941 | + {
|
| 2942 | + rx_optcount ++;
|
| 2943 | + VB_INT_OVERFLOW(rx_optcount);
|
| 2944 | + if((rx_optcount%1000) == 0){
|
| 2945 | + printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);
|
| 2946 | +
|
| 2947 | + }
|
| 2948 | + else if(rx_optcount == 1000000){
|
| 2949 | + printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);
|
| 2950 | + rx_optcount = 0;
|
| 2951 | +
|
| 2952 | + }
|
| 2953 | +
|
| 2954 | + //read form ps
|
| 2955 | + r_size = voice_buffer_read(vbuf_rec.fd, buf, size);
|
| 2956 | + if(r_size <= 0)
|
| 2957 | + {
|
| 2958 | + first_rderr_flag++;
|
| 2959 | + VB_INT_OVERFLOW(first_rderr_flag);
|
| 2960 | + continue ;
|
| 2961 | + }
|
| 2962 | + else{
|
| 2963 | + first_rderr_flag = 0;
|
| 2964 | +
|
| 2965 | + }
|
| 2966 | +
|
| 2967 | + if(vbuf_rec.rx_file != NULL)
|
| 2968 | + {
|
| 2969 | + r_size = fwrite(buf, 1,size, vbuf_rec.rx_file);
|
| 2970 | +
|
| 2971 | + if (r_size != size) {
|
| 2972 | + //printf("Error fwrite size not eq,r_size=%d,size=%d\n",r_size,size);
|
| 2973 | + }
|
| 2974 | + else{
|
| 2975 | +
|
| 2976 | + bytes_read += size;
|
| 2977 | + if(bytes_read >= vbuf_rec.rx_filesize){
|
| 2978 | + fseek(vbuf_rec.rx_file, 0, SEEK_SET);
|
| 2979 | + bytes_read = 0;
|
| 2980 | + printf("fwrite over write maxsize(%d)!!!\n",vbuf_rec.rx_filesize);
|
| 2981 | +
|
| 2982 | + }
|
| 2983 | + }
|
| 2984 | + }
|
| 2985 | +
|
| 2986 | +
|
| 2987 | + }
|
| 2988 | +
|
| 2989 | + return 0;
|
| 2990 | +}
|
| 2991 | +
|
| 2992 | +static int vb_tx_test_thread_func(void *arg)
|
| 2993 | +{
|
| 2994 | + int ret;
|
| 2995 | + int num_read;
|
| 2996 | +
|
| 2997 | +
|
| 2998 | + char* buf = vbuf_rec.tx_buf;
|
| 2999 | +
|
| 3000 | + int size = vbuf_rec.buf_size;
|
| 3001 | + int w_size;
|
| 3002 | +
|
| 3003 | + printf("%s: start size=%d! \n",__func__,size);
|
| 3004 | +
|
| 3005 | +
|
| 3006 | + memset(buf, 0,size);
|
| 3007 | + while (!vbuf_rec.quit)
|
| 3008 | + {
|
| 3009 | +
|
| 3010 | + if(vbuf_rec.tx_file != NULL)
|
| 3011 | + {
|
| 3012 | +
|
| 3013 | + num_read = fread(buf,1,size, vbuf_rec.tx_file);
|
| 3014 | +
|
| 3015 | + if (num_read != size) {
|
| 3016 | + //printf("Error fread size not eq,num_read=%d,size=%d\n",num_read,size);
|
| 3017 | + }
|
| 3018 | + if (num_read <= 0) {
|
| 3019 | + printf("Error fread size not eq,num_read=%d,size=%d\n",num_read,size);
|
| 3020 | + fseek(vbuf_rec.tx_file, 0, SEEK_SET);
|
| 3021 | + }
|
| 3022 | + }
|
| 3023 | + tx_optcount ++;
|
| 3024 | + VB_INT_OVERFLOW(tx_optcount);
|
| 3025 | +
|
| 3026 | + w_size = voice_buffer_write(vbuf_rec.fd, buf, size);
|
| 3027 | + if(w_size <= 0)
|
| 3028 | + {
|
| 3029 | + first_wrerr_flag++;
|
| 3030 | +
|
| 3031 | + VB_INT_OVERFLOW(first_wrerr_flag);
|
| 3032 | +
|
| 3033 | + continue;
|
| 3034 | + }
|
| 3035 | + else{
|
| 3036 | + first_wrerr_flag = 0;
|
| 3037 | +
|
| 3038 | + }
|
| 3039 | +
|
| 3040 | + }
|
| 3041 | + return 0;
|
| 3042 | +}
|
| 3043 | +
|
| 3044 | +
|
| 3045 | +static int vb_thread_create( const char *name,pthread_t *thread_t, vb_thread_proc *proc,
|
| 3046 | + int stack_size, unsigned priority,void *arg )
|
| 3047 | +{
|
| 3048 | + pthread_attr_t thread_attr;
|
| 3049 | + int ret;
|
| 3050 | + int default_size;
|
| 3051 | +
|
| 3052 | + struct sched_param param;
|
| 3053 | + int policy = SCHED_FIFO;
|
| 3054 | +
|
| 3055 | + printf("%s: start! \n",__func__);
|
| 3056 | +
|
| 3057 | + /* Init thread attributes */
|
| 3058 | + pthread_attr_init(&thread_attr);
|
| 3059 | + /* Create the thread. */
|
| 3060 | +
|
| 3061 | + ret = pthread_create( thread_t, &thread_attr,proc, arg);
|
| 3062 | + if (ret != 0)
|
| 3063 | + {
|
| 3064 | + printf("%s: pthread_create fail,ret=%d! \n",__func__,ret);
|
| 3065 | +
|
| 3066 | + pthread_attr_destroy(&thread_attr);
|
| 3067 | + return ret;
|
| 3068 | + }
|
| 3069 | +
|
| 3070 | + pthread_attr_getstacksize(&thread_attr, &default_size);
|
| 3071 | + printf("%s: pthread_attr_getstacksize(%d)! \n",__func__,default_size);
|
| 3072 | +
|
| 3073 | + pthread_attr_destroy(&thread_attr);
|
| 3074 | +
|
| 3075 | + printf("%s: end \n",__func__);
|
| 3076 | + return 0;
|
| 3077 | +}
|
| 3078 | +
|
| 3079 | +
|
| 3080 | +int voice_buffer_stream_test_stop(void);
|
| 3081 | +
|
| 3082 | +int voice_buffer_stream_test_start(int fs)
|
| 3083 | +{
|
| 3084 | + int ret = 0;
|
| 3085 | + int buf_size = 320;
|
| 3086 | + tx_optcount = 0;
|
| 3087 | + rx_optcount = 0;
|
| 3088 | + int* buf_int;
|
| 3089 | +
|
| 3090 | + int i;
|
| 3091 | +
|
| 3092 | + if(vbuffer_start_flag == 1){
|
| 3093 | + printf(" VB already start,return \n");
|
| 3094 | +
|
| 3095 | + return 0;
|
| 3096 | + }
|
| 3097 | +
|
| 3098 | + vbuffer_start_flag = 1;
|
| 3099 | +
|
| 3100 | +
|
| 3101 | +
|
| 3102 | + if((vbuf_rec.fd != -1)&&(vbuf_rec.fd != 0)){
|
| 3103 | + printf(" VB fd already get, vbuf_rec.fd=%d return \n",vbuf_rec.fd);
|
| 3104 | + }
|
| 3105 | +
|
| 3106 | + if(fs == 8000){
|
| 3107 | +
|
| 3108 | + buf_size = 320;
|
| 3109 | + }
|
| 3110 | + else if(fs == 16000){
|
| 3111 | +
|
| 3112 | + buf_size = 640;
|
| 3113 | + }
|
| 3114 | + else
|
| 3115 | + {
|
| 3116 | + buf_size = 320;
|
| 3117 | + }
|
| 3118 | + printf("Starting vb stream fs=%d buf_size=%d \n",fs,buf_size);
|
| 3119 | +
|
| 3120 | + printf("%s:open tx and rx file \n",__func__);
|
| 3121 | + if(fs == 8000){
|
| 3122 | +
|
| 3123 | + vbuf_rec.tx_filename = VBUFFER_TX_FILE_NAME;//"/cache/tx.pcm";
|
| 3124 | + vbuf_rec.rx_filename = VBUFFER_RX_FILE_NAME;//"/cache/rx.pcm";
|
| 3125 | +
|
| 3126 | + }
|
| 3127 | + else if(fs == 16000){
|
| 3128 | +
|
| 3129 | + vbuf_rec.tx_filename = VBUFFER_TX16_FILE_NAME;//"/cache/tx16.pcm";
|
| 3130 | + vbuf_rec.rx_filename = VBUFFER_RX16_FILE_NAME;//"/cache/rx16.pcm";
|
| 3131 | +
|
| 3132 | + }
|
| 3133 | + else
|
| 3134 | + {
|
| 3135 | + vbuf_rec.tx_filename = VBUFFER_TX_FILE_NAME;//"/cache/tx.pcm";
|
| 3136 | + vbuf_rec.rx_filename = VBUFFER_RX_FILE_NAME;//"/cache/rx.pcm";
|
| 3137 | +
|
| 3138 | + }
|
| 3139 | +
|
| 3140 | +
|
| 3141 | +
|
| 3142 | +
|
| 3143 | + vbuf_rec.tx_file = fopen(vbuf_rec.tx_filename , "rb");
|
| 3144 | + if (!vbuf_rec.tx_file) {
|
| 3145 | + printf("Unable to open file '%s'\n", vbuf_rec.tx_filename);
|
| 3146 | + //return -1;
|
| 3147 | + }
|
| 3148 | +
|
| 3149 | +
|
| 3150 | + vbuf_rec.rx_file = fopen(vbuf_rec.rx_filename, "wb");
|
| 3151 | + if (!vbuf_rec.rx_file) {
|
| 3152 | + printf(stderr, "Unable to create file '%s'\n", vbuf_rec.rx_filename);
|
| 3153 | + //fclose(vbuf_rec.tx_file);
|
| 3154 | +
|
| 3155 | + //return -1;
|
| 3156 | + }
|
| 3157 | + vbuf_rec.rx_filesize = RX_FILE_LEN_MAX;
|
| 3158 | + printf("%s : vbuf_rec.rx_filesize(%d) \n",__func__,vbuf_rec.rx_filesize);
|
| 3159 | +
|
| 3160 | + vbuf_rec.rx_buf = (char*) malloc(buf_size);
|
| 3161 | + if(!vbuf_rec.rx_buf) {
|
| 3162 | + printf("%s : malloc buf fail,return \n",__func__);
|
| 3163 | + goto err;
|
| 3164 | + }
|
| 3165 | + vbuf_rec.tx_buf = (char*) malloc(buf_size);
|
| 3166 | + if(!vbuf_rec.tx_buf) {
|
| 3167 | + free(vbuf_rec.rx_buf);
|
| 3168 | + printf("%s : malloc buf fail,return \n",__func__);
|
| 3169 | + vbuf_rec.rx_buf = NULL;
|
| 3170 | + goto err;
|
| 3171 | + }
|
| 3172 | + vbuf_rec.buf_size = buf_size;
|
| 3173 | +
|
| 3174 | + vbuf_rec.quit = 0;
|
| 3175 | +
|
| 3176 | + printf("%s : vb open start \n",__func__);
|
| 3177 | +
|
| 3178 | +
|
| 3179 | + vbuf_rec.fd = voice_buffer_open();
|
| 3180 | + if(vbuf_rec.fd <= 0){
|
| 3181 | + printf("%s : vb open fail fd=%d,return \n",__func__,vbuf_rec.fd);
|
| 3182 | + ret = -1;
|
| 3183 | + goto err;
|
| 3184 | +
|
| 3185 | + }
|
| 3186 | + printf("%s :voice_buffer_open end \n",__func__);
|
| 3187 | +
|
| 3188 | + printf("%s :rx tx vb_thread_create start \n",__func__);
|
| 3189 | + ret = vb_thread_create ("vb_playback_test",&vbuf_rec.rx_test_thread, vb_rx_test_thread_func,
|
| 3190 | + 4*1024,35,NULL);
|
| 3191 | + if (ret != 0)
|
| 3192 | + {
|
| 3193 | + printf("%s :rx vb_thread_create fail ret=%d,return \n",__func__,ret);
|
| 3194 | + vbuf_rec.rx_test_thread = NULL;
|
| 3195 | + goto err;
|
| 3196 | + }
|
| 3197 | +
|
| 3198 | + printf("%s :rx vb_thread_create end \n",__func__);
|
| 3199 | +
|
| 3200 | + ret = vb_thread_create ( "vbuf_record_test", &vbuf_rec.tx_test_thread, vb_tx_test_thread_func,
|
| 3201 | + 4*1024,35,NULL);
|
| 3202 | + if (ret != 0)
|
| 3203 | + {
|
| 3204 | +
|
| 3205 | + printf("%s :tx vb_thread_create fail ret=%d,return \n",__func__,ret);
|
| 3206 | + vbuf_rec.tx_test_thread = NULL;
|
| 3207 | + goto err;
|
| 3208 | + }
|
| 3209 | + printf("%s :tx vb_thread_create end \n",__func__);
|
| 3210 | +
|
| 3211 | + return 0;
|
| 3212 | +
|
| 3213 | +err:
|
| 3214 | + voice_buffer_stream_test_stop();
|
| 3215 | +
|
| 3216 | + return ret;
|
| 3217 | +}
|
| 3218 | +
|
| 3219 | +
|
| 3220 | +//Stop stream
|
| 3221 | +int voice_buffer_stream_test_stop(void)
|
| 3222 | +{
|
| 3223 | + int ret = 0;
|
| 3224 | + printf("%s:rx tx thread exit start \n",__func__);
|
| 3225 | + if(vbuf_rec.quit == 1) {
|
| 3226 | + printf("%s,already stop ,return\n",__func__);
|
| 3227 | +
|
| 3228 | + }
|
| 3229 | +
|
| 3230 | + vbuf_rec.quit = 1;
|
| 3231 | + voice_buffer_stop(vbuf_rec.fd);
|
| 3232 | + if (vbuf_rec.tx_test_thread)
|
| 3233 | + {
|
| 3234 | + pthread_join (vbuf_rec.tx_test_thread,NULL);
|
| 3235 | + vbuf_rec.tx_test_thread = NULL;
|
| 3236 | +
|
| 3237 | + }
|
| 3238 | +
|
| 3239 | + if (vbuf_rec.rx_test_thread)
|
| 3240 | + {
|
| 3241 | + pthread_join (vbuf_rec.rx_test_thread,NULL);
|
| 3242 | + vbuf_rec.rx_test_thread = NULL;
|
| 3243 | + }
|
| 3244 | +
|
| 3245 | + if(vbuf_rec.tx_file != NULL)
|
| 3246 | + {
|
| 3247 | + fclose(vbuf_rec.tx_file);
|
| 3248 | + printf("%s : vb close ,close tx file \n",__func__);
|
| 3249 | + vbuf_rec.tx_file = NULL;
|
| 3250 | + }
|
| 3251 | +
|
| 3252 | + if(vbuf_rec.rx_file != NULL)
|
| 3253 | + {
|
| 3254 | +
|
| 3255 | + fclose(vbuf_rec.rx_file);
|
| 3256 | + printf("%s : vb close ,close rx file \n",__func__);
|
| 3257 | + vbuf_rec.rx_file = NULL;
|
| 3258 | +
|
| 3259 | + }
|
| 3260 | +
|
| 3261 | + vb_close_fd_release_buf();
|
| 3262 | + return 0;
|
| 3263 | +}
|
| 3264 | +
|
| 3265 | +
|
| 3266 | +static int vb_loop_test_thread_func(void *arg)
|
| 3267 | +{
|
| 3268 | + int ret;
|
| 3269 | +
|
| 3270 | + char* buf = vbuf_rec.rx_buf;
|
| 3271 | + int size = vbuf_rec.buf_size;
|
| 3272 | +
|
| 3273 | + //char* buf = vbuf_rec.tx_buf;
|
| 3274 | +
|
| 3275 | + //int size = vbuf_rec.buf_size;
|
| 3276 | + int w_size;
|
| 3277 | + int r_size;
|
| 3278 | +
|
| 3279 | +
|
| 3280 | + printf( "%s: start size=%d! \n",__func__,size);
|
| 3281 | + memset (buf,0, size);
|
| 3282 | +
|
| 3283 | + while (!vbuf_rec.quit)
|
| 3284 | + {
|
| 3285 | + rx_optcount ++;
|
| 3286 | + VB_INT_OVERFLOW(rx_optcount);
|
| 3287 | + if((rx_optcount%1000) == 0){
|
| 3288 | + printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);
|
| 3289 | +
|
| 3290 | + }
|
| 3291 | + else if(rx_optcount == 1000000){
|
| 3292 | + printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);
|
| 3293 | + rx_optcount = 0;
|
| 3294 | +
|
| 3295 | + }
|
| 3296 | +
|
| 3297 | + //read form ps
|
| 3298 | + r_size = voice_buffer_read(vbuf_rec.fd, vbuf_rec.rx_buf, size);
|
| 3299 | + if(r_size <= 0)
|
| 3300 | + {
|
| 3301 | + first_rderr_flag++;
|
| 3302 | + VB_INT_OVERFLOW(first_rderr_flag);
|
| 3303 | + continue ;
|
| 3304 | + }
|
| 3305 | + else{
|
| 3306 | + first_rderr_flag = 0;
|
| 3307 | + }
|
| 3308 | + memcpy(vbuf_rec.tx_buf,vbuf_rec.rx_buf,size);
|
| 3309 | + w_size = voice_buffer_write(vbuf_rec.fd, vbuf_rec.tx_buf, size);
|
| 3310 | + if(w_size <= 0)
|
| 3311 | + {
|
| 3312 | + first_wrerr_flag++;
|
| 3313 | +
|
| 3314 | + VB_INT_OVERFLOW(first_wrerr_flag);
|
| 3315 | +
|
| 3316 | + continue;
|
| 3317 | + }
|
| 3318 | + else{
|
| 3319 | + first_wrerr_flag = 0;
|
| 3320 | + }
|
| 3321 | +
|
| 3322 | + }
|
| 3323 | +
|
| 3324 | + return 0;
|
| 3325 | +}
|
| 3326 | +
|
| 3327 | +
|
| 3328 | +int voice_buffer_stream_loop_test_stop(void);
|
| 3329 | +
|
| 3330 | +int voice_buffer_stream_loop_test_start(int fs)
|
| 3331 | +{
|
| 3332 | + int ret = -1;
|
| 3333 | + int buf_size = 320;
|
| 3334 | + tx_optcount = 0;
|
| 3335 | + rx_optcount = 0;
|
| 3336 | + int* buf_int;
|
| 3337 | +
|
| 3338 | + int i;
|
| 3339 | +
|
| 3340 | + if(vbuffer_start_flag == 1){
|
| 3341 | + printf(" VB already start,return \n");
|
| 3342 | +
|
| 3343 | + return 0;
|
| 3344 | + }
|
| 3345 | +
|
| 3346 | + if((vbuf_rec.fd != -1)&&(vbuf_rec.fd != 0)){
|
| 3347 | + printf(" VB fd already get, vbuf_rec.fd=%d return \n",vbuf_rec.fd);
|
| 3348 | + }
|
| 3349 | +
|
| 3350 | + vbuffer_start_flag = 1;
|
| 3351 | +
|
| 3352 | + if(fs == 8000){
|
| 3353 | +
|
| 3354 | + buf_size = 320;
|
| 3355 | + }
|
| 3356 | + else if(fs == 16000){
|
| 3357 | +
|
| 3358 | + buf_size = 640;
|
| 3359 | + }
|
| 3360 | + else
|
| 3361 | + {
|
| 3362 | + buf_size = 320;
|
| 3363 | + }
|
| 3364 | + printf("Starting vb stream fs=%d buf_size=%d \n",fs,buf_size);
|
| 3365 | +
|
| 3366 | + vbuf_rec.rx_buf = (char*) malloc(buf_size);
|
| 3367 | + if(!vbuf_rec.rx_buf) {
|
| 3368 | + printf("%s : malloc buf fail,return \n",__func__);
|
| 3369 | + goto err;
|
| 3370 | + }
|
| 3371 | + vbuf_rec.tx_buf = (char*) malloc(buf_size);
|
| 3372 | + if(!vbuf_rec.tx_buf) {
|
| 3373 | + printf("%s : malloc buf fail,return \n",__func__);
|
| 3374 | + goto err;
|
| 3375 | + }
|
| 3376 | + vbuf_rec.buf_size = buf_size;
|
| 3377 | +
|
| 3378 | + vbuf_rec.quit = 0;
|
| 3379 | +
|
| 3380 | + printf("%s : vb open start \n",__func__);
|
| 3381 | +
|
| 3382 | +
|
| 3383 | + vbuf_rec.fd = voice_buffer_open();
|
| 3384 | + if(vbuf_rec.fd <= 0){
|
| 3385 | + printf("%s : vb open fail fd=%d,return \n",__func__,vbuf_rec.fd);
|
| 3386 | + goto err;
|
| 3387 | +
|
| 3388 | + }
|
| 3389 | + printf("%s :loop vb_thread_create start \n",__func__);
|
| 3390 | + ret = vb_thread_create ("vb_playback_test",&vbuf_rec.loop_test_thread, vb_loop_test_thread_func,
|
| 3391 | + 4*1024,35,NULL);
|
| 3392 | + if (ret != 0)
|
| 3393 | + {
|
| 3394 | + printf("%s :rx vb_thread_create fail ret=%d,return \n",__func__,ret);
|
| 3395 | + goto err;
|
| 3396 | + }
|
| 3397 | +
|
| 3398 | + printf("%s :rx vb_thread_create end \n",__func__);
|
| 3399 | +
|
| 3400 | + return 0;
|
| 3401 | +
|
| 3402 | +err:
|
| 3403 | + voice_buffer_stream_loop_test_stop();
|
| 3404 | +
|
| 3405 | + return ret;
|
| 3406 | +}
|
| 3407 | +
|
| 3408 | +int voice_buffer_stream_loop_test_stop(void)
|
| 3409 | +{
|
| 3410 | + int ret = 0;
|
| 3411 | + printf("%s:loop thread exit start \n",__func__);
|
| 3412 | + if(vbuf_rec.quit == 1) {
|
| 3413 | + printf("%s,already stop ,return\n",__func__);
|
| 3414 | +
|
| 3415 | + }
|
| 3416 | +
|
| 3417 | + vbuf_rec.quit = 1;
|
| 3418 | + voice_buffer_stop(vbuf_rec.fd);
|
| 3419 | + if (vbuf_rec.loop_test_thread)
|
| 3420 | + {
|
| 3421 | + pthread_join (vbuf_rec.loop_test_thread,NULL);
|
| 3422 | + vbuf_rec.tx_test_thread = NULL;
|
| 3423 | +
|
| 3424 | + }
|
| 3425 | +
|
| 3426 | + vb_close_fd_release_buf();
|
| 3427 | + return 0;
|
| 3428 | +}
|
| 3429 | +
|
| 3430 | +int voice_buffer_rtp_test_start(int fs)
|
| 3431 | +{
|
| 3432 | + // refer to voice_buffer_stream_test_start(fs);
|
| 3433 | + return 0;
|
| 3434 | +}
|
| 3435 | +
|
| 3436 | +
|
| 3437 | +
|
| 3438 | +int voice_buffer_rtp_test_stop(void)
|
| 3439 | +{
|
| 3440 | +// refer to voice_buffer_stream_loop_test_stop();
|
| 3441 | + return 0;
|
| 3442 | +
|
| 3443 | +}
|
| 3444 | +
|
| 3445 | +void voice_buffer_cmd_proc(char *cmdstr)
|
| 3446 | +{
|
| 3447 | + int ret = 0;
|
| 3448 | + char data[VOICE_CMD_MAX_LEN];
|
| 3449 | + int cmdstr_len = strlen(cmdstr); //-strlen("\r")
|
| 3450 | + int value = 0;
|
| 3451 | + int *p_value = &value;
|
| 3452 | +
|
| 3453 | + cmdstr[cmdstr_len] = '\0'; //+strlen("\0")
|
| 3454 | +
|
| 3455 | + ret = sscanf(cmdstr, "%s", data);
|
| 3456 | + if(1 != ret){
|
| 3457 | + printf("data sscanf failed!(%d)\n", ret);
|
| 3458 | + return;
|
| 3459 | + }
|
| 3460 | + if(0 == strncmp(data, REQ_VOICE_BUFFER_TEST_START, strlen(REQ_VOICE_BUFFER_TEST_START))){
|
| 3461 | +
|
| 3462 | + ret = sscanf(cmdstr, "%*s %d", &value);
|
| 3463 | + if(1 != ret){
|
| 3464 | + printf("%s,value sscanf failed!(%d)\n",data, ret);
|
| 3465 | + return;
|
| 3466 | + }
|
| 3467 | +
|
| 3468 | + printf("%s set value %d\n", data, value);
|
| 3469 | + ret = voice_buffer_stream_test_start(value);
|
| 3470 | +
|
| 3471 | + printf("%s return ret=%d\n", data, ret);
|
| 3472 | +
|
| 3473 | + }
|
| 3474 | + else if(0 == strncmp(data, REQ_VOICE_BUFFER_TEST_STOP, strlen(REQ_VOICE_BUFFER_TEST_STOP))){
|
| 3475 | + ret = voice_buffer_stream_test_stop();
|
| 3476 | + printf("%s return %d\n", data, ret);
|
| 3477 | + }
|
| 3478 | + else if(0 == strncmp(data, REQ_VOICE_BUFFER_LOOP_TEST_START, strlen(REQ_VOICE_BUFFER_LOOP_TEST_START))){
|
| 3479 | +
|
| 3480 | + ret = sscanf(cmdstr, "%*s %d", &value);
|
| 3481 | + if(1 != ret){
|
| 3482 | + printf("%s,value sscanf failed!(%d)\n",data, ret);
|
| 3483 | + return;
|
| 3484 | + }
|
| 3485 | +
|
| 3486 | + printf("%s set value %d\n", data, value);
|
| 3487 | + ret = voice_buffer_stream_loop_test_start(value);
|
| 3488 | +
|
| 3489 | + printf("%s return ret=%d\n", data, ret);
|
| 3490 | +
|
| 3491 | + }
|
| 3492 | + else if(0 == strncmp(data, REQ_VOICE_BUFFER_LOOP_TEST_STOP, strlen(REQ_VOICE_BUFFER_LOOP_TEST_STOP))){
|
| 3493 | + printf("voice_buffer_stream_loop_test_stop \n");
|
| 3494 | + ret = voice_buffer_stream_loop_test_stop();
|
| 3495 | + printf("%s return %d\n", data, ret);
|
| 3496 | + }
|
| 3497 | + else if(0 == strncmp(data, REQ_VOICE_BUFFER_RTP_TEST_START, strlen(REQ_VOICE_BUFFER_RTP_TEST_START))){
|
| 3498 | +
|
| 3499 | + ret = sscanf(cmdstr, "%*s %d", &value);
|
| 3500 | + if(1 != ret){
|
| 3501 | + printf("%s,value sscanf failed!(%d)\n",data, ret);
|
| 3502 | + return;
|
| 3503 | + }
|
| 3504 | +
|
| 3505 | + printf("%s set value %d\n", data, value);
|
| 3506 | + ret = voice_buffer_rtp_test_start(value);
|
| 3507 | +
|
| 3508 | + printf("%s return ret=%d\n", data, ret);
|
| 3509 | +
|
| 3510 | + }
|
| 3511 | + else if(0 == strncmp(data, REQ_VOICE_BUFFER_RTP_TEST_STOP, strlen(REQ_VOICE_BUFFER_RTP_TEST_STOP))){
|
| 3512 | + ret = voice_buffer_rtp_test_stop();
|
| 3513 | + printf("%s return %d\n", data, ret);
|
| 3514 | + }
|
| 3515 | + else{
|
| 3516 | + printf("Request unknow.\n");
|
| 3517 | + printUsage(cmdstr);
|
| 3518 | + }
|
| 3519 | +}
|
| 3520 | +
|
| 3521 | +void vb_buffer_stop_all()
|
| 3522 | +{
|
| 3523 | + voice_buffer_stream_loop_test_stop();
|
| 3524 | + voice_buffer_stream_test_stop();
|
| 3525 | + voice_buffer_rtp_test_stop();
|
| 3526 | +}
|
| 3527 | +
|
| 3528 | +void signal_handle_func(int sig)
|
| 3529 | +{
|
| 3530 | + printf("sig(%d) signal_handle_func exit ",sig);
|
| 3531 | +
|
| 3532 | + vb_buffer_stop_all();
|
| 3533 | + exit(0);
|
| 3534 | +}
|
| 3535 | +
|
| 3536 | +int main(int argc, char **argv)
|
| 3537 | +{
|
| 3538 | + char cmdstr[VOICE_CMD_MAX_LEN];
|
| 3539 | +
|
| 3540 | + signal(SIGINT, signal_handle_func);
|
| 3541 | + signal(SIGQUIT, signal_handle_func);
|
| 3542 | + signal(SIGTERM, signal_handle_func);
|
| 3543 | + signal(SIGPIPE, signal_handle_func);
|
| 3544 | +
|
| 3545 | + memset(&vbuf_rec,0,sizeof(vbuf_rec));
|
| 3546 | +#if 0
|
| 3547 | + /*add by hq for faster start @20240906,begin*/
|
| 3548 | + if(argc>1)
|
| 3549 | + {
|
| 3550 | + voice_buffer_cmd_proc(argv[1]);
|
| 3551 | + }
|
| 3552 | + /*add by hq for faster start @20240906,end*/
|
| 3553 | + else
|
| 3554 | + {
|
| 3555 | +#endif
|
| 3556 | + while(1){
|
| 3557 | + printf("Please input an voice_demo command:\n");
|
| 3558 | + if(NULL != fgets(cmdstr, VOICE_CMD_MAX_LEN - 1, stdin)){
|
| 3559 | + if(0 == strcmp(EXIT_CMD_STOP, cmdstr) ||
|
| 3560 | + 0 == strcmp(EXIT_CMD_Q, cmdstr) ||
|
| 3561 | + 0 == strcmp(EXIT_CMD_EXIT, cmdstr)){
|
| 3562 | + vb_buffer_stop_all();
|
| 3563 | + break;
|
| 3564 | + }
|
| 3565 | +
|
| 3566 | + printf("len:%d, cmdstr:%s\n", strlen(cmdstr), cmdstr);
|
| 3567 | +
|
| 3568 | + if(1 >= strlen(cmdstr)){
|
| 3569 | + continue;
|
| 3570 | + }
|
| 3571 | + voice_buffer_cmd_proc(cmdstr);
|
| 3572 | + }
|
| 3573 | + }
|
| 3574 | +// }
|
| 3575 | +
|
| 3576 | + printf("voice_demo end\n");
|
| 3577 | +
|
| 3578 | + return 0;
|
| 3579 | +}
|
| 3580 | +
|
| 3581 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile |
| 3582 | new file mode 100755 |
| 3583 | index 0000000..6a6f960 |
| 3584 | --- /dev/null |
| 3585 | +++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile |
| 3586 | @@ -0,0 +1,47 @@ |
| 3587 | +SHELL = /bin/sh |
| 3588 | +RM = rm -f |
| 3589 | + |
| 3590 | +LOCAL_CFLAGS := -Wall \ |
| 3591 | + -g -Os \ |
| 3592 | + -flto \ |
| 3593 | + -fpermissive \ |
| 3594 | + -fPIC \ |
| 3595 | + |
| 3596 | +ifeq ($(strip $(TARGET_PLATFORM)), T106) |
| 3597 | +LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0 |
| 3598 | +endif |
| 3599 | + |
| 3600 | +LOCAL_CFLAGS += -Werror=implicit-function-declaration |
| 3601 | + |
| 3602 | +$(warning ################# rock ROOT: $(ROOT),includedir:$(includedir),) |
| 3603 | + |
| 3604 | +LOCAL_PATH = . |
| 3605 | + |
| 3606 | +LOCAL_C_INCLUDES = \ |
| 3607 | + -I. \ |
| 3608 | + -I$(ROOT)$(includedir)/ \ |
| 3609 | + |
| 3610 | + |
| 3611 | + |
| 3612 | +LOCAL_LIBS := \ |
| 3613 | + -L. \ |
| 3614 | + -ldl \ |
| 3615 | + -lpthread \ |
| 3616 | + -lvoice \ |
| 3617 | + |
| 3618 | +SOURCES = $(wildcard *.c) |
| 3619 | + |
| 3620 | +EXECUTABLE = lynq_vb_demo |
| 3621 | + |
| 3622 | +OBJECTS=$(SOURCES:.c=.o) |
| 3623 | +all: $(EXECUTABLE) |
| 3624 | + |
| 3625 | +$(EXECUTABLE): $(OBJECTS) |
| 3626 | + $(CC) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@ |
| 3627 | + |
| 3628 | +%.o : %.c |
| 3629 | + $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $< |
| 3630 | + |
| 3631 | +.PHONY: clean |
| 3632 | +clean: |
| 3633 | + $(RM) $(OBJECTS) $(EXECUTABLE) |
| 3634 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb |
| 3635 | new file mode 100755 |
| 3636 | index 0000000..b01d3b0 |
| 3637 | --- /dev/null |
| 3638 | +++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb |
| 3639 | @@ -0,0 +1,29 @@ |
| 3640 | +#inherit externalsrc package |
| 3641 | + |
| 3642 | +DESCRIPTION = "lynq-vb-demo" |
| 3643 | +LICENSE = "CLOSED" |
| 3644 | +LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff" |
| 3645 | +DEPENDS += "libvoice" |
| 3646 | +SRC_URI = "file://lynq_vb_demo.c \ |
| 3647 | + file://makefile \ |
| 3648 | +" |
| 3649 | + |
| 3650 | +SRC-DIR = "${S}/../lynq-vb-demo" |
| 3651 | +FILES_${PN} += "${bindir}/" |
| 3652 | +TARGET_CC_ARCH += "${LDFLAGS}" |
| 3653 | + |
| 3654 | +S = "${WORKDIR}" |
| 3655 | + |
| 3656 | +#INHIBIT_PACKAGE_STRIP = "1" |
| 3657 | +do_compile () { |
| 3658 | + if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then |
| 3659 | + oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float" |
| 3660 | + else |
| 3661 | + oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}" |
| 3662 | + fi |
| 3663 | +} |
| 3664 | + |
| 3665 | +do_install() { |
| 3666 | + install -d ${D}${bindir}/ |
| 3667 | + install -m 0755 ${S}/lynq_vb_demo ${D}${bindir}/ |
| 3668 | +} |
| 3669 | diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp |
| 3670 | index 445f51f..2264f5b 100755 |
| 3671 | --- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp |
| 3672 | +++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp |
| 3673 | @@ -211,6 +211,10 @@ |
| 3674 | printf("wakelock create fail\n"); |
| 3675 | printf("wifi_lock_num=%d\n", wifi_lock_num); |
| 3676 | } |
| 3677 | + if (type == LYNQ_WIFI_AP_INDEX_AP0) |
| 3678 | + qser_wifi_work_mode_set(LYNQ_WIFI_WORK_MODE_AP0); // Set 2.4G, and this function must be called after the qser_wifi_enable function |
| 3679 | + else |
| 3680 | + qser_wifi_work_mode_set(LYNQ_WIFI_WORK_MODE_AP1); // Set 5G, and this function must be called after the qser_wifi_enable function |
| 3681 | qser_wifi_ap_start(type); // Set the ap mode of 2.4G/5G |
| 3682 | qser_wifi_register_handle(lynq_wifi_event_handle_demo, NULL, (void *)&args); |
| 3683 | ret = qser_wakelock_lock(wifi_lock_num); |
| 3684 | @@ -220,6 +224,8 @@ |
| 3685 | printf("ret=%d\n", ret); |
| 3686 | } |
| 3687 | signal(SIGINT, signalHandler); |
| 3688 | + signal(SIGHUP, signalHandler); |
| 3689 | + signal(SIGTERM, signalHandler); |
| 3690 | while (1) |
| 3691 | { |
| 3692 | char cmdstr[128] = {0}; |
| 3693 | @@ -277,6 +283,8 @@ |
| 3694 | printf("ret=%d\n", ret); |
| 3695 | } |
| 3696 | signal(SIGINT, signalHandler); |
| 3697 | + signal(SIGHUP, signalHandler); |
| 3698 | + signal(SIGTERM, signalHandler); |
| 3699 | while (1) |
| 3700 | { |
| 3701 | printf("[lynq-wifi-demo]Enter the ssid and password as shown in the following example:ssid auth paris pw ||sta_pkt_get ||sta_param_get || sta_scan ||sta_stop\n"); |
| 3702 | diff --git a/esdk/layers/meta-zxic-selinux/recipes-security/refpolicy/files/policy-mls/policy/modules/system/locallogin.te b/esdk/layers/meta-zxic-selinux/recipes-security/refpolicy/files/policy-mls/policy/modules/system/locallogin.te |
| 3703 | index 103c0ef..5e63bbf 100755 |
| 3704 | --- a/esdk/layers/meta-zxic-selinux/recipes-security/refpolicy/files/policy-mls/policy/modules/system/locallogin.te |
| 3705 | +++ b/esdk/layers/meta-zxic-selinux/recipes-security/refpolicy/files/policy-mls/policy/modules/system/locallogin.te |
| 3706 | @@ -55,6 +55,9 @@ |
| 3707 | allow local_login_t local_login_tmp_t:file manage_file_perms; |
| 3708 | files_tmp_filetrans(local_login_t, local_login_tmp_t, { file dir }) |
| 3709 | |
| 3710 | +allow local_login_t unreserved_port_t:tcp_socket { name_connect }; |
| 3711 | +allow local_login_t unreserved_port_t:udp_socket { name_bind }; |
| 3712 | + |
| 3713 | kernel_read_system_state(local_login_t) |
| 3714 | kernel_read_kernel_sysctls(local_login_t) |
| 3715 | kernel_search_key(local_login_t) |
| 3716 | diff --git a/esdk/layers/meta-zxic/recipes-app/at-ctl/at-ctl.bb b/esdk/layers/meta-zxic/recipes-app/at-ctl/at-ctl.bb |
| 3717 | index 12ea54b..b9dd751 100755 |
| 3718 | --- a/esdk/layers/meta-zxic/recipes-app/at-ctl/at-ctl.bb |
| 3719 | +++ b/esdk/layers/meta-zxic/recipes-app/at-ctl/at-ctl.bb |
| 3720 | @@ -1,5 +1,5 @@ |
| 3721 | DESCRIPTION = "at_ctl" |
| 3722 | -DEPENDS = "libnvram libsoftap libsofttimer libatutils sqlcipher libatext libmxml libtelsvr libsd-daemon" |
| 3723 | +DEPENDS = "libdebug-info libnvram libsoftap libsofttimer libatutils sqlcipher libatext libmxml libtelsvr libsd-daemon" |
| 3724 | SECTION = "app" |
| 3725 | LICENSE = "zte" |
| 3726 | PV = "1.0.0" |
| 3727 | @@ -14,6 +14,7 @@ |
| 3728 | |
| 3729 | DEPENDS += " \ |
| 3730 | ${@bb.utils.contains('DISTRO_FEATURES', 'volte', 'libvoice', '', d)} \ |
| 3731 | + ${@bb.utils.contains('DISTRO_FEATURES', 'use_voice_buffer', 'libvoice', '', d)} \ |
| 3732 | " |
| 3733 | |
| 3734 | #é
ç½®codeè·¯å¾ä¿¡æ¯ã |
| 3735 | @@ -34,13 +35,16 @@ |
| 3736 | include ${BSPDIR}/sources/meta-zxic/conf/pub.inc |
| 3737 | CFLAGS_append = "-I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/src/phone/inc" |
| 3738 | CFLAGS_append += "${ZXIC_EXTRA_CFLAGS}" |
| 3739 | +LIBS_append += "${@bb.utils.contains('DISTRO_FEATURES', 'volte', '-lvoice', '', d)}" |
| 3740 | +LIBS_append += "${@bb.utils.contains('DISTRO_FEATURES', 'use_voice_buffer', '-lvoice', '', d)}" |
| 3741 | LDLIBS_EXT = "${@bb.utils.contains('DISTRO_FEATURES', 'volte', '-lvoice', '', d)}" |
| 3742 | +LDLIBS_EXT += "${@bb.utils.contains('DISTRO_FEATURES', 'use_voice_buffer', '-lvoice', '', d)}" |
| 3743 | #include at-ctl.inc |
| 3744 | |
| 3745 | #inherit autotools pkgconfig systemd |
| 3746 | |
| 3747 | do_compile() { |
| 3748 | - make -C ${S_SRC_PATH} LDLIBS_EXT=${LDLIBS_EXT} |
| 3749 | + make -C ${S_SRC_PATH} LDLIBS_EXT="${LDLIBS_EXT}" |
| 3750 | } |
| 3751 | |
| 3752 | do_install () { |
| 3753 | @@ -87,4 +91,4 @@ |
| 3754 | SYSTEMD_SERVICE_${PN} = "at_ctl.service" |
| 3755 | SYSTEMD_AUTO_ENABLE_${PN} = "enable" |
| 3756 | |
| 3757 | -RDEPENDS_${PN} = " libnvram libsoftap libsofttimer libatutils sqlcipher libatext libmxml libvoice libsd-daemon" |
| 3758 | +RDEPENDS_${PN} = " libdebug-info libnvram libsoftap libsofttimer libatutils sqlcipher libatext libmxml libvoice libsd-daemon" |
| 3759 | diff --git a/esdk/layers/meta-zxic/recipes-app/libatext/libatext.bb b/esdk/layers/meta-zxic/recipes-app/libatext/libatext.bb |
| 3760 | index 0f5dcee..77066ff 100755 |
| 3761 | --- a/esdk/layers/meta-zxic/recipes-app/libatext/libatext.bb |
| 3762 | +++ b/esdk/layers/meta-zxic/recipes-app/libatext/libatext.bb |
| 3763 | @@ -1,4 +1,5 @@ |
| 3764 | DESCRIPTION = "libatext" |
| 3765 | +DEPENDS = "libvoice " |
| 3766 | SECTION = "lib" |
| 3767 | LICENSE = "zte" |
| 3768 | PV = "1.0.0" |
| 3769 | @@ -14,6 +15,7 @@ |
| 3770 | DEPENDS = "libatutils libnvram" |
| 3771 | DEPENDS += " \ |
| 3772 | ${@bb.utils.contains('DISTRO_FEATURES', 'volte', 'libvoice', '', d)} \ |
| 3773 | + ${@bb.utils.contains('DISTRO_FEATURES', 'use_voice_buffer', 'libvoice', '', d)} \ |
| 3774 | " |
| 3775 | |
| 3776 | S = "${WORKDIR}" |
| 3777 | @@ -23,10 +25,13 @@ |
| 3778 | CFLAGS_append = "-I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/platform/at_ctl/inc" |
| 3779 | CFLAGS_append += "${ZXIC_EXTRA_CFLAGS}" |
| 3780 | LIBS_append += "${@bb.utils.contains('DISTRO_FEATURES', 'volte', '-lvoice', '', d)}" |
| 3781 | +LIBS_append += "${@bb.utils.contains('DISTRO_FEATURES', 'use_voice_buffer', '-lvoice', '', d)}" |
| 3782 | +LDLIBS_EXT = "${@bb.utils.contains('DISTRO_FEATURES', 'volte', '-lvoice', '', d)}" |
| 3783 | +LDLIBS_EXT += "${@bb.utils.contains('DISTRO_FEATURES', 'use_voice_buffer', '-lvoice', '', d)}" |
| 3784 | #include atext.inc |
| 3785 | |
| 3786 | do_compile () { |
| 3787 | - make -C libatext |
| 3788 | + make -C libatext LDLIBS_EXT="${LDLIBS_EXT}" |
| 3789 | } |
| 3790 | |
| 3791 | do_install () { |
| 3792 | diff --git a/esdk/layers/meta-zxic/recipes-app/libreference-ril/libreference-ril.bb b/esdk/layers/meta-zxic/recipes-app/libreference-ril/libreference-ril.bb |
| 3793 | index d5a5367..5b56ebf 100755 |
| 3794 | --- a/esdk/layers/meta-zxic/recipes-app/libreference-ril/libreference-ril.bb |
| 3795 | +++ b/esdk/layers/meta-zxic/recipes-app/libreference-ril/libreference-ril.bb |
| 3796 | @@ -18,7 +18,7 @@ |
| 3797 | |
| 3798 | #ç¼è¯ |
| 3799 | do_compile () { |
| 3800 | - make -C ril/reference-ril |
| 3801 | + make -C ril/reference-ril CONFIG_USE_NEW_SIGNAL_STRENGTH=${CONFIG_USE_NEW_SIGNAL_STRENGTH} |
| 3802 | } |
| 3803 | |
| 3804 | #åºå头æä»¶çå®è£
|
| 3805 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/Makefile b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/Makefile |
| 3806 | new file mode 100755 |
| 3807 | index 0000000..c4f4780 |
| 3808 | --- /dev/null |
| 3809 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/Makefile |
| 3810 | @@ -0,0 +1,126 @@ |
| 3811 | +# /*****************************************************************************
|
| 3812 | +#* °æÈ¨ËùÓÐ (C)2015, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
|
| 3813 | +#*
|
| 3814 | +#* ÎļþÃû³Æ: Makefile
|
| 3815 | +#* Îļþ±êʶ: Makefile
|
| 3816 | +#* ÄÚÈÝÕªÒª: Makefile of ZTE librarys
|
| 3817 | +#* ʹÓ÷½·¨: void
|
| 3818 | +#*
|
| 3819 | +#* ÐÞ¸ÄÈÕÆÚ °æ±¾ºÅ Ð޸ıê¼Ç ÐÞ¸ÄÈË ÐÞ¸ÄÄÚÈÝ
|
| 3820 | +#* -----------------------------------------------------------------------------
|
| 3821 | +#* 2018/01/15 V1.0 Create chentianming ´´½¨
|
| 3822 | +#*
|
| 3823 | +# ******************************************************************************/
|
| 3824 | +
|
| 3825 | +#*******************************************************************************
|
| 3826 | +# include ZTE library makefile
|
| 3827 | +#*******************************************************************************
|
| 3828 | +include $(COMMON_MK)
|
| 3829 | +
|
| 3830 | +
|
| 3831 | +#*******************************************************************************
|
| 3832 | +# library
|
| 3833 | +#*******************************************************************************
|
| 3834 | +LIB_SHARED = libtinyalsa.so
|
| 3835 | +LIB_STATIC = libtinyalsa.a
|
| 3836 | +
|
| 3837 | +OBJS = mixer.o pcm.o audio_mixer_ctrl.o
|
| 3838 | +CFLAGS += -g
|
| 3839 | +LDFLAGS += -lpthread
|
| 3840 | +
|
| 3841 | +##############USER COMIZE END##################
|
| 3842 | +
|
| 3843 | +CFLAGS += -I$(zte_lib_path)/libtinyalsa/include
|
| 3844 | +CFLAGS += -I$(STAGEDIR)/include
|
| 3845 | +CFLAGS += -I$(APP_DIR)/include
|
| 3846 | +CFLAGS += -fPIC
|
| 3847 | +
|
| 3848 | +LDFLAGS_SHARED += -shared
|
| 3849 | +
|
| 3850 | +
|
| 3851 | +#*******************************************************************************
|
| 3852 | +# comp test app and
|
| 3853 | +#*******************************************************************************
|
| 3854 | +EXEC_tinyplay = tinyplay
|
| 3855 | +EXEC_tinycap = tinycap
|
| 3856 | +EXEC_tinymix = tinymix
|
| 3857 | +EXEC_tinypcminfo = tinyinfo
|
| 3858 | +EXEC_alsatest = alsatest
|
| 3859 | +
|
| 3860 | +#*******************************************************************************
|
| 3861 | +# objects
|
| 3862 | +#*******************************************************************************
|
| 3863 | +tinyplay_OBJECTS += mixer.o pcm.o tinyplay.o
|
| 3864 | +tinycap_OBJECTS += mixer.o pcm.o tinycap.o
|
| 3865 | +tinymix_OBJECTS += mixer.o pcm.o tinymix.o
|
| 3866 | +tinypcminfo_OBJECTS += mixer.o pcm.o tinypcminfo.o
|
| 3867 | +alsatest_OBJECTS += mixer.o pcm.o alsatest.o
|
| 3868 | +
|
| 3869 | +#########################for linux######################################
|
| 3870 | +
|
| 3871 | +ifeq ($(V3PHONE_TYPE), K318)
|
| 3872 | + CFLAGS += -D_USE_7520V3_PHONE_TYPE_K318
|
| 3873 | +endif
|
| 3874 | +ifeq ($(V3PHONE_TYPE), C31F)
|
| 3875 | + CFLAGS += -D_USE_7520V3_PHONE_TYPE_C31F
|
| 3876 | +endif
|
| 3877 | +ifeq ($(V3PHONE_TYPE), XRSD)
|
| 3878 | + CFLAGS += -D_USE_7520V3_PHONE_TYPE_XRSD
|
| 3879 | +endif
|
| 3880 | +ifeq ($(V3PHONE_TYPE), FWP)
|
| 3881 | + CFLAGS += -D_USE_7520V3_PHONE_TYPE_FWP
|
| 3882 | +endif
|
| 3883 | +ifeq ($(V3PHONE_TYPE), WTWD)
|
| 3884 | + CFLAGS += -D_USE_7520V3_PHONE_TYPE_WTWD
|
| 3885 | +endif
|
| 3886 | +
|
| 3887 | +
|
| 3888 | +CFLAGS += -I./include/
|
| 3889 | +CFLAGS += -g -Werror=implicit-function-declaration
|
| 3890 | +#CFLAGS += -D_USE_CODEC_TI3100
|
| 3891 | +SHAREDFLAG := -shared -lc
|
| 3892 | +#LDLIBS += -L$(LIB_DIR)/libtinyalsa
|
| 3893 | +#LDLIBS += -ltinyalsa
|
| 3894 | +
|
| 3895 | +all: $(LIB_STATIC) $(LIB_SHARED) $(EXEC_tinyplay) $(EXEC_tinycap) $(EXEC_tinymix) $(EXEC_tinypcminfo)
|
| 3896 | +
|
| 3897 | +$(LIB_STATIC) : $(OBJS)
|
| 3898 | + $(AR) rcs $(LIB_STATIC) $(OBJS)
|
| 3899 | +
|
| 3900 | +$(LIB_SHARED): $(OBJS)
|
| 3901 | + $(CC) $(LDFLAGS) $(LDFLAGS_SHARED) -o $@ $^
|
| 3902 | +
|
| 3903 | +
|
| 3904 | +$(EXEC_tinyplay): $(tinyplay_OBJECTS)
|
| 3905 | + $(CC) $(LDFLAGS) -o $@ $(tinyplay_OBJECTS) -Wl,--start-group $(LDLIBS) -Wl,--end-group
|
| 3906 | +$(EXEC_tinycap): $(tinycap_OBJECTS)
|
| 3907 | + $(CC) $(LDFLAGS) -o $@ $(tinycap_OBJECTS) -Wl,--start-group $(LDLIBS) -Wl,--end-group
|
| 3908 | +$(EXEC_tinymix): $(tinymix_OBJECTS)
|
| 3909 | + $(CC) $(LDFLAGS) -o $@ $(tinymix_OBJECTS) -Wl,--start-group $(LDLIBS) -Wl,--end-group
|
| 3910 | +$(EXEC_tinypcminfo): $(tinypcminfo_OBJECTS)
|
| 3911 | + $(CC) $(LDFLAGS) -o $@ $(tinypcminfo_OBJECTS) -Wl,--start-group $(LDLIBS) -Wl,--end-group
|
| 3912 | +#$(EXEC_alsatest): $(alsatest_OBJECTS)
|
| 3913 | +# $(CC) $(LDFLAGS) -o $@ $(alsatest_OBJECTS) -Wl,--start-group $(LDLIBS) -Wl,--end-group
|
| 3914 | +
|
| 3915 | +clean:
|
| 3916 | + rm -f $(tinyplay_OBJECTS) $(tinycap_OBJECTS) $(tinymix_OBJECTS) $(tinypcminfo_OBJECTS) $(lib_OBJECTS) $(LIB_SHARED) $(LIB_STATIC) $(EXEC_tinyplay) $(EXEC_tinycap) $(EXEC_tinymix) $(EXEC_tinypcminfo) $(EXEC_alsatest) *.elf *.gdb *.o core
|
| 3917 | +
|
| 3918 | +romfs:
|
| 3919 | + $(ROMFSINST) $(LIB_SHARED) /lib/$(LIB_SHARED)
|
| 3920 | + $(ROMFSINST) $(EXEC_tinyplay) /bin/$(EXEC_tinyplay)
|
| 3921 | + $(ROMFSINST) $(EXEC_tinycap) /bin/$(EXEC_tinycap)
|
| 3922 | + $(ROMFSINST) $(EXEC_tinymix) /bin/$(EXEC_tinymix)
|
| 3923 | + # $(ROMFSINST) $(EXEC_tinypcminfo) /bin/$(EXEC_tinypcminfo)
|
| 3924 | + cp -v $(EXEC_tinyplay) $(APP_DIR)/test_tools/
|
| 3925 | + cp -v $(EXEC_tinycap) $(APP_DIR)/test_tools/
|
| 3926 | + cp -v $(EXEC_tinymix) $(APP_DIR)/test_tools/
|
| 3927 | + cp -v $(EXEC_tinypcminfo) $(APP_DIR)/test_tools/
|
| 3928 | +# $(ROMFSINST) $(EXEC_alsatest) /bin/$(EXEC_alsatest)
|
| 3929 | +
|
| 3930 | +
|
| 3931 | +# cp $(EXEC_tinyplay) $(EXEC_tinyplay).elf
|
| 3932 | +# cp $(EXEC_tinycap) $(EXEC_tinycap).elf
|
| 3933 | +
|
| 3934 | +# cp $(EXEC_tinymix) $(EXEC_tinymix).elf
|
| 3935 | +# cp $(EXEC_tinypcminfo) $(EXEC_tinypcminfo).elf
|
| 3936 | +# cp $(EXEC_alsatest) $(EXEC_alsatest).elf
|
| 3937 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/alsatest.c b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/alsatest.c |
| 3938 | new file mode 100755 |
| 3939 | index 0000000..e599fff |
| 3940 | --- /dev/null |
| 3941 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/alsatest.c |
| 3942 | @@ -0,0 +1,764 @@ |
| 3943 | +#include <stdio.h> |
| 3944 | +#include <unistd.h> |
| 3945 | +#include <string.h> |
| 3946 | +//#include <stdlib.h> |
| 3947 | +//#include "pthread.h" |
| 3948 | +//#include "alsatest.h" |
| 3949 | +//#include <stdbool.h> |
| 3950 | +#include <fcntl.h> |
| 3951 | +#include <signal.h> |
| 3952 | +#include <tinyalsa/asoundlib.h> |
| 3953 | +#include <sound/asound.h> |
| 3954 | +#include <stdint.h> |
| 3955 | +#include <stdbool.h> |
| 3956 | +#include <errno.h> |
| 3957 | +#include <stdlib.h> |
| 3958 | +#include <ctype.h> |
| 3959 | + |
| 3960 | +#define ID_RIFF 0x46464952 |
| 3961 | +#define ID_WAVE 0x45564157 |
| 3962 | +#define ID_FMT 0x20746d66 |
| 3963 | +#define ID_DATA 0x61746164 |
| 3964 | + |
| 3965 | +#define FORMAT_PCM 1 |
| 3966 | +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) |
| 3967 | + |
| 3968 | + |
| 3969 | +struct riff_wave_header { |
| 3970 | + uint32_t riff_id; |
| 3971 | + uint32_t riff_sz; |
| 3972 | + uint32_t wave_id; |
| 3973 | +}; |
| 3974 | + |
| 3975 | +struct chunk_header { |
| 3976 | + uint32_t id; |
| 3977 | + uint32_t sz; |
| 3978 | +}; |
| 3979 | + |
| 3980 | +struct chunk_fmt { |
| 3981 | + uint16_t audio_format; |
| 3982 | + uint16_t num_channels; |
| 3983 | + uint32_t sample_rate; |
| 3984 | + uint32_t byte_rate; |
| 3985 | + uint16_t block_align; |
| 3986 | + uint16_t bits_per_sample; |
| 3987 | +}; |
| 3988 | +struct wav_header { |
| 3989 | + uint32_t riff_id; |
| 3990 | + uint32_t riff_sz; |
| 3991 | + uint32_t riff_fmt; |
| 3992 | + uint32_t fmt_id; |
| 3993 | + uint32_t fmt_sz; |
| 3994 | + uint16_t audio_format; |
| 3995 | + uint16_t num_channels; |
| 3996 | + uint32_t sample_rate; |
| 3997 | + uint32_t byte_rate; |
| 3998 | + uint16_t block_align; |
| 3999 | + uint16_t bits_per_sample; |
| 4000 | + uint32_t data_id; |
| 4001 | + uint32_t data_sz; |
| 4002 | +}; |
| 4003 | + |
| 4004 | +enum t_output_path{ |
| 4005 | + T_OUTPUT_RECEIVER, |
| 4006 | + T_OUTPUT_SPEAKER, |
| 4007 | + T_OUTPUT_HEADSET, |
| 4008 | +}; |
| 4009 | + |
| 4010 | +enum t_input_path{ |
| 4011 | + T_INPUT_MICLP, |
| 4012 | + T_INPUT_MICRP, |
| 4013 | +}; |
| 4014 | + |
| 4015 | +enum t_output_vol{ |
| 4016 | + T_OUTPUT_VOL_MINUS_63_5DB = 0, |
| 4017 | + T_OUTPUT_VOL_MINUS_63DB = 1, |
| 4018 | + T_OUTPUT_VOL_MINUS_6DB = 115, |
| 4019 | + T_OUTPUT_VOL_MINUS_3DB = 121, |
| 4020 | + T_OUTPUT_VOL_MINUS_2DB = 123, |
| 4021 | + T_OUTPUT_VOL_MINUS_1DB = 125, |
| 4022 | + T_OUTPUT_VOL_0DB = 127, |
| 4023 | + T_OUTPUT_VOL_1DB = 129, |
| 4024 | + T_OUTPUT_VOL_2DB = 131, |
| 4025 | + T_OUTPUT_VOL_3DB = 133, |
| 4026 | + T_OUTPUT_VOL_6DB = 139, |
| 4027 | + T_OUTPUT_VOL_9DB = 145, |
| 4028 | + T_OUTPUT_VOL_12DB = 151, |
| 4029 | + T_OUTPUT_VOL_24DB = 175, |
| 4030 | +}; |
| 4031 | + |
| 4032 | +enum t_input_vol{ |
| 4033 | + T_INPUT_VOL_MINUS_12DB = 0, |
| 4034 | + T_INPUT_VOL_MINUS_3DB = 18, |
| 4035 | + T_INPUT_VOL_MINUS_2DB = 20, |
| 4036 | + T_INPUT_VOL_MINUS_1DB = 22, |
| 4037 | + T_INPUT_VOL_0DB = 24, |
| 4038 | + T_INPUT_VOL_1DB = 26, |
| 4039 | + T_INPUT_VOL_2DB = 28, |
| 4040 | + T_INPUT_VOL_3DB = 30, |
| 4041 | + T_INPUT_VOL_20DB = 64, |
| 4042 | +}; |
| 4043 | + |
| 4044 | +struct audio_para_conf { |
| 4045 | + const char *control; |
| 4046 | + char *values[2]; |
| 4047 | +}; |
| 4048 | + |
| 4049 | +static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 4050 | + {"Speaker Analog Playback Volume",{"127"}}, |
| 4051 | + {"Speaker Driver Playback Switch",{"1"}}, |
| 4052 | + {"DAC Left Input",{"Mono"}}, |
| 4053 | + {"DAC Right Input",{"Mono"}}, |
| 4054 | + {"Output Right From Right DAC",{"1"}}, |
| 4055 | + {"Output Left From Left DAC",{"1"}}, |
| 4056 | + {"HP Analog Playback Volume",{"127","127"}}, |
| 4057 | + {"HP Driver Playback Switch",{"1","1"}}, //7dB |
| 4058 | + |
| 4059 | +}; |
| 4060 | + |
| 4061 | +static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 4062 | + {"Mic PGA Capture Volume",{"40"}}, |
| 4063 | + {"ADC Capture Switch",{"1"}}, |
| 4064 | + {"ADC Fine Capture Volume",{"0"}}, |
| 4065 | + |
| 4066 | +}; |
| 4067 | + |
| 4068 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ |
| 4069 | + {"Speaker Switch",{"0"}}, |
| 4070 | + {"HP Left Switch",{"1"}}, |
| 4071 | + {"HP Right Switch",{"1"}}, |
| 4072 | + {"HP Driver Playback Volume",{"0","0"}}, |
| 4073 | +}; |
| 4074 | + |
| 4075 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 4076 | + {"Speaker Switch",{"1"}}, |
| 4077 | + {"Speaker Driver Playback Volume",{"2"}}, //18dB |
| 4078 | + {"HP Left Switch",{"0"}}, |
| 4079 | + {"HP Right Switch",{"0"}}, |
| 4080 | +}; |
| 4081 | + |
| 4082 | +static struct audio_para_conf mic1lp_mc1lm_inpath_para_audio[] = { //¶ÔÓ¦ÓÚMic1lp_Mic1lmÊäÈëͨµÀ |
| 4083 | + {"MIC1LM P-Terminal",{"Off"}}, |
| 4084 | + {"MIC1RP P-Terminal",{"Off"}}, |
| 4085 | + {"MIC1LP P-Terminal",{"FFR 10 Ohm"}}, |
| 4086 | + {"MIC1LM M-Terminal",{"FFR 10 Ohm"}}, |
| 4087 | + |
| 4088 | +}; |
| 4089 | + |
| 4090 | +static struct audio_para_conf mic1rp_inpath_para_audio[] = {//¶ÔÓ¦ÓÚMic1rpÊäÈëͨµÀ |
| 4091 | + {"MIC1LM P-Terminal",{"Off"}}, |
| 4092 | + {"MIC1RP P-Terminal",{"FFR 10 Ohm"}}, |
| 4093 | + {"MIC1LP P-Terminal",{"Off"}}, |
| 4094 | + {"MIC1LM M-Terminal",{"Off"}}, |
| 4095 | +}; |
| 4096 | + |
| 4097 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 4098 | + {"Speaker Switch",{"0"}}, |
| 4099 | + {"DAC Playback Volume",{"129","129"}}, |
| 4100 | + {"HP Left Switch",{"1"}}, |
| 4101 | + {"HP Right Switch",{"1"}}, |
| 4102 | + {"HP Driver Playback Volume",{"7","7"}}, |
| 4103 | + {"MIC1LM P-Terminal",{"Off"}}, |
| 4104 | + {"MIC1RP P-Terminal",{"Off"}}, |
| 4105 | + {"MIC1LP P-Terminal",{"FFR 10 Ohm"}}, |
| 4106 | + {"MIC1LM M-Terminal",{"FFR 10 Ohm"}}, |
| 4107 | + {"ADC Capture Volume",{"24"}}, |
| 4108 | + {"voice processing path select",{"handset"}}, |
| 4109 | + |
| 4110 | +}; |
| 4111 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ |
| 4112 | + {"Speaker Switch",{"0"}}, |
| 4113 | + {"DAC Playback Volume ",{"129","129"}}, |
| 4114 | + {"HP Left Switch",{"1"}}, |
| 4115 | + {"HP Right Switch",{"1"}}, |
| 4116 | + {"HP Driver Playback Switch",{"7","7"}}, //7dB |
| 4117 | + {"MIC1LM P-Terminal",{"Off"}}, |
| 4118 | + {"MIC1RP P-Terminal",{"FFR 10 Ohm"}}, |
| 4119 | + {"MIC1LP P-Terminal",{"Off"}}, |
| 4120 | + {"MIC1LM M-Terminal",{"Off"}}, |
| 4121 | + {"ADC Capture Volume",{"24"}}, |
| 4122 | + {"voice processing select",{"headset"}}, |
| 4123 | +}; |
| 4124 | + |
| 4125 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 4126 | + |
| 4127 | + {"DAC Playback Volume",{"124","124"}}, //-1.5dB |
| 4128 | + {"Speaker Switch",{"1"}}, |
| 4129 | + {"Speaker Driver Playback Volume",{"2"}}, //18dB |
| 4130 | + {"HP Left Switch",{"0"}}, |
| 4131 | + {"HP Right Switch",{"0"}}, |
| 4132 | + {"MIC1LM P-Terminal",{"Off"}}, |
| 4133 | + {"MIC1RP P-Terminal",{"Off"}}, |
| 4134 | + {"MIC1LP P-Terminal",{"FFR 10 Ohm"}}, |
| 4135 | + {"MIC1LM M-Terminal",{"FFR 10 Ohm"}}, |
| 4136 | + {"ADC Capture Volume",{"24"}}, |
| 4137 | + {"voice processing path select",{"speak"}}, |
| 4138 | +}; |
| 4139 | + |
| 4140 | +static struct audio_para_conf output_dac_vol = {"DAC Playback Volume",{"24"}}; |
| 4141 | + |
| 4142 | +static struct audio_para_conf input_adc_vol = {"ADC Capture Volume",{"129","129"}}; |
| 4143 | + |
| 4144 | +static int sig_close = 1; |
| 4145 | + |
| 4146 | +static int s_outpath = T_OUTPUT_SPEAKER; |
| 4147 | +static int s_inpath = T_INPUT_MICLP; |
| 4148 | +static int s_invol = T_INPUT_VOL_0DB; |
| 4149 | +static int s_outvol = T_OUTPUT_VOL_0DB; |
| 4150 | + |
| 4151 | +void stream_close(int sig) |
| 4152 | +{ |
| 4153 | + /* allow the stream to be closed gracefully */ |
| 4154 | + signal(sig, SIG_IGN); |
| 4155 | + sig_close = 0; |
| 4156 | +} |
| 4157 | + |
| 4158 | +static void tinymix_set_value_test(struct mixer *mixer, const char *control, |
| 4159 | + char **values) |
| 4160 | +{ |
| 4161 | + struct mixer_ctl *ctl; |
| 4162 | + enum mixer_ctl_type type; |
| 4163 | + unsigned int num_ctl_values; |
| 4164 | + unsigned int i; |
| 4165 | + |
| 4166 | + if (isdigit(control[0])) |
| 4167 | + ctl = mixer_get_ctl(mixer, atoi(control)); |
| 4168 | + else |
| 4169 | + ctl = mixer_get_ctl_by_name(mixer, control); |
| 4170 | + |
| 4171 | + if (!ctl) { |
| 4172 | + fprintf(stderr, "Invalid mixer control\n"); |
| 4173 | + return; |
| 4174 | + } |
| 4175 | + |
| 4176 | + type = mixer_ctl_get_type(ctl); |
| 4177 | + num_ctl_values = mixer_ctl_get_num_values(ctl); |
| 4178 | + |
| 4179 | + if (isdigit(values[0][0])) { |
| 4180 | + |
| 4181 | + for (i = 0; i < num_ctl_values; i++) { |
| 4182 | + if (mixer_ctl_set_value(ctl, i, atoi(values[i]))) { |
| 4183 | + fprintf(stderr, "Error: invalid value for index %d\n", i); |
| 4184 | + return; |
| 4185 | + } |
| 4186 | + } |
| 4187 | + |
| 4188 | + } else { |
| 4189 | + if (type == MIXER_CTL_TYPE_ENUM) { |
| 4190 | + /*if (num_values != 1) { |
| 4191 | + fprintf(stderr, "Enclose strings in quotes and try again\n"); |
| 4192 | + return; |
| 4193 | + }*/ |
| 4194 | + if (mixer_ctl_set_enum_by_string(ctl, values[0])) |
| 4195 | + fprintf(stderr, "Error: invalid enum value\n"); |
| 4196 | + } else { |
| 4197 | + fprintf(stderr, "Error: only enum types can be set with strings\n"); |
| 4198 | + } |
| 4199 | + } |
| 4200 | +} |
| 4201 | + |
| 4202 | +int mix_set_outputpath(struct mixer *mixer, int path) |
| 4203 | +{ |
| 4204 | + int i; |
| 4205 | + for(i = 0;i<ARRAY_SIZE(common_out_para_audio);i++) |
| 4206 | + { |
| 4207 | + tinymix_set_value_test(mixer,common_out_para_audio[i].control,common_out_para_audio[i].values); |
| 4208 | + } |
| 4209 | + switch(path) |
| 4210 | + { |
| 4211 | + case T_OUTPUT_RECEIVER: |
| 4212 | + for(i = 0;i<ARRAY_SIZE(hp_outpath_para_audio);i++) |
| 4213 | + { |
| 4214 | + tinymix_set_value_test(mixer,hp_outpath_para_audio[i].control,hp_outpath_para_audio[i].values); |
| 4215 | + } |
| 4216 | + break; |
| 4217 | + case T_OUTPUT_SPEAKER: |
| 4218 | + for(i = 0;i<ARRAY_SIZE(spk_outpath_para_audio);i++) |
| 4219 | + { |
| 4220 | + tinymix_set_value_test(mixer,spk_outpath_para_audio[i].control,spk_outpath_para_audio[i].values); |
| 4221 | + } |
| 4222 | + break; |
| 4223 | + default: |
| 4224 | + break; |
| 4225 | + } |
| 4226 | + |
| 4227 | + return 0; |
| 4228 | +} |
| 4229 | + |
| 4230 | +int mix_set_inputpath(struct mixer *mixer, int path) |
| 4231 | +{ |
| 4232 | + int i; |
| 4233 | + for(i = 0;i<ARRAY_SIZE(common_in_para_audio);i++) |
| 4234 | + { |
| 4235 | + tinymix_set_value_test(mixer,common_in_para_audio[i].control,common_in_para_audio[i].values); |
| 4236 | + } |
| 4237 | + switch(path) |
| 4238 | + { |
| 4239 | + case T_INPUT_MICLP: |
| 4240 | + for(i = 0;i<ARRAY_SIZE(mic1lp_mc1lm_inpath_para_audio);i++) |
| 4241 | + { |
| 4242 | + tinymix_set_value_test(mixer,mic1lp_mc1lm_inpath_para_audio[i].control,mic1lp_mc1lm_inpath_para_audio[i].values); |
| 4243 | + } |
| 4244 | + break; |
| 4245 | + case T_INPUT_MICRP: |
| 4246 | + for(i = 0;i<ARRAY_SIZE(mic1rp_inpath_para_audio);i++) |
| 4247 | + { |
| 4248 | + tinymix_set_value_test(mixer,mic1rp_inpath_para_audio[i].control,mic1rp_inpath_para_audio[i].values); |
| 4249 | + } |
| 4250 | + break; |
| 4251 | + default: |
| 4252 | + break; |
| 4253 | + } |
| 4254 | + |
| 4255 | + return 0; |
| 4256 | +} |
| 4257 | + |
| 4258 | +int mix_set_inputvol(struct mixer *mixer, int volume) |
| 4259 | +{ |
| 4260 | + |
| 4261 | + struct mixer_ctl *ctl = input_adc_vol.control; |
| 4262 | + enum mixer_ctl_type type; |
| 4263 | + unsigned int num_ctl_values; |
| 4264 | + unsigned int i; |
| 4265 | + |
| 4266 | + ctl = mixer_get_ctl_by_name(mixer, ctl); |
| 4267 | + if (!ctl) { |
| 4268 | + fprintf(stderr, "Invalid mixer control\n"); |
| 4269 | + return; |
| 4270 | + } |
| 4271 | + |
| 4272 | +// int value = atoi(input_adc_vol.values[0]); |
| 4273 | +// mixer_ctl_set_value(ctl, 0, value); |
| 4274 | + mixer_ctl_set_value(ctl, 0, volume); |
| 4275 | + |
| 4276 | + return 0; |
| 4277 | +} |
| 4278 | + |
| 4279 | +int mix_set_outputvol(struct mixer *mixer, int volume) |
| 4280 | +{ |
| 4281 | + struct mixer_ctl *ctl = output_dac_vol.control; |
| 4282 | + enum mixer_ctl_type type; |
| 4283 | + unsigned int i; |
| 4284 | + |
| 4285 | + ctl = mixer_get_ctl_by_name(mixer, ctl); |
| 4286 | + if (!ctl) { |
| 4287 | + fprintf(stderr, "Invalid mixer control\n"); |
| 4288 | + return; |
| 4289 | + } |
| 4290 | + |
| 4291 | + mixer_ctl_set_value(ctl, 0, volume); |
| 4292 | + mixer_ctl_set_value(ctl, 1, volume); |
| 4293 | +// int value = atoi(output_dac_vol.values[0]); |
| 4294 | +// mixer_ctl_set_value(ctl, 0, value); |
| 4295 | +// value = atoi(output_dac_vol.values[1]); |
| 4296 | +// mixer_ctl_set_value(ctl, 1, value); |
| 4297 | + |
| 4298 | + return 0; |
| 4299 | +} |
| 4300 | + |
| 4301 | +int mix_set_output_mute(struct mixer *mixer, bool enable) |
| 4302 | +{ |
| 4303 | + struct mixer_ctl *ctl = "DAC Mute"; |
| 4304 | + enum mixer_ctl_type type; |
| 4305 | + unsigned int i; |
| 4306 | + printf("mix_set_output_mute %d\n",enable); |
| 4307 | + |
| 4308 | + ctl = mixer_get_ctl_by_name(mixer, ctl); |
| 4309 | + if (!ctl) { |
| 4310 | + fprintf(stderr, "Invalid mixer control\n"); |
| 4311 | + return; |
| 4312 | + } |
| 4313 | + mixer_ctl_set_value(ctl, 0, enable); |
| 4314 | + mixer_ctl_set_value(ctl, 1, enable); |
| 4315 | +} |
| 4316 | + |
| 4317 | +int mix_set_input_mute(struct mixer *mixer, bool enable) |
| 4318 | +{ |
| 4319 | + struct mixer_ctl *ctl = "ADC Capture Switch"; |
| 4320 | + enum mixer_ctl_type type; |
| 4321 | + unsigned int i; |
| 4322 | + |
| 4323 | + ctl = mixer_get_ctl_by_name(mixer, ctl); |
| 4324 | + if (!ctl) { |
| 4325 | + fprintf(stderr, "Invalid mixer control\n"); |
| 4326 | + return; |
| 4327 | + } |
| 4328 | + |
| 4329 | + mixer_ctl_set_value(ctl, 0, !enable); |
| 4330 | +} |
| 4331 | + |
| 4332 | +int check_param(struct pcm_params *params, unsigned int param, unsigned int value, |
| 4333 | + char *param_name, char *param_unit) |
| 4334 | +{ |
| 4335 | + unsigned int min; |
| 4336 | + unsigned int max; |
| 4337 | + int is_within_bounds = 1; |
| 4338 | + |
| 4339 | + min = pcm_params_get_min(params, param); |
| 4340 | + if (value < min) { |
| 4341 | + fprintf(stderr, "%s is %u%s, device only supports >= %u%s\n", param_name, value, |
| 4342 | + param_unit, min, param_unit); |
| 4343 | + is_within_bounds = 0; |
| 4344 | + } |
| 4345 | + |
| 4346 | + max = pcm_params_get_max(params, param); |
| 4347 | + if (value > max) { |
| 4348 | + fprintf(stderr, "%s is %u%s, device only supports <= %u%s\n", param_name, value, |
| 4349 | + param_unit, max, param_unit); |
| 4350 | + is_within_bounds = 0; |
| 4351 | + } |
| 4352 | + |
| 4353 | + return is_within_bounds; |
| 4354 | +} |
| 4355 | + |
| 4356 | +int sample_is_playable(unsigned int card, unsigned int device, unsigned int channels, |
| 4357 | + unsigned int rate, unsigned int bits, unsigned int period_size, |
| 4358 | + unsigned int period_count) |
| 4359 | +{ |
| 4360 | + struct pcm_params *params; |
| 4361 | + int can_play; |
| 4362 | + |
| 4363 | + params = pcm_params_get(card, device, PCM_OUT); |
| 4364 | + if (params == NULL) { |
| 4365 | + fprintf(stderr, "Unable to open PCM device %u.\n", device); |
| 4366 | + return 0; |
| 4367 | + } |
| 4368 | + |
| 4369 | + can_play = check_param(params, PCM_PARAM_RATE, rate, "Sample rate", "Hz"); |
| 4370 | + can_play &= check_param(params, PCM_PARAM_CHANNELS, channels, "Sample", " channels"); |
| 4371 | + can_play &= check_param(params, PCM_PARAM_SAMPLE_BITS, bits, "Bitrate", " bits"); |
| 4372 | + can_play &= check_param(params, PCM_PARAM_PERIOD_SIZE, period_size, "Period size", "Hz"); |
| 4373 | + can_play &= check_param(params, PCM_PARAM_PERIODS, period_count, "Period count", "Hz"); |
| 4374 | + |
| 4375 | + pcm_params_free(params); |
| 4376 | + |
| 4377 | + return can_play; |
| 4378 | +} |
| 4379 | + |
| 4380 | +void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels, |
| 4381 | + unsigned int rate, unsigned int bits, unsigned int period_size, |
| 4382 | + unsigned int period_count) |
| 4383 | +{ |
| 4384 | + struct pcm_config config; |
| 4385 | + struct pcm *pcm; |
| 4386 | + char *buffer; |
| 4387 | + int size; |
| 4388 | + int num_read; |
| 4389 | + |
| 4390 | + memset(&config, 0, sizeof(config)); |
| 4391 | + config.channels = channels; |
| 4392 | + config.rate = rate; |
| 4393 | + config.period_size = period_size; |
| 4394 | + config.period_count = period_count; |
| 4395 | + if (bits == 32) |
| 4396 | + config.format = PCM_FORMAT_S32_LE; |
| 4397 | + else if (bits == 16) |
| 4398 | + config.format = PCM_FORMAT_S16_LE; |
| 4399 | + config.start_threshold = 0; |
| 4400 | + config.stop_threshold = 0; |
| 4401 | + config.silence_threshold = 0; |
| 4402 | + |
| 4403 | + if (!sample_is_playable(card, device, channels, rate, bits, period_size, period_count)) { |
| 4404 | + return; |
| 4405 | + } |
| 4406 | + |
| 4407 | + pcm = pcm_open(card, device, PCM_OUT, &config); |
| 4408 | + if (!pcm || !pcm_is_ready(pcm)) { |
| 4409 | + fprintf(stderr, "Unable to open PCM device %u (%s)\n", |
| 4410 | + device, pcm_get_error(pcm)); |
| 4411 | + return; |
| 4412 | + } |
| 4413 | + |
| 4414 | + size = pcm_frames_to_bytes(pcm, pcm_get_buffer_size(pcm)); |
| 4415 | + buffer = malloc(size); |
| 4416 | + if (!buffer) { |
| 4417 | + fprintf(stderr, "Unable to allocate %d bytes\n", size); |
| 4418 | + free(buffer); |
| 4419 | + pcm_close(pcm); |
| 4420 | + return; |
| 4421 | + } |
| 4422 | + |
| 4423 | + printf("Playing sample: %u ch, %u hz, %u bit\n", channels, rate, bits); |
| 4424 | + |
| 4425 | + /* catch ctrl-c to shutdown cleanly */ |
| 4426 | + signal(SIGINT, stream_close); |
| 4427 | + |
| 4428 | + do { |
| 4429 | + num_read = fread(buffer, 1, size, file); |
| 4430 | + if (num_read > 0) { |
| 4431 | + if (pcm_write(pcm, buffer, num_read)) { |
| 4432 | + fprintf(stderr, "Error playing sample\n"); |
| 4433 | + break; |
| 4434 | + } |
| 4435 | + } |
| 4436 | + } while (sig_close && num_read > 0); |
| 4437 | + |
| 4438 | + free(buffer); |
| 4439 | + pcm_close(pcm); |
| 4440 | +} |
| 4441 | + |
| 4442 | +unsigned int capture_sample(FILE *file, unsigned int card, unsigned int device, |
| 4443 | + unsigned int channels, unsigned int rate, |
| 4444 | + enum pcm_format format, unsigned int period_size, |
| 4445 | + unsigned int period_count) |
| 4446 | +{ |
| 4447 | + struct pcm_config config; |
| 4448 | + struct pcm *pcm; |
| 4449 | + char *buffer; |
| 4450 | + unsigned int size; |
| 4451 | + unsigned int bytes_read = 0; |
| 4452 | + |
| 4453 | + memset(&config, 0, sizeof(config)); |
| 4454 | + config.channels = channels; |
| 4455 | + config.rate = rate; |
| 4456 | + config.period_size = period_size; |
| 4457 | + config.period_count = period_count; |
| 4458 | + config.format = format; |
| 4459 | + config.start_threshold = 0; |
| 4460 | + config.stop_threshold = 0; |
| 4461 | + config.silence_threshold = 0; |
| 4462 | + |
| 4463 | + pcm = pcm_open(card, device, PCM_IN, &config); |
| 4464 | + if (!pcm || !pcm_is_ready(pcm)) { |
| 4465 | + fprintf(stderr, "Unable to open PCM device (%s)\n", |
| 4466 | + pcm_get_error(pcm)); |
| 4467 | + return 0; |
| 4468 | + } |
| 4469 | + |
| 4470 | + size = pcm_frames_to_bytes(pcm, pcm_get_buffer_size(pcm)); |
| 4471 | + buffer = malloc(size); |
| 4472 | + if (!buffer) { |
| 4473 | + fprintf(stderr, "Unable to allocate %d bytes\n", size); |
| 4474 | + free(buffer); |
| 4475 | + pcm_close(pcm); |
| 4476 | + return 0; |
| 4477 | + } |
| 4478 | + |
| 4479 | + printf("Capturing sample: %u ch, %u hz, %u bit\n", channels, rate, |
| 4480 | + pcm_format_to_bits(format)); |
| 4481 | + |
| 4482 | + while (sig_close && !pcm_read(pcm, buffer, size)) { |
| 4483 | + if (fwrite(buffer, 1, size, file) != size) { |
| 4484 | + fprintf(stderr,"Error capturing sample\n"); |
| 4485 | + break; |
| 4486 | + } |
| 4487 | + bytes_read += size; |
| 4488 | + if (bytes_read>=300000) |
| 4489 | + break; |
| 4490 | + } |
| 4491 | + |
| 4492 | + free(buffer); |
| 4493 | + pcm_close(pcm); |
| 4494 | + return pcm_bytes_to_frames(pcm, bytes_read); |
| 4495 | +} |
| 4496 | + |
| 4497 | +int main(int argc, char **argv) |
| 4498 | +{ |
| 4499 | + FILE *file; |
| 4500 | + struct wav_header header; |
| 4501 | + unsigned int card = 0; |
| 4502 | + unsigned int device = 0; |
| 4503 | + unsigned int channels = 2; |
| 4504 | + unsigned int rate = 44100; |
| 4505 | + unsigned int bits = 16; |
| 4506 | + unsigned int frames; |
| 4507 | + unsigned int period_size = 1024; |
| 4508 | + unsigned int period_count = 4; |
| 4509 | + enum pcm_format format; |
| 4510 | + |
| 4511 | + struct riff_wave_header riff_wave_header; |
| 4512 | + struct chunk_header chunk_header; |
| 4513 | + struct chunk_fmt chunk_fmt; |
| 4514 | + char *filename; |
| 4515 | + int more_chunks = 1; |
| 4516 | + struct mixer *mixer; |
| 4517 | + |
| 4518 | + |
| 4519 | + if (argc < 2) { |
| 4520 | + fprintf(stderr, "Usage: %s cap file.wav [-D card] [-d device] [-c channels] " |
| 4521 | + "[-r rate] [-b bits] [-p period_size] [-n n_periods]\n", argv[0]); |
| 4522 | + fprintf(stderr, "Usage: %s play file.wav [-D card] [-d device] [-p period_size]" |
| 4523 | + " [-n n_periods] \n", argv[0]); |
| 4524 | + return 1; |
| 4525 | + } |
| 4526 | + |
| 4527 | + if (strcmp(argv[1], "play") == 0) { |
| 4528 | + mixer = mixer_open(card); |
| 4529 | + if (!mixer) { |
| 4530 | + fprintf(stderr, "Failed to open mixer\n"); |
| 4531 | + return -1; |
| 4532 | + } |
| 4533 | + mix_set_outputpath(mixer, T_OUTPUT_SPEAKER); |
| 4534 | + mix_set_outputvol(mixer, T_OUTPUT_VOL_0DB); |
| 4535 | + // mix_set_output_mute(mixer,false); |
| 4536 | + mixer_close(mixer); |
| 4537 | + |
| 4538 | + filename = argv[2]; |
| 4539 | + file = fopen(filename, "rb"); |
| 4540 | + if (!file) { |
| 4541 | + fprintf(stderr, "Unable to open file '%s'\n", filename); |
| 4542 | + return 1; |
| 4543 | + } |
| 4544 | + |
| 4545 | + fread(&riff_wave_header, sizeof(riff_wave_header), 1, file); |
| 4546 | + if ((riff_wave_header.riff_id != ID_RIFF) || |
| 4547 | + (riff_wave_header.wave_id != ID_WAVE)) { |
| 4548 | + fprintf(stderr, "Error: '%s' is not a riff/wave file\n", filename); |
| 4549 | + fclose(file); |
| 4550 | + return 1; |
| 4551 | + } |
| 4552 | + |
| 4553 | + do { |
| 4554 | + fread(&chunk_header, sizeof(chunk_header), 1, file); |
| 4555 | + |
| 4556 | + switch (chunk_header.id) { |
| 4557 | + case ID_FMT: |
| 4558 | + fread(&chunk_fmt, sizeof(chunk_fmt), 1, file); |
| 4559 | + /* If the format header is larger, skip the rest */ |
| 4560 | + if (chunk_header.sz > sizeof(chunk_fmt)) |
| 4561 | + fseek(file, chunk_header.sz - sizeof(chunk_fmt), SEEK_CUR); |
| 4562 | + break; |
| 4563 | + case ID_DATA: |
| 4564 | + /* Stop looking for chunks */ |
| 4565 | + more_chunks = 0; |
| 4566 | + break; |
| 4567 | + default: |
| 4568 | + /* Unknown chunk, skip bytes */ |
| 4569 | + fseek(file, chunk_header.sz, SEEK_CUR); |
| 4570 | + } |
| 4571 | + } while (more_chunks); |
| 4572 | + |
| 4573 | + /* parse command line arguments */ |
| 4574 | + argv += 3; |
| 4575 | + while (*argv) { |
| 4576 | + if (strcmp(*argv, "-d") == 0) { |
| 4577 | + argv++; |
| 4578 | + if (*argv) |
| 4579 | + device = atoi(*argv); |
| 4580 | + } |
| 4581 | + if (strcmp(*argv, "-p") == 0) { |
| 4582 | + argv++; |
| 4583 | + if (*argv) |
| 4584 | + period_size = atoi(*argv); |
| 4585 | + } |
| 4586 | + if (strcmp(*argv, "-n") == 0) { |
| 4587 | + argv++; |
| 4588 | + if (*argv) |
| 4589 | + period_count = atoi(*argv); |
| 4590 | + } |
| 4591 | + if (strcmp(*argv, "-D") == 0) { |
| 4592 | + argv++; |
| 4593 | + if (*argv) |
| 4594 | + card = atoi(*argv); |
| 4595 | + } |
| 4596 | + if (*argv) |
| 4597 | + argv++; |
| 4598 | + } |
| 4599 | + |
| 4600 | + play_sample(file, card, device, chunk_fmt.num_channels, chunk_fmt.sample_rate, |
| 4601 | + chunk_fmt.bits_per_sample, period_size, period_count); |
| 4602 | + |
| 4603 | + fclose(file); |
| 4604 | + |
| 4605 | + }else if(strcmp(argv[1], "cap") == 0) { |
| 4606 | + mixer = mixer_open(card); |
| 4607 | + if (!mixer) { |
| 4608 | + fprintf(stderr, "Failed to open mixer\n"); |
| 4609 | + return -1; |
| 4610 | + } |
| 4611 | + mix_set_inputpath(mixer, T_INPUT_MICLP); |
| 4612 | + mix_set_inputvol(mixer, T_INPUT_VOL_0DB); |
| 4613 | + mixer_close(mixer); |
| 4614 | + |
| 4615 | + file = fopen(argv[2], "wb"); |
| 4616 | + if (!file) { |
| 4617 | + fprintf(stderr, "Unable to create file '%s'\n", argv[1]); |
| 4618 | + return 1; |
| 4619 | + } |
| 4620 | + |
| 4621 | + /* parse command line arguments */ |
| 4622 | + argv += 3; |
| 4623 | + while (*argv) { |
| 4624 | + if (strcmp(*argv, "-d") == 0) { |
| 4625 | + argv++; |
| 4626 | + if (*argv) |
| 4627 | + device = atoi(*argv); |
| 4628 | + } else if (strcmp(*argv, "-c") == 0) { |
| 4629 | + argv++; |
| 4630 | + if (*argv) |
| 4631 | + channels = atoi(*argv); |
| 4632 | + } else if (strcmp(*argv, "-r") == 0) { |
| 4633 | + argv++; |
| 4634 | + if (*argv) |
| 4635 | + rate = atoi(*argv); |
| 4636 | + } else if (strcmp(*argv, "-b") == 0) { |
| 4637 | + argv++; |
| 4638 | + if (*argv) |
| 4639 | + bits = atoi(*argv); |
| 4640 | + } else if (strcmp(*argv, "-D") == 0) { |
| 4641 | + argv++; |
| 4642 | + if (*argv) |
| 4643 | + card = atoi(*argv); |
| 4644 | + } else if (strcmp(*argv, "-p") == 0) { |
| 4645 | + argv++; |
| 4646 | + if (*argv) |
| 4647 | + period_size = atoi(*argv); |
| 4648 | + } else if (strcmp(*argv, "-n") == 0) { |
| 4649 | + argv++; |
| 4650 | + if (*argv) |
| 4651 | + period_count = atoi(*argv); |
| 4652 | + } |
| 4653 | + if (*argv) |
| 4654 | + argv++; |
| 4655 | + } |
| 4656 | + |
| 4657 | + header.riff_id = ID_RIFF; |
| 4658 | + header.riff_sz = 0; |
| 4659 | + header.riff_fmt = ID_WAVE; |
| 4660 | + header.fmt_id = ID_FMT; |
| 4661 | + header.fmt_sz = 16; |
| 4662 | + header.audio_format = FORMAT_PCM; |
| 4663 | + header.num_channels = channels; |
| 4664 | + header.sample_rate = rate; |
| 4665 | + |
| 4666 | + switch (bits) { |
| 4667 | + case 32: |
| 4668 | + format = PCM_FORMAT_S32_LE; |
| 4669 | + break; |
| 4670 | + case 24: |
| 4671 | + format = PCM_FORMAT_S24_LE; |
| 4672 | + break; |
| 4673 | + case 16: |
| 4674 | + format = PCM_FORMAT_S16_LE; |
| 4675 | + break; |
| 4676 | + default: |
| 4677 | + fprintf(stderr, "%d bits is not supported.\n", bits); |
| 4678 | + return 1; |
| 4679 | + } |
| 4680 | + |
| 4681 | + header.bits_per_sample = pcm_format_to_bits(format); |
| 4682 | + header.byte_rate = (header.bits_per_sample / 8) * channels * rate; |
| 4683 | + header.block_align = channels * (header.bits_per_sample / 8); |
| 4684 | + header.data_id = ID_DATA; |
| 4685 | + |
| 4686 | + /* leave enough room for header */ |
| 4687 | + fseek(file, sizeof(struct wav_header), SEEK_SET); |
| 4688 | + |
| 4689 | + /* install signal handler and begin capturing */ |
| 4690 | + signal(SIGINT, stream_close); |
| 4691 | + frames = capture_sample(file, card, device, header.num_channels, |
| 4692 | + header.sample_rate, format, |
| 4693 | + period_size, period_count); |
| 4694 | + printf("Captured %d frames\n", frames); |
| 4695 | + |
| 4696 | + /* write header now all information is known */ |
| 4697 | + header.data_sz = frames * header.block_align; |
| 4698 | + header.riff_sz = header.data_sz + sizeof(header) - 8; |
| 4699 | + fseek(file, 0, SEEK_SET); |
| 4700 | + fwrite(&header, sizeof(struct wav_header), 1, file); |
| 4701 | + |
| 4702 | + fclose(file); |
| 4703 | + } |
| 4704 | + |
| 4705 | + return 0; |
| 4706 | +} |
| 4707 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/audio_mixer_ctrl.c b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/audio_mixer_ctrl.c |
| 4708 | new file mode 100755 |
| 4709 | index 0000000..65c7e3c |
| 4710 | --- /dev/null |
| 4711 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/audio_mixer_ctrl.c |
| 4712 | @@ -0,0 +1,3017 @@ |
| 4713 | +#include <stdio.h> |
| 4714 | +#include <unistd.h> |
| 4715 | +#include <string.h> |
| 4716 | +#include <fcntl.h> |
| 4717 | +#include <stdint.h> |
| 4718 | +#include <stdbool.h> |
| 4719 | +#include <errno.h> |
| 4720 | +#include <stdlib.h> |
| 4721 | +#include <ctype.h> |
| 4722 | +#include <tinyalsa/asoundlib.h> |
| 4723 | +#include <sound/asound.h> |
| 4724 | +#include <tinyalsa/audio_mixer_ctrl.h> |
| 4725 | + |
| 4726 | +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) |
| 4727 | + |
| 4728 | +struct audio_para_conf { |
| 4729 | + const char *control; |
| 4730 | + char *values[2]; |
| 4731 | +}; |
| 4732 | + |
| 4733 | + |
| 4734 | +#if defined _USE_CODEC_TI3100 |
| 4735 | + |
| 4736 | + |
| 4737 | +enum t_output_vol { |
| 4738 | + T_OUTPUT_VOL_MINUS_63_5DB = 0, |
| 4739 | + T_OUTPUT_VOL_MINUS_63DB = 1, |
| 4740 | + T_OUTPUT_VOL_MINUS_27DB = 73, |
| 4741 | + T_OUTPUT_VOL_MINUS_24DB = 79, |
| 4742 | + T_OUTPUT_VOL_MINUS_21DB = 85, |
| 4743 | + T_OUTPUT_VOL_MINUS_18DB = 91, |
| 4744 | + T_OUTPUT_VOL_MINUS_15DB = 97, |
| 4745 | + T_OUTPUT_VOL_MINUS_12DB = 103, |
| 4746 | + T_OUTPUT_VOL_MINUS_9DB = 109, |
| 4747 | + T_OUTPUT_VOL_MINUS_6DB = 115, |
| 4748 | + T_OUTPUT_VOL_MINUS_3DB = 121, |
| 4749 | + T_OUTPUT_VOL_MINUS_2DB = 123, |
| 4750 | + T_OUTPUT_VOL_MINUS_1DB = 125, |
| 4751 | + T_OUTPUT_VOL_0DB = 127, |
| 4752 | + T_OUTPUT_VOL_1DB = 129, |
| 4753 | + T_OUTPUT_VOL_2DB = 131, |
| 4754 | + T_OUTPUT_VOL_3DB = 133, |
| 4755 | + T_OUTPUT_VOL_6DB = 139, |
| 4756 | + T_OUTPUT_VOL_9DB = 145, |
| 4757 | + T_OUTPUT_VOL_12DB = 151, |
| 4758 | + T_OUTPUT_VOL_24DB = 175, |
| 4759 | +}; |
| 4760 | + |
| 4761 | +enum t_input_vol { |
| 4762 | + T_INPUT_VOL_MINUS_12DB = 0, |
| 4763 | + T_INPUT_VOL_MINUS_7DB = 10, |
| 4764 | + T_INPUT_VOL_MINUS_6DB = 12, |
| 4765 | + T_INPUT_VOL_MINUS_5DB = 14, |
| 4766 | + T_INPUT_VOL_MINUS_4DB = 16, |
| 4767 | + T_INPUT_VOL_MINUS_3DB = 18, |
| 4768 | + T_INPUT_VOL_MINUS_2DB = 20, |
| 4769 | + T_INPUT_VOL_MINUS_1DB = 22, |
| 4770 | + T_INPUT_VOL_0DB = 24, |
| 4771 | + T_INPUT_VOL_1DB = 26, |
| 4772 | + T_INPUT_VOL_2DB = 28, |
| 4773 | + T_INPUT_VOL_3DB = 30, |
| 4774 | + T_INPUT_VOL_20DB = 64, |
| 4775 | +}; |
| 4776 | + |
| 4777 | +static struct audio_para_conf init_default_para[] = { //¿ª»ú³õʼ»¯µ÷Óà |
| 4778 | + {"Mic PGA Capture Volume", {"40"}}, |
| 4779 | + {"ADC Mute", {"0"}}, |
| 4780 | + {"ADC Fine Capture Volume", {"0"}}, |
| 4781 | + {"Speaker Analog Playback Volume", {"127"}}, |
| 4782 | + {"Speaker Driver Playback Switch", {"1"}}, |
| 4783 | + {"DAC Left Input", {"Mono"}}, |
| 4784 | + {"DAC Right Input", {"Mono"}}, |
| 4785 | + {"Output Right From Right DAC", {"1"}}, |
| 4786 | + {"Output Left From Left DAC", {"1"}}, |
| 4787 | + {"HP Analog Playback Volume", {"127", "127"}}, |
| 4788 | + {"HP Driver Playback Switch", {"1", "1"}}, //7dB |
| 4789 | +}; |
| 4790 | + |
| 4791 | +#ifdef _USE_7520V3_PHONE_TYPE_FWP |
| 4792 | +static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 4793 | + {"Speaker Analog Playback Volume", {"127"}}, |
| 4794 | + {"Speaker Driver Playback Switch", {"1"}}, |
| 4795 | + {"DAC Left Input", {"Mono"}}, |
| 4796 | + {"DAC Right Input", {"Mono"}}, |
| 4797 | + {"Output Right From Right DAC", {"1"}}, |
| 4798 | + {"Output Left From Left DAC", {"1"}}, |
| 4799 | + {"HP Analog Playback Volume", {"127", "127"}}, |
| 4800 | + {"HP Driver Playback Switch", {"1", "1"}}, //7dB |
| 4801 | +}; |
| 4802 | + |
| 4803 | +static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 4804 | + {"Mic PGA Capture Volume", {"12"}}, |
| 4805 | + {"ADC Mute", {"0"}}, |
| 4806 | + {"ADC Fine Capture Volume", {"0"}}, |
| 4807 | + |
| 4808 | +}; |
| 4809 | + |
| 4810 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ |
| 4811 | + {"Speaker Switch", {"0"}}, |
| 4812 | + {"HP Left Switch", {"1"}}, |
| 4813 | + {"HP Right Switch", {"1"}}, |
| 4814 | + {"HP Driver Playback Volume", {"0", "0"}}, |
| 4815 | +}; |
| 4816 | + |
| 4817 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 4818 | + {"Speaker Switch", {"1"}}, |
| 4819 | + {"Speaker Driver Playback Volume", {"2"}}, //18dB |
| 4820 | + {"HP Left Switch", {"0"}}, |
| 4821 | + {"HP Right Switch", {"0"}}, |
| 4822 | +}; |
| 4823 | + |
| 4824 | +static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚMic1lp_Mic1lmÊäÈëͨµÀ |
| 4825 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 4826 | + {"MIC1RP P-Terminal", {"Off"}}, |
| 4827 | + {"MIC1LP P-Terminal", {"FFR 10 Ohm"}}, |
| 4828 | + {"MIC1LM M-Terminal", {"FFR 10 Ohm"}}, |
| 4829 | + |
| 4830 | +}; |
| 4831 | + |
| 4832 | +static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚMic1rpÊäÈëͨµÀ |
| 4833 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 4834 | + {"MIC1RP P-Terminal", {"FFR 10 Ohm"}}, |
| 4835 | + {"MIC1LP P-Terminal", {"Off"}}, |
| 4836 | + {"MIC1LM M-Terminal", {"Off"}}, |
| 4837 | +}; |
| 4838 | + |
| 4839 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 4840 | + {"Mic PGA Capture Volume", {"12"}}, |
| 4841 | + //{"ADC Mute", {"0"}}, |
| 4842 | + //{"ADC Fine Capture Volume", {"0"}}, |
| 4843 | + {"DAC Left Input", {"Mono"}}, |
| 4844 | + {"DAC Right Input", {"Mono"}}, |
| 4845 | + {"Output Right From Right DAC", {"1"}}, |
| 4846 | + {"Output Left From Left DAC", {"1"}}, |
| 4847 | + {"HP Analog Playback Volume", {"127", "127"}}, |
| 4848 | + {"HP Driver Playback Switch", {"1", "1"}}, //7dB |
| 4849 | + {"Speaker Switch", {"0"}}, |
| 4850 | + {"DAC Playback Volume", {"129", "129"}}, |
| 4851 | + {"HP Left Switch", {"1"}}, |
| 4852 | + {"HP Right Switch", {"1"}}, |
| 4853 | + {"HP Driver Playback Volume", {"5", "5"}}, |
| 4854 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 4855 | + {"MIC1RP P-Terminal", {"Off"}}, |
| 4856 | + {"MIC1LP P-Terminal", {"FFR 10 Ohm"}}, |
| 4857 | + {"MIC1LM M-Terminal", {"FFR 10 Ohm"}}, |
| 4858 | + {"ADC Capture Volume", {"24"}}, |
| 4859 | +#ifndef USE_CAP_SUPPORT |
| 4860 | + |
| 4861 | + {"voice processing path select", {"handset"}}, // handset speak headset bluetooth |
| 4862 | +#endif |
| 4863 | +}; |
| 4864 | + |
| 4865 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ |
| 4866 | + {"Mic PGA Capture Volume", {"40"}}, |
| 4867 | + //{"ADC Mute", {"0"}}, |
| 4868 | + //{"ADC Fine Capture Volume", {"0"}}, |
| 4869 | + {"DAC Left Input", {"Mono"}}, |
| 4870 | + {"DAC Right Input", {"Mono"}}, |
| 4871 | + {"Output Right From Right DAC", {"1"}}, |
| 4872 | + {"Output Left From Left DAC", {"1"}}, |
| 4873 | + {"HP Analog Playback Volume", {"127", "127"}}, |
| 4874 | + {"HP Driver Playback Switch", {"1", "1"}}, //7dB |
| 4875 | + {"Speaker Switch", {"0"}}, |
| 4876 | + {"DAC Playback Volume ", {"129", "129"}}, |
| 4877 | + {"HP Left Switch", {"1"}}, |
| 4878 | + {"HP Right Switch", {"1"}}, |
| 4879 | + {"HP Driver Playback Switch", {"7", "7"}}, //7dB |
| 4880 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 4881 | + {"MIC1RP P-Terminal", {"FFR 10 Ohm"}}, |
| 4882 | + {"MIC1LP P-Terminal", {"Off"}}, |
| 4883 | + {"MIC1LM M-Terminal", {"Off"}}, |
| 4884 | + {"ADC Capture Volume", {"24"}}, |
| 4885 | +#ifndef USE_CAP_SUPPORT |
| 4886 | + {"voice processing path select", {"headset"}}, // handset speak headset bluetooth |
| 4887 | +#endif |
| 4888 | +}; |
| 4889 | + |
| 4890 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 4891 | + {"Mic PGA Capture Volume", {"12"}}, |
| 4892 | + //{"ADC Mute", {"0"}}, |
| 4893 | + //{"ADC Fine Capture Volume", {"0"}}, |
| 4894 | + {"Speaker Analog Playback Volume", {"127"}}, |
| 4895 | + {"Speaker Driver Playback Switch", {"1"}}, |
| 4896 | + {"DAC Left Input", {"Mono"}}, |
| 4897 | + {"DAC Right Input", {"Mono"}}, |
| 4898 | + {"Output Right From Right DAC", {"1"}}, |
| 4899 | + {"Output Left From Left DAC", {"1"}}, |
| 4900 | + {"DAC Playback Volume", {"124", "124"}}, //-1.5dB |
| 4901 | + {"Speaker Switch", {"1"}}, |
| 4902 | + {"Speaker Driver Playback Volume", {"0"}}, //18dB |
| 4903 | + {"HP Left Switch", {"0"}}, |
| 4904 | + {"HP Right Switch", {"0"}}, |
| 4905 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 4906 | + {"MIC1RP P-Terminal", {"Off"}}, |
| 4907 | + {"MIC1LP P-Terminal", {"FFR 10 Ohm"}}, |
| 4908 | + {"MIC1LM M-Terminal", {"FFR 10 Ohm"}}, |
| 4909 | + {"ADC Capture Volume", {"24"}}, |
| 4910 | +#ifndef USE_CAP_SUPPORT |
| 4911 | + |
| 4912 | + {"voice processing path select", {"speak"}}, // handset speak headset bluetooth |
| 4913 | +#endif |
| 4914 | +}; |
| 4915 | + |
| 4916 | +#else |
| 4917 | +static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 4918 | + {"Speaker Analog Playback Volume", {"127"}}, |
| 4919 | + {"Speaker Driver Playback Switch", {"1"}}, |
| 4920 | + {"DAC Left Input", {"Mono"}}, |
| 4921 | + {"DAC Right Input", {"Mono"}}, |
| 4922 | + {"Output Right From Right DAC", {"1"}}, |
| 4923 | + {"Output Left From Left DAC", {"1"}}, |
| 4924 | + {"HP Analog Playback Volume", {"127", "127"}}, |
| 4925 | + {"HP Driver Playback Switch", {"1", "1"}}, //7dB |
| 4926 | +}; |
| 4927 | + |
| 4928 | +static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 4929 | + {"Mic PGA Capture Volume", {"40"}}, |
| 4930 | + {"ADC Mute", {"0"}}, |
| 4931 | + {"ADC Fine Capture Volume", {"0"}}, |
| 4932 | + |
| 4933 | +}; |
| 4934 | + |
| 4935 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ |
| 4936 | + {"Speaker Switch", {"0"}}, |
| 4937 | + {"HP Left Switch", {"1"}}, |
| 4938 | + {"HP Right Switch", {"1"}}, |
| 4939 | + {"HP Driver Playback Volume", {"0", "0"}}, |
| 4940 | +}; |
| 4941 | + |
| 4942 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 4943 | + {"Speaker Switch", {"1"}}, |
| 4944 | + {"Speaker Driver Playback Volume", {"2"}}, //18dB |
| 4945 | + {"HP Left Switch", {"0"}}, |
| 4946 | + {"HP Right Switch", {"0"}}, |
| 4947 | +}; |
| 4948 | + |
| 4949 | +static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚMic1lp_Mic1lmÊäÈëͨµÀ |
| 4950 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 4951 | + {"MIC1RP P-Terminal", {"Off"}}, |
| 4952 | + {"MIC1LP P-Terminal", {"FFR 10 Ohm"}}, |
| 4953 | + {"MIC1LM M-Terminal", {"FFR 10 Ohm"}}, |
| 4954 | + |
| 4955 | +}; |
| 4956 | + |
| 4957 | +static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚMic1rpÊäÈëͨµÀ |
| 4958 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 4959 | + {"MIC1RP P-Terminal", {"FFR 10 Ohm"}}, |
| 4960 | + {"MIC1LP P-Terminal", {"Off"}}, |
| 4961 | + {"MIC1LM M-Terminal", {"Off"}}, |
| 4962 | +}; |
| 4963 | + |
| 4964 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 4965 | + {"Mic PGA Capture Volume", {"40"}},//analog gain control from 0 dB to 59.5 dB in steps of 0.5 dB |
| 4966 | + {"ADC Mute", {"0"}},//ADC muting |
| 4967 | + {"DAC Mute", {"0","0"}},//DAC muting and setting up a master gain control to control both channels occurs |
| 4968 | + //{"ADC Fine Capture Volume", {"0"}}, |
| 4969 | + {"DAC Left Input", {"Mono"}}, |
| 4970 | + {"DAC Right Input", {"Mono"}}, |
| 4971 | + {"Output Right From Right DAC", {"1"}}, |
| 4972 | + {"Output Left From Left DAC", {"1"}},//"1" means DAC_L is firstly routed to the left-channel mixer amplifier, then routed HPL driver |
| 4973 | + {"HP Analog Playback Volume", {"114", "114"}},//Analog Volume Control for Headphone and Speaker Outputs(D0~D6) |
| 4974 | + {"HP Driver Playback Switch", {"1", "1"}}, // HPL/HPR driver is not muted |
| 4975 | + {"Speaker Switch", {"0"}},//Analog Volume Control for Speaker Outputs(D7) |
| 4976 | + {"DAC Playback Volume", {"135", "135"}},//DAC volume: -127 to 48??//0627Ô½´óÔöÒæÔ½´ó |
| 4977 | + {"HP Left Switch", {"1"}},//Analog Volume Control for Headphone Outputs(D7) |
| 4978 | + {"HP Right Switch", {"1"}}, |
| 4979 | + {"HP Driver Playback Volume", {"9", "9"}},//HPL/HPR driver is 9dB(0~9) |
| 4980 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 4981 | + {"MIC1RP P-Terminal", {"Off"}}, |
| 4982 | + {"MIC1LP P-Terminal", {"FFR 10 Ohm"}}, |
| 4983 | + {"MIC1LM M-Terminal", {"FFR 10 Ohm"}}, |
| 4984 | + {"ADC Capture Volume", {"24"}}, |
| 4985 | +#ifndef USE_CAP_SUPPORT |
| 4986 | + {"voice processing path select", {"handset"}}, // handset speak headset bluetooth |
| 4987 | +#endif |
| 4988 | +}; |
| 4989 | + |
| 4990 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ |
| 4991 | + {"Mic PGA Capture Volume", {"40"}}, |
| 4992 | + {"ADC Mute", {"0"}}, |
| 4993 | + {"DAC Mute", {"0","0"}}, |
| 4994 | + //{"ADC Fine Capture Volume", {"0"}}, |
| 4995 | + {"DAC Left Input", {"Mono"}}, |
| 4996 | + {"DAC Right Input", {"Mono"}}, |
| 4997 | + {"Output Right From Right DAC", {"1"}}, |
| 4998 | + {"Output Left From Left DAC", {"1"}}, |
| 4999 | + {"HP Analog Playback Volume", {"127", "127"}}, |
| 5000 | + {"HP Driver Playback Switch", {"1", "1"}}, //7dB |
| 5001 | + {"Speaker Switch", {"0"}}, |
| 5002 | + {"DAC Playback Volume ", {"129", "129"}}, |
| 5003 | + {"HP Left Switch", {"1"}}, |
| 5004 | + {"HP Right Switch", {"1"}}, |
| 5005 | + {"HP Driver Playback Switch", {"7", "7"}}, //7dB |
| 5006 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 5007 | + {"MIC1RP P-Terminal", {"FFR 10 Ohm"}}, |
| 5008 | + {"MIC1LP P-Terminal", {"Off"}}, |
| 5009 | + {"MIC1LM M-Terminal", {"Off"}}, |
| 5010 | + {"ADC Capture Volume", {"24"}}, |
| 5011 | +#ifndef USE_CAP_SUPPORT |
| 5012 | + {"voice processing path select", {"headset"}}, // handset speak headset bluetooth |
| 5013 | +#endif |
| 5014 | +}; |
| 5015 | + |
| 5016 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 5017 | + {"Mic PGA Capture Volume", {"20"}}, |
| 5018 | + {"ADC Mute", {"0"}}, |
| 5019 | + {"DAC Mute", {"0","0"}}, |
| 5020 | + //{"ADC Fine Capture Volume", {"0"}}, |
| 5021 | + {"Speaker Analog Playback Volume", {"116"}}, |
| 5022 | + {"Speaker Driver Playback Switch", {"1"}}, |
| 5023 | + {"DAC Left Input", {"Mono"}}, |
| 5024 | + {"DAC Right Input", {"Mono"}}, |
| 5025 | + {"Output Right From Right DAC", {"1"}}, |
| 5026 | + {"Output Left From Left DAC", {"1"}}, |
| 5027 | + {"DAC Playback Volume", {"130", "130"}}, // |
| 5028 | + {"Speaker Switch", {"1"}}, |
| 5029 | + {"Speaker Driver Playback Volume", {"1"}}, //12dB //0~3 is 6dB~24dB(6-dB Steps) |
| 5030 | + {"HP Left Switch", {"0"}}, |
| 5031 | + {"HP Right Switch", {"0"}}, |
| 5032 | + {"MIC1LM P-Terminal", {"Off"}}, |
| 5033 | + {"MIC1RP P-Terminal", {"Off"}}, |
| 5034 | + {"MIC1LP P-Terminal", {"FFR 10 Ohm"}}, |
| 5035 | + {"MIC1LM M-Terminal", {"FFR 10 Ohm"}}, |
| 5036 | + {"ADC Capture Volume", {"24"}}, |
| 5037 | +#ifndef USE_CAP_SUPPORT |
| 5038 | + |
| 5039 | + {"voice processing path select", {"speak"}}, // handset speak headset bluetooth |
| 5040 | +#endif |
| 5041 | +}; |
| 5042 | + |
| 5043 | +#endif |
| 5044 | +static struct audio_para_conf output_dac_vol = {"DAC Playback Volume", {"129","129"}}; |
| 5045 | + |
| 5046 | +static struct audio_para_conf input_adc_vol = {"ADC Capture Volume", {"24"}}; |
| 5047 | + |
| 5048 | +static struct audio_para_conf dac_mute = {"DAC Mute", {"1", "1"}}; |
| 5049 | +static struct audio_para_conf adc_mute = {"ADC Mute", {"1"}}; |
| 5050 | + |
| 5051 | +static struct audio_para_conf spk_path_onoff[] = { |
| 5052 | + {"Speaker Switch", {"0"}}, |
| 5053 | +}; |
| 5054 | +static struct audio_para_conf rcv_path_onoff[] = { |
| 5055 | + {"HP Left Switch", {"0"}}, |
| 5056 | + {"HP Right Switch", {"0"}}, |
| 5057 | +}; |
| 5058 | +static struct audio_para_conf earp_path_onoff[] = { |
| 5059 | + {"HP Left Switch", {"0"}}, |
| 5060 | + {"HP Right Switch", {"0"}}, |
| 5061 | +}; |
| 5062 | +static int output_vol_conversion(int vol) |
| 5063 | +{ |
| 5064 | + switch(vol){ |
| 5065 | + case T_AUDIO_OUTPUT_VOL_LEVEL_0: |
| 5066 | + return T_OUTPUT_VOL_MINUS_63_5DB; |
| 5067 | + case T_AUDIO_OUTPUT_VOL_LEVEL_1: |
| 5068 | + return T_OUTPUT_VOL_MINUS_27DB; |
| 5069 | + case T_AUDIO_OUTPUT_VOL_LEVEL_2: |
| 5070 | + return T_OUTPUT_VOL_MINUS_24DB; |
| 5071 | + case T_AUDIO_OUTPUT_VOL_LEVEL_3: |
| 5072 | + return T_OUTPUT_VOL_MINUS_21DB; |
| 5073 | + case T_AUDIO_OUTPUT_VOL_LEVEL_4: |
| 5074 | + return T_OUTPUT_VOL_MINUS_18DB; |
| 5075 | + case T_AUDIO_OUTPUT_VOL_LEVEL_5: |
| 5076 | + return T_OUTPUT_VOL_MINUS_15DB; |
| 5077 | + case T_AUDIO_OUTPUT_VOL_LEVEL_6: |
| 5078 | + return T_OUTPUT_VOL_MINUS_12DB; |
| 5079 | + case T_AUDIO_OUTPUT_VOL_LEVEL_7: |
| 5080 | + return T_OUTPUT_VOL_MINUS_9DB; |
| 5081 | + case T_AUDIO_OUTPUT_VOL_LEVEL_8: |
| 5082 | + return T_OUTPUT_VOL_MINUS_6DB; |
| 5083 | + case T_AUDIO_OUTPUT_VOL_LEVEL_9: |
| 5084 | + return T_OUTPUT_VOL_MINUS_3DB; |
| 5085 | + case T_AUDIO_OUTPUT_VOL_LEVEL_10: |
| 5086 | + return T_OUTPUT_VOL_0DB; |
| 5087 | + case T_AUDIO_OUTPUT_VOL_LEVEL_11: |
| 5088 | + return T_OUTPUT_VOL_3DB; |
| 5089 | + default: |
| 5090 | + return T_OUTPUT_VOL_0DB; |
| 5091 | + } |
| 5092 | +} |
| 5093 | + |
| 5094 | + |
| 5095 | +static int input_vol_conversion(int vol) |
| 5096 | +{ |
| 5097 | + switch(vol) { |
| 5098 | + case T_AUDIO_INPUT_VOL_LEVEL_0: |
| 5099 | + return T_INPUT_VOL_MINUS_12DB; |
| 5100 | + case T_AUDIO_INPUT_VOL_LEVEL_1: |
| 5101 | + return T_INPUT_VOL_MINUS_7DB; |
| 5102 | + case T_AUDIO_INPUT_VOL_LEVEL_2: |
| 5103 | + return T_INPUT_VOL_MINUS_6DB; |
| 5104 | + case T_AUDIO_INPUT_VOL_LEVEL_3: |
| 5105 | + return T_INPUT_VOL_MINUS_5DB; |
| 5106 | + case T_AUDIO_INPUT_VOL_LEVEL_4: |
| 5107 | + return T_INPUT_VOL_MINUS_4DB; |
| 5108 | + case T_AUDIO_INPUT_VOL_LEVEL_5: |
| 5109 | + return T_INPUT_VOL_MINUS_3DB; |
| 5110 | + case T_AUDIO_INPUT_VOL_LEVEL_6: |
| 5111 | + return T_INPUT_VOL_MINUS_2DB; |
| 5112 | + case T_AUDIO_INPUT_VOL_LEVEL_7: |
| 5113 | + return T_INPUT_VOL_MINUS_1DB; |
| 5114 | + case T_AUDIO_INPUT_VOL_LEVEL_8: |
| 5115 | + return T_INPUT_VOL_0DB; |
| 5116 | + case T_AUDIO_INPUT_VOL_LEVEL_9: |
| 5117 | + return T_INPUT_VOL_1DB; |
| 5118 | + case T_AUDIO_INPUT_VOL_LEVEL_10: |
| 5119 | + return T_INPUT_VOL_2DB; |
| 5120 | + case T_AUDIO_INPUT_VOL_LEVEL_11: |
| 5121 | + return T_INPUT_VOL_3DB; |
| 5122 | + default: |
| 5123 | + return T_INPUT_VOL_0DB; |
| 5124 | + } |
| 5125 | +} |
| 5126 | +#elif defined _USE_CODEC_ES8311 |
| 5127 | +static struct audio_para_conf init_default_para[] = { //¿ª»ú³õʼ»¯µ÷Óà |
| 5128 | + |
| 5129 | +}; |
| 5130 | + |
| 5131 | +static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 5132 | + //{"DAC Soft Mute Control", {"0"}}, |
| 5133 | + |
| 5134 | + |
| 5135 | +}; |
| 5136 | + |
| 5137 | + |
| 5138 | +static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 5139 | + |
| 5140 | + //{"Mic Gain Control", {"0"}}, |
| 5141 | + |
| 5142 | +}; |
| 5143 | + |
| 5144 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ |
| 5145 | + {"MIC PGA GAIN", {"10"}}, |
| 5146 | + {"ADC SCALE", {"1"}}, |
| 5147 | + {"DMIC TYPE", {"dmic at high level"}}, |
| 5148 | + {"ADC RAMP RATE", {"4"}}, |
| 5149 | + {"ADC SDP MUTE", {"0"}}, |
| 5150 | + {"ADC INVERTED", {"0"}}, |
| 5151 | + {"ADC SYNC", {"0"}}, |
| 5152 | + {"ADC RAM CLR", {"0"}}, |
| 5153 | + {"ADC VOLUME", {"191"}}, |
| 5154 | + {"ALC ENABLE", {"0"}}, |
| 5155 | + {"ALC AUTOMUTE TYPE", {"automute disabled"}}, |
| 5156 | + {"ALC WIN SIZE", {"0"}}, |
| 5157 | + {"ALC MAX LEVEL", {"0"}}, |
| 5158 | + {"ALC MIN LEVEL", {"0"}}, |
| 5159 | + {"ALC AUTOMUTE WINSIZE", {"0"}}, |
| 5160 | + {"ALC AUTOMUTE GATE THRESHOLD", {"0"}}, |
| 5161 | + {"ALC AUTOMUTE VOLUME", {"0"}}, |
| 5162 | + {"ADC FS MODE", {"0"}}, |
| 5163 | + {"DAC SDP MUTE", {"0"}}, |
| 5164 | + {"DAC DEM MUTE", {"0"}}, |
| 5165 | + {"DAC INVERT", {"0"}}, |
| 5166 | + {"DAC RAM CLR", {"0"}}, |
| 5167 | + {"DAC DSM MUTE", {"mute to 8"}}, |
| 5168 | + {"DAC OFFSET", {"0"}}, |
| 5169 | + {"DAC VOLUME", {"191"}}, |
| 5170 | + {"DRC ENABLE", {"0"}}, |
| 5171 | + {"DRC WIN SIZE", {"0"}}, |
| 5172 | + {"DRC MAX LEVEL", {"0"}}, |
| 5173 | + {"DRC MIN LEVEL", {"0"}}, |
| 5174 | + {"DAC RAMP RATE", {"4"}}, |
| 5175 | + {"AEC MODE", {"adc left, adc right"}}, |
| 5176 | + {"ADC DATA TO DAC TEST MODE", {"disable"}}, |
| 5177 | + {"MCLK INVERT", {"0"}}, |
| 5178 | + {"BCLK INVERT", {"0"}}, |
| 5179 | + {"MCLK SOURCE", {"from mclk pin"}}, |
| 5180 | + |
| 5181 | + {"DMIC MUX", {"DMIC DISABLE"}}, |
| 5182 | + {"SDP OUT MUX", {"FROM ADC OUT"}}, |
| 5183 | + {"DAC SDP SRC MUX", {"SELECT SDP LEFT DATA"}}, |
| 5184 | + |
| 5185 | + |
| 5186 | + |
| 5187 | +}; |
| 5188 | + |
| 5189 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 5190 | + {"MIC PGA GAIN", {"10"}}, |
| 5191 | + {"ADC SCALE", {"1"}}, |
| 5192 | + {"DMIC TYPE", {"dmic at high level"}}, |
| 5193 | + {"ADC RAMP RATE", {"4"}}, |
| 5194 | + {"ADC SDP MUTE", {"0"}}, |
| 5195 | + {"ADC INVERTED", {"0"}}, |
| 5196 | + {"ADC SYNC", {"0"}}, |
| 5197 | + {"ADC RAM CLR", {"0"}}, |
| 5198 | + {"ADC VOLUME", {"191"}}, |
| 5199 | + {"ALC ENABLE", {"0"}}, |
| 5200 | + {"ALC AUTOMUTE TYPE", {"automute disabled"}}, |
| 5201 | + {"ALC WIN SIZE", {"0"}}, |
| 5202 | + {"ALC MAX LEVEL", {"0"}}, |
| 5203 | + {"ALC MIN LEVEL", {"0"}}, |
| 5204 | + {"ALC AUTOMUTE WINSIZE", {"0"}}, |
| 5205 | + {"ALC AUTOMUTE GATE THRESHOLD", {"0"}}, |
| 5206 | + {"ALC AUTOMUTE VOLUME", {"0"}}, |
| 5207 | + {"ADC FS MODE", {"0"}}, |
| 5208 | + {"DAC SDP MUTE", {"0"}}, |
| 5209 | + {"DAC DEM MUTE", {"0"}}, |
| 5210 | + {"DAC INVERT", {"0"}}, |
| 5211 | + {"DAC RAM CLR", {"0"}}, |
| 5212 | + {"DAC DSM MUTE", {"mute to 8"}}, |
| 5213 | + {"DAC OFFSET", {"0"}}, |
| 5214 | + {"DAC VOLUME", {"191"}}, |
| 5215 | + {"DRC ENABLE", {"0"}}, |
| 5216 | + {"DRC WIN SIZE", {"0"}}, |
| 5217 | + {"DRC MAX LEVEL", {"0"}}, |
| 5218 | + {"DRC MIN LEVEL", {"0"}}, |
| 5219 | + {"DAC RAMP RATE", {"4"}}, |
| 5220 | + {"AEC MODE", {"adc left, adc right"}}, |
| 5221 | + {"ADC DATA TO DAC TEST MODE", {"disable"}}, |
| 5222 | + {"MCLK INVERT", {"0"}}, |
| 5223 | + {"BCLK INVERT", {"0"}}, |
| 5224 | + {"MCLK SOURCE", {"from mclk pin"}}, |
| 5225 | + |
| 5226 | + {"DMIC MUX", {"DMIC DISABLE"}}, |
| 5227 | + {"SDP OUT MUX", {"FROM ADC OUT"}}, |
| 5228 | + {"DAC SDP SRC MUX", {"SELECT SDP LEFT DATA"}}, |
| 5229 | + |
| 5230 | + |
| 5231 | +}; |
| 5232 | + |
| 5233 | +static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚMic1lp_Mic1lmÊäÈëͨµÀ |
| 5234 | + |
| 5235 | + {"MIC PGA GAIN", {"10"}}, |
| 5236 | + {"ADC SCALE", {"1"}}, |
| 5237 | + {"DMIC TYPE", {"dmic at high level"}}, |
| 5238 | + {"ADC RAMP RATE", {"4"}}, |
| 5239 | + {"ADC SDP MUTE", {"0"}}, |
| 5240 | + {"ADC INVERTED", {"0"}}, |
| 5241 | + {"ADC SYNC", {"0"}}, |
| 5242 | + {"ADC RAM CLR", {"0"}}, |
| 5243 | + {"ADC VOLUME", {"191"}}, |
| 5244 | + {"ALC ENABLE", {"0"}}, |
| 5245 | + {"ALC AUTOMUTE TYPE", {"automute disabled"}}, |
| 5246 | + {"ALC WIN SIZE", {"0"}}, |
| 5247 | + {"ALC MAX LEVEL", {"0"}}, |
| 5248 | + {"ALC MIN LEVEL", {"0"}}, |
| 5249 | + {"ALC AUTOMUTE WINSIZE", {"0"}}, |
| 5250 | + {"ALC AUTOMUTE GATE THRESHOLD", {"0"}}, |
| 5251 | + {"ALC AUTOMUTE VOLUME", {"0"}}, |
| 5252 | + {"ADC FS MODE", {"0"}}, |
| 5253 | + {"DAC SDP MUTE", {"0"}}, |
| 5254 | + {"DAC DEM MUTE", {"0"}}, |
| 5255 | + {"DAC INVERT", {"0"}}, |
| 5256 | + {"DAC RAM CLR", {"0"}}, |
| 5257 | + {"DAC DSM MUTE", {"mute to 8"}}, |
| 5258 | + {"DAC OFFSET", {"0"}}, |
| 5259 | + {"DAC VOLUME", {"191"}}, |
| 5260 | + {"DRC ENABLE", {"0"}}, |
| 5261 | + {"DRC WIN SIZE", {"0"}}, |
| 5262 | + {"DRC MAX LEVEL", {"0"}}, |
| 5263 | + {"DRC MIN LEVEL", {"0"}}, |
| 5264 | + {"DAC RAMP RATE", {"4"}}, |
| 5265 | + {"AEC MODE", {"adc left, adc right"}}, |
| 5266 | + {"ADC DATA TO DAC TEST MODE", {"disable"}}, |
| 5267 | + {"MCLK INVERT", {"0"}}, |
| 5268 | + {"BCLK INVERT", {"0"}}, |
| 5269 | + {"MCLK SOURCE", {"from mclk pin"}}, |
| 5270 | + |
| 5271 | + {"DMIC MUX", {"DMIC DISABLE"}}, |
| 5272 | + {"SDP OUT MUX", {"FROM ADC OUT"}}, |
| 5273 | + {"DAC SDP SRC MUX", {"SELECT SDP LEFT DATA"}}, |
| 5274 | + |
| 5275 | +}; |
| 5276 | + |
| 5277 | +static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚMic1rpÊäÈëͨµÀ |
| 5278 | + |
| 5279 | + {"MIC PGA GAIN", {"10"}}, |
| 5280 | + {"ADC SCALE", {"1"}}, |
| 5281 | + {"DMIC TYPE", {"dmic at high level"}}, |
| 5282 | + {"ADC RAMP RATE", {"4"}}, |
| 5283 | + {"ADC SDP MUTE", {"0"}}, |
| 5284 | + {"ADC INVERTED", {"0"}}, |
| 5285 | + {"ADC SYNC", {"0"}}, |
| 5286 | + {"ADC RAM CLR", {"0"}}, |
| 5287 | + {"ADC VOLUME", {"191"}}, |
| 5288 | + {"ALC ENABLE", {"0"}}, |
| 5289 | + {"ALC AUTOMUTE TYPE", {"automute disabled"}}, |
| 5290 | + {"ALC WIN SIZE", {"0"}}, |
| 5291 | + {"ALC MAX LEVEL", {"0"}}, |
| 5292 | + {"ALC MIN LEVEL", {"0"}}, |
| 5293 | + {"ALC AUTOMUTE WINSIZE", {"0"}}, |
| 5294 | + {"ALC AUTOMUTE GATE THRESHOLD", {"0"}}, |
| 5295 | + {"ALC AUTOMUTE VOLUME", {"0"}}, |
| 5296 | + {"ADC FS MODE", {"0"}}, |
| 5297 | + {"DAC SDP MUTE", {"0"}}, |
| 5298 | + {"DAC DEM MUTE", {"0"}}, |
| 5299 | + {"DAC INVERT", {"0"}}, |
| 5300 | + {"DAC RAM CLR", {"0"}}, |
| 5301 | + {"DAC DSM MUTE", {"mute to 8"}}, |
| 5302 | + {"DAC OFFSET", {"0"}}, |
| 5303 | + {"DAC VOLUME", {"191"}}, |
| 5304 | + {"DRC ENABLE", {"0"}}, |
| 5305 | + {"DRC WIN SIZE", {"0"}}, |
| 5306 | + {"DRC MAX LEVEL", {"0"}}, |
| 5307 | + {"DRC MIN LEVEL", {"0"}}, |
| 5308 | + {"DAC RAMP RATE", {"4"}}, |
| 5309 | + {"AEC MODE", {"adc left, adc right"}}, |
| 5310 | + {"ADC DATA TO DAC TEST MODE", {"disable"}}, |
| 5311 | + {"MCLK INVERT", {"0"}}, |
| 5312 | + {"BCLK INVERT", {"0"}}, |
| 5313 | + {"MCLK SOURCE", {"from mclk pin"}}, |
| 5314 | + |
| 5315 | + {"DMIC MUX", {"DMIC DISABLE"}}, |
| 5316 | + {"SDP OUT MUX", {"FROM ADC OUT"}}, |
| 5317 | + {"DAC SDP SRC MUX", {"SELECT SDP LEFT DATA"}}, |
| 5318 | + |
| 5319 | + |
| 5320 | + |
| 5321 | +}; |
| 5322 | + |
| 5323 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 5324 | + {"MIC PGA GAIN", {"10"}}, |
| 5325 | + {"ADC SCALE", {"1"}}, |
| 5326 | + {"DMIC TYPE", {"dmic at high level"}}, |
| 5327 | + {"ADC RAMP RATE", {"4"}}, |
| 5328 | + {"ADC SDP MUTE", {"0"}}, |
| 5329 | + {"ADC INVERTED", {"0"}}, |
| 5330 | + {"ADC SYNC", {"0"}}, |
| 5331 | + {"ADC RAM CLR", {"0"}}, |
| 5332 | + {"ADC VOLUME", {"191"}}, |
| 5333 | + {"ALC ENABLE", {"0"}}, |
| 5334 | + {"ALC AUTOMUTE TYPE", {"automute disabled"}}, |
| 5335 | + {"ALC WIN SIZE", {"0"}}, |
| 5336 | + {"ALC MAX LEVEL", {"0"}}, |
| 5337 | + {"ALC MIN LEVEL", {"0"}}, |
| 5338 | + {"ALC AUTOMUTE WINSIZE", {"0"}}, |
| 5339 | + {"ALC AUTOMUTE GATE THRESHOLD", {"0"}}, |
| 5340 | + {"ALC AUTOMUTE VOLUME", {"0"}}, |
| 5341 | + {"ADC FS MODE", {"0"}}, |
| 5342 | + {"DAC SDP MUTE", {"0"}}, |
| 5343 | + {"DAC DEM MUTE", {"0"}}, |
| 5344 | + {"DAC INVERT", {"0"}}, |
| 5345 | + {"DAC RAM CLR", {"0"}}, |
| 5346 | + {"DAC DSM MUTE", {"mute to 8"}}, |
| 5347 | + {"DAC OFFSET", {"0"}}, |
| 5348 | + {"DAC VOLUME", {"191"}}, |
| 5349 | + {"DRC ENABLE", {"0"}}, |
| 5350 | + {"DRC WIN SIZE", {"0"}}, |
| 5351 | + {"DRC MAX LEVEL", {"0"}}, |
| 5352 | + {"DRC MIN LEVEL", {"0"}}, |
| 5353 | + {"DAC RAMP RATE", {"4"}}, |
| 5354 | + {"AEC MODE", {"adc left, adc right"}}, |
| 5355 | + {"ADC DATA TO DAC TEST MODE", {"disable"}}, |
| 5356 | + {"MCLK INVERT", {"0"}}, |
| 5357 | + {"BCLK INVERT", {"0"}}, |
| 5358 | + {"MCLK SOURCE", {"from mclk pin"}}, |
| 5359 | + |
| 5360 | + {"DMIC MUX", {"DMIC DISABLE"}}, |
| 5361 | + {"SDP OUT MUX", {"FROM ADC OUT"}}, |
| 5362 | + {"DAC SDP SRC MUX", {"SELECT SDP LEFT DATA"}}, |
| 5363 | + |
| 5364 | + |
| 5365 | + |
| 5366 | +}; |
| 5367 | + |
| 5368 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ |
| 5369 | + {"MIC PGA GAIN", {"10"}}, |
| 5370 | + {"ADC SCALE", {"1"}}, |
| 5371 | + {"DMIC TYPE", {"dmic at high level"}}, |
| 5372 | + {"ADC RAMP RATE", {"4"}}, |
| 5373 | + {"ADC SDP MUTE", {"0"}}, |
| 5374 | + {"ADC INVERTED", {"0"}}, |
| 5375 | + {"ADC SYNC", {"0"}}, |
| 5376 | + {"ADC RAM CLR", {"0"}}, |
| 5377 | + {"ADC VOLUME", {"191"}}, |
| 5378 | + {"ALC ENABLE", {"0"}}, |
| 5379 | + {"ALC AUTOMUTE TYPE", {"automute disabled"}}, |
| 5380 | + {"ALC WIN SIZE", {"0"}}, |
| 5381 | + {"ALC MAX LEVEL", {"0"}}, |
| 5382 | + {"ALC MIN LEVEL", {"0"}}, |
| 5383 | + {"ALC AUTOMUTE WINSIZE", {"0"}}, |
| 5384 | + {"ALC AUTOMUTE GATE THRESHOLD", {"0"}}, |
| 5385 | + {"ALC AUTOMUTE VOLUME", {"0"}}, |
| 5386 | + {"ADC FS MODE", {"0"}}, |
| 5387 | + {"DAC SDP MUTE", {"0"}}, |
| 5388 | + {"DAC DEM MUTE", {"0"}}, |
| 5389 | + {"DAC INVERT", {"0"}}, |
| 5390 | + {"DAC RAM CLR", {"0"}}, |
| 5391 | + {"DAC DSM MUTE", {"mute to 8"}}, |
| 5392 | + {"DAC OFFSET", {"0"}}, |
| 5393 | + {"DAC VOLUME", {"191"}}, |
| 5394 | + {"DRC ENABLE", {"0"}}, |
| 5395 | + {"DRC WIN SIZE", {"0"}}, |
| 5396 | + {"DRC MAX LEVEL", {"0"}}, |
| 5397 | + {"DRC MIN LEVEL", {"0"}}, |
| 5398 | + {"DAC RAMP RATE", {"4"}}, |
| 5399 | + {"AEC MODE", {"adc left, adc right"}}, |
| 5400 | + {"ADC DATA TO DAC TEST MODE", {"disable"}}, |
| 5401 | + {"MCLK INVERT", {"0"}}, |
| 5402 | + {"BCLK INVERT", {"0"}}, |
| 5403 | + {"MCLK SOURCE", {"from mclk pin"}}, |
| 5404 | + |
| 5405 | + {"DMIC MUX", {"DMIC DISABLE"}}, |
| 5406 | + {"SDP OUT MUX", {"FROM ADC OUT"}}, |
| 5407 | + {"DAC SDP SRC MUX", {"SELECT SDP LEFT DATA"}}, |
| 5408 | +}; |
| 5409 | + |
| 5410 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 5411 | + |
| 5412 | + {"MIC PGA GAIN", {"10"}}, |
| 5413 | + {"ADC SCALE", {"1"}}, |
| 5414 | + {"DMIC TYPE", {"dmic at high level"}}, |
| 5415 | + {"ADC RAMP RATE", {"4"}}, |
| 5416 | + {"ADC SDP MUTE", {"0"}}, |
| 5417 | + {"ADC INVERTED", {"0"}}, |
| 5418 | + {"ADC SYNC", {"0"}}, |
| 5419 | + {"ADC RAM CLR", {"0"}}, |
| 5420 | + {"ADC VOLUME", {"191"}}, |
| 5421 | + {"ALC ENABLE", {"0"}}, |
| 5422 | + {"ALC AUTOMUTE TYPE", {"automute disabled"}}, |
| 5423 | + {"ALC WIN SIZE", {"0"}}, |
| 5424 | + {"ALC MAX LEVEL", {"0"}}, |
| 5425 | + {"ALC MIN LEVEL", {"0"}}, |
| 5426 | + {"ALC AUTOMUTE WINSIZE", {"0"}}, |
| 5427 | + {"ALC AUTOMUTE GATE THRESHOLD", {"0"}}, |
| 5428 | + {"ALC AUTOMUTE VOLUME", {"0"}}, |
| 5429 | + {"ADC FS MODE", {"0"}}, |
| 5430 | + {"DAC SDP MUTE", {"0"}}, |
| 5431 | + {"DAC DEM MUTE", {"0"}}, |
| 5432 | + {"DAC INVERT", {"0"}}, |
| 5433 | + {"DAC RAM CLR", {"0"}}, |
| 5434 | + {"DAC DSM MUTE", {"mute to 8"}}, |
| 5435 | + {"DAC OFFSET", {"0"}}, |
| 5436 | + {"DAC VOLUME", {"191"}}, |
| 5437 | + {"DRC ENABLE", {"0"}}, |
| 5438 | + {"DRC WIN SIZE", {"0"}}, |
| 5439 | + {"DRC MAX LEVEL", {"0"}}, |
| 5440 | + {"DRC MIN LEVEL", {"0"}}, |
| 5441 | + {"DAC RAMP RATE", {"4"}}, |
| 5442 | + {"AEC MODE", {"adc left, adc right"}}, |
| 5443 | + {"ADC DATA TO DAC TEST MODE", {"disable"}}, |
| 5444 | + {"MCLK INVERT", {"0"}}, |
| 5445 | + {"BCLK INVERT", {"0"}}, |
| 5446 | + {"MCLK SOURCE", {"from mclk pin"}}, |
| 5447 | + |
| 5448 | + {"DMIC MUX", {"DMIC DISABLE"}}, |
| 5449 | + {"SDP OUT MUX", {"FROM ADC OUT"}}, |
| 5450 | + {"DAC SDP SRC MUX", {"SELECT SDP LEFT DATA"}}, |
| 5451 | +}; |
| 5452 | + |
| 5453 | + |
| 5454 | +static struct audio_para_conf output_dac_vol = { |
| 5455 | + //"Playback Volume", {"255"} |
| 5456 | + {"DAC VOLUME", {"191"}}, |
| 5457 | + |
| 5458 | + |
| 5459 | +}; |
| 5460 | + |
| 5461 | +static struct audio_para_conf input_adc_vol = { |
| 5462 | + //"Capture Volume", {"255"} |
| 5463 | + {"ADC VOLUME", {"191"}}, |
| 5464 | + |
| 5465 | +}; |
| 5466 | + |
| 5467 | +static struct audio_para_conf dac_mute = { |
| 5468 | + //"DAC MUTE", {"1"} |
| 5469 | + {"DAC SDP MUTE", {"0"}}, |
| 5470 | + {"DAC DEM MUTE", {"0"}}, |
| 5471 | + |
| 5472 | + |
| 5473 | +}; |
| 5474 | +static struct audio_para_conf adc_mute = { |
| 5475 | + //"Input Boost Stage PGA Mute Switch", {"0"} |
| 5476 | + {"ADC SDP MUTE", {"0"}}, |
| 5477 | + |
| 5478 | + |
| 5479 | +}; |
| 5480 | + |
| 5481 | +static struct audio_para_conf spk_path_onoff[] = { |
| 5482 | + //{"Mono Mixer PCM Playback Switch", {"0"}}, |
| 5483 | + {"DAC SDP MUTE", {"0"}}, |
| 5484 | + {"DAC DEM MUTE", {"0"}}, |
| 5485 | + |
| 5486 | + |
| 5487 | +}; |
| 5488 | + |
| 5489 | +static struct audio_para_conf rcv_path_onoff[] = { |
| 5490 | + //{"Mono Mixer PCM Playback Switch", {"0"}}, |
| 5491 | + {"ADC SDP MUTE", {"0"}}, |
| 5492 | + |
| 5493 | +}; |
| 5494 | + |
| 5495 | +static struct audio_para_conf earp_path_onoff[] = { |
| 5496 | + //{"Speaker Mixer PCM Playback Switch", {"0"}}, |
| 5497 | + {"DAC SDP MUTE", {"0"}}, |
| 5498 | + {"DAC DEM MUTE", {"0"}}, |
| 5499 | +}; |
| 5500 | + |
| 5501 | +/* yu.dong@20240627 [T106BUG-615]CODEC 8311 using voice_demo to set codec volume has no effect start */ |
| 5502 | + |
| 5503 | +/* yu.dong@20240716 [T106BUG-615]Abnormal whistling tone heard on the side of the phone when dialing in 3G network start */ |
| 5504 | +enum t_input_vol { |
| 5505 | + T_INPUT_VOL_MINUS_96DB = 0, |
| 5506 | + T_INPUT_VOL_MINUS_95DB = 2, |
| 5507 | + T_INPUT_VOL_MINUS_90DB = 12, |
| 5508 | + T_INPUT_VOL_MINUS_85DB = 22, |
| 5509 | + T_INPUT_VOL_MINUS_80DB = 32, |
| 5510 | + T_INPUT_VOL_MINUS_75DB = 42, |
| 5511 | + T_INPUT_VOL_MINUS_70DB = 52, |
| 5512 | + T_INPUT_VOL_MINUS_65DB = 62, |
| 5513 | + T_INPUT_VOL_MINUS_60DB = 72, |
| 5514 | + T_INPUT_VOL_MINUS_55DB = 82, |
| 5515 | + T_INPUT_VOL_MINUS_50DB = 92, |
| 5516 | + T_INPUT_VOL_MINUS_45DB = 102, |
| 5517 | + T_INPUT_VOL_MINUS_40DB = 112, |
| 5518 | + T_INPUT_VOL_MINUS_35DB = 122, |
| 5519 | + T_INPUT_VOL_MINUS_30DB = 132, |
| 5520 | + T_INPUT_VOL_MINUS_25DB = 142, |
| 5521 | + T_INPUT_VOL_MINUS_20DB = 152, |
| 5522 | + T_INPUT_VOL_MINUS_15DB = 162, |
| 5523 | + T_INPUT_VOL_MINUS_10DB = 172, |
| 5524 | + T_INPUT_VOL_MINUS_7DB = 178, |
| 5525 | + T_INPUT_VOL_MINUS_6DB = 180, |
| 5526 | + T_INPUT_VOL_MINUS_5DB = 182, |
| 5527 | + T_INPUT_VOL_MINUS_4DB = 184, |
| 5528 | + T_INPUT_VOL_MINUS_3DB = 186, |
| 5529 | + T_INPUT_VOL_MINUS_2DB = 188, |
| 5530 | + T_INPUT_VOL_MINUS_1DB = 190, |
| 5531 | + T_INPUT_VOL_0DB = 192 |
| 5532 | +}; |
| 5533 | + |
| 5534 | +static int input_vol_conversion(int vol) |
| 5535 | +{ |
| 5536 | + switch(vol) { |
| 5537 | + case T_AUDIO_INPUT_VOL_LEVEL_0: |
| 5538 | + return T_INPUT_VOL_MINUS_96DB; |
| 5539 | + case T_AUDIO_INPUT_VOL_LEVEL_1: |
| 5540 | + return T_INPUT_VOL_MINUS_30DB; |
| 5541 | + case T_AUDIO_INPUT_VOL_LEVEL_2: |
| 5542 | + return T_INPUT_VOL_MINUS_25DB; |
| 5543 | + case T_AUDIO_INPUT_VOL_LEVEL_3: |
| 5544 | + return T_INPUT_VOL_MINUS_20DB; |
| 5545 | + case T_AUDIO_INPUT_VOL_LEVEL_4: |
| 5546 | + return T_INPUT_VOL_MINUS_15DB; |
| 5547 | + case T_AUDIO_INPUT_VOL_LEVEL_5: |
| 5548 | + return T_INPUT_VOL_MINUS_10DB; |
| 5549 | + case T_AUDIO_INPUT_VOL_LEVEL_6: |
| 5550 | + return T_INPUT_VOL_MINUS_7DB; |
| 5551 | + case T_AUDIO_INPUT_VOL_LEVEL_7: |
| 5552 | + return T_INPUT_VOL_MINUS_4DB; |
| 5553 | + case T_AUDIO_INPUT_VOL_LEVEL_8: |
| 5554 | + return T_INPUT_VOL_MINUS_3DB; |
| 5555 | + case T_AUDIO_INPUT_VOL_LEVEL_9: |
| 5556 | + return T_INPUT_VOL_MINUS_2DB; |
| 5557 | + case T_AUDIO_INPUT_VOL_LEVEL_10: |
| 5558 | + return T_INPUT_VOL_MINUS_1DB; |
| 5559 | + case T_AUDIO_INPUT_VOL_LEVEL_11: |
| 5560 | + return T_INPUT_VOL_0DB; |
| 5561 | + default: |
| 5562 | + return T_INPUT_VOL_MINUS_30DB; |
| 5563 | + } |
| 5564 | +} |
| 5565 | +/* yu.dong@20240716 [T106BUG-615]Abnormal whistling tone heard on the side of the phone when dialing in 3G network end */ |
| 5566 | + |
| 5567 | +enum t_output_vol { |
| 5568 | + T_OUTPUT_VOL_MINUS_96DB = 0, |
| 5569 | + T_OUTPUT_VOL_MINUS_95DB = 2, |
| 5570 | + T_OUTPUT_VOL_MINUS_90DB = 12, |
| 5571 | + T_OUTPUT_VOL_MINUS_85DB = 22, |
| 5572 | + T_OUTPUT_VOL_MINUS_80DB = 32, |
| 5573 | + T_OUTPUT_VOL_MINUS_75DB = 42, |
| 5574 | + T_OUTPUT_VOL_MINUS_70DB = 52, |
| 5575 | + T_OUTPUT_VOL_MINUS_65DB = 62, |
| 5576 | + T_OUTPUT_VOL_MINUS_60DB = 72, |
| 5577 | + T_OUTPUT_VOL_MINUS_55DB = 82, |
| 5578 | + T_OUTPUT_VOL_MINUS_50DB = 92, |
| 5579 | + T_OUTPUT_VOL_MINUS_45DB = 102, |
| 5580 | + T_OUTPUT_VOL_MINUS_40DB = 112, |
| 5581 | + T_OUTPUT_VOL_MINUS_35DB = 122, |
| 5582 | + T_OUTPUT_VOL_MINUS_30DB = 132, |
| 5583 | + T_OUTPUT_VOL_MINUS_25DB = 142, |
| 5584 | + T_OUTPUT_VOL_MINUS_20DB = 152, |
| 5585 | + T_OUTPUT_VOL_MINUS_15DB = 162, |
| 5586 | + T_OUTPUT_VOL_MINUS_10DB = 172, |
| 5587 | + T_OUTPUT_VOL_MINUS_7DB = 178, |
| 5588 | + T_OUTPUT_VOL_MINUS_6DB = 180, |
| 5589 | + T_OUTPUT_VOL_MINUS_5DB = 182, |
| 5590 | + T_OUTPUT_VOL_MINUS_4DB = 184, |
| 5591 | + T_OUTPUT_VOL_MINUS_3DB = 186, |
| 5592 | + T_OUTPUT_VOL_MINUS_2DB = 188, |
| 5593 | + T_OUTPUT_VOL_MINUS_1DB = 190, |
| 5594 | + T_OUTPUT_VOL_0DB = 192 |
| 5595 | +}; |
| 5596 | + |
| 5597 | + static int output_vol_conversion(int vol) |
| 5598 | +{ |
| 5599 | + switch(vol){ |
| 5600 | + case T_AUDIO_OUTPUT_VOL_LEVEL_0: |
| 5601 | + return T_OUTPUT_VOL_MINUS_96DB; |
| 5602 | + case T_AUDIO_OUTPUT_VOL_LEVEL_1: |
| 5603 | + return T_OUTPUT_VOL_MINUS_45DB; |
| 5604 | + case T_AUDIO_OUTPUT_VOL_LEVEL_2: |
| 5605 | + return T_OUTPUT_VOL_MINUS_40DB; |
| 5606 | + case T_AUDIO_OUTPUT_VOL_LEVEL_3: |
| 5607 | + return T_OUTPUT_VOL_MINUS_35DB; |
| 5608 | + case T_AUDIO_OUTPUT_VOL_LEVEL_4: |
| 5609 | + return T_OUTPUT_VOL_MINUS_30DB; |
| 5610 | + case T_AUDIO_OUTPUT_VOL_LEVEL_5: |
| 5611 | + return T_OUTPUT_VOL_MINUS_25DB; |
| 5612 | + case T_AUDIO_OUTPUT_VOL_LEVEL_6: |
| 5613 | + return T_OUTPUT_VOL_MINUS_20DB; |
| 5614 | + case T_AUDIO_OUTPUT_VOL_LEVEL_7: |
| 5615 | + return T_OUTPUT_VOL_MINUS_15DB; |
| 5616 | + case T_AUDIO_OUTPUT_VOL_LEVEL_8: |
| 5617 | + return T_OUTPUT_VOL_MINUS_10DB; |
| 5618 | + case T_AUDIO_OUTPUT_VOL_LEVEL_9: |
| 5619 | + return T_OUTPUT_VOL_MINUS_6DB; |
| 5620 | + case T_AUDIO_OUTPUT_VOL_LEVEL_10: |
| 5621 | + return T_OUTPUT_VOL_MINUS_3DB; |
| 5622 | + case T_AUDIO_OUTPUT_VOL_LEVEL_11: |
| 5623 | + return T_OUTPUT_VOL_0DB; |
| 5624 | + default: |
| 5625 | + return T_OUTPUT_VOL_0DB; |
| 5626 | + } |
| 5627 | +} |
| 5628 | + |
| 5629 | +/* yu.dong@20240627 [T106BUG-615]CODEC 8311 using voice_demo to set codec volume has no effect end */ |
| 5630 | + |
| 5631 | +//l.yang modify for bug id T106BUG-337 2023/11/9 start |
| 5632 | +#elif defined _USE_CODEC_TI3104 |
| 5633 | + |
| 5634 | +static struct audio_para_conf init_default_para[] = { //¿¿¿¿¿¿¿ |
| 5635 | + |
| 5636 | +}; |
| 5637 | + |
| 5638 | +static struct audio_para_conf common_out_para_audio[] = { //¿¿¿¿¿¿ |
| 5639 | + //{"DAC Soft Mute Control", {"0"}}, |
| 5640 | +}; |
| 5641 | + |
| 5642 | + |
| 5643 | +static struct audio_para_conf common_in_para_audio[] = { //¿¿¿¿¿¿ |
| 5644 | + //{"Mic Gain Control", {"0"}}, |
| 5645 | +}; |
| 5646 | + |
| 5647 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¿¿¿Hp¿¿¿¿ |
| 5648 | + {"Line Playback Switch", {"1","1"}}, |
| 5649 | + {"PCM Playback Volume", {"110","110"}}, |
| 5650 | + {"Line Playback Volume", {"8","8"}}, |
| 5651 | + {"Line DAC Playback Volume", {"110","110"}}, |
| 5652 | +}; |
| 5653 | + |
| 5654 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¿¿¿Spk¿¿¿¿ |
| 5655 | + {"Line Playback Switch", {"1","1"}}, |
| 5656 | + {"PCM Playback Volume", {"110","110"}}, |
| 5657 | + {"Line Playback Volume", {"8","8"}}, |
| 5658 | + {"Line DAC Playback Volume", {"110","110"}}, |
| 5659 | +}; |
| 5660 | + |
| 5661 | +static struct audio_para_conf main_mic_inpath_para_audio[] = { //¿¿¿Mic1lp_Mic1lm¿¿¿¿ |
| 5662 | + {"MicBias VG", {"1"}}, |
| 5663 | + {"PGA Capture Volume", {"50","50"}}, //yu.dong@20240821 [AUDIO] Fix audio return tone problem on speakerphone |
| 5664 | + {"PGA Capture Switch", {"1","1"}}, |
| 5665 | + {"ADC HPF Cut-off", {"1","1"}}, |
| 5666 | + |
| 5667 | + {"Left PGA Mixer Mic2L Switch",{"1"}}, |
| 5668 | + {"Left PGA Mixer Mic2R Switch",{"1"}}, |
| 5669 | + {"Right PGA Mixer Mic2L Switch",{"1"}}, |
| 5670 | + {"Right PGA Mixer Mic2R Switch",{"1"}}, |
| 5671 | +}; |
| 5672 | + |
| 5673 | +static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¿¿¿Mic1rp¿¿¿¿ |
| 5674 | + {"MicBias VG", {"1"}}, |
| 5675 | + {"PGA Capture Volume", {"50","50"}}, //yu.dong@20240821 [AUDIO] Fix audio return tone problem on speakerphone |
| 5676 | + {"PGA Capture Switch", {"1","1"}}, |
| 5677 | + {"ADC HPF Cut-off", {"1","1"}}, |
| 5678 | + |
| 5679 | + {"Left PGA Mixer Mic2L Switch",{"1"}}, |
| 5680 | + {"Left PGA Mixer Mic2R Switch",{"1"}}, |
| 5681 | + {"Right PGA Mixer Mic2L Switch",{"1"}}, |
| 5682 | + {"Right PGA Mixer Mic2R Switch",{"1"}}, |
| 5683 | +}; |
| 5684 | + |
| 5685 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¿¿¿Hp¿¿¿¿Mic1lp_Mic1lm¿¿¿¿ |
| 5686 | + //in |
| 5687 | + //#0x2d b6 pga mute |
| 5688 | + {"MicBias VG", {"1"}}, |
| 5689 | + {"PGA Capture Volume", {"50","50"}}, //yu.dong@20240821 [AUDIO] Fix audio return tone problem on speakerphone |
| 5690 | + {"PGA Capture Switch", {"1","1"}}, |
| 5691 | + {"ADC HPF Cut-off", {"1","1"}}, |
| 5692 | + |
| 5693 | + {"Left PGA Mixer Mic2L Switch",{"1"}}, |
| 5694 | + {"Left PGA Mixer Mic2R Switch",{"1"}}, |
| 5695 | + {"Right PGA Mixer Mic2L Switch",{"1"}}, |
| 5696 | + {"Right PGA Mixer Mic2R Switch",{"1"}}, |
| 5697 | + |
| 5698 | + //out |
| 5699 | + {"Line Playback Switch", {"1","1"}}, |
| 5700 | + {"PCM Playback Volume", {"110","110"}}, |
| 5701 | + {"Line Playback Volume", {"8","8"}}, |
| 5702 | + {"Line DAC Playback Volume", {"110","110"}}, |
| 5703 | + |
| 5704 | + //voice |
| 5705 | + #ifndef USE_CAP_SUPPORT |
| 5706 | + {"voice processing path select", {"handset"}}, // handset speak headset bluetooth |
| 5707 | + #endif |
| 5708 | +}; |
| 5709 | + |
| 5710 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { //¿¿¿Hp¿¿¿¿ Mic1rp¿¿¿¿ |
| 5711 | + //in |
| 5712 | + //#0x2d b6 pga mute |
| 5713 | + {"MicBias VG", {"1"}}, |
| 5714 | + {"PGA Capture Volume", {"50","50"}}, //yu.dong@20240821 [AUDIO] Fix audio return tone problem on speakerphone |
| 5715 | + {"PGA Capture Switch", {"1","1"}}, |
| 5716 | + {"ADC HPF Cut-off", {"1","1"}}, |
| 5717 | + |
| 5718 | + {"Left PGA Mixer Mic2L Switch",{"1"}}, |
| 5719 | + {"Left PGA Mixer Mic2R Switch",{"1"}}, |
| 5720 | + {"Right PGA Mixer Mic2L Switch",{"1"}}, |
| 5721 | + {"Right PGA Mixer Mic2R Switch",{"1"}}, |
| 5722 | + |
| 5723 | + //out |
| 5724 | + {"Line Playback Switch", {"1","1"}}, |
| 5725 | + {"PCM Playback Volume", {"110","110"}}, |
| 5726 | + {"Line Playback Volume", {"8","8"}}, |
| 5727 | + {"Line DAC Playback Volume", {"110","110"}}, |
| 5728 | + |
| 5729 | + //voice |
| 5730 | + #ifndef USE_CAP_SUPPORT |
| 5731 | + {"voice processing select", {"headset"}}, // handset speak headset bluetooth |
| 5732 | + #endif |
| 5733 | +}; |
| 5734 | + |
| 5735 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¿¿¿Spk¿¿¿¿Mic1lp_Mic1lm¿¿¿¿ |
| 5736 | + //in |
| 5737 | + //#0x2d b6 pga mute |
| 5738 | + {"MicBias VG", {"1"}}, |
| 5739 | + {"PGA Capture Volume", {"50","50"}}, //yu.dong@20240821 [AUDIO] Fix audio return tone problem on speakerphone |
| 5740 | + {"PGA Capture Switch", {"1","1"}}, |
| 5741 | + {"ADC HPF Cut-off", {"1","1"}}, |
| 5742 | + |
| 5743 | + {"Left PGA Mixer Mic2L Switch",{"1"}}, |
| 5744 | + {"Left PGA Mixer Mic2R Switch",{"1"}}, |
| 5745 | + {"Right PGA Mixer Mic2L Switch",{"1"}}, |
| 5746 | + {"Right PGA Mixer Mic2R Switch",{"1"}}, |
| 5747 | + |
| 5748 | + //out |
| 5749 | + {"Line Playback Switch", {"1","1"}}, |
| 5750 | + {"PCM Playback Volume", {"110","110"}}, |
| 5751 | + {"Line Playback Volume", {"8","8"}}, |
| 5752 | + {"Line DAC Playback Volume", {"110","110"}}, |
| 5753 | + //voice |
| 5754 | + |
| 5755 | + #ifndef USE_CAP_SUPPORT |
| 5756 | + {"voice processing path select", {"speak"}}, // handset speak headset bluetooth |
| 5757 | + #endif |
| 5758 | +}; |
| 5759 | + |
| 5760 | +static struct audio_para_conf output_dac_vol = { |
| 5761 | + {"PCM Playback Volume", {"110","110"}}, |
| 5762 | +}; |
| 5763 | + |
| 5764 | +static struct audio_para_conf input_adc_vol = { |
| 5765 | + {"PGA Capture Volume", {"50","50"}}, //yu.dong@20240821 [AUDIO] Fix audio return tone problem on speakerphone |
| 5766 | +}; |
| 5767 | + |
| 5768 | +static struct audio_para_conf dac_mute = { |
| 5769 | + "Line Playback Switch", {"0","0"} |
| 5770 | +}; |
| 5771 | + |
| 5772 | +static struct audio_para_conf adc_mute = { |
| 5773 | + "MicBias VG", {"0"} |
| 5774 | +}; |
| 5775 | + |
| 5776 | +static struct audio_para_conf spk_path_onoff[] = { |
| 5777 | + {"Mono Mixer PCM Playback Switch", {"0"}}, |
| 5778 | +}; |
| 5779 | + |
| 5780 | +static struct audio_para_conf rcv_path_onoff[] = { |
| 5781 | + {"Mono Mixer PCM Playback Switch", {"0"}}, |
| 5782 | +}; |
| 5783 | + |
| 5784 | +static struct audio_para_conf earp_path_onoff[] = { |
| 5785 | + {"Speaker Mixer PCM Playback Switch", {"0"}}, |
| 5786 | +}; |
| 5787 | + |
| 5788 | +static int output_vol_conversion(int vol) |
| 5789 | +{ |
| 5790 | + return 120; |
| 5791 | +} |
| 5792 | + |
| 5793 | +static int input_vol_conversion(int vol) |
| 5794 | +{ |
| 5795 | + return 100; |
| 5796 | +} |
| 5797 | +//l.yang modify for bug id T106BUG-337 2023/11/9 end |
| 5798 | + |
| 5799 | +#elif defined _USE_CODEC_ES8374 |
| 5800 | + |
| 5801 | + |
| 5802 | +enum t_output_vol { |
| 5803 | + T_OUTPUT_VOL_MINUS_96DB = 0, |
| 5804 | + T_OUTPUT_VOL_MINUS_95DB = 2, |
| 5805 | + T_OUTPUT_VOL_MINUS_90DB = 12, |
| 5806 | + T_OUTPUT_VOL_MINUS_85DB = 22, |
| 5807 | + T_OUTPUT_VOL_MINUS_80DB = 32, |
| 5808 | + T_OUTPUT_VOL_MINUS_75DB = 42, |
| 5809 | + T_OUTPUT_VOL_MINUS_70DB = 52, |
| 5810 | + T_OUTPUT_VOL_MINUS_65DB = 62, |
| 5811 | + T_OUTPUT_VOL_MINUS_60DB = 72, |
| 5812 | + T_OUTPUT_VOL_MINUS_55DB = 82, |
| 5813 | + T_OUTPUT_VOL_MINUS_50DB = 92, |
| 5814 | + T_OUTPUT_VOL_MINUS_45DB = 102, |
| 5815 | + T_OUTPUT_VOL_MINUS_40DB = 112, |
| 5816 | + T_OUTPUT_VOL_MINUS_35DB = 122, |
| 5817 | + T_OUTPUT_VOL_MINUS_30DB = 132, |
| 5818 | + T_OUTPUT_VOL_MINUS_25DB = 142, |
| 5819 | + T_OUTPUT_VOL_MINUS_20DB = 152, |
| 5820 | + T_OUTPUT_VOL_MINUS_15DB = 162, |
| 5821 | + T_OUTPUT_VOL_MINUS_10DB = 172, |
| 5822 | + T_OUTPUT_VOL_MINUS_7DB = 178, |
| 5823 | + T_OUTPUT_VOL_MINUS_6DB = 180, |
| 5824 | + T_OUTPUT_VOL_MINUS_5DB = 182, |
| 5825 | + T_OUTPUT_VOL_MINUS_4DB = 184, |
| 5826 | + T_OUTPUT_VOL_MINUS_3DB = 186, |
| 5827 | + T_OUTPUT_VOL_MINUS_2DB = 188, |
| 5828 | + T_OUTPUT_VOL_MINUS_1DB = 190, |
| 5829 | + T_OUTPUT_VOL_0DB = 192 |
| 5830 | +}; |
| 5831 | + |
| 5832 | +enum t_input_vol { |
| 5833 | + T_INPUT_VOL_MINUS_96DB = 0, |
| 5834 | + T_INPUT_VOL_MINUS_95DB = 2, |
| 5835 | + T_INPUT_VOL_MINUS_90DB = 12, |
| 5836 | + T_INPUT_VOL_MINUS_85DB = 22, |
| 5837 | + T_INPUT_VOL_MINUS_80DB = 32, |
| 5838 | + T_INPUT_VOL_MINUS_75DB = 42, |
| 5839 | + T_INPUT_VOL_MINUS_70DB = 52, |
| 5840 | + T_INPUT_VOL_MINUS_65DB = 62, |
| 5841 | + T_INPUT_VOL_MINUS_60DB = 72, |
| 5842 | + T_INPUT_VOL_MINUS_55DB = 82, |
| 5843 | + T_INPUT_VOL_MINUS_50DB = 92, |
| 5844 | + T_INPUT_VOL_MINUS_45DB = 102, |
| 5845 | + T_INPUT_VOL_MINUS_40DB = 112, |
| 5846 | + T_INPUT_VOL_MINUS_35DB = 122, |
| 5847 | + T_INPUT_VOL_MINUS_30DB = 132, |
| 5848 | + T_INPUT_VOL_MINUS_25DB = 142, |
| 5849 | + T_INPUT_VOL_MINUS_20DB = 152, |
| 5850 | + T_INPUT_VOL_MINUS_15DB = 162, |
| 5851 | + T_INPUT_VOL_MINUS_10DB = 172, |
| 5852 | + T_INPUT_VOL_MINUS_7DB = 178, |
| 5853 | + T_INPUT_VOL_MINUS_6DB = 180, |
| 5854 | + T_INPUT_VOL_MINUS_5DB = 182, |
| 5855 | + T_INPUT_VOL_MINUS_4DB = 184, |
| 5856 | + T_INPUT_VOL_MINUS_3DB = 186, |
| 5857 | + T_INPUT_VOL_MINUS_2DB = 188, |
| 5858 | + T_INPUT_VOL_MINUS_1DB = 190, |
| 5859 | + T_INPUT_VOL_0DB = 192 |
| 5860 | +}; |
| 5861 | + |
| 5862 | + |
| 5863 | +static struct audio_para_conf init_default_para[] = { //¿ª»ú³õʼ»¯µ÷Óà |
| 5864 | + {"DMIC MUX", {"0"}}, |
| 5865 | + {"SDP OUT MUX", {"0"}}, |
| 5866 | + {"ALC MUX", {"0"}}, |
| 5867 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 5868 | + {"LIN PGA GAIN", {"6"}}, |
| 5869 | + {"ADC Capture Volume", {"192"}}, |
| 5870 | + {"ALC Capture Max PGA", {"15"}}, |
| 5871 | + {"DAC MUTE", {"0"}}, |
| 5872 | + {"DAC Playback Volume", {"120"}}, |
| 5873 | + {"DAC SDP SRC MUX", {"0"}}, |
| 5874 | + {"DAC SRC MUX", {"0"}} |
| 5875 | +}; |
| 5876 | + |
| 5877 | +//#ifdef _USE_7520V3_PHONE_TYPE_C31F |
| 5878 | +#if ( defined _USE_7520V3_PHONE_TYPE_C31F || defined _USE_7520V3_PHONE_TYPE_WTWD ) |
| 5879 | + |
| 5880 | +static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 5881 | + {"DAC MUTE", {"0"}}, |
| 5882 | + //{"DAC Playback Volume", {"120"}}, |
| 5883 | + {"DAC SDP SRC MUX", {"0"}}, |
| 5884 | + {"DAC SRC MUX", {"0"}} |
| 5885 | +}; |
| 5886 | + |
| 5887 | +static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 5888 | + {"DMIC MUX", {"0"}}, |
| 5889 | + {"SDP OUT MUX", {"0"}}, |
| 5890 | + {"ADC Soft Ramp", {"0"}}, |
| 5891 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 5892 | +#if 0 |
| 5893 | + {"ALC MUX", {"1"}}, |
| 5894 | + {"ALC Capture Target Volume", {"5"}}, |
| 5895 | + {"ALC Capture Max PGA", {"11"}}, |
| 5896 | + {"ALC Capture Min PGA", {"2"}}, |
| 5897 | + {"ALC Capture Hold Time", {"0"}}, |
| 5898 | + {"ALC Capture Decay Time", {"0"}}, |
| 5899 | + {"ALC Capture Attack Time", {"0"}}, |
| 5900 | + {"ALC WIN SIZE", {"6"}}, |
| 5901 | + {"ALC Capture NG Threshold", {"14"}}, |
| 5902 | + {"ALC Capture NG Type", {"0"}}, |
| 5903 | + {"ALC Capture NG Switch", {"0"}}, |
| 5904 | +#endif |
| 5905 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 5906 | + {"LIN PGA GAIN", {"6"}}, |
| 5907 | + {"ADC Capture Volume", {"192"}}, |
| 5908 | +}; |
| 5909 | + |
| 5910 | +#ifdef _USE_7520V3_PHONE_TYPE_WTWD |
| 5911 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ |
| 5912 | + {"MONO MIXER DAC TO MONO OUT Switch", {"0"}}, |
| 5913 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"1"}}, |
| 5914 | + {"SPEAKER MIXER GAIN", {"41"}}, //1d |
| 5915 | + {"SPEAKER OUTPUT Volume", {"0"}}, //1e |
| 5916 | + {"DAC Playback Volume", {"192"}}, //38 |
| 5917 | +}; |
| 5918 | +#else |
| 5919 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ |
| 5920 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 5921 | + {"MONO OUT GAIN", {"4"}}, |
| 5922 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}, |
| 5923 | + {"audio path select",{"handset"}}, |
| 5924 | +}; |
| 5925 | + |
| 5926 | +#endif |
| 5927 | +/* |
| 5928 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 5929 | + {"MONO MIXER DAC TO MONO OUT Switch", {"0"}}, |
| 5930 | + {"SPEAKER MIXER GAIN", {"4"}}, |
| 5931 | + {"SPEAKER OUTPUT Volume", {"4"}}, |
| 5932 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"1"}} |
| 5933 | +}; |
| 5934 | +*/ |
| 5935 | + |
| 5936 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 5937 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 5938 | + {"MONO OUT GAIN", {"11"}}, |
| 5939 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}, |
| 5940 | + {"audio path select",{"speak"}}, |
| 5941 | +}; |
| 5942 | + |
| 5943 | +static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚLin1-Rin1ÊäÈëͨµÀ |
| 5944 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 5945 | +}; |
| 5946 | + |
| 5947 | +static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚLin2-Rin2ÊäÈëͨµÀ |
| 5948 | + {"DIFFERENTIAL MUX", {"2"}}, |
| 5949 | +}; |
| 5950 | + |
| 5951 | +#ifdef _USE_7520V3_PHONE_TYPE_WTWD |
| 5952 | + |
| 5953 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 5954 | +#ifndef USE_CAP_SUPPORT |
| 5955 | + |
| 5956 | + //{"voice processing path select", {"headset"}}, // handset speak headset bluetooth |
| 5957 | + {"voice processing path select", {"handset"}}, // handset speak headset bluetooth |
| 5958 | +#endif |
| 5959 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 5960 | + {"DMIC MUX", {"0"}}, |
| 5961 | + {"SDP OUT MUX", {"0"}}, |
| 5962 | + {"ADC Soft Ramp", {"0"}}, |
| 5963 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 5964 | + |
| 5965 | + {"ALC MUX", {"0"}}, |
| 5966 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 5967 | + {"LIN PGA GAIN", {"6"}}, |
| 5968 | + {"ADC Capture Volume", {"192"}}, |
| 5969 | + |
| 5970 | + {"MONO MIXER DAC TO MONO OUT Switch", {"0"}}, |
| 5971 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"1"}}, |
| 5972 | + {"SPEAKER MIXER GAIN", {"32"}}, //old 41 |
| 5973 | + {"SPEAKER OUTPUT Volume", {"0"}}, //1 |
| 5974 | + {"DAC Playback Volume", {"192"}}, //38 |
| 5975 | +}; |
| 5976 | + |
| 5977 | +#else |
| 5978 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 5979 | +#ifndef USE_CAP_SUPPORT |
| 5980 | + |
| 5981 | + {"voice processing path select", {"handset"}}, // handset speak headset bluetooth |
| 5982 | +#endif |
| 5983 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 5984 | + {"DMIC MUX", {"0"}}, |
| 5985 | + {"SDP OUT MUX", {"0"}}, |
| 5986 | + {"ADC Soft Ramp", {"0"}}, |
| 5987 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 5988 | + |
| 5989 | + {"ALC MUX", {"0"}}, |
| 5990 | +#if 0 |
| 5991 | + {"ALC Capture Target Volume", {"7"}}, |
| 5992 | + {"ALC Capture Max PGA", {"13"}}, |
| 5993 | + {"ALC Capture Min PGA", {"8"}}, |
| 5994 | + {"ALC Capture Hold Time", {"0"}}, |
| 5995 | + {"ALC Capture Decay Time", {"1"}}, |
| 5996 | + {"ALC Capture Attack Time", {"2"}}, |
| 5997 | + {"ALC WIN SIZE", {"6"}}, |
| 5998 | + {"ALC Capture NG Threshold", {"14"}}, |
| 5999 | + {"ALC Capture NG Type", {"0"}}, |
| 6000 | + {"ALC Capture NG Switch", {"0"}}, |
| 6001 | +#endif |
| 6002 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 6003 | + {"LIN PGA GAIN", {"6"}}, |
| 6004 | + {"ADC Capture Volume", {"192"}}, |
| 6005 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 6006 | + {"MONO OUT GAIN", {"11"}}, |
| 6007 | + {"DAC Playback Volume", {"192"}}, |
| 6008 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}, |
| 6009 | +}; |
| 6010 | +#endif |
| 6011 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ |
| 6012 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 6013 | + {"DMIC MUX", {"0"}}, |
| 6014 | + {"SDP OUT MUX", {"0"}}, |
| 6015 | + {"ADC Soft Ramp", {"0"}}, |
| 6016 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 6017 | + |
| 6018 | + {"ALC MUX", {"0"}}, |
| 6019 | +#if 0 |
| 6020 | + {"ALC Capture Target Volume", {"7"}}, |
| 6021 | + {"ALC Capture Max PGA", {"13"}}, |
| 6022 | + {"ALC Capture Min PGA", {"8"}}, |
| 6023 | + {"ALC Capture Hold Time", {"0"}}, |
| 6024 | + {"ALC Capture Decay Time", {"1"}}, |
| 6025 | + {"ALC Capture Attack Time", {"2"}}, |
| 6026 | + {"ALC WIN SIZE", {"6"}}, |
| 6027 | + {"ALC Capture NG Threshold", {"14"}}, |
| 6028 | + {"ALC Capture NG Type", {"0"}}, |
| 6029 | + {"ALC Capture NG Switch", {"0"}}, |
| 6030 | +#endif |
| 6031 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 6032 | + {"LIN PGA GAIN", {"7"}}, |
| 6033 | + {"ADC Capture Volume", {"192"}}, |
| 6034 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 6035 | + {"MONO OUT GAIN", {"4"}}, |
| 6036 | + {"DAC Playback Volume", {"190"}}, |
| 6037 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}, |
| 6038 | +#ifndef USE_CAP_SUPPORT |
| 6039 | + {"voice processing path select", {"headset"}}, // handset speak headset bluetooth |
| 6040 | +#endif |
| 6041 | +}; |
| 6042 | +#ifdef _USE_7520V3_PHONE_TYPE_WTWD //class-d -->receiver |
| 6043 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 6044 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 6045 | + {"DMIC MUX", {"0"}}, |
| 6046 | + {"SDP OUT MUX", {"0"}}, |
| 6047 | + {"ADC Soft Ramp", {"0"}}, |
| 6048 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 6049 | + |
| 6050 | + {"ALC MUX", {"0"}}, |
| 6051 | +#if 0 |
| 6052 | + {"ALC Capture Target Volume", {"7"}}, |
| 6053 | + {"ALC Capture Max PGA", {"13"}}, |
| 6054 | + {"ALC Capture Min PGA", {"8"}}, |
| 6055 | + {"ALC Capture Hold Time", {"0"}}, |
| 6056 | + {"ALC Capture Decay Time", {"1"}}, |
| 6057 | + {"ALC Capture Attack Time", {"2"}}, |
| 6058 | + {"ALC WIN SIZE", {"6"}}, |
| 6059 | + {"ALC Capture NG Threshold", {"14"}}, |
| 6060 | + {"ALC Capture NG Type", {"0"}}, |
| 6061 | + {"ALC Capture NG Switch", {"0"}}, |
| 6062 | +#endif |
| 6063 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 6064 | + {"LIN PGA GAIN", {"6"}}, |
| 6065 | + {"ADC Capture Volume", {"192"}}, |
| 6066 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 6067 | + {"MONO OUT GAIN", {"4"}}, |
| 6068 | + {"DAC Playback Volume", {"186"}}, |
| 6069 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}, |
| 6070 | +#ifndef USE_CAP_SUPPORT |
| 6071 | + {"voice processing path select", {"speak"}}, // handset speak headset bluetooth |
| 6072 | +#endif |
| 6073 | +}; |
| 6074 | +#else//momo out -> speaker |
| 6075 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 6076 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 6077 | + {"DMIC MUX", {"0"}}, |
| 6078 | + {"SDP OUT MUX", {"0"}}, |
| 6079 | + {"ADC Soft Ramp", {"0"}}, |
| 6080 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 6081 | + |
| 6082 | + {"ALC MUX", {"0"}}, |
| 6083 | +#if 0 |
| 6084 | + {"ALC Capture Target Volume", {"7"}}, |
| 6085 | + {"ALC Capture Max PGA", {"13"}}, |
| 6086 | + {"ALC Capture Min PGA", {"8"}}, |
| 6087 | + {"ALC Capture Hold Time", {"0"}}, |
| 6088 | + {"ALC Capture Decay Time", {"1"}}, |
| 6089 | + {"ALC Capture Attack Time", {"2"}}, |
| 6090 | + {"ALC WIN SIZE", {"6"}}, |
| 6091 | + {"ALC Capture NG Threshold", {"14"}}, |
| 6092 | + {"ALC Capture NG Type", {"0"}}, |
| 6093 | + {"ALC Capture NG Switch", {"0"}}, |
| 6094 | +#endif |
| 6095 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 6096 | + {"LIN PGA GAIN", {"6"}}, |
| 6097 | + {"ADC Capture Volume", {"192"}}, |
| 6098 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 6099 | + {"MONO OUT GAIN", {"0"}}, |
| 6100 | + {"DAC Playback Volume", {"186"}}, |
| 6101 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}, |
| 6102 | +#ifndef USE_CAP_SUPPORT |
| 6103 | + {"voice processing path select", {"speak"}}, // handset speak headset bluetooth |
| 6104 | +#endif |
| 6105 | +}; |
| 6106 | + |
| 6107 | +#endif |
| 6108 | + |
| 6109 | + |
| 6110 | + |
| 6111 | +#else |
| 6112 | +static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 6113 | + {"DAC MUTE", {"0"}}, |
| 6114 | + //{"DAC Playback Volume", {"120"}}, |
| 6115 | + {"DAC SDP SRC MUX", {"0"}}, |
| 6116 | + {"DAC SRC MUX", {"0"}} |
| 6117 | +}; |
| 6118 | + |
| 6119 | +static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 6120 | + {"DMIC MUX", {"0"}}, |
| 6121 | + {"SDP OUT MUX", {"0"}}, |
| 6122 | + {"ADC Soft Ramp", {"0"}}, |
| 6123 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 6124 | +#if 1 |
| 6125 | + {"ALC MUX", {"1"}}, |
| 6126 | + {"ALC Capture Target Volume", {"5"}}, |
| 6127 | + {"ALC Capture Max PGA", {"11"}}, |
| 6128 | + {"ALC Capture Min PGA", {"2"}}, |
| 6129 | + {"ALC Capture Hold Time", {"0"}}, |
| 6130 | + {"ALC Capture Decay Time", {"0"}}, |
| 6131 | + {"ALC Capture Attack Time", {"0"}}, |
| 6132 | + {"ALC WIN SIZE", {"6"}}, |
| 6133 | + {"ALC Capture NG Threshold", {"14"}}, |
| 6134 | + {"ALC Capture NG Type", {"0"}}, |
| 6135 | + {"ALC Capture NG Switch", {"0"}}, |
| 6136 | +#endif |
| 6137 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 6138 | + {"LIN PGA GAIN", {"3"}}, |
| 6139 | + {"ADC Capture Volume", {"180"}}, |
| 6140 | +}; |
| 6141 | + |
| 6142 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ |
| 6143 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 6144 | + {"MONO OUT GAIN", {"4"}}, |
| 6145 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}} |
| 6146 | +}; |
| 6147 | + |
| 6148 | +/* |
| 6149 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 6150 | + {"MONO MIXER DAC TO MONO OUT Switch", {"0"}}, |
| 6151 | + {"SPEAKER MIXER GAIN", {"4"}}, |
| 6152 | + {"SPEAKER OUTPUT Volume", {"4"}}, |
| 6153 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"1"}} |
| 6154 | +}; |
| 6155 | +*/ |
| 6156 | + |
| 6157 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 6158 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 6159 | + {"MONO OUT GAIN", {"3"}}, |
| 6160 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}} |
| 6161 | +}; |
| 6162 | + |
| 6163 | +static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚLin1-Rin1ÊäÈëͨµÀ |
| 6164 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 6165 | +}; |
| 6166 | + |
| 6167 | +static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚLin2-Rin2ÊäÈëͨµÀ |
| 6168 | + {"DIFFERENTIAL MUX", {"2"}}, |
| 6169 | +}; |
| 6170 | + |
| 6171 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 6172 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 6173 | + {"DMIC MUX", {"0"}}, |
| 6174 | + {"SDP OUT MUX", {"0"}}, |
| 6175 | + {"ADC Soft Ramp", {"0"}}, |
| 6176 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 6177 | + |
| 6178 | + {"ALC MUX", {"0"}}, |
| 6179 | +#if 0 |
| 6180 | + {"ALC Capture Target Volume", {"7"}}, |
| 6181 | + {"ALC Capture Max PGA", {"13"}}, |
| 6182 | + {"ALC Capture Min PGA", {"8"}}, |
| 6183 | + {"ALC Capture Hold Time", {"0"}}, |
| 6184 | + {"ALC Capture Decay Time", {"1"}}, |
| 6185 | + {"ALC Capture Attack Time", {"2"}}, |
| 6186 | + {"ALC WIN SIZE", {"6"}}, |
| 6187 | + {"ALC Capture NG Threshold", {"14"}}, |
| 6188 | + {"ALC Capture NG Type", {"0"}}, |
| 6189 | + {"ALC Capture NG Switch", {"0"}}, |
| 6190 | +#endif |
| 6191 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 6192 | + {"LIN PGA GAIN", {"7"}}, |
| 6193 | + {"ADC Capture Volume", {"192"}}, |
| 6194 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 6195 | + {"MONO OUT GAIN", {"4"}}, |
| 6196 | + {"DAC Playback Volume", {"190"}}, |
| 6197 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}, |
| 6198 | +#ifndef USE_CAP_SUPPORT |
| 6199 | + {"voice processing path select", {"handset"}}, // handset speak headset bluetooth |
| 6200 | +#endif |
| 6201 | +}; |
| 6202 | + |
| 6203 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ |
| 6204 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 6205 | + {"DMIC MUX", {"0"}}, |
| 6206 | + {"SDP OUT MUX", {"0"}}, |
| 6207 | + {"ADC Soft Ramp", {"0"}}, |
| 6208 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 6209 | + |
| 6210 | + {"ALC MUX", {"0"}}, |
| 6211 | +#if 0 |
| 6212 | + {"ALC Capture Target Volume", {"7"}}, |
| 6213 | + {"ALC Capture Max PGA", {"13"}}, |
| 6214 | + {"ALC Capture Min PGA", {"8"}}, |
| 6215 | + {"ALC Capture Hold Time", {"0"}}, |
| 6216 | + {"ALC Capture Decay Time", {"1"}}, |
| 6217 | + {"ALC Capture Attack Time", {"2"}}, |
| 6218 | + {"ALC WIN SIZE", {"6"}}, |
| 6219 | + {"ALC Capture NG Threshold", {"14"}}, |
| 6220 | + {"ALC Capture NG Type", {"0"}}, |
| 6221 | + {"ALC Capture NG Switch", {"0"}}, |
| 6222 | +#endif |
| 6223 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 6224 | + {"LIN PGA GAIN", {"7"}}, |
| 6225 | + {"ADC Capture Volume", {"192"}}, |
| 6226 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 6227 | + {"MONO OUT GAIN", {"4"}}, |
| 6228 | + {"DAC Playback Volume", {"190"}}, |
| 6229 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}, |
| 6230 | +#ifndef USE_CAP_SUPPORT |
| 6231 | + {"voice processing path select", {"headset"}}, // handset speak headset bluetooth |
| 6232 | +#endif |
| 6233 | +}; |
| 6234 | + |
| 6235 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 6236 | + {"DIFFERENTIAL MUX", {"1"}}, |
| 6237 | + {"DMIC MUX", {"0"}}, |
| 6238 | + {"SDP OUT MUX", {"0"}}, |
| 6239 | + {"ADC Soft Ramp", {"0"}}, |
| 6240 | + {"ADC HPF COEFFICIENT", {"5"}}, |
| 6241 | + |
| 6242 | + {"ALC MUX", {"0"}}, |
| 6243 | +#if 0 |
| 6244 | + {"ALC Capture Target Volume", {"7"}}, |
| 6245 | + {"ALC Capture Max PGA", {"13"}}, |
| 6246 | + {"ALC Capture Min PGA", {"8"}}, |
| 6247 | + {"ALC Capture Hold Time", {"0"}}, |
| 6248 | + {"ALC Capture Decay Time", {"1"}}, |
| 6249 | + {"ALC Capture Attack Time", {"2"}}, |
| 6250 | + {"ALC WIN SIZE", {"6"}}, |
| 6251 | + {"ALC Capture NG Threshold", {"14"}}, |
| 6252 | + {"ALC Capture NG Type", {"0"}}, |
| 6253 | + {"ALC Capture NG Switch", {"0"}}, |
| 6254 | +#endif |
| 6255 | + {"D2SE MIC BOOST GAIN", {"1"}}, |
| 6256 | + {"LIN PGA GAIN", {"7"}}, |
| 6257 | + {"ADC Capture Volume", {"192"}}, |
| 6258 | + {"SPEAKER MIXER DAC TO SPEAKER OUT Switch", {"0"}}, |
| 6259 | + {"MONO OUT GAIN", {"4"}}, |
| 6260 | + {"DAC Playback Volume", {"190"}}, |
| 6261 | + {"MONO MIXER DAC TO MONO OUT Switch", {"1"}}, |
| 6262 | +#ifndef USE_CAP_SUPPORT |
| 6263 | + {"voice processing path select", {"speak"}}, // handset speak headset bluetooth |
| 6264 | +#endif |
| 6265 | +}; |
| 6266 | + |
| 6267 | +#endif |
| 6268 | + |
| 6269 | +static struct audio_para_conf output_dac_vol = {"DAC Playback Volume", {"120"}}; |
| 6270 | + |
| 6271 | +static struct audio_para_conf input_adc_vol = {"ADC Capture Volume", {"192"}}; |
| 6272 | + |
| 6273 | +static struct audio_para_conf dac_mute = {"DAC MUTE", {"1"}}; |
| 6274 | +static struct audio_para_conf adc_mute = {"ADC MUTE", {"1"}}; |
| 6275 | + |
| 6276 | +static struct audio_para_conf spk_path_onoff[] = { |
| 6277 | + {"MONO MIXER DAC TO MONO OUT Switch", {"0"}}, |
| 6278 | +}; |
| 6279 | + |
| 6280 | +static struct audio_para_conf rcv_path_onoff[] = { |
| 6281 | + {"MONO MIXER DAC TO MONO OUT Switch", {"0"}}, |
| 6282 | +}; |
| 6283 | + |
| 6284 | +static struct audio_para_conf earp_path_onoff[] = { |
| 6285 | + {"MONO MIXER DAC TO MONO OUT Switch", {"0"}}, |
| 6286 | +}; |
| 6287 | + |
| 6288 | + |
| 6289 | +static int output_vol_conversion(int vol) |
| 6290 | +{ |
| 6291 | + switch(vol){ |
| 6292 | + case T_AUDIO_OUTPUT_VOL_LEVEL_0: |
| 6293 | + return T_OUTPUT_VOL_MINUS_96DB; |
| 6294 | + case T_AUDIO_OUTPUT_VOL_LEVEL_1: |
| 6295 | + return T_OUTPUT_VOL_MINUS_45DB; |
| 6296 | + case T_AUDIO_OUTPUT_VOL_LEVEL_2: |
| 6297 | + return T_OUTPUT_VOL_MINUS_40DB; |
| 6298 | + case T_AUDIO_OUTPUT_VOL_LEVEL_3: |
| 6299 | + return T_OUTPUT_VOL_MINUS_35DB; |
| 6300 | + case T_AUDIO_OUTPUT_VOL_LEVEL_4: |
| 6301 | + return T_OUTPUT_VOL_MINUS_30DB; |
| 6302 | + case T_AUDIO_OUTPUT_VOL_LEVEL_5: |
| 6303 | + return T_OUTPUT_VOL_MINUS_25DB; |
| 6304 | + case T_AUDIO_OUTPUT_VOL_LEVEL_6: |
| 6305 | + return T_OUTPUT_VOL_MINUS_20DB; |
| 6306 | + case T_AUDIO_OUTPUT_VOL_LEVEL_7: |
| 6307 | + return T_OUTPUT_VOL_MINUS_15DB; |
| 6308 | + case T_AUDIO_OUTPUT_VOL_LEVEL_8: |
| 6309 | + return T_OUTPUT_VOL_MINUS_10DB; |
| 6310 | + case T_AUDIO_OUTPUT_VOL_LEVEL_9: |
| 6311 | + return T_OUTPUT_VOL_MINUS_6DB; |
| 6312 | + case T_AUDIO_OUTPUT_VOL_LEVEL_10: |
| 6313 | + return T_OUTPUT_VOL_MINUS_3DB; |
| 6314 | + case T_AUDIO_OUTPUT_VOL_LEVEL_11: |
| 6315 | + return T_OUTPUT_VOL_0DB; |
| 6316 | + default: |
| 6317 | + return T_OUTPUT_VOL_0DB; |
| 6318 | + } |
| 6319 | +} |
| 6320 | + |
| 6321 | +static int input_vol_conversion(int vol) |
| 6322 | +{ |
| 6323 | + switch(vol) { |
| 6324 | + case T_AUDIO_INPUT_VOL_LEVEL_0: |
| 6325 | + return T_INPUT_VOL_MINUS_96DB; |
| 6326 | + case T_AUDIO_INPUT_VOL_LEVEL_1: |
| 6327 | + return T_INPUT_VOL_MINUS_30DB; |
| 6328 | + case T_AUDIO_INPUT_VOL_LEVEL_2: |
| 6329 | + return T_INPUT_VOL_MINUS_25DB; |
| 6330 | + case T_AUDIO_INPUT_VOL_LEVEL_3: |
| 6331 | + return T_INPUT_VOL_MINUS_20DB; |
| 6332 | + case T_AUDIO_INPUT_VOL_LEVEL_4: |
| 6333 | + return T_INPUT_VOL_MINUS_15DB; |
| 6334 | + case T_AUDIO_INPUT_VOL_LEVEL_5: |
| 6335 | + return T_INPUT_VOL_MINUS_10DB; |
| 6336 | + case T_AUDIO_INPUT_VOL_LEVEL_6: |
| 6337 | + return T_INPUT_VOL_MINUS_7DB; |
| 6338 | + case T_AUDIO_INPUT_VOL_LEVEL_7: |
| 6339 | + return T_INPUT_VOL_MINUS_4DB; |
| 6340 | + case T_AUDIO_INPUT_VOL_LEVEL_8: |
| 6341 | + return T_INPUT_VOL_MINUS_3DB; |
| 6342 | + case T_AUDIO_INPUT_VOL_LEVEL_9: |
| 6343 | + return T_INPUT_VOL_MINUS_2DB; |
| 6344 | + case T_AUDIO_INPUT_VOL_LEVEL_10: |
| 6345 | + return T_INPUT_VOL_MINUS_1DB; |
| 6346 | + case T_AUDIO_INPUT_VOL_LEVEL_11: |
| 6347 | + return T_INPUT_VOL_0DB; |
| 6348 | + default: |
| 6349 | + return T_INPUT_VOL_MINUS_30DB; |
| 6350 | + } |
| 6351 | +} |
| 6352 | + |
| 6353 | +#elif defined _USE_CODEC_AK4940 |
| 6354 | + |
| 6355 | +static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 6356 | + {"DAC Soft Mute Control", {"0"}}, |
| 6357 | + //{"BICK Frequency", {"32fs"}}, |
| 6358 | + {"BICK Frequency", {"2"}},//0 64fs,1 48fs,2 32fs |
| 6359 | + |
| 6360 | +}; |
| 6361 | + |
| 6362 | + |
| 6363 | +static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 6364 | + |
| 6365 | + {"Mic Gain Control", {"0"}}, |
| 6366 | + {"ADC Digital Volume (VOLAD)", {"195"}}, |
| 6367 | + {"ADC Soft Mute Control", {"0"}}, |
| 6368 | + |
| 6369 | + |
| 6370 | +}; |
| 6371 | + |
| 6372 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ |
| 6373 | + {"OUT2 MUX", {"DAC"}}, |
| 6374 | + {"Lineout Type", {"Single-end"}}, |
| 6375 | + |
| 6376 | +}; |
| 6377 | + |
| 6378 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 6379 | + {"OUT1 MUX", {"DAC"}}, |
| 6380 | + {"Lineout Type", {"Differential"}}, |
| 6381 | + |
| 6382 | +}; |
| 6383 | + |
| 6384 | +static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚMic1lp_Mic1lmÊäÈëͨµÀ |
| 6385 | + |
| 6386 | + {"ADC Input Type", {"Single-end"}}, |
| 6387 | + {"AIN MUX", {"AIN1"}}, |
| 6388 | + |
| 6389 | +}; |
| 6390 | + |
| 6391 | +static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚMic1rpÊäÈëͨµÀ |
| 6392 | + |
| 6393 | + {"ADC Input Type", {"Single-end"}}, |
| 6394 | + {"AIN MUX", {"AIN2"}}, |
| 6395 | +}; |
| 6396 | + |
| 6397 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 6398 | + // common in |
| 6399 | + |
| 6400 | + {"Mic Gain Control", {"0"}}, |
| 6401 | + {"ADC Digital Volume (VOLAD)", {"195"}}, |
| 6402 | + {"ADC Soft Mute Control", {"0"}}, |
| 6403 | + //diff in |
| 6404 | + {"ADC Input Type", {"Single-end"}}, |
| 6405 | + {"AIN MUX", {"AIN1"}}, |
| 6406 | + |
| 6407 | + // common out |
| 6408 | + |
| 6409 | + {"DAC Soft Mute Control", {"0"}}, |
| 6410 | + //{"BICK Frequency", {"32fs"}}, |
| 6411 | + {"BICK Frequency", {"2"}},//0 64fs,1 48fs,2 32fs |
| 6412 | + //diff out |
| 6413 | + |
| 6414 | + //voice |
| 6415 | +#ifndef USE_CAP_SUPPORT |
| 6416 | + |
| 6417 | + {"voice processing path select", {"handset"}}, // handset speak headset bluetooth |
| 6418 | +#endif |
| 6419 | +}; |
| 6420 | + |
| 6421 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ |
| 6422 | + // common in |
| 6423 | + |
| 6424 | + {"Mic Gain Control", {"0"}}, |
| 6425 | + {"ADC Digital Volume (VOLAD)", {"195"}}, |
| 6426 | + {"ADC Soft Mute Control", {"0"}}, |
| 6427 | + //diff in |
| 6428 | + {"ADC Input Type", {"Single-end"}}, |
| 6429 | + {"AIN MUX", {"AIN2"}}, |
| 6430 | + // common out |
| 6431 | + |
| 6432 | + {"DAC Soft Mute Control", {"0"}}, |
| 6433 | + //{"BICK Frequency", {"32fs"}}, |
| 6434 | + {"BICK Frequency", {"2"}},//0 64fs,1 48fs,2 32fs |
| 6435 | + //diff out |
| 6436 | + |
| 6437 | + {"OUT2 MUX", {"DAC"}}, |
| 6438 | + {"Lineout Type", {"Single-end"}}, |
| 6439 | + //voice |
| 6440 | +#ifndef USE_CAP_SUPPORT |
| 6441 | + |
| 6442 | + {"voice processing path select", {"headset"}}, // handset speak headset bluetooth |
| 6443 | +#endif |
| 6444 | +}; |
| 6445 | + |
| 6446 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 6447 | + |
| 6448 | + // common in |
| 6449 | + {"Mic Gain Control", {"0"}}, |
| 6450 | + {"ADC Digital Volume (VOLAD)", {"195"}}, |
| 6451 | + {"ADC Soft Mute Control", {"0"}}, |
| 6452 | + //diff in |
| 6453 | + {"ADC Input Type", {"Single-end"}}, |
| 6454 | + {"AIN MUX", {"AIN1"}}, |
| 6455 | + // common out |
| 6456 | + {"DAC Soft Mute Control", {"0"}}, |
| 6457 | + //{"BICK Frequency", {"32fs"}}, |
| 6458 | + {"BICK Frequency", {"2"}},//0 64fs,1 48fs,2 32fs |
| 6459 | + //diff out |
| 6460 | + {"OUT1 MUX", {"DAC"}}, |
| 6461 | + {"Lineout Type", {"Differential"}}, |
| 6462 | + //voice |
| 6463 | +#ifndef USE_CAP_SUPPORT |
| 6464 | + |
| 6465 | + {"voice processing path select", {"speak"}}, // handset speak headset bluetooth |
| 6466 | +#endif |
| 6467 | +}; |
| 6468 | + |
| 6469 | +#elif defined _USE_CODEC_NAU8810 |
| 6470 | +static struct audio_para_conf init_default_para[] = { //¿ª»ú³õʼ»¯µ÷Óà |
| 6471 | + |
| 6472 | +}; |
| 6473 | + |
| 6474 | +static struct audio_para_conf common_out_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 6475 | + //{"DAC Soft Mute Control", {"0"}}, |
| 6476 | + |
| 6477 | + |
| 6478 | +}; |
| 6479 | + |
| 6480 | + |
| 6481 | +static struct audio_para_conf common_in_para_audio[] = { //¶ÔÓ¦¹«¹²²¿·Ö |
| 6482 | + |
| 6483 | + //{"Mic Gain Control", {"0"}}, |
| 6484 | + |
| 6485 | +}; |
| 6486 | + |
| 6487 | +static struct audio_para_conf hp_outpath_para_audio[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ |
| 6488 | + {"Speaker Mute Switch", {"1"}}, |
| 6489 | + {"Speaker Mixer PCM Playback Switch", {"0"}}, |
| 6490 | + {"Mono Mute Switch", {"0"}}, |
| 6491 | + {"Mono Mixer PCM Playback Switch", {"1"}}, |
| 6492 | + |
| 6493 | + |
| 6494 | +}; |
| 6495 | + |
| 6496 | +static struct audio_para_conf spk_outpath_para_audio[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀ |
| 6497 | + {"Mono Mute Switch", {"1"}}, |
| 6498 | + {"Mono Mixer PCM Playback Switch", {"0"}}, |
| 6499 | + {"Speaker Volume", {"57"}}, |
| 6500 | + {"Speaker Mute Switch", {"0"}}, |
| 6501 | + {"Speaker Mixer PCM Playback Switch", {"1"}}, |
| 6502 | + |
| 6503 | + |
| 6504 | +}; |
| 6505 | + |
| 6506 | +static struct audio_para_conf main_mic_inpath_para_audio[] = { //¶ÔÓ¦ÓÚMic1lp_Mic1lmÊäÈëͨµÀ |
| 6507 | + |
| 6508 | + //#0x2d b6 pga mute |
| 6509 | + {"Input Boost Stage PGA Mute Switch", {"1"}}, |
| 6510 | + {"Capture Volume", {"255"}}, |
| 6511 | + {"PGA Volume", {"32"}}, |
| 6512 | + {"Input PGA MicN Switch", {"1"}}, |
| 6513 | + {"Input PGA MicP Switch", {"1"}}, |
| 6514 | + |
| 6515 | + //#0x2f b4~b6 |
| 6516 | + {"Input Boost Stage PMIC PGA Switch", {"0"}}, |
| 6517 | + |
| 6518 | +}; |
| 6519 | + |
| 6520 | +static struct audio_para_conf aux_mic_inpath_para_audio[] = {//¶ÔÓ¦ÓÚMic1rpÊäÈëͨµÀ |
| 6521 | + |
| 6522 | + //#0x2d b6 pga mute |
| 6523 | + {"Input Boost Stage PGA Mute Switch", {"1"}}, |
| 6524 | + {"Capture Volume", {"255"}}, |
| 6525 | + {"PGA Volume", {"32"}}, |
| 6526 | + {"Input PGA MicN Switch", {"1"}}, |
| 6527 | + {"Input PGA MicP Switch", {"1"}}, |
| 6528 | + |
| 6529 | + //#0x2f b4~b6 |
| 6530 | + {"Input Boost Stage PMIC PGA Switch", {"0"}}, |
| 6531 | + |
| 6532 | + |
| 6533 | +}; |
| 6534 | + |
| 6535 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 6536 | + //in |
| 6537 | + //#0x2d b6 pga mute |
| 6538 | + {"Input Boost Stage PGA Mute Switch", {"1"}}, |
| 6539 | + {"Capture Volume", {"255"}}, |
| 6540 | + {"PGA Volume", {"32"}}, |
| 6541 | + {"Input PGA MicN Switch", {"1"}}, |
| 6542 | + {"Input PGA MicP Switch", {"1"}}, |
| 6543 | + |
| 6544 | + //#0x2f b4~b6 |
| 6545 | + {"Input Boost Stage PMIC PGA Switch", {"0"}}, |
| 6546 | + |
| 6547 | + //out |
| 6548 | + {"Playback Volume", {"255"}}, |
| 6549 | + {"Speaker Mute Switch", {"1"}}, |
| 6550 | + {"Speaker Mixer PCM Playback Switch", {"0"}}, |
| 6551 | + {"Mono Mute Switch", {"0"}}, |
| 6552 | + {"Mono Mixer PCM Playback Switch", {"1"}}, |
| 6553 | + |
| 6554 | + |
| 6555 | + |
| 6556 | + //voice |
| 6557 | +#ifndef USE_CAP_SUPPORT |
| 6558 | + |
| 6559 | + {"voice processing path select", {"handset"}}, // handset speak headset bluetooth |
| 6560 | +#endif |
| 6561 | +}; |
| 6562 | + |
| 6563 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚHpÊä³öͨµÀ Mic1rpÊäÈëͨµÀ |
| 6564 | + //in |
| 6565 | + //#0x2d b6 pga mute |
| 6566 | + {"Input Boost Stage PGA Mute Switch", {"1"}}, |
| 6567 | + {"Capture Volume", {"255"}}, |
| 6568 | + {"PGA Volume", {"32"}}, |
| 6569 | + {"Input PGA MicN Switch", {"1"}}, |
| 6570 | + {"Input PGA MicP Switch", {"1"}}, |
| 6571 | + |
| 6572 | + //#0x2f b4~b6 |
| 6573 | + {"Input Boost Stage PMIC PGA Switch", {"0"}}, |
| 6574 | + |
| 6575 | + //out |
| 6576 | + {"Playback Volume", {"255"}}, |
| 6577 | + {"Speaker Mute Switch", {"1"}}, |
| 6578 | + {"Speaker Mixer PCM Playback Switch", {"0"}}, |
| 6579 | + {"Mono Mute Switch", {"0"}}, |
| 6580 | + {"Mono Mixer PCM Playback Switch", {"1"}}, |
| 6581 | + |
| 6582 | + //voice |
| 6583 | +#ifndef USE_CAP_SUPPORT |
| 6584 | + |
| 6585 | + {"voice processing path select", {"headset"}}, // handset speak headset bluetooth |
| 6586 | +#endif |
| 6587 | +}; |
| 6588 | + |
| 6589 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { //¶ÔÓ¦ÓÚSpkÊä³öͨµÀMic1lp_Mic1lmÊäÈëͨµÀ |
| 6590 | + |
| 6591 | + //in |
| 6592 | + //#0x2d b6 pga mute |
| 6593 | + {"Input Boost Stage PGA Mute Switch", {"1"}}, |
| 6594 | + {"Capture Volume", {"255"}}, |
| 6595 | + {"PGA Volume", {"32"}}, |
| 6596 | + {"Input PGA MicN Switch", {"1"}}, |
| 6597 | + {"Input PGA MicP Switch", {"1"}}, |
| 6598 | + |
| 6599 | + //#0x2f b4~b6 |
| 6600 | + {"Input Boost Stage PMIC PGA Switch", {"0"}}, |
| 6601 | + |
| 6602 | + //out |
| 6603 | + {"Playback Volume", {"255"}}, |
| 6604 | + {"Mono Mute Switch", {"1"}}, |
| 6605 | + {"Mono Mixer PCM Playback Switch", {"0"}}, |
| 6606 | + {"Speaker Volume", {"63"}}, |
| 6607 | + {"Speaker Mute Switch", {"0"}}, |
| 6608 | + {"Speaker Mixer PCM Playback Switch", {"1"}}, |
| 6609 | + |
| 6610 | + |
| 6611 | + //voice |
| 6612 | +#ifndef USE_CAP_SUPPORT |
| 6613 | + |
| 6614 | + {"voice processing path select", {"speak"}}, // handset speak headset bluetooth |
| 6615 | +#endif |
| 6616 | +}; |
| 6617 | + |
| 6618 | + |
| 6619 | +static struct audio_para_conf output_dac_vol = { |
| 6620 | + "Playback Volume", {"255"} |
| 6621 | + |
| 6622 | +}; |
| 6623 | + |
| 6624 | +static struct audio_para_conf input_adc_vol = { |
| 6625 | + "Capture Volume", {"255"} |
| 6626 | +}; |
| 6627 | + |
| 6628 | +static struct audio_para_conf dac_mute = { |
| 6629 | + "DAC MUTE", {"1"} |
| 6630 | +}; |
| 6631 | +static struct audio_para_conf adc_mute = { |
| 6632 | + "Input Boost Stage PGA Mute Switch", {"0"} |
| 6633 | +}; |
| 6634 | + |
| 6635 | +static struct audio_para_conf spk_path_onoff[] = { |
| 6636 | + {"Mono Mixer PCM Playback Switch", {"0"}}, |
| 6637 | +}; |
| 6638 | + |
| 6639 | +static struct audio_para_conf rcv_path_onoff[] = { |
| 6640 | + {"Mono Mixer PCM Playback Switch", {"0"}}, |
| 6641 | +}; |
| 6642 | + |
| 6643 | +static struct audio_para_conf earp_path_onoff[] = { |
| 6644 | + {"Speaker Mixer PCM Playback Switch", {"0"}}, |
| 6645 | +}; |
| 6646 | + |
| 6647 | + |
| 6648 | +static int output_vol_conversion(int vol)//reg 0xb |
| 6649 | +{ |
| 6650 | + switch(vol){ |
| 6651 | + case T_AUDIO_OUTPUT_VOL_LEVEL_0: |
| 6652 | + return 189; |
| 6653 | + case T_AUDIO_OUTPUT_VOL_LEVEL_1: |
| 6654 | + return 195; |
| 6655 | + case T_AUDIO_OUTPUT_VOL_LEVEL_2: |
| 6656 | + return 201; |
| 6657 | + case T_AUDIO_OUTPUT_VOL_LEVEL_3: |
| 6658 | + return 207; |
| 6659 | + case T_AUDIO_OUTPUT_VOL_LEVEL_4: |
| 6660 | + return 213; |
| 6661 | + case T_AUDIO_OUTPUT_VOL_LEVEL_5: |
| 6662 | + return 219; |
| 6663 | + case T_AUDIO_OUTPUT_VOL_LEVEL_6: |
| 6664 | + return 225; |
| 6665 | + case T_AUDIO_OUTPUT_VOL_LEVEL_7: |
| 6666 | + return 231; |
| 6667 | + case T_AUDIO_OUTPUT_VOL_LEVEL_8: |
| 6668 | + return 237; |
| 6669 | + case T_AUDIO_OUTPUT_VOL_LEVEL_9: |
| 6670 | + return 243; |
| 6671 | + case T_AUDIO_OUTPUT_VOL_LEVEL_10: |
| 6672 | + return 249; |
| 6673 | + case T_AUDIO_OUTPUT_VOL_LEVEL_11: |
| 6674 | + return 255; |
| 6675 | + default: |
| 6676 | + return 255; |
| 6677 | + } |
| 6678 | +} |
| 6679 | +static int input_vol_conversion(int vol)//reg 0xf |
| 6680 | +{ |
| 6681 | + switch(vol) { |
| 6682 | + case T_AUDIO_INPUT_VOL_LEVEL_0: |
| 6683 | + return 189; |
| 6684 | + case T_AUDIO_INPUT_VOL_LEVEL_1: |
| 6685 | + return 195; |
| 6686 | + case T_AUDIO_INPUT_VOL_LEVEL_2: |
| 6687 | + return 201; |
| 6688 | + case T_AUDIO_INPUT_VOL_LEVEL_3: |
| 6689 | + return 207; |
| 6690 | + case T_AUDIO_INPUT_VOL_LEVEL_4: |
| 6691 | + return 213; |
| 6692 | + case T_AUDIO_INPUT_VOL_LEVEL_5: |
| 6693 | + return 219; |
| 6694 | + case T_AUDIO_INPUT_VOL_LEVEL_6: |
| 6695 | + return 225; |
| 6696 | + case T_AUDIO_INPUT_VOL_LEVEL_7: |
| 6697 | + return 231; |
| 6698 | + case T_AUDIO_INPUT_VOL_LEVEL_8: |
| 6699 | + return 237; |
| 6700 | + case T_AUDIO_INPUT_VOL_LEVEL_9: |
| 6701 | + return 243; |
| 6702 | + case T_AUDIO_INPUT_VOL_LEVEL_10: |
| 6703 | + return 249; |
| 6704 | + case T_AUDIO_INPUT_VOL_LEVEL_11: |
| 6705 | + return 255; |
| 6706 | + default: |
| 6707 | + return 255; |
| 6708 | + } |
| 6709 | +} |
| 6710 | + |
| 6711 | + |
| 6712 | + |
| 6713 | +#else //default |
| 6714 | + |
| 6715 | +static struct audio_para_conf init_default_para[] = { |
| 6716 | +}; |
| 6717 | + |
| 6718 | +static struct audio_para_conf common_out_para_audio[] = { |
| 6719 | + |
| 6720 | +}; |
| 6721 | + |
| 6722 | + |
| 6723 | + |
| 6724 | +static struct audio_para_conf common_in_para_audio[] = { |
| 6725 | +}; |
| 6726 | + |
| 6727 | +static struct audio_para_conf hp_outpath_para_audio[] = { |
| 6728 | +}; |
| 6729 | + |
| 6730 | + |
| 6731 | +static struct audio_para_conf spk_outpath_para_audio[] = { |
| 6732 | +}; |
| 6733 | + |
| 6734 | +static struct audio_para_conf main_mic_inpath_para_audio[] = { |
| 6735 | +}; |
| 6736 | + |
| 6737 | +static struct audio_para_conf aux_mic_inpath_para_audio[] = { |
| 6738 | +}; |
| 6739 | + |
| 6740 | +static struct audio_para_conf handset_inoutpath_para_voice[] = { |
| 6741 | + |
| 6742 | +}; |
| 6743 | + |
| 6744 | +static struct audio_para_conf headset_inoutpath_para_voice[] = { |
| 6745 | +}; |
| 6746 | + |
| 6747 | +static struct audio_para_conf spk_inoutpath_para_voice[] = { |
| 6748 | +}; |
| 6749 | + |
| 6750 | +static struct audio_para_conf output_dac_vol = {}; |
| 6751 | + |
| 6752 | +static struct audio_para_conf input_adc_vol = {}; |
| 6753 | + |
| 6754 | +static struct audio_para_conf dac_mute = {}; |
| 6755 | +static struct audio_para_conf adc_mute = {}; |
| 6756 | + |
| 6757 | +static struct audio_para_conf spk_path_onoff[] = { |
| 6758 | + |
| 6759 | +}; |
| 6760 | +static struct audio_para_conf rcv_path_onoff[] = { |
| 6761 | + |
| 6762 | +}; |
| 6763 | +static struct audio_para_conf earp_path_onoff[] = { |
| 6764 | + |
| 6765 | +}; |
| 6766 | +static int output_vol_conversion(int vol) |
| 6767 | +{ |
| 6768 | + |
| 6769 | + return 24; |
| 6770 | +} |
| 6771 | + |
| 6772 | +static int input_vol_conversion(int vol) |
| 6773 | +{ |
| 6774 | + |
| 6775 | + return 24; |
| 6776 | + |
| 6777 | +} |
| 6778 | + |
| 6779 | + |
| 6780 | +#endif |
| 6781 | + |
| 6782 | +static void mix_set_value_wrap(struct mixer *mixer, const char *control, char **values) |
| 6783 | +{ |
| 6784 | + struct mixer_ctl *ctl; |
| 6785 | + enum mixer_ctl_type type; |
| 6786 | + unsigned int num_ctl_values; |
| 6787 | + unsigned int i; |
| 6788 | + |
| 6789 | + if (isdigit(control[0])) |
| 6790 | + ctl = mixer_get_ctl(mixer, atoi(control)); |
| 6791 | + else |
| 6792 | + ctl = mixer_get_ctl_by_name(mixer, control); |
| 6793 | + |
| 6794 | + if (!ctl) { |
| 6795 | + fprintf(stderr, "Invalid mixer control(%s)\n",control); |
| 6796 | + return; |
| 6797 | + } |
| 6798 | + |
| 6799 | + type = mixer_ctl_get_type(ctl); |
| 6800 | + num_ctl_values = mixer_ctl_get_num_values(ctl); |
| 6801 | + |
| 6802 | + if (isdigit(values[0][0])) { |
| 6803 | + |
| 6804 | + for (i = 0; i < num_ctl_values; i++) { |
| 6805 | + if (mixer_ctl_set_value(ctl, i, atoi(values[i]))) { |
| 6806 | + fprintf(stderr, "Error: invalid value for index %d\n", i); |
| 6807 | + return; |
| 6808 | + } |
| 6809 | + } |
| 6810 | + |
| 6811 | + } else { |
| 6812 | + if (type == MIXER_CTL_TYPE_ENUM) { |
| 6813 | + /*if (num_values != 1) { |
| 6814 | + fprintf(stderr, "Enclose strings in quotes and try again\n"); |
| 6815 | + return; |
| 6816 | + }*/ |
| 6817 | + if (mixer_ctl_set_enum_by_string(ctl, values[0])) |
| 6818 | + fprintf(stderr, "Error: invalid enum value\n"); |
| 6819 | + } else { |
| 6820 | + fprintf(stderr, "Error: only enum types can be set with strings\n"); |
| 6821 | + } |
| 6822 | + } |
| 6823 | +} |
| 6824 | + |
| 6825 | +static void mix_get_value_wrap(struct mixer *mixer, const char *control, int *values) |
| 6826 | +{ |
| 6827 | + struct mixer_ctl *ctl; |
| 6828 | + enum mixer_ctl_type type; |
| 6829 | + unsigned int num_ctl_values; |
| 6830 | + unsigned int i; |
| 6831 | + int val; |
| 6832 | + |
| 6833 | + if (isdigit(control[0])) |
| 6834 | + ctl = mixer_get_ctl(mixer, atoi(control)); |
| 6835 | + else |
| 6836 | + ctl = mixer_get_ctl_by_name(mixer, control); |
| 6837 | + |
| 6838 | + if (!ctl) { |
| 6839 | + fprintf(stderr, "Invalid mixer control(%s)\n",control); |
| 6840 | + return; |
| 6841 | + } |
| 6842 | + |
| 6843 | + type = mixer_ctl_get_type(ctl); |
| 6844 | + num_ctl_values = mixer_ctl_get_num_values(ctl); |
| 6845 | + |
| 6846 | + |
| 6847 | + for (i = 0; i < num_ctl_values; i++) { |
| 6848 | + val = mixer_ctl_get_value(ctl, i); |
| 6849 | + if (val == -EINVAL) { |
| 6850 | + fprintf(stderr, "Error: invalid value for index %d\n", i); |
| 6851 | + return; |
| 6852 | + } |
| 6853 | + *(values+i) = val; |
| 6854 | + } |
| 6855 | + |
| 6856 | +} |
| 6857 | + |
| 6858 | + |
| 6859 | +#if (defined _USE_CODEC_TI3100)||(defined _USE_CODEC_AK4940)||(defined _USE_CODEC_NAU8810)||(defined _USE_CODEC_ES8311)||(defined _USE_CODEC_TI3104) |
| 6860 | +/* |
| 6861 | +int mix_set_input_vol(struct mixer *mixer, int volume) |
| 6862 | +{ |
| 6863 | + struct mixer_ctl *ctl; |
| 6864 | + char *name = input_adc_vol.control; |
| 6865 | + int num_values, i; |
| 6866 | + int vol = input_vol_conversion(volume); |
| 6867 | + |
| 6868 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 6869 | + if (!ctl) { |
| 6870 | + fprintf(stderr, "Invalid mixer control\n"); |
| 6871 | + return -1; |
| 6872 | + } |
| 6873 | + |
| 6874 | + num_values = mixer_ctl_get_num_values(ctl); |
| 6875 | + |
| 6876 | + for (i = 0; i < num_values; i++) { |
| 6877 | + mixer_ctl_set_value(ctl, i, vol); |
| 6878 | + } |
| 6879 | + |
| 6880 | + return 0; |
| 6881 | +} |
| 6882 | + |
| 6883 | +int mix_set_output_vol(struct mixer *mixer, int volume) |
| 6884 | +{ |
| 6885 | + struct mixer_ctl *ctl; |
| 6886 | + char *name = output_dac_vol.control; |
| 6887 | + int num_values, i; |
| 6888 | + |
| 6889 | + int vol = output_vol_conversion(volume); |
| 6890 | + |
| 6891 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 6892 | + if (!ctl) { |
| 6893 | + fprintf(stderr, "Invalid mixer control\n"); |
| 6894 | + return -1; |
| 6895 | + } |
| 6896 | + |
| 6897 | + num_values = mixer_ctl_get_num_values(ctl); |
| 6898 | + |
| 6899 | + for (i = 0; i < num_values; i++) { |
| 6900 | + mixer_ctl_set_value(ctl, i, vol); |
| 6901 | + } |
| 6902 | + |
| 6903 | + return 0; |
| 6904 | +} |
| 6905 | + |
| 6906 | +int mix_set_output_mute(struct mixer *mixer, bool enable) |
| 6907 | +{ |
| 6908 | + struct mixer_ctl *ctl; |
| 6909 | + char *name = dac_mute.control; |
| 6910 | + int num_values, i; |
| 6911 | + |
| 6912 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 6913 | + if (!ctl) { |
| 6914 | + fprintf(stderr, "Invalid mixer control\n"); |
| 6915 | + return -1; |
| 6916 | + } |
| 6917 | + |
| 6918 | + num_values = mixer_ctl_get_num_values(ctl); |
| 6919 | + |
| 6920 | + for (i = 0; i < num_values; i++) { |
| 6921 | + mixer_ctl_set_value(ctl, i, enable); |
| 6922 | + } |
| 6923 | + |
| 6924 | + return 0; |
| 6925 | +} |
| 6926 | + |
| 6927 | +int mix_set_input_mute(struct mixer *mixer, bool enable) |
| 6928 | +{ |
| 6929 | + struct mixer_ctl *ctl; |
| 6930 | + char *name = adc_mute.control; |
| 6931 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 6932 | + int num_values, i; |
| 6933 | + |
| 6934 | + if (!ctl) { |
| 6935 | + fprintf(stderr, "Invalid mixer control\n"); |
| 6936 | + return -1; |
| 6937 | + } |
| 6938 | + |
| 6939 | + num_values = mixer_ctl_get_num_values(ctl); |
| 6940 | + |
| 6941 | + for (i = 0; i < num_values; i++) { |
| 6942 | + mixer_ctl_set_value(ctl, 0, enable); |
| 6943 | + } |
| 6944 | + |
| 6945 | + return 0; |
| 6946 | +} |
| 6947 | + |
| 6948 | +int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff) |
| 6949 | +{ |
| 6950 | + struct mixer_ctl *ctl; |
| 6951 | + struct audio_para_conf *path_para; |
| 6952 | + int i, j, num_values, size; |
| 6953 | + switch(path) { |
| 6954 | + case T_OUTPUT_RECEIVER: |
| 6955 | + size = ARRAY_SIZE(rcv_path_onoff); |
| 6956 | + path_para = rcv_path_onoff; |
| 6957 | + break; |
| 6958 | + case T_OUTPUT_SPEAKER: |
| 6959 | + size = ARRAY_SIZE(spk_path_onoff); |
| 6960 | + path_para = spk_path_onoff; |
| 6961 | + break; |
| 6962 | + case T_OUTPUT_HEADSET: |
| 6963 | + size = ARRAY_SIZE(earp_path_onoff); |
| 6964 | + path_para = earp_path_onoff; |
| 6965 | + break; |
| 6966 | + default: |
| 6967 | + return -1; |
| 6968 | + } |
| 6969 | + |
| 6970 | + for (i = 0; i < size; i++) { |
| 6971 | + ctl = mixer_get_ctl_by_name(mixer, path_para[i].control); |
| 6972 | + num_values = mixer_ctl_get_num_values(ctl); |
| 6973 | + |
| 6974 | + for (j = 0; j < num_values; j++) { |
| 6975 | + mixer_ctl_set_value(ctl, j, onoff); |
| 6976 | + } |
| 6977 | + |
| 6978 | +// mix_set_value_wrap(mixer, spk_path_onoff[i].control, spk_path_onoff[i].values); |
| 6979 | + } |
| 6980 | + |
| 6981 | + return 0; |
| 6982 | +} |
| 6983 | +*/ |
| 6984 | + |
| 6985 | +/* |
| 6986 | + |
| 6987 | +int mix_set_in_call_tone(struct mixer *mixer, int tontype) |
| 6988 | +{ |
| 6989 | + struct mixer_ctl *ctl; |
| 6990 | + char name[] = "voice tone sel"; |
| 6991 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 6992 | + if (!ctl) { |
| 6993 | + fprintf(stderr, "Invalid mixer control\n"); |
| 6994 | + return -1; |
| 6995 | + } |
| 6996 | + |
| 6997 | + mixer_ctl_set_value(ctl, 0, tontype); |
| 6998 | + |
| 6999 | + return 0; |
| 7000 | +} |
| 7001 | + |
| 7002 | +int mix_set_default_param(struct mixer *mixer) |
| 7003 | +{ |
| 7004 | + int i; |
| 7005 | + for (i = 0; i < ARRAY_SIZE(init_default_para); i++) { |
| 7006 | + mix_set_value_wrap(mixer, init_default_para[i].control, init_default_para[i].values); |
| 7007 | + } |
| 7008 | + |
| 7009 | + return 0; |
| 7010 | +} |
| 7011 | + |
| 7012 | +*/ |
| 7013 | + |
| 7014 | +#define VOCIE_SND_CARD_NUM 0 |
| 7015 | + |
| 7016 | +int mix_set_input_vol(struct mixer *mixer, int volume) |
| 7017 | +{ |
| 7018 | + struct mixer_ctl *ctl; |
| 7019 | + char *name = input_adc_vol.control; |
| 7020 | + int num_values, i; |
| 7021 | + int vol = input_vol_conversion(volume); |
| 7022 | + if(name == NULL){ |
| 7023 | + printf("%s: name is null,return!\n",__func__); |
| 7024 | + return 0; |
| 7025 | + |
| 7026 | + } |
| 7027 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7028 | + if (!ctl) { |
| 7029 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7030 | + return -1; |
| 7031 | + } |
| 7032 | + |
| 7033 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7034 | + |
| 7035 | + for (i = 0; i < num_values; i++) { |
| 7036 | + mixer_ctl_set_value(ctl, i, vol); |
| 7037 | + } |
| 7038 | + |
| 7039 | + return 0; |
| 7040 | +} |
| 7041 | + |
| 7042 | +int mix_set_output_vol(struct mixer *mixer, int volume) |
| 7043 | +{ |
| 7044 | + struct mixer_ctl *ctl; |
| 7045 | + char *name = output_dac_vol.control; |
| 7046 | + int num_values, i; |
| 7047 | + |
| 7048 | + int vol = output_vol_conversion(volume); |
| 7049 | + if(name == NULL){ |
| 7050 | + printf("%s: name is null,return!\n",__func__); |
| 7051 | + return 0; |
| 7052 | + |
| 7053 | + } |
| 7054 | + |
| 7055 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7056 | + if (!ctl) { |
| 7057 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7058 | + return -1; |
| 7059 | + } |
| 7060 | + |
| 7061 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7062 | + |
| 7063 | + for (i = 0; i < num_values; i++) { |
| 7064 | + mixer_ctl_set_value(ctl, i, vol); |
| 7065 | + } |
| 7066 | + |
| 7067 | + return 0; |
| 7068 | +} |
| 7069 | + |
| 7070 | +int mix_set_output_mute(struct mixer *mixer, bool enable) |
| 7071 | +{ |
| 7072 | + struct mixer_ctl *ctl; |
| 7073 | + char *name = dac_mute.control; |
| 7074 | + int num_values, i; |
| 7075 | + if(name == NULL){ |
| 7076 | + printf("%s: name is null,return!\n",__func__); |
| 7077 | + return 0; |
| 7078 | + |
| 7079 | + } |
| 7080 | + |
| 7081 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7082 | + if (!ctl) { |
| 7083 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7084 | + return -1; |
| 7085 | + } |
| 7086 | + |
| 7087 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7088 | + |
| 7089 | + for (i = 0; i < num_values; i++) { |
| 7090 | + mixer_ctl_set_value(ctl, i, enable); |
| 7091 | + } |
| 7092 | + |
| 7093 | + return 0; |
| 7094 | +} |
| 7095 | + |
| 7096 | +int mix_set_input_mute(struct mixer *mixer, bool enable) |
| 7097 | +{ |
| 7098 | + struct mixer_ctl *ctl; |
| 7099 | + char *name = adc_mute.control; |
| 7100 | + int num_values, i; |
| 7101 | + if(name == NULL){ |
| 7102 | + printf("%s: name is null,return!\n",__func__); |
| 7103 | + return 0; |
| 7104 | + |
| 7105 | + } |
| 7106 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7107 | + |
| 7108 | + if (!ctl) { |
| 7109 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7110 | + return -1; |
| 7111 | + } |
| 7112 | + |
| 7113 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7114 | + |
| 7115 | + for (i = 0; i < num_values; i++) { |
| 7116 | + mixer_ctl_set_value(ctl, 0, enable); |
| 7117 | + } |
| 7118 | + |
| 7119 | + return 0; |
| 7120 | +} |
| 7121 | + |
| 7122 | +int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff) |
| 7123 | +{ |
| 7124 | + struct mixer_ctl *ctl; |
| 7125 | + struct audio_para_conf *path_para; |
| 7126 | + int i, j, num_values, size; |
| 7127 | + switch(path) { |
| 7128 | + case T_OUTPUT_RECEIVER: |
| 7129 | + size = ARRAY_SIZE(rcv_path_onoff); |
| 7130 | + path_para = rcv_path_onoff; |
| 7131 | + break; |
| 7132 | + case T_OUTPUT_SPEAKER: |
| 7133 | + size = ARRAY_SIZE(spk_path_onoff); |
| 7134 | + path_para = spk_path_onoff; |
| 7135 | + break; |
| 7136 | + case T_OUTPUT_HEADSET: |
| 7137 | + size = ARRAY_SIZE(earp_path_onoff); |
| 7138 | + path_para = earp_path_onoff; |
| 7139 | + break; |
| 7140 | + default: |
| 7141 | + return -1; |
| 7142 | + } |
| 7143 | + if(size == 0){ |
| 7144 | + printf("%s: array size is 0,return!\n",__func__); |
| 7145 | + return 0; |
| 7146 | + } |
| 7147 | + for (i = 0; i < size; i++) { |
| 7148 | + ctl = mixer_get_ctl_by_name(mixer, path_para[i].control); |
| 7149 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7150 | + |
| 7151 | + for (j = 0; j < num_values; j++) { |
| 7152 | + mixer_ctl_set_value(ctl, j, onoff); |
| 7153 | + } |
| 7154 | + |
| 7155 | +// mix_set_value_wrap(mixer, spk_path_onoff[i].control, spk_path_onoff[i].values); |
| 7156 | + } |
| 7157 | + |
| 7158 | + return 0; |
| 7159 | +} |
| 7160 | + |
| 7161 | +int mix_set_in_call_tone(struct mixer *mixer, int tontype) |
| 7162 | +{ |
| 7163 | + struct mixer_ctl *ctl; |
| 7164 | + char name[] = "voice tone sel"; |
| 7165 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7166 | + if (!ctl) { |
| 7167 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7168 | + return -1; |
| 7169 | + } |
| 7170 | + |
| 7171 | + mixer_ctl_set_value(ctl, 0, tontype); |
| 7172 | + |
| 7173 | + return 0; |
| 7174 | +} |
| 7175 | + |
| 7176 | +int mix_set_default_param(struct mixer *mixer) |
| 7177 | +{ |
| 7178 | + int i; |
| 7179 | + for (i = 0; i < ARRAY_SIZE(init_default_para); i++) { |
| 7180 | + mix_set_value_wrap(mixer, init_default_para[i].control, init_default_para[i].values); |
| 7181 | + } |
| 7182 | + |
| 7183 | + return 0; |
| 7184 | +} |
| 7185 | + |
| 7186 | +int mix_set_voice_vol(struct mixer *mixer, int volume) |
| 7187 | +{ |
| 7188 | + struct mixer_ctl *ctl; |
| 7189 | + char name[] = "voice processing path Volume"; |
| 7190 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7191 | + if (!ctl) { |
| 7192 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7193 | + return -1; |
| 7194 | + } |
| 7195 | + |
| 7196 | + mixer_ctl_set_value(ctl, 0, volume); |
| 7197 | + |
| 7198 | + return 0; |
| 7199 | +} |
| 7200 | +int mix_get_voice_vol(struct mixer *mixer, int *volume) |
| 7201 | +{ |
| 7202 | + |
| 7203 | + mix_get_value_wrap(mixer, "voice processing path Volume", volume); |
| 7204 | + |
| 7205 | + return 0; |
| 7206 | + |
| 7207 | +} |
| 7208 | + |
| 7209 | +int mix_set_tx_voice_vol(struct mixer *mixer, int volume) |
| 7210 | +{ |
| 7211 | + struct mixer_ctl *ctl; |
| 7212 | + char name[] = "voice processing tx path Volume"; |
| 7213 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7214 | + if (!ctl) { |
| 7215 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7216 | + return -1; |
| 7217 | + } |
| 7218 | + |
| 7219 | + mixer_ctl_set_value(ctl, 0, volume); |
| 7220 | + |
| 7221 | + return 0; |
| 7222 | +} |
| 7223 | +int mix_get_tx_voice_vol(struct mixer *mixer, int *volume) |
| 7224 | +{ |
| 7225 | + |
| 7226 | + mix_get_value_wrap(mixer, "voice processing tx path Volume", volume); |
| 7227 | + |
| 7228 | + return 0; |
| 7229 | + |
| 7230 | +} |
| 7231 | + |
| 7232 | + |
| 7233 | +int mix_set_voice_mute(struct mixer *mixer, bool enable) |
| 7234 | +{ |
| 7235 | + struct mixer_ctl *ctl; |
| 7236 | + char name[] = "voice uplink mute"; |
| 7237 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7238 | + if (!ctl) { |
| 7239 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7240 | + return -1; |
| 7241 | + } |
| 7242 | + |
| 7243 | + mixer_ctl_set_value(ctl, 0, enable); |
| 7244 | + |
| 7245 | + return 0; |
| 7246 | +} |
| 7247 | +int mix_get_voice_mute(struct mixer *mixer, int *enable) |
| 7248 | +{ |
| 7249 | + |
| 7250 | + mix_get_value_wrap(mixer, "voice uplink mute", enable); |
| 7251 | + |
| 7252 | + return 0; |
| 7253 | + |
| 7254 | +} |
| 7255 | + |
| 7256 | +//voice downlink mute |
| 7257 | + |
| 7258 | +int mix_set_rx_voice_mute(struct mixer *mixer, bool enable) |
| 7259 | +{ |
| 7260 | + struct mixer_ctl *ctl; |
| 7261 | + char name[] = "voice downlink mute"; |
| 7262 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7263 | + if (!ctl) { |
| 7264 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7265 | + return -1; |
| 7266 | + } |
| 7267 | + |
| 7268 | + mixer_ctl_set_value(ctl, 0, enable); |
| 7269 | + |
| 7270 | + return 0; |
| 7271 | +} |
| 7272 | +int mix_get_rx_voice_mute(struct mixer *mixer, int *enable) |
| 7273 | +{ |
| 7274 | + |
| 7275 | + mix_get_value_wrap(mixer, "voice downlink mute", enable); |
| 7276 | + |
| 7277 | + return 0; |
| 7278 | + |
| 7279 | +} |
| 7280 | + |
| 7281 | + |
| 7282 | + |
| 7283 | + |
| 7284 | + |
| 7285 | + |
| 7286 | +int mix_set_output_path(struct mixer *mixer, int path) |
| 7287 | +{ |
| 7288 | + int i; |
| 7289 | + for (i = 0; i < ARRAY_SIZE(common_out_para_audio); i++) { |
| 7290 | + mix_set_value_wrap(mixer, common_out_para_audio[i].control, common_out_para_audio[i].values); |
| 7291 | + } |
| 7292 | + switch (path) { |
| 7293 | + case T_OUTPUT_RECEIVER: |
| 7294 | + case T_OUTPUT_HEADSET: |
| 7295 | + for (i = 0; i < ARRAY_SIZE(hp_outpath_para_audio); i++) { |
| 7296 | + mix_set_value_wrap(mixer, hp_outpath_para_audio[i].control, hp_outpath_para_audio[i].values); |
| 7297 | + } |
| 7298 | + break; |
| 7299 | + case T_OUTPUT_SPEAKER: |
| 7300 | + for (i = 0; i < ARRAY_SIZE(spk_outpath_para_audio); i++) { |
| 7301 | + mix_set_value_wrap(mixer, spk_outpath_para_audio[i].control, spk_outpath_para_audio[i].values); |
| 7302 | + } |
| 7303 | + break; |
| 7304 | + default: |
| 7305 | + break; |
| 7306 | + } |
| 7307 | + |
| 7308 | + return 0; |
| 7309 | +} |
| 7310 | + |
| 7311 | +int mix_set_input_path(struct mixer *mixer, int path) |
| 7312 | +{ |
| 7313 | + int i; |
| 7314 | + for (i = 0; i < ARRAY_SIZE(common_in_para_audio); i++) { |
| 7315 | + mix_set_value_wrap(mixer, common_in_para_audio[i].control, common_in_para_audio[i].values); |
| 7316 | + } |
| 7317 | + |
| 7318 | + #if (defined _USE_CODEC_TI3100)||(defined _USE_CODEC_ES8311) |
| 7319 | + switch (path) { |
| 7320 | + case T_INPUT_MICLP: |
| 7321 | + for (i = 0; i < ARRAY_SIZE(main_mic_inpath_para_audio); i++) { |
| 7322 | + mix_set_value_wrap(mixer, main_mic_inpath_para_audio[i].control, main_mic_inpath_para_audio[i].values); |
| 7323 | + } |
| 7324 | + break; |
| 7325 | + case T_INPUT_MICRP: |
| 7326 | + for (i = 0; i < ARRAY_SIZE(aux_mic_inpath_para_audio); i++) { |
| 7327 | + mix_set_value_wrap(mixer, aux_mic_inpath_para_audio[i].control, aux_mic_inpath_para_audio[i].values); |
| 7328 | + } |
| 7329 | + break; |
| 7330 | + default: |
| 7331 | + break; |
| 7332 | + } |
| 7333 | + |
| 7334 | + |
| 7335 | + #else |
| 7336 | + switch (path) { |
| 7337 | + case T_INPUT_HANDSET: |
| 7338 | + case T_INPUT_SPEAKER: |
| 7339 | + for (i = 0; i < ARRAY_SIZE(main_mic_inpath_para_audio); i++) { |
| 7340 | + mix_set_value_wrap(mixer, main_mic_inpath_para_audio[i].control, main_mic_inpath_para_audio[i].values); |
| 7341 | + } |
| 7342 | + break; |
| 7343 | + case T_INPUT_HEADSET: |
| 7344 | + for (i = 0; i < ARRAY_SIZE(aux_mic_inpath_para_audio); i++) { |
| 7345 | + mix_set_value_wrap(mixer, aux_mic_inpath_para_audio[i].control, aux_mic_inpath_para_audio[i].values); |
| 7346 | + } |
| 7347 | + break; |
| 7348 | + default: |
| 7349 | + break; |
| 7350 | + } |
| 7351 | + #endif |
| 7352 | + |
| 7353 | + return 0; |
| 7354 | +} |
| 7355 | +/* |
| 7356 | +int mix_set_input_vol(struct mixer *mixer, int volume) |
| 7357 | +{ |
| 7358 | + struct mixer_ctl *ctl; |
| 7359 | + char *name = input_adc_vol.control; |
| 7360 | + int num_values, i; |
| 7361 | + int vol = input_vol_conversion(volume); |
| 7362 | + |
| 7363 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7364 | + if (!ctl) { |
| 7365 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7366 | + return -1; |
| 7367 | + } |
| 7368 | + |
| 7369 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7370 | + |
| 7371 | + for (i = 0; i < num_values; i++) { |
| 7372 | + mixer_ctl_set_value(ctl, i, vol); |
| 7373 | + } |
| 7374 | + |
| 7375 | + return 0; |
| 7376 | +} |
| 7377 | + |
| 7378 | +int mix_set_output_vol(struct mixer *mixer, int volume) |
| 7379 | +{ |
| 7380 | + struct mixer_ctl *ctl; |
| 7381 | + char *name = output_dac_vol.control; |
| 7382 | + int num_values, i; |
| 7383 | + |
| 7384 | + int vol = output_vol_conversion(volume); |
| 7385 | + |
| 7386 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7387 | + if (!ctl) { |
| 7388 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7389 | + return -1; |
| 7390 | + } |
| 7391 | + |
| 7392 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7393 | + |
| 7394 | + for (i = 0; i < num_values; i++) { |
| 7395 | + mixer_ctl_set_value(ctl, i, vol); |
| 7396 | + } |
| 7397 | + |
| 7398 | + return 0; |
| 7399 | +} |
| 7400 | + |
| 7401 | +int mix_set_output_mute(struct mixer *mixer, bool enable) |
| 7402 | +{ |
| 7403 | + struct mixer_ctl *ctl; |
| 7404 | + char *name = dac_mute.control; |
| 7405 | + int num_values, i; |
| 7406 | + |
| 7407 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7408 | + if (!ctl) { |
| 7409 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7410 | + return -1; |
| 7411 | + } |
| 7412 | + |
| 7413 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7414 | + |
| 7415 | + for (i = 0; i < num_values; i++) { |
| 7416 | + mixer_ctl_set_value(ctl, i, enable); |
| 7417 | + } |
| 7418 | + |
| 7419 | + return 0; |
| 7420 | +} |
| 7421 | + |
| 7422 | +int mix_set_input_mute(struct mixer *mixer, bool enable) |
| 7423 | +{ |
| 7424 | + struct mixer_ctl *ctl; |
| 7425 | + char *name = adc_mute.control; |
| 7426 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7427 | + int num_values, i; |
| 7428 | + |
| 7429 | + if (!ctl) { |
| 7430 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7431 | + return -1; |
| 7432 | + } |
| 7433 | + |
| 7434 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7435 | + |
| 7436 | + for (i = 0; i < num_values; i++) { |
| 7437 | + mixer_ctl_set_value(ctl, 0, enable); |
| 7438 | + } |
| 7439 | + |
| 7440 | + return 0; |
| 7441 | +} |
| 7442 | + |
| 7443 | +int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff) |
| 7444 | +{ |
| 7445 | + struct mixer_ctl *ctl; |
| 7446 | + struct audio_para_conf *path_para; |
| 7447 | + int i, j, num_values, size; |
| 7448 | + switch(path) { |
| 7449 | + case T_OUTPUT_RECEIVER: |
| 7450 | + size = ARRAY_SIZE(rcv_path_onoff); |
| 7451 | + path_para = rcv_path_onoff; |
| 7452 | + break; |
| 7453 | + case T_OUTPUT_SPEAKER: |
| 7454 | + size = ARRAY_SIZE(spk_path_onoff); |
| 7455 | + path_para = spk_path_onoff; |
| 7456 | + break; |
| 7457 | + case T_OUTPUT_HEADSET: |
| 7458 | + size = ARRAY_SIZE(earp_path_onoff); |
| 7459 | + path_para = earp_path_onoff; |
| 7460 | + break; |
| 7461 | + default: |
| 7462 | + return -1; |
| 7463 | + } |
| 7464 | + |
| 7465 | + for (i = 0; i < size; i++) { |
| 7466 | + ctl = mixer_get_ctl_by_name(mixer, path_para[i].control); |
| 7467 | + num_values = mixer_ctl_get_num_values(ctl); |
| 7468 | + |
| 7469 | + for (j = 0; j < num_values; j++) { |
| 7470 | + mixer_ctl_set_value(ctl, j, onoff); |
| 7471 | + } |
| 7472 | + |
| 7473 | +// mix_set_value_wrap(mixer, spk_path_onoff[i].control, spk_path_onoff[i].values); |
| 7474 | + } |
| 7475 | + |
| 7476 | + return 0; |
| 7477 | +} |
| 7478 | +*/ |
| 7479 | + |
| 7480 | + |
| 7481 | + |
| 7482 | + |
| 7483 | + |
| 7484 | + |
| 7485 | +int mix_set_voice_path(struct mixer *mixer, int path) |
| 7486 | +{ |
| 7487 | + int i; |
| 7488 | +/* |
| 7489 | + for (i = 0; i < ARRAY_SIZE(common_in_para_audio); i++) { |
| 7490 | + tinymix_set_value_test(mixer, common_in_para_audio[i].control, common_in_para_audio[i].values); |
| 7491 | + } |
| 7492 | + |
| 7493 | + for(i = 0;i<ARRAY_SIZE(common_out_para_audio);i++) |
| 7494 | + { |
| 7495 | + tinymix_set_value_test(mixer,common_out_para_audio[i].control,common_out_para_audio[i].values); |
| 7496 | + } |
| 7497 | +*/ |
| 7498 | + switch (path) { |
| 7499 | + case T_OUTPUT_RECEIVER: |
| 7500 | + for (i = 0; i < ARRAY_SIZE(handset_inoutpath_para_voice); i++) { |
| 7501 | + mix_set_value_wrap(mixer, handset_inoutpath_para_voice[i].control, handset_inoutpath_para_voice[i].values); |
| 7502 | + } |
| 7503 | + break; |
| 7504 | + case T_OUTPUT_SPEAKER: |
| 7505 | + for (i = 0; i < ARRAY_SIZE(spk_inoutpath_para_voice); i++) { |
| 7506 | + mix_set_value_wrap(mixer, spk_inoutpath_para_voice[i].control, spk_inoutpath_para_voice[i].values); |
| 7507 | + } |
| 7508 | + break; |
| 7509 | + case T_OUTPUT_HEADSET: |
| 7510 | + for (i = 0; i < ARRAY_SIZE(headset_inoutpath_para_voice); i++) { |
| 7511 | + mix_set_value_wrap(mixer, headset_inoutpath_para_voice[i].control, headset_inoutpath_para_voice[i].values); |
| 7512 | + } |
| 7513 | + default: |
| 7514 | + break; |
| 7515 | + } |
| 7516 | + |
| 7517 | + return 0; |
| 7518 | +} |
| 7519 | + |
| 7520 | + |
| 7521 | +int mix_get_voice_path(struct mixer *mixer, int *path) |
| 7522 | +{ |
| 7523 | + |
| 7524 | + mix_get_value_wrap(mixer, "audio path select", path); |
| 7525 | + |
| 7526 | + return 0; |
| 7527 | + |
| 7528 | +} |
| 7529 | +/* |
| 7530 | + |
| 7531 | +int mix_set_in_call_tone(struct mixer *mixer, int tontype) |
| 7532 | +{ |
| 7533 | + struct mixer_ctl *ctl; |
| 7534 | + char name[] = "voice tone sel"; |
| 7535 | + ctl = mixer_get_ctl_by_name(mixer, name); |
| 7536 | + if (!ctl) { |
| 7537 | + fprintf(stderr, "Invalid mixer control\n"); |
| 7538 | + return -1; |
| 7539 | + } |
| 7540 | + |
| 7541 | + mixer_ctl_set_value(ctl, 0, tontype); |
| 7542 | + |
| 7543 | + return 0; |
| 7544 | +} |
| 7545 | + |
| 7546 | +int mix_set_default_param(struct mixer *mixer) |
| 7547 | +{ |
| 7548 | + int i; |
| 7549 | + for (i = 0; i < ARRAY_SIZE(init_default_para); i++) { |
| 7550 | + mix_set_value_wrap(mixer, init_default_para[i].control, init_default_para[i].values); |
| 7551 | + } |
| 7552 | + |
| 7553 | + return 0; |
| 7554 | +} |
| 7555 | + |
| 7556 | +*/ |
| 7557 | + |
| 7558 | + |
| 7559 | + |
| 7560 | + |
| 7561 | +//����voice��Ƶ�豸ģʽ dev_mode��handset,speaker,headset 0 ��ʾ�ɹ��� ������ʾ�д��� |
| 7562 | +int set_voice_device_mode(int dev_mode) |
| 7563 | +{ |
| 7564 | + |
| 7565 | + struct mixer *voice_mixer = NULL; |
| 7566 | + printf("%s: start dev_mode=%d!\n",__func__, dev_mode); |
| 7567 | + |
| 7568 | + if ((dev_mode < T_OUTPUT_HANDSET ) ||(dev_mode >= T_OUTPUT_MAX)){ |
| 7569 | + printf("%s: dev_mode not support, dev_mode=%d!\n",__func__, dev_mode); |
| 7570 | + return -1; |
| 7571 | + } |
| 7572 | + |
| 7573 | + //open mixer dev for control |
| 7574 | + voice_mixer = mixer_open(VOCIE_SND_CARD_NUM); |
| 7575 | + if (!voice_mixer) { |
| 7576 | + printf("voice_mixer open failed!\n"); |
| 7577 | + return -1; |
| 7578 | + } |
| 7579 | + |
| 7580 | + //config mixer dev |
| 7581 | + mix_set_voice_path(voice_mixer, dev_mode); |
| 7582 | + |
| 7583 | + //close mixer |
| 7584 | + mixer_close(voice_mixer); |
| 7585 | + voice_mixer = NULL; |
| 7586 | + |
| 7587 | + |
| 7588 | + return 0; |
| 7589 | + |
| 7590 | + |
| 7591 | +} |
| 7592 | + |
| 7593 | +//#ifdef _CPE_AUDIO_PRJ |
| 7594 | +#else |
| 7595 | +int mix_set_output_path(struct mixer *mixer, int path) |
| 7596 | +{ |
| 7597 | + |
| 7598 | + return 0; |
| 7599 | +} |
| 7600 | + |
| 7601 | +int mix_set_input_path(struct mixer *mixer, int path) |
| 7602 | +{ |
| 7603 | + |
| 7604 | + |
| 7605 | + return 0; |
| 7606 | +} |
| 7607 | + |
| 7608 | +int mix_set_input_vol(struct mixer *mixer, int volume) |
| 7609 | +{ |
| 7610 | + |
| 7611 | + |
| 7612 | + return 0; |
| 7613 | +} |
| 7614 | + |
| 7615 | +int mix_set_output_vol(struct mixer *mixer, int volume) |
| 7616 | +{ |
| 7617 | + |
| 7618 | + |
| 7619 | + return 0; |
| 7620 | +} |
| 7621 | + |
| 7622 | +int mix_set_output_mute(struct mixer *mixer, bool enable) |
| 7623 | +{ |
| 7624 | + |
| 7625 | + |
| 7626 | + return 0; |
| 7627 | +} |
| 7628 | + |
| 7629 | +int mix_set_input_mute(struct mixer *mixer, bool enable) |
| 7630 | +{ |
| 7631 | + |
| 7632 | + |
| 7633 | + return 0; |
| 7634 | +} |
| 7635 | + |
| 7636 | +int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff) |
| 7637 | +{ |
| 7638 | + |
| 7639 | + return 0; |
| 7640 | +} |
| 7641 | + |
| 7642 | + |
| 7643 | +int mix_set_voice_vol(struct mixer *mixer, int volume) |
| 7644 | +{ |
| 7645 | + |
| 7646 | + |
| 7647 | + return 0; |
| 7648 | +} |
| 7649 | + |
| 7650 | +int mix_set_voice_mute(struct mixer *mixer, bool enable) |
| 7651 | +{ |
| 7652 | + |
| 7653 | + |
| 7654 | + return 0; |
| 7655 | +} |
| 7656 | + |
| 7657 | +int mix_set_voice_path(struct mixer *mixer, int path) |
| 7658 | +{ |
| 7659 | + int i; |
| 7660 | + |
| 7661 | + |
| 7662 | + return 0; |
| 7663 | +} |
| 7664 | + |
| 7665 | + |
| 7666 | +int mix_set_in_call_tone(struct mixer *mixer, int tontype) |
| 7667 | +{ |
| 7668 | + |
| 7669 | + |
| 7670 | + return 0; |
| 7671 | +} |
| 7672 | + |
| 7673 | +int mix_set_default_param(struct mixer *mixer) |
| 7674 | +{ |
| 7675 | + |
| 7676 | + return 0; |
| 7677 | +} |
| 7678 | + |
| 7679 | +int mix_get_voice_vol(struct mixer *mixer, int *volume) |
| 7680 | +{ |
| 7681 | + |
| 7682 | + return 0; |
| 7683 | +} |
| 7684 | + |
| 7685 | +int mix_set_tx_voice_vol(struct mixer *mixer, int volume) |
| 7686 | +{ |
| 7687 | + return 0; |
| 7688 | +} |
| 7689 | + |
| 7690 | +int mix_get_tx_voice_vol(struct mixer *mixer, int *volume) |
| 7691 | +{ |
| 7692 | + |
| 7693 | + return 0; |
| 7694 | + |
| 7695 | +} |
| 7696 | + |
| 7697 | +int mix_get_voice_mute(struct mixer *mixer, int *enable) |
| 7698 | +{ |
| 7699 | + |
| 7700 | + return 0; |
| 7701 | + |
| 7702 | +} |
| 7703 | + |
| 7704 | +//voice downlink mute |
| 7705 | + |
| 7706 | +int mix_set_rx_voice_mute(struct mixer *mixer, bool enable) |
| 7707 | +{ |
| 7708 | + return 0; |
| 7709 | +} |
| 7710 | +int mix_get_rx_voice_mute(struct mixer *mixer, int *enable) |
| 7711 | +{ |
| 7712 | + |
| 7713 | + return 0; |
| 7714 | + |
| 7715 | +} |
| 7716 | + |
| 7717 | +int mix_get_voice_path(struct mixer *mixer, int *path) |
| 7718 | +{ |
| 7719 | + |
| 7720 | + return 0; |
| 7721 | + |
| 7722 | +} |
| 7723 | + |
| 7724 | +int set_voice_device_mode(int dev_mode) |
| 7725 | +{ |
| 7726 | + return 0; |
| 7727 | +} |
| 7728 | + |
| 7729 | +#endif |
| 7730 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/include/tinyalsa/asoundlib.h b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/include/tinyalsa/asoundlib.h |
| 7731 | new file mode 100755 |
| 7732 | index 0000000..97ee4f3 |
| 7733 | --- /dev/null |
| 7734 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/include/tinyalsa/asoundlib.h |
| 7735 | @@ -0,0 +1,310 @@ |
| 7736 | +/* asoundlib.h |
| 7737 | +** |
| 7738 | +** Copyright 2011, The Android Open Source Project |
| 7739 | +** |
| 7740 | +** Redistribution and use in source and binary forms, with or without |
| 7741 | +** modification, are permitted provided that the following conditions are met: |
| 7742 | +** * Redistributions of source code must retain the above copyright |
| 7743 | +** notice, this list of conditions and the following disclaimer. |
| 7744 | +** * Redistributions in binary form must reproduce the above copyright |
| 7745 | +** notice, this list of conditions and the following disclaimer in the |
| 7746 | +** documentation and/or other materials provided with the distribution. |
| 7747 | +** * Neither the name of The Android Open Source Project nor the names of |
| 7748 | +** its contributors may be used to endorse or promote products derived |
| 7749 | +** from this software without specific prior written permission. |
| 7750 | +** |
| 7751 | +** THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND |
| 7752 | +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 7753 | +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 7754 | +** ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE |
| 7755 | +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 7756 | +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 7757 | +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 7758 | +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 7759 | +** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 7760 | +** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 7761 | +** DAMAGE. |
| 7762 | +*/ |
| 7763 | + |
| 7764 | +#ifndef ASOUNDLIB_H |
| 7765 | +#define ASOUNDLIB_H |
| 7766 | + |
| 7767 | +#include <sys/time.h> |
| 7768 | +#include <stddef.h> |
| 7769 | + |
| 7770 | +#if defined(__cplusplus) |
| 7771 | +extern "C" { |
| 7772 | +#endif |
| 7773 | + |
| 7774 | +/* |
| 7775 | + * PCM API |
| 7776 | + */ |
| 7777 | + |
| 7778 | +struct pcm; |
| 7779 | + |
| 7780 | +#define PCM_OUT 0x00000000 |
| 7781 | +#define PCM_IN 0x10000000 |
| 7782 | +#define PCM_MMAP 0x00000001 |
| 7783 | +#define PCM_NOIRQ 0x00000002 |
| 7784 | +#define PCM_NORESTART 0x00000004 /* PCM_NORESTART - when set, calls to |
| 7785 | + * pcm_write for a playback stream will not |
| 7786 | + * attempt to restart the stream in the case |
| 7787 | + * of an underflow, but will return -EPIPE |
| 7788 | + * instead. After the first -EPIPE error, the |
| 7789 | + * stream is considered to be stopped, and a |
| 7790 | + * second call to pcm_write will attempt to |
| 7791 | + * restart the stream. |
| 7792 | + */ |
| 7793 | +#define PCM_MONOTONIC 0x00000008 /* see pcm_get_htimestamp */ |
| 7794 | + |
| 7795 | +/* PCM runtime states */ |
| 7796 | +#define PCM_STATE_OPEN 0 |
| 7797 | +#define PCM_STATE_SETUP 1 |
| 7798 | +#define PCM_STATE_PREPARED 2 |
| 7799 | +#define PCM_STATE_RUNNING 3 |
| 7800 | +#define PCM_STATE_XRUN 4 |
| 7801 | +#define PCM_STATE_DRAINING 5 |
| 7802 | +#define PCM_STATE_PAUSED 6 |
| 7803 | +#define PCM_STATE_SUSPENDED 7 |
| 7804 | +#define PCM_STATE_DISCONNECTED 8 |
| 7805 | + |
| 7806 | +/* Bit formats */ |
| 7807 | +enum pcm_format { |
| 7808 | + PCM_FORMAT_INVALID = -1, |
| 7809 | + PCM_FORMAT_S16_LE = 0, /* 16-bit signed */ |
| 7810 | + PCM_FORMAT_S32_LE, /* 32-bit signed */ |
| 7811 | + PCM_FORMAT_S8, /* 8-bit signed */ |
| 7812 | + PCM_FORMAT_S24_LE, /* 24-bits in 4-bytes */ |
| 7813 | + PCM_FORMAT_S24_3LE, /* 24-bits in 3-bytes */ |
| 7814 | + |
| 7815 | + PCM_FORMAT_MAX, |
| 7816 | +}; |
| 7817 | + |
| 7818 | +/* Bitmask has 256 bits (32 bytes) in asound.h */ |
| 7819 | +struct pcm_mask { |
| 7820 | + unsigned int bits[32 / sizeof(unsigned int)]; |
| 7821 | +}; |
| 7822 | + |
| 7823 | +/* Configuration for a stream */ |
| 7824 | +struct pcm_config { |
| 7825 | + unsigned int channels; |
| 7826 | + unsigned int rate; |
| 7827 | + unsigned int period_size; |
| 7828 | + unsigned int period_count; |
| 7829 | + enum pcm_format format; |
| 7830 | + |
| 7831 | + /* Values to use for the ALSA start, stop and silence thresholds, and |
| 7832 | + * silence size. Setting any one of these values to 0 will cause the |
| 7833 | + * default tinyalsa values to be used instead. |
| 7834 | + * Tinyalsa defaults are as follows. |
| 7835 | + * |
| 7836 | + * start_threshold : period_count * period_size |
| 7837 | + * stop_threshold : period_count * period_size |
| 7838 | + * silence_threshold : 0 |
| 7839 | + * silence_size : 0 |
| 7840 | + */ |
| 7841 | + unsigned int start_threshold; |
| 7842 | + unsigned int stop_threshold; |
| 7843 | + unsigned int silence_threshold; |
| 7844 | + unsigned int silence_size; |
| 7845 | + |
| 7846 | + /* Minimum number of frames available before pcm_mmap_write() will actually |
| 7847 | + * write into the kernel buffer. Only used if the stream is opened in mmap mode |
| 7848 | + * (pcm_open() called with PCM_MMAP flag set). Use 0 for default. |
| 7849 | + */ |
| 7850 | + int avail_min; |
| 7851 | +}; |
| 7852 | + |
| 7853 | +/* PCM parameters */ |
| 7854 | +enum pcm_param |
| 7855 | +{ |
| 7856 | + /* mask parameters */ |
| 7857 | + PCM_PARAM_ACCESS, |
| 7858 | + PCM_PARAM_FORMAT, |
| 7859 | + PCM_PARAM_SUBFORMAT, |
| 7860 | + /* interval parameters */ |
| 7861 | + PCM_PARAM_SAMPLE_BITS, |
| 7862 | + PCM_PARAM_FRAME_BITS, |
| 7863 | + PCM_PARAM_CHANNELS, |
| 7864 | + PCM_PARAM_RATE, |
| 7865 | + PCM_PARAM_PERIOD_TIME, |
| 7866 | + PCM_PARAM_PERIOD_SIZE, |
| 7867 | + PCM_PARAM_PERIOD_BYTES, |
| 7868 | + PCM_PARAM_PERIODS, |
| 7869 | + PCM_PARAM_BUFFER_TIME, |
| 7870 | + PCM_PARAM_BUFFER_SIZE, |
| 7871 | + PCM_PARAM_BUFFER_BYTES, |
| 7872 | + PCM_PARAM_TICK_TIME, |
| 7873 | +}; |
| 7874 | + |
| 7875 | +/* Mixer control types */ |
| 7876 | +enum mixer_ctl_type { |
| 7877 | + MIXER_CTL_TYPE_BOOL, |
| 7878 | + MIXER_CTL_TYPE_INT, |
| 7879 | + MIXER_CTL_TYPE_ENUM, |
| 7880 | + MIXER_CTL_TYPE_BYTE, |
| 7881 | + MIXER_CTL_TYPE_IEC958, |
| 7882 | + MIXER_CTL_TYPE_INT64, |
| 7883 | + MIXER_CTL_TYPE_UNKNOWN, |
| 7884 | + |
| 7885 | + MIXER_CTL_TYPE_MAX, |
| 7886 | +}; |
| 7887 | + |
| 7888 | +/* Open and close a stream */ |
| 7889 | +struct pcm *pcm_open(unsigned int card, unsigned int device, |
| 7890 | + unsigned int flags, struct pcm_config *config); |
| 7891 | +int pcm_close(struct pcm *pcm); |
| 7892 | +int pcm_is_ready(struct pcm *pcm); |
| 7893 | + |
| 7894 | +/* Obtain the parameters for a PCM */ |
| 7895 | +struct pcm_params *pcm_params_get(unsigned int card, unsigned int device, |
| 7896 | + unsigned int flags); |
| 7897 | +void pcm_params_free(struct pcm_params *pcm_params); |
| 7898 | + |
| 7899 | +struct pcm_mask *pcm_params_get_mask(struct pcm_params *pcm_params, |
| 7900 | + enum pcm_param param); |
| 7901 | +unsigned int pcm_params_get_min(struct pcm_params *pcm_params, |
| 7902 | + enum pcm_param param); |
| 7903 | +void pcm_params_set_min(struct pcm_params *pcm_params, |
| 7904 | + enum pcm_param param, unsigned int val); |
| 7905 | +unsigned int pcm_params_get_max(struct pcm_params *pcm_params, |
| 7906 | + enum pcm_param param); |
| 7907 | +void pcm_params_set_max(struct pcm_params *pcm_params, |
| 7908 | + enum pcm_param param, unsigned int val); |
| 7909 | + |
| 7910 | +/* Converts the pcm parameters to a human readable string. |
| 7911 | + * The string parameter is a caller allocated buffer of size bytes, |
| 7912 | + * which is then filled up to size - 1 and null terminated, |
| 7913 | + * if size is greater than zero. |
| 7914 | + * The return value is the number of bytes copied to string |
| 7915 | + * (not including null termination) if less than size; otherwise, |
| 7916 | + * the number of bytes required for the buffer. |
| 7917 | + */ |
| 7918 | +int pcm_params_to_string(struct pcm_params *params, char *string, unsigned int size); |
| 7919 | + |
| 7920 | +/* Returns 1 if the pcm_format is present (format bit set) in |
| 7921 | + * the pcm_params structure; 0 otherwise, or upon unrecognized format. |
| 7922 | + */ |
| 7923 | +int pcm_params_format_test(struct pcm_params *params, enum pcm_format format); |
| 7924 | + |
| 7925 | +/* Set and get config */ |
| 7926 | +int pcm_get_config(struct pcm *pcm, struct pcm_config *config); |
| 7927 | +int pcm_set_config(struct pcm *pcm, struct pcm_config *config); |
| 7928 | + |
| 7929 | +/* Returns a human readable reason for the last error */ |
| 7930 | +const char *pcm_get_error(struct pcm *pcm); |
| 7931 | + |
| 7932 | +/* Returns the sample size in bits for a PCM format. |
| 7933 | + * As with ALSA formats, this is the storage size for the format, whereas the |
| 7934 | + * format represents the number of significant bits. For example, |
| 7935 | + * PCM_FORMAT_S24_LE uses 32 bits of storage. |
| 7936 | + */ |
| 7937 | +unsigned int pcm_format_to_bits(enum pcm_format format); |
| 7938 | + |
| 7939 | +/* Returns the buffer size (int frames) that should be used for pcm_write. */ |
| 7940 | +unsigned int pcm_get_buffer_size(struct pcm *pcm); |
| 7941 | +unsigned int pcm_frames_to_bytes(struct pcm *pcm, unsigned int frames); |
| 7942 | +unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int bytes); |
| 7943 | + |
| 7944 | +/* Returns the pcm latency in ms */ |
| 7945 | +unsigned int pcm_get_latency(struct pcm *pcm); |
| 7946 | + |
| 7947 | +/* Returns available frames in pcm buffer and corresponding time stamp. |
| 7948 | + * The clock is CLOCK_MONOTONIC if flag PCM_MONOTONIC was specified in pcm_open, |
| 7949 | + * otherwise the clock is CLOCK_REALTIME. |
| 7950 | + * For an input stream, frames available are frames ready for the |
| 7951 | + * application to read. |
| 7952 | + * For an output stream, frames available are the number of empty frames available |
| 7953 | + * for the application to write. |
| 7954 | + */ |
| 7955 | +int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, |
| 7956 | + struct timespec *tstamp); |
| 7957 | + |
| 7958 | +/* Write data to the fifo. |
| 7959 | + * Will start playback on the first write or on a write that |
| 7960 | + * occurs after a fifo underrun. |
| 7961 | + */ |
| 7962 | +int pcm_write(struct pcm *pcm, const void *data, unsigned int count); |
| 7963 | +int pcm_read(struct pcm *pcm, void *data, unsigned int count); |
| 7964 | + |
| 7965 | +/* |
| 7966 | + * mmap() support. |
| 7967 | + */ |
| 7968 | +int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count); |
| 7969 | +int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count); |
| 7970 | +int pcm_mmap_begin(struct pcm *pcm, void **areas, unsigned int *offset, |
| 7971 | + unsigned int *frames); |
| 7972 | +int pcm_mmap_commit(struct pcm *pcm, unsigned int offset, unsigned int frames); |
| 7973 | +int pcm_mmap_avail(struct pcm *pcm); |
| 7974 | + |
| 7975 | +/* Prepare the PCM substream to be triggerable */ |
| 7976 | +int pcm_prepare(struct pcm *pcm); |
| 7977 | +/* Start and stop a PCM channel that doesn't transfer data */ |
| 7978 | +int pcm_start(struct pcm *pcm); |
| 7979 | +int pcm_stop(struct pcm *pcm); |
| 7980 | + |
| 7981 | +/* ioctl function for PCM driver */ |
| 7982 | +int pcm_ioctl(struct pcm *pcm, int request, ...); |
| 7983 | + |
| 7984 | +/* Interrupt driven API */ |
| 7985 | +int pcm_wait(struct pcm *pcm, int timeout); |
| 7986 | +int pcm_get_poll_fd(struct pcm *pcm); |
| 7987 | + |
| 7988 | +/* Change avail_min after the stream has been opened with no need to stop the stream. |
| 7989 | + * Only accepted if opened with PCM_MMAP and PCM_NOIRQ flags |
| 7990 | + */ |
| 7991 | +int pcm_set_avail_min(struct pcm *pcm, int avail_min); |
| 7992 | + |
| 7993 | +/* |
| 7994 | + * MIXER API |
| 7995 | + */ |
| 7996 | + |
| 7997 | +struct mixer; |
| 7998 | +struct mixer_ctl; |
| 7999 | + |
| 8000 | +/* Open and close a mixer */ |
| 8001 | +struct mixer *mixer_open(unsigned int card); |
| 8002 | +void mixer_close(struct mixer *mixer); |
| 8003 | + |
| 8004 | +/* Get info about a mixer */ |
| 8005 | +const char *mixer_get_name(struct mixer *mixer); |
| 8006 | + |
| 8007 | +/* Obtain mixer controls */ |
| 8008 | +unsigned int mixer_get_num_ctls(struct mixer *mixer); |
| 8009 | +struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id); |
| 8010 | +struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name); |
| 8011 | + |
| 8012 | +/* Get info about mixer controls */ |
| 8013 | +const char *mixer_ctl_get_name(struct mixer_ctl *ctl); |
| 8014 | +enum mixer_ctl_type mixer_ctl_get_type(struct mixer_ctl *ctl); |
| 8015 | +const char *mixer_ctl_get_type_string(struct mixer_ctl *ctl); |
| 8016 | +unsigned int mixer_ctl_get_num_values(struct mixer_ctl *ctl); |
| 8017 | +unsigned int mixer_ctl_get_num_enums(struct mixer_ctl *ctl); |
| 8018 | +const char *mixer_ctl_get_enum_string(struct mixer_ctl *ctl, |
| 8019 | + unsigned int enum_id); |
| 8020 | + |
| 8021 | +/* Some sound cards update their controls due to external events, |
| 8022 | + * such as HDMI EDID byte data changing when an HDMI cable is |
| 8023 | + * connected. This API allows the count of elements to be updated. |
| 8024 | + */ |
| 8025 | +void mixer_ctl_update(struct mixer_ctl *ctl); |
| 8026 | + |
| 8027 | +/* Set and get mixer controls */ |
| 8028 | +int mixer_ctl_get_percent(struct mixer_ctl *ctl, unsigned int id); |
| 8029 | +int mixer_ctl_set_percent(struct mixer_ctl *ctl, unsigned int id, int percent); |
| 8030 | + |
| 8031 | +int mixer_ctl_get_value(struct mixer_ctl *ctl, unsigned int id); |
| 8032 | +int mixer_ctl_get_array(struct mixer_ctl *ctl, void *array, size_t count); |
| 8033 | +int mixer_ctl_set_value(struct mixer_ctl *ctl, unsigned int id, int value); |
| 8034 | +int mixer_ctl_set_array(struct mixer_ctl *ctl, const void *array, size_t count); |
| 8035 | +int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string); |
| 8036 | + |
| 8037 | +/* Determe range of integer mixer controls */ |
| 8038 | +int mixer_ctl_get_range_min(struct mixer_ctl *ctl); |
| 8039 | +int mixer_ctl_get_range_max(struct mixer_ctl *ctl); |
| 8040 | + |
| 8041 | +#if defined(__cplusplus) |
| 8042 | +} /* extern "C" */ |
| 8043 | +#endif |
| 8044 | + |
| 8045 | +#endif |
| 8046 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/include/tinyalsa/audio_mixer_ctrl.h b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/include/tinyalsa/audio_mixer_ctrl.h |
| 8047 | new file mode 100755 |
| 8048 | index 0000000..da78caa |
| 8049 | --- /dev/null |
| 8050 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/include/tinyalsa/audio_mixer_ctrl.h |
| 8051 | @@ -0,0 +1,96 @@ |
| 8052 | +#ifndef _AUDIO_MIXER_CTRL_H |
| 8053 | +#define _AUDIO_MIXER_CTRL_H |
| 8054 | +#include <stdint.h> |
| 8055 | +#include <stdbool.h> |
| 8056 | +#include <tinyalsa/asoundlib.h> |
| 8057 | +#include <sound/asound.h> |
| 8058 | + |
| 8059 | +enum t_tone_class { |
| 8060 | + T_LOWPOWER_TONE = 0, |
| 8061 | + T_SMS_TONE = 1, |
| 8062 | + T_CALLSTD_TONE = 2, |
| 8063 | + T_ALARM_TONE = 3, |
| 8064 | + T_CALL_TIME_TONE = 4, |
| 8065 | +}; |
| 8066 | + |
| 8067 | +enum t_output_path { |
| 8068 | + T_OUTPUT_RECEIVER = 0, |
| 8069 | + T_OUTPUT_HANDSET = T_OUTPUT_RECEIVER, |
| 8070 | + T_OUTPUT_SPEAKER = 1, |
| 8071 | + T_OUTPUT_HEADSET = 2, |
| 8072 | + T_OUTPUT_MAX, |
| 8073 | + |
| 8074 | +}; |
| 8075 | + |
| 8076 | + |
| 8077 | +enum t_input_path { |
| 8078 | + T_INPUT_MICLP = 0, |
| 8079 | + T_INPUT_MICRP = 1, |
| 8080 | + T_INPUT_HANDSET = T_INPUT_MICLP, |
| 8081 | + T_INPUT_SPEAKER = T_INPUT_MICRP, |
| 8082 | + T_INPUT_HEADSET = 2, |
| 8083 | + T_INPUT_MAX, |
| 8084 | +}; |
| 8085 | + |
| 8086 | +enum t_audio_out_vol { |
| 8087 | + T_AUDIO_OUTPUT_VOL_LEVEL_0 = 0, |
| 8088 | + T_AUDIO_OUTPUT_VOL_LEVEL_1, |
| 8089 | + T_AUDIO_OUTPUT_VOL_LEVEL_2, |
| 8090 | + T_AUDIO_OUTPUT_VOL_LEVEL_3, |
| 8091 | + T_AUDIO_OUTPUT_VOL_LEVEL_4, |
| 8092 | + T_AUDIO_OUTPUT_VOL_LEVEL_5, |
| 8093 | + T_AUDIO_OUTPUT_VOL_LEVEL_6, |
| 8094 | + T_AUDIO_OUTPUT_VOL_LEVEL_7, |
| 8095 | + T_AUDIO_OUTPUT_VOL_LEVEL_8, |
| 8096 | + T_AUDIO_OUTPUT_VOL_LEVEL_9, |
| 8097 | + T_AUDIO_OUTPUT_VOL_LEVEL_10, |
| 8098 | + T_AUDIO_OUTPUT_VOL_LEVEL_11, |
| 8099 | + T_AUDIO_OUTPUT_VOL_LEVEL_12, |
| 8100 | + T_AUDIO_OUTPUT_VOL_LEVEL_13, |
| 8101 | + T_AUDIO_OUTPUT_VOL_LEVEL_14, |
| 8102 | + T_AUDIO_OUTPUT_VOL_LEVEL_15, |
| 8103 | + T_AUDIO_OUTPUT_VOL_LEVEL_16, |
| 8104 | + T_MAX_AUDIO_OUTPUT_VOL_LEVEL |
| 8105 | +}; |
| 8106 | + |
| 8107 | +enum t_audio_in_vol { |
| 8108 | + T_AUDIO_INPUT_VOL_LEVEL_0 = 0, |
| 8109 | + T_AUDIO_INPUT_VOL_LEVEL_1, |
| 8110 | + T_AUDIO_INPUT_VOL_LEVEL_2, |
| 8111 | + T_AUDIO_INPUT_VOL_LEVEL_3, |
| 8112 | + T_AUDIO_INPUT_VOL_LEVEL_4, |
| 8113 | + T_AUDIO_INPUT_VOL_LEVEL_5, |
| 8114 | + T_AUDIO_INPUT_VOL_LEVEL_6, |
| 8115 | + T_AUDIO_INPUT_VOL_LEVEL_7, |
| 8116 | + T_AUDIO_INPUT_VOL_LEVEL_8, |
| 8117 | + T_AUDIO_INPUT_VOL_LEVEL_9, |
| 8118 | + T_AUDIO_INPUT_VOL_LEVEL_10, |
| 8119 | + T_AUDIO_INPUT_VOL_LEVEL_11, |
| 8120 | + |
| 8121 | + T_MAX_AUDIO_INPUT_VOL_LEVEL |
| 8122 | +} ; |
| 8123 | + |
| 8124 | +enum t_voice_vol { // volume level for voice |
| 8125 | + T_VOICE_VOL_0_LEVEL = 0, |
| 8126 | + T_VOICE_VOL_1_LEVEL = 1, |
| 8127 | + T_VOICE_VOL_2_LEVEL = 2, |
| 8128 | + T_VOICE_VOL_3_LEVEL = 3, |
| 8129 | + T_VOICE_VOL_4_LEVEL = 4, |
| 8130 | + T_VOICE_VOL_5_LEVEL = 5, |
| 8131 | +}; |
| 8132 | + |
| 8133 | +int mix_set_output_path(struct mixer *mixer, int path); |
| 8134 | +int mix_set_input_path(struct mixer *mixer, int path); |
| 8135 | +int mix_set_input_vol(struct mixer *mixer, int volume); |
| 8136 | +int mix_set_output_vol(struct mixer *mixer, int volume); |
| 8137 | +int mix_set_output_mute(struct mixer *mixer, bool enable); |
| 8138 | +int mix_set_input_mute(struct mixer *mixer, bool enable); |
| 8139 | +int mix_set_outputpath_onoff(struct mixer *mixer, int path ,bool onoff); |
| 8140 | +int mix_set_voice_vol(struct mixer *mixer, int volume); |
| 8141 | +int mix_set_voice_mute(struct mixer *mixer, bool enable); |
| 8142 | +int mix_set_voice_path(struct mixer *mixer, int path); |
| 8143 | +int mix_set_in_call_tone(struct mixer *mixer, int tontype); |
| 8144 | +int mix_set_default_param(struct mixer *mixer); |
| 8145 | +int set_voice_device_mode(int dev_mode); |
| 8146 | + |
| 8147 | +#endif |
| 8148 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/mixer.c b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/mixer.c |
| 8149 | new file mode 100755 |
| 8150 | index 0000000..c4e6765 |
| 8151 | --- /dev/null |
| 8152 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/mixer.c |
| 8153 | @@ -0,0 +1,555 @@ |
| 8154 | +/* mixer.c |
| 8155 | +** |
| 8156 | +** Copyright 2011, The Android Open Source Project |
| 8157 | +** |
| 8158 | +** Redistribution and use in source and binary forms, with or without |
| 8159 | +** modification, are permitted provided that the following conditions are met: |
| 8160 | +** * Redistributions of source code must retain the above copyright |
| 8161 | +** notice, this list of conditions and the following disclaimer. |
| 8162 | +** * Redistributions in binary form must reproduce the above copyright |
| 8163 | +** notice, this list of conditions and the following disclaimer in the |
| 8164 | +** documentation and/or other materials provided with the distribution. |
| 8165 | +** * Neither the name of The Android Open Source Project nor the names of |
| 8166 | +** its contributors may be used to endorse or promote products derived |
| 8167 | +** from this software without specific prior written permission. |
| 8168 | +** |
| 8169 | +** THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND |
| 8170 | +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 8171 | +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 8172 | +** ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE |
| 8173 | +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 8174 | +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 8175 | +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 8176 | +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 8177 | +** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 8178 | +** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 8179 | +** DAMAGE. |
| 8180 | +*/ |
| 8181 | + |
| 8182 | +#include <stdio.h> |
| 8183 | +#include <stdlib.h> |
| 8184 | +#include <stdint.h> |
| 8185 | +#include <string.h> |
| 8186 | +#include <unistd.h> |
| 8187 | +#include <fcntl.h> |
| 8188 | +#include <errno.h> |
| 8189 | +#include <ctype.h> |
| 8190 | + |
| 8191 | +#include <sys/ioctl.h> |
| 8192 | + |
| 8193 | +#include <linux/ioctl.h> |
| 8194 | +#define __force |
| 8195 | +#define __bitwise |
| 8196 | +#define __user |
| 8197 | +#include <sound/asound.h> |
| 8198 | + |
| 8199 | +#include <tinyalsa/asoundlib.h> |
| 8200 | + |
| 8201 | +struct mixer_ctl { |
| 8202 | + struct mixer *mixer; |
| 8203 | + struct snd_ctl_elem_info *info; |
| 8204 | + char **ename; |
| 8205 | +}; |
| 8206 | + |
| 8207 | +struct mixer { |
| 8208 | + int fd; |
| 8209 | + struct snd_ctl_card_info card_info; |
| 8210 | + struct snd_ctl_elem_info *elem_info; |
| 8211 | + struct mixer_ctl *ctl; |
| 8212 | + unsigned int count; |
| 8213 | +}; |
| 8214 | + |
| 8215 | +void mixer_close(struct mixer *mixer) |
| 8216 | +{ |
| 8217 | + unsigned int n,m; |
| 8218 | + |
| 8219 | + if (!mixer) |
| 8220 | + return; |
| 8221 | + |
| 8222 | + if (mixer->fd >= 0) |
| 8223 | + close(mixer->fd); |
| 8224 | + |
| 8225 | + if (mixer->ctl) { |
| 8226 | + for (n = 0; n < mixer->count; n++) { |
| 8227 | + if (mixer->ctl[n].ename) { |
| 8228 | + unsigned int max = mixer->ctl[n].info->value.enumerated.items; |
| 8229 | + for (m = 0; m < max; m++) |
| 8230 | + free(mixer->ctl[n].ename[m]); |
| 8231 | + free(mixer->ctl[n].ename); |
| 8232 | + } |
| 8233 | + } |
| 8234 | + free(mixer->ctl); |
| 8235 | + } |
| 8236 | + |
| 8237 | + if (mixer->elem_info) |
| 8238 | + free(mixer->elem_info); |
| 8239 | + |
| 8240 | + free(mixer); |
| 8241 | + |
| 8242 | + /* TODO: verify frees */ |
| 8243 | +} |
| 8244 | + |
| 8245 | +struct mixer *mixer_open(unsigned int card) |
| 8246 | +{ |
| 8247 | + struct snd_ctl_elem_list elist; |
| 8248 | + struct snd_ctl_elem_info tmp; |
| 8249 | + struct snd_ctl_elem_id *eid = NULL; |
| 8250 | + struct mixer *mixer = NULL; |
| 8251 | + unsigned int n, m; |
| 8252 | + int fd; |
| 8253 | + char fn[256]; |
| 8254 | + |
| 8255 | + snprintf(fn, sizeof(fn), "/dev/snd/controlC%u", card); |
| 8256 | + fd = open(fn, O_RDWR); |
| 8257 | + if (fd < 0) |
| 8258 | + return 0; |
| 8259 | + |
| 8260 | + memset(&elist, 0, sizeof(elist)); |
| 8261 | + if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_LIST, &elist) < 0) |
| 8262 | + goto fail; |
| 8263 | + |
| 8264 | + mixer = calloc(1, sizeof(*mixer)); |
| 8265 | + if (!mixer) |
| 8266 | + goto fail; |
| 8267 | + |
| 8268 | + mixer->ctl = calloc(elist.count, sizeof(struct mixer_ctl)); |
| 8269 | + mixer->elem_info = calloc(elist.count, sizeof(struct snd_ctl_elem_info)); |
| 8270 | + if (!mixer->ctl || !mixer->elem_info) |
| 8271 | + goto fail; |
| 8272 | + |
| 8273 | + if (ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, &mixer->card_info) < 0) |
| 8274 | + goto fail; |
| 8275 | + |
| 8276 | + eid = calloc(elist.count, sizeof(struct snd_ctl_elem_id)); |
| 8277 | + if (!eid) |
| 8278 | + goto fail; |
| 8279 | + |
| 8280 | + mixer->count = elist.count; |
| 8281 | + mixer->fd = fd; |
| 8282 | + elist.space = mixer->count; |
| 8283 | + elist.pids = eid; |
| 8284 | + if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_LIST, &elist) < 0) |
| 8285 | + goto fail; |
| 8286 | + |
| 8287 | + for (n = 0; n < mixer->count; n++) { |
| 8288 | + struct snd_ctl_elem_info *ei = mixer->elem_info + n; |
| 8289 | + ei->id.numid = eid[n].numid; |
| 8290 | + if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_INFO, ei) < 0) |
| 8291 | + goto fail; |
| 8292 | + mixer->ctl[n].info = ei; |
| 8293 | + mixer->ctl[n].mixer = mixer; |
| 8294 | + if (ei->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED) { |
| 8295 | + char **enames = calloc(ei->value.enumerated.items, sizeof(char*)); |
| 8296 | + if (!enames) |
| 8297 | + goto fail; |
| 8298 | + mixer->ctl[n].ename = enames; |
| 8299 | + for (m = 0; m < ei->value.enumerated.items; m++) { |
| 8300 | + memset(&tmp, 0, sizeof(tmp)); |
| 8301 | + tmp.id.numid = ei->id.numid; |
| 8302 | + tmp.value.enumerated.item = m; |
| 8303 | + if (ioctl(fd, SNDRV_CTL_IOCTL_ELEM_INFO, &tmp) < 0) |
| 8304 | + goto fail; |
| 8305 | + enames[m] = strdup(tmp.value.enumerated.name); |
| 8306 | + if (!enames[m]) |
| 8307 | + goto fail; |
| 8308 | + } |
| 8309 | + } |
| 8310 | + } |
| 8311 | + |
| 8312 | + free(eid); |
| 8313 | + return mixer; |
| 8314 | + |
| 8315 | +fail: |
| 8316 | + /* TODO: verify frees in failure case */ |
| 8317 | + if (eid) |
| 8318 | + free(eid); |
| 8319 | + if (mixer) |
| 8320 | + mixer_close(mixer); |
| 8321 | + else if (fd >= 0) |
| 8322 | + close(fd); |
| 8323 | + return 0; |
| 8324 | +} |
| 8325 | + |
| 8326 | +const char *mixer_get_name(struct mixer *mixer) |
| 8327 | +{ |
| 8328 | + return (const char *)mixer->card_info.name; |
| 8329 | +} |
| 8330 | + |
| 8331 | +unsigned int mixer_get_num_ctls(struct mixer *mixer) |
| 8332 | +{ |
| 8333 | + if (!mixer) |
| 8334 | + return 0; |
| 8335 | + |
| 8336 | + return mixer->count; |
| 8337 | +} |
| 8338 | + |
| 8339 | +struct mixer_ctl *mixer_get_ctl(struct mixer *mixer, unsigned int id) |
| 8340 | +{ |
| 8341 | + if (mixer && (id < mixer->count)) |
| 8342 | + return mixer->ctl + id; |
| 8343 | + |
| 8344 | + return NULL; |
| 8345 | +} |
| 8346 | + |
| 8347 | +struct mixer_ctl *mixer_get_ctl_by_name(struct mixer *mixer, const char *name) |
| 8348 | +{ |
| 8349 | + unsigned int n; |
| 8350 | + |
| 8351 | + if (!mixer) |
| 8352 | + return NULL; |
| 8353 | + |
| 8354 | + for (n = 0; n < mixer->count; n++) |
| 8355 | + if (!strcmp(name, (char*) mixer->elem_info[n].id.name)) |
| 8356 | + return mixer->ctl + n; |
| 8357 | + |
| 8358 | + return NULL; |
| 8359 | +} |
| 8360 | + |
| 8361 | +void mixer_ctl_update(struct mixer_ctl *ctl) |
| 8362 | +{ |
| 8363 | + ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_INFO, ctl->info); |
| 8364 | +} |
| 8365 | + |
| 8366 | +const char *mixer_ctl_get_name(struct mixer_ctl *ctl) |
| 8367 | +{ |
| 8368 | + if (!ctl) |
| 8369 | + return NULL; |
| 8370 | + |
| 8371 | + return (const char *)ctl->info->id.name; |
| 8372 | +} |
| 8373 | + |
| 8374 | +enum mixer_ctl_type mixer_ctl_get_type(struct mixer_ctl *ctl) |
| 8375 | +{ |
| 8376 | + if (!ctl) |
| 8377 | + return MIXER_CTL_TYPE_UNKNOWN; |
| 8378 | + |
| 8379 | + switch (ctl->info->type) { |
| 8380 | + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: return MIXER_CTL_TYPE_BOOL; |
| 8381 | + case SNDRV_CTL_ELEM_TYPE_INTEGER: return MIXER_CTL_TYPE_INT; |
| 8382 | + case SNDRV_CTL_ELEM_TYPE_ENUMERATED: return MIXER_CTL_TYPE_ENUM; |
| 8383 | + case SNDRV_CTL_ELEM_TYPE_BYTES: return MIXER_CTL_TYPE_BYTE; |
| 8384 | + case SNDRV_CTL_ELEM_TYPE_IEC958: return MIXER_CTL_TYPE_IEC958; |
| 8385 | + case SNDRV_CTL_ELEM_TYPE_INTEGER64: return MIXER_CTL_TYPE_INT64; |
| 8386 | + default: return MIXER_CTL_TYPE_UNKNOWN; |
| 8387 | + }; |
| 8388 | +} |
| 8389 | + |
| 8390 | +const char *mixer_ctl_get_type_string(struct mixer_ctl *ctl) |
| 8391 | +{ |
| 8392 | + if (!ctl) |
| 8393 | + return ""; |
| 8394 | + |
| 8395 | + switch (ctl->info->type) { |
| 8396 | + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: return "BOOL"; |
| 8397 | + case SNDRV_CTL_ELEM_TYPE_INTEGER: return "INT"; |
| 8398 | + case SNDRV_CTL_ELEM_TYPE_ENUMERATED: return "ENUM"; |
| 8399 | + case SNDRV_CTL_ELEM_TYPE_BYTES: return "BYTE"; |
| 8400 | + case SNDRV_CTL_ELEM_TYPE_IEC958: return "IEC958"; |
| 8401 | + case SNDRV_CTL_ELEM_TYPE_INTEGER64: return "INT64"; |
| 8402 | + default: return "Unknown"; |
| 8403 | + }; |
| 8404 | +} |
| 8405 | + |
| 8406 | +unsigned int mixer_ctl_get_num_values(struct mixer_ctl *ctl) |
| 8407 | +{ |
| 8408 | + if (!ctl) |
| 8409 | + return 0; |
| 8410 | + |
| 8411 | + return ctl->info->count; |
| 8412 | +} |
| 8413 | + |
| 8414 | +static int percent_to_int(struct snd_ctl_elem_info *ei, int percent) |
| 8415 | +{ |
| 8416 | + int range; |
| 8417 | + |
| 8418 | + if (percent > 100) |
| 8419 | + percent = 100; |
| 8420 | + else if (percent < 0) |
| 8421 | + percent = 0; |
| 8422 | + |
| 8423 | + range = (ei->value.integer.max - ei->value.integer.min); |
| 8424 | + |
| 8425 | + return ei->value.integer.min + (range * percent) / 100; |
| 8426 | +} |
| 8427 | + |
| 8428 | +static int int_to_percent(struct snd_ctl_elem_info *ei, int value) |
| 8429 | +{ |
| 8430 | + int range = (ei->value.integer.max - ei->value.integer.min); |
| 8431 | + |
| 8432 | + if (range == 0) |
| 8433 | + return 0; |
| 8434 | + |
| 8435 | + return ((value - ei->value.integer.min) / range) * 100; |
| 8436 | +} |
| 8437 | + |
| 8438 | +int mixer_ctl_get_percent(struct mixer_ctl *ctl, unsigned int id) |
| 8439 | +{ |
| 8440 | + if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_INTEGER)) |
| 8441 | + return -EINVAL; |
| 8442 | + |
| 8443 | + return int_to_percent(ctl->info, mixer_ctl_get_value(ctl, id)); |
| 8444 | +} |
| 8445 | + |
| 8446 | +int mixer_ctl_set_percent(struct mixer_ctl *ctl, unsigned int id, int percent) |
| 8447 | +{ |
| 8448 | + if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_INTEGER)) |
| 8449 | + return -EINVAL; |
| 8450 | + |
| 8451 | + return mixer_ctl_set_value(ctl, id, percent_to_int(ctl->info, percent)); |
| 8452 | +} |
| 8453 | + |
| 8454 | +int mixer_ctl_get_value(struct mixer_ctl *ctl, unsigned int id) |
| 8455 | +{ |
| 8456 | + struct snd_ctl_elem_value ev; |
| 8457 | + int ret; |
| 8458 | + |
| 8459 | + if (!ctl || (id >= ctl->info->count)) |
| 8460 | + return -EINVAL; |
| 8461 | + |
| 8462 | + memset(&ev, 0, sizeof(ev)); |
| 8463 | + ev.id.numid = ctl->info->id.numid; |
| 8464 | + ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev); |
| 8465 | + if (ret < 0) |
| 8466 | + return ret; |
| 8467 | + |
| 8468 | + switch (ctl->info->type) { |
| 8469 | + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: |
| 8470 | + return !!ev.value.integer.value[id]; |
| 8471 | + |
| 8472 | + case SNDRV_CTL_ELEM_TYPE_INTEGER: |
| 8473 | + return ev.value.integer.value[id]; |
| 8474 | + |
| 8475 | + case SNDRV_CTL_ELEM_TYPE_ENUMERATED: |
| 8476 | + return ev.value.enumerated.item[id]; |
| 8477 | + |
| 8478 | + case SNDRV_CTL_ELEM_TYPE_BYTES: |
| 8479 | + return ev.value.bytes.data[id]; |
| 8480 | + |
| 8481 | + default: |
| 8482 | + return -EINVAL; |
| 8483 | + } |
| 8484 | + |
| 8485 | + return 0; |
| 8486 | +} |
| 8487 | + |
| 8488 | +int mixer_ctl_get_array(struct mixer_ctl *ctl, void *array, size_t count) |
| 8489 | +{ |
| 8490 | + struct snd_ctl_elem_value ev; |
| 8491 | + int ret = 0; |
| 8492 | + size_t size; |
| 8493 | + void *source; |
| 8494 | + |
| 8495 | + if (!ctl || (count > ctl->info->count) || !count || !array) |
| 8496 | + return -EINVAL; |
| 8497 | + |
| 8498 | + memset(&ev, 0, sizeof(ev)); |
| 8499 | + ev.id.numid = ctl->info->id.numid; |
| 8500 | + |
| 8501 | + switch (ctl->info->type) { |
| 8502 | + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: |
| 8503 | + case SNDRV_CTL_ELEM_TYPE_INTEGER: |
| 8504 | + ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev); |
| 8505 | + if (ret < 0) |
| 8506 | + return ret; |
| 8507 | + size = sizeof(ev.value.integer.value[0]); |
| 8508 | + source = ev.value.integer.value; |
| 8509 | + break; |
| 8510 | + |
| 8511 | + case SNDRV_CTL_ELEM_TYPE_BYTES: |
| 8512 | + /* check if this is new bytes TLV */ |
| 8513 | + if (ctl->info->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) { |
| 8514 | + struct snd_ctl_tlv *tlv; |
| 8515 | + int ret; |
| 8516 | + |
| 8517 | + if (count > SIZE_MAX - sizeof(*tlv)) |
| 8518 | + return -EINVAL; |
| 8519 | + tlv = calloc(1, sizeof(*tlv) + count); |
| 8520 | + if (!tlv) |
| 8521 | + return -ENOMEM; |
| 8522 | + tlv->numid = ctl->info->id.numid; |
| 8523 | + tlv->length = count; |
| 8524 | + ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_TLV_READ, tlv); |
| 8525 | + |
| 8526 | + source = tlv->tlv; |
| 8527 | + memcpy(array, source, count); |
| 8528 | + |
| 8529 | + free(tlv); |
| 8530 | + |
| 8531 | + return ret; |
| 8532 | + } else { |
| 8533 | + ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev); |
| 8534 | + if (ret < 0) |
| 8535 | + return ret; |
| 8536 | + size = sizeof(ev.value.bytes.data[0]); |
| 8537 | + source = ev.value.bytes.data; |
| 8538 | + break; |
| 8539 | + } |
| 8540 | + |
| 8541 | + case SNDRV_CTL_ELEM_TYPE_IEC958: |
| 8542 | + size = sizeof(ev.value.iec958); |
| 8543 | + source = &ev.value.iec958; |
| 8544 | + break; |
| 8545 | + |
| 8546 | + default: |
| 8547 | + return -EINVAL; |
| 8548 | + } |
| 8549 | + |
| 8550 | + memcpy(array, source, size * count); |
| 8551 | + |
| 8552 | + return 0; |
| 8553 | +} |
| 8554 | + |
| 8555 | +int mixer_ctl_set_value(struct mixer_ctl *ctl, unsigned int id, int value) |
| 8556 | +{ |
| 8557 | + struct snd_ctl_elem_value ev; |
| 8558 | + int ret; |
| 8559 | + |
| 8560 | + if (!ctl || (id >= ctl->info->count)) |
| 8561 | + return -EINVAL; |
| 8562 | + |
| 8563 | + memset(&ev, 0, sizeof(ev)); |
| 8564 | + ev.id.numid = ctl->info->id.numid; |
| 8565 | + ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_READ, &ev); |
| 8566 | + if (ret < 0) |
| 8567 | + return ret; |
| 8568 | + |
| 8569 | + switch (ctl->info->type) { |
| 8570 | + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: |
| 8571 | + ev.value.integer.value[id] = !!value; |
| 8572 | + break; |
| 8573 | + |
| 8574 | + case SNDRV_CTL_ELEM_TYPE_INTEGER: |
| 8575 | + ev.value.integer.value[id] = value; |
| 8576 | + break; |
| 8577 | + |
| 8578 | + case SNDRV_CTL_ELEM_TYPE_ENUMERATED: |
| 8579 | + ev.value.enumerated.item[id] = value; |
| 8580 | + break; |
| 8581 | + |
| 8582 | + case SNDRV_CTL_ELEM_TYPE_BYTES: |
| 8583 | + ev.value.bytes.data[id] = value; |
| 8584 | + break; |
| 8585 | + |
| 8586 | + default: |
| 8587 | + return -EINVAL; |
| 8588 | + } |
| 8589 | + |
| 8590 | + return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); |
| 8591 | +} |
| 8592 | + |
| 8593 | +int mixer_ctl_set_array(struct mixer_ctl *ctl, const void *array, size_t count) |
| 8594 | +{ |
| 8595 | + struct snd_ctl_elem_value ev; |
| 8596 | + size_t size; |
| 8597 | + void *dest; |
| 8598 | + |
| 8599 | + if (!ctl || (count > ctl->info->count) || !count || !array) |
| 8600 | + return -EINVAL; |
| 8601 | + |
| 8602 | + memset(&ev, 0, sizeof(ev)); |
| 8603 | + ev.id.numid = ctl->info->id.numid; |
| 8604 | + |
| 8605 | + switch (ctl->info->type) { |
| 8606 | + case SNDRV_CTL_ELEM_TYPE_BOOLEAN: |
| 8607 | + case SNDRV_CTL_ELEM_TYPE_INTEGER: |
| 8608 | + size = sizeof(ev.value.integer.value[0]); |
| 8609 | + dest = ev.value.integer.value; |
| 8610 | + break; |
| 8611 | + |
| 8612 | + case SNDRV_CTL_ELEM_TYPE_BYTES: |
| 8613 | + /* check if this is new bytes TLV */ |
| 8614 | + if (ctl->info->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) { |
| 8615 | + struct snd_ctl_tlv *tlv; |
| 8616 | + int ret = 0; |
| 8617 | + if (count > SIZE_MAX - sizeof(*tlv)) |
| 8618 | + return -EINVAL; |
| 8619 | + tlv = calloc(1, sizeof(*tlv) + count); |
| 8620 | + if (!tlv) |
| 8621 | + return -ENOMEM; |
| 8622 | + tlv->numid = ctl->info->id.numid; |
| 8623 | + tlv->length = count; |
| 8624 | + memcpy(tlv->tlv, array, count); |
| 8625 | + |
| 8626 | + ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_TLV_WRITE, tlv); |
| 8627 | + free(tlv); |
| 8628 | + |
| 8629 | + return ret; |
| 8630 | + } else { |
| 8631 | + size = sizeof(ev.value.bytes.data[0]); |
| 8632 | + dest = ev.value.bytes.data; |
| 8633 | + } |
| 8634 | + break; |
| 8635 | + |
| 8636 | + case SNDRV_CTL_ELEM_TYPE_IEC958: |
| 8637 | + size = sizeof(ev.value.iec958); |
| 8638 | + dest = &ev.value.iec958; |
| 8639 | + break; |
| 8640 | + |
| 8641 | + default: |
| 8642 | + return -EINVAL; |
| 8643 | + } |
| 8644 | + |
| 8645 | + memcpy(dest, array, size * count); |
| 8646 | + |
| 8647 | + return ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); |
| 8648 | +} |
| 8649 | + |
| 8650 | +int mixer_ctl_get_range_min(struct mixer_ctl *ctl) |
| 8651 | +{ |
| 8652 | + if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_INTEGER)) |
| 8653 | + return -EINVAL; |
| 8654 | + |
| 8655 | + return ctl->info->value.integer.min; |
| 8656 | +} |
| 8657 | + |
| 8658 | +int mixer_ctl_get_range_max(struct mixer_ctl *ctl) |
| 8659 | +{ |
| 8660 | + if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_INTEGER)) |
| 8661 | + return -EINVAL; |
| 8662 | + |
| 8663 | + return ctl->info->value.integer.max; |
| 8664 | +} |
| 8665 | + |
| 8666 | +unsigned int mixer_ctl_get_num_enums(struct mixer_ctl *ctl) |
| 8667 | +{ |
| 8668 | + if (!ctl) |
| 8669 | + return 0; |
| 8670 | + |
| 8671 | + return ctl->info->value.enumerated.items; |
| 8672 | +} |
| 8673 | + |
| 8674 | +const char *mixer_ctl_get_enum_string(struct mixer_ctl *ctl, |
| 8675 | + unsigned int enum_id) |
| 8676 | +{ |
| 8677 | + if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_ENUMERATED) || |
| 8678 | + (enum_id >= ctl->info->value.enumerated.items)) |
| 8679 | + return NULL; |
| 8680 | + |
| 8681 | + return (const char *)ctl->ename[enum_id]; |
| 8682 | +} |
| 8683 | + |
| 8684 | +int mixer_ctl_set_enum_by_string(struct mixer_ctl *ctl, const char *string) |
| 8685 | +{ |
| 8686 | + unsigned int i, num_enums; |
| 8687 | + struct snd_ctl_elem_value ev; |
| 8688 | + int ret; |
| 8689 | + |
| 8690 | + if (!ctl || (ctl->info->type != SNDRV_CTL_ELEM_TYPE_ENUMERATED)) |
| 8691 | + return -EINVAL; |
| 8692 | + |
| 8693 | + num_enums = ctl->info->value.enumerated.items; |
| 8694 | + for (i = 0; i < num_enums; i++) { |
| 8695 | + if (!strcmp(string, ctl->ename[i])) { |
| 8696 | + memset(&ev, 0, sizeof(ev)); |
| 8697 | + ev.value.enumerated.item[0] = i; |
| 8698 | + ev.id.numid = ctl->info->id.numid; |
| 8699 | + ret = ioctl(ctl->mixer->fd, SNDRV_CTL_IOCTL_ELEM_WRITE, &ev); |
| 8700 | + if (ret < 0) |
| 8701 | + return ret; |
| 8702 | + return 0; |
| 8703 | + } |
| 8704 | + } |
| 8705 | + |
| 8706 | + return -EINVAL; |
| 8707 | +} |
| 8708 | + |
| 8709 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/pcm.c b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/pcm.c |
| 8710 | new file mode 100755 |
| 8711 | index 0000000..78e1cea |
| 8712 | --- /dev/null |
| 8713 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/pcm.c |
| 8714 | @@ -0,0 +1,1310 @@ |
| 8715 | +/* pcm.c |
| 8716 | +** |
| 8717 | +** Copyright 2011, The Android Open Source Project |
| 8718 | +** |
| 8719 | +** Redistribution and use in source and binary forms, with or without |
| 8720 | +** modification, are permitted provided that the following conditions are met: |
| 8721 | +** * Redistributions of source code must retain the above copyright |
| 8722 | +** notice, this list of conditions and the following disclaimer. |
| 8723 | +** * Redistributions in binary form must reproduce the above copyright |
| 8724 | +** notice, this list of conditions and the following disclaimer in the |
| 8725 | +** documentation and/or other materials provided with the distribution. |
| 8726 | +** * Neither the name of The Android Open Source Project nor the names of |
| 8727 | +** its contributors may be used to endorse or promote products derived |
| 8728 | +** from this software without specific prior written permission. |
| 8729 | +** |
| 8730 | +** THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND |
| 8731 | +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 8732 | +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 8733 | +** ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE |
| 8734 | +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 8735 | +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 8736 | +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 8737 | +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 8738 | +** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 8739 | +** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 8740 | +** DAMAGE. |
| 8741 | +*/ |
| 8742 | + |
| 8743 | +#include <stdio.h> |
| 8744 | +#include <stdlib.h> |
| 8745 | +#include <fcntl.h> |
| 8746 | +#include <stdarg.h> |
| 8747 | +#include <string.h> |
| 8748 | +#include <errno.h> |
| 8749 | +#include <unistd.h> |
| 8750 | +#include <poll.h> |
| 8751 | + |
| 8752 | +#include <sys/ioctl.h> |
| 8753 | +#include <sys/mman.h> |
| 8754 | +#include <sys/time.h> |
| 8755 | +#include <limits.h> |
| 8756 | + |
| 8757 | +#include <linux/ioctl.h> |
| 8758 | +#define __force |
| 8759 | +#define __bitwise |
| 8760 | +#define __user |
| 8761 | +#include <sound/asound.h> |
| 8762 | + |
| 8763 | +#include <tinyalsa/asoundlib.h> |
| 8764 | + |
| 8765 | +#define PARAM_MAX SNDRV_PCM_HW_PARAM_LAST_INTERVAL |
| 8766 | + |
| 8767 | +/* Logs information into a string; follows snprintf() in that |
| 8768 | + * offset may be greater than size, and though no characters are copied |
| 8769 | + * into string, characters are still counted into offset. */ |
| 8770 | +#define STRLOG(string, offset, size, ...) \ |
| 8771 | + do { int temp, clipoffset = offset > size ? size : offset; \ |
| 8772 | + temp = snprintf(string + clipoffset, size - clipoffset, __VA_ARGS__); \ |
| 8773 | + if (temp > 0) offset += temp; } while (0) |
| 8774 | + |
| 8775 | +#ifndef ARRAY_SIZE |
| 8776 | +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
| 8777 | +#endif |
| 8778 | + |
| 8779 | +/* refer to SNDRV_PCM_ACCESS_##index in sound/asound.h. */ |
| 8780 | +static const char * const access_lookup[] = { |
| 8781 | + "MMAP_INTERLEAVED", |
| 8782 | + "MMAP_NONINTERLEAVED", |
| 8783 | + "MMAP_COMPLEX", |
| 8784 | + "RW_INTERLEAVED", |
| 8785 | + "RW_NONINTERLEAVED", |
| 8786 | +}; |
| 8787 | + |
| 8788 | +/* refer to SNDRV_PCM_FORMAT_##index in sound/asound.h. */ |
| 8789 | +static const char * const format_lookup[] = { |
| 8790 | + /*[0] =*/ "S8", |
| 8791 | + "U8", |
| 8792 | + "S16_LE", |
| 8793 | + "S16_BE", |
| 8794 | + "U16_LE", |
| 8795 | + "U16_BE", |
| 8796 | + "S24_LE", |
| 8797 | + "S24_BE", |
| 8798 | + "U24_LE", |
| 8799 | + "U24_BE", |
| 8800 | + "S32_LE", |
| 8801 | + "S32_BE", |
| 8802 | + "U32_LE", |
| 8803 | + "U32_BE", |
| 8804 | + "FLOAT_LE", |
| 8805 | + "FLOAT_BE", |
| 8806 | + "FLOAT64_LE", |
| 8807 | + "FLOAT64_BE", |
| 8808 | + "IEC958_SUBFRAME_LE", |
| 8809 | + "IEC958_SUBFRAME_BE", |
| 8810 | + "MU_LAW", |
| 8811 | + "A_LAW", |
| 8812 | + "IMA_ADPCM", |
| 8813 | + "MPEG", |
| 8814 | + /*[24] =*/ "GSM", |
| 8815 | + /* gap */ |
| 8816 | + [31] = "SPECIAL", |
| 8817 | + "S24_3LE", |
| 8818 | + "S24_3BE", |
| 8819 | + "U24_3LE", |
| 8820 | + "U24_3BE", |
| 8821 | + "S20_3LE", |
| 8822 | + "S20_3BE", |
| 8823 | + "U20_3LE", |
| 8824 | + "U20_3BE", |
| 8825 | + "S18_3LE", |
| 8826 | + "S18_3BE", |
| 8827 | + "U18_3LE", |
| 8828 | + /*[43] =*/ "U18_3BE", |
| 8829 | +#if 0 |
| 8830 | + /* recent additions, may not be present on local asound.h */ |
| 8831 | + "G723_24", |
| 8832 | + "G723_24_1B", |
| 8833 | + "G723_40", |
| 8834 | + "G723_40_1B", |
| 8835 | + "DSD_U8", |
| 8836 | + "DSD_U16_LE", |
| 8837 | +#endif |
| 8838 | +}; |
| 8839 | + |
| 8840 | +/* refer to SNDRV_PCM_SUBFORMAT_##index in sound/asound.h. */ |
| 8841 | +static const char * const subformat_lookup[] = { |
| 8842 | + "STD", |
| 8843 | +}; |
| 8844 | + |
| 8845 | +static inline int param_is_mask(int p) |
| 8846 | +{ |
| 8847 | + return (p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) && |
| 8848 | + (p <= SNDRV_PCM_HW_PARAM_LAST_MASK); |
| 8849 | +} |
| 8850 | + |
| 8851 | +static inline int param_is_interval(int p) |
| 8852 | +{ |
| 8853 | + return (p >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL) && |
| 8854 | + (p <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL); |
| 8855 | +} |
| 8856 | + |
| 8857 | +static inline struct snd_interval *param_to_interval(struct snd_pcm_hw_params *p, int n) |
| 8858 | +{ |
| 8859 | + return &(p->intervals[n - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL]); |
| 8860 | +} |
| 8861 | + |
| 8862 | +static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, int n) |
| 8863 | +{ |
| 8864 | + return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]); |
| 8865 | +} |
| 8866 | + |
| 8867 | +static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned int bit) |
| 8868 | +{ |
| 8869 | + if (bit >= SNDRV_MASK_MAX) |
| 8870 | + return; |
| 8871 | + if (param_is_mask(n)) { |
| 8872 | + struct snd_mask *m = param_to_mask(p, n); |
| 8873 | + m->bits[0] = 0; |
| 8874 | + m->bits[1] = 0; |
| 8875 | + m->bits[bit >> 5] |= (1 << (bit & 31)); |
| 8876 | + } |
| 8877 | +} |
| 8878 | + |
| 8879 | +static void param_set_min(struct snd_pcm_hw_params *p, int n, unsigned int val) |
| 8880 | +{ |
| 8881 | + if (param_is_interval(n)) { |
| 8882 | + struct snd_interval *i = param_to_interval(p, n); |
| 8883 | + i->min = val; |
| 8884 | + } |
| 8885 | +} |
| 8886 | + |
| 8887 | +static unsigned int param_get_min(struct snd_pcm_hw_params *p, int n) |
| 8888 | +{ |
| 8889 | + if (param_is_interval(n)) { |
| 8890 | + struct snd_interval *i = param_to_interval(p, n); |
| 8891 | + return i->min; |
| 8892 | + } |
| 8893 | + return 0; |
| 8894 | +} |
| 8895 | + |
| 8896 | +static void param_set_max(struct snd_pcm_hw_params *p, int n, unsigned int val) |
| 8897 | +{ |
| 8898 | + if (param_is_interval(n)) { |
| 8899 | + struct snd_interval *i = param_to_interval(p, n); |
| 8900 | + i->max = val; |
| 8901 | + } |
| 8902 | +} |
| 8903 | + |
| 8904 | +static unsigned int param_get_max(struct snd_pcm_hw_params *p, int n) |
| 8905 | +{ |
| 8906 | + if (param_is_interval(n)) { |
| 8907 | + struct snd_interval *i = param_to_interval(p, n); |
| 8908 | + return i->max; |
| 8909 | + } |
| 8910 | + return 0; |
| 8911 | +} |
| 8912 | + |
| 8913 | +static void param_set_int(struct snd_pcm_hw_params *p, int n, unsigned int val) |
| 8914 | +{ |
| 8915 | + if (param_is_interval(n)) { |
| 8916 | + struct snd_interval *i = param_to_interval(p, n); |
| 8917 | + i->min = val; |
| 8918 | + i->max = val; |
| 8919 | + i->integer = 1; |
| 8920 | + } |
| 8921 | +} |
| 8922 | + |
| 8923 | +static unsigned int param_get_int(struct snd_pcm_hw_params *p, int n) |
| 8924 | +{ |
| 8925 | + if (param_is_interval(n)) { |
| 8926 | + struct snd_interval *i = param_to_interval(p, n); |
| 8927 | + if (i->integer) |
| 8928 | + return i->max; |
| 8929 | + } |
| 8930 | + return 0; |
| 8931 | +} |
| 8932 | + |
| 8933 | +static void param_init(struct snd_pcm_hw_params *p) |
| 8934 | +{ |
| 8935 | + int n; |
| 8936 | + |
| 8937 | + memset(p, 0, sizeof(*p)); |
| 8938 | + for (n = SNDRV_PCM_HW_PARAM_FIRST_MASK; |
| 8939 | + n <= SNDRV_PCM_HW_PARAM_LAST_MASK; n++) { |
| 8940 | + struct snd_mask *m = param_to_mask(p, n); |
| 8941 | + m->bits[0] = ~0; |
| 8942 | + m->bits[1] = ~0; |
| 8943 | + } |
| 8944 | + for (n = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; |
| 8945 | + n <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; n++) { |
| 8946 | + struct snd_interval *i = param_to_interval(p, n); |
| 8947 | + i->min = 0; |
| 8948 | + i->max = ~0; |
| 8949 | + } |
| 8950 | + p->rmask = ~0U; |
| 8951 | + p->cmask = 0; |
| 8952 | + p->info = ~0U; |
| 8953 | +} |
| 8954 | + |
| 8955 | +#define PCM_ERROR_MAX 128 |
| 8956 | + |
| 8957 | +struct pcm { |
| 8958 | + int fd; |
| 8959 | + unsigned int flags; |
| 8960 | + int running:1; |
| 8961 | + int prepared:1; |
| 8962 | + int underruns; |
| 8963 | + unsigned int buffer_size; |
| 8964 | + unsigned int boundary; |
| 8965 | + char error[PCM_ERROR_MAX]; |
| 8966 | + struct pcm_config config; |
| 8967 | + struct snd_pcm_mmap_status *mmap_status; |
| 8968 | + struct snd_pcm_mmap_control *mmap_control; |
| 8969 | + struct snd_pcm_sync_ptr *sync_ptr; |
| 8970 | + void *mmap_buffer; |
| 8971 | + unsigned int noirq_frames_per_msec; |
| 8972 | + int wait_for_avail_min; |
| 8973 | +}; |
| 8974 | + |
| 8975 | +unsigned int pcm_get_buffer_size(struct pcm *pcm) |
| 8976 | +{ |
| 8977 | + return pcm->buffer_size; |
| 8978 | +} |
| 8979 | + |
| 8980 | +const char* pcm_get_error(struct pcm *pcm) |
| 8981 | +{ |
| 8982 | + return pcm->error; |
| 8983 | +} |
| 8984 | + |
| 8985 | +static int oops(struct pcm *pcm, int e, const char *fmt, ...) |
| 8986 | +{ |
| 8987 | + va_list ap; |
| 8988 | + int sz; |
| 8989 | + |
| 8990 | + va_start(ap, fmt); |
| 8991 | + vsnprintf(pcm->error, PCM_ERROR_MAX, fmt, ap); |
| 8992 | + va_end(ap); |
| 8993 | + sz = strlen(pcm->error); |
| 8994 | + |
| 8995 | + if (errno) |
| 8996 | + snprintf(pcm->error + sz, PCM_ERROR_MAX - sz, |
| 8997 | + ": %s", strerror(e)); |
| 8998 | + return -1; |
| 8999 | +} |
| 9000 | + |
| 9001 | +static unsigned int pcm_format_to_alsa(enum pcm_format format) |
| 9002 | +{ |
| 9003 | + switch (format) { |
| 9004 | + case PCM_FORMAT_S32_LE: |
| 9005 | + return SNDRV_PCM_FORMAT_S32_LE; |
| 9006 | + case PCM_FORMAT_S8: |
| 9007 | + return SNDRV_PCM_FORMAT_S8; |
| 9008 | + case PCM_FORMAT_S24_3LE: |
| 9009 | + return SNDRV_PCM_FORMAT_S24_3LE; |
| 9010 | + case PCM_FORMAT_S24_LE: |
| 9011 | + return SNDRV_PCM_FORMAT_S24_LE; |
| 9012 | + default: |
| 9013 | + case PCM_FORMAT_S16_LE: |
| 9014 | + return SNDRV_PCM_FORMAT_S16_LE; |
| 9015 | + }; |
| 9016 | +} |
| 9017 | + |
| 9018 | +unsigned int pcm_format_to_bits(enum pcm_format format) |
| 9019 | +{ |
| 9020 | + switch (format) { |
| 9021 | + case PCM_FORMAT_S32_LE: |
| 9022 | + case PCM_FORMAT_S24_LE: |
| 9023 | + return 32; |
| 9024 | + case PCM_FORMAT_S24_3LE: |
| 9025 | + return 24; |
| 9026 | + default: |
| 9027 | + case PCM_FORMAT_S16_LE: |
| 9028 | + return 16; |
| 9029 | + }; |
| 9030 | +} |
| 9031 | + |
| 9032 | +unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int bytes) |
| 9033 | +{ |
| 9034 | + return bytes / (pcm->config.channels * |
| 9035 | + (pcm_format_to_bits(pcm->config.format) >> 3)); |
| 9036 | +} |
| 9037 | + |
| 9038 | +unsigned int pcm_frames_to_bytes(struct pcm *pcm, unsigned int frames) |
| 9039 | +{ |
| 9040 | + return frames * pcm->config.channels * |
| 9041 | + (pcm_format_to_bits(pcm->config.format) >> 3); |
| 9042 | +} |
| 9043 | + |
| 9044 | +static int pcm_sync_ptr(struct pcm *pcm, int flags) { |
| 9045 | + if (pcm->sync_ptr) { |
| 9046 | + pcm->sync_ptr->flags = flags; |
| 9047 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SYNC_PTR, pcm->sync_ptr) < 0) |
| 9048 | + return -1; |
| 9049 | + } |
| 9050 | + return 0; |
| 9051 | +} |
| 9052 | + |
| 9053 | +static int pcm_hw_mmap_status(struct pcm *pcm) { |
| 9054 | + |
| 9055 | + if (pcm->sync_ptr) |
| 9056 | + return 0; |
| 9057 | + |
| 9058 | + int page_size = sysconf(_SC_PAGE_SIZE); |
| 9059 | + pcm->mmap_status = mmap(NULL, page_size, PROT_READ, MAP_FILE | MAP_SHARED, |
| 9060 | + pcm->fd, SNDRV_PCM_MMAP_OFFSET_STATUS); |
| 9061 | + if (pcm->mmap_status == MAP_FAILED) |
| 9062 | + pcm->mmap_status = NULL; |
| 9063 | + if (!pcm->mmap_status) |
| 9064 | + goto mmap_error; |
| 9065 | + |
| 9066 | + pcm->mmap_control = mmap(NULL, page_size, PROT_READ | PROT_WRITE, |
| 9067 | + MAP_FILE | MAP_SHARED, pcm->fd, SNDRV_PCM_MMAP_OFFSET_CONTROL); |
| 9068 | + if (pcm->mmap_control == MAP_FAILED) |
| 9069 | + pcm->mmap_control = NULL; |
| 9070 | + if (!pcm->mmap_control) { |
| 9071 | + munmap(pcm->mmap_status, page_size); |
| 9072 | + pcm->mmap_status = NULL; |
| 9073 | + goto mmap_error; |
| 9074 | + } |
| 9075 | + if (pcm->flags & PCM_MMAP) |
| 9076 | + pcm->mmap_control->avail_min = pcm->config.avail_min; |
| 9077 | + else |
| 9078 | + pcm->mmap_control->avail_min = 1; |
| 9079 | + |
| 9080 | + return 0; |
| 9081 | + |
| 9082 | +mmap_error: |
| 9083 | + |
| 9084 | + pcm->sync_ptr = calloc(1, sizeof(*pcm->sync_ptr)); |
| 9085 | + if (!pcm->sync_ptr) |
| 9086 | + return -ENOMEM; |
| 9087 | + pcm->mmap_status = &pcm->sync_ptr->s.status; |
| 9088 | + pcm->mmap_control = &pcm->sync_ptr->c.control; |
| 9089 | + if (pcm->flags & PCM_MMAP) |
| 9090 | + pcm->mmap_control->avail_min = pcm->config.avail_min; |
| 9091 | + else |
| 9092 | + pcm->mmap_control->avail_min = 1; |
| 9093 | + |
| 9094 | + pcm_sync_ptr(pcm, 0); |
| 9095 | + |
| 9096 | + return 0; |
| 9097 | +} |
| 9098 | + |
| 9099 | +static void pcm_hw_munmap_status(struct pcm *pcm) { |
| 9100 | + if (pcm->sync_ptr) { |
| 9101 | + free(pcm->sync_ptr); |
| 9102 | + pcm->sync_ptr = NULL; |
| 9103 | + } else { |
| 9104 | + int page_size = sysconf(_SC_PAGE_SIZE); |
| 9105 | + if (pcm->mmap_status) |
| 9106 | + munmap(pcm->mmap_status, page_size); |
| 9107 | + if (pcm->mmap_control) |
| 9108 | + munmap(pcm->mmap_control, page_size); |
| 9109 | + } |
| 9110 | + pcm->mmap_status = NULL; |
| 9111 | + pcm->mmap_control = NULL; |
| 9112 | +} |
| 9113 | + |
| 9114 | +static int pcm_areas_copy(struct pcm *pcm, unsigned int pcm_offset, |
| 9115 | + char *buf, unsigned int src_offset, |
| 9116 | + unsigned int frames) |
| 9117 | +{ |
| 9118 | + int size_bytes = pcm_frames_to_bytes(pcm, frames); |
| 9119 | + int pcm_offset_bytes = pcm_frames_to_bytes(pcm, pcm_offset); |
| 9120 | + int src_offset_bytes = pcm_frames_to_bytes(pcm, src_offset); |
| 9121 | + |
| 9122 | + /* interleaved only atm */ |
| 9123 | + if (pcm->flags & PCM_IN) |
| 9124 | + memcpy(buf + src_offset_bytes, |
| 9125 | + (char*)pcm->mmap_buffer + pcm_offset_bytes, |
| 9126 | + size_bytes); |
| 9127 | + else |
| 9128 | + memcpy((char*)pcm->mmap_buffer + pcm_offset_bytes, |
| 9129 | + buf + src_offset_bytes, |
| 9130 | + size_bytes); |
| 9131 | + return 0; |
| 9132 | +} |
| 9133 | + |
| 9134 | +static int pcm_mmap_transfer_areas(struct pcm *pcm, char *buf, |
| 9135 | + unsigned int offset, unsigned int size) |
| 9136 | +{ |
| 9137 | + void *pcm_areas; |
| 9138 | + int commit; |
| 9139 | + unsigned int pcm_offset, frames, count = 0; |
| 9140 | + |
| 9141 | + while (size > 0) { |
| 9142 | + frames = size; |
| 9143 | + pcm_mmap_begin(pcm, &pcm_areas, &pcm_offset, &frames); |
| 9144 | + pcm_areas_copy(pcm, pcm_offset, buf, offset, frames); |
| 9145 | + commit = pcm_mmap_commit(pcm, pcm_offset, frames); |
| 9146 | + if (commit < 0) { |
| 9147 | + oops(pcm, commit, "failed to commit %d frames\n", frames); |
| 9148 | + return commit; |
| 9149 | + } |
| 9150 | + |
| 9151 | + offset += commit; |
| 9152 | + count += commit; |
| 9153 | + size -= commit; |
| 9154 | + } |
| 9155 | + return count; |
| 9156 | +} |
| 9157 | + |
| 9158 | +int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, |
| 9159 | + struct timespec *tstamp) |
| 9160 | +{ |
| 9161 | + int frames; |
| 9162 | + int rc; |
| 9163 | + snd_pcm_uframes_t hw_ptr; |
| 9164 | + |
| 9165 | + if (!pcm_is_ready(pcm)) |
| 9166 | + return -1; |
| 9167 | + |
| 9168 | + rc = pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_APPL|SNDRV_PCM_SYNC_PTR_HWSYNC); |
| 9169 | + if (rc < 0) |
| 9170 | + return -1; |
| 9171 | + |
| 9172 | + if ((pcm->mmap_status->state != PCM_STATE_RUNNING) && |
| 9173 | + (pcm->mmap_status->state != PCM_STATE_DRAINING)) |
| 9174 | + return -1; |
| 9175 | + |
| 9176 | + *tstamp = pcm->mmap_status->tstamp; |
| 9177 | + if (tstamp->tv_sec == 0 && tstamp->tv_nsec == 0) |
| 9178 | + return -1; |
| 9179 | + |
| 9180 | + hw_ptr = pcm->mmap_status->hw_ptr; |
| 9181 | + if (pcm->flags & PCM_IN) |
| 9182 | + frames = hw_ptr - pcm->mmap_control->appl_ptr; |
| 9183 | + else |
| 9184 | + frames = hw_ptr + pcm->buffer_size - pcm->mmap_control->appl_ptr; |
| 9185 | + |
| 9186 | + if (frames < 0) |
| 9187 | + frames += pcm->boundary; |
| 9188 | + else if (frames > (int)pcm->boundary) |
| 9189 | + frames -= pcm->boundary; |
| 9190 | + |
| 9191 | + *avail = (unsigned int)frames; |
| 9192 | + |
| 9193 | + return 0; |
| 9194 | +} |
| 9195 | + |
| 9196 | +int pcm_write(struct pcm *pcm, const void *data, unsigned int count) |
| 9197 | +{ |
| 9198 | + struct snd_xferi x; |
| 9199 | + |
| 9200 | + if (pcm->flags & PCM_IN) |
| 9201 | + return -EINVAL; |
| 9202 | + |
| 9203 | + x.buf = (void*)data; |
| 9204 | + x.frames = count / (pcm->config.channels * |
| 9205 | + pcm_format_to_bits(pcm->config.format) / 8); |
| 9206 | + |
| 9207 | + for (;;) { |
| 9208 | + if (!pcm->running) { |
| 9209 | + int prepare_error = pcm_prepare(pcm); |
| 9210 | + if (prepare_error) |
| 9211 | + return prepare_error; |
| 9212 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) |
| 9213 | + return oops(pcm, errno, "cannot write initial data"); |
| 9214 | + pcm->running = 1; |
| 9215 | + return 0; |
| 9216 | + } |
| 9217 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_WRITEI_FRAMES, &x)) { |
| 9218 | + pcm->prepared = 0; |
| 9219 | + pcm->running = 0; |
| 9220 | + if (errno == EPIPE) { |
| 9221 | + /* we failed to make our window -- try to restart if we are |
| 9222 | + * allowed to do so. Otherwise, simply allow the EPIPE error to |
| 9223 | + * propagate up to the app level */ |
| 9224 | + pcm->underruns++; |
| 9225 | + if (pcm->flags & PCM_NORESTART) |
| 9226 | + return -EPIPE; |
| 9227 | + continue; |
| 9228 | + } |
| 9229 | + return oops(pcm, errno, "cannot write stream data"); |
| 9230 | + } |
| 9231 | + return 0; |
| 9232 | + } |
| 9233 | +} |
| 9234 | + |
| 9235 | +int pcm_read(struct pcm *pcm, void *data, unsigned int count) |
| 9236 | +{ |
| 9237 | + struct snd_xferi x; |
| 9238 | + |
| 9239 | + if (!(pcm->flags & PCM_IN)) |
| 9240 | + return -EINVAL; |
| 9241 | + |
| 9242 | + x.buf = data; |
| 9243 | + x.frames = count / (pcm->config.channels * |
| 9244 | + pcm_format_to_bits(pcm->config.format) / 8); |
| 9245 | + |
| 9246 | + for (;;) { |
| 9247 | + if (!pcm->running) { |
| 9248 | + if (pcm_start(pcm) < 0) { |
| 9249 | + fprintf(stderr, "start error"); |
| 9250 | + return -errno; |
| 9251 | + } |
| 9252 | + } |
| 9253 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_READI_FRAMES, &x)) { |
| 9254 | + pcm->prepared = 0; |
| 9255 | + pcm->running = 0; |
| 9256 | + if (errno == EPIPE) { |
| 9257 | + /* we failed to make our window -- try to restart */ |
| 9258 | + pcm->underruns++; |
| 9259 | + continue; |
| 9260 | + } |
| 9261 | + return oops(pcm, errno, "cannot read stream data"); |
| 9262 | + } |
| 9263 | + return 0; |
| 9264 | + } |
| 9265 | +} |
| 9266 | + |
| 9267 | +static struct pcm bad_pcm = { |
| 9268 | + .fd = -1, |
| 9269 | +}; |
| 9270 | + |
| 9271 | +struct pcm_params *pcm_params_get(unsigned int card, unsigned int device, |
| 9272 | + unsigned int flags) |
| 9273 | +{ |
| 9274 | + struct snd_pcm_hw_params *params; |
| 9275 | + char fn[256]; |
| 9276 | + int fd; |
| 9277 | + |
| 9278 | + snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device, |
| 9279 | + flags & PCM_IN ? 'c' : 'p'); |
| 9280 | + |
| 9281 | + fd = open(fn, O_RDWR); |
| 9282 | + if (fd < 0) { |
| 9283 | + fprintf(stderr, "cannot open device '%s'\n", fn); |
| 9284 | + goto err_open; |
| 9285 | + } |
| 9286 | + |
| 9287 | + params = calloc(1, sizeof(struct snd_pcm_hw_params)); |
| 9288 | + if (!params) |
| 9289 | + goto err_calloc; |
| 9290 | + |
| 9291 | + param_init(params); |
| 9292 | + if (ioctl(fd, SNDRV_PCM_IOCTL_HW_REFINE, params)) { |
| 9293 | + fprintf(stderr, "SNDRV_PCM_IOCTL_HW_REFINE error (%d)\n", errno); |
| 9294 | + goto err_hw_refine; |
| 9295 | + } |
| 9296 | + |
| 9297 | + close(fd); |
| 9298 | + |
| 9299 | + return (struct pcm_params *)params; |
| 9300 | + |
| 9301 | +err_hw_refine: |
| 9302 | + free(params); |
| 9303 | +err_calloc: |
| 9304 | + close(fd); |
| 9305 | +err_open: |
| 9306 | + return NULL; |
| 9307 | +} |
| 9308 | + |
| 9309 | +void pcm_params_free(struct pcm_params *pcm_params) |
| 9310 | +{ |
| 9311 | + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; |
| 9312 | + |
| 9313 | + if (params) |
| 9314 | + free(params); |
| 9315 | +} |
| 9316 | + |
| 9317 | +static int pcm_param_to_alsa(enum pcm_param param) |
| 9318 | +{ |
| 9319 | + switch (param) { |
| 9320 | + case PCM_PARAM_ACCESS: |
| 9321 | + return SNDRV_PCM_HW_PARAM_ACCESS; |
| 9322 | + case PCM_PARAM_FORMAT: |
| 9323 | + return SNDRV_PCM_HW_PARAM_FORMAT; |
| 9324 | + case PCM_PARAM_SUBFORMAT: |
| 9325 | + return SNDRV_PCM_HW_PARAM_SUBFORMAT; |
| 9326 | + case PCM_PARAM_SAMPLE_BITS: |
| 9327 | + return SNDRV_PCM_HW_PARAM_SAMPLE_BITS; |
| 9328 | + break; |
| 9329 | + case PCM_PARAM_FRAME_BITS: |
| 9330 | + return SNDRV_PCM_HW_PARAM_FRAME_BITS; |
| 9331 | + break; |
| 9332 | + case PCM_PARAM_CHANNELS: |
| 9333 | + return SNDRV_PCM_HW_PARAM_CHANNELS; |
| 9334 | + break; |
| 9335 | + case PCM_PARAM_RATE: |
| 9336 | + return SNDRV_PCM_HW_PARAM_RATE; |
| 9337 | + break; |
| 9338 | + case PCM_PARAM_PERIOD_TIME: |
| 9339 | + return SNDRV_PCM_HW_PARAM_PERIOD_TIME; |
| 9340 | + break; |
| 9341 | + case PCM_PARAM_PERIOD_SIZE: |
| 9342 | + return SNDRV_PCM_HW_PARAM_PERIOD_SIZE; |
| 9343 | + break; |
| 9344 | + case PCM_PARAM_PERIOD_BYTES: |
| 9345 | + return SNDRV_PCM_HW_PARAM_PERIOD_BYTES; |
| 9346 | + break; |
| 9347 | + case PCM_PARAM_PERIODS: |
| 9348 | + return SNDRV_PCM_HW_PARAM_PERIODS; |
| 9349 | + break; |
| 9350 | + case PCM_PARAM_BUFFER_TIME: |
| 9351 | + return SNDRV_PCM_HW_PARAM_BUFFER_TIME; |
| 9352 | + break; |
| 9353 | + case PCM_PARAM_BUFFER_SIZE: |
| 9354 | + return SNDRV_PCM_HW_PARAM_BUFFER_SIZE; |
| 9355 | + break; |
| 9356 | + case PCM_PARAM_BUFFER_BYTES: |
| 9357 | + return SNDRV_PCM_HW_PARAM_BUFFER_BYTES; |
| 9358 | + break; |
| 9359 | + case PCM_PARAM_TICK_TIME: |
| 9360 | + return SNDRV_PCM_HW_PARAM_TICK_TIME; |
| 9361 | + break; |
| 9362 | + |
| 9363 | + default: |
| 9364 | + return -1; |
| 9365 | + } |
| 9366 | +} |
| 9367 | + |
| 9368 | +struct pcm_mask *pcm_params_get_mask(struct pcm_params *pcm_params, |
| 9369 | + enum pcm_param param) |
| 9370 | +{ |
| 9371 | + int p; |
| 9372 | + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; |
| 9373 | + if (params == NULL) { |
| 9374 | + return NULL; |
| 9375 | + } |
| 9376 | + |
| 9377 | + p = pcm_param_to_alsa(param); |
| 9378 | + if (p < 0 || !param_is_mask(p)) { |
| 9379 | + return NULL; |
| 9380 | + } |
| 9381 | + |
| 9382 | + return (struct pcm_mask *)param_to_mask(params, p); |
| 9383 | +} |
| 9384 | + |
| 9385 | +unsigned int pcm_params_get_min(struct pcm_params *pcm_params, |
| 9386 | + enum pcm_param param) |
| 9387 | +{ |
| 9388 | + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; |
| 9389 | + int p; |
| 9390 | + |
| 9391 | + if (!params) |
| 9392 | + return 0; |
| 9393 | + |
| 9394 | + p = pcm_param_to_alsa(param); |
| 9395 | + if (p < 0) |
| 9396 | + return 0; |
| 9397 | + |
| 9398 | + return param_get_min(params, p); |
| 9399 | +} |
| 9400 | + |
| 9401 | +void pcm_params_set_min(struct pcm_params *pcm_params, |
| 9402 | + enum pcm_param param, unsigned int val) |
| 9403 | +{ |
| 9404 | + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; |
| 9405 | + int p; |
| 9406 | + |
| 9407 | + if (!params) |
| 9408 | + return; |
| 9409 | + |
| 9410 | + p = pcm_param_to_alsa(param); |
| 9411 | + if (p < 0) |
| 9412 | + return; |
| 9413 | + |
| 9414 | + param_set_min(params, p, val); |
| 9415 | +} |
| 9416 | + |
| 9417 | +unsigned int pcm_params_get_max(struct pcm_params *pcm_params, |
| 9418 | + enum pcm_param param) |
| 9419 | +{ |
| 9420 | + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; |
| 9421 | + int p; |
| 9422 | + |
| 9423 | + if (!params) |
| 9424 | + return 0; |
| 9425 | + |
| 9426 | + p = pcm_param_to_alsa(param); |
| 9427 | + if (p < 0) |
| 9428 | + return 0; |
| 9429 | + |
| 9430 | + return param_get_max(params, p); |
| 9431 | +} |
| 9432 | + |
| 9433 | +void pcm_params_set_max(struct pcm_params *pcm_params, |
| 9434 | + enum pcm_param param, unsigned int val) |
| 9435 | +{ |
| 9436 | + struct snd_pcm_hw_params *params = (struct snd_pcm_hw_params *)pcm_params; |
| 9437 | + int p; |
| 9438 | + |
| 9439 | + if (!params) |
| 9440 | + return; |
| 9441 | + |
| 9442 | + p = pcm_param_to_alsa(param); |
| 9443 | + if (p < 0) |
| 9444 | + return; |
| 9445 | + |
| 9446 | + param_set_max(params, p, val); |
| 9447 | +} |
| 9448 | + |
| 9449 | +static int pcm_mask_test(struct pcm_mask *m, unsigned int index) |
| 9450 | +{ |
| 9451 | + const unsigned int bitshift = 5; /* for 32 bit integer */ |
| 9452 | + const unsigned int bitmask = (1 << bitshift) - 1; |
| 9453 | + unsigned int element; |
| 9454 | + |
| 9455 | + element = index >> bitshift; |
| 9456 | + if (element >= ARRAY_SIZE(m->bits)) |
| 9457 | + return 0; /* for safety, but should never occur */ |
| 9458 | + return (m->bits[element] >> (index & bitmask)) & 1; |
| 9459 | +} |
| 9460 | + |
| 9461 | +static int pcm_mask_to_string(struct pcm_mask *m, char *string, unsigned int size, |
| 9462 | + char *mask_name, |
| 9463 | + const char * const *bit_array_name, size_t bit_array_size) |
| 9464 | +{ |
| 9465 | + unsigned int i; |
| 9466 | + unsigned int offset = 0; |
| 9467 | + |
| 9468 | + if (m == NULL) |
| 9469 | + return 0; |
| 9470 | + if (bit_array_size < 32) { |
| 9471 | + STRLOG(string, offset, size, "%12s:\t%#08x\n", mask_name, m->bits[0]); |
| 9472 | + } else { /* spans two or more bitfields, print with an array index */ |
| 9473 | + for (i = 0; i < (bit_array_size + 31) >> 5; ++i) { |
| 9474 | + STRLOG(string, offset, size, "%9s[%d]:\t%#08x\n", |
| 9475 | + mask_name, i, m->bits[i]); |
| 9476 | + } |
| 9477 | + } |
| 9478 | + for (i = 0; i < bit_array_size; ++i) { |
| 9479 | + if (pcm_mask_test(m, i)) { |
| 9480 | + STRLOG(string, offset, size, "%12s \t%s\n", "", bit_array_name[i]); |
| 9481 | + } |
| 9482 | + } |
| 9483 | + return offset; |
| 9484 | +} |
| 9485 | + |
| 9486 | +int pcm_params_to_string(struct pcm_params *params, char *string, unsigned int size) |
| 9487 | +{ |
| 9488 | + struct pcm_mask *m; |
| 9489 | + unsigned int min, max; |
| 9490 | + unsigned int clipoffset, offset; |
| 9491 | + |
| 9492 | + m = pcm_params_get_mask(params, PCM_PARAM_ACCESS); |
| 9493 | + offset = pcm_mask_to_string(m, string, size, |
| 9494 | + "Access", access_lookup, ARRAY_SIZE(access_lookup)); |
| 9495 | + m = pcm_params_get_mask(params, PCM_PARAM_FORMAT); |
| 9496 | + clipoffset = offset > size ? size : offset; |
| 9497 | + offset += pcm_mask_to_string(m, string + clipoffset, size - clipoffset, |
| 9498 | + "Format", format_lookup, ARRAY_SIZE(format_lookup)); |
| 9499 | + m = pcm_params_get_mask(params, PCM_PARAM_SUBFORMAT); |
| 9500 | + clipoffset = offset > size ? size : offset; |
| 9501 | + offset += pcm_mask_to_string(m, string + clipoffset, size - clipoffset, |
| 9502 | + "Subformat", subformat_lookup, ARRAY_SIZE(subformat_lookup)); |
| 9503 | + min = pcm_params_get_min(params, PCM_PARAM_RATE); |
| 9504 | + max = pcm_params_get_max(params, PCM_PARAM_RATE); |
| 9505 | + STRLOG(string, offset, size, " Rate:\tmin=%uHz\tmax=%uHz\n", min, max); |
| 9506 | + min = pcm_params_get_min(params, PCM_PARAM_CHANNELS); |
| 9507 | + max = pcm_params_get_max(params, PCM_PARAM_CHANNELS); |
| 9508 | + STRLOG(string, offset, size, " Channels:\tmin=%u\t\tmax=%u\n", min, max); |
| 9509 | + min = pcm_params_get_min(params, PCM_PARAM_SAMPLE_BITS); |
| 9510 | + max = pcm_params_get_max(params, PCM_PARAM_SAMPLE_BITS); |
| 9511 | + STRLOG(string, offset, size, " Sample bits:\tmin=%u\t\tmax=%u\n", min, max); |
| 9512 | + min = pcm_params_get_min(params, PCM_PARAM_PERIOD_SIZE); |
| 9513 | + max = pcm_params_get_max(params, PCM_PARAM_PERIOD_SIZE); |
| 9514 | + STRLOG(string, offset, size, " Period size:\tmin=%u\t\tmax=%u\n", min, max); |
| 9515 | + min = pcm_params_get_min(params, PCM_PARAM_PERIODS); |
| 9516 | + max = pcm_params_get_max(params, PCM_PARAM_PERIODS); |
| 9517 | + STRLOG(string, offset, size, "Period count:\tmin=%u\t\tmax=%u\n", min, max); |
| 9518 | + return offset; |
| 9519 | +} |
| 9520 | + |
| 9521 | +int pcm_params_format_test(struct pcm_params *params, enum pcm_format format) |
| 9522 | +{ |
| 9523 | + unsigned int alsa_format = pcm_format_to_alsa(format); |
| 9524 | + |
| 9525 | + if (alsa_format == SNDRV_PCM_FORMAT_S16_LE && format != PCM_FORMAT_S16_LE) |
| 9526 | + return 0; /* caution: format not recognized is equivalent to S16_LE */ |
| 9527 | + return pcm_mask_test(pcm_params_get_mask(params, PCM_PARAM_FORMAT), alsa_format); |
| 9528 | +} |
| 9529 | + |
| 9530 | +int pcm_close(struct pcm *pcm) |
| 9531 | +{ |
| 9532 | + if (pcm == &bad_pcm) |
| 9533 | + return 0; |
| 9534 | + |
| 9535 | + pcm_hw_munmap_status(pcm); |
| 9536 | + |
| 9537 | + if (pcm->flags & PCM_MMAP) { |
| 9538 | + pcm_stop(pcm); |
| 9539 | + munmap(pcm->mmap_buffer, pcm_frames_to_bytes(pcm, pcm->buffer_size)); |
| 9540 | + } |
| 9541 | + |
| 9542 | + if (pcm->fd >= 0) |
| 9543 | + close(pcm->fd); |
| 9544 | + pcm->prepared = 0; |
| 9545 | + pcm->running = 0; |
| 9546 | + pcm->buffer_size = 0; |
| 9547 | + pcm->fd = -1; |
| 9548 | + free(pcm); |
| 9549 | + return 0; |
| 9550 | +} |
| 9551 | + |
| 9552 | +struct pcm *pcm_open(unsigned int card, unsigned int device, |
| 9553 | + unsigned int flags, struct pcm_config *config) |
| 9554 | +{ |
| 9555 | + struct pcm *pcm; |
| 9556 | + struct snd_pcm_info info; |
| 9557 | + struct snd_pcm_hw_params params; |
| 9558 | + struct snd_pcm_sw_params sparams; |
| 9559 | + char fn[256]; |
| 9560 | + int rc; |
| 9561 | + |
| 9562 | + pcm = calloc(1, sizeof(struct pcm)); |
| 9563 | + if (!pcm || !config) |
| 9564 | + return &bad_pcm; /* TODO: could support default config here */ |
| 9565 | + |
| 9566 | + pcm->config = *config; |
| 9567 | + |
| 9568 | + snprintf(fn, sizeof(fn), "/dev/snd/pcmC%uD%u%c", card, device, |
| 9569 | + flags & PCM_IN ? 'c' : 'p'); |
| 9570 | + |
| 9571 | + pcm->flags = flags; |
| 9572 | + pcm->fd = open(fn, O_RDWR|O_NONBLOCK); |
| 9573 | + if (pcm->fd < 0) { |
| 9574 | + oops(pcm, errno, "cannot open device '%s'", fn); |
| 9575 | + return pcm; |
| 9576 | + } |
| 9577 | + |
| 9578 | + if (fcntl(pcm->fd, F_SETFL, fcntl(pcm->fd, F_GETFL) & |
| 9579 | + ~O_NONBLOCK) < 0) { |
| 9580 | + oops(pcm, errno, "failed to reset blocking mode '%s'", fn); |
| 9581 | + goto fail_close; |
| 9582 | + } |
| 9583 | + |
| 9584 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_INFO, &info)) { |
| 9585 | + oops(pcm, errno, "cannot get info"); |
| 9586 | + goto fail_close; |
| 9587 | + } |
| 9588 | + |
| 9589 | + param_init(¶ms); |
| 9590 | + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, |
| 9591 | + pcm_format_to_alsa(config->format)); |
| 9592 | + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_SUBFORMAT, |
| 9593 | + SNDRV_PCM_SUBFORMAT_STD); |
| 9594 | + param_set_min(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, config->period_size); |
| 9595 | + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, |
| 9596 | + pcm_format_to_bits(config->format)); |
| 9597 | + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_FRAME_BITS, |
| 9598 | + pcm_format_to_bits(config->format) * config->channels); |
| 9599 | + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_CHANNELS, |
| 9600 | + config->channels); |
| 9601 | + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_PERIODS, config->period_count); |
| 9602 | + param_set_int(¶ms, SNDRV_PCM_HW_PARAM_RATE, config->rate); |
| 9603 | + |
| 9604 | + if (flags & PCM_NOIRQ) { |
| 9605 | + if (!(flags & PCM_MMAP)) { |
| 9606 | + oops(pcm, -EINVAL, "noirq only currently supported with mmap()."); |
| 9607 | + goto fail_close; |
| 9608 | + } |
| 9609 | + |
| 9610 | + params.flags |= SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP; |
| 9611 | + pcm->noirq_frames_per_msec = config->rate / 1000; |
| 9612 | + } |
| 9613 | + |
| 9614 | + if (flags & PCM_MMAP) |
| 9615 | + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, |
| 9616 | + SNDRV_PCM_ACCESS_MMAP_INTERLEAVED); |
| 9617 | + else |
| 9618 | + param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_ACCESS, |
| 9619 | + SNDRV_PCM_ACCESS_RW_INTERLEAVED); |
| 9620 | + |
| 9621 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_HW_PARAMS, ¶ms)) { |
| 9622 | + oops(pcm, errno, "cannot set hw params"); |
| 9623 | + goto fail_close; |
| 9624 | + } |
| 9625 | + |
| 9626 | + /* get our refined hw_params */ |
| 9627 | + config->period_size = param_get_int(¶ms, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); |
| 9628 | + config->period_count = param_get_int(¶ms, SNDRV_PCM_HW_PARAM_PERIODS); |
| 9629 | + pcm->buffer_size = config->period_count * config->period_size; |
| 9630 | + |
| 9631 | + if (flags & PCM_MMAP) { |
| 9632 | + pcm->mmap_buffer = mmap(NULL, pcm_frames_to_bytes(pcm, pcm->buffer_size), |
| 9633 | + PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, pcm->fd, 0); |
| 9634 | + if (pcm->mmap_buffer == MAP_FAILED) { |
| 9635 | + oops(pcm, -errno, "failed to mmap buffer %d bytes\n", |
| 9636 | + pcm_frames_to_bytes(pcm, pcm->buffer_size)); |
| 9637 | + goto fail_close; |
| 9638 | + } |
| 9639 | + } |
| 9640 | + |
| 9641 | + memset(&sparams, 0, sizeof(sparams)); |
| 9642 | + sparams.tstamp_mode = SNDRV_PCM_TSTAMP_ENABLE; |
| 9643 | + sparams.period_step = 1; |
| 9644 | + |
| 9645 | + if (!config->start_threshold) { |
| 9646 | + if (pcm->flags & PCM_IN) |
| 9647 | + pcm->config.start_threshold = sparams.start_threshold = 1; |
| 9648 | + else |
| 9649 | + pcm->config.start_threshold = sparams.start_threshold = |
| 9650 | + config->period_count * config->period_size / 2; |
| 9651 | + } else |
| 9652 | + sparams.start_threshold = config->start_threshold; |
| 9653 | + |
| 9654 | + /* pick a high stop threshold - todo: does this need further tuning */ |
| 9655 | + if (!config->stop_threshold) { |
| 9656 | + if (pcm->flags & PCM_IN) |
| 9657 | + pcm->config.stop_threshold = sparams.stop_threshold = |
| 9658 | + config->period_count * config->period_size * 10; |
| 9659 | + else |
| 9660 | + pcm->config.stop_threshold = sparams.stop_threshold = |
| 9661 | + config->period_count * config->period_size; |
| 9662 | + } |
| 9663 | + else |
| 9664 | + sparams.stop_threshold = config->stop_threshold; |
| 9665 | + |
| 9666 | + if (!pcm->config.avail_min) { |
| 9667 | + if (pcm->flags & PCM_MMAP) |
| 9668 | + pcm->config.avail_min = sparams.avail_min = pcm->config.period_size; |
| 9669 | + else |
| 9670 | + pcm->config.avail_min = sparams.avail_min = 1; |
| 9671 | + } else |
| 9672 | + sparams.avail_min = config->avail_min; |
| 9673 | + |
| 9674 | + sparams.xfer_align = config->period_size / 2; /* needed for old kernels */ |
| 9675 | + sparams.silence_threshold = config->silence_threshold; |
| 9676 | + sparams.silence_size = config->silence_size; |
| 9677 | + pcm->boundary = sparams.boundary = pcm->buffer_size; |
| 9678 | + |
| 9679 | + while (pcm->boundary * 2 <= INT_MAX - pcm->buffer_size) |
| 9680 | + pcm->boundary *= 2; |
| 9681 | + |
| 9682 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_SW_PARAMS, &sparams)) { |
| 9683 | + oops(pcm, errno, "cannot set sw params"); |
| 9684 | + goto fail; |
| 9685 | + } |
| 9686 | + |
| 9687 | + rc = pcm_hw_mmap_status(pcm); |
| 9688 | + if (rc < 0) { |
| 9689 | + oops(pcm, rc, "mmap status failed"); |
| 9690 | + goto fail; |
| 9691 | + } |
| 9692 | + |
| 9693 | +#ifdef SNDRV_PCM_IOCTL_TTSTAMP |
| 9694 | + if (pcm->flags & PCM_MONOTONIC) { |
| 9695 | + int arg = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC; |
| 9696 | + rc = ioctl(pcm->fd, SNDRV_PCM_IOCTL_TTSTAMP, &arg); |
| 9697 | + if (rc < 0) { |
| 9698 | + oops(pcm, rc, "cannot set timestamp type"); |
| 9699 | + goto fail; |
| 9700 | + } |
| 9701 | + } |
| 9702 | +#endif |
| 9703 | + |
| 9704 | + pcm->underruns = 0; |
| 9705 | + return pcm; |
| 9706 | + |
| 9707 | +fail: |
| 9708 | + if (flags & PCM_MMAP) |
| 9709 | + munmap(pcm->mmap_buffer, pcm_frames_to_bytes(pcm, pcm->buffer_size)); |
| 9710 | +fail_close: |
| 9711 | + close(pcm->fd); |
| 9712 | + pcm->fd = -1; |
| 9713 | + return pcm; |
| 9714 | +} |
| 9715 | + |
| 9716 | +int pcm_is_ready(struct pcm *pcm) |
| 9717 | +{ |
| 9718 | + return pcm->fd >= 0; |
| 9719 | +} |
| 9720 | + |
| 9721 | +int pcm_prepare(struct pcm *pcm) |
| 9722 | +{ |
| 9723 | + if (pcm->prepared) |
| 9724 | + return 0; |
| 9725 | + |
| 9726 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_PREPARE) < 0) |
| 9727 | + return oops(pcm, errno, "cannot prepare channel"); |
| 9728 | + |
| 9729 | + pcm->prepared = 1; |
| 9730 | + return 0; |
| 9731 | +} |
| 9732 | + |
| 9733 | +int pcm_start(struct pcm *pcm) |
| 9734 | +{ |
| 9735 | + int prepare_error = pcm_prepare(pcm); |
| 9736 | + if (prepare_error) |
| 9737 | + return prepare_error; |
| 9738 | + |
| 9739 | + if (pcm->flags & PCM_MMAP) |
| 9740 | + pcm_sync_ptr(pcm, 0); |
| 9741 | + |
| 9742 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START) < 0) |
| 9743 | + return oops(pcm, errno, "cannot start channel"); |
| 9744 | + |
| 9745 | + pcm->running = 1; |
| 9746 | + return 0; |
| 9747 | +} |
| 9748 | + |
| 9749 | +int pcm_stop(struct pcm *pcm) |
| 9750 | +{ |
| 9751 | + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_DROP) < 0) |
| 9752 | + return oops(pcm, errno, "cannot stop channel"); |
| 9753 | + |
| 9754 | + pcm->prepared = 0; |
| 9755 | + pcm->running = 0; |
| 9756 | + return 0; |
| 9757 | +} |
| 9758 | + |
| 9759 | +static inline int pcm_mmap_playback_avail(struct pcm *pcm) |
| 9760 | +{ |
| 9761 | + int avail; |
| 9762 | + |
| 9763 | + avail = pcm->mmap_status->hw_ptr + pcm->buffer_size - pcm->mmap_control->appl_ptr; |
| 9764 | + |
| 9765 | + if (avail < 0) |
| 9766 | + avail += pcm->boundary; |
| 9767 | + else if (avail > (int)pcm->boundary) |
| 9768 | + avail -= pcm->boundary; |
| 9769 | + |
| 9770 | + return avail; |
| 9771 | +} |
| 9772 | + |
| 9773 | +static inline int pcm_mmap_capture_avail(struct pcm *pcm) |
| 9774 | +{ |
| 9775 | + int avail = pcm->mmap_status->hw_ptr - pcm->mmap_control->appl_ptr; |
| 9776 | + if (avail < 0) |
| 9777 | + avail += pcm->boundary; |
| 9778 | + return avail; |
| 9779 | +} |
| 9780 | + |
| 9781 | +int pcm_mmap_avail(struct pcm *pcm) |
| 9782 | +{ |
| 9783 | + pcm_sync_ptr(pcm, SNDRV_PCM_SYNC_PTR_HWSYNC); |
| 9784 | + if (pcm->flags & PCM_IN) |
| 9785 | + return pcm_mmap_capture_avail(pcm); |
| 9786 | + else |
| 9787 | + return pcm_mmap_playback_avail(pcm); |
| 9788 | +} |
| 9789 | + |
| 9790 | +static void pcm_mmap_appl_forward(struct pcm *pcm, int frames) |
| 9791 | +{ |
| 9792 | + unsigned int appl_ptr = pcm->mmap_control->appl_ptr; |
| 9793 | + appl_ptr += frames; |
| 9794 | + |
| 9795 | + /* check for boundary wrap */ |
| 9796 | + if (appl_ptr > pcm->boundary) |
| 9797 | + appl_ptr -= pcm->boundary; |
| 9798 | + pcm->mmap_control->appl_ptr = appl_ptr; |
| 9799 | +} |
| 9800 | + |
| 9801 | +int pcm_mmap_begin(struct pcm *pcm, void **areas, unsigned int *offset, |
| 9802 | + unsigned int *frames) |
| 9803 | +{ |
| 9804 | + unsigned int continuous, copy_frames, avail; |
| 9805 | + |
| 9806 | + /* return the mmap buffer */ |
| 9807 | + *areas = pcm->mmap_buffer; |
| 9808 | + |
| 9809 | + /* and the application offset in frames */ |
| 9810 | + *offset = pcm->mmap_control->appl_ptr % pcm->buffer_size; |
| 9811 | + |
| 9812 | + avail = pcm_mmap_avail(pcm); |
| 9813 | + if (avail > pcm->buffer_size) |
| 9814 | + avail = pcm->buffer_size; |
| 9815 | + continuous = pcm->buffer_size - *offset; |
| 9816 | + |
| 9817 | + /* we can only copy frames if the are availabale and continuos */ |
| 9818 | + copy_frames = *frames; |
| 9819 | + if (copy_frames > avail) |
| 9820 | + copy_frames = avail; |
| 9821 | + if (copy_frames > continuous) |
| 9822 | + copy_frames = continuous; |
| 9823 | + *frames = copy_frames; |
| 9824 | + |
| 9825 | + return 0; |
| 9826 | +} |
| 9827 | + |
| 9828 | +int pcm_mmap_commit(struct pcm *pcm, unsigned int offset __attribute__((unused)), unsigned int frames) |
| 9829 | +{ |
| 9830 | + /* update the application pointer in userspace and kernel */ |
| 9831 | + pcm_mmap_appl_forward(pcm, frames); |
| 9832 | + pcm_sync_ptr(pcm, 0); |
| 9833 | + |
| 9834 | + return frames; |
| 9835 | +} |
| 9836 | + |
| 9837 | +int pcm_avail_update(struct pcm *pcm) |
| 9838 | +{ |
| 9839 | + pcm_sync_ptr(pcm, 0); |
| 9840 | + return pcm_mmap_avail(pcm); |
| 9841 | +} |
| 9842 | + |
| 9843 | +int pcm_state(struct pcm *pcm) |
| 9844 | +{ |
| 9845 | + int err = pcm_sync_ptr(pcm, 0); |
| 9846 | + if (err < 0) |
| 9847 | + return err; |
| 9848 | + |
| 9849 | + return pcm->mmap_status->state; |
| 9850 | +} |
| 9851 | + |
| 9852 | +int pcm_set_avail_min(struct pcm *pcm, int avail_min) |
| 9853 | +{ |
| 9854 | + if ((~pcm->flags) & (PCM_MMAP | PCM_NOIRQ)) |
| 9855 | + return -ENOSYS; |
| 9856 | + |
| 9857 | + pcm->config.avail_min = avail_min; |
| 9858 | + return 0; |
| 9859 | +} |
| 9860 | + |
| 9861 | +int pcm_wait(struct pcm *pcm, int timeout) |
| 9862 | +{ |
| 9863 | + struct pollfd pfd; |
| 9864 | + int err; |
| 9865 | + |
| 9866 | + pfd.fd = pcm->fd; |
| 9867 | + pfd.events = POLLOUT | POLLERR | POLLNVAL; |
| 9868 | + |
| 9869 | + do { |
| 9870 | + /* let's wait for avail or timeout */ |
| 9871 | + err = poll(&pfd, 1, timeout); |
| 9872 | + if (err < 0) |
| 9873 | + return -errno; |
| 9874 | + |
| 9875 | + /* timeout ? */ |
| 9876 | + if (err == 0) |
| 9877 | + return 0; |
| 9878 | + |
| 9879 | + /* have we been interrupted ? */ |
| 9880 | + if (errno == -EINTR) |
| 9881 | + continue; |
| 9882 | + |
| 9883 | + /* check for any errors */ |
| 9884 | + if (pfd.revents & (POLLERR | POLLNVAL)) { |
| 9885 | + switch (pcm_state(pcm)) { |
| 9886 | + case PCM_STATE_XRUN: |
| 9887 | + return -EPIPE; |
| 9888 | + case PCM_STATE_SUSPENDED: |
| 9889 | + return -ESTRPIPE; |
| 9890 | + case PCM_STATE_DISCONNECTED: |
| 9891 | + return -ENODEV; |
| 9892 | + default: |
| 9893 | + return -EIO; |
| 9894 | + } |
| 9895 | + } |
| 9896 | + /* poll again if fd not ready for IO */ |
| 9897 | + } while (!(pfd.revents & (POLLIN | POLLOUT))); |
| 9898 | + |
| 9899 | + return 1; |
| 9900 | +} |
| 9901 | + |
| 9902 | +int pcm_get_poll_fd(struct pcm *pcm) |
| 9903 | +{ |
| 9904 | + return pcm->fd; |
| 9905 | +} |
| 9906 | + |
| 9907 | +int pcm_mmap_transfer(struct pcm *pcm, const void *buffer, unsigned int bytes) |
| 9908 | +{ |
| 9909 | + int err = 0, frames, avail; |
| 9910 | + unsigned int offset = 0, count; |
| 9911 | + |
| 9912 | + if (bytes == 0) |
| 9913 | + return 0; |
| 9914 | + |
| 9915 | + count = pcm_bytes_to_frames(pcm, bytes); |
| 9916 | + |
| 9917 | + while (count > 0) { |
| 9918 | + |
| 9919 | + /* get the available space for writing new frames */ |
| 9920 | + avail = pcm_avail_update(pcm); |
| 9921 | + if (avail < 0) { |
| 9922 | + fprintf(stderr, "cannot determine available mmap frames"); |
| 9923 | + return err; |
| 9924 | + } |
| 9925 | + |
| 9926 | + /* start the audio if we reach the threshold */ |
| 9927 | + if (!pcm->running && |
| 9928 | + (pcm->buffer_size - avail) >= pcm->config.start_threshold) { |
| 9929 | + if (pcm_start(pcm) < 0) { |
| 9930 | + fprintf(stderr, "start error: hw 0x%x app 0x%x avail 0x%x\n", |
| 9931 | + (unsigned int)pcm->mmap_status->hw_ptr, |
| 9932 | + (unsigned int)pcm->mmap_control->appl_ptr, |
| 9933 | + avail); |
| 9934 | + return -errno; |
| 9935 | + } |
| 9936 | + pcm->wait_for_avail_min = 0; |
| 9937 | + } |
| 9938 | + |
| 9939 | + /* sleep until we have space to write new frames */ |
| 9940 | + if (pcm->running) { |
| 9941 | + /* enable waiting for avail_min threshold when less frames than we have to write |
| 9942 | + * are available. */ |
| 9943 | + if (!pcm->wait_for_avail_min && (count > (unsigned int)avail)) |
| 9944 | + pcm->wait_for_avail_min = 1; |
| 9945 | + |
| 9946 | + if (pcm->wait_for_avail_min && (avail < pcm->config.avail_min)) { |
| 9947 | + int time = -1; |
| 9948 | + |
| 9949 | + /* disable waiting for avail_min threshold to allow small amounts of data to be |
| 9950 | + * written without waiting as long as there is enough room in buffer. */ |
| 9951 | + pcm->wait_for_avail_min = 0; |
| 9952 | + |
| 9953 | + if (pcm->flags & PCM_NOIRQ) |
| 9954 | + time = (pcm->config.avail_min - avail) / pcm->noirq_frames_per_msec; |
| 9955 | + |
| 9956 | + err = pcm_wait(pcm, time); |
| 9957 | + if (err < 0) { |
| 9958 | + pcm->prepared = 0; |
| 9959 | + pcm->running = 0; |
| 9960 | + oops(pcm, err, "wait error: hw 0x%x app 0x%x avail 0x%x\n", |
| 9961 | + (unsigned int)pcm->mmap_status->hw_ptr, |
| 9962 | + (unsigned int)pcm->mmap_control->appl_ptr, |
| 9963 | + avail); |
| 9964 | + pcm->mmap_control->appl_ptr = 0; |
| 9965 | + return err; |
| 9966 | + } |
| 9967 | + continue; |
| 9968 | + } |
| 9969 | + } |
| 9970 | + |
| 9971 | + frames = count; |
| 9972 | + if (frames > avail) |
| 9973 | + frames = avail; |
| 9974 | + |
| 9975 | + if (!frames) |
| 9976 | + break; |
| 9977 | + |
| 9978 | + /* copy frames from buffer */ |
| 9979 | + frames = pcm_mmap_transfer_areas(pcm, (void *)buffer, offset, frames); |
| 9980 | + if (frames < 0) { |
| 9981 | + fprintf(stderr, "write error: hw 0x%x app 0x%x avail 0x%x\n", |
| 9982 | + (unsigned int)pcm->mmap_status->hw_ptr, |
| 9983 | + (unsigned int)pcm->mmap_control->appl_ptr, |
| 9984 | + avail); |
| 9985 | + return frames; |
| 9986 | + } |
| 9987 | + |
| 9988 | + offset += frames; |
| 9989 | + count -= frames; |
| 9990 | + } |
| 9991 | + |
| 9992 | + return 0; |
| 9993 | +} |
| 9994 | + |
| 9995 | +int pcm_mmap_write(struct pcm *pcm, const void *data, unsigned int count) |
| 9996 | +{ |
| 9997 | + if ((~pcm->flags) & (PCM_OUT | PCM_MMAP)) |
| 9998 | + return -ENOSYS; |
| 9999 | + |
| 10000 | + return pcm_mmap_transfer(pcm, (void *)data, count); |
| 10001 | +} |
| 10002 | + |
| 10003 | +int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count) |
| 10004 | +{ |
| 10005 | + if ((~pcm->flags) & (PCM_IN | PCM_MMAP)) |
| 10006 | + return -ENOSYS; |
| 10007 | + |
| 10008 | + return pcm_mmap_transfer(pcm, data, count); |
| 10009 | +} |
| 10010 | + |
| 10011 | +int pcm_ioctl(struct pcm *pcm, int request, ...) |
| 10012 | +{ |
| 10013 | + va_list ap; |
| 10014 | + void * arg; |
| 10015 | + |
| 10016 | + if (!pcm_is_ready(pcm)) |
| 10017 | + return -1; |
| 10018 | + |
| 10019 | + va_start(ap, request); |
| 10020 | + arg = va_arg(ap, void *); |
| 10021 | + va_end(ap); |
| 10022 | + |
| 10023 | + return ioctl(pcm->fd, request, arg); |
| 10024 | +} |
| 10025 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinyalsa_voice_ref.c b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinyalsa_voice_ref.c |
| 10026 | new file mode 100755 |
| 10027 | index 0000000..9cdc264 |
| 10028 | --- /dev/null |
| 10029 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinyalsa_voice_ref.c |
| 10030 | @@ -0,0 +1,122 @@ |
| 10031 | +/*
|
| 10032 | + *
|
| 10033 | + * Based on 7510_dev.c
|
| 10034 | + *
|
| 10035 | + */
|
| 10036 | +
|
| 10037 | +#include <tinyalsa/audio_mixer_ctrl.h>
|
| 10038 | +
|
| 10039 | +
|
| 10040 | +struct pcm *voicePcmOut = NULL;
|
| 10041 | +struct pcm *voicePcmIn = NULL;
|
| 10042 | +
|
| 10043 | +typedef struct
|
| 10044 | +{
|
| 10045 | + // uint32_t voice_mode;//0, 2/3g;1, volte nb;2 ,volte wb;
|
| 10046 | + uint32_t clock_rate; //8000, 2/3g;8000, volte nb;16000 ,volte wb;
|
| 10047 | + uint32_t channel_count;
|
| 10048 | + uint32_t samples_per_frame;//160, 2/3g;160, volte nb;320 ,volte wb;
|
| 10049 | + uint32_t bits_per_sample;
|
| 10050 | +} T_voiceCfg;
|
| 10051 | +
|
| 10052 | +T_voiceCfg cfgParam = {0,8000,1,160,16};
|
| 10053 | +
|
| 10054 | +
|
| 10055 | +
|
| 10056 | +
|
| 10057 | + int voice_PreOpen(T_voiceCfg *cfgParam)
|
| 10058 | +{
|
| 10059 | + struct mixer *voice_mixer = NULL;
|
| 10060 | + struct pcm_config config_voice = {0};
|
| 10061 | +
|
| 10062 | + /* open mixer dev for codec control */
|
| 10063 | + voice_mixer = mixer_open(0);
|
| 10064 | + if(!voice_mixer)
|
| 10065 | + {
|
| 10066 | + printf("voice_mixer open failed!");
|
| 10067 | + goto err_ret;
|
| 10068 | + }
|
| 10069 | +
|
| 10070 | + /* config mixer dev */
|
| 10071 | + mix_set_voice_path(voice_mixer, T_OUTPUT_SPEAKER);
|
| 10072 | + mix_set_voice_vol(voice_mixer, T_VOICE_VOL_3_LEVEL);
|
| 10073 | +
|
| 10074 | + /*close mixer */
|
| 10075 | + mixer_close(voice_mixer);
|
| 10076 | + voice_mixer = NULL;
|
| 10077 | +
|
| 10078 | + /* open pcm dev for data tranf*/
|
| 10079 | + config_voice.channels = cfgParam->channel_count;
|
| 10080 | + config_voice.rate = cfgParam->clock_rate;
|
| 10081 | + /* buffer num */
|
| 10082 | + config_voice.period_count = 3;
|
| 10083 | + /* buffer size */
|
| 10084 | + config_voice.period_size = cfgParam->samples_per_frame * cfgParam->bits_per_sample / 8;
|
| 10085 | + /* 16-bit signed */
|
| 10086 | + config_voice.format = PCM_FORMAT_S16_LE;
|
| 10087 | +
|
| 10088 | + //card 0 dev 1
|
| 10089 | + //23G card 0 dev 2
|
| 10090 | + voicePcmOut = pcm_open(0, 1, PCM_OUT, &config_voice);
|
| 10091 | + if(!voicePcmOut || !pcm_is_ready(voicePcmOut))
|
| 10092 | + {
|
| 10093 | + printf( "voicePcmOut open failed!");
|
| 10094 | + goto err_ret;
|
| 10095 | + }
|
| 10096 | +
|
| 10097 | + voicePcmIn = pcm_open(0, 1, PCM_IN, &config_voice);
|
| 10098 | + if(!voicePcmIn || !pcm_is_ready(voicePcmIn))
|
| 10099 | + {
|
| 10100 | + printf( "voicePcmIn open failed!");
|
| 10101 | + goto err_ret;
|
| 10102 | + }
|
| 10103 | +
|
| 10104 | + if(0 != pcm_prepare(voicePcmOut))
|
| 10105 | + {
|
| 10106 | + printf("voicePcmOut pcm_prepare failed!");
|
| 10107 | + goto err_ret;
|
| 10108 | + }
|
| 10109 | +
|
| 10110 | + if(0 != pcm_prepare(voicePcmIn))
|
| 10111 | + {
|
| 10112 | + printf("voicePcmIn pcm_prepare failed!");
|
| 10113 | + goto err_ret;
|
| 10114 | + }
|
| 10115 | + return 0;
|
| 10116 | +err_ret:
|
| 10117 | + if(voice_mixer)
|
| 10118 | + {
|
| 10119 | + mixer_close(voice_mixer);
|
| 10120 | + voice_mixer = NULL;
|
| 10121 | + }
|
| 10122 | +
|
| 10123 | + if(voicePcmOut)
|
| 10124 | + {
|
| 10125 | + pcm_close(voicePcmOut);
|
| 10126 | + voicePcmOut = NULL;
|
| 10127 | + }
|
| 10128 | + if(voicePcmIn)
|
| 10129 | + {
|
| 10130 | + pcm_close(voicePcmIn);
|
| 10131 | + voicePcmIn = NULL;
|
| 10132 | + }
|
| 10133 | + return -1;
|
| 10134 | +
|
| 10135 | +}
|
| 10136 | +
|
| 10137 | +
|
| 10138 | + void voice_PreClose(void)
|
| 10139 | +{
|
| 10140 | + if(voicePcmOut)
|
| 10141 | + {
|
| 10142 | + pcm_close(voicePcmOut);
|
| 10143 | + voicePcmOut = NULL;
|
| 10144 | + }
|
| 10145 | + if(voicePcmIn)
|
| 10146 | + {
|
| 10147 | + pcm_close(voicePcmIn);
|
| 10148 | + voicePcmIn = NULL;
|
| 10149 | + }
|
| 10150 | +}
|
| 10151 | +
|
| 10152 | +
|
| 10153 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinycap.c b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinycap.c |
| 10154 | new file mode 100755 |
| 10155 | index 0000000..da6f4e9 |
| 10156 | --- /dev/null |
| 10157 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinycap.c |
| 10158 | @@ -0,0 +1,237 @@ |
| 10159 | +/* tinycap.c |
| 10160 | +** |
| 10161 | +** Copyright 2011, The Android Open Source Project |
| 10162 | +** |
| 10163 | +** Redistribution and use in source and binary forms, with or without |
| 10164 | +** modification, are permitted provided that the following conditions are met: |
| 10165 | +** * Redistributions of source code must retain the above copyright |
| 10166 | +** notice, this list of conditions and the following disclaimer. |
| 10167 | +** * Redistributions in binary form must reproduce the above copyright |
| 10168 | +** notice, this list of conditions and the following disclaimer in the |
| 10169 | +** documentation and/or other materials provided with the distribution. |
| 10170 | +** * Neither the name of The Android Open Source Project nor the names of |
| 10171 | +** its contributors may be used to endorse or promote products derived |
| 10172 | +** from this software without specific prior written permission. |
| 10173 | +** |
| 10174 | +** THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND |
| 10175 | +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 10176 | +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 10177 | +** ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE |
| 10178 | +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 10179 | +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 10180 | +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 10181 | +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 10182 | +** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 10183 | +** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 10184 | +** DAMAGE. |
| 10185 | +*/ |
| 10186 | + |
| 10187 | +#include <tinyalsa/asoundlib.h> |
| 10188 | +#include <stdio.h> |
| 10189 | +#include <stdlib.h> |
| 10190 | +#include <stdint.h> |
| 10191 | +#include <signal.h> |
| 10192 | +#include <string.h> |
| 10193 | + |
| 10194 | +#define ID_RIFF 0x46464952 |
| 10195 | +#define ID_WAVE 0x45564157 |
| 10196 | +#define ID_FMT 0x20746d66 |
| 10197 | +#define ID_DATA 0x61746164 |
| 10198 | + |
| 10199 | +#define FORMAT_PCM 1 |
| 10200 | + |
| 10201 | +struct wav_header { |
| 10202 | + uint32_t riff_id; |
| 10203 | + uint32_t riff_sz; |
| 10204 | + uint32_t riff_fmt; |
| 10205 | + uint32_t fmt_id; |
| 10206 | + uint32_t fmt_sz; |
| 10207 | + uint16_t audio_format; |
| 10208 | + uint16_t num_channels; |
| 10209 | + uint32_t sample_rate; |
| 10210 | + uint32_t byte_rate; |
| 10211 | + uint16_t block_align; |
| 10212 | + uint16_t bits_per_sample; |
| 10213 | + uint32_t data_id; |
| 10214 | + uint32_t data_sz; |
| 10215 | +}; |
| 10216 | + |
| 10217 | +int capturing = 1; |
| 10218 | + |
| 10219 | +unsigned int capture_sample(FILE *file, unsigned int card, unsigned int device, |
| 10220 | + unsigned int channels, unsigned int rate, |
| 10221 | + enum pcm_format format, unsigned int period_size, |
| 10222 | + unsigned int period_count); |
| 10223 | + |
| 10224 | +void sigint_handler(int sig) // __unused) |
| 10225 | +{ |
| 10226 | + capturing = 0; |
| 10227 | +} |
| 10228 | + |
| 10229 | +int main(int argc, char **argv) |
| 10230 | +{ |
| 10231 | + FILE *file; |
| 10232 | + struct wav_header header; |
| 10233 | + unsigned int card = 0; |
| 10234 | + unsigned int device = 0; |
| 10235 | + unsigned int channels = 2; |
| 10236 | + unsigned int rate = 44100; |
| 10237 | + unsigned int bits = 16; |
| 10238 | + unsigned int frames; |
| 10239 | + unsigned int period_size = 1024; |
| 10240 | + unsigned int period_count = 4; |
| 10241 | + enum pcm_format format; |
| 10242 | + |
| 10243 | + if (argc < 2) { |
| 10244 | + fprintf(stderr, "Usage: %s file.wav [-D card] [-d device] [-c channels] " |
| 10245 | + "[-r rate] [-b bits] [-p period_size] [-n n_periods]\n", argv[0]); |
| 10246 | + return 1; |
| 10247 | + } |
| 10248 | + |
| 10249 | + file = fopen(argv[1], "wb"); |
| 10250 | + if (!file) { |
| 10251 | + fprintf(stderr, "Unable to create file '%s'\n", argv[1]); |
| 10252 | + return 1; |
| 10253 | + } |
| 10254 | + |
| 10255 | + /* parse command line arguments */ |
| 10256 | + argv += 2; |
| 10257 | + while (*argv) { |
| 10258 | + if (strcmp(*argv, "-d") == 0) { |
| 10259 | + argv++; |
| 10260 | + if (*argv) |
| 10261 | + device = atoi(*argv); |
| 10262 | + } else if (strcmp(*argv, "-c") == 0) { |
| 10263 | + argv++; |
| 10264 | + if (*argv) |
| 10265 | + channels = atoi(*argv); |
| 10266 | + } else if (strcmp(*argv, "-r") == 0) { |
| 10267 | + argv++; |
| 10268 | + if (*argv) |
| 10269 | + rate = atoi(*argv); |
| 10270 | + } else if (strcmp(*argv, "-b") == 0) { |
| 10271 | + argv++; |
| 10272 | + if (*argv) |
| 10273 | + bits = atoi(*argv); |
| 10274 | + } else if (strcmp(*argv, "-D") == 0) { |
| 10275 | + argv++; |
| 10276 | + if (*argv) |
| 10277 | + card = atoi(*argv); |
| 10278 | + } else if (strcmp(*argv, "-p") == 0) { |
| 10279 | + argv++; |
| 10280 | + if (*argv) |
| 10281 | + period_size = atoi(*argv); |
| 10282 | + } else if (strcmp(*argv, "-n") == 0) { |
| 10283 | + argv++; |
| 10284 | + if (*argv) |
| 10285 | + period_count = atoi(*argv); |
| 10286 | + } |
| 10287 | + if (*argv) |
| 10288 | + argv++; |
| 10289 | + } |
| 10290 | + |
| 10291 | + header.riff_id = ID_RIFF; |
| 10292 | + header.riff_sz = 0; |
| 10293 | + header.riff_fmt = ID_WAVE; |
| 10294 | + header.fmt_id = ID_FMT; |
| 10295 | + header.fmt_sz = 16; |
| 10296 | + header.audio_format = FORMAT_PCM; |
| 10297 | + header.num_channels = channels; |
| 10298 | + header.sample_rate = rate; |
| 10299 | + |
| 10300 | + switch (bits) { |
| 10301 | + case 32: |
| 10302 | + format = PCM_FORMAT_S32_LE; |
| 10303 | + break; |
| 10304 | + case 24: |
| 10305 | + format = PCM_FORMAT_S24_LE; |
| 10306 | + break; |
| 10307 | + case 16: |
| 10308 | + format = PCM_FORMAT_S16_LE; |
| 10309 | + break; |
| 10310 | + default: |
| 10311 | + fprintf(stderr, "%d bits is not supported.\n", bits); |
| 10312 | + return 1; |
| 10313 | + } |
| 10314 | + |
| 10315 | + header.bits_per_sample = pcm_format_to_bits(format); |
| 10316 | + header.byte_rate = (header.bits_per_sample / 8) * channels * rate; |
| 10317 | + header.block_align = channels * (header.bits_per_sample / 8); |
| 10318 | + header.data_id = ID_DATA; |
| 10319 | + |
| 10320 | + /* leave enough room for header */ |
| 10321 | + fseek(file, sizeof(struct wav_header), SEEK_SET); |
| 10322 | + |
| 10323 | + /* install signal handler and begin capturing */ |
| 10324 | + signal(SIGINT, sigint_handler); |
| 10325 | + signal(SIGHUP, sigint_handler); |
| 10326 | + signal(SIGTERM, sigint_handler); |
| 10327 | + frames = capture_sample(file, card, device, header.num_channels, |
| 10328 | + header.sample_rate, format, |
| 10329 | + period_size, period_count); |
| 10330 | + printf("Captured %d frames\n", frames); |
| 10331 | + |
| 10332 | + /* write header now all information is known */ |
| 10333 | + header.data_sz = frames * header.block_align; |
| 10334 | + header.riff_sz = header.data_sz + sizeof(header) - 8; |
| 10335 | + fseek(file, 0, SEEK_SET); |
| 10336 | + fwrite(&header, sizeof(struct wav_header), 1, file); |
| 10337 | + |
| 10338 | + fclose(file); |
| 10339 | + |
| 10340 | + return 0; |
| 10341 | +} |
| 10342 | + |
| 10343 | +unsigned int capture_sample(FILE *file, unsigned int card, unsigned int device, |
| 10344 | + unsigned int channels, unsigned int rate, |
| 10345 | + enum pcm_format format, unsigned int period_size, |
| 10346 | + unsigned int period_count) |
| 10347 | +{ |
| 10348 | + struct pcm_config config; |
| 10349 | + struct pcm *pcm; |
| 10350 | + char *buffer; |
| 10351 | + unsigned int size; |
| 10352 | + unsigned int bytes_read = 0; |
| 10353 | + |
| 10354 | + memset(&config, 0, sizeof(config)); |
| 10355 | + config.channels = channels; |
| 10356 | + config.rate = rate; |
| 10357 | + config.period_size = period_size; |
| 10358 | + config.period_count = period_count; |
| 10359 | + config.format = format; |
| 10360 | + config.start_threshold = 0; |
| 10361 | + config.stop_threshold = 0; |
| 10362 | + config.silence_threshold = 0; |
| 10363 | + |
| 10364 | + pcm = pcm_open(card, device, PCM_IN, &config); |
| 10365 | + if (!pcm || !pcm_is_ready(pcm)) { |
| 10366 | + fprintf(stderr, "Unable to open PCM device (%s)\n", |
| 10367 | + pcm_get_error(pcm)); |
| 10368 | + return 0; |
| 10369 | + } |
| 10370 | + |
| 10371 | + size = pcm_frames_to_bytes(pcm, pcm_get_buffer_size(pcm)); |
| 10372 | + buffer = malloc(size); |
| 10373 | + if (!buffer) { |
| 10374 | + fprintf(stderr, "Unable to allocate %d bytes\n", size); |
| 10375 | + free(buffer); |
| 10376 | + pcm_close(pcm); |
| 10377 | + return 0; |
| 10378 | + } |
| 10379 | + |
| 10380 | + printf("Capturing sample: %u ch, %u hz, %u bit\n", channels, rate, |
| 10381 | + pcm_format_to_bits(format)); |
| 10382 | + |
| 10383 | + while (capturing && !pcm_read(pcm, buffer, size)) { |
| 10384 | + if (fwrite(buffer, 1, size, file) != size) { |
| 10385 | + fprintf(stderr,"Error capturing sample\n"); |
| 10386 | + break; |
| 10387 | + } |
| 10388 | + bytes_read += size; |
| 10389 | + } |
| 10390 | + |
| 10391 | + free(buffer); |
| 10392 | + pcm_close(pcm); |
| 10393 | + return pcm_bytes_to_frames(pcm, bytes_read); |
| 10394 | +} |
| 10395 | + |
| 10396 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinymix.c b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinymix.c |
| 10397 | new file mode 100755 |
| 10398 | index 0000000..a3c41a2 |
| 10399 | --- /dev/null |
| 10400 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinymix.c |
| 10401 | @@ -0,0 +1,316 @@ |
| 10402 | +/* tinymix.c |
| 10403 | +** |
| 10404 | +** Copyright 2011, The Android Open Source Project |
| 10405 | +** |
| 10406 | +** Redistribution and use in source and binary forms, with or without |
| 10407 | +** modification, are permitted provided that the following conditions are met: |
| 10408 | +** * Redistributions of source code must retain the above copyright |
| 10409 | +** notice, this list of conditions and the following disclaimer. |
| 10410 | +** * Redistributions in binary form must reproduce the above copyright |
| 10411 | +** notice, this list of conditions and the following disclaimer in the |
| 10412 | +** documentation and/or other materials provided with the distribution. |
| 10413 | +** * Neither the name of The Android Open Source Project nor the names of |
| 10414 | +** its contributors may be used to endorse or promote products derived |
| 10415 | +** from this software without specific prior written permission. |
| 10416 | +** |
| 10417 | +** THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND |
| 10418 | +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 10419 | +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 10420 | +** ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE |
| 10421 | +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 10422 | +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 10423 | +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 10424 | +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 10425 | +** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 10426 | +** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 10427 | +** DAMAGE. |
| 10428 | +*/ |
| 10429 | + |
| 10430 | +#include <tinyalsa/asoundlib.h> |
| 10431 | +#include <errno.h> |
| 10432 | +#include <stdio.h> |
| 10433 | +#include <stdlib.h> |
| 10434 | +#include <ctype.h> |
| 10435 | +#include <string.h> |
| 10436 | + |
| 10437 | +static void tinymix_list_controls(struct mixer *mixer); |
| 10438 | +static void tinymix_detail_control(struct mixer *mixer, const char *control, |
| 10439 | + int print_all); |
| 10440 | +static void tinymix_set_value(struct mixer *mixer, const char *control, |
| 10441 | + char **values, unsigned int num_values); |
| 10442 | +static void tinymix_print_enum(struct mixer_ctl *ctl, int print_all); |
| 10443 | + |
| 10444 | +int main(int argc, char **argv) |
| 10445 | +{ |
| 10446 | + struct mixer *mixer; |
| 10447 | + int card = 0; |
| 10448 | + |
| 10449 | + if ((argc > 2) && (strcmp(argv[1], "-D") == 0)) { |
| 10450 | + argv++; |
| 10451 | + if (argv[1]) { |
| 10452 | + card = atoi(argv[1]); |
| 10453 | + argv++; |
| 10454 | + argc -= 2; |
| 10455 | + } else { |
| 10456 | + argc -= 1; |
| 10457 | + } |
| 10458 | + } |
| 10459 | + |
| 10460 | + mixer = mixer_open(card); |
| 10461 | + if (!mixer) { |
| 10462 | + fprintf(stderr, "Failed to open mixer\n"); |
| 10463 | + return EXIT_FAILURE; |
| 10464 | + } |
| 10465 | + |
| 10466 | + |
| 10467 | + if (argc == 1) { |
| 10468 | + printf("Mixer name: '%s'\n", mixer_get_name(mixer)); |
| 10469 | + tinymix_list_controls(mixer); |
| 10470 | + } else if (argc == 2) { |
| 10471 | + tinymix_detail_control(mixer, argv[1], 1); |
| 10472 | + } else if (argc >= 3) { |
| 10473 | + tinymix_set_value(mixer, argv[1], &argv[2], argc - 2); |
| 10474 | + } else { |
| 10475 | + printf("Usage: tinymix [-D card] [control id] [value to set]\n"); |
| 10476 | + } |
| 10477 | + |
| 10478 | + mixer_close(mixer); |
| 10479 | + |
| 10480 | + return 0; |
| 10481 | +} |
| 10482 | + |
| 10483 | +static void tinymix_list_controls(struct mixer *mixer) |
| 10484 | +{ |
| 10485 | + struct mixer_ctl *ctl; |
| 10486 | + const char *name, *type; |
| 10487 | + unsigned int num_ctls, num_values; |
| 10488 | + unsigned int i; |
| 10489 | + |
| 10490 | + num_ctls = mixer_get_num_ctls(mixer); |
| 10491 | + |
| 10492 | + printf("Number of controls: %d\n", num_ctls); |
| 10493 | + |
| 10494 | + printf("ctl\ttype\tnum\t%-40s value\n", "name"); |
| 10495 | + for (i = 0; i < num_ctls; i++) { |
| 10496 | + ctl = mixer_get_ctl(mixer, i); |
| 10497 | + |
| 10498 | + name = mixer_ctl_get_name(ctl); |
| 10499 | + type = mixer_ctl_get_type_string(ctl); |
| 10500 | + num_values = mixer_ctl_get_num_values(ctl); |
| 10501 | + printf("%d\t%s\t%d\t%-40s", i, type, num_values, name); |
| 10502 | + tinymix_detail_control(mixer, name, 0); |
| 10503 | + } |
| 10504 | +} |
| 10505 | + |
| 10506 | +static void tinymix_print_enum(struct mixer_ctl *ctl, int print_all) |
| 10507 | +{ |
| 10508 | + unsigned int num_enums; |
| 10509 | + unsigned int i; |
| 10510 | + const char *string; |
| 10511 | + |
| 10512 | + num_enums = mixer_ctl_get_num_enums(ctl); |
| 10513 | + |
| 10514 | + for (i = 0; i < num_enums; i++) { |
| 10515 | + string = mixer_ctl_get_enum_string(ctl, i); |
| 10516 | + if (print_all) |
| 10517 | + printf("\t%s%s", mixer_ctl_get_value(ctl, 0) == (int)i ? ">" : "", |
| 10518 | + string); |
| 10519 | + else if (mixer_ctl_get_value(ctl, 0) == (int)i) |
| 10520 | + printf(" %-s", string); |
| 10521 | + } |
| 10522 | +} |
| 10523 | + |
| 10524 | +static void tinymix_detail_control(struct mixer *mixer, const char *control, |
| 10525 | + int print_all) |
| 10526 | +{ |
| 10527 | + struct mixer_ctl *ctl; |
| 10528 | + enum mixer_ctl_type type; |
| 10529 | + unsigned int num_values; |
| 10530 | + unsigned int i; |
| 10531 | + int min, max; |
| 10532 | + int ret; |
| 10533 | + char *buf = NULL; |
| 10534 | + size_t len; |
| 10535 | + |
| 10536 | + if (isdigit(control[0])) |
| 10537 | + ctl = mixer_get_ctl(mixer, atoi(control)); |
| 10538 | + else |
| 10539 | + ctl = mixer_get_ctl_by_name(mixer, control); |
| 10540 | + |
| 10541 | + if (!ctl) { |
| 10542 | + fprintf(stderr, "Invalid mixer control\n"); |
| 10543 | + return; |
| 10544 | + } |
| 10545 | + |
| 10546 | + type = mixer_ctl_get_type(ctl); |
| 10547 | + num_values = mixer_ctl_get_num_values(ctl); |
| 10548 | + |
| 10549 | + if (type == MIXER_CTL_TYPE_BYTE) { |
| 10550 | + |
| 10551 | + buf = calloc(1, num_values); |
| 10552 | + if (buf == NULL) { |
| 10553 | + fprintf(stderr, "Failed to alloc mem for bytes %d\n", num_values); |
| 10554 | + return; |
| 10555 | + } |
| 10556 | + |
| 10557 | + len = num_values; |
| 10558 | + ret = mixer_ctl_get_array(ctl, buf, len); |
| 10559 | + if (ret < 0) { |
| 10560 | + fprintf(stderr, "Failed to mixer_ctl_get_array\n"); |
| 10561 | + free(buf); |
| 10562 | + return; |
| 10563 | + } |
| 10564 | + } |
| 10565 | + |
| 10566 | + if (print_all) |
| 10567 | + printf("%s:", mixer_ctl_get_name(ctl)); |
| 10568 | + |
| 10569 | + for (i = 0; i < num_values; i++) { |
| 10570 | + switch (type) |
| 10571 | + { |
| 10572 | + case MIXER_CTL_TYPE_INT: |
| 10573 | + printf(" %d", mixer_ctl_get_value(ctl, i)); |
| 10574 | + break; |
| 10575 | + case MIXER_CTL_TYPE_BOOL: |
| 10576 | + printf(" %s", mixer_ctl_get_value(ctl, i) ? "On" : "Off"); |
| 10577 | + break; |
| 10578 | + case MIXER_CTL_TYPE_ENUM: |
| 10579 | + tinymix_print_enum(ctl, print_all); |
| 10580 | + break; |
| 10581 | + case MIXER_CTL_TYPE_BYTE: |
| 10582 | + printf("%02x", buf[i]); |
| 10583 | + break; |
| 10584 | + default: |
| 10585 | + printf(" unknown"); |
| 10586 | + break; |
| 10587 | + }; |
| 10588 | + } |
| 10589 | + |
| 10590 | + if (print_all) { |
| 10591 | + if (type == MIXER_CTL_TYPE_INT) { |
| 10592 | + min = mixer_ctl_get_range_min(ctl); |
| 10593 | + max = mixer_ctl_get_range_max(ctl); |
| 10594 | + printf(" (range %d->%d)", min, max); |
| 10595 | + } |
| 10596 | + } |
| 10597 | + |
| 10598 | + free(buf); |
| 10599 | + |
| 10600 | + printf("\n"); |
| 10601 | +} |
| 10602 | + |
| 10603 | +static void tinymix_set_byte_ctl(struct mixer_ctl *ctl, |
| 10604 | + char **values, unsigned int num_values) |
| 10605 | +{ |
| 10606 | + int ret; |
| 10607 | + char *buf; |
| 10608 | + char *end; |
| 10609 | + unsigned int i; |
| 10610 | + long n; |
| 10611 | + |
| 10612 | + buf = calloc(1, num_values); |
| 10613 | + if (buf == NULL) { |
| 10614 | + fprintf(stderr, "set_byte_ctl: Failed to alloc mem for bytes %d\n", num_values); |
| 10615 | + exit(EXIT_FAILURE); |
| 10616 | + } |
| 10617 | + |
| 10618 | + for (i = 0; i < num_values; i++) { |
| 10619 | + errno = 0; |
| 10620 | + n = strtol(values[i], &end, 0); |
| 10621 | + if (*end) { |
| 10622 | + fprintf(stderr, "%s not an integer\n", values[i]); |
| 10623 | + goto fail; |
| 10624 | + } |
| 10625 | + if (errno) { |
| 10626 | + fprintf(stderr, "strtol: %s: %s\n", values[i], |
| 10627 | + strerror(errno)); |
| 10628 | + goto fail; |
| 10629 | + } |
| 10630 | + if (n < 0 || n > 0xff) { |
| 10631 | + fprintf(stderr, "%s should be between [0, 0xff]\n", |
| 10632 | + values[i]); |
| 10633 | + goto fail; |
| 10634 | + } |
| 10635 | + buf[i] = n; |
| 10636 | + } |
| 10637 | + |
| 10638 | + ret = mixer_ctl_set_array(ctl, buf, num_values); |
| 10639 | + if (ret < 0) { |
| 10640 | + fprintf(stderr, "Failed to set binary control\n"); |
| 10641 | + goto fail; |
| 10642 | + } |
| 10643 | + |
| 10644 | + free(buf); |
| 10645 | + return; |
| 10646 | + |
| 10647 | +fail: |
| 10648 | + free(buf); |
| 10649 | + exit(EXIT_FAILURE); |
| 10650 | +} |
| 10651 | + |
| 10652 | +static void tinymix_set_value(struct mixer *mixer, const char *control, |
| 10653 | + char **values, unsigned int num_values) |
| 10654 | +{ |
| 10655 | + struct mixer_ctl *ctl; |
| 10656 | + enum mixer_ctl_type type; |
| 10657 | + unsigned int num_ctl_values; |
| 10658 | + unsigned int i; |
| 10659 | + |
| 10660 | + if (isdigit(control[0])) |
| 10661 | + ctl = mixer_get_ctl(mixer, atoi(control)); |
| 10662 | + else |
| 10663 | + ctl = mixer_get_ctl_by_name(mixer, control); |
| 10664 | + |
| 10665 | + if (!ctl) { |
| 10666 | + fprintf(stderr, "Invalid mixer control\n"); |
| 10667 | + return; |
| 10668 | + } |
| 10669 | + |
| 10670 | + type = mixer_ctl_get_type(ctl); |
| 10671 | + num_ctl_values = mixer_ctl_get_num_values(ctl); |
| 10672 | + |
| 10673 | + if (type == MIXER_CTL_TYPE_BYTE) { |
| 10674 | + tinymix_set_byte_ctl(ctl, values, num_values); |
| 10675 | + return; |
| 10676 | + } |
| 10677 | + |
| 10678 | + if (isdigit(values[0][0])) { |
| 10679 | + if (num_values == 1) { |
| 10680 | + /* Set all values the same */ |
| 10681 | + int value = atoi(values[0]); |
| 10682 | + |
| 10683 | + for (i = 0; i < num_ctl_values; i++) { |
| 10684 | + if (mixer_ctl_set_value(ctl, i, value)) { |
| 10685 | + fprintf(stderr, "Error: invalid value\n"); |
| 10686 | + return; |
| 10687 | + } |
| 10688 | + } |
| 10689 | + } else { |
| 10690 | + /* Set multiple values */ |
| 10691 | + if (num_values > num_ctl_values) { |
| 10692 | + fprintf(stderr, |
| 10693 | + "Error: %d values given, but control only takes %d\n", |
| 10694 | + num_values, num_ctl_values); |
| 10695 | + return; |
| 10696 | + } |
| 10697 | + for (i = 0; i < num_values; i++) { |
| 10698 | + if (mixer_ctl_set_value(ctl, i, atoi(values[i]))) { |
| 10699 | + fprintf(stderr, "Error: invalid value for index %d\n", i); |
| 10700 | + return; |
| 10701 | + } |
| 10702 | + } |
| 10703 | + } |
| 10704 | + } else { |
| 10705 | + if (type == MIXER_CTL_TYPE_ENUM) { |
| 10706 | + if (num_values != 1) { |
| 10707 | + fprintf(stderr, "Enclose strings in quotes and try again\n"); |
| 10708 | + return; |
| 10709 | + } |
| 10710 | + if (mixer_ctl_set_enum_by_string(ctl, values[0])) |
| 10711 | + fprintf(stderr, "Error: invalid enum value\n"); |
| 10712 | + } else { |
| 10713 | + fprintf(stderr, "Error: only enum types can be set with strings\n"); |
| 10714 | + } |
| 10715 | + } |
| 10716 | +} |
| 10717 | + |
| 10718 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinypcminfo.c b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinypcminfo.c |
| 10719 | new file mode 100755 |
| 10720 | index 0000000..b2d11bc |
| 10721 | --- /dev/null |
| 10722 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinypcminfo.c |
| 10723 | @@ -0,0 +1,203 @@ |
| 10724 | +/* tinypcminfo.c |
| 10725 | +** |
| 10726 | +** Copyright 2012, The Android Open Source Project |
| 10727 | +** |
| 10728 | +** Redistribution and use in source and binary forms, with or without |
| 10729 | +** modification, are permitted provided that the following conditions are met: |
| 10730 | +** * Redistributions of source code must retain the above copyright |
| 10731 | +** notice, this list of conditions and the following disclaimer. |
| 10732 | +** * Redistributions in binary form must reproduce the above copyright |
| 10733 | +** notice, this list of conditions and the following disclaimer in the |
| 10734 | +** documentation and/or other materials provided with the distribution. |
| 10735 | +** * Neither the name of The Android Open Source Project nor the names of |
| 10736 | +** its contributors may be used to endorse or promote products derived |
| 10737 | +** from this software without specific prior written permission. |
| 10738 | +** |
| 10739 | +** THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND |
| 10740 | +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 10741 | +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 10742 | +** ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE |
| 10743 | +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 10744 | +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 10745 | +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 10746 | +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 10747 | +** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 10748 | +** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 10749 | +** DAMAGE. |
| 10750 | +*/ |
| 10751 | + |
| 10752 | +#include <tinyalsa/asoundlib.h> |
| 10753 | +#include <stdio.h> |
| 10754 | +#include <stdlib.h> |
| 10755 | +#include <string.h> |
| 10756 | + |
| 10757 | +#ifndef ARRAY_SIZE |
| 10758 | +#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) |
| 10759 | +#endif |
| 10760 | + |
| 10761 | +/* The format_lookup is in order of SNDRV_PCM_FORMAT_##index and |
| 10762 | + * matches the grouping in sound/asound.h. Note this is not |
| 10763 | + * continuous and has an empty gap from (25 - 30). |
| 10764 | + */ |
| 10765 | +static const char *format_lookup[] = { |
| 10766 | + /*[0] =*/ "S8", |
| 10767 | + "U8", |
| 10768 | + "S16_LE", |
| 10769 | + "S16_BE", |
| 10770 | + "U16_LE", |
| 10771 | + "U16_BE", |
| 10772 | + "S24_LE", |
| 10773 | + "S24_BE", |
| 10774 | + "U24_LE", |
| 10775 | + "U24_BE", |
| 10776 | + "S32_LE", |
| 10777 | + "S32_BE", |
| 10778 | + "U32_LE", |
| 10779 | + "U32_BE", |
| 10780 | + "FLOAT_LE", |
| 10781 | + "FLOAT_BE", |
| 10782 | + "FLOAT64_LE", |
| 10783 | + "FLOAT64_BE", |
| 10784 | + "IEC958_SUBFRAME_LE", |
| 10785 | + "IEC958_SUBFRAME_BE", |
| 10786 | + "MU_LAW", |
| 10787 | + "A_LAW", |
| 10788 | + "IMA_ADPCM", |
| 10789 | + "MPEG", |
| 10790 | + /*[24] =*/ "GSM", |
| 10791 | + [31] = "SPECIAL", |
| 10792 | + "S24_3LE", |
| 10793 | + "S24_3BE", |
| 10794 | + "U24_3LE", |
| 10795 | + "U24_3BE", |
| 10796 | + "S20_3LE", |
| 10797 | + "S20_3BE", |
| 10798 | + "U20_3LE", |
| 10799 | + "U20_3BE", |
| 10800 | + "S18_3LE", |
| 10801 | + "S18_3BE", |
| 10802 | + "U18_3LE", |
| 10803 | + /*[43] =*/ "U18_3BE", |
| 10804 | +#if 0 |
| 10805 | + /* recent additions, may not be present on local asound.h */ |
| 10806 | + "G723_24", |
| 10807 | + "G723_24_1B", |
| 10808 | + "G723_40", |
| 10809 | + "G723_40_1B", |
| 10810 | + "DSD_U8", |
| 10811 | + "DSD_U16_LE", |
| 10812 | +#endif |
| 10813 | +}; |
| 10814 | + |
| 10815 | +/* Returns a human readable name for the format associated with bit_index, |
| 10816 | + * NULL if bit_index is not known. |
| 10817 | + */ |
| 10818 | +inline const char *pcm_get_format_name(unsigned bit_index) |
| 10819 | +{ |
| 10820 | + return bit_index < ARRAY_SIZE(format_lookup) ? format_lookup[bit_index] : NULL; |
| 10821 | +} |
| 10822 | + |
| 10823 | +int main(int argc, char **argv) |
| 10824 | +{ |
| 10825 | + unsigned int device = 0; |
| 10826 | + unsigned int card = 0; |
| 10827 | + int i; |
| 10828 | + |
| 10829 | + if (argc < 3) { |
| 10830 | + fprintf(stderr, "Usage: %s -D card -d device\n", argv[0]); |
| 10831 | + return 1; |
| 10832 | + } |
| 10833 | + |
| 10834 | + /* parse command line arguments */ |
| 10835 | + argv += 1; |
| 10836 | + while (*argv) { |
| 10837 | + if (strcmp(*argv, "-D") == 0) { |
| 10838 | + argv++; |
| 10839 | + if (*argv) |
| 10840 | + card = atoi(*argv); |
| 10841 | + } |
| 10842 | + if (strcmp(*argv, "-d") == 0) { |
| 10843 | + argv++; |
| 10844 | + if (*argv) |
| 10845 | + device = atoi(*argv); |
| 10846 | + } |
| 10847 | + if (*argv) |
| 10848 | + argv++; |
| 10849 | + } |
| 10850 | + |
| 10851 | + printf("Info for card %d, device %d:\n", card, device); |
| 10852 | + |
| 10853 | + for (i = 0; i < 2; i++) { |
| 10854 | + struct pcm_params *params; |
| 10855 | + struct pcm_mask *m; |
| 10856 | + unsigned int min; |
| 10857 | + unsigned int max; |
| 10858 | + |
| 10859 | + printf("\nPCM %s:\n", i == 0 ? "out" : "in"); |
| 10860 | + |
| 10861 | + params = pcm_params_get(card, device, i == 0 ? PCM_OUT : PCM_IN); |
| 10862 | + if (params == NULL) { |
| 10863 | + printf("Device does not exist.\n"); |
| 10864 | + continue; |
| 10865 | + } |
| 10866 | + |
| 10867 | + m = pcm_params_get_mask(params, PCM_PARAM_ACCESS); |
| 10868 | + if (m) { /* bitmask, refer to SNDRV_PCM_ACCESS_*, generally interleaved */ |
| 10869 | + printf(" Access:\t%#08x\n", m->bits[0]); |
| 10870 | + } |
| 10871 | + m = pcm_params_get_mask(params, PCM_PARAM_FORMAT); |
| 10872 | + if (m) { /* bitmask, refer to: SNDRV_PCM_FORMAT_* */ |
| 10873 | + unsigned j, k, count = 0; |
| 10874 | + const unsigned bitcount = sizeof(m->bits[0]) * 8; |
| 10875 | + |
| 10876 | + /* we only check first two format masks (out of 8) - others are zero. */ |
| 10877 | + printf(" Format[0]:\t%#08x\n", m->bits[0]); |
| 10878 | + printf(" Format[1]:\t%#08x\n", m->bits[1]); |
| 10879 | + |
| 10880 | + /* print friendly format names, if they exist */ |
| 10881 | + for (k = 0; k < 2; ++k) { |
| 10882 | + for (j = 0; j < bitcount; ++j) { |
| 10883 | + const char *name; |
| 10884 | + |
| 10885 | + if (m->bits[k] & (1 << j)) { |
| 10886 | + name = pcm_get_format_name(j + k*bitcount); |
| 10887 | + if (name) { |
| 10888 | + if (count++ == 0) { |
| 10889 | + printf(" Format Name:\t"); |
| 10890 | + } else { |
| 10891 | + printf (", "); |
| 10892 | + } |
| 10893 | + printf("%s", name); |
| 10894 | + } |
| 10895 | + } |
| 10896 | + } |
| 10897 | + } |
| 10898 | + if (count) { |
| 10899 | + printf("\n"); |
| 10900 | + } |
| 10901 | + } |
| 10902 | + m = pcm_params_get_mask(params, PCM_PARAM_SUBFORMAT); |
| 10903 | + if (m) { /* bitmask, should be 1: SNDRV_PCM_SUBFORMAT_STD */ |
| 10904 | + printf(" Subformat:\t%#08x\n", m->bits[0]); |
| 10905 | + } |
| 10906 | + min = pcm_params_get_min(params, PCM_PARAM_RATE); |
| 10907 | + max = pcm_params_get_max(params, PCM_PARAM_RATE); |
| 10908 | + printf(" Rate:\tmin=%uHz\tmax=%uHz\n", min, max); |
| 10909 | + min = pcm_params_get_min(params, PCM_PARAM_CHANNELS); |
| 10910 | + max = pcm_params_get_max(params, PCM_PARAM_CHANNELS); |
| 10911 | + printf(" Channels:\tmin=%u\t\tmax=%u\n", min, max); |
| 10912 | + min = pcm_params_get_min(params, PCM_PARAM_SAMPLE_BITS); |
| 10913 | + max = pcm_params_get_max(params, PCM_PARAM_SAMPLE_BITS); |
| 10914 | + printf(" Sample bits:\tmin=%u\t\tmax=%u\n", min, max); |
| 10915 | + min = pcm_params_get_min(params, PCM_PARAM_PERIOD_SIZE); |
| 10916 | + max = pcm_params_get_max(params, PCM_PARAM_PERIOD_SIZE); |
| 10917 | + printf(" Period size:\tmin=%u\t\tmax=%u\n", min, max); |
| 10918 | + min = pcm_params_get_min(params, PCM_PARAM_PERIODS); |
| 10919 | + max = pcm_params_get_max(params, PCM_PARAM_PERIODS); |
| 10920 | + printf("Period count:\tmin=%u\t\tmax=%u\n", min, max); |
| 10921 | + |
| 10922 | + pcm_params_free(params); |
| 10923 | + } |
| 10924 | + |
| 10925 | + return 0; |
| 10926 | +} |
| 10927 | diff --git a/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinyplay.c b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinyplay.c |
| 10928 | new file mode 100755 |
| 10929 | index 0000000..88c54ae |
| 10930 | --- /dev/null |
| 10931 | +++ b/esdk/layers/meta-zxic/recipes-app/libtinyalsa/files/libtinyalsa/tinyplay.c |
| 10932 | @@ -0,0 +1,272 @@ |
| 10933 | +/* tinyplay.c |
| 10934 | +** |
| 10935 | +** Copyright 2011, The Android Open Source Project |
| 10936 | +** |
| 10937 | +** Redistribution and use in source and binary forms, with or without |
| 10938 | +** modification, are permitted provided that the following conditions are met: |
| 10939 | +** * Redistributions of source code must retain the above copyright |
| 10940 | +** notice, this list of conditions and the following disclaimer. |
| 10941 | +** * Redistributions in binary form must reproduce the above copyright |
| 10942 | +** notice, this list of conditions and the following disclaimer in the |
| 10943 | +** documentation and/or other materials provided with the distribution. |
| 10944 | +** * Neither the name of The Android Open Source Project nor the names of |
| 10945 | +** its contributors may be used to endorse or promote products derived |
| 10946 | +** from this software without specific prior written permission. |
| 10947 | +** |
| 10948 | +** THIS SOFTWARE IS PROVIDED BY The Android Open Source Project ``AS IS'' AND |
| 10949 | +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 10950 | +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 10951 | +** ARE DISCLAIMED. IN NO EVENT SHALL The Android Open Source Project BE LIABLE |
| 10952 | +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 10953 | +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 10954 | +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 10955 | +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 10956 | +** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 10957 | +** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 10958 | +** DAMAGE. |
| 10959 | +*/ |
| 10960 | + |
| 10961 | +#include <tinyalsa/asoundlib.h> |
| 10962 | +#include <stdio.h> |
| 10963 | +#include <stdlib.h> |
| 10964 | +#include <stdint.h> |
| 10965 | +#include <string.h> |
| 10966 | +#include <signal.h> |
| 10967 | + |
| 10968 | +#define ID_RIFF 0x46464952 |
| 10969 | +#define ID_WAVE 0x45564157 |
| 10970 | +#define ID_FMT 0x20746d66 |
| 10971 | +#define ID_DATA 0x61746164 |
| 10972 | + |
| 10973 | +struct riff_wave_header { |
| 10974 | + uint32_t riff_id; |
| 10975 | + uint32_t riff_sz; |
| 10976 | + uint32_t wave_id; |
| 10977 | +}; |
| 10978 | + |
| 10979 | +struct chunk_header { |
| 10980 | + uint32_t id; |
| 10981 | + uint32_t sz; |
| 10982 | +}; |
| 10983 | + |
| 10984 | +struct chunk_fmt { |
| 10985 | + uint16_t audio_format; |
| 10986 | + uint16_t num_channels; |
| 10987 | + uint32_t sample_rate; |
| 10988 | + uint32_t byte_rate; |
| 10989 | + uint16_t block_align; |
| 10990 | + uint16_t bits_per_sample; |
| 10991 | +}; |
| 10992 | + |
| 10993 | +static int close = 0; |
| 10994 | + |
| 10995 | +void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels, |
| 10996 | + unsigned int rate, unsigned int bits, unsigned int period_size, |
| 10997 | + unsigned int period_count); |
| 10998 | + |
| 10999 | +void stream_close(int sig) |
| 11000 | +{ |
| 11001 | + /* allow the stream to be closed gracefully */ |
| 11002 | + signal(sig, SIG_IGN); |
| 11003 | + close = 1; |
| 11004 | +} |
| 11005 | + |
| 11006 | +int main(int argc, char **argv) |
| 11007 | +{ |
| 11008 | + FILE *file; |
| 11009 | + struct riff_wave_header riff_wave_header; |
| 11010 | + struct chunk_header chunk_header; |
| 11011 | + struct chunk_fmt chunk_fmt; |
| 11012 | + unsigned int device = 0; |
| 11013 | + unsigned int card = 0; |
| 11014 | + unsigned int period_size = 1024; |
| 11015 | + unsigned int period_count = 4; |
| 11016 | + char *filename; |
| 11017 | + int more_chunks = 1; |
| 11018 | + |
| 11019 | + if (argc < 2) { |
| 11020 | + fprintf(stderr, "Usage: %s file.wav [-D card] [-d device] [-p period_size]" |
| 11021 | + " [-n n_periods] \n", argv[0]); |
| 11022 | + return 1; |
| 11023 | + } |
| 11024 | + |
| 11025 | + filename = argv[1]; |
| 11026 | + file = fopen(filename, "rb"); |
| 11027 | + if (!file) { |
| 11028 | + fprintf(stderr, "Unable to open file '%s'\n", filename); |
| 11029 | + return 1; |
| 11030 | + } |
| 11031 | + |
| 11032 | + fread(&riff_wave_header, sizeof(riff_wave_header), 1, file); |
| 11033 | + if ((riff_wave_header.riff_id != ID_RIFF) || |
| 11034 | + (riff_wave_header.wave_id != ID_WAVE)) { |
| 11035 | + fprintf(stderr, "Error: '%s' is not a riff/wave file\n", filename); |
| 11036 | + fclose(file); |
| 11037 | + return 1; |
| 11038 | + } |
| 11039 | + |
| 11040 | + do { |
| 11041 | + fread(&chunk_header, sizeof(chunk_header), 1, file); |
| 11042 | + |
| 11043 | + switch (chunk_header.id) { |
| 11044 | + case ID_FMT: |
| 11045 | + fread(&chunk_fmt, sizeof(chunk_fmt), 1, file); |
| 11046 | + /* If the format header is larger, skip the rest */ |
| 11047 | + if (chunk_header.sz > sizeof(chunk_fmt)) |
| 11048 | + fseek(file, chunk_header.sz - sizeof(chunk_fmt), SEEK_CUR); |
| 11049 | + break; |
| 11050 | + case ID_DATA: |
| 11051 | + /* Stop looking for chunks */ |
| 11052 | + more_chunks = 0; |
| 11053 | + break; |
| 11054 | + default: |
| 11055 | + /* Unknown chunk, skip bytes */ |
| 11056 | + fseek(file, chunk_header.sz, SEEK_CUR); |
| 11057 | + } |
| 11058 | + } while (more_chunks); |
| 11059 | + |
| 11060 | + /* parse command line arguments */ |
| 11061 | + argv += 2; |
| 11062 | + while (*argv) { |
| 11063 | + if (strcmp(*argv, "-d") == 0) { |
| 11064 | + argv++; |
| 11065 | + if (*argv) |
| 11066 | + device = atoi(*argv); |
| 11067 | + } |
| 11068 | + if (strcmp(*argv, "-p") == 0) { |
| 11069 | + argv++; |
| 11070 | + if (*argv) |
| 11071 | + period_size = atoi(*argv); |
| 11072 | + } |
| 11073 | + if (strcmp(*argv, "-n") == 0) { |
| 11074 | + argv++; |
| 11075 | + if (*argv) |
| 11076 | + period_count = atoi(*argv); |
| 11077 | + } |
| 11078 | + if (strcmp(*argv, "-D") == 0) { |
| 11079 | + argv++; |
| 11080 | + if (*argv) |
| 11081 | + card = atoi(*argv); |
| 11082 | + } |
| 11083 | + if (*argv) |
| 11084 | + argv++; |
| 11085 | + } |
| 11086 | + |
| 11087 | + play_sample(file, card, device, chunk_fmt.num_channels, chunk_fmt.sample_rate, |
| 11088 | + chunk_fmt.bits_per_sample, period_size, period_count); |
| 11089 | + |
| 11090 | + fclose(file); |
| 11091 | + |
| 11092 | + return 0; |
| 11093 | +} |
| 11094 | + |
| 11095 | +int check_param(struct pcm_params *params, unsigned int param, unsigned int value, |
| 11096 | + char *param_name, char *param_unit) |
| 11097 | +{ |
| 11098 | + unsigned int min; |
| 11099 | + unsigned int max; |
| 11100 | + int is_within_bounds = 1; |
| 11101 | + |
| 11102 | + min = pcm_params_get_min(params, param); |
| 11103 | + if (value < min) { |
| 11104 | + fprintf(stderr, "%s is %u%s, device only supports >= %u%s\n", param_name, value, |
| 11105 | + param_unit, min, param_unit); |
| 11106 | + is_within_bounds = 0; |
| 11107 | + } |
| 11108 | + |
| 11109 | + max = pcm_params_get_max(params, param); |
| 11110 | + if (value > max) { |
| 11111 | + fprintf(stderr, "%s is %u%s, device only supports <= %u%s\n", param_name, value, |
| 11112 | + param_unit, max, param_unit); |
| 11113 | + is_within_bounds = 0; |
| 11114 | + } |
| 11115 | + |
| 11116 | + return is_within_bounds; |
| 11117 | +} |
| 11118 | + |
| 11119 | +int sample_is_playable(unsigned int card, unsigned int device, unsigned int channels, |
| 11120 | + unsigned int rate, unsigned int bits, unsigned int period_size, |
| 11121 | + unsigned int period_count) |
| 11122 | +{ |
| 11123 | + struct pcm_params *params; |
| 11124 | + int can_play; |
| 11125 | + |
| 11126 | + params = pcm_params_get(card, device, PCM_OUT); |
| 11127 | + if (params == NULL) { |
| 11128 | + fprintf(stderr, "Unable to open PCM device %u.\n", device); |
| 11129 | + return 0; |
| 11130 | + } |
| 11131 | + |
| 11132 | + can_play = check_param(params, PCM_PARAM_RATE, rate, "Sample rate", "Hz"); |
| 11133 | + can_play &= check_param(params, PCM_PARAM_CHANNELS, channels, "Sample", " channels"); |
| 11134 | + can_play &= check_param(params, PCM_PARAM_SAMPLE_BITS, bits, "Bitrate", " bits"); |
| 11135 | + can_play &= check_param(params, PCM_PARAM_PERIOD_SIZE, period_size, "Period size", "Hz"); |
| 11136 | + can_play &= check_param(params, PCM_PARAM_PERIODS, period_count, "Period count", "Hz"); |
| 11137 | + |
| 11138 | + pcm_params_free(params); |
| 11139 | + |
| 11140 | + return can_play; |
| 11141 | +} |
| 11142 | + |
| 11143 | +void play_sample(FILE *file, unsigned int card, unsigned int device, unsigned int channels, |
| 11144 | + unsigned int rate, unsigned int bits, unsigned int period_size, |
| 11145 | + unsigned int period_count) |
| 11146 | +{ |
| 11147 | + struct pcm_config config; |
| 11148 | + struct pcm *pcm; |
| 11149 | + char *buffer; |
| 11150 | + int size; |
| 11151 | + int num_read; |
| 11152 | + |
| 11153 | + memset(&config, 0, sizeof(config)); |
| 11154 | + config.channels = channels; |
| 11155 | + config.rate = rate; |
| 11156 | + config.period_size = period_size; |
| 11157 | + config.period_count = period_count; |
| 11158 | + if (bits == 32) |
| 11159 | + config.format = PCM_FORMAT_S32_LE; |
| 11160 | + else if (bits == 16) |
| 11161 | + config.format = PCM_FORMAT_S16_LE; |
| 11162 | + config.start_threshold = 0; |
| 11163 | + config.stop_threshold = 0; |
| 11164 | + config.silence_threshold = 0; |
| 11165 | + |
| 11166 | + if (!sample_is_playable(card, device, channels, rate, bits, period_size, period_count)) { |
| 11167 | + return; |
| 11168 | + } |
| 11169 | + |
| 11170 | + pcm = pcm_open(card, device, PCM_OUT, &config); |
| 11171 | + if (!pcm || !pcm_is_ready(pcm)) { |
| 11172 | + fprintf(stderr, "Unable to open PCM device %u (%s)\n", |
| 11173 | + device, pcm_get_error(pcm)); |
| 11174 | + return; |
| 11175 | + } |
| 11176 | + |
| 11177 | + size = pcm_frames_to_bytes(pcm, pcm_get_buffer_size(pcm)); |
| 11178 | + buffer = malloc(size); |
| 11179 | + if (!buffer) { |
| 11180 | + fprintf(stderr, "Unable to allocate %d bytes\n", size); |
| 11181 | + free(buffer); |
| 11182 | + pcm_close(pcm); |
| 11183 | + return; |
| 11184 | + } |
| 11185 | + |
| 11186 | + printf("Playing sample: %u ch, %u hz, %u bit\n", channels, rate, bits); |
| 11187 | + |
| 11188 | + /* catch ctrl-c to shutdown cleanly */ |
| 11189 | + signal(SIGINT, stream_close); |
| 11190 | + |
| 11191 | + do { |
| 11192 | + num_read = fread(buffer, 1, size, file); |
| 11193 | + if (num_read > 0) { |
| 11194 | + if (pcm_write(pcm, buffer, num_read)) { |
| 11195 | + fprintf(stderr, "Error playing sample\n"); |
| 11196 | + break; |
| 11197 | + } |
| 11198 | + } |
| 11199 | + } while (!close && num_read > 0); |
| 11200 | + |
| 11201 | + free(buffer); |
| 11202 | + pcm_close(pcm); |
| 11203 | +} |
| 11204 | + |
| 11205 | diff --git a/esdk/layers/meta-zxic/recipes-app/libvoice/libvoice.bb b/esdk/layers/meta-zxic/recipes-app/libvoice/libvoice.bb |
| 11206 | index 02b81b9..b413ee2 100755 |
| 11207 | --- a/esdk/layers/meta-zxic/recipes-app/libvoice/libvoice.bb |
| 11208 | +++ b/esdk/layers/meta-zxic/recipes-app/libvoice/libvoice.bb |
| 11209 | @@ -16,6 +16,8 @@ |
| 11210 | #å¼ç¨å
¬ç¨å¤´æä»¶åç¼è¯é项ã |
| 11211 | include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc
|
| 11212 | CFLAGS_append = "-I ${BSPDIR}/zxic_code/zxic_source/zxic_app_open/platform/libtinyalsa/include"
|
| 11213 | +CFLAGS_append = "-I ${BSPDIR}/zxic_code/zxic_source/linux-5.10/include/linux"
|
| 11214 | +
|
| 11215 | |
| 11216 | CFLAGS_append += "${@bb.utils.contains("CONFIG_VB_TRANSMIT_INTF", "RTP", "-I ${BSPDIR}/zxic_code/zxic_source/zxic_app/librtp/include", "", d)}"
|
| 11217 | DEPENDS += "${@bb.utils.contains('CONFIG_VB_TRANSMIT_INTF', 'RTP', 'librtp', '', d)}"
|
| 11218 | diff --git a/esdk/layers/meta-zxic/recipes-app/sntp/sntp.bb b/esdk/layers/meta-zxic/recipes-app/sntp/sntp.bb |
| 11219 | index 21f207e..dd579d3 100755 |
| 11220 | --- a/esdk/layers/meta-zxic/recipes-app/sntp/sntp.bb |
| 11221 | +++ b/esdk/layers/meta-zxic/recipes-app/sntp/sntp.bb |
| 11222 | @@ -1,6 +1,6 @@ |
| 11223 | DESCRIPTION = "sntp" |
| 11224 | #sntpä¾èµlibnvramåº |
| 11225 | -DEPENDS = "libnvram libsoftap libsofttimer" |
| 11226 | +DEPENDS = "libdebug-info libnvram libsoftap libsofttimer" |
| 11227 | SECTION = "app" |
| 11228 | LICENSE = "zte" |
| 11229 | PV = "1.0.0" |
| 11230 | @@ -26,7 +26,8 @@ |
| 11231 | |
| 11232 | #å¼ç¨å
¬ç¨å¤´æä»¶åç¼è¯é项ã |
| 11233 | include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc |
| 11234 | - |
| 11235 | +include ${BSPDIR}/sources/meta-zxic/conf/pub.inc |
| 11236 | +CFLAGS_append += "${ZXIC_EXTRA_CFLAGS}" |
| 11237 | #ç¼è¯ |
| 11238 | do_compile() { |
| 11239 | make -C sntp |
| 11240 | @@ -49,7 +50,7 @@ |
| 11241 | if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then |
| 11242 | install -Dm 0755 ${WORKDIR}/sntp.sysvinit ${D}${sysconfdir}/init.d/sntp |
| 11243 | install -d ${D}${sysconfdir}/rcS.d |
| 11244 | - #ln -s ../init.d/sntp ${D}${sysconfdir}/rcS.d/S22sntp |
| 11245 | + ln -s ../init.d/sntp ${D}${sysconfdir}/rcS.d/S22sntp |
| 11246 | fi |
| 11247 | |
| 11248 | #install elfs |
| 11249 | @@ -72,4 +73,4 @@ |
| 11250 | SYSTEMD_SERVICE_${PN} = "sntp.service" |
| 11251 | SYSTEMD_AUTO_ENABLE_${PN} = "enable" |
| 11252 | |
| 11253 | -RDEPENDS_${PN} = " libnvram libsoftap libsofttimer" |
| 11254 | +RDEPENDS_${PN} = " libdebug-info libnvram libsoftap libsofttimer" |
| 11255 | \ No newline at end of file |
| 11256 | diff --git a/esdk/layers/meta-zxic/recipes-app/softap-demo/softap-demo.bb b/esdk/layers/meta-zxic/recipes-app/softap-demo/softap-demo.bb |
| 11257 | index b519bca..67b62d6 100755 |
| 11258 | --- a/esdk/layers/meta-zxic/recipes-app/softap-demo/softap-demo.bb |
| 11259 | +++ b/esdk/layers/meta-zxic/recipes-app/softap-demo/softap-demo.bb |
| 11260 | @@ -1,5 +1,5 @@ |
| 11261 | DESCRIPTION = "softap_demo" |
| 11262 | -DEPENDS = "libsoftap libatutils libsofttimer libnvram" |
| 11263 | +DEPENDS = "libsoftap libatutils libsofttimer libnvram libatreg" |
| 11264 | SECTION = "app" |
| 11265 | LICENSE = "zte" |
| 11266 | PV = "1.0.0" |
| 11267 | @@ -61,4 +61,4 @@ |
| 11268 | SYSTEMD_SERVICE_${PN} = "softap_demo.service" |
| 11269 | SYSTEMD_AUTO_ENABLE_${PN} = "disable" |
| 11270 | |
| 11271 | -RDEPENDS_${PN} = " libsoftap libatutils libsofttimer libnvram" |
| 11272 | +RDEPENDS_${PN} = " libsoftap libatutils libsofttimer libnvram libatreg" |
| 11273 | diff --git a/esdk/layers/meta-zxic/recipes-app/vb-demo/vb-demo.bb b/esdk/layers/meta-zxic/recipes-app/vb-demo/vb-demo.bb |
| 11274 | new file mode 100755 |
| 11275 | index 0000000..68f2fd2 |
| 11276 | --- /dev/null |
| 11277 | +++ b/esdk/layers/meta-zxic/recipes-app/vb-demo/vb-demo.bb |
| 11278 | @@ -0,0 +1,64 @@ |
| 11279 | +DESCRIPTION = "vb_demo" |
| 11280 | +DEPENDS = "libvoice" |
| 11281 | +SECTION = "app" |
| 11282 | +LICENSE = "zte" |
| 11283 | +PV = "1.0.0" |
| 11284 | +PR = "r0" |
| 11285 | + |
| 11286 | +CLASS_COM = " \ |
| 11287 | + ${@bb.utils.contains('DISTRO_FEATURES', 'procd', 'openwrt openwrt-services', '', d)} \ |
| 11288 | + ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)} \ |
| 11289 | +" |
| 11290 | +inherit ${CLASS_COM} |
| 11291 | + |
| 11292 | +#é
ç½®codeè·¯å¾ä¿¡æ¯ã |
| 11293 | +FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}:" |
| 11294 | +SRC_URI = " \ |
| 11295 | + file://test/vb_demo \ |
| 11296 | + ${@bb.utils.contains("DISTRO_FEATURES", "procd", "file://vb_demo.init","", d)} \ |
| 11297 | + ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "file://vb_demo.service","", d)} \ |
| 11298 | + " |
| 11299 | +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/zte;md5=c075689d1d1e06d4ab5bbe53623a6808" |
| 11300 | +S = "${WORKDIR}" |
| 11301 | +S_SRC_PATH = "${S}/test/vb_demo" |
| 11302 | +#å¼ç¨å
¬ç¨å¤´æä»¶åç¼è¯é项ã |
| 11303 | +include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc |
| 11304 | + |
| 11305 | +#inherit autotools pkgconfig systemd |
| 11306 | + |
| 11307 | +do_compile() { |
| 11308 | + make -C ${S_SRC_PATH} |
| 11309 | +} |
| 11310 | + |
| 11311 | +do_install () { |
| 11312 | + install -d ${D}${bindir}/ |
| 11313 | + install -m 0755 ${S_SRC_PATH}/vb_demo ${D}${bindir}/ |
| 11314 | + |
| 11315 | + if ${@bb.utils.contains('DISTRO_FEATURES','procd','true','false',d)}; then |
| 11316 | + install -Dm 0755 ${WORKDIR}/vb_demo.init ${D}${sysconfdir}/init.d/vb_demo |
| 11317 | + fi |
| 11318 | + |
| 11319 | + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then |
| 11320 | + install -d ${D}${systemd_unitdir}/system |
| 11321 | + install -m 0644 ${WORKDIR}/vb_demo.service ${D}${systemd_unitdir}/system |
| 11322 | + fi |
| 11323 | + |
| 11324 | + #install elfs |
| 11325 | + install -d ${ELFS-PATH}/ |
| 11326 | + install -m 0755 ${S_SRC_PATH}/vb_demo ${ELFS-PATH}/ |
| 11327 | +} |
| 11328 | + |
| 11329 | +do_cleanlibs () { |
| 11330 | + rm -fr ${ELFS-PATH}/vb_demo |
| 11331 | +} |
| 11332 | + |
| 11333 | +addtask cleanlibs after do_clean before do_cleansstate |
| 11334 | + |
| 11335 | +FILES_${PN} = "\ |
| 11336 | + ${bindir}/ \ |
| 11337 | + ${@bb.utils.contains("DISTRO_FEATURES", "procd", "${sysconfdir}/init.d/vb_demo","", d)} \ |
| 11338 | + " |
| 11339 | +SYSTEMD_SERVICE_${PN} = "vb_demo.service" |
| 11340 | +SYSTEMD_AUTO_ENABLE_${PN} = "disable" |
| 11341 | + |
| 11342 | +RDEPENDS_${PN} = " libvoice" |
| 11343 | diff --git a/esdk/layers/meta-zxic/recipes-app/vb-demo/vb-demo/vb_demo.init b/esdk/layers/meta-zxic/recipes-app/vb-demo/vb-demo/vb_demo.init |
| 11344 | new file mode 100755 |
| 11345 | index 0000000..e05899f |
| 11346 | --- /dev/null |
| 11347 | +++ b/esdk/layers/meta-zxic/recipes-app/vb-demo/vb-demo/vb_demo.init |
| 11348 | @@ -0,0 +1,21 @@ |
| 11349 | +#!/bin/sh /etc/rc.common |
| 11350 | + |
| 11351 | +START=18 |
| 11352 | +STOP=85 |
| 11353 | +USE_PROCD=1 |
| 11354 | + |
| 11355 | +logger -t vb_demo |
| 11356 | + |
| 11357 | +start_service() { |
| 11358 | + procd_open_instance |
| 11359 | + procd_set_param command /usr/bin/vb_demo |
| 11360 | + procd_set_param stdout 1 # forward stdout of the command to logd |
| 11361 | + procd_set_param stderr 1 # same for stderr |
| 11362 | + procd_set_param respawn |
| 11363 | + procd_close_instance |
| 11364 | +} |
| 11365 | + |
| 11366 | +stop_service() |
| 11367 | +{ |
| 11368 | + echo "add clean code" |
| 11369 | +} |
| 11370 | diff --git a/esdk/layers/meta-zxic/recipes-app/vb-demo/vb-demo/vb_demo.service b/esdk/layers/meta-zxic/recipes-app/vb-demo/vb-demo/vb_demo.service |
| 11371 | new file mode 100755 |
| 11372 | index 0000000..d519809 |
| 11373 | --- /dev/null |
| 11374 | +++ b/esdk/layers/meta-zxic/recipes-app/vb-demo/vb-demo/vb_demo.service |
| 11375 | @@ -0,0 +1,11 @@ |
| 11376 | +[Unit] |
| 11377 | +Description=The vb_demo service |
| 11378 | + |
| 11379 | +[Service] |
| 11380 | +Type=simple |
| 11381 | +ExecStart=/usr/bin/vb_demo |
| 11382 | +Restart=always |
| 11383 | + |
| 11384 | +[Install] |
| 11385 | +WantedBy=basic.target |
| 11386 | + |
| 11387 | diff --git a/esdk/layers/meta-zxic/recipes-app/wifi-demo/wifi-demo.bb b/esdk/layers/meta-zxic/recipes-app/wifi-demo/wifi-demo.bb |
| 11388 | index 5565218..574baff 100755 |
| 11389 | --- a/esdk/layers/meta-zxic/recipes-app/wifi-demo/wifi-demo.bb |
| 11390 | +++ b/esdk/layers/meta-zxic/recipes-app/wifi-demo/wifi-demo.bb |
| 11391 | @@ -32,16 +32,19 @@ |
| 11392 | install -d ${D}${bindir}/ |
| 11393 | install -m 0755 ${S}/wifi_demo/wifi_demo ${D}${bindir}/ |
| 11394 | install -m 0755 ${S}/wifi_demo/apsta_demo ${D}${bindir}/ |
| 11395 | + install -m 0755 ${S}/wifi_demo/wifi_testmode_demo ${D}${bindir}/ |
| 11396 | |
| 11397 | #install elfs |
| 11398 | install -d ${ELFS-PATH}/ |
| 11399 | install -m 0755 ${S}/wifi_demo/wifi_demo ${ELFS-PATH}/ |
| 11400 | install -m 0755 ${S}/wifi_demo/apsta_demo ${ELFS-PATH}/ |
| 11401 | + install -m 0755 ${S}/wifi_demo/wifi_testmode_demo ${ELFS-PATH}/ |
| 11402 | } |
| 11403 | |
| 11404 | do_cleanlibs () { |
| 11405 | rm -fr ${ELFS-PATH}/wifi_demo |
| 11406 | rm -fr ${ELFS-PATH}/apsta_demo |
| 11407 | + rm -fr ${ELFS-PATH}/wifi_testmode_demo |
| 11408 | } |
| 11409 | |
| 11410 | addtask cleanlibs after do_clean before do_cleansstate |
| 11411 | diff --git a/esdk/layers/meta-zxic/recipes-app/zxic-debug/zxic-debug.bb b/esdk/layers/meta-zxic/recipes-app/zxic-debug/zxic-debug.bb |
| 11412 | index c7f87d1..61650fa 100755 |
| 11413 | --- a/esdk/layers/meta-zxic/recipes-app/zxic-debug/zxic-debug.bb |
| 11414 | +++ b/esdk/layers/meta-zxic/recipes-app/zxic-debug/zxic-debug.bb |
| 11415 | @@ -16,6 +16,8 @@ |
| 11416 | FILESEXTRAPATHS_prepend :="${APP-OPEN-PATH}/platform:" |
| 11417 | SRC_URI = " \ |
| 11418 | file://zxic_debug \ |
| 11419 | + ${@bb.utils.contains("DISTRO_FEATURES", "procd", "file://zxic_debug.init","", d)} \ |
| 11420 | + ${@bb.utils.contains("DISTRO_FEATURES", "systemd", "file://zxic_debug.service","", d)} \ |
| 11421 | ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "file://zxic_debug.sysvinit","", d)} \ |
| 11422 | " |
| 11423 | |
| 11424 | @@ -37,10 +39,20 @@ |
| 11425 | install -d ${D}${bindir}/ |
| 11426 | install -m 0755 ${S}/zxic_debug/zxic_debug ${D}${bindir}/ |
| 11427 | |
| 11428 | + if ${@bb.utils.contains('DISTRO_FEATURES','procd','true','false',d)}; then |
| 11429 | + install -Dm 0755 ${WORKDIR}/zxic_debug.init ${D}${sysconfdir}/init.d/zxic_debug |
| 11430 | + fi |
| 11431 | + |
| 11432 | + if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then |
| 11433 | + install -d ${D}${systemd_unitdir}/system |
| 11434 | + install -m 0644 ${WORKDIR}/zxic_debug.service ${D}${systemd_unitdir}/system |
| 11435 | + fi |
| 11436 | + |
| 11437 | if ${@bb.utils.contains('DISTRO_FEATURES','sysvinit','true','false',d)}; then |
| 11438 | install -Dm 0755 ${WORKDIR}/zxic_debug.sysvinit ${D}${sysconfdir}/init.d/zxic_debug |
| 11439 | install -d ${D}${sysconfdir}/rcS.d |
| 11440 | ln -s ../init.d/zxic_debug ${D}${sysconfdir}/rcS.d/S90zxic_debug |
| 11441 | + ln -s ../init.d/zxic_debug ${D}${sysconfdir}/rcS.d/K10zxic_debug |
| 11442 | fi |
| 11443 | |
| 11444 | #install elfs |
| 11445 | @@ -57,5 +69,11 @@ |
| 11446 | #rootfså
å«çæä»¶ |
| 11447 | FILES_${PN} = "\ |
| 11448 | ${bindir}/ \ |
| 11449 | - ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "${sysconfdir}/","", d)} \ |
| 11450 | + ${@bb.utils.contains("DISTRO_FEATURES", "procd", "${sysconfdir}/","", d)} \ |
| 11451 | + ${@bb.utils.contains("DISTRO_FEATURES", "sysvinit", "${sysconfdir}/","", d)} \ |
| 11452 | " |
| 11453 | +SYSTEMD_SERVICE_${PN} = "zxic_debug.service" |
| 11454 | +SYSTEMD_AUTO_ENABLE_${PN} = "enable" |
| 11455 | + |
| 11456 | + |
| 11457 | + |
| 11458 | diff --git a/esdk/layers/meta-zxic/recipes-app/zxic-debug/zxic-debug/zxic_debug.service b/esdk/layers/meta-zxic/recipes-app/zxic-debug/zxic-debug/zxic_debug.service |
| 11459 | new file mode 100755 |
| 11460 | index 0000000..8dcc30b |
| 11461 | --- /dev/null |
| 11462 | +++ b/esdk/layers/meta-zxic/recipes-app/zxic-debug/zxic-debug/zxic_debug.service |
| 11463 | @@ -0,0 +1,11 @@ |
| 11464 | +[Unit] |
| 11465 | +Description=The zxic_debug service |
| 11466 | + |
| 11467 | +[Service] |
| 11468 | +Type=simple |
| 11469 | +ExecStart=/usr/bin/zxic_debug |
| 11470 | +Restart=always |
| 11471 | + |
| 11472 | +[Install] |
| 11473 | +WantedBy=basic.target |
| 11474 | + |
| 11475 | diff --git a/esdk/layers/meta-zxic/recipes-app/zxic-mainctrl/zxic-mainctrl.bb b/esdk/layers/meta-zxic/recipes-app/zxic-mainctrl/zxic-mainctrl.bb |
| 11476 | index dba5672..772f149 100755 |
| 11477 | --- a/esdk/layers/meta-zxic/recipes-app/zxic-mainctrl/zxic-mainctrl.bb |
| 11478 | +++ b/esdk/layers/meta-zxic/recipes-app/zxic-mainctrl/zxic-mainctrl.bb |
| 11479 | @@ -1,5 +1,5 @@ |
| 11480 | DESCRIPTION = "zxic_mainctrl" |
| 11481 | -DEPENDS = "libnvram libsofttimer libatutils libsoftap openssl libscipc libupi-ab" |
| 11482 | +DEPENDS = "libdebug-info libnvram libsofttimer libatutils libsoftap openssl libscipc libupi-ab" |
| 11483 | SECTION = "app" |
| 11484 | LICENSE = "zte" |
| 11485 | PV = "1.0.0" |
| 11486 | @@ -24,6 +24,8 @@ |
| 11487 | S_SRC_PATH = "${S}/zxic_mainctrl" |
| 11488 | #å¼ç¨å
¬ç¨å¤´æä»¶åç¼è¯é项ã |
| 11489 | include ${BSPDIR}/sources/meta-zxic/conf/app_com.inc |
| 11490 | +include ${BSPDIR}/sources/meta-zxic/conf/pub.inc |
| 11491 | +CFLAGS_append += "${ZXIC_EXTRA_CFLAGS}" |
| 11492 | |
| 11493 | #inherit autotools pkgconfig systemd |
| 11494 | |
| 11495 | @@ -74,4 +76,4 @@ |
| 11496 | SYSTEMD_SERVICE_${PN} = "zxic_mainctrl.service" |
| 11497 | SYSTEMD_AUTO_ENABLE_${PN} = "enable" |
| 11498 | |
| 11499 | -RDEPENDS_${PN} = " libnvram libsofttimer libatutils libsoftap openssl libscipc libupi-ab" |
| 11500 | +RDEPENDS_${PN} = " libdebug-info libnvram libsofttimer libatutils libsoftap openssl libscipc libupi-ab" |
| 11501 | diff --git a/esdk/layers/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/700-dhcpd-fix.patch b/esdk/layers/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/700-dhcpd-fix.patch |
| 11502 | new file mode 100755 |
| 11503 | index 0000000..2fff667 |
| 11504 | --- /dev/null |
| 11505 | +++ b/esdk/layers/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/700-dhcpd-fix.patch |
| 11506 | @@ -0,0 +1,80 @@ |
| 11507 | +--- a/networking/udhcp/dhcpd.c 2024-08-30 18:24:03.164366400 +0800 |
| 11508 | ++++ b/networking/udhcp/dhcpd.c 2024-08-30 09:21:19.122234100 +0800 |
| 11509 | +@@ -407,12 +407,16 @@ struct config_keyword { |
| 11510 | + }; |
| 11511 | + |
| 11512 | + #define OFS(field) offsetof(struct server_data_t, field) |
| 11513 | +- |
| 11514 | ++static char nv_start[16]; |
| 11515 | ++static char nv_end[16]; |
| 11516 | ++static char nv_if[16]; |
| 11517 | ++static char nv_lease_file[32]; |
| 11518 | ++static char nv_pidfile[24]; |
| 11519 | + static const struct config_keyword keywords[] ALIGN_PTR = { |
| 11520 | + /* keyword handler variable address default */ |
| 11521 | +- {"start" , udhcp_str2nip , OFS(start_ip ), "192.168.0.20"}, |
| 11522 | +- {"end" , udhcp_str2nip , OFS(end_ip ), "192.168.0.254"}, |
| 11523 | +- {"interface" , read_str , OFS(interface ), "eth0"}, |
| 11524 | ++ {"start" , udhcp_str2nip , OFS(start_ip ), nv_start}, |
| 11525 | ++ {"end" , udhcp_str2nip , OFS(end_ip ), nv_end}, |
| 11526 | ++ {"interface" , read_str , OFS(interface ), nv_if}, |
| 11527 | + /* Avoid "max_leases value not sane" warning by setting default |
| 11528 | + * to default_end_ip - default_start_ip + 1: */ |
| 11529 | + {"max_leases" , read_u32 , OFS(max_leases ), "235"}, |
| 11530 | +@@ -421,8 +425,8 @@ static const struct config_keyword keywo |
| 11531 | + {"conflict_time", read_u32 , OFS(conflict_time), "3600"}, |
| 11532 | + {"offer_time" , read_u32 , OFS(offer_time ), "60"}, |
| 11533 | + {"min_lease" , read_u32 , OFS(min_lease_sec), "60"}, |
| 11534 | +- {"lease_file" , read_str , OFS(lease_file ), LEASES_FILE}, |
| 11535 | +- {"pidfile" , read_str , OFS(pidfile ), PID_FILE_PATH "/udhcpd.pid"}, |
| 11536 | ++ {"lease_file" , read_str , OFS(lease_file ), nv_lease_file}, |
| 11537 | ++ {"pidfile" , read_str , OFS(pidfile ), nv_pidfile}, |
| 11538 | + {"siaddr" , udhcp_str2nip , OFS(siaddr_nip ), "0.0.0.0"}, |
| 11539 | + /* keywords with no defaults must be last! */ |
| 11540 | + {"option" , read_optset , OFS(options ), ""}, |
| 11541 | +@@ -433,13 +437,44 @@ static const struct config_keyword keywo |
| 11542 | + {"static_lease" , read_staticlease, OFS(static_leases), ""}, |
| 11543 | + }; |
| 11544 | + enum { KWS_WITH_DEFAULTS = ARRAY_SIZE(keywords) - 6 }; |
| 11545 | +- |
| 11546 | ++int execute_cmd(const char *cmd, char *out_data, int out_len); |
| 11547 | + static NOINLINE void read_config(const char *file) |
| 11548 | + { |
| 11549 | + parser_t *parser; |
| 11550 | + const struct config_keyword *k; |
| 11551 | + unsigned i; |
| 11552 | + char *token[2]; |
| 11553 | ++ |
| 11554 | ++ char value[8] = {0};; |
| 11555 | ++ char path[16] = {0};; |
| 11556 | ++ if(execute_cmd("nv get gw_in_cap", value, sizeof(value)) == 0 |
| 11557 | ++ && execute_cmd("nv get path_conf", path, sizeof(path)) == 0){ |
| 11558 | ++ char option[32] = {0}; |
| 11559 | ++ char nm[16] = {0}; |
| 11560 | ++ char gw[16] = {0}; |
| 11561 | ++ char dns[16] = {0}; |
| 11562 | ++ |
| 11563 | ++ execute_cmd("nv get dhcpStart", nv_start, sizeof(nv_start)); |
| 11564 | ++ execute_cmd("nv get dhcpEnd", nv_end, sizeof(nv_end)); |
| 11565 | ++ execute_cmd("nv get lan_netmask", nm, sizeof(nm)); |
| 11566 | ++ if(strcmp(value, "1") == 0){ |
| 11567 | ++ execute_cmd("nv get lan_name_cap", nv_if, sizeof(nv_if)); |
| 11568 | ++ execute_cmd("nv get lan_ipaddr_cap", gw, sizeof(gw)); |
| 11569 | ++ execute_cmd("nv get dhcpDns_cap", dns, sizeof(dns)); |
| 11570 | ++ }else{ |
| 11571 | ++ execute_cmd("nv get lan_name", nv_if, sizeof(nv_if)); |
| 11572 | ++ execute_cmd("nv get lan_ipaddr", gw, sizeof(gw)); |
| 11573 | ++ execute_cmd("nv get dhcpDns", dns, sizeof(dns)); |
| 11574 | ++ } |
| 11575 | ++ snprintf(nv_lease_file, sizeof(nv_lease_file),"%s/udhcpd.leases",path); |
| 11576 | ++ snprintf(nv_pidfile, sizeof(nv_pidfile),"%s/udhcpd.pid",path); |
| 11577 | ++ snprintf(option, sizeof(option),"subnet %s",nm); |
| 11578 | ++ read_optset(option, (char*)&server_data + OFS(options)); |
| 11579 | ++ snprintf(option, sizeof(option),"router %s",gw); |
| 11580 | ++ read_optset(option, (char*)&server_data + OFS(options)); |
| 11581 | ++ snprintf(option, sizeof(option),"dns %s",dns); |
| 11582 | ++ read_optset(option, (char*)&server_data + OFS(options)); |
| 11583 | ++ } |
| 11584 | + |
| 11585 | + for (i = 0; i < KWS_WITH_DEFAULTS; i++) |
| 11586 | + keywords[i].handler(keywords[i].def, (char*)&server_data + keywords[i].ofs); |
| 11587 | diff --git a/esdk/layers/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb b/esdk/layers/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb |
| 11588 | index a0e8bef..a5a5bf4 100755 |
| 11589 | --- a/esdk/layers/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb |
| 11590 | +++ b/esdk/layers/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb |
| 11591 | @@ -50,6 +50,7 @@ |
| 11592 | file://busybox-1.33.1/0001-mktemp-add-tmpdir-option.patch \ |
| 11593 | file://busybox-1.33.1/600-dhcpd-fix.patch \ |
| 11594 | file://busybox-1.33.1/0100-zxic-tty-disable-soft-flow-control.patch \ |
| 11595 | + file://busybox-1.33.1/700-dhcpd-fix.patch \ |
| 11596 | " |
| 11597 | |
| 11598 | SRC_URI += "file://busybox-1.33.1/010-syslogd-recive-remote-log.patch" |
| 11599 | @@ -57,7 +58,7 @@ |
| 11600 | #SRC_URI += "file://busybox-1.33.1/022-syslogd-replace-remote-log-facility.patch" |
| 11601 | SRC_URI += "file://busybox-1.33.1/0100-zxic-add-sync-after-chmod.patch" |
| 11602 | SRC_URI += "file://busybox-1.33.1/0101-zxic-bb_get_chunk_from_file-limit-10MB.patch" |
| 11603 | -#SRC_URI += "file://busybox-1.33.1/0102-zxic-ash-read-etc-profile.patch" |
| 11604 | +SRC_URI += "file://busybox-1.33.1/0102-zxic-ash-read-etc-profile.patch" |
| 11605 | SRC_URI += "file://busybox-1.33.1/0103-top-short-lived-processes-optimize.patch" |
| 11606 | SRC_URI += "file://busybox-1.33.1/0103-syslogd-data-encryption.patch" |
| 11607 | |
| 11608 | diff --git a/esdk/layers/meta-zxic/recipes-core/glibc/files/0002-fix-y2038-time_t-unsigned-long.patch b/esdk/layers/meta-zxic/recipes-core/glibc/files/0002-fix-y2038-time_t-unsigned-long.patch |
| 11609 | new file mode 100755 |
| 11610 | index 0000000..bc67008 |
| 11611 | --- /dev/null |
| 11612 | +++ b/esdk/layers/meta-zxic/recipes-core/glibc/files/0002-fix-y2038-time_t-unsigned-long.patch |
| 11613 | @@ -0,0 +1,48 @@ |
| 11614 | +diff -ruN a/bits/typesizes.h b/bits/typesizes.h |
| 11615 | +--- a/bits/typesizes.h 2024-05-13 15:49:06.279310297 +0800 |
| 11616 | ++++ b/bits/typesizes.h 2024-06-24 19:10:05.732039157 +0800 |
| 11617 | +@@ -47,7 +47,7 @@ |
| 11618 | + #define __FSWORD_T_TYPE __SWORD_TYPE |
| 11619 | + #define __ID_T_TYPE __U32_TYPE |
| 11620 | + #define __CLOCK_T_TYPE __SLONGWORD_TYPE |
| 11621 | +-#define __TIME_T_TYPE __SLONGWORD_TYPE |
| 11622 | ++#define __TIME_T_TYPE __ULONGWORD_TYPE |
| 11623 | + #define __USECONDS_T_TYPE __U32_TYPE |
| 11624 | + #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE |
| 11625 | + #define __DADDR_T_TYPE __S32_TYPE |
| 11626 | +diff -ruN a/sysdeps/unix/sysv/linux/adjtime.c b/sysdeps/unix/sysv/linux/adjtime.c |
| 11627 | +--- a/sysdeps/unix/sysv/linux/adjtime.c 2024-05-13 15:49:08.415312000 +0800 |
| 11628 | ++++ b/sysdeps/unix/sysv/linux/adjtime.c 2024-06-26 16:25:56.512216926 +0800 |
| 11629 | +@@ -33,16 +33,17 @@ |
| 11630 | + struct timeval tmp; |
| 11631 | + |
| 11632 | + /* We will do some check here. */ |
| 11633 | +- tmp.tv_sec = itv->tv_sec + itv->tv_usec / 1000000L; |
| 11634 | ++ tmp.tv_sec = (signed long)itv->tv_sec + itv->tv_usec / 1000000L; |
| 11635 | + tmp.tv_usec = itv->tv_usec % 1000000L; |
| 11636 | +- if (tmp.tv_sec > MAX_SEC || tmp.tv_sec < MIN_SEC) |
| 11637 | ++ if ((signed long)tmp.tv_sec > (signed long)MAX_SEC || (signed long)tmp.tv_sec < (signed long)MIN_SEC) |
| 11638 | + return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL); |
| 11639 | +- tntx.offset = tmp.tv_usec + tmp.tv_sec * 1000000L; |
| 11640 | ++ tntx.offset = tmp.tv_usec + (signed long)tmp.tv_sec * 1000000L; |
| 11641 | + tntx.modes = ADJ_OFFSET_SINGLESHOT; |
| 11642 | + } |
| 11643 | + else |
| 11644 | + tntx.modes = ADJ_OFFSET_SS_READ; |
| 11645 | + |
| 11646 | ++ |
| 11647 | + if (__glibc_unlikely (__adjtimex (&tntx) < 0)) |
| 11648 | + return -1; |
| 11649 | + |
| 11650 | +diff -ruN a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h |
| 11651 | +--- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h 2024-05-13 15:49:08.427312010 +0800 |
| 11652 | ++++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h 2024-06-24 19:10:56.580110887 +0800 |
| 11653 | +@@ -48,7 +48,7 @@ |
| 11654 | + #define __FSWORD_T_TYPE __SWORD_TYPE |
| 11655 | + #define __ID_T_TYPE __U32_TYPE |
| 11656 | + #define __CLOCK_T_TYPE __SLONGWORD_TYPE |
| 11657 | +-#define __TIME_T_TYPE __SLONGWORD_TYPE |
| 11658 | ++#define __TIME_T_TYPE __ULONGWORD_TYPE |
| 11659 | + #define __USECONDS_T_TYPE __U32_TYPE |
| 11660 | + #define __SUSECONDS_T_TYPE __SLONGWORD_TYPE |
| 11661 | + #define __DADDR_T_TYPE __S32_TYPE |
| 11662 | diff --git a/esdk/layers/meta-zxic/recipes-core/glibc/glibc_%.bbappend b/esdk/layers/meta-zxic/recipes-core/glibc/glibc_%.bbappend |
| 11663 | index 0314602..1ea730c 100755 |
| 11664 | --- a/esdk/layers/meta-zxic/recipes-core/glibc/glibc_%.bbappend |
| 11665 | +++ b/esdk/layers/meta-zxic/recipes-core/glibc/glibc_%.bbappend |
| 11666 | @@ -3,6 +3,7 @@ |
| 11667 | |
| 11668 | SRC_URI += " \ |
| 11669 | file://0001-write-log-to-zcat-tool.patch \ |
| 11670 | + file://0002-fix-y2038-time_t-unsigned-long.patch \ |
| 11671 | " |
| 11672 | |
| 11673 | do_install_append() { |
| 11674 | diff --git a/esdk/layers/meta-zxic/recipes-devtools/python/python3/0001-zxic-y2038-time_t.patch b/esdk/layers/meta-zxic/recipes-devtools/python/python3/0001-zxic-y2038-time_t.patch |
| 11675 | new file mode 100755 |
| 11676 | index 0000000..6740344 |
| 11677 | --- /dev/null |
| 11678 | +++ b/esdk/layers/meta-zxic/recipes-devtools/python/python3/0001-zxic-y2038-time_t.patch |
| 11679 | @@ -0,0 +1,35 @@ |
| 11680 | +From 0a7fc505937e81c1ff9ce19f4a0084d4f7040cf3 Mon Sep 17 00:00:00 2001 |
| 11681 | +From: =?utf-8?q?=E5=91=A8=E5=9B=BD=E5=9D=A10318000136?= |
| 11682 | + <zhou.guopo@sanechips.com.cn> |
| 11683 | +Date: Mon, 9 Sep 2024 16:02:36 +0800 |
| 11684 | +Subject: [PATCH] zxic y2038 time_t |
| 11685 | + |
| 11686 | +--- |
| 11687 | + Modules/timemodule.c | 4 ++-- |
| 11688 | + 1 file changed, 2 insertions(+), 2 deletions(-) |
| 11689 | + |
| 11690 | +diff --git a/Modules/timemodule.c b/Modules/timemodule.c |
| 11691 | +index 096911d..b34bf54 100644 |
| 11692 | +--- a/Modules/timemodule.c |
| 11693 | ++++ b/Modules/timemodule.c |
| 11694 | +@@ -1556,7 +1556,7 @@ get_zone(char *zone, int n, struct tm *p) |
| 11695 | + #endif |
| 11696 | + } |
| 11697 | + |
| 11698 | +-static time_t |
| 11699 | ++static long |
| 11700 | + get_gmtoff(time_t t, struct tm *p) |
| 11701 | + { |
| 11702 | + #ifdef HAVE_STRUCT_TM_TM_ZONE |
| 11703 | +@@ -1630,7 +1630,7 @@ init_timezone(PyObject *m) |
| 11704 | + static const time_t YEAR = (365 * 24 + 6) * 3600; |
| 11705 | + time_t t; |
| 11706 | + struct tm p; |
| 11707 | +- time_t janzone_t, julyzone_t; |
| 11708 | ++ long janzone_t, julyzone_t; |
| 11709 | + char janname[10], julyname[10]; |
| 11710 | + t = (time((time_t *)0) / YEAR) * YEAR; |
| 11711 | + _PyTime_localtime(t, &p); |
| 11712 | +-- |
| 11713 | +2.17.1 |
| 11714 | + |
| 11715 | diff --git a/esdk/layers/meta-zxic/recipes-devtools/python/python3_3.8.%.bbappend b/esdk/layers/meta-zxic/recipes-devtools/python/python3_3.8.%.bbappend |
| 11716 | new file mode 100755 |
| 11717 | index 0000000..8c97d91 |
| 11718 | --- /dev/null |
| 11719 | +++ b/esdk/layers/meta-zxic/recipes-devtools/python/python3_3.8.%.bbappend |
| 11720 | @@ -0,0 +1,5 @@ |
| 11721 | + |
| 11722 | +FILESEXTRAPATHS_prepend := "${THISDIR}/python3:" |
| 11723 | + |
| 11724 | +SRC_URI += "file://0001-zxic-y2038-time_t.patch" |
| 11725 | + |
| 11726 | diff --git a/esdk/layers/meta-zxic/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-add-zxic-volte_drv.h.patch b/esdk/layers/meta-zxic/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-add-zxic-volte_drv.h.patch |
| 11727 | index 96ec3d0..af2471f 100755 |
| 11728 | --- a/esdk/layers/meta-zxic/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-add-zxic-volte_drv.h.patch |
| 11729 | +++ b/esdk/layers/meta-zxic/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-add-zxic-volte_drv.h.patch |
| 11730 | @@ -1,20 +1,19 @@ |
| 11731 | -From b1b616e6daa86e3000de9eb74b54290ad47b8b4e Mon Sep 17 00:00:00 2001 |
| 11732 | -From: =?utf-8?q?=E5=91=A8=E5=9B=BD=E5=9D=A1=2010053386?= |
| 11733 | - <zhou.guopo@zte.com.cn> |
| 11734 | -Date: Mon, 13 Mar 2023 15:43:40 +0800 |
| 11735 | -Subject: [PATCH] add zxic volte_drv.h |
| 11736 | +From 8f9f5fc32b4cdb448aaf62e1fb56dfb63af570fd Mon Sep 17 00:00:00 2001 |
| 11737 | +From: =?UTF-8?q?=E5=BE=90=E6=96=B0=E5=BC=BA?= <xu.xinqiang@sanechips.com.cn> |
| 11738 | +Date: Fri, 23 Aug 2024 13:42:50 +0800 |
| 11739 | +Subject: [PATCH] volte drv |
| 11740 | |
| 11741 | --- |
| 11742 | - include/uapi/linux/volte_drv.h | 112 +++++++++++++++++++++++++++++++++ |
| 11743 | - 1 file changed, 112 insertions(+) |
| 11744 | - create mode 100644 include/uapi/linux/volte_drv.h |
| 11745 | + include/uapi/linux/volte_drv.h | 154 +++++++++++++++++++++++++++++++++ |
| 11746 | + 1 file changed, 154 insertions(+) |
| 11747 | + create mode 100755 include/uapi/linux/volte_drv.h |
| 11748 | |
| 11749 | diff --git a/include/uapi/linux/volte_drv.h b/include/uapi/linux/volte_drv.h |
| 11750 | -new file mode 100644 |
| 11751 | -index 0000000..010d9ac |
| 11752 | +new file mode 100755 |
| 11753 | +index 0000000..7862449 |
| 11754 | --- /dev/null |
| 11755 | +++ b/include/uapi/linux/volte_drv.h |
| 11756 | -@@ -0,0 +1,112 @@ |
| 11757 | +@@ -0,0 +1,154 @@ |
| 11758 | +/* |
| 11759 | + * Copyright (C) 2013 ZTE, China |
| 11760 | + * |
| 11761 | @@ -26,6 +25,9 @@ |
| 11762 | +#define __LINUX_VOLTE_DRV_H |
| 11763 | + |
| 11764 | +#include <linux/ioctl.h> |
| 11765 | ++#include <linux/types.h> |
| 11766 | ++ |
| 11767 | ++ |
| 11768 | + |
| 11769 | +typedef enum { |
| 11770 | + VOICE_GSM_MODE = 0, |
| 11771 | @@ -76,6 +78,13 @@ |
| 11772 | +} T_Codec_Path; |
| 11773 | + |
| 11774 | +typedef enum { |
| 11775 | ++ NOR_VOICE_INF_MODE = 0,//normal |
| 11776 | ++ VB_VOICE_INF_MODE,//voice buffer |
| 11777 | ++ MAX_VOICE_INF_MODE |
| 11778 | ++} T_VoiceInfMode; |
| 11779 | ++ |
| 11780 | ++ |
| 11781 | ++typedef enum { |
| 11782 | + VOICE_STOP = 0, |
| 11783 | + VOICE_START, |
| 11784 | + MAX_VOICE_STATE |
| 11785 | @@ -90,6 +99,15 @@ |
| 11786 | + |
| 11787 | +} T_Voice_Para; |
| 11788 | + |
| 11789 | ++typedef struct { |
| 11790 | ++ uint32_t fs; //8000;16000 |
| 11791 | ++ uint32_t enable; //// 0 disable;1 enable |
| 11792 | ++ uint32_t type;//0 single core;1 mult core |
| 11793 | ++ |
| 11794 | ++ |
| 11795 | ++} T_VoiceBuf_Para; |
| 11796 | ++ |
| 11797 | ++ |
| 11798 | +#ifdef __KERNEL__ |
| 11799 | +struct voice_dev { |
| 11800 | + T_Voice_Para param; |
| 11801 | @@ -102,6 +120,29 @@ |
| 11802 | +#define VOICE_IOCTL_GET_SLIC_USE_FLAG _IOR ('v', 12, int) |
| 11803 | +#define VOICE_IOCTL_VPLOOP _IOW('v', 13, int) |
| 11804 | + |
| 11805 | ++#define VOICE_IOCTL_SET_VOL _IOW('v', 14, int) |
| 11806 | ++#define VOICE_IOCTL_GET_VOL _IOR('v', 15, int) |
| 11807 | ++ |
| 11808 | ++#define VOICE_IOCTL_SET_MUTE _IOW('v', 16, bool) |
| 11809 | ++#define VOICE_IOCTL_GET_MUTE _IOR('v', 17, bool) |
| 11810 | ++ |
| 11811 | ++#define VOICE_IOCTL_SET_PATH _IOW('v', 18, int) |
| 11812 | ++#define VOICE_IOCTL_GET_PATH _IOR('v', 19, int) |
| 11813 | ++ |
| 11814 | ++#define VOICE_IOCTL_GET_FS _IOR('v', 20, int) |
| 11815 | ++#define VOICE_IOCTL_SET_VOICE_NVRW _IOW('v', 21, int) |
| 11816 | ++ |
| 11817 | ++#define VOICE_IOCTL_SET_VP _IOW('v', 22, int) |
| 11818 | ++#define VOICE_IOCTL_GET_VP _IOR('v', 23, int) |
| 11819 | ++ |
| 11820 | ++#define VOICE_IOCTL_SET_VBUF _IOW('v', 24, T_VoiceBuf_Para) |
| 11821 | ++#define VOICE_IOCTL_GET_VBUF _IOR('v', 25, T_VoiceBuf_Para) |
| 11822 | ++ |
| 11823 | ++#define VOICE_IOCTL_SET_INF_MODE _IOW('v', 26, int) |
| 11824 | ++#define VOICE_IOCTL_GET_INF_MODE _IOR('v', 27, int) |
| 11825 | ++ |
| 11826 | ++ |
| 11827 | ++ |
| 11828 | +#ifdef __KERNEL__ |
| 11829 | +#define print_audio(fmt, ...) \ |
| 11830 | + printk(fmt, ##__VA_ARGS__) |
| 11831 | @@ -128,5 +169,5 @@ |
| 11832 | +#endif |
| 11833 | + |
| 11834 | -- |
| 11835 | -2.17.1 |
| 11836 | +2.25.1 |
| 11837 | |
| 11838 | diff --git a/esdk/layers/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig b/esdk/layers/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig |
| 11839 | index ef22244..9baa954 100755 |
| 11840 | --- a/esdk/layers/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig |
| 11841 | +++ b/esdk/layers/meta-zxic/recipes-kernel/linux/files/zx297520v3/linux-5_10-vehicle_dc_ref-normal-defconfig |
| 11842 | @@ -156,7 +156,9 @@ |
| 11843 | CONFIG_SIGNALFD=y |
| 11844 | CONFIG_TIMERFD=y |
| 11845 | CONFIG_EVENTFD=y |
| 11846 | -# CONFIG_SHMEM is not set |
| 11847 | +#l.yang modify for mount to limit size |
| 11848 | +CONFIG_SHMEM=y |
| 11849 | +#l.yang modify for mount to limit size |
| 11850 | CONFIG_AIO=y |
| 11851 | CONFIG_IO_URING=y |
| 11852 | CONFIG_ADVISE_SYSCALLS=y |
| 11853 | @@ -2232,12 +2234,12 @@ |
| 11854 | # end of Microsoft Hyper-V guest support |
| 11855 | |
| 11856 | # CONFIG_GREYBUS is not set |
| 11857 | -# CONFIG_STAGING is not set |
| 11858 | -# |
| 11859 | +CONFIG_STAGING=y |
| 11860 | +# CONFIG_VOICE_DRV is not set |
| 11861 | # ZX297520 voice buffer driver |
| 11862 | # |
| 11863 | -# CONFIG_VOICE_BUFFER_DRV is not set |
| 11864 | -# CONFIG_VBUFF_IN_MULTI_CORE is not set |
| 11865 | +CONFIG_VOICE_BUFFER_DRV=y |
| 11866 | +CONFIG_VBUFF_IN_MULTI_CORE=y |
| 11867 | # CONFIG_GOLDFISH is not set |
| 11868 | # CONFIG_CHROME_PLATFORMS is not set |
| 11869 | # CONFIG_MELLANOX_PLATFORM is not set |
| 11870 | @@ -2491,6 +2493,12 @@ |
| 11871 | # CONFIG_PROC_CHILDREN is not set |
| 11872 | CONFIG_KERNFS=y |
| 11873 | CONFIG_SYSFS=y |
| 11874 | +#l.yang modify for mount to limit size |
| 11875 | +CONFIG_TMPFS=y |
| 11876 | +CONFIG_TMPFS_POSIX_ACL=y |
| 11877 | +CONFIG_TMPFS_XATTR=y |
| 11878 | +CONFIG_MEMFD_CREATE=y |
| 11879 | +#l.yang modify for mount to limit size |
| 11880 | # CONFIG_CONFIGFS_FS is not set |
| 11881 | # end of Pseudo filesystems |
| 11882 | |
| 11883 | diff --git a/esdk/layers/meta-zxic/recipes-kernel/linux/linux-zxic_5.10.bb b/esdk/layers/meta-zxic/recipes-kernel/linux/linux-zxic_5.10.bb |
| 11884 | index a8c7f65..5b2cc6d 100755 |
| 11885 | --- a/esdk/layers/meta-zxic/recipes-kernel/linux/linux-zxic_5.10.bb |
| 11886 | +++ b/esdk/layers/meta-zxic/recipes-kernel/linux/linux-zxic_5.10.bb |
| 11887 | @@ -12,7 +12,7 @@ |
| 11888 | DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES','dm-verity','zstd-native','',d)}" |
| 11889 | inherit kernel siteinfo |
| 11890 | |
| 11891 | -EXTRA_OEMAKE_append = " LOADADDR=${KERNEL_LOADADDR} EXTRA_CFLAGS='${ZXIC_EXTRA_CFLAGS}' " |
| 11892 | +EXTRA_OEMAKE_append = " LOADADDR=${KERNEL_LOADADDR} EXTRA_CFLAGS='${ZXIC_EXTRA_CFLAGS}' EXTRA_AFLAGS='${ZXIC_EXTRA_CFLAGS}' " |
| 11893 | FILESEXTRAPATHS_prepend :="${TOPDIR}/../upstream:" |
| 11894 | # PR_CONFIG_cpe = "linux-5_10-cpe-${BOOT_CTL}-defconfig" |
| 11895 | # PR_CONFIG_v2x = "linux-5_10-v2x-${BOOT_CTL}-defconfig" |
| 11896 | diff --git a/esdk/layers/meta-zxic/recipes-kernel/linux/linux_bb.diff b/esdk/layers/meta-zxic/recipes-kernel/linux/linux_bb.diff |
| 11897 | index 34dda2f..f2f6434 100755 |
| 11898 | --- a/esdk/layers/meta-zxic/recipes-kernel/linux/linux_bb.diff |
| 11899 | +++ b/esdk/layers/meta-zxic/recipes-kernel/linux/linux_bb.diff |
| 11900 | @@ -16,7 +16,7 @@ |
| 11901 | DEPENDS += "${@bb.utils.contains('DISTRO_FEATURES','dm-verity','zstd-native','',d)}" |
| 11902 | inherit kernel siteinfo |
| 11903 | |
| 11904 | - EXTRA_OEMAKE_append = " LOADADDR=${KERNEL_LOADADDR} EXTRA_CFLAGS='${ZXIC_EXTRA_CFLAGS}' " |
| 11905 | + EXTRA_OEMAKE_append = " LOADADDR=${KERNEL_LOADADDR} EXTRA_CFLAGS='${ZXIC_EXTRA_CFLAGS}' EXTRA_AFLAGS='${ZXIC_EXTRA_CFLAGS}' " |
| 11906 | -FILESEXTRAPATHS_prepend :="${SRC-PATH}:" |
| 11907 | +FILESEXTRAPATHS_prepend :="${TOPDIR}/../upstream:" |
| 11908 | # PR_CONFIG_cpe = "linux-5_10-cpe-${BOOT_CTL}-defconfig" |
| 11909 | diff --git a/upstream/linux-5.10/arch/arm/kernel/svc_s.S b/upstream/linux-5.10/arch/arm/kernel/svc_s.S |
| 11910 | index a52abb7..f249292 100755 |
| 11911 | --- a/upstream/linux-5.10/arch/arm/kernel/svc_s.S |
| 11912 | +++ b/upstream/linux-5.10/arch/arm/kernel/svc_s.S |
| 11913 | @@ -1,9 +1,12 @@ |
| 11914 | |
| 11915 | +#define _USE_VEHICLE_DC |
| 11916 | +#include "ram_base_config_7520v3.h" |
| 11917 | + |
| 11918 | #define GIC_DIST_BASE (0xF2000000) |
| 11919 | #define GIC_RDIST_BASE (0xF2040000) |
| 11920 | |
| 11921 | #define REAL_TXT_ADDR (CONFIG_PHYS_OFFSET + 0x8000) |
| 11922 | -#define DTB_ADDR (CONFIG_DTB_ADDR) |
| 11923 | +#define DTB_ADDR (DDR_BASE_CAP_DTB_ADDR) |
| 11924 | |
| 11925 | secure_init: |
| 11926 | |
| 11927 | diff --git a/upstream/linux-5.10/drivers/dma/sc/zx297520v3_dma.c b/upstream/linux-5.10/drivers/dma/sc/zx297520v3_dma.c |
| 11928 | index 6ef00d8..6eb68fa 100755 |
| 11929 | --- a/upstream/linux-5.10/drivers/dma/sc/zx297520v3_dma.c |
| 11930 | +++ b/upstream/linux-5.10/drivers/dma/sc/zx297520v3_dma.c |
| 11931 | @@ -1090,7 +1090,7 @@ |
| 11932 | /* schedule tasklet on this channel */ |
| 11933 | /* yu.dong@20240617 [T106BUG-641] SPI packet loss issue, increase kernel buffer and read all cached data away, no data loss start */ |
| 11934 | #ifdef _USE_VEHICLE_DC || _USE_VEHICLE_DC_REF |
| 11935 | - if((channel_id == DMA_CH_UART0_RX) || (channel_id == DMA_CH_UART2_RX) || (channel_id == DMA_CH_SSP0_RX)){ |
| 11936 | + if((channel_id == DMA_CH_UART0_RX) || (channel_id == DMA_CH_UART2_RX)||(channel_id == DMA_CH_SSP0_RX)||(channel_id == DMA_CH_SSP1_RX)){ |
| 11937 | if (dmac_ptr->dma_chan[channel_id].desc.callback) |
| 11938 | dmac_ptr->dma_chan[channel_id].desc.callback(dmac_ptr->dma_chan[channel_id].desc.callback_param); |
| 11939 | }else |
| 11940 | diff --git a/upstream/linux-5.10/drivers/misc/zcat/debug_info.c b/upstream/linux-5.10/drivers/misc/zcat/debug_info.c |
| 11941 | index d23e340..52a2146 100755 |
| 11942 | --- a/upstream/linux-5.10/drivers/misc/zcat/debug_info.c |
| 11943 | +++ b/upstream/linux-5.10/drivers/misc/zcat/debug_info.c |
| 11944 | @@ -5,10 +5,7 @@ |
| 11945 | #include <linux/cdev.h> |
| 11946 | #include <linux/semaphore.h> |
| 11947 | #include <linux/timer.h> |
| 11948 | - |
| 11949 | -// #include <linux/fs.h> |
| 11950 | #include <linux/ioport.h> |
| 11951 | -// #include <linux/serial_reg.h> |
| 11952 | #include <linux/poll.h> |
| 11953 | #include <linux/delay.h> |
| 11954 | #include <linux/wait.h> |
| 11955 | @@ -18,88 +15,94 @@ |
| 11956 | #include <linux/types.h> |
| 11957 | #include <linux/device.h> |
| 11958 | #include <linux/miscdevice.h> |
| 11959 | -// #include <linux/spinlock.h> |
| 11960 | #include <linux/list.h> |
| 11961 | #include <linux/slab.h> |
| 11962 | #include <linux/sched.h> |
| 11963 | -// #include <linux/kthread.h> |
| 11964 | #include <asm/io.h> |
| 11965 | - |
| 11966 | #include <linux/vmalloc.h> |
| 11967 | #include <linux/soc/zte/rpmsg.h> |
| 11968 | -// #include <linux/syscalls.h> |
| 11969 | - |
| 11970 | -// #include "debuginfo.h" |
| 11971 | #include "pub_debug_info.h" |
| 11972 | #include "ringbuf.h" |
| 11973 | +#include "ram_config.h" |
| 11974 | +#include "ZspTrace.h" |
| 11975 | +#include <linux/proc_fs.h> |
| 11976 | +#include <asm/barrier.h> |
| 11977 | +#include <asm/cache.h> |
| 11978 | +#include <asm/cacheflush.h> |
| 11979 | +#include <linux/seq_file.h> |
| 11980 | +#include <linux/ktime.h> |
| 11981 | +#include <linux/time.h> |
| 11982 | |
| 11983 | - |
| 11984 | -#if defined(_USE_ZXIC_DEBUG_INFO) && !defined(CONFIG_SYSTEM_RECOVERY) |
| 11985 | +#if defined(_USE_ZXIC_DEBUG_INFO) |
| 11986 | /******************************************************************************* |
| 11987 | * å®å®ä¹ * |
| 11988 | *******************************************************************************/ |
| 11989 | -#define DEBUG_INFO_SHARE_MEM_LEN (0x2000) |
| 11990 | +#define DEBUG_INFO_AP_MEM_LEN (0x2000) |
| 11991 | #define DEBUG_INFO_READABLE_LEN (0x1400) |
| 11992 | -#define DEBUG_INFO_MAX_DATA_LEN (128) |
| 11993 | -#define DEBUG_INFO_MAX_TOTAL_LEN (140) // 8 + 128 + 4 |
| 11994 | #define DEBUG_INFO_READ_TIME_MSECS (10000) |
| 11995 | |
| 11996 | -#define DEBUG_INFO_CHANNEL (9) |
| 11997 | -#define DEBUG_INFO_MSG_CAP_SIZE (2 * 1024) |
| 11998 | - |
| 11999 | #define DEBUG_INFO_OK (0) |
| 12000 | #define DEBUG_INFO_ERROR (-1) |
| 12001 | +#define DEBUG_READ_NOBLOCK (11) |
| 12002 | |
| 12003 | -#define DEBUG_INFO_IOCTL_SET_DISABLE (0x1001) |
| 12004 | +#define DEBUG_INFO_MAX_ID_LEN (16+3) |
| 12005 | +#define DEBUG_INFO_MAX_DATA_LEN (128) |
| 12006 | +#define DEBUG_INFO_MAX_TIME_LEN (0)//(20+3) |
| 12007 | +#define DEBUG_INFO_MAX_DATE_LEN (19+3) |
| 12008 | +#define DEBUG_INFO_MAX_TOTAL_LEN (DEBUG_INFO_MAX_ID_LEN + DEBUG_INFO_MAX_DATA_LEN + DEBUG_INFO_MAX_TIME_LEN) |
| 12009 | + |
| 12010 | +#define DEBUG_INFO_CORE_NUM (2) |
| 12011 | |
| 12012 | /******************************************************************************* |
| 12013 | * ç»æä½å®ä¹ * |
| 12014 | *******************************************************************************/ |
| 12015 | -typedef unsigned int UINT32; |
| 12016 | +typedef unsigned int UINT32; |
| 12017 | typedef unsigned short UINT16; |
| 12018 | -typedef unsigned char UINT8; |
| 12019 | - |
| 12020 | -typedef struct |
| 12021 | -{ |
| 12022 | - UINT16 module_id; // 模åid |
| 12023 | - UINT16 sub_len; // ç¨æ·æ°æ®é¿åº¦ |
| 12024 | - UINT32 time; |
| 12025 | - char sub_data[]; // ç¨æ·æ°æ® |
| 12026 | -} T_SHARED_MEM_DATA; |
| 12027 | - |
| 12028 | -typedef struct |
| 12029 | -{ |
| 12030 | - UINT32 head; // 0x010a0a0a |
| 12031 | - UINT32 total_len; // æ°æ®å
容é¿åº¦ |
| 12032 | - long long time; // time()彿°è·å |
| 12033 | +typedef unsigned char UINT8; |
| 12034 | +typedef unsigned long UINT64; |
| 12035 | +typedef struct{ |
| 12036 | + unsigned int head; /* 0x010a0a0a */ |
| 12037 | + unsigned int datalen[DEBUG_INFO_CORE_NUM]; /* æ°æ®å
容é¿åº¦ */ |
| 12038 | } T_SAVE_FILE_DATA; |
| 12039 | |
| 12040 | /******************************************************************************* |
| 12041 | * å
¨å±åé * |
| 12042 | *******************************************************************************/ |
| 12043 | -volatile T_RINGBUFFER *g_debug_info_buf = NULL; |
| 12044 | static struct semaphore debug_sem; |
| 12045 | -static DEFINE_RAW_SPINLOCK(debugWr_lock); |
| 12046 | static int g_init_flag = 0; |
| 12047 | +UINT32 *g_ps_debug_write_cnt; |
| 12048 | +UINT32 *g_ps_debug_full_cnt; |
| 12049 | +UINT32 g_ps_debug_read_cnt; |
| 12050 | +UINT32 g_ps_debug_read_full_cnt; |
| 12051 | +unsigned long g_debug_read_cnt; |
| 12052 | +unsigned long g_ap_debug_write_cnt; |
| 12053 | +unsigned long g_ap_debug_read_cnt; |
| 12054 | +UINT8 *g_ap_debug_buffer_start; |
| 12055 | +UINT8 *g_ap_debug_buffer_read; |
| 12056 | +UINT8 *g_ap_debug_buffer_write; |
| 12057 | +UINT8 *g_ap_debug_buffer_end; |
| 12058 | +UINT8 *g_ps_debug_buffer_start; |
| 12059 | +UINT8 *g_ps_debug_buffer_end; |
| 12060 | +UINT8 *g_ps_debug_buffer_read; |
| 12061 | +static DEFINE_SPINLOCK(debug_info_lock); |
| 12062 | +static char g_ap_debug_buffer[DEBUG_INFO_AP_MEM_LEN]; |
| 12063 | +unsigned long g_debug_read_state = 0; |
| 12064 | |
| 12065 | /******************************************************************************* |
| 12066 | * å
é¨å½æ°å®ä¹ * |
| 12067 | *******************************************************************************/ |
| 12068 | -static int sc_debug_info_read_to_user(char *buf, unsigned short count); |
| 12069 | -static int sc_debug_info_record_from_user(const char *info, unsigned short count); |
| 12070 | -static int sc_debug_info_write(UINT32 flag, const UINT8 *buf, UINT32 len); |
| 12071 | -static void sc_debug_info_from_ap(void *buf, unsigned int len); |
| 12072 | - |
| 12073 | +static int sc_debug_info_read_to_user(char *buf, size_t count); |
| 12074 | +static int sc_debug_info_record_from_user(const char *info, size_t count); |
| 12075 | +static void sc_debug_info_from_ps(void *buf, unsigned int len); |
| 12076 | static void kernel_timer_timeout(struct timer_list *t); |
| 12077 | static ssize_t debug_info_read(struct file *fp, char __user *buf, size_t count, loff_t *pos); |
| 12078 | static ssize_t debug_info_write(struct file *fp, const char __user *buf, size_t count, loff_t *pos); |
| 12079 | static int debug_info_open(struct inode *ip, struct file *fp); |
| 12080 | static long debug_info_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); |
| 12081 | static int debug_info_release(struct inode *ip, struct file *fp); |
| 12082 | - |
| 12083 | -//åå§åtimer |
| 12084 | +extern u64 cop_time_get_value64(void); |
| 12085 | +extern int seq_write(struct seq_file *seq, const void *data, size_t len); |
| 12086 | static DEFINE_TIMER(timer, kernel_timer_timeout); |
| 12087 | - |
| 12088 | static const struct file_operations debug_info_fops = { |
| 12089 | .owner = THIS_MODULE, |
| 12090 | .read = debug_info_read, |
| 12091 | @@ -114,35 +117,36 @@ |
| 12092 | .name = "debug_info", |
| 12093 | .fops = &debug_info_fops, |
| 12094 | }; |
| 12095 | - |
| 12096 | static void kernel_timer_timeout(struct timer_list *t) |
| 12097 | -{ |
| 12098 | +{ |
| 12099 | if (debug_sem.count == 0) |
| 12100 | - { |
| 12101 | + { |
| 12102 | up(&debug_sem); |
| 12103 | } |
| 12104 | - /* å 为å
æ ¸å®æ¶å¨æ¯ä¸ä¸ªå次ç宿¶å¨,æä»¥å¦ææ³è¦å¤æ¬¡éå¤å®æ¶éè¦å¨å®æ¶å¨ç»å®ç彿°ç»å°¾éæ°è£
è½½æ¶é´,å¹¶å¯å¨å®æ¶ */ |
| 12105 | /* Kernel Timer restart */ |
| 12106 | - mod_timer(&timer, jiffies + msecs_to_jiffies(DEBUG_INFO_READ_TIME_MSECS)); |
| 12107 | + mod_timer(&timer, jiffies + msecs_to_jiffies(DEBUG_INFO_READ_TIME_MSECS)); |
| 12108 | } |
| 12109 | |
| 12110 | +/* Started by AICoder, pid:y6ffbg9a06ieda114a190b4cb0ff4417bd78c0f4 */ |
| 12111 | static ssize_t debug_info_read(struct file *fp, char __user *buf, size_t count, loff_t *pos) |
| 12112 | { |
| 12113 | int ret; |
| 12114 | int rd_len; |
| 12115 | |
| 12116 | - ret = down_interruptible(&debug_sem); |
| 12117 | - if(ret < 0) |
| 12118 | + if (g_debug_read_state != DEBUG_READ_NOBLOCK) |
| 12119 | { |
| 12120 | - return ret; |
| 12121 | + ret = down_interruptible(&debug_sem); |
| 12122 | + if (ret < 0) |
| 12123 | + { |
| 12124 | + return ret; |
| 12125 | + } |
| 12126 | } |
| 12127 | - else |
| 12128 | - { |
| 12129 | - rd_len = sc_debug_info_read_to_user(buf, count); |
| 12130 | - } |
| 12131 | + |
| 12132 | + rd_len = sc_debug_info_read_to_user(buf, count); |
| 12133 | |
| 12134 | return rd_len; |
| 12135 | } |
| 12136 | +/* Ended by AICoder, pid:y6ffbg9a06ieda114a190b4cb0ff4417bd78c0f4 */ |
| 12137 | |
| 12138 | static ssize_t debug_info_write(struct file *fp, const char __user *buf, size_t count, loff_t *pos) |
| 12139 | { |
| 12140 | @@ -156,241 +160,425 @@ |
| 12141 | return 0; |
| 12142 | } |
| 12143 | |
| 12144 | -static long debug_info_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) |
| 12145 | -{ |
| 12146 | - switch(cmd) |
| 12147 | - { |
| 12148 | - case DEBUG_INFO_IOCTL_SET_DISABLE: |
| 12149 | - *(volatile UINT32 *)ZCAT_DEBUG_INFO_DISABLE = arg; |
| 12150 | - break; |
| 12151 | - |
| 12152 | - default: |
| 12153 | - break; |
| 12154 | +/* Started by AICoder, pid:u635ed463ce5ab2145a109c3c0f54d149e6386b3 */ |
| 12155 | +static long debug_info_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) { |
| 12156 | + if (cmd == DEBUG_READ_NOBLOCK) { |
| 12157 | + g_debug_read_state = DEBUG_READ_NOBLOCK; |
| 12158 | + } else { |
| 12159 | + // 妿å½ä»¤ä¸å¹é
ï¼è¿åé误ç |
| 12160 | + return -EINVAL; |
| 12161 | } |
| 12162 | + |
| 12163 | + // è®°å½è°è¯ä¿¡æ¯ |
| 12164 | + sc_debug_info_record("debug_info", "read noblock!\n"); |
| 12165 | + |
| 12166 | return 0; |
| 12167 | } |
| 12168 | +/* Ended by AICoder, pid:u635ed463ce5ab2145a109c3c0f54d149e6386b3 */ |
| 12169 | |
| 12170 | static int debug_info_release(struct inode *ip, struct file *fp) |
| 12171 | { |
| 12172 | return 0; |
| 12173 | } |
| 12174 | |
| 12175 | -static void sc_debug_info_from_ap(void *buf, unsigned int len) |
| 12176 | +static int ap_log_proc_show(struct seq_file *m, void *v) |
| 12177 | { |
| 12178 | - T_SHARED_MEM_DATA *debug_msg = (T_SHARED_MEM_DATA *)buf; |
| 12179 | - debug_msg->time = jiffies; |
| 12180 | + unsigned long writecnt = g_ap_debug_write_cnt; |
| 12181 | |
| 12182 | - sc_debug_info_write(ZCAT_MEM_TYPE_KERNEL, buf, len); |
| 12183 | + if (writecnt > DEBUG_INFO_AP_MEM_LEN) |
| 12184 | + { |
| 12185 | + writecnt = DEBUG_INFO_AP_MEM_LEN; |
| 12186 | + } |
| 12187 | + |
| 12188 | + seq_write(m, g_ap_debug_buffer_start, writecnt); |
| 12189 | + |
| 12190 | + return 0; |
| 12191 | +} |
| 12192 | + |
| 12193 | +static int ps_log_proc_show(struct seq_file *m, void *v) |
| 12194 | +{ |
| 12195 | + unsigned long writecnt = 0; |
| 12196 | + unsigned long fulllcnt = 0; |
| 12197 | + |
| 12198 | + writecnt = *(UINT32 *)g_ps_debug_write_cnt; |
| 12199 | + fulllcnt = *(UINT32 *)g_ps_debug_full_cnt; |
| 12200 | + |
| 12201 | + if (fulllcnt > 0) |
| 12202 | + { |
| 12203 | + writecnt = PS_DEBUG_INFO_SIZE; |
| 12204 | + } |
| 12205 | + |
| 12206 | + //__inval_dcache_area((void *)g_ps_debug_buffer_start, writecnt); |
| 12207 | + seq_write(m, g_ps_debug_buffer_start, writecnt); |
| 12208 | + |
| 12209 | + return 0; |
| 12210 | +} |
| 12211 | + |
| 12212 | +UINT32 skip_end_null(char *buf, size_t count) |
| 12213 | +{ |
| 12214 | + UINT32 len = 0; |
| 12215 | + char *tmpbuf = buf; |
| 12216 | + |
| 12217 | + while (count > 0) |
| 12218 | + { |
| 12219 | + if (*tmpbuf == '\0') |
| 12220 | + { |
| 12221 | + ++len; |
| 12222 | + tmpbuf -= 1; |
| 12223 | + count -= 1; |
| 12224 | + } |
| 12225 | + else |
| 12226 | + { |
| 12227 | + break; |
| 12228 | + } |
| 12229 | + } |
| 12230 | + |
| 12231 | + return len; |
| 12232 | +} |
| 12233 | + |
| 12234 | +int sc_debug_info_read_ap(char *buf, size_t count) |
| 12235 | +{ |
| 12236 | + UINT32 readLen = 0; |
| 12237 | + UINT32 updatelen = 0; |
| 12238 | + UINT32 readremainLen = 0; |
| 12239 | + UINT8 *readbuffaddr = 0; |
| 12240 | + UINT32 nullLen = 0; |
| 12241 | + char *tmpbuf = buf; |
| 12242 | + |
| 12243 | + updatelen = g_ap_debug_write_cnt - g_ap_debug_read_cnt; |
| 12244 | + if (updatelen > DEBUG_INFO_AP_MEM_LEN) |
| 12245 | + updatelen = DEBUG_INFO_AP_MEM_LEN; |
| 12246 | + |
| 12247 | + if(g_ap_debug_buffer_end - g_ap_debug_buffer_read >= updatelen) |
| 12248 | + { |
| 12249 | + readbuffaddr = g_ap_debug_buffer_read; |
| 12250 | + readLen = updatelen; |
| 12251 | + if (copy_to_user(tmpbuf , readbuffaddr, readLen)) |
| 12252 | + { |
| 12253 | + return -EFAULT; |
| 12254 | + } |
| 12255 | + g_ap_debug_buffer_read += readLen; |
| 12256 | + } |
| 12257 | + else if(g_ap_debug_buffer_end - g_ap_debug_buffer_read < updatelen) |
| 12258 | + { |
| 12259 | + readbuffaddr = g_ap_debug_buffer_read; |
| 12260 | + readLen = g_ap_debug_buffer_end - readbuffaddr; |
| 12261 | + readremainLen = updatelen - readLen; |
| 12262 | + nullLen = skip_end_null(g_ap_debug_buffer_end - 1, readLen); |
| 12263 | + readLen = readLen - nullLen; |
| 12264 | + if (copy_to_user(tmpbuf, readbuffaddr, readLen)) |
| 12265 | + { |
| 12266 | + return -EFAULT; |
| 12267 | + } |
| 12268 | + if (copy_to_user(tmpbuf + readLen, g_ap_debug_buffer_start, readremainLen)) |
| 12269 | + { |
| 12270 | + return -EFAULT; |
| 12271 | + } |
| 12272 | + g_ap_debug_buffer_read = g_ap_debug_buffer_start + readremainLen; |
| 12273 | + } |
| 12274 | + else |
| 12275 | + { |
| 12276 | + panic("gaohf sc_debug_info_read_to_user error"); |
| 12277 | + } |
| 12278 | + g_ap_debug_read_cnt = g_ap_debug_write_cnt; |
| 12279 | + |
| 12280 | + return (readLen + readremainLen); |
| 12281 | +} |
| 12282 | + |
| 12283 | +int sc_debug_info_read_ps(char *buf, size_t count) |
| 12284 | +{ |
| 12285 | + UINT32 readLen = 0; |
| 12286 | + UINT32 readremainLen = 0; |
| 12287 | + UINT8 *readbuffaddr = 0; |
| 12288 | + UINT32 fulllcnt = 0; |
| 12289 | + UINT32 fulllcntdiff = 0; |
| 12290 | + unsigned long writecnt = 0; |
| 12291 | + UINT32 nullLen = 0; |
| 12292 | + char *tmpbuf = buf; |
| 12293 | + |
| 12294 | + writecnt = *(volatile UINT32 *)g_ps_debug_write_cnt; |
| 12295 | + fulllcnt = *(volatile UINT32 *)g_ps_debug_full_cnt; |
| 12296 | + |
| 12297 | + if (fulllcnt >= g_ps_debug_read_full_cnt) |
| 12298 | + { |
| 12299 | + fulllcntdiff = fulllcnt - g_ps_debug_read_full_cnt; |
| 12300 | + } |
| 12301 | + else |
| 12302 | + { |
| 12303 | + fulllcntdiff = 0xFFFFFFFF - g_ps_debug_read_full_cnt + fulllcnt; |
| 12304 | + } |
| 12305 | + if(fulllcntdiff >= 2) |
| 12306 | + { |
| 12307 | + readbuffaddr = g_ps_debug_buffer_start + writecnt; |
| 12308 | + readLen = g_ps_debug_buffer_end - readbuffaddr; |
| 12309 | + readremainLen = writecnt; |
| 12310 | + nullLen = skip_end_null(g_ps_debug_buffer_end - 1, readLen); |
| 12311 | + readLen = readLen - nullLen; |
| 12312 | + if (copy_to_user(tmpbuf, readbuffaddr, readLen)) |
| 12313 | + { |
| 12314 | + return -EFAULT; |
| 12315 | + } |
| 12316 | + if (copy_to_user(tmpbuf + readLen, g_ps_debug_buffer_start, readremainLen)) |
| 12317 | + { |
| 12318 | + return -EFAULT; |
| 12319 | + } |
| 12320 | + g_ps_debug_buffer_read = g_ps_debug_buffer_start + readremainLen; |
| 12321 | + } |
| 12322 | + else if(fulllcntdiff == 0) |
| 12323 | + { |
| 12324 | + readbuffaddr = g_ps_debug_buffer_read; |
| 12325 | + readLen = writecnt - g_ps_debug_read_cnt;; |
| 12326 | + if (copy_to_user(tmpbuf , readbuffaddr, readLen)) |
| 12327 | + { |
| 12328 | + return -EFAULT; |
| 12329 | + } |
| 12330 | + g_ps_debug_buffer_read += readLen; |
| 12331 | + } |
| 12332 | + else if(fulllcntdiff == 1) |
| 12333 | + { |
| 12334 | + readLen = writecnt >= g_ps_debug_read_cnt ? writecnt : g_ps_debug_read_cnt; |
| 12335 | + readLen = PS_DEBUG_INFO_SIZE - readLen; |
| 12336 | + readbuffaddr = g_ps_debug_buffer_read; |
| 12337 | + nullLen = skip_end_null(g_ps_debug_buffer_end - 1, readLen); |
| 12338 | + readLen = readLen - nullLen; |
| 12339 | + if (copy_to_user(tmpbuf, readbuffaddr, readLen)) |
| 12340 | + { |
| 12341 | + return -EFAULT; |
| 12342 | + } |
| 12343 | + readremainLen = writecnt; |
| 12344 | + if (copy_to_user(tmpbuf + readLen , g_ps_debug_buffer_start, readremainLen)) |
| 12345 | + { |
| 12346 | + return -EFAULT; |
| 12347 | + } |
| 12348 | + g_ps_debug_buffer_read = g_ps_debug_buffer_start + readremainLen; |
| 12349 | + } |
| 12350 | + else |
| 12351 | + { |
| 12352 | + panic("gaohf sc_debug_info_read_to_user error"); |
| 12353 | + } |
| 12354 | + g_ps_debug_read_cnt = writecnt; |
| 12355 | + g_ps_debug_read_full_cnt = fulllcnt; |
| 12356 | + |
| 12357 | + return (readLen + readremainLen); |
| 12358 | +} |
| 12359 | + |
| 12360 | +int sc_debug_info_read_to_user(char *buf, size_t count) |
| 12361 | +{ |
| 12362 | + char *tmpbuf = 0; |
| 12363 | + int ret = 0; |
| 12364 | + int ap_len = 0; |
| 12365 | + int ps_len = 0; |
| 12366 | + T_SAVE_FILE_DATA fileDataHead; |
| 12367 | + |
| 12368 | + if (g_init_flag == 0) |
| 12369 | + { |
| 12370 | + printk("debug_info not init.\n"); |
| 12371 | + return DEBUG_INFO_ERROR; |
| 12372 | + } |
| 12373 | + |
| 12374 | + if (count == 0 || buf == NULL ) |
| 12375 | + { |
| 12376 | + printk("sc_debug_info_read_to_user count == 0 || buf == NULL \n"); |
| 12377 | + return DEBUG_INFO_ERROR; |
| 12378 | + } |
| 12379 | + tmpbuf = buf + sizeof(T_SAVE_FILE_DATA); |
| 12380 | + ap_len = sc_debug_info_read_ap(tmpbuf, DEBUG_INFO_AP_MEM_LEN); |
| 12381 | + tmpbuf += ap_len; |
| 12382 | + ps_len = sc_debug_info_read_ps(tmpbuf, PS_DEBUG_INFO_SIZE); |
| 12383 | + |
| 12384 | + fileDataHead.head = 0x010a0a0a; |
| 12385 | + fileDataHead.datalen[0] = ap_len; |
| 12386 | + fileDataHead.datalen[1] = ps_len; |
| 12387 | + |
| 12388 | + if (copy_to_user(buf, &fileDataHead, sizeof(T_SAVE_FILE_DATA))) |
| 12389 | + { |
| 12390 | + printk("sc_debug_info_read_to_user copy_to_user error \n"); |
| 12391 | + return -EFAULT; |
| 12392 | + } |
| 12393 | + return sizeof(T_SAVE_FILE_DATA) + ap_len + ps_len; |
| 12394 | +} |
| 12395 | + |
| 12396 | +static int sc_debug_info_record_from_user(const char *info, size_t count) |
| 12397 | +{ |
| 12398 | + UINT32 cnt = 0; |
| 12399 | + int spacelen; |
| 12400 | + int msg_len = 0; |
| 12401 | + struct tm tm; |
| 12402 | + time64_t time; |
| 12403 | + unsigned long used_space; |
| 12404 | + char buffer[DEBUG_INFO_MAX_TOTAL_LEN]; |
| 12405 | + unsigned long flags; |
| 12406 | + UINT8 *tmp_write_addr = buffer; |
| 12407 | + |
| 12408 | + if (g_init_flag == 0 || info == NULL) |
| 12409 | + { |
| 12410 | + printk("debug_info not init or sc_debug_info_record_from_user info is NULL\n"); |
| 12411 | + return DEBUG_INFO_ERROR; |
| 12412 | + } |
| 12413 | + |
| 12414 | + if(count > DEBUG_INFO_MAX_DATA_LEN + DEBUG_INFO_MAX_ID_LEN) |
| 12415 | + { |
| 12416 | + printk("debug_info data too long\n"); |
| 12417 | + return DEBUG_INFO_ERROR; |
| 12418 | + } |
| 12419 | + |
| 12420 | + time = ktime_get_real_seconds(); |
| 12421 | + time64_to_tm(time, 0, &tm); |
| 12422 | + cnt = snprintf((char *)tmp_write_addr, DEBUG_INFO_MAX_DATE_LEN, "[%ld-%02d-%02d %d:%02d:%02d]", \ |
| 12423 | + tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); |
| 12424 | + tmp_write_addr += cnt; |
| 12425 | + msg_len = cnt; |
| 12426 | + |
| 12427 | + spin_lock_irqsave(&debug_info_lock, flags); |
| 12428 | + spacelen = g_ap_debug_buffer_end - g_ap_debug_buffer_write; |
| 12429 | + if (spacelen < msg_len + count) |
| 12430 | + { |
| 12431 | + g_ap_debug_write_cnt += spacelen; |
| 12432 | + memset(g_ap_debug_buffer_write, '\0', spacelen); |
| 12433 | + g_ap_debug_buffer_write = g_ap_debug_buffer_start; |
| 12434 | + } |
| 12435 | + memcpy(g_ap_debug_buffer_write, buffer, msg_len); |
| 12436 | + if (copy_from_user(g_ap_debug_buffer_write + msg_len, info, count)) |
| 12437 | + return -EFAULT; |
| 12438 | + msg_len += count; |
| 12439 | + g_ap_debug_buffer_write += msg_len; |
| 12440 | + g_ap_debug_write_cnt += msg_len; |
| 12441 | + used_space = g_ap_debug_write_cnt - g_ap_debug_read_cnt; |
| 12442 | + spin_unlock_irqrestore(&debug_info_lock, flags); |
| 12443 | + if (used_space > DEBUG_INFO_READABLE_LEN) |
| 12444 | + { |
| 12445 | + if (debug_sem.count == 0) |
| 12446 | + { |
| 12447 | + up(&debug_sem); |
| 12448 | + } |
| 12449 | + } |
| 12450 | + return msg_len; |
| 12451 | +} |
| 12452 | + |
| 12453 | +int sc_debug_info_vrecord(char *id, const char *format, va_list args) |
| 12454 | +{ |
| 12455 | + int spacelen; |
| 12456 | + int msg_len = 0; |
| 12457 | + int cnt = 0; |
| 12458 | + unsigned long used_space; |
| 12459 | + struct tm tm; |
| 12460 | + time64_t time; |
| 12461 | + char buffer[DEBUG_INFO_MAX_TOTAL_LEN]; |
| 12462 | + unsigned long flags; |
| 12463 | + UINT8 *tmp_write_addr = buffer; |
| 12464 | + |
| 12465 | + time = ktime_get_real_seconds(); |
| 12466 | + time64_to_tm(time, 0, &tm); |
| 12467 | + cnt = snprintf((char *)tmp_write_addr, DEBUG_INFO_MAX_DATE_LEN, "[%ld-%02d-%02d %d:%02d:%02d]", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); |
| 12468 | + tmp_write_addr += cnt; |
| 12469 | + msg_len = cnt; |
| 12470 | + |
| 12471 | + cnt = snprintf((char *)tmp_write_addr, DEBUG_INFO_MAX_ID_LEN, "[%s]",id); |
| 12472 | + tmp_write_addr += cnt; |
| 12473 | + msg_len += cnt; |
| 12474 | + msg_len += vsnprintf((char *)tmp_write_addr, DEBUG_INFO_MAX_DATA_LEN, format, args); |
| 12475 | + |
| 12476 | + spin_lock_irqsave(&debug_info_lock, flags); |
| 12477 | + spacelen = g_ap_debug_buffer_end - g_ap_debug_buffer_write; |
| 12478 | + if (spacelen < DEBUG_INFO_MAX_TOTAL_LEN) |
| 12479 | + { |
| 12480 | + g_ap_debug_write_cnt += spacelen; |
| 12481 | + memset(g_ap_debug_buffer_write, '\0', spacelen); |
| 12482 | + g_ap_debug_buffer_write = g_ap_debug_buffer_start; |
| 12483 | + } |
| 12484 | + |
| 12485 | + memcpy(g_ap_debug_buffer_write, buffer, msg_len); |
| 12486 | + g_ap_debug_buffer_write += msg_len; |
| 12487 | + g_ap_debug_write_cnt += msg_len; |
| 12488 | + used_space = g_ap_debug_write_cnt - g_ap_debug_read_cnt; |
| 12489 | + spin_unlock_irqrestore(&debug_info_lock, flags); |
| 12490 | + if (used_space > DEBUG_INFO_READABLE_LEN) |
| 12491 | + { |
| 12492 | + if (debug_sem.count == 0) |
| 12493 | + { |
| 12494 | + up(&debug_sem); |
| 12495 | + } |
| 12496 | + } |
| 12497 | + return msg_len; |
| 12498 | +} |
| 12499 | +EXPORT_SYMBOL(sc_debug_info_vrecord); |
| 12500 | + |
| 12501 | +int sc_debug_info_record(char *id, const char *format, ...) |
| 12502 | +{ |
| 12503 | + va_list args; |
| 12504 | + int r; |
| 12505 | + |
| 12506 | + if (g_init_flag == 0) |
| 12507 | + { |
| 12508 | + printk("debug_info not init.\n"); |
| 12509 | + return DEBUG_INFO_ERROR; |
| 12510 | + } |
| 12511 | + |
| 12512 | + va_start(args, format); |
| 12513 | + r = sc_debug_info_vrecord(id, format, args); |
| 12514 | + va_end(args); |
| 12515 | + |
| 12516 | + return r; |
| 12517 | +} |
| 12518 | +EXPORT_SYMBOL(sc_debug_info_record); |
| 12519 | + |
| 12520 | +void early_debug_info_init(void) |
| 12521 | +{ |
| 12522 | + g_ap_debug_buffer_start = g_ap_debug_buffer; |
| 12523 | + g_ap_debug_buffer_write = g_ap_debug_buffer_start; |
| 12524 | + g_ap_debug_buffer_read = g_ap_debug_buffer_start; |
| 12525 | + g_ap_debug_buffer_end = g_ap_debug_buffer + DEBUG_INFO_AP_MEM_LEN; |
| 12526 | + g_ap_debug_read_cnt = 0; |
| 12527 | + g_ap_debug_write_cnt = 0; |
| 12528 | + |
| 12529 | + g_init_flag = 1; |
| 12530 | + printk("cap early_debug_info_init success \n"); |
| 12531 | } |
| 12532 | |
| 12533 | static int __init debug_info_init(void) |
| 12534 | { |
| 12535 | - int ret = misc_register(&debug_info_device); |
| 12536 | + int ret; |
| 12537 | + |
| 12538 | + ret = misc_register(&debug_info_device); |
| 12539 | if (ret) |
| 12540 | { |
| 12541 | - printk("debug_info_device init.\n"); |
| 12542 | + printk("debug_info_init init.\n"); |
| 12543 | return DEBUG_INFO_ERROR; |
| 12544 | } |
| 12545 | |
| 12546 | - void *mem; |
| 12547 | - mem = vmalloc(DEBUG_INFO_SHARE_MEM_LEN); |
| 12548 | - if (!mem) |
| 12549 | - { |
| 12550 | - printk("vmalloc failed.\n"); |
| 12551 | - return DEBUG_INFO_ERROR; |
| 12552 | - } |
| 12553 | - |
| 12554 | - g_debug_info_buf = CreateRingBuffer((UINT8 *)mem, DEBUG_INFO_SHARE_MEM_LEN); |
| 12555 | - if (g_debug_info_buf == NULL) |
| 12556 | - { |
| 12557 | - printk("CreateRingBuffer failed.\n"); |
| 12558 | - return DEBUG_INFO_ERROR; |
| 12559 | - } |
| 12560 | -#if 1 |
| 12561 | - ret = rpmsgCreateChannel( |
| 12562 | - CORE_PS0, |
| 12563 | - DEBUG_INFO_CHANNEL, |
| 12564 | - DEBUG_INFO_MSG_CAP_SIZE); |
| 12565 | - if (ret != DEBUG_INFO_OK) |
| 12566 | - { |
| 12567 | - printk("rpmsgCreateChannel failed, ret = %d\n", ret); |
| 12568 | - return DEBUG_INFO_ERROR; |
| 12569 | - } |
| 12570 | - |
| 12571 | - ret = rpmsgRegCallBack( |
| 12572 | - CORE_PS0, |
| 12573 | - DEBUG_INFO_CHANNEL, |
| 12574 | - sc_debug_info_from_ap); |
| 12575 | - if (ret != DEBUG_INFO_OK) |
| 12576 | - { |
| 12577 | - printk("rpmsgRegCallBack failed,ret = %d\n", ret); |
| 12578 | - return DEBUG_INFO_ERROR; |
| 12579 | - } |
| 12580 | -#endif |
| 12581 | + g_ps_debug_write_cnt = (UINT32 *)ioremap(PS_DEBUG_INFO_LEN_ADDR_PA, PS_DEBUG_INFO_LEN_SIZE); |
| 12582 | + // printf("PS_DEBUG_INFO_LEN_ADDR_PA \n",) |
| 12583 | + g_ps_debug_full_cnt = (UINT32 *)((char *)g_ps_debug_write_cnt + 4); |
| 12584 | + g_ps_debug_buffer_start = (unsigned long)ioremap(PS_DEBUG_INFO_ADDR_PA, PS_DEBUG_INFO_SIZE); |
| 12585 | + g_ps_debug_buffer_read = g_ps_debug_buffer_start; |
| 12586 | + g_ps_debug_buffer_end = g_ps_debug_buffer_start + PS_DEBUG_INFO_SIZE; |
| 12587 | + g_ps_debug_read_cnt = 0; |
| 12588 | + g_ps_debug_read_full_cnt = 0; |
| 12589 | sema_init(&debug_sem, 0); |
| 12590 | - /* æ·»å å¹¶å¯å¨å®æ¶å¨, 10ms */ |
| 12591 | - mod_timer(&timer, jiffies + 1); |
| 12592 | - |
| 12593 | - g_init_flag = 1; |
| 12594 | - |
| 12595 | + proc_create_single("debug_info_cap", 0, NULL, ap_log_proc_show); |
| 12596 | + proc_create_single("debug_info_ap", 0, NULL, ps_log_proc_show); |
| 12597 | + mod_timer(&timer, jiffies + 1); |
| 12598 | + printk("cap debug_info_init success \n"); |
| 12599 | + // g_init_flag = 1; |
| 12600 | return 0; |
| 12601 | } |
| 12602 | |
| 12603 | static void __exit debug_info_exit(void) |
| 12604 | { |
| 12605 | misc_deregister(&debug_info_device); |
| 12606 | - |
| 12607 | del_timer(&timer); |
| 12608 | } |
| 12609 | |
| 12610 | -static int sc_debug_info_write(UINT32 flag, const UINT8 *buf, UINT32 len) |
| 12611 | -{ |
| 12612 | - UINT32 writelen; |
| 12613 | - UINT32 used_space; |
| 12614 | - unsigned long flags; |
| 12615 | - |
| 12616 | - if (len == 0 || g_debug_info_buf == NULL) |
| 12617 | - { |
| 12618 | - printk("sc_debug_info_write:: (len == 0 || g_debug_info_buf == NULL).\n"); |
| 12619 | - return DEBUG_INFO_ERROR; |
| 12620 | - } |
| 12621 | - |
| 12622 | - raw_spin_lock_irqsave(&debugWr_lock, flags); |
| 12623 | - writelen = WriteRingBuffer(g_debug_info_buf, buf, len, flag); |
| 12624 | - raw_spin_unlock_irqrestore(&debugWr_lock, flags); |
| 12625 | - used_space = GetRingBufferSize(g_debug_info_buf); |
| 12626 | - if (used_space > DEBUG_INFO_READABLE_LEN) |
| 12627 | - { |
| 12628 | - if (debug_sem.count == 0) |
| 12629 | - { |
| 12630 | - up(&debug_sem); |
| 12631 | - } |
| 12632 | - } |
| 12633 | - |
| 12634 | - return writelen; |
| 12635 | -} |
| 12636 | - |
| 12637 | -static int sc_debug_info_read_to_user(char *buf, unsigned short count) |
| 12638 | -{ |
| 12639 | - unsigned int bufSize_used = 0; |
| 12640 | - unsigned int readLen = 0; |
| 12641 | - unsigned int bufLen = 0; |
| 12642 | - T_SAVE_FILE_DATA fileDataHead; |
| 12643 | - |
| 12644 | - if (g_init_flag == 0) |
| 12645 | - { |
| 12646 | - printk("debug_info not init.\n"); |
| 12647 | - return DEBUG_INFO_ERROR; |
| 12648 | - } |
| 12649 | - if (count == 0 || buf == NULL || g_debug_info_buf == NULL) |
| 12650 | - { |
| 12651 | - printk("sc_debug_info_read_to_user:: (count == 0 || buf == NULL || g_debug_info_buf == NULL).\n"); |
| 12652 | - return DEBUG_INFO_ERROR; |
| 12653 | - } |
| 12654 | - |
| 12655 | - bufSize_used = GetRingBufferSize(g_debug_info_buf); |
| 12656 | - if (bufSize_used == 0) |
| 12657 | - { |
| 12658 | - // printk("sc_debug_info_read_to_user:: ringBuf is empty.\n"); |
| 12659 | - return 0; |
| 12660 | - } |
| 12661 | - |
| 12662 | - fileDataHead.head = 0x010a0a0a; |
| 12663 | - fileDataHead.time = 0; |
| 12664 | - fileDataHead.total_len = bufSize_used; |
| 12665 | - |
| 12666 | - copy_to_user(buf, &fileDataHead, sizeof(T_SAVE_FILE_DATA)); |
| 12667 | - |
| 12668 | - readLen = ReadRingBuffer(g_debug_info_buf, (buf + sizeof(T_SAVE_FILE_DATA)), bufSize_used, ZCAT_MEM_TYPE_USER); |
| 12669 | - if (readLen == 0) |
| 12670 | - { |
| 12671 | - // printk("ReadRingBuffer failed.\n"); |
| 12672 | - return 0; |
| 12673 | - } |
| 12674 | - |
| 12675 | - return (readLen + sizeof(T_SAVE_FILE_DATA)); |
| 12676 | -} |
| 12677 | - |
| 12678 | -static int sc_debug_info_record_from_user(const char *info, unsigned short count) |
| 12679 | -{ |
| 12680 | - unsigned int cnt = 0; |
| 12681 | - unsigned int my_jiffies = jiffies; |
| 12682 | - |
| 12683 | - if (g_init_flag == 0) |
| 12684 | - { |
| 12685 | - printk("debug_info not init.\n"); |
| 12686 | - return DEBUG_INFO_ERROR; |
| 12687 | - } |
| 12688 | - if (info == NULL) |
| 12689 | - { |
| 12690 | - printk("sc_debug_info_record_from_user:: info is NULL.\n"); |
| 12691 | - return DEBUG_INFO_ERROR; |
| 12692 | - } |
| 12693 | - |
| 12694 | - copy_to_user(info + 4, &my_jiffies, sizeof(my_jiffies)); |
| 12695 | - cnt = sc_debug_info_write(ZCAT_MEM_TYPE_USER, (UINT8 *)info, count); |
| 12696 | - |
| 12697 | - return cnt; |
| 12698 | -} |
| 12699 | - |
| 12700 | module_init(debug_info_init); |
| 12701 | module_exit(debug_info_exit); |
| 12702 | - |
| 12703 | -MODULE_AUTHOR("jcw"); |
| 12704 | MODULE_DESCRIPTION("debug_info driver"); |
| 12705 | MODULE_LICENSE("GPL"); |
| 12706 | |
| 12707 | - |
| 12708 | -int sc_debug_info_vrecord(unsigned int id, const char *format, va_list args) |
| 12709 | -{ |
| 12710 | - int len; |
| 12711 | - UINT32 writelen; |
| 12712 | - // va_list args; |
| 12713 | - char str_buf[DEBUG_INFO_MAX_TOTAL_LEN] __attribute__((aligned(4))); |
| 12714 | - T_SHARED_MEM_DATA *shareMemData = (T_SHARED_MEM_DATA *)str_buf; |
| 12715 | - |
| 12716 | - if (g_init_flag == 0) |
| 12717 | - { |
| 12718 | - printk("debug_info not init.\n"); |
| 12719 | - return DEBUG_INFO_ERROR; |
| 12720 | - } |
| 12721 | - |
| 12722 | - /* argsæ¯ä¸ä¸ªchar*ç±»åæéï¼æåformatä¹åç第ä¸ä¸ªåæ°*/ |
| 12723 | - // va_start(args, format); |
| 12724 | - len = vsnprintf(shareMemData->sub_data, DEBUG_INFO_MAX_DATA_LEN, format, args); |
| 12725 | - // va_end(args); |
| 12726 | - if (len < 0) |
| 12727 | - { |
| 12728 | - printk("vsnprintf format error.\n"); |
| 12729 | - return DEBUG_INFO_ERROR; |
| 12730 | - } |
| 12731 | - |
| 12732 | - shareMemData->module_id = (UINT16)(id & 0xFFFF); |
| 12733 | - shareMemData->sub_len = len; |
| 12734 | - shareMemData->time = jiffies; |
| 12735 | - |
| 12736 | - writelen = sc_debug_info_write(ZCAT_MEM_TYPE_KERNEL, (UINT8 *)shareMemData, len + sizeof(T_SHARED_MEM_DATA)); |
| 12737 | - return writelen; |
| 12738 | -} |
| 12739 | -EXPORT_SYMBOL(sc_debug_info_vrecord); |
| 12740 | - |
| 12741 | -int sc_debug_info_record(unsigned int id, const char *format, ...) |
| 12742 | -{ |
| 12743 | - va_list args; |
| 12744 | - int r; |
| 12745 | - |
| 12746 | - va_start(args, format); |
| 12747 | - r = sc_debug_info_vrecord(id, format, args); |
| 12748 | - va_end(args); |
| 12749 | - |
| 12750 | - |
| 12751 | - return r; |
| 12752 | -} |
| 12753 | -EXPORT_SYMBOL(sc_debug_info_record); |
| 12754 | #else |
| 12755 | -int sc_debug_info_record(unsigned int id, const char *format, ...) |
| 12756 | +int sc_debug_info_record(char *id, const char *format, ...) |
| 12757 | { |
| 12758 | - return 0; |
| 12759 | + return 0; |
| 12760 | } |
| 12761 | #endif /* _USE_ZXIC_DEBUG_INFO */ |
| 12762 | |
| 12763 | + |
| 12764 | diff --git a/upstream/linux-5.10/drivers/mmc/core/mmc_ramdump.c b/upstream/linux-5.10/drivers/mmc/core/mmc_ramdump.c |
| 12765 | index f72860e..be7309c 100755 |
| 12766 | --- a/upstream/linux-5.10/drivers/mmc/core/mmc_ramdump.c |
| 12767 | +++ b/upstream/linux-5.10/drivers/mmc/core/mmc_ramdump.c |
| 12768 | @@ -20,7 +20,7 @@ |
| 12769 | #define MMC1_REG_BASE 0x1211000 |
| 12770 | #define MATRIX_CRM_REG_BASE 0x1306000 |
| 12771 | #define CFG_EMMC_CLK_ENUM 400000 |
| 12772 | -#define CFG_EMMC_CLK_WORK 26000000 |
| 12773 | +#define CFG_EMMC_CLK_WORK 50000000 |
| 12774 | #define CFG_EMMC_CLK_REF 50000000 |
| 12775 | |
| 12776 | #define ZXMCI_FIFO_DEPTH 128 |
| 12777 | diff --git a/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c b/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c |
| 12778 | index 2a8fcc3..c7da7a4 100755 |
| 12779 | --- a/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c |
| 12780 | +++ b/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c |
| 12781 | @@ -8,7 +8,7 @@ |
| 12782 | #include "zvnet_dev.h"
|
| 12783 | #include "ram_config.h"
|
| 12784 | #include <net/netfilter/nf_conntrack.h>
|
| 12785 | -
|
| 12786 | +#include <net/SI/fast_common.h>
|
| 12787 | /*******************************************************************************
|
| 12788 | * Macro definitions *
|
| 12789 | ******************************************************************************/
|
| 12790 | @@ -72,10 +72,8 @@ |
| 12791 | module_param(g_wrap_num, int, 0644);
|
| 12792 | unsigned int g_wrap_timeout = 10;
|
| 12793 | module_param(g_wrap_timeout, int, 0644);
|
| 12794 | -/*jb.qi add for debug network package on 20240806 start*/
|
| 12795 | unsigned int g_trace_limit = 0;
|
| 12796 | module_param(g_trace_limit, int, 0644);
|
| 12797 | -/*jb.qi add for debug network package on 20240806 end*/
|
| 12798 | #endif
|
| 12799 |
|
| 12800 | /*******************************************************************************
|
| 12801 | @@ -85,7 +83,6 @@ |
| 12802 | extern void v7_dma_map_area(const void *, size_t, int);
|
| 12803 | extern void *get_ct_for_ap(struct sk_buff *skb);
|
| 12804 | extern void put_ct_for_ap(void *ct);
|
| 12805 | -extern spinlock_t fast_fw_spinlock;
|
| 12806 | /*******************************************************************************
|
| 12807 | * Local function declarations *
|
| 12808 | ******************************************************************************/
|
| 12809 | @@ -128,38 +125,41 @@ |
| 12810 | return NULL;
|
| 12811 | }
|
| 12812 |
|
| 12813 | +/* Started by AICoder, pid:2fa080381bb2e3d14fbc0aa44091291a60d78e35 */
|
| 12814 | void check_skb_test(struct sk_buff *skb)
|
| 12815 | {
|
| 12816 | - if(skb && vir_addr_ap){
|
| 12817 | - struct sk_buff *tmp_skb;
|
| 12818 | - if((skb->capHead && (virt_to_phys_ap(skb->head) == NULL))
|
| 12819 | - || ((skb->capHead == NULL) && virt_to_phys_ap(skb->head))){
|
| 12820 | - dump_stack();
|
| 12821 | - msleep(1000);
|
| 12822 | - panic("capHead err");
|
| 12823 | - }
|
| 12824 | - skb_queue_walk(&g_zvnet_skb_queue, tmp_skb) {
|
| 12825 | - if(tmp_skb == skb){
|
| 12826 | - dump_stack();
|
| 12827 | - msleep(1000);
|
| 12828 | - panic("dup free");
|
| 12829 | - }
|
| 12830 | - }
|
| 12831 | - }
|
| 12832 | + if (skb && vir_addr_ap) {
|
| 12833 | + struct sk_buff *tmp_skb;
|
| 12834 | + if ((skb->capHead && (virt_to_phys_ap(skb->head) == NULL))
|
| 12835 | + || ((skb->capHead == NULL) && virt_to_phys_ap(skb->head))) {
|
| 12836 | + dump_stack();
|
| 12837 | + panic("capHead err");
|
| 12838 | + }
|
| 12839 | + skb_queue_walk(&g_zvnet_skb_queue, tmp_skb) {
|
| 12840 | + if (tmp_skb == skb) {
|
| 12841 | + dump_stack();
|
| 12842 | + panic("dup free");
|
| 12843 | + }
|
| 12844 | + }
|
| 12845 | + }
|
| 12846 | }
|
| 12847 | -/*jb.qi add for debug network package on 20240806 start*/
|
| 12848 | +/* Ended by AICoder, pid:2fa080381bb2e3d14fbc0aa44091291a60d78e35 */
|
| 12849 | +
|
| 12850 | +/* Started by AICoder, pid:z5702yf8bad07ad1448a083e806dc31250b2418f */
|
| 12851 | void zvnet_dump_packet(unsigned char * data, int len, int limit_len)
|
| 12852 | {
|
| 12853 | int i = 0;
|
| 12854 | -
|
| 12855 | - for(i = 0; i < len && i < limit_len; i=i+16)
|
| 12856 | + unsigned char *p = data;
|
| 12857 | + for(i = 0; i < len && i < limit_len; i+=16)
|
| 12858 | {
|
| 12859 | - printk("0x%04x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",i,
|
| 12860 | - *(data+i),*(data+i+1),*(data+i+2),*(data+i+3),*(data+i+4),*(data+i+5),*(data+i+6),*(data+i+7),
|
| 12861 | - *(data+i+8),*(data+i+9),*(data+i+10),*(data+i+11),*(data+i+12),*(data+i+13),*(data+i+14),*(data+i+15));
|
| 12862 | + printk("0x%04x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",i,
|
| 12863 | + p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],
|
| 12864 | + p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
|
| 12865 | + p += 16;
|
| 12866 | }
|
| 12867 | }
|
| 12868 | -/*jb.qi add for debug network package on 20240806 end*/
|
| 12869 | +/* Ended by AICoder, pid:z5702yf8bad07ad1448a083e806dc31250b2418f */
|
| 12870 | +
|
| 12871 | int zvnet_get_index_by_netdev(struct net_device *net)
|
| 12872 | {
|
| 12873 | int i;
|
| 12874 | @@ -304,13 +304,11 @@ |
| 12875 | /* make sure we initialize shinfo sequentially */
|
| 12876 | skb_reset_network_header(skb);
|
| 12877 | skb_set_kcov_handle(skb, kcov_common_handle());
|
| 12878 | - /*jb.qi add for debug network package on 20240806 start*/
|
| 12879 | if(unlikely(g_trace_limit > 0)){
|
| 12880 | - printk("-%s-dump_packet-start-%d\n", skb->dev->name, skb->len);
|
| 12881 | - zvnet_dump_packet(skb->data, skb->len, g_trace_limit);
|
| 12882 | - printk("-%s-dump_packet-end-\n", skb->dev->name);
|
| 12883 | - }
|
| 12884 | - /*jb.qi add for debug network package on 20240806 end*/
|
| 12885 | + printk("-%s-dump_packet-start-%d\n", skb->dev->name, skb->len);
|
| 12886 | + zvnet_dump_packet(skb->data, skb->len, g_trace_limit);
|
| 12887 | + printk("-%s-dump_packet-end-\n", skb->dev->name);
|
| 12888 | + }
|
| 12889 | return skb;
|
| 12890 | }
|
| 12891 |
|
| 12892 | @@ -321,33 +319,38 @@ |
| 12893 | return 0;
|
| 12894 | }
|
| 12895 |
|
| 12896 | +/* Started by AICoder, pid:b001dtf2551fd53146790a57201be3321cf0a682 */
|
| 12897 | static void skb_debug_test(struct sk_buff *skb)
|
| 12898 | {
|
| 12899 | int i;
|
| 12900 | - int vcount = skb->len/10;
|
| 12901 | - int rcount = skb->len%10;
|
| 12902 | + int vcount = skb->len / 10;
|
| 12903 | + int rcount = skb->len % 10;
|
| 12904 | char tmp[64] = {0};
|
| 12905 | char strbuf[64] = {0};
|
| 12906 | + const unsigned char *data = skb->data;
|
| 12907 |
|
| 12908 | zv_info("\n");
|
| 12909 | - for(i=0; i<vcount; i++) {
|
| 12910 | - zv_info("%d---0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x,0x%x\n",i,skb->data[0+10*i],skb->data[1+10*i],skb->data[2+10*i],
|
| 12911 | - skb->data[3+10*i],skb->data[4+10*i],skb->data[5+10*i],skb->data[6+10*i],skb->data[7+10*i],skb->data[8+10*i],skb->data[9+10*i]);
|
| 12912 | + for (i = 0; i < vcount; i++) {
|
| 12913 | + zv_info("%d---%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x,%02x\n", i,
|
| 12914 | + data[0 + 10 * i], data[1 + 10 * i], data[2 + 10 * i], data[3 + 10 * i],
|
| 12915 | + data[4 + 10 * i], data[5 + 10 * i], data[6 + 10 * i], data[7 + 10 * i],
|
| 12916 | + data[8 + 10 * i], data[9 + 10 * i]);
|
| 12917 | }
|
| 12918 | - if(vcount > 0) {
|
| 12919 | - memset(tmp,0,sizeof(tmp));
|
| 12920 | - memset(strbuf,0,sizeof(strbuf));
|
| 12921 | - sprintf(strbuf,"%d---",vcount);
|
| 12922 | + if (vcount > 0) {
|
| 12923 | + memset(tmp, 0, sizeof(tmp));
|
| 12924 | + sprintf(strbuf, "%d---", vcount);
|
| 12925 | + char *p = strbuf + strlen(strbuf);
|
| 12926 |
|
| 12927 | - for(i=0; i<rcount; i++)
|
| 12928 | - {
|
| 12929 | - sprintf(tmp,"0x%x,",skb->data[10*vcount + i]);
|
| 12930 | - strcat(strbuf,tmp);
|
| 12931 | + for (i = 0; i < rcount; i++) {
|
| 12932 | + sprintf(p, "%02x,", data[10 * vcount + i]);
|
| 12933 | + p += strlen(p);
|
| 12934 | }
|
| 12935 | - zv_info("%s ",strbuf);
|
| 12936 | + *(p - 1) = '\0'; // ÒÆ³ý×îºóÒ»¸ö¶ººÅ
|
| 12937 | + zv_info("%s ", strbuf);
|
| 12938 | }
|
| 12939 | zv_info("\n");
|
| 12940 | }
|
| 12941 | +/* Ended by AICoder, pid:b001dtf2551fd53146790a57201be3321cf0a682 */
|
| 12942 |
|
| 12943 | static int zvnet_open(struct net_device *net)
|
| 12944 | {
|
| 12945 | @@ -473,8 +476,8 @@ |
| 12946 | return NET_XMIT_SUCCESS;
|
| 12947 | }
|
| 12948 |
|
| 12949 | - if(unlikely(skb_headroom(skb) < NET_SKB_PAD || skb->next//|| skb->capHead
|
| 12950 | - || skb->fclone || skb->cloned || (skb_shinfo(skb)->nr_frags) || skb->sk || (skb->indev == NULL)
|
| 12951 | + if(unlikely(skb->next//|| skb->capHead || skb_headroom(skb) < NET_SKB_PAD
|
| 12952 | + || skb->fclone || skb->cloned || (skb_shinfo(skb)->nr_frags) || skb->sk || (skb->indev == NULL)
|
| 12953 | || (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) || (skb_has_frag_list(skb)))){
|
| 12954 | int ret_len = skb->len;
|
| 12955 |
|
| 12956 | @@ -632,6 +635,7 @@ |
| 12957 | .ndo_get_stats = zvnet_get_stats,
|
| 12958 | .ndo_change_mtu = eth_change_mtu,
|
| 12959 | .ndo_validate_addr = eth_validate_addr,
|
| 12960 | + .ndo_set_mac_address = eth_mac_addr,
|
| 12961 | };
|
| 12962 |
|
| 12963 | static void v2xnet_init_netdev(struct net_device *net)
|
| 12964 | @@ -802,30 +806,32 @@ |
| 12965 | {
|
| 12966 | struct sk_buff *skb;
|
| 12967 | #if 0
|
| 12968 | - char skb_data[ZVNET_TMP_BUFF_LEN];
|
| 12969 | - int ret_len = 0;
|
| 12970 | +/* Started by AICoder, pid:sd1cfsbc2eu87c41445f09652039f525fa147687 */
|
| 12971 | +int ret_len = 0;
|
| 12972 | +struct sk_buff *skb;
|
| 12973 |
|
| 12974 | - if(NULL == chninfo || NULL == dev) {
|
| 12975 | - zv_err("zvnet_channel_read null.\n");
|
| 12976 | - return NULL;
|
| 12977 | - }
|
| 12978 | +ret_len = zvnet_channel_read(chninfo, NULL, 0); // »ñÈ¡ÐèÒª¶ÁÈ¡µÄÊý¾Ý³¤¶È
|
| 12979 | +if(ret_len <= 0) {
|
| 12980 | + zv_err("zvnet_channel_read fail.\n");
|
| 12981 | + return NULL;
|
| 12982 | +}
|
| 12983 |
|
| 12984 | - ret_len = zvnet_channel_read(chninfo, (void *)skb_data, sizeof(skb_data));
|
| 12985 | +skb = dev_alloc_skb(ret_len + ZVNET_SKB_PAD);
|
| 12986 | +if (unlikely(!skb)) {
|
| 12987 | + zv_err("netdev_alloc_skb fail,len %d",ret_len);
|
| 12988 | + return NULL;
|
| 12989 | +}
|
| 12990 |
|
| 12991 | - if(ret_len <= 0) {
|
| 12992 | - zv_err("zvnet_channel_read fail.\n");
|
| 12993 | - return NULL;
|
| 12994 | - }
|
| 12995 | +ret_len = zvnet_channel_read(chninfo, skb->data, ret_len); // ¶ÁÈ¡Êý¾Ýµ½skb->data
|
| 12996 | +if(ret_len <= 0) {
|
| 12997 | + kfree_skb(skb); // Èç¹û¶Áȡʧ°Ü£¬ÊÍ·ÅÒÑ·ÖÅäµÄskb
|
| 12998 | + zv_err("zvnet_channel_read fail.\n");
|
| 12999 | + return NULL;
|
| 13000 | +}
|
| 13001 |
|
| 13002 | - skb = dev_alloc_skb(ret_len + ZVNET_SKB_PAD);
|
| 13003 | - if (unlikely(!skb)) {
|
| 13004 | - zv_err("netdev_alloc_skb fail,len %d",ret_len);
|
| 13005 | - return NULL;
|
| 13006 | - }
|
| 13007 | -
|
| 13008 | - skb_put(skb,ret_len);
|
| 13009 | - skb_reserve(skb, ZVNET_SKB_PAD);
|
| 13010 | - memcpy(skb->data, &skb_data[0], ret_len);
|
| 13011 | +skb_put(skb,ret_len);
|
| 13012 | +skb_reserve(skb, ZVNET_SKB_PAD);
|
| 13013 | +/* Ended by AICoder, pid:sd1cfsbc2eu87c41445f09652039f525fa147687 */
|
| 13014 | #else
|
| 13015 | struct T_zvnet_rpmsg buff = {0};
|
| 13016 | int ret_len = 0;
|
| 13017 | @@ -1099,6 +1105,9 @@ |
| 13018 | .flag = 0};
|
| 13019 | int ret_len = 0;
|
| 13020 | struct nf_conn *ct;
|
| 13021 | + fast_entry_t *entry;
|
| 13022 | + struct net_device *in;
|
| 13023 | + struct net_device *out;
|
| 13024 |
|
| 13025 | while(1) {
|
| 13026 | struct T_zvnet_rpmsg_ctstat buff = {0};
|
| 13027 | @@ -1115,33 +1124,104 @@ |
| 13028 | panic("err, ret:%d!!!!!!", ret_len);
|
| 13029 | }
|
| 13030 | ct = (struct nf_conn *)buff.cap_nfct;
|
| 13031 | -
|
| 13032 | WARN_ON(atomic_read(&ct->ct_general.use) == 0);
|
| 13033 | if(buff.flag){
|
| 13034 | + if(!(buff.pkt[0].pkt || buff.pkt[0].len || buff.pkt[1].pkt || buff.pkt[1].len))
|
| 13035 | + continue;
|
| 13036 | BUG_ON(buff.in <= 0 || buff.out <= 0);
|
| 13037 | + in = zvnet_dev[buff.in-1].net;
|
| 13038 | + out = zvnet_dev[buff.out-1].net;
|
| 13039 | if(buff.pkt[0].pkt && buff.pkt[0].len){
|
| 13040 | zv_info("nf_update %x %s %s %d %d", buff.cap_nfct, ct->indev[0]->name, ct->outdev[0]->name, buff.in, buff.out);
|
| 13041 | - zvnet_dev[buff.in-1].net->stats.rx_packets += buff.pkt[0].pkt;
|
| 13042 | - zvnet_dev[buff.in-1].net->stats.rx_bytes += buff.pkt[0].len;
|
| 13043 | - zvnet_dev[buff.out-1].net->stats.tx_packets += buff.pkt[0].pkt;
|
| 13044 | - zvnet_dev[buff.out-1].net->stats.tx_bytes += buff.pkt[0].len;
|
| 13045 | + in->stats.rx_packets += buff.pkt[0].pkt;
|
| 13046 | + in->stats.rx_bytes += buff.pkt[0].len;
|
| 13047 | + out->stats.tx_packets += buff.pkt[0].pkt;
|
| 13048 | + out->stats.tx_bytes += buff.pkt[0].len;
|
| 13049 | }
|
| 13050 | if(buff.pkt[1].pkt && buff.pkt[1].len){
|
| 13051 | zv_info("nf_update %x %s %s %d %d", buff.cap_nfct, ct->indev[1]->name, ct->outdev[1]->name, buff.out, buff.in);
|
| 13052 | - zvnet_dev[buff.out-1].net->stats.rx_packets += buff.pkt[1].pkt;
|
| 13053 | - zvnet_dev[buff.out-1].net->stats.rx_bytes += buff.pkt[1].len;
|
| 13054 | - zvnet_dev[buff.in-1].net->stats.tx_packets += buff.pkt[1].pkt;
|
| 13055 | - zvnet_dev[buff.in-1].net->stats.tx_bytes += buff.pkt[1].len;
|
| 13056 | + out->stats.rx_packets += buff.pkt[1].pkt;
|
| 13057 | + out->stats.rx_bytes += buff.pkt[1].len;
|
| 13058 | + in->stats.tx_packets += buff.pkt[1].pkt;
|
| 13059 | + in->stats.tx_bytes += buff.pkt[1].len;
|
| 13060 | }
|
| 13061 | spin_lock_bh(&fast_fw_spinlock);
|
| 13062 | + /*¸üÐÂÁ´½Ó³¬Ê±*/
|
| 13063 | + if (IPPROTO_TCP == nf_ct_protonum(ct))
|
| 13064 | + {
|
| 13065 | + ct->timeout = jiffies + tcp_timeouts[ct->proto.tcp.state];
|
| 13066 | + }else if (IPPROTO_UDP == nf_ct_protonum(ct)){
|
| 13067 | + /*udp*/
|
| 13068 | + if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)){
|
| 13069 | + ct->timeout = jiffies + fast_udp_timeout_stream;
|
| 13070 | + }else{
|
| 13071 | + ct->timeout = jiffies + fast_udp_timeout;
|
| 13072 | + }
|
| 13073 | + }
|
| 13074 | + entry = (fast_entry_t *)ct->fast_entry;
|
| 13075 | + if(entry){
|
| 13076 | + WARN_ON(entry->ct != ct);
|
| 13077 | + mod_timer(&entry->timeout, ct->timeout);
|
| 13078 | + }
|
| 13079 | ct->packet_info[IP_CT_DIR_ORIGINAL].bytes += buff.pkt[IP_CT_DIR_ORIGINAL].len;
|
| 13080 | ct->packet_info[IP_CT_DIR_ORIGINAL].packets += buff.pkt[IP_CT_DIR_ORIGINAL].pkt;
|
| 13081 | ct->packet_info[IP_CT_DIR_REPLY].bytes += buff.pkt[IP_CT_DIR_REPLY].len;
|
| 13082 | ct->packet_info[IP_CT_DIR_REPLY].packets += buff.pkt[IP_CT_DIR_REPLY].pkt;
|
| 13083 | + if(ct->indev[0] && is_vlan_dev(ct->indev[0])){
|
| 13084 | + struct net_device *tmp = vlan_dev_real_dev(ct->indev[0]);
|
| 13085 | + struct vlan_pcpu_stats *stats = this_cpu_ptr(vlan_dev_priv(ct->indev[0])->vlan_pcpu_stats);
|
| 13086 | +
|
| 13087 | + if(tmp == in){
|
| 13088 | +/* Started by AICoder, pid:tbef0151bf4135d1479d0a5d108c870bc756e858 */
|
| 13089 | +u64_stats_update_begin(&stats->syncp);
|
| 13090 | +stats->rx_packets += buff.pkt[0].pkt;
|
| 13091 | +stats->rx_bytes += buff.pkt[0].len;
|
| 13092 | +stats->tx_packets += buff.pkt[1].pkt;
|
| 13093 | +stats->tx_bytes += buff.pkt[1].len;
|
| 13094 | +u64_stats_update_end(&stats->syncp);
|
| 13095 | +/* Ended by AICoder, pid:tbef0151bf4135d1479d0a5d108c870bc756e858 */
|
| 13096 | + }else if(tmp == out){
|
| 13097 | +/* Started by AICoder, pid:y34f7id6bcs049f144f10bb8a05c9703b196635b */
|
| 13098 | +u64_stats_update_begin(&stats->syncp);
|
| 13099 | +stats->tx_packets += buff.pkt[0].pkt;
|
| 13100 | +stats->tx_bytes += buff.pkt[0].len;
|
| 13101 | +stats->rx_packets += buff.pkt[1].pkt;
|
| 13102 | +stats->rx_bytes += buff.pkt[1].len;
|
| 13103 | +u64_stats_update_end(&stats->syncp);
|
| 13104 | +/* Ended by AICoder, pid:y34f7id6bcs049f144f10bb8a05c9703b196635b */
|
| 13105 | + }else
|
| 13106 | + zv_err("nf_update0 %s->%s!=%s-%s", in->name, out->name, tmp->name, ct->indev[0]->name);
|
| 13107 | + }
|
| 13108 | + if(ct->indev[1] && is_vlan_dev(ct->indev[1])){
|
| 13109 | + struct net_device *tmp = vlan_dev_real_dev(ct->indev[1]);
|
| 13110 | + struct vlan_pcpu_stats *stats = this_cpu_ptr(vlan_dev_priv(ct->indev[1])->vlan_pcpu_stats);
|
| 13111 | +
|
| 13112 | + if(tmp == in){
|
| 13113 | +/* Started by AICoder, pid:8bef0t51bfu135d1479d0a5d108c870bc756e858 */
|
| 13114 | +u64_stats_update_begin(&stats->syncp);
|
| 13115 | +stats->rx_packets += buff.pkt[0].pkt;
|
| 13116 | +stats->rx_bytes += buff.pkt[0].len;
|
| 13117 | +stats->tx_packets += buff.pkt[1].pkt;
|
| 13118 | +stats->tx_bytes += buff.pkt[1].len;
|
| 13119 | +u64_stats_update_end(&stats->syncp);
|
| 13120 | +/* Ended by AICoder, pid:8bef0t51bfu135d1479d0a5d108c870bc756e858 */
|
| 13121 | + }else if(tmp == out){
|
| 13122 | +/* Started by AICoder, pid:934f7zd6bcl049f144f10bb8a05c9703b196635b */
|
| 13123 | +u64_stats_update_begin(&stats->syncp);
|
| 13124 | +stats->tx_packets += buff.pkt[0].pkt;
|
| 13125 | +stats->tx_bytes += buff.pkt[0].len;
|
| 13126 | +stats->rx_packets += buff.pkt[1].pkt;
|
| 13127 | +stats->rx_bytes += buff.pkt[1].len;
|
| 13128 | +u64_stats_update_end(&stats->syncp);
|
| 13129 | +/* Ended by AICoder, pid:934f7zd6bcl049f144f10bb8a05c9703b196635b */
|
| 13130 | + }else
|
| 13131 | + zv_err("nf_update1 %s->%s!=%s-%s", in->name, out->name, tmp->name, ct->indev[1]->name);
|
| 13132 | + }
|
| 13133 | spin_unlock_bh(&fast_fw_spinlock);
|
| 13134 | zv_info("nf_update %x %d %d %d %d", buff.cap_nfct, buff.pkt[0].pkt, buff.pkt[0].len, buff.pkt[1].pkt, buff.pkt[1].len);
|
| 13135 | }else{
|
| 13136 | zv_info("nf_put %x", buff.cap_nfct);
|
| 13137 | + WRITE_ONCE(ct->timeout, nfct_time_stamp);
|
| 13138 | nf_conntrack_put(buff.cap_nfct);
|
| 13139 | }
|
| 13140 | }
|
| 13141 | @@ -1179,11 +1259,11 @@ |
| 13142 | return err;
|
| 13143 | }
|
| 13144 |
|
| 13145 | - net->needed_headroom += ZVNET_SKB_PAD;//NET_SKB_PAD;
|
| 13146 | + //net->needed_headroom += ZVNET_SKB_PAD;//NET_SKB_PAD;
|
| 13147 | sprintf(net->name, "%s%d", ZVNET_IFNAME_PREFIX, i);
|
| 13148 | dev = v2xnet_dev_init(net, zvnetdev);
|
| 13149 | v2xnet_init_netdev(net);
|
| 13150 | - if(0 == i){
|
| 13151 | + if(0 == i || i > 8){
|
| 13152 | net->flags = (net->flags & (~IFF_NOARP));
|
| 13153 | }
|
| 13154 | err = register_netdev(net);
|
| 13155 | diff --git a/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.h b/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.h |
| 13156 | index d1feaa5..7c46dd3 100755 |
| 13157 | --- a/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.h |
| 13158 | +++ b/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.h |
| 13159 | @@ -27,7 +27,7 @@ |
| 13160 | __func__ , ## arg)
|
| 13161 |
|
| 13162 | //zvnetÉ豸×î´óÊý
|
| 13163 | -#define DDR_ZVNET_DEV_MAX 10
|
| 13164 | +#define DDR_ZVNET_DEV_MAX 16
|
| 13165 | #define ZVNET_IFNAME_PREFIX "zvnet"
|
| 13166 |
|
| 13167 | #define ICP_CHN_ZVNET1 20 //ICP_CHANNEL_WAN1
|
| 13168 | diff --git a/upstream/linux-5.10/drivers/rtc/class.c b/upstream/linux-5.10/drivers/rtc/class.c |
| 13169 | index 625effe..87310ce 100755 |
| 13170 | --- a/upstream/linux-5.10/drivers/rtc/class.c |
| 13171 | +++ b/upstream/linux-5.10/drivers/rtc/class.c |
| 13172 | @@ -19,6 +19,7 @@ |
| 13173 | #include <linux/workqueue.h> |
| 13174 | |
| 13175 | #include "rtc-core.h" |
| 13176 | +#include "pub_debug_info.h" |
| 13177 | |
| 13178 | static DEFINE_IDA(rtc_ida); |
| 13179 | struct class *rtc_class; |
| 13180 | @@ -80,7 +81,7 @@ |
| 13181 | #endif |
| 13182 | |
| 13183 | err = do_settimeofday64(&tv64); |
| 13184 | - |
| 13185 | + sc_debug_info_record("hctosys", "time synchronization successful!\r\n"); |
| 13186 | dev_info(rtc->dev.parent, "setting system clock to %ptR UTC (%lld)\n", |
| 13187 | &tm, (long long)tv64.tv_sec); |
| 13188 | |
| 13189 | diff --git a/upstream/linux-5.10/drivers/soc/sc/pcu/pcu-zx297520v3.c b/upstream/linux-5.10/drivers/soc/sc/pcu/pcu-zx297520v3.c |
| 13190 | index 66c8cf3..f9b23d7 100755 |
| 13191 | --- a/upstream/linux-5.10/drivers/soc/sc/pcu/pcu-zx297520v3.c |
| 13192 | +++ b/upstream/linux-5.10/drivers/soc/sc/pcu/pcu-zx297520v3.c |
| 13193 | @@ -37,6 +37,7 @@ |
| 13194 | #include <linux/soc/sc/rpmsg.h> |
| 13195 | #include <dt-bindings/soc/zx297520v3-irq.h> |
| 13196 | #include <uapi/linux/sc_bsp/bsp_api.h> |
| 13197 | +#include <pub_debug_info.h> |
| 13198 | |
| 13199 | #include "pcu-common.h" |
| 13200 | |
| 13201 | @@ -705,6 +706,7 @@ |
| 13202 | if(index_found != 0xff) |
| 13203 | { |
| 13204 | pm_ram_log(" wake: %d [%s]\n", zx297520v3_pcu_int_info[index_found].gic_index, zx297520v3_pcu_int_info[index_found].int_name); |
| 13205 | + sc_debug_info_record(MODULE_ID_CAP_PM, " wake: %d [%s]\n", zx297520v3_pcu_int_info[index_found].gic_index, zx297520v3_pcu_int_info[index_found].int_name); |
| 13206 | |
| 13207 | if(zx297520v3_pcu_int_info[index_found].gic_index ==ICP_PS2AP_INT) { |
| 13208 | show_icp_state(CORE_PS0); |
| 13209 | diff --git a/upstream/linux-5.10/drivers/soc/sc/plat/plat-zx297520v3.c b/upstream/linux-5.10/drivers/soc/sc/plat/plat-zx297520v3.c |
| 13210 | index b2da8d9..2cf9b67 100755 |
| 13211 | --- a/upstream/linux-5.10/drivers/soc/sc/plat/plat-zx297520v3.c |
| 13212 | +++ b/upstream/linux-5.10/drivers/soc/sc/plat/plat-zx297520v3.c |
| 13213 | @@ -80,6 +80,8 @@ |
| 13214 | #define ZX_SPINLOCK_TEST 0 |
| 13215 | #define ZX_PM_QOS_TEST 1 |
| 13216 | |
| 13217 | +#define GPIO_HIGH 1 |
| 13218 | +#define GPIO_LOW 0 |
| 13219 | |
| 13220 | /* |
| 13221 | * |
| 13222 | @@ -1898,6 +1900,10 @@ |
| 13223 | static int zx_restart(struct notifier_block *this, |
| 13224 | unsigned long mode, void *cmd) |
| 13225 | { |
| 13226 | + /*reset spinand cs*/ |
| 13227 | + soft_spin_lock_nand_psm(NAND_SFLOCK); |
| 13228 | + gpio_set_value(86,GPIO_HIGH); |
| 13229 | + |
| 13230 | if (reboot_rst) { |
| 13231 | reset_control_assert(reboot_rst); |
| 13232 | } |
| 13233 | diff --git a/upstream/linux-5.10/drivers/soc/sc/power/zx29-cpufreq.c b/upstream/linux-5.10/drivers/soc/sc/power/zx29-cpufreq.c |
| 13234 | index 7eacfd7..1def959 100755 |
| 13235 | --- a/upstream/linux-5.10/drivers/soc/sc/power/zx29-cpufreq.c |
| 13236 | +++ b/upstream/linux-5.10/drivers/soc/sc/power/zx29-cpufreq.c |
| 13237 | @@ -219,9 +219,11 @@ |
| 13238 | return 0; |
| 13239 | |
| 13240 | #ifdef SET_AXI_BY_HW |
| 13241 | - tmp = (pm_read_reg(PS_MATRIX_AXI_SEL)&(~0x7))|axi_freq; |
| 13242 | - pm_write_reg(PS_MATRIX_AXI_SEL,tmp); |
| 13243 | - pm_printk("[CPUFREQ] current_axi_freq(%d) request_axi_freq(%d) after_request_axi_freq(%d) after_request_vol(%d)\n",(u32)current_axi_freq,(u32)axi_freq,get_cur_axi(),get_cur_vol()); |
| 13244 | +/* Started by AICoder, pid:z8ed4zb53200a29148230ac670df2e16d7344ba7 */ |
| 13245 | + tmp = (pm_read_reg(AP_MATRIX_AXI_SEL)&(~0x7))|axi_freq; |
| 13246 | + pm_write_reg(AP_MATRIX_AXI_SEL,tmp); |
| 13247 | + pm_printk("[CPUFREQ] current_axi_freq(%d) request_axi_freq(%d) after_request_axi_freq(%d) after_request_vol(%d)\n",(u32)current_axi_freq,(u32)axi_freq, (pm_read_reg(AP_MATRIX_AXI_SEL)&(0x7)),get_cur_vol()); |
| 13248 | +/* Ended by AICoder, pid:z8ed4zb53200a29148230ac670df2e16d7344ba7 */ |
| 13249 | #else |
| 13250 | set_target_axi_sw(axi_freq); |
| 13251 | |
| 13252 | @@ -295,13 +297,9 @@ |
| 13253 | |
| 13254 | if(cpufreq_driver_inited==0) |
| 13255 | return -EPERM; |
| 13256 | - |
| 13257 | - if(axifreq >= 600*1000*1000) |
| 13258 | - return AXI_FREQ_156M; |
| 13259 | - else |
| 13260 | - return AXI_FREQ_78M; |
| 13261 | - |
| 13262 | - return request_axi_freq(axi_freq); |
| 13263 | +/* Started by AICoder, pid:keaa857ea2211111463f0b6cf00c182e9b179920 */ |
| 13264 | + return request_axi_freq(axifreq); |
| 13265 | +/* Ended by AICoder, pid:keaa857ea2211111463f0b6cf00c182e9b179920 */ |
| 13266 | } |
| 13267 | |
| 13268 | #endif |
| 13269 | diff --git a/upstream/linux-5.10/drivers/soc/sc/rpmsg/zx29_icp.c b/upstream/linux-5.10/drivers/soc/sc/rpmsg/zx29_icp.c |
| 13270 | index aae42a2..3c5ba58 100755 |
| 13271 | --- a/upstream/linux-5.10/drivers/soc/sc/rpmsg/zx29_icp.c |
| 13272 | +++ b/upstream/linux-5.10/drivers/soc/sc/rpmsg/zx29_icp.c |
| 13273 | @@ -15,6 +15,7 @@ |
| 13274 | #include <linux/pm_runtime.h> |
| 13275 | #include <linux/soc/sc/common.h> |
| 13276 | #include <linux/soc/sc/spinlock.h> |
| 13277 | +#include <pub_debug_info.h> |
| 13278 | |
| 13279 | #include "icp_dev.h" |
| 13280 | #include "zx29_icp.h" |
| 13281 | @@ -334,6 +335,7 @@ |
| 13282 | |
| 13283 | icp_get_int_info(actorID, &hw, &lw); |
| 13284 | pr_info("[SLP] icpwake: 0x%x 0x%x\n", hw, lw); |
| 13285 | + sc_debug_info_record(MODULE_ID_CAP_PM, " icpwake: 0x%x 0x%x\n", hw, lw); |
| 13286 | |
| 13287 | for (i=0; i<32; i++) |
| 13288 | if (lw&BIT(i)) |
| 13289 | diff --git a/upstream/linux-5.10/drivers/soc/sc/spinlock/spinlock-zx297520v3.c b/upstream/linux-5.10/drivers/soc/sc/spinlock/spinlock-zx297520v3.c |
| 13290 | index 7843e46..9e017da 100755 |
| 13291 | --- a/upstream/linux-5.10/drivers/soc/sc/spinlock/spinlock-zx297520v3.c |
| 13292 | +++ b/upstream/linux-5.10/drivers/soc/sc/spinlock/spinlock-zx297520v3.c |
| 13293 | @@ -300,6 +300,34 @@ |
| 13294 |
|
| 13295 | }
|
| 13296 |
|
| 13297 | +void soft_spin_lock_nand_psm(emsf_lock_id sfid)
|
| 13298 | +{
|
| 13299 | + unsigned long lock_count = 0;
|
| 13300 | +softlock_loop:
|
| 13301 | + while(softlock_desc[sfid]->owner != SELF_CORE_ID && softlock_desc[sfid]->used)
|
| 13302 | + {
|
| 13303 | + lock_count++;
|
| 13304 | + udelay(1);
|
| 13305 | + if(lock_count >= 100000)
|
| 13306 | + {
|
| 13307 | + return;
|
| 13308 | + }
|
| 13309 | + }
|
| 13310 | +
|
| 13311 | + _hw_spin_lock(SOFTLOCK_HWLOCK);
|
| 13312 | + if(softlock_desc[sfid]->owner != SELF_CORE_ID && softlock_desc[sfid]->used)
|
| 13313 | + {
|
| 13314 | + _hw_spin_unlock(SOFTLOCK_HWLOCK);
|
| 13315 | + goto softlock_loop;
|
| 13316 | + }
|
| 13317 | + softlock_desc[sfid]->used ++;
|
| 13318 | + softlock_desc[sfid]->owner = SELF_CORE_ID;
|
| 13319 | + _hw_spin_unlock(SOFTLOCK_HWLOCK);
|
| 13320 | + //zspinlock_debug("cpu %d releases %d software lock!/n",SELF_CORE_ID,sfid);
|
| 13321 | +
|
| 13322 | +}
|
| 13323 | +
|
| 13324 | +
|
| 13325 | /*******************************************************************************
|
| 13326 | * Function: soft_spin_unlock_psm
|
| 13327 | * Description:Óësoft_spin_lock_psm¶ÔÓ¦µÄÊÍ·ÅÈí¼þËø½Ó¿Ú¡£
|
| 13328 | @@ -503,6 +531,7 @@ |
| 13329 | void soft_spin_lock(emsf_lock_id sfid){}
|
| 13330 | void soft_spin_unlock(emsf_lock_id sfid){}
|
| 13331 | void soft_spin_lock_psm(emsf_lock_id sfid){}
|
| 13332 | +void soft_spin_lock_nand_psm(emsf_lock_id sfid){}
|
| 13333 | void soft_spin_unlock_psm(emsf_lock_id sfid){}
|
| 13334 | void hw_spin_lock(emhw_lock_id hwid){}
|
| 13335 | void hw_spin_unlock(emhw_lock_id hwid){}
|
| 13336 | diff --git a/upstream/linux-5.10/drivers/spi/spi-zx29.c b/upstream/linux-5.10/drivers/spi/spi-zx29.c |
| 13337 | index fd49fd6..57600dc 100755 |
| 13338 | --- a/upstream/linux-5.10/drivers/spi/spi-zx29.c |
| 13339 | +++ b/upstream/linux-5.10/drivers/spi/spi-zx29.c |
| 13340 | @@ -2341,7 +2341,9 @@ |
| 13341 | .iface = SPI_INTERFACE_MOTOROLA_SPI, |
| 13342 | .hierarchy = SPI_MASTER, |
| 13343 | .slave_tx_disable = DO_NOT_DRIVE_TX, |
| 13344 | + /* yu.dong@20240521 [T106BUG-616] SPI set to slave mode for read will get stuck start */ |
| 13345 | .rx_lev_trig = SPI_RX_8_OR_MORE_ELEM, |
| 13346 | + /* yu.dong@20240521 [T106BUG-616] SPI set to slave mode for read will get stuck end */ |
| 13347 | .tx_lev_trig = SPI_TX_4_OR_MORE_EMPTY_LOC, |
| 13348 | // .ctrl_len = SSP_BITS_8, |
| 13349 | // .wait_state = SSP_MWIRE_WAIT_ZERO, |
| 13350 | diff --git a/upstream/linux-5.10/drivers/staging/Kconfig b/upstream/linux-5.10/drivers/staging/Kconfig |
| 13351 | index 443587b..aacc8d0 100755 |
| 13352 | --- a/upstream/linux-5.10/drivers/staging/Kconfig |
| 13353 | +++ b/upstream/linux-5.10/drivers/staging/Kconfig |
| 13354 | @@ -118,5 +118,7 @@ |
| 13355 | |
| 13356 | source "drivers/staging/hikey9xx/Kconfig" |
| 13357 | |
| 13358 | +source "drivers/staging/voicedrv/Kconfig" |
| 13359 | + |
| 13360 | source "drivers/staging/voicebufferdrv/Kconfig" |
| 13361 | endif # STAGING |
| 13362 | diff --git a/upstream/linux-5.10/drivers/staging/Makefile b/upstream/linux-5.10/drivers/staging/Makefile |
| 13363 | index 0cb5246..276dea6 100755 |
| 13364 | --- a/upstream/linux-5.10/drivers/staging/Makefile |
| 13365 | +++ b/upstream/linux-5.10/drivers/staging/Makefile |
| 13366 | @@ -49,4 +49,5 @@ |
| 13367 | obj-$(CONFIG_QLGE) += qlge/ |
| 13368 | obj-$(CONFIG_WFX) += wfx/ |
| 13369 | obj-y += hikey9xx/ |
| 13370 | +obj-$(CONFIG_VOICE_DRV) += voicedrv/ |
| 13371 | obj-$(CONFIG_VOICE_BUFFER_DRV) += voicebufferdrv/ |
| 13372 | diff --git a/upstream/linux-5.10/drivers/staging/voicebufferdrv/voice_buffer_dev_multicore.c b/upstream/linux-5.10/drivers/staging/voicebufferdrv/voice_buffer_dev_multicore.c |
| 13373 | index 9c7d0c3..3beb425 100755 |
| 13374 | --- a/upstream/linux-5.10/drivers/staging/voicebufferdrv/voice_buffer_dev_multicore.c |
| 13375 | +++ b/upstream/linux-5.10/drivers/staging/voicebufferdrv/voice_buffer_dev_multicore.c |
| 13376 | Binary files differ |
| 13377 | diff --git a/upstream/linux-5.10/drivers/staging/voicedrv/Kconfig b/upstream/linux-5.10/drivers/staging/voicedrv/Kconfig |
| 13378 | new file mode 100755 |
| 13379 | index 0000000..426928d |
| 13380 | --- /dev/null |
| 13381 | +++ b/upstream/linux-5.10/drivers/staging/voicedrv/Kconfig |
| 13382 | @@ -0,0 +1,11 @@ |
| 13383 | +# |
| 13384 | +# voice driver for voice in userspace of ZX297520 |
| 13385 | +# |
| 13386 | + |
| 13387 | +comment "ZX297520 voice driver" |
| 13388 | + |
| 13389 | +config VOICE_DRV |
| 13390 | + bool "Voice Drv" |
| 13391 | + default n |
| 13392 | + help |
| 13393 | + Select this to make sure the build voice driver |
| 13394 | diff --git a/upstream/linux-5.10/drivers/staging/voicedrv/Makefile b/upstream/linux-5.10/drivers/staging/voicedrv/Makefile |
| 13395 | new file mode 100755 |
| 13396 | index 0000000..fbad610 |
| 13397 | --- /dev/null |
| 13398 | +++ b/upstream/linux-5.10/drivers/staging/voicedrv/Makefile |
| 13399 | @@ -0,0 +1,10 @@ |
| 13400 | +# |
| 13401 | +# voice driver. |
| 13402 | +# |
| 13403 | + |
| 13404 | + |
| 13405 | +ccflags-y += -Idrivers/staging/voicedrv/include |
| 13406 | + |
| 13407 | + |
| 13408 | +obj-$(CONFIG_VOICE_DRV) += voice_drv.o |
| 13409 | +voice_drv-$(CONFIG_VOICE_DRV) := voice_cap.o |
| 13410 | diff --git a/upstream/linux-5.10/drivers/staging/voicedrv/include/voice.h b/upstream/linux-5.10/drivers/staging/voicedrv/include/voice.h |
| 13411 | new file mode 100755 |
| 13412 | index 0000000..2566eb1 |
| 13413 | --- /dev/null |
| 13414 | +++ b/upstream/linux-5.10/drivers/staging/voicedrv/include/voice.h |
| 13415 | @@ -0,0 +1,17 @@ |
| 13416 | +/* |
| 13417 | + * Copyright (C) 2019 ZTE, China |
| 13418 | + * |
| 13419 | + * This is the header file for the voice driver. |
| 13420 | + * |
| 13421 | + */ |
| 13422 | + |
| 13423 | +#ifndef __LINUX_VOICE_H |
| 13424 | +#define __LINUX_VOICE_H |
| 13425 | + |
| 13426 | + |
| 13427 | + |
| 13428 | + |
| 13429 | + |
| 13430 | + |
| 13431 | + |
| 13432 | +#endif |
| 13433 | diff --git a/upstream/linux-5.10/drivers/staging/voicedrv/voice_cap.c b/upstream/linux-5.10/drivers/staging/voicedrv/voice_cap.c |
| 13434 | new file mode 100755 |
| 13435 | index 0000000..3da1ad3 |
| 13436 | --- /dev/null |
| 13437 | +++ b/upstream/linux-5.10/drivers/staging/voicedrv/voice_cap.c |
| 13438 | @@ -0,0 +1,207 @@ |
| 13439 | +#include <linux/module.h> |
| 13440 | +#include <linux/kernel.h> |
| 13441 | +#include <linux/init.h> |
| 13442 | +#include <linux/fs.h> |
| 13443 | +#include <linux/miscdevice.h> |
| 13444 | +#include <asm/uaccess.h> |
| 13445 | +#include <linux/slab.h> |
| 13446 | + |
| 13447 | +#include <linux/volte_drv.h> |
| 13448 | + |
| 13449 | + |
| 13450 | +#include "include/voice.h" |
| 13451 | + |
| 13452 | + |
| 13453 | +MODULE_LICENSE("GPL"); |
| 13454 | +MODULE_AUTHOR("xxq"); |
| 13455 | + |
| 13456 | +static int s_voiceInfMode = 0; |
| 13457 | +static DEFINE_MUTEX(infmode_lock); |
| 13458 | + |
| 13459 | + |
| 13460 | +struct voice_dev *voicedev = NULL; |
| 13461 | +static const char voice_shortname[] = "voice_device"; |
| 13462 | + |
| 13463 | + |
| 13464 | + |
| 13465 | + |
| 13466 | +static int voice_open(struct inode *ip, struct file *fp); |
| 13467 | +static int voice_release(struct inode *ip, struct file *fp); |
| 13468 | +static long voice_ioctl(struct file *fp, unsigned int cmd, unsigned long arg); |
| 13469 | + |
| 13470 | + |
| 13471 | + |
| 13472 | + |
| 13473 | + |
| 13474 | + |
| 13475 | +static int voice_SetVoiceInfMode(int mode) |
| 13476 | +{ |
| 13477 | + int ret = 0; |
| 13478 | + mutex_lock(&infmode_lock); |
| 13479 | + s_voiceInfMode = mode; |
| 13480 | + mutex_unlock(&infmode_lock); |
| 13481 | + printk(KERN_INFO "%s:mode = %d\n",__func__,mode); |
| 13482 | + |
| 13483 | + return ret; |
| 13484 | +} |
| 13485 | + |
| 13486 | +static int voice_GetVoiceInfMode(void) |
| 13487 | +{ |
| 13488 | + int mode; |
| 13489 | + mutex_lock(&infmode_lock); |
| 13490 | + mode = s_voiceInfMode; |
| 13491 | + mutex_unlock(&infmode_lock); |
| 13492 | + printk(KERN_INFO "%s:mode = %d\n",__func__,s_voiceInfMode); |
| 13493 | + return mode; |
| 13494 | +} |
| 13495 | + |
| 13496 | + |
| 13497 | + |
| 13498 | + |
| 13499 | +/* file operations for volte device /dev/volte_device */ |
| 13500 | +static const struct file_operations voice_fops = { |
| 13501 | + .owner = THIS_MODULE, |
| 13502 | + //.read = voice_read, |
| 13503 | + //.write = voice_write, |
| 13504 | + .unlocked_ioctl = voice_ioctl, |
| 13505 | + .open = voice_open, |
| 13506 | + .release = voice_release, |
| 13507 | +}; |
| 13508 | + |
| 13509 | +static struct miscdevice voice_device = { |
| 13510 | + .minor = MISC_DYNAMIC_MINOR, |
| 13511 | + .name = voice_shortname, |
| 13512 | + .fops = &voice_fops, |
| 13513 | +}; |
| 13514 | + |
| 13515 | + |
| 13516 | +#if 0 |
| 13517 | +static ssize_t voice_read(struct file *fp, char __user *buf, size_t count, loff_t *pos) |
| 13518 | +{ |
| 13519 | + struct adbproxy_dev *dev = fp->private_data; |
| 13520 | + struct usbproxy_request *req; |
| 13521 | + int r = count, xfer; |
| 13522 | + int ret; |
| 13523 | + return count; |
| 13524 | +} |
| 13525 | + |
| 13526 | +static ssize_t voice_write(struct file *fp, const char __user *buf, size_t count, loff_t *pos) |
| 13527 | +{ |
| 13528 | + int ret; |
| 13529 | + |
| 13530 | + |
| 13531 | + return count; |
| 13532 | +} |
| 13533 | +#endif |
| 13534 | + |
| 13535 | + |
| 13536 | +static long voice_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) |
| 13537 | +{ |
| 13538 | + int ret = 0; |
| 13539 | + void __user *argp = (void __user *) arg; |
| 13540 | +#ifndef CONFIG_RECOVERY_SYSTEM |
| 13541 | + |
| 13542 | + switch (cmd) { |
| 13543 | + |
| 13544 | + |
| 13545 | + case VOICE_IOCTL_GET_INF_MODE: { |
| 13546 | + |
| 13547 | + int mode; |
| 13548 | + mode = voice_GetVoiceInfMode(); |
| 13549 | + |
| 13550 | + pr_info("voice_ioctl GET_VBUF,mode=%d!\n",mode); |
| 13551 | + |
| 13552 | + if (copy_to_user(argp, &mode, sizeof(mode))) { |
| 13553 | + pr_err("voice_ioctl GetVoiceInfMode copy_to_user err!\n"); |
| 13554 | + return -EFAULT; |
| 13555 | + } |
| 13556 | + |
| 13557 | + break; |
| 13558 | + } |
| 13559 | + |
| 13560 | + case VOICE_IOCTL_SET_INF_MODE: { |
| 13561 | + int para; |
| 13562 | + |
| 13563 | + if (copy_from_user(¶, argp, sizeof(para))) { |
| 13564 | + print_audio("voice_ioctl SetVoiceInfMode copy_to_user err!\n"); |
| 13565 | + return -EFAULT; |
| 13566 | + } |
| 13567 | + ret = voice_SetVoiceInfMode(para); |
| 13568 | + if (ret < 0) |
| 13569 | + print_audio("%s SetVoiceInfMode ret=%d\n", __func__, ret); |
| 13570 | + |
| 13571 | + break; |
| 13572 | + } |
| 13573 | + |
| 13574 | + |
| 13575 | + default: { |
| 13576 | + pr_info("voice_ioctl invalid cmd!\n"); |
| 13577 | + break; |
| 13578 | + } |
| 13579 | + } |
| 13580 | +#endif |
| 13581 | + |
| 13582 | + return ret; |
| 13583 | +} |
| 13584 | + |
| 13585 | + |
| 13586 | + |
| 13587 | +static int voice_open(struct inode *ip, struct file *fp) |
| 13588 | +{ |
| 13589 | +// pr_info("volte_open\n"); |
| 13590 | + |
| 13591 | +#ifndef CONFIG_RECOVERY_SYSTEM |
| 13592 | + if (voicedev == NULL) { |
| 13593 | + voicedev = kzalloc(sizeof(*voicedev), GFP_KERNEL); |
| 13594 | + if (!voicedev) { |
| 13595 | + pr_info("voice_init malloc error\n"); |
| 13596 | + return -ENOMEM; |
| 13597 | + } |
| 13598 | + |
| 13599 | + |
| 13600 | + } |
| 13601 | + |
| 13602 | +#endif |
| 13603 | + |
| 13604 | + return 0; |
| 13605 | +} |
| 13606 | + |
| 13607 | +static int voice_release(struct inode *ip, struct file *fp) |
| 13608 | +{ |
| 13609 | +// pr_info("volte_release\n"); |
| 13610 | +#ifndef CONFIG_RECOVERY_SYSTEM |
| 13611 | + if (voicedev) { |
| 13612 | + kfree(voicedev); |
| 13613 | + voicedev = NULL; |
| 13614 | + print_audio("release voicedev!\n"); |
| 13615 | + |
| 13616 | + } |
| 13617 | +#endif |
| 13618 | + |
| 13619 | + return 0; |
| 13620 | +} |
| 13621 | + |
| 13622 | + |
| 13623 | +static int __init voice_init(void) |
| 13624 | +{ |
| 13625 | + int ret; |
| 13626 | +// pr_info("volte_init\n"); |
| 13627 | + |
| 13628 | + ret = misc_register(&voice_device); |
| 13629 | + if (ret) { |
| 13630 | + printk(KERN_ERR "voice driver failed to initialize\n"); |
| 13631 | + return -EFAULT; |
| 13632 | + } |
| 13633 | +// pr_info("voice_init volte_device nodename=%s\n",volte_device.nodename); |
| 13634 | + |
| 13635 | + return 0; |
| 13636 | +} |
| 13637 | + |
| 13638 | + |
| 13639 | +static void __exit voice_exit(void) |
| 13640 | +{ |
| 13641 | + misc_deregister(&voice_device); |
| 13642 | +} |
| 13643 | + |
| 13644 | +module_init(voice_init); |
| 13645 | +module_exit(voice_exit); |
| 13646 | diff --git a/upstream/linux-5.10/drivers/tty/tty_io.c b/upstream/linux-5.10/drivers/tty/tty_io.c |
| 13647 | index 669aef7..8591d06 100755 |
| 13648 | --- a/upstream/linux-5.10/drivers/tty/tty_io.c |
| 13649 | +++ b/upstream/linux-5.10/drivers/tty/tty_io.c |
| 13650 | @@ -771,6 +771,12 @@ |
| 13651 | if (tty->stopped) |
| 13652 | return; |
| 13653 | tty->stopped = 1; |
| 13654 | + |
| 13655 | + //l.yang add log for bug T106-134 start |
| 13656 | + if(tty->index == 1){ |
| 13657 | + printk("__stop_tty got stop cmd\n"); |
| 13658 | + } |
| 13659 | + //l.yang add log for bug T106-134 end |
| 13660 | if (tty->ops->stop) |
| 13661 | tty->ops->stop(tty); |
| 13662 | } |
| 13663 | diff --git a/upstream/linux-5.10/include/linux/soc/sc/spinlock.h b/upstream/linux-5.10/include/linux/soc/sc/spinlock.h |
| 13664 | index eb5e7b7..17faf8b 100755 |
| 13665 | --- a/upstream/linux-5.10/include/linux/soc/sc/spinlock.h |
| 13666 | +++ b/upstream/linux-5.10/include/linux/soc/sc/spinlock.h |
| 13667 | @@ -103,7 +103,7 @@ |
| 13668 | void reg_spin_unlock(void);
|
| 13669 | void soft_spin_lock_psm(emsf_lock_id sfid);
|
| 13670 | void soft_spin_unlock_psm(emsf_lock_id sfid);
|
| 13671 | -
|
| 13672 | +void soft_spin_lock_nand_psm(emsf_lock_id sfid);
|
| 13673 | void zx_spinlock_init(void __iomem *spinlock_base);
|
| 13674 | int soft_spin_lock_printf(emsf_lock_id sfid);
|
| 13675 |
|
| 13676 | diff --git a/upstream/linux-5.10/include/linux/soc/zte/spinlock.h b/upstream/linux-5.10/include/linux/soc/zte/spinlock.h |
| 13677 | index 1181933..e5edb44 100755 |
| 13678 | --- a/upstream/linux-5.10/include/linux/soc/zte/spinlock.h |
| 13679 | +++ b/upstream/linux-5.10/include/linux/soc/zte/spinlock.h |
| 13680 | @@ -107,7 +107,7 @@ |
| 13681 | void reg_spin_unlock(void);
|
| 13682 | void soft_spin_lock_psm(emsf_lock_id sfid);
|
| 13683 | void soft_spin_unlock_psm(emsf_lock_id sfid);
|
| 13684 | -
|
| 13685 | +void soft_spin_lock_nand_psm(emsf_lock_id sfid);
|
| 13686 | void zx_spinlock_init(void __iomem *spinlock_base);
|
| 13687 | int soft_spin_lock_printf(emsf_lock_id sfid);
|
| 13688 |
|
| 13689 | diff --git a/upstream/linux-5.10/include/linux/volte_drv.h b/upstream/linux-5.10/include/linux/volte_drv.h |
| 13690 | new file mode 100755 |
| 13691 | index 0000000..7862449 |
| 13692 | --- /dev/null |
| 13693 | +++ b/upstream/linux-5.10/include/linux/volte_drv.h |
| 13694 | @@ -0,0 +1,154 @@ |
| 13695 | +/* |
| 13696 | + * Copyright (C) 2013 ZTE, China |
| 13697 | + * |
| 13698 | + * It has the ioctl definitions for the volte driver that |
| 13699 | + * userspace needs to know about. |
| 13700 | + */ |
| 13701 | + |
| 13702 | +#ifndef __LINUX_VOLTE_DRV_H |
| 13703 | +#define __LINUX_VOLTE_DRV_H |
| 13704 | + |
| 13705 | +#include <linux/ioctl.h> |
| 13706 | +#include <linux/types.h> |
| 13707 | + |
| 13708 | + |
| 13709 | + |
| 13710 | +typedef enum { |
| 13711 | + VOICE_GSM_MODE = 0, |
| 13712 | + VOICE_TD_MODE , |
| 13713 | + VOICE_WCDMA_MODE, |
| 13714 | + VOICE_LTE_MODE, |
| 13715 | + VOICE_GSM_TD_MODE,//GSM TD share |
| 13716 | + VOICE_GSM_WCDMA_MODE, //GSM WCDMA share |
| 13717 | + MAX_VOICE_MODE |
| 13718 | +} T_ZDrvVoice_MODE; |
| 13719 | +typedef struct { |
| 13720 | + uint32_t clock_rate; |
| 13721 | + uint32_t channel_count; |
| 13722 | + uint32_t samples_per_frame; |
| 13723 | + uint32_t bits_per_sample; |
| 13724 | + uint32_t mode; |
| 13725 | +} T_ZDrvVoice_Cfg; |
| 13726 | + |
| 13727 | +typedef T_ZDrvVoice_Cfg T_ZDrvVolte_Cfg; |
| 13728 | + |
| 13729 | +#ifdef __KERNEL__ |
| 13730 | +struct volte_dev { |
| 13731 | + T_ZDrvVoice_Cfg param; |
| 13732 | + void *readbuf; |
| 13733 | + void *writebuf; |
| 13734 | +}; |
| 13735 | +#endif |
| 13736 | + |
| 13737 | +#define VOLTE_IOCTL_READ_START _IO('v', 1) |
| 13738 | +#define VOLTE_IOCTL_READ_STOP _IO('v', 2) |
| 13739 | +#define VOLTE_IOCTL_WRITE_START _IO('v', 3) |
| 13740 | +#define VOLTE_IOCTL_WRITE_STOP _IO('v', 4) |
| 13741 | +#define VOLTE_IOCTL_SET_CFG _IOW('v', 5, T_ZDrvVoice_Cfg) |
| 13742 | +#define VOLTE_IOCTL_GET_SLIC_USE_FLAG _IOR ('v', 6, int) |
| 13743 | + |
| 13744 | +/**************voice define****************/ |
| 13745 | +typedef enum { |
| 13746 | + AMR_NB_CODEC = 0, |
| 13747 | + AMR_WB_CODEC, |
| 13748 | + |
| 13749 | + MAX_CODEC_TYPE |
| 13750 | +} T_Codec_Type; |
| 13751 | + |
| 13752 | +typedef enum { |
| 13753 | + DSP_PATH = 0, |
| 13754 | + SOFT_PATH, |
| 13755 | + MAX_CODEC_PATH |
| 13756 | +} T_Codec_Path; |
| 13757 | + |
| 13758 | +typedef enum { |
| 13759 | + NOR_VOICE_INF_MODE = 0,//normal |
| 13760 | + VB_VOICE_INF_MODE,//voice buffer |
| 13761 | + MAX_VOICE_INF_MODE |
| 13762 | +} T_VoiceInfMode; |
| 13763 | + |
| 13764 | + |
| 13765 | +typedef enum { |
| 13766 | + VOICE_STOP = 0, |
| 13767 | + VOICE_START, |
| 13768 | + MAX_VOICE_STATE |
| 13769 | +} T_Voice_State; |
| 13770 | + |
| 13771 | +typedef struct { |
| 13772 | + uint32_t clock_rate; //8000;16000 |
| 13773 | + uint32_t mode; //// 0 gsm;1 td;2 wcdma;3 lte |
| 13774 | + uint32_t codec_type;//0 amr-nb;1 amr-wb |
| 13775 | + uint32_t codec_path;//0 hardware dsp;1 soft amr lib |
| 13776 | + |
| 13777 | + |
| 13778 | +} T_Voice_Para; |
| 13779 | + |
| 13780 | +typedef struct { |
| 13781 | + uint32_t fs; //8000;16000 |
| 13782 | + uint32_t enable; //// 0 disable;1 enable |
| 13783 | + uint32_t type;//0 single core;1 mult core |
| 13784 | + |
| 13785 | + |
| 13786 | +} T_VoiceBuf_Para; |
| 13787 | + |
| 13788 | + |
| 13789 | +#ifdef __KERNEL__ |
| 13790 | +struct voice_dev { |
| 13791 | + T_Voice_Para param; |
| 13792 | + uint32_t voice_state; |
| 13793 | +}; |
| 13794 | +#endif |
| 13795 | + |
| 13796 | +#define VOICE_IOCTL_START _IOW('v', 10, T_ZDrvVoice_Cfg) |
| 13797 | +#define VOICE_IOCTL_STOP _IOW('v', 11, T_ZDrvVoice_Cfg) |
| 13798 | +#define VOICE_IOCTL_GET_SLIC_USE_FLAG _IOR ('v', 12, int) |
| 13799 | +#define VOICE_IOCTL_VPLOOP _IOW('v', 13, int) |
| 13800 | + |
| 13801 | +#define VOICE_IOCTL_SET_VOL _IOW('v', 14, int) |
| 13802 | +#define VOICE_IOCTL_GET_VOL _IOR('v', 15, int) |
| 13803 | + |
| 13804 | +#define VOICE_IOCTL_SET_MUTE _IOW('v', 16, bool) |
| 13805 | +#define VOICE_IOCTL_GET_MUTE _IOR('v', 17, bool) |
| 13806 | + |
| 13807 | +#define VOICE_IOCTL_SET_PATH _IOW('v', 18, int) |
| 13808 | +#define VOICE_IOCTL_GET_PATH _IOR('v', 19, int) |
| 13809 | + |
| 13810 | +#define VOICE_IOCTL_GET_FS _IOR('v', 20, int) |
| 13811 | +#define VOICE_IOCTL_SET_VOICE_NVRW _IOW('v', 21, int) |
| 13812 | + |
| 13813 | +#define VOICE_IOCTL_SET_VP _IOW('v', 22, int) |
| 13814 | +#define VOICE_IOCTL_GET_VP _IOR('v', 23, int) |
| 13815 | + |
| 13816 | +#define VOICE_IOCTL_SET_VBUF _IOW('v', 24, T_VoiceBuf_Para) |
| 13817 | +#define VOICE_IOCTL_GET_VBUF _IOR('v', 25, T_VoiceBuf_Para) |
| 13818 | + |
| 13819 | +#define VOICE_IOCTL_SET_INF_MODE _IOW('v', 26, int) |
| 13820 | +#define VOICE_IOCTL_GET_INF_MODE _IOR('v', 27, int) |
| 13821 | + |
| 13822 | + |
| 13823 | + |
| 13824 | +#ifdef __KERNEL__ |
| 13825 | +#define print_audio(fmt, ...) \ |
| 13826 | + printk(fmt, ##__VA_ARGS__) |
| 13827 | +#endif |
| 13828 | + |
| 13829 | +/**************audiomix define****************/ |
| 13830 | +typedef struct { |
| 13831 | + uint32_t sample_rate; |
| 13832 | + uint32_t audioType; |
| 13833 | + //uint32_t samples_per_frame; |
| 13834 | + //uint32_t bits_per_sample; |
| 13835 | +} T_ZDrvAudioMix_Cfg; |
| 13836 | + |
| 13837 | +#ifdef __KERNEL__ |
| 13838 | +struct audio_mix_dev { |
| 13839 | + T_ZDrvAudioMix_Cfg param; |
| 13840 | + //void *readbuf; |
| 13841 | + void *writebuf; |
| 13842 | +}; |
| 13843 | +#endif |
| 13844 | + |
| 13845 | +#define AUDIOMIX_IOCTL_SET_CFG _IOW('v', 7, T_ZDrvAudioMix_Cfg) |
| 13846 | + |
| 13847 | +#endif |
| 13848 | + |
| 13849 | diff --git a/upstream/linux-5.10/include/net/SI/netioc_proc.h b/upstream/linux-5.10/include/net/SI/netioc_proc.h |
| 13850 | index f0c8aa4..38f9bce 100755 |
| 13851 | --- a/upstream/linux-5.10/include/net/SI/netioc_proc.h |
| 13852 | +++ b/upstream/linux-5.10/include/net/SI/netioc_proc.h |
| 13853 | @@ -417,6 +417,9 @@ |
| 13854 | extern int fast_local4_output_num; //±¾µØfast_local4³É¹¦·¢Ëͱ¨ÎÄ |
| 13855 | extern int fast_local6_output_num; //±¾µØfast_local6³É¹¦·¢Ëͱ¨ÎÄ |
| 13856 | extern int fast_tcpdump_num; //fast×¥°üÊýÁ¿ |
| 13857 | +extern int skb_expand4; //Í·¿Õ¼ä²»¹»ÖØÐÂÉêÇëµÄV4Êý¾Ý°ü |
| 13858 | +extern int skb_expand6; //Í·¿Õ¼ä²»¹»ÖØÐÂÉêÇëµÄV6Êý¾Ý°ü |
| 13859 | + |
| 13860 | |
| 13861 | extern int double_mac; |
| 13862 | |
| 13863 | diff --git a/upstream/linux-5.10/include/net/netfilter/nf_conntrack.h b/upstream/linux-5.10/include/net/netfilter/nf_conntrack.h |
| 13864 | index 04ab917..ff7b8ea 100755 |
| 13865 | --- a/upstream/linux-5.10/include/net/netfilter/nf_conntrack.h |
| 13866 | +++ b/upstream/linux-5.10/include/net/netfilter/nf_conntrack.h |
| 13867 | @@ -131,6 +131,7 @@ |
| 13868 | struct conn_skbinfo packet_info[IP_CT_DIR_MAX]; |
| 13869 | struct net_device* indev[IP_CT_DIR_MAX]; |
| 13870 | struct net_device* outdev[IP_CT_DIR_MAX]; |
| 13871 | + void *fast_entry; |
| 13872 | }; |
| 13873 | |
| 13874 | static inline struct nf_conn * |
| 13875 | diff --git a/upstream/linux-5.10/init/main.c b/upstream/linux-5.10/init/main.c |
| 13876 | index 83d93ea..576e168 100755 |
| 13877 | --- a/upstream/linux-5.10/init/main.c |
| 13878 | +++ b/upstream/linux-5.10/init/main.c |
| 13879 | @@ -852,7 +852,7 @@ |
| 13880 | } |
| 13881 | |
| 13882 | void __weak early_drv_init(void) {} |
| 13883 | - |
| 13884 | +void __weak early_debug_info_init(void){} |
| 13885 | asmlinkage __visible void __init __no_sanitize_address start_kernel(void) |
| 13886 | { |
| 13887 | char *command_line; |
| 13888 | @@ -950,7 +950,7 @@ |
| 13889 | initcall_debug_enable(); |
| 13890 | |
| 13891 | context_tracking_init(); |
| 13892 | - |
| 13893 | + early_debug_info_init(); |
| 13894 | early_drv_init(); |
| 13895 | |
| 13896 | /* init some links before init_ISA_irqs() */ |
| 13897 | diff --git a/upstream/linux-5.10/kernel/ramdump/ramdump_device_trans.c b/upstream/linux-5.10/kernel/ramdump/ramdump_device_trans.c |
| 13898 | index 40c920d..f3e91e9 100755 |
| 13899 | --- a/upstream/linux-5.10/kernel/ramdump/ramdump_device_trans.c |
| 13900 | +++ b/upstream/linux-5.10/kernel/ramdump/ramdump_device_trans.c |
| 13901 | @@ -620,6 +620,8 @@ |
| 13902 | /* interactive begin */ |
| 13903 | if(ramdump_device_init() < 0) |
| 13904 | return; |
| 13905 | + |
| 13906 | + ramdump_device_write_logbuf(); |
| 13907 | data_trans_max = RAMDUMP_SHARED_MEM_LEN - roundup(sizeof(ramdump_shmem_t), RAMDUMP_SHMEM_ALIGN_SIZE) - RAMDUMP_COMPRESS_OUT_LEN; |
| 13908 | cap_to_server_msg.cmd = RAMDUMP_PC_INTERACTIVE_REQ; |
| 13909 | ramdump_oss_data_trans_write((unsigned char*)(&cap_to_server_msg), sizeof(cap_to_server_msg)); |
| 13910 | @@ -635,8 +637,8 @@ |
| 13911 | ramdump_trans_server_interactive_req *server_to_cap_msg = (ramdump_trans_server_interactive_req *)req_buf; |
| 13912 | /* data from server to cap */ |
| 13913 | ramdump_file_num = server_to_cap_msg->file_num; |
| 13914 | - ramdump_device_fp.file_num = ramdump_file_num; |
| 13915 | - ramdump_spinand_fp.file_num = ramdump_file_num; |
| 13916 | + ramdump_device_fp.file_num += ramdump_file_num; |
| 13917 | + ramdump_spinand_fp.file_num += ramdump_file_num; |
| 13918 | |
| 13919 | /* data from cap to server */ |
| 13920 | cap_to_server_msg.cmd = RAMDUMP_PC_FILE_INFO_READ_REQ; |
| 13921 | @@ -732,7 +734,6 @@ |
| 13922 | } |
| 13923 | case RAMDUMP_TRANS_SERVER_FILE_TRANS_DONE_RSP: |
| 13924 | { |
| 13925 | - ramdump_device_write_logbuf(); |
| 13926 | ramdump_device_close(); |
| 13927 | return; |
| 13928 | } |
| 13929 | diff --git a/upstream/linux-5.10/net/8021q/vlan_dev.c b/upstream/linux-5.10/net/8021q/vlan_dev.c |
| 13930 | index 86a1c99..6117e9c 100755 |
| 13931 | --- a/upstream/linux-5.10/net/8021q/vlan_dev.c |
| 13932 | +++ b/upstream/linux-5.10/net/8021q/vlan_dev.c |
| 13933 | @@ -94,7 +94,7 @@ |
| 13934 | return NETDEV_TX_OK; |
| 13935 | #endif |
| 13936 | } |
| 13937 | - |
| 13938 | +extern void fast_update_indev(struct sk_buff *skb, struct net_device *dev); |
| 13939 | static netdev_tx_t vlan_dev_hard_start_xmit(struct sk_buff *skb, |
| 13940 | struct net_device *dev) |
| 13941 | { |
| 13942 | @@ -120,7 +120,7 @@ |
| 13943 | len = skb->len; |
| 13944 | if (unlikely(netpoll_tx_running(dev))) |
| 13945 | return vlan_netpoll_send_skb(vlan, skb); |
| 13946 | - |
| 13947 | + fast_update_indev(skb, dev); |
| 13948 | ret = dev_queue_xmit(skb); |
| 13949 | |
| 13950 | if (likely(ret == NET_XMIT_SUCCESS || ret == NET_XMIT_CN)) { |
| 13951 | diff --git a/upstream/linux-5.10/net/bridge/br_fdb.c b/upstream/linux-5.10/net/bridge/br_fdb.c |
| 13952 | index 65a6054..974ee5e 100755 |
| 13953 | --- a/upstream/linux-5.10/net/bridge/br_fdb.c |
| 13954 | +++ b/upstream/linux-5.10/net/bridge/br_fdb.c |
| 13955 | @@ -1313,7 +1313,7 @@ |
| 13956 | u16 vid = 0; |
| 13957 | int ntl_port_id = 0xff; |
| 13958 | |
| 13959 | - if(!skb->dev) |
| 13960 | + if(!skb->dev || fastbr_level != 1) |
| 13961 | { |
| 13962 | //print_sun(SUN_DBG, "fast_br skb->dev err skb->dev = %x\n", skb->dev); |
| 13963 | return 0; |
| 13964 | diff --git a/upstream/linux-5.10/net/core/SI/net_other.c b/upstream/linux-5.10/net/core/SI/net_other.c |
| 13965 | index a6748c7..816686b 100755 |
| 13966 | --- a/upstream/linux-5.10/net/core/SI/net_other.c |
| 13967 | +++ b/upstream/linux-5.10/net/core/SI/net_other.c |
| 13968 | @@ -1090,7 +1090,8 @@ |
| 13969 | int fast_local4_output_num = 0; //±¾µØfast_local4³É¹¦·¢Ëͱ¨ÎÄ |
| 13970 | int fast_local6_output_num = 0; //±¾µØfast_local6³É¹¦·¢Ëͱ¨ÎÄ |
| 13971 | int fast_tcpdump_num = 0; //fast×¥°üÊýÁ¿ |
| 13972 | - |
| 13973 | +int skb_expand4 = 0; //Í·¿Õ¼ä²»¹»ÖØÐÂÉêÇëµÄV4Êý¾Ý°ü |
| 13974 | +int skb_expand6 = 0; //Í·¿Õ¼ä²»¹»ÖØÐÂÉêÇëµÄV6Êý¾Ý°ü |
| 13975 | |
| 13976 | int double_mac = 0; //mac¼ì²é¿ª¹Ø |
| 13977 | //slabÄÚ´æÊ¹ÓÃÏà¹ØÍ³¼Æ£¬Î´¿¼ÂÇͨÓÃslabµØÖ·³Ø£¬Èçkmalloc |
| 13978 | diff --git a/upstream/linux-5.10/net/core/fastproc/fast4_fw.c b/upstream/linux-5.10/net/core/fastproc/fast4_fw.c |
| 13979 | index 0ef32e4..a0674f9 100755 |
| 13980 | --- a/upstream/linux-5.10/net/core/fastproc/fast4_fw.c |
| 13981 | +++ b/upstream/linux-5.10/net/core/fastproc/fast4_fw.c |
| 13982 | @@ -67,6 +67,7 @@ |
| 13983 | /* ******************************** º¯ÊýʵÏÖ ********************************/ |
| 13984 | int dst_expire_count = 0; |
| 13985 | extern int no_neighbour; |
| 13986 | +extern fast_list_t working_list; |
| 13987 | |
| 13988 | static inline int rt_is_expired(struct rtable *rth) |
| 13989 | { |
| 13990 | @@ -555,7 +556,11 @@ |
| 13991 | { |
| 13992 | ret = ifname_compare_aligned(ct->indev[dir]->name, ipinfo->iniface, ipinfo->iniface_mask); |
| 13993 | } |
| 13994 | - |
| 13995 | + else |
| 13996 | + { |
| 13997 | + ret=1; |
| 13998 | + } |
| 13999 | + |
| 14000 | if(ipinfo->iniface[0] != '\0') |
| 14001 | *match_filter = 1; |
| 14002 | |
| 14003 | @@ -583,6 +588,8 @@ |
| 14004 | ip_packet_match_neg(const struct ipt_ip *ipinfo,struct nf_conn* ct,int dir, int* match_filter) |
| 14005 | { |
| 14006 | unsigned long ret; |
| 14007 | + if(!(ct->status & IPS_NAT_MASK)) |
| 14008 | + return false; |
| 14009 | if (NF_INVF(ipinfo, IPT_INV_SRCIP, |
| 14010 | (ct->tuplehash[dir].tuple.dst.u3.ip & ipinfo->smsk.s_addr) != ipinfo->src.s_addr) || |
| 14011 | NF_INVF(ipinfo, IPT_INV_DSTIP, |
| 14012 | @@ -595,7 +602,11 @@ |
| 14013 | { |
| 14014 | ret = ifname_compare_aligned(ct->outdev[dir]->name, ipinfo->iniface, ipinfo->iniface_mask); |
| 14015 | } |
| 14016 | - |
| 14017 | + else |
| 14018 | + { |
| 14019 | + ret = 1; |
| 14020 | + } |
| 14021 | + |
| 14022 | if(ipinfo->iniface[0] != '\0') |
| 14023 | *match_filter = 1; |
| 14024 | |
| 14025 | @@ -675,7 +686,7 @@ |
| 14026 | e = get_entry(table_base, private->hook_entry[NF_INET_LOCAL_IN]); |
| 14027 | break; |
| 14028 | default: |
| 14029 | - break; |
| 14030 | + return; |
| 14031 | } |
| 14032 | while(num--) |
| 14033 | { |
| 14034 | @@ -747,8 +758,7 @@ |
| 14035 | |
| 14036 | static void ct_iptables_bhfunc(unsigned long param) |
| 14037 | { |
| 14038 | - int hash = 0; |
| 14039 | - struct nf_conntrack_tuple_hash *h; |
| 14040 | + fast_entry_t *ret = NULL; |
| 14041 | struct hlist_nulls_node *n; |
| 14042 | struct nf_conn *ct; |
| 14043 | struct xt_table_info *private; |
| 14044 | @@ -756,13 +766,12 @@ |
| 14045 | unsigned int addend; |
| 14046 | local_bh_disable(); |
| 14047 | addend = xt_write_recseq_begin(); |
| 14048 | - for(hash = 0; hash < nf_conntrack_htable_size; hash++) |
| 14049 | - { |
| 14050 | - hlist_nulls_for_each_entry_rcu(h,n,&nf_conntrack_hash[hash],hnnode) |
| 14051 | + spin_lock_bh(&fast_fw_spinlock); |
| 14052 | + for (ret = (&working_list)->next; ret; ret = ret->next) |
| 14053 | + { |
| 14054 | + if(ret) |
| 14055 | { |
| 14056 | - if(h) |
| 14057 | - { |
| 14058 | - ct = nf_ct_tuplehash_to_ctrack(h); |
| 14059 | + ct = ret->ct; |
| 14060 | if(ct->fast_ct.isFast) |
| 14061 | { |
| 14062 | net = nf_ct_net(ct); |
| 14063 | @@ -777,19 +786,66 @@ |
| 14064 | } |
| 14065 | else |
| 14066 | continue; |
| 14067 | - spin_lock_bh(&fast_fw_spinlock); |
| 14068 | + |
| 14069 | ct->packet_info[IP_CT_DIR_ORIGINAL].bytes = 0; |
| 14070 | ct->packet_info[IP_CT_DIR_ORIGINAL].packets = 0; |
| 14071 | ct->packet_info[IP_CT_DIR_REPLY].bytes = 0; |
| 14072 | ct->packet_info[IP_CT_DIR_REPLY].packets = 0; |
| 14073 | - spin_unlock_bh(&fast_fw_spinlock); |
| 14074 | - } |
| 14075 | - } |
| 14076 | - } |
| 14077 | + } |
| 14078 | + } |
| 14079 | + spin_unlock_bh(&fast_fw_spinlock); |
| 14080 | xt_write_recseq_end(addend); |
| 14081 | local_bh_enable(); |
| 14082 | } |
| 14083 | |
| 14084 | +#if 0 |
| 14085 | +/*ÐÂfastÏÂiptablesͬ²½µÄ´úÂ루±£Áô£©*/ |
| 14086 | +/* Started by AICoder, pid:bc328v3b69u30bb14fea08b4d0be594808c2486b */ |
| 14087 | +static void ct_iptables_bhfunc(unsigned long param) |
| 14088 | +{ |
| 14089 | + unsigned int addend; |
| 14090 | + local_bh_disable(); |
| 14091 | + addend = xt_write_recseq_begin(); |
| 14092 | + spin_lock_bh(&fast_fw_spinlock); |
| 14093 | + for(int hash = 0; hash < nf_conntrack_htable_size; hash++) |
| 14094 | + { |
| 14095 | + struct nf_conntrack_tuple_hash *h; |
| 14096 | + struct hlist_nulls_node *n; |
| 14097 | + for_each_rcu_safe(h, n, &nf_conntrack_hash[hash]) |
| 14098 | + { |
| 14099 | + if(h) |
| 14100 | + { |
| 14101 | + struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h); |
| 14102 | + if(ct->fast_ct.isFast) |
| 14103 | + { |
| 14104 | + struct net *net = nf_ct_net(ct); |
| 14105 | + struct xt_table_info *private; |
| 14106 | + const char *chain_names[] = { |
| 14107 | + "IPTABLE_RAW", |
| 14108 | + "IPTABLE_MANGLE", |
| 14109 | + "IPTABLE_NAT", |
| 14110 | + "IPTABLE_FILTER" |
| 14111 | + }; |
| 14112 | + for (int i = 0; i < 4; i++) { |
| 14113 | + switch (i) { |
| 14114 | + case 0: private = READ_ONCE(net->ipv4.iptable_raw->private); break; |
| 14115 | + case 1: private = READ_ONCE(net->ipv4.iptable_mangle->private); break; |
| 14116 | + case 2: private = READ_ONCE(net->ipv4.nat_table->private); break; |
| 14117 | + case 3: private = READ_ONCE(net->ipv4.iptable_filter->private); break; |
| 14118 | + } |
| 14119 | + ct_iptables_syn_handle(ct, private, chain_names[i]); |
| 14120 | + } |
| 14121 | + } |
| 14122 | + } |
| 14123 | + } |
| 14124 | + } |
| 14125 | + spin_unlock_bh(&fast_fw_spinlock); |
| 14126 | + xt_write_recseq_end(addend); |
| 14127 | + local_bh_enable(); |
| 14128 | +} |
| 14129 | +/* Ended by AICoder, pid:bc328v3b69u30bb14fea08b4d0be594808c2486b */ |
| 14130 | +#endif |
| 14131 | + |
| 14132 | |
| 14133 | int fast4_fw_init(void) |
| 14134 | { |
| 14135 | diff --git a/upstream/linux-5.10/net/core/fastproc/fast6.c b/upstream/linux-5.10/net/core/fastproc/fast6.c |
| 14136 | index d5fab9c..5beebba 100755 |
| 14137 | --- a/upstream/linux-5.10/net/core/fastproc/fast6.c |
| 14138 | +++ b/upstream/linux-5.10/net/core/fastproc/fast6.c |
| 14139 | @@ -207,7 +207,9 @@ |
| 14140 | __u8 next_hdr = 0; |
| 14141 | unsigned char *l4head; |
| 14142 | struct ipv6hdr *ip6; |
| 14143 | - |
| 14144 | + struct sk_buff *skb2 = NULL; |
| 14145 | + int l4_offset = 0; |
| 14146 | + |
| 14147 | print_sun(SUN_DBG, "enter fast_6_recv \n"); |
| 14148 | |
| 14149 | if (fastnat_level == FAST_CLOSE) |
| 14150 | @@ -286,13 +288,18 @@ |
| 14151 | print_sun(SUN_DBG, "fast_6_recv l4head is null \n"); |
| 14152 | return 0; |
| 14153 | } |
| 14154 | - |
| 14155 | - |
| 14156 | - |
| 14157 | - if (!(skb = fast_expand_headroom_v6(skb, dev))){ |
| 14158 | + l4_offset = l4head - skb->data; |
| 14159 | + |
| 14160 | + if (!(skb2 = fast_expand_headroom_v6(skb, dev))){ |
| 14161 | rcu_read_unlock(); |
| 14162 | return 1; |
| 14163 | } |
| 14164 | + |
| 14165 | + if(skb2 != skb){ |
| 14166 | + l4head = skb2->data + l4_offset; |
| 14167 | + skb = skb2; |
| 14168 | + skb_expand6++; |
| 14169 | + } |
| 14170 | |
| 14171 | fast_tcpdump(skb); |
| 14172 | |
| 14173 | @@ -316,8 +323,30 @@ |
| 14174 | skb->isFastnat = 1; |
| 14175 | skb->priority = fast6_entry_data->priority; |
| 14176 | skb->mark = fast6_entry_data->mark; |
| 14177 | - |
| 14178 | - |
| 14179 | + if (likely(skb_get_nfct(skb) == 0)){ |
| 14180 | + skb_set_nfct(skb, (unsigned long)fast6_entry->ct); |
| 14181 | + nf_conntrack_get(&fast6_entry->ct->ct_general); |
| 14182 | + } |
| 14183 | + spin_lock_bh(&fast_fw_spinlock); |
| 14184 | + //»ùÓÚctÁ´½ÓµÄÁ÷Á¿Í³¼Æ --- ͳ¼ÆIP°ü²»ÊÇMAC°ü |
| 14185 | + if (fast6_entry_data->tuplehash.tuple.dst.dir == IP_CT_DIR_ORIGINAL){ |
| 14186 | + fast6_entry->ct->packet_info[IP_CT_DIR_ORIGINAL].packets++; |
| 14187 | + fast6_entry->ct->packet_info[IP_CT_DIR_ORIGINAL].bytes += skb->len; |
| 14188 | + if(unlikely(fast6_entry->ct->indev[IP_CT_DIR_ORIGINAL] == NULL)) |
| 14189 | + fast6_entry->ct->indev[IP_CT_DIR_ORIGINAL] = skb->indev; |
| 14190 | + if(unlikely(fast6_entry->ct->outdev[IP_CT_DIR_ORIGINAL] == NULL)) |
| 14191 | + fast6_entry->ct->outdev[IP_CT_DIR_ORIGINAL] = dev; |
| 14192 | + } else if (fast6_entry_data->tuplehash.tuple.dst.dir == IP_CT_DIR_REPLY){ |
| 14193 | + fast6_entry->ct->packet_info[IP_CT_DIR_REPLY].packets++; |
| 14194 | + fast6_entry->ct->packet_info[IP_CT_DIR_REPLY].bytes += skb->len; |
| 14195 | + if(unlikely(fast6_entry->ct->indev[IP_CT_DIR_REPLY] == NULL)) |
| 14196 | + fast6_entry->ct->indev[IP_CT_DIR_REPLY] = skb->indev; |
| 14197 | + if(unlikely(fast6_entry->ct->outdev[IP_CT_DIR_REPLY] == NULL)) |
| 14198 | + fast6_entry->ct->outdev[IP_CT_DIR_REPLY] = dev; |
| 14199 | + } else { |
| 14200 | + printk("fast6 packet error\n"); |
| 14201 | + } |
| 14202 | + spin_unlock_bh(&fast_fw_spinlock); |
| 14203 | //ÄÚºË×Ô´øµÄ»ùÓÚÁ´½ÓµÄÁ÷Á¿Í³¼Æ |
| 14204 | struct nf_conn_counter *acct = (struct nf_conn_counter*)nf_conn_acct_find(fast6_entry->ct); |
| 14205 | if (acct) { |
| 14206 | @@ -348,7 +377,8 @@ |
| 14207 | |
| 14208 | //Ö»Óе±ÓÐMACÍ·Ô¤¸³ÖµÊ±£¬²Å×¼¸³Öµ£¬·ñÔòΪIPÍ· |
| 14209 | skb_push(skb, ETH_HLEN); |
| 14210 | - |
| 14211 | + |
| 14212 | + if (fast6_entry_data->hh_flag) |
| 14213 | memcpy(skb->data, fast6_entry_data->hh_data, ETH_HLEN); |
| 14214 | /*¸üÐÂÁ¬½Ó³¬Ê±*/ |
| 14215 | if (IPPROTO_TCP == tuple.dst.protonum) |
| 14216 | @@ -470,12 +500,12 @@ |
| 14217 | return NF_ACCEPT; |
| 14218 | } |
| 14219 | _neighbour = dst_neigh_lookup_skb(dst, skb); |
| 14220 | - if(!_neighbour) |
| 14221 | - { |
| 14222 | - return NF_ACCEPT; |
| 14223 | + if(_neighbour == NULL && ((ipv6_addr_type(&ipv6_hdr(skb)->daddr)) == IPV6_ADDR_ANY |
| 14224 | + || ((ipv6_addr_type(&ipv6_hdr(skb)->daddr)) & IPV6_ADDR_LOOPBACK))){ |
| 14225 | + return NF_ACCEPT; |
| 14226 | } |
| 14227 | |
| 14228 | - if (memcmp(_neighbour->ha, zeromac, ETH_ALEN) == 0) |
| 14229 | + if (_neighbour && memcmp(_neighbour->ha, zeromac, ETH_ALEN) == 0) |
| 14230 | { |
| 14231 | goto accept; |
| 14232 | } |
| 14233 | @@ -536,9 +566,10 @@ |
| 14234 | fast6_entry_data = &fast6_entry->data[dir]; |
| 14235 | fast6_entry_data->tuplehash.tuple = ct->tuplehash[dir].tuple; |
| 14236 | |
| 14237 | - memcpy(fast6_entry_data->dmac, _neighbour->ha, ETH_ALEN); |
| 14238 | + //memcpy(fast6_entry_data->dmac, _neighbour->ha, ETH_ALEN); |
| 14239 | fast6_entry_data->priority = skb->priority; |
| 14240 | fast6_entry_data->mark = skb->mark; |
| 14241 | + if(fast6_entry_data->outdev == NULL){ |
| 14242 | fast6_entry_data->outdev = out; |
| 14243 | |
| 14244 | if (!record_MAC_header(working_hash6, ct, fast6_entry, fast6_entry_data, _neighbour, out, htons(ETH_P_IPV6))) |
| 14245 | @@ -546,7 +577,7 @@ |
| 14246 | spin_unlock_bh(&fast6_spinlock); |
| 14247 | goto accept; |
| 14248 | } |
| 14249 | - |
| 14250 | + } |
| 14251 | //´Ë´¦±£Ö¤Õý·´Á½¸ö±ê¼Çλ²»³åÍ» |
| 14252 | fast6_entry->flags = fast6_entry->flags | (1 << dir); |
| 14253 | |
| 14254 | @@ -563,7 +594,7 @@ |
| 14255 | ct->fast_ct.isFast = FAST_CT_WND6; |
| 14256 | |
| 14257 | accept: |
| 14258 | - |
| 14259 | + if(_neighbour) |
| 14260 | neigh_release(_neighbour); |
| 14261 | return NF_ACCEPT; |
| 14262 | } |
| 14263 | diff --git a/upstream/linux-5.10/net/core/fastproc/fast6_fw.c b/upstream/linux-5.10/net/core/fastproc/fast6_fw.c |
| 14264 | index 322175b..ec21bc6 100755 |
| 14265 | --- a/upstream/linux-5.10/net/core/fastproc/fast6_fw.c |
| 14266 | +++ b/upstream/linux-5.10/net/core/fastproc/fast6_fw.c |
| 14267 | @@ -40,8 +40,23 @@ |
| 14268 | #include <net/SI/net_cache.h> |
| 14269 | #include <net/SI/print_sun.h> |
| 14270 | |
| 14271 | +#include <linux/netfilter/xt_tcpudp.h> |
| 14272 | +#include <linux/netfilter_ipv6/ip6_tables.h> |
| 14273 | + |
| 14274 | + |
| 14275 | MODULE_LICENSE("GPL"); |
| 14276 | |
| 14277 | +static struct task_struct *ct_ip6tables_syn; |
| 14278 | +static struct tasklet_struct ct_ip6tables_bh; |
| 14279 | +extern unsigned int ct_iptables_syn_sw; |
| 14280 | +enum table6_index { |
| 14281 | + IP6TABLE_RAW, |
| 14282 | + IP6TABLE_MANGLE, |
| 14283 | + IP6TABLE_NAT, |
| 14284 | + IP6TABLE_FILTER |
| 14285 | +}; |
| 14286 | + |
| 14287 | + |
| 14288 | /* ***************** ipv6 ¿ìËÙת·¢Ïà¹Ø±äÁ¿ ************************* */ |
| 14289 | |
| 14290 | |
| 14291 | @@ -53,6 +68,7 @@ |
| 14292 | |
| 14293 | int dst_expire_count_v6 = 0; |
| 14294 | extern int no_neighbour; |
| 14295 | +extern fast_list_t working_list6; |
| 14296 | extern void ntl_ct_set_iw(struct sk_buff *skb, struct nf_conn *ct, int ct_dir); |
| 14297 | int fast6_fw_recv(struct nf_conn *tmpl, |
| 14298 | struct sk_buff *skb, |
| 14299 | @@ -163,7 +179,8 @@ |
| 14300 | skb->isFastnat = 1; |
| 14301 | nf_ct_set(skb, (struct nf_conn *)&ct->ct_general, ctinfo); |
| 14302 | |
| 14303 | - |
| 14304 | + ct->packet_info[dir].packets++; |
| 14305 | + ct->packet_info[dir].bytes += skb->len; |
| 14306 | //»ùÓÚÍø¿ÚµÄÁ÷Á¿Í³¼Æ --- ²Î¿¼linuxÔÉúµÄÇý¶¯£¬Í³¼ÆµÄ¶¼ÊÇIP°ü³¤¶È |
| 14307 | if (fastnat_level == FAST_NET_DEVICE) |
| 14308 | { |
| 14309 | @@ -203,6 +220,17 @@ |
| 14310 | } |
| 14311 | skb->dev = dev; |
| 14312 | skb->now_location |= FASTNAT_SUCC; |
| 14313 | + |
| 14314 | + if(ct->indev[dir] == NULL && skb->indev != NULL) |
| 14315 | + { |
| 14316 | + ct->indev[dir] = skb->indev; |
| 14317 | + } |
| 14318 | + |
| 14319 | + if(ct->outdev[dir] == NULL && skb->dev != NULL) |
| 14320 | + { |
| 14321 | + ct->outdev[dir] = skb->dev; |
| 14322 | + } |
| 14323 | + |
| 14324 | skb->vlan_proto = vlan_proto_raw; |
| 14325 | skb->vlan_tci = vlan_tci_raw; |
| 14326 | __flush_dcache_area(skb->data, skb->len); |
| 14327 | @@ -370,6 +398,372 @@ |
| 14328 | .priority = NF_IP6_PRI_LAST, |
| 14329 | }; |
| 14330 | |
| 14331 | +static inline bool |
| 14332 | +port_match(u_int16_t min, u_int16_t max, u_int16_t port, bool invert) |
| 14333 | +{ |
| 14334 | + return (port >= min && port <= max) ^ invert; |
| 14335 | +} |
| 14336 | + |
| 14337 | +static bool ctable_mt(struct nf_conn* ct, struct xt_action_param *par,int dir, int* match_filter) |
| 14338 | +{ |
| 14339 | + const struct xt_tcp *tcpinfo = par->matchinfo; |
| 14340 | + |
| 14341 | + if (!port_match(tcpinfo->spts[0], tcpinfo->spts[1], |
| 14342 | + ntohs(ct->tuplehash[dir].tuple.src.u.tcp.port), |
| 14343 | + !!(tcpinfo->invflags & XT_TCP_INV_SRCPT))) |
| 14344 | + return false; |
| 14345 | + if((tcpinfo->spts[0] || tcpinfo->spts[1]) ^ (!!(tcpinfo->invflags & XT_TCP_INV_SRCPT))) |
| 14346 | + *match_filter = 1; |
| 14347 | + if (!port_match(tcpinfo->dpts[0], tcpinfo->dpts[1], |
| 14348 | + ntohs(ct->tuplehash[dir].tuple.dst.u.tcp.port), |
| 14349 | + !!(tcpinfo->invflags & XT_TCP_INV_DSTPT))) |
| 14350 | + return false; |
| 14351 | + if((tcpinfo->dpts[0] || tcpinfo->dpts[1]) ^ (!!(tcpinfo->invflags & XT_TCP_INV_DSTPT))) |
| 14352 | + *match_filter = 1; |
| 14353 | + return true; |
| 14354 | +} |
| 14355 | + |
| 14356 | +static inline bool |
| 14357 | +ip6_packet_match(const struct ip6t_ip6 *ip6info,struct nf_conn* ct,int dir, int* match_filter) |
| 14358 | +{ |
| 14359 | + unsigned long ret; |
| 14360 | + if (NF_INVF(ip6info, IP6T_INV_SRCIP, |
| 14361 | + ipv6_masked_addr_cmp((struct in6_addr *)(ct->tuplehash[dir].tuple.src.u3.ip6), &ip6info->smsk, |
| 14362 | + &ip6info->src)) || |
| 14363 | + NF_INVF(ip6info, IP6T_INV_DSTIP, |
| 14364 | + ipv6_masked_addr_cmp((struct in6_addr *)(ct->tuplehash[dir].tuple.dst.u3.ip6), &ip6info->dmsk, |
| 14365 | + &ip6info->dst))) |
| 14366 | + return false; |
| 14367 | + if(ip6info->src.in6_u.u6_addr32[0] || ip6info->dst.in6_u.u6_addr32[0]) |
| 14368 | + { |
| 14369 | + *match_filter = 1; |
| 14370 | + } |
| 14371 | + |
| 14372 | + if(ct->indev[dir] != NULL) |
| 14373 | + { |
| 14374 | + ret = ifname_compare_aligned(ct->indev[dir]->name, ip6info->iniface, ip6info->iniface_mask); |
| 14375 | + } |
| 14376 | + else |
| 14377 | + { |
| 14378 | + ret=1; |
| 14379 | + } |
| 14380 | + |
| 14381 | + if(ip6info->iniface[0] != '\0') |
| 14382 | + *match_filter = 1; |
| 14383 | + |
| 14384 | + if (NF_INVF(ip6info, IP6T_INV_VIA_IN, ret != 0)) |
| 14385 | + return false; |
| 14386 | + if(ct->outdev[dir] != NULL) |
| 14387 | + { |
| 14388 | + ret = ifname_compare_aligned(ct->outdev[dir]->name, ip6info->outiface, ip6info->outiface_mask); |
| 14389 | + } |
| 14390 | + |
| 14391 | + if(ip6info->outiface[0] != '\0') |
| 14392 | + *match_filter = 1; |
| 14393 | + |
| 14394 | + if (NF_INVF(ip6info, IP6T_INV_VIA_OUT, ret != 0)) |
| 14395 | + return false; |
| 14396 | + |
| 14397 | + if (ip6info->flags & IP6T_F_PROTO) { |
| 14398 | + int protohdr; |
| 14399 | + |
| 14400 | + protohdr = ct->tuplehash[dir].tuple.dst.protonum; |
| 14401 | + |
| 14402 | + if (ip6info->proto == protohdr) { |
| 14403 | + if (ip6info->invflags & IP6T_INV_PROTO) |
| 14404 | + return false; |
| 14405 | + |
| 14406 | + return true; |
| 14407 | + } |
| 14408 | + |
| 14409 | + /* We need match for the '-p all', too! */ |
| 14410 | + if ((ip6info->proto != 0) && |
| 14411 | + !(ip6info->invflags & IP6T_INV_PROTO)) |
| 14412 | + return false; |
| 14413 | + } |
| 14414 | + |
| 14415 | + return true; |
| 14416 | +} |
| 14417 | + |
| 14418 | +static inline bool |
| 14419 | +ip6_packet_match_neg(const struct ip6t_ip6 *ip6info,struct nf_conn* ct,int dir, int* match_filter) |
| 14420 | +{ |
| 14421 | + unsigned long ret; |
| 14422 | + if(!(ct->status & IPS_NAT_MASK)) |
| 14423 | + return false; |
| 14424 | + if (NF_INVF(ip6info, IP6T_INV_SRCIP, |
| 14425 | + ipv6_masked_addr_cmp((struct in6_addr *)ct->tuplehash[dir].tuple.src.u3.ip6, &ip6info->smsk, |
| 14426 | + &ip6info->src)) || |
| 14427 | + NF_INVF(ip6info, IP6T_INV_DSTIP, |
| 14428 | + ipv6_masked_addr_cmp((struct in6_addr *)ct->tuplehash[dir].tuple.dst.u3.ip6, &ip6info->dmsk, |
| 14429 | + &ip6info->dst))) |
| 14430 | + return false; |
| 14431 | + if(ip6info->src.in6_u.u6_addr32[0] || ip6info->dst.in6_u.u6_addr32[0]) |
| 14432 | + *match_filter = 1; |
| 14433 | + |
| 14434 | + if(ct->outdev[dir] != NULL) |
| 14435 | + { |
| 14436 | + ret = ifname_compare_aligned(ct->outdev[dir]->name, ip6info->iniface, ip6info->iniface_mask); |
| 14437 | + } |
| 14438 | + else |
| 14439 | + { |
| 14440 | + ret = 1; |
| 14441 | + } |
| 14442 | + |
| 14443 | + if(ip6info->iniface[0] != '\0') |
| 14444 | + *match_filter = 1; |
| 14445 | + |
| 14446 | + if (NF_INVF(ip6info, IP6T_INV_VIA_IN, ret != 0)) |
| 14447 | + return false; |
| 14448 | + if(ct->indev[dir] != NULL) |
| 14449 | + { |
| 14450 | + ret = ifname_compare_aligned(ct->indev[dir]->name, ip6info->outiface, ip6info->outiface_mask); |
| 14451 | + } |
| 14452 | + |
| 14453 | + if(ip6info->outiface[0] != '\0') |
| 14454 | + *match_filter = 1; |
| 14455 | + |
| 14456 | + if (NF_INVF(ip6info, IP6T_INV_VIA_OUT, ret != 0)) |
| 14457 | + return false; |
| 14458 | + |
| 14459 | + if (ip6info->flags & IP6T_F_PROTO) { |
| 14460 | + int protohdr; |
| 14461 | + |
| 14462 | + protohdr = ct->tuplehash[dir].tuple.dst.protonum; |
| 14463 | + |
| 14464 | + if (ip6info->proto == protohdr) { |
| 14465 | + if (ip6info->invflags & IP6T_INV_PROTO) |
| 14466 | + return false; |
| 14467 | + |
| 14468 | + return true; |
| 14469 | + } |
| 14470 | + |
| 14471 | + /* We need match for the '-p all', too! */ |
| 14472 | + if ((ip6info->proto != 0) && |
| 14473 | + !(ip6info->invflags & IP6T_INV_PROTO)) |
| 14474 | + return false; |
| 14475 | + } |
| 14476 | + |
| 14477 | + return true; |
| 14478 | +} |
| 14479 | + |
| 14480 | +static inline struct ip6t_entry * |
| 14481 | +get_entry(const void *base, unsigned int offset) |
| 14482 | +{ |
| 14483 | + return (struct ip6t_entry *)(base + offset); |
| 14484 | +} |
| 14485 | + |
| 14486 | +static inline |
| 14487 | +struct ip6t_entry *ip6t_next_entry(const struct ip6t_entry *entry) |
| 14488 | +{ |
| 14489 | + return (void *)entry + entry->next_offset; |
| 14490 | +} |
| 14491 | + |
| 14492 | + |
| 14493 | + |
| 14494 | +//ͬ²½ctͳ¼ÆÐÅÏ¢µ½iptables,ͬ²½ÖÜÆÚÔݶ¨1s |
| 14495 | +static int ct_ip6tables_syn_thread(void *param) |
| 14496 | +{ |
| 14497 | + while (1) |
| 14498 | + { |
| 14499 | + if(ct_iptables_syn_sw) |
| 14500 | + { |
| 14501 | + rcu_read_lock(); |
| 14502 | + tasklet_schedule(&ct_ip6tables_bh); |
| 14503 | + rcu_read_unlock(); |
| 14504 | + //ÿ´Îͬ²½¼ä¸ôΪ1s. |
| 14505 | + } |
| 14506 | + msleep(1*1000); |
| 14507 | + } |
| 14508 | + return 0; |
| 14509 | +} |
| 14510 | + |
| 14511 | +void ct_ip6tables_syn_handle(struct nf_conn *ct,struct xt_table_info *private,int table_id) |
| 14512 | +{ |
| 14513 | + void *table_base; |
| 14514 | + struct ip6t_entry *e; |
| 14515 | + const struct xt_entry_match *ematch; |
| 14516 | + struct xt_action_param acpar; |
| 14517 | + struct xt_counters *counter; |
| 14518 | + int match_flag = 0; |
| 14519 | + int match_filter = 0; |
| 14520 | + int num = 0; |
| 14521 | + |
| 14522 | + |
| 14523 | + table_base = private->entries; |
| 14524 | + num = private->number; |
| 14525 | + switch(table_id) |
| 14526 | + { |
| 14527 | + case 0: |
| 14528 | + case 1: |
| 14529 | + case 2: |
| 14530 | + e = get_entry(table_base, private->hook_entry[NF_INET_PRE_ROUTING]); |
| 14531 | + break; |
| 14532 | + case 3: |
| 14533 | + e = get_entry(table_base, private->hook_entry[NF_INET_LOCAL_IN]); |
| 14534 | + break; |
| 14535 | + default: |
| 14536 | + return; |
| 14537 | + } |
| 14538 | + while(num--) |
| 14539 | + { |
| 14540 | + match_flag = 0; |
| 14541 | + match_filter = 0; |
| 14542 | + if(!ip6_packet_match(&e->ipv6, ct, IP_CT_DIR_ORIGINAL,&match_filter) && |
| 14543 | + !ip6_packet_match_neg(&e->ipv6, ct, IP_CT_DIR_REPLY,&match_filter)) |
| 14544 | + { |
| 14545 | + } |
| 14546 | + else |
| 14547 | + { |
| 14548 | + xt_ematch_foreach(ematch, e) |
| 14549 | + { |
| 14550 | + acpar.matchinfo = ematch->data; |
| 14551 | + if (!ctable_mt(ct, &acpar, IP_CT_DIR_ORIGINAL,&match_filter)) |
| 14552 | + { |
| 14553 | + match_flag = 1; |
| 14554 | + break; |
| 14555 | + } |
| 14556 | + else |
| 14557 | + { |
| 14558 | + } |
| 14559 | + } |
| 14560 | + if(!match_flag) |
| 14561 | + { |
| 14562 | + if(match_filter) |
| 14563 | + { |
| 14564 | + counter = xt_get_this_cpu_counter(&e->counters); |
| 14565 | + ADD_COUNTER(*counter, ct->packet_info[IP_CT_DIR_ORIGINAL].bytes,ct->packet_info[IP_CT_DIR_ORIGINAL].packets); |
| 14566 | + } |
| 14567 | + e = ip6t_next_entry(e); |
| 14568 | + continue; |
| 14569 | + } |
| 14570 | + match_flag = 0; |
| 14571 | + match_filter = 0; |
| 14572 | + } |
| 14573 | + |
| 14574 | + if (!ip6_packet_match(&e->ipv6, ct, IP_CT_DIR_REPLY,&match_filter) && |
| 14575 | + !ip6_packet_match_neg(&e->ipv6, ct, IP_CT_DIR_ORIGINAL,&match_filter)) |
| 14576 | + { |
| 14577 | + e = ip6t_next_entry(e); |
| 14578 | + continue; |
| 14579 | + } |
| 14580 | + else |
| 14581 | + { |
| 14582 | + xt_ematch_foreach(ematch, e) |
| 14583 | + { |
| 14584 | + acpar.matchinfo = ematch->data; |
| 14585 | + if (!ctable_mt(ct, &acpar, IP_CT_DIR_REPLY,&match_filter)) |
| 14586 | + { |
| 14587 | + match_flag = 1; |
| 14588 | + break; |
| 14589 | + } |
| 14590 | + } |
| 14591 | + if(!match_flag) |
| 14592 | + { |
| 14593 | + if(match_filter) |
| 14594 | + { |
| 14595 | + counter = xt_get_this_cpu_counter(&e->counters); |
| 14596 | + ADD_COUNTER(*counter, ct->packet_info[IP_CT_DIR_REPLY].bytes,ct->packet_info[IP_CT_DIR_REPLY].packets); |
| 14597 | + } |
| 14598 | + e = ip6t_next_entry(e); |
| 14599 | + continue; |
| 14600 | + } |
| 14601 | + } |
| 14602 | + } |
| 14603 | + |
| 14604 | +} |
| 14605 | + |
| 14606 | +static void ct_ip6tables_bhfunc(unsigned long param) |
| 14607 | +{ |
| 14608 | + fast_entry_t *ret = NULL; |
| 14609 | + struct hlist_nulls_node *n; |
| 14610 | + struct nf_conn *ct; |
| 14611 | + struct xt_table_info *private; |
| 14612 | + struct net * net; |
| 14613 | + unsigned int addend; |
| 14614 | + local_bh_disable(); |
| 14615 | + addend = xt_write_recseq_begin(); |
| 14616 | + spin_lock_bh(&fast_fw_spinlock); |
| 14617 | + for (ret = (&working_list6)->next; ret; ret = ret->next) |
| 14618 | + { |
| 14619 | + if(ret) |
| 14620 | + { |
| 14621 | + ct = ret->ct; |
| 14622 | + if(ct->fast_ct.isFast) |
| 14623 | + { |
| 14624 | + net = nf_ct_net(ct); |
| 14625 | + private = READ_ONCE(net->ipv6.ip6table_raw->private); |
| 14626 | + ct_ip6tables_syn_handle(ct,private,IP6TABLE_RAW); |
| 14627 | + private = READ_ONCE(net->ipv6.ip6table_mangle->private); |
| 14628 | + ct_ip6tables_syn_handle(ct,private,IP6TABLE_MANGLE); |
| 14629 | + private = READ_ONCE(net->ipv6.ip6table_nat->private); |
| 14630 | + ct_ip6tables_syn_handle(ct,private,IP6TABLE_NAT); |
| 14631 | + private = READ_ONCE(net->ipv6.ip6table_filter->private); |
| 14632 | + ct_ip6tables_syn_handle(ct,private,IP6TABLE_FILTER); |
| 14633 | + } |
| 14634 | + else |
| 14635 | + continue; |
| 14636 | + |
| 14637 | + ct->packet_info[IP_CT_DIR_ORIGINAL].bytes = 0; |
| 14638 | + ct->packet_info[IP_CT_DIR_ORIGINAL].packets = 0; |
| 14639 | + ct->packet_info[IP_CT_DIR_REPLY].bytes = 0; |
| 14640 | + ct->packet_info[IP_CT_DIR_REPLY].packets = 0; |
| 14641 | + } |
| 14642 | + } |
| 14643 | + spin_unlock_bh(&fast_fw_spinlock); |
| 14644 | + xt_write_recseq_end(addend); |
| 14645 | + local_bh_enable(); |
| 14646 | +} |
| 14647 | + |
| 14648 | +#if 0 |
| 14649 | +/*ÐÂfast ip6tablesÁ÷Á¿Í¬²½´úÂë,±£Áô*/ |
| 14650 | +/* Started by AICoder, pid:b1b62d7ef7md76714807099a103c224334833109 */ |
| 14651 | +static void ct_ip6tables_bhfunc(unsigned long param) |
| 14652 | +{ |
| 14653 | + int hash; |
| 14654 | + struct nf_conn *ct; |
| 14655 | + struct xt_table_info *private; |
| 14656 | + struct net *net; |
| 14657 | + unsigned int addend; |
| 14658 | + local_bh_disable(); |
| 14659 | + addend = xt_write_recseq_begin(); |
| 14660 | + for(hash = 0; hash < nf_conntrack_htable_size; hash++) |
| 14661 | + { |
| 14662 | + struct nf_conntrack_tuple_hash *h; |
| 14663 | + struct hlist_nulls_node *n; |
| 14664 | + hlist_nulls_for_each_entry_rcu(h, n, &nf_conntrack_hash[hash], hnnode) |
| 14665 | + { |
| 14666 | + if(h) |
| 14667 | + { |
| 14668 | + ct = nf_ct_tuplehash_to_ctrack(h); |
| 14669 | + if(ct->fast_ct.isFast) |
| 14670 | + { |
| 14671 | + net = nf_ct_net(ct); |
| 14672 | + private = READ_ONCE(net->ipv6.ip6table_raw->private); |
| 14673 | + ct_ip6tables_syn_handle(ct, private, IP6TABLE_RAW); |
| 14674 | + private = READ_ONCE(net->ipv6.ip6table_mangle->private); |
| 14675 | + ct_ip6tables_syn_handle(ct, private, IP6TABLE_MANGLE); |
| 14676 | + private = READ_ONCE(net->ipv6.ip6table_nat->private); |
| 14677 | + ct_ip6tables_syn_handle(ct, private, IP6TABLE_NAT); |
| 14678 | + private = READ_ONCE(net->ipv6.ip6table_filter->private); |
| 14679 | + ct_ip6tables_syn_handle(ct, private, IP6TABLE_FILTER); |
| 14680 | + spin_lock_bh(&fast_fw_spinlock); |
| 14681 | + for(int i = 0; i < 4; i++) |
| 14682 | + { |
| 14683 | + ct->packet_info[i].bytes = 0; |
| 14684 | + ct->packet_info[i].packets = 0; |
| 14685 | + } |
| 14686 | + spin_unlock_bh(&fast_fw_spinlock); |
| 14687 | + } |
| 14688 | + } |
| 14689 | + } |
| 14690 | + } |
| 14691 | + xt_write_recseq_end(addend); |
| 14692 | + local_bh_enable(); |
| 14693 | +} |
| 14694 | +/* Ended by AICoder, pid:b1b62d7ef7md76714807099a103c224334833109 */ |
| 14695 | +#endif |
| 14696 | + |
| 14697 | |
| 14698 | int fast6_fw_init(void) |
| 14699 | { |
| 14700 | @@ -383,6 +777,14 @@ |
| 14701 | } |
| 14702 | print_sun(SUN_DBG,"init fast6_fw_init done\n"); |
| 14703 | |
| 14704 | + ct_ip6tables_bh.func = ct_ip6tables_bhfunc; |
| 14705 | + ct_ip6tables_syn = kthread_create(ct_ip6tables_syn_thread, (void *)0, "ct_ip6tables_syn" ); |
| 14706 | + if (!IS_ERR(ct_ip6tables_syn)) |
| 14707 | + { |
| 14708 | + printk("ntl_syn_task thread's init is succ"); |
| 14709 | + wake_up_process(ct_ip6tables_syn); |
| 14710 | + } |
| 14711 | + |
| 14712 | return 0; |
| 14713 | } |
| 14714 | |
| 14715 | @@ -390,6 +792,12 @@ |
| 14716 | { |
| 14717 | fast_release_all(RELEASE_ALL_DST); |
| 14718 | nf_unregister_net_hook(&init_net, &fast6_fw_hook); |
| 14719 | + if (ct_ip6tables_syn) |
| 14720 | + { |
| 14721 | + kthread_stop(ct_ip6tables_syn); |
| 14722 | + ct_ip6tables_syn = NULL; |
| 14723 | + } |
| 14724 | + tasklet_kill(&ct_ip6tables_bh); |
| 14725 | return 0; |
| 14726 | } |
| 14727 | |
| 14728 | diff --git a/upstream/linux-5.10/net/core/fastproc/fast_common.c b/upstream/linux-5.10/net/core/fastproc/fast_common.c |
| 14729 | index 69f3761..80ad864 100755 |
| 14730 | --- a/upstream/linux-5.10/net/core/fastproc/fast_common.c |
| 14731 | +++ b/upstream/linux-5.10/net/core/fastproc/fast_common.c |
| 14732 | @@ -621,7 +621,7 @@ |
| 14733 | |
| 14734 | //²Î¿¼ip6_xmit,À©³äskbÍ·²¿ |
| 14735 | struct sk_buff *fast_expand_headroom_v6(struct sk_buff *skb, struct net_device *dev) { |
| 14736 | - unsigned int hh_len = LL_RESERVED_SPACE(dev) + sizeof(struct ipv6hdr); |
| 14737 | + unsigned int hh_len = LL_RESERVED_SPACE(dev);//EC616000622279½â¾öv6ÉÏÐÐÊý¾Ý°üÓÉÓÚÍ·¿Õ¼ä²»¹»ÖØÐÂÉêÇëµÄÎÊÌâ + sizeof(struct ipv6hdr); |
| 14738 | struct sk_buff *skb2 = NULL; |
| 14739 | if (unlikely(skb_headroom(skb) < hh_len)) { |
| 14740 | skb2 = skb_realloc_headroom(skb, max(hh_len, NET_SKB_PAD)); |
| 14741 | @@ -726,6 +726,9 @@ |
| 14742 | { |
| 14743 | tcpack_rel(entry); |
| 14744 | //nf_ct_put(entry->ct); |
| 14745 | + spin_lock_bh(&fast_fw_spinlock); |
| 14746 | + entry->ct->fast_entry = NULL; |
| 14747 | + spin_unlock_bh(&fast_fw_spinlock); |
| 14748 | atomic_dec(&(entry->ct->ct_general.use)); |
| 14749 | fn_list_del(list_head, entry); |
| 14750 | } |
| 14751 | @@ -810,6 +813,7 @@ |
| 14752 | netslab_inc(FAST_SLAB); |
| 14753 | memset(ret, 0, sizeof(fast_entry_t)); |
| 14754 | ret->ct = ct; |
| 14755 | + ct->fast_entry = ret; |
| 14756 | ret->list_head = list_head; |
| 14757 | |
| 14758 | //ÉèÖö¨Ê±Æ÷ |
| 14759 | @@ -897,7 +901,7 @@ |
| 14760 | goto REL; |
| 14761 | |
| 14762 | //½ö¶ÔÒÔÌ«ÍøÀàÍø¿Ú½øÐÐMACÍ·Ô¤¸³Öµ£¬ÆäËüµÄÈçPPP¡¢PPPoEÕâЩ£¬½ÔÊǿɱäµÄ£¬²»ÄÜÔ¤¸³Öµ£»²Î¼ûalloc_netdevºÍalloc_etherdev½Ó¿Ú |
| 14763 | - if (out->type != ARPHRD_ETHER) |
| 14764 | + if (out->type != ARPHRD_ETHER || neigh == NULL) |
| 14765 | return 1; |
| 14766 | |
| 14767 | //¶ÔÓÚ³ö¿ÚÎªÍøÇÅbrʱ£¬Ö±½Ó»ñÈ¡L2ÍøÂçÉ豸£¬¼´usb0»òwifi0 |
| 14768 | @@ -906,7 +910,7 @@ |
| 14769 | if(out->dev_addr == NULL) |
| 14770 | goto REL; |
| 14771 | |
| 14772 | - if (fastbr_level == 1) |
| 14773 | + if (fastbr_level) |
| 14774 | { |
| 14775 | dst_out = getbrport_bydst(out, neigh->ha); |
| 14776 | if (dst_out == NULL) |
| 14777 | @@ -964,6 +968,9 @@ |
| 14778 | //»Ö¸´ctµÄ³¬Ê± |
| 14779 | //add_timer(&ct->timeout); |
| 14780 | //nf_ct_put(ct); |
| 14781 | + spin_lock_bh(&fast_fw_spinlock); |
| 14782 | + entry->ct->fast_entry = NULL; |
| 14783 | + spin_unlock_bh(&fast_fw_spinlock); |
| 14784 | atomic_dec(&(ct->ct_general.use)); |
| 14785 | del_timer(&entry->timeout); |
| 14786 | fn_list_del(entry->list_head, entry); |
| 14787 | @@ -1079,7 +1086,9 @@ |
| 14788 | del_timer(&entry->timeout); |
| 14789 | |
| 14790 | workinghash_del_node(entry); |
| 14791 | - |
| 14792 | + spin_lock_bh(&fast_fw_spinlock); |
| 14793 | + entry->ct->fast_entry = NULL; |
| 14794 | + spin_unlock_bh(&fast_fw_spinlock); |
| 14795 | //»Ö¸´ctµÄ³¬Ê± |
| 14796 | //add_timer(&entry->ct->timeout); |
| 14797 | fn_list_del(list_head, entry); |
| 14798 | @@ -1552,7 +1561,7 @@ |
| 14799 | return 1; |
| 14800 | } |
| 14801 | //vlan |
| 14802 | - else if (next_pro == cpu_to_be16(ETH_P_8021Q)) |
| 14803 | + else if (next_pro == cpu_to_be16(ETH_P_8021Q) && fastbr_level == 1) |
| 14804 | { |
| 14805 | skb->isvlan = 1; |
| 14806 | skb_pull(skb, VLAN_HLEN); |
| 14807 | @@ -1591,7 +1600,7 @@ |
| 14808 | //if (((unsigned long)skb->data)%4 != 0) |
| 14809 | //panic("ERR: fast from dev skb->data%4 != 0"); |
| 14810 | |
| 14811 | - if (skb->indev == NULL) |
| 14812 | + if (skb->indev == NULL || is_vlan_dev(skb->dev)) |
| 14813 | skb->indev = skb->dev; |
| 14814 | //ÐèҪ׼ȷ¶¨Î»µ½IPÍ·£¬ÆÚ¼ä¿ÉÄÜÌø¹ýppp/mac/pppoeµÈ¸÷ÖÖ²ã2Í·²¿ |
| 14815 | if (set_skbdata_toip(skb) == 1 && fast_for_ipdata(skb)) |
| 14816 | @@ -2055,6 +2064,21 @@ |
| 14817 | return dst; |
| 14818 | } |
| 14819 | |
| 14820 | +void fast_update_indev(struct sk_buff *skb, struct net_device *dev) |
| 14821 | +{ |
| 14822 | + if(fastbr_level != 1 && skb->isFastnat == 1){ |
| 14823 | + enum ip_conntrack_info ctinfo; |
| 14824 | + struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
| 14825 | + |
| 14826 | + if(ct){ |
| 14827 | + if(ct->indev[0] == skb->indev && ct->indev[1] == NULL) |
| 14828 | + ct->indev[1] = dev; |
| 14829 | + if(ct->indev[1] == skb->indev && ct->indev[0] == NULL) |
| 14830 | + ct->indev[0] = dev; |
| 14831 | + } |
| 14832 | + } |
| 14833 | +} |
| 14834 | + |
| 14835 | /*fast³õʼ»¯*/ |
| 14836 | static int __init |
| 14837 | tsp_fast_init(void) |
| 14838 | diff --git a/upstream/linux-5.10/net/core/fastproc/fast_track.c b/upstream/linux-5.10/net/core/fastproc/fast_track.c |
| 14839 | index 37f3cfc..712ff6d 100755 |
| 14840 | --- a/upstream/linux-5.10/net/core/fastproc/fast_track.c |
| 14841 | +++ b/upstream/linux-5.10/net/core/fastproc/fast_track.c |
| 14842 | @@ -234,7 +234,7 @@ |
| 14843 | if (copy_from_user(char_fastbr, buffer, 1))
|
| 14844 | return -EFAULT;
|
| 14845 |
|
| 14846 | - if (char_fastbr[0] < '0' || char_fastbr[0] > '1')
|
| 14847 | + if (char_fastbr[0] < '0' || char_fastbr[0] > '2')
|
| 14848 | return -EINVAL;
|
| 14849 |
|
| 14850 | fastbr_level = (int)(char_fastbr[0] - '0');
|
| 14851 | @@ -252,8 +252,8 @@ |
| 14852 | {
|
| 14853 | if (*pos == 0)
|
| 14854 | {
|
| 14855 | - seq_printf(seq, "fastnat have %d conn!!!\nskb_num4:%d,fastnat_num:%d\n",
|
| 14856 | - working_list.count, skb_num4, fastnat_num);
|
| 14857 | + seq_printf(seq, "fastnat have %d conn!!!\nskb_num4:%d,fastnat_num:%d,expand_head4:%d\n",
|
| 14858 | + working_list.count, skb_num4, fastnat_num, skb_expand4);
|
| 14859 | seq_printf(seq, "fastbr_sum:%d,fastbr_num:%d\n",
|
| 14860 | skb_num4 + skb_num6 + skb_unknown - fastnat_num - fast6_num, fastbr_num);
|
| 14861 |
|
| 14862 | @@ -399,8 +399,8 @@ |
| 14863 | working_list.count,fastnat_recv_count,fastnat_real_count);
|
| 14864 | seq_printf(seq, "send_2_ps_failed:%u, send_2_usb_failed:%u\n", send_2_ps_failed, send_2_usb_failed);
|
| 14865 | #endif
|
| 14866 | - seq_printf(seq, "fast6 have %d conn!!!\nskb_num6:%d,fast6_num:%d\n",
|
| 14867 | - working_list6.count, skb_num6, fast6_num);
|
| 14868 | + seq_printf(seq, "fast6 have %d conn!!!\nskb_num6:%d,fast6_num:%d,expand_head6:%d\n",
|
| 14869 | + working_list6.count, skb_num6, fast6_num, skb_expand6);
|
| 14870 | }
|
| 14871 | return &working_hash6[*pos];
|
| 14872 | }
|
| 14873 | @@ -1160,6 +1160,42 @@ |
| 14874 | .proc_write = ct_iptables_syn_set,
|
| 14875 | };
|
| 14876 |
|
| 14877 | +/* Started by AICoder, pid:i2747j1887i1a311479909db709e49391b4455c1 */
|
| 14878 | +static ssize_t dev_unreg_set(struct file *file, const char __user *buffer, size_t count, loff_t *pos)
|
| 14879 | +{
|
| 14880 | + struct net_device *dev = NULL;
|
| 14881 | + size_t size;
|
| 14882 | + char dev_name[MAX_NET_DEVICE_NAME_LEN + 1] = {0};
|
| 14883 | +
|
| 14884 | + // Ensure that the string is null-terminated
|
| 14885 | + if (count == 0 || count > MAX_NET_DEVICE_NAME_LEN + 1)
|
| 14886 | + return -EINVAL;
|
| 14887 | +
|
| 14888 | + // Copy the device name from user space and ensure it's null terminated
|
| 14889 | + size = min(count - 1, MAX_NET_DEVICE_NAME_LEN);
|
| 14890 | + if (copy_from_user(dev_name, buffer, size)) {
|
| 14891 | + return -EFAULT;
|
| 14892 | + }
|
| 14893 | + dev_name[size] = '\0'; // Ensure null-termination
|
| 14894 | +
|
| 14895 | + // Try to get the network device by name
|
| 14896 | + dev = dev_get_by_name(&init_net, dev_name);
|
| 14897 | + if (dev) {
|
| 14898 | + // Put the device reference
|
| 14899 | + dev_put(dev);
|
| 14900 | + // Unregister the network device
|
| 14901 | + unregister_netdev(dev);
|
| 14902 | + } else {
|
| 14903 | + printk("dev_unreg %s not found\n", dev_name);
|
| 14904 | + }
|
| 14905 | +
|
| 14906 | + return count;
|
| 14907 | +}
|
| 14908 | +
|
| 14909 | +static const struct proc_ops dev_unreg_file_ops = {
|
| 14910 | + .proc_write = dev_unreg_set,
|
| 14911 | +};
|
| 14912 | +/* Ended by AICoder, pid:i2747j1887i1a311479909db709e49391b4455c1 */
|
| 14913 |
|
| 14914 | //¿ìËÙת·¢procÎļþµÄ³õʼ»¯
|
| 14915 | int fast_conntrack_init_proc(void)
|
| 14916 | @@ -1195,6 +1231,7 @@ |
| 14917 | proc_create("dev_reset_stats", 0440, init_net.proc_net, &dev_reset_file_ops);
|
| 14918 |
|
| 14919 | proc_create("ct_iptables_syn", 0440, init_net.proc_net, &ct_iptables_syn_file_ops);
|
| 14920 | + proc_create("dev_unreg", 0440, init_net.proc_net, &dev_unreg_file_ops);
|
| 14921 | return 1;
|
| 14922 | }
|
| 14923 |
|
| 14924 | diff --git a/upstream/linux-5.10/net/core/fastproc/fastnat.c b/upstream/linux-5.10/net/core/fastproc/fastnat.c |
| 14925 | index 717454c..8d585c0 100755 |
| 14926 | --- a/upstream/linux-5.10/net/core/fastproc/fastnat.c |
| 14927 | +++ b/upstream/linux-5.10/net/core/fastproc/fastnat.c |
| 14928 | @@ -209,6 +209,7 @@ |
| 14929 | { |
| 14930 | iph = (struct iphdr *)skb2->data; |
| 14931 | skb = skb2; |
| 14932 | + skb_expand4++; |
| 14933 | } |
| 14934 | |
| 14935 | fast_tcpdump(skb); |
| 14936 | @@ -275,7 +276,8 @@ |
| 14937 | |
| 14938 | skb->priority = nat_entry_data->priority; |
| 14939 | skb->mark = nat_entry_data->mark; |
| 14940 | - |
| 14941 | + |
| 14942 | + spin_lock_bh(&fast_fw_spinlock); |
| 14943 | //»ùÓÚctÁ´½ÓµÄÁ÷Á¿Í³¼Æ --- ͳ¼ÆIP°ü²»ÊÇMAC°ü |
| 14944 | if (nat_entry_data->tuplehash.tuple.dst.dir == IP_CT_DIR_ORIGINAL){ |
| 14945 | nat_entry->ct->packet_info[IP_CT_DIR_ORIGINAL].packets++; |
| 14946 | @@ -294,6 +296,7 @@ |
| 14947 | } else { |
| 14948 | printk("fastnat packet error\n"); |
| 14949 | } |
| 14950 | + spin_unlock_bh(&fast_fw_spinlock); |
| 14951 | |
| 14952 | //ÄÚºË×Ô´øµÄ»ùÓÚÁ´½ÓµÄÁ÷Á¿Í³¼Æ |
| 14953 | struct nf_conn_counter *acct = (struct nf_conn_counter *)nf_conn_acct_find((const struct nf_conn *)nat_entry->ct); |
| 14954 | @@ -450,7 +453,8 @@ |
| 14955 | } |
| 14956 | |
| 14957 | //¹ã²¥¡¢×é²¥²»½¨Á´ |
| 14958 | - if (ipv4_is_multicast(ip_hdr(skb)->daddr) || ipv4_is_lbcast(ip_hdr(skb)->daddr)) |
| 14959 | + if (ipv4_is_multicast(ip_hdr(skb)->daddr) || ipv4_is_lbcast(ip_hdr(skb)->daddr) |
| 14960 | + || ip_hdr(skb)->daddr == 0 || ip_hdr(skb)->saddr == 0) |
| 14961 | { |
| 14962 | return NF_ACCEPT; |
| 14963 | } |
| 14964 | @@ -467,13 +471,10 @@ |
| 14965 | } |
| 14966 | |
| 14967 | _neighbour = dst_neigh_lookup_skb(dst, skb); |
| 14968 | - if (!_neighbour) |
| 14969 | - { |
| 14970 | - print_sun(SUN_DBG,"napt_handle() _neighbour = null\n"); |
| 14971 | + if(_neighbour == NULL && ((ip_hdr(skb)->daddr & 0xff000000) == 0xff000000 )){ |
| 14972 | return NF_ACCEPT; |
| 14973 | - } |
| 14974 | - |
| 14975 | - if (memcmp(_neighbour->ha, zeromac, ETH_ALEN) == 0) |
| 14976 | + } |
| 14977 | + if (_neighbour && memcmp(_neighbour->ha, zeromac, ETH_ALEN) == 0) |
| 14978 | { |
| 14979 | if (strncmp(out->name, ppp_name, strlen(ppp_name)) != 0) |
| 14980 | { |
| 14981 | @@ -557,9 +558,10 @@ |
| 14982 | |
| 14983 | entry_data = &nat_entry->data[dir]; |
| 14984 | entry_data->tuplehash.tuple = ct->tuplehash[dir].tuple; |
| 14985 | - memcpy(entry_data->dmac, _neighbour->ha, ETH_ALEN); |
| 14986 | + //memcpy(entry_data->dmac, _neighbour->ha, ETH_ALEN); |
| 14987 | entry_data->priority = skb->priority; |
| 14988 | entry_data->mark = skb->mark; |
| 14989 | + if(entry_data->outdev == NULL){ |
| 14990 | entry_data->outdev = out; |
| 14991 | |
| 14992 | /*¼Ç¼MACµØÖ·µ½entry_data->hh_data*/ |
| 14993 | @@ -568,6 +570,7 @@ |
| 14994 | spin_unlock_bh(&fastnat_spinlock); |
| 14995 | goto accept; |
| 14996 | } |
| 14997 | + } |
| 14998 | print_sun(SUN_DBG,"napt_handle() ct->status=0x%x\n", ct->status); |
| 14999 | /*»ñÈ¡natת»»ÐèÒªµÄIPºÍportÐÅÏ¢*/ |
| 15000 | if (test_bit(IPS_SRC_NAT_BIT, &ct->status)) |
| 15001 | @@ -624,6 +627,7 @@ |
| 15002 | spin_unlock_bh(&fastnat_spinlock); |
| 15003 | |
| 15004 | accept: |
| 15005 | + if(_neighbour) |
| 15006 | neigh_release(_neighbour); |
| 15007 | return NF_ACCEPT; |
| 15008 | } |
| 15009 | diff --git a/upstream/linux-5.10/net/netfilter/nf_conntrack_core.c b/upstream/linux-5.10/net/netfilter/nf_conntrack_core.c |
| 15010 | index e92413e..d4ae0b7 100755 |
| 15011 | --- a/upstream/linux-5.10/net/netfilter/nf_conntrack_core.c |
| 15012 | +++ b/upstream/linux-5.10/net/netfilter/nf_conntrack_core.c |
| 15013 | @@ -1621,6 +1621,11 @@ |
| 15014 | ct->packet_info[IP_CT_DIR_ORIGINAL].bytes = 0; |
| 15015 | ct->packet_info[IP_CT_DIR_REPLY].packets = 0; |
| 15016 | ct->packet_info[IP_CT_DIR_REPLY].bytes = 0; |
| 15017 | + ct->indev[IP_CT_DIR_ORIGINAL] = NULL; |
| 15018 | + ct->outdev[IP_CT_DIR_ORIGINAL] = NULL; |
| 15019 | + ct->indev[IP_CT_DIR_REPLY] = NULL; |
| 15020 | + ct->outdev[IP_CT_DIR_REPLY] = NULL; |
| 15021 | + ct->fast_entry = NULL; |
| 15022 | for(dir = IP_CT_DIR_ORIGINAL; dir < IP_CT_DIR_MAX; dir++) |
| 15023 | { |
| 15024 | ct->indev[dir] = NULL; |
| 15025 | diff --git a/upstream/linux-5.10/sound/soc/codecs/es8311.c b/upstream/linux-5.10/sound/soc/codecs/es8311.c |
| 15026 | index fef445f..34410ce 100755 |
| 15027 | --- a/upstream/linux-5.10/sound/soc/codecs/es8311.c |
| 15028 | +++ b/upstream/linux-5.10/sound/soc/codecs/es8311.c |
| 15029 | @@ -766,35 +766,38 @@ |
| 15030 | /* set iface */
|
| 15031 | snd_soc_component_write(component, ES8311_SDPOUT_REG0A, iface);
|
| 15032 | }
|
| 15033 | -/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */ |
| 15034 | -#ifdef CONFIG_USE_TOP_TDM |
| 15035 | +/* yu.dong@20240816[ZXW-277]Disable soft ramp, optimize playback 44.1k noise issue start */ |
| 15036 | +#if defined(CONFIG_USE_TOP_TDM) |
| 15037 | + snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x1a); |
| 15038 | #else |
| 15039 | - snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x98); |
| 15040 | + snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x98); |
| 15041 | +#endif |
| 15042 | snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1b); |
| 15043 | snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1b); |
| 15044 | - /* |
| 15045 | + |
| 15046 | if(rate == 8000){ |
| 15047 | - snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0xbb); |
| 15048 | - pr_info("%s rate:%d\n",__FUNCTION__,rate); |
| 15049 | - |
| 15050 | - } |
| 15051 | - if(rate == 16000){ |
| 15052 | - snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x55); |
| 15053 | - pr_info("%s rate:%d\n",__FUNCTION__,rate); |
| 15054 | - |
| 15055 | - } |
| 15056 | - */ |
| 15057 | - if(rate == 44100){ |
| 15058 | - |
| 15059 | - snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x90); |
| 15060 | - snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x1d); |
| 15061 | - snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x1d); |
| 15062 | - snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00); |
| 15063 | - pr_info("%s rate:%d\n",__FUNCTION__,rate); |
| 15064 | - |
| 15065 | - } |
| 15066 | +#if defined(CONFIG_USE_TOP_TDM) |
| 15067 | + snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00); |
| 15068 | +#else |
| 15069 | + snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0xbb); |
| 15070 | #endif |
| 15071 | -/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */ |
| 15072 | + pr_info("%s rate:%d\n",__FUNCTION__,rate); |
| 15073 | + |
| 15074 | + } |
| 15075 | + |
| 15076 | + if(rate == 16000){ |
| 15077 | + snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x55); |
| 15078 | + pr_info("%s rate:%d\n",__FUNCTION__,rate); |
| 15079 | + } |
| 15080 | + |
| 15081 | + if(rate == 44100){ |
| 15082 | + snd_soc_component_write(component, ES8311_CLK_MANAGER_REG02, 0x00); |
| 15083 | + snd_soc_component_write(component, ES8311_CLK_MANAGER_REG03, 0x10); |
| 15084 | + snd_soc_component_write(component, ES8311_CLK_MANAGER_REG04, 0x20); |
| 15085 | + snd_soc_component_write(component, ES8311_CLK_MANAGER_REG05, 0x00); |
| 15086 | + pr_info("%s rate:%d\n",__FUNCTION__,rate); |
| 15087 | + } |
| 15088 | +/* yu.dong@20240816[ZXW-277]Disable soft ramp, optimize playback 44.1k noise issue end */ |
| 15089 | snd_soc_component_write(component, ES8311_CLK_MANAGER_REG06, 0x18); |
| 15090 | snd_soc_component_write(component, ES8311_CLK_MANAGER_REG07, 0x06); |
| 15091 | |
| 15092 | @@ -893,7 +896,7 @@ |
| 15093 | snd_soc_component_write(component, ES8311_ADC_REG15, 0x40);
|
| 15094 | snd_soc_component_write(component, ES8311_ADC_REG1B, 0x0A);
|
| 15095 | snd_soc_component_write(component, ES8311_ADC_REG1C, 0x6A);
|
| 15096 | - snd_soc_component_write(component, ES8311_DAC_REG37, 0x48);
|
| 15097 | + snd_soc_component_write(component, ES8311_DAC_REG37, 0x08); //0 â disable soft ramp |
| 15098 | /* yu.dong@20240718[ZXW-277]Optimizing Recording in CODEC 8311 TDM Mode start*/ |
| 15099 | #if defined(CONFIG_USE_TOP_TDM) |
| 15100 | snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x9f); |
| 15101 | diff --git a/upstream/pub/include/infra/pub_debug_info.h b/upstream/pub/include/infra/pub_debug_info.h |
| 15102 | index 10357aa..95a480f 100755 |
| 15103 | --- a/upstream/pub/include/infra/pub_debug_info.h |
| 15104 | +++ b/upstream/pub/include/infra/pub_debug_info.h |
| 15105 | @@ -6,62 +6,43 @@ |
| 15106 | #define DEBUG_INFO_DEV_PATH "/dev/debug_info" |
| 15107 | |
| 15108 | /* AP²àºÍCAP²àµÄPS\KERNEL\DRIVER\FS\APP ÒÔSTART~ENDÎªÇø¼ä£¬¸÷²¿·ÖÔ¤ÁôÁË100¸öID */ |
| 15109 | -#define MODULE_ID_PS_START (1) |
| 15110 | -#define MODULE_ID_PS_NAS (1) |
| 15111 | -#define MODULE_ID_PS_RRC (2) |
| 15112 | -#define MODULE_ID_PS_L2 (3) |
| 15113 | -#define MODULE_ID_PS_UICC (99) |
| 15114 | -#define MODULE_ID_PS_END (100) |
| 15115 | |
| 15116 | -#define MODULE_ID_AP_KERNEL_START (101) |
| 15117 | -#define MODULE_ID_AP_KERNEL_END (200) |
| 15118 | +#define MODULE_ID_PS_NAS ("ps_nas") |
| 15119 | +#define MODULE_ID_PS_RRC ("ps_rrc") |
| 15120 | +#define MODULE_ID_PS_L2 ("ps_l2") |
| 15121 | +#define MODULE_ID_PS_UICC ("ps_uicc") |
| 15122 | +#define MODULE_ID_AP_USB ("ap_usb") |
| 15123 | +#define MODULE_ID_AP_REBOOT ("ap_reboot") |
| 15124 | +#define MODULE_ID_AP_TSC ("ap_tsc") |
| 15125 | +#define MODULE_ID_AP_PSM ("ap_psm") |
| 15126 | +#define MODULE_ID_AP_NAND ("ap_nand") |
| 15127 | +#define MODULE_ID_AP_MMC ("ap_mmc") |
| 15128 | +#define MODULE_ID_AP_WIFI ("ap_wifi") |
| 15129 | |
| 15130 | -#define MODULE_ID_CAP_KERNEL_START (201) |
| 15131 | -#define MODULE_ID_CAP_KERNEL_END (300) |
| 15132 | |
| 15133 | -#define MODULE_ID_AP_DRIVES_START (301) |
| 15134 | -#define MODULE_ID_AP_USB (301) |
| 15135 | -#define MODULE_ID_AP_REBOOT (302) |
| 15136 | -#define MODULE_ID_AP_TSC (303) |
| 15137 | -#define MODULE_ID_AP_PSM (304) |
| 15138 | -#define MODULE_ID_AP_NAND (305) |
| 15139 | -#define MODULE_ID_AP_MMC (306) |
| 15140 | -#define MODULE_ID_AP_WIFI (307) |
| 15141 | -#define MODULE_ID_AP_DRIVES_END (400) |
| 15142 | +#define MODULE_ID_CAP_USB ("cap_usb") |
| 15143 | +#define MODULE_ID_CAP_TSC ("cap_tsc") |
| 15144 | +#define MODULE_ID_CAP_PSM ("cap_psm") |
| 15145 | +#define MODULE_ID_CAP_NAND ("cap_nand") |
| 15146 | +#define MODULE_ID_CAP_SPI ("cap_spi") |
| 15147 | +#define MODULE_ID_CAP_MMC ("cap_mmc") |
| 15148 | +#define MODULE_ID_CAP_UART ("cap_uart") |
| 15149 | +#define MODULE_ID_CAP_PM ("cap_pm") |
| 15150 | |
| 15151 | -#define MODULE_ID_CAP_DRIVES_START (401) |
| 15152 | -#define MODULE_ID_CAP_USB (401) |
| 15153 | -#define MODULE_ID_CAP_TSC (402) |
| 15154 | -#define MODULE_ID_CAP_PSM (403) |
| 15155 | -#define MODULE_ID_CAP_NAND (404) |
| 15156 | -#define MODULE_ID_CAP_SPI (405) |
| 15157 | -#define MODULE_ID_CAP_MMC (406) |
| 15158 | -#define MODULE_ID_CAP_UART (407) |
| 15159 | -#define MODULE_ID_CAP_DRIVES_END (500) |
| 15160 | |
| 15161 | -#define MODULE_ID_AP_FS_START (501) |
| 15162 | -#define MODULE_ID_AP_JFFS2 (501) |
| 15163 | -#define MODULE_ID_AP_FS_END (600) |
| 15164 | +#define MODULE_ID_AP_JFFS2 ("ap_jffs2") |
| 15165 | +#define MODULE_ID_AP_FOTA ("ap_fota") |
| 15166 | +#define MODULE_ID_AP_FS_CHECK ("ap_fs_check") |
| 15167 | |
| 15168 | -#define MODULE_ID_CAP_FS_START (601) |
| 15169 | -#define MODULE_ID_CAP_FS_END (700) |
| 15170 | - |
| 15171 | -#define MODULE_ID_AP_APP_START (701) |
| 15172 | -#define MODULE_ID_AP_FOTA (701) |
| 15173 | -#define MODULE_ID_AP_FS_CHECK (702) |
| 15174 | -#define MODULE_ID_AP_APP_END (800) |
| 15175 | - |
| 15176 | -#define MODULE_ID_CAP_APP_START (801) |
| 15177 | -#define MODULE_ID_CAP_FOTA (801) |
| 15178 | -#define MODULE_ID_CAP_FS_CHECK (802) |
| 15179 | -#define MODULE_ID_CAP_APP_END (900) |
| 15180 | - |
| 15181 | -#if defined(_USE_ZXIC_DEBUG_INFO) && !defined(CONFIG_SYSTEM_RECOVERY) |
| 15182 | -int sc_debug_info_vrecord(unsigned int id, const char *format, va_list args); |
| 15183 | -int sc_debug_info_record(unsigned int id, const char *format, ...); |
| 15184 | +#define MODULE_ID_CAP_FOTA ("cap_fota") |
| 15185 | +#define MODULE_ID_CAP_FS_CHECK ("cap_fs_check") |
| 15186 | + |
| 15187 | +#if defined(_USE_ZXIC_DEBUG_INFO) |
| 15188 | +int sc_debug_info_vrecord(char *id, const char *format, va_list args); |
| 15189 | +int sc_debug_info_record(char *id, const char *format, ...); |
| 15190 | #else |
| 15191 | -static inline int sc_debug_info_vrecord(unsigned int id, const char *format, va_list args) { return 0; } |
| 15192 | -static inline int sc_debug_info_record(unsigned int id, const char *format, ...) { return 0; } |
| 15193 | +static inline int sc_debug_info_vrecord(char *id, const char *format, va_list args) { return 0; } |
| 15194 | +static inline int sc_debug_info_record(char *id, const char *format, ...) { return 0; } |
| 15195 | #endif |
| 15196 | |
| 15197 | #endif |
| 15198 | \ No newline at end of file |
| 15199 | diff --git a/upstream/pub/include/ps_phy/atipsevent.h b/upstream/pub/include/ps_phy/atipsevent.h |
| 15200 | index 2bd5386..92e71e6 100755 |
| 15201 | --- a/upstream/pub/include/ps_phy/atipsevent.h |
| 15202 | +++ b/upstream/pub/include/ps_phy/atipsevent.h |
| 15203 | @@ -421,6 +421,7 @@ |
| 15204 | #define AP_MMIA_ZCOPS_TEST_CNF_EV (DWORD)(AP_MMIA_MM_RSP_EVENT + 25)
|
| 15205 | #define AP_MMIA_TIMEZONE_IND_EV (DWORD)(AP_MMIA_MM_RSP_EVENT + 26)
|
| 15206 | #define AP_MMIA_ZULRTIND_IND_EV (DWORD)(AP_MMIA_MM_RSP_EVENT + 27)
|
| 15207 | +#define AP_MMIA_ZPSABNORMAL_IND_EV (DWORD)(AP_MMIA_MM_RSP_EVENT + 28)
|
| 15208 | /* ========================================================================
|
| 15209 | AP-MMIA CCÏà¹Ø²¿·ÖÏûÏ¢ºÅ
|
| 15210 | ======================================================================== */
|
| 15211 | diff --git a/upstream/pub/project/zx297520v3/include/drv/NvParam_drv.h b/upstream/pub/project/zx297520v3/include/drv/NvParam_drv.h |
| 15212 | index 66c6f6d..95c3158 100755 |
| 15213 | --- a/upstream/pub/project/zx297520v3/include/drv/NvParam_drv.h |
| 15214 | +++ b/upstream/pub/project/zx297520v3/include/drv/NvParam_drv.h |
| 15215 | @@ -214,8 +214,10 @@ |
| 15216 | UINT8 isUseTxDtmfDet;
|
| 15217 | UINT8 isUseRxMixData;
|
| 15218 | UINT8 isUseTxMixData;//12
|
| 15219 | - UINT8 isUseEcall;
|
| 15220 | - UINT8 reserved[19];//32-13
|
| 15221 | + UINT8 isUseEcall; //13
|
| 15222 | + UINT8 isUseVoiceBuffer; //14 0 not use,1 use
|
| 15223 | + UINT8 selVoiceBufferType; //15 0 single core, 1 dual core
|
| 15224 | + UINT8 reserved[17];//32-15
|
| 15225 |
|
| 15226 | } T_Audio_NvFlag;
|
| 15227 |
|
| 15228 | diff --git a/upstream/pub/project/zx297520v3/include/infra/ram_base_config_7520v3.h b/upstream/pub/project/zx297520v3/include/infra/ram_base_config_7520v3.h |
| 15229 | index 6a1626d..edb3bfb 100755 |
| 15230 | --- a/upstream/pub/project/zx297520v3/include/infra/ram_base_config_7520v3.h |
| 15231 | +++ b/upstream/pub/project/zx297520v3/include/infra/ram_base_config_7520v3.h |
| 15232 | @@ -163,7 +163,7 @@ |
| 15233 | #define DDR_BASE_OFF_CAP (DDR_BASE_OFF_CAP_BUF + DDR_BASE_LEN_CAP_BUF)
|
| 15234 |
|
| 15235 | /* capºËµÄdtbµØÖ·¹©ubootºËcap kernelʹÓà */
|
| 15236 | -#define DDR_BASE_CAP_DTB_ADDR (DDR_BASE_ADDR_CAP_BUF + (0x00100000UL>>CPU_SHIFT))
|
| 15237 | +#define DDR_BASE_CAP_DTB_ADDR (DDR_BASE_ADDR_CAP_BUF + (0x00194000UL>>CPU_SHIFT))
|
| 15238 | #else
|
| 15239 | /* 42.75M£¬AP¹²ºË°æ±¾(´Ë´óСÊǰ´ÕÕº¬CAPºËµÄ64MÄÚ´æÅäÖö¨Ò壬¸Ãºê±ð´¦²»»á±»Ê¹ÓÃ) */
|
| 15240 | #define DDR_BASE_ADDR_AP (DDR_BASE_ADDR_RAMDUMP + DDR_BASE_LEN_RAMDUMP)
|
| 15241 | @@ -253,6 +253,13 @@ |
| 15242 | #define TEE_SHARE_BUF_ADDR (RAMDUMP_AP_TO_CAP_BUF_ADDR + RAMDUMP_AP_TO_CAP_BUF_LEN)
|
| 15243 | #define TEE_SHARE_BUF_LEN ((384 * 1024UL)>>CPU_SHIFT)
|
| 15244 |
|
| 15245 | +/* psά²â¿Õ¼ä(Êý¾Ý + ¿ØÖÆ)¸´ÓÃAP_TO_CAPµÄramdump´æ´¢¿Õ¼ä */
|
| 15246 | +#define PS_DEBUG_INFO_LEN_ADDR (RAMDUMP_AP_TO_CAP_BUF_ADDR + ((4 * 1024UL)>>CPU_SHIFT))
|
| 15247 | +#define PS_DEBUG_INFO_LEN_SIZE ((4 * 1024UL)>>CPU_SHIFT)
|
| 15248 | +
|
| 15249 | +#define PS_DEBUG_INFO_ADDR (PS_DEBUG_INFO_LEN_ADDR + PS_DEBUG_INFO_LEN_SIZE)
|
| 15250 | +#define PS_DEBUG_INFO_SIZE ((64 * 1024UL)>>CPU_SHIFT)
|
| 15251 | +
|
| 15252 | #define ICP_CAP_BUF_ADDR_PA DDR_BASE_CAPBUF_ADDR_PA
|
| 15253 | #define TOOL_CAP_BUF_ADDR_PA (ICP_CAP_BUF_ADDR_PA + ICP_CAP_BUF_LEN)
|
| 15254 | #define RINGBUF_CAP_TO_AP_ADDR_PA (TOOL_CAP_BUF_ADDR_PA + TOOL_CAP_BUF_LEN)
|
| 15255 | @@ -262,6 +269,9 @@ |
| 15256 | #define TOOL_ZSP_TO_CAP_LOG_ADDR_PA (RINGBUF_AP_TO_CAP_ADDR_PA + RINGBUF_AP_TO_CAP_LEN)
|
| 15257 | #define RAMDUMP_AP_TO_CAP_BUF_ADDR_PA (TOOL_ZSP_TO_CAP_LOG_ADDR_PA + TOOL_ZSP_TO_CAP_LOG_LEN)
|
| 15258 | #define TEE_SHARE_BUF_ADDR_PA (RAMDUMP_AP_TO_CAP_BUF_ADDR_PA + RAMDUMP_AP_TO_CAP_BUF_LEN)
|
| 15259 | +
|
| 15260 | +#define PS_DEBUG_INFO_LEN_ADDR_PA (RAMDUMP_AP_TO_CAP_BUF_ADDR_PA + ((4 * 1024UL)>>CPU_SHIFT))
|
| 15261 | +#define PS_DEBUG_INFO_ADDR_PA (PS_DEBUG_INFO_LEN_ADDR_PA + PS_DEBUG_INFO_LEN_SIZE)
|
| 15262 | #endif
|
| 15263 |
|
| 15264 | /* 7520V3оƬIRAM0ѹËõ£¬ÐÒéÕ»ÎïÀí²ã½»»¥¿Õ¼äÒÆ¶¯µ½DDR£¬¸´ÓÃRamdump¿Õ¼ä */
|
| 15265 | diff --git a/upstream/tools/SignTool/SignImage b/upstream/tools/SignTool/SignImage |
| 15266 | index 552a4de..0b03078 100755 |
| 15267 | --- a/upstream/tools/SignTool/SignImage |
| 15268 | +++ b/upstream/tools/SignTool/SignImage |
| 15269 | Binary files differ |
| 15270 | diff --git a/upstream/tools/SignTool/SignImage.exe b/upstream/tools/SignTool/SignImage.exe |
| 15271 | index 6905638..7a58d11 100755 |
| 15272 | --- a/upstream/tools/SignTool/SignImage.exe |
| 15273 | +++ b/upstream/tools/SignTool/SignImage.exe |
| 15274 | Binary files differ |
| 15275 | diff --git a/upstream/tools/SignTool/private.k b/upstream/tools/SignTool/private.k |
| 15276 | new file mode 100755 |
| 15277 | index 0000000..9b72371 |
| 15278 | --- /dev/null |
| 15279 | +++ b/upstream/tools/SignTool/private.k |
| 15280 | Binary files differ |