The NetBSD Project

CVS log for src/sys/dev/audio/audio.c

[BACK] Up to [cvs.NetBSD.org] / src / sys / dev / audio

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.136 / (download) - annotate - [select for diffs], Thu Aug 25 11:16:33 2022 UTC (5 months, 1 week ago) by riastradh
Branch: MAIN
CVS Tags: netbsd-10-base, netbsd-10, bouyer-sunxi-drm-base, bouyer-sunxi-drm, HEAD
Changes since 1.135: +15 -6 lines
Diff to previous 1.135 (colored)

audio(4): Fix bug in detaching audio16 and beyond.

The minor numbers have only four bits for the unit number, so unit
numbers past 15 can't be represented as is.  Attempting to revoke
them was once harmless, when the system made no attempt to avoid
open/detach races; now it crashes because vdevgone assumes that the
minor number can be mapped back to an autoconf device, but it's the
wrong one.  With this change, we stop trying to revoke units beyond
15, because they can't be opened anyway (which may be a bug in its
own right, requiring expansion of the minor number encoding!).

Reported-by: syzbot+6634ffd48997ae9b1eb0@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=db40a795a0b078f9b3b9fa0d3b7a9addcd2534de

Reported-by: syzbot+d2df39bb3f72975c0a97@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=cbdd598287529cff9a8c4230263f7414df88db4b

Reported-by: syzbot+1404969f68424f8f6e4b@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=6e4782408d0351769215fe433986f1844a546774

Reported-by: syzbot+2a4174a65609b3a00abb@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=886bbee544c2337683e24c801f9b632630a24681

Reported-by: syzbot+c0d9e49f22e571650736@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=7fb2e5576ebae731e859283f85c97747d2824f35

Reported-by: syzbot+583ba2cdb8aa6e59a4bf@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=2af44f5245eba572ebfb222070b9fd1378854303

Revision 1.135 / (download) - annotate - [select for diffs], Sat Aug 13 06:47:41 2022 UTC (5 months, 3 weeks ago) by isaki
Branch: MAIN
Changes since 1.134: +98 -124 lines
Diff to previous 1.134 (colored)

audio: Rework about usrbuf allocation.
- Allocate the usrbuf from kmem(9) instead of uvm(9).  The usrbuf has used
  uvm(9), in case mmap(2) might be issued later.  However, despite the most
  apps don't use mmap(2), allocating (and reallocating) uvm(9) every time
  would be expensive.  In addition, uvm(9) for recording usrbuf was totally
  pointless now.
- For playback, the usrbuf memory will be allocated in pages.  Because the
  usrbuf for playback is mostly near 64KB for backward compatibility.
  This will reduce reallocation especially from the initial ulaw to the most
  commonly used format like slinear16/2ch/48kHz.
- When mmap(2) is called, it will replace the playback usrbuf from kmem(9) to
  uvm(9).
- Prohibit changing playback format once mmap(2) is called.
  It follows netbsd-7.
- For recording, the usrbuf memory will be allocated in the requested size
  every time as before.  Because the usrbuf for recording is only one block
  and is enough small to the page in the most case.
Inspired by PR kern/56947.

Revision 1.134 / (download) - annotate - [select for diffs], Wed Jul 6 01:12:45 2022 UTC (7 months ago) by riastradh
Branch: MAIN
Changes since 1.133: +6 -2 lines
Diff to previous 1.133 (colored)

uvm(9): fo_mmap caller guarantees positive size.

No functional change intended, just sprinkling assertions to make it
clearer.

Revision 1.133 / (download) - annotate - [select for diffs], Sat Apr 23 11:44:01 2022 UTC (9 months, 1 week ago) by isaki
Branch: MAIN
Changes since 1.132: +4 -5 lines
Diff to previous 1.132 (colored)

audio(4): Fix a typo in comment.  Remove several old comments.

Revision 1.132 / (download) - annotate - [select for diffs], Sat Apr 23 11:30:57 2022 UTC (9 months, 1 week ago) by isaki
Branch: MAIN
Changes since 1.131: +4 -14 lines
Diff to previous 1.131 (colored)

audio(4): Clean up about audio_realloc().
- audio_realloc() never returns NULL, so there is no need to check it.
- audio_free() is no point in this case.

Revision 1.131 / (download) - annotate - [select for diffs], Sat Apr 23 07:55:07 2022 UTC (9 months, 1 week ago) by isaki
Branch: MAIN
Changes since 1.130: +3 -15 lines
Diff to previous 1.130 (colored)

audio(4): Remove no longer used counters.
These were used at very early phase of development.

Revision 1.130 / (download) - annotate - [select for diffs], Sat Apr 23 07:43:16 2022 UTC (9 months, 1 week ago) by isaki
Branch: MAIN
Changes since 1.129: +27 -10 lines
Diff to previous 1.129 (colored)

audio(4): Restore(implement) AUDIO_GETIOFFS ioctl.

Revision 1.129 / (download) - annotate - [select for diffs], Sat Apr 23 06:17:59 2022 UTC (9 months, 2 weeks ago) by isaki
Branch: MAIN
Changes since 1.128: +4 -3 lines
Diff to previous 1.128 (colored)

audio(4): Fix an (unintended) minor behavior on AUDIO_FLUSH.
On NetBSD7, when AUDIO_FLUSH was issued, .offset of AUDIO_GETOOFFS was
reinitialized (to one block ahead from zero) or unchanged depend on
whether the user encoding is hardware native or not (probably).
I don't believe that it's intended or we need to maintain it.
Now, AUDIO_FLUSH always clears the offset to zero.

Revision 1.128 / (download) - annotate - [select for diffs], Thu Apr 21 01:15:24 2022 UTC (9 months, 2 weeks ago) by macallan
Branch: MAIN
Changes since 1.127: +4 -2 lines
Diff to previous 1.127 (colored)

#if 0 now unused audio_track_is_record() to appease clang

Revision 1.127 / (download) - annotate - [select for diffs], Wed Apr 20 07:11:13 2022 UTC (9 months, 2 weeks ago) by isaki
Branch: MAIN
Changes since 1.126: +18 -21 lines
Diff to previous 1.126 (colored)

audio(4): Rework AUDIO_GETOOFFS.
- Count .samples/.deltablks in blocks.  It makes .deltablks integer wrap
  around safe.
- Remove suspicious one block offset from .offset.  I added the offset
  because it was observed so on NetBSD7.  But according to manpage, it
  should not be.  And it looks fine without the offset.
- Related to that, remove a comment in AUDIO_WSEEK.
  Limit the user-visible buffer to usrbuf only.

Revision 1.126 / (download) - annotate - [select for diffs], Wed Apr 20 06:05:22 2022 UTC (9 months, 2 weeks ago) by isaki
Branch: MAIN
Changes since 1.125: +192 -94 lines
Diff to previous 1.125 (colored)

audio(4): Make recording buffer more robust.
Previously, main buffer in recording track was usrbuf, which is the closest
buffer to the userland.  Because, this buffer arrangement was symmetrical
with the playback track, and had affinity with the past implementation.
However, in the current implementation, read(2) (from user application)
takes recorded block out from inputbuf, which is the closest buffer to
rmixer, to usrbuf.  So it was not good way to use the usrbuf as main buffer.
Now, usrbuf in recording track holds only fragment bytes in order to
transfer to the userland, and main buffer in recording track is the inputbuf,
the closest to rmixer.

Buffer size of the inputbuf is also modified.  Previously, it was less than
64KB or at least 4 blocks.  This had affinity with playback track and the
past implementation.  But this was not appropriate for both formats with
too large frames or too small frames.  In large frames (for example,
192kHz/12ch), 184KB buffer would be allocated but it corresponds to only
40msec.  In opposite, in small frames (for example, 8000Hz/1ch), 64KB
buffer would be allocated and it corresponds to 4.1 seconds.  But for such
machines that have 8000Hz/1ch device, in-kernel 64KB memory would probably
be expensive.
Now, inputbuf will always be allocated 16(NBLKIN) blocks, regardless of its
hardware format.  It corresponds to 160msec on modern archs (if blk_ms=10),
or 640msec on antique archs (if blk_ms=40).

Revision 1.125 / (download) - annotate - [select for diffs], Wed Apr 20 04:41:29 2022 UTC (9 months, 2 weeks ago) by isaki
Branch: MAIN
Changes since 1.124: +116 -76 lines
Diff to previous 1.124 (colored)

audio(4): Make debug messages better in audio_ioctl() and mixier_ioctl().
Divide by case.  Reduce to one line if possible.

Revision 1.124 / (download) - annotate - [select for diffs], Tue Apr 19 09:19:53 2022 UTC (9 months, 2 weeks ago) by riastradh
Branch: MAIN
Changes since 1.123: +13 -2 lines
Diff to previous 1.123 (colored)

audio(4): Wait for opens to drain in detach.

Otherwise detach may barge ahead and start freeing things before open
has finished and is about to use them after free.

Reported-by: syzbot+31d2619e72c2c8436cc9@syzkaller.appspotmail.com

Revision 1.123 / (download) - annotate - [select for diffs], Sat Apr 9 23:35:58 2022 UTC (9 months, 3 weeks ago) by riastradh
Branch: MAIN
Changes since 1.122: +5 -5 lines
Diff to previous 1.122 (colored)

audio(4): Use membar_acquire, not membar_enter.

Cheaper and adequate to make an atomic_swap into a load-acquire.

Revision 1.122 / (download) - annotate - [select for diffs], Thu Mar 31 19:30:15 2022 UTC (10 months ago) by pgoyette
Branch: MAIN
Changes since 1.121: +6 -7 lines
Diff to previous 1.121 (colored)

For device modules that provide both auto-config and /dev/xxx
interfaces, make sure that initialization and destruction
follow the proper sequence.  This is triggered by the recent
changes to the devsw stuff; per riastradh@ the required call
sequence is:

	devsw_attach()
	config_init_component() or config_cf*_attach()
	...
	config_fini_component() or config_cf*_detach()
	devsw_detach()

While here, add a few missing calls to some of the detach
routines.

Testing of these changes has been limited to:
	1. compile without build break
	2. no related test failures from atf
	3. modload/modunload work as well as
	   before.

No functional device testing done, since I don't have any
of these devices.  Let me know of any damage I might cause
here!

XXX Some of the modules affected by this commit are already
XXX broken;  see kern/56772.  This commit does not break
any additional modules (as far as I know).

Revision 1.121 / (download) - annotate - [select for diffs], Mon Mar 28 12:39:57 2022 UTC (10 months, 1 week ago) by riastradh
Branch: MAIN
Changes since 1.120: +42 -51 lines
Diff to previous 1.120 (colored)

audio(4): Use d_cfdriver/devtounit to avoid open/detach races.

Revision 1.120 / (download) - annotate - [select for diffs], Sat Mar 26 06:49:27 2022 UTC (10 months, 1 week ago) by isaki
Branch: MAIN
Changes since 1.119: +45 -2 lines
Diff to previous 1.119 (colored)

Add terminology comments.

Revision 1.119 / (download) - annotate - [select for diffs], Sat Mar 26 06:43:36 2022 UTC (10 months, 1 week ago) by isaki
Branch: MAIN
Changes since 1.118: +9 -6 lines
Diff to previous 1.118 (colored)

Improve comments.

Revision 1.118 / (download) - annotate - [select for diffs], Sat Mar 26 06:41:12 2022 UTC (10 months, 1 week ago) by isaki
Branch: MAIN
Changes since 1.117: +4 -7 lines
Diff to previous 1.117 (colored)

Remove a dead code in audio_track_record().

Revision 1.117 / (download) - annotate - [select for diffs], Sat Mar 26 06:36:06 2022 UTC (10 months, 1 week ago) by isaki
Branch: MAIN
Changes since 1.116: +5 -5 lines
Diff to previous 1.116 (colored)

Clarify the assertion in audio_rmixer_process().
By previous commit (r1.116), the assersion no longer fires even without
this modification.  But the condition was a bit inaccurate.
There is no need to check the data length must be aligned to blocks here
(though it also should be aligned now).  What we should check here is that
the tail must be aligned.

Revision 1.116 / (download) - annotate - [select for diffs], Sat Mar 26 06:27:32 2022 UTC (10 months, 1 week ago) by isaki
Branch: MAIN
Changes since 1.115: +11 -5 lines
Diff to previous 1.115 (colored)

Fix conditions that audio_read() calls audio_track_record().
audio_track_record() must be called when usrbuf has at least one free block.

I hope that this will fix the panic reported in PR kern/56644.
When an user process specifies the hardware format as its recording format
(i.e., there is no track conversions), if the user process read(2) a small
amount of data and the rmixer_process then runs, depending on the conditions,
the panic may happen.  I have never reproduced it because it's difficult to
do intentionally.

Thanks Y.Sugahara and riastradh@ for help and comments.

Revision 1.115 / (download) - annotate - [select for diffs], Mon Mar 14 21:38:04 2022 UTC (10 months, 3 weeks ago) by riastradh
Branch: MAIN
Changes since 1.114: +3 -3 lines
Diff to previous 1.114 (colored)

audio(4): Fix typo in previous -- atomic_store_release, not reease.

Built the wrong kernel to compile-test AUDIO_DEBUG, oops.

Revision 1.114 / (download) - annotate - [select for diffs], Mon Mar 14 11:47:33 2022 UTC (10 months, 3 weeks ago) by riastradh
Branch: MAIN
Changes since 1.113: +16 -7 lines
Diff to previous 1.113 (colored)

audio(4): Membar audit.

Won't affect anything on x86 because atomic r/m/w operations are
always full sequential consistency barriers, but might potentially
fix problems on, e.g., arm.

Note 1: I'm not clear on why the track lock is a bespoke mutex made
out of an atomic -- why not just mutex(9)?

Note 2: I'm not convinced the audio_mlog_flush synchronization is
correct; what happens if the softint runs on two CPUs at the same
time and swaps mlog_wpage simultaneously?

Note 3: Should maybe use atomic_load/store_relaxed for mlog_full and
mlog_drop, and atomic_inc/dec for mlog_refs.

Revision 1.113 / (download) - annotate - [select for diffs], Sun Dec 12 13:05:13 2021 UTC (13 months, 3 weeks ago) by andvar
Branch: MAIN
Changes since 1.112: +3 -3 lines
Diff to previous 1.112 (colored)

fix various typos, mainly in comments.

Revision 1.112 / (download) - annotate - [select for diffs], Fri Dec 10 20:36:03 2021 UTC (13 months, 3 weeks ago) by andvar
Branch: MAIN
Changes since 1.111: +3 -3 lines
Diff to previous 1.111 (colored)

s/occured/occurred/ in comments, log messages and man pages.

Revision 1.111 / (download) - annotate - [select for diffs], Sun Dec 5 02:56:55 2021 UTC (14 months ago) by msaitoh
Branch: MAIN
Changes since 1.110: +3 -3 lines
Diff to previous 1.110 (colored)

s/faciliate/facilitate/ in comment.

Revision 1.110 / (download) - annotate - [select for diffs], Sun Oct 10 11:21:05 2021 UTC (15 months, 3 weeks ago) by riastradh
Branch: MAIN
Changes since 1.109: +3 -3 lines
Diff to previous 1.109 (colored)

audio(9): Issue pserialize_perform outside sc_lock in audiodetach.

Breaks another deadlock between sc_lock and high-priority xcalls at
softint serial.  With any luck, this should be the last such softint
deadlock in audio!

Revision 1.109 / (download) - annotate - [select for diffs], Sun Oct 10 11:20:29 2021 UTC (15 months, 3 weeks ago) by riastradh
Branch: MAIN
Changes since 1.108: +3 -7 lines
Diff to previous 1.108 (colored)

audio(9): Call hw_if->getdev without sc_lock.

Holding sc_lock is not necessary -- I reviewed all ~70 cases in-tree,
and none of them rely on state protected by sc_lock.  Essentially
everything just copies from static data or data initialized at attach
time.

(Exceptions: tms320av110.c issues a bus_space_read_1, but I don't see
any reason why that needs to be serialized; and uaudio.c reads from
sc_dying, but that's not necessary and also not protected by sc_lock
anyway.)

Holding sc_lock is harmful because at least hdafg(4) can trigger module
autoload that leads to pserialize_perform, which waits for logic to run
at softint serial on all CPUs; at the same time, audio_softintr_rd/wr
run at softint serial and take sc_lock, so this leads to deadlock.

Revision 1.108 / (download) - annotate - [select for diffs], Sun Sep 26 01:16:08 2021 UTC (16 months, 1 week ago) by thorpej
Branch: MAIN
Changes since 1.107: +4 -4 lines
Diff to previous 1.107 (colored)

Change the kqueue filterops::f_isfd field to filterops::f_flags, and
define a flag FILTEROP_ISFD that has the meaning of the prior f_isfd.
Field and flag name aligned with OpenBSD.

This does not constitute a functional or ABI change, as the field location
and size, and the value placed in that field, are the same as the previous
code, but we're bumping __NetBSD_Version__ so 3rd-party module source code
can adapt, as needed.

NetBSD 9.99.89

Revision 1.107 / (download) - annotate - [select for diffs], Tue Sep 7 13:24:46 2021 UTC (16 months, 4 weeks ago) by andvar
Branch: MAIN
Changes since 1.106: +3 -3 lines
Diff to previous 1.106 (colored)

s/aquire/acquire/ in comments, also one typo fix acqure->acquire.

Revision 1.106 / (download) - annotate - [select for diffs], Sat Aug 7 16:19:09 2021 UTC (17 months, 4 weeks ago) by thorpej
Branch: MAIN
CVS Tags: thorpej-i2c-spi-conf2-base, thorpej-i2c-spi-conf2
Changes since 1.105: +5 -7 lines
Diff to previous 1.105 (colored)

Merge thorpej-cfargs2.

Revision 1.105.2.1 / (download) - annotate - [select for diffs], Wed Aug 4 17:27:29 2021 UTC (18 months ago) by thorpej
Branch: thorpej-cfargs2
Changes since 1.105: +5 -7 lines
Diff to previous 1.105 (colored) next main 1.106 (colored)

Adapt to CFARGS().

Revision 1.92.2.3 / (download) - annotate - [select for diffs], Sun Aug 1 22:42:21 2021 UTC (18 months ago) by thorpej
Branch: thorpej-i2c-spi-conf
Changes since 1.92.2.2: +27 -40 lines
Diff to previous 1.92.2.2 (colored) next main 1.93 (colored)

Sync with HEAD.

Revision 1.28.2.23 / (download) - annotate - [select for diffs], Wed Jul 28 14:59:02 2021 UTC (18 months, 1 week ago) by snj
Branch: netbsd-9
CVS Tags: netbsd-9-3-RELEASE
Changes since 1.28.2.22: +27 -40 lines
Diff to previous 1.28.2.22 (colored) to branchpoint 1.28 (colored) next main 1.29 (colored)

