18c2ecf20Sopenharmony_ci#!/bin/sh
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: LGPL-2.1
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci[ $# -eq 1 ] && header_dir=$1 || header_dir=tools/include/uapi/drm/
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciprintf "#ifndef DRM_COMMAND_BASE\n"
78c2ecf20Sopenharmony_cigrep "#define DRM_COMMAND_BASE" $header_dir/drm.h
88c2ecf20Sopenharmony_ciprintf "#endif\n"
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciprintf "static const char *drm_ioctl_cmds[] = {\n"
118c2ecf20Sopenharmony_cigrep "^#define DRM_IOCTL.*DRM_IO" $header_dir/drm.h | \
128c2ecf20Sopenharmony_ci	sed -r 's/^#define +DRM_IOCTL_([A-Z0-9_]+)[	 ]+DRM_IO[A-Z]* *\( *(0x[[:xdigit:]]+),*.*/	[\2] = "\1",/g'
138c2ecf20Sopenharmony_cigrep "^#define DRM_I915_[A-Z_0-9]\+[	 ]\+0x" $header_dir/i915_drm.h | \
148c2ecf20Sopenharmony_ci	sed -r 's/^#define +DRM_I915_([A-Z0-9_]+)[	 ]+(0x[[:xdigit:]]+)/\t[DRM_COMMAND_BASE + \2] = "I915_\1",/g'
158c2ecf20Sopenharmony_ciprintf "};\n"
16