📄 dvb-dibusb-core.c
字号:
{ &dib_table[11], NULL }, { &dib_table[12], NULL }, }, { "Grandtec USB1.1 DVB-T", &dibusb_device_classes[DIBUSB1_1], { &dib_table[13], &dib_table[15], NULL }, { &dib_table[14], &dib_table[16], NULL }, }, { "DiBcom USB1.1 DVB-T reference design (MOD3000)", &dibusb_device_classes[DIBUSB1_1], { &dib_table[7], NULL }, { &dib_table[8], NULL }, }, { "Artec T1 USB1.1 TVBOX with AN2135", &dibusb_device_classes[DIBUSB1_1], { &dib_table[23], NULL }, { &dib_table[24], NULL }, }, { "Artec T1 USB1.1 TVBOX with AN2235", &dibusb_device_classes[DIBUSB1_1_AN2235], { &dib_table[25], NULL }, { &dib_table[26], NULL }, }, { "Avermedia AverTV DVBT USB1.1", &dibusb_device_classes[DIBUSB1_1], { &dib_table[0], NULL }, { &dib_table[1], NULL }, }, { "Compro Videomate DVB-U2000 - DVB-T USB1.1 (please confirm to linux-dvb)", &dibusb_device_classes[DIBUSB1_1], { &dib_table[4], &dib_table[6], NULL}, { &dib_table[5], NULL }, }, { "Unkown USB1.1 DVB-T device ???? please report the name to the author", &dibusb_device_classes[DIBUSB1_1], { &dib_table[17], NULL }, { &dib_table[18], NULL }, }, { "DiBcom USB2.0 DVB-T reference design (MOD3000P)", &dibusb_device_classes[DIBUSB2_0], { &dib_table[9], NULL }, { &dib_table[10], NULL }, }, { "Artec T1 USB2.0 TVBOX (please report the warm ID)", &dibusb_device_classes[DIBUSB2_0], { &dib_table[27], NULL }, { NULL }, }, { "AVermedia/Yakumo/Hama/Typhoon DVB-T USB2.0", &dibusb_device_classes[UMT2_0], { &dib_table[2], NULL }, { NULL }, }, { "Hanftek UMT-010 DVB-T USB2.0", &dibusb_device_classes[UMT2_0], { &dib_table[28], NULL }, { &dib_table[29], NULL }, }, #ifdef CONFIG_DVB_DIBUSB_MISDESIGNED_DEVICES { "Artec T1 USB1.1 TVBOX with AN2235 (misdesigned)", &dibusb_device_classes[DIBUSB1_1_AN2235], { &dib_table[30], NULL }, { NULL }, }, { "Artec T1 USB2.0 TVBOX with FX2 IDs (misdesigned, please report the warm ID)", &dibusb_device_classes[DIBUSB2_0], { &dib_table[31], NULL }, { &dib_table[32], NULL }, /* undefined, it could be that the device will get another USB ID in warm state */ }, { "DiBcom USB1.1 DVB-T reference design (MOD3000) with AN2135 default IDs", &dibusb_device_classes[DIBUSB1_1], { &dib_table[33], NULL }, { NULL }, },#endif};static int dibusb_exit(struct usb_dibusb *dib){ deb_info("init_state before exiting everything: %x\n",dib->init_state); dibusb_remote_exit(dib); dibusb_fe_exit(dib); dibusb_i2c_exit(dib); dibusb_pid_list_exit(dib); dibusb_dvb_exit(dib); dibusb_urb_exit(dib); deb_info("init_state should be zero now: %x\n",dib->init_state); dib->init_state = DIBUSB_STATE_INIT; kfree(dib); return 0;}static int dibusb_init(struct usb_dibusb *dib){ int ret = 0; sema_init(&dib->usb_sem, 1); sema_init(&dib->i2c_sem, 1); dib->init_state = DIBUSB_STATE_INIT; if ((ret = dibusb_urb_init(dib)) || (ret = dibusb_dvb_init(dib)) || (ret = dibusb_pid_list_init(dib)) || (ret = dibusb_i2c_init(dib))) { dibusb_exit(dib); return ret; } if ((ret = dibusb_fe_init(dib))) err("could not initialize a frontend."); if ((ret = dibusb_remote_init(dib))) err("could not initialize remote control."); return 0;}static struct dibusb_usb_device * dibusb_find_device (struct usb_device *udev,int *cold){ int i,j; *cold = -1; for (i = 0; i < sizeof(dibusb_devices)/sizeof(struct dibusb_usb_device); i++) { for (j = 0; j < DIBUSB_ID_MAX_NUM && dibusb_devices[i].cold_ids[j] != NULL; j++) { deb_info("check for cold %x %x\n",dibusb_devices[i].cold_ids[j]->idVendor, dibusb_devices[i].cold_ids[j]->idProduct); if (dibusb_devices[i].cold_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) && dibusb_devices[i].cold_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) { *cold = 1; return &dibusb_devices[i]; } } for (j = 0; j < DIBUSB_ID_MAX_NUM && dibusb_devices[i].warm_ids[j] != NULL; j++) { deb_info("check for warm %x %x\n",dibusb_devices[i].warm_ids[j]->idVendor, dibusb_devices[i].warm_ids[j]->idProduct); if (dibusb_devices[i].warm_ids[j]->idVendor == le16_to_cpu(udev->descriptor.idVendor) && dibusb_devices[i].warm_ids[j]->idProduct == le16_to_cpu(udev->descriptor.idProduct)) { *cold = 0; return &dibusb_devices[i]; } } } return NULL;}/* * USB */static int dibusb_probe(struct usb_interface *intf, const struct usb_device_id *id){ struct usb_device *udev = interface_to_usbdev(intf); struct usb_dibusb *dib = NULL; struct dibusb_usb_device *dibdev = NULL; int ret = -ENOMEM,cold=0; if ((dibdev = dibusb_find_device(udev,&cold)) == NULL) { err("something went very wrong, " "unknown product ID: %.4x",le16_to_cpu(udev->descriptor.idProduct)); return -ENODEV; } if (cold == 1) { info("found a '%s' in cold state, will try to load a firmware",dibdev->name); ret = dibusb_loadfirmware(udev,dibdev); } else { info("found a '%s' in warm state.",dibdev->name); dib = kmalloc(sizeof(struct usb_dibusb),GFP_KERNEL); if (dib == NULL) { err("no memory"); return ret; } memset(dib,0,sizeof(struct usb_dibusb)); dib->udev = udev; dib->dibdev = dibdev; /* store parameters to structures */ dib->rc_query_interval = rc_query_interval; dib->pid_parse = pid_parse; usb_set_intfdata(intf, dib); ret = dibusb_init(dib); } if (ret == 0) info("%s successfully initialized and connected.",dibdev->name); else info("%s error while loading driver (%d)",dibdev->name,ret); return ret;}static void dibusb_disconnect(struct usb_interface *intf){ struct usb_dibusb *dib = usb_get_intfdata(intf); const char *name = DRIVER_DESC; usb_set_intfdata(intf,NULL); if (dib != NULL && dib->dibdev != NULL) { name = dib->dibdev->name; dibusb_exit(dib); } info("%s successfully deinitialized and disconnected.",name); }/* usb specific object needed to register this driver with the usb subsystem */struct usb_driver dibusb_driver = { .owner = THIS_MODULE, .name = DRIVER_DESC, .probe = dibusb_probe, .disconnect = dibusb_disconnect, .id_table = dib_table,};/* module stuff */static int __init usb_dibusb_init(void){ int result; if ((result = usb_register(&dibusb_driver))) { err("usb_register failed. Error number %d",result); return result; } return 0;}static void __exit usb_dibusb_exit(void){ /* deregister this driver from the USB subsystem */ usb_deregister(&dibusb_driver);}module_init (usb_dibusb_init);module_exit (usb_dibusb_exit);MODULE_AUTHOR(DRIVER_AUTHOR);MODULE_DESCRIPTION(DRIVER_DESC);MODULE_LICENSE("GPL");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -