3

我正在尝试在 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 文件 - 可怕的东西!

谢谢你的帮助。

4

2 回答 2

1

仅此部分

/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:343:警告:从不兼容的指针类型初始化
/home/v4/driver-686x-0.1.1/videobuf-dma-contig -tw.c:344:错误:在初始化程序
/home/v4/driver-686x-0.1.1/videobuf-dma-contig-tw.c:344 中指定的未知字段“vaddr”:警告:结构初始化程序中的多余元素

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

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

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

于 2012-09-28T12:36:26.973 回答
1

由于某种原因,编译器不喜欢这部分:

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-dma-contig-tw.c:344:错误:初始化程序中指定的未知字段“vaddr”

现在的问题是为什么vaddr. struct videobuf_qtype_ops它可能低于#if,但我不确定。struct videobuf_qtype_ops未在此文件中定义。

你应该自己看看这个。发布大量不相关的代码并不能很好地利用人们的时间。

于 2012-09-28T12:38:30.560 回答