spmeta.h 344 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 5422 5423 5424 5425 5426 5427 5428 5429 5430 5431 5432 5433 5434 5435 5436 5437 5438 5439 5440 5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473 5474 5475 5476 5477 5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 5510 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 5992 5993 5994 5995 5996 5997 5998 5999 6000 6001 6002 6003 6004 6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 6466 6467 6468 6469 6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491 6492 6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538 6539 6540 6541 6542 6543 6544 6545 6546 6547 6548 6549 6550 6551 6552 6553 6554 6555 6556 6557 6558 6559 6560 6561 6562 6563 6564 6565 6566 6567 6568 6569 6570 6571 6572 6573 6574 6575 6576 6577 6578 6579 6580 6581 6582 6583 6584 6585 6586 6587 6588 6589 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 6606 6607 6608 6609 6610 6611 6612 6613 6614 6615 6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 6670 6671 6672 6673 6674 6675 6676 6677 6678 6679 6680 6681 6682 6683 6684 6685 6686 6687 6688 6689 6690 6691 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 6733 6734 6735 6736 6737 6738 6739 6740 6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819 6820 6821 6822 6823 6824 6825 6826 6827 6828 6829 6830 6831 6832 6833 6834 6835 6836 6837 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 6853 6854 6855 6856 6857 6858 6859 6860 6861 6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873 6874 6875 6876 6877 6878 6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890 6891 6892 6893 6894 6895 6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929 6930 6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 6967 6968 6969 6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 7085 7086 7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 7306 7307 7308 7309 7310 7311 7312 7313 7314 7315 7316 7317 7318 7319 7320 7321 7322 7323 7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 7530 7531 7532 7533 7534 7535 7536 7537 7538 7539 7540 7541 7542 7543 7544 7545 7546 7547 7548 7549 7550 7551 7552 7553 7554 7555 7556 7557 7558 7559 7560 7561 7562 7563 7564 7565 7566 7567 7568 7569 7570 7571 7572 7573 7574 7575 7576 7577 7578 7579 7580 7581 7582 7583 7584 7585 7586 7587 7588 7589 7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 7799 7800 7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 8184 8185 8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 8269 8270 8271 8272 8273 8274 8275 8276 8277 8278 8279 8280 8281 8282 8283 8284 8285 8286 8287 8288 8289 8290 8291 8292 8293 8294 8295 8296 8297 8298 8299 8300 8301 8302 8303 8304 8305 8306 8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439
#ifndef SPMETA_DLL_H
#define SPMETA_DLL_H


#ifdef __cplusplus
extern "C" {
#endif

//--------------------------------------------------------------------------//
//  META General                                                            //
//--------------------------------------------------------------------------//

//-----------------------------------------------------//
//  META General: data structure definition            //
//-----------------------------------------------------//
//namespace SPMETA_DLL
//{



#define STATUS_OK_DIRVER		1
#define STATUS_FAIL_DIRVER		0
#define STATUS_OK_DVB			1
#define STATUS_FAIL_DVB			0



#define STATUS_OK_FT			0
#define STATUS_FAIL_FT			1


typedef enum
{
	// META_DLL received a corrupted frame
	META_CNF_FRAME_ERROR = 0,

	// META_DLL received a confirm or indication from target,
	// but there is not corresponding call back function
	// installed for this confirm or indication.
	META_CNF_NO_CALLBACK = 1,

	// META_DLL received a corrupted primitive.
	META_CNF_PRIMITIVE_ERROR = 2,

	// META_DLL received a confirm or indication from
	// target, but there is no sufficient memory to process.
	META_CNF_NO_MEMORY = 3,

	// META_DLL retrieved a callback function, however,
	// the user input arguments are invalid.
	META_CNF_CALLBACK_PARAMETER_ERROR = 4,

	// META_DLL received a confirm with peer msg, however,
	// the peer msg is corrupted.
	META_CNF_PEER_MSG_ERROR = 5,

	// META_DLL received a confirm and successfully executed
	// the callback function.
	META_CNF_OK = 6,
	META_CNF_FT_STATUS_ERROR = 7
} META_CNF_ERR_CODE;

// The magic value to stop usb enumerate process 
#define ENUM_USB_STOP	9876

typedef enum
{
	META_SUCCESS = 0
	,META_FAILED
	,META_COMM_FAIL
	,META_NORESPONSE
	,META_BUFFER_LEN
	,META_FILE_BAD
	,META_LID_INVALID
	,META_INTERNAL_DB_ERR
	,META_NO_MEMORY
	,META_INVALID_ARGUMENTS
	,META_TIMEOUT
	,META_BUSY
	,META_INVALID_HANDLE
	,META_FAT_ERROR
	,META_FAT_DISK_FULL
	,META_FAT_ROOT_DIR_FULL
	,META_FAT_INVALID_FILENAME
	,META_FAT_INVALID_FILE_HANDLE
	,META_FAT_FILE_NOT_FOUND
	,META_FAT_DRIVE_NOT_FOUND
	,META_FAT_PATH_NOT_FOUND
	,META_FAT_ACCESS_DENIED
	,META_FAT_TOO_MANY_FILES
	,META_INCORRECT_TARGET_VER
	,META_COM_ERROR
	,META_BROM_CMD_ERROR
	,META_INCORRECT_BBCHIP_TYPE
	,META_BROM_ERROR
	,META_STOP_BOOTUP_PROCEDURE
	,META_CANCEL
	,META_CCT_NOT_IMPORT_PROFILE
	,META_CCT_INVALID_SENSOR_ID
	,META_CCT_TGT_NO_MEM_FOR_SINGLE_SHOT
	,META_CCT_TGT_NO_MEM_FOR_MULTI_SHOT
	,META_FUNC_NOT_IMPLEMENT_YET
	,META_CCT_NOT_IMPLEMENT_YET = META_FUNC_NOT_IMPLEMENT_YET
	,META_CCT_PREVIEW_ALREADY_STARTED
	,META_CCT_PREVIEW_ALREADY_STOPPED
	,META_CCT_READ_REG_NO_CNF
	,META_CCT_WRITE_REG_NO_CNF
	,META_CCT_TGT_ABORT_IMAGE_SENDING
	,META_CCT_READ_ONLY_REGISTER
	,META_CCT_LOAD_FROM_NVRAM_FAIL
	,META_CCT_SAVE_TO_NVRAM_FAIL
	,META_CCT_AE_INVALID_EC_LEVEL
	,META_CCT_AE_INVALID_EC_STEP
	,META_CCT_AE_ALREADY_ENABLED
	,META_CCT_AE_ALREADY_DISABLED
	,META_CCT_WB_INVALID_INDEX
	,META_CCT_NO_TGT_SENSOR_MATCH_IN_PROFILE
	,META_CCT_IMAGE_SENDING_FAME_NUM_ERROR
	,META_CCT_AE_IS_NOT_DISABLED
	,META_FAT_APP_QUOTA_FULL
	,META_IMEI_CD_ERROR
	,META_RFID_MISMATCH
	,META_NVRAM_DB_IS_NOT_LOADED_YET
	,META_CCT_ERR_CAPTURE_WIDTH_HEIGHT_TOO_SMALL
	,META_WAIT_FOR_TARGET_READY_TIMEOUT
	,META_CCT_ERR_SENSOR_ENG_SET_INVALID_VALUE
	,META_CCT_ERR_SENSOR_ENG_GROUP_NOT_EXIST
	,META_CCT_NO_TGT_ISP_MATCH_IN_PROFILE
	,META_CCT_TGT_ISP_SUPPORT_NOT_DEFINED
	,META_CCT_ERR_SENSOR_ENG_ITEM_NOT_EXIST
	,META_CCT_ERR_INVALID_COMPENSATION_MODE
	,META_CCT_ERR_USB_COM_NOT_READY
	,META_CCT_DEFECTPIXEL_CAL_UNDER_PROCESSING
	,META_CCT_ERR_DEFECTPIXEL_CAL_NO_MEM
	,META_CCT_ERR_TOO_MANY_DEFECT_PIXEL
	,META_CCT_ERR_CAPTURE_JPEG_FAIL
	,META_CCT_ERR_CAPTURE_JPEG_TIMEOUT
	,META_CCT_ERR_AF_FAIL
	,META_CCT_ERR_AF_TIMEOUT
	,META_CCT_ERR_AF_LENS_OFFSET_CAL_FAIL
	,META_CCT_ERR_PREVIEW_MUST_ENABLE
	,META_CCT_ERR_UNSUPPORT_CAPTURE_FORMAT
	,META_CCT_ERR_EXCEED_MAX_DEFECT_PIXEL
	,META_ERR_EXCEED_MAX_PEER_BUF_SIZE
	,META_CCT_ERR_INVALID_WIDTH_FACTOR
	,META_BROM_SECURITY_CHECK_FAIL
	,META_CCT_ERR_PREVIEW_MUST_DISABLE
	,META_MAUI_DB_INCONSISTENT
	,META_FAT_FILEPATH_TOO_LONG
	,META_FAT_RESTRICTED_FILEPATH
	,META_FAT_DIR_NOT_EXIST
	,META_FAT_DISK_SPACE_IS_NOT_ENOUGH
	,META_TDMB_ERR_BAND_NOT_EXIST
	,META_TDMB_ERR_FREQ_NOT_EXIST
	,META_TDMB_ERR_ENSM_NOT_EXIST
	,META_TDMB_ERR_SERV_NOT_EXIST
	,META_TDMB_ERR_SUB_CHAN_NOT_EXIST
	,META_TDMB_ERR_DEMOD_STATE
	,META_PERMISSION_DENIED
	,META_ENUMERATE_USB_FAIL
  ,META_STOP_ENUM_USB_PROCEDURE
   //----------------[TH] for CCT 6238--------------------------
  ,META_CCT_6238_AE_ALREADY_ENABLED
  ,META_CCT_6238_AE_ALREADY_DISABLED
  ,META_CCT_6238_AE_IS_NOT_DISABLED
  ,META_CCT_6238_ISP_FLASHLIGHT_LINEARITY_PRESTROBE_FAIL
  //-----------------------------------------------------------
  ,META_NOT_SUPPORT
  //-----------------for Multi-log------------------
  ,META_LOG_ERROR_OPEN_FILE

  ,META_LAST_RESULT
} META_RESULT;

typedef enum  {
	META_BAUD2400 = 0,
	META_BAUD4800,
	META_BAUD9600,
	META_BAUD14400,
	META_BAUD19200,
	META_BAUD57600,   // 5
	META_BAUD115200,
	META_BAUD230400,
	META_BAUD460800,
	META_BAUD921600,
	META_BAUD1500000,            //10
	META_BAUD_END = 0xFF
} META_COMM_BAUDRATE;

typedef enum {
	META_NO_FLOWCTRL = 0,	// no flow control
	META_SW_FLOWCTRL,		// enable S/W flow control
	META_FLOWCTRL_END
} META_FLOWCTRL;

typedef struct {
	char	BB_CHIP[64];	// BaseBand chip version
	char	ECO_VER[4];		// ECO version
	char	SW_TIME[64];
	char	DSP_FW[64];		// DSP firmware version
	char	DSP_PATCH[64];	// DSP patch version
	char	SW_VER[64];		// S/W version
	char	HW_VER[64];		// H/W board version
	char	MELODY_VER[64];	// Melody version
	unsigned char status;
} VerInfo_Cnf;

typedef struct {
	char	BB_CHIP[64];	// BaseBand chip version
	char	ECO_VER[4];		// ECO version
	char	SW_TIME[64];
	char	DSP_FW[64];		// DSP firmware version
	char	DSP_PATCH[64];	// DSP patch version
	char	SW_VER[64];		// S/W version
	char	HW_VER[64];		// H/W board version
	char	MELODY_VER[64];	// Melody version
	char	BUILD_DISP_ID[64];  //build version
	unsigned char status;
} VerInfo_V2_Cnf;


typedef struct {
	char	code_func[64];	
	char	code_proj[64];		
	char	code_date[64];
	char	code_fab[64];		
	unsigned char status;
} ChipInfo_Cnf;

typedef struct
{
	unsigned short      com_port_list[255];   
	unsigned short      com_port_num;
	unsigned int		ms_connect_timeout; // [META] META enumerate port timeout value 

}META_Enumerate_USB_Req;

typedef struct {
	int 				com_port;
	META_COMM_BAUDRATE  baudrate[12];		// [META] META stage baudrate polling array, it must end with META_BAUD_END. 
	META_FLOWCTRL  		flowctrl;			// [META] META stage uart flow control type. 
	unsigned int		ms_connect_timeout; // [META] META stage sync timeout value (after BootROM negotiation pass) 
} META_Connect_Req;

typedef struct {
	META_COMM_BAUDRATE  final_baudrate;					// [META] Detected META stage baudrate.     
	unsigned int		meta_ver_required_by_target;	// [META] Target required META_DLL version. 
} META_Connect_Report;

typedef struct {
	int 				com_port;
	unsigned int		ms_connect_timeout; // [META] META stage sync timeout value (after BootROM negotiation pass) 
} META_ConnectByUSB_Req;

typedef struct {
	unsigned int		meta_ver_required_by_target;	// [META] Target required META_DLL version. 
} META_ConnectByUSB_Report;

typedef struct {
	int 				com_port;
	META_COMM_BAUDRATE  baudrate[11];		// [META] META stage baudrate polling array, it must end with META_BAUD_END. 
	META_FLOWCTRL  		flowctrl;			// [META] META stage uart flow control type. 
	unsigned int		ms_connect_timeout; // [META] META stage sync timeout value (after BootROM negotiation pass) 
}WM_META_ConnectInMETA_Req;


typedef struct {
	META_COMM_BAUDRATE  final_baudrate;					// [META] Detected META stage baudrate. 
	unsigned int		meta_ver_required_by_target;	// [META] Target required META_DLL version. 
}WM_META_ConnectInMETA_Report;



//-----------------------------------------------------//
//  META General: callback function definition         //
//-----------------------------------------------------//
typedef void (__stdcall *META_Error_CallBack)(const META_CNF_ERR_CODE  mr);
typedef void (__stdcall *META_SysTrace_CallBack)(const char *sys_trace);
typedef void (__stdcall *META_GET_VERSION_INFO_CNF)(const VerInfo_Cnf  *cnf, const short token, void *usrData);
typedef void (__stdcall *META_GET_VERSION_INFO_V2_CNF)(const VerInfo_V2_Cnf  *cnf_v2, const short token, void *usrData);
typedef void (__stdcall *META_GET_CHIP_INFO_CNF)(const ChipInfo_Cnf  *cnf, const short token, void *usrData);

//-----------------------------------------------------//
//  META for CTI                                       //
//-----------------------------------------------------//
typedef enum {
	 CTI_OK = 0
	,CTI_MISSING_HEADER
	,CTI_CORRUPTED_FAME
	,CTI_EXCEED_LEN
} CTI_RET_ENUM;

typedef void (__stdcall *META_CTI_CallBack)(CTI_RET_ENUM  ret, const int size, const unsigned char *data, void *param);

//-----------------------------------------------------//
//  Switch TST message format                          //
//-----------------------------------------------------//
typedef enum {
	META_TST_MSG_2G = 0,
	META_TST_MSG_3G
} META_TST_MSG_FORMAT;

META_RESULT  __stdcall SP_META_SetTstMsgFormat(META_TST_MSG_FORMAT  msg_fmt);
META_RESULT  __stdcall SP_META_SetTstMsgFormat_r(const int meta_handle, META_TST_MSG_FORMAT  msg_fmt);

//-----------------------------------------------------//
//  META Debug: exported debug function definition     //
//-----------------------------------------------------//
META_RESULT  __stdcall SP_META_DebugOn();
META_RESULT  __stdcall SP_META_DebugOn_ex(const int meta_handle);
META_RESULT  __stdcall SP_META_DebugOff();
META_RESULT  __stdcall SP_META_DebugClear();
META_RESULT  __stdcall SP_META_DebugOnThePath(const char * path);
META_RESULT  __stdcall SP_META_DebugOnThePath_ex(const int meta_handle,const char * path);

//-----------------------------------------------------//
//  META UnitTest                                      //
//-----------------------------------------------------//

/*
typedef struct {
	unsigned int	m_TestCaseID;
	const char *	m_pDescription;
} META_UT_TestCaseID_T;
*/

//void __stdcall META_QueryTestCase(META_UT_TestCaseID_T  **ppTestCase, unsigned int  *pTestCaseCount);
//void __stdcall META_UnitTest(const unsigned int  *p_TestCaseID_Array, unsigned int  TestCaseCount);

//-----------------------------------------------------//
//  META General: exported function definition         //
//-----------------------------------------------------//

#define     FT_MT_UNKNOWN  0
#define     FT_MT6305  1
#define     FT_MT6318  2 
#define     FT_MT6326  3
typedef struct {
	unsigned char	id;
} PMIC_ID;
typedef struct {
	unsigned int	pcl;
} RF_GetITC_PCL;
// General 

void  __stdcall SP_META_GetDLLVer(unsigned int *major_ver, unsigned int *minor_ver, unsigned int *build_num, unsigned int *patch_num);
void  __stdcall SP_META_GetDLLInfo(const char **pp_version, const char **pp_release_type, const char **pp_build_date, const char **pp_load_path);
void  __stdcall SP_META_Cancel(const short token);
void  __stdcall SP_META_Cancel_r(const int meta_handle, const short token);
void  __stdcall SP_META_CancelAllBlockingCall(void);
void  __stdcall SP_META_CancelAllBlockingCall_r(const int meta_handle);

META_RESULT  __stdcall SP_META_QueryIfFunctionSupportedByTarget(unsigned int ms_timeout, const char *query_func_name);
META_RESULT  __stdcall SP_META_QueryIfFunctionSupportedByTarget_r(const int meta_handle, unsigned int ms_timeout, const char *query_func_name);


META_RESULT  __stdcall SP_META_QuerySpeakerCalibrationSupport(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QuerySpeakerCalibrationSupport_r(const int meta_handle, unsigned int ms_timeout);

META_RESULT  __stdcall SP_META_QueryIfTargetIsLowCostSingleBankFlash(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfTargetIsLowCostSingleBankFlash_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryPMICID(unsigned int  ms_timeout, PMIC_ID  *cnf);
META_RESULT  __stdcall SP_META_QueryPMICID_r(const int meta_handle, unsigned int  ms_timeout, PMIC_ID  *cnf);
META_RESULT  __stdcall SP_META_QueryITC_PCL(unsigned int  ms_timeout, RF_GetITC_PCL  *cnf);
META_RESULT  __stdcall SP_META_QueryITC_PCL_r(const int meta_handle, unsigned int  ms_timeout, RF_GetITC_PCL  *cnf);
META_RESULT  __stdcall SP_META_QueryIfTargetSupportDRC(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfTargetSupportDRC_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfBTPowerOn(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfBTPowerOn_r(const int meta_handle, unsigned int ms_timeout);
// META_RESULT  __stdcall SP_META_BTOpen(unsigned int ms_timeout);
// META_RESULT  __stdcall SP_META_BTOpen(const int meta_handle, unsigned int ms_timeout);

//-----------------------------------------------------//
//  UTILITY--ENABLE WATCHDOG				           //
//-----------------------------------------------------//
#define GPIO_DEV_LED_MAINLCD 0
//#define GPIO_DEV_LED_SUBLCD 1

typedef struct  {
	unsigned char			lcd_light_level;
}LCDLevel_REQ;

typedef struct  {
	int			status;
}LCDLevel_CNF;

typedef struct  {
	int				onoff;
	char					DIV;
	char					DUTY;
}KeypadBK_REQ;

typedef struct  {
	int			status;
}KeypadBK_CNF;

typedef struct{
    unsigned int LedNum;
    int  OFFON;
}NLED_REQ;

typedef struct{
    int ret;
}NLED_CNF;

typedef struct{
   int 	Notused;
   unsigned char BackupTime[64];
}SetCleanBootFlag_REQ;

typedef struct{
   int 	drv_status;
}SetCleanBootFlag_CNF;



typedef struct  {
	unsigned short		interval;
}WatchDog_REQ;

typedef struct  {
	unsigned short		rtc_sec;    
	unsigned short		rtc_min;    
	unsigned short		rtc_hour;   
	unsigned short		rtc_day;    
	unsigned short		rtc_mon;    
	unsigned short		rtc_wday;  
	unsigned short		rtc_year;  
	unsigned short		status;
}WatchDog_CNF;


//META_RESULT  __stdcall META_EnableWatchDogTimer(unsigned int ms_timeout, FtWatchDog *req);
//META_RESULT  __stdcall META_EnableWatchDogTimer_r(const int meta_handle, unsigned int ms_timeout, FtWatchDog *req);


META_RESULT  __stdcall SP_META_SetLEDLightLevelforMT6573(unsigned int ms_timeout, NLED_REQ *req);
META_RESULT  __stdcall SP_META_SetLEDLightLevelforMT6573_r(const int meta_handle, unsigned int ms_timeout, NLED_REQ *req);
META_RESULT  __stdcall SP_META_SetVibratorOnOff(unsigned int ms_timeout, NLED_REQ *req);
META_RESULT  __stdcall SP_META_SetVibratorOnOff_r(const int meta_handle, unsigned int ms_timeout, NLED_REQ *req);
META_RESULT  __stdcall SP_META_SetSignalIndicatorOnOff(unsigned int ms_timeout, NLED_REQ *req);
META_RESULT  __stdcall SP_META_SetSignalIndicatorOnOff_r(const int meta_handle, unsigned int ms_timeout, NLED_REQ *req);
META_RESULT  __stdcall SP_META_QueryLocalTime(unsigned int  ms_timeout, WatchDog_CNF  *cnf);
META_RESULT  __stdcall SP_META_QueryLocalTime_r(const int meta_handle, unsigned int  ms_timeout, WatchDog_CNF  *cnf);
META_RESULT  __stdcall SP_META_SetMainSubLCDLightLevel(unsigned int ms_timeout, LCDLevel_REQ *req);
META_RESULT  __stdcall SP_META_SetMainSubLCDLightLevel_r(const int meta_handle, unsigned int ms_timeout, LCDLevel_REQ *req);
// timer-related APIs
META_RESULT  __stdcall SP_META_StartTimer();
META_RESULT  __stdcall SP_META_StartTimer_r(const int meta_handle);
META_RESULT  __stdcall SP_META_StopTimer();
META_RESULT  __stdcall SP_META_StopTimer_r(const int meta_handle);
META_RESULT  __stdcall SP_META_GetProcessTime(unsigned int  *pProcessTime, unsigned short *pNumAPIs);
META_RESULT  __stdcall SP_META_GetProcessTime_r(const int meta_handle, unsigned int *pProcessTime, unsigned short *pNumAPIs);
const char * __stdcall SP_META_GetErrorString(META_RESULT  ErrCode);
const char * __stdcall SP_META_BaudrateEnumToName(META_COMM_BAUDRATE  baudrate);
// Initialization 
META_RESULT  __stdcall SP_META_GetAvailableHandle(int *p_meta_handle);
META_RESULT  __stdcall SP_META_Init(const META_Error_CallBack  cb);
META_RESULT  __stdcall SP_META_Init_r(const int meta_handle, const META_Error_CallBack  cb);
META_RESULT  __stdcall SP_META_SetSysTraceCallback(const META_SysTrace_CallBack  sys_cb);
META_RESULT  __stdcall SP_META_SetSysTraceCallback_r(const int meta_handle, const META_SysTrace_CallBack  sys_cb);
void  __stdcall SP_META_Deinit(void);
void  __stdcall SP_META_Deinit_r(int *p_meta_handle);


// connect with target 
META_RESULT  __stdcall SP_META_ConnectWithTarget(const META_Connect_Req  *req, int *p_bootstop, META_Connect_Report  *p_report);
META_RESULT  __stdcall SP_META_ConnectWithTarget_r(const int meta_handle, const META_Connect_Req  *req, int *p_bootstop, META_Connect_Report  *p_report);
// disconnect and shutdown target
META_RESULT  __stdcall SP_META_DisconnectWithTarget(void);
META_RESULT  __stdcall SP_META_DisconnectWithTarget_r(const int meta_handle);

// connect with target when target already in meta mode 
META_RESULT  __stdcall SP_META_ConnectInMetaMode(const WM_META_ConnectInMETA_Req  *req, int *p_bootstop, WM_META_ConnectInMETA_Report  *p_report);
META_RESULT  __stdcall SP_META_ConnectInMetaMode_r(const int meta_handle, const WM_META_ConnectInMETA_Req  *req, int *p_bootstop, WM_META_ConnectInMETA_Report  *p_report);

// disconnect without shutdown target
META_RESULT  __stdcall SP_META_DisconnectInMetaMode(void);
META_RESULT  __stdcall SP_META_DisconnectInMetaMode_r(const int meta_handle);

// USB-related connect
META_RESULT  __stdcall SP_META_ConnectInMetaModeByUSB(const META_ConnectByUSB_Req  *req, int *p_bootstop, META_ConnectByUSB_Report  *p_report);
META_RESULT  __stdcall SP_META_ConnectInMetaModeByUSB_r(const int meta_handle, const META_ConnectByUSB_Req  *req, int *p_bootstop, META_ConnectByUSB_Report  *p_report);

META_RESULT  __stdcall SP_META_ConnectWithTargetByUSB(const META_ConnectByUSB_Req  *req, int *p_bootstop, META_ConnectByUSB_Report  *p_report);
META_RESULT  __stdcall SP_META_ConnectWithTargetByUSB_r(const int meta_handle, const META_ConnectByUSB_Req  *req, int *p_bootstop, META_ConnectByUSB_Report  *p_report);
META_RESULT  __stdcall SP_META_GetDynamicUSBComPort(unsigned int ms_scan_timeout, unsigned short *com_port, int *p_scanstop);
META_RESULT  __stdcall SP_META_GetDynamicUSBComPort_r(const int meta_handle, unsigned int ms_scan_timeout, unsigned short *com_port, int *p_scanstop);

// Get target S/W, H/W and Melody version
META_RESULT  __stdcall SP_META_GetTargetVerInfo(const META_GET_VERSION_INFO_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_GetTargetVerInfo_r(const int meta_handle, const META_GET_VERSION_INFO_CNF  cb, short *token, void *usrData);

// Get target S/W, H/W, melody and build version
META_RESULT  __stdcall SP_META_GetTargetVerInfoV2(VerInfo_V2_Cnf  *cnf_v2, short *token, void *usrData);
META_RESULT  __stdcall SP_META_GetTargetVerInfoV2_r(const int meta_handle, VerInfo_V2_Cnf  *cnf_v2, short *token, void *usrData);

// Get Chip Info
META_RESULT  __stdcall SP_META_GetTargetChipInfo(const META_GET_CHIP_INFO_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_GetTargetChipInfo_r(const int meta_handle, const META_GET_CHIP_INFO_CNF  cb, short *token, void *usrData);

// Get build properity
typedef struct
{
    unsigned char tag[64];
    
} BUILD_PROP_REQ_S;

typedef struct
{
    unsigned char content[128];
    
} BUILD_PROP_CNF_S;

META_RESULT  __stdcall SP_META_GetTargetBuildProp(BUILD_PROP_REQ_S * pReq, BUILD_PROP_CNF_S * pCnf);
META_RESULT  __stdcall SP_META_GetTargetBuildProp_r(const int meta_handle, BUILD_PROP_REQ_S * pReq, BUILD_PROP_CNF_S * pCnf);


// Shutdown target 
META_RESULT  __stdcall SP_META_ShutDownTarget(void);
META_RESULT  __stdcall SP_META_ShutDownTarget_r(const int meta_handle);

// Close Com Port
META_RESULT  __stdcall SP_META_CloseComPort(void);
META_RESULT  __stdcall SP_META_CloseComPort_r(const int meta_handle);

// Close Com Port and reboot
META_RESULT  __stdcall SP_META_CloseComPortReboot(void);
META_RESULT  __stdcall SP_META_CloseComPortReboot_r(const int meta_handle);

META_RESULT  __stdcall SP_META_RebootTarget(unsigned int delay);
META_RESULT  __stdcall SP_META_RebootTarget_r(const int meta_handle,unsigned int delay);

// ***** Expired Functions -- BEGIN ***** //
// these functions are expired, we encourage you to use META_ConnectWithTarget and META_DisconnectWithTarget 
META_RESULT  __stdcall SP_META_COMM_Set_Baudrate(const META_COMM_BAUDRATE  baudrate);
META_RESULT  __stdcall SP_META_COMM_Set_Baudrate_r(const int meta_handle, const META_COMM_BAUDRATE  baudrate);
META_RESULT  __stdcall SP_META_COMM_Start(const int comm_port, const META_FLOWCTRL  flowctrl);
META_RESULT  __stdcall SP_META_COMM_Start_r(const int meta_handle, const int comm_port, const META_FLOWCTRL  flowctrl);
META_RESULT  __stdcall SP_META_COMM_Stop(void);
META_RESULT  __stdcall SP_META_COMM_Stop_r(const int meta_handle);
META_RESULT  __stdcall SP_META_WaitForTargetReady(unsigned int ms_waiting_time, unsigned int request_count);
META_RESULT  __stdcall SP_META_WaitForTargetReady_r(const int meta_handle, unsigned int ms_waiting_time, unsigned int request_count);
META_RESULT  __stdcall SP_META_GetTargetRequiredMetaVer(unsigned int *p_meta_ver_required_by_target);
META_RESULT  __stdcall SP_META_GetTargetRequiredMetaVer_r(const int meta_handle, unsigned int *p_meta_ver_required_by_target);


META_RESULT  __stdcall SP_META_SetVersionInfo(VerInfo_Cnf *vinfo);

META_RESULT  __stdcall SP_META_BackupEFuseToFile( unsigned int ms_timeout, char * path);
META_RESULT  __stdcall SP_META_BackupEFuseToFile_r(const int meta_handle, unsigned int ms_timeout,char * path);


// ***** Expired Functions -- END ***** //

//--------------------------------------------------------------------------//
//  3G RF Testing                                                           //
//--------------------------------------------------------------------------//

//-----------------------------------------------------//
//  3G RF Testing: data structure definition           //
//-----------------------------------------------------//
typedef enum {
	URF_TEST_CMD_TXACCESS = 0
	,URF_TEST_CMD_STOP
	,URF_TEST_CMD_TX_DPCH
	,URF_TEST_CMD_RX_DPCH
	,URF_TEST_CMD_RSSI
	,URF_TEST_CMD_RSCP
	,URF_TEST_CMD_AFC
	,URF_TEST_CMD_TX_PAAPC  // for calling UL1D_RF_SetPaApcDac in FT task
	,URF_TEST_CMD_GET_RFID
	,URF_TEST_CMD_CONFIG_HWTPC
	,URF_TEST_CMD_GET_PWR_DT_STEP
	,URF_TEST_CMD_GET_PWR_DT_DAC
	,URF_TEST_CMD_GET_PWR_DT_DEFAULT_THR
	,URF_TEST_CMD_SET_IMMEDIATE_BSI
	,URF_TEST_CMD_GET_IMMEDIATE_BSI
	,URF_TEST_CMD_END
}URfTestCmdType;

typedef struct {
	unsigned short	uarfcn;			//kal_int16
	short			psc;			//kal_int16
	unsigned short	signature;	    //kal_uint16
	unsigned char	pa_mode;		//unsigned char
	char			init_power;		//kal_int8
	unsigned char   power_step;     //kal_uint8	
	unsigned char	max_retrans;	//kal_uint8
}URfTestCmdTxAccess;
typedef struct
{
	//unsigned short	dl_freq;
	unsigned short	ul_freq;
	short	psc;		/* 0~511. */
	unsigned int	sc_code;	/* Scrambling code #. 0 ~ 16777215 */
	unsigned char   power_ctrl_mode;
	unsigned char 	pa_mode;
	unsigned short 	idx;
	unsigned short	afc_dac;
	unsigned char	dpcch_pwr;
	unsigned char	dpdch_pwr;
	
	/* Below for UL1D_RF_Meta_SetTxInfo. */
	bool 	no_loop_ctrl;
	
	/* Below for setPaApcDac. */	
	unsigned char 	rf_band;
	unsigned char   vm1;
    unsigned char   vm2;
	unsigned short  dc2dc_dac;
    unsigned short  vbias_dac;
	bool            pwr_det;
	unsigned short 	apc_dac;		
} URfTestCmdTxDPCh;	//Anthony  target side is :UL1TSTCmdTxDPCh and  URfTestCmdTxDPCh

typedef struct
{
	unsigned short	dl_freq;
	short	psc;	/* 0~511. */
	unsigned char	ssc;	/* 0~15. */
	short	ovsf;	/* 0~sf-1. */
	unsigned short	afc_dac;
	
	/* Below for RF_SetBBRxParams. */
	bool 	hwAGC;
	unsigned char	mode;		/* 0: mode0, 1: mode1. */
	short	gain;		/* mode0. */
	unsigned char	LNAmode;	 /* mode1. 0: LNA high, 1: LNA mid, 2: LNA low. */
	unsigned short	pga;		/* mode1. */
} URfTestCmdRxDPCh;
#define MAX_FREQ_LIST 36
typedef struct
{
	unsigned char	num_freq;
	unsigned short	dl_freq[ MAX_FREQ_LIST ];
	unsigned char   temperature;
	
	/* Below for RF_SetBBRxParams. */
	bool 	hwAGC;
	unsigned char	mode;		/* 0: mode0, 1: mode1. */
	short	gain;		/* mode0. */
	unsigned char	LNAmode;	/* mode1. 0: LNA high, 1: LNA mid, 2: LNA low. */
	unsigned short	pga;		/* mode1. */
} URfTestCmdRSSI;

typedef struct
{
	bool	pscan_before_cell_search;	/* True if UL1TST needs power scan before cell search/RSCP. */
	unsigned short	dl_freq;	/* Specific dl_freq to do cell search. Valid if pscan_before_cell_search=F. */
	unsigned char	sample_num_per_cell;
	bool	read_sfn;	/* True if we need to do SFN measurement for the found cell. */
	
	/* Below for RF_SetBBRxParams. */
	bool 	hwAGC;
	unsigned char	mode;		/* 0: mode0, 1: mode1. */
	short	gain;		/* mode0. */
	unsigned char	LNAmode;	/* mode1. 0: LNA high, 1: LNA mid, 2: LNA low. */
	unsigned short	pga;		/* mode1. */
} URfTestCmdRSCP;

typedef struct
{
	//kal_bool	pscan_before_cell_search;	/* True if UL1TST needs power scan before cell search/RSCP. */
	short	        dl_freq;	/* Specific dl_freq to do cell search. Valid if pscan_before_cell_search=F. */
	//kal_uint8	sample_num_per_cell;
	//kal_bool	read_sfn;	/* True if we need to do SFN measurement for the found cell. */
	
	short           afc_dac;    //anthony 0514
	
	/* Below for RF_SetBBRxParams. */
	bool 	        hwAGC;
	unsigned char	mode;		/* 0: mode0, 1: mode1. */
	short	        gain;		/* mode0. */
	unsigned char	LNAmode;	/* mode1. 0: LNA high, 1: LNA mid, 2: LNA low. */
	unsigned short	pga;		/* mode1. */

} URfTestCmdAFC;

typedef struct
{
	char            m_cRfBand;    // only 0 ~ 5
    unsigned short  m_u2Idx;
	unsigned char   m_ucPaMode;
//	unsigned short m_u2PaDac;
	unsigned char    m_ucVm1;
	unsigned char    m_ucVm2;
	unsigned short   m_u2DC2DC_Dac;
	unsigned short   m_u2Vbias_Dac;
	unsigned short   m_u2ApcDac;

}UL1D_RF_TX_PA_APC_REQ_T;


typedef struct
{
   // structure of META_HWTPC_FRAME_INFO in target
   unsigned char tpc_step;
   unsigned char itp;
   unsigned char rpp;
   unsigned char fmt_idx;
   unsigned char dl_frame_type;
   unsigned short slot_mask;
   char   tpc_cmd[15];
   unsigned char  beta_c;
   unsigned char  beta_d;

}UL1D_RF_HWTPC_FRAME_INFO;

typedef struct
{
   unsigned char pc_algo;
   unsigned char tpc_used_frame;  // at most 8 so far
   short  p_ini;

   UL1D_RF_HWTPC_FRAME_INFO frame_info[8];
   
}UL1D_RF_HWTPC_CONFIG_REQ_T;


typedef struct
{
	unsigned char rf_band;

}UL1D_RF_GET_PWR_THR_REQ_T;

typedef struct
{
    unsigned int bsi_data;
}UL1D_RF_SET_BSI_DATA_REQ_T;

typedef struct
{
    unsigned int bsi_addr;
}UL1D_RF_GET_BSI_DATA_REQ_T;



typedef union {
	URfTestCmdTxAccess         txaccess;
	URfTestCmdTxDPCh	txdpch;	//Anthony
	URfTestCmdRxDPCh	rxdpch;
	URfTestCmdRSSI		rssi;
	URfTestCmdRSCP		rscp;
	URfTestCmdAFC       afc;
    UL1D_RF_TX_PA_APC_REQ_T    m_rTxPaApc;
	UL1D_RF_HWTPC_CONFIG_REQ_T  m_rHWTPC;
	UL1D_RF_GET_PWR_THR_REQ_T   m_rGetPwrThr;
}URfTestCmdParam;

typedef struct
{
	bool	ok;
	unsigned char	num_freq;
	short	dl_freq[ MAX_FREQ_LIST ];
	int	rssi[ MAX_FREQ_LIST ];	
} URfTestResultRSSI;



typedef struct
{	
	unsigned short	psc;		/* Primary scrambling code */
	int	tm;		/* Cell frame boundary offset to LST */
	short	off;		/* Cell frame number offset to LST */	
	bool	sttd; 		/* True for STTD used. */
	unsigned char	sample_num;
	unsigned char	rscp_sum;
	short freq_error;  // 20070514
} UL1TST_cpich_result_T;

#define MAX_NUM_MEAS_CELL 32
typedef struct
{
	bool		ok;
	unsigned char		num_cell;
	UL1TST_cpich_result_T	cpich_result[ MAX_NUM_MEAS_CELL ];	
} URfTestResultRSCP;

typedef struct
{
	bool	        ok;
	unsigned short	psc;		/* Primary scrambling code */
	int	            tm;		/* Cell frame boundary offset to LST */
	bool	        sttd; 		/* True for STTD used. */
	unsigned char	rscp_sum;
	short           freq_error;	//anthony 0514    

}URfTestResultAFC;

typedef struct
{
	bool	ok;
	unsigned int	ber;	/* Spec requirement=10^-3. We will count 10^5 frames(100 times spec requirement) for BER calculation. Only count for the only TRCh for DPDCh. */
} URfTestResultRxDPCh;

#define  UL1D_RF_ID_SONY_CXA3359    0x00000001
#define  UL1D_RF_ID_MT6159B         0x00000002
#define  UL1D_RF_ID_SMARTI3G        0x00000003
#define  UL1D_RF_ID_MT6159C         0x00000004


typedef struct
{
	unsigned int m_u4Rfid;
	
}URfTestResultRFID;

typedef struct
{
	unsigned char m_u1Result;

}URfTestResultPwrDtStep;

typedef struct
{
	unsigned short m_u2Result;

}URfTestResultPwrDtDac;

typedef struct
{

	unsigned char m_u1Result;

}URfTestResultPwrDtDefaultThr;


typedef union {
	bool	ok;   //kal_bool  // for only request
	URfTestResultRSSI	rssi;
	URfTestResultAFC    afc;
  URfTestResultRSCP	rscp;
  URfTestResultRxDPCh	rx_dpch;
	URfTestResultRFID   rfid;
	URfTestResultPwrDtStep        pwr_dt_step;
	URfTestResultPwrDtDac         pwr_dt_dac;
  URfTestResultPwrDtDefaultThr  pwr_dt_default_thr;
  unsigned int                  bsi_data;
}URfTestResultParam;


//--------------------------------------------------------------------------//
//  RF Testing                                                              //
//--------------------------------------------------------------------------//

//-----------------------------------------------------//
//  RF Testing: data structure definition              //
//-----------------------------------------------------//
typedef short	ARFCN;
typedef short	Gain;
typedef char	BSIC;
typedef short	Power;
typedef unsigned char	TimingAdvance;

// RF ID 
#define  RF_ID_UNKNOWN     0x00000000
#define  RF_ID_BRIGHT2     0x00000001
#define  RF_ID_BRIGHT4     0x00000002
#define  RF_ID_AERO        0x00000004
#define  RF_ID_AERO1PLUS   0x00000008
#define  RF_ID_POLARIS1    0x00000010
#define  RF_ID_POLARIS2    0x00000020
#define  RF_ID_SKY74045    0x00000040
#define  RF_ID_BRIGHT5P    0x00000080
#define  RF_ID_MT6116      0x00000100
#define  RF_ID_MT6119      0x00000200
#define  RF_ID_MT6119C     0x00000400
#define  RF_ID_MT6129A     0x00000800
#define  RF_ID_MT6129B     0x00001000
#define  RF_ID_MT6129C     0x00002000
#define  RF_ID_MT6129D     0x00004000
#define  RF_ID_MT6139B     0x00008000
#define  RF_ID_MT6139C     0x00010000
#define  RF_ID_MT6140A     0x00020000
#define  RF_ID_SKY74117    0x00040000
#define  RF_ID_SKY74400    0x00080000
#define  RF_ID_AERO2       0x00100000
#define  RF_ID_MT6140B     0x00200000
#define  RF_ID_ALICEG2S    0x00400000
#define  RF_ID_MT6139E     0x00800000
#define  RF_ID_SKY74137    0x01000000
#define  RF_ID_MT6140C     0x02000000
#define  RF_ID_GRF6201     0x04000000
#define  RF_ID_IRFS3001    0x08000000
#define  RF_ID_MT6140D     0x10000000
#define  RF_ID_AG2550      0x10000001
#define  RF_ID_AERO2E      0x10000002
#define  RF_ID_AD6548      0x10000005     
#define  RF_ID_AD6546      0x10000006
#define  RF_ID_A60111A     0x10000007

typedef enum
{
   FrequencyBand400=0,				// GSM 450/480 band
   FrequencyBand850,				// GSM 850 band
   FrequencyBand900,				// GSM 900 band
   FrequencyBand1800,				// DCS 1800 band
   FrequencyBand1900,				// PCS 1900 band

   FrequencyBandCount				// count of supported bands
} FrequencyBand;

typedef struct 
{
	ARFCN			arfcn;				// Absolute radio frequency channel number
	char			sampleNoPerFrame;	// number of samples per frame
	Gain			gain;				// Gain that should be used in power management
	short			frames;				// number of frames
} RfPm_Req;

typedef struct {
	unsigned char	valid;				// if valid != zero, it means the extra info is meaningful. 
										// otherwise, the extra info should be ignore. 
   	int				iOffset;
	int				qOffset;
	int				validSamples;
} RfPmExtraInfo_T;

typedef struct
{
	int				power;				// average power
	int				deviation;			// deviation of power measurement
	Gain			usedGain;			// Gain that is used
	unsigned char	ok;					// status
	RfPmExtraInfo_T	extra_info;			// extra info 
} RfPm_Cnf;

typedef struct
{
	ARFCN			arfcn;				// absolute radio frequency channel number
	short			dacValue;			// AFC DAC value
	Gain			gain;				// gain used for AFC testing
	short			testNumber;			// test number
} RfAfc_Req;

typedef struct
{
	short			fcb_ok_number;		// successful number of FCB decoded
	int				freqOffset;			// average frequency error
	int				deviation;			// deviation of frequency error
	unsigned char	ok;					// status
} RfAfc_Cnf;

typedef enum {
	 AB_TX_RANDOM_WITH_SYNC_SEQ
	,NB_TX_ALL_ZEROS_WITHOUT_TSC
	,NB_TX_ALL_ONES_WITHOUT_TSC
	,NB_TX_ALTER_BITS_WITHOUT_TSC
	,NB_TX_RANDOM_WITH_TSC
	,NB_TX_PATTERN_WITHOUT_TSC
	,NB_TX_FIXED_RANDOM_WITH_TSC
	,NB_TX_FIXED_ALL_ZEROS_WITH_TSC
	,NB_TX_FIXED_ALTER_BITS_WITH_TSC
} APCTxPattern;

typedef struct
{
	ARFCN			arfcn;				// Absolute radio frequency channel number
	BSIC			bsic;				// bsic value used in transmission
	Power			power;				// Tx power in the unit of PCL
	short			frames;				// the number of frames NB should transmit
	short			dacValue;			// AFC DAC value
	APCTxPattern	burstTypeNB;
} RfNbtx_Req;

typedef struct
{
	ARFCN			arfcn;				// Absolute radio frequency channel number
	Gain			gain;				// Gain that should be used
	unsigned char	OnOff;				// On or off
} RfCnRx_Req;

typedef enum {
	CONT_TX_ALL_ZEROS
	,CONT_TX_ALL_ONES
	,CONT_TX_ALTERNATE_BITS
	,CONT_TX_PSEUDO_RANDOM
	,CONT_TX_PATTERN_WITHOUT_TSC
} ContTxPattern;

typedef struct
{
	ARFCN			arfcn;				// Absolute radio frequency channel number
	ContTxPattern	pattern;
	unsigned char	OnOff;				// On or off
} RfCnTx_Req;

typedef struct
{
	char	TxTrimI;
	char	TxTrimQ;
	char	TxOffsetI;
	char	TxOffsetQ;
} RfSetBBTXCfg_Req;

typedef struct {
	char	TxTrimI;
	char	TxTrimQ;
	char	TxOffsetI;
	char	TxOffsetQ;
	char	TxCalbias;
	char	TxIQSwap;
	char	TxCMV;
	char	TxGain;
	char	TxCalrcsel;
} RfBBTXCfg2;

typedef struct {
	char	TxTrimI;
	char	TxTrimQ;
	char	TxOffsetI;
	char	TxOffsetQ;
	char	TxCalbias;
	char	TxIQSwap;
	char	TxCMV;
	char	TxGain;
	char	TxCalrcsel;
	char	TxPhasesel;
} RfBBTXCfg3;

typedef struct {
	char    TxTrimI;
	char    TxTrimQ;
	char	TxOffsetI;
	char	TxOffsetQ;
	char	TxCalbias;
	char	TxIQSwap;
	char	TxCMV;
	char	TxGain;
	char	TxCalrcsel;
	char	TxPhasesel;
	char    TxCoarseI;
	char    TxCoarseQ;

}RfBBTXCfg4;  //RfTestCmdSetBBTXCfg4

typedef struct
{
    unsigned char bbtx_common_mode_voltage;
    unsigned char bbtx_gain;
    unsigned char bbtx_calrcsel;
//    unsigned char bbtx_coarseI; // need to set
//   unsigned char bbtx_coarseQ; // need to set
    unsigned char bbtx_trimI;   // need to set
    unsigned char bbtx_trimQ;   // need to set
	unsigned char bbtx_dccoarseI; // need to set
    unsigned char bbtx_dccoarseQ; // need to set
    unsigned char bbtx_offsetI; // need to set
    unsigned char bbtx_offsetQ; // need to set
    unsigned char bbtx_isCalibrated; // need to set
    int           apc_bat_low_voltage;
    int           apc_bat_high_voltage;
    int           apc_bat_low_temperature;
    int           apc_bat_high_temperature;
    unsigned char bbtx_common_mode_voltage_h;
    unsigned char bbtx_gain_h;
    unsigned char bbtx_calrcsel_h;
    unsigned char bbtx_trimI_h;
    unsigned char bbtx_trimQ_h;
//    unsigned char bbtx_coarseI_h;
//    unsigned char bbtx_coarseQ_h;
	unsigned char bbtx_dccoarseI_h;
    unsigned char bbtx_dccoarseQ_h;

    unsigned char bbtx_offsetI_h;
    unsigned char bbtx_offsetQ_h;
    unsigned char bbtx_phsel;
    unsigned char bbtx_phsel_h;
//    unsigned char bbrx_gsm850_gsm900_swap;
 //   unsigned char bbrx_dcs1800_pcs1900_swap;
}BBTXParameters_T;
typedef enum {
	CodingSchemeCS1 = 1,
	CodingSchemeCS2,
	CodingSchemeCS3,
	CodingSchemeCS4,
	CodingSchemePRACh8,
	CodingSchemePRACh11,
	CodingSchemeMCS1,
	CodingSchemeMCS2,
	CodingSchemeMCS3,
	CodingSchemeMCS4,
	CodingSchemeMCS5,
	CodingSchemeMCS6,
	CodingSchemeMCS7,
	CodingSchemeMCS8,
	CodingSchemeMCS9
} CodingScheme;

typedef struct {
	ARFCN			arfcn;			// absolute radio frequency channel number
	BSIC			bsic;			// training sequence
	char			timeSlotmask;	// time slot mask, slot_1: 0x01, slot_2: 0x02, slot_3: 0x04, slot_4: 0x08
	Power			powerLev[4];	// power level for each time slot
	CodingScheme	cs[4];			// coding scheme for each time slot
	TimingAdvance	ta;				// time advance
	int				frames;			// the number of frames should transmit
	short			dacValue;		// AFC DAC value
} RfMultiSlotTX_Req;

typedef struct {
	FrequencyBand	rf_band;
	int				power_level;
	int				apc_dac;
} RfSetRampApcLevel_Req;

typedef struct {
	short			dacValue;		// AFC DAC value
} RfSetAfcDacValue_Req;

typedef struct {
	int				cap_id;
} RfSetCrystalCfg_Req;

typedef struct {
	ARFCN			arfcn;			// absolute radio frequency channel number
	BSIC			bsic;			// training sequence
	char			timeSlotmask;	// time slot mask, slot_1: 0x01, slot_2: 0x02, slot_3: 0x04, slot_4: 0x08
	Power			powerLev[4];	// power level for each time slot
	CodingScheme	cs[4];			// coding scheme for each time slot, MCS1~9 is only valid for EPSK function 
	TimingAdvance	ta;				// time advance
	int				frames;			// the number of frames should transmit
	short			dacValue;		// AFC DAC value
	APCTxPattern	pattern;		// Tx pattern is only valid for EPSK function  
	unsigned short	pattern_data;	// if NB_TX_PATTERN_WITHOUT_TSC==pattern, user can input any 16bits value as pattern. 
} Rf_MultiSlotTXEx_Req;

typedef struct {
	unsigned int	id;				// please refer RF_ID_XXXX 
} RFMod_ID;

typedef enum {
	MS_GSM = 0
	,MS_GPRS
	,MS_EGPRS_RX_ONLY
	,MS_EGPRS_FULL_FUNCTION
} MS_CAPABILITY_E;

typedef struct {
	unsigned int	GSM400;			// Zero: not support, Non-zero: support 
	unsigned int	GSM850;
	unsigned int	GSM900;
	unsigned int	DCS1800;
	unsigned int	PCS1900;
} RFBandSupport_S;

typedef struct {
	MS_CAPABILITY_E		capability;
	RFBandSupport_S		band_support;
} RfMsCapability_S;

typedef struct {
	unsigned int	GSM:1;
	unsigned int	GPRS:1;
	unsigned int	EDGE_RX:1;
	unsigned int	EDGE_8PSK_TX:1;
	unsigned int	Calibration_8PM:1;
} RfMsCapabilityBits;

typedef struct {
	unsigned int	GSM:1;
	unsigned int	GPRS:1;
	unsigned int	EDGE_RX:1;
	unsigned int	EDGE_8PSK_TX:1;
	unsigned int	Calibration_8PM:1;
	unsigned int    Calibration_FDT:1;      // new
	unsigned int    Calibration_33Steps:1;  // new
} RfMsCapabilityBits_2;

typedef struct {
	unsigned int	GSM400:1;
	unsigned int	GSM850:1;
	unsigned int	GSM900:1;
	unsigned int	DCS1800:1;
	unsigned int	PCS1900:1;
} RfMsBandSupportBits;

typedef struct {
	RfMsCapabilityBits		capability;
	RfMsBandSupportBits		band_support;
} RfMsCapabilityEx_S;

typedef struct {
	RfMsCapabilityBits_2		capability;
	RfMsBandSupportBits		band_support;
} RfMsCapabilityEx2_S;



typedef enum {
	AFC_SINWAVE_OFF = 0
	,AFC_SINWAVE_ON
} AFC_SINWAVE_DETECTION_E;

typedef struct {
	ARFCN			arfcn;				// Absolute radio frequency channel number
	ContTxPattern	pattern;
	unsigned short	pattern_data;
	unsigned char	OnOff;				// On or off 
	unsigned short	modtype;			// modulation type: 0->GMSK, 1->EPSK 
} RfCnTxEx_Req;

typedef struct {
	ARFCN			arfcn;				// Absolute radio frequency channel number
	ContTxPattern	pattern;
	unsigned short	pattern_data;
	unsigned char	OnOff;				// On or off 
	unsigned short	modtype;			// modulation type: 0->GMSK, 1->EPSK 
	Power			powerLev;			// power level 
} RfCnTxEx2_Req;

typedef struct {
	short			dacValue;		// AFC DAC value
} RfGetAfcDacValueAtRTXOffsetCal;

//----------  FDT related structure -----------------------

#define MAX_STEP_CNT   50
typedef struct{
   FrequencyBand	  band;
   ARFCN			  arfcn;
   short		      dac_value[33];
   Gain			      gain;
   short		      repeat_cnt;	// repetitive test counts (frames) for each AFC DAC value
   bool			      capid_cal;	// capid calibration ctrl
   bool			      linear_cal;	// 33 stages calibration ctrl
   //char			      capid_min;	// min value for capid range when capid_cal is True; capid when capid_cal is False
   //char			      capid_max;	// max value for capid range
   int			      capid_min;	// min value for capid range when capid_cal is True; capid when capid_cal is False
   int			      capid_max;	// max value for capid range

}Rf_DSSAFC_T;

typedef struct
{
   FrequencyBand 	   band;
   ARFCN			   arfcn;
   Gain				   gain[6];		// gain for rx slot 0/1/2/3/4/5
   short			   repeat_cnt;	// repetitive test counts (frames) for each ARFCN value
//   short			   dac_value;	// Use InitDacValue from AFC calibration when dacValue = 0 (or -1)
} Rf_DSSPL_T;

typedef struct
{
   bool				   afc_cal;
   bool                pl_cal;       // Control whether Path loss calibration is needed or not
   char				   sync_sb_num;	// the SB frame numbers needed for sync process before path loss calibration
   short		       power;               // the power level expected to measure from test set
   Rf_DSSAFC_T 	       AfcDSS;
   char				   step_cnt;
   Rf_DSSPL_T	       PathLossDSS[MAX_STEP_CNT-2]; // because sync process will need 2 steps

}Rf_DTS_REQ_T;

typedef struct
{
   FrequencyBand	    band;
   ARFCN			    arfcn;
   char				    timeslot_per_frame;	
   char				    apc_dac_pcl_sel;				// 1: apc_dac, 0: apc_pcl
   short			    apc_dac_pcl_value[4];
   unsigned char		pa_vbias_val;	
   CodingScheme		    cs[4];
   int			        repeat_cnt;			
   short			    afc_dac_value;
   char				    tsc;
   APCTxPattern			pattern;		
   unsigned short		pattern_data;
} Rf_USSAPC_T;

typedef struct
{
//   bool                pa_vbias_cal;
   char				   step_cnt;
   Rf_USSAPC_T	       ApcUSS[MAX_STEP_CNT];
}Rf_UTS_REQ_T;

typedef struct
{
   int	    power[MAX_STEP_CNT-2];  // because sync process will need 2 steps
   short    valid_sample[MAX_STEP_CNT-2];
   bool		ok;
} Rf_DSSPL_RESULT_T;

typedef struct
{
   int	    freq_offset[33];	// only valid when 33 stage calibration is ON
   int	    deviation[33];		// only valid when 33 stage calibration is ON
   short	fcb_ok_number[33];  // only valid when 33 stage calibration is ON
   //char		capid;			    // only valid when capid calibration is ON
   int		capid;			    // only valid when capid calibration is ON
   short	init_dac_value; 	// only valid when 33 stage calibration is OFF
   int	    slope;              // only valid when 33 stage calibration is OFF
   bool		ok;
} Rf_DSSAFC_RESULT_T;

typedef struct
{
   Rf_DSSPL_RESULT_T	  PLResult;
   Rf_DSSAFC_RESULT_T	  AfcResult;
	
} Rf_DTS_CNF_T;

//-----------------------------------------------------//
//  TX Ramping Table                                   //
//-----------------------------------------------------//
#define PROFILE_NUM             16
#define ARFCN_SECTION_NUM       12
#define ARFCN_SECTION_NUM_Ex       64
typedef  struct
{
   unsigned char   point[2][16];	// ramp up/down profile

} sRAMPAREADATA;

typedef  struct
{
   short			max_arfcn;		// sub-band boundary of this PCL weighting area
   unsigned short   mid_level;		// PCLboundary level to apply high/low weighting
   unsigned short   hi_weight;		// scale factor of PCLs higher than mid_level
   unsigned short   low_weight;		// scale factor of PCLs lower than mid_level

} sARFCN_SECTION;

typedef  struct
{
   int				lowest_power;						// The lower apc power of the indicated band
   unsigned short	power[16];							// The mapping of power level to apc dac value
   sRAMPAREADATA	ramp[ PROFILE_NUM ];				// ramp profile
   sARFCN_SECTION	arfcn_weight[ ARFCN_SECTION_NUM ];	// profile of weighting power level by PCL and sub-band
   unsigned short	battery_compensate[3][3];			// [volt][temp] 
   short			tx_afc_offset;
} sRAMPDATA;

typedef struct
{
   int				lowest_power;						// The lower apc power of the indicated band
   unsigned short	power[16];							// The mapping of power level to apc dac value
   sRAMPAREADATA	ramp[ PROFILE_NUM ];				// ramp profile
   sARFCN_SECTION	arfcn_weight[ ARFCN_SECTION_NUM_Ex ];	// profile of weighting power level by PCL and sub-band
   unsigned short	battery_compensate[3][3];			// [volt][temp] 
   short			tx_afc_offset;
} sRAMPDATA_Ex;

typedef  struct
{
   int				lowest_power;						// The lower apc power of the indicated band
   unsigned short	power[16];							// The mapping of power level to apc dac value
   sRAMPAREADATA	ramp[ PROFILE_NUM ];				// ramp profile
   sARFCN_SECTION	arfcn_weight[ ARFCN_SECTION_NUM ];	// profile of weighting power level by PCL and sub-band
   unsigned short	battery_compensate[3][3];			// [volt][temp] 
   short			tx_afc_offset;
   unsigned char	vbias[16];
} sRAMPDATA_Ex2;

typedef struct
{
   sRAMPDATA          rampData;							// apc ramp profile of all bands
}l1cal_rampTable_T;

typedef struct
{
   sRAMPDATA_Ex          rampData;							// apc ramp profile of all bands
}l1cal_rampTable_T_Ex;

typedef struct
{
   sRAMPDATA_Ex2          rampData;							// apc ramp profile of all bands
}l1cal_rampTable_T_Ex2;

//-----------------------------------------------------//
//  TX Inter Ramping Table                             //
//-----------------------------------------------------//

// interRampData 
typedef struct {   
	unsigned char	interRampData[16];
} l1cal_interRampData_T;

// EPSK interRampData 
typedef struct {
	unsigned char	EPSK_interRampData[4][16];
} l1cal_EPSK_interRampData_T;

//-----------------------------------------------------//
//  3F RF compose/decompose table                      //
//-----------------------------------------------------//
#define  CAL_UARFCN_SECTION  15
#define  U_ARFCN_SECTION_NUM   15
#define  CAL_TEMP_SECTION     8
#define CAL_PWR_DETECTOR_SECTION 32  
typedef  struct
{
   unsigned short  max_uarfcn;
    char   path_loss_H;//loss;
    char   path_loss_M;//gain_diff_HM;
    char   path_loss_L;//gain_diff_HL;
}  U_sAGCGAINOFFSET;

typedef  struct
{
   //char   temp;   
   U_sAGCGAINOFFSET  gain_of_uarfcn[CAL_UARFCN_SECTION];   
}  U_sTEMPAGCOFFSET;

typedef  struct
{
   unsigned short dc2dc_dac;
   unsigned short vbias_dac;
   unsigned char vm1;
   unsigned char vm2;
}  U_sPADATA;

typedef  struct
{
   unsigned short  max_uarfcn;
   short           pwr_offset;
   short           pwr_slope;
} U_sARFCN_SECTION;

typedef struct
{
   unsigned short max_uarfcn;
   short          pwr_offset_dB; /* unit: 1/32 dB, range: -8 ~ +7 dB */ 
   short          pwr_offset_txdac;
}U_sARFCN_SECTION_B;  // for MT6268B later


typedef  struct
{
   //unsigned short  pa_dac;
   U_sPADATA          pa_data;
   unsigned short     vga_dac[90];//vga_dac[81];
   U_sARFCN_SECTION   vga_comp_by_subband[CAL_UARFCN_SECTION];
   short              vga_comp_by_temperature[8][2];  //[0]:slope, [1]:offset
   //short           vga_offset_by_temperature[8]; 
} U_sTXPOWERDATA;

typedef  struct
{
   U_sPADATA           pa_data; 
   unsigned short      vga_dac[90];
   U_sARFCN_SECTION_B  vga_comp_by_subband[ CAL_UARFCN_SECTION ];
   short               vga_comp_by_temperature[8][2];  //[0]:offset in dB (unit: 1/32 dB), [1]:offset in txdac
} U_sTXPOWERDATA_B;  // for MT6268B later

typedef  struct
{
   unsigned short start;
   unsigned short end;
} U_sHYSTERESISDATA;

typedef  struct
{
   unsigned char     pwr_dt_thr;
   unsigned char     pwr_dt_section;   // can not be larger than CAL_PWR_DETECTOR_SECTION
   unsigned short    pwr_dt_dac[CAL_PWR_DETECTOR_SECTION];
   
   short             pwr_dt_value[CAL_PWR_DETECTOR_SECTION]; //bit0~4 is used for fractions
   U_sARFCN_SECTION  pwr_dt_comp_by_subband[CAL_UARFCN_SECTION];   // for compensation, no need calibration, after test, will auto-store
   short             pwr_dt_comp_by_temperature[8][2];  //[0]:slope, [1]:offset
 
}  U_sPWTDTDATA;

typedef  struct
{
   unsigned char       pwr_dt_thr;
   unsigned char       pwr_dt_section;
   unsigned short      pwr_dt_dac[ CAL_PWR_DETECTOR_SECTION ];
   short               pwr_dt_value[ CAL_PWR_DETECTOR_SECTION ]; //bit0~4 is used for fractions
   U_sARFCN_SECTION_B  pwr_dt_comp_by_subband[ CAL_UARFCN_SECTION ];
   short               pwr_dt_comp_by_temperature[8][2];  //[0]:offset in dB (unit: 1/32 dB), [1]:offset in txdac
}  U_sPWTDTDATA_B;   // for MT6268B later



typedef  struct
{
   U_sTXPOWERDATA    power_dac[3];   //0:PA high mode, 1:PA mid mode, 2:PA low mode (use 0&1 if only 2 mode)
   U_sHYSTERESISDATA tx_hysteresis[2];
   U_sPWTDTDATA      pwr_dt_data;
 //  U_sRAMPAREADATA   u_ramp;
 //  U_sARFCN_SECTION  u_arfcn_weight[ U_ARFCN_SECTION_NUM ];
} U_sRAMPDATA;

typedef  struct
{
   U_sTXPOWERDATA_B      power_dac[3];   //0:PA high mode, 1:PA mid mode, 2:PA low mode (use 0&1 if only 2 mode)
   U_sHYSTERESISDATA     tx_hysteresis[2];
   U_sPWTDTDATA_B        pwr_dt_data;

} U_sRAMPDATA_B;   // for MT6268B later


//chliu provide
typedef struct
{
   unsigned char tempdacData[8];
}ul1cal_tempdacData_T; 

typedef struct
{
   U_sTEMPAGCOFFSET  pathlossData[CAL_TEMP_SECTION]; 
}ul1cal_pathlossData_T;

typedef struct
{
   U_sRAMPDATA txdacData; 
}ul1cal_txdacData_T;

typedef struct
{
   U_sRAMPDATA_B txdacData; 
}ul1cal_txdacData_T_B;   // for MT6268B later

/* end of chliu */

//-----------------------------------------------------//
//  RF Module Special Coef                             //
//-----------------------------------------------------//

//mt6140D
typedef struct{
   short		pcl_index;
   unsigned char pa_vbias1;   
}pa_vbias;

typedef struct {
   pa_vbias GSM850_pa_vbias[8];
   pa_vbias GSM900_pa_vbias[8];   
   pa_vbias DCS1800_pa_vbias[8];
   pa_vbias PCS1900_pa_vbias[8];
   //pa_vbias low_band_pa_vbias[8];
   //pa_vbias high_band_pa_vbias[8];
}mt6140tx_pa_vbias;

typedef struct{  
      mt6140tx_pa_vbias data;
}mt6140tx;  
// Skyworks 
typedef struct {
	unsigned int		icorrection;
	unsigned int		qcorrection;
} RF_SKY74045_IP2_Coef;

typedef struct {
	RF_SKY74045_IP2_Coef	coef[5/*band*/];
} RF_SKY74045_RX_Coef;

typedef struct {
	RF_SKY74045_RX_Coef		rx;
} RF_SKY74045_Coef_T;

typedef struct {
	unsigned int			ipol;
	unsigned int			qpol;
} RF_SKY74117_IP2_Pol;

typedef struct {
	RF_SKY74045_IP2_Coef	coef[5/*band*/];
	RF_SKY74117_IP2_Pol		pol[5/*band*/];
} RF_SKY74117_RX_Coef;

typedef struct {
	RF_SKY74117_RX_Coef		rx;
} RF_SKY74117_Coef_T;

// MT6139B 
typedef struct {
	unsigned int		acode;
	unsigned int		amcode;
} RF_MT6139B_IP2_Coef;

typedef struct {  
	RF_MT6139B_IP2_Coef		coef[5/*band*/];
	unsigned int			rxamcalmode;
} RF_MT6139B_RX_Coef;

typedef struct {
	RF_MT6139B_RX_Coef		rx;
} RF_MT6139B_Coef_T;

// Bright5P 
typedef struct {
	unsigned int		word6_4_0;
	unsigned int		word6_5_0;
	unsigned int		word6_6_0;
	unsigned int		word6_7_0;
	unsigned int		bvmode;
	unsigned int		c3mode;
	unsigned int		wordC3;
} RF_BRIGHT5P_TX_Coef;

typedef struct {
	RF_BRIGHT5P_TX_Coef		tx;
} RF_BRIGHT5P_Coef_T;

typedef struct
{
   unsigned char REFDET_SLOPE_SKEW ;
   unsigned char AM_FB_DAC; 
}ad6546txcoef;



typedef  struct
{ 
      ad6546txcoef   CalData[4];

} ad6546tx;   

//-----------------------------------------------------//
//  RF Testing: callback function definition           //
//-----------------------------------------------------//
typedef void (__stdcall *META_RF_PM_CNF)(const RfPm_Cnf *cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_AFC_CNF)(const RfAfc_Cnf *cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_NB_TX_CNF)(const unsigned char cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_CONT_RX_CNF)(const unsigned char cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_CONT_TX_CNF)(const unsigned char cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_SETBBTX_CFG_CNF)(const unsigned char cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_SELBAND_CNF)(const unsigned char cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_STOP_CNF)(const unsigned char cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_MULTISLOT_TX_CNF)(const unsigned char cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_SET_RAMPAPCLEVEL_CNF)(const unsigned char cnf, const short token, void *usrData);
typedef void (__stdcall *META_RF_SET_AFCDACVALUE_CNF)(const unsigned char cnf, const short token, void *usrData);



int __stdcall SP_META_ComPortEnumerate(unsigned short *p_com_port_array, unsigned short *p_com_port_count);
//--------------------------------------------------------------------------//
//  NVRAM                                                                   //
//--------------------------------------------------------------------------//

//-----------------------------------------------------//
//  NVRAM: data structure definition                   //
//-----------------------------------------------------//

// Reset NVRAM
typedef enum 
{
	NVRAM_RESET_ALL,		// Reset all data items in both of user and system category
	NVRAM_RESET_USER,		// Reset data items in user category
	NVRAM_RESET_SYSTEM,		// Reset data items in system category
	NVRAM_RESET_CERTAIN,	// Reset certain data item according to LID
	NVRAM_RESET_FACTORY		// Reset to factory default value, all the LIDs has FACTORY attribute will be reseted 
} ResetCategory;   

typedef struct
{
	ResetCategory	category;	// Reset category

	const char		*LID;		// The name of logical data item ID , it will be used
								// if and only if ResetCategory = NVRAM_RESET_CERTAIN,
								// in other case you can just assign NULL.
} FT_NVRAM_RESET_REQ;

typedef struct
{
	unsigned char   reset_status;
	unsigned char	status;		// The status of Reset
} FT_NVRAM_RESET_CNF;

// Read from NVRAM
typedef struct
{
	const char			*LID;		// The name of logical data item ID
	unsigned short 		RID;		// Record ID (the first record is 1)
} FT_NVRAM_READ_REQ;

typedef struct
{
	unsigned short		LID;		// Logical data item ID of a EF
	unsigned short		RID;		// Record ID (the first record is 1)
	unsigned char		status;		// 0: read ok; others: read failed.

	unsigned int		len;		// [IN] Length of Buffer, [OUT] Length of read data
									// The "len" field indicates the size of "buf" you 
									// allocated. When the data is read back, "len" will
									// be replaced with the actual size of the data.

	unsigned char 		*buf;		// Buffer that will contains the content of record
	unsigned char		read_status;
} FT_NVRAM_READ_CNF;

//Write to NVRAM
typedef struct
{
	const char			*LID;		// The name of logical data item ID
	unsigned short		RID;		// Record ID (the first record is 1)
	unsigned int		len;		// Length of write data
	unsigned char		*buf;		// Buffer that contains the content of record
} FT_NVRAM_WRITE_REQ;

typedef struct
{
	unsigned short		LID;		// Logical data item ID of a EF
	unsigned short		RID;		// Record ID (the first record is 1)
	unsigned char		write_status;
	unsigned char		status;		// 0: write ok; others: write failed.
} FT_NVRAM_WRITE_CNF;

// AGC path loss 
#define  PLTABLE_SIZE  13			// element count of path loss table

typedef  struct
{
   short        max_arfcn;			// The maximum ARFCN of the indicated sub-band
   char			gain_offset;		// The maximum available gain of transceiver of the indicated sub-band
} sAGCGAINOFFSET;

typedef struct
{
   sAGCGAINOFFSET     agcPathLoss[FrequencyBandCount][PLTABLE_SIZE];
}l1cal_agcPathLoss_T;

// Speech Coefficient
typedef struct {
	short		Speech_8k_Input_Coeff[30];		// FIR for input speech (microphone) with 8k sampling rate  
	short		Speech_8k_Output_Coeff[30];		// FIR for output speech (speaker) with 8k sampling rate    
	short		Speech_16k_Input_Coeff[62];		// FIR for input speech (microphone) with 16k sampling rate 
	short		Speech_16k_Output_Coeff[62];	// FIR for output speech (speaker) with 16k sampling rate   

	short		Additional_Speech_8k_Output_Coeff[5][30];	// The additional FIR for output speech (speaker) with 8k sampling rate 

	unsigned short	Speech_8k_Output_Coeff_Index;	// The active FIR index                      
													// 0 -> Speech_8k_Output_Coeff               
													// 1 -> Additional_Speech_8k_Output_Coeff[0] 
													// 2 -> Additional_Speech_8k_Output_Coeff[1] 
													// 3 -> Additional_Speech_8k_Output_Coeff[2] 
													// 4 -> Additional_Speech_8k_Output_Coeff[3] 
													// 5 -> Additional_Speech_8k_Output_Coeff[4] 
}L1_SpeechCoeff_T;

// Melody Coefficient
typedef struct {
	short		Melody_32k_Output_Coeff[45];	// FIR for melody playback with with 32k sampling rate 
}L1_MelodyCoeff_T;

// L1Audio Param
typedef struct{
	L1_SpeechCoeff_T	Speech_FIR[2];	// [0]: normal mode 
										// [1]: headset mode 
										// NOTE: In headset mode, Additional_Speech_8k_Output_Coeff and 
										//       Speech_8k_Output_Coeff_Index are ignored! you can just 
										//       leave them alone.                                      

	L1_MelodyCoeff_T	Melody_FIR[2];	// [0]: loud speaker mode 
										// [1]: stereo speaker mode 
	unsigned short		ES_TimeConst;
	unsigned short		ES_VolConst;
	unsigned short		ES_TimeConst2;
	unsigned short		ES_VolConst2;
	unsigned short		Media_Playback_Maximum_Swing;
}l1audio_param_T;

// L1Audio Param from W0547 

#define SPEECH_NORMAL_MODE			0
#define SPEECH_EARPHONE_MODE		1
#define SPEECH_LOUDSPEAKER_MODE		2
#define SPEECH_BT_ERAPHONE_MODE		3
#define SPEECH_BT_CORDLESS_MODE		4
#define SPEECH_AUX1_MODE			5
#define SPEECH_AUX2_MODE			6
#define SPEECH_AUX3_MODE			7

typedef struct{
	L1_SpeechCoeff_T	Speech_FIR[2];	// [0]: normal mode 
										// [1]: headset mode 
										// NOTE: In headset mode, Additional_Speech_8k_Output_Coeff and 
										//       Speech_8k_Output_Coeff_Index are ignored! you can just 
										//       leave them alone.                                      

	L1_MelodyCoeff_T	Melody_FIR[2];	// [0]: loud speaker mode 
										// [1]: stereo speaker mode 

	unsigned short		Speech_Common_Para[12];

	unsigned short		Speech_ModeDependent_Para[8][8];	// [0]: Normal Mode             
															// [1]: Earphone Mode           
															// [2]: Loud Speaker Mode       
															// [3]: BlueTooth Earphone Mode 
															// [4]: BlueTooth Cordless Mode 
															// [5]: AUX1 Mode               
															// [6]: AUX2 Mode               
															// [7]: AUX3 Mode               
	unsigned short		Media_Playback_Maximum_Swing;
} l1audio_param_W0547_T;


typedef struct{
	short speech_input_FIR_coeffs[6][45];
    short speech_output_FIR_coeffs[6][45];
    unsigned short selected_FIR_output_index;
    unsigned short speech_common_para[12];
    unsigned short speech_normal_mode_para[8];
    unsigned short speech_earphone_mode_para[8];
    unsigned short speech_loudspk_mode_para[8];
    unsigned short speech_bt_earphone_mode_para[8];
    unsigned short speech_bt_cordless_mode_para[8];
    unsigned short speech_aux1_mode_para[8];
    unsigned short speech_aux2_mode_para[8];
    unsigned short speech_aux3_mode_para[8];
    unsigned short Media_Playback_Maximum_Swing;
    short Melody_FIR_Output_Coeff_32k_Tbl1[45];
} l1audio_param_W0547_45_T;

typedef struct{
	short speech_input_FIR_coeffs[6][45];
    short speech_output_FIR_coeffs[6][45];
    unsigned short selected_FIR_output_index;
    unsigned short speech_common_para[12];
    unsigned short speech_normal_mode_para[8];
    unsigned short speech_earphone_mode_para[8];
    unsigned short speech_loudspk_mode_para[8];
    unsigned short speech_bt_earphone_mode_para[8];
    unsigned short speech_bt_cordless_mode_para[8];
    unsigned short speech_aux1_mode_para[8];
    unsigned short speech_aux2_mode_para[8];
    unsigned short speech_aux3_mode_para[8];
    unsigned short Media_Playback_Maximum_Swing;
    short Melody_FIR_Output_Coeff_32k_Tbl1[25];
} l1audio_param_W0712_T;


typedef struct
{
    short          speech_input_FIR_coeffs[6][45];
    short          speech_output_FIR_coeffs[6][45];
    unsigned short selected_FIR_output_index;
    unsigned short speech_common_para[12];
    unsigned short speech_mode_para[8][8];
    unsigned short Media_Playback_Maximum_Swing;
    short          Melody_FIR_Coeff_Tbl[25];
    short          audio_compensation_coeff[2][45];  // new added, so different with others structure

} l1audio_param_W0740_T;



typedef struct
{
	/* volume setting */
	char		   volume[3][7];
	/* speech enhancement */
	unsigned short speech_common_para[12];
	unsigned short speech_mode_para[8][16];
	unsigned short speech_volume_para[4];
	
	unsigned short debug_info[16];
	/* speech input FIR */
	short		   speech_input_FIR_coeffs[6][45];
	/* speech output FIR */
	short		   speech_output_FIR_coeffs[6][45];

	/* digital gain of DL speech */
	unsigned short Digi_DL_Speech;
	/* digital gain of uplink speech */
	unsigned short Digi_Microphone;
	/* FM record volume*/
	unsigned short FM_Record_Volume;	
	/* user mode : normal mode, earphone mode, loud speaker mode */
	unsigned short Bluetooth_Sync_Type;
	unsigned short Bluetooth_Sync_Length;
	unsigned short bt_pcm_in_vol;
	unsigned short bt_pcm_out_vol;
	unsigned short user_mode;
	/* auto VM record setting */
	unsigned short bSupportVM;
	unsigned short bAutoVM;
	unsigned short uMicbiasVolt;

} l1audio_param_W0809_T;


// 6516 add
typedef struct
{
                /* volume setting */
                char                          volume[3][7];
                /* speech input FIR */
                short                        speech_input_FIR_coeffs[6][45];
                /* speech output FIR */
                short                        speech_output_FIR_coeffs[6][45];
                /* speech enhancement */
                unsigned short speech_common_para[12];
                unsigned short speech_mode_para[8][16];
                /* digital gain of DL speech */
                unsigned short Digi_DL_Speech;
                /* digital gain of uplink speech */
                unsigned short Digi_Microphone;
                /* FM record volume*/
                unsigned short FM_Record_Volume;     
                /* user mode : normal mode, earphone mode, loud speaker mode */
                unsigned short Bluetooth_Sync_Type;
                unsigned short Bluetooth_Sync_Length;
                unsigned short bt_pcm_in_vol;
                unsigned short bt_pcm_out_vol;
                unsigned short user_mode;
                /* auto VM record setting */
                unsigned short bSupportVM;
                unsigned short bAutoVM;

                //////////////////////////////////////////////////////////////////////////
                // dummy members, which would be removed some day
                unsigned short selected_FIR_output_index;
                unsigned short speech_volume_para[3][7][4];
                unsigned short Media_Playback_Maximum_Swing;
                short          Melody_FIR_Coeff_Tbl[25];
                short          audio_compensation_coeff[2][45];  // new added, so different with others structure
                //////////////////////////////////////////////////////////////////////////

} l1audio_param_W0809_6516_T;


typedef struct 
{    
    unsigned int bes_loudness_hsf_coeff[9][4];
    unsigned int bes_loudness_bpf_coeff[4][6][3];
    // BesLoudness V3
    unsigned int besloudness_DRC_Forget_Table[9][2];
    unsigned int besloudness_WS_Gain_Max;
    unsigned int besloudness_WS_Gain_Min;
    unsigned int besloudness_Filter_First;
    char         besloudness_Gain_Map_In[5];
    char         besloudness_Gain_Map_Out[5];
    
}l4aud_acf_param;

// 6516 add
typedef struct 
{    
    unsigned int bes_loudness_hsf_coeff[9][4];
    unsigned int bes_loudness_bpf_coeff[4][6][3];
}l4aud_get_acf_param_cnf;

typedef struct 
{ 	
	//Volume: 
	short VOL_CALIBRATION_SUBBAND_SHIFT[8];
	short VOL_CALIBRATION_SUBBAND[8];
	//Delay: 
	short DELAY_CAL_INT;
	short DELAY_CAL_FRAC;
	short DELAY_CAL_SUBBAND[8];
	//Leakage: 
	short POWER_RATIO_SCALE;
	short WIND_INDEX_THRESHOLD;
	short SUBBAND_BMG[8];
	short MOCKUP_LEVEL;
	short SHIELDING_LEVEL;
	//NR_Level
	short NR_Level;
	//Reserve
	short Parameter_Reserve[5];
}l1audio_extra_param_W1105_T;

typedef struct 
{ 	
	//Volume: 
	short VOL_CALIBRATION_SUBBAND_SHIFT[16];
	short VOL_CALIBRATION_SUBBAND[16];
	//Delay: 
	short DELAY_CAL_INT;
	short DELAY_CAL_FRAC;
	short DELAY_CAL_SUBBAND[16];
	//Leakage: 
	short POWER_RATIO_SCALE;
	short WIND_INDEX_THRESHOLD;
	short SUBBAND_BMG[16];
	short MOCKUP_LEVEL;
	short SHIELDING_LEVEL;
	//NR_Level
	short NR_Level;
	//Reserve
	short Parameter_Reserve[5];
}l1audio_extra_param_W1134_T;


// Audio gain table
typedef	struct { 
	char  bEnable;    // return if support gain table 
}l4aud_gaintable_cnf;

typedef	struct { 
	int  gaintablenum;  // return number ogf gain type 
}l4aud_gaintablenum_cnf;


typedef	struct { 
	int gaintabletype;    // query of which gain type 
}l4aud_gaintablelevel_req;


typedef	struct { 
	int gaintabletype;     // return of gain type4
	int gainttablelevel;    // return level of query gain type 
}l4aud_gaintablelevel_cnf;


typedef	struct { 
	int  i4ctrpointnum;        // this get control point number 
}l4aud_ctrpointnum_cnf;


typedef	struct { 
	int  i4ctrpoint;       
	//  this range should depend on amp control pointer number 
}l4aud_ctrpointbits_req;


typedef	struct { 
	int  i4ctrpoint;   //  this range should depend on amp control pointer number 
	
	int  i4ctrpointbits;   // return bits of this control bpoint 
}l4aud_ctrpointbits_cnf;


typedef	struct { 
	int  i4ctrpoint;        //  query control point of table 
}l4aud_ctrpointtable_req;


typedef	struct { 
	int  i4ctrpoint;        //  query control point of table
	char buffer[255];          //   buffer to fill contorl point table 
	int i4bufferlength;  //   length of buffer  filled. 
}l4aud_ctrpointtable_cnf;

// HD Recording
typedef struct
{
	unsigned char bHdRecSupport;
	unsigned char bDualMicSupport;
} l4aud_hdrec_info_cnf;



//#define AUDIO_GAIN_TABLE_LEVEL_PER_PAGE_REAL  20

#define GAIN_TABLE_SUPPORT
#ifdef GAIN_TABLE_SUPPORT
#define GAIN_TABLE_LEVEL (20)
#else
#define GAIN_TABLE_LEVEL (20)
#endif

#define VOICE_GAIN_TABLE_LEVEL (6+1)
#define SYSTEM_GAIN_TABLE_LEVEL (7+1)
#define RING_GAIN_TABLE_LEVEL (7+1)
#define MUSIC_GAIN_TABLE_LEVEL (13+1)
#define ALARM_GAIN_TABLE_LEVEL (7+1)
#define NOTIFICATION_GAIN_TABLE_LEVEL (7+1)
#define BLUETOOTHSCO_GAIN_TABLE_LEVEL (15+1)
#define ENFORCEAUDIBLE_GAIN_TABLE_LEVEL (7+1)
#define DTMF_GAIN_TABLE_LEVEL (15+1)
#define TTS_GAIN_TABLE_LEVEL (15+1)
#define FM_GAIN_TABLE_LEVEL (13+1)
#define MATV_GAIN_TABLE_LEVEL (13+1)

enum AUDIO_GAIN_TYPE {
	AUDIO_GAIN_DEFAULT 		    =-1,
	AUDIO_GAIN_VOICE_CALL		= 0,
	AUDIO_GAIN_SYSTEM			= 1,
	AUDIO_GAIN_RING			    = 2,
	AUDIO_GAIN_MUSIC			= 3,
	AUDIO_GAIN_ALARM			= 4,
	AUDIO_GAIN_NOTIFICATION	    = 5,
	AUDIO_GAIN_BLUETOOTH_SCO	= 6,
	AUDIO_GAIN_ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be routed to speaker
	AUDIO_GAIN_DTMF			    = 8,
	AUDIO_GAIN_TTS 			    = 9,
	AUDIO_GAIN_FM				= 10,
	AUDIO_GAIN_MAX_STREAM       = 10, 
	AUDIO_GAIN_MIC              = 11,
	AUDIO_GAIN_SIDETONE         = 12,
	AUDIO_GAIN_SPEECH           = 13,
	AUDIO_GAIN_SPEECH_WB        = 14,
    NUM_AUDIO_GAIN_TYPES              //max index of stream
};

enum MICROPHONE_DEVICEGAIN{
    GAIN_IDLE_RECORD_MIC =0,
	GAIN_IDLE_RECORD_HEADSET ,
	GAIN_INCALL_RECEIVER,
	GAIN_INCALL_HEADSET, 
	GAIN_INCALL_SPEAKER,
	GAIN_VOIP_RECEIVER, 
	GAIN_VOIP_HEADSET,
	GAIN_VOIP_SPEAKER,
	GAIN_FM_RECORDING, 
	GAIN_VOICE_RECOGNITION_RECEIVER,
	GAIN_VOICE_RECOGNITION_HEADSET,
	GAIN_INCALL_WB_RECEIVER,
	GAIN_INCALL_WB_HEADSET, 
	GAIN_INCALL_WB_SPEAKER,
	GAIN_MIC_RESOLVED,
	NUM_OF_MICGAINS //15
};

//---------------------------------------------------------------------------
enum SIDETONE_DEVICEGAIN{
	GAIN_SIDETONE_RECEIVER =0,
    GAIN_SIDETONE_HEADSET,
    GAIN_SIDETONE_SPEAKER,
    NUM_OF_SIDETONEGAINS
};

//---------------------------------------------------------------------------
enum GAIN_SPEECH{
    SPEECH_NORMAL  = 0,
    SPEECH_HEADSET = 1,
    SPEECH_SPEAKER = 2,    
    NUM_OF_SPEECHGAIN,
};

//---------------------------------------------------------------------------

enum GAIN_OUTPUT_DEVICE
{
	GAIN_OUTPUT_RECEIVER = 0,
	GAIN_OUTPUT_HEADSET  = 1,
	GAIN_OUTPUT_SPEAKER  = 2,
	NUM_GAIN_OUTPUT_DEVICES
};

//---------------------------------------------------------------------------
typedef struct _AUDIO_GAIN_CONTROL_STRUCT
{
    unsigned char u8Gain_digital;
    unsigned int u32Gain_PGA_Amp;
} AUDIO_GAIN_CONTROL_STRUCT;

//---------------------------------------------------------------------------
typedef struct _STREAM_GAIN_CONTROL_STRUCT
{
    AUDIO_GAIN_CONTROL_STRUCT streamGain[NUM_GAIN_OUTPUT_DEVICES][GAIN_TABLE_LEVEL];
} STREAM_GAIN_CONTROL_STRUCT;

//---------------------------------------------------------------------------
typedef struct _STREAM_MICROPHONE_GAIN_CONTROL_STRUCT
{
    unsigned char micGain[GAIN_TABLE_LEVEL];
} STREAM_MICROPHONE_GAIN_CONTROL_STRUCT;

//---------------------------------------------------------------------------
typedef struct _STREAM_SIDETONE_GAIN_CONTROL_STRUCT
{
    unsigned char sidetoneGain[GAIN_TABLE_LEVEL];
} STREAM_SIDETONE_GAIN_CONTROL_STRUCT;

//---------------------------------------------------------------------------
typedef struct _STREAM_SPEECH_GAIN_CONTROL_STRUCT
{
    AUDIO_GAIN_CONTROL_STRUCT speechGain[NUM_OF_SPEECHGAIN][GAIN_TABLE_LEVEL];
} STREAM_SPEECH_GAIN_CONTROL_STRUCT;



//---------------------------------------------------------------------------
typedef struct _AUDIO_GAIN_TABLE_STRUCT
{
    STREAM_GAIN_CONTROL_STRUCT voiceCall;	
    STREAM_GAIN_CONTROL_STRUCT system;	
    STREAM_GAIN_CONTROL_STRUCT ring;
	
    STREAM_GAIN_CONTROL_STRUCT music;	
    STREAM_GAIN_CONTROL_STRUCT alarm;
    STREAM_GAIN_CONTROL_STRUCT notification;
    STREAM_GAIN_CONTROL_STRUCT blueToothSco;
    STREAM_GAIN_CONTROL_STRUCT enforceAudible;
    STREAM_GAIN_CONTROL_STRUCT dtmf;
    STREAM_GAIN_CONTROL_STRUCT tts;
    STREAM_GAIN_CONTROL_STRUCT fm;
    // STREAM_GAIN_CONTROL_STRUCT Matv_Gain_table;
	
    STREAM_MICROPHONE_GAIN_CONTROL_STRUCT microphoneGain;
    STREAM_SIDETONE_GAIN_CONTROL_STRUCT sidetoneGain;
    STREAM_SPEECH_GAIN_CONTROL_STRUCT speechGain;
    STREAM_SPEECH_GAIN_CONTROL_STRUCT speechGainWB;
	
} AUDIO_GAIN_TABLE_STRUCT;




/*
#define MAX_SIZE_SCENE_NAME 128 // max length of scene name
#define NUM_RECORD_MODE 	3   // handset+headset+bt
*/
#define MAX_NUM_SCENE 	    6   // for each voice/video rec, max #scene = 6. Total <= 10 (10 * 3 = 30 = max)


#define MAX_HD_REC_SCENES                              10
#define NUM_HD_REC_DEVICE_SOURCE   3

/*
typedef struct 
{
    char          name[MAX_SIZE_SCENE_NAME];    // scene name, ex : "Indoor", "Outdoor"
    unsigned char modes[NUM_RECORD_MODE];       // modes[0] for handset, modes[1] for headset, modes[2] for bt
} HD_REC_SCENE_INFO;
*/

/*
typedef struct  
{
    HD_REC_SCENE_INFO voice_rec_scenes[MAX_NUM_SCENE]; // ex: indoor scene, indoor scene, ...
    unsigned char 	  num_voice_rec_scene;

    HD_REC_SCENE_INFO video_rec_scenes[MAX_NUM_SCENE]; // ex: concert scene, ...
    unsigned char     num_video_rec_scene;
} HD_REC_SCENE_TABLE_STRUCT;
*/

typedef struct  
{
    unsigned char num_voice_rec_scenes;
    unsigned char num_video_rec_scenes;
    unsigned char scene_table[MAX_HD_REC_SCENES][NUM_HD_REC_DEVICE_SOURCE];
} AUDIO_HD_RECORD_SCENE_TABLE_STRUCT;


#define SPC_MAX_NUM_RECORD_SPH_MODE     (30)
#define SPC_MAX_NUM_RECORD_INPUT_FIR    (8)

#define SPEECH_PARA_NUM                 (16)
#define WB_FIR_NUM                      (90)

typedef struct _AUDIO_HD_RECORD_PARAM_STRUCT
{
    /* HD RECORD Mode Num & FIR Num*/
    unsigned short hd_rec_mode_num; // max(hd_rec_fir_num) == 30 
    unsigned short hd_rec_fir_num;  // max(hd_rec_fir_num) == 4 
    
    /* HD RECORD Speech Enhancement */
    unsigned short hd_rec_speech_mode_para[SPC_MAX_NUM_RECORD_SPH_MODE][SPEECH_PARA_NUM]; // the contain only have hd_rec_mode_num effective values
    
    /* HD RECORD FIR */
    short          hd_rec_fir[SPC_MAX_NUM_RECORD_INPUT_FIR][WB_FIR_NUM]; // the contain only have hd_rec_fir_num effective values
    
    /* HD RECORD FIR Mapping (ex, map[sph_mode] = FIR3) */
    unsigned short hd_rec_map_to_fir_for_ch1[SPC_MAX_NUM_RECORD_SPH_MODE];
    unsigned short hd_rec_map_to_fir_for_ch2[SPC_MAX_NUM_RECORD_SPH_MODE];

    /* HD RECORD Device Mode Mapping (ex, map[sph_mode] = SPH_MODE_NORMAL ) */
    unsigned char hd_rec_map_to_dev_mode[SPC_MAX_NUM_RECORD_SPH_MODE];

    /* HD RECORD Input Source Mapping (ex, map[sph_mode] = BT Earphone mic)*/
    unsigned char hd_rec_map_to_input_src[SPC_MAX_NUM_RECORD_SPH_MODE];

    /* HD RECORD mode is stereo or not (ex, map[sph_mode] = 0(mono), 1(stereo) )*/
    unsigned char hd_rec_map_to_stereo_flag[SPC_MAX_NUM_RECORD_SPH_MODE];

} AUDIO_HD_RECORD_PARAM_STRUCT;


// crystalAfcData
#define XO_SlopeArea_Num       33  // change from 8 to 33, 8 is obsolete

typedef struct {
	int		min_freq;
	short	min_dac;
	int		inv_slope;
}XO_SLOPE_AREA_DATA;

typedef struct {  
	XO_SLOPE_AREA_DATA		XO_SlopeAreaData[XO_SlopeArea_Num]; 
}l1cal_crystalAfcData_T;

// IMEISV
typedef struct {
	char			imei[16];
	unsigned char	svn;
	unsigned char	pad;
}IMEISV_struct_T;

// Custom Acoustic Volume
#define MAX_VOL_CATE		3
#define MAX_VOL_TYPE		7
#define MAX_VOL_LEVEL		7
typedef struct {
	unsigned char	volume_gain[MAX_VOL_CATE][MAX_VOL_TYPE][MAX_VOL_LEVEL];
	// Volume Gain:	[Mode (Normal, Headset, LoudSpeaker)]									
	//				[Tone type (CallTone, Keytone, MIC, GMI, Speech, SideTone, Melody) ]	
	//				[Level (1~7)]															

	unsigned char	volume[MAX_VOL_CATE][MAX_VOL_TYPE];
	// Current Volume Level:	[Mode (Normal, Headset, LoudSpeaker)]									
	//							[Tone type (CallTone, Keytone, MIC, GMI, Speech, SideTone, Melody) ]	
	//							value: 0~6 [ Level_1(0) ~ Level_7(6) ]
   	
} CustAcousticVol_T;
typedef struct {
	unsigned char	volume_gain[MAX_VOL_CATE][MAX_VOL_TYPE][MAX_VOL_LEVEL];
	// Volume Gain:	[Mode (Normal, Headset, LoudSpeaker)]									
	//				[Tone type (CallTone, Keytone, MIC, GMI, Speech, SideTone, Melody) ]	
	//				[Level (1~7)]															

	unsigned char	volume[MAX_VOL_CATE][MAX_VOL_TYPE];
	// Current Volume Level:	[Mode (Normal, Headset, LoudSpeaker)]									
	//							[Tone type (CallTone, Keytone, MIC, GMI, Speech, SideTone, Melody) ]	
	//							value: 0~6 [ Level_1(0) ~ Level_7(6) ]
   	unsigned char max_melody_volume_gain[MAX_VOL_CATE + 1];
    unsigned char melody_volume_gain_step[MAX_VOL_CATE + 1];
    unsigned char tv_out_volume_gain[MAX_VOL_LEVEL];
} CustAcousticVol16lvl_T;

// S/W Change 
typedef enum {
	LID_VER_SAME = 0,
	LID_VER_CHANGED
}LID_STATUS;

typedef struct {
	int		OldVer;
	int		NewVer;
	char	LID[64];
}LID_Info;

typedef struct {
   int		target_nvramsize;	// current NVRAM size on target FAT file system
   int		target_freespace;	// current freespace of target FAT file system
   int		target_overhead;	// S/W upgrade operation overhead
   int		newdb_nvramsize;	// new NVRAM size
   unsigned char	status;		// 0 -> [OK] safe to upgrade to new NVRAM
   								// 1 -> [ERROR] can't retrieve info from target
   								// 2 -> [ERROR] freespace is not enough to upgrade to new NVRAM
} NVRAM_GetDiskInfo_Cnf;

// WiFi 
typedef struct {
	unsigned char	mac_addr[6];
} WiFi_MacAddress_S;

typedef struct {
	unsigned char	CCKTxPWR[14]; 
	unsigned char	OFDMTxPWR[14]; 
} WiFi_TxPower_2400M_S;

typedef struct {
	unsigned char	TxPWR[34]; 
} WiFi_TxPower_5000M_S;

typedef struct {
	unsigned char	i_ch_offset;
	unsigned char	q_ch_offset;
} WiFi_DAC_DC_Offset_S;

typedef struct {
	unsigned char txAlcCCK[14];
    unsigned char txOutputPowerDBCCK[14];
    unsigned char txAlcOFDM [8][14];
    unsigned char txOutputPowerDBOFDM[8][14];
} WiFi_ALC_2400M_S;

typedef struct
{
    unsigned char alcSlop1Divider;
    unsigned char alcSlop1Dividend;
    unsigned char alcSlop2Divider;
    unsigned char alcSlop2Dividend;
} WiFi_TxALC_2400M_S;
typedef struct
{
   unsigned char BluetoothAddress[6];
   unsigned char MinEncryptionSize[1];
   unsigned char MaxEncryptionSize[1];
   unsigned char HCITransportLayerParameters[3];
   unsigned char FixedPIN[16];
   unsigned char FixedPINLength[1];
   unsigned char SleepEnableMask[1];
   unsigned char LowPowerClockParameter[8];
   unsigned char PowerControlConfiguration[13];
   unsigned char SleepControlParameters[12];
   unsigned char DebugControl[4];
   unsigned char LCandRMOverrideEnable[4];
   unsigned char RadioRegisterOverride[6];
   unsigned char CodecConfiguration[8];
   unsigned char CVSDGainVolumeSettings[6];
   unsigned char VoiceSettings[2];
   unsigned char UserBaudRate[3];

   unsigned char LowPowerDriftRate[1];
   unsigned char MaxTxPowerLevel[1];
   unsigned char AdaptiveFrequencyHoppingParameters[29];
   unsigned char BufferSize[4];
   unsigned char GpioMapping[16];
   unsigned char GpioPolarity[4];
}  nvram_ef_btradio_rfmd3500_struct;

typedef struct
{
    unsigned char BDAddr[6];
    unsigned char ClassOfDevice[3];
    unsigned char LinkKeyType[1];
    unsigned char UnitKey[16];
    unsigned char Encryption[3];
    unsigned char PinCodeType[1];
    unsigned char Voice[2];
    unsigned char Codec[1];
    unsigned char Radio[30];
    unsigned char Sleep[6];
    unsigned char MainOscillatorInfo[5];
    unsigned char LPOInfo[4];
    unsigned char AFH[9];
    unsigned char PTA[49];
    unsigned char WDT[2];
    unsigned char Debug[1];
    unsigned char UART[2];
}  nvram_ef_btradio_mt6601_struct;

//Deprecated structure
/*
typedef struct
{
	unsigned char addr[6];
	unsigned char CapId[1];
	unsigned char LinkKeyType[1];
	unsigned char UnitKey[16];
	unsigned char Encryption[3];
	unsigned char PinCodeType[1];
	unsigned char Voice[2];
	unsigned char Codec[2];
	unsigned char Radio[6];
	unsigned char Sleep[7];
	unsigned char Reserved[2];
}nvram_ef_btradio_mt6611_struct;
*/

typedef struct
{
    unsigned char addr[6];
    unsigned char CapId[1];
    unsigned char Codec[1];
    
} NVRAM_BTRADIO_MT6611_S;

//delete old struct define
/*
typedef struct
{
    unsigned char addr[6];
    unsigned char Voice[2];
    unsigned char Codec[4];
    unsigned char Radio[6];
    unsigned char Sleep[7];
    unsigned char BtFTR[2];
    unsigned char TxPWOffset[3];
    
} NVRAM_BTRADIO_MT6620_S;
*/

typedef struct
{
    unsigned char addr[6];
    unsigned char Voice[2];
    unsigned char Codec[4];
    unsigned char Radio[6];
    unsigned char Sleep[7];
    unsigned char BtFTR[2];
    unsigned char TxPWOffset[3];
	unsigned char CoexAdjust[6];      // BT/WIFI coexistence performance adjustment
    unsigned char Reserved1[2];       // Reserved
    unsigned char Reserved2[2];       // Reserved
    unsigned char Reserved3[4];       // Reserved
    unsigned char Reserved4[4];       // Reserved
    unsigned char Reserved5[8];       // Reserved
    unsigned char Reserved6[8];       // Reserved
    
} NVRAM_BTRADIO_MT6620_S;

typedef struct
{
    unsigned char addr[6];
    unsigned char CapId[1];
    unsigned char LinkKeyType[1];
    unsigned char UintKey[16];
    unsigned char Encryption[3];
    unsigned char PinCodeType[1];
    unsigned char Voice[2];
    unsigned char Codec[4];
    unsigned char Radio[6];
    unsigned char Sleep[7];
    unsigned char BtFTR[2];
    unsigned char TxPWOffset[3];
    unsigned char ECLK_SEL[1];
    unsigned char Reserved1[1];
    unsigned char Reserved2[2];
    unsigned char Reserved3[4];
    unsigned char Reserved4[4];
    unsigned char Reserved5[16];
    unsigned char Reserved6[16];
    
}NVRAM_BTRADIO_MT6626_S;

//-----------------------------------------------------//
//  NVRAM: callback function definition                //
//-----------------------------------------------------//
typedef void (__stdcall *META_NVRAM_Reset_CNF)(const FT_NVRAM_RESET_CNF *cnf, const short token, void *usrData);
typedef void (__stdcall *META_NVRAM_Read_CNF)(const FT_NVRAM_READ_CNF *cnf, const short token, void *usrData);
typedef void (__stdcall *META_NVRAM_Write_CNF)(const FT_NVRAM_WRITE_CNF *cnf, const short token, void *usrData);
typedef void (__stdcall *CB_META_NVRAM_GET_DISK_INFO_CNF)(const NVRAM_GetDiskInfo_Cnf *cnf, const short token, void *usrData);

//-----------------------------------------------------//
//  NVRAM: exported function definition                //
//-----------------------------------------------------//
META_RESULT  __stdcall SP_META_NVRAM_Init(const char *PathName, unsigned long *p_nvram_CatcherTranAddr);
META_RESULT  __stdcall SP_META_NVRAM_Init_r(const int meta_handle,const char *PathName, unsigned long *p_nvram_CatcherTranAddr);
META_RESULT  __stdcall SP_META_NVRAM_Reset(const FT_NVRAM_RESET_REQ *req, const META_NVRAM_Reset_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_NVRAM_Reset_r(const int meta_handle, const FT_NVRAM_RESET_REQ *req, const META_NVRAM_Reset_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_NVRAM_Read(const FT_NVRAM_READ_REQ *req, FT_NVRAM_READ_CNF *cnf, const META_NVRAM_Read_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_NVRAM_Read_r(const int meta_handle, const FT_NVRAM_READ_REQ *req, FT_NVRAM_READ_CNF *cnf, const META_NVRAM_Read_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_NVRAM_Write(const FT_NVRAM_WRITE_REQ *req, const META_NVRAM_Write_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_NVRAM_Write_r(const int meta_handle, const FT_NVRAM_WRITE_REQ *req, const META_NVRAM_Write_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_NVRAM_GetAllLIDNameLength(int *len);
META_RESULT  __stdcall SP_META_NVRAM_GetAllLIDName(char *buf, const int buf_len, int *NofLID);
META_RESULT  __stdcall SP_META_NVRAM_GetLIDVersion(const char *LID,unsigned short *ver);
META_RESULT  __stdcall SP_META_NVRAM_GetRecStructNameLength(const char *LID, int *len);
META_RESULT  __stdcall SP_META_NVRAM_GetRecStructName(const char *LID, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_GetAllRecFieldNameLength(const char *LID, int *len);
META_RESULT  __stdcall SP_META_NVRAM_GetAllRecFieldName(const char *LID, char *buf, const int buf_len, int *NofField);
META_RESULT  __stdcall SP_META_NVRAM_CheckFieldNameExist(const char *LID, const char *Field, bool *result);
META_RESULT  __stdcall SP_META_NVRAM_GetRecNum(const char *LID, int *num);
META_RESULT  __stdcall SP_META_NVRAM_GetRecLen(const char *LID, int *len);
META_RESULT  __stdcall SP_META_NVRAM_SetRecFieldValue(const char *LID, const char *field, char *buf, const int buf_len, void *value, const int value_len);
META_RESULT  __stdcall SP_META_NVRAM_GetRecFieldValue(const char *LID, const char *field, const char *buf, const int buf_len, void *value, const int value_len);
META_RESULT  __stdcall SP_META_NVRAM_SetRecFieldBitValue(const char *LID, const char *field, const char *bitname, char *buf, const int buf_len, const int bitvalue);
META_RESULT  __stdcall SP_META_NVRAM_GetRecFieldBitValue(const char *LID, const char *field, const char *bitname, const char *buf, const int buf_len, int *bitvalue);
META_RESULT  __stdcall SP_META_NVRAM_QueryIsLIDExist(const char *LID);
META_RESULT  __stdcall SP_META_NVRAM_ResetToFactoryDefault(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_NVRAM_ResetToFactoryDefault_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_NVRAM_LockDown(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_NVRAM_LockDown_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_NVRAM_OTP_LockDown(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_NVRAM_OTP_LockDown_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_NVRAM_CheckAPDbVersion();
META_RESULT  __stdcall SP_META_NVRAM_CheckAPDbVersion_r(const int meta_handle);

// S/W Change
META_RESULT  __stdcall SP_META_NVRAM_SWC_RetrieveChangeList(void);
META_RESULT  __stdcall SP_META_NVRAM_SWC_RetrieveChangeList_r(const int meta_handle);
META_RESULT  __stdcall SP_META_NVRAM_SWC_UpdateChangeList(void);
META_RESULT  __stdcall SP_META_NVRAM_SWC_UpdateChangeList_r(const int meta_handle);
META_RESULT  __stdcall SP_META_NVRAM_SWC_GetAllChangedLIDCount(int *NofLID);
META_RESULT  __stdcall SP_META_NVRAM_SWC_GetAllChangedLIDCount_r(const int meta_handle, int *NofLID);
META_RESULT  __stdcall SP_META_NVRAM_SWC_GetAllChangedLIDName(LID_Info *p_ArrayOfLID, const int NofLID);
META_RESULT  __stdcall SP_META_NVRAM_SWC_GetAllChangedLIDName_r(const int meta_handle, LID_Info *p_ArrayOfLID, const int NofLID);
META_RESULT  __stdcall SP_META_NVRAM_SWC_QueryIfLIDChanged(const char *LID, LID_STATUS  *result);
META_RESULT  __stdcall SP_META_NVRAM_SWC_QueryIfLIDChanged_r(const int meta_handle, const char *LID, LID_STATUS  *result);
META_RESULT  __stdcall SP_META_NVRAM_SWC_ImportData(LID_Info *p_import_multiple_lid, int num_of_import_multiple_lid, int import_1st_sys_record_size );
META_RESULT  __stdcall SP_META_NVRAM_SWC_ImportData_r(const int meta_handle, LID_Info *p_import_multiple_lid, int num_of_import_multiple_lid, int import_1st_sys_record_size );
META_RESULT  __stdcall SP_META_NVRAM_SWC_Database_Compare(const char *PathName, int *p_NumOfNewAddLID, int *p_NumOfModifiedLID, int *p_NumOfDeletedLID);
META_RESULT  __stdcall SP_META_NVRAM_SWC_Database_Compare_r(const int meta_handle, const char *PathName, int *p_NumOfNewAddLID, int *p_NumOfModifiedLID, int *p_NumOfDeletedLID);
META_RESULT  __stdcall SP_META_NVRAM_SWC_Get_Database_Compare_Result(LID_Info *p_ArrayOfNewAddLID, const int NumOfNewAddLID, LID_Info *p_ArrayOfModifiedLID, const int NumOfModifiedLID, LID_Info *p_ArrayOfDeletedLID, const int NumOfDeletedLID);
META_RESULT  __stdcall SP_META_NVRAM_SWC_Get_Database_Compare_Result_r(const int meta_handle, LID_Info *p_ArrayOfNewAddLID, const int NumOfNewAddLID, LID_Info *p_ArrayOfModifiedLID, const int NumOfModifiedLID, LID_Info *p_ArrayOfDeletedLID, const int NumOfDeletedLID);
META_RESULT  __stdcall SP_META_NVRAM_SWC_Check_FAT_FreeSpace(const CB_META_NVRAM_GET_DISK_INFO_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_NVRAM_SWC_Check_FAT_FreeSpace_r(const int meta_handle, const CB_META_NVRAM_GET_DISK_INFO_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_NVRAM_SWC_Enable_ForceUpgrade(void);
META_RESULT  __stdcall SP_META_NVRAM_SWC_Enable_ForceUpgrade_r(const int meta_handle);
META_RESULT  __stdcall SP_META_NVRAM_SWC_Disable_ForceUpgrade(void);
META_RESULT  __stdcall SP_META_NVRAM_SWC_Disable_ForceUpgrade_r(const int meta_handle);

META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioBesLoudNess(const l4aud_acf_param *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioBesLoudNess(l4aud_acf_param *param, const char *buf, const int buf_len);

// 6516 add
META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioBesLoudNess_6516(const l4aud_get_acf_param_cnf *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioBesLoudNess_6516(l4aud_get_acf_param_cnf *param, const char *buf, const int buf_len);

// AGC path loss 
META_RESULT  __stdcall SP_META_NVRAM_agcPathLoss_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_agcPathLoss(const l1cal_agcPathLoss_T *loss, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_agcPathLoss(l1cal_agcPathLoss_T *loss, const char *buf, const int buf_len);

META_RESULT  __stdcall SP_META_NVRAM_rampTable_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_rampTable(const l1cal_rampTable_T *tbl, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_rampTable(l1cal_rampTable_T *tbl, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_rampTable_Len_Ex(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_rampTable_Ex(const l1cal_rampTable_T_Ex *tbl, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_rampTable_Ex(l1cal_rampTable_T_Ex *tbl, const char *buf, const int buf_len);

// rampTable
META_RESULT  __stdcall SP_META_NVRAM_rampTable_Len_Ex2(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_rampTable_Ex2(const l1cal_rampTable_T_Ex2 *tbl, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_rampTable_Ex2(l1cal_rampTable_T_Ex2 *tbl, const char *buf, const int buf_len);

// L1Audio Param
META_RESULT  __stdcall SP_META_NVRAM_AudioParam_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioParam(const l1audio_param_T *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioParam(l1audio_param_T *param, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_If_AudioParam_W0547_Support(void);
META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioParam_W0547(const l1audio_param_W0547_T *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioParam_W0547(l1audio_param_W0547_T *param, const char *buf, const int buf_len);

META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioParam_W0547_45(const l1audio_param_W0547_45_T *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioParam_W0547_45(l1audio_param_W0547_45_T *param, const char *buf, const int buf_len);

META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioParam_W0712(const l1audio_param_W0712_T *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioParam_W0712(l1audio_param_W0712_T *param, const char *buf, const int buf_len);
// interRampData
META_RESULT  __stdcall SP_META_NVRAM_interRampData_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_interRampData(const l1cal_interRampData_T *tbl, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_interRampData(l1cal_interRampData_T *tbl, const char *buf, const int buf_len);
// crystalAfcData
META_RESULT  __stdcall SP_META_NVRAM_crystalAfcData_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_crystalAfcData(const l1cal_crystalAfcData_T *xo_afc, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_crystalAfcData(l1cal_crystalAfcData_T *xo_afc, const char *buf, const int buf_len);
// IMEISV
META_RESULT  __stdcall SP_META_NVRAM_Calculate_IMEI_CD(const char *imei, unsigned short *p_cd);
META_RESULT  __stdcall SP_META_NVRAM_IMEISV_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_IMEISV(const IMEISV_struct_T  *p_imeisv, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_IMEISV_NoCheck(const IMEISV_struct_T  *p_imeisv, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_IMEISV_ex(const IMEISV_struct_T  *p_imeisv, char *buf, const int buf_len,bool DoCheckSum);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_IMEISV(IMEISV_struct_T  *p_imeisv, const char *buf, const int buf_len);

// Custom Acoustic Volume
META_RESULT  __stdcall SP_META_NVRAM_CustAcousticVol_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_CustAcousticVol(const CustAcousticVol_T *cust_acoustic_vol, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_CustAcousticVol(CustAcousticVol_T *cust_acoustic_vol, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_16lvlCustAcousticVol(const CustAcousticVol16lvl_T *cust_acoustic_vol, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_16lvlCustAcousticVol(CustAcousticVol16lvl_T *cust_acoustic_vol, const char *buf, const int buf_len);
// RF Module Configuration 
META_RESULT  __stdcall SP_META_NVRAM_RFSpecialCoef_Len(int *len);
// Skyworks 
META_RESULT  __stdcall SP_META_NVRAM_Compose_SKY74045_RFSpecialCoef(const RF_SKY74045_Coef_T *rf_mod_coef, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_SKY74045_RFSpecialCoef(RF_SKY74045_Coef_T *rf_mod_coef, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_SKY74117_RFSpecialCoef(const RF_SKY74117_Coef_T *rf_mod_coef, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_SKY74117_RFSpecialCoef(RF_SKY74117_Coef_T *rf_mod_coef, const char *buf, const int buf_len);
// MT6139B 
META_RESULT  __stdcall SP_META_NVRAM_Compose_MT6139B_RFSpecialCoef(const RF_MT6139B_Coef_T *rf_mod_coef, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_MT6139B_RFSpecialCoef(RF_MT6139B_Coef_T *rf_mod_coef, const char *buf, const int buf_len);
// MT6140
META_RESULT  __stdcall SP_META_NVRAM_Compose_MT6140tx_RFSpecialCoef(const mt6140tx *rf_mod_coef, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_MT6140tx_RFSpecialCoef(mt6140tx *rf_mod_coef, const char *buf, const int buf_len);

META_RESULT  __stdcall SP_META_NVRAM_Compose_MT6140tx_PaVbias(const mt6140tx *pavbias, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_MT6140tx_PaVbias(mt6140tx *pavbias, const char *buf, const int buf_len);

// Renesas Bright5P 
META_RESULT  __stdcall SP_META_NVRAM_Compose_BRIGHT5P_RFSpecialCoef(const RF_BRIGHT5P_Coef_T *rf_mod_coef, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_BRIGHT5P_RFSpecialCoef(RF_BRIGHT5P_Coef_T *rf_mod_coef, const char *buf, const int buf_len);
// EPSK interRampData 
META_RESULT  __stdcall SP_META_NVRAM_EPSK_interRampData_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_EPSK_interRampData(const l1cal_EPSK_interRampData_T *tbl, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_EPSK_interRampData(l1cal_EPSK_interRampData_T *tbl, const char *buf, const int buf_len);




META_RESULT  __stdcall SP_META_NVRAM_3G_Compose_tempdacData(const ul1cal_tempdacData_T  *dac, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_3G_Decompose_tempdacData(ul1cal_tempdacData_T  *dac, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_3G_Compose_pathlossData(const ul1cal_pathlossData_T  *pathloss, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_3G_Decompose_pathlossData(ul1cal_pathlossData_T  *pathloss, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_3G_Compose_txdacData(const ul1cal_txdacData_T  *txdac, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_3G_Decompose_txdacData(ul1cal_txdacData_T  *txdac, const char *buf, const int buf_len);


// Gain Table

META_RESULT  __stdcall SP_META_Audio_GainTable(unsigned int ms_timeout, l4aud_gaintable_cnf * pCnf);
META_RESULT  __stdcall SP_META_Audio_GainTable_r(const int meta_handle, unsigned int ms_timeout, l4aud_gaintable_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_GainTableNum(unsigned int ms_timeout, l4aud_gaintablenum_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_GainTableNum_r(const int meta_handle, unsigned int ms_timeout, l4aud_gaintablenum_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_GainTableLevel(unsigned int ms_timeout,l4aud_gaintablelevel_req *pReq, l4aud_gaintablelevel_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_GainTableLevel_r(const int meta_handle,unsigned int ms_timeout,l4aud_gaintablelevel_req *pReq, l4aud_gaintablelevel_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_CtrpointNum(unsigned int ms_timeout,l4aud_ctrpointnum_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_CtrpointNum_r(const int meta_handle,unsigned int ms_timeout,l4aud_ctrpointnum_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_CtrpointBits(unsigned int ms_timeout, l4aud_ctrpointbits_req *pReq,l4aud_ctrpointbits_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_CtrpointBits_r(const int meta_handle,unsigned int ms_timeout,l4aud_ctrpointbits_req *pReq,l4aud_ctrpointbits_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_CtrpointTable(unsigned int ms_timeout, l4aud_ctrpointtable_req *pReq,l4aud_ctrpointtable_cnf *pCnf);
META_RESULT  __stdcall SP_META_Audio_CtrpointTable_r(const int meta_handle,unsigned int ms_timeout, l4aud_ctrpointtable_req *pReq,l4aud_ctrpointtable_cnf *pCnf);
META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioGainTable(const AUDIO_GAIN_TABLE_STRUCT *param, char *buf, const int buf_len, bool isVersionV4);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioGainTable(AUDIO_GAIN_TABLE_STRUCT *param, char *buf, const int buf_len, bool isVersionV4);


// HD Recording

META_RESULT  __stdcall SP_META_Audio_HdRecGetInfo(unsigned int ms_timeout, l4aud_hdrec_info_cnf * pCnf);
META_RESULT  __stdcall SP_META_Audio_HdRecGetInfo_r(const int meta_handle, unsigned int ms_timeout, l4aud_hdrec_info_cnf * pCnf);
META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioHdRecSceneTableStruct(const AUDIO_HD_RECORD_SCENE_TABLE_STRUCT *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioHdRecSceneTableStruct(AUDIO_HD_RECORD_SCENE_TABLE_STRUCT *param, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioHdRecParamStruct(const AUDIO_HD_RECORD_PARAM_STRUCT *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioHdRecParamStruct(AUDIO_HD_RECORD_PARAM_STRUCT *param, const char *buf, const int buf_len);



//BT
typedef enum 
{
  BT_CHIP_ID_MT6611 = 0,
  BT_CHIP_ID_MT6612,
  BT_CHIP_ID_MT6616,
  BT_CHIP_ID_MT6620,
  BT_CHIP_ID_MT6622,
  BT_CHIP_ID_MT6626,
  BT_CHIP_ID_MT6628,
  BT_CHIP_ID_MT6572,
  BT_CHIP_ID_MT6582,
  BT_CHIP_ID_MT6592,
  BT_CHIP_ID_MT6630,
  BT_CHIP_ID_END
  
} BT_CHIP_ID_E;

META_RESULT  __stdcall SP_META_NVRAM_BT_Compose_RFMD3500Radio(const nvram_ef_btradio_rfmd3500_struct  *radio, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_Decompose_RFMD3500Radio(nvram_ef_btradio_rfmd3500_struct  *radio, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_Compose_MT6601Radio(const nvram_ef_btradio_mt6601_struct  *radio, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_Decompose_MT6601Radio(nvram_ef_btradio_mt6601_struct  *radio, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_Compose_MT6611Radio(const NVRAM_BTRADIO_MT6611_S *radio, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_Decompose_MT6611Radio(NVRAM_BTRADIO_MT6611_S *radio, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_Compose_MT6620Radio(const NVRAM_BTRADIO_MT6620_S *radio, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_Decompose_MT6620Radio(NVRAM_BTRADIO_MT6620_S *radio, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_Compose_MT6626Radio(const NVRAM_BTRADIO_MT6626_S *radio, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_Decompose_MT6626Radio(NVRAM_BTRADIO_MT6626_S *radio, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_BT_QueryChipByStructSize(BT_CHIP_ID_E * chipID);

// sBBTxParameters
META_RESULT  __stdcall SP_META_NVRAM_BBTXParameters_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_BBTXParameters(const BBTXParameters_T *bbtx, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_BBTXParameters(BBTXParameters_T *bbtx, const char *buf, const int buf_len);
//l1audio_param_W0740_T
META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioParam_W0740(const l1audio_param_W0740_T *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioParam_W0740(l1audio_param_W0740_T *param, const char *buf, const int buf_len);
// l1audio_param_W0809_T
META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioParam_W0809(const l1audio_param_W0809_T *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioParam_W0809(l1audio_param_W0809_T *param, const char *buf, const int buf_len);
// ad6546tx
META_RESULT  __stdcall SP_META_NVRAM_Compose_ad6546tx(const ad6546tx *adtx, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_ad6546tx(ad6546tx *adtx, const char *buf, const int buf_len);
//Dual mic
META_RESULT  __stdcall SP_META_NVRAM_Compose_Extra_AudioParam_W1105(const l1audio_extra_param_W1105_T *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_Extra_AudioParam_W1105(l1audio_extra_param_W1105_T *param, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Compose_Extra_AudioParam_W1134(const l1audio_extra_param_W1134_T *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_Extra_AudioParam_W1134(l1audio_extra_param_W1134_T *param, const char *buf, const int buf_len);
// l1audio_param_W0809_6516_T   (NEW ADD)
META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioParam_W0809_6516(const l1audio_param_W0809_6516_T *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioParam_W0809_6516(l1audio_param_W0809_6516_T *param, const char *buf, const int buf_len);


//--------------------------------------------------------------------------//
//  Audio Testing                                                           //
//--------------------------------------------------------------------------//

//-----------------------------------------------------//
//  Audio Testing: data structure definition           //
//-----------------------------------------------------//

// audio testing result
typedef enum  {
	AUD_RES_OK = 0,						// OK 
	AUD_RES_FAIL,						// General Fail 
	AUD_RES_BUSY,						// system busy 
	AUD_RES_DISC_FULL,					// Memory full 
	AUD_RES_OPEN_FILE_FAIL,				// open file fail 
	AUD_RES_END_OF_FILE,				// play finish 
	AUD_ERR_OP_NOT_SUPPORT = 0xFB,       // added by ShuMin, for error handler enhancements// filepath too long
	AUD_ERR_STILL_PLAYING = 0xFC,       // added by ShuMin, because I found target had this error value
	AUD_ERR_PEER_BUF_ERROR = 0xFD,		// peer buf error 
	AUD_ERR_FILEPATH_ERROR = 0xFE,		// filepath error 
	AUD_ERR_FILEPATH_TOO_LONG = 0xFF	// filepath too long 
}AUDIO_RESULT;

// play style enum 
typedef enum {
	FT_L4AUD_AUDIO_PLAY_CRESCENDO = 0,	// Play sound for crescendo. 
	FT_L4AUD_AUDIO_PLAY_INFINITE,		// Play sound for infinite. 
	FT_L4AUD_AUDIO_PLAY_ONCE,			// Play sound for once. 
	FT_L4AUD_AUDIO_PLAY_DESCENDO		// Play sound for descendo. 
}AUDIO_PLAY_STYLE;

// default system embeded audio id query 
typedef struct {
	unsigned short		MinRingTone_ID;
	unsigned short		MaxRingTone_ID;
	unsigned short		MinMIDI_ID;
	unsigned short		MaxMIDI_ID;
	unsigned short		MinSound_ID;
	unsigned short		MaxSound_ID;
	AUDIO_RESULT		status;
}Audio_Query_ID_Cnf;

// play default system embeded audio by the given audio id 
typedef struct {
	unsigned short		audio_id;		// default system embeded audio id 
	AUDIO_PLAY_STYLE	play_style;		// play style 
}Audio_Play_Req;

// play audio from FAT by the given filepath 
typedef struct {
	const char			*fat_filepath;	// filepath on target FAT file system 
	AUDIO_PLAY_STYLE	play_style;		// play style 
}Audio_Play_ByName_Req;

// play imelody by the buffer from PC side 
typedef struct {
	const char			*imy_buf;		// buffer that stores iMelody content 
	unsigned int		imy_buf_len;	// length of buffer 
	unsigned char		imy_instrument;	// instrument id, 1 ~ 128 
	AUDIO_PLAY_STYLE	play_style;		// play style 
}Audio_Play_IMY_ByBuf_Req;

// play mp3 from FAT by the given filepath 
typedef struct {
	const char			*fat_filepath;	// filepath on target FAT file system 
	AUDIO_PLAY_STYLE	play_style;		// play style 
}Audio_MEDIA_Play_Req;

// set volume 
typedef struct {
	unsigned char		volume;			// play volume, 0 ~ 255 
}Audio_Set_Volume_Req;

typedef struct {
	unsigned char		echoflag;			// echofalg true
}Audio_Set_Echo_Req;

typedef struct {
	unsigned char		modeflag;			// modeflag
}Audio_Set_Mode_Req;

typedef struct {
	unsigned char		type;
	unsigned char		gain;
}Audio_Set_Gain_Req;

typedef struct {
	short		in_fir_coeffs[45];
	short		out_fir_coeffs[45];
}Audio_Set_LoudSpk_FIR_Coeffs_Req;

/*
typedef struct
{
	unsigned int     bes_loudness_hsf_coeff[9][4];
	unsigned int     bes_loudness_bpf_coeff[4][6][3];
	// BesLoudness V3
	unsigned int besloudness_DRC_Forget_Table[9][2];
	unsigned int besloudness_WS_Gain_Max;
	unsigned int besloudness_WS_Gain_Min;
	unsigned int besloudness_Filter_First;
	char         besloudness_Gain_Map_In[5];
	char         besloudness_Gain_Map_Out[5];
	
}Audio_Ex_SetACFToTarget_REQ_T;
*/





typedef struct {
	unsigned short speech_common_para[12];  // 8 or 12, so at most 12
}Audio_Set_Speech_Common_Req;

typedef struct {
	unsigned short speech_loudspk_mode_para[16];  // change from 8 to 16, because at most: 16
}Audio_Set_LoudSpk_Mode_Req;

typedef struct {
	unsigned short Media_Playback_Maximum_Swing;
}Audio_Set_Playback_Maximum_Swing_Req;

typedef struct {
	short Melody_FIR_Output_Coeff_32k_Tbl1[25];
}Audio_Set_Melody_FIR_Output_Coeffs_Req;

typedef struct {
	unsigned short speech_common_para[12];
	unsigned short speech_loudspk_mode_para[16];  // change from 8 to 16, because at most: 16
}Audio_Set_Speech_Common_And_Mode_Req;

typedef struct {
	unsigned short		fre;
	unsigned char		spkgain;
	unsigned char		micgain;
	unsigned short      ulgain; 
	unsigned short      dlgain;
	unsigned short      amp;
    
}Audio_Tone_LoopBackRec_Req;

typedef struct {
	unsigned int		buffer[2000];
}Audio_Tone_LoopBackRec_Cnf;

typedef struct {
	unsigned int		buffer[500];
}Audio_Tone_LoopBackRec_Cnf_2K;

typedef struct
{
	unsigned char  m_ucVolume;
	unsigned short m_u2Freq;
}Audio_Set_Freq_Vol_Tone_Req_T;

typedef struct
{
	unsigned char  m_ucMode;
}Audio_Get_Profile_Settings_By_Mode_Req_T;

typedef struct
{
	unsigned char mode;
    unsigned char melody[7];         
    unsigned char sound[7];          
    unsigned char keytone[7];         
    unsigned char speech[7];         
    unsigned char mic[7];           
    unsigned char sidetone;         
    unsigned char max_melody_volume_gain;
    unsigned char melody_volume_gain_step;
    unsigned char tv_out_volume_gain[MAX_VOL_LEVEL];  // 7 here

}Audio_Get_Profile_Settings_By_Mode_Cnf_T;

typedef struct
{
	unsigned char mode;
    unsigned char melody[7];         
    unsigned char sound[7];          
    unsigned char keytone[7];         
    unsigned char speech[7];         
    unsigned char mic[7];           
    unsigned char sidetone;         
    unsigned char max_melody_volume_gain;
    unsigned char melody_volume_gain_step;
    unsigned char tv_out_volume_gain[MAX_VOL_LEVEL];  // 7 here

}Audio_Set_Profile_Settings_By_Mode_Req_T;

typedef struct
{
    
    unsigned short m_u2FailReason;  // possible fail resons

}Audio_Set_Profile_Settings_By_Mode_Cnf_T;


typedef struct
{
    unsigned short m_u2FailReason;  // possible fail resons, (2 means the format is not matched with Target side)
}Audio_Set_Param_Cnf_T;

typedef	struct
{
	char	receiver_test;		// receiver_test true mean enable
}ft_l4aud_receiver_test;

typedef	struct
{
	char	left_channel;		// true mean enable
	char	right_channel;		// true mean enable
}ft_l4aud_loudspk;




//For Dual Mic

typedef enum 
{
    RECORD_ERROR = 0,
    RECORD_START,
    RECORD_END,
    NUM_RECORD_STATES
    
}AUDIO_RECORD_STATES_E;


typedef struct
{
    char fileName[256];
    
}AUDIO_DL_PLAYBACK_FILE_REQ_S;

typedef struct
{
    char fileName[256];
    int duration;	  /* record duration */
    
}AUDIO_DUALMIC_RECORD_REQ_S;

typedef struct
{
    char playbackFileName[256];	
    char recordingFileName[256];
    int recordDuration;
    
}AUDIO_PLAYBACK_DUALMICRECORD_REQ_S;

typedef struct
{
    char pcFileName[256];
    char tgFileName[256];
    
}AUDIO_LOAD_FILE_REQ_S;

typedef struct
{
    int value;
    
}AUDIO_PARAM_VALUE_S;


//-----------------------------------------------------//
//  API function definition for Dual Mic       //
//-----------------------------------------------------//

META_RESULT  __stdcall SP_META_Audio_SetPlaybackFile(unsigned int  ms_timeout, const AUDIO_DL_PLAYBACK_FILE_REQ_S  *req);
META_RESULT  __stdcall SP_META_Audio_SetPlaybackFile_r(const int meta_handle, unsigned int  ms_timeout, const AUDIO_DL_PLAYBACK_FILE_REQ_S  *req);
META_RESULT  __stdcall SP_META_Audio_DualMicRecord(unsigned int  ms_timeout, const AUDIO_DUALMIC_RECORD_REQ_S *req, AUDIO_RECORD_STATES_E * cnf);
META_RESULT  __stdcall SP_META_Audio_DualMicRecord_r(const int meta_handle, unsigned int  ms_timeout, const AUDIO_DUALMIC_RECORD_REQ_S *req, AUDIO_RECORD_STATES_E * cnf);
META_RESULT  __stdcall SP_META_Audio_PlaybackDualMicRecord(unsigned int  ms_timeout, const AUDIO_PLAYBACK_DUALMICRECORD_REQ_S *req, AUDIO_RECORD_STATES_E * cnf);
META_RESULT  __stdcall SP_META_Audio_PlaybackDualMicRecord_r(const int meta_handle, unsigned int  ms_timeout, const AUDIO_PLAYBACK_DUALMICRECORD_REQ_S *req, AUDIO_RECORD_STATES_E * cnf);
META_RESULT  __stdcall SP_META_Audio_PlaybackDualMicRecord_HS(unsigned int  ms_timeout, const AUDIO_PLAYBACK_DUALMICRECORD_REQ_S *req, AUDIO_RECORD_STATES_E * cnf);
META_RESULT  __stdcall SP_META_Audio_PlaybackDualMicRecord_HS_r(const int meta_handle, unsigned int  ms_timeout, const AUDIO_PLAYBACK_DUALMICRECORD_REQ_S *req, AUDIO_RECORD_STATES_E * cnf);
META_RESULT  __stdcall SP_META_Audio_StopDualMicRecord(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_Audio_StopDualMicRecord_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_Audio_DownloadFile(unsigned int  ms_timeout, const AUDIO_LOAD_FILE_REQ_S  *req);
META_RESULT  __stdcall SP_META_Audio_DownloadFile_r(const int meta_handle, unsigned int  ms_timeout, const AUDIO_LOAD_FILE_REQ_S  *req);
META_RESULT  __stdcall SP_META_Audio_UploadFile(unsigned int  ms_timeout, const AUDIO_LOAD_FILE_REQ_S  *req);
META_RESULT  __stdcall SP_META_Audio_UploadFile_r(const int meta_handle, unsigned int  ms_timeout, const AUDIO_LOAD_FILE_REQ_S  *req);
META_RESULT  __stdcall SP_META_Audio_GetRecordingGain(unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * cnf);
META_RESULT  __stdcall SP_META_Audio_GetRecordingGain_r(const int meta_handle, unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * cnf);
META_RESULT  __stdcall SP_META_Audio_SetRecordingGain(unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * req);
META_RESULT  __stdcall SP_META_Audio_SetRecordingGain_r(const int meta_handle, unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * req);
META_RESULT  __stdcall SP_META_Audio_GetPlaybackGain(unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * cnf);
META_RESULT  __stdcall SP_META_Audio_GetPlaybackGain_r(const int meta_handle, unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * cnf);
META_RESULT  __stdcall SP_META_Audio_SetPlaybackGain(unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * req);
META_RESULT  __stdcall SP_META_Audio_SetPlaybackGain_r(const int meta_handle, unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * req);
META_RESULT  __stdcall SP_META_Audio_GetPlaybackGain_HS(unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * cnf);
META_RESULT  __stdcall SP_META_Audio_GetPlaybackGain_HS_r(const int meta_handle, unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * cnf);
META_RESULT  __stdcall SP_META_Audio_SetPlaybackGain_HS(unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * req);
META_RESULT  __stdcall SP_META_Audio_SetPlaybackGain_HS_r(const int meta_handle, unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * req);

META_RESULT  __stdcall SP_META_Audio_QueryRecordStatus(AUDIO_RECORD_STATES_E * pStates);
META_RESULT  __stdcall SP_META_Audio_QueryRecordStatus_r(const int meta_handle, AUDIO_RECORD_STATES_E * pStates);

META_RESULT  __stdcall SP_META_Audio_QueryWBSupport(unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * cnf);
META_RESULT  __stdcall SP_META_Audio_QueryWBSupport_r(const int meta_handle, unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * cnf);
META_RESULT  __stdcall SP_META_Audio_SetWBMode(unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * req);
META_RESULT  __stdcall SP_META_Audio_SetWBMode_r(const int meta_handle, unsigned int  ms_timeout, AUDIO_PARAM_VALUE_S * req);


//-----------------------------------------------------//
//  Audio Testing: callback function definition        //
//-----------------------------------------------------//
typedef void (__stdcall *META_AUDIO_QUERY_ID_CNF)(const Audio_Query_ID_Cnf *cnf, const short token, void *usrData);
typedef void (__stdcall *META_AUDIO_PLAY_CNF)(const AUDIO_RESULT status, const short token, void *usrData);
typedef void (__stdcall *META_AUDIO_PLAY_BYNAME_CNF)(const AUDIO_RESULT status, const short token, void *usrData);
typedef void (__stdcall *META_AUDIO_PLAY_IMY_BYBUF_CNF)(const AUDIO_RESULT status, const short token, void *usrData);
typedef void (__stdcall *META_AUDIO_PLAY_OVER_IND)(const AUDIO_RESULT status, const short token, void *usrData);
typedef void (__stdcall *META_AUDIO_STOP_CNF)(const AUDIO_RESULT status, const short token, void *usrData);
typedef void (__stdcall *META_AUDIO_MEDIA_PLAY_CNF)(const AUDIO_RESULT status, const short token, void *usrData);
typedef void (__stdcall *META_AUDIO_MEDIA_PLAY_OVER_IND)(const AUDIO_RESULT status, const short token, void *usrData);
typedef void (__stdcall *META_AUDIO_MEDIA_STOP_CNF)(const AUDIO_RESULT status, const short token, void *usrData);
typedef void (__stdcall *META_AUDIO_SET_VOLUME_CNF)(const AUDIO_RESULT status, const short token, void *usrData);

//-----------------------------------------------------//
//  Audio Testing: exported function definition        //
//-----------------------------------------------------//

META_RESULT  __stdcall SP_META_Audio_Query_ID(const META_AUDIO_QUERY_ID_CNF  cnf_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Query_ID_r(const int meta_handle, const META_AUDIO_QUERY_ID_CNF  cnf_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Play(const Audio_Play_Req  *req, const META_AUDIO_PLAY_CNF cnf_cb, const META_AUDIO_PLAY_OVER_IND  ind_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Play_r(const int meta_handle, const Audio_Play_Req  *req, const META_AUDIO_PLAY_CNF cnf_cb, const META_AUDIO_PLAY_OVER_IND  ind_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Play_ByName(const Audio_Play_ByName_Req  *req, const META_AUDIO_PLAY_BYNAME_CNF  cnf_cb, const META_AUDIO_PLAY_OVER_IND  ind_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Play_ByName_r(const int meta_handle, const Audio_Play_ByName_Req  *req, const META_AUDIO_PLAY_BYNAME_CNF  cnf_cb, const META_AUDIO_PLAY_OVER_IND  ind_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Play_IMY_ByBuf(const Audio_Play_IMY_ByBuf_Req  *req, const META_AUDIO_PLAY_IMY_BYBUF_CNF  cnf_cb, const META_AUDIO_PLAY_OVER_IND  ind_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Play_IMY_ByBuf_r(const int meta_handle, const Audio_Play_IMY_ByBuf_Req  *req, const META_AUDIO_PLAY_IMY_BYBUF_CNF  cnf_cb, const META_AUDIO_PLAY_OVER_IND  ind_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Stop(const META_AUDIO_STOP_CNF  cnf_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Stop_r(const int meta_handle, const META_AUDIO_STOP_CNF  cnf_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_MEDIA_Play(const Audio_MEDIA_Play_Req  *req, const META_AUDIO_MEDIA_PLAY_CNF  cnf_cb, const META_AUDIO_MEDIA_PLAY_OVER_IND  ind_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_MEDIA_Play_r(const int meta_handle, const Audio_MEDIA_Play_Req  *req, const META_AUDIO_MEDIA_PLAY_CNF  cnf_cb, const META_AUDIO_MEDIA_PLAY_OVER_IND  ind_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_MEDIA_Stop(const META_AUDIO_MEDIA_STOP_CNF  cnf_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_MEDIA_Stop_r(const int meta_handle, const META_AUDIO_MEDIA_STOP_CNF  cnf_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Set_Volume(const Audio_Set_Volume_Req  *req, const META_AUDIO_SET_VOLUME_CNF  cnf_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Set_Volume_r(const int meta_handle, const Audio_Set_Volume_Req  *req, const META_AUDIO_SET_VOLUME_CNF  cnf_cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Audio_Set_Echo_Loop(unsigned int  ms_timeout,const Audio_Set_Echo_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Echo_Loop_r(const int meta_handle,unsigned int  ms_timeout ,const Audio_Set_Echo_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Mode(unsigned int  ms_timeout,const Audio_Set_Mode_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Mode_r(const int meta_handle,unsigned int  ms_timeout ,const Audio_Set_Mode_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Gain(unsigned int  ms_timeout,const Audio_Set_Gain_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Gain_r(const int meta_handle,unsigned int  ms_timeout ,const Audio_Set_Gain_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Tone_Loop_Back_Rec(unsigned int  ms_timeout, Audio_Tone_LoopBackRec_Req  *req, Audio_Tone_LoopBackRec_Cnf *cnf);
META_RESULT  __stdcall SP_META_Audio_Tone_Loop_Back_Rec_r(const int meta_handle,unsigned int  ms_timeout , Audio_Tone_LoopBackRec_Req  *req, Audio_Tone_LoopBackRec_Cnf *cnf);
//  for loud-speaker mode
META_RESULT  __stdcall SP_META_Audio_Tone_Loop_Back_Rec_2K(unsigned int  ms_timeout, Audio_Tone_LoopBackRec_Req  *req, Audio_Tone_LoopBackRec_Cnf_2K *cnf);
META_RESULT  __stdcall SP_META_Audio_Tone_Loop_Back_Rec_2K_r(const int meta_handle,unsigned int  ms_timeout , Audio_Tone_LoopBackRec_Req  *req, Audio_Tone_LoopBackRec_Cnf_2K *cnf);
// for normal mode
META_RESULT  __stdcall SP_META_Audio_Tone_Loop_Back_Rec_2K_Normal(unsigned int  ms_timeout, Audio_Tone_LoopBackRec_Req  *req, Audio_Tone_LoopBackRec_Cnf_2K *cnf);
META_RESULT  __stdcall SP_META_Audio_Tone_Loop_Back_Rec_2K_Normal_r(const int meta_handle,unsigned int  ms_timeout , Audio_Tone_LoopBackRec_Req  *req, Audio_Tone_LoopBackRec_Cnf_2K *cnf);
META_RESULT  __stdcall SP_META_Audio_Set_LoudSpk_FIR_Coeffs(unsigned int  ms_timeout,const Audio_Set_LoudSpk_FIR_Coeffs_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_LoudSpk_FIR_Coeffs_r(const int meta_handle, unsigned int  ms_timeout,const Audio_Set_LoudSpk_FIR_Coeffs_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Speech_Common(unsigned int  ms_timeout,const Audio_Set_Speech_Common_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Speech_Common_r(const int meta_handle, unsigned int  ms_timeout,const Audio_Set_Speech_Common_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_LoudSpk_Mode(unsigned int  ms_timeout,const Audio_Set_LoudSpk_Mode_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_LoudSpk_Mode_r(const int meta_handle, unsigned int  ms_timeout,const Audio_Set_LoudSpk_Mode_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Playback_Maximum_Swing(unsigned int  ms_timeout,const Audio_Set_Playback_Maximum_Swing_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Playback_Maximum_Swing_r(const int meta_handle, unsigned int  ms_timeout,const Audio_Set_Playback_Maximum_Swing_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Melody_FIR_Output_Coeffs(unsigned int  ms_timeout,const Audio_Set_Melody_FIR_Output_Coeffs_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Melody_FIR_Output_Coeffs_r(const int meta_handle, unsigned int  ms_timeout,const Audio_Set_Melody_FIR_Output_Coeffs_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Speech_Common_And_Mode(unsigned int  ms_timeout,const Audio_Set_Speech_Common_And_Mode_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Speech_Common_And_Mode_r(const int meta_handle, unsigned int  ms_timeout,const Audio_Set_Speech_Common_And_Mode_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Play_Freq_Vol_Tone(unsigned int  ms_timeout,const Audio_Set_Freq_Vol_Tone_Req_T  *req);
META_RESULT  __stdcall SP_META_Audio_Play_Freq_Vol_Tone_r(const int meta_handle, unsigned int  ms_timeout,const Audio_Set_Freq_Vol_Tone_Req_T  *req);
META_RESULT  __stdcall SP_META_Audio_Stop_Freq_Vol_Tone(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_Audio_Stop_Freq_Vol_Tone_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_Audio_Get_Audio_Profile_Settings(unsigned int ms_timeout,Audio_Get_Profile_Settings_By_Mode_Req_T *req, Audio_Get_Profile_Settings_By_Mode_Cnf_T *cnf);
META_RESULT  __stdcall SP_META_Audio_Get_Audio_Profile_Settings_r(const int meta_handle, unsigned int  ms_timeout, Audio_Get_Profile_Settings_By_Mode_Req_T *req, Audio_Get_Profile_Settings_By_Mode_Cnf_T *cnf);
META_RESULT  __stdcall SP_META_Audio_Set_Audio_Profile_Settings(unsigned int ms_timeout,Audio_Set_Profile_Settings_By_Mode_Req_T *req, Audio_Set_Profile_Settings_By_Mode_Cnf_T *cnf);
META_RESULT  __stdcall SP_META_Audio_Set_Audio_Profile_Settings_r(const int meta_handle, unsigned int  ms_timeout, Audio_Set_Profile_Settings_By_Mode_Req_T *req, Audio_Set_Profile_Settings_By_Mode_Cnf_T *cnf);
META_RESULT  __stdcall SP_META_Audio_Get_Audio_Param_Settings_0809(unsigned int ms_timeout,l1audio_param_W0809_T *cnf);
META_RESULT  __stdcall SP_META_Audio_Get_Audio_Param_Settings_0809_r(const int meta_handle, unsigned int  ms_timeout,  l1audio_param_W0809_T *cnf);
META_RESULT  __stdcall SP_META_Audio_Set_Audio_Param_Settings_0809(unsigned int ms_timeout,l1audio_param_W0809_T *req,Audio_Set_Param_Cnf_T *cnf);
META_RESULT  __stdcall SP_META_Audio_Set_Audio_Param_Settings_0809_r(const int meta_handle, unsigned int  ms_timeout,  l1audio_param_W0809_T *req,Audio_Set_Param_Cnf_T *cnf);
META_RESULT  __stdcall SP_META_Audio_Receiver_Test(unsigned int ms_timeout, ft_l4aud_receiver_test *req);
META_RESULT  __stdcall SP_META_Audio_Receiver_Test_r(const int meta_handle, unsigned int ms_timeout, ft_l4aud_receiver_test *req);
META_RESULT  __stdcall SP_META_Audio_LoudSpk_Test(unsigned int ms_timeout, ft_l4aud_loudspk *req);
META_RESULT  __stdcall SP_META_Audio_LoudSpk_Test_r(const int meta_handle, unsigned int ms_timeout, ft_l4aud_loudspk *req);
META_RESULT  __stdcall SP_META_Audio_EX_SetACFIIRToTarget(const unsigned int ms_timeout, l4aud_acf_param *req);
META_RESULT  __stdcall SP_META_Audio_EX_SetACFIIRToTarget_r(const int meta_handle, const unsigned int ms_timeout, l4aud_acf_param *req);
// Wei Fang add about HCF
META_RESULT __stdcall SP_META_Audio_EX_SetHCFIIRToTarget(const unsigned int ms_timeout, l4aud_acf_param *req);
META_RESULT __stdcall SP_META_Audio_EX_SetHCFIIRToTarget_r(const int meta_handle, const unsigned int ms_timeout, l4aud_acf_param *req);

//6516 add
META_RESULT  __stdcall SP_META_Audio_EX_SetACFIIRToTarget_6516(const unsigned int ms_timeout, l4aud_get_acf_param_cnf *req);
META_RESULT  __stdcall SP_META_Audio_EX_SetACFIIRToTarget_6516_r(const int meta_handle, const unsigned int ms_timeout, l4aud_get_acf_param_cnf *req);


//New API
META_RESULT  __stdcall SP_META_Audio_LoadVolume(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_Audio_LoadVolume_r(const int meta_handle, unsigned int ms_timeout);

//--------------------------------------------------------------------------//
//  BaseBand Testing                                                        //
//--------------------------------------------------------------------------//

//-----------------------------------------------------//
//  BaseBand Testing: data structure definition        //
//-----------------------------------------------------//

typedef struct{
	unsigned int		addr;
	unsigned char		bytenum;
}CPU_REG_READ_REQ;

typedef struct{
	unsigned int		value;
	unsigned char		status;
}CPU_REG_READ_CNF;

typedef struct{
	unsigned int		addr;
	unsigned int		value;
	unsigned char		bytenum;
}CPU_REG_WRITE_REQ;

typedef struct{
	unsigned char		status;
}CPU_REG_WRITE_CNF;


typedef struct{
	unsigned char 	registernumber;	/// the valid value: 0--96
}WM_CMD_ReadPMICRegister_REQ_T;

typedef struct{
	unsigned char 		value;
	int		status;
}WM_CMD_ReadRegister_CNF_T;

typedef struct{
	unsigned char registernumber;   //the valid value: 20~~ 96
	unsigned char registervalue;
}WM_CMD_WritePMICRegister_REQ_T;

typedef struct{
	int value;   //not used
	int		status;
}WM_CMD_WriteRegister_CNF_T;


//add by dian.wang for MT6573 PMIC
typedef struct{
	unsigned long 	registernumber;	/// the valid value: 0--96
}WM_CMD_ReadPMICRegister_DWORD_REQ_T;

typedef struct{
	unsigned int  value;
	unsigned char status;
}WM_CMD_ReadRegister_DWORD_CNF_T;

typedef struct{
	unsigned long registernumber;   //the valid value: 20~~ 96
	unsigned short registervalue;
}WM_CMD_WritePMICRegister_DWORD_REQ_T;

typedef struct{
	unsigned int    value;   //not used
	unsigned char	status;
}WM_CMD_WriteRegister_DWORD_CNF_T;

////////////////////////////////////////


typedef struct {
    int num;
    int delay;
    int tolerance;
} GS_CMD_CALI;

typedef struct {
    int x;
    int y;
    int z; 
} GS_ACK_CALI;

typedef struct {
    int dummy;
} GS_CMD_READ_RAW;

typedef struct {
    int x;
    int y;
    int z;
} GS_ACK_READ_RAW;

typedef struct {
    int x;
    int y;
    int z;    
} GS_CMD_WRITE_NVRAM;

typedef struct {
    int   dummy;
} GS_ACK_WRITE_NVRAM;

typedef struct {
    int   dummy;
} GS_CMD_READ_NVRAM;

typedef struct {
    int x;
    int y;
    int z;    
} GS_ACK_READ_NVRAM;



META_RESULT  __stdcall SP_META_GS_Perform_Calibration(unsigned int ms_timeout, const  GS_CMD_CALI *req, GS_ACK_CALI *cnf);
META_RESULT  __stdcall SP_META_GS_Perform_Calibration_r(const int meta_handle, unsigned int ms_timeout, const  GS_CMD_CALI *req, GS_ACK_CALI *cnf);

META_RESULT  __stdcall SP_META_GS_Write_NVRAM(unsigned int ms_timeout, const  GS_CMD_WRITE_NVRAM *req, GS_ACK_WRITE_NVRAM *cnf);
META_RESULT  __stdcall SP_META_GS_Write_NVRAM_r(const int meta_handle, unsigned int ms_timeout, const  GS_CMD_WRITE_NVRAM *req, GS_ACK_WRITE_NVRAM *cnf);

META_RESULT  __stdcall SP_META_GS_Read_Raw(unsigned int ms_timeout, const  GS_CMD_READ_RAW *req, GS_ACK_READ_RAW *cnf);
META_RESULT  __stdcall SP_META_GS_Read_Raw_r(const int meta_handle, unsigned int ms_timeout, const  GS_CMD_READ_RAW *req, GS_ACK_READ_RAW *cnf);

typedef struct {
    int num;
    int delay;
    int tolerance;
} GYRO_CMD_CALI;

typedef struct {
    int x;
    int y;
    int z; 
} GYRO_ACK_CALI;

typedef struct {
    int dummy;
} GYRO_CMD_READ_RAW;

typedef struct {
    int x;
    int y;
    int z;
} GYRO_ACK_READ_RAW;

typedef struct {
    int x;
    int y;
    int z;    
} GYRO_CMD_WRITE_NVRAM;

typedef struct {
    int   dummy;
} GYRO_ACK_WRITE_NVRAM;

typedef struct {
    int   dummy;
} GYRO_CMD_READ_NVRAM;

typedef struct {
    int x;
    int y;
    int z;    
} GYRO_ACK_READ_NVRAM;


META_RESULT  __stdcall SP_META_GYRO_Perform_Calibration(unsigned int ms_timeout, const  GYRO_CMD_CALI*req, GYRO_ACK_CALI *cnf);
META_RESULT  __stdcall SP_META_GYRO_Perform_Calibration_r(const int meta_handle, unsigned int ms_timeout, const  GYRO_CMD_CALI*req, GYRO_ACK_CALI *cnf);


META_RESULT  __stdcall SP_META_GYRO_Write_NVRAM(unsigned int ms_timeout, const  GYRO_CMD_WRITE_NVRAM*req, GYRO_ACK_WRITE_NVRAM *cnf);
META_RESULT  __stdcall SP_META_GYRO_Write_NVRAM_r(const int meta_handle, unsigned int ms_timeout, const  GYRO_CMD_WRITE_NVRAM*req, GYRO_ACK_WRITE_NVRAM *cnf);


META_RESULT  __stdcall SP_META_GYRO_Read_Raw(unsigned int ms_timeout, const  GYRO_CMD_READ_RAW *req, GYRO_ACK_READ_RAW *cnf);
META_RESULT  __stdcall SP_META_GYRO_Read_Raw_r(const int meta_handle, unsigned int ms_timeout, const  GYRO_CMD_READ_RAW *req, GYRO_ACK_READ_RAW *cnf);

typedef struct
{
	unsigned char	channel;	// ADC channel number.
	unsigned short	Meacount;	// Number of measure times.
} ADCMeaData_Req;

typedef struct
{
	unsigned int	value;		// ADC value, it a sum value of each measurement data.
	int				drv_status;
	unsigned char	status;		// 0: success, others: get ADC measurement fail.
} ADCMeaData_Cnf;

//-----------------------------------------------------//
//  BaseBand Testing: callback function definition     //
//-----------------------------------------------------//
typedef void (__stdcall *META_BB_READREG_CNF)(const CPU_REG_READ_CNF *result, const short token, void *usrData);
typedef void (__stdcall *META_BB_WRITEREG_CNF)(const CPU_REG_WRITE_CNF *result, const short token, void *usrData);
typedef void (__stdcall *META_BB_ADCGETMEADATA_CNF)(const ADCMeaData_Cnf *result, const short token, void *usrData);

//-----------------------------------------------------//
//  BaseBand Testing: exported function definition     //
//-----------------------------------------------------//

META_RESULT  __stdcall SP_META_BB_RegRead(const CPU_REG_READ_REQ *req, const META_BB_READREG_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_BB_RegRead_r(const int meta_handle, const CPU_REG_READ_REQ *req, const META_BB_READREG_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_BB_RegWrite(const CPU_REG_WRITE_REQ *req, const META_BB_WRITEREG_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_BB_RegWrite_r(const int meta_handle, const CPU_REG_WRITE_REQ *req, const META_BB_WRITEREG_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_BB_ADCGetMeaSumData(const ADCMeaData_Req *req, const META_BB_ADCGETMEADATA_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_BB_ADCGetMeaSumData_r(const int meta_handle, const ADCMeaData_Req *req, const META_BB_ADCGETMEADATA_CNF cb, short *token, void *usrData);

//--------------------------------------------------------------------------//
//  FAT Access                                                              //
//--------------------------------------------------------------------------//

//-----------------------------------------------------//
//  FAT Access: data structure definition              //
//-----------------------------------------------------//
typedef enum {
	FAT_OPEN_READ = 0,
	FAT_OPEN_WRITE
}FAT_OPEN_MODE;

typedef enum {
	FAT_FIND_FILE = 0,
	FAT_FIND_FILE_RECURSIVE,
	FAT_FIND_DIR_RECURSIVE
}FAT_FIND_MODE;

typedef enum {
	FAT12 = 0,
	FAT16,
	FAT32
}FAT_TYPE;

typedef struct {
	FAT_TYPE		Type;
	unsigned int 	SectorsPerCluster;
	unsigned int	TotalSize;
	unsigned int	FreeSpace;
}FAT_DiskInfo_T;

typedef struct 
{
	char m_cDriveLetter;   // Target FAT disk drive letter such as: 'C'
	char *m_pcfilepath;    // File path of the file we intend to write into target FAT

}FAT_FILE_INFO_REQ_T;

//-----------------------------------------------------//
//  FAT Access: callback function definition           //
//-----------------------------------------------------//
typedef int (__stdcall *CALLBACK_META_FAT_PROGRESS)(unsigned char percent, int sent_bytes, int total_bytes, const short token, void *usr_arg);

//-----------------------------------------------------//
//  FAT Access: exported function definition           //
//-----------------------------------------------------//


/*  NOR_DRIVE = 1,
	NAND_DRIVE=2,
	CARD_DRIVE = 3,
	EXTERNAL_DRIVE = 4
*/
META_RESULT  __stdcall SP_META_FAT_GetDriveType(unsigned int ms_timeout, const char DriveLetter, int *p_DriveType);
META_RESULT  __stdcall SP_META_FAT_GetDriveType_r(const int meta_handle, unsigned int ms_timeout, const char DriveLetter, int *p_DriveType);
//--------------------------------------------------------------------------//
//  WiFi Calibration                                                        //
//--------------------------------------------------------------------------//

//-----------------------------------------------------//
//  WiFi Calibration: data structure definition        //
//-----------------------------------------------------//

// WiFi Baseband Chip ID 
#define WIFI_BB_MT5911		0x00000001

// WiFi RF Chip ID 
#define WIFI_RF_AL2236		0x00000001
#define WIFI_RF_MAX2827		0x00000002

typedef enum {
	WIFI_TEST_RATE_1M = 0,     /* 1M          */
	WIFI_TEST_RATE_2M,         /* 2M          */
	WIFI_TEST_RATE_5_5M,       /* 5.5M        */
	WIFI_TEST_RATE_11M,        /* 11M         */
	WIFI_TEST_RATE_6M,         /* 6M          */
	WIFI_TEST_RATE_9M,         /* 9M          */
	WIFI_TEST_RATE_12M,        /* 12M         */
	WIFI_TEST_RATE_18M,        /* 18M         */
	WIFI_TEST_RATE_24M,        /* 24M         */
	WIFI_TEST_RATE_36M,        /* 36M         */
	WIFI_TEST_RATE_48M,        /* 48M         */
	WIFI_TEST_RATE_54M,        /* 54M         */
	WIFI_TEST_RATE_COUNT       /* Total count */
} WiFi_TestRate_E;

typedef enum {
	 WNDRV_HOST_INTERFACE_SDIO = 0
	,WNDRV_HOST_INTERFACE_HPI
	,WNDRV_HOST_INTERFACE_SPI
	,WNDRV_HOST_INTERFACE_CF_MEM
	,WNDRV_HOST_INTERFACE_CF_IO  
} WiFi_HostInterface_E;

typedef enum {
	WIFI_TX_ALL_ZEROS,
	WIFI_TX_ALL_ONES,
	WIFI_TX_ALTERNATE_BITS,
	WIFI_TX_PSEUDO_RANDOM
} WiFi_TestPktTxPattern_E;

typedef enum {
	WIFI_POWER_MODE_NORMAL,
	WIFI_POWER_MODE_IDLE,
	WIFI_POWER_MODE_SLEEP
} WiFi_PowerManagementMode_E;

typedef enum {    
	WIFI_RF_RX_TEST_MODE = 1  /* For RF Test use */
} WiFi_TestPktRxMode_E;

typedef enum {
	WIFI_RX_ANT_DIVERSITY_AGC,  /* AGC based selection */
	WIFI_RX_ANT_DIVERSITY_MPDU, /* MPDU based selection */
	WIFI_RX_ANT_FIXED_0,        /* Always 0 */ 
	WIFI_RX_ANT_FIXED_1         /* Always 1 */
} WiFi_RxAntSel_E;

typedef struct {
	unsigned int	bb_chip_id;
	char			bb_chip_ver[32];
	unsigned int	rf_chip_id;
	char			rf_chip_ver[32];
	unsigned char	support_802_11b;
	unsigned char	support_802_11a;
	unsigned char	support_802_11g;
	bool			eeprom_exist;
	unsigned int	eeprom_size;
	WiFi_HostInterface_E	host_interface;
} WiFi_ChipCapability_S;

typedef struct {
	unsigned int		ch_freq; /* Frq, units are kHz */
	WiFi_TestRate_E		tx_rate;
	int					dbm;
} WiFi_DBM2DAC_Set_S;

typedef struct {
	unsigned short		tx_gain_dac;
} WiFi_DBM2DAC_Query_S;

typedef struct {
	unsigned int		ch_freq;/* Frq, units are kHz */
	WiFi_TestRate_E		tx_rate;
	unsigned char		txAnt; /* 0 for Antenna 0; 1 for Antenna 1 */
	unsigned short		tx_gain_dac;
} WiFi_TestTx_S;

typedef struct {
	unsigned int			ch_freq;			/* Frq, units are kHz */
	WiFi_TestRate_E			tx_rate;
	unsigned short			tx_gain_dac;
	unsigned int			pktCount;
	unsigned int			pktInterval;		/* interval between each Tx Packet */
	unsigned int			pktLength;			/* 24~1500 */
	WiFi_TestPktTxPattern_E	pattern;			/* content of the Tx Packet */
	unsigned char			txAnt;				/* 0 for Antenna 0; 1 for Antenna 1 */
	unsigned char			is_short_preamble;	/* 0 for long preamble and 1 for short preamble */
	unsigned char			mac_header[ 24 ];	/* Frame Ctrl, Duration = 2bytes + 2bytes */
												/* Address 1 = 6 bytes */ 
												/* Address 2 = 6 bytes */ 
												/* Address 3 = 6 bytes */ 
												/* Sequence Ctrl = 2 bytes */
} WiFi_TestPktTx_S;

typedef struct {
	unsigned int			ch_freq;			/* Frq, units are kHz */
	WiFi_TestRate_E			tx_rate;
	unsigned short			tx_gain_dac;
	unsigned int			pktCount;
	unsigned int			pktInterval;		/* interval between each Tx Packet */
	unsigned int			pktLength;			/* 24~1500 */
	WiFi_TestPktTxPattern_E	pattern;			/* content of the Tx Packet */
	unsigned char			txAnt;				/* 0 for Antenna 0; 1 for Antenna 1 */
	unsigned int			txFlags;
	unsigned int			targetAlc;
	unsigned char			is_short_preamble;	/* 0 for long preamble and 1 for short preamble */
	unsigned char			mac_header[ 24 ];	/* Frame Ctrl, Duration = 2bytes + 2bytes */
												/* Address 1 = 6 bytes */ 
												/* Address 2 = 6 bytes */ 
												/* Address 3 = 6 bytes */ 
												/* Sequence Ctrl = 2 bytes */
} WiFi_TestPktTx_Ex_S;

typedef struct {    
	unsigned int		pkt_sent_count;  /* total num sent */
	unsigned int		pkt_sent_acked;  /* acked num */    
} WiFi_TxStatus_S;


typedef struct {    
	unsigned int		pkt_sent_count;  /* total num sent */
	unsigned int		pkt_sent_acked;  /* acked num */    
	unsigned short		avgAlc;
	unsigned char		cckGainControl;
    unsigned char		ofdmGainControl;
} WiFi_TxStatus_Ex_S;

typedef struct {
	unsigned int				ch_freq;  /* Frq, units are kHz */
	WiFi_TestPktRxMode_E		mode;
	WiFi_RxAntSel_E				rxAnt;
} WiFi_TestPktRx_S;

typedef struct {    
	unsigned int		int_rx_ok_num;     /* number of packets that Rx ok from interrupt */
	unsigned int		int_crc_err_num;   /* number of packets that CRC error from interrupt */
	unsigned int		pau_rx_pkt_count;  /* number of packets that Rx ok from PAU */
	unsigned int		pau_crc_err_count; /* number of packets that CRC error from PAU */
	unsigned int		pau_cca_count;     /* CCA rising edge count */
	unsigned int		pau_rx_fifo_full_count; /* number of lost packets due to FiFo full */
	unsigned int		int_long_preamble_num;
	unsigned int		int_short_preamble_num;
	unsigned int		int_rate_ok_num[ WIFI_TEST_RATE_COUNT ];
	unsigned int		int_rate_crc_err_num[ WIFI_TEST_RATE_COUNT ];
	int					int_rssi_max;
	int					int_rssi_min;
	int					int_rssi_mean;
	int					int_rssi_variance;
} WiFi_RxStatus_S;

typedef struct {    
	int  ED;
	int  OSD;
	int  SQ1;
	int  SFD;
	int  CRC16;
} WiFi_RxCounter_S;

typedef struct {    
	unsigned int	channel_num;
	unsigned char	channel_list[64];
} WiFi_ChannelList_S;

typedef struct {    
	unsigned char	country_code[2];
} WiFi_RegDomain_S;

typedef struct {
	unsigned int	index;		// 32bits alignment index, +4 
	unsigned int	mcr_data32;
} WiFi_MACReg32_S;

typedef struct {
	unsigned int	index;		// 16bits alignment index, +2 
	unsigned short	mcr_data16;
} WiFi_MACReg16_S;

typedef struct {
	unsigned int	index;		// 8bits alignment index, +1 
	unsigned char	bbcr_data8;
} WiFi_BBReg8_S;

typedef struct {
	unsigned int	index;		// 16bits alignment index, +2 
	unsigned short	eeprom_data16;
} WiFi_EEPROM_S;


// Wei Fang 2011-12-8
META_RESULT __stdcall SP_META_WiFi_switchAntenna_r(const int meta_handle, unsigned int ms_timeout,unsigned int value);
META_RESULT __stdcall SP_META_WiFi_switchAntenna(unsigned int ms_timeout,unsigned int value);


//--------------------------------------------------------------------------//
//  BT Calibration                                                          //
//--------------------------------------------------------------------------//

//-----------------------------------------------------//
//  BT Calibration: data structure definition          //
//-----------------------------------------------------//

// BT Module ID 
#define BT_NOT_SUPPORT		0x00000000
#define BTMODULE_MT6601		0x00000011
#define BTMODULE_MT6611	    0x00000012
#define BTMODULE_RFMD3500   0x00000021 
#define BTMODULE_RFMD4020	0x00000022

//#define BT_PACKET_LEN       339
#define BT_PACKET_LEN       1021  // because BT2.0 support at most 1021 bytes per packet
#define BT_BUFFER_LEN       1024
#define BT_DATA_LEN           1026
typedef struct {
	unsigned char	id;
} BT_ModuleID_S;

typedef struct {
	unsigned char   m_event;
	char         	m_status;
	unsigned short  m_handle;
	unsigned char	m_len;
	unsigned char	m_parms[256];
} BT_HCI_EVENT;

typedef struct {
	unsigned short	m_opcode;
	unsigned char	m_len;
	unsigned char	m_cmd[256];
} BT_HCI_COMMAND;
typedef struct {
    unsigned short           m_con_hdl;
    unsigned short           m_len;      	
    unsigned char            m_buffer[BT_BUFFER_LEN]; 
} BT_HCI_BUFFER;
typedef struct {
    unsigned short           m_len;
    unsigned char            m_data[BT_DATA_LEN];
} BT_HCI_PACKET;
typedef struct {
    unsigned short           m_con_hdl;
    unsigned short           m_len;      	
    unsigned short           m_total_pks; 
} BT_HCI_TX_PURE_TEST;

typedef struct {
    unsigned int             m_used_time;
    unsigned short           m_len;     
} BT_HCI_TX_PURE_TEST_STAT;

typedef struct {
    unsigned int             m_used_time;
    unsigned short           m_len;     
} BT_HCI_RX_PURE_TEST_STAT;

typedef struct {
    unsigned int             m_u4UsedTime;
    unsigned short           m_u2PktSentNum; 
    
} BT_HCI_TX_PURE_TEST_STAT_V2;


//-----------------------------------------------------//
//  BT Calibration Functions                           //
//-----------------------------------------------------//
META_RESULT  __stdcall SP_META_BT_QueryModuleID(unsigned int  ms_timeout, BT_ModuleID_S  *cnf);
META_RESULT  __stdcall SP_META_BT_QueryModuleID_r(const int meta_handle, unsigned int  ms_timeout, BT_ModuleID_S  *cnf);

typedef void (__stdcall *META_BT_HCI_CNF)(const BT_HCI_EVENT *cnf, const short token, void *usrData);
typedef void (__stdcall *META_BT_HCI_TXDATA_CNF)(const BT_HCI_PACKET *cnf, const short token, void *usrData);
typedef void (__stdcall *META_BT_AUTO_HCI_CNF)(const BT_HCI_EVENT *cnf, const short token, void *usrData);
typedef void (__stdcall *META_BT_HCI_RXDATA_CNF)(const BT_HCI_BUFFER *cnf, const short token, void *usrData);

typedef void (__stdcall *META_BT_HCI_TXTEST_CNF)(const BT_HCI_TX_PURE_TEST_STAT *cnf, const short token, void *usrData);
typedef void (__stdcall *META_BT_HCI_RXTEST_CNF)(const BT_HCI_RX_PURE_TEST_STAT *cnf, const short token, void *usrData);

typedef void (__stdcall *META_BT_HCI_TXTEST_V2_CNF)(const BT_HCI_TX_PURE_TEST_STAT_V2 *cnf, const short token, void *usrData);

typedef struct{
	META_BT_HCI_TXDATA_CNF      m_SendDataCallback;
	META_BT_HCI_RXDATA_CNF		m_RecvDataCallback;
	META_BT_AUTO_HCI_CNF		m_AutoCallback;
	META_BT_HCI_TXTEST_CNF		m_TxTestCallback;
	META_BT_HCI_RXTEST_CNF		m_RxTestCallback;
	META_BT_HCI_TXTEST_V2_CNF   m_TxTestCallback_V2;
} BT_OtherCallBack;

META_RESULT  __stdcall SP_META_BT_SendHCICommand(unsigned int  ms_timeout,BT_HCI_COMMAND *req, META_BT_HCI_CNF  cb, void  *cb_arg, unsigned char Cmpltcode);
META_RESULT  __stdcall SP_META_BT_SendHCICommand_r(const int meta_handle, unsigned int  ms_timeout,BT_HCI_COMMAND *req, META_BT_HCI_CNF  cb, void  *cb_arg, unsigned char Cmpltcode);
META_RESULT  __stdcall SP_META_BT_CancelHCICommand(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_CancelHCICommand_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_SendHCIData(unsigned int  ms_timeout,BT_HCI_BUFFER *snd, META_BT_HCI_TXDATA_CNF  cb_tx, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_SendHCIData_r(const int meta_handle, unsigned int  ms_timeout,BT_HCI_BUFFER *snd, META_BT_HCI_TXDATA_CNF  cb_tx, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_RegisterAutoCallback(META_BT_AUTO_HCI_CNF cb_auto);
META_RESULT  __stdcall SP_META_BT_RegisterAutoCallback_r(const int meta_handle,META_BT_AUTO_HCI_CNF cb_auto);
META_RESULT  __stdcall SP_META_BT_ReceiveHCIData(META_BT_HCI_RXDATA_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_ReceiveHCIData_r(const int meta_handle,META_BT_HCI_RXDATA_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_RemoveAutoCallback();
META_RESULT  __stdcall SP_META_BT_RemoveAutoCallback_r(const int meta_handle);
META_RESULT  __stdcall SP_META_BT_RemoveReceiveHCIDataCallback();
META_RESULT  __stdcall SP_META_BT_RemoveReceiveHCIDataCallback_r(const int meta_handle);

META_RESULT  __stdcall SP_META_BT_GetChipID(unsigned int  ms_timeout, unsigned int * pID);
META_RESULT  __stdcall SP_META_BT_GetChipID_r(const int meta_handle, unsigned int  ms_timeout, unsigned int * pID);




//----------------------------------------------------------------//
//                              MATV                              //
//----------------------------------------------------------------//

typedef struct
{
	unsigned int	freq;
	unsigned char	sndsys;
	unsigned char	colsys;
	unsigned char	flag;
}matv_ch_entry;

typedef struct
{
    unsigned char   m_ucChannel;
    matv_ch_entry   m_rmatv_ch_entry;
}FT_MATV_SET_CHANNEL_PROPERTY_REQ_T;

typedef struct
{
    unsigned char   m_ucProgress;
    unsigned char   m_ucChannels;
    matv_ch_entry   m_rmatv_ch_entry[70];
}FT_MATV_GET_CHANNEL_LIST_CNF_T;

typedef struct
{
    int             m_i4QualityIndex[128];
}FT_MATV_GET_CHANNEL_QUALITY_ALL_CNF_T;

typedef struct
{
    char chipname[20];
}MATV_CHIPNAME_S;


META_RESULT  __stdcall SP_META_MATV_PowerOn(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_MATV_PowerOn_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_MATV_PowerOff(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_MATV_PowerOff_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_MATV_SetRegion(unsigned int ms_timeout, unsigned char region);
META_RESULT  __stdcall SP_META_MATV_SetRegion_r(const int meta_handle, unsigned int ms_timeout, unsigned char region);
META_RESULT  __stdcall SP_META_MATV_StartScan(unsigned int ms_timeout, unsigned int scanmode);
META_RESULT  __stdcall SP_META_MATV_StartScan_r(const int meta_handle, unsigned int ms_timeout, unsigned char scanmode);
META_RESULT  __stdcall SP_META_MATV_StartFullScan(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_MATV_StartFullScan_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_MATV_StopScan(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_MATV_StopScan_r(const int meta_handle, unsigned int ms_timeout);


META_RESULT  __stdcall SP_META_MATV_GetChannelList(unsigned int ms_timeout, FT_MATV_GET_CHANNEL_LIST_CNF_T* cnf);
META_RESULT  __stdcall SP_META_MATV_GetChannelList_r(const int meta_handle, unsigned int ms_timeout, FT_MATV_GET_CHANNEL_LIST_CNF_T* cnf);
META_RESULT  __stdcall SP_META_MATV_ChangeChannel(unsigned int ms_timeout, unsigned char channel);
META_RESULT  __stdcall SP_META_MATV_ChangeChannel_r(const int meta_handle, unsigned int ms_timeout, unsigned char channel);
META_RESULT  __stdcall SP_META_MATV_SetChannelProperty(unsigned int ms_timeout, FT_MATV_SET_CHANNEL_PROPERTY_REQ_T* req);
META_RESULT  __stdcall SP_META_MATV_SetChannelProperty_r(const int meta_handle, unsigned int ms_timeout, FT_MATV_SET_CHANNEL_PROPERTY_REQ_T* req);
META_RESULT  __stdcall SP_META_MATV_GetChannelQuality(unsigned int ms_timeout, unsigned short item, int *qualityindex);
META_RESULT  __stdcall SP_META_MATV_GetChannelQuality_r(const int meta_handle, unsigned int ms_timeout, unsigned short index, int *qualityindex);
META_RESULT  __stdcall SP_META_MATV_GetChannelQualityAll(unsigned int ms_timeout, FT_MATV_GET_CHANNEL_QUALITY_ALL_CNF_T* channel_quality);
META_RESULT  __stdcall SP_META_MATV_GetChannelQualityAll_r(const int meta_handle, unsigned int ms_timeout, FT_MATV_GET_CHANNEL_QUALITY_ALL_CNF_T* channel_quality);
META_RESULT  __stdcall SP_META_MATV_GetChipName(unsigned int ms_timeout, MATV_CHIPNAME_S * pChipName);
META_RESULT  __stdcall SP_META_MATV_GetChipName_r(const int meta_handle, unsigned int ms_timeout, MATV_CHIPNAME_S * pChipName);


//----------------------------------------------------------------//
//                              FM                                //
//----------------------------------------------------------------//

//--------------------------//
//    FM data structures    //
//--------------------------//
/*
typedef enum
{
    FM_CHIP_ID_MT6189AN = 0,
    FM_CHIP_ID_MT6189BN_CN = 1,
    FM_CHIP_ID_MT6188A = 3,
    FM_CHIP_ID_MT6188C = 4,
    FM_CHIP_ID_MT6188D = 5,
    FM_CHIP_ID_MT6616 = 6,
	FM_CHIP_ID_AR1000 = 7,
	FM_CHIP_ID_MT6620 = 8

}FM_CHIP_ID_E;
*/
typedef enum
{
  FM_CHIP_ID_MT6189AN = 0,
  FM_CHIP_ID_MT6189BN_CN = 1,
  FM_CHIP_ID_MT6188A = 3,
  FM_CHIP_ID_MT6188C = 4,
  FM_CHIP_ID_MT6188D = 5,
  FM_CHIP_ID_MT6616 = 6,
  FM_CHIP_ID_AR1000 = 7,
  FM_CHIP_ID_MT6620 = 8,
  FM_CHIP_ID_MT6626 = 9,
  FM_CHIP_ID_MT6628 = 10,
  FM_CHIP_ID_MT6627 = 11,
  FM_CHIP_ID_MT6630 = 12,
  FM_CHIP_ID_MT6580 = 13
}FM_CHIP_ID_E;

typedef struct{
    unsigned char pty;         // 0~31 integer
    unsigned char rds_rbds;    // 0:RDS, 1:RBDS
    unsigned char dyn_pty;     // 0:static, 1:dynamic
    unsigned short pi_code;    // 2-byte hex
    unsigned char ps_buf[8];     // hex buf of PS
    unsigned char ps_len;      // length of PS, must be 0 / 8"
    unsigned char af;          // 0~204, 0:not used, 1~204:(87.5+0.1*af)MHz
    unsigned char ah;          // Artificial head, 0:no, 1:yes
    unsigned char stereo;      // 0:mono, 1:stereo
    unsigned char compress;    // Audio compress, 0:no, 1:yes
    unsigned char tp;          // traffic program, 0:no, 1:yes
    unsigned char ta;          // traffic announcement, 0:no, 1:yes
    unsigned char speech;      // 0:music, 1:speech
}FM_RDS_TX_REQ_T;

typedef struct
{
    unsigned char  m_ucChipId;
}FM_CHIP_ID_CNF_T;

typedef struct
{
	short m_i2CurFreq;  // freq range is [875, 1080]
}FM_FREQ_REQ_T;



typedef struct
{
    //unsigned char m_ucSignalLevel;
	int m_ucSignalLevel;
}FM_RSSI_CNF_T;

typedef struct
{
	//unsigned char m_ucIfCnt;
	unsigned short m_u2IfCnt;
	
}FM_IF_CNT_CNF_T;

typedef struct
{
	unsigned short m_u2MonoOrStereo;  // 0: mono, 1: stereo
	unsigned short m_u2SblendOnOrOff; // 0: sblend off, 1: sblend on
	unsigned int   m_u4ItemValue;  // 0: disable, 1: enable

}FM_MONO_STEREO_BLEND_REQ_T;

typedef struct  // freq range is [875, 1080]
{
   short m_i2StartFreq;    // note: when we try to search next: start freq should <= stop freq 
   short m_i2StopFreq;     // note: when we try to search prev: start freq should >= stop freq

}FM_FREQ_RANGE_REQ_T;

typedef struct
{
	unsigned char m_ucExit;      // 0: don't exist, 1: exist
	short         m_i2ValidFreq; // -1: settings error, 0: invalid freq, others: 875-1080 valid

}FM_VAILD_FREQ_CNF_T;

typedef struct
{
   unsigned int m_u4RssiThreshold;

}FM_RSSI_THRESHOLD_REQ_T;

typedef struct
{
   unsigned int m_u4IfCntDelta;

}FM_IF_CNT_DELTA_REQ_T;


typedef struct
{
	unsigned char m_ucAddr;
	
}FM_READ_BYTE_ADDR_REQ_T;


typedef struct
{
   unsigned short m_u2ReadByte;

}FM_READ_BYTE_CNF_T;


typedef struct
{
	unsigned char m_ucAddr;
	unsigned short m_u2WriteByte;
}FM_WRITE_BYTE_REQ_T;

typedef struct
{
    unsigned char m_bOnOff;  // 0: off, 1: on

}FM_SOFT_MUTE_ONOFF_REQ_T;

typedef struct
{
	unsigned char m_ucStage;  // 1~3
}FM_STAGE_REQ_T;

typedef struct
{
	unsigned char  m_ucHighOrLow;
}FM_HL_Side_CNF_T;

typedef struct
{
	unsigned char m_ucStereoOrMono;

}FM_Stereo_Mono_CNF_T;

// for MT6616 new API
typedef struct
{
    unsigned char m_ucVolume;
    char m_cDigitalGainIndex;
}FM_Volume_Setting_REQ_T;

typedef struct
{
   // unsigned short m_u2Bitmap[16]; for 100KHz
	unsigned short m_u2Bitmap[26]; //for 50KHz
}FM_AutoScan_CNF_T;

typedef struct
{
    unsigned char m_ucRDSOn;
}FM_SetRDS_REQ_T;

typedef struct
{
    unsigned char m_ucRXFilterBW;
}FM_RX_FilterBW_CNF_T;

typedef struct
{
    unsigned char m_ucPAMDLevel;
}FM_PAMD_Level_CNF_T;

typedef struct
{
    unsigned char m_ucMR;
}FM_MR_CNF_T;

typedef struct
{
    unsigned int m_u4DecodeMode;
}FM_Decode_Mode_REQ_T;

typedef struct
{
    unsigned int m_u4HCC;
}FM_HCC_REQ_T;

typedef struct
{
    unsigned int m_u4PAMDThreshold;
}FM_PAMD_Threshold_REQ_T;

typedef struct
{
    unsigned int m_u4SoftmuteEnable;
}FM_Softmute_Enable_REQ_T;

typedef struct
{
    unsigned int m_u4DeemphasisLevel;
}FM_Deemphasis_Level_REQ_T;

typedef struct
{
	unsigned int m_u4HLSide;
}FM_HL_Side_REQ_T;

typedef struct
{
    unsigned int m_u4DemodBandwidth;
}FM_Demod_Bandwidth_REQ_T;

typedef struct
{
    unsigned int m_u4DynamicLimiter;
}FM_DynamicLimiter_REQ_T;

typedef struct
{
    unsigned int m_u4SoftmuteRate;
}FM_Softmute_Rate_REQ_T;

typedef enum
{
    RDS_CMD_NONE = 0,   // No command. This is usually an error.
    RDS_CMD_PI_CODE,
    RDS_CMD_PTY_CODE,
    RDS_CMD_PROGRAMNAME,
    RDS_CMD_LOCDATETIME,
    RDS_CMD_UTCDATETIME,
    RDS_CMD_LAST_RADIOTEXT,
    RDS_CMD_AF,
    RDS_CMD_AF_LIST,  
    RDS_CMD_AFON,
    RDS_CMD_TAON,
    RDS_CMD_TAON_OFF
}RdsCmd;

typedef enum
{
    RDS_FLAG_IS_TP              	              = 0x0001, // Program is a traffic program
    RDS_FLAG_IS_TA                            = 0x0002, // Program currently broadcasts a traffic ann.
    RDS_FLAG_IS_MUSIC                     = 0x0004, // Program currently broadcasts music
    RDS_FLAG_IS_STEREO                  = 0x0008, // Program is transmitted in stereo
    RDS_FLAG_IS_ARTIFICIAL_HEAD = 0x0010, // Program is an artificial head recording
    RDS_FLAG_IS_COMPRESSED       = 0x0020, // Program content is compressed
    RDS_FLAG_IS_DYNAMIC_PTY       = 0x0040, // Program type can change 
    RDS_FLAG_TEXT_AB                      = 0x0080  // If this flag changes state, a new radio text 					 string begins
}RdsFlag;

typedef enum {
   RDS_EVENT_FLAGS          = 0x0001, // One of the RDS flags has changed state
   RDS_EVENT_PI_CODE        = 0x0002, // The program identification code has changed
   RDS_EVENT_PTY_CODE       = 0x0004, // The program type code has changed
   RDS_EVENT_PROGRAMNAME    = 0x0008, // The program name has changed
   RDS_EVENT_UTCDATETIME    = 0x0010, // A new UTC date/time is available
   RDS_EVENT_LOCDATETIME    = 0x0020, // A new local date/time is available
   RDS_EVENT_LAST_RADIOTEXT = 0x0040, // A radio text string was completed
   RDS_EVENT_AF                   = 0x0080, // Current Channel RF signal strength too weak, need do AF switch  
   RDS_EVENT_AF_LIST        = 0x0100, // An alternative frequency list is ready
   RDS_EVENT_AFON_LIST        = 0x0200, // An alternative frequency list is ready
   RDS_EVENT_TAON        = 0x0400,  // Other Network traffic announcement start
   RDS_EVENT_TAON_OFF        = 0x0800 // Other Network traffic announcement finished.
} RdsEvent;

typedef struct
{
    RdsCmd m_eCmd;
}FM_RDS_Info_REQ_T;

typedef struct
{
    unsigned char m_buffer[64];
}FM_RDS_Info_CNF_T;

typedef struct
{
    RdsFlag m_eFlag;
    unsigned char m_buffer[64];
}FM_RDS_Status_CNF_T;

typedef struct  
{
	char TP;
	char TA;
	char Music;
	char Stereo;
	char Artificial_Head;
	char Compressed;
	char Danamic_PTY;
	char Text_AB;
	int falg_status;
}RDSFlag_Struct;

typedef struct
{
        unsigned short Month;
        unsigned short Day;
        unsigned short Year;
        unsigned short Hour;
        unsigned short Minute;
        unsigned char Local_Time_offset_signebit;
        unsigned char Local_Time_offset_half_hour;
}CT_Struct;

typedef struct
{
    unsigned short m_u2GoodBlock;
}FM_RDS_Good_Block_Counter_CNF_T;

typedef struct
{
    unsigned short m_u2BadBlock;
}FM_RDS_Bad_Block_Counter_CNF_T;

/*
typedef struct
{
    unsigned short m_u2GroupCounter[32];
}FM_RDS_Group_Counter_CNF_T;
*/

typedef struct
{
    short m_i2StartFreq;
    unsigned char m_ucDirection;
}FM_HWSeek_REQ_T;

typedef struct
{
    short m_i2EndFreq;
}FM_HWSeek_CNF_T;


typedef struct
{
    unsigned short m_u2StereoBlendControl;
}FM_SetStereoBlend_REQ_T;

/*
typedef struct
{
    unsigned short m_u2Blocks[5];
}FM_RDS_Block_CNF_T;
*/


typedef struct  
{
	unsigned short DECODE_MODE;
	unsigned short STEREO_BLEND;
	unsigned short HCC;
	unsigned short PAMD_THRESHOLD;
	unsigned short RSSI_THRESHOLD;
	unsigned short SOFTMUTE;
	unsigned short COSTAS;
	unsigned short DE_EMPHASIS_LEV;
	unsigned short HL_SIDE;
	unsigned short DEMOD_BANDWIDTH;
	unsigned short DYNAMIC_LIMITER;
	unsigned short SOFTMUTE_RATE;
	unsigned short AFC;
	unsigned short SET_BW;
	unsigned short CAP_ARRAY;
	unsigned short DEMOD_TYPE;
}FM_SETStatus_REQ_T;

typedef struct  
{
	unsigned short RSSI;               //RSSI
	unsigned short RSSI_HEX;           //RSSI(Hex)
	unsigned short RSSI_DBM;            //
	unsigned short STA_BW;              //BW
	unsigned short PAMD;
	unsigned short PAMD_HEX;
	unsigned short PAMD_DBM;
	unsigned short MR;
	unsigned short STEREO_MONO;			//Stereo/Mono
	unsigned short BLEND_GAIN;			//Blend gain
	unsigned short BLEND_FILTER_NUMBER; //Blend filter number
	unsigned short SOFTMUTE_GMS;
	unsigned short SOFTMUTE_GFS;
	unsigned short DYNAMIC_GAIN;
	unsigned short PILOT_LOCKED_FLAG;
	unsigned short SOFTMUTE_SELECTION_FLAG;
	unsigned short RSSI_HCC;
	unsigned short PAMD_HCC;
	unsigned short RSSI_OFF_B;
	unsigned short RSSI_OFF_H;
	unsigned short PAMD_OFF_B;
	unsigned short PAMD_OFF_H;
	unsigned short HCC_FILTER;
	unsigned short SOFTMUTE_STEP;
	unsigned short GAIN_COUNTER;
	unsigned short PGA_GAIN;
	unsigned short LNA_GAIN;
	unsigned short PGA_GAIN_INDEX;
	unsigned short LNA_GAIN_INDEX;
	unsigned short TOTAL_GAIN;
	unsigned short PULSE_RATIO;
	unsigned short FAST_PAMD;
	unsigned short POWER_DETECTOR;
	unsigned short CHIP_ID;
}FM_Status_CNF_T;

//--------------------------//
//      FM Functions        //
//--------------------------//

META_RESULT  __stdcall SP_META_FM_SetRDSTX(unsigned int ms_timeout,FM_RDS_TX_REQ_T req );
META_RESULT  __stdcall SP_META_FM_SetRDSTX_r(const int meta_handle, unsigned int ms_timeout,FM_RDS_TX_REQ_T req);
META_RESULT  __stdcall SP_META_FM_SetStatus(unsigned int ms_timeout, char * fileName,FM_SETStatus_REQ_T req);
META_RESULT  __stdcall SP_META_FM_SetStatus_r(const int meta_handle, unsigned int ms_timeout, char * fileName,FM_SETStatus_REQ_T req);
META_RESULT  __stdcall SP_META_FM_GetStatus( unsigned int ms_timeout, char * fileName,FM_Status_CNF_T* cnf);
META_RESULT  __stdcall SP_META_FM_GetStatus_r(const int meta_handle, unsigned int ms_timeout, char * fileName,FM_Status_CNF_T* cnf);
META_RESULT  __stdcall SP_META_FM_GetChipId(unsigned int ms_timeout, FM_CHIP_ID_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetChipId_r(const int meta_handle, unsigned int ms_timeout, FM_CHIP_ID_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_PowerOn(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_PowerOn_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_TXPowerOn(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_TXPowerOn_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_PowerOff(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_PowerOff_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_TxSetFreq(unsigned int ms_timeout, FM_FREQ_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_TxSetFreq_r(const int meta_handle,unsigned int ms_timeout, FM_FREQ_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetFreq(unsigned int ms_timeout, FM_FREQ_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetFreq_r(const int meta_handle, unsigned int ms_timeout, FM_FREQ_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_GetRSSI(unsigned int ms_timeout, FM_FREQ_REQ_T *req, FM_RSSI_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetRSSI_r(const int meta_handle, unsigned int ms_timeout, FM_FREQ_REQ_T *req, FM_RSSI_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetIfCnt(unsigned int ms_timeout, FM_FREQ_REQ_T *req, FM_IF_CNT_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetIfCnt_r(const int meta_handle, unsigned int ms_timeout, FM_FREQ_REQ_T *req, FM_IF_CNT_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_SearchNextFreq(unsigned int ms_timeout, FM_FREQ_RANGE_REQ_T *req, FM_VAILD_FREQ_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_SearchNextFreq_r(const int meta_handle, unsigned int ms_timeout, FM_FREQ_RANGE_REQ_T *req, FM_VAILD_FREQ_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_SearchPrevFreq(unsigned int ms_timeout, FM_FREQ_RANGE_REQ_T *req, FM_VAILD_FREQ_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_SearchPrevFreq_r(const int meta_handle, unsigned int ms_timeout, FM_FREQ_RANGE_REQ_T *req, FM_VAILD_FREQ_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_SetMonoOrStereo_Blend(unsigned int ms_timeout, FM_MONO_STEREO_BLEND_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetMonoOrStereo_Blend_r(const int meta_handle, unsigned int ms_timeout, FM_MONO_STEREO_BLEND_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetRssiThreold(unsigned int ms_timeout, FM_RSSI_THRESHOLD_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetRssiThreold_r(const int meta_handle, unsigned int ms_timeout, FM_RSSI_THRESHOLD_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetIfCntDelta(unsigned int ms_timeout, FM_IF_CNT_DELTA_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetIfCntDelta_r(const int meta_handle, unsigned int ms_timeout, FM_IF_CNT_DELTA_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_ReadByte(unsigned int ms_timeout, FM_READ_BYTE_ADDR_REQ_T *req, FM_READ_BYTE_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_ReadByte_r(const int meta_handle, unsigned int ms_timeout, FM_READ_BYTE_ADDR_REQ_T *req, FM_READ_BYTE_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_WriteByte(unsigned int ms_timeout, FM_WRITE_BYTE_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_WriteByte_r(const int meta_handle, unsigned int ms_timeout, FM_WRITE_BYTE_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetSoftMute(unsigned int ms_timeout, FM_SOFT_MUTE_ONOFF_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetSoftMute_r(const int meta_handle, unsigned int ms_timeout, FM_SOFT_MUTE_ONOFF_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SelectSoftMuteStage(unsigned int ms_timeout, FM_STAGE_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SelectSoftMuteStage_r(const int meta_handle, unsigned int ms_timeout, FM_STAGE_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SelectSBlendStage(unsigned int ms_timeout, FM_STAGE_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SelectSBlendStage_r(const int meta_handle, unsigned int ms_timeout, FM_STAGE_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_GetHighOrLowSide(unsigned int ms_timeout, FM_FREQ_REQ_T *req, FM_HL_Side_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetHighOrLowSide_r(const int meta_handle, unsigned int ms_timeout, FM_FREQ_REQ_T *req, FM_HL_Side_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetStereoOrMono(unsigned int ms_timeout, FM_Stereo_Mono_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetStereoOrMono_r(const int meta_handle, unsigned int ms_timeout, FM_Stereo_Mono_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_SetVolume(unsigned int ms_timeout, FM_Volume_Setting_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetVolume_r(const int meta_handle, unsigned int ms_timeout, FM_Volume_Setting_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_AutoScan(unsigned int ms_timeout, FM_AutoScan_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_AutoScan_r(const int meta_handle, unsigned int ms_timeout, FM_AutoScan_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_SetRDS(unsigned int ms_timeout, FM_SetRDS_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetRDS_r(const int meta_handle, unsigned int ms_timeout, FM_SetRDS_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_GetRXFilterBW(unsigned int ms_timeout, FM_RX_FilterBW_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetRXFilterBW_r(const int meta_handle, unsigned int ms_timeout, FM_RX_FilterBW_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetPAMDLevel(unsigned int ms_timeout, FM_FREQ_REQ_T *req, FM_PAMD_Level_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetPAMDLevel_r(const int meta_handle, unsigned int ms_timeout, FM_FREQ_REQ_T* req, FM_PAMD_Level_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetMR(unsigned int ms_timeout, FM_MR_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetMR_r(const int meta_handle, unsigned int ms_timeout, FM_MR_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_SetDecodeMode(unsigned int ms_timeout, FM_Decode_Mode_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetDecodeMode_r(const int meta_handle, unsigned int ms_timeout, FM_Decode_Mode_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetHCC(unsigned int ms_timeout, FM_HCC_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetHCC_r(const int meta_handle, unsigned int ms_timeout, FM_HCC_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetPAMDThreshold(unsigned int ms_timeout, FM_PAMD_Threshold_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetPAMDThreshold_r(const int meta_handle, unsigned int ms_timeout, FM_PAMD_Threshold_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_YUSU_SetSoftmute(unsigned int ms_timeout, FM_Softmute_Enable_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_YUSU_SetSoftmute_r(const int meta_handle, unsigned int ms_timeout, FM_Softmute_Enable_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetDeemphasisLevel(unsigned int ms_timeout, FM_Deemphasis_Level_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetDeemphasisLevel_r(const int meta_handle, unsigned int ms_timeout, FM_Deemphasis_Level_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetHLSide(unsigned int ms_timeout, FM_HL_Side_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetHLSide_r(const int meta_handle, unsigned int ms_timeout, FM_HL_Side_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetDemodBW(unsigned int ms_timeout, FM_Demod_Bandwidth_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetDemodBW_r(const int meta_handle, unsigned int ms_timeout, FM_Demod_Bandwidth_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetDynamicLimiter(unsigned int ms_timeout, FM_DynamicLimiter_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetDynamicLimiter_r(const int meta_handle, unsigned int ms_timeout, FM_DynamicLimiter_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetSoftmuteRate(unsigned int ms_timeout, FM_Softmute_Rate_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_SetSoftmuteRate_r(const int meta_handle, unsigned int ms_timeout, FM_Softmute_Rate_REQ_T *req);
META_RESULT  __stdcall SP_META_FM_GetPI(unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetPI_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetPTY(unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetPTY_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetPS(unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetPS_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetAF(unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetAF_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetRT(unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetRT_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Info_REQ_T *req, FM_RDS_Info_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetTP(unsigned int ms_timeout, FM_RDS_Status_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetTP_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Status_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetTA(unsigned int ms_timeout, FM_RDS_Status_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetTA_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Status_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetMS(unsigned int ms_timeout, FM_RDS_Status_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetMS_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Status_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetGoodBlockCounter(unsigned int ms_timeout, FM_RDS_Good_Block_Counter_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetGoodBlockCounter_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Good_Block_Counter_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetBadBlockCounter(unsigned int ms_timeout, FM_RDS_Bad_Block_Counter_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_GetBadBlockCounter_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_Bad_Block_Counter_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_ResetBlockCounter(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_ResetBlockCounter_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_ResetGroupCounter(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_ResetGroupCounter_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_HWSeek(unsigned int ms_timeout, FM_HWSeek_REQ_T *req, FM_HWSeek_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_HWSeek_r(const int meta_handle, unsigned int ms_timeout, FM_HWSeek_REQ_T *req, FM_HWSeek_CNF_T *cnf);
META_RESULT  __stdcall SP_META_FM_HWSearch_Stop(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_HWSearch_Stop_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_SetStereoBlend(unsigned int ms_timeout, FM_SetStereoBlend_REQ_T* req);
META_RESULT  __stdcall SP_META_FM_SetStereoBlend_r(const int meta_handle, unsigned int ms_timeout, FM_SetStereoBlend_REQ_T* req);


//New API using workflow
typedef enum
{
	FMTX_1K_TONE = 1, 
	FMTX_2K_TONE = 2,
	FMTX_3K_TONE = 3,
	FMTX_4K_TONE = 4,
	FMTX_5K_TONE = 5,
	FMTX_6K_TONE = 6,
	FMTX_7K_TONE = 7,
	FMTX_8K_TONE = 8,
	FMTX_9K_TONE = 9,
	FMTX_10K_TONE = 10,
	FMTX_11K_TONE = 11,
	FMTX_12K_TONE = 12,
	FMTX_13K_TONE = 13,
	FMTX_14K_TONE = 14,
	FMTX_15K_TONE = 15,
	FMTX_MAX_TONE
	
}FM_TX_TONE_T;

typedef enum
{
	FM_TX_AUDIO_ANALOG = 0,
	FM_TX_AUDIO_I2S = 1,
	FM_RX_AUDIO_ANALOG = 2,
	FM_RX_AUDIO_I2S = 3,
	FM_AUDIO_MAX
	
}FM_TX_AUDIO_PATH_T;

typedef enum
{
	FM_ANA_LONG = 0,
	FM_ANA_SHORT=1,
	FM_ANA_MAX
	
}FM_ANA_T;


typedef struct
{
	FM_TX_AUDIO_PATH_T m_audioPath;
	
}FM_SetTxAudioPath_REQ_T;

typedef struct
{
	FM_TX_TONE_T m_audioFreq;
	
}FM_SetTxAudioFreq_REQ_T;


#define MAX_RDS_LOGDATA_LEN 256

typedef struct
{
	unsigned int dataLen;
	char data[MAX_RDS_LOGDATA_LEN];
	
} FM_RDS_LOGDATA_T;

typedef struct
{
    unsigned long total;
    unsigned long groupA[16]; //RDS groupA counter
    unsigned long groupB[16]; //RDS groupB counter
    
} FM_RDS_GROUPCOUNTER_T;

typedef struct
{
    int ana;
}FM_SetAntenna_REQ_T;

typedef struct
{
    int m_uCapArray;
}FM_CapArray_CNF_T;


typedef struct
{
	int  m_i4Step;
}FM_STEP_MODE_CNF_T;



META_RESULT  __stdcall SP_META_FM_SetTxAudioPath(unsigned int ms_timeout, FM_SetTxAudioPath_REQ_T path);
META_RESULT  __stdcall SP_META_FM_SetTxAudioPath_r(const int meta_handle, unsigned int ms_timeout, FM_SetTxAudioPath_REQ_T path);
META_RESULT  __stdcall SP_META_FM_SetTxAudioFreq(unsigned int ms_timeout, FM_SetTxAudioFreq_REQ_T freq);
META_RESULT  __stdcall SP_META_FM_SetTxAudioFreq_r(const int meta_handle, unsigned int ms_timeout, FM_SetTxAudioFreq_REQ_T freq);
META_RESULT  __stdcall SP_META_FM_GetRDSLogData(unsigned int ms_timeout, FM_RDS_LOGDATA_T * pCnf);
META_RESULT  __stdcall SP_META_FM_GetRDSLogData_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_LOGDATA_T * pCnf);
META_RESULT  __stdcall SP_META_FM_GetRDSBlerRatio(unsigned int ms_timeout, unsigned short * pBler);
META_RESULT  __stdcall SP_META_FM_GetRDSBlerRatio_r(const int meta_handle, unsigned int ms_timeout, unsigned short * pBler);
META_RESULT  __stdcall SP_META_FM_GetRDSGroupCounter(unsigned int ms_timeout, FM_RDS_GROUPCOUNTER_T * pCnf);
META_RESULT  __stdcall SP_META_FM_GetRDSGroupCounter_r(const int meta_handle, unsigned int ms_timeout, FM_RDS_GROUPCOUNTER_T * pCnf);
META_RESULT  __stdcall SP_META_FM_SetAntenna(unsigned int ms_timeout, FM_SetAntenna_REQ_T * pReq);
META_RESULT  __stdcall SP_META_FM_SetAntenna_r(const int meta_handle, unsigned int ms_timeout, FM_SetAntenna_REQ_T * pReq);
META_RESULT  __stdcall SP_META_FM_GetCapArray(unsigned int ms_timeout, FM_CapArray_CNF_T * pCnf);
META_RESULT  __stdcall SP_META_FM_GetCapArray_r(const int meta_handle, unsigned int ms_timeout, FM_CapArray_CNF_T * pCnf);
META_RESULT  __stdcall SP_META_FM_GetStepMode(unsigned int ms_timeout, FM_STEP_MODE_CNF_T * pCnf);
META_RESULT  __stdcall SP_META_FM_GetStepMode_r(const int meta_handle, unsigned int ms_timeout, FM_STEP_MODE_CNF_T * pCnf);




typedef void (__stdcall *WM_META_FM_RDS_INFO_UPDATE_CNF)(const FM_RDS_Info_CNF_T *cnf, const short token, void *usrData);
typedef void (__stdcall *WM_META_FM_RDS_STATUS_UPDATE_CNF)(const FM_RDS_Status_CNF_T *cnf, const short token, void *usrData);
typedef struct
{
	WM_META_FM_RDS_INFO_UPDATE_CNF m_RDSInfoUpdateCallback;
	WM_META_FM_RDS_STATUS_UPDATE_CNF m_RDSStatusUpdateCallback;
} FM_RDSCallBack;

META_RESULT  __stdcall SP_META_FM_RegisterRDSInfoUpdateCallback(WM_META_FM_RDS_INFO_UPDATE_CNF cb);
META_RESULT  __stdcall SP_META_FM_RegisterRDSInfoUpdateCallback_r(const int meta_handle, WM_META_FM_RDS_INFO_UPDATE_CNF cb);
META_RESULT  __stdcall SP_META_FM_RegisterRDSStatusUpdateCallback(WM_META_FM_RDS_STATUS_UPDATE_CNF cb);
META_RESULT  __stdcall SP_META_FM_RegisterRDSStatusUpdateCallback_r(const int meta_handle, WM_META_FM_RDS_STATUS_UPDATE_CNF cb);
META_RESULT  __stdcall SP_META_FM_RemoveRDSInfoUpdateCallback(void);
META_RESULT  __stdcall SP_META_FM_RemoveRDSInfoUpdateCallback_r(const int meta_handle);
META_RESULT  __stdcall SP_META_FM_RemoveRDSStatusUpdateCallback(void);
META_RESULT  __stdcall SP_META_FM_RemoveRDSStatusUpdateCallback_r(const int meta_handle);

// FM Audio Test
META_RESULT  __stdcall SP_META_FM_AudioTest(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_FM_AudioTest_r(const int meta_handle, unsigned int ms_timeout);


//----------------------------------------------------------------//
//                            TDMB                                //
//----------------------------------------------------------------//

//--------------------------//
//    TDMB data structures  //
//--------------------------//

typedef enum {   // ref from TDMB
   META_TDMB_KOREA_BAND=1,
   META_TDMB_BAND_III,
   META_TDMB_L_BAND,
   META_TDMB_CANADA_BAND,
   META_TDMB_CHINESE_BAND,
   META_TDMB_BAND_II,
   META_TDMB_BAND_IF,
   META_TDMB_UNDEF_BAND
} META_TDMB_BAND_enum;

typedef struct
{
    META_TDMB_BAND_enum  m_rBand;
	
}TDMB_SET_BAND_REQ_T;

typedef struct
{
   unsigned int  m_u4Freq;
}TDMB_SET_FREQ_REQ_T;



typedef struct
{
	unsigned char m_ucFreqNum;
	unsigned int m_u4Freq[10];
   
}TDMB_AUTO_SCAN_CNF_T;

// ========  for Ensemble ========


typedef struct
{
	//TDMB_DBSTATE	   DB;
	unsigned char        m_ucStateNum;
	unsigned int		 m_u4State[10];


	unsigned int		Type;   //DMB,DAB,DATA
	unsigned int		Id;
	unsigned int		BitRate;
	unsigned char		PL; //Protection Level
	unsigned char		Reg[8];
	unsigned short		UserApplType;		// added by KST 2006.07.20

	unsigned int		TMId;
	unsigned int		ASCTy_DSCTy;
	unsigned int		SCId;
	unsigned int		PackAdd;
	unsigned int		DG_MFflag;
	unsigned int		Primary;
	unsigned int		CAflag;
	unsigned int		Language;
	char				SCLabel[16];
 
	//TDMB_SvcComponentInfo	 *pSvcComp;
	unsigned char		SvcComp_Order;			// 4bits
	unsigned char		SvcComp_TMId;			// 2bits	Transport Mechanism Id
	unsigned char		SvcComp_ASCTy_DSCTy;	// 6bits	Audio Service Component Type	
	unsigned char		SvcComp_SubCh_FIDCId;	// 6bits	SubChId or FIDCId in FIG 0/4
	unsigned int		SvcComp_SId;			// 16bit
	unsigned char		SvcComp_CAflag;			// 1bit		CA Flag
	unsigned char		SvcComp_DG_MFflag;		// 1bit		DG Flag or MF flag
	unsigned char		SvcComp_Language;		// 8bit
	unsigned char		SvcComp_SCIdS;			// 4bit		Service component Identifier within ther Service
	unsigned char       SvcComp_SvcCompLabel[16];// 16bytes Service component Label	

	unsigned short		SvcComp_SCId;			// 12bits	Service Component Id
	unsigned short		SvcComp_PackAdd;		// 10bits	Packet Address
	unsigned short		SvcComp_SCCA;			// 16bits	Service Component Conditional Access

	unsigned short      SvcComp_m_encoded_id;   // Only for Frontier
    unsigned char       SvcComp_m_sif;          // Only for Frontier	


	//TDMB_SubChInfo			 *pSubCh;
	unsigned char	    SubChId;		// 6bits	Sub channel Id
	unsigned char	    TblIndex;		// 6bits	TableIndex
	unsigned char	    Form_Opt_Prot;  //[3] : FormFlag   //[2] : Option//[1~0] : protection
	unsigned short	    StrtAdd;		// 10bits	Start Address
	unsigned short	    SubChSize;		// 10bits	Sub channel size

	unsigned int		Tag;

}TDMB_CHANNELDB_T;


typedef struct
{
	// TDMB_DBSTATE
	unsigned char       m_ucStateNum;
	unsigned int		m_u4State[10];

	unsigned int		Id;
	char				Label[20];

	//TDMB_ServiceInfo  *pService;
	unsigned int		SId;			// 32bits	
	unsigned char		SvcLabel[16];	// 16bytes	Service Label(Program service and Data service)
	unsigned short		CharacterFlag;
	unsigned char		CAId;			// 3bit
	unsigned char		NumSvcComp;		// 4bits	Number of Service Component	


	//TDMB_CHANNELDB		*Channel;
    unsigned char     m_ucChannelDBNum;
	TDMB_CHANNELDB_T  m_rChannelDB[10];


	//struct _TDMB_SERVICEDB	*Next;
	unsigned int				Tag;
	unsigned int			ChannelCount;


}TDMB_SERVICEDB_T; 

typedef struct
{
	// TDMB_DBSTATE
	unsigned char        m_ucStateNum;
	unsigned int		 m_u4State[10];

	unsigned int		 Band;
    unsigned int		 Frequency;
    unsigned short		 Id;
    unsigned int		 SvcNum;
    unsigned int		 SvcCompNum;
    unsigned int		 SubChNum;
	char				 Label[20];

	// TDMB_EnsembleInfo
	unsigned char	AlFlag;				// 1bit		Al flag
	unsigned char   NumSubCh;
	unsigned char   NumSvc;
	unsigned char	NumProgram;
	unsigned char   NumSvcComp;
	unsigned char	NumUserApp;
	unsigned char	NumAnn;
	unsigned char	NumProgType;
	unsigned char	EnsemLabel[16];		// 16bytes	Ensemble Label
	unsigned short  CharacterFlag;
	unsigned short	EId;				// 16bits	country Id Ensemble reference

	// TDMB_SERVICEDB[]
	unsigned char   m_ucServiceDBNum;
	TDMB_SERVICEDB_T  m_rServiceDB[10];

	unsigned int     Tag;

}TDMB_ENSEMBLEDB_T;


typedef struct   // for META APP
{
   unsigned char      m_ucEnsembleNum;
   TDMB_ENSEMBLEDB_T  m_rEnsembleDB[10];

}TDMB_GET_ENSM_INFO_BY_AUTO_SCAN_CNF_T;

typedef struct   // for META APP
{
	char m_cResult; // 0: success, 
	                // 1: the band not exist  ==> META_TDMB_ERR_BAND_NOT_EXIST
	                // 2: frequency not exist ==> META_TDMB_ERR_FREQ_NOT_EXIST

	unsigned char      m_ucEnsembleNum;
    TDMB_ENSEMBLEDB_T  m_rEnsembleDB[10];
	TDMB_ENSEMBLEDB_T  m_rCurEnsembleDB;

}TDMB_SET_FREQ_CNF_T;


typedef struct
{
	unsigned short m_u2Snr;
	unsigned char  m_ucBer_a;  // a.b*10^-c
	unsigned char  m_ucBer_b;
	unsigned char  m_ucBer_c;
	short          m_i2RSSI; 

}TDMB_GET_SIGNAL_CNF_T;

typedef struct
{
	unsigned int m_u4ServiceId;
	unsigned int m_u4SubChnId;
	char         *m_pcfilepath; // store the TS stream data to this file 

}TDMB_SEL_SERVICE_REQ_T;

typedef struct  
{
	unsigned int m_u4ServiceId;
	unsigned int m_u4SubChnId;

}TDMB_SEL_SERVICE_ONLY_REQ_T;



typedef struct  //  for Meta APP only
{
	unsigned char      m_ucEnsembleNum;
    TDMB_ENSEMBLEDB_T  m_rEnsembleDB[10];
	TDMB_ENSEMBLEDB_T  m_rCurEnsembleDB;

}TDMB_GET_ENSM_CNF_T;
// --------------------------//
//      TDMB callback        //
// --------------------------//
typedef enum
{
    TDMB_FAT_DISK_FULL = 0
   ,TDMB_FAT_UNKNOWN_WRITE_ERROR
   ,TDMB_MED_MEMORY_FULL
   ,TDMB_MED_MEMORY_NOT_EXIST

}TDMB_SEL_SERV_ERROR_RESULT;

typedef void (__stdcall *META_TDMB_SEL_SERV_CNF)(const TDMB_SEL_SERV_ERROR_RESULT status);


/*
//----------------------------------------------------------------------------------//
//  WM_MetaTest: data structure definition
//-----------------------------------------------------------------------------------//
//  WM_CMD_SUM
#define SIZE_ARRAY_NTEST_WM_CMD_SUM_REQ_T	10
typedef struct 
{
	short	nTest[SIZE_ARRAY_NTEST_WM_CMD_SUM_REQ_T];
}WM_CMD_SUM_REQ_T;

typedef struct 
{
	short	nTestSum;
}WM_CMD_SUM_CNF_T;

//	WM_CMD_Query_If_Target_Support_DVBH
typedef struct 
{
	 short	notUsed;
}WM_CMD_Query_If_Target_Support_DVBH_REQ_T;

typedef struct 
{
	  bool		bSupportDVBH;
}WM_CMD_Query_If_Target_Support_DVBH_CNF_T;

  //WM_CMD_Active_Timer
typedef struct
{
	   unsigned int		nMsTimer;
}WM_CMD_Active_Timer_REQ_T;

typedef struct 
{
	   unsigned int		nRecNum;
	   unsigned int		nMs;
}WM_CMD_Active_Timer_CNF_T;

typedef enum{
	FILE_START = 0,
	FILE_ONGOING,
	FILE_CLOSE,
	FILE_ONCE
}WM_METATEST_FILE_OP_TYPE;

typedef struct{
	unsigned int	nReqWriteFileStatus;
}WM_CMD_WriteFile_REQ_T;

typedef struct{
	unsigned int	nCnfWriteFileStatus;
}WM_CMD_WriteFile_CNF_T;

typedef struct{
	unsigned int	nReqReadFileStatus;
}WM_CMD_ReadFile_REQ_T;

typedef struct{
	unsigned int	nCnfReadFileStatus;
}WM_CMD_ReadFile_CNF_T;


// ---------------------------------------------
//      WM_MetaTest: callback        
// ----------------------------------------------

typedef enum
{
    WM_CMD_SUM_SUCESS = 0
   ,WM_CMD_SUM_FAIL 
}WM_MetaTest_RESULT;
//------------------------------------------
//WM_MetaTest: export function definition
//-----------------------------------------
META_RESULT  __stdcall META_WmMetaTest_Sum(unsigned int  ms_timeout, WM_CMD_SUM_REQ_T *req, WM_CMD_SUM_CNF_T *cnf);
META_RESULT  __stdcall META_WmMetaTest_Sum_r(const int meta_handle,unsigned int  ms_timeout, WM_CMD_SUM_REQ_T *req, WM_CMD_SUM_CNF_T *cnf);
META_RESULT  __stdcall META_WmMetaTest_QueryIfTargetSupportDVBH(unsigned int  ms_timeout, WM_CMD_Query_If_Target_Support_DVBH_REQ_T *req, WM_CMD_Query_If_Target_Support_DVBH_CNF_T *cnf);
META_RESULT  __stdcall META_WmMetaTest_QueryIfTargetSupportDVBH_r(const int meta_handle,unsigned int  ms_timeout, WM_CMD_Query_If_Target_Support_DVBH_REQ_T *req, WM_CMD_Query_If_Target_Support_DVBH_CNF_T *cnf);
META_RESULT  __stdcall META_WmMetaTest_ActiveTimer(unsigned int  ms_timeout, WM_CMD_Active_Timer_REQ_T *req, WM_CMD_Active_Timer_CNF_T *cnf);
META_RESULT  __stdcall META_WmMetaTest_ActiveTimer_r(const int meta_handle,unsigned int  ms_timeout, WM_CMD_Active_Timer_REQ_T *req, WM_CMD_Active_Timer_CNF_T *cnf);
META_RESULT  __stdcall META_WmMetaTest_WriteFile(unsigned int  ms_timeout, WM_CMD_WriteFile_REQ_T *req, WM_CMD_WriteFile_CNF_T *cnf);
META_RESULT  __stdcall META_WmMetaTest_WriteFile_r(const int meta_handle,unsigned int  ms_timeout, WM_CMD_WriteFile_REQ_T *req, WM_CMD_WriteFile_CNF_T *cnf);
META_RESULT  __stdcall META_WmMetaTest_ReadFile(unsigned int  ms_timeout, WM_CMD_ReadFile_REQ_T *req, WM_CMD_ReadFile_CNF_T *cnf);
META_RESULT  __stdcall META_WmMetaTest_ReadFile_r(const int meta_handle,unsigned int  ms_timeout, WM_CMD_ReadFile_REQ_T *req, WM_CMD_ReadFile_CNF_T *cnf);
*/

//-----------------------------------------------------//
//  WM META UnitTest
//-----------------------------------------------------//

typedef struct {
	unsigned int	m_TestCaseID;
	const char *	m_pDescription;
} WM_META_UT_TestCaseID_T;

void __stdcall SP_META_QueryTestCase(WM_META_UT_TestCaseID_T  **ppTestCase, unsigned int  *pTestCaseCount);
void __stdcall SP_META_UnitTest(const unsigned int  *p_TestCaseID_Array, unsigned int  TestCaseCount);


// --------------------------------------------------------------------------------
//      WM_Battery:    data structure definition     addey by yuying 2008-12-18     
// --------------------------------------------------------------------------------
typedef enum{
	FILE_START,
	FILE_ONGOING,
	FILE_CLOSE,
	FILE_ONCE
}WM_Bat_Image_OP_TYPE;

typedef enum{
	FILE_Success,
	FILE_Fail
}WM_Bat_File_Err_TYPE;

 typedef enum{
  WM_BAT_WRITE_DATA=0,
  WM_BAT_COMPARA_DATA,
  WM_BAT_DELAY
}WM_BAT_Upload_OP_TYPE;

typedef struct{
	int				nReqDLImageStatus;
	unsigned int		image_size;  //the size of whole image
	unsigned int		block_size;  //the size of current transfer.
}WM_Bat_DLImage_REQ_T;

typedef struct{
	int	nCnfDLImageStatus;
	int    DL_Status;		//0-success 1-failed
}WM_Bat_DLImage_CNF_T;

typedef struct{
	//int	nReqUPImageStatus;
	WM_Bat_Image_OP_TYPE	nReqStartStatus;
 	WM_BAT_Upload_OP_TYPE 	nReqUpdateOpStatus;
  	char  					StartAddress;		
  	unsigned short 			delaytime;
	unsigned short			nLen;
	char					Buf[96];
}WM_Bat_UPImage_REQ_T;

typedef struct{
	WM_Bat_Image_OP_TYPE	nCnfStartStatus;	//0-first 1-
	int	nCnfUpdateStatus;  //0-success 1-fail
}WM_Bat_UPImage_CNF_T;


//export function

//META_RESULT  __stdcall META_Battery_UploadImage(unsigned int ms_timeout, const WM_Bat_UPImage_REQ_T *req, WM_Bat_UPImage_CNF_T *cnf,char* fileAddress);
//META_RESULT  __stdcall META_Battery_UploadImage_r(const int meta_handle,unsigned int ms_timeout, const WM_Bat_UPImage_REQ_T *req, WM_Bat_UPImage_CNF_T *cnf, char* fileAddress);



// --------------------------------------------------------------------------------
//      WM_Battery:    data structure definition
// --------------------------------------------------------------------------------

// 0  WM_CMD_DVB_Connect

typedef struct
{
	unsigned int Frequency;
	unsigned int BandWidth;
}DVB_CONNECT_REQ;

typedef struct
{
	int           drv_status;
}DVB_CONNECT_CNF;	

// 1  WM_CMD_DVB_Disconnect

typedef struct
{
	unsigned int NotUsed;
}DVB_DISCONNECT_REQ;

typedef struct{
	int           drv_status;
}DVB_DISCONNECT_CNF;

// 2 WM_CMD_DVB_Middleware_Update

typedef struct
{
	int 			FileStatus;
	unsigned int 	ImageSize;
	unsigned int 	BrockSize;
}DVB_MIDDLEWARE_UPDATE_REQ;

typedef struct
{
	int 	FileStatus;
	int		drv_status;
}DVB_MIDDLEWARE_UPDATE_CNF;


// 3 WM_CMD_DVB_Parameter_Calibration
typedef struct
{
	unsigned int NotUsed;
}DVB_PARAMETER_CALIBRATION_REQ;

typedef struct
{
	int           drv_status;
}DVB_PARAMETER_CALIBRATION_CNF;

// 4  WM_CMD_DVB_Get_Signal_Quality

typedef struct
{
	unsigned int NotUsed;
}DVB_GET_SIGNALQUALITY_REQ;

typedef struct
{
	unsigned char	SNRValue;
	char			Strength;
	unsigned int	TSPER;
	unsigned int	PostVBER;
	int				drv_status;
}DVB_GET_SIGNALQUALITY_CNF;

// 5  WM_CMD_DVB_Demodulator_IsAlive

typedef struct
{
	unsigned int NotUsed;
}DVB_DEMODULATOR_ISALIVE_REQ;

typedef struct
{
	int           drv_status;
}DVB_DEMODULATOR_ISALIVE_CNF;

// 6  WM_CMD_DVB_Set_TS_PacketBatch

typedef struct
{
	unsigned int BatchNum;
}DVB_SET_TS_PACKETBATCH_REQ;

typedef struct
{
	int           drv_status;
}DVB_SET_TS_PACKETBATCH_CNF;

// 7  WM_CMD_DVB_Set_TX_PacketTimeout

typedef struct
{
	unsigned int TimeOut;
}DVB_SET_TX_PACKETTIMEOUT_REQ;

typedef struct
{
	int           drv_status;
}DVB_SET_TX_PACKETTIMEOUT_CNF;

// 9  WM_CMD_DVB_Add_TS_PID

typedef struct
{
	unsigned int PIDValue;
}DVB_ADD_TS_PID_REQ;

typedef struct
{
	int           drv_status;
}DVB_ADD_TS_PID_CNF;

// 10  WM_CMD_DVB_Remove_TS_PID

typedef struct
{
	unsigned int PIDValue;
}DVB_REMOVE_TS_PID_REQ;

typedef struct
{
	int           drv_status;
}DVB_REMOVE_TS_PID_CNF;

// 11 WM_CMD_DVB_Disable_AllTS_PIDsFiltering

typedef struct
{
	unsigned int NotUsed;
}DVB_DISABLE_ALLTS_PIDFILTERING_REQ;

typedef struct
{
	int		drv_status;
}DVB_DISABLE_ALLTS_PIDFILTERING_CNF;

// 12 WM_CMD_DVB_Dump_TS_PacketstoSDCard

typedef struct
{
	unsigned int NotUsed;
}DVB_DUMP_TS_PACKETSTOSDCARD_REQ;

typedef struct
{
	int           drv_status;
}DVB_DUMP_TS_PACKETSTOSDCARD_CNF;

// 13 WM_CMD_DVB_Get_ReceptionMode

typedef struct
{
	unsigned int NotUsed;
}DVB_GET_RECEPTIONMODE_REQ;

typedef struct
{
	unsigned char	FFT;
	unsigned char	GI;
	unsigned char	CodeRate;
	unsigned char	Constellation;
	unsigned char	Hierarchy;
	unsigned char	HP_LP;
	unsigned char	HP_CodeRate;
	unsigned char	LP_CodeRate;
	unsigned char	Indepth;
	unsigned short	CellID;
	int				drv_status;
}DVB_GET_RECEPTIONMODE_CNF;


// 14 WM_CMD_DVB_Get_LockIndicator

typedef struct
{
	unsigned int NotUsed;
}DVB_GET_LOCKINDICATOR_REQ;

typedef struct
{
	unsigned char	AGCLock;
	unsigned char	MDLock;
	unsigned char	TPSLock;
	unsigned char	TSLock;
	unsigned char	CtrlStatus;
	unsigned char	SigStrength;
	unsigned char	SigQuality;
	short			InbandPow;
	short			WidebandPow;
	int				drv_status;
}DVB_GET_LOCKINDICATOR_CNF;

// 15 WM_CMD_DVB_Get_PerformanceInfo

typedef struct
{
	unsigned int NotUsed;
}DVB_GET_PERFORMANCEINFO_REQ;

typedef struct
{
    unsigned char	SNR;
    unsigned char	CCCICount;
    unsigned char	AR;
    unsigned char	FDBW;
    char			RFAGC;
    char			IFAGC;
    unsigned char	RFAGCState;
    unsigned char	ReceiveMode;
    unsigned char	ResetCount;
    unsigned char	AcqCount;
    unsigned char	Wbpd;
    unsigned char	AdcPow;
    unsigned short	INRCount;
    short			WinDrift;
    unsigned short	IQGain;
    unsigned short	TPSTime;
    unsigned short	TSTime;
    unsigned short	FER;
    unsigned short	MFER;
    unsigned int	PostBER;
    unsigned int	TSPER;
    unsigned int	TSBER;
    unsigned int	IQPhase;
    unsigned int	PhaseComp;
    int				CFOInit;
    int				CFOTra;
    int				TimeOffset;
    int				Tope;
	int				drv_status;
}DVB_GET_PERFORMANCEINFO_CNF;

// 16 WM_CMD_DVB_Get_Version

typedef struct
{
	unsigned int	NotUsed;
} DVB_GET_VERSION_REQ;

typedef struct
{
	char	Version[256];
	int		drv_status;
} DVB_GET_VERSION_CNF;

// 17 WM_CMD_DVB_Get_Debug_Counter

typedef struct
{
    unsigned int	NotUsed;
} DVB_GET_DEBUG_COUNTER_REQ;

typedef struct
{
	unsigned int	TSPacketNumber;
	unsigned int	OverflowCounter;
	unsigned int	InterruptCounter;
	int				drv_status;
} DVB_GET_DEBUG_COUNTER_CNF;


//wifi
typedef struct
{    
	unsigned int		int_rx_ok_num;
	unsigned int		int_crc_err_num;
	unsigned int		int_rssi_max;
	unsigned int		int_rssi_min;
	unsigned int		int_rssi_mean;
	unsigned int		int_rssi_variance;
} WIFI_RXSTATUS_T;

typedef enum _ENUM_CFG_SRC_TYPE_T
{
	CFG_SRC_TYPE_EEPROM,	//cfg data is queried/set from/to EEPROM
	CFG_SRC_TYPE_NVRAM,		//cfg data is queried/set from/to NVRAM
	CFG_SRC_TYPE_BOTH,		//cfg data is queried/set from/to NVRAM, and E2PROM presents too
	CFG_SRC_TYPE_AUTO
} ENUM_CFG_SRC_TYPE_T;

typedef struct
{
	int bufSize;
	int bLongPreamble;
	int txRate;
	int pktCount;
	int pktInterval;
	int bGainControl;
	int gainControl;
	int bTrackAlc;
	int bTargetAlc;
	int targetAlcValue;
	int txAntenna;
	
} WIFI_TX_PARAM_T;

META_RESULT  __stdcall SP_META_WiFi_QueryConfig(unsigned int ms_timeout, ENUM_CFG_SRC_TYPE_T *bufType);
META_RESULT  __stdcall SP_META_WiFi_QueryConfig_r(int meta_handle, unsigned int ms_timeout, ENUM_CFG_SRC_TYPE_T *bufType);
META_RESULT  __stdcall SP_META_WiFi_setPacketRx(unsigned int ms_timeout, int condition, int nAntenna);
META_RESULT  __stdcall SP_META_WiFi_setPacketRx_r(const int meta_handle, unsigned int ms_timeout, int condition, int nAntenna);
META_RESULT  __stdcall SP_META_WiFi_readMCR32(unsigned int ms_timeout, unsigned int offset, unsigned long *value);
META_RESULT  __stdcall SP_META_WiFi_readMCR32_r(const int meta_handle, unsigned int ms_timeout, unsigned int offset, unsigned long *value);
META_RESULT  __stdcall SP_META_WiFi_writeMCR32(unsigned int ms_timeout, unsigned int offset, unsigned int value);
META_RESULT  __stdcall SP_META_WiFi_writeMCR32_r(const int meta_handle, unsigned int ms_timeout, unsigned int offset, unsigned int value);


META_RESULT  __stdcall SP_META_WiFi_ReadConfigData(unsigned int ms_timeout, unsigned int offset, unsigned long *value, ENUM_CFG_SRC_TYPE_T type);
META_RESULT  __stdcall SP_META_WiFi_ReadConfigData_r(int meta_handle, unsigned int ms_timeout, unsigned int offset, unsigned long *value, ENUM_CFG_SRC_TYPE_T type);
META_RESULT  __stdcall SP_META_WiFi_WriteConfigData(unsigned int ms_timeout, unsigned int offset, unsigned int value, ENUM_CFG_SRC_TYPE_T type);
META_RESULT  __stdcall SP_META_WiFi_WriteConfigData_r(int meta_handle, unsigned int ms_timeout, unsigned int offset, unsigned int value, ENUM_CFG_SRC_TYPE_T type);

#define SP_META_WiFi_readEEPRom16(ms_timeout, offset, value)	\
	META_WiFi_ReadConfigData(ms_timeout, offset, value, CFG_SRC_TYPE_AUTO)
#define SP_META_WiFi_writeEEPRom16(ms_timeout, offset, value)	\
	META_WiFi_WriteConfigData(ms_timeout, offset, value, CFG_SRC_TYPE_AUTO)
#define SP_META_WiFi_readEEPRom16_r(meta_handle, ms_timeout, offset, value)	\
SP_META_WiFi_ReadConfigData_r(meta_handle, ms_timeout, offset, value, CFG_SRC_TYPE_AUTO)
#define SP_META_WiFi_writeEEPRom16_r(meta_handle, ms_timeout, offset, value)	\
SP_META_WiFi_WriteConfigData_r(meta_handle, ms_timeout, offset, value, CFG_SRC_TYPE_AUTO)

META_RESULT  __stdcall SP_META_WiFi_eepromReadByteStr(unsigned int ms_timeout, unsigned int u4Addr, unsigned int u4Length, char *pszStr);
META_RESULT  __stdcall SP_META_WiFi_eepromReadByteStr_r(const int meta_handle, unsigned int ms_timeout, unsigned int u4Addr, unsigned int u4Length, char *pszStr);
META_RESULT  __stdcall SP_META_WiFi_eepromWriteByteStr(unsigned int ms_timeout, unsigned int u4Addr, unsigned int u4Length, char *pszStr);
META_RESULT  __stdcall SP_META_WiFi_eepromWriteByteStr_r(const int meta_handle, unsigned int ms_timeout, unsigned int u4Addr, unsigned int u4Length, char *pszStr);
META_RESULT  __stdcall SP_META_WiFi_getChannel(unsigned int ms_timeout, long *channelConfig_p);
META_RESULT  __stdcall SP_META_WiFi_getChannel_r(const int meta_handle, unsigned int ms_timeout, long *channelConfig_p);
META_RESULT  __stdcall SP_META_WiFi_setPacketTxEx(unsigned int ms_timeout, WIFI_TX_PARAM_T * pTxParam);
META_RESULT  __stdcall SP_META_WiFi_setPacketTxEx_r(const int meta_handle, unsigned int ms_timeout, WIFI_TX_PARAM_T * pTxParam);
META_RESULT  __stdcall SP_META_WiFi_GetATParam(unsigned int ms_timeout, unsigned int offset, unsigned long *value);
META_RESULT  __stdcall SP_META_WiFi_GetATParam_r(const int meta_handle, unsigned int ms_timeout, unsigned int offset, unsigned long *value);
META_RESULT  __stdcall SP_META_WiFi_SetATParam(unsigned int ms_timeout, unsigned int offset, unsigned int value);
META_RESULT  __stdcall SP_META_WiFi_SetATParam_r(const int meta_handle, unsigned int ms_timeout, unsigned int offset, unsigned int value);
META_RESULT  __stdcall SP_META_WiFi_setOutputPower(unsigned int ms_timeout, WIFI_TX_PARAM_T * pTxParam);
META_RESULT  __stdcall SP_META_WiFi_setOutputPower_r(const int meta_handle, unsigned int ms_timeout, WIFI_TX_PARAM_T * pTxParam);
META_RESULT  __stdcall SP_META_WiFi_setStandBy(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_setStandBy_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_setCarrierSuppression(unsigned int ms_timeout, WIFI_TX_PARAM_T * pTxParam);
META_RESULT  __stdcall SP_META_WiFi_setCarrierSuppression_r(const int meta_handle, unsigned int ms_timeout, WIFI_TX_PARAM_T * pTxParam);
META_RESULT  __stdcall SP_META_WiFi_setLocalFrequecy(unsigned int ms_timeout, int txPower, int txAntenna);
META_RESULT  __stdcall SP_META_WiFi_setLocalFrequecy_r(const int meta_handle, unsigned int ms_timeout, int txPower, int txAntenna);
META_RESULT  __stdcall SP_META_WiFi_setNormalMode(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_setNormalMode_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_setOutputPin(unsigned int ms_timeout, int pinIndex, int outputLevel);
META_RESULT  __stdcall SP_META_WiFi_setOutputPin_r(const int meta_handle, unsigned int ms_timeout, int pinIndex, int outputLevel);
META_RESULT  __stdcall SP_META_WiFi_setPnpPower(unsigned int ms_timeout, int i4PowerMode);
META_RESULT  __stdcall SP_META_WiFi_setPnpPower_r(const int meta_handle, unsigned int ms_timeout, int i4PowerMode);
META_RESULT  __stdcall SP_META_WiFi_setTestMode(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_setTestMode_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_setChannel(unsigned int ms_timeout, int channelConfig);
META_RESULT  __stdcall SP_META_WiFi_setChannel_r(const int meta_handle, unsigned int ms_timeout, int channelConfig);
META_RESULT  __stdcall SP_META_WiFi_readTxPowerFromEEPromEx(unsigned int ms_timeout, int channelFreq, int rate, long *nTxPwr, long *outputPower, long *targetAlc);
META_RESULT  __stdcall SP_META_WiFi_readTxPowerFromEEPromEx_r(const int meta_handle, unsigned int ms_timeout, int channelFreq, int rate, long *nTxPwr, long *outputPower, long *targetAlc);
META_RESULT  __stdcall SP_META_WiFi_getPacketRxStatus(unsigned int ms_timeout, WIFI_RXSTATUS_T *pRxStatus);
META_RESULT  __stdcall SP_META_WiFi_getPacketRxStatus_r(const int meta_handle, unsigned int ms_timeout, WIFI_RXSTATUS_T *pRxStatus);
META_RESULT  __stdcall SP_META_WiFi_setXtalTrimToCr(unsigned int ms_timeout, unsigned int u4Value);
META_RESULT  __stdcall SP_META_WiFi_setXtalTrimToCr_r(const int meta_handle, unsigned int ms_timeout, unsigned int u4Value);
META_RESULT  __stdcall SP_META_WiFi_queryThermoInfo(unsigned int ms_timeout, long * pi4Enable, unsigned long * pu4RawVal);
META_RESULT  __stdcall SP_META_WiFi_queryThermoInfo_r(const int meta_handle, unsigned int ms_timeout, long * pi4Enable, unsigned long * pu4RawVal);
META_RESULT  __stdcall SP_META_WiFi_setThermoEn(unsigned int ms_timeout, long i4Enable);
META_RESULT  __stdcall SP_META_WiFi_setThermoEn_r(const int meta_handle, unsigned int ms_timeout, long i4Enable);


//add by dian.wang for MT6620
META_RESULT __stdcall SP_META_WiFi_readTxPower(unsigned int ms_timeout, unsigned long *value);
META_RESULT __stdcall SP_META_WiFi_readTxPower_r(const int meta_handle, unsigned int ms_timeout, unsigned long *value);
META_RESULT __stdcall SP_META_WiFi_setRxTest(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WiFi_setRxTest_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WiFi_setBandwidth(unsigned int ms_timeout,unsigned int value);
META_RESULT __stdcall SP_META_WiFi_setBandwidth_r(const int meta_handle, unsigned int ms_timeout,unsigned int value);
META_RESULT __stdcall SP_META_WiFi_setGuardinterval( unsigned int ms_timeout,unsigned int value);
META_RESULT __stdcall SP_META_WiFi_setGuardinterval_r(const int meta_handle, unsigned int ms_timeout,unsigned int value);
META_RESULT __stdcall SP_META_WiFi_setModeSelect(unsigned int ms_timeout,unsigned int value);
META_RESULT __stdcall SP_META_WiFi_setModeSelect_r(const int meta_handle, unsigned int ms_timeout,unsigned int value);
META_RESULT __stdcall SP_META_WiFi_setTxRxIQCalibration( unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WiFi_setTxRxIQCalibration_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WiFi_setDPDCalibration( unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WiFi_setDPDCalibration_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WiFi_getResultInformation( unsigned int ms_timeout,unsigned int index,unsigned long * length);
META_RESULT __stdcall SP_META_WiFi_getResultInformation_r(const int meta_handle, unsigned int ms_timeout,unsigned int index,unsigned long * length);
META_RESULT __stdcall SP_META_WiFi_getCalResult(unsigned int ms_timeout,unsigned int index,unsigned int offset,unsigned long * data);
META_RESULT __stdcall SP_META_WiFi_getCalResult_r(const int meta_handle, unsigned int ms_timeout,unsigned int index,unsigned int offset,unsigned long * data);
META_RESULT __stdcall SP_META_WiFi_getTemperatureSensorResult( unsigned int ms_timeout,unsigned long *value);
META_RESULT __stdcall SP_META_WiFi_getTemperatureSensorResult_r(const int meta_handle, unsigned int ms_timeout,unsigned long *value);
META_RESULT __stdcall SP_META_WiFi_getVoltageSensorResult(unsigned int ms_timeout,unsigned long *value);
META_RESULT __stdcall SP_META_WiFi_getVoltageSensorResult_r(const int meta_handle, unsigned int ms_timeout,unsigned long *value);
META_RESULT __stdcall SP_META_WiFi_readEFuseAddr( unsigned int ms_timeout,unsigned int addr,unsigned long *value);
META_RESULT __stdcall SP_META_WiFi_readEFuseAddr_r(const int meta_handle, unsigned int ms_timeout,unsigned int addr,unsigned long *value);
META_RESULT __stdcall SP_META_WiFi_writeEFuseAddr(unsigned int ms_timeout,unsigned int addr,unsigned int value);
META_RESULT __stdcall SP_META_WiFi_writeEFuseAddr_r(const int meta_handle, unsigned int ms_timeout,unsigned int addr,unsigned int value);
/*DEPRECATED*/META_RESULT __stdcall SP_META_WiFi_setTSSIEnableorDisable(unsigned int ms_timeout,unsigned int flag);
/*DEPRECATED*/META_RESULT __stdcall SP_META_WiFi_setTSSIEnableorDisable_r(const int meta_handle, unsigned int ms_timeout,unsigned int flag);
/*DEPRECATED*/META_RESULT __stdcall SP_META_WiFi_getTSSICalibrationResult( unsigned int ms_timeout,unsigned long * value);
/*DEPRECATED*/META_RESULT __stdcall SP_META_WiFi_getTSSICalibrationResult_r(const int meta_handle, unsigned int ms_timeout,unsigned long * value);
META_RESULT __stdcall SP_META_WiFi_TSSICalibration( unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WiFi_TSSICalibration_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WiFi_setRate(unsigned int ms_timeout,unsigned long value);
META_RESULT __stdcall SP_META_WiFi_setRate_r(const int meta_handle, unsigned int ms_timeout,unsigned long value);
META_RESULT __stdcall SP_META_WiFi_ReceivedErrorCount(unsigned int ms_timeout, unsigned long * value);
META_RESULT __stdcall SP_META_WiFi_ReceivedErrorCount_r(const int meta_handle, unsigned int ms_timeout, unsigned long * value);
META_RESULT __stdcall SP_META_WiFi_ReceivedOKCount(unsigned int ms_timeout, unsigned long * value);
META_RESULT __stdcall SP_META_WiFi_ReceivedOKCount_r(const int meta_handle, unsigned int ms_timeout, unsigned long * value);
META_RESULT __stdcall SP_META_WiFi_GetChipVersion( unsigned int ms_timeout,unsigned long * chipVersion);
META_RESULT __stdcall SP_META_WiFi_GetChipVersion_r(const int meta_handle, unsigned int ms_timeout,unsigned long * chipVersion);



typedef struct _NVRAM_ACCESS_STRUCT 
{
    unsigned int dataLen; 
    unsigned int dataOffset; /*set as zero for whole region */
    char * data;
    
} NVRAM_ACCESS_STRUCT;

META_RESULT  __stdcall SP_META_WiFi_WriteNVRAM_r(const int meta_handle, unsigned int  ms_timeout, NVRAM_ACCESS_STRUCT * pReq);
META_RESULT  __stdcall SP_META_WiFi_WriteNVRAM(unsigned int  ms_timeout, NVRAM_ACCESS_STRUCT * pReq);
META_RESULT  __stdcall SP_META_WiFi_ReadNVRAM_r(const int meta_handle, unsigned int  ms_timeout, NVRAM_ACCESS_STRUCT * pReq);
META_RESULT  __stdcall SP_META_WiFi_ReadNVRAM(unsigned int  ms_timeout, NVRAM_ACCESS_STRUCT * pReq);


//for wifi CW mode
//for input parameter nTxRate please set to 0.
//for input parameter nCWModeType please set to 4. 
META_RESULT __stdcall SP_META_WiFi_setCWMode(unsigned int ms_timeout, int nTxRate, int nCWModeType);
META_RESULT __stdcall SP_META_WiFi_setCWMode_r(const int meta_handle, unsigned int ms_timeout, int nTxRate, int nCWModeType);

META_RESULT __stdcall SP_META_WiFi_ReceivedRSSI(unsigned int ms_timeout, long * value);
META_RESULT __stdcall SP_META_WiFi_ReceivedRSSI_r(const int meta_handle, unsigned int ms_timeout, long * value);
//

//For WiFi MT6630
META_RESULT __stdcall SP_META_WiFi_setBandwidthEx(unsigned int ms_timeout, unsigned int nChBandwidth, unsigned int nDataBandwidth, unsigned int nPrimarySetting);
META_RESULT __stdcall SP_META_WiFi_setBandwidthEx_r(const int meta_handle, unsigned int ms_timeout, unsigned int nChBandwidth, unsigned int nDataBandwidth, unsigned int nPrimarySetting);

META_RESULT __stdcall SP_META_WiFi_setJMode(unsigned int ms_timeout, unsigned int nMode);
META_RESULT __stdcall SP_META_WiFi_setJMode_r(const int meta_handle, unsigned int ms_timeout, unsigned int nMode);
//

META_RESULT  __stdcall SP_META_WiFi_setDutyCycle(unsigned int ms_timeout, WIFI_TX_PARAM_T * pTxParam, int nCWMode);
META_RESULT  __stdcall SP_META_WiFi_setDutyCycle_r(const int meta_handle, unsigned int ms_timeout, WIFI_TX_PARAM_T * pTxParam, int nCWMode);

//add 2016-02-01
META_RESULT __stdcall SP_META_WiFi_setTXPath(unsigned int ms_timeout, unsigned int nPath);
META_RESULT __stdcall SP_META_WiFi_setTXPath_r(const int meta_handle, unsigned int ms_timeout, unsigned int nPath);

META_RESULT __stdcall SP_META_WiFi_setTX1Channel(unsigned int ms_timeout, int channelConfig);
META_RESULT __stdcall SP_META_WiFi_setTX1Channel_r(const int meta_handle, unsigned int ms_timeout, int channelConfig);

META_RESULT __stdcall SP_META_WiFi_setNss(unsigned int ms_timeout, int nNss);
META_RESULT __stdcall SP_META_WiFi_setNss_r(const int meta_handle, unsigned int ms_timeout, int nNss); 

META_RESULT __stdcall SP_META_WiFi_setRXPath(unsigned int ms_timeout, unsigned int nPath);
META_RESULT __stdcall SP_META_WiFi_setRXPath_r(const int meta_handle, unsigned int ms_timeout, unsigned int nPath);

//add 2016-03-31
META_RESULT __stdcall SP_META_WiFi_ReceivedRSSI1(unsigned int ms_timeout, long * value);
META_RESULT __stdcall SP_META_WiFi_ReceivedRSSI1_r(const int meta_handle, unsigned int ms_timeout, long * value);

//ui does not use, no test
#if 0
META_RESULT  __stdcall SP_META_WiFi_getPacketTxStatusEx(unsigned int ms_timeout, long *sentCount, long *ackCount, long *alc, 
												long *cckGainControl, long *ofdmGainControl);
META_RESULT  __stdcall SP_META_WiFi_setEEPRomFromFile(unsigned int ms_timeout, TCHAR* fileName);
META_RESULT  __stdcall SP_META_WiFi_setEEPromCKSUpdated(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_setEEPRomSize(unsigned int ms_timeout, long eepromSz);
META_RESULT  __stdcall SP_META_WiFi_getChannelBand(unsigned int ms_timeout, long freq, long *channel, long *band);
META_RESULT  __stdcall SP_META_WiFi_getEEPRomSize(unsigned int ms_timeout, long *eepromSz);
META_RESULT  __stdcall SP_META_WiFi_setChipType(unsigned int ms_timeout, unsigned long u4ChipType);

META_RESULT  __stdcall SP_META_WiFi_getPacketTxStatusEx_r(const int meta_handle, unsigned int ms_timeout, long *sentCount, long *ackCount, long *alc, 
												long *cckGainControl, long *ofdmGainControl);
META_RESULT  __stdcall SP_META_WiFi_setEEPRomFromFile_r(const int meta_handle, unsigned int ms_timeout, TCHAR* fileName);
META_RESULT  __stdcall SP_META_WiFi_setEEPromCKSUpdated_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_setEEPRomSize_r(const int meta_handle, unsigned int ms_timeout, long eepromSz);
META_RESULT  __stdcall SP_META_WiFi_getChannelBand_r(const int meta_handle, unsigned int ms_timeout, long freq, long *channel, long *band);
META_RESULT  __stdcall SP_META_WiFi_getEEPRomSize_r(const int meta_handle, unsigned int ms_timeout, long *eepromSz);
META_RESULT  __stdcall SP_META_WiFi_setChipType_r(const int meta_handle, unsigned int ms_timeout, unsigned long u4ChipType);
#endif

//Clean Boot Flag
META_RESULT __stdcall SP_META_SetCleanBootFlag(unsigned int ms_timeout,SetCleanBootFlag_REQ *req, SetCleanBootFlag_CNF *cnf);
META_RESULT __stdcall SP_META_SetCleanBootFlag_r(const int meta_handle,unsigned int ms_timeout,SetCleanBootFlag_REQ *req,SetCleanBootFlag_CNF *cnf);

//Battey FW/SOC info
typedef enum{
 BAT_READ_INFO_FAILED=0, 
 BAT_READ_INFO_SUCCESS,
 BAT_READ_FW_SUCCESS,
 BAT_READ_VBAT_SUCCESS 
}WM_Bat_READ_FW_TYPE;

 typedef enum{
	WM_BAT_SOC1_SETTINGS=0,
   	WM_BAT_SOC1_CLEAR
 }WM_BAT_SOC_TYPE;

typedef struct
{
  	int 		ibatteryinfo; //N/A
}WM_Bat_READ_FW_INFO_REQ_T;
 
typedef struct{
  	//int 		ibatteryinfo; //N/A
  	int		nReqReadSocType;	//0-setting, 1-clear
}WM_Bat_READ_SOC_REQ_T; 
 
typedef struct
{
  	//unsigned short 	SocValue; //N/A
  	unsigned char		SocValue;
  	unsigned char		SocClearValue;
  	int		nReqWriteSocType;	//0-setting, 1-clear
}WM_Bat_WRITE_SOC_REQ_T; 
 
typedef struct
{
	unsigned short	BQ27500_FW_Version;		//0xFFFF
	unsigned short	BQ27500_Battery_Voltage;	 //0xFFFF  
	unsigned short	BQ27500_DFI_Version;
//	WM_Bat_READ_FW_TYPE    Drv_Status; 	
  	int				Drv_Status;
 }WM_Bat_READ_FW_INFO_CNF_T;
 
typedef struct{	
	unsigned char   	BQ27500_SOC_Threshold;        //0xFFFF  
	unsigned char		BQ27500_SOC_ClearThreshold;
 	
	//WM_Bat_READ_FW_TYPE    	Drv_Status; 
	int				Drv_Status;
}WM_Bat_READ_SOC_CNF_T;
 
typedef struct{	    
 	//WM_Bat_READ_FW_TYPE    	Drv_Status; 
	int				Drv_Status;
}WM_Bat_WRITE_SOC_CNF_T;

//GPS module
typedef struct{
	unsigned int	len;
	unsigned char	buff[1024];
}GPS_CMD; 

typedef struct {
	unsigned int	len;
	unsigned char	buff[1024];
}GPS_ACK_BUF;

//GPS callback
typedef void (__stdcall *META_GPS_SEND_COMMAND_CNF)(const GPS_ACK_BUF*cnf, const short token, void *usrData);

META_RESULT  __stdcall SP_META_GPS_Open(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_GPS_Open_r(const int meta_handle,unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_GPS_Close(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_GPS_Close_r(const int meta_handle,unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_GPS_SendCommand(unsigned int ms_timeout,const GPS_CMD *req, GPS_ACK_BUF *cnf,META_GPS_SEND_COMMAND_CNF cb);
META_RESULT  __stdcall SP_META_GPS_SendCommand_r(const int meta_handle,unsigned int ms_timeout,const GPS_CMD *req, GPS_ACK_BUF *cnf,META_GPS_SEND_COMMAND_CNF cb);
META_RESULT  __stdcall SP_META_GPS_SendCommandMultiThread(unsigned int ms_timeout,const GPS_CMD *req, GPS_ACK_BUF *cnf,META_GPS_SEND_COMMAND_CNF cb,void *usrData);
META_RESULT  __stdcall SP_META_GPS_SendCommandMultiThread_r(const int meta_handle,unsigned int ms_timeout,const GPS_CMD *req, GPS_ACK_BUF *cnf,META_GPS_SEND_COMMAND_CNF cb,void *usrData);




typedef struct
{
	unsigned int	dwSDHCIndex; // MSDC1/2/3. if dwSDHCIndex no equal 1/2/3 auto test.
}FT_SDCARD_REQ;

typedef struct
{
	unsigned char			DatBusWidth;
	int			IsSecuredMode;
	unsigned short	CardTpye;
	unsigned int	SizeOfProtectErea;
	unsigned char			SpeedClass;
	unsigned char			Performance_move;
	unsigned char			AUSize;
	unsigned char	status;
}FT_SDCARD_CNF;

META_RESULT  __stdcall SP_META_SDCARD_Query(unsigned int ms_timeout,const FT_SDCARD_REQ *req, FT_SDCARD_CNF *cnf);
META_RESULT  __stdcall SP_META_SDCARD_Query_r(const int meta_handle,unsigned int ms_timeout,const FT_SDCARD_REQ *req, FT_SDCARD_CNF *cnf);

typedef struct
{
	unsigned long	time_duration;
}LCDFt_REQ;

typedef struct
{
	int status;
}LCDFt_CNF;

META_RESULT __stdcall SP_META_LcdColorTest(unsigned int ms_timeout, LCDFt_REQ *req, LCDFt_CNF *cnf);
META_RESULT __stdcall SP_META_LcdColorTest_r(const int meta_handle, unsigned int ms_timeout, LCDFt_REQ *req, LCDFt_CNF *cnf);

//Low Power
typedef enum
{
	WM_CMD_POWER_DOWN =0, 
	WM_CMD_POWER_UP,
}WM_LOW_POWER_TYPE;

META_RESULT __stdcall SP_META_LowPowerTest(unsigned int ms_timeout, WM_LOW_POWER_TYPE *ptype /*in & out*/);
META_RESULT __stdcall SP_META_LowPowerTest_r(int meta_handle, unsigned int ms_timeout, WM_LOW_POWER_TYPE *ptype /*in & out*/);


META_RESULT __stdcall SP_META_ReadUuid(unsigned int ms_timeout, unsigned int *high, unsigned int *low);
META_RESULT __stdcall SP_META_ReadUuid_r(int meta_handle, unsigned int ms_timeout, unsigned int *high, unsigned int *low);

META_RESULT __stdcall SP_META_WriteUuid(unsigned int ms_timeout, unsigned int high, unsigned int low);
META_RESULT __stdcall SP_META_WriteUuid_r(int meta_handle, unsigned int ms_timeout, unsigned int high, unsigned int low);




/*
typedef enum
{
    HW_GPIO0 = 0,
	HW_GPIO1,
	HW_GPIO2,
	...
	HW_GPIO146,
	HW_GPIO_MAX,
}HW_GPIO;          //pin number
*/
typedef enum
{
	GET_MODE_STA = 0,
	SET_MODE_0,  // 00
	SET_MODE_1,  // 01
	SET_MODE_2,  // 10
	SET_MODE_3,  // 11

	GET_DIR_STA, 
	SET_DIR_IN,  // 0
	SET_DIR_OUT, // 1
	
	GET_PULLEN_STA,  
	SET_PULLEN_DISABLE,  // 0
	SET_PULLEN_ENABLE,   // 1
	
	GET_PULL_STA,
	SET_PULL_DOWN,  // 0
	SET_PULL_UP,    // 1
	
	GET_INV_STA,
	SET_INV_ENABLE,  // 1
	SET_INV_DISABLE, // 0
	
	GET_DATA_IN,
	GET_DATA_OUT,
	SET_DATA_LOW,  // 0
	SET_DATA_HIGH, // 1

	SET_MODE_4,
	SET_MODE_5,
	SET_MODE_6,
	SET_MODE_7,


}GPIO_OP;

typedef struct
{
	unsigned int	pin;	// pin number
	GPIO_OP	op;		// operation to GPIO	
}GPIO_REQ;

typedef struct
{
	unsigned int	status;
	unsigned long	data;
}GPIO_CNF;

META_RESULT __stdcall SP_META_GpioCtrl(unsigned int ms_timeout, const GPIO_REQ *req, GPIO_CNF *cnf);
META_RESULT __stdcall SP_META_GpioCtrl_r(int meta_handle, unsigned int ms_timeout, const GPIO_REQ *req, GPIO_CNF *cnf);


META_RESULT __stdcall SP_META_Nvram_Backup(unsigned int ms_timeout, const char *file1, const char *file2);
META_RESULT __stdcall SP_META_Nvram_Backup_r(int meta_handle, unsigned int ms_timeout, const char *file1, const char *file2);
META_RESULT __stdcall SP_META_Nvram_Backup_YUSU(unsigned int ms_timeout, const char *file);
META_RESULT __stdcall SP_META_Nvram_Backup_YUSU_r(int meta_handle, unsigned int ms_timeout, const char *file);

META_RESULT __stdcall SP_META_Nvram_Restore(unsigned int ms_timeout, const char *file1, const char *file2);
META_RESULT __stdcall SP_META_Nvram_Restore_r(int meta_handle, unsigned int ms_timeout, const char *file1, const char *file2);
META_RESULT __stdcall SP_META_Nvram_Restore_YUSU(unsigned int ms_timeout, const char *file);
META_RESULT __stdcall SP_META_Nvram_Restore_YUSU_r(int meta_handle, unsigned int ms_timeout, const char *file);

META_RESULT __stdcall SP_META_Clean_Boot(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_Clean_Boot_r(int meta_handle,unsigned int ms_timeout);

META_RESULT __stdcall SP_META_Mode_Lock(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_Mode_Lock_r(int meta_handle,unsigned int ms_timeout);

typedef struct
{
	char mldrVersion[50];
	char ebootVersion[50];
	char flashVersion[50];
	unsigned short mldrCheckSum;
	unsigned short ebootCheckSum;
	unsigned short flashCheckSum;
	unsigned char status;
}FT_BTLDR_FLASH_VER_CNF;

META_RESULT __stdcall SP_META_Btldr_Flash_Ver(unsigned int ms_timeout, FT_BTLDR_FLASH_VER_CNF *cnf);
META_RESULT __stdcall SP_META_Btldr_Flash_Ver_r(int meta_handle, unsigned int ms_timeout, FT_BTLDR_FLASH_VER_CNF *cnf);


META_RESULT __stdcall SP_META_Nvram2Bin(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_Nvram2Bin_r(int meta_handle, unsigned int ms_timeout);




#define MD_FRAME_MAX_LEN 256

typedef struct
{
    short	frame_length;
    char	frame_data[MD_FRAME_MAX_LEN]; 
}MD_FRAME;

typedef struct _AUDIO_VOLUME_CUSTOM_STRUCT
{
	unsigned char audiovolume_ring[3][7];
	unsigned char audiovolume_key[3][7];
	unsigned char audiovolume_mic[3][7];
	unsigned char audiovolume_fmr[3][7];
	unsigned char audiovolume_sph[3][7];
	unsigned char audiovolume_sid[3][7];
	unsigned char audiovolume_media[3][7];
	unsigned char audiovolume_matv[3][7];
} AUDIO_VOLUME_CUSTOM_STRUCT;

typedef struct 
{
	short speech_input_FIR_coeffs[8][45];
	short speech_output_FIR_coeffs[8][6][45];
	short select_FIR_output_index[8];
	short select_FIR_intput_index[8];
	short speech_mode_para[8][16];
	
}AUDIO_PARAM_MED_STRUCT;

typedef struct
{
	unsigned short speech_mode_wb_para[8][16];
	short sph_wb_in_fir[6][90];
	short sph_wb_out_fir[6][90];
	
}AUDIO_CUSTOM_WB_PARAM_STRUCT;

META_RESULT __stdcall SP_META_SwitchUsbChnl(int enter, const WM_META_ConnectInMETA_Req *req, int *p_bootstop, WM_META_ConnectInMETA_Report *p_report);
META_RESULT __stdcall SP_META_SwitchUsbChnl_r(int meta_handle, int enter, const WM_META_ConnectInMETA_Req *req, int *p_bootstop, WM_META_ConnectInMETA_Report *p_report);

META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioVlomeCustomStruct(AUDIO_VOLUME_CUSTOM_STRUCT *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioVlomeCustomStruct(AUDIO_VOLUME_CUSTOM_STRUCT *param, const char *buf, const int buf_len);

META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioMedStruct(AUDIO_PARAM_MED_STRUCT *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioMedStruct(AUDIO_PARAM_MED_STRUCT *param, const char *buf, const int buf_len);

META_RESULT  __stdcall SP_META_NVRAM_Compose_AudioCustomWBStruct(AUDIO_CUSTOM_WB_PARAM_STRUCT *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_AudioCustomWBStruct(AUDIO_CUSTOM_WB_PARAM_STRUCT *param, const char *buf, const int buf_len);


META_RESULT __stdcall SP_META_Nvram_Backup_Custom(unsigned int ms_timeout, 
													const char *file1, const char *file2,const char * buffer,  int count, int mode );

META_RESULT __stdcall SP_META_Nvram_Backup_Custom_r(int meta_handle, unsigned int ms_timeout, 
										const char *file1, const char *file2,const char * buffer,  int count, int mode );

META_RESULT  __stdcall SP_META_Audio_Set_Echo_Loop2(unsigned int  ms_timeout,const Audio_Set_Echo_Req  *req);
META_RESULT  __stdcall SP_META_Audio_Set_Echo_Loop2_r(const int meta_handle,unsigned int  ms_timeout ,const Audio_Set_Echo_Req  *req);


META_RESULT __stdcall SP_META_Customer_Func(int ms_timeout, const unsigned char *data_in, const int data_in_len, int type, unsigned char dummy_in , unsigned char *dummy_out, unsigned char *data_out, int *data_out_len);
META_RESULT __stdcall SP_META_Customer_Func_r(int meta_handle, int ms_timeout, const unsigned char *data_in, const int data_in_len, int type, unsigned char dummy_in, unsigned char *dummy_out,unsigned char *data_out, int *data_out_len);

//For parameter: unsigned char* ChipID, the length should be greater than or equal to 17.
META_RESULT  __stdcall SP_META_GetChipID(unsigned int  ms_timeout, unsigned char* ChipID);
META_RESULT  __stdcall SP_META_GetChipID_r(const int meta_handle, unsigned int  ms_timeout, unsigned char* ChipID);

META_RESULT  __stdcall SP_META_MSensorTest(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_MSensorTest_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CTPTest(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CTPTest_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_ALSPSTest(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_ALSPSTest_r(const int meta_handle, unsigned int  ms_timeout);




//CMMB

#define MAX_CHANNEL_INFO_NUM    36
#define MAX_SERVICE_NUM   40

typedef struct
{
	int channel;
	int freq;
	
} CMMB_CHANNEL_INFO_S;

typedef struct
{
    int flag;              /*  flag = 0 means continuous confirm  */
                               /*  flag = 1 means all confirms have been received  */
    unsigned int    num;
    CMMB_CHANNEL_INFO_S    chInfo[MAX_CHANNEL_INFO_NUM];
    
} CMMB_CHANNEL_LIST_S;

typedef struct
{
    int flag;              /*  flag = 0 means continuous confirm  */
                               /*  flag = 1 means all confirms have been received  */
    unsigned int    num;
    int    servID[MAX_SERVICE_NUM];
    
} CMMB_SERVICE_LIST_S;

typedef struct
{
    int servID;
    char szMfsFile[260];
    
} CMMB_START_SERV_PARAM_S;

typedef struct
{
    int SNR;
    int PRE_BER;
    int RSSI;
    
} CMMB_PROPS_S;

META_RESULT  __stdcall SP_META_CMMB_Init(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_Init_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_Term(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_Term_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_AutoScan(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_AutoScan_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_CancelScan(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_CancelScan_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_SetChannel(unsigned int  ms_timeout, int channel);
META_RESULT  __stdcall SP_META_CMMB_SetChannel_r(const int meta_handle, unsigned int  ms_timeout, int channel);
META_RESULT  __stdcall SP_META_CMMB_ListServices(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_ListServices_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_StartService(unsigned int  ms_timeout, CMMB_START_SERV_PARAM_S * servParam);
META_RESULT  __stdcall SP_META_CMMB_StartService_r(const int meta_handle, unsigned int  ms_timeout, CMMB_START_SERV_PARAM_S * servParam);
META_RESULT  __stdcall SP_META_CMMB_StopService(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_StopService_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_CMMB_GetProp(unsigned int  ms_timeout, CMMB_PROPS_S * prop);
META_RESULT  __stdcall SP_META_CMMB_GetProp_r(const int meta_handle, unsigned int  ms_timeout, CMMB_PROPS_S * prop);

META_RESULT  __stdcall SP_META_CMMB_QueryChannelList(CMMB_CHANNEL_LIST_S * chList);
META_RESULT  __stdcall SP_META_CMMB_QueryChannelList_r(const int meta_handle, CMMB_CHANNEL_LIST_S * chList);
META_RESULT  __stdcall SP_META_CMMB_QueryServiceList(CMMB_SERVICE_LIST_S * servList);
META_RESULT  __stdcall SP_META_CMMB_QueryServiceList_r(const int meta_handle, CMMB_SERVICE_LIST_S * servList);




//-----------------------------------------------------//
//-----------------------NFC--------------------------//
//-----------------------------------------------------//

#define MIFARE4K_LEN        (16)
#define MIFARE1K_LEN        (4)
#define MIFARE1K_PAGE       (4)
#define UID_DATA_LEN        (7)
#define NDEF_DATA_LEN       (256)
#define RAW_COMM_DATA_LEN   (256) 
#define TAG_RAW_DATA_LEN    (256) 
#define TAG_WRITE_MAXDATA   (512)
#define UID_LEN             (10)
#define PNFC_DATA			(256)
#define VERSION_MW			(20)
#define URL_DATA			(64)
#define MTK_NFC_MAX_SE_NUM	(3)

//  NFC: REQ/CNF structure definition
typedef struct 
{
    unsigned int    nfc_enable;               /* feature enable or disable , 0: disable, 1:enable */
    unsigned int    debug_enable;        /*debug enable or disable , 0: disable, 1:enable */  
    unsigned int    sw_protocol;           /*SW protocol,  0: SW stack, 1: raw data mode */ 
    unsigned int     get_capabilities;      /*get chip capability 0: no request, 1: request*/

} NFC_SETTING_REQ_S;


typedef struct
{  
    unsigned int    status;                        /* return setting result*/  
    unsigned int    nfc_enable;               /* return feature enable or disable */  
    unsigned int    debug_enable;        /* return debug enable or disable*/  
    unsigned int    sw_protocol;           /* return SW protocol,*/  
    unsigned int    get_capabilities;      /* return chip capability*/       
    unsigned int    sw_ver;                      /* return software version*/   
    unsigned int    hw_ver;                     /* return hardware version*/  
    unsigned int    fw_ver;                       /* return firmware version*/  
    unsigned int    reader_mode;          /* return support  format bitmap*/  
    unsigned int    card_mode;              /* return support  format bitmap */

} NFC_SETTING_CNF_S;


typedef struct
{  
    unsigned int    reg_type;               /* register notification bitmap */       
    
} NFC_REGNOTIFY_REQ_S;

// Nina modified
typedef struct
{  
    unsigned int     status;          /* return setting result,0 success, other: fail*/  
	
    unsigned int     se;                /* secure element detect, 0: no detect, 1: se typ1 , 2: se type 2*/  
    unsigned int     se_status; /* secure element status, 0:off, 1:Virtual, 2:Wired*/  
    unsigned int     se_type;      /* secure element type, bitmap*/  
    unsigned int     length; /* length of data*/
    
} NFC_REGNOTIFY_CNF_S;


typedef struct
{  
    unsigned int     set_SEtype;      /* setting se  type, 0:off, 1:Virtual, 2:Wired */
    
} NFC_SECURE_REQ_S;

// Nina add 
typedef struct
{  
     unsigned int     status;          /* return setting result, 0:sucess*/
    
} NFC_SECURE_CNF_S;

typedef struct 
{  
    unsigned int    tag_type;               /* return detected tag type*/  
    unsigned int    card_type;            /* card type, 1: Mifare classic 1K*/                                                              
                                                             /* 2: Mifare classic 4K*/                                                              
                                                             /* 3: NDEF*/  
    unsigned int    uid;                        /* card Uid*/  
    unsigned int    sak;                       /* card sak*/               
    unsigned int    atag;                    /* card atag*/  
    unsigned int    appdata;             /* card appdata */  
    unsigned int    maxdatarate;    /* card maxdatarate */

} NFC_TAG_INFO_S;


typedef struct 
{  
    unsigned int    p2p_type;               /* return detected tag type*/

} NFC_P2P_INFO_S;


typedef union
{  
    NFC_TAG_INFO_S    nfc_tag_info;  
    NFC_P2P_INFO_S    nfc_p2p_info;  

} NFC_DEVICE_INFO_U;


typedef struct 
{  
    unsigned int     status;          /* return setting result, 0:sucess */  
    unsigned char    type;           /*1 : Tag ,2: p2p */  
    NFC_DEVICE_INFO_U    nfc_device_info;
    
} NFC_DISCOVERY_CNF_S;

typedef struct 
{
  unsigned int    dis_type;               /* discovery notification bitmap */
  unsigned int duration;                 /* set duration,(unit:ms) */   
    
} NFC_DISCOVERY_REQ_S;


typedef struct
{  
    unsigned int    address;               /*  */  
    unsigned short  data[MIFARE1K_LEN];

} NFC_MIFARE1K_DATA_S;


typedef struct
{  
    unsigned int    sector;               /*  */  
    unsigned int    block;  
    unsigned short data[MIFARE4K_LEN];

} NFC_MIFARE4K_DATA_S;


typedef struct
{  
    unsigned  int  ndef_type;  
    unsigned  int  length;        
    unsigned short data[NDEF_DATA_LEN];

} NFC_NDEF_DATA_S;


typedef union
{   
    NFC_MIFARE1K_DATA_S    nfc_Mifare1K_data;   
    NFC_MIFARE4K_DATA_S    nfc_Mifare4K_data;   
    NFC_NDEF_DATA_S    nfc_ndef_data;

} NFC_RW_DATA_U;


typedef struct 
{  
    unsigned int    read_type;               /*  which type want to read*/  
                                                                /* 1 for Mifare classic 1K */                                                                  
                                                                /* 2 for Mifare classic 4K */                                                                  
                                                                /* 3 for NDEF type*/  
    unsigned int    address;                  /* for Mifare classic 1K used*/  
    unsigned int    sector;                    /* for Mifare classic 4K used*/  
    unsigned int    block;                     /* for Mifare classic 4K used*/
	unsigned char   AuthentificationKey;       /* KEY_A:0 , KEY_B:1 */

} NFC_TAGREAD_REQ_S;


typedef struct 
{  
    unsigned int    status;               /*  return read status, 0 success*/  
    unsigned int    type;                 /*1 : Mifare classic 1K ,2: Mifare classic 4K, 3: NDEF */  
    NFC_RW_DATA_U    nfc_read_data;
    
} NFC_TAGREAD_CNF_S;

typedef struct 
{  
    unsigned int    write_type;               /*  which type want to write*/  
    NFC_RW_DATA_U    nfc_write_data;

} NFC_TAGWRITE_REQ_S;

//Nina add
typedef enum {
    nfc_tag_DEFAULT    = 0,
    nfc_tag_MIFARE_UL  = 1,
    nfc_tag_MIFARE_STD = 2,
    nfc_tag_ISO1443_4A = 3,
    nfc_tag_ISO1443_4B = 4,
    nfc_tag_JEWWL      = 5,
    nfc_tag_NFC        = 6,
    nfc_tag_FELICA     = 7,
    nfc_tag_ISO15693   = 8,
	nfc_NDEF           = 9
}NFC_TAG_TYPE;


//Nina modify
typedef struct 
{  
    unsigned int    status;                /*  return read status, 0 success*/                 
    unsigned int    wrtie_type;      /*  return writed type*/
	//NFC_TAG_TYPE	 wrtie_type;   
    
} NFC_TAGWRITE_CNF_S;

typedef struct 
{  
    unsigned int    action;     /* 1: disconnect, */
    
} NFC_TAGDISCONNECT_REQ_S;

// Nina add
typedef struct
{
	unsigned int    status;      /*0: success*/

}NFC_TAGDISCONNECT_CNF_S;

typedef struct 
{  
    unsigned int    action;      /* 1: format to Ndef, */
    
} NFC_TAGFORMAT2NDEF_REQ_S;

// Nina add
typedef struct 
{  
   unsigned int    status;      /*0: success*/
    
} NFC_TAGFORMAT2NDEF_CNF_S;


typedef struct
{
  unsigned int   length;
  unsigned char data[TAG_RAW_DATA_LEN];
} NFC_TAGRAWCOM_REQ_typeA;

typedef struct 
{
  unsigned int   length;
  unsigned char data[TAG_RAW_DATA_LEN];
} NFC_TAGRAWCOM_REQ_typeB;

typedef struct 
{
  unsigned int   length;
  unsigned char  data[TAG_RAW_DATA_LEN];
}NFC_TAGRAWCOM_REQ_typeJewel;

typedef struct 
{
  unsigned int   length;
  unsigned char  data[TAG_RAW_DATA_LEN];
}NFC_TAGRAWCOM_REQ_typeFelica;

typedef union 
{
  NFC_TAGRAWCOM_REQ_typeA  req_data_typeA;
  NFC_TAGRAWCOM_REQ_typeB  req_data_typeB;
  NFC_TAGRAWCOM_REQ_typeJewel req_data_typeJewel;
  NFC_TAGRAWCOM_REQ_typeFelica req_data_typeFelica;

} NFC_TAGRAWCOM_REQ_DATA_U;

typedef struct 
{  
    unsigned int    action;     /*1: enable raw command */  
    unsigned int    length;     /*Length of written data. Unit is byte. The data is stored in the Meta peer buffer*/

	// Nina add
	NFC_TAGRAWCOM_REQ_DATA_U req_data;   
    
} NFC_TAGRAWCOMM_REQ_S;


typedef struct
{
  unsigned int   length;
  unsigned char data[TAG_RAW_DATA_LEN];

} NFC_TAGRAWCOM_CNF_typeA;

typedef struct
{
  unsigned int   length;
  unsigned char data[TAG_RAW_DATA_LEN];

} NFC_TAGRAWCOM_CNF_typeB;

typedef struct
{
  unsigned int   length;
  unsigned char  data[TAG_RAW_DATA_LEN];

}NFC_TAGRAWCOM_CNF_typeJewel;

typedef struct 
{
  unsigned int   length;
  unsigned char  data[TAG_RAW_DATA_LEN];

}NFC_TAGRAWCOM_CNF_typeFelica;


typedef union 
{
  NFC_TAGRAWCOM_CNF_typeA  rsp_data_typeA;
  NFC_TAGRAWCOM_CNF_typeB  rsp_data_typeB;
  NFC_TAGRAWCOM_CNF_typeJewel  rsp_data_typeJewel;
  NFC_TAGRAWCOM_CNF_typeFelica rsp_data_typeFelica;

} NFC_TAGRAWCOM_CNF_DATA_U;


// Nina add
typedef struct 
{
  //NFC_TAG_TYPE    type;        /*Type A / Type B*/
  unsigned int    type;
  unsigned int    status;      /*0 : success*/
  NFC_TAGRAWCOM_CNF_DATA_U   rsp_data;
} NFC_TAGRAWCOMM_CNF_S;

typedef struct 
{  
    unsigned int    action;      /* 1 : send, 2 receive*/  
    unsigned int    length;      /*Length of written data. Unit is byte. The data is stored in the Meta peer buffer*/

} NFC_P2PCOMM_REQ_S;

// Nina add
typedef struct 
{  
   unsigned int    status;   /* 0:success*/
   unsigned int    length;   /*Length of written data. Unit is byte.*/

} NFC_P2PCOMM_CNF_S;

typedef struct 
{  
    unsigned int    action;      /*1:start test, 0:stop test*/  
    unsigned int    length;      /*Length of written data. Unit is byte. The data is stored in the Meta peer buffer*/
    
} NFC_RDCOMM_REQ_S;

//Nina add
typedef struct 
{  
     unsigned int    status;   /*Test result, 0:success*/
	unsigned int    length;   /*Length of written data. Unit is byte.*/
    
} NFC_RDCOMM_CNF_S;

typedef struct 
{   
    unsigned int   type;           /*Test type: currently, always set 1*/   
    unsigned int   action;	      /*Test action, 1: start test, 0:stop test*/   
    
} NFC_SCRIPT_REQ_S;

typedef struct 
{   
    signed int   result;         /*Test result,0 :success*/

} NFC_SCRIPT_CNF_S;

typedef struct { 
	unsigned int   type;    /*Test type: currently, always set 1*/
	unsigned int   action;	/*Test action, 1: start test, 0:stop test*/  
	unsigned char  modulation_type;   /* 0:type A, 1:type B, 2:type F, 3:No Modulation */
	unsigned char  bitrate;           /* 0:106kbps, 1:212kbps, 2:424kbps */ 
} NFC_TXALWAYS_REQ_S;


typedef struct { 
	unsigned int   type;           /*Test type: currently, always set 1*/
	unsigned int   action;	       /*Test action, 1: start test, 0:stop test*/  
	unsigned short  technology;    /*bitmask: MifareUL=bit 0, MifareStd=bit1, ISO14443_4A=bit 2, ISO14443_4B=bit 3, Jewel=bit 4, Felica=bit 5, ISO15693=bit 6 */
	unsigned short  protocols;     /*bitmask: Iso14443A=bit 0, Iso14443B=bit 1, Felica212=bit 2, Felica424=bit 3, Iso15693=bit 4 */ 
} NFC_CARDEMULATION_REQ_S;

typedef struct 
{   
    unsigned int   type;                /*Test type: currently, always set 1*/   
    unsigned int   action;	      /*Test action, 1: start test, 0:stop test*/   
    unsigned int   uid_type;        /* 1: uid 4bytes, 2 : uid 7bytes*/       
    unsigned short data[UID_DATA_LEN];       /*uid content*/
    
} NFC_SCRIPTUID_REQ_S;

typedef struct 
{   
    signed int   result;                 /*Test result, 0: success*/   
    unsigned int uid_type;         /* 1: uid 4bytes, 2 : uid 7bytes */	   
    unsigned short data[UID_DATA_LEN];      /*uid content*/
    
} NFC_SCRIPTUID_CNF_S;

typedef struct { 
	unsigned int   type;           
	unsigned int   action;	       
	unsigned short  technology;    
	unsigned short  protocols; 
} NFC_CARDMODETEST_REQ_S;

//Chunlan 2013-4-28

typedef enum {
    nfc_ndef_lang_DEFAULT = 0,
    nfc_ndef_lang_DE = 1,
    nfc_ndef_lang_EN = 2,
    nfc_ndef_lang_FR = 3
} NFC_NDEF_LANG_TYPE;

typedef enum {
    nfc_ndef_type_uri = 0,
    nfc_ndef_type_text,
    nfc_ndef_type_sp,
    nfc_ndef_type_others,
} NFC_NDEF_TYPE;

typedef struct {
    char   Name[64];
    char   Compagny[64];
    char   Titlep[64];
    char   Tel[32];
    char   Email[64];
    char   Adress[128];
    char   PostalCode[32];
    char   City[64];
    char   CompagnyUrl[64];
} Vcard;

typedef struct {
    unsigned char  Compagny[64];
    unsigned short CompagnyLength;
    unsigned char  CompagnyUrl[64];
    unsigned short CompagnyUrlLength;
} SmartPoster;

typedef struct {
    unsigned short DataLength;
    unsigned char  data[TAG_WRITE_MAXDATA];
} Text_S;

typedef struct {
    unsigned short URLLength;
    unsigned char  URLData[URL_DATA];
} URL_S;

typedef struct {
    char   EXTTagType[64];
    char   EXTData[TAG_WRITE_MAXDATA];
    unsigned short EXTLength;
} EXTTag;

typedef union {
//    SmartPoster  SP_Data;
//    Vcard        VC_Data;
    Text_S         TX_Data;
    URL_S          URL_Data;
//    EXTTag       EXT_Data;
} NFC_TAG_WRITE_NDEF_DATA;

typedef struct {
    unsigned int                    length;
//    NFC_NDEF_TYPE             ndef_type;
	unsigned int ndef_type;
//    NFC_NDEF_LANG_TYPE        language;
	unsigned int language;
    NFC_TAG_WRITE_NDEF_DATA   ndef_data;
} NFC_TAG_WRITE_NDEF;

typedef struct {
    unsigned int action;          /* Action, please refer ENUM of EM_ACTION*/
    unsigned int supporttype;     /* supporttype, please refer BITMAP of EM_ALS_READER_M_TYPE*/
    unsigned int typeA_datarate;  /* TypeA,datarate, please refer BITMAP of EM_ALS_READER_M_SPDRATE*/
    unsigned int typeB_datarate;  /* TypeB,datarate, please refer BITMAP of EM_ALS_READER_M_SPDRATE*/
    unsigned int typeV_datarate;  /* TypeV,datarate, please refer BITMAP of EM_ALS_READER_M_SPDRATE*/
    unsigned int typeF_datarate;  /* TypeF,datarate, please refer BITMAP of EM_ALS_READER_M_SPDRATE*/
    unsigned int typeV_subcarrier;/* 0: subcarrier, 1 :dual subcarrier*/
//	unsigned int typeV_codingmode;/*0:1 out of 4, 1: 1 out of 256*/
} NFC_EM_ALS_READERM_REQ_S;

typedef struct {
    int  result;          /* 0:Success,Tag connected, 1: Fail, 2:Tag disconnected*/
    unsigned int isNDEF;          /* 1:NDEF, 0: Non-NDEF*/
    unsigned int UidLen;
    unsigned char  Uid[32];
} NFC_EM_ALS_READERM_NTF_S;

typedef struct {
    int  result;          /* 0:Success, 1: Fail,*/
} NFC_EM_ALS_READERM_CNF_S;

typedef struct {
    int  action;          /* Action, please refer ENUM of EM_OPT_ACTION*/   
    NFC_TAG_WRITE_NDEF ndef_write;
} NFC_EM_ALS_READERM_OPT_REQ_S;

typedef struct {
	//   NFC_NDEF_TYPE ndef_type;
	unsigned int   length;
	unsigned int ndef_type;
	unsigned char  recordId[32];
	unsigned char  lang[3];
	unsigned char  recordFlags;
	unsigned char  recordTnf;
	unsigned char  data[512];
} NFC_TAG_READ_NDEF;

typedef struct {
    unsigned int  result;          /* 0:Success,1:Fail*/
    NFC_TAG_READ_NDEF ndef_read;
} NFC_EM_ALS_READERM_OPT_CNF_S;

/* --------------------------------------------------------*/
/* P2P_MODE_RELATED                                        */
/* --------------------------------------------------------*/
typedef struct {
    unsigned int action;          /* Action, please refer ENUM of EM_ACTION*/
    unsigned int supporttype;     /* supporttype, please refer BITMAP of EM_ALS_READER_M_TYPE*/
    unsigned int typeA_datarate;  /* TypeA,datarate, please refer BITMAP of EM_ALS_READER_M_SPDRATE*/
    unsigned int typeF_datarate;  /* TypeV,datarate, please refer BITMAP of EM_ALS_READER_M_SPDRATE*/
    unsigned int mode;            /* BITMAPS bit0: Passive mode, bit1: Active mode, please refer BITMAP of EM_P2P_MODE*/
    unsigned int role;            /* BITMAPS bit0: Initator, bit1: Target, please refer BITMAP of EM_P2P_ROLE*/
    unsigned int isDisableCardM;  /* 0: , 1: disable card mode*/
} NFC_EM_ALS_P2P_REQ_S;

typedef struct {
    int  link_status;     /* 1:llcp link is up,0:llcp link is down*/
    //UINT32  datalen;
    //UINT8 data[256];
} NFC_EM_ALS_P2P_NTF_S;

typedef struct {
    int  result;          /* 0:Success,1:Fail*/
} NFC_EM_ALS_P2P_CNF_S;

/* -------------------------------------------------------- */
/* CARD_MODE_RELATED                                        */
/* -------------------------------------------------------- */
typedef struct {
	
	unsigned int seid;
	unsigned int status;
	unsigned int type;
	unsigned int connecttype;
	unsigned int lowpowermode;
	unsigned int bpf;
	
} mtk_nfc_tool_se_info;

typedef struct {
	
	unsigned int status;
	mtk_nfc_tool_se_info SeInfor[MTK_NFC_MAX_SE_NUM];
	unsigned char SeCount;
	
} NFC_EM_SE_GET_LIST;


typedef struct {
    unsigned int action;          /* Action, please refer ENUM of EM_ACTION*/
    unsigned int SWNum;           /* SWNum, please refer BITMAP of EM_ALS_CARD_M_SW_NUM*/
    unsigned int supporttype;     /* supporttype, please refer BITMAP of EM_ALS_READER_M_TYPE*/
    unsigned int fgvirtualcard;   /* 1:enable virtual card, 0:disable virtual card(default)   */
} NFC_EM_ALS_CARDM_REQ_S;

typedef struct {
    int  result;          /*0:Success,1:Fail*/
} NFC_EM_ALS_CARDM_CNF_S;

/* -------------------------------------------------------- */
/* POLLING_MODE_RELATED                                     */
/* -------------------------------------------------------- */
typedef struct {
    unsigned int action;          /* Action, please refer ENUM of EM_ACTION*/
    unsigned int phase;           /* 0:Listen phase, 1:Pause phase*/
    unsigned int Period;
    unsigned int enablefunc;      /* enablefunc, please refer BITMAP of EM_ENABLE_FUNC*/
    NFC_EM_ALS_P2P_REQ_S     p2pM;
    NFC_EM_ALS_CARDM_REQ_S   cardM;
    NFC_EM_ALS_READERM_REQ_S readerM;
} NFC_EM_POLLING_REQ_S;

typedef struct {
    int  result;          /* 0:Success,1:Fail*/
} NFC_EM_POLLING_CNF_S;

typedef union {
    NFC_EM_ALS_P2P_NTF_S     p2p;
    NFC_EM_ALS_CARDM_CNF_S   card;
    NFC_EM_ALS_READERM_NTF_S reader;
} NFC_EM_POLLING_FUNC_NTF_S;

typedef struct {
    int detecttype;       /* enablefunc, please refer ENUM of EM_ENABLE_FUNC*/
    NFC_EM_POLLING_FUNC_NTF_S ntf;
} NFC_EM_POLLING_NTF_S;

/* -------------------------------------------------------- */
/* TX carrier signal                                        */
/* -------------------------------------------------------- */
typedef struct {
    unsigned int action;          /* Action, please refer ENUM of EM_ACTION*/
} NFC_EM_TX_CARR_ALS_ON_REQ_S;

typedef struct {
    unsigned int result;          /* 0:Success,1:Fail*/
} NFC_EM_TX_CARR_ALS_ON_CNF_S;

/* -------------------------------------------------------- */
/* CARD_MODE_RELATED                                        */
/* -------------------------------------------------------- */

typedef struct {
    unsigned int action;          /* Action, please refer ENUM of EM_ACTION*/
    unsigned int supporttype;     /* supporttype, please refer BITMAP of EM_ALS_READER_M_TYPE*/
    //UINT32 typeA_datarate;  /* TypeA,datarate, please refer BITMAP of EM_ALS_READER_M_SPDRATE*/
    //UINT32 typeB_datarate;  /* TypeB,datarate, please refer BITMAP of EM_ALS_READER_M_SPDRATE*/
    unsigned int typeF_datarate;  /* TypeF,datarate, please refer BITMAP of EM_ALS_READER_M_SPDRATE*/
} NFC_EM_VIRTUAL_CARD_REQ_S;

typedef struct {
    unsigned int result;          /* 0:Success,1:Fail*/
} NFC_EM_VIRTUAL_CARD_CNF_S;

/* --------------------------------------------------------*/
/* PNFC command                                            */
/* --------------------------------------------------------*/
typedef struct {
    unsigned int   action;          /* Action, please refer ENUM of EM_ACTION*/
    unsigned int   datalen;
    unsigned char  data[256];
} NFC_EM_PNFC_RAW_REQ_S;

typedef struct  
{
	NFC_EM_PNFC_RAW_REQ_S pnfc_req;
} NFC_EM_PNFC_REQ_S;

typedef struct {
    unsigned int result;          /* 0:Success,1:Fail*/
    unsigned int datalen;
    unsigned char  data[256];
} NFC_EM_PNFC_CNF_S;


/* --------------------------------------------------------*/
/* Version                                                 */
/* --------------------------------------------------------*/

typedef struct {
    unsigned short fw_ver;
    unsigned short hw_ver;
    char   mw_ver[VERSION_MW];
} NFC_SW_VERSION_CNF_S;

/* --------------------------------------------------------*/
/* HW Test Tool Version                                                 */
/* --------------------------------------------------------*/

typedef struct {
	unsigned int version;
} NFC_META_CHIP_VER_CNF_S;

/* --------------------------------------------------------*/
/* Option setting                                          */
/* --------------------------------------------------------*/
typedef struct
{
    unsigned short   forceDownLoad; 
    unsigned short   TagAutoPresenceChk; 
} NFC_TEST_MODE_SETTING_REQ_S;

typedef struct
{
    int result;
} NFC_TEST_MODE_SETTING_CNF_S;

/* --------------------------------------------------------*/
/* Loopback set                                            */
/* --------------------------------------------------------*/
typedef struct
{
    char   action;
} NFC_LOOPBACK_TEST_REQ_S;

typedef struct
{
    int result;
} NFC_LOOPBACK_TEST_CNF_S;

/* --------------------------------------------------------*/
/* SWP Test                                                */
/* --------------------------------------------------------*/
typedef struct { 
    int  action;
	int  SEmap;
} NFC_FM_SWP_TEST_REQ_S;

typedef struct {
	int result;
} NFC_FM_SWP_TEST_CNF_S;
//  NFC: Callback function definition
//typedef void (__stdcall * NFC_DISCOVERY_CB)(const NFC_DISCOVERY_CNF * pDisCnf, const short token, void *usrData);

typedef void (__stdcall *META_NFC_NOTIFY_CNF)(const NFC_EM_ALS_READERM_NTF_S *cnf);
typedef void (__stdcall *META_NFC_P2P_NOTIRY)(const NFC_EM_ALS_P2P_NTF_S *p2p_cnf);
typedef void (__stdcall *META_NFC_POOLINGLOOP_NOTIFY)(const NFC_EM_POLLING_NTF_S *pooling_loop_cnf);

//  NFC: API declaration
META_RESULT  __stdcall SP_META_NFC_Setting(unsigned int  ms_timeout, NFC_SETTING_REQ_S * pSetReq, NFC_SETTING_CNF_S * pSetCnf);
META_RESULT  __stdcall SP_META_NFC_Setting_r(const int meta_handle, unsigned int  ms_timeout, NFC_SETTING_REQ_S * pSetReq, NFC_SETTING_CNF_S * pSetCnf);
META_RESULT  __stdcall SP_META_NFC_RegNotify(unsigned int  ms_timeout, NFC_REGNOTIFY_REQ_S * pRegReq, NFC_REGNOTIFY_CNF_S * pRegCnf);
META_RESULT  __stdcall SP_META_NFC_RegNotify_r(const int meta_handle, unsigned int  ms_timeout, NFC_REGNOTIFY_REQ_S * pRegReq, NFC_REGNOTIFY_CNF_S * pRegCnf);
//META_RESULT  __stdcall SP_META_NFC_SecureElement(unsigned int  ms_timeout, NFC_SECURE_REQ_S * pSecReq);
//META_RESULT  __stdcall SP_META_NFC_SecureElement_r(const int meta_handle, unsigned int  ms_timeout, NFC_SECURE_REQ_S * pSecReq);
META_RESULT  __stdcall SP_META_NFC_SecureElement(unsigned int  ms_timeout, NFC_SECURE_REQ_S * pSecReq , NFC_SECURE_CNF_S * pSecCnf);
META_RESULT  __stdcall SP_META_NFC_SecureElement_r(const int meta_handle, unsigned int  ms_timeout, NFC_SECURE_REQ_S * pSecReq ,NFC_SECURE_CNF_S * pSecCnf);
//META_RESULT  __stdcall SP_META_NFC_Discovery(unsigned int  ms_timeout, const NFC_DISCOVERY_CB cb, short *token, void *usrData);
//META_RESULT  __stdcall SP_META_NFC_Discovery_r(const int meta_handle, unsigned int  ms_timeout, const NFC_DISCOVERY_CB cb, short *token, void *usrData);
//META_RESULT  __stdcall SP_META_NFC_Discovery(unsigned int  ms_timeout, NFC_DISCOVERY_REQ * pDisReq, const NFC_DISCOVERY_CB cb, short *token, void *usrData);
//META_RESULT  __stdcall SP_META_NFC_Discovery_r(const int meta_handle, unsigned int  ms_timeout, NFC_DISCOVERY_REQ * pDisReq, const NFC_DISCOVERY_CB cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_NFC_Discovery(unsigned int  ms_timeout, NFC_DISCOVERY_REQ_S * pDisReq, NFC_DISCOVERY_CNF_S * pDisCnf);
META_RESULT  __stdcall SP_META_NFC_Discovery_r(const int meta_handle, unsigned int  ms_timeout, NFC_DISCOVERY_REQ_S * pDisReq, NFC_DISCOVERY_CNF_S * pDisCnf);
META_RESULT  __stdcall SP_META_NFC_TagRead(unsigned int  ms_timeout, NFC_TAGREAD_REQ_S * pTagReadReq, NFC_TAGREAD_CNF_S * pTagReadCnf);
META_RESULT  __stdcall SP_META_NFC_TagRead_r(const int meta_handle, unsigned int  ms_timeout, NFC_TAGREAD_REQ_S * pTagReadReq, NFC_TAGREAD_CNF_S * pTagReadCnf);
META_RESULT  __stdcall SP_META_NFC_TagWrite(unsigned int  ms_timeout, NFC_TAGWRITE_REQ_S * pTagWriteReq, NFC_TAGWRITE_CNF_S * pTagWriteCnf);
META_RESULT  __stdcall SP_META_NFC_TagWrite_r(const int meta_handle, unsigned int  ms_timeout, NFC_TAGWRITE_REQ_S * pTagWriteReq, NFC_TAGWRITE_CNF_S * pTagWriteCnf);
META_RESULT  __stdcall SP_META_NFC_TagDisconnect(unsigned int  ms_timeout, NFC_TAGDISCONNECT_REQ_S * pDisReq,NFC_TAGDISCONNECT_CNF_S * pDisCnf);
META_RESULT  __stdcall SP_META_NFC_TagDisconnect_r(const int meta_handle, unsigned int  ms_timeout, NFC_TAGDISCONNECT_REQ_S * pDisReq,NFC_TAGDISCONNECT_CNF_S * pDisCnf);
META_RESULT  __stdcall SP_META_NFC_TagFormatNDEF(unsigned int  ms_timeout, NFC_TAGFORMAT2NDEF_REQ_S * pFormatReq, NFC_TAGFORMAT2NDEF_CNF_S * pFormatCnf);
META_RESULT  __stdcall SP_META_NFC_TagFormatNDEF_r(const int meta_handle, unsigned int  ms_timeout, NFC_TAGFORMAT2NDEF_REQ_S * pFormatReq, NFC_TAGFORMAT2NDEF_CNF_S * pFormatCnf);
META_RESULT  __stdcall SP_META_NFC_TagRawComm(unsigned int  ms_timeout, NFC_TAGRAWCOMM_REQ_S * pRawReq , NFC_TAGRAWCOMM_CNF_S * pRawCnf);
META_RESULT  __stdcall SP_META_NFC_TagRawComm_r(const int meta_handle, unsigned int  ms_timeout, NFC_TAGRAWCOMM_REQ_S * pRawReq , NFC_TAGRAWCOMM_CNF_S * pRawCnf);
META_RESULT  __stdcall SP_META_NFC_P2PComm(unsigned int  ms_timeout, NFC_P2PCOMM_REQ_S * pP2PReq,NFC_P2PCOMM_CNF_S * pP2PCnf);
META_RESULT  __stdcall SP_META_NFC_P2PComm_r(const int meta_handle, unsigned int  ms_timeout, NFC_P2PCOMM_REQ_S * pP2PReq,NFC_P2PCOMM_CNF_S * pP2PCnf);
META_RESULT  __stdcall SP_META_NFC_RDComm(unsigned int  ms_timeout, NFC_RDCOMM_REQ_S * pRDReq,NFC_RDCOMM_CNF_S * pRDCnf);
META_RESULT  __stdcall SP_META_NFC_RDComm_r(const int meta_handle, unsigned int  ms_timeout, NFC_RDCOMM_REQ_S * pRDReq,NFC_RDCOMM_CNF_S * pRDCnf);
META_RESULT  __stdcall SP_META_NFC_TxAlwaysOn(unsigned int  ms_timeout, NFC_TXALWAYS_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_TxAlwaysOn_r(const int meta_handle, unsigned int  ms_timeout, NFC_TXALWAYS_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_TxAlwaysOnWOACK(unsigned int  ms_timeout, NFC_TXALWAYS_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_TxAlwaysOnWOACK_r(const int meta_handle, unsigned int  ms_timeout, NFC_TXALWAYS_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
//META_RESULT  __stdcall SP_META_NFC_CardEmulationMode(unsigned int  ms_timeout, NFC_CARDEMULATION_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
//META_RESULT  __stdcall SP_META_NFC_CardEmulationMode_r(const int meta_handle, unsigned int  ms_timeout, NFC_CARDEMULATION_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_ReaderModeTest(unsigned int  ms_timeout, NFC_SCRIPT_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_ReaderModeTest_r(const int meta_handle, unsigned int  ms_timeout, NFC_SCRIPT_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_P2PModeTest(unsigned int  ms_timeout, NFC_SCRIPT_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_P2PModeTest_r(const int meta_handle, unsigned int  ms_timeout, NFC_SCRIPT_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_SWPSelfTest(unsigned int  ms_timeout, NFC_SCRIPT_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_SWPSelfTest_r(const int meta_handle, unsigned int  ms_timeout, NFC_SCRIPT_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_AntennaSelfTest(unsigned int  ms_timeout, NFC_SCRIPT_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_AntennaSelfTest_r(const int meta_handle, unsigned int  ms_timeout, NFC_SCRIPT_REQ_S * pScriptReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_TagUidRW(unsigned int  ms_timeout, NFC_SCRIPTUID_REQ_S * pUidReq, NFC_SCRIPTUID_CNF_S * pUidCnf);
META_RESULT  __stdcall SP_META_NFC_TagUidRW_r(const int meta_handle, unsigned int  ms_timeout, NFC_SCRIPTUID_REQ_S * pUidReq, NFC_SCRIPTUID_CNF_S * pUidCnf);
META_RESULT  __stdcall SP_META_NFC_CardModeTest(unsigned int  ms_timeout, NFC_CARDMODETEST_REQ_S * pCardModeReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_CardModeTest_r(const int meta_handle, unsigned int  ms_timeout, NFC_CARDMODETEST_REQ_S * pCardModeReq, NFC_SCRIPT_CNF_S * pScriptCnf);
META_RESULT  __stdcall SP_META_NFC_Em_Als_Reader_Mode(unsigned int  ms_timeout, NFC_CARDMODETEST_REQ_S * pEmAlsReadermReq, NFC_EM_ALS_READERM_CNF_S * pEmAlsReadermCnf, META_NFC_NOTIFY_CNF nfc_c,int action);
META_RESULT  __stdcall SP_META_NFC_Em_Als_Reader_Mode_r(const int meta_handle, unsigned int  ms_timeout, NFC_EM_ALS_READERM_REQ_S * pEmAlsReadermReq, NFC_EM_ALS_READERM_CNF_S * pEmAlsReadermCnf, META_NFC_NOTIFY_CNF nfc_c,int action);
META_RESULT  __stdcall SP_META_NFC_Em_Als_Reader_Mode_OPT_r(const int meta_handle, unsigned int  ms_timeout, NFC_EM_ALS_READERM_OPT_REQ_S * pEmAlsReadermOptReq,NFC_EM_ALS_READERM_OPT_CNF_S * pEmAlsReadermOptCnf);
META_RESULT  __stdcall SP_META_NFC_Em_Als_Reader_Mode_OPT(unsigned int  ms_timeout, NFC_EM_ALS_READERM_OPT_REQ_S * pEmAlsReadermOptReq, NFC_EM_ALS_READERM_OPT_CNF_S * pEmAlsReadermOptCnf);
META_RESULT  __stdcall SP_META_NFC_Em_Als_P2P_Mode_r(const int meta_handle, unsigned int  ms_timeout, NFC_EM_ALS_P2P_REQ_S * pEmAlsP2PmReq, NFC_EM_ALS_P2P_CNF_S * pEmAlsP2PmCnf, META_NFC_P2P_NOTIRY nfc_cb);
META_RESULT  __stdcall SP_META_NFC_Em_Als_P2P_Mode(unsigned int  ms_timeout, NFC_EM_ALS_P2P_REQ_S * pEmAlsP2PmReq, NFC_EM_ALS_P2P_CNF_S * pEmAlsP2PmCnf, META_NFC_P2P_NOTIRY nfc_cb);
META_RESULT  __stdcall SP_META_NFC_CardMode_SetSE_r(const int meta_handle, unsigned int  ms_timeout, NFC_EM_SE_GET_LIST * pCardModeSetSECnf);
META_RESULT  __stdcall SP_META_NFC_CardMode_SetSE(unsigned int  ms_timeout, NFC_EM_SE_GET_LIST * pCardModeSetSECnf);
META_RESULT  __stdcall SP_META_NFC_CardMode_r(const int meta_handle, unsigned int  ms_timeout, NFC_EM_ALS_CARDM_REQ_S * pCardModeReq, NFC_EM_ALS_CARDM_CNF_S * pCardModeCnf);
META_RESULT  __stdcall SP_META_NFC_CardMode(unsigned int  ms_timeout,  NFC_EM_ALS_CARDM_REQ_S * pCardModeReq, NFC_EM_ALS_CARDM_CNF_S * pCardModeCnf);
META_RESULT  __stdcall SP_META_NFC_TX_Carrier_Signal_AlsOn_r(const int meta_handle, unsigned int  ms_timeout, NFC_EM_TX_CARR_ALS_ON_REQ_S * pTxCarrierAlsOnReq, NFC_EM_TX_CARR_ALS_ON_CNF_S * pTxCarrierAlsOnCnf);
META_RESULT  __stdcall SP_META_NFC_TX_Carrier_Signal_AlsOn(unsigned int  ms_timeout,  NFC_EM_TX_CARR_ALS_ON_REQ_S * pTxCarrierAlsOnReq, NFC_EM_TX_CARR_ALS_ON_CNF_S * pTxCarrierAlsOnCnf);
META_RESULT  __stdcall SP_META_NFC_Virtural_Card_Func_r(const int meta_handle, unsigned int  ms_timeout, NFC_EM_VIRTUAL_CARD_REQ_S * pVirtualCardFuncReq, NFC_EM_VIRTUAL_CARD_CNF_S * pVirtualCardFuncCnf);
META_RESULT  __stdcall SP_META_NFC_Virtural_Card_Func(unsigned int  ms_timeout,  NFC_EM_VIRTUAL_CARD_REQ_S * pVirtualCardFuncReq, NFC_EM_VIRTUAL_CARD_CNF_S * pVirtualCardFuncCnf);
META_RESULT  __stdcall SP_META_NFC_PNFC_COMMAND_r(const int meta_handle, unsigned int  ms_timeout, NFC_EM_PNFC_REQ_S * pPNFCCommandReq, NFC_EM_PNFC_CNF_S * pPNFCCommandCnf);
META_RESULT  __stdcall SP_META_NFC_PNFC_COMMAND(unsigned int  ms_timeout,  NFC_EM_PNFC_REQ_S * pPNFCCommandReq, NFC_EM_PNFC_CNF_S * pPNFCCommandCnf);
META_RESULT  __stdcall SP_META_NFC_VERSION_QUERY_r(const int meta_handle, unsigned int  ms_timeout, NFC_SW_VERSION_CNF_S * pVersionQueryCnf);
META_RESULT  __stdcall SP_META_NFC_VERSION_QUERY(unsigned int  ms_timeout, NFC_SW_VERSION_CNF_S * pVersionQueryCnf);
META_RESULT  __stdcall SP_META_NFC_Option_r(const int meta_handle, unsigned int  ms_timeout, NFC_TEST_MODE_SETTING_REQ_S * pOptionSettingReq, NFC_TEST_MODE_SETTING_CNF_S * pOptionSettingCnf);
META_RESULT  __stdcall SP_META_NFC_Option(unsigned int  ms_timeout,  NFC_TEST_MODE_SETTING_REQ_S * pOptionSettingReq, NFC_TEST_MODE_SETTING_CNF_S * pOptionSettingCnf);
META_RESULT  __stdcall SP_META_NFC_Loopback_Test_r(const int meta_handle, unsigned int  ms_timeout, NFC_LOOPBACK_TEST_REQ_S * pLoopbackTestReq, NFC_LOOPBACK_TEST_CNF_S * pLoopbackTestCnf);
META_RESULT  __stdcall SP_META_NFC_Loopback_Test(unsigned int  ms_timeout,  NFC_LOOPBACK_TEST_REQ_S * pLoopbackTestReq, NFC_LOOPBACK_TEST_CNF_S * pLoopbackTestCnf);
META_RESULT  __stdcall SP_META_NFC_SWP_Test_r(const int meta_handle, unsigned int  ms_timeout, NFC_FM_SWP_TEST_REQ_S * pSWPTestReq, NFC_FM_SWP_TEST_CNF_S * pSWPTestCnf);
META_RESULT  __stdcall SP_META_NFC_SWP_Test(unsigned int  ms_timeout,  NFC_FM_SWP_TEST_REQ_S * pSWPTestReq, NFC_FM_SWP_TEST_CNF_S * pSWPTestCnf);
META_RESULT  __stdcall SP_META_NFC_PollingLoopMode_r(const int meta_handle, unsigned int  ms_timeout, NFC_EM_POLLING_REQ_S * pPollingLoopModeReq, NFC_EM_POLLING_CNF_S * pPollingLoopModeCnf,META_NFC_POOLINGLOOP_NOTIFY poolingloopcb);
META_RESULT  __stdcall SP_META_NFC_PollingLoopMode(unsigned int  ms_timeout, NFC_EM_POLLING_REQ_S * pPollingLoopModeReq, NFC_EM_POLLING_CNF_S * pPollingLoopModeCnf, META_NFC_POOLINGLOOP_NOTIFY poolingloopcb);
META_RESULT  __stdcall SP_META_NFC_HW_Version_Test_r(const int meta_handle, unsigned int  ms_timeout, NFC_META_CHIP_VER_CNF_S * pHWVerTestCnf);
META_RESULT  __stdcall SP_META_NFC_HW_Version_Test(unsigned int  ms_timeout, NFC_META_CHIP_VER_CNF_S * pHWVerTestCnf);


// CCT

/*
typedef struct
{
	char sensor_prefix_name[64];
}CCT_Dual_Dev_ISP_camera_sensor_prefix_name_struct;

typedef struct
{
	char lens_prefix_name[64];
}CCT_Dual_Dev_ISP_camera_lens_prefix_name_struct; 
*/

//------------------------------------------------------------------------------
// Capture Related Functions                                                    
//------------------------------------------------------------------------------

typedef enum {
	CAMERA_SUB_SAMPLE_1_1 =	1,	// 1:1 
	CAMERA_SUB_SAMPLE_1_2 = 2,	// 1:2 
	CAMERA_SUB_SAMPLE_1_4 = 4,	// 1:4 
	CAMERA_SUB_SAMPLE_1_8 = 8	// 1:8 
} CAMERA_SUB_SAMPLE_MODE;

typedef enum {
	 OUTPUT_RAW_8BITS = 0
	,OUTPUT_YUV
	,OUTPUT_JPEG
	,OUTPUT_RGB888
	,OUTPUT_RAW_10BITS
	,OUTPUT_EXT_RAW_8BITS
	,OUTPUT_EXT_RAW_10BITS
	,OUTPUT_EXT_YUV
} CAMERA_OUTPUT_FORMAT;

typedef enum {
	BAYER_PTN_GR = 0,
	BAYER_PTN_R,
	BAYER_PTN_B,
	BAYER_PTN_GB
} CAMERA_BAYER_PATTERN;

typedef void (*CALLBACK_META_CCT_CAPTURE)(unsigned char finished_percentage, unsigned int received_bytes, unsigned int total_bytes, void *cb_arg);

typedef struct {
	// shot screen range (position in pixel) 
	unsigned short	nLeftPos;	// 0~N 
	unsigned short	nTopPos;	// 0~N 
	unsigned short	nWidth;
	unsigned short	nHeight;
} CCT_CaptureScreen_T;

typedef struct {

	// shot screen range (position in pixel) 
	CCT_CaptureScreen_T			ShotScreen;

	// RAW doesn't support subsample 
	CAMERA_SUB_SAMPLE_MODE		SubSample; 

	CAMERA_OUTPUT_FORMAT		OutputFormat;

	CALLBACK_META_CCT_CAPTURE	cb;
	void *cb_arg;

} CCT_Capture_Req;

typedef struct {

	// actual shot screen (position in pixel), the original shot screen might be truncated if out of range 
	CCT_CaptureScreen_T			ShotScreen;

	// the bayer pattern of left-top start pixel 
	CAMERA_BAYER_PATTERN		BayerPattern;

	// actual image data buffer 
	unsigned short	nOutputBuf_Width;
	unsigned short	nOutputBuf_Height;
	char 	*pOutputBuf;		// don't forget to free it by calling META_CCT_FreeCaptureImage 

	// NOTICE! buffer size will be applied different formulas according to output format 
	// For RAW 8BITS format, the size will be nOutputBuf_Width x nOutputBuf_Height bytes 
	// For RAW 10BITS format, the size will be nOutputBuf_Width x nOutputBuf_Height x 2 bytes 
	// For YUV format, the size will be nOutputBuf_Width x nOutputBuf_Height x 4 bytes 
	unsigned int	nOutputBuf_Size;

} CCT_Capture_Result;

typedef struct
{
    unsigned int packetNO;
    unsigned int isEnd; 
    unsigned int bufLength;
    unsigned char DebugBuf[2048];
} CCT_Strobe_DumpData;


META_RESULT __stdcall SP_META_CCT_PreviewOnLCD_Ex(bool bEnablePreview);
META_RESULT __stdcall SP_META_CCT_PreviewOnLCD_Ex_r(const int meta_handle, bool bEnablePreview);
META_RESULT __stdcall SP_META_CCT_SubPreviewOnLCD(bool bEnablePreview);
META_RESULT __stdcall SP_META_CCT_SubPreviewOnLCD_r(const int meta_handle, bool bEnablePreview);
META_RESULT __stdcall SP_META_CCT_PhotoFlashControl();
META_RESULT __stdcall SP_META_CCT_PhotoFlashControl_r(const int meta_handle);

META_RESULT __stdcall SP_META_CCT_Init(bool bEnableUSBCOM, unsigned int &sensorID);
META_RESULT __stdcall SP_META_CCT_Init_r(const int meta_handle, bool bEnableUSBCOM, unsigned int &sensorID);
META_RESULT __stdcall SP_META_CCT_SingleShotCaptureEx(unsigned int DeviceId, const CCT_Capture_Req  *req, CCT_Capture_Result  *p_result);
META_RESULT __stdcall SP_META_CCT_SingleShotCaptureEx_r(const int meta_handle, unsigned int DeviceId, const CCT_Capture_Req  *req, CCT_Capture_Result  *p_result);

META_RESULT __stdcall SP_META_CCT_StrobeCalibrationStart(unsigned int  ms_timeout);
META_RESULT __stdcall SP_META_CCT_StrobeCalibrationStart_r(const int meta_handle, unsigned int  ms_timeout);

META_RESULT __stdcall SP_META_CCT_StrobeGetCalibrationStatus(unsigned int  ms_timeout, unsigned int *cali_status);//out: cali_status //0: End_Success 1:End_Fail 2: Going
META_RESULT __stdcall SP_META_CCT_StrobeGetCalibrationStatus_r(const int meta_handle, unsigned int  ms_timeout, unsigned int *cali_status);

META_RESULT __stdcall SP_META_CCT_StrobeGetCalibrationDump(unsigned int  ms_timeout, CCT_Strobe_DumpData *pCnf);
META_RESULT __stdcall SP_META_CCT_StrobeGetCalibrationDump_r(const int meta_handle, unsigned int  ms_timeout, CCT_Strobe_DumpData *pCnf);

META_RESULT __stdcall SP_META_CCT_StrobeCalibrationStop(unsigned int  ms_timeout);
META_RESULT __stdcall SP_META_CCT_StrobeCalibrationStop_r(const int meta_handle, unsigned int  ms_timeout);




// 2011-11-10 Wei Fang add


META_RESULT __stdcall SP_META_GetDynamicUSBComPortExWithFilter(unsigned int ms_scan_timeout, unsigned short *com_port, int *p_scanstop, char *info, int length, char *valid_usb_info);
META_RESULT __stdcall SP_META_GetDynamicUSBComPortExWithFilter_r(const int meta_handle, unsigned int ms_scan_timeout, unsigned short *com_port, int *p_scanstop, char *info, int length, char *valid_usb_info);

//META_RESULT __stdcall SP_META_GetDynamicUSBComPortWithPrefix_r(const int meta_handle, unsigned int ms_scan_timeout, unsigned short *com_port, int *p_scanstop, const char* prefix);
//META_RESULT __stdcall SP_META_GetDynamicUSBComPortWithFilter_r(const int meta_handle, unsigned int ms_scan_timeout, unsigned short *com_port, int *p_scanstop, char *valid_usb_info);


// EMMC Module



typedef struct
{       
    unsigned char   status;   // The operation whether success , 1 means success
} EMMC_CLEAR_CNF_S;

typedef struct
{       
    unsigned char   sign;   // No means
} EMMC_CLEAR_REQ_S;

typedef struct
{
	unsigned char   sign;   // No means
} EMMC_FORMAT_TCARD_REQ_S;

typedef struct
{       
    unsigned char   status;   // The operation whether success , 1 means success
} EMMC_FORMAT_TCARD_CNF_S;

typedef struct 
{       
    unsigned char   status;   // The operation whether success , 1 means success
}EMMC_CLEAR_WITHOUT_TCARD_CNF_S;

typedef struct 
{
    unsigned char   sign;   // No means
}EMMC_CLEAR_WITHOUT_TCARD_REQ_S;




META_RESULT __stdcall SP_META_ClearValue_r(const int meta_handle, unsigned int  ms_timeout, EMMC_CLEAR_CNF_S *pCnf);
META_RESULT __stdcall SP_META_ClearValue(unsigned int  ms_timeout, EMMC_CLEAR_CNF_S *pCnf);

META_RESULT __stdcall SP_META_EMMC_FormatTCard_r(const int meta_handle, unsigned int  ms_timeout, EMMC_FORMAT_TCARD_CNF_S *pCnf);
META_RESULT __stdcall SP_META_EMMC_FormatTCard(unsigned int  ms_timeout, EMMC_FORMAT_TCARD_CNF_S *pCnf);

META_RESULT __stdcall SP_META_ClearValue_WithoutTCard_r(const int meta_handle, unsigned int  ms_timeout, EMMC_CLEAR_WITHOUT_TCARD_CNF_S *pCnf);
META_RESULT __stdcall SP_META_ClearValue_WithoutTCard(unsigned int  ms_timeout, EMMC_CLEAR_WITHOUT_TCARD_CNF_S *pCnf);

META_RESULT __stdcall SP_META_ClearValueEx_r(const int meta_handle, unsigned int  ms_timeout, EMMC_CLEAR_CNF_S *pCnf);
META_RESULT __stdcall SP_META_ClearValueEx(unsigned int  ms_timeout, EMMC_CLEAR_CNF_S *pCnf);

META_RESULT __stdcall SP_META_ClearValue_WithoutTCardEx_r(const int meta_handle, unsigned int  ms_timeout, EMMC_CLEAR_WITHOUT_TCARD_CNF_S *pCnf);
META_RESULT __stdcall SP_META_ClearValue_WithoutTCardEx(unsigned int  ms_timeout, EMMC_CLEAR_WITHOUT_TCARD_CNF_S *pCnf);


// ENCRYPTED

typedef struct
{       
    unsigned char  sign;   // No means
} CRYPTFS_QUERYSUPPORT_REQ;

typedef struct
{       
    unsigned char   support;    // 1 means support; 0 means unsupport
} CRYPTFS_QUERYSUPPORT_CNF;

typedef struct
{
   unsigned char pwd[32];
   int  length;
} CRYPTFS_VERITIF_REQ;

typedef struct
{       
    unsigned char match_result;   // 1 means match, 0 means unmatch
} CRYPTFS_VERITIF_CNF;


typedef struct
{       
    unsigned char cfg;   // 0 means to disable 'default encryption', 1 means to enable 'default encryption'
} CRYPTFS_SET_CFG_REQ;

typedef struct
{       
    unsigned char set_cfg_result; // 1 means to set cfg successfully, 0 means that failed to set cfg 
} CRYPTFS_SET_CFG_CNF;


typedef struct
{       
	unsigned char  sign;   // No means
} CRYPTFS_GET_CFG_REQ;

typedef struct
{   
    unsigned char get_cfg_result;    //0 means to disable 'default encryption', 
	                                 //1 means to enable 'default encryption', 
	                                 //'F' means failure that no such cfg or something wrong
} CRYPTFS_GET_CFG_CNF;


META_RESULT __stdcall SP_META_ENCRYPTED_Support(unsigned int  ms_timeout, CRYPTFS_QUERYSUPPORT_CNF *pCnf);
META_RESULT __stdcall SP_META_ENCRYPTED_Support_r(const int meta_handle, unsigned int  ms_timeout, CRYPTFS_QUERYSUPPORT_CNF *pCnf);


META_RESULT __stdcall SP_META_ENCRYPTED_VertifyPwd_r(const int meta_handle, unsigned int  ms_timeout, CRYPTFS_VERITIF_REQ *pReq ,CRYPTFS_VERITIF_CNF *pCnf);
META_RESULT __stdcall SP_META_ENCRYPTED_VertifyPwd(unsigned int  ms_timeout, CRYPTFS_VERITIF_REQ *pReq ,CRYPTFS_VERITIF_CNF *pCnf);

META_RESULT __stdcall SP_META_ENCRYPTED_SetConfig_r(const int meta_handle, unsigned int  ms_timeout, CRYPTFS_SET_CFG_REQ *pReq ,CRYPTFS_SET_CFG_CNF *pCnf);
META_RESULT __stdcall SP_META_ENCRYPTED_SetConfig(unsigned int  ms_timeout, CRYPTFS_SET_CFG_REQ *pReq ,CRYPTFS_SET_CFG_CNF *pCnf);

META_RESULT __stdcall SP_META_ENCRYPTED_GetConfig_r(const int meta_handle, unsigned int  ms_timeout, CRYPTFS_GET_CFG_CNF *pCnf);
META_RESULT __stdcall SP_META_ENCRYPTED_GetConfig(unsigned int  ms_timeout, CRYPTFS_GET_CFG_CNF *pCnf);



//MODEM(DFO)
typedef struct 
{
    unsigned char reserved;   //just reserved
} MODEM_QUERY_INFO_REQ;

typedef struct 
{
    unsigned int modem_number;
    unsigned int modem_id;
} MODEM_QUERY_INFO_CNF;

META_RESULT __stdcall SP_META_MODEM_Query_Info(unsigned int  ms_timeout, MODEM_QUERY_INFO_REQ *pReq, MODEM_QUERY_INFO_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_Query_Info_r(const int meta_handle, unsigned int  ms_timeout, MODEM_QUERY_INFO_REQ *pReq, MODEM_QUERY_INFO_CNF *pCnf);


typedef struct 
{
    unsigned char reserved;   //just reserved
} MODEM_CAPABILITY_LIST_REQ;

typedef enum 
{
	FT_MODEM_SRV_INVALID = 0,
	FT_MODEM_SRV_TST = 1,
    FT_MODEM_SRV_DHL = 2,
	FT_MODEM_SRV_C2K = 3,
	FT_MODEM_SRV_END = 0x0fffffff
}FT_MODEM_SRV;

typedef enum 
{
	FT_MODEM_CH_NATIVE_INVALID = 0,
	FT_MODEM_CH_NATIVE_TST = 1,
    FT_MODEM_CH_TUNNELING = 2,
    FT_MODEM_CH_TUNNELING_IGNORE_CKSM = 3,
	FT_MODEM_CH_NATIVE_C2K = 4,
	FT_MODEM_CH_END = 0x0fffffff
}FT_MODEM_CH_TYPE;

typedef struct 
{
	unsigned int md_service;
    unsigned int ch_type;
    unsigned char reserved;
}MODEM_CAPABILITY; 

typedef struct
{
	MODEM_CAPABILITY modem_cap[8];
}MODEM_CAPABILITY_LIST_CNF; 


META_RESULT __stdcall SP_META_MODEM_Capability(unsigned int  ms_timeout, MODEM_CAPABILITY_LIST_REQ *pReq, MODEM_CAPABILITY_LIST_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_Capability_r(const int meta_handle, unsigned int  ms_timeout, MODEM_CAPABILITY_LIST_REQ *pReq, MODEM_CAPABILITY_LIST_CNF *pCnf);


typedef struct 
{
	unsigned int modem_id;
	unsigned int modem_type;
}MODEM_SET_MODEMTYPE_REQ;

typedef struct 
{
	unsigned char reserved;	
}MODEM_SET_MODEMTYPE_CNF;

META_RESULT __stdcall SP_META_MODEM_Set_ModemType(unsigned int  ms_timeout, MODEM_SET_MODEMTYPE_REQ *pReq,MODEM_SET_MODEMTYPE_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_Set_ModemType_r(const int meta_handle, unsigned int  ms_timeout, MODEM_SET_MODEMTYPE_REQ *pReq, MODEM_SET_MODEMTYPE_CNF *pCnf);

typedef struct 
{
	unsigned int modem_id;
}MODEM_GET_CURRENTMODEMTYPE_REQ;

typedef struct 
{
	unsigned int current_modem_type;
}MODEM_GET_CURENTMODEMTYPE_CNF;

META_RESULT __stdcall SP_META_MODEM_Get_CurrentModemType(unsigned int  ms_timeout, MODEM_GET_CURRENTMODEMTYPE_REQ *pReq,MODEM_GET_CURENTMODEMTYPE_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_Get_CurrentModemType_r(const int meta_handle, unsigned int  ms_timeout, MODEM_GET_CURRENTMODEMTYPE_REQ *pReq, MODEM_GET_CURENTMODEMTYPE_CNF *pCnf);

typedef struct 
{
	unsigned int modem_id;	
}MODEM_QUERY_MDIMGTYPE_REQ;

typedef struct 
{
	unsigned int mdimg_type[16];
}MODEM_QUERY_MDIMGTYPE_CNF;

META_RESULT __stdcall SP_META_MODEM_Query_MDIMGType(unsigned int  ms_timeout, MODEM_QUERY_MDIMGTYPE_REQ *pReq,MODEM_QUERY_MDIMGTYPE_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_Query_MDIMGType_r(const int meta_handle, unsigned int  ms_timeout, MODEM_QUERY_MDIMGTYPE_REQ *pReq, MODEM_QUERY_MDIMGTYPE_CNF *pCnf);


typedef struct 
{
	unsigned char reserved;	
}MODEM_QUERY_DOWNLOAD_STATUS_REQ;


typedef struct 
{
	unsigned int percentage;
	unsigned int status_code;
}MODEM_QUERY_DOWNLOAD_STATUS_CNF;


META_RESULT __stdcall SP_META_MODEM_Query_Download_Status(unsigned int  ms_timeout, MODEM_QUERY_DOWNLOAD_STATUS_REQ *pReq,MODEM_QUERY_DOWNLOAD_STATUS_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_Query_Download_Status_r(const int meta_handle, unsigned int  ms_timeout, MODEM_QUERY_DOWNLOAD_STATUS_REQ *pReq,MODEM_QUERY_DOWNLOAD_STATUS_CNF *pCnf);

typedef struct 
{
	unsigned char modem_index;	
	unsigned char reserved;	
}MODEM_TRIGGER_NATIVE_DOWNLOAD_REQ;

typedef struct 
{
	unsigned char reserved;	
}MODEM_TRIGGER_NATIVE_DOWNLOAD_CNF;

META_RESULT __stdcall SP_META_MODEM_TRIGGER_NATIVE_DOWNLOAD(unsigned int ms_timeout, MODEM_TRIGGER_NATIVE_DOWNLOAD_REQ *pReq, MODEM_TRIGGER_NATIVE_DOWNLOAD_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_TRIGGER_NATIVE_DOWNLOAD_r(const int meta_handle, unsigned int ms_timeout,MODEM_TRIGGER_NATIVE_DOWNLOAD_REQ *pReq, MODEM_TRIGGER_NATIVE_DOWNLOAD_CNF *pCnf);

typedef struct
{
	unsigned char modem_index;
	unsigned char mode;//normal=1, meta=2
}MODEM_REBOOT_REQ;

typedef struct 
{
	unsigned int reserved ;
}MODEM_REBOOT_CNF;

META_RESULT __stdcall SP_META_MODEM_Reboot_Modem(unsigned int  ms_timeout, MODEM_REBOOT_REQ *pReq,MODEM_REBOOT_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_Reboot_Modem_r(const int meta_handle, unsigned int  ms_timeout, MODEM_REBOOT_REQ *pReq, MODEM_REBOOT_CNF *pCnf);

typedef struct
{
	unsigned char modem_index; //reserved
}MODEM_GET_MODEMMODE_REQ;

typedef struct 
{
	unsigned char mode; //normal=1, meta=2
}MODEM_GET_MODEMMODE_CNF;

META_RESULT __stdcall SP_META_MODEM_Get_ModemMode(unsigned int  ms_timeout, MODEM_GET_MODEMMODE_REQ *pReq,MODEM_GET_MODEMMODE_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_Get_ModemMode_r(const int meta_handle, unsigned int  ms_timeout, MODEM_GET_MODEMMODE_REQ *pReq, MODEM_GET_MODEMMODE_CNF *pCnf);

typedef struct
{
	unsigned int modem_id; //reserved, no use
}MODEM_QUERY_MDDBPATH_REQ;

typedef struct 
{
	unsigned char mddb_path[64];
}MODEM_QUERY_MDDBPATH_CNF;

META_RESULT __stdcall SP_META_MODEM_Query_MDDBPath(unsigned int  ms_timeout, MODEM_QUERY_MDDBPATH_REQ *pReq,MODEM_QUERY_MDDBPATH_CNF *pCnf);
META_RESULT __stdcall SP_META_MODEM_Query_MDDBPath_r(const int meta_handle, unsigned int  ms_timeout, MODEM_QUERY_MDDBPATH_REQ *pReq, MODEM_QUERY_MDDBPATH_CNF *pCnf);


typedef struct
{       
    unsigned int action;   //0:disable; 1:enable 
} MODEM_SUPPORT_COMPRESS_REQ;

typedef struct 
{
    unsigned int result;  //0:fail; 1:sucess
} MODEM_SUPPORT_COMPRESS_CNF;

META_RESULT __stdcall SP_META_MODEM_Support_Compress(unsigned int  ms_timeout, MODEM_SUPPORT_COMPRESS_REQ *pReq, MODEM_SUPPORT_COMPRESS_CNF  *pCnf);
META_RESULT __stdcall SP_META_MODEM_Support_Compress_r(const int meta_handle, unsigned int  ms_timeout,  MODEM_SUPPORT_COMPRESS_REQ *pReq, MODEM_SUPPORT_COMPRESS_CNF  *pCnf);

//Set mobile log for meta mode
typedef struct
{
    int reserved;
}SAVE_MOBILE_LOG_REQ;

typedef struct
{
    int drv_status;
}SAVE_MOBILE_LOG_CNF;

META_RESULT __stdcall SP_META_SaveMobileLog(unsigned int ms_timeout,SAVE_MOBILE_LOG_REQ *req, SAVE_MOBILE_LOG_CNF *cnf);
META_RESULT __stdcall SP_META_SaveMobileLog_r(const int meta_handle,unsigned int ms_timeout,SAVE_MOBILE_LOG_REQ *req,SAVE_MOBILE_LOG_CNF *cnf);

//

typedef struct
{
    unsigned int level;
}SET_LOG_LEVEL_REQ;

typedef struct
{
    int reserved;
}SET_LOG_LEVEL_CNF;

META_RESULT __stdcall SP_META_SetLogLevel(unsigned int ms_timeout,SET_LOG_LEVEL_REQ *req, SET_LOG_LEVEL_CNF *cnf);
META_RESULT __stdcall SP_META_SetLogLevel_r(const int meta_handle,unsigned int ms_timeout,SET_LOG_LEVEL_REQ *req,SET_LOG_LEVEL_CNF *cnf);

META_RESULT __stdcall SP_META_SDIOAutoCalibration(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_SDIOAutoCalibration_r(const int meta_handle,unsigned int ms_timeout);

META_RESULT __stdcall SP_META_SDIOCheckCalibration(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_SDIOCheckCalibration_r(const int meta_handle,unsigned int ms_timeout);

META_RESULT __stdcall SP_META_BT_OPEN(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_BT_OPEN_r(const int meta_handle, unsigned int ms_timeout);

META_RESULT __stdcall SP_META_BT_CLOSE(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_BT_CLOSE_r(const int meta_handle, unsigned int ms_timeout);

META_RESULT __stdcall SP_META_WIFI_OPEN(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WIFI_OPEN_r(const int meta_handle, unsigned int ms_timeout);

META_RESULT __stdcall SP_META_WIFI_CLOSE(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_WIFI_CLOSE_r(const int meta_handle, unsigned int ms_timeout);

// Get Sim Card

META_RESULT __stdcall SP_META_GetSimCardNum(unsigned int ms_timeout, unsigned int *number);
META_RESULT __stdcall SP_META_GetSimCardNum_r(const int meta_handle, unsigned int ms_timeout, unsigned int *number);



struct EXTERNAL_SD_CARD_PATH_CNF
{
    unsigned char sd_path[256];
};
/*
META_RESULT __stdcall SP_META_GetExternalSDCardPath(unsigned int ms_timeout, EXTERNAL_SD_CARD_PATH_CNF *cnf);
META_RESULT __stdcall SP_META_GetExternalSDCardPath_r(const int meta_handle,unsigned int ms_timeout, EXTERNAL_SD_CARD_PATH_CNF *cnf);
*/
// HDCP
#define HDCP_KEY_ARRAY_NUMBER 287
struct FILE_CUSTOM_HDCP_KEY_STRUCT
{
    unsigned char HdcpKeyArray[HDCP_KEY_ARRAY_NUMBER];
};

META_RESULT  __stdcall SP_META_NVRAM_Compose_HDCP(const FILE_CUSTOM_HDCP_KEY_STRUCT *param, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_Decompose_HDCP(FILE_CUSTOM_HDCP_KEY_STRUCT *param, const char *buf, const int buf_len);
// This api is not supported in target side

// BT Module 
META_RESULT  __stdcall SP_META_BT_TxPureTest(unsigned int  ms_timeout, BT_HCI_TX_PURE_TEST *snd, META_BT_HCI_TXTEST_CNF cb_tx, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_TxPureTest_r(const int meta_handle, unsigned int  ms_timeout, BT_HCI_TX_PURE_TEST *snd, META_BT_HCI_TXTEST_CNF cb_tx, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_RxTestStart(unsigned int  ms_timeout, META_BT_HCI_RXTEST_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_RxTestStart_r(const int meta_handle, unsigned int  ms_timeout, META_BT_HCI_RXTEST_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_TxPureTest_V2(unsigned int  ms_timeout, BT_HCI_TX_PURE_TEST *snd, META_BT_HCI_TXTEST_V2_CNF cb_txtest, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_TxPureTest_V2_r(const int meta_handle, unsigned int  ms_timeout, BT_HCI_TX_PURE_TEST	*snd, META_BT_HCI_TXTEST_V2_CNF cb_txtest, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_RxTestStart_V2(unsigned int  ms_timeout, META_BT_HCI_RXTEST_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_RxTestStart_V2_r(const int meta_handle, unsigned int ms_timeout, META_BT_HCI_RXTEST_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_RxTestEnd(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_RxTestEnd_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_EnableNvramOnlineUpdate(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_EnableNvramOnlineUpdate_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_BT_DisableNvramOnlineUpdate(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_DisableNvramOnlineUpdate_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_BT_EnablePcmClockSyncSignal(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_EnablePcmClockSyncSignal_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_BT_DisablePcmClockSyncSignal(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_DisablePcmClockSyncSignal_r(const int meta_handle, unsigned int ms_timeout);

// This api is not supported in target side

// BT Module 
META_RESULT  __stdcall SP_META_BT_TxPureTest(unsigned int  ms_timeout, BT_HCI_TX_PURE_TEST *snd, META_BT_HCI_TXTEST_CNF cb_tx, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_TxPureTest_r(const int meta_handle, unsigned int  ms_timeout, BT_HCI_TX_PURE_TEST *snd, META_BT_HCI_TXTEST_CNF cb_tx, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_RxTestStart(unsigned int  ms_timeout, META_BT_HCI_RXTEST_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_RxTestStart_r(const int meta_handle, unsigned int  ms_timeout, META_BT_HCI_RXTEST_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_TxPureTest_V2(unsigned int  ms_timeout, BT_HCI_TX_PURE_TEST *snd, META_BT_HCI_TXTEST_V2_CNF cb_txtest, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_TxPureTest_V2_r(const int meta_handle, unsigned int  ms_timeout, BT_HCI_TX_PURE_TEST	*snd, META_BT_HCI_TXTEST_V2_CNF cb_txtest, void  *cb_arg);
META_RESULT  __stdcall SP_META_BT_RxTestStart_V2(unsigned int  ms_timeout, META_BT_HCI_RXTEST_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_RxTestStart_V2_r(const int meta_handle, unsigned int ms_timeout, META_BT_HCI_RXTEST_CNF cb_rx);
META_RESULT  __stdcall SP_META_BT_RxTestEnd(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_RxTestEnd_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_EnableNvramOnlineUpdate(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_EnableNvramOnlineUpdate_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_BT_DisableNvramOnlineUpdate(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_DisableNvramOnlineUpdate_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_BT_EnablePcmClockSyncSignal(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_EnablePcmClockSyncSignal_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_BT_DisablePcmClockSyncSignal(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_BT_DisablePcmClockSyncSignal_r(const int meta_handle, unsigned int ms_timeout);

// WIFI Module
META_RESULT  __stdcall SP_META_NVRAM_WiFi_MacAddress_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Compose_MacAddress(const WiFi_MacAddress_S  *mac, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Decompose_MacAddress(WiFi_MacAddress_S  *mac, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_DacDcOffset_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Compose_DacDcOffset(const WiFi_DAC_DC_Offset_S  *dac, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Decompose_DacDcOffset(WiFi_DAC_DC_Offset_S  *dac, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_TxPower2400M_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Compose_TxPower2400M(const WiFi_TxPower_2400M_S  *txpwr, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Decompose_TxPower2400M(WiFi_TxPower_2400M_S  *txpwr, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_TxPower5000M_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Compose_TxPower5000M(const WiFi_TxPower_5000M_S  *txpwr, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Decompose_TxPower5000M(WiFi_TxPower_5000M_S  *txpwr, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Compose_ALC_2400M(const WiFi_ALC_2400M_S  *alc, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Decompose_ALC_2400M(WiFi_ALC_2400M_S  *alc, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_ALC_2400M_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_TxALC2400M_Len(int *len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Compose_TxALC2400M(const WiFi_TxALC_2400M_S  *txalc, char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_NVRAM_WiFi_Decompose_TxALC2400M(WiFi_TxALC_2400M_S  *txalc, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_WiFi_Stop(unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_Stop_r(const int meta_handle, unsigned int  ms_timeout);
META_RESULT  __stdcall SP_META_WiFi_ContTx(unsigned int  ms_timeout, const WiFi_TestTx_S *req);
META_RESULT  __stdcall SP_META_WiFi_ContTx_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_TestTx_S *req);
META_RESULT  __stdcall SP_META_WiFi_LocalFrequencyMeasure(unsigned int  ms_timeout, const WiFi_TestTx_S *req);
META_RESULT  __stdcall SP_META_WiFi_LocalFrequencyMeasure_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_TestTx_S *req);
META_RESULT  __stdcall SP_META_WiFi_CarrierSuppressionMeasure(unsigned int  ms_timeout, const WiFi_TestTx_S *req);
META_RESULT  __stdcall SP_META_WiFi_CarrierSuppressionMeasure_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_TestTx_S *req);
META_RESULT  __stdcall SP_META_WiFi_ContPktTx(unsigned int  ms_timeout, const WiFi_TestPktTx_S *req);
META_RESULT  __stdcall SP_META_WiFi_ContPktTx_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_TestPktTx_S *req);
META_RESULT  __stdcall SP_META_WiFi_ContPktTx_Ex(unsigned int  ms_timeout, const WiFi_TestPktTx_Ex_S *req);
META_RESULT  __stdcall SP_META_WiFi_ContPktTx_Ex_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_TestPktTx_Ex_S *req);

//-----------------------------------------------------//
//  WiFi Calibration: WNDRV SET Functions              //
//-----------------------------------------------------//

META_RESULT  __stdcall SP_META_WiFi_SetPowerManagementMode(unsigned int  ms_timeout, const WiFi_PowerManagementMode_E  mode);
META_RESULT  __stdcall SP_META_WiFi_SetPowerManagementMode_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_PowerManagementMode_E  mode);
META_RESULT  __stdcall SP_META_WiFi_ContPktRx(unsigned int  ms_timeout, const WiFi_TestPktRx_S *req);
META_RESULT  __stdcall SP_META_WiFi_ContPktRx_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_TestPktRx_S *req);
META_RESULT  __stdcall SP_META_WiFi_SetRegDomain(unsigned int  ms_timeout, const WiFi_RegDomain_S  *req);
META_RESULT  __stdcall SP_META_WiFi_SetRegDomain_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_RegDomain_S  *req);
META_RESULT  __stdcall SP_META_WiFi_SetDbmToDac(unsigned int  ms_timeout, const WiFi_DBM2DAC_Set_S *req);
META_RESULT  __stdcall SP_META_WiFi_SetDbmToDac_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_DBM2DAC_Set_S *req);
META_RESULT  __stdcall SP_META_WiFi_MACReg32Write(unsigned int  ms_timeout, const WiFi_MACReg32_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_MACReg32Write_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_MACReg32_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_MACReg16Write(unsigned int  ms_timeout, const WiFi_MACReg16_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_MACReg16Write_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_MACReg16_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_BBRegWrite(unsigned int  ms_timeout, const WiFi_BBReg8_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_BBRegWrite_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_BBReg8_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_EEPROM_Write(unsigned int  ms_timeout, const WiFi_EEPROM_S *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_EEPROM_Write_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_EEPROM_S *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_QueryTxStatus(unsigned int  ms_timeout, WiFi_TxStatus_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryTxStatus_r(const int meta_handle, unsigned int  ms_timeout, WiFi_TxStatus_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryTxStatus_Ex(unsigned int  ms_timeout, WiFi_TxStatus_Ex_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryTxStatus_Ex_r(const int meta_handle, unsigned int  ms_timeout, WiFi_TxStatus_Ex_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryRxStatus(unsigned int  ms_timeout, WiFi_RxStatus_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryRxStatus_r(const int meta_handle, unsigned int  ms_timeout, WiFi_RxStatus_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryChannelList(unsigned int  ms_timeout, WiFi_ChannelList_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryChannelList_r(const int meta_handle, unsigned int  ms_timeout, WiFi_ChannelList_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryRxCounter(unsigned int  ms_timeout, WiFi_RxCounter_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryRxCounter_r(const int meta_handle, unsigned int  ms_timeout, WiFi_RxCounter_S *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryDbmToDac(unsigned int  ms_timeout, WiFi_DBM2DAC_Query_S  *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryDbmToDac_r(const int meta_handle, unsigned int  ms_timeout, WiFi_DBM2DAC_Query_S  *cnf);


//-----------------------------------------------------//
//  WiFi Calibration: WNDRV QUERY Functions            //
//-----------------------------------------------------//
META_RESULT  __stdcall SP_META_WiFi_MACReg32Read(unsigned int  ms_timeout, WiFi_MACReg32_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_MACReg32Read_r(const int meta_handle, unsigned int  ms_timeout, WiFi_MACReg32_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_MACReg16Read(unsigned int  ms_timeout, WiFi_MACReg16_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_MACReg16Read_r(const int meta_handle, unsigned int  ms_timeout, WiFi_MACReg16_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_BBRegRead(unsigned int  ms_timeout, WiFi_BBReg8_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_BBRegRead_r(const int meta_handle, unsigned int  ms_timeout, WiFi_BBReg8_S  *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_EEPROM_Read(unsigned int  ms_timeout, WiFi_EEPROM_S *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_EEPROM_Read_r(const int meta_handle, unsigned int  ms_timeout, WiFi_EEPROM_S *array, unsigned int array_cnt);
META_RESULT  __stdcall SP_META_WiFi_DacDcOffsetAutoCalibration(unsigned int  ms_timeout, WiFi_DAC_DC_Offset_S  *cnf);
META_RESULT  __stdcall SP_META_WiFi_DacDcOffsetAutoCalibration_r(const int meta_handle, unsigned int  ms_timeout, WiFi_DAC_DC_Offset_S  *cnf);


//-----------------------------------------------------//
//  WiFi Calibration: Exported Functions               //
//-----------------------------------------------------//
META_RESULT  __stdcall SP_META_WiFi_QueryChipCapability(unsigned int  ms_timeout, WiFi_ChipCapability_S  *cnf);
META_RESULT  __stdcall SP_META_WiFi_QueryChipCapability_r(const int meta_handle, unsigned int  ms_timeout, WiFi_ChipCapability_S  *cnf);
META_RESULT  __stdcall SP_META_WiFi_SetMacAddress(unsigned int  ms_timeout, const WiFi_MacAddress_S  *mac);
META_RESULT  __stdcall SP_META_WiFi_SetMacAddress_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_MacAddress_S  *mac);
META_RESULT  __stdcall SP_META_WiFi_SetTxPower2400M(unsigned int  ms_timeout, const WiFi_TxPower_2400M_S  *txpwr);
META_RESULT  __stdcall SP_META_WiFi_SetTxPower2400M_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_TxPower_2400M_S  *txpwr);
META_RESULT  __stdcall SP_META_WiFi_SetTxPower5000M(unsigned int  ms_timeout, const WiFi_TxPower_5000M_S  *txpwr);
META_RESULT  __stdcall SP_META_WiFi_SetTxPower5000M_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_TxPower_5000M_S  *txpwr);
META_RESULT  __stdcall SP_META_WiFi_SetDacDcOffset(unsigned int  ms_timeout, const WiFi_DAC_DC_Offset_S  *dac_dc_offset);
META_RESULT  __stdcall SP_META_WiFi_SetDacDcOffset_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_DAC_DC_Offset_S  *dac_dc_offset);

META_RESULT  __stdcall SP_META_WiFi_SetTxALC2400M(unsigned int  ms_timeout, const WiFi_TxALC_2400M_S  *txalc);
META_RESULT  __stdcall SP_META_WiFi_SetTxALC2400M_r(const int meta_handle, unsigned int  ms_timeout, const WiFi_TxALC_2400M_S  *txalc);


// ADC Cal
META_RESULT  __stdcall SP_META_ADC_GetChannelNum(unsigned int  ms_timeout, unsigned int * pNum);
META_RESULT  __stdcall SP_META_ADC_GetChannelNum_r(const int meta_handle, unsigned int  ms_timeout, unsigned int * pNum);
META_RESULT  __stdcall SP_META_ADC_QueryEfuseCalExist(unsigned int  ms_timeout, unsigned int * pIsExist);
META_RESULT  __stdcall SP_META_ADC_QueryEfuseCalExist_r(const int meta_handle, unsigned int  ms_timeout, unsigned int * pIsExist);


// pVol: battery voltage(mV) 
// pCapacity: battery capacity
META_RESULT  __stdcall SP_META_ADC_GetBatVol(unsigned int  ms_timeout, int * pVol);   
META_RESULT  __stdcall SP_META_ADC_GetBatVol_r(const int meta_handle, unsigned int ms_timeout, int * pVol);
META_RESULT  __stdcall SP_META_ADC_GetBatCapacity(unsigned int  ms_timeout, int * pCapacity);
META_RESULT  __stdcall SP_META_ADC_GetBatCapacity_r(const int meta_handle, unsigned int ms_timeout, int * pCapacity);
//

// GPS
META_RESULT  __stdcall SP_META_GPS_Stop(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_GPS_Stop_r(const int meta_handle,unsigned int ms_timeout);

//-----------------------------------------------------//
//  3G RF Testing: function definition				   //
//-----------------------------------------------------//

META_RESULT  __stdcall SP_META_3Grf_ContinuousRX(unsigned int  ms_timeout, URfTestCmdRSSI *req);
META_RESULT  __stdcall SP_META_3Grf_ContinuousRX_r(const int meta_handle, unsigned int  ms_timeout, URfTestCmdRSSI *req);

META_RESULT  __stdcall SP_META_3Grf_TxAccess(unsigned int  ms_timeout, URfTestCmdTxAccess *req, URfTestResultParam *cnf);
META_RESULT  __stdcall SP_META_3Grf_TxAccess_r(const int meta_handle, unsigned int  ms_timeout, URfTestCmdTxAccess *req, URfTestResultParam *cnf);
META_RESULT  __stdcall SP_META_3Grf_TestStop(unsigned int  ms_timeout, URfTestResultParam *cnf);
META_RESULT  __stdcall SP_META_3Grf_TestStop_r(const int meta_handle, unsigned int  ms_timeout, URfTestResultParam *cnf);
META_RESULT  __stdcall SP_META_3Grf_TxDpch(unsigned int  ms_timeout, URfTestCmdTxDPCh *req, URfTestResultParam *cnf);
META_RESULT  __stdcall SP_META_3Grf_TxDpch_r(const int meta_handle, unsigned int  ms_timeout, URfTestCmdTxDPCh *req, URfTestResultParam *cnf);
META_RESULT  __stdcall SP_META_3Grf_RxDpch(unsigned int  ms_timeout, URfTestCmdRxDPCh *req, URfTestResultRxDPCh *cnf);
META_RESULT  __stdcall SP_META_3Grf_RxDpch_r(const int meta_handle, unsigned int  ms_timeout, URfTestCmdRxDPCh *req, URfTestResultRxDPCh *cnf);
META_RESULT  __stdcall SP_META_3Grf_Rssi(unsigned int  ms_timeout, URfTestCmdRSSI *req, URfTestResultRSSI *cnf);
META_RESULT  __stdcall SP_META_3Grf_Rssi_r(const int meta_handle, unsigned int  ms_timeout, URfTestCmdRSSI *req, URfTestResultRSSI *cnf);
META_RESULT  __stdcall SP_META_3Grf_Rscp(unsigned int  ms_timeout, URfTestCmdRSCP *req, URfTestResultRSCP *cnf);
META_RESULT  __stdcall SP_META_3Grf_Rscp_r(const int meta_handle, unsigned int  ms_timeout, URfTestCmdRSCP *req, URfTestResultRSCP *cnf);

META_RESULT  __stdcall SP_META_3Grf_Set_Tx_PaApc(unsigned int  ms_timeout, UL1D_RF_TX_PA_APC_REQ_T *req);
META_RESULT  __stdcall SP_META_3Grf_Set_Tx_PaApc_r(const int meta_handle, unsigned int  ms_timeout, UL1D_RF_TX_PA_APC_REQ_T *req);

META_RESULT  __stdcall SP_META_3Grf_AFC(unsigned int  ms_timeout, URfTestCmdAFC *req, URfTestResultAFC *cnf);
META_RESULT  __stdcall SP_META_3Grf_AFC_r(const int meta_handle, unsigned int  ms_timeout, URfTestCmdAFC *req, URfTestResultAFC *cnf);

META_RESULT  __stdcall SP_META_3Grf_GetRFID(unsigned int  ms_timeout, URfTestResultRFID *cnf);
META_RESULT  __stdcall SP_META_3Grf_GetRFID_r(const int meta_handle, unsigned int  ms_timeout, URfTestResultRFID *cnf);

META_RESULT  __stdcall SP_META_3Grf_ConfigHWTPC(unsigned int  ms_timeout, UL1D_RF_HWTPC_CONFIG_REQ_T *req);
META_RESULT  __stdcall SP_META_3Grf_ConfigHWTPC_r(const int meta_handle, unsigned int  ms_timeout, UL1D_RF_HWTPC_CONFIG_REQ_T *req);


META_RESULT  __stdcall SP_META_3Grf_GetPwrDtStep(unsigned int  ms_timeout, URfTestResultPwrDtStep *cnf);
META_RESULT  __stdcall SP_META_3Grf_GetPwrDtStep_r(const int meta_handle, unsigned int  ms_timeout, URfTestResultPwrDtStep *cnf);
META_RESULT  __stdcall SP_META_3Grf_GetPwrDtDac(unsigned int  ms_timeout, URfTestResultPwrDtDac *cnf);
META_RESULT  __stdcall SP_META_3Grf_GetPwrDtDac_r(const int meta_handle, unsigned int  ms_timeout, URfTestResultPwrDtDac *cnf);
META_RESULT  __stdcall SP_META_3Grf_GetPwrDtDefaultThr(unsigned int  ms_timeout, UL1D_RF_GET_PWR_THR_REQ_T *req, URfTestResultPwrDtDefaultThr *cnf);
META_RESULT  __stdcall SP_META_3Grf_GetPwrDtDefaultThr_r(const int meta_handle, unsigned int  ms_timeout, UL1D_RF_GET_PWR_THR_REQ_T *req, URfTestResultPwrDtDefaultThr *cnf);


META_RESULT  __stdcall SP_META_3Grf_SetImmediateBSI(unsigned int  ms_timeout, const UL1D_RF_SET_BSI_DATA_REQ_T *req);
META_RESULT  __stdcall SP_META_3Grf_SetImmediateBSI_r(const int meta_handle, unsigned int  ms_timeout, const UL1D_RF_SET_BSI_DATA_REQ_T *req);
META_RESULT  __stdcall SP_META_3Grf_GetImmediateBSI(unsigned int  ms_timeout, const UL1D_RF_GET_BSI_DATA_REQ_T *req, unsigned int *p_bsi_data);
META_RESULT  __stdcall SP_META_3Grf_GetImmediateBSI_r(const int meta_handle, unsigned int  ms_timeout, const UL1D_RF_GET_BSI_DATA_REQ_T *req, unsigned int *p_bsi_data);


// Base Band Test
META_RESULT  __stdcall SP_META_PMIC_RegRead(unsigned int ms_timeout, const WM_CMD_ReadPMICRegister_REQ_T *req, WM_CMD_ReadRegister_CNF_T *cnf) ;
META_RESULT  __stdcall SP_META_PMIC_RegRead_r(const int meta_handle,unsigned int ms_timeout, const WM_CMD_ReadPMICRegister_REQ_T *req, WM_CMD_ReadRegister_CNF_T *cnf);
META_RESULT  __stdcall SP_META_PMIC_RegWrite(unsigned int ms_timeout, const WM_CMD_WritePMICRegister_REQ_T *req, WM_CMD_WriteRegister_CNF_T *cnf) ;
META_RESULT  __stdcall SP_META_PMIC_RegWrite_r(const int meta_handle,unsigned int ms_timeout, const WM_CMD_WritePMICRegister_REQ_T *req, WM_CMD_WriteRegister_CNF_T *cnf);
META_RESULT  __stdcall SP_META_PMIC_RegRead_DWORD(unsigned int ms_timeout, const WM_CMD_ReadPMICRegister_DWORD_REQ_T *req, WM_CMD_ReadRegister_DWORD_CNF_T *cnf) ;
META_RESULT  __stdcall SP_META_PMIC_RegRead_DWORD_r(const int meta_handle,unsigned int ms_timeout, const WM_CMD_ReadPMICRegister_DWORD_REQ_T *req, WM_CMD_ReadRegister_DWORD_CNF_T *cnf);
META_RESULT  __stdcall SP_META_PMIC_RegWrite_DWORD(unsigned int ms_timeout, const WM_CMD_WritePMICRegister_DWORD_REQ_T *req, WM_CMD_WriteRegister_DWORD_CNF_T *cnf) ;
META_RESULT  __stdcall SP_META_PMIC_RegWrite_DWORD_r(const int meta_handle,unsigned int ms_timeout, const WM_CMD_WritePMICRegister_DWORD_REQ_T *req, WM_CMD_WriteRegister_DWORD_CNF_T *cnf);


// Battery
META_RESULT  __stdcall SP_META_Battery_DownloadImage(unsigned int ms_timeout, const WM_Bat_DLImage_REQ_T *req, WM_Bat_DLImage_CNF_T *cnf, char* fileAddress);
META_RESULT  __stdcall SP_META_Battery_DownloadImage_r(const int meta_handle,unsigned int ms_timeout, const WM_Bat_DLImage_REQ_T *req, WM_Bat_DLImage_CNF_T *cnf, char* fileAddress);
META_RESULT  __stdcall SP_META_Battery_Read_FW_INFO(unsigned int ms_timeout, const WM_Bat_READ_FW_INFO_REQ_T *req,WM_Bat_READ_FW_INFO_CNF_T *cnf);
META_RESULT  __stdcall SP_META_Battery_Read_FW_INFO_r(const int meta_handle,unsigned int ms_timeout, const WM_Bat_READ_FW_INFO_REQ_T *req,WM_Bat_READ_FW_INFO_CNF_T *cnf);
META_RESULT  __stdcall SP_META_Battery_Read_SOC(unsigned int ms_timeout, const WM_Bat_READ_SOC_REQ_T *req, WM_Bat_READ_SOC_CNF_T *cnf);
META_RESULT  __stdcall SP_META_Battery_Read_SOC_r(const int meta_handle,unsigned int ms_timeout, const WM_Bat_READ_SOC_REQ_T *req, WM_Bat_READ_SOC_CNF_T *cnf);
META_RESULT  __stdcall SP_META_Battery_Write_SOC(unsigned int ms_timeout,const WM_Bat_WRITE_SOC_REQ_T *req, WM_Bat_WRITE_SOC_CNF_T *cnf); 
META_RESULT  __stdcall SP_META_Battery_Write_SOC_r(const int meta_handle,unsigned int ms_timeout, const WM_Bat_WRITE_SOC_REQ_T *req, WM_Bat_WRITE_SOC_CNF_T *cnf);
META_RESULT  __stdcall SP_META_Battery_Update_FW(unsigned int ms_timeout,const WM_Bat_UPImage_REQ_T*req, WM_Bat_UPImage_CNF_T *cnf); 
META_RESULT  __stdcall SP_META_Battery_Update_FW_r(const int meta_handle,unsigned int ms_timeout, const WM_Bat_UPImage_REQ_T *req, WM_Bat_UPImage_CNF_T *cnf);
META_RESULT  __stdcall SP_META_Battery_Enable_IT(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_Battery_Enable_IT_r(int meta_handle, unsigned int ms_timeout);


// DVB
//export function
META_RESULT  __stdcall SP_META_DVB_Connect(unsigned int ms_timeout, const DVB_CONNECT_REQ *req, DVB_CONNECT_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Disconnect(unsigned int ms_timeout, const DVB_DISCONNECT_REQ *req, DVB_DISCONNECT_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Middleware_Update(unsigned int ms_timeout, const DVB_MIDDLEWARE_UPDATE_REQ *req, DVB_MIDDLEWARE_UPDATE_CNF *cnf,  char * fileAddress);
//META_RESULT  __stdcall META_DVB_Parameter_Calibration(unsigned int ms_timeout, const DVB_PARAMETER_CALIBRATION_REQ *req, DVB_PARAMETER_CALIBRATION_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_Signal_Quality(unsigned int ms_timeout, const DVB_GET_SIGNALQUALITY_REQ *req, DVB_GET_SIGNALQUALITY_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Demodulator_IsAlive(unsigned int ms_timeout, const DVB_DEMODULATOR_ISALIVE_REQ *req, DVB_DEMODULATOR_ISALIVE_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Set_TS_PacketBatch(unsigned int ms_timeout, const DVB_SET_TS_PACKETBATCH_REQ *req, DVB_SET_TS_PACKETBATCH_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Set_TX_PacketTimeout(unsigned int ms_timeout, const DVB_SET_TX_PACKETTIMEOUT_REQ *req, DVB_SET_TX_PACKETTIMEOUT_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Add_TS_PID(unsigned int ms_timeout, const DVB_ADD_TS_PID_REQ *req, DVB_ADD_TS_PID_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Remove_TS_PID(unsigned int ms_timeout, const DVB_REMOVE_TS_PID_REQ *req, DVB_REMOVE_TS_PID_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Disable_AllTS_PIDsFiltering(unsigned int ms_timeout, const DVB_DISABLE_ALLTS_PIDFILTERING_REQ *req, DVB_DISABLE_ALLTS_PIDFILTERING_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Dump_TS_PacketstoSDCard(unsigned int ms_timeout, const DVB_DUMP_TS_PACKETSTOSDCARD_REQ *req, DVB_DUMP_TS_PACKETSTOSDCARD_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_ReceptionMode(unsigned int ms_timeout, const DVB_GET_RECEPTIONMODE_REQ *req, DVB_GET_RECEPTIONMODE_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_LockIndicator(unsigned int ms_timeout, const DVB_GET_LOCKINDICATOR_REQ *req, DVB_GET_LOCKINDICATOR_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_PerformanceInfo(unsigned int ms_timeout, const DVB_GET_PERFORMANCEINFO_REQ *req, DVB_GET_PERFORMANCEINFO_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_Version(unsigned int ms_timeout, const DVB_GET_VERSION_REQ *req, DVB_GET_VERSION_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_DebugCounter(unsigned int ms_timeout, const DVB_GET_DEBUG_COUNTER_REQ *req, DVB_GET_DEBUG_COUNTER_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Connect_r(const int meta_handle, unsigned int ms_timeout, const DVB_CONNECT_REQ *req, DVB_CONNECT_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Disconnect_r(const int meta_handle, unsigned int ms_timeout, const DVB_DISCONNECT_REQ *req, DVB_DISCONNECT_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Middleware_Update_r(const int meta_handle, unsigned int ms_timeout, const DVB_MIDDLEWARE_UPDATE_REQ *req, DVB_MIDDLEWARE_UPDATE_CNF *cnf,  char * fileAddress);
//META_RESULT  __stdcall META_DVB_Parameter_Calibration_r(const int meta_handle, unsigned int ms_timeout, const DVB_PARAMETER_CALIBRATION_REQ *req, DVB_PARAMETER_CALIBRATION_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_Signal_Quality_r(const int meta_handle, unsigned int ms_timeout, const DVB_GET_SIGNALQUALITY_REQ *req, DVB_GET_SIGNALQUALITY_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Demodulator_IsAlive_r(const int meta_handle, unsigned int ms_timeout, const DVB_DEMODULATOR_ISALIVE_REQ *req, DVB_DEMODULATOR_ISALIVE_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Set_TS_PacketBatch_r(const int meta_handle, unsigned int ms_timeout, const DVB_SET_TS_PACKETBATCH_REQ *req, DVB_SET_TS_PACKETBATCH_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Set_TX_PacketTimeout_r(const int meta_handle, unsigned int ms_timeout, const DVB_SET_TX_PACKETTIMEOUT_REQ *req, DVB_SET_TX_PACKETTIMEOUT_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Add_TS_PID_r(const int meta_handle, unsigned int ms_timeout, const DVB_ADD_TS_PID_REQ *req, DVB_ADD_TS_PID_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Remove_TS_PID_r(const int meta_handle, unsigned int ms_timeout, const DVB_REMOVE_TS_PID_REQ *req, DVB_REMOVE_TS_PID_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Disable_AllTS_PIDsFiltering_r(const int meta_handle, unsigned int ms_timeout, const DVB_DISABLE_ALLTS_PIDFILTERING_REQ *req, DVB_DISABLE_ALLTS_PIDFILTERING_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Dump_TS_PacketstoSDCard_r(const int meta_handle, unsigned int ms_timeout, const DVB_DUMP_TS_PACKETSTOSDCARD_REQ *req, DVB_DUMP_TS_PACKETSTOSDCARD_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_ReceptionMode_r(const int meta_handle, unsigned int ms_timeout, const DVB_GET_RECEPTIONMODE_REQ *req, DVB_GET_RECEPTIONMODE_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_LockIndicator_r(const int meta_handle, unsigned int ms_timeout, const DVB_GET_LOCKINDICATOR_REQ *req, DVB_GET_LOCKINDICATOR_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_PerformanceInfo_r(const int meta_handle, unsigned int ms_timeout, const DVB_GET_PERFORMANCEINFO_REQ *req, DVB_GET_PERFORMANCEINFO_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_Version_r(const int meta_handle, unsigned int ms_timeout, const DVB_GET_VERSION_REQ *req, DVB_GET_VERSION_CNF *cnf);
META_RESULT  __stdcall SP_META_DVB_Get_DebugCounter_r(const int meta_handle, unsigned int ms_timeout, const DVB_GET_DEBUG_COUNTER_REQ *req, DVB_GET_DEBUG_COUNTER_CNF *cnf);


// ECI
META_RESULT __stdcall SP_META_EciPortTest(unsigned int ms_timeout, unsigned long portIdx);
META_RESULT __stdcall SP_META_EciPortTest_r(int meta_handle, unsigned int ms_timeout, unsigned long portIdx);

// FAT
META_RESULT  __stdcall SP_META_FAT_Open(const char *fat_filepath, FAT_OPEN_MODE  mode, int *fs_handle, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Open_r(const int meta_handle, const char *fat_filepath, FAT_OPEN_MODE  mode, int *fs_handle, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Close(int *fs_handle, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Close_r(const int meta_handle, int *fs_handle, short *p_token);
META_RESULT  __stdcall SP_META_FAT_GetFileSize(const int fs_handle, int *filesize, short *p_token);
META_RESULT  __stdcall SP_META_FAT_GetFileSize_r(const int meta_handle, const int fs_handle, int *filesize, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Read(const int fs_handle, char *buf, const int buf_len, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Read_r(const int meta_handle, const int fs_handle, char *buf, const int buf_len, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Write(const int fs_handle, const char *buf, const int buf_len, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Write_r(const int meta_handle, const int fs_handle, const char *buf, const int buf_len, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Read_To_File(const int fs_handle, const char *local_filepath, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Read_To_File_r(const int meta_handle, const int fs_handle, const char *local_filepath, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Write_By_File(const int fs_handle, const char *local_filepath, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Write_By_File_r(const int meta_handle, const int fs_handle, const char *local_filepath, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Delete(const char *fat_filepath, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Delete_r(const int meta_handle, const char *fat_filepath, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Move(const char *fat_filepath, const char *new_fat_filepath, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Move_r(const int meta_handle, const char *fat_filepath, const char *new_fat_filepath, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Find_Start(const char *fat_base_dir, const char *fat_find_pattern, FAT_FIND_MODE	 find_mode, int *p_find_handle, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Find_Start_r(const int meta_handle, const char *fat_base_dir, const char *fat_find_pattern, FAT_FIND_MODE	 find_mode, int *p_find_handle, short *p_token);
META_RESULT  __stdcall SP_META_FAT_Find_Head(int find_handle);
META_RESULT  __stdcall SP_META_FAT_Find_Prev(int find_handle);
META_RESULT  __stdcall SP_META_FAT_Find_Next(int find_handle);
META_RESULT  __stdcall SP_META_FAT_Find_GetFileInfo(int find_handle, char *p_filepath, const int filepath_len, int *p_filesize);
META_RESULT  __stdcall SP_META_FAT_Find_Close(int *p_find_handle);
META_RESULT  __stdcall SP_META_FAT_GetDiskInfo(const char DriveLetter, FAT_DiskInfo_T  *p_DiskInfo, short *p_token);
META_RESULT  __stdcall SP_META_FAT_GetDiskInfo_r(const int meta_handle, const char DriveLetter, FAT_DiskInfo_T  *p_DiskInfo, short *p_token);
META_RESULT  __stdcall SP_META_FAT_RemoveDir(const char *fat_dirpath);
META_RESULT  __stdcall SP_META_FAT_RemoveDir_r(const int meta_handle, const char *fat_dirpath);
META_RESULT  __stdcall SP_META_FAT_CheckEnoughSpace(FAT_FILE_INFO_REQ_T *req);
META_RESULT  __stdcall SP_META_FAT_CheckEnoughSpace_r(const int meta_handle, FAT_FILE_INFO_REQ_T *req);

// Query 
META_RESULT  __stdcall SP_META_QueryIfTargetSupportISP(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfTargetSupportISP_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfTargetSupportAcoustic16level(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfTargetSupportAcoustic16level_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfTargetSupportAudioParam45Tap(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfTargetSupportAudioParam45Tap_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_BTPowerOn(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_BTPowerOn_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfTargetSupportWifiALC(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_QueryIfTargetSupportWifiALC_r(const int meta_handle, unsigned int ms_timeout);

//-----------------------------------------------------//
//  RF Testing: exported function definition           //
//-----------------------------------------------------//
// for SP project, RF is exclusive

META_RESULT  __stdcall SP_META_Rf_PM(const RfPm_Req *req, const META_RF_PM_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_PM_r(const int meta_handle, const RfPm_Req *req, const META_RF_PM_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_AFC(const RfAfc_Req *req, const META_RF_AFC_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_AFC_r(const int meta_handle, const RfAfc_Req *req, const META_RF_AFC_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_NB_TX(const RfNbtx_Req *req, const META_RF_NB_TX_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_NB_TX_r(const int meta_handle, const RfNbtx_Req *req, const META_RF_NB_TX_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_CONTINUE_RX(const RfCnRx_Req *req, const META_RF_CONT_RX_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_CONTINUE_RX_r(const int meta_handle, const RfCnRx_Req *req, const META_RF_CONT_RX_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_CONTINUE_TX(const RfCnTx_Req *req, const META_RF_CONT_TX_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_CONTINUE_TX_r(const int meta_handle, const RfCnTx_Req *req, const META_RF_CONT_TX_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_SetBBTXCfg(const RfSetBBTXCfg_Req *req, const META_RF_SETBBTX_CFG_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_SetBBTXCfg_r(const int meta_handle, const RfSetBBTXCfg_Req *req, const META_RF_SETBBTX_CFG_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_SelectFrequencyBand1900(const unsigned char selectPCS1900, const META_RF_SELBAND_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_SelectFrequencyBand1900_r(const int meta_handle, const unsigned char selectPCS1900, const META_RF_SELBAND_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_Stop(const META_RF_STOP_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_Stop_r(const int meta_handle, const META_RF_STOP_CNF cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_MultiSlot_TX(const RfMultiSlotTX_Req *req, const META_RF_MULTISLOT_TX_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_MultiSlot_TX_r(const int meta_handle, const RfMultiSlotTX_Req *req, const META_RF_MULTISLOT_TX_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_SetAfcDacValue(const RfSetAfcDacValue_Req *req, const META_RF_SET_AFCDACVALUE_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_SetAfcDacValue_r(const int meta_handle, const RfSetAfcDacValue_Req *req, const META_RF_SET_AFCDACVALUE_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_SetBBTxCfg2(unsigned int ms_timeout, const RfBBTXCfg2  *tx_cfg_req, RfBBTXCfg2  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_SetBBTxCfg2_r(const int meta_handle, unsigned int ms_timeout, const RfBBTXCfg2  *tx_cfg_req, RfBBTXCfg2  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_GetBBTxCfg2(unsigned int ms_timeout, RfBBTXCfg2  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_GetBBTxCfg2_r(const int meta_handle, unsigned int ms_timeout, RfBBTXCfg2  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_SetCrystalCapId(unsigned int ms_timeout, const RfSetCrystalCfg_Req  *req);
META_RESULT  __stdcall SP_META_Rf_SetCrystalCapId_r(const int meta_handle, unsigned int ms_timeout, const RfSetCrystalCfg_Req  *req);
META_RESULT  __stdcall SP_META_Rf_BBTXAutoCal(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_Rf_BBTXAutoCal_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_Rf_QueryMSCapability(unsigned int ms_timeout, RfMsCapability_S  *p_type);
META_RESULT  __stdcall SP_META_Rf_QueryMSCapability_r(const int meta_handle, unsigned int ms_timeout, RfMsCapability_S  *p_type);
META_RESULT  __stdcall SP_META_Rf_QueryMSCapabilityEx(unsigned int ms_timeout, RfMsCapabilityEx_S  *p_ms_cap);
META_RESULT  __stdcall SP_META_Rf_QueryMSCapabilityEx_r(const int meta_handle, unsigned int ms_timeout, RfMsCapabilityEx_S  *p_ms_cap);
META_RESULT  __stdcall SP_META_Rf_SetAfcSinWaveDetection(unsigned int ms_timeout, AFC_SINWAVE_DETECTION_E  bIsAfcSinWaveOn);
META_RESULT  __stdcall SP_META_Rf_SetAfcSinWaveDetection_r(const int meta_handle, unsigned int ms_timeout, AFC_SINWAVE_DETECTION_E  bIsAfcSinWaveOn);
META_RESULT  __stdcall SP_META_Rf_QueryIfTwoApcDCOffsetSupport(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_Rf_QueryIfTwoApcDCOffsetSupport_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_Rf_MultiSlot_TX_Ex(unsigned int ms_timeout, const Rf_MultiSlotTXEx_Req *req);
META_RESULT  __stdcall SP_META_Rf_MultiSlot_TX_Ex_r(const int meta_handle, unsigned int ms_timeout, const Rf_MultiSlotTXEx_Req *req);
META_RESULT  __stdcall SP_META_Rf_GetRFID(unsigned int ms_timeout, RFMod_ID *cnf);
META_RESULT  __stdcall SP_META_Rf_GetRFID_r(const int meta_handle, unsigned int ms_timeout, RFMod_ID *cnf);
META_RESULT  __stdcall SP_META_Rf_CONTINUE_TX_Ex(unsigned int ms_timeout, const RfCnTxEx_Req *req);
META_RESULT  __stdcall SP_META_Rf_CONTINUE_TX_Ex_r(const int meta_handle, unsigned int ms_timeout, const RfCnTxEx_Req *req);
META_RESULT  __stdcall SP_META_Rf_SetBBTxCfg3(unsigned int ms_timeout, const RfBBTXCfg3  *tx_cfg_req, RfBBTXCfg3  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_SetBBTxCfg3_r(const int meta_handle, unsigned int ms_timeout, const RfBBTXCfg3  *tx_cfg_req, RfBBTXCfg3  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_GetBBTxCfg3(unsigned int ms_timeout, RfBBTXCfg3  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_GetBBTxCfg3_r(const int meta_handle, unsigned int ms_timeout, RfBBTXCfg3  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_CONTINUE_TX_Ex2(unsigned int ms_timeout, const RfCnTxEx2_Req *req);
META_RESULT  __stdcall SP_META_Rf_CONTINUE_TX_Ex2_r(const int meta_handle, unsigned int ms_timeout, const RfCnTxEx2_Req *req);
META_RESULT  __stdcall SP_META_Rf_GetAfcDacValueAtRTXOffsetCal(unsigned int ms_timeout, RfGetAfcDacValueAtRTXOffsetCal *cnf);
META_RESULT  __stdcall SP_META_Rf_GetAfcDacValueAtRTXOffsetCal_r(const int meta_handle, unsigned int ms_timeout, RfGetAfcDacValueAtRTXOffsetCal *cnf);

META_RESULT  __stdcall SP_META_Rf_SetBBTxCfg4(unsigned int ms_timeout, const RfBBTXCfg4  *tx_cfg_req, RfBBTXCfg4  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_SetBBTxCfg4_r(const int meta_handle, unsigned int ms_timeout, const RfBBTXCfg4  *tx_cfg_req, RfBBTXCfg4  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_GetBBTxCfg4(unsigned int ms_timeout, RfBBTXCfg4  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_GetBBTxCfg4_r(const int meta_handle, unsigned int ms_timeout, RfBBTXCfg4  *tx_cfg_cnf);

META_RESULT  __stdcall SP_META_Rf_SetBBTxCfg5(unsigned int ms_timeout, const RfBBTXCfg4  *tx_cfg_req, RfBBTXCfg4  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_SetBBTxCfg5_r(const int meta_handle, unsigned int ms_timeout, const RfBBTXCfg4  *tx_cfg_req, RfBBTXCfg4  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_GetBBTxCfg5(unsigned int ms_timeout, RfBBTXCfg4  *tx_cfg_cnf);
META_RESULT  __stdcall SP_META_Rf_GetBBTxCfg5_r(const int meta_handle, unsigned int ms_timeout, RfBBTXCfg4  *tx_cfg_cnf);

//-----------------------------------------------------//
//  RunTime Setting Functions Without Update NVRAM     //
//-----------------------------------------------------//
META_RESULT  __stdcall SP_META_Rf_SetRampTable(unsigned int ms_timeout, FrequencyBand  band, const l1cal_rampTable_T  *ramp);
META_RESULT  __stdcall SP_META_Rf_SetRampTable_r(const int meta_handle, unsigned int ms_timeout, FrequencyBand  band, const l1cal_rampTable_T  *ramp);
META_RESULT  __stdcall SP_META_Rf_SetRampApcLevel(const RfSetRampApcLevel_Req *req, const META_RF_SET_RAMPAPCLEVEL_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_SetRampApcLevel_r(const int meta_handle, const RfSetRampApcLevel_Req *req, const META_RF_SET_RAMPAPCLEVEL_CNF  cb, short *token, void *usrData);
META_RESULT  __stdcall SP_META_Rf_EPSK_SetRampTable(unsigned int ms_timeout, FrequencyBand  band, const l1cal_rampTable_T  *ramp);
META_RESULT  __stdcall SP_META_Rf_EPSK_SetRampTable_r(const int meta_handle, unsigned int ms_timeout, FrequencyBand  band, const l1cal_rampTable_T  *ramp);
META_RESULT  __stdcall SP_META_Rf_EPSK_SetRampApcLevel(unsigned int ms_timeout, const RfSetRampApcLevel_Req *req);
META_RESULT  __stdcall SP_META_Rf_EPSK_SetRampApcLevel_r(const int meta_handle, unsigned int ms_timeout, const RfSetRampApcLevel_Req *req);
META_RESULT  __stdcall SP_META_Rf_SetRFImmediateBSI(unsigned int ms_timeout, const unsigned int bsi_data);
META_RESULT  __stdcall SP_META_Rf_SetRFImmediateBSI_r(const int meta_handle, unsigned int ms_timeout, const unsigned int bsi_data);
META_RESULT  __stdcall SP_META_Rf_GetRFImmediateBSI(unsigned int ms_timeout, unsigned int bsi_addr, unsigned int *p_bsi_data);
META_RESULT  __stdcall SP_META_Rf_GetRFImmediateBSI_r(const int meta_handle, unsigned int ms_timeout, unsigned int bsi_addr, unsigned int *p_bsi_data);
META_RESULT  __stdcall SP_META_Rf_SetRampTable_Ex(unsigned int ms_timeout, FrequencyBand  band, const l1cal_rampTable_T_Ex  *ramp);
META_RESULT  __stdcall SP_META_Rf_SetRampTable_Ex_r(const int meta_handle, unsigned int ms_timeout, FrequencyBand  band, const l1cal_rampTable_T_Ex  *ramp);
META_RESULT  __stdcall SP_META_Rf_SetRampTable_Ex2(unsigned int ms_timeout, FrequencyBand  band, const l1cal_rampTable_T_Ex2  *ramp);
META_RESULT  __stdcall SP_META_Rf_SetRampTable_Ex2_r(const int meta_handle, unsigned int ms_timeout, FrequencyBand  band, const l1cal_rampTable_T_Ex2  *ramp);
// Skyworks
META_RESULT  __stdcall SP_META_Rf_SKY74045_SetSpecialCoef(unsigned int ms_timeout, const RF_SKY74045_Coef_T *rf_mod_coef);
META_RESULT  __stdcall SP_META_Rf_SKY74045_SetSpecialCoef_r(const int meta_handle, unsigned int ms_timeout, const RF_SKY74045_Coef_T *rf_mod_coef);
META_RESULT  __stdcall SP_META_Rf_SKY74117_SetSpecialCoef(unsigned int ms_timeout, const RF_SKY74117_Coef_T *rf_mod_coef);
META_RESULT  __stdcall SP_META_Rf_SKY74117_SetSpecialCoef_r(const int meta_handle, unsigned int ms_timeout, const RF_SKY74117_Coef_T *rf_mod_coef);
// MT6139B
META_RESULT  __stdcall SP_META_Rf_MT6139B_SetSpecialCoef(unsigned int ms_timeout, const RF_MT6139B_Coef_T *rf_mod_coef);
META_RESULT  __stdcall SP_META_Rf_MT6139B_SetSpecialCoef_r(const int meta_handle, unsigned int ms_timeout, const RF_MT6139B_Coef_T *rf_mod_coef);
// Renesas Bright5P 
META_RESULT  __stdcall SP_META_Rf_BRIGHT5P_SetSpecialCoef(unsigned int ms_timeout, const RF_BRIGHT5P_Coef_T *rf_mod_coef);
META_RESULT  __stdcall SP_META_Rf_BRIGHT5P_SetSpecialCoef_r(const int meta_handle, unsigned int ms_timeout, const RF_BRIGHT5P_Coef_T *rf_mod_coef);
META_RESULT  __stdcall SP_META_Rf_32kCalibration(unsigned int ms_timeout, int *p_result);
META_RESULT  __stdcall SP_META_Rf_32kCalibration_r(const int meta_handle, unsigned int ms_timeout, int *p_result);
META_RESULT  __stdcall SP_META_Rf_AD6546_SetSpecialCoef(unsigned int ms_timeout, const ad6546tx *rf_mod_coef, const char *buf, const int buf_len);
META_RESULT  __stdcall SP_META_Rf_AD6546_SetSpecialCoef_r(const int meta_handle, unsigned int ms_timeout, const ad6546tx *rf_mod_coef, const char *buf, const int buf_len);


// MD
META_RESULT __stdcall SP_META_SendMDCmd(unsigned int ms_timeout, MD_FRAME *frame/*in & out*/);
META_RESULT __stdcall SP_META_SendMDCmd_r(int meta_handle, unsigned int ms_timeout, MD_FRAME *frame/*in & out*/);

// LED
META_RESULT  __stdcall SP_META_SetLEDLightLevel(unsigned int ms_timeout, KeypadBK_REQ *req);
META_RESULT  __stdcall SP_META_SetLEDLightLevel_r(const int meta_handle, unsigned int ms_timeout, KeypadBK_REQ *req);


// TDMB Functions

META_RESULT  __stdcall SP_META_TDMB_TurnOn(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_TDMB_TurnOn_r(const int meta_handle, unsigned int ms_timeout);
// send band may return: META_TDMB_ERR_BAND_NOT_EXIST, META_SUCCESS, META_FAILED
META_RESULT __stdcall SP_META_TDMB_SetBand(unsigned int ms_timeout, TDMB_SET_BAND_REQ_T *req);
META_RESULT __stdcall SP_META_TDMB_SetBand_r(const int meta_handle, unsigned int ms_timeout, TDMB_SET_BAND_REQ_T *req);
META_RESULT __stdcall SP_META_TDMB_AutoScan_GetFreq(unsigned int ms_timeout, TDMB_AUTO_SCAN_CNF_T *cnf);
META_RESULT __stdcall SP_META_TDMB_AutoScan_GetFreq_r(const int meta_handle, unsigned int ms_timeout, TDMB_AUTO_SCAN_CNF_T *cnf);
META_RESULT __stdcall SP_META_TDMB_SetFreq(unsigned int ms_timeout, TDMB_SET_FREQ_REQ_T *req, TDMB_SET_FREQ_CNF_T *cnf);
META_RESULT __stdcall SP_META_TDMB_SetFreq_r(const int meta_handle, unsigned int ms_timeout, TDMB_SET_FREQ_REQ_T *req, TDMB_SET_FREQ_CNF_T *cnf);
META_RESULT __stdcall SP_META_TDMB_AutoScan_GetEnsemble(unsigned int ms_timeout, TDMB_GET_ENSM_INFO_BY_AUTO_SCAN_CNF_T *cnf);
META_RESULT __stdcall SP_META_TDMB_AutoScan_GetEnsemble_r(const int meta_handle, unsigned int ms_timeout, TDMB_GET_ENSM_INFO_BY_AUTO_SCAN_CNF_T *cnf);
META_RESULT __stdcall SP_META_TDMB_GetSignal(unsigned int ms_timeout, TDMB_GET_SIGNAL_CNF_T *cnf);
META_RESULT __stdcall SP_META_TDMB_GetSignal_r(const int meta_handle, unsigned int ms_timeout, TDMB_GET_SIGNAL_CNF_T *cnf);
//META_RESULT __stdcall META_TDMB_SelService(unsigned int ms_timeout, TDMB_SEL_SERVICE_REQ_T *req);
//META_RESULT __stdcall META_TDMB_SelService_r(const int meta_handle, unsigned int ms_timeout, TDMB_SEL_SERVICE_REQ_T *req);
META_RESULT __stdcall SP_META_TDMB_SelService(unsigned int ms_timeout, TDMB_SEL_SERVICE_REQ_T *req, const META_TDMB_SEL_SERV_CNF  cnf_cb);
META_RESULT __stdcall SP_META_TDMB_SelService_r(const int meta_handle, unsigned int ms_timeout, TDMB_SEL_SERVICE_REQ_T *req, const META_TDMB_SEL_SERV_CNF  cnf_cb);
//META_RESULT __stdcall META_TDMB_SetIdle(unsigned int ms_timeout);
//META_RESULT __stdcall META_TDMB_SetIdle_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT __stdcall SP_META_TDMB_SetIdle(unsigned int ms_timeout, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg);
META_RESULT __stdcall SP_META_TDMB_SetIdle_r(const int meta_handle, unsigned int ms_timeout, CALLBACK_META_FAT_PROGRESS  cb_progress, void  *cb_progress_arg);
META_RESULT __stdcall SP_META_TDMB_TurnOff(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_TDMB_TurnOff_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT __stdcall SP_META_TDMB_GetEnsm(unsigned int ms_timeout, TDMB_GET_ENSM_CNF_T *cnf);
META_RESULT __stdcall SP_META_TDMB_GetEnsm_r(const int meta_handle, unsigned int ms_timeout, TDMB_GET_ENSM_CNF_T *cnf);
META_RESULT __stdcall SP_META_TDMB_SelServiceOnly( unsigned int ms_timeout, TDMB_SEL_SERVICE_ONLY_REQ_T *req);
META_RESULT __stdcall SP_META_TDMB_SelServiceOnly_r(const int meta_handle, unsigned int ms_timeout, TDMB_SEL_SERVICE_ONLY_REQ_T *);
META_RESULT __stdcall SP_META_TDMB_StopAutoScan(unsigned int ms_timeout);
META_RESULT __stdcall SP_META_TDMB_StopAutoScan_r(const int meta_handle, unsigned int ms_timeout);

// Misc
META_RESULT  __stdcall SP_META_CTI_SendPacketCmd(const unsigned char *pPayLoadBuffer, int nPayloadLength);
META_RESULT  __stdcall SP_META_CTI_SendPacketCmd_r(const int meta_handle, const unsigned char *pPayLoadBuffer, int nPayloadLength);
META_RESULT  __stdcall SP_META_CTI_SetPacketCallback(META_CTI_CallBack  pCBFunc, void* param);
META_RESULT  __stdcall SP_META_CTI_SetPacketCallback_r(const int meta_handle, META_CTI_CallBack  pCBFunc, void* param);

// HW Test Tool Manual test.
META_RESULT  __stdcall SP_META_Audio_GetSupportAfeRegAccess(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_Audio_GetSupportAfeRegAccess_r(const int meta_handle, unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_Audio_RunAfeRegAccess(unsigned int ms_timeout);
META_RESULT  __stdcall SP_META_Audio_RunAfeRegAccess_r(const int meta_handle, unsigned int ms_timeout);

//-----------------------------------------------------//
//  GAMMA Test              //
//-----------------------------------------------------//
typedef struct {
	unsigned char aalink;
	unsigned char aal;
	unsigned char color;
	unsigned char gamma;
	unsigned char ccorr;
} PQ_ONOFF_CONTROL;

META_RESULT __stdcall SP_META_GAMMA_PQ_ONOFF(unsigned int ms_timeout,PQ_ONOFF_CONTROL *req);
META_RESULT __stdcall SP_META_GAMMA_PQ_ONOFF_r(const int meta_handle, unsigned int ms_timeout,PQ_ONOFF_CONTROL *req);


typedef struct {
	unsigned int r;
	unsigned int g;
	unsigned int b;
} INK_RGB_PATTERN;

META_RESULT __stdcall SP_META_GAMMA_SET_DISP_PATTERN(unsigned int ms_timeout,INK_RGB_PATTERN *req);
META_RESULT __stdcall SP_META_GAMMA_SET_DISP_PATTERN_r(const int meta_handle,unsigned int ms_timeout,INK_RGB_PATTERN *req);

typedef struct {
	unsigned int size;
} LUT_SIZE;

META_RESULT __stdcall SP_META_GAMMA_SET_LUT_SIZE(unsigned int ms_timeout,LUT_SIZE *req);
META_RESULT __stdcall SP_META_GAMMA_SET_LUT_SIZE_r(const int meta_handle,unsigned int ms_timeout,LUT_SIZE *req);

#define GAMMA_TABLE_MAX 1024

typedef struct {
	unsigned int rgbindex;
	unsigned short gamma_table[GAMMA_TABLE_MAX];
} LUT_RGB_VALUE;


META_RESULT __stdcall SP_META_GAMMA_WRITE_LUT(unsigned int ms_timeout, LUT_RGB_VALUE *req);
META_RESULT __stdcall SP_META_GAMMA_WRITE_LUT_r(const int meta_handle,unsigned int ms_timeout, LUT_RGB_VALUE *req);

typedef struct {
	unsigned int save_index;
} LUT_SAVE_INDEX;

META_RESULT __stdcall SP_META_GAMMA_WRITE_LUT_FINISH(unsigned int ms_timeout, LUT_SAVE_INDEX *req);
META_RESULT __stdcall SP_META_GAMMA_WRITE_LUT_FINISH_r(const int meta_handle,unsigned int ms_timeout, LUT_SAVE_INDEX *req);

typedef struct{
	unsigned int checksum;
}GAMMA_STATUS_RETURN_CHECKSUM;

META_RESULT __stdcall SP_META_GAMMA_READ_CHECKSUM(unsigned int ms_timeout,GAMMA_STATUS_RETURN_CHECKSUM *cnf);
META_RESULT __stdcall SP_META_GAMMA_READ_CHECKSUM_r(const int meta_handle,unsigned int ms_timeout,GAMMA_STATUS_RETURN_CHECKSUM *cnf);

typedef struct {
	unsigned int gain_index;
	unsigned int r;
	unsigned int g;
	unsigned int b;
} GAIN_RGB_VALUE;

META_RESULT __stdcall SP_META_GAMMA_WRITE_GAIN(unsigned int ms_timeout,GAIN_RGB_VALUE *req); 
META_RESULT __stdcall SP_META_GAMMA_WRITE_GAIN_r(const int meta_handle,unsigned int ms_timeout,GAIN_RGB_VALUE *req); 

//-----------------------------------------------------//
//  DFO Editor Functions              //
//-----------------------------------------------------//
typedef struct 
{
    unsigned char reserved;   //just reserved
} DFO_QUERY_STATUS_REQ;

typedef struct 
{
    unsigned char   support;    // 1 means support; 0 means unsupport
} DFO_QUERY_STATUS_CNF;

typedef struct 
{
    unsigned char reserved;   //just reserved
} DFO_READ_COUNT_REQ;

typedef struct 
{
     int count;
} DFO_READ_COUNT_CNF;

typedef struct
{
    int index;          //[0, count)
} DFO_READ_REQ;

typedef struct
{
    char name[32];          //read result, dfo name
    int value;              //read result, dfo value
	int partition;      // 0: NVRAM, 1: MISC
} DFO_READ_CNF;
  
typedef struct
{
    char name[32];
    int value;
	int  partition;      // 0: NVRAM, 1: MISC
    int  save;           // 0: don't save to MISC/NVRAM, 1: save to MISC/NVRAM
} DFO_WRITE_REQ;

typedef struct
{
	unsigned char status;    //the status of ft module:  0 is success
} DFO_WRITE_CNF;

typedef struct
{
    unsigned char reserved;
} DFO_COMBO_COUNT_REQ;

typedef struct
{
    int     count;
} DFO_COMBO_COUNT_CNF;

typedef struct
{
    int     index;          // [0, count) of combo
} DFO_COMBO_READ_REQ;

typedef struct
{
    char    name[32];       // read result, combo name
    int     modeCount;      // read result, the number of mode
} DFO_COMBO_READ_CNF;

typedef struct
{
    int     index;          // [0, count) of combo
    int     modeIndex;      // [0, modeCount) of the mode of a combo
} DFO_COMBO_MODE_REQ;

typedef struct
{
    char    name[32];       // read result, the mode name of a combo
} DFO_COMBO_MODE_CNF;

typedef struct
{
    int     index;          // [0, count) of combo
    int     modeIndex;      // [0, modeCount) of the mode of a combo
} DFO_COMBO_UPDATE_REQ;

typedef struct
{
    int     status;
} DFO_COMBO_UPDATE_CNF;

META_RESULT __stdcall SP_META_DFO_Query_Status(unsigned int ms_timeout, DFO_QUERY_STATUS_CNF *pCnf);
META_RESULT __stdcall SP_META_DFO_Query_Status_r(const int meta_handle, unsigned int ms_timeout, DFO_QUERY_STATUS_CNF *pCnf);

META_RESULT __stdcall SP_META_DFO_Read_Count(unsigned int ms_timeout, DFO_READ_COUNT_CNF *pCnf);
META_RESULT __stdcall SP_META_DFO_Read_Count_r(const int meta_handle, unsigned int ms_timeout, DFO_READ_COUNT_CNF *pCnf);
 
META_RESULT __stdcall SP_META_DFO_Read(unsigned int ms_timeout, DFO_READ_REQ *pReq, DFO_READ_CNF *pCnf);
META_RESULT __stdcall SP_META_DFO_Read_r(const int meta_handle, unsigned int ms_timeout, DFO_READ_REQ *pReq, DFO_READ_CNF *pCnf);

META_RESULT __stdcall SP_META_DFO_Write(unsigned int ms_timeout, DFO_WRITE_REQ *pReq, DFO_WRITE_CNF *pCnf);
META_RESULT __stdcall SP_META_DFO_Write_r(const int meta_handle, unsigned int ms_timeout, DFO_WRITE_REQ *pReq, DFO_WRITE_CNF *pCnf);

META_RESULT __stdcall SP_META_DFO_Combo_Count(unsigned int ms_timeout, DFO_COMBO_COUNT_CNF *pCnf);
META_RESULT __stdcall SP_META_DFO_Combo_Count_r(const int meta_handle, unsigned int ms_timeout, DFO_COMBO_COUNT_CNF *pCnf);

META_RESULT __stdcall SP_META_DFO_Combo_Read(unsigned int ms_timeout, DFO_COMBO_READ_REQ *pReq, DFO_COMBO_READ_CNF *pCnf);
META_RESULT __stdcall SP_META_DFO_Combo_Read_r(const int meta_handle, unsigned int ms_timeout, DFO_COMBO_READ_REQ *pReq, DFO_COMBO_READ_CNF *pCnf);

META_RESULT __stdcall SP_META_DFO_Combo_Mode(unsigned int ms_timeout, DFO_COMBO_MODE_REQ *pReq, DFO_COMBO_MODE_CNF *pCnf);
META_RESULT __stdcall SP_META_DFO_Combo_Mode_r(const int meta_handle, unsigned int ms_timeout, DFO_COMBO_MODE_REQ *pReq, DFO_COMBO_MODE_CNF *pCnf);

META_RESULT __stdcall SP_META_DFO_Combo_Update(unsigned int ms_timeout, DFO_COMBO_UPDATE_REQ *pReq, DFO_COMBO_UPDATE_CNF *pCnf);
META_RESULT __stdcall SP_META_DFO_Combo_Update_r(const int meta_handle, unsigned int ms_timeout, DFO_COMBO_UPDATE_REQ *pReq, DFO_COMBO_UPDATE_CNF *pCnf);
//DFO Editor end


//DRM Key Install
typedef struct 
{
    unsigned int result;
} DRMKEY_INSTALL_SET_CNF;

typedef struct
{
    unsigned int req;  // unused
} DRMKEY_INSTALL_QUERY_REQ;

typedef struct
{
	unsigned int  keycount;
	unsigned int  keytype[512];
} DRMKEY_INSTALL_QUERY_CNF;

typedef struct
{
   	unsigned int  keylength;
	unsigned char content[128];
} DRMKEY_WRITE_MCID_REQ;

typedef struct 
{
    unsigned int result;
} DRMKEY_WRITE_MCID_CNF;

typedef struct
{
    unsigned int req;  // unused
} DRMKEY_READ_MCID_REQ;

typedef struct 
{
	unsigned int  keylength;
	unsigned char content[128];
} DRMKEY_READ_MCID_CNF;
META_RESULT __stdcall SP_META_DRMKey_Install_Set(unsigned int  ms_timeout, const char *file, DRMKEY_INSTALL_SET_CNF *pCnf);
META_RESULT __stdcall SP_META_DRMKey_Install_Set_r(const int meta_handle, unsigned int  ms_timeout, const char *file, DRMKEY_INSTALL_SET_CNF *pCnf);


META_RESULT __stdcall SP_META_DRMKey_Install_Query(unsigned int  ms_timeout, DRMKEY_INSTALL_QUERY_REQ *pReq, DRMKEY_INSTALL_QUERY_CNF *pCnf);
META_RESULT __stdcall SP_META_DRMKey_Install_Query_r(const int meta_handle, unsigned int  ms_timeout, DRMKEY_INSTALL_QUERY_REQ *pReq, DRMKEY_INSTALL_QUERY_CNF *pCnf);

META_RESULT __stdcall SP_META_DRMKey_Write_MCID(unsigned int  ms_timeout, DRMKEY_WRITE_MCID_REQ *pReq, DRMKEY_WRITE_MCID_CNF *pCnf);
META_RESULT __stdcall SP_META_DRMKey_Write_MCID_r(const int meta_handle, unsigned int  ms_timeout, DRMKEY_WRITE_MCID_REQ *pReq, DRMKEY_WRITE_MCID_CNF *pCnf);

META_RESULT __stdcall SP_META_DRMKey_Read_MCID(unsigned int  ms_timeout, DRMKEY_READ_MCID_REQ *pReq, DRMKEY_READ_MCID_CNF *pCnf);
META_RESULT __stdcall SP_META_DRMKey_Read_MCID_r(const int meta_handle, unsigned int  ms_timeout, DRMKEY_READ_MCID_REQ *pReq, DRMKEY_READ_MCID_CNF *pCnf);

//HDCP
typedef struct 
{
	unsigned int install_result;   //0 means success, 1 means fail
} HDCP_INSTALL_CNF;

META_RESULT __stdcall SP_META_HDCP_Install(unsigned int  ms_timeout, const char *file, const char *cek_file, HDCP_INSTALL_CNF *pCnf);
META_RESULT __stdcall SP_META_HDCP_Install_r(const int meta_handle, unsigned int  ms_timeout, const char *file, const char *cek_file, HDCP_INSTALL_CNF *pCnf);
//-------------END---------------

//special test
typedef struct
{
	int  reserved;  //no use
}SPECIALTEST_HUGEDATA_REQ;

typedef struct
{
    unsigned char result;
}SPECIALTEST_HUGEDATA_CNF;


META_RESULT  __stdcall SP_META_SpecialTest_HugeData(unsigned int ms_timeout, unsigned int datasize);
META_RESULT  __stdcall SP_META_SpecialTest_HugeData_r(const int meta_handle, unsigned int ms_timeout, unsigned int datasize);

META_RESULT  __stdcall SP_META_SpecialTest_RawData(unsigned int ms_timeout, unsigned char *dest, unsigned char *src, unsigned int datasize);
META_RESULT  __stdcall SP_META_SpecialTest_RawData_r(const int meta_handle, unsigned int ms_timeout, unsigned char *dest, unsigned char *src, unsigned int datasize);


//-----------------------------------------------------//
//  Switch SIM Functions							   //
//-----------------------------------------------------//

typedef struct  
{
	unsigned int reserved;
}SIM_QUERY_MDTYPE_REQ;

typedef struct  
{
	unsigned int md_type;
}SIM_QUERY_MDTYPE_CNF;

typedef struct  
{
	unsigned int reserved;
}SIM_QUERY_PRJTYPE_REQ;

typedef struct  
{
	unsigned int prj_type;
}SIM_QUERY_PRJTYPE_CNF;

typedef struct  
{
	unsigned int reserved;
}SIM_QUERY_MDIDXSET_REQ;

typedef struct  
{
	unsigned int md_idxset;
}SIM_QUERY_MDIDXSET_CNF;

typedef struct  
{
	unsigned int mode_cmd;
}SIM_SET_SWITCHER_REQ;

typedef struct  
{
	unsigned int reserved;
}SIM_SET_SWITCHER_CNF;

typedef struct  
{
	unsigned int reserved;
}SIM_QUERY_SSW_REQ;

typedef struct  
{
	unsigned int ssw_val;
}SIM_QUERY_SSW_CNF;


META_RESULT __stdcall SP_META_SIM_Check_ExtMd_r(const int meta_handle, unsigned int  ms_timeout, SIM_QUERY_MDTYPE_REQ *pReq ,SIM_QUERY_MDTYPE_CNF *pCnf);
META_RESULT __stdcall SP_META_SIM_Check_ExtMd(unsigned int  ms_timeout, SIM_QUERY_MDTYPE_REQ *pReq ,SIM_QUERY_MDTYPE_CNF *pCnf);

META_RESULT __stdcall SP_META_SIM_Query_PrjType_r(const int meta_handle, unsigned int  ms_timeout, SIM_QUERY_PRJTYPE_REQ *pReq ,SIM_QUERY_PRJTYPE_CNF *pCnf);
META_RESULT __stdcall SP_META_SIM_Query_PrjType(unsigned int  ms_timeout, SIM_QUERY_PRJTYPE_REQ *pReq ,SIM_QUERY_PRJTYPE_CNF *pCnf);

META_RESULT __stdcall SP_META_SIM_Query_MdIdxSet_r(const int meta_handle, unsigned int  ms_timeout, SIM_QUERY_MDIDXSET_REQ *pReq ,SIM_QUERY_MDIDXSET_CNF *pCnf);
META_RESULT __stdcall SP_META_SIM_Query_MdIdxSet(unsigned int  ms_timeout, SIM_QUERY_MDIDXSET_REQ *pReq ,SIM_QUERY_MDIDXSET_CNF *pCnf);

META_RESULT __stdcall SP_META_SIM_Set_Switcher_r(const int meta_handle, unsigned int  ms_timeout, SIM_SET_SWITCHER_REQ *pReq ,SIM_SET_SWITCHER_CNF *pCnf);
META_RESULT __stdcall SP_META_SIM_Set_Switcher(unsigned int  ms_timeout, SIM_SET_SWITCHER_REQ *pReq ,SIM_SET_SWITCHER_CNF *pCnf);

META_RESULT __stdcall SP_META_SIM_Query_SSW_r(const int meta_handle, unsigned int  ms_timeout, SIM_QUERY_SSW_REQ *pReq ,SIM_QUERY_SSW_CNF *pCnf);
META_RESULT __stdcall SP_META_SIM_Query_SSW(unsigned int  ms_timeout, SIM_QUERY_SSW_REQ *pReq, SIM_QUERY_SSW_CNF *pCnf);

//for mdlogger ctrl
typedef struct  
{
	unsigned int mode;     //1: usb, 2:SD
	unsigned int action;   //0: stop, 1: start
}MDLOGGER_SWITCH_MODE_REQ;

typedef struct  
{
	unsigned int reserved;
}MDLOGGER_SWITCH_MODE_CNF;

typedef struct  
{
	unsigned int reserved;

}MDLOGGER_QUERY_STATUS_REQ;

typedef struct  
{
	unsigned int status;  //0: stop 1:logging
}MDLOGGER_QUERY_STATUS_CNF;

typedef struct  
{
	unsigned int reserved;
	
}MDLOGGER_QUERY_LOGPATH_REQ;

typedef struct  
{
	unsigned char path[256];
}MDLOGGER_QUERY_LOGPATH_CNF;

META_RESULT __stdcall SP_META_Mdlogger_Switch_Mode_r(const int meta_handle, unsigned int  ms_timeout, MDLOGGER_SWITCH_MODE_REQ *pReq, MDLOGGER_SWITCH_MODE_CNF *pCnf);
META_RESULT __stdcall SP_META_Mdlogger_Switch_Mode(unsigned int  ms_timeout,MDLOGGER_SWITCH_MODE_REQ *pReq, MDLOGGER_SWITCH_MODE_CNF *pCnf);

META_RESULT __stdcall SP_META_Mdlogger_Query_Status_r(const int meta_handle, unsigned int  ms_timeout, MDLOGGER_QUERY_STATUS_CNF *pCnf);
META_RESULT __stdcall SP_META_Mdlogger_Query_status(unsigned int  ms_timeout, MDLOGGER_QUERY_STATUS_CNF *pCnf);

META_RESULT __stdcall SP_META_Mdlogger_Query_NormalLog_Path_r(const int meta_handle, unsigned int ms_timeout, MDLOGGER_QUERY_LOGPATH_CNF *pCnf);
META_RESULT __stdcall SP_META_Mdlogger_Query_NormalLog_Path(unsigned int ms_timeout, MDLOGGER_QUERY_LOGPATH_CNF *pCnf);

META_RESULT __stdcall SP_META_Mdlogger_Query_EELog_Path_r(const int meta_handle, unsigned int ms_timeout, MDLOGGER_QUERY_LOGPATH_CNF *pCnf);
META_RESULT __stdcall SP_META_Mdlogger_Query_EELog_Path(unsigned int ms_timeout, MDLOGGER_QUERY_LOGPATH_CNF *pCnf);


// for mobilelog ctrl
typedef struct  
{
	unsigned int mode;     //reserved, in the future maybe->1: usb, 2:SD
	unsigned int action;   //0: stop, 1: start
}MOBILELOG_SWITCH_MODE_REQ;

typedef struct  
{
	unsigned int reserved;
}MOBILELOG_SWITCH_MODE_CNF;

typedef struct  
{
	unsigned int reserved;
	
}MOBILELOG_QUERY_LOGPATH_REQ;

typedef struct  
{
	unsigned char path[256];
}MOBILELOG_QUERY_LOGPATH_CNF;

META_RESULT __stdcall SP_META_Mobilelog_Switch_Mode_r(const int meta_handle, unsigned int  ms_timeout, MOBILELOG_SWITCH_MODE_REQ *pReq, MOBILELOG_SWITCH_MODE_CNF *pCnf);
META_RESULT __stdcall SP_META_Mobilelog_Switch_Mode(unsigned int  ms_timeout,MOBILELOG_SWITCH_MODE_REQ *pReq, MOBILELOG_SWITCH_MODE_CNF *pCnf);

META_RESULT __stdcall SP_META_Mobilelog_Query_Log_Path_r(const int meta_handle, unsigned int ms_timeout, MOBILELOG_QUERY_LOGPATH_CNF *pCnf);
META_RESULT __stdcall SP_META_Mobilelog_Query_Log_Path(unsigned int ms_timeout, MOBILELOG_QUERY_LOGPATH_CNF *pCnf);


//for ADC CAR TUNE Value
META_RESULT  __stdcall SP_META_ADC_SetCarTuneVal_r(const int meta_handle, unsigned int ms_timeout, int val);
META_RESULT  __stdcall SP_META_ADC_SetCarTuneVal(unsigned int ms_timeout, int val);

META_RESULT  __stdcall SP_META_ADC_GetCarTuneVal_r(const int meta_handle, unsigned int ms_timeout, int *val);
META_RESULT  __stdcall SP_META_ADC_GetCarTuneVal(unsigned int ms_timeout, int *val);

//for multi-log
META_RESULT  __stdcall SP_META_Open_Multi_Thread_Log(const char* filename, int nThreadID);
META_RESULT  __stdcall SP_META_Close_Multi_Thread_Log(int nThreadID);
META_RESULT  __stdcall SP_META_Set_Multi_Thread_ID(const int meta_handle, int nThreadID);
META_RESULT  __stdcall SP_META_InsertConfirmThreadId(const int meta_handle);
//
//query WCN driver ready
typedef struct
{
    unsigned int result;
}QUERY_WCNDRIVER_READY_CNF;

META_RESULT __stdcall SP_META_Query_WCNDriver_Ready_r(const int meta_handle, unsigned int  ms_timeout, QUERY_WCNDRIVER_READY_CNF *pCnf);
META_RESULT __stdcall SP_META_Query_WCNDriver_Ready(unsigned int  ms_timeout, QUERY_WCNDRIVER_READY_CNF *pCnf);


typedef struct  
{
	unsigned char path_name[256];    //folder path
	unsigned char filename_substr[256];  //file name sub string,if set it as "*", we will parse all the file in the folder
}FILE_OPERATION_PARSE_REQ;

typedef struct  
{
	unsigned int file_count;        //file count for folder
}FILE_OPERATION_PARSE_CNF;


typedef struct  
{
	unsigned int index;             //[0, file_count)
}FILE_OPERATION_GETFILEINFO_REQ;

typedef enum 
{
	FT_FILE_TYPE_INVALID = 0,
	FT_FILE_TYPE_FILE = 1,
	FT_FILE_TYPE_FOLDER = 2,
	FT_FILE_TYPE_END = 0x0fffffff
}FT_FILE_TYPE;

typedef struct
{
	unsigned int file_type;
	unsigned int file_size;    //if the file_type is folder, we will return file_size as 0.
	unsigned char file_name[256];
}FT_FILE_INFO;

typedef struct  
{
    FT_FILE_INFO file_info;	
}FILE_OPERATION_GETFILEINFO_CNF;


META_RESULT __stdcall SP_META_File_Operation_Parse_r(const int meta_handle, unsigned int  ms_timeout, FILE_OPERATION_PARSE_REQ *pReq, FILE_OPERATION_PARSE_CNF *pCnf);
META_RESULT __stdcall SP_META_File_Operation_Parse(unsigned int  ms_timeout, FILE_OPERATION_PARSE_REQ *pReq, FILE_OPERATION_PARSE_CNF *pCnf);

META_RESULT __stdcall SP_META_File_Operation_GetFileInfo_r(const int meta_handle, unsigned int  ms_timeout, FILE_OPERATION_GETFILEINFO_REQ *pReq, FILE_OPERATION_GETFILEINFO_CNF *pCnf);
META_RESULT __stdcall SP_META_File_Operation_GetFileInfo(unsigned int  ms_timeout, FILE_OPERATION_GETFILEINFO_REQ *pReq, FILE_OPERATION_GETFILEINFO_CNF *pCnf);

META_RESULT __stdcall SP_META_File_Operation_SendFile_r(const int meta_handle, unsigned int  ms_timeout, const char *pSourceFileName, const char *pDestFileName);
META_RESULT __stdcall SP_META_File_Operation_SendFile(unsigned int  ms_timeout, const char *pSourceFileName, const char *pDestFileName);

META_RESULT __stdcall SP_META_File_Operation_ReceiveFile_r(const int meta_handle, unsigned int  ms_timeout, const char *pSourceFileName, const char *pDestFileName);
META_RESULT __stdcall SP_META_File_Operation_ReceiveFile(unsigned int  ms_timeout, const char *pSourceFileName, const char *pDestFileName);


//
//switch usb/socket connect
typedef struct
{
    unsigned int flag;   //0: wifi to usb,  1: usb to wifi
}SWITCH_WIFI_USB_REQ;

typedef struct
{
    unsigned int result;
}SWITCH_WIFI_USB_CNF;

META_RESULT __stdcall SP_META_Switch_WiFiUSB_r(const int meta_handle, unsigned int  ms_timeout, SWITCH_WIFI_USB_REQ *pReq, SWITCH_WIFI_USB_CNF *pCnf);
META_RESULT __stdcall SP_META_Switch_WiFiUSB(unsigned int  ms_timeout, SWITCH_WIFI_USB_REQ *pReq, SWITCH_WIFI_USB_CNF *pCnf);


//RAT Config

typedef struct
{
    unsigned char optr[64];
}RATCONFIG_READOPTR_CNF;

META_RESULT __stdcall SP_META_RATConfig_ReadOptr_r(const int meta_handle, unsigned int  ms_timeout, RATCONFIG_READOPTR_CNF *pCnf);
META_RESULT __stdcall SP_META_RATConfig_ReadOptr(unsigned int  ms_timeout, RATCONFIG_READOPTR_CNF *pCnf);


typedef struct
{
    unsigned char optrseg[64];
}RATCONFIG_READOPTRSEG_CNF;

META_RESULT __stdcall SP_META_RATConfig_ReadOptrSeg_r(const int meta_handle, unsigned int  ms_timeout, RATCONFIG_READOPTRSEG_CNF *pCnf);
META_RESULT __stdcall SP_META_RATConfig_ReadOptrSeg(unsigned int  ms_timeout, RATCONFIG_READOPTRSEG_CNF *pCnf);


typedef struct
{
    unsigned char rat_value[64];
}RATCONFIG_GETCURRENTRAT_CNF;

META_RESULT __stdcall SP_META_RATConfig_GetCurrentRat_r(const int meta_handle, unsigned int  ms_timeout, RATCONFIG_GETCURRENTRAT_CNF *pCnf);
META_RESULT __stdcall SP_META_RATConfig_GetCurrentRat(unsigned int  ms_timeout, RATCONFIG_GETCURRENTRAT_CNF *pCnf);


typedef struct
{
    unsigned char set_rat_value[64];
}RATCONFIG_SETNEWRAT_REQ;


typedef struct
{
    unsigned int set_result; //0:Fail; 1:Success, need reboot target; 2:Success, no need reboot
}RATCONFIG_SETNEWRAT_CNF;

META_RESULT __stdcall SP_META_RATConfig_SetNewRat_r(const int meta_handle, unsigned int  ms_timeout, RATCONFIG_SETNEWRAT_REQ *pReq, RATCONFIG_SETNEWRAT_CNF *pCnf);
META_RESULT __stdcall SP_META_RATConfig_SetNewRat(unsigned int  ms_timeout, RATCONFIG_SETNEWRAT_REQ *pReq, RATCONFIG_SETNEWRAT_CNF *pCnf);


//Multi-SIM
typedef struct
{
    unsigned char msim_value[16];
} MSIM_GETVALUE_CNF;


META_RESULT __stdcall SP_META_MSIM_GetValue_r(const int meta_handle, unsigned int  ms_timeout, MSIM_GETVALUE_CNF *pCnf);
META_RESULT __stdcall SP_META_MSIM_GetValue(unsigned int ms_timeout, MSIM_GETVALUE_CNF *pCnf);

typedef struct
{
    unsigned char msim_value[16];
} MSIM_SETVALUE_REQ;

typedef struct
{
    unsigned int set_result;
} MSIM_SETVALUE_CNF;

META_RESULT __stdcall SP_META_MSIM_SetValue_r(const int meta_handle, unsigned int  ms_timeout, MSIM_SETVALUE_REQ *pReq, MSIM_SETVALUE_CNF *pCnf);
META_RESULT __stdcall SP_META_MSIM_SetValue(unsigned int ms_timeout, MSIM_SETVALUE_REQ *pReq, MSIM_SETVALUE_CNF *pCnf);

typedef struct
{
	unsigned int reserved; //reserved, no use
} QUERY_APDBPATH_REQ;

typedef struct 
{
	unsigned char apdb_path[128];
} QUERY_APDBPATH_CNF;

META_RESULT __stdcall SP_META_Query_APDBPath(unsigned int ms_timeout, QUERY_APDBPATH_REQ *pReq,QUERY_APDBPATH_CNF *pCnf);
META_RESULT __stdcall SP_META_Query_APDBPath_r(const int meta_handle, unsigned int ms_timeout, QUERY_APDBPATH_REQ *pReq, QUERY_APDBPATH_CNF *pCnf);

////////////////////////////////////////////////////////////////////////////
/*****************For production line tool test flag start*****************/

/////////////////////////////////////////////////////////
/***************From mtk_test_flag.h file***************/
/* 
* ****************************************
*                 ATE_Tool
* ****************************************
*/
typedef struct _s_ate_gsm_flag
{
    //unsigned char        total_pass:1;
    //unsigned char        tadc:1;
    //unsigned char        afc:1;
    //unsigned char        capid:1;
    //unsigned char        agc:1;
    //unsigned char        w_coe:1;
    //unsigned char        gmsk_apc:1;
    //unsigned char        gmsk_apc_subband:1;
    //unsigned char        epsk_apc:1;
    //unsigned char        epsk_apc_subband:1;
    //unsigned char        LPM:1;
    //unsigned char        trx_offset:1;
    //unsigned char        b_reserved:4;
    //unsigned char        reserved[2];
	unsigned char        ate_gsm_flag[4];
} s_ate_gsm_flag;         // 4Bytes

typedef struct _s_ate_tdscdma_flag
{
    //unsigned char        total_pass:1;
    //unsigned char        tadc:1;
    //unsigned char        afc:1;
    //unsigned char        capid:1;
    //unsigned char        agc:1;
    //unsigned char        apc:1;
    //unsigned char        subband:1;
    //unsigned char        b_reserved:1;
    //unsigned char        reserved[1];
	unsigned char        ate_tdscdma_flag[2];
} s_ate_tdscdma_flag;    // 2Bytes

typedef struct _s_ate_wcdma_flag
{
    //unsigned char        total_pass:1;
    //unsigned char        tadc:1;
    //unsigned char        afc:1;
    //unsigned char        capid:1;
    //unsigned char        agc:1;
    //unsigned char        rxd:1;
    //unsigned char        apc:1;
    //unsigned char        subband:1;
    //unsigned char        reserved[1];
	unsigned char        ate_wcdma_flag[2];
} s_ate_wcdma_flag;      // 2Bytes

typedef struct _s_ate_lte_flag
{
    //unsigned char        total_pass:1;
    //unsigned char        tadc:1;
    //unsigned char        afc:1;
    //unsigned char        capid:1;
    //unsigned char        agc:1;
    //unsigned char        rxd:1;
    //unsigned char        apc:1;
    //unsigned char        subband:1;
    //unsigned char        reserved[1];
	unsigned char        ate_lte_flag[2];
} s_ate_lte_flag;    // 2Bytes

typedef struct _s_ate_cdma_flag
{
    //unsigned char        total_pass:1;
    //unsigned char        tadc:1;
    //unsigned char        afc:1;
    //unsigned char        capid:1;
    //unsigned char        agc:1;
    //unsigned char        rxd:1;
    //unsigned char        apc:1;
    //unsigned char        subband:1;
    //unsigned char        reserved[1];
	unsigned char        ate_cdma_flag[2];
} s_ate_cdma_flag;      // 2Bytes

typedef struct _s_ate_nsft_flag
{
    //unsigned char        gsm:1;
    //unsigned char        tdscdma:1;
    //unsigned char        wcdma:1;
    //unsigned char        lte:1;
    //unsigned char        cdma:1;
    //unsigned char        b_reserved:3;
    //unsigned char        reserved[1];
	unsigned char        ate_nsft_flag[2];
} s_ate_nsft_flag;      // 2Bytes

typedef struct _s_ate_wireless_flag
{
    //unsigned char        gsm:1;
    //unsigned char        tdscdma:1;
    //unsigned char        wcdma:1;
    //unsigned char        lte:1;
    //unsigned char        cdma:1;
    //unsigned char        b_reserved:3;
    //unsigned char        reserved[1];
	unsigned char        ate_wireless_flag[2];
} s_ate_wireless_flag;  // 2Bytes

typedef struct s_ate_other_flag
{
    //unsigned char        gpscoclock:1;
    //unsigned char        b_reserved:7;
	unsigned char        ate_other_flag[1];
} s_ate_other_flag;     // 1Bytes

typedef struct _s_ate_flag
{
    unsigned char                    sw_index;
    unsigned char                    md_index;
    
    s_ate_gsm_flag        	gsm_flag;
    s_ate_tdscdma_flag  	tdscdma_flag;
    s_ate_wcdma_flag     	wcdma_flag;
    s_ate_lte_flag    	    lte_flag;
    s_ate_cdma_flag         cdma_flag;
    s_ate_other_flag      	other_flag;
    s_ate_nsft_flag      	nsft_flag;
    s_ate_wireless_flag 	wireless_flag;
    
    unsigned char                    reserved[3];
} s_ate_flag;       // 22Bytes


/* 
* ****************************************
*                 WCN_ATE_Tool
* ****************************************
*/
typedef struct _s_wcn_ate_flag
{
    //unsigned char        wifi_2g_cal:1;
    //unsigned char        wifi_5g_cal:1;
    //unsigned char	    cal_reserved:6;
    
    //unsigned char        wifi:1;
    //unsigned char        bt:1;
    //unsigned char        gps:1;
    //unsigned char        fm:1;
    //unsigned char	    nsft_reserved:4;
    //unsigned char	    reserved[2];
	unsigned char        wcn_ate_flag[4];
} s_wcn_ate_flag;   // 4Bytes

/* 
* ****************************************
*                 HW_Test_Tool
* ****************************************
*/
typedef struct _s_hw_test_flag
{
    //total pass flag
    //unsigned char        total_pass:1;
    
    //test item check flag
    //Auto Test
    //unsigned char        bluebooth_check:1;
    //unsigned char        wifi_check:1;
    //unsigned char        gps_check:1;
    //unsigned char        fm_check:1;
    //unsigned char        sdcard_check:1;
    //unsigned char        sim1_check:1;
    //unsigned char        sim2_check:1;
    //unsigned char        msensor_check:1;
    //unsigned char        gsensor_check:1;
    //unsigned char        alspssensor_check:1;
    //unsigned char        ctp_check:1;
    //unsigned char        nfc_check:1;
    //unsigned char        sdio_autoK:1;
    //unsigned char        b_reserved_auto_check:2; //2 Bytes
    //unsigned char        reserved_auto_check[2];  //2 Bytes
    
    //Manual Test
    //unsigned char        keypadled_check:1;
    //unsigned char        vibrator_check:1;
    //unsigned char        indexled_check:1;
    //unsigned char        lcmbacklight_check:1;
    //unsigned char        lcm_check:1;
    //unsigned char        speakerl_check:1;
    //unsigned char        speakerr_check:1;
    //unsigned char        receiver_check:1;
    //unsigned char        mic1loopback_check:1;
    //unsigned char        mic2loopback_check:1;
    //unsigned char        photoflash_check:1;
    //unsigned char        camera_check:1;
    //unsigned char        subcamera_check:1;
    //unsigned char        b_reserved_manual_check:3; //2 Bytes
    //unsigned char        reserved_manual_check[2];  //2 Bytes
    //test item check flag end(26bit)
    
    //test item flag
    //Auto Test
    //unsigned char        bluebooth:1;
    //unsigned char        wifi:1;
    //unsigned char        gps:1;
    //unsigned char        fm:1;
    //unsigned char        sdcard:1;
    //unsigned char        sim1:1;
    //unsigned char        sim2:1;
    //unsigned char        msensor:1;
    //unsigned char        gsensor:1;
    //unsigned char        alspssensor:1;
    //unsigned char        ctp:1;
    //unsigned char        nfc:1;
    //unsigned char        sdio:1;
    //unsigned char        b_reserved_auto:3; //2 Bytes
    //unsigned char        reserved_auto[2];  //2 Bytes
    
    //Manual Test
    //unsigned char        keypadled:1;
    //unsigned char        vibrator:1;
    //unsigned char        indexled:1;
    //unsigned char        lcmbacklight:1;
    //unsigned char        lcm:1;
    //unsigned char        speakerl:1;
    //unsigned char        speakerr:1;
    //unsigned char        receiver:1;
    //unsigned char        mic1loopback:1;
    //unsigned char        mic2loopback:1;
    //unsigned char        photoflash:1;
    //unsigned char        camera:1;
    //unsigned char        subcamera:1;
    //unsigned char        b_reserved_manual:3; //2 Bytes
    //unsigned char        reserved_manual[2];  //2 Bytes
    //test item flag end(51bit)
    
    //default no use
    //Auto Test
    //unsigned char        dvb_check:1;
    //unsigned char        battery_check:1;
    //unsigned char        pmic_check:1;
    //unsigned char        eint_check:1;
    //unsigned char        gpioin_check:1;
    //unsigned char        sim3_check:1;
    //unsigned char        sim4_check:1;
    //Manual Test
    //unsigned char        earphone_check:1;
    //unsigned char        pwm_check:1;
    //unsigned char        sleepmode_check:1;
    //unsigned char        charging_check:1;
    //unsigned char        gpiooutput_check:1;
    
    //Auto Test
    //unsigned char        dvb:1;
    //unsigned char        battery:1;
    //unsigned char        pmic:1;
    //unsigned char        eint:1;
    //unsigned char        gpioin:1;
    //unsigned char        sim3:1;
    //unsigned char        sim4:1;
    //Manual Test
    //unsigned char        earphone:1;
    //unsigned char        pwm:1;
    //unsigned char        sleepmode:1;
    //unsigned char        charging:1;
    //unsigned char        gpiooutput:1;
    
    //unsigned char        reserved[1];    //1 Byte
    unsigned char        hw_test_flag[20];
} s_hw_test_flag;               // 20Bytes

/* 
* ****************************************
*            ATA_Tool & Factory Mode
* ****************************************
*/
typedef struct _s_factory_mode_flag
{
    unsigned char	    ata_flag;
    unsigned char	    reserved[20-1];
} s_factory_mode_flag;	// 20Bytes

/* 
* ****************************************
*            SN Writer
* ****************************************
*/
typedef struct _s_sn_write_flag
{
    //unsigned char        total_pass:1;
    //unsigned char        barcode:1;
    //unsigned char        IMEI:1;
    //unsigned char        bt:1;
    //unsigned char        wifi:1;
    //unsigned char        MEID:1;
    //unsigned char        reserved:10;
    unsigned char        sn_write_flag[2];
} s_sn_write_flag;  // 2Bytes


/* 
* ****************************************
*            s_proinfo_test_flag
* ****************************************
*/
typedef struct _s_mtk_test_flag
{
    s_ate_flag			ate_flag[5];	// 110Bytes
    s_wcn_ate_flag		wcn_ate_flag;	// 4Bytes
    s_hw_test_flag		hw_test_flag;	// 20Bytes
    s_factory_mode_flag	factory_mode_flag; // 20Bytes
    s_sn_write_flag     sn_write_flag;  //2Bytes
    unsigned char	    reserved[14];
} s_mtk_test_flag;	// 170Bytes
/////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////
/*********From CFG_PRODUCT_INFO_File.h file*************/
// the record structure define of PRODUCT_INFO nvram file
typedef struct
{
    unsigned char   imei[8];
    unsigned char   svn;
    unsigned char   pad;
} nvram_ef_imei_imeisv_struct;

typedef struct
{
    unsigned char   BTAddr[6];
    unsigned char   WifiAddr[6];
    unsigned char   ADBSeriaNo[20];
    unsigned char   revered[32];
} s_target_info_record;

typedef struct
{
    unsigned char  boot_mode;   //0:normal, 1: meta, etc
    unsigned char  com_type;    //0:unknow com, 1:uart, 2:usb
	unsigned char  com_id;      // 0:enable mobile log meta mode, enable adb(composite device)
                                // 1:enable mobile log meta mode, disable adb(single device)
                                // 2:disable mobile log meta mode, enable adb(composite device)
                                // 3:disable mobile log meta mode, disable adb(single device)
} s_mtk_boot_mode_flag;


typedef struct
{
    unsigned char               barcode[64];    // 64B
    nvram_ef_imei_imeisv_struct IMEI[4];        // 40B
    s_target_info_record        target_info;    // 64B
    s_mtk_test_flag             mtk_test_flag;  // 170B
	s_mtk_boot_mode_flag        mtk_boot_mode_flag; //3B
    unsigned char reserved[1024-170-64-40-64-3];
}PRODUCT_INFO;
/////////////////////////////////////////////////////////

/*******************For production line tool test flag end*****************/
////////////////////////////////////////////////////////////////////////////

//};

#ifdef __cplusplus
}
#endif

#endif