diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-03-02 01:14:36 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-03-02 01:14:36 +0100 |
commit | 41ffab7b32df1756e78af92ff68ff40afb75e1d5 (patch) | |
tree | 3bcddc3dfaa9f6ad7afbd0cf31f09d6bceb8e208 /chip-data/ati/drm_pciids.awk | |
parent | 273765aa78125b2106218ad554e6dedad7d2b381 (diff) | |
parent | 52bcf6e79eb3085b598a9ca0d21f60879a0e3706 (diff) | |
download | bugzilla-triage-41ffab7b32df1756e78af92ff68ff40afb75e1d5.tar.gz |
Merge branch 'pageMod' into next
Conflicts:
lib/bzpage.js
Diffstat (limited to 'chip-data/ati/drm_pciids.awk')
-rwxr-xr-x | chip-data/ati/drm_pciids.awk | 94 |
1 files changed, 94 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..898f496 --- /dev/null +++ b/chip-data/ati/drm_pciids.awk @@ -0,0 +1,94 @@ +#!/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)) + chip_type = 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 +} |