ymfpci.c (60c5772b50fe8ce947685cfe3a80b9bf6ea92831) ymfpci.c (6436bcf6a4a35ae83af9ff3c250435e5fd001205)
1/*
2 * The driver for the Yamaha's DS1/DS1E cards
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 *
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 92 unchanged lines hidden (view full) ---

101 /* auto-detect */
102 for (io_port = 0x201; io_port <= 0x205; io_port++) {
103 if (io_port == 0x203)
104 continue;
105 if ((r = request_region(io_port, 1, "YMFPCI gameport")) != NULL)
106 break;
107 }
108 if (!r) {
1/*
2 * The driver for the Yamaha's DS1/DS1E cards
3 * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
4 *
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 92 unchanged lines hidden (view full) ---

101 /* auto-detect */
102 for (io_port = 0x201; io_port <= 0x205; io_port++) {
103 if (io_port == 0x203)
104 continue;
105 if ((r = request_region(io_port, 1, "YMFPCI gameport")) != NULL)
106 break;
107 }
108 if (!r) {
109 printk(KERN_ERR "ymfpci: no gameport ports available\n");
109 dev_err(chip->card->dev,
110 "no gameport ports available\n");
110 return -EBUSY;
111 }
112 }
113 switch (io_port) {
114 case 0x201: legacy_ctrl2 |= 0 << 6; break;
115 case 0x202: legacy_ctrl2 |= 1 << 6; break;
116 case 0x204: legacy_ctrl2 |= 2 << 6; break;
117 case 0x205: legacy_ctrl2 |= 3 << 6; break;
118 default:
111 return -EBUSY;
112 }
113 }
114 switch (io_port) {
115 case 0x201: legacy_ctrl2 |= 0 << 6; break;
116 case 0x202: legacy_ctrl2 |= 1 << 6; break;
117 case 0x204: legacy_ctrl2 |= 2 << 6; break;
118 case 0x205: legacy_ctrl2 |= 3 << 6; break;
119 default:
119 printk(KERN_ERR "ymfpci: invalid joystick port %#x", io_port);
120 dev_err(chip->card->dev,
121 "invalid joystick port %#x", io_port);
120 return -EINVAL;
121 }
122 }
123
124 if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) {
122 return -EINVAL;
123 }
124 }
125
126 if (!r && !(r = request_region(io_port, 1, "YMFPCI gameport"))) {
125 printk(KERN_ERR "ymfpci: joystick port %#x is in use.\n", io_port);
127 dev_err(chip->card->dev,
128 "joystick port %#x is in use.\n", io_port);
126 return -EBUSY;
127 }
128
129 chip->gameport = gp = gameport_allocate_port();
130 if (!gp) {
129 return -EBUSY;
130 }
131
132 chip->gameport = gp = gameport_allocate_port();
133 if (!gp) {
131 printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n");
134 dev_err(chip->card->dev,
135 "cannot allocate memory for gameport\n");
132 release_and_free_resource(r);
133 return -ENOMEM;
134 }
135
136
137 gameport_set_name(gp, "Yamaha YMF Gameport");
138 gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci));
139 gameport_set_dev_parent(gp, &chip->pci->dev);

--- 169 unchanged lines hidden (view full) ---

309 return err;
310 }
311 if (chip->mpu_res) {
312 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI,
313 mpu_port[dev],
314 MPU401_INFO_INTEGRATED |
315 MPU401_INFO_IRQ_HOOK,
316 -1, &chip->rawmidi)) < 0) {
136 release_and_free_resource(r);
137 return -ENOMEM;
138 }
139
140
141 gameport_set_name(gp, "Yamaha YMF Gameport");
142 gameport_set_phys(gp, "pci%s/gameport0", pci_name(chip->pci));
143 gameport_set_dev_parent(gp, &chip->pci->dev);

--- 169 unchanged lines hidden (view full) ---

313 return err;
314 }
315 if (chip->mpu_res) {
316 if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_YMFPCI,
317 mpu_port[dev],
318 MPU401_INFO_INTEGRATED |
319 MPU401_INFO_IRQ_HOOK,
320 -1, &chip->rawmidi)) < 0) {
317 printk(KERN_WARNING "ymfpci: cannot initialize MPU401 at 0x%lx, skipping...\n", mpu_port[dev]);
321 dev_warn(card->dev,
322 "cannot initialize MPU401 at 0x%lx, skipping...\n",
323 mpu_port[dev]);
318 legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */
319 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
320 }
321 }
322 if (chip->fm_res) {
323 if ((err = snd_opl3_create(card,
324 fm_port[dev],
325 fm_port[dev] + 2,
326 OPL3_HW_OPL3, 1, &opl3)) < 0) {
324 legacy_ctrl &= ~YMFPCI_LEGACY_MIEN; /* disable MPU401 irq */
325 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
326 }
327 }
328 if (chip->fm_res) {
329 if ((err = snd_opl3_create(card,
330 fm_port[dev],
331 fm_port[dev] + 2,
332 OPL3_HW_OPL3, 1, &opl3)) < 0) {
327 printk(KERN_WARNING "ymfpci: cannot initialize FM OPL3 at 0x%lx, skipping...\n", fm_port[dev]);
333 dev_warn(card->dev,
334 "cannot initialize FM OPL3 at 0x%lx, skipping...\n",
335 fm_port[dev]);
328 legacy_ctrl &= ~YMFPCI_LEGACY_FMEN;
329 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
330 } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
331 snd_card_free(card);
336 legacy_ctrl &= ~YMFPCI_LEGACY_FMEN;
337 pci_write_config_word(pci, PCIR_DSXG_LEGACY, legacy_ctrl);
338 } else if ((err = snd_opl3_hwdep_new(opl3, 0, 1, NULL)) < 0) {
339 snd_card_free(card);
332 snd_printk(KERN_ERR "cannot create opl3 hwdep\n");
340 dev_err(card->dev, "cannot create opl3 hwdep\n");
333 return err;
334 }
335 }
336
337 snd_ymfpci_create_gameport(chip, dev, legacy_ctrl, legacy_ctrl2);
338
339 if ((err = snd_card_register(card)) < 0) {
340 snd_card_free(card);

--- 25 unchanged lines hidden ---
341 return err;
342 }
343 }
344
345 snd_ymfpci_create_gameport(chip, dev, legacy_ctrl, legacy_ctrl2);
346
347 if ((err = snd_card_register(card)) < 0) {
348 snd_card_free(card);

--- 25 unchanged lines hidden ---