MTK MDP driver cleanups to prep for futher work
Subsystems (2)
cover MTK MDP driver cleanups to prep for futher work
From: Eizan Miyamoto <[email protected]>
It most notably converts an array of MDP components to a list instead, but also removes some unused fields.
This series of patches does some cleanup in preparation for futher work so that hardware video decode works on 4.19 and later kernels. We are planning on adding a dummy driver for the relevant MDP components that will be bound together using the component framework, which will enable calls to set up IOMMUs and LARBs, and make calls into pm_runtime.
Eizan Miyamoto (5):
[media] mtk-mdp: remove mtk_mdp_comp.regs from mtk_mdp_comp.h [media] mtk-mdp: handle vb2_dma_contig_set_max_seg_size errors during
probe
[media] mtk-mdp: handle vpu_wdt_reg_handler() errors during probe [media] mtk-mdp: convert mtk_mdp_dev.comp array to list [media] mtk-mdp: Remove mtk_mdp_comp.id and supporting functionality
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 60 ++------------- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 23 +----- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 74 ++++++++++++------- drivers/media/platform/mtk-mdp/mtk_mdp_core.h | 10 ++- 4 files changed, 68 insertions(+), 99 deletions(-)
Signature · 1 line
2.26.2.526.g744177e7f7-goog
PATCH 1/5 mtk-mdp: remove mtk_mdp_comp.regs from mtk_mdp_comp.h
These fields are not used and can be removed.
---
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 1 - drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 2 -- 2 files changed, 3 deletions(-)
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +0 -1
@@ -106,7 +106,6 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, comp->dev_node =of_node_get (node); comp->id = comp_id; comp->type = mtk_mdp_matches[comp_id].type; - comp->regs =of_iomap (node,0 );for (i =0 ; i <ARRAY_SIZE (comp->clk); i++) { comp->clk[i] =of_clk_get (node, i);
drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +0 -2
@@ -38,7 +38,6 @@ enum mtk_mdp_comp_id {* struct mtk_mdp_comp - the MDP's function component data * @dev_node: component device node * @clk: clocks required for component -* @regs: Mapped address of component registers. * @larb_dev: SMI device required for component * @type: component type * @id: component ID
@@ -46,7 +45,6 @@ enum mtk_mdp_comp_id {struct mtk_mdp_comp {struct device_node *dev_node;struct clk *clk[2 ]; -void __iomem *regs;struct device *larb_dev;enum mtk_mdp_comp_type type;enum mtk_mdp_comp_id id;
Signature · 1 line
2.26.2.526.g744177e7f7-goog
Re: [PATCH v1 1/5] [media] mtk-mdp: remove mtk_mdp_comp.regs from mtk_mdp_comp.h
Hi Eizan,
Thank you for your patch. One trivial comment below ...
Missatge de Eizan Miyamoto <[email protected]> del dia dt., 5 de maig 2020 a les 6:01:
Quoted 4 lines
These fields are not used and can be removed.
Signed-off-by [email protected]
Malformatted Signed-off-by tag. Drop it.
Quoted 1 line
Signed-off-by Eizan Miyamoto <[email protected]>
Note that the author/seder should match the Signed-off-by, so you should use your chromium.org account here. Other than that the patch looks good to me, so
Quoted 46 lines
---
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 1 - drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 2 -- 2 files changed, 3 deletions(-)drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +0
-1@@ -106,7 +106,6 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, comp->dev_node =of_node_get (node); comp->id = comp_id; comp->type = mtk_mdp_matches[comp_id].type; - comp->regs =of_iomap (node,0 );for (i =0 ; i <ARRAY_SIZE (comp->clk); i++) { comp->clk[i] =of_clk_get (node, i);drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +0
-3@@ -38,7 +38,6 @@ enum mtk_mdp_comp_id {* struct mtk_mdp_comp - the MDP's function component data * @dev_node: component device node * @clk: clocks required for component -* @regs: Mapped address of component registers. * @larb_dev: SMI device required for component * @type: component type * @id: component ID @@ -46,7 +45,6 @@ enum mtk_mdp_comp_id {struct mtk_mdp_comp {struct device_node *dev_node;struct clk *clk[2 ]; -void __iomem *regs;struct device *larb_dev;enum mtk_mdp_comp_type type;enum mtk_mdp_comp_id id; --2.26.2.526.g744177e7f7-goog
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 2/5 mtk-mdp: handle vb2_dma_contig_set_max_seg_size errors during probe
In reply to Eizan MiyamotoThis is a cleanup to better handle errors during MDP probe.
---
drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +7 -1
@@ -193,13 +193,19 @@ static int mtk_mdp_probe(struct platform_device *pdev)platform_set_drvdata (pdev, mdp); -vb2_dma_contig_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 )); + ret =vb2_dma_contig_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) { +dev_err (&pdev->dev,"Failed to set vb2 dma mag seg size\n" ); + goto err_set_max_seg_size; + }pm_runtime_enable (dev);dev_dbg (dev,"mdp-%d registered successfully\n" , mdp->id);return 0 ; +err_set_max_seg_size: + err_m2m_register:v4l2_device_unregister (&mdp->v4l2_dev);
Signature · 1 line
2.26.2.526.g744177e7f7-goog
Re: [PATCH v1 2/5] [media] mtk-mdp: handle vb2_dma_contig_set_max_seg_size errors during probe
Hi Eizan,
Thank you for your patch.
Missatge de Eizan Miyamoto <[email protected]> del dia dt., 5 de maig 2020 a les 6:01:
Quoted 5 lines
This is a cleanup to better handle errors during MDP probe.
Signed-off-by [email protected]Signed-off-by Eizan Miyamoto <[email protected]>
Same comment as the first patch. You should probably fix your configuration.
Quoted 10 lines
---
drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/media/platform/mtk-mdp/mtk_mdp_core.c +0
-0
drivers/media/platform/mtk-mdp/mtk_mdp_core.c static int mtk_mdp_probe(struct platform_device *pdev) · line 199
Quoted 8 lines
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +4
-1@@ -193,13 +193,19 @@ static int mtk_mdp_probe(struct platform_device *pdev)platform_set_drvdata (pdev, mdp); -vb2_dma_contig_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 )); + ret =vb2_dma_contig_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 )); +if (ret) { +dev_err (&pdev->dev,"Failed to set vb2 dma mag seg size\n" ); + goto err_set_max_seg_size;
You don't need to introduce a new label, just goto err_m2m_register
Quoted 20 lines
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +3
-1+ }pm_runtime_enable (dev);dev_dbg (dev,"mdp-%d registered successfully\n" , mdp->id);return 0 ; +err_set_max_seg_size: + err_m2m_register:v4l2_device_unregister (&mdp->v4l2_dev); --2.26.2.526.g744177e7f7-goog
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 3/5 mtk-mdp: handle vpu_wdt_reg_handler() errors during probe
In reply to Eizan MiyamotoThis is a cleanup to better handle errors during MDP probe.
---
drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +8 -2
@@ -188,8 +188,12 @@ static int mtk_mdp_probe(struct platform_device *pdev) } mdp->vpu_dev =vpu_get_plat_device (pdev); -vpu_wdt_reg_handler (mdp->vpu_dev, mtk_mdp_reset_handler, mdp, -VPU_RST_MDP ); + ret =vpu_wdt_reg_handler (mdp->vpu_dev, mtk_mdp_reset_handler, mdp, +VPU_RST_MDP ); +if (ret) { +dev_err (&pdev->dev,"Failed to register reset handler\n" ); + goto err_wdt_reg; + }platform_set_drvdata (pdev, mdp);
@@ -206,6 +210,8 @@ static int mtk_mdp_probe(struct platform_device *pdev) err_set_max_seg_size: +err_wdt_reg: + err_m2m_register:v4l2_device_unregister (&mdp->v4l2_dev);
Signature · 1 line
2.26.2.526.g744177e7f7-goog
Re: [PATCH v1 3/5] [media] mtk-mdp: handle vpu_wdt_reg_handler() errors during probe
Hi Eizan,
Thank you for your patch.
Missatge de Eizan Miyamoto <[email protected]> del dia dt., 5 de maig 2020 a les 6:01:
Quoted 5 lines
This is a cleanup to better handle errors during MDP probe.
Signed-off-by [email protected]Signed-off-by Eizan Miyamoto <[email protected]>
Ditto
Quoted 10 lines
---
drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/media/platform/mtk-mdp/mtk_mdp_core.c +0
-0
drivers/media/platform/mtk-mdp/mtk_mdp_core.c static int mtk_mdp_probe(struct platform_device *pdev) · line 195
Quoted 10 lines
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +5
-2@@ -188,8 +188,12 @@ static int mtk_mdp_probe(struct platform_device *pdev) } mdp->vpu_dev =vpu_get_plat_device (pdev); -vpu_wdt_reg_handler (mdp->vpu_dev, mtk_mdp_reset_handler, mdp, -VPU_RST_MDP ); + ret =vpu_wdt_reg_handler (mdp->vpu_dev, mtk_mdp_reset_handler, mdp, +VPU_RST_MDP ); +if (ret) { +dev_err (&pdev->dev,"Failed to register reset handler\n" ); + goto err_wdt_reg;
No need to introduce a new label, just goto err_m2m_register
Quoted 21 lines
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +3
-1+ }platform_set_drvdata (pdev, mdp);@@ -206,6 +210,8 @@ static int mtk_mdp_probe(struct platform_device *pdev) err_set_max_seg_size: +err_wdt_reg: + err_m2m_register:v4l2_device_unregister (&mdp->v4l2_dev); --2.26.2.526.g744177e7f7-goog
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 4/5 mtk-mdp: convert mtk_mdp_dev.comp array to list
In reply to Eizan MiyamotoThe functions mtk_mdp_register/unregister_component have been created to add / remove items from the list of components.
This will eventually enable us to specify a list of components in the device tree instead of hardcoding them into this driver.
The list is modified by a single thread at driver probe time, and will not be traversed by another thread until the call to pm_runtime_enable at the end of probing.
---
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 1 + drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 2 + drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 46 +++++++++++++------ drivers/media/platform/mtk-mdp/mtk_mdp_core.h | 10 +++- 4 files changed, 43 insertions(+), 16 deletions(-)
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +1 -0
@@ -103,6 +103,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,return -EINVAL ; } +INIT_LIST_HEAD (&comp->node); comp->dev_node =of_node_get (node); comp->id = comp_id; comp->type = mtk_mdp_matches[comp_id].type;
drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +2 -0
@@ -36,6 +36,7 @@ enum mtk_mdp_comp_id {/** * struct mtk_mdp_comp - the MDP's function component data +* @node: list node to track sibing MDP components * @dev_node: component device node * @clk: clocks required for component * @larb_dev: SMI device required for component
@@ -43,6 +44,7 @@ enum mtk_mdp_comp_id {* @id: component ID */ struct mtk_mdp_comp { +struct list_head node;struct device_node *dev_node;struct clk *clk[2 ];struct device *larb_dev;
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +32 -14
112 lines not on this page · raw message
drivers/media/platform/mtk-mdp/mtk_mdp_core.h +8 -2
@@ -136,7 +136,7 @@ struct mtk_mdp_variant {* @pdev: pointer to the image processor platform device * @variant: the IP variant information * @id: image processor device index (0..MTK_MDP_MAX_DEVS) -* @comp: MDP function components +* @comp_list: list of MDP function components * @m2m_dev: v4l2 memory-to-memory device data * @ctx_list: list of struct mtk_mdp_ctx * @vdev: video device for image processor driver
@@ -154,7 +154,7 @@ struct mtk_mdp_dev {struct platform_device *pdev;struct mtk_mdp_variant *variant;u16 id; -struct mtk_mdp_comp *comp[MTK_MDP_COMP_ID_MAX ]; +struct list_head comp_list;struct v4l2_m2m_dev *m2m_dev;struct list_head ctx_list;struct video_device *vdev;
@@ -221,6 +221,12 @@ struct mtk_mdp_ctx {extern int mtk_mdp_dbg_level; +void mtk_mdp_register_component (struct mtk_mdp_dev *mdp, +struct mtk_mdp_comp *comp); + +void mtk_mdp_unregister_component (struct mtk_mdp_dev *mdp, +struct mtk_mdp_comp *comp); +#if defined(DEBUG ) #define mtk_mdp_dbg(level, fmt, args...) \
Signature · 1 line
2.26.2.526.g744177e7f7-goog
Re: [PATCH v1 4/5] [media] mtk-mdp: convert mtk_mdp_dev.comp array to list
Hi Eizan,
Thank you for your patch.
Missatge de Eizan Miyamoto <[email protected]> del dia dt., 5 de maig 2020 a les 6:02:
Quoted 7 lines
The functions mtk_mdp_register/unregister_component have been created to add / remove items from the list of components.
This will eventually enable us to specify a list of components in the device tree instead of hardcoding them into this driver.
Quoted 6 lines
The list is modified by a single thread at driver probe time, and will not be traversed by another thread until the call to
pm_runtime_enableat the end of probing.Signed-off-by [email protected]Signed-off-by Eizan Miyamoto <[email protected]>
Ditto. Other than that.
Quoted 207 lines
---
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 1 + drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 2 + drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 46 +++++++++++++------ drivers/media/platform/mtk-mdp/mtk_mdp_core.h | 10 +++- 4 files changed, 43 insertions(+), 16 deletions(-)drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +1
-0@@ -103,6 +103,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,return -EINVAL ; } +INIT_LIST_HEAD (&comp->node); comp->dev_node =of_node_get (node); comp->id = comp_id; comp->type = mtk_mdp_matches[comp_id].type;drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +2
-0@@ -36,6 +36,7 @@ enum mtk_mdp_comp_id {/** * struct mtk_mdp_comp - the MDP's function component data +* @node: list node to track sibing MDP components * @dev_node: component device node * @clk: clocks required for component * @larb_dev: SMI device required for component @@ -43,6 +44,7 @@ enum mtk_mdp_comp_id {* @id: component ID */ struct mtk_mdp_comp { +struct list_head node;struct device_node *dev_node;struct clk *clk[2 ];struct device *larb_dev;drivers/media/platform/mtk-mdp/mtk_mdp_core.c +32
-14@@ -55,19 +55,19 @@ MODULE_DEVICE_TABLE(of, mtk_mdp_of_ids);static void mtk_mdp_clock_on (struct mtk_mdp_dev *mdp) {struct device *dev = &mdp->pdev->dev; -int i; +struct mtk_mdp_comp *comp_node; -for (i =0 ; i <ARRAY_SIZE (mdp->comp); i++) -mtk_mdp_comp_clock_on (dev, mdp->comp[i]); +list_for_each_entry (comp_node, &mdp->comp_list, node) +mtk_mdp_comp_clock_on (dev, comp_node); }static void mtk_mdp_clock_off (struct mtk_mdp_dev *mdp) {struct device *dev = &mdp->pdev->dev; -int i; +struct mtk_mdp_comp *comp_node; -for (i =0 ; i <ARRAY_SIZE (mdp->comp); i++) -mtk_mdp_comp_clock_off (dev, mdp->comp[i]); +list_for_each_entry (comp_node, &mdp->comp_list, node) +mtk_mdp_comp_clock_off (dev, comp_node); }static void mtk_mdp_wdt_worker (struct work_struct *work)@@ -91,12 +91,25 @@ static void mtk_mdp_reset_handler(void *priv)queue_work (mdp->wdt_wq, &mdp->wdt_work); } +void mtk_mdp_register_component (struct mtk_mdp_dev *mdp, +struct mtk_mdp_comp *comp) +{ +list_add (&mdp->comp_list, &comp->node); +} + +void mtk_mdp_unregister_component (struct mtk_mdp_dev *mdp, +struct mtk_mdp_comp *comp) +{ +list_del (&comp->node); +} +static int mtk_mdp_probe (struct platform_device *pdev) {struct mtk_mdp_dev *mdp;struct device *dev = &pdev->dev;struct device_node *node, *parent; -int i, ret =0 ; +struct mtk_mdp_comp *comp, *comp_temp; +int ret =0 ; mdp =devm_kzalloc (dev,sizeof (*mdp),GFP_KERNEL );if (!mdp)@@ -104,6 +117,7 @@ static int mtk_mdp_probe(struct platform_device *pdev) mdp->id = pdev->id; mdp->pdev = pdev; +INIT_LIST_HEAD (&mdp->comp_list);INIT_LIST_HEAD (&mdp->ctx_list);mutex_init (&mdp->lock);@@ -124,7 +138,6 @@ static int mtk_mdp_probe(struct platform_device *pdev)const struct of_device_id *of_id;enum mtk_mdp_comp_type comp_type;int comp_id; -struct mtk_mdp_comp *comp; of_id =of_match_node (mtk_mdp_comp_dt_ids, node);if (!of_id)@@ -150,13 +163,14 @@ static int mtk_mdp_probe(struct platform_device *pdev)of_node_put (node); goto err_comp; } - mdp->comp[comp_id] = comp; ret =mtk_mdp_comp_init (dev, node, comp, comp_id);if (ret) {of_node_put (node); goto err_comp; } + +mtk_mdp_register_component (mdp, comp); } mdp->job_wq =create_singlethread_workqueue (MTK_MDP_MODULE_NAME );@@ -224,8 +238,10 @@ static int mtk_mdp_probe(struct platform_device *pdev) err_alloc_job_wq: err_comp: -for (i =0 ; i <ARRAY_SIZE (mdp->comp); i++) -mtk_mdp_comp_deinit (dev, mdp->comp[i]); +list_for_each_entry_safe (comp, comp_temp, &mdp->comp_list, node) { +mtk_mdp_unregister_component (mdp, comp); +mtk_mdp_comp_deinit (dev, comp); + }dev_dbg (dev,"err %d\n" , ret);return ret;@@ -234,7 +250,7 @@ static int mtk_mdp_probe(struct platform_device *pdev)static int mtk_mdp_remove (struct platform_device *pdev) {struct mtk_mdp_dev *mdp =platform_get_drvdata (pdev); -int i; +struct mtk_mdp_comp *comp, *comp_temp;pm_runtime_disable (&pdev->dev);vb2_dma_contig_clear_max_seg_size (&pdev->dev);@@ -247,8 +263,10 @@ static int mtk_mdp_remove(struct platform_device *pdev)flush_workqueue (mdp->job_wq);destroy_workqueue (mdp->job_wq); -for (i =0 ; i <ARRAY_SIZE (mdp->comp); i++) -mtk_mdp_comp_deinit (&pdev->dev, mdp->comp[i]); +list_for_each_entry_safe (comp, comp_temp, &mdp->comp_list, node) { +mtk_mdp_unregister_component (mdp, comp); +mtk_mdp_comp_deinit (&pdev->dev, comp); + }dev_dbg (&pdev->dev,"%s driver unloaded\n" , pdev->name);return 0 ;drivers/media/platform/mtk-mdp/mtk_mdp_core.h +8
-3@@ -136,7 +136,7 @@ struct mtk_mdp_variant {* @pdev: pointer to the image processor platform device * @variant: the IP variant information * @id: image processor device index (0..MTK_MDP_MAX_DEVS) -* @comp: MDP function components +* @comp_list: list of MDP function components * @m2m_dev: v4l2 memory-to-memory device data * @ctx_list: list of struct mtk_mdp_ctx * @vdev: video device for image processor driver @@ -154,7 +154,7 @@ struct mtk_mdp_dev {struct platform_device *pdev;struct mtk_mdp_variant *variant;u16 id; -struct mtk_mdp_comp *comp[MTK_MDP_COMP_ID_MAX ]; +struct list_head comp_list;struct v4l2_m2m_dev *m2m_dev;struct list_head ctx_list;struct video_device *vdev;@@ -221,6 +221,12 @@ struct mtk_mdp_ctx {extern int mtk_mdp_dbg_level; +void mtk_mdp_register_component (struct mtk_mdp_dev *mdp, +struct mtk_mdp_comp *comp); + +void mtk_mdp_unregister_component (struct mtk_mdp_dev *mdp, +struct mtk_mdp_comp *comp); +#if defined(DEBUG ) #define mtk_mdp_dbg(level, fmt, args...) \ --2.26.2.526.g744177e7f7-goog
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
PATCH 5/5 mtk-mdp: Remove mtk_mdp_comp.id and supporting functionality
In reply to Eizan MiyamotoSince components are registered in a list, the numeric component id that specified a location in an array is not necessary.
---
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 60 +++---------------- drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 19 +----- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 10 +--- 3 files changed, 11 insertions(+), 78 deletions(-)
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +7 -53
@@ -14,46 +14,6 @@#include "mtk_mdp_comp.h" -static const char *const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX ] = { -"mdp_rdma" , -"mdp_rsz" , -"mdp_wdma" , -"mdp_wrot" , -}; - -struct mtk_mdp_comp_match { -enum mtk_mdp_comp_type type; -int alias_id; -}; - -static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_ID_MAX ] = { - {MTK_MDP_RDMA ,0 }, - {MTK_MDP_RDMA ,1 }, - {MTK_MDP_RSZ ,0 }, - {MTK_MDP_RSZ ,1 }, - {MTK_MDP_RSZ ,2 }, - {MTK_MDP_WDMA ,0 }, - {MTK_MDP_WROT ,0 }, - {MTK_MDP_WROT ,1 }, -}; - -int mtk_mdp_comp_get_id (struct device *dev,struct device_node *node, -enum mtk_mdp_comp_type comp_type) -{ -int id =of_alias_get_id (node, mtk_mdp_comp_stem[comp_type]); -int i; - -for (i =0 ; i <ARRAY_SIZE (mtk_mdp_matches); i++) { -if (comp_type == mtk_mdp_matches[i].type && - id == mtk_mdp_matches[i].alias_id) -return i; - } - -dev_err (dev,"Failed to get id. type: %d, id: %d\n" , comp_type, id); - -return -EINVAL ; -} -void mtk_mdp_comp_clock_on (struct device *dev,struct mtk_mdp_comp *comp) {int i, err;
@@ -62,8 +22,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) err =mtk_smi_larb_get (comp->larb_dev);if (err)dev_err (dev, -"failed to get larb, err %d. type:%d id:%d\n" , - err, comp->type, comp->id); +"failed to get larb, err %d. type:%d\n" , + err, comp->type); }for (i =0 ; i <ARRAY_SIZE (comp->clk); i++) {
@@ -72,8 +32,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) err =clk_prepare_enable (comp->clk[i]);if (err)dev_err (dev, -"failed to enable clock, err %d. type:%d id:%d i:%d\n" , - err, comp->type, comp->id, i); +"failed to enable clock, err %d. type:%d i:%d\n" , + err, comp->type, i); } }
@@ -92,21 +52,15 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) }int mtk_mdp_comp_init (struct device *dev,struct device_node *node, -struct mtk_mdp_comp *comp,enum mtk_mdp_comp_id comp_id) +struct mtk_mdp_comp *comp, +enum mtk_mdp_comp_type comp_type) {struct device_node *larb_node;struct platform_device *larb_pdev;int i; -if (comp_id <0 || comp_id >=MTK_MDP_COMP_ID_MAX ) { -dev_err (dev,"Invalid comp_id %d\n" , comp_id); -return -EINVAL ; - } - -INIT_LIST_HEAD (&comp->node); comp->dev_node =of_node_get (node); - comp->id = comp_id; - comp->type = mtk_mdp_matches[comp_id].type; + comp->type = comp_type;for (i =0 ; i <ARRAY_SIZE (comp->clk); i++) { comp->clk[i] =of_clk_get (node, i);
drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +2 -17
@@ -22,18 +22,6 @@ enum mtk_mdp_comp_type { MTK_MDP_COMP_TYPE_MAX, }; -enum mtk_mdp_comp_id { -MTK_MDP_COMP_RDMA0 , -MTK_MDP_COMP_RDMA1 , -MTK_MDP_COMP_RSZ0 , -MTK_MDP_COMP_RSZ1 , -MTK_MDP_COMP_RSZ2 , -MTK_MDP_COMP_WDMA , -MTK_MDP_COMP_WROT0 , -MTK_MDP_COMP_WROT1 , -MTK_MDP_COMP_ID_MAX , -}; -/** * struct mtk_mdp_comp - the MDP's function component data * @node: list node to track sibing MDP components
@@ -41,7 +29,6 @@ enum mtk_mdp_comp_id {* @clk: clocks required for component * @larb_dev: SMI device required for component * @type: component type -* @id: component ID */ struct mtk_mdp_comp {struct list_head node;
@@ -49,14 +36,12 @@ struct mtk_mdp_comp {struct clk *clk[2 ];struct device *larb_dev;enum mtk_mdp_comp_type type; -enum mtk_mdp_comp_id id; };int mtk_mdp_comp_init (struct device *dev,struct device_node *node, -struct mtk_mdp_comp *comp,enum mtk_mdp_comp_id comp_id); +struct mtk_mdp_comp *comp, +enum mtk_mdp_comp_type comp_type);void mtk_mdp_comp_deinit (struct device *dev,struct mtk_mdp_comp *comp); -int mtk_mdp_comp_get_id (struct device *dev,struct device_node *node, -enum mtk_mdp_comp_type comp_type);void mtk_mdp_comp_clock_on (struct device *dev,struct mtk_mdp_comp *comp);void mtk_mdp_comp_clock_off (struct device *dev,struct mtk_mdp_comp *comp);
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +2 -8
@@ -137,7 +137,6 @@ static int mtk_mdp_probe(struct platform_device *pdev)for_each_child_of_node (parent, node) {const struct of_device_id *of_id;enum mtk_mdp_comp_type comp_type; -int comp_id; of_id =of_match_node (mtk_mdp_comp_dt_ids, node);if (!of_id)
@@ -150,12 +149,7 @@ static int mtk_mdp_probe(struct platform_device *pdev) } comp_type = (enum mtk_mdp_comp_type )of_id->data; - comp_id =mtk_mdp_comp_get_id (dev, node, comp_type); -if (comp_id <0 ) { -dev_warn (dev,"Skipping unknown component %pOF\n" , - node); -continue ; - } + comp =devm_kzalloc (dev,sizeof (*comp),GFP_KERNEL );if (!comp) {
@@ -164,7 +158,7 @@ static int mtk_mdp_probe(struct platform_device *pdev) goto err_comp; } - ret =mtk_mdp_comp_init (dev, node, comp, comp_id); + ret =mtk_mdp_comp_init (dev, node, comp, comp_type);if (ret) {of_node_put (node); goto err_comp;
Signature · 1 line
2.26.2.526.g744177e7f7-goog
Re: [PATCH v1 5/5] [media] mtk-mdp: Remove mtk_mdp_comp.id and supporting functionality
Hi Eizan,
Thank you for your patch.
Missatge de Eizan Miyamoto <[email protected]> del dia dt., 5 de maig 2020 a les 6:02:
Quoted 6 lines
Since components are registered in a list, the numeric component id that specified a location in an array is not necessary.
Signed-off-by [email protected]Signed-off-by Eizan Miyamoto <[email protected]>
Ditto
Quoted 3 lines
---
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 60 +++----------------
This patch will conflict with this one [1]. It is already queued, please rebase on top of it.
Quoted 193 lines
drivers/media/platform/mtk-mdp/mtk_mdp_comp.h | 19 +----- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 10 +--- 3 files changed, 11 insertions(+), 78 deletions(-)drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +7
-53@@ -14,46 +14,6 @@#include "mtk_mdp_comp.h" -static const char *const mtk_mdp_comp_stem[MTK_MDP_COMP_TYPE_MAX ] = { -"mdp_rdma" , -"mdp_rsz" , -"mdp_wdma" , -"mdp_wrot" , -}; - -struct mtk_mdp_comp_match { -enum mtk_mdp_comp_type type; -int alias_id; -}; - -static const struct mtk_mdp_comp_match mtk_mdp_matches[MTK_MDP_COMP_ID_MAX ] = { - {MTK_MDP_RDMA ,0 }, - {MTK_MDP_RDMA ,1 }, - {MTK_MDP_RSZ ,0 }, - {MTK_MDP_RSZ ,1 }, - {MTK_MDP_RSZ ,2 }, - {MTK_MDP_WDMA ,0 }, - {MTK_MDP_WROT ,0 }, - {MTK_MDP_WROT ,1 }, -}; - -int mtk_mdp_comp_get_id (struct device *dev,struct device_node *node, -enum mtk_mdp_comp_type comp_type) -{ -int id =of_alias_get_id (node, mtk_mdp_comp_stem[comp_type]); -int i; - -for (i =0 ; i <ARRAY_SIZE (mtk_mdp_matches); i++) { -if (comp_type == mtk_mdp_matches[i].type && - id == mtk_mdp_matches[i].alias_id) -return i; - } - -dev_err (dev,"Failed to get id. type: %d, id: %d\n" , comp_type, id); - -return -EINVAL ; -} -void mtk_mdp_comp_clock_on (struct device *dev,struct mtk_mdp_comp *comp) {int i, err;@@ -62,8 +22,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) err =mtk_smi_larb_get (comp->larb_dev);if (err)dev_err (dev, -"failed to get larb, err %d. type:%d id:%d\n" , - err, comp->type, comp->id); +"failed to get larb, err %d. type:%d\n" , + err, comp->type); }for (i =0 ; i <ARRAY_SIZE (comp->clk); i++) {@@ -72,8 +32,8 @@ void mtk_mdp_comp_clock_on(struct device *dev, struct mtk_mdp_comp *comp) err =clk_prepare_enable (comp->clk[i]);if (err)dev_err (dev, -"failed to enable clock, err %d. type:%d id:%d i:%d\n" , - err, comp->type, comp->id, i); +"failed to enable clock, err %d. type:%d i:%d\n" , + err, comp->type, i); } }@@ -92,21 +52,15 @@ void mtk_mdp_comp_clock_off(struct device *dev, struct mtk_mdp_comp *comp) }int mtk_mdp_comp_init (struct device *dev,struct device_node *node, -struct mtk_mdp_comp *comp,enum mtk_mdp_comp_id comp_id) +struct mtk_mdp_comp *comp, +enum mtk_mdp_comp_type comp_type) {struct device_node *larb_node;struct platform_device *larb_pdev;int i; -if (comp_id <0 || comp_id >=MTK_MDP_COMP_ID_MAX ) { -dev_err (dev,"Invalid comp_id %d\n" , comp_id); -return -EINVAL ; - } - -INIT_LIST_HEAD (&comp->node); comp->dev_node =of_node_get (node); - comp->id = comp_id; - comp->type = mtk_mdp_matches[comp_id].type; + comp->type = comp_type;for (i =0 ; i <ARRAY_SIZE (comp->clk); i++) { comp->clk[i] =of_clk_get (node, i);drivers/media/platform/mtk-mdp/mtk_mdp_comp.h +2
-17@@ -22,18 +22,6 @@ enum mtk_mdp_comp_type { MTK_MDP_COMP_TYPE_MAX, }; -enum mtk_mdp_comp_id { -MTK_MDP_COMP_RDMA0 , -MTK_MDP_COMP_RDMA1 , -MTK_MDP_COMP_RSZ0 , -MTK_MDP_COMP_RSZ1 , -MTK_MDP_COMP_RSZ2 , -MTK_MDP_COMP_WDMA , -MTK_MDP_COMP_WROT0 , -MTK_MDP_COMP_WROT1 , -MTK_MDP_COMP_ID_MAX , -}; -/** * struct mtk_mdp_comp - the MDP's function component data * @node: list node to track sibing MDP components @@ -41,7 +29,6 @@ enum mtk_mdp_comp_id {* @clk: clocks required for component * @larb_dev: SMI device required for component * @type: component type -* @id: component ID */ struct mtk_mdp_comp {struct list_head node;@@ -49,14 +36,12 @@ struct mtk_mdp_comp {struct clk *clk[2 ];struct device *larb_dev;enum mtk_mdp_comp_type type; -enum mtk_mdp_comp_id id; };int mtk_mdp_comp_init (struct device *dev,struct device_node *node, -struct mtk_mdp_comp *comp,enum mtk_mdp_comp_id comp_id); +struct mtk_mdp_comp *comp, +enum mtk_mdp_comp_type comp_type);void mtk_mdp_comp_deinit (struct device *dev,struct mtk_mdp_comp *comp); -int mtk_mdp_comp_get_id (struct device *dev,struct device_node *node, -enum mtk_mdp_comp_type comp_type);void mtk_mdp_comp_clock_on (struct device *dev,struct mtk_mdp_comp *comp);void mtk_mdp_comp_clock_off (struct device *dev,struct mtk_mdp_comp *comp);drivers/media/platform/mtk-mdp/mtk_mdp_core.c +2
-9@@ -137,7 +137,6 @@ static int mtk_mdp_probe(struct platform_device *pdev)for_each_child_of_node (parent, node) {const struct of_device_id *of_id;enum mtk_mdp_comp_type comp_type; -int comp_id; of_id =of_match_node (mtk_mdp_comp_dt_ids, node);if (!of_id)@@ -150,12 +149,7 @@ static int mtk_mdp_probe(struct platform_device *pdev) } comp_type = (enum mtk_mdp_comp_type )of_id->data; - comp_id =mtk_mdp_comp_get_id (dev, node, comp_type); -if (comp_id <0 ) { -dev_warn (dev,"Skipping unknown component %pOF\n" , - node); -continue ; - } + comp =devm_kzalloc (dev,sizeof (*comp),GFP_KERNEL );if (!comp) {@@ -164,7 +158,7 @@ static int mtk_mdp_probe(struct platform_device *pdev) goto err_comp; } - ret =mtk_mdp_comp_init (dev, node, comp, comp_id); + ret =mtk_mdp_comp_init (dev, node, comp, comp_type);if (ret) {of_node_put (node); goto err_comp; --2.26.2.526.g744177e7f7-goog
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek