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 && input && input->users && in cyapa_empty_pip_output_data()
526 (struct cyapa_pip_report_data *)pip->empty_buf); in cyapa_empty_pip_output_data()
529 error = -EINVAL; in cyapa_empty_pip_output_data()
540 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_do_i2c_pip_cmd_irq_sync()
544 init_completion(&pip->cmd_ready); in cyapa_do_i2c_pip_cmd_irq_sync()
546 atomic_inc(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_irq_sync()
549 atomic_dec(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_irq_sync()
550 return (error < 0) ? error : -EIO; in cyapa_do_i2c_pip_cmd_irq_sync()
554 timeout = wait_for_completion_timeout(&pip->cmd_ready, in cyapa_do_i2c_pip_cmd_irq_sync()
557 atomic_dec(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_irq_sync()
558 return -ETIMEDOUT; in cyapa_do_i2c_pip_cmd_irq_sync()
571 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_do_i2c_pip_cmd_polling()
576 atomic_inc(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_polling()
579 atomic_dec(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_polling()
580 return error < 0 ? error : -EIO; in cyapa_do_i2c_pip_cmd_polling()
595 } while (--tries > 0); in cyapa_do_i2c_pip_cmd_polling()
597 error = error ? error : -ETIMEDOUT; in cyapa_do_i2c_pip_cmd_polling()
600 atomic_dec(&pip->cmd_issued); in cyapa_do_i2c_pip_cmd_polling()
612 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_i2c_pip_cmd_irq_sync()
616 return -EINVAL; in cyapa_i2c_pip_cmd_irq_sync()
619 error = mutex_lock_interruptible(&pip->cmd_lock); in cyapa_i2c_pip_cmd_irq_sync()
623 pip->resp_sort_func = func; in cyapa_i2c_pip_cmd_irq_sync()
624 pip->resp_data = resp_data; in cyapa_i2c_pip_cmd_irq_sync()
625 pip->resp_len = resp_len; in cyapa_i2c_pip_cmd_irq_sync()
630 pip->in_progress_cmd = cmd[6] & 0x7f; in cyapa_i2c_pip_cmd_irq_sync()
634 pip->in_progress_cmd = cmd[7]; in cyapa_i2c_pip_cmd_irq_sync()
639 pip->is_irq_mode = true; in cyapa_i2c_pip_cmd_irq_sync()
642 if (error == -ETIMEDOUT && resp_data && in cyapa_i2c_pip_cmd_irq_sync()
652 error = error ? error : -ETIMEDOUT; in cyapa_i2c_pip_cmd_irq_sync()
655 pip->is_irq_mode = false; in cyapa_i2c_pip_cmd_irq_sync()
660 pip->resp_sort_func = NULL; in cyapa_i2c_pip_cmd_irq_sync()
661 pip->resp_data = NULL; in cyapa_i2c_pip_cmd_irq_sync()
662 pip->resp_len = NULL; in cyapa_i2c_pip_cmd_irq_sync()
663 pip->in_progress_cmd = PIP_INVALID_CMD; in cyapa_i2c_pip_cmd_irq_sync()
665 mutex_unlock(&pip->cmd_lock); in cyapa_i2c_pip_cmd_irq_sync()
687 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_sort_tsg_pip_app_resp_data()
698 data[5] == pip->in_progress_cmd) { in cyapa_sort_tsg_pip_app_resp_data()
702 pip->in_progress_cmd) { in cyapa_sort_tsg_pip_app_resp_data()
785 return ret < 0 ? ret : -EIO; in gen5_idle_state_parse()
790 cyapa->gen = CYAPA_GEN5; in gen5_idle_state_parse()
816 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_idle_state_parse()
823 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_idle_state_parse()
826 cyapa->state = CYAPA_STATE_NO_DEVICE; in gen5_idle_state_parse()
845 * or report any touch or button data. in gen5_hid_description_header_parse()
850 return ret < 0 ? ret : -EIO; in gen5_hid_description_header_parse()
860 cyapa->gen = CYAPA_GEN5; in gen5_hid_description_header_parse()
861 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_hid_description_header_parse()
867 cyapa->gen = CYAPA_GEN5; in gen5_hid_description_header_parse()
868 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_hid_description_header_parse()
874 cyapa->gen = CYAPA_GEN5; in gen5_hid_description_header_parse()
875 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_hid_description_header_parse()
881 cyapa->gen = CYAPA_GEN5; in gen5_hid_description_header_parse()
882 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_hid_description_header_parse()
885 cyapa->state = CYAPA_STATE_NO_DEVICE; in gen5_hid_description_header_parse()
900 return -EINVAL; in gen5_report_data_header_parse()
907 return -EINVAL; in gen5_report_data_header_parse()
911 return -EINVAL; in gen5_report_data_header_parse()
914 return -EINVAL; in gen5_report_data_header_parse()
917 cyapa->gen = CYAPA_GEN5; in gen5_report_data_header_parse()
918 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_report_data_header_parse()
924 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in gen5_cmd_resp_header_parse()
931 * or report any touch or button data. in gen5_cmd_resp_header_parse()
934 ret = cyapa_i2c_pip_read(cyapa, pip->empty_buf, length); in gen5_cmd_resp_header_parse()
936 return ret < 0 ? ret : -EIO; in gen5_cmd_resp_header_parse()
943 cyapa->gen = CYAPA_GEN5; in gen5_cmd_resp_header_parse()
944 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_cmd_resp_header_parse()
947 cyapa->gen = CYAPA_GEN5; in gen5_cmd_resp_header_parse()
948 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_cmd_resp_header_parse()
950 } else if ((pip->empty_buf[PIP_RESP_REPORT_ID_OFFSET] == in gen5_cmd_resp_header_parse()
952 (pip->empty_buf[PIP_RESP_RSVD_OFFSET] == in gen5_cmd_resp_header_parse()
954 (pip->empty_buf[PIP_RESP_BL_SOP_OFFSET] == in gen5_cmd_resp_header_parse()
956 (pip->empty_buf[length - 1] == in gen5_cmd_resp_header_parse()
959 cyapa->gen = CYAPA_GEN5; in gen5_cmd_resp_header_parse()
960 cyapa->state = CYAPA_STATE_GEN5_BL; in gen5_cmd_resp_header_parse()
961 } else if (pip->empty_buf[PIP_RESP_REPORT_ID_OFFSET] == in gen5_cmd_resp_header_parse()
963 pip->empty_buf[PIP_RESP_RSVD_OFFSET] == in gen5_cmd_resp_header_parse()
966 cyapa->gen = CYAPA_GEN5; in gen5_cmd_resp_header_parse()
967 cyapa->state = CYAPA_STATE_GEN5_APP; in gen5_cmd_resp_header_parse()
970 cyapa->state = CYAPA_STATE_NO_DEVICE; in gen5_cmd_resp_header_parse()
981 return -EINVAL; in cyapa_gen5_state_parse()
983 cyapa->state = CYAPA_STATE_NO_DEVICE; in cyapa_gen5_state_parse()
997 cyapa->gen = CYAPA_GEN5; in cyapa_gen5_state_parse()
998 cyapa->state = CYAPA_STATE_GEN5_APP; in cyapa_gen5_state_parse()
1002 cyapa->gen = CYAPA_GEN5; in cyapa_gen5_state_parse()
1003 cyapa->state = CYAPA_STATE_GEN5_BL; in cyapa_gen5_state_parse()
1015 if (cyapa->gen == CYAPA_GEN5) { in cyapa_gen5_state_parse()
1020 * report any touch or button data later. in cyapa_gen5_state_parse()
1024 if (cyapa->state == CYAPA_STATE_GEN5_APP || in cyapa_gen5_state_parse()
1025 cyapa->state == CYAPA_STATE_GEN5_BL) in cyapa_gen5_state_parse()
1029 return -EAGAIN; in cyapa_gen5_state_parse()
1038 head_size = fw->data[0] + 1; in cyapa_get_image_record_data_num()
1039 *record_num = (fw->size - head_size) / in cyapa_get_image_record_data_num()
1041 return (struct cyapa_tsg_bin_image_data_record *)&fw->data[head_size]; in cyapa_get_image_record_data_num()
1071 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &bl_cmd_head->addr); in cyapa_pip_bl_initiate()
1072 put_unaligned_le16(cmd_len - 2, &bl_cmd_head->length); in cyapa_pip_bl_initiate()
1073 bl_cmd_head->report_id = PIP_BL_CMD_REPORT_ID; in cyapa_pip_bl_initiate()
1075 bl_packet_start = &bl_cmd_head->packet_start; in cyapa_pip_bl_initiate()
1076 bl_packet_start->sop = PIP_SOP_KEY; in cyapa_pip_bl_initiate()
1077 bl_packet_start->cmd_code = PIP_BL_CMD_INITIATE_BL; in cyapa_pip_bl_initiate()
1079 put_unaligned_le16(cmd_data_len, &bl_packet_start->data_length); in cyapa_pip_bl_initiate()
1081 cmd_data = (struct pip_bl_initiate_cmd_data *)bl_cmd_head->data; in cyapa_pip_bl_initiate()
1082 memcpy(cmd_data->key, cyapa_pip_bl_cmd_key, CYAPA_TSG_BL_KEY_SIZE); in cyapa_pip_bl_initiate()
1087 data = image_records[records_num - 1].record_data; in cyapa_pip_bl_initiate()
1088 memcpy(cmd_data->metadata_raw_parameter, data, in cyapa_pip_bl_initiate()
1091 meta_data_crc = crc_itu_t(0xffff, cmd_data->metadata_raw_parameter, in cyapa_pip_bl_initiate()
1093 put_unaligned_le16(meta_data_crc, &cmd_data->metadata_crc); in cyapa_pip_bl_initiate()
1095 bl_packet_end = (struct pip_bl_packet_end *)(bl_cmd_head->data + in cyapa_pip_bl_initiate()
1099 put_unaligned_le16(cmd_crc, &bl_packet_end->crc); in cyapa_pip_bl_initiate()
1100 bl_packet_end->eop = PIP_EOP_KEY; in cyapa_pip_bl_initiate()
1110 return error ? error : -EAGAIN; in cyapa_pip_bl_initiate()
1157 return -EAGAIN; in cyapa_pip_bl_exit()
1162 return -ENODEV; in cyapa_pip_bl_exit()
1180 return -EINVAL; in cyapa_pip_bl_enter()
1197 return error < 0 ? error : -EAGAIN; in cyapa_pip_bl_enter()
1199 cyapa->operational = false; in cyapa_pip_bl_enter()
1200 if (cyapa->gen == CYAPA_GEN5) in cyapa_pip_bl_enter()
1201 cyapa->state = CYAPA_STATE_GEN5_BL; in cyapa_pip_bl_enter()
1202 else if (cyapa->gen == CYAPA_GEN6) in cyapa_pip_bl_enter()
1203 cyapa->state = CYAPA_STATE_GEN6_BL; in cyapa_pip_bl_enter()
1210 if (image_head->head_size != 0x0C && image_head->head_size != 0x12) in cyapa_pip_fw_head_check()
1211 return -EINVAL; in cyapa_pip_fw_head_check()
1213 switch (cyapa->gen) { in cyapa_pip_fw_head_check()
1215 if (image_head->family_id != 0x9B || in cyapa_pip_fw_head_check()
1216 image_head->silicon_id_hi != 0x0B) in cyapa_pip_fw_head_check()
1217 return -EINVAL; in cyapa_pip_fw_head_check()
1221 if (cyapa->platform_ver < 2) { in cyapa_pip_fw_head_check()
1222 if (image_head->head_size == 0x0C) in cyapa_pip_fw_head_check()
1224 return -EINVAL; in cyapa_pip_fw_head_check()
1227 if (image_head->family_id != 0x91 || in cyapa_pip_fw_head_check()
1228 image_head->silicon_id_hi != 0x02) in cyapa_pip_fw_head_check()
1229 return -EINVAL; in cyapa_pip_fw_head_check()
1232 return -EINVAL; in cyapa_pip_fw_head_check()
1240 struct device *dev = &cyapa->client->dev; in cyapa_pip_check_fw()
1251 /* Verify the firmware image not miss-used for Gen5 and Gen6. */ in cyapa_pip_check_fw()
1253 (struct cyapa_tsg_bin_image_head *)fw->data)) { in cyapa_pip_check_fw()
1256 return -EINVAL; in cyapa_pip_check_fw()
1266 app_integrity = &image_records[flash_records_count - 1]; in cyapa_pip_check_fw()
1268 if (app_integrity->flash_array_id != 0x00 || in cyapa_pip_check_fw()
1269 get_unaligned_be16(&app_integrity->row_number) != 0x01ff) { in cyapa_pip_check_fw()
1271 return -EINVAL; in cyapa_pip_check_fw()
1274 metadata = (const void *)app_integrity->record_data; in cyapa_pip_check_fw()
1277 app_integrity_crc = crc_itu_t(0xffff, app_integrity->record_data, in cyapa_pip_check_fw()
1279 if (app_integrity_crc != get_unaligned_le16(&metadata->metadata_crc)) { in cyapa_pip_check_fw()
1281 return -EINVAL; in cyapa_pip_check_fw()
1284 fw_app_start = get_unaligned_le32(&metadata->app_start); in cyapa_pip_check_fw()
1285 fw_app_len = get_unaligned_le16(&metadata->app_len); in cyapa_pip_check_fw()
1286 fw_upgrade_start = get_unaligned_le32(&metadata->upgrade_start); in cyapa_pip_check_fw()
1287 fw_upgrade_len = get_unaligned_le16(&metadata->upgrade_len); in cyapa_pip_check_fw()
1294 return -EINVAL; in cyapa_pip_check_fw()
1305 if (app_crc != get_unaligned_le16(&metadata->app_crc)) { in cyapa_pip_check_fw()
1307 return -EINVAL; in cyapa_pip_check_fw()
1332 flash_array_id = flash_record->flash_array_id; in cyapa_pip_write_fw_block()
1333 flash_row_id = get_unaligned_be16(&flash_record->row_number); in cyapa_pip_write_fw_block()
1334 record_len = get_unaligned_be16(&flash_record->record_len); in cyapa_pip_write_fw_block()
1335 record_data = flash_record->record_data; in cyapa_pip_write_fw_block()
1339 bl_packet_start = &bl_cmd_head->packet_start; in cyapa_pip_write_fw_block()
1345 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &bl_cmd_head->addr); in cyapa_pip_write_fw_block()
1347 put_unaligned_le16(cmd_len - 2, &bl_cmd_head->length); in cyapa_pip_write_fw_block()
1348 bl_cmd_head->report_id = PIP_BL_CMD_REPORT_ID; in cyapa_pip_write_fw_block()
1349 bl_packet_start->sop = PIP_SOP_KEY; in cyapa_pip_write_fw_block()
1350 bl_packet_start->cmd_code = PIP_BL_CMD_PROGRAM_VERIFY_ROW; in cyapa_pip_write_fw_block()
1354 put_unaligned_le16(data_len, &bl_packet_start->data_length); in cyapa_pip_write_fw_block()
1356 flash_row_head = (struct tsg_bl_flash_row_head *)bl_cmd_head->data; in cyapa_pip_write_fw_block()
1357 flash_row_head->flash_array_id = flash_array_id; in cyapa_pip_write_fw_block()
1358 put_unaligned_le16(flash_row_id, &flash_row_head->flash_row_id); in cyapa_pip_write_fw_block()
1359 memcpy(flash_row_head->flash_data, record_data, record_len); in cyapa_pip_write_fw_block()
1361 bl_packet_end = (struct pip_bl_packet_end *)(bl_cmd_head->data + in cyapa_pip_write_fw_block()
1365 put_unaligned_le16(crc, &bl_packet_end->crc); in cyapa_pip_write_fw_block()
1366 bl_packet_end->eop = PIP_EOP_KEY; in cyapa_pip_write_fw_block()
1375 return error < 0 ? error : -EAGAIN; in cyapa_pip_write_fw_block()
1383 struct device *dev = &cyapa->client->dev; in cyapa_pip_do_fw_update()
1398 for (i = 0; i < (flash_records_count - 1); i++) { in cyapa_pip_do_fw_update()
1424 return error < 0 ? error : -EINVAL; in cyapa_gen5_change_power_state()
1444 app_cmd_head->parameter_data; in cyapa_gen5_set_interval_time()
1459 return -EINVAL; in cyapa_gen5_set_interval_time()
1462 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_set_interval_time()
1467 put_unaligned_le16(cmd_len - (4 - parameter_size) - 2, in cyapa_gen5_set_interval_time()
1468 &app_cmd_head->length); in cyapa_gen5_set_interval_time()
1469 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_set_interval_time()
1470 app_cmd_head->cmd_code = GEN5_CMD_SET_PARAMETER; in cyapa_gen5_set_interval_time()
1471 parameter_data->parameter_id = parameter_id; in cyapa_gen5_set_interval_time()
1472 parameter_data->parameter_size = parameter_size; in cyapa_gen5_set_interval_time()
1473 put_unaligned_le32((u32)interval_time, &parameter_data->value); in cyapa_gen5_set_interval_time()
1481 return error < 0 ? error : -EINVAL; in cyapa_gen5_set_interval_time()
1502 app_cmd_head->parameter_data; in cyapa_gen5_get_interval_time()
1518 return -EINVAL; in cyapa_gen5_get_interval_time()
1521 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_get_interval_time()
1523 put_unaligned_le16(cmd_len - 2, &app_cmd_head->length); in cyapa_gen5_get_interval_time()
1524 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_get_interval_time()
1525 app_cmd_head->cmd_code = GEN5_CMD_GET_PARAMETER; in cyapa_gen5_get_interval_time()
1526 parameter_data->parameter_id = parameter_id; in cyapa_gen5_get_interval_time()
1534 return error < 0 ? error : -EINVAL; in cyapa_gen5_get_interval_time()
1555 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_disable_pip_report()
1556 put_unaligned_le16(sizeof(cmd) - 2, &app_cmd_head->length); in cyapa_gen5_disable_pip_report()
1557 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_disable_pip_report()
1558 app_cmd_head->cmd_code = GEN5_CMD_SET_PARAMETER; in cyapa_gen5_disable_pip_report()
1559 app_cmd_head->parameter_data[0] = GEN5_PARAMETER_DISABLE_PIP_REPORT; in cyapa_gen5_disable_pip_report()
1560 app_cmd_head->parameter_data[1] = 0x01; in cyapa_gen5_disable_pip_report()
1561 app_cmd_head->parameter_data[2] = 0x01; in cyapa_gen5_disable_pip_report()
1569 return error < 0 ? error : -EINVAL; in cyapa_gen5_disable_pip_report()
1589 error = (error == -ETIMEDOUT) ? -EOPNOTSUPP : error; in cyapa_pip_set_proximity()
1590 return error < 0 ? error : -EINVAL; in cyapa_pip_set_proximity()
1609 return -EINVAL; in cyapa_pip_deep_sleep()
1617 struct device *dev = &cyapa->client->dev; in cyapa_gen5_set_power_mode()
1621 if (cyapa->state != CYAPA_STATE_GEN5_APP) in cyapa_gen5_set_power_mode()
1628 * Assume TP in deep sleep mode when driver is loaded, in cyapa_gen5_set_power_mode()
1630 * has been set into deep sleep mode when unloading. in cyapa_gen5_set_power_mode()
1639 &cyapa->dev_sleep_time) != 0) in cyapa_gen5_set_power_mode()
1655 dev_err(dev, "enter deep sleep fail: %d\n", error); in cyapa_gen5_set_power_mode()
1671 dev_err(dev, "deep sleep wake fail: %d\n", error); in cyapa_gen5_set_power_mode()
1720 * re-enable it automatically. It's used to fix the issue in cyapa_gen5_set_power_mode()
1723 * at the same time, user touch trackpad to wake system up. in cyapa_gen5_set_power_mode()
1756 return -EINVAL; in cyapa_pip_resume_scanning()
1780 return -EINVAL; in cyapa_pip_suspend_scanning()
1802 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_pip_calibrate_pwcs()
1803 put_unaligned_le16(sizeof(cmd) - 2, &app_cmd_head->length); in cyapa_pip_calibrate_pwcs()
1804 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_pip_calibrate_pwcs()
1805 app_cmd_head->cmd_code = PIP_CMD_CALIBRATE; in cyapa_pip_calibrate_pwcs()
1806 app_cmd_head->parameter_data[0] = calibrate_sensing_mode_type; in cyapa_pip_calibrate_pwcs()
1814 return error < 0 ? error : -EAGAIN; in cyapa_pip_calibrate_pwcs()
1854 if (value >> (num_bits - 1)) in twos_complement_to_s32()
1855 value |= -1 << num_bits; in twos_complement_to_s32()
1904 if (cyapa->electrodes_rx != 0) { in cyapa_gen5_guess_electrodes()
1905 *electrodes_rx = cyapa->electrodes_rx; in cyapa_gen5_guess_electrodes()
1906 *electrodes_tx = (cyapa->electrodes_x == *electrodes_rx) ? in cyapa_gen5_guess_electrodes()
1907 cyapa->electrodes_y : cyapa->electrodes_x; in cyapa_gen5_guess_electrodes()
1909 *electrodes_tx = min(cyapa->electrodes_x, cyapa->electrodes_y); in cyapa_gen5_guess_electrodes()
1910 *electrodes_rx = max(cyapa->electrodes_x, cyapa->electrodes_y); in cyapa_gen5_guess_electrodes()
1955 return -EINVAL; in cyapa_gen5_read_idac_data()
1974 if (cyapa->aligned_electrodes_rx == 0) { in cyapa_gen5_read_idac_data()
1977 cyapa->aligned_electrodes_rx = in cyapa_gen5_read_idac_data()
1981 (cyapa->aligned_electrodes_rx + 7) & ~7u; in cyapa_gen5_read_idac_data()
1991 offset = cyapa->aligned_electrodes_rx * (*data_size); in cyapa_gen5_read_idac_data()
1992 if (cyapa->electrodes_rx == cyapa->electrodes_x) in cyapa_gen5_read_idac_data()
1993 electrodes_tx = cyapa->electrodes_y; in cyapa_gen5_read_idac_data()
1995 electrodes_tx = cyapa->electrodes_x; in cyapa_gen5_read_idac_data()
1996 max_element_cnt = ((cyapa->aligned_electrodes_rx + 7) & in cyapa_gen5_read_idac_data()
2000 max_element_cnt = cyapa->electrodes_x + in cyapa_gen5_read_idac_data()
2001 cyapa->electrodes_y; in cyapa_gen5_read_idac_data()
2008 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &cmd_head->addr); in cyapa_gen5_read_idac_data()
2009 put_unaligned_le16(sizeof(cmd) - 2, &cmd_head->length); in cyapa_gen5_read_idac_data()
2010 cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_read_idac_data()
2011 cmd_head->cmd_code = cmd_code; in cyapa_gen5_read_idac_data()
2013 read_elements = (256 - GEN5_RESP_DATA_STRUCTURE_OFFSET) / in cyapa_gen5_read_idac_data()
2015 read_elements = min(read_elements, max_element_cnt - count); in cyapa_gen5_read_idac_data()
2018 put_unaligned_le16(offset, &cmd_head->parameter_data[0]); in cyapa_gen5_read_idac_data()
2019 put_unaligned_le16(read_len, &cmd_head->parameter_data[2]); in cyapa_gen5_read_idac_data()
2020 cmd_head->parameter_data[4] = idac_data_type; in cyapa_gen5_read_idac_data()
2031 return (error < 0) ? error : -EAGAIN; in cyapa_gen5_read_idac_data()
2038 return -EINVAL; in cyapa_gen5_read_idac_data()
2066 tmp_count < cyapa->aligned_electrodes_rx && in cyapa_gen5_read_idac_data()
2100 if (tmp_count == cyapa->aligned_electrodes_rx) { in cyapa_gen5_read_idac_data()
2101 cyapa->electrodes_rx = cyapa->electrodes_rx ? in cyapa_gen5_read_idac_data()
2102 cyapa->electrodes_rx : electrodes_rx; in cyapa_gen5_read_idac_data()
2104 cyapa->electrodes_rx = cyapa->electrodes_rx ? in cyapa_gen5_read_idac_data()
2105 cyapa->electrodes_rx : electrodes_rx; in cyapa_gen5_read_idac_data()
2106 cyapa->aligned_electrodes_rx = electrodes_rx; in cyapa_gen5_read_idac_data()
2108 cyapa->electrodes_rx = cyapa->electrodes_rx ? in cyapa_gen5_read_idac_data()
2109 cyapa->electrodes_rx : electrodes_tx; in cyapa_gen5_read_idac_data()
2110 cyapa->aligned_electrodes_rx = tmp_count; in cyapa_gen5_read_idac_data()
2187 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_execute_panel_scan()
2188 put_unaligned_le16(sizeof(cmd) - 2, &app_cmd_head->length); in cyapa_gen5_execute_panel_scan()
2189 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_execute_panel_scan()
2190 app_cmd_head->cmd_code = GEN5_CMD_EXECUTE_PANEL_SCAN; in cyapa_gen5_execute_panel_scan()
2200 return error ? error : -EAGAIN; in cyapa_gen5_execute_panel_scan()
2228 return -EINVAL; in cyapa_gen5_read_panel_scan_raw_data()
2236 read_elements = (256 - GEN5_RESP_DATA_STRUCTURE_OFFSET) / 4; in cyapa_gen5_read_panel_scan_raw_data()
2239 put_unaligned_le16(PIP_OUTPUT_REPORT_ADDR, &app_cmd_head->addr); in cyapa_gen5_read_panel_scan_raw_data()
2240 put_unaligned_le16(sizeof(cmd) - 2, &app_cmd_head->length); in cyapa_gen5_read_panel_scan_raw_data()
2241 app_cmd_head->report_id = PIP_APP_CMD_REPORT_ID; in cyapa_gen5_read_panel_scan_raw_data()
2242 app_cmd_head->cmd_code = cmd_code; in cyapa_gen5_read_panel_scan_raw_data()
2244 app_cmd_head->parameter_data; in cyapa_gen5_read_panel_scan_raw_data()
2246 put_unaligned_le16(offset, &panel_sacn_data->read_offset); in cyapa_gen5_read_panel_scan_raw_data()
2248 &panel_sacn_data->read_elements); in cyapa_gen5_read_panel_scan_raw_data()
2249 panel_sacn_data->data_id = raw_data_type; in cyapa_gen5_read_panel_scan_raw_data()
2260 return error ? error : -EAGAIN; in cyapa_gen5_read_panel_scan_raw_data()
2290 read_elements = (sizeof(resp_data) - in cyapa_gen5_read_panel_scan_raw_data()
2318 return -EBUSY; in cyapa_gen5_show_baseline()
2351 cyapa->electrodes_x * cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2362 cyapa->electrodes_x + cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2373 cyapa->electrodes_x * cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2384 cyapa->electrodes_x + cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2395 cyapa->electrodes_x * cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2406 cyapa->electrodes_x + cyapa->electrodes_y, in cyapa_gen5_show_baseline()
2425 size += scnprintf(buf + size, PAGE_SIZE - size, in cyapa_gen5_show_baseline()
2459 return error ? error : -EIO; in cyapa_gen5_bl_query_data()
2461 memcpy(&cyapa->product_id[0], &resp_data[8], 5); in cyapa_gen5_bl_query_data()
2462 cyapa->product_id[5] = '-'; in cyapa_gen5_bl_query_data()
2463 memcpy(&cyapa->product_id[6], &resp_data[13], 6); in cyapa_gen5_bl_query_data()
2464 cyapa->product_id[12] = '-'; in cyapa_gen5_bl_query_data()
2465 memcpy(&cyapa->product_id[13], &resp_data[19], 2); in cyapa_gen5_bl_query_data()
2466 cyapa->product_id[15] = '\0'; in cyapa_gen5_bl_query_data()
2468 cyapa->fw_maj_ver = resp_data[22]; in cyapa_gen5_bl_query_data()
2469 cyapa->fw_min_ver = resp_data[23]; in cyapa_gen5_bl_query_data()
2471 cyapa->platform_ver = (resp_data[26] >> PIP_BL_PLATFORM_VER_SHIFT) & in cyapa_gen5_bl_query_data()
2490 return error ? error : -EIO; in cyapa_gen5_get_query_data()
2495 return -EINVAL; in cyapa_gen5_get_query_data()
2497 cyapa->platform_ver = (resp_data[49] >> PIP_BL_PLATFORM_VER_SHIFT) & in cyapa_gen5_get_query_data()
2499 if (cyapa->gen == CYAPA_GEN5 && cyapa->platform_ver < 2) { in cyapa_gen5_get_query_data()
2501 cyapa->fw_maj_ver = resp_data[15]; in cyapa_gen5_get_query_data()
2502 cyapa->fw_min_ver = resp_data[16]; in cyapa_gen5_get_query_data()
2504 cyapa->fw_maj_ver = resp_data[9]; in cyapa_gen5_get_query_data()
2505 cyapa->fw_min_ver = resp_data[10]; in cyapa_gen5_get_query_data()
2508 cyapa->electrodes_x = resp_data[52]; in cyapa_gen5_get_query_data()
2509 cyapa->electrodes_y = resp_data[53]; in cyapa_gen5_get_query_data()
2511 cyapa->physical_size_x = get_unaligned_le16(&resp_data[54]) / 100; in cyapa_gen5_get_query_data()
2512 cyapa->physical_size_y = get_unaligned_le16(&resp_data[56]) / 100; in cyapa_gen5_get_query_data()
2514 cyapa->max_abs_x = get_unaligned_le16(&resp_data[58]); in cyapa_gen5_get_query_data()
2515 cyapa->max_abs_y = get_unaligned_le16(&resp_data[60]); in cyapa_gen5_get_query_data()
2517 cyapa->max_z = get_unaligned_le16(&resp_data[62]); in cyapa_gen5_get_query_data()
2519 cyapa->x_origin = resp_data[64] & 0x01; in cyapa_gen5_get_query_data()
2520 cyapa->y_origin = resp_data[65] & 0x01; in cyapa_gen5_get_query_data()
2522 cyapa->btn_capability = (resp_data[70] << 3) & CAPABILITY_BTN_MASK; in cyapa_gen5_get_query_data()
2524 memcpy(&cyapa->product_id[0], &resp_data[33], 5); in cyapa_gen5_get_query_data()
2525 cyapa->product_id[5] = '-'; in cyapa_gen5_get_query_data()
2526 memcpy(&cyapa->product_id[6], &resp_data[38], 6); in cyapa_gen5_get_query_data()
2527 cyapa->product_id[12] = '-'; in cyapa_gen5_get_query_data()
2528 memcpy(&cyapa->product_id[13], &resp_data[44], 2); in cyapa_gen5_get_query_data()
2529 cyapa->product_id[15] = '\0'; in cyapa_gen5_get_query_data()
2531 if (!cyapa->electrodes_x || !cyapa->electrodes_y || in cyapa_gen5_get_query_data()
2532 !cyapa->physical_size_x || !cyapa->physical_size_y || in cyapa_gen5_get_query_data()
2533 !cyapa->max_abs_x || !cyapa->max_abs_y || !cyapa->max_z) in cyapa_gen5_get_query_data()
2534 return -EINVAL; in cyapa_gen5_get_query_data()
2541 struct device *dev = &cyapa->client->dev; in cyapa_gen5_do_operational_check()
2544 if (cyapa->gen != CYAPA_GEN5) in cyapa_gen5_do_operational_check()
2545 return -ENODEV; in cyapa_gen5_do_operational_check()
2547 switch (cyapa->state) { in cyapa_gen5_do_operational_check()
2556 cyapa->state = CYAPA_STATE_GEN5_APP; in cyapa_gen5_do_operational_check()
2561 * If trackpad device in deep sleep mode, in cyapa_gen5_do_operational_check()
2573 if (cyapa->platform_ver >= 2) { in cyapa_gen5_do_operational_check()
2586 if (memcmp(cyapa->product_id, product_id, in cyapa_gen5_do_operational_check()
2589 __func__, cyapa->product_id); in cyapa_gen5_do_operational_check()
2590 error = -EINVAL; in cyapa_gen5_do_operational_check()
2594 error = -EINVAL; in cyapa_gen5_do_operational_check()
2607 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip; in cyapa_pip_irq_cmd_handler()
2610 if (atomic_read(&pip->cmd_issued)) { in cyapa_pip_irq_cmd_handler()
2612 if (pip->is_irq_mode == false) in cyapa_pip_irq_cmd_handler()
2620 cyapa_i2c_pip_read(cyapa, pip->irq_cmd_buf, in cyapa_pip_irq_cmd_handler()
2622 length = get_unaligned_le16(pip->irq_cmd_buf); in cyapa_pip_irq_cmd_handler()
2627 pip->irq_cmd_buf, length); in cyapa_pip_irq_cmd_handler()
2628 if (!(pip->resp_sort_func && in cyapa_pip_irq_cmd_handler()
2629 pip->resp_sort_func(cyapa, in cyapa_pip_irq_cmd_handler()
2630 pip->irq_cmd_buf, length))) { in cyapa_pip_irq_cmd_handler()
2635 * ready event. Because when there was a finger touch in cyapa_pip_irq_cmd_handler()
2637 * won't be empty (always with touch report data), so in cyapa_pip_irq_cmd_handler()
2645 if (pip->resp_len) in cyapa_pip_irq_cmd_handler()
2646 length = *pip->resp_len; in cyapa_pip_irq_cmd_handler()
2648 pip->resp_data, in cyapa_pip_irq_cmd_handler()
2650 pip->resp_sort_func); in cyapa_pip_irq_cmd_handler()
2651 if (pip->resp_len && length != 0) { in cyapa_pip_irq_cmd_handler()
2652 *pip->resp_len = length; in cyapa_pip_irq_cmd_handler()
2653 atomic_dec(&pip->cmd_issued); in cyapa_pip_irq_cmd_handler()
2654 complete(&pip->cmd_ready); in cyapa_pip_irq_cmd_handler()
2659 if (pip->resp_data && pip->resp_len) { in cyapa_pip_irq_cmd_handler()
2660 *pip->resp_len = (*pip->resp_len < length) ? in cyapa_pip_irq_cmd_handler()
2661 *pip->resp_len : length; in cyapa_pip_irq_cmd_handler()
2662 memcpy(pip->resp_data, pip->irq_cmd_buf, in cyapa_pip_irq_cmd_handler()
2663 *pip->resp_len); in cyapa_pip_irq_cmd_handler()
2665 atomic_dec(&pip->cmd_issued); in cyapa_pip_irq_cmd_handler()
2666 complete(&pip->cmd_ready); in cyapa_pip_irq_cmd_handler()
2676 struct input_dev *input = cyapa->input; in cyapa_pip_report_buttons()
2677 u8 buttons = report_data->report_head[PIP_BUTTONS_OFFSET]; in cyapa_pip_report_buttons()
2681 if (cyapa->btn_capability & CAPABILITY_LEFT_BTN_MASK) { in cyapa_pip_report_buttons()
2685 if (cyapa->btn_capability & CAPABILITY_MIDDLE_BTN_MASK) { in cyapa_pip_report_buttons()
2689 if (cyapa->btn_capability & CAPABILITY_RIGHT_BTN_MASK) { in cyapa_pip_report_buttons()
2700 struct input_dev *input = cyapa->input; in cyapa_pip_report_proximity()
2701 u8 distance = report_data->report_head[PIP_PROXIMITY_DISTANCE_OFFSET] & in cyapa_pip_report_proximity()
2709 const struct cyapa_pip_touch_record *touch) in cyapa_pip_report_slot_data() argument
2711 struct input_dev *input = cyapa->input; in cyapa_pip_report_slot_data()
2712 u8 event_id = PIP_GET_EVENT_ID(touch->touch_tip_event_id); in cyapa_pip_report_slot_data()
2713 int slot = PIP_GET_TOUCH_ID(touch->touch_tip_event_id); in cyapa_pip_report_slot_data()
2721 x = (touch->x_hi << 8) | touch->x_lo; in cyapa_pip_report_slot_data()
2722 if (cyapa->x_origin) in cyapa_pip_report_slot_data()
2723 x = cyapa->max_abs_x - x; in cyapa_pip_report_slot_data()
2724 y = (touch->y_hi << 8) | touch->y_lo; in cyapa_pip_report_slot_data()
2725 if (cyapa->y_origin) in cyapa_pip_report_slot_data()
2726 y = cyapa->max_abs_y - y; in cyapa_pip_report_slot_data()
2731 touch->z); in cyapa_pip_report_slot_data()
2733 touch->major_axis_len); in cyapa_pip_report_slot_data()
2735 touch->minor_axis_len); in cyapa_pip_report_slot_data()
2738 touch->major_tool_len); in cyapa_pip_report_slot_data()
2740 touch->minor_tool_len); in cyapa_pip_report_slot_data()
2743 touch->orientation); in cyapa_pip_report_slot_data()
2749 struct input_dev *input = cyapa->input; in cyapa_pip_report_touches()
2753 touch_num = report_data->report_head[PIP_NUMBER_OF_TOUCH_OFFSET] & in cyapa_pip_report_touches()
2758 &report_data->touch_records[i]); in cyapa_pip_report_touches()
2766 struct device *dev = &cyapa->client->dev; in cyapa_pip_irq_handler()
2773 cyapa->gen, cyapa->state); in cyapa_pip_irq_handler()
2774 return -EINVAL; in cyapa_pip_irq_handler()
2781 return -EINVAL; in cyapa_pip_irq_handler()
2791 return -EINVAL; in cyapa_pip_irq_handler()
2802 return -EINVAL; in cyapa_pip_irq_handler()
2811 struct device *dev = &cyapa->client->dev; in cyapa_pip_event_process()
2816 &report_data->report_head[PIP_RESP_LENGTH_OFFSET]); in cyapa_pip_event_process()
2821 report_id = report_data->report_head[PIP_RESP_REPORT_ID_OFFSET]; in cyapa_pip_event_process()
2825 * Device wake event from deep sleep mode for touch. in cyapa_pip_event_process()
2830 * time in receiving for first valid touch report data. in cyapa_pip_event_process()
2845 return -EINVAL; in cyapa_pip_event_process()
2852 dev_err(dev, "invalid touch packet length=%d\n", report_len); in cyapa_pip_event_process()