Commit Graph

84 Commits

Author SHA1 Message Date
isaki
baa8677bbf Support audio descriptor for fstat(1).
sys/dev/audio/*.h: export only what we need for fstat.
2020-09-13 04:14:48 +00:00
isaki
6e3869e707 Improve slinear16-to-mulaw conversion calculation.
It's about 2~3 times faster on my amd64 and x68k(68030).
2020-09-12 06:09:16 +00:00
isaki
0c9974fdba Fix misspellings in comment. 2020-09-07 03:36:11 +00:00
isaki
6da107a348 Improve debug messages. 2020-08-23 04:20:01 +00:00
isaki
bb4723b2fb Improve and update comments. 2020-08-23 04:14:57 +00:00
isaki
910d1610f8 Style fixes. 2020-08-23 04:07:23 +00:00
isaki
c8e35e0151 Fix suspend/resume.
- Revert temporary usage of sc_[pr]busy during suspend.  These indicate
  whether the mixer needs to be restarted or not.
- Avoid timeout error when about to suspend.
2020-05-29 03:09:14 +00:00
nia
725b833bbf audio: Only restart recording mixer on resume if it's already been started 2020-05-26 15:20:16 +00:00
nia
00e3f66015 audio: remove comment that is no longer valid 2020-05-26 11:43:00 +00:00
nia
2ed25f0c70 audio: Restore compat with Solaris for 8-bit LINEAR.
It's always signed, unless it's LINEAR8.

PR kern/55175
2020-05-26 10:12:12 +00:00
nia
8913094aef audio: Fix logic for resuming when the device is in use.
audio_[r/p]mixer_start should never be called when the device is
marked busy.

Resolves a panic on resume when audio is playing, PR kern/55301
2020-05-26 10:07:29 +00:00
ad
0eaaa024ea Move proc_lock into the data segment. It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.
2020-05-23 23:42:41 +00:00
isaki
23a77a734f Move machine dependent AUDIO_BLK_MS default value to <machine/param.h>.
If the port has __AUDIO_BLK_MS in <machine/param.h>, it will be used.
Otherwise the default value (currently 10 msec) defined in audio.c will
be used.  This mechanism is for very old ports which cannot satisfactorily
handle 10 msec block.  Currently hppa, m68k, sh3, sparc(!64) and vax are.

For port maintainers, if general models in your port cannot satisfactorily
handle 10 msec block, please consider to define your suitable longer period
(40 msec would be a good first choice).
But please don't be eager to make the default value shorter.

<machine/param.h> was discussed in source-changes-d.  It's better than
ifdef storm, or adding 60+ new header files in every arch/*/include/
directories for this.  Thanks mrg@, ad@, and everyone.
http://mail-index.netbsd.org/source-changes-d/2020/05/01/msg012572.html
2020-05-01 08:21:27 +00:00
isaki
841e28ba96 Set AUDIO_BLK_MS 40 msec on other old(slow) architectures not only m68k.
Thanks tsutsui@ for comment about architecture choice.
And move it from audiodef.h to audio.c as suggested by joerg@.
2020-04-29 03:58:27 +00:00
isaki
518e6f838b Improve the blocksize notation.
The blocksize is expressed in bytes, and the millisecond notation
is supplementary information to make it easier to understand.
2020-04-19 03:52:22 +00:00
isaki
620dca1eae Improve diagnostic messages. 2020-04-17 07:48:35 +00:00
isaki
d58df70401 Reduce default AUDIO_BLK_MS from 40msec to 10msec on all platform except m68k
(m68k uses 40msec default as before).  And remove the option from GENERIC.
- It's not good idea to set such parameter in individual GENERICs.
- 4msec is (probably no problem for most modern real hardware but)
  too aggressive to be default.
- 10msec is too severe for antique machines but it's hard to draw a line.
2020-03-28 08:35:36 +00:00
isaki
85c4f0d204 Fix to start recording immediately when open() with READ mode is
called (unless pause).
- Opening /dev/audio always initializes pause with false.  Therefore
  it always starts recording.
- Opening /dev/sound inherites pause from the sticky parameter.
  Therefore whether /dev/sound starts recording or not depends on the
  sticky pause parameter.
This fixes two problems:
- Opening /dev/audio didn't start recording after merging isaki-audio2.
- Opening /dev/sound didn't start recording regardless of the sticky
  pause, probably since long time ago (at least netbsd-7).
2020-03-26 13:32:03 +00:00
isaki
d0b5c44ab6 Fix/Update comments about allocm/freem. 2020-03-07 06:27:19 +00:00
isaki
a8be951e4d Split sc_lock and sc_exlock.
Most (probably all) malloc/free (or routines which may sleep) now can be
called without holding mutex.
Pointed out by riastradh@.
2020-03-07 06:25:57 +00:00
riastradh
df1f0e7940 Revert "Include opt_diagnostic.h for DIAGNOSTIC."
This did not do what I thought it did.  opt_diagnostic.h is only for
the unused _DIAGNOSTIC, which seems like an abortive attempt to
incrementally convert DIAGNOSTIC to an opt_*.h option rather than a
command-line option.
2020-03-05 15:18:54 +00:00
riastradh
57c472be02 Include opt_diagnostic.h for DIAGNOSTIC.
...at least, in header files, which may not have already included
libkern.h.
2020-03-05 08:08:32 +00:00
isaki
1cb852fd8e Restore backward compatibility with netbsd-7 audio.
For sticky parameters (encoding, precision, channels, sample_rate and pause):
 - AUDIO_SETINFO for nonexistent track updates sticky parameters.
 - AUDIO_GETINFO for nonexistent track reads sticky parameters.
For blocksize, hiwat, lowat and {play.record}.buffer_size:
 - AUDIO_SETINFO for nonexistent track does nothing.
 - AUDIO_GETINFO for nonexistent track returns dummy non-zero values.
Nonexistent track is a playback track on O_RDONLY descriptor for example,
or both tracks on /dev/audioctl.
2020-03-04 14:19:41 +00:00
isaki
876b561c3d Improve an error message about round_blocksize. 2020-03-01 07:42:07 +00:00
isaki
64ccf8fc30 Fix wrong parameter displayed in debug messages. 2020-03-01 07:40:03 +00:00
isaki
1d286abd67 Reinitialize the sticky parameters whenever the hardware format is changed.
When the number of the hardware channels becomes less than the number of
channels that sticky parameters remember, subsequent open("/dev/sound") will
fail without this treatment.  This is for rev 1.43.
2020-03-01 07:35:33 +00:00
isaki
3d4cb61926 Minor fix. audio_prinfo.pause is u_char, not bool. 2020-02-29 09:38:10 +00:00
isaki
9178c7e6bd Release memories on audiobellclose.
It's rest of the last commit.
2020-02-29 07:13:37 +00:00
isaki
66c7f93253 Prevent a race between audiodetach and fileops methods using psref(9).
Fix PR kern/54427.
Thank you so much riastradh@
2020-02-23 07:17:01 +00:00
isaki
49489285f6 Improve error handling around audio_hw_probe().
It was difficult to return multiple errors.
2020-02-23 04:24:56 +00:00
isaki
92e2bd444b Make start_input/halt_input optional if the driver has no recording,
make start_output/halt_output optional if the driver has no playback.
And remove such never called functions.
2020-02-23 04:02:45 +00:00
chs
5d4d9a2027 remove some unnecessary includes of internal UVM headers. 2020-02-22 19:49:11 +00:00
isaki
4f60b558c3 Make calling get_props() lockless.
get_props() of all MD drivers now can be called without sc_lock.
2020-02-22 08:15:09 +00:00
isaki
6d13f8a36a On audio_[pr]mixer_halt(), it's better to reset parameters in intr_lock. 2020-02-22 08:03:19 +00:00
isaki
710d84f6ac Add KASSERTs. audio_[pr]mixer_start() need exlock. 2020-02-22 08:01:59 +00:00
isaki
3dc846c0d9 Move #if DIAGNOSTIC..#endif to correct place.
It should ignore stray interrupts regardless of DIAGNOSTIC.
2020-02-22 07:59:47 +00:00
isaki
379e7aeb32 hw_if->query_format is already mandatory method. Drop null checks. 2020-02-22 07:09:18 +00:00
isaki
61f731db38 Improve KASSERT messages. 2020-02-22 06:58:39 +00:00
isaki
63cdbdbe8c Change two aprint_error_dev() to device_printf() (and improve messages).
This is also called from other than boot.
2020-02-22 06:36:07 +00:00
isaki
9fd5ffc974 const-ify. These arguments are no longer written back. 2020-02-22 06:28:10 +00:00
isaki
5eda9f581a Fix/Update comments. 2020-02-22 06:22:46 +00:00
isaki
0b3fcad9a1 Limit the number of channels that userland apps can set (by AUDIO_SETINFO)
to the number of channels supported by the hardware or less, if the hardware
supports multi channels.
- On monaural or stereo hardware, userland apps can always set 1ch or 2ch.
  The kernel (audio layer) can convert mono-stereo each other.
- On 3ch (2.1ch) hardware, for example, userland apps can set 1, 2, or 3ch,
  but not 4ch or more.
This allows userland apps to know actual number of channels supported by
the hardware in the same way as before.
PR kern/54973.
2020-02-22 05:51:39 +00:00
isaki
9e6a92af82 Remove incorrect KASSERT(!mutex_owned()).
Pointed out by riastradh@.
2020-02-15 02:47:00 +00:00
jmcneill
c1058ddd10 defopt AUDIO_BLK_MS 2020-01-25 12:15:35 +00:00
isaki
febfde9c6a Simplify async_mixer handling.
- It makes FIOASYNC code in mixer_ioctl() symmetric.
- For readability, mixer_async_{add,remove}() should take pid argument
  though pid is always curproc.
2020-01-11 04:53:10 +00:00
isaki
5ce2968c43 Remove old debug #ifdefs. 2020-01-11 04:06:13 +00:00
isaki
3b9c5d089b Fix an resource leak on audiobell close.
audioclose() freed audio_file_t structure, but only audiobellclose
didn't pass there.  I change that all of freeing audio_file_t is done
by each *_close().
2020-01-08 13:30:15 +00:00
isaki
b01e228efb Remove obsoleted comment. 2020-01-08 13:05:02 +00:00
isaki
ab1308759b Move mutex_exit() correct place to protect sc_async_mixer.
Thanks maxv@!
2020-01-08 08:10:15 +00:00
msaitoh
ba5c90c4a4 s/sucess/success/ in comment. 2019-12-27 09:45:26 +00:00