[PATCH v2 6/8] drm/mipi-dbi: Support shadow-plane state
Thomas Zimmermann
tzimmermann at suse.de
Sat Dec 3 16:01:59 UTC 2022
Hi
Am 03.12.22 um 15:23 schrieb Noralf Trønnes:
>
>
> Den 02.12.2022 13.56, skrev Thomas Zimmermann:
>> Implement MIPI DBI planes with struct drm_shadow_plane_state, so that the
>> respective drivers can use the vmap'ed GEM-buffer memory. Implement state
>> helpers, the {begin,end}_fb_access helpers and wire up everything.
>>
>> With this commit, MIPI DBI drivers can access the GEM object's memory
>> that is provided by shadow-plane state. The actual changes to drivers
>> are implemented separately.
>>
>> v2:
>> * use shadow-plane state directly (Noralf)
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
>> Tested-by: Javier Martinez Canillas <javierm at redhat.com>
>> Tested-by: Noralf Trønnes <noralf at tronnes.org> # drm/tiny/mi0283qt
>> ---
>> drivers/gpu/drm/drm_mipi_dbi.c | 85 ++++++++++++++++++++++++++++++++++
>> drivers/gpu/drm/tiny/ili9225.c | 5 ++
>> drivers/gpu/drm/tiny/st7586.c | 5 ++
>> include/drm/drm_mipi_dbi.h | 16 ++++++-
>> 4 files changed, 110 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
>> index f58123327ed6..b808de61c5bc 100644
>> --- a/drivers/gpu/drm/drm_mipi_dbi.c
>> +++ b/drivers/gpu/drm/drm_mipi_dbi.c
>> @@ -21,6 +21,7 @@
>> #include <drm/drm_fourcc.h>
>> #include <drm/drm_framebuffer.h>
>> #include <drm/drm_gem.h>
>> +#include <drm/drm_gem_atomic_helper.h>
>> #include <drm/drm_gem_framebuffer_helper.h>
>> #include <drm/drm_mipi_dbi.h>
>> #include <drm/drm_modes.h>
>> @@ -433,6 +434,90 @@ void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe)
>> }
>> EXPORT_SYMBOL(mipi_dbi_pipe_disable);
>>
>> +/**
>> + * mipi_dbi_pipe_begin_fb_access - MIPI DBI pipe begin-access helper
>> + * @pipe: Display pipe
>> + * @plane_state: Plane state
>> + *
>> + * This function implements struct &drm_simple_display_funcs.begin_fb_access.
>> + *
>> + * See drm_gem_begin_shadow_fb_access() for details and mipi_dbi_pipe_cleanup_fb()
>> + * for cleanup.
>> + *
>> + * Returns:
>> + * 0 on success, or a negative errno code otherwise.
>> + */
>> +int mipi_dbi_pipe_begin_fb_access(struct drm_simple_display_pipe *pipe,
>> + struct drm_plane_state *plane_state)
>> +{
>> + return drm_gem_begin_shadow_fb_access(&pipe->plane, plane_state);
>> +}
>> +EXPORT_SYMBOL(mipi_dbi_pipe_begin_fb_access);
>> +
>> +/**
>> + * mipi_dbi_pipe_end_fb_access - MIPI DBI pipe end-access helper
>> + * @pipe: Display pipe
>> + * @plane_state: Plane state
>> + *
>> + * This function implements struct &drm_simple_display_funcs.end_fb_access.
>> + *
>> + * See mipi_dbi_pipe_begin_fb_access().
>> + */
>> +void mipi_dbi_pipe_end_fb_access(struct drm_simple_display_pipe *pipe,
>> + struct drm_plane_state *plane_state)
>> +{
>> + drm_gem_end_shadow_fb_access(&pipe->plane, plane_state);
>> +}
>> +EXPORT_SYMBOL(mipi_dbi_pipe_end_fb_access);
>> +
>> +/**
>> + * mipi_dbi_pipe_reset_plane - MIPI DBI plane-reset helper
>> + * @pipe: Display pipe
>> + *
>> + * This function implements struct &drm_simple_display_funcs.reset_plane
>> + * for MIPI DBI planes.
>> + */
>> +void mipi_dbi_pipe_reset_plane(struct drm_simple_display_pipe *pipe)
>> +{
>> + drm_gem_reset_shadow_plane(&pipe->plane);
>> +}
>> +EXPORT_SYMBOL(mipi_dbi_pipe_reset_plane);
>> +
>> +/**
>> + * mipi_dbi_pipe_duplicate_plane_state - duplicates MIPI DBI plane state
>> + * @pipe: Display pipe
>> + *
>> + * This function implements struct &drm_simple_display_funcs.duplicate_plane_state
>> + * for MIPI DBI planes.
>> + *
>> + * See drm_gem_duplicate_shadow_plane_state() for additional details.
>> + *
>> + * Returns:
>> + * A pointer to a new plane state on success, or NULL otherwise.
>> + */
>> +struct drm_plane_state *mipi_dbi_pipe_duplicate_plane_state(struct drm_simple_display_pipe *pipe)
>> +{
>> + return drm_gem_duplicate_shadow_plane_state(&pipe->plane);
>> +}
>> +EXPORT_SYMBOL(mipi_dbi_pipe_duplicate_plane_state);
>> +
>> +/**
>> + * mipi_dbi_pipe_destroy_plane_state - cleans up MIPI DBI plane state
>> + * @pipe: Display pipe
>> + * @plane_state: Plane state
>> + *
>> + * This function implements struct drm_simple_display_funcs.destroy_plane_state
>> + * for MIPI DBI planes.
>> + *
>> + * See drm_gem_destroy_shadow_plane_state() for additional details.
>> + */
>> +void mipi_dbi_pipe_destroy_plane_state(struct drm_simple_display_pipe *pipe,
>> + struct drm_plane_state *plane_state)
>> +{
>> + drm_gem_destroy_shadow_plane_state(&pipe->plane, plane_state);
>> +}
>> +EXPORT_SYMBOL(mipi_dbi_pipe_destroy_plane_state);
>> +
>> static int mipi_dbi_connector_get_modes(struct drm_connector *connector)
>> {
>> struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(connector->dev);
>> diff --git a/drivers/gpu/drm/tiny/ili9225.c b/drivers/gpu/drm/tiny/ili9225.c
>> index ae94c74d0163..a69aec8402bc 100644
>> --- a/drivers/gpu/drm/tiny/ili9225.c
>> +++ b/drivers/gpu/drm/tiny/ili9225.c
>> @@ -343,6 +343,11 @@ static const struct drm_simple_display_pipe_funcs ili9225_pipe_funcs = {
>> .enable = ili9225_pipe_enable,
>> .disable = ili9225_pipe_disable,
>> .update = ili9225_pipe_update,
>> + .begin_fb_access = mipi_dbi_pipe_begin_fb_access,
>> + .end_fb_access = mipi_dbi_pipe_end_fb_access,
>> + .reset_plane = mipi_dbi_pipe_reset_plane,
>> + .duplicate_plane_state = mipi_dbi_pipe_duplicate_plane_state,
>> + .destroy_plane_state = mipi_dbi_pipe_destroy_plane_state,
>> };
>
> Why not just use DRM_GEM_SIMPLE_DISPLAY_PIPE_SHADOW_PLANE_FUNCS?
The simple-kms mid-layer is more of a liability than a feature. It
requires us to have additional wrappers around common helpers, such the
shadow-plane code. I'd like to get rid of those wrappers as much as
possible. Not using them here is a first step.
Best regards
Thomas
>
> Noralf.
>
>>
>> static const struct drm_display_mode ili9225_mode = {
>> diff --git a/drivers/gpu/drm/tiny/st7586.c b/drivers/gpu/drm/tiny/st7586.c
>> index e773b1f2fd5f..76b13cefc904 100644
>> --- a/drivers/gpu/drm/tiny/st7586.c
>> +++ b/drivers/gpu/drm/tiny/st7586.c
>> @@ -277,6 +277,11 @@ static const struct drm_simple_display_pipe_funcs st7586_pipe_funcs = {
>> .enable = st7586_pipe_enable,
>> .disable = st7586_pipe_disable,
>> .update = st7586_pipe_update,
>> + .begin_fb_access = mipi_dbi_pipe_begin_fb_access,
>> + .end_fb_access = mipi_dbi_pipe_end_fb_access,
>> + .reset_plane = mipi_dbi_pipe_reset_plane,
>> + .duplicate_plane_state = mipi_dbi_pipe_duplicate_plane_state,
>> + .destroy_plane_state = mipi_dbi_pipe_destroy_plane_state,
>> };
>>
>> static const struct drm_display_mode st7586_mode = {
>> diff --git a/include/drm/drm_mipi_dbi.h b/include/drm/drm_mipi_dbi.h
>> index 36ac8495566b..304fbecdc66a 100644
>> --- a/include/drm/drm_mipi_dbi.h
>> +++ b/include/drm/drm_mipi_dbi.h
>> @@ -164,6 +164,15 @@ void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev,
>> struct drm_crtc_state *crtc_state,
>> struct drm_plane_state *plan_state);
>> void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe);
>> +int mipi_dbi_pipe_begin_fb_access(struct drm_simple_display_pipe *pipe,
>> + struct drm_plane_state *plane_state);
>> +void mipi_dbi_pipe_end_fb_access(struct drm_simple_display_pipe *pipe,
>> + struct drm_plane_state *plane_state);
>> +void mipi_dbi_pipe_reset_plane(struct drm_simple_display_pipe *pipe);
>> +struct drm_plane_state *mipi_dbi_pipe_duplicate_plane_state(struct drm_simple_display_pipe *pipe);
>> +void mipi_dbi_pipe_destroy_plane_state(struct drm_simple_display_pipe *pipe,
>> + struct drm_plane_state *plane_state);
>> +
>> void mipi_dbi_hw_reset(struct mipi_dbi *dbi);
>> bool mipi_dbi_display_is_on(struct mipi_dbi *dbi);
>> int mipi_dbi_poweron_reset(struct mipi_dbi_dev *dbidev);
>> @@ -223,6 +232,11 @@ static inline void mipi_dbi_debugfs_init(struct drm_minor *minor) {}
>> .mode_valid = mipi_dbi_pipe_mode_valid, \
>> .enable = (enable_), \
>> .disable = mipi_dbi_pipe_disable, \
>> - .update = mipi_dbi_pipe_update
>> + .update = mipi_dbi_pipe_update, \
>> + .begin_fb_access = mipi_dbi_pipe_begin_fb_access, \
>> + .end_fb_access = mipi_dbi_pipe_end_fb_access, \
>> + .reset_plane = mipi_dbi_pipe_reset_plane, \
>> + .duplicate_plane_state = mipi_dbi_pipe_duplicate_plane_state, \
>> + .destroy_plane_state = mipi_dbi_pipe_destroy_plane_state
>>
>> #endif /* __LINUX_MIPI_DBI_H */
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20221203/eca68ab5/attachment-0001.sig>
More information about the dri-devel
mailing list