Commit Graph

1109 Commits

Author SHA1 Message Date
Ariff Abdullah
8a7c4d36cb Fix stream suspend/resume activity due to its states being
clobbered by pcm channel start/stop trigger operation.

Approved by:	re (hrs)
2007-07-09 20:41:23 +00:00
Ariff Abdullah
36bc8661bf Properly unlock mutex before returning. There was a slight mishap
during last major locking cleanup.

Reported by:	Thierry Herbelot <thierry@herbelot.com>
Approved by:	re (mux)
2007-07-05 10:22:37 +00:00
Ariff Abdullah
a5b0e31251 Be much more forgiving towards applications that requesting ioctls
that should be a no-op (for example, requesting SYNC on record path).
The standards does not indicate that such requests are illegal, so
just return it as success instead of EINVAL.

Approved by:	re (mux)
2007-07-04 12:33:11 +00:00
Ariff Abdullah
e5ad83a7e3 - Fix input/microphone support for ASUS A8N-VMCSM series.
Submitted by:	Simon Schubert <corecode@fs.ei.tum.de>

- Defer flushing unsolicited response into taskqueue thread rather
  than handle it directly in interrupt handler, since few of its
  operations (like measuring/calibrating jack impedance) are quite
  expensive.
- Misc. debugging cleanups.

Tested by:	joel
Approved by:	re (hrs)
MFC after:	3 days
2007-07-01 17:31:20 +00:00
Ariff Abdullah
6cf06ec6b1 Fix no-sound issues with ASUS A9T notebook.
Note: The offending quirk should have been made model/codec specific,
but since there were no records / log which model requires it, the quirk
logic had to be inverted (blacklist instead of whitelist).

Tested by:	Arkadiy Dudevitch <dudevitch@englerllc.com>
Approved by:	re (hrs)
MFC after:	3 days
2007-07-01 17:28:58 +00:00
Warner Losh
7bd250d818 s/logprintf/printf/g
Approved by: re@
2007-06-20 05:11:37 +00:00
Ariff Abdullah
715ed548ab Fix headphone jack sensing support for Olivetti Olibook 610-430 XPSE.
Tested by:	Gonzalo Lionel Rodriguez
2007-06-18 22:39:27 +00:00
Warner Losh
528fb030b3 Explicitly use usb_port.h to get compat macros. 2007-06-18 22:26:41 +00:00
Ariff Abdullah
838d35891f Spelling nit due to my lamenglishness.
Noticed by:	brueffer
2007-06-17 19:02:05 +00:00
Ariff Abdullah
ad8612b97a Add sysctl/tunable "hw.snd.default_auto", which is useful (especially
for non-root users) to automatically assign default unit to a newly
attach device like USB audio.
2007-06-17 16:15:56 +00:00
Ariff Abdullah
f368584146 Reassign default unit to a valid unit, be it during attach or detach.
If nothing is available, set to something that is purely ridiculous
so the next valid attach will notice it.

Tested by:	chibis
2007-06-17 15:53:11 +00:00
Ariff Abdullah
082f63835c Flush remaining malloc() cleanups (M_NOWAIT -> M_WAITOK). 2007-06-17 06:10:43 +00:00
Ariff Abdullah
c17bfa7714 Use signed int, since all the samples are in that form.
This will help future implementation of soft amplifier
with variable/relative 0db.
2007-06-16 20:36:39 +00:00
Ariff Abdullah
e4e61333ff Last (again ?!?) major commit for RELENG_7, featuring total Giant
eradication in/from userland path, countless locking fixes, etc.

- General sleep call through msleep(9) has been converted to condvar(9)
  with better consistencies.
- Heavily guard every possible "slow path" entries (open(), close(),
  few ioctl()s, sysctls), but once it entering "fast path" (io, interrupt
  started), they are free to fly on their own.
- Rearrange locking sequences, resulting better concurrency and
  serialization. Large part doesn't even need locking at all, and will be
  removed in future. Less clutter, except in few places due to lock
  ordering.
- Anonymous mixer object creation/deletion to simplify mixer handling
  beyond typical mixer ioctls.
  Submitted by:		chibis (with modifications)
- Add few mix_[get|set|..] functions to avoid calling mixer_ioctl()
  directly using cryptic arguments.