Pull up following revision(s) (requested by isaki in ticket #1325):
	sys/dev/audio/audio.c: revision 1.105
AUDIO_SETINFO: fix a bug that the gain and the balance could not be set
at the same time.  Fix PR kern/56308.

Revision 1.105 / (download) - annotate - [select for diffs], Wed Jul 21 06:14:58 2021 UTC (18 months, 2 weeks ago) by isaki
Branch: MAIN
CVS Tags: thorpej-i2c-spi-conf-base, thorpej-futex2-base, thorpej-futex2, thorpej-cfargs2-base
Branch point for: thorpej-cfargs2
Changes since 1.104: +27 -40 lines
Diff to previous 1.104 (colored)

AUDIO_SETINFO: fix a bug that the gain and the balance could not be set
at the same time.  Fix PR kern/56308.

Revision 1.92.2.2 / (download) - annotate - [select for diffs], Thu Jun 17 04:46:27 2021 UTC (19 months, 2 weeks ago) by thorpej
Branch: thorpej-i2c-spi-conf
Changes since 1.92.2.1: +66 -24 lines
Diff to previous 1.92.2.1 (colored)

Sync w/ HEAD.

Revision 1.104 / (download) - annotate - [select for diffs], Tue Jun 8 09:46:04 2021 UTC (19 months, 4 weeks ago) by riastradh
Branch: MAIN
Changes since 1.103: +6 -15 lines
Diff to previous 1.103 (colored)

audio(4): Revert revision 1.96 and redo it another way.

Instead of refusing to open /dev/audioN for writes when the device
doesn't support playback, just refuse to issue writes.

Although it seems more sensible to me to reject writable opens early
on, and it seems Solaris does so, this makes querying device
properties a little trickier and is a change to the NetBSD semantics.

Revision 1.102.2.1 / (download) - annotate - [select for diffs], Sun Jun 6 20:30:51 2021 UTC (19 months, 4 weeks ago) by cjep
Branch: cjep_sun2x
Changes since 1.102: +18 -7 lines
Diff to previous 1.102 (colored) next main 1.103 (colored)

sync with head

Revision 1.103 / (download) - annotate - [select for diffs], Fri Jun 4 08:57:05 2021 UTC (20 months ago) by riastradh
Branch: MAIN
CVS Tags: cjep_sun2x-base1
Changes since 1.102: +18 -7 lines
Diff to previous 1.102 (colored)

audio(4): When closing /dev/audioN, drain before removing from list.

Previously, in revision 1.100, I factored the SLIST_REMOVE out of
audio_unlink and audio_close up into audioclose since it is now used
by /dev/audio, /dev/audioctl, and /dev/mixer alike.  But I didn't
realize that the order

1. audio_track_drain
2. SLIST_REMOVE from sc_files

was significant; it matters because audio_track_drain waits for
wakeups that are delivered by hardware interrupts only to files
listed in sc_files.

This also fixes a bug introduced with the audiobell -- it was missing
the SLIST_REMOVE altogether.

For now, duplicate the SLIST_REMOVE calls in a few more places --
this is suboptimal but I want to make sure the logic works before
factoring it all out to tidy up.

Revision 1.102 / (download) - annotate - [select for diffs], Tue Jun 1 21:27:36 2021 UTC (20 months ago) by riastradh
Branch: MAIN
CVS Tags: cjep_sun2x-base
Branch point for: cjep_sun2x
Changes since 1.101: +6 -8 lines
Diff to previous 1.101 (colored)

audio(4): audio_unlink never fails, so make it return void.

Revision 1.101 / (download) - annotate - [select for diffs], Tue Jun 1 21:19:03 2021 UTC (20 months ago) by riastradh
Branch: MAIN
Changes since 1.100: +40 -9 lines
Diff to previous 1.100 (colored)

audio(4): Insert mixers and audioctls into sc_files on open too.

This is necessary so that on detach we set file->dying before any
operations, particularly audioclose, try to acquire a psref by the
time the audio softc is gone.

Candidate fix for PR kern/56164.

Revision 1.100 / (download) - annotate - [select for diffs], Tue Jun 1 21:15:37 2021 UTC (20 months ago) by riastradh
Branch: MAIN
Changes since 1.99: +2 -5 lines
Diff to previous 1.99 (colored)

audio(4): No need to set file->dying when closing the file.

No other file operations are possible by the time we get to
audioclose.

Revision 1.99 / (download) - annotate - [select for diffs], Tue Jun 1 21:14:52 2021 UTC (20 months ago) by riastradh
Branch: MAIN
Changes since 1.98: +7 -4 lines
Diff to previous 1.98 (colored)

audio(4): Grab sc->sc_cred under sc->sc_lock before freeing.

Otherwise we may race with open, leaking a cred no longer in use and
freeing a cred still in use.

Revision 1.98 / (download) - annotate - [select for diffs], Tue Jun 1 21:12:47 2021 UTC (20 months ago) by riastradh
Branch: MAIN
Changes since 1.97: +5 -5 lines
Diff to previous 1.97 (colored)

audio(4): Use kmem_alloc(sizeof(*p)) style.

Revision 1.97 / (download) - annotate - [select for diffs], Tue Jun 1 21:12:35 2021 UTC (20 months ago) by riastradh
Branch: MAIN
Changes since 1.96: +3 -2 lines
Diff to previous 1.96 (colored)

audio(4): Make sure to return ENXIO if device is being detached.

Don't return 0 indicating successful open of an unusable device!

Revision 1.96 / (download) - annotate - [select for diffs], Tue Jun 1 21:12:24 2021 UTC (20 months ago) by riastradh
Branch: MAIN
Changes since 1.95: +14 -4 lines
Diff to previous 1.95 (colored)

audio(4): Set AUMODE_PLAY/RECORD only if asked _and_ supported.

If one is requested and _not_ supported, fail; otherwise we might
enter audio_write with a null play track and crash on KASSERT.

Revision 1.92.2.1 / (download) - annotate - [select for diffs], Thu May 13 00:47:30 2021 UTC (20 months, 3 weeks ago) by thorpej
Branch: thorpej-i2c-spi-conf
Changes since 1.92: +12 -4 lines
Diff to previous 1.92 (colored)

Sync with HEAD.

Revision 1.28.2.22 / (download) - annotate - [select for diffs], Wed May 5 17:01:41 2021 UTC (21 months ago) by martin
Branch: netbsd-9
CVS Tags: netbsd-9-2-RELEASE
Changes since 1.28.2.21: +6 -3 lines
Diff to previous 1.28.2.21 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by nia in ticket #1268):

	sys/dev/audio/audio.c: revision 1.95

audio: Only score hardware formats by channel count at count<=2

Scoring by channel count makes sense when you are using hardware that
supports mono and stereo formats. However, if your hardware also supports
surround formats, defaulting to those might be confusing. So, don't
prefer them.

Problem reported and fix tested by tcmart14 with a 2015 model Macbook Pro.

Revision 1.95 / (download) - annotate - [select for diffs], Sun May 2 21:37:32 2021 UTC (21 months ago) by nia
Branch: MAIN
CVS Tags: cjep_staticlib_x-base1, cjep_staticlib_x-base, cjep_staticlib_x
Changes since 1.94: +6 -3 lines
Diff to previous 1.94 (colored)

audio: Only score hardware formats by channel count at count<=2

Scoring by channel count makes sense when you are using hardware that
supports mono and stereo formats. However, if your hardware also supports
surround formats, defaulting to those might be confusing. So, don't
prefer them.

Problem reported and fix tested by tcmart14 with a 2015 model Macbook Pro.

Revision 1.94 / (download) - annotate - [select for diffs], Mon Apr 26 19:59:58 2021 UTC (21 months, 1 week ago) by thorpej
Branch: MAIN
Changes since 1.93: +5 -2 lines
Diff to previous 1.93 (colored)

audioprint(): handle AUDIODEV_TYPE_AUX.

Revision 1.93 / (download) - annotate - [select for diffs], Mon Apr 26 14:02:49 2021 UTC (21 months, 1 week ago) by thorpej
Branch: MAIN
Changes since 1.92: +5 -3 lines
Diff to previous 1.92 (colored)

audio_attach_mi(): Be explicit about using the "audiobus" interface attribute,
as the caller may be a device that carries more than one.

Revision 1.92 / (download) - annotate - [select for diffs], Sat Apr 24 23:36:52 2021 UTC (21 months, 1 week ago) by thorpej
Branch: MAIN
Branch point for: thorpej-i2c-spi-conf
Changes since 1.91: +11 -11 lines
Diff to previous 1.91 (colored)

Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
  actually needed.
- Don't be explicit about what interface attribute is attaching if
  the device only has one.  (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
  situations, making is visibly easier to see when indirect config is
  in play, and allowing for future change in semantics.  (As of now,
  this is just a wrapper around config_match(), but that is an
  implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance.  This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).

Revision 1.91.2.8 / (download) - annotate - [select for diffs], Tue Apr 6 00:16:48 2021 UTC (22 months ago) by thorpej
Branch: thorpej-cfargs
Changes since 1.91.2.7: +2 -3 lines
Diff to previous 1.91.2.7 (colored) to branchpoint 1.91 (colored) next main 1.92 (colored)

audiosearch(): Remove a stray CFARG_LOCATORS tag.

Revision 1.91.2.7 / (download) - annotate - [select for diffs], Mon Apr 5 00:48:53 2021 UTC (22 months ago) by thorpej
Branch: thorpej-cfargs
Changes since 1.91.2.6: +3 -3 lines
Diff to previous 1.91.2.6 (colored) to branchpoint 1.91 (colored)

config_match() -> config_probe() for the straight-forward indirect config
cases.  There are still a few odd balls using config_match() which should
be sorted out later.

Revision 1.91.2.6 / (download) - annotate - [select for diffs], Sun Apr 4 22:01:21 2021 UTC (22 months ago) by thorpej
Branch: thorpej-cfargs
Changes since 1.91.2.5: +3 -3 lines
Diff to previous 1.91.2.5 (colored) to branchpoint 1.91 (colored)

CFARG_SUBMATCH -> CFARG_SEARCH for the indirect configuration uses.

Revision 1.79.2.3 / (download) - annotate - [select for diffs], Sat Apr 3 22:28:43 2021 UTC (22 months ago) by thorpej
Branch: thorpej-futex
Changes since 1.79.2.2: +324 -178 lines
Diff to previous 1.79.2.2 (colored) next main 1.80 (colored)

Sync with HEAD.

Revision 1.91.2.5 / (download) - annotate - [select for diffs], Sat Apr 3 06:54:28 2021 UTC (22 months ago) by thorpej
Branch: thorpej-cfargs
Changes since 1.91.2.4: +5 -3 lines
Diff to previous 1.91.2.4 (colored) to branchpoint 1.91 (colored)

config_attach_loc() -> config_attach() with CFARG_LOCATORS argument.

Revision 1.91.2.4 / (download) - annotate - [select for diffs], Sun Mar 28 19:55:37 2021 UTC (22 months, 1 week ago) by thorpej
Branch: thorpej-cfargs
Changes since 1.91.2.3: +3 -5 lines
Diff to previous 1.91.2.3 (colored) to branchpoint 1.91 (colored)

audio only has one interface attribute, so no need to be explcit about it.
audio also doesn't have locators, so don't pass any to config_search().

Revision 1.91.2.3 / (download) - annotate - [select for diffs], Sun Mar 21 21:09:09 2021 UTC (22 months, 2 weeks ago) by thorpej
Branch: thorpej-cfargs
Changes since 1.91.2.2: +3 -3 lines
Diff to previous 1.91.2.2 (colored) to branchpoint 1.91 (colored)

Give config_found() the same variadic arguments treatment as
config_search().  This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls.  Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.

Revision 1.91.2.2 / (download) - annotate - [select for diffs], Sun Mar 21 19:06:19 2021 UTC (22 months, 2 weeks ago) by thorpej
Branch: thorpej-cfargs
Changes since 1.91.2.1: +5 -7 lines
Diff to previous 1.91.2.1 (colored) to branchpoint 1.91 (colored)

In "rescan" routines, always pass locators and the interface attribute
straight through to config_search().  Also, for devices that carry only
one interface attribute, no need to do an ifattr_match(), because
rescan_with_cfdata() will have already validated that the parent is
eligible, which includes an interface attribute check.

Revision 1.91.2.1 / (download) - annotate - [select for diffs], Sat Mar 20 19:33:40 2021 UTC (22 months, 2 weeks ago) by thorpej
Branch: thorpej-cfargs
Changes since 1.91: +6 -3 lines
Diff to previous 1.91 (colored)

The proliferation if config_search_*() and config_found_*() combinations
is a little absurd, so begin to tidy this up:

- Introduce a new cfarg_t enumerated type, that defines the types of
  tag-value variadic arguments that can be passed to the various
  config_*() functions (CFARG_SUBMATCH, CFARG_IATTR, and CFARG_LOCATORS,
  for now, plus a CFARG_EOL sentinel).
- Collapse config_search_*() into config_search() that takes these
  variadic arguments.
- Convert all call sites of config_search_*() to the new signature.
  Noticed several incorrect usages along the way, which will be
  audited in a future commit.

Revision 1.28.2.21 / (download) - annotate - [select for diffs], Mon Mar 1 16:00:08 2021 UTC (23 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.20: +232 -101 lines
Diff to previous 1.28.2.20 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #1219):

	sys/dev/audio/audio.c: revision 1.89
	sys/dev/audio/audio.c: revision 1.90
	sys/dev/audio/audio.c: revision 1.91

Change the lock conditions to call audio_unlink().

This can remove a different copy of audio_exlock_enter() in audio_unlink()
and can use normal one.  Also, in audiodetach(), this can set the exlock
at more natual order (before calling audio_unlink()).

No noticeable functional changes are intended.
Thanks for comments, riastradh@.

Protect also audioopen() and audiobellopen() from audiodetach() with
psref(9), as well as others(audioread, audiowrite, etc..).
- Rename audio_file_enter to audio_sc_acquire_fromfile, audio_file_exit
  to audio_sc_release, for clarify.  These are the reference counter for
  this sc.
- Introduce audio_sc_acquire_foropen for audio{,bell}open.
- audio_open needs to examine sc_dying again before inserting it into
  sc_files, in order to keep sc_files consistency.

The race between audiodetach and audioopen is pointed out by riastradh@.
Thank you for many advices.

Add missing curlwp_bindx() corresponding to curlwp_bind().
Pointed out by riastradh@.

Revision 1.28.2.20 / (download) - annotate - [select for diffs], Sun Feb 28 07:07:38 2021 UTC (23 months, 1 week ago) by martin
Branch: netbsd-9
Changes since 1.28.2.19: +3 -3 lines
Diff to previous 1.28.2.19 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #1218):

	sys/dev/audio/audio.c: revision 1.84

Fix a return value of audiopoll().
fo_poll is expected to return revents rather than errno on error.

Revision 1.28.2.19 / (download) - annotate - [select for diffs], Sun Feb 28 07:05:14 2021 UTC (23 months, 1 week ago) by martin
Branch: netbsd-9
Changes since 1.28.2.18: +101 -82 lines
Diff to previous 1.28.2.18 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #1217):

	sys/dev/audio/audio.c: revision 1.46
	sys/dev/audio/audio.c: revision 1.82
	sys/dev/audio/audio.c: revision 1.85
	sys/dev/audio/audio.c: revision 1.87
	sys/dev/audio/audio.c: revision 1.88

Change two aprint_error_dev() to device_printf() (and improve messages).
This is also called from other than boot.

Add missing newline.

Revise comments.

Change (harmless) zero-length debug messages.
sys/modules is compiled with -Wzero-length-format and this
makes sys/modules compilable even if AUDIO_DEBUG is defined.

Improve error messages.
- prefix MD device name if it's considered to be related to the MD driver.
- revise some messages.

Revision 1.91 / (download) - annotate - [select for diffs], Sun Feb 14 03:41:13 2021 UTC (23 months, 3 weeks ago) by isaki
Branch: MAIN
CVS Tags: thorpej-futex-base, thorpej-cfargs-base
Branch point for: thorpej-cfargs
Changes since 1.90: +91 -29 lines
Diff to previous 1.90 (colored)

Add missing curlwp_bindx() corresponding to curlwp_bind().
Pointed out by riastradh@.

Revision 1.90 / (download) - annotate - [select for diffs], Tue Feb 9 12:36:34 2021 UTC (23 months, 3 weeks ago) by isaki
Branch: MAIN
Changes since 1.89: +126 -53 lines
Diff to previous 1.89 (colored)

Protect also audioopen() and audiobellopen() from audiodetach() with
psref(9), as well as others(audioread, audiowrite, etc..).
- Rename audio_file_enter to audio_sc_acquire_fromfile, audio_file_exit
  to audio_sc_release, for clarify.  These are the reference counter for
  this sc.
- Introduce audio_sc_acquire_foropen for audio{,bell}open.
- audio_open needs to examine sc_dying again before inserting it into
  sc_files, in order to keep sc_files consistency.
The race between audiodetach and audioopen is pointed out by riastradh@.
Thank you for many advices.

Revision 1.89 / (download) - annotate - [select for diffs], Tue Feb 9 05:53:14 2021 UTC (23 months, 3 weeks ago) by isaki
Branch: MAIN
Changes since 1.88: +22 -26 lines
Diff to previous 1.88 (colored)

Change the lock conditions to call audio_unlink().
This can remove a different copy of audio_exlock_enter() in audio_unlink()
and can use normal one.  Also, in audiodetach(), this can set the exlock
at more natual order (before calling audio_unlink()).
No noticeable functional changes are intended.
Thanks for comments, riastradh@.

Revision 1.88 / (download) - annotate - [select for diffs], Fri Jan 15 05:34:49 2021 UTC (2 years ago) by isaki
Branch: MAIN
Changes since 1.87: +90 -75 lines
Diff to previous 1.87 (colored)

Improve error messages.
- prefix MD device name if it's considered to be related to the MD driver.
- revise some messages.

Revision 1.87 / (download) - annotate - [select for diffs], Fri Jan 15 04:09:28 2021 UTC (2 years ago) by isaki
Branch: MAIN
Changes since 1.86: +8 -8 lines
Diff to previous 1.86 (colored)

Change (harmless) zero-length debug messages.
sys/modules is compiled with -Wzero-length-format and this
makes sys/modules compilable even if AUDIO_DEBUG is defined.

Revision 1.79.2.2 / (download) - annotate - [select for diffs], Sun Jan 3 16:34:57 2021 UTC (2 years, 1 month ago) by thorpej
Branch: thorpej-futex
Changes since 1.79.2.1: +9 -12 lines
Diff to previous 1.79.2.1 (colored)

Sync w/ HEAD.

Revision 1.28.2.18 / (download) - annotate - [select for diffs], Sat Dec 19 13:54:56 2020 UTC (2 years, 1 month ago) by martin
Branch: netbsd-9
Changes since 1.28.2.17: +3 -3 lines
Diff to previous 1.28.2.17 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #1158):

	sys/dev/audio/audio.c: revision 1.83

Avoid a dead lock in audiodetach, since rev 1.63.
audio_unlink() must be called without exlock held (and
audio_mixer_destroy() must be called with exlock held).

This makes unplugging during playing/recording work (again).

Reported by Julian Coleman on current-users:
 http://mail-index.netbsd.org/current-users/2020/12/10/msg040050.html

Revision 1.28.2.17 / (download) - annotate - [select for diffs], Sat Dec 19 13:48:27 2020 UTC (2 years, 1 month ago) by martin
Branch: netbsd-9
Changes since 1.28.2.16: +57 -28 lines
Diff to previous 1.28.2.16 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #1156):

	sys/dev/audio/audio.c: revision 1.80
	sys/dev/audio/audio.c: revision 1.81

Fix that audio_open() didn't halt the recording mixer correctly
if fd_allocfile() failed, since rev 1.65.

Will fix PR kern/55848.

 -

Rewrite error handling on audio_open().
This also fixes a few resource leaks on error case.

Revision 1.86 / (download) - annotate - [select for diffs], Sat Dec 19 01:18:58 2020 UTC (2 years, 1 month ago) by thorpej
Branch: MAIN
Changes since 1.85: +9 -12 lines
Diff to previous 1.85 (colored)

Use sel{record,remove}_knote().

Revision 1.79.2.1 / (download) - annotate - [select for diffs], Mon Dec 14 14:38:05 2020 UTC (2 years, 1 month ago) by thorpej
Branch: thorpej-futex
Changes since 1.79: +65 -34 lines
Diff to previous 1.79 (colored)

Sync w/ HEAD.

Revision 1.85 / (download) - annotate - [select for diffs], Sun Dec 13 05:47:08 2020 UTC (2 years, 1 month ago) by isaki
Branch: MAIN
Changes since 1.84: +6 -5 lines
Diff to previous 1.84 (colored)

Revise comments.

Revision 1.84 / (download) - annotate - [select for diffs], Sun Dec 13 05:44:09 2020 UTC (2 years, 1 month ago) by isaki
Branch: MAIN
Changes since 1.83: +3 -3 lines
Diff to previous 1.83 (colored)

Fix a return value of audiopoll().
fo_poll is expected to return revents rather than errno on error.

Revision 1.83 / (download) - annotate - [select for diffs], Sun Dec 13 05:29:19 2020 UTC (2 years, 1 month ago) by isaki
Branch: MAIN
Changes since 1.82: +3 -3 lines
Diff to previous 1.82 (colored)

Avoid a dead lock in audiodetach, since rev 1.63.
audio_unlink() must be called without exlock held (and
audio_mixer_destroy() must be called with exlock held).
This makes unplugging during playing/recording work (again).
Reported by Julian Coleman on current-users:
 http://mail-index.netbsd.org/current-users/2020/12/10/msg040050.html

Revision 1.82 / (download) - annotate - [select for diffs], Sun Dec 13 05:21:12 2020 UTC (2 years, 1 month ago) by isaki
Branch: MAIN
Changes since 1.81: +4 -3 lines
Diff to previous 1.81 (colored)

Add missing newline.

Revision 1.81 / (download) - annotate - [select for diffs], Wed Dec 9 04:30:39 2020 UTC (2 years, 1 month ago) by isaki
Branch: MAIN
Changes since 1.80: +44 -25 lines
Diff to previous 1.80 (colored)

Rewrite error handling on audio_open().
This also fixes a few resource leaks on error case.

Revision 1.80 / (download) - annotate - [select for diffs], Wed Dec 9 04:24:08 2020 UTC (2 years, 1 month ago) by isaki
Branch: MAIN
Changes since 1.79: +17 -7 lines
Diff to previous 1.79 (colored)

Fix that audio_open() didn't halt the recording mixer correctly
if fd_allocfile() failed, since rev 1.65.
Will fix PR kern/55848.

Revision 1.79 / (download) - annotate - [select for diffs], Mon Sep 7 03:36:11 2020 UTC (2 years, 4 months ago) by isaki
Branch: MAIN
Branch point for: thorpej-futex
Changes since 1.78: +5 -5 lines
Diff to previous 1.78 (colored)

Fix misspellings in comment.

Revision 1.78 / (download) - annotate - [select for diffs], Sun Aug 23 04:20:01 2020 UTC (2 years, 5 months ago) by isaki
Branch: MAIN
Changes since 1.77: +4 -4 lines
Diff to previous 1.77 (colored)

Improve debug messages.

Revision 1.77 / (download) - annotate - [select for diffs], Sun Aug 23 04:14:57 2020 UTC (2 years, 5 months ago) by isaki
Branch: MAIN
Changes since 1.76: +6 -5 lines
Diff to previous 1.76 (colored)

Improve and update comments.

Revision 1.76 / (download) - annotate - [select for diffs], Sun Aug 23 04:07:23 2020 UTC (2 years, 5 months ago) by isaki
Branch: MAIN
Changes since 1.75: +8 -6 lines
Diff to previous 1.75 (colored)

Style fixes.

Revision 1.28.2.16 / (download) - annotate - [select for diffs], Sun Jun 7 19:04:00 2020 UTC (2 years, 7 months ago) by martin
Branch: netbsd-9
CVS Tags: netbsd-9-1-RELEASE
Changes since 1.28.2.15: +27 -5 lines
Diff to previous 1.28.2.15 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #950):

	sys/dev/audio/audio.c: revision 1.71
	sys/dev/audio/audio.c: revision 1.73
	sys/dev/audio/audio.c: revision 1.74
	sys/dev/audio/audio.c: revision 1.75
	sys/dev/audio/audiovar.h: revision 1.12

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

audio: remove comment that is no longer valid

audio: Only restart recording mixer on resume if it's already been started

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.

Revision 1.75 / (download) - annotate - [select for diffs], Fri May 29 03:09:14 2020 UTC (2 years, 8 months ago) by isaki
Branch: MAIN
Changes since 1.74: +29 -4 lines
Diff to previous 1.74 (colored)

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.

Revision 1.74 / (download) - annotate - [select for diffs], Tue May 26 15:20:16 2020 UTC (2 years, 8 months ago) by nia
Branch: MAIN
Changes since 1.73: +3 -3 lines
Diff to previous 1.73 (colored)

audio: Only restart recording mixer on resume if it's already been started

Revision 1.73 / (download) - annotate - [select for diffs], Tue May 26 11:43:00 2020 UTC (2 years, 8 months ago) by nia
Branch: MAIN
Changes since 1.72: +2 -3 lines
Diff to previous 1.72 (colored)

audio: remove comment that is no longer valid

Revision 1.72 / (download) - annotate - [select for diffs], Tue May 26 10:12:12 2020 UTC (2 years, 8 months ago) by nia
Branch: MAIN
Changes since 1.71: +12 -8 lines
Diff to previous 1.71 (colored)

audio: Restore compat with Solaris for 8-bit LINEAR.

It's always signed, unless it's LINEAR8.

PR kern/55175

Revision 1.71 / (download) - annotate - [select for diffs], Tue May 26 10:07:29 2020 UTC (2 years, 8 months ago) by nia
Branch: MAIN
Changes since 1.70: +4 -6 lines
Diff to previous 1.70 (colored)

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

Revision 1.70 / (download) - annotate - [select for diffs], Sat May 23 23:42:42 2020 UTC (2 years, 8 months ago) by ad
Branch: MAIN
Changes since 1.69: +6 -6 lines
Diff to previous 1.69 (colored)

Move proc_lock into the data segment.  It was dynamically allocated because
at the time we had mutex_obj_alloc() but not __cacheline_aligned.

Revision 1.28.2.15 / (download) - annotate - [select for diffs], Mon May 18 18:12:24 2020 UTC (2 years, 8 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.14: +24 -2 lines
Diff to previous 1.28.2.14 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #911):

	sys/dev/audio/audiodef.h: revision 1.13
	sys/dev/audio/audiodef.h: revision 1.14
	sys/arch/sparc/include/param.h: revision 1.74
	sys/arch/evbarm/conf/GENERIC64: revision 1.148
	sys/arch/sh3/include/param.h: revision 1.25
	sys/arch/evbarm/conf/GENERIC: revision 1.75
	sys/arch/m68k/include/param.h: revision 1.23
	sys/arch/amd64/conf/GENERIC: revision 1.564
	sys/arch/hppa/include/param.h: revision 1.27
	sys/dev/audio/audio.c: revision 1.68
	sys/arch/vax/include/param.h: revision 1.63
	sys/dev/audio/audio.c: revision 1.69

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.

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@.


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

Revision 1.28.2.14 / (download) - annotate - [select for diffs], Mon May 18 18:05:34 2020 UTC (2 years, 8 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.13: +30 -12 lines
Diff to previous 1.28.2.13 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #910):

	sys/dev/audio/audio.c: revision 1.49
	sys/dev/audio/audio.c: revision 1.61
	sys/dev/audio/audio.c: revision 1.66
	sys/dev/audio/audio.c: revision 1.67

Move #if DIAGNOSTIC..#endif to correct place.
It should ignore stray interrupts regardless of DIAGNOSTIC.

Improve an error message about round_blocksize.

Improve diagnostic messages.

Improve the blocksize notation.
The blocksize is expressed in bytes, and the millisecond notation
is supplementary information to make it easier to understand.

Revision 1.28.2.13 / (download) - annotate - [select for diffs], Mon May 18 18:02:23 2020 UTC (2 years, 8 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.12: +30 -14 lines
Diff to previous 1.28.2.12 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #909):

	sys/dev/audio/audio.c: revision 1.65

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).

Revision 1.69 / (download) - annotate - [select for diffs], Fri May 1 08:21:27 2020 UTC (2 years, 9 months ago) by isaki
Branch: MAIN
Changes since 1.68: +12 -25 lines
Diff to previous 1.68 (colored)

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

Revision 1.28.2.12 / (download) - annotate - [select for diffs], Thu Apr 30 16:05:18 2020 UTC (2 years, 9 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.11: +319 -268 lines
Diff to previous 1.28.2.11 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #877):

	sys/dev/audio/audio.c: revision 1.55
	sys/dev/audio/audio.c: revision 1.41
	sys/dev/audio/audio.c: revision 1.48
	sys/dev/audio/audiovar.h: revision 1.7
	sys/dev/audio/audio.c: revision 1.63 (via patch)
	sys/dev/audio/audiovar.h: revision 1.11
	sys/dev/audio/audio.c: revision 1.64

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.

hw_if->query_format is already mandatory method.  Drop null checks.

Improve error handling around audio_hw_probe().
It was difficult to return multiple errors.

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@.

Fix/Update comments about allocm/freem.

Revision 1.28.2.11 / (download) - annotate - [select for diffs], Thu Apr 30 15:43:30 2020 UTC (2 years, 9 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.10: +132 -85 lines
Diff to previous 1.28.2.10 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #876):

	sys/dev/audio/audio.c: revision 1.60
	sys/dev/audio/audio.c: revision 1.62

Fix wrong parameter displayed in debug messages.

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.

Revision 1.28.2.10 / (download) - annotate - [select for diffs], Thu Apr 30 15:40:50 2020 UTC (2 years, 9 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.9: +28 -6 lines
Diff to previous 1.28.2.9 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #875):

	sys/dev/audio/audio.c: revision 1.59
	share/man/man4/audio.4: revision 1.102
	share/man/man4/audio.4: revision 1.103
	sys/dev/audio/audio.c: revision 1.43

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.


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.


Add description about channel limitation introduced in audio.c 1.43.
PR kern/54973.

Remove trailing whitespace.

Revision 1.68 / (download) - annotate - [select for diffs], Wed Apr 29 03:58:27 2020 UTC (2 years, 9 months ago) by isaki
Branch: MAIN
Changes since 1.67: +37 -2 lines
Diff to previous 1.67 (colored)

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@.

Revision 1.16.2.4 / (download) - annotate - [select for diffs], Tue Apr 21 18:42:15 2020 UTC (2 years, 9 months ago) by martin
Branch: phil-wifi
Changes since 1.16.2.3: +17 -4 lines
Diff to previous 1.16.2.3 (colored) next main 1.17 (colored)

Sync with HEAD

Revision 1.65.2.1 / (download) - annotate - [select for diffs], Mon Apr 20 11:29:03 2020 UTC (2 years, 9 months ago) by bouyer
Branch: bouyer-xenpvh
Changes since 1.65: +19 -6 lines
Diff to previous 1.65 (colored) next main 1.66 (colored)

Sync with HEAD

Revision 1.67 / (download) - annotate - [select for diffs], Sun Apr 19 03:52:22 2020 UTC (2 years, 9 months ago) by isaki
Branch: MAIN
CVS Tags: phil-wifi-20200421, bouyer-xenpvh-base2, bouyer-xenpvh-base1
Changes since 1.66: +13 -4 lines
Diff to previous 1.66 (colored)

Improve the blocksize notation.
The blocksize is expressed in bytes, and the millisecond notation
is supplementary information to make it easier to understand.

Revision 1.66 / (download) - annotate - [select for diffs], Fri Apr 17 07:48:35 2020 UTC (2 years, 9 months ago) by isaki
Branch: MAIN
Changes since 1.65: +8 -4 lines
Diff to previous 1.65 (colored)

Improve diagnostic messages.

Revision 1.16.2.3 / (download) - annotate - [select for diffs], Mon Apr 13 08:04:18 2020 UTC (2 years, 9 months ago) by martin
Branch: phil-wifi
Changes since 1.16.2.2: +1108 -853 lines
Diff to previous 1.16.2.2 (colored)

Mostly merge changes from HEAD upto 20200411

Revision 1.65 / (download) - annotate - [select for diffs], Thu Mar 26 13:32:03 2020 UTC (2 years, 10 months ago) by isaki
Branch: MAIN
CVS Tags: phil-wifi-20200411, phil-wifi-20200406, bouyer-xenpvh-base
Branch point for: bouyer-xenpvh
Changes since 1.64: +30 -14 lines
Diff to previous 1.64 (colored)

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).

Revision 1.28.2.9 / (download) - annotate - [select for diffs], Sat Mar 21 15:47:00 2020 UTC (2 years, 10 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.8: +252 -104 lines
Diff to previous 1.28.2.8 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #794):

	sys/dev/audio/audiodef.h: revision 1.10
	sys/dev/audio/audio.c: revision 1.56 (via patch)
	sys/dev/audio/audio.c: revision 1.57
	sys/dev/audio/audiovar.h: revision 1.8
	sys/dev/audio/audio.c: revision 1.38

Remove obsoleted comment.

Prevent a race between audiodetach and fileops methods using psref(9).
Fix PR kern/54427.
Thank you so much riastradh@

Release memories on audiobellclose.
It's rest of the last commit.

Revision 1.28.2.8 / (download) - annotate - [select for diffs], Sat Mar 21 15:41:18 2020 UTC (2 years, 10 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.7: +81 -61 lines
Diff to previous 1.28.2.7 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #793):

	sys/dev/audio/audio.c: revision 1.42
	sys/dev/audio/audio.c: revision 1.47
	sys/dev/audio/audiodef.h: revision 1.9

Remove incorrect KASSERT(!mutex_owned()).
Pointed out by riastradh@.

Improve KASSERT messages.

Revision 1.64 / (download) - annotate - [select for diffs], Sat Mar 7 06:27:19 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.63: +6 -11 lines
Diff to previous 1.63 (colored)

Fix/Update comments about allocm/freem.

Revision 1.63 / (download) - annotate - [select for diffs], Sat Mar 7 06:25:57 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.62: +207 -142 lines
Diff to previous 1.62 (colored)

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@.

Revision 1.62 / (download) - annotate - [select for diffs], Wed Mar 4 14:19:41 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.61: +132 -89 lines
Diff to previous 1.61 (colored)

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.

Revision 1.61 / (download) - annotate - [select for diffs], Sun Mar 1 07:42:07 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
CVS Tags: is-mlppp-base, is-mlppp
Changes since 1.60: +9 -4 lines
Diff to previous 1.60 (colored)

Improve an error message about round_blocksize.

Revision 1.60 / (download) - annotate - [select for diffs], Sun Mar 1 07:40:03 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.59: +14 -10 lines
Diff to previous 1.59 (colored)

Fix wrong parameter displayed in debug messages.

Revision 1.59 / (download) - annotate - [select for diffs], Sun Mar 1 07:35:33 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.58: +14 -2 lines
Diff to previous 1.58 (colored)

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.

Revision 1.37.2.2 / (download) - annotate - [select for diffs], Sat Feb 29 20:19:07 2020 UTC (2 years, 11 months ago) by ad
Branch: ad-namecache
Changes since 1.37.2.1: +443 -301 lines
Diff to previous 1.37.2.1 (colored) to branchpoint 1.37 (colored) next main 1.38 (colored)

Sync with head.

Revision 1.58 / (download) - annotate - [select for diffs], Sat Feb 29 09:38:10 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
CVS Tags: ad-namecache-base3
Changes since 1.57: +5 -5 lines
Diff to previous 1.57 (colored)

Minor fix.  audio_prinfo.pause is u_char, not bool.

Revision 1.57 / (download) - annotate - [select for diffs], Sat Feb 29 07:13:37 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.56: +7 -2 lines
Diff to previous 1.56 (colored)

Release memories on audiobellclose.
It's rest of the last commit.

Revision 1.56 / (download) - annotate - [select for diffs], Sun Feb 23 07:17:01 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.55: +248 -100 lines
Diff to previous 1.55 (colored)

Prevent a race between audiodetach and fileops methods using psref(9).
Fix PR kern/54427.
Thank you so much riastradh@

Revision 1.55 / (download) - annotate - [select for diffs], Sun Feb 23 04:24:56 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.54: +44 -76 lines
Diff to previous 1.54 (colored)

Improve error handling around audio_hw_probe().
It was difficult to return multiple errors.

Revision 1.54 / (download) - annotate - [select for diffs], Sun Feb 23 04:02:46 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.53: +27 -17 lines
Diff to previous 1.53 (colored)

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.

Revision 1.53 / (download) - annotate - [select for diffs], Sat Feb 22 19:49:11 2020 UTC (2 years, 11 months ago) by chs
Branch: MAIN
Changes since 1.52: +3 -3 lines
Diff to previous 1.52 (colored)

remove some unnecessary includes of internal UVM headers.

Revision 1.52 / (download) - annotate - [select for diffs], Sat Feb 22 08:15:09 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.51: +3 -5 lines
Diff to previous 1.51 (colored)

Make calling get_props() lockless.
get_props() of all MD drivers now can be called without sc_lock.

Revision 1.51 / (download) - annotate - [select for diffs], Sat Feb 22 08:03:19 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.50: +4 -4 lines
Diff to previous 1.50 (colored)

On audio_[pr]mixer_halt(), it's better to reset parameters in intr_lock.

Revision 1.50 / (download) - annotate - [select for diffs], Sat Feb 22 08:01:59 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.49: +6 -4 lines
Diff to previous 1.49 (colored)

Add KASSERTs.  audio_[pr]mixer_start() need exlock.

Revision 1.49 / (download) - annotate - [select for diffs], Sat Feb 22 07:59:47 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.48: +6 -6 lines
Diff to previous 1.48 (colored)

Move #if DIAGNOSTIC..#endif to correct place.
It should ignore stray interrupts regardless of DIAGNOSTIC.

Revision 1.48 / (download) - annotate - [select for diffs], Sat Feb 22 07:09:18 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.47: +7 -26 lines
Diff to previous 1.47 (colored)

hw_if->query_format is already mandatory method.  Drop null checks.

Revision 1.47 / (download) - annotate - [select for diffs], Sat Feb 22 06:58:39 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.46: +58 -42 lines
Diff to previous 1.46 (colored)

Improve KASSERT messages.

Revision 1.46 / (download) - annotate - [select for diffs], Sat Feb 22 06:36:07 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.45: +8 -6 lines
Diff to previous 1.45 (colored)

Change two aprint_error_dev() to device_printf() (and improve messages).
This is also called from other than boot.

Revision 1.45 / (download) - annotate - [select for diffs], Sat Feb 22 06:28:10 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.44: +4 -5 lines
Diff to previous 1.44 (colored)

const-ify.  These arguments are no longer written back.

Revision 1.44 / (download) - annotate - [select for diffs], Sat Feb 22 06:22:46 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.43: +5 -6 lines
Diff to previous 1.43 (colored)

Fix/Update comments.

Revision 1.43 / (download) - annotate - [select for diffs], Sat Feb 22 05:51:39 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.42: +16 -6 lines
Diff to previous 1.42 (colored)

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.

Revision 1.42 / (download) - annotate - [select for diffs], Sat Feb 15 02:47:00 2020 UTC (2 years, 11 months ago) by isaki
Branch: MAIN
Changes since 1.41: +25 -21 lines
Diff to previous 1.41 (colored)

Remove incorrect KASSERT(!mutex_owned()).
Pointed out by riastradh@.

Revision 1.28.2.7 / (download) - annotate - [select for diffs], Tue Jan 21 11:19:19 2020 UTC (3 years ago) by martin
Branch: netbsd-9
CVS Tags: netbsd-9-0-RELEASE, netbsd-9-0-RC2
Changes since 1.28.2.6: +17 -7 lines
Diff to previous 1.28.2.6 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #620):

	sys/dev/audio/audio.c: revision 1.39

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().

Revision 1.28.2.6 / (download) - annotate - [select for diffs], Tue Jan 21 11:17:58 2020 UTC (3 years ago) by martin
Branch: netbsd-9
Changes since 1.28.2.5: +3 -3 lines
Diff to previous 1.28.2.5 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #619):

	sys/dev/audio/audio.c: revision 1.37

Move mutex_exit() correct place to protect sc_async_mixer.
Thanks maxv@!

Revision 1.37.2.1 / (download) - annotate - [select for diffs], Fri Jan 17 21:47:30 2020 UTC (3 years ago) by ad
Branch: ad-namecache
Changes since 1.37: +83 -44 lines
Diff to previous 1.37 (colored)

Sync with head.

Revision 1.41 / (download) - annotate - [select for diffs], Sat Jan 11 04:53:10 2020 UTC (3 years ago) by isaki
Branch: MAIN
CVS Tags: ad-namecache-base2, ad-namecache-base1
Changes since 1.40: +68 -26 lines
Diff to previous 1.40 (colored)

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.

Revision 1.40 / (download) - annotate - [select for diffs], Sat Jan 11 04:06:13 2020 UTC (3 years ago) by isaki
Branch: MAIN
Changes since 1.39: +2 -10 lines
Diff to previous 1.39 (colored)

Remove old debug #ifdefs.

Revision 1.39 / (download) - annotate - [select for diffs], Wed Jan 8 13:30:15 2020 UTC (3 years ago) by isaki
Branch: MAIN
Changes since 1.38: +17 -7 lines
Diff to previous 1.38 (colored)

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().

Revision 1.38 / (download) - annotate - [select for diffs], Wed Jan 8 13:05:02 2020 UTC (3 years ago) by isaki
Branch: MAIN
Changes since 1.37: +2 -7 lines
Diff to previous 1.37 (colored)

Remove obsoleted comment.

Revision 1.37 / (download) - annotate - [select for diffs], Wed Jan 8 08:10:15 2020 UTC (3 years ago) by isaki
Branch: MAIN
CVS Tags: ad-namecache-base
Branch point for: ad-namecache
Changes since 1.36: +3 -3 lines
Diff to previous 1.36 (colored)

Move mutex_exit() correct place to protect sc_async_mixer.
Thanks maxv@!

Revision 1.28.2.5 / (download) - annotate - [select for diffs], Thu Jan 2 09:18:15 2020 UTC (3 years, 1 month ago) by martin
Branch: netbsd-9
Changes since 1.28.2.4: +16 -74 lines
Diff to previous 1.28.2.4 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #593):

	sys/dev/audio/audio.c: revision 1.34
	sys/dev/audio/audio.c: revision 1.35

Use M_WAITOK instead of M_NOWAIT.
These allocations don't require NOWAIT constraints.

Will fix PR kern/54796.

 -

Improve and simplify around audio_realloc().

Revision 1.36 / (download) - annotate - [select for diffs], Fri Dec 27 09:45:26 2019 UTC (3 years, 1 month ago) by msaitoh
Branch: MAIN
Changes since 1.35: +3 -3 lines
Diff to previous 1.35 (colored)

s/sucess/success/ in comment.

Revision 1.35 / (download) - annotate - [select for diffs], Thu Dec 26 11:27:03 2019 UTC (3 years, 1 month ago) by isaki
Branch: MAIN
Changes since 1.34: +16 -74 lines
Diff to previous 1.34 (colored)

Improve and simplify around audio_realloc().

Revision 1.34 / (download) - annotate - [select for diffs], Thu Dec 26 11:24:55 2019 UTC (3 years, 1 month ago) by isaki
Branch: MAIN
Changes since 1.33: +4 -4 lines
Diff to previous 1.33 (colored)

Use M_WAITOK instead of M_NOWAIT.
These allocations don't require NOWAIT constraints.
Will fix PR kern/54796.

Revision 1.28.2.4 / (download) - annotate - [select for diffs], Tue Nov 19 12:58:29 2019 UTC (3 years, 2 months ago) by martin
Branch: netbsd-9
CVS Tags: netbsd-9-0-RC1
Changes since 1.28.2.3: +3 -3 lines
Diff to previous 1.28.2.3 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #448):

	sys/dev/audio/audio.c: revision 1.33

Fix a wrong calculation of recording ring buffer.  Reported on
http://mail-index.netbsd.org/current-users/2019/11/04/msg036976.html

Revision 1.33 / (download) - annotate - [select for diffs], Wed Nov 6 13:37:27 2019 UTC (3 years, 3 months ago) by isaki
Branch: MAIN
CVS Tags: phil-wifi-20191119
Changes since 1.32: +3 -3 lines
Diff to previous 1.32 (colored)

Fix a wrong calculation of recording ring buffer.  Reported on
http://mail-index.netbsd.org/current-users/2019/11/04/msg036976.html

Revision 1.32 / (download) - annotate - [select for diffs], Fri Oct 18 04:09:02 2019 UTC (3 years, 3 months ago) by msaitoh
Branch: MAIN
Changes since 1.31: +3 -3 lines
Diff to previous 1.31 (colored)

 s/initalize/initialize/ in comment or printf message.

Revision 1.28.2.3 / (download) - annotate - [select for diffs], Sun Oct 6 11:02:32 2019 UTC (3 years, 4 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.2: +5 -5 lines
Diff to previous 1.28.2.2 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #286):

	sys/dev/audio/audio.c: revision 1.31

Tune some debug message level.
These messages are important for debugging hardware driver.

Revision 1.28.2.2 / (download) - annotate - [select for diffs], Sun Oct 6 11:00:15 2019 UTC (3 years, 4 months ago) by martin
Branch: netbsd-9
Changes since 1.28.2.1: +36 -12 lines
Diff to previous 1.28.2.1 (colored) to branchpoint 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #285):

	sys/dev/audio/audiovar.h: revision 1.5
	sys/dev/audio/audio.c: revision 1.30

Fix lock assertion on async I/O mode.
psignal() must be called without any spin locks.
Thanks maxv@!

Revision 1.28.2.1 / (download) - annotate - [select for diffs], Sun Oct 6 10:58:14 2019 UTC (3 years, 4 months ago) by martin
Branch: netbsd-9
Changes since 1.28: +4 -2 lines
Diff to previous 1.28 (colored)

Pull up following revision(s) (requested by isaki in ticket #284):

	sys/dev/audio/audio.c: revision 1.29

Add missing mutex, we were hitting a KASSERT.

Revision 1.31 / (download) - annotate - [select for diffs], Fri Sep 6 06:44:45 2019 UTC (3 years, 5 months ago) by isaki
Branch: MAIN
Changes since 1.30: +5 -5 lines
Diff to previous 1.30 (colored)

Tune some debug message level.
These messages are important for debugging hardware driver.

Revision 1.30 / (download) - annotate - [select for diffs], Thu Aug 29 13:01:07 2019 UTC (3 years, 5 months ago) by isaki
Branch: MAIN
Changes since 1.29: +36 -12 lines
Diff to previous 1.29 (colored)

Fix lock assertion on async I/O mode.
psignal() must be called without any spin locks.
Thanks maxv@!

Revision 1.29 / (download) - annotate - [select for diffs], Fri Aug 23 09:41:26 2019 UTC (3 years, 5 months ago) by maxv
Branch: MAIN
Changes since 1.28: +4 -2 lines
Diff to previous 1.28 (colored)

Add missing mutex, we were hitting a KASSERT.

Revision 1.28 / (download) - annotate - [select for diffs], Wed Jul 10 13:26:47 2019 UTC (3 years, 6 months ago) by isaki
Branch: MAIN
CVS Tags: netbsd-9-base
Branch point for: netbsd-9
Changes since 1.27: +4 -10 lines
Diff to previous 1.27 (colored)

Use kmem_alloc/free() instead of old kern_malloc/free().

Revision 1.27 / (download) - annotate - [select for diffs], Wed Jul 10 13:17:57 2019 UTC (3 years, 6 months ago) by isaki
Branch: MAIN
Changes since 1.26: +5 -6 lines
Diff to previous 1.26 (colored)

Fix freem() argument.  The 3rd argument is bufsize, not direction...

Revision 1.26 / (download) - annotate - [select for diffs], Sun Jul 7 06:29:14 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.25: +14 -8 lines
Diff to previous 1.25 (colored)

Avoid memory reallocation on SET_FORMAT.

Revision 1.25 / (download) - annotate - [select for diffs], Sun Jul 7 06:14:21 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.24: +10 -9 lines
Diff to previous 1.24 (colored)

Rearrange some KASSERT and debug messages, to sync with others.

Revision 1.24 / (download) - annotate - [select for diffs], Sun Jul 7 06:06:46 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.23: +12 -13 lines
Diff to previous 1.23 (colored)

Fix to evaluate the validity of this track at earlier on audio_read().
It fixes a panic on read() against descriptor opened as O_RDWR on the
half duplex device.

Revision 1.23 / (download) - annotate - [select for diffs], Sat Jul 6 12:58:58 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.22: +81 -50 lines
Diff to previous 1.22 (colored)

Implement auto recovery of the mixing volume.

Revision 1.22 / (download) - annotate - [select for diffs], Wed Jun 26 07:47:25 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.21: +4 -5 lines
Diff to previous 1.21 (colored)

Improve debug message and remove duplicated one.

Revision 1.21 / (download) - annotate - [select for diffs], Wed Jun 26 06:57:45 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.20: +38 -40 lines
Diff to previous 1.20 (colored)

Improve audiobell (and interfaces with audio).
- Generate pseudo sine wave if possible.  It may improve timbre.
  If it cannot represent a sine wave, it falls back to a triangular
  wave or a rectangular wave.
- Volume adjustment.
- Calculate playback frequency based on mixer frequency.
  Now audiobellopen() initializes playback parameters other than
  sample_rate, and new audiobellsetrate() sets sample_rate.

Revision 1.20 / (download) - annotate - [select for diffs], Tue Jun 25 13:07:48 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.19: +11 -44 lines
Diff to previous 1.19 (colored)

Put the lowered mixing volume back when all playback tracks are closed.
TODO: about long life descriptor.

Revision 1.19 / (download) - annotate - [select for diffs], Sun Jun 23 01:46:56 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.18: +5 -2 lines
Diff to previous 1.18 (colored)

Restore sysctl_teardown which was unintentionally dropped.

Revision 1.18 / (download) - annotate - [select for diffs], Wed Jun 19 12:49:49 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.17: +3 -20 lines
Diff to previous 1.17 (colored)

Don't wait until a block is filled.
This improves that short sound breaks.

Revision 1.17 / (download) - annotate - [select for diffs], Wed Jun 12 13:53:25 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.16: +5 -2 lines
Diff to previous 1.16 (colored)

Fill silence if the last block of the first track is not filled.

Revision 1.16.2.2 / (download) - annotate - [select for diffs], Mon Jun 10 22:07:06 2019 UTC (3 years, 7 months ago) by christos
Branch: phil-wifi
Changes since 1.16.2.1: +8515 -0 lines
Diff to previous 1.16.2.1 (colored)

Sync with HEAD

Revision 1.16.2.1, Mon Jun 10 13:49:39 2019 UTC (3 years, 7 months ago) by christos
Branch: phil-wifi
Changes since 1.16: +0 -8498 lines
FILE REMOVED

file audio.c was added on branch phil-wifi on 2019-06-10 22:07:06 +0000

Revision 1.16 / (download) - annotate - [select for diffs], Mon Jun 10 13:49:39 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Branch point for: phil-wifi
Changes since 1.15: +33 -27 lines
Diff to previous 1.15 (colored)

Use AUDIO_SCALEDOWN() macro rather than seemingly strange ifdefs.
Discussed on source-changes-d.

Revision 1.15 / (download) - annotate - [select for diffs], Mon Jun 10 13:28:08 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.14: +6 -6 lines
Diff to previous 1.14 (colored)

Add missing newline to some error messages.

Revision 1.14 / (download) - annotate - [select for diffs], Mon Jun 10 13:12:51 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.13: +17 -40 lines
Diff to previous 1.13 (colored)

Call get_props() once at attach.

Revision 1.13 / (download) - annotate - [select for diffs], Sat Jun 8 08:20:10 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
CVS Tags: phil-wifi-20190609
Changes since 1.12: +31 -19 lines
Diff to previous 1.12 (colored)

Improve checking and displaying property.
- Full/half duplex and independentness are valid only on bidirectional
  device.
- MMAP is no longer hardware driver's property.

Revision 1.12 / (download) - annotate - [select for diffs], Sat Jun 8 08:02:37 2019 UTC (3 years, 7 months ago) by isaki
Branch: MAIN
Changes since 1.11: +2 -10 lines
Diff to previous 1.11 (colored)

Clean get_props().
- Make get_props() return AUDIO_PROP_{PLAYBACK,CAPTURE} properly.
  This eliminates need for audio.c to take care of such (old)
  drivers which don't return both of PLAYBACK and CAPTURE.
- All get_props() doesn't need to return AUDIO_PROP_MMAP.
  It is handled in the audio layer now.

Revision 1.11 / (download) - annotate - [select for diffs], Thu Jun 6 13:08:30 2019 UTC (3 years, 8 months ago) by isaki
Branch: MAIN
Changes since 1.10: +2 -7 lines
Diff to previous 1.10 (colored)

Revert rev1.7.
Don't take care of incorrect drivers.  They should be fixed.
PR kern/54264.  OK'ed by nakayama@-san.

Revision 1.10 / (download) - annotate - [select for diffs], Sat May 25 02:42:03 2019 UTC (3 years, 8 months ago) by isaki
Branch: MAIN
Changes since 1.9: +3 -3 lines
Diff to previous 1.9 (colored)

Fix typo in comment.

Revision 1.9 / (download) - annotate - [select for diffs], Thu May 23 12:20:27 2019 UTC (3 years, 8 months ago) by isaki
Branch: MAIN
Changes since 1.8: +15 -125 lines
Diff to previous 1.8 (colored)

Remove unnecessary file lock.
It has been introduced to prevent multiple syscalls entering
simultaneously.  But it's completely unnecessary.
It fixes firefox problem in PR kern/54177.

Revision 1.8 / (download) - annotate - [select for diffs], Tue May 21 12:52:57 2019 UTC (3 years, 8 months ago) by isaki
Branch: MAIN
Changes since 1.7: +16 -16 lines
Diff to previous 1.7 (colored)

Adjust debug message.  Inspired from PR kern/54177.

Revision 1.7 / (download) - annotate - [select for diffs], Mon May 13 08:50:25 2019 UTC (3 years, 8 months ago) by nakayama
Branch: MAIN
Changes since 1.6: +7 -2 lines
Diff to previous 1.6 (colored)

audio_open:
On full duplex hardware, the flags passed to hw_if->open() is always
(FREAD | FWRITE).  But some devices (e.g. uaudio) check its
capabilities at open(), so unidirection devices like USB speakers
always return EACCES.

Avoid open() failure on such devices by checking the capabilities of
the device and changing the flags passed to hw_if->open().

Revision 1.6 / (download) - annotate - [select for diffs], Mon May 13 07:53:56 2019 UTC (3 years, 8 months ago) by nakayama
Branch: MAIN
Changes since 1.5: +4 -3 lines
Diff to previous 1.5 (colored)

sysctl "multiuser" type is CTLTYPE_BOOL, so use bool instead of int.

Revision 1.5 / (download) - annotate - [select for diffs], Mon May 13 04:11:04 2019 UTC (3 years, 8 months ago) by nakayama
Branch: MAIN
Changes since 1.4: +12 -6 lines
Diff to previous 1.4 (colored)

audio_hw_probe:
Return error if both play and record probes failed.

Avoid audio is disabled on devices with only play like USB speakers.

Revision 1.4 / (download) - annotate - [select for diffs], Mon May 13 04:09:35 2019 UTC (3 years, 8 months ago) by nakayama
Branch: MAIN
Changes since 1.3: +13 -4 lines
Diff to previous 1.3 (colored)

audioattach:
Output the cause of the audio device disabled along with the error code.

Revision 1.3 / (download) - annotate - [select for diffs], Sat May 11 03:26:43 2019 UTC (3 years, 8 months ago) by maya
Branch: MAIN
Changes since 1.2: +3 -3 lines
Diff to previous 1.2 (colored)

Don't use a confusing GCC extension. NFC

Revision 1.2 / (download) - annotate - [select for diffs], Wed May 8 13:40:17 2019 UTC (3 years, 8 months ago) by isaki
Branch: MAIN
Changes since 1.1: +8605 -0 lines
Diff to previous 1.1 (colored)

Merge isaki-audio2 branch, the overhaul of audio subsystem.
- Interrupt-oriented system rather than thread-oriented.
- Improve stability, quality and performance.
- Split playback and record cleanly.  Improve halfduplex support.
- Many bugs are fixed including deadlocks, resource leaks, abuses, etc.
- Simplify audio filter mechanism.  The encoding/channels/frequency
  conversions are completely handled in the upper layer.  So the hard-
  ware driver only converts its hardware encoding (if necessary).
- audio_hw_if changes:
  - Obsoletes query_encoding and add query_format instead.
  - Obsoletes set_params and add set_format instead.
  - Remove drain, setfd, mappage.
  - The call sequences are changed.
- ioctl AUDIO_GETFD/SETFD, AUDIO_GETCHAN/SETCHAN are obsoleted.
- ioctl AUDIO_{QUERY,GET,SET}FORMAT are introduced.
- cleanup config attributes: au*conv and mulaw.
- All hardware drivers should follow it (I've done as much as possible).

Some file paths are changed:
- dev/audio.c         -> dev/audio/audio.c (rewritten)
- dev/audiovar.h      -> dev/audio/audiovar.h
- dev/audio_dai.h     -> dev/audio/audio_dai.h
- dev/audio_if.h      -> dev/audio/audio_if.h
- dev/audiobell.c     -> dev/audio/audiobell.c
- dev/audiobellvar.h  -> dev/audio/audiobellvar.h
- dev/mulaw.[ch]      -> dev/audio/mulaw.[ch] + dev/audio/alaw.c

Revision 1.1.2.9 / (download) - annotate - [select for diffs], Sun May 5 02:20:36 2019 UTC (3 years, 9 months ago) by isaki
Branch: isaki-audio2
Changes since 1.1.2.8: +40 -4 lines
Diff to previous 1.1.2.8 (colored) next main 1.2 (colored)

Revive multiuser control.

Revision 1.1.2.8 / (download) - annotate - [select for diffs], Sat May 4 07:41:50 2019 UTC (3 years, 9 months ago) by isaki
Branch: isaki-audio2
Changes since 1.1.2.7: +7 -9 lines
Diff to previous 1.1.2.7 (colored)

Improve comments.

Revision 1.1.2.7 / (download) - annotate - [select for diffs], Sat May 4 07:20:09 2019 UTC (3 years, 9 months ago) by isaki
Branch: isaki-audio2
Changes since 1.1.2.6: +4 -4 lines
Diff to previous 1.1.2.6 (colored)

Move dev/audio_if.h -> dev/audio/audio_if.h

Revision 1.1.2.6 / (download) - annotate - [select for diffs], Sat May 4 04:13:23 2019 UTC (3 years, 9 months ago) by isaki
Branch: isaki-audio2
Changes since 1.1.2.5: +2 -5 lines
Diff to previous 1.1.2.5 (colored)

Remove obsoleted methods in audio_hw_if.
- drain: is handled in audio upper layer now.
- mappage: is handled in audio upper layer now.
- setfd: no one uses and it's meaningless now.

Revision 1.1.2.5 / (download) - annotate - [select for diffs], Fri May 3 06:29:05 2019 UTC (3 years, 9 months ago) by isaki
Branch: isaki-audio2
Changes since 1.1.2.4: +3 -3 lines
Diff to previous 1.1.2.4 (colored)

Remove dev/audiovar.h.  It already have been just a link to
dev/audio/audiovar.h in this branch.

Revision 1.1.2.4 / (download) - annotate - [select for diffs], Fri May 3 05:15:33 2019 UTC (3 years, 9 months ago) by isaki
Branch: isaki-audio2
Changes since 1.1.2.3: +22 -207 lines
Diff to previous 1.1.2.3 (colored)

Remove query_encoding and set_params interfaces from audio_hw_if
and remove related backward compatible routines.
All drivers were converted to use new query_format/set_format.

Revision 1.1.2.3 / (download) - annotate - [select for diffs], Sat Apr 27 12:05:28 2019 UTC (3 years, 9 months ago) by isaki
Branch: isaki-audio2
Changes since 1.1.2.2: +54 -2 lines
Diff to previous 1.1.2.2 (colored)

Add audio_indexof_format().  It finds index matches with specified
audio_param_t from array of audio_format_t.
Formerly, it was auconv_set_converter() that convert userland
params to the hardware native (linear) format and such conversion
is unnecessary in audio2.  But some drivers have gotten index from
this format array using auconv_set_converter().  This function is
an alternative to such usage.

Revision 1.1.2.2 / (download) - annotate - [select for diffs], Wed Apr 24 12:14:56 2019 UTC (3 years, 9 months ago) by isaki
Branch: isaki-audio2
Changes since 1.1.2.1: +25 -9 lines
Diff to previous 1.1.2.1 (colored)

Accept if bufsize returned from round_buffersize() is a multiple of
blksize.

Revision 1.1.2.1 / (download) - annotate - [select for diffs], Sun Apr 21 04:28:59 2019 UTC (3 years, 9 months ago) by isaki
Branch: isaki-audio2
Changes since 1.1: +8691 -0 lines
Diff to previous 1.1 (colored)

Reimplement audio subsystem.
http://mail-index.netbsd.org/tech-kern/2019/04/01/msg024944.html
At first step, audio and devices tightly coupled to audio.
 audio.c -> dev/audio.c: completely rewritten.
 mulaw.c -> audio/mulaw.c, audio/alaw.c: improve quality.
 audiovar.h, mulaw.h: should be removed.
 audio/linear.c: efficient new linear-linear converter.
 auconv.[ch]: should be removed but need some functions for now.
 aurateconv, auvolconv: removed (new audio.c handles it).
 audiobell.c: efficient and small new bell driver.
 audiobelldata.h: removed 4KB sine wave data.
 pad/pad.c: catch up audio, but not cloneable for now.

Revision 1.1, Sun Apr 21 04:28:59 2019 UTC (3 years, 9 months ago) by isaki
Branch: MAIN
Branch point for: isaki-audio2
FILE REMOVED

file audio.c was initially added on branch isaki-audio2.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.




CVSweb <webmaster@jp.NetBSD.org>