linux-020-edt-touch-make-gain-offset-threshold-writeable.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. --- a/drivers/input/touchscreen/edt-ft5x06.c 2017-09-26 15:27:56.685769326 +0200
  2. +++ b/drivers/input/touchscreen/edt-ft5x06.c 2017-09-25 08:00:57.530768619 +0200
  3. @@ -639,6 +639,111 @@
  4. return 0;
  5. }
  6. +
  7. +static int edt_ft5x06_debugfs_threshold_get(void *data, u64 *threshold)
  8. +{
  9. + struct edt_ft5x06_ts_data *tsdata = data;
  10. +
  11. + *threshold = (u64)(tsdata->threshold);
  12. +
  13. + return 0;
  14. +};
  15. +
  16. +static int edt_ft5x06_debugfs_threshold_set(void *data, u64 threshold)
  17. +{
  18. + struct edt_ft5x06_ts_data *tsdata = data;
  19. + struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
  20. + int retval = 0;
  21. +
  22. +/* if (param > ??????)
  23. + return -ERANGE;
  24. +*/
  25. + mutex_lock(&tsdata->mutex);
  26. +
  27. + tsdata->threshold = (int)(threshold);
  28. + edt_ft5x06_register_write(tsdata, reg_addr->reg_threshold,
  29. + tsdata->threshold);
  30. + tsdata->threshold = edt_ft5x06_register_read(tsdata,
  31. + reg_addr->reg_threshold);
  32. +
  33. + mutex_unlock(&tsdata->mutex);
  34. +
  35. + return retval;
  36. +};
  37. +
  38. +DEFINE_SIMPLE_ATTRIBUTE(debugfs_threshold_fops, edt_ft5x06_debugfs_threshold_get,
  39. + edt_ft5x06_debugfs_threshold_set, "%llu\n");
  40. +
  41. +
  42. +static int edt_ft5x06_debugfs_gain_get(void *data, u64 *gain)
  43. +{
  44. + struct edt_ft5x06_ts_data *tsdata = data;
  45. +
  46. + *gain = (u64)(tsdata->gain);
  47. +
  48. + return 0;
  49. +};
  50. +
  51. +static int edt_ft5x06_debugfs_gain_set(void *data, u64 gain)
  52. +{
  53. + struct edt_ft5x06_ts_data *tsdata = data;
  54. + struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
  55. + int retval = 0;
  56. +
  57. +/* if (param > ??????)
  58. + return -ERANGE;
  59. +*/
  60. + mutex_lock(&tsdata->mutex);
  61. +
  62. + tsdata->gain = (int)(gain);
  63. + edt_ft5x06_register_write(tsdata, reg_addr->reg_gain,
  64. + tsdata->gain);
  65. + tsdata->gain = edt_ft5x06_register_read(tsdata,
  66. + reg_addr->reg_gain);
  67. +
  68. + mutex_unlock(&tsdata->mutex);
  69. +
  70. + return retval;
  71. +};
  72. +
  73. +DEFINE_SIMPLE_ATTRIBUTE(debugfs_gain_fops, edt_ft5x06_debugfs_gain_get,
  74. + edt_ft5x06_debugfs_gain_set, "%llu\n");
  75. +
  76. +
  77. +static int edt_ft5x06_debugfs_offset_get(void *data, u64 *offset)
  78. +{
  79. + struct edt_ft5x06_ts_data *tsdata = data;
  80. +
  81. + *offset = (u64)(tsdata->offset);
  82. +
  83. + return 0;
  84. +};
  85. +
  86. +static int edt_ft5x06_debugfs_offset_set(void *data, u64 offset)
  87. +{
  88. + struct edt_ft5x06_ts_data *tsdata = data;
  89. + struct edt_reg_addr *reg_addr = &tsdata->reg_addr;
  90. + int retval = 0;
  91. +
  92. +/* if (param > ??????)
  93. + return -ERANGE;
  94. +*/
  95. + mutex_lock(&tsdata->mutex);
  96. +
  97. + tsdata->offset = (int)(offset);
  98. + edt_ft5x06_register_write(tsdata, reg_addr->reg_offset,
  99. + tsdata->offset);
  100. + tsdata->offset = edt_ft5x06_register_read(tsdata,
  101. + reg_addr->reg_offset);
  102. +
  103. + mutex_unlock(&tsdata->mutex);
  104. +
  105. + return retval;
  106. +};
  107. +
  108. +DEFINE_SIMPLE_ATTRIBUTE(debugfs_offset_fops, edt_ft5x06_debugfs_offset_get,
  109. + edt_ft5x06_debugfs_offset_set, "%llu\n");
  110. +
  111. static int edt_ft5x06_debugfs_mode_get(void *data, u64 *mode)
  112. {
  113. struct edt_ft5x06_ts_data *tsdata = data;
  114. @@ -766,10 +871,19 @@
  115. debugfs_create_u16("num_x", S_IRUSR, tsdata->debug_dir, &tsdata->num_x);
  116. debugfs_create_u16("num_y", S_IRUSR, tsdata->debug_dir, &tsdata->num_y);
  117. +
  118. +/*
  119. debugfs_create_u32("threshold", S_IRUSR, tsdata->debug_dir, &tsdata->threshold);
  120. debugfs_create_u32("gain", S_IRUSR, tsdata->debug_dir, &tsdata->gain);
  121. debugfs_create_u32("offset", S_IRUSR, tsdata->debug_dir, &tsdata->offset);
  122. +*/
  123. + debugfs_create_file("threshold", S_IRUSR | S_IWUSR,
  124. + tsdata->debug_dir, tsdata, &debugfs_threshold_fops);
  125. + debugfs_create_file("gain", S_IRUSR | S_IWUSR,
  126. + tsdata->debug_dir, tsdata, &debugfs_gain_fops);
  127. + debugfs_create_file("offset", S_IRUSR | S_IWUSR,
  128. + tsdata->debug_dir, tsdata, &debugfs_offset_fops);
  129. debugfs_create_file("mode", S_IRUSR | S_IWUSR,
  130. tsdata->debug_dir, tsdata, &debugfs_mode_fops);