- Locking fixes to avoid possible deadlock with (still under Giant) USB.
- Better simplex/duplex device handling.
- Recover mmap() functionality for recording, which has been lost
  since 2.2.x - 3.x (the introduction of newpcm). Full-duplex mmap still
  doesn't work (due to VM/page design), but people still can mmap
  both by opening each direction separately. mmaped playback is guarantee
  to work either way.
- New sysctl: "hw.snd.compat_linux_mmap" to allow PROT_EXEC page
  mapping, due to recent changes in linux compatibility layer which
  require it. All linux applications that using sound + mmap() (mostly games)
  require this to be enabled. Disabled by default.
- Other goodies.. too many, that will increase releng7 shareholder value
  and make users of releng6 (and below) cry ;)

* This commit should be atomic. If anything goes wrong (not counting problem
  originated from elsewhere), I will not hesitate to revert everything back
  within 12 hours. This substantial changes itself not a rocket science
  and the process has begun for almost 2 years, and lots of incremental
  changes are already in place during that period of time.
* Some issues does occur in snd_emu10kx (note the 'x') due to various
  internal locking issues and it is currently being worked on by chibis.

Tested by:	chibis (Yuriy Tsibizov), joel, Alexandre Vieira,
          	many innocent souls...
2007-06-16 03:37:28 +00:00
Ariff Abdullah
504e00af6b Buffer optimization and locking cleanup. Don't resize/malloc
unless it is really necessary to ease down unlock/lock sequence.
2007-06-14 11:15:51 +00:00
Ariff Abdullah
5d75db4f00 Drain all callout handlers during driver detach appropriately. 2007-06-14 11:13:38 +00:00
Ariff Abdullah
79b783c721 Don't push too hard waiting/looping for codec detection interrupt.
Let the interrupt do the job waking us up.
2007-06-14 11:11:06 +00:00
Ariff Abdullah
553dc5c78c - Add option to allow sleeping malloc(9).
- Cleanup locking assertions that aren't needed anymore.
2007-06-14 11:10:21 +00:00
Warner Losh
645016c0e4 Expand USB_ATTACH_{ERROR,SUCCESS}_RETURN inline and eliminate from
usb_port.h.  They aren't needed, and are a legacy of this code's past.
2007-06-12 15:37:19 +00:00
Ariff Abdullah
bdfbdcec6a Filter/compress the amount of channel trigger. This should reduce
much of lock/unlock contentions within the interrupt handler. Most
of these drivers only need PCMTRIG_START or STOP (ABORT).

Discussed with:		scottl
2007-06-11 00:49:46 +00:00
Ariff Abdullah
f6cdab92db - Add codec id for ALC660 [1]
- Add codec id for AD1988B, along with fixing its line-in and other
  issues (with proper quirks). [2]

Submitted by:	[1] barbara.xxx1975@libero.it
             	[2] Oliver Brandmueller ob@e-Gitt.NET
MFC after:	3 days
2007-06-10 23:01:40 +00:00
Matt Jacob
adb0d36d03 Cast len to be a uintmax_t and make format in KASSERT match so as
to avoid different sizes on different platforms types of complaints.

Reviewed by:	Ariff
2007-06-10 15:46:34 +00:00
Matt Jacob
471f8f34b5 Remove const type qualifier from a function- gcc4.2 doesn't accept it.
Reviewed by:	Ariff
2007-06-10 15:45:29 +00:00
Ruslan Ermilov
1f082787d4 Make this compile. 2007-06-09 11:07:07 +00:00
Warner Losh
8d58ce651f Expand USB_ATTACH_SETUP inline + devinfo tweaks
# looks like there's a chance that uaudio might compile on otherBSD, so leave
# those #defines alone as well as make this change in a compatible way.
2007-06-09 06:49:05 +00:00
Ariff Abdullah
69f6d261cf - Do triple reads on reset register to detect read register bug. 2 reads
seems not enough to verify its consistencies.
- Define AC97_MIXER_SIZE as SOUND_MIXER_NRDEVICES (25), since we
  don't need more than that. Stop doing wild and random guess about
  its size since we're stricly bound to it.
2007-06-05 20:30:16 +00:00
Ariff Abdullah
34b8e37073 Fix (enable) phone out for laptops with ALC655, specifically
for Amilo Pro V2055.

PR:		kern/113101
Submitted by:	konrad@egipt-medytacje.pl
MFC after:	3 days
2007-06-05 20:12:40 +00:00
David Malone
041b706b2f Despite several examples in the kernel, the third argument of
sysctl_handle_int is not sizeof the int type you want to export.
The type must always be an int or an unsigned int.

Remove the instances where a sizeof(variable) is passed to stop
people accidently cut and pasting these examples.

In a few places this was sysctl_handle_int was being used on 64 bit
types, which would truncate the value to be exported.  In these
cases use sysctl_handle_quad to export them and change the format
to Q so that sysctl(1) can still print them.
2007-06-04 18:25:08 +00:00
Ariff Abdullah
9c271f79d6 Insert NULL pointer checking around devclass_get_maxunit(pcm_devclass, ..) .
Things can get ugly without it due to uninitialized class. RELENG_6 need
a simmilar, but different treatment as well.

err.. perhaps we should teach devclass_get_maxunit() to return -1 ?

MFC after:	1 day
2007-06-03 10:56:22 +00:00
Ariff Abdullah
c1bf516f6e Remove (accidentally) included types.h . 2007-06-02 17:36:11 +00:00
Ariff Abdullah
e510f52136 Use standard pcm_get/setflags() rather than dereferencing softc while
enabling SD_F_SOFTPCMVOL or any flags.
2007-06-02 17:28:26 +00:00
Joel Dahl
e9577a5cd9 Separate license from comments.
Approved by:	ariff
2007-06-02 13:07:44 +00:00
Ariff Abdullah
bba4862c64 Last major commit and updates for RELENG_7:
- Rework the entire pcm_channel structure:
  * Remove rarely used link placeholder, instead, make each pcm_channel
    as head/link of each own/each other. Unlock - Lock sequence due to
    sleep malloc has been reduced.
  * Implement "busy" queue which will contain list of busy/active
    channels. This greatly reduce locking contention for example while
    servicing interrupt for hardware with many channels or when virtual
    channels reach its 256 peak channels.

- So I heard you like v chan ... O RLY?
  Welcome to Virtual **Record** Channels (vrec, rec vchans, vchans for
  recording, Rec-Chan, you decide), the ultimate solutions for your
  nagging O_RDWR full-duplex wannabe (note: flash plugins) monopolizing
  single record channel causing EBUSY.  Vrec works exactly like Vchans
  (or, should I rename it to "Vplay" :) , except that it operates on the
  opposite direction (recording). Up to 256 vrecs (like vchans) are
  possible.

  Notes:
   * Relocate dev.pcm.%d.{vchans,vchanformat,vchanrate} to each of its
     respective node/direction:
       dev.pcm.%d.play.* for "play"   (cdev = dsp%d.vp%d)
       dev.pcm.%d.rec.*  for "record" (cdev = dsp%d.vr%d)
   * Don't expect that it will magically give you ability to split
     "recording source" (eg: 1 channel for cdrom, 1 channel for mic,
     etc). Just admit that you only have a *single* recording source /
     channel. Please bug your hardware vendor instead :)

- Bump maxautovchans from 4 to 16. For a full-fledged multimedia
  desktop/workstation with too many soundservers installed (esound,
  artsd, jackd, pulse/polypaudio, ding-dong pling plong mudkip fuh fuh,
  etc), 4 seems inadequate. There will be no memory penalty here, since
  virtual channels are allocate only by demand.

- Nuke/Rework the entire statically created cdev entries. Everything is
  clonable through snd own clone manager which designed to withstand many
  kind of abusive devfs droids such as:
      * while : ; do /bin/test -e /dev/dsp ; done
      * jot 16777216 0 | while read x ; do ls /dev/dsp0.$x ; done
      * hundreds (could be thousands) concurrent threads/process opening
	"/dev/dsp" (previously, this might result EBUSY even with just
	3 contesting threads/procs).
  o Reusable clone objects (instead of creating new one like there's no
    tomorrow) after certain expiration deadline. The clone allocator will
    decide whether to reuse, share, or creating new clone.
  o Automatic garbage collector.

- Dynamic unit magic allocator. Maximum attached soundcards can be tuned
  using tunable "hw.snd.maxunit" (Default to 512). Minimum is 16, and
  maximum is 2048.

- ..other fixes, mostly related to concurrency issues.

joel@ will do the manpage updates on sound(4).

