diff options
author | Dave Airlie <airlied@gmail.com> | 2010-12-14 12:16:38 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-02-06 22:09:36 -0500 |
commit | 8410ea3b95d105a5be5db501656f44bbb91197c1 (patch) | |
tree | 6cd27f207e50c13ba2f4a78d6323bc23f751e380 /include/drm | |
parent | ff72145badb834e8051719ea66e024784d000cb4 (diff) |
drm: rework PCI/platform driver interface.
This abstracts the pci/platform interface out a step further,
we can go further but this is far enough for now to allow USB
to be plugged in.
The drivers now just call the init code directly for their
device type.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm')
-rw-r--r-- | include/drm/drmP.h | 106 |
1 files changed, 51 insertions, 55 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 3cbe7a02d2aa..a99aefb9537c 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -145,7 +145,10 @@ extern void drm_ut_debug_printk(unsigned int request_level, | |||
145 | #define DRIVER_IRQ_VBL2 0x800 | 145 | #define DRIVER_IRQ_VBL2 0x800 |
146 | #define DRIVER_GEM 0x1000 | 146 | #define DRIVER_GEM 0x1000 |
147 | #define DRIVER_MODESET 0x2000 | 147 | #define DRIVER_MODESET 0x2000 |
148 | #define DRIVER_USE_PLATFORM_DEVICE 0x4000 | 148 | |
149 | #define DRIVER_BUS_PCI 0x1 | ||
150 | #define DRIVER_BUS_PLATFORM 0x2 | ||
151 | #define DRIVER_BUS_USB 0x3 | ||
149 | 152 | ||
150 | /***********************************************************************/ | 153 | /***********************************************************************/ |
151 | /** \name Begin the DRM... */ | 154 | /** \name Begin the DRM... */ |
@@ -698,6 +701,19 @@ struct drm_master { | |||
698 | #define DRM_SCANOUTPOS_INVBL (1 << 1) | 701 | #define DRM_SCANOUTPOS_INVBL (1 << 1) |
699 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) | 702 | #define DRM_SCANOUTPOS_ACCURATE (1 << 2) |
700 | 703 | ||
704 | struct drm_bus { | ||
705 | int bus_type; | ||
706 | int (*get_irq)(struct drm_device *dev); | ||
707 | const char *(*get_name)(struct drm_device *dev); | ||
708 | int (*set_busid)(struct drm_device *dev, struct drm_master *master); | ||
709 | int (*set_unique)(struct drm_device *dev, struct drm_master *master, | ||
710 | struct drm_unique *unique); | ||
711 | int (*irq_by_busid)(struct drm_device *dev, struct drm_irq_busid *p); | ||
712 | /* hooks that are for PCI */ | ||
713 | int (*agp_init)(struct drm_device *dev); | ||
714 | |||
715 | }; | ||
716 | |||
701 | /** | 717 | /** |
702 | * DRM driver structure. This structure represent the common code for | 718 | * DRM driver structure. This structure represent the common code for |
703 | * a family of cards. There will one drm_device for each card present | 719 | * a family of cards. There will one drm_device for each card present |
@@ -906,8 +922,12 @@ struct drm_driver { | |||
906 | struct drm_ioctl_desc *ioctls; | 922 | struct drm_ioctl_desc *ioctls; |
907 | int num_ioctls; | 923 | int num_ioctls; |
908 | struct file_operations fops; | 924 | struct file_operations fops; |
909 | struct pci_driver pci_driver; | 925 | union { |
910 | struct platform_device *platform_device; | 926 | struct pci_driver *pci; |
927 | struct platform_device *platform_device; | ||
928 | } kdriver; | ||
929 | struct drm_bus *bus; | ||
930 | |||
911 | /* List of devices hanging off this driver */ | 931 | /* List of devices hanging off this driver */ |
912 | struct list_head device_list; | 932 | struct list_head device_list; |
913 | }; | 933 | }; |
@@ -1147,28 +1167,9 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev, | |||
1147 | 1167 | ||
1148 | static inline int drm_dev_to_irq(struct drm_device *dev) | 1168 | static inline int drm_dev_to_irq(struct drm_device *dev) |
1149 | { | 1169 | { |
1150 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | 1170 | return dev->driver->bus->get_irq(dev); |
1151 | return platform_get_irq(dev->platformdev, 0); | ||
1152 | else | ||
1153 | return dev->pdev->irq; | ||
1154 | } | 1171 | } |
1155 | 1172 | ||
1156 | static inline int drm_get_pci_domain(struct drm_device *dev) | ||
1157 | { | ||
1158 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | ||
1159 | return 0; | ||
1160 | |||
1161 | #ifndef __alpha__ | ||
1162 | /* For historical reasons, drm_get_pci_domain() is busticated | ||
1163 | * on most archs and has to remain so for userspace interface | ||
1164 | * < 1.4, except on alpha which was right from the beginning | ||
1165 | */ | ||
1166 | if (dev->if_version < 0x10004) | ||
1167 | return 0; | ||
1168 | #endif /* __alpha__ */ | ||
1169 | |||
1170 | return pci_domain_nr(dev->pdev->bus); | ||
1171 | } | ||
1172 | 1173 | ||
1173 | #if __OS_HAS_AGP | 1174 | #if __OS_HAS_AGP |
1174 | static inline int drm_core_has_AGP(struct drm_device *dev) | 1175 | static inline int drm_core_has_AGP(struct drm_device *dev) |
@@ -1222,8 +1223,6 @@ static inline int drm_mtrr_del(int handle, unsigned long offset, | |||
1222 | /*@{*/ | 1223 | /*@{*/ |
1223 | 1224 | ||
1224 | /* Driver support (drm_drv.h) */ | 1225 | /* Driver support (drm_drv.h) */ |
1225 | extern int drm_init(struct drm_driver *driver); | ||
1226 | extern void drm_exit(struct drm_driver *driver); | ||
1227 | extern long drm_ioctl(struct file *filp, | 1226 | extern long drm_ioctl(struct file *filp, |
1228 | unsigned int cmd, unsigned long arg); | 1227 | unsigned int cmd, unsigned long arg); |
1229 | extern long drm_compat_ioctl(struct file *filp, | 1228 | extern long drm_compat_ioctl(struct file *filp, |
@@ -1433,11 +1432,7 @@ extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data, | |||
1433 | struct drm_master *drm_master_create(struct drm_minor *minor); | 1432 | struct drm_master *drm_master_create(struct drm_minor *minor); |
1434 | extern struct drm_master *drm_master_get(struct drm_master *master); | 1433 | extern struct drm_master *drm_master_get(struct drm_master *master); |
1435 | extern void drm_master_put(struct drm_master **master); | 1434 | extern void drm_master_put(struct drm_master **master); |
1436 | extern int drm_get_pci_dev(struct pci_dev *pdev, | 1435 | |
1437 | const struct pci_device_id *ent, | ||
1438 | struct drm_driver *driver); | ||
1439 | extern int drm_get_platform_dev(struct platform_device *pdev, | ||
1440 | struct drm_driver *driver); | ||
1441 | extern void drm_put_dev(struct drm_device *dev); | 1436 | extern void drm_put_dev(struct drm_device *dev); |
1442 | extern int drm_put_minor(struct drm_minor **minor); | 1437 | extern int drm_put_minor(struct drm_minor **minor); |
1443 | extern unsigned int drm_debug; | 1438 | extern unsigned int drm_debug; |
@@ -1628,11 +1623,21 @@ static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, | |||
1628 | return NULL; | 1623 | return NULL; |
1629 | } | 1624 | } |
1630 | 1625 | ||
1631 | static __inline__ int drm_device_is_agp(struct drm_device *dev) | 1626 | static __inline__ void drm_core_dropmap(struct drm_local_map *map) |
1632 | { | 1627 | { |
1633 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | 1628 | } |
1634 | return 0; | 1629 | |
1630 | #include "drm_mem_util.h" | ||
1635 | 1631 | ||
1632 | extern int drm_fill_in_dev(struct drm_device *dev, | ||
1633 | const struct pci_device_id *ent, | ||
1634 | struct drm_driver *driver); | ||
1635 | int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); | ||
1636 | /*@}*/ | ||
1637 | |||
1638 | /* PCI section */ | ||
1639 | static __inline__ int drm_pci_device_is_agp(struct drm_device *dev) | ||
1640 | { | ||
1636 | if (dev->driver->device_is_agp != NULL) { | 1641 | if (dev->driver->device_is_agp != NULL) { |
1637 | int err = (*dev->driver->device_is_agp) (dev); | 1642 | int err = (*dev->driver->device_is_agp) (dev); |
1638 | 1643 | ||
@@ -1644,35 +1649,26 @@ static __inline__ int drm_device_is_agp(struct drm_device *dev) | |||
1644 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); | 1649 | return pci_find_capability(dev->pdev, PCI_CAP_ID_AGP); |
1645 | } | 1650 | } |
1646 | 1651 | ||
1647 | static __inline__ int drm_device_is_pcie(struct drm_device *dev) | ||
1648 | { | ||
1649 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | ||
1650 | return 0; | ||
1651 | else | ||
1652 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); | ||
1653 | } | ||
1654 | 1652 | ||
1655 | static __inline__ void drm_core_dropmap(struct drm_local_map *map) | 1653 | static __inline__ int drm_pci_device_is_pcie(struct drm_device *dev) |
1656 | { | 1654 | { |
1655 | return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); | ||
1657 | } | 1656 | } |
1658 | 1657 | ||
1659 | #include "drm_mem_util.h" | ||
1660 | 1658 | ||
1661 | static inline void *drm_get_device(struct drm_device *dev) | 1659 | extern int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver); |
1662 | { | 1660 | extern void drm_pci_exit(struct drm_driver *driver, struct pci_driver *pdriver); |
1663 | if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) | 1661 | extern int drm_get_pci_dev(struct pci_dev *pdev, |
1664 | return dev->platformdev; | ||
1665 | else | ||
1666 | return dev->pdev; | ||
1667 | } | ||
1668 | |||
1669 | extern int drm_platform_init(struct drm_driver *driver); | ||
1670 | extern int drm_pci_init(struct drm_driver *driver); | ||
1671 | extern int drm_fill_in_dev(struct drm_device *dev, | ||
1672 | const struct pci_device_id *ent, | 1662 | const struct pci_device_id *ent, |
1673 | struct drm_driver *driver); | 1663 | struct drm_driver *driver); |
1674 | int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type); | 1664 | |
1675 | /*@}*/ | 1665 | |
1666 | /* platform section */ | ||
1667 | extern int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device); | ||
1668 | extern void drm_platform_exit(struct drm_driver *driver, struct platform_device *platform_device); | ||
1669 | |||
1670 | extern int drm_get_platform_dev(struct platform_device *pdev, | ||
1671 | struct drm_driver *driver); | ||
1676 | 1672 | ||
1677 | #endif /* __KERNEL__ */ | 1673 | #endif /* __KERNEL__ */ |
1678 | #endif | 1674 | #endif |