Skip to contentSkip to conversation

drm/amdgpu: Add virtual connector and encoder macros.

PATCH In review Emily Deng 5 participants 20 messages Aug 4, 2016 – Aug 5, 2016 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Emily Deng

author
#0 lore raw

PATCH 1/13 drm/amdgpu: Add virtual connector and encoder macros.

For virtual display feature, add virtual connector and encoder macros.

---
 drivers/gpu/drm/amd/amdgpu/ObjectID.h | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/ObjectID.h +7 -0
index 0619269..b8d6667 100644
@@ -90,6 +90,7 @@
 #define ENCODER_OBJECT_ID_INTERNAL_VCE            0x24
 #define ENCODER_OBJECT_ID_INTERNAL_UNIPHY3        0x25
 #define ENCODER_OBJECT_ID_INTERNAL_AMCLK          0x27
+#define ENCODER_OBJECT_ID_VIRTUAL                 0x28
 
 #define ENCODER_OBJECT_ID_GENERAL_EXTERNAL_DVO    0xFF
 
@@ -119,6 +120,7 @@
 #define CONNECTOR_OBJECT_ID_eDP                   0x14
 #define CONNECTOR_OBJECT_ID_MXM                   0x15
 #define CONNECTOR_OBJECT_ID_LVDS_eDP              0x16
+#define CONNECTOR_OBJECT_ID_VIRTUAL               0x17
 
 /* deleted */
 
@@ -147,6 +149,7 @@
 #define GRAPH_OBJECT_ENUM_ID5                     0x05
 #define GRAPH_OBJECT_ENUM_ID6                     0x06
 #define GRAPH_OBJECT_ENUM_ID7                     0x07
+#define GRAPH_OBJECT_ENUM_VIRTUAL                 0x08
 
 /****************************************************/
 /* Graphics Object ID Bit definition                */
@@ -408,6 +411,10 @@
                                                   GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\
                                                   ENCODER_OBJECT_ID_HDMI_ANX9805 << OBJECT_ID_SHIFT)
 
+#define ENCODER_VIRTUAL_ENUM_VIRTUAL            ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\
+                                                  GRAPH_OBJECT_ENUM_VIRTUAL << ENUM_ID_SHIFT |\
+                                                  ENCODER_OBJECT_ID_VIRTUAL << OBJECT_ID_SHIFT)
+
 /****************************************************/
 /* Connector Object ID definition - Shared with BIOS */
 /****************************************************/
Signature · 6 lines
1.9.1

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

A message that is not in the archive (sent off-list or not yet received): 1470282173-2896-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 2/13 drm/amdgpu: Initialize dce_virtual_ip_funcs

For virtual display feature, first need to initialize dce_virtual_ip_funcs, which will be used when set ip blocks.

---
 drivers/gpu/drm/amd/amdgpu/Makefile         |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c |   5 +-
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c    | 308 ++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/dce_virtual.h    |  29 +++
 4 files changed, 343 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/dce_virtual.h
drivers/gpu/drm/amd/amdgpu/Makefile +2 -1
index 215f8fc..c8d4d7c 100644
@@ -64,7 +64,8 @@ amdgpu-y += \
 # add DCE block
 amdgpu-y += \
 	dce_v10_0.o \
-	dce_v11_0.o
+	dce_v11_0.o \
+	dce_virtual.o
 
 # add GFX block
 amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +4 -1
index 89cb630..e189903b 100644
@@ -335,7 +335,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set)
 	return ret;
 }
 
-static const char *encoder_names[38] = {
+static const char *encoder_names[41] = {
 	"NONE",
 	"INTERNAL_LVDS",
 	"INTERNAL_TMDS1",
@@ -374,6 +374,9 @@ static const char *encoder_names[38] = {
 	"TRAVIS",
 	"INTERNAL_VCE",
 	"INTERNAL_UNIPHY3",
+	"HDMI_ANX9805",
+	"INTERNAL_AMCLK",
+	"VIRTUAL",
 };
 
 static const char *hpd_names[6] = {
drivers/gpu/drm/amd/amdgpu/dce_virtual.c new file +308 -0

308 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/dce_virtual.h new file +29 -0
new file mode 100644
index 0000000..d205d7f
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __DCE_VIRTUAL_H__
+#define __DCE_VIRTUAL_H__
+
+extern const struct amd_ip_funcs dce_virtual_ip_funcs;
+#endif
+
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#3 lore raw

PATCH 3/13 drm/amdgpu: Initialize dce_virtual_display_funcs.

In reply to a message not in the archive

For virtual display feature, initialize dce_virtual_display_funcs, which will be used in function dce_virtual_set_display_funcs.

---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 222 +++++++++++++++++++++++++++++--
 1 file changed, 208 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +208 -14
index 953ee1a..2da8847 100644
@@ -34,6 +34,97 @@
 static void dce_virtual_set_display_funcs(struct amdgpu_device *adev);
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev);
 
+/**
+ * dce_virtual_vblank_wait - vblank wait asic callback.
+ *
+ * @adev: amdgpu_device pointer
+ * @crtc: crtc to wait for vblank on
+ *
+ * Wait for vblank on the requested crtc (evergreen+).
+ */
+static void dce_virtual_vblank_wait(struct amdgpu_device *adev, int crtc)
+{
+	return;
+}
+
+static u32 dce_virtual_vblank_get_counter(struct amdgpu_device *adev, int crtc)
+{
+	if (crtc >= adev->mode_info.num_crtc)
+		return 0;
+	else
+		return adev->ddev->vblank[crtc].count;
+}
+
+static void dce_virtual_page_flip(struct amdgpu_device *adev,
+			      int crtc_id, u64 crtc_base, bool async)
+{
+	return;
+}
+
+static int dce_virtual_crtc_get_scanoutpos(struct amdgpu_device *adev, int crtc,
+					u32 *vbl, u32 *position)
+{
+	if ((crtc < 0) || (crtc >= adev->mode_info.num_crtc))
+		return -EINVAL;
+
+	*vbl = 0;
+	*position = 0;
+
+	return 0;
+}
+
+static bool dce_virtual_hpd_sense(struct amdgpu_device *adev,
+			       enum amdgpu_hpd_id hpd)
+{
+	return true;
+}
+
+static void dce_virtual_hpd_set_polarity(struct amdgpu_device *adev,
+				      enum amdgpu_hpd_id hpd)
+{
+	return;
+}
+
+static u32 dce_virtual_hpd_get_gpio_reg(struct amdgpu_device *adev)
+{
+	return 0;
+}
+
+static bool dce_virtual_is_display_hung(struct amdgpu_device *adev)
+{
+	return false;
+}
+
+void dce_virtual_stop_mc_access(struct amdgpu_device *adev,
+			      struct amdgpu_mode_mc_save *save)
+{
+	return;
+}
+void dce_virtual_resume_mc_access(struct amdgpu_device *adev,
+				struct amdgpu_mode_mc_save *save)
+{
+	return;
+}
+
+void dce_virtual_set_vga_render_state(struct amdgpu_device *adev,
+				    bool render)
+{
+	return;
+}
+
+/**
+ * dce_virtual_bandwidth_update - program display watermarks
+ *
+ * @adev: amdgpu_device pointer
+ *
+ * Calculate and program the display watermarks and line
+ * buffer allocation (CIK).
+ */
+static void dce_virtual_bandwidth_update(struct amdgpu_device *adev)
+{
+	return;
+}
+
 static const struct drm_crtc_funcs dce_virtual_crtc_funcs = {
 	.cursor_set2 = NULL,
 	.cursor_move = NULL,
@@ -253,23 +344,127 @@ const struct amd_ip_funcs dce_virtual_ip_funcs = {
 	.set_powergating_state = dce_virtual_set_powergating_state,
 };
 
+/* these are handled by the primary encoders */
+static void dce_virtual_encoder_prepare(struct drm_encoder *encoder)
+{
+	return;
+}
+
+static void dce_virtual_encoder_commit(struct drm_encoder *encoder)
+{
+	return;
+}
+
+static void
+dce_virtual_encoder_mode_set(struct drm_encoder *encoder,
+		      struct drm_display_mode *mode,
+		      struct drm_display_mode *adjusted_mode)
+{
+	return;
+}
+
+static void dce_virtual_encoder_disable(struct drm_encoder *encoder)
+{
+	return;
+}
+
+static void
+dce_virtual_encoder_dpms(struct drm_encoder *encoder, int mode)
+{
+	return;
+}
+
+static bool dce_virtual_encoder_mode_fixup(struct drm_encoder *encoder,
+				    const struct drm_display_mode *mode,
+				    struct drm_display_mode *adjusted_mode)
+{
+
+	/* set the active encoder to connector routing */
+	amdgpu_encoder_set_active_device(encoder);
+
+	return true;
+}
+
+static const struct drm_encoder_helper_funcs dce_virtual_encoder_helper_funcs = {
+	.dpms = dce_virtual_encoder_dpms,
+	.mode_fixup = dce_virtual_encoder_mode_fixup,
+	.prepare = dce_virtual_encoder_prepare,
+	.mode_set = dce_virtual_encoder_mode_set,
+	.commit = dce_virtual_encoder_commit,
+	.disable = dce_virtual_encoder_disable,
+};
+
+static void dce_virtual_encoder_destroy(struct drm_encoder *encoder)
+{
+	struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
+
+	kfree(amdgpu_encoder->enc_priv);
+	drm_encoder_cleanup(encoder);
+	kfree(amdgpu_encoder);
+}
+
+static const struct drm_encoder_funcs dce_virtual_encoder_funcs = {
+	.destroy = dce_virtual_encoder_destroy,
+};
+
+static void dce_virtual_encoder_add(struct amdgpu_device *adev,
+				 uint32_t encoder_enum,
+				 uint32_t supported_device,
+				 u16 caps)
+{
+	struct drm_device *dev = adev->ddev;
+	struct drm_encoder *encoder;
+	struct amdgpu_encoder *amdgpu_encoder;
+
+	/* see if we already added it */
+	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+		amdgpu_encoder = to_amdgpu_encoder(encoder);
+		if (amdgpu_encoder->encoder_enum == encoder_enum) {
+			amdgpu_encoder->devices |= supported_device;
+			return;
+		}
+
+	}
+
+	/* add a new one */
+	amdgpu_encoder = kzalloc(sizeof(struct amdgpu_encoder), GFP_KERNEL);
+	if (!amdgpu_encoder)
+		return;
+
+	encoder = &amdgpu_encoder->base;
+	encoder->possible_crtcs = 0x1;
+	amdgpu_encoder->enc_priv = NULL;
+	amdgpu_encoder->encoder_enum = encoder_enum;
+	amdgpu_encoder->encoder_id = (encoder_enum & OBJECT_ID_MASK) >> OBJECT_ID_SHIFT;
+	amdgpu_encoder->devices = supported_device;
+	amdgpu_encoder->rmx_type = RMX_OFF;
+	amdgpu_encoder->underscan_type = UNDERSCAN_OFF;
+	amdgpu_encoder->is_ext_encoder = false;
+	amdgpu_encoder->caps = caps;
+
+	drm_encoder_init(dev, encoder, &dce_virtual_encoder_funcs,
+					 DRM_MODE_ENCODER_VIRTUAL, NULL);
+	drm_encoder_helper_add(encoder, &dce_virtual_encoder_helper_funcs);
+	DRM_INFO("[FM]encoder: %d is VIRTUAL\n", amdgpu_encoder->encoder_id);
+}
+
 static const struct amdgpu_display_funcs dce_virtual_display_funcs = {
-	.set_vga_render_state = NULL,
-	.bandwidth_update = NULL,
-	.vblank_get_counter = NULL,
-	.vblank_wait = NULL,
-	.is_display_hung = NULL,
+	.set_vga_render_state = &dce_virtual_set_vga_render_state,
+	.bandwidth_update = &dce_virtual_bandwidth_update,
+	.vblank_get_counter = &dce_virtual_vblank_get_counter,
+	.vblank_wait = &dce_virtual_vblank_wait,
+	.is_display_hung = &dce_virtual_is_display_hung,
 	.backlight_set_level = NULL,
 	.backlight_get_level = NULL,
-	.hpd_sense = NULL,
-	.hpd_set_polarity = NULL,
-	.hpd_get_gpio_reg = NULL,
-	.page_flip = NULL,
-	.page_flip_get_scanoutpos = NULL,
-	.add_encoder = NULL,
+	.hpd_sense = &dce_virtual_hpd_sense,
+	.hpd_set_polarity = &dce_virtual_hpd_set_polarity,
+	.hpd_get_gpio_reg = &dce_virtual_hpd_get_gpio_reg,
+	.page_flip = &dce_virtual_page_flip,
+	.page_flip_get_scanoutpos = &dce_virtual_crtc_get_scanoutpos,
+	.add_encoder = &dce_virtual_encoder_add,
 	.add_connector = &amdgpu_connector_add,
-	.stop_mc_access = NULL,
-	.resume_mc_access = NULL,
+	.stop_mc_access = &dce_virtual_stop_mc_access,
+	.resume_mc_access = &dce_virtual_resume_mc_access,
 };
 
 static void dce_virtual_set_display_funcs(struct amdgpu_device *adev)
@@ -305,4 +500,3 @@ static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
 	adev->hpd_irq.funcs = &dce_virtual_hpd_irq_funcs;
 }
 
-
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#4 lore raw

PATCH 4/13 drm/amdgpu: Initialize crtc, pageflip irq funcs

In reply to a message not in the archive

For virtual display feature, initialize dce_virtual_crtc_irq_funcs, dce_virtual_pageflip_irq_funcs. As it has no dce engine, so the pageflip interrupt won't be generated, and the vsync interrupt will be generated by smu's periodic timer or software timer which will be implemented later.

---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 130 ++++++++++++++++++++++++++++---
 1 file changed, 118 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +118 -12
index 2da8847..704806f 100644
@@ -473,19 +473,128 @@ static void dce_virtual_set_display_funcs(struct amdgpu_device *adev)
 		adev->mode_info.funcs = &dce_virtual_display_funcs;
 }
 
