I am learning to understand the how v4l2_based drivers work, and subsequently system calls as well. As a part of that working on decoder driver.
So I need to take the buffer data out after the qbuf system-call after it is getting transferred to the vb2_bufffer from v4l2_buffer. I am required to dump data after qbuf as there is no decoder involved by calculating the size I can verify my system call is working.
I have developed a driver which have all the required system call, but because there is no secific hardware decoder is there can’t check woth playback.
Please do suggest other ideas to debug as well.
just for referance :
https://elixir.bootlin.com/linux/v6.10/source/drivers/media/common/videobuf2/videobuf2-core.c#L1799
I tried dumping the data in qbuf using the following method but it is not working it seems.
in qbuf system call taken out vb(vb2_buffer)
from vq(vb2_queue)
using one function
buffer = vb2_plane_vaddr ().
and calculated size using
size = vb2_plane_size()
using the above passed size and buffer, passed it to a file_saver_function()
void save_buffer_to_file(const char *filename, void *buffer, size_t size) {
struct file *file;
mm_segment_t old_fs;
loff_t pos = 0;
printk(KERN_INFO " >> Saving buffer of size %d n", size);
if (!buffer || size == 0) {
printk(KERN_ERR "save_buffer_to_file: Invalid buffer or sizen");
return;
}
old_fs = get_fs();
set_fs(KERNEL_DS);
file = filp_open(filename, O_WRONLY | O_CREAT | O_APPEND, 0644);
if (IS_ERR(file)) {
printk(KERN_ERR "save_buffer_to_file: Failed to open file %sn", filename);
set_fs(old_fs);
return;
}
kernel_write(file, buffer, size, &pos);
filp_close(file, NULL);
set_fs(old_fs);
}
But not getting the expected results.
I am very new to kernel/driver world, I am trying my best to learn and understand things as fast as I can. If I am missing any details which is making my question confusing please do tell.