Commit Graph

252 Commits

Author SHA1 Message Date
tsutsui e0a14f3564 Fix botches in rev 1.185 (kent-audio1 merge) which cause buffer overrun
and "tlb_exception: no copyin/out fault hander" panic in
audio_fill_silence() after audio playback on dreamcast.

The problem is tracked and fix is provieded by Ryo SHIMIZU,
who is the auther of aica(4) audio driver for dreamcast.
2010-11-20 18:03:49 +00:00
dyoung c1b390d493 A pointer typedef entails trading too much flexibility to declare const
and non-const types, and the kernel uses both const and non-const
PMF qualifiers and device suspensors, so change the pmf_qual_t and
device_suspensor_t typedefs from "pointers to const" to non-pointer,
non-const types.
2010-02-24 22:37:54 +00:00
dyoung cd6e1fbf91 Expand PMF_FN_* macros. 2010-01-08 19:53:10 +00:00
dyoung 4075f812e7 Simplify these device-activation hooks using the following semantic
patch.

XXX sc_dying must die.

@@
type device_t;

identifier act, midi_softc, midiactivate, sc, self;
@@

int
midiactivate(device_t self, enum devact act)
{
(
	struct midi_softc *sc = device_private(self);
|
-	struct midi_softc *sc;
+	struct midi_softc *sc = device_private(self);
...
-	sc = device_private(self);
)
...
	switch (act) {
-	case DVACT_ACTIVATE:
-		return (EOPNOTSUPP);
-
	case DVACT_DEACTIVATE:
(
	sc->dying
|
	sc->sc_dying
)
		=
(
	1
|
	true
)
		;
-		break;
+		return 0;
+	default:
+		return EOPNOTSUPP;
	}
-	return (0);
}
2009-12-06 22:42:48 +00:00
sborrill 21e3c4b6e7 Add support for playback- or capture-only devices by adding
AUDIO_PROP_PLAYBACK and AUDIO_PROP_CAPTURE properties.

From jmcneill@.

Fixes PR#42050
2009-09-29 15:58:54 +00:00
sborrill eecdf6949e Revert previous and instead select whether to call mixer_ioctl() or
audio_ioctl() based on whether the command smells like a mixer ioctl or not.
2009-09-24 16:03:11 +00:00
sborrill 48666a05d3 OSS audio allows mixer operations on the dsp device. NetBSD would return
EINVAL in these circumstances. This can break audio in apps running under
Linux emulation (e.g. Citrix ICA client will mute all audio when volume
control used). Therefore, pass unrecognised ioctls attempted on dsp devices
to mixer_ioctl.
2009-09-24 11:13:38 +00:00
dyoung 36fffd8d02 In pmf(9), improve the implementation of device self-suspension
and make suspension by self, by drvctl(8), and by ACPI system sleep
play nice together.  Start solidifying some temporary API changes.

1. Extract a new header file, <sys/device_if.h>, from <sys/device.h> and
   #include it from <sys/pmf.h> instead of <sys/device.h> to break the
   circular dependency between <sys/device.h> and <sys/pmf.h>.

2. Introduce pmf_qual_t, an aggregate of qualifications on a PMF
   suspend/resume call.  Start to replace instances of PMF_FN_PROTO,
   PMF_FN_ARGS, et cetera, with a pmf_qual_t.

3. Introduce the notion of a "suspensor," an entity that holds a
   device in suspension.  More than one suspensor may hold a device
   at once.  A device stays suspended as long as at least one
   suspensor holds it.  A device resumes when the last suspensor
   releases it.

   Currently, the kernel defines three suspensors,

   3a the system-suspensor: for system suspension, initiated
      by 'sysctl -w machdep.sleep_state=3', by lid closure, by
      power-button press, et cetera,

   3b the drvctl-suspensor: for device suspension by /dev/drvctl
      ioctl, e.g., drvctl -S sip0.

   3c the system self-suspensor: for device drivers that suspend
      themselves and their children.  Several drivers for network
      interfaces put the network device to sleep while it is not
      administratively up, that is, after the kernel calls if_stop(,
      1).  The self-suspensor should not be used directly.  See
      the description of suspensor delegates, below.

   A suspensor can have one or more "delegates".  A suspensor can
   release devices that its delegates hold suspended.  Right now,
   only the system self-suspensor has delegates.  For each device
   that a self-suspending driver attaches, it creates the device's
   self-suspensor, a delegate of the system self-suspensor.

   Suspensors stop a system-wide suspend/resume cycle from waking
   devices that the operator put to sleep with drvctl before the cycle.
   They also help self-suspension to work more simply, safely, and in
   accord with expectations.

4. Add the notion of device activation level, devact_level_t,
   and a routine for checking the current activation level,
   device_activation().  Current activation levels are DEVACT_LEVEL_BUS,
   DEVACT_LEVEL_DRIVER, and DEVACT_LEVEL_CLASS, which respectively
   indicate that the device's bus is active, that the bus and device are
   active, and that the bus, device, and the functions of the device's
   class (network, audio) are active.

   Suspend/resume calls can be qualified with a devact_level_t.
   The power-management framework treats a devact_level_t that
   qualifies a device suspension as the device's current activation
   level; it only runs hooks to reduce the activation level from
   the presumed current level to the fully suspended state.  The
   framework treats a devact_level_t qualifying device resumption
   as the target activation level; it only runs hooks to raise the
   activation level to the target.

5. Use pmf_qual_t, devact_level_t, and self-suspensors in several
   drivers.

6. Temporarily add an unused power-management workqueue that I will
   remove or replace, soon.
2009-09-16 16:34:49 +00:00
dyoung 9c07c1c9a8 Detach audio(4) during shutdown. 2009-04-17 20:04:35 +00:00
cegger fc8fd752ef device_private(device_lookup()) -> device_lookup_private()
ok cube@
2008-06-10 22:53:08 +00:00
tsutsui 887a89aa5c Use device_lookup_private() rather than using cd_devs[] directly to get softc.
XXX maybe we should change a type of cd_devs[] in struct cfdriver
    from (void *) to device_t.
2008-06-08 18:18:33 +00:00
bjs c3c1440b25 - Fix the conditions for POLLOUT to match those elsewhere
- Refactor pause attribute handling so that it it's preserved
   appropriately and reset in audio_clear().

Now audio/jack-devel works with the native driver.
2008-06-03 06:21:17 +00:00
jmcneill c0154b15d0 pmf: in audio_volume_up and audio_volume_down, honour the mixer control's
delta field rather than arbitrary '32' when stepping up or down master
volume.
2008-06-03 02:16:18 +00:00
ad 6d70f903e6 Network protocol interrupts can now block on locks, so merge the globals
proclist_mutex and proclist_lock into a single adaptive mutex (proc_lock).
Implications:

- Inspecting process state requires thread context, so signals can no longer
  be sent from a hardware interrupt handler. Signal activity must be
  deferred to a soft interrupt or kthread.

- As the proc state locking is simplified, it's now safe to take exit()
  and wait() out from under kernel_lock.

- The system spends less time at IPL_SCHED, and there is less lock activity.
2008-04-24 15:35:27 +00:00
jmcneill b2bbe181c6 Fix audio_volume_toggle. How did this ever work for me? Thinkpad T61
mutes audio automatically when the mute key is pressed.
2008-04-01 00:52:11 +00:00
dyoung 3df2b2feb5 Use device_t and its accessors throughout. Use aprint_*_dev().
Improve PMF-ability.

        Add a 'flags' argument to suspend/resume handlers and
        callers such as pmf_system_suspend().

        Define a flag, PMF_F_SELF, which indicates to PMF that a
        device is suspending/resuming itself.  Add helper routines,
        pmf_device_suspend_self(dev) and pmf_device_resume_self(dev),
        that call pmf_device_suspend(dev, PMF_F_SELF) and
        pmf_device_resume(dev, PMF_F_SELF), respectively.  Use
        PMF_F_SELF to suspend/resume self in ath(4), audio(4),
        rtw(4), and sip(4).

        In ath(4) and in rtw(4), replace the icky sc_enable/sc_disable
        callbacks, provided by the bus front-end, with
        self-suspension/resumption.  Also, clean up the bus
        front-ends.  Make sure that the interrupt handler is
        disestablished during suspension.  Get rid of driver-private
        flags (e.g., RTW_F_ENABLED, ath_softc->sc_invalid); use
        device_is_active()/device_has_power() calls, instead.

        In the network-class suspend handler, call if_stop(, 0)
        instead of if_stop(, 1), because the latter is superfluous
        (bus- and driver-suspension hooks will 'disable' the NIC),
        and it may cause recursion.

        In the network-class resume handler, prevent infinite
        recursion through if_init() by getting out early if we are
        self-suspending (PMF_F_SELF).

rtw(4) improvements:

        Destroy rtw(4) callouts when we detach it.  Make rtw at
        pci detachable.  Print some more information with the "rx
        frame too long" warning.

Remove activate() methods:

        Get rid of rtw_activate() and ath_activate().  The device
        activate() methods are not good for much these days.

Make ath at cardbus resume with crypto functions intact:

        Introduce a boolean device property, "pmf-powerdown".  If
        pmf-powerdown is present and false, it indicates that a
        bus back-end should not remove power from a device.

        Honor this property in cardbus_child_suspend().

        Set this property to 'false' in ath_attach(), since removing
        power from an ath at cardbus seems to lobotomize the WPA
        crypto engine.  XXX Should the pmf-powerdown property
        propagate toward the root of the device tree?

Miscellaneous ath(4) changes:

        Warn if ath(4) tries to write crypto keys to suspended
        hardware.

        Reduce differences between FreeBSD and NetBSD in ath(4)
        multicast filter setup.

        Make ath_printrxbuf() print an rx descriptor's status &
        key index, to help debug crypto errors.

        Shorten a staircase in ath_ioctl().  Don't check for
        ieee80211_ioctl() return code ERESTART, it never happens.
2008-03-12 18:02:21 +00:00
cube 492d8b0d9e Split device_t and softc for audio(4), and other related cosmetic changes. 2008-03-04 18:23:44 +00:00
rmind c6186face4 Welcome to 4.99.55:
- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call.  It will
  indicate which event (POLL_IN, POLL_OUT, etc) happen.  If unknown,
  zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
2008-03-01 14:16:49 +00:00
jmcneill a95bb300e8 Disable audio idle timer. It was a fun experiment, but causes more issues
than it was worth.
2008-02-13 18:31:51 +00:00
gson b8e6012764 Don't enter an infinite loop in audio_read() when the sc->sc_rustream
buffer is full.  Fixes kern/34659.
2008-01-23 14:14:55 +00:00
jmcneill 940524edab Deregister activity handler on detach. 2007-12-23 19:14:03 +00:00
christos 4d16498d9e Use M_NOWAIT in audio_stream_ctor; it can be called from a softintr context
through pmf_resume.
2007-12-22 18:34:56 +00:00
joerg af42580f29 Don't count poll(2) and select(2) as device activity. Don't activate the
device on write(2) if it is suspended and was not idle.
2007-12-13 14:40:36 +00:00
jmcneill 67153124ea When resuming the audio device, call audiosetinfo with the last known good
parameters. Fixes an issue with suspending the audio device while playback
is paused.
2007-12-13 14:02:53 +00:00
martin 2ce2127701 When collecting mixer values while suspending, initialize the number
of channels from the mixer device info. Fixes PR kern/37512.
OK: jmcneill
2007-12-11 00:08:14 +00:00
jmcneill 4c1d81b2b5 Merge jmcneill-pm branch. 2007-12-09 20:27:42 +00:00
pooka 4e38160d4d Do not "return 1" from kqfilter for errors. That value is passed
directly to the userland caller and results in a mysterious EPERM.
Instead, return EINVAL or something else sensible depending on the
case.
2007-12-05 17:19:46 +00:00
jmcneill 4fbe23fdd0 aprintify 2007-12-01 04:50:50 +00:00
ad 46ed8f7d77 Use the softint API. 2007-10-08 16:18:02 +00:00
uwe 9a34099682 au_setup_ports - don't hide ports->nports++ inside another expression,
especially if that other expression is the right hand side operand of
&& which is short-circuiting.  The effect was that audiorecord(1)
would always fail trying to set recording port with AUDIO_SETINFO.

Tested on wss@pnpbios.  It looks like this problem has been reported
as PR/35239, filed against port-hp700.
2007-08-14 21:34:03 +00:00
joerg 5ccf1c578a Add a new ioctl AUDIO_GETBUFINFO. It works like AUDIO_GETINFO, but
doesn't obtain the ports, gain and balance related parameters.
Those generally require reading from the hardware and therefore are much
more expensive to obtain. Modify OSS emulation to use the new ioctl
where possible.

This reduces CPU usage of mplayer during mp3 playback with my Thinkpad
from 20% to < 1% and from 50% to 20% during Xvid playback.

Review and comments from jmcneill@
2007-06-11 13:05:46 +00:00
kent e893f67fa1 return information about playing buffer, not recording bufer,
for AUDIO_WSEEK.

PR#35171
2007-03-09 13:20:12 +00:00
christos 53524e44ef Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. 2007-03-04 05:59:00 +00:00
thorpej ebd626809e TRUE -> true, FALSE -> false 2007-03-01 17:31:35 +00:00
thorpej 712239e366 Replace the Mach-derived boolean_t type with the C99 bool type. A
future commit will replace use of TRUE and FALSE with true and false.
2007-02-21 22:59:35 +00:00
ad 9db0a17503 Defer wakeup() to the soft interrupt also. 2007-02-15 18:12:05 +00:00
ad b07ec3fc38 Merge newlock2 to head. 2007-02-09 21:55:00 +00:00
christos 168cd830d2 __unused removal on arguments; approved by core. 2006-11-16 01:32:37 +00:00
cbiere 293f5e50a2 Set oldpblksize and oldrblksize early enough so that zero-initialisation
isn't necessary. The GCC warning was not a false-positive, AFAICS.
2006-11-01 10:13:37 +00:00
xtraeme 5975efbaee Initialize old[pr]blksize to 0 to avoid gcc warnings. 2006-11-01 09:36:52 +00:00
cbiere 87261698f4 Fix for kern/17446. Restore the audio settings if an error occured. 2006-11-01 06:39:19 +00:00
christos 4d595fd7b1 - sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386
2006-10-12 01:30:41 +00:00
jmcneill f135e0d607 Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@
2006-09-24 03:53:07 +00:00
christos ff62f5c658 add missing initializers. 2006-08-27 23:54:50 +00:00
jmcneill 7508425eaa Protect audio_powerhook with '#if NAUDIO > 0'. PR kern/33832. 2006-06-27 02:07:08 +00:00
jmcneill bd22603476 Halt input/output on soft suspend if currently running, and restore them
on soft resume.
2006-06-19 10:19:08 +00:00
kent e47609747e If one or more playback filters are applied, minimize loading
size of the hardware buffer to improve accuracy of AUDIO_GETIOFFS.
2006-05-16 13:46:19 +00:00
kent 6ad20dfc11 Fixes a bug that audio_offset_t::samples for AUDIO_GETxOFFS has
incorrect value.  It also affects SNDCTL_DSP_GETOPTR of
ossaudio.

PR: kern/32405 by Stephane Witzman
2006-05-10 01:56:21 +00:00
jmcneill f77081f364 Don't use simple_locks; we can't hold them while calling malloc and
friends.
2006-04-19 14:10:58 +00:00
jmcneill a46cb959f0 Protect audio_write's filter graph from being modified in the middle of a
write. Fixes the 'audioctl of death' problem (PR#32563).
2006-04-18 19:15:27 +00:00