Commit Graph

250 Commits

Author SHA1 Message Date
Yoshihiro Takahashi
2b375b4edd Remove pc98 support completely.
I thank all developers and contributors for pc98.

Relnotes:	yes
2017-01-28 02:22:15 +00:00
Pedro F. Giffuni
73a1170a8c sys/dev: use our nitems() macro when it is avaliable through param.h.
No functional change, only trivial cases are done in this sweep,
Drivers that can get further enhancements will be done independently.

Discussed in:	freebsd-current
2016-04-19 23:37:24 +00:00
Pedro F. Giffuni
87d8fcc80e Replace 0 with NULL for pointers in misc. device drivers.
Found with devel/coccinelle.
2016-04-12 17:23:03 +00:00
Justin Hibbits
da1b038af9 Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.
On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit.  This extends rman's resources to uintmax_t.  With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).

Why uintmax_t and not something machine dependent, or uint64_t?  Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures.  64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead.  That being said, uintmax_t was chosen for source
clarity.  If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros.  Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros.  Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.

Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)

Tested PAE and devinfo on virtualbox (live CD)

Special thanks to bz for his testing on ARM.

Reviewed By: bz, jhb (previous)
Relnotes:	Yes
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544
2016-03-18 01:28:41 +00:00
Justin Hibbits
c47476d7e6 Migrate many bus_alloc_resource() calls to bus_alloc_resource_anywhere().
Most calls to bus_alloc_resource() use "anywhere" as the range, with a given
count.  Migrate these to use the new bus_alloc_resource_anywhere() API.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D5370
2016-02-27 03:38:01 +00:00
Justin Hibbits
2dd1bdf183 Convert rman to use rman_res_t instead of u_long
Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources.  For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by:	Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075
2016-01-27 02:23:54 +00:00
Baptiste Daroussin
775fcb6e63 Remove check for obsolete FreeBSD versions
PR:		194517
Submitted by:	François Tigeot <ftigeot@wolfpond.org>
2014-11-03 11:11:45 +00:00
Marius Strobl
4b7ec27007 - There's no need to overwrite the default device method with the default
one. Interestingly, these are actually the default for quite some time
  (bus_generic_driver_added(9) since r52045 and bus_generic_print_child(9)
  since r52045) but even recently added device drivers do this unnecessarily.
  Discussed with: jhb, marcel
- While at it, use DEVMETHOD_END.
  Discussed with: jhb
- Also while at it, use __FBSDID.
2011-11-22 21:28:20 +00:00
Ariff Abdullah
90da2b2859 Sound Mega-commit. Expect further cleanup until code freeze.
For a slightly thorough explaination, please refer to
	[1] http://people.freebsd.org/~ariff/SOUND_4.TXT.html .

Summary of changes includes:

1 Volume Per-Channel (vpc).  Provides private / standalone volume control
  unique per-stream pcm channel without touching master volume / pcm.
  Applications can directly use SNDCTL_DSP_[GET|SET][PLAY|REC]VOL, or for
  backwards compatibility, SOUND_MIXER_PCM through the opened dsp device
  instead of /dev/mixer.  Special "bypass" mode is enabled through
  /dev/mixer which will automatically detect if the adjustment is made
  through /dev/mixer and forward its request to this private volume
  controller.  Changes to this volume object will not interfere with
  other channels.

  Requirements:
    - SNDCTL_DSP_[GET|SET][PLAY|REC]_VOL are newer ioctls (OSSv4) which
      require specific application modifications (preferred).
    - No modifications required for using bypass mode, so applications
      like mplayer or xmms should work out of the box.

  Kernel hints:
    - hint.pcm.%d.vpc (0 = disable vpc).

  Kernel sysctls:
    - hw.snd.vpc_mixer_bypass (default: 1).  Enable or disable /dev/mixer
      bypass mode.
    - hw.snd.vpc_autoreset (default: 1).  By default, closing/opening
      /dev/dsp will reset the volume back to 0 db gain/attenuation.
      Setting this to 0 will preserve its settings across device
      closing/opening.
    - hw.snd.vpc_reset (default: 0).  Panic/reset button to reset all
      volume settings back to 0 db.
    - hw.snd.vpc_0db (default: 45).  0 db relative to linear mixer value.

2 High quality fixed-point Bandlimited SINC sampling rate converter,
  based on Julius O'Smith's Digital Audio Resampling -
  http://ccrma.stanford.edu/~jos/resample/.  It includes a filter design
  script written in awk (the clumsiest joke I've ever written)
    - 100% 32bit fixed-point, 64bit accumulator.
    - Possibly among the fastest (if not fastest) of its kind.
    - Resampling quality is tunable, either runtime or during kernel
      compilation (FEEDER_RATE_PRESETS).
    - Quality can be further customized during kernel compilation by
      defining FEEDER_RATE_PRESETS in /etc/make.conf.

  Kernel sysctls:
    - hw.snd.feeder_rate_quality.
      0 - Zero-order Hold (ZOH).  Fastest, bad quality.
      1 - Linear Interpolation (LINEAR).  Slightly slower than ZOH,
          better quality but still does not eliminate aliasing.
      2 - (and above) - Sinc Interpolation(SINC).  Best quality.  SINC
          quality always start from 2 and above.

  Rough quality comparisons:
    - http://people.freebsd.org/~ariff/z_comparison/

3 Bit-perfect mode.  Bypasses all feeder/dsp effects.  Pure sound will be
  directly fed into the hardware.

4 Parametric (compile time) Software Equalizer (Bass/Treble mixer). Can
  be customized by defining FEEDER_EQ_PRESETS in /etc/make.conf.

5 Transparent/Adaptive Virtual Channel. Now you don't have to disable
  vchans in order to make digital format pass through.  It also makes
  vchans more dynamic by choosing a better format/rate among all the
  concurrent streams, which means that dev.pcm.X.play.vchanformat/rate
  becomes sort of optional.

6 Exclusive Stream, with special open() mode O_EXCL.  This will "mute"
  other concurrent vchan streams and only allow a single channel with
  O_EXCL set to keep producing sound.

Other Changes:
    * most feeder_* stuffs are compilable in userland. Let's not
      speculate whether we should go all out for it (save that for
      FreeBSD 16.0-RELEASE).
    * kobj signature fixups, thanks to Andriy Gapon <avg@freebsd.org>
    * pull out channel mixing logic out of vchan.c and create its own
      feeder_mixer for world justice.
    * various refactoring here and there, for good or bad.
    * activation of few more OSSv4 ioctls() (see [1] above).
    * opt_snd.h for possible compile time configuration:
      (mostly for debugging purposes, don't try these at home)
        SND_DEBUG
        SND_DIAGNOSTIC
        SND_FEEDER_MULTIFORMAT
        SND_FEEDER_FULL_MULTIFORMAT
        SND_FEEDER_RATE_HP
        SND_PCM_64
        SND_OLDSTEREO

Manual page updates are on the way.

Tested by:	joel, Olivier SMEDTS <olivier at gid0 d org>, too many
          	unsung / unnamed heroes.
2009-06-07 19:12:08 +00:00
Kevin Lo
976b010645 Spelling fix for interupt -> interrupt 2007-10-12 06:03:46 +00:00
Ariff Abdullah
082f63835c Flush remaining malloc() cleanups (M_NOWAIT -> M_WAITOK). 2007-06-17 06:10:43 +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
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
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
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
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
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
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
Joel Dahl
155414e2e4 Remove dead email address.
Requested by:	luigi
2007-02-02 13:44:09 +00:00
Joel Dahl
a0afd24d9c Clean up the BSD license to match the preferred license in
/usr/share/examples/etc/bsd-style-copyright.  I've fixed a
few minor wording and formatting differences.

Approved by:	luigi, Hannu Savolainen <hannu@opensound.com>
2007-02-02 13:39:20 +00:00
Joel Dahl
262e034444 Add a standard BSD license to these files.
Discussed with:	rwatson
Approved by:	luigi
2007-02-02 13:33:35 +00:00
John Baldwin
73dbd3da73 Remove various bits of conditional Alpha code and fixup a few comments. 2006-05-12 05:04:46 +00:00
John Baldwin
3e20eaf592 Remove the snd_ess identify routine for the sound device in Alpha PWS
machines.
2006-05-12 04:11:25 +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
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
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
33291bca01 Fix left/right channel mixed-up during recording by splitting recdev
mask to recdev_l and recdev_r, since each have its own unique mask.

Submitted by:	Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
Approved by:	netchild (mentor)
2005-11-14 18:16:59 +00:00
Ariff Abdullah
238c5dc5c3 Fix kernel panic caused by double mss_unlock().
Noticed by:	Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
2005-11-07 09:25:15 +00:00
Yoshihiro Takahashi
8621e8a737 more #ifndef PC98. This really fix the pc98 tinderbox. 2005-09-12 13:40:10 +00:00
Warner Losh
d78baf42dc Since opti_detect is now only called on !PC98 machines, only declare
and define there as well.  This should fix the pc98 tinderbox.
2005-09-12 04:12:50 +00:00
Alexander Leidinger
70001ecea2 Add some ad_wait_init() calls to fix some problems in some configs (e.g.
PC98, CS4231A, "pcm0: play interrupt timeout").

PR:		45682
Submitted by:	Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
2005-09-11 13:59:02 +00:00
Alexander Leidinger
3159d831fc Allow to record non 8bit-mono formats even in half-duplex configurations.
PR:		45679
Submitted by:	Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
2005-09-11 13:49:24 +00:00
Alexander Leidinger
6643b656bb Fix misdetection of the sound chip on PC98 systems. The submitter doesn't
believe that there are PC98 systems with an OPTi chip.

I don't know enough about this special PC architecture to be sure about
this, so let's find out by letting people with such a system complain in
case this commit breaks the sound system for them. It's easy to revert
then.

PR:		45673
Submitted by:	Watanabe Kazuhiro <CQG00620@nifty.ne.jp>
2005-09-11 10:07:12 +00:00
Alexander Leidinger
0725262365 Fix panic caused by full duplex operation.
From the PR:
---snip---
The vibra16X supports full duplex. I traced the Windows driver, and what is
does is that it programs one DMA channel 8-bit, and the other 16-bit. There
might be some kind of auto detection logic here, because it always uses 8-bit
for playback, even if I play 16-bit sound ...
---snip---

PR:		80977
Submitted by:	Hans Petter Selasky <hselasky@c2i.net>
2005-09-10 17:33:58 +00:00
Alexander Leidinger
4442c32be7 Style fix.
Noticed by:	njl
2005-07-31 18:59:47 +00:00
Alexander Leidinger
c249345405 - Fixup the locking.
- Don't mark MPSAFE (yet).
- DSP_CMD_DMAEXIT_8 doesn't work on old cards, use sb_reset_dsp() instead.

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
2005-07-31 13:53:53 +00:00
Alexander Leidinger
7a7689dea4 - Fixup the locking.
- Don't mark MPSAFE (yet).

Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
2005-07-31 13:51:04 +00:00
Alexander Leidinger
205d75821e Add another ID.
Submitted by:	Ariff Abdullah <skywizard@MyBSD.org.my>
2005-07-31 13:49:47 +00:00
John Baldwin
dfa9ef3d99 Don't attach the non-PnP mss pcm(4) driver to acpi busses as ACPI only
enumerates PnP ISA-like devices.

Reported by:	Harry Coin harrycoin at qconline dot com
MFC after:	3 days
2005-07-13 15:17:54 +00:00
Warner Losh
d2b677bb1a Use BUS_PROBE_DEFAULT in preference to 0 and BUS_PROBE_LOW_PRIORITY in
preference to some random negative number to allow other drivers a
bite at the apple.
2005-03-01 08:58:06 +00:00
Matthew N. Dodd
c58d5e62ad Use mss_{format,speed}() rather than chn_set{format,speed}() and hold
mss lock across call.

This allows my Thinkpad 600E to resume with the sound driver loaded and
vchans enabled.
2005-02-27 23:32:21 +00:00
Warner Losh
098ca2bda9 Start each of the license/copyright comments with /*-, minor shuffle of lines 2005-01-06 01:43:34 +00:00
Warner Losh
993fd0c509 PNP BIOS devices are fundamentally different than ISA PNP devices.
These devices should be probed first because they are at fixed
locations and cannot be turned off.  ISA PNP devices, on the other
hand, can be turned off and often can be flexible in the resources
they use.  Probe them last, as always.
2004-12-07 05:30:02 +00:00
Nate Lawson
ecb7c87d1c Re-add an acpi attachment for the legacy probe that was inadvertently
removed.
2004-10-15 05:13:25 +00:00
Pyun YongHyeon
eba1cb6e3e Audio drivers failed to detect failure condition and attempted to
assign DMA address to the wrong address. It can cause system lockup
or other mysterious errors. Since most sound cards requires low DMA
address(BUS_SPACE_MAXADDR_24BIT) sndbuf_alloc() would fail when the
audio driver is loaded after long running of operations.

Approved by:	jake (mentor)
Reviewed by:	truckman, matk
2004-10-13 05:45:16 +00:00
Nate Lawson
4a25d7ffe2 * Remove the acpi attachment from the es1888. It has an identify method
that conjures up the device node so it isn't true PNP.  Noticed by jhb@.

* Add an attachment for esscontrol since it too uses ISA_PNP_PROBE.

* Move an attachment from snd_mss to snd_pnpmss.  The latter is the real
  PNP user.
2004-10-12 01:56:03 +00:00
Nate Lawson
8909901fdd Add acpi attachments for ISA sound drivers. This is needed so they'll
probe and attach when ACPI is enabled.

Submitted by:	takawata (sbc fix)
MFC after:	1 day
2004-10-11 19:52:31 +00:00
Don Lewis
2e715afcac Change sb_lock() calls to sbc_lockassert() and remove the sb_unlock()
calls in sb_cmd2() and sb_getmixer().  The lock has already be grabbed
before these functions are called.

This is a RELENG_5 candidate.

PR:		71189
Submitted by:	stephane
MFC after:	3 days
2004-09-12 18:19:42 +00:00
Seigo Tanimura
0739ea1de2 Rename the sound device drivers:
- `sound'
  The generic sound driver, always required.

- `snd_*'
  Device-dependent drivers, named after the sound module names.
  Configure accordingly to your hardware.

In addition, rename the `snd_pcm' module to `sound' in order to sync
with the driver names.

Suggested by:	cg
2004-07-16 04:00:08 +00:00