+static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *adev,
+                                                    int crtc,
+                                                    enum amdgpu_interrupt_state state)
+{
+	if (crtc >= adev->mode_info.num_crtc) {
+		DRM_DEBUG("invalid crtc %d\n", crtc);
+		return;
+	}
+}
+
+static int dce_virtual_set_crtc_irq_state(struct amdgpu_device *adev,
+                                       struct amdgpu_irq_src *source,
+                                       unsigned type,
+                                       enum amdgpu_interrupt_state state)
+{
+	switch (type) {
+	case AMDGPU_CRTC_IRQ_VBLANK1:
+		dce_virtual_set_crtc_vblank_interrupt_state(adev, 0, state);
+		break;
+	default:
+		break;
+	}
+	return 0;
+}
+
+static void dce_virtual_crtc_vblank_int_ack(struct amdgpu_device *adev,
+					  int crtc)
+{
+	if (crtc >= adev->mode_info.num_crtc) {
+		DRM_DEBUG("invalid crtc %d\n", crtc);
+		return;
+	}
+}
+
+static int dce_virtual_crtc_irq(struct amdgpu_device *adev,
+                             struct amdgpu_irq_src *source,
+                             struct amdgpu_iv_entry *entry)
+{
+	unsigned crtc = 0;
+	unsigned irq_type = AMDGPU_CRTC_IRQ_VBLANK1;
+
+	adev->ddev->vblank[crtc].count++;
+	dce_virtual_crtc_vblank_int_ack(adev, crtc);
+
+	if (amdgpu_irq_enabled(adev, source, irq_type)) {
+		drm_handle_vblank(adev->ddev, crtc);
+	}
+
+	DRM_DEBUG("IH: D%d vblank\n", crtc + 1);
+	return 0;
+}
+
+static int dce_virtual_set_pageflip_irq_state(struct amdgpu_device *adev,
+					    struct amdgpu_irq_src *src,
+					    unsigned type,
+					    enum amdgpu_interrupt_state state)
+{
+	if (type >= adev->mode_info.num_crtc) {
+		DRM_ERROR("invalid pageflip crtc %d\n", type);
+		return -EINVAL;
+	}
+	DRM_DEBUG("[FM]set pageflip irq type %d state %d\n", type, state);
+
+	return 0;
+}
+
+static int dce_virtual_pageflip_irq(struct amdgpu_device *adev,
+				  struct amdgpu_irq_src *source,
+				  struct amdgpu_iv_entry *entry)
+{
+	unsigned long flags;
+	unsigned crtc_id = 0;
+	struct amdgpu_crtc *amdgpu_crtc;
+	struct amdgpu_flip_work *works;
+
+	crtc_id = 0;
+	amdgpu_crtc = adev->mode_info.crtcs[crtc_id];
+
+	if (crtc_id >= adev->mode_info.num_crtc) {
+		DRM_ERROR("invalid pageflip crtc %d\n", crtc_id);
+		return -EINVAL;
+	}
+
+	/* IRQ could occur when in initial stage */
+	if (amdgpu_crtc == NULL)
+		return 0;
+
+	spin_lock_irqsave(&adev->ddev->event_lock, flags);
+	works = amdgpu_crtc->pflip_works;
+	if (amdgpu_crtc->pflip_status != AMDGPU_FLIP_SUBMITTED) {
+		DRM_DEBUG_DRIVER("amdgpu_crtc->pflip_status = %d != "
+			"AMDGPU_FLIP_SUBMITTED(%d)\n",
+			amdgpu_crtc->pflip_status,
+			AMDGPU_FLIP_SUBMITTED);
+		spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
+		return 0;
+	}
+
+	/* page flip completed. clean up */
+	amdgpu_crtc->pflip_status = AMDGPU_FLIP_NONE;
+	amdgpu_crtc->pflip_works = NULL;
+
+	/* wakeup usersapce */
+	if (works->event)
+		drm_send_vblank_event(adev->ddev, crtc_id, works->event);
+
+	spin_unlock_irqrestore(&adev->ddev->event_lock, flags);
+
+	drm_vblank_put(adev->ddev, amdgpu_crtc->crtc_id);
+	schedule_work(&works->unpin_work);
+
+	return 0;
+}
+
 static const struct amdgpu_irq_src_funcs dce_virtual_crtc_irq_funcs = {
-	.set = NULL,
-	.process = NULL,
+	.set = dce_virtual_set_crtc_irq_state,
+	.process = dce_virtual_crtc_irq,
 };
 
 static const struct amdgpu_irq_src_funcs dce_virtual_pageflip_irq_funcs = {
-	.set = NULL,
-	.process = NULL,
-};
-
-static const struct amdgpu_irq_src_funcs dce_virtual_hpd_irq_funcs = {
-	.set = NULL,
-	.process = NULL,
+	.set = dce_virtual_set_pageflip_irq_state,
+	.process = dce_virtual_pageflip_irq,
 };
 
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
@@ -495,8 +604,5 @@ static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev)
 
 	adev->pageflip_irq.num_types = AMDGPU_PAGEFLIP_IRQ_LAST;
 	adev->pageflip_irq.funcs = &dce_virtual_pageflip_irq_funcs;
-
-	adev->hpd_irq.num_types = AMDGPU_HPD_LAST;
-	adev->hpd_irq.funcs = &dce_virtual_hpd_irq_funcs;
 }
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#5 lore raw

PATCH 5/13 drm/amdgpu: Initialize dce_virtual_crtc_helper_funcs

In reply to a message not in the archive

For virtual display feature, initialize dce_virtual_crtc_helper_funcs.

---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 137 +++++++++++++++++++++++++++++--
 1 file changed, 128 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +128 -9
index 704806f..6b9f645 100644
@@ -134,16 +134,135 @@ static const struct drm_crtc_funcs dce_virtual_crtc_funcs = {
 	.page_flip = NULL,
 };
 
+static void dce_virtual_crtc_dpms(struct drm_crtc *crtc, int mode)
+{
+	struct drm_device *dev = crtc->dev;
+	struct amdgpu_device *adev = dev->dev_private;
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+	unsigned type;
+
+	switch (mode) {
+	case DRM_MODE_DPMS_ON:
+		amdgpu_crtc->enabled = true;
+		/* Make sure VBLANK and PFLIP interrupts are still enabled */
+		type = amdgpu_crtc_idx_to_irq_type(adev, amdgpu_crtc->crtc_id);
+		amdgpu_irq_update(adev, &adev->crtc_irq, type);
+		amdgpu_irq_update(adev, &adev->pageflip_irq, type);
+		drm_vblank_on(dev, amdgpu_crtc->crtc_id);
+		break;
+	case DRM_MODE_DPMS_STANDBY:
+	case DRM_MODE_DPMS_SUSPEND:
+	case DRM_MODE_DPMS_OFF:
+		drm_vblank_off(dev, amdgpu_crtc->crtc_id);
+		amdgpu_crtc->enabled = false;
+		break;
+	}
+}
+
+
+static void dce_virtual_crtc_prepare(struct drm_crtc *crtc)
+{
+	dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
+}
+
+static void dce_virtual_crtc_commit(struct drm_crtc *crtc)
+{
+	dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
+}
+
+static void dce_virtual_crtc_disable(struct drm_crtc *crtc)
+{
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+
+	dce_virtual_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
+	if (crtc->primary->fb) {
+		int r;
+		struct amdgpu_framebuffer *amdgpu_fb;
+		struct amdgpu_bo *rbo;
+
+		amdgpu_fb = to_amdgpu_framebuffer(crtc->primary->fb);
+		rbo = gem_to_amdgpu_bo(amdgpu_fb->obj);
+		r = amdgpu_bo_reserve(rbo, false);
+		if (unlikely(r))
+			DRM_ERROR("failed to reserve rbo before unpin\n");
+		else {
+			amdgpu_bo_unpin(rbo);
+			amdgpu_bo_unreserve(rbo);
+		}
+	}
+
+	amdgpu_crtc->pll_id = ATOM_PPLL_INVALID;
+	amdgpu_crtc->encoder = NULL;
+	amdgpu_crtc->connector = NULL;
+}
+
+static int dce_virtual_crtc_mode_set(struct drm_crtc *crtc,
+				  struct drm_display_mode *mode,
+				  struct drm_display_mode *adjusted_mode,
+				  int x, int y, struct drm_framebuffer *old_fb)
+{
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+
+	/* update the hw version fpr dpm */
+	amdgpu_crtc->hw_mode = *adjusted_mode;
+
+	return 0;
+}
+
+static bool dce_virtual_crtc_mode_fixup(struct drm_crtc *crtc,
+				     const struct drm_display_mode *mode,
+				     struct drm_display_mode *adjusted_mode)
+{
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+	struct drm_device *dev = crtc->dev;
+	struct drm_encoder *encoder;
+
+	/* assign the encoder to the amdgpu crtc to avoid repeated lookups later */
+	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
+		if (encoder->crtc == crtc) {
+			amdgpu_crtc->encoder = encoder;
+			amdgpu_crtc->connector = amdgpu_get_connector_for_encoder(encoder);
+			break;
+		}
+	}
+	if ((amdgpu_crtc->encoder == NULL) || (amdgpu_crtc->connector == NULL)) {
+		amdgpu_crtc->encoder = NULL;
+		amdgpu_crtc->connector = NULL;
+		return false;
+	}
+
+	return true;
+}
+
+
+static int dce_virtual_crtc_set_base(struct drm_crtc *crtc, int x, int y,
+				  struct drm_framebuffer *old_fb)
+{
+	return 0;
+}
+
+static void dce_virtual_crtc_load_lut(struct drm_crtc *crtc)
+{
+	return;
+}
+
+static int dce_virtual_crtc_set_base_atomic(struct drm_crtc *crtc,
+					 struct drm_framebuffer *fb,
+					 int x, int y, enum mode_set_atomic state)
+{
+	return 0;
+}
+
 static const struct drm_crtc_helper_funcs dce_virtual_crtc_helper_funcs = {
-	.dpms = NULL,
-	.mode_fixup = NULL,
-	.mode_set = NULL,
-	.mode_set_base = NULL,
-	.mode_set_base_atomic = NULL,
-	.prepare = NULL,
-	.commit = NULL,
-	.load_lut = NULL,
-	.disable = NULL,
+	.dpms = dce_virtual_crtc_dpms,
+	.mode_fixup = dce_virtual_crtc_mode_fixup,
+	.mode_set = dce_virtual_crtc_mode_set,
+	.mode_set_base = dce_virtual_crtc_set_base,
+	.mode_set_base_atomic = dce_virtual_crtc_set_base_atomic,
+	.prepare = dce_virtual_crtc_prepare,
+	.commit = dce_virtual_crtc_commit,
+	.load_lut = dce_virtual_crtc_load_lut,
+	.disable = dce_virtual_crtc_disable,
 };
 
 static int dce_virtual_crtc_init(struct amdgpu_device *adev, int index)
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#6 lore raw

PATCH 6/13 drm/amdgpu: Initialize dce_virtual_crtc_funcs.

In reply to a message not in the archive

For virtual display feature, initialize dce_virtual_crtc_funcs.

---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +26 -4
index 6b9f645..b77c85e 100644
@@ -125,13 +125,35 @@ static void dce_virtual_bandwidth_update(struct amdgpu_device *adev)
 	return;
 }
 
+static void dce_virtual_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+				    u16 *blue, uint32_t start, uint32_t size)
+{
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+	int end = (start + size > 256) ? 256 : start + size, i;
+
+	/* userspace palettes are always correct as is */
+	for (i = start; i < end; i++) {
+		amdgpu_crtc->lut_r[i] = red[i] >> 6;
+		amdgpu_crtc->lut_g[i] = green[i] >> 6;
+		amdgpu_crtc->lut_b[i] = blue[i] >> 6;
+	}
+}
+
+static void dce_virtual_crtc_destroy(struct drm_crtc *crtc)
+{
+	struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
+
+	drm_crtc_cleanup(crtc);
+	kfree(amdgpu_crtc);
+}
+
 static const struct drm_crtc_funcs dce_virtual_crtc_funcs = {
 	.cursor_set2 = NULL,
 	.cursor_move = NULL,
-	.gamma_set = NULL,
-	.set_config = NULL,
-	.destroy = NULL,
-	.page_flip = NULL,
+	.gamma_set = dce_virtual_crtc_gamma_set,
+	.set_config = amdgpu_crtc_set_config,
+	.destroy = dce_virtual_crtc_destroy,
+	.page_flip = amdgpu_crtc_page_flip,
 };
 
 static void dce_virtual_crtc_dpms(struct drm_crtc *crtc, int mode)
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#7 lore raw

PATCH 7/13 drm/amdgpu: Disable VGA render and crtc when init GMC.

In reply to a message not in the archive

For virtual display feature, when the GPU has DCE engine, need to disable the VGA render and CRTC, or it will hang when initialize GMC.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h          |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 27 +++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h     |  5 +-
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c       | 75 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.h       |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c       | 83 +++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.h       |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c        | 82 +++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.h        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c     | 85 ++++++++++++++++++++++++++--
 11 files changed, 359 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index 3cafcfd..7a9e6b8 100644
@@ -2304,6 +2304,8 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 #define amdgpu_display_add_connector(adev, ci, sd, ct, ib, coi, h, r) (adev)->mode_info.funcs->add_connector((adev), (ci), (sd), (ct), (ib), (coi), (h), (r))
 #define amdgpu_display_stop_mc_access(adev, s) (adev)->mode_info.funcs->stop_mc_access((adev), (s))
 #define amdgpu_display_resume_mc_access(adev, s) (adev)->mode_info.funcs->resume_mc_access((adev), (s))
+#define amdgpu_display_disable_vga_and_crtc(adev) (adev)->mode_info.funcs->disable_vga_and_crtc((adev))
+#define amdgpu_display_resume_vga_and_crtc(adev) (adev)->mode_info.funcs->resume_vga_and_crtc((adev))
 #define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib),  (s), (d), (b))
 #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b))
 #define amdgpu_dpm_pre_set_power_state(adev) (adev)->pm.funcs->pre_set_power_state((adev))
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +27 -0
index 9831753..f9ea890 100644
@@ -259,6 +259,33 @@ static const int object_connector_convert[] = {
 	DRM_MODE_CONNECTOR_Unknown
 };
 
+bool amdgpu_atombios_has_DCE_engine_info(struct amdgpu_device *adev)
+{
+	struct amdgpu_mode_info *mode_info = &adev->mode_info;
+	struct atom_context *ctx = mode_info->atom_context;
+	int index = GetIndexIntoMasterTable(DATA, Object_Header);
+	u16 size, data_offset;
+	u8 frev, crev;
+	ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj;
+	ATOM_OBJECT_HEADER *obj_header;
+
+	if (!amdgpu_atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
+		return false;
+
+	if (crev < 2)
+		return false;
+
+	obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset);
+	path_obj = (ATOM_DISPLAY_OBJECT_PATH_TABLE *)
+	    (ctx->bios + data_offset +
+	     le16_to_cpu(obj_header->usDisplayPathTableOffset));
+
+	if (path_obj->ucNumOfDispPath)
+		return true;
+	else
+		return false;
+}
+
 bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *adev)
 {
 	struct amdgpu_mode_info *mode_info = &adev->mode_info;
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h +2 -0
index 8c2e696..8a0f770 100644
@@ -140,6 +140,8 @@ struct amdgpu_i2c_bus_rec amdgpu_atombios_lookup_i2c_gpio(struct amdgpu_device *
 							  uint8_t id);
 void amdgpu_atombios_i2c_init(struct amdgpu_device *adev);
 
+bool amdgpu_atombios_has_DCE_engine_info(struct amdgpu_device *adev);
+
 bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *adev);
 
 int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +3 -2
index a2f12b0..d7cf37c 100644
@@ -313,8 +313,8 @@ struct amdgpu_display_funcs {
 	int (*set_freesync_property)(struct drm_connector *connector,
 				     struct drm_property *property,
 				     uint64_t val);
-
-
+	void (*disable_vga_and_crtc)(struct amdgpu_device *adev);
+	void (*resume_vga_and_crtc)(struct amdgpu_device *adev);
 };
 
 struct amdgpu_framebuffer {
@@ -367,6 +367,7 @@ struct amdgpu_mode_info {
 	int			num_dig; /* number of dig blocks */
 	int			disp_priority;
 	const struct amdgpu_display_funcs *funcs;
+	struct amdgpu_mode_mc_save save;
 };
 
 #define AMDGPU_MAX_BL_LEVEL 0xFF
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +75 -0

81 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/dce_v10_0.h +2 -0
index 77a732c..48f56f3 100644
@@ -32,5 +32,7 @@ void dce_v10_0_stop_mc_access(struct amdgpu_device *adev,
 			      struct amdgpu_mode_mc_save *save);
 void dce_v10_0_resume_mc_access(struct amdgpu_device *adev,
 				struct amdgpu_mode_mc_save *save);
+void dce_virtual_v10_0_disable_vga_and_crtc(struct amdgpu_device *adev);
+void dce_virtual_v10_0_resume_vga_and_crtc(struct amdgpu_device *adev);
 bool dce_v10_0_is_display_hung(struct amdgpu_device *adev);
 #endif
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +83 -0

89 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/dce_v11_0.h +2 -0
index fa1884c..6a5e134 100644
@@ -32,5 +32,7 @@ void dce_v11_0_stop_mc_access(struct amdgpu_device *adev,
 			      struct amdgpu_mode_mc_save *save);
 void dce_v11_0_resume_mc_access(struct amdgpu_device *adev,
 				struct amdgpu_mode_mc_save *save);
+void dce_virtual_v11_0_disable_vga_and_crtc(struct amdgpu_device *adev);
+void dce_virtual_v11_0_resume_vga_and_crtc(struct amdgpu_device *adev);
 bool dce_v11_0_is_display_hung(struct amdgpu_device *adev);
 #endif
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +82 -0

88 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/dce_v8_0.h +2 -0
index 53f643c..464b564 100644
@@ -32,5 +32,7 @@ void dce_v8_0_stop_mc_access(struct amdgpu_device *adev,
 			     struct amdgpu_mode_mc_save *save);
 void dce_v8_0_resume_mc_access(struct amdgpu_device *adev,
 			       struct amdgpu_mode_mc_save *save);
+void dce_virtual_v8_0_disable_vga_and_crtc(struct amdgpu_device *adev);
+void dce_virtual_v8_0_resume_vga_and_crtc(struct amdgpu_device *adev);
 bool dce_v8_0_is_display_hung(struct amdgpu_device *adev);
 #endif
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +79 -6

115 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

A message that is not in the archive (sent off-list or not yet received): 1470282173-2896-7-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

#9 lore raw

Re: [PATCH 07/13] drm/amdgpu: Disable VGA render and crtc when init GMC.

Quoted 36 lines · Emily Deng

For virtual display feature, when the GPU has DCE engine, need to disable the VGA render and CRTC, or it will hang when initialize GMC.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h          |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c | 27 +++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h |  2 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h     |  5 +-
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.c       | 75 ++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/dce_v10_0.h       |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.c       | 83 +++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/dce_v11_0.h       |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.c        | 82 +++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/dce_v8_0.h        |  2 +
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c     | 85 ++++++++++++++++++++++++++--
 11 files changed, 359 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index 3cafcfd..7a9e6b8 100644
@@ -2304,6 +2304,8 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)
 #define amdgpu_display_add_connector(adev, ci, sd, ct, ib, coi, h, r) (adev)->mode_info.funcs->add_connector((adev), (ci), (sd), (ct), (ib), (coi), (h), (r))
 #define amdgpu_display_stop_mc_access(adev, s) (adev)->mode_info.funcs->stop_mc_access((adev), (s))
 #define amdgpu_display_resume_mc_access(adev, s) (adev)->mode_info.funcs->resume_mc_access((adev), (s))
+#define amdgpu_display_disable_vga_and_crtc(adev) (adev)->mode_info.funcs->disable_vga_and_crtc((adev))
+#define amdgpu_display_resume_vga_and_crtc(adev) (adev)->mode_info.funcs->resume_vga_and_crtc((adev))
 #define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib),  (s), (d), (b))
 #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b))
 #define amdgpu_dpm_pre_set_power_state(adev) (adev)->pm.funcs->pre_set_power_state((adev))
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +0 -0
index 9831753..f9ea890 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c static const int object_connector_convert[] = { · line 262

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +1 -0
@@ -259,6 +259,33 @@ static const int object_connector_convert[] = {
        DRM_MODE_CONNECTOR_Unknown
 };
 
+bool amdgpu_atombios_has_DCE_engine_info(struct amdgpu_device *adev)

No need to capitalize the DCE in this function name. amdgpu_atombios_has_dce_engine_info() is fine. It would also be nice to add this function in a separate commit.

Quoted 47 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c +26 -0
+{
+       struct amdgpu_mode_info *mode_info = &adev->mode_info;
+       struct atom_context *ctx = mode_info->atom_context;
+       int index = GetIndexIntoMasterTable(DATA, Object_Header);
+       u16 size, data_offset;
+       u8 frev, crev;
+       ATOM_DISPLAY_OBJECT_PATH_TABLE *path_obj;
+       ATOM_OBJECT_HEADER *obj_header;
+
+       if (!amdgpu_atom_parse_data_header(ctx, index, &size, &frev, &crev, &data_offset))
+               return false;
+
+       if (crev < 2)
+               return false;
+
+       obj_header = (ATOM_OBJECT_HEADER *) (ctx->bios + data_offset);
+       path_obj = (ATOM_DISPLAY_OBJECT_PATH_TABLE *)
+           (ctx->bios + data_offset +
+            le16_to_cpu(obj_header->usDisplayPathTableOffset));
+
+       if (path_obj->ucNumOfDispPath)
+               return true;
+       else
+               return false;
+}
+
 bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *adev)
 {
        struct amdgpu_mode_info *mode_info = &adev->mode_info;
drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.h +2 -0
index 8c2e696..8a0f770 100644
@@ -140,6 +140,8 @@ struct amdgpu_i2c_bus_rec amdgpu_atombios_lookup_i2c_gpio(struct amdgpu_device *
                                                          uint8_t id);
 void amdgpu_atombios_i2c_init(struct amdgpu_device *adev);
 
+bool amdgpu_atombios_has_DCE_engine_info(struct amdgpu_device *adev);
+
 bool amdgpu_atombios_get_connector_info_from_object_table(struct amdgpu_device *adev);
 
 int amdgpu_atombios_get_clock_info(struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +0 -0
index a2f12b0..d7cf37c 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h struct amdgpu_display_funcs { · line 317

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +2 -2
@@ -313,8 +313,8 @@ struct amdgpu_display_funcs {
        int (*set_freesync_property)(struct drm_connector *connector,
                                     struct drm_property *property,
                                     uint64_t val);
-
-
+       void (*disable_vga_and_crtc)(struct amdgpu_device *adev);
+       void (*resume_vga_and_crtc)(struct amdgpu_device *adev);

I think we can drop these.

Quoted 23 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +1 -0
 };
 
 struct amdgpu_framebuffer {
@@ -367,6 +367,7 @@ struct amdgpu_mode_info {
        int                     num_dig; /* number of dig blocks */
        int                     disp_priority;
        const struct amdgpu_display_funcs *funcs;
+       struct amdgpu_mode_mc_save save;
 };
 
 #define AMDGPU_MAX_BL_LEVEL 0xFF
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +4 -0
index e49e151..efa5605 100644
@@ -690,6 +690,81 @@ void dce_v10_0_resume_mc_access(struct amdgpu_device *adev,
        WREG32(mmVGA_RENDER_CONTROL, save->vga_render_control);
 }
 
+static int dce_virtual_v10_0_original_crtc_num(struct amdgpu_device *adev)
+{
+       int original_num_crtc = 0;
+

drivers/gpu/drm/amd/amdgpu/dce_v10_0.c void dce_v10_0_resume_mc_access(struct amdgpu_device *adev, · line 706

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +10 -0
+       switch (adev->asic_type) {
+       case CHIP_FIJI:
+       case CHIP_TONGA:
+               original_num_crtc = 6;
+               break;
+       default:
+               original_num_crtc = 0;
+       }
+       return original_num_crtc;
+}

Can you make dce_v10_0_early_init() use this function too? that way we don't duplicate the same information. Call it dce_v10_get_num_crtc() or something like that.

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +24 -0
+
+void dce_virtual_v10_0_disable_vga_and_crtc(struct amdgpu_device *adev)
+{
+       /*Disable VGA render and enabled crtc, if has DCE engine*/
+       if (amdgpu_atombios_has_DCE_engine_info(adev)) {
+               u32 tmp;
+               int crtc_enabled, i;
+               int original_num_crtc = dce_virtual_v10_0_original_crtc_num(adev);
+
+               adev->mode_info.save.vga_render_control = RREG32(mmVGA_RENDER_CONTROL);
+               adev->mode_info.save.vga_hdp_control = RREG32(mmVGA_HDP_CONTROL);
+
+               /* Disable VGA render */
+               tmp = RREG32(mmVGA_RENDER_CONTROL);
+               tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0);
+               WREG32(mmVGA_RENDER_CONTROL, tmp);
+
+               /*Disable crtc*/
+               for (i = 0; i < original_num_crtc; i++) {
+                       crtc_enabled = REG_GET_FIELD(RREG32(mmCRTC_CONTROL + crtc_offsets[i]),
+                                                                        CRTC_CONTROL, CRTC_MASTER_EN);
+                       if (crtc_enabled) {
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
+                               tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);

drivers/gpu/drm/amd/amdgpu/dce_v10_0.c void dce_v10_0_resume_mc_access(struct amdgpu_device *adev, · line 740

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +10 -0
+                               tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0);
+                               WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);
+                               adev->mode_info.save.crtc_enabled[i] = true;
+                       } else {
+                               adev->mode_info.save.crtc_enabled[i] = false;
+                       }
+               }
+       }
+}

Rename this function disable_dce() Just go ahead and disable vga and the crtcs. This function would basically turn into:
void dce_v10_0_disable_dce(adev)

{
    unsigned i;

    dce_v10_0_set_vga_render_state(adev, false);

    for (i = 0; i < dce_v10_0_get_num_crtc(adev); i++) {
                                WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
            tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);
            tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0);
            WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
            WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);
    }
}
Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +17 -0
+
+void dce_virtual_v10_0_resume_vga_and_crtc(struct amdgpu_device *adev)
+{
+       /*Restore VGA render and enabled crtc, if has DCE engine*/
+       if (amdgpu_atombios_has_DCE_engine_info(adev)) {
+               u32 tmp;
+               int i;
+               int original_num_crtc = dce_virtual_v10_0_original_crtc_num(adev);
+
+               /*Disable crtc*/
+               for (i = 0; i < original_num_crtc; i++) {
+                       if (adev->mode_info.save.crtc_enabled[i]) {
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
+                               tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);
+                               tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 1);
+                               WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);

drivers/gpu/drm/amd/amdgpu/dce_v10_0.c void dce_v10_0_resume_mc_access(struct amdgpu_device *adev, · line 767

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +10 -0
+                       }
+               }
+
+               /* Unlock vga access */
+               WREG32(mmVGA_HDP_CONTROL, adev->mode_info.save.vga_hdp_control);
+               mdelay(1);
+               WREG32(mmVGA_RENDER_CONTROL, adev->mode_info.save.vga_render_control);
+       }
+}
+

No need to restore the old state. WIth virtual dce, we generally want the display hw turned off. We can drop this function.

Quoted 337 lines
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +0 -0
 void dce_v10_0_set_vga_render_state(struct amdgpu_device *adev,
                                    bool render)
 {
drivers/gpu/drm/amd/amdgpu/dce_v10_0.h +2 -0
index 77a732c..48f56f3 100644
@@ -32,5 +32,7 @@ void dce_v10_0_stop_mc_access(struct amdgpu_device *adev,
                              struct amdgpu_mode_mc_save *save);
 void dce_v10_0_resume_mc_access(struct amdgpu_device *adev,
                                struct amdgpu_mode_mc_save *save);
+void dce_virtual_v10_0_disable_vga_and_crtc(struct amdgpu_device *adev);
+void dce_virtual_v10_0_resume_vga_and_crtc(struct amdgpu_device *adev);
 bool dce_v10_0_is_display_hung(struct amdgpu_device *adev);
 #endif
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +83 -0
index 2f08c8b..cf552ae 100644
@@ -651,6 +651,89 @@ void dce_v11_0_resume_mc_access(struct amdgpu_device *adev,
        WREG32(mmVGA_RENDER_CONTROL, save->vga_render_control);
 }
 
+static int dce_virtual_v11_0_original_crtc_num(struct amdgpu_device *adev)
+{
+       int original_num_crtc = 0;
+
+       switch (adev->asic_type) {
+       case CHIP_CARRIZO:
+               original_num_crtc = 3;
+               break;
+       case CHIP_STONEY:
+               original_num_crtc = 2;
+               break;
+       case CHIP_POLARIS10:
+               original_num_crtc = 6;
+               break;
+       case CHIP_POLARIS11:
+               original_num_crtc = 5;
+               break;
+       default:
+               original_num_crtc = 0;
+       }
+       return original_num_crtc;
+}
+
+void dce_virtual_v11_0_disable_vga_and_crtc(struct amdgpu_device *adev)
+{
+       /*Disable VGA render and enabled crtc, if has DCE engine*/
+       if (amdgpu_atombios_has_DCE_engine_info(adev)) {
+               u32 tmp;
+               int crtc_enabled, i;
+               int original_num_crtc = dce_virtual_v11_0_original_crtc_num(adev);
+
+               adev->mode_info.save.vga_render_control = RREG32(mmVGA_RENDER_CONTROL);
+               adev->mode_info.save.vga_hdp_control = RREG32(mmVGA_HDP_CONTROL);
+
+               /* Disable VGA render */
+               tmp = RREG32(mmVGA_RENDER_CONTROL);
+               tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0);
+               WREG32(mmVGA_RENDER_CONTROL, tmp);
+
+               /*Disable crtc*/
+               for (i = 0; i < original_num_crtc; i++) {
+                       crtc_enabled = REG_GET_FIELD(RREG32(mmCRTC_CONTROL + crtc_offsets[i]),
+                                                                        CRTC_CONTROL, CRTC_MASTER_EN);
+                       if (crtc_enabled) {
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
+                               tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);
+                               tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0);
+                               WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);
+                               adev->mode_info.save.crtc_enabled[i] = true;
+                       } else {
+                               adev->mode_info.save.crtc_enabled[i] = false;
+                       }
+               }
+       }
+}
+
+void dce_virtual_v11_0_resume_vga_and_crtc(struct amdgpu_device *adev)
+{
+       /*Restore VGA render and enabled crtc, if has DCE engine*/
+       if (amdgpu_atombios_has_DCE_engine_info(adev)) {
+               u32 tmp;
+               int i;
+               int original_num_crtc = dce_virtual_v11_0_original_crtc_num(adev);
+
+               /*Disable crtc*/
+               for (i = 0; i < original_num_crtc; i++) {
+                       if (adev->mode_info.save.crtc_enabled[i]) {
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
+                               tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);
+                               tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 1);
+                               WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);
+                       }
+               }
+
+               /* Unlock vga access */
+               WREG32(mmVGA_HDP_CONTROL, adev->mode_info.save.vga_hdp_control);
+               mdelay(1);
+               WREG32(mmVGA_RENDER_CONTROL, adev->mode_info.save.vga_render_control);
+       }
+}
+
 void dce_v11_0_set_vga_render_state(struct amdgpu_device *adev,
                                    bool render)
 {
drivers/gpu/drm/amd/amdgpu/dce_v11_0.h +2 -0
index fa1884c..6a5e134 100644
@@ -32,5 +32,7 @@ void dce_v11_0_stop_mc_access(struct amdgpu_device *adev,
                              struct amdgpu_mode_mc_save *save);
 void dce_v11_0_resume_mc_access(struct amdgpu_device *adev,
                                struct amdgpu_mode_mc_save *save);
+void dce_virtual_v11_0_disable_vga_and_crtc(struct amdgpu_device *adev);
+void dce_virtual_v11_0_resume_vga_and_crtc(struct amdgpu_device *adev);
 bool dce_v11_0_is_display_hung(struct amdgpu_device *adev);
 #endif
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +82 -0
index ca5fc06..da4307c 100644
@@ -582,6 +582,88 @@ void dce_v8_0_resume_mc_access(struct amdgpu_device *adev,
        WREG32(mmVGA_RENDER_CONTROL, save->vga_render_control);
 }
 
+static int dce_virtual_v8_0_original_crtc_num(struct amdgpu_device *adev)
+{
+       int original_num_crtc = 0;
+
+       switch (adev->asic_type) {
+       case CHIP_BONAIRE:
+       case CHIP_HAWAII:
+               original_num_crtc = 6;
+               break;
+       case CHIP_KAVERI:
+               original_num_crtc = 4;
+               break;
+       case CHIP_KABINI:
+       case CHIP_MULLINS:
+               original_num_crtc = 2;
+               break;
+       default:
+               original_num_crtc = 0;
+       }
+       return original_num_crtc;
+}
+
+void dce_virtual_v8_0_disable_vga_and_crtc(struct amdgpu_device *adev)
+{
+       /*Disable VGA render and enabled crtc, if has DCE engine*/
+       if (amdgpu_atombios_has_DCE_engine_info(adev)) {
+               u32 tmp;
+               int crtc_enabled, i;
+               int original_num_crtc = dce_virtual_v8_0_original_crtc_num(adev);
+
+               adev->mode_info.save.vga_render_control = RREG32(mmVGA_RENDER_CONTROL);
+               adev->mode_info.save.vga_hdp_control = RREG32(mmVGA_HDP_CONTROL);
+
+               /* Disable VGA render */
+               tmp = RREG32(mmVGA_RENDER_CONTROL);
+               tmp = REG_SET_FIELD(tmp, VGA_RENDER_CONTROL, VGA_VSTATUS_CNTL, 0);
+               WREG32(mmVGA_RENDER_CONTROL, tmp);
+
+               /*Disable crtc*/
+               for (i = 0; i < original_num_crtc; i++) {
+                       crtc_enabled = REG_GET_FIELD(RREG32(mmCRTC_CONTROL + crtc_offsets[i]),
+                                                                        CRTC_CONTROL, CRTC_MASTER_EN);
+                       if (crtc_enabled) {
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
+                               tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);
+                               tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 0);
+                               WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);
+                               adev->mode_info.save.crtc_enabled[i] = true;
+                       } else {
+                               adev->mode_info.save.crtc_enabled[i] = false;
+                       }
+               }
+       }
+}
+
+void dce_virtual_v8_0_resume_vga_and_crtc(struct amdgpu_device *adev)
+{
+       /*Restore VGA render and enabled crtc, if has DCE engine*/
+       if (amdgpu_atombios_has_DCE_engine_info(adev)) {
+               u32 tmp;
+               int i;
+               int original_num_crtc = dce_virtual_v8_0_original_crtc_num(adev);
+
+               /*Disable crtc*/
+               for (i = 0; i < original_num_crtc; i++) {
+                       if (adev->mode_info.save.crtc_enabled[i]) {
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 1);
+                               tmp = RREG32(mmCRTC_CONTROL + crtc_offsets[i]);
+                               tmp = REG_SET_FIELD(tmp, CRTC_CONTROL, CRTC_MASTER_EN, 1);
+                               WREG32(mmCRTC_CONTROL + crtc_offsets[i], tmp);
+                               WREG32(mmCRTC_UPDATE_LOCK + crtc_offsets[i], 0);
+                       }
+               }
+
+               /* Unlock vga access */
+               WREG32(mmVGA_HDP_CONTROL, adev->mode_info.save.vga_hdp_control);
+               mdelay(1);
+               WREG32(mmVGA_RENDER_CONTROL, adev->mode_info.save.vga_render_control);
+       }
+}
+
 void dce_v8_0_set_vga_render_state(struct amdgpu_device *adev,
                                   bool render)
 {
drivers/gpu/drm/amd/amdgpu/dce_v8_0.h +2 -0
index 53f643c..464b564 100644
@@ -32,5 +32,7 @@ void dce_v8_0_stop_mc_access(struct amdgpu_device *adev,
                             struct amdgpu_mode_mc_save *save);
 void dce_v8_0_resume_mc_access(struct amdgpu_device *adev,
                               struct amdgpu_mode_mc_save *save);
+void dce_virtual_v8_0_disable_vga_and_crtc(struct amdgpu_device *adev);
+void dce_virtual_v8_0_resume_vga_and_crtc(struct amdgpu_device *adev);
 bool dce_v8_0_is_display_hung(struct amdgpu_device *adev);
 #endif
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +70 -6
index b77c85e..21a2e41 100644
@@ -25,11 +25,13 @@
 #include "amdgpu_pm.h"
 #include "amdgpu_i2c.h"
 #include "atom.h"
-#include "amdgpu_atombios.h"
-#include "atombios_crtc.h"
-#include "atombios_encoders.h"
 #include "amdgpu_pll.h"
 #include "amdgpu_connectors.h"
+#ifdef CONFIG_DRM_AMDGPU_CIK
+#include "dce_v8_0.h"
+#endif
+#include "dce_v10_0.h"
+#include "dce_v11_0.h"
 
 static void dce_virtual_set_display_funcs(struct amdgpu_device *adev);
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev);
@@ -414,6 +416,7 @@ static int dce_virtual_sw_fini(void *handle)
 
        drm_mode_config_cleanup(adev->ddev);
        adev->mode_info.mode_config_initialized = false;
+       amdgpu_display_resume_vga_and_crtc(adev);
        return 0;
 }
 
@@ -589,7 +592,8 @@ static void dce_virtual_encoder_add(struct amdgpu_device *adev,
        DRM_INFO("[FM]encoder: %d is VIRTUAL\n", amdgpu_encoder->encoder_id);
 }
 
-static const struct amdgpu_display_funcs dce_virtual_display_funcs = {
+#ifdef CONFIG_DRM_AMDGPU_CIK
+static const struct amdgpu_display_funcs dce_virtual_v8_0_display_funcs = {
        .set_vga_render_state = &dce_virtual_set_vga_render_state,
        .bandwidth_update = &dce_virtual_bandwidth_update,
        .vblank_get_counter = &dce_virtual_vblank_get_counter,
@@ -606,12 +610,81 @@ static const struct amdgpu_display_funcs dce_virtual_display_funcs = {
        .add_connector = &amdgpu_connector_add,
        .stop_mc_access = &dce_virtual_stop_mc_access,
        .resume_mc_access = &dce_virtual_resume_mc_access,
+       .disable_vga_and_crtc = &dce_virtual_v8_0_disable_vga_and_crtc,
+       .resume_vga_and_crtc = &dce_virtual_v8_0_resume_vga_and_crtc,
+};
+#endif
+
+static const struct amdgpu_display_funcs dce_virtual_v10_0_display_funcs = {
+       .set_vga_render_state = &dce_virtual_set_vga_render_state,
+       .bandwidth_update = &dce_virtual_bandwidth_update,
+       .vblank_get_counter = &dce_virtual_vblank_get_counter,
+       .vblank_wait = &dce_virtual_vblank_wait,
+       .is_display_hung = &dce_virtual_is_display_hung,
+       .backlight_set_level = NULL,
+       .backlight_get_level = NULL,
+       .hpd_sense = &dce_virtual_hpd_sense,
+       .hpd_set_polarity = &dce_virtual_hpd_set_polarity,
+       .hpd_get_gpio_reg = &dce_virtual_hpd_get_gpio_reg,
+       .page_flip = &dce_virtual_page_flip,
+       .page_flip_get_scanoutpos = &dce_virtual_crtc_get_scanoutpos,
+       .add_encoder = &dce_virtual_encoder_add,
+       .add_connector = &amdgpu_connector_add,
+       .stop_mc_access = &dce_virtual_stop_mc_access,
+       .resume_mc_access = &dce_virtual_resume_mc_access,
+       .disable_vga_and_crtc = &dce_virtual_v10_0_disable_vga_and_crtc,
+       .resume_vga_and_crtc = &dce_virtual_v10_0_resume_vga_and_crtc,
+};
+
+static const struct amdgpu_display_funcs dce_virtual_v11_0_display_funcs = {
+       .set_vga_render_state = &dce_virtual_set_vga_render_state,
+       .bandwidth_update = &dce_virtual_bandwidth_update,
+       .vblank_get_counter = &dce_virtual_vblank_get_counter,
+       .vblank_wait = &dce_virtual_vblank_wait,
+       .is_display_hung = &dce_virtual_is_display_hung,
+       .backlight_set_level = NULL,
+       .backlight_get_level = NULL,
+       .hpd_sense = &dce_virtual_hpd_sense,
+       .hpd_set_polarity = &dce_virtual_hpd_set_polarity,
+       .hpd_get_gpio_reg = &dce_virtual_hpd_get_gpio_reg,
+       .page_flip = &dce_virtual_page_flip,
+       .page_flip_get_scanoutpos = &dce_virtual_crtc_get_scanoutpos,
+       .add_encoder = &dce_virtual_encoder_add,
+       .add_connector = &amdgpu_connector_add,
+       .stop_mc_access = &dce_virtual_stop_mc_access,
+       .resume_mc_access = &dce_virtual_resume_mc_access,
+       .disable_vga_and_crtc = &dce_virtual_v11_0_disable_vga_and_crtc,
+       .resume_vga_and_crtc = &dce_virtual_v11_0_resume_vga_and_crtc,
 };
 
 static void dce_virtual_set_display_funcs(struct amdgpu_device *adev)
 {
-       if (adev->mode_info.funcs == NULL)
-               adev->mode_info.funcs = &dce_virtual_display_funcs;
+       switch (adev->asic_type) {
+       case CHIP_BONAIRE:
+       case CHIP_HAWAII:
+       case CHIP_KAVERI:
+       case CHIP_KABINI:
+       case CHIP_MULLINS:
+#ifdef CONFIG_DRM_AMDGPU_CIK
+               if (adev->mode_info.funcs == NULL)
+                       adev->mode_info.funcs = &dce_virtual_v8_0_display_funcs;
+#endif
+               break;
+       case CHIP_FIJI:
+       case CHIP_TONGA:
+               if (adev->mode_info.funcs == NULL)
+                       adev->mode_info.funcs = &dce_virtual_v10_0_display_funcs;
+               break;
+       case CHIP_CARRIZO:

drivers/gpu/drm/amd/amdgpu/dce_virtual.c static const struct amdgpu_display_funcs dce_virtual_display_funcs = { · line 688

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +9 -0
+       case CHIP_STONEY:
+       case CHIP_POLARIS11:
+       case CHIP_POLARIS10:
+               if (adev->mode_info.funcs == NULL)
+                       adev->mode_info.funcs = &dce_virtual_v11_0_display_funcs;
+               break;
+       default:
+               DRM_ERROR("Usupported ASIC type: 0x%X\n", adev->asic_type);
+       }
 }

Rather than adding all of these callbacks, just add a big asic_type switch statement to the virtual mc_stop function can just call the dce8, 10, and 11 disable_dce() functions directly.

Alex

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +0 -1
 static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *adev,
--

1.9.1

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

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

author
#10 lore raw

PATCH 8/13 drm/amdgpu: Use software timer to generate vsync interrupt.

In reply to a message not in the archive

For virtual display feature, use the software timer to simulate the vsync interrupt.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h |  4 ++++
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 33 ++++++++++++++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/dce_virtual.h |  2 ++
 3 files changed, 37 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +4 -0
index d7cf37c..0c8b404 100644
@@ -42,6 +42,8 @@
 #include <linux/i2c-algo-bit.h>
 
 #include <drm/drm_dp_mst_helper.h>
+#include <linux/hrtimer.h>
+#include "amdgpu_irq.h"
 
 struct amdgpu_bo;
 struct amdgpu_device;
@@ -368,6 +370,8 @@ struct amdgpu_mode_info {
 	int			disp_priority;
 	const struct amdgpu_display_funcs *funcs;
 	struct amdgpu_mode_mc_save save;
+	struct hrtimer vblank_timer;
+	enum amdgpu_interrupt_state vsync_timer_enabled;
 };
 
 #define AMDGPU_MAX_BL_LEVEL 0xFF
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +31 -2
index 21a2e41..00d3844 100644
@@ -32,6 +32,7 @@
 #endif
 #include "dce_v10_0.h"
 #include "dce_v11_0.h"
+#include "dce_virtual.h"
 
 static void dce_virtual_set_display_funcs(struct amdgpu_device *adev);
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev);
@@ -687,16 +688,44 @@ static void dce_virtual_set_display_funcs(struct amdgpu_device *adev)
 	}
 }
 
+static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer *vblank_timer)
+{
+	struct amdgpu_mode_info *mode_info = container_of(vblank_timer, struct amdgpu_mode_info ,vblank_timer);
+	struct amdgpu_device *adev = container_of(mode_info, struct amdgpu_device ,mode_info);
+	unsigned crtc = 0;
+	adev->ddev->vblank[0].count++;
+	drm_handle_vblank(adev->ddev, crtc);
+	hrtimer_start(vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), HRTIMER_MODE_REL);
+	return HRTIMER_NORESTART;
+}
+
 static void dce_virtual_set_crtc_vblank_interrupt_state(struct amdgpu_device *adev,
-                                                    int crtc,
-                                                    enum amdgpu_interrupt_state state)
+						     int crtc,
+						     enum amdgpu_interrupt_state state)
 {
 	if (crtc >= adev->mode_info.num_crtc) {
 		DRM_DEBUG("invalid crtc %d\n", crtc);
 		return;
 	}
+
+	if (state && !adev->mode_info.vsync_timer_enabled) {
+		DRM_DEBUG("Enable software vsync timer\n");
+		hrtimer_init(&adev->mode_info.vblank_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
+		hrtimer_set_expires(&adev->mode_info.vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD));
+		adev->mode_info.vblank_timer.function = dce_virtual_vblank_timer_handle;
+		hrtimer_start(&adev->mode_info.vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), HRTIMER_MODE_REL);
+	} else if (!state && adev->mode_info.vsync_timer_enabled) {
+		DRM_DEBUG("Disable software vsync timer\n");
+		hrtimer_cancel(&adev->mode_info.vblank_timer);
+	}
+
+	if (!state || (state && !adev->mode_info.vsync_timer_enabled))
+		adev->ddev->vblank[0].count = 0;
+	adev->mode_info.vsync_timer_enabled = state;
+	DRM_DEBUG("[FM]set crtc %d vblank interrupt state %d\n", crtc, state);
 }
 
+
 static int dce_virtual_set_crtc_irq_state(struct amdgpu_device *adev,
                                        struct amdgpu_irq_src *source,
                                        unsigned type,
drivers/gpu/drm/amd/amdgpu/dce_virtual.h +2 -0
index d205d7f..e239243 100644
@@ -25,5 +25,7 @@
 #define __DCE_VIRTUAL_H__
 
 extern const struct amd_ip_funcs dce_virtual_ip_funcs;
+#define DCE_VIRTUAL_VBLANK_PERIOD 16666666
+
 #endif
 
Signature · 6 lines
1.9.1

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

PATCH 9/13 drm/amdgpu: Call pageflip irq funtion when receiced vsync interrupt.

In reply to a message not in the archive

For virtual display feature, as there is no dce engine, so no pageflip irq generated. So directly call pageflip irq funtion when received vysn interrupt.

---
 drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/dce_virtual.c +7 -3
index 00d3844..ef3c135 100644
@@ -36,6 +36,9 @@
 
 static void dce_virtual_set_display_funcs(struct amdgpu_device *adev);
 static void dce_virtual_set_irq_funcs(struct amdgpu_device *adev);
+static int dce_virtual_pageflip_irq(struct amdgpu_device *adev,
+				  struct amdgpu_irq_src *source,
+				  struct amdgpu_iv_entry *entry);
 
 /**
  * dce_virtual_vblank_wait - vblank wait asic callback.
@@ -695,6 +698,7 @@ static enum hrtimer_restart dce_virtual_vblank_timer_handle(struct hrtimer *vbla
 	unsigned crtc = 0;
 	adev->ddev->vblank[0].count++;
 	drm_handle_vblank(adev->ddev, crtc);
+	dce_virtual_pageflip_irq(adev, NULL, NULL);
 	hrtimer_start(vblank_timer, ktime_set(0, DCE_VIRTUAL_VBLANK_PERIOD), HRTIMER_MODE_REL);
 	return HRTIMER_NORESTART;
 }
@@ -751,8 +755,8 @@ static void dce_virtual_crtc_vblank_int_ack(struct amdgpu_device *adev,
 }
 
 static int dce_virtual_crtc_irq(struct amdgpu_device *adev,
-                             struct amdgpu_irq_src *source,
-                             struct amdgpu_iv_entry *entry)
+			      struct amdgpu_irq_src *source,
+			      struct amdgpu_iv_entry *entry)
 {
 	unsigned crtc = 0;
 	unsigned irq_type = AMDGPU_CRTC_IRQ_VBLANK1;
@@ -763,7 +767,7 @@ static int dce_virtual_crtc_irq(struct amdgpu_device *adev,
 	if (amdgpu_irq_enabled(adev, source, irq_type)) {
 		drm_handle_vblank(adev->ddev, crtc);
 	}
-
+	dce_virtual_pageflip_irq(adev, NULL, NULL);
 	DRM_DEBUG("IH: D%d vblank\n", crtc + 1);
 	return 0;
 }
Signature · 6 lines
1.9.1

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

PATCH 10/13 drm/amdgpu: Add DRM_MODE_CONNECTOR_VIRTUAL connector in amdgpu_connector_add.

In reply to a message not in the archive

For virtual display feature, add one connector type in amdgpu_connector_add.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 95 ++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +95 -0
index cb07da4..e40724a 100644
@@ -1504,6 +1504,86 @@ static const struct drm_connector_funcs amdgpu_connector_edp_funcs = {
 	.force = amdgpu_connector_dvi_force,
 };
 
+static struct drm_encoder *
+amdgpu_connector_virtual_encoder(struct drm_connector *connector)
+{
+	int enc_id = connector->encoder_ids[0];
+	struct drm_encoder *encoder;
+	int i;
+	for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
+		if (connector->encoder_ids[i] == 0)
+			break;
+
+		encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
+		if (!encoder)
+			continue;
+
+		if (encoder->encoder_type == DRM_MODE_ENCODER_VIRTUAL)
+			return encoder;
+	}
+
+	/* pick the first one */
+	if (enc_id)
+		return drm_encoder_find(connector->dev, enc_id);
+	return NULL;
+}
+
+static int amdgpu_connector_virtual_get_modes(struct drm_connector *connector)
+{
+	struct drm_encoder *encoder = amdgpu_connector_best_single_encoder(connector);
+
+	if (encoder) {
+		amdgpu_connector_add_common_modes(encoder, connector);
+	}
+
+	return 0;
+}
+
+static int amdgpu_connector_virtual_mode_valid(struct drm_connector *connector,
+					   struct drm_display_mode *mode)
+{
+	return MODE_OK;
+}
+
+int amdgpu_connector_virtual_dpms(struct drm_connector *connector, int mode)
+{
+	return 0;
+}
+
+static enum drm_connector_status
+
+amdgpu_connector_virtual_detect(struct drm_connector *connector, bool force)
+{
+	return connector_status_connected;
+}
+
+int amdgpu_connector_virtual_set_property(struct drm_connector *connector,
+				  struct drm_property *property,
+				  uint64_t val)
+{
+	return 0;
+}
+
+static void amdgpu_connector_virtual_force(struct drm_connector *connector)
+{
+	return;
+}
+
+static const struct drm_connector_helper_funcs amdgpu_connector_virtual_helper_funcs = {
+	.get_modes = amdgpu_connector_virtual_get_modes,
+	.mode_valid = amdgpu_connector_virtual_mode_valid,
+	.best_encoder = amdgpu_connector_virtual_encoder,
+};
+
+static const struct drm_connector_funcs amdgpu_connector_virtual_funcs = {
+	.dpms = amdgpu_connector_virtual_dpms,
+	.detect = amdgpu_connector_virtual_detect,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.set_property = amdgpu_connector_virtual_set_property,
+	.destroy = amdgpu_connector_destroy,
+	.force = amdgpu_connector_virtual_force,
+};
+
 void
 amdgpu_connector_add(struct amdgpu_device *adev,
 		      uint32_t connector_id,
@@ -1889,6 +1969,21 @@ amdgpu_connector_add(struct amdgpu_device *adev,
 			connector->interlace_allowed = false;
 			connector->doublescan_allowed = false;
 			break;
+		case DRM_MODE_CONNECTOR_VIRTUAL:
+			amdgpu_dig_connector = kzalloc(sizeof(struct amdgpu_connector_atom_dig), GFP_KERNEL);
+			if (!amdgpu_dig_connector)
+				goto failed;
+			amdgpu_connector->con_priv = amdgpu_dig_connector;
+			drm_connector_init(dev, &amdgpu_connector->base, &amdgpu_connector_virtual_funcs, connector_type);
+			drm_connector_helper_add(&amdgpu_connector->base, &amdgpu_connector_virtual_helper_funcs);
+			drm_object_attach_property(&amdgpu_connector->base.base,
+							  dev->mode_config.scaling_mode_property,
+							  DRM_MODE_SCALE_FULLSCREEN);
+			subpixel_order = SubPixelHorizontalRGB;
+			connector->interlace_allowed = false;
+			connector->doublescan_allowed = false;
+
+			break;
 		}
 	}
 
Signature · 6 lines
1.9.1

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

A message that is not in the archive (sent off-list or not yet received): 1470282173-2896-10-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

#14 lore raw

Re: [PATCH 10/13] drm/amdgpu: Add DRM_MODE_CONNECTOR_VIRTUAL connector in amdgpu_connector_add.

Quoted 102 lines · Emily Deng

For virtual display feature, add one connector type in amdgpu_connector_add.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 95 ++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +80 -0
index cb07da4..e40724a 100644
@@ -1504,6 +1504,86 @@ static const struct drm_connector_funcs amdgpu_connector_edp_funcs = {
        .force = amdgpu_connector_dvi_force,
 };
 
+static struct drm_encoder *
+amdgpu_connector_virtual_encoder(struct drm_connector *connector)
+{
+       int enc_id = connector->encoder_ids[0];
+       struct drm_encoder *encoder;
+       int i;
+       for (i = 0; i < DRM_CONNECTOR_MAX_ENCODER; i++) {
+               if (connector->encoder_ids[i] == 0)
+                       break;
+
+               encoder = drm_encoder_find(connector->dev, connector->encoder_ids[i]);
+               if (!encoder)
+                       continue;
+
+               if (encoder->encoder_type == DRM_MODE_ENCODER_VIRTUAL)
+                       return encoder;
+       }
+
+       /* pick the first one */
+       if (enc_id)
+               return drm_encoder_find(connector->dev, enc_id);
+       return NULL;
+}
+
+static int amdgpu_connector_virtual_get_modes(struct drm_connector *connector)
+{
+       struct drm_encoder *encoder = amdgpu_connector_best_single_encoder(connector);
+
+       if (encoder) {
+               amdgpu_connector_add_common_modes(encoder, connector);
+       }
+
+       return 0;
+}
+
+static int amdgpu_connector_virtual_mode_valid(struct drm_connector *connector,
+                                          struct drm_display_mode *mode)
+{
+       return MODE_OK;
+}
+
+int amdgpu_connector_virtual_dpms(struct drm_connector *connector, int mode)
+{
+       return 0;
+}
+
+static enum drm_connector_status
+
+amdgpu_connector_virtual_detect(struct drm_connector *connector, bool force)
+{
+       return connector_status_connected;
+}
+
+int amdgpu_connector_virtual_set_property(struct drm_connector *connector,
+                                 struct drm_property *property,
+                                 uint64_t val)
+{
+       return 0;
+}
+
+static void amdgpu_connector_virtual_force(struct drm_connector *connector)
+{
+       return;
+}
+
+static const struct drm_connector_helper_funcs amdgpu_connector_virtual_helper_funcs = {
+       .get_modes = amdgpu_connector_virtual_get_modes,
+       .mode_valid = amdgpu_connector_virtual_mode_valid,
+       .best_encoder = amdgpu_connector_virtual_encoder,
+};
+
+static const struct drm_connector_funcs amdgpu_connector_virtual_funcs = {
+       .dpms = amdgpu_connector_virtual_dpms,
+       .detect = amdgpu_connector_virtual_detect,
+       .fill_modes = drm_helper_probe_single_connector_modes,
+       .set_property = amdgpu_connector_virtual_set_property,
+       .destroy = amdgpu_connector_destroy,
+       .force = amdgpu_connector_virtual_force,
+};
+
 void
 amdgpu_connector_add(struct amdgpu_device *adev,
                      uint32_t connector_id,
@@ -1889,6 +1969,21 @@ amdgpu_connector_add(struct amdgpu_device *adev,
                        connector->interlace_allowed = false;
                        connector->doublescan_allowed = false;
                        break;

drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c amdgpu_connector_add(struct amdgpu_device *adev, · line 1981

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +10 -0
+               case DRM_MODE_CONNECTOR_VIRTUAL:
+                       amdgpu_dig_connector = kzalloc(sizeof(struct amdgpu_connector_atom_dig), GFP_KERNEL);
+                       if (!amdgpu_dig_connector)
+                               goto failed;
+                       amdgpu_connector->con_priv = amdgpu_dig_connector;
+                       drm_connector_init(dev, &amdgpu_connector->base, &amdgpu_connector_virtual_funcs, connector_type);
+                       drm_connector_helper_add(&amdgpu_connector->base, &amdgpu_connector_virtual_helper_funcs);
+                       drm_object_attach_property(&amdgpu_connector->base.base,
+                                                         dev->mode_config.scaling_mode_property,
+                                                         DRM_MODE_SCALE_FULLSCREEN);

No need to expose a the scaling property. Please remove it.

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +5 -1
+                       subpixel_order = SubPixelHorizontalRGB;
+                       connector->interlace_allowed = false;
+                       connector->doublescan_allowed = false;
+
+                       break;
                }
        }
 
--

1.9.1

Quoted 4 lines

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

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

author
#15 lore raw

PATCH 11/13 drm/amdgpu: Define vitual display ip blocks.

In reply to a message not in the archive

For virtual display feature, define virtual display ip blocks, and set dce_virtual_ip_funcs to DCE block.

---
 drivers/gpu/drm/amd/amdgpu/cik.c | 341 +++++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/vi.c  | 282 ++++++++++++++++++++++++++++++++
 2 files changed, 623 insertions(+)
drivers/gpu/drm/amd/amdgpu/cik.c +341 -0
index f4667f1..d0442a9 100644
@@ -68,6 +68,7 @@
 #include "amdgpu_dm.h"
 #include "amdgpu_amdkfd.h"
 #include "amdgpu_powerplay.h"
+#include "dce_virtual.h"
 
 /*
  * Indirect registers accessor
@@ -1779,6 +1780,74 @@ static const struct amdgpu_ip_block_version bonaire_ip_blocks[] =
 	},
 };
 
+static const struct amdgpu_ip_block_version bonaire_ip_blocks_vd[] =
+{
+	/* ORDER MATTERS! */
+	{
+		.type = AMD_IP_BLOCK_TYPE_COMMON,
+		.major = 1,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_common_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &gmc_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_IH,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_ih_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &amdgpu_pp_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_DCE,
+		.major = 8,
+		.minor = 2,
+		.rev = 0,
+		.funcs = &dce_virtual_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GFX,
+		.major = 7,
+		.minor = 2,
+		.rev = 0,
+		.funcs = &gfx_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SDMA,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_sdma_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_UVD,
+		.major = 4,
+		.minor = 2,
+		.rev = 0,
+		.funcs = &uvd_v4_2_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_VCE,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &vce_v2_0_ip_funcs,
+	},
+};
+
 #if defined(CONFIG_DRM_AMD_DAL_DCE8_0)
 static const struct amdgpu_ip_block_version hawaii_ip_blocks_dal[] =
 {
@@ -1917,6 +1986,74 @@ static const struct amdgpu_ip_block_version hawaii_ip_blocks[] =
 	},
 };
 
+static const struct amdgpu_ip_block_version hawaii_ip_blocks_vd[] =
+{
+	/* ORDER MATTERS! */
+	{
+		.type = AMD_IP_BLOCK_TYPE_COMMON,
+		.major = 1,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_common_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &gmc_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_IH,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_ih_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &amdgpu_pp_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_DCE,
+		.major = 8,
+		.minor = 5,
+		.rev = 0,
+		.funcs = &dce_virtual_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GFX,
+		.major = 7,
+		.minor = 3,
+		.rev = 0,
+		.funcs = &gfx_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SDMA,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_sdma_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_UVD,
+		.major = 4,
+		.minor = 2,
+		.rev = 0,
+		.funcs = &uvd_v4_2_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_VCE,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &vce_v2_0_ip_funcs,
+	},
+};
+
 static const struct amdgpu_ip_block_version kabini_ip_blocks[] =
 {
 	/* ORDER MATTERS! */
@@ -1985,6 +2122,74 @@ static const struct amdgpu_ip_block_version kabini_ip_blocks[] =
 	},
 };
 
+static const struct amdgpu_ip_block_version kabini_ip_blocks_vd[] =
+{
+	/* ORDER MATTERS! */
+	{
+		.type = AMD_IP_BLOCK_TYPE_COMMON,
+		.major = 1,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_common_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &gmc_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_IH,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_ih_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &amdgpu_pp_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_DCE,
+		.major = 8,
+		.minor = 3,
+		.rev = 0,
+		.funcs = &dce_virtual_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GFX,
+		.major = 7,
+		.minor = 2,
+		.rev = 0,
+		.funcs = &gfx_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SDMA,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_sdma_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_UVD,
+		.major = 4,
+		.minor = 2,
+		.rev = 0,
+		.funcs = &uvd_v4_2_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_VCE,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &vce_v2_0_ip_funcs,
+	},
+};
+
 static const struct amdgpu_ip_block_version mullins_ip_blocks[] =
 {
 	/* ORDER MATTERS! */
@@ -2053,6 +2258,74 @@ static const struct amdgpu_ip_block_version mullins_ip_blocks[] =
 	},
 };
 
+static const struct amdgpu_ip_block_version mullins_ip_blocks_vd[] =
+{
+	/* ORDER MATTERS! */
+	{
+		.type = AMD_IP_BLOCK_TYPE_COMMON,
+		.major = 1,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_common_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &gmc_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_IH,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_ih_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &amdgpu_pp_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_DCE,
+		.major = 8,
+		.minor = 3,
+		.rev = 0,
+		.funcs = &dce_virtual_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GFX,
+		.major = 7,
+		.minor = 2,
+		.rev = 0,
+		.funcs = &gfx_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SDMA,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_sdma_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_UVD,
+		.major = 4,
+		.minor = 2,
+		.rev = 0,
+		.funcs = &uvd_v4_2_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_VCE,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &vce_v2_0_ip_funcs,
+	},
+};
+
 static const struct amdgpu_ip_block_version kaveri_ip_blocks[] =
 {
 	/* ORDER MATTERS! */
@@ -2121,6 +2394,74 @@ static const struct amdgpu_ip_block_version kaveri_ip_blocks[] =
 	},
 };
 
+static const struct amdgpu_ip_block_version kaveri_ip_blocks_vd[] =
+{
+	/* ORDER MATTERS! */
+	{
+		.type = AMD_IP_BLOCK_TYPE_COMMON,
+		.major = 1,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_common_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &gmc_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_IH,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_ih_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SMC,
+		.major = 7,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &amdgpu_pp_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_DCE,
+		.major = 8,
+		.minor = 1,
+		.rev = 0,
+		.funcs = &dce_virtual_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_GFX,
+		.major = 7,
+		.minor = 1,
+		.rev = 0,
+		.funcs = &gfx_v7_0_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_SDMA,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &cik_sdma_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_UVD,
+		.major = 4,
+		.minor = 2,
+		.rev = 0,
+		.funcs = &uvd_v4_2_ip_funcs,
+	},
+	{
+		.type = AMD_IP_BLOCK_TYPE_VCE,
+		.major = 2,
+		.minor = 0,
+		.rev = 0,
+		.funcs = &vce_v2_0_ip_funcs,
+	},
+};
+
 int cik_set_ip_blocks(struct amdgpu_device *adev)
 {
 	switch (adev->asic_type) {
drivers/gpu/drm/amd/amdgpu/vi.c +282 -0

312 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#16 lore raw

PATCH 12/13 drm/amdgpu: Define one variable for virtual display.

In reply to a message not in the archive

For virtual display feature, define on variable in amdgpu.ko. When want to enable virtual display feature, need set the option "amdgpu.virtual_display=1". And then disable vga render and crtc if have DCE engine.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 4 ++++
 3 files changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 7a9e6b8..1ebf634 100644
@@ -93,6 +93,7 @@ extern unsigned amdgpu_pcie_lane_cap;
 extern unsigned amdgpu_cg_mask;
 extern unsigned amdgpu_pg_mask;
 extern int amdgpu_sclk_deep_sleep_en;
+extern int amdgpu_virtual_display;
 
 #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS	        3000
 #define AMDGPU_MAX_USEC_TIMEOUT			100000	/* 100 ms */
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index edbb370..2d7eb34 100644
@@ -1265,6 +1265,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
 {
 	int i, r;
 
+	if(amdgpu_virtual_display)
+		amdgpu_display_disable_vga_and_crtc(adev);
+
 	for (i = 0; i < adev->num_ip_blocks; i++) {
 		if (!adev->ip_block_status[i].valid)
 			continue;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -0
index f2af1ff..7007cf7 100644
@@ -90,6 +90,7 @@ unsigned amdgpu_pcie_gen_cap = 0;
 unsigned amdgpu_pcie_lane_cap = 0;
 unsigned amdgpu_cg_mask = 0xffffffff;
 unsigned amdgpu_pg_mask = 0xffffffff;
+int amdgpu_virtual_display = 0;
 
 MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
 module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
@@ -189,6 +190,9 @@ module_param_named(cg_mask, amdgpu_cg_mask, uint, 0444);
 MODULE_PARM_DESC(pg_mask, "Powergating flags mask (0 = disable power gating)");
 module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444);
 
+MODULE_PARM_DESC(virtual_display, "enable virtual display (0 = disable virtual display)");
+module_param_named(virtual_display, amdgpu_virtual_display, int, 0444);
+
 static const struct pci_device_id pciidlist[] = {
 #ifdef CONFIG_DRM_AMDGPU_CIK
 	/* Kaveri */
Signature · 6 lines
1.9.1

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

A message that is not in the archive (sent off-list or not yet received): 1470282173-2896-12-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

#18 lore raw

Re: [PATCH 12/13] drm/amdgpu: Define one variable for virtual display.

Quoted 28 lines · Emily Deng

For virtual display feature, define on variable in amdgpu.ko. When want to enable virtual display feature, need set the option "amdgpu.virtual_display=1". And then disable vga render and crtc if have DCE engine.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 4 ++++
 3 files changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 7a9e6b8..1ebf634 100644
@@ -93,6 +93,7 @@ extern unsigned amdgpu_pcie_lane_cap;
 extern unsigned amdgpu_cg_mask;
 extern unsigned amdgpu_pg_mask;
 extern int amdgpu_sclk_deep_sleep_en;
+extern int amdgpu_virtual_display;
 
 #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS         3000
 #define AMDGPU_MAX_USEC_TIMEOUT                        100000  /* 100 ms */
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index edbb370..2d7eb34 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_init(struct amdgpu_device *adev) · line 1270

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
@@ -1265,6 +1265,9 @@ static int amdgpu_init(struct amdgpu_device *adev)
 {
        int i, r;
 
+       if(amdgpu_virtual_display)
+               amdgpu_display_disable_vga_and_crtc(adev);
+

You can drop this if you implement the changes I proposed in the patch that adds this.

Alex

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
        for (i = 0; i < adev->num_ip_blocks; i++) {
                if (!adev->ip_block_status[i].valid)
                        continue;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -1
index f2af1ff..7007cf7 100644
@@ -90,6 +90,7 @@ unsigned amdgpu_pcie_gen_cap = 0;
 unsigned amdgpu_pcie_lane_cap = 0;
 unsigned amdgpu_cg_mask = 0xffffffff;
 unsigned amdgpu_pg_mask = 0xffffffff;
+int amdgpu_virtual_display = 0;
 
 MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
 module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
@@ -189,6 +190,9 @@ module_param_named(cg_mask, amdgpu_cg_mask, uint, 0444);
 MODULE_PARM_DESC(pg_mask, "Powergating flags mask (0 = disable power gating)");
 module_param_named(pg_mask, amdgpu_pg_mask, uint, 0444);
 
+MODULE_PARM_DESC(virtual_display, "enable virtual display (0 = disable virtual display)");
+module_param_named(virtual_display, amdgpu_virtual_display, int, 0444);
+
 static const struct pci_device_id pciidlist[] = {
 #ifdef CONFIG_DRM_AMDGPU_CIK
        /* Kaveri */
--

1.9.1

Quoted 4 lines

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

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

author
#19 lore raw

PATCH 13/13 drm/amdgpu: Set ip_blocks according variable amdgpu_virtual_display.

In reply to a message not in the archive

For virtual display feature, if user set the option "amdgpu.virtual_display=1" when load amdgpu.ko. Then need to set the ip_blocks with virtual display ip blocks. And when enable virtual display, the amdgpu_dal need to be set to zero.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   2 +
 drivers/gpu/drm/amd/amdgpu/cik.c           | 104 ++++++++++++++--------
 drivers/gpu/drm/amd/amdgpu/vi.c            | 134 ++++++++++++++++++-----------
 3 files changed, 153 insertions(+), 87 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 2d7eb34..008e6a0 100644
@@ -1186,6 +1186,8 @@ static int amdgpu_early_init(struct amdgpu_device *adev)
 {
 	int i, r;
 
+	DRM_INFO("virtual display enabled:%d\n", amdgpu_virtual_display);
+
 	switch (adev->asic_type) {
 	case CHIP_TOPAZ:
 	case CHIP_TONGA:
drivers/gpu/drm/amd/amdgpu/cik.c +67 -37

122 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/vi.c +84 -50

161 lines not on this page · raw message

Signature · 6 lines
1.9.1

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

A message that is not in the archive (sent off-list or not yet received): 1470282173-2896-13-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#21 lore raw

Re: [PATCH 13/13] drm/amdgpu: Set ip_blocks according variable amdgpu_virtual_display.

2016-08-03 23:42 GMT-04:00 Emily Deng <[email protected]>:

Quoted 5 lines

For virtual display feature, if user set the option "amdgpu.virtual_display=1" when load amdgpu.ko. Then need to set the ip_blocks with virtual display ip blocks. And when enable virtual display, the amdgpu_dal need to be set to zero.

For the old patches that were not replaced with new ones:

Quoted 315 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   2 +
 drivers/gpu/drm/amd/amdgpu/cik.c           | 104 ++++++++++++++--------
 drivers/gpu/drm/amd/amdgpu/vi.c            | 134 ++++++++++++++++++-----------
 3 files changed, 153 insertions(+), 87 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 2d7eb34..008e6a0 100644
@@ -1186,6 +1186,8 @@ static int amdgpu_early_init(struct amdgpu_device *adev)
 {
        int i, r;
 
+       DRM_INFO("virtual display enabled:%d\n", amdgpu_virtual_display);
+
        switch (adev->asic_type) {
        case CHIP_TOPAZ:
        case CHIP_TONGA:
drivers/gpu/drm/amd/amdgpu/cik.c +67 -37
index d0442a9..4b48bcd 100644
@@ -2464,55 +2464,85 @@ static const struct amdgpu_ip_block_version kaveri_ip_blocks_vd[] =
 
 int cik_set_ip_blocks(struct amdgpu_device *adev)
 {
-       switch (adev->asic_type) {
-       case CHIP_BONAIRE:
+       if (amdgpu_virtual_display) {
+               amdgpu_dal = 0;
+               adev->mode_info.vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
+               switch (adev->asic_type) {
+               case CHIP_BONAIRE:
+                       adev->ip_blocks = bonaire_ip_blocks_vd;
+                       adev->num_ip_blocks = ARRAY_SIZE(bonaire_ip_blocks_vd);
+                       break;
+               case CHIP_HAWAII:
+                       adev->ip_blocks = hawaii_ip_blocks_vd;
+                       adev->num_ip_blocks = ARRAY_SIZE(hawaii_ip_blocks_vd);
+                       break;
+               case CHIP_KAVERI:
+                       adev->ip_blocks = kaveri_ip_blocks_vd;
+                       adev->num_ip_blocks = ARRAY_SIZE(kaveri_ip_blocks_vd);
+                       break;
+               case CHIP_KABINI:
+                       adev->ip_blocks = kabini_ip_blocks_vd;
+                       adev->num_ip_blocks = ARRAY_SIZE(kabini_ip_blocks_vd);
+                       break;
+               case CHIP_MULLINS:
+                       adev->ip_blocks = mullins_ip_blocks_vd;
+                       adev->num_ip_blocks = ARRAY_SIZE(mullins_ip_blocks_vd);
+                       break;
+               default:
+                       /* FIXME: not supported yet */
+                       return -EINVAL;
+               }
+       } else {
+               switch (adev->asic_type) {
+               case CHIP_BONAIRE:
 #if defined(CONFIG_DRM_AMD_DAL_DCE8_0)
-               if (amdgpu_device_has_dal_support(adev)) {
-                       adev->ip_blocks = bonaire_ip_blocks_dal;
-                       adev->num_ip_blocks = ARRAY_SIZE(bonaire_ip_blocks_dal);
-               } else {
+                       if (amdgpu_device_has_dal_support(adev)) {
+                               adev->ip_blocks = bonaire_ip_blocks_dal;
+                               adev->num_ip_blocks = ARRAY_SIZE(bonaire_ip_blocks_dal);
+                       } else {
+                               adev->ip_blocks = bonaire_ip_blocks;
+                               adev->num_ip_blocks = ARRAY_SIZE(bonaire_ip_blocks);
+                       }
+#else
                        adev->ip_blocks = bonaire_ip_blocks;
                        adev->num_ip_blocks = ARRAY_SIZE(bonaire_ip_blocks);
-               }
-#else
-               adev->ip_blocks = bonaire_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(bonaire_ip_blocks);
 #endif
-               break;
-       case CHIP_HAWAII:
+                       break;
+               case CHIP_HAWAII:
 #if defined(CONFIG_DRM_AMD_DAL_DCE8_0)
-               if (amdgpu_device_has_dal_support(adev)) {
-                       adev->ip_blocks = hawaii_ip_blocks_dal;
-                       adev->num_ip_blocks = ARRAY_SIZE(hawaii_ip_blocks_dal);
-               } else {
+                       if (amdgpu_device_has_dal_support(adev)) {
+                               adev->ip_blocks = hawaii_ip_blocks_dal;
+                               adev->num_ip_blocks = ARRAY_SIZE(hawaii_ip_blocks_dal);
+                       } else {
+                               adev->ip_blocks = hawaii_ip_blocks;
+                               adev->num_ip_blocks = ARRAY_SIZE(hawaii_ip_blocks);
+                       }
+#else
                        adev->ip_blocks = hawaii_ip_blocks;
                        adev->num_ip_blocks = ARRAY_SIZE(hawaii_ip_blocks);
-               }
-#else
-               adev->ip_blocks = hawaii_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(hawaii_ip_blocks);
 #endif
-               break;
-       case CHIP_KAVERI:
-               adev->ip_blocks = kaveri_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(kaveri_ip_blocks);
-               break;
-       case CHIP_KABINI:
-               adev->ip_blocks = kabini_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(kabini_ip_blocks);
-               break;
-       case CHIP_MULLINS:
-               adev->ip_blocks = mullins_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(mullins_ip_blocks);
-               break;
-       default:
-               /* FIXME: not supported yet */
-               return -EINVAL;
+                       break;
+               case CHIP_KAVERI:
+                       adev->ip_blocks = kaveri_ip_blocks;
+                       adev->num_ip_blocks = ARRAY_SIZE(kaveri_ip_blocks);
+                       break;
+               case CHIP_KABINI:
+                       adev->ip_blocks = kabini_ip_blocks;
+                       adev->num_ip_blocks = ARRAY_SIZE(kabini_ip_blocks);
+                       break;
+               case CHIP_MULLINS:
+                       adev->ip_blocks = mullins_ip_blocks;
+                       adev->num_ip_blocks = ARRAY_SIZE(mullins_ip_blocks);
+                       break;
+               default:
+                       /* FIXME: not supported yet */
+                       return -EINVAL;
+               }
        }
-
        return 0;
 }
 
+
 static const struct amdgpu_asic_funcs cik_asic_funcs =
 {
        .read_disabled_bios = &cik_read_disabled_bios,
drivers/gpu/drm/amd/amdgpu/vi.c +84 -51
index eecc92f..432a01c 100644
@@ -1676,77 +1676,111 @@ static const struct amdgpu_ip_block_version fiji_ip_blocks_dal[] =
 
 int vi_set_ip_blocks(struct amdgpu_device *adev)
 {
-       switch (adev->asic_type) {
-       case CHIP_TOPAZ:
-               adev->ip_blocks = topaz_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks);
-               break;
-       case CHIP_FIJI:
+       if (amdgpu_virtual_display) {
+               amdgpu_dal = 0;
+               adev->mode_info.vsync_timer_enabled = AMDGPU_IRQ_STATE_DISABLE;
+               switch (adev->asic_type) {
+               case CHIP_TOPAZ:
+                       adev->ip_blocks = topaz_ip_blocks;
+                       adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks);
+                       break;
+               case CHIP_FIJI:
+                       adev->ip_blocks = fiji_ip_blocks_vd;
+                       adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks_vd);
+                       break;
+               case CHIP_TONGA:
+                       adev->ip_blocks = tonga_ip_blocks_vd;
+                       adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks_vd);
+                       break;
+               case CHIP_POLARIS11:
+               case CHIP_POLARIS10:
+                       adev->ip_blocks = polaris11_ip_blocks_vd;
+                       adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks_vd);
+                       break;
+
+               case CHIP_CARRIZO:
+               case CHIP_STONEY:
+                       adev->ip_blocks = cz_ip_blocks_vd;
+                       adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks_vd);
+                       break;
+               default:
+                       /* FIXME: not supported yet */
+                       return -EINVAL;
+               }
+       } else {
+               switch (adev->asic_type) {
+               case CHIP_TOPAZ:
+                       adev->ip_blocks = topaz_ip_blocks;
+                       adev->num_ip_blocks = ARRAY_SIZE(topaz_ip_blocks);
+                       break;
+               case CHIP_FIJI:
 #if defined(CONFIG_DRM_AMD_DAL)
-               if (amdgpu_device_has_dal_support(adev)) {
-                       adev->ip_blocks = fiji_ip_blocks_dal;
-                       adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks_dal);
-               } else {
+                       if (amdgpu_device_has_dal_support(adev)) {
+                               adev->ip_blocks = fiji_ip_blocks_dal;
+                               adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks_dal);
+                       } else {
+                               adev->ip_blocks = fiji_ip_blocks;
+                               adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks);
+                       }
+#else
                        adev->ip_blocks = fiji_ip_blocks;
                        adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks);
-               }
-#else
-               adev->ip_blocks = fiji_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(fiji_ip_blocks);
 #endif
-               break;
-       case CHIP_TONGA:
+                       break;
+               case CHIP_TONGA:
 #if defined(CONFIG_DRM_AMD_DAL)
-               if (amdgpu_device_has_dal_support(adev)) {
-                       adev->ip_blocks = tonga_ip_blocks_dal;
-                       adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks_dal);
-               } else {
+                       if (amdgpu_device_has_dal_support(adev)) {
+                               adev->ip_blocks = tonga_ip_blocks_dal;
+                               adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks_dal);
+                       } else {
+                               adev->ip_blocks = tonga_ip_blocks;
+                               adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks);
+                       }
+#else
                        adev->ip_blocks = tonga_ip_blocks;
                        adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks);
-               }
-#else
-               adev->ip_blocks = tonga_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(tonga_ip_blocks);
 #endif
-               break;
-       case CHIP_POLARIS11:
-       case CHIP_POLARIS10:
+                       break;
+               case CHIP_POLARIS11:
+               case CHIP_POLARIS10:
 #if defined(CONFIG_DRM_AMD_DAL)
-               if (amdgpu_device_has_dal_support(adev)) {
-                       adev->ip_blocks = polaris11_ip_blocks_dal;
-                       adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks_dal);
-               } else {
+                       if (amdgpu_device_has_dal_support(adev)) {
+                               adev->ip_blocks = polaris11_ip_blocks_dal;
+                               adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks_dal);
+                       } else {
+                               adev->ip_blocks = polaris11_ip_blocks;
+                               adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks);
+                       }
+#else
                        adev->ip_blocks = polaris11_ip_blocks;
                        adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks);
-               }
-#else
-               adev->ip_blocks = polaris11_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(polaris11_ip_blocks);
 #endif
-               break;
-       case CHIP_CARRIZO:
-       case CHIP_STONEY:
+                       break;
+               case CHIP_CARRIZO:
+               case CHIP_STONEY:
 #if defined(CONFIG_DRM_AMD_DAL)
-               if (amdgpu_device_has_dal_support(adev)) {
-                       adev->ip_blocks = cz_ip_blocks_dal;
-                       adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks_dal);
-               } else {
+                       if (amdgpu_device_has_dal_support(adev)) {
+                               adev->ip_blocks = cz_ip_blocks_dal;
+                               adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks_dal);
+                       } else {
+                               adev->ip_blocks = cz_ip_blocks;
+                               adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks);
+                       }
+#else
                        adev->ip_blocks = cz_ip_blocks;
                        adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks);
-               }
-#else
-               adev->ip_blocks = cz_ip_blocks;
-               adev->num_ip_blocks = ARRAY_SIZE(cz_ip_blocks);
 #endif
-               break;
-       default:
-               /* FIXME: not supported yet */
-               return -EINVAL;
+                       break;
+               default:
+                       /* FIXME: not supported yet */
+                       return -EINVAL;
+               }
        }
 
        return 0;
 }
 
+
 #define ATI_REV_ID_FUSE_MACRO__ADDRESS      0xC0014044
 #define ATI_REV_ID_FUSE_MACRO__SHIFT        9
 #define ATI_REV_ID_FUSE_MACRO__MASK         0x00001E00
--

1.9.1

Quoted 4 lines

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

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

#22 lore raw
In reply to a message not in the archive

Hi Emily,

Maybe, you need a cover letter to describe what you do for the whole patch set. :-)

git format-patch --cover-letter HEAD~13

Thanks,
Rui

Quoted 53 lines · Emily Deng

For virtual display feature, add virtual connector and encoder macros.

---
 drivers/gpu/drm/amd/amdgpu/ObjectID.h | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/ObjectID.h +7 -0
index 0619269..b8d6667 100644
@@ -90,6 +90,7 @@
 #define ENCODER_OBJECT_ID_INTERNAL_VCE            0x24
 #define ENCODER_OBJECT_ID_INTERNAL_UNIPHY3        0x25
 #define ENCODER_OBJECT_ID_INTERNAL_AMCLK          0x27
+#define ENCODER_OBJECT_ID_VIRTUAL                 0x28
 
 #define ENCODER_OBJECT_ID_GENERAL_EXTERNAL_DVO    0xFF
 
@@ -119,6 +120,7 @@
 #define CONNECTOR_OBJECT_ID_eDP                   0x14
 #define CONNECTOR_OBJECT_ID_MXM                   0x15
 #define CONNECTOR_OBJECT_ID_LVDS_eDP              0x16
+#define CONNECTOR_OBJECT_ID_VIRTUAL               0x17
 
 /* deleted */
 
@@ -147,6 +149,7 @@
 #define GRAPH_OBJECT_ENUM_ID5                     0x05
 #define GRAPH_OBJECT_ENUM_ID6                     0x06
 #define GRAPH_OBJECT_ENUM_ID7                     0x07
+#define GRAPH_OBJECT_ENUM_VIRTUAL                 0x08
 
 /****************************************************/
 /* Graphics Object ID Bit definition                */
@@ -408,6 +411,10 @@
                                                   GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\
                                                   ENCODER_OBJECT_ID_HDMI_ANX9805 << OBJECT_ID_SHIFT)
 
+#define ENCODER_VIRTUAL_ENUM_VIRTUAL            ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\
+                                                  GRAPH_OBJECT_ENUM_VIRTUAL << ENUM_ID_SHIFT |\
+                                                  ENCODER_OBJECT_ID_VIRTUAL << OBJECT_ID_SHIFT)
+
 /****************************************************/
 /* Connector Object ID definition - Shared with BIOS */
 /****************************************************/
Signature · 6 lines
1.9.1

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

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

#23 lore raw

Hi guys,

yeah good idea, I was about to complain as well. Especially since we can't be sure if the design of this will be accepted or not.

Dave & Daniel please take a look at this. It's basically the same approach we have seen with the virtual crtc patch set a couple of years ago, e.g. adding a virtual connector/encoder/crtc when there isn't any real one present.

This allows to start X (or any other userspace client) even on boards which doesn't have any connectors in their BIOS tables.

Intel does this by adding a virtual crtc in their DDX if I'm not completely mistaken, but we wanted a solution which works with any userspace client.

I only briefly skimmed over the set and can't say much about this part of the driver anyway, but things like coding style looks good to me on first glance. So the whole set is Acked-by: Christian König <[email protected]>.

Regards,
Christian.

Am 04.08.2016 um 08:52 schrieb Huang Rui:

Quoted 59 lines

Hi Emily,

Maybe, you need a cover letter to describe what you do for the whole patch set. :-)

git format-patch --cover-letter HEAD~13

Thanks,
Rui

Quoted 49 lines · Emily Deng

For virtual display feature, add virtual connector and encoder macros.

---
  drivers/gpu/drm/amd/amdgpu/ObjectID.h | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/ObjectID.h +7 -0
index 0619269..b8d6667 100644
@@ -90,6 +90,7 @@
  #define ENCODER_OBJECT_ID_INTERNAL_VCE            0x24
  #define ENCODER_OBJECT_ID_INTERNAL_UNIPHY3        0x25
  #define ENCODER_OBJECT_ID_INTERNAL_AMCLK          0x27
+#define ENCODER_OBJECT_ID_VIRTUAL                 0x28
 
  #define ENCODER_OBJECT_ID_GENERAL_EXTERNAL_DVO    0xFF
 
@@ -119,6 +120,7 @@
  #define CONNECTOR_OBJECT_ID_eDP                   0x14
  #define CONNECTOR_OBJECT_ID_MXM                   0x15
  #define CONNECTOR_OBJECT_ID_LVDS_eDP              0x16
+#define CONNECTOR_OBJECT_ID_VIRTUAL               0x17
 
  /* deleted */
 
@@ -147,6 +149,7 @@
  #define GRAPH_OBJECT_ENUM_ID5                     0x05
  #define GRAPH_OBJECT_ENUM_ID6                     0x06
  #define GRAPH_OBJECT_ENUM_ID7                     0x07
+#define GRAPH_OBJECT_ENUM_VIRTUAL                 0x08
 
  /****************************************************/
  /* Graphics Object ID Bit definition                */
@@ -408,6 +411,10 @@
                                                    GRAPH_OBJECT_ENUM_ID1 << ENUM_ID_SHIFT |\
                                                    ENCODER_OBJECT_ID_HDMI_ANX9805 << OBJECT_ID_SHIFT)
 
+#define ENCODER_VIRTUAL_ENUM_VIRTUAL            ( GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\
+                                                  GRAPH_OBJECT_ENUM_VIRTUAL << ENUM_ID_SHIFT |\
+                                                  ENCODER_OBJECT_ID_VIRTUAL << OBJECT_ID_SHIFT)
+
  /****************************************************/
  /* Connector Object ID definition - Shared with BIOS */
  /****************************************************/
Signature · 1 line
1.9.1
Quoted 8 lines
Quoted 4 lines

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

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

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

#24 lore raw

I have no idea or clue on this, but adding dri-devel can't hurt. -Daniel

Quoted 99 lines · Christian König

Hi guys,

yeah good idea, I was about to complain as well. Especially since we can't be sure if the design of this will be accepted or not.

Dave & Daniel please take a look at this. It's basically the same approach we have seen with the virtual crtc patch set a couple of years ago, e.g. adding a virtual connector/encoder/crtc when there isn't any real one present.

This allows to start X (or any other userspace client) even on boards which doesn't have any connectors in their BIOS tables.

Intel does this by adding a virtual crtc in their DDX if I'm not completely mistaken, but we wanted a solution which works with any userspace client.

I only briefly skimmed over the set and can't say much about this part of the driver anyway, but things like coding style looks good to me on first glance. So the whole set is Acked-by: Christian König <[email protected]>.

Regards,
Christian.

Am 04.08.2016 um 08:52 schrieb Huang Rui:

Quoted 71 lines

Hi Emily,

Maybe, you need a cover letter to describe what you do for the whole patch set. :-)

git format-patch --cover-letter HEAD~13

Thanks,
Rui

Quoted 50 lines · Emily Deng

For virtual display feature, add virtual connector and encoder macros.

---
  drivers/gpu/drm/amd/amdgpu/ObjectID.h | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/amdgpu/ObjectID.h +1 -0
index 0619269..b8d6667 100644
@@ -90,6 +90,7 @@
  #define ENCODER_OBJECT_ID_INTERNAL_VCE            0x24
  #define ENCODER_OBJECT_ID_INTERNAL_UNIPHY3        0x25
  #define ENCODER_OBJECT_ID_INTERNAL_AMCLK          0x27
+#define ENCODER_OBJECT_ID_VIRTUAL                 0x28
    #define ENCODER_OBJECT_ID_GENERAL_EXTERNAL_DVO    0xFF
  @@ -119,6 +120,7 @@
  #define CONNECTOR_OBJECT_ID_eDP                   0x14
  #define CONNECTOR_OBJECT_ID_MXM                   0x15
  #define CONNECTOR_OBJECT_ID_LVDS_eDP              0x16
drivers/gpu/drm/amd/amdgpu/ObjectID.h +3 -0
+#define CONNECTOR_OBJECT_ID_VIRTUAL               0x17
    /* deleted */
  @@ -147,6 +149,7 @@
  #define GRAPH_OBJECT_ENUM_ID5                     0x05
  #define GRAPH_OBJECT_ENUM_ID6                     0x06
  #define GRAPH_OBJECT_ENUM_ID7                     0x07
+#define GRAPH_OBJECT_ENUM_VIRTUAL                 0x08
    /****************************************************/
  /* Graphics Object ID Bit definition                */
@@ -408,6 +411,10 @@
                                                    GRAPH_OBJECT_ENUM_ID1
 << ENUM_ID_SHIFT |\
 
 ENCODER_OBJECT_ID_HDMI_ANX9805 << OBJECT_ID_SHIFT)
  +#define ENCODER_VIRTUAL_ENUM_VIRTUAL            (
 GRAPH_OBJECT_TYPE_ENCODER << OBJECT_TYPE_SHIFT |\
+

GRAPH_OBJECT_ENUM_VIRTUAL << ENUM_ID_SHIFT |\
+
ENCODER_OBJECT_ID_VIRTUAL << OBJECT_ID_SHIFT)
+
/****************************************************/ /* Connector Object ID definition - Shared with BIOS */ /****************************************************/
--
1.9.1

Quoted 4 lines

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

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

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel