Other Parts Discussed in Thread: AM67, AM67A, ALP
Tool/software:
Hi TI,
We have TDA4VEN - DS90UB960 - IMX390 (builtin DS90UB953), and the device tree relay is set. Now, we want to test the sensor powering on and working or not using the following code:
# after boot and login, config code provided by manutacturer $ i2cset -y 7 0x3d 0x4c 0x01 $ i2cset -y 7 0x3d 0x58 0x5e $ i2cset -y 7 0x3d 0x1f 0x02 $ i2cset -y 7 0x3d 0x20 0x20 $ i2cset -y 7 0x3d 0x33 0x03
#include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <linux/videodev2.h> #include <string.h> #include <errno.h> #define DEVICE "/dev/video4" #define WIDTH 1936 #define HEIGHT 1100 int main() { int fd = open(DEVICE, O_RDWR); if (fd == -1) { perror("Error opening video device"); return 1; } // Set video format struct v4l2_format fmt; memset(&fmt, 0, sizeof(fmt)); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fmt.fmt.pix.width = WIDTH; fmt.fmt.pix.height = HEIGHT; fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SRGGB12; // 10-bit Bayer Packed fmt.fmt.pix.field = V4L2_FIELD_NONE; if (ioctl(fd, VIDIOC_S_FMT, &fmt) == -1) { perror("VIDIOC_S_FMT failed"); printf("Error: %d\n", errno); close(fd); return 1; } // Request buffers struct v4l2_requestbuffers req; memset(&req, 0, sizeof(req)); req.count = 1; // Request 1 buffer req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; req.memory = V4L2_MEMORY_MMAP; if (ioctl(fd, VIDIOC_REQBUFS, &req) == -1) { perror("VIDIOC_REQBUFS failed"); close(fd); return 1; } // Query buffer struct v4l2_buffer buf; memset(&buf, 0, sizeof(buf)); buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; buf.index = 0; if (ioctl(fd, VIDIOC_QUERYBUF, &buf) == -1) { perror("VIDIOC_QUERYBUF failed"); close(fd); return 1; } // Map buffer to user space void* buffer = mmap(NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, buf.m.offset); if (buffer == MAP_FAILED) { perror("Memory mapping failed"); close(fd); return 1; } // Queue buffer if (ioctl(fd, VIDIOC_QBUF, &buf) == -1) { perror("VIDIOC_QBUF failed"); close(fd); return 1; } // Start streaming int type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (ioctl(fd, VIDIOC_STREAMON, &type) == -1) { perror("VIDIOC_STREAMON failed"); close(fd); return 1; } // Dequeue buffer (capture frame) if (ioctl(fd, VIDIOC_DQBUF, &buf) == -1) { perror("VIDIOC_DQBUF failed"); close(fd); return 1; } // Save raw Bayer frame FILE* file = fopen("frame.raw", "wb"); if (file) { fwrite(buffer, buf.length, 1, file); fclose(file); printf("Frame captured and saved as frame.raw\n"); } else { perror("Error saving frame"); } // Stop streaming if (ioctl(fd, VIDIOC_STREAMOFF, &type) == -1) { perror("VIDIOC_STREAMOFF failed"); } // Cleanup munmap(buffer, buf.length); close(fd); return 0; }
The execution hangs at line 88, and if we interrupt with ctrl + c and check the 0x20 and 0x33 registers of 954, the value was modified back to 0xf0, 0x02, respectively. The values seem to be modified after line 81 executed.
We also tried `v4l2-ctl --device /dev/video4 --stream-mmap --stream-count=1 --stream-to=frame.raw` and hanged too.
Regards