mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	drm: writeback: Create drmm variants for drm_writeback_connector initialization
To allows driver to only use drmm objects, add helper to create drm_writeback_connectors with automated lifetime management. Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20250116-google-vkms-managed-v9-7-3e4ae1bd05a0@bootlin.com Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
This commit is contained in:
		
							parent
							
								
									2f3f4a7363
								
							
						
					
					
						commit
						1914ba2b91
					
				
					 2 changed files with 80 additions and 0 deletions
				
			
		| 
						 | 
					@ -340,6 +340,80 @@ int drm_writeback_connector_init_with_encoder(struct drm_device *dev,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(drm_writeback_connector_init_with_encoder);
 | 
					EXPORT_SYMBOL(drm_writeback_connector_init_with_encoder);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * drm_writeback_connector_cleanup - Cleanup the writeback connector
 | 
				
			||||||
 | 
					 * @dev: DRM device
 | 
				
			||||||
 | 
					 * @wb_connector: Pointer to the writeback connector to clean up
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This will decrement the reference counter of blobs and destroy properties. It
 | 
				
			||||||
 | 
					 * will also clean the remaining jobs in this writeback connector. Caution: This helper will not
 | 
				
			||||||
 | 
					 * clean up the attached encoder and the drm_connector.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					static void drm_writeback_connector_cleanup(struct drm_device *dev,
 | 
				
			||||||
 | 
										    struct drm_writeback_connector *wb_connector)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						unsigned long flags;
 | 
				
			||||||
 | 
						struct drm_writeback_job *pos, *n;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						delete_writeback_properties(dev);
 | 
				
			||||||
 | 
						drm_property_blob_put(wb_connector->pixel_formats_blob_ptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spin_lock_irqsave(&wb_connector->job_lock, flags);
 | 
				
			||||||
 | 
						list_for_each_entry_safe(pos, n, &wb_connector->job_queue, list_entry) {
 | 
				
			||||||
 | 
							drm_writeback_cleanup_job(pos);
 | 
				
			||||||
 | 
							list_del(&pos->list_entry);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						spin_unlock_irqrestore(&wb_connector->job_lock, flags);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * drmm_writeback_connector_init - Initialize a writeback connector with
 | 
				
			||||||
 | 
					 * a custom encoder
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @dev: DRM device
 | 
				
			||||||
 | 
					 * @wb_connector: Writeback connector to initialize
 | 
				
			||||||
 | 
					 * @con_funcs: Connector funcs vtable
 | 
				
			||||||
 | 
					 * @enc: Encoder to connect this writeback connector
 | 
				
			||||||
 | 
					 * @formats: Array of supported pixel formats for the writeback engine
 | 
				
			||||||
 | 
					 * @n_formats: Length of the formats array
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function initialize a writeback connector and register its cleanup.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * This function creates the writeback-connector-specific properties if they
 | 
				
			||||||
 | 
					 * have not been already created, initializes the connector as
 | 
				
			||||||
 | 
					 * type DRM_MODE_CONNECTOR_WRITEBACK, and correctly initializes the property
 | 
				
			||||||
 | 
					 * values.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Returns: 0 on success, or a negative error code
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					int drmm_writeback_connector_init(struct drm_device *dev,
 | 
				
			||||||
 | 
									  struct drm_writeback_connector *wb_connector,
 | 
				
			||||||
 | 
									  const struct drm_connector_funcs *con_funcs,
 | 
				
			||||||
 | 
									  struct drm_encoder *enc,
 | 
				
			||||||
 | 
									  const u32 *formats, int n_formats)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct drm_connector *connector = &wb_connector->base;
 | 
				
			||||||
 | 
						int ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = drmm_connector_init(dev, connector, con_funcs,
 | 
				
			||||||
 | 
									  DRM_MODE_CONNECTOR_WRITEBACK, NULL);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = __drm_writeback_connector_init(dev, wb_connector, enc, formats,
 | 
				
			||||||
 | 
										     n_formats);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ret = drmm_add_action_or_reset(dev, (void *)drm_writeback_connector_cleanup,
 | 
				
			||||||
 | 
									       wb_connector);
 | 
				
			||||||
 | 
						if (ret)
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EXPORT_SYMBOL(drmm_writeback_connector_init);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int drm_writeback_set_fb(struct drm_connector_state *conn_state,
 | 
					int drm_writeback_set_fb(struct drm_connector_state *conn_state,
 | 
				
			||||||
			 struct drm_framebuffer *fb)
 | 
								 struct drm_framebuffer *fb)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -161,6 +161,12 @@ int drm_writeback_connector_init_with_encoder(struct drm_device *dev,
 | 
				
			||||||
				const struct drm_connector_funcs *con_funcs, const u32 *formats,
 | 
									const struct drm_connector_funcs *con_funcs, const u32 *formats,
 | 
				
			||||||
				int n_formats);
 | 
									int n_formats);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int drmm_writeback_connector_init(struct drm_device *dev,
 | 
				
			||||||
 | 
									  struct drm_writeback_connector *wb_connector,
 | 
				
			||||||
 | 
									  const struct drm_connector_funcs *con_funcs,
 | 
				
			||||||
 | 
									  struct drm_encoder *enc,
 | 
				
			||||||
 | 
									  const u32 *formats, int n_formats);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int drm_writeback_set_fb(struct drm_connector_state *conn_state,
 | 
					int drm_writeback_set_fb(struct drm_connector_state *conn_state,
 | 
				
			||||||
			 struct drm_framebuffer *fb);
 | 
								 struct drm_framebuffer *fb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue