drm/bridge: introduce bridge detaching mechanism
Subsystems (3)
PATCH v3 1/3 drm/bridge: introduce bridge detaching mechanism
Up to now, once a bridge has been attached to a DRM device, it cannot be undone.
In particular you couldn't rmmod/insmod a DRM driver that uses a bridge, because the bridge would remain bound to the first (dead) driver instance.
This patch fixes this by introducing drm_encoder_detach() and a ->detach callback in drm_bridge_funcs for the bridge to be notified about detaches.
It's DRM/KMS driver responsibility to call drm_encoder_detach().
While adding the bridge detach callback, with its kerneldoc, I also added kerneldoc for attach callback.
Few other kerneldocs fixes around there are included.
--- drivers/gpu/drm/drm_bridge.c | 29 +++++++++++++++++++++++++++-- include/drm/drm_crtc.h | 26 +++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_bridge.c +27 -2
@@ -98,11 +98,11 @@ EXPORT_SYMBOL(drm_bridge_remove);* @dev: DRM device * @bridge: bridge control structure * -* called by a kms driver to link one of our encoder/bridge to the given +* Called by a kms driver to link one of our encoder/bridge to the given * bridge. * * Note that setting up links between the bridge and our encoder/bridge -* objects needs to be handled by the kms driver itself +* objects needs to be handled by the kms driver itself. * * RETURNS: * Zero on success, error code on failure
@@ -125,6 +125,31 @@ int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge)EXPORT_SYMBOL (drm_bridge_attach);/** +* drm_bridge_detach - deassociate given bridge from its DRM device +* +* @bridge: bridge control structure +* +* Called by a kms driver to unlink the given bridge from its DRM device. +* +* Note that tearing down links between the bridge and our encoder/bridge +* objects needs to be handled by the kms driver itself. +*/ +void drm_bridge_detach (struct drm_bridge *bridge) +{ +if (WARN_ON (!bridge)) +return ; + +if (WARN_ON (!bridge->dev)) +return ; + +if (bridge->funcs->detach) + bridge->funcs->detach (bridge); + + bridge->dev =NULL ; +} +EXPORT_SYMBOL (drm_bridge_detach); + +/** * DOC: bridge callbacks * * The &drm_bridge_funcs ops are populated by the bridge driver. The DRM
include/drm/drm_crtc.h +25 -1
@@ -1118,12 +1118,33 @@ struct drm_plane {/** * struct drm_bridge_funcs - drm_bridge control functions -* @attach: Called during drm_bridge_attach */ struct drm_bridge_funcs { +/** +* @attach: +* +* This callback is invoked whenever our bridge is being attached to a +* &drm_encoder. +* +* The attach callback is optional. +* +* RETURNS: +* +* Zero on success, error code on failure. +*/ int (*attach)(struct drm_bridge *bridge);/** +* @detach: +* +* This callback is invoked whenever our bridge is being detached from a +* &drm_encoder. +* +* The detach callback is optional. +*/ +void (*detach)(struct drm_bridge *bridge); + +/** * @mode_fixup: * * This callback is used to validate and adjust a mode. The paramater
@@ -1137,6 +1158,8 @@ struct drm_bridge_funcs {* this function passes all other callbacks must succeed for this * configuration. * +* The mode_fixup callback is optional. +* * NOTE: * * This function is called in the check phase of atomic modesets, which
@@ -2426,6 +2449,7 @@ extern int drm_bridge_add(struct drm_bridge *bridge);extern void drm_bridge_remove (struct drm_bridge *bridge);extern struct drm_bridge *of_drm_find_bridge (struct device_node *np);extern int drm_bridge_attach (struct drm_device *dev,struct drm_bridge *bridge); +extern void drm_bridge_detach (struct drm_bridge *bridge); bool drm_bridge_mode_fixup(struct drm_bridge *bridge, const struct drm_display_mode *mode,
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 2/3 drm: simple_kms_helper: make connector optional at init time
drm_simple_display_pipe_init() pretends to attach a connector to the display pipe.
In case a drm bridge has to be used, then it's the bridge that takes care of connectors.
This patch makes the connector parameter optional for drm_simple_display_pipe_init(), so that a drm bridge could handle connector by itself later.
--- drivers/gpu/drm/drm_simple_kms_helper.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_simple_kms_helper.c +8 -3
@@ -146,10 +146,15 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = {* @funcs: callbacks for the display pipe (optional) * @formats: array of supported formats (DRM_FORMAT\_\*) * @format_count: number of elements in @formats -* @connector: connector to attach and register +* @connector: connector to attach and register (optional) * * Sets up a display pipeline which consist of a really simple -* plane-crtc-encoder pipe coupled with the provided connector. +* plane-crtc-encoder pipe. +* +* If a connector is supplied, the pipe will be coupled with the provided +* connector. You may supply a NULL connector when using drm bridges, that +* handle connectors themselves (see drm_simple_display_pipe_attach_bridge()). +* * Teardown of a simple display pipe is all handled automatically by the drm * core through calling drm_mode_config_cleanup(). Drivers afterwards need to * release the memory for the structure themselves.
@@ -188,7 +193,7 @@ int drm_simple_display_pipe_init(struct drm_device *dev, encoder->possible_crtcs =1 <<drm_crtc_index (crtc); ret =drm_encoder_init (dev, encoder, &drm_simple_kms_encoder_funcs,DRM_MODE_ENCODER_NONE ,NULL ); -if (ret) +if (ret || !connector)return ret;return drm_mode_connector_attach_encoder (connector, encoder);
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Archit Taneja
AppliedRe: [PATCH v3 2/3] drm: simple_kms_helper: make connector optional at init time
Quoted 10 lines · Andrea Merello
drm_simple_display_pipe_init()pretends to attach a connector to the display pipe.In case a drm bridge has to be used, then it's the bridge that takes care of connectors.
This patch makes the connector parameter optional for
drm_simple_display_pipe_init(), so that a drm bridge could handle connector by itself later.
Pushed to drm-misc.
Thanks,
Archit
Quoted 41 lines
Signed-off-by Andrea Merello <[email protected]>Reviewed-by Daniel Vetter <[email protected]>Cc David Airlie <[email protected]>Cc Noralf Trønnes <[email protected]>Cc Daniel Vetter <[email protected]>--- drivers/gpu/drm/drm_simple_kms_helper.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_simple_kms_helper.c +8
-3@@ -146,10 +146,15 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = {* @funcs: callbacks for the display pipe (optional) * @formats: array of supported formats (DRM_FORMAT\_\*) * @format_count: number of elements in @formats -* @connector: connector to attach and register +* @connector: connector to attach and register (optional) * * Sets up a display pipeline which consist of a really simple -* plane-crtc-encoder pipe coupled with the provided connector. +* plane-crtc-encoder pipe. +* +* If a connector is supplied, the pipe will be coupled with the provided +* connector. You may supply a NULL connector when using drm bridges, that +* handle connectors themselves (see drm_simple_display_pipe_attach_bridge()). +* * Teardown of a simple display pipe is all handled automatically by the drm * core through calling drm_mode_config_cleanup(). Drivers afterwards need to * release the memory for the structure themselves. @@ -188,7 +193,7 @@ int drm_simple_display_pipe_init(struct drm_device *dev, encoder->possible_crtcs =1 <<drm_crtc_index (crtc); ret =drm_encoder_init (dev, encoder, &drm_simple_kms_encoder_funcs,DRM_MODE_ENCODER_NONE ,NULL ); -if (ret) +if (ret || !connector)return ret;return drm_mode_connector_attach_encoder (connector, encoder);
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 3/3 drm: simple_kms_helper: add support for bridges
In reply to Andrea MerelloIntroduce drm_simple_display_pipe_attach_bridge() and drm_simple_display_pipe_detach_bridge() in order to make it possible to use drm encoders with the simple display pipes managed by simple_kms_helpers
--- drivers/gpu/drm/drm_simple_kms_helper.c | 40 +++++++++++++++++++++++++++++++++ include/drm/drm_simple_kms_helper.h | 5 +++++ 2 files changed, 45 insertions(+)
drivers/gpu/drm/drm_simple_kms_helper.c +40 -0
@@ -140,6 +140,46 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = { };/** +* drm_simple_display_pipe_attach_bridge - Attach a bridge to the display pipe +* @pipe: simple display pipe object +* @bridge: bridge to attach +* +* Makes it possible to still use the drm_simple_display_pipe helpers when +* a DRM bridge has to be used. +* +* Note that you probably want to initialize the pipe by passing a NULL +* connector to drm_simple_display_pipe_init(). +* +* Returns: +* Zero on success, negative error code on failure. +*/ +int drm_simple_display_pipe_attach_bridge (struct drm_simple_display_pipe *pipe, +struct drm_bridge *bridge) +{ + bridge->encoder = &pipe->encoder; + pipe->encoder.bridge = bridge; +return drm_bridge_attach (pipe->encoder.dev, bridge); +} +EXPORT_SYMBOL (drm_simple_display_pipe_attach_bridge); + +/** +* drm_simple_display_pipe_detach_bridge - Detach the bridge from the display pipe +* @pipe: simple display pipe object +* +* Detaches the drm bridge previously attached with +* drm_simple_display_pipe_attach_bridge() +*/ +void drm_simple_display_pipe_detach_bridge (struct drm_simple_display_pipe *pipe) +{ +if (WARN_ON (!pipe->encoder.bridge)) +return ; + +drm_bridge_detach (pipe->encoder.bridge); + pipe->encoder.bridge =NULL ; +} +EXPORT_SYMBOL (drm_simple_display_pipe_detach_bridge); + +/** * drm_simple_display_pipe_init - Initialize a simple display pipeline * @dev: DRM device * @pipe: simple display pipe object to initialize
include/drm/drm_simple_kms_helper.h +5 -0
@@ -85,6 +85,11 @@ struct drm_simple_display_pipe {const struct drm_simple_display_pipe_funcs *funcs; }; +int drm_simple_display_pipe_attach_bridge (struct drm_simple_display_pipe *pipe, +struct drm_bridge *bridge); + +void drm_simple_display_pipe_detach_bridge (struct drm_simple_display_pipe *pipe); + int drm_simple_display_pipe_init(struct drm_device *dev, struct drm_simple_display_pipe *pipe, const struct drm_simple_display_pipe_funcs *funcs,
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Archit Taneja
AppliedRe: [PATCH v3 3/3] drm: simple_kms_helper: add support for bridges
Quoted 7 lines · Andrea Merello
Introduce
drm_simple_display_pipe_attach_bridge()anddrm_simple_display_pipe_detach_bridge()in order to make it possible to use drm encoders with the simple display pipes managed bysimple_kms_helpersSuggested-by Daniel Vetter <[email protected]>Signed-off-by Andrea Merello <[email protected]>Reviewed-by Daniel Vetter <[email protected]>
Pushed to drm-misc.
Thanks,
Archit
Quoted 76 lines
Cc Noralf Trønnes <[email protected]>Cc Daniel Vetter <[email protected]>Cc David Airlie <[email protected]>--- drivers/gpu/drm/drm_simple_kms_helper.c | 40 +++++++++++++++++++++++++++++++++ include/drm/drm_simple_kms_helper.h | 5 +++++ 2 files changed, 45 insertions(+)drivers/gpu/drm/drm_simple_kms_helper.c +40
-0@@ -140,6 +140,46 @@ static const struct drm_plane_funcs drm_simple_kms_plane_funcs = { };/** +* drm_simple_display_pipe_attach_bridge - Attach a bridge to the display pipe +* @pipe: simple display pipe object +* @bridge: bridge to attach +* +* Makes it possible to still use the drm_simple_display_pipe helpers when +* a DRM bridge has to be used. +* +* Note that you probably want to initialize the pipe by passing a NULL +* connector to drm_simple_display_pipe_init(). +* +* Returns: +* Zero on success, negative error code on failure. +*/ +int drm_simple_display_pipe_attach_bridge (struct drm_simple_display_pipe *pipe, +struct drm_bridge *bridge) +{ + bridge->encoder = &pipe->encoder; + pipe->encoder.bridge = bridge; +return drm_bridge_attach (pipe->encoder.dev, bridge); +} +EXPORT_SYMBOL (drm_simple_display_pipe_attach_bridge); + +/** +* drm_simple_display_pipe_detach_bridge - Detach the bridge from the display pipe +* @pipe: simple display pipe object +* +* Detaches the drm bridge previously attached with +* drm_simple_display_pipe_attach_bridge() +*/ +void drm_simple_display_pipe_detach_bridge (struct drm_simple_display_pipe *pipe) +{ +if (WARN_ON (!pipe->encoder.bridge)) +return ; + +drm_bridge_detach (pipe->encoder.bridge); + pipe->encoder.bridge =NULL ; +} +EXPORT_SYMBOL (drm_simple_display_pipe_detach_bridge); + +/** * drm_simple_display_pipe_init - Initialize a simple display pipeline * @dev: DRM device * @pipe: simple display pipe object to initialize include/drm/drm_simple_kms_helper.h +5
-0@@ -85,6 +85,11 @@ struct drm_simple_display_pipe {const struct drm_simple_display_pipe_funcs *funcs; }; +int drm_simple_display_pipe_attach_bridge (struct drm_simple_display_pipe *pipe, +struct drm_bridge *bridge); + +void drm_simple_display_pipe_detach_bridge (struct drm_simple_display_pipe *pipe); + int drm_simple_display_pipe_init(struct drm_device *dev, struct drm_simple_display_pipe *pipe, const struct drm_simple_display_pipe_funcs *funcs,
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 16 lines · Andrea Merello
Up to now, once a bridge has been attached to a DRM device, it cannot be undone.
In particular you couldn't rmmod/insmod a DRM driver that uses a bridge, because the bridge would remain bound to the first (dead) driver instance.
This patch fixes this by introducing
drm_encoder_detach()and a ->detach callback indrm_bridge_funcsfor the bridge to be notified about detaches.It's DRM/KMS driver responsibility to call
drm_encoder_detach().While adding the bridge detach callback, with its kerneldoc, I also added kerneldoc for attach callback.
Few other kerneldocs fixes around there are included.
Quoted 7 lines
Suggested-by Daniel Vetter <[email protected]>Suggested-by Lucas Stach <[email protected]>Signed-off-by Andrea Merello <[email protected]>Cc Archit Taneja <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Lucas Stach <[email protected]>
As discussed on the last round, I'll let Archit apply all 3 to drm-misc, so he can check them out too.
-Daniel
Quoted 114 lines
--- drivers/gpu/drm/drm_bridge.c | 29 +++++++++++++++++++++++++++-- include/drm/drm_crtc.h | 26 +++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_bridge.c +27
-2@@ -98,11 +98,11 @@ EXPORT_SYMBOL(drm_bridge_remove);* @dev: DRM device * @bridge: bridge control structure * -* called by a kms driver to link one of our encoder/bridge to the given +* Called by a kms driver to link one of our encoder/bridge to the given * bridge. * * Note that setting up links between the bridge and our encoder/bridge -* objects needs to be handled by the kms driver itself +* objects needs to be handled by the kms driver itself. * * RETURNS: * Zero on success, error code on failure @@ -125,6 +125,31 @@ int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge)EXPORT_SYMBOL (drm_bridge_attach);/** +* drm_bridge_detach - deassociate given bridge from its DRM device +* +* @bridge: bridge control structure +* +* Called by a kms driver to unlink the given bridge from its DRM device. +* +* Note that tearing down links between the bridge and our encoder/bridge +* objects needs to be handled by the kms driver itself. +*/ +void drm_bridge_detach (struct drm_bridge *bridge) +{ +if (WARN_ON (!bridge)) +return ; + +if (WARN_ON (!bridge->dev)) +return ; + +if (bridge->funcs->detach) + bridge->funcs->detach (bridge); + + bridge->dev =NULL ; +} +EXPORT_SYMBOL (drm_bridge_detach); + +/** * DOC: bridge callbacks * * The &drm_bridge_funcs ops are populated by the bridge driver. The DRM include/drm/drm_crtc.h +25
-1@@ -1118,12 +1118,33 @@ struct drm_plane {/** * struct drm_bridge_funcs - drm_bridge control functions -* @attach: Called during drm_bridge_attach */ struct drm_bridge_funcs { +/** +* @attach: +* +* This callback is invoked whenever our bridge is being attached to a +* &drm_encoder. +* +* The attach callback is optional. +* +* RETURNS: +* +* Zero on success, error code on failure. +*/ int (*attach)(struct drm_bridge *bridge);/** +* @detach: +* +* This callback is invoked whenever our bridge is being detached from a +* &drm_encoder. +* +* The detach callback is optional. +*/ +void (*detach)(struct drm_bridge *bridge); + +/** * @mode_fixup: * * This callback is used to validate and adjust a mode. The paramater @@ -1137,6 +1158,8 @@ struct drm_bridge_funcs {* this function passes all other callbacks must succeed for this * configuration. * +* The mode_fixup callback is optional. +* * NOTE: * * This function is called in the check phase of atomic modesets, which @@ -2426,6 +2449,7 @@ extern int drm_bridge_add(struct drm_bridge *bridge);extern void drm_bridge_remove (struct drm_bridge *bridge);extern struct drm_bridge *of_drm_find_bridge (struct device_node *np);extern int drm_bridge_attach (struct drm_device *dev,struct drm_bridge *bridge); +extern void drm_bridge_detach (struct drm_bridge *bridge); bool drm_bridge_mode_fixup(struct drm_bridge *bridge, const struct drm_display_mode *mode,Signature · 1 line
2.7.4
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Archit Taneja
AppliedQuoted 25 lines · Daniel Vetter
Quoted 16 lines · Andrea Merello
Up to now, once a bridge has been attached to a DRM device, it cannot be undone.
In particular you couldn't rmmod/insmod a DRM driver that uses a bridge, because the bridge would remain bound to the first (dead) driver instance.
This patch fixes this by introducing
drm_encoder_detach()and a ->detach callback indrm_bridge_funcsfor the bridge to be notified about detaches.It's DRM/KMS driver responsibility to call
drm_encoder_detach().While adding the bridge detach callback, with its kerneldoc, I also added kerneldoc for attach callback.
Few other kerneldocs fixes around there are included.
Quoted 7 lines
Suggested-by Daniel Vetter <[email protected]>Suggested-by Lucas Stach <[email protected]>Signed-off-by Andrea Merello <[email protected]>Cc Archit Taneja <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc Lucas Stach <[email protected]>
Quoted 4 lines
Reviewed-by Daniel Vetter <[email protected]>As discussed on the last round, I'll let Archit apply all 3 to drm-misc, so he can check them out too.
Pushed to drm-misc.
Thanks,
Archit
Quoted 116 lines
-Daniel
Quoted 114 lines
--- drivers/gpu/drm/drm_bridge.c | 29 +++++++++++++++++++++++++++-- include/drm/drm_crtc.h | 26 +++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_bridge.c +27
-2@@ -98,11 +98,11 @@ EXPORT_SYMBOL(drm_bridge_remove);* @dev: DRM device * @bridge: bridge control structure * -* called by a kms driver to link one of our encoder/bridge to the given +* Called by a kms driver to link one of our encoder/bridge to the given * bridge. * * Note that setting up links between the bridge and our encoder/bridge -* objects needs to be handled by the kms driver itself +* objects needs to be handled by the kms driver itself. * * RETURNS: * Zero on success, error code on failure @@ -125,6 +125,31 @@ int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge)EXPORT_SYMBOL (drm_bridge_attach);/** +* drm_bridge_detach - deassociate given bridge from its DRM device +* +* @bridge: bridge control structure +* +* Called by a kms driver to unlink the given bridge from its DRM device. +* +* Note that tearing down links between the bridge and our encoder/bridge +* objects needs to be handled by the kms driver itself. +*/ +void drm_bridge_detach (struct drm_bridge *bridge) +{ +if (WARN_ON (!bridge)) +return ; + +if (WARN_ON (!bridge->dev)) +return ; + +if (bridge->funcs->detach) + bridge->funcs->detach (bridge); + + bridge->dev =NULL ; +} +EXPORT_SYMBOL (drm_bridge_detach); + +/** * DOC: bridge callbacks * * The &drm_bridge_funcs ops are populated by the bridge driver. The DRM include/drm/drm_crtc.h +25
-2@@ -1118,12 +1118,33 @@ struct drm_plane {/** * struct drm_bridge_funcs - drm_bridge control functions -* @attach: Called during drm_bridge_attach */ struct drm_bridge_funcs { +/** +* @attach: +* +* This callback is invoked whenever our bridge is being attached to a +* &drm_encoder. +* +* The attach callback is optional. +* +* RETURNS: +* +* Zero on success, error code on failure. +*/ int (*attach)(struct drm_bridge *bridge);/** +* @detach: +* +* This callback is invoked whenever our bridge is being detached from a +* &drm_encoder. +* +* The detach callback is optional. +*/ +void (*detach)(struct drm_bridge *bridge); + +/** * @mode_fixup: * * This callback is used to validate and adjust a mode. The paramater @@ -1137,6 +1158,8 @@ struct drm_bridge_funcs {* this function passes all other callbacks must succeed for this * configuration. * +* The mode_fixup callback is optional. +* * NOTE: * * This function is called in the check phase of atomic modesets, which @@ -2426,6 +2449,7 @@ extern int drm_bridge_add(struct drm_bridge *bridge);extern void drm_bridge_remove (struct drm_bridge *bridge);extern struct drm_bridge *of_drm_find_bridge (struct device_node *np);extern int drm_bridge_attach (struct drm_device *dev,struct drm_bridge *bridge); +extern void drm_bridge_detach (struct drm_bridge *bridge); bool drm_bridge_mode_fixup(struct drm_bridge *bridge, const struct drm_display_mode *mode, --2.7.4
Signature · 6 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel