12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928 |
- #ifdef SEC_TSP_FACTORY_TEST
- #define TSP_FACTEST_RESULT_PASS 2
- #define TSP_FACTEST_RESULT_FAIL 1
- #define TSP_FACTEST_RESULT_NONE 0
- #define BUFFER_MAX (256 * 1024) - 16
- #define READ_CHUNK_SIZE 128 // (2 * 1024) - 16
- enum {
- TYPE_RAW_DATA = 0,
- TYPE_FILTERED_DATA = 2,
- TYPE_STRENGTH_DATA = 4,
- TYPE_BASELINE_DATA = 6
- };
- #ifdef FTS_SUPPORT_TOUCH_KEY
- enum {
- TYPE_TOUCHKEY_RAW = 0x34,
- TYPE_TOUCHKEY_STRENGTH = 0x36
- };
- #endif // FTS_SUPPORT_TOUCH_KEY
- enum {
- BUILT_IN = 0,
- UMS,
- };
- enum CMD_STATUS {
- CMD_STATUS_WAITING = 0,
- CMD_STATUS_RUNNING,
- CMD_STATUS_OK,
- CMD_STATUS_FAIL,
- CMD_STATUS_NOT_APPLICABLE,
- };
- static void fw_update(void *device_data);
- static void get_fw_ver_bin(void *device_data);
- static void get_fw_ver_ic(void *device_data);
- static void get_config_ver(void *device_data);
- static void get_threshold(void *device_data);
- static void module_off_master(void *device_data);
- static void module_on_master(void *device_data);
- static void get_chip_vendor(void *device_data);
- static void get_chip_name(void *device_data);
- static void get_x_num(void *device_data);
- static void get_y_num(void *device_data);
- static void run_reference_read(void *device_data);
- static void get_reference(void *device_data);
- static void run_rawcap_read(void *device_data);
- static void get_rawcap(void *device_data);
- static void run_delta_read(void *device_data);
- static void get_delta(void *device_data);
- static void run_abscap_read(void *device_data);
- static void run_absdelta_read(void *device_data);
- static void run_trx_short_test(void *device_data);
- static void set_tsp_test_result(void *device_data);
- static void get_tsp_test_result(void *device_data);
- static void hover_enable(void *device_data);
- static void hover_no_sleep_enable(void *device_data);
- static void glove_mode(void *device_data);
- static void get_glove_sensitivity(void *device_data);
- static void clear_cover_mode(void *device_data);
- static void fast_glove_mode(void *device_data);
- static void report_rate(void *device_data);
- #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
- static void interrupt_control(void *device_data);
- #endif
- #ifdef FTS_SUPPORT_TOUCH_KEY
- static int read_touchkey_data(struct fts_ts_info *info, unsigned char type, unsigned int keycode);
- #endif
- #if defined(TOUCH_BOOSTER_DVFS)
- static void boost_level(void *device_data);
- #endif
- static void not_support_cmd(void *device_data);
- static ssize_t store_cmd(struct device *dev, struct device_attribute *devattr,
- const char *buf, size_t count);
- static ssize_t show_cmd_status(struct device *dev,
- struct device_attribute *devattr, char *buf);
- static ssize_t show_cmd_result(struct device *dev,
- struct device_attribute *devattr, char *buf);
- static ssize_t cmd_list_show(struct device *dev,
- struct device_attribute *attr, char *buf);
- #define FT_CMD(name, func) .cmd_name = name, .cmd_func = func
- struct ft_cmd {
- struct list_head list;
- const char *cmd_name;
- void (*cmd_func) (void *device_data);
- };
- struct ft_cmd ft_cmds[] = {
- {FT_CMD("fw_update", fw_update),},
- {FT_CMD("get_fw_ver_bin", get_fw_ver_bin),},
- {FT_CMD("get_fw_ver_ic", get_fw_ver_ic),},
- {FT_CMD("get_config_ver", get_config_ver),},
- {FT_CMD("get_threshold", get_threshold),},
- {FT_CMD("module_off_master", module_off_master),},
- {FT_CMD("module_on_master", module_on_master),},
- {FT_CMD("module_off_slave", not_support_cmd),},
- {FT_CMD("module_on_slave", not_support_cmd),},
- {FT_CMD("get_chip_vendor", get_chip_vendor),},
- {FT_CMD("get_chip_name", get_chip_name),},
- {FT_CMD("get_x_num", get_x_num),},
- {FT_CMD("get_y_num", get_y_num),},
- {FT_CMD("run_reference_read", run_reference_read),},
- {FT_CMD("get_reference", get_reference),},
- {FT_CMD("run_rawcap_read", run_rawcap_read),},
- {FT_CMD("get_rawcap", get_rawcap),},
- {FT_CMD("run_delta_read", run_delta_read),},
- {FT_CMD("get_delta", get_delta),},
- {FT_CMD("run_abscap_read" , run_abscap_read),},
- {FT_CMD("run_absdelta_read", run_absdelta_read),},
- {FT_CMD("run_trx_short_test", run_trx_short_test),},
- {FT_CMD("set_tsp_test_result", set_tsp_test_result),},
- {FT_CMD("get_tsp_test_result", get_tsp_test_result),},
- {FT_CMD("hover_enable", hover_enable),},
- {FT_CMD("hover_no_sleep_enable", hover_no_sleep_enable),},
- {FT_CMD("glove_mode", glove_mode),},
- {FT_CMD("get_glove_sensitivity", get_glove_sensitivity),},
- {FT_CMD("clear_cover_mode", clear_cover_mode),},
- {FT_CMD("fast_glove_mode", fast_glove_mode),},
- {FT_CMD("report_rate", report_rate),},
- #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
- {FT_CMD("interrupt_control", interrupt_control),},
- #endif
- #if defined(TOUCH_BOOSTER_DVFS)
- {FT_CMD("boost_level", boost_level),},
- #endif
- {FT_CMD("not_support_cmd", not_support_cmd),},
- };
- static DEVICE_ATTR(cmd, S_IWUSR | S_IWGRP, NULL, store_cmd);
- static DEVICE_ATTR(cmd_status, S_IRUGO, show_cmd_status, NULL);
- static DEVICE_ATTR(cmd_result, S_IRUGO, show_cmd_result, NULL);
- static DEVICE_ATTR(cmd_list, S_IRUGO, cmd_list_show, NULL);
- static struct attribute *sec_touch_facotry_attributes[] = {
- &dev_attr_cmd.attr,
- &dev_attr_cmd_status.attr,
- &dev_attr_cmd_result.attr,
- &dev_attr_cmd_list.attr,
- NULL,
- };
- static struct attribute_group sec_touch_factory_attr_group = {
- .attrs = sec_touch_facotry_attributes,
- };
- #ifdef FTS_SUPPORT_TOUCH_KEY
- static int read_touchkey_data(struct fts_ts_info *info, unsigned char type, unsigned int keycode)
- {
- unsigned char pCMD[8] = { 0xD0, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 };
- unsigned char buf[8] = { 0 };
- int i;
- int ret = 0;
- pCMD[2] = type;
- ret = fts_read_reg(info, &pCMD[0], 3, buf, 2);
- if (ret >= 0) {
- pCMD[1] = buf[1];
- pCMD[2] = buf[0];
- } else {
- return -1;
- }
- ret = fts_read_reg(info, &pCMD[0], 3, buf, 8);
- if (ret < 0) {
- return -2;
- }
- for (i = 0 ; i < info->board->num_touchkey ; i++)
- if (info->board->touchkey[i].keycode==keycode) {
- printk("the return value is %d \n", *(unsigned short *)&buf[i*2]);
- return (*(unsigned short *)&buf[i*2]);
- }
- return -3;
- }
- #endif
- #ifdef FTS_SUPPORT_TOUCH_KEY
- static ssize_t touchkey_d_menu_show(struct device *dev,
- struct device_attribute *attr, char *buf){
- struct fts_ts_info *info = dev_get_drvdata(dev);
- int value;
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n", __func__);
- return snprintf(buf, sizeof(buf), "%s", "TSP turned off");
- }
- value = read_touchkey_data(info, TYPE_TOUCHKEY_STRENGTH, KEY_DUMMY_MENU);
- if (value<0) {
- return snprintf(buf, sizeof(buf), "Fail");
- }
- printk("touchkey_d_menu_show value is %d \n",value);
- return snprintf(buf, sizeof(buf), "%d\n", value);
- }
- static ssize_t touchkey_d_back_show(struct device *dev,
- struct device_attribute *attr, char *buf){
- struct fts_ts_info *info = dev_get_drvdata(dev);
- int value;
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n", __func__);
- return snprintf(buf, sizeof(buf), "%s", "TSP turned off");
- }
- value = read_touchkey_data(info, TYPE_TOUCHKEY_STRENGTH, KEY_BACK);
- if (value<0) {
- return snprintf(buf, sizeof(buf), "Fail");
- }
- printk("the touchkey_d_back_show value is %d \n",value);
- return snprintf(buf, sizeof(buf), "%d\n", value);
- }
- static ssize_t touchkey_recent_show(struct device *dev,
- struct device_attribute *attr, char *buf){
- struct fts_ts_info *info = dev_get_drvdata(dev);
- int value;
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n", __func__);
- return snprintf(buf, sizeof(buf), "%s", "TSP turned off");
- }
- value = read_touchkey_data(info, TYPE_TOUCHKEY_STRENGTH, KEY_RECENT);
- if (value<0) {
- return snprintf(buf, sizeof(buf), "Fail");
- }
- printk("touchkey_recent_show value is %d \n",value);
- return snprintf(buf, sizeof(buf), "%d\n", value);
- }
- static ssize_t touchkey_back_show(struct device *dev,
- struct device_attribute *attr, char *buf){
- struct fts_ts_info *info = dev_get_drvdata(dev);
- int value;
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n", __func__);
- return snprintf(buf, sizeof(buf), "%s", "TSP turned off");
- }
- value = read_touchkey_data(info, TYPE_TOUCHKEY_STRENGTH, KEY_BACK);
- if (value<0) {
- return snprintf(buf, sizeof(buf), "Fail");
- }
- printk("the touchkey_back_show value is %d \n",value);
- return snprintf(buf, sizeof(buf), "%d\n", value);
- }
- static ssize_t get_touchkey_threshold(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct fts_ts_info *info = dev_get_drvdata(dev);
- unsigned char cmd[4] =
- { 0xB2, 0x01, 0xEF, 0x02 };
- int timeout=0;
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n", __func__);
- return snprintf(buf, sizeof(buf), "%s", "TSP turned off");
- }
- info->touchkey_threshold = -1;
- fts_write_reg(info, &cmd[0], 4);
- info->cmd_state = CMD_STATUS_RUNNING;
- while (info->touchkey_threshold<0) {
- if (timeout++>30) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Time out\n", __func__);
- return snprintf(buf, sizeof(buf), "%s", "Time out");
- }
- msleep(10);
- }
- printk("touchkey_threshold value is %d \n",info->touchkey_threshold);
- return snprintf(buf, sizeof(buf), "%d\n", info->touchkey_threshold);
- }
- static ssize_t touchkey_report_dummy_key_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct fts_ts_info *data = dev_get_drvdata(dev);
- return sprintf(buf, "%s\n", data->report_dummy_key? "True" : "False");
- }
- static ssize_t touchkey_report_dummy_key_store(struct device *dev,
- struct device_attribute *attr, const char *buf,
- size_t size)
- {
- struct fts_ts_info *data = dev_get_drvdata(dev);
- int input;
- int ret;
- ret = sscanf(buf, "%d", &input);
- if (ret != 1) {
- dev_info(&data->client->dev, "%s: %d err\n",
- __func__, ret);
- return size;
- }
- if (input)
- data->report_dummy_key = true;
- else
- data->report_dummy_key = false;
- return size;
- }
- static DEVICE_ATTR(touchkey_d_menu, S_IRUGO | S_IWUSR | S_IWGRP, touchkey_d_menu_show, NULL);
- static DEVICE_ATTR(touchkey_d_back, S_IRUGO | S_IWUSR | S_IWGRP, touchkey_d_back_show, NULL);
- static DEVICE_ATTR(touchkey_recent, S_IRUGO | S_IWUSR | S_IWGRP, touchkey_recent_show, NULL);
- static DEVICE_ATTR(touchkey_back, S_IRUGO | S_IWUSR | S_IWGRP, touchkey_back_show, NULL);
- static DEVICE_ATTR(touchkey_threshold, S_IRUGO | S_IWUSR | S_IWGRP, get_touchkey_threshold, NULL);
- //static DEVICE_ATTR(brightness, S_IRUGO | S_IWUSR | S_IWGRP, NULL, touchkey_led_control);
- static DEVICE_ATTR(extra_button_event, S_IRUGO | S_IWUSR | S_IWGRP,
- touchkey_report_dummy_key_show, touchkey_report_dummy_key_store);
- static struct attribute *touchkey_attributes[] = {
- &dev_attr_touchkey_d_menu.attr,
- &dev_attr_touchkey_d_back.attr,
- &dev_attr_touchkey_recent.attr,
- &dev_attr_touchkey_back.attr,
- &dev_attr_touchkey_threshold.attr,
- //&dev_attr_brightness.attr,
- &dev_attr_extra_button_event.attr,
- NULL,
- };
- static struct attribute_group sec_touchkey_attr_group = {
- .attrs = touchkey_attributes,
- };
- #endif
- static int fts_check_index(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- int node;
- if (info->cmd_param[0] < 0
- || info->cmd_param[0] >= info->SenseChannelLength
- || info->cmd_param[1] < 0
- || info->cmd_param[1] >= info->ForceChannelLength) {
- snprintf(buff, sizeof(buff), "%s", "NG");
- strncat(info->cmd_result, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = 3;
- tsp_debug_info(true, &info->client->dev, "%s: parameter error: %u,%u\n",
- __func__, info->cmd_param[0], info->cmd_param[1]);
- node = -1;
- return node;
- }
- node =
- info->cmd_param[1] * info->SenseChannelLength + info->cmd_param[0];
- tsp_debug_info(true, &info->client->dev, "%s: node = %d\n", __func__, node);
- return node;
- }
- static ssize_t store_cmd(struct device *dev, struct device_attribute *devattr,
- const char *buf, size_t count)
- {
- struct fts_ts_info *info = dev_get_drvdata(dev);
- char *cur, *start, *end;
- char buff[CMD_STR_LEN] = { 0 };
- int len, i;
- struct ft_cmd *ft_cmd_ptr = NULL;
- char delim = ',';
- bool cmd_found = false;
- int param_cnt = 0;
- if (!info) {
- printk(KERN_ERR "%s: No platform data found\n",
- __func__);
- return -EINVAL;
- }
- if (!info->input_dev) {
- printk(KERN_ERR "%s: No input_dev data found\n",
- __func__);
- return -EINVAL;
- }
- if (strlen(buf) >= CMD_STR_LEN) {
- tsp_debug_err(true, &info->client->dev, "%s: cmd length is over(%s,%d)!!\n", __func__, buf, (int)strlen(buf));
- return -EINVAL;
- }
- if (info->cmd_is_running == true) {
- tsp_debug_err(true, &info->client->dev, "ft_cmd: other cmd is running.\n");
- goto err_out;
- }
- /* check lock */
- mutex_lock(&info->cmd_lock);
- info->cmd_is_running = true;
- mutex_unlock(&info->cmd_lock);
- info->cmd_state = 1;
- for (i = 0; i < ARRAY_SIZE(info->cmd_param); i++)
- info->cmd_param[i] = 0;
- len = (int)count;
- if (*(buf + len - 1) == '\n')
- len--;
- memset(info->cmd, 0x00, ARRAY_SIZE(info->cmd));
- memcpy(info->cmd, buf, len);
- cur = strchr(buf, (int)delim);
- if (cur)
- memcpy(buff, buf, cur - buf);
- else
- memcpy(buff, buf, len);
- tsp_debug_info(true, &info->client->dev, "COMMAND : %s\n", buff);
- /* find command */
- list_for_each_entry(ft_cmd_ptr, &info->cmd_list_head, list) {
- if (!strncmp(buff, ft_cmd_ptr->cmd_name, CMD_STR_LEN)) {
- cmd_found = true;
- break;
- }
- }
- /* set not_support_cmd */
- if (!cmd_found) {
- list_for_each_entry(ft_cmd_ptr, &info->cmd_list_head, list) {
- if (!strncmp
- ("not_support_cmd", ft_cmd_ptr->cmd_name,
- CMD_STR_LEN))
- break;
- }
- }
- /* parsing parameters */
- if (cur && cmd_found) {
- cur++;
- start = cur;
- memset(buff, 0x00, ARRAY_SIZE(buff));
- do {
- if (*cur == delim || cur - buf == len) {
- end = cur;
- memcpy(buff, start, end - start);
- *(buff + strnlen(buff, ARRAY_SIZE(buff))) =
- '\0';
- if (kstrtoint
- (buff, 10,
- info->cmd_param + param_cnt) < 0)
- goto err_out;
- start = cur + 1;
- memset(buff, 0x00, ARRAY_SIZE(buff));
- param_cnt++;
- }
- cur++;
- } while ((cur - buf <= len) && (param_cnt < CMD_PARAM_NUM));
- }
- tsp_debug_info(true, &info->client->dev, "cmd = %s\n", ft_cmd_ptr->cmd_name);
- for (i = 0; i < param_cnt; i++)
- tsp_debug_info(true, &info->client->dev, "cmd param %d= %d\n", i,
- info->cmd_param[i]);
- ft_cmd_ptr->cmd_func(info);
- err_out:
- return count;
- }
- static ssize_t show_cmd_status(struct device *dev,
- struct device_attribute *devattr, char *buf)
- {
- struct fts_ts_info *info = dev_get_drvdata(dev);
- char buff[16] = { 0 };
- if (!info) {
- printk(KERN_ERR "%s: No platform data found\n",
- __func__);
- return -EINVAL;
- }
- if (!info->input_dev) {
- printk(KERN_ERR "%s: No input_dev data found\n",
- __func__);
- return -EINVAL;
- }
- tsp_debug_info(true, &info->client->dev, "tsp cmd: status:%d\n", info->cmd_state);
- if (info->cmd_state == CMD_STATUS_WAITING)
- snprintf(buff, sizeof(buff), "WAITING");
- else if (info->cmd_state == CMD_STATUS_RUNNING)
- snprintf(buff, sizeof(buff), "RUNNING");
- else if (info->cmd_state == CMD_STATUS_OK)
- snprintf(buff, sizeof(buff), "OK");
- else if (info->cmd_state == CMD_STATUS_FAIL)
- snprintf(buff, sizeof(buff), "FAIL");
- else if (info->cmd_state == CMD_STATUS_NOT_APPLICABLE)
- snprintf(buff, sizeof(buff), "NOT_APPLICABLE");
- return snprintf(buf, TSP_BUF_SIZE, "%s\n", buff);
- }
- static ssize_t show_cmd_result(struct device *dev,
- struct device_attribute *devattr, char *buf)
- {
- struct fts_ts_info *info = dev_get_drvdata(dev);
- if (!info) {
- printk(KERN_ERR "%s: No platform data found\n",
- __func__);
- return -EINVAL;
- }
- if (!info->input_dev) {
- printk(KERN_ERR "%s: No input_dev data found\n",
- __func__);
- return -EINVAL;
- }
- tsp_debug_info(true, &info->client->dev, "tsp cmd: result: %s\n",
- info->cmd_result);
- mutex_lock(&info->cmd_lock);
- info->cmd_is_running = false;
- mutex_unlock(&info->cmd_lock);
- info->cmd_state = 0;
- return snprintf(buf, TSP_BUF_SIZE, "%s\n", info->cmd_result);
- }
- static ssize_t cmd_list_show(struct device *dev,
- struct device_attribute *attr, char *buf)
- {
- struct fts_ts_info *info = dev_get_drvdata(dev);
- int ii = 0;
- char buffer[info->cmd_buffer_size + 30];
- char buffer_name[CMD_STR_LEN];
- snprintf(buffer, 30, "++factory command list++\n");
- while (strncmp(ft_cmds[ii].cmd_name, "not_support_cmd", 16) != 0) {
- snprintf(buffer_name, CMD_STR_LEN, "%s\n", ft_cmds[ii].cmd_name);
- strncat(buffer, buffer_name, (int)strlen(buffer_name));
- ii++;
- }
- dev_info(&info->client->dev,
- "%s: length : %u / %d\n", __func__,
- strlen(buffer), info->cmd_buffer_size);
- return snprintf(buf, TSP_BUF_SIZE, "%s\n", buffer);
- }
- static void set_default_result(struct fts_ts_info *info)
- {
- char delim = ':';
- memset(info->cmd_result, 0x00, info->cmd_buffer_size);
- memcpy(info->cmd_result, info->cmd, strnlen(info->cmd, CMD_STR_LEN));
- strncat(info->cmd_result, &delim, 1);
- }
- static void set_cmd_result(struct fts_ts_info *info, char *buff, int len)
- {
- strncat(info->cmd_result, buff, len);
- }
- static void not_support_cmd(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[16] = { 0 };
- set_default_result(info);
- snprintf(buff, sizeof(buff), "%s", "NA");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = 4;
- tsp_debug_info(true, &info->client->dev, "%s: \"%s(%d)\"\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void fw_update(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- //struct i2c_client *client = info->client;
- char buff[64] = { 0 };
- int retval = 0;
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- retval = fts_fw_update_on_hidden_menu(info, info->cmd_param[0]);
- if (retval < 0) {
- sprintf(buff, "%s", "NA");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_FAIL;
- tsp_debug_info(true, &info->client->dev, "%s: failed [%d]\n", __func__, retval);
- } else {
- sprintf(buff, "%s", "OK");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: success [%d]\n", __func__, retval);
- }
- return;
- }
- static int getChannelInfo(struct fts_ts_info *info)
- {
- int rc;
- unsigned char cmd[4] =
- { 0xB2, 0x00, 0x14, 0x02 };
- unsigned char data[FTS_EVENT_SIZE];
- int retry = 0;
- memset(data, 0x0, FTS_EVENT_SIZE);
- rc = -1;
- fts_write_reg(info, &cmd[0], 4);
- cmd[0]=READ_ONE_EVENT;
- while (fts_read_reg
- (info, &cmd[0], 1, (unsigned char *)data, FTS_EVENT_SIZE)) {
- if (data[0] == EVENTID_RESULT_READ_REGISTER) {
- if ((data[1]==cmd[1]) && (data[2]==cmd[2]))
- {
- info->SenseChannelLength =data[3];
- info->ForceChannelLength =data[4];
- rc = 0;
- break;
- }
- }
- if (retry++ > 30) {
- rc = -1;
- tsp_debug_info(true, &info->client->dev, "Time over - wait for channel info\n");
- break;
- }
- mdelay(5);
- }
- return rc;
- }
- static void procedure_cmd_event(struct fts_ts_info *info, unsigned char *data)
- {
- char buff[16] = { 0 };
- if ((data[1] == 0x00) && (data[2] == 0x62))
- {
- snprintf(buff, sizeof(buff), "%d",
- *(unsigned short *)&data[3]);
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", "get_threshold", buff,
- strnlen(buff, sizeof(buff)));
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- }
- else if ((data[1] == 0x01) && (data[2] == 0xC6))
- {
- snprintf(buff, sizeof(buff), "%d",
- *(unsigned short *)&data[3]);
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", "get_glove_sensitivity", buff,
- strnlen(buff, sizeof(buff)));
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- }
- else if ((data[1] == 0x07) && (data[2] == 0xE7))
- {
- if (data[3] <= TSP_FACTEST_RESULT_PASS) {
- sprintf(buff, "%s",
- data[3] == TSP_FACTEST_RESULT_PASS ? "PASS" :
- data[3] == TSP_FACTEST_RESULT_FAIL ? "FAIL" : "NONE");
- tsp_debug_info(true, &info->client->dev, "%s: success [%s][%d]", "get_tsp_test_result",
- data[3] == TSP_FACTEST_RESULT_PASS ? "PASS" :
- data[3] == TSP_FACTEST_RESULT_FAIL ? "FAIL" :
- "NONE", data[3]);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- }
- else
- {
- snprintf(buff, sizeof(buff), "%s", "NG");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_FAIL;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n",
- "get_tsp_test_result",
- buff,
- strnlen(buff, sizeof(buff)));
- }
- }
- #ifdef FTS_SUPPORT_TOUCH_KEY
- if ((data[1] == 0x01) && (data[2] == 0xEF))
- {
- info->touchkey_threshold = *(unsigned short *)&data[3];
- }
- #endif
- }
- void fts_print_frame(struct fts_ts_info *info, short *min, short *max)
- {
- int i = 0;
- int j = 0;
- unsigned char *pStr = NULL;
- unsigned char pTmp[16] = { 0 };
- pStr = kzalloc(6 * (info->SenseChannelLength + 1), GFP_KERNEL);
- if (pStr == NULL) {
- tsp_debug_info(true, &info->client->dev, "FTS pStr kzalloc failed\n");
- return;
- }
- memset(pStr, 0x0, 6 * (info->SenseChannelLength + 1));
- snprintf(pTmp, sizeof(pTmp), " ");
- strncat(pStr, pTmp, 6 * info->SenseChannelLength);
- for (i = 0; i < info->SenseChannelLength; i++) {
- snprintf(pTmp, sizeof(pTmp), "Rx%02d ", i);
- strncat(pStr, pTmp, 6 * info->SenseChannelLength);
- }
- tsp_debug_info(true, &info->client->dev, "FTS %s\n", pStr);
- memset(pStr, 0x0, 6 * (info->SenseChannelLength + 1));
- snprintf(pTmp, sizeof(pTmp), " +");
- strncat(pStr, pTmp, 6 * info->SenseChannelLength);
- for (i = 0; i < info->SenseChannelLength; i++) {
- snprintf(pTmp, sizeof(pTmp), "------");
- strncat(pStr, pTmp, 6 * info->SenseChannelLength);
- }
- tsp_debug_info(true, &info->client->dev, "FTS %s\n", pStr);
- for (i = 0; i < info->ForceChannelLength; i++) {
- memset(pStr, 0x0, 6 * (info->SenseChannelLength + 1));
- snprintf(pTmp, sizeof(pTmp), "Tx%02d | ", i);
- strncat(pStr, pTmp, 6 * info->SenseChannelLength);
- for (j = 0; j < info->SenseChannelLength; j++) {
- snprintf(pTmp, sizeof(pTmp), "%5d ", info->pFrame[(i * info->SenseChannelLength) + j]);
- if (i > 0) {
- if (info->pFrame[(i * info->SenseChannelLength) + j] < *min)
- *min = info->pFrame[(i * info->SenseChannelLength) + j];
- if (info->pFrame[(i * info->SenseChannelLength) + j] > *max)
- *max = info->pFrame[(i * info->SenseChannelLength) + j];
- }
- strncat(pStr, pTmp, 6 * info->SenseChannelLength);
- }
- tsp_debug_info(true, &info->client->dev, "FTS %s\n", pStr);
- }
- kfree(pStr);
- }
- int fts_read_frame(struct fts_ts_info *info, unsigned char type, short *min,
- short *max)
- {
- unsigned char pFrameAddress[8] =
- { 0xD0, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 };
- unsigned int FrameAddress = 0;
- unsigned int writeAddr = 0;
- unsigned int start_addr = 0;
- unsigned int end_addr = 0;
- unsigned int totalbytes = 0;
- unsigned int remained = 0;
- unsigned int readbytes = 0xFF;
- unsigned int dataposition = 0;
- unsigned char *pRead = NULL;
- int rc = 0;
- int ret = 0;
- int i = 0;
- pRead = kzalloc(BUFFER_MAX, GFP_KERNEL);
- if (pRead == NULL) {
- tsp_debug_info(true, &info->client->dev, "FTS pRead kzalloc failed\n");
- rc = 1;
- goto ErrorExit;
- }
- pFrameAddress[2] = type;
- totalbytes = info->SenseChannelLength * info->ForceChannelLength * 2;
- ret = fts_read_reg(info, &pFrameAddress[0], 3, pRead, pFrameAddress[3]);
- if (ret >= 0) {
- FrameAddress = pRead[0] + (pRead[1] << 8);
- start_addr = FrameAddress+info->SenseChannelLength*2;
- // end_addr = FrameAddress + totalbytes;
- end_addr = start_addr + totalbytes;
- } else {
- tsp_debug_info(true, &info->client->dev, "FTS read failed rc = %d \n", ret);
- rc = 2;
- goto ErrorExit;
- }
- #ifdef DEBUG_MSG
- tsp_debug_info(true, &info->client->dev, "FTS FrameAddress = %X \n", FrameAddress);
- tsp_debug_info(true, &info->client->dev, "FTS start_addr = %X, end_addr = %X \n", start_addr, end_addr);
- #endif
- remained = totalbytes;
- for (writeAddr = start_addr; writeAddr < end_addr;
- writeAddr += READ_CHUNK_SIZE) {
- pFrameAddress[1] = (writeAddr >> 8) & 0xFF;
- pFrameAddress[2] = writeAddr & 0xFF;
- if (remained >= READ_CHUNK_SIZE) {
- readbytes = READ_CHUNK_SIZE;
- } else {
- readbytes = remained;
- }
- memset(pRead, 0x0, readbytes);
- #ifdef DEBUG_MSG
- tsp_debug_info(true, &info->client->dev, "FTS %02X%02X%02X readbytes=%d\n",
- pFrameAddress[0], pFrameAddress[1],
- pFrameAddress[2], readbytes);
- #endif /* */
- fts_read_reg(info, &pFrameAddress[0], 3, pRead, readbytes);
- remained -= readbytes;
- for (i = 0; i < readbytes; i += 2) {
- //for(i = 0; i < totalbytes ; i += 2){
- info->pFrame[dataposition++] =
- pRead[i] + (pRead[i + 1] << 8);
- }
- }
- kfree(pRead);
- #ifdef DEBUG_MSG
- tsp_debug_info(true, &info->client->dev,
- "FTS writeAddr = %X, start_addr = %X, end_addr = %X \n",
- writeAddr, start_addr, end_addr);
- #endif
- switch (type) {
- case TYPE_RAW_DATA:
- tsp_debug_info(true, &info->client->dev, "FTS [Raw Data : 0x%X%X] \n", pFrameAddress[0],
- FrameAddress);
- break;
- case TYPE_FILTERED_DATA:
- tsp_debug_info(true, &info->client->dev, "FTS [Filtered Data : 0x%X%X] \n",
- pFrameAddress[0], FrameAddress);
- break;
- case TYPE_STRENGTH_DATA:
- tsp_debug_info(true, &info->client->dev, "FTS [Strength Data : 0x%X%X] \n",
- pFrameAddress[0], FrameAddress);
- break;
- case TYPE_BASELINE_DATA:
- tsp_debug_info(true, &info->client->dev, "FTS [Baseline Data : 0x%X%X] \n",
- pFrameAddress[0], FrameAddress);
- break;
- }
- fts_print_frame(info, min, max);
- ErrorExit:
- return rc;
- }
- static int fts_panel_ito_test(struct fts_ts_info *info)
- {
- unsigned char cmd = READ_ONE_EVENT;
- unsigned char data[FTS_EVENT_SIZE];
- unsigned char regAdd[4] = {0xB0, 0x03, 0x60, 0xFB};
- int retry = 0;
- int result = -1;
- fts_systemreset(info);
- fts_wait_for_ready(info);
- fts_command(info, SLEEPOUT);
- fts_delay(20);
- fts_interrupt_set(info, INT_DISABLE);
- fts_write_reg(info, ®Add[0], 4);
- fts_command(info, FLUSHBUFFER);
- fts_command(info, 0xA7);
- fts_delay(200);
- memset(data, 0x0, FTS_EVENT_SIZE);
- while (fts_read_reg
- (info, &cmd, 1, (unsigned char *)data, FTS_EVENT_SIZE)) {
- if ((data[0] == 0x0F) && (data[1] == 0x05)) {
- switch (data[2]) {
- case 0x00 :
- result = 0;
- break;
- case 0x01 :
- tsp_debug_info(true, &info->client->dev, "[FTS] ITO Test result : Force channel [%d] open.\n",
- data[3]);
- break;
- case 0x02 :
- tsp_debug_info(true, &info->client->dev, "[FTS] ITO Test result : Sense channel [%d] open.\n",
- data[3]);
- break;
- case 0x03 :
- tsp_debug_info(true, &info->client->dev, "[FTS] ITO Test result : Force channel [%d] short to GND.\n",
- data[3]);
- break;
- case 0x04 :
- tsp_debug_info(true, &info->client->dev, "[FTS] ITO Test result : Sense channel [%d] short to GND.\n",
- data[3]);
- break;
- case 0x07 :
- tsp_debug_info(true, &info->client->dev, "[FTS] ITO Test result : Force channel [%d] short to force.\n",
- data[3]);
- break;
- case 0x0E :
- tsp_debug_info(true, &info->client->dev, "[FTS] ITO Test result : Sennse channel [%d] short to sense.\n",
- data[3]);
- break;
- default:
- break;
- }
- break;
- }
- if (retry++ > 30) {
- tsp_debug_info(true, &info->client->dev, "Time over - wait for result of ITO test\n");
- break;
- }
- fts_delay(10);
- }
- fts_systemreset(info);
- // wait for ready event
- fts_wait_for_ready(info);
- #ifdef FTS_SUPPORT_NOISE_PARAM
- fts_set_noise_param(info);
- #endif // FTS_SUPPORT_NOISE_PARAM
- fts_command(info, SLEEPOUT);
- fts_command(info, SENSEON);
- #ifdef FTS_SUPPORT_TOUCH_KEY
- info->fts_command(info, FTS_CMD_KEY_SENSE_ON);
- #endif
- if (info->hover_enabled)
- fts_command(info, FTS_CMD_HOVER_ON);
- if (info->flip_enable) {
- fts_set_flipcover_mode(info, true);
- } else {
- if (info->mshover_enabled)
- fts_command(info, FTS_CMD_MSHOVER_ON);
- }
- #ifdef FTS_SUPPORT_TA_MODE
- if (info->TA_Pluged)
- fts_command(info, FTS_CMD_CHARGER_PLUGGED);
- #endif
- info->touch_count = 0;
- fts_command(info, FLUSHBUFFER);
- fts_interrupt_set(info, INT_ENABLE);
- return result;
- }
- static void get_fw_ver_bin(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[16] = { 0 };
- set_default_result(info);
- info->panel_revision = 0x00;
- sprintf(buff, "ST%02X%04X",
- info->panel_revision,
- info->fw_main_version_of_bin);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void get_fw_ver_ic(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[16] = { 0 };
- set_default_result(info);
- info->panel_revision = 0x00;
- sprintf(buff, "ST%02X%04X",
- info->panel_revision,
- info->fw_main_version_of_ic);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void get_config_ver(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[20] = { 0 };
- snprintf(buff, sizeof(buff), "%s_ST_%04X",
- info->board->project_name ?: STM_DEVICE_NAME,
- info->config_version_of_ic);
- set_default_result(info);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void get_threshold(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- unsigned char cmd[4] =
- { 0xB2, 0x00, 0x62, 0x02 };
- int timeout=0;
- set_default_result(info);
- if (info->touch_stopped) {
- char buff[CMD_STR_LEN] = { 0 };
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- fts_write_reg(info, &cmd[0], 4);
- info->cmd_state = CMD_STATUS_RUNNING;
- while (info->cmd_state == CMD_STATUS_RUNNING) {
- if (timeout++>30) {
- info->cmd_state = CMD_STATUS_FAIL;
- break;
- }
- msleep(10);
- }
- }
- static void module_off_master(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[3] = { 0 };
- int ret = 0;
- mutex_lock(&info->lock);
- if (info->enabled) {
- disable_irq(info->irq);
- info->enabled = false;
- }
- mutex_unlock(&info->lock);
- if (info->board->power)
- info->board->power(0);
- else
- ret = 1;
- if (ret == 0)
- snprintf(buff, sizeof(buff), "%s", "OK");
- else
- snprintf(buff, sizeof(buff), "%s", "NG");
- set_default_result(info);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- if (strncmp(buff, "OK", 2) == 0)
- info->cmd_state = CMD_STATUS_OK;
- else
- info->cmd_state = CMD_STATUS_FAIL;
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void module_on_master(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[3] = { 0 };
- int ret = 0;
- mutex_lock(&info->lock);
- if (!info->enabled) {
- enable_irq(info->irq);
- info->enabled = true;
- }
- mutex_unlock(&info->lock);
- if (info->board->power)
- info->board->power(1);
- else
- ret = 1;
- if (ret == 0)
- snprintf(buff, sizeof(buff), "%s", "OK");
- else
- snprintf(buff, sizeof(buff), "%s", "NG");
- set_default_result(info);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- if (strncmp(buff, "OK", 2) == 0)
- info->cmd_state = CMD_STATUS_OK;
- else
- info->cmd_state = CMD_STATUS_FAIL;
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void get_chip_vendor(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[16] = { 0 };
- strncpy(buff, "STM", sizeof(buff));
- set_default_result(info);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void get_chip_name(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[16] = { 0 };
- strncpy(buff, "FTS", sizeof(buff));
- set_default_result(info);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void get_x_num(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[16] = { 0 };
- set_default_result(info);
- snprintf(buff, sizeof(buff), "%d", info->SenseChannelLength);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = 2;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void get_y_num(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[16] = { 0 };
- set_default_result(info);
- snprintf(buff, sizeof(buff), "%d", info->ForceChannelLength);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void run_reference_read(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- short min = 0x7FFF;
- short max = 0x8000;
- set_default_result(info);
- if (info->touch_stopped) {
- char buff[CMD_STR_LEN] = { 0 };
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- fts_read_frame(info, TYPE_BASELINE_DATA, &min, &max);
- snprintf(buff, sizeof(buff), "%d,%d", min, max);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void get_reference(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- short min = 0x7FFF;
- short max = 0x8000;
- short val = 0;
- int node = 0;
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- node = fts_check_index(info);
- if (node < 0)
- return;
- fts_read_frame(info, TYPE_BASELINE_DATA, &min, &max);
- val = info->pFrame[node];
- snprintf(buff, sizeof(buff), "%d", val);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void run_rawcap_read(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- short min = 0x7FFF;
- short max = 0x8000;
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- fts_delay(500);
- fts_read_frame(info, TYPE_FILTERED_DATA, &min, &max);
- snprintf(buff, sizeof(buff), "%d,%d", min, max);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void get_rawcap(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- short min = 0x7FFF;
- short max = 0x8000;
- short val = 0;
- int node = 0;
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- node = fts_check_index(info);
- if (node < 0)
- return;
- fts_read_frame(info, TYPE_FILTERED_DATA, &min, &max);
- val = info->pFrame[node];
- snprintf(buff, sizeof(buff), "%d", val);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- static void run_delta_read(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- short min = 0x7FFF;
- short max = 0x8000;
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- fts_read_frame(info, TYPE_STRENGTH_DATA, &min, &max);
- snprintf(buff, sizeof(buff), "%d,%d", min, max);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void get_delta(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- short min = 0x7FFF;
- short max = 0x8000;
- short val = 0;
- int node = 0;
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- node = fts_check_index(info);
- if (node < 0)
- return;
- fts_read_frame(info, TYPE_STRENGTH_DATA, &min, &max);
- val = info->pFrame[node];
- snprintf(buff, sizeof(buff), "%d", val);
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- tsp_debug_info(true, &info->client->dev, "%s: %s(%d)\n", __func__, buff,
- strnlen(buff, sizeof(buff)));
- }
- void fts_read_self_frame(struct fts_ts_info *info, unsigned short oAddr)
- {
- char buff[64] = { 0 };
- short *data;
- char temp[9] = { 0 };
- char temp2[512] = { 0 };
- int i;
- int rc;
- int retry=1;
- unsigned char regAdd[6] = {0xD0, 0x00, 0x00, 0xD0, 0x00, 0x00};
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- if (!info->hover_enabled) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Hover is disabled\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP Hover disabled");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- while (!info->hover_ready) {
- if (retry++ > 500) { // max 5sec
- tsp_debug_info(true, &info->client->dev, "%s: [FTS] Timeout - Abs Raw Data Ready Event\n",
- __func__);
- break;
- }
- fts_delay(10);
- }
- regAdd[1] = (oAddr >> 8) & 0xff;
- regAdd[2] = oAddr & 0xff;
- rc = info->fts_read_reg(info, ®Add[0], 3, (unsigned char *)&buff[0], 4);
- if (!rc) {
- info->cmd_state = CMD_STATUS_FAIL;
- return;
- }
- tsp_debug_info(true, &info->client->dev, "%s: Force Address : %02x%02x\n",
- __func__, buff[1], buff[0]);
- tsp_debug_info(true, &info->client->dev, "%s: Sense Address : %02x%02x\n",
- __func__, buff[3], buff[2]);
- regAdd[1] = buff[3];
- regAdd[2] = buff[2];
- regAdd[4] = buff[1];
- regAdd[5] = buff[0];
- rc = info->fts_read_reg(info, ®Add[0], 3,
- (unsigned char *)&buff[0],
- info->SenseChannelLength*2);
- if (!rc) {
- info->cmd_state = CMD_STATUS_FAIL;
- return;
- }
- data = (short *)&buff[0];
- for (i = 0; i < info->SenseChannelLength; i++) {
- tsp_debug_info(true, &info->client->dev,
- "%s: Rx [%d] = %d\n", __func__,
- i,
- *data);
- sprintf(temp, "%d,", *data);
- strncat(temp2, temp, 9);
- data++;
- }
- rc = info->fts_read_reg(info, ®Add[3], 3,
- (unsigned char *)&buff[0],
- info->ForceChannelLength*2);
- if (!rc) {
- info->cmd_state = CMD_STATUS_FAIL;
- return;
- }
- data = (short *)&buff[0];
- for (i = 0; i < info->ForceChannelLength; i++) {
- tsp_debug_info(true, &info->client->dev,
- "%s: Tx [%d] = %d\n", __func__, i, *data);
- sprintf(temp, "%d,", *data);
- strncat(temp2, temp, 9);
- data++;
- }
- set_cmd_result(info, temp2, strnlen(temp2, sizeof(temp2)));
- info->cmd_state = CMD_STATUS_OK;
- }
- static void run_abscap_read(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- set_default_result(info);
- fts_read_self_frame(info, 0x000E);
- }
- static void run_absdelta_read(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- set_default_result(info);
- fts_read_self_frame(info, 0x0012);
- }
- static void run_trx_short_test(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- int ret = 0;
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- disable_irq(info->irq);
- ret = fts_panel_ito_test(info);
- if (ret == 0)
- snprintf(buff, sizeof(buff), "%s", "OK");
- else
- snprintf(buff, sizeof(buff), "%s", "FAIL");
- enable_irq(info->irq);
- info->cmd_state = CMD_STATUS_OK;
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void set_tsp_test_result(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- unsigned char regAdd[4] = {0xB0, 0x07, 0xE7, 0x00};
- set_default_result(info);
- if (info->cmd_param[0] < TSP_FACTEST_RESULT_NONE
- || info->cmd_param[0] > TSP_FACTEST_RESULT_PASS) {
- snprintf(buff, sizeof(buff), "%s", "NG");
- info->cmd_state = CMD_STATUS_FAIL;
- return;
- }
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- regAdd[3] = info->cmd_param[0];
- fts_write_reg(info, ®Add[0], 4);
- fts_delay(100);
- fts_command(info, FTS_CMD_SAVE_FWCONFIG);
- snprintf(buff, sizeof(buff), "%s", "OK");
- info->cmd_state = CMD_STATUS_OK;
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void get_tsp_test_result(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- unsigned char cmd[4] = {0xB2, 0x07, 0xE7, 0x01};
- int timeout = 0;
- set_default_result(info);
- if (info->touch_stopped) {
- char buff[CMD_STR_LEN] = { 0 };
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- fts_command(info, FLUSHBUFFER);
- fts_write_reg(info, &cmd[0], 4);
- info->cmd_state = CMD_STATUS_RUNNING;
- while (info->cmd_state == CMD_STATUS_RUNNING) {
- if (timeout++>30) {
- info->cmd_state = CMD_STATUS_FAIL;
- break;
- }
- fts_delay(10);
- }
- }
- static void hover_enable(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- set_default_result(info);
- if (info->touch_stopped || !(info->reinit_done)) {
- tsp_debug_info(true, &info->client->dev,
- "%s: [ERROR] Touch is stopped : %d, reinit_done : %d\n",
- __func__, info->touch_stopped, info->reinit_done);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- if(info->cmd_param[0]==1){
- retry_hover_enable_after_wakeup = 1;
- tsp_debug_info(true, &info->client->dev, "%s: retry_hover_on_after_wakeup \n", __func__);
- }
- goto out;
- }
- if (info->cmd_param[0] < 0 || info->cmd_param[0] > 1) {
- snprintf(buff, sizeof(buff), "%s", "NG");
- info->cmd_state = CMD_STATUS_FAIL;
- } else {
- int enables;
- enables = info->cmd_param[0];
- if (enables) {
- unsigned char regAdd[4] = {0xB0, 0x01, 0x29, 0x41};
- fts_write_reg(info, ®Add[0], 4);
- fts_command(info, FTS_CMD_HOVER_ON);
- info->hover_ready = false;
- info->hover_enabled = true;
- } else {
- fts_command(info, FTS_CMD_HOVER_OFF);
- info->hover_enabled = false;
- info->hover_ready = false;
- }
- snprintf(buff, sizeof(buff), "%s", "OK");
- info->cmd_state = CMD_STATUS_OK;
- }
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_WAITING;
- out:
- mutex_lock(&info->cmd_lock);
- info->cmd_is_running = false;
- mutex_unlock(&info->cmd_lock);
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void hover_no_sleep_enable(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- unsigned char regAdd[4] = {0xB0, 0x01, 0x18, 0x00};
- char buff[CMD_STR_LEN] = { 0 };
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev,
- "%s: [ERROR] Touch is stopped : %d\n",
- __func__, info->touch_stopped);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- if (info->cmd_param[0] < 0 || info->cmd_param[0] > 1) {
- snprintf(buff, sizeof(buff), "%s", "NG");
- info->cmd_state = CMD_STATUS_FAIL;
- } else {
- if (info->cmd_param[0]) {
- regAdd[3]=0x0F;
- } else {
- regAdd[3]=0x08;
- }
- fts_write_reg(info, ®Add[0], 4);
- snprintf(buff, sizeof(buff), "%s", "OK");
- info->cmd_state = CMD_STATUS_OK;
- }
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void glove_mode(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- set_default_result(info);
- if (info->cmd_param[0] < 0 || info->cmd_param[0] > 1) {
- snprintf(buff, sizeof(buff), "%s", "NG");
- info->cmd_state = CMD_STATUS_FAIL;
- } else {
- info->mshover_enabled = info->cmd_param[0];
- if (!info->touch_stopped && info->reinit_done) {
- if (info->mshover_enabled)
- fts_command(info, FTS_CMD_MSHOVER_ON);
- else
- fts_command(info, FTS_CMD_MSHOVER_OFF);
- }
- snprintf(buff, sizeof(buff), "%s", "OK");
- info->cmd_state = CMD_STATUS_OK;
- }
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_WAITING;
- mutex_lock(&info->cmd_lock);
- info->cmd_is_running = false;
- mutex_unlock(&info->cmd_lock);
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- static void get_glove_sensitivity(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- unsigned char cmd[4] =
- { 0xB2, 0x01, 0xC6, 0x02 };
- int timeout=0;
- set_default_result(info);
- if (info->touch_stopped) {
- char buff[CMD_STR_LEN] = { 0 };
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- return;
- }
- fts_write_reg(info, &cmd[0], 4);
- info->cmd_state = CMD_STATUS_RUNNING;
- while (info->cmd_state == CMD_STATUS_RUNNING) {
- if (timeout++>30) {
- info->cmd_state = CMD_STATUS_FAIL;
- break;
- }
- msleep(10);
- }
- }
- static void clear_cover_mode(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- set_default_result(info);
- if (info->cmd_param[0] < 0 || info->cmd_param[0] > 3) {
- snprintf(buff, sizeof(buff), "%s", "NG");
- info->cmd_state = CMD_STATUS_FAIL;
- } else {
- if (info->cmd_param[0] > 1)
- info->flip_enable = true;
- else
- info->flip_enable = false;
- if (!info->touch_stopped && info->reinit_done) {
- if (info->flip_enable) {
- if (info->mshover_enabled)
- fts_command(info, FTS_CMD_MSHOVER_OFF);
- fts_set_flipcover_mode(info, true);
- } else {
- fts_set_flipcover_mode(info, false);
- if (info->fast_mshover_enabled)
- fts_command(info, FTS_CMD_SET_FAST_GLOVE_MODE);
- else if (info->mshover_enabled)
- fts_command(info, FTS_CMD_MSHOVER_ON);
- }
- }
- snprintf(buff, sizeof(buff), "%s", "OK");
- info->cmd_state = CMD_STATUS_OK;
- }
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_WAITING;
- mutex_lock(&info->cmd_lock);
- info->cmd_is_running = false;
- mutex_unlock(&info->cmd_lock);
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- };
- static void fast_glove_mode(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- set_default_result(info);
- if (info->cmd_param[0] < 0 || info->cmd_param[0] > 1) {
- snprintf(buff, sizeof(buff), "%s", "NG");
- info->cmd_state = CMD_STATUS_FAIL;
- } else {
- info->fast_mshover_enabled = info->cmd_param[0];
- if (!info->touch_stopped && info->reinit_done) {
- if (info->fast_mshover_enabled)
- fts_command(info, FTS_CMD_SET_FAST_GLOVE_MODE);
- else
- fts_command(info, FTS_CMD_SET_NOR_GLOVE_MODE);
- }
- snprintf(buff, sizeof(buff), "%s", "OK");
- info->cmd_state = CMD_STATUS_OK;
- }
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_WAITING;
- mutex_lock(&info->cmd_lock);
- info->cmd_is_running = false;
- mutex_unlock(&info->cmd_lock);
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- };
- static void report_rate(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- goto out;
- }
- if (info->panel_revision == 0) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Not supported panel\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "OK");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_OK;
- goto out;
- }
- if (info->cmd_param[0] < 0 || info->cmd_param[0] > 1) {
- snprintf(buff, sizeof(buff), "%s", "NG");
- info->cmd_state = CMD_STATUS_FAIL;
- } else {
- int enables;
- enables = info->cmd_param[0];
- if (enables) { // 60 Hz
- if (!info->slow_report_rate) {
- #if defined(CONFIG_SEC_S_PROJECT)
- fts_command(info, FTS_CMD_SLOW_SCAN);
- #else
- fts_command(info, SENSEOFF);
- fts_command(info, SENSEON_SLOW);
- #endif
- #ifdef FTS_SUPPORT_TOUCH_KEY
- info->fts_command(info, FTS_CMD_KEY_SENSE_ON);
- #endif // FTS_SUPPORT_TOUCH_KEY
- info->slow_report_rate = true;
- }
- } else { // 90Hz
- if (info->slow_report_rate) {
- #if defined(CONFIG_SEC_S_PROJECT)
- fts_command(info, FTS_CMD_FAST_SCAN);
- #else
- fts_command(info, SENSEOFF);
- fts_command(info, SENSEON);
- #endif
- #ifdef FTS_SUPPORT_TOUCH_KEY
- info->fts_command(info, FTS_CMD_KEY_SENSE_ON);
- #endif // FTS_SUPPORT_TOUCH_KEY
- info->slow_report_rate = false;
- }
- }
- snprintf(buff, sizeof(buff), "%s", "OK");
- info->cmd_state = CMD_STATUS_OK;
- }
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_WAITING;
- out:
- mutex_lock(&info->cmd_lock);
- info->cmd_is_running = false;
- mutex_unlock(&info->cmd_lock);
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- #if !defined(CONFIG_SAMSUNG_PRODUCT_SHIP)
- static void interrupt_control(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- char buff[CMD_STR_LEN] = { 0 };
- set_default_result(info);
- if (info->touch_stopped) {
- tsp_debug_info(true, &info->client->dev, "%s: [ERROR] Touch is stopped\n",
- __func__);
- snprintf(buff, sizeof(buff), "%s", "TSP turned off");
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_NOT_APPLICABLE;
- goto out;
- }
- if (info->cmd_param[0] < 0 || info->cmd_param[0] > 1) {
- snprintf(buff, sizeof(buff), "%s", "NG");
- info->cmd_state = CMD_STATUS_FAIL;
- } else {
- int enables;
- enables = info->cmd_param[0];
- if (enables)
- fts_irq_enable(info, true);
- else
- fts_irq_enable(info, false);
- snprintf(buff, sizeof(buff), "%s", "OK");
- info->cmd_state = CMD_STATUS_OK;
- }
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_WAITING;
- out:
- mutex_lock(&info->cmd_lock);
- info->cmd_is_running = false;
- mutex_unlock(&info->cmd_lock);
- tsp_debug_info(true, &info->client->dev, "%s: %s\n", __func__, buff);
- }
- #endif
- #ifdef TOUCH_BOOSTER_DVFS
- static void boost_level(void *device_data)
- {
- struct fts_ts_info *info = (struct fts_ts_info *)device_data;
- struct i2c_client *client = info->client;
- char buff[CMD_STR_LEN] = { 0 };
- int retval = 0;
- set_default_result(info);
- #ifdef CONFIG_SEC_S_PROJECT
- /* Level 5 is replaced to Level 3 */
- if(info->cmd_param[0] == DVFS_STAGE_PENTA){
- info->cmd_param[0] = DVFS_STAGE_TRIPLE;
- }
- #endif
- info->dvfs_boost_mode = info->cmd_param[0];
- dev_info(&client->dev,
- "%s: dvfs_boost_mode = %d\n",
- __func__, info->dvfs_boost_mode);
- snprintf(buff, sizeof(buff), "OK");
- info->cmd_state = CMD_STATUS_OK;
- if (info->dvfs_boost_mode == DVFS_STAGE_NONE) {
- retval = set_freq_limit(DVFS_TOUCH_ID, -1);
- if (retval < 0) {
- dev_err(&info->client->dev,
- "%s: booster stop failed(%d).\n",
- __func__, retval);
- snprintf(buff, sizeof(buff), "NG");
- info->cmd_state = CMD_STATUS_FAIL;
- info->dvfs_lock_status = false;
- }
- }
- set_cmd_result(info, buff, strnlen(buff, sizeof(buff)));
- info->cmd_state = CMD_STATUS_WAITING;
- mutex_lock(&info->cmd_lock);
- info->cmd_is_running = false;
- mutex_unlock(&info->cmd_lock);
- return;
- }
- #endif
- #endif
|