tracychui | 3515162 | 2020-04-29 16:24:36 +0800 | [diff] [blame^] | 1 | /* Himax Android Driver Sample Code for debug nodes |
| 2 | * |
| 3 | * Copyright (C) 2017 Himax Corporation. |
| 4 | * |
| 5 | * This software is licensed under the terms of the GNU General Public |
| 6 | * License version 2, as published by the Free Software Foundation, and |
| 7 | * may be copied, distributed, and modified under those terms. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | */ |
| 15 | |
| 16 | #include "himax_debug.h" |
| 17 | #include "himax_ic.h" |
| 18 | |
| 19 | //struct himax_debug_data* debug_data; |
| 20 | |
| 21 | extern struct himax_ic_data* ic_data; |
| 22 | extern struct himax_ts_data *private_ts; |
| 23 | extern unsigned char IC_TYPE; |
| 24 | extern unsigned char IC_CHECKSUM; |
| 25 | extern int himax_input_register(struct himax_ts_data *ts); |
| 26 | #ifdef HX_CHIP_STATUS_MONITOR |
| 27 | extern struct chip_monitor_data *g_chip_monitor_data; |
| 28 | #endif |
| 29 | |
| 30 | #ifdef HX_RST_PIN_FUNC |
| 31 | extern void himax_ic_reset(uint8_t loadconfig,uint8_t int_off); |
| 32 | #endif |
| 33 | |
| 34 | #ifdef HX_TP_PROC_DIAG |
| 35 | #ifdef HX_TP_PROC_2T2R |
| 36 | extern bool Is_2T2R; |
| 37 | int HX_RX_NUM_2 = 0; |
| 38 | int HX_TX_NUM_2 = 0; |
| 39 | #endif |
| 40 | uint8_t g_diag_arr_num = 0; |
| 41 | #endif |
| 42 | |
| 43 | #ifdef HX_SMART_WAKEUP |
| 44 | bool FAKE_POWER_KEY_SEND; |
| 45 | #endif |
| 46 | |
| 47 | int g_max_mutual = 0; |
| 48 | int g_min_mutual = 255; |
| 49 | int g_max_self = 0; |
| 50 | int g_min_self = 255; |
| 51 | |
| 52 | #if defined(HX_TP_PROC_SELF_TEST) || defined(CONFIG_TOUCHSCREEN_HIMAX_ITO_TEST) |
| 53 | int g_self_test_entered = 0; |
| 54 | #endif |
| 55 | |
| 56 | struct timespec timeStart, timeEnd, timeDelta; |
| 57 | int g_switch_mode = 0; |
| 58 | extern void himax_idle_mode(struct i2c_client *client,int disable); |
| 59 | extern int himax_switch_mode(struct i2c_client *client,int mode); |
| 60 | extern void himax_return_event_stack(struct i2c_client *client); |
| 61 | |
| 62 | #ifdef HX_ZERO_FLASH |
| 63 | extern void himax_0f_operation(struct work_struct *work); |
| 64 | extern void himax_0f_operation_check(void); |
| 65 | extern void himax_sys_reset(void); |
| 66 | #endif |
| 67 | |
| 68 | //============================================================================================================= |
| 69 | // |
| 70 | // Segment : Himax PROC Debug Function |
| 71 | // |
| 72 | //============================================================================================================= |
| 73 | #if defined(CONFIG_TOUCHSCREEN_HIMAX_DEBUG) |
| 74 | |
| 75 | #if defined(CONFIG_TOUCHSCREEN_HIMAX_ITO_TEST) |
| 76 | |
| 77 | static ssize_t himax_ito_test_read(struct file *file, char *buf, |
| 78 | size_t len, loff_t *pos) |
| 79 | { |
| 80 | ssize_t ret = 0; |
| 81 | uint8_t result = 0; |
| 82 | uint8_t status = 0; |
| 83 | |
| 84 | if(!HX_PROC_SEND_FLAG) |
| 85 | { |
| 86 | status = ito_get_step_status(); |
| 87 | |
| 88 | switch(status) |
| 89 | { |
| 90 | case 0: |
| 91 | ret += sprintf(buf + ret, "Step : START_TEST\n"); |
| 92 | break; |
| 93 | case 1: |
| 94 | ret += sprintf(buf + ret, "Step : RAW_DATA\n"); |
| 95 | break; |
| 96 | case 2: |
| 97 | ret += sprintf(buf + ret, "Step : PERCENT_TEST\n"); |
| 98 | break; |
| 99 | case 3: |
| 100 | ret += sprintf(buf + ret, "Step : DEV_TEST\n"); |
| 101 | break; |
| 102 | case 4: |
| 103 | ret += sprintf(buf + ret, "Step : NOISE_TEST\n"); |
| 104 | break; |
| 105 | case 9: |
| 106 | ret += sprintf(buf + ret, "Step : END_TEST\n"); |
| 107 | break; |
| 108 | default: |
| 109 | ret += sprintf(buf + ret, "Step : Null\n"); |
| 110 | } |
| 111 | |
| 112 | result = ito_get_result_status(); |
| 113 | if(result == 0xF) |
| 114 | ret += sprintf(buf + ret, "ITO test is On-going! \n"); |
| 115 | else if(result == 0) |
| 116 | ret += sprintf(buf + ret, "ITO test is Pass! \n"); |
| 117 | else if(result == 2) |
| 118 | ret += sprintf(buf + ret, "Open config file fail! \n"); |
| 119 | else |
| 120 | ret += sprintf(buf + ret, "ITO test is Fail! \n"); |
| 121 | HX_PROC_SEND_FLAG=1; |
| 122 | } |
| 123 | else |
| 124 | HX_PROC_SEND_FLAG=0; |
| 125 | |
| 126 | return ret; |
| 127 | } |
| 128 | |
| 129 | static ssize_t himax_ito_test_write(struct file *file, const char *buff, |
| 130 | size_t len, loff_t *pos) |
| 131 | { |
| 132 | struct himax_ts_data *ts = private_ts; |
| 133 | uint8_t result = 0; |
| 134 | char buf[80] = {0}; |
| 135 | |
| 136 | if (len >= 80) |
| 137 | { |
| 138 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 139 | return -EFAULT; |
| 140 | } |
| 141 | if (copy_from_user(buf, buff, len)) |
| 142 | { |
| 143 | return -EFAULT; |
| 144 | } |
| 145 | |
| 146 | result = ito_get_result_status(); |
| 147 | I("%s: buf = %s, result = %d.\n", __func__, buf, result); |
| 148 | |
| 149 | if(buf[0] == '1' && result != 0xF) |
| 150 | { |
| 151 | I("%s: buf[0] = %c.\n", __func__, buf[0]); |
| 152 | ito_set_step_status(0); |
| 153 | queue_work(ts->ito_test_wq, &ts->ito_test_work); |
| 154 | } |
| 155 | |
| 156 | return len; |
| 157 | } |
| 158 | |
| 159 | static struct file_operations himax_proc_ito_test_ops = |
| 160 | { |
| 161 | .owner = THIS_MODULE, |
| 162 | .read = himax_ito_test_read, |
| 163 | .write = himax_ito_test_write, |
| 164 | }; |
| 165 | #endif |
| 166 | |
| 167 | static ssize_t himax_CRC_test_read(struct file *file, char *buf, |
| 168 | size_t len, loff_t *pos) |
| 169 | { |
| 170 | ssize_t ret = 0; |
| 171 | uint8_t result = 0; |
| 172 | char *temp_buf; |
| 173 | |
| 174 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 175 | |
| 176 | if(!HX_PROC_SEND_FLAG) |
| 177 | { |
| 178 | himax_sense_off(private_ts->client); |
| 179 | msleep(20); |
| 180 | result = himax_calculateChecksum(private_ts->client, false); |
| 181 | himax_sense_on(private_ts->client, 0x01); |
| 182 | if(result) |
| 183 | ret += sprintf(temp_buf + ret, "CRC test is Pass! \n"); |
| 184 | else |
| 185 | ret += sprintf(temp_buf + ret, "CRC test is Fail! \n"); |
| 186 | if(copy_to_user(buf, temp_buf, len)) |
| 187 | I("%s,here:%d\n",__func__,__LINE__); |
| 188 | kfree(temp_buf); |
| 189 | HX_PROC_SEND_FLAG=1; |
| 190 | } |
| 191 | else |
| 192 | HX_PROC_SEND_FLAG=0; |
| 193 | |
| 194 | return ret; |
| 195 | } |
| 196 | |
| 197 | static struct file_operations himax_proc_CRC_test_ops = |
| 198 | { |
| 199 | .owner = THIS_MODULE, |
| 200 | .read = himax_CRC_test_read, |
| 201 | }; |
| 202 | |
| 203 | static ssize_t himax_vendor_read(struct file *file, char *buf, |
| 204 | size_t len, loff_t *pos) |
| 205 | { |
| 206 | ssize_t count = 0; |
| 207 | char *temp_buf; |
| 208 | |
| 209 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 210 | |
| 211 | if(!HX_PROC_SEND_FLAG) |
| 212 | { |
| 213 | #if 1 |
| 214 | if((IC_TYPE >= 8)&&(ic_data->vendor_cid_maj_ver >= 0 || ic_data->vendor_cid_min_ver >= 0)) |
| 215 | { |
| 216 | if(IC_TYPE == HX_83112A_SERIES_PWON) |
| 217 | { |
| 218 | count += sprintf(temp_buf + count, "Truly Himax CID0%2.2X_D%2.2X_C%2.2X \n",(ic_data->vendor_cid_maj_ver << 8 | ic_data->vendor_cid_min_ver),ic_data->vendor_display_cfg_ver,ic_data->vendor_touch_cfg_ver); |
| 219 | } |
| 220 | else |
| 221 | { |
| 222 | count += sprintf(temp_buf + count, "DJN Himax CID0%2.2X_D%2.2X_C%2.2X \n",(ic_data->vendor_cid_maj_ver << 8 | ic_data->vendor_cid_min_ver),ic_data->vendor_display_cfg_ver,ic_data->vendor_touch_cfg_ver); |
| 223 | } |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | count += sprintf(temp_buf + count, "Himax null\n"); |
| 228 | } |
| 229 | #else |
| 230 | count += sprintf(temp_buf + count, "FW_VER = 0x%2.2X \n",ic_data->vendor_fw_ver); |
| 231 | |
| 232 | if(IC_TYPE < 8) |
| 233 | count += sprintf(temp_buf + count, "CONFIG_VER = 0x%2.2X \n",ic_data->vendor_config_ver); |
| 234 | else |
| 235 | { |
| 236 | count += sprintf(temp_buf + count, "TOUCH_VER = 0x%2.2X \n",ic_data->vendor_touch_cfg_ver); |
| 237 | count += sprintf(temp_buf + count, "DISPLAY_VER = 0x%2.2X \n",ic_data->vendor_display_cfg_ver); |
| 238 | } |
| 239 | if(ic_data->vendor_cid_maj_ver < 0 && ic_data->vendor_cid_min_ver < 0) |
| 240 | count += sprintf(temp_buf + count, "CID_VER = NULL\n"); |
| 241 | else |
| 242 | count += sprintf(temp_buf + count, "CID_VER = 0x%2.2X \n",(ic_data->vendor_cid_maj_ver << 8 | ic_data->vendor_cid_min_ver)); |
| 243 | |
| 244 | if(ic_data->vendor_panel_ver < 0) |
| 245 | count += sprintf(temp_buf + count, "PANEL_VER = NULL\n"); |
| 246 | else |
| 247 | count += sprintf(temp_buf + count, "PANEL_VER = 0x%2.2X \n",ic_data->vendor_panel_ver); |
| 248 | |
| 249 | count += sprintf(temp_buf + count, "\n"); |
| 250 | |
| 251 | count += sprintf(temp_buf + count, "Himax Touch Driver Version:\n"); |
| 252 | count += sprintf(temp_buf + count, "%s \n", HIMAX_DRIVER_VER); |
| 253 | #endif |
| 254 | HX_PROC_SEND_FLAG=1; |
| 255 | if(copy_to_user(buf, temp_buf, len)) |
| 256 | I("%s,here:%d\n",__func__,__LINE__); |
| 257 | kfree(temp_buf); |
| 258 | } |
| 259 | else |
| 260 | HX_PROC_SEND_FLAG=0; |
| 261 | |
| 262 | return count; |
| 263 | } |
| 264 | |
| 265 | static struct file_operations himax_proc_vendor_ops = |
| 266 | { |
| 267 | .owner = THIS_MODULE, |
| 268 | .read = himax_vendor_read, |
| 269 | }; |
| 270 | |
| 271 | static ssize_t himax_attn_read(struct file *file, char *buf, |
| 272 | size_t len, loff_t *pos) |
| 273 | { |
| 274 | ssize_t ret = 0; |
| 275 | struct himax_ts_data *ts_data; |
| 276 | char *temp_buf; |
| 277 | |
| 278 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 279 | ts_data = private_ts; |
| 280 | |
| 281 | if(!HX_PROC_SEND_FLAG) |
| 282 | { |
| 283 | ret += sprintf(temp_buf, "attn = %x\n", himax_int_gpio_read(ts_data->pdata->gpio_irq)); |
| 284 | if(copy_to_user(buf, temp_buf, len)) |
| 285 | I("%s,here:%d\n",__func__,__LINE__); |
| 286 | kfree(temp_buf); |
| 287 | HX_PROC_SEND_FLAG=1; |
| 288 | } |
| 289 | else |
| 290 | HX_PROC_SEND_FLAG=0; |
| 291 | |
| 292 | return ret; |
| 293 | } |
| 294 | |
| 295 | |
| 296 | static struct file_operations himax_proc_attn_ops = |
| 297 | { |
| 298 | .owner = THIS_MODULE, |
| 299 | .read = himax_attn_read, |
| 300 | }; |
| 301 | |
| 302 | static ssize_t himax_int_en_read(struct file *file, char *buf, |
| 303 | size_t len, loff_t *pos) |
| 304 | { |
| 305 | struct himax_ts_data *ts = private_ts; |
| 306 | size_t count = 0; |
| 307 | char *temp_buf; |
| 308 | |
| 309 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 310 | |
| 311 | if(!HX_PROC_SEND_FLAG) |
| 312 | { |
| 313 | count += sprintf(temp_buf + count, "%d ", ts->irq_enabled); |
| 314 | count += sprintf(temp_buf + count, "\n"); |
| 315 | if(copy_to_user(buf, temp_buf, len)) |
| 316 | I("%s,here:%d\n",__func__,__LINE__); |
| 317 | kfree(temp_buf); |
| 318 | HX_PROC_SEND_FLAG=1; |
| 319 | } |
| 320 | else |
| 321 | HX_PROC_SEND_FLAG=0; |
| 322 | return count; |
| 323 | } |
| 324 | |
| 325 | static ssize_t himax_int_en_write(struct file *file, const char *buff, |
| 326 | size_t len, loff_t *pos) |
| 327 | { |
| 328 | struct himax_ts_data *ts = private_ts; |
| 329 | char buf_tmp[12]= {0}; |
| 330 | int value, ret=0; |
| 331 | |
| 332 | if (len >= 12) |
| 333 | { |
| 334 | I("%s: no command exceeds 12 chars.\n", __func__); |
| 335 | return -EFAULT; |
| 336 | } |
| 337 | if (copy_from_user(buf_tmp, buff, len)) |
| 338 | { |
| 339 | return -EFAULT; |
| 340 | } |
| 341 | |
| 342 | if (buf_tmp[0] == '0') |
| 343 | value = false; |
| 344 | else if (buf_tmp[0] == '1') |
| 345 | value = true; |
| 346 | else |
| 347 | return -EINVAL; |
| 348 | |
| 349 | if (value) |
| 350 | { |
| 351 | ret = himax_int_en_set(ts->client); |
| 352 | if (ret == 0) |
| 353 | { |
| 354 | ts->irq_enabled = 1; |
| 355 | irq_enable_count = 1; |
| 356 | } |
| 357 | } |
| 358 | else |
| 359 | { |
| 360 | himax_int_enable(ts->client->irq,0); |
| 361 | free_irq(ts->client->irq, ts); |
| 362 | ts->irq_enabled = 0; |
| 363 | } |
| 364 | |
| 365 | return len; |
| 366 | } |
| 367 | |
| 368 | static struct file_operations himax_proc_int_en_ops = |
| 369 | { |
| 370 | .owner = THIS_MODULE, |
| 371 | .read = himax_int_en_read, |
| 372 | .write = himax_int_en_write, |
| 373 | }; |
| 374 | |
| 375 | static ssize_t himax_layout_read(struct file *file, char *buf, |
| 376 | size_t len, loff_t *pos) |
| 377 | { |
| 378 | struct himax_ts_data *ts = private_ts; |
| 379 | size_t count = 0; |
| 380 | char *temp_buf; |
| 381 | |
| 382 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 383 | |
| 384 | if(!HX_PROC_SEND_FLAG) |
| 385 | { |
| 386 | count += sprintf(temp_buf + count, "%d ", ts->pdata->abs_x_min); |
| 387 | count += sprintf(temp_buf + count, "%d ", ts->pdata->abs_x_max); |
| 388 | count += sprintf(temp_buf + count, "%d ", ts->pdata->abs_y_min); |
| 389 | count += sprintf(temp_buf + count, "%d ", ts->pdata->abs_y_max); |
| 390 | count += sprintf(temp_buf + count, "\n"); |
| 391 | if(copy_to_user(buf, temp_buf, len)) |
| 392 | I("%s,here:%d\n",__func__,__LINE__); |
| 393 | kfree(temp_buf); |
| 394 | HX_PROC_SEND_FLAG=1; |
| 395 | } |
| 396 | else |
| 397 | HX_PROC_SEND_FLAG=0; |
| 398 | |
| 399 | return count; |
| 400 | } |
| 401 | |
| 402 | static ssize_t himax_layout_write(struct file *file, const char *buff, |
| 403 | size_t len, loff_t *pos) |
| 404 | { |
| 405 | struct himax_ts_data *ts = private_ts; |
| 406 | char buf_tmp[5]; |
| 407 | int i = 0, j = 0, k = 0, ret; |
| 408 | unsigned long value; |
| 409 | int layout[4] = {0}; |
| 410 | char buf[80] = {0}; |
| 411 | |
| 412 | if (len >= 80) |
| 413 | { |
| 414 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 415 | return -EFAULT; |
| 416 | } |
| 417 | if (copy_from_user(buf, buff, len)) |
| 418 | { |
| 419 | return -EFAULT; |
| 420 | } |
| 421 | |
| 422 | for (i = 0; i < 20; i++) |
| 423 | { |
| 424 | if (buf[i] == ',' || buf[i] == '\n') |
| 425 | { |
| 426 | memset(buf_tmp, 0x0, sizeof(buf_tmp)); |
| 427 | if (i - j <= 5) |
| 428 | memcpy(buf_tmp, buf + j, i - j); |
| 429 | else |
| 430 | { |
| 431 | I("buffer size is over 5 char\n"); |
| 432 | return len; |
| 433 | } |
| 434 | j = i + 1; |
| 435 | if (k < 4) |
| 436 | { |
| 437 | ret = kstrtoul(buf_tmp, 10, &value); |
| 438 | layout[k++] = value; |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | if (k == 4) |
| 443 | { |
| 444 | ts->pdata->abs_x_min=layout[0]; |
| 445 | ts->pdata->abs_x_max=layout[1]; |
| 446 | ts->pdata->abs_y_min=layout[2]; |
| 447 | ts->pdata->abs_y_max=layout[3]; |
| 448 | I("%d, %d, %d, %d\n", |
| 449 | ts->pdata->abs_x_min, ts->pdata->abs_x_max, ts->pdata->abs_y_min, ts->pdata->abs_y_max); |
| 450 | input_unregister_device(ts->input_dev); |
| 451 | himax_input_register(ts); |
| 452 | } |
| 453 | else |
| 454 | I("ERR@%d, %d, %d, %d\n", |
| 455 | ts->pdata->abs_x_min, ts->pdata->abs_x_max, ts->pdata->abs_y_min, ts->pdata->abs_y_max); |
| 456 | return len; |
| 457 | } |
| 458 | |
| 459 | static struct file_operations himax_proc_layout_ops = |
| 460 | { |
| 461 | .owner = THIS_MODULE, |
| 462 | .read = himax_layout_read, |
| 463 | .write = himax_layout_write, |
| 464 | }; |
| 465 | |
| 466 | static ssize_t himax_debug_level_read(struct file *file, char *buf, |
| 467 | size_t len, loff_t *pos) |
| 468 | { |
| 469 | struct himax_ts_data *ts_data; |
| 470 | size_t count = 0; |
| 471 | char *temp_buf; |
| 472 | |
| 473 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 474 | ts_data = private_ts; |
| 475 | |
| 476 | if(!HX_PROC_SEND_FLAG) |
| 477 | { |
| 478 | count += sprintf(temp_buf, "%d\n", ts_data->debug_log_level); |
| 479 | if(copy_to_user(buf, temp_buf, len)) |
| 480 | I("%s,here:%d\n",__func__,__LINE__); |
| 481 | kfree(temp_buf); |
| 482 | HX_PROC_SEND_FLAG = 1; |
| 483 | } |
| 484 | else |
| 485 | HX_PROC_SEND_FLAG=0; |
| 486 | |
| 487 | return count; |
| 488 | } |
| 489 | |
| 490 | static ssize_t himax_debug_level_write(struct file *file, const char *buff, |
| 491 | size_t len, loff_t *pos) |
| 492 | { |
| 493 | struct himax_ts_data *ts; |
| 494 | char buf_tmp[11]; |
| 495 | int i; |
| 496 | ts = private_ts; |
| 497 | |
| 498 | if (len >= 12) |
| 499 | { |
| 500 | I("%s: no command exceeds 12 chars.\n", __func__); |
| 501 | return -EFAULT; |
| 502 | } |
| 503 | if (copy_from_user(buf_tmp, buff, len)) |
| 504 | { |
| 505 | return -EFAULT; |
| 506 | } |
| 507 | |
| 508 | ts->debug_log_level = 0; |
| 509 | for(i=0; i<len-1; i++) |
| 510 | { |
| 511 | if( buf_tmp[i]>='0' && buf_tmp[i]<='9' ) |
| 512 | ts->debug_log_level |= (buf_tmp[i]-'0'); |
| 513 | else if( buf_tmp[i]>='A' && buf_tmp[i]<='F' ) |
| 514 | ts->debug_log_level |= (buf_tmp[i]-'A'+10); |
| 515 | else if( buf_tmp[i]>='a' && buf_tmp[i]<='f' ) |
| 516 | ts->debug_log_level |= (buf_tmp[i]-'a'+10); |
| 517 | |
| 518 | if(i!=len-2) |
| 519 | ts->debug_log_level <<= 4; |
| 520 | } |
| 521 | |
| 522 | if (ts->debug_log_level & BIT(3)) |
| 523 | { |
| 524 | if (ts->pdata->screenWidth > 0 && ts->pdata->screenHeight > 0 && |
| 525 | (ts->pdata->abs_x_max - ts->pdata->abs_x_min) > 0 && |
| 526 | (ts->pdata->abs_y_max - ts->pdata->abs_y_min) > 0) |
| 527 | { |
| 528 | ts->widthFactor = (ts->pdata->screenWidth << SHIFTBITS)/(ts->pdata->abs_x_max - ts->pdata->abs_x_min); |
| 529 | ts->heightFactor = (ts->pdata->screenHeight << SHIFTBITS)/(ts->pdata->abs_y_max - ts->pdata->abs_y_min); |
| 530 | if (ts->widthFactor > 0 && ts->heightFactor > 0) |
| 531 | ts->useScreenRes = 1; |
| 532 | else |
| 533 | { |
| 534 | ts->heightFactor = 0; |
| 535 | ts->widthFactor = 0; |
| 536 | ts->useScreenRes = 0; |
| 537 | } |
| 538 | } |
| 539 | else |
| 540 | I("Enable finger debug with raw position mode!\n"); |
| 541 | } |
| 542 | else |
| 543 | { |
| 544 | ts->useScreenRes = 0; |
| 545 | ts->widthFactor = 0; |
| 546 | ts->heightFactor = 0; |
| 547 | } |
| 548 | |
| 549 | return len; |
| 550 | } |
| 551 | |
| 552 | static struct file_operations himax_proc_debug_level_ops = |
| 553 | { |
| 554 | .owner = THIS_MODULE, |
| 555 | .read = himax_debug_level_read, |
| 556 | .write = himax_debug_level_write, |
| 557 | }; |
| 558 | |
| 559 | #ifdef HX_TP_PROC_REGISTER |
| 560 | static ssize_t himax_proc_register_read(struct file *file, char *buf, |
| 561 | size_t len, loff_t *pos) |
| 562 | { |
| 563 | int ret = 0; |
| 564 | uint16_t loop_i; |
| 565 | uint8_t data[128]; |
| 566 | char *temp_buf; |
| 567 | |
| 568 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 569 | memset(data, 0x00, sizeof(data)); |
| 570 | |
| 571 | if(!HX_PROC_SEND_FLAG) |
| 572 | { |
| 573 | I("himax_register_show: %02X,%02X,%02X,%02X\n", register_command[3],register_command[2],register_command[1],register_command[0]); |
| 574 | himax_register_read(private_ts->client, register_command, 128, data, cfg_flag); |
| 575 | |
| 576 | ret += sprintf(temp_buf, "command: %02X,%02X,%02X,%02X\n", register_command[3],register_command[2],register_command[1],register_command[0]); |
| 577 | |
| 578 | for (loop_i = 0; loop_i < 128; loop_i++) |
| 579 | { |
| 580 | ret += sprintf(temp_buf + ret, "0x%2.2X ", data[loop_i]); |
| 581 | if ((loop_i % 16) == 15) |
| 582 | ret += sprintf(temp_buf + ret, "\n"); |
| 583 | } |
| 584 | ret += sprintf(temp_buf + ret, "\n"); |
| 585 | if(copy_to_user(buf, temp_buf, len)) |
| 586 | I("%s,here:%d\n",__func__,__LINE__); |
| 587 | kfree(temp_buf); |
| 588 | HX_PROC_SEND_FLAG=1; |
| 589 | } |
| 590 | else |
| 591 | HX_PROC_SEND_FLAG=0; |
| 592 | return ret; |
| 593 | } |
| 594 | |
| 595 | static ssize_t himax_proc_register_write(struct file *file, const char *buff, |
| 596 | size_t len, loff_t *pos) |
| 597 | { |
| 598 | char buf[80] = {0}; |
| 599 | char buf_tmp[16]; |
| 600 | uint8_t length = 0; |
| 601 | unsigned long result = 0; |
| 602 | uint8_t loop_i = 0; |
| 603 | uint16_t base = 2; |
| 604 | char *data_str = NULL; |
| 605 | uint8_t w_data[20]; |
| 606 | uint8_t x_pos[20]; |
| 607 | uint8_t count = 0; |
| 608 | |
| 609 | if (len >= 80) |
| 610 | { |
| 611 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 612 | return -EFAULT; |
| 613 | } |
| 614 | |
| 615 | if (copy_from_user(buf, buff, len)) |
| 616 | { |
| 617 | return -EFAULT; |
| 618 | } |
| 619 | |
| 620 | memset(buf_tmp, 0x0, sizeof(buf_tmp)); |
| 621 | memset(w_data, 0x0, sizeof(w_data)); |
| 622 | memset(x_pos, 0x0, sizeof(x_pos)); |
| 623 | |
| 624 | I("himax %s \n",buf); |
| 625 | |
| 626 | if ((buf[0] == 'r' || buf[0] == 'w') && buf[1] == ':' && buf[2] == 'x') |
| 627 | { |
| 628 | |
| 629 | length = strlen(buf); |
| 630 | |
| 631 | //I("%s: length = %d.\n", __func__,length); |
| 632 | for (loop_i = 0; loop_i < length; loop_i++) //find postion of 'x' |
| 633 | { |
| 634 | if(buf[loop_i] == 'x') |
| 635 | { |
| 636 | x_pos[count] = loop_i; |
| 637 | count++; |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | data_str = strrchr(buf, 'x'); |
| 642 | I("%s: %s.\n", __func__,data_str); |
| 643 | length = strlen(data_str+1) - 1; |
| 644 | |
| 645 | if (buf[0] == 'r') |
| 646 | { |
| 647 | if (buf[3] == 'F' && buf[4] == 'E' && length == 4) |
| 648 | { |
| 649 | length = length - base; |
| 650 | cfg_flag = true; |
| 651 | memcpy(buf_tmp, data_str + base +1, length); |
| 652 | } |
| 653 | else |
| 654 | { |
| 655 | cfg_flag = false; |
| 656 | memcpy(buf_tmp, data_str + 1, length); |
| 657 | } |
| 658 | |
| 659 | byte_length = length/2; |
| 660 | if (!kstrtoul(buf_tmp, 16, &result)) |
| 661 | { |
| 662 | for (loop_i = 0 ; loop_i < byte_length ; loop_i++) |
| 663 | { |
| 664 | register_command[loop_i] = (uint8_t)(result >> loop_i*8); |
| 665 | } |
| 666 | } |
| 667 | } |
| 668 | else if (buf[0] == 'w') |
| 669 | { |
| 670 | if (buf[3] == 'F' && buf[4] == 'E') |
| 671 | { |
| 672 | cfg_flag = true; |
| 673 | memcpy(buf_tmp, buf + base + 3, length); |
| 674 | } |
| 675 | else |
| 676 | { |
| 677 | cfg_flag = false; |
| 678 | memcpy(buf_tmp, buf + 3, length); |
| 679 | } |
| 680 | if(count < 3) |
| 681 | { |
| 682 | byte_length = length/2; |
| 683 | if (!kstrtoul(buf_tmp, 16, &result)) //command |
| 684 | { |
| 685 | for (loop_i = 0 ; loop_i < byte_length ; loop_i++) |
| 686 | { |
| 687 | register_command[loop_i] = (uint8_t)(result >> loop_i*8); |
| 688 | } |
| 689 | } |
| 690 | if (!kstrtoul(data_str+1, 16, &result)) //data |
| 691 | { |
| 692 | for (loop_i = 0 ; loop_i < byte_length ; loop_i++) |
| 693 | { |
| 694 | w_data[loop_i] = (uint8_t)(result >> loop_i*8); |
| 695 | } |
| 696 | } |
| 697 | himax_register_write(private_ts->client, register_command, byte_length, w_data, cfg_flag); |
| 698 | } |
| 699 | else |
| 700 | { |
| 701 | byte_length = x_pos[1] - x_pos[0] - 2; |
| 702 | for (loop_i = 0; loop_i < count; loop_i++) //parsing addr after 'x' |
| 703 | { |
| 704 | memcpy(buf_tmp, buf + x_pos[loop_i] + 1, byte_length); |
| 705 | //I("%s: buf_tmp = %s\n", __func__,buf_tmp); |
| 706 | if (!kstrtoul(buf_tmp, 16, &result)) |
| 707 | { |
| 708 | if(loop_i == 0) |
| 709 | { |
| 710 | register_command[loop_i] = (uint8_t)(result); |
| 711 | //I("%s: register_command = %X\n", __func__,register_command[0]); |
| 712 | } |
| 713 | else |
| 714 | { |
| 715 | w_data[loop_i - 1] = (uint8_t)(result); |
| 716 | //I("%s: w_data[%d] = %2X\n", __func__,loop_i - 1,w_data[loop_i - 1]); |
| 717 | } |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | byte_length = count - 1; |
| 722 | himax_register_write(private_ts->client, register_command, byte_length, &w_data[0], cfg_flag); |
| 723 | } |
| 724 | } |
| 725 | else |
| 726 | return len; |
| 727 | |
| 728 | } |
| 729 | return len; |
| 730 | } |
| 731 | |
| 732 | static struct file_operations himax_proc_register_ops = |
| 733 | { |
| 734 | .owner = THIS_MODULE, |
| 735 | .read = himax_proc_register_read, |
| 736 | .write = himax_proc_register_write, |
| 737 | }; |
| 738 | #endif |
| 739 | |
| 740 | #ifdef HX_TP_PROC_DIAG |
| 741 | int32_t *getMutualBuffer(void) |
| 742 | { |
| 743 | return diag_mutual; |
| 744 | } |
| 745 | int32_t *getMutualNewBuffer(void) |
| 746 | { |
| 747 | return diag_mutual_new; |
| 748 | } |
| 749 | int32_t *getMutualOldBuffer(void) |
| 750 | { |
| 751 | return diag_mutual_old; |
| 752 | } |
| 753 | int32_t *getSelfBuffer(void) |
| 754 | { |
| 755 | return &diag_self[0]; |
| 756 | } |
| 757 | uint8_t getXChannel(void) |
| 758 | { |
| 759 | return x_channel; |
| 760 | } |
| 761 | uint8_t getYChannel(void) |
| 762 | { |
| 763 | return y_channel; |
| 764 | } |
| 765 | uint8_t getDiagCommand(void) |
| 766 | { |
| 767 | return g_diag_command; |
| 768 | } |
| 769 | void setXChannel(uint8_t x) |
| 770 | { |
| 771 | x_channel = x; |
| 772 | } |
| 773 | void setYChannel(uint8_t y) |
| 774 | { |
| 775 | y_channel = y; |
| 776 | } |
| 777 | void setMutualBuffer(void) |
| 778 | { |
| 779 | diag_mutual = kzalloc(x_channel * y_channel * sizeof(int32_t), GFP_KERNEL); |
| 780 | } |
| 781 | void setMutualNewBuffer(void) |
| 782 | { |
| 783 | diag_mutual_new = kzalloc(x_channel * y_channel * sizeof(int32_t), GFP_KERNEL); |
| 784 | } |
| 785 | void setMutualOldBuffer(void) |
| 786 | { |
| 787 | diag_mutual_old = kzalloc(x_channel * y_channel * sizeof(int32_t), GFP_KERNEL); |
| 788 | } |
| 789 | |
| 790 | #ifdef HX_TP_PROC_2T2R |
| 791 | int32_t *getMutualBuffer_2(void) |
| 792 | { |
| 793 | return diag_mutual_2; |
| 794 | } |
| 795 | uint8_t getXChannel_2(void) |
| 796 | { |
| 797 | return x_channel_2; |
| 798 | } |
| 799 | uint8_t getYChannel_2(void) |
| 800 | { |
| 801 | return y_channel_2; |
| 802 | } |
| 803 | void setXChannel_2(uint8_t x) |
| 804 | { |
| 805 | x_channel_2 = x; |
| 806 | } |
| 807 | void setYChannel_2(uint8_t y) |
| 808 | { |
| 809 | y_channel_2 = y; |
| 810 | } |
| 811 | void setMutualBuffer_2(void) |
| 812 | { |
| 813 | diag_mutual_2 = kzalloc(x_channel_2 * y_channel_2 * sizeof(int32_t), GFP_KERNEL); |
| 814 | } |
| 815 | #endif |
| 816 | |
| 817 | #ifdef HX_TP_PROC_DIAG |
| 818 | int himax_set_diag_cmd(struct himax_ic_data *ic_data,struct himax_report_data *hx_touch_data) |
| 819 | { |
| 820 | int32_t *mutual_data; |
| 821 | int32_t *self_data; |
| 822 | int mul_num; |
| 823 | int self_num; |
| 824 | //int RawDataLen = 0; |
| 825 | |
| 826 | hx_touch_data->diag_cmd = getDiagCommand(); |
| 827 | if (hx_touch_data->diag_cmd >= 1 && hx_touch_data->diag_cmd <= 7) |
| 828 | { |
| 829 | //Check event stack CRC |
| 830 | if(!diag_check_sum(hx_touch_data)) |
| 831 | { |
| 832 | goto bypass_checksum_failed_packet; |
| 833 | } |
| 834 | #ifdef HX_TP_PROC_2T2R |
| 835 | if(Is_2T2R && (hx_touch_data->diag_cmd >= 4 && hx_touch_data->diag_cmd <= 6)) |
| 836 | { |
| 837 | mutual_data = getMutualBuffer_2(); |
| 838 | self_data = getSelfBuffer(); |
| 839 | |
| 840 | // initiallize the block number of mutual and self |
| 841 | mul_num = getXChannel_2() * getYChannel_2(); |
| 842 | |
| 843 | #ifdef HX_EN_SEL_BUTTON |
| 844 | self_num = getXChannel_2() + getYChannel_2() + ic_data->HX_BT_NUM; |
| 845 | #else |
| 846 | self_num = getXChannel_2() + getYChannel_2(); |
| 847 | #endif |
| 848 | } |
| 849 | else |
| 850 | #endif |
| 851 | { |
| 852 | mutual_data = getMutualBuffer(); |
| 853 | self_data = getSelfBuffer(); |
| 854 | |
| 855 | // initiallize the block number of mutual and self |
| 856 | mul_num = getXChannel() * getYChannel(); |
| 857 | |
| 858 | #ifdef HX_EN_SEL_BUTTON |
| 859 | self_num = getXChannel() + getYChannel() + ic_data->HX_BT_NUM; |
| 860 | #else |
| 861 | self_num = getXChannel() + getYChannel(); |
| 862 | #endif |
| 863 | } |
| 864 | |
| 865 | diag_parse_raw_data(hx_touch_data,mul_num, self_num,hx_touch_data->diag_cmd, mutual_data,self_data); |
| 866 | |
| 867 | } |
| 868 | else if (hx_touch_data->diag_cmd == 8) |
| 869 | { |
| 870 | memset(diag_coor, 0x00, sizeof(diag_coor)); |
| 871 | memcpy(&(diag_coor[0]), &hx_touch_data->hx_coord_buf[0], hx_touch_data->touch_info_size); |
| 872 | } |
| 873 | //assign state info data |
| 874 | memcpy(&(hx_state_info[0]), &hx_touch_data->hx_state_info[0], 2); |
| 875 | |
| 876 | return NO_ERR; |
| 877 | |
| 878 | bypass_checksum_failed_packet: |
| 879 | return 1; |
| 880 | } |
| 881 | #endif |
| 882 | //#if defined(HX_DEBUG_LEVEL) |
| 883 | void himax_log_touch_data(uint8_t *buf,struct himax_report_data *hx_touch_data) |
| 884 | { |
| 885 | int loop_i = 0; |
| 886 | int print_size = 0; |
| 887 | |
| 888 | if(!hx_touch_data->diag_cmd) |
| 889 | print_size = hx_touch_data->touch_info_size; |
| 890 | else |
| 891 | print_size = hx_touch_data->touch_all_size; |
| 892 | |
| 893 | for (loop_i = 0; loop_i < print_size; loop_i+=8) |
| 894 | { |
| 895 | if((loop_i + 7) >= print_size) |
| 896 | { |
| 897 | I("%s: over flow\n",__func__); |
| 898 | break; |
| 899 | } |
| 900 | I("P %2d = 0x%2.2X P %2d = 0x%2.2X ", loop_i, buf[loop_i], loop_i + 1, buf[loop_i + 1]); |
| 901 | I("P %2d = 0x%2.2X P %2d = 0x%2.2X ", loop_i + 2, buf[loop_i + 2], loop_i + 3, buf[loop_i + 3]); |
| 902 | I("P %2d = 0x%2.2X P %2d = 0x%2.2X ", loop_i + 4, buf[loop_i + 4], loop_i + 5, buf[loop_i + 5]); |
| 903 | I("P %2d = 0x%2.2X P %2d = 0x%2.2X ", loop_i + 6, buf[loop_i + 6], loop_i + 7, buf[loop_i + 7]); |
| 904 | I("\n"); |
| 905 | } |
| 906 | } |
| 907 | void himax_log_touch_event(int x,int y,int w,int loop_i,uint8_t EN_NoiseFilter,int touched) |
| 908 | { |
| 909 | if(touched == HX_FINGER_ON) |
| 910 | I("Finger %d=> X:%d, Y:%d W:%d, Z:%d, F:%d, N:%d\n",loop_i + 1, x, y, w, w, loop_i + 1, EN_NoiseFilter); |
| 911 | else if(touched == HX_FINGER_LEAVE) |
| 912 | I("All Finger leave\n"); |
| 913 | else |
| 914 | I("%s : wrong input!\n",__func__); |
| 915 | } |
| 916 | void himax_log_touch_int_devation(int touched) |
| 917 | { |
| 918 | |
| 919 | |
| 920 | if(touched == HX_FINGER_ON) |
| 921 | { |
| 922 | getnstimeofday(&timeStart); |
| 923 | /* I(" Irq start time = %ld.%06ld s\n", |
| 924 | timeStart.tv_sec, timeStart.tv_nsec/1000); */ |
| 925 | } |
| 926 | else if(touched == HX_FINGER_LEAVE) |
| 927 | { |
| 928 | getnstimeofday(&timeEnd); |
| 929 | timeDelta.tv_nsec = (timeEnd.tv_sec*1000000000+timeEnd.tv_nsec) - (timeStart.tv_sec*1000000000+timeStart.tv_nsec); |
| 930 | /*I("Irq finish time = %ld.%06ld s\n", |
| 931 | timeEnd.tv_sec, timeEnd.tv_nsec/1000);*/ |
| 932 | I("Touch latency = %ld us\n", timeDelta.tv_nsec/1000); |
| 933 | } |
| 934 | else |
| 935 | I("%s : wrong input!\n",__func__); |
| 936 | } |
| 937 | void himax_log_touch_event_detail(struct himax_ts_data *ts,int x,int y,int w,int loop_i,uint8_t EN_NoiseFilter,int touched,uint16_t old_finger) |
| 938 | { |
| 939 | |
| 940 | if (touched == HX_FINGER_ON) |
| 941 | { |
| 942 | if (old_finger >> loop_i == 0) |
| 943 | { |
| 944 | if (ts->useScreenRes) |
| 945 | { |
| 946 | I("status: Screen:F:%02d Down, X:%d, Y:%d, W:%d, N:%d\n", |
| 947 | loop_i+1, x * ts->widthFactor >> SHIFTBITS, |
| 948 | y * ts->heightFactor >> SHIFTBITS, w, EN_NoiseFilter); |
| 949 | } |
| 950 | else |
| 951 | { |
| 952 | I("status: Raw:F:%02d Down, X:%d, Y:%d, W:%d, N:%d\n", |
| 953 | loop_i+1, x, y, w, EN_NoiseFilter); |
| 954 | } |
| 955 | } |
| 956 | } |
| 957 | else if(touched == HX_FINGER_LEAVE)//if (old_finger >> loop_i == 1) |
| 958 | { |
| 959 | if (old_finger >> loop_i == 1) |
| 960 | { |
| 961 | if (ts->useScreenRes) |
| 962 | { |
| 963 | I("status: Screen:F:%02d Up, X:%d, Y:%d, N:%d\n", |
| 964 | loop_i+1, ts->pre_finger_data[loop_i][0] * ts->widthFactor >> SHIFTBITS, |
| 965 | ts->pre_finger_data[loop_i][1] * ts->heightFactor >> SHIFTBITS, EN_NoiseFilter); //Last_EN_NoiseFilter |
| 966 | } |
| 967 | else |
| 968 | { |
| 969 | I("status: Raw:F:%02d Up, X:%d, Y:%d, N:%d\n", |
| 970 | loop_i+1, ts->pre_finger_data[loop_i][0], |
| 971 | ts->pre_finger_data[loop_i][1], EN_NoiseFilter); //Last_EN_NoiseFilter |
| 972 | } |
| 973 | } |
| 974 | } |
| 975 | else |
| 976 | { |
| 977 | I("%s : wrong input!\n",__func__); |
| 978 | } |
| 979 | } |
| 980 | //#endif |
| 981 | static ssize_t himax_diag_arrange_write(struct file *file, const char *buff, |
| 982 | size_t len, loff_t *pos) |
| 983 | { |
| 984 | |
| 985 | char buf[80] = {0}; |
| 986 | |
| 987 | if (len >= 80) |
| 988 | { |
| 989 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 990 | return -EFAULT; |
| 991 | } |
| 992 | if (copy_from_user(buf, buff, len)) |
| 993 | { |
| 994 | return -EFAULT; |
| 995 | } |
| 996 | |
| 997 | g_diag_arr_num = buf[0] - '0'; |
| 998 | I("%s: g_diag_arr_num = %d \n", __func__,g_diag_arr_num); |
| 999 | |
| 1000 | return len; |
| 1001 | } |
| 1002 | |
| 1003 | void himax_get_mutual_edge(void) |
| 1004 | { |
| 1005 | int i = 0; |
| 1006 | for(i = 0; i < (x_channel * y_channel); i++) |
| 1007 | { |
| 1008 | if(diag_mutual[i] > g_max_mutual) |
| 1009 | g_max_mutual = diag_mutual[i]; |
| 1010 | if(diag_mutual[i] < g_min_mutual) |
| 1011 | g_min_mutual = diag_mutual[i]; |
| 1012 | } |
| 1013 | } |
| 1014 | |
| 1015 | void himax_get_self_edge(void) |
| 1016 | { |
| 1017 | int i = 0; |
| 1018 | for(i = 0; i < (x_channel + y_channel); i++) |
| 1019 | { |
| 1020 | if(diag_self[i] > g_max_self) |
| 1021 | g_max_self = diag_self[i]; |
| 1022 | if(diag_self[i] < g_min_self) |
| 1023 | g_min_self = diag_self[i]; |
| 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | /* print first step which is row */ |
| 1028 | static struct file_operations himax_proc_diag_arrange_ops = |
| 1029 | { |
| 1030 | .owner = THIS_MODULE, |
| 1031 | .write = himax_diag_arrange_write, |
| 1032 | }; |
| 1033 | static void print_state_info(struct seq_file *s) |
| 1034 | { |
| 1035 | //seq_printf(s, "State_info_2bytes:%3d, %3d\n",hx_state_info[0],hx_state_info[1]); |
| 1036 | seq_printf(s, "ReCal = %d\t",hx_state_info[0] & 0x01); |
| 1037 | seq_printf(s, "Palm = %d\t",hx_state_info[0]>>1 & 0x01); |
| 1038 | seq_printf(s, "AC mode = %d\t",hx_state_info[0]>>2 & 0x01); |
| 1039 | seq_printf(s, "Water = %d\n",hx_state_info[0]>>3 & 0x01); |
| 1040 | seq_printf(s, "Glove = %d\t",hx_state_info[0]>>4 & 0x01); |
| 1041 | seq_printf(s, "TX Hop = %d\t",hx_state_info[0]>>5 & 0x01 ); |
| 1042 | seq_printf(s, "Base Line = %d\t",hx_state_info[0]>>6 & 0x01); |
| 1043 | seq_printf(s, "OSR Hop = %d\t",hx_state_info[1]>>3 & 0x01); |
| 1044 | seq_printf(s, "KEY = %d\n",hx_state_info[1]>>4 & 0x0F); |
| 1045 | } |
| 1046 | |
| 1047 | static void himax_diag_arrange_print(struct seq_file *s, int i, int j, int transpose) |
| 1048 | { |
| 1049 | |
| 1050 | if(transpose) |
| 1051 | seq_printf(s, "%6d", diag_mutual[ j + i*x_channel]); |
| 1052 | else |
| 1053 | seq_printf(s, "%6d", diag_mutual[ i + j*x_channel]); |
| 1054 | } |
| 1055 | |
| 1056 | /* ready to print second step which is column*/ |
| 1057 | static void himax_diag_arrange_inloop(struct seq_file *s, int in_init,int out_init,bool transpose, int j) |
| 1058 | { |
| 1059 | int i; |
| 1060 | int in_max = 0; |
| 1061 | |
| 1062 | if(transpose) |
| 1063 | in_max = y_channel; |
| 1064 | else |
| 1065 | in_max = x_channel; |
| 1066 | |
| 1067 | if (in_init > 0) //bit0 = 1 |
| 1068 | { |
| 1069 | for(i = in_init-1; i >= 0; i--) |
| 1070 | { |
| 1071 | himax_diag_arrange_print(s, i, j, transpose); |
| 1072 | } |
| 1073 | if(transpose) |
| 1074 | { |
| 1075 | if(out_init > 0) |
| 1076 | seq_printf(s, " %5d\n", diag_self[j]); |
| 1077 | else |
| 1078 | seq_printf(s, " %5d\n", diag_self[x_channel - j - 1]); |
| 1079 | } |
| 1080 | } |
| 1081 | else //bit0 = 0 |
| 1082 | { |
| 1083 | for (i = 0; i < in_max; i++) |
| 1084 | { |
| 1085 | himax_diag_arrange_print(s, i, j, transpose); |
| 1086 | } |
| 1087 | if(transpose) |
| 1088 | { |
| 1089 | if(out_init > 0) |
| 1090 | seq_printf(s, " %5d\n", diag_self[x_channel - j - 1]); |
| 1091 | else |
| 1092 | seq_printf(s, " %5d\n", diag_self[j]); |
| 1093 | } |
| 1094 | } |
| 1095 | } |
| 1096 | |
| 1097 | /* print first step which is row */ |
| 1098 | static void himax_diag_arrange_outloop(struct seq_file *s, int transpose, int out_init, int in_init) |
| 1099 | { |
| 1100 | int j; |
| 1101 | int out_max = 0; |
| 1102 | int self_cnt = 0; |
| 1103 | |
| 1104 | if(transpose) |
| 1105 | out_max = x_channel; |
| 1106 | else |
| 1107 | out_max = y_channel; |
| 1108 | |
| 1109 | if(out_init > 0) //bit1 = 1 |
| 1110 | { |
| 1111 | self_cnt = 1; |
| 1112 | for(j = out_init-1; j >= 0; j--) |
| 1113 | { |
| 1114 | seq_printf(s, "%3c%02d%c",'[', j + 1,']'); |
| 1115 | himax_diag_arrange_inloop(s, in_init, out_init, transpose, j); |
| 1116 | if(!transpose) |
| 1117 | { |
| 1118 | seq_printf(s, " %5d\n", diag_self[y_channel + x_channel - self_cnt]); |
| 1119 | self_cnt++; |
| 1120 | } |
| 1121 | } |
| 1122 | } |
| 1123 | else //bit1 = 0 |
| 1124 | { |
| 1125 | //self_cnt = x_channel; |
| 1126 | for(j = 0; j < out_max; j++) |
| 1127 | { |
| 1128 | seq_printf(s, "%3c%02d%c",'[', j + 1,']'); |
| 1129 | himax_diag_arrange_inloop(s, in_init, out_init, transpose, j); |
| 1130 | if(!transpose) |
| 1131 | { |
| 1132 | seq_printf(s, " %5d\n", diag_self[j + x_channel]); |
| 1133 | } |
| 1134 | } |
| 1135 | } |
| 1136 | } |
| 1137 | |
| 1138 | /* determin the output format of diag */ |
| 1139 | static void himax_diag_arrange(struct seq_file *s) |
| 1140 | { |
| 1141 | int bit2,bit1,bit0; |
| 1142 | int i; |
| 1143 | |
| 1144 | /* rotate bit */ |
| 1145 | bit2 = g_diag_arr_num >> 2; |
| 1146 | /* reverse Y */ |
| 1147 | bit1 = g_diag_arr_num >> 1 & 0x1; |
| 1148 | /* reverse X */ |
| 1149 | bit0 = g_diag_arr_num & 0x1; |
| 1150 | |
| 1151 | if (g_diag_arr_num < 4) |
| 1152 | { |
| 1153 | for (i = 0 ; i <= x_channel; i++) |
| 1154 | seq_printf(s, "%3c%02d%c",'[', i,']'); |
| 1155 | seq_printf(s,"\n"); |
| 1156 | himax_diag_arrange_outloop(s, bit2, bit1 * y_channel, bit0 * x_channel); |
| 1157 | seq_printf(s, "%6c",' '); |
| 1158 | if(bit0 == 1) |
| 1159 | { |
| 1160 | for (i = x_channel - 1; i >= 0; i--) |
| 1161 | seq_printf(s, "%6d", diag_self[i]); |
| 1162 | } |
| 1163 | else |
| 1164 | { |
| 1165 | for (i = 0; i < x_channel; i++) |
| 1166 | seq_printf(s, "%6d", diag_self[i]); |
| 1167 | } |
| 1168 | } |
| 1169 | else |
| 1170 | { |
| 1171 | for (i = 0 ; i <= y_channel; i++) |
| 1172 | seq_printf(s, "%3c%02d%c",'[', i,']'); |
| 1173 | seq_printf(s,"\n"); |
| 1174 | himax_diag_arrange_outloop(s, bit2, bit1 * x_channel, bit0 * y_channel); |
| 1175 | seq_printf(s, "%6c",' '); |
| 1176 | if(bit1 == 1) |
| 1177 | { |
| 1178 | for (i = x_channel + y_channel - 1; i >= x_channel; i--) |
| 1179 | { |
| 1180 | seq_printf(s, "%6d", diag_self[i]); |
| 1181 | } |
| 1182 | } |
| 1183 | else |
| 1184 | { |
| 1185 | for (i = x_channel; i < x_channel + y_channel; i++) |
| 1186 | { |
| 1187 | seq_printf(s, "%6d", diag_self[i]); |
| 1188 | } |
| 1189 | } |
| 1190 | } |
| 1191 | } |
| 1192 | |
| 1193 | static void *himax_diag_seq_start(struct seq_file *s, loff_t *pos) |
| 1194 | { |
| 1195 | if (*pos>=1) return NULL; |
| 1196 | return (void *)((unsigned long) *pos+1); |
| 1197 | } |
| 1198 | |
| 1199 | static void *himax_diag_seq_next(struct seq_file *s, void *v, loff_t *pos) |
| 1200 | { |
| 1201 | return NULL; |
| 1202 | } |
| 1203 | static void himax_diag_seq_stop(struct seq_file *s, void *v) |
| 1204 | { |
| 1205 | } |
| 1206 | static int himax_diag_seq_read(struct seq_file *s, void *v) |
| 1207 | { |
| 1208 | size_t count = 0; |
| 1209 | uint32_t loop_i; |
| 1210 | uint16_t mutual_num, self_num, width; |
| 1211 | int dsram_type = 0; |
| 1212 | |
| 1213 | dsram_type = g_diag_command/10; |
| 1214 | |
| 1215 | #ifdef HX_TP_PROC_2T2R |
| 1216 | if(Is_2T2R &&(g_diag_command >= 4 && g_diag_command <= 6)) |
| 1217 | { |
| 1218 | mutual_num = x_channel_2 * y_channel_2; |
| 1219 | self_num = x_channel_2 + y_channel_2; //don't add KEY_COUNT |
| 1220 | width = x_channel_2; |
| 1221 | seq_printf(s, "ChannelStart: %4d, %4d\n\n", x_channel_2, y_channel_2); |
| 1222 | } |
| 1223 | else |
| 1224 | #endif |
| 1225 | { |
| 1226 | mutual_num = x_channel * y_channel; |
| 1227 | self_num = x_channel + y_channel; //don't add KEY_COUNT |
| 1228 | width = x_channel; |
| 1229 | seq_printf(s, "ChannelStart: %4d, %4d\n\n", x_channel, y_channel); |
| 1230 | } |
| 1231 | |
| 1232 | // start to show out the raw data in adb shell |
| 1233 | if ((g_diag_command >= 1 && g_diag_command <= 3) || (g_diag_command == 7)) |
| 1234 | { |
| 1235 | himax_diag_arrange(s); |
| 1236 | seq_printf(s, "\n"); |
| 1237 | #ifdef HX_EN_SEL_BUTTON |
| 1238 | seq_printf(s, "\n"); |
| 1239 | for (loop_i = 0; loop_i < ic_data->HX_BT_NUM; loop_i++) |
| 1240 | seq_printf(s, "%6d", diag_self[ic_data->HX_RX_NUM + ic_data->HX_TX_NUM + loop_i]); |
| 1241 | #endif |
| 1242 | seq_printf(s, "ChannelEnd"); |
| 1243 | seq_printf(s, "\n"); |
| 1244 | } |
| 1245 | #ifdef HX_TP_PROC_2T2R |
| 1246 | else if(Is_2T2R && g_diag_command >= 4 && g_diag_command <= 6) |
| 1247 | { |
| 1248 | for (loop_i = 0; loop_i < mutual_num; loop_i++) |
| 1249 | { |
| 1250 | seq_printf(s, "%4d", diag_mutual_2[loop_i]); |
| 1251 | if ((loop_i % width) == (width - 1)) |
| 1252 | seq_printf(s, " %4d\n", diag_self[width + loop_i/width]); |
| 1253 | } |
| 1254 | seq_printf(s, "\n"); |
| 1255 | for (loop_i = 0; loop_i < width; loop_i++) |
| 1256 | { |
| 1257 | seq_printf(s, "%4d", diag_self[loop_i]); |
| 1258 | if (((loop_i) % width) == (width - 1)) |
| 1259 | seq_printf(s, "\n"); |
| 1260 | } |
| 1261 | |
| 1262 | #ifdef HX_EN_SEL_BUTTON |
| 1263 | seq_printf(s, "\n"); |
| 1264 | for (loop_i = 0; loop_i < HX_BT_NUM; loop_i++) |
| 1265 | seq_printf(s, "%4d", diag_self[ic_data->HX_RX_NUM_2 + ic_data->HX_TX_NUM_2 + loop_i]); |
| 1266 | #endif |
| 1267 | seq_printf(s, "ChannelEnd"); |
| 1268 | seq_printf(s, "\n"); |
| 1269 | } |
| 1270 | #endif |
| 1271 | else if (g_diag_command == 8) |
| 1272 | { |
| 1273 | for (loop_i = 0; loop_i < 128 ; loop_i++) |
| 1274 | { |
| 1275 | if ((loop_i % 16) == 0) |
| 1276 | seq_printf(s, "LineStart:"); |
| 1277 | seq_printf(s, "%4x", diag_coor[loop_i]); |
| 1278 | if ((loop_i % 16) == 15) |
| 1279 | seq_printf(s, "\n"); |
| 1280 | } |
| 1281 | } |
| 1282 | else if (dsram_type > 0 && dsram_type <= 8) |
| 1283 | { |
| 1284 | himax_diag_arrange(s); |
| 1285 | seq_printf(s, "ChannelEnd"); |
| 1286 | seq_printf(s, "\n"); |
| 1287 | } |
| 1288 | if((g_diag_command >= 1 && g_diag_command <= 7) || dsram_type > 0) |
| 1289 | { |
| 1290 | /* print Mutual/Slef Maximum and Minimum */ |
| 1291 | himax_get_mutual_edge(); |
| 1292 | himax_get_self_edge(); |
| 1293 | seq_printf(s, "Mutual Max:%3d, Min:%3d\n",g_max_mutual,g_min_mutual); |
| 1294 | seq_printf(s, "Self Max:%3d, Min:%3d\n",g_max_self,g_min_self); |
| 1295 | |
| 1296 | /* recovery status after print*/ |
| 1297 | g_max_mutual = 0; |
| 1298 | g_min_mutual = 255; |
| 1299 | g_max_self = 0; |
| 1300 | g_min_self = 255; |
| 1301 | } |
| 1302 | /*pring state info*/ |
| 1303 | print_state_info(s); |
| 1304 | return count; |
| 1305 | } |
| 1306 | static struct seq_operations himax_diag_seq_ops = |
| 1307 | { |
| 1308 | .start = himax_diag_seq_start, |
| 1309 | .next = himax_diag_seq_next, |
| 1310 | .stop = himax_diag_seq_stop, |
| 1311 | .show = himax_diag_seq_read, |
| 1312 | }; |
| 1313 | static int himax_diag_proc_open(struct inode *inode, struct file *file) |
| 1314 | { |
| 1315 | return seq_open(file, &himax_diag_seq_ops); |
| 1316 | }; |
| 1317 | bool DSRAM_Flag = false; |
| 1318 | |
| 1319 | //DSRAM thread |
| 1320 | void himax_ts_diag_func(void) |
| 1321 | { |
| 1322 | int i=0, j=0; |
| 1323 | unsigned int index = 0; |
| 1324 | int total_size = ic_data->HX_TX_NUM * ic_data->HX_RX_NUM * 2; |
| 1325 | uint8_t info_data[total_size]; |
| 1326 | int32_t *mutual_data; |
| 1327 | int32_t *mutual_data_new; |
| 1328 | int32_t *mutual_data_old; |
| 1329 | int32_t new_data; |
| 1330 | /* 1:common dsram,2:100 frame Max,3:N-(N-1)frame */ |
| 1331 | int dsram_type = 0; |
| 1332 | char temp_buf[20]; |
| 1333 | char write_buf[total_size*3]; |
| 1334 | |
| 1335 | mutual_data = NULL; |
| 1336 | mutual_data_new = NULL; |
| 1337 | mutual_data_old = NULL; |
| 1338 | memset(write_buf, '\0', sizeof(write_buf)); |
| 1339 | |
| 1340 | dsram_type = g_diag_command/10; |
| 1341 | |
| 1342 | I("%s:Entering g_diag_command=%d\n!",__func__,g_diag_command); |
| 1343 | |
| 1344 | if(dsram_type == 8) |
| 1345 | { |
| 1346 | dsram_type = 1; |
| 1347 | I("%s Sorting Mode run sram type1 ! \n",__func__); |
| 1348 | } |
| 1349 | |
| 1350 | himax_burst_enable(private_ts->client, 1); |
| 1351 | if(dsram_type == 1 || dsram_type == 2 || dsram_type == 4) |
| 1352 | { |
| 1353 | mutual_data = getMutualBuffer(); |
| 1354 | } |
| 1355 | else if(dsram_type == 3) |
| 1356 | { |
| 1357 | mutual_data = getMutualBuffer(); |
| 1358 | mutual_data_new = getMutualNewBuffer(); |
| 1359 | mutual_data_old = getMutualOldBuffer(); |
| 1360 | } |
| 1361 | himax_get_DSRAM_data(private_ts->client, info_data); |
| 1362 | |
| 1363 | index = 0; |
| 1364 | for (i = 0; i < ic_data->HX_TX_NUM; i++) |
| 1365 | { |
| 1366 | for (j = 0; j < ic_data->HX_RX_NUM; j++) |
| 1367 | { |
| 1368 | new_data = (info_data[index + 1] << 8 | info_data[index]); |
| 1369 | if(dsram_type == 1 || dsram_type == 4) |
| 1370 | { |
| 1371 | mutual_data[i*ic_data->HX_RX_NUM+j] = new_data; |
| 1372 | } |
| 1373 | else if(dsram_type == 2) |
| 1374 | { |
| 1375 | //Keep max data for 100 frame |
| 1376 | if(mutual_data[i * ic_data->HX_RX_NUM + j] < new_data) |
| 1377 | mutual_data[i * ic_data->HX_RX_NUM + j] = new_data; |
| 1378 | } |
| 1379 | else if(dsram_type == 3) |
| 1380 | { |
| 1381 | //Cal data for [N]-[N-1] frame |
| 1382 | mutual_data_new[i * ic_data->HX_RX_NUM + j] = new_data; |
| 1383 | mutual_data[i * ic_data->HX_RX_NUM + j] = mutual_data_new[i * ic_data->HX_RX_NUM + j] - mutual_data_old[i * ic_data->HX_RX_NUM + j]; |
| 1384 | } |
| 1385 | index += 2; |
| 1386 | } |
| 1387 | } |
| 1388 | if(dsram_type == 3) |
| 1389 | { |
| 1390 | memcpy(mutual_data_old,mutual_data_new,x_channel * y_channel * sizeof(int16_t)); //copy N data to N-1 array |
| 1391 | } |
| 1392 | diag_max_cnt++; |
| 1393 | if(dsram_type == 1 || dsram_type == 3 ) |
| 1394 | { |
| 1395 | queue_delayed_work(private_ts->himax_diag_wq, &private_ts->himax_diag_delay_wrok, 1/10*HZ); |
| 1396 | } |
| 1397 | else if(dsram_type == 4) |
| 1398 | { |
| 1399 | for(i = 0; i < x_channel * y_channel; i++) |
| 1400 | { |
| 1401 | memset(temp_buf, '\0', sizeof(temp_buf)); |
| 1402 | if(i == (x_channel * y_channel - 1)) |
| 1403 | snprintf(temp_buf, sizeof(temp_buf), "%4d\n\n", mutual_data[i]); |
| 1404 | //I("%s :temp_buf = %s\n",__func__,temp_buf); |
| 1405 | else if(i % x_channel == (x_channel - 1)) |
| 1406 | snprintf(temp_buf, sizeof(temp_buf), "%4d\n", mutual_data[i]); |
| 1407 | else |
| 1408 | snprintf(temp_buf, sizeof(temp_buf), "%4d\t", mutual_data[i]); |
| 1409 | //I("%s :mutual_data[%d] = %d, temp_buf = %s\n",__func__, i, mutual_data[i], temp_buf); |
| 1410 | strcat(write_buf, temp_buf); |
| 1411 | } |
| 1412 | |
| 1413 | //save raw data in file |
| 1414 | if (!IS_ERR(diag_sram_fn)) |
| 1415 | { |
| 1416 | I("%s create file and ready to write\n",__func__); |
| 1417 | diag_sram_fn->f_op->write(diag_sram_fn, write_buf, sizeof(write_buf), &diag_sram_fn->f_pos); |
| 1418 | write_counter++; |
| 1419 | if(write_counter < write_max_count) |
| 1420 | queue_delayed_work(private_ts->himax_diag_wq, &private_ts->himax_diag_delay_wrok, 1/10*HZ); |
| 1421 | else |
| 1422 | { |
| 1423 | filp_close(diag_sram_fn,NULL); |
| 1424 | write_counter = 0; |
| 1425 | } |
| 1426 | } |
| 1427 | } |
| 1428 | else if(dsram_type == 2) |
| 1429 | { |
| 1430 | if(diag_max_cnt > 100) //count for 100 frame |
| 1431 | { |
| 1432 | //Clear DSRAM flag |
| 1433 | DSRAM_Flag = false; |
| 1434 | |
| 1435 | //Enable ISR |
| 1436 | himax_int_enable(private_ts->client->irq,1); |
| 1437 | |
| 1438 | //===================================== |
| 1439 | // test result command : 0x8002_0324 ==> 0x00 |
| 1440 | //===================================== |
| 1441 | himax_diag_register_set(private_ts->client, 0x00); |
| 1442 | } |
| 1443 | else |
| 1444 | { |
| 1445 | queue_delayed_work(private_ts->himax_diag_wq, &private_ts->himax_diag_delay_wrok, 1/10*HZ); |
| 1446 | } |
| 1447 | } |
| 1448 | } |
| 1449 | |
| 1450 | static ssize_t himax_diag_write(struct file *filp, const char __user *buff, size_t len, loff_t *data) |
| 1451 | { |
| 1452 | char messages[80] = {0}; |
| 1453 | |
| 1454 | uint8_t command[2] = {0x00, 0x00}; |
| 1455 | uint8_t receive[1]; |
| 1456 | |
| 1457 | /* 0: common , other: dsram*/ |
| 1458 | int storage_type = 0; |
| 1459 | /* 1:IIR,2:DC,3:Bank,4:IIR2,5:IIR2_N,6:FIR2,7:Baseline,8:dump coord */ |
| 1460 | int rawdata_type = 0; |
| 1461 | |
| 1462 | memset(receive, 0x00, sizeof(receive)); |
| 1463 | |
| 1464 | if (len >= 80) |
| 1465 | { |
| 1466 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 1467 | return -EFAULT; |
| 1468 | } |
| 1469 | if (copy_from_user(messages, buff, len)) |
| 1470 | { |
| 1471 | return -EFAULT; |
| 1472 | } |
| 1473 | |
| 1474 | I("%s:g_switch_mode = %d\n",__func__,g_switch_mode); |
| 1475 | |
| 1476 | if (messages[1] == 0x0A) |
| 1477 | { |
| 1478 | g_diag_command =messages[0] - '0'; |
| 1479 | } |
| 1480 | else |
| 1481 | { |
| 1482 | g_diag_command =(messages[0] - '0')*10 + (messages[1] - '0'); |
| 1483 | } |
| 1484 | |
| 1485 | storage_type = himax_determin_diag_storage(g_diag_command); |
| 1486 | rawdata_type = himax_determin_diag_rawdata(g_diag_command); |
| 1487 | |
| 1488 | if(g_diag_command > 0 && rawdata_type == 0) |
| 1489 | { |
| 1490 | I("[Himax]g_diag_command=0x%x ,storage_type=%d, rawdata_type=%d! Maybe no support!\n" |
| 1491 | ,g_diag_command,storage_type,rawdata_type); |
| 1492 | g_diag_command = 0x00; |
| 1493 | } |
| 1494 | else |
| 1495 | I("[Himax]g_diag_command=0x%x ,storage_type=%d, rawdata_type=%d\n",g_diag_command,storage_type,rawdata_type); |
| 1496 | |
| 1497 | if (storage_type == 0 && rawdata_type > 0 && rawdata_type < 8) |
| 1498 | { |
| 1499 | I("%s,common\n",__func__); |
| 1500 | if(DSRAM_Flag) |
| 1501 | { |
| 1502 | //1. Clear DSRAM flag |
| 1503 | DSRAM_Flag = false; |
| 1504 | //2. Stop DSRAM thread |
| 1505 | cancel_delayed_work(&private_ts->himax_diag_delay_wrok); |
| 1506 | //3. Enable ISR |
| 1507 | himax_int_enable(private_ts->client->irq,1); |
| 1508 | |
| 1509 | /*(4) FW leave sram and return to event stack*/ |
| 1510 | himax_return_event_stack(private_ts->client); |
| 1511 | } |
| 1512 | |
| 1513 | if(g_switch_mode == 2) |
| 1514 | { |
| 1515 | himax_idle_mode(private_ts->client,0); |
| 1516 | g_switch_mode = himax_switch_mode(private_ts->client,0); |
| 1517 | } |
| 1518 | |
| 1519 | if(g_diag_command == 0x04) |
| 1520 | { |
| 1521 | #if defined(HX_TP_PROC_2T2R) |
| 1522 | command[0] = g_diag_command; |
| 1523 | #else |
| 1524 | g_diag_command = 0x00; |
| 1525 | command[0] = 0x00; |
| 1526 | #endif |
| 1527 | } |
| 1528 | else |
| 1529 | command[0] = g_diag_command; |
| 1530 | himax_diag_register_set(private_ts->client, command[0]); |
| 1531 | } |
| 1532 | else if (storage_type > 0 && storage_type < 8 && rawdata_type > 0 && rawdata_type < 8) |
| 1533 | { |
| 1534 | I("%s,dsram\n",__func__); |
| 1535 | |
| 1536 | diag_max_cnt = 0; |
| 1537 | memset(diag_mutual, 0x00, x_channel * y_channel * sizeof(int32_t)); //Set data 0 everytime |
| 1538 | |
| 1539 | //0. set diag flag |
| 1540 | if(DSRAM_Flag) |
| 1541 | { |
| 1542 | //(1) Clear DSRAM flag |
| 1543 | DSRAM_Flag = false; |
| 1544 | |
| 1545 | //(2) Stop DSRAM thread |
| 1546 | cancel_delayed_work(&private_ts->himax_diag_delay_wrok); |
| 1547 | //(3) Enable ISR |
| 1548 | himax_int_enable(private_ts->client->irq,1); |
| 1549 | |
| 1550 | /*(4) FW leave sram and return to event stack*/ |
| 1551 | himax_return_event_stack(private_ts->client); |
| 1552 | } |
| 1553 | /* close sorting if turn on*/ |
| 1554 | if(g_switch_mode == 2) |
| 1555 | { |
| 1556 | himax_idle_mode(private_ts->client,0); |
| 1557 | g_switch_mode = himax_switch_mode(private_ts->client,0); |
| 1558 | } |
| 1559 | |
| 1560 | switch(rawdata_type) |
| 1561 | { |
| 1562 | case 1: |
| 1563 | command[0] = 0x09; //IIR |
| 1564 | break; |
| 1565 | case 2: |
| 1566 | command[0] = 0x0A; //RAWDATA |
| 1567 | break; |
| 1568 | case 7: |
| 1569 | command[0] = 0x0B; //DC |
| 1570 | break; |
| 1571 | default: |
| 1572 | command[0] = 0x00; |
| 1573 | E("%s: Sram no support this type !\n",__func__); |
| 1574 | break; |
| 1575 | } |
| 1576 | himax_diag_register_set(private_ts->client, command[0]); |
| 1577 | |
| 1578 | //1. Disable ISR |
| 1579 | himax_int_enable(private_ts->client->irq,0); |
| 1580 | |
| 1581 | //Open file for save raw data log |
| 1582 | if (storage_type == 4) |
| 1583 | { |
| 1584 | switch (rawdata_type) |
| 1585 | { |
| 1586 | case 1: |
| 1587 | diag_sram_fn = filp_open(IIR_DUMP_FILE,O_CREAT | O_WRONLY,0); |
| 1588 | break; |
| 1589 | case 2: |
| 1590 | diag_sram_fn = filp_open(DC_DUMP_FILE,O_CREAT | O_WRONLY,0); |
| 1591 | break; |
| 1592 | case 3: |
| 1593 | diag_sram_fn = filp_open(BANK_DUMP_FILE,O_CREAT | O_WRONLY,0); |
| 1594 | break; |
| 1595 | default: |
| 1596 | I("%s raw data type is not true. raw data type is %d \n",__func__, rawdata_type); |
| 1597 | } |
| 1598 | } |
| 1599 | |
| 1600 | //2. Start DSRAM thread |
| 1601 | queue_delayed_work(private_ts->himax_diag_wq, &private_ts->himax_diag_delay_wrok, 2*HZ/100); |
| 1602 | |
| 1603 | I("%s: Start get raw data in DSRAM\n", __func__); |
| 1604 | if (storage_type == 4) |
| 1605 | msleep(6000); |
| 1606 | //3. Set DSRAM flag |
| 1607 | DSRAM_Flag = true; |
| 1608 | |
| 1609 | |
| 1610 | } |
| 1611 | else if(storage_type == 8) |
| 1612 | { |
| 1613 | I("Soritng mode!\n"); |
| 1614 | |
| 1615 | if(DSRAM_Flag) |
| 1616 | { |
| 1617 | //1. Clear DSRAM flag |
| 1618 | DSRAM_Flag = false; |
| 1619 | //2. Stop DSRAM thread |
| 1620 | cancel_delayed_work(&private_ts->himax_diag_delay_wrok); |
| 1621 | //3. Enable ISR |
| 1622 | himax_int_enable(private_ts->client->irq,1); |
| 1623 | |
| 1624 | /*(4) FW leave sram and return to event stack*/ |
| 1625 | himax_return_event_stack(private_ts->client); |
| 1626 | } |
| 1627 | |
| 1628 | himax_idle_mode(private_ts->client,1); |
| 1629 | g_switch_mode = himax_switch_mode(private_ts->client,1); |
| 1630 | if(g_switch_mode == 2) |
| 1631 | { |
| 1632 | if(rawdata_type == 1) |
| 1633 | command[0] = 0x09; //IIR |
| 1634 | else if(rawdata_type == 2) |
| 1635 | command[0] = 0x0A; //DC |
| 1636 | else if(rawdata_type == 7) |
| 1637 | command[0] = 0x08; //BASLINE |
| 1638 | else |
| 1639 | { |
| 1640 | command[0] = 0x00; |
| 1641 | E("%s: Now Sorting Mode does not support this command=%d\n",__func__,g_diag_command); |
| 1642 | } |
| 1643 | himax_diag_register_set(private_ts->client, command[0]); |
| 1644 | } |
| 1645 | |
| 1646 | queue_delayed_work(private_ts->himax_diag_wq, &private_ts->himax_diag_delay_wrok, 2*HZ/100); |
| 1647 | DSRAM_Flag = true; |
| 1648 | |
| 1649 | } |
| 1650 | else |
| 1651 | { |
| 1652 | //set diag flag |
| 1653 | if(DSRAM_Flag) |
| 1654 | { |
| 1655 | I("return and cancel sram thread!\n"); |
| 1656 | //(1) Clear DSRAM flag |
| 1657 | DSRAM_Flag = false; |
| 1658 | |
| 1659 | //(2) Stop DSRAM thread |
| 1660 | cancel_delayed_work(&private_ts->himax_diag_delay_wrok); |
| 1661 | //(3) Enable ISR |
| 1662 | himax_int_enable(private_ts->client->irq,1); |
| 1663 | |
| 1664 | /*(4) FW leave sram and return to event stack*/ |
| 1665 | himax_return_event_stack(private_ts->client); |
| 1666 | } |
| 1667 | |
| 1668 | if(g_switch_mode == 2) |
| 1669 | { |
| 1670 | himax_idle_mode(private_ts->client,0); |
| 1671 | g_switch_mode = himax_switch_mode(private_ts->client,0); |
| 1672 | } |
| 1673 | |
| 1674 | if(g_diag_command != 0x00) |
| 1675 | { |
| 1676 | |
| 1677 | E("[Himax]g_diag_command error!diag_command=0x%x so reset\n",g_diag_command); |
| 1678 | command[0] = 0x00; |
| 1679 | if(g_diag_command != 0x08) |
| 1680 | g_diag_command = 0x00; |
| 1681 | himax_diag_register_set(private_ts->client, command[0]); |
| 1682 | } |
| 1683 | else |
| 1684 | { |
| 1685 | command[0] = 0x00; |
| 1686 | g_diag_command = 0x00; |
| 1687 | himax_diag_register_set(private_ts->client, command[0]); |
| 1688 | I("return to normal g_diag_command=0x%x\n",g_diag_command); |
| 1689 | } |
| 1690 | } |
| 1691 | return len; |
| 1692 | } |
| 1693 | |
| 1694 | static struct file_operations himax_proc_diag_ops = |
| 1695 | { |
| 1696 | .owner = THIS_MODULE, |
| 1697 | .open = himax_diag_proc_open, |
| 1698 | .read = seq_read, |
| 1699 | .write = himax_diag_write, |
| 1700 | }; |
| 1701 | #endif |
| 1702 | |
| 1703 | #ifdef HX_TP_PROC_RESET |
| 1704 | static ssize_t himax_reset_write(struct file *file, const char *buff, |
| 1705 | size_t len, loff_t *pos) |
| 1706 | { |
| 1707 | char buf_tmp[12]; |
| 1708 | |
| 1709 | if (len >= 12) |
| 1710 | { |
| 1711 | I("%s: no command exceeds 12 chars.\n", __func__); |
| 1712 | return -EFAULT; |
| 1713 | } |
| 1714 | if (copy_from_user(buf_tmp, buff, len)) |
| 1715 | { |
| 1716 | return -EFAULT; |
| 1717 | } |
| 1718 | #ifdef HX_RST_PIN_FUNC |
| 1719 | if (buf_tmp[0] == '1') |
| 1720 | himax_ic_reset(false,false); |
| 1721 | else if (buf_tmp[0] == '2') |
| 1722 | himax_ic_reset(false,true); |
| 1723 | else if (buf_tmp[0] == '3') |
| 1724 | himax_ic_reset(true,false); |
| 1725 | else if (buf_tmp[0] == '4') |
| 1726 | himax_ic_reset(true,true); |
| 1727 | //else if (buf_tmp[0] == '5') |
| 1728 | // ESD_HW_REST(); |
| 1729 | #endif |
| 1730 | return len; |
| 1731 | } |
| 1732 | |
| 1733 | static struct file_operations himax_proc_reset_ops = |
| 1734 | { |
| 1735 | .owner = THIS_MODULE, |
| 1736 | .write = himax_reset_write, |
| 1737 | }; |
| 1738 | #endif |
| 1739 | |
| 1740 | #ifdef HX_TP_PROC_DEBUG |
| 1741 | static ssize_t himax_debug_read(struct file *file, char *buf, |
| 1742 | size_t len, loff_t *pos) |
| 1743 | { |
| 1744 | size_t count = 0; |
| 1745 | char *temp_buf; |
| 1746 | |
| 1747 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 1748 | |
| 1749 | if(!HX_PROC_SEND_FLAG) |
| 1750 | { |
| 1751 | if (debug_level_cmd == 't') |
| 1752 | { |
| 1753 | if (fw_update_complete) |
| 1754 | { |
| 1755 | count += sprintf(temp_buf, "FW Update Complete "); |
| 1756 | } |
| 1757 | else |
| 1758 | { |
| 1759 | count += sprintf(temp_buf, "FW Update Fail "); |
| 1760 | } |
| 1761 | } |
| 1762 | else if (debug_level_cmd == 'h') |
| 1763 | { |
| 1764 | if (handshaking_result == 0) |
| 1765 | { |
| 1766 | count += sprintf(temp_buf, "Handshaking Result = %d (MCU Running)\n",handshaking_result); |
| 1767 | } |
| 1768 | else if (handshaking_result == 1) |
| 1769 | { |
| 1770 | count += sprintf(temp_buf, "Handshaking Result = %d (MCU Stop)\n",handshaking_result); |
| 1771 | } |
| 1772 | else if (handshaking_result == 2) |
| 1773 | { |
| 1774 | count += sprintf(temp_buf, "Handshaking Result = %d (I2C Error)\n",handshaking_result); |
| 1775 | } |
| 1776 | else |
| 1777 | { |
| 1778 | count += sprintf(temp_buf, "Handshaking Result = error \n"); |
| 1779 | } |
| 1780 | } |
| 1781 | else if (debug_level_cmd == 'v') |
| 1782 | { |
| 1783 | count += sprintf(temp_buf + count, "FW_VER = 0x%2.2X \n",ic_data->vendor_fw_ver); |
| 1784 | |
| 1785 | if(IC_TYPE < 8) |
| 1786 | count += sprintf(temp_buf + count, "CONFIG_VER = 0x%2.2X \n",ic_data->vendor_config_ver); |
| 1787 | else |
| 1788 | { |
| 1789 | count += sprintf(temp_buf + count, "TOUCH_VER = 0x%2.2X \n",ic_data->vendor_touch_cfg_ver); |
| 1790 | count += sprintf(temp_buf + count, "DISPLAY_VER = 0x%2.2X \n",ic_data->vendor_display_cfg_ver); |
| 1791 | } |
| 1792 | if(ic_data->vendor_cid_maj_ver < 0 && ic_data->vendor_cid_min_ver < 0) |
| 1793 | count += sprintf(temp_buf + count, "CID_VER = NULL\n"); |
| 1794 | else |
| 1795 | count += sprintf(temp_buf + count, "CID_VER = 0x%2.2X \n",(ic_data->vendor_cid_maj_ver << 8 | ic_data->vendor_cid_min_ver)); |
| 1796 | |
| 1797 | if(ic_data->vendor_panel_ver < 0) |
| 1798 | count += sprintf(temp_buf + count, "PANEL_VER = NULL\n"); |
| 1799 | else |
| 1800 | count += sprintf(temp_buf + count, "PANEL_VER = 0x%2.2X \n",ic_data->vendor_panel_ver); |
| 1801 | |
| 1802 | count += sprintf(temp_buf + count, "\n"); |
| 1803 | |
| 1804 | count += sprintf(temp_buf + count, "Himax Touch Driver Version:\n"); |
| 1805 | count += sprintf(temp_buf + count, "%s \n", HIMAX_DRIVER_VER); |
| 1806 | } |
| 1807 | else if (debug_level_cmd == 'd') |
| 1808 | { |
| 1809 | count += sprintf(temp_buf + count, "Himax Touch IC Information :\n"); |
| 1810 | switch(IC_TYPE) |
| 1811 | { |
| 1812 | case HX_85XX_D_SERIES_PWON: |
| 1813 | count += sprintf(temp_buf + count, "IC Type : HX852xD\n"); |
| 1814 | break; |
| 1815 | case HX_85XX_E_SERIES_PWON: |
| 1816 | count += sprintf(temp_buf + count, "IC Type : HX852xE\n"); |
| 1817 | break; |
| 1818 | case HX_85XX_ES_SERIES_PWON: |
| 1819 | count += sprintf(temp_buf + count, "IC Type : HX852xES\n"); |
| 1820 | break; |
| 1821 | case HX_85XX_F_SERIES_PWON: |
| 1822 | count += sprintf(temp_buf + count, "IC Type : HX852xF\n"); |
| 1823 | break; |
| 1824 | case HX_83100A_SERIES_PWON: |
| 1825 | count += sprintf(temp_buf + count, "IC Type : HX83100A\n"); |
| 1826 | break; |
| 1827 | case HX_83102A_SERIES_PWON: |
| 1828 | count += sprintf(temp_buf + count, "IC Type : HX83102A\n"); |
| 1829 | break; |
| 1830 | case HX_83102B_SERIES_PWON: |
| 1831 | count += sprintf(temp_buf + count, "IC Type : HX83102B\n"); |
| 1832 | break; |
| 1833 | case HX_83110A_SERIES_PWON: |
| 1834 | count += sprintf(temp_buf + count, "IC Type : HX83110A\n"); |
| 1835 | break; |
| 1836 | case HX_83110B_SERIES_PWON: |
| 1837 | count += sprintf(temp_buf + count, "IC Type : HX83110B\n"); |
| 1838 | break; |
| 1839 | case HX_83111B_SERIES_PWON: |
| 1840 | count += sprintf(temp_buf + count, "IC Type : HX83111B\n"); |
| 1841 | break; |
| 1842 | case HX_83112A_SERIES_PWON: |
| 1843 | count += sprintf(temp_buf + count, "IC Type : HX83112A\n"); |
| 1844 | break; |
| 1845 | case HX_83112B_SERIES_PWON: |
| 1846 | count += sprintf(temp_buf + count, "IC Type : HX83112B\n"); |
| 1847 | break; |
| 1848 | default: |
| 1849 | count += sprintf(temp_buf + count, "IC Type error.\n"); |
| 1850 | } |
| 1851 | switch(IC_CHECKSUM) |
| 1852 | { |
| 1853 | case HX_TP_BIN_CHECKSUM_SW: |
| 1854 | count += sprintf(temp_buf + count, "IC Checksum : SW\n"); |
| 1855 | break; |
| 1856 | case HX_TP_BIN_CHECKSUM_HW: |
| 1857 | count += sprintf(temp_buf + count, "IC Checksum : HW\n"); |
| 1858 | break; |
| 1859 | case HX_TP_BIN_CHECKSUM_CRC: |
| 1860 | count += sprintf(temp_buf + count, "IC Checksum : CRC\n"); |
| 1861 | break; |
| 1862 | default: |
| 1863 | count += sprintf(temp_buf + count, "IC Checksum error.\n"); |
| 1864 | } |
| 1865 | |
| 1866 | if (ic_data->HX_INT_IS_EDGE) |
| 1867 | { |
| 1868 | count += sprintf(temp_buf + count, "Driver register Interrupt : EDGE TIRGGER\n"); |
| 1869 | } |
| 1870 | else |
| 1871 | { |
| 1872 | count += sprintf(temp_buf + count, "Driver register Interrupt : LEVEL TRIGGER\n"); |
| 1873 | } |
| 1874 | if (private_ts->protocol_type == PROTOCOL_TYPE_A) |
| 1875 | { |
| 1876 | count += sprintf(temp_buf + count, "Protocol : TYPE_A\n"); |
| 1877 | } |
| 1878 | else |
| 1879 | { |
| 1880 | count += sprintf(temp_buf + count, "Protocol : TYPE_B\n"); |
| 1881 | } |
| 1882 | count += sprintf(temp_buf + count, "RX Num : %d\n",ic_data->HX_RX_NUM); |
| 1883 | count += sprintf(temp_buf + count, "TX Num : %d\n",ic_data->HX_TX_NUM); |
| 1884 | count += sprintf(temp_buf + count, "BT Num : %d\n",ic_data->HX_BT_NUM); |
| 1885 | count += sprintf(temp_buf + count, "X Resolution : %d\n",ic_data->HX_X_RES); |
| 1886 | count += sprintf(temp_buf + count, "Y Resolution : %d\n",ic_data->HX_Y_RES); |
| 1887 | count += sprintf(temp_buf + count, "Max Point : %d\n",ic_data->HX_MAX_PT); |
| 1888 | count += sprintf(temp_buf + count, "XY reverse : %d\n",ic_data->HX_XY_REVERSE); |
| 1889 | #ifdef HX_TP_PROC_2T2R |
| 1890 | if(Is_2T2R) |
| 1891 | { |
| 1892 | count += sprintf(temp_buf + count, "2T2R panel\n"); |
| 1893 | count += sprintf(temp_buf + count, "RX Num_2 : %d\n",HX_RX_NUM_2); |
| 1894 | count += sprintf(temp_buf + count, "TX Num_2 : %d\n",HX_TX_NUM_2); |
| 1895 | } |
| 1896 | #endif |
| 1897 | } |
| 1898 | else if (debug_level_cmd == 'i') |
| 1899 | { |
| 1900 | if(himax_read_i2c_status(private_ts->client)) |
| 1901 | count += sprintf(temp_buf + count, "I2C communication is bad.\n"); |
| 1902 | else |
| 1903 | count += sprintf(temp_buf + count, "I2C communication is good.\n"); |
| 1904 | } |
| 1905 | else if (debug_level_cmd == 'n') |
| 1906 | { |
| 1907 | if(himax_read_ic_trigger_type(private_ts->client) == 1) //Edgd = 1, Level = 0 |
| 1908 | count += sprintf(temp_buf + count, "IC Interrupt type is edge trigger.\n"); |
| 1909 | else if(himax_read_ic_trigger_type(private_ts->client) == 0) |
| 1910 | count += sprintf(temp_buf + count, "IC Interrupt type is level trigger.\n"); |
| 1911 | else |
| 1912 | count += sprintf(temp_buf + count, "Unkown IC trigger type.\n"); |
| 1913 | if (ic_data->HX_INT_IS_EDGE) |
| 1914 | count += sprintf(temp_buf + count, "Driver register Interrupt : EDGE TIRGGER\n"); |
| 1915 | else |
| 1916 | count += sprintf(temp_buf + count, "Driver register Interrupt : LEVEL TRIGGER\n"); |
| 1917 | } |
| 1918 | #if defined(HX_CHIP_STATUS_MONITOR) |
| 1919 | else if(debug_level_cmd=='c') |
| 1920 | { |
| 1921 | count += sprintf(temp_buf + count, "chip_monitor :%d\n", g_chip_monitor_data->HX_CHIP_MONITOR_EN); |
| 1922 | } |
| 1923 | #endif |
| 1924 | if(copy_to_user(buf, temp_buf, len)) |
| 1925 | I("%s,here:%d\n",__func__,__LINE__); |
| 1926 | kfree(temp_buf); |
| 1927 | HX_PROC_SEND_FLAG=1; |
| 1928 | } |
| 1929 | else |
| 1930 | HX_PROC_SEND_FLAG=0; |
| 1931 | return count; |
| 1932 | } |
| 1933 | |
| 1934 | static ssize_t himax_debug_write(struct file *file, const char *buff, |
| 1935 | size_t len, loff_t *pos) |
| 1936 | { |
| 1937 | struct file* filp = NULL; |
| 1938 | mm_segment_t oldfs; |
| 1939 | int result = 0; |
| 1940 | char fileName[128]; |
| 1941 | char buf[80] = {0}; |
| 1942 | int fw_type = 0; |
| 1943 | struct inode *inode; |
| 1944 | loff_t file_len = 0; |
| 1945 | |
| 1946 | if (len >= 80) |
| 1947 | { |
| 1948 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 1949 | return -EFAULT; |
| 1950 | } |
| 1951 | if (copy_from_user(buf, buff, len)) |
| 1952 | { |
| 1953 | return -EFAULT; |
| 1954 | } |
| 1955 | |
| 1956 | if ( buf[0] == 'h') //handshaking |
| 1957 | { |
| 1958 | debug_level_cmd = buf[0]; |
| 1959 | |
| 1960 | himax_int_enable(private_ts->client->irq,0); |
| 1961 | |
| 1962 | handshaking_result = himax_hand_shaking(private_ts->client); //0:Running, 1:Stop, 2:I2C Fail |
| 1963 | |
| 1964 | himax_int_enable(private_ts->client->irq,1); |
| 1965 | |
| 1966 | return len; |
| 1967 | } |
| 1968 | |
| 1969 | else if ( buf[0] == 'v') //firmware version |
| 1970 | { |
| 1971 | himax_int_enable(private_ts->client->irq,0); |
| 1972 | #ifdef HX_RST_PIN_FUNC |
| 1973 | himax_ic_reset(false,false); |
| 1974 | #endif |
| 1975 | debug_level_cmd = buf[0]; |
| 1976 | himax_read_FW_ver(private_ts->client); |
| 1977 | #ifdef HX_RST_PIN_FUNC |
| 1978 | himax_ic_reset(true,false); |
| 1979 | #endif |
| 1980 | himax_int_enable(private_ts->client->irq,1); |
| 1981 | //himax_check_chip_version(); |
| 1982 | return len; |
| 1983 | } |
| 1984 | |
| 1985 | else if ( buf[0] == 'd') //ic information |
| 1986 | { |
| 1987 | debug_level_cmd = buf[0]; |
| 1988 | return len; |
| 1989 | } |
| 1990 | |
| 1991 | else if (buf[0] == 't') |
| 1992 | { |
| 1993 | |
| 1994 | himax_int_enable(private_ts->client->irq,0); |
| 1995 | |
| 1996 | #ifdef HX_CHIP_STATUS_MONITOR |
| 1997 | g_chip_monitor_data->HX_CHIP_POLLING_COUNT = 0; |
| 1998 | g_chip_monitor_data->HX_CHIP_MONITOR_EN = 0; |
| 1999 | cancel_delayed_work_sync(&private_ts->himax_chip_monitor); |
| 2000 | #endif |
| 2001 | |
| 2002 | debug_level_cmd = buf[0]; |
| 2003 | fw_update_complete = false; |
| 2004 | |
| 2005 | memset(fileName, 0, 128); |
| 2006 | // parse the file name |
| 2007 | snprintf(fileName, len-2, "%s", &buf[2]); |
| 2008 | I("%s: upgrade from file(%s) start!\n", __func__, fileName); |
| 2009 | // open file |
| 2010 | filp = filp_open(fileName, O_RDONLY, 0); |
| 2011 | if (IS_ERR(filp)) |
| 2012 | { |
| 2013 | E("%s: open firmware file failed\n", __func__); |
| 2014 | goto firmware_upgrade_done; |
| 2015 | //return len; |
| 2016 | } |
| 2017 | inode = filp->f_inode; |
| 2018 | file_len = inode->i_size; |
| 2019 | oldfs = get_fs(); |
| 2020 | set_fs(get_ds()); |
| 2021 | |
| 2022 | // read the latest firmware binary file |
| 2023 | result=vfs_read(filp,upgrade_fw,file_len, &filp->f_pos); |
| 2024 | if (result < 0) |
| 2025 | { |
| 2026 | E("%s: read firmware file failed\n", __func__); |
| 2027 | goto firmware_upgrade_done; |
| 2028 | //return len; |
| 2029 | } |
| 2030 | |
| 2031 | set_fs(oldfs); |
| 2032 | filp_close(filp, NULL); |
| 2033 | |
| 2034 | I("%s: FW image,len %d: %02X, %02X, %02X, %02X\n", __func__, result, upgrade_fw[0], upgrade_fw[1], upgrade_fw[2], upgrade_fw[3]); |
| 2035 | |
| 2036 | if (result > 0) |
| 2037 | { |
| 2038 | fw_type = result/1024; |
| 2039 | // start to upgrade |
| 2040 | himax_int_enable(private_ts->client->irq,0); |
| 2041 | I("Now FW size is : %dk\n",fw_type); |
| 2042 | switch(fw_type) |
| 2043 | { |
| 2044 | case 32: |
| 2045 | if (fts_ctpm_fw_upgrade_with_sys_fs_32k(private_ts->client,upgrade_fw, result, false) == 0) |
| 2046 | { |
| 2047 | E("%s: TP upgrade error, line: %d\n", __func__, __LINE__); |
| 2048 | fw_update_complete = false; |
| 2049 | } |
| 2050 | else |
| 2051 | { |
| 2052 | I("%s: TP upgrade OK, line: %d\n", __func__, __LINE__); |
| 2053 | fw_update_complete = true; |
| 2054 | } |
| 2055 | break; |
| 2056 | case 60: |
| 2057 | if (fts_ctpm_fw_upgrade_with_sys_fs_60k(private_ts->client,upgrade_fw, result, false) == 0) |
| 2058 | { |
| 2059 | E("%s: TP upgrade error, line: %d\n", __func__, __LINE__); |
| 2060 | fw_update_complete = false; |
| 2061 | } |
| 2062 | else |
| 2063 | { |
| 2064 | I("%s: TP upgrade OK, line: %d\n", __func__, __LINE__); |
| 2065 | fw_update_complete = true; |
| 2066 | } |
| 2067 | break; |
| 2068 | case 64: |
| 2069 | if (fts_ctpm_fw_upgrade_with_sys_fs_64k(private_ts->client,upgrade_fw, result, false) == 0) |
| 2070 | { |
| 2071 | E("%s: TP upgrade error, line: %d\n", __func__, __LINE__); |
| 2072 | fw_update_complete = false; |
| 2073 | } |
| 2074 | else |
| 2075 | { |
| 2076 | I("%s: TP upgrade OK, line: %d\n", __func__, __LINE__); |
| 2077 | fw_update_complete = true; |
| 2078 | } |
| 2079 | break; |
| 2080 | case 124: |
| 2081 | if (fts_ctpm_fw_upgrade_with_sys_fs_124k(private_ts->client,upgrade_fw, result, false) == 0) |
| 2082 | { |
| 2083 | E("%s: TP upgrade error, line: %d\n", __func__, __LINE__); |
| 2084 | fw_update_complete = false; |
| 2085 | } |
| 2086 | else |
| 2087 | { |
| 2088 | I("%s: TP upgrade OK, line: %d\n", __func__, __LINE__); |
| 2089 | fw_update_complete = true; |
| 2090 | } |
| 2091 | break; |
| 2092 | case 128: |
| 2093 | if (fts_ctpm_fw_upgrade_with_sys_fs_128k(private_ts->client,upgrade_fw, result, false) == 0) |
| 2094 | { |
| 2095 | E("%s: TP upgrade error, line: %d\n", __func__, __LINE__); |
| 2096 | fw_update_complete = false; |
| 2097 | } |
| 2098 | else |
| 2099 | { |
| 2100 | I("%s: TP upgrade OK, line: %d\n", __func__, __LINE__); |
| 2101 | fw_update_complete = true; |
| 2102 | } |
| 2103 | break; |
| 2104 | default: |
| 2105 | E("%s: Flash command fail: %d\n", __func__, __LINE__); |
| 2106 | fw_update_complete = false; |
| 2107 | break; |
| 2108 | } |
| 2109 | goto firmware_upgrade_done; |
| 2110 | //return count; |
| 2111 | } |
| 2112 | } |
| 2113 | else if (buf[0] == 'i' && buf[1] == '2' && buf[2] == 'c') //i2c commutation |
| 2114 | { |
| 2115 | debug_level_cmd = 'i'; |
| 2116 | return len; |
| 2117 | } |
| 2118 | |
| 2119 | else if (buf[0] == 'i' && buf[1] == 'n' && buf[2] == 't') //INT trigger |
| 2120 | { |
| 2121 | debug_level_cmd = 'n'; |
| 2122 | return len; |
| 2123 | } |
| 2124 | #if defined(HX_CHIP_STATUS_MONITOR) |
| 2125 | else if(buf[0] == 'c') |
| 2126 | { |
| 2127 | debug_level_cmd = buf[0]; |
| 2128 | g_chip_monitor_data->HX_CHIP_POLLING_COUNT = 0; |
| 2129 | g_chip_monitor_data->HX_CHIP_MONITOR_EN = 0; |
| 2130 | cancel_delayed_work_sync(&private_ts->himax_chip_monitor); |
| 2131 | return len; |
| 2132 | } |
| 2133 | #endif |
| 2134 | #ifdef HX_ZERO_FLASH |
| 2135 | else if(buf[0] == 'z') |
| 2136 | { |
| 2137 | himax_0f_operation_check(); |
| 2138 | return len; |
| 2139 | } |
| 2140 | else if(buf[0] == 'p') |
| 2141 | { |
| 2142 | I("NOW debug echo r!\n"); |
| 2143 | //himax_program_sram(); |
| 2144 | private_ts->himax_0f_update_wq = create_singlethread_workqueue("HMX_update_0f_reuqest_write"); |
| 2145 | if (!private_ts->himax_0f_update_wq) |
| 2146 | E(" allocate syn_update_wq failed\n"); |
| 2147 | |
| 2148 | INIT_DELAYED_WORK(&private_ts->work_0f_update, himax_0f_operation); |
| 2149 | queue_delayed_work(private_ts->himax_0f_update_wq, &private_ts->work_0f_update, msecs_to_jiffies(100)); |
| 2150 | return len; |
| 2151 | } |
| 2152 | else if(buf[0] == 'x') |
| 2153 | { |
| 2154 | himax_sys_reset(); |
| 2155 | return len; |
| 2156 | } |
| 2157 | #endif |
| 2158 | /* others,do nothing */ |
| 2159 | else |
| 2160 | { |
| 2161 | debug_level_cmd = 0; |
| 2162 | return len; |
| 2163 | } |
| 2164 | |
| 2165 | firmware_upgrade_done: |
| 2166 | |
| 2167 | #ifdef HX_RST_PIN_FUNC |
| 2168 | himax_ic_reset(true,false); |
| 2169 | #endif |
| 2170 | himax_int_enable(private_ts->client->irq,1); |
| 2171 | |
| 2172 | #ifdef HX_CHIP_STATUS_MONITOR |
| 2173 | g_chip_monitor_data->HX_CHIP_POLLING_COUNT = 0; |
| 2174 | g_chip_monitor_data->HX_CHIP_MONITOR_EN = 1; |
| 2175 | queue_delayed_work(private_ts->himax_chip_monitor_wq, &private_ts->himax_chip_monitor, g_chip_monitor_data->HX_POLLING_TIMES*HZ); |
| 2176 | #endif |
| 2177 | |
| 2178 | //todo himax_chip->tp_firmware_upgrade_proceed = 0; |
| 2179 | //todo himax_chip->suspend_state = 0; |
| 2180 | //todo enable_irq(himax_chip->irq); |
| 2181 | return len; |
| 2182 | } |
| 2183 | |
| 2184 | static struct file_operations himax_proc_debug_ops = |
| 2185 | { |
| 2186 | .owner = THIS_MODULE, |
| 2187 | .read = himax_debug_read, |
| 2188 | .write = himax_debug_write, |
| 2189 | }; |
| 2190 | |
| 2191 | static ssize_t himax_proc_FW_debug_read(struct file *file, char *buf, |
| 2192 | size_t len, loff_t *pos) |
| 2193 | { |
| 2194 | int ret = 0; |
| 2195 | uint8_t loop_i = 0; |
| 2196 | uint8_t tmp_data[64]; |
| 2197 | char *temp_buf; |
| 2198 | |
| 2199 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 2200 | |
| 2201 | if(!HX_PROC_SEND_FLAG) |
| 2202 | { |
| 2203 | cmd_set[0] = 0x01; |
| 2204 | if(himax_read_FW_status(cmd_set, tmp_data) == NO_ERR) |
| 2205 | { |
| 2206 | ret += sprintf(temp_buf + ret, "0x%02X%02X%02X%02X :\t",cmd_set[5],cmd_set[4],cmd_set[3],cmd_set[2]); |
| 2207 | for (loop_i = 0; loop_i < cmd_set[1]; loop_i++) |
| 2208 | { |
| 2209 | ret += sprintf(temp_buf+ ret, "%5d\t", tmp_data[loop_i]); |
| 2210 | } |
| 2211 | ret += sprintf(temp_buf + ret, "\n"); |
| 2212 | } |
| 2213 | cmd_set[0] = 0x02; |
| 2214 | if(himax_read_FW_status(cmd_set, tmp_data) == NO_ERR) |
| 2215 | { |
| 2216 | for (loop_i = 0; loop_i < cmd_set[1]; loop_i = loop_i + 2) |
| 2217 | { |
| 2218 | if ((loop_i % 16) == 0) |
| 2219 | ret += sprintf(temp_buf + ret, "0x%02X%02X%02X%02X :\t", |
| 2220 | cmd_set[5],cmd_set[4],cmd_set[3]+(((cmd_set[2]+ loop_i)>>8)&0xFF), (cmd_set[2] + loop_i)&0xFF); |
| 2221 | ret += sprintf(temp_buf + ret, "%5d\t", tmp_data[loop_i] + (tmp_data[loop_i + 1] << 8)); |
| 2222 | if ((loop_i % 16) == 14) |
| 2223 | ret += sprintf(temp_buf + ret, "\n"); |
| 2224 | } |
| 2225 | |
| 2226 | } |
| 2227 | ret += sprintf(temp_buf + ret, "\n"); |
| 2228 | if(copy_to_user(buf, temp_buf, len)) |
| 2229 | I("%s,here:%d\n",__func__,__LINE__); |
| 2230 | kfree(temp_buf); |
| 2231 | HX_PROC_SEND_FLAG=1; |
| 2232 | } |
| 2233 | else |
| 2234 | HX_PROC_SEND_FLAG=0; |
| 2235 | return ret; |
| 2236 | } |
| 2237 | |
| 2238 | static struct file_operations himax_proc_fw_debug_ops = |
| 2239 | { |
| 2240 | .owner = THIS_MODULE, |
| 2241 | .read = himax_proc_FW_debug_read, |
| 2242 | }; |
| 2243 | |
| 2244 | static ssize_t himax_proc_DD_debug_read(struct file *file, char *buf, |
| 2245 | size_t len, loff_t *pos) |
| 2246 | { |
| 2247 | int ret = 0; |
| 2248 | uint8_t tmp_data[64]; |
| 2249 | uint8_t loop_i = 0; |
| 2250 | char *temp_buf; |
| 2251 | |
| 2252 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 2253 | |
| 2254 | if(!HX_PROC_SEND_FLAG) |
| 2255 | { |
| 2256 | if(mutual_set_flag == 1) |
| 2257 | { |
| 2258 | if(himax_read_DD_status(cmd_set, tmp_data) == NO_ERR) |
| 2259 | { |
| 2260 | for (loop_i = 0; loop_i < cmd_set[0]; loop_i++) |
| 2261 | { |
| 2262 | if ((loop_i % 8) == 0) |
| 2263 | ret += sprintf(temp_buf + ret, "0x%02X : ", loop_i); |
| 2264 | ret += sprintf(temp_buf + ret, "0x%02X ", tmp_data[loop_i]); |
| 2265 | if ((loop_i % 8) == 7) |
| 2266 | ret += sprintf(temp_buf + ret, "\n"); |
| 2267 | } |
| 2268 | } |
| 2269 | } |
| 2270 | //else |
| 2271 | ret += sprintf(temp_buf + ret, "\n"); |
| 2272 | if(copy_to_user(buf, temp_buf, len)) |
| 2273 | I("%s,here:%d\n",__func__,__LINE__); |
| 2274 | kfree(temp_buf); |
| 2275 | HX_PROC_SEND_FLAG=1; |
| 2276 | } |
| 2277 | else |
| 2278 | HX_PROC_SEND_FLAG=0; |
| 2279 | return ret; |
| 2280 | } |
| 2281 | |
| 2282 | static ssize_t himax_proc_DD_debug_write(struct file *file, const char *buff, |
| 2283 | size_t len, loff_t *pos) |
| 2284 | { |
| 2285 | uint8_t i = 0; |
| 2286 | uint8_t cnt = 2; |
| 2287 | unsigned long result = 0; |
| 2288 | char buf_tmp[20]; |
| 2289 | char buf_tmp2[4]; |
| 2290 | |
| 2291 | if (len >= 20) |
| 2292 | { |
| 2293 | I("%s: no command exceeds 20 chars.\n", __func__); |
| 2294 | return -EFAULT; |
| 2295 | } |
| 2296 | if (copy_from_user(buf_tmp, buff, len)) |
| 2297 | { |
| 2298 | return -EFAULT; |
| 2299 | } |
| 2300 | memset(buf_tmp2, 0x0, sizeof(buf_tmp2)); |
| 2301 | |
| 2302 | if (buf_tmp[2] == 'x' && buf_tmp[6] == 'x' && buf_tmp[10] == 'x') |
| 2303 | { |
| 2304 | mutual_set_flag = 1; |
| 2305 | for (i = 3; i < 12; i = i + 4) |
| 2306 | { |
| 2307 | memcpy(buf_tmp2, buf_tmp + i, 2); |
| 2308 | if (!kstrtoul(buf_tmp2, 16, &result)) |
| 2309 | cmd_set[cnt] = (uint8_t)result; |
| 2310 | else |
| 2311 | I("String to oul is fail in cnt = %d, buf_tmp2 = %s",cnt, buf_tmp2); |
| 2312 | cnt--; |
| 2313 | } |
| 2314 | I("cmd_set[2] = %02X, cmd_set[1] = %02X, cmd_set[0] = %02X\n",cmd_set[2],cmd_set[1],cmd_set[0]); |
| 2315 | } |
| 2316 | else |
| 2317 | mutual_set_flag = 0; |
| 2318 | |
| 2319 | return len; |
| 2320 | } |
| 2321 | |
| 2322 | static struct file_operations himax_proc_dd_debug_ops = |
| 2323 | { |
| 2324 | .owner = THIS_MODULE, |
| 2325 | .read = himax_proc_DD_debug_read, |
| 2326 | .write = himax_proc_DD_debug_write, |
| 2327 | }; |
| 2328 | |
| 2329 | #endif |
| 2330 | |
| 2331 | #ifdef HX_TP_PROC_FLASH_DUMP |
| 2332 | |
| 2333 | uint8_t getFlashCommand(void) |
| 2334 | { |
| 2335 | return flash_command; |
| 2336 | } |
| 2337 | |
| 2338 | static uint8_t getFlashDumpProgress(void) |
| 2339 | { |
| 2340 | return flash_progress; |
| 2341 | } |
| 2342 | |
| 2343 | static uint8_t getFlashDumpComplete(void) |
| 2344 | { |
| 2345 | return flash_dump_complete; |
| 2346 | } |
| 2347 | |
| 2348 | static uint8_t getFlashDumpFail(void) |
| 2349 | { |
| 2350 | return flash_dump_fail; |
| 2351 | } |
| 2352 | |
| 2353 | uint8_t getSysOperation(void) |
| 2354 | { |
| 2355 | return sys_operation; |
| 2356 | } |
| 2357 | |
| 2358 | static uint8_t getFlashReadStep(void) |
| 2359 | { |
| 2360 | return flash_read_step; |
| 2361 | } |
| 2362 | |
| 2363 | bool getFlashDumpGoing(void) |
| 2364 | { |
| 2365 | return flash_dump_going; |
| 2366 | } |
| 2367 | |
| 2368 | void setFlashBuffer(void) |
| 2369 | { |
| 2370 | flash_buffer = kzalloc(Flash_Size * sizeof(uint8_t), GFP_KERNEL); |
| 2371 | memset(flash_buffer,0x00,Flash_Size); |
| 2372 | } |
| 2373 | |
| 2374 | void setSysOperation(uint8_t operation) |
| 2375 | { |
| 2376 | sys_operation = operation; |
| 2377 | } |
| 2378 | |
| 2379 | void setFlashDumpProgress(uint8_t progress) |
| 2380 | { |
| 2381 | flash_progress = progress; |
| 2382 | //I("setFlashDumpProgress : progress = %d ,flash_progress = %d \n",progress,flash_progress); |
| 2383 | } |
| 2384 | |
| 2385 | void setFlashDumpComplete(uint8_t status) |
| 2386 | { |
| 2387 | flash_dump_complete = status; |
| 2388 | } |
| 2389 | |
| 2390 | void setFlashDumpFail(uint8_t fail) |
| 2391 | { |
| 2392 | flash_dump_fail = fail; |
| 2393 | } |
| 2394 | |
| 2395 | static void setFlashCommand(uint8_t command) |
| 2396 | { |
| 2397 | flash_command = command; |
| 2398 | } |
| 2399 | |
| 2400 | static void setFlashReadStep(uint8_t step) |
| 2401 | { |
| 2402 | flash_read_step = step; |
| 2403 | } |
| 2404 | |
| 2405 | void setFlashDumpGoing(bool going) |
| 2406 | { |
| 2407 | flash_dump_going = going; |
| 2408 | } |
| 2409 | |
| 2410 | static ssize_t himax_proc_flash_read(struct file *file, char *buf, |
| 2411 | size_t len, loff_t *pos) |
| 2412 | { |
| 2413 | int ret = 0; |
| 2414 | int loop_i; |
| 2415 | uint8_t local_flash_read_step=0; |
| 2416 | uint8_t local_flash_complete = 0; |
| 2417 | uint8_t local_flash_progress = 0; |
| 2418 | uint8_t local_flash_command = 0; |
| 2419 | uint8_t local_flash_fail = 0; |
| 2420 | char *temp_buf; |
| 2421 | |
| 2422 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 2423 | |
| 2424 | local_flash_complete = getFlashDumpComplete(); |
| 2425 | local_flash_progress = getFlashDumpProgress(); |
| 2426 | local_flash_command = getFlashCommand(); |
| 2427 | local_flash_fail = getFlashDumpFail(); |
| 2428 | |
| 2429 | I("flash_progress = %d \n",local_flash_progress); |
| 2430 | if(!HX_PROC_SEND_FLAG) |
| 2431 | { |
| 2432 | if (local_flash_fail) |
| 2433 | { |
| 2434 | ret += sprintf(temp_buf + ret, "FlashStart:Fail \n"); |
| 2435 | ret += sprintf(temp_buf + ret, "FlashEnd"); |
| 2436 | ret += sprintf(temp_buf + ret, "\n"); |
| 2437 | if(copy_to_user(buf, temp_buf, len)) |
| 2438 | I("%s,here:%d\n",__func__,__LINE__); |
| 2439 | kfree(temp_buf); |
| 2440 | HX_PROC_SEND_FLAG=1; |
| 2441 | return ret; |
| 2442 | } |
| 2443 | |
| 2444 | if (!local_flash_complete) |
| 2445 | { |
| 2446 | ret += sprintf(temp_buf + ret, "FlashStart:Ongoing:0x%2.2x \n",flash_progress); |
| 2447 | ret += sprintf(temp_buf + ret, "FlashEnd"); |
| 2448 | ret += sprintf(temp_buf + ret, "\n"); |
| 2449 | if(copy_to_user(buf, temp_buf, len)) |
| 2450 | I("%s,here:%d\n",__func__,__LINE__); |
| 2451 | kfree(temp_buf); |
| 2452 | HX_PROC_SEND_FLAG=1; |
| 2453 | return ret; |
| 2454 | } |
| 2455 | |
| 2456 | if (local_flash_command == 1 && local_flash_complete) |
| 2457 | { |
| 2458 | ret += sprintf(temp_buf + ret, "FlashStart:Complete \n"); |
| 2459 | ret += sprintf(temp_buf + ret, "FlashEnd"); |
| 2460 | ret += sprintf(temp_buf + ret, "\n"); |
| 2461 | if(copy_to_user(buf, temp_buf, len)) |
| 2462 | I("%s,here:%d\n",__func__,__LINE__); |
| 2463 | kfree(temp_buf); |
| 2464 | HX_PROC_SEND_FLAG=1; |
| 2465 | return ret; |
| 2466 | } |
| 2467 | |
| 2468 | if (local_flash_command == 3 && local_flash_complete) |
| 2469 | { |
| 2470 | ret += sprintf(temp_buf + ret, "FlashStart: \n"); |
| 2471 | for(loop_i = 0; loop_i < 128; loop_i++) |
| 2472 | { |
| 2473 | ret += sprintf(temp_buf + ret, "x%2.2x", flash_buffer[loop_i]); |
| 2474 | if ((loop_i % 16) == 15) |
| 2475 | { |
| 2476 | ret += sprintf(temp_buf + ret, "\n"); |
| 2477 | } |
| 2478 | } |
| 2479 | ret += sprintf(temp_buf + ret, "FlashEnd"); |
| 2480 | ret += sprintf(temp_buf + ret, "\n"); |
| 2481 | if(copy_to_user(buf, temp_buf, len)) |
| 2482 | I("%s,here:%d\n",__func__,__LINE__); |
| 2483 | kfree(temp_buf); |
| 2484 | HX_PROC_SEND_FLAG=1; |
| 2485 | return ret; |
| 2486 | } |
| 2487 | |
| 2488 | //flash command == 0 , report the data |
| 2489 | local_flash_read_step = getFlashReadStep(); |
| 2490 | |
| 2491 | ret += sprintf(temp_buf + ret, "FlashStart:%2.2x \n",local_flash_read_step); |
| 2492 | |
| 2493 | for (loop_i = 0; loop_i < 1024; loop_i++) |
| 2494 | { |
| 2495 | ret += sprintf(temp_buf + ret, "x%2.2X", flash_buffer[local_flash_read_step*1024 + loop_i]); |
| 2496 | |
| 2497 | if ((loop_i % 16) == 15) |
| 2498 | { |
| 2499 | ret += sprintf(temp_buf + ret, "\n"); |
| 2500 | } |
| 2501 | } |
| 2502 | |
| 2503 | ret += sprintf(temp_buf + ret, "FlashEnd"); |
| 2504 | ret += sprintf(temp_buf + ret, "\n"); |
| 2505 | if(copy_to_user(buf, temp_buf, len)) |
| 2506 | I("%s,here:%d\n",__func__,__LINE__); |
| 2507 | kfree(temp_buf); |
| 2508 | HX_PROC_SEND_FLAG=1; |
| 2509 | } |
| 2510 | else |
| 2511 | HX_PROC_SEND_FLAG=0; |
| 2512 | return ret; |
| 2513 | } |
| 2514 | |
| 2515 | static ssize_t himax_proc_flash_write(struct file *file, const char *buff, |
| 2516 | size_t len, loff_t *pos) |
| 2517 | { |
| 2518 | char buf_tmp[6]; |
| 2519 | unsigned long result = 0; |
| 2520 | char buf[80] = {0}; |
| 2521 | |
| 2522 | if (len >= 80) |
| 2523 | { |
| 2524 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 2525 | return -EFAULT; |
| 2526 | } |
| 2527 | if (copy_from_user(buf, buff, len)) |
| 2528 | { |
| 2529 | return -EFAULT; |
| 2530 | } |
| 2531 | memset(buf_tmp, 0x0, sizeof(buf_tmp)); |
| 2532 | |
| 2533 | I("%s: buf = %s\n", __func__, buf); |
| 2534 | |
| 2535 | if (getSysOperation() == 1) |
| 2536 | { |
| 2537 | E("%s: PROC is busy , return!\n", __func__); |
| 2538 | return len; |
| 2539 | } |
| 2540 | |
| 2541 | if (buf[0] == '0') |
| 2542 | { |
| 2543 | setFlashCommand(0); |
| 2544 | if (buf[1] == ':' && buf[2] == 'x') |
| 2545 | { |
| 2546 | memcpy(buf_tmp, buf + 3, 2); |
| 2547 | I("%s: read_Step = %s\n", __func__, buf_tmp); |
| 2548 | if (!kstrtoul(buf_tmp, 16, &result)) |
| 2549 | { |
| 2550 | I("%s: read_Step = %lu \n", __func__, result); |
| 2551 | setFlashReadStep(result); |
| 2552 | } |
| 2553 | } |
| 2554 | } |
| 2555 | else if (buf[0] == '1')// 1_32,1_60,1_64,1_24,1_28 for flash size 32k,60k,64k,124k,128k |
| 2556 | { |
| 2557 | setSysOperation(1); |
| 2558 | setFlashCommand(1); |
| 2559 | setFlashDumpProgress(0); |
| 2560 | setFlashDumpComplete(0); |
| 2561 | setFlashDumpFail(0); |
| 2562 | if ((buf[1] == '_' ) && (buf[2] == '3' ) && (buf[3] == '2' )) |
| 2563 | { |
| 2564 | Flash_Size = FW_SIZE_32k; |
| 2565 | } |
| 2566 | else if ((buf[1] == '_' ) && (buf[2] == '6' )) |
| 2567 | { |
| 2568 | if (buf[3] == '0') |
| 2569 | { |
| 2570 | Flash_Size = FW_SIZE_60k; |
| 2571 | } |
| 2572 | else if (buf[3] == '4') |
| 2573 | { |
| 2574 | Flash_Size = FW_SIZE_64k; |
| 2575 | } |
| 2576 | } |
| 2577 | else if ((buf[1] == '_' ) && (buf[2] == '2' )) |
| 2578 | { |
| 2579 | if (buf[3] == '4') |
| 2580 | { |
| 2581 | Flash_Size = FW_SIZE_124k; |
| 2582 | } |
| 2583 | else if (buf[3] == '8') |
| 2584 | { |
| 2585 | Flash_Size = FW_SIZE_128k; |
| 2586 | } |
| 2587 | } |
| 2588 | queue_work(private_ts->flash_wq, &private_ts->flash_work); |
| 2589 | } |
| 2590 | else if (buf[0] == '2') // 2_32,2_60,2_64,2_24,2_28 for flash size 32k,60k,64k,124k,128k |
| 2591 | { |
| 2592 | setSysOperation(1); |
| 2593 | setFlashCommand(2); |
| 2594 | setFlashDumpProgress(0); |
| 2595 | setFlashDumpComplete(0); |
| 2596 | setFlashDumpFail(0); |
| 2597 | if ((buf[1] == '_' ) && (buf[2] == '3' ) && (buf[3] == '2' )) |
| 2598 | { |
| 2599 | Flash_Size = FW_SIZE_32k; |
| 2600 | } |
| 2601 | else if ((buf[1] == '_' ) && (buf[2] == '6' )) |
| 2602 | { |
| 2603 | if (buf[3] == '0') |
| 2604 | { |
| 2605 | Flash_Size = FW_SIZE_60k; |
| 2606 | } |
| 2607 | else if (buf[3] == '4') |
| 2608 | { |
| 2609 | Flash_Size = FW_SIZE_64k; |
| 2610 | } |
| 2611 | } |
| 2612 | else if ((buf[1] == '_' ) && (buf[2] == '2' )) |
| 2613 | { |
| 2614 | if (buf[3] == '4') |
| 2615 | { |
| 2616 | Flash_Size = FW_SIZE_124k; |
| 2617 | } |
| 2618 | else if (buf[3] == '8') |
| 2619 | { |
| 2620 | Flash_Size = FW_SIZE_128k; |
| 2621 | } |
| 2622 | } |
| 2623 | queue_work(private_ts->flash_wq, &private_ts->flash_work); |
| 2624 | } |
| 2625 | return len; |
| 2626 | } |
| 2627 | |
| 2628 | static struct file_operations himax_proc_flash_ops = |
| 2629 | { |
| 2630 | .owner = THIS_MODULE, |
| 2631 | .read = himax_proc_flash_read, |
| 2632 | .write = himax_proc_flash_write, |
| 2633 | }; |
| 2634 | |
| 2635 | void himax_ts_flash_func(void) |
| 2636 | { |
| 2637 | uint8_t local_flash_command = 0; |
| 2638 | |
| 2639 | himax_int_enable(private_ts->client->irq,0); |
| 2640 | setFlashDumpGoing(true); |
| 2641 | |
| 2642 | //sector = getFlashDumpSector(); |
| 2643 | //page = getFlashDumpPage(); |
| 2644 | |
| 2645 | local_flash_command = getFlashCommand(); |
| 2646 | |
| 2647 | msleep(100); |
| 2648 | |
| 2649 | I("%s: local_flash_command = %d enter.\n", __func__,local_flash_command); |
| 2650 | |
| 2651 | if ((local_flash_command == 1 || local_flash_command == 2)|| (local_flash_command==0x0F)) |
| 2652 | { |
| 2653 | himax_flash_dump_func(private_ts->client, local_flash_command,Flash_Size, flash_buffer); |
| 2654 | } |
| 2655 | |
| 2656 | I("Complete~~~~~~~~~~~~~~~~~~~~~~~\n"); |
| 2657 | |
| 2658 | if (local_flash_command == 2) |
| 2659 | { |
| 2660 | struct file *fn; |
| 2661 | |
| 2662 | fn = filp_open(FLASH_DUMP_FILE,O_CREAT | O_WRONLY,0); |
| 2663 | if (!IS_ERR(fn)) |
| 2664 | { |
| 2665 | I("%s create file and ready to write\n",__func__); |
| 2666 | fn->f_op->write(fn,flash_buffer,Flash_Size*sizeof(uint8_t),&fn->f_pos); |
| 2667 | filp_close(fn,NULL); |
| 2668 | } |
| 2669 | } |
| 2670 | |
| 2671 | himax_int_enable(private_ts->client->irq,1); |
| 2672 | setFlashDumpGoing(false); |
| 2673 | |
| 2674 | setFlashDumpComplete(1); |
| 2675 | setSysOperation(0); |
| 2676 | return; |
| 2677 | |
| 2678 | /* Flash_Dump_i2c_transfer_error: |
| 2679 | |
| 2680 | himax_int_enable(private_ts->client->irq,1); |
| 2681 | setFlashDumpGoing(false); |
| 2682 | setFlashDumpComplete(0); |
| 2683 | setFlashDumpFail(1); |
| 2684 | setSysOperation(0); |
| 2685 | return; |
| 2686 | */ |
| 2687 | } |
| 2688 | |
| 2689 | #endif |
| 2690 | |
| 2691 | #ifdef HX_TP_PROC_SELF_TEST |
| 2692 | static ssize_t himax_self_test_read(struct file *file, char *buf, |
| 2693 | size_t len, loff_t *pos) |
| 2694 | { |
| 2695 | int val=0x00; |
| 2696 | int ret = 0; |
| 2697 | char *temp_buf; |
| 2698 | |
| 2699 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 2700 | I("%s: enter, %d \n", __func__, __LINE__); |
| 2701 | if(!HX_PROC_SEND_FLAG) |
| 2702 | { |
| 2703 | himax_int_enable(private_ts->client->irq,0);//disable irq |
| 2704 | g_self_test_entered = 1; |
| 2705 | val = himax_chip_self_test(private_ts->client); |
| 2706 | #ifdef HX_ESD_RECOVERY |
| 2707 | HX_ESD_RESET_ACTIVATE = 1; |
| 2708 | #endif |
| 2709 | himax_int_enable(private_ts->client->irq,1);//enable irq |
| 2710 | |
| 2711 | if (val == 0x01) |
| 2712 | { |
| 2713 | ret += sprintf(temp_buf + ret, "Self_Test Pass\n"); |
| 2714 | } |
| 2715 | else |
| 2716 | { |
| 2717 | ret += sprintf(temp_buf + ret, "Self_Test Fail\n"); |
| 2718 | } |
| 2719 | g_self_test_entered = 0; |
| 2720 | if(copy_to_user(buf, temp_buf, len)) |
| 2721 | I("%s,here:%d\n",__func__,__LINE__); |
| 2722 | kfree(temp_buf); |
| 2723 | HX_PROC_SEND_FLAG=1; |
| 2724 | } |
| 2725 | else |
| 2726 | HX_PROC_SEND_FLAG=0; |
| 2727 | return ret; |
| 2728 | } |
| 2729 | |
| 2730 | /* |
| 2731 | static ssize_t himax_chip_self_test_store(struct device *dev,struct device_attribute *attr, const char *buf, size_t count) |
| 2732 | { |
| 2733 | char buf_tmp[2]; |
| 2734 | unsigned long result = 0; |
| 2735 | |
| 2736 | memset(buf_tmp, 0x0, sizeof(buf_tmp)); |
| 2737 | memcpy(buf_tmp, buf, 2); |
| 2738 | if(!kstrtoul(buf_tmp, 16, &result)) |
| 2739 | { |
| 2740 | sel_type = (uint8_t)result; |
| 2741 | } |
| 2742 | I("sel_type = %x \r\n", sel_type); |
| 2743 | return count; |
| 2744 | } |
| 2745 | */ |
| 2746 | |
| 2747 | static struct file_operations himax_proc_self_test_ops = |
| 2748 | { |
| 2749 | .owner = THIS_MODULE, |
| 2750 | .read = himax_self_test_read, |
| 2751 | }; |
| 2752 | #endif |
| 2753 | |
| 2754 | #ifdef HX_TP_PROC_SENSE_ON_OFF |
| 2755 | static ssize_t himax_sense_on_off_write(struct file *file, const char *buff, |
| 2756 | size_t len, loff_t *pos) |
| 2757 | { |
| 2758 | char buf[80] = {0}; |
| 2759 | |
| 2760 | if (len >= 80) |
| 2761 | { |
| 2762 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 2763 | return -EFAULT; |
| 2764 | } |
| 2765 | if (copy_from_user(buf, buff, len)) |
| 2766 | { |
| 2767 | return -EFAULT; |
| 2768 | } |
| 2769 | |
| 2770 | if(buf[0] == '0') |
| 2771 | { |
| 2772 | himax_sense_off(private_ts->client); |
| 2773 | I("Sense off \n"); |
| 2774 | } |
| 2775 | else if(buf[0] == '1') |
| 2776 | { |
| 2777 | if(buf[1] == 's') |
| 2778 | { |
| 2779 | himax_sense_on(private_ts->client, 0x00); |
| 2780 | I("Sense on re-map on, run sram \n"); |
| 2781 | } |
| 2782 | else |
| 2783 | { |
| 2784 | himax_sense_on(private_ts->client, 0x01); |
| 2785 | I("Sense on re-map off, run flash \n"); |
| 2786 | } |
| 2787 | } |
| 2788 | else |
| 2789 | { |
| 2790 | I("Do nothing \n"); |
| 2791 | } |
| 2792 | return len; |
| 2793 | } |
| 2794 | |
| 2795 | static struct file_operations himax_proc_sense_on_off_ops = |
| 2796 | { |
| 2797 | .owner = THIS_MODULE, |
| 2798 | .write = himax_sense_on_off_write, |
| 2799 | }; |
| 2800 | #endif |
| 2801 | |
| 2802 | #ifdef HX_HIGH_SENSE |
| 2803 | static ssize_t himax_HSEN_read(struct file *file, char *buf, |
| 2804 | size_t len, loff_t *pos) |
| 2805 | { |
| 2806 | struct himax_ts_data *ts = private_ts; |
| 2807 | size_t count = 0; |
| 2808 | char *temp_buf; |
| 2809 | |
| 2810 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 2811 | |
| 2812 | if(!HX_PROC_SEND_FLAG) |
| 2813 | { |
| 2814 | count = snprintf(temp_buf, PAGE_SIZE, "%d\n", ts->HSEN_enable); |
| 2815 | if(copy_to_user(buf, temp_buf, len)) |
| 2816 | I("%s,here:%d\n",__func__,__LINE__); |
| 2817 | kfree(temp_buf); |
| 2818 | HX_PROC_SEND_FLAG=1; |
| 2819 | } |
| 2820 | else |
| 2821 | HX_PROC_SEND_FLAG=0; |
| 2822 | return count; |
| 2823 | } |
| 2824 | |
| 2825 | static ssize_t himax_HSEN_write(struct file *file, const char *buff, |
| 2826 | size_t len, loff_t *pos) |
| 2827 | { |
| 2828 | struct himax_ts_data *ts = private_ts; |
| 2829 | char buf[80] = {0}; |
| 2830 | |
| 2831 | |
| 2832 | if (len >= 80) |
| 2833 | { |
| 2834 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 2835 | return -EFAULT; |
| 2836 | } |
| 2837 | if (copy_from_user(buf, buff, len)) |
| 2838 | { |
| 2839 | return -EFAULT; |
| 2840 | } |
| 2841 | |
| 2842 | if (buf[0] == '0') |
| 2843 | { |
| 2844 | ts->HSEN_enable = 0; |
| 2845 | } |
| 2846 | else if (buf[0] == '1') |
| 2847 | { |
| 2848 | ts->HSEN_enable = 1; |
| 2849 | } |
| 2850 | else |
| 2851 | return -EINVAL; |
| 2852 | |
| 2853 | himax_set_HSEN_enable(ts->client, ts->HSEN_enable, ts->suspended); |
| 2854 | |
| 2855 | I("%s: HSEN_enable = %d.\n", __func__, ts->HSEN_enable); |
| 2856 | |
| 2857 | return len; |
| 2858 | } |
| 2859 | |
| 2860 | static struct file_operations himax_proc_HSEN_ops = |
| 2861 | { |
| 2862 | .owner = THIS_MODULE, |
| 2863 | .read = himax_HSEN_read, |
| 2864 | .write = himax_HSEN_write, |
| 2865 | }; |
| 2866 | #endif |
| 2867 | |
| 2868 | #ifdef HX_SMART_WAKEUP |
| 2869 | static ssize_t himax_SMWP_read(struct file *file, char *buf, |
| 2870 | size_t len, loff_t *pos) |
| 2871 | { |
| 2872 | size_t count = 0; |
| 2873 | struct himax_ts_data *ts = private_ts; |
| 2874 | |
| 2875 | char *temp_buf; |
| 2876 | |
| 2877 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 2878 | |
| 2879 | if(!HX_PROC_SEND_FLAG) |
| 2880 | { |
| 2881 | count = snprintf(temp_buf, PAGE_SIZE, "%d\n", ts->SMWP_enable); |
| 2882 | if(copy_to_user(buf, temp_buf, len)) |
| 2883 | I("%s,here:%d\n",__func__,__LINE__); |
| 2884 | kfree(temp_buf); |
| 2885 | HX_PROC_SEND_FLAG=1; |
| 2886 | } |
| 2887 | else |
| 2888 | HX_PROC_SEND_FLAG=0; |
| 2889 | |
| 2890 | return count; |
| 2891 | } |
| 2892 | |
| 2893 | static ssize_t himax_SMWP_write(struct file *file, const char *buff, |
| 2894 | size_t len, loff_t *pos) |
| 2895 | { |
| 2896 | struct himax_ts_data *ts = private_ts; |
| 2897 | char buf[80] = {0}; |
| 2898 | |
| 2899 | if (len >= 80) |
| 2900 | { |
| 2901 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 2902 | return -EFAULT; |
| 2903 | } |
| 2904 | if (copy_from_user(buf, buff, len)) |
| 2905 | { |
| 2906 | return -EFAULT; |
| 2907 | } |
| 2908 | |
| 2909 | |
| 2910 | if (buf[0] == '0') |
| 2911 | { |
| 2912 | ts->SMWP_enable = 0; |
| 2913 | } |
| 2914 | else if (buf[0] == '1') |
| 2915 | { |
| 2916 | ts->SMWP_enable = 1; |
| 2917 | } |
| 2918 | else |
| 2919 | return -EINVAL; |
| 2920 | |
| 2921 | himax_set_SMWP_enable(ts->client, ts->SMWP_enable, ts->suspended); |
| 2922 | |
| 2923 | HX_SMWP_EN = ts->SMWP_enable; |
| 2924 | I("%s: SMART_WAKEUP_enable = %d.\n", __func__, HX_SMWP_EN); |
| 2925 | |
| 2926 | return len; |
| 2927 | } |
| 2928 | |
| 2929 | static struct file_operations himax_proc_SMWP_ops = |
| 2930 | { |
| 2931 | .owner = THIS_MODULE, |
| 2932 | .read = himax_SMWP_read, |
| 2933 | .write = himax_SMWP_write, |
| 2934 | }; |
| 2935 | |
| 2936 | static ssize_t himax_GESTURE_read(struct file *file, char *buf, |
| 2937 | size_t len, loff_t *pos) |
| 2938 | { |
| 2939 | struct himax_ts_data *ts = private_ts; |
| 2940 | int i =0; |
| 2941 | int ret = 0; |
| 2942 | char *temp_buf; |
| 2943 | |
| 2944 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 2945 | if(!HX_PROC_SEND_FLAG) |
| 2946 | { |
| 2947 | for(i=0; i<16; i++) |
| 2948 | ret += sprintf(temp_buf + ret, "ges_en[%d]=%d \n",i,ts->gesture_cust_en[i]); |
| 2949 | if(copy_to_user(buf, temp_buf, len)) |
| 2950 | I("%s,here:%d\n",__func__,__LINE__); |
| 2951 | kfree(temp_buf); |
| 2952 | HX_PROC_SEND_FLAG = 1; |
| 2953 | } |
| 2954 | else |
| 2955 | { |
| 2956 | HX_PROC_SEND_FLAG = 0; |
| 2957 | ret = 0; |
| 2958 | } |
| 2959 | return ret; |
| 2960 | } |
| 2961 | |
| 2962 | static ssize_t himax_GESTURE_write(struct file *file, const char *buff, |
| 2963 | size_t len, loff_t *pos) |
| 2964 | { |
| 2965 | struct himax_ts_data *ts = private_ts; |
| 2966 | int i =0; |
| 2967 | char buf[80] = {0}; |
| 2968 | |
| 2969 | if (len >= 80) |
| 2970 | { |
| 2971 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 2972 | return -EFAULT; |
| 2973 | } |
| 2974 | if (copy_from_user(buf, buff, len)) |
| 2975 | { |
| 2976 | return -EFAULT; |
| 2977 | } |
| 2978 | |
| 2979 | I("himax_GESTURE_store= %s \n",buf); |
| 2980 | for (i=0; i<16; i++) |
| 2981 | { |
| 2982 | if (buf[i] == '0') |
| 2983 | ts->gesture_cust_en[i]= 0; |
| 2984 | else if (buf[i] == '1') |
| 2985 | ts->gesture_cust_en[i]= 1; |
| 2986 | else |
| 2987 | ts->gesture_cust_en[i]= 0; |
| 2988 | I("gesture en[%d]=%d \n", i, ts->gesture_cust_en[i]); |
| 2989 | } |
| 2990 | return len; |
| 2991 | } |
| 2992 | |
| 2993 | static struct file_operations himax_proc_Gesture_ops = |
| 2994 | { |
| 2995 | .owner = THIS_MODULE, |
| 2996 | .read = himax_GESTURE_read, |
| 2997 | .write = himax_GESTURE_write, |
| 2998 | }; |
| 2999 | #endif |
| 3000 | |
| 3001 | #ifdef HX_ESD_RECOVERY |
| 3002 | static ssize_t himax_esd_cnt_read(struct file *file, char *buf, |
| 3003 | size_t len, loff_t *pos) |
| 3004 | { |
| 3005 | int ret = 0; |
| 3006 | char *temp_buf; |
| 3007 | |
| 3008 | temp_buf = kzalloc(len,GFP_KERNEL); |
| 3009 | |
| 3010 | I("%s: enter, %d \n", __func__, __LINE__); |
| 3011 | if(!HX_PROC_SEND_FLAG) |
| 3012 | { |
| 3013 | ret += sprintf(temp_buf + ret, "EB_cnt = %d, EC_cnt = %d, ED_cnt = %d\n",hx_EB_event_flag, hx_EC_event_flag, hx_ED_event_flag); |
| 3014 | if(copy_to_user(buf, temp_buf, len)) |
| 3015 | I("%s,here:%d\n",__func__,__LINE__); |
| 3016 | kfree(temp_buf); |
| 3017 | HX_PROC_SEND_FLAG=1; |
| 3018 | } |
| 3019 | else |
| 3020 | HX_PROC_SEND_FLAG=0; |
| 3021 | return ret; |
| 3022 | } |
| 3023 | |
| 3024 | static ssize_t himax_esd_cnt_write(struct file *file, const char *buff, |
| 3025 | size_t len, loff_t *pos) |
| 3026 | { |
| 3027 | int i =0; |
| 3028 | char buf[12] = {0}; |
| 3029 | |
| 3030 | if (len >= 12) |
| 3031 | { |
| 3032 | I("%s: no command exceeds 80 chars.\n", __func__); |
| 3033 | return -EFAULT; |
| 3034 | } |
| 3035 | if (copy_from_user(buf, buff, len)) |
| 3036 | { |
| 3037 | return -EFAULT; |
| 3038 | } |
| 3039 | |
| 3040 | I("Clear ESD Flag \n"); |
| 3041 | if (buf[i] == '0') |
| 3042 | { |
| 3043 | hx_EB_event_flag = 0; |
| 3044 | hx_EC_event_flag = 0; |
| 3045 | hx_ED_event_flag = 0; |
| 3046 | } |
| 3047 | |
| 3048 | return len; |
| 3049 | } |
| 3050 | |
| 3051 | static struct file_operations himax_proc_esd_cnt_ops = |
| 3052 | { |
| 3053 | .owner = THIS_MODULE, |
| 3054 | .read = himax_esd_cnt_read, |
| 3055 | .write = himax_esd_cnt_write, |
| 3056 | }; |
| 3057 | #endif |
| 3058 | |
| 3059 | int himax_touch_proc_init(void) |
| 3060 | { |
| 3061 | himax_touch_proc_dir = proc_mkdir( HIMAX_PROC_TOUCH_FOLDER, NULL); |
| 3062 | if (himax_touch_proc_dir == NULL) |
| 3063 | { |
| 3064 | E(" %s: himax_touch_proc_dir file create failed!\n", __func__); |
| 3065 | return -ENOMEM; |
| 3066 | } |
| 3067 | |
| 3068 | himax_proc_debug_level_file = proc_create(HIMAX_PROC_DEBUG_LEVEL_FILE, (S_IWUSR|S_IRUGO), |
| 3069 | himax_touch_proc_dir, &himax_proc_debug_level_ops); |
| 3070 | if (himax_proc_debug_level_file == NULL) |
| 3071 | { |
| 3072 | E(" %s: proc debug_level file create failed!\n", __func__); |
| 3073 | goto fail_1; |
| 3074 | } |
| 3075 | |
| 3076 | himax_proc_vendor_file = proc_create(HIMAX_PROC_VENDOR_FILE, (S_IRUGO), |
| 3077 | himax_touch_proc_dir, &himax_proc_vendor_ops); |
| 3078 | if(himax_proc_vendor_file == NULL) |
| 3079 | { |
| 3080 | E(" %s: proc vendor file create failed!\n", __func__); |
| 3081 | goto fail_2; |
| 3082 | } |
| 3083 | |
| 3084 | himax_proc_attn_file = proc_create(HIMAX_PROC_ATTN_FILE, (S_IRUGO), |
| 3085 | himax_touch_proc_dir, &himax_proc_attn_ops); |
| 3086 | if(himax_proc_attn_file == NULL) |
| 3087 | { |
| 3088 | E(" %s: proc attn file create failed!\n", __func__); |
| 3089 | goto fail_3; |
| 3090 | } |
| 3091 | |
| 3092 | himax_proc_int_en_file = proc_create(HIMAX_PROC_INT_EN_FILE, (S_IWUSR|S_IRUGO), |
| 3093 | himax_touch_proc_dir, &himax_proc_int_en_ops); |
| 3094 | if(himax_proc_int_en_file == NULL) |
| 3095 | { |
| 3096 | E(" %s: proc int en file create failed!\n", __func__); |
| 3097 | goto fail_4; |
| 3098 | } |
| 3099 | |
| 3100 | himax_proc_layout_file = proc_create(HIMAX_PROC_LAYOUT_FILE, (S_IWUSR|S_IRUGO), |
| 3101 | himax_touch_proc_dir, &himax_proc_layout_ops); |
| 3102 | if(himax_proc_layout_file == NULL) |
| 3103 | { |
| 3104 | E(" %s: proc layout file create failed!\n", __func__); |
| 3105 | goto fail_5; |
| 3106 | } |
| 3107 | |
| 3108 | #ifdef HX_TP_PROC_RESET |
| 3109 | himax_proc_reset_file = proc_create(HIMAX_PROC_RESET_FILE, (S_IWUSR), |
| 3110 | himax_touch_proc_dir, &himax_proc_reset_ops); |
| 3111 | if(himax_proc_reset_file == NULL) |
| 3112 | { |
| 3113 | E(" %s: proc reset file create failed!\n", __func__); |
| 3114 | goto fail_6; |
| 3115 | } |
| 3116 | #endif |
| 3117 | |
| 3118 | #ifdef HX_TP_PROC_DIAG |
| 3119 | himax_proc_diag_file = proc_create(HIMAX_PROC_DIAG_FILE, (S_IWUSR|S_IRUGO), |
| 3120 | himax_touch_proc_dir, &himax_proc_diag_ops); |
| 3121 | if(himax_proc_diag_file == NULL) |
| 3122 | { |
| 3123 | E(" %s: proc diag file create failed!\n", __func__); |
| 3124 | goto fail_7; |
| 3125 | } |
| 3126 | himax_proc_diag_arrange_file = proc_create(HIMAX_PROC_DIAG_ARR_FILE, (S_IWUSR|S_IRUGO), |
| 3127 | himax_touch_proc_dir, &himax_proc_diag_arrange_ops); |
| 3128 | if(himax_proc_diag_arrange_file == NULL) |
| 3129 | { |
| 3130 | E(" %s: proc diag file create failed!\n", __func__); |
| 3131 | goto fail_7_1; |
| 3132 | } |
| 3133 | #endif |
| 3134 | |
| 3135 | #ifdef HX_TP_PROC_REGISTER |
| 3136 | himax_proc_register_file = proc_create(HIMAX_PROC_REGISTER_FILE, (S_IWUSR|S_IRUGO), |
| 3137 | himax_touch_proc_dir, &himax_proc_register_ops); |
| 3138 | if(himax_proc_register_file == NULL) |
| 3139 | { |
| 3140 | E(" %s: proc register file create failed!\n", __func__); |
| 3141 | goto fail_8; |
| 3142 | } |
| 3143 | #endif |
| 3144 | |
| 3145 | #ifdef HX_TP_PROC_DEBUG |
| 3146 | himax_proc_debug_file = proc_create(HIMAX_PROC_DEBUG_FILE, (S_IWUSR|S_IRUGO), |
| 3147 | himax_touch_proc_dir, &himax_proc_debug_ops); |
| 3148 | if(himax_proc_debug_file == NULL) |
| 3149 | { |
| 3150 | E(" %s: proc debug file create failed!\n", __func__); |
| 3151 | goto fail_9; |
| 3152 | } |
| 3153 | |
| 3154 | himax_proc_fw_debug_file = proc_create(HIMAX_PROC_FW_DEBUG_FILE, (S_IWUSR|S_IRUGO), |
| 3155 | himax_touch_proc_dir, &himax_proc_fw_debug_ops); |
| 3156 | if(himax_proc_fw_debug_file == NULL) |
| 3157 | { |
| 3158 | E(" %s: proc fw debug file create failed!\n", __func__); |
| 3159 | goto fail_9_1; |
| 3160 | } |
| 3161 | |
| 3162 | himax_proc_dd_debug_file = proc_create(HIMAX_PROC_DD_DEBUG_FILE, (S_IWUSR|S_IRUGO), |
| 3163 | himax_touch_proc_dir, &himax_proc_dd_debug_ops); |
| 3164 | if(himax_proc_dd_debug_file == NULL) |
| 3165 | { |
| 3166 | E(" %s: proc DD debug file create failed!\n", __func__); |
| 3167 | goto fail_9_2; |
| 3168 | } |
| 3169 | #endif |
| 3170 | |
| 3171 | #ifdef HX_TP_PROC_FLASH_DUMP |
| 3172 | himax_proc_flash_dump_file = proc_create(HIMAX_PROC_FLASH_DUMP_FILE, (S_IWUSR|S_IRUGO), |
| 3173 | himax_touch_proc_dir, &himax_proc_flash_ops); |
| 3174 | if(himax_proc_flash_dump_file == NULL) |
| 3175 | { |
| 3176 | E(" %s: proc flash dump file create failed!\n", __func__); |
| 3177 | goto fail_10; |
| 3178 | } |
| 3179 | #endif |
| 3180 | |
| 3181 | #ifdef HX_TP_PROC_SELF_TEST |
| 3182 | himax_proc_self_test_file = proc_create(HIMAX_PROC_SELF_TEST_FILE, (S_IRUGO), |
| 3183 | himax_touch_proc_dir, &himax_proc_self_test_ops); |
| 3184 | if(himax_proc_self_test_file == NULL) |
| 3185 | { |
| 3186 | E(" %s: proc self_test file create failed!\n", __func__); |
| 3187 | goto fail_11; |
| 3188 | } |
| 3189 | #endif |
| 3190 | |
| 3191 | #ifdef HX_HIGH_SENSE |
| 3192 | himax_proc_HSEN_file = proc_create(HIMAX_PROC_HSEN_FILE, (S_IWUSR|S_IRUGO|S_IWUGO), |
| 3193 | himax_touch_proc_dir, &himax_proc_HSEN_ops); |
| 3194 | if(himax_proc_HSEN_file == NULL) |
| 3195 | { |
| 3196 | E(" %s: proc HSEN file create failed!\n", __func__); |
| 3197 | goto fail_13; |
| 3198 | } |
| 3199 | #endif |
| 3200 | |
| 3201 | #ifdef HX_SMART_WAKEUP |
| 3202 | himax_proc_SMWP_file = proc_create(HIMAX_PROC_SMWP_FILE, (S_IWUSR|S_IRUGO|S_IWUGO), |
| 3203 | himax_touch_proc_dir, &himax_proc_SMWP_ops); |
| 3204 | if(himax_proc_SMWP_file == NULL) |
| 3205 | { |
| 3206 | E(" %s: proc SMWP file create failed!\n", __func__); |
| 3207 | goto fail_14; |
| 3208 | } |
| 3209 | himax_proc_GESTURE_file = proc_create(HIMAX_PROC_GESTURE_FILE, (S_IWUSR|S_IRUGO|S_IWUGO), |
| 3210 | himax_touch_proc_dir, &himax_proc_Gesture_ops); |
| 3211 | if(himax_proc_GESTURE_file == NULL) |
| 3212 | { |
| 3213 | E(" %s: proc GESTURE file create failed!\n", __func__); |
| 3214 | goto fail_15; |
| 3215 | } |
| 3216 | #endif |
| 3217 | |
| 3218 | #ifdef HX_TP_PROC_SENSE_ON_OFF |
| 3219 | himax_proc_SENSE_ON_OFF_file = proc_create(HIMAX_PROC_SENSE_ON_OFF_FILE, (S_IWUSR|S_IRUGO|S_IWUGO), |
| 3220 | himax_touch_proc_dir, &himax_proc_sense_on_off_ops); |
| 3221 | if(himax_proc_SENSE_ON_OFF_file == NULL) |
| 3222 | { |
| 3223 | E(" %s: proc SENSE_ON_OFF file create failed!\n", __func__); |
| 3224 | goto fail_16; |
| 3225 | } |
| 3226 | #endif |
| 3227 | #ifdef HX_ESD_RECOVERY |
| 3228 | himax_proc_ESD_cnt_file = proc_create(HIMAX_PROC_ESD_CNT_FILE, (S_IWUSR|S_IRUGO|S_IWUGO), |
| 3229 | himax_touch_proc_dir, &himax_proc_esd_cnt_ops); |
| 3230 | if(himax_proc_ESD_cnt_file == NULL) |
| 3231 | { |
| 3232 | E(" %s: proc ESD cnt file create failed!\n", __func__); |
| 3233 | goto fail_17; |
| 3234 | } |
| 3235 | #endif |
| 3236 | himax_proc_CRC_test_file = proc_create(HIMAX_PROC_CRC_TEST_FILE, (S_IWUSR|S_IRUGO|S_IWUGO), |
| 3237 | himax_touch_proc_dir, &himax_proc_CRC_test_ops); |
| 3238 | if(himax_proc_CRC_test_file == NULL) |
| 3239 | { |
| 3240 | E(" %s: proc CRC test file create failed!\n", __func__); |
| 3241 | goto fail_18; |
| 3242 | } |
| 3243 | return 0 ; |
| 3244 | |
| 3245 | fail_18: |
| 3246 | #ifdef HX_ESD_RECOVERY |
| 3247 | remove_proc_entry( HIMAX_PROC_ESD_CNT_FILE, himax_touch_proc_dir ); |
| 3248 | fail_17: |
| 3249 | #endif |
| 3250 | #ifdef HX_TP_PROC_SENSE_ON_OFF |
| 3251 | remove_proc_entry( HIMAX_PROC_SENSE_ON_OFF_FILE, himax_touch_proc_dir ); |
| 3252 | fail_16: |
| 3253 | #endif |
| 3254 | #ifdef HX_SMART_WAKEUP |
| 3255 | remove_proc_entry( HIMAX_PROC_GESTURE_FILE, himax_touch_proc_dir ); |
| 3256 | fail_15: |
| 3257 | remove_proc_entry( HIMAX_PROC_SMWP_FILE, himax_touch_proc_dir ); |
| 3258 | fail_14: |
| 3259 | #endif |
| 3260 | #ifdef HX_HIGH_SENSE |
| 3261 | remove_proc_entry( HIMAX_PROC_HSEN_FILE, himax_touch_proc_dir ); |
| 3262 | fail_13: |
| 3263 | #endif |
| 3264 | #ifdef HX_TP_PROC_SELF_TEST |
| 3265 | remove_proc_entry( HIMAX_PROC_SELF_TEST_FILE, himax_touch_proc_dir ); |
| 3266 | fail_11: |
| 3267 | #endif |
| 3268 | #ifdef HX_TP_PROC_FLASH_DUMP |
| 3269 | remove_proc_entry( HIMAX_PROC_FLASH_DUMP_FILE, himax_touch_proc_dir ); |
| 3270 | fail_10: |
| 3271 | #endif |
| 3272 | #ifdef HX_TP_PROC_DEBUG |
| 3273 | remove_proc_entry( HIMAX_PROC_DEBUG_FILE, himax_touch_proc_dir ); |
| 3274 | fail_9: |
| 3275 | remove_proc_entry( HIMAX_PROC_FW_DEBUG_FILE, himax_touch_proc_dir ); |
| 3276 | fail_9_1: |
| 3277 | remove_proc_entry( HIMAX_PROC_DD_DEBUG_FILE, himax_touch_proc_dir ); |
| 3278 | fail_9_2: |
| 3279 | #endif |
| 3280 | #ifdef HX_TP_PROC_REGISTER |
| 3281 | remove_proc_entry( HIMAX_PROC_REGISTER_FILE, himax_touch_proc_dir ); |
| 3282 | fail_8: |
| 3283 | #endif |
| 3284 | #ifdef HX_TP_PROC_DIAG |
| 3285 | remove_proc_entry( HIMAX_PROC_DIAG_FILE, himax_touch_proc_dir ); |
| 3286 | fail_7: |
| 3287 | remove_proc_entry( HIMAX_PROC_DIAG_ARR_FILE, himax_touch_proc_dir ); |
| 3288 | fail_7_1: |
| 3289 | #endif |
| 3290 | #ifdef HX_TP_PROC_RESET |
| 3291 | remove_proc_entry( HIMAX_PROC_RESET_FILE, himax_touch_proc_dir ); |
| 3292 | fail_6: |
| 3293 | #endif |
| 3294 | remove_proc_entry( HIMAX_PROC_LAYOUT_FILE, himax_touch_proc_dir ); |
| 3295 | fail_5: |
| 3296 | remove_proc_entry( HIMAX_PROC_INT_EN_FILE, himax_touch_proc_dir ); |
| 3297 | fail_4: |
| 3298 | remove_proc_entry( HIMAX_PROC_ATTN_FILE, himax_touch_proc_dir ); |
| 3299 | fail_3: |
| 3300 | remove_proc_entry( HIMAX_PROC_VENDOR_FILE, himax_touch_proc_dir ); |
| 3301 | fail_2: |
| 3302 | remove_proc_entry( HIMAX_PROC_DEBUG_LEVEL_FILE, himax_touch_proc_dir ); |
| 3303 | fail_1: |
| 3304 | remove_proc_entry( HIMAX_PROC_TOUCH_FOLDER, NULL ); |
| 3305 | return -ENOMEM; |
| 3306 | } |
| 3307 | |
| 3308 | void himax_touch_proc_deinit(void) |
| 3309 | { |
| 3310 | remove_proc_entry( HIMAX_PROC_CRC_TEST_FILE, himax_touch_proc_dir ); |
| 3311 | #ifdef HX_ESD_RECOVERY |
| 3312 | remove_proc_entry( HIMAX_PROC_ESD_CNT_FILE, himax_touch_proc_dir ); |
| 3313 | #endif |
| 3314 | #ifdef HX_TP_PROC_SENSE_ON_OFF |
| 3315 | remove_proc_entry( HIMAX_PROC_SENSE_ON_OFF_FILE, himax_touch_proc_dir ); |
| 3316 | #endif |
| 3317 | #ifdef HX_SMART_WAKEUP |
| 3318 | remove_proc_entry( HIMAX_PROC_GESTURE_FILE, himax_touch_proc_dir ); |
| 3319 | remove_proc_entry( HIMAX_PROC_SMWP_FILE, himax_touch_proc_dir ); |
| 3320 | #endif |
| 3321 | #ifdef HX_DOT_VIEW |
| 3322 | remove_proc_entry( HIMAX_PROC_HSEN_FILE, himax_touch_proc_dir ); |
| 3323 | #endif |
| 3324 | #ifdef HX_TP_PROC_SELF_TEST |
| 3325 | remove_proc_entry(HIMAX_PROC_SELF_TEST_FILE, himax_touch_proc_dir); |
| 3326 | #endif |
| 3327 | #ifdef HX_TP_PROC_FLASH_DUMP |
| 3328 | remove_proc_entry(HIMAX_PROC_FLASH_DUMP_FILE, himax_touch_proc_dir); |
| 3329 | #endif |
| 3330 | #ifdef HX_TP_PROC_DEBUG |
| 3331 | remove_proc_entry( HIMAX_PROC_DEBUG_FILE, himax_touch_proc_dir ); |
| 3332 | remove_proc_entry( HIMAX_PROC_FW_DEBUG_FILE, himax_touch_proc_dir ); |
| 3333 | remove_proc_entry( HIMAX_PROC_DD_DEBUG_FILE, himax_touch_proc_dir ); |
| 3334 | #endif |
| 3335 | #ifdef HX_TP_PROC_REGISTER |
| 3336 | remove_proc_entry(HIMAX_PROC_REGISTER_FILE, himax_touch_proc_dir); |
| 3337 | #endif |
| 3338 | #ifdef HX_TP_PROC_DIAG |
| 3339 | remove_proc_entry(HIMAX_PROC_DIAG_FILE, himax_touch_proc_dir); |
| 3340 | #endif |
| 3341 | #ifdef HX_TP_PROC_RESET |
| 3342 | remove_proc_entry( HIMAX_PROC_RESET_FILE, himax_touch_proc_dir ); |
| 3343 | #endif |
| 3344 | remove_proc_entry( HIMAX_PROC_LAYOUT_FILE, himax_touch_proc_dir ); |
| 3345 | remove_proc_entry( HIMAX_PROC_INT_EN_FILE, himax_touch_proc_dir ); |
| 3346 | remove_proc_entry( HIMAX_PROC_ATTN_FILE, himax_touch_proc_dir ); |
| 3347 | remove_proc_entry( HIMAX_PROC_VENDOR_FILE, himax_touch_proc_dir ); |
| 3348 | remove_proc_entry( HIMAX_PROC_DEBUG_LEVEL_FILE, himax_touch_proc_dir ); |
| 3349 | remove_proc_entry( HIMAX_PROC_TOUCH_FOLDER, NULL ); |
| 3350 | } |
| 3351 | #endif |