diff options
author | Lucas Stach <l.stach@pengutronix.de> | 2017-11-10 11:10:01 -0500 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2017-12-19 06:49:11 -0500 |
commit | 37aca51b08ca48df4212cbb2137197d4737b8585 (patch) | |
tree | d4809cfd9077273111ea2dd6a57fa1662dee7c73 /drivers | |
parent | 9222f768f7b09fea4f12914b376ec975ef758a60 (diff) |
drm/imx: advertise supported plane format modifiers
Let userspace know about the supported modifiers, to make automatic
selection of a proper modifier possible.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/imx/ipuv3-plane.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c index 32a6debf7107..849f4bde2a1a 100644 --- a/drivers/gpu/drm/imx/ipuv3-plane.c +++ b/drivers/gpu/drm/imx/ipuv3-plane.c | |||
@@ -77,6 +77,18 @@ static const uint32_t ipu_plane_formats[] = { | |||
77 | DRM_FORMAT_BGRX8888_A8, | 77 | DRM_FORMAT_BGRX8888_A8, |
78 | }; | 78 | }; |
79 | 79 | ||
80 | static const uint64_t ipu_format_modifiers[] = { | ||
81 | DRM_FORMAT_MOD_LINEAR, | ||
82 | DRM_FORMAT_MOD_INVALID | ||
83 | }; | ||
84 | |||
85 | static const uint64_t pre_format_modifiers[] = { | ||
86 | DRM_FORMAT_MOD_LINEAR, | ||
87 | DRM_FORMAT_MOD_VIVANTE_TILED, | ||
88 | DRM_FORMAT_MOD_VIVANTE_SUPER_TILED, | ||
89 | DRM_FORMAT_MOD_INVALID | ||
90 | }; | ||
91 | |||
80 | int ipu_plane_irq(struct ipu_plane *ipu_plane) | 92 | int ipu_plane_irq(struct ipu_plane *ipu_plane) |
81 | { | 93 | { |
82 | return ipu_idmac_channel_irq(ipu_plane->ipu, ipu_plane->ipu_ch, | 94 | return ipu_idmac_channel_irq(ipu_plane->ipu, ipu_plane->ipu_ch, |
@@ -303,6 +315,22 @@ void ipu_plane_destroy_state(struct drm_plane *plane, | |||
303 | kfree(ipu_state); | 315 | kfree(ipu_state); |
304 | } | 316 | } |
305 | 317 | ||
318 | static bool ipu_plane_format_mod_supported(struct drm_plane *plane, | ||
319 | uint32_t format, uint64_t modifier) | ||
320 | { | ||
321 | struct ipu_soc *ipu = to_ipu_plane(plane)->ipu; | ||
322 | |||
323 | /* linear is supported for all planes and formats */ | ||
324 | if (modifier == DRM_FORMAT_MOD_LINEAR) | ||
325 | return true; | ||
326 | |||
327 | /* without a PRG there are no supported modifiers */ | ||
328 | if (!ipu_prg_present(ipu)) | ||
329 | return false; | ||
330 | |||
331 | return ipu_prg_format_supported(ipu, format, modifier); | ||
332 | } | ||
333 | |||
306 | static const struct drm_plane_funcs ipu_plane_funcs = { | 334 | static const struct drm_plane_funcs ipu_plane_funcs = { |
307 | .update_plane = drm_atomic_helper_update_plane, | 335 | .update_plane = drm_atomic_helper_update_plane, |
308 | .disable_plane = drm_atomic_helper_disable_plane, | 336 | .disable_plane = drm_atomic_helper_disable_plane, |
@@ -310,6 +338,7 @@ static const struct drm_plane_funcs ipu_plane_funcs = { | |||
310 | .reset = ipu_plane_state_reset, | 338 | .reset = ipu_plane_state_reset, |
311 | .atomic_duplicate_state = ipu_plane_duplicate_state, | 339 | .atomic_duplicate_state = ipu_plane_duplicate_state, |
312 | .atomic_destroy_state = ipu_plane_destroy_state, | 340 | .atomic_destroy_state = ipu_plane_destroy_state, |
341 | .format_mod_supported = ipu_plane_format_mod_supported, | ||
313 | }; | 342 | }; |
314 | 343 | ||
315 | static int ipu_plane_atomic_check(struct drm_plane *plane, | 344 | static int ipu_plane_atomic_check(struct drm_plane *plane, |
@@ -784,6 +813,7 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu, | |||
784 | enum drm_plane_type type) | 813 | enum drm_plane_type type) |
785 | { | 814 | { |
786 | struct ipu_plane *ipu_plane; | 815 | struct ipu_plane *ipu_plane; |
816 | const uint64_t *modifiers = ipu_format_modifiers; | ||
787 | int ret; | 817 | int ret; |
788 | 818 | ||
789 | DRM_DEBUG_KMS("channel %d, dp flow %d, possible_crtcs=0x%x\n", | 819 | DRM_DEBUG_KMS("channel %d, dp flow %d, possible_crtcs=0x%x\n", |
@@ -799,10 +829,13 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu, | |||
799 | ipu_plane->dma = dma; | 829 | ipu_plane->dma = dma; |
800 | ipu_plane->dp_flow = dp; | 830 | ipu_plane->dp_flow = dp; |
801 | 831 | ||
832 | if (ipu_prg_present(ipu)) | ||
833 | modifiers = pre_format_modifiers; | ||
834 | |||
802 | ret = drm_universal_plane_init(dev, &ipu_plane->base, possible_crtcs, | 835 | ret = drm_universal_plane_init(dev, &ipu_plane->base, possible_crtcs, |
803 | &ipu_plane_funcs, ipu_plane_formats, | 836 | &ipu_plane_funcs, ipu_plane_formats, |
804 | ARRAY_SIZE(ipu_plane_formats), | 837 | ARRAY_SIZE(ipu_plane_formats), |
805 | NULL, type, NULL); | 838 | modifiers, type, NULL); |
806 | if (ret) { | 839 | if (ret) { |
807 | DRM_ERROR("failed to initialize plane\n"); | 840 | DRM_ERROR("failed to initialize plane\n"); |
808 | kfree(ipu_plane); | 841 | kfree(ipu_plane); |