via_drv.c revision 296373
1154941Sjhb/* via_drv.c -- VIA unichrome driver -*- linux-c -*-
2154941Sjhb * Created: Fri Aug 12 2005 by anholt@FreeBSD.org
3154941Sjhb */
4154941Sjhb/*-
5154941Sjhb * Copyright 2005 Eric Anholt
6154941Sjhb * All Rights Reserved.
7154941Sjhb *
8154941Sjhb * Permission is hereby granted, free of charge, to any person obtaining a
9154941Sjhb * copy of this software and associated documentation files (the "Software"),
10154941Sjhb * to deal in the Software without restriction, including without limitation
11154941Sjhb * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12154941Sjhb * and/or sell copies of the Software, and to permit persons to whom the
13154941Sjhb * Software is furnished to do so, subject to the following conditions:
14154941Sjhb *
15154941Sjhb * The above copyright notice and this permission notice (including the next
16154941Sjhb * paragraph) shall be included in all copies or substantial portions of the
17154941Sjhb * Software.
18154941Sjhb *
19154941Sjhb * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20154941Sjhb * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21154941Sjhb * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22154941Sjhb * ERIC ANHOLT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23154941Sjhb * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24154941Sjhb * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25154941Sjhb *
26154941Sjhb * Authors:
27154941Sjhb *    Eric Anholt <anholt@FreeBSD.org>
28154941Sjhb *
29154941Sjhb */
30154941Sjhb
31154941Sjhb#include <sys/cdefs.h>
32154941Sjhb__FBSDID("$FreeBSD: releng/10.3/sys/dev/drm/via_drv.c 203288 2010-01-31 14:30:39Z rnoland $");
33154941Sjhb
34154941Sjhb#include "dev/drm/drmP.h"
35154941Sjhb#include "dev/drm/drm.h"
36154941Sjhb#include "dev/drm/via_drm.h"
37154941Sjhb#include "dev/drm/via_drv.h"
38192853Ssson#include "dev/drm/drm_pciids.h"
39167801Sjhb
40154941Sjhb/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
41154941Sjhbstatic drm_pci_id_list_t via_pciidlist[] = {
42154941Sjhb	viadrv_PCI_IDS
43177912Sjeff};
44154941Sjhb
45154941Sjhbstatic void via_configure(struct drm_device *dev)
46154941Sjhb{
47154941Sjhb	dev->driver->driver_features =
48177912Sjeff	    DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_HAVE_IRQ;
49154941Sjhb
50154941Sjhb	dev->driver->buf_priv_size	= sizeof(drm_via_private_t);
51171516Sattilio	dev->driver->load		= via_driver_load;
52154941Sjhb	dev->driver->unload		= via_driver_unload;
53154941Sjhb	dev->driver->lastclose		= via_lastclose;
54167801Sjhb	dev->driver->get_vblank_counter	= via_get_vblank_counter;
55167801Sjhb	dev->driver->enable_vblank	= via_enable_vblank;
56167801Sjhb	dev->driver->disable_vblank	= via_disable_vblank;
57167801Sjhb	dev->driver->irq_preinstall	= via_driver_irq_preinstall;
58177912Sjeff	dev->driver->irq_postinstall	= via_driver_irq_postinstall;
59177912Sjeff	dev->driver->irq_uninstall	= via_driver_irq_uninstall;
60177912Sjeff	dev->driver->irq_handler	= via_driver_irq_handler;
61177912Sjeff	dev->driver->dma_quiescent	= via_driver_dma_quiescent;
62177912Sjeff
63177912Sjeff	dev->driver->ioctls		= via_ioctls;
64177912Sjeff	dev->driver->max_ioctl		= via_max_ioctl;
65177912Sjeff
66154941Sjhb	dev->driver->name		= DRIVER_NAME;
67154941Sjhb	dev->driver->desc		= DRIVER_DESC;
68154941Sjhb	dev->driver->date		= DRIVER_DATE;
69154941Sjhb	dev->driver->major		= DRIVER_MAJOR;
70154941Sjhb	dev->driver->minor		= DRIVER_MINOR;
71173733Sattilio	dev->driver->patchlevel		= DRIVER_PATCHLEVEL;
72167368Sjhb}
73192853Ssson
74192853Sssonstatic int
75192853Sssonvia_probe(device_t kdev)
76167368Sjhb{
77154941Sjhb	return drm_probe(kdev, via_pciidlist);
78154941Sjhb}
79167365Sjhb
80167365Sjhbstatic int
81173733Sattiliovia_attach(device_t kdev)
82154941Sjhb{
83167365Sjhb	struct drm_device *dev = device_get_softc(kdev);
84154941Sjhb
85167368Sjhb	dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
86167368Sjhb	    M_WAITOK | M_ZERO);
87192853Ssson
88192853Ssson	via_configure(dev);
89192853Ssson
90154941Sjhb	return drm_attach(kdev, via_pciidlist);
91154941Sjhb}
92157826Sjhb
93157826Sjhbstatic int
94157826Sjhbvia_detach(device_t kdev)
95157826Sjhb{
96157826Sjhb	struct drm_device *dev = device_get_softc(kdev);
97154941Sjhb	int ret;
98154941Sjhb
99154941Sjhb	ret = drm_detach(kdev);
100157826Sjhb
101171052Sattilio	free(dev->driver, DRM_MEM_DRIVER);
102171052Sattilio
103171052Sattilio	return ret;
104171052Sattilio}
105171052Sattilio
106171052Sattiliostatic device_method_t via_methods[] = {
107171052Sattilio	/* Device interface */
108171052Sattilio	DEVMETHOD(device_probe,		via_probe),
109171052Sattilio	DEVMETHOD(device_attach,	via_attach),
110171052Sattilio	DEVMETHOD(device_detach,	via_detach),
111171052Sattilio
112157826Sjhb	{ 0, 0 }
113157826Sjhb};
114157826Sjhb
115157826Sjhbstatic driver_t via_driver = {
116157826Sjhb	"drm",
117157826Sjhb	via_methods,
118154941Sjhb	sizeof(struct drm_device)
119154941Sjhb};
120154941Sjhb
121154941Sjhbextern devclass_t drm_devclass;
122154941SjhbDRIVER_MODULE(via, vgapci, via_driver, drm_devclass, 0, 0);
123173733SattilioMODULE_DEPEND(via, drm, 1, 1, 1);
124173733Sattilio