Update of /cvsroot/alsa/alsa-kernel/pci/ymfpci In directory sc8-pr-cvs1:/tmp/cvs-serv10067/pci/ymfpci
Modified Files: ymfpci.c ymfpci_main.c Log Message: - removed joystick control from the card control API. added joystick (or joystick_port) module option instead. - updated documents for this joystick fix. - moved resource management for ALS4000 from sb-common header to the als4000 local code. Index: ymfpci.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/ymfpci/ymfpci.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- ymfpci.c 14 Oct 2003 13:08:20 -0000 1.28 +++ ymfpci.c 14 Oct 2003 13:59:21 -0000 1.29 @@ -44,8 +44,11 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ -static long fm_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; -static long mpu_port[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -1}; +static long fm_port[SNDRV_CARDS]; +static long mpu_port[SNDRV_CARDS]; +#ifdef SUPPORT_JOYSTICK +static long joystick_port[SNDRV_CARDS]; +#endif static int rear_switch[SNDRV_CARDS]; MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); @@ -63,6 +66,11 @@ MODULE_PARM(fm_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); MODULE_PARM_DESC(fm_port, "FM OPL-3 Port."); MODULE_PARM_SYNTAX(fm_port, SNDRV_ENABLED); +#ifdef SUPPORT_JOYSTICK +MODULE_PARM(joystick_port, "1-" __MODULE_STRING(SNDRV_CARDS) "l"); +MODULE_PARM_DESC(joystick_port, "Joystick port address"); +MODULE_PARM_SYNTAX(joystick_port, SNDRV_ENABLED); +#endif MODULE_PARM(rear_switch, "1-" __MODULE_STRING(SNDRV_CARDS) "i"); MODULE_PARM_DESC(rear_switch, "Enable shared rear/line-in switch"); MODULE_PARM_SYNTAX(rear_switch, SNDRV_ENABLED "," SNDRV_BOOLEAN_FALSE_DESC); @@ -86,6 +94,9 @@ snd_card_t *card; struct resource *fm_res = NULL; struct resource *mpu_res = NULL; +#ifdef SUPPORT_JOYSTICK + struct resource *joystick_res = NULL; +#endif ymfpci_t *chip; opl3_t *opl3; char *str; @@ -117,22 +128,32 @@ legacy_ctrl2 = 0x0800; /* SBEN = 0, SMOD = 01, LAD = 0 */ if (pci_id->device >= 0x0010) { /* YMF 744/754 */ - if (fm_port[dev] < 0) { + if (fm_port[dev] <= 0) { fm_port[dev] = pci_resource_start(pci, 1); } - if (fm_port[dev] >= 0 && + if (fm_port[dev] > 0 && (fm_res = request_region(fm_port[dev], 4, "YMFPCI OPL3")) != NULL) { legacy_ctrl |= YMFPCI_LEGACY_FMEN; pci_write_config_word(pci, PCIR_DSXG_FMBASE, fm_port[dev]); } - if (mpu_port[dev] < 0) { + if (mpu_port[dev] <= 0) { mpu_port[dev] = pci_resource_start(pci, 1) + 0x20; } - if (mpu_port[dev] >= 0 && + if (mpu_port[dev] > 0 && (mpu_res = request_region(mpu_port[dev], 2, "YMFPCI MPU401")) != NULL) { legacy_ctrl |= YMFPCI_LEGACY_MEN; pci_write_config_word(pci, PCIR_DSXG_MPU401BASE, mpu_port[dev]); } +#ifdef SUPPORT_JOYSTICK + if (joystick_port[dev] < 0) { + joystick_port[dev] = pci_resource_start(pci, 2); + } + if (joystick_port[dev] >= 0 && + (joystick_res = request_region(joystick_port[dev], 1, "YMFPCI gameport")) != NULL) { + legacy_ctrl |= YMFPCI_LEGACY_JPEN; + pci_write_config_word(pci, PCIR_DSXG_JOYBASE, joystick_port[dev]); + } +#endif } else { switch (fm_port[dev]) { case 0x388: legacy_ctrl2 |= 0; break; @@ -162,6 +183,22 @@ legacy_ctrl2 &= ~YMFPCI_LEGACY2_MPUIO; mpu_port[dev] = -1; } +#ifdef SUPPORT_JOYSTICK + switch (joystick_port[dev]) { + case 0x201: legacy_ctrl2 |= 0 << 6; break; + case 0x202: legacy_ctrl2 |= 1 << 6; break; + case 0x204: legacy_ctrl2 |= 2 << 6; break; + case 0x205: legacy_ctrl2 |= 3 << 6; break; + default: joystick_port[dev] = -1; break; + } + if (joystick_port[dev] > 0 && + (joystick_res = request_region(joystick_port[dev], 1, "YMFPCI gameport")) != NULL) { + legacy_ctrl |= YMFPCI_LEGACY_JPEN; + } else { + legacy_ctrl2 &= ~YMFPCI_LEGACY2_JSIO; + joystick_port[dev] = -1; + } +#endif } if (mpu_res) { legacy_ctrl |= YMFPCI_LEGACY_MIEN; @@ -182,10 +219,19 @@ release_resource(fm_res); kfree_nocheck(fm_res); } +#ifdef SUPPORT_JOYSTICK + if (joystick_res) { + release_resource(joystick_res); + kfree_nocheck(joystick_res); + } +#endif return err; } chip->fm_res = fm_res; chip->mpu_res = mpu_res; +#ifdef SUPPORT_JOYSTICK + chip->joystick_res = joystick_res; +#endif if ((err = snd_ymfpci_pcm(chip, 0, NULL)) < 0) { snd_card_free(card); return err; @@ -233,9 +279,10 @@ return err; } } -#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) - if ((err = snd_ymfpci_joystick(chip)) < 0) { - printk(KERN_WARNING "ymfpci: cannot initialize joystick, skipping...\n"); +#ifdef SUPPORT_JOYSTICK + if (chip->joystick_res) { + chip->gameport.io = joystick_port[dev]; + gameport_register_port(&chip->gameport); } #endif strcpy(card->driver, str); Index: ymfpci_main.c =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/pci/ymfpci/ymfpci_main.c,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- ymfpci_main.c 7 Oct 2003 10:03:24 -0000 1.42 +++ ymfpci_main.c 14 Oct 2003 13:59:21 -0000 1.43 @@ -1775,177 +1775,6 @@ /* - * joystick support - */ - -#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) -static int ymfpci_joystick_ports[4] = { - 0x201, 0x202, 0x204, 0x205 -}; - -static int snd_ymfpci_get_joystick_port(ymfpci_t *chip, int index) -{ - if (index < 4) - return ymfpci_joystick_ports[index]; - else - return pci_resource_start(chip->pci, 2); -} - -static void setup_joystick_base(ymfpci_t *chip) -{ - if (chip->device_id >= 0x0010) /* YMF 744/754 */ - pci_write_config_word(chip->pci, PCIR_DSXG_JOYBASE, - snd_ymfpci_get_joystick_port(chip, chip->joystick_port)); - else { - u16 legacy_ctrl2; - pci_read_config_word(chip->pci, PCIR_DSXG_ELEGACY, &legacy_ctrl2); - legacy_ctrl2 &= ~YMFPCI_LEGACY2_JSIO; - legacy_ctrl2 |= chip->joystick_port << 6; - pci_write_config_word(chip->pci, PCIR_DSXG_ELEGACY, legacy_ctrl2); - } -} - -static int snd_ymfpci_enable_joystick(ymfpci_t *chip) -{ - u16 val; - - chip->gameport.io = snd_ymfpci_get_joystick_port(chip, chip->joystick_port); - chip->joystick_res = request_region(chip->gameport.io, 1, "YMFPCI gameport"); - if (!chip->joystick_res) { - snd_printk(KERN_WARNING "gameport port %#x in use\n", chip->gameport.io); - return 0; - } - setup_joystick_base(chip); - pci_read_config_word(chip->pci, PCIR_DSXG_LEGACY, &val); - val |= YMFPCI_LEGACY_JPEN; - pci_write_config_word(chip->pci, PCIR_DSXG_LEGACY, val); - gameport_register_port(&chip->gameport); - return 1; -} - -static int snd_ymfpci_disable_joystick(ymfpci_t *chip) -{ - u16 val; - - gameport_unregister_port(&chip->gameport); - pci_read_config_word(chip->pci, PCIR_DSXG_LEGACY, &val); - val &= ~YMFPCI_LEGACY_JPEN; - pci_write_config_word(chip->pci, PCIR_DSXG_LEGACY, val); - release_resource(chip->joystick_res); - kfree_nocheck(chip->joystick_res); - chip->joystick_res = NULL; - return 1; -} - -static int snd_ymfpci_joystick_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; - uinfo->count = 1; - uinfo->value.integer.min = 0; - uinfo->value.integer.max = 1; - return 0; -} - -static int snd_ymfpci_joystick_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) -{ - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - u16 val; - - pci_read_config_word(chip->pci, PCIR_DSXG_LEGACY, &val); - ucontrol->value.integer.value[0] = (val & YMFPCI_LEGACY_JPEN) ? 1 : 0; - return 0; -} - -static int snd_ymfpci_joystick_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) -{ - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - int enabled, change; - - down(&chip->joystick_mutex); - enabled = chip->joystick_res != NULL; - change = enabled != !! ucontrol->value.integer.value[0]; - if (change) { - if (!enabled) - change = snd_ymfpci_enable_joystick(chip); - else - change = snd_ymfpci_disable_joystick(chip); - } - up(&chip->joystick_mutex); - return change; -} - -static int snd_ymfpci_joystick_addr_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) -{ - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - int ports = chip->device_id >= 0x0010 ? 5 : 4; - - uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; - uinfo->count = 1; - uinfo->value.enumerated.items = ports; - if (uinfo->value.enumerated.item >= ports) - uinfo->value.enumerated.item = ports - 1; - sprintf(uinfo->value.enumerated.name, "port 0x%x", - snd_ymfpci_get_joystick_port(chip, uinfo->value.enumerated.item)); - return 0; -} - -static int snd_ymfpci_joystick_addr_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) -{ - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - ucontrol->value.enumerated.item[0] = chip->joystick_port; - return 0; -} - -static int snd_ymfpci_joystick_addr_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol) -{ - ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - int change, enabled; - - down(&chip->joystick_mutex); - change = ucontrol->value.enumerated.item[0] != chip->joystick_port; - if (change) { - enabled = chip->joystick_res != NULL; - if (enabled) - snd_ymfpci_disable_joystick(chip); - chip->joystick_port = ucontrol->value.enumerated.item[0]; - if (enabled) - snd_ymfpci_enable_joystick(chip); - } - up(&chip->joystick_mutex); - return change; -} - -static snd_kcontrol_new_t snd_ymfpci_control_joystick __devinitdata = { - .name = "Joystick", - .iface = SNDRV_CTL_ELEM_IFACE_CARD, - .info = snd_ymfpci_joystick_info, - .get = snd_ymfpci_joystick_get, - .put = snd_ymfpci_joystick_put, -}; - -static snd_kcontrol_new_t snd_ymfpci_control_joystick_addr __devinitdata = { - .name = "Joystick Address", - .iface = SNDRV_CTL_ELEM_IFACE_CARD, - .info = snd_ymfpci_joystick_addr_info, - .get = snd_ymfpci_joystick_addr_get, - .put = snd_ymfpci_joystick_addr_put, -}; - -int __devinit snd_ymfpci_joystick(ymfpci_t *chip) -{ - int err; - - chip->joystick_port = 0; /* default */ - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_control_joystick, chip))) < 0) - return err; - if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_control_joystick_addr, chip))) < 0) - return err; - return 0; -} -#endif /* CONFIG_GAMEPORT */ - - -/* * proc interface */ @@ -2194,9 +2023,13 @@ release_resource(chip->fm_res); kfree_nocheck(chip->fm_res); } -#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) - if (chip->joystick_res) - snd_ymfpci_disable_joystick(chip); +#ifdef SUPPORT_JOYSTICK + if (chip->joystick_res) { + if (chip->gameport.io) + gameport_unregister_port(&chip->gameport); + release_resource(chip->joystick_res); + kfree_nocheck(chip->joystick_res); + } #endif if (chip->reg_area_virt) iounmap((void *)chip->reg_area_virt); @@ -2347,9 +2180,6 @@ spin_lock_init(&chip->voice_lock); init_waitqueue_head(&chip->interrupt_sleep); atomic_set(&chip->interrupt_sleep_count, 0); -#if defined(CONFIG_GAMEPORT) || (defined(MODULE) && defined(CONFIG_GAMEPORT_MODULE)) - init_MUTEX(&chip->joystick_mutex); -#endif chip->card = card; chip->pci = pci; chip->irq = -1; ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects. See the people who have HELPED US provide better services: Click here: http://sourceforge.net/supporters.php _______________________________________________ Alsa-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-cvslog