Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / sound / isa / sb / emu8000_pcm.c
index db5eb8b..91dc3d8 100644 (file)
  */
 
 
-typedef struct snd_emu8k_pcm emu8k_pcm_t;
-
 struct snd_emu8k_pcm {
-       emu8000_t *emu;
-       snd_pcm_substream_t *substream;
+       struct snd_emu8000 *emu;
+       struct snd_pcm_substream *substream;
 
        unsigned int allocated_bytes;
-       snd_util_memblk_t *block;
+       struct snd_util_memblk *block;
        unsigned int offset;
        unsigned int buf_size;
        unsigned int period_size;
@@ -77,7 +75,7 @@ struct snd_emu8k_pcm {
  * open up channels for the simultaneous data transfer and playback
  */
 static int
-emu8k_open_dram_for_pcm(emu8000_t *emu, int channels)
+emu8k_open_dram_for_pcm(struct snd_emu8000 *emu, int channels)
 {
        int i;
 
@@ -113,12 +111,11 @@ emu8k_open_dram_for_pcm(emu8000_t *emu, int channels)
 /*
  */
 static void
-snd_emu8000_write_wait(emu8000_t *emu, int can_schedule)
+snd_emu8000_write_wait(struct snd_emu8000 *emu, int can_schedule)
 {
        while ((EMU8000_SMALW_READ(emu) & 0x80000000) != 0) {
                if (can_schedule) {
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(1);
+                       schedule_timeout_interruptible(1);
                        if (signal_pending(current))
                                break;
                }
@@ -129,7 +126,7 @@ snd_emu8000_write_wait(emu8000_t *emu, int can_schedule)
  * close all channels
  */
 static void
-emu8k_close_dram(emu8000_t *emu)
+emu8k_close_dram(struct snd_emu8000 *emu)
 {
        int i;
 
@@ -157,7 +154,7 @@ static int calc_rate_offset(int hz)
 /*
  */
 
-static snd_pcm_hardware_t emu8k_pcm_hw = {
+static struct snd_pcm_hardware emu8k_pcm_hw = {
 #ifdef USE_NONINTERLEAVE
        .info =                 SNDRV_PCM_INFO_NONINTERLEAVED,
 #else
@@ -181,7 +178,7 @@ static snd_pcm_hardware_t emu8k_pcm_hw = {
 /*
  * get the current position at the given channel from CCCA register
  */
-static inline int emu8k_get_curpos(emu8k_pcm_t *rec, int ch)
+static inline int emu8k_get_curpos(struct snd_emu8k_pcm *rec, int ch)
 {
        int val = EMU8000_CCCA_READ(rec->emu, ch) & 0xfffffff;
        val -= rec->loop_start[ch] - 1;
@@ -195,7 +192,7 @@ static inline int emu8k_get_curpos(emu8k_pcm_t *rec, int ch)
  */
 static void emu8k_pcm_timer_func(unsigned long data)
 {
-       emu8k_pcm_t *rec = (emu8k_pcm_t *)data;
+       struct snd_emu8k_pcm *rec = (struct snd_emu8k_pcm *)data;
        int ptr, delta;
 
        spin_lock(&rec->timer_lock);
@@ -227,13 +224,13 @@ static void emu8k_pcm_timer_func(unsigned long data)
  * open pcm
  * creating an instance here
  */
-static int emu8k_pcm_open(snd_pcm_substream_t *subs)
+static int emu8k_pcm_open(struct snd_pcm_substream *subs)
 {
-       emu8000_t *emu = snd_pcm_substream_chip(subs);
-       emu8k_pcm_t *rec;
-       snd_pcm_runtime_t *runtime = subs->runtime;
+       struct snd_emu8000 *emu = snd_pcm_substream_chip(subs);
+       struct snd_emu8k_pcm *rec;
+       struct snd_pcm_runtime *runtime = subs->runtime;
 
-       rec = kcalloc(1, sizeof(*rec), GFP_KERNEL);
+       rec = kzalloc(sizeof(*rec), GFP_KERNEL);
        if (! rec)
                return -ENOMEM;
 
@@ -257,9 +254,9 @@ static int emu8k_pcm_open(snd_pcm_substream_t *subs)
        return 0;
 }
 
-static int emu8k_pcm_close(snd_pcm_substream_t *subs)
+static int emu8k_pcm_close(struct snd_pcm_substream *subs)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
        kfree(rec);
        subs->runtime->private_data = NULL;
        return 0;
@@ -282,9 +279,9 @@ static int calc_pitch_target(int pitch)
 /*
  * set up the voice
  */
-static void setup_voice(emu8k_pcm_t *rec, int ch)
+static void setup_voice(struct snd_emu8k_pcm *rec, int ch)
 {
-       emu8000_t *hw = rec->emu;
+       struct snd_emu8000 *hw = rec->emu;
        unsigned int temp;
 
        /* channel to be silent and idle */
@@ -335,10 +332,10 @@ static void setup_voice(emu8k_pcm_t *rec, int ch)
 /*
  * trigger the voice
  */
-static void start_voice(emu8k_pcm_t *rec, int ch)
+static void start_voice(struct snd_emu8k_pcm *rec, int ch)
 {
        unsigned long flags;
-       emu8000_t *hw = rec->emu;
+       struct snd_emu8000 *hw = rec->emu;
        unsigned int temp, aux;
        int pt = calc_pitch_target(rec->pitch);
 
@@ -371,10 +368,10 @@ static void start_voice(emu8k_pcm_t *rec, int ch)
 /*
  * stop the voice immediately
  */
-static void stop_voice(emu8k_pcm_t *rec, int ch)
+static void stop_voice(struct snd_emu8k_pcm *rec, int ch)
 {
        unsigned long flags;
-       emu8000_t *hw = rec->emu;
+       struct snd_emu8000 *hw = rec->emu;
 
        EMU8000_DCYSUSV_WRITE(hw, ch, 0x807F);
 
@@ -387,9 +384,9 @@ static void stop_voice(emu8k_pcm_t *rec, int ch)
        spin_unlock_irqrestore(&rec->timer_lock, flags);
 }
 
-static int emu8k_pcm_trigger(snd_pcm_substream_t *subs, int cmd)
+static int emu8k_pcm_trigger(struct snd_pcm_substream *subs, int cmd)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
        int ch;
 
        switch (cmd) {
@@ -429,7 +426,7 @@ do { \
 
 #ifdef USE_NONINTERLEAVE
 /* copy one channel block */
-static int emu8k_transfer_block(emu8000_t *emu, int offset, unsigned short *buf, int count)
+static int emu8k_transfer_block(struct snd_emu8000 *emu, int offset, unsigned short *buf, int count)
 {
        EMU8000_SMALW_WRITE(emu, offset);
        while (count > 0) {
@@ -443,14 +440,14 @@ static int emu8k_transfer_block(emu8000_t *emu, int offset, unsigned short *buf,
        return 0;
 }
 
-static int emu8k_pcm_copy(snd_pcm_substream_t *subs,
+static int emu8k_pcm_copy(struct snd_pcm_substream *subs,
                          int voice,
                          snd_pcm_uframes_t pos,
                          void *src,
                          snd_pcm_uframes_t count)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
-       emu8000_t *emu = rec->emu;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
+       struct snd_emu8000 *emu = rec->emu;
 
        snd_emu8000_write_wait(emu, 1);
        if (voice == -1) {
@@ -470,7 +467,7 @@ static int emu8k_pcm_copy(snd_pcm_substream_t *subs,
 }
 
 /* make a channel block silence */
-static int emu8k_silence_block(emu8000_t *emu, int offset, int count)
+static int emu8k_silence_block(struct snd_emu8000 *emu, int offset, int count)
 {
        EMU8000_SMALW_WRITE(emu, offset);
        while (count > 0) {
@@ -481,13 +478,13 @@ static int emu8k_silence_block(emu8000_t *emu, int offset, int count)
        return 0;
 }
 
-static int emu8k_pcm_silence(snd_pcm_substream_t *subs,
+static int emu8k_pcm_silence(struct snd_pcm_substream *subs,
                             int voice,
                             snd_pcm_uframes_t pos,
                             snd_pcm_uframes_t count)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
-       emu8000_t *emu = rec->emu;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
+       struct snd_emu8000 *emu = rec->emu;
 
        snd_emu8000_write_wait(emu, 1);
        if (voice == -1 && rec->voices == 1)
@@ -509,14 +506,14 @@ static int emu8k_pcm_silence(snd_pcm_substream_t *subs,
  * copy the interleaved data can be done easily by using
  * DMA "left" and "right" channels on emu8k engine.
  */
-static int emu8k_pcm_copy(snd_pcm_substream_t *subs,
+static int emu8k_pcm_copy(struct snd_pcm_substream *subs,
                          int voice,
                          snd_pcm_uframes_t pos,
                          void __user *src,
                          snd_pcm_uframes_t count)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
-       emu8000_t *emu = rec->emu;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
+       struct snd_emu8000 *emu = rec->emu;
        unsigned short __user *buf = src;
 
        snd_emu8000_write_wait(emu, 1);
@@ -540,13 +537,13 @@ static int emu8k_pcm_copy(snd_pcm_substream_t *subs,
        return 0;
 }
 
-static int emu8k_pcm_silence(snd_pcm_substream_t *subs,
+static int emu8k_pcm_silence(struct snd_pcm_substream *subs,
                             int voice,
                             snd_pcm_uframes_t pos,
                             snd_pcm_uframes_t count)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
-       emu8000_t *emu = rec->emu;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
+       struct snd_emu8000 *emu = rec->emu;
 
        snd_emu8000_write_wait(emu, 1);
        EMU8000_SMALW_WRITE(emu, rec->loop_start[0] + pos);
@@ -568,10 +565,10 @@ static int emu8k_pcm_silence(snd_pcm_substream_t *subs,
 /*
  * allocate a memory block
  */
-static int emu8k_pcm_hw_params(snd_pcm_substream_t *subs,
-                              snd_pcm_hw_params_t *hw_params)
+static int emu8k_pcm_hw_params(struct snd_pcm_substream *subs,
+                              struct snd_pcm_hw_params *hw_params)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
 
        if (rec->block) {
                /* reallocation - release the old block */
@@ -593,9 +590,9 @@ static int emu8k_pcm_hw_params(snd_pcm_substream_t *subs,
 /*
  * free the memory block
  */
-static int emu8k_pcm_hw_free(snd_pcm_substream_t *subs)
+static int emu8k_pcm_hw_free(struct snd_pcm_substream *subs)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
 
        if (rec->block) {
                int ch;
@@ -611,9 +608,9 @@ static int emu8k_pcm_hw_free(snd_pcm_substream_t *subs)
 
 /*
  */
-static int emu8k_pcm_prepare(snd_pcm_substream_t *subs)
+static int emu8k_pcm_prepare(struct snd_pcm_substream *subs)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
 
        rec->pitch = 0xe000 + calc_rate_offset(subs->runtime->rate);
        rec->last_ptr = 0;
@@ -657,16 +654,16 @@ static int emu8k_pcm_prepare(snd_pcm_substream_t *subs)
        return 0;
 }
 
-static snd_pcm_uframes_t emu8k_pcm_pointer(snd_pcm_substream_t *subs)
+static snd_pcm_uframes_t emu8k_pcm_pointer(struct snd_pcm_substream *subs)
 {
-       emu8k_pcm_t *rec = subs->runtime->private_data;
+       struct snd_emu8k_pcm *rec = subs->runtime->private_data;
        if (rec->running)
                return emu8k_get_curpos(rec, 0);
        return 0;
 }
 
 
-static snd_pcm_ops_t emu8k_pcm_ops = {
+static struct snd_pcm_ops emu8k_pcm_ops = {
        .open =         emu8k_pcm_open,
        .close =        emu8k_pcm_close,
        .ioctl =        snd_pcm_lib_ioctl,
@@ -680,15 +677,15 @@ static snd_pcm_ops_t emu8k_pcm_ops = {
 };
 
 
-static void snd_emu8000_pcm_free(snd_pcm_t *pcm)
+static void snd_emu8000_pcm_free(struct snd_pcm *pcm)
 {
-       emu8000_t *emu = pcm->private_data;
+       struct snd_emu8000 *emu = pcm->private_data;
        emu->pcm = NULL;
 }
 
-int snd_emu8000_pcm_new(snd_card_t *card, emu8000_t *emu, int index)
+int snd_emu8000_pcm_new(struct snd_card *card, struct snd_emu8000 *emu, int index)
 {
-       snd_pcm_t *pcm;
+       struct snd_pcm *pcm;
        int err;
 
        if ((err = snd_pcm_new(card, "Emu8000 PCM", index, 1, 0, &pcm)) < 0)