/* * Tries to detect the currently attached accessory */ static enum accessory_jack_type detect(struct abx500_ad *dd, int *req_det_count) { enum accessory_jack_type type = JACK_TYPE_DISCONNECTED; int i; accessory_regulator_enable(dd, REGULATOR_VAUDIO | REGULATOR_AVSWITCH); /* enable the VAMIC1 regulator */ dd->config_hw_test_basic_carkit(dd, 0); for (i = 0; i < ARRAY_SIZE(detect_ops); ++i) { if (detect_hw(dd, &detect_ops[i])) { type = detect_ops[i].type; *req_det_count = detect_ops[i].req_det_count; break; } } dd->config_hw_test_plug_connected(dd, 0); if (jack_supports_buttons(type)) accessory_regulator_enable(dd, REGULATOR_VAMIC1); else accessory_regulator_disable(dd, REGULATOR_VAMIC1 | REGULATOR_AVSWITCH); accessory_regulator_disable(dd, REGULATOR_VAUDIO); return type; }
int drv_init_hw (void) { u16_t i, j; /* First, detect the hardware */ if (detect_hw() != OK) { return EIO; } /* PCI command register * enable the SERR# driver, PCI bus mastering and I/O access */ pci_attr_w16 (dev.devind, PCI_CR, SERR_EN|PCI_MASTER|IO_ACCESS); /* turn everything off */ pci_outl(reg(CHIP_SEL_CTRL), 0x0UL); /* turn off legacy (legacy control is undocumented) */ pci_outl(reg(LEGACY), 0x0UL); pci_outl(reg(LEGACY+4), 0x0UL); /* turn off serial interface */ pci_outl(reg(SERIAL_INTERFACE_CTRL), 0x0UL); /*pci_outl(reg(SERIAL_INTERFACE_CTRL), 0x3UL);*/ /* clear all the memory */ for (i = 0; i < 0x10; ++i) { pci_outb(reg(MEM_PAGE), i); for (j = 0; j < 0x10; j += 4) { pci_outl (reg(MEMORY) + j, 0x0UL); } } /* Sample Rate Converter initialization */ if (src_init(&dev) != OK) { return EIO; } if (AC97_init(&dev) != OK) { return EIO; } /* initialize variables for each sub_device */ for (i = 0; i < drv.NrOfSubDevices; i++) { if(i != MIXER) { aud_conf[i].busy = 0; aud_conf[i].stereo = DEFAULT_STEREO; aud_conf[i].sample_rate = DEFAULT_RATE; aud_conf[i].nr_of_bits = DEFAULT_NR_OF_BITS; aud_conf[i].sign = DEFAULT_SIGNED; aud_conf[i].fragment_size = sub_dev[i].DmaSize / sub_dev[i].NrOfDmaFragments; } } return OK; }