libcamera: v4l2_device: Rename parameters to s/g_fmt
Rename parameters to get and set format functions to expand 'fmt' to 'format'. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
parent
2f516306a7
commit
755644fe64
2 changed files with 54 additions and 54 deletions
|
@ -86,15 +86,15 @@ public:
|
||||||
const char *deviceName() const { return caps_.card(); }
|
const char *deviceName() const { return caps_.card(); }
|
||||||
const char *busName() const { return caps_.bus_info(); }
|
const char *busName() const { return caps_.bus_info(); }
|
||||||
|
|
||||||
int getFormat(V4L2DeviceFormat *fmt);
|
int getFormat(V4L2DeviceFormat *format);
|
||||||
int setFormat(V4L2DeviceFormat *fmt);
|
int setFormat(V4L2DeviceFormat *format);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int getFormatSingleplane(V4L2DeviceFormat *fmt);
|
int getFormatSingleplane(V4L2DeviceFormat *format);
|
||||||
int setFormatSingleplane(V4L2DeviceFormat *fmt);
|
int setFormatSingleplane(V4L2DeviceFormat *format);
|
||||||
|
|
||||||
int getFormatMultiplane(V4L2DeviceFormat *fmt);
|
int getFormatMultiplane(V4L2DeviceFormat *format);
|
||||||
int setFormatMultiplane(V4L2DeviceFormat *fmt);
|
int setFormatMultiplane(V4L2DeviceFormat *format);
|
||||||
|
|
||||||
std::string deviceNode_;
|
std::string deviceNode_;
|
||||||
int fd_;
|
int fd_;
|
||||||
|
|
|
@ -282,58 +282,58 @@ void V4L2Device::close()
|
||||||
* \brief Retrieve the image format set on the V4L2 device
|
* \brief Retrieve the image format set on the V4L2 device
|
||||||
* \return 0 for success, a negative error code otherwise
|
* \return 0 for success, a negative error code otherwise
|
||||||
*/
|
*/
|
||||||
int V4L2Device::getFormat(V4L2DeviceFormat *fmt)
|
int V4L2Device::getFormat(V4L2DeviceFormat *format)
|
||||||
{
|
{
|
||||||
return caps_.isMultiplanar() ? getFormatMultiplane(fmt) :
|
return caps_.isMultiplanar() ? getFormatMultiplane(format) :
|
||||||
getFormatSingleplane(fmt);
|
getFormatSingleplane(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Configure an image format on the V4L2 device
|
* \brief Configure an image format on the V4L2 device
|
||||||
* \return 0 for success, a negative error code otherwise
|
* \return 0 for success, a negative error code otherwise
|
||||||
*/
|
*/
|
||||||
int V4L2Device::setFormat(V4L2DeviceFormat *fmt)
|
int V4L2Device::setFormat(V4L2DeviceFormat *format)
|
||||||
{
|
{
|
||||||
return caps_.isMultiplanar() ? setFormatMultiplane(fmt) :
|
return caps_.isMultiplanar() ? setFormatMultiplane(format) :
|
||||||
setFormatSingleplane(fmt);
|
setFormatSingleplane(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *fmt)
|
int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)
|
||||||
{
|
{
|
||||||
struct v4l2_format v4l2Fmt;
|
struct v4l2_format v4l2Format;
|
||||||
struct v4l2_pix_format *pix = &v4l2Fmt.fmt.pix;
|
struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
v4l2Fmt.type = bufferType_;
|
v4l2Format.type = bufferType_;
|
||||||
ret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Fmt);
|
ret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Format);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
LOG(Error) << "Unable to get format: " << strerror(-ret);
|
LOG(Error) << "Unable to get format: " << strerror(-ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt->width = pix->width;
|
format->width = pix->width;
|
||||||
fmt->height = pix->height;
|
format->height = pix->height;
|
||||||
fmt->fourcc = pix->pixelformat;
|
format->fourcc = pix->pixelformat;
|
||||||
fmt->planes = 1;
|
format->planes = 1;
|
||||||
fmt->planesFmt[0].bpl = pix->bytesperline;
|
format->planesFmt[0].bpl = pix->bytesperline;
|
||||||
fmt->planesFmt[0].size = pix->sizeimage;
|
format->planesFmt[0].size = pix->sizeimage;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *fmt)
|
int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)
|
||||||
{
|
{
|
||||||
struct v4l2_format v4l2Fmt;
|
struct v4l2_format v4l2Format;
|
||||||
struct v4l2_pix_format *pix = &v4l2Fmt.fmt.pix;
|
struct v4l2_pix_format *pix = &v4l2Format.fmt.pix;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
v4l2Fmt.type = bufferType_;
|
v4l2Format.type = bufferType_;
|
||||||
pix->width = fmt->width;
|
pix->width = format->width;
|
||||||
pix->height = fmt->height;
|
pix->height = format->height;
|
||||||
pix->pixelformat = fmt->fourcc;
|
pix->pixelformat = format->fourcc;
|
||||||
|
|
||||||
ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Fmt);
|
ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
LOG(Error) << "Unable to set format: " << strerror(-ret);
|
LOG(Error) << "Unable to set format: " << strerror(-ret);
|
||||||
|
@ -343,51 +343,51 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *fmt)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *fmt)
|
int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)
|
||||||
{
|
{
|
||||||
struct v4l2_format v4l2Fmt;
|
struct v4l2_format v4l2Format;
|
||||||
struct v4l2_pix_format_mplane *pix = &v4l2Fmt.fmt.pix_mp;
|
struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
v4l2Fmt.type = bufferType_;
|
v4l2Format.type = bufferType_;
|
||||||
ret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Fmt);
|
ret = ioctl(fd_, VIDIOC_G_FMT, &v4l2Format);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
LOG(Error) << "Unable to get format: " << strerror(-ret);
|
LOG(Error) << "Unable to get format: " << strerror(-ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt->width = pix->width;
|
format->width = pix->width;
|
||||||
fmt->height = pix->height;
|
format->height = pix->height;
|
||||||
fmt->fourcc = pix->pixelformat;
|
format->fourcc = pix->pixelformat;
|
||||||
fmt->planes = pix->num_planes;
|
format->planes = pix->num_planes;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < fmt->planes; ++i) {
|
for (unsigned int i = 0; i < format->planes; ++i) {
|
||||||
fmt->planesFmt[i].bpl = pix->plane_fmt[i].bytesperline;
|
format->planesFmt[i].bpl = pix->plane_fmt[i].bytesperline;
|
||||||
fmt->planesFmt[i].size = pix->plane_fmt[i].sizeimage;
|
format->planesFmt[i].size = pix->plane_fmt[i].sizeimage;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *fmt)
|
int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)
|
||||||
{
|
{
|
||||||
struct v4l2_format v4l2Fmt;
|
struct v4l2_format v4l2Format;
|
||||||
struct v4l2_pix_format_mplane *pix = &v4l2Fmt.fmt.pix_mp;
|
struct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
v4l2Fmt.type = bufferType_;
|
v4l2Format.type = bufferType_;
|
||||||
pix->width = fmt->width;
|
pix->width = format->width;
|
||||||
pix->height = fmt->height;
|
pix->height = format->height;
|
||||||
pix->pixelformat = fmt->fourcc;
|
pix->pixelformat = format->fourcc;
|
||||||
pix->num_planes = fmt->planes;
|
pix->num_planes = format->planes;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < pix->num_planes; ++i) {
|
for (unsigned int i = 0; i < pix->num_planes; ++i) {
|
||||||
pix->plane_fmt[i].bytesperline = fmt->planesFmt[i].bpl;
|
pix->plane_fmt[i].bytesperline = format->planesFmt[i].bpl;
|
||||||
pix->plane_fmt[i].sizeimage = fmt->planesFmt[i].size;
|
pix->plane_fmt[i].sizeimage = format->planesFmt[i].size;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Fmt);
|
ret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
LOG(Error) << "Unable to set format: " << strerror(-ret);
|
LOG(Error) << "Unable to set format: " << strerror(-ret);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue