Message ID | 20210906225636.14683-4-laurent.pinchart@ideasonboard.com |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
On 06/09/2021 23:56, Laurent Pinchart wrote: > Replace manual looked for V4L2 pixel format in the PixelFormatInfo with s/looked/searches/ ? > the V4L2PixelFormat::fromPixelFormat() helper function. This prepares > for multi-planar support that will modify how V4L2 pixel formats are > stored in PixelFormatInfo. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > --- > src/libcamera/pipeline/ipu3/cio2.cpp | 4 +--- > src/v4l2/v4l2_camera_proxy.cpp | 9 +++------ > 2 files changed, 4 insertions(+), 9 deletions(-) > > diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp > index 9cedcb5b2879..dc62ab197acb 100644 > --- a/src/libcamera/pipeline/ipu3/cio2.cpp > +++ b/src/libcamera/pipeline/ipu3/cio2.cpp > @@ -203,9 +203,7 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat) > if (itInfo == mbusCodesToPixelFormat.end()) > return -EINVAL; > > - const PixelFormatInfo &info = PixelFormatInfo::info(itInfo->second); > - > - outputFormat->fourcc = info.v4l2Format; > + outputFormat->fourcc = V4L2PixelFormat::fromPixelFormat(itInfo->second); > outputFormat->size = sensorFormat.size; > outputFormat->planesCount = 1; > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp > index 07b1a90aa32f..d926a7b77083 100644 > --- a/src/v4l2/v4l2_camera_proxy.cpp > +++ b/src/v4l2/v4l2_camera_proxy.cpp > @@ -164,12 +164,11 @@ bool V4L2CameraProxy::validateMemoryType(uint32_t memory) > > void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig) > { > - const PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat); > const Size &size = streamConfig.size; > > v4l2PixFormat_.width = size.width; > v4l2PixFormat_.height = size.height; > - v4l2PixFormat_.pixelformat = info.v4l2Format; > + v4l2PixFormat_.pixelformat = V4L2PixelFormat::fromPixelFormat(streamConfig.pixelFormat); > v4l2PixFormat_.field = V4L2_FIELD_NONE; > v4l2PixFormat_.bytesperline = streamConfig.stride; > v4l2PixFormat_.sizeimage = streamConfig.frameSize; > @@ -276,7 +275,7 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc * > /* \todo Add map from format to description. */ > utils::strlcpy(reinterpret_cast<char *>(arg->description), > "Video Format Description", sizeof(arg->description)); > - arg->pixelformat = PixelFormatInfo::info(format).v4l2Format; > + arg->pixelformat = V4L2PixelFormat::fromPixelFormat(format); > > memset(arg->reserved, 0, sizeof(arg->reserved)); > > @@ -311,11 +310,9 @@ int V4L2CameraProxy::tryFormat(struct v4l2_format *arg) > return -EINVAL; > } > > - const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat); > - > arg->fmt.pix.width = config.size.width; > arg->fmt.pix.height = config.size.height; > - arg->fmt.pix.pixelformat = info.v4l2Format; > + arg->fmt.pix.pixelformat = V4L2PixelFormat::fromPixelFormat(config.pixelFormat); > arg->fmt.pix.field = V4L2_FIELD_NONE; > arg->fmt.pix.bytesperline = config.stride; > arg->fmt.pix.sizeimage = config.frameSize; >
On Tue, Sep 07, 2021 at 12:27:03AM +0100, Kieran Bingham wrote: > On 06/09/2021 23:56, Laurent Pinchart wrote: > > Replace manual looked for V4L2 pixel format in the PixelFormatInfo with > > s/looked/searches/ ? I meant lookup, but searches is nice too. > > the V4L2PixelFormat::fromPixelFormat() helper function. This prepares > > for multi-planar support that will modify how V4L2 pixel formats are > > stored in PixelFormatInfo. > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> > > > --- > > src/libcamera/pipeline/ipu3/cio2.cpp | 4 +--- > > src/v4l2/v4l2_camera_proxy.cpp | 9 +++------ > > 2 files changed, 4 insertions(+), 9 deletions(-) > > > > diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp > > index 9cedcb5b2879..dc62ab197acb 100644 > > --- a/src/libcamera/pipeline/ipu3/cio2.cpp > > +++ b/src/libcamera/pipeline/ipu3/cio2.cpp > > @@ -203,9 +203,7 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat) > > if (itInfo == mbusCodesToPixelFormat.end()) > > return -EINVAL; > > > > - const PixelFormatInfo &info = PixelFormatInfo::info(itInfo->second); > > - > > - outputFormat->fourcc = info.v4l2Format; > > + outputFormat->fourcc = V4L2PixelFormat::fromPixelFormat(itInfo->second); > > outputFormat->size = sensorFormat.size; > > outputFormat->planesCount = 1; > > > > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp > > index 07b1a90aa32f..d926a7b77083 100644 > > --- a/src/v4l2/v4l2_camera_proxy.cpp > > +++ b/src/v4l2/v4l2_camera_proxy.cpp > > @@ -164,12 +164,11 @@ bool V4L2CameraProxy::validateMemoryType(uint32_t memory) > > > > void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig) > > { > > - const PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat); > > const Size &size = streamConfig.size; > > > > v4l2PixFormat_.width = size.width; > > v4l2PixFormat_.height = size.height; > > - v4l2PixFormat_.pixelformat = info.v4l2Format; > > + v4l2PixFormat_.pixelformat = V4L2PixelFormat::fromPixelFormat(streamConfig.pixelFormat); > > v4l2PixFormat_.field = V4L2_FIELD_NONE; > > v4l2PixFormat_.bytesperline = streamConfig.stride; > > v4l2PixFormat_.sizeimage = streamConfig.frameSize; > > @@ -276,7 +275,7 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc * > > /* \todo Add map from format to description. */ > > utils::strlcpy(reinterpret_cast<char *>(arg->description), > > "Video Format Description", sizeof(arg->description)); > > - arg->pixelformat = PixelFormatInfo::info(format).v4l2Format; > > + arg->pixelformat = V4L2PixelFormat::fromPixelFormat(format); > > > > memset(arg->reserved, 0, sizeof(arg->reserved)); > > > > @@ -311,11 +310,9 @@ int V4L2CameraProxy::tryFormat(struct v4l2_format *arg) > > return -EINVAL; > > } > > > > - const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat); > > - > > arg->fmt.pix.width = config.size.width; > > arg->fmt.pix.height = config.size.height; > > - arg->fmt.pix.pixelformat = info.v4l2Format; > > + arg->fmt.pix.pixelformat = V4L2PixelFormat::fromPixelFormat(config.pixelFormat); > > arg->fmt.pix.field = V4L2_FIELD_NONE; > > arg->fmt.pix.bytesperline = config.stride; > > arg->fmt.pix.sizeimage = config.frameSize; > >
diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 9cedcb5b2879..dc62ab197acb 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -203,9 +203,7 @@ int CIO2Device::configure(const Size &size, V4L2DeviceFormat *outputFormat) if (itInfo == mbusCodesToPixelFormat.end()) return -EINVAL; - const PixelFormatInfo &info = PixelFormatInfo::info(itInfo->second); - - outputFormat->fourcc = info.v4l2Format; + outputFormat->fourcc = V4L2PixelFormat::fromPixelFormat(itInfo->second); outputFormat->size = sensorFormat.size; outputFormat->planesCount = 1; diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 07b1a90aa32f..d926a7b77083 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -164,12 +164,11 @@ bool V4L2CameraProxy::validateMemoryType(uint32_t memory) void V4L2CameraProxy::setFmtFromConfig(const StreamConfiguration &streamConfig) { - const PixelFormatInfo &info = PixelFormatInfo::info(streamConfig.pixelFormat); const Size &size = streamConfig.size; v4l2PixFormat_.width = size.width; v4l2PixFormat_.height = size.height; - v4l2PixFormat_.pixelformat = info.v4l2Format; + v4l2PixFormat_.pixelformat = V4L2PixelFormat::fromPixelFormat(streamConfig.pixelFormat); v4l2PixFormat_.field = V4L2_FIELD_NONE; v4l2PixFormat_.bytesperline = streamConfig.stride; v4l2PixFormat_.sizeimage = streamConfig.frameSize; @@ -276,7 +275,7 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc * /* \todo Add map from format to description. */ utils::strlcpy(reinterpret_cast<char *>(arg->description), "Video Format Description", sizeof(arg->description)); - arg->pixelformat = PixelFormatInfo::info(format).v4l2Format; + arg->pixelformat = V4L2PixelFormat::fromPixelFormat(format); memset(arg->reserved, 0, sizeof(arg->reserved)); @@ -311,11 +310,9 @@ int V4L2CameraProxy::tryFormat(struct v4l2_format *arg) return -EINVAL; } - const PixelFormatInfo &info = PixelFormatInfo::info(config.pixelFormat); - arg->fmt.pix.width = config.size.width; arg->fmt.pix.height = config.size.height; - arg->fmt.pix.pixelformat = info.v4l2Format; + arg->fmt.pix.pixelformat = V4L2PixelFormat::fromPixelFormat(config.pixelFormat); arg->fmt.pix.field = V4L2_FIELD_NONE; arg->fmt.pix.bytesperline = config.stride; arg->fmt.pix.sizeimage = config.frameSize;