libcamera: v4l2_subdevice: Rename V4L2SubdeviceFormat::mbus_code to code

The V4L2SubdeviceFormat::mbus_code member doesn't follow the libcamera
coding style as it should use camelCase. Fix it by renaming it to just
'code', to shorten lines in addition to fixing the coding style.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Laurent Pinchart 2024-02-26 13:27:39 +02:00
parent 4c82481fc4
commit d41e0585e9
14 changed files with 42 additions and 42 deletions

View file

@ -61,7 +61,7 @@ struct V4L2SubdeviceCapability final : v4l2_subdev_capability {
};
struct V4L2SubdeviceFormat {
uint32_t mbus_code;
uint32_t code;
Size size;
std::optional<ColorSpace> colorSpace;

View file

@ -770,7 +770,7 @@ V4L2SubdeviceFormat CameraSensor::getFormat(const std::vector<unsigned int> &mbu
}
V4L2SubdeviceFormat format{
.mbus_code = bestCode,
.code = bestCode,
.size = *bestSize,
.colorSpace = ColorSpace::Raw,
};
@ -892,12 +892,12 @@ int CameraSensor::applyConfiguration(const SensorConfiguration &config,
size.height != config.outputSize.height)
continue;
subdevFormat.mbus_code = code;
subdevFormat.code = code;
subdevFormat.size = size;
break;
}
}
if (!subdevFormat.mbus_code) {
if (!subdevFormat.code) {
LOG(CameraSensor, Error) << "Invalid output size in sensor configuration";
return -EINVAL;
}
@ -1061,7 +1061,7 @@ int CameraSensor::sensorInfo(IPACameraSensorInfo *info) const
if (ret)
return ret;
info->bitsPerPixel = MediaBusFormatInfo::info(format.mbus_code).bitsPerPixel;
info->bitsPerPixel = MediaBusFormatInfo::info(format.code).bitsPerPixel;
info->outputSize = format.size;
std::optional<int32_t> cfa = properties_.get(properties::draft::ColorFilterArrangement);

View file

@ -554,7 +554,7 @@ CameraConfiguration::Status ISICameraConfiguration::validate()
PixelFormat pixelFormat = config_[0].pixelFormat;
V4L2SubdeviceFormat sensorFormat{};
sensorFormat.mbus_code = data_->getMediaBusFormat(&pixelFormat);
sensorFormat.code = data_->getMediaBusFormat(&pixelFormat);
sensorFormat.size = maxSize;
LOG(ISI, Debug) << "Computed sensor configuration: " << sensorFormat;
@ -569,7 +569,7 @@ CameraConfiguration::Status ISICameraConfiguration::validate()
* the smallest larger format without considering the aspect ratio
* as the ISI can freely scale.
*/
auto sizes = sensor->sizes(sensorFormat.mbus_code);
auto sizes = sensor->sizes(sensorFormat.code);
Size bestSize;
for (const Size &s : sizes) {
@ -595,7 +595,7 @@ CameraConfiguration::Status ISICameraConfiguration::validate()
return Invalid;
}
sensorFormat_.mbus_code = sensorFormat.mbus_code;
sensorFormat_.code = sensorFormat.code;
sensorFormat_.size = bestSize;
LOG(ISI, Debug) << "Selected sensor format: " << sensorFormat_;
@ -632,7 +632,7 @@ StreamConfiguration PipelineHandlerISI::generateYUVConfiguration(Camera *camera,
/* Adjust the requested size to the sensor's capabilities. */
V4L2SubdeviceFormat sensorFmt;
sensorFmt.mbus_code = mbusCode;
sensorFmt.code = mbusCode;
sensorFmt.size = size;
int ret = data->sensor_->tryFormat(&sensorFmt);
@ -891,7 +891,7 @@ int PipelineHandlerISI::configure(Camera *camera, CameraConfiguration *c)
unsigned int isiCode = ISICameraConfiguration::formatsMap_.at(config.pixelFormat);
V4L2SubdeviceFormat isiFormat{};
isiFormat.mbus_code = isiCode;
isiFormat.code = isiCode;
isiFormat.size = config.size;
ret = pipe->isi->setFormat(1, &isiFormat);

View file

@ -202,7 +202,7 @@ int CIO2Device::configure(const Size &size, const Transform &transform,
if (ret)
return ret;
const auto &itInfo = mbusCodesToPixelFormat.find(sensorFormat.mbus_code);
const auto &itInfo = mbusCodesToPixelFormat.find(sensorFormat.code);
if (itInfo == mbusCodesToPixelFormat.end())
return -EINVAL;
@ -230,13 +230,13 @@ StreamConfiguration CIO2Device::generateConfiguration(Size size) const
/* Query the sensor static information for closest match. */
std::vector<unsigned int> mbusCodes = utils::map_keys(mbusCodesToPixelFormat);
V4L2SubdeviceFormat sensorFormat = getSensorFormat(mbusCodes, size);
if (!sensorFormat.mbus_code) {
if (!sensorFormat.code) {
LOG(IPU3, Error) << "Sensor does not support mbus code";
return {};
}
cfg.size = sensorFormat.size;
cfg.pixelFormat = mbusCodesToPixelFormat.at(sensorFormat.mbus_code);
cfg.pixelFormat = mbusCodesToPixelFormat.at(sensorFormat.code);
cfg.bufferCount = kBufferCount;
return cfg;
@ -326,7 +326,7 @@ V4L2SubdeviceFormat CIO2Device::getSensorFormat(const std::vector<unsigned int>
}
V4L2SubdeviceFormat format{};
format.mbus_code = bestCode;
format.code = bestCode;
format.size = bestSize;
return format;

View file

@ -504,7 +504,7 @@ int ImgUDevice::configure(const PipeConfig &pipeConfig, V4L2DeviceFormat *inputF
LOG(IPU3, Debug) << "ImgU BDS rectangle = " << bds;
V4L2SubdeviceFormat gdcFormat = {};
gdcFormat.mbus_code = MEDIA_BUS_FMT_FIXED;
gdcFormat.code = MEDIA_BUS_FMT_FIXED;
gdcFormat.size = pipeConfig.gdc;
ret = imgu_->setFormat(PAD_INPUT, &gdcFormat);
@ -543,7 +543,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad,
V4L2DeviceFormat *outputFormat)
{
V4L2SubdeviceFormat imguFormat = {};
imguFormat.mbus_code = MEDIA_BUS_FMT_FIXED;
imguFormat.code = MEDIA_BUS_FMT_FIXED;
imguFormat.size = cfg.size;
int ret = imgu_->setFormat(pad, &imguFormat);

View file

@ -761,7 +761,7 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c)
/* YUYV8_2X8 is required on the ISP source path pad for YUV output. */
if (!isRaw_)
format.mbus_code = MEDIA_BUS_FMT_YUYV8_2X8;
format.code = MEDIA_BUS_FMT_YUYV8_2X8;
LOG(RkISP1, Debug)
<< "Configuring ISP output pad with " << format

View file

@ -365,7 +365,7 @@ int RkISP1Path::configure(const StreamConfiguration &config,
* The configuration has been validated, the pixel format is guaranteed
* to be supported and thus found in formatToMediaBus.
*/
ispFormat.mbus_code = formatToMediaBus.at(config.pixelFormat);
ispFormat.code = formatToMediaBus.at(config.pixelFormat);
ret = resizer_->setFormat(1, &ispFormat);
if (ret < 0)

View file

@ -37,10 +37,10 @@ namespace {
constexpr unsigned int defaultRawBitDepth = 12;
PixelFormat mbusCodeToPixelFormat(unsigned int mbus_code,
PixelFormat mbusCodeToPixelFormat(unsigned int code,
BayerFormat::Packing packingReq)
{
BayerFormat bayer = BayerFormat::fromMbusCode(mbus_code);
BayerFormat bayer = BayerFormat::fromMbusCode(code);
ASSERT(bayer.isValid());
@ -221,7 +221,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
* without modifications.
*/
if (sensorConfig) {
BayerFormat bayer = BayerFormat::fromMbusCode(sensorFormat_.mbus_code);
BayerFormat bayer = BayerFormat::fromMbusCode(sensorFormat_.code);
if (bayer.bitDepth != sensorConfig->bitDepth ||
sensorFormat_.size != sensorConfig->outputSize) {
@ -236,7 +236,7 @@ CameraConfiguration::Status RPiCameraConfiguration::validate()
StreamConfiguration *rawStream = raw.cfg;
/* Adjust the RAW stream to match the computed sensor format. */
BayerFormat sensorBayer = BayerFormat::fromMbusCode(sensorFormat_.mbus_code);
BayerFormat sensorBayer = BayerFormat::fromMbusCode(sensorFormat_.code);
/*
* Some sensors change their Bayer order when they are h-flipped
@ -377,8 +377,8 @@ V4L2DeviceFormat PipelineHandlerBase::toV4L2DeviceFormat(const V4L2VideoDevice *
const V4L2SubdeviceFormat &format,
BayerFormat::Packing packingReq)
{
unsigned int mbus_code = format.mbus_code;
const PixelFormat pix = mbusCodeToPixelFormat(mbus_code, packingReq);
unsigned int code = format.code;
const PixelFormat pix = mbusCodeToPixelFormat(code, packingReq);
V4L2DeviceFormat deviceFormat;
deviceFormat.fourcc = dev->toV4L2PixelFormat(pix);
@ -409,7 +409,7 @@ PipelineHandlerBase::generateConfiguration(Camera *camera, Span<const StreamRole
case StreamRole::Raw:
size = sensorSize;
sensorFormat = data->findBestFormat(size, defaultRawBitDepth);
pixelFormat = mbusCodeToPixelFormat(sensorFormat.mbus_code,
pixelFormat = mbusCodeToPixelFormat(sensorFormat.code,
BayerFormat::Packing::CSI2);
ASSERT(pixelFormat.isValid());
colorSpace = ColorSpace::Raw;
@ -990,7 +990,7 @@ V4L2SubdeviceFormat CameraData::findBestFormat(const Size &req, unsigned int bit
if (score <= bestScore) {
bestScore = score;
bestFormat.mbus_code = mbusCode;
bestFormat.code = mbusCode;
bestFormat.size = size;
}

View file

@ -426,7 +426,7 @@ CameraConfiguration::Status Vc4CameraData::platformValidate(RPi::RPiCameraConfig
BayerFormat rawBayer = BayerFormat::fromPixelFormat(rawStream->pixelFormat);
/* Apply the sensor bitdepth. */
rawBayer.bitDepth = BayerFormat::fromMbusCode(rpiConfig->sensorFormat_.mbus_code).bitDepth;
rawBayer.bitDepth = BayerFormat::fromMbusCode(rpiConfig->sensorFormat_.code).bitDepth;
/* Default to CSI2 packing if the user request is unsupported. */
if (rawBayer.packing != BayerFormat::Packing::CSI2 &&

View file

@ -563,13 +563,13 @@ void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)
* corresponding possible V4L2 pixel formats on the video node.
*/
V4L2SubdeviceFormat format{};
format.mbus_code = code;
format.code = code;
format.size = size;
int ret = setupFormats(&format, V4L2Subdevice::TryFormat);
if (ret < 0) {
/* Pipeline configuration failed, skip this configuration. */
format.mbus_code = code;
format.code = code;
format.size = size;
LOG(SimplePipeline, Debug)
<< "Sensor format " << format
@ -577,7 +577,7 @@ void SimpleCameraData::tryPipeline(unsigned int code, const Size &size)
return;
}
V4L2VideoDevice::Formats videoFormats = video_->formats(format.mbus_code);
V4L2VideoDevice::Formats videoFormats = video_->formats(format.code);
LOG(SimplePipeline, Debug)
<< "Adding configuration for " << format.size
@ -707,7 +707,7 @@ int SimpleCameraData::setupFormats(V4L2SubdeviceFormat *format,
if (ret < 0)
return ret;
if (format->mbus_code != sourceFormat.mbus_code ||
if (format->code != sourceFormat.code ||
format->size != sourceFormat.size) {
LOG(SimplePipeline, Debug)
<< "Source '" << source->entity()->name()
@ -1121,7 +1121,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)
const SimpleCameraData::Configuration *pipeConfig = config->pipeConfig();
V4L2SubdeviceFormat format{};
format.mbus_code = pipeConfig->code;
format.code = pipeConfig->code;
format.size = pipeConfig->sensorSize;
ret = data->setupFormats(&format, V4L2Subdevice::ActiveFormat,

View file

@ -244,7 +244,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)
/* The scaler hardcodes a x3 scale-up ratio. */
V4L2SubdeviceFormat subformat = {};
subformat.mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8;
subformat.code = MEDIA_BUS_FMT_SGRBG8_1X8;
subformat.size = { cfg.size.width / 3, cfg.size.height / 3 };
ret = data->sensor_->setFormat(&subformat);
@ -255,7 +255,7 @@ int PipelineHandlerVimc::configure(Camera *camera, CameraConfiguration *config)
if (ret)
return ret;
subformat.mbus_code = pixelformats.find(cfg.pixelFormat)->second;
subformat.code = pixelformats.find(cfg.pixelFormat)->second;
ret = data->debayer_->setFormat(1, &subformat);
if (ret)
return ret;

View file

@ -757,7 +757,7 @@ const MediaBusFormatInfo &MediaBusFormatInfo::info(uint32_t code)
*/
/**
* \var V4L2SubdeviceFormat::mbus_code
* \var V4L2SubdeviceFormat::code
* \brief The image format bus code
*/
@ -804,10 +804,10 @@ std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f)
{
out << f.size << "-";
const auto it = mediaBusFormatInfo.find(f.mbus_code);
const auto it = mediaBusFormatInfo.find(f.code);
if (it == mediaBusFormatInfo.end())
out << utils::hex(f.mbus_code, 4);
out << utils::hex(f.code, 4);
else
out << it->second.name;
@ -1097,7 +1097,7 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,
format->size.width = subdevFmt.format.width;
format->size.height = subdevFmt.format.height;
format->mbus_code = subdevFmt.format.code;
format->code = subdevFmt.format.code;
format->colorSpace = toColorSpace(subdevFmt.format);
return 0;
@ -1123,7 +1123,7 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,
subdevFmt.pad = pad;
subdevFmt.format.width = format->size.width;
subdevFmt.format.height = format->size.height;
subdevFmt.format.code = format->mbus_code;
subdevFmt.format.code = format->code;
subdevFmt.format.field = V4L2_FIELD_NONE;
if (format->colorSpace) {
fromColorSpace(format->colorSpace, subdevFmt.format);
@ -1143,7 +1143,7 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,
format->size.width = subdevFmt.format.width;
format->size.height = subdevFmt.format.height;
format->mbus_code = subdevFmt.format.code;
format->code = subdevFmt.format.code;
format->colorSpace = toColorSpace(subdevFmt.format);
return 0;

View file

@ -100,7 +100,7 @@ protected:
MEDIA_BUS_FMT_SBGGR10_1X10,
MEDIA_BUS_FMT_BGR888_1X24 },
Size(1024, 768));
if (format.mbus_code != MEDIA_BUS_FMT_SBGGR10_1X10 ||
if (format.code != MEDIA_BUS_FMT_SBGGR10_1X10 ||
format.size != Size(4096, 2160)) {
cerr << "Failed to get a suitable format, expected 4096x2160-0x"
<< utils::hex(MEDIA_BUS_FMT_SBGGR10_1X10)

View file

@ -75,7 +75,7 @@ int V4L2VideoDeviceTest::init()
format.fourcc = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8);
V4L2SubdeviceFormat subformat = {};
subformat.mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8;
subformat.code = MEDIA_BUS_FMT_SBGGR8_1X8;
subformat.size = format.size;
if (sensor_->setFormat(&subformat))