aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drmP.h
diff options
context:
space:
mode:
authorJordan Crouse <jcrouse@codeaurora.org>2010-05-27 15:40:25 -0400
committerDave Airlie <airlied@redhat.com>2010-05-31 20:07:39 -0400
commitdcdb167402cbdca1d021bdfa5f63995ee0a79317 (patch)
tree3cd0ab1189d972b59daaaf863f518d7b94d2de7a /include/drm/drmP.h
parent01d73a6967f12fe6c4bbde1834a9fe662264a2eb (diff)
drm: Add support for platform devices to register as DRM devices
Allow platform devices without PCI resources to be DRM devices. [airlied: fixup warnings with dev pointers] Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include/drm/drmP.h')
-rw-r--r--include/drm/drmP.h52
1 files changed, 44 insertions, 8 deletions
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 8f7f5cb4a86d..6235169d5950 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -9,6 +9,7 @@
9/* 9/*
10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. 10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. 11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
12 * Copyright (c) 2009-2010, Code Aurora Forum.
12 * All rights reserved. 13 * All rights reserved.
13 * 14 *
14 * Permission is hereby granted, free of charge, to any person obtaining a 15 * Permission is hereby granted, free of charge, to any person obtaining a
@@ -48,6 +49,7 @@
48#include <linux/proc_fs.h> 49#include <linux/proc_fs.h>
49#include <linux/init.h> 50#include <linux/init.h>
50#include <linux/file.h> 51#include <linux/file.h>
52#include <linux/platform_device.h>
51#include <linux/pci.h> 53#include <linux/pci.h>
52#include <linux/jiffies.h> 54#include <linux/jiffies.h>
53#include <linux/smp_lock.h> /* For (un)lock_kernel */ 55#include <linux/smp_lock.h> /* For (un)lock_kernel */
@@ -144,6 +146,7 @@ extern void drm_ut_debug_printk(unsigned int request_level,
144#define DRIVER_IRQ_VBL2 0x800 146#define DRIVER_IRQ_VBL2 0x800
145#define DRIVER_GEM 0x1000 147#define DRIVER_GEM 0x1000
146#define DRIVER_MODESET 0x2000 148#define DRIVER_MODESET 0x2000
149#define DRIVER_USE_PLATFORM_DEVICE 0x4000
147 150
148/***********************************************************************/ 151/***********************************************************************/
149/** \name Begin the DRM... */ 152/** \name Begin the DRM... */
@@ -823,6 +826,7 @@ struct drm_driver {
823 int num_ioctls; 826 int num_ioctls;
824 struct file_operations fops; 827 struct file_operations fops;
825 struct pci_driver pci_driver; 828 struct pci_driver pci_driver;
829 struct platform_device *platform_device;
826 /* List of devices hanging off this driver */ 830 /* List of devices hanging off this driver */
827 struct list_head device_list; 831 struct list_head device_list;
828}; 832};
@@ -1015,12 +1019,16 @@ struct drm_device {
1015 1019
1016 struct drm_agp_head *agp; /**< AGP data */ 1020 struct drm_agp_head *agp; /**< AGP data */
1017 1021
1022 struct device *dev; /**< Device structure */
1018 struct pci_dev *pdev; /**< PCI device structure */ 1023 struct pci_dev *pdev; /**< PCI device structure */
1019 int pci_vendor; /**< PCI vendor id */ 1024 int pci_vendor; /**< PCI vendor id */
1020 int pci_device; /**< PCI device id */ 1025 int pci_device; /**< PCI device id */
1021#ifdef __alpha__ 1026#ifdef __alpha__
1022 struct pci_controller *hose; 1027 struct pci_controller *hose;
1023#endif 1028#endif
1029
1030 struct platform_device *platformdev; /**< Platform device struture */
1031
1024 struct drm_sg_mem *sg; /**< Scatter gather memory */ 1032 struct drm_sg_mem *sg; /**< Scatter gather memory */
1025 int num_crtcs; /**< Number of CRTCs on this device */ 1033 int num_crtcs; /**< Number of CRTCs on this device */
1026 void *dev_private; /**< device private data */ 1034 void *dev_private; /**< device private data */
@@ -1060,17 +1068,21 @@ struct drm_device {
1060 1068
1061}; 1069};
1062 1070
1063static inline int drm_dev_to_irq(struct drm_device *dev)
1064{
1065 return dev->pdev->irq;
1066}
1067
1068static __inline__ int drm_core_check_feature(struct drm_device *dev, 1071static __inline__ int drm_core_check_feature(struct drm_device *dev,
1069 int feature) 1072 int feature)
1070{ 1073{
1071 return ((dev->driver->driver_features & feature) ? 1 : 0); 1074 return ((dev->driver->driver_features & feature) ? 1 : 0);
1072} 1075}
1073 1076
1077
1078static inline int drm_dev_to_irq(struct drm_device *dev)
1079{
1080 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1081 return platform_get_irq(dev->platformdev, 0);
1082 else
1083 return dev->pdev->irq;
1084}
1085
1074#ifdef __alpha__ 1086#ifdef __alpha__
1075#define drm_get_pci_domain(dev) dev->hose->index 1087#define drm_get_pci_domain(dev) dev->hose->index
1076#else 1088#else
@@ -1347,8 +1359,11 @@ extern int drm_dropmaster_ioctl(struct drm_device *dev, void *data,
1347struct drm_master *drm_master_create(struct drm_minor *minor); 1359struct drm_master *drm_master_create(struct drm_minor *minor);
1348extern struct drm_master *drm_master_get(struct drm_master *master); 1360extern struct drm_master *drm_master_get(struct drm_master *master);
1349extern void drm_master_put(struct drm_master **master); 1361extern void drm_master_put(struct drm_master **master);
1350extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, 1362extern int drm_get_pci_dev(struct pci_dev *pdev,
1351 struct drm_driver *driver); 1363 const struct pci_device_id *ent,
1364 struct drm_driver *driver);
1365extern int drm_get_platform_dev(struct platform_device *pdev,
1366 struct drm_driver *driver);
1352extern void drm_put_dev(struct drm_device *dev); 1367extern void drm_put_dev(struct drm_device *dev);
1353extern int drm_put_minor(struct drm_minor **minor); 1368extern int drm_put_minor(struct drm_minor **minor);
1354extern unsigned int drm_debug; 1369extern unsigned int drm_debug;
@@ -1525,6 +1540,9 @@ static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev,
1525 1540
1526static __inline__ int drm_device_is_agp(struct drm_device *dev) 1541static __inline__ int drm_device_is_agp(struct drm_device *dev)
1527{ 1542{
1543 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1544 return 0;
1545
1528 if (dev->driver->device_is_agp != NULL) { 1546 if (dev->driver->device_is_agp != NULL) {
1529 int err = (*dev->driver->device_is_agp) (dev); 1547 int err = (*dev->driver->device_is_agp) (dev);
1530 1548
@@ -1538,7 +1556,10 @@ static __inline__ int drm_device_is_agp(struct drm_device *dev)
1538 1556
1539static __inline__ int drm_device_is_pcie(struct drm_device *dev) 1557static __inline__ int drm_device_is_pcie(struct drm_device *dev)
1540{ 1558{
1541 return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP); 1559 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1560 return 0;
1561 else
1562 return pci_find_capability(dev->pdev, PCI_CAP_ID_EXP);
1542} 1563}
1543 1564
1544static __inline__ void drm_core_dropmap(struct drm_local_map *map) 1565static __inline__ void drm_core_dropmap(struct drm_local_map *map)
@@ -1546,6 +1567,21 @@ static __inline__ void drm_core_dropmap(struct drm_local_map *map)
1546} 1567}
1547 1568
1548#include "drm_mem_util.h" 1569#include "drm_mem_util.h"
1570
1571static inline void *drm_get_device(struct drm_device *dev)
1572{
1573 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE))
1574 return dev->platformdev;
1575 else
1576 return dev->pdev;
1577}
1578
1579extern int drm_platform_init(struct drm_driver *driver);
1580extern int drm_pci_init(struct drm_driver *driver);
1581extern int drm_fill_in_dev(struct drm_device *dev,
1582 const struct pci_device_id *ent,
1583 struct drm_driver *driver);
1584int drm_get_minor(struct drm_device *dev, struct drm_minor **minor, int type);
1549/*@}*/ 1585/*@}*/
1550 1586
1551#endif /* __KERNEL__ */ 1587#endif /* __KERNEL__ */