diff mbox

[1/6] pci: add pci_vga_type(), giving the device name of the chosen VGA device

Message ID 1483049536-21548-2-git-send-email-hpoussin@reactos.org (mailing list archive)
State New, archived
Headers show

Commit Message

Hervé Poussineau Dec. 29, 2016, 10:12 p.m. UTC
This is in fact a split of pci_vga_init() function in two parts.

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 hw/pci/pci.c         | 22 ++++++++++++++++------
 include/hw/pci/pci.h |  1 +
 2 files changed, 17 insertions(+), 6 deletions(-)

Comments

David Gibson Jan. 2, 2017, 11:01 p.m. UTC | #1
On Thu, Dec 29, 2016 at 11:12:11PM +0100, Hervé Poussineau wrote:
> This is in fact a split of pci_vga_init() function in two parts.
> 
> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

I think it needs Michael or someone to merge it though.

> ---
>  hw/pci/pci.c         | 22 ++++++++++++++++------
>  include/hw/pci/pci.h |  1 +
>  2 files changed, 17 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index 24fae16..0d5a862 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -1816,19 +1816,19 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
>      return pci_dev;
>  }
>  
> -PCIDevice *pci_vga_init(PCIBus *bus)
> +const char *pci_vga_type(void)
>  {
>      switch (vga_interface_type) {
>      case VGA_CIRRUS:
> -        return pci_create_simple(bus, -1, "cirrus-vga");
> +        return "cirrus-vga";
>      case VGA_QXL:
> -        return pci_create_simple(bus, -1, "qxl-vga");
> +        return "qxl-vga";
>      case VGA_STD:
> -        return pci_create_simple(bus, -1, "VGA");
> +        return "VGA";
>      case VGA_VMWARE:
> -        return pci_create_simple(bus, -1, "vmware-svga");
> +        return "vmware-svga";
>      case VGA_VIRTIO:
> -        return pci_create_simple(bus, -1, "virtio-vga");
> +        return "virtio-vga";
>      case VGA_NONE:
>      default: /* Other non-PCI types. Checking for unsupported types is already
>                  done in vl.c. */
> @@ -1836,6 +1836,16 @@ PCIDevice *pci_vga_init(PCIBus *bus)
>      }
>  }
>  
> +PCIDevice *pci_vga_init(PCIBus *bus)
> +{
> +    const char *vga_type = pci_vga_type();
> +    if (vga_type) {
> +        return pci_create_simple(bus, -1, vga_type);
> +    } else {
> +        return NULL;
> +    }
> +}
> +
>  /* Whether a given bus number is in range of the secondary
>   * bus of the given bridge device. */
>  static bool pci_secondary_bus_in_range(PCIDevice *dev, int bus_num)
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index 772692f..aa8d014 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -420,6 +420,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
>                                 const char *default_model,
>                                 const char *default_devaddr);
>  
> +const char *pci_vga_type(void);
>  PCIDevice *pci_vga_init(PCIBus *bus);
>  
>  int pci_bus_num(PCIBus *s);
Michael S. Tsirkin Jan. 10, 2017, 3:14 a.m. UTC | #2
On Tue, Jan 03, 2017 at 10:01:25AM +1100, David Gibson wrote:
> On Thu, Dec 29, 2016 at 11:12:11PM +0100, Hervé Poussineau wrote:
> > This is in fact a split of pci_vga_init() function in two parts.
> > 
> > Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> 
> I think it needs Michael or someone to merge it though.

Do we have to keep poking at pci_vga_type?
I'd rather people just used -device for everything.

> > ---
> >  hw/pci/pci.c         | 22 ++++++++++++++++------
> >  include/hw/pci/pci.h |  1 +
> >  2 files changed, 17 insertions(+), 6 deletions(-)
> > 
> > diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> > index 24fae16..0d5a862 100644
> > --- a/hw/pci/pci.c
> > +++ b/hw/pci/pci.c
> > @@ -1816,19 +1816,19 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
> >      return pci_dev;
> >  }
> >  
> > -PCIDevice *pci_vga_init(PCIBus *bus)
> > +const char *pci_vga_type(void)
> >  {
> >      switch (vga_interface_type) {
> >      case VGA_CIRRUS:
> > -        return pci_create_simple(bus, -1, "cirrus-vga");
> > +        return "cirrus-vga";
> >      case VGA_QXL:
> > -        return pci_create_simple(bus, -1, "qxl-vga");
> > +        return "qxl-vga";
> >      case VGA_STD:
> > -        return pci_create_simple(bus, -1, "VGA");
> > +        return "VGA";
> >      case VGA_VMWARE:
> > -        return pci_create_simple(bus, -1, "vmware-svga");
> > +        return "vmware-svga";
> >      case VGA_VIRTIO:
> > -        return pci_create_simple(bus, -1, "virtio-vga");
> > +        return "virtio-vga";
> >      case VGA_NONE:
> >      default: /* Other non-PCI types. Checking for unsupported types is already
> >                  done in vl.c. */
> > @@ -1836,6 +1836,16 @@ PCIDevice *pci_vga_init(PCIBus *bus)
> >      }
> >  }
> >  
> > +PCIDevice *pci_vga_init(PCIBus *bus)
> > +{
> > +    const char *vga_type = pci_vga_type();
> > +    if (vga_type) {
> > +        return pci_create_simple(bus, -1, vga_type);
> > +    } else {
> > +        return NULL;
> > +    }
> > +}
> > +
> >  /* Whether a given bus number is in range of the secondary
> >   * bus of the given bridge device. */
> >  static bool pci_secondary_bus_in_range(PCIDevice *dev, int bus_num)
> > diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> > index 772692f..aa8d014 100644
> > --- a/include/hw/pci/pci.h
> > +++ b/include/hw/pci/pci.h
> > @@ -420,6 +420,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
> >                                 const char *default_model,
> >                                 const char *default_devaddr);
> >  
> > +const char *pci_vga_type(void);
> >  PCIDevice *pci_vga_init(PCIBus *bus);
> >  
> >  int pci_bus_num(PCIBus *s);
> 
> -- 
> David Gibson			| I'll have my music baroque, and my code
> david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
> 				| _way_ _around_!
> http://www.ozlabs.org/~dgibson
Hervé Poussineau Jan. 10, 2017, 9 p.m. UTC | #3
Le 10/01/2017 à 04:14, Michael S. Tsirkin a écrit :
> On Tue, Jan 03, 2017 at 10:01:25AM +1100, David Gibson wrote:
>> On Thu, Dec 29, 2016 at 11:12:11PM +0100, Hervé Poussineau wrote:
>>> This is in fact a split of pci_vga_init() function in two parts.
>>>
>>> Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
>>
>> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>>
>> I think it needs Michael or someone to merge it though.
>
> Do we have to keep poking at pci_vga_type?
> I'd rather people just used -device for everything.

On some machine, I want to be able to specify on which PCI slot is added the graphic card.
- Either the machine code is able to get the pci_vga_type, to be able to do itself a pci_create_simple(bus, PCI_DEVFN(...), vga_type) [this patch]
- Or we need to add a pci_vga_init_with_address(int devfn)

What do you prefer?

Hervé

>
>>> ---
>>>  hw/pci/pci.c         | 22 ++++++++++++++++------
>>>  include/hw/pci/pci.h |  1 +
>>>  2 files changed, 17 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
>>> index 24fae16..0d5a862 100644
>>> --- a/hw/pci/pci.c
>>> +++ b/hw/pci/pci.c
>>> @@ -1816,19 +1816,19 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
>>>      return pci_dev;
>>>  }
>>>
>>> -PCIDevice *pci_vga_init(PCIBus *bus)
>>> +const char *pci_vga_type(void)
>>>  {
>>>      switch (vga_interface_type) {
>>>      case VGA_CIRRUS:
>>> -        return pci_create_simple(bus, -1, "cirrus-vga");
>>> +        return "cirrus-vga";
>>>      case VGA_QXL:
>>> -        return pci_create_simple(bus, -1, "qxl-vga");
>>> +        return "qxl-vga";
>>>      case VGA_STD:
>>> -        return pci_create_simple(bus, -1, "VGA");
>>> +        return "VGA";
>>>      case VGA_VMWARE:
>>> -        return pci_create_simple(bus, -1, "vmware-svga");
>>> +        return "vmware-svga";
>>>      case VGA_VIRTIO:
>>> -        return pci_create_simple(bus, -1, "virtio-vga");
>>> +        return "virtio-vga";
>>>      case VGA_NONE:
>>>      default: /* Other non-PCI types. Checking for unsupported types is already
>>>                  done in vl.c. */
>>> @@ -1836,6 +1836,16 @@ PCIDevice *pci_vga_init(PCIBus *bus)
>>>      }
>>>  }
>>>
>>> +PCIDevice *pci_vga_init(PCIBus *bus)
>>> +{
>>> +    const char *vga_type = pci_vga_type();
>>> +    if (vga_type) {
>>> +        return pci_create_simple(bus, -1, vga_type);
>>> +    } else {
>>> +        return NULL;
>>> +    }
>>> +}
>>> +
>>>  /* Whether a given bus number is in range of the secondary
>>>   * bus of the given bridge device. */
>>>  static bool pci_secondary_bus_in_range(PCIDevice *dev, int bus_num)
>>> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
>>> index 772692f..aa8d014 100644
>>> --- a/include/hw/pci/pci.h
>>> +++ b/include/hw/pci/pci.h
>>> @@ -420,6 +420,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
>>>                                 const char *default_model,
>>>                                 const char *default_devaddr);
>>>
>>> +const char *pci_vga_type(void);
>>>  PCIDevice *pci_vga_init(PCIBus *bus);
>>>
>>>  int pci_bus_num(PCIBus *s);
>>
>> --
>> David Gibson			| I'll have my music baroque, and my code
>> david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
>> 				| _way_ _around_!
>> http://www.ozlabs.org/~dgibson
>
>
>
diff mbox

Patch

diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 24fae16..0d5a862 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -1816,19 +1816,19 @@  PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
     return pci_dev;
 }
 
-PCIDevice *pci_vga_init(PCIBus *bus)
+const char *pci_vga_type(void)
 {
     switch (vga_interface_type) {
     case VGA_CIRRUS:
-        return pci_create_simple(bus, -1, "cirrus-vga");
+        return "cirrus-vga";
     case VGA_QXL:
-        return pci_create_simple(bus, -1, "qxl-vga");
+        return "qxl-vga";
     case VGA_STD:
-        return pci_create_simple(bus, -1, "VGA");
+        return "VGA";
     case VGA_VMWARE:
-        return pci_create_simple(bus, -1, "vmware-svga");
+        return "vmware-svga";
     case VGA_VIRTIO:
-        return pci_create_simple(bus, -1, "virtio-vga");
+        return "virtio-vga";
     case VGA_NONE:
     default: /* Other non-PCI types. Checking for unsupported types is already
                 done in vl.c. */
@@ -1836,6 +1836,16 @@  PCIDevice *pci_vga_init(PCIBus *bus)
     }
 }
 
+PCIDevice *pci_vga_init(PCIBus *bus)
+{
+    const char *vga_type = pci_vga_type();
+    if (vga_type) {
+        return pci_create_simple(bus, -1, vga_type);
+    } else {
+        return NULL;
+    }
+}
+
 /* Whether a given bus number is in range of the secondary
  * bus of the given bridge device. */
 static bool pci_secondary_bus_in_range(PCIDevice *dev, int bus_num)
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index 772692f..aa8d014 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -420,6 +420,7 @@  PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
                                const char *default_model,
                                const char *default_devaddr);
 
+const char *pci_vga_type(void);
 PCIDevice *pci_vga_init(PCIBus *bus);
 
 int pci_bus_num(PCIBus *s);