Commit Graph

161 Commits

Author SHA1 Message Date
mlelstv
b96be097c6 Don't wait in interrupt context. 2019-11-16 22:06:49 +00:00
isaki
ede47d01be 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.
2019-06-08 08:02:36 +00:00
isaki
c6b8a0a474 Make it compilable even with debug option. 2019-05-25 04:41:53 +00:00
isaki
e622eac459 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
2019-05-08 13:40:13 +00:00
isaki
6291b1348d Use C99 style struct initializer to audio_hw_if. 2019-03-16 12:09:56 +00:00
mrg
fbffadb9f8 - add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
  this case, and thus can't be marked __dead easily
2019-02-03 03:19:25 +00:00
knakahara
7258e0fc2d Add comments about D_MPSAFE to functions called as struct linesw.l_ioctl. 2019-01-24 09:33:03 +00:00
jakllsch
269297e942 Correctly handle signed/unsigned quantities in kernel HID parser.
Should fix PR kern/53605.
2018-11-15 23:01:45 +00:00
riastradh
d1579b2d70 Rename min/max -> uimin/uimax for better honesty.
These functions are defined on unsigned int.  The generic name
min/max should not silently truncate to 32 bits on 64-bit systems.
This is purely a name change -- no functional change intended.

HOWEVER!  Some subsystems have

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

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

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

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

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

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

Maybe one day we can reintroduce min/max as type-generic things that
never silently truncate.  But we should avoid doing that for a while,
so that existing code has a chance to be detected by the compiler for
conversion to uimin/uimax without changing the semantics until we can
properly audit it all.  (Who knows, maybe in some cases integer
truncation is actually intended!)
2018-09-03 16:29:22 +00:00
bouyer
404d04cdb7 Factor out bus-independant HID code so that it can be shared by USB, bluetooth
and i2c.
dev/usb/ukbdmap.c is renamed to dev/hid/hidkbdmap.c
dev/usb/hid.[ch] moved to dev/hid/
usage pages moved from dev/usb/usbhid.h moved to dev/hid/hid.h,
and updated with OpenBSD entries.
bus-independant code moved from dev/usb/ums.c to dev/hid/hidms.c
(the same should be done for keyboard and touchpad drivers)

Needed for the upcoming HID over I2C support, proposed on tech-kern@
on Dec, 1.
2017-12-10 17:03:07 +00:00
nat
e68c19236b Remove references to BlueCore.
Enable XON/XOFF flowcontrol in SLIP layer depending on config response.
Send an acknowlegment packet on timeout/retry.
Compute tx{ack,seq} and rx{ack,seq} according to the specification.
2017-09-03 23:11:19 +00:00
nat
b79ea570a8 Apply the sequence number mask to txack. 2017-08-14 12:51:11 +00:00
nat
cb47fae4db Conform to the spec. with regards to acknowlegment packets. This prevents
the host controller from freezing.

Inmprove communication from inactive to active state.
2017-08-14 05:33:30 +00:00
nat
9923fa67d0 Ensure the XMIT flag is cleared before calling bth5_start.
This avoids a panic due to a diagnostic assertion.
2017-08-11 00:58:37 +00:00
nat
ed80d44262 Add support for btuart h5 3-wire protocol. 2017-08-10 13:22:19 +00:00
chs
fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00
nat
e1c6c0762d bt_lock is now used as the audio interrupt lock. This is more appropriate
as the interrupt lock deals with the hardware.

btsco audio works again with the new audio changes.
2017-05-28 04:12:13 +00:00
maxv
0d54b7825d Curious typo, found by mootja 2016-08-15 08:20:11 +00:00
msaitoh
8bc54e5be6 KNF. Remove extra spaces. No functional change. 2016-07-07 06:55:38 +00:00
plunky
42359c559e STRENGHT -> STRENGTH and misc spelling/whitespace. no functional change 2015-12-13 21:13:00 +00:00
dholland
1fbab01a93 More on PR 41200: headers that declare ioctls should include sys/ioccom.h.
This covers (I think) all the MI headers outside of external/ (and dist/).
2015-09-06 06:00:59 +00:00
christos
e7ae23fd9e include "ioconf.h" to get the 'void <driver>attach(int count);' prototype. 2015-08-20 14:40:16 +00:00
nat
8476b0d2f1 Wrap up calls to softint_schedule in kpeempt_[dis/en]able.
Addresses PR kern/48459.

