免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2807 | 回复: 7

[硬件及驱动] 求教:写了PCI驱动框架 为什么probe里的printk没有输出?init里printk到是输出了 [复制链接]

论坛徽章:
0
发表于 2013-01-15 13:31 |显示全部楼层
写了个PCI驱动框架 为什么probe里的printk没有输出?init里printk到是输出了
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/initval.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#define  PCI_VENDOR_ID_ALC888 0x10ec
#define  PCI_DEVICE_ID_ALC888 0x0888
static struct pci_device_id snd_alc888_ids[]={
{PCI_VENDOR_ID_ALC888,PCI_DEVICE_ID_ALC888,
  PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0,},
{0,}
};
MODULE_DEVICE_TABLE(pci,snd_alc888_ids);


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int __devinit snd_alc888_probe(struct pci_dev *pci,const struct pci_device_id *pci_id)
{
  int err=0;
  printk( "snd_alc888_probe pci->vendor=%d!\n",pci->vendor);
  return err;

}
static void __devexit snd_alc888_remove(struct pci_dev *pci)
{
  snd_card_free(pci_get_drvdata(pci));
  pci_set_drvdata(pci,NULL);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static struct pci_driver driver={
        .name        =        "alc888",
        .id_table=snd_alc888_ids,
        .probe=snd_alc888_probe,
        .remove=__devexit_p(snd_alc888_remove),
};
static int __init alas_card_alc888_init(void)
{
printk("alc888_init\n");
return pci_register_driver(&driver);
}

static void __exit alsa_card_alc888_exit(void)
{
printk("alc888_exit\n");
pci_unregister_driver(&driver);
}


MODULE_ALIAS("ALC888 8 Out 4 in");

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("ALC888 HD-audio codec");

module_init(alas_card_alc888_init);
module_exit(alsa_card_alc888_exit);

论坛徽章:
0
发表于 2013-01-15 13:42 |显示全部楼层
probe没有输出那肯定是你的驱动与设备的Device ID或VendorID没有匹配上了。
(1) 确认一下pci扫描的时候设备找到了吗?查看一下/proc/pci/busses目录下设备看看,(或者查看内核关于pci扫描设备的打印)确认设备是否发现了。
(2) 确认pci_device_id 里面设备号与扫描发现的设备号是否一致。
(3) 内核是否已经有了支持该设备的驱动了,如果有两份驱动,设备只会匹配先注册的那份驱动的。

论坛徽章:
0
发表于 2013-01-15 14:08 |显示全部楼层
本帖最后由 lgperson 于 2013-01-15 14:51 编辑

谢谢 我用的fedora15 好象没/proc/pci/busses这个目录
VENDOR_ID和DEVICE_ID是alc888的信片手册里找的
alc888.JPG
原来系统自动安装的alsa驱动,我用rmmod从里面删除了
[root@localhost pciprobe]# lsmod
Module                  Size  Used by
soundcore               5039  0
sunrpc                165119  1
p4_clockmod             3158  0
ip6t_REJECT             3387  2
nf_conntrack_ipv6       6637  2
nf_defrag_ipv6          7574  1 nf_conntrack_ipv6
ip6table_filter         1227  1
ip6_tables              9798  1 ip6table_filter
ppdev                   6488  0
parport_pc             18056  0
e1000e                151216  0
microcode              11108  0
parport                26671  2 ppdev,parport_pc
i2c_i801                7957  0
iTCO_wdt                9368  0
iTCO_vendor_support     2082  1 iTCO_wdt
ipv6                  234769  31 ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6
usb_storage            36123  0
uas                     6231  0
i915                  306671  0
drm_kms_helper         24432  1 i915
drm                   152647  2 i915,drm_kms_helper
i2c_algo_bit            4214  1 i915
i2c_core               21344  5 i2c_i801,i915,drm_kms_helper,drm,i2c_algo_bit
video                  10793  1 i915

论坛徽章:
2
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:53:17
发表于 2013-01-15 16:21 |显示全部楼层
$ ls -l /sys/bus/pci/devices/*/driver
lrwxrwxrwx 1 root root 0  1月 15 16:12 /sys/bus/pci/devices/0000:00:01.0/driver -> ../../../bus/pci/drivers/pcieport
lrwxrwxrwx 1 root root 0  1月  6 11:57 /sys/bus/pci/devices/0000:00:1a.0/driver -> ../../../bus/pci/drivers/ehci_hcd
lrwxrwxrwx 1 root root 0  1月 15 16:12 /sys/bus/pci/devices/0000:00:1b.0/driver -> ../../../bus/pci/drivers/snd_hda_intel
lrwxrwxrwx 1 root root 0  1月  6 11:57 /sys/bus/pci/devices/0000:00:1c.0/driver -> ../../../bus/pci/drivers/pcieport
lrwxrwxrwx 1 root root 0  1月  6 11:57 /sys/bus/pci/devices/0000:00:1c.2/driver -> ../../../bus/pci/drivers/pcieport
lrwxrwxrwx 1 root root 0  1月  6 11:57 /sys/bus/pci/devices/0000:00:1c.5/driver -> ../../../bus/pci/drivers/pcieport
lrwxrwxrwx 1 root root 0  1月 15 16:12 /sys/bus/pci/devices/0000:00:1d.0/driver -> ../../../bus/pci/drivers/ehci_hcd
lrwxrwxrwx 1 root root 0  1月 15 16:12 /sys/bus/pci/devices/0000:00:1f.2/driver -> ../../../bus/pci/drivers/ata_piix
lrwxrwxrwx 1 root root 0  1月  6 11:57 /sys/bus/pci/devices/0000:00:1f.3/driver -> ../../../bus/pci/drivers/i801_smbus
lrwxrwxrwx 1 root root 0  1月 15 16:12 /sys/bus/pci/devices/0000:00:1f.5/driver -> ../../../bus/pci/drivers/ata_piix
lrwxrwxrwx 1 root root 0  1月 15 16:12 /sys/bus/pci/devices/0000:01:00.0/driver -> ../../../../bus/pci/drivers/nouveau
lrwxrwxrwx 1 root root 0  1月 15 16:12 /sys/bus/pci/devices/0000:01:00.1/driver -> ../../../../bus/pci/drivers/snd_hda_intel
lrwxrwxrwx 1 root root 0  1月 15 16:12 /sys/bus/pci/devices/0000:05:00.0/driver -> ../../../../bus/pci/drivers/r8169

论坛徽章:
0
发表于 2013-01-15 16:29 |显示全部楼层
[root@localhost ALC888Driver]# ls -l /sys/bus/pci/devices/*/driver
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:00.0/driver -> ../../../bus/pci/drivers/agpgart-intel
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1a.0/driver -> ../../../bus/pci/drivers/uhci_hcd
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1a.1/driver -> ../../../bus/pci/drivers/uhci_hcd
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1a.2/driver -> ../../../bus/pci/drivers/uhci_hcd
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1a.7/driver -> ../../../bus/pci/drivers/ehci_hcd
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1c.0/driver -> ../../../bus/pci/drivers/pcieport
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1c.4/driver -> ../../../bus/pci/drivers/pcieport
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1c.5/driver -> ../../../bus/pci/drivers/pcieport
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1d.0/driver -> ../../../bus/pci/drivers/uhci_hcd
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1d.1/driver -> ../../../bus/pci/drivers/uhci_hcd
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1d.2/driver -> ../../../bus/pci/drivers/uhci_hcd
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1d.7/driver -> ../../../bus/pci/drivers/ehci_hcd
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1f.2/driver -> ../../../bus/pci/drivers/ata_piix
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1f.3/driver -> ../../../bus/pci/drivers/i801_smbus
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:00:1f.5/driver -> ../../../bus/pci/drivers/ata_piix
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:03:00.0/driver -> ../../../../bus/pci/drivers/e1000e
lrwxrwxrwx. 1 root root 0 Jan 15 16:20 /sys/bus/pci/devices/0000:04:00.0/driver -> ../../../../bus/pci/drivers/e1000e

哪个是那个alc888

论坛徽章:
0
发表于 2013-01-15 16:37 |显示全部楼层
本帖最后由 lgperson 于 2013-01-15 16:39 编辑

想跳过alsa驱动,自己写一个alc888的驱动.
从芯片资料上看它可以做8个输出4个输入,片子上有2个立体声输入.但ALSA驱动只能同时录一个line in 或 mic .

论坛徽章:
0
发表于 2013-01-15 19:18 |显示全部楼层
行了,原来那个VID,PID的问题:wink:

论坛徽章:
0
发表于 2013-10-16 08:48 |显示全部楼层
能描述一下是怎么解决的么?详细一点,谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP