diff options
author | Maxime Jourdan <mjourdan@baylibre.com> | 2018-11-05 05:45:08 -0500 |
---|---|---|
committer | Neil Armstrong <narmstrong@baylibre.com> | 2018-11-13 05:51:34 -0500 |
commit | 66cae477c380d1a652399908de94ec680225bbdb (patch) | |
tree | 1eac4d0a99d958fb22abec1993298bd32967102f | |
parent | 2b80b98b722bc8f174275e1bcad2122bd9dacee2 (diff) |
drm/meson: Use optional canvas provider
This is the first step into converting the meson/drm driver to use
the canvas module.
If a canvas provider node is detected in DT, use it. Otherwise,
fall back to what is currently being done.
Signed-off-by: Maxime Jourdan <mjourdan@baylibre.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
[narmstrong: added back priv in meson_drv_unbind()]
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181105104508.23090-3-mjourdan@baylibre.com
-rw-r--r-- | drivers/gpu/drm/meson/Kconfig | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/meson/meson_crtc.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/meson/meson_drv.c | 47 | ||||
-rw-r--r-- | drivers/gpu/drm/meson/meson_drv.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/meson/meson_plane.c | 8 |
5 files changed, 52 insertions, 22 deletions
diff --git a/drivers/gpu/drm/meson/Kconfig b/drivers/gpu/drm/meson/Kconfig index 3ce51d8dfe1c..c28b69f48555 100644 --- a/drivers/gpu/drm/meson/Kconfig +++ b/drivers/gpu/drm/meson/Kconfig | |||
@@ -7,6 +7,7 @@ config DRM_MESON | |||
7 | select DRM_GEM_CMA_HELPER | 7 | select DRM_GEM_CMA_HELPER |
8 | select VIDEOMODE_HELPERS | 8 | select VIDEOMODE_HELPERS |
9 | select REGMAP_MMIO | 9 | select REGMAP_MMIO |
10 | select MESON_CANVAS | ||
10 | 11 | ||
11 | config DRM_MESON_DW_HDMI | 12 | config DRM_MESON_DW_HDMI |
12 | tristate "HDMI Synopsys Controller support for Amlogic Meson Display" | 13 | tristate "HDMI Synopsys Controller support for Amlogic Meson Display" |
diff --git a/drivers/gpu/drm/meson/meson_crtc.c b/drivers/gpu/drm/meson/meson_crtc.c index 05520202c967..b3bc0b0ee07f 100644 --- a/drivers/gpu/drm/meson/meson_crtc.c +++ b/drivers/gpu/drm/meson/meson_crtc.c | |||
@@ -193,10 +193,16 @@ void meson_crtc_irq(struct meson_drm *priv) | |||
193 | } else | 193 | } else |
194 | meson_vpp_disable_interlace_vscaler_osd1(priv); | 194 | meson_vpp_disable_interlace_vscaler_osd1(priv); |
195 | 195 | ||
196 | meson_canvas_setup(priv, MESON_CANVAS_ID_OSD1, | 196 | if (priv->canvas) |
197 | priv->viu.osd1_addr, priv->viu.osd1_stride, | 197 | meson_canvas_config(priv->canvas, priv->canvas_id_osd1, |
198 | priv->viu.osd1_height, MESON_CANVAS_WRAP_NONE, | 198 | priv->viu.osd1_addr, priv->viu.osd1_stride, |
199 | MESON_CANVAS_BLKMODE_LINEAR); | 199 | priv->viu.osd1_height, MESON_CANVAS_WRAP_NONE, |
200 | MESON_CANVAS_BLKMODE_LINEAR, 0); | ||
201 | else | ||
202 | meson_canvas_setup(priv, MESON_CANVAS_ID_OSD1, | ||
203 | priv->viu.osd1_addr, priv->viu.osd1_stride, | ||
204 | priv->viu.osd1_height, MESON_CANVAS_WRAP_NONE, | ||
205 | MESON_CANVAS_BLKMODE_LINEAR); | ||
200 | 206 | ||
201 | /* Enable OSD1 */ | 207 | /* Enable OSD1 */ |
202 | writel_bits_relaxed(VPP_OSD1_POSTBLEND, VPP_OSD1_POSTBLEND, | 208 | writel_bits_relaxed(VPP_OSD1_POSTBLEND, VPP_OSD1_POSTBLEND, |
diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c index 348b5a198b9d..3fe6edf79b5c 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c | |||
@@ -208,24 +208,33 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) | |||
208 | goto free_drm; | 208 | goto free_drm; |
209 | } | 209 | } |
210 | 210 | ||
211 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmc"); | 211 | priv->canvas = meson_canvas_get(dev); |
212 | if (!res) { | 212 | if (!IS_ERR(priv->canvas)) { |
213 | ret = -EINVAL; | 213 | ret = meson_canvas_alloc(priv->canvas, &priv->canvas_id_osd1); |
214 | goto free_drm; | 214 | if (ret) |
215 | } | 215 | goto free_drm; |
216 | /* Simply ioremap since it may be a shared register zone */ | 216 | } else { |
217 | regs = devm_ioremap(dev, res->start, resource_size(res)); | 217 | priv->canvas = NULL; |
218 | if (!regs) { | ||
219 | ret = -EADDRNOTAVAIL; | ||
220 | goto free_drm; | ||
221 | } | ||
222 | 218 | ||
223 | priv->dmc = devm_regmap_init_mmio(dev, regs, | 219 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmc"); |
224 | &meson_regmap_config); | 220 | if (!res) { |
225 | if (IS_ERR(priv->dmc)) { | 221 | ret = -EINVAL; |
226 | dev_err(&pdev->dev, "Couldn't create the DMC regmap\n"); | 222 | goto free_drm; |
227 | ret = PTR_ERR(priv->dmc); | 223 | } |
228 | goto free_drm; | 224 | /* Simply ioremap since it may be a shared register zone */ |
225 | regs = devm_ioremap(dev, res->start, resource_size(res)); | ||
226 | if (!regs) { | ||
227 | ret = -EADDRNOTAVAIL; | ||
228 | goto free_drm; | ||
229 | } | ||
230 | |||
231 | priv->dmc = devm_regmap_init_mmio(dev, regs, | ||
232 | &meson_regmap_config); | ||
233 | if (IS_ERR(priv->dmc)) { | ||
234 | dev_err(&pdev->dev, "Couldn't create the DMC regmap\n"); | ||
235 | ret = PTR_ERR(priv->dmc); | ||
236 | goto free_drm; | ||
237 | } | ||
229 | } | 238 | } |
230 | 239 | ||
231 | priv->vsync_irq = platform_get_irq(pdev, 0); | 240 | priv->vsync_irq = platform_get_irq(pdev, 0); |
@@ -300,6 +309,10 @@ static int meson_drv_bind(struct device *dev) | |||
300 | static void meson_drv_unbind(struct device *dev) | 309 | static void meson_drv_unbind(struct device *dev) |
301 | { | 310 | { |
302 | struct drm_device *drm = dev_get_drvdata(dev); | 311 | struct drm_device *drm = dev_get_drvdata(dev); |
312 | struct meson_drm *priv = drm->dev_private; | ||
313 | |||
314 | if (priv->canvas) | ||
315 | meson_canvas_free(priv->canvas, priv->canvas_id_osd1); | ||
303 | 316 | ||
304 | drm_dev_unregister(drm); | 317 | drm_dev_unregister(drm); |
305 | drm_kms_helper_poll_fini(drm); | 318 | drm_kms_helper_poll_fini(drm); |
diff --git a/drivers/gpu/drm/meson/meson_drv.h b/drivers/gpu/drm/meson/meson_drv.h index aab96260da9f..747a996dcbdd 100644 --- a/drivers/gpu/drm/meson/meson_drv.h +++ b/drivers/gpu/drm/meson/meson_drv.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/regmap.h> | 23 | #include <linux/regmap.h> |
24 | #include <linux/of.h> | 24 | #include <linux/of.h> |
25 | #include <linux/soc/amlogic/meson-canvas.h> | ||
25 | #include <drm/drmP.h> | 26 | #include <drm/drmP.h> |
26 | 27 | ||
27 | struct meson_drm { | 28 | struct meson_drm { |
@@ -31,6 +32,9 @@ struct meson_drm { | |||
31 | struct regmap *dmc; | 32 | struct regmap *dmc; |
32 | int vsync_irq; | 33 | int vsync_irq; |
33 | 34 | ||
35 | struct meson_canvas *canvas; | ||
36 | u8 canvas_id_osd1; | ||
37 | |||
34 | struct drm_device *drm; | 38 | struct drm_device *drm; |
35 | struct drm_crtc *crtc; | 39 | struct drm_crtc *crtc; |
36 | struct drm_plane *primary_plane; | 40 | struct drm_plane *primary_plane; |
diff --git a/drivers/gpu/drm/meson/meson_plane.c b/drivers/gpu/drm/meson/meson_plane.c index 12c80dfcff59..51bec8e98a39 100644 --- a/drivers/gpu/drm/meson/meson_plane.c +++ b/drivers/gpu/drm/meson/meson_plane.c | |||
@@ -90,6 +90,7 @@ static void meson_plane_atomic_update(struct drm_plane *plane, | |||
90 | .y2 = state->crtc_y + state->crtc_h, | 90 | .y2 = state->crtc_y + state->crtc_h, |
91 | }; | 91 | }; |
92 | unsigned long flags; | 92 | unsigned long flags; |
93 | u8 canvas_id_osd1; | ||
93 | 94 | ||
94 | /* | 95 | /* |
95 | * Update Coordinates | 96 | * Update Coordinates |
@@ -104,8 +105,13 @@ static void meson_plane_atomic_update(struct drm_plane *plane, | |||
104 | (0xFF << OSD_GLOBAL_ALPHA_SHIFT) | | 105 | (0xFF << OSD_GLOBAL_ALPHA_SHIFT) | |
105 | OSD_BLK0_ENABLE; | 106 | OSD_BLK0_ENABLE; |
106 | 107 | ||
108 | if (priv->canvas) | ||
109 | canvas_id_osd1 = priv->canvas_id_osd1; | ||
110 | else | ||
111 | canvas_id_osd1 = MESON_CANVAS_ID_OSD1; | ||
112 | |||
107 | /* Set up BLK0 to point to the right canvas */ | 113 | /* Set up BLK0 to point to the right canvas */ |
108 | priv->viu.osd1_blk0_cfg[0] = ((MESON_CANVAS_ID_OSD1 << OSD_CANVAS_SEL) | | 114 | priv->viu.osd1_blk0_cfg[0] = ((canvas_id_osd1 << OSD_CANVAS_SEL) | |
109 | OSD_ENDIANNESS_LE); | 115 | OSD_ENDIANNESS_LE); |
110 | 116 | ||
111 | /* On GXBB, Use the old non-HDR RGB2YUV converter */ | 117 | /* On GXBB, Use the old non-HDR RGB2YUV converter */ |