15b809074SNoralf Trønnes /* 25b809074SNoralf Trønnes * Copyright (C) 2016 Noralf Trønnes 35b809074SNoralf Trønnes * 45b809074SNoralf Trønnes * This program is free software; you can redistribute it and/or modify 55b809074SNoralf Trønnes * it under the terms of the GNU General Public License as published by 65b809074SNoralf Trønnes * the Free Software Foundation; either version 2 of the License, or 75b809074SNoralf Trønnes * (at your option) any later version. 85b809074SNoralf Trønnes */ 95b809074SNoralf Trønnes 105b809074SNoralf Trønnes #ifndef __LINUX_DRM_SIMPLE_KMS_HELPER_H 115b809074SNoralf Trønnes #define __LINUX_DRM_SIMPLE_KMS_HELPER_H 125b809074SNoralf Trønnes 135b809074SNoralf Trønnes struct drm_simple_display_pipe; 145b809074SNoralf Trønnes 155b809074SNoralf Trønnes /** 165b809074SNoralf Trønnes * struct drm_simple_display_pipe_funcs - helper operations for a simple 175b809074SNoralf Trønnes * display pipeline 185b809074SNoralf Trønnes */ 195b809074SNoralf Trønnes struct drm_simple_display_pipe_funcs { 205b809074SNoralf Trønnes /** 215b809074SNoralf Trønnes * @enable: 225b809074SNoralf Trønnes * 235b809074SNoralf Trønnes * This function should be used to enable the pipeline. 245b809074SNoralf Trønnes * It is called when the underlying crtc is enabled. 255b809074SNoralf Trønnes * This hook is optional. 265b809074SNoralf Trønnes */ 275b809074SNoralf Trønnes void (*enable)(struct drm_simple_display_pipe *pipe, 285b809074SNoralf Trønnes struct drm_crtc_state *crtc_state); 295b809074SNoralf Trønnes /** 305b809074SNoralf Trønnes * @disable: 315b809074SNoralf Trønnes * 325b809074SNoralf Trønnes * This function should be used to disable the pipeline. 335b809074SNoralf Trønnes * It is called when the underlying crtc is disabled. 345b809074SNoralf Trønnes * This hook is optional. 355b809074SNoralf Trønnes */ 365b809074SNoralf Trønnes void (*disable)(struct drm_simple_display_pipe *pipe); 375b809074SNoralf Trønnes 385b809074SNoralf Trønnes /** 395b809074SNoralf Trønnes * @check: 405b809074SNoralf Trønnes * 415b809074SNoralf Trønnes * This function is called in the check phase of an atomic update, 425b809074SNoralf Trønnes * specifically when the underlying plane is checked. 435b809074SNoralf Trønnes * The simple display pipeline helpers already check that the plane is 445b809074SNoralf Trønnes * not scaled, fills the entire visible area and is always enabled 455b809074SNoralf Trønnes * when the crtc is also enabled. 465b809074SNoralf Trønnes * This hook is optional. 475b809074SNoralf Trønnes * 485b809074SNoralf Trønnes * RETURNS: 495b809074SNoralf Trønnes * 505b809074SNoralf Trønnes * 0 on success, -EINVAL if the state or the transition can't be 515b809074SNoralf Trønnes * supported, -ENOMEM on memory allocation failure and -EDEADLK if an 525b809074SNoralf Trønnes * attempt to obtain another state object ran into a &drm_modeset_lock 535b809074SNoralf Trønnes * deadlock. 545b809074SNoralf Trønnes */ 555b809074SNoralf Trønnes int (*check)(struct drm_simple_display_pipe *pipe, 565b809074SNoralf Trønnes struct drm_plane_state *plane_state, 575b809074SNoralf Trønnes struct drm_crtc_state *crtc_state); 585b809074SNoralf Trønnes /** 595b809074SNoralf Trønnes * @update: 605b809074SNoralf Trønnes * 615b809074SNoralf Trønnes * This function is called when the underlying plane state is updated. 625b809074SNoralf Trønnes * This hook is optional. 636dcf0de7SDaniel Vetter * 646dcf0de7SDaniel Vetter * This is the function drivers should submit the 656dcf0de7SDaniel Vetter * &drm_pending_vblank_event from. Using either 666dcf0de7SDaniel Vetter * drm_crtc_arm_vblank_event(), when the driver supports vblank 676dcf0de7SDaniel Vetter * interrupt handling, or drm_crtc_send_vblank_event() directly in case 686dcf0de7SDaniel Vetter * the hardware lacks vblank support entirely. 695b809074SNoralf Trønnes */ 705b809074SNoralf Trønnes void (*update)(struct drm_simple_display_pipe *pipe, 715b809074SNoralf Trønnes struct drm_plane_state *plane_state); 72*7d83a155SMarek Vasut 73*7d83a155SMarek Vasut /** 74*7d83a155SMarek Vasut * @prepare_fb: 75*7d83a155SMarek Vasut * 76*7d83a155SMarek Vasut * Optional, called by struct &drm_plane_helper_funcs ->prepare_fb . 77*7d83a155SMarek Vasut * Please read the documentation for the ->prepare_fb hook in 78*7d83a155SMarek Vasut * struct &drm_plane_helper_funcs for more details. 79*7d83a155SMarek Vasut */ 80*7d83a155SMarek Vasut int (*prepare_fb)(struct drm_simple_display_pipe *pipe, 81*7d83a155SMarek Vasut struct drm_plane_state *plane_state); 82*7d83a155SMarek Vasut 83*7d83a155SMarek Vasut /** 84*7d83a155SMarek Vasut * @cleanup_fb: 85*7d83a155SMarek Vasut * 86*7d83a155SMarek Vasut * Optional, called by struct &drm_plane_helper_funcs ->cleanup_fb . 87*7d83a155SMarek Vasut * Please read the documentation for the ->cleanup_fb hook in 88*7d83a155SMarek Vasut * struct &drm_plane_helper_funcs for more details. 89*7d83a155SMarek Vasut */ 90*7d83a155SMarek Vasut void (*cleanup_fb)(struct drm_simple_display_pipe *pipe, 91*7d83a155SMarek Vasut struct drm_plane_state *plane_state); 925b809074SNoralf Trønnes }; 935b809074SNoralf Trønnes 945b809074SNoralf Trønnes /** 955b809074SNoralf Trønnes * struct drm_simple_display_pipe - simple display pipeline 965b809074SNoralf Trønnes * @crtc: CRTC control structure 975b809074SNoralf Trønnes * @plane: Plane control structure 985b809074SNoralf Trønnes * @encoder: Encoder control structure 995b809074SNoralf Trønnes * @connector: Connector control structure 1005b809074SNoralf Trønnes * @funcs: Pipeline control functions (optional) 1015b809074SNoralf Trønnes * 1025b809074SNoralf Trønnes * Simple display pipeline with plane, crtc and encoder collapsed into one 1035b809074SNoralf Trønnes * entity. It should be initialized by calling drm_simple_display_pipe_init(). 1045b809074SNoralf Trønnes */ 1055b809074SNoralf Trønnes struct drm_simple_display_pipe { 1065b809074SNoralf Trønnes struct drm_crtc crtc; 1075b809074SNoralf Trønnes struct drm_plane plane; 1085b809074SNoralf Trønnes struct drm_encoder encoder; 1095b809074SNoralf Trønnes struct drm_connector *connector; 1105b809074SNoralf Trønnes 1115b809074SNoralf Trønnes const struct drm_simple_display_pipe_funcs *funcs; 1125b809074SNoralf Trønnes }; 1135b809074SNoralf Trønnes 114315486c6SAndrea Merello int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe, 115315486c6SAndrea Merello struct drm_bridge *bridge); 116315486c6SAndrea Merello 117315486c6SAndrea Merello void drm_simple_display_pipe_detach_bridge(struct drm_simple_display_pipe *pipe); 118315486c6SAndrea Merello 1195b809074SNoralf Trønnes int drm_simple_display_pipe_init(struct drm_device *dev, 1205b809074SNoralf Trønnes struct drm_simple_display_pipe *pipe, 1215b809074SNoralf Trønnes const struct drm_simple_display_pipe_funcs *funcs, 1225b809074SNoralf Trønnes const uint32_t *formats, unsigned int format_count, 1235b809074SNoralf Trønnes struct drm_connector *connector); 1245b809074SNoralf Trønnes 1255b809074SNoralf Trønnes #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */ 126