summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux-2.6/Makefile429
-rw-r--r--linux-2.6/Makefile.kernel99
-rw-r--r--linux-2.6/drm_core.h44
-rw-r--r--linux-2.6/drm_sysfs.h (renamed from linux/drm_sysfs.h)0
-rw-r--r--linux-2.6/radeon_i2c.c (renamed from linux/radeon_i2c.c)0
-rw-r--r--linux-2.6/radeon_i2c.h (renamed from linux/radeon_gpl.h)2
-rw-r--r--linux-core/Makefile2
-rw-r--r--linux-core/Makefile.kernel2
-rw-r--r--linux-core/drm_core.h1
-rw-r--r--linux-core/drm_sysfs.c206
-rw-r--r--linux-core/radeon_i2c.c157
-rw-r--r--linux-core/radeon_i2c.h29
-rw-r--r--linux/Makefile2
-rw-r--r--linux/Makefile.kernel2
-rw-r--r--linux/drm_core.h1
-rw-r--r--shared-core/radeon_drv.h6
-rw-r--r--shared/radeon_drv.h6
17 files changed, 975 insertions, 13 deletions
diff --git a/linux-2.6/Makefile b/linux-2.6/Makefile
new file mode 100644
index 00000000..d39bddda
--- /dev/null
+++ b/linux-2.6/Makefile
@@ -0,0 +1,429 @@
+# Makefile -- For the Direct Rendering Manager module (drm)
+#
+# Based on David Woodhouse's mtd build.
+#
+# Modified to handle the DRM requirements and builds on a wider range of
+# platforms in a flexible way by David Dawes. It's not clear, however,
+# that this approach is simpler than the old one.
+#
+# The purpose of this Makefile is to handle setting up everything
+# needed for an out-of-kernel source build. Makefile.kernel contains
+# everything required for in-kernel source builds. It is included into
+# this file, so none of that should be duplicated here.
+#
+# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux,v 1.40 2003/08/17 17:12:25 dawes Exp $
+#
+
+#
+# By default, the build is done against the running linux kernel source.
+# To build against a different kernel source tree, set LINUXDIR:
+#
+# make LINUXDIR=/path/to/kernel/source
+
+#
+# To build only some modules, either set DRM_MODULES to the list of modules,
+# or specify the modules as targets:
+#
+# make r128.o radeon.o
+#
+# or:
+#
+# make DRM_MODULES="r128 radeon"
+#
+
+SHELL=/bin/sh
+
+.SUFFIXES:
+
+ifndef LINUXDIR
+RUNNING_REL := $(shell uname -r)
+
+LINUXDIR := $(shell if [ -e /lib/modules/$(RUNNING_REL)/source ]; then \
+ echo /lib/modules/$(RUNNING_REL)/source; \
+ else echo /lib/modules/$(RUNNING_REL)/build; fi)
+endif
+
+ifndef O
+O := $(LINUXDIR)
+endif
+
+MACHINE := $(shell uname -m)
+
+# Modules for all architectures
+MODULE_LIST := tdfx.o r128.o radeon.o mga.o sis.o savage.o via.o mach64.o
+
+# Modules only for ix86 architectures
+ifneq (,$(findstring 86,$(MACHINE)))
+ARCHX86 := 1
+MODULE_LIST += i830.o i810.o i915.o
+endif
+
+ifneq (,$(findstring sparc64,$(MACHINE)))
+ARCHSPARC64 := 1
+MODULE_LIST += ffb.o
+endif
+
+DRM_MODULES ?= $(MODULE_LIST)
+
+# These definitions are for handling dependencies in the out of kernel build.
+
+DRMTEMPLATES = drm_auth.h drm_bufs.h drm_context.h drm_dma.h drm_drawable.h \
+ drm_drv.h drm_fops.h drm_init.h drm_ioctl.h drm_irq.h \
+ drm_lock.h drm_memory.h drm_proc.h drm_stub.h drm_vm.h \
+ drm_sysfs.h drm_core.h
+
+DRMSHARED = drm.h drm_sarea.h
+DRMHEADERS = drmP.h $(DRMSHARED)
+
+L24SHARED = ati_pcigart.h drm_drawable.h drm_pci.h i810_dma.c i830_irq.c savage_dma.c \
+ Config.in drm_drv.h drmP.h i810_drm.h i915_drv.c savage_drm.h \
+ Doxyfile drm_fops.h drm_proc.h i810_drv.c Kconfig savage_drv.c \
+ drm_agpsupport.h drm_init.h drm_scatter.h i810_drv.h mach64_drv.c \
+ savage_drv.h drm_auth.h drm_ioctl.h drm_stub.h i810.h savage.h \
+ drm_bufs.h drm_irq.h drm_vm.h i830_dma.c drm_compat.h drm_lock.h \
+ ffb_context.c i830_drm.h mga_drv.c sis_drv.c drm_context.h \
+ drm_memory_debug.h ffb_drv.c i830_drv.c r128_drv.c tdfx_drv.c \
+ drm_memory.h ffb_drv.h i830_drv.h radeon_drv.c \
+ drm_dma.h drm_os_linux.h ffb.h i830.h README.drm
+
+
+TDFXHEADERS = tdfx.h $(DRMHEADERS) $(DRMTEMPLATES)
+TDFXSHARED = tdfx.h
+R128HEADERS = r128.h r128_drv.h r128_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
+R128SHARED = r128.h r128_drv.h r128_drm.h r128_cce.c r128_state.c r128_irq.c
+RADEONHEADERS = radeon.h radeon_drv.h radeon_drm.h $(DRMHEADERS) \
+ $(DRMTEMPLATES)
+RADEONSHARED = radeon.h radeon_drv.h radeon_drm.h radeon_cp.c radeon_irq.c \
+ radeon_mem.c radeon_state.c
+MGAHEADERS = mga.h mga_drv.h mga_drm.h mga_ucode.h $(DRMHEADERS) \
+ $(DRMTEMPLATES)
+MGASHARED = mga.h mga_dma.c mga_drm.h mga_drv.h mga_irq.c mga_state.c \
+ mga_ucode.h mga_warp.c
+I810HEADERS = i810.h i810_drv.h i810_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
+I830HEADERS = i830.h i830_drv.h i830_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
+I915HEADERS = i915.h i915_drv.h i915_drm.h $(DRMHEADERS) $(DRMTEMPLATES)
+I915SHARED = i915.h i915_drv.h i915_drm.h i915_irq.c i915_mem.c i915_dma.c
+SISHEADERS= sis.h sis_drv.h sis_drm.h $(DRMHEADERS)
+SISSHARED= sis.h sis_drv.h sis_drm.h sis_ds.c sis_ds.h sis_mm.c
+SAVAGEHEADERS= savage.h savage_drv.h savage_drm.h $(DRMHEADERS) \
+ $(DRMTEMPLATES)
+VIAHEADERS = via_drm.h via_drv.h via.h via_mm.h via_ds.h \
+ via_3d_reg.h $(DRMHEADERS) $(DRMTEMPLATES)
+VIASHARED = via_drm.h via_drv.h via.h via_mm.h via_ds.h \
+ via_3d_reg.h via_drv.c via_ds.c via_irq.c via_map.c \
+ via_mm.c via_dma.c
+MACH64HEADERS = mach64.h mach64_drv.h mach64_drm.h $(DRMHEADERS) \
+ $(DRMTEMPLATES)
+MACH64SHARED = mach64.h mach64_drv.h mach64_drm.h mach64_dma.c \
+ mach64_irq.c mach64_state.c
+FFBHEADERS = ffb.h ffb_drv.h $(DRMHEADERS) $(DRMTEMPLATES)
+
+SHAREDSRC = $(DRMSHARED) $(MGASHARED) $(R128SHARED) $(RADEONSHARED) \
+ $(SISSHARED) $(TDFXSHARED) $(VIASHARED) $(MACH64SHARED) \
+ $(I915SHARED)
+
+PROGS = dristat drmstat
+
+CLEANFILES = *.o *.ko $(PROGS) .depend .*.flags .*.d .*.cmd *.mod.c linux drm_pciids.h .tmp_versions
+
+# VERSION is not defined from the initial invocation. It is defined when
+# this Makefile is invoked from the kernel's root Makefile.
+
+ifndef VERSION
+
+ifdef RUNNING_REL
+
+# SuSE has the version.h and autoconf.h headers for the current kernel
+# in /boot as /boot/vmlinuz.version.h and /boot/vmlinuz.autoconf.h.
+# Check these first to see if they match the running kernel.
+
+BOOTVERSION_PREFIX = /boot/vmlinuz.
+
+V := $(shell if [ -f $(BOOTVERSION_PREFIX)version.h ]; then \
+ grep UTS_RELEASE $(BOOTVERSION_PREFIX)version.h | \
+ cut -d' ' -f3; fi)
+
+ifeq ($(V),"$(RUNNING_REL)")
+HEADERFROMBOOT := 1
+GETCONFIG := MAKEFILES=$(shell pwd)/.config
+HAVECONFIG := y
+endif
+
+# On Red Hat we need to check if there is a .config file in the kernel
+# source directory. If there isn't, we need to check if there's a
+# matching file in the configs subdirectory.
+
+ifneq ($(HAVECONFIG),y)
+HAVECONFIG := $(shell if [ -e $(LINUXDIR)/.config ]; then echo y; fi)
+endif
+
+ifneq ($(HAVECONFIG),y)
+REL_BASE := $(shell echo $(RUNNING_REL) | sed 's/-.*//')
+REL_TYPE := $(shell echo $(RUNNING_REL) | sed 's/[0-9.-]//g')
+ifeq ($(REL_TYPE),)
+RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE).config
+else
+RHCONFIG := configs/kernel-$(REL_BASE)-$(MACHINE)-$(REL_TYPE).config
+endif
+HAVECONFIG := $(shell if [ -e $(LINUXDIR)/$(RHCONFIG) ]; then echo y; fi)
+ifneq ($(HAVECONFIG),y)
+RHCONFIG :=
+endif
+endif
+
+ifneq ($(HAVECONFIG),y)
+ifneq ($(0),$(LINUXDIR))
+GETCONFIG += O=$(O)
+endif
+HAVECONFIG := $(shell if [ -e $(O)/.config ]; then echo y; fi)
+endif
+
+ifneq ($(HAVECONFIG),y)
+$(error Cannot find a kernel config file)
+endif
+
+endif
+
+CLEANCONFIG := $(shell if cmp -s $(LINUXDIR)/.config .config; then echo y; fi)
+ifeq ($(CLEANCONFIG),y)
+CLEANFILES += $(LINUXDIR)/.config .config $(LINUXDIR)/tmp_include_depends
+endif
+
+all: modules
+
+modules: includes
+ make -C $(LINUXDIR) $(GETCONFIG) SUBDIRS=`pwd` DRMSRCDIR=`pwd` modules
+
+ifeq ($(HEADERFROMBOOT),1)
+
+BOOTHEADERS = version.h autoconf.h
+BOOTCONFIG = .config
+
+CLEANFILES += $(BOOTHEADERS) $(BOOTCONFIG)
+
+includes:: $(BOOTHEADERS) $(BOOTCONFIG)
+
+version.h: $(BOOTVERSION_PREFIX)version.h
+ rm -f $@
+ ln -s $< $@
+
+autoconf.h: $(BOOTVERSION_PREFIX)autoconf.h
+ rm -f $@
+ ln -s $< $@
+
+.config: $(BOOTVERSION_PREFIX)config
+ rm -f $@
+ ln -s $< $@
+endif
+
+# This prepares an unused Red Hat kernel tree for the build.
+ifneq ($(RHCONFIG),)
+includes:: $(LINUXDIR)/.config $(LINUXDIR)/tmp_include_depends .config
+
+$(LINUXDIR)/.config: $(LINUXDIR)/$(RHCONFIG)
+ rm -f $@
+ ln -s $< $@
+
+.config: $(LINUXDIR)/$(RHCONFIG)
+ rm -f $@
+ ln -s $< $@
+
+$(LINUXDIR)/tmp_include_depends:
+ echo all: > $@
+endif
+
+# Make sure that the shared source files are linked into this directory.
+
+
+SHAREDDIR := ../shared
+
+HASSHARED := $(shell if [ -d $(SHAREDDIR) ]; then echo y; fi)
+
+ifeq ($(HASSHARED),y)
+includes:: $(SHAREDSRC) drm_pciids.h
+
+drm_pciids.h: $(SHAREDDIR)/drm_pciids.txt
+ sh ../scripts/create_linux_pci_lists.sh < $(SHAREDDIR)/drm_pciids.txt
+
+$(SHAREDSRC):
+ @if [ -r $(SHAREDDIR)/$@ ]; then \
+ (rm -f $@; set -x; ln -s $(SHAREDDIR)/$@ $@); fi
+
+CLEANFILES += $(SHAREDSRC)
+endif
+
+L24SHAREDDIR := ../linux
+
+HAS24SHARED := $(shell if [ -d $(L24SHAREDDIR) ]; then echo y; fi)
+
+ifeq ($(HAS24SHARED),y)
+
+includes:: $(L24SHARED)
+
+$(L24SHARED):
+ @if [ -r $(L24SHAREDDIR)/$@ ]; then \
+ (rm -f $@; set -x; ln -s $(L24SHAREDDIR)/$@ $@); fi
+
+CLEANFILES += $(L24SHARED)
+endif
+
+includes:: linux
+
+linux:
+ rm -f linux
+ ln -s . linux
+
+clean cleandir:
+ rm -rf $(CLEANFILES)
+
+$(MODULE_LIST)::
+ make DRM_MODULES=$@ modules
+
+# Build test utilities
+
+PRGCFLAGS = $(CFLAGS) -g -ansi -pedantic -DPOSIX_C_SOURCE=199309L \
+ -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE \
+ -I. -I../../..
+
+DRMSTATLIBS = -L../../.. -L.. -ldrm -lxf86_os \
+ -L../../../../dummylib -ldummy -lm
+
+programs: $(PROGS)
+
+dristat: dristat.c
+ $(CC) $(PRGCFLAGS) $< -o $@
+
+drmstat: drmstat.c
+ $(CC) $(PRGCFLAGS) $< -o $@ $(DRMSTATLIBS)
+
+else
+
+# Check for kernel versions that we don't support.
+
+BELOW24 := $(shell if [ $(VERSION) -lt 2 -o $(PATCHLEVEL) -lt 4 ]; then \
+ echo y; fi)
+
+ifeq ($(BELOW24),y)
+$(error Only 2.4.x and later kernels are supported \
+ ($(VERSION).$(PATCHLEVEL).$(SUBLEVEL)))
+endif
+
+ifdef ARCHX86
+ifndef CONFIG_X86_CMPXCHG
+$(error CONFIG_X86_CMPXCHG needs to be enabled in the kernel)
+endif
+endif
+
+# This needs to go before all other include paths.
+CC += -I$(DRMSRCDIR)
+
+# Check for Red Hat's 4-argument do_munmap().
+DOMUNMAP := $(shell grep do_munmap $(LINUXDIR)/include/linux/mm.h | \
+ grep -c acct)
+
+ifneq ($(DOMUNMAP),0)
+EXTRA_CFLAGS += -DDO_MUNMAP_4_ARGS
+endif
+
+# Check for 5-argument remap_page_range() in RH9 kernel, and 2.5.x kernels
+RPR := $(shell grep remap_page_range $(LINUXDIR)/include/linux/mm.h | \
+ grep -c vma)
+
+ifneq ($(RPR),0)
+EXTRA_CFLAGS += -DREMAP_PAGE_RANGE_5_ARGS
+endif
+
+# Check for 4-argument vmap() in some 2.5.x and 2.4.x kernels
+VMAP := $(shell grep -A1 'vmap.*count,$$' $(LINUXDIR)/include/linux/vmalloc.h | \
+ grep -c prot)
+
+ifneq ($(VMAP),0)
+EXTRA_CFLAGS += -DVMAP_4_ARGS
+endif
+
+# Check for PAGE_AGP definition
+PAGE_AGP := $(shell cat $(LINUXDIR)/include/asm/agp.h 2>/dev/null | \
+ grep -c PAGE_AGP)
+
+ifneq ($(PAGE_AGP),0)
+EXTRA_CFLAGS += -DHAVE_PAGE_AGP
+endif
+
+
+# Start with all modules turned off.
+CONFIG_DRM_GAMMA := n
+CONFIG_DRM_TDFX := n
+CONFIG_DRM_MGA := n
+CONFIG_DRM_I810 := n
+CONFIG_DRM_R128 := n
+CONFIG_DRM_RADEON := n
+CONFIG_DRM_I830 := n
+CONFIG_DRM_I915 := n
+CONFIG_DRM_SIS := n
+CONFIG_DRM_FFB := n
+CONFIG_DRM_SAVAGE := n
+CONFIG_DRM_VIA := n
+CONFIG_DRM_MACH64 := n
+
+# Enable module builds for the modules requested/supported.
+
+ifneq (,$(findstring tdfx,$(DRM_MODULES)))
+CONFIG_DRM_TDFX := m
+endif
+ifneq (,$(findstring r128,$(DRM_MODULES)))
+CONFIG_DRM_R128 := m
+endif
+ifneq (,$(findstring radeon,$(DRM_MODULES)))
+CONFIG_DRM_RADEON := m
+endif
+ifneq (,$(findstring sis,$(DRM_MODULES)))
+CONFIG_DRM_SIS := m
+endif
+ifneq (,$(findstring via,$(DRM_MODULES)))
+CONFIG_DRM_VIA := m
+endif
+ifneq (,$(findstring mach64,$(DRM_MODULES)))
+CONFIG_DRM_MACH64 := m
+endif
+ifneq (,$(findstring ffb,$(DRM_MODULES)))
+CONFIG_DRM_FFB := m
+endif
+
+# These require AGP support
+
+ifdef CONFIG_AGP
+ifneq (,$(findstring mga,$(DRM_MODULES)))
+CONFIG_DRM_MGA := m
+endif
+ifneq (,$(findstring i810,$(DRM_MODULES)))
+CONFIG_DRM_I810 := m
+endif
+ifneq (,$(findstring i830,$(DRM_MODULES)))
+CONFIG_DRM_I830 := m
+endif
+ifneq (,$(findstring i915,$(DRM_MODULES)))
+CONFIG_DRM_I915 := m
+endif
+ifneq (,$(findstring savage,$(DRM_MODULES)))
+CONFIG_DRM_SAVAGE := m
+endif
+endif
+
+include $(DRMSRCDIR)/Makefile.kernel
+
+# Depencencies
+$(tdfx-objs): $(TDFXHEADERS)
+$(r128-objs): $(R128HEADERS)
+$(mga-objs): $(MGAHEADERS)
+$(i810-objs): $(I810HEADERS)
+$(i830-objs): $(I830HEADERS)
+$(i915-objs): $(I830HEADERS)
+$(radeon-objs): $(RADEONHEADERS)
+$(sis-objs): $(SISHEADERS)
+$(ffb-objs): $(FFBHEADERS)
+$(savage-objs): $(SAVAGEHEADERS)
+$(via-objs): $(VIAHEADERS)
+$(mach64-objs): $(MACH64HEADERS)
+
+endif
+
diff --git a/linux-2.6/Makefile.kernel b/linux-2.6/Makefile.kernel
new file mode 100644
index 00000000..5ff3d399
--- /dev/null
+++ b/linux-2.6/Makefile.kernel
@@ -0,0 +1,99 @@
+#
+# Makefile for the drm device driver. This driver provides support for the
+# Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
+#
+# Based on David Woodhouse's mtd build.
+#
+# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel,v 1.18 2003/08/16 17:59:17 dawes Exp $
+#
+
+tdfx-objs := tdfx_drv.o
+r128-objs := r128_drv.o r128_cce.o r128_state.o r128_irq.o
+mga-objs := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o
+i810-objs := i810_drv.o i810_dma.o
+i830-objs := i830_drv.o i830_dma.o i830_irq.o
+i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o
+radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o radeon_i2c.o
+sis-objs := sis_drv.o sis_ds.o sis_mm.o
+ffb-objs := ffb_drv.o ffb_context.o
+savage-objs := savage_drv.o savage_dma.o
+via-objs := via_irq.o via_drv.o via_ds.o via_map.o via_mm.o via_dma.o
+mach64-objs := mach64_drv.o mach64_dma.o mach64_irq.o mach64_state.o
+
+# Kernel version checks
+
+BELOW25 := $(shell if [ $(PATCHLEVEL) -lt 5 ]; then echo y; fi)
+
+# There were major build changes starting with 2.5.52
+ifneq ($(BELOW25),y)
+BELOW2552 := $(shell if [ $(PATCHLEVEL) -eq 5 -a $(SUBLEVEL) -lt 52 ]; then echo y; fi)
+else
+BELOW2552 := y
+endif
+
+ifeq ($(BELOW25),y)
+O_TARGET := drm.o
+list-multi := tdfx.o r128.o mga.o i810.o i830.o ffb.o radeon.o \
+ savage.o via.o mach64.o i915.o
+obj-m :=
+obj-n :=
+obj- :=
+export-objs := via_mm.o
+endif
+
+obj-$(CONFIG_DRM_TDFX) += tdfx.o
+obj-$(CONFIG_DRM_R128) += r128.o
+obj-$(CONFIG_DRM_RADEON)+= radeon.o
+obj-$(CONFIG_DRM_MGA) += mga.o
+obj-$(CONFIG_DRM_I810) += i810.o
+obj-$(CONFIG_DRM_I830) += i830.o
+obj-$(CONFIG_DRM_I915) += i915.o
+obj-$(CONFIG_DRM_SIS) += sis.o
+obj-$(CONFIG_DRM_FFB) += ffb.o
+obj-$(CONFIG_DRM_SAVAGE)+= savage.o
+obj-$(CONFIG_DRM_VIA) += via.o
+obj-$(CONFIG_DRM_MACH64)+= mach64.o
+
+ifeq ($(BELOW2552),y)
+include $(TOPDIR)/Rules.make
+endif
+
+ifeq ($(BELOW25),y)
+tdfx.o: $(tdfx-objs) $(lib)
+ $(LD) -r -o $@ $(tdfx-objs) $(lib)
+
+mga.o: $(mga-objs) $(lib)
+ $(LD) -r -o $@ $(mga-objs) $(lib)
+
+i810.o: $(i810-objs) $(lib)
+ $(LD) -r -o $@ $(i810-objs) $(lib)
+
+i830.o: $(i830-objs) $(lib)
+ $(LD) -r -o $@ $(i830-objs) $(lib)
+
+i915.o: $(i915-objs) $(lib)
+ $(LD) -r -o $@ $(i915-objs) $(lib)
+
+r128.o: $(r128-objs) $(lib)
+ $(LD) -r -o $@ $(r128-objs) $(lib)
+
+radeon.o: $(radeon-objs) $(lib)
+ $(LD) -r -o $@ $(radeon-objs) $(lib)
+
+sis.o: $(sis-objs) $(lib)
+ $(LD) -r -o $@ $(sis-objs) $(lib)
+
+ffb.o: $(ffb-objs) $(lib)
+ $(LD) -r -o $@ $(ffb-objs) $(lib)
+
+savage.o: $(savage-objs) $(lib)
+ $(LD) -r -o $@ $(savage-objs) $(lib)
+
+via.o: $(via-objs) $(lib)
+ $(LD) -r -o $@ $(via-objs) $(lib)
+
+mach64.o: $(mach64-objs) $(lib)
+ $(LD) -r -o $@ $(mach64-objs) $(lib)
+
+endif
+
diff --git a/linux-2.6/drm_core.h b/linux-2.6/drm_core.h
new file mode 100644
index 00000000..4e27d90a
--- /dev/null
+++ b/linux-2.6/drm_core.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2004 Jon Smirl <jonsmirl@gmail.com>
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
+ *
+ * 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, sub license,
+ * 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
+ * VIA, S3 GRAPHICS, AND/OR ITS SUPPLIERS 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.
+ */
+
+#include "drm_auth.h"
+#include "drm_agpsupport.h"
+#include "drm_bufs.h"
+#include "drm_context.h"
+#include "drm_dma.h"
+#include "drm_irq.h"
+#include "drm_drawable.h"
+#include "drm_drv.h"
+#include "drm_fops.h"
+#include "drm_init.h"
+#include "drm_ioctl.h"
+#include "drm_lock.h"
+#include "drm_memory.h"
+#include "drm_pci.h"
+#include "drm_proc.h"
+#include "drm_vm.h"
+#include "drm_sysfs.h"
+#include "drm_stub.h"
+#include "drm_scatter.h"
diff --git a/linux/drm_sysfs.h b/linux-2.6/drm_sysfs.h
index c6f6a7a9..c6f6a7a9 100644
--- a/linux/drm_sysfs.h
+++ b/linux-2.6/drm_sysfs.h
diff --git a/linux/radeon_i2c.c b/linux-2.6/radeon_i2c.c
index e2591723..e2591723 100644
--- a/linux/radeon_i2c.c
+++ b/linux-2.6/radeon_i2c.c
diff --git a/linux/radeon_gpl.h b/linux-2.6/radeon_i2c.h
index e8c479a1..2adc6723 100644
--- a/linux/radeon_gpl.h
+++ b/linux-2.6/radeon_i2c.h
@@ -1,5 +1,5 @@
/*
- * linux/radeon_gpl.h
+ * linux/radeon_i2c.h
*
* Original author probably Benjamin Herrenschmidt <benh@kernel.crashing.org>
* or Kronos <kronos@kronoz.cjb.net>
diff --git a/linux-core/Makefile b/linux-core/Makefile
index b338f7db..41339420 100644
--- a/linux-core/Makefile
+++ b/linux-core/Makefile
@@ -70,7 +70,7 @@ DRM_MODULES ?= $(MODULE_LIST)
DRMTEMPLATES = drm_auth.h drm_bufs.h drm_context.h drm_dma.h drm_drawable.h \
drm_drv.h drm_fops.h drm_init.h drm_ioctl.h drm_irq.h \
drm_lock.h drm_memory.h drm_proc.h drm_stub.h drm_vm.h \
- drm_sysfs.h drm_core.h
+ drm_core.h
DRMSHARED = drm.h drm_sarea.h
DRMHEADERS = drmP.h $(DRMSHARED)
diff --git a/linux-core/Makefile.kernel b/linux-core/Makefile.kernel
index 5ff3d399..92e3f73e 100644
--- a/linux-core/Makefile.kernel
+++ b/linux-core/Makefile.kernel
@@ -13,7 +13,7 @@ mga-objs := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o
i810-objs := i810_drv.o i810_dma.o
i830-objs := i830_drv.o i830_dma.o i830_irq.o
i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o
-radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o radeon_i2c.o
+radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o
sis-objs := sis_drv.o sis_ds.o sis_mm.o
ffb-objs := ffb_drv.o ffb_context.o
savage-objs := savage_drv.o savage_dma.o
diff --git a/linux-core/drm_core.h b/linux-core/drm_core.h
index 4e27d90a..adaf581b 100644
--- a/linux-core/drm_core.h
+++ b/linux-core/drm_core.h
@@ -39,6 +39,5 @@
#include "drm_pci.h"
#include "drm_proc.h"
#include "drm_vm.h"
-#include "drm_sysfs.h"
#include "drm_stub.h"
#include "drm_scatter.h"
diff --git a/linux-core/drm_sysfs.c b/linux-core/drm_sysfs.c
new file mode 100644
index 00000000..c6f6a7a9
--- /dev/null
+++ b/linux-core/drm_sysfs.c
@@ -0,0 +1,206 @@
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+/*
+ * drm_sysfs.c - Modifications to drm_sysfs_class.c to support
+ * extra sysfs attribute from DRM. Normal drm_sysfs_class
+ * does not allow adding attributes.
+ *
+ * Copyright (c) 2004 Jon Smirl <jonsmirl@gmail.com>
+ * Copyright (c) 2003-2004 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (c) 2003-2004 IBM Corp.
+ *
+ * This file is released under the GPLv2
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/device.h>
+#include <linux/kdev_t.h>
+#include <linux/err.h>
+
+struct drm_sysfs_class {
+ struct class_device_attribute attr;
+ struct class class;
+};
+#define to_drm_sysfs_class(d) container_of(d, struct drm_sysfs_class, class)
+
+struct simple_dev {
+ struct list_head node;
+ dev_t dev;
+ struct class_device class_dev;
+};
+#define to_simple_dev(d) container_of(d, struct simple_dev, class_dev)
+
+static LIST_HEAD(simple_dev_list);
+static spinlock_t simple_dev_list_lock = SPIN_LOCK_UNLOCKED;
+
+static void release_simple_dev(struct class_device *class_dev)
+{
+ struct simple_dev *s_dev = to_simple_dev(class_dev);
+ kfree(s_dev);
+}
+
+static ssize_t show_dev(struct class_device *class_dev, char *buf)
+{
+ struct simple_dev *s_dev = to_simple_dev(class_dev);
+ return print_dev_t(buf, s_dev->dev);
+}
+
+static void drm_sysfs_class_release(struct class *class)
+{
+ struct drm_sysfs_class *cs = to_drm_sysfs_class(class);
+ kfree(cs);
+}
+
+/* Display the version of drm_core. This doesn't work right in current design */
+static ssize_t version_show(struct class *dev, char *buf)
+{
+ return sprintf(buf, "fixme for drm_core %s %d.%d.%d %s\n", DRIVER_NAME, DRIVER_MAJOR,
+ DRIVER_MINOR, DRIVER_PATCHLEVEL, DRIVER_DATE);
+}
+static CLASS_ATTR(version, S_IRUGO, version_show, NULL);
+
+/**
+ * DRM(sysfs_create) - create a struct drm_sysfs_class structure
+ * @owner: pointer to the module that is to "own" this struct drm_sysfs_class
+ * @name: pointer to a string for the name of this class.
+ *
+ * This is used to create a struct drm_sysfs_class pointer that can then be used
+ * in calls to DRM(sysfs_device_add)().
+ *
+ * Note, the pointer created here is to be destroyed when finished by making a
+ * call to DRM(sysfs_destroy)().
+ */
+struct drm_sysfs_class *DRM(sysfs_create)(struct module *owner, char *name)
+{
+ struct drm_sysfs_class *cs;
+ int retval;
+
+ cs = kmalloc(sizeof(*cs), GFP_KERNEL);
+ if (!cs) {
+ retval = -ENOMEM;
+ goto error;
+ }
+ memset(cs, 0x00, sizeof(*cs));
+
+ cs->class.name = name;
+ cs->class.class_release = drm_sysfs_class_release;
+ cs->class.release = release_simple_dev;
+
+ cs->attr.attr.name = "dev";
+ cs->attr.attr.mode = S_IRUGO;
+ cs->attr.attr.owner = owner;
+ cs->attr.show = show_dev;
+ cs->attr.store = NULL;
+
+ retval = class_register(&cs->class);
+ if (retval)
+ goto error;
+ class_create_file(&cs->class, &class_attr_version);
+
+ return cs;
+
+error:
+ kfree(cs);
+ return ERR_PTR(retval);
+}
+
+/**
+ * DRM(sysfs_destroy) - destroys a struct drm_sysfs_class structure
+ * @cs: pointer to the struct drm_sysfs_class that is to be destroyed
+ *
+ * Note, the pointer to be destroyed must have been created with a call to
+ * DRM(sysfs_create)().
+ */
+void DRM(sysfs_destroy)(struct drm_sysfs_class *cs)
+{
+ if ((cs == NULL) || (IS_ERR(cs)))
+ return;
+
+ class_unregister(&cs->class);
+}
+
+/**
+ * DRM(sysfs_device_add) - adds a class device to sysfs for a character driver
+ * @cs: pointer to the struct drm_sysfs_class that this device should be registered to.
+ * @dev: the dev_t for the device to be added.
+ * @device: a pointer to a struct device that is assiociated with this class device.
+ * @fmt: string for the class device's name
+ *
+ * A struct class_device will be created in sysfs, registered to the specified
+ * class. A "dev" file will be created, showing the dev_t for the device. The
+ * pointer to the struct class_device will be returned from the call. Any further
+ * sysfs files that might be required can be created using this pointer.
+ * Note: the struct drm_sysfs_class passed to this function must have previously been
+ * created with a call to DRM(sysfs_create)().
+ */
+struct class_device *DRM(sysfs_device_add)(struct drm_sysfs_class *cs, dev_t dev, struct device *device, const char *fmt, ...)
+{
+ va_list args;
+ struct simple_dev *s_dev = NULL;
+ int retval;
+
+ if ((cs == NULL) || (IS_ERR(cs))) {
+ retval = -ENODEV;
+ goto error;
+ }
+
+ s_dev = kmalloc(sizeof(*s_dev), GFP_KERNEL);
+ if (!s_dev) {
+ retval = -ENOMEM;
+ goto error;
+ }
+ memset(s_dev, 0x00, sizeof(*s_dev));
+
+ s_dev->dev = dev;
+ s_dev->class_dev.dev = device;
+ s_dev->class_dev.class = &cs->class;
+
+ va_start(args, fmt);
+ vsnprintf(s_dev->class_dev.class_id, BUS_ID_SIZE, fmt, args);
+ va_end(args);
+ retval = class_device_register(&s_dev->class_dev);
+ if (retval)
+ goto error;
+
+ class_device_create_file(&s_dev->class_dev, &cs->attr);
+
+ spin_lock(&simple_dev_list_lock);
+ list_add(&s_dev->node, &simple_dev_list);
+ spin_unlock(&simple_dev_list_lock);
+
+ return &s_dev->class_dev;
+
+error:
+ kfree(s_dev);
+ return ERR_PTR(retval);
+}
+
+/**
+ * DRM(sysfs_device_remove) - removes a class device that was created with DRM(sysfs_device_add)()
+ * @dev: the dev_t of the device that was previously registered.
+ *
+ * This call unregisters and cleans up a class device that was created with a
+ * call to DRM(sysfs_device_add)()
+ */
+void DRM(sysfs_device_remove)(dev_t dev)
+{
+ struct simple_dev *s_dev = NULL;
+ int found = 0;
+
+ spin_lock(&simple_dev_list_lock);
+ list_for_each_entry(s_dev, &simple_dev_list, node) {
+ if (s_dev->dev == dev) {
+ found = 1;
+ break;
+ }
+ }
+ if (found) {
+ list_del(&s_dev->node);
+ spin_unlock(&simple_dev_list_lock);
+ class_device_unregister(&s_dev->class_dev);
+ } else {
+ spin_unlock(&simple_dev_list_lock);
+ }
+}
+
+#endif
diff --git a/linux-core/radeon_i2c.c b/linux-core/radeon_i2c.c
new file mode 100644
index 00000000..e2591723
--- /dev/null
+++ b/linux-core/radeon_i2c.c
@@ -0,0 +1,157 @@
+/*
+ * linux/radeon_i2c.c
+ *
+ * Original author probably Benjamin Herrenschmidt <benh@kernel.crashing.org>
+ * or Kronos <kronos@kronoz.cjb.net>
+ * Based on Xfree sources
+ * (C) Copyright 2004 Jon Smirl <jonsmirl@gmail.com>
+ *
+ * This is a GPL licensed file from the Linux kernel, don't add it to the BSD build
+ *
+ * Radeon I2C support routines
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+#include <linux/pci.h>
+#include <linux/fb.h>
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+
+#include <asm/io.h>
+#include <video/radeon.h>
+
+#include "radeon.h"
+#include "drmP.h"
+#include "drm.h"
+#include "radeon_drm.h"
+#include "radeon_drv.h"
+
+static void gpio_setscl(void* data, int state)
+{
+ struct radeon_i2c_chan *chan = data;
+ drm_radeon_private_t *dev_priv = chan->dev->dev_private;
+ u32 val;
+
+ val = RADEON_READ(chan->ddc_reg) & ~(VGA_DDC_CLK_OUT_EN);
+ if (!state)
+ val |= VGA_DDC_CLK_OUT_EN;
+
+ RADEON_WRITE(chan->ddc_reg, val);
+ (void)RADEON_READ(chan->ddc_reg);
+}
+
+static void gpio_setsda(void* data, int state)
+{
+ struct radeon_i2c_chan *chan = data;
+ drm_radeon_private_t *dev_priv = chan->dev->dev_private;
+ u32 val;
+
+ val = RADEON_READ(chan->ddc_reg) & ~(VGA_DDC_DATA_OUT_EN);
+ if (!state)
+ val |= VGA_DDC_DATA_OUT_EN;
+
+ RADEON_WRITE(chan->ddc_reg, val);
+ (void)RADEON_READ(chan->ddc_reg);
+}
+
+static int gpio_getscl(void* data)
+{
+ struct radeon_i2c_chan *chan = data;
+ drm_radeon_private_t *dev_priv = chan->dev->dev_private;
+ u32 val;
+
+ val = RADEON_READ(chan->ddc_reg);
+
+ return (val & VGA_DDC_CLK_INPUT) ? 1 : 0;
+}
+
+static int gpio_getsda(void* data)
+{
+ struct radeon_i2c_chan *chan = data;
+ drm_radeon_private_t *dev_priv = chan->dev->dev_private;
+ u32 val;
+
+ val = RADEON_READ(chan->ddc_reg);
+
+ return (val & VGA_DDC_DATA_INPUT) ? 1 : 0;
+}
+
+static int setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name)
+{
+ int rc;
+
+ strcpy(chan->adapter.name, name);
+ chan->adapter.owner = THIS_MODULE;
+ chan->adapter.id = I2C_ALGO_ATI;
+ chan->adapter.algo_data = &chan->algo;
+ chan->adapter.dev.parent = &chan->dev->pdev->dev;
+ chan->algo.setsda = gpio_setsda;
+ chan->algo.setscl = gpio_setscl;
+ chan->algo.getsda = gpio_getsda;
+ chan->algo.getscl = gpio_getscl;
+ chan->algo.udelay = 40;
+ chan->algo.timeout = 20;
+ chan->algo.data = chan;
+
+ i2c_set_adapdata(&chan->adapter, chan);
+
+ /* Raise SCL and SDA */
+ gpio_setsda(chan, 1);
+ gpio_setscl(chan, 1);
+ udelay(20);
+
+ rc = i2c_bit_add_bus(&chan->adapter);
+ if (rc == 0)
+ DRM_DEBUG("I2C bus %s registered.\n", name);
+ else
+ DRM_ERROR("Failed to register I2C bus %s.\n", name);
+ return rc;
+}
+
+int radeon_create_i2c_busses(drm_device_t *dev)
+{
+ drm_radeon_private_t *dev_priv = dev->dev_private;
+ int ret;
+
+ dev_priv->i2c[0].dev = dev;
+ dev_priv->i2c[0].ddc_reg = GPIO_MONID;
+ if ((ret = setup_i2c_bus(&dev_priv->i2c[0], "monid")))
+ return ret;
+
+ dev_priv->i2c[1].dev = dev;
+ dev_priv->i2c[1].ddc_reg = GPIO_DVI_DDC;
+ if ((ret = setup_i2c_bus(&dev_priv->i2c[1], "dvi")))
+ return ret;
+
+ dev_priv->i2c[2].dev = dev;
+ dev_priv->i2c[2].ddc_reg = GPIO_VGA_DDC;
+ if ((ret = setup_i2c_bus(&dev_priv->i2c[2], "vga")))
+ return ret;
+
+ dev_priv->i2c[3].dev = dev;
+ dev_priv->i2c[3].ddc_reg = GPIO_CRT2_DDC;
+ if ((ret = setup_i2c_bus(&dev_priv->i2c[3], "crt2")))
+ return ret;
+ return 0;
+}
+
+void radeon_delete_i2c_busses(drm_device_t *dev)
+{
+ drm_radeon_private_t *dev_priv = dev->dev_private;
+ int i, ret;
+
+ for (i = 0; i < 4; i++) {
+ if (dev_priv->i2c[i].dev) {
+ ret = i2c_bit_del_bus(&dev_priv->i2c[i].adapter);
+ }
+ dev_priv->i2c[i].dev = NULL;
+ }
+}
+
+#endif
diff --git a/linux-core/radeon_i2c.h b/linux-core/radeon_i2c.h
new file mode 100644
index 00000000..2adc6723
--- /dev/null
+++ b/linux-core/radeon_i2c.h
@@ -0,0 +1,29 @@
+/*
+ * linux/radeon_i2c.h
+ *
+ * Original author probably Benjamin Herrenschmidt <benh@kernel.crashing.org>
+ * or Kronos <kronos@kronoz.cjb.net>
+ * Based on Xfree sources
+ * (C) Copyright 2004 Jon Smirl <jonsmirl@gmail.com>
+ *
+ * This is a GPL licensed file from the Linux kernel, don't add it to the BSD build
+ *
+ * Radeon I2C support routines
+ *
+ */
+
+#include <linux/i2c.h>
+#include <linux/i2c-id.h>
+#include <linux/i2c-algo-bit.h>
+
+struct radeon_i2c_chan {
+ drm_device_t *dev;
+ u32 ddc_reg;
+ struct i2c_adapter adapter;
+ struct i2c_algo_bit_data algo;
+};
+
+extern int radeon_create_i2c_busses(drm_device_t *dev);
+extern void radeon_delete_i2c_busses(drm_device_t *dev);
+
+
diff --git a/linux/Makefile b/linux/Makefile
index b338f7db..41339420 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -70,7 +70,7 @@ DRM_MODULES ?= $(MODULE_LIST)
DRMTEMPLATES = drm_auth.h drm_bufs.h drm_context.h drm_dma.h drm_drawable.h \
drm_drv.h drm_fops.h drm_init.h drm_ioctl.h drm_irq.h \
drm_lock.h drm_memory.h drm_proc.h drm_stub.h drm_vm.h \
- drm_sysfs.h drm_core.h
+ drm_core.h
DRMSHARED = drm.h drm_sarea.h
DRMHEADERS = drmP.h $(DRMSHARED)
diff --git a/linux/Makefile.kernel b/linux/Makefile.kernel
index 5ff3d399..92e3f73e 100644
--- a/linux/Makefile.kernel
+++ b/linux/Makefile.kernel
@@ -13,7 +13,7 @@ mga-objs := mga_drv.o mga_dma.o mga_state.o mga_warp.o mga_irq.o
i810-objs := i810_drv.o i810_dma.o
i830-objs := i830_drv.o i830_dma.o i830_irq.o
i915-objs := i915_drv.o i915_dma.o i915_irq.o i915_mem.o
-radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o radeon_i2c.o
+radeon-objs := radeon_drv.o radeon_cp.o radeon_state.o radeon_mem.o radeon_irq.o
sis-objs := sis_drv.o sis_ds.o sis_mm.o
ffb-objs := ffb_drv.o ffb_context.o
savage-objs := savage_drv.o savage_dma.o
diff --git a/linux/drm_core.h b/linux/drm_core.h
index 4e27d90a..adaf581b 100644
--- a/linux/drm_core.h
+++ b/linux/drm_core.h
@@ -39,6 +39,5 @@
#include "drm_pci.h"
#include "drm_proc.h"
#include "drm_vm.h"
-#include "drm_sysfs.h"
#include "drm_stub.h"
#include "drm_scatter.h"
diff --git a/shared-core/radeon_drv.h b/shared-core/radeon_drv.h
index ec3560aa..ccb1654f 100644
--- a/shared-core/radeon_drv.h
+++ b/shared-core/radeon_drv.h
@@ -47,8 +47,8 @@ enum radeon_family {
CHIP_LAST,
};
-#if defined(__linux__)
-#include "radeon_gpl.h"
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#include "radeon_i2c.h"
#endif
/*
@@ -184,7 +184,7 @@ typedef struct drm_radeon_private {
/* starting from here on, data is preserved accross an open */
uint32_t flags; /* see radeon_chip_flags */
-#if defined(__linux__)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
struct radeon_i2c_chan i2c[4];
#endif
} drm_radeon_private_t;
diff --git a/shared/radeon_drv.h b/shared/radeon_drv.h
index ec3560aa..ccb1654f 100644
--- a/shared/radeon_drv.h
+++ b/shared/radeon_drv.h
@@ -47,8 +47,8 @@ enum radeon_family {
CHIP_LAST,
};
-#if defined(__linux__)
-#include "radeon_gpl.h"
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#include "radeon_i2c.h"
#endif
/*
@@ -184,7 +184,7 @@ typedef struct drm_radeon_private {
/* starting from here on, data is preserved accross an open */
uint32_t flags; /* see radeon_chip_flags */
-#if defined(__linux__)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
struct radeon_i2c_chan i2c[4];
#endif
} drm_radeon_private_t;