Skip to content
Permalink
Browse files
drm: allow passing a real encoder object for wb connector
Instead of creating an internal encoder for the writeback
connector to satisfy DRM requirements, allow the clients
to pass a real encoder to it by changing the drm_writeback's
encoder to a pointer.

If a real encoder is not passed, drm_writeback_connector_init
will internally allocate one.

This will help the clients to manage the real encoder states
better as they will allocate and maintain the encoder.

Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
  • Loading branch information
Abhinav Kumar authored and intel-lab-lkp committed Jan 21, 2022
1 parent 4efdddb commit ce1d81913d9146f6e753c39f41929266a5885f99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
@@ -189,8 +189,11 @@ int drm_writeback_connector_init(struct drm_device *dev,
if (IS_ERR(blob))
return PTR_ERR(blob);

drm_encoder_helper_add(&wb_connector->encoder, enc_helper_funcs);
ret = drm_encoder_init(dev, &wb_connector->encoder,
/* allocate the internal drm encoder if a real one wasnt passed */
if (!wb_connector->encoder)
wb_connector->encoder = devm_kzalloc(dev->dev, sizeof(struct drm_encoder), GFP_KERNEL);
drm_encoder_helper_add(wb_connector->encoder, enc_helper_funcs);
ret = drm_encoder_init(dev, wb_connector->encoder,
&drm_writeback_encoder_funcs,
DRM_MODE_ENCODER_VIRTUAL, NULL);
if (ret)
@@ -204,7 +207,7 @@ int drm_writeback_connector_init(struct drm_device *dev,
goto connector_fail;

ret = drm_connector_attach_encoder(connector,
&wb_connector->encoder);
wb_connector->encoder);
if (ret)
goto attach_fail;

@@ -233,7 +236,7 @@ int drm_writeback_connector_init(struct drm_device *dev,
attach_fail:
drm_connector_cleanup(connector);
connector_fail:
drm_encoder_cleanup(&wb_connector->encoder);
drm_encoder_cleanup(wb_connector->encoder);
fail:
drm_property_blob_put(blob);
return ret;
@@ -31,7 +31,7 @@ struct drm_writeback_connector {
* by passing the @enc_funcs parameter to drm_writeback_connector_init()
* function.
*/
struct drm_encoder encoder;
struct drm_encoder *encoder;

/**
* @pixel_formats_blob_ptr:

0 comments on commit ce1d819

Please sign in to comment.