diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-02-20 01:21:39 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-02-20 01:21:39 +0100 |
commit | 2abc7e13fe87f92feceafaf348f553cf8b6c9b9e (patch) | |
tree | 6956d68273a6e15b4abf5c8bcb2437ad851eae1c /chip-data/ati/drm_pciids.awk | |
parent | 71df561fef80abf523548727d77dba2ef8ab7b93 (diff) | |
download | bugzilla-triage-2abc7e13fe87f92feceafaf348f553cf8b6c9b9e.tar.gz |
Fix fill-in magic.
* changed regexp for parsing driver line, just PCI ID is
relevant.
* all magic is now in data
* eliminated most unnecessary console.logs ... either changed
to console.error or just removed.
Diffstat (limited to 'chip-data/ati/drm_pciids.awk')
-rwxr-xr-x | chip-data/ati/drm_pciids.awk | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/chip-data/ati/drm_pciids.awk b/chip-data/ati/drm_pciids.awk new file mode 100755 index 0000000..dea8fd2 --- /dev/null +++ b/chip-data/ati/drm_pciids.awk @@ -0,0 +1,93 @@ +#!/usr/bin/gawk -f + +BEGIN { + FS=", " + + # NOTE: please edit flags template as well + flag_letter["RADEON_IS_MOBILITY"] = "m" + flag_letter["RADEON_NEW_MEMMAP"] = "M" + flag_letter["RADEON_IS_IGP"] = "i" + flag_letter["RADEON_IS_IGPGART"] = "I" + flag_letter["RADEON_SINGLE_CRTC"] = "c" + flags_template = "mMiIc" + first_line = "" + printf("{\n") +} + +function error(f, s1, s2) { + printf("%s:%d: " f "\n", FILENAME, NR, s1, s2) >"/dev/stderr" + error_code = 1 +} + +function flag_to_letter(f_name) +{ + if (f_name in flag_letter) { + return flag_letter[f_name] + } else { + error("unknown flag %s%s", f_name) + return f_name + } +} + +function format_flags(f_code, i, n, l, out) { + n = length(flags_template) + for (i=1; i<=n; i++) { + l = substr(flags_template, i, 1) + out = out f_code[l] + delete f_code[l] + } + for (l in f_code) { + out = out f_code[l] + if (length(l)==1) + error("flag \"%s\" missing from flags_template", l, "") + } + if (length(out)>0) { + out = ",\"" out "\"" + } + return out +} + +/^[[:blank:]]+{0x/ { + sub(/^[[:blank:]]+{/,"") + sub(/},[[:blank:]]*\\$/,"") + + id_vendor = $1; sub(/^0x/, "", id_vendor) + id_type = $2; sub(/^0x/, "", id_type) + + flags = $7 + + if (flags == "0") + next + + n_flag_arr = split(flags, flag_arr, "|") + first_flag = flag_arr[1] + delete f_code + for (i=2; i<=n_flag_arr; i++) { + l = flag_to_letter(flag_arr[i]) + f_code[l] = l + } + + formatted_flags = format_flags(f_code) + + # second param to gensub is the replacement text: + chip_type = tolower(gensub(/^CHIP_/, "", "", first_flag)) + + if (length(first_line) > 0) { + printf(",\n") + } else { + first_line = "TRUE" + } + if ((chip_type in types) && types[chip_type] != first_flag) + error("chip name collision: %s vs. %s", \ + types[chip_type], first_flag) + + types[chip_type] = first_flag + + printf("\t\"%s,%s\":[\"%s\"%s]", toupper(id_vendor), toupper(id_type),\ + chip_type, formatted_flags) +} + +END { + printf("\n}\n") + exit error_code +} |