/[openvortex]/alsa/alsa-kernel/ppc/tumbler.c
ViewVC logotype

Diff of /alsa/alsa-kernel/ppc/tumbler.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by vizard, Sat May 31 02:35:12 2003 UTC revision 1.3 by vizard, Mon Aug 11 00:06:40 2003 UTC
# Line 79  typedef struct pmac_gpio { Line 79  typedef struct pmac_gpio {
79          int active_state;          int active_state;
80  } pmac_gpio_t;  } pmac_gpio_t;
81    
82  typedef struct pmac_tumber_t {  typedef struct pmac_tumbler_t {
83          pmac_keywest_t i2c;          pmac_keywest_t i2c;
84          pmac_gpio_t audio_reset;          pmac_gpio_t audio_reset;
85          pmac_gpio_t amp_mute;          pmac_gpio_t amp_mute;
# Line 95  typedef struct pmac_tumber_t { Line 95  typedef struct pmac_tumber_t {
95  } pmac_tumbler_t;  } pmac_tumbler_t;
96    
97    
 #define number_of(ary) (sizeof(ary) / sizeof(ary[0]))  
   
98  /*  /*
99   */   */
100    
# Line 168  static int tumbler_set_master_volume(pma Line 166  static int tumbler_set_master_volume(pma
166                  left_vol = 0;                  left_vol = 0;
167          else {          else {
168                  left_vol = mix->master_vol[0];                  left_vol = mix->master_vol[0];
169                  if (left_vol >= number_of(master_volume_table))                  if (left_vol >= ARRAY_SIZE(master_volume_table))
170                          left_vol = number_of(master_volume_table) - 1;                          left_vol = ARRAY_SIZE(master_volume_table) - 1;
171                  left_vol = master_volume_table[left_vol];                  left_vol = master_volume_table[left_vol];
172          }          }
173          if (! mix->master_switch[1])          if (! mix->master_switch[1])
174                  right_vol = 0;                  right_vol = 0;
175          else {          else {
176                  right_vol = mix->master_vol[1];                  right_vol = mix->master_vol[1];
177                  if (right_vol >= number_of(master_volume_table))                  if (right_vol >= ARRAY_SIZE(master_volume_table))
178                          right_vol = number_of(master_volume_table) - 1;                          right_vol = ARRAY_SIZE(master_volume_table) - 1;
179                  right_vol = master_volume_table[right_vol];                  right_vol = master_volume_table[right_vol];
180          }          }
181    
# Line 203  static int tumbler_info_master_volume(sn Line 201  static int tumbler_info_master_volume(sn
201          uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;          uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
202          uinfo->count = 2;          uinfo->count = 2;
203          uinfo->value.integer.min = 0;          uinfo->value.integer.min = 0;
204          uinfo->value.integer.max = number_of(master_volume_table) - 1;          uinfo->value.integer.max = ARRAY_SIZE(master_volume_table) - 1;
205          return 0;          return 0;
206  }  }
207    
# Line 479  static struct tumbler_mono_vol tumbler_p Line 477  static struct tumbler_mono_vol tumbler_p
477          .index = VOL_IDX_PCM_MONO,          .index = VOL_IDX_PCM_MONO,
478          .reg = TAS_REG_PCM,          .reg = TAS_REG_PCM,
479          .bytes = 3,          .bytes = 3,
480          .max = number_of(mixer_volume_table),          .max = ARRAY_SIZE(mixer_volume_table),
481          .table = mixer_volume_table,          .table = mixer_volume_table,
482  };  };
483    
# Line 487  static struct tumbler_mono_vol tumbler_b Line 485  static struct tumbler_mono_vol tumbler_b
485          .index = VOL_IDX_BASS,          .index = VOL_IDX_BASS,
486          .reg = TAS_REG_BASS,          .reg = TAS_REG_BASS,
487          .bytes = 1,          .bytes = 1,
488          .max = number_of(bass_volume_table),          .max = ARRAY_SIZE(bass_volume_table),
489          .table = bass_volume_table,          .table = bass_volume_table,
490  };  };
491    
# Line 495  static struct tumbler_mono_vol tumbler_t Line 493  static struct tumbler_mono_vol tumbler_t
493          .index = VOL_IDX_TREBLE,          .index = VOL_IDX_TREBLE,
494          .reg = TAS_REG_TREBLE,          .reg = TAS_REG_TREBLE,
495          .bytes = 1,          .bytes = 1,
496          .max = number_of(treble_volume_table),          .max = ARRAY_SIZE(treble_volume_table),
497          .table = treble_volume_table,          .table = treble_volume_table,
498  };  };
499    
# Line 504  static struct tumbler_mono_vol snapper_b Line 502  static struct tumbler_mono_vol snapper_b
502          .index = VOL_IDX_BASS,          .index = VOL_IDX_BASS,
503          .reg = TAS_REG_BASS,          .reg = TAS_REG_BASS,
504          .bytes = 1,          .bytes = 1,
505          .max = number_of(snapper_bass_volume_table),          .max = ARRAY_SIZE(snapper_bass_volume_table),
506          .table = snapper_bass_volume_table,          .table = snapper_bass_volume_table,
507  };  };
508    
# Line 512  static struct tumbler_mono_vol snapper_t Line 510  static struct tumbler_mono_vol snapper_t
510          .index = VOL_IDX_TREBLE,          .index = VOL_IDX_TREBLE,
511          .reg = TAS_REG_TREBLE,          .reg = TAS_REG_TREBLE,
512          .bytes = 1,          .bytes = 1,
513          .max = number_of(snapper_treble_volume_table),          .max = ARRAY_SIZE(snapper_treble_volume_table),
514          .table = snapper_treble_volume_table,          .table = snapper_treble_volume_table,
515  };  };
516    
# Line 546  static int snapper_set_mix_vol1(pmac_tum Line 544  static int snapper_set_mix_vol1(pmac_tum
544          unsigned char block[9];          unsigned char block[9];
545    
546          vol = mix->mix_vol[idx][ch];          vol = mix->mix_vol[idx][ch];
547          if (vol >= number_of(mixer_volume_table)) {          if (vol >= ARRAY_SIZE(mixer_volume_table)) {
548                  vol = number_of(mixer_volume_table) - 1;                  vol = ARRAY_SIZE(mixer_volume_table) - 1;
549                  mix->mix_vol[idx][ch] = vol;                  mix->mix_vol[idx][ch] = vol;
550          }          }
551    
# Line 579  static int snapper_info_mix(snd_kcontrol Line 577  static int snapper_info_mix(snd_kcontrol
577          uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;          uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
578          uinfo->count = 2;          uinfo->count = 2;
579          uinfo->value.integer.min = 0;          uinfo->value.integer.min = 0;
580          uinfo->value.integer.max = number_of(mixer_volume_table) - 1;          uinfo->value.integer.max = ARRAY_SIZE(mixer_volume_table) - 1;
581          return 0;          return 0;
582  }  }
583    
# Line 868  static void tumbler_reset_audio(pmac_t * Line 866  static void tumbler_reset_audio(pmac_t *
866          pmac_tumbler_t *mix = chip->mixer_data;          pmac_tumbler_t *mix = chip->mixer_data;
867    
868          write_audio_gpio(&mix->audio_reset, 0);          write_audio_gpio(&mix->audio_reset, 0);
869          mdelay(200);          big_mdelay(200);
870          write_audio_gpio(&mix->audio_reset, 1);          write_audio_gpio(&mix->audio_reset, 1);
871          mdelay(100);          big_mdelay(100);
872          write_audio_gpio(&mix->audio_reset, 0);          write_audio_gpio(&mix->audio_reset, 0);
873          mdelay(100);          big_mdelay(100);
874  }  }
875    
876  #ifdef CONFIG_PMAC_PBOOK  #ifdef CONFIG_PMAC_PBOOK
# Line 880  static void tumbler_reset_audio(pmac_t * Line 878  static void tumbler_reset_audio(pmac_t *
878  static void tumbler_resume(pmac_t *chip)  static void tumbler_resume(pmac_t *chip)
879  {  {
880          pmac_tumbler_t *mix = chip->mixer_data;          pmac_tumbler_t *mix = chip->mixer_data;
881    
882          snd_assert(mix, return);          snd_assert(mix, return);
883    
884          tumbler_reset_audio(chip);          tumbler_reset_audio(chip);
885          if (mix->i2c.client)          if (mix->i2c.client) {
886                  tumbler_init_client(&mix->i2c);                  if (tumbler_init_client(&mix->i2c) < 0)
887                            printk(KERN_ERR "tumbler_init_client error\n");
888            } else
889                    printk(KERN_ERR "tumbler: i2c is not initialized\n");
890          if (chip->model == PMAC_TUMBLER) {          if (chip->model == PMAC_TUMBLER) {
891                  tumbler_set_mono_volume(mix, &tumbler_pcm_vol_info);                  tumbler_set_mono_volume(mix, &tumbler_pcm_vol_info);
892                  tumbler_set_mono_volume(mix, &tumbler_bass_vol_info);                  tumbler_set_mono_volume(mix, &tumbler_bass_vol_info);
893                  tumbler_set_mono_volume(mix, &tumbler_treble_vol_info);                  tumbler_set_mono_volume(mix, &tumbler_treble_vol_info);
894                    tumbler_set_drc(mix);
895          } else {          } else {
896                  snapper_set_mix_vol(mix, VOL_IDX_PCM);                  snapper_set_mix_vol(mix, VOL_IDX_PCM);
897                  snapper_set_mix_vol(mix, VOL_IDX_PCM2);                  snapper_set_mix_vol(mix, VOL_IDX_PCM2);
898                  snapper_set_mix_vol(mix, VOL_IDX_ADC);                  snapper_set_mix_vol(mix, VOL_IDX_ADC);
899                  tumbler_set_mono_volume(mix, &tumbler_bass_vol_info);                  tumbler_set_mono_volume(mix, &tumbler_bass_vol_info);
900                  tumbler_set_mono_volume(mix, &tumbler_treble_vol_info);                  tumbler_set_mono_volume(mix, &tumbler_treble_vol_info);
901                    snapper_set_drc(mix);
902          }          }
         tumbler_set_drc(mix);  
903          tumbler_set_master_volume(mix);          tumbler_set_master_volume(mix);
904          if (chip->update_automute)          if (chip->update_automute)
905                  chip->update_automute(chip, 0);                  chip->update_automute(chip, 0);
# Line 1001  int __init snd_pmac_tumbler_init(pmac_t Line 1005  int __init snd_pmac_tumbler_init(pmac_t
1005          sprintf(chip->card->mixername, "PowerMac %s", chipname);          sprintf(chip->card->mixername, "PowerMac %s", chipname);
1006    
1007          if (chip->model == PMAC_TUMBLER) {          if (chip->model == PMAC_TUMBLER) {
1008                  for (i = 0; i < number_of(tumbler_mixers); i++) {                  for (i = 0; i < ARRAY_SIZE(tumbler_mixers); i++) {
1009                          if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&tumbler_mixers[i], chip))) < 0)                          if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&tumbler_mixers[i], chip))) < 0)
1010                                  return err;                                  return err;
1011                  }                  }
1012          } else {          } else {
1013                  for (i = 0; i < number_of(snapper_mixers); i++) {                  for (i = 0; i < ARRAY_SIZE(snapper_mixers); i++) {
1014                          if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snapper_mixers[i], chip))) < 0)                          if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snapper_mixers[i], chip))) < 0)
1015                                  return err;                                  return err;
1016                  }                  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26