mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	drm/gem: Export implementation of shadow-plane helpers
Export the implementation of duplicate, destroy and reset helpers for shadow-buffered plane state. Useful for drivers that subclass struct drm_shadow_plane_state. The exported functions are wrappers around plane-state implementation, but using them is the correct thing to do for drivers. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Melissa Wen <melissa.srw@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210705074633.9425-2-tzimmermann@suse.de
This commit is contained in:
		
							parent
							
								
									6293eb2891
								
							
						
					
					
						commit
						b715650220
					
				
					 2 changed files with 58 additions and 3 deletions
				
			
		| 
						 | 
					@ -182,6 +182,27 @@ EXPORT_SYMBOL(drm_gem_simple_display_pipe_prepare_fb);
 | 
				
			||||||
 * Shadow-buffered Planes
 | 
					 * Shadow-buffered Planes
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * __drm_gem_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
 | 
				
			||||||
 | 
					 * @plane: the plane
 | 
				
			||||||
 | 
					 * @new_shadow_plane_state: the new shadow-buffered plane state
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function duplicates shadow-buffered plane state. This is helpful for drivers
 | 
				
			||||||
 | 
					 * that subclass struct drm_shadow_plane_state.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * The function does not duplicate existing mappings of the shadow buffers.
 | 
				
			||||||
 | 
					 * Mappings are maintained during the atomic commit by the plane's prepare_fb
 | 
				
			||||||
 | 
					 * and cleanup_fb helpers. See drm_gem_prepare_shadow_fb() and drm_gem_cleanup_shadow_fb()
 | 
				
			||||||
 | 
					 * for corresponding helpers.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					__drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane,
 | 
				
			||||||
 | 
									       struct drm_shadow_plane_state *new_shadow_plane_state)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						__drm_atomic_helper_plane_duplicate_state(plane, &new_shadow_plane_state->base);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL(__drm_gem_duplicate_shadow_plane_state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * drm_gem_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
 | 
					 * drm_gem_duplicate_shadow_plane_state - duplicates shadow-buffered plane state
 | 
				
			||||||
 * @plane: the plane
 | 
					 * @plane: the plane
 | 
				
			||||||
| 
						 | 
					@ -211,12 +232,25 @@ drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane)
 | 
				
			||||||
	new_shadow_plane_state = kzalloc(sizeof(*new_shadow_plane_state), GFP_KERNEL);
 | 
						new_shadow_plane_state = kzalloc(sizeof(*new_shadow_plane_state), GFP_KERNEL);
 | 
				
			||||||
	if (!new_shadow_plane_state)
 | 
						if (!new_shadow_plane_state)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	__drm_atomic_helper_plane_duplicate_state(plane, &new_shadow_plane_state->base);
 | 
						__drm_gem_duplicate_shadow_plane_state(plane, new_shadow_plane_state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return &new_shadow_plane_state->base;
 | 
						return &new_shadow_plane_state->base;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(drm_gem_duplicate_shadow_plane_state);
 | 
					EXPORT_SYMBOL(drm_gem_duplicate_shadow_plane_state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * __drm_gem_destroy_shadow_plane_state - cleans up shadow-buffered plane state
 | 
				
			||||||
 | 
					 * @shadow_plane_state: the shadow-buffered plane state
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function cleans up shadow-buffered plane state. Helpful for drivers that
 | 
				
			||||||
 | 
					 * subclass struct drm_shadow_plane_state.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void __drm_gem_destroy_shadow_plane_state(struct drm_shadow_plane_state *shadow_plane_state)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						__drm_atomic_helper_plane_destroy_state(&shadow_plane_state->base);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL(__drm_gem_destroy_shadow_plane_state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * drm_gem_destroy_shadow_plane_state - deletes shadow-buffered plane state
 | 
					 * drm_gem_destroy_shadow_plane_state - deletes shadow-buffered plane state
 | 
				
			||||||
 * @plane: the plane
 | 
					 * @plane: the plane
 | 
				
			||||||
| 
						 | 
					@ -232,11 +266,26 @@ void drm_gem_destroy_shadow_plane_state(struct drm_plane *plane,
 | 
				
			||||||
	struct drm_shadow_plane_state *shadow_plane_state =
 | 
						struct drm_shadow_plane_state *shadow_plane_state =
 | 
				
			||||||
		to_drm_shadow_plane_state(plane_state);
 | 
							to_drm_shadow_plane_state(plane_state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	__drm_atomic_helper_plane_destroy_state(&shadow_plane_state->base);
 | 
						__drm_gem_destroy_shadow_plane_state(shadow_plane_state);
 | 
				
			||||||
	kfree(shadow_plane_state);
 | 
						kfree(shadow_plane_state);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(drm_gem_destroy_shadow_plane_state);
 | 
					EXPORT_SYMBOL(drm_gem_destroy_shadow_plane_state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * __drm_gem_reset_shadow_plane - resets a shadow-buffered plane
 | 
				
			||||||
 | 
					 * @plane: the plane
 | 
				
			||||||
 | 
					 * @shadow_plane_state: the shadow-buffered plane state
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function resets state for shadow-buffered planes. Helpful
 | 
				
			||||||
 | 
					 * for drivers that subclass struct drm_shadow_plane_state.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					void __drm_gem_reset_shadow_plane(struct drm_plane *plane,
 | 
				
			||||||
 | 
									  struct drm_shadow_plane_state *shadow_plane_state)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						__drm_atomic_helper_plane_reset(plane, &shadow_plane_state->base);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL(__drm_gem_reset_shadow_plane);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * drm_gem_reset_shadow_plane - resets a shadow-buffered plane
 | 
					 * drm_gem_reset_shadow_plane - resets a shadow-buffered plane
 | 
				
			||||||
 * @plane: the plane
 | 
					 * @plane: the plane
 | 
				
			||||||
| 
						 | 
					@ -258,7 +307,7 @@ void drm_gem_reset_shadow_plane(struct drm_plane *plane)
 | 
				
			||||||
	shadow_plane_state = kzalloc(sizeof(*shadow_plane_state), GFP_KERNEL);
 | 
						shadow_plane_state = kzalloc(sizeof(*shadow_plane_state), GFP_KERNEL);
 | 
				
			||||||
	if (!shadow_plane_state)
 | 
						if (!shadow_plane_state)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	__drm_atomic_helper_plane_reset(plane, &shadow_plane_state->base);
 | 
						__drm_gem_reset_shadow_plane(plane, shadow_plane_state);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(drm_gem_reset_shadow_plane);
 | 
					EXPORT_SYMBOL(drm_gem_reset_shadow_plane);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,6 +53,12 @@ to_drm_shadow_plane_state(struct drm_plane_state *state)
 | 
				
			||||||
	return container_of(state, struct drm_shadow_plane_state, base);
 | 
						return container_of(state, struct drm_shadow_plane_state, base);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void __drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane,
 | 
				
			||||||
 | 
										    struct drm_shadow_plane_state *new_shadow_plane_state);
 | 
				
			||||||
 | 
					void __drm_gem_destroy_shadow_plane_state(struct drm_shadow_plane_state *shadow_plane_state);
 | 
				
			||||||
 | 
					void __drm_gem_reset_shadow_plane(struct drm_plane *plane,
 | 
				
			||||||
 | 
									  struct drm_shadow_plane_state *shadow_plane_state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void drm_gem_reset_shadow_plane(struct drm_plane *plane);
 | 
					void drm_gem_reset_shadow_plane(struct drm_plane *plane);
 | 
				
			||||||
struct drm_plane_state *drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane);
 | 
					struct drm_plane_state *drm_gem_duplicate_shadow_plane_state(struct drm_plane *plane);
 | 
				
			||||||
void drm_gem_destroy_shadow_plane_state(struct drm_plane *plane,
 | 
					void drm_gem_destroy_shadow_plane_state(struct drm_plane *plane,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue