Skip to content

Commit e7caf04

Browse files
committed
drm/mipi-dbi: Support shadow-plane state
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@suse.de> Reviewed-by: Noralf Trønnes <noralf@tronnes.org> Tested-by: Javier Martinez Canillas <javierm@redhat.com> Tested-by: Noralf Trønnes <noralf@tronnes.org> # drm/tiny/mi0283qt Link: https://patchwork.freedesktop.org/patch/msgid/20221202125644.7917-7-tzimmermann@suse.de
1 parent b5f636e commit e7caf04

File tree

4 files changed

+110
-1
lines changed

4 files changed

+110
-1
lines changed

drivers/gpu/drm/drm_mipi_dbi.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <drm/drm_fourcc.h>
2222
#include <drm/drm_framebuffer.h>
2323
#include <drm/drm_gem.h>
24+
#include <drm/drm_gem_atomic_helper.h>
2425
#include <drm/drm_gem_framebuffer_helper.h>
2526
#include <drm/drm_mipi_dbi.h>
2627
#include <drm/drm_modes.h>
@@ -433,6 +434,90 @@ void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe)
433434
}
434435
EXPORT_SYMBOL(mipi_dbi_pipe_disable);
435436

437+
/**
438+
* mipi_dbi_pipe_begin_fb_access - MIPI DBI pipe begin-access helper
439+
* @pipe: Display pipe
440+
* @plane_state: Plane state
441+
*
442+
* This function implements struct &drm_simple_display_funcs.begin_fb_access.
443+
*
444+
* See drm_gem_begin_shadow_fb_access() for details and mipi_dbi_pipe_cleanup_fb()
445+
* for cleanup.
446+
*
447+
* Returns:
448+
* 0 on success, or a negative errno code otherwise.
449+
*/
450+
int mipi_dbi_pipe_begin_fb_access(struct drm_simple_display_pipe *pipe,
451+
struct drm_plane_state *plane_state)
452+
{
453+
return drm_gem_begin_shadow_fb_access(&pipe->plane, plane_state);
454+
}
455+
EXPORT_SYMBOL(mipi_dbi_pipe_begin_fb_access);
456+
457+
/**
458+
* mipi_dbi_pipe_end_fb_access - MIPI DBI pipe end-access helper
459+
* @pipe: Display pipe
460+
* @plane_state: Plane state
461+
*
462+
* This function implements struct &drm_simple_display_funcs.end_fb_access.
463+
*
464+
* See mipi_dbi_pipe_begin_fb_access().
465+
*/
466+
void mipi_dbi_pipe_end_fb_access(struct drm_simple_display_pipe *pipe,
467+
struct drm_plane_state *plane_state)
468+
{
469+
drm_gem_end_shadow_fb_access(&pipe->plane, plane_state);
470+
}
471+
EXPORT_SYMBOL(mipi_dbi_pipe_end_fb_access);
472+
473+
/**
474+
* mipi_dbi_pipe_reset_plane - MIPI DBI plane-reset helper
475+
* @pipe: Display pipe
476+
*
477+
* This function implements struct &drm_simple_display_funcs.reset_plane
478+
* for MIPI DBI planes.
479+
*/
480+
void mipi_dbi_pipe_reset_plane(struct drm_simple_display_pipe *pipe)
481+
{
482+
drm_gem_reset_shadow_plane(&pipe->plane);
483+
}
484+
EXPORT_SYMBOL(mipi_dbi_pipe_reset_plane);
485+
486+
/**
487+
* mipi_dbi_pipe_duplicate_plane_state - duplicates MIPI DBI plane state
488+
* @pipe: Display pipe
489+
*
490+
* This function implements struct &drm_simple_display_funcs.duplicate_plane_state
491+
* for MIPI DBI planes.
492+
*
493+
* See drm_gem_duplicate_shadow_plane_state() for additional details.
494+
*
495+
* Returns:
496+
* A pointer to a new plane state on success, or NULL otherwise.
497+
*/
498+
struct drm_plane_state *mipi_dbi_pipe_duplicate_plane_state(struct drm_simple_display_pipe *pipe)
499+
{
500+
return drm_gem_duplicate_shadow_plane_state(&pipe->plane);
501+
}
502+
EXPORT_SYMBOL(mipi_dbi_pipe_duplicate_plane_state);
503+
504+
/**
505+
* mipi_dbi_pipe_destroy_plane_state - cleans up MIPI DBI plane state
506+
* @pipe: Display pipe
507+
* @plane_state: Plane state
508+
*
509+
* This function implements struct drm_simple_display_funcs.destroy_plane_state
510+
* for MIPI DBI planes.
511+
*
512+
* See drm_gem_destroy_shadow_plane_state() for additional details.
513+
*/
514+
void mipi_dbi_pipe_destroy_plane_state(struct drm_simple_display_pipe *pipe,
515+
struct drm_plane_state *plane_state)
516+
{
517+
drm_gem_destroy_shadow_plane_state(&pipe->plane, plane_state);
518+
}
519+
EXPORT_SYMBOL(mipi_dbi_pipe_destroy_plane_state);
520+
436521
static int mipi_dbi_connector_get_modes(struct drm_connector *connector)
437522
{
438523
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(connector->dev);

drivers/gpu/drm/tiny/ili9225.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,11 @@ static const struct drm_simple_display_pipe_funcs ili9225_pipe_funcs = {
343343
.enable = ili9225_pipe_enable,
344344
.disable = ili9225_pipe_disable,
345345
.update = ili9225_pipe_update,
346+
.begin_fb_access = mipi_dbi_pipe_begin_fb_access,
347+
.end_fb_access = mipi_dbi_pipe_end_fb_access,
348+
.reset_plane = mipi_dbi_pipe_reset_plane,
349+
.duplicate_plane_state = mipi_dbi_pipe_duplicate_plane_state,
350+
.destroy_plane_state = mipi_dbi_pipe_destroy_plane_state,
346351
};
347352

348353
static const struct drm_display_mode ili9225_mode = {

drivers/gpu/drm/tiny/st7586.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ static const struct drm_simple_display_pipe_funcs st7586_pipe_funcs = {
277277
.enable = st7586_pipe_enable,
278278
.disable = st7586_pipe_disable,
279279
.update = st7586_pipe_update,
280+
.begin_fb_access = mipi_dbi_pipe_begin_fb_access,
281+
.end_fb_access = mipi_dbi_pipe_end_fb_access,
282+
.reset_plane = mipi_dbi_pipe_reset_plane,
283+
.duplicate_plane_state = mipi_dbi_pipe_duplicate_plane_state,
284+
.destroy_plane_state = mipi_dbi_pipe_destroy_plane_state,
280285
};
281286

282287
static const struct drm_display_mode st7586_mode = {

include/drm/drm_mipi_dbi.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ void mipi_dbi_enable_flush(struct mipi_dbi_dev *dbidev,
164164
struct drm_crtc_state *crtc_state,
165165
struct drm_plane_state *plan_state);
166166
void mipi_dbi_pipe_disable(struct drm_simple_display_pipe *pipe);
167+
int mipi_dbi_pipe_begin_fb_access(struct drm_simple_display_pipe *pipe,
168+
struct drm_plane_state *plane_state);
169+
void mipi_dbi_pipe_end_fb_access(struct drm_simple_display_pipe *pipe,
170+
struct drm_plane_state *plane_state);
171+
void mipi_dbi_pipe_reset_plane(struct drm_simple_display_pipe *pipe);
172+
struct drm_plane_state *mipi_dbi_pipe_duplicate_plane_state(struct drm_simple_display_pipe *pipe);
173+
void mipi_dbi_pipe_destroy_plane_state(struct drm_simple_display_pipe *pipe,
174+
struct drm_plane_state *plane_state);
175+
167176
void mipi_dbi_hw_reset(struct mipi_dbi *dbi);
168177
bool mipi_dbi_display_is_on(struct mipi_dbi *dbi);
169178
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) {}
223232
.mode_valid = mipi_dbi_pipe_mode_valid, \
224233
.enable = (enable_), \
225234
.disable = mipi_dbi_pipe_disable, \
226-
.update = mipi_dbi_pipe_update
235+
.update = mipi_dbi_pipe_update, \
236+
.begin_fb_access = mipi_dbi_pipe_begin_fb_access, \
237+
.end_fb_access = mipi_dbi_pipe_end_fb_access, \
238+
.reset_plane = mipi_dbi_pipe_reset_plane, \
239+
.duplicate_plane_state = mipi_dbi_pipe_duplicate_plane_state, \
240+
.destroy_plane_state = mipi_dbi_pipe_destroy_plane_state
227241

228242
#endif /* __LINUX_MIPI_DBI_H */

0 commit comments

Comments
 (0)