I have extended the Linux 2.6 agpgart to support initializing multiple 
backends. 
The proposed drm<->agpgart interface provided by agp_backend.h
is included at the end. 

In my BK tree, I have modified the necessary agpgart, drm and video files so 
they should work using this new interface in the same way they do now for a 
single agp bridge. For example, 

from drivers/char/drm/drm_agpsupport.h:
int DRM(agp_acquire)(struct inode *inode, struct file *filp,
                     unsigned int cmd, unsigned long arg)
{
        drm_file_t       *priv   = filp->private_data;
        drm_device_t     *dev    = priv->dev;
        int              retcode;

        if (!dev->agp)
                return -ENODEV;
        if (dev->agp->acquired)
                return -EBUSY;
        if (!drm_agp->acquire)
                return -EINVAL;
        if ((retcode = drm_agp->acquire(NULL,NULL)))
                return retcode;
        dev->agp->acquired = 1;
        return 0;
}


or from drivers/video/intelfb/intelfbdrv.c:
        /* Use agpgart to manage the GATT */
        if (agp_backend_acquire(NULL, NULL)) {
                ERR_MSG("cannot acquire agp\n");
                cleanup(dinfo);
                return -ENODEV;
        }

        /* get the current gatt info */
        if (agp_copy_info(agp_bridge, &gtt_info)) {
                ERR_MSG("cannot get agp info\n");
                agp_backend_release(agp_bridge);
                cleanup(dinfo);
                return -ENODEV;
        }

The acquire function is the one most likely to require discussion.
Systems which support multiple bridges will call the acquire function
with the pci_dev structure for the particular agp bridge device and 
it will return an error code and a pointer to the agp_bridge_data struct.
When pci_dev is NULL, the acquire function will use the default agp_bridge
which corresponds to the first bridge detected and added to the list 
agp_bridges.

Let me know what you think about the proposed changes.

include/linux/agp_backend.h:
/*
 * AGPGART backend specific includes. Not for userspace consumption.
 *
 * Copyright (C) 2004 Silicon Graphics, Inc.
 * Copyright (C) 2002-2003 Dave Jones
 * Copyright (C) 1999 Jeff Hartmann
 * Copyright (C) 1999 Precision Insight, Inc.
 * Copyright (C) 1999 Xi Graphics, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * JEFF HARTMANN, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 
 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#ifndef _AGP_BACKEND_H
#define _AGP_BACKEND_H 1

#ifdef __KERNEL__

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif

enum chipset_type {
        NOT_SUPPORTED,
        SUPPORTED,
};

struct agp_version {
        u16 major;
        u16 minor;
};

struct agp_kern_info {
        struct agp_version version;
        struct pci_dev *device;
        enum chipset_type chipset;
        unsigned long mode;
        off_t aper_base;
        size_t aper_size;
        int max_memory;         /* In pages */
        int current_memory;
        int cant_use_aperture;
        unsigned long page_mask;
        struct vm_operations_struct *vm_ops;
};

/* 
 * The agp_memory structure has information about the block of agp memory
 * allocated.  A caller may manipulate the next and prev pointers to link
 * each allocated item into a list.  These pointers are ignored by the 
backend.
 * Everything else should never be written to, but the caller may read any of
 * the items to detrimine the status of this block of agp memory. 
 */

struct agp_memory {
        int key;
        struct agp_memory *next;
        struct agp_memory *prev;
        size_t page_count;
        int num_scratch_pages;
        unsigned long *memory;
        off_t pg_start;
        u32 type;
        u32 physical;
        u8 is_bound;
        u8 is_flushed;
};

#define AGP_NORMAL_MEMORY 0

typedef struct agp_bridge_data *agp_bridge_data_p;
extern agp_bridge_data_p agp_bridge;
extern struct list_head agp_bridges;

extern void agp_free_memory(agp_bridge_data_p, struct agp_memory *);
extern struct agp_memory *agp_allocate_memory(agp_bridge_data_p, size_t, u32);
extern int agp_copy_info(agp_bridge_data_p, struct agp_kern_info *);
extern int agp_bind_memory(agp_bridge_data_p, struct agp_memory *, off_t);
extern int agp_unbind_memory(agp_bridge_data_p, struct agp_memory *);
extern void agp_enable(agp_bridge_data_p, u32);
extern int agp_backend_acquire(struct pci_dev *, agp_bridge_data_p *);
extern void agp_backend_release(agp_bridge_data_p);

/*
 * Interface between drm and agp code.  When agp initializes, it makes
 * the below structure available via inter_module_register(), drm might
 * use it.  Keith Owens <[EMAIL PROTECTED]> 28 Oct 2000.
 */
typedef struct {
        void                    (*free_memory)(agp_bridge_data_p, struct 
agp_memory *);
        struct agp_memory *     (*allocate_memory)(agp_bridge_data_p, size_t, 
u32);
        int                     (*bind_memory)(agp_bridge_data_p, struct 
agp_memory *, off_t);
        int                     (*unbind_memory)(agp_bridge_data_p, struct 
agp_memory *);
        void                    (*enable)(agp_bridge_data_p, u32);
        int                     (*acquire)(struct pci_dev *, agp_bridge_data_p 
*);
        void                    (*release)(agp_bridge_data_p);
        int                     (*copy_info)(agp_bridge_data_p, struct 
agp_kern_info *);
} drm_agp_t;

extern const drm_agp_t *drm_agp_p;

#endif                          /* __KERNEL__ */
#endif                          /* _AGP_BACKEND_H */


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
--
_______________________________________________
Dri-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dri-devel

Reply via email to