Commit Graph

64 Commits

Author SHA1 Message Date
nakayama
276930195c pad(4) mixer has only 1 channel, so return EINVAL in the case other than 1.
This fixes the following strange output of mixerctl(1):

        outputs.master=255,0
        inputs.dac=255,0
2018-09-25 06:55:23 +00:00
nakayama
3718cdade0 Revert to rev.1.53.
I accidentally committed the netbsd-8 branch file in rev.1.54.
2018-09-25 06:53:49 +00:00
kre
2ed63bfbf6 Since we need an int paramater, and uio_resid is size_t cast it to int
to avoid warnings from the ever friendly compiler... (check that size if
in range was already made).
2018-09-23 23:34:45 +00:00
kre
233da0ae1f Open code min() so we don't need to find its prototype ... 2018-09-23 23:30:51 +00:00
nakayama
1950bffe53 pad(4) mixer has only 1 channel, so return EINVAL in the case other than 1.
This fixes the following strange output of mixerctl(1):

	outputs.master=255,0
	inputs.dac=255,0
2018-09-23 21:18:30 +00:00
riastradh
d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

	#define min(a, b)	((a) < (b) ? (a) : (b))
	#define max(a, b)	((a) > (b) ? (a) : (b))

even though our standard name for that is MIN/MAX.  Although these
may invite multiple evaluation bugs, these do _not_ cause integer
truncation.

To avoid `fixing' these cases, I first changed the name in libkern,
and then compile-tested every file where min/max occurred in order to
confirm that it failed -- and thus confirm that nothing shadowed
min/max -- before changing it.

I have left a handful of bootloaders that are too annoying to
compile-test, and some dead code:

cobalt ews4800mips hp300 hppa ia64 luna68k vax
acorn32/if_ie.c (not included in any kernels)
macppc/if_gm.c (superseded by gem(4))

It should be easy to fix the fallout once identified -- this way of
doing things fails safe, and the goal here, after all, is to _avoid_
silent integer truncations, not introduce them.

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
pgoyette
7051423712 Fix typo in previous. mea culpa, mea culpa, mea maxima culpa 2018-01-26 23:36:01 +00:00
pgoyette
d10dc2b1d3 Unitialized variable - CID/1428657 2018-01-26 22:48:22 +00:00
nat
6a9f5fca12 Fix pad on systems with many cores/cpus:
* Introduce a lock to serialize attach/detach of pad devices.
	* Forcefully detach children of pad on close.
	* Be more carefull in pad_open with regards to config_detach only
	  if new instances of the pad device are created and fail to open.

Addresses PR kern/52889.

These changes were developed with and tested by pgoyette@.
2018-01-09 04:23:59 +00:00
pgoyette
4b44327057 If config_fini_component() fails (due to device driver busy), don't
discard its error value when re-attaching the devsw.  If the devsw
is successfully re-attached and we return success, the module will
get detached anyway.  And, since the device is actually busy, we'll
eventually panic.

Thanks to nat@ for providing the reproduction instructions.

XXX A driver-busy condition will currently still trigger the error
XXX message from config_fini_component()
XXX	configure: attachment `pad' of `pad' driver fini failed: 16
XXX This will be addresses separately by having pad maintain its own
XXX ref-count and not relying on config_fini_component() to detect
XXX the busy state.
2017-12-17 21:57:11 +00:00
pgoyette
9921032f58 Use config(1) and IOCONF= to generate most of the auto-config data
structures.  (Note that bin/52823 documents the reasons for still
requiring hand-crafted cfattach structures.)
2017-12-16 06:39:07 +00:00
pgoyette
b573b68bcf Remove the correct extra #endif
:)
2017-12-16 02:45:14 +00:00
mrg
0a52b33c75 remove extra #endif left in previous commit. 2017-12-16 02:13:13 +00:00
pgoyette
7778f761a5 Replace manipulation of individual config structures with calls to
config_{init,fini}_component()
2017-12-15 23:57:42 +00:00
pgoyette
f941c7bf68 Rework so that module infrastructure is provided even when the module
is built-in to the kernel.

XXX pullup-8?
2017-12-15 11:49:32 +00:00
christos
ea05286d92 add fo_name so we can identify the fileops in a simple way. 2017-11-30 20:25:54 +00:00
nat
2bb842c6eb The pad module will now compile with WARNS=5. 2017-07-30 00:50:52 +00:00
nat
2ffd7d03db If a particular pad device is opened, ie pad1 then configure and use pad1
if it is not already configured.

This improves scriptability as you will know the particular pad(4) device
you have opened.

pad(4) devices still have a cloning interface if pad device (minor
number 254) is opened it will attach the next free device.  This action
can be repeated.

XXX update MAKEDEV scripts to make /dev/pad the cloning device.

Ok christos@.
2017-07-02 13:32:50 +00:00
nat
1d8c132573 Return early from read if kpause is interrupted by a signal. 2017-07-02 05:59:27 +00:00
nat
cbfe5fc929 Pad is now clones its device, attaching upon open and detaching upon close.
This means that only one pad device is required in /dev.

