Commit Graph

1064 Commits

Author SHA1 Message Date
Ariff Abdullah
3419bf5a7d Fix (or rather workaround) Intel 440MX Errata #36
- http://www.intel.com/design/chipsets/specupdt/245051.htm

AC97 Soft Audio and Soft Modem Master Abort Errata

Issue:
  Use of either soft audio or soft modem on an Intel® 82443MX PCISet
  based platform running a 100 MHz Processor System Bus and an AC97 codec
  may result in failures. The system continues to function normally while
  the AC97 hardware may not resume and may require a cold-boot to
  recover. As a result of the failure, the Master Abort Status bit will
  be set in the audio or modem function PCI header space.

Workaround:
  Force uncacheable DMA on both BDL and pcm buffers.

Tested by:	Emil Holmstr|m <emil@linux.se>
2007-05-05 09:18:05 +00:00
Ariff Abdullah
71e3af015d Miscellaneous changes and fix:
- Remove explicit call to pmap_change_attr(), since we now have proper
  and functional definition of BUS_DMA_NOCACHE.
- Enable PCI(e) bus snooping for non i386/amd64 as an alternative for
  uncacheable DMA.
- Codecs changes:
  * Analag Device -> Analog Devices, AD1988.
  * New codec: VIA VT1708 and VT1709, Realtek ALC262, ALC861-VD and
    ALC885.
  * Various fixups for Conexant Waikiki, fix recording (read: microphone)
    on various Analog Devices codecs due to vendor BIOS mess, various
    quirks for several ASUS laptops/boards.
- Fix connection list handling, closely following the specification to
  handle range of nids.
- Basic Jack sense polling infrastructure for possible hardwares with
  broken unsolicited response interrupt.

Ideas/Submitted/Tested by:	Andriy Gapon <avg@icyb.net.ua>,
                          	#freebsd-azalia, many.
2007-05-05 09:17:36 +00:00
Ariff Abdullah
53bc1d83c0 Fix use-after-free for DMA tag. Destroy DMA tag later.
Submitted by:	Yuriy Tsibizov
2007-05-04 12:38:46 +00:00
Ariff Abdullah
9d2d90cb79 Unbreak module / driver attach breakage. Both snd_envy24 and snd_envy24ht
mistakenly rely on wrong snd_spicds version.
2007-04-20 01:28:51 +00:00
Ariff Abdullah
fd7390d640 - AC97 quirk / patch cleanups. Most quirks doesn't work in general sense
and should only be applied on certain specific card / vendor, hence the
  addition of ac97_getsubvendor().
- Fix low volume issue on several MSI laptops through ALC655 quirk.

Reported/Tested by:	Christian Mueller
                   	<raptor-freebsd-multimedia@xpls.de>
MFC after:		1 week
2007-04-19 13:54:22 +00:00
Ariff Abdullah
2e334adf6a sndbuf_alloc() now accept dmaflags argument which will be forwarded to
internal bus_dmammem_alloc() for greater flexibility on setting up DMA /
page attributes.
2007-04-18 18:26:41 +00:00
Ariff Abdullah
e492b75981 Break ABI / module compatibility for the upcoming sndbuf_alloc() changes. 2007-04-18 18:20:48 +00:00
Ariff Abdullah
319276aac0 Disable cmi_midiattach(). The implementation is incomplete, and causing
various interesting memory leak issues.
2007-04-08 07:52:27 +00:00
Ariff Abdullah
f505e02090 Revert busy refcount back to int. As a side note, multiple open
is still (and always) possible and does not change previous behaviour.

Requested by:	netchild
2007-04-02 10:24:15 +00:00
Ariff Abdullah
ff7499570c Disable seq_modevent(). The implementation is incomplete, and causing
memory leak during unload.
2007-04-02 06:03:47 +00:00
Ariff Abdullah
3627e77dfa No need to track every closing instance, and put busy counter to rest
in its single bit coffin.
2007-04-02 03:46:25 +00:00
Ariff Abdullah
a9be51acfe Provide hint / tunable for possible asynchronous USB execution. Async
execution should help us avoiding potential deadlock and illegal locking
while sleeping in various mixer -> usb calls. To enable it, use
hint.uaudio.%d.async="1" or sysctl dev.uaudio.%d.async=1. Default is
disable, to remain compatible with old behaviour (with slight risk of
potential deadlock).
2007-04-02 03:25:39 +00:00
Ariff Abdullah
72e9d07fbf - Don't wakeup() unnecessarily, so the behavior of dead interrupt or
stalled DMA engine can be observed and predicted.
- Minor sysctl/tunable cleanup.
2007-04-02 03:03:06 +00:00
Alexander Leidinger
c2bb6a54ef Tell interested readers of the source that the return value is not
checked by intend.

Found by:	Coverity Prevent (tm)
CID:		55
Reviewed by:	ariff
2007-03-31 13:38:12 +00:00
Ariff Abdullah
703c934a48 Memory leak killing spree, mostly bus_dma(9) related. 2007-03-21 18:17:03 +00:00
Ariff Abdullah
94d36aa276 Put a temporary bandaid to set/reset uncacheable DMA region (affected
on amd64 and i386) until we gain proper BUS_DMA_NOCACHE support.
(in progress).

Tested by:	rafan, infofarmer, Nguyen Tam Chinh <unixvn@gmail.com>
Tested on:	amd64, i386
2007-03-20 11:24:29 +00:00
Ariff Abdullah
19f018fb83 Destroy channel DMA tag during resource cleanup. 2007-03-19 16:06:26 +00:00
Ariff Abdullah
d5304d9e3d Enforce sample size alignment on first direct-copy channel. 2007-03-18 18:26:40 +00:00
Ariff Abdullah
d2ea76fe8f Fix (another, more to come) ivar memory leak during driver detach. 2007-03-17 19:37:09 +00:00
Ariff Abdullah
42a3b81e4e Fix long delay closing/syncing issues on mmaped buffer. 2007-03-17 17:07:21 +00:00
Ariff Abdullah
7ab4fa8ee2 [stage: 9/9]
- SWAPLR quirk for (unknown, luckily it is mine) broken uaudio stick.
  Fixing by rewiring is impossible without damaging it. Luckily,
  we can fix it using "other" methods :) .
- Add uaudio_get_vendor(), _product() and _release() in uaudio.c
  (currently used by uaudio_pcm quirk).
- Implement CHANNEL_SETFRAGMENTS().
- Drop channel locking in few places where it is about to sleep
  somewhere. This should help eliminating illegal locking acquisition
  where the current thread is about to sleep, and also few deadlock
  cases. Dropping it right here is quite safe since it is already
  protected by CHN_F_BUSY flag and other threads won't bother to touch it.
  Solving other illegal locking issues are quite tricky without converting
  most usbd_do_request() calls to its equivalent _async() calls,
  which I intend to do it later after getting full test report from
  other people with different uaudio hardwares.
- Fix memory leak issues during detach. This seems common to any drivers
  (notably emu10kx, csapcm?) with bridge functions.
2007-03-16 17:19:03 +00:00
Ariff Abdullah
1042342ad8 [stage: 8/9]
Implement CHANNEL_SETFRAGMENTS() for snd_atiixp, snd_es137x, snd_hda
and snd_via8233. CHANNEL_SETBLOCKSIZE() will basically call
CHANNEL_SETFRAGMENTS() internally using conservative blocksize /
blockcount hints. Other drivers will be converted later.
2007-03-16 17:18:17 +00:00
Ariff Abdullah
7d9022b422 [stage: 7/9]
EWOULDBLOCK -> EAGAIN.
2007-03-16 17:17:25 +00:00
Ariff Abdullah
1324d98beb [stage: 6/9]
- Disable stray buffer management, since sample size aligned buffering
  are pretty much guaranteed through out the entire feeder_* chain
  processes.
- Few style(9) cleanups.
2007-03-16 17:16:56 +00:00
Ariff Abdullah
fd1475d34d [stage: 5/9]
channel.c/channel_if.m:
 - Macros cleanups, prefer inlined min() over MIN().
 - Rework chn_read()/chn_write() for better dead interrupt detection
   policy. Reduce scheduling overhead by doing pure 5 seconds sleep
   before giving up, instead of several cycle of brute micro sleeping.
 - Avoid calling wakeup_one() for non-sleeping channel (for example,
   vchan parent channel).
 - EWOULDBLOCK -> EAGAIN.
 - Fix possible divide-by-zero panic on chn_sync().
 - Re-enforce ^2 blocksize policy, since there are too many broken
   userland apps that blindly assume it without even trying to do
   serious calculations.
 - New channel method - CHANNEL_SETFRAGMENTS(), a refined version of
   CHANNEL_SETBLOCKSIZE(). It accept _both_ blocksize and blockcount
   arguments, so the driver internals will have better hints for
   buffering and timing calculations.
 - Hook FEEDER_SWAPLR into feederchain building process.

feeder_fmt.c:
- Unified version of various filters, avoiding duplications.
- malloc()less feeder_fmt. Informations can be retrieved dynamically
  by doing table lookup on static data. For cases such as converting
  from stereo to mono or reducing bit depth where input data is larger
  than output, cycle remaining available free space until it has been
  exhausted and start kicking 8 bytes reservoir space from there to
  complete the remaining requested count.
- Introduce FEEDER_SWAPLR. Few super broken hardwares (found on several
  extremely cheap uaudio stick, possibly others) mistakenly wired left
  and right channels wrongly, screwing output or input.
2007-03-16 17:16:24 +00:00
Ariff Abdullah
c30ec7427a [stage: 4/9]
- Rearrange FEEDER_* constants starting from 0 to 31, so the future
  additions will be much easier and consistent.
- Introduce FEEDER_SWAPLR. Few super broken hardwares (found on several
  extremely cheap uaudio stick, possibly others) mistakenly wired left
  and right channels wrongly, screwing output or input.
2007-03-16 17:15:33 +00:00
Ariff Abdullah
e956c4e11f [stage: 3.2/9]
malloc()less feeder_vchan. Informations can be retrieved dynamically
by doing table lookup on static data. Reduce mixing overhead by
doing direct copy on first channel. Mixing process will begin starting
from second channel onwards.
2007-03-16 17:14:41 +00:00
Ariff Abdullah
3e3981e8a0 [stage: 3.1/9]
malloc()less feeder_volume. Informations can be retrieved dynamically
by doing table lookup on static data. Increase resolution from 6bit
to PCM_FXSHIFT (8bit) for better resolution and finer volume changes.
2007-03-16 17:14:19 +00:00
Ariff Abdullah
4dfcb0573f [stage: 2/9]
Use inlined min() rather than MIN() macross.
2007-03-16 17:13:44 +00:00
Ariff Abdullah
dd83f3b6cf [stage: 1/9]
- Convert sx lock to plain mutex. Since the access of /dev/sndstat
  is pretty much exclusive and protected by toggling sndstat_isopen,
  plain mutex is more than enough.
- Enable SBUF_AUTOEXTEND to avoid buffer truncation.
2007-03-16 17:13:12 +00:00
Ariff Abdullah
d90a1cd318 Fix support for ASUS A7T ALC882 laptop (gpio0 quirk).
Reported/Tested by:	cognet
2007-03-16 01:44:21 +00:00
Ariff Abdullah
4beb77e673 Spring cleanup on irrelevant NULL checking over M_WAITOK allocations. 2007-03-15 18:19:01 +00:00
Ariff Abdullah
12828031ac - Put some sanity break statement in few missing places.
- Remove NULL checking on snd_mtxcreate() (M_WAITOK) .
2007-03-15 17:35:04 +00:00
Ariff Abdullah
82199c9255 NOOP (for now) for hdac_dma_nocache(). It is a wrong way to enforce
cache coherency, besides of causing train wreck in other places
(especially on amd64, possibly on i386).

Discussed with:	kib@, rafan@
Tested by:	rafan@
2007-03-15 17:23:38 +00:00
Ariff Abdullah
4582b3a100 Fix severe out-of-bound mtx "type" pointer, causing WITNESS refcount
confusions and panic provided that the following conditions are met:

  1) WITNESS is enabled (watch/trace).
  2) Using modules, instead of statically linked (Not a strict
     requirement, but easier to reproduce this way).
  3) 2 or more modules share the same mtx type ("sound softc").
     - They might share the same name (strcmp() == 0), but it always
       point to different address.
  4) Repetitive kldunload/load on any module that shares the same mtx
     type (Not a strict requirement, but easier to reproduce this way).

     Consider module A and module B:
     - From enroll() - subr_witness.c:
       * Load module A. Everything seems fine right now.
         wA-w_refcount == 1 ; wA-w_name = "sound softc"
       * Load module B.
       * w->w_name == description will always fail.
         ("sound softc" from A and B point to different address).
       * wA->w_refcount > 0 && strcmp(description, wA->w_name) == 0
       * enroll() will return wA instead of returning (possibly unique)
         wB.
         wA->w_refcount++ , == 2.
       * Unload module A, mtx_destroy(), wA->w_name become invalid,
         but wA->w_refcount-- become 1 instead of 0. wA will not be
         removed from witness list.
       * Some other places call mtx_init(), iterating witness list,
         found wA, failed on wA->w_name == description
       * wA->w_refcount > 0 && strcmp(description, wA->w_name)
       * Panic on strcmp() since wA->w_name no longer point to valid
         address.

