aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorNoralf Trønnes <noralf@tronnes.org>2018-11-10 09:56:47 -0500
committerNoralf Trønnes <noralf@tronnes.org>2018-11-20 08:58:19 -0500
commit3db8d37dd84e93f352b8a8d34a713415cd1a6d0f (patch)
tree30d24df108e711b85628e252399df6b2bda5a95e /drivers/gpu
parentb9068cde51eea189c2c3560a9a8ae83f7b213c9c (diff)
drm/tinydrm: Use DRM_GEM_CMA_VMAP_DRIVER_OPS
The CMA helper now has the functionality to ensure a virtual address on imported buffer so use that. While touching all tinydrm drivers, remove the unnecessary inclusion of drm_fb_helper.h in some drivers. Cc: David Lechner <david@lechnology.com> Cc: Eric Anholt <eric@anholt.net> Signed-off-by: Noralf Trønnes <noralf@tronnes.org> Acked-by: Christian König <christian.koenig@amd.com> Reviewed-by: Eric Anholt <eric@anholt.net> Link: https://patchwork.freedesktop.org/patch/msgid/20181110145647.17580-6-noralf@tronnes.org
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/tinydrm/core/tinydrm-core.c71
-rw-r--r--drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c6
-rw-r--r--drivers/gpu/drm/tinydrm/hx8357d.c4
-rw-r--r--drivers/gpu/drm/tinydrm/ili9225.c5
-rw-r--r--drivers/gpu/drm/tinydrm/ili9341.c4
-rw-r--r--drivers/gpu/drm/tinydrm/mi0283qt.c6
-rw-r--r--drivers/gpu/drm/tinydrm/mipi-dbi.c10
-rw-r--r--drivers/gpu/drm/tinydrm/repaper.c4
-rw-r--r--drivers/gpu/drm/tinydrm/st7586.c5
-rw-r--r--drivers/gpu/drm/tinydrm/st7735r.c4
10 files changed, 31 insertions, 88 deletions
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
index 9af51d982a33..01a6f2d42440 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
@@ -36,77 +36,6 @@
36 * and registers the DRM device using devm_tinydrm_register(). 36 * and registers the DRM device using devm_tinydrm_register().
37 */ 37 */
38 38
39/**
40 * tinydrm_gem_cma_prime_import_sg_table - Produce a CMA GEM object from
41 * another driver's scatter/gather table of pinned pages
42 * @drm: DRM device to import into
43 * @attach: DMA-BUF attachment
44 * @sgt: Scatter/gather table of pinned pages
45 *
46 * This function imports a scatter/gather table exported via DMA-BUF by
47 * another driver using drm_gem_cma_prime_import_sg_table(). It sets the
48 * kernel virtual address on the CMA object. Drivers should use this as their
49 * &drm_driver->gem_prime_import_sg_table callback if they need the virtual
50 * address. tinydrm_gem_cma_free_object() should be used in combination with
51 * this function.
52 *
53 * Returns:
54 * A pointer to a newly created GEM object or an ERR_PTR-encoded negative
55 * error code on failure.
56 */
57struct drm_gem_object *
58tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
59 struct dma_buf_attachment *attach,
60 struct sg_table *sgt)
61{
62 struct drm_gem_cma_object *cma_obj;
63 struct drm_gem_object *obj;
64 void *vaddr;
65
66 vaddr = dma_buf_vmap(attach->dmabuf);
67 if (!vaddr) {
68 DRM_ERROR("Failed to vmap PRIME buffer\n");
69 return ERR_PTR(-ENOMEM);
70 }
71
72 obj = drm_gem_cma_prime_import_sg_table(drm, attach, sgt);
73 if (IS_ERR(obj)) {
74 dma_buf_vunmap(attach->dmabuf, vaddr);
75 return obj;
76 }
77
78 cma_obj = to_drm_gem_cma_obj(obj);
79 cma_obj->vaddr = vaddr;
80
81 return obj;
82}
83EXPORT_SYMBOL(tinydrm_gem_cma_prime_import_sg_table);
84
85/**
86 * tinydrm_gem_cma_free_object - Free resources associated with a CMA GEM
87 * object
88 * @gem_obj: GEM object to free
89 *
90 * This function frees the backing memory of the CMA GEM object, cleans up the
91 * GEM object state and frees the memory used to store the object itself using
92 * drm_gem_cma_free_object(). It also handles PRIME buffers which has the kernel
93 * virtual address set by tinydrm_gem_cma_prime_import_sg_table(). Drivers
94 * can use this as their &drm_driver->gem_free_object_unlocked callback.
95 */
96void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj)
97{
98 if (gem_obj->import_attach) {
99 struct drm_gem_cma_object *cma_obj;
100
101 cma_obj = to_drm_gem_cma_obj(gem_obj);
102 dma_buf_vunmap(gem_obj->import_attach->dmabuf, cma_obj->vaddr);
103 cma_obj->vaddr = NULL;
104 }
105
106 drm_gem_cma_free_object(gem_obj);
107}
108EXPORT_SYMBOL_GPL(tinydrm_gem_cma_free_object);
109
110static struct drm_framebuffer * 39static struct drm_framebuffer *
111tinydrm_fb_create(struct drm_device *drm, struct drm_file *file_priv, 40tinydrm_fb_create(struct drm_device *drm, struct drm_file *file_priv,
112 const struct drm_mode_fb_cmd2 *mode_cmd) 41 const struct drm_mode_fb_cmd2 *mode_cmd)
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
index dcd390163a4a..bf6bfbc5d412 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c
@@ -9,12 +9,18 @@
9 9
10#include <linux/backlight.h> 10#include <linux/backlight.h>
11#include <linux/dma-buf.h> 11#include <linux/dma-buf.h>
12#include <linux/module.h>
12#include <linux/pm.h> 13#include <linux/pm.h>
13#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
14#include <linux/swab.h> 15#include <linux/swab.h>
15 16
17#include <drm/drm_device.h>
18#include <drm/drm_drv.h>
19#include <drm/drm_fourcc.h>
20#include <drm/drm_print.h>
16#include <drm/tinydrm/tinydrm.h> 21#include <drm/tinydrm/tinydrm.h>
17#include <drm/tinydrm/tinydrm-helpers.h> 22#include <drm/tinydrm/tinydrm-helpers.h>
23#include <uapi/drm/drm.h>
18 24
19static unsigned int spi_max; 25static unsigned int spi_max;
20module_param(spi_max, uint, 0400); 26module_param(spi_max, uint, 0400);
diff --git a/drivers/gpu/drm/tinydrm/hx8357d.c b/drivers/gpu/drm/tinydrm/hx8357d.c
index c3e51c2baebc..81a2bbeb25d4 100644
--- a/drivers/gpu/drm/tinydrm/hx8357d.c
+++ b/drivers/gpu/drm/tinydrm/hx8357d.c
@@ -16,7 +16,7 @@
16#include <linux/property.h> 16#include <linux/property.h>
17#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
18 18
19#include <drm/drm_fb_helper.h> 19#include <drm/drm_gem_cma_helper.h>
20#include <drm/drm_gem_framebuffer_helper.h> 20#include <drm/drm_gem_framebuffer_helper.h>
21#include <drm/drm_modeset_helper.h> 21#include <drm/drm_modeset_helper.h>
22#include <drm/tinydrm/mipi-dbi.h> 22#include <drm/tinydrm/mipi-dbi.h>
@@ -188,7 +188,7 @@ DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);
188static struct drm_driver hx8357d_driver = { 188static struct drm_driver hx8357d_driver = {
189 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC, 189 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
190 .fops = &hx8357d_fops, 190 .fops = &hx8357d_fops,
191 TINYDRM_GEM_DRIVER_OPS, 191 DRM_GEM_CMA_VMAP_DRIVER_OPS,
192 .debugfs_init = mipi_dbi_debugfs_init, 192 .debugfs_init = mipi_dbi_debugfs_init,
193 .name = "hx8357d", 193 .name = "hx8357d",
194 .desc = "HX8357D", 194 .desc = "HX8357D",
diff --git a/drivers/gpu/drm/tinydrm/ili9225.c b/drivers/gpu/drm/tinydrm/ili9225.c
index 455fefe012f5..78f7c2d1b449 100644
--- a/drivers/gpu/drm/tinydrm/ili9225.c
+++ b/drivers/gpu/drm/tinydrm/ili9225.c
@@ -20,7 +20,8 @@
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <video/mipi_display.h> 21#include <video/mipi_display.h>
22 22
23#include <drm/drm_fb_helper.h> 23#include <drm/drm_fb_cma_helper.h>
24#include <drm/drm_gem_cma_helper.h>
24#include <drm/drm_gem_framebuffer_helper.h> 25#include <drm/drm_gem_framebuffer_helper.h>
25#include <drm/tinydrm/mipi-dbi.h> 26#include <drm/tinydrm/mipi-dbi.h>
26#include <drm/tinydrm/tinydrm-helpers.h> 27#include <drm/tinydrm/tinydrm-helpers.h>
@@ -367,7 +368,7 @@ static struct drm_driver ili9225_driver = {
367 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | 368 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
368 DRIVER_ATOMIC, 369 DRIVER_ATOMIC,
369 .fops = &ili9225_fops, 370 .fops = &ili9225_fops,
370 TINYDRM_GEM_DRIVER_OPS, 371 DRM_GEM_CMA_VMAP_DRIVER_OPS,
371 .name = "ili9225", 372 .name = "ili9225",
372 .desc = "Ilitek ILI9225", 373 .desc = "Ilitek ILI9225",
373 .date = "20171106", 374 .date = "20171106",
diff --git a/drivers/gpu/drm/tinydrm/ili9341.c b/drivers/gpu/drm/tinydrm/ili9341.c
index 6701037749a7..51395bdc6ca2 100644
--- a/drivers/gpu/drm/tinydrm/ili9341.c
+++ b/drivers/gpu/drm/tinydrm/ili9341.c
@@ -15,7 +15,7 @@
15#include <linux/property.h> 15#include <linux/property.h>
16#include <linux/spi/spi.h> 16#include <linux/spi/spi.h>
17 17
18#include <drm/drm_fb_helper.h> 18#include <drm/drm_gem_cma_helper.h>
19#include <drm/drm_gem_framebuffer_helper.h> 19#include <drm/drm_gem_framebuffer_helper.h>
20#include <drm/drm_modeset_helper.h> 20#include <drm/drm_modeset_helper.h>
21#include <drm/tinydrm/mipi-dbi.h> 21#include <drm/tinydrm/mipi-dbi.h>
@@ -144,7 +144,7 @@ DEFINE_DRM_GEM_CMA_FOPS(ili9341_fops);
144static struct drm_driver ili9341_driver = { 144static struct drm_driver ili9341_driver = {
145 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC, 145 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
146 .fops = &ili9341_fops, 146 .fops = &ili9341_fops,
147 TINYDRM_GEM_DRIVER_OPS, 147 DRM_GEM_CMA_VMAP_DRIVER_OPS,
148 .debugfs_init = mipi_dbi_debugfs_init, 148 .debugfs_init = mipi_dbi_debugfs_init,
149 .name = "ili9341", 149 .name = "ili9341",
150 .desc = "Ilitek ILI9341", 150 .desc = "Ilitek ILI9341",
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c b/drivers/gpu/drm/tinydrm/mi0283qt.c
index d7bb4c5e6657..3fa62e77c30b 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -17,9 +17,9 @@
17#include <linux/regulator/consumer.h> 17#include <linux/regulator/consumer.h>
18#include <linux/spi/spi.h> 18#include <linux/spi/spi.h>
19 19
20#include <drm/drm_fb_helper.h> 20#include <drm/drm_gem_cma_helper.h>
21#include <drm/drm_modeset_helper.h>
22#include <drm/drm_gem_framebuffer_helper.h> 21#include <drm/drm_gem_framebuffer_helper.h>
22#include <drm/drm_modeset_helper.h>
23#include <drm/tinydrm/mipi-dbi.h> 23#include <drm/tinydrm/mipi-dbi.h>
24#include <drm/tinydrm/tinydrm-helpers.h> 24#include <drm/tinydrm/tinydrm-helpers.h>
25#include <video/mipi_display.h> 25#include <video/mipi_display.h>
@@ -153,7 +153,7 @@ static struct drm_driver mi0283qt_driver = {
153 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | 153 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
154 DRIVER_ATOMIC, 154 DRIVER_ATOMIC,
155 .fops = &mi0283qt_fops, 155 .fops = &mi0283qt_fops,
156 TINYDRM_GEM_DRIVER_OPS, 156 DRM_GEM_CMA_VMAP_DRIVER_OPS,
157 .debugfs_init = mipi_dbi_debugfs_init, 157 .debugfs_init = mipi_dbi_debugfs_init,
158 .name = "mi0283qt", 158 .name = "mi0283qt",
159 .desc = "Multi-Inno MI0283QT", 159 .desc = "Multi-Inno MI0283QT",
diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c
index 1bb870021f6e..3a05e56f9b0d 100644
--- a/drivers/gpu/drm/tinydrm/mipi-dbi.c
+++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c
@@ -9,15 +9,19 @@
9 * (at your option) any later version. 9 * (at your option) any later version.
10 */ 10 */
11 11
12#include <drm/drm_gem_framebuffer_helper.h>
13#include <drm/tinydrm/mipi-dbi.h>
14#include <drm/tinydrm/tinydrm-helpers.h>
15#include <linux/debugfs.h> 12#include <linux/debugfs.h>
16#include <linux/dma-buf.h> 13#include <linux/dma-buf.h>
17#include <linux/gpio/consumer.h> 14#include <linux/gpio/consumer.h>
18#include <linux/module.h> 15#include <linux/module.h>
19#include <linux/regulator/consumer.h> 16#include <linux/regulator/consumer.h>
20#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
18
19#include <drm/drm_fb_cma_helper.h>
20#include <drm/drm_gem_cma_helper.h>
21#include <drm/drm_gem_framebuffer_helper.h>
22#include <drm/tinydrm/mipi-dbi.h>
23#include <drm/tinydrm/tinydrm-helpers.h>
24#include <uapi/drm/drm.h>
21#include <video/mipi_display.h> 25#include <video/mipi_display.h>
22 26
23#define MIPI_DBI_MAX_SPI_READ_SPEED 2000000 /* 2MHz */ 27#define MIPI_DBI_MAX_SPI_READ_SPEED 2000000 /* 2MHz */
diff --git a/drivers/gpu/drm/tinydrm/repaper.c b/drivers/gpu/drm/tinydrm/repaper.c
index 50a1d4216ce7..07f45a008a0f 100644
--- a/drivers/gpu/drm/tinydrm/repaper.c
+++ b/drivers/gpu/drm/tinydrm/repaper.c
@@ -26,6 +26,8 @@
26#include <linux/spi/spi.h> 26#include <linux/spi/spi.h>
27#include <linux/thermal.h> 27#include <linux/thermal.h>
28 28
29#include <drm/drm_fb_cma_helper.h>
30#include <drm/drm_gem_cma_helper.h>
29#include <drm/drm_gem_framebuffer_helper.h> 31#include <drm/drm_gem_framebuffer_helper.h>
30#include <drm/tinydrm/tinydrm.h> 32#include <drm/tinydrm/tinydrm.h>
31#include <drm/tinydrm/tinydrm-helpers.h> 33#include <drm/tinydrm/tinydrm-helpers.h>
@@ -882,7 +884,7 @@ static struct drm_driver repaper_driver = {
882 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | 884 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
883 DRIVER_ATOMIC, 885 DRIVER_ATOMIC,
884 .fops = &repaper_fops, 886 .fops = &repaper_fops,
885 TINYDRM_GEM_DRIVER_OPS, 887 DRM_GEM_CMA_VMAP_DRIVER_OPS,
886 .name = "repaper", 888 .name = "repaper",
887 .desc = "Pervasive Displays RePaper e-ink panels", 889 .desc = "Pervasive Displays RePaper e-ink panels",
888 .date = "20170405", 890 .date = "20170405",
diff --git a/drivers/gpu/drm/tinydrm/st7586.c b/drivers/gpu/drm/tinydrm/st7586.c
index 2fcbc3067d71..a6a8a1081b73 100644
--- a/drivers/gpu/drm/tinydrm/st7586.c
+++ b/drivers/gpu/drm/tinydrm/st7586.c
@@ -17,7 +17,8 @@
17#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
18#include <video/mipi_display.h> 18#include <video/mipi_display.h>
19 19
20#include <drm/drm_fb_helper.h> 20#include <drm/drm_fb_cma_helper.h>
21#include <drm/drm_gem_cma_helper.h>
21#include <drm/drm_gem_framebuffer_helper.h> 22#include <drm/drm_gem_framebuffer_helper.h>
22#include <drm/tinydrm/mipi-dbi.h> 23#include <drm/tinydrm/mipi-dbi.h>
23#include <drm/tinydrm/tinydrm-helpers.h> 24#include <drm/tinydrm/tinydrm-helpers.h>
@@ -303,7 +304,7 @@ static struct drm_driver st7586_driver = {
303 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | 304 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
304 DRIVER_ATOMIC, 305 DRIVER_ATOMIC,
305 .fops = &st7586_fops, 306 .fops = &st7586_fops,
306 TINYDRM_GEM_DRIVER_OPS, 307 DRM_GEM_CMA_VMAP_DRIVER_OPS,
307 .debugfs_init = mipi_dbi_debugfs_init, 308 .debugfs_init = mipi_dbi_debugfs_init,
308 .name = "st7586", 309 .name = "st7586",
309 .desc = "Sitronix ST7586", 310 .desc = "Sitronix ST7586",
diff --git a/drivers/gpu/drm/tinydrm/st7735r.c b/drivers/gpu/drm/tinydrm/st7735r.c
index 3081bc57c116..b39779e0dcd8 100644
--- a/drivers/gpu/drm/tinydrm/st7735r.c
+++ b/drivers/gpu/drm/tinydrm/st7735r.c
@@ -14,7 +14,7 @@
14#include <linux/spi/spi.h> 14#include <linux/spi/spi.h>
15#include <video/mipi_display.h> 15#include <video/mipi_display.h>
16 16
17#include <drm/drm_fb_helper.h> 17#include <drm/drm_gem_cma_helper.h>
18#include <drm/drm_gem_framebuffer_helper.h> 18#include <drm/drm_gem_framebuffer_helper.h>
19#include <drm/tinydrm/mipi-dbi.h> 19#include <drm/tinydrm/mipi-dbi.h>
20#include <drm/tinydrm/tinydrm-helpers.h> 20#include <drm/tinydrm/tinydrm-helpers.h>
@@ -119,7 +119,7 @@ static struct drm_driver st7735r_driver = {
119 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | 119 .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
120 DRIVER_ATOMIC, 120 DRIVER_ATOMIC,
121 .fops = &st7735r_fops, 121 .fops = &st7735r_fops,
122 TINYDRM_GEM_DRIVER_OPS, 122 DRM_GEM_CMA_VMAP_DRIVER_OPS,
123 .debugfs_init = mipi_dbi_debugfs_init, 123 .debugfs_init = mipi_dbi_debugfs_init,
124 .name = "st7735r", 124 .name = "st7735r",
125 .desc = "Sitronix ST7735R", 125 .desc = "Sitronix ST7735R",