gpt4 book ai didi

c - 编译驱动程序时出错 - 初始化程序中指定的未知字段

转载 作者:行者123 更新时间:2023-12-02 14:33:16 25 4
gpt4 key购买 nike

我尝试在 Ubuntu 10.04 LTS 上编译视频驱动程序,出现错误:

**************************************************************************
* Building Techwell TW686x driver... *
* Type "make help" for a list of available targets. *
**************************************************************************

make -C /lib/modules/`uname -r`/build M="/home/v4/driver-686x-0.1.1" clean
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-43-generic'
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-43-generic'
make -C /lib/modules/`uname -r`/build M="/home/v4/driver-686x-0.1.1" modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.32-43-generic'
CC [M] /home/v4/driver-686x-0.1.1/tw686x-core.o
CC [M] /home/v4/driver-686x-0.1.1/tw686x-video.o
CC [M] /home/v4/driver-686x-0.1.1/tw686x-i2c.o
CC [M] /home/v4/driver-686x-0.1.1/tw686x-device.o
CC [M] /home/v4/driver-686x-0.1.1/i2c-sw.o
CC [M] /home/v4/driver-686x-0.1.1/tw686x-alsa.o
CC [M] /home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.o
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:341: warning: initialization from incompatible pointer type
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:343: warning: initialization from incompatible pointer type
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:344: error: unknown field ‘vaddr’ specified in initializer
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:344: warning: excess elements in struct initializer
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:344: warning: (near initialization for ‘qops’)
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c: In function ‘videobuf_queue_dma_contig_init_tw’:
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:357: warning: passing argument 2 of ‘videobuf_queue_core_init’ discards qualifiers from pointer target type
include/media/videobuf-core.h:197: note: expected ‘struct videobuf_queue_ops *’ but argument is of type ‘const struct videobuf_queue_ops *’
make[2]: *** [/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.o] Error 1
make[1]: *** [_module_/home/v4/driver-686x-0.1.1] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.32-43-generic'
make: *** [modules] Error 2

我的内核是2.6.32-43。我的C很生锈,所以请教各位高手。据我所知,问题涉及文件 videobuf-core.h 中的变量 videobuf_queue_ops,我在以下位置找到了该变量:

/usr/src/linux-headers-2.6.24-24/include/media/videobuf-core.h
/usr/src/linux-headers-2.6.32-43/include/media/videobuf-core.h
/usr/src/linux-headers-2.6.24-32/include/media/videobuf-core.h

这是有问题的文件(摘录)videobuf-dma-contig-tw.c:

static struct videobuf_qtype_ops qops = {
.magic = MAGIC_QTYPE_OPS,

.alloc = __videobuf_alloc,
.iolock = __videobuf_iolock,
.mmap_mapper = __videobuf_mmap_mapper,
.vaddr = __videobuf_to_vaddr,
};

头文件中videobuf_qtype_ops的定义如下:

struct videobuf_queue_ops {
int (*buf_setup)(struct videobuf_queue *q,
unsigned int *count, unsigned int *size);
int (*buf_prepare)(struct videobuf_queue *q,
struct videobuf_buffer *vb,
enum v4l2_field field);
void (*buf_queue)(struct videobuf_queue *q,
struct videobuf_buffer *vb);
void (*buf_release)(struct videobuf_queue *q,
struct videobuf_buffer *vb);
};

#define MAGIC_QTYPE_OPS 0x12261003

/* Helper operations - device type dependent */
struct videobuf_qtype_ops {
u32 magic;

void *(*alloc) (size_t size);
void *(*vmalloc) (struct videobuf_buffer *buf);
int (*iolock) (struct videobuf_queue* q,
struct videobuf_buffer *vb,
struct v4l2_framebuffer *fbuf);
int (*mmap) (struct videobuf_queue *q,
unsigned int *count,
unsigned int *size,
enum v4l2_memory memory);
int (*sync) (struct videobuf_queue* q,
struct videobuf_buffer *buf);
int (*video_copy_to_user)(struct videobuf_queue *q,
char __user *data,
size_t count,
int nonblocking);
int (*copy_stream) (struct videobuf_queue *q,
char __user *data,
size_t count,
size_t pos,
int vbihack,
int nonblocking);
int (*mmap_free) (struct videobuf_queue *q);
int (*mmap_mapper) (struct videobuf_queue *q,
struct vm_area_struct *vma);
};

我应该更改这个头文件吗?我不确定修复是什么,或者我是否应该更改 Linux 文件 - 可怕的东西!

感谢您的帮助。

最佳答案

仅此部分

/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:343: warning: initialization from incompatible pointer type
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:344: error: unknown field ‘vaddr’ specified in initializer
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:344: warning: excess elements in struct initializer

告诉我们初始化器和结构使用不同的类型、不同的字段名称和不同的元素数量。

绝对不是正确的包含文件。 :-)

您必须弄清楚应该使用哪个版本,并确保其中一个版本位于包含路径中(而不是其他版本)。

关于c - 编译驱动程序时出错 - 初始化程序中指定的未知字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12640024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com