Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

Camera board • VIDIOC_SUBDEV_S_FMT has no effect

$
0
0
Hello,
I try to modify the pixformat code of the subdev with V4L2 API.
I run on Raspberry Pi4 with a camera imx296 (Raspberry Cam global shutter)
The code is very simple :
- open the /dev/v4l-subdev0 device
- ioctl VIDIOC_SUBDEV_G_FMT to retrieve the code (0x300f)
- ioctl VIDIOC_SUBDEV_S_FMT to change the code (0x3007) (this value is normally accepted and it's used by rpicam-hello)
- ioctl VIDIOC_SUBDEV_G_FMT to retrieve the code (0x300f) I retrieve 0x300f instead 0x3007

Code:

#include <stdint.h>#include <stdio.h>#include <fcntl.h>#include <string.h>#include <sys/ioctl.h>#include <linux/v4l2-subdev.h>#include <linux/v4l2-mediabus.h>int main(int argc, const char *argv[]){uint32_t fmtbus[4];const char *device = "/dev/v4l-subdev0";uint32_t width = 1448;uint32_t height = 1088;struct v4l2_subdev_format ffs = {0};if (argc > 1)device = argv[1];int ret = -1;int fd = open(device, O_RDWR);if (fd < 0){printf("error on open %s %m\n", device);return -1;}fmtbus[0] = 0x3007;ffs.pad = 0;ffs.stream = 0;ffs.which = V4L2_SUBDEV_FORMAT_ACTIVE;ret = ioctl(fd, VIDIOC_SUBDEV_G_FMT, &ffs);if (ret)printf("subdev_g_fmt error %m\n");fmtbus[1] = ffs.format.code;memset(&ffs, 0, sizeof(ffs));ffs.pad = 0;ffs.stream = 0;ffs.which = V4L2_SUBDEV_FORMAT_ACTIVE;ffs.format.width = width;ffs.format.height = height;ffs.format.code = fmtbus[0];ffs.format.field = V4L2_FIELD_NONE;ret = ioctl(fd, VIDIOC_SUBDEV_S_FMT, &ffs);if (ret)printf("subdev_g_fmt error %m\n");memset(&ffs, 0, sizeof(ffs));ffs.pad = 0;ffs.stream = 0;ffs.which = V4L2_SUBDEV_FORMAT_ACTIVE;ret = ioctl(fd, VIDIOC_SUBDEV_G_FMT, &ffs);if (ret)printf("subdev_g_fmt error %m\n");fmtbus[2] = ffs.format.code;printf("code %#lx => req(%#lx) => %#lx\n", fmtbus[1], fmtbus[0], fmtbus[2]);return 0;}
and the output is

Code:

code 0x300f => req(0x3007) = > 0x300f
Then all the ioctl return fine but the VIDIOC_SUBDEV_S_FMT does nothing the code stay at 0x300f.

I would like to understand why, I can change the code ? Can you help me ?

Statistics: Posted by mchalain — Thu Nov 06, 2025 4:39 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles