summaryrefslogtreecommitdiff
path: root/src/pcidb/parse_pci_ids.pl
diff options
context:
space:
mode:
authorDave Airlie <airlied@clockmaker.usersys.redhat.com>2007-11-20 22:33:39 +1000
committerDave Airlie <airlied@clockmaker.usersys.redhat.com>2007-11-20 22:33:39 +1000
commitc8872603454e6a4ffed9fc7d9adc2c364a429608 (patch)
tree86057a99193c04f9aaf0f2de8e2049d20efdd6b3 /src/pcidb/parse_pci_ids.pl
parent49055d8aff91ff12186feaf5343c8fd2f96bcba0 (diff)
radeon: restructure pci ids to avoid effort later
This uses a single file with all the pciids and parameters for radeon family and setup in it. I don't run the perl script at build time to avoid a perl dependency on build but adding pci ids should be done via the csv file with openoffice or gnumeric if possible.
Diffstat (limited to 'src/pcidb/parse_pci_ids.pl')
-rwxr-xr-xsrc/pcidb/parse_pci_ids.pl94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/pcidb/parse_pci_ids.pl b/src/pcidb/parse_pci_ids.pl
new file mode 100755
index 00000000..e6eac76f
--- /dev/null
+++ b/src/pcidb/parse_pci_ids.pl
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+#
+# Copyright 2007 Red Hat Inc.
+# This crappy script written by Dave Airlie to avoid hassle of adding
+# ids in every place.
+#
+use strict;
+use warnings;
+use Text::CSV_XS;
+
+my $file = $ARGV[0];
+
+my $atioutfile = 'ati_pciids_gen.h';
+my $radeonpcichipsetfile = 'radeon_pci_chipset_gen.h';
+my $radeonchipsetfile = 'radeon_chipset_gen.h';
+my $radeonchipinfofile = 'radeon_chipinfo_gen.h';
+
+my $csv = Text::CSV_XS->new();
+
+open (CSV, "<", $file) or die $!;
+
+open (ATIOUT, ">", $atioutfile) or die;
+open (PCICHIPSET, ">", $radeonpcichipsetfile) or die;
+open (RADEONCHIPSET, ">", $radeonchipsetfile) or die;
+open (RADEONCHIPINFO, ">", $radeonchipinfofile) or die;
+
+print RADEONCHIPSET "/* This file is autogenerated please do not edit */\n";
+print RADEONCHIPSET "static SymTabRec RADEONChipsets[] = {\n";
+print PCICHIPSET "/* This file is autogenerated please do not edit */\n";
+print PCICHIPSET "PciChipsets RADEONPciChipsets[] = {\n";
+print RADEONCHIPINFO "/* This file is autogenerated please do not edit */\n";
+print RADEONCHIPINFO "RADEONCardInfo RADEONCards[] = {\n";
+while (<CSV>) {
+ if ($csv->parse($_)) {
+ my @columns = $csv->fields();
+
+ if ((substr($columns[0], 0, 1) ne "#")) {
+
+ print ATIOUT "#define PCI_CHIP_$columns[1] $columns[0]\n";
+
+ if (($columns[2] ne "R128") && ($columns[2] ne "MACH64") && ($columns[2] ne "MACH32")) {
+ print PCICHIPSET " { PCI_CHIP_$columns[1], PCI_CHIP_$columns[1], RES_SHARED_VGA },\n";
+
+ print RADEONCHIPSET " { PCI_CHIP_$columns[1], \"$columns[8]\" },\n";
+
+ print RADEONCHIPINFO " { $columns[0], CHIP_FAMILY_$columns[2], ";
+
+ if ($columns[3] eq "1") {
+ print RADEONCHIPINFO "1, ";
+ } else {
+ print RADEONCHIPINFO "0, ";
+ }
+
+ if ($columns[4] eq "1") {
+ print RADEONCHIPINFO "1, ";
+ } else {
+ print RADEONCHIPINFO "0, ";
+ }
+
+ if ($columns[5] eq "1") {
+ print RADEONCHIPINFO "1, ";
+ } else {
+ print RADEONCHIPINFO "0, ";
+ }
+
+ if ($columns[6] eq "1") {
+ print RADEONCHIPINFO "1, ";
+ } else {
+ print RADEONCHIPINFO "0, ";
+ }
+
+ if ($columns[7] eq "1") {
+ print RADEONCHIPINFO "1 ";
+ } else {
+ print RADEONCHIPINFO "0 ";
+ }
+
+ print RADEONCHIPINFO "},\n";
+ }
+ }
+ } else {
+ my $err = $csv->error_input;
+ print "Failed to parse line: $err";
+ }
+}
+
+print RADEONCHIPINFO "};\n";
+print RADEONCHIPSET " { -1, NULL }\n};\n";
+print PCICHIPSET " { -1, -1, RES_UNDEFINED }\n};\n";
+close CSV;
+close ATIOUT;
+close PCICHIPSET;
+close RADEONCHIPSET;
+close RADEONCHIPINFO;