Skip to contentSkip to conversation

Add DRM driver for Hisilicon Hibmc

PATCH Superseded Rongrong Zou 3 participants 15 messages Oct 13, 2016 – Oct 18, 2016

Subsystems (3)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 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 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
There are too many modifications, sorry for sending v3 sevaral months later.

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           |  15 +
 drivers/gpu/drm/hisilicon/hibmc/Makefile          |   5 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c    | 506 +++++++++++++++++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h    |  29 ++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   | 425 ++++++++++++++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   | 120 +++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 259 ++++++++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c |  88 ++++
 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  | 173 +++++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c       | 575 ++++++++++++++++++++++
 15 files changed, 2438 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 · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v3 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           |  15 ++
 drivers/gpu/drm/hisilicon/hibmc/Makefile          |   5 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   | 288 ++++++++++++++++++++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   |  41 +++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c |  88 +++++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h |  28 +++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_regs.h  | 212 ++++++++++++++++
 9 files changed, 679 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
index 558c61b..2fd2724 100644
@@ -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
index e3f6d49..c8155bf 100644
@@ -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 +15 -0
new file mode 100644
index 0000000..277f9c8
@@ -0,0 +1,15 @@
+config DRM_HISI_HIBMC
+	tristate "DRM Support for Hisilicon Hibmc"
+	depends on DRM && PCI
+	select DRM_KMS_HELPER
+	select DRM_KMS_FB_HELPER
+	select DRM_GEM_CMA_HELPER
+	select DRM_KMS_CMA_HELPER
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select DRM_TTM
+
+	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
new file mode 100644
index 0000000..97cf4a0
@@ -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 +288 -0

288 lines not on this page · raw message

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h new file +41 -0

41 lines not on this page · raw message

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.c new file +88 -0

88 lines not on this page · raw message

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_power.h new file +28 -0
new file mode 100644
index 0000000..c7efb3a
@@ -0,0 +1,28 @@
+/* Hisilicon Hibmc SoC drm driver
+ *
+ * Based on the bochs drm driver.
+ *
+ * Copyright (c) 2016 Huawei Limited.
+ *
+ * Author:
+ *	Rongrong Zou <zourongrong@huawei>
+ *	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 · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH v3 1/9] drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver

[snip]

drivers/gpu/drm/hisilicon/hibmc/Kconfig line 7

Quoted 10 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +7 -0
@@ -0,0 +1,15 @@
+config DRM_HISI_HIBMC
+       tristate "DRM Support for Hisilicon Hibmc"
+       depends on DRM && PCI
+       select DRM_KMS_HELPER
+       select DRM_KMS_FB_HELPER
+       select DRM_GEM_CMA_HELPER
+       select DRM_KMS_CMA_HELPER

since you use TTM I don't think that selecting DRM_GEM_CMA_HELPER and DRM_KMS_CMA_HELPER
help you lot here.
You could add configuration flags step by step in following patches that will make you needs more clear (that also true for #include)

Quoted 25 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +8 -0
+       select FB_SYS_FILLRECT
+       select FB_SYS_COPYAREA
+       select FB_SYS_IMAGEBLIT
+       select DRM_TTM
+
+       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
new file mode 100644
index 0000000..97cf4a0
@@ -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 +0 -0
new file mode 100644
index 0000000..52c9353

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 8

Quoted 8 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +8 -0
@@ -0,0 +1,288 @@
+/* Hisilicon Hibmc SoC drm driver
+ *
+ * Based on the bochs drm driver.
+ *
+ * Copyright (c) 2016 Huawei Limited.
+ *
+ * Author:
+ *     Rongrong Zou <zourongrong@huawei>

".com" is missing in you email address (same typo in all other files)

Quoted 7 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +7 -0
+ *     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.

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 25

Quoted 10 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +10 -0
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/console.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>

cma_helpers look useless since you use TTM, no ?

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 31

Quoted 6 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +6 -0
+#include <drm/drmP.h>
+
+#include "hibmc_drm_drv.h"
+#include "hibmc_drm_regs.h"
+#include "hibmc_drm_power.h"
+

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH v3 1/9] drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver

Hi Benjamin,

Thanks for reviewing!

Benjamin Gaignard 於 2016/10/14 16:29 寫道:

Quoted 18 lines

[snip]

drivers/gpu/drm/hisilicon/hibmc/Kconfig line 7

Quoted 10 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +7 -0
@@ -0,0 +1,15 @@
+config DRM_HISI_HIBMC
+       tristate "DRM Support for Hisilicon Hibmc"
+       depends on DRM && PCI
+       select DRM_KMS_HELPER
+       select DRM_KMS_FB_HELPER
+       select DRM_GEM_CMA_HELPER
+       select DRM_KMS_CMA_HELPER

since you use TTM I don't think that selecting DRM_GEM_CMA_HELPER and DRM_KMS_CMA_HELPER
help you lot here.
You could add configuration flags step by step in following patches that will make you needs more clear (that also true for #include)

will delete them, thanks.

Quoted 28 lines
Quoted 28 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +8 -0
+       select FB_SYS_FILLRECT
+       select FB_SYS_COPYAREA
+       select FB_SYS_IMAGEBLIT
+       select DRM_TTM
+
+       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
new file mode 100644
index 0000000..97cf4a0
@@ -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 +2 -0
new file mode 100644
index 0000000..52c9353
@@ -0,0 +1,288 @@
+/* Hisilicon Hibmc SoC drm driver
+ *
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 8

Quoted 6 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +6 -0
+ * Based on the bochs drm driver.
+ *
+ * Copyright (c) 2016 Huawei Limited.
+ *
+ * Author:
+ *     Rongrong Zou <zourongrong@huawei>

".com" is missing in you email address (same typo in all other files)

will fix it in next version, thanks. :)

Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +11 -0
+ *     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.
+ *
+ */
+
+#include <linux/module.h>
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 25

Quoted 6 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +6 -0
+#include <linux/console.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>

cma_helpers look useless since you use TTM, no ?

I add TTM just in this version, and forgot to clean these cma relevant code, will fix in next version. Thanks.

Quoted 7 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 31

Quoted 7 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +6 -0
+#include <drm/drmP.h>
+
+#include "hibmc_drm_drv.h"
+#include "hibmc_drm_regs.h"
+#include "hibmc_drm_power.h"
+

Regards,
Rongrong
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#4 lore raw

Re: [PATCH v3 1/9] drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver

Just by curiosity, why using "old" TTM instead of GEM ? any particular reasons ?

2016-10-14 16:44 GMT+02:00 Rongrong Zou <[email protected]>:

Quoted 110 lines

Hi Benjamin,

Thanks for reviewing!

Benjamin Gaignard 於 2016/10/14 16:29 寫道:

Quoted 12 lines

[snip]

Quoted 9 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +6 -0
@@ -0,0 +1,15 @@
+config DRM_HISI_HIBMC
+       tristate "DRM Support for Hisilicon Hibmc"
+       depends on DRM && PCI
+       select DRM_KMS_HELPER
+       select DRM_KMS_FB_HELPER
+       select DRM_GEM_CMA_HELPER
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/Kconfig line 7

Quoted 1 line
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +1 -0
+       select DRM_KMS_CMA_HELPER

