Linux Audio

Check our new training course

Loading...
v5.4
  1/*
  2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
  3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
  4 *
  5 * Permission is hereby granted, free of charge, to any person obtaining a
  6 * copy of this software and associated documentation files (the "Software"),
  7 * to deal in the Software without restriction, including without limitation
  8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
  9 * and/or sell copies of the Software, and to permit persons to whom the
 10 * Software is furnished to do so, subject to the following conditions:
 11 *
 12 * The above copyright notice and this permission notice (including the
 13 * next paragraph) shall be included in all copies or substantial portions
 14 * of the Software.
 15 *
 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 22 * DEALINGS IN THE SOFTWARE.
 23 */
 24
 
 
 25#include <drm/drm_device.h>
 26#include <drm/drm_pci.h>
 27#include <drm/drm_vblank.h>
 28#include <drm/via_drm.h>
 29
 30#include "via_drv.h"
 31
 32static int via_do_init_map(struct drm_device *dev, drm_via_init_t *init)
 33{
 34	drm_via_private_t *dev_priv = dev->dev_private;
 35
 36	DRM_DEBUG("\n");
 37
 38	dev_priv->sarea = drm_legacy_getsarea(dev);
 39	if (!dev_priv->sarea) {
 40		DRM_ERROR("could not find sarea!\n");
 41		dev->dev_private = (void *)dev_priv;
 42		via_do_cleanup_map(dev);
 43		return -EINVAL;
 44	}
 45
 46	dev_priv->fb = drm_legacy_findmap(dev, init->fb_offset);
 47	if (!dev_priv->fb) {
 48		DRM_ERROR("could not find framebuffer!\n");
 49		dev->dev_private = (void *)dev_priv;
 50		via_do_cleanup_map(dev);
 51		return -EINVAL;
 52	}
 53	dev_priv->mmio = drm_legacy_findmap(dev, init->mmio_offset);
 54	if (!dev_priv->mmio) {
 55		DRM_ERROR("could not find mmio region!\n");
 56		dev->dev_private = (void *)dev_priv;
 57		via_do_cleanup_map(dev);
 58		return -EINVAL;
 59	}
 60
 61	dev_priv->sarea_priv =
 62	    (drm_via_sarea_t *) ((u8 *) dev_priv->sarea->handle +
 63				 init->sarea_priv_offset);
 64
 65	dev_priv->agpAddr = init->agpAddr;
 66
 67	via_init_futex(dev_priv);
 68
 69	via_init_dmablit(dev);
 70
 71	dev->dev_private = (void *)dev_priv;
 72	return 0;
 73}
 74
 75int via_do_cleanup_map(struct drm_device *dev)
 76{
 77	via_dma_cleanup(dev);
 78
 79	return 0;
 80}
 81
 82int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
 83{
 84	drm_via_init_t *init = data;
 85
 86	DRM_DEBUG("\n");
 87
 88	switch (init->func) {
 89	case VIA_INIT_MAP:
 90		return via_do_init_map(dev, init);
 91	case VIA_CLEANUP_MAP:
 92		return via_do_cleanup_map(dev);
 93	}
 94
 95	return -EINVAL;
 96}
 97
 98int via_driver_load(struct drm_device *dev, unsigned long chipset)
 99{
 
100	drm_via_private_t *dev_priv;
101	int ret = 0;
102
103	dev_priv = kzalloc(sizeof(drm_via_private_t), GFP_KERNEL);
104	if (dev_priv == NULL)
105		return -ENOMEM;
106
107	idr_init(&dev_priv->object_idr);
108	dev->dev_private = (void *)dev_priv;
109
110	dev_priv->chipset = chipset;
111
112	pci_set_master(dev->pdev);
113
114	ret = drm_vblank_init(dev, 1);
115	if (ret) {
116		kfree(dev_priv);
117		return ret;
118	}
119
120	return 0;
121}
122
123void via_driver_unload(struct drm_device *dev)
124{
125	drm_via_private_t *dev_priv = dev->dev_private;
126
127	idr_destroy(&dev_priv->object_idr);
128
129	kfree(dev_priv);
130}
v5.14.15
  1/*
  2 * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
  3 * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
  4 *
  5 * Permission is hereby granted, free of charge, to any person obtaining a
  6 * copy of this software and associated documentation files (the "Software"),
  7 * to deal in the Software without restriction, including without limitation
  8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
  9 * and/or sell copies of the Software, and to permit persons to whom the
 10 * Software is furnished to do so, subject to the following conditions:
 11 *
 12 * The above copyright notice and this permission notice (including the
 13 * next paragraph) shall be included in all copies or substantial portions
 14 * of the Software.
 15 *
 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 19 * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 22 * DEALINGS IN THE SOFTWARE.
 23 */
 24
 25#include <linux/pci.h>
 26
 27#include <drm/drm_device.h>
 
 28#include <drm/drm_vblank.h>
 29#include <drm/via_drm.h>
 30
 31#include "via_drv.h"
 32
 33static int via_do_init_map(struct drm_device *dev, drm_via_init_t *init)
 34{
 35	drm_via_private_t *dev_priv = dev->dev_private;
 36
 37	DRM_DEBUG("\n");
 38
 39	dev_priv->sarea = drm_legacy_getsarea(dev);
 40	if (!dev_priv->sarea) {
 41		DRM_ERROR("could not find sarea!\n");
 42		dev->dev_private = (void *)dev_priv;
 43		via_do_cleanup_map(dev);
 44		return -EINVAL;
 45	}
 46
 47	dev_priv->fb = drm_legacy_findmap(dev, init->fb_offset);
 48	if (!dev_priv->fb) {
 49		DRM_ERROR("could not find framebuffer!\n");
 50		dev->dev_private = (void *)dev_priv;
 51		via_do_cleanup_map(dev);
 52		return -EINVAL;
 53	}
 54	dev_priv->mmio = drm_legacy_findmap(dev, init->mmio_offset);
 55	if (!dev_priv->mmio) {
 56		DRM_ERROR("could not find mmio region!\n");
 57		dev->dev_private = (void *)dev_priv;
 58		via_do_cleanup_map(dev);
 59		return -EINVAL;
 60	}
 61
 62	dev_priv->sarea_priv =
 63	    (drm_via_sarea_t *) ((u8 *) dev_priv->sarea->handle +
 64				 init->sarea_priv_offset);
 65
 66	dev_priv->agpAddr = init->agpAddr;
 67
 68	via_init_futex(dev_priv);
 69
 70	via_init_dmablit(dev);
 71
 72	dev->dev_private = (void *)dev_priv;
 73	return 0;
 74}
 75
 76int via_do_cleanup_map(struct drm_device *dev)
 77{
 78	via_dma_cleanup(dev);
 79
 80	return 0;
 81}
 82
 83int via_map_init(struct drm_device *dev, void *data, struct drm_file *file_priv)
 84{
 85	drm_via_init_t *init = data;
 86
 87	DRM_DEBUG("\n");
 88
 89	switch (init->func) {
 90	case VIA_INIT_MAP:
 91		return via_do_init_map(dev, init);
 92	case VIA_CLEANUP_MAP:
 93		return via_do_cleanup_map(dev);
 94	}
 95
 96	return -EINVAL;
 97}
 98
 99int via_driver_load(struct drm_device *dev, unsigned long chipset)
100{
101	struct pci_dev *pdev = to_pci_dev(dev->dev);
102	drm_via_private_t *dev_priv;
103	int ret = 0;
104
105	dev_priv = kzalloc(sizeof(drm_via_private_t), GFP_KERNEL);
106	if (dev_priv == NULL)
107		return -ENOMEM;
108
109	idr_init(&dev_priv->object_idr);
110	dev->dev_private = (void *)dev_priv;
111
112	dev_priv->chipset = chipset;
113
114	pci_set_master(pdev);
115
116	ret = drm_vblank_init(dev, 1);
117	if (ret) {
118		kfree(dev_priv);
119		return ret;
120	}
121
122	return 0;
123}
124
125void via_driver_unload(struct drm_device *dev)
126{
127	drm_via_private_t *dev_priv = dev->dev_private;
128
129	idr_destroy(&dev_priv->object_idr);
130
131	kfree(dev_priv);
132}