Message ID | 20240305110136.3624-3-nick.hollinghurst@raspberrypi.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Nick, Thank you for the patch. On Tue, Mar 05, 2024 at 11:01:36AM +0000, Nick Hollinghurst wrote: > Fix embedded data byte-skipping for 14-bit modes (4 out of 7 bytes > carry register data), and allow 14-bit modes in IMX708 PDAF parsing. > > Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/ipa/rpi/cam_helper/cam_helper_imx708.cpp | 2 +- > src/ipa/rpi/cam_helper/md_parser_smia.cpp | 11 +++++++---- > 2 files changed, 8 insertions(+), 5 deletions(-) > > diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp > index dce39cd5..906c6fa2 100644 > --- a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp > +++ b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp > @@ -269,7 +269,7 @@ bool CamHelperImx708::parsePdafData(const uint8_t *ptr, size_t len, > { > size_t step = bpp >> 1; /* bytes per PDAF grid entry */ > > - if (bpp < 10 || bpp > 12 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) { > + if (bpp < 10 || bpp > 14 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) { > LOG(IPARPI, Error) << "PDAF data in unsupported format"; > return false; > } > diff --git a/src/ipa/rpi/cam_helper/md_parser_smia.cpp b/src/ipa/rpi/cam_helper/md_parser_smia.cpp > index 210787ed..c5b806d7 100644 > --- a/src/ipa/rpi/cam_helper/md_parser_smia.cpp > +++ b/src/ipa/rpi/cam_helper/md_parser_smia.cpp > @@ -86,10 +86,13 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t> > while (1) { > int tag = buffer[currentOffset++]; > > - if ((bitsPerPixel_ == 10 && > - (currentOffset + 1 - currentLineStart) % 5 == 0) || > - (bitsPerPixel_ == 12 && > - (currentOffset + 1 - currentLineStart) % 3 == 0)) { > + /* Non-dummy bytes come in even-sized blocks: skip can only ever follow tag */ > + while ((bitsPerPixel_ == 10 && > + (currentOffset + 1 - currentLineStart) % 5 == 0) || > + (bitsPerPixel_ == 12 && > + (currentOffset + 1 - currentLineStart) % 3 == 0) || > + (bitsPerPixel_ == 14 && > + (currentOffset - currentLineStart) % 7 >= 4)) { > if (buffer[currentOffset++] != RegSkip) > return BadDummy; > }
Hi Nick, On Tue, 5 Mar 2024 at 11:01, Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> wrote: > > Fix embedded data byte-skipping for 14-bit modes (4 out of 7 bytes > carry register data), and allow 14-bit modes in IMX708 PDAF parsing. > > Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> Reviewed-by: Naushir Patuck <naush@raspberrypi.com> > --- > src/ipa/rpi/cam_helper/cam_helper_imx708.cpp | 2 +- > src/ipa/rpi/cam_helper/md_parser_smia.cpp | 11 +++++++---- > 2 files changed, 8 insertions(+), 5 deletions(-) > > diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp > index dce39cd5..906c6fa2 100644 > --- a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp > +++ b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp > @@ -269,7 +269,7 @@ bool CamHelperImx708::parsePdafData(const uint8_t *ptr, size_t len, > { > size_t step = bpp >> 1; /* bytes per PDAF grid entry */ > > - if (bpp < 10 || bpp > 12 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) { > + if (bpp < 10 || bpp > 14 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) { > LOG(IPARPI, Error) << "PDAF data in unsupported format"; > return false; > } > diff --git a/src/ipa/rpi/cam_helper/md_parser_smia.cpp b/src/ipa/rpi/cam_helper/md_parser_smia.cpp > index 210787ed..c5b806d7 100644 > --- a/src/ipa/rpi/cam_helper/md_parser_smia.cpp > +++ b/src/ipa/rpi/cam_helper/md_parser_smia.cpp > @@ -86,10 +86,13 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t> > while (1) { > int tag = buffer[currentOffset++]; > > - if ((bitsPerPixel_ == 10 && > - (currentOffset + 1 - currentLineStart) % 5 == 0) || > - (bitsPerPixel_ == 12 && > - (currentOffset + 1 - currentLineStart) % 3 == 0)) { > + /* Non-dummy bytes come in even-sized blocks: skip can only ever follow tag */ > + while ((bitsPerPixel_ == 10 && > + (currentOffset + 1 - currentLineStart) % 5 == 0) || > + (bitsPerPixel_ == 12 && > + (currentOffset + 1 - currentLineStart) % 3 == 0) || > + (bitsPerPixel_ == 14 && > + (currentOffset - currentLineStart) % 7 >= 4)) { > if (buffer[currentOffset++] != RegSkip) > return BadDummy; > } > -- > 2.30.2 >
diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp index dce39cd5..906c6fa2 100644 --- a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp +++ b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp @@ -269,7 +269,7 @@ bool CamHelperImx708::parsePdafData(const uint8_t *ptr, size_t len, { size_t step = bpp >> 1; /* bytes per PDAF grid entry */ - if (bpp < 10 || bpp > 12 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) { + if (bpp < 10 || bpp > 14 || len < 194 * step || ptr[0] != 0 || ptr[1] >= 0x40) { LOG(IPARPI, Error) << "PDAF data in unsupported format"; return false; } diff --git a/src/ipa/rpi/cam_helper/md_parser_smia.cpp b/src/ipa/rpi/cam_helper/md_parser_smia.cpp index 210787ed..c5b806d7 100644 --- a/src/ipa/rpi/cam_helper/md_parser_smia.cpp +++ b/src/ipa/rpi/cam_helper/md_parser_smia.cpp @@ -86,10 +86,13 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t> while (1) { int tag = buffer[currentOffset++]; - if ((bitsPerPixel_ == 10 && - (currentOffset + 1 - currentLineStart) % 5 == 0) || - (bitsPerPixel_ == 12 && - (currentOffset + 1 - currentLineStart) % 3 == 0)) { + /* Non-dummy bytes come in even-sized blocks: skip can only ever follow tag */ + while ((bitsPerPixel_ == 10 && + (currentOffset + 1 - currentLineStart) % 5 == 0) || + (bitsPerPixel_ == 12 && + (currentOffset + 1 - currentLineStart) % 3 == 0) || + (bitsPerPixel_ == 14 && + (currentOffset - currentLineStart) % 7 >= 4)) { if (buffer[currentOffset++] != RegSkip) return BadDummy; }
Fix embedded data byte-skipping for 14-bit modes (4 out of 7 bytes carry register data), and allow 14-bit modes in IMX708 PDAF parsing. Signed-off-by: Nick Hollinghurst <nick.hollinghurst@raspberrypi.com> --- src/ipa/rpi/cam_helper/cam_helper_imx708.cpp | 2 +- src/ipa/rpi/cam_helper/md_parser_smia.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-)