2 * Copyright (C) 2010,Imagis Technology Co. Ltd. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
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.
16 #include <linux/i2c.h>
17 #include <linux/delay.h>
18 #include <linux/slab.h>
19 #include <linux/firmware.h>
20 #include <linux/stat.h>
23 #include "ist30xx_update.h"
24 #include "ist30xx_misc.h"
27 #include "ist30xx_chkic_bin.h"
30 #define TSP_CH_SCREEN (1)
31 #define TSP_CH_KEY (2)
33 #define TOUCH_NODE_PARSING_DEBUG (0)
35 extern struct ist30xx_data *ts_data;
37 TSP_INFO ist30xx_tsp_info;
38 TKEY_INFO ist30xx_tkey_info;
40 static u32 *ist30xx_frame_buf;
41 static u32 *ist30xx_frame_rawbuf;
42 static u32 *ist30xx_frame_fltbuf;
45 int ist30xx_tkey_update_info(void)
48 u32 tkey_info1, tkey_info2, tkey_info3;
49 TKEY_INFO *tkey = &ist30xx_tkey_info;
51 ret = ist30xx_read_cmd(ts_data->client, CMD_GET_KEY_INFO1, &tkey_info1);
54 ret = ist30xx_read_cmd(ts_data->client, CMD_GET_KEY_INFO2, &tkey_info2);
57 ret = ist30xx_read_cmd(ts_data->client, CMD_GET_KEY_INFO3, &tkey_info3);
61 tkey->enable = ((tkey_info1 & (0xFF << 24)) ? true : false);
62 tkey->key_num = (tkey_info1 >> 16) & 0xFF;
63 tkey->ch_num[0] = (tkey_info2 >> 24) & 0xFF;
64 tkey->ch_num[1] = (tkey_info2 >> 16) & 0xFF;
65 tkey->ch_num[2] = (tkey_info2 >> 8) & 0xFF;
66 tkey->ch_num[3] = tkey_info2 & 0xFF;
67 tkey->ch_num[4] = (tkey_info3 >> 24) & 0xFF;
73 #define TSP_INFO_SWAP_XY (1 << 0)
74 #define TSP_INFO_FLIP_X (1 << 1)
75 #define TSP_INFO_FLIP_Y (1 << 2)
76 int ist30xx_tsp_update_info(void)
79 u32 tsp_ch_num, tsp_swap, tsp_dir;
80 TSP_INFO *tsp = &ist30xx_tsp_info;
82 ret = ist30xx_read_cmd(ts_data->client, CMD_GET_TSP_SWAP_INFO, &tsp_swap);
83 if (unlikely(ret)) return ret;
85 ret = ist30xx_read_cmd(ts_data->client, CMD_GET_TSP_DIRECTION, &tsp_dir);
86 if (unlikely(ret)) return ret;
88 ret = ist30xx_read_cmd(ts_data->client, CMD_GET_TSP_CHNUM1, &tsp_ch_num);
89 if (unlikely(ret || !tsp_ch_num)) return ret;
91 tsp->finger_num = IST30XX_MAX_MT_FINGERS;
93 tsp->ch_num.rx = tsp_ch_num >> 16;
94 tsp->ch_num.tx = tsp_ch_num & 0xFFFF;
96 tsp->dir.swap_xy = (tsp_swap & TSP_INFO_SWAP_XY ? true : false);
97 tsp->dir.flip_x = (tsp_swap & TSP_INFO_FLIP_X ? true : false);
98 tsp->dir.flip_y = (tsp_swap & TSP_INFO_FLIP_Y ? true : false);
100 tsp->node.len = tsp->ch_num.tx * tsp->ch_num.rx;
101 tsp->height = (tsp->dir.swap_xy ? tsp->ch_num.rx : tsp->ch_num.tx);
102 tsp->width = (tsp->dir.swap_xy ? tsp->ch_num.tx : tsp->ch_num.rx);
107 int ist30xx_check_valid_ch(int ch_tx, int ch_rx)
109 TKEY_INFO *tkey = &ist30xx_tkey_info;
110 TSP_INFO *tsp = &ist30xx_tsp_info;
112 if (unlikely((ch_tx > tsp->ch_num.tx) || (ch_rx > tsp->ch_num.rx)))
117 tsp_verb("tx: %d, rx: %d\n", ch_tx, ch_rx);
118 if (ch_rx == tsp->ch_num.rx - 1) {
119 tsp_verb("ch_tx: %d\n", ch_tx);
120 if ((ch_tx == tkey->ch_num[0]) || (ch_tx == tkey->ch_num[1]) ||
121 (ch_tx == tkey->ch_num[2]) || (ch_tx == tkey->ch_num[3]) ||
122 (ch_tx == tkey->ch_num[4]))
128 if (ch_tx == tsp->ch_num.tx - 1) {
129 if ((ch_rx == tkey->ch_num[0]) || (ch_rx == tkey->ch_num[1]) ||
130 (ch_rx == tkey->ch_num[2]) || (ch_rx == tkey->ch_num[3]) ||
131 (ch_rx == tkey->ch_num[4]))
139 return TSP_CH_SCREEN;
143 int ist30xx_parse_touch_node(u8 flag, struct TSP_NODE_BUF *node)
145 #if TOUCH_NODE_PARSING_DEBUG
147 TSP_INFO *tsp = &ist30xx_tsp_info;
150 u16 *raw = (u16 *)&node->raw;
151 u16 *base = (u16 *)&node->base;
152 u16 *filter = (u16 *)&node->filter;
153 u32 *tmp_rawbuf = ist30xx_frame_rawbuf;
154 u32 *tmp_fltbuf = ist30xx_frame_fltbuf;
156 for (i = 0; i < node->len; i++) {
157 if (flag & (NODE_FLAG_RAW | NODE_FLAG_BASE)) {
158 *raw++ = *tmp_rawbuf & 0xFFF;
159 *base++ = (*tmp_rawbuf >> 16) & 0xFFF;
163 if (flag & NODE_FLAG_FILTER)
164 *filter++ = *tmp_fltbuf++ & 0xFFF;
167 #if TOUCH_NODE_PARSING_DEBUG
168 tsp_info("RAW - %d * %d\n", tsp->ch_num.tx, tsp->ch_num.rx);
169 for (i = 0; i < tsp->ch_num.tx; i++) {
170 printk("\n[ TSP ] ");
171 for (j = 0; j < tsp->ch_num.rx; j++)
172 printk("%4d ", node->raw[i][j]);
175 tsp_info("BASE - %d * %d\n", tsp->ch_num.tx, tsp->ch_num.rx);
176 for (i = 0; i < tsp->ch_num.tx; i++) {
177 printk("\n[ TSP ] ");
178 for (j = 0; j < tsp->ch_num.rx; j++)
179 printk("%4d ", node->base[i][j]);
182 tsp_info("FILTER - %d * %d\n", tsp->ch_num.tx, tsp->ch_num.rx);
183 for (i = 0; i < tsp->ch_num.tx; i++) {
184 printk("\n[ TSP ] ");
185 for (j = 0; j < tsp->ch_num.rx; j++)
186 printk("%4d ", node->filter[i][j]);
193 int print_touch_node(u8 flag, struct TSP_NODE_BUF *node, char *buf, bool ch_tsp)
198 const int msg_len = 128;
200 TSP_INFO *tsp = &ist30xx_tsp_info;
202 if (tsp->dir.swap_xy) {
204 for (i = 0; i < tsp->ch_num.tx; i++) {
205 for (j = 0; j < tsp->ch_num.rx; j++) {
206 if (ch_tsp && (ist30xx_check_valid_ch(i, j) != TSP_CH_SCREEN))
209 if (flag == NODE_FLAG_RAW)
210 val = (int)node->raw[i][j];
211 else if (flag == NODE_FLAG_BASE)
212 val = (int)node->base[i][j];
213 else if (flag == NODE_FLAG_FILTER)
214 val = (int)node->filter[i][j];
215 else if (flag == NODE_FLAG_DIFF)
216 val = (int)(node->raw[i][j] - node->base[i][j]);
220 if (val < 0) val = 0;
222 count += snprintf(msg, msg_len, "%4d ", val);
223 strncat(buf, msg, msg_len);
226 count += snprintf(msg, msg_len, "\n");
227 strncat(buf, msg, msg_len);
234 int parse_tsp_node(u8 flag, struct TSP_NODE_BUF *node, s16 *buf16)
238 TSP_INFO *tsp = &ist30xx_tsp_info;
240 if (unlikely((flag != NODE_FLAG_RAW) && (flag != NODE_FLAG_BASE) &&
241 (flag != NODE_FLAG_FILTER) && (flag != NODE_FLAG_DIFF)))
244 if (tsp->dir.swap_xy) {
246 for (i = 0; i < tsp->ch_num.tx; i++) {
247 for (j = 0; j < tsp->ch_num.rx; j++) {
248 if (ist30xx_check_valid_ch(i, j) != TSP_CH_SCREEN)
253 val = (s16)node->raw[i][j];
256 val = (s16)node->base[i][j];
258 case NODE_FLAG_FILTER:
259 val = (s16)node->filter[i][j];
262 val = (s16)(node->raw[i][j] - node->base[i][j]);
266 if (val < 0) val = 0;
276 int ist30xx_read_touch_node(u8 flag, struct TSP_NODE_BUF *node)
279 u32 addr = IST30XXB_RAW_ADDR;
281 if (ts_data->chip_id == IST3038_CHIP_ID)
284 ist30xx_disable_irq(ts_data);
286 if (flag & NODE_FLAG_NO_CCP) {
287 ist30xx_reset(false);
289 ret = ist30xx_write_cmd(ts_data->client, CMD_USE_CORRECT_CP, 0);
291 goto read_tsp_node_end;
294 ret = ist30xx_cmd_reg(ts_data->client, CMD_ENTER_REG_ACCESS);
296 goto read_tsp_node_end;
298 ret = ist30xx_write_cmd(ts_data->client, IST30XX_RX_CNT_ADDR, node->len);
302 if (flag & (NODE_FLAG_RAW | NODE_FLAG_BASE)) {
303 tsp_info("Reg addr: %x, size: %d\n", addr, node->len);
304 ret = ist30xx_read_buf(ts_data->client, addr,
305 ist30xx_frame_rawbuf, node->len);
310 if (flag & NODE_FLAG_FILTER) {
311 tsp_info("Reg addr: %x, size: %d\n", IST30XXB_FILTER_ADDR, node->len);
312 ret = ist30xx_read_buf(ts_data->client, IST30XXB_FILTER_ADDR,
313 ist30xx_frame_fltbuf, node->len);
319 ist30xx_cmd_reg(ts_data->client, CMD_EXIT_REG_ACCESS);
320 ist30xx_cmd_start_scan(ts_data->client);
323 ist30xx_enable_irq(ts_data);
329 /* sysfs: /sys/class/touch/node/refresh */
330 ssize_t ist30xx_frame_refresh(struct device *dev, struct device_attribute *attr,
334 TSP_INFO *tsp = &ist30xx_tsp_info;
335 u8 flag = NODE_FLAG_RAW | NODE_FLAG_BASE | NODE_FLAG_FILTER;
337 tsp_info("refresh\n");
339 ret = ist30xx_read_touch_node(flag, &tsp->node);
341 tsp_err("cmd 1frame raw update fail\n");
342 return sprintf(buf, "FAIL\n");
345 ist30xx_parse_touch_node(flag, &tsp->node);
347 return sprintf(buf, "OK\n");
351 /* sysfs: /sys/class/touch/node/read_nocp */
352 ssize_t ist30xx_frame_nocp(struct device *dev, struct device_attribute *attr,
356 TSP_INFO *tsp = &ist30xx_tsp_info;
357 u8 flag = NODE_FLAG_RAW | NODE_FLAG_BASE | NODE_FLAG_FILTER |
360 ret = ist30xx_read_touch_node(flag, &tsp->node);
362 tsp_err("cmd 1frame raw update fail\n");
363 return sprintf(buf, "FAIL\n");
366 ist30xx_parse_touch_node(flag, &tsp->node);
368 return sprintf(buf, "OK\n");
372 /* sysfs: /sys/class/touch/node/base */
373 ssize_t ist30xx_base_show(struct device *dev, struct device_attribute *attr,
377 TSP_INFO *tsp = &ist30xx_tsp_info;
380 count = sprintf(buf, "dump ist30xxb baseline(%d)\n", tsp->node.len);
382 count += print_touch_node(NODE_FLAG_BASE, &tsp->node, buf, false);
388 /* sysfs: /sys/class/touch/node/raw */
389 ssize_t ist30xx_raw_show(struct device *dev, struct device_attribute *attr,
393 TSP_INFO *tsp = &ist30xx_tsp_info;
396 count = sprintf(buf, "dump ist30xxb raw(%d)\n", tsp->node.len);
398 count += print_touch_node(NODE_FLAG_RAW, &tsp->node, buf, false);
404 /* sysfs: /sys/class/touch/node/diff */
405 ssize_t ist30xx_diff_show(struct device *dev, struct device_attribute *attr,
409 TSP_INFO *tsp = &ist30xx_tsp_info;
412 count = sprintf(buf, "dump ist30xxb difference (%d)\n", tsp->node.len);
414 count += print_touch_node(NODE_FLAG_DIFF, &tsp->node, buf, false);
420 /* sysfs: /sys/class/touch/node/filter */
421 ssize_t ist30xx_filter_show(struct device *dev, struct device_attribute *attr,
425 TSP_INFO *tsp = &ist30xx_tsp_info;
428 count = sprintf(buf, "dump ist30xxb filter (%d)\n", tsp->node.len);
430 count += print_touch_node(NODE_FLAG_FILTER, &tsp->node, buf, false);
436 extern int calib_ms_delay;
437 /* sysfs: /sys/class/touch/sys/clb_time */
438 ssize_t ist30xx_calib_time_store(struct device *dev,
439 struct device_attribute *attr, const char *buf, size_t size)
443 sscanf(buf, "%d", &ms_delay);
445 if (ms_delay > 10 && ms_delay < 1000) // 1sec ~ 100sec
446 calib_ms_delay = ms_delay;
448 tsp_info("Calibration wait time %dsec\n", calib_ms_delay / 10);
453 /* sysfs: /sys/class/touch/sys/clb */
454 ssize_t ist30xx_calib_show(struct device *dev, struct device_attribute *attr,
457 ist30xx_disable_irq(ts_data);
459 ist30xx_reset(false);
461 ist30xx_calibrate(1);
463 ist30xx_start(ts_data);
468 /* sysfs: /sys/class/touch/sys/clb_result */
469 ssize_t ist30xx_calib_result_show(struct device *dev,
470 struct device_attribute *attr, char *buf)
476 mutex_lock(&ist30xx_mutex);
477 ist30xx_disable_irq(ts_data);
478 ist30xx_reset(false);
480 ret = ist30xx_read_cmd(ts_data->client, CMD_GET_CALIB_RESULT, &value);
482 count = sprintf(buf, "Error Read Calibration Result\n");
487 "Calibration Status : %d, Max raw gap : %d - (raw: %08x)\n",
488 CALIB_TO_STATUS(value), CALIB_TO_GAP(value), value);
491 ist30xx_start(ts_data);
492 ist30xx_enable_irq(ts_data);
493 mutex_unlock(&ist30xx_mutex);
498 /* sysfs: /sys/class/touch/sys/power_on */
499 ssize_t ist30xx_power_on_show(struct device *dev, struct device_attribute *attr,
502 tsp_info("Power enable: %d\n", true);
504 mutex_lock(&ist30xx_mutex);
505 ist30xx_internal_resume(ts_data);
506 ist30xx_enable_irq(ts_data);
507 mutex_unlock(&ist30xx_mutex);
509 ist30xx_start(ts_data);
514 /* sysfs: /sys/class/touch/sys/power_off */
515 ssize_t ist30xx_power_off_show(struct device *dev,
516 struct device_attribute *attr, char *buf)
518 tsp_info("Power enable: %d\n", false);
520 mutex_lock(&ist30xx_mutex);
521 ist30xx_disable_irq(ts_data);
522 ist30xx_internal_suspend(ts_data);
523 mutex_unlock(&ist30xx_mutex);
528 extern int ist30xx_max_error_cnt;
529 /* sysfs: /sys/class/touch/sys/errcnt */
530 ssize_t ist30xx_errcnt_store(struct device *dev, struct device_attribute *attr,
531 const char *buf, size_t size)
535 sscanf(buf, "%d", &err_cnt);
537 if (unlikely(err_cnt < 0))
540 tsp_info("Request reset error count: %d\n", err_cnt);
542 ist30xx_max_error_cnt = err_cnt;
547 #if IST30XX_EVENT_MODE
548 extern int ist30xx_max_scan_retry;
549 /* sysfs: /sys/class/touch/sys/scancnt */
550 ssize_t ist30xx_scancnt_store(struct device *dev, struct device_attribute *attr,
551 const char *buf, size_t size)
555 sscanf(buf, "%d", &retry);
557 if (unlikely(retry < 0))
560 tsp_info("Timer scan count retry: %d\n", retry);
562 ist30xx_max_scan_retry = retry;
567 extern int timer_period_ms;
568 /* sysfs: /sys/class/touch/sys/timerms */
569 ssize_t ist30xx_timerms_store(struct device *dev, struct device_attribute *attr,
570 const char *buf, size_t size)
574 sscanf(buf, "%d", &ms);
576 if (unlikely((ms < 0) || (ms > 10000)))
579 tsp_info("Timer period ms: %dms\n", ms);
581 timer_period_ms = ms;
587 extern int ist30xx_dbg_level;
588 /* sysfs: /sys/class/touch/sys/printk */
589 ssize_t ist30xx_printk_store(struct device *dev, struct device_attribute *attr,
590 const char *buf, size_t size)
594 sscanf(buf, "%d", &level);
596 if (unlikely((level < DEV_ERR) || (level > DEV_VERB)))
599 tsp_info("prink log level: %d\n", level);
601 ist30xx_dbg_level = level;
606 ssize_t ist30xx_printk_show(struct device *dev, struct device_attribute *attr,
609 return sprintf(buf, "prink log level: %d\n", ist30xx_dbg_level);
612 /* sysfs: /sys/class/touch/sys/printk5 */
613 ssize_t ist30xx_printk5_show(struct device *dev, struct device_attribute *attr,
616 tsp_info("prink log level:%d\n", DEV_DEBUG);
618 ist30xx_dbg_level = DEV_DEBUG;
623 /* sysfs: /sys/class/touch/sys/printk6 */
624 ssize_t ist30xx_printk6_show(struct device *dev, struct device_attribute *attr,
627 tsp_info("prink log level:%d\n", DEV_VERB);
629 ist30xx_dbg_level = DEV_VERB;
634 /* sysfs: /sys/class/touch/sys/max_touch */
635 ssize_t ist30xx_touch_store(struct device *dev, struct device_attribute *attr,
636 const char *buf, size_t size)
641 sscanf(buf, "%d %d", &finger, &key);
643 tsp_info("fingers : %d, keys : %d\n", finger, key);
645 ts_data->max_fingers = finger;
646 ts_data->max_keys = key;
651 extern void ist30xx_scheduled_reset(void);
652 extern int ist30xx_report_rate;
653 /* sysfs: /sys/class/touch/sys/touch_rate */
654 ssize_t ist30xx_touch_rate_store(struct device *dev,
655 struct device_attribute *attr, const char *buf, size_t size)
659 sscanf(buf, "%d", &rate); // us
661 if (unlikely(rate > 0xFFFF)) // over 65.5ms
664 tsp_info("touch reporting rate: %d\n", rate);
666 ist30xx_report_rate = rate;
668 ist30xx_scheduled_reset();
673 extern int ist30xx_idle_rate;
674 /* sysfs: /sys/class/touch/sys/idle_rate */
675 ssize_t ist30xx_idle_scan_rate_store(struct device *dev,
676 struct device_attribute *attr, const char *buf, size_t size)
680 sscanf(buf, "%d", &rate); // us
682 if (unlikely(rate > 0xFFFF)) // over 65.5ms
685 tsp_info("touch idle scan rate: %d\n", rate);
687 ist30xx_idle_rate = rate;
689 ist30xx_scheduled_reset();
694 extern void ist30xx_set_ta_mode(bool charging);
695 /* sysfs: /sys/class/touch/sys/mode_ta */
696 ssize_t ist30xx_ta_mode_store(struct device *dev, struct device_attribute *attr,
697 const char *buf, size_t size)
701 sscanf(buf, "%d", &mode);
703 if (unlikely((mode != 0) && (mode != 1))) // enable/disable
706 ist30xx_set_ta_mode(mode);
711 extern void ist30xx_set_call_mode(int mode);
712 /* sysfs: /sys/class/touch/sys/mode_call */
713 ssize_t ist30xx_call_mode_store(struct device *dev,
714 struct device_attribute *attr, const char *buf, size_t size)
718 sscanf(buf, "%d", &mode);
720 if (unlikely((mode != 0) && (mode != 1))) // enable/disable
723 ist30xx_set_call_mode(mode);
728 extern void ist30xx_set_cover_mode(int mode);
729 /* sysfs: /sys/class/touch/sys/mode_cover */
730 ssize_t ist30xx_cover_mode_store(struct device *dev,
731 struct device_attribute *attr, const char *buf, size_t size)
735 sscanf(buf, "%d", &mode);
737 if (unlikely((mode != 0) && (mode != 1))) // enable/disable
740 ist30xx_set_cover_mode(mode);
745 #define TUNES_CMD_WRITE (1)
746 #define TUNES_CMD_READ (2)
747 #define TUNES_CMD_REG_ENTER (3)
748 #define TUNES_CMD_REG_EXIT (4)
749 #define TUNES_CMD_UPDATE_PARAM (5)
750 #define TUNES_CMD_UPDATE_FW (6)
752 #define DIRECT_ADDR(n) (IST30XXB_DA_ADDR(n))
753 #define DIRECT_CMD_WRITE ('w')
754 #define DIRECT_CMD_READ ('r')
771 static TUNES_INFO ist30xx_tunes;
772 static DIRECT_INFO ist30xx_direct;
773 static bool tunes_cmd_done = false;
774 static bool ist30xx_reg_mode = false;
776 /* sysfs: /sys/class/touch/sys/direct */
777 ssize_t ist30xxb_direct_store(struct device *dev, struct device_attribute *attr,
778 const char *buf, size_t size)
781 DIRECT_INFO *direct = (DIRECT_INFO *)&ist30xx_direct;
783 sscanf(buf, "%c %x %x", &direct->cmd, &direct->addr, &direct->val);
785 tsp_debug("Direct cmd: %c, addr: %x, val: %x\n",
786 direct->cmd, direct->addr, direct->val);
788 if (unlikely((direct->cmd != DIRECT_CMD_WRITE) &&
789 (direct->cmd != DIRECT_CMD_READ))) {
790 tsp_warn("Direct cmd is not correct!\n");
794 if (ist30xx_intr_wait(30) < 0)
797 ts_data->status.event_mode = false;
798 if (direct->cmd == DIRECT_CMD_WRITE) {
799 ret = ist30xx_write_cmd(ts_data->client, DIRECT_ADDR(direct->addr),
801 ret = ist30xx_read_cmd(ts_data->client, DIRECT_ADDR(direct->addr),
803 tsp_debug("Direct write addr: %x, val: %x\n",
804 direct->addr, direct->val);
806 ts_data->status.event_mode = true;
811 #define DIRECT_BUF_COUNT (4)
812 ssize_t ist30xxb_direct_show(struct device *dev, struct device_attribute *attr,
815 int i, ret, count = 0;
818 u32 buf32[DIRECT_BUF_COUNT];
819 int max_len = DIRECT_BUF_COUNT;
820 const int msg_len = 256;
823 DIRECT_INFO *direct = (DIRECT_INFO *)&ist30xx_direct;
825 if (unlikely(direct->cmd != DIRECT_CMD_READ))
826 return sprintf(buf, "ex) echo r addr len > direct\n");
829 addr = DIRECT_ADDR(direct->addr);
831 if (ist30xx_intr_wait(30) < 0)
833 ts_data->status.event_mode = false;
835 if (len < max_len) max_len = len;
837 memset(buf32, 0, sizeof(buf32));
838 ret = ist30xxb_burst_read(ts_data->client, addr, buf32, max_len);
840 count = sprintf(buf, "I2C Burst read fail, addr: %x\n", addr);
844 for (i = 0; i < max_len; i++) {
845 count += snprintf(msg, msg_len, "0x%08x ", buf32[i]);
846 strncat(buf, msg, msg_len);
848 count += snprintf(msg, msg_len, "\n");
849 strncat(buf, msg, msg_len);
851 addr += max_len * IST30XX_DATA_LEN;
854 ts_data->status.event_mode = true;
856 tsp_debug("%s", buf);
861 /* sysfs: /sys/class/touch/tunes/node_info */
862 ssize_t tunes_node_info_show(struct device *dev,
863 struct device_attribute *attr, char *buf)
866 TSP_INFO *tsp = &ist30xx_tsp_info;
867 TKEY_INFO *tkey = &ist30xx_tkey_info;
869 size = sprintf(buf, "%d %d %d %d %d %d %d %d %d %d %d %d %d ",
870 ts_data->chip_id, tsp->dir.swap_xy, tsp->ch_num.tx, tsp->ch_num.rx,
871 tsp->baseline, tkey->axis_rx, tkey->enable, tkey->baseline,
872 tkey->ch_num[0], tkey->ch_num[1],
873 tkey->ch_num[2], tkey->ch_num[3], tkey->ch_num[4]);
878 /* sysfs: /sys/class/touch/tunes/regcmd */
879 ssize_t tunes_regcmd_store(struct device *dev, struct device_attribute *attr,
880 const char *buf, size_t size)
885 memcpy(&ist30xx_tunes, buf, sizeof(ist30xx_tunes));
886 buf += sizeof(ist30xx_tunes);
889 tunes_cmd_done = false;
891 switch (ist30xx_tunes.cmd) {
892 case TUNES_CMD_WRITE:
896 case TUNES_CMD_REG_ENTER:
897 ist30xx_disable_irq(ts_data);
898 ist30xx_reset(false);
900 /* enter reg access mode */
901 ret = ist30xx_cmd_reg(ts_data->client, CMD_ENTER_REG_ACCESS);
905 ist30xx_reg_mode = true;
908 case TUNES_CMD_REG_EXIT:
909 /* exit reg access mode */
910 ret = ist30xx_cmd_reg(ts_data->client, CMD_EXIT_REG_ACCESS);
914 ret = ist30xx_cmd_start_scan(ts_data->client);
918 ist30xx_reg_mode = false;
920 ist30xx_enable_irq(ts_data);
923 ist30xx_enable_irq(ts_data);
926 tunes_cmd_done = true;
931 tsp_err("Tunes regcmd i2c_fail, ret=%d\n", ret);
935 ssize_t tunes_regcmd_show(struct device *dev, struct device_attribute *attr,
940 size = sprintf(buf, "cmd: 0x%02x, addr: 0x%08x, len: 0x%04x\n",
941 ist30xx_tunes.cmd, ist30xx_tunes.addr, ist30xx_tunes.len);
946 #define MAX_WRITE_LEN (1)
947 /* sysfs: /sys/class/touch/tunes/reg */
948 ssize_t tunes_reg_store(struct device *dev, struct device_attribute *attr,
949 const char *buf, size_t size)
952 u32 *buf32 = (u32 *)buf;
953 int waddr, wcnt = 0, len = 0;
955 if (unlikely(ist30xx_tunes.cmd != TUNES_CMD_WRITE)) {
956 tsp_err("error, IST30XX_REG_CMD is not correct!\n");
960 if (unlikely(!ist30xx_reg_mode)) {
961 tsp_err("error, IST30XX_REG_CMD is not ready!\n");
965 if (unlikely(!tunes_cmd_done)) {
966 tsp_err("error, IST30XX_REG_CMD is not ready!\n");
970 waddr = ist30xx_tunes.addr;
971 if (ist30xx_tunes.len >= MAX_WRITE_LEN)
974 len = ist30xx_tunes.len;
976 while (wcnt < ist30xx_tunes.len) {
977 ret = ist30xx_write_buf(ts_data->client, waddr, buf32, len);
979 tsp_err("Tunes regstore i2c_fail, ret=%d\n", ret);
985 if ((ist30xx_tunes.len - wcnt) < MAX_WRITE_LEN)
986 len = ist30xx_tunes.len - wcnt;
988 buf32 += MAX_WRITE_LEN;
989 waddr += MAX_WRITE_LEN * IST30XX_DATA_LEN;
992 tunes_cmd_done = false;
997 ssize_t tunes_reg_show(struct device *dev, struct device_attribute *attr,
1002 u32 *buf32 = (u32 *)buf;
1004 #if I2C_MONOPOLY_MODE
1005 unsigned long flags;
1008 if (unlikely(ist30xx_tunes.cmd != TUNES_CMD_READ)) {
1009 tsp_err("error, IST30XX_REG_CMD is not correct!\n");
1013 if (unlikely(!tunes_cmd_done)) {
1014 tsp_err("error, IST30XX_REG_CMD is not ready!\n");
1018 size = ist30xx_tunes.len;
1019 ret = ist30xx_write_cmd(ts_data->client, IST30XX_RX_CNT_ADDR, size);
1020 if (unlikely(ret)) {
1021 tsp_err("Tunes regshow i2c_fail, ret=%d\n", ret);
1025 #if I2C_MONOPOLY_MODE
1026 local_irq_save(flags); // Activated only when the GPIO I2C is used
1028 ret = ist30xx_read_buf(ts_data->client, ist30xx_tunes.addr, buf32, size);
1029 #if I2C_MONOPOLY_MODE
1030 local_irq_restore(flags); // Activated only when the GPIO I2C is used
1032 if (unlikely(ret)) {
1033 tsp_err("Tunes regshow i2c_fail, ret=%d\n", ret);
1037 size = ist30xx_tunes.len * IST30XX_DATA_LEN;
1039 tunes_cmd_done = false;
1044 /* sysfs: /sys/class/touch/tunes/adb */
1045 ssize_t tunes_adb_store(struct device *dev, struct device_attribute *attr,
1046 const char *buf, size_t size)
1051 u32 cmd, addr, len, val;
1054 sscanf(buf, "%x %x %x", &cmd, &addr, &len);
1057 case TUNES_CMD_WRITE: /* write cmd */
1059 ptr = (char *)(buf + 15);
1061 while (write_len < len) {
1062 memcpy(token, ptr, 8);
1064 val = simple_strtoul(token, &tmp, 16);
1065 ret = ist30xx_write_buf(ts_data->client, addr, &val, 1);
1066 if (unlikely(ret)) {
1067 tsp_err("Tunes regstore i2c_fail, ret=%d\n", ret);
1077 case TUNES_CMD_READ: /* read cmd */
1078 ist30xx_tunes.cmd = cmd;
1079 ist30xx_tunes.addr = addr;
1080 ist30xx_tunes.len = len;
1083 case TUNES_CMD_REG_ENTER: /* enter */
1084 ist30xx_disable_irq(ts_data);
1085 ist30xx_reset(false);
1087 ret = ist30xx_cmd_reg(ts_data->client, CMD_ENTER_REG_ACCESS);
1088 if (unlikely(ret < 0))
1090 ist30xx_reg_mode = true;
1093 case TUNES_CMD_REG_EXIT: /* exit */
1094 if (ist30xx_reg_mode == true) {
1095 ret = ist30xx_cmd_reg(ts_data->client, CMD_EXIT_REG_ACCESS);
1096 if (unlikely(ret < 0))
1099 ret = ist30xx_cmd_start_scan(ts_data->client);
1100 if (unlikely(ret < 0))
1102 ist30xx_reg_mode = false;
1103 ist30xx_enable_irq(ts_data);
1114 tsp_err("Tunes adb i2c_fail\n");
1118 ssize_t tunes_adb_show(struct device *dev, struct device_attribute *attr,
1122 int i, len, size = 0;
1125 #if I2C_MONOPOLY_MODE
1126 unsigned long flags;
1129 ret = ist30xx_write_cmd(ts_data->client, IST30XX_RX_CNT_ADDR,
1131 if (unlikely(ret)) {
1132 tsp_err("Tunes adbshow i2c_fail, ret=%d\n", ret);
1136 #if I2C_MONOPOLY_MODE
1137 local_irq_save(flags);
1139 ret = ist30xx_read_buf(ts_data->client, ist30xx_tunes.addr,
1140 ist30xx_frame_buf, ist30xx_tunes.len);
1141 #if I2C_MONOPOLY_MODE
1142 local_irq_restore(flags);
1144 if (unlikely(ret)) {
1145 tsp_err("Tunes adbshow i2c_fail, ret=%d\n", ret);
1151 len = sprintf(reg_val, "%08x", ist30xx_tunes.addr);
1152 strcat(buf, reg_val);
1154 for (i = 0; i < ist30xx_tunes.len; i++) {
1155 len = sprintf(reg_val, "%08x", ist30xx_frame_buf[i]);
1156 strcat(buf, reg_val);
1163 #if IST30XX_ALGORITHM_MODE
1164 /* sysfs: /sys/class/touch/tunes/algorithm */
1165 extern u32 ist30xx_algr_addr, ist30xx_algr_size;
1166 ssize_t ist30xx_algr_store(struct device *dev, struct device_attribute *attr,
1167 const char *buf, size_t size)
1169 sscanf(buf, "%x %d", &ist30xx_algr_addr, &ist30xx_algr_size);
1171 tsp_info("Algorithm addr: 0x%x, count: %d\n",
1172 ist30xx_algr_addr, ist30xx_algr_size);
1174 ist30xx_algr_addr |= IST30XXB_ACCESS_ADDR;
1179 ssize_t ist30xx_algr_show(struct device *dev, struct device_attribute *attr,
1186 ret = ist30xx_read_cmd(ts_data->client, IST30XXB_MEM_ALGORITHM, &algr_addr);
1187 if (unlikely(ret)) {
1188 tsp_warn("Algorithm mem addr read fail!\n");
1192 tsp_info("algr_addr(0x%x): 0x%x\n", IST30XXB_MEM_ALGORITHM, algr_addr);
1194 count = sprintf(buf, "Algorithm addr : 0x%x\n", algr_addr);
1198 #endif // IST30XX_ALGORITHM_MODE
1200 /* sysfs: /sys/class/touch/tunes/intr_debug */
1201 extern u32 intr_debug_addr, intr_debug_size;
1202 ssize_t intr_debug_store(struct device *dev, struct device_attribute *attr,
1203 const char *buf, size_t size)
1205 sscanf(buf, "%x %d", &intr_debug_addr, &intr_debug_size);
1206 tsp_info("Interrupt debug addr: 0x%x, count: %d\n",
1207 intr_debug_addr, intr_debug_size);
1209 intr_debug_addr |= IST30XXB_ACCESS_ADDR;
1214 ssize_t intr_debug_show(struct device *dev, struct device_attribute *attr,
1219 tsp_info("intr_debug_addr(0x%x): %d\n", intr_debug_addr, intr_debug_size);
1221 count = sprintf(buf, "intr_debug_addr(0x%x): %d\n",
1222 intr_debug_addr, intr_debug_size);
1227 /* sysfs: /sys/class/touch/tunes/intr_debug2 */
1228 extern u32 intr_debug2_addr, intr_debug2_size;
1229 ssize_t intr_debug2_store(struct device *dev, struct device_attribute *attr,
1230 const char *buf, size_t size)
1232 sscanf(buf, "%x %d", &intr_debug2_addr, &intr_debug2_size);
1233 tsp_info("Interrupt debug2 addr: 0x%x, count: %d\n",
1234 intr_debug2_addr, intr_debug2_size);
1236 intr_debug2_addr |= IST30XXB_ACCESS_ADDR;
1241 ssize_t intr_debug2_show(struct device *dev, struct device_attribute *attr,
1246 tsp_info("intr_debug2_addr(0x%x): %d\n",
1247 intr_debug2_addr, intr_debug2_size);
1249 count = sprintf(buf, "intr_debug2_addr(0x%x): %d\n",
1250 intr_debug2_addr, intr_debug2_size);
1255 /* sysfs: /sys/class/touch/tunes/intr_debug3 */
1256 extern u32 intr_debug3_addr, intr_debug3_size;
1257 ssize_t intr_debug3_store(struct device *dev, struct device_attribute *attr,
1258 const char *buf, size_t size)
1260 sscanf(buf, "%x %d", &intr_debug3_addr, &intr_debug3_size);
1261 tsp_info("Interrupt debug3 addr: 0x%x, count: %d\n",
1262 intr_debug3_addr, intr_debug3_size);
1264 intr_debug3_addr |= IST30XXB_ACCESS_ADDR;
1269 ssize_t intr_debug3_show(struct device *dev, struct device_attribute *attr,
1274 tsp_info("intr_debug3_addr(0x%x): %d\n",
1275 intr_debug3_addr, intr_debug3_size);
1277 count = sprintf(buf, "intr_debug3_addr(0x%x): %d\n",
1278 intr_debug3_addr, intr_debug3_size);
1284 u8 *ts_chkic_bin = NULL;
1285 u32 ts_chkic_bin_size = 0;
1286 u32 ts_chkic_result = 0;
1288 int chkic_ms_delay = IST30XX_CHKIC_WAIT;
1289 int ist30xx_chkic_wait(void)
1291 int cnt = chkic_ms_delay;
1293 ts_data->status.chkic_msg = 0;
1297 if (ts_data->status.chkic_msg) {
1298 if (ts_data->status.chkic_msg == IST30XX_CHKIC_END)
1304 tsp_warn("Fault test time out\n");
1309 #define chkic_next_step(ret) { if (unlikely(ret)) goto end; msleep(5); }
1310 int ist30xx_chkic_test(const u8 *buf, int size)
1315 u32 chkic_chksum = 0;
1317 struct i2c_client *client = (struct i2c_client *)ts_data->client;
1319 tsp_info("*** Check IC ***\n");
1321 /* Result initial */
1322 ts_chkic_result = 0;
1324 /* Parse chkicsum */
1325 chkic_chksum = *((u32 *)&buf[size - IST30XX_CHECKSUM_SIZE]);
1326 tsp_verb("Read binary info - chksum: 0x%08x size: 0x%x\n",
1327 chkic_chksum, size);
1329 ist30xx_disable_irq(ts_data);
1331 ist30xx_reset(false);
1333 /* Load IC chkic test code */
1334 ret = ist30xx_write_cmd(client, CMD_EXEC_MEM_CODE, 0);
1335 chkic_next_step(ret);
1338 len = size / IST30XX_DATA_LEN;
1339 tsp_verb("%08x %08x %08x %08x\n", buf32[0], buf32[1], buf32[2], buf32[3]);
1340 ret = ist30xx_write_buf(client, len, buf32, len);
1341 chkic_next_step(ret);
1343 /* Check load end */
1344 ret = ist30xx_read_cmd(client, CMD_DEFAULT, &chksum);
1345 chkic_next_step(ret);
1346 if (chksum != IST30XX_CHKIC_LOAD_END)
1348 tsp_info("Check ic code ready!!\n");
1351 ret = ist30xx_read_cmd(client, CMD_DEFAULT, &chksum);
1352 chkic_next_step(ret);
1353 tsp_info("Check ic chksum: %08x, %08x\n", chksum, chkic_chksum);
1355 ist30xx_enable_irq(ts_data);
1356 /* Wait IC chkic result */
1357 if (ist30xx_chkic_wait() != 0)
1358 tsp_info("Check ic timeout!!\n");
1360 ist30xx_disable_irq(ts_data);
1362 /* Read IC chkic result */
1363 ret = ist30xx_read_cmd(client, CMD_DEFAULT, &ts_chkic_result);
1364 chkic_next_step(ret);
1365 tsp_info("Read result value: %08x\n", ts_chkic_result);
1367 ist30xx_reset(false);
1369 ist30xx_start(ts_data);
1372 if (unlikely(ret)) {
1373 tsp_warn("Check ic error, ret=%d\n", ret);
1374 } else if (unlikely(chksum != chkic_chksum)) {
1375 tsp_warn("Chksum error, chksum=%x(%x)\n", chksum, chkic_chksum);
1379 ist30xx_enable_irq(ts_data);
1384 /* sysfs: /sys/class/touch/chkic/chkic */
1385 static ssize_t ist30xx_chkic_show(struct device *dev,
1386 struct device_attribute *attr, char *buf)
1390 if ((ts_chkic_bin == NULL) || (ts_chkic_bin_size == 0))
1391 return sprintf(buf, "Binary is not correct(%d)\n", ts_chkic_bin_size);
1393 mutex_lock(&ist30xx_mutex);
1394 ret = ist30xx_chkic_test(ts_chkic_bin, ts_chkic_bin_size);
1395 mutex_unlock(&ist30xx_mutex);
1397 if (ts_chkic_result == IST30XX_CHKIC_OK)
1398 return sprintf(buf, "Check IC : OK");
1399 else if (ts_chkic_result == IST30XX_CHKIC_FAIL)
1400 return sprintf(buf, "Check IC : FAIL");
1402 return sprintf(buf, "Check IC : ERROR");
1407 static DEVICE_ATTR(refresh, S_IRWXUGO, ist30xx_frame_refresh, NULL);
1408 static DEVICE_ATTR(nocp, S_IRWXUGO, ist30xx_frame_nocp, NULL);
1409 static DEVICE_ATTR(filter, S_IRWXUGO, ist30xx_filter_show, NULL);
1410 static DEVICE_ATTR(raw, S_IRWXUGO, ist30xx_raw_show, NULL);
1411 static DEVICE_ATTR(base, S_IRWXUGO, ist30xx_base_show, NULL);
1412 static DEVICE_ATTR(diff, S_IRWXUGO, ist30xx_diff_show, NULL);
1415 static DEVICE_ATTR(printk, S_IRWXUGO,
1416 ist30xx_printk_show, ist30xx_printk_store);
1417 static DEVICE_ATTR(printk5, S_IRWXUGO, ist30xx_printk5_show, NULL);
1418 static DEVICE_ATTR(printk6, S_IRWXUGO, ist30xx_printk6_show, NULL);
1419 static DEVICE_ATTR(direct, S_IRWXUGO,
1420 ist30xxb_direct_show, ist30xxb_direct_store);
1421 static DEVICE_ATTR(clb_time, S_IRWXUGO, NULL, ist30xx_calib_time_store);
1422 static DEVICE_ATTR(clb, S_IRWXUGO, ist30xx_calib_show, NULL);
1423 static DEVICE_ATTR(clb_result, S_IRWXUGO, ist30xx_calib_result_show, NULL);
1424 static DEVICE_ATTR(tsp_power_on, S_IRWXUGO, ist30xx_power_on_show, NULL);
1425 static DEVICE_ATTR(tsp_power_off, S_IRWXUGO, ist30xx_power_off_show, NULL);
1426 static DEVICE_ATTR(errcnt, S_IRWXUGO, NULL, ist30xx_errcnt_store);
1427 #if IST30XX_EVENT_MODE
1428 static DEVICE_ATTR(scancnt, S_IRWXUGO, NULL, ist30xx_scancnt_store);
1429 static DEVICE_ATTR(timerms, S_IRWXUGO, NULL, ist30xx_timerms_store);
1431 static DEVICE_ATTR(report_rate, S_IRWXUGO, NULL, ist30xx_touch_rate_store);
1432 static DEVICE_ATTR(idle_rate, S_IRWXUGO, NULL, ist30xx_idle_scan_rate_store);
1433 static DEVICE_ATTR(mode_ta, S_IRWXUGO, NULL, ist30xx_ta_mode_store);
1434 static DEVICE_ATTR(mode_call, S_IRWXUGO, NULL, ist30xx_call_mode_store);
1435 static DEVICE_ATTR(mode_cover, S_IRWXUGO, NULL, ist30xx_cover_mode_store);
1436 static DEVICE_ATTR(max_touch, S_IRWXUGO, NULL, ist30xx_touch_store);
1439 static DEVICE_ATTR(node_info, S_IRWXUGO, tunes_node_info_show, NULL);
1440 static DEVICE_ATTR(regcmd, S_IRWXUGO, tunes_regcmd_show, tunes_regcmd_store);
1441 static DEVICE_ATTR(reg, S_IRWXUGO, tunes_reg_show, tunes_reg_store);
1442 static DEVICE_ATTR(adb, S_IRWXUGO, tunes_adb_show, tunes_adb_store);
1443 #if IST30XX_ALGORITHM_MODE
1444 static DEVICE_ATTR(algorithm, S_IRWXUGO, ist30xx_algr_show, ist30xx_algr_store);
1446 static DEVICE_ATTR(intr_debug, S_IRWXUGO, intr_debug_show, intr_debug_store);
1447 static DEVICE_ATTR(intr_debug2, S_IRWXUGO, intr_debug2_show, intr_debug2_store);
1448 static DEVICE_ATTR(intr_debug3, S_IRWXUGO, intr_debug3_show, intr_debug3_store);
1452 static DEVICE_ATTR(chkic, S_IRUGO, ist30xx_chkic_show, NULL);
1455 static struct attribute *node_attributes[] = {
1456 &dev_attr_refresh.attr,
1457 &dev_attr_nocp.attr,
1458 &dev_attr_filter.attr,
1460 &dev_attr_base.attr,
1461 &dev_attr_diff.attr,
1465 static struct attribute *sys_attributes[] = {
1466 &dev_attr_printk.attr,
1467 &dev_attr_printk5.attr,
1468 &dev_attr_printk6.attr,
1469 &dev_attr_direct.attr,
1470 &dev_attr_clb_time.attr,
1472 &dev_attr_clb_result.attr,
1473 &dev_attr_tsp_power_on.attr,
1474 &dev_attr_tsp_power_off.attr,
1475 &dev_attr_errcnt.attr,
1476 #if IST30XX_EVENT_MODE
1477 &dev_attr_scancnt.attr,
1478 &dev_attr_timerms.attr,
1480 &dev_attr_report_rate.attr,
1481 &dev_attr_idle_rate.attr,
1482 &dev_attr_mode_ta.attr,
1483 &dev_attr_mode_call.attr,
1484 &dev_attr_mode_cover.attr,
1485 &dev_attr_max_touch.attr,
1489 static struct attribute *tunes_attributes[] = {
1490 &dev_attr_node_info.attr,
1491 &dev_attr_regcmd.attr,
1494 #if IST30XX_ALGORITHM_MODE
1495 &dev_attr_algorithm.attr,
1497 &dev_attr_intr_debug.attr,
1498 &dev_attr_intr_debug2.attr,
1499 &dev_attr_intr_debug3.attr,
1504 static struct attribute *chkic_attributes[] = {
1505 &dev_attr_chkic.attr,
1510 static struct attribute_group node_attr_group = {
1511 .attrs = node_attributes,
1514 static struct attribute_group sys_attr_group = {
1515 .attrs = sys_attributes,
1518 static struct attribute_group tunes_attr_group = {
1519 .attrs = tunes_attributes,
1523 static struct attribute_group chkic_attr_group = {
1524 .attrs = chkic_attributes,
1528 extern struct class *ist30xx_class;
1529 struct device *ist30xx_sys_dev;
1530 struct device *ist30xx_tunes_dev;
1531 struct device *ist30xx_node_dev;
1533 struct device *ist30xx_chkic_dev;
1536 int ist30xx_init_misc_sysfs(void)
1538 /* /sys/class/touch/sys */
1539 ist30xx_sys_dev = device_create(ist30xx_class, NULL, 0, NULL, "sys");
1541 /* /sys/class/touch/sys/... */
1542 if (unlikely(sysfs_create_group(&ist30xx_sys_dev->kobj,
1544 tsp_err("Failed to create sysfs group(%s)!\n", "sys");
1546 /* /sys/class/touch/tunes */
1547 ist30xx_tunes_dev = device_create(ist30xx_class, NULL, 0, NULL, "tunes");
1549 /* /sys/class/touch/tunes/... */
1550 if (unlikely(sysfs_create_group(&ist30xx_tunes_dev->kobj,
1551 &tunes_attr_group)))
1552 tsp_err("Failed to create sysfs group(%s)!\n", "tunes");
1554 /* /sys/class/touch/node */
1555 ist30xx_node_dev = device_create(ist30xx_class, NULL, 0, NULL, "node");
1557 /* /sys/class/touch/node/... */
1558 if (unlikely(sysfs_create_group(&ist30xx_node_dev->kobj,
1560 tsp_err("Failed to create sysfs group(%s)!\n", "node");
1563 /* /sys/class/touch/chkic */
1564 ist30xx_chkic_dev = device_create(ist30xx_class, NULL, 0, NULL, "chkic");
1566 /* /sys/class/touch/chkic/... */
1567 if (unlikely(sysfs_create_group(&ist30xx_chkic_dev->kobj,
1568 &chkic_attr_group)))
1569 tsp_err("Failed to create sysfs group(%s)!\n", "chkic");
1571 ts_chkic_bin = (u8 *)ist30xxb_chkic;
1572 ts_chkic_bin_size = sizeof(ist30xxb_chkic);
1575 ist30xx_frame_buf = kmalloc(4096, GFP_KERNEL);
1576 ist30xx_frame_rawbuf = kmalloc(4096, GFP_KERNEL);
1577 ist30xx_frame_fltbuf = kmalloc(4096, GFP_KERNEL);
1578 if (!ist30xx_frame_buf || !ist30xx_frame_rawbuf || !ist30xx_frame_fltbuf)