Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete image capture error #158

Open
Yuxin-Yu opened this issue Oct 14, 2024 · 0 comments
Open

Incomplete image capture error #158

Yuxin-Yu opened this issue Oct 14, 2024 · 0 comments

Comments

@Yuxin-Yu
Copy link

Yuxin-Yu commented Oct 14, 2024

In order to achieve the video capture function, I used the OV5640 camera, axi4 stream in, and vdma core, and used the AXIDMA_DMAvDEOREADED case in this project. The specific video capture code can be found in the axidma_capture video attachment. In addition, to achieve the video capture function, I made the following modifications to the code in AXIDMA_DMAdDEOREADED:

case AXIDMA_DMA_VIDEO_READ:
            // 从用户空间复制视频传输结构到内核空间
            if (copy_from_user(&video_trans, arg_ptr,
                               sizeof(video_trans)) != 0) {
                axidma_err("Unable to copy transfer info from userspace for "
                           "AXIDMA_DMA_VIDEO_READ.\n");
                return -EFAULT;
            }

            // 计算帧缓冲区数组的大小
            size = video_trans.num_frame_buffers *
                   sizeof(video_trans.frame_buffers[0]);
            // 在内核空间分配帧缓冲区数组
            video_trans.frame_buffers = kmalloc(size, GFP_KERNEL);
            if (video_trans.frame_buffers == NULL) {
                axidma_err("Unable to allocate array for the frame buffers.\n");
                return -ENOMEM;
            }

            //获取用户空间的视频传输结构指针
            user_video_trans = (struct axidma_video_transaction *__user)arg_ptr;
            //// 从用户空间复制完整的视频传输结构到内核空间的临时变量
            if (copy_from_user(&video_trans_copy, user_video_trans, sizeof(struct axidma_video_transaction)) != 0) {
                axidma_err("Unable to copy video transaction structure from userspace.\n");
                return -EFAULT;
            }
            
            // 验证用户空间帧缓冲区指针的有效性
            if (!access_ok(video_trans_copy.frame_buffers, size)) {
                axidma_err("Invalid frame buffer pointer in AXIDMA_DMA_VIDEO_READ.\n");
                return -EFAULT;
            }

            //从用户空间复制帧缓冲区数组到内核空间
            if (copy_from_user(video_trans.frame_buffers,
                        video_trans_copy.frame_buffers, size) != 0) {
                axidma_err("Unable to copy the frame buffer array from "
                        "userspace for AXIDMA_DMA_VIDEO_READ.\n");
                kfree(video_trans.frame_buffers);
                return -EFAULT;
            }

            rc = axidma_video_transfer(dev, &video_trans, AXIDMA_READ);
            // 释放内核空间分配的帧缓冲区数组
            kfree(video_trans.frame_buffers);
            break;

After executing the code capture, it was found that some of the captured images had vertical patterns, as shown below. After capturing the waveform, it was found that the OV5640 camera was initialized normally, and the image data was input to VDMA normally after passing through the axi4 stream in core. However, VDMA did not output complete data, resulting in only partial data being captured. Has anyone encountered the same problem before? How can we solve it? @bperez77
frame_0006

axidma_capture_video.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant