summaryrefslogtreecommitdiffstats
path: root/vidix
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-01-08 02:39:39 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-01-08 02:39:39 +0200
commit852570d342943894f109e2dbd281237a369bcceb (patch)
tree51be0a2f91af492dc23020f5faaaeb1e9e11af7c /vidix
parentd1f0cbe5c8628d206fb0337835b0a7e99e7acc10 (diff)
parenta7a1f395c6b883b34aeaf008c0d22d6fe3dcd1c8 (diff)
downloadmpv-852570d342943894f109e2dbd281237a369bcceb.tar.bz2
mpv-852570d342943894f109e2dbd281237a369bcceb.tar.xz
Merge svn changes up to r30216
Diffstat (limited to 'vidix')
-rwxr-xr-xvidix/pci_db2c.awk100
-rw-r--r--vidix/pci_names.c50
2 files changed, 76 insertions, 74 deletions
diff --git a/vidix/pci_db2c.awk b/vidix/pci_db2c.awk
index 976dd76640..8a1cb69cbb 100755
--- a/vidix/pci_db2c.awk
+++ b/vidix/pci_db2c.awk
@@ -34,12 +34,12 @@ BEGIN {
with_pci_db = ARGV[2];
dev_ids_c_file = "vidix/pci_dev_ids.c"
ids_h_file = "vidix/pci_ids.h"
- vendor_ids_h_file = "vidix/pci_vendor_ids.h"
+ names_c_file = "vidix/pci_names.c"
vendors_h_file = "vidix/pci_vendors.h";
# print out head lines
print_head(vendors_h_file);
print_head(ids_h_file);
- print_head(vendor_ids_h_file);
+ print_head(names_c_file);
print_head(dev_ids_c_file);
print "#include <stdlib.h>" > dev_ids_c_file;
print "#include \"pci_names.h\"" > dev_ids_c_file;
@@ -49,12 +49,12 @@ BEGIN {
print "#include \"pci_vendors.h\"" > ids_h_file
print "" > ids_h_file
- print "#include <stddef.h>" > vendor_ids_h_file
- print "#include \"pci_names.h\"" > vendor_ids_h_file
+ print "#include <stddef.h>" > names_c_file
+ print "#include \"pci_names.h\"" > names_c_file
if (with_pci_db) {
- print "#include \"pci_dev_ids.c\"" > vendor_ids_h_file
- print "" > vendor_ids_h_file
- print "static struct vendor_id_s vendor_ids[] = {" > vendor_ids_h_file
+ print "#include \"pci_dev_ids.c\"" > names_c_file
+ print "" > names_c_file
+ print "static struct vendor_id_s vendor_ids[] = {" > names_c_file
}
first_pass = 1;
init_name_db();
@@ -65,13 +65,17 @@ BEGIN {
init_device_db()
svend_name = get_short_vendor_name(field[3])
printf("#define VENDOR_%s\t", svend_name) > vendors_h_file;
- if (length(svend_name) < 9) printf("\t") > vendors_h_file;
+ if (length(svend_name) < 9)
+ printf("\t") > vendors_h_file;
printf("0x%s /*%s*/\n", field[2], name_field) > vendors_h_file;
- if (with_pci_db) printf("{ 0x%s, \"%s\", dev_lst_%s },\n", field[2], name_field, field[2]) > vendor_ids_h_file;
+ if (with_pci_db)
+ printf("{ 0x%s, \"%s\", dev_lst_%s },\n", field[2], name_field, field[2]) > names_c_file;
printf("/* Vendor: %s: %s */\n", field[2], name_field) > ids_h_file
- if (first_pass == 1) first_pass = 0;
- else print "{ 0xFFFF, NULL }\n};" > dev_ids_c_file;
- printf("static const struct device_id_s dev_lst_%s[] = {\n", field[2])> dev_ids_c_file
+ if (first_pass == 1)
+ first_pass = 0;
+ else
+ print "{ 0xFFFF, NULL }\n};" > dev_ids_c_file;
+ printf("static const struct device_id_s dev_lst_%s[] = {\n", field[2]) > dev_ids_c_file
}
if (field[1] == "d" && length(field[3]) > 0 && field[4] == "0") {
sdev_name = get_short_device_name(field[3])
@@ -100,9 +104,11 @@ BEGIN {
}
print_guards_end(vendors_h_file);
print_guards_end(ids_h_file);
- if (with_pci_db) print "};" > vendor_ids_h_file
+ if (with_pci_db)
+ print "};" > names_c_file
print "{ 0xFFFF, NULL }" > dev_ids_c_file;
print "};" > dev_ids_c_file
+ print_func_bodies(names_c_file);
}
function construct_guard_name(out_file)
@@ -134,11 +140,47 @@ function print_head(out_file)
print "" > out_file
}
+function print_func_bodies(out_file)
+{
+ print "" > out_file
+ print "const char *pci_vendor_name(unsigned short id)" > out_file
+ print "{" > out_file
+ if (with_pci_db) {
+ print " unsigned i;" > out_file
+ print " for (i = 0; i < sizeof(vendor_ids) / sizeof(struct vendor_id_s); i++) {" > out_file
+ print " if (vendor_ids[i].id == id)" > out_file
+ print " return vendor_ids[i].name;" > out_file
+ print " }" > out_file
+ }
+ print " return NULL;" > out_file
+ print "}" > out_file
+ print "" > out_file
+ print "const char *pci_device_name(unsigned short vendor_id, unsigned short device_id)" > out_file
+ print "{" > out_file
+ if (with_pci_db) {
+ print " unsigned i, j;" > out_file
+ print " for (i = 0; i < sizeof(vendor_ids) / sizeof(struct vendor_id_s); i++) {" > out_file
+ print " if (vendor_ids[i].id == vendor_id) {" > out_file
+ print " j = 0;" > out_file
+ print " while (vendor_ids[i].dev_list[j].id != 0xFFFF) {" > out_file
+ print " if (vendor_ids[i].dev_list[j].id == device_id)" > out_file
+ print " return vendor_ids[i].dev_list[j].name;" > out_file
+ print " j++;" > out_file
+ print " };" > out_file
+ print " break;" > out_file
+ print " }" > out_file
+ print " }" > out_file
+ }
+ print " return NULL;" > out_file
+ print "}" > out_file
+}
+
function kill_double_quoting(fld)
{
n = split(fld, phrases, "[\"]");
new_fld = phrases[1]
- for (i = 2; i <= n; i++) new_fld = sprintf("%s\\\"%s", new_fld, phrases[i])
+ for (i = 2; i <= n; i++)
+ new_fld = sprintf("%s\\\"%s", new_fld, phrases[i])
return new_fld
}
@@ -150,10 +192,12 @@ function init_name_db()
function init_device_db()
{
# delete device_names
- for (i in device_names) delete device_names[i];
+ for (i in device_names)
+ delete device_names[i];
device_names[1] = ""
# delete subdevice_names
- for (i in subdevice_names) delete subdevice_names[i];
+ for (i in subdevice_names)
+ delete subdevice_names[i];
subdevice_names[1] = ""
}
@@ -161,10 +205,12 @@ function get_short_vendor_name(from)
{
n = split(from, name, "[ ]");
new_name = toupper(name[1]);
- if (length(new_name) < 3) new_name = sprintf("%s_%s", new_name, toupper(name[2]));
+ if (length(new_name) < 3)
+ new_name = sprintf("%s_%s", new_name, toupper(name[2]));
n = split(new_name, name, "[^0-9A-Za-z]");
svendor = name[1];
- for (i = 2; i <= n; i++) svendor = sprintf("%s%s%s", svendor, length(name[i]) ? "_" : "", name[i]);
+ for (i = 2; i <= n; i++)
+ svendor = sprintf("%s%s%s", svendor, length(name[i]) ? "_" : "", name[i]);
new_name = svendor;
vend_suffix = 2;
# check for unique
@@ -181,11 +227,14 @@ function get_short_device_name(from_name)
{
n = split(from_name, name, "[ ]");
new_name = toupper(name[1]);
- if (length(name[2])) new_name = sprintf("%s_%s", new_name, toupper(name[2]));
- if (length(name[3])) new_name = sprintf("%s_%s", new_name, toupper(name[3]));
+ if (length(name[2]))
+ new_name = sprintf("%s_%s", new_name, toupper(name[2]));
+ if (length(name[3]))
+ new_name = sprintf("%s_%s", new_name, toupper(name[3]));
n = split(new_name, name, "[^0-9A-Za-z]");
sdevice = name[1];
- for (i = 2; i <= n; i++) sdevice = sprintf("%s%s%s", sdevice, length(name[i]) ? "_" : "", name[i]);
+ for (i = 2; i <= n; i++)
+ sdevice = sprintf("%s%s%s", sdevice, length(name[i]) ? "_" : "", name[i]);
new_name = sdevice;
dev_suffix = 2;
# check for unique
@@ -202,11 +251,14 @@ function get_short_subdevice_name(from_name)
{
n = split(from_name, name, "[ ]");
new_name = toupper(name[1]);
- if (length(name[2])) new_name = sprintf("%s_%s", new_name, toupper(name[2]));
- if (length(name[3])) new_name = sprintf("%s_%s", new_name, toupper(name[3]));
+ if (length(name[2]))
+ new_name = sprintf("%s_%s", new_name, toupper(name[2]));
+ if (length(name[3]))
+ new_name = sprintf("%s_%s", new_name, toupper(name[3]));
n = split(new_name, name, "[^0-9A-Za-z]");
ssdevice = name[1];
- for (i = 2; i <= n; i++) ssdevice = sprintf("%s%s%s", ssdevice, length(name[i]) ? "_" : "", name[i]);
+ for (i = 2; i <= n; i++)
+ ssdevice = sprintf("%s%s%s", ssdevice, length(name[i]) ? "_" : "", name[i]);
new_name = ssdevice;
sdev_suffix = 2;
# check for unique
diff --git a/vidix/pci_names.c b/vidix/pci_names.c
deleted file mode 100644
index d7348446ac..0000000000
--- a/vidix/pci_names.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * VIDIX - VIDeo Interface for *niX.
- *
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stddef.h>
-#include "pci_names.h"
-#include "pci_vendor_ids.h"
-
-const char *pci_vendor_name(unsigned short id)
-{
- unsigned i;
- for (i = 0; i < sizeof(vendor_ids) / sizeof(struct vendor_id_s); i++) {
- if (vendor_ids[i].id == id)
- return vendor_ids[i].name;
- }
- return NULL;
-}
-
-const char *pci_device_name(unsigned short vendor_id, unsigned short device_id)
-{
- unsigned i, j;
- for (i = 0; i < sizeof(vendor_ids) / sizeof(struct vendor_id_s); i++) {
- if (vendor_ids[i].id == vendor_id) {
- j = 0;
- while (vendor_ids[i].dev_list[j].id != 0xFFFF) {
- if (vendor_ids[i].dev_list[j].id == device_id)
- return vendor_ids[i].dev_list[j].name;
- j++;
- };
- break;
- }
- }
- return NULL;
-}