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 13a6a9534cSNoralf Trønnes #include <drm/drm_crtc.h> 14a6a9534cSNoralf Trønnes #include <drm/drm_encoder.h> 15a6a9534cSNoralf Trønnes #include <drm/drm_plane.h> 16a6a9534cSNoralf Trønnes 175b809074SNoralf Trønnes struct drm_simple_display_pipe; 185b809074SNoralf Trønnes 195b809074SNoralf Trønnes /** 205b809074SNoralf Trønnes * struct drm_simple_display_pipe_funcs - helper operations for a simple 215b809074SNoralf Trønnes * display pipeline 225b809074SNoralf Trønnes */ 235b809074SNoralf Trønnes struct drm_simple_display_pipe_funcs { 245b809074SNoralf Trønnes /** 2540275dc4SLinus Walleij * @mode_valid: 2640275dc4SLinus Walleij * 27afe09e43SLinus Walleij * This callback is used to check if a specific mode is valid in the 28afe09e43SLinus Walleij * crtc used in this simple display pipe. This should be implemented 29afe09e43SLinus Walleij * if the display pipe has some sort of restriction in the modes 30afe09e43SLinus Walleij * it can display. For example, a given display pipe may be responsible 31afe09e43SLinus Walleij * to set a clock value. If the clock can not produce all the values 32afe09e43SLinus Walleij * for the available modes then this callback can be used to restrict 33afe09e43SLinus Walleij * the number of modes to only the ones that can be displayed. Another 34afe09e43SLinus Walleij * reason can be bandwidth mitigation: the memory port on the display 35afe09e43SLinus Walleij * controller can have bandwidth limitations not allowing pixel data 36afe09e43SLinus Walleij * to be fetched at any rate. 37afe09e43SLinus Walleij * 38afe09e43SLinus Walleij * This hook is used by the probe helpers to filter the mode list in 39afe09e43SLinus Walleij * drm_helper_probe_single_connector_modes(), and it is used by the 40afe09e43SLinus Walleij * atomic helpers to validate modes supplied by userspace in 41afe09e43SLinus Walleij * drm_atomic_helper_check_modeset(). 42afe09e43SLinus Walleij * 43afe09e43SLinus Walleij * This function is optional. 44afe09e43SLinus Walleij * 45afe09e43SLinus Walleij * NOTE: 46afe09e43SLinus Walleij * 47afe09e43SLinus Walleij * Since this function is both called from the check phase of an atomic 48afe09e43SLinus Walleij * commit, and the mode validation in the probe paths it is not allowed 49afe09e43SLinus Walleij * to look at anything else but the passed-in mode, and validate it 50afe09e43SLinus Walleij * against configuration-invariant hardware constraints. 5140275dc4SLinus Walleij * 5240275dc4SLinus Walleij * RETURNS: 5340275dc4SLinus Walleij * 5440275dc4SLinus Walleij * drm_mode_status Enum 5540275dc4SLinus Walleij */ 5640275dc4SLinus Walleij enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc, 5740275dc4SLinus Walleij const struct drm_display_mode *mode); 5840275dc4SLinus Walleij 5940275dc4SLinus Walleij /** 605b809074SNoralf Trønnes * @enable: 615b809074SNoralf Trønnes * 625b809074SNoralf Trønnes * This function should be used to enable the pipeline. 635b809074SNoralf Trønnes * It is called when the underlying crtc is enabled. 645b809074SNoralf Trønnes * This hook is optional. 655b809074SNoralf Trønnes */ 665b809074SNoralf Trønnes void (*enable)(struct drm_simple_display_pipe *pipe, 67*0c9c7fd0SVille Syrjälä struct drm_crtc_state *crtc_state, 68*0c9c7fd0SVille Syrjälä struct drm_plane_state *plane_state); 695b809074SNoralf Trønnes /** 705b809074SNoralf Trønnes * @disable: 715b809074SNoralf Trønnes * 725b809074SNoralf Trønnes * This function should be used to disable the pipeline. 735b809074SNoralf Trønnes * It is called when the underlying crtc is disabled. 745b809074SNoralf Trønnes * This hook is optional. 755b809074SNoralf Trønnes */ 765b809074SNoralf Trønnes void (*disable)(struct drm_simple_display_pipe *pipe); 775b809074SNoralf Trønnes 785b809074SNoralf Trønnes /** 795b809074SNoralf Trønnes * @check: 805b809074SNoralf Trønnes * 815b809074SNoralf Trønnes * This function is called in the check phase of an atomic update, 825b809074SNoralf Trønnes * specifically when the underlying plane is checked. 835b809074SNoralf Trønnes * The simple display pipeline helpers already check that the plane is 845b809074SNoralf Trønnes * not scaled, fills the entire visible area and is always enabled 855b809074SNoralf Trønnes * when the crtc is also enabled. 865b809074SNoralf Trønnes * This hook is optional. 875b809074SNoralf Trønnes * 885b809074SNoralf Trønnes * RETURNS: 895b809074SNoralf Trønnes * 905b809074SNoralf Trønnes * 0 on success, -EINVAL if the state or the transition can't be 915b809074SNoralf Trønnes * supported, -ENOMEM on memory allocation failure and -EDEADLK if an 925b809074SNoralf Trønnes * attempt to obtain another state object ran into a &drm_modeset_lock 935b809074SNoralf Trønnes * deadlock. 945b809074SNoralf Trønnes */ 955b809074SNoralf Trønnes int (*check)(struct drm_simple_display_pipe *pipe, 965b809074SNoralf Trønnes struct drm_plane_state *plane_state, 975b809074SNoralf Trønnes struct drm_crtc_state *crtc_state); 985b809074SNoralf Trønnes /** 995b809074SNoralf Trønnes * @update: 1005b809074SNoralf Trønnes * 1015b809074SNoralf Trønnes * This function is called when the underlying plane state is updated. 1025b809074SNoralf Trønnes * This hook is optional. 1036dcf0de7SDaniel Vetter * 1046dcf0de7SDaniel Vetter * This is the function drivers should submit the 1056dcf0de7SDaniel Vetter * &drm_pending_vblank_event from. Using either 1066dcf0de7SDaniel Vetter * drm_crtc_arm_vblank_event(), when the driver supports vblank 1076dcf0de7SDaniel Vetter * interrupt handling, or drm_crtc_send_vblank_event() directly in case 1086dcf0de7SDaniel Vetter * the hardware lacks vblank support entirely. 1095b809074SNoralf Trønnes */ 1105b809074SNoralf Trønnes void (*update)(struct drm_simple_display_pipe *pipe, 111bcd2ba02SEric Anholt struct drm_plane_state *old_plane_state); 1127d83a155SMarek Vasut 1137d83a155SMarek Vasut /** 1147d83a155SMarek Vasut * @prepare_fb: 1157d83a155SMarek Vasut * 1166806cdf9SDaniel Vetter * Optional, called by &drm_plane_helper_funcs.prepare_fb. Please read 1176806cdf9SDaniel Vetter * the documentation for the &drm_plane_helper_funcs.prepare_fb hook for 1186806cdf9SDaniel Vetter * more details. 1197d83a155SMarek Vasut */ 1207d83a155SMarek Vasut int (*prepare_fb)(struct drm_simple_display_pipe *pipe, 1217d83a155SMarek Vasut struct drm_plane_state *plane_state); 1227d83a155SMarek Vasut 1237d83a155SMarek Vasut /** 1247d83a155SMarek Vasut * @cleanup_fb: 1257d83a155SMarek Vasut * 1266806cdf9SDaniel Vetter * Optional, called by &drm_plane_helper_funcs.cleanup_fb. Please read 1276806cdf9SDaniel Vetter * the documentation for the &drm_plane_helper_funcs.cleanup_fb hook for 1286806cdf9SDaniel Vetter * more details. 1297d83a155SMarek Vasut */ 1307d83a155SMarek Vasut void (*cleanup_fb)(struct drm_simple_display_pipe *pipe, 1317d83a155SMarek Vasut struct drm_plane_state *plane_state); 132ac86cba9SOleksandr Andrushchenko 133ac86cba9SOleksandr Andrushchenko /** 134ac86cba9SOleksandr Andrushchenko * @enable_vblank: 135ac86cba9SOleksandr Andrushchenko * 136ac86cba9SOleksandr Andrushchenko * Optional, called by &drm_crtc_funcs.enable_vblank. Please read 137ac86cba9SOleksandr Andrushchenko * the documentation for the &drm_crtc_funcs.enable_vblank hook for 138ac86cba9SOleksandr Andrushchenko * more details. 139ac86cba9SOleksandr Andrushchenko */ 140ac86cba9SOleksandr Andrushchenko int (*enable_vblank)(struct drm_simple_display_pipe *pipe); 141ac86cba9SOleksandr Andrushchenko 142ac86cba9SOleksandr Andrushchenko /** 143ac86cba9SOleksandr Andrushchenko * @disable_vblank: 144ac86cba9SOleksandr Andrushchenko * 145ac86cba9SOleksandr Andrushchenko * Optional, called by &drm_crtc_funcs.disable_vblank. Please read 146ac86cba9SOleksandr Andrushchenko * the documentation for the &drm_crtc_funcs.disable_vblank hook for 147ac86cba9SOleksandr Andrushchenko * more details. 148ac86cba9SOleksandr Andrushchenko */ 149ac86cba9SOleksandr Andrushchenko void (*disable_vblank)(struct drm_simple_display_pipe *pipe); 1505b809074SNoralf Trønnes }; 1515b809074SNoralf Trønnes 1525b809074SNoralf Trønnes /** 1535b809074SNoralf Trønnes * struct drm_simple_display_pipe - simple display pipeline 1545b809074SNoralf Trønnes * @crtc: CRTC control structure 1555b809074SNoralf Trønnes * @plane: Plane control structure 1565b809074SNoralf Trønnes * @encoder: Encoder control structure 1575b809074SNoralf Trønnes * @connector: Connector control structure 1585b809074SNoralf Trønnes * @funcs: Pipeline control functions (optional) 1595b809074SNoralf Trønnes * 1605b809074SNoralf Trønnes * Simple display pipeline with plane, crtc and encoder collapsed into one 1615b809074SNoralf Trønnes * entity. It should be initialized by calling drm_simple_display_pipe_init(). 1625b809074SNoralf Trønnes */ 1635b809074SNoralf Trønnes struct drm_simple_display_pipe { 1645b809074SNoralf Trønnes struct drm_crtc crtc; 1655b809074SNoralf Trønnes struct drm_plane plane; 1665b809074SNoralf Trønnes struct drm_encoder encoder; 1675b809074SNoralf Trønnes struct drm_connector *connector; 1685b809074SNoralf Trønnes 1695b809074SNoralf Trønnes const struct drm_simple_display_pipe_funcs *funcs; 1705b809074SNoralf Trønnes }; 1715b809074SNoralf Trønnes 172315486c6SAndrea Merello int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe, 173315486c6SAndrea Merello struct drm_bridge *bridge); 174315486c6SAndrea Merello 1755b809074SNoralf Trønnes int drm_simple_display_pipe_init(struct drm_device *dev, 1765b809074SNoralf Trønnes struct drm_simple_display_pipe *pipe, 1775b809074SNoralf Trønnes const struct drm_simple_display_pipe_funcs *funcs, 1785b809074SNoralf Trønnes const uint32_t *formats, unsigned int format_count, 179e6fc3b68SBen Widawsky const uint64_t *format_modifiers, 1805b809074SNoralf Trønnes struct drm_connector *connector); 1815b809074SNoralf Trønnes 1825b809074SNoralf Trønnes #endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */ 183