Have fun.
2007-05-31 18:43:33 +00:00
Ariff Abdullah
f03f99e35f Last major commit and updates for RELENG_7:
Add few new files. The _real_ commit will follow shortly, so fasten
up your seatbelts, sit back and enjoy the ride..
2007-05-31 18:35:24 +00:00
Ariff Abdullah
4257f25c06 Don't rely on pcm_channel index numbering while doing sequential channel
allocation.
2007-05-30 16:15:01 +00:00
Ariff Abdullah
2ba5e1edcc - Enable soft pcm volume flag early to ensure it not being clobbered
by the subsequent mix_setdevs() and friends.
- Minor style(9) declaration arrangement nit.

Requested by:	joeld
Submitted by:	pluknet <pluknet@gmail.com>
2007-05-28 16:22:07 +00:00
Ariff Abdullah
832345319a Fix broken "rec" and "igain" introduced by previous commit. Convert
reg to a full blown int since there's not much gain compacting it,
and we do need its signess.
2007-05-28 14:09:06 +00:00
Ariff Abdullah
79462204f1 Fix broken binary issues with latest gcc 4.x due to bitfield signess
mishaps for emu10k1 [1] and few other places.

Reported/Submitted/Tested by:	Ed Schouten <ed@fxq.nl> [1]
2007-05-27 20:12:51 +00:00
Joel Dahl
ccb43d8d2c Bring in a bunch of bug fixes and some code to support more chipsets.
Neither me nor Ariff have access to any of this hardware, so all tests
have been made by Konstantin and Artem.  Commit message mostly written
by Konstantin.

envy24:
- Add test code to support rear line-in input on 'Terratec DMX 6fire'
  audio card.  This code is also intended to be used in the future for
  support of cards, that have I2C-to-GPIO expanders wired between the
  control line of the audio codec and the Envy24, however such cards
  are too complex and i can't add that support without hardware sample
  of such board, i've already tried and failed.

envy24ht:
- Add support for 'AudioTrak Prodigy HD2'.
- Add support for 'AudioTrak Prodigy 7.1 XT'.
- Add support for 'ESI Juli@' (Works ok, DAC volume is hard-coded for
  the time being, so 'mixer vol ...' doesn't work, only 'mixer pcm
  ...' works). [1]
- Fix bug in the init data for M-Audio Revolution 5.1, that
  results in distorted sound.
- Add software volume control (now 'mixer pcm' works, thanks to Ariff).
- Add support for more samples rates - 176.4kHz and 192kHz.
- Fix problem with the 192kHz samples rate playback when 24.576MHz
  crystal is used on the board instead of 49.152MHz crystal.

spicds:
- Add support for Asahi Kasei flagship DAC - AK4396 (used in AudioTrak
  Prodigy HD2).

Submitted by:	Konstantin Dimitrov <kosio.dimitrov@gmail.com>
Tested by:	Artem Antonov [1]
Reviewed by:	ariff
2007-05-27 19:58:39 +00:00
Joel Dahl
ea18b1d925 Fix randomly broken playback with Fortemedia FM801 XWave PCI soundcard.
PR:		kern/98898
Submitted by:	Johannes Weiner <hnazfoo@googlemail.com>
Approved by:	ariff
2007-05-19 13:19:32 +00:00
Joel Dahl
03756ceff7 Turn off the AK452X De-emphasis filter for 44.1KHz. This should fix some
sound quality problems.

PR:		kern/112688
Submitted by:	Stefan Ehmann <shoesoft@gmx.net>
Reviewed by:	Konstantin Dimitrov <kosio.dimitrov@gmail.com>
Approved by:	ariff
2007-05-19 11:06:43 +00:00
Joel Dahl
ecdbb0d42b Fix detection of PC-9821 V166 internal sound card.
PR:		kern/105600
Submitted by:	rotus <rotus@takamanohara.dyndns.org>
Approved by:	ariff
2007-05-19 10:53:01 +00:00
Ariff Abdullah
a6f9c6fb5f Don't hold mutex while releasing bus resources. 2007-05-10 01:46:51 +00:00
Ariff Abdullah
64a113269c buf_addr should be bus_addr_t rather than u_int32_t. 2007-05-07 02:46:48 +00:00
Ariff Abdullah
0e86bad6e3 PCMMKMINOR() bit twiddling, so we can have:
- 2048 unique sound cards (dsp0 -> dsp2047)
    (used to be 15)
  - 32 unique device types  (dspW, audio, mixer, sndstat, .. 32th)
    (used to be 15)
  -  256 unique cloneable devices (dsp%d.0 -> dsp%d.255)
    (unchanged)
2007-05-06 16:46:23 +00:00
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