Note that this could happened in other places as well, not just sound
(eg. consider lots of drivers that share simmilar MTX_NETWORK_LOCK).

Solutions (for sound case):
  1) Provide unique mtx type string for each mutex creation (chosen)
  or
  2) Put "sound softc" global variable somewhere and use it.
2007-03-15 16:41:27 +00:00
Ariff Abdullah
7a5897d4d9 Remove NULL allocation checking since malloc() is allow to wait.
(I'll fix other places later..)
2007-03-15 15:06:54 +00:00
Ariff Abdullah
8c0a77e3d3 NULL instead of 0 in mtx_init() . 2007-03-15 14:57:54 +00:00
Ariff Abdullah
0585c315b7 Add AC97 inverted external amplifier quirk for ASUS A6R laptop.
PR:		kern/110244
MFC after:	3 days
2007-03-13 15:20:33 +00:00
Ariff Abdullah
c0dc2ab241 Fix analog CD connectivity. HP decided to screw pinconfig settings in
their latest Compaq V3000 BIOS (revision F.22). As a result, analog CD
connectivity is gone to the oblivion. Even if they decide to fix it in
future revisions, the damage has been done.
2007-03-11 15:26:49 +00:00
Ariff Abdullah
018b991e1d Fix long standing multi playback/recording issues, caused by
excessive interrupt clock timer reset, screwing interrupt generation
for already active channels. Track moving DMA pointer and call buffer
interrupt on each blocksize boundary.

PR:		kern/109791
MFC after:	3 days
2007-03-09 05:35:20 +00:00
Kevin Lo
32d6c6993c Use M_NOWAIT instead of M_WAITOK to cause malloc() to return NULL. 2007-03-07 05:28:42 +00:00
Ariff Abdullah
f0c4d27278 Enable tone / 3D controls for YAMAHA YMF743, 753 and 752 (partially).
PR:		kern/109599
Submitted by:	Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
2007-03-06 02:36:54 +00:00
Ariff Abdullah
9622f4d439 Quick bandaid for possible broken multiple playback channels implementation.
Reported/Tested by:	Oliver Iberien <odilist@sonic.net>
2007-03-05 07:45:38 +00:00
Alexander Leidinger
8f981688dd semi-automatic style(9) 2007-02-25 13:51:52 +00:00
Ariff Abdullah
b88d63a8ea Fix ALC883 microphone / recording issues. Setting high(er) VRef on
(external) microphone pin tend to screw it. Internal microphone (found
on several laptops) still need high VRef.

Tested by:	Pietro Cerutti <pietro.cerutti@gmail.com>
          	lenix <irc.freenode.net>
2007-02-25 06:17:56 +00:00
Ariff Abdullah
5583760956 - Revert arguments for several functions to pre bus_get_dma_tag()
changes. Each softc contains information about their own device_t,
  use that instead.
- bus_setup_intr() -> snd_setup_intr().
2007-02-23 19:41:16 +00:00
Ariff Abdullah
2cc08b748c - Compile time compatibility for pre/post newbus API (intr filter)
changes. This should ease the job of maintaining codebase since much
  of the regression tests are done across os versions.
- bus_setup_intr() -> snd_setup_intr().
2007-02-23 19:40:13 +00:00
Ariff Abdullah
78bb065b84 Use snd_setup_intr() instead of bus_setup_intr() , like other drivers. 2007-02-23 19:39:06 +00:00
Alexander Leidinger
0b989078d7 MFp4 (114068):
Use bus_get_dma_tag() to obtain the parent DMA tag to make the drivers
        a little bit more non-ia32/amd64 friendly.

        There is no man page for bus_get_dma_tag, so this is modelled after
        rev. 1.62 of src/sys/dev/sound/pci/es137x.c by marius.

        Inspired by:	commit by marius
2007-02-23 13:47:34 +00:00
Paolo Pisati
ef544f6312 o break newbus api: add a new argument of type driver_filter_t to
bus_setup_intr()

o add an int return code to all fast handlers

o retire INTR_FAST/IH_FAST

For more info: http://docs.freebsd.org/cgi/getmsg.cgi?fetch=465712+0+current/freebsd-current

Reviewed by: many
Approved by: re@
2007-02-23 12:19:07 +00:00