libcamera: video_device: Convert between ColorSpace class and V4L2 formats

Add functions to the V4L2Device class to convert to and from
libcamera ColorSpace.

These functions are added to the base V4L2Device class so that they can
be shared both by the video device class and subdevices.

With the ColorSpace class, the color space and related other fields
are stored together, corresponding to a number of fields in the
various different V4L2 format structures. Template functions are
therefore a convenient implementation, and we must explicitly
instantiate the templates that will be needed.

Note that unset color spaces are converted to requests for the
device's "default" color space.

Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
2 files changed