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