/* When switching from master to slave or the other way around, *youdon'twanttohavethecodecchipactingasclocksource *whilethebusstillis. *Moreimportantly,whileswitchfromslavetomaster,youneed *toturnoffthechip'smasterfunctionfirst,butthenthere's *noclockforawhileandotherchipsmightreset,sowenotify *theirdriversafterhavingswitched. *Theconstantsherearecodec-pointofview,sowhenweswitch *thesoundbustomasterwetellthecodecwe'regoingtoswitch *andgiveitCLOCK_SWITCH_PREPARE_SLAVE!
*/ enum clock_switch {
CLOCK_SWITCH_PREPARE_SLAVE,
CLOCK_SWITCH_PREPARE_MASTER,
CLOCK_SWITCH_SLAVE,
CLOCK_SWITCH_MASTER,
CLOCK_SWITCH_NOTIFY,
};
/* information on a transfer the codec can take */ struct transfer_info {
u64 formats; /* SNDRV_PCM_FMTBIT_* */ unsignedint rates; /* SNDRV_PCM_RATE_* */ /* flags */
u32 transfer_in:1, /* input = 1, output = 0 */
must_be_clock_source:1; /* for codecs to distinguish among their TIs */ int tag;
};
struct codec_info_item { struct codec_info *codec; void *codec_data; struct soundbus_dev *sdev; /* internal, to be used by the soundbus provider */ struct list_head list;
};
/* for prepare, where the codecs need to know
* what we're going to drive the bus with */ struct bus_info { /* see below */ int sysclock_factor; int bus_factor;
};
/* information on the codec itself, plus function pointers */ struct codec_info { /* the module this lives in */ struct module *owner;
/* supported transfer possibilities, array terminated by
* formats or rates being 0. */ struct transfer_info *transfers;
/* Master clock speed factor *tobeused(masterclockspeed=sysclock_factor*samplingfreq) *Unusedifthesoundbusproviderhasnosuchnotion.
*/ int sysclock_factor;
/* Bus factor, bus clock speed = bus_factor * sampling freq) *Unusedifthesoundbusproviderhasnosuchnotion.
*/ int bus_factor;
/* operations */ /* clock switching, see above */ int (*switch_clock)(struct codec_info_item *cii, enum clock_switch clock);
/* called for each transfer_info when the user *opensthepcmdevicetodeterminewhatthe *hardwarecansupportatthispointintime. *Thatcandependonotheruser-switchablecontrols. *Return1ifusable,0ifnot. *outpointstoanotherinstanceofatransfer_info *whichisinitialisedtothevaluesin*ti,and *it'sformatandratevaluescanbemodifiedby *thecallbackifitisnecessarytofurtherrestrict *theformatsthatcanbeusedatthemoment,for *examplewhenonecodechasmultiplelogicalcodec *infostructsformultipleinputs.
*/ int (*usable)(struct codec_info_item *cii, struct transfer_info *ti, struct transfer_info *out);
/* called when pcm stream is opened, probably not implemented
* most of the time since it isn't too useful */ int (*open)(struct codec_info_item *cii, struct snd_pcm_substream *substream);
/* called when the pcm stream is closed, at this point
* the user choices can all be unlocked (see below) */ int (*close)(struct codec_info_item *cii, struct snd_pcm_substream *substream);
/* if the codec must forbid some user choices because *theyarenotvalidwiththesubstream/transferinfo, *itmustdosohere.Example:nodigitaloutputfor *incompatibleframerate,say8KHz,onOnyx. *IftheselectedstuffinthesubstreamisNOT
* compatible, you have to reject this call! */ int (*prepare)(struct codec_info_item *cii, struct bus_info *bi, struct snd_pcm_substream *substream);
/* start() is called before data is pushed to the codec.
* Note that start() must be atomic! */ int (*start)(struct codec_info_item *cii, struct snd_pcm_substream *substream);
/* stop() is called after data is no longer pushed to the codec.
* Note that stop() must be atomic! */ int (*stop)(struct codec_info_item *cii, struct snd_pcm_substream *substream);
int (*suspend)(struct codec_info_item *cii, pm_message_t state); int (*resume)(struct codec_info_item *cii);
};
/* information on a soundbus device */ struct soundbus_dev { /* the bus it belongs to */ struct list_head onbuslist;
/* the of device it represents */ struct platform_device ofdev;
/* what modules go by */ char modalias[32];
/* These fields must be before attach_codec can be called. *Theyshouldbesetbytheownerofthealsacardobject *thatisneeded,andwhoeversetsthemmustmakesure
* that they are unique within that alsa card object. */ char *pcmname; int pcmid;
/* this is assigned by the soundbus provider in attach_codec */ struct snd_pcm *pcm;
/* operations */ /* attach a codec to this soundbus, give the alsa *cardobjectthePCMsforthissoundbusshouldbein. *The'data'pointermustbeunique,itisusedasthe
* key for detach_codec(). */ int (*attach_codec)(struct soundbus_dev *dev, struct snd_card *card, struct codec_info *ci, void *data); void (*detach_codec)(struct soundbus_dev *dev, void *data); /* TODO: suspend/resume */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.