Lines Matching full:chip
172 This directory contains the codes for ASoC (ALSA System on Chip)
229 /* definition of the chip-specific record */
237 /* chip-specific destructor
240 static int snd_mychip_free(struct mychip *chip)
253 /* chip-specific constructor
260 struct mychip *chip;
273 /* allocate a chip-specific data with zero filled */
274 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
275 if (chip == NULL)
278 chip->card = card;
285 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
287 snd_mychip_free(chip);
291 *rchip = chip;
301 struct mychip *chip;
319 err = snd_mychip_create(card, pci, &chip);
324 strcpy(card->driver, "My Chip");
325 strcpy(card->shortname, "My Own Chip 123");
327 card->shortname, chip->port, chip->irq);
409 struct mychip *chip;
411 err = snd_mychip_create(card, pci, &chip);
437 strcpy(card->driver, "My Chip");
438 strcpy(card->shortname, "My Own Chip 123");
440 card->shortname, chip->port, chip->irq);
442 The driver field holds the minimal ID string of the chip. This is used
445 functionality of each chip type.
560 card->private_data for the chip-specific data. Note that these data are
581 snd_device_new(card, SNDRV_DEV_XXX, chip, &ops);
592 argument. This pointer (``chip`` in the above example) is used as the
603 example will show an implementation of chip-specific data.
605 Chip-Specific Data
608 Chip-specific information, e.g. the I/O port address, its resource
609 pointer, or the irq number, is stored in the chip-specific record.
618 In general, there are two ways of allocating the chip record.
631 :c:type:`struct mychip <mychip>` is the type of the chip record.
637 struct mychip *chip = card->private_data;
651 struct mychip *chip;
655 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
657 The chip record should have the field to hold the card pointer at least,
667 Then, set the card pointer in the returned chip instance.
671 chip->card = card;
673 Next, initialize the fields, and register this chip record as a
682 snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
727 In this section, we'll complete the chip-specific constructor,
740 static int snd_mychip_free(struct mychip *chip)
746 if (chip->irq >= 0)
747 free_irq(chip->irq, chip);
749 pci_release_regions(chip->pci);
751 pci_disable_device(chip->pci);
753 kfree(chip);
757 /* chip-specific constructor */
762 struct mychip *chip;
782 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
783 if (chip == NULL) {
789 chip->card = card;
790 chip->pci = pci;
791 chip->irq = -1;
794 err = pci_request_regions(pci, "My Chip");
796 kfree(chip);
800 chip->port = pci_resource_start(pci, 0);
802 IRQF_SHARED, KBUILD_MODNAME, chip)) {
804 snd_mychip_free(chip);
807 chip->irq = pci->irq;
809 /* (2) initialization of the chip hardware */
812 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
814 snd_mychip_free(chip);
818 *rchip = chip;
917 err = pci_request_regions(pci, "My Chip");
919 kfree(chip);
923 chip->port = pci_resource_start(pci, 0);
926 The returned value, ``chip->res_port``, is allocated via
936 IRQF_SHARED, KBUILD_MODNAME, chip)) {
938 snd_mychip_free(chip);
941 chip->irq = pci->irq;
945 ``chip->irq`` should be defined only when :c:func:`request_irq()`
952 passed to the interrupt handler. Usually, the chip-specific record is
963 struct mychip *chip = dev_id;
979 if (chip->irq >= 0)
980 free_irq(chip->irq, chip);
983 ``chip->irq`` with a negative value (e.g. -1), so that you can check
995 pci_release_regions(chip->pci);
1001 chip->res_port, the release procedure looks like:
1005 release_and_free_resource(chip->res_port);
1010 And finally, release the chip-specific record.
1014 kfree(chip);
1018 before the initialization of the chip is completed. It would be better
1022 When the chip-data is assigned to the card using
1045 err = pci_request_regions(pci, "My Chip");
1047 kfree(chip);
1050 chip->iobase_phys = pci_resource_start(pci, 0);
1051 chip->iobase_virt = ioremap_nocache(chip->iobase_phys,
1058 static int snd_mychip_free(struct mychip *chip)
1061 if (chip->iobase_virt)
1062 iounmap(chip->iobase_virt);
1064 pci_release_regions(chip->pci);
1073 err = pci_request_regions(pci, "My Chip");
1075 kfree(chip);
1078 chip->iobase_virt = pci_iomap(pci, 0, 0);
1235 struct mychip *chip = snd_pcm_substream_chip(substream);
1247 struct mychip *chip = snd_pcm_substream_chip(substream);
1257 struct mychip *chip = snd_pcm_substream_chip(substream);
1269 struct mychip *chip = snd_pcm_substream_chip(substream);
1293 struct mychip *chip = snd_pcm_substream_chip(substream);
1299 mychip_set_sample_format(chip, runtime->format);
1300 mychip_set_sample_rate(chip, runtime->rate);
1301 mychip_set_channels(chip, runtime->channels);
1302 mychip_set_dma_setup(chip, runtime->dma_addr,
1303 chip->buffer_size,
1304 chip->period_size);
1330 struct mychip *chip = snd_pcm_substream_chip(substream);
1334 current_ptr = mychip_get_hw_pointer(chip);
1367 static int snd_mychip_new_pcm(struct mychip *chip)
1372 err = snd_pcm_new(chip->card, "My Chip", 0, 1, 1, &pcm);
1375 pcm->private_data = chip;
1376 strcpy(pcm->name, "My Chip");
1377 chip->pcm = pcm;
1386 snd_dma_pci_data(chip->pci),
1400 static int snd_mychip_new_pcm(struct mychip *chip)
1405 err = snd_pcm_new(chip->card, "My Chip", 0, 1, 1, &pcm);
1408 pcm->private_data = chip;
1409 strcpy(pcm->name, "My Chip");
1410 chip->pcm = pcm;
1429 If a chip supports multiple playbacks or captures, you can specify more
1473 snd_dma_pci_data(chip->pci),
1506 struct mychip *chip = snd_pcm_chip(pcm);
1508 kfree(chip->my_private_pcm_data);
1513 static int snd_mychip_new_pcm(struct mychip *chip)
1518 chip->my_private_pcm_data = kmalloc(...);
1520 pcm->private_data = chip;
1640 channels is 1 only on some chip models, you can still use the same
1648 if (chip->model == VERY_OLD_ONE)
1709 (``SNDRV_PCM_RATE_XXX``). When the chip supports continuous rates,
1711 provided only for typical rates. If your chip supports
1809 ``pcm->private_data`` usually points to the chip instance assigned
1838 snd_pcm_substream <snd_pcm_substream>` pointer. To retrieve the chip
1845 struct mychip *chip = snd_pcm_substream_chip(substream);
1872 struct mychip *chip = snd_pcm_substream_chip(substream);
2133 from the chip instance. For example, define ``substream`` field in the
2134 chip record to hold the current running substream pointer, and set the
2150 struct mychip *chip = dev_id;
2151 spin_lock(&chip->lock);
2153 if (pcm_irq_invoked(chip)) {
2155 spin_unlock(&chip->lock);
2156 snd_pcm_period_elapsed(chip->substream);
2157 spin_lock(&chip->lock);
2161 spin_unlock(&chip->lock);
2184 struct mychip *chip = dev_id;
2185 spin_lock(&chip->lock);
2187 if (pcm_irq_invoked(chip)) {
2190 last_ptr = get_hw_ptr(chip);
2194 if (last_ptr < chip->last_ptr)
2196 - chip->last_ptr;
2198 size = last_ptr - chip->last_ptr;
2200 chip->last_ptr = last_ptr;
2202 chip->size += size;
2204 if (chip->size >= runtime->period_size) {
2206 chip->size %= runtime->period_size;
2208 spin_unlock(&chip->lock);
2210 spin_lock(&chip->lock);
2215 spin_unlock(&chip->lock);
2271 If your chip supports unconventional sample rates, or only the limited
2405 ALSA has a well-defined AC97 control module. If your chip supports only
2636 struct mychip *chip = snd_kcontrol_chip(kcontrol);
2637 ucontrol->value.integer.value[0] = get_some_value(chip);
2683 struct mychip *chip = snd_kcontrol_chip(kcontrol);
2685 if (chip->current_value !=
2687 change_current_value(chip,
2719 err = snd_ctl_add(card, snd_ctl_new1(&my_control, chip));
2724 <snd_kcontrol_new>` object defined above, and chip is the object
2813 struct mychip *chip = ac97->private_data;
2822 struct mychip *chip = ac97->private_data;
2827 static int snd_mychip_ac97(struct mychip *chip)
2837 err = snd_ac97_bus(chip->card, 0, &ops, NULL, &bus);
2841 ac97.private_data = chip;
2842 return snd_ac97_mixer(bus, &ac97, &chip->ac97);
2874 ac97.private_data = chip;
2875 snd_ac97_mixer(bus, &ac97, &chip->ac97);
2877 where chip->ac97 is a pointer to a newly created ``ac97_t``
2878 instance. In this case, the chip pointer is set as the private data,
2879 so that the read/write callback functions can refer to this chip
2880 instance. This instance is not necessarily stored in the chip
2900 struct mychip *chip = ac97->private_data;
2905 Here, the chip can be cast from ``ac97->private_data``.
2920 The ``reset`` callback is used to reset the codec. If the chip
2924 initialization of the codec. If the chip requires the extra waiting
3040 PCI I/O region. It depends on the chip design.
3135 err = snd_rawmidi_new(chip->card, "MyMIDI", 0, outs, ins, &rmidi);
3138 rmidi->private_data = chip;
3383 call :c:func:`snd_opl3_init()` to initialize the chip to the
3443 this chip needs an ioctl.
3479 set the raw bit mode. The implementation will depend on the chip, but
3563 Another case is when the chip uses a PCI memory-map region for the
3700 the :c:type:`struct pci_dev <pci_dev>` pointer of the chip as
3785 snd_info_set_text_ops(entry, chip, my_proc_read);
3787 where the second argument (``chip``) is the private data to be used in
3806 struct my_chip *chip = entry->private_data;
3808 snd_iprintf(buffer, "This is my chip!\n");
3809 snd_iprintf(buffer, "Port = %ld\n", chip->port);
3840 entry->private_data = chip;
3874 If the chip is supposed to work with suspend/resume functions, you need
3883 possible when the registers of the chip can be safely saved and restored
3922 1. Retrieve the card and the chip data.
3942 struct mychip *chip = card->private_data;
3946 snd_ac97_suspend(chip->ac97);
3948 snd_mychip_save_registers(chip);
3950 snd_mychip_stop_hardware(chip);
3957 1. Retrieve the card and the chip data.
3959 2. Re-initialize the chip.
3978 struct mychip *chip = card->private_data;
3980 snd_mychip_reinit_chip(chip);
3982 snd_mychip_restore_registers(chip);
3984 snd_ac97_resume(chip->ac97);
3986 snd_mychip_restart_chip(chip);
3997 of the card, make sure that you can get the chip data from the card
3999 chip data individually.
4008 struct mychip *chip;
4014 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
4016 card->private_data = chip;
4020 When you created the chip data with :c:func:`snd_card_new()`, it's
4030 struct mychip *chip;
4036 chip = card->private_data;
4087 #define CARD_NAME "My Chip"
4102 MODULE_DESCRIPTION("Sound driver for My Chip");