Re: [PATCH v2 4/4] ARM: dts: add SKOV imx6q and imx6dl based boards

2021-07-22 Thread Shawn Guo
On Sun, Jul 18, 2021 at 10:22:14PM +0200, Sam Ravnborg wrote:
> Hi Oleksij,
> On Wed, Jul 14, 2021 at 06:53:49AM +0200, Oleksij Rempel wrote:
> > From: Sam Ravnborg 
> 
> The real author one these dts files are Juergen Borleis IIRC.
> I made some internal refactoring / renaming which is why I thing git
> says otherwise.
> So onless Juergen says otherwise we should give him the author credit.
> 
> Arnd - would it be OK if I take the bindings patches through
> drm-misc-next, and then you can take the DTS files via arm-soc?

Yeah, it makes sense to send panel-simple.yaml change (patch #1) via drm
tree.

Shawn


Re: [PATCH v2 4/4] ARM: dts: add SKOV imx6q and imx6dl based boards

2021-07-25 Thread Shawn Guo
On Wed, Jul 14, 2021 at 06:53:49AM +0200, Oleksij Rempel wrote:
> From: Sam Ravnborg 
> 
> Add SKOV imx6q/dl LT2, LT6 and mi1010ait-1cp1 boards.
> 
> Signed-off-by: Sam Ravnborg 
> Signed-off-by: Søren Andersen 
> Signed-off-by: Juergen Borleis 
> Signed-off-by: Ulrich Ölmann 
> Signed-off-by: Michael Grzeschik 
> Signed-off-by: Marco Felsch 
> Signed-off-by: Lucas Stach 
> Signed-off-by: Oleksij Rempel 
> ---
>  arch/arm/boot/dts/Makefile|   5 +
>  arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts|  13 +
>  arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts| 108 
>  arch/arm/boot/dts/imx6q-skov-revc-lt2.dts |  36 ++
>  arch/arm/boot/dts/imx6q-skov-revc-lt6.dts | 128 +
>  .../dts/imx6q-skov-reve-mi1010ait-1cp1.dts| 127 +
>  arch/arm/boot/dts/imx6qdl-skov-cpu-revc.dtsi  |  54 ++
>  arch/arm/boot/dts/imx6qdl-skov-cpu.dtsi   | 475 ++
>  8 files changed, 946 insertions(+)
>  create mode 100644 arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts
>  create mode 100644 arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts
>  create mode 100644 arch/arm/boot/dts/imx6q-skov-revc-lt2.dts
>  create mode 100644 arch/arm/boot/dts/imx6q-skov-revc-lt6.dts
>  create mode 100644 arch/arm/boot/dts/imx6q-skov-reve-mi1010ait-1cp1.dts
>  create mode 100644 arch/arm/boot/dts/imx6qdl-skov-cpu-revc.dtsi
>  create mode 100644 arch/arm/boot/dts/imx6qdl-skov-cpu.dtsi
> 
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index a2389b17026a..66aef5c6526d 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -473,6 +473,8 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
>   imx6dl-sabrelite.dtb \
>   imx6dl-sabresd.dtb \
>   imx6dl-savageboard.dtb \
> + imx6dl-skov-revc-lt2.dtb \
> + imx6dl-skov-revc-lt6.dtb \
>   imx6dl-ts4900.dtb \
>   imx6dl-ts7970.dtb \
>   imx6dl-tx6dl-comtft.dtb \
> @@ -573,6 +575,9 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
>   imx6q-sabresd.dtb \
>   imx6q-savageboard.dtb \
>   imx6q-sbc6x.dtb \
> + imx6q-skov-revc-lt2.dtb \
> + imx6q-skov-revc-lt6.dtb \
> + imx6q-skov-reve-mi1010ait-1cp1.dtb \
>   imx6q-tbs2910.dtb \
>   imx6q-ts4900.dtb \
>   imx6q-ts7970.dtb \
> diff --git a/arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts 
> b/arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts
> new file mode 100644
> index ..667b8faa1807
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts
> @@ -0,0 +1,13 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +//
> +// Copyright (C) 2020 Pengutronix, Ulrich Oelmann 
> +
> +/dts-v1/;
> +#include "imx6dl.dtsi"
> +#include "imx6qdl-skov-cpu.dtsi"
> +#include "imx6qdl-skov-cpu-revc.dtsi"
> +
> +/ {
> + model = "SKOV IMX6 CPU SoloCore";
> + compatible = "skov,imx6dl-skov-revc-lt2", "fsl,imx6dl";
> +};
> diff --git a/arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts 
> b/arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts
> new file mode 100644
> index ..25071c7c4e29
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts
> @@ -0,0 +1,108 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +//
> +// Copyright (C) 2020 Pengutronix, Ulrich Oelmann 
> +
> +/dts-v1/;
> +#include "imx6dl.dtsi"
> +#include "imx6qdl-skov-cpu.dtsi"
> +#include "imx6qdl-skov-cpu-revc.dtsi"
> +
> +/ {
> + model = "SKOV IMX6 CPU SoloCore";
> + compatible = "skov,imx6dl-skov-revc-lt6", "fsl,imx6dl";
> +
> + backlight: backlight {
> + compatible = "pwm-backlight";
> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_backlight>;
> + enable-gpios = <&gpio6 23 GPIO_ACTIVE_LOW>;
> + pwms = <&pwm2 0 2 0>;
> + brightness-levels = <0 255>;
> + num-interpolated-steps = <17>;
> + default-brightness-level = <8>;
> + power-supply = <®_24v0>;
> + };
> +
> + display {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + compatible = "fsl,imx-parallel-display";

Drop the newline and start with compatible.

> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_ipu1>;
> +
> + port@0 {
> + reg = <0>;
> +
> + display0_in: endpoint {
> + remote-endpoint = <&ipu1_di0_disp0>;
> + };
> + };
> +
> + port@1 {
> + reg = <1>;
> +
> + display0_out: endpoint {
> + remote-endpoint = <&panel_in>;
> + };
> + };
> + };
> +
> +

One newline is good enough.

> + panel {
> + compatible = "logictechno,lttd800480070-l6wh-rt";
> + backlight = <&backlight>;
> + power-supply = <®_3v3>;
> +
> + port {
> + panel_in: endpoint {
> + remote-endpoint = <&display0_out>;
> +  

[PATCH 0/2] Add Truly NT35521 panel driver support

2021-08-04 Thread Shawn Guo
It adds a drm driver for Truly NT35521 5.24" 1280x720 DSI panel, which
can be found on Sony Xperia M4 Aqua phone.

Shawn Guo (2):
  dt-bindings: display: panel: Add Truly NT35521 panel support
  drm/panel: Add Truly NT35521 panel driver

 .../bindings/display/panel/truly,nt35521.yaml |  62 +++
 drivers/gpu/drm/panel/Kconfig |   9 +
 drivers/gpu/drm/panel/Makefile|   1 +
 drivers/gpu/drm/panel/panel-truly-nt35521.c   | 491 ++
 4 files changed, 563 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/truly,nt35521.yaml
 create mode 100644 drivers/gpu/drm/panel/panel-truly-nt35521.c

-- 
2.17.1



[PATCH 1/2] dt-bindings: display: panel: Add Truly NT35521 panel support

2021-08-04 Thread Shawn Guo
The Truly NT35521 is a 5.24" 1280x720 DSI panel, and the backlight is
managed through DSI link.

Signed-off-by: Shawn Guo 
---
 .../bindings/display/panel/truly,nt35521.yaml | 62 +++
 1 file changed, 62 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/truly,nt35521.yaml

diff --git a/Documentation/devicetree/bindings/display/panel/truly,nt35521.yaml 
b/Documentation/devicetree/bindings/display/panel/truly,nt35521.yaml
new file mode 100644
index ..4727c3df6eb8
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/truly,nt35521.yaml
@@ -0,0 +1,62 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/truly,nt35521.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Truly NT35521 5.24" 1280x720 MIPI-DSI Panel
+
+maintainers:
+  - Shawn Guo 
+
+description: |
+  The Truly NT35521 is a 5.24" 1280x720 MIPI-DSI panel.  The panel backlight
+  is managed through DSI link.
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+const: truly,nt35521
+
+  reg: true
+
+  reset-gpios: true
+
+  enable-gpios: true
+
+  pwr-positive5-gpios:
+maxItems: 1
+
+  pwr-negative5-gpios:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - reset-gpios
+  - enable-gpios
+  - pwr-positive5-gpios
+  - pwr-negative5-gpios
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+dsi {
+#address-cells = <1>;
+#size-cells = <0>;
+
+panel@0 {
+compatible = "truly,nt35521";
+reg = <0>;
+reset-gpios = <&msmgpio 25 GPIO_ACTIVE_LOW>;
+pwr-positive5-gpios = <&msmgpio 114 GPIO_ACTIVE_HIGH>;
+pwr-negative5-gpios = <&msmgpio 17 GPIO_ACTIVE_HIGH>;
+enable-gpios = <&msmgpio 10 GPIO_ACTIVE_HIGH>;
+};
+};
+...
-- 
2.17.1



[PATCH 2/2] drm/panel: Add Truly NT35521 panel driver

2021-08-04 Thread Shawn Guo
It adds a drm driver for Truly NT35521 5.24" 1280x720 DSI panel, which
can be found on Sony Xperia M4 Aqua phone.  The panel backlight is
managed through DSI link.

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/panel/Kconfig   |   9 +
 drivers/gpu/drm/panel/Makefile  |   1 +
 drivers/gpu/drm/panel/panel-truly-nt35521.c | 491 
 3 files changed, 501 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-truly-nt35521.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index ef87d92cdf49..cdc4abd5c40c 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -537,6 +537,15 @@ config DRM_PANEL_TPO_TPG110
  400CH LTPS TFT LCD Single Chip Digital Driver for up to
  800x400 LCD panels.
 
+config DRM_PANEL_TRULY_NT35521
+   tristate "Truly NT35521 panel"
+   depends on OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ Say Y here if you want to enable support for Truly NT35521
+ 1280x720 DSI panel.
+
 config DRM_PANEL_TRULY_NT35597_WQXGA
tristate "Truly WQXGA"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index cae4d976c069..3d3c98cb7a7b 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += 
panel-tdo-tl070wsh30.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
+obj-$(CONFIG_DRM_PANEL_TRULY_NT35521) += panel-truly-nt35521.o
 obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o
 obj-$(CONFIG_DRM_PANEL_VISIONOX_RM69299) += panel-visionox-rm69299.o
 obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o
diff --git a/drivers/gpu/drm/panel/panel-truly-nt35521.c 
b/drivers/gpu/drm/panel/panel-truly-nt35521.c
new file mode 100644
index ..ea3cfb46be7e
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-truly-nt35521.c
@@ -0,0 +1,491 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021, Linaro Limited
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+struct nt35521_panel {
+   struct drm_panel panel;
+   struct device *dev;
+   struct gpio_desc *rst_gpio;
+   struct gpio_desc *pwrp5_gpio;
+   struct gpio_desc *pwrn5_gpio;
+   struct gpio_desc *en_gpio;
+   bool prepared;
+   bool enabled;
+};
+
+static inline struct nt35521_panel *panel_to_nt35521(struct drm_panel *panel)
+{
+   return container_of(panel, struct nt35521_panel, panel);
+}
+
+#define nt_dcs_write(seq...)   \
+({ \
+   const u8 d[] = { seq }; \
+   if (mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)) < 0)   \
+   DRM_DEV_ERROR(dev, "dcs write buffer failed\n");\
+})
+
+#define nt_gen_write(seq...)   \
+({ \
+   const u8 d[] = { seq }; \
+   if (mipi_dsi_generic_write(dsi, d, ARRAY_SIZE(d)) < 0)  \
+   DRM_DEV_ERROR(dev, "generic write buffer failed\n");\
+})
+
+static void nt35521_panel_on(struct nt35521_panel *nt)
+{
+   struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
+   struct device *dev = nt->dev;
+
+   /* Transmit data in low power mode */
+   dsi->mode_flags |= MIPI_DSI_MODE_LPM;
+
+   nt_dcs_write(0xf0, 0x55, 0xaa, 0x52, 0x08, 0x00);
+   nt_dcs_write(0xff, 0xaa, 0x55, 0xa5, 0x80);
+   nt_dcs_write(0x6f, 0x11, 0x00);
+   nt_dcs_write(0xf7, 0x20, 0x00);
+   nt_dcs_write(0x6f, 0x01);
+   nt_dcs_write(0xb1, 0x21);
+   nt_dcs_write(0xbd, 0x01, 0xa0, 0x10, 0x08, 0x01);
+   nt_dcs_write(0xb8, 0x01, 0x02, 0x0c, 0x02);
+   nt_dcs_write(0xbb, 0x11, 0x11);
+   nt_dcs_write(0xbc, 0x00, 0x00);
+   nt_dcs_write(0xb6, 0x02);
+   nt_dcs_write(0xf0, 0x55, 0xaa, 0x52, 0x08, 0x01);
+   nt_dcs_write(0xb0, 0x09, 0x09);
+   nt_dcs_write(0xb1, 0x09, 0x09);
+   nt_dcs_write(0xbc, 0x8c, 0x00);
+   nt_dcs_write(0xbd, 0x8c, 0x00);
+   nt_dcs_write(0xca, 0x00);
+   nt_dcs_write(0xc0, 0x04);
+   nt_dcs_write(0xbe, 0xb5);
+   nt_dcs_write(0xb3, 0x35, 0x35);
+   nt_dcs_write(0xb4, 0x25, 0x25);
+   nt_dcs_write(0xb9, 0x43, 0x43);
+   nt_dcs_write(0xba, 0x24, 0x24);
+   nt_dcs_write(0xf0, 0x55, 0xaa, 0x52, 0x08, 0x02);
+   nt_dcs_write(0xee, 0x03);
+   nt_dcs_write(0xb0, 0x00, 0xb2, 0x00, 0xb3, 0x00, 0xb6, 0x00,
+  

Re: [PATCH 1/2] dt-bindings: display: panel: Add Truly NT35521 panel support

2021-08-08 Thread Shawn Guo
On Wed, Aug 04, 2021 at 06:03:54PM +0200, Sam Ravnborg wrote:
> Hi Shawn,
> 
> On Wed, Aug 04, 2021 at 04:13:51PM +0800, Shawn Guo wrote:
> > The Truly NT35521 is a 5.24" 1280x720 DSI panel, and the backlight is
> > managed through DSI link.
> > 
> > Signed-off-by: Shawn Guo 
> 
> Please consider adding an optional port node, so we can use this panels
> in a setup using a graph.

Sure, will do in v2.

> A simple port: true would do the trick.
> I am aware that it may not be used today, this is a preparation for
> potential future use.
> 
> With this fixed,
> Reviewed-by: Sam Ravnborg 

Thanks, Sam!

Shawn


Re: [PATCH 2/2] drm/panel: Add Truly NT35521 panel driver

2021-08-08 Thread Shawn Guo
Hi Stephan,

Thanks for looking at the patch!

On Wed, Aug 04, 2021 at 02:09:19PM +0200, Stephan Gerhold wrote:
> Hi Shawn,
> 
> Thanks for the patch!
> 
> On Wed, Aug 04, 2021 at 04:13:52PM +0800, Shawn Guo wrote:
> > It adds a drm driver for Truly NT35521 5.24" 1280x720 DSI panel, which
> > can be found on Sony Xperia M4 Aqua phone.  The panel backlight is
> > managed through DSI link.
> > 
> > Signed-off-by: Shawn Guo 
> > ---
> >  drivers/gpu/drm/panel/Kconfig   |   9 +
> >  drivers/gpu/drm/panel/Makefile  |   1 +
> >  drivers/gpu/drm/panel/panel-truly-nt35521.c | 491 
> >  3 files changed, 501 insertions(+)
> >  create mode 100644 drivers/gpu/drm/panel/panel-truly-nt35521.c
> > 
> > diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> > index ef87d92cdf49..cdc4abd5c40c 100644
> > --- a/drivers/gpu/drm/panel/Kconfig
> > +++ b/drivers/gpu/drm/panel/Kconfig
> > @@ -537,6 +537,15 @@ config DRM_PANEL_TPO_TPG110
> >   400CH LTPS TFT LCD Single Chip Digital Driver for up to
> >   800x400 LCD panels.
> >  
> > +config DRM_PANEL_TRULY_NT35521
> > +   tristate "Truly NT35521 panel"
> 
> I think the name "Truly NT35521" is a bit too generic. AFAIK "Truly" is
> a panel vendor and the NovaTek NT35521 is the panel controller. But
> there are almost certainly other Truly panels that were also combined
> with a NT35521 but need a slightly different configuration.
> 
> If you don't know more than "Truly NT35521" based on the Sony sources,
> maybe do it similar to "asus,z00t-tm5p5-n35596" and use a compatible
> like "sony,-truly-nt35521". Would be good to clarify the Kconfig
> option here too.

Sounds good!

> 
> > +   depends on OF
> > +   depends on DRM_MIPI_DSI
> > +   depends on BACKLIGHT_CLASS_DEVICE
> > +   help
> > + Say Y here if you want to enable support for Truly NT35521
> > + 1280x720 DSI panel.
> > +
> >  config DRM_PANEL_TRULY_NT35597_WQXGA
> > tristate "Truly WQXGA"
> > depends on OF
> > diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> > index cae4d976c069..3d3c98cb7a7b 100644
> > --- a/drivers/gpu/drm/panel/Makefile
> > +++ b/drivers/gpu/drm/panel/Makefile
> > @@ -56,6 +56,7 @@ obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += 
> > panel-tdo-tl070wsh30.o
> >  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
> >  obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
> >  obj-$(CONFIG_DRM_PANEL_TPO_TPG110) += panel-tpo-tpg110.o
> > +obj-$(CONFIG_DRM_PANEL_TRULY_NT35521) += panel-truly-nt35521.o
> >  obj-$(CONFIG_DRM_PANEL_TRULY_NT35597_WQXGA) += panel-truly-nt35597.o
> >  obj-$(CONFIG_DRM_PANEL_VISIONOX_RM69299) += panel-visionox-rm69299.o
> >  obj-$(CONFIG_DRM_PANEL_XINPENG_XPP055C272) += panel-xinpeng-xpp055c272.o
> > diff --git a/drivers/gpu/drm/panel/panel-truly-nt35521.c 
> > b/drivers/gpu/drm/panel/panel-truly-nt35521.c
> > new file mode 100644
> > index ..ea3cfb46be7e
> > --- /dev/null
> > +++ b/drivers/gpu/drm/panel/panel-truly-nt35521.c
> > @@ -0,0 +1,491 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (c) 2021, Linaro Limited
> > + */
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#include 
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +struct nt35521_panel {
> > +   struct drm_panel panel;
> > +   struct device *dev;
> > +   struct gpio_desc *rst_gpio;
> > +   struct gpio_desc *pwrp5_gpio;
> > +   struct gpio_desc *pwrn5_gpio;
> > +   struct gpio_desc *en_gpio;
> > +   bool prepared;
> > +   bool enabled;
> > +};
> > +
> > +static inline struct nt35521_panel *panel_to_nt35521(struct drm_panel 
> > *panel)
> > +{
> > +   return container_of(panel, struct nt35521_panel, panel);
> > +}
> > +
> > +#define nt_dcs_write(seq...)   
> > \
> > +({ \
> > +   const u8 d[] = { seq }; \
> > +   if (mipi_dsi_dcs_write_buffer(dsi, d, ARRAY_SIZE(d)) < 0)   \
> > +   DRM_DEV_ERROR(dev, "dcs write buffer failed\n");\
> > +})
> > +
> > +#define nt_gen_write(seq...)

Re: [PATCH 2/2] drm/panel: Add Truly NT35521 panel driver

2021-08-08 Thread Shawn Guo
Hi Sam,

On Wed, Aug 04, 2021 at 06:24:12PM +0200, Sam Ravnborg wrote:
> Hi Shawn,
> 
> see a few comments in the following.

Thanks for the review comments!  All of them will be addressed in v2.

Shawn

> On Wed, Aug 04, 2021 at 04:13:52PM +0800, Shawn Guo wrote:
> > It adds a drm driver for Truly NT35521 5.24" 1280x720 DSI panel, which
> > can be found on Sony Xperia M4 Aqua phone.  The panel backlight is
> > managed through DSI link.
> > 
> > Signed-off-by: Shawn Guo 
> > ---
> >  drivers/gpu/drm/panel/Kconfig   |   9 +
> >  drivers/gpu/drm/panel/Makefile  |   1 +
> >  drivers/gpu/drm/panel/panel-truly-nt35521.c | 491 
> >  3 files changed, 501 insertions(+)
> >  create mode 100644 drivers/gpu/drm/panel/panel-truly-nt35521.c


Re: [PATCH 2/2] drm/panel: Add Truly NT35521 panel driver

2021-08-08 Thread Shawn Guo
On Sun, Aug 08, 2021 at 05:29:30PM +0200, Stephan Gerhold wrote:
> > 2) The driver works good, if the kernel is launched via "fastboot boot".
> >But if the kernel is flashed to eMMC and launched by bootloader with
> >splash screen, kernel will fail to bring up the panel.  After kernel
> >boots up, a blank & unblank cycle can get panel work though.
> > 
> > The problem 2) is not driver generator related.  @Konrad, did you see
> > it on asus-z00t-tm5p5-n35596 driver?
> > 
> 
> Do you have CONFIG_DRM_MSM=y (built-in) instead of =m (module) maybe?
> I think a similar issue exists on MSM8916 but it does not happen
> for some reason if CONFIG_DRM_MSM=m instead of =y. Somehow having it
> load later during the boot process fixes some things there.

Indeed!  I have CONFIG_DRM_MSM=y in my build, and changing it to module
removes the problem.  Thanks much for the hint, Stephan!

Shawn


[PATCH v2 0/2] Add Sony Tulip Truly NT35521 panel support

2021-08-08 Thread Shawn Guo
It adds driver for Sony Tulip Truly NT35521 5.24" 1280x720 DSI panel,
which can be found on Sony Xperia M4 Aqua phone.

Changes for v2:
- Add `port` node into bindings.
- Re-create the driver using linux-mdss-dsi-panel-driver-generator[1].
- Rename the driver to include Sony Tulip.
- Model 5V control GPIOs with regulators.
- Rename Backlight GPIO as "backlight-gpios".

[1] https://github.com/msm8916-mainline/linux-mdss-dsi-panel-driver-generator

Shawn Guo (2):
  dt-bindings: display: Add Sony Tulip Truly NT35521 panel support
  drm/panel: Add Sony Tulip Truly NT35521 driver

 .../panel/sony,tulip-truly-nt35521.yaml   |  72 +++
 drivers/gpu/drm/panel/Kconfig |  10 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../panel/panel-sony-tulip-truly-nt35521.c| 552 ++
 4 files changed, 635 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/sony,tulip-truly-nt35521.yaml
 create mode 100644 drivers/gpu/drm/panel/panel-sony-tulip-truly-nt35521.c

-- 
2.17.1



[PATCH v2 1/2] dt-bindings: display: Add Sony Tulip Truly NT35521 panel support

2021-08-08 Thread Shawn Guo
The Sony Tulip Truly NT35521 is a 5.24" 1280x720 DSI panel, which can
be found on Sony Xperia M4 Aqua phone.  The backlight is managed
through DSI link.

Signed-off-by: Shawn Guo 
---
 .../panel/sony,tulip-truly-nt35521.yaml   | 72 +++
 1 file changed, 72 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/panel/sony,tulip-truly-nt35521.yaml

diff --git 
a/Documentation/devicetree/bindings/display/panel/sony,tulip-truly-nt35521.yaml 
b/Documentation/devicetree/bindings/display/panel/sony,tulip-truly-nt35521.yaml
new file mode 100644
index ..967972939598
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/display/panel/sony,tulip-truly-nt35521.yaml
@@ -0,0 +1,72 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/sony,tulip-truly-nt35521.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sony Tulip Truly NT35521 5.24" 1280x720 MIPI-DSI Panel
+
+maintainers:
+  - Shawn Guo 
+
+description: |
+  The Sony Tulip Truly NT35521 is a 5.24" 1280x720 MIPI-DSI panel, which
+  can be found no Sony Xperia M4 phone.  The panel backlight is managed
+  through DSI link.
+
+allOf:
+  - $ref: panel-common.yaml#
+
+properties:
+  compatible:
+const: sony,tulip-truly-nt35521
+
+  reg: true
+
+  positive5-supply:
+description: Positive 5V supply
+
+  negative5-supply:
+description: Negative 5V supply
+
+  reset-gpios: true
+
+  enable-gpios: true
+
+  port: true
+
+required:
+  - compatible
+  - reg
+  - positive5-supply
+  - negative5-supply
+  - reset-gpios
+  - enable-gpios
+  - port
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+
+dsi {
+#address-cells = <1>;
+#size-cells = <0>;
+
+panel@0 {
+compatible = "sony,tulip-truly-nt35521";
+reg = <0>;
+positive5-supply = <&positive5_reg>;
+negative5-supply = <&negative5_reg>;
+reset-gpios = <&msmgpio 25 GPIO_ACTIVE_LOW>;
+enable-gpios = <&msmgpio 10 GPIO_ACTIVE_HIGH>;
+
+port {
+panel_in: endpoint {
+remote-endpoint = <&dsi0_out>;
+};
+};
+};
+};
+...
-- 
2.17.1



[PATCH v2 2/2] drm/panel: Add Sony Tulip Truly NT35521 driver

2021-08-08 Thread Shawn Guo
It adds a DRM panel driver for Sony Tulip Truly NT35521 5.24" 1280x720
DSI panel, which can be found on Sony Xperia M4 Aqua phone.  The panel
backlight is managed through DSI link.

The driver is built using linux-mdss-dsi-panel-driver-generator[1], and
additionally modeling the 5V control GPIOs with regulators and adding
Backlight GPIO support.

[1] https://github.com/msm8916-mainline/linux-mdss-dsi-panel-driver-generator

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/panel/Kconfig |  10 +
 drivers/gpu/drm/panel/Makefile|   1 +
 .../panel/panel-sony-tulip-truly-nt35521.c| 552 ++
 3 files changed, 563 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-sony-tulip-truly-nt35521.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index ef87d92cdf49..a5809eab49b2 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -502,6 +502,16 @@ config DRM_PANEL_SONY_ACX565AKM
  Say Y here if you want to enable support for the Sony ACX565AKM
  800x600 3.5" panel (found on the Nokia N900).
 
+config DRM_PANEL_SONY_TULIP_TRULY_NT35521
+   tristate "Sony Tulip Truly NT35521 panel"
+   depends on GPIOLIB && OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ Say Y here if you want to enable support for the Sony Tulip
+ NT35521 1280x720 video mode panel as found on Sony Xperia M4
+ Aqua phone.
+
 config DRM_PANEL_TDO_TL070WSH30
tristate "TDO TL070WSH30 DSI panel"
depends on OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index cae4d976c069..852ce32d58ee 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -52,6 +52,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += 
panel-sitronix-st7703.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX424AKP) += panel-sony-acx424akp.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
+obj-$(CONFIG_DRM_PANEL_SONY_TULIP_TRULY_NT35521) += 
panel-sony-tulip-truly-nt35521.o
 obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD043MTEA1) += panel-tpo-td043mtea1.o
diff --git a/drivers/gpu/drm/panel/panel-sony-tulip-truly-nt35521.c 
b/drivers/gpu/drm/panel/panel-sony-tulip-truly-nt35521.c
new file mode 100644
index ..eba926c6f722
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-sony-tulip-truly-nt35521.c
@@ -0,0 +1,552 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2021, Linaro Limited
+ *
+ * Generated with linux-mdss-dsi-panel-driver-generator from vendor device 
tree:
+ *   Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+struct truly_nt35521 {
+   struct drm_panel panel;
+   struct mipi_dsi_device *dsi;
+   struct regulator_bulk_data supplies[2];
+   struct gpio_desc *reset_gpio;
+   struct gpio_desc *blen_gpio;
+   bool prepared;
+   bool enabled;
+};
+
+static inline
+struct truly_nt35521 *to_truly_nt35521(struct drm_panel *panel)
+{
+   return container_of(panel, struct truly_nt35521, panel);
+}
+
+#define dsi_generic_write_seq(dsi, seq...) do {
\
+   static const u8 d[] = { seq };  \
+   int ret;\
+   ret = mipi_dsi_generic_write(dsi, d, ARRAY_SIZE(d));\
+   if (ret < 0)\
+   return ret; \
+   } while (0)
+
+static void truly_nt35521_reset(struct truly_nt35521 *ctx)
+{
+   gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+   usleep_range(1000, 2000);
+   gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+   usleep_range(1, 11000);
+   gpiod_set_value_cansleep(ctx->reset_gpio, 0);
+   msleep(150);
+}
+
+static int truly_nt35521_on(struct truly_nt35521 *ctx)
+{
+   struct mipi_dsi_device *dsi = ctx->dsi;
+   struct device *dev = &dsi->dev;
+   int ret;
+
+   dsi->mode_flags |= MIPI_DSI_MODE_LPM;
+
+   dsi_generic_write_seq(dsi, 0xf0, 0x55, 0xaa, 0x52, 0x08, 0x00);
+   dsi_generic_write_seq(dsi, 0xff, 0xaa, 0x55, 0xa5, 0x80);
+   dsi_generic_write_seq(dsi, 0x6f, 0x11, 0x00);
+   dsi_generic_write_seq(dsi, 0xf7, 0x20, 0x00);
+   dsi_generic_write_seq(dsi, 0x6f, 0x01);
+   dsi_generic_write_seq(dsi, 0xb1, 0x21);
+   dsi_generic_write_seq(dsi, 0xbd, 0x01, 0xa0, 0x10, 0x08, 0x01);
+   dsi_generic_write_seq(dsi, 0xb8, 0x01, 0x02, 0x0c, 0x02);
+   dsi_generic_write_seq(dsi, 0

Re: [PATCH 1/2] dt-bindings: display: panel: Add Truly NT35521 panel support

2021-08-13 Thread Shawn Guo
On Wed, Aug 11, 2021 at 12:51:56PM -0600, Rob Herring wrote:
> On Wed, Aug 04, 2021 at 04:13:51PM +0800, Shawn Guo wrote:
> > The Truly NT35521 is a 5.24" 1280x720 DSI panel, and the backlight is
> > managed through DSI link.
> > 
> > Signed-off-by: Shawn Guo 
> > ---
> >  .../bindings/display/panel/truly,nt35521.yaml | 62 +++
> >  1 file changed, 62 insertions(+)
> >  create mode 100644 
> > Documentation/devicetree/bindings/display/panel/truly,nt35521.yaml
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/display/panel/truly,nt35521.yaml 
> > b/Documentation/devicetree/bindings/display/panel/truly,nt35521.yaml
> > new file mode 100644
> > index ..4727c3df6eb8
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/display/panel/truly,nt35521.yaml
> > @@ -0,0 +1,62 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/display/panel/truly,nt35521.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Truly NT35521 5.24" 1280x720 MIPI-DSI Panel
> > +
> > +maintainers:
> > +  - Shawn Guo 
> > +
> > +description: |
> > +  The Truly NT35521 is a 5.24" 1280x720 MIPI-DSI panel.  The panel 
> > backlight
> > +  is managed through DSI link.
> > +
> > +allOf:
> > +  - $ref: panel-common.yaml#
> > +
> > +properties:
> > +  compatible:
> > +const: truly,nt35521
> > +
> > +  reg: true
> > +
> > +  reset-gpios: true
> > +
> > +  enable-gpios: true
> > +
> > +  pwr-positive5-gpios:
> > +maxItems: 1
> > +
> > +  pwr-negative5-gpios:
> > +maxItems: 1
> 
> Are these +/-5V supplies? If so, they should be modeled with 
> gpio-regulator perhaps unless the panel connection could only ever be 
> GPIOs.

Hi Rob,

The binding has been updated in v2 [1].  Please help review that.
Thanks!

Shawn

[1] 
https://lore.kernel.org/linux-arm-msm/20210809051008.6172-2-shawn@linaro.org/T/#m587035a602b1be6c5326dcf24af01b3e8a5d2cc9

> 
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - reset-gpios
> > +  - enable-gpios
> > +  - pwr-positive5-gpios
> > +  - pwr-negative5-gpios
> > +
> > +additionalProperties: false
> > +
> > +examples:
> > +  - |
> > +#include 
> > +
> > +dsi {
> > +#address-cells = <1>;
> > +#size-cells = <0>;
> > +
> > +panel@0 {
> > +compatible = "truly,nt35521";
> > +reg = <0>;
> > +reset-gpios = <&msmgpio 25 GPIO_ACTIVE_LOW>;
> > +pwr-positive5-gpios = <&msmgpio 114 GPIO_ACTIVE_HIGH>;
> > +pwr-negative5-gpios = <&msmgpio 17 GPIO_ACTIVE_HIGH>;
> > +enable-gpios = <&msmgpio 10 GPIO_ACTIVE_HIGH>;
> > +};
> > +};
> > +...
> > -- 
> > 2.17.1
> > 
> > 


Re: [PATCH v34 0/3] Mainline imx6 based SKOV boards

2021-08-13 Thread Shawn Guo
On Wed, Aug 04, 2021 at 06:34:36AM +0200, Oleksij Rempel wrote:
> changes v4:
> - add vref-supply to adc@0
> - split gpio assignment for the mdio node
> 
> changes v3:
> - drop panel bindings patches, it is already in drm-misc-next
> - remove some new lines
> - reorder compatibles at the start of the nodes
> - use lowercase for hex value
> - add enable-active-high to the regulator-vcc-mmc-io and fix MMC voltage
>   configuration.
> 
> changes v2:
> - remove unnecessary newlines.
> - change linux,wakeup to wakeup-source
> - change switch@3 unit-address to @0
> - sort aliases alphabetically
> 
> Mainline imx6 based DTs for SKOV A/S boards
> 
> Oleksij Rempel (2):
>   dt-bindings: vendor-prefixes: Add an entry for SKOV A/S
>   dt-bindings: arm: fsl: add SKOV imx6q and imx6dl based boards
> 
> Sam Ravnborg (1):
>   ARM: dts: add SKOV imx6q and imx6dl based boards

Applied, thanks!


Re: [PATCH v2 2/2] drm/panel: Add Sony Tulip Truly NT35521 driver

2021-08-23 Thread Shawn Guo
On Mon, Aug 09, 2021 at 01:10:08PM +0800, Shawn Guo wrote:
> It adds a DRM panel driver for Sony Tulip Truly NT35521 5.24" 1280x720
> DSI panel, which can be found on Sony Xperia M4 Aqua phone.  The panel
> backlight is managed through DSI link.
> 
> The driver is built using linux-mdss-dsi-panel-driver-generator[1], and
> additionally modeling the 5V control GPIOs with regulators and adding
> Backlight GPIO support.
> 
> [1] https://github.com/msm8916-mainline/linux-mdss-dsi-panel-driver-generator
> 
> Signed-off-by: Shawn Guo 

Sam, Stephan,

Thank you for the review comments on v1!  How does v2 look to you?

Shawn


Re: [PATCH] Revert "i2c: qcom-geni: Disable DMA processing on the Lenovo Yoga C630"

2020-11-29 Thread Shawn Guo
On Tue, Nov 24, 2020 at 12:57:43PM -0600, Bjorn Andersson wrote:
> A combination of recent bug fixes by Doug Anderson and the proper
> definition of iommu streams means that this hack is no longer needed.
> Let's clean up the code by reverting '127068abe85b ("i2c: qcom-geni:
> Disable DMA processing on the Lenovo Yoga C630")'.
> 
> Signed-off-by: Bjorn Andersson 

Acked-by: Shawn Guo 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/bridge: ti-sn65dsi86: Implement the pwm_chip

2020-12-09 Thread Shawn Guo
On Mon, Dec 07, 2020 at 10:40:22PM -0600, Bjorn Andersson wrote:
> The SN65DSI86 provides the ability to supply a PWM signal on GPIO 4,
> with the primary purpose of controlling the backlight of the attached
> panel. Add an implementation that exposes this using the standard PWM
> framework, to allow e.g. pwm-backlight to expose this to the user.
> 
> Special thanks to Doug Anderson for suggestions related to the involved
> math.
> 
> Signed-off-by: Bjorn Andersson 
> ---
>  drivers/gpu/drm/bridge/ti-sn65dsi86.c | 202 ++
>  1 file changed, 202 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c 
> b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> index f27306c51e4d..43c0acba57ab 100644
> --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
> @@ -4,6 +4,7 @@
>   * datasheet: https://www.ti.com/lit/ds/symlink/sn65dsi86.pdf
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -14,6 +15,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -89,6 +91,11 @@
>  #define SN_ML_TX_MODE_REG0x96
>  #define  ML_TX_MAIN_LINK_OFF 0
>  #define  ML_TX_NORMAL_MODE   BIT(0)
> +#define SN_PWM_PRE_DIV_REG   0xA0
> +#define SN_BACKLIGHT_SCALE_REG   0xA1
> +#define  BACKLIGHT_SCALE_MAX 0x
> +#define SN_BACKLIGHT_REG 0xA3
> +#define SN_PWM_EN_INV_REG0xA5
>  #define SN_AUX_CMD_STATUS_REG0xF4
>  #define  AUX_IRQ_STATUS_AUX_RPLY_TOUTBIT(3)
>  #define  AUX_IRQ_STATUS_AUX_SHORTBIT(5)
> @@ -111,6 +118,8 @@
>  
>  #define SN_LINK_TRAINING_TRIES   10
>  
> +#define SN_PWM_GPIO  3

So this maps to the GPIO4 described in sn65dsi86 datasheet.  I'm
wondering if it's more readable to define the following SHIFT constants
(your code), and use GPIO_MUX_GPIO4_SHIFT >> 2 where you need GPIO
offset?

#define  GPIO_MUX_GPIO1_SHIFT   0
#define  GPIO_MUX_GPIO2_SHIFT   2
#define  GPIO_MUX_GPIO3_SHIFT   4
#define  GPIO_MUX_GPIO4_SHIFT   6

If you agree, you may consider to integrate this patch beforehand:

https://github.com/shawnguo2/linux/commit/7cde887ffb3b27a36e77a08bee3666d14968b586


Shawn

> +
>  /**
>   * struct ti_sn_bridge - Platform data for ti-sn65dsi86 driver.
>   * @dev:  Pointer to our device.
> @@ -162,6 +171,12 @@ struct ti_sn_bridge {
>   struct gpio_chipgchip;
>   DECLARE_BITMAP(gchip_output, SN_NUM_GPIOS);
>  #endif
> +#if defined(CONFIG_PWM)
> + struct pwm_chip pchip;
> + boolpwm_enabled;
> + unsigned intpwm_refclk;
> + atomic_tpwm_pin_busy;
> +#endif
>  };
>  
>  static const struct regmap_range ti_sn_bridge_volatile_ranges[] = {
> @@ -499,6 +514,14 @@ static void ti_sn_bridge_set_refclk_freq(struct 
> ti_sn_bridge *pdata)
>  
>   regmap_update_bits(pdata->regmap, SN_DPPLL_SRC_REG, REFCLK_FREQ_MASK,
>  REFCLK_FREQ(i));
> +
> +#if defined(CONFIG_PWM)
> + /*
> +  * The PWM refclk is based on the value written to SN_DPPLL_SRC_REG,
> +  * regardless of its actual sourcing.
> +  */
> + pdata->pwm_refclk = ti_sn_bridge_refclk_lut[i];
> +#endif
>  }
>  
>  static void ti_sn_bridge_set_dsi_rate(struct ti_sn_bridge *pdata)
> @@ -981,6 +1004,161 @@ static int ti_sn_bridge_parse_dsi_host(struct 
> ti_sn_bridge *pdata)
>   return 0;
>  }
>  
> +#if defined(CONFIG_PWM)
> +static int ti_sn_pwm_pin_request(struct ti_sn_bridge *pdata)
> +{
> + return atomic_xchg(&pdata->pwm_pin_busy, 1) ? -EBUSY : 0;
> +}
> +
> +static void ti_sn_pwm_pin_release(struct ti_sn_bridge *pdata)
> +{
> + atomic_set(&pdata->pwm_pin_busy, 0);
> +}
> +
> +static struct ti_sn_bridge *
> +pwm_chip_to_ti_sn_bridge(struct pwm_chip *chip)
> +{
> + return container_of(chip, struct ti_sn_bridge, pchip);
> +}
> +
> +static int ti_sn_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> + struct ti_sn_bridge *pdata = pwm_chip_to_ti_sn_bridge(chip);
> +
> + return ti_sn_pwm_pin_request(pdata);
> +}
> +
> +static void ti_sn_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
> +{
> + struct ti_sn_bridge *pdata = pwm_chip_to_ti_sn_bridge(chip);
> +
> + ti_sn_pwm_pin_release(pdata);
> +}
> +
> +static int ti_sn_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
> +const struct pwm_state *state)
> +{
> + struct ti_sn_bridge *pdata = pwm_chip_to_ti_sn_bridge(chip);
> + unsigned int pwm_en_inv;
> + unsigned int backlight;
> + unsigned int pwm_freq;
> + unsigned int pre_div;
> + unsigned int scale;
> + int ret;
> +
> + if (!pdata->pwm_enabled) {
> + ret = pm_runtime_get_sync(pdata->dev);
> + if (ret < 0)
> + retu

[PATCH] drm/bridge: ti-sn65dsi86: rename GPIO register bits

2020-12-10 Thread Shawn Guo
From: Shawn Guo 

It renames GPIO register bits to drop 'SN_' prefix, so that they are
consistent to other definitions - prefixing register name with 'SN_' but
not for bit fields.

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c 
b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index f27306c51e4d..8eac9d77eba1 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
@@ -63,13 +63,13 @@
 #define SN_HPD_DISABLE_REG 0x5C
 #define  HPD_DISABLE   BIT(0)
 #define SN_GPIO_IO_REG 0x5E
-#define  SN_GPIO_INPUT_SHIFT   4
-#define  SN_GPIO_OUTPUT_SHIFT  0
+#define  GPIO_INPUT_SHIFT  4
+#define  GPIO_OUTPUT_SHIFT 0
 #define SN_GPIO_CTRL_REG   0x5F
-#define  SN_GPIO_MUX_INPUT 0
-#define  SN_GPIO_MUX_OUTPUT1
-#define  SN_GPIO_MUX_SPECIAL   2
-#define  SN_GPIO_MUX_MASK  0x3
+#define  GPIO_MUX_INPUT0
+#define  GPIO_MUX_OUTPUT   1
+#define  GPIO_MUX_SPECIAL  2
+#define  GPIO_MUX_MASK 0x3
 #define SN_AUX_WDATA_REG(x)(0x64 + (x))
 #define SN_AUX_ADDR_19_16_REG  0x74
 #define SN_AUX_ADDR_15_8_REG   0x75
@@ -1035,7 +1035,7 @@ static int ti_sn_bridge_gpio_get(struct gpio_chip *chip, 
unsigned int offset)
if (ret)
return ret;
 
-   return !!(val & BIT(SN_GPIO_INPUT_SHIFT + offset));
+   return !!(val & BIT(GPIO_INPUT_SHIFT + offset));
 }
 
 static void ti_sn_bridge_gpio_set(struct gpio_chip *chip, unsigned int offset,
@@ -1051,8 +1051,8 @@ static void ti_sn_bridge_gpio_set(struct gpio_chip *chip, 
unsigned int offset,
 
val &= 1;
ret = regmap_update_bits(pdata->regmap, SN_GPIO_IO_REG,
-BIT(SN_GPIO_OUTPUT_SHIFT + offset),
-val << (SN_GPIO_OUTPUT_SHIFT + offset));
+BIT(GPIO_OUTPUT_SHIFT + offset),
+val << (GPIO_OUTPUT_SHIFT + offset));
if (ret)
dev_warn(pdata->dev,
 "Failed to set bridge GPIO %u: %d\n", offset, ret);
@@ -1069,8 +1069,8 @@ static int ti_sn_bridge_gpio_direction_input(struct 
gpio_chip *chip,
return 0;
 
ret = regmap_update_bits(pdata->regmap, SN_GPIO_CTRL_REG,
-SN_GPIO_MUX_MASK << shift,
-SN_GPIO_MUX_INPUT << shift);
+GPIO_MUX_MASK << shift,
+GPIO_MUX_INPUT << shift);
if (ret) {
set_bit(offset, pdata->gchip_output);
return ret;
@@ -1103,8 +1103,8 @@ static int ti_sn_bridge_gpio_direction_output(struct 
gpio_chip *chip,
 
/* Set direction */
ret = regmap_update_bits(pdata->regmap, SN_GPIO_CTRL_REG,
-SN_GPIO_MUX_MASK << shift,
-SN_GPIO_MUX_OUTPUT << shift);
+GPIO_MUX_MASK << shift,
+GPIO_MUX_OUTPUT << shift);
if (ret) {
clear_bit(offset, pdata->gchip_output);
pm_runtime_put(pdata->dev);
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/bridge: ti-sn65dsi86: Implement the pwm_chip

2020-12-10 Thread Shawn Guo
Hi Uwe,

On Thu, Dec 10, 2020 at 9:05 PM Uwe Kleine-König
 wrote:
> > > @@ -111,6 +118,8 @@
> > >
> > >  #define SN_LINK_TRAINING_TRIES 10
> > >
> > > +#define SN_PWM_GPIO3
> >
> > So this maps to the GPIO4 described in sn65dsi86 datasheet.  I'm
> > wondering if it's more readable to define the following SHIFT constants
> > (your code), and use GPIO_MUX_GPIO4_SHIFT >> 2 where you need GPIO
> > offset?
> >
> > #define  GPIO_MUX_GPIO1_SHIFT 0
> > #define  GPIO_MUX_GPIO2_SHIFT 2
> > #define  GPIO_MUX_GPIO3_SHIFT 4
> > #define  GPIO_MUX_GPIO4_SHIFT 6
> >
> > If you agree, you may consider to integrate this patch beforehand:
> >
> > https://github.com/shawnguo2/linux/commit/7cde887ffb3b27a36e77a08bee3666d14968b586
>
> My preferred way here would be to add a prefix for the other constants.
> It (IMHO) looks nicer and
>
> GPIO_INPUT_SHIFT
>
> looks like a quite generic name for a hardware specific definition.

While this looks like a reasonable argument, I also like the naming
choice for these constants in the beginning for that distinction
between registers and bits.  And changing the names the other way
around means there will be a much bigger diffstat, which I would like
to avoid.  I suggest let's just focus on what really matters here -
keep the naming consistent, so that people do not get confused when
they want to add more constants in there.

Shawn

> (Even if up to now there is no other code location using this name.)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v1 4/4] ARM: dts: add SKOV imx6q and imx6dl based boards

2021-07-13 Thread Shawn Guo
On Wed, Jun 09, 2021 at 02:10:50PM +0200, Oleksij Rempel wrote:
> From: Sam Ravnborg 
> 
> Add SKOV imx6q/dl LT2, LT6 and mi1010ait-1cp1 boards.
> 
> Signed-off-by: Sam Ravnborg 
> Signed-off-by: Søren Andersen 
> Signed-off-by: Juergen Borleis 
> Signed-off-by: Ulrich Ölmann 
> Signed-off-by: Michael Grzeschik 
> Signed-off-by: Marco Felsch 
> Signed-off-by: Lucas Stach 
> Signed-off-by: Oleksij Rempel 
> ---
>  arch/arm/boot/dts/Makefile|   5 +
>  arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts|  13 +
>  arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts| 108 
>  arch/arm/boot/dts/imx6q-skov-revc-lt2.dts |  36 ++
>  arch/arm/boot/dts/imx6q-skov-revc-lt6.dts | 128 +
>  .../dts/imx6q-skov-reve-mi1010ait-1cp1.dts| 127 +
>  arch/arm/boot/dts/imx6qdl-skov-cpu-revc.dtsi  |  58 +++
>  arch/arm/boot/dts/imx6qdl-skov-cpu.dtsi   | 476 ++
>  8 files changed, 951 insertions(+)
>  create mode 100644 arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts
>  create mode 100644 arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts
>  create mode 100644 arch/arm/boot/dts/imx6q-skov-revc-lt2.dts
>  create mode 100644 arch/arm/boot/dts/imx6q-skov-revc-lt6.dts
>  create mode 100644 arch/arm/boot/dts/imx6q-skov-reve-mi1010ait-1cp1.dts
>  create mode 100644 arch/arm/boot/dts/imx6qdl-skov-cpu-revc.dtsi
>  create mode 100644 arch/arm/boot/dts/imx6qdl-skov-cpu.dtsi
> 
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index f8f09c5066e7..60a3ef665697 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -473,6 +473,8 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
>   imx6dl-sabrelite.dtb \
>   imx6dl-sabresd.dtb \
>   imx6dl-savageboard.dtb \
> + imx6dl-skov-revc-lt2.dtb \
> + imx6dl-skov-revc-lt6.dtb \
>   imx6dl-ts4900.dtb \
>   imx6dl-ts7970.dtb \
>   imx6dl-tx6dl-comtft.dtb \
> @@ -567,6 +569,9 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
>   imx6q-sabresd.dtb \
>   imx6q-savageboard.dtb \
>   imx6q-sbc6x.dtb \
> + imx6q-skov-revc-lt2.dtb \
> + imx6q-skov-revc-lt6.dtb \
> + imx6q-skov-reve-mi1010ait-1cp1.dtb \
>   imx6q-tbs2910.dtb \
>   imx6q-ts4900.dtb \
>   imx6q-ts7970.dtb \
> diff --git a/arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts 
> b/arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts
> new file mode 100644
> index ..667b8faa1807
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx6dl-skov-revc-lt2.dts
> @@ -0,0 +1,13 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +//
> +// Copyright (C) 2020 Pengutronix, Ulrich Oelmann 
> +
> +/dts-v1/;
> +#include "imx6dl.dtsi"
> +#include "imx6qdl-skov-cpu.dtsi"
> +#include "imx6qdl-skov-cpu-revc.dtsi"
> +
> +/ {
> + model = "SKOV IMX6 CPU SoloCore";
> + compatible = "skov,imx6dl-skov-revc-lt2", "fsl,imx6dl";
> +};
> diff --git a/arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts 
> b/arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts
> new file mode 100644
> index ..25071c7c4e29
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx6dl-skov-revc-lt6.dts
> @@ -0,0 +1,108 @@
> +// SPDX-License-Identifier: (GPL-2.0 OR MIT)
> +//
> +// Copyright (C) 2020 Pengutronix, Ulrich Oelmann 
> +
> +/dts-v1/;
> +#include "imx6dl.dtsi"
> +#include "imx6qdl-skov-cpu.dtsi"
> +#include "imx6qdl-skov-cpu-revc.dtsi"
> +
> +/ {
> + model = "SKOV IMX6 CPU SoloCore";
> + compatible = "skov,imx6dl-skov-revc-lt6", "fsl,imx6dl";
> +
> + backlight: backlight {
> + compatible = "pwm-backlight";
> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_backlight>;
> + enable-gpios = <&gpio6 23 GPIO_ACTIVE_LOW>;
> + pwms = <&pwm2 0 2 0>;
> + brightness-levels = <0 255>;
> + num-interpolated-steps = <17>;
> + default-brightness-level = <8>;
> + power-supply = <®_24v0>;
> + };
> +
> + display {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + compatible = "fsl,imx-parallel-display";
> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_ipu1>;
> +
> + port@0 {
> + reg = <0>;
> +
> + display0_in: endpoint {
> + remote-endpoint = <&ipu1_di0_disp0>;
> + };
> + };
> +
> + port@1 {
> + reg = <1>;
> +
> + display0_out: endpoint {
> + remote-endpoint = <&panel_in>;
> + };
> + };
> + };
> +
> +
> + panel {
> + compatible = "logictechno,lttd800480070-l6wh-rt";
> + backlight = <&backlight>;
> + power-supply = <®_3v3>;
> +
> + port {
> + panel_in: endpoint {
> + remote-endpoint = <&display0_out>;
> + };
> + };
> + };
> +};
> +
> +&ipu1_di0_disp0 {

Re: [PATCH v2 2/2] drm/panel: Add Sony Tulip Truly NT35521 driver

2021-09-21 Thread Shawn Guo
On Tue, Aug 24, 2021 at 09:59:04PM +0200, Sam Ravnborg wrote:
> On Tue, Aug 24, 2021 at 10:58:31AM +0800, Shawn Guo wrote:
> > On Mon, Aug 09, 2021 at 01:10:08PM +0800, Shawn Guo wrote:
> > > It adds a DRM panel driver for Sony Tulip Truly NT35521 5.24" 1280x720
> > > DSI panel, which can be found on Sony Xperia M4 Aqua phone.  The panel
> > > backlight is managed through DSI link.
> > > 
> > > The driver is built using linux-mdss-dsi-panel-driver-generator[1], and
> > > additionally modeling the 5V control GPIOs with regulators and adding
> > > Backlight GPIO support.
> > > 
> > > [1] 
> > > https://github.com/msm8916-mainline/linux-mdss-dsi-panel-driver-generator
> > > 
> > > Signed-off-by: Shawn Guo 
> > 
> > Sam, Stephan,
> > 
> > Thank you for the review comments on v1!  How does v2 look to you?
> 
> I will not have time until next week - sorry.
> Please ping me if you have no feedback i one week from now.

Sam,

Could you help handle this patch now?  Thanks!

Shawn


Re: [PATCH v1 4/4] ARM: dts: imx6dl: plym2m, prtvt7, victgo: make use of new resistive-adc-touch driver

2022-01-25 Thread Shawn Guo
On Wed, Jan 05, 2022 at 12:04:34PM +0100, Oleksij Rempel wrote:
> Hi Shawn,
> 
> sorry for the delay, I just came back to work.
> 
> On Mon, Dec 06, 2021 at 09:06:28AM +0800, Shawn Guo wrote:
> > On Mon, Nov 22, 2021 at 01:43:10PM +0100, Oleksij Rempel wrote:
> > > The tsc2046 is an ADC used as touchscreen controller. To share as mach
> > > code as possible, we should use it as actual ADC + virtual tochscreen
> > > controller.
> > > With this patch we make use of the new kernel IIO and HID infrastructure.
> > > 
> > > Signed-off-by: Oleksij Rempel 
> > 
> > One space is enough in subject "victgo:  make".
> 
> done.
> 
> > > ---
> > >  arch/arm/boot/dts/imx6dl-plym2m.dts | 55 -
> > >  arch/arm/boot/dts/imx6dl-prtvt7.dts | 53 ---
> > >  arch/arm/boot/dts/imx6dl-victgo.dts | 55 +
> > >  3 files changed, 120 insertions(+), 43 deletions(-)
> > > 
> > > diff --git a/arch/arm/boot/dts/imx6dl-plym2m.dts 
> > > b/arch/arm/boot/dts/imx6dl-plym2m.dts
> > > index 60fe5f14666e..e2afedae85cb 100644
> > > --- a/arch/arm/boot/dts/imx6dl-plym2m.dts
> > > +++ b/arch/arm/boot/dts/imx6dl-plym2m.dts
> > > @@ -101,6 +101,17 @@ reg_12v0: regulator-12v0 {
> > >   regulator-min-microvolt = <1200>;
> > >   regulator-max-microvolt = <1200>;
> > >   };
> > > +
> > > + touchscreen {
> > > + compatible = "resistive-adc-touch";
> > > + io-channels = <&adc 1>, <&adc 3>, <&adc 4>, <&adc 5>;
> > > + io-channel-names = "y", "z1", "z2", "x";
> > > + touchscreen-min-pressure = <64687>;
> > > + touchscreen-inverted-x;
> > > + touchscreen-inverted-y;
> > > + touchscreen-x-plate-ohms = <300>;
> > > + touchscreen-y-plate-ohms = <800>;
> > > + };
> > >  };
> > >  
> > >  &can1 {
> > > @@ -129,26 +140,38 @@ &ecspi2 {
> > >   pinctrl-0 = <&pinctrl_ecspi2>;
> > >   status = "okay";
> > >  
> > > - touchscreen@0 {
> > > - compatible = "ti,tsc2046";
> > > + adc: adc@0 {
> > 
> > Isn't label name "adc" too generic?
> 
> I do not have strong opinion about this. Currently we have no
> restrictions for the node names:
> Documentation/devicetree/bindings/iio/adc/ti,tsc2046.yaml
> Documentation/devicetree/bindings/iio/adc/adc.yaml
> 
> I can name it touchscreen-adc@0 or something like this. What are your
> preferences?

I wasn't talking about node name but label.

Shawn


Re: [PATCH v1 2/4] ARM: dts: imx6dl-prtvt7: Add missing tvp5150 video decoder node

2021-12-06 Thread Shawn Guo
On Mon, Nov 22, 2021 at 01:43:08PM +0100, Oleksij Rempel wrote:
> From: Robin van der Gracht 
> 
> Signed-off-by: Robin van der Gracht 
> ---
>  arch/arm/boot/dts/imx6dl-prtvt7.dts | 40 +
>  1 file changed, 40 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/imx6dl-prtvt7.dts 
> b/arch/arm/boot/dts/imx6dl-prtvt7.dts
> index be7c4cb339e7..02b53df03e6f 100644
> --- a/arch/arm/boot/dts/imx6dl-prtvt7.dts
> +++ b/arch/arm/boot/dts/imx6dl-prtvt7.dts
> @@ -6,6 +6,7 @@
>  /dts-v1/;
>  #include "imx6dl.dtsi"
>  #include "imx6qdl-prti6q.dtsi"
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -171,6 +172,18 @@ panel_in: endpoint {
>   };
>   };
>  
> + connector {
> + compatible = "composite-video-connector";
> + label = "Composite0";
> + sdtv-standards = ;
> +
> + port {
> + comp0_out: endpoint {
> + remote-endpoint = <&tvp5150_comp0_in>;
> + };
> + };
> + };
> +
>   reg_bl_12v0: regulator-bl-12v0 {
>   compatible = "regulator-fixed";
>   pinctrl-names = "default";
> @@ -295,6 +308,29 @@ sgtl5000: audio-codec@a {
>   VDDIO-supply = <®_3v3>;
>   VDDD-supply = <®_1v8>;
>   };
> +
> + video@5c {
> + compatible = "ti,tvp5150";
> + reg = <0x5c>;
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + port@0 {
> + reg = <0>;

Have a newline between property and child node.

Shawn

> + tvp5150_comp0_in: endpoint {
> + remote-endpoint = <&comp0_out>;
> + };
> + };
> +
> + /* Output port 2 is video output pad */
> + port@2 {
> + reg = <2>;
> + tvp5151_to_ipu1_csi0_mux: endpoint {
> + remote-endpoint = 
> <&ipu1_csi0_mux_from_parallel_sensor>;
> + };
> + };
> + };
>  };
>  
>  &i2c3 {
> @@ -322,6 +358,10 @@ &ipu1_di0_disp0 {
>   remote-endpoint = <&display_in>;
>  };
>  
> +&ipu1_csi0_mux_from_parallel_sensor {
> + remote-endpoint = <&tvp5151_to_ipu1_csi0_mux>;
> +};
> +
>  &pwm1 {
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_pwm1>;
> -- 
> 2.30.2
> 


Re: [PATCH v1 4/4] ARM: dts: imx6dl: plym2m, prtvt7, victgo: make use of new resistive-adc-touch driver

2021-12-06 Thread Shawn Guo
On Mon, Nov 22, 2021 at 01:43:10PM +0100, Oleksij Rempel wrote:
> The tsc2046 is an ADC used as touchscreen controller. To share as mach
> code as possible, we should use it as actual ADC + virtual tochscreen
> controller.
> With this patch we make use of the new kernel IIO and HID infrastructure.
> 
> Signed-off-by: Oleksij Rempel 

One space is enough in subject "victgo:  make".

> ---
>  arch/arm/boot/dts/imx6dl-plym2m.dts | 55 -
>  arch/arm/boot/dts/imx6dl-prtvt7.dts | 53 ---
>  arch/arm/boot/dts/imx6dl-victgo.dts | 55 +
>  3 files changed, 120 insertions(+), 43 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx6dl-plym2m.dts 
> b/arch/arm/boot/dts/imx6dl-plym2m.dts
> index 60fe5f14666e..e2afedae85cb 100644
> --- a/arch/arm/boot/dts/imx6dl-plym2m.dts
> +++ b/arch/arm/boot/dts/imx6dl-plym2m.dts
> @@ -101,6 +101,17 @@ reg_12v0: regulator-12v0 {
>   regulator-min-microvolt = <1200>;
>   regulator-max-microvolt = <1200>;
>   };
> +
> + touchscreen {
> + compatible = "resistive-adc-touch";
> + io-channels = <&adc 1>, <&adc 3>, <&adc 4>, <&adc 5>;
> + io-channel-names = "y", "z1", "z2", "x";
> + touchscreen-min-pressure = <64687>;
> + touchscreen-inverted-x;
> + touchscreen-inverted-y;
> + touchscreen-x-plate-ohms = <300>;
> + touchscreen-y-plate-ohms = <800>;
> + };
>  };
>  
>  &can1 {
> @@ -129,26 +140,38 @@ &ecspi2 {
>   pinctrl-0 = <&pinctrl_ecspi2>;
>   status = "okay";
>  
> - touchscreen@0 {
> - compatible = "ti,tsc2046";
> + adc: adc@0 {

Isn't label name "adc" too generic?

> + compatible = "ti,tsc2046e-adc";
>   reg = <0>;
>   pinctrl-0 = <&pinctrl_tsc2046>;
>   pinctrl-names ="default";
> - spi-max-frequency = <10>;
> - interrupts-extended = <&gpio3 20 IRQ_TYPE_EDGE_FALLING>;
> - pendown-gpio = <&gpio3 20 GPIO_ACTIVE_LOW>;
> + spi-max-frequency = <100>;
> + interrupts-extended = <&gpio3 20 IRQ_TYPE_LEVEL_LOW>;
> + #io-channel-cells = <1>;
>  
> - touchscreen-inverted-x;
> - touchscreen-inverted-y;
> - touchscreen-max-pressure = <4095>;
> -
> - ti,vref-delay-usecs = /bits/ 16 <100>;
> - ti,x-plate-ohms = /bits/ 16 <800>;
> - ti,y-plate-ohms = /bits/ 16 <300>;
> - ti,debounce-max = /bits/ 16 <3>;
> - ti,debounce-tol = /bits/ 16 <70>;
> - ti,debounce-rep = /bits/ 16 <3>;
> - wakeup-source;
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + channel@1 {
> + reg = <1>;
> + settling-time-us = <700>;
> + oversampling-ratio = <5>;
> + };

Have a newline between child nodes.

Shawn

> + channel@3 {
> + reg = <3>;
> + settling-time-us = <700>;
> + oversampling-ratio = <5>;
> + };
> + channel@4 {
> + reg = <4>;
> + settling-time-us = <700>;
> + oversampling-ratio = <5>;
> + };
> + channel@5 {
> + reg = <5>;
> + settling-time-us = <700>;
> + oversampling-ratio = <5>;
> + };
>   };
>  };
>  
> diff --git a/arch/arm/boot/dts/imx6dl-prtvt7.dts 
> b/arch/arm/boot/dts/imx6dl-prtvt7.dts
> index 02b53df03e6f..c361e0683973 100644
> --- a/arch/arm/boot/dts/imx6dl-prtvt7.dts
> +++ b/arch/arm/boot/dts/imx6dl-prtvt7.dts
> @@ -235,6 +235,17 @@ simple-audio-card,codec {
>   frame-master;
>   };
>   };
> +
> + touchscreen {
> + compatible = "resistive-adc-touch";
> + io-channels = <&adc 1>, <&adc 3>, <&adc 4>, <&adc 5>;
> + io-channel-names = "y", "z1", "z2", "x";
> + touchscreen-min-pressure = <64687>;
> + touchscreen-inverted-x;
> + touchscreen-inverted-y;
> + touchscreen-x-plate-ohms = <300>;
> + touchscreen-y-plate-ohms = <800>;
> + };
>  };
>  
>  &audmux {
> @@ -277,22 +288,38 @@ &ecspi2 {
>   pinctrl-0 = <&pinctrl_ecspi2>;
>   status = "okay";
>  
> - touchscreen@0 {
> - compatible = "ti,tsc2046";
> + adc: adc@0 {
> + compatible = "ti,tsc2046e-adc";
>   reg = <0>;
>   pinctrl-0 = <&pinctrl_tsc>;
>   pinctrl-names ="default";
> - spi-max-frequency = <10>;
> - interrupts-extended = <&gpio3 20 IRQ_TYPE_EDGE_FALLING>;
> - pendown-gpio = <&gpio3 20 GPIO_ACTIVE_LOW>;
> - touchscreen-max-pressure = <4095>;
> -

Re: [PATCH v7 0/8] mainline Plymovent M2M and BAS board

2021-01-06 Thread Shawn Guo
On Mon, Dec 07, 2020 at 03:09:31PM +0100, Oleksij Rempel wrote:
> changes v7:
> - panel-simple.yaml: fix comments and part order
> - panel-simple.yaml: invent a product description for the Kyocera tcg070wvlq 
> panel
> 
> changes v6:
> - do more panel-simple.yaml related cleanups
> 
> changes v5:
> - rebase against latest shawngup/for-next
> - add patch to fix checkpatch warning on PLYM2M dts
> 
> changes v4:
> - add PLYBAS board
> - PLYM2M: add touchscreen node
> - PLYM2M: add rename led nodes to led-x
> 
> changes v3:
> - use old style copyright text
> 
> changes v2:
> - fsl.yaml: reorder ply,plym2m
> - imx6dl-plym2m.dts: use hyphen instead of underscore in phy-clock
> 
> Oleksij Rempel (8):
>   dt-bindings: display: simple: fix alphabetical order for EDT
> compatibles
>   dt-bindings: display: simple: add EDT compatibles already supported by
> the driver
>   dt-bindings: display: simple: Add Kyocera tcg070wvlq panel
>   dt-bindings: vendor-prefixes: Add an entry for Plymovent
>   dt-bindings: arm: fsl: add Plymovent M2M board
>   ARM: dts: add Plymovent M2M board
>   dt-bindings: arm: fsl: add Plymovent BAS board
>   ARM: dts: add Plymovent BAS board

Applied all, thanks.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm: drop DRIVER_HAVE_IRQ flag for some drivers

2016-08-12 Thread Shawn Guo
The drm driver feature flag DRIVER_HAVE_IRQ is used to indicates whether
the driver has an IRQ handler managed by the DRM core.  Some drivers,
armada, etnaviv, kirin and sti, set this flag without .irq_handler setup
in drm_driver.  These drivers manage IRQ handler by themselves and the
flag DRIVER_HAVE_IRQ makes no sense there.

Drop the flag for these drivers to avoid confusion.

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/armada/armada_drv.c | 2 +-
 drivers/gpu/drm/etnaviv/etnaviv_drv.c   | 3 +--
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 2 +-
 drivers/gpu/drm/sti/sti_drv.c   | 2 +-
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index f5ebdd681445..1e0e68f608e4 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -211,7 +211,7 @@ static struct drm_driver armada_drm_driver = {
.desc   = "Armada SoC DRM",
.date   = "20120730",
.driver_features= DRIVER_GEM | DRIVER_MODESET |
- DRIVER_HAVE_IRQ | DRIVER_PRIME,
+ DRIVER_PRIME,
.ioctls = armada_ioctls,
.fops   = &armada_drm_fops,
 };
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index ffd1b32caa8d..fd0ed61565f3 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -488,8 +488,7 @@ static const struct file_operations fops = {
 };

 static struct drm_driver etnaviv_drm_driver = {
-   .driver_features= DRIVER_HAVE_IRQ |
-   DRIVER_GEM |
+   .driver_features= DRIVER_GEM |
DRIVER_PRIME |
DRIVER_RENDER,
.open   = etnaviv_open,
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 1edd9bc80294..1fc2f502d20d 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -169,7 +169,7 @@ static int kirin_gem_cma_dumb_create(struct drm_file *file,

 static struct drm_driver kirin_drm_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
- DRIVER_ATOMIC | DRIVER_HAVE_IRQ,
+ DRIVER_ATOMIC,
.fops   = &kirin_drm_fops,

.gem_free_object_unlocked = drm_gem_cma_free_object,
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 96bd3d08b2d4..f8311b2bc84e 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -282,7 +282,7 @@ static const struct file_operations sti_driver_fops = {
 };

 static struct drm_driver sti_driver = {
-   .driver_features = DRIVER_HAVE_IRQ | DRIVER_MODESET |
+   .driver_features = DRIVER_MODESET |
DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
-- 
1.9.1



[PATCH] drm: drop DRIVER_HAVE_IRQ flag for some drivers

2016-08-16 Thread Shawn Guo
On Fri, Aug 12, 2016 at 03:03:31PM +0100, Russell King - ARM Linux wrote:
> On Fri, Aug 12, 2016 at 01:15:37PM +0800, Shawn Guo wrote:
> > The drm driver feature flag DRIVER_HAVE_IRQ is used to indicates whether
> > the driver has an IRQ handler managed by the DRM core.  Some drivers,
> > armada, etnaviv, kirin and sti, set this flag without .irq_handler setup
> > in drm_driver.  These drivers manage IRQ handler by themselves and the
> > flag DRIVER_HAVE_IRQ makes no sense there.
> 
> It's worth noting that DRIVER_HAVE_IRQ was required prior to:
> 
> commit 4984979b9b9025a1cb9a9bea089d31a3e01ccff1
> Author: Daniel Vetter 
> Date:   Wed Aug 28 15:02:37 2013 +0200
> 
> drm/irq: simplify irq checks in drm_wait_vblank
> 
> to have working vblank.  As this is no longer the case, this change
> looks sane.

Okay, I will improve the commit log and send v2 soon.

> 
> > 
> > Drop the flag for these drivers to avoid confusion.
> > 
> > Signed-off-by: Shawn Guo 
> > ---
> >  drivers/gpu/drm/armada/armada_drv.c | 2 +-
> >  drivers/gpu/drm/etnaviv/etnaviv_drv.c   | 3 +--
> 
> For both of these,
> 
> Acked-by: Russell King 

Thanks, Russell.

Shawn


[PATCH v2] drm: drop DRIVER_HAVE_IRQ flag for some drivers

2016-08-16 Thread Shawn Guo
Since commit 4984979b9b90 ("drm/irq: simplify irq checks in
drm_wait_vblank"), the drm driver feature flag DRIVER_HAVE_IRQ is only
required for drivers that have an IRQ handler managed by the DRM core.
Some drivers, armada, etnaviv, kirin and sti, set this flag without
.irq_handler setup in drm_driver.  These drivers manage IRQ handler
by themselves and the flag DRIVER_HAVE_IRQ makes no sense there.

Drop the flag for these drivers to avoid confusion.

Signed-off-by: Shawn Guo 
Cc: Vincent Abriou 
Cc: Xinliang Liu 
Acked-by: Russell King  (for armada and etnaviv)
---
Changes for v2:
 - Improve commit log per Russell's suggestion
 - Add Russell's ACK tag

 drivers/gpu/drm/armada/armada_drv.c | 2 +-
 drivers/gpu/drm/etnaviv/etnaviv_drv.c   | 3 +--
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 2 +-
 drivers/gpu/drm/sti/sti_drv.c   | 2 +-
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index f5ebdd681445..1e0e68f608e4 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -211,7 +211,7 @@ static struct drm_driver armada_drm_driver = {
.desc   = "Armada SoC DRM",
.date   = "20120730",
.driver_features= DRIVER_GEM | DRIVER_MODESET |
- DRIVER_HAVE_IRQ | DRIVER_PRIME,
+ DRIVER_PRIME,
.ioctls = armada_ioctls,
.fops   = &armada_drm_fops,
 };
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index ffd1b32caa8d..fd0ed61565f3 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -488,8 +488,7 @@ static const struct file_operations fops = {
 };

 static struct drm_driver etnaviv_drm_driver = {
-   .driver_features= DRIVER_HAVE_IRQ |
-   DRIVER_GEM |
+   .driver_features= DRIVER_GEM |
DRIVER_PRIME |
DRIVER_RENDER,
.open   = etnaviv_open,
diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 1edd9bc80294..1fc2f502d20d 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -169,7 +169,7 @@ static int kirin_gem_cma_dumb_create(struct drm_file *file,

 static struct drm_driver kirin_drm_driver = {
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
- DRIVER_ATOMIC | DRIVER_HAVE_IRQ,
+ DRIVER_ATOMIC,
.fops   = &kirin_drm_fops,

.gem_free_object_unlocked = drm_gem_cma_free_object,
diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index 96bd3d08b2d4..f8311b2bc84e 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -282,7 +282,7 @@ static const struct file_operations sti_driver_fops = {
 };

 static struct drm_driver sti_driver = {
-   .driver_features = DRIVER_HAVE_IRQ | DRIVER_MODESET |
+   .driver_features = DRIVER_MODESET |
DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
-- 
1.9.1



Re: [PATCH 0/2] drm: imx: Add NWL MIPI DSI host controller support

2019-05-26 Thread Shawn Guo
On Wed, May 08, 2019 at 07:18:27PM +0200, Guido Günther wrote:
> If somebody is working on DCSS support it'd be cool to know since this

I have some time slots here and will start looking at it, if no one else
is already working on it.

Shawn

> driver is currently a component of imx-display-subsystem which will only
> work out if dcss is handled like this as well.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 0/2] drm: imx: Add NWL MIPI DSI host controller support

2019-05-27 Thread Shawn Guo
Hi Lucas,

On Mon, May 27, 2019 at 03:36:53PM +0200, Lucas Stach wrote:
> We have been looking at how to support DCSS in mainline for a while,
> but most of the actual work got pushed behind in schedule due to other
> priorities.

I have some time to contribute.  Would you suggest how I should help
here?

1. You guys already have something close to completion and do not need
   more hands.
2. You guys already have some preliminary code and can use help from
   others.
3. You guys haven't got anything to start with, but just some design
   principles that anyone who wants to work on it should consider.

Which is the one that you want me to read?

> One thing I can can say for certain is that DCSS should not be
> integrated into imx-drm. It's a totally different hardware and
> downstream clearly shows that it's not a good idea to cram it into imx-
> drm.

I haven't gone deeper into the vendor code, but from a brief looking I
didn't see so many problems with integrating DCSS into imx-drm.  It's
not so unreasonable to take imx-drm as an imx-display-subsystem which
can have multiple CRTCs.  So can you please elaborate a bit on why it's
really a bad idea?

> Also the artificial split between hardware control in
> drivers/gpu/imx/dcss and the DRM driver is just cargo-cult from the
> IPU/imx-drm split. For the IPU we did it as the IPU has legs in both
> DRM for the output parts and V4L2 for the input parts. As the DCSS has
> no video input capabilities the driver could be simplified a lot by
> moving it all into a single DRM driver.

Agreed on this.

Shawn
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [EXT] Re: [PATCH 0/2] drm: imx: Add NWL MIPI DSI host controller support

2019-05-28 Thread Shawn Guo
Hi Laurentiu,

On Tue, May 28, 2019 at 07:03:54AM +, Laurentiu Palcu wrote:
> Hi Shawn, Lucas,
> 
> On Tue, May 28, 2019 at 09:38:02AM +0800, Shawn Guo wrote:
> > Caution: EXT Email
> > 
> > Hi Lucas,
> > 
> > On Mon, May 27, 2019 at 03:36:53PM +0200, Lucas Stach wrote:
> > > We have been looking at how to support DCSS in mainline for a while,
> > > but most of the actual work got pushed behind in schedule due to other
> > > priorities.
> > 
> > I have some time to contribute.  Would you suggest how I should help
> > here?
> > 
> > 1. You guys already have something close to completion and do not need
> >more hands.
> > 2. You guys already have some preliminary code and can use help from
> >others.
> > 3. You guys haven't got anything to start with, but just some design
> >principles that anyone who wants to work on it should consider.
> > 
> > Which is the one that you want me to read?
> 
> We're already working on clearing up the DCSS code and preparing it for
> upstreaming. It should be done in the following weeks.

Great!  I will stay away from this then :)

> The reason we've
> been delaying this is because neither HDMI nor MIPI support was present
> and, until these are upstream, testing DCSS would be quite impossible.

Well, they have to be done one by one, and I guess DCSS should be the
first one.  I think it's fine to test DCSS with out-of-tree HDMI or
MIPI driver which is not ready for submission yet.

Shawn
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 39/59] drm/zte: Drop drm_gem_prime_export/import

2019-06-18 Thread Shawn Guo
On Fri, Jun 14, 2019 at 10:35:55PM +0200, Daniel Vetter wrote:
> They're the default.
> 
> Aside: Would be really nice to switch the others over to
> drm_gem_object_funcs.
> 
> Signed-off-by: Daniel Vetter 
> Cc: Shawn Guo 

Acked-by: Shawn Guo 

> ---
>  drivers/gpu/drm/zte/zx_drm_drv.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c 
> b/drivers/gpu/drm/zte/zx_drm_drv.c
> index 060ad5266bc7..ef019cad7e81 100644
> --- a/drivers/gpu/drm/zte/zx_drm_drv.c
> +++ b/drivers/gpu/drm/zte/zx_drm_drv.c
> @@ -44,8 +44,6 @@ static struct drm_driver zx_drm_driver = {
>   .dumb_create = drm_gem_cma_dumb_create,
>   .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
>   .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
> - .gem_prime_export = drm_gem_prime_export,
> - .gem_prime_import = drm_gem_prime_import,
>   .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
>   .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
>   .gem_prime_vmap = drm_gem_cma_prime_vmap,
> -- 
> 2.20.1
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH] ARM: imx_v6_v7_defconfig: Enable CONFIG_PWM_IMX27

2019-03-21 Thread Shawn Guo
On Thu, Mar 21, 2019 at 10:49:03AM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> On Wed, Mar 20, 2019 at 01:01:26PM +, Leonard Crestez wrote:
> > Commit d80f8206905c ("pwm: imx: Split into two drivers") also adds a new
> > CONFIG_PWM_IMX27 for the PWM block on recent IMX chips and we should
> > enable it by default for imx.
> > 
> > Restoring the PWM driver fixes an infinite probe loop in 5.1-rc1 on
> > various imx6qdl-sabresd boards.
> > 
> > Signed-off-by: Leonard Crestez 
> > Reported-by: Abel Vesa 
> 
> This is prior art:
> 
> https://patchwork.ozlabs.org/project/linux-pwm/list/?series=85452&state=%2A&archive=both
> 
> unfortunately this didn't get an Ack by Shawn and Thierry (added to
> recipients) marked it as "Not Applicable".
> 
> Given that the driver change is in Linus Torvald's tree now (since
> v5.1-rc1~38) it doesn't matter much via which tree this goes in and
> Shawn's tree is the easier now.
> 
> @Shawn: Would you please apply my patches? If you don't have them any
> more, I can bounce them to you. See

Yeah, just applied.  Sorry for being sluggish.

Shawn
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v1 10/33] drm/zte: drop use of drmP.h

2019-07-18 Thread Shawn Guo
On Sun, Jun 30, 2019 at 08:18:59AM +0200, Sam Ravnborg wrote:
> Drop use of the deprecated drmP.h header file.
> Fix fallout.
> 
> Signed-off-by: Sam Ravnborg 
> Cc: Shawn Guo 
> Cc: David Airlie 
> Cc: Daniel Vetter 

Acked-by: Shawn Guo 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v4 12/23] drm: zte: Provide ddc symlink in hdmi connector sysfs directory

2019-07-22 Thread Shawn Guo
On Thu, Jul 11, 2019 at 01:26:39PM +0200, Andrzej Pietrasiewicz wrote:
> Use the ddc pointer provided by the generic connector.
> 
> Signed-off-by: Andrzej Pietrasiewicz 

Acked-by: Shawn Guo 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v4 13/23] drm: zte: Provide ddc symlink in vga connector sysfs directory

2019-07-22 Thread Shawn Guo
On Thu, Jul 11, 2019 at 01:26:40PM +0200, Andrzej Pietrasiewicz wrote:
> Use the ddc pointer provided by the generic connector.
> 
> Signed-off-by: Andrzej Pietrasiewicz 

Acked-by: Shawn Guo 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH v2 2/5] ARM: dts: imx6dl-prtvt7: Add missing tvp5150 video decoder node

2022-02-11 Thread Shawn Guo
On Mon, Jan 31, 2022 at 11:28:38AM +0100, Oleksij Rempel wrote:
> From: Robin van der Gracht 
> 
> Signed-off-by: Robin van der Gracht 

Please write up some commit log.  Also your SoB is missing.

Shawn

> ---
>  arch/arm/boot/dts/imx6dl-prtvt7.dts | 42 +
>  1 file changed, 42 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/imx6dl-prtvt7.dts 
> b/arch/arm/boot/dts/imx6dl-prtvt7.dts
> index be7c4cb339e7..baaa6ffc4df9 100644
> --- a/arch/arm/boot/dts/imx6dl-prtvt7.dts
> +++ b/arch/arm/boot/dts/imx6dl-prtvt7.dts
> @@ -6,6 +6,7 @@
>  /dts-v1/;
>  #include "imx6dl.dtsi"
>  #include "imx6qdl-prti6q.dtsi"
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -171,6 +172,18 @@ panel_in: endpoint {
>   };
>   };
>  
> + connector {
> + compatible = "composite-video-connector";
> + label = "Composite0";
> + sdtv-standards = ;
> +
> + port {
> + comp0_out: endpoint {
> + remote-endpoint = <&tvp5150_comp0_in>;
> + };
> + };
> + };
> +
>   reg_bl_12v0: regulator-bl-12v0 {
>   compatible = "regulator-fixed";
>   pinctrl-names = "default";
> @@ -295,6 +308,31 @@ sgtl5000: audio-codec@a {
>   VDDIO-supply = <®_3v3>;
>   VDDD-supply = <®_1v8>;
>   };
> +
> + video@5c {
> + compatible = "ti,tvp5150";
> + reg = <0x5c>;
> +
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + port@0 {
> + reg = <0>;
> +
> + tvp5150_comp0_in: endpoint {
> + remote-endpoint = <&comp0_out>;
> + };
> + };
> +
> + /* Output port 2 is video output pad */
> + port@2 {
> + reg = <2>;
> +
> + tvp5151_to_ipu1_csi0_mux: endpoint {
> + remote-endpoint = 
> <&ipu1_csi0_mux_from_parallel_sensor>;
> + };
> + };
> + };
>  };
>  
>  &i2c3 {
> @@ -322,6 +360,10 @@ &ipu1_di0_disp0 {
>   remote-endpoint = <&display_in>;
>  };
>  
> +&ipu1_csi0_mux_from_parallel_sensor {
> + remote-endpoint = <&tvp5151_to_ipu1_csi0_mux>;
> +};
> +
>  &pwm1 {
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_pwm1>;
> -- 
> 2.30.2
> 


Re: [PATCH v3 3/5] ARM: dts: imx6qdl-vicut1: add CAN termination support

2022-02-12 Thread Shawn Guo
On Fri, Feb 11, 2022 at 02:30:33PM +0100, Oleksij Rempel wrote:
> The gpio1 0 pin is controlling CAN termination, not USB H1 VBUS. So,
> remove wrong regulator and assign this gpio to new DT CAN termnation

Sigh, the typo is still there with a new version.

Fixed it up and applied the series.

Shawn

> property.
> 
> Signed-off-by: Oleksij Rempel 
> ---
>  arch/arm/boot/dts/imx6qdl-vicut1.dtsi | 12 ++--
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx6qdl-vicut1.dtsi 
> b/arch/arm/boot/dts/imx6qdl-vicut1.dtsi
> index b9e305774fed..1ac7e13249d2 100644
> --- a/arch/arm/boot/dts/imx6qdl-vicut1.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-vicut1.dtsi
> @@ -126,15 +126,6 @@ reg_3v3: regulator-3v3 {
>   regulator-max-microvolt = <330>;
>   };
>  
> - reg_h1_vbus: regulator-h1-vbus {
> - compatible = "regulator-fixed";
> - regulator-name = "h1-vbus";
> - regulator-min-microvolt = <500>;
> - regulator-max-microvolt = <500>;
> - gpio = <&gpio1 0 GPIO_ACTIVE_HIGH>;
> - enable-active-high;
> - };
> -
>   reg_otg_vbus: regulator-otg-vbus {
>   compatible = "regulator-fixed";
>   regulator-name = "otg-vbus";
> @@ -212,6 +203,8 @@ IMX_AUDMUX_V2_PTCR_SYN
> IMX_AUDMUX_V2_PDCR_RXDSEL(0)
>  &can1 {
>   pinctrl-names = "default";
>   pinctrl-0 = <&pinctrl_can1>;
> + termination-gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
> + termination-ohms = <150>;
>   status = "okay";
>  };
>  
> @@ -492,7 +485,6 @@ &uart5 {
>  };
>  
>  &usbh1 {
> - vbus-supply = <®_h1_vbus>;
>   pinctrl-names = "default";
>   phy_type = "utmi";
>   dr_mode = "host";
> -- 
> 2.30.2
> 


Re: [PATCH v1 1/8] ARM: dts: imx6qdl-vicut1/vicutgo: Set default backlight brightness to maximum

2022-04-05 Thread Shawn Guo
On Mon, Feb 21, 2022 at 10:53:05AM +0100, Oleksij Rempel wrote:
> From: David Jander 
> 
> Recover default behavior of the device and set maximal brightness
> 
> Signed-off-by: David Jander 
> Signed-off-by: Oleksij Rempel 
> ---
>  arch/arm/boot/dts/imx6dl-victgo.dts   | 2 +-
>  arch/arm/boot/dts/imx6qdl-vicut1.dtsi | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx6dl-victgo.dts 
> b/arch/arm/boot/dts/imx6dl-victgo.dts
> index 227c952543d4..e6134efbfabd 100644
> --- a/arch/arm/boot/dts/imx6dl-victgo.dts
> +++ b/arch/arm/boot/dts/imx6dl-victgo.dts
> @@ -28,7 +28,7 @@ backlight: backlight {
>   pwms = <&pwm1 0 500 0>;
>   brightness-levels = <0 16 64 255>;
>   num-interpolated-steps = <16>;
> - default-brightness-level = <1>;
> + default-brightness-level = <48>;

Please take a look at the documentation of the property.

  default-brightness-level:
description:
  The default brightness level (index into the array defined by the
  "brightness-levels" property).

Shawn

>   power-supply = <®_3v3>;
>   enable-gpios = <&gpio4 28 GPIO_ACTIVE_HIGH>;
>   };
> diff --git a/arch/arm/boot/dts/imx6qdl-vicut1.dtsi 
> b/arch/arm/boot/dts/imx6qdl-vicut1.dtsi
> index 1ac7e13249d2..c1d06bc28c67 100644
> --- a/arch/arm/boot/dts/imx6qdl-vicut1.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-vicut1.dtsi
> @@ -23,7 +23,7 @@ backlight: backlight {
>   pwms = <&pwm1 0 500 0>;
>   brightness-levels = <0 16 64 255>;
>   num-interpolated-steps = <16>;
> - default-brightness-level = <1>;
> + default-brightness-level = <48>;
>   power-supply = <®_3v3>;
>   enable-gpios = <&gpio4 28 GPIO_ACTIVE_HIGH>;
>   };
> -- 
> 2.30.2
> 


Re: [PATCH v1 1/8] ARM: dts: imx6qdl-vicut1/vicutgo: Set default backlight brightness to maximum

2022-04-05 Thread Shawn Guo
On Wed, Apr 6, 2022 at 9:23 AM Shawn Guo  wrote:
>
> On Mon, Feb 21, 2022 at 10:53:05AM +0100, Oleksij Rempel wrote:
> > From: David Jander 
> >
> > Recover default behavior of the device and set maximal brightness
> >
> > Signed-off-by: David Jander 
> > Signed-off-by: Oleksij Rempel 
> > ---
> >  arch/arm/boot/dts/imx6dl-victgo.dts   | 2 +-
> >  arch/arm/boot/dts/imx6qdl-vicut1.dtsi | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/boot/dts/imx6dl-victgo.dts 
> > b/arch/arm/boot/dts/imx6dl-victgo.dts
> > index 227c952543d4..e6134efbfabd 100644
> > --- a/arch/arm/boot/dts/imx6dl-victgo.dts
> > +++ b/arch/arm/boot/dts/imx6dl-victgo.dts
> > @@ -28,7 +28,7 @@ backlight: backlight {
> >   pwms = <&pwm1 0 500 0>;
> >   brightness-levels = <0 16 64 255>;
> >   num-interpolated-steps = <16>;
> > - default-brightness-level = <1>;
> > + default-brightness-level = <48>;
>
> Please take a look at the documentation of the property.
>
>   default-brightness-level:
> description:
>   The default brightness level (index into the array defined by the
>   "brightness-levels" property).

Ah, never mind, I missed 'num-interpolated-steps' there.

Shawn


Re: [PATCH v1 5/8] ARM: dts: imx6qdl-vicut1/vicutgo: The sgtl5000 uses i2s not ac97

2022-04-05 Thread Shawn Guo
On Mon, Feb 21, 2022 at 10:53:09AM +0100, Oleksij Rempel wrote:
> From: Robin van der Gracht 
> 
> According to Documentation/devicetree/bindings/sound/fsl,ssi.txt
> 'fsl,mode' should be specified for AC97 mode only.
> 
> The 'fsl,ssi' documentation doesn't say anything about specifying
> 'sound-dai-cells' so we'll remove that as well.

Hmm, what needs to be fixed is fsl,ssi binding doc, I think.

Shawn

> 
> Signed-off-by: Robin van der Gracht 
> Signed-off-by: Oleksij Rempel 
> ---
>  arch/arm/boot/dts/imx6dl-victgo.dts   | 2 --
>  arch/arm/boot/dts/imx6qdl-vicut1.dtsi | 2 --
>  2 files changed, 4 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx6dl-victgo.dts 
> b/arch/arm/boot/dts/imx6dl-victgo.dts
> index d542ddad4e32..20c7f80e5ec9 100644
> --- a/arch/arm/boot/dts/imx6dl-victgo.dts
> +++ b/arch/arm/boot/dts/imx6dl-victgo.dts
> @@ -591,8 +591,6 @@ &pwm3 {
>  };
>  
>  &ssi1 {
> - #sound-dai-cells = <0>;
> - fsl,mode = "ac97-slave";
>   status = "okay";
>  };
>  
> diff --git a/arch/arm/boot/dts/imx6qdl-vicut1.dtsi 
> b/arch/arm/boot/dts/imx6qdl-vicut1.dtsi
> index ec39008c0950..97ef8264947a 100644
> --- a/arch/arm/boot/dts/imx6qdl-vicut1.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-vicut1.dtsi
> @@ -466,8 +466,6 @@ &pwm3 {
>  };
>  
>  &ssi1 {
> - #sound-dai-cells = <0>;
> - fsl,mode = "ac97-slave";
>   status = "okay";
>  };
>  
> -- 
> 2.30.2
> 


Re: [PATCH v1 1/8] ARM: dts: imx6qdl-vicut1/vicutgo: Set default backlight brightness to maximum

2022-04-05 Thread Shawn Guo
On Mon, Feb 21, 2022 at 10:53:05AM +0100, Oleksij Rempel wrote:
> From: David Jander 
> 
> Recover default behavior of the device and set maximal brightness
> 
> Signed-off-by: David Jander 
> Signed-off-by: Oleksij Rempel 

Applied, thanks!


Re: [PATCH v1 2/8] ARM: dts: imx6qdl-vicut1/vicutgo: Rename backlight to backlight_lcd

2022-04-05 Thread Shawn Guo
On Mon, Feb 21, 2022 at 10:53:06AM +0100, Oleksij Rempel wrote:
> From: David Jander 
> 
> We have two backlight sources on this boards. Use more specific name for
> the LCD backlight to see the difference.
> 
> Signed-off-by: David Jander 
> Signed-off-by: Robin van der Gracht 
> Signed-off-by: Oleksij Rempel 

Applied, thanks!


Re: [PATCH v1 3/8] ARM: dts: imx6qdl-vicut1/vicutgo: Add backlight_led node

2022-04-05 Thread Shawn Guo
On Mon, Feb 21, 2022 at 10:53:07AM +0100, Oleksij Rempel wrote:
> From: David Jander 
> 
> backlight_led is the dimmable backlight for the rubber border on the case. It
> is also used to highlight the power- and some other buttons.
> 
> MX6QDL_PAD_SD4_DAT1__PWM3_OUT is also assigned as output for pwm3. Since
> we need pwm3 for the backlight, we're forced to disable user space hardware
> revision detection. The bootloader will have to supply this information
> (i.e. through device tree).
> 
> Signed-off-by: David Jander 
> Signed-off-by: Oleksij Rempel 

Applied, thanks!


Re: [PATCH v1 4/8] ARM: dts: imx6qdl-vicut1: update gpio-line-names for some GPIOs

2022-04-05 Thread Shawn Guo
On Mon, Feb 21, 2022 at 10:53:08AM +0100, Oleksij Rempel wrote:
> From: David Jander 
> 
> countedX lines have different board names (YACO_x). And REV_ and BOARD_ pins
> have multiple functions. So, use names exposed to the OS.
> 
> Signed-off-by: David Jander 
> Signed-off-by: Oleksij Rempel 

Applied, thanks!


Re: [PATCH v1 6/8] ARM: dts: imx6dl-victgo: Add interrupt-counter nodes

2022-04-05 Thread Shawn Guo
On Mon, Feb 21, 2022 at 10:53:10AM +0100, Oleksij Rempel wrote:
> From: Robin van der Gracht 
> 
> Interrupt counter is mainlined, now we can add missing counter nodes.
> 
> Signed-off-by: Robin van der Gracht 
> Signed-off-by: Oleksij Rempel 

Applied, thanks!


Re: [PATCH v1 7/8] ARM: dts: imx6dl-victgo: The TGO uses a lg,lb070wv8 compatible 7" display

2022-04-05 Thread Shawn Guo
On Mon, Feb 21, 2022 at 10:53:11AM +0100, Oleksij Rempel wrote:
> From: Robin van der Gracht 
> 
> This series of devices is using lg,lb070wv8 instead of kyo,tcg121xglp.
> 
> Signed-off-by: Robin van der Gracht 
> Signed-off-by: Oleksij Rempel 

Applied, thanks!


Re: [PATCH v1 8/8] ARM: dts: imx6qdl-victgo: add CAN termination support

2022-04-05 Thread Shawn Guo
On Mon, Feb 21, 2022 at 10:53:12AM +0100, Oleksij Rempel wrote:
> From: David Jander 
> 
> The gpio1 0 pin is controlling CAN termination, not USB H1 VBUS. So,
> remove wrong regulator and assign this gpio to new DT CAN termination
> property.
> 
> Signed-off-by: David Jander 
> Signed-off-by: Oleksij Rempel 

Applied, thanks!


Re: [PATCH v2 2/2] dt-bindings: etnaviv: Add #cooling-cells

2019-10-06 Thread Shawn Guo
On Mon, Sep 16, 2019 at 04:32:55PM +0200, Lucas Stach wrote:
> On Mi, 2019-09-11 at 19:40 -0700, Guido Günther wrote:
> > Add #cooling-cells for when the gpu acts as a cooling device.
> > 
> > Signed-off-by: Guido Günther 
> 
> Reviewed-by: Lucas Stach 

Lucas,

I assume you will pick it up.

Shawn

> 
> > ---
> >  .../devicetree/bindings/display/etnaviv/etnaviv-drm.txt  | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git 
> > a/Documentation/devicetree/bindings/display/etnaviv/etnaviv-drm.txt 
> > b/Documentation/devicetree/bindings/display/etnaviv/etnaviv-drm.txt
> > index 8def11b16a24..640592e8ab2e 100644
> > --- a/Documentation/devicetree/bindings/display/etnaviv/etnaviv-drm.txt
> > +++ b/Documentation/devicetree/bindings/display/etnaviv/etnaviv-drm.txt
> > @@ -21,6 +21,7 @@ Required properties:
> >  Optional properties:
> >  - power-domains: a power domain consumer specifier according to
> >Documentation/devicetree/bindings/power/power_domain.txt
> > +- #cooling-cells: : If used as a cooling device, must be <2>
> >  
> >  example:
> >  
> 


Re: [PATCH v2 1/2] dts: arm64: imx8mq: Enable gpu passive throttling

2019-10-06 Thread Shawn Guo
On Wed, Sep 11, 2019 at 07:40:35PM -0700, Guido Günther wrote:
> Temperature and hysteresis were picked after the CPU.
> 
> Signed-off-by: Guido Günther 

The patch prefix should be 'arm64: dts: ...'

I fixed it up and applied the patch.

Shawn

> ---
>  arch/arm64/boot/dts/freescale/imx8mq.dtsi | 15 +++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/freescale/imx8mq.dtsi 
> b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
> index 4fdd60f2c51e..5023a0e5068d 100644
> --- a/arch/arm64/boot/dts/freescale/imx8mq.dtsi
> +++ b/arch/arm64/boot/dts/freescale/imx8mq.dtsi
> @@ -235,12 +235,26 @@
>   thermal-sensors = <&tmu 1>;
>  
>   trips {
> + gpu_alert: gpu-alert {
> + temperature = <8>;
> + hysteresis = <2000>;
> + type = "passive";
> + };
> +
>   gpu-crit {
>   temperature = <9>;
>   hysteresis = <2000>;
>   type = "critical";
>   };
>   };
> +
> + cooling-maps {
> + map0 {
> + trip = <&gpu_alert>;
> + cooling-device =
> + <&gpu THERMAL_NO_LIMIT 
> THERMAL_NO_LIMIT>;
> + };
> + };
>   };
>  
>   vpu-thermal {
> @@ -912,6 +926,7 @@
><&clk IMX8MQ_CLK_GPU_AXI>,
><&clk IMX8MQ_CLK_GPU_AHB>;
>   clock-names = "core", "shader", "bus", "reg";
> + #cooling-cells = <2>;
>   assigned-clocks = <&clk IMX8MQ_CLK_GPU_CORE_SRC>,
> <&clk IMX8MQ_CLK_GPU_SHADER_SRC>,
> <&clk IMX8MQ_CLK_GPU_AXI>,
> -- 
> 2.23.0.rc1
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Re: [PATCH 07/11] dts: arm64: layerscape: add dma-ranges property to qoric-mc node

2019-10-14 Thread Shawn Guo
On Tue, Sep 24, 2019 at 08:12:38PM +0200, Nicolas Saenz Julienne wrote:
> qoriq-mc's dpmacs DMA configuration is inherited from their parent node,
> which acts a bus in this regard. So far it maked all devices as
> dma-coherent but no dma-ranges recommendation is made.
> 
> The truth is that the underlying interconnect has DMA constraints, so
> add an empty dma-ranges in qoriq-mc's node in order for DT's DMA
> configuration code to get the DMA constraints from it.
> 
> Signed-off-by: Nicolas Saenz Julienne 

Updated subject prefix as 'arm64: dts: ...', and applied the patch.

Shawn

> ---
> 
>  arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi | 1 +
>  arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi | 1 +
>  arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi 
> b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
> index c676d0771762..f0d0b6145b72 100644
> --- a/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
> +++ b/arch/arm64/boot/dts/freescale/fsl-ls1088a.dtsi
> @@ -698,6 +698,7 @@
> <0x 0x0834 0 0x4>; /* MC control 
> reg */
>   msi-parent = <&its>;
>   iommu-map = <0 &smmu 0 0>;  /* This is fixed-up by 
> u-boot */
> + dma-ranges;
>   dma-coherent;
>   #address-cells = <3>;
>   #size-cells = <1>;
> diff --git a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi 
> b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi
> index 7a0be8eaa84a..fd6036b7865c 100644
> --- a/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi
> +++ b/arch/arm64/boot/dts/freescale/fsl-ls208xa.dtsi
> @@ -340,6 +340,7 @@
> <0x 0x0834 0 0x4>; /* MC control 
> reg */
>   msi-parent = <&its>;
>   iommu-map = <0 &smmu 0 0>;  /* This is fixed-up by 
> u-boot */
> + dma-ranges;
>   dma-coherent;
>   #address-cells = <3>;
>   #size-cells = <1>;
> diff --git a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi 
> b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
> index 408e0ecdce6a..3735bb139cb2 100644
> --- a/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
> +++ b/arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi
> @@ -868,6 +868,7 @@
>   msi-parent = <&its>;
>   /* iommu-map property is fixed up by u-boot */
>   iommu-map = <0 &smmu 0 0>;
> + dma-ranges;
>   dma-coherent;
>   #address-cells = <3>;
>   #size-cells = <1>;
> -- 
> 2.23.0
> 


Re: [PATCH 08/11] dts: arm64: layerscape: add dma-ranges property to pcie nodes

2019-10-14 Thread Shawn Guo
On Tue, Sep 24, 2019 at 08:12:39PM +0200, Nicolas Saenz Julienne wrote:
> The bus behind the board's PCIe core has DMA addressing limitations. Add
> an empty 'dma-ranges' property on all PCIe bus descriptions to inform
> the OF core that a translation is due further down the line.
> 
> Signed-off-by: Nicolas Saenz Julienne 

Applied, thanks.


Re: [PATCH 07/11] dts: arm64: layerscape: add dma-ranges property to qoric-mc node

2019-10-14 Thread Shawn Guo
On Mon, Oct 14, 2019 at 12:00:25PM +0200, Nicolas Saenz Julienne wrote:
> On Mon, 2019-10-14 at 16:28 +0800, Shawn Guo wrote:
> > On Tue, Sep 24, 2019 at 08:12:38PM +0200, Nicolas Saenz Julienne wrote:
> > > qoriq-mc's dpmacs DMA configuration is inherited from their parent node,
> > > which acts a bus in this regard. So far it maked all devices as
> > > dma-coherent but no dma-ranges recommendation is made.
> > > 
> > > The truth is that the underlying interconnect has DMA constraints, so
> > > add an empty dma-ranges in qoriq-mc's node in order for DT's DMA
> > > configuration code to get the DMA constraints from it.
> > > 
> > > Signed-off-by: Nicolas Saenz Julienne 
> > 
> > Updated subject prefix as 'arm64: dts: ...', and applied the patch.
> 
> Hi Shawn,
> these two patches are no longer needed. This series has been superseded by 
> this
> patch[1] 951d48855d ('of: Make of_dma_get_range() work on bus nodes', 
> available
> in linux-next) which fixed the issue directly in OF code.
> 
> Sorry for the noise.

Okay, thanks for letting me know.  Dropped them.

Shawn


Re: [PATCHv2 5/5] ARM: dts: imx6: Add GE B1x5v2

2021-05-22 Thread Shawn Guo
On Thu, Apr 29, 2021 at 12:29:53AM +0200, Sebastian Reichel wrote:
> This adds device tree files for the General Electric Healthcare
> (GEHC) B1x5v2 series. All models make use of Congatec's QMX6 module,
> which is described in its own device tree include, so that it can
> also be used by other boards.
> 
> Signed-off-by: Sebastian Reichel 
> ---
>  arch/arm/boot/dts/Makefile|   5 +
>  arch/arm/boot/dts/imx6dl-b105pv2.dts  |  35 ++
>  arch/arm/boot/dts/imx6dl-b105v2.dts   |  35 ++
>  arch/arm/boot/dts/imx6dl-b125pv2.dts  |  33 ++
>  arch/arm/boot/dts/imx6dl-b125v2.dts   |  33 ++
>  arch/arm/boot/dts/imx6dl-b155v2.dts   |  36 ++
>  arch/arm/boot/dts/imx6dl-b1x5pv2.dtsi | 434 ++
>  arch/arm/boot/dts/imx6dl-b1x5v2.dtsi  |  61 +++
>  arch/arm/boot/dts/imx6dl-qmx6.dtsi| 624 ++
>  9 files changed, 1296 insertions(+)
>  create mode 100644 arch/arm/boot/dts/imx6dl-b105pv2.dts
>  create mode 100644 arch/arm/boot/dts/imx6dl-b105v2.dts
>  create mode 100644 arch/arm/boot/dts/imx6dl-b125pv2.dts
>  create mode 100644 arch/arm/boot/dts/imx6dl-b125v2.dts
>  create mode 100644 arch/arm/boot/dts/imx6dl-b155v2.dts
>  create mode 100644 arch/arm/boot/dts/imx6dl-b1x5pv2.dtsi
>  create mode 100644 arch/arm/boot/dts/imx6dl-b1x5v2.dtsi
>  create mode 100644 arch/arm/boot/dts/imx6dl-qmx6.dtsi
> 
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index f8f09c5066e7..811f22ed1e37 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -515,6 +515,11 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
>   imx6q-dms-ba16.dtb \
>   imx6q-emcon-avari.dtb \
>   imx6q-evi.dtb \
> + imx6dl-b105v2.dtb \
> + imx6dl-b105pv2.dtb \

'p' goes before 'v'.

> + imx6dl-b125v2.dtb \
> + imx6dl-b125pv2.dtb \
> + imx6dl-b155v2.dtb \
>   imx6q-gk802.dtb \
>   imx6q-gw51xx.dtb \
>   imx6q-gw52xx.dtb \
> diff --git a/arch/arm/boot/dts/imx6dl-b105pv2.dts 
> b/arch/arm/boot/dts/imx6dl-b105pv2.dts
> new file mode 100644
> index ..0d5be2f9471f
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx6dl-b105pv2.dts
> @@ -0,0 +1,35 @@
> +// SPDX-License-Identifier: GPL-2.0 or MIT
> +//
> +// Device Tree Source for General Electric B105Pv2
> +//
> +// Copyright 2018-2021 General Electric Company
> +// Copyright 2018-2021 Collabora
> +
> +/dts-v1/;
> +#include "imx6dl-b1x5pv2.dtsi"
> +
> +/ {
> + model = "General Electric B105Pv2";
> + compatible = "ge,imx6dl-b105pv2", "congatec,qmx6", "fsl,imx6dl";
> +
> + panel {
> + compatible = "auo,g101evn010";
> + status = "okay";

Unneeded okay status.

> + };
> +};
> +
> +&i2c3 {
> + touchscreen@41 {
> + reg = <0x41>;

We generally start property list with 'compatible'.

> + compatible = "ilitek,ili251x";
> +

In general, we do not use newline in middle of property list.

> + pinctrl-names = "default";
> + pinctrl-0 =<&pinctrl_q7_gpio0>;
> + interrupt-parent = <&gpio5>;
> + interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
> + reset-gpios = <&tca6424a 21 GPIO_ACTIVE_LOW>;
> +
> + touchscreen-size-x = <1280>;
> + touchscreen-size-y = <800>;
> + };
> +};
> diff --git a/arch/arm/boot/dts/imx6dl-b105v2.dts 
> b/arch/arm/boot/dts/imx6dl-b105v2.dts
> new file mode 100644
> index ..72a085348304
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx6dl-b105v2.dts
> @@ -0,0 +1,35 @@
> +// SPDX-License-Identifier: GPL-2.0 or MIT
> +//
> +// Device Tree Source for General Electric B105v2
> +//
> +// Copyright 2018-2021 General Electric Company
> +// Copyright 2018-2021 Collabora
> +
> +/dts-v1/;
> +#include "imx6dl-b1x5v2.dtsi"
> +
> +/ {
> + model = "General Electric B105v2";
> + compatible = "ge,imx6dl-b105v2", "congatec,qmx6", "fsl,imx6dl";
> +
> + panel {
> + compatible = "auo,g101evn010";
> + status = "okay";
> + };
> +};
> +
> +&i2c3 {
> + touchscreen@41 {
> + reg = <0x41>;
> + compatible = "ilitek,ili251x";
> +
> + pinctrl-names = "default";
> + pinctrl-0 =<&pinctrl_q7_gpio0>;
> + interrupt-parent = <&gpio5>;
> + interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
> + reset-gpios = <&tca6424a 21 GPIO_ACTIVE_LOW>;
> +
> + touchscreen-size-x = <1280>;
> + touchscreen-size-y = <800>;
> + };
> +};
> diff --git a/arch/arm/boot/dts/imx6dl-b125pv2.dts 
> b/arch/arm/boot/dts/imx6dl-b125pv2.dts
> new file mode 100644
> index ..8fd6c8ed6750
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx6dl-b125pv2.dts
> @@ -0,0 +1,33 @@
> +// SPDX-License-Identifier: GPL-2.0 or MIT
> +//
> +// Device Tree Source for General Electric B125Pv2
> +//
> +// Copyright 2018-2021 General Electric Company
> +// Copyright 2018-2021 Collabora
> +
> +/dts-v1/;
> +#include "imx6dl-b1x5pv2.dtsi"
> +
> +/ {
> + model = "General Electric

Re: [PATCH v3 3/6] ARM: dts: freescale: Use new media bus type macros

2023-01-24 Thread Shawn Guo
On Thu, Jun 16, 2022 at 01:14:07AM +0300, Laurent Pinchart wrote:
> Now that a header exists with macros for the media interface bus-type
> values, replace hardcoding numerical constants with the corresponding
> macros in the DT sources.
> 
> Signed-off-by: Laurent Pinchart 

Applied, thanks!


[PATCH v2 1/2] dt-bindings: add bindings doc for ZTE VOU display controller

2016-10-09 Thread Shawn Guo
On Mon, Oct 03, 2016 at 12:44:29PM -0500, Rob Herring wrote:
> > +Example:
> > +
> > +vou: vou at 144 {
> > +   compatible = "zte,zx296718-vou";
> > +   #address-cells = <1>;
> > +   #size-cells = <1>;
> > +   reg = <0x144 0x1>;
> > +   ranges;
> 
> You still have overlapping addresses. Explicitly list the sub ranges in 
> reg here used by the VOU driver if the driver usage doesn't overlap. If 
> there is overlap (2 drivers accessing the same range), then you need 
> some APIs between the components (or possibly regmap).

The driver matching "zte,zx296718-vou" doesn't map or access the any
'reg' address.  The 'reg' property here is more like a hint telling
that the VOU block covers the address space of all child devices.

I will simply drop the 'reg' property here.

> Also, don't do an empty ranges here. Fill it in so the child nodes are 
> just offsets of 0x144

Okay.  I thought that empty 'ranges' is fine as long as parent and child
address spaces are identical (1:1 mapping).

So with your suggestion, I made the changes below.  Let me know if this
is still not what you are asking for.

Shawn

-8<-

diff --git a/Documentation/devicetree/bindings/display/zte,vou.txt 
b/Documentation/devicetree/bindings/display/zte,vou.txt
index d03ba4c4810c..6bb4ab2517ef 100644
--- a/Documentation/devicetree/bindings/display/zte,vou.txt
+++ b/Documentation/devicetree/bindings/display/zte,vou.txt
@@ -56,14 +56,13 @@ vou: vou at 144 {
compatible = "zte,zx296718-vou";
#address-cells = <1>;
#size-cells = <1>;
-   reg = <0x144 0x1>;
-   ranges;
+   ranges = <0 0x144 0x1>;

-   dpc: dpc at 144 {
+   dpc: dpc at 0 {
compatible = "zte,zx296718-dpc";
-   reg = <0x144 0x1000>, <0x1441000 0x1000>,
- <0x1445000 0x1000>, <0x1446000 0x1000>,
- <0x144a000 0x1000>;
+   reg = <0x 0x1000>, <0x1000 0x1000>,
+ <0x5000 0x1000>, <0x6000 0x1000>,
+ <0xa000 0x1000>;
reg-names = "osd", "timing_ctrl",
"dtrc", "vou_ctrl",
"otfppu";
@@ -74,9 +73,9 @@ vou: vou at 144 {
  "main_wclk", "aux_wclk";
};

-   hdmi: hdmi at 144c000 {
+   hdmi: hdmi at c000 {
compatible = "zte,zx296718-hdmi";
-   reg = <0x144c000 0x4000>;
+   reg = <0xc000 0x4000>;
interrupts = ;



[PATCH v3 0/3] Add initial ZTE VOU DRM/KMS driver

2016-10-20 Thread Shawn Guo
The series adds the initial ZTE VOU display controller DRM/KMS driver.
There are still some features to be added, like overlay plane, scaling,
and more output devices support.  But it's already useful with dual
CRTCs and HDMI display working.

Changes for v3:
 - Rebase to v4.9-rc1
 - Update bindings doc to use 'ranges' for address translation between
   parent and child devices.
 - Call drm_dev_register() last in bind function and drm_dev_unregister()
   first in unbind, so that drm_connector_regiser() can be saved from
   HDMI driver.
 - Instead of using open-coded drm_do_get_edid(), add an I2C adapter for
   HDMI DDC read and use drm_get_edid().
 - Improve the plane .atomic_check implementation by calling helper
   function drm_plane_helper_check_state().
 - Rename zx_crtc.c to zx_vou.c to avoid the confusion that the file
   implements crtc instance.
 - Store vou pointer in zx_crtc, so that we do not need to embed the
   pointer in zx_drm_private.
 - Create zx_readl/zx_writel/zx_writel_mask for register access.
 - Define a few macro helpers to ease the register bit setting, like
   SYNC_WIDE, BACK_PORCH and FRONT_PORCH.
 - Define main/aux channel specific register offset and bits in zx_crtc
   to save the use of is_main check
 - Sort include headers alphabetically
 - Removing encoder pointer out of the structure and constify struct
   vou_inf
 - Add log message for error conditions
 - Make the function calls in teardown path asymmetrical
 - A few coding style improvements like defining macro for sub-module
   address and changing code to save indentation level
 - Add a MAINTAINERS entry for ZTE ZX DRM driver

Changes for v2:
 - Change device tree bindings to kill the virtual display-subsystem
   node make VOU the parent node.

Shawn Guo (3):
  dt-bindings: add bindings doc for ZTE VOU display controller
  drm: zte: add initial vou drm driver
  MAINTAINERS: add an entry for ZTE ZX DRM driver

 .../devicetree/bindings/display/zte,vou.txt|  84 +++
 MAINTAINERS|   7 +
 drivers/gpu/drm/Kconfig|   2 +
 drivers/gpu/drm/Makefile   |   1 +
 drivers/gpu/drm/zte/Kconfig|   8 +
 drivers/gpu/drm/zte/Makefile   |   7 +
 drivers/gpu/drm/zte/zx_drm_drv.c   | 267 +++
 drivers/gpu/drm/zte/zx_drm_drv.h   |  36 +
 drivers/gpu/drm/zte/zx_hdmi.c  | 678 +
 drivers/gpu/drm/zte/zx_plane.c | 375 ++
 drivers/gpu/drm/zte/zx_plane.h |  26 +
 drivers/gpu/drm/zte/zx_vou.c   | 799 +
 drivers/gpu/drm/zte/zx_vou.h   |  46 ++
 13 files changed, 2336 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/zte,vou.txt
 create mode 100644 drivers/gpu/drm/zte/Kconfig
 create mode 100644 drivers/gpu/drm/zte/Makefile
 create mode 100644 drivers/gpu/drm/zte/zx_drm_drv.c
 create mode 100644 drivers/gpu/drm/zte/zx_drm_drv.h
 create mode 100644 drivers/gpu/drm/zte/zx_hdmi.c
 create mode 100644 drivers/gpu/drm/zte/zx_plane.c
 create mode 100644 drivers/gpu/drm/zte/zx_plane.h
 create mode 100644 drivers/gpu/drm/zte/zx_vou.c
 create mode 100644 drivers/gpu/drm/zte/zx_vou.h

-- 
1.9.1



[PATCH v3 1/3] dt-bindings: add bindings doc for ZTE VOU display controller

2016-10-20 Thread Shawn Guo
It adds initial bindings doc for ZTE VOU display controller.  HDMI is
the only supported output device right now.

Signed-off-by: Shawn Guo 
Acked-by: Rob Herring 
---
 .../devicetree/bindings/display/zte,vou.txt| 84 ++
 1 file changed, 84 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/display/zte,vou.txt

diff --git a/Documentation/devicetree/bindings/display/zte,vou.txt 
b/Documentation/devicetree/bindings/display/zte,vou.txt
new file mode 100644
index ..740e5bd2e4f7
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/zte,vou.txt
@@ -0,0 +1,84 @@
+ZTE VOU Display Controller
+
+This is a display controller found on ZTE ZX296718 SoC.  It includes multiple
+Graphic Layer (GL) and Video Layer (VL), two Mixers/Channels, and a few blocks
+handling scaling, color space conversion etc.  VOU also integrates the support
+for typical output devices, like HDMI, TV Encoder, VGA, and RGB LCD.
+
+* Master VOU node
+
+It must be the parent node of all the sub-device nodes.
+
+Required properties:
+ - compatible: should be "zte,zx296718-vou"
+ - #address-cells: should be <1>
+ - #size-cells: should be <1>
+ - ranges: list of address translations between VOU and sub-devices
+
+* VOU DPC device
+
+Required properties:
+ - compatible: should be "zte,zx296718-dpc"
+ - reg: Physical base address and length of DPC register regions, one for each
+   entry in 'reg-names'
+ - reg-names: The names of register regions. The following regions are 
required:
+   "osd"
+   "timing_ctrl"
+   "dtrc"
+   "vou_ctrl"
+   "otfppu"
+ - interrupts: VOU DPC interrupt number to CPU
+ - clocks: A list of phandle + clock-specifier pairs, one for each entry
+   in 'clock-names'
+ - clock-names: A list of clock names.  The following clocks are required:
+   "aclk"
+   "ppu_wclk"
+   "main_wclk"
+   "aux_wclk"
+
+* HDMI output device
+
+Required properties:
+ - compatible: should be "zte,zx296718-hdmi"
+ - reg: Physical base address and length of the HDMI device IO region
+ - interrupts : HDMI interrupt number to CPU
+ - clocks: A list of phandle + clock-specifier pairs, one for each entry
+   in 'clock-names'
+ - clock-names: A list of clock names.  The following clocks are required:
+   "osc_cec"
+   "osc_clk"
+   "xclk"
+
+Example:
+
+vou: vou at 144 {
+   compatible = "zte,zx296718-vou";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x144 0x1>;
+
+   dpc: dpc at 0 {
+   compatible = "zte,zx296718-dpc";
+   reg = <0x 0x1000>, <0x1000 0x1000>,
+ <0x5000 0x1000>, <0x6000 0x1000>,
+ <0xa000 0x1000>;
+   reg-names = "osd", "timing_ctrl",
+   "dtrc", "vou_ctrl",
+   "otfppu";
+   interrupts = ;
+   clocks = <&topcrm VOU_ACLK>, <&topcrm VOU_PPU_WCLK>,
+<&topcrm VOU_MAIN_WCLK>, <&topcrm VOU_AUX_WCLK>;
+   clock-names = "aclk", "ppu_wclk",
+ "main_wclk", "aux_wclk";
+   };
+
+   hdmi: hdmi at c000 {
+   compatible = "zte,zx296718-hdmi";
+   reg = <0xc000 0x4000>;
+   interrupts = ;
+   clocks = <&topcrm HDMI_OSC_CEC>,
+<&topcrm HDMI_OSC_CLK>,
+<&topcrm HDMI_XCLK>;
+   clock-names = "osc_cec", "osc_clk", "xclk";
+   };
+};
-- 
1.9.1



[PATCH v3 2/3] drm: zte: add initial vou drm driver

2016-10-20 Thread Shawn Guo
It adds the initial ZTE VOU display controller DRM driver.  There are
still some features to be added, like overlay plane, scaling, and more
output devices support.  But it's already useful with dual CRTCs and
HDMI monitor working.

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/Kconfig  |   2 +
 drivers/gpu/drm/Makefile |   1 +
 drivers/gpu/drm/zte/Kconfig  |   8 +
 drivers/gpu/drm/zte/Makefile |   7 +
 drivers/gpu/drm/zte/zx_drm_drv.c | 267 +
 drivers/gpu/drm/zte/zx_drm_drv.h |  36 ++
 drivers/gpu/drm/zte/zx_hdmi.c| 678 +
 drivers/gpu/drm/zte/zx_plane.c   | 375 ++
 drivers/gpu/drm/zte/zx_plane.h   |  26 ++
 drivers/gpu/drm/zte/zx_vou.c | 799 +++
 drivers/gpu/drm/zte/zx_vou.h |  46 +++
 11 files changed, 2245 insertions(+)
 create mode 100644 drivers/gpu/drm/zte/Kconfig
 create mode 100644 drivers/gpu/drm/zte/Makefile
 create mode 100644 drivers/gpu/drm/zte/zx_drm_drv.c
 create mode 100644 drivers/gpu/drm/zte/zx_drm_drv.h
 create mode 100644 drivers/gpu/drm/zte/zx_hdmi.c
 create mode 100644 drivers/gpu/drm/zte/zx_plane.c
 create mode 100644 drivers/gpu/drm/zte/zx_plane.h
 create mode 100644 drivers/gpu/drm/zte/zx_vou.c
 create mode 100644 drivers/gpu/drm/zte/zx_vou.h

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 483059a22b1b..a91f8cecbe0f 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -223,6 +223,8 @@ source "drivers/gpu/drm/hisilicon/Kconfig"

 source "drivers/gpu/drm/mediatek/Kconfig"

+source "drivers/gpu/drm/zte/Kconfig"
+
 # Keep legacy drivers last

 menuconfig DRM_LEGACY
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 25c720454017..f3251750c92b 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -86,3 +86,4 @@ obj-$(CONFIG_DRM_FSL_DCU) += fsl-dcu/
 obj-$(CONFIG_DRM_ETNAVIV) += etnaviv/
 obj-$(CONFIG_DRM_ARCPGU)+= arc/
 obj-y  += hisilicon/
+obj-$(CONFIG_DRM_ZTE)  += zte/
diff --git a/drivers/gpu/drm/zte/Kconfig b/drivers/gpu/drm/zte/Kconfig
new file mode 100644
index ..4065b2840f1c
--- /dev/null
+++ b/drivers/gpu/drm/zte/Kconfig
@@ -0,0 +1,8 @@
+config DRM_ZTE
+   tristate "DRM Support for ZTE SoCs"
+   depends on DRM && ARCH_ZX
+   select DRM_KMS_CMA_HELPER
+   select DRM_KMS_FB_HELPER
+   select DRM_KMS_HELPER
+   help
+ Choose this option to enable DRM on ZTE ZX SoCs.
diff --git a/drivers/gpu/drm/zte/Makefile b/drivers/gpu/drm/zte/Makefile
new file mode 100644
index ..699180bfd57c
--- /dev/null
+++ b/drivers/gpu/drm/zte/Makefile
@@ -0,0 +1,7 @@
+zxdrm-y := \
+   zx_drm_drv.o \
+   zx_hdmi.o \
+   zx_plane.o \
+   zx_vou.o
+
+obj-$(CONFIG_DRM_ZTE) += zxdrm.o
diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c b/drivers/gpu/drm/zte/zx_drm_drv.c
new file mode 100644
index ..2476a9b92cea
--- /dev/null
+++ b/drivers/gpu/drm/zte/zx_drm_drv.c
@@ -0,0 +1,267 @@
+/*
+ * Copyright 2016 Linaro Ltd.
+ * Copyright 2016 ZTE Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "zx_drm_drv.h"
+#include "zx_vou.h"
+
+struct zx_drm_private {
+   struct drm_fbdev_cma *fbdev;
+};
+
+static void zx_drm_fb_output_poll_changed(struct drm_device *drm)
+{
+   struct zx_drm_private *priv = drm->dev_private;
+
+   drm_fbdev_cma_hotplug_event(priv->fbdev);
+}
+
+static const struct drm_mode_config_funcs zx_drm_mode_config_funcs = {
+   .fb_create = drm_fb_cma_create,
+   .output_poll_changed = zx_drm_fb_output_poll_changed,
+   .atomic_check = drm_atomic_helper_check,
+   .atomic_commit = drm_atomic_helper_commit,
+};
+
+static void zx_drm_lastclose(struct drm_device *drm)
+{
+   struct zx_drm_private *priv = drm->dev_private;
+
+   drm_fbdev_cma_restore_mode(priv->fbdev);
+}
+
+static const struct file_operations zx_drm_fops = {
+   .owner = THIS_MODULE,
+   .open = drm_open,
+   .release = drm_release,
+   .unlocked_ioctl = drm_ioctl,
+#ifdef CONFIG_COMPAT
+   .compat_ioctl = drm_compat_ioctl,
+#endif
+   .poll = drm_poll,
+   .read = drm_read,
+   .llseek = noop_llseek,
+   .mmap = drm_gem_cma_mmap,
+};
+
+static struct drm_driver zx_drm_driver = {
+   .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
+  DRIVER_ATOMIC,
+   .lastclose = zx_drm_lastclose,
+   .get_vblank_counter = drm_vblank_no_hw_counter,
+   .enable_vblank = zx_vou_enable_vblank,
+   .disab

[PATCH v3 3/3] MAINTAINERS: add an entry for ZTE ZX DRM driver

2016-10-20 Thread Shawn Guo
Add myself as the maintainer of ZTE ZX DRM driver.

Signed-off-by: Shawn Guo 
---
 MAINTAINERS | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 1cd38a7e0064..907dbd3261c5 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4281,6 +4281,13 @@ S:   Maintained
 F: drivers/gpu/drm/tilcdc/
 F: Documentation/devicetree/bindings/display/tilcdc/

+DRM DRIVERS FOR ZTE ZX
+M: Shawn Guo 
+L: dri-devel at lists.freedesktop.org
+S: Maintained
+F: drivers/gpu/drm/zte/
+F: Documentation/devicetree/bindings/display/zte,vou.txt
+
 DSBR100 USB FM RADIO DRIVER
 M: Alexey Klimov 
 L: linux-media at vger.kernel.org
-- 
1.9.1



Re: [PATCH 4/4] drm: zte: add VGA driver support

2017-04-04 Thread Shawn Guo
On Mon, Apr 03, 2017 at 11:23:51AM +0200, Daniel Vetter wrote:
> > +static int zx_vga_ddc_register(struct zx_vga *vga)
> > +{
> > +   struct device *dev = vga->dev;
> > +   struct i2c_adapter *adap;
> > +   struct zx_vga_i2c *ddc;
> > +   int ret;
> > +
> > +   ddc = devm_kzalloc(dev, sizeof(*ddc), GFP_KERNEL);
> > +   if (!ddc)
> > +   return -ENOMEM;
> > +
> > +   vga->ddc = ddc;
> > +   mutex_init(&ddc->lock);
> > +
> > +   adap = &ddc->adap;
> > +   adap->owner = THIS_MODULE;
> > +   adap->class = I2C_CLASS_DDC;
> > +   adap->dev.parent = dev;
> > +   adap->algo = &zx_vga_algorithm;
> > +   snprintf(adap->name, sizeof(adap->name), "zx vga i2c");
> > +
> > +   ret = i2c_add_adapter(adap);
> > +   if (ret) {
> > +   DRM_DEV_ERROR(dev, "failed to add I2C adapter: %d\n", ret);
> > +   return ret;
> > +   }
> > +
> > +   i2c_set_adapdata(adap, vga);
> 
> Since this really isn't a full-featured i2c adapter but a specialized
> "give me the edid" thing I think you should look into drm_do_get_edid and
> _not_ expose the i2c thing. That should simplify your code a lot, and
> avoid any kind of synchronization issues between userspace i2c access and
> your driver's access (which you atm don't handle at all).

I'm a bit confused here.  Could you give me some more details on how to
know it's a full-featured I2C bus or specialized "give me the edid" one?
My understanding is that the ZTE hardware for reading HDMI and VGA EDID
are different but pretty similar.  But in HDMI driver review [1], you
gave the opposite comment, asking to change to I2C adapter from
drm_do_get_edid().  I'm wondering how you see that the hardware in HDMI
is a full-featured I2C bus, while the one in VGA is a specialized bus?

Shawn

[1] https://patchwork.kernel.org/patch/9349195/
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/4] drm: zte: add VGA driver support

2017-04-04 Thread Shawn Guo
On Tue, Apr 04, 2017 at 01:32:39PM -0400, Sean Paul wrote:
> On Tue, Apr 04, 2017 at 09:47:38PM +0800, Shawn Guo wrote:
> > On Mon, Apr 03, 2017 at 11:23:51AM +0200, Daniel Vetter wrote:
> > > > +static int zx_vga_ddc_register(struct zx_vga *vga)
> > > > +{
> > > > +   struct device *dev = vga->dev;
> > > > +   struct i2c_adapter *adap;
> > > > +   struct zx_vga_i2c *ddc;
> > > > +   int ret;
> > > > +
> > > > +   ddc = devm_kzalloc(dev, sizeof(*ddc), GFP_KERNEL);
> > > > +   if (!ddc)
> > > > +   return -ENOMEM;
> > > > +
> > > > +   vga->ddc = ddc;
> > > > +   mutex_init(&ddc->lock);
> > > > +
> > > > +   adap = &ddc->adap;
> > > > +   adap->owner = THIS_MODULE;
> > > > +   adap->class = I2C_CLASS_DDC;
> > > > +   adap->dev.parent = dev;
> > > > +   adap->algo = &zx_vga_algorithm;
> > > > +   snprintf(adap->name, sizeof(adap->name), "zx vga i2c");
> > > > +
> > > > +   ret = i2c_add_adapter(adap);
> > > > +   if (ret) {
> > > > +   DRM_DEV_ERROR(dev, "failed to add I2C adapter: %d\n", 
> > > > ret);
> > > > +   return ret;
> > > > +   }
> > > > +
> > > > +   i2c_set_adapdata(adap, vga);
> > > 
> > > Since this really isn't a full-featured i2c adapter but a specialized
> > > "give me the edid" thing I think you should look into drm_do_get_edid and
> > > _not_ expose the i2c thing. That should simplify your code a lot, and
> > > avoid any kind of synchronization issues between userspace i2c access and
> > > your driver's access (which you atm don't handle at all).
> > 
> > I'm a bit confused here.  Could you give me some more details on how to
> > know it's a full-featured I2C bus or specialized "give me the edid" one?
> > My understanding is that the ZTE hardware for reading HDMI and VGA EDID
> > are different but pretty similar.  But in HDMI driver review [1], you
> > gave the opposite comment, asking to change to I2C adapter from
> > drm_do_get_edid().  I'm wondering how you see that the hardware in HDMI
> > is a full-featured I2C bus, while the one in VGA is a specialized bus?
> 
> That was my suggestion :-)

It was Daniel's too.  He commented as below under function
zx_hdmi_get_edid_block().

"It looks like the ZX_DDC register range implements a hw i2c engine (since
you specifiy port and offsets and everything). Please implement it as an
i2c_adapter driver and use the normal drm_get_edid function."

Shawn

> 
> At the time, it seemed like the hardware implemented a fully fledged i2c bus, 
> so
> I suggested you made it generic. In retrospect, since it can only read from 
> one
> address, the original implementation was fine.
> 
> Given the HDMI adapter is implemented the same way, I'm inclined to favor this
> version, but Daniel might disagree with me.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/4] drm: zte: add VGA driver support

2017-04-05 Thread Shawn Guo
On Tue, Apr 04, 2017 at 01:46:48PM -0400, Sean Paul wrote:
> > +static int zx_vga_register(struct drm_device *drm, struct zx_vga *vga)
> > +{
> > +   struct drm_encoder *encoder = &vga->encoder;
> > +   struct drm_connector *connector = &vga->connector;
> > +
> > +   encoder->possible_crtcs = VOU_CRTC_MASK;
> > +
> > +   drm_encoder_init(drm, encoder, &zx_vga_encoder_funcs,
> > +DRM_MODE_ENCODER_DAC, NULL);
> > +   drm_encoder_helper_add(encoder, &zx_vga_encoder_helper_funcs);
> > +
> > +   vga->connector.polled = DRM_CONNECTOR_POLL_HPD;
> > +
> > +   drm_connector_init(drm, connector, &zx_vga_connector_funcs,
> > +  DRM_MODE_CONNECTOR_VGA);
> > +   drm_connector_helper_add(connector, &zx_vga_connector_helper_funcs);
> > +
> > +   drm_mode_connector_attach_encoder(connector, encoder);
> 
> You're missing a couple of return value checks in this function.

Okay.  I will add return checks in the new version.

> 
> > +
> > +   return 0;
> > +}



> > +static irqreturn_t zx_vga_irq_handler(int irq, void *dev_id)
> > +{
> > +   struct zx_vga *vga = dev_id;
> > +   u32 status;
> > +
> > +   status = zx_readl(vga->mmio + VGA_I2C_STATUS);
> > +
> > +   /* Clear interrupt status */
> > +   zx_writel_mask(vga->mmio + VGA_I2C_STATUS, VGA_CLEAR_IRQ,
> > +  VGA_CLEAR_IRQ);
> > +
> > +   if (status & VGA_DEVICE_CONNECTED) {
> > +   /*
> > +* We should ideally set up VGA_DETECT_SEL_HAS_DEVICE bit here
> > +* for unplug detection, but doing so will stop DDC bus from
> > +* reading EDID later on. It looks like a HW limitation, and we
> > +* work around it by defering the bit setup to .get_modes hook
> > +* after EDID read succeeds.
> 
> get_modes resets VGA_AUTO_DETECT_SEL before and after reading edid, so is it
> really necessary to defer setting it here?

Okay, the comment in the code seems confusing.  Since we need to reset
VGA_AUTO_DETECT_SEL bits to switch DDC bus from device detecting to EDID
reading, VGA_DETECT_SEL_HAS_DEVICE will need to be set after reading
EDID anyway.  I will improve the comment.

> 
> > +*/
> > +   vga->connected = true;
> > +   return IRQ_WAKE_THREAD;
> > +   }
> > +
> > +   if (status & VGA_DEVICE_DISCONNECTED) {
> > +   zx_writel(vga->mmio + VGA_AUTO_DETECT_SEL,
> > + VGA_DETECT_SEL_NO_DEVICE);
> 
> This races with get_modes, you should serialize access to this register.

Good catch.  I will add lock for it.

Shawn

> 
> > +   vga->connected = false;
> > +   return IRQ_WAKE_THREAD;
> > +   }
> > +
> > +   if (status & VGA_TRANS_DONE) {
> > +   complete(&vga->complete);
> > +   return IRQ_HANDLED;
> > +   }
> > +
> > +   return IRQ_NONE;
> > +}
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 0/4] Add ZTE VGA driver support

2017-04-06 Thread Shawn Guo
From: Shawn Guo 

The series adds the driver for ZTE VGA device, which becomes the third
VOU output device we support, besides the existing HDMI and TV Encoder.

Changes for v2:
 - Add return check for encoder and connector init function calls.
 - Improve comments in function zx_vga_irq_handler() to avoid confusion.
 - Add lock for VGA_AUTO_DETECT_SEL register access to avoid race
   condition between irq handler and .get_modes hook.
 - Copy device tree maintainer and list for bindings doc.

Shawn Guo (4):
  drm: zte: do not enable clock auto-gating by default
  drm: zte: move CSC register definitions into a common header
  dt-bindings: display: add support for ZTE VGA device
  drm: zte: add VGA driver support

 .../devicetree/bindings/display/zte,vou.txt|  21 +
 drivers/gpu/drm/zte/Makefile   |   1 +
 drivers/gpu/drm/zte/zx_common_regs.h   |  31 ++
 drivers/gpu/drm/zte/zx_drm_drv.c   |   1 +
 drivers/gpu/drm/zte/zx_drm_drv.h   |   1 +
 drivers/gpu/drm/zte/zx_plane.c |   1 +
 drivers/gpu/drm/zte/zx_plane_regs.h|  18 -
 drivers/gpu/drm/zte/zx_vga.c   | 530 +
 drivers/gpu/drm/zte/zx_vga_regs.h  |  36 ++
 drivers/gpu/drm/zte/zx_vou.c   |  36 +-
 drivers/gpu/drm/zte/zx_vou_regs.h  |  12 +-
 11 files changed, 663 insertions(+), 25 deletions(-)
 create mode 100644 drivers/gpu/drm/zte/zx_common_regs.h
 create mode 100644 drivers/gpu/drm/zte/zx_vga.c
 create mode 100644 drivers/gpu/drm/zte/zx_vga_regs.h

-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 3/4] dt-bindings: display: add support for ZTE VGA device

2017-04-06 Thread Shawn Guo
From: Shawn Guo 

It adds bindings doc for ZTE VOU VGA output device.

Signed-off-by: Shawn Guo 
---
 .../devicetree/bindings/display/zte,vou.txt | 21 +
 1 file changed, 21 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/zte,vou.txt 
b/Documentation/devicetree/bindings/display/zte,vou.txt
index 9c356284232b..38476475fd60 100644
--- a/Documentation/devicetree/bindings/display/zte,vou.txt
+++ b/Documentation/devicetree/bindings/display/zte,vou.txt
@@ -58,6 +58,18 @@ Required properties:
integer cells.  The first cell is the offset of SYSCTRL register used
to control TV Encoder DAC power, and the second cell is the bit mask.
 
+* VGA output device
+
+Required properties:
+ - compatible: should be "zte,zx296718-vga"
+ - reg: Physical base address and length of the VGA device IO region
+ - interrupts : VGA interrupt number to CPU
+ - clocks: Phandle with clock-specifier pointing to VGA I2C clock.
+ - clock-names: Must be "i2c_wclk".
+ - zte,vga-power-control: the phandle to SYSCTRL block followed by two
+   integer cells.  The first cell is the offset of SYSCTRL register used
+   to control VGA DAC power, and the second cell is the bit mask.
+
 Example:
 
 vou: vou@144 {
@@ -81,6 +93,15 @@ vou: vou@144 {
  "main_wclk", "aux_wclk";
};
 
+   vga: vga@8000 {
+   compatible = "zte,zx296718-vga";
+   reg = <0x8000 0x1000>;
+   interrupts = ;
+   clocks = <&topcrm VGA_I2C_WCLK>;
+   clock-names = "i2c_wclk";
+   zte,vga-power-control = <&sysctrl 0x170 0xe0>;
+   };
+
hdmi: hdmi@c000 {
compatible = "zte,zx296718-hdmi";
reg = <0xc000 0x4000>;
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 1/4] drm: zte: do not enable clock auto-gating by default

2017-04-06 Thread Shawn Guo
From: Shawn Guo 

Some VOU modules do not work well with clock auto-gating.  For example,
VGA I2C bus will fail to read EDID data from monitor.  Let's not enable
this feature by default, and leave it to the possible future low-power
optimization.

Signed-off-by: Shawn Guo 
Reviewed-by: Sean Paul 
Acked-by: Daniel Vetter 
---
 drivers/gpu/drm/zte/zx_vou.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/gpu/drm/zte/zx_vou.c b/drivers/gpu/drm/zte/zx_vou.c
index cf92d675feaa..2a2d90bd9425 100644
--- a/drivers/gpu/drm/zte/zx_vou.c
+++ b/drivers/gpu/drm/zte/zx_vou.c
@@ -720,9 +720,6 @@ static void vou_hw_init(struct zx_vou_hw *vou)
/* Release reset for all VOU modules */
zx_writel(vou->vouctl + VOU_SOFT_RST, ~0);
 
-   /* Enable clock auto-gating for all VOU modules */
-   zx_writel(vou->vouctl + VOU_CLK_REQEN, ~0);
-
/* Enable all VOU module clocks */
zx_writel(vou->vouctl + VOU_CLK_EN, ~0);
 
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 2/4] drm: zte: move CSC register definitions into a common header

2017-04-06 Thread Shawn Guo
From: Shawn Guo 

The CSC (Color Space Conversion) block in VOU is used by not only
Graphic Layer (plane) but also channel (CRTC) module.  Let's move
its register definitions into a common header, so that CRTC driver can
include it when needed.

Signed-off-by: Shawn Guo 
Reviewed-by: Sean Paul 
Acked-by: Daniel Vetter 
---
 drivers/gpu/drm/zte/zx_common_regs.h | 31 +++
 drivers/gpu/drm/zte/zx_plane.c   |  1 +
 drivers/gpu/drm/zte/zx_plane_regs.h  | 18 --
 3 files changed, 32 insertions(+), 18 deletions(-)
 create mode 100644 drivers/gpu/drm/zte/zx_common_regs.h

diff --git a/drivers/gpu/drm/zte/zx_common_regs.h 
b/drivers/gpu/drm/zte/zx_common_regs.h
new file mode 100644
index ..2afd80664c51
--- /dev/null
+++ b/drivers/gpu/drm/zte/zx_common_regs.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * Copyright 2017 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __ZX_COMMON_REGS_H__
+#define __ZX_COMMON_REGS_H__
+
+/* CSC registers */
+#define CSC_CTRL0  0x30
+#define CSC_COV_MODE_SHIFT 16
+#define CSC_COV_MODE_MASK  (0x << CSC_COV_MODE_SHIFT)
+#define CSC_BT601_IMAGE_RGB2YCBCR  0
+#define CSC_BT601_IMAGE_YCBCR2RGB  1
+#define CSC_BT601_VIDEO_RGB2YCBCR  2
+#define CSC_BT601_VIDEO_YCBCR2RGB  3
+#define CSC_BT709_IMAGE_RGB2YCBCR  4
+#define CSC_BT709_IMAGE_YCBCR2RGB  5
+#define CSC_BT709_VIDEO_RGB2YCBCR  6
+#define CSC_BT709_VIDEO_YCBCR2RGB  7
+#define CSC_BT2020_IMAGE_RGB2YCBCR 8
+#define CSC_BT2020_IMAGE_YCBCR2RGB 9
+#define CSC_BT2020_VIDEO_RGB2YCBCR 10
+#define CSC_BT2020_VIDEO_YCBCR2RGB 11
+#define CSC_WORK_ENABLEBIT(0)
+
+#endif /* __ZX_COMMON_REGS_H__ */
diff --git a/drivers/gpu/drm/zte/zx_plane.c b/drivers/gpu/drm/zte/zx_plane.c
index d646ac931663..4a6252720c10 100644
--- a/drivers/gpu/drm/zte/zx_plane.c
+++ b/drivers/gpu/drm/zte/zx_plane.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include "zx_common_regs.h"
 #include "zx_drm_drv.h"
 #include "zx_plane.h"
 #include "zx_plane_regs.h"
diff --git a/drivers/gpu/drm/zte/zx_plane_regs.h 
b/drivers/gpu/drm/zte/zx_plane_regs.h
index 65f271aeabed..9c655f59f9f7 100644
--- a/drivers/gpu/drm/zte/zx_plane_regs.h
+++ b/drivers/gpu/drm/zte/zx_plane_regs.h
@@ -77,24 +77,6 @@
 #define LUMA_STRIDE(x)  (((x) << LUMA_STRIDE_SHIFT) & LUMA_STRIDE_MASK)
 #define CHROMA_STRIDE(x) (((x) << CHROMA_STRIDE_SHIFT) & CHROMA_STRIDE_MASK)
 
-/* CSC registers */
-#define CSC_CTRL0  0x30
-#define CSC_COV_MODE_SHIFT 16
-#define CSC_COV_MODE_MASK  (0x << CSC_COV_MODE_SHIFT)
-#define CSC_BT601_IMAGE_RGB2YCBCR  0
-#define CSC_BT601_IMAGE_YCBCR2RGB  1
-#define CSC_BT601_VIDEO_RGB2YCBCR  2
-#define CSC_BT601_VIDEO_YCBCR2RGB  3
-#define CSC_BT709_IMAGE_RGB2YCBCR  4
-#define CSC_BT709_IMAGE_YCBCR2RGB  5
-#define CSC_BT709_VIDEO_RGB2YCBCR  6
-#define CSC_BT709_VIDEO_YCBCR2RGB  7
-#define CSC_BT2020_IMAGE_RGB2YCBCR 8
-#define CSC_BT2020_IMAGE_YCBCR2RGB 9
-#define CSC_BT2020_VIDEO_RGB2YCBCR 10
-#define CSC_BT2020_VIDEO_YCBCR2RGB 11
-#define CSC_WORK_ENABLEBIT(0)
-
 /* RSZ registers */
 #define RSZ_SRC_CFG0x00
 #define RSZ_DEST_CFG   0x04
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 4/4] drm: zte: add VGA driver support

2017-04-06 Thread Shawn Guo
From: Shawn Guo 

It adds VGA driver support, which needs to configure corresponding VOU
interface in RGB_888 format, and thus the following changes are needed
on zx_vou.

- Rename the CSC block of Graphic Layer a bit to make it more specific,
  and add CSC of Channel to support RGB output.
- Bypass Dither block for RGB output.

Signed-off-by: Shawn Guo 
Acked-by: Daniel Vetter 
---
 drivers/gpu/drm/zte/Makefile  |   1 +
 drivers/gpu/drm/zte/zx_drm_drv.c  |   1 +
 drivers/gpu/drm/zte/zx_drm_drv.h  |   1 +
 drivers/gpu/drm/zte/zx_vga.c  | 530 ++
 drivers/gpu/drm/zte/zx_vga_regs.h |  36 +++
 drivers/gpu/drm/zte/zx_vou.c  |  33 ++-
 drivers/gpu/drm/zte/zx_vou_regs.h |  12 +-
 7 files changed, 610 insertions(+), 4 deletions(-)
 create mode 100644 drivers/gpu/drm/zte/zx_vga.c
 create mode 100644 drivers/gpu/drm/zte/zx_vga_regs.h

diff --git a/drivers/gpu/drm/zte/Makefile b/drivers/gpu/drm/zte/Makefile
index 01352b56c418..9df7766a7f9d 100644
--- a/drivers/gpu/drm/zte/Makefile
+++ b/drivers/gpu/drm/zte/Makefile
@@ -3,6 +3,7 @@ zxdrm-y := \
zx_hdmi.o \
zx_plane.o \
zx_tvenc.o \
+   zx_vga.o \
zx_vou.o
 
 obj-$(CONFIG_DRM_ZTE) += zxdrm.o
diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c b/drivers/gpu/drm/zte/zx_drm_drv.c
index 5c6944a1e72c..8a6892eeb44f 100644
--- a/drivers/gpu/drm/zte/zx_drm_drv.c
+++ b/drivers/gpu/drm/zte/zx_drm_drv.c
@@ -248,6 +248,7 @@ static int zx_drm_remove(struct platform_device *pdev)
&zx_crtc_driver,
&zx_hdmi_driver,
&zx_tvenc_driver,
+   &zx_vga_driver,
&zx_drm_platform_driver,
 };
 
diff --git a/drivers/gpu/drm/zte/zx_drm_drv.h b/drivers/gpu/drm/zte/zx_drm_drv.h
index 5ca035b079c7..2a8cdc5f8be4 100644
--- a/drivers/gpu/drm/zte/zx_drm_drv.h
+++ b/drivers/gpu/drm/zte/zx_drm_drv.h
@@ -14,6 +14,7 @@
 extern struct platform_driver zx_crtc_driver;
 extern struct platform_driver zx_hdmi_driver;
 extern struct platform_driver zx_tvenc_driver;
+extern struct platform_driver zx_vga_driver;
 
 static inline u32 zx_readl(void __iomem *reg)
 {
diff --git a/drivers/gpu/drm/zte/zx_vga.c b/drivers/gpu/drm/zte/zx_vga.c
new file mode 100644
index ..0d850d9ea700
--- /dev/null
+++ b/drivers/gpu/drm/zte/zx_vga.c
@@ -0,0 +1,530 @@
+/*
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * Copyright 2017 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "zx_drm_drv.h"
+#include "zx_vga_regs.h"
+#include "zx_vou.h"
+
+struct zx_vga_pwrctrl {
+   struct regmap *regmap;
+   u32 reg;
+   u32 mask;
+};
+
+struct zx_vga_i2c {
+   struct i2c_adapter adap;
+   struct mutex lock;
+};
+
+struct zx_vga {
+   struct drm_connector connector;
+   struct drm_encoder encoder;
+   struct zx_vga_i2c *ddc;
+   struct device *dev;
+   void __iomem *mmio;
+   struct clk *i2c_wclk;
+   struct zx_vga_pwrctrl pwrctrl;
+   spinlock_t lock;
+   struct completion complete;
+   bool connected;
+};
+
+#define to_zx_vga(x) container_of(x, struct zx_vga, x)
+
+static void zx_vga_encoder_enable(struct drm_encoder *encoder)
+{
+   struct zx_vga *vga = to_zx_vga(encoder);
+   struct zx_vga_pwrctrl *pwrctrl = &vga->pwrctrl;
+
+   /* Set bit to power up VGA DACs */
+   regmap_update_bits(pwrctrl->regmap, pwrctrl->reg, pwrctrl->mask,
+  pwrctrl->mask);
+
+   vou_inf_enable(VOU_VGA, encoder->crtc);
+}
+
+static void zx_vga_encoder_disable(struct drm_encoder *encoder)
+{
+   struct zx_vga *vga = to_zx_vga(encoder);
+   struct zx_vga_pwrctrl *pwrctrl = &vga->pwrctrl;
+
+   vou_inf_disable(VOU_VGA, encoder->crtc);
+
+   /* Clear bit to power down VGA DACs */
+   regmap_update_bits(pwrctrl->regmap, pwrctrl->reg, pwrctrl->mask, 0);
+}
+
+static const struct drm_encoder_helper_funcs zx_vga_encoder_helper_funcs = {
+   .enable = zx_vga_encoder_enable,
+   .disable = zx_vga_encoder_disable,
+};
+
+static const struct drm_encoder_funcs zx_vga_encoder_funcs = {
+   .destroy = drm_encoder_cleanup,
+};
+
+static int zx_vga_connector_get_modes(struct drm_connector *connector)
+{
+   struct zx_vga *vga = to_zx_vga(connector);
+   unsigned long flags;
+   struct edid *edid;
+   int ret;
+
+   /*
+* Clear both detection bits to switch I2C bus from device
+* detecting to EDID reading.
+*/
+   spin_lock_irqsave(&vga->lock, flags);
+   zx_writel(vga->mmio + VGA_AUTO_DETECT_SEL, 0);
+   spin_unlock_irqrestore(&vga->lock, flags);
+
+   edid = drm_get_edid(connector, &vga->ddc-&g

Re: [PATCH v2 4/4] drm: zte: add VGA driver support

2017-04-06 Thread Shawn Guo
On Thu, Apr 06, 2017 at 01:12:51PM -0400, Sean Paul wrote:
> On Thu, Apr 06, 2017 at 11:01:10PM +0800, Shawn Guo wrote:
> > +static int zx_vga_connector_get_modes(struct drm_connector *connector)
> > +{
> > +   struct zx_vga *vga = to_zx_vga(connector);
> > +   unsigned long flags;
> > +   struct edid *edid;
> > +   int ret;
> > +
> > +   /*
> > +* Clear both detection bits to switch I2C bus from device
> > +* detecting to EDID reading.
> > +*/
> > +   spin_lock_irqsave(&vga->lock, flags);
> > +   zx_writel(vga->mmio + VGA_AUTO_DETECT_SEL, 0);
> > +   spin_unlock_irqrestore(&vga->lock, flags);
> > +
> > +   edid = drm_get_edid(connector, &vga->ddc->adap);
> > +   if (!edid)
> > +   return 0;
> > +
> > +   /*
> > +* As edid reading succeeds, device must be connected, so we set
> > +* up detection bit for unplug interrupt here.
> > +*/
> > +   spin_lock_irqsave(&vga->lock, flags);
> > +   zx_writel(vga->mmio + VGA_AUTO_DETECT_SEL, VGA_DETECT_SEL_HAS_DEVICE);
> > +   spin_unlock_irqrestore(&vga->lock, flags);
> > +
> > +   drm_mode_connector_update_edid_property(connector, edid);
> > +   ret = drm_add_edid_modes(connector, edid);
> > +   kfree(edid);
> > +
> > +   return ret;
> > +}



> > +static irqreturn_t zx_vga_irq_handler(int irq, void *dev_id)
> > +{
> > +   struct zx_vga *vga = dev_id;
> > +   u32 status;
> > +
> > +   status = zx_readl(vga->mmio + VGA_I2C_STATUS);
> > +
> > +   /* Clear interrupt status */
> > +   zx_writel_mask(vga->mmio + VGA_I2C_STATUS, VGA_CLEAR_IRQ,
> > +  VGA_CLEAR_IRQ);
> > +
> > +   if (status & VGA_DEVICE_CONNECTED) {
> > +   /*
> > +* Since VGA_DETECT_SEL bits need to be reset for switching DDC
> > +* bus from device detection to EDID read, rather than setting
> > +* up HAS_DEVICE bit here, we need to do that in .get_modes
> > +* hook for unplug detecting after EDID read succeeds.
> > +*/
> > +   vga->connected = true;
> > +   return IRQ_WAKE_THREAD;
> > +   }
> > +
> > +   if (status & VGA_DEVICE_DISCONNECTED) {
> > +   spin_lock(&vga->lock);
> > +   zx_writel(vga->mmio + VGA_AUTO_DETECT_SEL,
> > + VGA_DETECT_SEL_NO_DEVICE);
> > +   spin_unlock(&vga->lock);
> 
> I think you still have the race here. If you get a disconnect between get_edid
> successfully finishing, and resetting the DETECT_SEL register, you will end up
> with the device being disconnected and DETECT_SEL == 
> VGA_DETECT_SEL_HAS_DEVICE.
> 
> In order to close this, you'll need to hold the lock across the edid read.

We cannot hold a spin lock across the EDID read procedure, which does
sleep.

When you suggested to have a lock for DETECT_SEL register access, I
thought we are accessing it in a read-modify-write way and thus agreed
to add a lock.  However, I just found that it's not the case actually.
All the accesses to the register are single direct write.

And here is my understanding about the condition you described above.
Once DETECT_SEL register gets reset (both bits cleared), the hardware
switches DDC bus for EDID read, and hotplug detection will stop working
right away (this is how ZTE hardware works).  That said, if we get a
disconnect before drm_get_edid() successfully finishes, two points:

- The irq handler will not be triggered, so it will not get a chance to
  update DETECT_SEL register.
- The drm_get_edid() fails, and .get_modes returns with both detect bits
  kept cleared.

I think what we can do better in this case is that we should set the
device state into disconnected, before returning from .get_modes,
something like the code below.  But still, I do not see we need a lock
for that.

Shawn

static int zx_vga_connector_get_modes(struct drm_connector *connector)
{
struct zx_vga *vga = to_zx_vga(connector);
unsigned long flags;
struct edid *edid;
int ret;

/*
 * Clear both detection bits to switch I2C bus from device
 * detecting to EDID reading.
 */
zx_writel(vga->mmio + VGA_AUTO_DETECT_SEL, 0);

edid = drm_get_edid(connector, &vga->ddc->adap);
if (!edid) {
/*
 * If EDID reading fails, we set the device state into
 * disconnected.
 */
zx_writel(vga->mmio + VGA_AUTO_DETECT_SEL,
  VGA_DETECT_SEL_NO_DEVICE);
vga->connected = false;
   

Re: [PATCH v2 4/4] drm: zte: add VGA driver support

2017-04-11 Thread Shawn Guo
On Fri, Apr 07, 2017 at 10:43:02AM -0400, Sean Paul wrote:
> On Fri, Apr 07, 2017 at 11:02:33AM +0800, Shawn Guo wrote:
> > When you suggested to have a lock for DETECT_SEL register access, I
> > thought we are accessing it in a read-modify-write way and thus agreed
> > to add a lock.  However, I just found that it's not the case actually.
> > All the accesses to the register are single direct write.
> > 
> > And here is my understanding about the condition you described above.
> > Once DETECT_SEL register gets reset (both bits cleared), the hardware
> > switches DDC bus for EDID read, and hotplug detection will stop working
> > right away (this is how ZTE hardware works).  That said, if we get a
> > disconnect before drm_get_edid() successfully finishes, two points:
> > 
> > - The irq handler will not be triggered, so it will not get a chance to
> >   update DETECT_SEL register.
> 
> Ah, this was the missing piece I needed. I hadn't realized that the first
> VGA_AUTO_DETECT_SEL write in get_modes disabled the irq. 

Sorry, something is not true with my point.  The irq handler can still
be triggered, but the cause has to be something else than hotplug
interrupt, like EDID data transfer done or various error conditions.

So my point should be that the VGA_AUTO_DETECT_SEL reset at the
beginning of .get_modes disables hotplug detection interrupt, and irq
handler will not get any chance to write to the register in this case.

> > - The drm_get_edid() fails, and .get_modes returns with both detect bits
> >   kept cleared.
> > 
> > I think what we can do better in this case is that we should set the
> > device state into disconnected, before returning from .get_modes,
> > something like the code below.  But still, I do not see we need a lock
> > for that.
> 
> Yep, agreed. Can you also please add to your comment in the !edid case,
> something like:
> 
> * Locking is not required here since the only other place to write this 
> register
> * (and connected var) is the irq handler. The irq handler is disabled because
> * we've cleared AUTO_DETECT_SEL above.

Sure, thanks for the suggestion.  I will add proper comment in the new
version.

Shawn
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 4/4] drm: zte: add VGA driver support

2017-04-11 Thread Shawn Guo
From: Shawn Guo 

It adds VGA driver support, which needs to configure corresponding VOU
interface in RGB_888 format, and thus the following changes are needed
on zx_vou.

 - Rename the CSC block of Graphic Layer a bit to make it more specific,
   and add CSC of Channel to support RGB output.
 - Bypass Dither block for RGB output.

Signed-off-by: Shawn Guo 
Acked-by: Daniel Vetter 
---
Changes for v3:
 - Set device state into disconnected when edid read fails in .get_modes
   hook.
 - Drop locking and add comments for understanding why it's not
   necessary.

Changes for v2:
 - Add return check for encoder and connector init function calls.
 - Improve comments in function zx_vga_irq_handler() to avoid confusion.
 - Add lock for VGA_AUTO_DETECT_SEL register access to avoid race
   condition between irq handler and .get_modes hook.
 drivers/gpu/drm/zte/Makefile  |   1 +
 drivers/gpu/drm/zte/zx_drm_drv.c  |   1 +
 drivers/gpu/drm/zte/zx_drm_drv.h  |   1 +
 drivers/gpu/drm/zte/zx_vga.c  | 531 ++
 drivers/gpu/drm/zte/zx_vga_regs.h |  36 +++
 drivers/gpu/drm/zte/zx_vou.c  |  33 ++-
 drivers/gpu/drm/zte/zx_vou_regs.h |  12 +-
 7 files changed, 611 insertions(+), 4 deletions(-)
 create mode 100644 drivers/gpu/drm/zte/zx_vga.c
 create mode 100644 drivers/gpu/drm/zte/zx_vga_regs.h

diff --git a/drivers/gpu/drm/zte/Makefile b/drivers/gpu/drm/zte/Makefile
index 01352b56c418..9df7766a7f9d 100644
--- a/drivers/gpu/drm/zte/Makefile
+++ b/drivers/gpu/drm/zte/Makefile
@@ -3,6 +3,7 @@ zxdrm-y := \
zx_hdmi.o \
zx_plane.o \
zx_tvenc.o \
+   zx_vga.o \
zx_vou.o
 
 obj-$(CONFIG_DRM_ZTE) += zxdrm.o
diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c b/drivers/gpu/drm/zte/zx_drm_drv.c
index 5c6944a1e72c..8a6892eeb44f 100644
--- a/drivers/gpu/drm/zte/zx_drm_drv.c
+++ b/drivers/gpu/drm/zte/zx_drm_drv.c
@@ -248,6 +248,7 @@ static int zx_drm_remove(struct platform_device *pdev)
&zx_crtc_driver,
&zx_hdmi_driver,
&zx_tvenc_driver,
+   &zx_vga_driver,
&zx_drm_platform_driver,
 };
 
diff --git a/drivers/gpu/drm/zte/zx_drm_drv.h b/drivers/gpu/drm/zte/zx_drm_drv.h
index 5ca035b079c7..2a8cdc5f8be4 100644
--- a/drivers/gpu/drm/zte/zx_drm_drv.h
+++ b/drivers/gpu/drm/zte/zx_drm_drv.h
@@ -14,6 +14,7 @@
 extern struct platform_driver zx_crtc_driver;
 extern struct platform_driver zx_hdmi_driver;
 extern struct platform_driver zx_tvenc_driver;
+extern struct platform_driver zx_vga_driver;
 
 static inline u32 zx_readl(void __iomem *reg)
 {
diff --git a/drivers/gpu/drm/zte/zx_vga.c b/drivers/gpu/drm/zte/zx_vga.c
new file mode 100644
index ..1e0811f775cb
--- /dev/null
+++ b/drivers/gpu/drm/zte/zx_vga.c
@@ -0,0 +1,531 @@
+/*
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ * Copyright 2017 Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "zx_drm_drv.h"
+#include "zx_vga_regs.h"
+#include "zx_vou.h"
+
+struct zx_vga_pwrctrl {
+   struct regmap *regmap;
+   u32 reg;
+   u32 mask;
+};
+
+struct zx_vga_i2c {
+   struct i2c_adapter adap;
+   struct mutex lock;
+};
+
+struct zx_vga {
+   struct drm_connector connector;
+   struct drm_encoder encoder;
+   struct zx_vga_i2c *ddc;
+   struct device *dev;
+   void __iomem *mmio;
+   struct clk *i2c_wclk;
+   struct zx_vga_pwrctrl pwrctrl;
+   struct completion complete;
+   bool connected;
+};
+
+#define to_zx_vga(x) container_of(x, struct zx_vga, x)
+
+static void zx_vga_encoder_enable(struct drm_encoder *encoder)
+{
+   struct zx_vga *vga = to_zx_vga(encoder);
+   struct zx_vga_pwrctrl *pwrctrl = &vga->pwrctrl;
+
+   /* Set bit to power up VGA DACs */
+   regmap_update_bits(pwrctrl->regmap, pwrctrl->reg, pwrctrl->mask,
+  pwrctrl->mask);
+
+   vou_inf_enable(VOU_VGA, encoder->crtc);
+}
+
+static void zx_vga_encoder_disable(struct drm_encoder *encoder)
+{
+   struct zx_vga *vga = to_zx_vga(encoder);
+   struct zx_vga_pwrctrl *pwrctrl = &vga->pwrctrl;
+
+   vou_inf_disable(VOU_VGA, encoder->crtc);
+
+   /* Clear bit to power down VGA DACs */
+   regmap_update_bits(pwrctrl->regmap, pwrctrl->reg, pwrctrl->mask, 0);
+}
+
+static const struct drm_encoder_helper_funcs zx_vga_encoder_helper_funcs = {
+   .enable = zx_vga_encoder_enable,
+   .disable = zx_vga_encoder_disable,
+};
+
+static const struct drm_encoder_funcs zx_vga_encoder_funcs = {
+   .destroy = drm_encoder_cleanup,
+};
+
+static int zx_vga_connector_get_modes(struct drm_connector *connector)
+{
+   struct zx_vga *vga = to_zx_vga(connector);

Re: [PATCH v3 4/4] drm: zte: add VGA driver support

2017-05-02 Thread Shawn Guo
Hi Sean,

On Tue, Apr 11, 2017 at 7:30 PM, Shawn Guo  wrote:
> From: Shawn Guo 
>
> It adds VGA driver support, which needs to configure corresponding VOU
> interface in RGB_888 format, and thus the following changes are needed
> on zx_vou.
>
>  - Rename the CSC block of Graphic Layer a bit to make it more specific,
>and add CSC of Channel to support RGB output.
>  - Bypass Dither block for RGB output.
>
> Signed-off-by: Shawn Guo 
> Acked-by: Daniel Vetter 
> ---
> Changes for v3:
>  - Set device state into disconnected when edid read fails in .get_modes
>hook.
>  - Drop locking and add comments for understanding why it's not
>necessary.

Are you okay with this version?  I need a 'go' from you to push the
series to drm-misc-next.

Shawn
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/5] drm: zte: add interlace mode support

2017-01-25 Thread Shawn Guo
Hi Sean,

Thanks for reviewing the patches.

On Mon, Jan 23, 2017 at 10:19:01AM -0500, Sean Paul wrote:
> On Fri, Jan 20, 2017 at 12:24:56AM +0800, Shawn Guo wrote:
> > From: Shawn Guo 
> > 
> > It adds interlace mode support in VOU TIMING_CTRL and channel control
> > block, so that VOU driver gets ready to support output device in
> > interlace mode like TV Encoder.
> > 
> > Signed-off-by: Shawn Guo 
> > ---
> >  drivers/gpu/drm/zte/zx_vou.c  | 53 
> > +--
> >  drivers/gpu/drm/zte/zx_vou_regs.h | 15 +++
> >  2 files changed, 66 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/zte/zx_vou.c b/drivers/gpu/drm/zte/zx_vou.c
> > index 3056b41df518..8c4f0e2885f3 100644
> > --- a/drivers/gpu/drm/zte/zx_vou.c
> > +++ b/drivers/gpu/drm/zte/zx_vou.c
> 
> 
> 
> > @@ -196,19 +211,26 @@ static inline void vou_chn_set_update(struct zx_crtc 
> > *zcrtc)
> >  static void zx_crtc_enable(struct drm_crtc *crtc)
> >  {
> > struct drm_display_mode *mode = &crtc->state->adjusted_mode;
> > +   bool interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE;
> > struct zx_crtc *zcrtc = to_zx_crtc(crtc);
> > struct zx_vou_hw *vou = zcrtc->vou;
> > const struct zx_crtc_regs *regs = zcrtc->regs;
> > const struct zx_crtc_bits *bits = zcrtc->bits;
> > struct videomode vm;
> > +   u32 vactive;
> > u32 pol = 0;
> > u32 val;
> > +   u32 mask;
> > int ret;
> >  
> > drm_display_mode_to_videomode(mode, &vm);
> >  
> > /* Set up timing parameters */
> > -   val = V_ACTIVE(vm.vactive - 1);
> > +   vactive = vm.vactive;
> > +   if (interlaced)
> > +   vactive /= 2;
> > +
> > +   val = V_ACTIVE(vactive - 1);
> 
> Instead of introducing a new var, I think you can get away with:
> 
> if (interlaced)
> val = V_ACTIVE(vm.vactive / 2);
> else
> val = V_ACTIVE(vm.vactive - 1);

The variable is used by SEC_V_ACTIVE register setup below as well.  But
yeah, I admit this additional variable makes the code even harder for
readers.  I will kill it by having interlaced case check where
necessary.

> 
> 
> > val |= H_ACTIVE(vm.hactive - 1);
> > zx_writel(vou->timing + regs->fir_active, val);
> >  
> > @@ -222,6 +244,22 @@ static void zx_crtc_enable(struct drm_crtc *crtc)
> > val |= FRONT_PORCH(vm.vfront_porch - 1);
> > zx_writel(vou->timing + regs->fir_vtiming, val);
> >  
> > +   if (interlaced) {
> > +   u32 shift = bits->sec_vactive_shift;
> > +   u32 mask = bits->sec_vactive_mask;
> 
> mask is already defined at the function scope

Right.  I will rename the one in function scope to avoid the confusion.

> 
> > +
> > +   val = zx_readl(vou->timing + SEC_V_ACTIVE);
> > +   val &= ~mask;
> > +   val |= ((vactive - 1) << shift) & mask;
> > +   zx_writel(vou->timing + SEC_V_ACTIVE, val);
> > +
> > +   val = SYNC_WIDE(vm.vsync_len - 1);
> > +   /* sec_vbp = fir_vbp + 1 */
> 
> Looks like leftover kruft here.

It's actually a comment which seems to be only understandable by
myself :)  I will write up some proper text for it.

> 
> > +   val |= BACK_PORCH(vm.vback_porch);
> > +   val |= FRONT_PORCH(vm.vfront_porch - 1);
> > +   zx_writel(vou->timing + regs->sec_vtiming, val);
> > +   }
> > +
> > /* Set up polarities */
> > if (vm.flags & DISPLAY_FLAGS_VSYNC_LOW)
> > pol |= 1 << POL_VSYNC_SHIFT;
> > @@ -232,9 +270,16 @@ static void zx_crtc_enable(struct drm_crtc *crtc)
> >pol << bits->polarity_shift);
> >  
> > /* Setup SHIFT register by following what ZTE BSP does */
> > -   zx_writel(vou->timing + regs->timing_shift, H_SHIFT_VAL);
> > +   val = H_SHIFT_VAL;
> > +   if (interlaced)
> > +   val |= V_SHIFT_VAL << 16;
> > +   zx_writel(vou->timing + regs->timing_shift, val);
> > zx_writel(vou->timing + regs->timing_pi_shift, H_PI_SHIFT_VAL);
> >  
> > +   /* Progressive or interlace scan select */
> > +   mask = bits->interlace_select | bits->pi_enable;
> > +   zx_writel_mask(vou->timing + SCAN_CTRL, mask, interlaced ? mask : 0);
> > +
> > /* Enable TIMING_CTRL */
> > zx_writel_mask(vou->timing + TIMING_TC_ENABLE, bits->tc_enable,
> >bits-&

Re: [PATCH 5/5] drm: zte: add tvenc driver support

2017-01-26 Thread Shawn Guo
On Mon, Jan 23, 2017 at 11:10:34AM -0500, Sean Paul wrote:
> > +static const struct zx_tvenc_mode tvenc_modes[] = {
> > +   {
> > +   .name = "PAL",
> > +   .hdisplay = 720,
> > +   .vdisplay = 576,
> > +   .hfp = 12,
> > +   .hbp = 130,
> > +   .hsw = 2,
> > +   .vfp = 2,
> > +   .vbp = 20,
> > +   .vsw = 2,
> > +   .video_info = 0x00040040,
> > +   .video_res = 0x05a9c760,
> > +   .field1_param = 0x0004d416,
> > +   .field2_param = 0x0009b94f,
> > +   .burst_line_odd1 = 0x0004d406,
> > +   .burst_line_even1 = 0x0009b53e,
> > +   .burst_line_odd2 = 0x0004d805,
> > +   .burst_line_even2 = 0x0009b93f,
> > +   .line_timing_param = 0x06a96fdf,
> > +   .weight_value = 0x00c188a0,
> > +   .blank_black_level = 0xfcfc,
> > +   .burst_level = 0x1595,
> > +   .control_param = 0x0001,
> > +   .sub_carrier_phase1 = 0x1504c566,
> > +   .phase_line_incr_cvbs = 0xc068db8c,
> 
> I don't suppose you can derive these magic values from the mode?

No, we have no way to derive these register values from the mode
parameters.  The registers contain a lot of hardware specific
configurations which need to be set up differently per PAL or NTSC.

All other comments will be addressed in v2.  Thanks for the review
effort.

Shawn
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 0/5] Add TV Encoder support for ZTE DRM driver

2017-01-26 Thread Shawn Guo
From: Shawn Guo 

The series updates zx_vou driver a bit as the preparation of adding
TVENC output device, and then adds the device driver.

Changes for v2:
 - Save the use of variable 'vactive' by checking interlaced case.
 - Rename mask variable for scan register to avoid naming scope
   confusion.
 - Write a proper comment to explain how vback_porch of the first
   and second field are related.
 - Embed struct drm_display_mode in zx_tvenc_mode to save function
   zx_tvenc_mode_to_drm_mode().
 - Use drm_mode_equal() to find the matching mode.
 - Use drm_mode_set_name() to name mode.
 - Fix typos in clock multiplier comment.
 - Add a sanity check in .mode_valid hook to ensure the given mode is
   valid.
 - Remove destroy() calls from .unbind hook, as those are already taken
   care of by drm_mode_config_cleanup().

Shawn Guo (5):
  drm: zte: add interlace mode support
  drm: zte: move struct vou_inf into zx_vou driver
  drm: zte: add function to configure vou_ctrl dividers
  dt: add bindings for ZTE tvenc device
  drm: zte: add tvenc driver support

 .../devicetree/bindings/display/zte,vou.txt|  15 +
 drivers/gpu/drm/zte/Makefile   |   1 +
 drivers/gpu/drm/zte/zx_drm_drv.c   |   1 +
 drivers/gpu/drm/zte/zx_drm_drv.h   |   1 +
 drivers/gpu/drm/zte/zx_hdmi.c  |  12 +-
 drivers/gpu/drm/zte/zx_tvenc.c | 407 +
 drivers/gpu/drm/zte/zx_tvenc_regs.h|  31 ++
 drivers/gpu/drm/zte/zx_vou.c   | 167 -
 drivers/gpu/drm/zte/zx_vou.h   |  32 +-
 drivers/gpu/drm/zte/zx_vou_regs.h  |  31 ++
 10 files changed, 672 insertions(+), 26 deletions(-)
 create mode 100644 drivers/gpu/drm/zte/zx_tvenc.c
 create mode 100644 drivers/gpu/drm/zte/zx_tvenc_regs.h

-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 1/5] drm: zte: add interlace mode support

2017-01-26 Thread Shawn Guo
From: Shawn Guo 

It adds interlace mode support in VOU TIMING_CTRL and channel control
block, so that VOU driver gets ready to support output device in
interlace mode like TV Encoder.

Signed-off-by: Shawn Guo 
---
Changes for v2:
 - Save the use of variable 'vactive' by checking interlaced case.
 - Rename mask variable for scan register to avoid naming scope
   confusion.
 - Write a proper comment to explain how vback_porch of the first
   and second field are related.

 drivers/gpu/drm/zte/zx_vou.c  | 52 +--
 drivers/gpu/drm/zte/zx_vou_regs.h | 15 +++
 2 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/zte/zx_vou.c b/drivers/gpu/drm/zte/zx_vou.c
index 3056b41df518..fe066e0f3df4 100644
--- a/drivers/gpu/drm/zte/zx_vou.c
+++ b/drivers/gpu/drm/zte/zx_vou.c
@@ -40,6 +40,7 @@ struct zx_crtc_regs {
u32 fir_active;
u32 fir_htiming;
u32 fir_vtiming;
+   u32 sec_vtiming;
u32 timing_shift;
u32 timing_pi_shift;
 };
@@ -48,6 +49,7 @@ struct zx_crtc_regs {
.fir_active = FIR_MAIN_ACTIVE,
.fir_htiming = FIR_MAIN_H_TIMING,
.fir_vtiming = FIR_MAIN_V_TIMING,
+   .sec_vtiming = SEC_MAIN_V_TIMING,
.timing_shift = TIMING_MAIN_SHIFT,
.timing_pi_shift = TIMING_MAIN_PI_SHIFT,
 };
@@ -56,6 +58,7 @@ struct zx_crtc_regs {
.fir_active = FIR_AUX_ACTIVE,
.fir_htiming = FIR_AUX_H_TIMING,
.fir_vtiming = FIR_AUX_V_TIMING,
+   .sec_vtiming = SEC_AUX_V_TIMING,
.timing_shift = TIMING_AUX_SHIFT,
.timing_pi_shift = TIMING_AUX_PI_SHIFT,
 };
@@ -65,6 +68,10 @@ struct zx_crtc_bits {
u32 polarity_shift;
u32 int_frame_mask;
u32 tc_enable;
+   u32 sec_vactive_shift;
+   u32 sec_vactive_mask;
+   u32 interlace_select;
+   u32 pi_enable;
 };
 
 static const struct zx_crtc_bits main_crtc_bits = {
@@ -72,6 +79,10 @@ struct zx_crtc_bits {
.polarity_shift = MAIN_POL_SHIFT,
.int_frame_mask = TIMING_INT_MAIN_FRAME,
.tc_enable = MAIN_TC_EN,
+   .sec_vactive_shift = SEC_VACT_MAIN_SHIFT,
+   .sec_vactive_mask = SEC_VACT_MAIN_MASK,
+   .interlace_select = MAIN_INTERLACE_SEL,
+   .pi_enable = MAIN_PI_EN,
 };
 
 static const struct zx_crtc_bits aux_crtc_bits = {
@@ -79,6 +90,10 @@ struct zx_crtc_bits {
.polarity_shift = AUX_POL_SHIFT,
.int_frame_mask = TIMING_INT_AUX_FRAME,
.tc_enable = AUX_TC_EN,
+   .sec_vactive_shift = SEC_VACT_AUX_SHIFT,
+   .sec_vactive_mask = SEC_VACT_AUX_MASK,
+   .interlace_select = AUX_INTERLACE_SEL,
+   .pi_enable = AUX_PI_EN,
 };
 
 struct zx_crtc {
@@ -196,11 +211,13 @@ static inline void vou_chn_set_update(struct zx_crtc 
*zcrtc)
 static void zx_crtc_enable(struct drm_crtc *crtc)
 {
struct drm_display_mode *mode = &crtc->state->adjusted_mode;
+   bool interlaced = mode->flags & DRM_MODE_FLAG_INTERLACE;
struct zx_crtc *zcrtc = to_zx_crtc(crtc);
struct zx_vou_hw *vou = zcrtc->vou;
const struct zx_crtc_regs *regs = zcrtc->regs;
const struct zx_crtc_bits *bits = zcrtc->bits;
struct videomode vm;
+   u32 scan_mask;
u32 pol = 0;
u32 val;
int ret;
@@ -208,7 +225,7 @@ static void zx_crtc_enable(struct drm_crtc *crtc)
drm_display_mode_to_videomode(mode, &vm);
 
/* Set up timing parameters */
-   val = V_ACTIVE(vm.vactive - 1);
+   val = V_ACTIVE((interlaced ? vm.vactive / 2 : vm.vactive) - 1);
val |= H_ACTIVE(vm.hactive - 1);
zx_writel(vou->timing + regs->fir_active, val);
 
@@ -222,6 +239,25 @@ static void zx_crtc_enable(struct drm_crtc *crtc)
val |= FRONT_PORCH(vm.vfront_porch - 1);
zx_writel(vou->timing + regs->fir_vtiming, val);
 
+   if (interlaced) {
+   u32 shift = bits->sec_vactive_shift;
+   u32 mask = bits->sec_vactive_mask;
+
+   val = zx_readl(vou->timing + SEC_V_ACTIVE);
+   val &= ~mask;
+   val |= ((vm.vactive / 2 - 1) << shift) & mask;
+   zx_writel(vou->timing + SEC_V_ACTIVE, val);
+
+   val = SYNC_WIDE(vm.vsync_len - 1);
+   /*
+* The vback_porch for the second field needs to shift one on
+* the value for the first field.
+*/
+   val |= BACK_PORCH(vm.vback_porch);
+   val |= FRONT_PORCH(vm.vfront_porch - 1);
+   zx_writel(vou->timing + regs->sec_vtiming, val);
+   }
+
/* Set up polarities */
if (vm.flags & DISPLAY_FLAGS_VSYNC_LOW)
pol |= 1 << POL_VSYNC_SHIFT;
@@ -232,9 +268,17 @@ static void zx_crtc_enable(struct drm_crtc *crtc)
   pol << bits->polarity_shift);
 
/* Setup SHIFT register by following what ZTE BSP does */

[PATCH v2 2/5] drm: zte: move struct vou_inf into zx_vou driver

2017-01-26 Thread Shawn Guo
From: Shawn Guo 

Although data in struct vou_inf is defined per output device, it doesn't
belong to the device itself but VOU control module.  All these data can
just be defined in VOU driver, and output device driver only needs to
invoke VOU driver function with device ID to enable/disable specific
output device.

Signed-off-by: Shawn Guo 
Reviewed-by: Sean Paul 
---
 drivers/gpu/drm/zte/zx_hdmi.c | 12 ++--
 drivers/gpu/drm/zte/zx_vou.c  | 31 ---
 drivers/gpu/drm/zte/zx_vou.h  | 11 ++-
 3 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/zte/zx_hdmi.c b/drivers/gpu/drm/zte/zx_hdmi.c
index 6bf6c364811e..2f1e278ab50e 100644
--- a/drivers/gpu/drm/zte/zx_hdmi.c
+++ b/drivers/gpu/drm/zte/zx_hdmi.c
@@ -53,13 +53,6 @@ struct zx_hdmi {
 
 #define to_zx_hdmi(x) container_of(x, struct zx_hdmi, x)
 
-static const struct vou_inf vou_inf_hdmi = {
-   .id = VOU_HDMI,
-   .data_sel = VOU_YUV444,
-   .clocks_en_bits = BIT(24) | BIT(18) | BIT(6),
-   .clocks_sel_bits = BIT(13) | BIT(2),
-};
-
 static inline u8 hdmi_readb(struct zx_hdmi *hdmi, u16 offset)
 {
return readl_relaxed(hdmi->mmio + offset * 4);
@@ -238,14 +231,14 @@ static void zx_hdmi_encoder_enable(struct drm_encoder 
*encoder)
 
zx_hdmi_hw_enable(hdmi);
 
-   vou_inf_enable(hdmi->inf, encoder->crtc);
+   vou_inf_enable(VOU_HDMI, encoder->crtc);
 }
 
 static void zx_hdmi_encoder_disable(struct drm_encoder *encoder)
 {
struct zx_hdmi *hdmi = to_zx_hdmi(encoder);
 
-   vou_inf_disable(hdmi->inf, encoder->crtc);
+   vou_inf_disable(VOU_HDMI, encoder->crtc);
 
zx_hdmi_hw_disable(hdmi);
 
@@ -523,7 +516,6 @@ static int zx_hdmi_bind(struct device *dev, struct device 
*master, void *data)
 
hdmi->dev = dev;
hdmi->drm = drm;
-   hdmi->inf = &vou_inf_hdmi;
 
dev_set_drvdata(dev, hdmi);
 
diff --git a/drivers/gpu/drm/zte/zx_vou.c b/drivers/gpu/drm/zte/zx_vou.c
index fe066e0f3df4..a82ba294c7e1 100644
--- a/drivers/gpu/drm/zte/zx_vou.c
+++ b/drivers/gpu/drm/zte/zx_vou.c
@@ -158,6 +158,21 @@ struct zx_vou_hw {
struct zx_crtc *aux_crtc;
 };
 
+struct vou_inf {
+   enum vou_inf_id id;
+   enum vou_inf_data_sel data_sel;
+   u32 clocks_en_bits;
+   u32 clocks_sel_bits;
+};
+
+static struct vou_inf vou_infs[] = {
+   [VOU_HDMI] = {
+   .data_sel = VOU_YUV444,
+   .clocks_en_bits = BIT(24) | BIT(18) | BIT(6),
+   .clocks_sel_bits = BIT(13) | BIT(2),
+   },
+};
+
 static inline struct zx_vou_hw *crtc_to_vou(struct drm_crtc *crtc)
 {
struct zx_crtc *zcrtc = to_zx_crtc(crtc);
@@ -165,20 +180,21 @@ static inline struct zx_vou_hw *crtc_to_vou(struct 
drm_crtc *crtc)
return zcrtc->vou;
 }
 
-void vou_inf_enable(const struct vou_inf *inf, struct drm_crtc *crtc)
+void vou_inf_enable(enum vou_inf_id id, struct drm_crtc *crtc)
 {
struct zx_crtc *zcrtc = to_zx_crtc(crtc);
struct zx_vou_hw *vou = zcrtc->vou;
+   struct vou_inf *inf = &vou_infs[id];
bool is_main = zcrtc->chn_type == VOU_CHN_MAIN;
-   u32 data_sel_shift = inf->id << 1;
+   u32 data_sel_shift = id << 1;
 
/* Select data format */
zx_writel_mask(vou->vouctl + VOU_INF_DATA_SEL, 0x3 << data_sel_shift,
   inf->data_sel << data_sel_shift);
 
/* Select channel */
-   zx_writel_mask(vou->vouctl + VOU_INF_CH_SEL, 0x1 << inf->id,
-  zcrtc->chn_type << inf->id);
+   zx_writel_mask(vou->vouctl + VOU_INF_CH_SEL, 0x1 << id,
+  zcrtc->chn_type << id);
 
/* Select interface clocks */
zx_writel_mask(vou->vouctl + VOU_CLK_SEL, inf->clocks_sel_bits,
@@ -189,15 +205,16 @@ void vou_inf_enable(const struct vou_inf *inf, struct 
drm_crtc *crtc)
   inf->clocks_en_bits);
 
/* Enable the device */
-   zx_writel_mask(vou->vouctl + VOU_INF_EN, 1 << inf->id, 1 << inf->id);
+   zx_writel_mask(vou->vouctl + VOU_INF_EN, 1 << id, 1 << id);
 }
 
-void vou_inf_disable(const struct vou_inf *inf, struct drm_crtc *crtc)
+void vou_inf_disable(enum vou_inf_id id, struct drm_crtc *crtc)
 {
struct zx_vou_hw *vou = crtc_to_vou(crtc);
+   struct vou_inf *inf = &vou_infs[id];
 
/* Disable the device */
-   zx_writel_mask(vou->vouctl + VOU_INF_EN, 1 << inf->id, 0);
+   zx_writel_mask(vou->vouctl + VOU_INF_EN, 1 << id, 0);
 
/* Disable interface clocks */
zx_writel_mask(vou->vouctl + VOU_CLK_EN, inf->clocks_en_bits, 0);
diff --git a/drivers/gpu/drm/zte/zx_vou.h b/drivers/gpu/drm/zte/zx_vou.h
index 4b4339be641b..a41a0ad49857 100644
--- a/drivers/gpu/drm/zte/zx_vou.h
+++ b/drivers/gpu/drm/zte/zx_vou.h

[PATCH v2 3/5] drm: zte: add function to configure vou_ctrl dividers

2017-01-26 Thread Shawn Guo
From: Shawn Guo 

The clock control module (CRM) cannot always provide desired frequency
for all VOU output devices.  That's why VOU integrates a few dividers
to further divide the clocks from CRM.  Let's add an interface for
configuring these dividers.

Signed-off-by: Shawn Guo 
Reviewed-by: Sean Paul 
---
 drivers/gpu/drm/zte/zx_vou.c  | 79 +++
 drivers/gpu/drm/zte/zx_vou.h  | 25 +
 drivers/gpu/drm/zte/zx_vou_regs.h | 16 
 3 files changed, 120 insertions(+)

diff --git a/drivers/gpu/drm/zte/zx_vou.c b/drivers/gpu/drm/zte/zx_vou.c
index a82ba294c7e1..823b74ea758a 100644
--- a/drivers/gpu/drm/zte/zx_vou.c
+++ b/drivers/gpu/drm/zte/zx_vou.c
@@ -72,6 +72,13 @@ struct zx_crtc_bits {
u32 sec_vactive_mask;
u32 interlace_select;
u32 pi_enable;
+   u32 div_vga_shift;
+   u32 div_pic_shift;
+   u32 div_tvenc_shift;
+   u32 div_hdmi_pnx_shift;
+   u32 div_hdmi_shift;
+   u32 div_inf_shift;
+   u32 div_layer_shift;
 };
 
 static const struct zx_crtc_bits main_crtc_bits = {
@@ -83,6 +90,13 @@ struct zx_crtc_bits {
.sec_vactive_mask = SEC_VACT_MAIN_MASK,
.interlace_select = MAIN_INTERLACE_SEL,
.pi_enable = MAIN_PI_EN,
+   .div_vga_shift = VGA_MAIN_DIV_SHIFT,
+   .div_pic_shift = PIC_MAIN_DIV_SHIFT,
+   .div_tvenc_shift = TVENC_MAIN_DIV_SHIFT,
+   .div_hdmi_pnx_shift = HDMI_MAIN_PNX_DIV_SHIFT,
+   .div_hdmi_shift = HDMI_MAIN_DIV_SHIFT,
+   .div_inf_shift = INF_MAIN_DIV_SHIFT,
+   .div_layer_shift = LAYER_MAIN_DIV_SHIFT,
 };
 
 static const struct zx_crtc_bits aux_crtc_bits = {
@@ -94,6 +108,13 @@ struct zx_crtc_bits {
.sec_vactive_mask = SEC_VACT_AUX_MASK,
.interlace_select = AUX_INTERLACE_SEL,
.pi_enable = AUX_PI_EN,
+   .div_vga_shift = VGA_AUX_DIV_SHIFT,
+   .div_pic_shift = PIC_AUX_DIV_SHIFT,
+   .div_tvenc_shift = TVENC_AUX_DIV_SHIFT,
+   .div_hdmi_pnx_shift = HDMI_AUX_PNX_DIV_SHIFT,
+   .div_hdmi_shift = HDMI_AUX_DIV_SHIFT,
+   .div_inf_shift = INF_AUX_DIV_SHIFT,
+   .div_layer_shift = LAYER_AUX_DIV_SHIFT,
 };
 
 struct zx_crtc {
@@ -220,6 +241,64 @@ void vou_inf_disable(enum vou_inf_id id, struct drm_crtc 
*crtc)
zx_writel_mask(vou->vouctl + VOU_CLK_EN, inf->clocks_en_bits, 0);
 }
 
+void zx_vou_config_dividers(struct drm_crtc *crtc,
+   struct vou_div_config *configs, int num)
+{
+   struct zx_crtc *zcrtc = to_zx_crtc(crtc);
+   struct zx_vou_hw *vou = zcrtc->vou;
+   const struct zx_crtc_bits *bits = zcrtc->bits;
+   int i;
+
+   /* Clear update flag bit */
+   zx_writel_mask(vou->vouctl + VOU_DIV_PARA, DIV_PARA_UPDATE, 0);
+
+   for (i = 0; i < num; i++) {
+   struct vou_div_config *cfg = configs + i;
+   u32 reg, shift;
+
+   switch (cfg->id) {
+   case VOU_DIV_VGA:
+   reg = VOU_CLK_SEL;
+   shift = bits->div_vga_shift;
+   break;
+   case VOU_DIV_PIC:
+   reg = VOU_CLK_SEL;
+   shift = bits->div_pic_shift;
+   break;
+   case VOU_DIV_TVENC:
+   reg = VOU_DIV_PARA;
+   shift = bits->div_tvenc_shift;
+   break;
+   case VOU_DIV_HDMI_PNX:
+   reg = VOU_DIV_PARA;
+   shift = bits->div_hdmi_pnx_shift;
+   break;
+   case VOU_DIV_HDMI:
+   reg = VOU_DIV_PARA;
+   shift = bits->div_hdmi_shift;
+   break;
+   case VOU_DIV_INF:
+   reg = VOU_DIV_PARA;
+   shift = bits->div_inf_shift;
+   break;
+   case VOU_DIV_LAYER:
+   reg = VOU_DIV_PARA;
+   shift = bits->div_layer_shift;
+   break;
+   default:
+   continue;
+   }
+
+   /* Each divider occupies 3 bits */
+   zx_writel_mask(vou->vouctl + reg, 0x7 << shift,
+  cfg->val << shift);
+   }
+
+   /* Set update flag bit to get dividers effected */
+   zx_writel_mask(vou->vouctl + VOU_DIV_PARA, DIV_PARA_UPDATE,
+  DIV_PARA_UPDATE);
+}
+
 static inline void vou_chn_set_update(struct zx_crtc *zcrtc)
 {
zx_writel(zcrtc->chnreg + CHN_UPDATE, 1);
diff --git a/drivers/gpu/drm/zte/zx_vou.h b/drivers/gpu/drm/zte/zx_vou.h
index a41a0ad49857..0dae4faefac4 100644
--- a/drivers/gpu/drm/zte/zx_vou.h
+++ b/drivers/gpu/drm/zte/zx_vou.h
@@ -33,6 +33,31 @@ enum vou_inf_data_sel {
 void vou_inf_enable(enum vou_inf_id id, struct drm_crtc *crtc);
 void vo

[PATCH v2 4/5] dt: add bindings for ZTE tvenc device

2017-01-26 Thread Shawn Guo
From: Shawn Guo 

It adds bindings doc for ZTE VOU TV Encoder device.

Signed-off-by: Shawn Guo 
Acked-by: Rob Herring 
---
 Documentation/devicetree/bindings/display/zte,vou.txt | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/zte,vou.txt 
b/Documentation/devicetree/bindings/display/zte,vou.txt
index 740e5bd2e4f7..9c356284232b 100644
--- a/Documentation/devicetree/bindings/display/zte,vou.txt
+++ b/Documentation/devicetree/bindings/display/zte,vou.txt
@@ -49,6 +49,15 @@ Required properties:
"osc_clk"
"xclk"
 
+* TV Encoder output device
+
+Required properties:
+ - compatible: should be "zte,zx296718-tvenc"
+ - reg: Physical base address and length of the TVENC device IO region
+ - zte,tvenc-power-control: the phandle to SYSCTRL block followed by two
+   integer cells.  The first cell is the offset of SYSCTRL register used
+   to control TV Encoder DAC power, and the second cell is the bit mask.
+
 Example:
 
 vou: vou@144 {
@@ -81,4 +90,10 @@ vou: vou@144 {
 <&topcrm HDMI_XCLK>;
clock-names = "osc_cec", "osc_clk", "xclk";
};
+
+   tvenc: tvenc@2000 {
+   compatible = "zte,zx296718-tvenc";
+   reg = <0x2000 0x1000>;
+   zte,tvenc-power-control = <&sysctrl 0x170 0x10>;
+   };
 };
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 5/5] drm: zte: add tvenc driver support

2017-01-26 Thread Shawn Guo
From: Shawn Guo 

It adds the TV Encoder driver to support video output in PAL and NTSC
format.  The driver uses syscon/regmap interface to configure register
bit sitting in SYSCTRL module for DAC power control.

Signed-off-by: Shawn Guo 
---
Changes for v2:
 - Embed struct drm_display_mode in zx_tvenc_mode to save function
   zx_tvenc_mode_to_drm_mode().
 - Use drm_mode_equal() to find the matching mode.
 - Use drm_mode_set_name() to name mode.
 - Fix typos in clock multiplier comment.
 - Add a sanity check in .mode_valid hook to ensure the given mode is
   valid.
 - Remove destroy() calls from .unbind hook, as those are already taken
   care of by drm_mode_config_cleanup().

 drivers/gpu/drm/zte/Makefile|   1 +
 drivers/gpu/drm/zte/zx_drm_drv.c|   1 +
 drivers/gpu/drm/zte/zx_drm_drv.h|   1 +
 drivers/gpu/drm/zte/zx_tvenc.c  | 407 
 drivers/gpu/drm/zte/zx_tvenc_regs.h |  31 +++
 drivers/gpu/drm/zte/zx_vou.c|   5 +
 6 files changed, 446 insertions(+)
 create mode 100644 drivers/gpu/drm/zte/zx_tvenc.c
 create mode 100644 drivers/gpu/drm/zte/zx_tvenc_regs.h

diff --git a/drivers/gpu/drm/zte/Makefile b/drivers/gpu/drm/zte/Makefile
index 699180bfd57c..01352b56c418 100644
--- a/drivers/gpu/drm/zte/Makefile
+++ b/drivers/gpu/drm/zte/Makefile
@@ -2,6 +2,7 @@ zxdrm-y := \
zx_drm_drv.o \
zx_hdmi.o \
zx_plane.o \
+   zx_tvenc.o \
zx_vou.o
 
 obj-$(CONFIG_DRM_ZTE) += zxdrm.o
diff --git a/drivers/gpu/drm/zte/zx_drm_drv.c b/drivers/gpu/drm/zte/zx_drm_drv.c
index 3e76f72c92ff..13081fed902d 100644
--- a/drivers/gpu/drm/zte/zx_drm_drv.c
+++ b/drivers/gpu/drm/zte/zx_drm_drv.c
@@ -247,6 +247,7 @@ static int zx_drm_remove(struct platform_device *pdev)
 static struct platform_driver *drivers[] = {
&zx_crtc_driver,
&zx_hdmi_driver,
+   &zx_tvenc_driver,
&zx_drm_platform_driver,
 };
 
diff --git a/drivers/gpu/drm/zte/zx_drm_drv.h b/drivers/gpu/drm/zte/zx_drm_drv.h
index e65cd18a6cba..5ca035b079c7 100644
--- a/drivers/gpu/drm/zte/zx_drm_drv.h
+++ b/drivers/gpu/drm/zte/zx_drm_drv.h
@@ -13,6 +13,7 @@
 
 extern struct platform_driver zx_crtc_driver;
 extern struct platform_driver zx_hdmi_driver;
+extern struct platform_driver zx_tvenc_driver;
 
 static inline u32 zx_readl(void __iomem *reg)
 {
diff --git a/drivers/gpu/drm/zte/zx_tvenc.c b/drivers/gpu/drm/zte/zx_tvenc.c
new file mode 100644
index ..b56dc69843fc
--- /dev/null
+++ b/drivers/gpu/drm/zte/zx_tvenc.c
@@ -0,0 +1,407 @@
+/*
+ * Copyright 2017 Linaro Ltd.
+ * Copyright 2017 ZTE Corporation.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "zx_drm_drv.h"
+#include "zx_tvenc_regs.h"
+#include "zx_vou.h"
+
+struct zx_tvenc_pwrctrl {
+   struct regmap *regmap;
+   u32 reg;
+   u32 mask;
+};
+
+struct zx_tvenc {
+   struct drm_connector connector;
+   struct drm_encoder encoder;
+   struct device *dev;
+   void __iomem *mmio;
+   const struct vou_inf *inf;
+   struct zx_tvenc_pwrctrl pwrctrl;
+};
+
+#define to_zx_tvenc(x) container_of(x, struct zx_tvenc, x)
+
+struct zx_tvenc_mode {
+   struct drm_display_mode mode;
+   u32 video_info;
+   u32 video_res;
+   u32 field1_param;
+   u32 field2_param;
+   u32 burst_line_odd1;
+   u32 burst_line_even1;
+   u32 burst_line_odd2;
+   u32 burst_line_even2;
+   u32 line_timing_param;
+   u32 weight_value;
+   u32 blank_black_level;
+   u32 burst_level;
+   u32 control_param;
+   u32 sub_carrier_phase1;
+   u32 phase_line_incr_cvbs;
+};
+
+/*
+ * The CRM cannot directly provide a suitable frequency, and we have to
+ * ask a multiplied rate from CRM and use the divider in VOU to get the
+ * desired one.
+ */
+#define TVENC_CLOCK_MULTIPLIER 4
+
+static const struct zx_tvenc_mode tvenc_mode_pal = {
+   .mode = {
+   .clock = 13500 * TVENC_CLOCK_MULTIPLIER,
+   .hdisplay = 720,
+   .hsync_start = 720 + 12,
+   .hsync_end = 720 + 12 + 2,
+   .htotal = 720 + 12 + 2 + 130,
+   .vdisplay = 576,
+   .vsync_start = 576 + 2,
+   .vsync_end = 576 + 2 + 2,
+   .vtotal = 576 + 2 + 2 + 20,
+   .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC |
+DRM_MODE_FLAG_INTERLACE,
+   },
+   .video_info = 0x00040040,
+   .video_res = 0x05a9c760,
+   .field1_param = 0x0004d416,
+   .field2_param = 0x0009b94f,
+   .burst_line_odd1 = 0x0004d406,
+   .burst_line_even1 = 0x0009b53e,
+   .burst_line_odd2 = 0x0004d805,
+   .burst_line_even2 = 0x000

[GIT PULL] ZTE DRM driver updates for 4.11

2017-01-28 Thread Shawn Guo
Hi Dave,

Please consider to pull the following ZTE DRM driver updates for 4.11.
Thanks.

Shawn

The following changes since commit a121103c922847ba5010819a3f250f1f7fc84ab8:

  Linux 4.10-rc3 (2017-01-08 14:18:17 -0800)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git 
tags/zxdrm-4.11

for you to fetch changes up to 098988cbe5849e3e125b0bc02a6545a1dc414ab1:

  drm: zte: add tvenc driver support (2017-01-28 11:51:23 +0800)


ZTE DRM driver updates for 4.11:
 - Add missing selection of VIDEOMODE_HELPERS in Kconfig, since ZTE DRM
   driver uses drm_display_mode_to_videomode().
 - Enable HDMI audio support through SPDIF interface based on generic
   hdmi-audio-codec driver.
 - Enable VOU VL (Video Layer) to support overlay plane with scaling
   function.
 - Refine zx_vou driver a bit and then add TV Encoder output device
   support.


Shawn Guo (10):
  drm: zte: select VIDEOMODE_HELPERS in Kconfig
  drm: zte: support hdmi audio through spdif
  drm: zte: make zx_plane accessible from zx_vou driver
  drm: zte: add .atomic_disable hook to disable graphic layer
  drm: zte: add overlay plane support
  drm: zte: add interlace mode support
  drm: zte: move struct vou_inf into zx_vou driver
  drm: zte: add function to configure vou_ctrl dividers
  dt: add bindings for ZTE tvenc device
  drm: zte: add tvenc driver support

 .../devicetree/bindings/display/zte,vou.txt|  15 +
 drivers/gpu/drm/zte/Kconfig|   2 +
 drivers/gpu/drm/zte/Makefile   |   1 +
 drivers/gpu/drm/zte/zx_drm_drv.c   |   1 +
 drivers/gpu/drm/zte/zx_drm_drv.h   |   1 +
 drivers/gpu/drm/zte/zx_hdmi.c  | 160 +++-
 drivers/gpu/drm/zte/zx_hdmi_regs.h |  14 +
 drivers/gpu/drm/zte/zx_plane.c | 328 +++--
 drivers/gpu/drm/zte/zx_plane.h |  12 +-
 drivers/gpu/drm/zte/zx_plane_regs.h|  51 +++
 drivers/gpu/drm/zte/zx_tvenc.c | 407 +
 drivers/gpu/drm/zte/zx_tvenc_regs.h|  31 ++
 drivers/gpu/drm/zte/zx_vou.c   | 356 +++---
 drivers/gpu/drm/zte/zx_vou.h   |  48 ++-
 drivers/gpu/drm/zte/zx_vou_regs.h  |  51 +++
 15 files changed, 1365 insertions(+), 113 deletions(-)
 create mode 100644 drivers/gpu/drm/zte/zx_tvenc.c
 create mode 100644 drivers/gpu/drm/zte/zx_tvenc_regs.h
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [GIT PULL] ZTE DRM driver updates for 4.11

2017-02-03 Thread Shawn Guo
On Wed, Feb 01, 2017 at 08:29:51AM +1000, Dave Airlie wrote:
> On 29 January 2017 at 15:41, Shawn Guo  wrote:
> > Hi Dave,
> >
> > Please consider to pull the following ZTE DRM driver updates for 4.11.
> > Thanks.
> 
> Sorry for delay, I've pulled this and fixed up the plane format mismatch,
> 
> please confirm it works with drm-next.

Confirmed.  Thanks, Dave.

Shawn
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RFC PATCH v2 0/5] Add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
On Tue, Feb 07, 2017 at 08:32:46AM +0100, Daniel Vetter wrote:
> On Tue, Jan 24, 2017 at 08:55:35AM +0100, Daniel Vetter wrote:
> > On Sun, Jan 22, 2017 at 02:09:01PM +0800, Shawn Guo wrote:
> > > From: Shawn Guo 
> > > 
> > > The vblank is mostly CRTC specific and implemented as part of CRTC
> > > driver.  The first patch adds 3 vblank core-driver hooks into struct
> > > drm_crtc_funcs, and wraps around core vblank handling code to use the
> > > new hooks for modern MODESET drivers and the ones in struct drm_driver
> > > as fallback for legacy drivers.
> > > 
> > > The other patches in the series are to demonstrate how the new hooks
> > > are going to influence the driver code.  There are more drivers than
> > > the ones included here can be converted.  But before doing that, I would
> > > like to get some feedbacks first, expecially on how .get_vblank_counter
> > > should be converted when it's being drm_vblank_no_hw_counter().
> > > 
> > >   .get_vblank_counter = drm_vblank_no_hw_counter
> > 
> > I dropped some suggestions about this onto patch 3. Thanks for doing this,
> > I think it looks rather pretty.
> 
> Just to check: Do you plan to resend this series with my comments on the
> first patch addressed? I really like this, so I guess you could drop the
> RFC part and then we give maintainers a week or two for reviews and land
> it into drm-misc for 4.12 ...

Sorry for being late due to Chinese New Year Holidays.  The new version
is on the way, and will be on the list in a couple of hours.

Shawn
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 00/23] Add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank is mostly CRTC specific and implemented as part of CRTC
driver.  The first patch adds 3 vblank core<->driver hooks into struct
drm_crtc_funcs, and plug them into core by adding wrapper functions for
vblank handling code.  We effectively make the .get_vblank_counter hook
optional by providing drm_vblank_no_hw_counter() as the default fallback
in the wrapper function.

Patch #2 and #3 unexport function drm_vblank_no_hw_counter() by cleaning
up its use, since it's already the default implememention for
.get_vblank_counter hook anyway.

The rest of the series is trying to do a massive conversion to the new
hooks for DRIVER_MODESET drivers.  But it only handles low-hanging
fruit, and leaves out the ones that need a bit surgery, like gma500,
i915, msm etc.  Most of conversion get done by simply moving code and
making functions static, but imx and rockchip are great examples showing
how driver code can be cleaned up with these new hooks.

The series is generated against branch drm-next.

Changes for v3:
 - Let drm_vblank_no_hw_counter() be the last fallback for
   .get_vblank_counter() hook.
 - Improve the kernel-doc for .get_vblank_counter() hook.
 - Convert more DRIVER_MODESET drivers to new hooks.

Changes for v2:
 - Wrap around core vblank handling code to save
   drm_crtc_enable[disable]_vblank() helpers
 - Add .get_vblank_counter to struct drm_crtc_funcs
 - Add some comments to link between two sets of hooks
 - Add one hdlcd driver patch for example

Shawn Guo (23):
  drm: add vblank hooks to struct drm_crtc_funcs
  drm: remove drm_vblank_no_hw_counter assignment from driver code
  drm: unexport function drm_vblank_no_hw_counter()
  drm: hdlcd: use vblank hooks in struct drm_crtc_funcs
  drm: malidp: use vblank hooks in struct drm_crtc_funcs
  drm: armada: use vblank hooks in struct drm_crtc_funcs
  drm: atmel: use vblank hooks in struct drm_crtc_funcs
  drm: exynos: use vblank hooks in struct drm_crtc_funcs
  drm: fsl-dcu: use vblank hooks in struct drm_crtc_funcs
  drm: hibmc: use vblank hooks in struct drm_crtc_funcs
  drm: kirin: use vblank hooks in struct drm_crtc_funcs
  drm: imx: remove struct imx_drm_crtc and imx_drm_crtc_helper_funcs
  drm: mediatek: use vblank hooks in struct drm_crtc_funcs
  drm: meson: use vblank hooks in struct drm_crtc_funcs
  drm: qxl: use vblank hooks in struct drm_crtc_funcs
  drm: rcar-du: use vblank hooks in struct drm_crtc_funcs
  drm: rockchip: remove struct rockchip_crtc_funcs
  drm: shmobile: use vblank hooks in struct drm_crtc_funcs
  drm: sun4i: use vblank hooks in struct drm_crtc_funcs
  drm: tegra: use vblank hooks in struct drm_crtc_funcs
  drm: tilcdc: use vblank hooks in struct drm_crtc_funcs
  drm: vc4: use vblank hooks in struct drm_crtc_funcs
  drm: zte: use vblank hooks in struct drm_crtc_funcs

 drivers/gpu/drm/arc/arcpgu_drv.c|   1 -
 drivers/gpu/drm/arm/hdlcd_crtc.c|  20 +
 drivers/gpu/drm/arm/hdlcd_drv.c |  21 -
 drivers/gpu/drm/arm/malidp_crtc.c   |  21 +
 drivers/gpu/drm/arm/malidp_drv.c|  22 -
 drivers/gpu/drm/armada/armada_crtc.c|  56 -
 drivers/gpu/drm/armada/armada_crtc.h|   2 -
 drivers/gpu/drm/armada/armada_drv.c |  17 
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c  |  21 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c|  22 -
 drivers/gpu/drm/drm_irq.c   |  81 +--
 drivers/gpu/drm/exynos/exynos_drm_crtc.c|  40 +-
 drivers/gpu/drm/exynos/exynos_drm_crtc.h|   2 -
 drivers/gpu/drm/exynos/exynos_drm_drv.c |   4 -
 drivers/gpu/drm/exynos/exynos_drm_drv.h |   8 --
 drivers/gpu/drm/exynos/exynos_hdmi.c|   7 +-
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c  |  26 ++
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c   |  26 --
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c  |  20 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c |  23 --
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c |  11 +--
 drivers/gpu/drm/i915/i915_irq.c |   1 -
 drivers/gpu/drm/imx/imx-drm-core.c  | 102 
 drivers/gpu/drm/imx/imx-drm.h   |  13 ---
 drivers/gpu/drm/imx/ipuv3-crtc.c|  58 +-
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c |   8 +-
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h |   2 -
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  |   4 -
 drivers/gpu/drm/meson/meson_crtc.c  |  22 +
 drivers/gpu/drm/meson/meson_drv.c   |  21 -
 drivers/gpu/drm/msm/msm_drv.c   |   1 -
 drivers/gpu/drm/mxsfb/mxsfb_drv.c   |   1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   |   1 -
 drivers/gpu/drm/omapdrm/omap_drv.c  |   1 -
 drivers/gpu/drm/qxl/qxl_display.c   |  16 
 drivers/gpu/drm/qx

[PATCH v3 03/23] drm: unexport function drm_vblank_no_hw_counter()

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The function drm_vblank_no_hw_counter() is now only used in core vblank
wrapper code.  Let's unexport it by making it a static function.

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/drm_irq.c | 28 ++--
 include/drm/drm_drv.h |  7 +++
 include/drm/drm_irq.h |  1 -
 3 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 646b3e57b9ad..1906723af389 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -89,6 +89,16 @@ static void store_vblank(struct drm_device *dev, unsigned 
int pipe,
write_sequnlock(&vblank->seqlock);
 }
 
+/*
+ * "No hw counter" fallback implementation of .get_vblank_counter() hook,
+ * if there is no useable hardware frame counter available.
+ */
+static u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe)
+{
+   WARN_ON_ONCE(dev->max_vblank_count != 0);
+   return 0;
+}
+
 static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
 {
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
@@ -1748,21 +1758,3 @@ bool drm_crtc_handle_vblank(struct drm_crtc *crtc)
return drm_handle_vblank(crtc->dev, drm_crtc_index(crtc));
 }
 EXPORT_SYMBOL(drm_crtc_handle_vblank);
-
-/**
- * drm_vblank_no_hw_counter - "No hw counter" implementation of 
.get_vblank_counter()
- * @dev: DRM device
- * @pipe: CRTC for which to read the counter
- *
- * Drivers can plug this into the .get_vblank_counter() function if
- * there is no useable hardware frame counter available.
- *
- * Returns:
- * 0
- */
-u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe)
-{
-   WARN_ON_ONCE(dev->max_vblank_count != 0);
-   return 0;
-}
-EXPORT_SYMBOL(drm_vblank_no_hw_counter);
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 40ae89106594..661ca24a4c97 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -120,10 +120,9 @@ struct drm_driver {
 *
 * Driver callback for fetching a raw hardware vblank counter for the
 * CRTC specified with the pipe argument.  If a device doesn't have a
-* hardware counter, the driver can simply use
-* drm_vblank_no_hw_counter() function. The DRM core will account for
-* missed vblank events while interrupts where disabled based on system
-* timestamps.
+* hardware counter, the driver can simply leave the hook as NULL.
+* The DRM core will account for missed vblank events while interrupts
+* where disabled based on system timestamps.
 *
 * Wraparound handling and loss of events due to modesetting is dealt
 * with in the DRM core code, as long as drivers call
diff --git a/include/drm/drm_irq.h b/include/drm/drm_irq.h
index 2fb880462a57..cf0be6594c8c 100644
--- a/include/drm/drm_irq.h
+++ b/include/drm/drm_irq.h
@@ -152,7 +152,6 @@ void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
 void drm_crtc_vblank_on(struct drm_crtc *crtc);
 void drm_vblank_cleanup(struct drm_device *dev);
 u32 drm_accurate_vblank_count(struct drm_crtc *crtc);
-u32 drm_vblank_no_hw_counter(struct drm_device *dev, unsigned int pipe);
 
 int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev,
  unsigned int pipe, int *max_error,
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 02/23] drm: remove drm_vblank_no_hw_counter assignment from driver code

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

Core code already makes drm_driver.get_vblank_counter hook optional by
letting drm_vblank_no_hw_counter be the default implementation for the
function hook.  So the drm_vblank_no_hw_counter assignment in the driver
code becomes redundant and can be removed now.

Signed-off-by: Shawn Guo 
Cc: Alexey Brodkin 
Cc: Liviu Dudau 
Cc: Mali DP Maintainers 
Cc: Russell King 
Cc: Boris Brezillon 
Cc: Inki Dae 
Cc: Stefan Agner 
Cc: Xinliang Liu 
Cc: Daniel Vetter 
Cc: Philipp Zabel 
Cc: CK Hu 
Cc: Neil Armstrong 
Cc: Rob Clark 
Cc: Marek Vasut 
Cc: Ben Skeggs 
Cc: Tomi Valkeinen 
Cc: Laurent Pinchart 
Cc: Mark Yao 
Cc: Benjamin Gaignard 
Cc: Maxime Ripard 
Cc: Jyri Sarha 
Cc: Eric Anholt 
---
 drivers/gpu/drm/arc/arcpgu_drv.c| 1 -
 drivers/gpu/drm/arm/hdlcd_drv.c | 1 -
 drivers/gpu/drm/arm/malidp_drv.c| 1 -
 drivers/gpu/drm/armada/armada_drv.c | 1 -
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c| 1 -
 drivers/gpu/drm/exynos/exynos_drm_drv.c | 1 -
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c   | 1 -
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 1 -
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 1 -
 drivers/gpu/drm/i915/i915_irq.c | 1 -
 drivers/gpu/drm/imx/imx-drm-core.c  | 1 -
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 1 -
 drivers/gpu/drm/meson/meson_drv.c   | 1 -
 drivers/gpu/drm/msm/msm_drv.c   | 1 -
 drivers/gpu/drm/mxsfb/mxsfb_drv.c   | 1 -
 drivers/gpu/drm/nouveau/nouveau_drm.c   | 1 -
 drivers/gpu/drm/omapdrm/omap_drv.c  | 1 -
 drivers/gpu/drm/rcar-du/rcar_du_drv.c   | 1 -
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 1 -
 drivers/gpu/drm/shmobile/shmob_drm_drv.c| 1 -
 drivers/gpu/drm/sti/sti_drv.c   | 1 -
 drivers/gpu/drm/sun4i/sun4i_drv.c   | 1 -
 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 1 -
 drivers/gpu/drm/vc4/vc4_drv.c   | 1 -
 drivers/gpu/drm/zte/zx_drm_drv.c| 1 -
 25 files changed, 25 deletions(-)

diff --git a/drivers/gpu/drm/arc/arcpgu_drv.c b/drivers/gpu/drm/arc/arcpgu_drv.c
index 8d8344ed655e..1926b200e4cb 100644
--- a/drivers/gpu/drm/arc/arcpgu_drv.c
+++ b/drivers/gpu/drm/arc/arcpgu_drv.c
@@ -175,7 +175,6 @@ static int arcpgu_unload(struct drm_device *drm)
.dumb_create = drm_gem_cma_dumb_create,
.dumb_map_offset = drm_gem_cma_dumb_map_offset,
.dumb_destroy = drm_gem_dumb_destroy,
-   .get_vblank_counter = drm_vblank_no_hw_counter,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_free_object_unlocked = drm_gem_cma_free_object,
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 4ce4f970920b..5d79e87f7421 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -278,7 +278,6 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
.irq_preinstall = hdlcd_irq_preinstall,
.irq_postinstall = hdlcd_irq_postinstall,
.irq_uninstall = hdlcd_irq_uninstall,
-   .get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank = hdlcd_enable_vblank,
.disable_vblank = hdlcd_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index 8b0672d4aee9..ca6ccd172de3 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -213,7 +213,6 @@ static void malidp_lastclose(struct drm_device *drm)
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
   DRIVER_PRIME,
.lastclose = malidp_lastclose,
-   .get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank = malidp_enable_vblank,
.disable_vblank = malidp_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index 63f42d001f33..bb27892012de 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -87,7 +87,6 @@ static void armada_drm_lastclose(struct drm_device *dev)
 
 static struct drm_driver armada_drm_driver = {
.lastclose  = armada_drm_lastclose,
-   .get_vblank_counter = drm_vblank_no_hw_counter,
.enable_vblank  = armada_drm_enable_vblank,
.disable_vblank = armada_drm_disable_vblank,
.gem_free_object_unlocked = armada_gem_free_object,
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 427bdff425c2..5cba65b5ea16 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -760,7 +760,6 @@ static void atmel_hlcdc_dc_disable_vblank(struct drm_device

[PATCH v3 01/23] drm: add vblank hooks to struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank is mostly CRTC specific and implemented as part of CRTC
driver.  Let's keep the vblank hooks struct drm_driver for legacy
drivers, and add corresponding hooks in struct drm_crtc_funcs.  These
hooks take struct drm_crtc pointer as argument, and will be called by
core vblank handling code for DRIVER_MODESET drivers.

The new hooks get plugged into core by adding wrapper functions for
vblank handling code.  The .get_vblank_counter hook is effectively
optional, as we provide drm_vblank_no_hw_counter() as the default
fallback in the wrapper function.

Signed-off-by: Shawn Guo 
---
 drivers/gpu/drm/drm_irq.c | 53 +--
 include/drm/drm_crtc.h| 44 +++
 include/drm/drm_drv.h |  9 
 3 files changed, 100 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index e06cf11ebb4a..646b3e57b9ad 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -89,6 +89,21 @@ static void store_vblank(struct drm_device *dev, unsigned 
int pipe,
write_sequnlock(&vblank->seqlock);
 }
 
+static u32 __get_vblank_counter(struct drm_device *dev, unsigned int pipe)
+{
+   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+
+   if (crtc->funcs->get_vblank_counter)
+   return crtc->funcs->get_vblank_counter(crtc);
+   }
+
+   if (dev->driver->get_vblank_counter)
+   return dev->driver->get_vblank_counter(dev, pipe);
+
+   return drm_vblank_no_hw_counter(dev, pipe);
+}
+
 /*
  * Reset the stored timestamp for the current vblank count to correspond
  * to the last vblank occurred.
@@ -112,9 +127,9 @@ static void drm_reset_vblank_timestamp(struct drm_device 
*dev, unsigned int pipe
 * when drm_vblank_enable() applies the diff
 */
do {
-   cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
+   cur_vblank = __get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, 0);
-   } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && 
--count > 0);
+   } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
 
/*
 * Only reinitialize corresponding vblank timestamp if high-precision 
query
@@ -168,9 +183,9 @@ static void drm_update_vblank_count(struct drm_device *dev, 
unsigned int pipe,
 * corresponding vblank timestamp.
 */
do {
-   cur_vblank = dev->driver->get_vblank_counter(dev, pipe);
+   cur_vblank = __get_vblank_counter(dev, pipe);
rc = drm_get_last_vbltimestamp(dev, pipe, &t_vblank, flags);
-   } while (cur_vblank != dev->driver->get_vblank_counter(dev, pipe) && 
--count > 0);
+   } while (cur_vblank != __get_vblank_counter(dev, pipe) && --count > 0);
 
if (dev->max_vblank_count != 0) {
/* trust the hw counter when it's around */
@@ -275,6 +290,20 @@ u32 drm_accurate_vblank_count(struct drm_crtc *crtc)
 }
 EXPORT_SYMBOL(drm_accurate_vblank_count);
 
+static void __disable_vblank(struct drm_device *dev, unsigned int pipe)
+{
+   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+
+   if (crtc->funcs->disable_vblank) {
+   crtc->funcs->disable_vblank(crtc);
+   return;
+   }
+   }
+
+   dev->driver->disable_vblank(dev, pipe);
+}
+
 /*
  * Disable vblank irq's on crtc, make sure that last vblank count
  * of hardware and corresponding consistent software vblank counter
@@ -298,7 +327,7 @@ static void vblank_disable_and_save(struct drm_device *dev, 
unsigned int pipe)
 * hardware potentially runtime suspended.
 */
if (vblank->enabled) {
-   dev->driver->disable_vblank(dev, pipe);
+   __disable_vblank(dev, pipe);
vblank->enabled = false;
}
 
@@ -1027,6 +1056,18 @@ void drm_crtc_send_vblank_event(struct drm_crtc *crtc,
 }
 EXPORT_SYMBOL(drm_crtc_send_vblank_event);
 
+static int __enable_vblank(struct drm_device *dev, unsigned int pipe)
+{
+   if (drm_core_check_feature(dev, DRIVER_MODESET)) {
+   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
+
+   if (crtc->funcs->enable_vblank)
+   return crtc->funcs->enable_vblank(crtc);
+   }
+
+   return dev->driver->enable_vblank(dev, pipe);
+}
+
 /**
  * drm_vblank_enable - enable the vblank interrupt on a CRTC
  * @dev: DRM device
@@ -1052,7 +1093,7 @@ static int drm_vblank_enable(struct dr

[PATCH v3 04/23] drm: hdlcd: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Acked-by: Liviu Dudau 
---
 drivers/gpu/drm/arm/hdlcd_crtc.c | 20 
 drivers/gpu/drm/arm/hdlcd_drv.c  | 20 
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c
index 20ebfb4fbdfa..798a3cc480a2 100644
--- a/drivers/gpu/drm/arm/hdlcd_crtc.c
+++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
@@ -42,6 +42,24 @@ static void hdlcd_crtc_cleanup(struct drm_crtc *crtc)
drm_crtc_cleanup(crtc);
 }
 
+static int hdlcd_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
+   unsigned int mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK);
+
+   hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, mask | HDLCD_INTERRUPT_VSYNC);
+
+   return 0;
+}
+
+static void hdlcd_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc);
+   unsigned int mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK);
+
+   hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, mask & ~HDLCD_INTERRUPT_VSYNC);
+}
+
 static const struct drm_crtc_funcs hdlcd_crtc_funcs = {
.destroy = hdlcd_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
@@ -49,6 +67,8 @@ static void hdlcd_crtc_cleanup(struct drm_crtc *crtc)
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = hdlcd_crtc_enable_vblank,
+   .disable_vblank = hdlcd_crtc_disable_vblank,
 };
 
 static struct simplefb_format supported_formats[] = SIMPLEFB_FORMATS;
diff --git a/drivers/gpu/drm/arm/hdlcd_drv.c b/drivers/gpu/drm/arm/hdlcd_drv.c
index 5d79e87f7421..4840dc277339 100644
--- a/drivers/gpu/drm/arm/hdlcd_drv.c
+++ b/drivers/gpu/drm/arm/hdlcd_drv.c
@@ -199,24 +199,6 @@ static void hdlcd_irq_uninstall(struct drm_device *drm)
hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, irq_mask);
 }
 
-static int hdlcd_enable_vblank(struct drm_device *drm, unsigned int crtc)
-{
-   struct hdlcd_drm_private *hdlcd = drm->dev_private;
-   unsigned int mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK);
-
-   hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, mask | HDLCD_INTERRUPT_VSYNC);
-
-   return 0;
-}
-
-static void hdlcd_disable_vblank(struct drm_device *drm, unsigned int crtc)
-{
-   struct hdlcd_drm_private *hdlcd = drm->dev_private;
-   unsigned int mask = hdlcd_read(hdlcd, HDLCD_REG_INT_MASK);
-
-   hdlcd_write(hdlcd, HDLCD_REG_INT_MASK, mask & ~HDLCD_INTERRUPT_VSYNC);
-}
-
 #ifdef CONFIG_DEBUG_FS
 static int hdlcd_show_underrun_count(struct seq_file *m, void *arg)
 {
@@ -278,8 +260,6 @@ static int hdlcd_debugfs_init(struct drm_minor *minor)
.irq_preinstall = hdlcd_irq_preinstall,
.irq_postinstall = hdlcd_irq_postinstall,
.irq_uninstall = hdlcd_irq_uninstall,
-   .enable_vblank = hdlcd_enable_vblank,
-   .disable_vblank = hdlcd_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = drm_gem_cma_dumb_create,
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 07/23] drm: atmel: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Boris Brezillon 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 21 +
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c   | 21 -
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 9b17a66cf0e1..fabeeea0e899 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -434,6 +434,25 @@ static void atmel_hlcdc_crtc_destroy_state(struct drm_crtc 
*crtc,
kfree(state);
 }
 
+static int atmel_hlcdc_crtc_enable_vblank(struct drm_crtc *c)
+{
+   struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
+   struct regmap *regmap = crtc->dc->hlcdc->regmap;
+
+   /* Enable SOF (Start Of Frame) interrupt for vblank counting */
+   regmap_write(regmap, ATMEL_HLCDC_IER, ATMEL_HLCDC_SOF);
+
+   return 0;
+}
+
+static void atmel_hlcdc_crtc_disable_vblank(struct drm_crtc *c)
+{
+   struct atmel_hlcdc_crtc *crtc = drm_crtc_to_atmel_hlcdc_crtc(c);
+   struct regmap *regmap = crtc->dc->hlcdc->regmap;
+
+   regmap_write(regmap, ATMEL_HLCDC_IDR, ATMEL_HLCDC_SOF);
+}
+
 static const struct drm_crtc_funcs atmel_hlcdc_crtc_funcs = {
.page_flip = drm_atomic_helper_page_flip,
.set_config = drm_atomic_helper_set_config,
@@ -441,6 +460,8 @@ static void atmel_hlcdc_crtc_destroy_state(struct drm_crtc 
*crtc,
.reset = atmel_hlcdc_crtc_reset,
.atomic_duplicate_state =  atmel_hlcdc_crtc_duplicate_state,
.atomic_destroy_state = atmel_hlcdc_crtc_destroy_state,
+   .enable_vblank = atmel_hlcdc_crtc_enable_vblank,
+   .disable_vblank = atmel_hlcdc_crtc_disable_vblank,
 };
 
 int atmel_hlcdc_crtc_create(struct drm_device *dev)
diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
index 5cba65b5ea16..fd1a2d0c870d 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_dc.c
@@ -720,25 +720,6 @@ static void atmel_hlcdc_dc_irq_uninstall(struct drm_device 
*dev)
regmap_read(dc->hlcdc->regmap, ATMEL_HLCDC_ISR, &isr);
 }
 
-static int atmel_hlcdc_dc_enable_vblank(struct drm_device *dev,
-   unsigned int pipe)
-{
-   struct atmel_hlcdc_dc *dc = dev->dev_private;
-
-   /* Enable SOF (Start Of Frame) interrupt for vblank counting */
-   regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IER, ATMEL_HLCDC_SOF);
-
-   return 0;
-}
-
-static void atmel_hlcdc_dc_disable_vblank(struct drm_device *dev,
- unsigned int pipe)
-{
-   struct atmel_hlcdc_dc *dc = dev->dev_private;
-
-   regmap_write(dc->hlcdc->regmap, ATMEL_HLCDC_IDR, ATMEL_HLCDC_SOF);
-}
-
 static const struct file_operations fops = {
.owner  = THIS_MODULE,
.open   = drm_open,
@@ -760,8 +741,6 @@ static void atmel_hlcdc_dc_disable_vblank(struct drm_device 
*dev,
.irq_preinstall = atmel_hlcdc_dc_irq_uninstall,
.irq_postinstall = atmel_hlcdc_dc_irq_postinstall,
.irq_uninstall = atmel_hlcdc_dc_irq_uninstall,
-   .enable_vblank = atmel_hlcdc_dc_enable_vblank,
-   .disable_vblank = atmel_hlcdc_dc_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 09/23] drm: fsl-dcu: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Stefan Agner 
---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c | 26 ++
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c  | 25 -
 2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
index deb57435cc89..cc4e944a1d3c 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_crtc.c
@@ -137,6 +137,30 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
.mode_set_nofb = fsl_dcu_drm_crtc_mode_set_nofb,
 };
 
+static int fsl_dcu_drm_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+   unsigned int value;
+
+   regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
+   value &= ~DCU_INT_MASK_VBLANK;
+   regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
+
+   return 0;
+}
+
+static void fsl_dcu_drm_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct drm_device *dev = crtc->dev;
+   struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+   unsigned int value;
+
+   regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
+   value |= DCU_INT_MASK_VBLANK;
+   regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
+}
+
 static const struct drm_crtc_funcs fsl_dcu_drm_crtc_funcs = {
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
@@ -144,6 +168,8 @@ static void fsl_dcu_drm_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
.page_flip = drm_atomic_helper_page_flip,
.reset = drm_atomic_helper_crtc_reset,
.set_config = drm_atomic_helper_set_config,
+   .enable_vblank = fsl_dcu_drm_crtc_enable_vblank,
+   .disable_vblank = fsl_dcu_drm_crtc_disable_vblank,
 };
 
 int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index b59b816a1d7d..b5391c124c64 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -154,29 +154,6 @@ static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg)
return IRQ_HANDLED;
 }
 
-static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
-   unsigned int value;
-
-   regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
-   value &= ~DCU_INT_MASK_VBLANK;
-   regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
-
-   return 0;
-}
-
-static void fsl_dcu_drm_disable_vblank(struct drm_device *dev,
-  unsigned int pipe)
-{
-   struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
-   unsigned int value;
-
-   regmap_read(fsl_dev->regmap, DCU_INT_MASK, &value);
-   value |= DCU_INT_MASK_VBLANK;
-   regmap_write(fsl_dev->regmap, DCU_INT_MASK, value);
-}
-
 static void fsl_dcu_drm_lastclose(struct drm_device *dev)
 {
struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
@@ -203,8 +180,6 @@ static void fsl_dcu_drm_lastclose(struct drm_device *dev)
.load   = fsl_dcu_load,
.unload = fsl_dcu_unload,
.irq_handler= fsl_dcu_drm_irq,
-   .enable_vblank  = fsl_dcu_drm_enable_vblank,
-   .disable_vblank = fsl_dcu_drm_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 06/23] drm: armada: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.  As the result,
functions armada_drm_crtc_enable[disable]_irq() can be static, although
they are moved around a bit to save forward declaration.

The armada_crtc pointer array in struct armada_private is still kept in
there, because armada_debugfs.c still have reference to it.

Signed-off-by: Shawn Guo 
Cc: Russell King 
---
 drivers/gpu/drm/armada/armada_crtc.c | 56 
 drivers/gpu/drm/armada/armada_crtc.h |  2 --
 drivers/gpu/drm/armada/armada_drv.c  | 16 ---
 3 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_crtc.c 
b/drivers/gpu/drm/armada/armada_crtc.c
index e62ee4498ce4..1341e0b9368a 100644
--- a/drivers/gpu/drm/armada/armada_crtc.c
+++ b/drivers/gpu/drm/armada/armada_crtc.c
@@ -418,6 +418,25 @@ static bool armada_drm_crtc_mode_fixup(struct drm_crtc 
*crtc,
return true;
 }
 
+/* These are locked by dev->vbl_lock */
+static void armada_drm_crtc_disable_irq(struct armada_crtc *dcrtc, u32 mask)
+{
+   if (dcrtc->irq_ena & mask) {
+   dcrtc->irq_ena &= ~mask;
+   writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
+   }
+}
+
+static void armada_drm_crtc_enable_irq(struct armada_crtc *dcrtc, u32 mask)
+{
+   if ((dcrtc->irq_ena & mask) != mask) {
+   dcrtc->irq_ena |= mask;
+   writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
+   if (readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR) & mask)
+   writel(0, dcrtc->base + LCD_SPU_IRQ_ISR);
+   }
+}
+
 static void armada_drm_crtc_irq(struct armada_crtc *dcrtc, u32 stat)
 {
void __iomem *base = dcrtc->base;
@@ -491,25 +510,6 @@ static irqreturn_t armada_drm_irq(int irq, void *arg)
return IRQ_NONE;
 }
 
-/* These are locked by dev->vbl_lock */
-void armada_drm_crtc_disable_irq(struct armada_crtc *dcrtc, u32 mask)
-{
-   if (dcrtc->irq_ena & mask) {
-   dcrtc->irq_ena &= ~mask;
-   writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
-   }
-}
-
-void armada_drm_crtc_enable_irq(struct armada_crtc *dcrtc, u32 mask)
-{
-   if ((dcrtc->irq_ena & mask) != mask) {
-   dcrtc->irq_ena |= mask;
-   writel(dcrtc->irq_ena, dcrtc->base + LCD_SPU_IRQ_ENA);
-   if (readl_relaxed(dcrtc->base + LCD_SPU_IRQ_ISR) & mask)
-   writel(0, dcrtc->base + LCD_SPU_IRQ_ISR);
-   }
-}
-
 static uint32_t armada_drm_crtc_calculate_csc(struct armada_crtc *dcrtc)
 {
struct drm_display_mode *adj = &dcrtc->crtc.mode;
@@ -1109,6 +1109,22 @@ static int armada_drm_crtc_page_flip(struct drm_crtc 
*crtc,
return 0;
 }
 
+/* These are called under the vbl_lock. */
+static int armada_drm_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
+
+   armada_drm_crtc_enable_irq(dcrtc, VSYNC_IRQ_ENA);
+   return 0;
+}
+
+static void armada_drm_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
+
+   armada_drm_crtc_disable_irq(dcrtc, VSYNC_IRQ_ENA);
+}
+
 static const struct drm_crtc_funcs armada_crtc_funcs = {
.cursor_set = armada_drm_crtc_cursor_set,
.cursor_move= armada_drm_crtc_cursor_move,
@@ -1116,6 +1132,8 @@ static int armada_drm_crtc_page_flip(struct drm_crtc 
*crtc,
.set_config = drm_crtc_helper_set_config,
.page_flip  = armada_drm_crtc_page_flip,
.set_property   = armada_drm_crtc_set_property,
+   .enable_vblank  = armada_drm_crtc_enable_vblank,
+   .disable_vblank = armada_drm_crtc_disable_vblank,
 };
 
 static const struct drm_plane_funcs armada_primary_plane_funcs = {
diff --git a/drivers/gpu/drm/armada/armada_crtc.h 
b/drivers/gpu/drm/armada/armada_crtc.h
index b08043e8cc3b..7e8906d3ae26 100644
--- a/drivers/gpu/drm/armada/armada_crtc.h
+++ b/drivers/gpu/drm/armada/armada_crtc.h
@@ -104,8 +104,6 @@ struct armada_crtc {
 
 void armada_drm_crtc_gamma_set(struct drm_crtc *, u16, u16, u16, int);
 void armada_drm_crtc_gamma_get(struct drm_crtc *, u16 *, u16 *, u16 *, int);
-void armada_drm_crtc_disable_irq(struct armada_crtc *, u32);
-void armada_drm_crtc_enable_irq(struct armada_crtc *, u32);
 void armada_drm_crtc_update_regs(struct armada_crtc *, struct armada_regs *);
 
 void armada_drm_crtc_plane_disable(struct armada_crtc *dcrtc,
diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index bb27892012de..737bfcbce87b 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -49,20 +49,6 @@ void armada_drm_queue_un

[PATCH v3 08/23] drm: exynos: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

As the result, exynos_drm_crtc_enable[disable]_vblank() become static
functions.  They are moved around a bit to save forward declaration
though.  Also while at it, we move one step further to kill
exynos_drm_crtc_from_pipe() completely by updating hdmi_bind() a bit.

Signed-off-by: Shawn Guo 
Cc: Inki Dae 
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c | 40 
 drivers/gpu/drm/exynos/exynos_drm_crtc.h |  2 --
 drivers/gpu/drm/exynos/exynos_drm_drv.c  |  3 ---
 drivers/gpu/drm/exynos/exynos_drm_drv.h  |  8 ---
 drivers/gpu/drm/exynos/exynos_hdmi.c |  7 --
 5 files changed, 25 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index 5367b6664fe3..fa32091af924 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -122,6 +122,24 @@ static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
kfree(exynos_crtc);
 }
 
+static int exynos_drm_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+
+   if (exynos_crtc->ops->enable_vblank)
+   return exynos_crtc->ops->enable_vblank(exynos_crtc);
+
+   return 0;
+}
+
+static void exynos_drm_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
+
+   if (exynos_crtc->ops->disable_vblank)
+   exynos_crtc->ops->disable_vblank(exynos_crtc);
+}
+
 static const struct drm_crtc_funcs exynos_crtc_funcs = {
.set_config = drm_atomic_helper_set_config,
.page_flip  = drm_atomic_helper_page_flip,
@@ -129,6 +147,8 @@ static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = exynos_drm_crtc_enable_vblank,
+   .disable_vblank = exynos_drm_crtc_disable_vblank,
 };
 
 struct exynos_drm_crtc *exynos_drm_crtc_create(struct drm_device *drm_dev,
@@ -168,26 +188,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct 
drm_device *drm_dev,
return ERR_PTR(ret);
 }
 
-int exynos_drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct exynos_drm_crtc *exynos_crtc = exynos_drm_crtc_from_pipe(dev,
-   pipe);
-
-   if (exynos_crtc->ops->enable_vblank)
-   return exynos_crtc->ops->enable_vblank(exynos_crtc);
-
-   return 0;
-}
-
-void exynos_drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct exynos_drm_crtc *exynos_crtc = exynos_drm_crtc_from_pipe(dev,
-   pipe);
-
-   if (exynos_crtc->ops->disable_vblank)
-   exynos_crtc->ops->disable_vblank(exynos_crtc);
-}
-
 int exynos_drm_crtc_get_pipe_from_type(struct drm_device *drm_dev,
   enum exynos_drm_output_type out_type)
 {
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index 6a581a8af465..4e986ba92320 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -23,8 +23,6 @@ struct exynos_drm_crtc *exynos_drm_crtc_create(struct 
drm_device *drm_dev,
enum exynos_drm_output_type type,
const struct exynos_drm_crtc_ops *ops,
void *context);
-int exynos_drm_crtc_enable_vblank(struct drm_device *dev, unsigned int pipe);
-void exynos_drm_crtc_disable_vblank(struct drm_device *dev, unsigned int pipe);
 void exynos_drm_crtc_wait_pending_update(struct exynos_drm_crtc *exynos_crtc);
 void exynos_drm_crtc_finish_update(struct exynos_drm_crtc *exynos_crtc,
   struct exynos_drm_plane *exynos_plane);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index a1c22eb12f4b..b4522f67b3cb 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -22,7 +22,6 @@
 #include 
 
 #include "exynos_drm_drv.h"
-#include "exynos_drm_crtc.h"
 #include "exynos_drm_fbdev.h"
 #include "exynos_drm_fb.h"
 #include "exynos_drm_gem.h"
@@ -263,8 +262,6 @@ static void exynos_drm_lastclose(struct drm_device *dev)
.preclose   = exynos_drm_preclose,
.lastclose  = ex

[PATCH v3 05/23] drm: malidp: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Mali DP Maintainers 
---
 drivers/gpu/drm/arm/malidp_crtc.c | 21 +
 drivers/gpu/drm/arm/malidp_drv.c  | 21 -
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/arm/malidp_crtc.c 
b/drivers/gpu/drm/arm/malidp_crtc.c
index 08e6a71f5d05..bad4d80cb711 100644
--- a/drivers/gpu/drm/arm/malidp_crtc.c
+++ b/drivers/gpu/drm/arm/malidp_crtc.c
@@ -167,6 +167,25 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
.atomic_check = malidp_crtc_atomic_check,
 };
 
+static int malidp_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
+   struct malidp_hw_device *hwdev = malidp->dev;
+
+   malidp_hw_enable_irq(hwdev, MALIDP_DE_BLOCK,
+hwdev->map.de_irq_map.vsync_irq);
+   return 0;
+}
+
+static void malidp_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct malidp_drm *malidp = crtc_to_malidp_device(crtc);
+   struct malidp_hw_device *hwdev = malidp->dev;
+
+   malidp_hw_disable_irq(hwdev, MALIDP_DE_BLOCK,
+ hwdev->map.de_irq_map.vsync_irq);
+}
+
 static const struct drm_crtc_funcs malidp_crtc_funcs = {
.destroy = drm_crtc_cleanup,
.set_config = drm_atomic_helper_set_config,
@@ -174,6 +193,8 @@ static int malidp_crtc_atomic_check(struct drm_crtc *crtc,
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = malidp_crtc_enable_vblank,
+   .disable_vblank = malidp_crtc_disable_vblank,
 };
 
 int malidp_crtc_init(struct drm_device *drm)
diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c
index ca6ccd172de3..5dfcdb05c96e 100644
--- a/drivers/gpu/drm/arm/malidp_drv.c
+++ b/drivers/gpu/drm/arm/malidp_drv.c
@@ -111,25 +111,6 @@ static void malidp_atomic_commit_tail(struct 
drm_atomic_state *state)
.atomic_commit = drm_atomic_helper_commit,
 };
 
-static int malidp_enable_vblank(struct drm_device *drm, unsigned int crtc)
-{
-   struct malidp_drm *malidp = drm->dev_private;
-   struct malidp_hw_device *hwdev = malidp->dev;
-
-   malidp_hw_enable_irq(hwdev, MALIDP_DE_BLOCK,
-hwdev->map.de_irq_map.vsync_irq);
-   return 0;
-}
-
-static void malidp_disable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct malidp_drm *malidp = drm->dev_private;
-   struct malidp_hw_device *hwdev = malidp->dev;
-
-   malidp_hw_disable_irq(hwdev, MALIDP_DE_BLOCK,
- hwdev->map.de_irq_map.vsync_irq);
-}
-
 static int malidp_init(struct drm_device *drm)
 {
int ret;
@@ -213,8 +194,6 @@ static void malidp_lastclose(struct drm_device *drm)
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
   DRIVER_PRIME,
.lastclose = malidp_lastclose,
-   .enable_vblank = malidp_enable_vblank,
-   .disable_vblank = malidp_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = drm_gem_cma_dumb_create,
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 10/23] drm: hibmc: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Xinliang Liu 
---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c  | 20 
 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 22 --
 2 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
index c655883d3613..59542bddc980 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
@@ -423,6 +423,24 @@ static void hibmc_crtc_atomic_flush(struct drm_crtc *crtc,
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
 }
 
+static int hibmc_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct hibmc_drm_private *priv = crtc->dev->dev_private;
+
+   writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(1),
+  priv->mmio + HIBMC_RAW_INTERRUPT_EN);
+
+   return 0;
+}
+
+static void hibmc_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct hibmc_drm_private *priv = crtc->dev->dev_private;
+
+   writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(0),
+  priv->mmio + HIBMC_RAW_INTERRUPT_EN);
+}
+
 static const struct drm_crtc_funcs hibmc_crtc_funcs = {
.page_flip = drm_atomic_helper_page_flip,
.set_config = drm_atomic_helper_set_config,
@@ -430,6 +448,8 @@ static void hibmc_crtc_atomic_flush(struct drm_crtc *crtc,
.reset = drm_atomic_helper_crtc_reset,
.atomic_duplicate_state =  drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = hibmc_crtc_enable_vblank,
+   .disable_vblank = hibmc_crtc_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs hibmc_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 8cac70454b57..2ffdbf9801bd 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -37,26 +37,6 @@
.llseek = no_llseek,
 };
 
-static int hibmc_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct hibmc_drm_private *priv =
-   (struct hibmc_drm_private *)dev->dev_private;
-
-   writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(1),
-  priv->mmio + HIBMC_RAW_INTERRUPT_EN);
-
-   return 0;
-}
-
-static void hibmc_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct hibmc_drm_private *priv =
-   (struct hibmc_drm_private *)dev->dev_private;
-
-   writel(HIBMC_RAW_INTERRUPT_EN_VBLANK(0),
-  priv->mmio + HIBMC_RAW_INTERRUPT_EN);
-}
-
 irqreturn_t hibmc_drm_interrupt(int irq, void *arg)
 {
struct drm_device *dev = (struct drm_device *)arg;
@@ -84,8 +64,6 @@ irqreturn_t hibmc_drm_interrupt(int irq, void *arg)
.desc   = "hibmc drm driver",
.major  = 1,
.minor  = 0,
-   .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,
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 12/23] drm: imx: remove struct imx_drm_crtc and imx_drm_crtc_helper_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

With the vblank hooks in struct drm_crtc_funcs, we do not need to
maintain the CRTC specific vblank callbacks with struct
imx_drm_crtc_helper_funcs any more.  By moving the stuff that we
currently do in imx_drm_add_crtc(), like of_node setting and
drm_crtc_helper_add()/drm_crtc_init_with_planes() invoking, we can kill
things like struct imx_drm_crtc, imx_drm_crtc_helper_funcs and related
functions completely.

Functions ipu_enable_vblank() and ipu_disable_vblank() are moved around
without changes, only for saving the forward declarations.

Signed-off-by: Shawn Guo 
Cc: Philipp Zabel 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 101 -
 drivers/gpu/drm/imx/imx-drm.h  |  13 -
 drivers/gpu/drm/imx/ipuv3-crtc.c   |  58 -
 3 files changed, 22 insertions(+), 150 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index 4badbb66d69e..65bd8b8a2494 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -40,17 +40,11 @@ struct imx_drm_component {
 
 struct imx_drm_device {
struct drm_device   *drm;
-   struct imx_drm_crtc *crtc[MAX_CRTC];
unsigned intpipes;
struct drm_fbdev_cma*fbhelper;
struct drm_atomic_state *state;
 };
 
-struct imx_drm_crtc {
-   struct drm_crtc *crtc;
-   struct imx_drm_crtc_helper_funcsimx_drm_helper_funcs;
-};
-
 #if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
 static int legacyfb_depth = 16;
 module_param(legacyfb_depth, int, 0444);
@@ -63,38 +57,6 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
 }
 
-static int imx_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct imx_drm_device *imxdrm = drm->dev_private;
-   struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
-   int ret;
-
-   if (!imx_drm_crtc)
-   return -EINVAL;
-
-   if (!imx_drm_crtc->imx_drm_helper_funcs.enable_vblank)
-   return -ENOSYS;
-
-   ret = imx_drm_crtc->imx_drm_helper_funcs.enable_vblank(
-   imx_drm_crtc->crtc);
-
-   return ret;
-}
-
-static void imx_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
-{
-   struct imx_drm_device *imxdrm = drm->dev_private;
-   struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
-
-   if (!imx_drm_crtc)
-   return;
-
-   if (!imx_drm_crtc->imx_drm_helper_funcs.disable_vblank)
-   return;
-
-   imx_drm_crtc->imx_drm_helper_funcs.disable_vblank(imx_drm_crtc->crtc);
-}
-
 static const struct file_operations imx_drm_driver_fops = {
.owner = THIS_MODULE,
.open = drm_open,
@@ -180,67 +142,6 @@ static void imx_drm_atomic_commit_tail(struct 
drm_atomic_state *state)
.atomic_commit_tail = imx_drm_atomic_commit_tail,
 };
 
-/*
- * imx_drm_add_crtc - add a new crtc
- */
-int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
-   struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane,
-   const struct imx_drm_crtc_helper_funcs *imx_drm_helper_funcs,
-   struct device_node *port)
-{
-   struct imx_drm_device *imxdrm = drm->dev_private;
-   struct imx_drm_crtc *imx_drm_crtc;
-
-   /*
-* The vblank arrays are dimensioned by MAX_CRTC - we can't
-* pass IDs greater than this to those functions.
-*/
-   if (imxdrm->pipes >= MAX_CRTC)
-   return -EINVAL;
-
-   if (imxdrm->drm->open_count)
-   return -EBUSY;
-
-   imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL);
-   if (!imx_drm_crtc)
-   return -ENOMEM;
-
-   imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs;
-   imx_drm_crtc->crtc = crtc;
-
-   crtc->port = port;
-
-   imxdrm->crtc[imxdrm->pipes++] = imx_drm_crtc;
-
-   *new_crtc = imx_drm_crtc;
-
-   drm_crtc_helper_add(crtc,
-   imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs);
-
-   drm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
-   imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs, NULL);
-
-   return 0;
-}
-EXPORT_SYMBOL_GPL(imx_drm_add_crtc);
-
-/*
- * imx_drm_remove_crtc - remove a crtc
- */
-int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc)
-{
-   struct imx_drm_device *imxdrm = imx_drm_crtc->crtc->dev->dev_private;
-   unsigned int pipe = drm_crtc_index(imx_drm_crtc->crtc);
-
-   drm_crtc_cleanup(imx_drm_crtc->crtc);
-
-   imxdrm->crtc[pipe] = NULL;
-
-   kfree(imx_drm_crtc);
-
-   return 0;
-}
-EXPORT_SYMBOL_GPL(imx_drm_remove_crtc);
 
 int 

[PATCH v3 11/23] drm: kirin: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Xinliang Liu 
---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
index 0624fab8046f..c96c228a9898 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -302,9 +302,8 @@ static void ade_set_medianoc_qos(struct ade_crtc *acrtc)
   SOCKET_QOS_EN, SOCKET_QOS_EN);
 }
 
-static int ade_enable_vblank(struct drm_device *dev, unsigned int pipe)
+static int ade_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
struct ade_crtc *acrtc = to_ade_crtc(crtc);
struct ade_hw_ctx *ctx = acrtc->ctx;
void __iomem *base = ctx->base;
@@ -318,9 +317,8 @@ static int ade_enable_vblank(struct drm_device *dev, 
unsigned int pipe)
return 0;
 }
 
-static void ade_disable_vblank(struct drm_device *dev, unsigned int pipe)
+static void ade_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
struct ade_crtc *acrtc = to_ade_crtc(crtc);
struct ade_hw_ctx *ctx = acrtc->ctx;
void __iomem *base = ctx->base;
@@ -570,6 +568,8 @@ static void ade_crtc_atomic_flush(struct drm_crtc *crtc,
.set_property = drm_atomic_helper_crtc_set_property,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state   = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank  = ade_crtc_enable_vblank,
+   .disable_vblank = ade_crtc_disable_vblank,
 };
 
 static int ade_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
@@ -1025,8 +1025,6 @@ static int ade_drm_init(struct platform_device *pdev)
   IRQF_SHARED, dev->driver->name, acrtc);
if (ret)
return ret;
-   dev->driver->enable_vblank = ade_enable_vblank;
-   dev->driver->disable_vblank = ade_disable_vblank;
 
return 0;
 }
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 13/23] drm: mediatek: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: CK Hu 
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 8 
 drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 2 --
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 3 ---
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index a73de1e669c2..69982f5a6198 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -168,9 +168,8 @@ static void mtk_drm_crtc_mode_set_nofb(struct drm_crtc 
*crtc)
state->pending_config = true;
 }
 
-int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe)
+static int mtk_drm_crtc_enable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
 
@@ -179,9 +178,8 @@ int mtk_drm_crtc_enable_vblank(struct drm_device *drm, 
unsigned int pipe)
return 0;
 }
 
-void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe)
+static void mtk_drm_crtc_disable_vblank(struct drm_crtc *crtc)
 {
-   struct drm_crtc *crtc = drm_crtc_from_index(drm, pipe);
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
struct mtk_ddp_comp *ovl = mtk_crtc->ddp_comp[0];
 
@@ -436,6 +434,8 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
.atomic_duplicate_state = mtk_drm_crtc_duplicate_state,
.atomic_destroy_state   = mtk_drm_crtc_destroy_state,
.gamma_set  = drm_atomic_helper_legacy_gamma_set,
+   .enable_vblank  = mtk_drm_crtc_enable_vblank,
+   .disable_vblank = mtk_drm_crtc_disable_vblank,
 };
 
 static const struct drm_crtc_helper_funcs mtk_crtc_helper_funcs = {
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h 
b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h
index a1550fa3c9d2..9d9410c67ae9 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.h
@@ -23,8 +23,6 @@
 #define MTK_MAX_BPC10
 #define MTK_MIN_BPC3
 
-int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe);
-void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe);
 void mtk_drm_crtc_commit(struct drm_crtc *crtc);
 void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *ovl);
 int mtk_drm_crtc_create(struct drm_device *drm_dev,
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index ef8675336465..f5a1fd9b3ecc 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -256,9 +256,6 @@ static void mtk_drm_kms_deinit(struct drm_device *drm)
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
   DRIVER_ATOMIC,
 
-   .enable_vblank = mtk_drm_crtc_enable_vblank,
-   .disable_vblank = mtk_drm_crtc_disable_vblank,
-
.gem_free_object_unlocked = mtk_drm_gem_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = mtk_drm_gem_dumb_create,
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 15/23] drm: qxl: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Dave Airlie 
---
 drivers/gpu/drm/qxl/qxl_display.c | 16 
 drivers/gpu/drm/qxl/qxl_drv.c | 18 --
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_display.c 
b/drivers/gpu/drm/qxl/qxl_display.c
index 1094cd33eb06..2ce805a7ce5e 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -548,6 +548,19 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
return 0;
 }
 
+static u32 qxl_noop_get_vblank_counter(struct drm_crtc *crtc)
+{
+   return 0;
+}
+
+static int qxl_noop_enable_vblank(struct drm_crtc *crtc)
+{
+   return 0;
+}
+
+static void qxl_noop_disable_vblank(struct drm_crtc *crtc)
+{
+}
 
 static const struct drm_crtc_funcs qxl_crtc_funcs = {
.cursor_set2 = qxl_crtc_cursor_set2,
@@ -555,6 +568,9 @@ static int qxl_crtc_cursor_move(struct drm_crtc *crtc,
.set_config = drm_crtc_helper_set_config,
.destroy = qxl_crtc_destroy,
.page_flip = qxl_crtc_page_flip,
+   .get_vblank_counter = qxl_noop_get_vblank_counter,
+   .enable_vblank = qxl_noop_enable_vblank,
+   .disable_vblank = qxl_noop_disable_vblank,
 };
 
 void qxl_user_framebuffer_destroy(struct drm_framebuffer *fb)
diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index 8e17c241e63c..48d51a2f3bd8 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -247,21 +247,6 @@ static int qxl_pm_restore(struct device *dev)
return qxl_drm_resume(drm_dev, false);
 }
 
-static u32 qxl_noop_get_vblank_counter(struct drm_device *dev,
-  unsigned int pipe)
-{
-   return 0;
-}
-
-static int qxl_noop_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   return 0;
-}
-
-static void qxl_noop_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-}
-
 static const struct dev_pm_ops qxl_pm_ops = {
.suspend = qxl_pm_suspend,
.resume = qxl_pm_resume,
@@ -281,9 +266,6 @@ static void qxl_noop_disable_vblank(struct drm_device *dev, 
unsigned int pipe)
 static struct drm_driver qxl_driver = {
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME |
   DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
-   .get_vblank_counter = qxl_noop_get_vblank_counter,
-   .enable_vblank = qxl_noop_enable_vblank,
-   .disable_vblank = qxl_noop_disable_vblank,
 
.set_busid = drm_pci_set_busid,
 
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 16/23] drm: rcar-du: use vblank hooks in struct drm_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

The vblank hooks in struct drm_driver are deprecated and only meant for
legacy drivers.  For modern drivers with DRIVER_MODESET flag, the hooks
in struct drm_crtc_funcs should be used instead.

Signed-off-by: Shawn Guo 
Cc: Laurent Pinchart 
---
 drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 29 +++--
 drivers/gpu/drm/rcar-du/rcar_du_crtc.h |  1 -
 drivers/gpu/drm/rcar-du/rcar_du_drv.c  | 19 ---
 3 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
index a2ec6d8796a0..edcbe2e3625d 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c
@@ -529,6 +529,23 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc 
*crtc,
.atomic_flush = rcar_du_crtc_atomic_flush,
 };
 
+static int rcar_du_crtc_enable_vblank(struct drm_crtc *crtc)
+{
+   struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
+
+   rcar_du_crtc_write(rcrtc, DSRCR, DSRCR_VBCL);
+   rcar_du_crtc_set(rcrtc, DIER, DIER_VBE);
+
+   return 0;
+}
+
+static void rcar_du_crtc_disable_vblank(struct drm_crtc *crtc)
+{
+   struct rcar_du_crtc *rcrtc = to_rcar_crtc(crtc);
+
+   rcar_du_crtc_clr(rcrtc, DIER, DIER_VBE);
+}
+
 static const struct drm_crtc_funcs crtc_funcs = {
.reset = drm_atomic_helper_crtc_reset,
.destroy = drm_crtc_cleanup,
@@ -536,6 +553,8 @@ static void rcar_du_crtc_atomic_flush(struct drm_crtc *crtc,
.page_flip = drm_atomic_helper_page_flip,
.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
+   .enable_vblank = rcar_du_crtc_enable_vblank,
+   .disable_vblank = rcar_du_crtc_disable_vblank,
 };
 
 /* 
-
@@ -650,13 +669,3 @@ int rcar_du_crtc_create(struct rcar_du_group *rgrp, 
unsigned int index)
 
return 0;
 }
-
-void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable)
-{
-   if (enable) {
-   rcar_du_crtc_write(rcrtc, DSRCR, DSRCR_VBCL);
-   rcar_du_crtc_set(rcrtc, DIER, DIER_VBE);
-   } else {
-   rcar_du_crtc_clr(rcrtc, DIER, DIER_VBE);
-   }
-}
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h 
b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
index 6f08b7e7db06..a7194812997e 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.h
@@ -66,7 +66,6 @@ enum rcar_du_output {
 };
 
 int rcar_du_crtc_create(struct rcar_du_group *rgrp, unsigned int index);
-void rcar_du_crtc_enable_vblank(struct rcar_du_crtc *rcrtc, bool enable);
 void rcar_du_crtc_suspend(struct rcar_du_crtc *rcrtc);
 void rcar_du_crtc_resume(struct rcar_du_crtc *rcrtc);
 
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 094da3ef49d1..192346d4fb34 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 
-#include "rcar_du_crtc.h"
 #include "rcar_du_drv.h"
 #include "rcar_du_kms.h"
 #include "rcar_du_regs.h"
@@ -227,22 +226,6 @@ static void rcar_du_lastclose(struct drm_device *dev)
drm_fbdev_cma_restore_mode(rcdu->fbdev);
 }
 
-static int rcar_du_enable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct rcar_du_device *rcdu = dev->dev_private;
-
-   rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], true);
-
-   return 0;
-}
-
-static void rcar_du_disable_vblank(struct drm_device *dev, unsigned int pipe)
-{
-   struct rcar_du_device *rcdu = dev->dev_private;
-
-   rcar_du_crtc_enable_vblank(&rcdu->crtcs[pipe], false);
-}
-
 static const struct file_operations rcar_du_fops = {
.owner  = THIS_MODULE,
.open   = drm_open,
@@ -259,8 +242,6 @@ static void rcar_du_disable_vblank(struct drm_device *dev, 
unsigned int pipe)
.driver_features= DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME
| DRIVER_ATOMIC,
.lastclose  = rcar_du_lastclose,
-   .enable_vblank  = rcar_du_enable_vblank,
-   .disable_vblank = rcar_du_disable_vblank,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
-- 
1.9.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 17/23] drm: rockchip: remove struct rockchip_crtc_funcs

2017-02-07 Thread Shawn Guo
From: Shawn Guo 

With the vblank hooks in struct drm_crtc_funcs, we do not need to
maintain struct rockchip_crtc_funcs and the related registration
functions.  Remove them.

Signed-off-by: Shawn Guo 
Cc: Mark Yao 
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 51 -
 drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 14 
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  9 ++---
 3 files changed, 2 insertions(+), 72 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 39243480c834..7719b9cd5b74 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -74,55 +74,6 @@ void rockchip_drm_dma_detach_device(struct drm_device 
*drm_dev,
arm_iommu_detach_device(dev);
 }
 
-int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
-const struct rockchip_crtc_funcs *crtc_funcs)
-{
-   int pipe = drm_crtc_index(crtc);
-   struct rockchip_drm_private *priv = crtc->dev->dev_private;
-
-   if (pipe >= ROCKCHIP_MAX_CRTC)
-   return -EINVAL;
-
-   priv->crtc_funcs[pipe] = crtc_funcs;
-
-   return 0;
-}
-
-void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc)
-{
-   int pipe = drm_crtc_index(crtc);
-   struct rockchip_drm_private *priv = crtc->dev->dev_private;
-
-   if (pipe >= ROCKCHIP_MAX_CRTC)
-   return;
-
-   priv->crtc_funcs[pipe] = NULL;
-}
-
-static int rockchip_drm_crtc_enable_vblank(struct drm_device *dev,
-  unsigned int pipe)
-{
-   struct rockchip_drm_private *priv = dev->dev_private;
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
-
-   if (crtc && priv->crtc_funcs[pipe] &&
-   priv->crtc_funcs[pipe]->enable_vblank)
-   return priv->crtc_funcs[pipe]->enable_vblank(crtc);
-
-   return 0;
-}
-
-static void rockchip_drm_crtc_disable_vblank(struct drm_device *dev,
-unsigned int pipe)
-{
-   struct rockchip_drm_private *priv = dev->dev_private;
-   struct drm_crtc *crtc = drm_crtc_from_index(dev, pipe);
-
-   if (crtc && priv->crtc_funcs[pipe] &&
-   priv->crtc_funcs[pipe]->enable_vblank)
-   priv->crtc_funcs[pipe]->disable_vblank(crtc);
-}
-
 static int rockchip_drm_bind(struct device *dev)
 {
struct drm_device *drm_dev;
@@ -270,8 +221,6 @@ static void rockchip_drm_lastclose(struct drm_device *dev)
.driver_features= DRIVER_MODESET | DRIVER_GEM |
  DRIVER_PRIME | DRIVER_ATOMIC,
.lastclose  = rockchip_drm_lastclose,
-   .enable_vblank  = rockchip_drm_crtc_enable_vblank,
-   .disable_vblank = rockchip_drm_crtc_disable_vblank,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.gem_free_object_unlocked = rockchip_gem_free_object,
.dumb_create= rockchip_gem_dumb_create,
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
index fb6226cf84b7..9f9bc959b108 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h
@@ -31,16 +31,6 @@
 struct drm_device;
 struct drm_connector;
 
-/*
- * Rockchip drm private crtc funcs.
- * @enable_vblank: enable crtc vblank irq.
- * @disable_vblank: disable crtc vblank irq.
- */
-struct rockchip_crtc_funcs {
-   int (*enable_vblank)(struct drm_crtc *crtc);
-   void (*disable_vblank)(struct drm_crtc *crtc);
-};
-
 struct rockchip_crtc_state {
struct drm_crtc_state base;
int output_type;
@@ -58,16 +48,12 @@ struct rockchip_crtc_state {
 struct rockchip_drm_private {
struct drm_fb_helper fbdev_helper;
struct drm_gem_object *fbdev_bo;
-   const struct rockchip_crtc_funcs *crtc_funcs[ROCKCHIP_MAX_CRTC];
struct drm_atomic_state *state;
 
struct list_head psr_list;
spinlock_t psr_list_lock;
 };
 
-int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
-const struct rockchip_crtc_funcs *crtc_funcs);
-void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc);
 int rockchip_drm_dma_attach_device(struct drm_device *drm_dev,
   struct device *dev);
 void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index fb5f001f51c3..ffee8d8c3794 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -853,11 +853,6 @@ static void vop_crtc_disable_vblank(struct drm_crtc *crtc)
spin_unlock_irqrestore(&vop->irq_lock, flags);
 }
 
-static const struct rockchip_crt

  1   2   3   4   >