使用V4L2驱动框架操作OV5640 使用VIDIOC_S_FMT设置视频格式时出现
[ 3810.562670] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[ 3810.570806] pgd = d77d8000
[ 3810.573330] [00000000] *pgd=558c8831, *pte=00000000, *ppte=00000000
[ 3810.579581] Internal error: Oops: 17 [#1] PREEMPT SMP
[ 3810.584606] Modules linked in:
[ 3810.587648] CPU: 0 Not tainted (3.0.15 #16)
[ 3810.592173] PC is at fimc_s_fmt_vid_capture+0xe8/0x358
[ 3810.597283] LR is at fimc_s_fmt_vid_capture+0x94/0x358
[ 3810.602404] pc : [] lr : [] psr: 40000053
[ 3810.602412] sp : d5935c30 ip : c078f8ac fp : d5935c5c
[ 3810.613859] r10: d70db780 r9 : d582f320 r8 : d7084200
[ 3810.619067] r7 : d7304064 r6 : d589c03c r5 : d589c000 r4 : d7304000
[ 3810.625577] r3 : 00000000 r2 : 4745504a r1 : 4745504a r0 : ffffffff
[ 3810.632089] Flags: nZcv IRQs on FIQs off Mode SVC_32 ISA ARM Segment user
[ 3810.639292] Control: 10c5387d Table: 577d804a DAC: 00000015
[ 3810.645019]
解决方法
解决方法 在调用ioctl(fd, VIDIOC_S_FMT, &fmt) 之前设置视频输入
struct v4l2_input input;
memset(&input, 0, sizeof(struct v4l2_input));
input.index = 0;
ret = ioctl(fd, VIDIOC_S_INPUT, &input);
if(ret == -1){
printf("VIDIOC_S_INPUT is error! LINE:%d\n",__LINE__);