ipa: raspberrypi: Non-functional formatting fixes to md_parser.hpp
Adjust source formatting to closer match libcamera guidelines: - Switch to C style comments. - Add whitespace for readability. There are no functional changes in this commit. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
01e387acb0
commit
12fdfee68f
1 changed files with 87 additions and 58 deletions
|
@ -10,71 +10,93 @@
|
||||||
|
|
||||||
#include <libcamera/span.h>
|
#include <libcamera/span.h>
|
||||||
|
|
||||||
/* Camera metadata parser class. Usage as shown below.
|
/*
|
||||||
|
* Camera metadata parser class. Usage as shown below.
|
||||||
Setup:
|
*
|
||||||
|
* Setup:
|
||||||
Usually the metadata parser will be made as part of the CamHelper class so
|
*
|
||||||
application code doesn't have to worry which to kind to instantiate. But for
|
* Usually the metadata parser will be made as part of the CamHelper class so
|
||||||
the sake of example let's suppose we're parsing imx219 metadata.
|
* application code doesn't have to worry which kind to instantiate. But for
|
||||||
|
* the sake of example let's suppose we're parsing imx219 metadata.
|
||||||
MdParser *parser = new MdParserImx219(); // for example
|
*
|
||||||
parser->SetBitsPerPixel(bpp);
|
* MdParser *parser = new MdParserImx219(); // for example
|
||||||
parser->SetLineLengthBytes(pitch);
|
* parser->SetBitsPerPixel(bpp);
|
||||||
parser->SetNumLines(2);
|
* parser->SetLineLengthBytes(pitch);
|
||||||
|
* parser->SetNumLines(2);
|
||||||
Note 1: if you don't know how many lines there are, the size of the input
|
*
|
||||||
buffer is used as a limit instead.
|
* Note 1: if you don't know how many lines there are, the size of the input
|
||||||
|
* buffer is used as a limit instead.
|
||||||
Note 2: if you don't know the line length, you can leave the line length unset
|
*
|
||||||
(or set to zero) and the parser will hunt for the line start instead.
|
* Note 2: if you don't know the line length, you can leave the line length unset
|
||||||
|
* (or set to zero) and the parser will hunt for the line start instead.
|
||||||
Then on every frame:
|
*
|
||||||
|
* Then on every frame:
|
||||||
if (parser->Parse(buffer) != MdParser::OK)
|
*
|
||||||
much badness;
|
* if (parser->Parse(buffer) != MdParser::OK)
|
||||||
unsigned int exposure_lines, gain_code
|
* much badness;
|
||||||
if (parser->GetExposureLines(exposure_lines) != MdParser::OK)
|
* unsigned int exposure_lines, gain_code
|
||||||
exposure was not found;
|
* if (parser->GetExposureLines(exposure_lines) != MdParser::OK)
|
||||||
if (parser->GetGainCode(parser, gain_code) != MdParser::OK)
|
* exposure was not found;
|
||||||
gain code was not found;
|
* if (parser->GetGainCode(parser, gain_code) != MdParser::OK)
|
||||||
|
* gain code was not found;
|
||||||
(Note that the CamHelper class converts to/from exposure lines and time,
|
*
|
||||||
and gain_code / actual gain.)
|
* (Note that the CamHelper class converts to/from exposure lines and time,
|
||||||
|
* and gain_code / actual gain.)
|
||||||
If you suspect your embedded data may have changed its layout, change any line
|
*
|
||||||
lengths, number of lines, bits per pixel etc. that are different, and
|
* If you suspect your embedded data may have changed its layout, change any line
|
||||||
then:
|
* lengths, number of lines, bits per pixel etc. that are different, and
|
||||||
|
* then:
|
||||||
parser->Reset();
|
*
|
||||||
|
* parser->Reset();
|
||||||
before calling Parse again. */
|
*
|
||||||
|
* before calling Parse again.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace RPiController {
|
namespace RPiController {
|
||||||
|
|
||||||
// Abstract base class from which other metadata parsers are derived.
|
/* Abstract base class from which other metadata parsers are derived. */
|
||||||
|
|
||||||
class MdParser
|
class MdParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Parser status codes:
|
/*
|
||||||
// OK - success
|
* Parser status codes:
|
||||||
// NOTFOUND - value such as exposure or gain was not found
|
* OK - success
|
||||||
// ERROR - all other errors
|
* NOTFOUND - value such as exposure or gain was not found
|
||||||
|
* ERROR - all other errors
|
||||||
|
*/
|
||||||
enum Status {
|
enum Status {
|
||||||
OK = 0,
|
OK = 0,
|
||||||
NOTFOUND = 1,
|
NOTFOUND = 1,
|
||||||
ERROR = 2
|
ERROR = 2
|
||||||
};
|
};
|
||||||
MdParser() : reset_(true) {}
|
|
||||||
|
MdParser() : reset_(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~MdParser() = default;
|
virtual ~MdParser() = default;
|
||||||
void Reset() { reset_ = true; }
|
|
||||||
void SetBitsPerPixel(int bpp) { bits_per_pixel_ = bpp; }
|
void Reset()
|
||||||
void SetNumLines(unsigned int num_lines) { num_lines_ = num_lines; }
|
{
|
||||||
|
reset_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBitsPerPixel(int bpp)
|
||||||
|
{
|
||||||
|
bits_per_pixel_ = bpp;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetNumLines(unsigned int num_lines)
|
||||||
|
{
|
||||||
|
num_lines_ = num_lines;
|
||||||
|
}
|
||||||
|
|
||||||
void SetLineLengthBytes(unsigned int num_bytes)
|
void SetLineLengthBytes(unsigned int num_bytes)
|
||||||
{
|
{
|
||||||
line_length_bytes_ = num_bytes;
|
line_length_bytes_ = num_bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Status Parse(libcamera::Span<const uint8_t> buffer) = 0;
|
virtual Status Parse(libcamera::Span<const uint8_t> buffer) = 0;
|
||||||
virtual Status GetExposureLines(unsigned int &lines) = 0;
|
virtual Status GetExposureLines(unsigned int &lines) = 0;
|
||||||
virtual Status GetGainCode(unsigned int &gain_code) = 0;
|
virtual Status GetGainCode(unsigned int &gain_code) = 0;
|
||||||
|
@ -87,22 +109,28 @@ protected:
|
||||||
unsigned int buffer_size_bytes_;
|
unsigned int buffer_size_bytes_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This isn't a full implementation of a metadata parser for SMIA sensors,
|
/*
|
||||||
// however, it does provide the findRegs method which will prove useful and make
|
* This isn't a full implementation of a metadata parser for SMIA sensors,
|
||||||
// it easier to implement parsers for other SMIA-like sensors (see
|
* however, it does provide the findRegs method which will prove useful and make
|
||||||
// md_parser_imx219.cpp for an example).
|
* it easier to implement parsers for other SMIA-like sensors (see
|
||||||
|
* md_parser_imx219.cpp for an example).
|
||||||
|
*/
|
||||||
|
|
||||||
class MdParserSmia : public MdParser
|
class MdParserSmia : public MdParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MdParserSmia() : MdParser() {}
|
MdParserSmia() : MdParser()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Note that error codes > 0 are regarded as non-fatal; codes < 0
|
/*
|
||||||
// indicate a bad data buffer. Status codes are:
|
* Note that error codes > 0 are regarded as non-fatal; codes < 0
|
||||||
// PARSE_OK - found all registers, much happiness
|
* indicate a bad data buffer. Status codes are:
|
||||||
// MISSING_REGS - some registers found; should this be a hard error?
|
* PARSE_OK - found all registers, much happiness
|
||||||
// The remaining codes are all hard errors.
|
* MISSING_REGS - some registers found; should this be a hard error?
|
||||||
|
* The remaining codes are all hard errors.
|
||||||
|
*/
|
||||||
enum ParseStatus {
|
enum ParseStatus {
|
||||||
PARSE_OK = 0,
|
PARSE_OK = 0,
|
||||||
MISSING_REGS = 1,
|
MISSING_REGS = 1,
|
||||||
|
@ -112,6 +140,7 @@ protected:
|
||||||
BAD_LINE_END = -4,
|
BAD_LINE_END = -4,
|
||||||
BAD_PADDING = -5
|
BAD_PADDING = -5
|
||||||
};
|
};
|
||||||
|
|
||||||
ParseStatus findRegs(libcamera::Span<const uint8_t> buffer, uint32_t regs[],
|
ParseStatus findRegs(libcamera::Span<const uint8_t> buffer, uint32_t regs[],
|
||||||
int offsets[], unsigned int num_regs);
|
int offsets[], unsigned int num_regs);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue