Skip to contentSkip to conversation

drm/sti: update STI driver to be atomic

PATCH In review Vincent Abriou 4 participants 9 messages Jul 31, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drm/sti: update STI driver to be atomic

This patch series aims to update the sti drm driver to be atomic. To do so, the sti driver needs to be code cleaned to have good fundations to enable the atomic plane update functionnality. The driver is thereby simplier, more readable and better fit the STI hardware structure.

Vincent Abriou (4):
drm/sti: fix dynamic z-ordering
drm/sti: code clean up
drm/sti: rename files and functions
drm/sti: atomic crtc/plane update

 drivers/gpu/drm/sti/Makefile         |   7 +-
 drivers/gpu/drm/sti/sti_compositor.c | 141 +++++----
 drivers/gpu/drm/sti/sti_compositor.h |  12 +-
 drivers/gpu/drm/sti/sti_crtc.c       | 396 ++++++++++++++++++++++++++
 drivers/gpu/drm/sti/sti_crtc.h       |  22 ++
 drivers/gpu/drm/sti/sti_cursor.c     | 243 +++++++++-------
 drivers/gpu/drm/sti/sti_cursor.h     |   5 +-
 drivers/gpu/drm/sti/sti_drm_crtc.c   | 322 ---------------------
 drivers/gpu/drm/sti/sti_drm_crtc.h   |  22 --
 drivers/gpu/drm/sti/sti_drm_drv.c    | 294 -------------------
 drivers/gpu/drm/sti/sti_drm_drv.h    |  35 ---
 drivers/gpu/drm/sti/sti_drm_plane.c  | 251 ----------------
 drivers/gpu/drm/sti/sti_drm_plane.h  |  18 --
 drivers/gpu/drm/sti/sti_drv.c        | 294 +++++++++++++++++++
 drivers/gpu/drm/sti/sti_drv.h        |  35 +++
 drivers/gpu/drm/sti/sti_gdp.c        | 536 ++++++++++++++++++++---------------
 drivers/gpu/drm/sti/sti_gdp.h        |   7 +-
 drivers/gpu/drm/sti/sti_hdmi.c       |   2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c      | 482 ++++++++++++++++---------------
 drivers/gpu/drm/sti/sti_hqvdp.h      |  12 -
 drivers/gpu/drm/sti/sti_layer.c      | 213 --------------
 drivers/gpu/drm/sti/sti_layer.h      | 131 ---------
 drivers/gpu/drm/sti/sti_mixer.c      |  66 ++---
 drivers/gpu/drm/sti/sti_mixer.h      |  28 +-
 drivers/gpu/drm/sti/sti_plane.c      | 120 ++++++++
 drivers/gpu/drm/sti/sti_plane.h      |  71 +++++
 drivers/gpu/drm/sti/sti_tvout.c      |   8 +-
 drivers/gpu/drm/sti/sti_vid.c        |  72 ++---
 drivers/gpu/drm/sti/sti_vid.h        |  19 +-
 29 files changed, 1825 insertions(+), 2039 deletions(-)
 create mode 100644 drivers/gpu/drm/sti/sti_crtc.c
 create mode 100644 drivers/gpu/drm/sti/sti_crtc.h
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_drv.h
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_plane.h
 create mode 100644 drivers/gpu/drm/sti/sti_drv.c
 create mode 100644 drivers/gpu/drm/sti/sti_drv.h
 delete mode 100644 drivers/gpu/drm/sti/sti_hqvdp.h
 delete mode 100644 drivers/gpu/drm/sti/sti_layer.c
 delete mode 100644 drivers/gpu/drm/sti/sti_layer.h
 create mode 100644 drivers/gpu/drm/sti/sti_plane.c
 create mode 100644 drivers/gpu/drm/sti/sti_plane.h
Signature · 6 lines
1.9.1

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

PATCH 1/4 drm/sti: fix dynamic z-ordering

Apply the plane depth when the plane is updated.
If the depth is different from the previous plane update, the register controlling the plane depth is cleaned and updated with the new depth.

---
 drivers/gpu/drm/sti/sti_drm_plane.c | 23 +++++++++--------------
 drivers/gpu/drm/sti/sti_mixer.c     | 19 ++++++++++++++-----
 drivers/gpu/drm/sti/sti_mixer.h     |  2 +-
 3 files changed, 24 insertions(+), 20 deletions(-)
drivers/gpu/drm/sti/sti_drm_plane.c +9 -14
index 64d4ed4..5427bc2 100644
@@ -15,17 +15,16 @@
 #include "sti_drm_plane.h"
 #include "sti_vtg.h"
 
+/* (Background) < GDP0 < GDP1 < VID0 < VID1 < GDP2 < GDP3 < (ForeGround) */
 enum sti_layer_desc sti_layer_default_zorder[] = {
 	STI_GDP_0,
-	STI_VID_0,
 	STI_GDP_1,
+	STI_VID_0,
 	STI_VID_1,
 	STI_GDP_2,
 	STI_GDP_3,
 };
 
-/* (Background) < GDP0 < VID0 < GDP1 < VID1 < GDP2 < GDP3 < (ForeGround) */
-
 static int
 sti_drm_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 		     struct drm_framebuffer *fb, int crtc_x, int crtc_y,
@@ -191,8 +190,7 @@ static const struct drm_plane_helper_funcs sti_drm_plane_helpers_funcs = {
 	.atomic_disable = sti_drm_plane_atomic_disable,
 };
 
-static void sti_drm_plane_attach_zorder_property(struct drm_plane *plane,
-						 uint64_t default_val)
+static void sti_drm_plane_attach_zorder_property(struct drm_plane *plane)
 {
 	struct drm_device *dev = plane->dev;
 	struct sti_drm_private *private = dev->dev_private;
@@ -201,16 +199,15 @@ static void sti_drm_plane_attach_zorder_property(struct drm_plane *plane,
 
 	prop = private->plane_zorder_property;
 	if (!prop) {
-		prop = drm_property_create_range(dev, 0, "zpos", 0,
-						 GAM_MIXER_NB_DEPTH_LEVEL - 1);
+		prop = drm_property_create_range(dev, 0, "zpos", 1,
+						 GAM_MIXER_NB_DEPTH_LEVEL);
 		if (!prop)
 			return;
 
 		private->plane_zorder_property = prop;
 	}
 
-	drm_object_attach_property(&plane->base, prop, default_val);
-	layer->zorder = default_val;
+	drm_object_attach_property(&plane->base, prop, layer->zorder);
 }
 
 struct drm_plane *sti_drm_plane_init(struct drm_device *dev,
@@ -219,7 +216,6 @@ struct drm_plane *sti_drm_plane_init(struct drm_device *dev,
 				     enum drm_plane_type type)
 {
 	int err, i;
-	uint64_t default_zorder = 0;
 
 	err = drm_universal_plane_init(dev, &layer->plane, possible_crtcs,
 			     &sti_drm_plane_funcs,
@@ -236,15 +232,14 @@ struct drm_plane *sti_drm_plane_init(struct drm_device *dev,
 		if (sti_layer_default_zorder[i] == layer->desc)
 			break;
 
-	default_zorder = i + 1;
+	layer->zorder = i + 1;
 
 	if (type == DRM_PLANE_TYPE_OVERLAY)
-		sti_drm_plane_attach_zorder_property(&layer->plane,
-				default_zorder);
+		sti_drm_plane_attach_zorder_property(&layer->plane);
 
 	DRM_DEBUG_DRIVER("drm plane:%d mapped to %s with zorder:%llu\n",
 			 layer->plane.base.id,
-			 sti_layer_to_str(layer), default_zorder);
+			 sti_layer_to_str(layer), layer->zorder);
 
 	return &layer->plane;
 }
drivers/gpu/drm/sti/sti_mixer.c +14 -5
index 13a4b84..61a2048 100644
@@ -103,10 +103,11 @@ static void sti_mixer_set_background_area(struct sti_mixer *mixer,
 
 int sti_mixer_set_layer_depth(struct sti_mixer *mixer, struct sti_layer *layer)
 {
-	int layer_id = 0, depth = layer->zorder;
+	int layer_id, depth = layer->zorder;
+	unsigned int i;
 	u32 mask, val;
 
-	if (depth >= GAM_MIXER_NB_DEPTH_LEVEL)
+	if ((depth < 1) || (depth > GAM_MIXER_NB_DEPTH_LEVEL))
 		return 1;
 
 	switch (layer->desc) {
@@ -136,15 +137,23 @@ int sti_mixer_set_layer_depth(struct sti_mixer *mixer, struct sti_layer *layer)
 		DRM_ERROR("Unknown layer %d\n", layer->desc);
 		return 1;
 	}
-	mask = GAM_DEPTH_MASK_ID << (3 * depth);
-	layer_id = layer_id << (3 * depth);
+
+	/* Search if a previous depth was already assigned to the layer */
+	val = sti_mixer_reg_read(mixer, GAM_MIXER_CRB);
+	for (i = 0; i < GAM_MIXER_NB_DEPTH_LEVEL; i++) {
+		mask = GAM_DEPTH_MASK_ID << (3 * i);
+		if ((val & mask) == layer_id << (3 * i))
+			break;
+	}
+
+	mask |= GAM_DEPTH_MASK_ID << (3 * (depth - 1));
+	layer_id = layer_id << (3 * (depth - 1));
 
 	DRM_DEBUG_DRIVER("%s %s depth=%d\n", sti_mixer_to_str(mixer),
 			 sti_layer_to_str(layer), depth);
 	dev_dbg(mixer->dev, "GAM_MIXER_CRB val 0x%x mask 0x%x\n",
 		layer_id, mask);
 
-	val = sti_mixer_reg_read(mixer, GAM_MIXER_CRB);
 	val &= ~mask;
 	val |= layer_id;
 	sti_mixer_reg_write(mixer, GAM_MIXER_CRB, val);
drivers/gpu/drm/sti/sti_mixer.h +1 -1
index b972821..eb663f6 100644
@@ -49,7 +49,7 @@ int sti_mixer_active_video_area(struct sti_mixer *mixer,
 void sti_mixer_set_background_status(struct sti_mixer *mixer, bool enable);
 
 /* depth in Cross-bar control = z order */
-#define GAM_MIXER_NB_DEPTH_LEVEL 7
+#define GAM_MIXER_NB_DEPTH_LEVEL 6
 
 #define STI_MIXER_MAIN 0
 #define STI_MIXER_AUX  1
Signature · 6 lines
1.9.1

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

PATCH 2/4 drm/sti: code clean up

In reply to Vincent Abriou

Purpose is to simplify the STI driver:
- remove layer structure
- consider video subdev as part of the compositor (like mixer subdev)
- remove useless STI_VID0 and STI_VID1 enum

---
 drivers/gpu/drm/sti/Makefile         |   1 -
 drivers/gpu/drm/sti/sti_compositor.c | 135 ++++++++-------
 drivers/gpu/drm/sti/sti_compositor.h |  12 +-
 drivers/gpu/drm/sti/sti_cursor.c     | 108 ++++++------
 drivers/gpu/drm/sti/sti_cursor.h     |   3 +-
 drivers/gpu/drm/sti/sti_drm_crtc.c   |  34 ++--
 drivers/gpu/drm/sti/sti_drm_plane.c  | 322 +++++++++++++++++++++++------------
 drivers/gpu/drm/sti/sti_drm_plane.h  |  91 +++++++++-
 drivers/gpu/drm/sti/sti_gdp.c        | 185 ++++++++++----------
 drivers/gpu/drm/sti/sti_gdp.h        |   3 +-
 drivers/gpu/drm/sti/sti_hdmi.c       |   2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c      | 201 +++++++++++-----------
 drivers/gpu/drm/sti/sti_hqvdp.h      |  12 --
 drivers/gpu/drm/sti/sti_layer.c      | 213 -----------------------
 drivers/gpu/drm/sti/sti_layer.h      | 131 --------------
 drivers/gpu/drm/sti/sti_mixer.c      |  55 +++---
 drivers/gpu/drm/sti/sti_mixer.h      |  16 +-
 drivers/gpu/drm/sti/sti_vid.c        |  57 ++-----
 drivers/gpu/drm/sti/sti_vid.h        |  18 +-
 19 files changed, 713 insertions(+), 886 deletions(-)
 delete mode 100644 drivers/gpu/drm/sti/sti_hqvdp.h
 delete mode 100644 drivers/gpu/drm/sti/sti_layer.c
 delete mode 100644 drivers/gpu/drm/sti/sti_layer.h
drivers/gpu/drm/sti/Makefile +0 -1
index f0f1e4e..505b3ba 100644
@@ -1,5 +1,4 @@
 sticompositor-y := \
-	sti_layer.o \
 	sti_mixer.o \
 	sti_gdp.o \
 	sti_vid.o \
drivers/gpu/drm/sti/sti_compositor.c +69 -66

200 lines not on this page · raw message

drivers/gpu/drm/sti/sti_compositor.h +4 -8
index 019eb44..77f9978 100644
@@ -12,13 +12,13 @@
 #include <linux/clk.h>
 #include <linux/kernel.h>
 
-#include "sti_layer.h"
+#include "sti_drm_plane.h"
 #include "sti_mixer.h"
 
 #define WAIT_NEXT_VSYNC_MS      50 /*ms*/
 
-#define STI_MAX_LAYER 8
 #define STI_MAX_MIXER 2
+#define STI_MAX_VID   1
 
 enum sti_compositor_subdev_type {
 	STI_MIXER_MAIN_SUBDEV,
@@ -59,11 +59,9 @@ struct sti_compositor_data {
  * @rst_main: reset control of the main path
  * @rst_aux: reset control of the aux path
  * @mixer: array of mixers
+ * @vid: array of vids
  * @vtg_main: vtg for main data path
  * @vtg_aux: vtg for auxillary data path
- * @layer: array of layers
- * @nb_mixers: number of mixers for this compositor
- * @nb_layers: number of layers (GDP,VID,...) for this compositor
  * @vtg_vblank_nb: callback for VTG VSYNC notification
  */
 struct sti_compositor {
@@ -77,11 +75,9 @@ struct sti_compositor {
 	struct reset_control *rst_main;
 	struct reset_control *rst_aux;
 	struct sti_mixer *mixer[STI_MAX_MIXER];
+	struct sti_vid *vid[STI_MAX_VID];
 	struct sti_vtg *vtg_main;
 	struct sti_vtg *vtg_aux;
-	struct sti_layer *layer[STI_MAX_LAYER];
-	int nb_mixers;
-	int nb_layers;
 	struct notifier_block vtg_vblank_nb;
 };
 
drivers/gpu/drm/sti/sti_cursor.c +58 -50

221 lines not on this page · raw message

drivers/gpu/drm/sti/sti_cursor.h +2 -1
index 3c98274..db973b7 100644
@@ -7,6 +7,7 @@
 #ifndef _STI_CURSOR_H_
 #define _STI_CURSOR_H_
 
-struct sti_layer *sti_cursor_create(struct device *dev);
+struct sti_plane *sti_cursor_create(struct device *dev, int desc,
+				    void __iomem *baseaddr);
 
 #endif
drivers/gpu/drm/sti/sti_drm_crtc.c +17 -17
index 6b641c5..a489b04 100644
@@ -41,7 +41,7 @@ static void sti_drm_crtc_prepare(struct drm_crtc *crtc)
 			DRM_INFO("Failed to prepare/enable compo_aux clk\n");
 	}
 
-	sti_mixer_clear_all_layers(mixer);
+	sti_mixer_clear_all_planes(mixer);
 }
 
 static void sti_drm_crtc_commit(struct drm_crtc *crtc)
@@ -49,23 +49,21 @@ static void sti_drm_crtc_commit(struct drm_crtc *crtc)
 	struct sti_mixer *mixer = to_sti_mixer(crtc);
 	struct device *dev = mixer->dev;
 	struct sti_compositor *compo = dev_get_drvdata(dev);
-	struct sti_layer *layer;
+	struct sti_plane *plane;
 
 	if ((!mixer || !compo)) {
-		DRM_ERROR("Can not find mixer or compositor)\n");
+		DRM_ERROR("Can't find mixer or compositor)\n");
 		return;
 	}
 
 	/* get GDP which is reserved to the CRTC FB */
-	layer = to_sti_layer(crtc->primary);
-	if (layer)
-		sti_layer_commit(layer);
-	else
-		DRM_ERROR("Can not find CRTC dedicated plane (GDP0)\n");
+	plane = to_sti_plane(crtc->primary);
+	if (!plane)
+		DRM_ERROR("Can't find CRTC dedicated plane (GDP0)\n");
 
-	/* Enable layer on mixer */
-	if (sti_mixer_set_layer_status(mixer, layer, true))
-		DRM_ERROR("Can not enable layer at mixer\n");
+	/* Enable plane on mixer */
+	if (sti_mixer_set_plane_status(mixer, plane, true))
+		DRM_ERROR("Cannot enable plane at mixer\n");
 
 	drm_crtc_vblank_on(crtc);
 }
@@ -122,7 +120,7 @@ sti_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode)
 
 	res = sti_mixer_active_video_area(mixer, &crtc->mode);
 	if (res) {
-		DRM_ERROR("Can not set active video area\n");
+		DRM_ERROR("Can't set active video area\n");
 		return -EINVAL;
 	}
 
@@ -164,7 +162,7 @@ sti_drm_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	sti_drm_crtc_mode_set(crtc, &crtc->state->adjusted_mode);
 }
 
-static void sti_drm_atomic_begin(struct drm_crtc *crtc)
+static void sti_drm_crtc_atomic_begin(struct drm_crtc *crtc)
 {
 	struct sti_mixer *mixer = to_sti_mixer(crtc);
 
@@ -178,7 +176,7 @@ static void sti_drm_atomic_begin(struct drm_crtc *crtc)
 	}
 }
 
-static void sti_drm_atomic_flush(struct drm_crtc *crtc)
+static void sti_drm_crtc_atomic_flush(struct drm_crtc *crtc)
 {
 }
 
@@ -191,8 +189,8 @@ static struct drm_crtc_helper_funcs sti_crtc_helper_funcs = {
 	.mode_set_nofb = sti_drm_crtc_mode_set_nofb,
 	.mode_set_base = drm_helper_crtc_mode_set_base,
 	.disable = sti_drm_crtc_disable,
-	.atomic_begin = sti_drm_atomic_begin,
-	.atomic_flush = sti_drm_atomic_flush,
+	.atomic_begin = sti_drm_crtc_atomic_begin,
+	.atomic_flush = sti_drm_crtc_atomic_flush,
 };
 
 static void sti_drm_crtc_destroy(struct drm_crtc *crtc)
@@ -248,6 +246,8 @@ int sti_drm_crtc_enable_vblank(struct drm_device *dev, int crtc)
 	struct sti_compositor *compo = dev_priv->compo;
 	struct notifier_block *vtg_vblank_nb = &compo->vtg_vblank_nb;
 
+	DRM_DEBUG_DRIVER("\n");
+
 	if (sti_vtg_register_client(crtc == STI_MIXER_MAIN ?
 			compo->vtg_main : compo->vtg_aux,
 			vtg_vblank_nb, crtc)) {
@@ -309,7 +309,7 @@ int sti_drm_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
 	res = drm_crtc_init_with_planes(drm_dev, crtc, primary, cursor,
 			&sti_crtc_funcs);
 	if (res) {
-		DRM_ERROR("Can not initialze CRTC\n");
+		DRM_ERROR("Can't initialze CRTC\n");
 		return -EINVAL;
 	}
 
drivers/gpu/drm/sti/sti_drm_plane.c +210 -112

433 lines not on this page · raw message

drivers/gpu/drm/sti/sti_drm_plane.h +89 -2

99 lines not on this page · raw message

drivers/gpu/drm/sti/sti_gdp.c +97 -88

427 lines not on this page · raw message

drivers/gpu/drm/sti/sti_gdp.h +2 -1
index 1dab682..01818ea 100644
@@ -11,6 +11,7 @@
 
 #include <linux/types.h>
 
-struct sti_layer *sti_gdp_create(struct device *dev, int id);
+struct sti_plane *sti_gdp_create(struct device *dev, int desc,
+				 void __iomem *baseaddr);
 
 #endif
drivers/gpu/drm/sti/sti_hdmi.c +1 -1
index 06595e9..09e29e4 100644
@@ -588,7 +588,7 @@ static int sti_hdmi_connector_get_modes(struct drm_connector *connector)
 	return count;
 
 fail:
-	DRM_ERROR("Can not read HDMI EDID\n");
+	DRM_ERROR("Can't read HDMI EDID\n");
 	return 0;
 }
 
drivers/gpu/drm/sti/sti_hqvdp.c +97 -104

400 lines not on this page · raw message

drivers/gpu/drm/sti/sti_hqvdp.h deleted +0 -12
deleted file mode 100644
index cd5ecd0..0000000
@@ -1,12 +0,0 @@
-/*
- * Copyright (C) STMicroelectronics SA 2014
- * Authors: Fabien Dessenne <[email protected]> for STMicroelectronics.
- * License terms:  GNU General Public License (GPL), version 2
- */
-
-#ifndef _STI_HQVDP_H_
-#define _STI_HQVDP_H_
-
-struct sti_layer *sti_hqvdp_create(struct device *dev);
-
-#endif
drivers/gpu/drm/sti/sti_layer.c deleted +0 -213

213 lines not on this page · raw message

drivers/gpu/drm/sti/sti_layer.h deleted +0 -131

131 lines not on this page · raw message

drivers/gpu/drm/sti/sti_mixer.c +24 -31

133 lines not on this page · raw message

drivers/gpu/drm/sti/sti_mixer.h +8 -8
index eb663f6..9d51eac 100644
@@ -11,7 +11,7 @@
 
 #include <drm/drmP.h>
 
-#include "sti_layer.h"
+#include "sti_drm_plane.h"
 
 #define to_sti_mixer(x) container_of(x, struct sti_mixer, drm_crtc)
 
@@ -29,7 +29,7 @@ struct sti_mixer {
 	struct device *dev;
 	void __iomem *regs;
 	int id;
-	struct drm_crtc	drm_crtc;
+	struct drm_crtc drm_crtc;
 	struct drm_pending_vblank_event *pending_event;
 	bool enabled;
 };
@@ -37,14 +37,14 @@ struct sti_mixer {
 const char *sti_mixer_to_str(struct sti_mixer *mixer);
 
 struct sti_mixer *sti_mixer_create(struct device *dev, int id,
-		void __iomem *baseaddr);
+				   void __iomem *baseaddr);
 
-int sti_mixer_set_layer_status(struct sti_mixer *mixer,
-		struct sti_layer *layer, bool status);
-void sti_mixer_clear_all_layers(struct sti_mixer *mixer);
-int sti_mixer_set_layer_depth(struct sti_mixer *mixer, struct sti_layer *layer);
+int sti_mixer_set_plane_status(struct sti_mixer *mixer,
+			       struct sti_plane *plane, bool status);
+void sti_mixer_clear_all_planes(struct sti_mixer *mixer);
+int sti_mixer_set_plane_depth(struct sti_mixer *mixer, struct sti_plane *plane);
 int sti_mixer_active_video_area(struct sti_mixer *mixer,
-		struct drm_display_mode *mode);
+				struct drm_display_mode *mode);
 
 void sti_mixer_set_background_status(struct sti_mixer *mixer, bool enable);
 
drivers/gpu/drm/sti/sti_vid.c +18 -39

101 lines not on this page · raw message

drivers/gpu/drm/sti/sti_vid.h +17 -1
index 2c0aecd..cc680a2 100644
@@ -7,6 +7,22 @@
 #ifndef _STI_VID_H_
 #define _STI_VID_H_
 
-struct sti_layer *sti_vid_create(struct device *dev);
+/**
+ * STI VID structure
+ *
+ * @dev:   driver device
+ * @regs:  vid registers
+ * @id:    id of the vid
+ */
+struct sti_vid {
+	struct device *dev;
+	void __iomem *regs;
+	int id;
+};
+
+int sti_vid_commit(struct sti_vid *vid, struct sti_plane *plane);
+int sti_vid_disable(struct sti_vid *vid);
+struct sti_vid *sti_vid_create(struct device *dev, int id,
+			       void __iomem *baseaddr);
 
 #endif
Signature · 6 lines
1.9.1

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

PATCH 3/4 drm/sti: rename files and functions

In reply to Vincent Abriou

replace all "sti_drm_" occurences by "sti_"

---
 drivers/gpu/drm/sti/Makefile         |   6 +-
 drivers/gpu/drm/sti/sti_compositor.c |  24 +--
 drivers/gpu/drm/sti/sti_compositor.h |   2 +-
 drivers/gpu/drm/sti/sti_crtc.c       | 322 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/sti/sti_crtc.h       |  22 +++
 drivers/gpu/drm/sti/sti_cursor.c     |   2 +-
 drivers/gpu/drm/sti/sti_drm_crtc.c   | 322 --------------------------------
 drivers/gpu/drm/sti/sti_drm_crtc.h   |  22 ---
 drivers/gpu/drm/sti/sti_drm_drv.c    | 294 ------------------------------
 drivers/gpu/drm/sti/sti_drm_drv.h    |  35 ----
 drivers/gpu/drm/sti/sti_drm_plane.c  | 344 -----------------------------------
 drivers/gpu/drm/sti/sti_drm_plane.h  | 105 -----------
 drivers/gpu/drm/sti/sti_drv.c        | 294 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/sti/sti_drv.h        |  35 ++++
 drivers/gpu/drm/sti/sti_gdp.c        |   2 +-
 drivers/gpu/drm/sti/sti_hqvdp.c      |   6 +-
 drivers/gpu/drm/sti/sti_mixer.h      |   2 +-
 drivers/gpu/drm/sti/sti_plane.c      | 343 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/sti/sti_plane.h      | 105 +++++++++++
 drivers/gpu/drm/sti/sti_tvout.c      |   8 +-
 drivers/gpu/drm/sti/sti_vid.c        |   2 +-
 21 files changed, 1148 insertions(+), 1149 deletions(-)
 create mode 100644 drivers/gpu/drm/sti/sti_crtc.c
 create mode 100644 drivers/gpu/drm/sti/sti_crtc.h
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.c
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_crtc.h
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_drv.c
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_drv.h
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_plane.c
 delete mode 100644 drivers/gpu/drm/sti/sti_drm_plane.h
 create mode 100644 drivers/gpu/drm/sti/sti_drv.c
 create mode 100644 drivers/gpu/drm/sti/sti_drv.h
 create mode 100644 drivers/gpu/drm/sti/sti_plane.c
 create mode 100644 drivers/gpu/drm/sti/sti_plane.h
drivers/gpu/drm/sti/Makefile +3 -3
index 505b3ba..e27490b 100644
@@ -4,8 +4,8 @@ sticompositor-y := \
 	sti_vid.o \
 	sti_cursor.o \
 	sti_compositor.o \
-	sti_drm_crtc.o \
-	sti_drm_plane.o
+	sti_crtc.o \
+	sti_plane.o
 
 stihdmi-y := sti_hdmi.o \
 	sti_hdmi_tx3g0c55phy.o \
@@ -23,4 +23,4 @@ obj-$(CONFIG_DRM_STI) = \
 	sticompositor.o \
 	sti_hqvdp.o \
 	stidvo.o \
-	sti_drm_drv.o
+	sti_drv.o
drivers/gpu/drm/sti/sti_compositor.c +12 -12
index 68c5c95..d62ed7f 100644
@@ -14,11 +14,11 @@
 #include <drm/drmP.h>
 
 #include "sti_compositor.h"
+#include "sti_crtc.h"
 #include "sti_cursor.h"
-#include "sti_drm_crtc.h"
-#include "sti_drm_drv.h"
-#include "sti_drm_plane.h"
+#include "sti_drv.h"
 #include "sti_gdp.h"
+#include "sti_plane.h"
 #include "sti_vid.h"
 #include "sti_vtg.h"
 
@@ -62,7 +62,7 @@ static int sti_compositor_bind(struct device *dev,
 	struct sti_compositor *compo = dev_get_drvdata(dev);
 	struct drm_device *drm_dev = data;
 	unsigned int i, mixer_id = 0, vid_id = 0, crtc_id = 0, plane_id = 0;
-	struct sti_drm_private *dev_priv = drm_dev->dev_private;
+	struct sti_private *dev_priv = drm_dev->dev_private;
 	struct drm_plane *cursor = NULL;
 	struct drm_plane *primary = NULL;
 	struct sti_compositor_subdev_descriptor *desc = compo->data.subdev_desc;
@@ -116,8 +116,8 @@ static int sti_compositor_bind(struct device *dev,
 				DRM_ERROR("Can't create CURSOR plane\n");
 				break;
 			}
-			cursor = sti_drm_plane_init(drm_dev, plane, 1,
-						    DRM_PLANE_TYPE_CURSOR);
+			cursor = sti_plane_init(drm_dev, plane, 1,
+						DRM_PLANE_TYPE_CURSOR);
 			plane_id++;
 			break;
 		case STI_GPD_SUBDEV:
@@ -127,9 +127,9 @@ static int sti_compositor_bind(struct device *dev,
 				DRM_ERROR("Can't create GDP plane\n");
 				break;
 			}
-			primary = sti_drm_plane_init(drm_dev, plane,
-						     (1 << mixer_id) - 1,
-						     plane_type);
+			primary = sti_plane_init(drm_dev, plane,
+						 (1 << mixer_id) - 1,
+						 plane_type);
 			plane_id++;
 			break;
 		default:
@@ -139,8 +139,8 @@ static int sti_compositor_bind(struct device *dev,
 
 		/* The first planes are reserved for primary planes*/
 		if (crtc_id < mixer_id && primary) {
-			sti_drm_crtc_init(drm_dev, compo->mixer[crtc_id],
-					  primary, cursor);
+			sti_crtc_init(drm_dev, compo->mixer[crtc_id],
+				      primary, cursor);
 			crtc_id++;
 			cursor = NULL;
 			primary = NULL;
@@ -196,7 +196,7 @@ static int sti_compositor_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 	compo->dev = dev;
-	compo->vtg_vblank_nb.notifier_call = sti_drm_crtc_vblank_cb;
+	compo->vtg_vblank_nb.notifier_call = sti_crtc_vblank_cb;
 
 	/* populate data structure depending on compatibility */
 	BUG_ON(!of_match_node(compositor_of_match, np)->data);
drivers/gpu/drm/sti/sti_compositor.h +1 -1
index 77f9978..1a4a73d 100644
@@ -12,8 +12,8 @@
 #include <linux/clk.h>
 #include <linux/kernel.h>
 
-#include "sti_drm_plane.h"
 #include "sti_mixer.h"
+#include "sti_plane.h"
 
 #define WAIT_NEXT_VSYNC_MS      50 /*ms*/
 
drivers/gpu/drm/sti/sti_crtc.c new file +322 -0

322 lines not on this page · raw message

drivers/gpu/drm/sti/sti_crtc.h new file +22 -0
new file mode 100644
index 0000000..51963e6
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2014
+ * Author: Benjamin Gaignard <[email protected]> for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#ifndef _STI_CRTC_H_
+#define _STI_CRTC_H_
+
+#include <drm/drmP.h>
+
+struct sti_mixer;
+
+int sti_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
+		  struct drm_plane *primary, struct drm_plane *cursor);
+int sti_crtc_enable_vblank(struct drm_device *dev, int crtc);
+void sti_crtc_disable_vblank(struct drm_device *dev, int crtc);
+int sti_crtc_vblank_cb(struct notifier_block *nb,
+		       unsigned long event, void *data);
+bool sti_crtc_is_main(struct drm_crtc *drm_crtc);
+
+#endif
drivers/gpu/drm/sti/sti_cursor.c +1 -1
index cd12403..2868909 100644
@@ -8,7 +8,7 @@
 #include <drm/drmP.h>
 
 #include "sti_cursor.h"
-#include "sti_drm_plane.h"
+#include "sti_plane.h"
 #include "sti_vtg.h"
 
 /* Registers */
drivers/gpu/drm/sti/sti_drm_crtc.c deleted +0 -322

322 lines not on this page · raw message

drivers/gpu/drm/sti/sti_drm_crtc.h deleted +0 -22
deleted file mode 100644
index caca8b1..0000000
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) STMicroelectronics SA 2014
- * Author: Benjamin Gaignard <[email protected]> for STMicroelectronics.
- * License terms:  GNU General Public License (GPL), version 2
- */
-
-#ifndef _STI_DRM_CRTC_H_
-#define _STI_DRM_CRTC_H_
-
-#include <drm/drmP.h>
-
-struct sti_mixer;
-
-int sti_drm_crtc_init(struct drm_device *drm_dev, struct sti_mixer *mixer,
-		struct drm_plane *primary, struct drm_plane *cursor);
-int sti_drm_crtc_enable_vblank(struct drm_device *dev, int crtc);
-void sti_drm_crtc_disable_vblank(struct drm_device *dev, int crtc);
-int sti_drm_crtc_vblank_cb(struct notifier_block *nb,
-		unsigned long event, void *data);
-bool sti_drm_crtc_is_main(struct drm_crtc *drm_crtc);
-
-#endif
drivers/gpu/drm/sti/sti_drm_drv.c deleted +0 -294

294 lines not on this page · raw message

drivers/gpu/drm/sti/sti_drm_drv.h deleted +0 -35
deleted file mode 100644
index c413aa3..0000000
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) STMicroelectronics SA 2014
- * Author: Benjamin Gaignard <[email protected]> for STMicroelectronics.
- * License terms:  GNU General Public License (GPL), version 2
- */
-
-#ifndef _STI_DRM_DRV_H_
-#define _STI_DRM_DRV_H_
-
-#include <drm/drmP.h>
-
-struct sti_compositor;
-struct sti_tvout;
-
-/**
- * STI drm private structure
- * This structure is stored as private in the drm_device
- *
- * @compo:                 compositor
- * @plane_zorder_property: z-order property for CRTC planes
- * @drm_dev:               drm device
- */
-struct sti_drm_private {
-	struct sti_compositor *compo;
-	struct drm_property *plane_zorder_property;
-	struct drm_device *drm_dev;
-
-	struct {
-		struct drm_atomic_state *state;
-		struct work_struct work;
-		struct mutex lock;
-	} commit;
-};
-
-#endif
drivers/gpu/drm/sti/sti_drm_plane.c deleted +0 -344

344 lines not on this page · raw message

drivers/gpu/drm/sti/sti_drm_plane.h deleted +0 -105

105 lines not on this page · raw message

drivers/gpu/drm/sti/sti_drv.c new file +294 -0

294 lines not on this page · raw message

drivers/gpu/drm/sti/sti_drv.h new file +35 -0
new file mode 100644
index 0000000..9372f69
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) STMicroelectronics SA 2014
+ * Author: Benjamin Gaignard <[email protected]> for STMicroelectronics.
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#ifndef _STI_DRV_H_
+#define _STI_DRV_H_
+
+#include <drm/drmP.h>
+
+struct sti_compositor;
+struct sti_tvout;
+
+/**
+ * STI drm private structure
+ * This structure is stored as private in the drm_device
+ *
+ * @compo:                 compositor
+ * @plane_zorder_property: z-order property for CRTC planes
+ * @drm_dev:               drm device
+ */
+struct sti_private {
+	struct sti_compositor *compo;
+	struct drm_property *plane_zorder_property;
+	struct drm_device *drm_dev;
+
+	struct {
+		struct drm_atomic_state *state;
+		struct work_struct work;
+		struct mutex lock;
+	} commit;
+};
+
+#endif
drivers/gpu/drm/sti/sti_gdp.c +1 -1
index e94d0be..e323310 100644
@@ -10,8 +10,8 @@
 #include <linux/dma-mapping.h>
 
 #include "sti_compositor.h"
-#include "sti_drm_plane.h"
 #include "sti_gdp.h"
+#include "sti_plane.h"
 #include "sti_vtg.h"
 
 #define ALPHASWITCH     BIT(6)
drivers/gpu/drm/sti/sti_hqvdp.c +3 -3
index 54e8c2f..b91a009 100644
@@ -13,8 +13,8 @@
 
 #include <drm/drmP.h>
 
-#include "sti_drm_plane.h"
 #include "sti_hqvdp_lut.h"
+#include "sti_plane.h"
 #include "sti_vtg.h"
 
 /* Firmware name */
@@ -967,8 +967,8 @@ int sti_hqvdp_bind(struct device *dev, struct device *master, void *data)
 	/* Create HQVDP plane once xp70 is initialized */
 	plane = sti_hqvdp_create(hqvdp->dev, STI_HQVDP_0);
 	if (plane)
-		sti_drm_plane_init(hqvdp->drm_dev, plane, 1,
-				   DRM_PLANE_TYPE_OVERLAY);
+		sti_plane_init(hqvdp->drm_dev, plane, 1,
+			       DRM_PLANE_TYPE_OVERLAY);
 	else
 		DRM_ERROR("Can't create HQVDP plane\n");
 
drivers/gpu/drm/sti/sti_mixer.h +1 -1
index 9d51eac..2f69b00 100644
@@ -11,7 +11,7 @@
 
 #include <drm/drmP.h>
 
-#include "sti_drm_plane.h"
+#include "sti_plane.h"
 
 #define to_sti_mixer(x) container_of(x, struct sti_mixer, drm_crtc)
 
drivers/gpu/drm/sti/sti_plane.c new file +343 -0

343 lines not on this page · raw message

drivers/gpu/drm/sti/sti_plane.h new file +105 -0

105 lines not on this page · raw message

drivers/gpu/drm/sti/sti_tvout.c +4 -4
index 576b5be..c1aac8e 100644
@@ -16,7 +16,7 @@
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 
-#include "sti_drm_crtc.h"
+#include "sti_crtc.h"
 
 /* glue registers */
 #define TVO_CSC_MAIN_M0                  0x000
@@ -473,7 +473,7 @@ static void sti_dvo_encoder_commit(struct drm_encoder *encoder)
 {
 	struct sti_tvout *tvout = to_sti_tvout(encoder);
 
-	tvout_dvo_start(tvout, sti_drm_crtc_is_main(encoder->crtc));
+	tvout_dvo_start(tvout, sti_crtc_is_main(encoder->crtc));
 }
 
 static void sti_dvo_encoder_disable(struct drm_encoder *encoder)
@@ -523,7 +523,7 @@ static void sti_hda_encoder_commit(struct drm_encoder *encoder)
 {
 	struct sti_tvout *tvout = to_sti_tvout(encoder);
 
-	tvout_hda_start(tvout, sti_drm_crtc_is_main(encoder->crtc));
+	tvout_hda_start(tvout, sti_crtc_is_main(encoder->crtc));
 }
 
 static void sti_hda_encoder_disable(struct drm_encoder *encoder)
@@ -575,7 +575,7 @@ static void sti_hdmi_encoder_commit(struct drm_encoder *encoder)
 {
 	struct sti_tvout *tvout = to_sti_tvout(encoder);
 
-	tvout_hdmi_start(tvout, sti_drm_crtc_is_main(encoder->crtc));
+	tvout_hdmi_start(tvout, sti_crtc_is_main(encoder->crtc));
 }
 
 static void sti_hdmi_encoder_disable(struct drm_encoder *encoder)
drivers/gpu/drm/sti/sti_vid.c +1 -1
index b82a34f..1e7e1d7 100644
@@ -6,7 +6,7 @@
 
 #include <drm/drmP.h>
 
-#include "sti_drm_plane.h"
+#include "sti_plane.h"
 #include "sti_vid.h"
 #include "sti_vtg.h"
 
Signature · 6 lines
1.9.1

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

PATCH 4/4 drm/sti: atomic crtc/plane update

In reply to Vincent Abriou

Better fit STI hardware structure.
Planes are no more responsible of updating mixer information such as z-order and status. It is now up to the CRTC atomic flush to do it. Plane actions (enable or disable) are performed atomically. Disabling of a plane is synchronize with the vsync event.

---
 drivers/gpu/drm/sti/sti_compositor.c |  32 +--
 drivers/gpu/drm/sti/sti_crtc.c       | 120 +++++++--
 drivers/gpu/drm/sti/sti_cursor.c     | 211 +++++++++------
 drivers/gpu/drm/sti/sti_cursor.h     |   6 +-
 drivers/gpu/drm/sti/sti_gdp.c        | 493 +++++++++++++++++++----------------
 drivers/gpu/drm/sti/sti_gdp.h        |   8 +-
 drivers/gpu/drm/sti/sti_hqvdp.c      | 429 ++++++++++++++++--------------
 drivers/gpu/drm/sti/sti_mixer.h      |  10 +-
 drivers/gpu/drm/sti/sti_plane.c      | 251 +-----------------
 drivers/gpu/drm/sti/sti_plane.h      |  66 ++---
 drivers/gpu/drm/sti/sti_vid.c        |  29 ++-
 drivers/gpu/drm/sti/sti_vid.h        |   5 +-
 12 files changed, 808 insertions(+), 852 deletions(-)
drivers/gpu/drm/sti/sti_compositor.c +12 -20
index d62ed7f..c652627 100644
@@ -61,15 +61,13 @@ static int sti_compositor_bind(struct device *dev,
 {
 	struct sti_compositor *compo = dev_get_drvdata(dev);
 	struct drm_device *drm_dev = data;
-	unsigned int i, mixer_id = 0, vid_id = 0, crtc_id = 0, plane_id = 0;
+	unsigned int i, mixer_id = 0, vid_id = 0, crtc_id = 0;
 	struct sti_private *dev_priv = drm_dev->dev_private;
 	struct drm_plane *cursor = NULL;
 	struct drm_plane *primary = NULL;
 	struct sti_compositor_subdev_descriptor *desc = compo->data.subdev_desc;
 	unsigned int array_size = compo->data.nb_subdev;
 
-	struct sti_plane *plane;
-
 	dev_priv->compo = compo;
 
 	/* Register mixer subdev and video subdev first */
@@ -110,27 +108,25 @@ static int sti_compositor_bind(struct device *dev,
 			/* Nothing to do, already done at the first round */
 			break;
 		case STI_CURSOR_SUBDEV:
-			plane = sti_cursor_create(compo->dev, desc[i].id,
-						  compo->regs + desc[i].offset);
-			if (!plane) {
+			cursor = sti_cursor_create(drm_dev, compo->dev,
+						   desc[i].id,
+						   compo->regs + desc[i].offset,
+						   1);
+			if (!cursor) {
 				DRM_ERROR("Can't create CURSOR plane\n");
 				break;
 			}
-			cursor = sti_plane_init(drm_dev, plane, 1,
-						DRM_PLANE_TYPE_CURSOR);
-			plane_id++;
 			break;
 		case STI_GPD_SUBDEV:
-			plane = sti_gdp_create(compo->dev, desc[i].id,
-					       compo->regs + desc[i].offset);
-			if (!plane) {
+			primary = sti_gdp_create(drm_dev, compo->dev,
+						 desc[i].id,
+						 compo->regs + desc[i].offset,
+						 (1 << mixer_id) - 1,
+						 plane_type);
+			if (!primary) {
 				DRM_ERROR("Can't create GDP plane\n");
 				break;
 			}
-			primary = sti_plane_init(drm_dev, plane,
-						 (1 << mixer_id) - 1,
-						 plane_type);
-			plane_id++;
 			break;
 		default:
 			DRM_ERROR("Unknown subdev compoment type\n");
@@ -151,10 +147,6 @@ static int sti_compositor_bind(struct device *dev,
 	/* Allow usage of vblank without having to call drm_irq_install */
 	drm_dev->irq_enabled = 1;
 
-	DRM_DEBUG_DRIVER("Initialized %d DRM CRTC(s) and %d DRM plane(s)\n",
-			 crtc_id, plane_id);
-	DRM_DEBUG_DRIVER("DRM plane(s) for VID/VDP not created yet\n");
-
 	return 0;
 }
 
drivers/gpu/drm/sti/sti_crtc.c +97 -23

205 lines not on this page · raw message

drivers/gpu/drm/sti/sti_cursor.c +127 -84

296 lines not on this page · raw message

drivers/gpu/drm/sti/sti_cursor.h +4 -2
index db973b7..2ee5c10 100644
@@ -7,7 +7,9 @@
 #ifndef _STI_CURSOR_H_
 #define _STI_CURSOR_H_
 
-struct sti_plane *sti_cursor_create(struct device *dev, int desc,
-				    void __iomem *baseaddr);
+struct drm_plane *sti_cursor_create(struct drm_device *drm_dev,
+				    struct device *dev, int desc,
+				    void __iomem *baseaddr,
+				    unsigned int possible_crtcs);
 
 #endif
drivers/gpu/drm/sti/sti_gdp.c +274 -219

606 lines not on this page · raw message

drivers/gpu/drm/sti/sti_gdp.h +5 -3
index 01818ea..73947a4 100644
@@ -11,7 +11,9 @@
 
 #include <linux/types.h>
 
-struct sti_plane *sti_gdp_create(struct device *dev, int desc,
-				 void __iomem *baseaddr);
-
+struct drm_plane *sti_gdp_create(struct drm_device *drm_dev,
+				 struct device *dev, int desc,
+				 void __iomem *baseaddr,
+				 unsigned int possible_crtcs,
+				 enum drm_plane_type type);
 #endif
drivers/gpu/drm/sti/sti_hqvdp.c +230 -199

514 lines not on this page · raw message

drivers/gpu/drm/sti/sti_mixer.h +8 -2
index 2f69b00..4acf4f8 100644
@@ -15,6 +15,12 @@
 
 #define to_sti_mixer(x) container_of(x, struct sti_mixer, drm_crtc)
 
+enum sti_mixer_status {
+	STI_MIXER_READY,
+	STI_MIXER_DISABLING,
+	STI_MIXER_DISABLED,
+};
+
 /**
  * STI Mixer subdevice structure
  *
@@ -23,7 +29,7 @@
  * @id: id of the mixer
  * @drm_crtc: crtc object link to the mixer
  * @pending_event: set if a flip event is pending on crtc
- * @enabled: to know if the mixer is active or not
+ * @status: to know the status of the mixer
  */
 struct sti_mixer {
 	struct device *dev;
@@ -31,7 +37,7 @@ struct sti_mixer {
 	int id;
 	struct drm_crtc drm_crtc;
 	struct drm_pending_vblank_event *pending_event;
-	bool enabled;
+	enum sti_mixer_status status;
 };
 
 const char *sti_mixer_to_str(struct sti_mixer *mixer);
drivers/gpu/drm/sti/sti_plane.c +14 -237

285 lines not on this page · raw message

drivers/gpu/drm/sti/sti_plane.h +16 -50

90 lines not on this page · raw message

drivers/gpu/drm/sti/sti_vid.c +18 -11
index 1e7e1d7..a8254cc 100644
@@ -43,28 +43,37 @@
 #define VID_MPR2_BT709          0x07150545
 #define VID_MPR3_BT709          0x00000AE8
 
-int sti_vid_commit(struct sti_vid *vid, struct sti_plane *plane)
+void sti_vid_commit(struct sti_vid *vid,
+		    struct drm_plane_state *state)
 {
-	struct drm_display_mode *mode = plane->mode;
+	struct drm_crtc *crtc = state->crtc;
+	struct drm_display_mode *mode = &crtc->mode;
+	int dst_x = state->crtc_x;
+	int dst_y = state->crtc_y;
+	int dst_w = clamp_val(state->crtc_w, 0, mode->crtc_hdisplay - dst_x);
+	int dst_h = clamp_val(state->crtc_h, 0, mode->crtc_vdisplay - dst_y);
 	u32 val, ydo, xdo, yds, xds;
 
+	/* Input / output size
+	 * Align to upper even value */
+	dst_w = ALIGN(dst_w, 2);
+	dst_h = ALIGN(dst_h, 2);
+
 	/* Unmask */
 	val = readl(vid->regs + VID_CTL);
 	val &= ~VID_CTL_IGNORE;
 	writel(val, vid->regs + VID_CTL);
 
-	ydo = sti_vtg_get_line_number(*mode, plane->dst_y);
-	yds = sti_vtg_get_line_number(*mode, plane->dst_y + plane->dst_h - 1);
-	xdo = sti_vtg_get_pixel_number(*mode, plane->dst_x);
-	xds = sti_vtg_get_pixel_number(*mode, plane->dst_x + plane->dst_w - 1);
+	ydo = sti_vtg_get_line_number(*mode, dst_y);
+	yds = sti_vtg_get_line_number(*mode, dst_y + dst_h - 1);
+	xdo = sti_vtg_get_pixel_number(*mode, dst_x);
+	xds = sti_vtg_get_pixel_number(*mode, dst_x + dst_w - 1);
 
 	writel((ydo << 16) | xdo, vid->regs + VID_VPO);
 	writel((yds << 16) | xds, vid->regs + VID_VPS);
-
-	return 0;
 }
 
-int sti_vid_disable(struct sti_vid *vid)
+void sti_vid_disable(struct sti_vid *vid)
 {
 	u32 val;
 
@@ -72,8 +81,6 @@ int sti_vid_disable(struct sti_vid *vid)
 	val = readl(vid->regs + VID_CTL);
 	val |= VID_CTL_IGNORE;
 	writel(val, vid->regs + VID_CTL);
-
-	return 0;
 }
 
 static void sti_vid_init(struct sti_vid *vid)
drivers/gpu/drm/sti/sti_vid.h +3 -2
index cc680a2..5dea479 100644
@@ -20,8 +20,9 @@ struct sti_vid {
 	int id;
 };
 
-int sti_vid_commit(struct sti_vid *vid, struct sti_plane *plane);
-int sti_vid_disable(struct sti_vid *vid);
+void sti_vid_commit(struct sti_vid *vid,
+		    struct drm_plane_state *state);
+void sti_vid_disable(struct sti_vid *vid);
 struct sti_vid *sti_vid_create(struct device *dev, int id,
 			       void __iomem *baseaddr);
 
Signature · 6 lines
1.9.1

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

Re: [PATCH 4/4] drm/sti: atomic crtc/plane update

Hello Vincent,

Quoted 8 lines · Vincent Abriou

Better fit STI hardware structure.
Planes are no more responsible of updating mixer information such as z-order and status. It is now up to the CRTC atomic flush to do it. Plane actions (enable or disable) are performed atomically. Disabling of a plane is synchronize with the vsync event.

Quoted 15 lines
---
 drivers/gpu/drm/sti/sti_compositor.c |  32 +--
 drivers/gpu/drm/sti/sti_crtc.c       | 120 +++++++--
 drivers/gpu/drm/sti/sti_cursor.c     | 211 +++++++++------
 drivers/gpu/drm/sti/sti_cursor.h     |   6 +-
 drivers/gpu/drm/sti/sti_gdp.c        | 493 +++++++++++++++++++----------------
 drivers/gpu/drm/sti/sti_gdp.h        |   8 +-
 drivers/gpu/drm/sti/sti_hqvdp.c      | 429 ++++++++++++++++--------------
 drivers/gpu/drm/sti/sti_mixer.h      |  10 +-
 drivers/gpu/drm/sti/sti_plane.c      | 251 +-----------------
 drivers/gpu/drm/sti/sti_plane.h      |  66 ++---
 drivers/gpu/drm/sti/sti_vid.c        |  29 ++-
 drivers/gpu/drm/sti/sti_vid.h        |   5 +-
 12 files changed, 808 insertions(+), 852 deletions(-)

Just a friendly note - other drivers transitioning to atomics have done so in a more gradual manner. I believe the idea/intent was to ensure commits are simple and straightforward enough to minimise the cases of regressions/bugs.

Either way the decision is between you and the driver maintainer. Speaking of which there isn't one listed in MAINTAINERS. Is that intentional ?

Cheers,
Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw

Re: [PATCH 4/4] drm/sti: atomic crtc/plane update

Hello Emil,

This series of patches is the second step to convert sit driver to atomic, I have the first step few weeks ago.
This time we really take benefit of the atomic helpers to make match correctly code and hardware split. To give you an example, before those patches, we were calling code driving hardware planes while setting crtc hardware...

I agree that is a big change but we can to less then that to keep everything working.
We have done quite many tests with modetest and weston to be sure we do not have regressions.

Both Vincent and I should be put in MAINTAINERS file, I will do a patch for that.

Regards,
Benjamin

2015-07-31 14:22 GMT+02:00 Emil Velikov <[email protected]>:

Quoted 37 lines

Hello Vincent,

Quoted 8 lines · Vincent Abriou

Better fit STI hardware structure.
Planes are no more responsible of updating mixer information such as z-order and status. It is now up to the CRTC atomic flush to do it. Plane actions (enable or disable) are performed atomically. Disabling of a plane is synchronize with the vsync event.

Quoted 15 lines
---
 drivers/gpu/drm/sti/sti_compositor.c |  32 +--
 drivers/gpu/drm/sti/sti_crtc.c       | 120 +++++++--
 drivers/gpu/drm/sti/sti_cursor.c     | 211 +++++++++------
 drivers/gpu/drm/sti/sti_cursor.h     |   6 +-
 drivers/gpu/drm/sti/sti_gdp.c        | 493 +++++++++++++++++++----------------
 drivers/gpu/drm/sti/sti_gdp.h        |   8 +-
 drivers/gpu/drm/sti/sti_hqvdp.c      | 429 ++++++++++++++++--------------
 drivers/gpu/drm/sti/sti_mixer.h      |  10 +-
 drivers/gpu/drm/sti/sti_plane.c      | 251 +-----------------
 drivers/gpu/drm/sti/sti_plane.h      |  66 ++---
 drivers/gpu/drm/sti/sti_vid.c        |  29 ++-
 drivers/gpu/drm/sti/sti_vid.h        |   5 +-
 12 files changed, 808 insertions(+), 852 deletions(-)

Just a friendly note - other drivers transitioning to atomics have done so in a more gradual manner. I believe the idea/intent was to ensure commits are simple and straightforward enough to minimise the cases of regressions/bugs.

Either way the decision is between you and the driver maintainer. Speaking of which there isn't one listed in MAINTAINERS. Is that intentional ?

Cheers,
Emil

Signature · 11 lines
Benjamin Gaignard

Graphic Working Group

Linaro.org │ Open source software for ARM SoCs

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

Re: [PATCH 4/4] drm/sti: atomic crtc/plane update

Quoted 9 lines · Benjamin Gaignard

Hello Emil,

This series of patches is the second step to convert sit driver to atomic, I have the first step few weeks ago.
This time we really take benefit of the atomic helpers to make match correctly code and hardware split. To give you an example, before those patches, we were calling code driving hardware planes while setting crtc hardware...

Quoted 5 lines

I agree that is a big change but we can to less then that to keep everything working.
We have done quite many tests with modetest and weston to be sure we do not have regressions.

Fair enough. Just wanted to put it out on the table, as other teams (with more developers and testers) do occasionally stumble upon corner cases with atomics. I did not mean to tell you how you should do your job, but mitigate the awkward cases like the one floating around a couple of days ago.

Quoted 3 lines

Both Vincent and I should be put in MAINTAINERS file, I will do a patch for that.

Great. Now if we can convince a few others to do the same ;-)

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

#8 lore raw

Re: [PATCH 4/4] drm/sti: atomic crtc/plane update

In reply to Vincent Abriou
Quoted 2 lines · Vincent Abriou

static struct drm_crtc_helper_funcs sti_crtc_helper_funcs = {
.dpms = sti_crtc_dpms,

dpms isn't needed any more with atomic, you should use drm_atomic_helper_connector_dpms instead of drm_helper_connector_dpms.

drivers/gpu/drm/sti/sti_crtc.c static void sti_crtc_atomic_begin(struct drm_crtc *crtc) · line 244

Quoted 3 lines
drivers/gpu/drm/sti/sti_crtc.c +1 -2
-	.prepare = sti_crtc_prepare,
-	.commit = sti_crtc_commit,
+	.prepare = sti_crtc_helper_prepare,

prepare is now called .enable for clarity.

drivers/gpu/drm/sti/sti_crtc.c static void sti_crtc_atomic_begin(struct drm_crtc *crtc) · line 245

Quoted 1 line
drivers/gpu/drm/sti/sti_crtc.c +1 -0
+	.commit = sti_crtc_helper_commit,

commit and disable are redundant with atomic.

Cheers, Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel