1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>PCI Entries</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Writing an ALSA Driver"><link rel="up" href="pci-resource.html" title="Chapter 4. PCI Resource Management"><link rel="prev" href="pci-resource-resource-allocation.html" title="Resource Allocation"><link rel="next" href="pcm-interface.html" title="Chapter 5. PCM Interface"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">PCI Entries</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="pci-resource-resource-allocation.html">Prev</a> </td><th width="60%" align="center">Chapter 4. PCI Resource Management</th><td width="20%" align="right"> <a accesskey="n" href="pcm-interface.html">Next</a></td></tr></table><hr></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="pci-resource-entries"></a>PCI Entries</h2></div></div></div><p> 2 So far, so good. Let's finish the missing PCI 3 stuff. At first, we need a 4 <span class="structname">pci_device_id</span> table for this 5 chipset. It's a table of PCI vendor/device ID number, and some 6 masks. 7 </p><p> 8 For example, 9 10 </p><div class="informalexample"><pre class="programlisting"> 11 12 static struct pci_device_id snd_mychip_ids[] = { 13 { PCI_VENDOR_ID_FOO, PCI_DEVICE_ID_BAR, 14 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, 15 .... 16 { 0, } 17 }; 18 MODULE_DEVICE_TABLE(pci, snd_mychip_ids); 19 20 </pre></div><p> 21 </p><p> 22 The first and second fields of 23 the <span class="structname">pci_device_id</span> structure are the vendor and 24 device IDs. If you have no reason to filter the matching 25 devices, you can leave the remaining fields as above. The last 26 field of the <span class="structname">pci_device_id</span> struct contains 27 private data for this entry. You can specify any value here, for 28 example, to define specific operations for supported device IDs. 29 Such an example is found in the intel8x0 driver. 30 </p><p> 31 The last entry of this list is the terminator. You must 32 specify this all-zero entry. 33 </p><p> 34 Then, prepare the <span class="structname">pci_driver</span> record: 35 36 </p><div class="informalexample"><pre class="programlisting"> 37 38 static struct pci_driver driver = { 39 .name = KBUILD_MODNAME, 40 .id_table = snd_mychip_ids, 41 .probe = snd_mychip_probe, 42 .remove = snd_mychip_remove, 43 }; 44 45 </pre></div><p> 46 </p><p> 47 The <em class="structfield"><code>probe</code></em> and 48 <em class="structfield"><code>remove</code></em> functions have already 49 been defined in the previous sections. 50 The <em class="structfield"><code>name</code></em> 51 field is the name string of this device. Note that you must not 52 use a slash <span class="quote">“<span class="quote">/</span>”</span> in this string. 53 </p><p> 54 And at last, the module entries: 55 56 </p><div class="informalexample"><pre class="programlisting"> 57 58 static int __init alsa_card_mychip_init(void) 59 { 60 return pci_register_driver(&driver); 61 } 62 63 static void __exit alsa_card_mychip_exit(void) 64 { 65 pci_unregister_driver(&driver); 66 } 67 68 module_init(alsa_card_mychip_init) 69 module_exit(alsa_card_mychip_exit) 70 71 </pre></div><p> 72 </p><p> 73 Note that these module entries are tagged with 74 <em class="parameter"><code>__init</code></em> and 75 <em class="parameter"><code>__exit</code></em> prefixes. 76 </p><p> 77 Oh, one thing was forgotten. If you have no exported symbols, 78 you need to declare it in 2.2 or 2.4 kernels (it's not necessary in 2.6 kernels). 79 80 </p><div class="informalexample"><pre class="programlisting"> 81 82 EXPORT_NO_SYMBOLS; 83 84 </pre></div><p> 85 86 That's all! 87 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pci-resource-resource-allocation.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pci-resource.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pcm-interface.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Resource Allocation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 5. PCM Interface</td></tr></table></div></body></html> 88