ubuntu 在 R40e 上 還有 Debian 在 Sempron 2600 上

2015年9月18日 星期五

typedef int snd_pcm_hw_param_t;
#define SNDRV_PCM_HW_PARAM_ACCESS       0       /* Access type */
#define SNDRV_PCM_HW_PARAM_FORMAT       1       /* Format */
#define SNDRV_PCM_HW_PARAM_SUBFORMAT    2       /* Subformat */
#define SNDRV_PCM_HW_PARAM_FIRST_MASK   SNDRV_PCM_HW_PARAM_ACCESS
#define SNDRV_PCM_HW_PARAM_LAST_MASK    SNDRV_PCM_HW_PARAM_SUBFORMAT

#define SNDRV_PCM_HW_PARAM_SAMPLE_BITS  8       /* Bits per sample */
#define SNDRV_PCM_HW_PARAM_FRAME_BITS   9       /* Bits per frame */
#define SNDRV_PCM_HW_PARAM_CHANNELS     10      /* Channels */
#define SNDRV_PCM_HW_PARAM_RATE         11      /* Approx rate */
#define SNDRV_PCM_HW_PARAM_PERIOD_TIME  12      /* Approx distance between
                                                 * interrupts in us
                                                 */
#define SNDRV_PCM_HW_PARAM_PERIOD_SIZE  13      /* Approx frames between
                                                 * interrupts
                                                 */
#define SNDRV_PCM_HW_PARAM_PERIOD_BYTES 14      /* Approx bytes between
                                                 * interrupts
                                                 */
#define SNDRV_PCM_HW_PARAM_PERIODS      15      /* Approx interrupts per
                                                 * buffer
                                                 */
#define SNDRV_PCM_HW_PARAM_BUFFER_TIME  16      /* Approx duration of buffer
                                                 * in us
                                                 */
#define SNDRV_PCM_HW_PARAM_BUFFER_SIZE  17      /* Size of buffer in frames */
#define SNDRV_PCM_HW_PARAM_BUFFER_BYTES 18      /* Size of buffer in bytes */
#define SNDRV_PCM_HW_PARAM_TICK_TIME    19      /* Approx tick duration in us */

把有範圍的歸在一起,再用:
#define SNDRV_PCM_HW_PARAM_FIRST_INTERVAL       SNDRV_PCM_HW_PARAM_SAMPLE_BITS
#define SNDRV_PCM_HW_PARAM_LAST_INTERVAL        SNDRV_PCM_HW_PARAM_TICK_TIME
然後就可以用這個function :
static inline int param_is_interval(int p)
{
    return (p >= SNDRV_PCM_HW_PARAM_FIRST_INTERVAL) &&
        (p <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL);
}
決定該參數是有範圍的 (upper, lower) 還是就一個值。

然後 structure:
struct snd_pcm_hw_params {
        unsigned int flags;
        struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK -
                               SNDRV_PCM_HW_PARAM_FIRST_MASK + 1];
        struct snd_mask mres[5];        /* reserved masks */
        struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL -
                                        SNDRV_PCM_HW_PARAM_FIRST_INTERVAL + 1];
        struct snd_interval ires[9];    /* reserved intervals */
        unsigned int rmask;             /* W: requested masks */
        unsigned int cmask;             /* R: changed masks */
        unsigned int info;              /* R: Info flags for returned setup */
        unsigned int msbits;            /* R: used most significant bits */
        unsigned int rate_num;          /* R: rate numerator */
        unsigned int rate_den;          /* R: rate denominator */
        snd_pcm_uframes_t fifo_size;    /* R: chip FIFO size in frames */
        unsigned char reserved[64];     /* reserved for future */
};
也可以直接用 array ..
---- 所以適當安排 IOCTL code 還是有幫助的

沒有留言:

標籤

網誌存檔