Commit Graph

909 Commits

Author SHA1 Message Date
Ariff Abdullah
facebb04a5 Add device ID for nForce 410 MCP audio controller.
PR:		kern/95257
Submitted by:	cenix <cenixxx at gmail dot com>
MFC after:	3 days
2006-04-03 17:37:27 +00:00
Ariff Abdullah
a1d444e140 MEGA Fixes / Cleanup
--------------------

- Seal the fate of long standing memory leak (4 years, 7 months) during
  pcm_unregister(). While destroying cdevs, scan / detect possible
  children and free its SLIST placeholder properly.
- Optimize channel allocation / numbering even further. Do brute cyclic
  checking only if the channel numbering screwed.
- Mega vchan create/destroy cleanup:
  o Implement pcm_setvchans() so everybody can use it freely instead
    of implementing their own, be it through sysctl or channel auto
    allocation.
  o Increase vchan creation/destruction resiliency:
    + it's possible to increase/decrease total vchans even during
      busy playback/recording. Busy channel will be left alone, untouched.
      Abusive test sample:
      # play whatever...
      #
         while : ; do
           sysctl hw.snd.pcm0.vchans=1
           sysctl hw.snd.pcm0.vchans=10
           sysctl hw.snd.pcm0.vchans=100
           sysctl hw.snd.pcm0.vchans=200
         done
      # Play something else, leave above loop running frantically.
    + Seal another 4 years old bug where it is possible to destroy (virtual)
      channel even when its cdevs being referenced by other process.
      The "First Come First Served" nature of dsp_clone() is the main
      culprit of this issue, and usually manifest itself as dangling
      channel <-> process association. Ensure that all of its cdevs
      are free from being referenced before destroying it (through
      ORPHAN_CDEVT() macross).

All these fixes (including previous fixes) will be MFCed, later.
2006-03-31 10:36:36 +00:00
Ariff Abdullah
9c271eba78 - Increase snddev refcount earlier while accessing through sysctl interface
to avoid possible device unregister race (impossible to reproduce, yet
  possible).
- Extra sanity check to ensure proper parent channel is being selected.
- Reset parent channel once all of its children gone.
2006-03-31 10:27:47 +00:00
Ariff Abdullah
844f9220aa Remove paranoid thread hijacking check. It cause wierd behaviour
(dangling channel - process association) especially in threaded
or fork()ed apps.
2006-03-30 06:17:03 +00:00
Ariff Abdullah
6d52c3bf33 Don't set primary resume interrupt flag during channel initialization
since it can cause high interrupt rate (storm) and slowdown the entire
system.

Note: Please report back to me if this commit cause any abnormal
      behaviour, especially during suspend / resume.

Reported/Submitted by:	[1] Daan Vreeken [PA4DAN] <Danovitsch_at_vitsch dot net>
Reported/Confirmed by:	[2] Angka H. K. <harikurniawan at gmail dot com>

MFC after:		5 days

[1] http://lists.freebsd.org/mailman/htdig/freebsd-hackers/2004-December/009335.html
[2] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-March/003830.html
2006-03-22 22:24:23 +00:00
Ariff Abdullah
f2a1d71aaa Misc. fixups:
- [1] Make the driver friendly towards kernel without PREEMPTION.
  Use msleep(9) instead of simple unlock-check_variable-lock mechanisme
  since the later not really effective in non-preemptible kernel
  (especially during codec detection routine).
- Free most driver resources in a sane manner to avoid possible
  double free and panics especially during device detach and codec
  detection failure.

MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-questions/2006-March/116515.html
2006-03-22 21:29:47 +00:00
Ariff Abdullah
b422186846 We shouldn't really care about the return value of mixer_uninit(),
except EBUSY.
2006-03-22 20:50:04 +00:00
Ariff Abdullah
c17cb0c68f Pointer align should be generic enough to handle awkward byte size
especially for true 24bit format.
2006-03-22 00:34:17 +00:00
Ariff Abdullah
3fdb3676ba Apply more thorough fixes while dealing with device opening and closing:
- Determine open direction using 'flags', not 'mode'. This bug exist since
  past 4 years.
- Don't allow opening the same device twice, be it in a same or different
  direction.
- O_RDWR is allowed, provided that it is done by a single open (for example
  by mixer(8)) and the underlying hardware support true full-duplex operation.
