Skip to content

Commit 3db8d37

Browse files
committed
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
1 parent b9068cd commit 3db8d37

11 files changed

Lines changed: 38 additions & 116 deletions

File tree

‎drivers/gpu/drm/tinydrm/core/tinydrm-core.c‎

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -36,77 +36,6 @@
3636
* and registers the DRM device using devm_tinydrm_register().
3737
*/
3838

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-
*/
57-
struct drm_gem_object *
58-
tinydrm_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-
}
83-
EXPORT_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-
*/
96-
void 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-
}
108-
EXPORT_SYMBOL_GPL(tinydrm_gem_cma_free_object);
109-
11039
static struct drm_framebuffer *
11140
tinydrm_fb_create(struct drm_device *drm, struct drm_file *file_priv,
11241
const struct drm_mode_fb_cmd2 *mode_cmd)

‎drivers/gpu/drm/tinydrm/core/tinydrm-helpers.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@
99

1010
#include <linux/backlight.h>
1111
#include <linux/dma-buf.h>
12+
#include <linux/module.h>
1213
#include <linux/pm.h>
1314
#include <linux/spi/spi.h>
1415
#include <linux/swab.h>
1516

17+
#include <drm/drm_device.h>
18+
#include <drm/drm_drv.h>
19+
#include <drm/drm_fourcc.h>
20+
#include <drm/drm_print.h>
1621
#include <drm/tinydrm/tinydrm.h>
1722
#include <drm/tinydrm/tinydrm-helpers.h>
23+
#include <uapi/drm/drm.h>
1824

1925
static unsigned int spi_max;
2026
module_param(spi_max, uint, 0400);

‎drivers/gpu/drm/tinydrm/hx8357d.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <linux/property.h>
1717
#include <linux/spi/spi.h>
1818

19-
#include <drm/drm_fb_helper.h>
19+
#include <drm/drm_gem_cma_helper.h>
2020
#include <drm/drm_gem_framebuffer_helper.h>
2121
#include <drm/drm_modeset_helper.h>
2222
#include <drm/tinydrm/mipi-dbi.h>
@@ -188,7 +188,7 @@ DEFINE_DRM_GEM_CMA_FOPS(hx8357d_fops);
188188
static struct drm_driver hx8357d_driver = {
189189
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
190190
.fops = &hx8357d_fops,
191-
TINYDRM_GEM_DRIVER_OPS,
191+
DRM_GEM_CMA_VMAP_DRIVER_OPS,
192192
.debugfs_init = mipi_dbi_debugfs_init,
193193
.name = "hx8357d",
194194
.desc = "HX8357D",

‎drivers/gpu/drm/tinydrm/ili9225.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#include <linux/spi/spi.h>
2121
#include <video/mipi_display.h>
2222

23-
#include <drm/drm_fb_helper.h>
23+
#include <drm/drm_fb_cma_helper.h>
24+
#include <drm/drm_gem_cma_helper.h>
2425
#include <drm/drm_gem_framebuffer_helper.h>
2526
#include <drm/tinydrm/mipi-dbi.h>
2627
#include <drm/tinydrm/tinydrm-helpers.h>
@@ -367,7 +368,7 @@ static struct drm_driver ili9225_driver = {
367368
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
368369
DRIVER_ATOMIC,
369370
.fops = &ili9225_fops,
370-
TINYDRM_GEM_DRIVER_OPS,
371+
DRM_GEM_CMA_VMAP_DRIVER_OPS,
371372
.name = "ili9225",
372373
.desc = "Ilitek ILI9225",
373374
.date = "20171106",

‎drivers/gpu/drm/tinydrm/ili9341.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <linux/property.h>
1616
#include <linux/spi/spi.h>
1717

18-
#include <drm/drm_fb_helper.h>
18+
#include <drm/drm_gem_cma_helper.h>
1919
#include <drm/drm_gem_framebuffer_helper.h>
2020
#include <drm/drm_modeset_helper.h>
2121
#include <drm/tinydrm/mipi-dbi.h>
@@ -144,7 +144,7 @@ DEFINE_DRM_GEM_CMA_FOPS(ili9341_fops);
144144
static struct drm_driver ili9341_driver = {
145145
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC,
146146
.fops = &ili9341_fops,
147-
TINYDRM_GEM_DRIVER_OPS,
147+
DRM_GEM_CMA_VMAP_DRIVER_OPS,
148148
.debugfs_init = mipi_dbi_debugfs_init,
149149
.name = "ili9341",
150150
.desc = "Ilitek ILI9341",

‎drivers/gpu/drm/tinydrm/mi0283qt.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#include <linux/regulator/consumer.h>
1818
#include <linux/spi/spi.h>
1919

20-
#include <drm/drm_fb_helper.h>
21-
#include <drm/drm_modeset_helper.h>
20+
#include <drm/drm_gem_cma_helper.h>
2221
#include <drm/drm_gem_framebuffer_helper.h>
22+
#include <drm/drm_modeset_helper.h>
2323
#include <drm/tinydrm/mipi-dbi.h>
2424
#include <drm/tinydrm/tinydrm-helpers.h>
2525
#include <video/mipi_display.h>
@@ -153,7 +153,7 @@ static struct drm_driver mi0283qt_driver = {
153153
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
154154
DRIVER_ATOMIC,
155155
.fops = &mi0283qt_fops,
156-
TINYDRM_GEM_DRIVER_OPS,
156+
DRM_GEM_CMA_VMAP_DRIVER_OPS,
157157
.debugfs_init = mipi_dbi_debugfs_init,
158158
.name = "mi0283qt",
159159
.desc = "Multi-Inno MI0283QT",

‎drivers/gpu/drm/tinydrm/mipi-dbi.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@
99
* (at your option) any later version.
1010
*/
1111

12-
#include <drm/drm_gem_framebuffer_helper.h>
13-
#include <drm/tinydrm/mipi-dbi.h>
14-
#include <drm/tinydrm/tinydrm-helpers.h>
1512
#include <linux/debugfs.h>
1613
#include <linux/dma-buf.h>
1714
#include <linux/gpio/consumer.h>
1815
#include <linux/module.h>
1916
#include <linux/regulator/consumer.h>
2017
#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>
2125
#include <video/mipi_display.h>
2226

2327
#define MIPI_DBI_MAX_SPI_READ_SPEED 2000000 /* 2MHz */

‎drivers/gpu/drm/tinydrm/repaper.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include <linux/spi/spi.h>
2727
#include <linux/thermal.h>
2828

29+
#include <drm/drm_fb_cma_helper.h>
30+
#include <drm/drm_gem_cma_helper.h>
2931
#include <drm/drm_gem_framebuffer_helper.h>
3032
#include <drm/tinydrm/tinydrm.h>
3133
#include <drm/tinydrm/tinydrm-helpers.h>
@@ -882,7 +884,7 @@ static struct drm_driver repaper_driver = {
882884
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
883885
DRIVER_ATOMIC,
884886
.fops = &repaper_fops,
885-
TINYDRM_GEM_DRIVER_OPS,
887+
DRM_GEM_CMA_VMAP_DRIVER_OPS,
886888
.name = "repaper",
887889
.desc = "Pervasive Displays RePaper e-ink panels",
888890
.date = "20170405",

‎drivers/gpu/drm/tinydrm/st7586.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#include <linux/spi/spi.h>
1818
#include <video/mipi_display.h>
1919

20-
#include <drm/drm_fb_helper.h>
20+
#include <drm/drm_fb_cma_helper.h>
21+
#include <drm/drm_gem_cma_helper.h>
2122
#include <drm/drm_gem_framebuffer_helper.h>
2223
#include <drm/tinydrm/mipi-dbi.h>
2324
#include <drm/tinydrm/tinydrm-helpers.h>
@@ -303,7 +304,7 @@ static struct drm_driver st7586_driver = {
303304
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
304305
DRIVER_ATOMIC,
305306
.fops = &st7586_fops,
306-
TINYDRM_GEM_DRIVER_OPS,
307+
DRM_GEM_CMA_VMAP_DRIVER_OPS,
307308
.debugfs_init = mipi_dbi_debugfs_init,
308309
.name = "st7586",
309310
.desc = "Sitronix ST7586",

‎drivers/gpu/drm/tinydrm/st7735r.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <linux/spi/spi.h>
1515
#include <video/mipi_display.h>
1616

17-
#include <drm/drm_fb_helper.h>
17+
#include <drm/drm_gem_cma_helper.h>
1818
#include <drm/drm_gem_framebuffer_helper.h>
1919
#include <drm/tinydrm/mipi-dbi.h>
2020
#include <drm/tinydrm/tinydrm-helpers.h>
@@ -119,7 +119,7 @@ static struct drm_driver st7735r_driver = {
119119
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
120120
DRIVER_ATOMIC,
121121
.fops = &st7735r_fops,
122-
TINYDRM_GEM_DRIVER_OPS,
122+
DRM_GEM_CMA_VMAP_DRIVER_OPS,
123123
.debugfs_init = mipi_dbi_debugfs_init,
124124
.name = "st7735r",
125125
.desc = "Sitronix ST7735R",

0 commit comments

Comments
 (0)