drm: Kirin driver cleanups to prep for Kirin960 support
Subsystems (3)
v5 cover drm: Kirin driver cleanups to prep for Kirin960 support
Sending this out again (apologies!), to address a few issues Sam found.
This patchset contains one fix (in the front, so its easier to eventually backport), and a series of changes from YiPing to refactor the kirin drm driver so that it can be used on both kirin620 based devices (like the original HiKey board) as well as kirin960 based devices (like the HiKey960 board).
The full kirin960 drm support is still being refactored, but as this base kirin rework was getting to be substantial, I wanted to send out the first chunk, so that the review burden wasn't overwhelming.
The full HiKey960 patch stack can be found here:
https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/hikey960-mainline-WIP
thanks
-john
New in v5:
* Whitespace changes and few logic simplifications to get checkpatch.pl --strict to pass, as noted by Sam
* Fix for one of my patches which broke building the kirin driver as a module. Again noted by Sam.
Da Lv (1):
drm: kirin: Fix for hikey620 display offset problem
John Stultz (3):
drm: kirin: Remove HISI_KIRIN_DW_DSI config option
drm: kirin: Remove unreachable return
drm: kirin: Move workqueue to ade_hw_ctx structure
Xu YiPing (21):
drm: kirin: Remove uncessary parameter indirection
drm: kirin: Remove out_format from ade_crtc
drm: kirin: Rename ade_plane to kirin_plane
drm: kirin: Rename ade_crtc to kirin_crtc
drm: kirin: Dynamically allocate the hw_ctx
drm: kirin: Move request irq handle in ade hw ctx alloc
drm: kirin: Move kirin_crtc, kirin_plane, kirin_format to
kirin_drm_drv.h
drm: kirin: Reanme dc_ops to kirin_drm_data
drm: kirin: Move ade crtc/plane help functions to driver_data
drm: kirin: Move channel formats to driver data
drm: kirin: Move mode config function to driver_data
drm: kirin: Move plane number and primay plane in driver data
drm: kirin: Move config max_width and max_height to driver data
drm: kirin: Move drm driver to driver data
drm: kirin: Add register connect helper functions in drm init
drm: kirin: Rename plane_init and crtc_init
drm: kirin: Fix dev->driver_data setting
drm: kirin: Make driver_data variable non-global
drm: kirin: Add alloc_hw_ctx/clean_hw_ctx ops in driver data
drm: kirin: Pass driver data to crtc init and plane init
drm: kirin: Move ade drm init to kirin drm drv
drivers/gpu/drm/hisilicon/kirin/Kconfig | 10 +- drivers/gpu/drm/hisilicon/kirin/Makefile | 3 +- .../gpu/drm/hisilicon/kirin/kirin_ade_reg.h | 1 + .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 351 +++++++----------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 250 +++++++++---- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 48 ++- 6 files changed, 367 insertions(+), 296 deletions(-)
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 1/25 drm: kirin: Fix for hikey620 display offset problem
From: Da Lv <[email protected]>
The original HiKey (620) board has had a long running issue where when using a 1080p montior, the display would occasionally blink and come come back with a horizontal offset (usually also shifting the colors, depending on the value of the offset%4).
After lots of analysis by HiSi developers, they found the issue was due to when running at 1080p, it was possible to hit the device memory bandwidth limits, which could cause the DSI signal to get out of sync.
Unfortunately the DSI logic doesn't have the ability to automatically recover from this situation, but we can get a an LDI underflow interrupt when it happens.
To then correct the issue, when we get an LDI underflow irq, we we can simply suspend and resume the display, which resets the hardware.
Thus, this patch enables the ldi underflow interrupt, and initializes a workqueue that is used to suspend/resume the display to recover. Then when the irq occurs we clear it and schedule the workqueue to reset display engine.
---
v2: Minor cleanups
v3: Rename workqueue entry for clarity (suggested by Sam)
--- .../gpu/drm/hisilicon/kirin/kirin_ade_reg.h | 1 + .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+)
drivers/gpu/drm/hisilicon/kirin/kirin_ade_reg.h +1 -0
@@ -83,6 +83,7 @@#define VSIZE_OFST 20#define LDI_INT_EN 0x741C#define FRAME_END_INT_EN_OFST 1 +#define UNDERFLOW_INT_EN_OFST 2#define LDI_CTRL 0x7420#define BPP_OFST 3#define DATA_GATE_EN BIT(2)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +22 -0
@@ -58,6 +58,7 @@ struct ade_hw_ctx {struct ade_crtc {struct drm_crtc base;struct ade_hw_ctx *ctx; +struct work_struct display_reset_wq;bool enable;u32 out_format; };
@@ -176,6 +177,7 @@ static void ade_init(struct ade_hw_ctx *ctx)*/ ade_update_bits (base +ADE_CTRL ,FRM_END_START_OFST ,FRM_END_START_MASK ,REG_EFFECTIVE_IN_ADEEN_FRMEND ); +ade_update_bits (base +LDI_INT_EN ,UNDERFLOW_INT_EN_OFST ,MASK (1 ),1 ); } static bool ade_crtc_mode_fixup(struct drm_crtc *crtc,
@@ -345,6 +347,17 @@ static void ade_crtc_disable_vblank(struct drm_crtc *crtc) MASK(1), 0); } +static void drm_underflow_wq (struct work_struct *work) +{ + struct ade_crtc *acrtc = container_of(work, struct ade_crtc, + display_reset_wq); +struct drm_device *drm_dev = (&acrtc->base)->dev; +struct drm_atomic_state *state; + + state =drm_atomic_helper_suspend (drm_dev); +drm_atomic_helper_resume (drm_dev, state); +} +static irqreturn_t ade_irq_handler (int irq,void *data) {struct ade_crtc *acrtc = data;
@@ -362,6 +375,12 @@ static irqreturn_t ade_irq_handler(int irq, void *data) MASK(1), 1);drm_crtc_handle_vblank (crtc); } +if (status &BIT (UNDERFLOW_INT_EN_OFST )) { +ade_update_bits (base +LDI_INT_CLR ,UNDERFLOW_INT_EN_OFST , +MASK (1 ),1 ); +DRM_ERROR ("LDI underflow!" ); +schedule_work (&acrtc->display_reset_wq); + }return IRQ_HANDLED ; }
@@ -1038,6 +1057,9 @@ static int ade_drm_init(struct platform_device *pdev)/* vblank irq init */ ret =devm_request_irq (dev->dev, ctx->irq, ade_irq_handler,IRQF_SHARED , dev->driver->name, acrtc); + +INIT_WORK (&acrtc->display_reset_wq, drm_underflow_wq); +if (ret)return ret;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 2/25 drm: kirin: Remove HISI_KIRIN_DW_DSI config option
In reply to John StultzThe CONFIG_HISI_KIRIN_DW_DSI option is only used w/ kirin driver, so cut out the middleman and condense the config logic down.
---
v5: Build fixup for module config noticed by Sam
--- drivers/gpu/drm/hisilicon/kirin/Kconfig | 10 +--------- drivers/gpu/drm/hisilicon/kirin/Makefile | 3 +-- 2 files changed, 2 insertions(+), 11 deletions(-)
drivers/gpu/drm/hisilicon/kirin/Kconfig +1 -9
@@ -5,16 +5,8 @@ config DRM_HISI_KIRIN select DRM_KMS_HELPER select DRM_GEM_CMA_HELPER select DRM_KMS_CMA_HELPER - select HISI_KIRIN_DW_DSI + select DRM_MIPI_DSI help Choose this option if you have a hisilicon Kirin chipsets(hi6220). If M is selected the module will be called kirin-drm. -config HISI_KIRIN_DW_DSI - tristate "HiSilicon Kirin specific extensions for Synopsys DW MIPI DSI" - depends on DRM_HISI_KIRIN - select DRM_MIPI_DSI - help - This selects support for HiSilicon Kirin SoC specific extensions for - the Synopsys DesignWare DSI driver. If you want to enable MIPI DSI on - hi6220 based SoC, you should selet this option.
drivers/gpu/drm/hisilicon/kirin/Makefile +1 -2
@@ -2,6 +2,5 @@ kirin-drm-y := kirin_drm_drv.o \ kirin_drm_ade.o -obj-$(CONFIG_DRM_HISI_KIRIN) += kirin-drm.o +obj-$(CONFIG_DRM_HISI_KIRIN) += kirin-drm.o dw_drm_dsi.o -obj-$(CONFIG_HISI_KIRIN_DW_DSI) += dw_drm_dsi.o
Signature · 1 line
2.17.1
PATCH v5 3/25 drm: kirin: Remove unreachable return
In reply to John StultzThe 'return 0' in kirin_drm_platform_probe() is unreachable code, so remove it.
Suggested by: Xu YiPing <[email protected]>
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +0 -2
@@ -208,8 +208,6 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)of_node_put (remote);return component_master_add_with_match (dev, &kirin_drm_ops, match); - -return 0 ; }static int kirin_drm_platform_remove (struct platform_device *pdev)
Signature · 1 line
2.17.1
PATCH v5 4/25 drm: kirin: Remove uncessary parameter indirection
In reply to John StultzFrom: Xu YiPing <[email protected]>
In a few functions, we pass in a struct ade_crtc, which we only use to get to the underlying struct ade_hw_ctx.
Thus this patch refactors the functions to just take the struct ade_hw_ctx directly.
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +5 -7
@@ -210,11 +210,10 @@ static void ade_set_pix_clk(struct ade_hw_ctx *ctx, adj_mode->clock =clk_get_rate (ctx->ade_pix_clk) /1000 ; } -static void ade_ldi_set_mode (struct ade_crtc *acrtc, +static void ade_ldi_set_mode (struct ade_hw_ctx *ctx,struct drm_display_mode *mode,struct drm_display_mode *adj_mode) { -struct ade_hw_ctx *ctx = acrtc->ctx;void __iomem *base = ctx->base;u32 width = mode->hdisplay;u32 height = mode->vdisplay;
@@ -301,9 +300,8 @@ static void ade_power_down(struct ade_hw_ctx *ctx) ctx->power_on = false; } -static void ade_set_medianoc_qos (struct ade_crtc *acrtc) +static void ade_set_medianoc_qos (struct ade_hw_ctx *ctx) { -struct ade_hw_ctx *ctx = acrtc->ctx;struct regmap *map = ctx->noc_regmap; regmap_update_bits(map, ADE0_QOSGENERATOR_MODE,
@@ -515,7 +513,7 @@ static void ade_crtc_atomic_enable(struct drm_crtc *crtc,return ; } -ade_set_medianoc_qos (acrtc); +ade_set_medianoc_qos (ctx);ade_display_enable (acrtc);ade_dump_regs (ctx->base);drm_crtc_vblank_on (crtc);
@@ -545,7 +543,7 @@ static void ade_crtc_mode_set_nofb(struct drm_crtc *crtc)if (!ctx->power_on) (void )ade_power_up (ctx); -ade_ldi_set_mode (acrtc, mode, adj_mode); +ade_ldi_set_mode (ctx, mode, adj_mode); } static void ade_crtc_atomic_begin(struct drm_crtc *crtc,
@@ -558,7 +556,7 @@ static void ade_crtc_atomic_begin(struct drm_crtc *crtc,if (!ctx->power_on) (void )ade_power_up (ctx); -ade_ldi_set_mode (acrtc, mode, adj_mode); +ade_ldi_set_mode (ctx, mode, adj_mode); } static void ade_crtc_atomic_flush(struct drm_crtc *crtc,
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 5/25 drm: kirin: Remove out_format from ade_crtc
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch removes the out_format field in the struct ade_crtc, which was only ever set to LDI_OUT_RGB_888.
Thus this patch removes the field and instead directly uses LDI_OUT_RGB_888.
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +3 -6
@@ -60,7 +60,6 @@ struct ade_crtc {struct ade_hw_ctx *ctx;struct work_struct display_reset_wq;bool enable; -u32 out_format; };struct ade_plane {
@@ -383,11 +382,10 @@ static irqreturn_t ade_irq_handler(int irq, void *data)return IRQ_HANDLED ; } -static void ade_display_enable (struct ade_crtc *acrtc) +static void ade_display_enable (struct ade_hw_ctx *ctx) { -struct ade_hw_ctx *ctx = acrtc->ctx;void __iomem *base = ctx->base; -u32 out_fmt = acrtc->out_format; +u32 out_fmt =LDI_OUT_RGB_888 ;/* enable output overlay compositor */ writel (ADE_ENABLE , base +ADE_OVLYX_CTL (OUT_OVLY ));
@@ -514,7 +512,7 @@ static void ade_crtc_atomic_enable(struct drm_crtc *crtc, }ade_set_medianoc_qos (ctx); -ade_display_enable (acrtc); +ade_display_enable (ctx);ade_dump_regs (ctx->base);drm_crtc_vblank_on (crtc); acrtc->enable = true;
@@ -1024,7 +1022,6 @@ static int ade_drm_init(struct platform_device *pdev) ctx = &ade->ctx; acrtc = &ade->acrtc; acrtc->ctx = ctx; - acrtc->out_format =LDI_OUT_RGB_888 ; ret =ade_dts_parse (pdev, ctx);if (ret)
Signature · 1 line
2.17.1
PATCH v5 6/25 drm: kirin: Rename ade_plane to kirin_plane
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch renames the struct ade_plane to kirin_plane.
The struct kirin_plane will later used by both kirin620 and future kirin960 driver, and will be moved to a common kirin_drm_drv.h in a future patch
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +29 -28
@@ -41,8 +41,9 @@#define to_ade_crtc (crtc) \ container_of(crtc, struct ade_crtc, base) -#define to_ade_plane (plane) \ - container_of(plane, struct ade_plane, base) +#define to_kirin_plane (plane) \ + container_of(plane, struct kirin_plane, base) +struct ade_hw_ctx {void __iomem *base;
@@ -62,15 +63,15 @@ struct ade_crtc {bool enable; }; -struct ade_plane { +struct kirin_plane {struct drm_plane base; -void *ctx; -u8 ch;/* channel */ +void *hw_ctx; +u32 ch; };struct ade_data {struct ade_crtc acrtc; -struct ade_plane aplane[ADE_CH_NUM ]; +struct kirin_plane planes[ADE_CH_NUM ];struct ade_hw_ctx ctx; };
@@ -795,16 +796,16 @@ static void ade_compositor_routing_disable(void __iomem *base, u32 ch)/* * Typicaly, a channel looks like: DMA-->clip-->scale-->ctrans-->compositor */ -static void ade_update_channel (struct ade_plane *aplane, +static void ade_update_channel (struct kirin_plane *kplane,struct drm_framebuffer *fb,int crtc_x,int crtc_y,unsigned int crtc_w,unsigned int crtc_h,u32 src_x,u32 src_y,u32 src_w,u32 src_h) { -struct ade_hw_ctx *ctx = aplane->ctx; +struct ade_hw_ctx *ctx = kplane->hw_ctx;void __iomem *base = ctx->base;u32 fmt =ade_get_format (fb->format->format); -u32 ch = aplane->ch; +u32 ch = kplane->ch;u32 in_w;u32 in_h;
@@ -828,11 +829,11 @@ static void ade_update_channel(struct ade_plane *aplane,ade_compositor_routing_set (base, ch, crtc_x, crtc_y, in_w, in_h, fmt); } -static void ade_disable_channel (struct ade_plane *aplane) +static void ade_disable_channel (struct kirin_plane *kplane) { -struct ade_hw_ctx *ctx = aplane->ctx; +struct ade_hw_ctx *ctx = kplane->hw_ctx;void __iomem *base = ctx->base; -u32 ch = aplane->ch; +u32 ch = kplane->ch;DRM_DEBUG_DRIVER ("disable channel%d\n" , ch +1 );
@@ -894,10 +895,10 @@ static int ade_plane_atomic_check(struct drm_plane *plane,static void ade_plane_atomic_update (struct drm_plane *plane,struct drm_plane_state *old_state) { -struct drm_plane_state *state = plane->state; -struct ade_plane *aplane =to_ade_plane (plane); +struct drm_plane_state *state = plane->state; +struct kirin_plane *kplane =to_kirin_plane (plane); -ade_update_channel (aplane, state->fb, state->crtc_x, state->crtc_y, +ade_update_channel (kplane, state->fb, state->crtc_x, state->crtc_y, state->crtc_w, state->crtc_h, state->src_x >>16 , state->src_y >>16 , state->src_w >>16 , state->src_h >>16 );
@@ -906,9 +907,9 @@ static void ade_plane_atomic_update(struct drm_plane *plane,static void ade_plane_atomic_disable (struct drm_plane *plane,struct drm_plane_state *old_state) { -struct ade_plane *aplane =to_ade_plane (plane); +struct kirin_plane *kplane =to_kirin_plane (plane); -ade_disable_channel (aplane); +ade_disable_channel (kplane); }static const struct drm_plane_helper_funcs ade_plane_helper_funcs = {
@@ -926,7 +927,7 @@ static struct drm_plane_funcs ade_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; -static int ade_plane_init (struct drm_device *dev,struct ade_plane *aplane, +static int ade_plane_init (struct drm_device *dev,struct kirin_plane *kplane,enum drm_plane_type type) {const u32 *fmts;
@@ -934,18 +935,18 @@ static int ade_plane_init(struct drm_device *dev, struct ade_plane *aplane,int ret =0 ;/* get properties */ - fmts_cnt =ade_get_channel_formats (aplane->ch, &fmts); + fmts_cnt =ade_get_channel_formats (kplane->ch, &fmts);if (ret)return ret; - ret =drm_universal_plane_init (dev, &aplane->base,1 , &ade_plane_funcs, + ret =drm_universal_plane_init (dev, &kplane->base,1 , &ade_plane_funcs, fmts, fmts_cnt,NULL , type,NULL );if (ret) { -DRM_ERROR ("fail to init plane, ch=%d\n" , aplane->ch); +DRM_ERROR ("fail to init plane, ch=%d\n" , kplane->ch);return ret; } -drm_plane_helper_add (&aplane->base, &ade_plane_helper_funcs); +drm_plane_helper_add (&kplane->base, &ade_plane_helper_funcs);return 0 ; }
@@ -1007,7 +1008,7 @@ static int ade_drm_init(struct platform_device *pdev)struct ade_data *ade;struct ade_hw_ctx *ctx;struct ade_crtc *acrtc; -struct ade_plane *aplane; +struct kirin_plane *kplane;enum drm_plane_type type;int ret;int i;
@@ -1033,19 +1034,19 @@ static int ade_drm_init(struct platform_device *pdev)* need to do. */ for (i =0 ; i <ADE_CH_NUM ; i++) { - aplane = &ade->aplane[i]; - aplane->ch = i; - aplane->ctx = ctx; + kplane = &ade->planes[i]; + kplane->ch = i; + kplane->hw_ctx = ctx; type = i ==PRIMARY_CH ?DRM_PLANE_TYPE_PRIMARY :DRM_PLANE_TYPE_OVERLAY ; - ret =ade_plane_init (dev, aplane, type); + ret =ade_plane_init (dev, kplane, type);if (ret)return ret; }/* crtc init */ - ret =ade_crtc_init (dev, &acrtc->base, &ade->aplane[PRIMARY_CH ].base); + ret =ade_crtc_init (dev, &acrtc->base, &ade->planes[PRIMARY_CH ].base);if (ret)return ret;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 7/25 drm: kirin: Rename ade_crtc to kirin_crtc
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch renames the struct ade_crtc to kirin_crtc.
The struct kirin_crtc will later used by both kirin620 and future kirin960 driver, and will be moved to a common kirin_drm_drv.h in a future patch
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +37 -37
@@ -38,8 +38,8 @@#define OUT_OVLY ADE_OVLY2/* output overlay compositor */ #define ADE_DEBUG 1 -#define to_ade_crtc (crtc) \ - container_of(crtc, struct ade_crtc, base) +#define to_kirin_crtc (crtc) \ + container_of(crtc, struct kirin_crtc, base)#define to_kirin_plane (plane) \ container_of(plane, struct kirin_plane, base)
@@ -56,9 +56,9 @@ struct ade_hw_ctx {int irq; }; -struct ade_crtc { +struct kirin_crtc {struct drm_crtc base; -struct ade_hw_ctx *ctx; +void *hw_ctx;struct work_struct display_reset_wq;bool enable; };
@@ -70,7 +70,7 @@ struct kirin_plane { };struct ade_data { -struct ade_crtc acrtc; +struct kirin_crtc crtc;struct kirin_plane planes[ADE_CH_NUM ];struct ade_hw_ctx ctx; };
@@ -184,8 +184,8 @@ static bool ade_crtc_mode_fixup(struct drm_crtc *crtc,const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { - struct ade_crtc *acrtc = to_ade_crtc(crtc); -struct ade_hw_ctx *ctx = acrtc->ctx; + struct kirin_crtc *kcrtc = to_kirin_crtc(crtc); +struct ade_hw_ctx *ctx = kcrtc->hw_ctx; adjusted_mode->clock =clk_round_rate (ctx->ade_pix_clk, mode->clock *1000 ) /1000 ;
@@ -317,8 +317,8 @@ static void ade_set_medianoc_qos(struct ade_hw_ctx *ctx)static int ade_crtc_enable_vblank (struct drm_crtc *crtc) { -struct ade_crtc *acrtc =to_ade_crtc (crtc); -struct ade_hw_ctx *ctx = acrtc->ctx; +struct kirin_crtc *kcrtc =to_kirin_crtc (crtc); +struct ade_hw_ctx *ctx = kcrtc->hw_ctx;void __iomem *base = ctx->base;if (!ctx->power_on)
@@ -332,8 +332,8 @@ static int ade_crtc_enable_vblank(struct drm_crtc *crtc)static void ade_crtc_disable_vblank (struct drm_crtc *crtc) { -struct ade_crtc *acrtc =to_ade_crtc (crtc); -struct ade_hw_ctx *ctx = acrtc->ctx; +struct kirin_crtc *kcrtc =to_kirin_crtc (crtc); +struct ade_hw_ctx *ctx = kcrtc->hw_ctx;void __iomem *base = ctx->base;if (!ctx->power_on) {
@@ -347,7 +347,7 @@ static void ade_crtc_disable_vblank(struct drm_crtc *crtc)static void drm_underflow_wq (struct work_struct *work) { - struct ade_crtc *acrtc = container_of(work, struct ade_crtc, + struct kirin_crtc *acrtc = container_of(work, struct kirin_crtc, display_reset_wq);struct drm_device *drm_dev = (&acrtc->base)->dev;struct drm_atomic_state *state;
@@ -358,9 +358,9 @@ static void drm_underflow_wq(struct work_struct *work)static irqreturn_t ade_irq_handler (int irq,void *data) { -struct ade_crtc *acrtc = data; -struct ade_hw_ctx *ctx = acrtc->ctx; -struct drm_crtc *crtc = &acrtc->base; +struct kirin_crtc *kcrtc = data; +struct ade_hw_ctx *ctx = kcrtc->hw_ctx; +struct drm_crtc *crtc = &kcrtc->base;void __iomem *base = ctx->base;u32 status;
@@ -377,7 +377,7 @@ static irqreturn_t ade_irq_handler(int irq, void *data)ade_update_bits (base +LDI_INT_CLR ,UNDERFLOW_INT_EN_OFST ,MASK (1 ),1 );DRM_ERROR ("LDI underflow!" ); -schedule_work (&acrtc->display_reset_wq); +schedule_work (&kcrtc->display_reset_wq); }return IRQ_HANDLED ;
@@ -499,11 +499,11 @@ static void ade_dump_regs(void __iomem *base) { }static void ade_crtc_atomic_enable (struct drm_crtc *crtc,struct drm_crtc_state *old_state) { -struct ade_crtc *acrtc =to_ade_crtc (crtc); -struct ade_hw_ctx *ctx = acrtc->ctx; +struct kirin_crtc *kcrtc =to_kirin_crtc (crtc); +struct ade_hw_ctx *ctx = kcrtc->hw_ctx;int ret; -if (acrtc->enable) +if (kcrtc->enable)return ;if (!ctx->power_on) {
@@ -516,27 +516,27 @@ static void ade_crtc_atomic_enable(struct drm_crtc *crtc,ade_display_enable (ctx);ade_dump_regs (ctx->base);drm_crtc_vblank_on (crtc); - acrtc->enable = true; + kcrtc->enable = true; }static void ade_crtc_atomic_disable (struct drm_crtc *crtc,struct drm_crtc_state *old_state) { -struct ade_crtc *acrtc =to_ade_crtc (crtc); -struct ade_hw_ctx *ctx = acrtc->ctx; +struct kirin_crtc *kcrtc =to_kirin_crtc (crtc); +struct ade_hw_ctx *ctx = kcrtc->hw_ctx; -if (!acrtc->enable) +if (!kcrtc->enable)return ;drm_crtc_vblank_off (crtc);ade_power_down (ctx); - acrtc->enable = false; + kcrtc->enable = false; }static void ade_crtc_mode_set_nofb (struct drm_crtc *crtc) { -struct ade_crtc *acrtc =to_ade_crtc (crtc); -struct ade_hw_ctx *ctx = acrtc->ctx; +struct kirin_crtc *kcrtc =to_kirin_crtc (crtc); +struct ade_hw_ctx *ctx = kcrtc->hw_ctx;struct drm_display_mode *mode = &crtc->state->mode;struct drm_display_mode *adj_mode = &crtc->state->adjusted_mode;
@@ -548,8 +548,8 @@ static void ade_crtc_mode_set_nofb(struct drm_crtc *crtc)static void ade_crtc_atomic_begin (struct drm_crtc *crtc,struct drm_crtc_state *old_state) { -struct ade_crtc *acrtc =to_ade_crtc (crtc); -struct ade_hw_ctx *ctx = acrtc->ctx; +struct kirin_crtc *kcrtc =to_kirin_crtc (crtc); +struct ade_hw_ctx *ctx = kcrtc->hw_ctx;struct drm_display_mode *mode = &crtc->state->mode;struct drm_display_mode *adj_mode = &crtc->state->adjusted_mode;
@@ -562,13 +562,13 @@ static void ade_crtc_atomic_flush(struct drm_crtc *crtc, struct drm_crtc_state *old_state) { -struct ade_crtc *acrtc =to_ade_crtc (crtc); -struct ade_hw_ctx *ctx = acrtc->ctx; +struct kirin_crtc *kcrtc =to_kirin_crtc (crtc); +struct ade_hw_ctx *ctx = kcrtc->hw_ctx;struct drm_pending_vblank_event *event = crtc->state->event;void __iomem *base = ctx->base;/* only crtc is enabled regs take effect */ -if (acrtc->enable) { +if (kcrtc->enable) {ade_dump_regs (base);/* flush ade registers */ writel (ADE_ENABLE , base +ADE_EN );
@@ -1007,7 +1007,7 @@ static int ade_drm_init(struct platform_device *pdev)struct drm_device *dev =platform_get_drvdata (pdev);struct ade_data *ade;struct ade_hw_ctx *ctx; -struct ade_crtc *acrtc; +struct kirin_crtc *kcrtc;struct kirin_plane *kplane;enum drm_plane_type type;int ret;
@@ -1021,8 +1021,8 @@ static int ade_drm_init(struct platform_device *pdev)platform_set_drvdata (pdev, ade); ctx = &ade->ctx; - acrtc = &ade->acrtc; - acrtc->ctx = ctx; + kcrtc = &ade->crtc; + kcrtc->hw_ctx = ctx; ret =ade_dts_parse (pdev, ctx);if (ret)
@@ -1046,15 +1046,15 @@ static int ade_drm_init(struct platform_device *pdev) }/* crtc init */ - ret =ade_crtc_init (dev, &acrtc->base, &ade->planes[PRIMARY_CH ].base); + ret =ade_crtc_init (dev, &kcrtc->base, &ade->planes[PRIMARY_CH ].base);if (ret)return ret;/* vblank irq init */ ret =devm_request_irq (dev->dev, ctx->irq, ade_irq_handler, -IRQF_SHARED , dev->driver->name, acrtc); +IRQF_SHARED , dev->driver->name, kcrtc); -INIT_WORK (&acrtc->display_reset_wq, drm_underflow_wq); +INIT_WORK (&kcrtc->display_reset_wq, drm_underflow_wq);if (ret)return ret;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 8/25 drm: kirin: Dynamically allocate the hw_ctx
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch modifies the initialization function to dynamically allocate the ade_hw_ctx structure previously kept as part of struct ade_data.
This is done so that later we can have the hw_ctx point to hardware revision specific ctx structures.
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +24 -15
@@ -72,7 +72,7 @@ struct kirin_plane {struct ade_data {struct kirin_crtc crtc;struct kirin_plane planes[ADE_CH_NUM ]; -struct ade_hw_ctx ctx; +struct ade_hw_ctx *hw_ctx; };/* ade-format info: */
@@ -951,55 +951,62 @@ static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane,return 0 ; } -static int ade_dts_parse (struct platform_device *pdev,struct ade_hw_ctx *ctx) +static void *ade_hw_ctx_alloc (struct platform_device *pdev) {struct resource *res;struct device *dev = &pdev->dev;struct device_node *np = pdev->dev.of_node; +struct ade_hw_ctx *ctx =NULL ; + + ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL ); +if (!ctx) { +DRM_ERROR ("failed to alloc ade_hw_ctx\n" ); +return ERR_PTR (-ENOMEM ); + } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); ctx->base =devm_ioremap_resource (dev, res);if (IS_ERR (ctx->base)) {DRM_ERROR ("failed to remap ade io base\n" ); -return PTR_ERR (ctx->base); +return ERR_PTR (-EIO ); } ctx->reset =devm_reset_control_get (dev,NULL );if (IS_ERR (ctx->reset)) -return PTR_ERR (ctx->reset); +return ERR_PTR (-ENODEV ); ctx->noc_regmap =syscon_regmap_lookup_by_phandle (np,"hisilicon,noc-syscon" );if (IS_ERR (ctx->noc_regmap)) {DRM_ERROR ("failed to get noc regmap\n" ); -return PTR_ERR (ctx->noc_regmap); +return ERR_PTR (-ENODEV ); } ctx->irq =platform_get_irq (pdev,0 );if (ctx->irq <0 ) {DRM_ERROR ("failed to get irq\n" ); -return -ENODEV ; +return ERR_PTR (-ENODEV ); } ctx->ade_core_clk =devm_clk_get (dev,"clk_ade_core" );if (IS_ERR (ctx->ade_core_clk)) {DRM_ERROR ("failed to parse clk ADE_CORE\n" ); -return PTR_ERR (ctx->ade_core_clk); +return ERR_PTR (-ENODEV ); } ctx->media_noc_clk =devm_clk_get (dev,"clk_codec_jpeg" );if (IS_ERR (ctx->media_noc_clk)) {DRM_ERROR ("failed to parse clk CODEC_JPEG\n" ); -return PTR_ERR (ctx->media_noc_clk); +return ERR_PTR (-ENODEV ); } ctx->ade_pix_clk =devm_clk_get (dev,"clk_ade_pix" );if (IS_ERR (ctx->ade_pix_clk)) {DRM_ERROR ("failed to parse clk ADE_PIX\n" ); -return PTR_ERR (ctx->ade_pix_clk); +return ERR_PTR (-ENODEV ); } -return 0 ; +return ctx; }static int ade_drm_init (struct platform_device *pdev)
@@ -1020,14 +1027,16 @@ static int ade_drm_init(struct platform_device *pdev) }platform_set_drvdata (pdev, ade); - ctx = &ade->ctx; + ctx =ade_hw_ctx_alloc (pdev); +if (IS_ERR (ctx)) { +DRM_ERROR ("failed to initialize kirin_priv hw ctx\n" ); +return -EINVAL ; + } + ade->hw_ctx = ctx; + kcrtc = &ade->crtc; kcrtc->hw_ctx = ctx; - ret =ade_dts_parse (pdev, ctx); -if (ret) -return ret; -/* * plane init * TODO: Now only support primary plane, overlay planes
Signature · 1 line
2.17.1
PATCH v5 9/25 drm: kirin: Move request irq handle in ade hw ctx alloc
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch modifies the initialization routines so the devm_request_irq() function is called as part of the allocation function.
This will be needed in the future when we will have different allocation functions to allocate hardware specific hw_ctx structures, which will setup the vblank irq differently.
---
v5: checkpatch --strict whitespace fixups noticed by Sam
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +17 -12
@@ -54,6 +54,8 @@ struct ade_hw_ctx {struct reset_control *reset;bool power_on;int irq; + +struct drm_crtc *crtc; };struct kirin_crtc {
@@ -358,9 +360,9 @@ static void drm_underflow_wq(struct work_struct *work)static irqreturn_t ade_irq_handler (int irq,void *data) { -struct kirin_crtc *kcrtc = data; -struct ade_hw_ctx *ctx = kcrtc->hw_ctx; -struct drm_crtc *crtc = &kcrtc->base; +struct ade_hw_ctx *ctx = data; +struct drm_crtc *crtc = ctx->crtc; +struct kirin_crtc *kcrtc =to_kirin_crtc (crtc);void __iomem *base = ctx->base;u32 status;
@@ -951,12 +953,14 @@ static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane,return 0 ; } -static void *ade_hw_ctx_alloc (struct platform_device *pdev) +static void *ade_hw_ctx_alloc (struct platform_device *pdev, +struct drm_crtc *crtc) {struct resource *res;struct device *dev = &pdev->dev;struct device_node *np = pdev->dev.of_node;struct ade_hw_ctx *ctx =NULL ; +int ret; ctx =devm_kzalloc (dev,sizeof (*ctx),GFP_KERNEL );if (!ctx) {
@@ -1006,6 +1010,14 @@ static void *ade_hw_ctx_alloc(struct platform_device *pdev)return ERR_PTR (-ENODEV ); } +/* vblank irq init */ + ret =devm_request_irq (dev, ctx->irq, ade_irq_handler, +IRQF_SHARED , dev->driver->name, ctx); +if (ret) +return ERR_PTR (-EIO ); + + ctx->crtc = crtc; +return ctx; }
@@ -1027,7 +1039,7 @@ static int ade_drm_init(struct platform_device *pdev) }platform_set_drvdata (pdev, ade); - ctx =ade_hw_ctx_alloc (pdev); + ctx =ade_hw_ctx_alloc (pdev, &ade->crtc.base);if (IS_ERR (ctx)) {DRM_ERROR ("failed to initialize kirin_priv hw ctx\n" );return -EINVAL ;
@@ -1059,15 +1071,8 @@ static int ade_drm_init(struct platform_device *pdev)if (ret)return ret; -/* vblank irq init */ - ret =devm_request_irq (dev->dev, ctx->irq, ade_irq_handler, -IRQF_SHARED , dev->driver->name, kcrtc); -INIT_WORK (&kcrtc->display_reset_wq, drm_underflow_wq); -if (ret) -return ret; -return 0 ; }
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 10/25 drm: kirin: Move workqueue to ade_hw_ctx structure
In reply to John StultzThe workqueue used to reset the display when we hit an LDI underflow error is ADE specific, so since this patch series works to make the kirin_crtc structure more generic, move the workqueue to the ade_hw_ctx structure instead.
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +5 -7
@@ -52,6 +52,7 @@ struct ade_hw_ctx {struct clk *media_noc_clk;struct clk *ade_pix_clk;struct reset_control *reset; +struct work_struct display_reset_wq;bool power_on;int irq;
@@ -61,7 +62,6 @@ struct ade_hw_ctx {struct kirin_crtc {struct drm_crtc base;void *hw_ctx; -struct work_struct display_reset_wq;bool enable; };
@@ -349,9 +349,9 @@ static void ade_crtc_disable_vblank(struct drm_crtc *crtc)static void drm_underflow_wq (struct work_struct *work) { - struct kirin_crtc *acrtc = container_of(work, struct kirin_crtc, + struct ade_hw_ctx *ctx = container_of(work, struct ade_hw_ctx, display_reset_wq); -struct drm_device *drm_dev = (&acrtc->base)->dev; +struct drm_device *drm_dev = ctx->crtc->dev;struct drm_atomic_state *state; state =drm_atomic_helper_suspend (drm_dev);
@@ -362,7 +362,6 @@ static irqreturn_t ade_irq_handler(int irq, void *data) {struct ade_hw_ctx *ctx = data;struct drm_crtc *crtc = ctx->crtc; -struct kirin_crtc *kcrtc =to_kirin_crtc (crtc);void __iomem *base = ctx->base;u32 status;
@@ -379,7 +378,7 @@ static irqreturn_t ade_irq_handler(int irq, void *data)ade_update_bits (base +LDI_INT_CLR ,UNDERFLOW_INT_EN_OFST ,MASK (1 ),1 );DRM_ERROR ("LDI underflow!" ); -schedule_work (&kcrtc->display_reset_wq); +schedule_work (&ctx->display_reset_wq); }return IRQ_HANDLED ;
@@ -1016,6 +1015,7 @@ static void *ade_hw_ctx_alloc(struct platform_device *pdev,if (ret)return ERR_PTR (-EIO ); +INIT_WORK (&ctx->display_reset_wq, drm_underflow_wq); ctx->crtc = crtc;return ctx;
@@ -1071,8 +1071,6 @@ static int ade_drm_init(struct platform_device *pdev)if (ret)return ret; -INIT_WORK (&kcrtc->display_reset_wq, drm_underflow_wq); -return 0 ; }
Signature · 1 line
2.17.1
PATCH v5 11/25 drm: kirin: Move kirin_crtc, kirin_plane, kirin_format to kirin_drm_drv.h
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch moves some shared structures and helpers to the common kirin_drm_drv.h
These structures will later used by both kirin620 and future kirin960 driver
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 27 ++----------------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 24 +++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +2 -25
@@ -38,12 +38,6 @@#define OUT_OVLY ADE_OVLY2/* output overlay compositor */ #define ADE_DEBUG 1 -#define to_kirin_crtc (crtc) \ - container_of(crtc, struct kirin_crtc, base) - -#define to_kirin_plane (plane) \ - container_of(plane, struct kirin_plane, base) -struct ade_hw_ctx {void __iomem *base;
@@ -59,18 +53,6 @@ struct ade_hw_ctx {struct drm_crtc *crtc; }; -struct kirin_crtc { -struct drm_crtc base; -void *hw_ctx; -bool enable; -}; - -struct kirin_plane { -struct drm_plane base; -void *hw_ctx; -u32 ch; -}; -struct ade_data {struct kirin_crtc crtc;struct kirin_plane planes[ADE_CH_NUM ];
@@ -78,12 +60,7 @@ struct ade_data { };/* ade-format info: */ -struct ade_format { -u32 pixel_format; -enum ade_fb_format ade_format; -}; - -static const struct ade_format ade_formats[] = { +static const struct kirin_format ade_formats[] = {/* 16bpp RGB: */ {DRM_FORMAT_RGB565 ,ADE_RGB_565 }, {DRM_FORMAT_BGR565 ,ADE_BGR_565 },
@@ -127,7 +104,7 @@ static u32 ade_get_format(u32 pixel_format)for (i =0 ; i <ARRAY_SIZE (ade_formats); i++)if (ade_formats[i].pixel_format == pixel_format) -return ade_formats[i].ade_format; +return ade_formats[i].hw_format;/* not found */ DRM_ERROR("Not found pixel format!!fourcc_format= %d\n",
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +24 -0
@@ -9,6 +9,30 @@#define MAX_CRTC 2 +#define to_kirin_crtc (crtc) \ + container_of(crtc, struct kirin_crtc, base) + +#define to_kirin_plane (plane) \ + container_of(plane, struct kirin_plane, base) + +/* kirin-format translate table */ +struct kirin_format { +u32 pixel_format; +u32 hw_format; +}; + +struct kirin_crtc { +struct drm_crtc base; +void *hw_ctx; +bool enable; +}; + +struct kirin_plane { +struct drm_plane base; +void *hw_ctx; +u32 ch; +}; +/* display controller init/cleanup ops */ struct kirin_dc_ops {int (*init)(struct platform_device *pdev);
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 12/25 drm: kirin: Reanme dc_ops to kirin_drm_data
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch renames the struct kirin_dc_ops to struct kirin_drm_data and cleans up the related variable names.
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 2 +- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 16 ++++++++-------- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +1 -1
@@ -1055,7 +1055,7 @@ static void ade_drm_cleanup(struct platform_device *pdev) { } -const struct kirin_dc_ops ade_dc_ops = { +struct kirin_drm_data ade_driver_data = { .init = ade_drm_init, .cleanup = ade_drm_cleanup };
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +8 -8
@@ -29,12 +29,12 @@#include "kirin_drm_drv.h" -static struct kirin_dc_ops *dc_ops; +static struct kirin_drm_data *driver_data;static int kirin_drm_kms_cleanup (struct drm_device *dev) {drm_kms_helper_poll_fini (dev); - dc_ops->cleanup (to_platform_device (dev->dev)); + driver_data->cleanup (to_platform_device (dev->dev));drm_mode_config_cleanup (dev);return 0 ;
@@ -68,7 +68,7 @@ static int kirin_drm_kms_init(struct drm_device *dev)kirin_drm_mode_config_init (dev);/* display controller init */ - ret = dc_ops->init (to_platform_device (dev->dev)); + ret = driver_data->init (to_platform_device (dev->dev));if (ret) goto err_mode_config_cleanup;
@@ -99,7 +99,7 @@ static int kirin_drm_kms_init(struct drm_device *dev) err_unbind_all:component_unbind_all (dev->dev, dev); err_dc_cleanup: - dc_ops->cleanup (to_platform_device (dev->dev)); + driver_data->cleanup (to_platform_device (dev->dev)); err_mode_config_cleanup:drm_mode_config_cleanup (dev);
@@ -194,8 +194,8 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)struct component_match *match =NULL ;struct device_node *remote; - dc_ops = (struct kirin_dc_ops *)of_device_get_match_data (dev); -if (!dc_ops) { + driver_data = (struct kirin_drm_data *)of_device_get_match_data (dev); +if (!driver_data) {DRM_ERROR ("failed to get dt id data\n" );return -EINVAL ; }
@@ -213,13 +213,13 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)static int kirin_drm_platform_remove (struct platform_device *pdev) {component_master_del (&pdev->dev, &kirin_drm_ops); - dc_ops =NULL ; + driver_data =NULL ;return 0 ; }static const struct of_device_id kirin_drm_dt_ids[] = { { .compatible ="hisilicon,hi6220-ade" , - .data = &ade_dc_ops, + .data = &ade_driver_data, }, {/* end node */ }, };
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +2 -2
@@ -34,11 +34,11 @@ struct kirin_plane { };/* display controller init/cleanup ops */ -struct kirin_dc_ops { +struct kirin_drm_data {int (*init)(struct platform_device *pdev);void (*cleanup)(struct platform_device *pdev); }; -extern const struct kirin_dc_ops ade_dc_ops; +extern struct kirin_drm_data ade_driver_data;#endif /* __KIRIN_DRM_DRV_H__ */
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 13/25 drm: kirin: Move ade crtc/plane help functions to driver_data
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the crtc and plane funcs/helper_funcs to the struct kirin_drm_data.
This will make it easier to add support for new devices via a new kirin_drm_data structure.
---
v5: checkpatch --strict whitespace fixups noticed by Sam
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 15 ++++++++++----- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 5 +++++ 2 files changed, 15 insertions(+), 5 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +10 -5
@@ -602,13 +602,13 @@ static int ade_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, crtc->port = port; ret =drm_crtc_init_with_planes (dev, crtc, plane,NULL , - &ade_crtc_funcs,NULL ); + ade_driver_data.crtc_funcs,NULL );if (ret) {DRM_ERROR ("failed to init crtc.\n" );return ret; } -drm_crtc_helper_add (crtc, &ade_crtc_helper_funcs); +drm_crtc_helper_add (crtc, ade_driver_data.crtc_helper_funcs);return 0 ; }
@@ -917,14 +917,15 @@ static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane,if (ret)return ret; - ret =drm_universal_plane_init (dev, &kplane->base,1 , &ade_plane_funcs, - fmts, fmts_cnt,NULL , type,NULL ); + ret =drm_universal_plane_init (dev, &kplane->base,1 , + ade_driver_data.plane_funcs, fmts, + fmts_cnt,NULL , type,NULL );if (ret) {DRM_ERROR ("fail to init plane, ch=%d\n" , kplane->ch);return ret; } -drm_plane_helper_add (&kplane->base, &ade_plane_helper_funcs); +drm_plane_helper_add (&kplane->base, ade_driver_data.plane_helper_funcs);return 0 ; }
@@ -1056,6 +1057,10 @@ static void ade_drm_cleanup(struct platform_device *pdev) }struct kirin_drm_data ade_driver_data = { + .crtc_helper_funcs = &ade_crtc_helper_funcs, + .crtc_funcs = &ade_crtc_funcs, + .plane_helper_funcs = &ade_plane_helper_funcs, + .plane_funcs = &ade_plane_funcs, .init = ade_drm_init, .cleanup = ade_drm_cleanup };
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +5 -0
@@ -35,6 +35,11 @@ struct kirin_plane {/* display controller init/cleanup ops */ struct kirin_drm_data { +const struct drm_crtc_helper_funcs *crtc_helper_funcs; +const struct drm_crtc_funcs *crtc_funcs; +const struct drm_plane_helper_funcs *plane_helper_funcs; +const struct drm_plane_funcs *plane_funcs; +int (*init)(struct platform_device *pdev);void (*cleanup)(struct platform_device *pdev); };
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 14/25 drm: kirin: Move channel formats to driver data
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the channel format arrays into the kirin_drm_data structure.
This will make it easier to add support for new devices via a new kirin_drm_data structure.
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 30 +++++-------------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 3 ++ 2 files changed, 10 insertions(+), 23 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +7 -23
@@ -76,7 +76,7 @@ static const struct kirin_format ade_formats[] = { { DRM_FORMAT_ABGR8888, ADE_ABGR_8888 }, }; -static const u32 channel_formats1[] = { +static const u32 channel_formats[] = {/* channel 1,2,3,4 */ DRM_FORMAT_RGB565 ,DRM_FORMAT_BGR565 ,DRM_FORMAT_RGB888 , DRM_FORMAT_BGR888, DRM_FORMAT_XRGB8888, DRM_FORMAT_XBGR8888,
@@ -84,19 +84,6 @@ static const u32 channel_formats1[] = { DRM_FORMAT_ABGR8888 }; -u32 ade_get_channel_formats (u8 ch,const u32 **formats) -{ -switch (ch) { -case ADE_CH1 : - *formats = channel_formats1; -return ARRAY_SIZE (channel_formats1); -default : -DRM_ERROR ("no this channel %d\n" , ch); - *formats =NULL ; -return 0 ; - } -} -/* convert from fourcc format to ade format */ static u32 ade_get_format (u32 pixel_format) {
@@ -908,18 +895,13 @@ static struct drm_plane_funcs ade_plane_funcs = {static int ade_plane_init (struct drm_device *dev,struct kirin_plane *kplane,enum drm_plane_type type) { -const u32 *fmts; -u32 fmts_cnt;int ret =0 ; -/* get properties */ - fmts_cnt =ade_get_channel_formats (kplane->ch, &fmts); -if (ret) -return ret; - ret =drm_universal_plane_init (dev, &kplane->base,1 , - ade_driver_data.plane_funcs, fmts, - fmts_cnt,NULL , type,NULL ); + ade_driver_data.plane_funcs, + ade_driver_data.channel_formats, + ade_driver_data.channel_formats_cnt, +NULL , type,NULL );if (ret) {DRM_ERROR ("fail to init plane, ch=%d\n" , kplane->ch);return ret;
@@ -1057,6 +1039,8 @@ static void ade_drm_cleanup(struct platform_device *pdev) }struct kirin_drm_data ade_driver_data = { + .channel_formats = channel_formats, + .channel_formats_cnt =ARRAY_SIZE (channel_formats), .crtc_helper_funcs = &ade_crtc_helper_funcs, .crtc_funcs = &ade_crtc_funcs, .plane_helper_funcs = &ade_plane_helper_funcs,
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +3 -0
@@ -35,6 +35,9 @@ struct kirin_plane {/* display controller init/cleanup ops */ struct kirin_drm_data { +const u32 *channel_formats; +u32 channel_formats_cnt; +const struct drm_crtc_helper_funcs *crtc_helper_funcs;const struct drm_crtc_funcs *crtc_funcs;const struct drm_plane_helper_funcs *plane_helper_funcs;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 15/25 drm: kirin: Move mode config function to driver_data
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the mode config initialization values into the kirin_drm_data structure.
This will make it easier to add support for new devices via a new kirin_drm_data structure.
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 10 ++++++++++ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 8 +------- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +10 -0
@@ -30,6 +30,7 @@#include <drm/drm_plane_helper.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h> +#include <drm/drm_gem_framebuffer_helper.h> #include "kirin_drm_drv.h" #include "kirin_ade_reg.h"
@@ -1038,6 +1039,13 @@ static void ade_drm_cleanup(struct platform_device *pdev) { } +static const struct drm_mode_config_funcs ade_mode_config_funcs = { + .fb_create = drm_gem_fb_create, + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, + +}; +struct kirin_drm_data ade_driver_data = { .channel_formats = channel_formats, .channel_formats_cnt =ARRAY_SIZE (channel_formats),
@@ -1045,6 +1053,8 @@ struct kirin_drm_data ade_driver_data = { .crtc_funcs = &ade_crtc_funcs, .plane_helper_funcs = &ade_plane_helper_funcs, .plane_funcs = &ade_plane_funcs, + .mode_config_funcs = &ade_mode_config_funcs, + .init = ade_drm_init, .cleanup = ade_drm_cleanup };
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +1 -7
@@ -40,12 +40,6 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev)return 0 ; } -static const struct drm_mode_config_funcs kirin_drm_mode_config_funcs = { - .fb_create = drm_gem_fb_create, - .atomic_check = drm_atomic_helper_check, - .atomic_commit = drm_atomic_helper_commit, -}; -static void kirin_drm_mode_config_init (struct drm_device *dev) { dev->mode_config.min_width =0 ;
@@ -54,7 +48,7 @@ static void kirin_drm_mode_config_init(struct drm_device *dev) dev->mode_config.max_width =2048 ; dev->mode_config.max_height =2048 ; - dev->mode_config.funcs = &kirin_drm_mode_config_funcs; + dev->mode_config.funcs = driver_data->mode_config_funcs; }static int kirin_drm_kms_init (struct drm_device *dev)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +1 -1
@@ -42,7 +42,7 @@ struct kirin_drm_data {const struct drm_crtc_funcs *crtc_funcs;const struct drm_plane_helper_funcs *plane_helper_funcs;const struct drm_plane_funcs *plane_funcs; - +const struct drm_mode_config_funcs *mode_config_funcs;int (*init)(struct platform_device *pdev);void (*cleanup)(struct platform_device *pdev); };
Signature · 1 line
2.17.1
PATCH v5 16/25 drm: kirin: Move plane number and primay plane in driver data
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the number of planes and the primary plane value to the kirin_drm_data structure
This will make it easier to add support for new devices via a new kirin_drm_data structure.
---
v5: checkpatch --strict whitespace fixups noticed by Sam
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 21 ++++++++++++------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +13 -8
@@ -35,7 +35,6 @@#include "kirin_drm_drv.h" #include "kirin_ade_reg.h" -#define PRIMARY_CH ADE_CH1/* primary plane */ #define OUT_OVLY ADE_OVLY2/* output overlay compositor */ #define ADE_DEBUG 1
@@ -991,7 +990,7 @@ static int ade_drm_init(struct platform_device *pdev)struct kirin_plane *kplane;enum drm_plane_type type;int ret; -int i; +u32 ch; ade =devm_kzalloc (dev->dev,sizeof (*ade),GFP_KERNEL );if (!ade) {
@@ -1015,12 +1014,15 @@ static int ade_drm_init(struct platform_device *pdev)* TODO: Now only support primary plane, overlay planes * need to do. */ -for (i =0 ; i <ADE_CH_NUM ; i++) { - kplane = &ade->planes[i]; - kplane->ch = i; +for (ch =0 ; ch < ade_driver_data.num_planes; ch++) { + kplane = &ade->planes[ch]; + kplane->ch = ch; kplane->hw_ctx = ctx; - type = i ==PRIMARY_CH ?DRM_PLANE_TYPE_PRIMARY : -DRM_PLANE_TYPE_OVERLAY ; + +if (ch == ade_driver_data.prim_plane) + type =DRM_PLANE_TYPE_PRIMARY ; +else + type =DRM_PLANE_TYPE_OVERLAY ; ret =ade_plane_init (dev, kplane, type);if (ret)
@@ -1028,7 +1030,8 @@ static int ade_drm_init(struct platform_device *pdev) }/* crtc init */ - ret =ade_crtc_init (dev, &kcrtc->base, &ade->planes[PRIMARY_CH ].base); + ret =ade_crtc_init (dev, &kcrtc->base, + &ade->planes[ade_driver_data.prim_plane].base);if (ret)return ret;
@@ -1047,6 +1050,8 @@ static const struct drm_mode_config_funcs ade_mode_config_funcs = { };struct kirin_drm_data ade_driver_data = { + .num_planes =ADE_CH_NUM , + .prim_plane =ADE_CH1 , .channel_formats = channel_formats, .channel_formats_cnt =ARRAY_SIZE (channel_formats), .crtc_helper_funcs = &ade_crtc_helper_funcs,
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +2 -0
@@ -37,6 +37,8 @@ struct kirin_plane {struct kirin_drm_data {const u32 *channel_formats;u32 channel_formats_cnt; +u32 num_planes; +u32 prim_plane;const struct drm_crtc_helper_funcs *crtc_helper_funcs;const struct drm_crtc_funcs *crtc_funcs;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 17/25 drm: kirin: Move config max_width and max_height to driver data
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the max_width and max_height values used in kirin_drm_mode_config_inita to hardware specific driver data.
This will make it easier to add support for new devices via a new kirin_drm_data structure.
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 2 ++ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 17 +++++------------ drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 2 ++ 3 files changed, 9 insertions(+), 12 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +2 -0
@@ -1054,6 +1054,8 @@ struct kirin_drm_data ade_driver_data = { .prim_plane = ADE_CH1, .channel_formats = channel_formats, .channel_formats_cnt = ARRAY_SIZE(channel_formats), + .config_max_width = 2048, + .config_max_height = 2048, .crtc_helper_funcs = &ade_crtc_helper_funcs, .crtc_funcs = &ade_crtc_funcs, .plane_helper_funcs = &ade_plane_helper_funcs,
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +5 -12
@@ -40,17 +40,6 @@ static int kirin_drm_kms_cleanup(struct drm_device *dev)return 0 ; } -static void kirin_drm_mode_config_init (struct drm_device *dev) -{ - dev->mode_config.min_width =0 ; - dev->mode_config.min_height =0 ; - - dev->mode_config.max_width =2048 ; - dev->mode_config.max_height =2048 ; - - dev->mode_config.funcs = driver_data->mode_config_funcs; -} -static int kirin_drm_kms_init (struct drm_device *dev) {int ret;
@@ -59,7 +48,11 @@ static int kirin_drm_kms_init(struct drm_device *dev)/* dev->mode_config initialization */ drm_mode_config_init (dev); -kirin_drm_mode_config_init (dev); + dev->mode_config.min_width =0 ; + dev->mode_config.min_height =0 ; + dev->mode_config.max_width = driver_data->config_max_width; + dev->mode_config.max_height = driver_data->config_max_width; + dev->mode_config.funcs = driver_data->mode_config_funcs;/* display controller init */ ret = driver_data->init (to_platform_device (dev->dev));
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +2 -0
@@ -37,6 +37,8 @@ struct kirin_plane {struct kirin_drm_data {const u32 *channel_formats;u32 channel_formats_cnt; +int config_max_width; +int config_max_height;u32 num_planes;u32 prim_plane;
Signature · 1 line
2.17.1
PATCH v5 18/25 drm: kirin: Move drm driver to driver data
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the drm_driver structure to be under device specific driver data.
This will allow us to more easily add support for kirin960 hardware with later patches.
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 24 +++++++++++++ .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 35 +------------------ .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 1 + 3 files changed, 26 insertions(+), 34 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +24 -0
@@ -1049,6 +1049,29 @@ static const struct drm_mode_config_funcs ade_mode_config_funcs = { }; +DEFINE_DRM_GEM_CMA_FOPS (ade_fops); + +static struct drm_driver ade_driver = { + .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_ATOMIC , + .fops = &ade_fops, + .gem_free_object_unlocked = drm_gem_cma_free_object, + .gem_vm_ops = &drm_gem_cma_vm_ops, + .dumb_create = drm_gem_cma_dumb_create_internal, + .prime_handle_to_fd = drm_gem_prime_handle_to_fd, + .prime_fd_to_handle = drm_gem_prime_fd_to_handle, + .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, + .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, + .gem_prime_vmap = drm_gem_cma_prime_vmap, + .gem_prime_vunmap = drm_gem_cma_prime_vunmap, + .gem_prime_mmap = drm_gem_cma_prime_mmap, + + .name ="kirin" , + .desc ="Hisilicon Kirin620 SoC DRM Driver" , + .date ="20150718" , + .major =1 , + .minor =0 , +}; +struct kirin_drm_data ade_driver_data = { .num_planes =ADE_CH_NUM , .prim_plane =ADE_CH1 ,
@@ -1056,6 +1079,7 @@ struct kirin_drm_data ade_driver_data = { .channel_formats_cnt = ARRAY_SIZE(channel_formats), .config_max_width = 2048, .config_max_height = 2048, + .driver = &ade_driver, .crtc_helper_funcs = &ade_crtc_helper_funcs, .crtc_funcs = &ade_crtc_funcs, .plane_helper_funcs = &ade_plane_helper_funcs,
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +1 -34
@@ -93,38 +93,6 @@ static int kirin_drm_kms_init(struct drm_device *dev)return ret; } -DEFINE_DRM_GEM_CMA_FOPS (kirin_drm_fops); - -static int kirin_gem_cma_dumb_create (struct drm_file *file, -struct drm_device *dev, -struct drm_mode_create_dumb *args) -{ -return drm_gem_cma_dumb_create_internal (file, dev, args); -} - -static struct drm_driver kirin_drm_driver = { - .driver_features =DRIVER_GEM |DRIVER_MODESET |DRIVER_ATOMIC , - .fops = &kirin_drm_fops, - - .gem_free_object_unlocked = drm_gem_cma_free_object, - .gem_vm_ops = &drm_gem_cma_vm_ops, - .dumb_create = kirin_gem_cma_dumb_create, - - .prime_handle_to_fd = drm_gem_prime_handle_to_fd, - .prime_fd_to_handle = drm_gem_prime_fd_to_handle, - .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, - .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table, - .gem_prime_vmap = drm_gem_cma_prime_vmap, - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, - .gem_prime_mmap = drm_gem_cma_prime_mmap, - - .name ="kirin" , - .desc ="Hisilicon Kirin SoCs' DRM Driver" , - .date ="20150718" , - .major =1 , - .minor =0 , -}; -static int compare_of (struct device *dev,void *data) {return dev->of_node == data;
@@ -132,11 +100,10 @@ static int compare_of(struct device *dev, void *data)static int kirin_drm_bind (struct device *dev) { -struct drm_driver *driver = &kirin_drm_driver;struct drm_device *drm_dev;int ret; - drm_dev =drm_dev_alloc (driver, dev); + drm_dev =drm_dev_alloc (driver_data->driver, dev);if (IS_ERR (drm_dev))return PTR_ERR (drm_dev);
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +1 -0
@@ -42,6 +42,7 @@ struct kirin_drm_data {u32 num_planes;u32 prim_plane; +struct drm_driver *driver;const struct drm_crtc_helper_funcs *crtc_helper_funcs;const struct drm_crtc_funcs *crtc_funcs;const struct drm_plane_helper_funcs *plane_helper_funcs;
Signature · 1 line
2.17.1
PATCH v5 19/25 drm: kirin: Add register connect helper functions in drm init
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch adds a flag to the device specific driver data so that we can conditionally register the connectors at init.
---
v5: checkpatch --strict whitespace fixups noticed by Sam
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 + .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 43 +++++++++++++++++++ .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 1 + 3 files changed, 45 insertions(+)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +1 -0
@@ -1073,6 +1073,7 @@ static struct drm_driver ade_driver = { };struct kirin_drm_data ade_driver_data = { + .register_connects = false, .num_planes =ADE_CH_NUM , .prim_plane =ADE_CH1 , .channel_formats = channel_formats,
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +43 -0
57 lines not on this page · raw message
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +1 -0
@@ -39,6 +39,7 @@ struct kirin_drm_data {u32 channel_formats_cnt;int config_max_width;int config_max_height; +bool register_connects;u32 num_planes;u32 prim_plane;
Signature · 6 lines
2.17.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 19/25] drm: kirin: Add register connect helper functions in drm init
Quoted 8 lines · John Stultz
From: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch adds a flag to the device specific driver data so that we can conditionally register the connectors at init.
Quoted 11 lines
Cc Rongrong Zou <[email protected]>Cc Xinliang Liu <[email protected]>Cc David Airlie <[email protected]>Cc Daniel Vetter <[email protected]>Cc dri-devel <[email protected]>Cc Sam Ravnborg <[email protected]>Acked-by Xinliang Liu <[email protected]>Reviewed-by Sam Ravnborg <[email protected]>Signed-off-by Xu YiPing <[email protected]>[jstultz: reworded commit message]Signed-off-by John Stultz <[email protected]>
Whatever it is you're doing, this is nonsense. drm_dev_register does register connectors for you. If you hotplug connectors later on, you have to register them (manually), but definitely that should happen in the hotplug code. General rule: If it's not a hotplugged dp mst connector, calling drm_connector_register from drivers is pointless (and yes I know there's tons of that stuff around, for historical reasons).
Further the flag isn't even set, so this is just dead code.
Please revert.
Thanks, Daniel
Quoted 98 lines
---
v5: checkpatch --strict whitespace fixups noticed by Sam--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 + .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 43 +++++++++++++++++++ .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 1 + 3 files changed, 45 insertions(+)drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +1
-0@@ -1073,6 +1073,7 @@ static struct drm_driver ade_driver = { };struct kirin_drm_data ade_driver_data = { + .register_connects = false, .num_planes =ADE_CH_NUM , .prim_plane =ADE_CH1 , .channel_formats = channel_formats,drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +43
-0@@ -98,6 +98,40 @@ static int compare_of(struct device *dev, void *data)return dev->of_node == data; } +static int kirin_drm_connectors_register (struct drm_device *dev) +{ +struct drm_connector *connector; +struct drm_connector *failed_connector; +struct drm_connector_list_iter conn_iter; +int ret; + +mutex_lock (&dev->mode_config.mutex); +drm_connector_list_iter_begin (dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { + ret =drm_connector_register (connector); +if (ret) { + failed_connector = connector; + goto err; + } + } +drm_connector_list_iter_end (&conn_iter); +mutex_unlock (&dev->mode_config.mutex); + +return 0 ; + +err: +drm_connector_list_iter_begin (dev, &conn_iter); +drm_for_each_connector_iter (connector, &conn_iter) { +if (failed_connector == connector) +break ; +drm_connector_unregister (connector); + } +drm_connector_list_iter_end (&conn_iter); +mutex_unlock (&dev->mode_config.mutex); + +return ret; +} +static int kirin_drm_bind (struct device *dev) {struct drm_device *drm_dev;@@ -117,8 +151,17 @@ static int kirin_drm_bind(struct device *dev)drm_fbdev_generic_setup (drm_dev,32 ); +/* connectors should be registered after drm device register */ +if (driver_data->register_connects) { + ret =kirin_drm_connectors_register (drm_dev); +if (ret) + goto err_drm_dev_unregister; + } +return 0 ; +err_drm_dev_unregister: +drm_dev_unregister (drm_dev); err_kms_cleanup:kirin_drm_kms_cleanup (drm_dev); err_drm_dev_put:drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +1
-1@@ -39,6 +39,7 @@ struct kirin_drm_data {u32 channel_formats_cnt;int config_max_width;int config_max_height; +bool register_connects;u32 num_planes;u32 prim_plane; --2.17.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v5 20/25 drm: kirin: Rename plane_init and crtc_init
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch renames ade_crtc/plane_init kirin_plane/crtc_init, as they will later be moved to kirin drm drv and shared with the kirin960 hardware support.
---
v5: checkpatch --strict whitespace fixups noticed by Sam
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +10 -7
@@ -571,8 +571,8 @@ static const struct drm_crtc_funcs ade_crtc_funcs = { .disable_vblank = ade_crtc_disable_vblank, }; -static int ade_crtc_init (struct drm_device *dev,struct drm_crtc *crtc, -struct drm_plane *plane) +static int kirin_drm_crtc_init (struct drm_device *dev,struct drm_crtc *crtc, +struct drm_plane *plane) {struct device_node *port;int ret;
@@ -892,8 +892,9 @@ static struct drm_plane_funcs ade_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; -static int ade_plane_init (struct drm_device *dev,struct kirin_plane *kplane, -enum drm_plane_type type) +static int kirin_drm_plane_init (struct drm_device *dev, +struct kirin_plane *kplane, +enum drm_plane_type type) {int ret =0 ;
@@ -989,6 +990,7 @@ static int ade_drm_init(struct platform_device *pdev)struct kirin_crtc *kcrtc;struct kirin_plane *kplane;enum drm_plane_type type; +int prim_plane;int ret;u32 ch;
@@ -1024,14 +1026,15 @@ static int ade_drm_init(struct platform_device *pdev)else type =DRM_PLANE_TYPE_OVERLAY ; - ret =ade_plane_init (dev, kplane, type); + ret =kirin_drm_plane_init (dev, kplane, type);if (ret)return ret; }/* crtc init */ - ret =ade_crtc_init (dev, &kcrtc->base, - &ade->planes[ade_driver_data.prim_plane].base); + prim_plane = ade_driver_data.prim_plane; + ret =kirin_drm_crtc_init (dev, &kcrtc->base, + &ade->planes[prim_plane].base);if (ret)return ret;
Signature · 1 line
2.17.1
PATCH v5 21/25 drm: kirin: Fix dev->driver_data setting
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch changes the dev->driver_data to point to a drm_device, not ade_data.
Thus we set the driver data to drm device after alloc.
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 - drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +0 -1
@@ -999,7 +999,6 @@ static int ade_drm_init(struct platform_device *pdev)DRM_ERROR ("failed to alloc ade_data\n" );return -ENOMEM ; } -platform_set_drvdata (pdev, ade); ctx =ade_hw_ctx_alloc (pdev, &ade->crtc.base);if (IS_ERR (ctx)) {
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +1 -2
@@ -44,8 +44,6 @@ static int kirin_drm_kms_init(struct drm_device *dev) {int ret; -dev_set_drvdata (dev->dev, dev); -/* dev->mode_config initialization */ drm_mode_config_init (dev); dev->mode_config.min_width =0 ;
@@ -140,6 +138,7 @@ static int kirin_drm_bind(struct device *dev) drm_dev =drm_dev_alloc (driver_data->driver, dev);if (IS_ERR (drm_dev))return PTR_ERR (drm_dev); +dev_set_drvdata (dev, drm_dev); ret =kirin_drm_kms_init (drm_dev);if (ret)
Signature · 1 line
2.17.1
PATCH v5 22/25 drm: kirin: Make driver_data variable non-global
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch changes the driver_data value to not be a global variable. Instead the driver_data value is accessed via the of_device_get_match_data() when needed.
---
v5: checkpatch --strict whitespace fixups noticed by Sam
--- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +24 -19
@@ -29,18 +29,9 @@#include "kirin_drm_drv.h" -static struct kirin_drm_data *driver_data; -static int kirin_drm_kms_cleanup (struct drm_device *dev) -{ -drm_kms_helper_poll_fini (dev); - driver_data->cleanup (to_platform_device (dev->dev)); -drm_mode_config_cleanup (dev); - -return 0 ; -} - -static int kirin_drm_kms_init (struct drm_device *dev) +static int kirin_drm_kms_init (struct drm_device *dev, +const struct kirin_drm_data *driver_data) {int ret;
@@ -96,6 +87,21 @@ static int compare_of(struct device *dev, void *data)return dev->of_node == data; } +static int kirin_drm_kms_cleanup (struct drm_device *dev) +{ +const struct kirin_drm_data *driver_data; + +drm_kms_helper_poll_fini (dev); + + driver_data =of_device_get_match_data (dev->dev); +if (driver_data->cleanup) + driver_data->cleanup (to_platform_device (dev->dev)); + +drm_mode_config_cleanup (dev); + +return 0 ; +} +static int kirin_drm_connectors_register (struct drm_device *dev) {struct drm_connector *connector;
@@ -132,15 +138,21 @@ static int kirin_drm_connectors_register(struct drm_device *dev)static int kirin_drm_bind (struct device *dev) { +struct kirin_drm_data *driver_data;struct drm_device *drm_dev;int ret; + driver_data = (struct kirin_drm_data *)of_device_get_match_data (dev); +if (!driver_data) +return -EINVAL ; + drm_dev =drm_dev_alloc (driver_data->driver, dev);if (IS_ERR (drm_dev))return PTR_ERR (drm_dev);dev_set_drvdata (dev, drm_dev); - ret =kirin_drm_kms_init (drm_dev); +/* display controller init */ + ret =kirin_drm_kms_init (drm_dev, driver_data);if (ret) goto err_drm_dev_put;
@@ -190,12 +202,6 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)struct component_match *match =NULL ;struct device_node *remote; - driver_data = (struct kirin_drm_data *)of_device_get_match_data (dev); -if (!driver_data) { -DRM_ERROR ("failed to get dt id data\n" ); -return -EINVAL ; - } - remote =of_graph_get_remote_node (np,0 ,0 );if (!remote)return -ENODEV ;
@@ -209,7 +215,6 @@ static int kirin_drm_platform_probe(struct platform_device *pdev)static int kirin_drm_platform_remove (struct platform_device *pdev) {component_master_del (&pdev->dev, &kirin_drm_ops); - driver_data =NULL ;return 0 ; }
Signature · 1 line
2.17.1
PATCH v5 23/25 drm: kirin: Add alloc_hw_ctx/clean_hw_ctx ops in driver data
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch changes the alloc/clean_hw_ctx functions to be called via driver_data specific funciton pointers.
This will allow the ade_drm_init to later be made generic and moved to kirin_drm_drv.c
--- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 9 ++++++++- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +8 -1
@@ -1000,7 +1000,7 @@ static int ade_drm_init(struct platform_device *pdev)return -ENOMEM ; } - ctx =ade_hw_ctx_alloc (pdev, &ade->crtc.base); + ctx = ade_driver_data.alloc_hw_ctx (pdev, &ade->crtc.base);if (IS_ERR (ctx)) {DRM_ERROR ("failed to initialize kirin_priv hw ctx\n" );return -EINVAL ;
@@ -1040,6 +1040,10 @@ static int ade_drm_init(struct platform_device *pdev)return 0 ; } +static void ade_hw_ctx_cleanup (void *hw_ctx) +{ +} +static void ade_drm_cleanup (struct platform_device *pdev) { }
@@ -1089,6 +1093,9 @@ struct kirin_drm_data ade_driver_data = { .plane_funcs = &ade_plane_funcs, .mode_config_funcs = &ade_mode_config_funcs, + .alloc_hw_ctx = ade_hw_ctx_alloc, + .cleanup_hw_ctx = ade_hw_ctx_cleanup, + .init = ade_drm_init, .cleanup = ade_drm_cleanup };
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +5 -0
@@ -49,6 +49,11 @@ struct kirin_drm_data {const struct drm_plane_helper_funcs *plane_helper_funcs;const struct drm_plane_funcs *plane_funcs;const struct drm_mode_config_funcs *mode_config_funcs; + +void *(*alloc_hw_ctx)(struct platform_device *pdev, +struct drm_crtc *crtc); +void (*cleanup_hw_ctx)(void *hw_ctx); +int (*init)(struct platform_device *pdev);void (*cleanup)(struct platform_device *pdev); };
Signature · 1 line
2.17.1
PATCH v5 24/25 drm: kirin: Pass driver data to crtc init and plane init
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch changes the code via a passed in driver_data pointer, rather than hardcoding them via ade_driver_data variable.
This will allow those funcitons to be later moved to the generic kirin_drm_drv.c using alternative driver_data structures that support other hardware.
---
v2: Whitespace fixups, commit message tweaks suggested by Sam.
v5: checkpatch --strict whitespace fixups noticed by Sam
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +13 -10
@@ -572,7 +572,8 @@ static const struct drm_crtc_funcs ade_crtc_funcs = { };static int kirin_drm_crtc_init (struct drm_device *dev,struct drm_crtc *crtc, -struct drm_plane *plane) +struct drm_plane *plane, +const struct kirin_drm_data *driver_data) {struct device_node *port;int ret;
@@ -589,13 +590,13 @@ static int kirin_drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, crtc->port = port; ret =drm_crtc_init_with_planes (dev, crtc, plane,NULL , - ade_driver_data.crtc_funcs,NULL ); + driver_data->crtc_funcs,NULL );if (ret) {DRM_ERROR ("failed to init crtc.\n" );return ret; } -drm_crtc_helper_add (crtc, ade_driver_data.crtc_helper_funcs); +drm_crtc_helper_add (crtc, driver_data->crtc_helper_funcs);return 0 ; }
@@ -894,21 +895,22 @@ static struct drm_plane_funcs ade_plane_funcs = {static int kirin_drm_plane_init (struct drm_device *dev,struct kirin_plane *kplane, -enum drm_plane_type type) +enum drm_plane_type type, +const struct kirin_drm_data *driver_data) {int ret =0 ; ret =drm_universal_plane_init (dev, &kplane->base,1 , - ade_driver_data.plane_funcs, - ade_driver_data.channel_formats, - ade_driver_data.channel_formats_cnt, + driver_data->plane_funcs, + driver_data->channel_formats, + driver_data->channel_formats_cnt,NULL , type,NULL );if (ret) {DRM_ERROR ("fail to init plane, ch=%d\n" , kplane->ch);return ret; } -drm_plane_helper_add (&kplane->base, ade_driver_data.plane_helper_funcs); +drm_plane_helper_add (&kplane->base, driver_data->plane_helper_funcs);return 0 ; }
@@ -1025,7 +1027,7 @@ static int ade_drm_init(struct platform_device *pdev)else type =DRM_PLANE_TYPE_OVERLAY ; - ret =kirin_drm_plane_init (dev, kplane, type); + ret =kirin_drm_plane_init (dev, kplane, type, &ade_driver_data);if (ret)return ret; }
@@ -1033,7 +1035,8 @@ static int ade_drm_init(struct platform_device *pdev)/* crtc init */ prim_plane = ade_driver_data.prim_plane; ret =kirin_drm_crtc_init (dev, &kcrtc->base, - &ade->planes[prim_plane].base); + &ade->planes[prim_plane].base, + &ade_driver_data);if (ret)return ret;
Signature · 1 line
2.17.1
PATCH v5 25/25 drm: kirin: Move ade drm init to kirin drm drv
In reply to John StultzFrom: Xu YiPing <[email protected]>
As part of refactoring the kirin driver to better support different hardware revisions, this patch renames ade_data to kirin_drm_private, and moves crtc_init and plane_init to kirin drm drv too. Now that they are generic the functions can be shared between the kirin620 and (to be added later) kirin960 specific support code.
---
v5: checkpatch --strict whitespace fixups noticed by Sam
--- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 125 ---------------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 141 ++++++++++++++++-- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 5 - 3 files changed, 129 insertions(+), 142 deletions(-)
drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +0 -125
@@ -53,13 +53,6 @@ struct ade_hw_ctx {struct drm_crtc *crtc; }; -struct ade_data { -struct kirin_crtc crtc; -struct kirin_plane planes[ADE_CH_NUM ]; -struct ade_hw_ctx *hw_ctx; -}; - -/* ade-format info: */ static const struct kirin_format ade_formats[] = {/* 16bpp RGB: */ {DRM_FORMAT_RGB565 ,ADE_RGB_565 },
@@ -571,36 +564,6 @@ static const struct drm_crtc_funcs ade_crtc_funcs = { .disable_vblank = ade_crtc_disable_vblank, }; -static int kirin_drm_crtc_init (struct drm_device *dev,struct drm_crtc *crtc, -struct drm_plane *plane, -const struct kirin_drm_data *driver_data) -{ -struct device_node *port; -int ret; - -/* set crtc port so that -* drm_of_find_possible_crtcs call works -*/ - port =of_get_child_by_name (dev->dev->of_node,"port" ); -if (!port) { -DRM_ERROR ("no port node found in %pOF\n" , dev->dev->of_node); -return -EINVAL ; - } -of_node_put (port); - crtc->port = port; - - ret =drm_crtc_init_with_planes (dev, crtc, plane,NULL , - driver_data->crtc_funcs,NULL ); -if (ret) { -DRM_ERROR ("failed to init crtc.\n" ); -return ret; - } - -drm_crtc_helper_add (crtc, driver_data->crtc_helper_funcs); - -return 0 ; -} -static void ade_rdma_set (void __iomem *base,struct drm_framebuffer *fb,u32 ch,u32 y,u32 in_h,u32 fmt) {
@@ -893,28 +856,6 @@ static struct drm_plane_funcs ade_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; -static int kirin_drm_plane_init (struct drm_device *dev, -struct kirin_plane *kplane, -enum drm_plane_type type, -const struct kirin_drm_data *driver_data) -{ -int ret =0 ; - - ret =drm_universal_plane_init (dev, &kplane->base,1 , - driver_data->plane_funcs, - driver_data->channel_formats, - driver_data->channel_formats_cnt, -NULL , type,NULL ); -if (ret) { -DRM_ERROR ("fail to init plane, ch=%d\n" , kplane->ch); -return ret; - } - -drm_plane_helper_add (&kplane->base, driver_data->plane_helper_funcs); - -return 0 ; -} -static void *ade_hw_ctx_alloc (struct platform_device *pdev,struct drm_crtc *crtc) {
@@ -984,73 +925,10 @@ static void *ade_hw_ctx_alloc(struct platform_device *pdev,return ctx; } -static int ade_drm_init (struct platform_device *pdev) -{ -struct drm_device *dev =platform_get_drvdata (pdev); -struct ade_data *ade; -struct ade_hw_ctx *ctx; -struct kirin_crtc *kcrtc; -struct kirin_plane *kplane; -enum drm_plane_type type; -int prim_plane; -int ret; -u32 ch; - - ade =devm_kzalloc (dev->dev,sizeof (*ade),GFP_KERNEL ); -if (!ade) { -DRM_ERROR ("failed to alloc ade_data\n" ); -return -ENOMEM ; - } - - ctx = ade_driver_data.alloc_hw_ctx (pdev, &ade->crtc.base); -if (IS_ERR (ctx)) { -DRM_ERROR ("failed to initialize kirin_priv hw ctx\n" ); -return -EINVAL ; - } - ade->hw_ctx = ctx; - - kcrtc = &ade->crtc; - kcrtc->hw_ctx = ctx; - -/* -* plane init -* TODO: Now only support primary plane, overlay planes -* need to do. -*/ -for (ch =0 ; ch < ade_driver_data.num_planes; ch++) { - kplane = &ade->planes[ch]; - kplane->ch = ch; - kplane->hw_ctx = ctx; - -if (ch == ade_driver_data.prim_plane) - type =DRM_PLANE_TYPE_PRIMARY ; -else - type =DRM_PLANE_TYPE_OVERLAY ; - - ret =kirin_drm_plane_init (dev, kplane, type, &ade_driver_data); -if (ret) -return ret; - } - -/* crtc init */ - prim_plane = ade_driver_data.prim_plane; - ret =kirin_drm_crtc_init (dev, &kcrtc->base, - &ade->planes[prim_plane].base, - &ade_driver_data); -if (ret) -return ret; - -return 0 ; -} -static void ade_hw_ctx_cleanup (void *hw_ctx) { } -static void ade_drm_cleanup (struct platform_device *pdev) -{ -} -static const struct drm_mode_config_funcs ade_mode_config_funcs = { .fb_create = drm_gem_fb_create, .atomic_check = drm_atomic_helper_check,
@@ -1098,7 +976,4 @@ struct kirin_drm_data ade_driver_data = { .alloc_hw_ctx = ade_hw_ctx_alloc, .cleanup_hw_ctx = ade_hw_ctx_cleanup, - - .init = ade_drm_init, - .cleanup = ade_drm_cleanup };
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c +129 -12
174 lines not on this page · raw message
drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +0 -5
@@ -7,8 +7,6 @@#ifndef __KIRIN_DRM_DRV_H__#define __KIRIN_DRM_DRV_H__ -#define MAX_CRTC 2 -#define to_kirin_crtc (crtc) \ container_of(crtc, struct kirin_crtc, base)
@@ -53,9 +51,6 @@ struct kirin_drm_data {void *(*alloc_hw_ctx)(struct platform_device *pdev,struct drm_crtc *crtc);void (*cleanup_hw_ctx)(void *hw_ctx); - -int (*init)(struct platform_device *pdev); -void (*cleanup)(struct platform_device *pdev); };extern struct kirin_drm_data ade_driver_data;
Signature · 1 line
2.17.1
Hi John.
Quoted 9 lines · John Stultz
Sending this out again (apologies!), to address a few issues Sam found.
This patchset contains one fix (in the front, so its easier to eventually backport), and a series of changes from YiPing to refactor the kirin drm driver so that it can be used on both kirin620 based devices (like the original HiKey board) as well as kirin960 based devices (like the HiKey960 board).
Quoted 7 lines
The full kirin960 drm support is still being refactored, but as this base kirin rework was getting to be substantial, I wanted to send out the first chunk, so that the review burden wasn't overwhelming.
The full HiKey960 patch stack can be found here:
https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/hikey960-mainline-WIP
Applied from the mails - as this is what my tooling expect. Pushed to drm-misc-next.
Sam
Quoted 18 lines · Sam Ravnborg
Hi John.
Quoted 14 lines · John Stultz
Sending this out again (apologies!), to address a few issues Sam found.
This patchset contains one fix (in the front, so its easier to eventually backport), and a series of changes from YiPing to refactor the kirin drm driver so that it can be used on both kirin620 based devices (like the original HiKey board) as well as kirin960 based devices (like the HiKey960 board).
The full kirin960 drm support is still being refactored, but as this base kirin rework was getting to be substantial, I wanted to send out the first chunk, so that the review burden wasn't overwhelming.
Quoted 4 lines
Quoted 2 lines
The full HiKey960 patch stack can be found here:
https://git.linaro.org/people/john.stultz/android-dev.git/log/?h=dev/hikey960-mainline-WIPApplied from the mails - as this is what my tooling expect.
Oh yes, that URL was just for reference if anyone wanted to see what all the churn here was for.
Quoted 1 line
Pushed to drm-misc-next.
Great! Thanks so much for all the review and fedback! I really appreciate your time helping!
-john