[BACK]Return to audio_if.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / dev

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/dev/Attic/audio_if.h between version 1.53 and 1.53.2.5

version 1.53, 2003/06/29 22:29:57 version 1.53.2.5, 2005/01/17 19:30:39
Line 36 
Line 36 
   
 #ifndef _SYS_DEV_AUDIO_IF_H_  #ifndef _SYS_DEV_AUDIO_IF_H_
 #define _SYS_DEV_AUDIO_IF_H_  #define _SYS_DEV_AUDIO_IF_H_
   #include <sys/types.h>
   #include <sys/audioio.h>
   
 /* check we have an audio(4) configured into kernel */  /* check we have an audio(4) configured into kernel */
 #if defined(_KERNEL_OPT)  #if defined(_KERNEL_OPT)
Line 48 
Line 50 
 #endif /* _KERNEL_OPT */  #endif /* _KERNEL_OPT */
   
 /*  /*
  * Generic interface to hardware driver.   * Interfaces for hardware drivers and MI audio.
  */   */
   
 struct audio_softc;  struct audio_softc;
   
 struct audio_params {  /**
         u_long  sample_rate;                    /* sample rate */   * audio stream format
         u_int   encoding;                       /* e.g. mu-law, linear, etc */   */
         u_int   precision;                      /* bits/sample */  typedef struct audio_params {
         u_int   channels;                       /* mono(1), stereo(2) */          u_int   sample_rate;    /* sample rate */
         /* Software en/decode functions, set if SW coding required by HW */          u_int   encoding;       /* e.g. mu-law, linear, etc */
         void    (*sw_code)(void *, u_char *, int);          u_int   precision;      /* bits/subframe */
         int     factor;                         /* coding space change */          u_int   validbits;      /* valid bits in a subframe */
         int     factor_denom;                   /* denominator of factor */          u_int   channels;       /* mono(1), stereo(2) */
         /*  } audio_params_t;
          * The following four members represent what format is used in a  
          * hardware.  If hw_sample_rate != sample_rate || hw_channels !=  
          * channels, the audio framework converts data.  Encoding and  
          * precision are converted in sw_code().  
          * set_params() should set correct values to them if no conversion is  
          * needed.  
          */  
         u_long  hw_sample_rate;  
         u_int   hw_encoding;  
         u_int   hw_precision;  
         u_int   hw_channels;  
 };  
   
 /* The default audio mode: 8 kHz mono mu-law */  /* The default audio mode: 8 kHz mono mu-law */
 extern const struct audio_params audio_default;  extern const struct audio_params audio_default;
   
   /**
    * audio stream buffer
    */
   typedef struct audio_stream {
           size_t bufsize;         /* allocated memory */
           uint8_t *start;         /* start of buffer area */
           uint8_t *end;           /* end of valid buffer area */
           uint8_t *inp;           /* address to be written next */
           const uint8_t *outp;    /* address to be read next */
           int used;               /* valid data size in this stream */
           audio_params_t param;   /* represents this stream */
           boolean_t loop;
   } audio_stream_t;
   
   static __inline int
   audio_stream_get_space(const audio_stream_t *s)
   {
           return (s->end - s->start) - s->used;
   }
   
   static __inline int
   audio_stream_get_used(const audio_stream_t *s)
   {
           return s->used;
   }
   
   static __inline uint8_t *
   audio_stream_add_inp(audio_stream_t *s, uint8_t *v, int diff)
   {
           s->used += diff;
           v += diff;
           if (v >= s->end)
                   v -= s->end - s->start;
           return v;
   }
   
   static __inline const uint8_t *
   audio_stream_add_outp(audio_stream_t *s, const uint8_t *v, int diff)
   {
           s->used -= diff;
           v += diff;
           if (v >= s->end)
                   v -= s->end - s->start;
           return v;
   }
   
   /**
    * an interface to fill a audio stream buffer
    */
   typedef struct stream_fetcher {
           int (*fetch_to)(struct stream_fetcher *, audio_stream_t *, int);
   } stream_fetcher_t;
   
   /**
    * audio stream filter.
    * This must be an extension of stream_fetcher_t.
    */
   typedef struct stream_filter {
   /* public: */
           stream_fetcher_t base;
           void (*dtor)(struct stream_filter *);
           void (*set_fetcher)(struct stream_filter *, stream_fetcher_t *);
           void (*set_inputbuffer)(struct stream_filter *, audio_stream_t *);
   /* private: */
           stream_fetcher_t *prev;
           audio_stream_t *src;
   } stream_filter_t;
   
   /**
    * factory method for stream_filter_t
    */
   typedef stream_filter_t *stream_filter_factory_t(struct audio_softc *,
           const audio_params_t *, const audio_params_t *);
   
   /**
    * filter pipeline request
    *
    * filters[0] is the first filter for playing or the last filter for recording.
    * The audio_params_t instance for the hardware is filters[0].param.
    */
   #ifndef AUDIO_MAX_FILTERS
   # define AUDIO_MAX_FILTERS      8
   #endif
   typedef struct stream_filter_list {
           void (*append)(struct stream_filter_list *, stream_filter_factory_t,
                          const audio_params_t *);
           void (*prepend)(struct stream_filter_list *, stream_filter_factory_t,
                           const audio_params_t *);
           void (*set)(struct stream_filter_list *, int, stream_filter_factory_t,
                       const audio_params_t *);
           int req_size;
           struct stream_filter_req {
                   stream_filter_factory_t *factory;
                   audio_params_t param; /* from-param for recording,
                                            to-param for playing */
           } filters[AUDIO_MAX_FILTERS];
   } stream_filter_list_t;
   
 struct malloc_type;  struct malloc_type;
 struct audio_hw_if {  struct audio_hw_if {
         int     (*open)(void *, int);   /* open hardware */          int     (*open)(void *, int);   /* open hardware */
Line 87  struct audio_hw_if {
Line 175  struct audio_hw_if {
   
         /* Encoding. */          /* Encoding. */
         /* XXX should we have separate in/out? */          /* XXX should we have separate in/out? */
         int     (*query_encoding)(void *, struct audio_encoding *);          int     (*query_encoding)(void *, audio_encoding_t *);
   
         /* Set the audio encoding parameters (record and play).          /* Set the audio encoding parameters (record and play).
          * Return 0 on success, or an error code if the           * Return 0 on success, or an error code if the
Line 95  struct audio_hw_if {
Line 183  struct audio_hw_if {
          * The values in the params struct may be changed (e.g. rounding           * The values in the params struct may be changed (e.g. rounding
          * to the nearest sample rate.)           * to the nearest sample rate.)
          */           */
         int     (*set_params)(void *, int, int, struct audio_params *,          int     (*set_params)(void *, int, int, audio_params_t *,
                     struct audio_params *);                      audio_params_t *, stream_filter_list_t *,
                       stream_filter_list_t *);
   
         /* Hardware may have some say in the blocksize to choose */          /* Hardware may have some say in the blocksize to choose */
         int     (*round_blocksize)(void *, int);          int     (*round_blocksize)(void *, int, int, const audio_params_t *);
   
         /*          /*
          * Changing settings may require taking device out of "data mode",           * Changing settings may require taking device out of "data mode",
Line 143  struct audio_hw_if {
Line 232  struct audio_hw_if {
         int     (*get_props)(void *); /* device properties */          int     (*get_props)(void *); /* device properties */
   
         int     (*trigger_output)(void *, void *, void *, int,          int     (*trigger_output)(void *, void *, void *, int,
                     void (*)(void *), void *, struct audio_params *);                      void (*)(void *), void *, const audio_params_t *);
         int     (*trigger_input)(void *, void *, void *, int,          int     (*trigger_input)(void *, void *, void *, int,
                     void (*)(void *), void *, struct audio_params *);                      void (*)(void *), void *, const audio_params_t *);
         int     (*dev_ioctl)(void *, u_long, caddr_t, int, struct proc *);          int     (*dev_ioctl)(void *, u_long, caddr_t, int, struct lwp *);
 };  };
   
 struct audio_attach_args {  struct audio_attach_args {
         int     type;          int     type;
         void    *hwif;          /* either audio_hw_if * or midi_hw_if * */          const void *hwif;       /* either audio_hw_if * or midi_hw_if * */
         void    *hdl;          void    *hdl;
 };  };
 #define AUDIODEV_TYPE_AUDIO     0  #define AUDIODEV_TYPE_AUDIO     0
Line 161  struct audio_attach_args {
Line 250  struct audio_attach_args {
 #define AUDIODEV_TYPE_AUX       4  #define AUDIODEV_TYPE_AUX       4
   
 /* Attach the MI driver(s) to the MD driver. */  /* Attach the MI driver(s) to the MD driver. */
 struct device *audio_attach_mi(struct audio_hw_if *, void *, struct device *);  struct device *audio_attach_mi(const struct audio_hw_if *, void *,
       struct device *);
 int     audioprint(void *, const char *);  int     audioprint(void *, const char *);
   
 /* Device identity flags */  /* Device identity flags */

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.53.2.5

CVSweb <webmaster@jp.NetBSD.org>