since you use TTM I don't think that selecting DRM_GEM_CMA_HELPER and DRM_KMS_CMA_HELPER
help you lot here.
You could add configuration flags step by step in following patches that will make you needs more clear (that also true for #include)

will delete them, thanks.

Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +8 -0
+       select FB_SYS_FILLRECT
+       select FB_SYS_COPYAREA
+       select FB_SYS_IMAGEBLIT
+       select DRM_TTM
+
+       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
new file mode 100644
index 0000000..97cf4a0
@@ -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 +3 -0
new file mode 100644
index 0000000..52c9353
@@ -0,0 +1,288 @@
+/* Hisilicon Hibmc SoC drm driver
+ *
+ * Based on the bochs drm driver.
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 8

Quoted 5 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +5 -0
+ *
+ * Copyright (c) 2016 Huawei Limited.
+ *
+ * Author:
+ *     Rongrong Zou <zourongrong@huawei>

".com" is missing in you email address (same typo in all other files)

will fix it in next version, thanks. :)

Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +12 -0
+ *     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.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/console.h>
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 25

Quoted 5 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +5 -0
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>

cma_helpers look useless since you use TTM, no ?

I add TTM just in this version, and forgot to clean these cma relevant code, will fix in next version. Thanks.

Quoted 7 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 31

Quoted 7 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +6 -0
+#include <drm/drmP.h>
+
+#include "hibmc_drm_drv.h"
+#include "hibmc_drm_regs.h"
+#include "hibmc_drm_power.h"
+

Regards,
Rongrong

Signature · 11 lines
Benjamin Gaignard

Graphic Study Group

Linaro.org │ Open source software for ARM SoCs

Follow Linaro: Facebook | Twitter | Blog
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw

Re: [PATCH v3 1/9] drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver

Benjamin Gaignard 於 2016/10/14 22:33 寫道:

Quoted 1 line

Just by curiosity, why using "old" TTM instead of GEM ? any particular reasons ?

Do you mean i can manage the video memory visiable to pci without TTM, i found all the other simple gpu chips(eg: AST, mgag200) use TTM, so i chose TTM.

Quoted 115 lines

2016-10-14 16:44 GMT+02:00 Rongrong Zou <[email protected]>:

Quoted 110 lines

Hi Benjamin,

Thanks for reviewing!

Benjamin Gaignard 於 2016/10/14 16:29 寫道:

Quoted 12 lines

[snip]

Quoted 9 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +6 -0
@@ -0,0 +1,15 @@
+config DRM_HISI_HIBMC
+       tristate "DRM Support for Hisilicon Hibmc"
+       depends on DRM && PCI
+       select DRM_KMS_HELPER
+       select DRM_KMS_FB_HELPER
+       select DRM_GEM_CMA_HELPER
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/Kconfig line 7

Quoted 1 line
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +1 -0
+       select DRM_KMS_CMA_HELPER

since you use TTM I don't think that selecting DRM_GEM_CMA_HELPER and DRM_KMS_CMA_HELPER
help you lot here.
You could add configuration flags step by step in following patches that will make you needs more clear (that also true for #include)

will delete them, thanks.

Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +8 -0
+       select FB_SYS_FILLRECT
+       select FB_SYS_COPYAREA
+       select FB_SYS_IMAGEBLIT
+       select DRM_TTM
+
+       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
new file mode 100644
index 0000000..97cf4a0
@@ -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 +3 -0
new file mode 100644
index 0000000..52c9353
@@ -0,0 +1,288 @@
+/* Hisilicon Hibmc SoC drm driver
+ *
+ * Based on the bochs drm driver.
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 8

Quoted 5 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +5 -0
+ *
+ * Copyright (c) 2016 Huawei Limited.
+ *
+ * Author:
+ *     Rongrong Zou <zourongrong@huawei>

".com" is missing in you email address (same typo in all other files)

will fix it in next version, thanks. :)

Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +12 -0
+ *     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.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/console.h>
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 25

Quoted 5 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +5 -0
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>

cma_helpers look useless since you use TTM, no ?

I add TTM just in this version, and forgot to clean these cma relevant code, will fix in next version. Thanks.

Quoted 7 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 31

Quoted 7 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +6 -0
+#include <drm/drmP.h>
+
+#include "hibmc_drm_drv.h"
+#include "hibmc_drm_regs.h"
+#include "hibmc_drm_power.h"
+

Regards,
Rongrong

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH v3 1/9] drm/hisilicon/hibmc: Add hisilicon hibmc drm master driver

In reply to Benjamin Gaignard
Quoted 1 line · Benjamin Gaignard

Just by curiosity, why using "old" TTM instead of GEM ? any particular reasons ?

From the linux kernel DRM mm doc[1] it says:
"GEM has simpler initialization and execution requirements than
25 TTM, but has no video RAM management capabilities and is thus
limited to
26 UMA devices."

So, I think we can't use GEM to managing video RAM.
But in fact, in this driver fb buffer is also created as an GEM object though it use TTM to manage video RAM.
So GEM ,like its name, say mostly use for execution management ???

[1] Documentation/gpu/drm-mm.rst

-xinliang

Quoted 115 lines

2016-10-14 16:44 GMT+02:00 Rongrong Zou <[email protected]>:

Quoted 100 lines

Hi Benjamin,

Thanks for reviewing!

Benjamin Gaignard 於 2016/10/14 16:29 寫道:

Quoted 12 lines

[snip]

Quoted 9 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +6 -0
@@ -0,0 +1,15 @@
+config DRM_HISI_HIBMC
+       tristate "DRM Support for Hisilicon Hibmc"
+       depends on DRM && PCI
+       select DRM_KMS_HELPER
+       select DRM_KMS_FB_HELPER
+       select DRM_GEM_CMA_HELPER
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/Kconfig line 7

Quoted 1 line
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +1 -0
+       select DRM_KMS_CMA_HELPER

since you use TTM I don't think that selecting DRM_GEM_CMA_HELPER and DRM_KMS_CMA_HELPER
help you lot here.
You could add configuration flags step by step in following patches that will make you needs more clear (that also true for #include)

will delete them, thanks.

Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/hisilicon/hibmc/Kconfig new file +8 -0
+       select FB_SYS_FILLRECT
+       select FB_SYS_COPYAREA
+       select FB_SYS_IMAGEBLIT
+       select DRM_TTM
+
+       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
new file mode 100644
index 0000000..97cf4a0
@@ -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 +3 -0
new file mode 100644
index 0000000..52c9353
@@ -0,0 +1,288 @@
+/* Hisilicon Hibmc SoC drm driver
+ *
+ * Based on the bochs drm driver.
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 8

Quoted 5 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +5 -0
+ *
+ * Copyright (c) 2016 Huawei Limited.
+ *
+ * Author:
+ *     Rongrong Zou <zourongrong@huawei>

".com" is missing in you email address (same typo in all other files)

will fix it in next version, thanks. :)

Quoted 13 lines
Quoted 13 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +12 -0
+ *     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.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/console.h>
Quoted 8 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 25

Quoted 5 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +5 -0
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>

cma_helpers look useless since you use TTM, no ?

I add TTM just in this version, and forgot to clean these cma relevant code, will fix in next version. Thanks.

Quoted 1 line
Quoted 10 lines
Quoted 6 lines

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c line 31

Quoted 6 lines
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c new file +6 -0
+#include <drm/drmP.h>
+
+#include "hibmc_drm_drv.h"
+#include "hibmc_drm_regs.h"
+#include "hibmc_drm_power.h"
+

Regards,
Rongrong

Quoted 8 lines

--
Benjamin Gaignard

Graphic Study Group

Linaro.org │ Open source software for ARM SoCs

Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw

PATCH v3 2/9 drm/hisilicon/hibmc: Add video memory management

In reply to Rongrong Zou

Hibmc have 32m video memory which can be accessed through PCIe by host, we use ttm to manage these memory.

---
 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 |  44 +++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c     | 501 ++++++++++++++++++++++++
 4 files changed, 557 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
index 97cf4a0..d5c40b8 100644
@@ -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 +11 -1
index 52c9353..de3b3c3 100644
@@ -37,6 +37,7 @@
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= drm_compat_ioctl,
 #endif
+	.mmap		= hibmc_mmap,
 	.poll		= drm_poll,
 	.read		= drm_read,
 	.llseek		= no_llseek,
@@ -52,7 +53,7 @@ static void hibmc_disable_vblank(struct drm_device *dev, unsigned int pipe)
 }
 
 static struct drm_driver hibmc_driver = {
-	.driver_features	= DRIVER_ATOMIC,
+	.driver_features	= DRIVER_GEM | DRIVER_ATOMIC,
 	.fops			= &hibmc_fops,
 	.name			= "hibmc",
 	.date			= "20160828",
@@ -62,6 +63,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)
@@ -202,6 +207,11 @@ 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 +44 -0

49 lines not on this page · raw message

drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c new file +501 -0

501 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw

PATCH v3 3/9 drm/hisilicon/hibmc: Add support for frame buffer

In reply to Rongrong Zou

Add support for fbdev and kms fb management.

---
 drivers/gpu/drm/hisilicon/hibmc/Makefile          |   2 +-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c   |  18 ++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h   |  24 ++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c | 259 ++++++++++++++++++++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c       |  68 ++++++
 5 files changed, 370 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
index d5c40b8..810a37e 100644
@@ -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 +18 -0
index de3b3c3..ba31ead 100644
@@ -73,9 +73,16 @@ 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_kms_helper_poll_disable(drm_dev);
 
+	if (hidev->fbdev.initialized) {
+		console_lock();
+		drm_fb_helper_set_suspend(&hidev->fbdev.helper, 1);
+		console_unlock();
+	}
+
 	return 0;
 }
 
@@ -83,9 +90,16 @@ 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_helper_resume_force_mode(drm_dev);
 
+	if (hidev->fbdev.initialized) {
+		console_lock();
+		drm_fb_helper_set_suspend(&hidev->fbdev.helper, 0);
+		console_unlock();
+	}
+
 	drm_kms_helper_poll_enable(drm_dev);
 
 	return 0;
@@ -187,6 +201,7 @@ static int hibmc_unload(struct drm_device *dev)
 {
 	struct hibmc_drm_device *hidev = dev->dev_private;
 
+	hibmc_fbdev_fini(hidev);
 	hibmc_hw_fini(hidev);
 	dev->dev_private = NULL;
 	return 0;
@@ -208,7 +223,10 @@ static int hibmc_load(struct drm_device *dev, unsigned long flags)
 		goto err;
 
 	ret = hibmc_mm_init(hidev);
+	if (ret)
+		goto err;
 
+	ret = hibmc_fbdev_init(hidev);
 	if (ret)
 		goto err;
 
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +24 -0
index d5ef34b..c37ce2b 100644
@@ -28,6 +28,19 @@
 #include <drm/ttm/ttm_module.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;
@@ -46,9 +59,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;
@@ -70,8 +87,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);
 int hibmc_bo_pin(struct hibmc_bo *bo, u32 pl_flag, u64 *gpu_addr);
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_fbdev.c new file +259 -0

259 lines not on this page · raw message

drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c +68 -0

71 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#9 lore raw

PATCH v3 4/9 drm/hisilicon/hibmc: Add plane for DE

In reply to Rongrong Zou

Add plane funcs and helper funcs for DE.

---
 drivers/gpu/drm/hisilicon/hibmc/Makefile        |   2 +-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c  | 188 ++++++++++++++++++++++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h  |  29 ++++
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  46 +++++-
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h |   5 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c     |   6 +
 6 files changed, 274 insertions(+), 2 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/Makefile +1 -1
index 810a37e..72e107e 100644
@@ -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 +188 -0

188 lines not on this page · raw message

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.h new file +29 -0
new file mode 100644
index 0000000..c22f0a4
@@ -0,0 +1,29 @@
+/* Hisilicon Hibmc SoC drm driver
+ *
+ * Based on the bochs drm driver.
+ *
+ * Copyright (c) 2016 Huawei Limited.
+ *
+ * Author:
+ *	Rongrong Zou <zourongrong@huawei>
+ *	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 +45 -1

70 lines not on this page · raw message

drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +5 -0
index c37ce2b..19312ca 100644
@@ -50,6 +50,8 @@ struct hibmc_drm_device {
 
 	/* drm */
 	struct drm_device  *dev;
+	struct drm_plane plane;
+	bool mode_config_initialized;
 
 	/* ttm */
 	struct {
@@ -87,6 +89,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);
 
@@ -106,4 +109,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
index 0f301ac..996082b 100644
@@ -567,3 +567,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 · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#10 lore raw

PATCH v3 5/9 drm/hisilicon/hibmc: Add crtc for DE

In reply to Rongrong Zou

Add 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
index 28d2e65..5e7f171 100644
@@ -26,6 +26,7 @@
 
 #include "hibmc_drm_drv.h"
 #include "hibmc_drm_regs.h"
+#include "hibmc_drm_de.h"
 #include "hibmc_drm_power.h"
 
 /* ---------------------------------------------------------------------- */
@@ -186,3 +187,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
index bd8e8b8..b054b13 100644
@@ -135,6 +135,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
index 19312ca..b4b27c6 100644
@@ -51,6 +51,7 @@ struct hibmc_drm_device {
 	/* drm */
 	struct drm_device  *dev;
 	struct drm_plane plane;
+	struct drm_crtc crtc;
 	bool mode_config_initialized;
 
 	/* ttm */
@@ -90,6 +91,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 · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#11 lore raw

PATCH v3 6/9 drm/hisilicon/hibmc: Add encoder for VDAC

In reply to Rongrong Zou

Add 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 | 91 ++++++++++++++++++++++++
 4 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c
drivers/gpu/drm/hisilicon/hibmc/Makefile +1 -1
index 72e107e..e04f114 100644
@@ -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
index b054b13..f690798 100644
@@ -141,6 +141,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
index b4b27c6..a888f5c 100644
@@ -52,6 +52,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 */
@@ -92,6 +93,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 +91 -0

91 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#12 lore raw

PATCH v3 7/9 drm/hisilicon/hibmc: Add connector for VDAC

In reply to Rongrong Zou

Add 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 | 82 ++++++++++++++++++++++++
 3 files changed, 92 insertions(+)
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +8 -0
index f690798..7c88295 100644
@@ -147,6 +147,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
index a888f5c..db4a872 100644
@@ -53,6 +53,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 */
@@ -94,6 +95,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 +82 -0

85 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#13 lore raw

PATCH v3 8/9 drm/hisilicon/hibmc: Add vblank interruput

In reply to Rongrong Zou

Add 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
index 7c88295..8c0d492 100644
@@ -45,15 +45,45 @@
 
 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_features	= DRIVER_HAVE_IRQ | DRIVER_GEM |
 				DRIVER_MODESET | DRIVER_ATOMIC,
 	.fops			= &hibmc_fops,
 	.name			= "hibmc",
@@ -68,6 +98,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)
@@ -287,6 +318,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");
+		return ret;
+	}
+
+	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 · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#14 lore raw

PATCH v3 9/9 MAINTAINERS: Update HISILICON DRM entries

In reply to Rongrong Zou
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index 4347bce..16f4569 100644
@@ -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 · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel