All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [RFC] drm/nouveau: bring back hdmi audio device after switcheroo power down
@ 2013-07-24  7:13 Dave Airlie
  2013-07-24  8:45 ` Paul Menzel
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dave Airlie @ 2013-07-24  7:13 UTC (permalink / raw)
  To: dri-devel; +Cc: tiwai, nouveau

After a full device powerdown via the optimus power switch, we seem
to lose the HDMI device completely on power on, this keep track of
whether we had a hdmi audio sub function device at power on, and
pokes a magic register to make it reappear after the optimus power
switch is thrown.

This at least works on my NVC4 machine, probably needs testing on
a few other laptops with other nvidia GPUs.

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/nouveau/nouveau_drm.c | 32 ++++++++++++++++++++++++++++++++
 drivers/gpu/drm/nouveau/nouveau_drm.h |  2 ++
 drivers/gpu/drm/nouveau/nouveau_vga.c | 17 +++++++++++++++++
 3 files changed, 51 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index 6197266..12a6240 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -296,6 +296,31 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
 	return 0;
 }
 
+#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
+
+static void
+nouveau_get_hdmi_dev(struct drm_device *dev)
+{
+	struct nouveau_drm *drm = dev->dev_private;
+	struct pci_dev *pdev = dev->pdev;
+
+	/* subfunction one is a hdmi audio device? */
+	drm->hdmi_device = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
+						PCI_DEVFN(PCI_SLOT(pdev->devfn), 1));
+
+	if (!drm->hdmi_device) {
+		DRM_INFO("hdmi device  not found %d %d %d\n", pdev->bus->number, PCI_SLOT(pdev->devfn), 1);
+		return;
+	}
+
+	if ((drm->hdmi_device->class >> 8) != PCI_CLASS_MULTIMEDIA_HD_AUDIO) {
+		DRM_INFO("possible hdmi device  not audio %d\n", drm->hdmi_device->class);
+		pci_dev_put(drm->hdmi_device);
+		drm->hdmi_device = NULL;
+		return;
+	}
+}
+
 static int
 nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 {
@@ -314,6 +339,8 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
 	INIT_LIST_HEAD(&drm->clients);
 	spin_lock_init(&drm->tile.lock);
 
+	nouveau_get_hdmi_dev(dev);
+
 	/* make sure AGP controller is in a consistent state before we
 	 * (possibly) execute vbios init tables (see nouveau_agp.h)
 	 */
@@ -400,6 +427,9 @@ fail_ttm:
 	nouveau_agp_fini(drm);
 	nouveau_vga_fini(drm);
 fail_device:
+	if (drm->hdmi_device)
+		pci_dev_put(drm->hdmi_device);
+
 	nouveau_cli_destroy(&drm->client);
 	return ret;
 }
@@ -424,6 +454,8 @@ nouveau_drm_unload(struct drm_device *dev)
 	nouveau_agp_fini(drm);
 	nouveau_vga_fini(drm);
 
+	if (drm->hdmi_device)
+		pci_dev_put(drm->hdmi_device);
 	nouveau_cli_destroy(&drm->client);
 	return 0;
 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
index 41ff7e0..f276e37 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
@@ -129,6 +129,8 @@ struct nouveau_drm {
 
 	/* power management */
 	struct nouveau_pm *pm;
+
+	struct pci_dev *hdmi_device;
 };
 
 static inline struct nouveau_drm *
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index 25d3495..d8af49c 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -27,6 +27,22 @@ nouveau_vga_set_decode(void *priv, bool state)
 }
 
 static void
+nouveau_reenable_hdmi_device(struct drm_device *dev)
+{
+	struct nouveau_drm *drm = nouveau_drm(dev);
+	struct nouveau_device *device = nv_device(drm->device);
+	uint32_t val;
+
+	if (!drm->hdmi_device)
+		return;
+
+	/* write magic value into magic place */
+	val = nv_rd32(device, 0x88488);
+	val |= (1 << 25);
+	nv_wr32(device, 0x88488, val);
+}
+
+static void
 nouveau_switcheroo_set_state(struct pci_dev *pdev,
 			     enum vga_switcheroo_state state)
 {
@@ -37,6 +53,7 @@ nouveau_switcheroo_set_state(struct pci_dev *pdev,
 		dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 		nouveau_pmops_resume(&pdev->dev);
 		drm_kms_helper_poll_enable(dev);
+		nouveau_reenable_hdmi_device(dev);
 		dev->switch_power_state = DRM_SWITCH_POWER_ON;
 	} else {
 		printk(KERN_ERR "VGA switcheroo: switched nouveau off\n");
-- 
1.8.2.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RFC] drm/nouveau: bring back hdmi audio device after switcheroo power down
  2013-07-24  7:13 [PATCH] [RFC] drm/nouveau: bring back hdmi audio device after switcheroo power down Dave Airlie
@ 2013-07-24  8:45 ` Paul Menzel
  2013-07-24 12:06 ` Pasi Kärkkäinen
       [not found] ` <1374650022-17865-1-git-send-email-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Paul Menzel @ 2013-07-24  8:45 UTC (permalink / raw)
  To: Dave Airlie; +Cc: tiwai, nouveau, dri-devel


[-- Attachment #1.1: Type: text/plain, Size: 4702 bytes --]

Am Mittwoch, den 24.07.2013, 17:13 +1000 schrieb Dave Airlie:
> After a full device powerdown via the optimus power switch, we seem
> to lose the HDMI device completely on power on, this keep track of

keep*s*

> whether we had a hdmi audio sub function device at power on, and
> pokes a magic register to make it reappear after the optimus power
> switch is thrown.
> 
> This at least works on my NVC4 machine, probably needs testing on
> a few other laptops with other nvidia GPUs.
> 
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 32 ++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/nouveau/nouveau_drm.h |  2 ++
>  drivers/gpu/drm/nouveau/nouveau_vga.c | 17 +++++++++++++++++
>  3 files changed, 51 insertions(+)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 6197266..12a6240 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -296,6 +296,31 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
>  	return 0;
>  }
>  
> +#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403

Should that go into some header?

> +
> +static void
> +nouveau_get_hdmi_dev(struct drm_device *dev)
> +{
> +	struct nouveau_drm *drm = dev->dev_private;
> +	struct pci_dev *pdev = dev->pdev;
> +
> +	/* subfunction one is a hdmi audio device? */

Just function as in <domain>:<bus>:<slot>.<func>?

> +	drm->hdmi_device = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
> +						PCI_DEVFN(PCI_SLOT(pdev->devfn), 1));
> +
> +	if (!drm->hdmi_device) {
> +		DRM_INFO("hdmi device  not found %d %d %d\n", pdev->bus->number, PCI_SLOT(pdev->devfn), 1);

Just one space after device?

> +		return;
> +	}
> +
> +	if ((drm->hdmi_device->class >> 8) != PCI_CLASS_MULTIMEDIA_HD_AUDIO) {
> +		DRM_INFO("possible hdmi device  not audio %d\n", drm->hdmi_device->class);
> +		pci_dev_put(drm->hdmi_device);
> +		drm->hdmi_device = NULL;
> +		return;
> +	}
> +}
> +
>  static int
>  nouveau_drm_load(struct drm_device *dev, unsigned long flags)
>  {
> @@ -314,6 +339,8 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
>  	INIT_LIST_HEAD(&drm->clients);
>  	spin_lock_init(&drm->tile.lock);
>  
> +	nouveau_get_hdmi_dev(dev);
> +
>  	/* make sure AGP controller is in a consistent state before we
>  	 * (possibly) execute vbios init tables (see nouveau_agp.h)
>  	 */
> @@ -400,6 +427,9 @@ fail_ttm:
>  	nouveau_agp_fini(drm);
>  	nouveau_vga_fini(drm);
>  fail_device:
> +	if (drm->hdmi_device)
> +		pci_dev_put(drm->hdmi_device);
> +
>  	nouveau_cli_destroy(&drm->client);
>  	return ret;
>  }
> @@ -424,6 +454,8 @@ nouveau_drm_unload(struct drm_device *dev)
>  	nouveau_agp_fini(drm);
>  	nouveau_vga_fini(drm);
>  
> +	if (drm->hdmi_device)
> +		pci_dev_put(drm->hdmi_device);
>  	nouveau_cli_destroy(&drm->client);
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
> index 41ff7e0..f276e37 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
> @@ -129,6 +129,8 @@ struct nouveau_drm {
>  
>  	/* power management */
>  	struct nouveau_pm *pm;
> +
> +	struct pci_dev *hdmi_device;
>  };
>  
>  static inline struct nouveau_drm *
> diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
> index 25d3495..d8af49c 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
> @@ -27,6 +27,22 @@ nouveau_vga_set_decode(void *priv, bool state)
>  }
>  
>  static void
> +nouveau_reenable_hdmi_device(struct drm_device *dev)
> +{
> +	struct nouveau_drm *drm = nouveau_drm(dev);
> +	struct nouveau_device *device = nv_device(drm->device);
> +	uint32_t val;
> +
> +	if (!drm->hdmi_device)
> +		return;
> +
> +	/* write magic value into magic place */
> +	val = nv_rd32(device, 0x88488);
> +	val |= (1 << 25);
> +	nv_wr32(device, 0x88488, val);

Use a define for this nevertheless?

> +}
> +
> +static void
>  nouveau_switcheroo_set_state(struct pci_dev *pdev,
>  			     enum vga_switcheroo_state state)
>  {
> @@ -37,6 +53,7 @@ nouveau_switcheroo_set_state(struct pci_dev *pdev,
>  		dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
>  		nouveau_pmops_resume(&pdev->dev);
>  		drm_kms_helper_poll_enable(dev);
> +		nouveau_reenable_hdmi_device(dev);
>  		dev->switch_power_state = DRM_SWITCH_POWER_ON;
>  	} else {
>  		printk(KERN_ERR "VGA switcheroo: switched nouveau off\n");

Otherwise this looks good,


Thanks,

Paul

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RFC] drm/nouveau: bring back hdmi audio device after switcheroo power down
  2013-07-24  7:13 [PATCH] [RFC] drm/nouveau: bring back hdmi audio device after switcheroo power down Dave Airlie
  2013-07-24  8:45 ` Paul Menzel
@ 2013-07-24 12:06 ` Pasi Kärkkäinen
       [not found] ` <1374650022-17865-1-git-send-email-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2 siblings, 0 replies; 5+ messages in thread
From: Pasi Kärkkäinen @ 2013-07-24 12:06 UTC (permalink / raw)
  To: Dave Airlie; +Cc: tiwai, nouveau, dri-devel

On Wed, Jul 24, 2013 at 05:13:42PM +1000, Dave Airlie wrote:
> After a full device powerdown via the optimus power switch, we seem
> to lose the HDMI device completely on power on, this keep track of
> whether we had a hdmi audio sub function device at power on, and
> pokes a magic register to make it reappear after the optimus power
> switch is thrown.
> 
> This at least works on my NVC4 machine, probably needs testing on
> a few other laptops with other nvidia GPUs.
> 

Sorry for a stupid question, but how do you test "optimus power switch" ? 
(I have a laptop with hybrid Optimus graphics, so I could test..)

Thanks,

-- Pasi 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RFC] drm/nouveau: bring back hdmi audio device after switcheroo power down
       [not found] ` <1374650022-17865-1-git-send-email-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2013-07-24 13:38   ` Maarten Lankhorst
       [not found]     ` <51EFD8DB.10206-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Maarten Lankhorst @ 2013-07-24 13:38 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Op 24-07-13 09:13, Dave Airlie schreef:
> After a full device powerdown via the optimus power switch, we seem
> to lose the HDMI device completely on power on, this keep track of
> whether we had a hdmi audio sub function device at power on, and
> pokes a magic register to make it reappear after the optimus power
> switch is thrown.
>
> This at least works on my NVC4 machine, probably needs testing on
> a few other laptops with other nvidia GPUs.
>
> Signed-off-by: Dave Airlie <airlied-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/gpu/drm/nouveau/nouveau_drm.c | 32 ++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/nouveau/nouveau_drm.h |  2 ++
>  drivers/gpu/drm/nouveau/nouveau_vga.c | 17 +++++++++++++++++
>  3 files changed, 51 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 6197266..12a6240 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -296,6 +296,31 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
>  	return 0;
>  }
>  
> +#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
> +
> +static void
> +nouveau_get_hdmi_dev(struct drm_device *dev)
> +{
> +	struct nouveau_drm *drm = dev->dev_private;
> +	struct pci_dev *pdev = dev->pdev;
> +
> +	/* subfunction one is a hdmi audio device? */
> +	drm->hdmi_device = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
> +						PCI_DEVFN(PCI_SLOT(pdev->devfn), 1));
> +
> +	if (!drm->hdmi_device) {
> +		DRM_INFO("hdmi device  not found %d %d %d\n", pdev->bus->number, PCI_SLOT(pdev->devfn), 1);
> +		return;
> +	}
> +
> +	if ((drm->hdmi_device->class >> 8) != PCI_CLASS_MULTIMEDIA_HD_AUDIO) {
> +		DRM_INFO("possible hdmi device  not audio %d\n", drm->hdmi_device->class);
> +		pci_dev_put(drm->hdmi_device);
> +		drm->hdmi_device = NULL;
> +		return;
> +	}
> +}
> +
>  static int
>  nouveau_drm_load(struct drm_device *dev, unsigned long flags)
>  {
> @@ -314,6 +339,8 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
>  	INIT_LIST_HEAD(&drm->clients);
>  	spin_lock_init(&drm->tile.lock);
>  
> +	nouveau_get_hdmi_dev(dev);
> +
>  	/* make sure AGP controller is in a consistent state before we
>  	 * (possibly) execute vbios init tables (see nouveau_agp.h)
>  	 */
> @@ -400,6 +427,9 @@ fail_ttm:
>  	nouveau_agp_fini(drm);
>  	nouveau_vga_fini(drm);
>  fail_device:
> +	if (drm->hdmi_device)
> +		pci_dev_put(drm->hdmi_device);
> +
>  	nouveau_cli_destroy(&drm->client);
>  	return ret;
>  }
> @@ -424,6 +454,8 @@ nouveau_drm_unload(struct drm_device *dev)
>  	nouveau_agp_fini(drm);
>  	nouveau_vga_fini(drm);
>  
> +	if (drm->hdmi_device)
> +		pci_dev_put(drm->hdmi_device);
>  	nouveau_cli_destroy(&drm->client);
>  	return 0;
>  }
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
> index 41ff7e0..f276e37 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
> @@ -129,6 +129,8 @@ struct nouveau_drm {
>  
>  	/* power management */
>  	struct nouveau_pm *pm;
> +
> +	struct pci_dev *hdmi_device;
>  };
>  
>  static inline struct nouveau_drm *
> diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
> index 25d3495..d8af49c 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
> @@ -27,6 +27,22 @@ nouveau_vga_set_decode(void *priv, bool state)
>  }
>  
>  static void
> +nouveau_reenable_hdmi_device(struct drm_device *dev)
> +{
> +	struct nouveau_drm *drm = nouveau_drm(dev);
> +	struct nouveau_device *device = nv_device(drm->device);
> +	uint32_t val;
> +
> +	if (!drm->hdmi_device)
> +		return;
> +
> +	/* write magic value into magic place */
> +	val = nv_rd32(device, 0x88488);
> +	val |= (1 << 25);
> +	nv_wr32(device, 0x88488, val);
> +}
use nv_mask(dev, 0x88488, 0x02000000, 0x02000000);

Could this be added in core/engine/disp/hdminv84.c nv84_hdmi_ctrl to get the same effect?

~Maarten

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [RFC] drm/nouveau: bring back hdmi audio device after switcheroo power down
       [not found]     ` <51EFD8DB.10206-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
@ 2013-07-25  0:05       ` Dave Airlie
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Airlie @ 2013-07-25  0:05 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Wed, Jul 24, 2013 at 11:38 PM, Maarten Lankhorst
<maarten.lankhorst-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org> wrote:
> Op 24-07-13 09:13, Dave Airlie schreef:
>> After a full device powerdown via the optimus power switch, we seem
>> to lose the HDMI device completely on power on, this keep track of
>> whether we had a hdmi audio sub function device at power on, and
>> pokes a magic register to make it reappear after the optimus power
>> switch is thrown.
>>
>> This at least works on my NVC4 machine, probably needs testing on
>> a few other laptops with other nvidia GPUs.
>>
>> Signed-off-by: Dave Airlie <airlied-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>>  drivers/gpu/drm/nouveau/nouveau_drm.c | 32 ++++++++++++++++++++++++++++++++
>>  drivers/gpu/drm/nouveau/nouveau_drm.h |  2 ++
>>  drivers/gpu/drm/nouveau/nouveau_vga.c | 17 +++++++++++++++++
>>  3 files changed, 51 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
>> index 6197266..12a6240 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
>> @@ -296,6 +296,31 @@ static int nouveau_drm_probe(struct pci_dev *pdev,
>>       return 0;
>>  }
>>
>> +#define PCI_CLASS_MULTIMEDIA_HD_AUDIO 0x0403
>> +
>> +static void
>> +nouveau_get_hdmi_dev(struct drm_device *dev)
>> +{
>> +     struct nouveau_drm *drm = dev->dev_private;
>> +     struct pci_dev *pdev = dev->pdev;
>> +
>> +     /* subfunction one is a hdmi audio device? */
>> +     drm->hdmi_device = pci_get_bus_and_slot((unsigned int)pdev->bus->number,
>> +                                             PCI_DEVFN(PCI_SLOT(pdev->devfn), 1));
>> +
>> +     if (!drm->hdmi_device) {
>> +             DRM_INFO("hdmi device  not found %d %d %d\n", pdev->bus->number, PCI_SLOT(pdev->devfn), 1);
>> +             return;
>> +     }
>> +
>> +     if ((drm->hdmi_device->class >> 8) != PCI_CLASS_MULTIMEDIA_HD_AUDIO) {
>> +             DRM_INFO("possible hdmi device  not audio %d\n", drm->hdmi_device->class);
>> +             pci_dev_put(drm->hdmi_device);
>> +             drm->hdmi_device = NULL;
>> +             return;
>> +     }
>> +}
>> +
>>  static int
>>  nouveau_drm_load(struct drm_device *dev, unsigned long flags)
>>  {
>> @@ -314,6 +339,8 @@ nouveau_drm_load(struct drm_device *dev, unsigned long flags)
>>       INIT_LIST_HEAD(&drm->clients);
>>       spin_lock_init(&drm->tile.lock);
>>
>> +     nouveau_get_hdmi_dev(dev);
>> +
>>       /* make sure AGP controller is in a consistent state before we
>>        * (possibly) execute vbios init tables (see nouveau_agp.h)
>>        */
>> @@ -400,6 +427,9 @@ fail_ttm:
>>       nouveau_agp_fini(drm);
>>       nouveau_vga_fini(drm);
>>  fail_device:
>> +     if (drm->hdmi_device)
>> +             pci_dev_put(drm->hdmi_device);
>> +
>>       nouveau_cli_destroy(&drm->client);
>>       return ret;
>>  }
>> @@ -424,6 +454,8 @@ nouveau_drm_unload(struct drm_device *dev)
>>       nouveau_agp_fini(drm);
>>       nouveau_vga_fini(drm);
>>
>> +     if (drm->hdmi_device)
>> +             pci_dev_put(drm->hdmi_device);
>>       nouveau_cli_destroy(&drm->client);
>>       return 0;
>>  }
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
>> index 41ff7e0..f276e37 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
>> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
>> @@ -129,6 +129,8 @@ struct nouveau_drm {
>>
>>       /* power management */
>>       struct nouveau_pm *pm;
>> +
>> +     struct pci_dev *hdmi_device;
>>  };
>>
>>  static inline struct nouveau_drm *
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
>> index 25d3495..d8af49c 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
>> @@ -27,6 +27,22 @@ nouveau_vga_set_decode(void *priv, bool state)
>>  }
>>
>>  static void
>> +nouveau_reenable_hdmi_device(struct drm_device *dev)
>> +{
>> +     struct nouveau_drm *drm = nouveau_drm(dev);
>> +     struct nouveau_device *device = nv_device(drm->device);
>> +     uint32_t val;
>> +
>> +     if (!drm->hdmi_device)
>> +             return;
>> +
>> +     /* write magic value into magic place */
>> +     val = nv_rd32(device, 0x88488);
>> +     val |= (1 << 25);
>> +     nv_wr32(device, 0x88488, val);
>> +}
> use nv_mask(dev, 0x88488, 0x02000000, 0x02000000);

much nicer,

>
> Could this be added in core/engine/disp/hdminv84.c nv84_hdmi_ctrl to get the same effect?
>
Don't think so its nothing to do with the hdmi audio part on the
device, it just controls the PCI sub function appearing/disappearing.

Dave.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-25  0:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-24  7:13 [PATCH] [RFC] drm/nouveau: bring back hdmi audio device after switcheroo power down Dave Airlie
2013-07-24  8:45 ` Paul Menzel
2013-07-24 12:06 ` Pasi Kärkkäinen
     [not found] ` <1374650022-17865-1-git-send-email-airlied-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-07-24 13:38   ` Maarten Lankhorst
     [not found]     ` <51EFD8DB.10206-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2013-07-25  0:05       ` Dave Airlie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.