[PATCH v1] libcamera: pipeline: uvcvideo: Expose `Gamma` control

Kieran Bingham kieran.bingham at ideasonboard.com
Fri Mar 21 17:00:44 CET 2025


Quoting Barnabás Pőcze (2025-03-10 17:03:13)
> Commit 294ead848c3fa2 ("libcamera: Add gamma control id")
> introduced the "Gamma" control, so expose it for UVC
> cameras as well using the `V4L2_CID_GAMMA` control.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze at ideasonboard.com>

I've just tested this on a UVC camera with camshark, and the controls
seem to work as I expect:


Tested-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

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

> ---
>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> index 7470b5627..8a845233d 100644
> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp
> @@ -304,6 +304,8 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id,
>                 cid = V4L2_CID_EXPOSURE_ABSOLUTE;
>         else if (id == controls::AnalogueGain)
>                 cid = V4L2_CID_GAIN;
> +       else if (id == controls::Gamma)
> +               cid = V4L2_CID_GAMMA;
>         else
>                 return -EINVAL;
>  
> @@ -358,6 +360,10 @@ int PipelineHandlerUVC::processControl(ControlList *controls, unsigned int id,
>                 break;
>         }
>  
> +       case V4L2_CID_GAMMA:
> +               controls->set(cid, static_cast<int32_t>(std::lround(value.get<float>() * 100)));
> +               break;
> +
>         default: {
>                 int32_t ivalue = value.get<int32_t>();
>                 controls->set(cid, ivalue);
> @@ -655,6 +661,9 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,
>         case V4L2_CID_GAIN:
>                 id = &controls::AnalogueGain;
>                 break;
> +       case V4L2_CID_GAMMA:
> +               id = &controls::Gamma;
> +               break;
>         default:
>                 return;
>         }
> @@ -782,6 +791,15 @@ void UVCCameraData::addControl(uint32_t cid, const ControlInfo &v4l2Info,
>                 break;
>         }
>  
> +       case V4L2_CID_GAMMA:
> +               /* UVC gamma is in units of 1/100 gamma. */
> +               info = ControlInfo{
> +                       { min / 100.0f },
> +                       { max / 100.0f },
> +                       { def / 100.0f }
> +               };
> +               break;
> +
>         default:
>                 info = v4l2Info;
>                 break;
> -- 
> 2.48.1
>


More information about the libcamera-devel mailing list