[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.54 and 1.54.2.6

version 1.54, 2004/10/29 12:57:16 version 1.54.2.6, 2004/12/26 17:38:25
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>
   
 /* 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 49 
 #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/sample */
         int     factor;                         /* coding space change */          u_int   channels;       /* mono(1), stereo(2) */
         int     factor_denom;                   /* denominator of factor */  } 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 */
           audio_params_t param;   /* represents this stream */
           boolean_t loop;
   } audio_stream_t;
   
   static __inline int
   audio_stream_get_space(const audio_stream_t *p)
   {
           uint8_t *i;
           const uint8_t *o;
   
           i = p->inp;
           o = p->outp;
           return i <= o ? o - i : p->end - i + o - p->start;
   }
   
   static __inline int
   audio_stream_get_used(const audio_stream_t *p)
   {
           uint8_t *i;
           const uint8_t *o;
   
           i = p->inp;
           o = p->outp;
           return o <= i ? i - o : p->end - o + i - p->start;
   }
   
   /**
    * an interface to fill a audio stream buffer
    */
   typedef struct stream_fetcher {
           int (*fetch_to)(struct stream_fetcher *, audio_stream_t *, int, int *);
   } stream_fetcher_t;
   
   /**
    * audio stream filter.
    * This must be an extension of stream_fetcher_t.
    */
   typedef struct stream_filter {
           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 *);
   } 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.  The audio_params_t instance for the
    * hardware is filters[0].param for recording and filters[req_size -1].param
    * for playing.
    */
   #ifndef AUDIO_MAX_FILTERS
   # define AUDIO_MAX_FILTERS      8
   #endif
   typedef struct stream_filter_list {
           int req_size;
           struct stream_filter_req {
                   stream_filter_factory_t *factory;
                   audio_params_t param; /* output-param for recording,
                                            input-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 153  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 161  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);
Line 114  struct audio_hw_if {
Line 181  struct audio_hw_if {
         /* Start input/output routines. These usually control DMA. */          /* Start input/output routines. These usually control DMA. */
         int     (*init_output)(void *, void *, int);          int     (*init_output)(void *, void *, int);
         int     (*init_input)(void *, void *, int);          int     (*init_input)(void *, void *, int);
         int     (*start_output)(void *, void *, int,          int     (*start_output)(void *, const void *, int,
                                     void (*)(void *), void *);                                      void (*)(void *), void *);
         int     (*start_input)(void *, void *, int,          int     (*start_input)(void *, void *, int,
                                    void (*)(void *), void *);                                     void (*)(void *), void *);
Line 142  struct audio_hw_if {
Line 209  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 *, const void *, void *, int,
                     void (*)(void *), void *, struct audio_params *);                      void (*)(void *), void *, 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 *, audio_params_t *);
         int     (*dev_ioctl)(void *, u_long, caddr_t, int, struct proc *);          int     (*dev_ioctl)(void *, u_long, caddr_t, int, struct proc *);
 };  };
   

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.54.2.6

CVSweb <webmaster@jp.NetBSD.org>