- Do various paranoid checking in case other process/thread trying to hijack
  the same device twice (or more).

MFC after:	5 days
2006-03-21 06:35:48 +00:00
Ariff Abdullah
02dbda9d17 Recover (?) support for AD1815 based ISA soundcards.
PR:		kern/94388
Submitted by:	Krzysztof Kotlenga <piernik at gmail dot com>
MFC after:	3 days
2006-03-21 03:47:25 +00:00
Ariff Abdullah
945510a039 Restore CHN_F_BUSY flag which was removed accidentally in previous commit. 2006-03-16 08:01:10 +00:00
Ariff Abdullah
7982e7a465 Fix severe 8bit integer overflow during channel creation and destruction,
especially for vchans. It turns out that channel numbering always depend
on d->devcount counter (which keep increasing), while PCMMKMINOR() truncate
everything to 8bit length. At some point the truncation cause the newly
created character device overlapped with the existence one, causing erratic
overall system behaviour and panic. Easily reproduce with something like:

	(Luckily, only root can reproduce this)

	while : ; do
		sysctl hw.snd.pcm0.vchans=200
		sysctl hw.snd.pcm0.vchans=100
	done

- Enforce channel/chardev numbering within 8bit boundary. Return E2BIG
  if necessary.
- Traverse d->channels SLIST and try to reclaim "free" counter during channel
  creation. Don't rely on d->devcount at all.
- Destroy vchans in reverse order.

Anyway, this is not the fault of vchans. It is just that vchans are so cute
and begging to be abused ;) . Don't blame her.

Old, hidden bugs.. sigh..

MFC after:	3 days
2006-03-16 04:12:49 +00:00
Ariff Abdullah
ead3cc4315 Add another inverted amplifier sense quirk for Kvazar-Micro Senator 3592XT.
Submitted by:	[1] Alexandr Krivulya <admin at marcom-group.com>
MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-March/003773.html
2006-03-07 05:48:14 +00:00
Ariff Abdullah
428feeb3b9 Add another inverted amplifier sense quirk for Sony VAIO Type T.
PR:		kern/94056
Submitted by:	Yoshihiko Sarumaru <mistral at imasy.or.jp>
MFC after:	3 days
2006-03-05 02:26:51 +00:00
Ariff Abdullah
df010ca869 Trim unnecessary pointer alignment. 2006-02-24 09:29:32 +00:00
John Baldwin
de49f3252c Remove some dead code.
Coverity ID:	822
Found by:	Coverity Prevent
Reviewed by:	ariff
MFC after:	1 week
2006-02-23 19:23:55 +00:00
Ariff Abdullah
050519958c - Fix severe crackling after long running and abusive module load / unload by
forcing DMA alignment to default buffer size.
- Make sure DMA pointer properly aligned to avoid being truncated by caller
  which causing severe underruns and random popping (especially in 32bit
  playback / recording).
- Add AC97 inverted external amplifier quirk for Maxselect x710s
  - http://maxselect.ru/

MFC after:	1 week
2006-02-18 10:24:48 +00:00
Ariff Abdullah
fba6b23875 Fix random popping while playing in 32bit by increasing default buffer size
from 4096 to 8192.

MFC after:	1 week
2006-02-18 10:23:37 +00:00
Ariff Abdullah
34733eb529 Fix possible DMA leak and locking violation especially
during suspend <-> resume and module load <-> unload.

PR:		kern/92764
MFC after:	3 days
2006-02-12 10:42:47 +00:00
Alexander Leidinger
9d978cc757 Convert NULL checks into KASSERT (and move them before the first
dereferencing) since a NULL value would be a bug here.

Note: Both affected functions look very similar. A refactoring may
be beneficial.

CID:		483, 485
Found with:	Coverity Prevent(tm)
Discussed with:	ariff
MFC after:	5 days
2006-02-05 17:47:26 +00:00
Alexander Leidinger
cd9de7ee61 A pointer was checked for NULL after dereferencing it. The check is not
needed here, except there's a bug which results in detaching the device
twice.

Move the NULL pointer check to the beginning of the function and convert
it into a KASSERT.

CID:		420
Found with:	Coverity Prevent(tm)
Discussed with:	ariff
MFC after:	5 days
2006-02-05 17:33:18 +00:00
Alexander Leidinger
f31eef8b22 Fix memory leak in some failure cases.
CID:		420
Found with:	Coverity Prevent(tm)
2006-02-05 17:10:52 +00:00
Alexander Leidinger
c8c4c87d6a Fix some potential NULL pointer dereferences.
This is supposed to fix some Coverity Prevent errors (Ariff didn't
looked at the CID's (ENOTIME), I just told him that there are some problems
in function dsp_ioctl()).

CID:		215-218
Found with:	Coverity Prevent(tm)
Submitted by:	ariff
MFC after:	5 days
2006-01-29 16:48:41 +00:00
Ariff Abdullah
4a193ac907 Tune format scoring so (non)stereo format will get better chance
to be selected.
2006-01-29 01:32:37 +00:00
Ariff Abdullah
86b391b2e1 Enable full duplex operation since it works and to solve panic issue.
PR:		kern/91992
MFC after:	2 days
2006-01-27 02:01:27 +00:00
Joel Dahl
da8623eca0 Fix typos and clean up some comments.
Approved by:	ariff
2006-01-25 21:13:46 +00:00
Ariff Abdullah
14665331ab channel.c:
(1) Fix DMA alignment, based on bytes per sample.

feeder_rate.c:
	Handle strayed bytes (mostly caused by #1) better.

This DMA alignment issues are extremely hard to reproduce unless
the user happen to have a 32bit capable soundcards (ATI IXP) and
knowledgeable enough to force it to operate under pure 32bit
operations on both record and play directions.
2006-01-24 01:10:07 +00:00
Joel Dahl
ae75448fcd Sort list of modules.
Approved by:	ariff
2006-01-23 11:58:01 +00:00
Ariff Abdullah
d9bd844573 Various fixups:
feeder.h:
 feeder.c:
	- Implement scoring mechanisme to select best format for conversion.
	  This is actually part of newer format chaining procedures which
	  will be commited someday. Confusion during chaining process solved
	  by this scoring since it will try to reduce list of from/to formats
	  to a single, best format.
	  Related PR:	kern/91683
channel.c:
	- Simplify feeder building process since we have smarter format
	  chaining.

feeder_fmt.c:
	- Add few more sign conversion feeders for 24 and 32 bit format.

feeder_rate.c:
	- Force buffer / bytes allignment. Unaligned buffer may cause
	  panics during recording on pure 32bit sample format if it
	  involves feeder_rate as part of feeders chain.
	  Tested on: ATI IXP, force 32bit recording.

MFC after:	5 days
2006-01-22 15:06:49 +00:00
Alexander Leidinger
5f35685cc2 Backput the "Dell ID" part of the last commit, it was already tried in
the past but didn't worked.

Noticed by:	Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
2006-01-21 16:21:06 +00:00
Alexander Leidinger
30baa78df4 Merge rev. 1.5 and 1.6 from DFly:
- Add PCI identifier to match against a Dell OEM version of the SB Live!
 - Fix spurious warning about ANSI trigraphs

Obtained from:	DragonFlyBSD
2006-01-21 15:23:15 +00:00
Alexander Leidinger
a7571c3f6b Prevent dereferencing a NULL pointer if the malloc() fails.
CID:		219
Found with:	Coverity Prevent(tm)
2006-01-21 11:50:56 +00:00
Joel Dahl
16451fc93a Remove unused pointer.
Approved by:	ariff
2006-01-21 09:05:13 +00:00
Ariff Abdullah
8815a86933 Turn on native 32bit recording (at 48000hz).
It works perfectly on my Compaq Presario M2000Z, but my last attempt
on Acer Ferrari 4000 only produce garbled sound.

MFC after:	3 days
2006-01-20 19:35:44 +00:00
Ariff Abdullah
9ca45dd7dc Ruthless vchan speed workaround against the dreaded sb16 / sb16x. It appear
that nothing else using this weird 45k / 49k speed upper limit.
2006-01-20 03:46:02 +00:00
Ariff Abdullah
4aee05133b Remove Giant / busdma_lock_mutex from busdma_tag_create(). 2006-01-18 01:01:37 +00:00
Ariff Abdullah
d8f1a170d9 Fix broken capabilites. There are possible calculation errors within
ess_calcspeed8() and ess_calcspeed9() that need to be fixed as well
(TODO).

Reported by:	[1] Claude Buisson <cbuisson at nerim.net>
MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-January/003566.html
2006-01-16 20:01:33 +00:00
Ariff Abdullah
2fd8d3d84e Restore old compatibility of feeding directly into /dev/dsp at 8000 hz
while preserving the New World Order.

Discussed with:	[1] Michael W. Oliver <michael at gargantuan.com>
MFC after:	1 week

[1] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-January/003562.html
2006-01-16 11:07:15 +00:00
Ariff Abdullah
f432c562bf Add another inverted EAPD quirk for Gateway 7326GZ.
Tested by:	Jeff Cross <jeff.cross at averageadmins.com>
MFC after:	3 days
2006-01-14 23:37:08 +00:00
Ariff Abdullah
97efeca38d Workaround for sb16 behave poorly when running at 45000 hz while
vchan is enabled.

Reported by:	many sb16, AWE64 users.
MFC after:	1 week
2006-01-13 18:10:43 +00:00
Ariff Abdullah
8c437e077b Joyport blacklist. Either we're facing with broken hardware
or because this hardware need special (unknown) initialization
procedures.

Reported by:	[1] Rob Clark <vx2 at tds.net>
MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-January/003535.html
2006-01-13 04:54:34 +00:00
Ariff Abdullah
1738f66243 Fix broken playback capabilities to prevent impending disaster.
The minimum / maximum speed was way too low / high!

minspeed =   2000 - is this for real ?
maxspeed = 767999 - is this for real ?????

Wrap everything into 8000 - 48000 boundary, just to be safe.

MFC after:	3 days
2006-01-11 23:22:57 +00:00
Ariff Abdullah
40c012dd6d - Locking fixes. Release lock while chn_intr().
- Mark MPSAFE since most of the locking procedures already implemented.
- Turn on inverted external amplifier sense flag for selected boards.

Tested by:	bland
MFC after:	1 week
2006-01-11 08:02:15 +00:00
Ariff Abdullah
c02b454deb More thorough fixes to enable inverted external amplifier sense flag.
Instead of dragging the entire ICH4/82801DB into this mess, select
only few boards based on pci subdevice / subvendor.

Tested by:	Daisuke Orikasa <luxury-acura-3.5rl at nifty.com>
MFC after:	3 days
2006-01-10 06:52:59 +00:00
Ariff Abdullah
be0fee94a7 Turn on inverted external amplifier sense flags for ICH4/82801DB.
PR:		kern/66422, kern/75687, kern/84471
MFC after:	2 days
2006-01-09 11:20:37 +00:00
Ariff Abdullah
7659fda352 Fix obvious capabilities (rate) violation. Should be 5500, not 4000.
MFC after:	1 day
2006-01-09 06:05:25 +00:00
Ariff Abdullah
e1e05d5d12 Add codec id support for Analog Device AD1986 AC'97 codec.
Submitted by:	UMENO Takashi <umeno at rr.iij4u.or.jp>
PR:		kern/80234
MFC after:	2 days
2006-01-07 05:20:46 +00:00
Ariff Abdullah
1332ddcb64 Fix locking violation, causing frantic diagnostic messages during boot.
Reported by:	[1] julian
MFC after:	3 days

[1] http://lists.freebsd.org/pipermail/freebsd-multimedia/2006-January/003408.html
2006-01-06 10:36:55 +00:00
Ariff Abdullah
8b6d3fe1b6 Another major fixes and enhancements:
- MPSAFE
    - Fix / reorganize attach routine. Device specific initialization must
      be done after generic bus / DMA setup. At last, Virtual Channels
      (vchan) works as expected.

Note: Recent commit / fix against this driver proves that major enhancements
      on the generic sound layer does indeed help to expose flaw within
      device specific code. There are probably other drivers that need to
      be addressed as well.

Tested by:	barner
MFC after:	1 week
2006-01-06 05:04:18 +00:00
Ariff Abdullah
1333b4a431 Fix broken capabilities, causing failure during channel reset.
Its min/max speed were off by -/+ 1000.

Reported by:	[1] Ion-Mihai Tetcu <itetcu@people.tecnik93.com>
            	[2] barner
MFC after:	1 day

[1] http://lists.freebsd.org/mailman/htdig/freebsd-multimedia/2005-December/003189.html
[2] http://lists.freebsd.org/mailman/htdig/freebsd-multimedia/2006-January/003422.html
2006-01-04 15:35:55 +00:00