The code contains a compile time limit of 128 units.

Ok christos@.
2017-07-01 23:31:19 +00:00
nat
8304d273aa sc_audiodev should be defined as a device_t as this is what audio_attach_mi
returns.
2017-07-01 05:50:10 +00:00
nat
2922a461bc Use defines to specify pad audio format. NFCI.
Ok christos@.
2017-06-19 23:54:00 +00:00
nat
aaa8c67e4e Style change. 2017-06-06 07:32:41 +00:00
nat
59a3cdc9c9 pad blocksize 1024 -> 8192. Helps when sleeping in rate limiter. 2017-06-06 07:31:40 +00:00
nat
153aad6495 Simplification of rate limiter. It now works uni/multiprocessor. 2017-06-06 07:29:35 +00:00
nat
77e338f6c3 sc_bytes_count needs to be set in pad_audio_open not pad_open. 2017-06-06 07:27:15 +00:00
nat
518307b9ac Express BYTESTOSLEEP as an 64 bit integer.
Use BYTESTOSLEEP in expresson of BYTES_PER_SEC.
2017-06-06 07:18:38 +00:00
pgoyette
ab66491cc5 Add infrastructure for modularization of audio, midi, and sequencer 2017-06-01 09:44:30 +00:00
chs
fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00
nat
fad2617ec8 Add missing sc_bytes_count. 2017-05-27 10:43:30 +00:00
nat
1a9a1dfb7d Rework of previous.
Math for BYTESTOSLEEP and TIMENEXTREAD is now correct.
2017-05-27 10:02:26 +00:00
nat
f37c1195ee Update pad due to changes in audio. sc_bytes_count and BYTESTOSLEEP are
no longer required.
2017-02-23 23:13:27 +00:00
nat
7257364421 Don't hold the thread_lock between successive calls to sc_intr as it
breaks mixing.

This will help passing the atf test.  Changes to audio.c to ensue this
will be in a followup commit.
2017-01-26 04:10:27 +00:00
nat
333b297cf7 pad(4) must be open before corresponding audio device is opened.
OK christos@
2016-10-15 07:08:06 +00:00
msaitoh
8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
nat
69ec26e42b Allow reads from pad(4) less or greater than PAD_BLKSIZE.
Ensure that audio data is ready before reading.
Addresses PR 39204.

OK jmcneil@.
2016-02-26 13:17:04 +00:00
nat
79728ed766 Wrap up calls to sc_intr in kpreempt[en/dis]able.
This commit was approved by christos@
2015-07-10 21:58:56 +00:00
jmcneill
dd9a139587 Add common audio converters for software volume control. Only supports
slinear16_le and slinear16_be for now.

Convert pad(4) to use the new converters.
2014-11-18 01:53:17 +00:00
dholland
f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
christos
ad1d4a6684 sprinke __diagused 2013-11-02 00:37:12 +00:00
agc
c980395227 get rid of a variable which is no longer used after the demise of splaudio 2011-11-24 01:54:08 +00:00
jmcneill
aef2dcc2bc splaudio is no more 2011-11-24 01:11:04 +00:00
jmcneill
8a962f23f2 Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

  Add MP locking to the audio drivers.

  Making the audio drivers MP safe is necessary before efforts
  can be made to make the VM system MP safe.

  The are two locks per device instance, an ISR lock and
  a character device lock. The ISR lock replaces calls to
  splaudio()/splx(), and will be held across calls to device
  methods which were called at splaudio() before (e.g.
  trigger_output). The character device lock is held across
  calls to nearly all of the methods, excluding some only
  used for initialization, e.g. get_locks.

Welcome to 5.99.57.
2011-11-23 23:07:28 +00:00
riz
a110815e0b Use le16enc()/be16enc() to encode LE/BE values back into the audio stream.
This fixes the tests/dev/audio test on my macppc box.

While I'm here, use le16dec()/be16dec() directly instead of rewriting them.
2011-02-28 16:56:39 +00:00
jmcneill
3298ac716e - return EIO if audio data is received and /dev/pad isn't open
- give a better description for AUDIO_GETDEV
2010-09-03 19:19:48 +00:00
pooka
021e75bbe7 Don't print spammy message if read is interrupted (ctrl-c)
while waiting for data.
2010-06-28 17:45:08 +00:00
pooka
199d07fe55 fix field initializers 2010-05-01 23:40:21 +00:00
ahoka
bc0cafe08f Add support to be built as a kernel module. 2010-04-09 13:39:17 +00:00
dyoung
c217bc3b1d If the device does not exist, return ENXIO, as is customary, instead of
ENODEV.  Ok jmcneill@.
2010-01-18 23:57:14 +00:00
jmcneill
e875bf360e PR# kern/39899: audio attach with pad(4) segfaults
Make sure pad pulls in auconv mulaw support.
2009-09-08 09:47:42 +00:00