bool F54_SetRawCapData(struct i2c_client *ts_client, s16 *node_data) { u8 *ImageBuffer; int i, k, length; unsigned char command; client = ts_client; RegSetup(); /* PDT scan for reg map adress mapping */ length = numberOfTx * numberOfRx * 2; /* Set report mode to to run the AutoScan */ command = 0x03; writeRMI(F54_Data_Base, &command, 1); command = 0x00; writeRMI(F54_Data_LowIndex, &command, 1); writeRMI(F54_Data_HighIndex, &command, 1); /* Set the GetReport bit to run the AutoScan */ command = 0x01; writeRMI(F54_Command_Base, &command, 1); /* Wait until the command is completed */ do { udelay(1000); readRMI(F54_Command_Base, &command, 1); } while (command == 0x01); ImageBuffer = kmalloc(sizeof(u8) * CFG_F54_TXCOUNT * CFG_F54_RXCOUNT * 2, GFP_KERNEL); if (ImageBuffer == NULL) { pr_err("tsp fw. : alloc fw. memory failed.\n"); return false; } /* Read raw_cap data */ readRMI(F54_Data_Buffer, ImageBuffer, length); for (i = 0, k = 0; i < numberOfTx * numberOfRx; i++, k += 2) node_data[i] = (s16)(ImageBuffer[k] | (ImageBuffer[k + 1] << 8)); /* reset TSP IC */ SetPage(0x00); command = 0x01; writeRMI(F01_Command_Base, &command, 1); udelay(160); readRMI(F01_Data_Base + 1, &command, 1); kfree(ImageBuffer); return true; }
bool F54_TxToTest(struct i2c_client *ts_client, s16 *node_data, int mode) { u8 ImageBuffer[CFG_F54_TXCOUNT] = {0, }; u8 ImageArray[CFG_F54_TXCOUNT] = {0, }; u8 command; int i, k, length, shift; client = ts_client; RegSetup(); /* PDT scan for reg map adress mapping */ length = (numberOfTx + 7) / 8; /* Set report mode to run Tx-to-Tx */ command = mode; writeRMI(F54_Data_Base, &command, 1); command = 0x00; writeRMI(F54_Data_LowIndex, &command, 1); writeRMI(F54_Data_HighIndex, &command, 1); /* Set the GetReport bit to run Tx-to-Tx */ command = 0x01; writeRMI(F54_Command_Base, &command, 1); /* Wait until the command is completed */ do { mdelay(1); readRMI(F54_Command_Base, &command, 1); } while (command != 0x00); readRMI(F54_Data_Buffer, &ImageBuffer[0], length); if (mode == TX_TO_TX_TEST_MODE) { /* One bit per transmitter channel */ for (i = 0, k = 0; i < numberOfTx; i++) { k = i / 8; shift = i % 8; node_data[i] = ImageBuffer[k] & (1 << shift); } } else if (mode == TX_TO_GND_TEST_MODE) { /* One bit per transmitter channel */ for (i = 0, k = 0; i < length * 8; i++) { k = i / 8; shift = i % 8; if (ImageBuffer[k] & (1 << shift)) ImageArray[i] = 1; } for (i = 0; i < numberOfTx; i++) node_data[i] = ImageArray[TxChannelUsed[i]]; } /* enable all the interrupts */ SetPage(0x00); command = 0x01; writeRMI(F01_Command_Base, &command, 1); msleep(160); // 160ms /* Read Interrupt status register to Interrupt line goes to high */ readRMI(F01_Data_Base+1, &command, 1); return true; }
bool F54_SetRxToRxData(struct i2c_client *ts_client, s16 *node_data) { u8 *ImageBuffer; int i, k, length; u8 command; client = ts_client; RegSetup(); /* PDT scan for reg map adress mapping */ /* Set report mode to run Rx-to-Rx 1st data */ length = numberOfRx * numberOfTx * 2; command = 0x07; writeRMI(F54_Data_Base, &command, 1); /* NoCDM4 */ command = 0x01; writeRMI(NOISEMITIGATION, &command, 1); command = 0x04; writeRMI(F54_Command_Base, &command, 1); do { mdelay(1); readRMI(F54_Command_Base, &command, 1); } while (command != 0x02); command = 0x02; writeRMI(F54_Command_Base, &command, 1); do { mdelay(1); readRMI(F54_Command_Base, &command, 1); } while (command != 0x00); command = 0x00; writeRMI(F54_Data_LowIndex, &command, 1); writeRMI(F54_Data_HighIndex, &command, 1); /* Set the GetReport bit to run Tx-to-Tx */ command = 0x01; writeRMI(F54_Command_Base, &command, 1); /* Wait until the command is completed */ do { mdelay(1); readRMI(F54_Command_Base, &command, 1); } while (command != 0x00); ImageBuffer = kmalloc(sizeof(u8) * CFG_F54_TXCOUNT * CFG_F54_RXCOUNT * 2, GFP_KERNEL); if (ImageBuffer == NULL) { pr_err("tsp fw. : alloc fw. memory failed.\n"); return false; } readRMI(F54_Data_Buffer, &ImageBuffer[0], length); for (i = 0, k = 0; i < numberOfTx * numberOfRx; i++, k += 2) { node_data[i] = (s16)((ImageBuffer[k] | (ImageBuffer[k + 1] << 8))); } /* Set report mode to run Rx-to-Rx 2nd data */ length = numberOfRx * (numberOfRx - numberOfTx) * 2; command = 0x11; writeRMI(F54_Data_Base, &command, 1); command = 0x00; writeRMI(F54_Data_LowIndex, &command, 1); writeRMI(F54_Data_HighIndex, &command, 1); /* Set the GetReport bit to run Tx-to-Tx */ command = 0x01; writeRMI(F54_Command_Base, &command, 1); /* Wait until the command is completed */ do { mdelay(1); readRMI(F54_Command_Base, &command, 1); } while (command != 0x00); readRMI(F54_Data_Buffer, &ImageBuffer[0], length); for (i = 0, k = 0; i < (numberOfRx - numberOfTx) * numberOfRx; i++, k += 2) node_data[(numberOfTx * numberOfRx) + i] = (s16)(ImageBuffer[k] | (ImageBuffer[k + 1] << 8)); /* Set the Force Cal */ command = 0x02; writeRMI(F54_Command_Base, &command, 1); do { mdelay(1); readRMI(F54_Command_Base, &command, 1); } while (command != 0x00); /* enable all the interrupts */ SetPage(0x00); command = 0x01; writeRMI(F01_Command_Base, &command, 1); msleep(160); /* Read Interrupt status register to Interrupt line goes to high */ readRMI(F01_Data_Base+1, &command, 1); kfree(ImageBuffer); return true; }
bool F54_SetRawCapData(struct i2c_client *ts_client, s16 *node_data) { u8 *ImageBuffer; int i, j, k, x, length; unsigned char command; client = ts_client; RegSetup(); /* PDT scan for reg map adress mapping */ length = numberOfTx * numberOfRx * 2; /* Set report mode to to run the AutoScan */ command = 0x03; writeRMI(F54_Data_Base, &command, 1); /* NoCDM4 */ command = 0x01; writeRMI(NOISEMITIGATION, &command, 1); command = 0x06; writeRMI(F54_Command_Base, &command, 1); do { mdelay(1); readRMI(F54_Command_Base, &command, 1); } while (command != 0x00); command = 0x00; writeRMI(F54_Data_LowIndex, &command, 1); writeRMI(F54_Data_HighIndex, &command, 1); /* Set the GetReport bit to run the AutoScan */ command = 0x01; writeRMI(F54_Command_Base, &command, 1); /* Wait until the command is completed */ do { mdelay(1); readRMI(F54_Command_Base, &command, 1); } while (command != 0x00); ImageBuffer = kmalloc(sizeof(u8) * CFG_F54_TXCOUNT * CFG_F54_RXCOUNT * 2, GFP_KERNEL); if (ImageBuffer == NULL) { pr_err("tsp fw. : alloc fw. memory failed.\n"); return false; } /* Read raw_cap data */ readRMI(F54_Data_Buffer, ImageBuffer, length); x=0; k=0; for (i=0; i<numberOfTx;i++) { for (j=0; j<numberOfRx;j++) { if(j != (numberOfRx-1)) { node_data[x] = (s16)(ImageBuffer[k] | (ImageBuffer[k + 1] << 8)); //printk(" %d", node_data[x]); x++; } k+=2; } } #if 1 /* reset TSP IC */ SetPage(0x00); command = 0x01; writeRMI(F01_Command_Base, &command, 1); printk("[TSP] %s, %d\n", __func__, __LINE__ ); mdelay(160); printk("[TSP] %s, %d\n", __func__, __LINE__ ); readRMI(F01_Data_Base + 1, &command, 1); #endif kfree(ImageBuffer); return true; }