By the way, I wrote a little Python script to ease the debugging of GBM formats. You may find it useful too. Here's the example usage:
$ gbm-format GBM_FORMAT_BGRA1010102 0x30334142 $ gbm-format 0x30334142 GBM_FORMAT_BGRA1010102 $ gbm-format B A 3 0 GBM_FORMAT_BGRA1010102 ---- -8<- ---- file: ~/bin/gbm-format #!/usr/bin/env python3 import os import os.path import re import sys PROGNAME = os.path.basename(sys.argv[0]) def print_usage(file=None): print('usage: ', file=file) print(' {0} GBM_FORMAT_XXXX'.format(PROGNAME), file=file) print(' {0} 0xabcd1234'.format(PROGNAME), file=file) print(' {0} a b c d'.format(PROGNAME), file=file) def usage_error(): print_usage(sys.stderr) sys.exit(1) def atoi(c): assert(len(c) == 1) return c.encode()[0] def gbm_fourcc_code(a, b, c, d): return (a) | (b << 8) | (c << 16) | (d << 24) def gbm_iter_header(): regex = re.compile("#define\s+(GBM_FORMAT_\w+)\s+__gbm_fourcc_code\('(.)', '(.)', '(.)', '(.)'\)") with open('/usr/include/gbm.h') as f: for line in f: m = regex.match(line) if m is None: continue test_name = m.group(1) test_code = gbm_fourcc_code(*map(atoi, m.group(2, 3, 4, 5))) yield test_name, test_code def gbm_fourcc_code_to_name(code): for hname, hcode in gbm_iter_header(): if hcode == code: return hname def gbm_fourcc_name_to_code(name): for hname, hcode in gbm_iter_header(): if hname == name: return hcode def cmd_find_name(code): name = gbm_fourcc_code_to_name(code) if name is None: die('failed to find name of fourcc code 0x{:x}'.format(code)) print(name) def cmd_find_code(name): code = gbm_fourcc_name_to_code(name) if code is None: die('failed to find fourcc code for {}'.format(name)) print('0x{:x}'.format(code)) def main(): if len(sys.argv) == 2: if sys.argv[1].startswith('GBM_FORMAT_'): name = sys.argv[1] cmd_find_code(name) elif sys.argv[1].startswith('0x') or sys.argv[1].startswith('0X'): code = int(sys.argv[1], 16) cmd_find_name(code) else: usage_error() elif len(sys.argv) == 5: code = gbm_fourcc_code(*map(atoi, sys.argv[1:5])) cmd_find_name(code) else: usage_error() if __name__ == '__main__': main()
signature.asc
Description: OpenPGP digital signature
_______________________________________________ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle