tinydrm-helpers.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (C) 2016 Noralf Trønnes
  3. *
  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.
  8. */
  9. #ifndef __LINUX_TINYDRM_HELPERS_H
  10. #define __LINUX_TINYDRM_HELPERS_H
  11. struct backlight_device;
  12. struct tinydrm_device;
  13. struct drm_clip_rect;
  14. struct spi_transfer;
  15. struct spi_message;
  16. struct spi_device;
  17. struct device;
  18. /**
  19. * tinydrm_machine_little_endian - Machine is little endian
  20. *
  21. * Returns:
  22. * true if *defined(__LITTLE_ENDIAN)*, false otherwise
  23. */
  24. static inline bool tinydrm_machine_little_endian(void)
  25. {
  26. #if defined(__LITTLE_ENDIAN)
  27. return true;
  28. #else
  29. return false;
  30. #endif
  31. }
  32. bool tinydrm_merge_clips(struct drm_clip_rect *dst,
  33. struct drm_clip_rect *src, unsigned int num_clips,
  34. unsigned int flags, u32 max_width, u32 max_height);
  35. int tinydrm_fb_dirty(struct drm_framebuffer *fb,
  36. struct drm_file *file_priv,
  37. unsigned int flags, unsigned int color,
  38. struct drm_clip_rect *clips,
  39. unsigned int num_clips);
  40. void tinydrm_memcpy(void *dst, void *vaddr, struct drm_framebuffer *fb,
  41. struct drm_clip_rect *clip);
  42. void tinydrm_swab16(u16 *dst, void *vaddr, struct drm_framebuffer *fb,
  43. struct drm_clip_rect *clip);
  44. void tinydrm_xrgb8888_to_rgb565(u16 *dst, void *vaddr,
  45. struct drm_framebuffer *fb,
  46. struct drm_clip_rect *clip, bool swap);
  47. void tinydrm_xrgb8888_to_gray8(u8 *dst, void *vaddr, struct drm_framebuffer *fb,
  48. struct drm_clip_rect *clip);
  49. size_t tinydrm_spi_max_transfer_size(struct spi_device *spi, size_t max_len);
  50. bool tinydrm_spi_bpw_supported(struct spi_device *spi, u8 bpw);
  51. int tinydrm_spi_transfer(struct spi_device *spi, u32 speed_hz,
  52. struct spi_transfer *header, u8 bpw, const void *buf,
  53. size_t len);
  54. void _tinydrm_dbg_spi_message(struct spi_device *spi, struct spi_message *m);
  55. #ifdef DEBUG
  56. /**
  57. * tinydrm_dbg_spi_message - Dump SPI message
  58. * @spi: SPI device
  59. * @m: SPI message
  60. *
  61. * Dumps info about the transfers in a SPI message including buffer content.
  62. * DEBUG has to be defined for this function to be enabled alongside setting
  63. * the DRM_UT_DRIVER bit of &drm_debug.
  64. */
  65. static inline void tinydrm_dbg_spi_message(struct spi_device *spi,
  66. struct spi_message *m)
  67. {
  68. if (drm_debug & DRM_UT_DRIVER)
  69. _tinydrm_dbg_spi_message(spi, m);
  70. }
  71. #else
  72. static inline void tinydrm_dbg_spi_message(struct spi_device *spi,
  73. struct spi_message *m)
  74. {
  75. }
  76. #endif /* DEBUG */
  77. #endif /* __LINUX_TINYDRM_HELPERS_H */