Lines Matching +full:deep +full:- +full:touch

6  * Copyright (C) 2014-2015 Cypress Semiconductor, Inc.
21 #include <linux/crc-itu-t.h>
33 #define CYAPA_TSG_IMG_MAX_RECORDS (CYAPA_TSG_IMG_END_ROW_NUM - \
141 * Bit 7 - 3: reserved
142 * Bit 2 - 0: touch type;
146 * 3 - 15 : reserved.
151 * Bit 7: indicates touch liftoff status.
152 * 0 : touch is currently on the panel.
153 * 1 : touch record indicates a liftoff.
154 * Bit 6 - 5: indicates an event associated with this touch instance
159 * Bit 4 - 0: An arbitrary ID tag associated with a finger
160 * to allow tracking a touch as it moves around the panel.
164 /* Bit 7 - 0 of X-axis coordinate of the touch in pixel. */
167 /* Bit 15 - 8 of X-axis coordinate of the touch in pixel. */
170 /* Bit 7 - 0 of Y-axis coordinate of the touch in pixel. */
173 /* Bit 15 - 8 of Y-axis coordinate of the touch in pixel. */
179 * Touch intensity in counts, pressure value.
212 * the major axis of the contact ellipse. This value is an 8-bit
213 * signed integer. The range is -127 to +127 (corresponding to
214 * -90 degree and +90 degree respectively).
314 * Bit 6-0: command code.
350 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_pip_cmd_state_initialize()
352 init_completion(&pip->cmd_ready); in cyapa_pip_cmd_state_initialize()
353 atomic_set(&pip->cmd_issued, 0); in cyapa_pip_cmd_state_initialize()
354 mutex_init(&pip->cmd_lock); in cyapa_pip_cmd_state_initialize()
356 mutex_init(&pip->pm_stage_lock); in cyapa_pip_cmd_state_initialize()
357 pip->pm_stage = CYAPA_PM_DEACTIVE; in cyapa_pip_cmd_state_initialize()
359 pip->resp_sort_func = NULL; in cyapa_pip_cmd_state_initialize()
360 pip->in_progress_cmd = PIP_INVALID_CMD; in cyapa_pip_cmd_state_initialize()
361 pip->resp_data = NULL; in cyapa_pip_cmd_state_initialize()
362 pip->resp_len = NULL; in cyapa_pip_cmd_state_initialize()
364 cyapa->dev_pwr_mode = UNINIT_PWR_MODE; in cyapa_pip_cmd_state_initialize()
365 cyapa->dev_sleep_time = UNINIT_SLEEP_TIME; in cyapa_pip_cmd_state_initialize()
379 return -EINVAL; in cyapa_i2c_pip_read()
381 ret = i2c_master_recv(cyapa->client, buf, size); in cyapa_i2c_pip_read()
384 return (ret < 0) ? ret : -EIO; in cyapa_i2c_pip_read()
396 return -EINVAL; in cyapa_i2c_pip_write()
398 ret = i2c_master_send(cyapa->client, buf, size); in cyapa_i2c_pip_write()
401 return (ret < 0) ? ret : -EIO; in cyapa_i2c_pip_write()
409 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_set_pip_pm_state()
411 mutex_lock(&pip->pm_stage_lock); in cyapa_set_pip_pm_state()
412 pip->pm_stage = pm_stage; in cyapa_set_pip_pm_state()
413 mutex_unlock(&pip->pm_stage_lock); in cyapa_set_pip_pm_state()
418 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_reset_pip_pm_state()
420 /* Indicates the pip->pm_stage is not valid. */ in cyapa_reset_pip_pm_state()
421 mutex_lock(&pip->pm_stage_lock); in cyapa_reset_pip_pm_state()
422 pip->pm_stage = CYAPA_PM_DEACTIVE; in cyapa_reset_pip_pm_state()
423 mutex_unlock(&pip->pm_stage_lock); in cyapa_reset_pip_pm_state()
428 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_get_pip_pm_state()
431 mutex_lock(&pip->pm_stage_lock); in cyapa_get_pip_pm_state()
432 pm_stage = pip->pm_stage; in cyapa_get_pip_pm_state()
433 mutex_unlock(&pip->pm_stage_lock); in cyapa_get_pip_pm_state()
445 struct input_dev *input = cyapa->input; in cyapa_empty_pip_output_data()
446 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_empty_pip_output_data()
479 error = cyapa_i2c_pip_read(cyapa, pip->empty_buf, in cyapa_empty_pip_output_data()
484 length = get_unaligned_le16(pip->empty_buf); in cyapa_empty_pip_output_data()
490 return -EINVAL; in cyapa_empty_pip_output_data()
495 func(cyapa, pip->empty_buf, length)) { in cyapa_empty_pip_output_data()
497 memcpy(buf, pip->empty_buf, length); in cyapa_empty_pip_output_data()
505 error = cyapa_i2c_pip_read(cyapa, pip->empty_buf, length); in cyapa_empty_pip_output_data()
509 report_count--; in cyapa_empty_pip_output_data()
511 length = get_unaligned_le16(pip->empty_buf); in cyapa_empty_pip_output_data()
515 func(cyapa, pip->empty_buf, length)) { in cyapa_empty_pip_output_data()
517 memcpy(buf, pip->empty_buf, length); in cyapa_empty_pip_output_data()
521 } else if (cyapa->operational && in cyapa_empty_pip_output_data()
527 (struct cyapa_pip_report_data *)pip->empty_buf); in cyapa_empty_pip_output_data()
530 error = -EINVAL; in cyapa_empty_pip_output_data()
541 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_do_i2c_pip_cmd_irq_sync()
545 init_completion(&pip->cmd_ready); in cyapa_do_i2c_pip_cmd_irq_sync()
547 atomic_inc(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_irq_sync()
550 atomic_dec(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_irq_sync()
551 return (error < 0) ? error : -EIO; in cyapa_do_i2c_pip_cmd_irq_sync()
555 timeout = wait_for_completion_timeout(&pip->cmd_ready, in cyapa_do_i2c_pip_cmd_irq_sync()
558 atomic_dec(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_irq_sync()
559 return -ETIMEDOUT; in cyapa_do_i2c_pip_cmd_irq_sync()
572 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_do_i2c_pip_cmd_polling()
577 atomic_inc(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_polling()
580 atomic_dec(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_polling()
581 return error < 0 ? error : -EIO; in cyapa_do_i2c_pip_cmd_polling()
596 } while (--tries > 0); in cyapa_do_i2c_pip_cmd_polling()
598 error = error ? error : -ETIMEDOUT; in cyapa_do_i2c_pip_cmd_polling()
601 atomic_dec(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_polling()
613 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_i2c_pip_cmd_irq_sync()
617 return -EINVAL; in cyapa_i2c_pip_cmd_irq_sync()
620 error = mutex_lock_interruptible(&pip->cmd_lock); in cyapa_i2c_pip_cmd_irq_sync()
624 pip->resp_sort_func = func; in cyapa_i2c_pip_cmd_irq_sync()
625 pip->resp_data = resp_data; in cyapa_i2c_pip_cmd_irq_sync()
626 pip->resp_len = resp_len; in cyapa_i2c_pip_cmd_irq_sync()
631 pip->in_progress_cmd = cmd[6] & 0x7f; in cyapa_i2c_pip_cmd_irq_sync()
635 pip->in_progress_cmd = cmd[7]; in cyapa_i2c_pip_cmd_irq_sync()
640 pip->is_irq_mode = true; in cyapa_i2c_pip_cmd_irq_sync()
643 if (error == -ETIMEDOUT && resp_data && in cyapa_i2c_pip_cmd_irq_sync()
653 error = error ? error : -ETIMEDOUT; in cyapa_i2c_pip_cmd_irq_sync()
656 pip->is_irq_mode = false; in cyapa_i2c_pip_cmd_irq_sync()
661 pip->resp_sort_func = NULL; in cyapa_i2c_pip_cmd_irq_sync()
662 pip->resp_data = NULL; in cyapa_i2c_pip_cmd_irq_sync()
663 pip->resp_len = NULL; in cyapa_i2c_pip_cmd_irq_sync()
664 pip->in_progress_cmd = PIP_INVALID_CMD; in cyapa_i2c_pip_cmd_irq_sync()
666 mutex_unlock(&pip->cmd_lock); in cyapa_i2c_pip_cmd_irq_sync()
688 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_sort_tsg_pip_app_resp_data()
699 data[5] == pip->in_progress_cmd) { in cyapa_sort_tsg_pip_app_resp_data()
703 pip->in_progress_cmd) { in cyapa_sort_tsg_pip_app_resp_data()
786 return ret < 0 ? ret : -EIO; in gen5_idle_state_parse()
791 cyapa->gen = CYAPA_GEN5; in gen5_idle_state_parse()
817 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_idle_state_parse()
824 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_idle_state_parse()
827 cyapa->state = CYAPA_STATE_NO_DEVICE; in gen5_idle_state_parse()
846 * or report any touch or button data. in gen5_hid_description_header_parse()
851 return ret < 0 ? ret : -EIO; in gen5_hid_description_header_parse()
861 cyapa->gen = CYAPA_GEN5; in gen5_hid_description_header_parse()
862 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_hid_description_header_parse()
868 cyapa->gen = CYAPA_GEN5; in gen5_hid_description_header_parse()
869 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_hid_description_header_parse()
875 cyapa->gen = CYAPA_GEN5; in gen5_hid_description_header_parse()
876 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_hid_description_header_parse()
882 cyapa->gen = CYAPA_GEN5; in gen5_hid_description_header_parse()
883 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_hid_description_header_parse()
886 cyapa->state = CYAPA_STATE_NO_DEVICE; in gen5_hid_description_header_parse()
901 return -EINVAL; in gen5_report_data_header_parse()
908 return -EINVAL; in gen5_report_data_header_parse()
912 return -EINVAL; in gen5_report_data_header_parse()
915 return -EINVAL; in gen5_report_data_header_parse()
918 cyapa->gen = CYAPA_GEN5; in gen5_report_data_header_parse()
919 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_report_data_header_parse()
925 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in gen5_cmd_resp_header_parse()
932 * or report any touch or button data. in gen5_cmd_resp_header_parse()
935 ret = cyapa_i2c_pip_read(cyapa, pip->empty_buf, length); in gen5_cmd_resp_header_parse()
937 return ret < 0 ? ret : -EIO; in gen5_cmd_resp_header_parse()
944 cyapa->gen = CYAPA_GEN5; in gen5_cmd_resp_header_parse()
945 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_cmd_resp_header_parse()
948 cyapa->gen = CYAPA_GEN5; in gen5_cmd_resp_header_parse()
949 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_cmd_resp_header_parse()
951 } else if ((pip->empty_buf[PIP_RESP_REPORT_ID_OFFSET] == in gen5_cmd_resp_header_parse()
953 (pip->empty_buf[PIP_RESP_RSVD_OFFSET] == in gen5_cmd_resp_header_parse()
955 (pip->empty_buf[PIP_RESP_BL_SOP_OFFSET] == in gen5_cmd_resp_header_parse()
957 (pip->empty_buf[length - 1] == in gen5_cmd_resp_header_parse()
960 cyapa->gen = CYAPA_GEN5; in gen5_cmd_resp_header_parse()
961 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_cmd_resp_header_parse()
962 } else if (pip->empty_buf[PIP_RESP_REPORT_ID_OFFSET] == in gen5_cmd_resp_header_parse()
964 pip->empty_buf[PIP_RESP_RSVD_OFFSET] == in gen5_cmd_resp_header_parse()
967 cyapa->gen = CYAPA_GEN5; in gen5_cmd_resp_header_parse()
968 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_cmd_resp_header_parse()
971 cyapa->state = CYAPA_STATE_NO_DEVICE; in gen5_cmd_resp_header_parse()
982 return -EINVAL; in cyapa_gen5_state_parse()
984 cyapa->state = CYAPA_STATE_NO_DEVICE; in cyapa_gen5_state_parse()
998 cyapa->gen = CYAPA_GEN5; in cyapa_gen5_state_parse()
999 cyapa->state = CYAPA_STATE_GEN5_APP; in cyapa_gen5_state_parse()
1003 cyapa->gen = CYAPA_GEN5; in cyapa_gen5_state_parse()
1004 cyapa->state = CYAPA_STATE_GEN5_BL; in cyapa_gen5_state_parse()
1016 if (cyapa->gen == CYAPA_GEN5) { in cyapa_gen5_state_parse()
1021 * report any touch or button data later. in cyapa_gen5_state_parse()
1025 if (cyapa->state == CYAPA_STATE_GEN5_APP || in cyapa_gen5_state_parse()
1026 cyapa->state == CYAPA_STATE_GEN5_BL) in cyapa_gen5_state_parse()
1030 return -EAGAIN; in cyapa_gen5_state_parse()
1039 head_size = fw->data[0] + 1; in cyapa_get_image_record_data_num()
1040 *record_num = (fw->size - head_size) / in cyapa_get_image_record_data_num()
1042 return (struct cyapa_tsg_bin_image_data_record *)&fw->data[head_size]; in cyapa_get_image_record_data_num()
1072 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &bl_cmd_head->addr); in cyapa_pip_bl_initiate()
1073 put_unaligned_le16(cmd_len - 2, &bl_cmd_head->length); in cyapa_pip_bl_initiate()
1074 bl_cmd_head->report_id = PIP_BL_CMD_REPORT_ID; in cyapa_pip_bl_initiate()
1076 bl_packet_start = &bl_cmd_head->packet_start; in cyapa_pip_bl_initiate()
1077 bl_packet_start->sop = PIP_SOP_KEY; in cyapa_pip_bl_initiate()
1078 bl_packet_start->cmd_code = PIP_BL_CMD_INITIATE_BL; in cyapa_pip_bl_initiate()
1080 put_unaligned_le16(cmd_data_len, &bl_packet_start->data_length); in cyapa_pip_bl_initiate()
1082 cmd_data = (struct pip_bl_initiate_cmd_data *)bl_cmd_head->data; in cyapa_pip_bl_initiate()
1083 memcpy(cmd_data->key, cyapa_pip_bl_cmd_key, CYAPA_TSG_BL_KEY_SIZE); in cyapa_pip_bl_initiate()
1088 data = image_records[records_num - 1].record_data; in cyapa_pip_bl_initiate()
1089 memcpy(cmd_data->metadata_raw_parameter, data, in cyapa_pip_bl_initiate()
1092 meta_data_crc = crc_itu_t(0xffff, cmd_data->metadata_raw_parameter, in cyapa_pip_bl_initiate()
1094 put_unaligned_le16(meta_data_crc, &cmd_data->metadata_crc); in cyapa_pip_bl_initiate()
1096 bl_packet_end = (struct pip_bl_packet_end *)(bl_cmd_head->data + in cyapa_pip_bl_initiate()
1100 put_unaligned_le16(cmd_crc, &bl_packet_end->crc); in cyapa_pip_bl_initiate()
1101 bl_packet_end->eop = PIP_EOP_KEY; in cyapa_pip_bl_initiate()
1111 return error ? error : -EAGAIN; in cyapa_pip_bl_initiate()
1158 return -EAGAIN; in cyapa_pip_bl_exit()
1163 return -ENODEV; in cyapa_pip_bl_exit()
1181 return -EINVAL; in cyapa_pip_bl_enter()
1198 return error < 0 ? error : -EAGAIN; in cyapa_pip_bl_enter()
1200 cyapa->operational = false; in cyapa_pip_bl_enter()
1201 if (cyapa->gen == CYAPA_GEN5) in cyapa_pip_bl_enter()
1202 cyapa->state = CYAPA_STATE_GEN5_BL; in cyapa_pip_bl_enter()
1203 else if (cyapa->gen == CYAPA_GEN6) in cyapa_pip_bl_enter()
1204 cyapa->state = CYAPA_STATE_GEN6_BL; in cyapa_pip_bl_enter()
1211 if (image_head->head_size != 0x0C && image_head->head_size != 0x12) in cyapa_pip_fw_head_check()
1212 return -EINVAL; in cyapa_pip_fw_head_check()
1214 switch (cyapa->gen) { in cyapa_pip_fw_head_check()
1216 if (image_head->family_id != 0x9B || in cyapa_pip_fw_head_check()
1217 image_head->silicon_id_hi != 0x0B) in cyapa_pip_fw_head_check()
1218 return -EINVAL; in cyapa_pip_fw_head_check()
1222 if (cyapa->platform_ver < 2) { in cyapa_pip_fw_head_check()
1223 if (image_head->head_size == 0x0C) in cyapa_pip_fw_head_check()
1225 return -EINVAL; in cyapa_pip_fw_head_check()
1228 if (image_head->family_id != 0x91 || in cyapa_pip_fw_head_check()
1229 image_head->silicon_id_hi != 0x02) in cyapa_pip_fw_head_check()
1230 return -EINVAL; in cyapa_pip_fw_head_check()
1233 return -EINVAL; in cyapa_pip_fw_head_check()
1241 struct device *dev = &cyapa->client->dev; in cyapa_pip_check_fw()
1252 /* Verify the firmware image not miss-used for Gen5 and Gen6. */ in cyapa_pip_check_fw()
1254 (struct cyapa_tsg_bin_image_head *)fw->data)) { in cyapa_pip_check_fw()
1257 return -EINVAL; in cyapa_pip_check_fw()
1267 app_integrity = &image_records[flash_records_count - 1]; in cyapa_pip_check_fw()
1269 if (app_integrity->flash_array_id != 0x00 || in cyapa_pip_check_fw()
1270 get_unaligned_be16(&app_integrity->row_number) != 0x01ff) { in cyapa_pip_check_fw()
1272 return -EINVAL; in cyapa_pip_check_fw()
1275 metadata = (const void *)app_integrity->record_data; in cyapa_pip_check_fw()
1278 app_integrity_crc = crc_itu_t(0xffff, app_integrity->record_data, in cyapa_pip_check_fw()
1280 if (app_integrity_crc != get_unaligned_le16(&metadata->metadata_crc)) { in cyapa_pip_check_fw()
1282 return -EINVAL; in cyapa_pip_check_fw()
1285 fw_app_start = get_unaligned_le32(&metadata->app_start); in cyapa_pip_check_fw()
1286 fw_app_len = get_unaligned_le16(&metadata->app_len); in cyapa_pip_check_fw()
1287 fw_upgrade_start = get_unaligned_le32(&metadata->upgrade_start); in cyapa_pip_check_fw()
1288 fw_upgrade_len = get_unaligned_le16(&metadata->upgrade_len); in cyapa_pip_check_fw()
1295 return -EINVAL; in cyapa_pip_check_fw()
1306 if (app_crc != get_unaligned_le16(&metadata->app_crc)) { in cyapa_pip_check_fw()
1308 return -EINVAL; in cyapa_pip_check_fw()
1333 flash_array_id = flash_record->flash_array_id; in cyapa_pip_write_fw_block()
1334 flash_row_id = get_unaligned_be16(&flash_record->row_number); in cyapa_pip_write_fw_block()
1335 record_len = get_unaligned_be16(&flash_record->record_len); in cyapa_pip_write_fw_block()
1336 record_data = flash_record->record_data; in cyapa_pip_write_fw_block()
1340 bl_packet_start = &bl_cmd_head->packet_start; in cyapa_pip_write_fw_block()
1346 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &bl_cmd_head->addr); in cyapa_pip_write_fw_block()
1348 put_unaligned_le16(cmd_len - 2, &bl_cmd_head->length); in cyapa_pip_write_fw_block()
1349 bl_cmd_head->report_id = PIP_BL_CMD_REPORT_ID; in cyapa_pip_write_fw_block()
1350 bl_packet_start->sop = PIP_SOP_KEY; in cyapa_pip_write_fw_block()
1351 bl_packet_start->cmd_code = PIP_BL_CMD_PROGRAM_VERIFY_ROW; in cyapa_pip_write_fw_block()
1355 put_unaligned_le16(data_len, &bl_packet_start->data_length); in cyapa_pip_write_fw_block()
1357 flash_row_head = (struct tsg_bl_flash_row_head *)bl_cmd_head->data; in cyapa_pip_write_fw_block()
1358 flash_row_head->flash_array_id = flash_array_id; in cyapa_pip_write_fw_block()
1359 put_unaligned_le16(flash_row_id, &flash_row_head->flash_row_id); in cyapa_pip_write_fw_block()
1360 memcpy(flash_row_head->flash_data, record_data, record_len); in cyapa_pip_write_fw_block()
1362 bl_packet_end = (struct pip_bl_packet_end *)(bl_cmd_head->data + in cyapa_pip_write_fw_block()
1366 put_unaligned_le16(crc, &bl_packet_end->crc); in cyapa_pip_write_fw_block()
1367 bl_packet_end->eop = PIP_EOP_KEY; in cyapa_pip_write_fw_block()
1376 return error < 0 ? error : -EAGAIN; in cyapa_pip_write_fw_block()
1384 struct device *dev = &cyapa->client->dev; in cyapa_pip_do_fw_update()
1399 for (i = 0; i < (flash_records_count - 1); i++) { in cyapa_pip_do_fw_update()
1425 return error < 0 ? error : -EINVAL; in cyapa_gen5_change_power_state()
1445 app_cmd_head->parameter_data; in cyapa_gen5_set_interval_time()
1460 return -EINVAL; in cyapa_gen5_set_interval_time()
1463 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_set_interval_time()
1468 put_unaligned_le16(cmd_len - (4 - parameter_size) - 2, in cyapa_gen5_set_interval_time()
1469 &app_cmd_head->length); in cyapa_gen5_set_interval_time()
1470 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_set_interval_time()
1471 app_cmd_head->cmd_code = GEN5_CMD_SET_PARAMETER; in cyapa_gen5_set_interval_time()
1472 parameter_data->parameter_id = parameter_id; in cyapa_gen5_set_interval_time()
1473 parameter_data->parameter_size = parameter_size; in cyapa_gen5_set_interval_time()
1474 put_unaligned_le32((u32)interval_time, &parameter_data->value); in cyapa_gen5_set_interval_time()
1482 return error < 0 ? error : -EINVAL; in cyapa_gen5_set_interval_time()
1503 app_cmd_head->parameter_data; in cyapa_gen5_get_interval_time()
1519 return -EINVAL; in cyapa_gen5_get_interval_time()
1522 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_get_interval_time()
1524 put_unaligned_le16(cmd_len - 2, &app_cmd_head->length); in cyapa_gen5_get_interval_time()
1525 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_get_interval_time()
1526 app_cmd_head->cmd_code = GEN5_CMD_GET_PARAMETER; in cyapa_gen5_get_interval_time()
1527 parameter_data->parameter_id = parameter_id; in cyapa_gen5_get_interval_time()
1535 return error < 0 ? error : -EINVAL; in cyapa_gen5_get_interval_time()
1556 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_disable_pip_report()
1557 put_unaligned_le16(sizeof(cmd) - 2, &app_cmd_head->length); in cyapa_gen5_disable_pip_report()
1558 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_disable_pip_report()
1559 app_cmd_head->cmd_code = GEN5_CMD_SET_PARAMETER; in cyapa_gen5_disable_pip_report()
1560 app_cmd_head->parameter_data[0] = GEN5_PARAMETER_DISABLE_PIP_REPORT; in cyapa_gen5_disable_pip_report()
1561 app_cmd_head->parameter_data[1] = 0x01; in cyapa_gen5_disable_pip_report()
1562 app_cmd_head->parameter_data[2] = 0x01; in cyapa_gen5_disable_pip_report()
1570 return error < 0 ? error : -EINVAL; in cyapa_gen5_disable_pip_report()
1590 error = (error == -ETIMEDOUT) ? -EOPNOTSUPP : error; in cyapa_pip_set_proximity()
1591 return error < 0 ? error : -EINVAL; in cyapa_pip_set_proximity()
1610 return -EINVAL; in cyapa_pip_deep_sleep()
1618 struct device *dev = &cyapa->client->dev; in cyapa_gen5_set_power_mode()
1622 if (cyapa->state != CYAPA_STATE_GEN5_APP) in cyapa_gen5_set_power_mode()
1629 * Assume TP in deep sleep mode when driver is loaded, in cyapa_gen5_set_power_mode()
1631 * has been set into deep sleep mode when unloading. in cyapa_gen5_set_power_mode()
1640 &cyapa->dev_sleep_time) != 0) in cyapa_gen5_set_power_mode()
1656 dev_err(dev, "enter deep sleep fail: %d\n", error); in cyapa_gen5_set_power_mode()
1672 dev_err(dev, "deep sleep wake fail: %d\n", error); in cyapa_gen5_set_power_mode()
1721 * re-enable it automatically. It's used to fix the issue in cyapa_gen5_set_power_mode()
1724 * at the same time, user touch trackpad to wake system up. in cyapa_gen5_set_power_mode()
1757 return -EINVAL; in cyapa_pip_resume_scanning()
1781 return -EINVAL; in cyapa_pip_suspend_scanning()
1803 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_pip_calibrate_pwcs()
1804 put_unaligned_le16(sizeof(cmd) - 2, &app_cmd_head->length); in cyapa_pip_calibrate_pwcs()
1805 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_pip_calibrate_pwcs()
1806 app_cmd_head->cmd_code = PIP_CMD_CALIBRATE; in cyapa_pip_calibrate_pwcs()
1807 app_cmd_head->parameter_data[0] = calibrate_sensing_mode_type; in cyapa_pip_calibrate_pwcs()
1815 return error < 0 ? error : -EAGAIN; in cyapa_pip_calibrate_pwcs()
1855 if (value >> (num_bits - 1)) in twos_complement_to_s32()
1856 value |= -1 << num_bits; in twos_complement_to_s32()
1905 if (cyapa->electrodes_rx != 0) { in cyapa_gen5_guess_electrodes()
1906 *electrodes_rx = cyapa->electrodes_rx; in cyapa_gen5_guess_electrodes()
1907 *electrodes_tx = (cyapa->electrodes_x == *electrodes_rx) ? in cyapa_gen5_guess_electrodes()
1908 cyapa->electrodes_y : cyapa->electrodes_x; in cyapa_gen5_guess_electrodes()
1910 *electrodes_tx = min(cyapa->electrodes_x, cyapa->electrodes_y); in cyapa_gen5_guess_electrodes()
1911 *electrodes_rx = max(cyapa->electrodes_x, cyapa->electrodes_y); in cyapa_gen5_guess_electrodes()
1956 return -EINVAL; in cyapa_gen5_read_idac_data()
1975 if (cyapa->aligned_electrodes_rx == 0) { in cyapa_gen5_read_idac_data()
1978 cyapa->aligned_electrodes_rx = in cyapa_gen5_read_idac_data()
1982 (cyapa->aligned_electrodes_rx + 7) & ~7u; in cyapa_gen5_read_idac_data()
1992 offset = cyapa->aligned_electrodes_rx * (*data_size); in cyapa_gen5_read_idac_data()
1993 if (cyapa->electrodes_rx == cyapa->electrodes_x) in cyapa_gen5_read_idac_data()
1994 electrodes_tx = cyapa->electrodes_y; in cyapa_gen5_read_idac_data()
1996 electrodes_tx = cyapa->electrodes_x; in cyapa_gen5_read_idac_data()
1997 max_element_cnt = ((cyapa->aligned_electrodes_rx + 7) & in cyapa_gen5_read_idac_data()
2001 max_element_cnt = cyapa->electrodes_x + in cyapa_gen5_read_idac_data()
2002 cyapa->electrodes_y; in cyapa_gen5_read_idac_data()
2009 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &cmd_head->addr); in cyapa_gen5_read_idac_data()
2010 put_unaligned_le16(sizeof(cmd) - 2, &cmd_head->length); in cyapa_gen5_read_idac_data()
2011 cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_read_idac_data()
2012 cmd_head->cmd_code = cmd_code; in cyapa_gen5_read_idac_data()
2014 read_elements = (256 - GEN5_RESP_DATA_STRUCTURE_OFFSET) / in cyapa_gen5_read_idac_data()
2016 read_elements = min(read_elements, max_element_cnt - count); in cyapa_gen5_read_idac_data()
2019 put_unaligned_le16(offset, &cmd_head->parameter_data[0]); in cyapa_gen5_read_idac_data()
2020 put_unaligned_le16(read_len, &cmd_head->parameter_data[2]); in cyapa_gen5_read_idac_data()
2021 cmd_head->parameter_data[4] = idac_data_type; in cyapa_gen5_read_idac_data()
2032 return (error < 0) ? error : -EAGAIN; in cyapa_gen5_read_idac_data()
2039 return -EINVAL; in cyapa_gen5_read_idac_data()
2067 tmp_count < cyapa->aligned_electrodes_rx && in cyapa_gen5_read_idac_data()
2101 if (tmp_count == cyapa->aligned_electrodes_rx) { in cyapa_gen5_read_idac_data()
2102 cyapa->electrodes_rx = cyapa->electrodes_rx ? in cyapa_gen5_read_idac_data()
2103 cyapa->electrodes_rx : electrodes_rx; in cyapa_gen5_read_idac_data()
2105 cyapa->electrodes_rx = cyapa->electrodes_rx ? in cyapa_gen5_read_idac_data()
2106 cyapa->electrodes_rx : electrodes_rx; in cyapa_gen5_read_idac_data()
2107 cyapa->aligned_electrodes_rx = electrodes_rx; in cyapa_gen5_read_idac_data()
2109 cyapa->electrodes_rx = cyapa->electrodes_rx ? in cyapa_gen5_read_idac_data()
2110 cyapa->electrodes_rx : electrodes_tx; in cyapa_gen5_read_idac_data()
2111 cyapa->aligned_electrodes_rx = tmp_count; in cyapa_gen5_read_idac_data()
2188 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_execute_panel_scan()
2189 put_unaligned_le16(sizeof(cmd) - 2, &app_cmd_head->length); in cyapa_gen5_execute_panel_scan()
2190 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_execute_panel_scan()
2191 app_cmd_head->cmd_code = GEN5_CMD_EXECUTE_PANEL_SCAN; in cyapa_gen5_execute_panel_scan()
2201 return error ? error : -EAGAIN; in cyapa_gen5_execute_panel_scan()
2229 return -EINVAL; in cyapa_gen5_read_panel_scan_raw_data()
2237 read_elements = (256 - GEN5_RESP_DATA_STRUCTURE_OFFSET) / 4; in cyapa_gen5_read_panel_scan_raw_data()
2240 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_read_panel_scan_raw_data()
2241 put_unaligned_le16(sizeof(cmd) - 2, &app_cmd_head->length); in cyapa_gen5_read_panel_scan_raw_data()
2242 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_read_panel_scan_raw_data()
2243 app_cmd_head->cmd_code = cmd_code; in cyapa_gen5_read_panel_scan_raw_data()
2245 app_cmd_head->parameter_data; in cyapa_gen5_read_panel_scan_raw_data()
2247 put_unaligned_le16(offset, &panel_sacn_data->read_offset); in cyapa_gen5_read_panel_scan_raw_data()
2249 &panel_sacn_data->read_elements); in cyapa_gen5_read_panel_scan_raw_data()
2250 panel_sacn_data->data_id = raw_data_type; in cyapa_gen5_read_panel_scan_raw_data()
2261 return error ? error : -EAGAIN; in cyapa_gen5_read_panel_scan_raw_data()
2291 read_elements = (sizeof(resp_data) - in cyapa_gen5_read_panel_scan_raw_data()
2319 return -EBUSY; in cyapa_gen5_show_baseline()
2352 cyapa->electrodes_x * cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2363 cyapa->electrodes_x + cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2374 cyapa->electrodes_x * cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2385 cyapa->electrodes_x + cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2396 cyapa->electrodes_x * cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2407 cyapa->electrodes_x + cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2460 return error ? error : -EIO; in cyapa_gen5_bl_query_data()
2462 memcpy(&cyapa->product_id[0], &resp_data[8], 5); in cyapa_gen5_bl_query_data()
2463 cyapa->product_id[5] = '-'; in cyapa_gen5_bl_query_data()
2464 memcpy(&cyapa->product_id[6], &resp_data[13], 6); in cyapa_gen5_bl_query_data()
2465 cyapa->product_id[12] = '-'; in cyapa_gen5_bl_query_data()
2466 memcpy(&cyapa->product_id[13], &resp_data[19], 2); in cyapa_gen5_bl_query_data()
2467 cyapa->product_id[15] = '\0'; in cyapa_gen5_bl_query_data()
2469 cyapa->fw_maj_ver = resp_data[22]; in cyapa_gen5_bl_query_data()
2470 cyapa->fw_min_ver = resp_data[23]; in cyapa_gen5_bl_query_data()
2472 cyapa->platform_ver = (resp_data[26] >> PIP_BL_PLATFORM_VER_SHIFT) & in cyapa_gen5_bl_query_data()
2491 return error ? error : -EIO; in cyapa_gen5_get_query_data()
2496 return -EINVAL; in cyapa_gen5_get_query_data()
2498 cyapa->platform_ver = (resp_data[49] >> PIP_BL_PLATFORM_VER_SHIFT) & in cyapa_gen5_get_query_data()
2500 if (cyapa->gen == CYAPA_GEN5 && cyapa->platform_ver < 2) { in cyapa_gen5_get_query_data()
2502 cyapa->fw_maj_ver = resp_data[15]; in cyapa_gen5_get_query_data()
2503 cyapa->fw_min_ver = resp_data[16]; in cyapa_gen5_get_query_data()
2505 cyapa->fw_maj_ver = resp_data[9]; in cyapa_gen5_get_query_data()
2506 cyapa->fw_min_ver = resp_data[10]; in cyapa_gen5_get_query_data()
2509 cyapa->electrodes_x = resp_data[52]; in cyapa_gen5_get_query_data()
2510 cyapa->electrodes_y = resp_data[53]; in cyapa_gen5_get_query_data()
2512 cyapa->physical_size_x = get_unaligned_le16(&resp_data[54]) / 100; in cyapa_gen5_get_query_data()
2513 cyapa->physical_size_y = get_unaligned_le16(&resp_data[56]) / 100; in cyapa_gen5_get_query_data()
2515 cyapa->max_abs_x = get_unaligned_le16(&resp_data[58]); in cyapa_gen5_get_query_data()
2516 cyapa->max_abs_y = get_unaligned_le16(&resp_data[60]); in cyapa_gen5_get_query_data()
2518 cyapa->max_z = get_unaligned_le16(&resp_data[62]); in cyapa_gen5_get_query_data()
2520 cyapa->x_origin = resp_data[64] & 0x01; in cyapa_gen5_get_query_data()
2521 cyapa->y_origin = resp_data[65] & 0x01; in cyapa_gen5_get_query_data()
2523 cyapa->btn_capability = (resp_data[70] << 3) & CAPABILITY_BTN_MASK; in cyapa_gen5_get_query_data()
2525 memcpy(&cyapa->product_id[0], &resp_data[33], 5); in cyapa_gen5_get_query_data()
2526 cyapa->product_id[5] = '-'; in cyapa_gen5_get_query_data()
2527 memcpy(&cyapa->product_id[6], &resp_data[38], 6); in cyapa_gen5_get_query_data()
2528 cyapa->product_id[12] = '-'; in cyapa_gen5_get_query_data()
2529 memcpy(&cyapa->product_id[13], &resp_data[44], 2); in cyapa_gen5_get_query_data()
2530 cyapa->product_id[15] = '\0'; in cyapa_gen5_get_query_data()
2532 if (!cyapa->electrodes_x || !cyapa->electrodes_y || in cyapa_gen5_get_query_data()
2533 !cyapa->physical_size_x || !cyapa->physical_size_y || in cyapa_gen5_get_query_data()
2534 !cyapa->max_abs_x || !cyapa->max_abs_y || !cyapa->max_z) in cyapa_gen5_get_query_data()
2535 return -EINVAL; in cyapa_gen5_get_query_data()
2542 struct device *dev = &cyapa->client->dev; in cyapa_gen5_do_operational_check()
2545 if (cyapa->gen != CYAPA_GEN5) in cyapa_gen5_do_operational_check()
2546 return -ENODEV; in cyapa_gen5_do_operational_check()
2548 switch (cyapa->state) { in cyapa_gen5_do_operational_check()
2557 cyapa->state = CYAPA_STATE_GEN5_APP; in cyapa_gen5_do_operational_check()
2562 * If trackpad device in deep sleep mode, in cyapa_gen5_do_operational_check()
2574 if (cyapa->platform_ver >= 2) { in cyapa_gen5_do_operational_check()
2587 if (memcmp(cyapa->product_id, product_id, in cyapa_gen5_do_operational_check()
2590 __func__, cyapa->product_id); in cyapa_gen5_do_operational_check()
2591 error = -EINVAL; in cyapa_gen5_do_operational_check()
2595 error = -EINVAL; in cyapa_gen5_do_operational_check()
2608 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_pip_irq_cmd_handler()
2611 if (atomic_read(&pip->cmd_issued)) { in cyapa_pip_irq_cmd_handler()
2613 if (pip->is_irq_mode == false) in cyapa_pip_irq_cmd_handler()
2621 cyapa_i2c_pip_read(cyapa, pip->irq_cmd_buf, in cyapa_pip_irq_cmd_handler()
2623 length = get_unaligned_le16(pip->irq_cmd_buf); in cyapa_pip_irq_cmd_handler()
2628 pip->irq_cmd_buf, length); in cyapa_pip_irq_cmd_handler()
2629 if (!(pip->resp_sort_func && in cyapa_pip_irq_cmd_handler()
2630 pip->resp_sort_func(cyapa, in cyapa_pip_irq_cmd_handler()
2631 pip->irq_cmd_buf, length))) { in cyapa_pip_irq_cmd_handler()
2636 * ready event. Because when there was a finger touch in cyapa_pip_irq_cmd_handler()
2638 * won't be empty (always with touch report data), so in cyapa_pip_irq_cmd_handler()
2646 if (pip->resp_len) in cyapa_pip_irq_cmd_handler()
2647 length = *pip->resp_len; in cyapa_pip_irq_cmd_handler()
2649 pip->resp_data, in cyapa_pip_irq_cmd_handler()
2651 pip->resp_sort_func); in cyapa_pip_irq_cmd_handler()
2652 if (pip->resp_len && length != 0) { in cyapa_pip_irq_cmd_handler()
2653 *pip->resp_len = length; in cyapa_pip_irq_cmd_handler()
2654 atomic_dec(&pip->cmd_issued); in cyapa_pip_irq_cmd_handler()
2655 complete(&pip->cmd_ready); in cyapa_pip_irq_cmd_handler()
2660 if (pip->resp_data && pip->resp_len) { in cyapa_pip_irq_cmd_handler()
2661 *pip->resp_len = (*pip->resp_len < length) ? in cyapa_pip_irq_cmd_handler()
2662 *pip->resp_len : length; in cyapa_pip_irq_cmd_handler()
2663 memcpy(pip->resp_data, pip->irq_cmd_buf, in cyapa_pip_irq_cmd_handler()
2664 *pip->resp_len); in cyapa_pip_irq_cmd_handler()
2666 atomic_dec(&pip->cmd_issued); in cyapa_pip_irq_cmd_handler()
2667 complete(&pip->cmd_ready); in cyapa_pip_irq_cmd_handler()
2677 struct input_dev *input = cyapa->input; in cyapa_pip_report_buttons()
2678 u8 buttons = report_data->report_head[PIP_BUTTONS_OFFSET]; in cyapa_pip_report_buttons()
2682 if (cyapa->btn_capability & CAPABILITY_LEFT_BTN_MASK) { in cyapa_pip_report_buttons()
2686 if (cyapa->btn_capability & CAPABILITY_MIDDLE_BTN_MASK) { in cyapa_pip_report_buttons()
2690 if (cyapa->btn_capability & CAPABILITY_RIGHT_BTN_MASK) { in cyapa_pip_report_buttons()
2701 struct input_dev *input = cyapa->input; in cyapa_pip_report_proximity()
2702 u8 distance = report_data->report_head[PIP_PROXIMITY_DISTANCE_OFFSET] & in cyapa_pip_report_proximity()
2710 const struct cyapa_pip_touch_record *touch) in cyapa_pip_report_slot_data() argument
2712 struct input_dev *input = cyapa->input; in cyapa_pip_report_slot_data()
2713 u8 event_id = PIP_GET_EVENT_ID(touch->touch_tip_event_id); in cyapa_pip_report_slot_data()
2714 int slot = PIP_GET_TOUCH_ID(touch->touch_tip_event_id); in cyapa_pip_report_slot_data()
2722 x = (touch->x_hi << 8) | touch->x_lo; in cyapa_pip_report_slot_data()
2723 if (cyapa->x_origin) in cyapa_pip_report_slot_data()
2724 x = cyapa->max_abs_x - x; in cyapa_pip_report_slot_data()
2725 y = (touch->y_hi << 8) | touch->y_lo; in cyapa_pip_report_slot_data()
2726 if (cyapa->y_origin) in cyapa_pip_report_slot_data()
2727 y = cyapa->max_abs_y - y; in cyapa_pip_report_slot_data()
2732 touch->z); in cyapa_pip_report_slot_data()
2734 touch->major_axis_len); in cyapa_pip_report_slot_data()
2736 touch->minor_axis_len); in cyapa_pip_report_slot_data()
2739 touch->major_tool_len); in cyapa_pip_report_slot_data()
2741 touch->minor_tool_len); in cyapa_pip_report_slot_data()
2744 touch->orientation); in cyapa_pip_report_slot_data()
2750 struct input_dev *input = cyapa->input; in cyapa_pip_report_touches()
2754 touch_num = report_data->report_head[PIP_NUMBER_OF_TOUCH_OFFSET] & in cyapa_pip_report_touches()
2759 &report_data->touch_records[i]); in cyapa_pip_report_touches()
2767 struct device *dev = &cyapa->client->dev; in cyapa_pip_irq_handler()
2774 cyapa->gen, cyapa->state); in cyapa_pip_irq_handler()
2775 return -EINVAL; in cyapa_pip_irq_handler()
2782 return -EINVAL; in cyapa_pip_irq_handler()
2792 return -EINVAL; in cyapa_pip_irq_handler()
2803 return -EINVAL; in cyapa_pip_irq_handler()
2812 struct device *dev = &cyapa->client->dev; in cyapa_pip_event_process()
2817 &report_data->report_head[PIP_RESP_LENGTH_OFFSET]); in cyapa_pip_event_process()
2822 report_id = report_data->report_head[PIP_RESP_REPORT_ID_OFFSET]; in cyapa_pip_event_process()
2826 * Device wake event from deep sleep mode for touch. in cyapa_pip_event_process()
2831 * time in receiving for first valid touch report data. in cyapa_pip_event_process()
2846 return -EINVAL; in cyapa_pip_event_process()
2853 dev_err(dev, "invalid touch packet length=%d\n", report_len); in cyapa_pip_event_process()