diff options
Diffstat (limited to 'Documentation/DocBook/writing-an-alsa-driver.tmpl')
-rw-r--r-- | Documentation/DocBook/writing-an-alsa-driver.tmpl | 72 |
1 files changed, 27 insertions, 45 deletions
diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl index 06741e925985..d0056a4e9c53 100644 --- a/Documentation/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl | |||
@@ -468,8 +468,6 @@ | |||
468 | return err; | 468 | return err; |
469 | } | 469 | } |
470 | 470 | ||
471 | snd_card_set_dev(card, &pci->dev); | ||
472 | |||
473 | *rchip = chip; | 471 | *rchip = chip; |
474 | return 0; | 472 | return 0; |
475 | } | 473 | } |
@@ -492,7 +490,8 @@ | |||
492 | } | 490 | } |
493 | 491 | ||
494 | /* (2) */ | 492 | /* (2) */ |
495 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); | 493 | err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, |
494 | 0, &card); | ||
496 | if (err < 0) | 495 | if (err < 0) |
497 | return err; | 496 | return err; |
498 | 497 | ||
@@ -591,7 +590,8 @@ | |||
591 | struct snd_card *card; | 590 | struct snd_card *card; |
592 | int err; | 591 | int err; |
593 | .... | 592 | .... |
594 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); | 593 | err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, |
594 | 0, &card); | ||
595 | ]]> | 595 | ]]> |
596 | </programlisting> | 596 | </programlisting> |
597 | </informalexample> | 597 | </informalexample> |
@@ -809,28 +809,34 @@ | |||
809 | 809 | ||
810 | <para> | 810 | <para> |
811 | As mentioned above, to create a card instance, call | 811 | As mentioned above, to create a card instance, call |
812 | <function>snd_card_create()</function>. | 812 | <function>snd_card_new()</function>. |
813 | 813 | ||
814 | <informalexample> | 814 | <informalexample> |
815 | <programlisting> | 815 | <programlisting> |
816 | <![CDATA[ | 816 | <![CDATA[ |
817 | struct snd_card *card; | 817 | struct snd_card *card; |
818 | int err; | 818 | int err; |
819 | err = snd_card_create(index, id, module, extra_size, &card); | 819 | err = snd_card_new(&pci->dev, index, id, module, extra_size, &card); |
820 | ]]> | 820 | ]]> |
821 | </programlisting> | 821 | </programlisting> |
822 | </informalexample> | 822 | </informalexample> |
823 | </para> | 823 | </para> |
824 | 824 | ||
825 | <para> | 825 | <para> |
826 | The function takes five arguments, the card-index number, the | 826 | The function takes six arguments: the parent device pointer, |
827 | id string, the module pointer (usually | 827 | the card-index number, the id string, the module pointer (usually |
828 | <constant>THIS_MODULE</constant>), | 828 | <constant>THIS_MODULE</constant>), |
829 | the size of extra-data space, and the pointer to return the | 829 | the size of extra-data space, and the pointer to return the |
830 | card instance. The extra_size argument is used to | 830 | card instance. The extra_size argument is used to |
831 | allocate card->private_data for the | 831 | allocate card->private_data for the |
832 | chip-specific data. Note that these data | 832 | chip-specific data. Note that these data |
833 | are allocated by <function>snd_card_create()</function>. | 833 | are allocated by <function>snd_card_new()</function>. |
834 | </para> | ||
835 | |||
836 | <para> | ||
837 | The first argument, the pointer of struct | ||
838 | <structname>device</structname>, specifies the parent device. | ||
839 | For PCI devices, typically &pci-> is passed there. | ||
834 | </para> | 840 | </para> |
835 | </section> | 841 | </section> |
836 | 842 | ||
@@ -916,16 +922,16 @@ | |||
916 | </para> | 922 | </para> |
917 | 923 | ||
918 | <section id="card-management-chip-specific-snd-card-new"> | 924 | <section id="card-management-chip-specific-snd-card-new"> |
919 | <title>1. Allocating via <function>snd_card_create()</function>.</title> | 925 | <title>1. Allocating via <function>snd_card_new()</function>.</title> |
920 | <para> | 926 | <para> |
921 | As mentioned above, you can pass the extra-data-length | 927 | As mentioned above, you can pass the extra-data-length |
922 | to the 4th argument of <function>snd_card_create()</function>, i.e. | 928 | to the 5th argument of <function>snd_card_new()</function>, i.e. |
923 | 929 | ||
924 | <informalexample> | 930 | <informalexample> |
925 | <programlisting> | 931 | <programlisting> |
926 | <![CDATA[ | 932 | <![CDATA[ |
927 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, | 933 | err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, |
928 | sizeof(struct mychip), &card); | 934 | sizeof(struct mychip), &card); |
929 | ]]> | 935 | ]]> |
930 | </programlisting> | 936 | </programlisting> |
931 | </informalexample> | 937 | </informalexample> |
@@ -954,7 +960,7 @@ | |||
954 | 960 | ||
955 | <para> | 961 | <para> |
956 | After allocating a card instance via | 962 | After allocating a card instance via |
957 | <function>snd_card_create()</function> (with | 963 | <function>snd_card_new()</function> (with |
958 | <constant>0</constant> on the 4th arg), call | 964 | <constant>0</constant> on the 4th arg), call |
959 | <function>kzalloc()</function>. | 965 | <function>kzalloc()</function>. |
960 | 966 | ||
@@ -963,7 +969,8 @@ | |||
963 | <![CDATA[ | 969 | <![CDATA[ |
964 | struct snd_card *card; | 970 | struct snd_card *card; |
965 | struct mychip *chip; | 971 | struct mychip *chip; |
966 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); | 972 | err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, |
973 | 0, &card); | ||
967 | ..... | 974 | ..... |
968 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 975 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
969 | ]]> | 976 | ]]> |
@@ -1170,8 +1177,6 @@ | |||
1170 | return err; | 1177 | return err; |
1171 | } | 1178 | } |
1172 | 1179 | ||
1173 | snd_card_set_dev(card, &pci->dev); | ||
1174 | |||
1175 | *rchip = chip; | 1180 | *rchip = chip; |
1176 | return 0; | 1181 | return 0; |
1177 | } | 1182 | } |
@@ -1526,30 +1531,6 @@ | |||
1526 | 1531 | ||
1527 | </section> | 1532 | </section> |
1528 | 1533 | ||
1529 | <section id="pci-resource-device-struct"> | ||
1530 | <title>Registration of Device Struct</title> | ||
1531 | <para> | ||
1532 | At some point, typically after calling <function>snd_device_new()</function>, | ||
1533 | you need to register the struct <structname>device</structname> of the chip | ||
1534 | you're handling for udev and co. ALSA provides a macro for compatibility with | ||
1535 | older kernels. Simply call like the following: | ||
1536 | <informalexample> | ||
1537 | <programlisting> | ||
1538 | <![CDATA[ | ||
1539 | snd_card_set_dev(card, &pci->dev); | ||
1540 | ]]> | ||
1541 | </programlisting> | ||
1542 | </informalexample> | ||
1543 | so that it stores the PCI's device pointer to the card. This will be | ||
1544 | referred by ALSA core functions later when the devices are registered. | ||
1545 | </para> | ||
1546 | <para> | ||
1547 | In the case of non-PCI, pass the proper device struct pointer of the BUS | ||
1548 | instead. (In the case of legacy ISA without PnP, you don't have to do | ||
1549 | anything.) | ||
1550 | </para> | ||
1551 | </section> | ||
1552 | |||
1553 | <section id="pci-resource-entries"> | 1534 | <section id="pci-resource-entries"> |
1554 | <title>PCI Entries</title> | 1535 | <title>PCI Entries</title> |
1555 | <para> | 1536 | <para> |
@@ -5740,7 +5721,8 @@ struct _snd_pcm_runtime { | |||
5740 | struct mychip *chip; | 5721 | struct mychip *chip; |
5741 | int err; | 5722 | int err; |
5742 | .... | 5723 | .... |
5743 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card); | 5724 | err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, |
5725 | 0, &card); | ||
5744 | .... | 5726 | .... |
5745 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 5727 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
5746 | .... | 5728 | .... |
@@ -5752,7 +5734,7 @@ struct _snd_pcm_runtime { | |||
5752 | </informalexample> | 5734 | </informalexample> |
5753 | 5735 | ||
5754 | When you created the chip data with | 5736 | When you created the chip data with |
5755 | <function>snd_card_create()</function>, it's anyway accessible | 5737 | <function>snd_card_new()</function>, it's anyway accessible |
5756 | via <structfield>private_data</structfield> field. | 5738 | via <structfield>private_data</structfield> field. |
5757 | 5739 | ||
5758 | <informalexample> | 5740 | <informalexample> |
@@ -5766,8 +5748,8 @@ struct _snd_pcm_runtime { | |||
5766 | struct mychip *chip; | 5748 | struct mychip *chip; |
5767 | int err; | 5749 | int err; |
5768 | .... | 5750 | .... |
5769 | err = snd_card_create(index[dev], id[dev], THIS_MODULE, | 5751 | err = snd_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, |
5770 | sizeof(struct mychip), &card); | 5752 | sizeof(struct mychip), &card); |
5771 | .... | 5753 | .... |
5772 | chip = card->private_data; | 5754 | chip = card->private_data; |
5773 | .... | 5755 | .... |