Add DRM driver for Hisilicon Hibmc
Subsystems (3)
v5 cover Add DRM driver for Hisilicon Hibmc
This patch set adds a new drm driver for Hisilicon Hibmc. Hibmc is a BMC SoC with a display controller intergrated, usually it is used on server for Out-of-band management purpose. In this patch set, we just support basic function for Hibmc display subsystem. Hibmc display subsystem is connected to host CPU by PCIe as blow:
+----------+ +----------+ | | PCIe | Hibmc | |host CPU( |<----->| display | |arm64,x86)| |subsystem | +----------+ +----------+
Hardware Detail for Hibmc display subsystem
-----------
The display subsystem of Hibmc is show as bellow:
+----+ +----+ +----+ +--------+ | | | | | | | | | FB |----->| DE |----->|VDAC|---->|external| | | | | | | | VGA | +----+ +----+ +----+ +--------+
-DE(Display Engine) is the display controller.
-VDAC(Video Digital-to-Analog converter) converts the RGB diaital data stream from DE to VGA analog signals.
Change History
------------
Changes in v5:
-rebase on v4.9-rc2.
-replace drm_fb_helper_set_suspend() with
drm_fb_helper_set_suspend_unlocked(), remove redundant console_lock() and console_unlock().
Changes in v4:
-remove unused include files, and include header file when it is needed. -remove unused FLAG in Kconfig: DRM_GEM_CMA_HELPER/DRM_KMS_CMA_HELPER. -remove drm_helper_disable_unused_functions, since we use DRIVER_ATOMIC.
Changes in v3:
-enable KMS, in v2, only fbdev is enabled.
-management video memory with ttm.
-add vblank interrupt.
-remove drm_connector_register_all() and drm_connector_unregister_all(). -I have a basic test with igt.
Changes in v2:
-Remove self-defined macros for bit operations. -Remove unused register.
-Replace those deprecated functions with new version of them. -use drm_connector_register_all() to register connector after
drm_dev_register().
The patch v2 is at
https://lists.freedesktop.org/archives/dri-devel/2016-May/108661.html
Rongrong Zou (9):
drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver drm/hisilicon/hibmc: Add video memory management drm/hisilicon/hibmc: Add support for frame buffer drm/hisilicon/hibmc: Add plane for DE drm/hisilicon/hibmc: Add crtc for DE drm/hisilicon/hibmc: Add encoder for VDAC drm/hisilicon/hibmc: Add connector for VDAC drm/hisilicon/hibmc: Add vblank interruput
MAINTAINERS: Update HISILICON DRM entries
MAINTAINERS | 1 + drivers/gpu/drm/hisilicon/Kconfig | 1 + drivers/gpu/drm/hisilicon/Makefile | 1 + drivers/gpu/drm/hisilicon/hibmc/Kconfig | 9 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 5 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 488 +++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h | 29 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 410 ++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 117 +++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 256 ++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c | 85 ++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h | 28 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h | 212 ++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 165 +++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 563 ++++++++++++++++++++++ 15 files changed, 2370 insertions(+) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Kconfig create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Makefile create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
Signature · 1 line
1.9.1
PATCH v5 1/9 drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver
Add DRM master driver for Hisilicon Hibmc SoC which used for Out-of-band management. Blow is the general hardware connection, both the Hibmc and the host CPU are on the same mother board.
+----------+ +----------+ | | PCIe | Hibmc | |host CPU( |<----->| display | |arm64,x86)| |subsystem | +----------+ +----------+
--- drivers/gpu/drm/hisilicon/Kconfig | 1 + drivers/gpu/drm/hisilicon/Makefile | 1 + drivers/gpu/drm/hisilicon/hibmc/Kconfig | 7 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 5 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 269 ++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 35 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c | 85 +++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h | 28 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h | 212 +++++++++++++++++ 9 files changed, 643 insertions(+) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Kconfig create mode 100644 drivers/gpu/drm/hisilicon/hibmc/Makefile create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h
drivers/gpu/drm/hisilicon/Kconfig +1 -0
@@ -2,4 +2,5 @@ # hisilicon drm device configuration. # Please keep this list sorted alphabetically +source "drivers/gpu/drm/hisilicon/hibmc/Kconfig" source "drivers/gpu/drm/hisilicon/kirin/Kconfig"
drivers/gpu/drm/hisilicon/Makefile +1 -0
@@ -2,4 +2,5 @@ # Makefile for hisilicon drm drivers. # Please keep this list sorted alphabetically +obj-$(CONFIG_DRM_HISI_HIBMC) += hibmc/ obj-$(CONFIG_DRM_HISI_KIRIN) += kirin/
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +config DRM_HISI_HIBMC + tristate "DRM Support for Hisilicon Hibmc" + depends on DRM && PCI + + help + Choose this option if you have a Hisilicon Hibmc soc chipset. + If M is selected the module will be called hibmc-drm.
drivers/gpu/drm/hisilicon/hibmc/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +ccflags-y := -Iinclude/drm +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_power.o + +obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o +#obj-y += hibmc-drm.o
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +269 -0
269 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h new file +35 -0
@@ -0,0 +1,35 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <[email protected]> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_DRV_H +#define HIBMC_DRM_DRV_H + +#include <drm/drmP.h> + +struct hibmc_drm_device { +/* hw */ +void __iomem *mmio; +void __iomem *fb_map; +unsigned long fb_base; +unsigned long fb_size; + +/* drm */ +struct drm_device *dev; +}; + +#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c new file +85 -0
85 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h new file +28 -0
@@ -0,0 +1,28 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <[email protected]> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_POWER_H +#define HIBMC_DRM_POWER_H + +#include "hibmc_drm_drv.h" + +void hibmc_set_power_mode (struct hibmc_drm_device *hidev, +unsigned int power_mode); +void hibmc_set_current_gate (struct hibmc_drm_device *hidev, +unsigned int gate); +#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h new file +212 -0
212 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v5 2/9 drm/hisilicon/hibmc: Add video memory management
In reply to Rongrong ZouHibmc have 32m video memory which can be accessed through PCIe by host, we use ttm to manage these memory.
--- drivers/gpu/drm/hisilicon/hibmc/Kconfig | 1 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 12 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 46 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 490 ++++++++++++++++++++++++ 5 files changed, 550 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
drivers/gpu/drm/hisilicon/hibmc/Kconfig +1 -0
@@ -1,6 +1,7 @@ config DRM_HISI_HIBMC tristate "DRM Support for Hisilicon Hibmc" depends on DRM && PCI + select DRM_TTM help Choose this option if you have a Hisilicon Hibmc soc chipset.
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
@@ -1,5 +1,5 @@ ccflags-y := -Iinclude/drm -hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_power.o +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_power.o hibmc_ttm.o obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o #obj-y += hibmc-drm.o
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +12 -0
@@ -31,6 +31,7 @@#ifdef CONFIG_COMPAT .compat_ioctl = drm_compat_ioctl, #endif + .mmap = hibmc_mmap, .poll = drm_poll, .read = drm_read, .llseek = no_llseek,
@@ -46,6 +47,8 @@ static void hibmc_disable_vblank(struct drm_device *dev, unsigned int pipe) }static struct drm_driver hibmc_driver = { + .driver_features =DRIVER_GEM , + .fops = &hibmc_fops, .name ="hibmc" , .date ="20160828" ,
@@ -55,6 +58,10 @@ static void hibmc_disable_vblank(struct drm_device *dev, unsigned int pipe) .get_vblank_counter = drm_vblank_no_hw_counter, .enable_vblank = hibmc_enable_vblank, .disable_vblank = hibmc_disable_vblank, + .gem_free_object_unlocked = hibmc_gem_free_object, + .dumb_create = hibmc_dumb_create, + .dumb_map_offset = hibmc_dumb_mmap_offset, + .dumb_destroy = drm_gem_dumb_destroy, };static int hibmc_pm_suspend (struct device *dev)
@@ -163,6 +170,7 @@ static int hibmc_unload(struct drm_device *dev) {struct hibmc_drm_device *hidev = dev->dev_private; +hibmc_mm_fini (hidev);hibmc_hw_fini (hidev); dev->dev_private =NULL ;return 0 ;
@@ -183,6 +191,10 @@ static int hibmc_load(struct drm_device *dev, unsigned long flags)if (ret) goto err; + ret =hibmc_mm_init (hidev); +if (ret) + goto err; +return 0 ; err:
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +46 -0
58 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c new file +490 -0
490 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v5 3/9 drm/hisilicon/hibmc: Add support for frame buffer
In reply to Rongrong ZouAdd support for fbdev and kms fb management.
--- drivers/gpu/drm/hisilicon/hibmc/Makefile | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 17 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 25 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 256 ++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 67 ++++++ 5 files changed, 366 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
@@ -1,5 +1,5 @@ ccflags-y := -Iinclude/drm -hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_power.o hibmc_ttm.o +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_fbdev.o hibmc_drm_power.o hibmc_ttm.o obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o #obj-y += hibmc-drm.o
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +17 -0
@@ -66,11 +66,23 @@ static void hibmc_disable_vblank(struct drm_device *dev, unsigned int pipe)static int hibmc_pm_suspend (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct hibmc_drm_device *hidev = drm_dev->dev_private; + +drm_fb_helper_set_suspend_unlocked (&hidev->fbdev.helper,1 ); +return 0 ; }static int hibmc_pm_resume (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev); +struct drm_device *drm_dev =pci_get_drvdata (pdev); +struct hibmc_drm_device *hidev = drm_dev->dev_private; + +drm_fb_helper_set_suspend_unlocked (&hidev->fbdev.helper,0 ); +return 0 ; }
@@ -170,6 +182,7 @@ static int hibmc_unload(struct drm_device *dev) {struct hibmc_drm_device *hidev = dev->dev_private; +hibmc_fbdev_fini (hidev);hibmc_mm_fini (hidev);hibmc_hw_fini (hidev); dev->dev_private =NULL ;
@@ -195,6 +208,10 @@ static int hibmc_load(struct drm_device *dev, unsigned long flags)if (ret) goto err; + ret =hibmc_fbdev_init (hidev); +if (ret) + goto err; +return 0 ; err:
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +25 -0
@@ -20,9 +20,23 @@#define HIBMC_DRM_DRV_H #include <drm/drmP.h> +#include <drm/drm_fb_helper.h> #include <drm/ttm/ttm_bo_driver.h> #include <drm/drm_gem.h> +struct hibmc_framebuffer { +struct drm_framebuffer fb; +struct drm_gem_object *obj; +bool is_fbdev_fb; +}; + +struct hibmc_fbdev { +struct drm_fb_helper helper; +struct hibmc_framebuffer fb; +int size; +bool initialized; +}; +struct hibmc_drm_device {/* hw */ void __iomem *mmio;
@@ -41,9 +55,13 @@ struct hibmc_drm_device {bool initialized; } ttm; +/* fbdev */ +struct hibmc_fbdev fbdev;bool mm_inited; }; +#define to_hibmc_framebuffer (x) container_of(x, struct hibmc_framebuffer, fb) +struct hibmc_bo {struct ttm_buffer_object bo;struct ttm_placement placement;
@@ -65,8 +83,15 @@ static inline struct hibmc_bo *gem_to_hibmc_bo(struct drm_gem_object *gem)#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) +int hibmc_fbdev_init (struct hibmc_drm_device *hidev); +void hibmc_fbdev_fini (struct hibmc_drm_device *hidev); +int hibmc_gem_create (struct drm_device *dev,u32 size,bool iskernel,struct drm_gem_object **obj); +int hibmc_framebuffer_init (struct drm_device *dev, +struct hibmc_framebuffer *gfb, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object *obj);int hibmc_mm_init (struct hibmc_drm_device *hibmc);void hibmc_mm_fini (struct hibmc_drm_device *hibmc);
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c new file +256 -0
256 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +67 -0
70 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v5 3/9] drm/hisilicon/hibmc: Add support for frame buffer
Quoted 3 lines · Rongrong Zou
Add support for fbdev and kms fb management.
Signed-off-by Rongrong Zou <[email protected]>
Small drive-by comment below.
Quoted 11 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +1
-0@@ -20,9 +20,23 @@#define HIBMC_DRM_DRV_H #include <drm/drmP.h> +#include <drm/drm_fb_helper.h> #include <drm/ttm/ttm_bo_driver.h> #include <drm/drm_gem.h>
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h line 35
Quoted 10 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +9
-0+struct hibmc_framebuffer { +struct drm_framebuffer fb; +struct drm_gem_object *obj; +bool is_fbdev_fb; +}; + +struct hibmc_fbdev { +struct drm_fb_helper helper; +struct hibmc_framebuffer fb;
I wouldn't embed the single framebuffer here, but instead have a pointer and just refcount it. This here is a pattern that predates framebuffer refcounting, and it leads to plenty of surprises.
Maybe we should update the documentation of drm_framebuffer_unregister_private() to mention that it is deprecated? The overview doc in drm_framebuffer.c already explains that, but I guess that's not obvious enough.
Can you pls do that patch? And pls make sure it all looks pretty when building the docs with
$ make htmldocs
Thanks, Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Re: [PATCH v5 3/9] drm/hisilicon/hibmc: Add support for frame buffer
Hi Daniel,
Thansk for reviewing!
Quoted 19 lines · Daniel Vetter
Quoted 3 lines · Rongrong Zou
Add support for fbdev and kms fb management.
Signed-off-by Rongrong Zou <[email protected]>Small drive-by comment below.
Quoted 12 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +1
-0@@ -20,9 +20,23 @@#define HIBMC_DRM_DRV_H #include <drm/drmP.h> +#include <drm/drm_fb_helper.h> #include <drm/ttm/ttm_bo_driver.h> #include <drm/drm_gem.h>
Quoted 13 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h line 35
Quoted 9 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +9
-0+struct hibmc_framebuffer { +struct drm_framebuffer fb; +struct drm_gem_object *obj; +bool is_fbdev_fb; +}; + +struct hibmc_fbdev { +struct drm_fb_helper helper; +struct hibmc_framebuffer fb;I wouldn't embed the single framebuffer here, but instead have a pointer and just refcount it. This here is a pattern that predates framebuffer refcounting, and it leads to plenty of surprises.
will allocate fbdev in next patch version, thanks.
Quoted 5 lines
Maybe we should update the documentation of
drm_framebuffer_unregister_private()to mention that it is deprecated? The overview doc indrm_framebuffer.calready explains that, but I guess that's not obvious enough.
Just replace drm_framebuffer_unregister_private() with drm_framebuffer_remove()?
I found many other drivers use the following two functions in their own xxx_fbdev_destroy():
drm_framebuffer_unregister_private(fbdev->fb); drm_framebuffer_remove(fbdev->fb);
so the former is redundant and can be removed directly?
Quoted 3 lines
Can you pls do that patch? And pls make sure it all looks pretty when building the docs with
No problem, i'll send another patch later.
Regards,
Rongrong
Quoted 5 lines
$ make htmldocsThanks, Daniel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v5 3/9] drm/hisilicon/hibmc: Add support for frame buffer
Quoted 38 lines · Rongrong Zou
Hi Daniel,
Thansk for reviewing!
Quoted 19 lines · Daniel Vetter
Quoted 3 lines · Rongrong Zou
Add support for fbdev and kms fb management.
Signed-off-by Rongrong Zou <[email protected]>Small drive-by comment below.
Quoted 12 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +1
-0@@ -20,9 +20,23 @@#define HIBMC_DRM_DRV_H #include <drm/drmP.h> +#include <drm/drm_fb_helper.h> #include <drm/ttm/ttm_bo_driver.h> #include <drm/drm_gem.h> Quoted 13 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h line 35
Quoted 9 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +9
-0+struct hibmc_framebuffer { +struct drm_framebuffer fb; +struct drm_gem_object *obj; +bool is_fbdev_fb; +}; + +struct hibmc_fbdev { +struct drm_fb_helper helper; +struct hibmc_framebuffer fb;I wouldn't embed the single framebuffer here, but instead have a pointer and just refcount it. This here is a pattern that predates framebuffer refcounting, and it leads to plenty of surprises.
Quoted 1 line
will allocate fbdev in next patch version, thanks.
Not the fbdev, the hibmc_framebuffer.
Quoted 5 lines
Quoted 4 lines
Maybe we should update the documentation of
drm_framebuffer_unregister_private()to mention that it is deprecated? The overview doc indrm_framebuffer.calready explains that, but I guess that's not obvious enough.
Quoted 8 lines
Just replace
drm_framebuffer_unregister_private()withdrm_framebuffer_remove()?I found many other drivers use the following two functions in their own
xxx_fbdev_destroy():drm_framebuffer_unregister_private(fbdev->fb); drm_framebuffer_remove(fbdev->fb);so the former is redundant and can be removed directly?
They all embed the fb instead of having a pointer, because those drivers are all older than the fb refcounting support. In general good practice is to look at the most recently merged driver, not at all of them. Only the most recently one has a good chance to be up-to-date with latest best practices. The function to call would be drm_framebuffer_unreference(), and your struct above should be
struct hibmc_fbdev {
struct drm_fb_helper helper;
struct hibmc_framebuffer *fb;
...
};Note how fb is a pointer here, not an embedded struct. -Daniel
Quoted 18 lines
Quoted 4 lines
Can you pls do that patch? And pls make sure it all looks pretty when building the docs with
No problem, i'll send another patch later.
Regards,
RongrongQuoted 5 lines
$ make htmldocsThanks, Daniel
Signature · 8 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v5 3/9] drm/hisilicon/hibmc: Add support for frame buffer
Quoted 39 lines · Daniel Vetter
Quoted 38 lines · Rongrong Zou
Hi Daniel,
Thansk for reviewing!
Quoted 32 lines · Daniel Vetter
Quoted 3 lines · Rongrong Zou
Add support for fbdev and kms fb management.
Signed-off-by Rongrong Zou <[email protected]>Small drive-by comment below.
Quoted 11 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +1
-0@@ -20,9 +20,23 @@#define HIBMC_DRM_DRV_H #include <drm/drmP.h> +#include <drm/drm_fb_helper.h> #include <drm/ttm/ttm_bo_driver.h> #include <drm/drm_gem.h> drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h line 35
Quoted 10 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +9
-0+struct hibmc_framebuffer { +struct drm_framebuffer fb; +struct drm_gem_object *obj; +bool is_fbdev_fb; +}; + +struct hibmc_fbdev { +struct drm_fb_helper helper; +struct hibmc_framebuffer fb;I wouldn't embed the single framebuffer here, but instead have a pointer and just refcount it. This here is a pattern that predates framebuffer refcounting, and it leads to plenty of surprises.
Quoted 3 lines
Quoted 1 line
will allocate fbdev in next patch version, thanks.
Not the fbdev, the
hibmc_framebuffer.
Understood, thanks.
Quoted 22 lines
Quoted 6 lines
Quoted 5 lines
Maybe we should update the documentation of
drm_framebuffer_unregister_private()to mention that it is deprecated? The overview doc indrm_framebuffer.calready explains that, but I guess that's not obvious enough.Quoted 8 lines
Just replace
drm_framebuffer_unregister_private()withdrm_framebuffer_remove()?I found many other drivers use the following two functions in their own
xxx_fbdev_destroy():drm_framebuffer_unregister_private(fbdev->fb); drm_framebuffer_remove(fbdev->fb);so the former is redundant and can be removed directly?
They all embed the fb instead of having a pointer, because those drivers are all older than the fb refcounting support. In general good practice is to look at the most recently merged driver, not at all of them. Only the most recently one has a good chance to be up-to-date with latest best practices. The function to call would be
drm_framebuffer_unreference(), and your struct above should be
Quoted 7 lines
struct hibmc_fbdev { struct drm_fb_helper helper; struct hibmc_framebuffer *fb; ... };Note how fb is a pointer here, not an embedded struct.
And in hibmc_user_framebuffer_destroy(), it should call kfree(hibmc_framebuffer *hibmc_fb) not kfree(drm_framebuffer *fb), thanks.
regards,
Rongrong
Quoted 21 lines
-Daniel
Quoted 18 lines
Quoted 4 lines
Can you pls do that patch? And pls make sure it all looks pretty when building the docs with
No problem, i'll send another patch later.
Regards,
RongrongQuoted 5 lines
$ make htmldocsThanks, Daniel
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v5 4/9 drm/hisilicon/hibmc: Add plane for DE
In reply to Rongrong ZouAdd plane funcs and helper funcs for DE.
--- drivers/gpu/drm/hisilicon/hibmc/Kconfig | 1 + drivers/gpu/drm/hisilicon/hibmc/Makefile | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 170 ++++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h | 29 ++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 51 ++++++- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 5 + drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c | 6 + 7 files changed, 261 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h
drivers/gpu/drm/hisilicon/hibmc/Kconfig +1 -0
@@ -1,6 +1,7 @@ config DRM_HISI_HIBMC tristate "DRM Support for Hisilicon Hibmc" depends on DRM && PCI + select DRM_KMS_HELPER select DRM_TTM help
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
@@ -1,5 +1,5 @@ ccflags-y := -Iinclude/drm -hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_fbdev.o hibmc_drm_power.o hibmc_ttm.o +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_fbdev.o hibmc_drm_power.o hibmc_ttm.o obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o #obj-y += hibmc-drm.o
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c new file +170 -0
170 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h new file +29 -0
@@ -0,0 +1,29 @@ +/* Hisilicon Hibmc SoC drm driver +* +* Based on the bochs drm driver. +* +* Copyright (c) 2016 Huawei Limited. +* +* Author: +* Rongrong Zou <[email protected]> +* Rongrong Zou <[email protected]> +* Jianhua Li <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +*/ + +#ifndef HIBMC_DRM_DE_H +#define HIBMC_DRM_DE_H + +struct panel_pll { +unsigned long M; +unsigned long N; +unsigned long OD; +unsigned long POD; +}; + +#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +49 -2
94 lines not on this page · raw message
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +5 -0
@@ -46,6 +46,8 @@ struct hibmc_drm_device {/* drm */ struct drm_device *dev; +struct drm_plane plane; +bool mode_config_initialized;/* ttm */ struct {
@@ -83,6 +85,7 @@ static inline struct hibmc_bo *gem_to_hibmc_bo(struct drm_gem_object *gem)#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT) +int hibmc_plane_init (struct hibmc_drm_device *hidev);int hibmc_fbdev_init (struct hibmc_drm_device *hidev);void hibmc_fbdev_fini (struct hibmc_drm_device *hidev);
@@ -103,4 +106,6 @@ int hibmc_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev, u32 handle, u64 *offset);int hibmc_mmap (struct file *filp,struct vm_area_struct *vma); +extern const struct drm_mode_config_funcs hibmc_mode_funcs; +#endif
drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +6 -0
@@ -555,3 +555,9 @@ int hibmc_framebuffer_init(struct drm_device *dev, }return &hibmc_fb->fb; } + +const struct drm_mode_config_funcs hibmc_mode_funcs = { + .atomic_check = drm_atomic_helper_check, + .atomic_commit = drm_atomic_helper_commit, + .fb_create = hibmc_user_framebuffer_create, +};
Signature · 1 line
1.9.1
PATCH v5 5/9 drm/hisilicon/hibmc: Add crtc for DE
In reply to Rongrong ZouAdd crtc funcs and helper funcs for DE.
--- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 318 ++++++++++++++++++++++++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 6 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 2 + 3 files changed, 326 insertions(+)
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c +318 -0
@@ -23,6 +23,7 @@#include "hibmc_drm_drv.h" #include "hibmc_drm_regs.h" +#include "hibmc_drm_de.h" #include "hibmc_drm_power.h" /* ---------------------------------------------------------------------- */
@@ -168,3 +169,320 @@ int hibmc_plane_init(struct hibmc_drm_device *hidev)drm_plane_helper_add (plane, &hibmc_plane_helper_funcs);return 0 ; } + +static void hibmc_crtc_enable (struct drm_crtc *crtc) +{ +unsigned int reg; +/* power mode 0 is default. */ +struct hibmc_drm_device *hidev = crtc->dev->dev_private; + +hibmc_set_power_mode (hidev,HIBMC_PW_MODE_CTL_MODE_MODE0 ); + +/* Enable display power gate & LOCALMEM power gate*/ + reg =readl (hidev->mmio +HIBMC_CURRENT_GATE ); + reg &= ~HIBMC_CURR_GATE_LOCALMEM_MASK ; + reg &= ~HIBMC_CURR_GATE_DISPLAY_MASK ; + reg |=HIBMC_CURR_GATE_LOCALMEM (ON ); + reg |=HIBMC_CURR_GATE_DISPLAY (ON ); +hibmc_set_current_gate (hidev, reg); +drm_crtc_vblank_on (crtc); +} + +static void hibmc_crtc_disable (struct drm_crtc *crtc) +{ +unsigned int reg; +struct hibmc_drm_device *hidev = crtc->dev->dev_private; + +drm_crtc_vblank_off (crtc); + +hibmc_set_power_mode (hidev,HIBMC_PW_MODE_CTL_MODE_SLEEP ); + +/* Enable display power gate & LOCALMEM power gate*/ + reg =readl (hidev->mmio +HIBMC_CURRENT_GATE ); + reg &= ~HIBMC_CURR_GATE_LOCALMEM_MASK ; + reg &= ~HIBMC_CURR_GATE_DISPLAY_MASK ; + reg |=HIBMC_CURR_GATE_LOCALMEM (OFF ); + reg |=HIBMC_CURR_GATE_DISPLAY (OFF ); +hibmc_set_current_gate (hidev, reg); +} + +static int hibmc_crtc_atomic_check (struct drm_crtc *crtc, +struct drm_crtc_state *state) +{ +return 0 ; +} + +static unsigned int format_pll_reg (void ) +{ +unsigned int pllreg =0 ; +struct panel_pll pll = {0 }; + +/* Note that all PLL's have the same format. Here, +* we just use Panel PLL parameter to work out the bit +* fields in the register.On returning a 32 bit number, the value can +* be applied to any PLL in the calling function. +*/ + pllreg |=HIBMC_PLL_CTRL_BYPASS (OFF ) &HIBMC_PLL_CTRL_BYPASS_MASK ; + pllreg |=HIBMC_PLL_CTRL_POWER (ON ) &HIBMC_PLL_CTRL_POWER_MASK ; + pllreg |=HIBMC_PLL_CTRL_INPUT (OSC ) &HIBMC_PLL_CTRL_INPUT_MASK ; + pllreg |=HIBMC_PLL_CTRL_POD (pll.POD) &HIBMC_PLL_CTRL_POD_MASK ; + pllreg |=HIBMC_PLL_CTRL_OD (pll.OD) &HIBMC_PLL_CTRL_OD_MASK ; + pllreg |=HIBMC_PLL_CTRL_N (pll.N) &HIBMC_PLL_CTRL_N_MASK ; + pllreg |=HIBMC_PLL_CTRL_M (pll.M) &HIBMC_PLL_CTRL_M_MASK ; + +return pllreg; +} + +static void set_vclock_hisilicon (struct drm_device *dev,unsigned long pll) +{ +unsigned long tmp0, tmp1; +struct hibmc_drm_device *hidev = dev->dev_private; + +/* 1. outer_bypass_n=0 */ + tmp0 =readl (hidev->mmio +CRT_PLL1_HS ); + tmp0 &=0xBFFFFFFF ; +writel (tmp0, hidev->mmio +CRT_PLL1_HS ); + +/* 2. pll_pd=1?inter_bypass=1 */ +writel (0x21000000 , hidev->mmio +CRT_PLL1_HS ); + +/* 3. config pll */ +writel (pll, hidev->mmio +CRT_PLL1_HS ); + +/* 4. delay */ +mdelay (1 ); + +/* 5. pll_pd =0 */ + tmp1 = pll & ~0x01000000 ; +writel (tmp1, hidev->mmio +CRT_PLL1_HS ); + +/* 6. delay */ +mdelay (1 ); + +/* 7. inter_bypass=0 */ + tmp1 &= ~0x20000000 ; +writel (tmp1, hidev->mmio +CRT_PLL1_HS ); + +/* 8. delay */ +mdelay (1 ); + +/* 9. outer_bypass_n=1 */ + tmp1 |=0x40000000 ; +writel (tmp1, hidev->mmio +CRT_PLL1_HS ); +} + +/* This function takes care the extra registers and bit fields required to +*setup a mode in board. +*Explanation about Display Control register: +*FPGA only supports 7 predefined pixel clocks, and clock select is +*in bit 4:0 of new register 0x802a8. +*/ +static unsigned int display_ctrl_adjust (struct drm_device *dev, +struct drm_display_mode *mode, +unsigned int ctrl) +{ +unsigned long x, y; +unsigned long pll1;/* bit[31:0] of PLL */ +unsigned long pll2;/* bit[63:32] of PLL */ +struct hibmc_drm_device *hidev = dev->dev_private; + + x = mode->hdisplay; + y = mode->vdisplay; + +/* Hisilicon has to set up a new register for PLL control +*(CRT_PLL1_HS & CRT_PLL2_HS). +*/ +if (x ==800 && y ==600 ) { + pll1 =CRT_PLL1_HS_40MHZ ; + pll2 =CRT_PLL2_HS_40MHZ ; + }else if (x ==1024 && y ==768 ) { + pll1 =CRT_PLL1_HS_65MHZ ; + pll2 =CRT_PLL2_HS_65MHZ ; + }else if (x ==1152 && y ==864 ) { + pll1 =CRT_PLL1_HS_80MHZ_1152 ; + pll2 =CRT_PLL2_HS_80MHZ ; + }else if (x ==1280 && y ==768 ) { + pll1 =CRT_PLL1_HS_80MHZ ; + pll2 =CRT_PLL2_HS_80MHZ ; + }else if (x ==1280 && y ==720 ) { + pll1 =CRT_PLL1_HS_74MHZ ; + pll2 =CRT_PLL2_HS_74MHZ ; + }else if (x ==1280 && y ==960 ) { + pll1 =CRT_PLL1_HS_108MHZ ; + pll2 =CRT_PLL2_HS_108MHZ ; + }else if (x ==1280 && y ==1024 ) { + pll1 =CRT_PLL1_HS_108MHZ ; + pll2 =CRT_PLL2_HS_108MHZ ; + }else if (x ==1600 && y ==1200 ) { + pll1 =CRT_PLL1_HS_162MHZ ; + pll2 =CRT_PLL2_HS_162MHZ ; + }else if (x ==1920 && y ==1080 ) { + pll1 =CRT_PLL1_HS_148MHZ ; + pll2 =CRT_PLL2_HS_148MHZ ; + }else if (x ==1920 && y ==1200 ) { + pll1 =CRT_PLL1_HS_193MHZ ; + pll2 =CRT_PLL2_HS_193MHZ ; + }else /* default to VGA clock */ { + pll1 =CRT_PLL1_HS_25MHZ ; + pll2 =CRT_PLL2_HS_25MHZ ; + } + +writel (pll2, hidev->mmio +CRT_PLL2_HS ); +set_vclock_hisilicon (dev, pll1); + +/* Hisilicon has to set up the top-left and bottom-right +* registers as well. +* Note that normal chip only use those two register for +* auto-centering mode. +*/ +writel ((HIBMC_CRT_AUTO_CENTERING_TL_TOP (0 ) & +HIBMC_CRT_AUTO_CENTERING_TL_TOP_MSK ) | + (HIBMC_CRT_AUTO_CENTERING_TL_LEFT (0 ) & +HIBMC_CRT_AUTO_CENTERING_TL_LEFT_MSK ), + hidev->mmio +HIBMC_CRT_AUTO_CENTERING_TL ); + +writel ((HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM (y -1 ) & +HIBMC_CRT_AUTO_CENTERING_BR_BOTTOM_MASK ) | + (HIBMC_CRT_AUTO_CENTERING_BR_RIGHT (x -1 ) & +HIBMC_CRT_AUTO_CENTERING_BR_RIGHT_MASK ), + hidev->mmio +HIBMC_CRT_AUTO_CENTERING_BR ); + +/* Assume common fields in ctrl have been properly set before +* calling this function. +* This function only sets the extra fields in ctrl. +*/ + +/* Set bit 25 of display controller: Select CRT or VGA clock */ + ctrl &= ~HIBMC_CRT_DISP_CTL_CRTSELECT_MASK ; + ctrl &= ~HIBMC_CRT_DISP_CTL_CLOCK_PHASE_MASK ; + + ctrl |=HIBMC_CRT_DISP_CTL_CRTSELECT (CRTSELECT_CRT ); + +/*ctrl = FIELD_SET(ctrl, HIBMC_CRT_DISP_CTL, CRTSELECT, CRT);*/ + +/* Set bit 14 of display controller */ +/*ctrl &= FIELD_CLEAR(HIBMC_CRT_DISP_CTL, CLOCK_PHASE);*/ + +/* clock_phase_polarity is 0 */ + ctrl |=HIBMC_CRT_DISP_CTL_CLOCK_PHASE (PHASE_ACTIVE_HIGH ); +/*ctrl = FIELD_SET(ctrl, HIBMC_CRT_DISP_CTL,*/ +/*CLOCK_PHASE, ACTIVE_HIGH);*/ + +writel (ctrl, hidev->mmio +HIBMC_CRT_DISP_CTL ); + +return ctrl; +} + +static void hibmc_crtc_mode_set_nofb (struct drm_crtc *crtc) +{ +unsigned int val; +struct drm_display_mode *mode = &crtc->state->mode; +struct drm_device *dev = crtc->dev; +struct hibmc_drm_device *hidev = dev->dev_private; + +writel (format_pll_reg (), hidev->mmio +HIBMC_CRT_PLL_CTRL ); +writel ((HIBMC_CRT_HORZ_TOTAL_TOTAL (mode->htotal -1 ) & +HIBMC_CRT_HORZ_TOTAL_TOTAL_MASK ) | + (HIBMC_CRT_HORZ_TOTAL_DISPLAY_END (mode->hdisplay -1 ) & +HIBMC_CRT_HORZ_TOTAL_DISPLAY_END_MASK ), + hidev->mmio +HIBMC_CRT_HORZ_TOTAL ); + +writel ((HIBMC_CRT_HORZ_SYNC_WIDTH (mode->hsync_end - mode->hsync_start) + &HIBMC_CRT_HORZ_SYNC_WIDTH_MASK ) | + (HIBMC_CRT_HORZ_SYNC_START (mode->hsync_start -1 ) + &HIBMC_CRT_HORZ_SYNC_START_MASK ), + hidev->mmio +HIBMC_CRT_HORZ_SYNC ); + +writel ((HIBMC_CRT_VERT_TOTAL_TOTAL (mode->vtotal -1 ) & +HIBMC_CRT_VERT_TOTAL_TOTAL_MASK ) | + (HIBMC_CRT_VERT_TOTAL_DISPLAY_END (mode->vdisplay -1 ) & +HIBMC_CRT_VERT_TOTAL_DISPLAY_END_MASK ), + hidev->mmio +HIBMC_CRT_VERT_TOTAL ); + +writel ((HIBMC_CRT_VERT_SYNC_HEIGHT (mode->vsync_end - mode->vsync_start) + &HIBMC_CRT_VERT_SYNC_HEIGHT_MASK ) | + (HIBMC_CRT_VERT_SYNC_START (mode->vsync_start -1 ) & +HIBMC_CRT_VERT_SYNC_START_MASK ), + hidev->mmio +HIBMC_CRT_VERT_SYNC ); + + val =HIBMC_CRT_DISP_CTL_VSYNC_PHASE (0 ) & +HIBMC_CRT_DISP_CTL_VSYNC_PHASE_MASK ; + val |=HIBMC_CRT_DISP_CTL_HSYNC_PHASE (0 ) & +HIBMC_CRT_DISP_CTL_HSYNC_PHASE_MASK ; + val |=HIBMC_CRT_DISP_CTL_TIMING (ENABLE ); + val |=HIBMC_CRT_DISP_CTL_PLANE (ENABLE ); + +display_ctrl_adjust (dev, mode, val); +} + +static void hibmc_crtc_atomic_begin (struct drm_crtc *crtc, +struct drm_crtc_state *old_state) +{ +unsigned int reg; +struct drm_device *dev = crtc->dev; +struct hibmc_drm_device *hidev = dev->dev_private; + +hibmc_set_power_mode (hidev,HIBMC_PW_MODE_CTL_MODE_MODE0 ); + +/* Enable display power gate & LOCALMEM power gate*/ + reg =readl (hidev->mmio +HIBMC_CURRENT_GATE ); + reg &= ~HIBMC_CURR_GATE_DISPLAY_MASK ; + reg &= ~HIBMC_CURR_GATE_LOCALMEM_MASK ; + reg |=HIBMC_CURR_GATE_DISPLAY (ON ); + reg |=HIBMC_CURR_GATE_LOCALMEM (ON ); +hibmc_set_current_gate (hidev, reg); + +/* We can add more initialization as needed. */ +} + +static void hibmc_crtc_atomic_flush (struct drm_crtc *crtc, +struct drm_crtc_state *old_state) + +{ +unsigned long flags; + +spin_lock_irqsave (&crtc->dev->event_lock, flags); +if (crtc->state->event) +drm_crtc_send_vblank_event (crtc, crtc->state->event); + crtc->state->event =NULL ; + +spin_unlock_irqrestore (&crtc->dev->event_lock, flags); +} + +/* These provide the minimum set of functions required to handle a CRTC */ +static const struct drm_crtc_funcs hibmc_crtc_funcs = { + .page_flip = drm_atomic_helper_page_flip, + .set_config = drm_atomic_helper_set_config, + .destroy = drm_crtc_cleanup, + .reset = drm_atomic_helper_crtc_reset, + .atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_crtc_destroy_state, +}; + +static const struct drm_crtc_helper_funcs hibmc_crtc_helper_funcs = { + .enable = hibmc_crtc_enable, + .disable = hibmc_crtc_disable, + .mode_set_nofb = hibmc_crtc_mode_set_nofb, + .atomic_check = hibmc_crtc_atomic_check, + .atomic_begin = hibmc_crtc_atomic_begin, + .atomic_flush = hibmc_crtc_atomic_flush, +}; + +int hibmc_crtc_init (struct hibmc_drm_device *hidev) +{ +struct drm_device *dev = hidev->dev; +struct drm_crtc *crtc = &hidev->crtc; +struct drm_plane *plane = &hidev->plane; +int ret; + + ret =drm_crtc_init_with_planes (dev, crtc, plane, +NULL , &hibmc_crtc_funcs,NULL ); +if (ret) { +DRM_ERROR ("failed to init crtc.\n" ); +return ret; + } + +drm_mode_crtc_set_gamma_size (crtc,256 ); +drm_crtc_helper_add (crtc, &hibmc_crtc_helper_funcs); +return 0 ; +}
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +6 -0
@@ -119,6 +119,12 @@ static int hibmc_kms_init(struct hibmc_drm_device *hidev)return ret; } + ret =hibmc_crtc_init (hidev); +if (ret) { +DRM_ERROR ("failed to init crtc.\n" ); +return ret; + } +return 0 ; }
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +2 -0
@@ -47,6 +47,7 @@ struct hibmc_drm_device {/* drm */ struct drm_device *dev;struct drm_plane plane; +struct drm_crtc crtc;bool mode_config_initialized;/* ttm */
@@ -86,6 +87,7 @@ static inline struct hibmc_bo *gem_to_hibmc_bo(struct drm_gem_object *gem)#define DRM_FILE_PAGE_OFFSET (0x100000000ULL >> PAGE_SHIFT)int hibmc_plane_init (struct hibmc_drm_device *hidev); +int hibmc_crtc_init (struct hibmc_drm_device *hidev);int hibmc_fbdev_init (struct hibmc_drm_device *hidev);void hibmc_fbdev_fini (struct hibmc_drm_device *hidev);
Signature · 1 line
1.9.1
PATCH v5 6/9 drm/hisilicon/hibmc: Add encoder for VDAC
In reply to Rongrong ZouAdd encoder funcs and helpers for VDAC.
--- drivers/gpu/drm/hisilicon/hibmc/Makefile | 2 +- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 6 ++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 2 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 89 ++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
@@ -1,5 +1,5 @@ ccflags-y := -Iinclude/drm -hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_fbdev.o hibmc_drm_power.o hibmc_ttm.o +hibmc-drm-y := hibmc_drm_drv.o hibmc_drm_de.o hibmc_drm_vdac.o hibmc_drm_fbdev.o hibmc_drm_power.o hibmc_ttm.o obj-$(CONFIG_DRM_HISI_HIBMC) +=hibmc-drm.o #obj-y += hibmc-drm.o
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +6 -0
@@ -125,6 +125,12 @@ static int hibmc_kms_init(struct hibmc_drm_device *hidev)return ret; } + ret =hibmc_encoder_init (hidev); +if (ret) { +DRM_ERROR ("failed to init encoder\n" ); +return ret; + } +return 0 ; }
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +2 -0
@@ -48,6 +48,7 @@ struct hibmc_drm_device {struct drm_device *dev;struct drm_plane plane;struct drm_crtc crtc; +struct drm_encoder encoder;bool mode_config_initialized;/* ttm */
@@ -88,6 +89,7 @@ static inline struct hibmc_bo *gem_to_hibmc_bo(struct drm_gem_object *gem)int hibmc_plane_init (struct hibmc_drm_device *hidev);int hibmc_crtc_init (struct hibmc_drm_device *hidev); +int hibmc_encoder_init (struct hibmc_drm_device *hidev);int hibmc_fbdev_init (struct hibmc_drm_device *hidev);void hibmc_fbdev_fini (struct hibmc_drm_device *hidev);
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v5 7/9 drm/hisilicon/hibmc: Add connector for VDAC
In reply to Rongrong ZouAdd connector funcs and helper funcs for VDAC.
--- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 8 +++ drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 2 + drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 76 ++++++++++++++++++++++++ 3 files changed, 86 insertions(+)
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +8 -0
@@ -131,6 +131,14 @@ static int hibmc_kms_init(struct hibmc_drm_device *hidev)return ret; } + ret =hibmc_connector_init (hidev); +if (ret) { +DRM_ERROR ("failed to init connector\n" ); +return ret; + } + +drm_mode_connector_attach_encoder (&hidev->connector, + &hidev->encoder);return 0 ; }
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +2 -0
@@ -49,6 +49,7 @@ struct hibmc_drm_device {struct drm_plane plane;struct drm_crtc crtc;struct drm_encoder encoder; +struct drm_connector connector;bool mode_config_initialized;/* ttm */
@@ -90,6 +91,7 @@ static inline struct hibmc_bo *gem_to_hibmc_bo(struct drm_gem_object *gem)int hibmc_plane_init (struct hibmc_drm_device *hidev);int hibmc_crtc_init (struct hibmc_drm_device *hidev);int hibmc_encoder_init (struct hibmc_drm_device *hidev); +int hibmc_connector_init (struct hibmc_drm_device *hidev);int hibmc_fbdev_init (struct hibmc_drm_device *hidev);void hibmc_fbdev_fini (struct hibmc_drm_device *hidev);
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c +76 -0
79 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v5 8/9 drm/hisilicon/hibmc: Add vblank interruput
In reply to Rongrong ZouAdd vblank interrupt.
--- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 47 ++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-)
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +46 -1
@@ -40,16 +40,46 @@static int hibmc_enable_vblank (struct drm_device *dev,unsigned int pipe) { +struct hibmc_drm_device *hidev = + (struct hibmc_drm_device *)dev->dev_private; + +writel (HIBMC_RAW_INTERRUPT_EN_VBLANK (1 ), + hidev->mmio +HIBMC_RAW_INTERRUPT_EN ); +return 0 ; }static void hibmc_disable_vblank (struct drm_device *dev,unsigned int pipe) { +struct hibmc_drm_device *hidev = + (struct hibmc_drm_device *)dev->dev_private; + +writel (HIBMC_RAW_INTERRUPT_EN_VBLANK (0 ), + hidev->mmio +HIBMC_RAW_INTERRUPT_EN ); +} + +irqreturn_t hibmc_drm_interrupt (int irq,void *arg) +{ +struct drm_device *dev = (struct drm_device *)arg; +struct hibmc_drm_device *hidev = + (struct hibmc_drm_device *)dev->dev_private; +struct drm_crtc *crtc = &hidev->crtc; +u32 status; + + status =readl (hidev->mmio +HIBMC_RAW_INTERRUPT ); + +if (status &HIBMC_RAW_INTERRUPT_VBLANK (1 )) { +writel (HIBMC_RAW_INTERRUPT_VBLANK (1 ), + hidev->mmio +HIBMC_RAW_INTERRUPT ); +drm_crtc_handle_vblank (crtc); + } + +return IRQ_HANDLED ; }static struct drm_driver hibmc_driver = { .driver_features =DRIVER_GEM |DRIVER_MODESET | -DRIVER_ATOMIC , +DRIVER_ATOMIC |DRIVER_HAVE_IRQ , .fops = &hibmc_fops, .name ="hibmc" , .date ="20160828" ,
@@ -63,6 +93,7 @@ static void hibmc_disable_vblank(struct drm_device *dev, unsigned int pipe) .dumb_create = hibmc_dumb_create, .dumb_map_offset = hibmc_dumb_mmap_offset, .dumb_destroy = drm_gem_dumb_destroy, + .irq_handler = hibmc_drm_interrupt, };static int hibmc_pm_suspend (struct device *dev)
@@ -272,6 +303,20 @@ static int hibmc_load(struct drm_device *dev, unsigned long flags)if (ret) goto err; + ret =drm_vblank_init (dev, dev->mode_config.num_crtc); +if (ret) { +DRM_ERROR ("failed to initialize vblank.\n" ); + goto err; + } + +if (pci_enable_msi (dev->pdev)) { +DRM_ERROR ("Enabling MSI failed!\n" ); + }else { + ret =drm_irq_install (dev, dev->pdev->irq); +if (ret) +DRM_ERROR ("install irq failed , ret = %d\n" , ret); + } +/* reset all the states of crtc/plane/encoder/connector */ drm_mode_config_reset (dev);
Signature · 1 line
1.9.1
PATCH v5 9/9 MAINTAINERS: Update HISILICON DRM entries
In reply to Rongrong Zou--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -4117,6 +4117,7 @@ F: drivers/gpu/drm/gma500/ DRM DRIVERS FOR HISILICON M: Xinliang Liu <[email protected]> +M: Rongrong Zou <[email protected]> R: Xinwei Kong <[email protected]> R: Chen Feng <[email protected]> L: [email protected]
Signature · 1 line
1.9.1