Created
February 25, 2022 11:02
-
-
Save kbingham/1e500c7113eb594c1d8e081052c2c9d2 to your computer and use it in GitHub Desktop.
Quick tool to help reviewing Camera Sensor drivers in linux-media to support libcamera requirements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
function initialiseControls(ids, keys, controls) | |
{ | |
split(ids, keys) | |
for (i in keys) controls[keys[i]] = "--------" | |
} | |
BEGIN { | |
print "Processing " ARGV[1] | |
# Required Media Controller support | |
mc = " \ | |
MEDIA_ENT_F_CAM_SENSOR \ | |
V4L2_SUBDEV_FL_HAS_DEVNODE \ | |
" | |
initialiseControls(mc, mcKeys, mcIdentifiers) | |
# Required controls that libcamera can not create a camera without | |
mandatory = " \ | |
V4L2_CID_EXPOSURE \ | |
V4L2_CID_HBLANK \ | |
V4L2_CID_PIXEL_RATE \ | |
V4L2_CID_VBLANK \ | |
" | |
initialiseControls(mandatory, mandatoryKeys, mandatoryControls) | |
# Track support for Selection APIs | |
selection = " \ | |
.get_selection \ | |
V4L2_SEL_TGT_CROP_BOUNDS \ | |
V4L2_SEL_TGT_CROP_DEFAULT \ | |
V4L2_SEL_TGT_CROP \ | |
" | |
initialiseControls(selection, selectionKeys, selectionControls) | |
# Optionally provided controls that add functionality | |
optional = " \ | |
V4L2_CID_CAMERA_ORIENTATION \ | |
V4L2_CID_CAMERA_SENSOR_ROTATION \ | |
V4L2_CID_ANALOGUE_GAIN \ | |
V4L2_CID_GAIN \ | |
V4L2_CID_TEST_PATTERN \ | |
" | |
initialiseControls(optional, optionalKeys, optionalControls) | |
} | |
function findKeys(line, keys, list) | |
{ | |
for (i in keys) | |
if ( line ~ keys[i] ) | |
{ list[keys[i]] = "found" } | |
} | |
# Search for identifiers in the input, and record when they are found | |
{ | |
findKeys($0, mcKeys, mcIdentifiers) | |
findKeys($0, mandatoryKeys, mandatoryControls) | |
findKeys($0, selectionKeys, selectionControls) | |
findKeys($0, optionalKeys, optionalControls) | |
} | |
# Report results to the caller. | |
# | |
# Identify if there are any keys that were not found. | |
# This could be extended to exit with a failure | |
# if a required key is not located. | |
function reportControls(controls, message) { | |
print message | |
missing = 0 | |
for (c in controls) { | |
print " - " c " : " controls[c] | |
if (controls[c] == "--------") | |
missing = 1 | |
} | |
if (missing) { | |
print "Failed to find some keys" | |
} | |
print "" | |
} | |
END { | |
reportControls(mcIdentifiers, "Media Controller Support:") | |
reportControls(mandatoryControls, "Mandatory Controls:") | |
reportControls(selectionControls, "Selection Controls (will become mandatory):") | |
reportControls(optionalControls, "Optional Controls:") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment