drm/radeon/kms/evergreen: add soft reset function
[safe/jmp/linux-2.6] / sound / oss / ac97_codec.c
index 602db49..456a1b4 100644 (file)
@@ -30,7 +30,7 @@
  **************************************************************************
  *
  * History
- * May 02, 2003 Liam Girdwood <liam.girdwood@wolfsonmicro.com>
+ * May 02, 2003 Liam Girdwood <lrg@slimlogic.co.uk>
  *     Removed non existant WM9700
  *     Added support for WM9705, WM9708, WM9709, WM9710, WM9711
  *     WM9712 and WM9717
@@ -189,42 +189,6 @@ static const struct {
        {0x57454301, "Winbond 83971D",          &null_ops},
 };
 
-static const char *ac97_stereo_enhancements[] =
-{
-       /*   0 */ "No 3D Stereo Enhancement",
-       /*   1 */ "Analog Devices Phat Stereo",
-       /*   2 */ "Creative Stereo Enhancement",
-       /*   3 */ "National Semi 3D Stereo Enhancement",
-       /*   4 */ "YAMAHA Ymersion",
-       /*   5 */ "BBE 3D Stereo Enhancement",
-       /*   6 */ "Crystal Semi 3D Stereo Enhancement",
-       /*   7 */ "Qsound QXpander",
-       /*   8 */ "Spatializer 3D Stereo Enhancement",
-       /*   9 */ "SRS 3D Stereo Enhancement",
-       /*  10 */ "Platform Tech 3D Stereo Enhancement",
-       /*  11 */ "AKM 3D Audio",
-       /*  12 */ "Aureal Stereo Enhancement",
-       /*  13 */ "Aztech 3D Enhancement",
-       /*  14 */ "Binaura 3D Audio Enhancement",
-       /*  15 */ "ESS Technology Stereo Enhancement",
-       /*  16 */ "Harman International VMAx",
-       /*  17 */ "Nvidea 3D Stereo Enhancement",
-       /*  18 */ "Philips Incredible Sound",
-       /*  19 */ "Texas Instruments 3D Stereo Enhancement",
-       /*  20 */ "VLSI Technology 3D Stereo Enhancement",
-       /*  21 */ "TriTech 3D Stereo Enhancement",
-       /*  22 */ "Realtek 3D Stereo Enhancement",
-       /*  23 */ "Samsung 3D Stereo Enhancement",
-       /*  24 */ "Wolfson Microelectronics 3D Enhancement",
-       /*  25 */ "Delta Integration 3D Enhancement",
-       /*  26 */ "SigmaTel 3D Enhancement",
-       /*  27 */ "Winbond 3D Stereo Enhancement",
-       /*  28 */ "Rockwell 3D Stereo Enhancement",
-       /*  29 */ "Reserved 29",
-       /*  30 */ "Reserved 30",
-       /*  31 */ "Reserved 31"
-};
-
 /* this table has default mixer values for all OSS mixers. */
 static struct mixer_defaults {
        int mixer;
@@ -614,83 +578,6 @@ static int ac97_mixer_ioctl(struct ac97_codec *codec, unsigned int cmd, unsigned
        return -EINVAL;
 }
 
-/* entry point for /proc/driver/controller_vendor/ac97/%d */
-int ac97_read_proc (char *page, char **start, off_t off,
-                   int count, int *eof, void *data)
-{
-       int len = 0, cap, extid, val, id1, id2;
-       struct ac97_codec *codec;
-       int is_ac97_20 = 0;
-
-       if ((codec = data) == NULL)
-               return -ENODEV;
-
-       id1 = codec->codec_read(codec, AC97_VENDOR_ID1);
-       id2 = codec->codec_read(codec, AC97_VENDOR_ID2);
-       len += sprintf (page+len, "Vendor name      : %s\n", codec->name);
-       len += sprintf (page+len, "Vendor id        : %04X %04X\n", id1, id2);
-
-       extid = codec->codec_read(codec, AC97_EXTENDED_ID);
-       extid &= ~((1<<2)|(1<<4)|(1<<5)|(1<<10)|(1<<11)|(1<<12)|(1<<13));
-       len += sprintf (page+len, "AC97 Version     : %s\n",
-                       extid ? "2.0 or later" : "1.0");
-       if (extid) is_ac97_20 = 1;
-
-       cap = codec->codec_read(codec, AC97_RESET);
-       len += sprintf (page+len, "Capabilities     :%s%s%s%s%s%s\n",
-                       cap & 0x0001 ? " -dedicated MIC PCM IN channel-" : "",
-                       cap & 0x0002 ? " -reserved1-" : "",
-                       cap & 0x0004 ? " -bass & treble-" : "",
-                       cap & 0x0008 ? " -simulated stereo-" : "",
-                       cap & 0x0010 ? " -headphone out-" : "",
-                       cap & 0x0020 ? " -loudness-" : "");
-       val = cap & 0x00c0;
-       len += sprintf (page+len, "DAC resolutions  :%s%s%s\n",
-                       " -16-bit-",
-                       val & 0x0040 ? " -18-bit-" : "",
-                       val & 0x0080 ? " -20-bit-" : "");
-       val = cap & 0x0300;
-       len += sprintf (page+len, "ADC resolutions  :%s%s%s\n",
-                       " -16-bit-",
-                       val & 0x0100 ? " -18-bit-" : "",
-                       val & 0x0200 ? " -20-bit-" : "");
-       len += sprintf (page+len, "3D enhancement   : %s\n",
-                       ac97_stereo_enhancements[(cap >> 10) & 0x1f]);
-
-       val = codec->codec_read(codec, AC97_GENERAL_PURPOSE);
-       len += sprintf (page+len, "POP path         : %s 3D\n"
-                       "Sim. stereo      : %s\n"
-                       "3D enhancement   : %s\n"
-                       "Loudness         : %s\n"
-                       "Mono output      : %s\n"
-                       "MIC select       : %s\n"
-                       "ADC/DAC loopback : %s\n",
-                       val & 0x8000 ? "post" : "pre",
-                       val & 0x4000 ? "on" : "off",
-                       val & 0x2000 ? "on" : "off",
-                       val & 0x1000 ? "on" : "off",
-                       val & 0x0200 ? "MIC" : "MIX",
-                       val & 0x0100 ? "MIC2" : "MIC1",
-                       val & 0x0080 ? "on" : "off");
-
-       extid = codec->codec_read(codec, AC97_EXTENDED_ID);
-       cap = extid;
-       len += sprintf (page+len, "Ext Capabilities :%s%s%s%s%s%s%s\n",
-                       cap & 0x0001 ? " -var rate PCM audio-" : "",
-                       cap & 0x0002 ? " -2x PCM audio out-" : "",
-                       cap & 0x0008 ? " -var rate MIC in-" : "",
-                       cap & 0x0040 ? " -PCM center DAC-" : "",
-                       cap & 0x0080 ? " -PCM surround DAC-" : "",
-                       cap & 0x0100 ? " -PCM LFE DAC-" : "",
-                       cap & 0x0200 ? " -slot/DAC mappings-" : "");
-       if (is_ac97_20) {
-               len += sprintf (page+len, "Front DAC rate   : %d\n",
-                               codec->codec_read(codec, AC97_PCM_FRONT_DAC_RATE));
-       }
-
-       return len;
-}
-
 /**
  *     codec_id        -  Turn id1/id2 into a PnP string
  *     @id1: Vendor ID1
@@ -744,11 +631,10 @@ static int ac97_check_modem(struct ac97_codec *codec)
  
 struct ac97_codec *ac97_alloc_codec(void)
 {
-       struct ac97_codec *codec = kmalloc(sizeof(struct ac97_codec), GFP_KERNEL);
+       struct ac97_codec *codec = kzalloc(sizeof(struct ac97_codec), GFP_KERNEL);
        if(!codec)
                return NULL;
 
-       memset(codec, 0, sizeof(*codec));
        spin_lock_init(&codec->lock);
        INIT_LIST_HEAD(&codec->list);
        return codec;
@@ -1314,176 +1200,7 @@ static int pt101_init(struct ac97_codec * codec)
 #endif
        
 
-EXPORT_SYMBOL(ac97_read_proc);
 EXPORT_SYMBOL(ac97_probe_codec);
 
-/*
- *     AC97 library support routines
- */    
-/**
- *     ac97_set_dac_rate       -       set codec rate adaption
- *     @codec: ac97 code
- *     @rate: rate in hertz
- *
- *     Set the DAC rate. Assumes the codec supports VRA. The caller is
- *     expected to have checked this little detail.
- */
-unsigned int ac97_set_dac_rate(struct ac97_codec *codec, unsigned int rate)
-{
-       unsigned int new_rate = rate;
-       u32 dacp;
-       u32 mast_vol, phone_vol, mono_vol, pcm_vol;
-       u32 mute_vol = 0x8000;  /* The mute volume? */
-
-       if(rate != codec->codec_read(codec, AC97_PCM_FRONT_DAC_RATE))
-       {
-               /* Mute several registers */
-               mast_vol = codec->codec_read(codec, AC97_MASTER_VOL_STEREO);
-               mono_vol = codec->codec_read(codec, AC97_MASTER_VOL_MONO);
-               phone_vol = codec->codec_read(codec, AC97_HEADPHONE_VOL);
-               pcm_vol = codec->codec_read(codec, AC97_PCMOUT_VOL);
-               codec->codec_write(codec, AC97_MASTER_VOL_STEREO, mute_vol);
-               codec->codec_write(codec, AC97_MASTER_VOL_MONO, mute_vol);
-               codec->codec_write(codec, AC97_HEADPHONE_VOL, mute_vol);
-               codec->codec_write(codec, AC97_PCMOUT_VOL, mute_vol);
-               
-               /* Power down the DAC */
-               dacp=codec->codec_read(codec, AC97_POWER_CONTROL);
-               codec->codec_write(codec, AC97_POWER_CONTROL, dacp|0x0200);
-               /* Load the rate and read the effective rate */
-               codec->codec_write(codec, AC97_PCM_FRONT_DAC_RATE, rate);
-               new_rate=codec->codec_read(codec, AC97_PCM_FRONT_DAC_RATE);
-               /* Power it back up */
-               codec->codec_write(codec, AC97_POWER_CONTROL, dacp);
-
-               /* Restore volumes */
-               codec->codec_write(codec, AC97_MASTER_VOL_STEREO, mast_vol);
-               codec->codec_write(codec, AC97_MASTER_VOL_MONO, mono_vol);
-               codec->codec_write(codec, AC97_HEADPHONE_VOL, phone_vol);
-               codec->codec_write(codec, AC97_PCMOUT_VOL, pcm_vol);
-       }
-       return new_rate;
-}
-
-EXPORT_SYMBOL(ac97_set_dac_rate);
-
-/**
- *     ac97_set_adc_rate       -       set codec rate adaption
- *     @codec: ac97 code
- *     @rate: rate in hertz
- *
- *     Set the ADC rate. Assumes the codec supports VRA. The caller is
- *     expected to have checked this little detail.
- */
-
-unsigned int ac97_set_adc_rate(struct ac97_codec *codec, unsigned int rate)
-{
-       unsigned int new_rate = rate;
-       u32 dacp;
-
-       if(rate != codec->codec_read(codec, AC97_PCM_LR_ADC_RATE))
-       {
-               /* Power down the ADC */
-               dacp=codec->codec_read(codec, AC97_POWER_CONTROL);
-               codec->codec_write(codec, AC97_POWER_CONTROL, dacp|0x0100);
-               /* Load the rate and read the effective rate */
-               codec->codec_write(codec, AC97_PCM_LR_ADC_RATE, rate);
-               new_rate=codec->codec_read(codec, AC97_PCM_LR_ADC_RATE);
-               /* Power it back up */
-               codec->codec_write(codec, AC97_POWER_CONTROL, dacp);
-       }
-       return new_rate;
-}
-
-EXPORT_SYMBOL(ac97_set_adc_rate);
-
-static int swap_headphone(int remove_master)
-{
-       struct list_head *l;
-       struct ac97_codec *c;
-       
-       if (remove_master) {
-               mutex_lock(&codec_mutex);
-               list_for_each(l, &codecs)
-               {
-                       c = list_entry(l, struct ac97_codec, list);
-                       if (supported_mixer(c, SOUND_MIXER_PHONEOUT))
-                               c->supported_mixers &= ~SOUND_MASK_PHONEOUT;
-               }
-               mutex_unlock(&codec_mutex);
-       } else
-               ac97_hw[SOUND_MIXER_PHONEOUT].offset = AC97_MASTER_VOL_STEREO;
-
-       /* Scale values already match */
-       ac97_hw[SOUND_MIXER_VOLUME].offset = AC97_MASTER_VOL_MONO;
-       return 0;
-}
-
-static int apply_quirk(int quirk)
-{
-       switch (quirk) {
-       case AC97_TUNE_NONE:
-               return 0;
-       case AC97_TUNE_HP_ONLY:
-               return swap_headphone(1);
-       case AC97_TUNE_SWAP_HP:
-               return swap_headphone(0);
-       case AC97_TUNE_SWAP_SURROUND:
-               return -ENOSYS; /* not yet implemented */
-       case AC97_TUNE_AD_SHARING:
-               return -ENOSYS; /* not yet implemented */
-       case AC97_TUNE_ALC_JACK:
-               return -ENOSYS; /* not yet implemented */
-       }
-       return -EINVAL;
-}
-
-/**
- *     ac97_tune_hardware - tune up the hardware
- *     @pdev: pci_dev pointer
- *     @quirk: quirk list
- *     @override: explicit quirk value (overrides if not AC97_TUNE_DEFAULT)
- *
- *     Do some workaround for each pci device, such as renaming of the
- *     headphone (true line-out) control as "Master".
- *     The quirk-list must be terminated with a zero-filled entry.
- *
- *     Returns zero if successful, or a negative error code on failure.
- */
-
-int ac97_tune_hardware(struct pci_dev *pdev, struct ac97_quirk *quirk, int override)
-{
-       int result;
-
-       if (!quirk)
-               return -EINVAL;
-
-       if (override != AC97_TUNE_DEFAULT) {
-               result = apply_quirk(override);
-               if (result < 0)
-                       printk(KERN_ERR "applying quirk type %d failed (%d)\n", override, result);
-               return result;
-       }
-
-       for (; quirk->vendor; quirk++) {
-               if (quirk->vendor != pdev->subsystem_vendor)
-                       continue;
-               if ((! quirk->mask && quirk->device == pdev->subsystem_device) ||
-                   quirk->device == (quirk->mask & pdev->subsystem_device)) {
-#ifdef DEBUG
-                       printk("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, pdev->subsystem_device);
-#endif
-                       result = apply_quirk(quirk->type);
-                       if (result < 0)
-                               printk(KERN_ERR "applying quirk type %d for %s failed (%d)\n", quirk->type, quirk->name, result);
-                       return result;
-               }
-       }
-       return 0;
-}
-
-EXPORT_SYMBOL_GPL(ac97_tune_hardware);
-
 MODULE_LICENSE("GPL");
+