drm/arm/komeda: Remove component framework and add a simple encoder
Subsystems (4)
PATCH v2 1/1 drm/arm/komeda: Remove component framework and add a simple encoder
The Komeda driver always expects the remote connector node to initialize an encoder. It uses the component aggregator framework which consists of component->bind() calls used to initialize the remote encoder and attach it to the crtc. This makes it incompatible with connector drivers which implement drm_bridge APIs.
Remove all component framework calls from the komeda driver and declare and attach an encoder inside komeda_crtc_add().
The remote connector driver has to implement the DRM bridge APIs which can be used to glue the encoder to the remote connector. Since we usually pair this with a component encoder that also implements a drm_bridge, dropping support is not expected to affect users of this driver.
--- .../gpu/drm/arm/display/komeda/komeda_crtc.c | 23 +++++++- .../gpu/drm/arm/display/komeda/komeda_drv.c | 57 ++----------------- .../gpu/drm/arm/display/komeda/komeda_kms.c | 10 +--- .../gpu/drm/arm/display/komeda/komeda_kms.h | 3 + 4 files changed, 32 insertions(+), 61 deletions(-)
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +22 -1
@@ -13,6 +13,8 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_print.h> #include <drm/drm_vblank.h> +#include <drm/drm_simple_kms_helper.h> +#include <drm/drm_bridge.h> #include "komeda_dev.h" #include "komeda_kms.h"
@@ -613,9 +615,11 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms, struct komeda_crtc *kcrtc) {struct drm_crtc *crtc = &kcrtc->base; +struct drm_device *base = &kms->base; +struct drm_bridge *bridge;int err; - err =drm_crtc_init_with_planes (&kms->base, crtc, + err =drm_crtc_init_with_planes (base, crtc,get_crtc_primary (kms, kcrtc),NULL , &komeda_crtc_funcs,NULL );if (err)
@@ -625,6 +629,23 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms, crtc->port = kcrtc->master->of_output_port; + +/* Construct an encoder for each pipeline and attach it to the remote +* bridge +*/ + kcrtc->encoder.possible_crtcs =drm_crtc_mask (crtc); + err =drm_simple_encoder_init (base, &kcrtc->encoder, +DRM_MODE_ENCODER_TMDS ); +if (err) +return err; + + bridge =devm_drm_of_get_bridge (base->dev, kcrtc->master->of_node, +KOMEDA_OF_PORT_OUTPUT ,0 ); +if (IS_ERR (bridge)) +return PTR_ERR (bridge); + + err =drm_bridge_attach (&kcrtc->encoder, bridge,NULL ,0 ); +drm_crtc_enable_color_mgmt (crtc,0 , true,KOMEDA_COLOR_LUT_SIZE );return err;
drivers/gpu/drm/arm/display/komeda/komeda_drv.c +6 -51
88 lines not on this page · raw message
drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1 -9
@@ -4,7 +4,6 @@* Author: James.Qian.Wang <[email protected]> * */ -#include <linux/component.h> #include <linux/interrupt.h> #include <drm/drm_atomic.h>
@@ -307,17 +306,13 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)if (err) goto cleanup_mode_config; - err =component_bind_all (mdev->dev, kms); -if (err) - goto cleanup_mode_config; -drm_mode_config_reset (drm); err =devm_request_irq (drm->dev, mdev->irq, komeda_kms_irq_handler,IRQF_SHARED , drm->driver->name, drm);if (err) - goto free_component_binding; + goto cleanup_mode_config;drm_kms_helper_poll_init (drm);
@@ -329,8 +324,6 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev) free_interrupts:drm_kms_helper_poll_fini (drm); -free_component_binding: -component_unbind_all (mdev->dev, drm); cleanup_mode_config:drm_mode_config_cleanup (drm);komeda_kms_cleanup_private_objs (kms);
@@ -346,7 +339,6 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)drm_dev_unregister (drm);drm_kms_helper_poll_fini (drm);drm_atomic_helper_shutdown (drm); -component_unbind_all (mdev->dev, drm);drm_mode_config_cleanup (drm);komeda_kms_cleanup_private_objs (kms); drm->dev_private =NULL ;
drivers/gpu/drm/arm/display/komeda/komeda_kms.h +3 -0
@@ -85,6 +85,9 @@ struct komeda_crtc {/** @disable_done: this flip_done is for tracing the disable */ struct completion *disable_done; + +/** @encoder: encoder at the end of the pipeline */ +struct drm_encoder encoder; };/**
Signature · 1 line
2.25.1
Liviu Dudau
maintainerHi Faiz,
Quoted 6 lines · Faiz Abbas
The Komeda driver always expects the remote connector node to initialize an encoder. It uses the component aggregator framework which consists of
component->bind()calls used to initialize the remote encoder and attach it to the crtc. This makes it incompatible with connector drivers which implementdrm_bridgeAPIs.
Quoted 8 lines
Remove all component framework calls from the komeda driver and declare and attach an encoder inside
komeda_crtc_add().The remote connector driver has to implement the DRM bridge APIs which can be used to glue the encoder to the remote connector. Since we usually pair this with a component encoder that also implements a
drm_bridge, dropping support is not expected to affect users of this driver.
Thanks for updating the commit description, I think it shows the intent better.
When I'm trying to apply your patch to drm-misc next (or any branch that matters) it fails because ...
Quoted 14 lines
Signed-off-by Faiz Abbas <[email protected]>--- .../gpu/drm/arm/display/komeda/komeda_crtc.c | 23 +++++++- .../gpu/drm/arm/display/komeda/komeda_drv.c | 57 ++----------------- .../gpu/drm/arm/display/komeda/komeda_kms.c | 10 +--- .../gpu/drm/arm/display/komeda/komeda_kms.h | 3 + 4 files changed, 32 insertions(+), 61 deletions(-)drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +0
-0
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c line 13
Quoted 1 line
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +0
-0@@ -13,6 +13,8 @@#include <drm/drm_crtc_helper.h>
... this line is different in my tree. It looks like your tree is missing commit e3b63718827880 ("drm/arm/komeda: Remove unnecessary include statements for drm_crtc_helper.h"), which has been applied in early January.
Best regards,
Liviu
Quoted 205 lines
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +22
-1#include <drm/drm_print.h> #include <drm/drm_vblank.h> +#include <drm/drm_simple_kms_helper.h> +#include <drm/drm_bridge.h> #include "komeda_dev.h" #include "komeda_kms.h" @@ -613,9 +615,11 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms, struct komeda_crtc *kcrtc) {struct drm_crtc *crtc = &kcrtc->base; +struct drm_device *base = &kms->base; +struct drm_bridge *bridge;int err; - err =drm_crtc_init_with_planes (&kms->base, crtc, + err =drm_crtc_init_with_planes (base, crtc,get_crtc_primary (kms, kcrtc),NULL , &komeda_crtc_funcs,NULL );if (err)@@ -625,6 +629,23 @@ static int komeda_crtc_add(struct komeda_kms_dev *kms, crtc->port = kcrtc->master->of_output_port; + +/* Construct an encoder for each pipeline and attach it to the remote +* bridge +*/ + kcrtc->encoder.possible_crtcs =drm_crtc_mask (crtc); + err =drm_simple_encoder_init (base, &kcrtc->encoder, +DRM_MODE_ENCODER_TMDS ); +if (err) +return err; + + bridge =devm_drm_of_get_bridge (base->dev, kcrtc->master->of_node, +KOMEDA_OF_PORT_OUTPUT ,0 ); +if (IS_ERR (bridge)) +return PTR_ERR (bridge); + + err =drm_bridge_attach (&kcrtc->encoder, bridge,NULL ,0 ); +drm_crtc_enable_color_mgmt (crtc,0 , true,KOMEDA_COLOR_LUT_SIZE );return err;drivers/gpu/drm/arm/display/komeda/komeda_drv.c +6
-51@@ -7,7 +7,6 @@#include <linux/module.h> #include <linux/kernel.h> #include <linux/platform_device.h> -#include <linux/component.h> #include <linux/pm_runtime.h> #include <drm/drm_fb_helper.h> #include <drm/drm_module.h> @@ -27,13 +26,11 @@ struct komeda_dev *dev_to_mdev(struct device *dev)return mdrv ? mdrv->mdev :NULL ; } -static void komeda_unbind (struct device *dev) +static int komeda_platform_remove (struct platform_device *pdev) { +struct device *dev = &pdev->dev;struct komeda_drv *mdrv =dev_get_drvdata (dev); -if (!mdrv) -return ; -komeda_kms_detach (mdrv->kms);if (pm_runtime_enabled (dev))@@ -45,10 +42,13 @@ static void komeda_unbind(struct device *dev)dev_set_drvdata (dev,NULL );devm_kfree (dev, mdrv); + +return 0 ; } -static int komeda_bind (struct device *dev) +static int komeda_platform_probe (struct platform_device *pdev) { +struct device *dev = &pdev->dev;struct komeda_drv *mdrv;int err;@@ -88,52 +88,7 @@ static int komeda_bind(struct device *dev) free_mdrv:devm_kfree (dev, mdrv);return err; -} - -static const struct component_master_ops komeda_master_ops = { - .bind = komeda_bind, - .unbind = komeda_unbind, -}; -static void komeda_add_slave (struct device *master, -struct component_match **match, -struct device_node *np, -u32 port,u32 endpoint) -{ -struct device_node *remote; - - remote =of_graph_get_remote_node (np, port, endpoint); -if (remote) { -drm_of_component_match_add (master, match, component_compare_of, remote); -of_node_put (remote); - } -} - -static int komeda_platform_probe (struct platform_device *pdev) -{ -struct device *dev = &pdev->dev; -struct component_match *match =NULL ; -struct device_node *child; - -if (!dev->of_node) -return -ENODEV ; - -for_each_available_child_of_node (dev->of_node, child) { -if (of_node_cmp (child->name,"pipeline" ) !=0 ) -continue ; - -/* add connector */ -komeda_add_slave (dev, &match, child,KOMEDA_OF_PORT_OUTPUT ,0 ); -komeda_add_slave (dev, &match, child,KOMEDA_OF_PORT_OUTPUT ,1 ); - } - -return component_master_add_with_match (dev, &komeda_master_ops, match); -} - -static int komeda_platform_remove (struct platform_device *pdev) -{ -component_master_del (&pdev->dev, &komeda_master_ops); -return 0 ; }static const struct of_device_id komeda_of_match[] = {drivers/gpu/drm/arm/display/komeda/komeda_kms.c +1
-9@@ -4,7 +4,6 @@* Author: James.Qian.Wang <[email protected]> * */ -#include <linux/component.h> #include <linux/interrupt.h> #include <drm/drm_atomic.h> @@ -307,17 +306,13 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev)if (err) goto cleanup_mode_config; - err =component_bind_all (mdev->dev, kms); -if (err) - goto cleanup_mode_config; -drm_mode_config_reset (drm); err =devm_request_irq (drm->dev, mdev->irq, komeda_kms_irq_handler,IRQF_SHARED , drm->driver->name, drm);if (err) - goto free_component_binding; + goto cleanup_mode_config;drm_kms_helper_poll_init (drm);@@ -329,8 +324,6 @@ struct komeda_kms_dev *komeda_kms_attach(struct komeda_dev *mdev) free_interrupts:drm_kms_helper_poll_fini (drm); -free_component_binding: -component_unbind_all (mdev->dev, drm); cleanup_mode_config:drm_mode_config_cleanup (drm);komeda_kms_cleanup_private_objs (kms);@@ -346,7 +339,6 @@ void komeda_kms_detach(struct komeda_kms_dev *kms)drm_dev_unregister (drm);drm_kms_helper_poll_fini (drm);drm_atomic_helper_shutdown (drm); -component_unbind_all (mdev->dev, drm);drm_mode_config_cleanup (drm);komeda_kms_cleanup_private_objs (kms); drm->dev_private =NULL ;drivers/gpu/drm/arm/display/komeda/komeda_kms.h +3
-0@@ -85,6 +85,9 @@ struct komeda_crtc {/** @disable_done: this flip_done is for tracing the disable */ struct completion *disable_done; + +/** @encoder: encoder at the end of the pipeline */ +struct drm_encoder encoder; };/** Signature · 1 line
2.25.1
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Hi Liviu,
Quoted 32 lines · Liviu Dudau
Hi Faiz,
Quoted 6 lines · Faiz Abbas
The Komeda driver always expects the remote connector node to initialize an encoder. It uses the component aggregator framework which consists of
component->bind()calls used to initialize the remote encoder and attach it to the crtc. This makes it incompatible with connector drivers which implementdrm_bridgeAPIs.Quoted 8 lines
Remove all component framework calls from the komeda driver and declare and attach an encoder inside
komeda_crtc_add().The remote connector driver has to implement the DRM bridge APIs which can be used to glue the encoder to the remote connector. Since we usually pair this with a component encoder that also implements a
drm_bridge, dropping support is not expected to affect users of this driver.Thanks for updating the commit description, I think it shows the intent better.
When I'm trying to apply your patch to drm-misc next (or any branch that matters) it fails because ...
Quoted 9 lines
Signed-off-by Faiz Abbas <[email protected]>--- .../gpu/drm/arm/display/komeda/komeda_crtc.c | 23 +++++++- .../gpu/drm/arm/display/komeda/komeda_drv.c | 57 ++----------------- .../gpu/drm/arm/display/komeda/komeda_kms.c | 10 +--- .../gpu/drm/arm/display/komeda/komeda_kms.h | 3 + 4 files changed, 32 insertions(+), 61 deletions(-)
Quoted 11 lines
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c line 13
Quoted 6 lines
drivers/gpu/drm/arm/display/komeda/komeda_crtc.c +0
-0@@ -13,6 +13,8 @@#include <drm/drm_crtc_helper.h> ... this line is different in my tree. It looks like your tree is missing commit
e3b63718827880("drm/arm/komeda: Remove unnecessary include statements fordrm_crtc_helper.h"), which has been applied in early January.
Right. Let me rebase to drm-misc-next and send another version.
Thanks,
Faiz