libcamera: utils: Add hex stream output helper

Add a utils::hex() function that simplifies writing hexadecimal values
to an ostream. The function handles the '0x' prefix, the field width and
the fill character automatically. Use it through the libcamera code
base, and add a test.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart 2019-10-13 22:22:04 +03:00
parent ce739e616c
commit f391048a7b
11 changed files with 147 additions and 22 deletions

View file

@ -13,6 +13,7 @@
#include "camera_sensor.h"
#include "device_enumerator.h"
#include "media_device.h"
#include "utils.h"
#include "v4l2_subdevice.h"
#include "test.h"
@ -91,7 +92,7 @@ protected:
if (format.mbus_code != MEDIA_BUS_FMT_SBGGR10_1X10 ||
format.size != Size(4096, 2160)) {
cerr << "Failed to get a suitable format, expected 4096x2160-0x"
<< std::hex << MEDIA_BUS_FMT_SBGGR10_1X10
<< utils::hex(MEDIA_BUS_FMT_SBGGR10_1X10)
<< ", got " << format.toString() << endl;
return TestFail;
}