update FTC to v1.0.0.2, add ftc-stop
authorPeter Li <peter-li@ti.com>
Sat, 18 Mar 2017 00:01:14 +0000 (08:01 +0800)
committerPeter Li <peter-li@ti.com>
Sat, 18 Mar 2017 00:01:14 +0000 (08:01 +0800)
lib/libftc32.a [changed mode: 0755->0644]
lib/libftc64.a [changed mode: 0755->0644]
tas2557.c
tas2557.h
tas2557_ftc.c
tas2557_ftc_lib.h

old mode 100755 (executable)
new mode 100644 (file)
index 8113f0c..d4c7402
Binary files a/lib/libftc32.a and b/lib/libftc32.a differ
old mode 100755 (executable)
new mode 100644 (file)
index a1708c2..db6f361
Binary files a/lib/libftc64.a and b/lib/libftc64.a differ
index 4d93ecd26ae23072a9b37991173619dc779ab19a..95bd946ed3603c8c9bac9312ae3369fa5612d204 100755 (executable)
--- a/tas2557.c
+++ b/tas2557.c
@@ -116,12 +116,15 @@ uint8_t tas2557_get_PGID(void)
        return pData[0];
 }
 
-uint32_t tas2557_coeff_read(uint8_t book, uint8_t page, uint8_t reg)
+uint32_t tas2557_coeff_read(uint32_t reg)
 {
+       uint8_t nbook = TAS2557_BOOK_ID(reg);
+       uint8_t npage = TAS2557_PAGE_ID(reg);
+       uint8_t nreg = TAS2557_PAGE_REG(reg);
        unsigned char pPageZero[] = {0x00, 0x00};
-       unsigned char pBook[] = {0x7F, book};
-       unsigned char pPage[] = {0x00, page};
-       unsigned char pData[] = {reg, 0x00, 0x00, 0x00, 0x00};
+       unsigned char pBook[] = {0x7F, nbook};
+       unsigned char pPage[] = {0x00, npage};
+       unsigned char pData[] = {nreg, 0x00, 0x00, 0x00, 0x00};
 
        tas2557_check_node();
 
@@ -133,29 +136,40 @@ uint32_t tas2557_coeff_read(uint8_t book, uint8_t page, uint8_t reg)
        return ((pData[0] << 24) | (pData[1] << 16) | (pData[2] << 8) | (pData[3]));
 }
 
-void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
+
+#define TAS2557_mCDSP_SWAP_REG TAS2557_REG(0x8c, 0x19, 0x7c)
+#define TAS2557_uCDSP_SWAP_REG TAS2557_REG(0x00, 0x35, 0x2c)
+
+void tas2557_coeff_write(uint32_t reg, uint32_t data)
 {
        unsigned int nByte;
+       uint8_t nbook, npage, nreg;
+
+       nbook = TAS2557_BOOK_ID(reg);
+       npage = TAS2557_PAGE_ID(reg);
+       nreg = TAS2557_PAGE_REG(reg);
 
+       // if the bin file is open, write the coefficients to the bin file
        if (gBinFile) {
                /* if the bin file is open, write the coefficients to the bin file */
-               unsigned int index = gnDevABlockIndex*4;
-               gpDevABlock[index] = 0;
-               gpDevABlock[index + 1] = 4;
-               gpDevABlock[index + 2] = 0x85;
-               gpDevABlock[index + 4] = book;
-               gpDevABlock[index + 5] = page;
-               gpDevABlock[index + 6] = reg;
-
-               for (nByte = 0; nByte < 4; nByte++)
-                       gpDevABlock[index + 7 + nByte] = (data >> ((3 - nByte) * 8)) & 0xFF;
-
-               gnDevABlockIndex += 3;
+                       unsigned int index = gnDevABlockIndex*4;
+
+                       gpDevABlock[index] = 0;
+                       gpDevABlock[index + 1] = 4;
+                       gpDevABlock[index + 2] = 0x85;
+                       gpDevABlock[index + 4] = nbook;
+                       gpDevABlock[index + 5] = npage;
+                       gpDevABlock[index + 6] = nreg;
+
+                       for (nByte = 0; nByte < 4; nByte++)
+                               gpDevABlock[index + 7 + nByte] = (data >> ((3 - nByte) * 8)) & 0xFF;
+
+                       gnDevABlockIndex += 3;
        } else {
                unsigned char pPageZero[] = {0x00, 0x00};
-               unsigned char pBook[] = {0x7F, book};
-               unsigned char pPage[] = {0x00, page};
-               unsigned char pData[] = {reg, (data & 0xFF000000) >> 24, (data & 0x00FF0000) >> 16, (data & 0x0000FF00) >> 8, data & 0x000000FF};
+               unsigned char pBook[] = {0x7F, nbook};
+               unsigned char pPage[] = {0x00, npage};
+               unsigned char pData[] = {nreg, (data & 0xFF000000) >> 24, (data & 0x00FF0000) >> 16, (data & 0x0000FF00) >> 8, data & 0x000000FF};
 
                tas2557_check_node();
 
@@ -164,10 +178,10 @@ void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
                write(gTILoad, pPage, 2);
                write(gTILoad, pData, 5);
 
-               pBook[1] = 0x8C;
-               pPage[1] = 0x19;
+               pBook[1] = TAS2557_BOOK_ID(TAS2557_mCDSP_SWAP_REG);
+               pPage[1] = TAS2557_PAGE_ID(TAS2557_mCDSP_SWAP_REG);
 
-               pData[0] = 0x7C;
+               pData[0] = TAS2557_PAGE_REG(TAS2557_mCDSP_SWAP_REG);
                pData[1] = 0x00;
                pData[2] = 0x00;
                pData[3] = 0x00;
@@ -178,10 +192,10 @@ void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data)
                write(gTILoad, pPage, 2);
                write(gTILoad, pData, 5);
 
-               pBook[1] = 0x00;
-               pPage[1] = 0x35;
+               pBook[1] = TAS2557_BOOK_ID(TAS2557_uCDSP_SWAP_REG);;
+               pPage[1] = TAS2557_PAGE_ID(TAS2557_uCDSP_SWAP_REG);
 
-               pData[0] = 0x2c;
+               pData[0] = TAS2557_PAGE_REG(TAS2557_uCDSP_SWAP_REG);
                pData[1] = 0x00;
                pData[2] = 0x00;
                pData[3] = 0x00;
@@ -312,10 +326,10 @@ void tas2557_close_bin(void)
        unsigned int nCommands;
        unsigned char pCommit[] = {
                0x00, 0x04, 0x85, 0x00,
-               0x8C, 0x19, 0x7C, 0x00,
+               TAS2557_BOOK_ID(TAS2557_mCDSP_SWAP_REG), TAS2557_PAGE_ID(TAS2557_mCDSP_SWAP_REG), TAS2557_PAGE_REG(TAS2557_mCDSP_SWAP_REG), 0x00,
                0x00, 0x00, 0x01, 0x00,
                0x00, 0x04, 0x85, 0x00,
-               0x00, 0x35, 0x2c, 0x00,
+               TAS2557_BOOK_ID(TAS2557_uCDSP_SWAP_REG), TAS2557_PAGE_ID(TAS2557_uCDSP_SWAP_REG), TAS2557_PAGE_REG(TAS2557_uCDSP_SWAP_REG), 0x00,
                0x00, 0x00, 0x01, 0x00
        };
 
index b6cfc590fa759ec9de80c03a78ab65c535e371c7..994bb0ae867ff731ff40dbe95b731d93c533a3dc 100755 (executable)
--- a/tas2557.h
+++ b/tas2557.h
 #include <stdint.h>\r
 #include "tas2557_ftc.h"\r
 \r
+/* 0000 0000 0BBB BBBB BPPP PPPP PRRR RRRR */\r
+\r
+#define TAS2557_REG(book, page, reg)           ((((unsigned int)book * 256 * 128) + \\r
+                                                ((unsigned int)page * 128)) + reg)\r
+\r
+#define TAS2557_BOOK_ID(reg)                   ((unsigned char)(reg / (256 * 128)))\r
+#define TAS2557_PAGE_ID(reg)                   ((unsigned char)((reg % (256 * 128)) / 128))\r
+#define TAS2557_BOOK_REG(reg)                  ((unsigned char)(reg % (256 * 128)))\r
+#define TAS2557_PAGE_REG(reg)                  ((unsigned char)((reg % (256 * 128)) % 128))\r
+\r
 #define TILOAD_IOC_MAGIC   0xE0\r
 \r
 #define TILOAD_IOCTL_SET_CHL                   _IOW(TILOAD_IOC_MAGIC, 5, int)\r
@@ -42,8 +52,8 @@
 \r
 uint8_t tas2557_get_PGID(void);\r
 void tas2557_mixer_command(char *pCommand, int nData);\r
-uint32_t tas2557_coeff_read(uint8_t book, uint8_t page, uint8_t reg);\r
-void tas2557_coeff_write(uint8_t book, uint8_t page, uint8_t reg, uint32_t data);\r
+uint32_t tas2557_coeff_read(uint32_t reg);\r
+void tas2557_coeff_write(uint32_t reg, uint32_t data);\r
 void tas2557_save_cal(struct TFTCConfiguration *pFTCC,\r
        double dev_a_re, uint32_t dev_a_rms_pow, uint32_t dev_a_t_limit,\r
        double t_cal, uint32_t,char * pFileName);\r
index b0686add9760abefb1ac011c0b4486be1125fc92..9c31224bc6daa36f26277af128c6debc15c128b6 100755 (executable)
@@ -101,6 +101,8 @@ uint32_t tas2557_ftc(double t_cal, struct TFTCConfiguration *pFTCC)
                set_temp_cal(dev_a_prm_pow, dev_a_prm_tlimit);\r
        }\r
 \r
+       tas2557_ftc_stop();\r
+\r
        sys_stop_wav(nPlaybackProcess);\r
 \r
        /* STEP 7: Save Re, and Cal Temp into a file */\r
index de688e6e0675827cf834ecc12a4436bf02f069b0..a7f96f7a2ae73851cb7d0bade78081e2a0bf94fc 100755 (executable)
@@ -39,4 +39,5 @@ void set_temp_cal(uint32_t prm_pow, uint32_t prm_tlimit);
 double get_re(double re_ppc3);\r
 uint32_t calc_prm_pow(double re, double delta_t_max, double nRTV, double nRTM, double nRTVA, double nSysGain);\r
 uint32_t calc_prm_tlimit(double delta_t_max, double alpha, double nDevNonlinPer, double nRTV, double nRTM, double nRTVA);\r
+void tas2557_ftc_stop(void);\r
 #endif /* TAS2557_LIB_FTC_H_ */\r