1 /* $NetBSD: emuxki_boards.c,v 1.1 2022/09/07 03:34:43 khorben Exp $ */ 2 3 /*- 4 * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Yannick Montulet, and by Andrew Doran. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include <sys/cdefs.h> 33 __KERNEL_RCSID(0, "$NetBSD: emuxki_boards.c,v 1.1 2022/09/07 03:34:43 khorben Exp $"); 34 35 #include <dev/pci/emuxkivar.h> 36 #include <dev/pci/emuxki_boards.h> 37 38 /* generic fallbacks must be after any corresponding precise match */ 39 static const struct emuxki_board emuxki_boards[] = { 40 { 41 .sb_board = "SB1550", 42 .sb_name = "Sound Blaster Audigy Rx", 43 .sb_vendor = PCI_VENDOR_CREATIVELABS, 44 .sb_product = PCI_PRODUCT_CREATIVELABS_SBAUDIGY4, 45 .sb_subsystem = 0x10241102, 46 .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2 | EMUXKI_AUDIGY2_CA0108, 47 }, 48 { 49 .sb_board = "SB0610", 50 .sb_name = "Sound Blaster Audigy 4", 51 .sb_vendor = PCI_VENDOR_CREATIVELABS, 52 .sb_product = PCI_PRODUCT_CREATIVELABS_SBAUDIGY4, 53 .sb_subsystem = 0x10211102, 54 .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2 | EMUXKI_AUDIGY2_CA0108, 55 }, 56 { 57 .sb_board = "SB0400", 58 .sb_name = "Sound Blaster Audigy 2 Value", 59 .sb_vendor = PCI_VENDOR_CREATIVELABS, 60 .sb_product = PCI_PRODUCT_CREATIVELABS_SBAUDIGY4, 61 .sb_subsystem = 0x10011102, 62 .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2 | EMUXKI_AUDIGY2_CA0108, 63 }, 64 { 65 .sb_board = "generic", 66 .sb_name = "Sound Blaster Audigy 2 Value", 67 .sb_vendor = PCI_VENDOR_CREATIVELABS, 68 .sb_product = PCI_PRODUCT_CREATIVELABS_SBAUDIGY4, 69 .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2 | EMUXKI_AUDIGY2_CA0108, 70 }, 71 { 72 .sb_board = "SB0350", 73 .sb_name = "Sound Blaster Audigy 2 ZS", 74 .sb_vendor = PCI_VENDOR_CREATIVELABS, 75 .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY, 76 .sb_subsystem = 0x20021102, 77 .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2, 78 }, 79 { 80 .sb_board = "SB0350", 81 .sb_name = "Sound Blaster Audigy 2", 82 .sb_vendor = PCI_VENDOR_CREATIVELABS, 83 .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY, 84 .sb_subsystem = 0x20051102, 85 .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2, 86 }, 87 { 88 .sb_board = "SB0240", 89 .sb_name = "Sound Blaster Audigy 2", 90 .sb_vendor = PCI_VENDOR_CREATIVELABS, 91 .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY, 92 .sb_subsystem = 0x10021102, 93 .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2, 94 }, 95 { 96 .sb_board = "generic", 97 .sb_name = "Sound Blaster Audigy 2", 98 .sb_vendor = PCI_VENDOR_CREATIVELABS, 99 .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY, 100 .sb_revision = 0x8, 101 .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2, 102 }, 103 { 104 .sb_board = "generic", 105 .sb_name = "Sound Blaster Audigy 2", 106 .sb_vendor = PCI_VENDOR_CREATIVELABS, 107 .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY, 108 .sb_revision = 0x4, 109 .sb_flags = EMUXKI_AUDIGY | EMUXKI_AUDIGY2, 110 }, 111 { 112 .sb_board = "generic", 113 .sb_name = "Sound Blaster Audigy", 114 .sb_vendor = PCI_VENDOR_CREATIVELABS, 115 .sb_product = PCI_PRODUCT_CREATIVELABS_AUDIGY, 116 .sb_flags = EMUXKI_AUDIGY, 117 }, 118 { 119 .sb_board = "generic", 120 .sb_name = "Sound Blaster Live! 2", 121 .sb_vendor = PCI_VENDOR_CREATIVELABS, 122 .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE2, 123 .sb_flags = EMUXKI_SBLIVE, 124 }, 125 { 126 .sb_board = "CT4870", 127 .sb_name = "Sound Blaster Live! Value", 128 .sb_vendor = PCI_VENDOR_CREATIVELABS, 129 .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE, 130 .sb_subsystem = 0x80281102, 131 .sb_flags = EMUXKI_SBLIVE, 132 }, 133 { 134 .sb_board = "CT4790", 135 .sb_name = "Sound Blaster PCI512", 136 .sb_vendor = PCI_VENDOR_CREATIVELABS, 137 .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE, 138 .sb_subsystem = 0x80231102, 139 .sb_flags = EMUXKI_SBLIVE, 140 }, 141 { 142 .sb_board = "PC545", 143 .sb_name = "Sound Blaster E-mu APS", 144 .sb_vendor = PCI_VENDOR_CREATIVELABS, 145 .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE, 146 .sb_subsystem = 0x40011102, 147 .sb_flags = EMUXKI_APS, 148 }, 149 { 150 .sb_board = "generic", 151 .sb_name = "Sound Blaster Live!", 152 .sb_vendor = PCI_VENDOR_CREATIVELABS, 153 .sb_product = PCI_PRODUCT_CREATIVELABS_SBLIVE, 154 .sb_flags = EMUXKI_SBLIVE, 155 }, 156 }; 157 158 const struct emuxki_board * 159 emuxki_board_lookup(pci_vendor_id_t vendor, pci_product_id_t product, 160 uint32_t subsystem, uint8_t revision) 161 { 162 const struct emuxki_board *sb; 163 unsigned int i; 164 165 for (i = 0; i < __arraycount(emuxki_boards); i++) { 166 sb = &emuxki_boards[i]; 167 168 /* precise match */ 169 if (vendor == sb->sb_vendor && product == sb->sb_product && 170 subsystem == sb->sb_subsystem && revision == sb->sb_revision) 171 return sb; 172 173 /* generic fallback (same subsystem, any revision) */ 174 if (vendor == sb->sb_vendor && product == sb->sb_product && 175 subsystem == sb->sb_subsystem && sb->sb_revision == 0) 176 return sb; 177 178 /* generic fallback (any subsystem, specific revision) */ 179 if (vendor == sb->sb_vendor && product == sb->sb_product && 180 sb->sb_subsystem == 0 && revision == sb->sb_revision) 181 return sb; 182 183 /* generic fallback (same vendor, same product) */ 184 if (vendor == sb->sb_vendor && product == sb->sb_product && 185 sb->sb_subsystem == 0 && sb->sb_revision == 0) 186 return sb; 187 } 188 189 return NULL; 190 } 191