Update of /cvsroot/alsa/alsa-kernel/Documentation/DocBook In directory sc8-pr-cvs1:/tmp/cvs-serv6515
Modified Files: writing-an-alsa-driver.tmpl Log Message: - fixed for the new ac97_bus struct. Index: writing-an-alsa-driver.tmpl =================================================================== RCS file: /cvsroot/alsa/alsa-kernel/Documentation/DocBook/writing-an-alsa-driver.tmpl,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- writing-an-alsa-driver.tmpl 20 Nov 2003 13:22:19 -0000 1.16 +++ writing-an-alsa-driver.tmpl 26 Nov 2003 13:57:05 -0000 1.17 @@ -3978,13 +3978,18 @@ static int snd_mychip_ac97(mychip_t *chip) { + ac97_bus_t bus, *pbus; ac97_t ac97; + int err; + memset(&bus, 0, sizeof(bus)); + bus.write = snd_mychip_ac97_write; + bus.read = snd_mychip_ac97_read; + if ((err = snd_ac97_bus(chip->card, &bus, &pbus)) < 0) + return err; memset(&ac97, 0, sizeof(ac97)); - ac97.write = snd_mychip_ac97_write; - ac97.read = snd_mychip_ac97_read; ac97.private_data = chip; - return snd_ac97_mixer(card, &ac97, &chip->ac97); + return snd_ac97_mixer(pbus, &ac97, &chip->ac97); } ]]> @@ -3996,9 +4001,29 @@ <section id="api-ac97-constructor"> <title>Constructor</title> <para> - For creating an ac97 instance, call - <function>snd_ac97_mixer()</function> with an <type>ac97_t</type> - record, in which the callbacks and the private_data is set. + For creating an ac97 instance, first call <function>snd_ac97_bus</function> + with <type>ac97_bus_t</type> record including callback functions. + + <informalexample> + <programlisting> +<![CDATA[ + ac97_bus_t bus, *pbus; + int err; + + memset(&bus, 0, sizeof(bus)); + bus.write = snd_mychip_ac97_write; + bus.read = snd_mychip_ac97_read; + snd_ac97_bus(card, &bus, &pbus); +]]> + </programlisting> + </informalexample> + + The bus record is shared among all belonging ac97 instances. + </para> + + <para> + And then call <function>snd_ac97_mixer()</function> with an <type>ac97_t</type> + record together with the bus pointer created above. <informalexample> <programlisting> @@ -4007,16 +4032,16 @@ int err; memset(&ac97, 0, sizeof(ac97)); - ac97.write = snd_mychip_ac97_write; - ac97.read = snd_mychip_ac97_read; ac97.private_data = chip; - snd_ac97_mixer(card, &ac97, &chip->ac97); + snd_ac97_mixer(bus, &ac97, &chip->ac97); ]]> </programlisting> </informalexample> where chip->ac97 is the pointer of a newly created <type>ac97_t</type> instance. + In this case, the chip pointer is set as the private data, so that + the read/write callback functions can refer to this chip instance. This instance is not necessarily stored in the chip record. When you need to change the register values from the driver, or need the suspend/resume of ac97 codecs, keep this ------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it help you create better code? SHARE THE LOVE, and help us help YOU! Click Here: http://sourceforge.net/donate/ _______________________________________________ Alsa-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/alsa-cvslog