aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2006-01-02 04:14:23 -0500
committerDave Airlie <airlied@linux.ie>2006-01-02 04:14:23 -0500
commit0d6aa60b4ac9689b750e35cd66f5d7c053aff0f4 (patch)
treedfc0d9ddfb139df8612e1823f9af89a6ff000a31 /drivers/char/drm
parentf0c408b564ddefa0959ada4e2c2248f4a57f1842 (diff)
drm: update to i915 1.3.0
Add support for vblank ioctls to i915 driver From: Dave Airlie <airlied@linux.ie> Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm')
-rw-r--r--drivers/char/drm/i915_dma.c12
-rw-r--r--drivers/char/drm/i915_drm.h6
-rw-r--r--drivers/char/drm/i915_drv.c7
-rw-r--r--drivers/char/drm/i915_drv.h39
-rw-r--r--drivers/char/drm/i915_irq.c48
-rw-r--r--drivers/char/drm/i915_mem.c5
6 files changed, 78 insertions, 39 deletions
diff --git a/drivers/char/drm/i915_dma.c b/drivers/char/drm/i915_dma.c
index 6cc3584e367f..9140703da1ba 100644
--- a/drivers/char/drm/i915_dma.c
+++ b/drivers/char/drm/i915_dma.c
@@ -1,7 +1,6 @@
1/* i915_dma.c -- DMA support for the I915 -*- linux-c -*- 1/* i915_dma.c -- DMA support for the I915 -*- linux-c -*-
2 */ 2 */
3/************************************************************************** 3/*
4 *
5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 4 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * All Rights Reserved. 5 * All Rights Reserved.
7 * 6 *
@@ -25,7 +24,7 @@
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * 26 *
28 **************************************************************************/ 27 */
29 28
30#include "drmP.h" 29#include "drmP.h"
31#include "drm.h" 30#include "drm.h"
@@ -196,7 +195,7 @@ static int i915_initialize(drm_device_t * dev,
196 return 0; 195 return 0;
197} 196}
198 197
199static int i915_resume(drm_device_t * dev) 198static int i915_dma_resume(drm_device_t * dev)
200{ 199{
201 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 200 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
202 201
@@ -253,7 +252,7 @@ static int i915_dma_init(DRM_IOCTL_ARGS)
253 retcode = i915_dma_cleanup(dev); 252 retcode = i915_dma_cleanup(dev);
254 break; 253 break;
255 case I915_RESUME_DMA: 254 case I915_RESUME_DMA:
256 retcode = i915_resume(dev); 255 retcode = i915_dma_resume(dev);
257 break; 256 break;
258 default: 257 default:
259 retcode = -EINVAL; 258 retcode = -EINVAL;
@@ -654,6 +653,9 @@ static int i915_getparam(DRM_IOCTL_ARGS)
654 case I915_PARAM_ALLOW_BATCHBUFFER: 653 case I915_PARAM_ALLOW_BATCHBUFFER:
655 value = dev_priv->allow_batchbuffer ? 1 : 0; 654 value = dev_priv->allow_batchbuffer ? 1 : 0;
656 break; 655 break;
656 case I915_PARAM_LAST_DISPATCH:
657 value = READ_BREADCRUMB(dev_priv);
658 break;
657 default: 659 default:
658 DRM_ERROR("Unkown parameter %d\n", param.param); 660 DRM_ERROR("Unkown parameter %d\n", param.param);
659 return DRM_ERR(EINVAL); 661 return DRM_ERR(EINVAL);
diff --git a/drivers/char/drm/i915_drm.h b/drivers/char/drm/i915_drm.h
index 23e027d29080..77412ddac007 100644
--- a/drivers/char/drm/i915_drm.h
+++ b/drivers/char/drm/i915_drm.h
@@ -1,5 +1,4 @@
1/************************************************************************** 1/*
2 *
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 2 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved. 3 * All Rights Reserved.
5 * 4 *
@@ -23,7 +22,7 @@
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * 24 *
26 **************************************************************************/ 25 */
27 26
28#ifndef _I915_DRM_H_ 27#ifndef _I915_DRM_H_
29#define _I915_DRM_H_ 28#define _I915_DRM_H_
@@ -152,6 +151,7 @@ typedef struct drm_i915_irq_wait {
152 */ 151 */
153#define I915_PARAM_IRQ_ACTIVE 1 152#define I915_PARAM_IRQ_ACTIVE 1
154#define I915_PARAM_ALLOW_BATCHBUFFER 2 153#define I915_PARAM_ALLOW_BATCHBUFFER 2
154#define I915_PARAM_LAST_DISPATCH 3
155 155
156typedef struct drm_i915_getparam { 156typedef struct drm_i915_getparam {
157 int param; 157 int param;
diff --git a/drivers/char/drm/i915_drv.c b/drivers/char/drm/i915_drv.c
index e88d32d286f5..8e2e6095c4b3 100644
--- a/drivers/char/drm/i915_drv.c
+++ b/drivers/char/drm/i915_drv.c
@@ -1,6 +1,6 @@
1/* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*- 1/* i915_drv.c -- i830,i845,i855,i865,i915 driver -*- linux-c -*-
2 */ 2 */
3/************************************************************************** 3/*
4 * 4 *
5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * All Rights Reserved. 6 * All Rights Reserved.
@@ -25,7 +25,7 @@
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * 27 *
28 **************************************************************************/ 28 */
29 29
30#include "drmP.h" 30#include "drmP.h"
31#include "drm.h" 31#include "drm.h"
@@ -44,11 +44,12 @@ static struct drm_driver driver = {
44 */ 44 */
45 .driver_features = 45 .driver_features =
46 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/ 46 DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/
47 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED, 47 DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_IRQ_VBL,
48 .load = i915_driver_load, 48 .load = i915_driver_load,
49 .lastclose = i915_driver_lastclose, 49 .lastclose = i915_driver_lastclose,
50 .preclose = i915_driver_preclose, 50 .preclose = i915_driver_preclose,
51 .device_is_agp = i915_driver_device_is_agp, 51 .device_is_agp = i915_driver_device_is_agp,
52 .vblank_wait = i915_driver_vblank_wait,
52 .irq_preinstall = i915_driver_irq_preinstall, 53 .irq_preinstall = i915_driver_irq_preinstall,
53 .irq_postinstall = i915_driver_irq_postinstall, 54 .irq_postinstall = i915_driver_irq_postinstall,
54 .irq_uninstall = i915_driver_irq_uninstall, 55 .irq_uninstall = i915_driver_irq_uninstall,
diff --git a/drivers/char/drm/i915_drv.h b/drivers/char/drm/i915_drv.h
index cd4f5227d0ea..c6c71b45f101 100644
--- a/drivers/char/drm/i915_drv.h
+++ b/drivers/char/drm/i915_drv.h
@@ -1,6 +1,6 @@
1/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*- 1/* i915_drv.h -- Private header for the I915 driver -*- linux-c -*-
2 */ 2 */
3/************************************************************************** 3/*
4 * 4 *
5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * All Rights Reserved. 6 * All Rights Reserved.
@@ -25,7 +25,7 @@
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * 27 *
28 **************************************************************************/ 28 */
29 29
30#ifndef _I915_DRV_H_ 30#ifndef _I915_DRV_H_
31#define _I915_DRV_H_ 31#define _I915_DRV_H_
@@ -37,21 +37,18 @@
37 37
38#define DRIVER_NAME "i915" 38#define DRIVER_NAME "i915"
39#define DRIVER_DESC "Intel Graphics" 39#define DRIVER_DESC "Intel Graphics"
40#define DRIVER_DATE "20040405" 40#define DRIVER_DATE "20051209"
41 41
42/* Interface history: 42/* Interface history:
43 * 43 *
44 * 1.1: Original. 44 * 1.1: Original.
45 * 1.2: Add Power Management
46 * 1.3: Add vblank support
45 */ 47 */
46#define DRIVER_MAJOR 1 48#define DRIVER_MAJOR 1
47#define DRIVER_MINOR 1 49#define DRIVER_MINOR 3
48#define DRIVER_PATCHLEVEL 0 50#define DRIVER_PATCHLEVEL 0
49 51
50/* We use our own dma mechanisms, not the drm template code. However,
51 * the shared IRQ code is useful to us:
52 */
53#define __HAVE_PM 1
54
55typedef struct _drm_i915_ring_buffer { 52typedef struct _drm_i915_ring_buffer {
56 int tail_mask; 53 int tail_mask;
57 unsigned long Start; 54 unsigned long Start;
@@ -97,6 +94,7 @@ typedef struct drm_i915_private {
97 int tex_lru_log_granularity; 94 int tex_lru_log_granularity;
98 int allow_batchbuffer; 95 int allow_batchbuffer;
99 struct mem_block *agp_heap; 96 struct mem_block *agp_heap;
97 unsigned int sr01, adpa, ppcr, dvob, dvoc, lvds;
100} drm_i915_private_t; 98} drm_i915_private_t;
101 99
102extern drm_ioctl_desc_t i915_ioctls[]; 100extern drm_ioctl_desc_t i915_ioctls[];
@@ -108,11 +106,14 @@ extern int i915_driver_load(struct drm_device *, unsigned long flags);
108extern void i915_driver_lastclose(drm_device_t * dev); 106extern void i915_driver_lastclose(drm_device_t * dev);
109extern void i915_driver_preclose(drm_device_t * dev, DRMFILE filp); 107extern void i915_driver_preclose(drm_device_t * dev, DRMFILE filp);
110extern int i915_driver_device_is_agp(drm_device_t * dev); 108extern int i915_driver_device_is_agp(drm_device_t * dev);
109extern long i915_compat_ioctl(struct file *filp, unsigned int cmd,
110 unsigned long arg);
111 111
112/* i915_irq.c */ 112/* i915_irq.c */
113extern int i915_irq_emit(DRM_IOCTL_ARGS); 113extern int i915_irq_emit(DRM_IOCTL_ARGS);
114extern int i915_irq_wait(DRM_IOCTL_ARGS); 114extern int i915_irq_wait(DRM_IOCTL_ARGS);
115 115
116extern int i915_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence);
116extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS); 117extern irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS);
117extern void i915_driver_irq_preinstall(drm_device_t * dev); 118extern void i915_driver_irq_preinstall(drm_device_t * dev);
118extern void i915_driver_irq_postinstall(drm_device_t * dev); 119extern void i915_driver_irq_postinstall(drm_device_t * dev);
@@ -126,13 +127,10 @@ extern void i915_mem_takedown(struct mem_block **heap);
126extern void i915_mem_release(drm_device_t * dev, 127extern void i915_mem_release(drm_device_t * dev,
127 DRMFILE filp, struct mem_block *heap); 128 DRMFILE filp, struct mem_block *heap);
128 129
129extern long i915_compat_ioctl(struct file *filp, unsigned int cmd, 130#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, (reg))
130 unsigned long arg); 131#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, (reg), (val))
131 132#define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, (reg))
132#define I915_READ(reg) DRM_READ32(dev_priv->mmio_map, reg) 133#define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, (reg), (val))
133#define I915_WRITE(reg,val) DRM_WRITE32(dev_priv->mmio_map, reg, val)
134#define I915_READ16(reg) DRM_READ16(dev_priv->mmio_map, reg)
135#define I915_WRITE16(reg,val) DRM_WRITE16(dev_priv->mmio_map, reg, val)
136 134
137#define I915_VERBOSE 0 135#define I915_VERBOSE 0
138 136
@@ -196,6 +194,13 @@ extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller);
196#define PPCR 0x61204 194#define PPCR 0x61204
197#define PPCR_ON (1<<0) 195#define PPCR_ON (1<<0)
198 196
197#define DVOB 0x61140
198#define DVOB_ON (1<<31)
199#define DVOC 0x61160
200#define DVOC_ON (1<<31)
201#define LVDS 0x61180
202#define LVDS_ON (1<<31)
203
199#define ADPA 0x61100 204#define ADPA 0x61100
200#define ADPA_DPMS_MASK (~(3<<10)) 205#define ADPA_DPMS_MASK (~(3<<10))
201#define ADPA_DPMS_ON (0<<10) 206#define ADPA_DPMS_ON (0<<10)
@@ -259,4 +264,6 @@ extern int i915_wait_ring(drm_device_t * dev, int n, const char *caller);
259 264
260#define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1) 265#define CMD_OP_DESTBUFFER_INFO ((0x3<<29)|(0x1d<<24)|(0x8e<<16)|1)
261 266
267#define READ_BREADCRUMB(dev_priv) (((u32 *)(dev_priv->hw_status_page))[5])
268
262#endif 269#endif
diff --git a/drivers/char/drm/i915_irq.c b/drivers/char/drm/i915_irq.c
index 4fa448ee846b..a1381c61aa63 100644
--- a/drivers/char/drm/i915_irq.c
+++ b/drivers/char/drm/i915_irq.c
@@ -1,7 +1,6 @@
1/* i915_dma.c -- DMA support for the I915 -*- linux-c -*- 1/* i915_irq.c -- IRQ support for the I915 -*- linux-c -*-
2 */ 2 */
3/************************************************************************** 3/*
4 *
5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 4 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * All Rights Reserved. 5 * All Rights Reserved.
7 * 6 *
@@ -25,16 +24,18 @@
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * 26 *
28 **************************************************************************/ 27 */
29 28
30#include "drmP.h" 29#include "drmP.h"
31#include "drm.h" 30#include "drm.h"
32#include "i915_drm.h" 31#include "i915_drm.h"
33#include "i915_drv.h" 32#include "i915_drv.h"
34 33
35#define USER_INT_FLAG 0x2 34#define USER_INT_FLAG (1<<1)
35#define VSYNC_PIPEB_FLAG (1<<5)
36#define VSYNC_PIPEA_FLAG (1<<7)
37
36#define MAX_NOPID ((u32)~0) 38#define MAX_NOPID ((u32)~0)
37#define READ_BREADCRUMB(dev_priv) (((u32*)(dev_priv->hw_status_page))[5])
38 39
39irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) 40irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
40{ 41{
@@ -43,7 +44,7 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
43 u16 temp; 44 u16 temp;
44 45
45 temp = I915_READ16(I915REG_INT_IDENTITY_R); 46 temp = I915_READ16(I915REG_INT_IDENTITY_R);
46 temp &= USER_INT_FLAG; 47 temp &= (USER_INT_FLAG | VSYNC_PIPEA_FLAG);
47 48
48 DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp); 49 DRM_DEBUG("%s flag=%08x\n", __FUNCTION__, temp);
49 50
@@ -51,7 +52,15 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
51 return IRQ_NONE; 52 return IRQ_NONE;
52 53
53 I915_WRITE16(I915REG_INT_IDENTITY_R, temp); 54 I915_WRITE16(I915REG_INT_IDENTITY_R, temp);
54 DRM_WAKEUP(&dev_priv->irq_queue); 55
56 if (temp & USER_INT_FLAG)
57 DRM_WAKEUP(&dev_priv->irq_queue);
58
59 if (temp & VSYNC_PIPEA_FLAG) {
60 atomic_inc(&dev->vbl_received);
61 DRM_WAKEUP(&dev->vbl_queue);
62 drm_vbl_send_signals(dev);
63 }
55 64
56 return IRQ_HANDLED; 65 return IRQ_HANDLED;
57} 66}
@@ -102,6 +111,27 @@ static int i915_wait_irq(drm_device_t * dev, int irq_nr)
102 return ret; 111 return ret;
103} 112}
104 113
114int i915_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence)
115{
116 drm_i915_private_t *dev_priv = dev->dev_private;
117 unsigned int cur_vblank;
118 int ret = 0;
119
120 if (!dev_priv) {
121 DRM_ERROR("%s called with no initialization\n", __FUNCTION__);
122 return DRM_ERR(EINVAL);
123 }
124
125 DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
126 (((cur_vblank = atomic_read(&dev->vbl_received))
127 - *sequence) <= (1<<23)));
128
129 *sequence = cur_vblank;
130
131 return ret;
132}
133
134
105/* Needs the lock as it touches the ring. 135/* Needs the lock as it touches the ring.
106 */ 136 */
107int i915_irq_emit(DRM_IOCTL_ARGS) 137int i915_irq_emit(DRM_IOCTL_ARGS)
@@ -165,7 +195,7 @@ void i915_driver_irq_postinstall(drm_device_t * dev)
165{ 195{
166 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private; 196 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
167 197
168 I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG); 198 I915_WRITE16(I915REG_INT_ENABLE_R, USER_INT_FLAG | VSYNC_PIPEA_FLAG);
169 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue); 199 DRM_INIT_WAITQUEUE(&dev_priv->irq_queue);
170} 200}
171 201
diff --git a/drivers/char/drm/i915_mem.c b/drivers/char/drm/i915_mem.c
index 13176d136a99..ba87ff17ff64 100644
--- a/drivers/char/drm/i915_mem.c
+++ b/drivers/char/drm/i915_mem.c
@@ -1,7 +1,6 @@
1/* i915_mem.c -- Simple agp/fb memory manager for i915 -*- linux-c -*- 1/* i915_mem.c -- Simple agp/fb memory manager for i915 -*- linux-c -*-
2 */ 2 */
3/************************************************************************** 3/*
4 *
5 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas. 4 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * All Rights Reserved. 5 * All Rights Reserved.
7 * 6 *
@@ -25,7 +24,7 @@
25 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * 26 *
28 **************************************************************************/ 27 */
29 28
30#include "drmP.h" 29#include "drmP.h"
31#include "drm.h" 30#include "drm.h"