Message ID | 20200623020930.1781469-3-niklas.soderlund@ragnatech.se |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Niklas, Thank you for the patch. On Tue, Jun 23, 2020 at 04:09:22AM +0200, Niklas Söderlund wrote: > Make the code easier to read and refactor. I actually think it's more difficult to read like this :-) > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/libcamera/pipeline/ipu3/ipu3.cpp | 38 ++++++++++++++-------------- > 1 file changed, 19 insertions(+), 19 deletions(-) > > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp > index 1a59de0c58975b3c..c525e30a5ad35011 100644 > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp > @@ -134,8 +134,6 @@ public: > int start(); > int stop(); > > - static V4L2PixelFormat mediaBusToFormat(unsigned int code); > - > V4L2VideoDevice *output_; > V4L2Subdevice *csi2_; > CameraSensor *sensor_; > @@ -1503,7 +1501,25 @@ int CIO2Device::configure(const Size &size, > if (ret) > return ret; > > - outputFormat->fourcc = mediaBusToFormat(sensorFormat.mbus_code); > + V4L2PixelFormat v4l2Format; > + switch (sensorFormat.mbus_code) { > + case MEDIA_BUS_FMT_SBGGR10_1X10: > + v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10); > + break; > + case MEDIA_BUS_FMT_SGBRG10_1X10: > + v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10); > + break; > + case MEDIA_BUS_FMT_SGRBG10_1X10: > + v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10); > + break; > + case MEDIA_BUS_FMT_SRGGB10_1X10: > + v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10); > + break; > + default: > + return -EINVAL; > + } > + > + outputFormat->fourcc = v4l2Format; > outputFormat->size = sensorFormat.size; > outputFormat->planesCount = 1; > > @@ -1577,22 +1593,6 @@ int CIO2Device::stop() > return output_->streamOff(); > } > > -V4L2PixelFormat CIO2Device::mediaBusToFormat(unsigned int code) > -{ > - switch (code) { > - case MEDIA_BUS_FMT_SBGGR10_1X10: > - return V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10); > - case MEDIA_BUS_FMT_SGBRG10_1X10: > - return V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10); > - case MEDIA_BUS_FMT_SGRBG10_1X10: > - return V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10); > - case MEDIA_BUS_FMT_SRGGB10_1X10: > - return V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10); > - default: > - return {}; > - } > -} > - > REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3); > > } /* namespace libcamera */
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 1a59de0c58975b3c..c525e30a5ad35011 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -134,8 +134,6 @@ public: int start(); int stop(); - static V4L2PixelFormat mediaBusToFormat(unsigned int code); - V4L2VideoDevice *output_; V4L2Subdevice *csi2_; CameraSensor *sensor_; @@ -1503,7 +1501,25 @@ int CIO2Device::configure(const Size &size, if (ret) return ret; - outputFormat->fourcc = mediaBusToFormat(sensorFormat.mbus_code); + V4L2PixelFormat v4l2Format; + switch (sensorFormat.mbus_code) { + case MEDIA_BUS_FMT_SBGGR10_1X10: + v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10); + break; + case MEDIA_BUS_FMT_SGBRG10_1X10: + v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10); + break; + case MEDIA_BUS_FMT_SGRBG10_1X10: + v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10); + break; + case MEDIA_BUS_FMT_SRGGB10_1X10: + v4l2Format = V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10); + break; + default: + return -EINVAL; + } + + outputFormat->fourcc = v4l2Format; outputFormat->size = sensorFormat.size; outputFormat->planesCount = 1; @@ -1577,22 +1593,6 @@ int CIO2Device::stop() return output_->streamOff(); } -V4L2PixelFormat CIO2Device::mediaBusToFormat(unsigned int code) -{ - switch (code) { - case MEDIA_BUS_FMT_SBGGR10_1X10: - return V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SBGGR10); - case MEDIA_BUS_FMT_SGBRG10_1X10: - return V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGBRG10); - case MEDIA_BUS_FMT_SGRBG10_1X10: - return V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SGRBG10); - case MEDIA_BUS_FMT_SRGGB10_1X10: - return V4L2PixelFormat(V4L2_PIX_FMT_IPU3_SRGGB10); - default: - return {}; - } -} - REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3); } /* namespace libcamera */