Home | History | Annotate | Line # | Download | only in drm
drm_atomic.h revision 1.1.1.1
      1 /*	$NetBSD: drm_atomic.h,v 1.1.1.1 2018/08/27 01:35:00 riastradh Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 2014 Red Hat
      5  * Copyright (C) 2014 Intel Corp.
      6  *
      7  * Permission is hereby granted, free of charge, to any person obtaining a
      8  * copy of this software and associated documentation files (the "Software"),
      9  * to deal in the Software without restriction, including without limitation
     10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     11  * and/or sell copies of the Software, and to permit persons to whom the
     12  * Software is furnished to do so, subject to the following conditions:
     13  *
     14  * The above copyright notice and this permission notice shall be included in
     15  * all copies or substantial portions of the Software.
     16  *
     17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     20  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     23  * OTHER DEALINGS IN THE SOFTWARE.
     24  *
     25  * Authors:
     26  * Rob Clark <robdclark (at) gmail.com>
     27  * Daniel Vetter <daniel.vetter (at) ffwll.ch>
     28  */
     29 
     30 #ifndef DRM_ATOMIC_H_
     31 #define DRM_ATOMIC_H_
     32 
     33 #include <drm/drm_crtc.h>
     34 
     35 struct drm_atomic_state * __must_check
     36 drm_atomic_state_alloc(struct drm_device *dev);
     37 void drm_atomic_state_clear(struct drm_atomic_state *state);
     38 void drm_atomic_state_free(struct drm_atomic_state *state);
     39 
     40 int  __must_check
     41 drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state);
     42 void drm_atomic_state_default_clear(struct drm_atomic_state *state);
     43 void drm_atomic_state_default_release(struct drm_atomic_state *state);
     44 
     45 struct drm_crtc_state * __must_check
     46 drm_atomic_get_crtc_state(struct drm_atomic_state *state,
     47 			  struct drm_crtc *crtc);
     48 int drm_atomic_crtc_set_property(struct drm_crtc *crtc,
     49 		struct drm_crtc_state *state, struct drm_property *property,
     50 		uint64_t val);
     51 struct drm_plane_state * __must_check
     52 drm_atomic_get_plane_state(struct drm_atomic_state *state,
     53 			   struct drm_plane *plane);
     54 int drm_atomic_plane_set_property(struct drm_plane *plane,
     55 		struct drm_plane_state *state, struct drm_property *property,
     56 		uint64_t val);
     57 struct drm_connector_state * __must_check
     58 drm_atomic_get_connector_state(struct drm_atomic_state *state,
     59 			       struct drm_connector *connector);
     60 int drm_atomic_connector_set_property(struct drm_connector *connector,
     61 		struct drm_connector_state *state, struct drm_property *property,
     62 		uint64_t val);
     63 
     64 /**
     65  * drm_atomic_get_existing_crtc_state - get crtc state, if it exists
     66  * @state: global atomic state object
     67  * @crtc: crtc to grab
     68  *
     69  * This function returns the crtc state for the given crtc, or NULL
     70  * if the crtc is not part of the global atomic state.
     71  */
     72 static inline struct drm_crtc_state *
     73 drm_atomic_get_existing_crtc_state(struct drm_atomic_state *state,
     74 				   struct drm_crtc *crtc)
     75 {
     76 	return state->crtc_states[drm_crtc_index(crtc)];
     77 }
     78 
     79 /**
     80  * drm_atomic_get_existing_plane_state - get plane state, if it exists
     81  * @state: global atomic state object
     82  * @plane: plane to grab
     83  *
     84  * This function returns the plane state for the given plane, or NULL
     85  * if the plane is not part of the global atomic state.
     86  */
     87 static inline struct drm_plane_state *
     88 drm_atomic_get_existing_plane_state(struct drm_atomic_state *state,
     89 				    struct drm_plane *plane)
     90 {
     91 	return state->plane_states[drm_plane_index(plane)];
     92 }
     93 
     94 /**
     95  * drm_atomic_get_existing_connector_state - get connector state, if it exists
     96  * @state: global atomic state object
     97  * @connector: connector to grab
     98  *
     99  * This function returns the connector state for the given connector,
    100  * or NULL if the connector is not part of the global atomic state.
    101  */
    102 static inline struct drm_connector_state *
    103 drm_atomic_get_existing_connector_state(struct drm_atomic_state *state,
    104 					struct drm_connector *connector)
    105 {
    106 	int index = drm_connector_index(connector);
    107 
    108 	if (index >= state->num_connector)
    109 		return NULL;
    110 
    111 	return state->connector_states[index];
    112 }
    113 
    114 int __must_check
    115 drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
    116 			     struct drm_display_mode *mode);
    117 int __must_check
    118 drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state *state,
    119 				  struct drm_property_blob *blob);
    120 int __must_check
    121 drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
    122 			      struct drm_crtc *crtc);
    123 void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
    124 				 struct drm_framebuffer *fb);
    125 int __must_check
    126 drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
    127 				  struct drm_crtc *crtc);
    128 int __must_check
    129 drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
    130 				   struct drm_crtc *crtc);
    131 int __must_check
    132 drm_atomic_add_affected_planes(struct drm_atomic_state *state,
    133 			       struct drm_crtc *crtc);
    134 
    135 int
    136 drm_atomic_connectors_for_crtc(struct drm_atomic_state *state,
    137 			       struct drm_crtc *crtc);
    138 
    139 void drm_atomic_legacy_backoff(struct drm_atomic_state *state);
    140 
    141 void
    142 drm_atomic_clean_old_fb(struct drm_device *dev, unsigned plane_mask, int ret);
    143 
    144 int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
    145 int __must_check drm_atomic_commit(struct drm_atomic_state *state);
    146 int __must_check drm_atomic_async_commit(struct drm_atomic_state *state);
    147 
    148 #define for_each_connector_in_state(state, connector, connector_state, __i) \
    149 	for ((__i) = 0;							\
    150 	     (__i) < (state)->num_connector &&				\
    151 	     ((connector) = (state)->connectors[__i],			\
    152 	     (connector_state) = (state)->connector_states[__i], 1); 	\
    153 	     (__i)++)							\
    154 		if (connector)
    155 
    156 #define for_each_crtc_in_state(state, crtc, crtc_state, __i)	\
    157 	for ((__i) = 0;						\
    158 	     (__i) < (state)->dev->mode_config.num_crtc &&	\
    159 	     ((crtc) = (state)->crtcs[__i],			\
    160 	     (crtc_state) = (state)->crtc_states[__i], 1);	\
    161 	     (__i)++)						\
    162 		if (crtc_state)
    163 
    164 #define for_each_plane_in_state(state, plane, plane_state, __i)		\
    165 	for ((__i) = 0;							\
    166 	     (__i) < (state)->dev->mode_config.num_total_plane &&	\
    167 	     ((plane) = (state)->planes[__i],				\
    168 	     (plane_state) = (state)->plane_states[__i], 1);		\
    169 	     (__i)++)							\
    170 		if (plane_state)
    171 static inline bool
    172 drm_atomic_crtc_needs_modeset(struct drm_crtc_state *state)
    173 {
    174 	return state->mode_changed || state->active_changed ||
    175 	       state->connectors_changed;
    176 }
    177 
    178 
    179 #endif /* DRM_ATOMIC_H_ */
    180