This commit was approved by christos@
2015-07-10 22:03:12 +00:00
bouyer
3c96c24fae Add basic support for tap detection, emulating a left-click. 2015-07-03 14:18:18 +00:00
dholland
de33725fda use standard idiom - thanks riastradh@ 2015-05-09 22:23:40 +00:00
dholland
a409b95d7f Coverity CID 975184: don't ignore pmf_device_register failure.
(XXX: unfortunately all we can do for the moment is print a warning)
2015-05-09 21:31:05 +00:00
christos
e94e9e7953 goto out for negative lengths too. Really this test should either be removed
or turned into a KASSERT(). From max.
2015-05-08 11:47:53 +00:00
christos
087f193c39 Fix more memory leaks by changing the transmit routines to always free the
mbuf to send.
2015-04-30 16:01:51 +00:00
christos
6ff99d8719 free mbuf on failure (Brainy) 2015-04-27 17:36:41 +00:00
christos
72592701b8 CID 1293640/1 memory corruption/overrun 2015-04-16 19:53:19 +00:00
bouyer
8692d33ed3 Add support for Apple Magic Trackpad.
3 button emulation by detecting in which area of the bottom of
the device the trackpad's button is pressed.
Pointer move support with 1 finger touch, X/Y scroll with 2-finger touch.
TODO:
- detect tap to emulate button press and drag/n/drop.
- Detect and support zoom, if wsmouse allows to report this
2015-04-06 17:45:31 +00:00
nonaka
fa5e93a153 Added quirk for ELECOM M-XG2BB. 2014-12-13 19:28:55 +00:00
ozaki-r
433c9fcdef Replace callout_stop with callout_halt
In order to call callout_destroy for a callout safely, we have to ensure
the function of the callout is not running and pending. To do so, we should
use callout_halt, not callout_stop.

Discussed with martin@ and riastradh@.
2014-11-16 16:20:00 +00:00
rtr
651e5bd3f8 split PRU_SEND function out of pr_generic() usrreq switches and put into
separate functions

   xxx_send(struct socket *, struct mbuf *, struct mbuf *,
       struct mbuf *, struct lwp *)

  - always KASSERT(solocked(so)) even if not implemented

  - replace calls to pr_generic() with req = PRU_SEND with calls to
    pr_send()

rename existing functions that operate on PCB for consistency (and to
free up their names for xxx_send() PRUs

  - l2cap_send() -> l2cap_send_pcb()
  - sco_send() -> sco_send_pcb()
  - rfcomm_send() -> rfcomm_send_pcb()

patch reviewed by rmind
2014-08-05 07:55:31 +00:00
rtr
892163b8e9 split PRU_DISCONNECT, PRU_SHUTDOWN and PRU_ABORT function out of
pr_generic() usrreq switches and put into separate functions

   xxx_disconnect(struct socket *)
   xxx_shutdown(struct socket *)
   xxx_abort(struct socket *)

   - always KASSERT(solocked(so)) even if not implemented
   - replace calls to pr_generic() with req =
PRU_{DISCONNECT,SHUTDOWN,ABORT}
     with calls to pr_{disconnect,shutdown,abort}() respectively

rename existing internal functions used to implement above functionality
to permit use of the names for xxx_{disconnect,shutdown,abort}().

   - {l2cap,sco,rfcomm}_disconnect() ->
{l2cap,sco,rfcomm}_disconnect_pcb()
   - {unp,rip,tcp}_disconnect() -> {unp,rip,tcp}_disconnect1()
   - unp_shutdown() -> unp_shutdown1()

patch reviewed by rmind
2014-07-31 03:39:35 +00:00
rtr
ad6ae402db split PRU_CONNECT function out of pr_generic() usrreq switches and put
into seaparate functions

  xxx_listen(struct socket *, struct mbuf *)

  - always KASSERT(solocked(so)) and KASSERT(nam != NULL)
  - replace calls to pr_generic() with req = PRU_CONNECT with
    pr_connect()
  - rename existin {l2cap,sco,rfcomm}_connect() to
    {l2cap,sco,rfcomm}_connect_pcb() respectively to permit
    naming consistency with other protocols functions.
  - drop struct lwp * parameter from unp_connect() and at_pcbconnect()
    and use curlwp instead where appropriate.

patch reviewed by rmind
2014-07-30 10:04:25 +00:00
dholland
f9228f4225 Add d_discard to all struct cdevsw instances I could find.
All have been set to "nodiscard"; some should get a real implementation.
2014-07-25 08:10:31 +00:00
rtr
6dd8eef044 split PRU_BIND and PRU_LISTEN function out of pr_generic() usrreq
switches and put into separate functions
  xxx_bind(struct socket *, struct mbuf *)
  xxx_listen(struct socket *)

  - always KASSERT(solocked(so)) even if not implemented

  - replace calls to pr_generic() with req = PRU_BIND with call to
    pr_bind()

  - replace calls to pr_generic() with req = PRU_LISTEN with call to
    pr_listen()

  - drop struct lwp * parameter from at_pcbsetaddr(), in_pcbbind() and
    unp_bind() and always use curlwp.

rename existing functions that operate on PCB for consistency (and to
free up their names for xxx_{bind,listen}() PRUs

  - l2cap_{bind,listen}() -> l2cap_{bind,listen}_pcb()
  - sco_{bind,listen}() -> sco_{bind,listen}_pcb()
  - rfcomm_{bind,listen}() -> rfcomm_{bind,listen}_pcb()

patch reviewed by rmind

welcome to netbsd 6.99.48
2014-07-24 15:12:03 +00:00
rmind
56a73a7d30 netbt: rename some attach/detach functions to have _pcb suffix, so
we could use standard attach/detach naming for pr_usrreq functions.
No functional change.
2014-05-20 18:25:54 +00:00
dholland
a68f9396b6 Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
2014-03-16 05:20:22 +00:00
pooka
4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
christos
abf8e02e90 add __USE for debugging variables 2013-10-17 21:22:01 +00:00
martin
3f88fce981 #ifdef the "npress" variable, so it is only defined (and initialized) when
it is also used.
2013-09-12 12:20:01 +00:00
plunky
f99a352229 increase some diagnostics 2012-12-20 11:17:47 +00:00
plunky
6ea27368df when no link-mode is specified, explicitly set a mode of (int)0
otherwise l2cap_setmode() will fail during connection setup

for bthidev.c, this fixes a problem with Microsoft Wedge Touch
mouse (which may not be able to authenticate)

for btmagic.c, include this fix in case somebody tries that

related to PR/47286
2012-12-20 11:13:53 +00:00
chs
cbab9cadce split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.
2012-10-27 17:17:22 +00:00
dsl
e21a34c25e Add some pre-processor magic to verify that the type of the data item
passed to sysctl_createv() actually matches the declared type for
  the item itself.
In the places where the caller specifies a function and a structure
  address (typically the 'softc') an explicit (void *) cast is now needed.
Fixes bugs in sys/dev/acpi/asus_acpi.c sys/dev/bluetooth/bcsp.c
  sys/kern/vfs_bio.c sys/miscfs/syncfs/sync_subr.c and setting
  AcpiGbl_EnableAmlDebugObject.
(mostly passing the address of a uint64_t when typed as CTLTYPE_INT).
I've test built quite a few kernels, but there may be some unfixed MD
  fallout. Most likely passing &char[] to char *.
Also add CTLFLAG_UNSIGNED for unsiged decimals - not set yet.
2012-06-02 21:36:41 +00:00
plunky
7e98c91dc1 register/deregister pmf(9) NULL handlers for bthub(4) and
bluetooth devices which attach there, to fix PR/39006
2012-04-03 09:32:53 +00:00
mrg
9a1921b3ca don't use mutex_spin*() on an IPL_NONE mutex. fixes PR#46120. 2012-03-26 06:49:15 +00:00
plunky
269b0ae7be offset processing of input reports to a kernel thread, to avoid
locking issues when a child device needs to call back into the
Bluetooth stack (eg when caps-lock is pressed, and wskbd wants
to change a LED)

(as discussed with Radoslaw Kujawa)
2012-01-11 17:27:45 +00:00