From nobody@FreeBSD.org  Thu Apr 13 16:33:04 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 87E4F16A403
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 13 Apr 2006 16:33:04 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4F9D743D46
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 13 Apr 2006 16:33:04 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k3DGX4fn028427
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 13 Apr 2006 16:33:04 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k3DGX4dq028426;
	Thu, 13 Apr 2006 16:33:04 GMT
	(envelope-from nobody)
Message-Id: <200604131633.k3DGX4dq028426@www.freebsd.org>
Date: Thu, 13 Apr 2006 16:33:04 GMT
From: Dmitriy Marchenko <_pppp@mail.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: i915 DRI driver doesn't work
X-Send-Pr-Version: www-2.3

>Number:         95703
>Category:       kern
>Synopsis:       i915 DRI driver doesn't work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    anholt
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 13 16:40:14 GMT 2006
>Closed-Date:    Sat May 20 19:24:28 GMT 2006
>Last-Modified:  Sat May 20 19:24:28 GMT 2006
>Originator:     Dmitriy Marchenko
>Release:        RELENG_6
>Organization:
AGAVA Software
>Environment:
FreeBSD pppp.home 6.1-RC FreeBSD 6.1-RC #1: Wed Apr 12 00:54:24 MSD 2006     root@pppp.home:/home/tmp/usr/obj/home/tmp/usr/src/sys/PPPP  i386

>Description:
Eric Anholt commited the i915 DRI driver to RELENG_6. I was one of the testers last autumn. The driver doesn't actually work without a patch (provided in the "Fix" section). It would be a nice idea to have a working driver in 6.1 release; not only announce the new feature which doesn't actually work.
>How-To-Repeat:
Run X server on any modern Intel integrated graphics card.
The driver will attach as /dev/dri/card1 instead of /dev/dri/card0 and hardware acceleration won't work.
>Fix:
Apply the following patch:

diff -ur dev/drm.orig/drm_drv.c dev/drm/drm_drv.c
--- dev/drm.orig/drm_drv.c      Wed Nov 30 16:22:19 2005
+++ dev/drm/drm_drv.c   Wed Nov 30 18:08:54 2005
@@ -149,9 +149,15 @@
 {
        drm_pci_id_list_t *id_entry;
        int vendor, device;
+       device_t realdev;

-       vendor = pci_get_vendor(dev);
-       device = pci_get_device(dev);
+       if (!strcmp(device_get_name(dev), "drmsub"))
+               realdev = device_get_parent(dev);
+       else
+               realdev = dev;
+
+       vendor = pci_get_vendor(realdev);
+       device = pci_get_device(realdev);

        id_entry = drm_find_description(vendor, device, idlist);
        if (id_entry != NULL) {
@@ -167,14 +173,17 @@
        drm_device_t *dev;
        drm_pci_id_list_t *id_entry;
        int unit;
+       int subdevice = 0;
+       device_t parentdev = device_get_parent( nbdev );

        unit = device_get_unit(nbdev);
        dev = device_get_softc(nbdev);

-       if (!strcmp(device_get_name(nbdev), "drmsub"))
-               dev->device = device_get_parent(nbdev);
-       else
-               dev->device = nbdev;
+       if (!strcmp(device_get_name(nbdev), "drmsub")) {
+               parentdev = device_get_parent(nbdev);
+               subdevice = 1;
+       }
+       dev->device = subdevice ? parentdev : nbdev;

        dev->devnode = make_dev(&drm_cdevsw,
                        unit,
@@ -186,8 +195,9 @@
        mtx_init(&dev->dev_lock, "drm device", NULL, MTX_DEF);
 #endif

-       id_entry = drm_find_description(pci_get_vendor(nbdev),
-           pci_get_device(nbdev), idlist);
+       id_entry = drm_find_description(
+                       pci_get_vendor(subdevice ? parentdev : nbdev),
+                       pci_get_device(subdevice ? parentdev : nbdev), idlist);
        dev->id_entry = id_entry;

        return drm_load(dev);
@@ -519,8 +529,9 @@
        }

        if (dev->driver.use_agp) {
-               if (drm_device_is_agp(dev))
-                       dev->agp = drm_agp_init();
+               if (drm_device_is_agp(dev) ||
+                       !strcmp(device_get_name(dev->device), "agp"))
+                               dev->agp = drm_agp_init();
                if (dev->driver.require_agp && dev->agp == NULL) {
                        DRM_ERROR("Card isn't AGP, or couldn't initialize "
                            "AGP.\n");
diff -ur dev/drm.orig/i915_drv.c dev/drm/i915_drv.c
--- dev/drm.orig/i915_drv.c     Wed Nov 30 16:22:19 2005
+++ dev/drm/i915_drv.c  Wed Nov 30 16:28:20 2005
@@ -104,7 +104,7 @@
 };

 extern devclass_t drm_devclass;
-DRIVER_MODULE(i915, pci, i915_driver, drm_devclass, 0, 0);
+DRIVER_MODULE(i915, agp, i915_driver, drm_devclass, 0, 0);
 MODULE_DEPEND(i915, drm, 1, 1, 1);

 #elif defined(__NetBSD__) || defined(__OpenBSD__)


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->anholt 
Responsible-Changed-By: matteo 
Responsible-Changed-When: Fri Apr 14 07:34:39 UTC 2006 
Responsible-Changed-Why:  
Assign to DRI maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95703 
State-Changed-From-To: open->closed 
State-Changed-By: anholt 
State-Changed-When: Sat May 20 19:24:10 UTC 2006 
State-Changed-Why:  
With the merge I committed this week, i915 works for me now. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=95703 
>Unformatted:
