0002-surface3-spi.patch 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 06e4d51c83a77d54ca5b1d402fb57554c51d3926 Mon Sep 17 00:00:00 2001
  2. From: kitakar5525 <34676735+kitakar5525@users.noreply.github.com>
  3. Date: Fri, 6 Dec 2019 23:10:30 +0900
  4. Subject: [PATCH 02/10] surface3-spi
  5. ---
  6. drivers/input/touchscreen/surface3_spi.c | 26 ++++++++++++++++++++++++
  7. 1 file changed, 26 insertions(+)
  8. diff --git a/drivers/input/touchscreen/surface3_spi.c b/drivers/input/touchscreen/surface3_spi.c
  9. index 5db0f1c4ef38..8935ddbc2357 100644
  10. --- a/drivers/input/touchscreen/surface3_spi.c
  11. +++ b/drivers/input/touchscreen/surface3_spi.c
  12. @@ -29,6 +29,12 @@
  13. #define SURFACE3_REPORT_TOUCH 0xd2
  14. #define SURFACE3_REPORT_PEN 0x16
  15. +bool use_dma = false;
  16. +module_param(use_dma, bool, 0644);
  17. +MODULE_PARM_DESC(use_dma,
  18. + "Disable DMA mode if you encounter touch input crash. "
  19. + "(default: false, disabled to avoid crash)");
  20. +
  21. struct surface3_ts_data {
  22. struct spi_device *spi;
  23. struct gpio_desc *gpiod_rst[2];
  24. @@ -330,6 +336,13 @@ static int surface3_spi_create_pen_input(struct surface3_ts_data *data)
  25. return 0;
  26. }
  27. +static bool surface3_spi_can_dma(struct spi_controller *ctlr,
  28. + struct spi_device *spi,
  29. + struct spi_transfer *tfr)
  30. +{
  31. + return use_dma;
  32. +}
  33. +
  34. static int surface3_spi_probe(struct spi_device *spi)
  35. {
  36. struct surface3_ts_data *data;
  37. @@ -372,6 +385,19 @@ static int surface3_spi_probe(struct spi_device *spi)
  38. if (error)
  39. return error;
  40. + /*
  41. + * Set up DMA
  42. + *
  43. + * TODO: Currently, touch input with DMA seems to be broken.
  44. + * On 4.19 LTS, touch input will crash after suspend.
  45. + * On recent stable kernel (at least after 5.1), touch input will crash after
  46. + * the first touch. No problem with PIO on those kernels.
  47. + * Maybe we need to configure DMA here.
  48. + *
  49. + * Link to issue: https://github.com/jakeday/linux-surface/issues/596
  50. + */
  51. + spi->controller->can_dma = surface3_spi_can_dma;
  52. +
  53. return 0;
  54. }
  55. --
  56. 2.26.2