Commit Graph

55 Commits

Author SHA1 Message Date
macallan 275e310708 add support for the onewire bus found in some macs, namely Quicksilver.
This can be used to read the EEPROM content from Apple Pro speakers, or to
hook up other onewire devices.
2020-08-08 22:37:19 +00:00
macallan 4ac14a66d7 don't try to read a 32bit property into a uint8_t.
Now headphone detection works properly on machines which have the gpio's
polarity reversed, like Quicksilver and TiBook.
2020-04-11 01:42:56 +00:00
macallan 9927696972 various minor fixes and updates:
- add (very) basic ONYX support. Treat as 16bit codec with software volume
  control. Makes basic audio work on PCIe G5
- correctly detect TAS3001 without 'compatible' property, now this works on
  Quicksilver
- mute line input on TAS3001 - it's unconnected on Quicksilver and causes noise
- make more of an effort to match codecs to i2sbus instances, needed on G5 and
  some other models with software 'modems'
2019-09-20 21:24:34 +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
macallan 1a0d0c1609 switch the default input to line in, to avoid feedback noise on laptops
should probably just mute the input, I need to read the datasheet again...
2019-05-16 23:39:37 +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
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
macallan b25dbf73f9 use obio_space_map() to map DMA registers, now this works on both G5 and
32bit hardware
2018-05-04 17:20:34 +00:00
macallan 6bde8e4865 explicitly enable the i2s part in the keylargo FCR
now this works on my PCI-X G5
2018-03-29 18:34:32 +00:00
macallan b285859f53 deal with PowerMac7,* mac-io/i2s/sound reg properties
now we map the right registers on G5 and get DMA interrupts. Still no sound
but - well - progress
2018-03-29 06:56:54 +00:00
macallan bea393bbca don't poke GPIOs directly, use obio_*() access functions, now this
has a chance of working on G5 where we can't just BAT-map everything with
paddr == busaddr.
Doesn't play audio yet but things like headphone detection work.
2018-03-24 16:22:48 +00:00
macallan aac882f162 remove some leftover references to ki2c in comments
no functional change
2018-01-29 19:33:39 +00:00
sevan 9b65f16d5d Fix issue with audio being downpitched, thanks to <nat>
"it seems that snapper_init should be called before audio_attach_mi, as snapper
init is setting the rate to 44100 after the hardware format has been configured
by audio_attach_mi.

audio_attach_mi should be the last thing called during an attach of an audio
device so the audio device is ready to be configured when audio_attach_mi is
called."

Resolves PR port-macppc/52949
2018-01-27 16:21:47 +00:00
msaitoh eabd5e1de9 Remove extra 0x. This bug was added when replacing bitmask_snprintf(9) with
snprintb(3) (in between NetBSD 5 and 6). Old bitmask_snprint(9) didn't add
0x" automatically for hexadecimal value, so old code used it with "0x%s".
2017-03-31 08:38:13 +00:00
macallan c9a4f92c3f adjust to dbdma changes 2016-07-15 22:10:47 +00:00
mrg f6e33f02a8 remove various set-but-unused variables. 2014-03-14 21:59:41 +00:00
mrg 8de08fa998 put back IPL_AUDIO and splaudio(), at the request of rmind. they are
aliases and now we can easily revert audio to IPL_VM if necessary,
without having to revert the whole branch.
2011-11-24 03:35:56 +00:00
jmcneill 8a962f23f2 Merge jmcneill-audiomp3 branch, which is derived from ad-audiomp2. From
the original ad-audiomp branch notes:

  Add MP locking to the audio drivers.

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

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

Welcome to 5.99.57.
2011-11-23 23:07:28 +00:00
phx 4f6a6a0cec Get the dma registers from the soundbus property. This should work with all
snapper-compatible hardware.
Tested on PowerBook G4, MacMini and iBook G4. Failed on the PowerBook before.
2010-11-12 12:26:29 +00:00
phx ffe1973ed5 Find all GPIOs in OF also on newer PowerBooks.
Do not use a GPIO or establish an interrupt when it was not found.
To be done: We should use bus_space(9) for reading/writing GPIOs.
2010-10-16 18:22:37 +00:00
macallan 210f669b31 get rid of custom PMF event handlers, instead do what the upper layer expects
so volume control via PMF still works
2010-09-09 00:24:59 +00:00
dyoung 7507fa6898 In awacs(4) and snapper(4), use deviter(9) instead of accessing
alldevs directly.

In pbms(4), delete some unused debugging macros, expand USB
compatibility macros, and add a child-detachment routine.  Simplify
pbms(4) deactivation and detachment.

These changes are compile-tested, only.
2009-11-05 05:37:30 +00:00
cegger c363a9cb62 bzero -> memset 2009-03-18 16:00:08 +00:00
christos 9a5d3f2817 replace bitmask_snprintf(9) with snprintb(3) 2008-12-16 22:35:21 +00:00
macallan b8ae2bc305 use access functions to mess with obio's registers 2008-09-26 03:38:25 +00:00
macallan e3856204b9 use min(255, blah) to cap volume instead of masking the upper bits out 2008-09-26 03:20:30 +00:00
macallan e369394198 sprinkle static 2008-05-16 03:49:54 +00:00
macallan f147f68f57 listen to PMF volume control events
With this volume vontrol via keyboard works on my iBook G4.
2008-05-15 20:11:00 +00:00
macallan 7d61890be8 struct device -> device_t 2008-05-15 19:47:09 +00:00
garbled 23a7584d7e Convert macppc to shared ofw_autoconf.c. Compile tested only. 2007-11-07 19:47:00 +00:00
macallan a741bccaba cleanup, various fixes and TAS3001 / Tumbler support
from Marco Trillo in PR37076
2007-10-18 22:03:09 +00:00
garbled d974db0ada Merge the ppcoea-renovation branch to HEAD.
This branch was a major cleanup and rototill of many of the various OEA
cpu based PPC ports that focused on sharing as much code as possible
between the various ports to eliminate near-identical copies of files in
every tree.  Additionally there is a new PIC system that unifies the
interface to interrupt code for all different OEA ppc arches.  The work
for this branch was done by a variety of people, too long to list here.

TODO:
bebox still needs work to complete the transition to -renovation.
ofppc still needs a bunch of work, which I will be looking at.
ev64260 still needs to be renovated
amigappc was not attempted.

NOTES:
pmppc was removed as an arch, and moved to a evbppc target.
2007-10-17 19:52:51 +00:00
dogcow 0477b152f4 struct cfattach -> CFATTACH_DECL; compiles again. 2007-09-27 08:49:33 +00:00
aymeric 8b9fcfffdc add support for the "tumbler" as found at least on iBook G3/600.
quick OK macallan@
2007-09-17 13:15:20 +00:00
jmcneill f972216e48 Simplify sw volume control, attach to AOAK2 as well, make mono work as
well as stereo, and print a friendlier message when we don't find a
hardware mixer.
2007-04-04 02:14:57 +00:00
jmcneill 71195759ef In the AOAKeylargo case, there is no hardware volume control. Instead,
implement volume control in software via audio filter framework.

XXX: audio filter framework doesn't let me pass parameters from the hw
     softc to the filter, so the volume variables are globals for now.
2007-04-03 13:11:21 +00:00
jmcneill c38a78ca65 Match AOAKeylargo, and don't make finding deq a requirement. Sound now
comes out of my last gen G4 Mac Mini, minus mixer controls. ok macallan@
2007-04-03 03:26:52 +00:00
macallan b2fbecd2f8 fix typo 2007-03-25 23:38:22 +00:00
thorpej 09c5f9cc49 TRUE -> true, FALSE -> false 2007-02-28 04:21:51 +00:00
macallan b2bac7650b don't pretend to support 8kHz since the chip really doesn't
noticed by Marco Trillo
2006-12-17 21:26:04 +00:00
macallan 35a2b63b90 actually change the sample rate when asked to.
Fix provided by Marco Trillo in PR35204
While there also enable 24bit I/O.
2006-12-11 02:17:53 +00:00
jmcneill 3150bfdedd Don't use // for comments. 2006-09-24 03:47:09 +00:00
macallan 3887e678eb use gain table for master volume as well 2006-08-23 03:25:31 +00:00
macallan ef6b7fdb0e fix some KNF nits 2006-08-23 02:56:32 +00:00
macallan 5f55aaa2e1 Add audio input support. From Magnus Henoch, fixes PR 32664 2006-08-11 20:37:43 +00:00
thorpej 458b3e43f7 Use device_parent(). 2006-02-23 05:37:46 +00:00
perry 2d65de2479 bare asm -> __asm 2005-12-24 22:45:33 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
macallan d9f9caa094 - don't call ki2c private functions anymore, use iic_exec() to be a good i2c citizen
- use the deq driver to find the mixer device
- add controls for bass and treble
2005-08-10 14:32:08 +00:00