#if defined(CONFIG_PM) && defined(CONFIG_PMAC_PBOOK) 
#ifdef CONFIG_PM 
int __init snd_pmac_new(snd_card_t *card, pmac_t **chip_return){	pmac_t *chip;	struct device_node *np;	int i, err;	unsigned long ctrl_addr, txdma_addr, rxdma_addr;	static snd_device_ops_t ops = {		.dev_free =	snd_pmac_dev_free,	};	snd_runtime_check(chip_return, return -EINVAL);	*chip_return = NULL;	chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);	if (chip == NULL)		return -ENOMEM;	chip->card = card;	spin_lock_init(&chip->reg_lock);	chip->irq = chip->tx_irq = chip->rx_irq = -1;	chip->playback.stream = SNDRV_PCM_STREAM_PLAYBACK;	chip->capture.stream = SNDRV_PCM_STREAM_CAPTURE;	if ((err = snd_pmac_detect(chip)) < 0)		goto __error;	if (snd_pmac_dbdma_alloc(chip, &chip->playback.cmd, PMAC_MAX_FRAGS + 1) < 0 ||	    snd_pmac_dbdma_alloc(chip, &chip->capture.cmd, PMAC_MAX_FRAGS + 1) < 0 ||	    snd_pmac_dbdma_alloc(chip, &chip->extra_dma, 2) < 0) {		err = -ENOMEM;		goto __error;	}	np = chip->node;	if (chip->is_k2) {		if (np->parent->n_addrs < 2 || np->n_intrs < 3) {			err = -ENODEV;			goto __error;		}		for (i = 0; i < 2; i++) {#ifndef CONFIG_PPC64			static char *name[2] = { "- Control", "- DMA" };			if (! request_OF_resource(np->parent, i, name[i])) {				snd_printk(KERN_ERR "pmac: can't request resource %d!\n", i);				err = -ENODEV;				goto __error;			}			chip->of_requested |= (1 << i);#endif /* CONFIG_PPC64 */			ctrl_addr = np->parent->addrs[0].address;			txdma_addr = np->parent->addrs[1].address;			rxdma_addr = txdma_addr + 0x100;		}	} else {		if (np->n_addrs < 3 || np->n_intrs < 3) {			err = -ENODEV;			goto __error;		}		for (i = 0; i < 3; i++) {#ifndef CONFIG_PPC64			static char *name[3] = { "- Control", "- Tx DMA", "- Rx DMA" };			if (! request_OF_resource(np, i, name[i])) {				snd_printk(KERN_ERR "pmac: can't request resource %d!\n", i);				err = -ENODEV;				goto __error;			}			chip->of_requested |= (1 << i);#endif /* CONFIG_PPC64 */			ctrl_addr = np->addrs[0].address;			txdma_addr = np->addrs[1].address;			rxdma_addr = np->addrs[2].address;		}	}	chip->awacs = ioremap(ctrl_addr, 0x1000);	chip->playback.dma = ioremap(txdma_addr, 0x100);	chip->capture.dma = ioremap(rxdma_addr, 0x100);	if (chip->model <= PMAC_BURGUNDY) {		if (request_irq(np->intrs[0].line, snd_pmac_ctrl_intr, 0,				"PMac", (void*)chip)) {			snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", np->intrs[0].line);			err = -EBUSY;			goto __error;		}		chip->irq = np->intrs[0].line;	}	if (request_irq(np->intrs[1].line, snd_pmac_tx_intr, 0,			"PMac Output", (void*)chip)) {		snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", np->intrs[1].line);		err = -EBUSY;		goto __error;	}	chip->tx_irq = np->intrs[1].line;	if (request_irq(np->intrs[2].line, snd_pmac_rx_intr, 0,			"PMac Input", (void*)chip)) {		snd_printk(KERN_ERR "pmac: unable to grab IRQ %d\n", np->intrs[2].line);		err = -EBUSY;		goto __error;	}	chip->rx_irq = np->intrs[2].line;	snd_pmac_sound_feature(chip, 1);	/* reset */	if (chip->model == PMAC_AWACS)		out_le32(&chip->awacs->control, 0x11);	/* Powerbooks have odd ways of enabling inputs such as	   an expansion-bay CD or sound from an internal modem	   or a PC-card modem. */	if (chip->is_pbook_3400) {		/* Enable CD and PC-card sound inputs. */		/* This is done by reading from address		 * f301a000, + 0x10 to enable the expansion-bay		 * CD sound input, + 0x80 to enable the PC-card		 * sound input.  The 0x100 enables the SCSI bus		 * terminator power.		 */		chip->latch_base = ioremap (0xf301a000, 0x1000);		in_8(chip->latch_base + 0x190);	} else if (chip->is_pbook_G3) {		struct device_node* mio;		for (mio = chip->node->parent; mio; mio = mio->parent) {			if (strcmp(mio->name, "mac-io") == 0			    && mio->n_addrs > 0) {				chip->macio_base = ioremap(mio->addrs[0].address, 0x40);				break;			}		}		/* Enable CD sound input. */		/* The relevant bits for writing to this byte are 0x8f.		 * I haven't found out what the 0x80 bit does.		 * For the 0xf bits, writing 3 or 7 enables the CD		 * input, any other value disables it.  Values		 * 1, 3, 5, 7 enable the microphone.  Values 0, 2,		 * 4, 6, 8 - f enable the input from the modem.		 */		if (chip->macio_base)			out_8(chip->macio_base + 0x37, 3);	}	/* Reset dbdma channels */	snd_pmac_dbdma_reset(chip);#if defined(CONFIG_PM) && defined(CONFIG_PMAC_PBOOK)	/* add sleep notifier */	if (! snd_pmac_register_sleep_notifier(chip))		snd_card_set_pm_callback(chip->card, snd_pmac_suspend, snd_pmac_resume, chip);#endif	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)		goto __error;	*chip_return = chip;	return 0; __error:	if (chip->pdev)		pci_dev_put(chip->pdev);	snd_pmac_free(chip);	return err;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/8c8709334cec803368a432a33e0f2e116d48fe07/pmac.c/buggy/sound/ppc/pmac.c