-
Notifications
You must be signed in to change notification settings - Fork 8.2k
drivers: video: add format utilities to improve usability #79476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: video: add format utilities to improve usability #79476
Conversation
include/zephyr/drivers/video.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From macro below, should be "{fourcc} {width}x{height}" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I changed it after seeing how v4l2-ctl and the examples show the formats but forgot to update thedoc. I will adjust it along with other doc fixups.
Thank you for pointing it!
29a4758 to
6c21f48
Compare
c021247 to
d541c10
Compare
|
force-push: CI fixes |
d541c10 to
a9587f1
Compare
|
force-push: use |
12ca486 to
75345f9
Compare
|
force-push: split |
75345f9 to
ac056cf
Compare
doc/releases/migration-guide-4.1.rst
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use BITS_PER_BYTE throughout this change.
cfriedt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use BITS_PER_BYTE instead of /8 or *8
e8ad2e7 to
6ce200d
Compare
6ce200d to
f1bc836
Compare
f1bc836 to
7e1e702
Compare
|
@josuah can you please rebase? random CI glitch causing a job to be stuck and can't seem to be able to re-trigger it manually. Thanks! |
Introduce a new text documentation of the video formats, describing every bit, gives the position of the most significant bit, outline how it is cut in bytes, and show the pixel segmentation. Extra care is taken for the RGB565 which requies paying attention to the bit endianess as well as the byte endianess. Signed-off-by: Josuah Demangeon <[email protected]>
Rename video_fourcc() to VIDEO_FOURCC(), differing from the Linux implementation, but more compliant with the coding style. Also introduce a VIDEO_FOURCC_FROM_STR() to generate a FOURCC format code out of a 4-characters string. Signed-off-by: Josuah Demangeon <[email protected]>
This was present in the form of video_pix_fmt_bpp() inside ST and NXP drivers, and was returning the number of bytes, which does not allow support for 10-bits, 4-bits or non-byte aligned video formats. The helper leverages the VIDEO_PIX_FMT_*_BITS macros. Signed-off-by: Josuah Demangeon <[email protected]>
The previous commit introduces video_bits_per_pixel() and converts all invocation relying on video_pix_fmt_bpp(), 3rd-party users will need to do the same on their code, and this is not a 100% drop-in API, so better document it on the release notes. Signed-off-by: Josuah Demangeon <[email protected]>
7e1e702 to
a35b5c6
Compare
|
Yes of course! |
kartben
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes of course!
Thanks! Didn't expect it to dismiss existing approvals as I don't think there were any conflicts but, anyway, refresh +1 :)
Introduce several enhancements for dealing with the video API:
note: this image is wrong for RGB565 format!

But in a text-based format to be easy to maintain and colorblindness-friendly, and easy to
grepthrough[EDIT: fixed version below]:Add a printf() formatter like stdint.h's PRIu32:
printf("video format: " PRIvfmt, PRIvfmt_arg(&fmt));This is present elsewhere on Zephyr
Convert
video_fourcc()toVIDEO_FOURCC()and make it visible to the documentation, now that it is used outside of the header itself.Add a
VIDEO_FOURCC_FROM_STR()to easily convert a string from i.e. Kconfig or the devicetree.Looking forward to your feedback and advises.