1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Copyright (C) 2016 Noralf Trønnes 4 */ 5 6 /* 7 * Simple KMS helpers are deprected in favor of regular atomic helpers. Do not 8 * use the min new code. 9 */ 10 11 #ifndef __LINUX_DRM_SIMPLE_KMS_HELPER_H 12 #define __LINUX_DRM_SIMPLE_KMS_HELPER_H 13 14 #include <drm/drm_crtc.h> 15 #include <drm/drm_encoder.h> 16 #include <drm/drm_plane.h> 17 18 struct drm_simple_display_pipe; 19 20 struct drm_simple_display_pipe_funcs { 21 enum drm_mode_status (*mode_valid)(struct drm_simple_display_pipe *pipe, 22 const struct drm_display_mode *mode); 23 void (*enable)(struct drm_simple_display_pipe *pipe, 24 struct drm_crtc_state *crtc_state, 25 struct drm_plane_state *plane_state); 26 void (*disable)(struct drm_simple_display_pipe *pipe); 27 int (*check)(struct drm_simple_display_pipe *pipe, 28 struct drm_plane_state *plane_state, 29 struct drm_crtc_state *crtc_state); 30 void (*update)(struct drm_simple_display_pipe *pipe, 31 struct drm_plane_state *old_plane_state); 32 int (*prepare_fb)(struct drm_simple_display_pipe *pipe, 33 struct drm_plane_state *plane_state); 34 void (*cleanup_fb)(struct drm_simple_display_pipe *pipe, 35 struct drm_plane_state *plane_state); 36 int (*begin_fb_access)(struct drm_simple_display_pipe *pipe, 37 struct drm_plane_state *new_plane_state); 38 void (*end_fb_access)(struct drm_simple_display_pipe *pipe, 39 struct drm_plane_state *plane_state); 40 int (*enable_vblank)(struct drm_simple_display_pipe *pipe); 41 void (*disable_vblank)(struct drm_simple_display_pipe *pipe); 42 struct drm_crtc_state * (*duplicate_crtc_state)(struct drm_simple_display_pipe *pipe); 43 void (*destroy_crtc_state)(struct drm_simple_display_pipe *pipe, 44 struct drm_crtc_state *crtc_state); 45 struct drm_plane_state * (*create_plane_state)(struct drm_simple_display_pipe *pipe); 46 struct drm_plane_state * (*duplicate_plane_state)(struct drm_simple_display_pipe *pipe); 47 void (*destroy_plane_state)(struct drm_simple_display_pipe *pipe, 48 struct drm_plane_state *plane_state); 49 }; 50 51 struct drm_simple_display_pipe { 52 struct drm_crtc crtc; 53 struct drm_plane plane; 54 struct drm_encoder encoder; 55 struct drm_connector *connector; 56 57 const struct drm_simple_display_pipe_funcs *funcs; 58 }; 59 60 int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe, 61 struct drm_bridge *bridge); 62 63 int drm_simple_display_pipe_init(struct drm_device *dev, 64 struct drm_simple_display_pipe *pipe, 65 const struct drm_simple_display_pipe_funcs *funcs, 66 const uint32_t *formats, unsigned int format_count, 67 const uint64_t *format_modifiers, 68 struct drm_connector *connector); 69 70 void *__drmm_simple_encoder_alloc(struct drm_device *dev, size_t size, 71 size_t offset, int encoder_type); 72 73 #define drmm_simple_encoder_alloc(dev, type, member, encoder_type) \ 74 ((type *)__drmm_simple_encoder_alloc(dev, sizeof(type), \ 75 offsetof(type, member), \ 76 encoder_type)) 77 78 #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */ 79