• Home
  • Raw
  • Download

Lines Matching +full:num +full:- +full:strings

11 Architecture) <http://www.alsa-project.org/>`__ driver. The document
19 low-level driver implementation details. It only describes the standard
29 -------
61 --------------
65 sub-directories contain different modules and are dependent upon the
74 ``core/seq/oss`` directory (see `below <#core-seq-oss>`__).
79 This directory and its sub-directories are for the ALSA sequencer. This
81 like snd-seq-midi, snd-seq-virmidi, etc. They are compiled only when
90 -----------------
93 to be exported to user-space, or included by several files at different
99 -----------------
102 architectures. They are hence supposed not to be architecture-specific.
104 in this directory. In the sub-directories, there is code for components
110 The MPU401 and MPU401-UART modules are stored here.
115 The OPL3 and OPL4 FM-synth stuff is found here.
118 -------------
127 ---------------
129 This contains the synth middle-level modules.
132 ``synth/emux`` sub-directory.
135 -------------
137 This directory and its sub-directories hold the top-level card modules
142 their own sub-directory (e.g. emu10k1, ice1712).
145 -------------
147 This directory and its sub-directories hold the top-level card modules
151 -------------------------------
153 They are used for top-level card modules which are specific to one of
157 -------------
159 This directory contains the USB-audio driver. In the latest version, the
160 USB MIDI driver is integrated in the usb-audio driver.
163 ----------------
170 -------------
176 -------------
187 -------
191 - define the PCI ID table (see the section `PCI Entries`_).
193 - create ``probe`` callback.
195 - create ``remove`` callback.
197 - create a struct pci_driver structure
200 - create an ``init`` function just calling the
204 - create an ``exit`` function to call the
208 -----------------
229 /* definition of the chip-specific record */
237 /* chip-specific destructor
245 /* component-destructor
250 return snd_mychip_free(device->device_data);
253 /* chip-specific constructor
273 /* allocate a chip-specific data with zero filled */
276 return -ENOMEM;
278 chip->card = card;
295 /* constructor -- see "Driver Constructor" sub-section */
306 return -ENODEV;
309 return -ENOENT;
313 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
324 strcpy(card->driver, "My Chip");
325 strcpy(card->shortname, "My Own Chip 123");
326 sprintf(card->longname, "%s at 0x%lx irq %i",
327 card->shortname, chip->port, chip->irq);
347 /* destructor -- see the "Destructor" sub-section */
356 ------------------
359 ``probe`` callback and other component-constructors which are called
373 return -ENODEV;
376 return -ENOENT;
385 <#set-the-pci-driver-data-and-return-zero>`__).
395 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
432 4) Set the driver ID and name strings.
437 strcpy(card->driver, "My Chip");
438 strcpy(card->shortname, "My Own Chip 123");
439 sprintf(card->longname, "%s at 0x%lx irq %i",
440 card->shortname, chip->port, chip->irq);
443 by alsa-lib's configurator, so keep it simple but unique. Even the
453 Here you define the basic components such as `PCM <#PCM-Interface>`__,
454 mixer (e.g. `AC97 <#API-for-AC97-Codec>`__), MIDI (e.g.
455 `MPU-401 <#MIDI-MPU401-UART-Interface>`__), and other interfaces.
456 Also, if you want a `proc file <#Proc-Interface>`__, define it here,
481 remove callback and power-management callbacks, too.
484 ----------
504 ------------
534 -------------
541 name strings of the card, manages the root of proc files, and controls
542 the power-management states and hotplug disconnections. The component
553 err = snd_card_new(&pci->dev, index, id, module, extra_size, &card);
557 card-index number, the id string, the module pointer (usually
558 ``THIS_MODULE``), the size of extra-data space, and the pointer to
560 card->private_data for the chip-specific data. Note that these data are
564 device. For PCI devices, typically ``&pci->`` is passed there.
567 ----------
582 This takes the card pointer, the device-level (``SNDRV_DEV_XXX``), the
583 data pointer, and the callback pointers (``&ops``). The device-level
585 de-registration. For most components, the device-level is already
586 defined. For a user-defined component, you can use
594 Each pre-defined ALSA component such as ac97 and pcm calls
602 example will show an implementation of chip-specific data.
604 Chip-Specific Data
605 ------------------
607 Chip-specific information, e.g. the I/O port address, its resource
608 pointer, or the irq number, is stored in the chip-specific record.
622 As mentioned above, you can pass the extra-data-length to the 5th
627 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
636 struct mychip *chip = card->private_data;
651 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
670 chip->card = card;
673 low-level device with a specified ``ops``,
683 :c:func:`snd_mychip_dev_free()` is the device-destructor
690 return snd_mychip_free(device->device_data);
703 ------------------------
724 -----------------
726 In this section, we'll complete the chip-specific constructor,
745 if (chip->irq >= 0)
746 free_irq(chip->irq, chip);
748 pci_release_regions(chip->pci);
750 pci_disable_device(chip->pci);
756 /* chip-specific constructor */
778 return -ENXIO;
784 return -ENOMEM;
788 chip->card = card;
789 chip->pci = pci;
790 chip->irq = -1;
799 chip->port = pci_resource_start(pci, 0);
800 if (request_irq(pci->irq, snd_mychip_interrupt,
802 printk(KERN_ERR "cannot grab irq %d\n", pci->irq);
804 return -EBUSY;
806 chip->irq = pci->irq;
807 card->sync_irq = chip->irq;
857 ------------
880 return -ENXIO;
885 -------------------
908 this number as -1 before actual allocation, since irq 0 is valid. The
923 chip->port = pci_resource_start(pci, 0);
926 The returned value, ``chip->res_port``, is allocated via
935 if (request_irq(pci->irq, snd_mychip_interrupt,
937 printk(KERN_ERR "cannot grab irq %d\n", pci->irq);
939 return -EBUSY;
941 chip->irq = pci->irq;
944 defined `later <#pcm-interface-interrupt-handler>`__. Note that
945 ``chip->irq`` should be defined only when :c:func:`request_irq()`
952 passed to the interrupt handler. Usually, the chip-specific record is
968 After requesting the IRQ, you can passed it to ``card->sync_irq``
972 card->irq = chip->irq;
983 To release the resources, the “check-and-release” method is a safer way.
988 if (chip->irq >= 0)
989 free_irq(chip->irq, chip);
992 ``chip->irq`` with a negative value (e.g. -1), so that you can check
1004 pci_release_regions(chip->pci);
1010 chip->res_port, the release procedure looks like:
1014 release_and_free_resource(chip->res_port);
1019 And finally, release the chip-specific record.
1031 When the chip-data is assigned to the card using
1035 have to stop PCMs, etc. explicitly, but just call low-level hardware
1038 The management of a memory-mapped region is almost as same as the
1059 chip->iobase_phys = pci_resource_start(pci, 0);
1060 chip->iobase_virt = ioremap(chip->iobase_phys,
1070 if (chip->iobase_virt)
1071 iounmap(chip->iobase_virt);
1073 pci_release_regions(chip->pci);
1087 chip->iobase_virt = pci_iomap(pci, 0, 0);
1093 -----------
1120 all-zero entry.
1164 -------
1167 for each driver to implement the low-level functions to access its
1191 -----------------
1243 struct snd_pcm_runtime *runtime = substream->runtime;
1245 runtime->hw = snd_mychip_playback_hw;
1246 /* more hardware-initialization will be done here */
1255 /* the hardware-specific codes will be here */
1265 struct snd_pcm_runtime *runtime = substream->runtime;
1267 runtime->hw = snd_mychip_capture_hw;
1268 /* more hardware-initialization will be done here */
1277 /* the hardware-specific codes will be here */
1286 /* the hardware-specific codes will be here */
1294 /* the hardware-specific codes will be here */
1303 struct snd_pcm_runtime *runtime = substream->runtime;
1308 mychip_set_sample_format(chip, runtime->format);
1309 mychip_set_sample_rate(chip, runtime->rate);
1310 mychip_set_channels(chip, runtime->channels);
1311 mychip_set_dma_setup(chip, runtime->dma_addr,
1312 chip->buffer_size,
1313 chip->period_size);
1331 return -EINVAL;
1379 err = snd_pcm_new(chip->card, "My Chip", 0, 1, 1, &pcm);
1382 pcm->private_data = chip;
1383 strcpy(pcm->name, "My Chip");
1384 chip->pcm = pcm;
1390 /* pre-allocation of buffers */
1393 &chip->pci->dev,
1400 ---------------
1412 err = snd_pcm_new(chip->card, "My Chip", 0, 1, 1, &pcm);
1415 pcm->private_data = chip;
1416 strcpy(pcm->name, "My Chip");
1417 chip->pcm = pcm;
1445 int index = substream->number;
1473 After setting the operators, you probably will want to pre-allocate the
1480 &chip->pci->dev,
1488 ``pcm->info_flags``. The available values are defined as
1491 half-duplex, specify like this:
1495 pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
1499 -----------------------
1507 destructor function to ``pcm->private_free``:
1515 kfree(chip->my_private_pcm_data);
1525 chip->my_private_pcm_data = kmalloc(...);
1527 pcm->private_data = chip;
1528 pcm->private_free = mychip_pcm_free;
1534 Runtime Pointer - The Chest of PCM Information
1535 ----------------------------------------------
1539 ``substream->runtime``. This runtime pointer holds most information you
1549 /* -- Status -- */
1557 /* -- HW params -- */
1575 /* -- SW params -- */
1591 /* -- mmap -- */
1596 /* -- locking / scheduling -- */
1602 /* -- private section -- */
1606 /* -- hardware description -- */
1610 /* -- timer -- */
1613 /* -- DMA -- */
1621 /* -- OSS things -- */
1628 records are supposed to be read-only. Only the PCM middle-layer changes
1644 (``runtime->hw``) as you need. For example, if the maximum number of
1650 struct snd_pcm_runtime *runtime = substream->runtime;
1652 runtime->hw = snd_mychip_playback_hw; /* common definition */
1653 if (chip->model == VERY_OLD_ONE)
1654 runtime->hw.channels_max = 1;
1678 - The ``info`` field contains the type and capabilities of this
1684 interleaved or the non-interleaved formats,
1705 need to check the linked-list of PCM substreams in the trigger
1708 - ``formats`` field contains the bit-flags of supported formats
1711 little-endian format is specified.
1713 - ``rates`` field contains the bit-flags of supported rates
1715 pass ``CONTINUOUS`` bit additionally. The pre-defined rate bits are
1720 - ``rate_min`` and ``rate_max`` define the minimum and maximum sample
1723 - ``channel_min`` and ``channel_max`` define, as you might already
1726 - ``buffer_bytes_max`` defines the maximum buffer size in
1742 - There is also a field ``fifo_size``. This specifies the size of the
1744 in the alsa-lib. So, you can ignore this field.
1753 alsa-lib. There are many fields copied from hw_params and sw_params
1760 channels \* samples-size``. For conversion between frames and bytes,
1766 period_bytes = frames_to_bytes(runtime, runtime->period_size);
1798 The running status can be referred via ``runtime->status``. This is
1801 DMA hardware pointer via ``runtime->status->hw_ptr``.
1803 The DMA application pointer can be referred via ``runtime->control``,
1811 ``runtime->private_data``. Usually, this is done in the `PCM open
1812 callback`_. Don't mix this with ``pcm->private_data``. The
1813 ``pcm->private_data`` usually points to the chip instance assigned
1814 statically at the creation of PCM, while the ``runtime->private_data``
1825 substream->runtime->private_data = data;
1833 ---------
1837 error number such as ``-EINVAL``. To choose an appropriate error
1853 The macro reads ``substream->private_data``, which is a copy of
1854 ``pcm->private_data``. You can override the former if you need to
1857 capture directions, because it uses two different codecs (SB- and
1858 AD-compatible) for different directions.
1869 At least, here you have to initialize the ``runtime->hw``
1877 struct snd_pcm_runtime *runtime = substream->runtime;
1879 runtime->hw = snd_mychip_playback_hw;
1883 where ``snd_mychip_playback_hw`` is the pre-defined hardware
1910 kfree(substream->runtime->private_data);
1951 DMA buffers have been pre-allocated. See the section `Buffer Types`_
1963 Another note is that this callback is non-atomic (schedulable) as
1965 because the ``trigger`` callback is atomic (non-schedulable). That is,
1966 mutexes or any schedule-related functions are not available in
1988 pre-allocated pool, you can use the standard API function
2008 Note that this callback is now non-atomic. You can use
2009 schedule-related functions safely in this callback.
2012 the runtime record, ``substream->runtime``. For example, to get the
2013 current rate, format or channels, access to ``runtime->rate``,
2014 ``runtime->format`` or ``runtime->channels``, respectively. The
2016 ``runtime->dma_area``. The buffer and period sizes are in
2017 ``runtime->buffer_size`` and ``runtime->period_size``, respectively.
2045 return -EINVAL;
2056 power-management status is changed. Obviously, the ``SUSPEND`` and
2086 ``card->sync_irq`` field to store the valid interrupt number after
2091 to clear ``card->sync_irq``, as the card itself is being released.
2093 ``card->sync_irq`` in the driver code unless the driver re-acquires
2094 the IRQ. When the driver frees and re-acquires the IRQ dynamically
2095 (e.g. for suspend/resume), it needs to clear and re-set
2096 ``card->sync_irq`` again appropriately.
2107 frames, ranging from 0 to ``buffer_size - 1``.
2109 This is called usually from the buffer-update routine in the pcm
2125 buffer is non-contiguous on both physical and virtual memory spaces,
2128 If these two callbacks are defined, copy and set-silence operations
2137 emu10k1-fx and cs46xx need to track the current ``appl_ptr`` for the
2149 the standard SG-buffer or vmalloc-buffer. Hence this callback should
2157 memory-mapped instead of dealing via the standard helper.
2159 device-specific issues), implement everything here as you like.
2163 ---------------------
2200 spin_lock(&chip->lock);
2204 spin_unlock(&chip->lock);
2205 snd_pcm_period_elapsed(chip->substream);
2206 spin_lock(&chip->lock);
2210 spin_unlock(&chip->lock);
2234 spin_lock(&chip->lock);
2243 if (last_ptr < chip->last_ptr)
2244 size = runtime->buffer_size + last_ptr
2245 - chip->last_ptr;
2247 size = last_ptr - chip->last_ptr;
2249 chip->last_ptr = last_ptr;
2251 chip->size += size;
2253 if (chip->size >= runtime->period_size) {
2255 chip->size %= runtime->period_size;
2257 spin_unlock(&chip->lock);
2259 spin_lock(&chip->lock);
2264 spin_unlock(&chip->lock);
2279 ---------
2283 usually avoided via spin-locks, mutexes or semaphores. In general, if a
2291 example, the ``hw_params`` callback is non-atomic, while ``trigger``
2306 to be non-atomic. This assumes that the all caller sides are in
2307 non-atomic contexts. For example, the function
2310 interrupt handler, this call can be in non-atomic context, too. In such
2314 functions safely in a non-atomic
2318 -----------
2341 err = snd_pcm_hw_constraint_list(substream->runtime, 0,
2369 if (f->bits[0] == SNDRV_PCM_FMTBIT_S16_LE) {
2382 snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS,
2384 SNDRV_PCM_HW_PARAM_FORMAT, -1);
2402 if (c->min < 2) {
2414 snd_pcm_hw_rule_add(substream->runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT,
2416 SNDRV_PCM_HW_PARAM_CHANNELS, -1);
2431 snd_pcm_hw_constraint_integer(substream->runtime,
2446 -------
2449 which are accessed from user-space. Its most important use is the mixer
2453 ALSA has a well-defined AC97 control module. If your chip supports only
2460 ----------------------
2491 its name. There are pre-defined standard control names. The details
2518 -------------
2525 pre-defined sources.
2527 The second, ``DIRECTION``, is one of the following strings according to
2532 The third, ``FUNCTION``, is one of the following strings according to
2548 Tone-controls
2551 tone-control switch and volumes are specified like “Tone Control - XXX”,
2552 e.g. “Tone Control - Switch”, “Tone Control - Bass”, “Tone Control -
2558 3D-control switches and volumes are specified like “3D Control - XXX”,
2559 e.g. “3D Control - Switch”, “3D Control - Center”, “3D Control - Space”.
2564 Mic-boost switch is set as “Mic Boost” or “Mic Boost (6dB)”.
2567 ``Documentation/sound/designs/control-names.rst``.
2570 ------------
2578 When the control is read-only, pass ``SNDRV_CTL_ELEM_ACCESS_READ``
2580 Similarly, when the control is write-only (although it's a rare case),
2593 -----------------
2609 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
2610 uinfo->count = 1;
2611 uinfo->value.integer.min = 0;
2612 uinfo->value.integer.max = 1;
2636 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2637 uinfo->count = 1;
2638 uinfo->value.enumerated.items = 4;
2639 if (uinfo->value.enumerated.item > 3)
2640 uinfo->value.enumerated.item = 3;
2641 strcpy(uinfo->value.enumerated.name,
2642 texts[uinfo->value.enumerated.item]);
2674 return to user-space.
2685 ucontrol->value.integer.value[0] = get_some_value(chip);
2693 register offset, the bit-shift and the bit-mask. The ``private_value``
2707 int reg = kcontrol->private_value & 0xff;
2708 int shift = (kcontrol->private_value >> 16) & 0xff;
2709 int mask = (kcontrol->private_value >> 24) & 0xff;
2721 This callback is used to write a value from user-space.
2733 if (chip->current_value !=
2734 ucontrol->value.integer.value[0]) {
2736 ucontrol->value.integer.value[0]);
2757 -------------------
2772 and chip is the object pointer to be passed to kcontrol->private_data which
2780 -------------------
2789 This function takes the card pointer, the event-mask, and the control id
2790 pointer for the notification. The event-mask specifies the types of
2797 --------
2807 static DECLARE_TLV_DB_SCALE(db_scale_my_control, -4050, 150, 0);
2838 -------
2840 The ALSA AC97 codec layer is a well-defined one, and you don't have to
2841 write much code to control it. Only low-level control routines are
2845 -----------------
2858 struct mychip *chip = ac97->private_data;
2867 struct mychip *chip = ac97->private_data;
2882 err = snd_ac97_bus(chip->card, 0, &ops, NULL, &bus);
2887 return snd_ac97_mixer(bus, &ac97, &chip->ac97);
2892 ----------------
2919 snd_ac97_mixer(bus, &ac97, &chip->ac97);
2921 where chip->ac97 is a pointer to a newly created ``ac97_t``
2930 --------------
2934 hardware low-level codes.
2944 struct mychip *chip = ac97->private_data;
2949 Here, the chip can be cast from ``ac97->private_data``.
2960 These callbacks are non-atomic like the control API callbacks.
2975 --------------------------------
3024 ----------------
3027 (to save a quartz!). In this case, change the field ``bus->clock`` to
3032 ----------
3035 ``/proc/asound/card0/codec97#0/ac97#0-0`` and ``ac97#0-0+regs``. You
3040 ---------------
3043 :c:func:`snd_ac97_mixer()` multiple times with ``ac97.num=1`` or
3044 greater. The ``num`` field specifies the codec number.
3047 callbacks for each codec or check ``ac97->num`` in the callback
3050 MIDI (MPU401-UART) Interface
3054 -------
3056 Many soundcards have built-in MIDI (MPU401-UART) interfaces. When the
3057 soundcard supports the standard MPU401-UART interface, most likely you
3058 can use the ALSA MPU401-UART API. The MPU401-UART API is defined in
3065 ----------------
3082 The 4th argument is the I/O port address. Many backward-compatible
3090 mpu401-uart layer will allocate the I/O ports by itself.
3105 If the MPU-401 interface shares its interrupt with the other logical
3107 `below <#MIDI-Interrupt-Handler>`__).
3114 need to cast ``rmidi->private_data`` to struct snd_mpu401 explicitly,
3119 mpu = rmidi->private_data;
3125 mpu->cport = my_own_control_port;
3130 -1 instead. For a MPU-401 device without an interrupt, a polling timer
3134 ----------------------
3151 snd_mpu401_uart_interrupt(irq, rmidi->private_data, regs);
3158 --------
3170 -------------------
3178 err = snd_rawmidi_new(chip->card, "MyMIDI", 0, outs, ins, &rmidi);
3181 rmidi->private_data = chip;
3182 strcpy(rmidi->name, "My MIDI");
3183 rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT |
3231 &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT].substreams,
3233 sprintf(substream->name, "My MIDI Port %d", substream->number + 1);
3238 -----------------
3241 device can be accessed as ``substream->rmidi->private_data``.
3250 int index = substream->number;
3378 -------
3384 FM registers can be directly accessed through the direct-FM API, defined
3386 accessed through the Hardware-Dependent Device direct-FM extension API,
3388 OSS direct-FM compatible API in ``/dev/dmfmX`` device.
3406 driver, pass non-zero to the fifth argument (``integrated``). Otherwise,
3422 ``opl3->private_data`` field.
3440 The third argument is the index-offset for the sequencer client assigned
3441 to the OPL3 port. When there is an MPU401-UART, give 1 for here (UART
3444 Hardware-Dependent Devices
3445 --------------------------
3447 Some chips need user-space access for special controls or for loading
3449 (hardware-dependent) device. The hwdep API is defined in
3470 hw->private_data = p;
3471 hw->private_free = mydata_free;
3479 struct mydata *p = hw->private_data;
3489 hw->ops.open = mydata_open;
3490 hw->ops.ioctl = mydata_ioctl;
3491 hw->ops.release = mydata_release;
3496 ---------------
3509 “IEC958 Playback Con Mask” is used to return the bit-mask for the IEC958
3511 returns the bitmask for professional mode. They are read-only controls.
3533 ------------
3537 allocation of physically-contiguous pages is done via
3551 is called “pre-allocation”. As already written, you can call the
3558 &pci->dev, size, max);
3560 where ``size`` is the byte size to be pre-allocated and the ``max`` is
3567 (typically identical as ``card->dev``) to the third argument with
3569 bus can be pre-allocated with ``SNDRV_DMA_TYPE_CONTINUOUS`` type.
3575 For the scatter-gather buffers, use ``SNDRV_DMA_TYPE_DEV_SG`` with the
3576 device pointer (see the `Non-Contiguous Buffers`_ section).
3578 Once the buffer is pre-allocated, you can use the allocator in the
3585 Note that you have to pre-allocate to use this function.
3595 &pci->dev, size, max);
3607 -------------------------
3627 Another case is when the chip uses a PCI memory-map region for the
3629 on certain architectures like the Intel one. In non-mmap mode, the data
3637 interleaved or non-interleaved samples. The ``copy_user`` callback is
3663 offset (``pos``) on the hardware buffer. When coded like memcpy-like
3679 it's the user-space buffer that is passed to these callbacks. That
3680 is, the callback is supposed to copy from/to the user-space data
3686 easier to unify both the interleaved and non-interleaved cases, as
3689 In the case of non-interleaved samples, the implementation will be a bit
3691 the second argument, so totally it's called for N-channels times per
3696 user-space buffer, but only for the given channel. For the detailed
3700 The above callbacks are the copy from/to the user-space buffer. There
3701 are some cases where we want copy from/to the kernel-space buffer
3715 without ``__user`` prefix; that is, a kernel-buffer pointer is passed
3717 a version without the user-copy, such as:
3740 silent-data is 0), and the implementation using a memset-like function
3747 In the case of non-interleaved samples, again, the implementation
3748 becomes a bit more complicated, as it's called N-times per transfer
3751 Non-Contiguous Buffers
3752 ----------------------
3755 descriptors as in via82xx, you can use the scatter-gather (SG) DMA. ALSA
3756 provides an interface for handling SG-buffers. The API is provided in
3759 For creating the SG-buffer handler, call
3763 pre-allocator. You need to pass ``&pci->dev``, where pci is
3770 &pci->dev, size, max);
3773 ``substream->dma_private`` in turn. You can cast the pointer like:
3777 struct snd_sg_buf *sgbuf = (struct snd_sg_buf *)substream->dma_private;
3779 Then in :c:func:`snd_pcm_lib_malloc_pages()` call, the common SG-buffer
3780 handler will allocate the non-contiguous kernel pages of the given size
3782 is addressed in runtime->dma_area. The physical address
3783 (``runtime->dma_addr``) is set to zero, because the buffer is
3784 physically non-contiguous. The physical address table is set up in
3785 ``sgbuf->table``. You can get the physical address at a certain offset
3788 If you need to release the SG-buffer data explicitly, call the
3792 ------------------
3811 we don't need to pre-allocate the buffers like other continuous
3836 int err = snd_card_proc_new(card, "my-file", &entry);
3839 created. The above example will create a file ``my-file`` under the
3840 card directory, e.g. ``/proc/asound/card0/my-file``.
3848 proc file for read only. To use this proc file as a read-only text file
3867 strings, which works just like normal :c:func:`printf()`. For
3875 struct my_chip *chip = entry->private_data;
3878 snd_iprintf(buffer, "Port = %ld\n", chip->port);
3887 entry->mode = S_IFREG | S_IRUGO | S_IWUSR;
3893 entry->c.text.write = my_proc_write;
3900 For a raw-data proc-file, set the attributes as follows:
3908 entry->content = SNDRV_INFO_CONTENT_DATA;
3909 entry->private_data = chip;
3910 entry->c.ops = &my_file_io_ops;
3911 entry->size = 4096;
3912 entry->mode = S_IFREG | S_IRUGO;
3918 You need to use a low-level I/O functions such as
3931 return -EFAULT;
3944 to add power-management code to the driver. The additional code for
3945 power-management should be ifdef-ed with ``CONFIG_PM``, or annotated
3971 In the earlier version of ALSA drivers, a common power-management layer
4011 struct mychip *chip = card->private_data;
4015 snd_ac97_suspend(chip->ac97);
4028 2. Re-initialize the chip.
4047 struct mychip *chip = card->private_data;
4053 snd_ac97_resume(chip->ac97);
4080 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
4085 card->private_data = chip;
4102 err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
4105 chip = card->private_data;
4179 -------
4186 module name would be snd-xyz. The new driver is usually put into the
4187 alsa-driver tree, ``sound/pci`` directory in the case of PCI
4195 --------------------------------
4203 snd-xyz-objs := xyz.o
4204 obj-$(CONFIG_SND_XYZ) += snd-xyz.o
4211 as a module, choose M here: the module will be called snd-xyz. the
4227 ---------------------------------
4229 Suppose that the driver snd-xyz have several source files. They are
4237 obj-$(CONFIG_SND) += sound/pci/xyz/
4244 snd-xyz-objs := xyz.o abc.o def.o
4245 obj-$(CONFIG_SND_XYZ) += snd-xyz.o
4256 ----------------------------------
4281 -------------------
4290 ----------------------
4295 return -EINVAL;
4298 ``CONFIG_SND_DEBUG``, is set, if the expression is non-zero, it shows
4308 Kevin Conder reformatted the original plain-text to the DocBook format.