[v1] libcamera: control_serializer: Accept empty `ControlList`
diff mbox series

Message ID 20250721115029.1561179-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1] libcamera: control_serializer: Accept empty `ControlList`
Related show

Commit Message

Barnabás Pőcze July 21, 2025, 11:50 a.m. UTC
Accept empty `ControlList`s without an info map. Serialization
supports `ControlList`s without an associated `ControlInfoMap`
object. However, for deserialization, a "v4l2" control list
without an info map resulted in a fatal error.

After 30114cadd8cb65 ("ipa: rpi: Defer initialising AF LensPosition ControlInfo and value")
the `lensControls` member of `ipa::RPi::ConfigResult` is left empty
and without an info map in every case, not just when a lens is not present.
This causes the above assertion to trigger every single time.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/libcamera/control_serializer.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Isaac Scott July 21, 2025, 5:45 p.m. UTC | #1
Hi Barnabás,

Thank you for the patch!

On Mon, 2025-07-21 at 13:50 +0200, Barnabás Pőcze wrote:
> Accept empty `ControlList`s without an info map. Serialization
> supports `ControlList`s without an associated `ControlInfoMap`
> object. However, for deserialization, a "v4l2" control list
> without an info map resulted in a fatal error.
> 
> After 30114cadd8cb65 ("ipa: rpi: Defer initialising AF LensPosition
> ControlInfo and value")
> the `lensControls` member of `ipa::RPi::ConfigResult` is left empty
> and without an info map in every case, not just when a lens is not
> present.
> This causes the above assertion to trigger every single time.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/libcamera/control_serializer.cpp | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/control_serializer.cpp
> b/src/libcamera/control_serializer.cpp
> index 17834648c..1534fc5c8 100644
> --- a/src/libcamera/control_serializer.cpp
> +++ b/src/libcamera/control_serializer.cpp
> @@ -601,8 +601,11 @@ ControlList
> ControlSerializer::deserialize<ControlList>(ByteStreamBuffer &buffer
>  
>  		case IPA_CONTROL_ID_MAP_V4L2:
>  		default:
> -			LOG(Serializer, Fatal)
> -				<< "A list of V4L2 controls requires
> an ControlInfoMap";
> +			if (hdr->entries > 0) {
> +				LOG(Serializer, Fatal)
> +					<< "A list of V4L2 controls
> requires an ControlInfoMap";
> +			}
> +

Reviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>

>  			return {};
>  		}
>  	}
Kieran Bingham July 21, 2025, 7:09 p.m. UTC | #2
Quoting Barnabás Pőcze (2025-07-21 12:50:29)
> Accept empty `ControlList`s without an info map. Serialization
> supports `ControlList`s without an associated `ControlInfoMap`
> object. However, for deserialization, a "v4l2" control list
> without an info map resulted in a fatal error.
> 
> After 30114cadd8cb65 ("ipa: rpi: Defer initialising AF LensPosition ControlInfo and value")
> the `lensControls` member of `ipa::RPi::ConfigResult` is left empty
> and without an info map in every case, not just when a lens is not present.
> This causes the above assertion to trigger every single time.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
> ---
>  src/libcamera/control_serializer.cpp | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp
> index 17834648c..1534fc5c8 100644
> --- a/src/libcamera/control_serializer.cpp
> +++ b/src/libcamera/control_serializer.cpp
> @@ -601,8 +601,11 @@ ControlList ControlSerializer::deserialize<ControlList>(ByteStreamBuffer &buffer
>  
>                 case IPA_CONTROL_ID_MAP_V4L2:
>                 default:
> -                       LOG(Serializer, Fatal)
> -                               << "A list of V4L2 controls requires an ControlInfoMap";
> +                       if (hdr->entries > 0) {
> +                               LOG(Serializer, Fatal)
> +                                       << "A list of V4L2 controls requires an ControlInfoMap";
> +                       }
> +

I think this sounds ok ... I have nothing to argue against it ...


Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

>                         return {};
>                 }
>         }
> -- 
> 2.50.1
>

Patch
diff mbox series

diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp
index 17834648c..1534fc5c8 100644
--- a/src/libcamera/control_serializer.cpp
+++ b/src/libcamera/control_serializer.cpp
@@ -601,8 +601,11 @@  ControlList ControlSerializer::deserialize<ControlList>(ByteStreamBuffer &buffer
 
 		case IPA_CONTROL_ID_MAP_V4L2:
 		default:
-			LOG(Serializer, Fatal)
-				<< "A list of V4L2 controls requires an ControlInfoMap";
+			if (hdr->entries > 0) {
+				LOG(Serializer, Fatal)
+					<< "A list of V4L2 controls requires an ControlInfoMap";
+			}
+
 			return {};
 		}
 	}