Sound patch - some cleanup for ad1848

Itai Nahshon (nahshon@actcom.co.il)
Thu, 26 Mar 1998 14:37:09 +0300


This is a multi-part message in MIME format.
--------------205BB36C7172CC03DD29FBA5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The patch can be applied to kernels 2.1.90 or to pre-2.1.91-{1,2}.

Changes in ad1848_mixer.h
- Add the mute bit for the left channel.
- Use the mixer bit as documented for the 82C930/82C931 chips.
- Fix indentation etc..

Changes in ad1848.c
- cleanup in adintr. For C930 block interrupts only once for
reading/clearing the interrupt pending bits.
- remove c930_password_port from ad1848_info. It was never used.
- Change ad1848_control from void() to int(). Return error if
parameters are wrong.
- correct parameter checking for ad1848_control.

Changes in sound_calls.h
- Change ad1848_control from void() to int().

Itai

-- 
Itai Nahshon   nahshon@actcom.co.il
        Also   nahshon@vnet.ibm.com
--------------205BB36C7172CC03DD29FBA5
Content-Type: text/plain; charset=us-ascii; name="patch-sound-2.1.91-pre1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="patch-sound-2.1.91-pre1"

diff -u linux/drivers/sound-orig/ad1848.c linux/drivers/sound/ad1848.c --- linux/drivers/sound-orig/ad1848.c Thu Mar 12 20:52:09 1998 +++ linux/drivers/sound/ad1848.c Wed Mar 25 14:29:18 1998 @@ -84,7 +84,6 @@ int irq_ok; mixer_ents *mix_devices; int mixer_output_port; - int c930_password_port; } ad1848_info; typedef struct ad1848_port_info @@ -1409,7 +1408,6 @@ devc->chip_name = devc->name = "AD1848"; devc->model = MD_1848; /* AD1848 or CS4248 */ devc->levels = NULL; - devc->c930_password_port = 0; devc->debug_flag = 0; /* @@ -1847,12 +1845,12 @@ return my_dev; } -void ad1848_control(int cmd, int arg) +int ad1848_control(int cmd, int arg) { ad1848_info *devc; if (nr_ad1848_devs < 1) - return; + return -ENODEV; devc = &adev_info[nr_ad1848_devs - 1]; @@ -1860,7 +1858,7 @@ { case AD1848_SET_XTAL: /* Change clock frequency of AD1845 (only ) */ if (devc->model != MD_1845) - return; + return -EINVAL; ad_enter_MCE(devc); ad_write(devc, 29, (ad_read(devc, 29) & 0x1f) | (arg << 5)); ad_leave_MCE(devc); @@ -1871,32 +1869,37 @@ int o = (arg >> 8) & 0xff; int n = arg & 0xff; + if (o < 0 || o >= SOUND_MIXER_NRDEVICES) + return -EINVAL; + + if (!(devc->supported_devices & (1 << o)) && + !(devc->supported_rec_devices & (1 << o))) + return -EINVAL; + if (n == SOUND_MIXER_NONE) { /* Just hide this control */ ad1848_mixer_set(devc, o, 0); /* Shut up it */ devc->supported_devices &= ~(1 << o); devc->supported_rec_devices &= ~(1 << o); - return; + break; } - /* Make the mixer control identified by o to appear as n */ - if (o < 0 || o > SOUND_MIXER_NRDEVICES) - return; - if (n < 0 || n > SOUND_MIXER_NRDEVICES) - return; - if (!(devc->supported_devices & (1 << o))) - return; /* Not supported */ + /* Make the mixer control identified by o to appear as n */ + if (n < 0 || n >= SOUND_MIXER_NRDEVICES) + return -EINVAL; devc->mixer_reroute[n] = o; /* Rename the control */ - devc->supported_devices &= ~(1 << o); - devc->supported_devices |= (1 << n); + if (devc->supported_devices & (1 << o)) + devc->supported_devices |= (1 << n); if (devc->supported_rec_devices & (1 << o)) devc->supported_rec_devices |= (1 << n); + + devc->supported_devices &= ~(1 << o); devc->supported_rec_devices &= ~(1 << o); } break; } - return; + return 0; } void ad1848_unload(int io_base, int irq, int dma_playback, int dma_capture, int share_dma) @@ -1965,37 +1968,22 @@ save_flags(flags); cli(); - alt_stat = 0; - - if (devc->c930_password_port) - outb((0xe4), devc->c930_password_port); /* Password */ + /* 0xe0e is C930 address port + * 0xe0f is C930 data port + */ outb(11, 0xe0e); c930_stat = inb(0xe0f); + outb((~c930_stat), 0xe0f); - if (c930_stat & 0x04) - alt_stat |= 0x10; /* Playback intr */ - if (c930_stat & 0x08) - alt_stat |= 0x20; /* Playback intr */ restore_flags(flags); - } else if (devc->model != MD_1848) - alt_stat = ad_read(devc, 24); - /* Acknowledge the intr before proceeding */ - if (devc->model == MD_C930) - { /* 82C930 has interrupt status register in MAD16 register MC11 */ - unsigned long flags; - - save_flags(flags); - cli(); - - if (devc->c930_password_port) - outb((0xe4), devc->c930_password_port); /* Password */ - outb((11), 0xe0e); - outb((~c930_stat), 0xe0f); - restore_flags(flags); + alt_stat = (c930_stat << 2) & 0x30; } else if (devc->model != MD_1848) + { + alt_stat = ad_read(devc, 24); ad_write(devc, 24, ad_read(devc, 24) & ~alt_stat); /* Selective ack */ + } if (devc->open_mode & OPEN_READ && devc->audio_mode & PCM_ENABLE_INPUT && alt_stat & 0x20) { diff -u linux/drivers/sound-orig/ad1848_mixer.h linux/drivers/sound/ad1848_mixer.h --- linux/drivers/sound-orig/ad1848_mixer.h Tue Sep 30 18:46:44 1997 +++ linux/drivers/sound/ad1848_mixer.h Wed Mar 25 14:18:27 1998 @@ -1,6 +1,6 @@ /* * sound/ad1848_mixer.h - * + * * Definitions for the mixer of AD1848 and compatible codecs. */ @@ -77,7 +77,7 @@ */ #define MIX_ENT(name, reg_l, pola_l, pos_l, len_l, reg_r, pola_r, pos_r, len_r, mute_bit) \ - {{reg_l, pola_l, pos_l, len_l}, {reg_r, pola_r, pos_r, len_r, mute_bit}} + {{reg_l, pola_l, pos_l, len_l, mute_bit}, {reg_r, pola_r, pos_r, len_r, mute_bit}} static mixer_ents ad1848_mix_devices[32] = { MIX_ENT(SOUND_MIXER_VOLUME, 27, 1, 0, 4, 29, 1, 0, 4, 8), @@ -88,13 +88,13 @@ MIX_ENT(SOUND_MIXER_SPEAKER, 26, 1, 0, 4, 0, 0, 0, 0, 8), MIX_ENT(SOUND_MIXER_LINE, 18, 1, 0, 5, 19, 1, 0, 5, 7), MIX_ENT(SOUND_MIXER_MIC, 0, 0, 5, 1, 1, 0, 5, 1, 8), -MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5, 7), +MIX_ENT(SOUND_MIXER_CD, 2, 1, 0, 5, 3, 1, 0, 5, 7), MIX_ENT(SOU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ENT(SOUND_MIXER_LINE1, 2, 1, 0, 5, 3, 1, 0, 5, 7), MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 0, 5, 5, 1, 0, 5, 7), MIX_ENT(SOUND_MIXER_LINE3, 18, 1, 0, 5, 19, 1, 0, 5, 7) }; @@ -125,21 +125,21 @@ * MIC is level of mic monitoring direct to output. Same for CD, LINE, etc. */ static mixer_ents c930_mix_devices[32] = { -MIX_ENT(SOUND_MIXER_VOLUME, 22, 1, 0, 5, 23, 1, 0, 5, 7), +MIX_ENT(SOUND_MIXER_VOLUME, 22, 1, 1, 5, 23, 1, 1, 5, 7), MIX_ENT(SOUND_MIXER_BASS, 0, 0, 0, 0, 0, 0, 0, 0, 8), MIX_ENT(SOUND_MIXER_TREBLE, 0, 0, 0, 0, 0, 0, 0, 0, 8), -MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 0, 5, 5, 1, 0, 5, 7), -MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 6, 7, 1, 0, 6, 7), -MIX_ENT(SOUND_MIXER_SPEAKER, 22, 1, 0, 5, 23, 1, 0, 5, 8), +MIX_ENT(SOUND_MIXER_SYNTH, 4, 1, 1, 4, 5, 1, 1, 4, 7), +MIX_ENT(SOUND_MIXER_PCM, 6, 1, 0, 5, 7, 1, 0, 5, 7), +MIX_ENT(SOUND_MIXER_SPEAKER, 22, 1, 1, 5, 23, 1, 1, 5, 7), MIX_ENT(SOUND_MIXER_LINE, 18, 1, 1, 4, 19, 1, 1, 4, 7), -MIX_ENT(SOUND_MIXER_MIC, 20, 1, 0, 4, 21, 1, 0, 4, 8), -MIX_ENT(SOUND_MIXER_CD, 2, 1, 1, 4, 3, 1, 1, 4, 7), -MIX_ENT(SOUND_MIXER_IMIX, 0, 0, 0, 0, 0, 0, 0, 0, 8), +MIX_ENT(SOUND_MIXER_MIC, 20, 1, 1, 4, 21, 1, 1, 4, 7), +MIX_ENT(SOUND_MIXER_CD, 2, 1, 1, 4, 3, 1, 1, 4, 7), +MIX_ENT(SOUND_MIXER_IMIX, 0, 0, 0, 0, 0, 0, 0, 0, 8), MIX_ENT(SOUND_MIXER_ALTPCM, 0, 0, 0, 0, 0, 0, 0, 0, 8), MIX_ENT(SOUND_MIXER_RECLEV, 0, 0, 0, 0, 0, 0, 0, 0, 8), MIX_ENT(SOUND_MIXER_IGAIN, 0, 0, 0, 4, 1, 0, 0, 4, 8), MIX_ENT(SOUND_MIXER_OGAIN, 0, 0, 0, 0, 0, 0, 0, 0, 8), -MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 1, 4, 3, 1, 1, 4, 7), +MIX_ENT(SOUND_MIXER_LINE1, 2, 1, 1, 4, 3, 1, 1, 4, 7), MIX_ENT(SOUND_MIXER_LINE2, 4, 1, 1, 4, 5, 1, 1, 4, 7), MIX_ENT(SOUND_MIXER_LINE3, 18, 1, 1, 4, 19, 1, 1, 4, 7) }; diff -u linux/drivers/sound-orig/sound_calls.h linux/drivers/sound/sound_calls.h --- linux/drivers/sound-orig/sound_calls.h Thu Mar 12 20:52:09 1998 +++ linux/drivers/sound/sound_calls.h Wed Mar 25 06:37:44 1998 @@ -187,7 +187,7 @@ #define AD_F_CS4231 0x0001 /* Returned if a CS4232 (or compatible) detected */ #define AD_F_CS4248 0x0001 /* Returned if a CS4248 (or compatible) detected */ -void ad1848_control(int cmd, int arg); +int ad1848_control(int cmd, int arg); #define AD1848_SET_XTAL 1 #define AD1848_MIXER_REROUTE 2 #define AD1848_REROUTE(oldctl, newctl) \

--------------205BB36C7172CC03DD29FBA5--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu