Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/sys/arch/hppa/gsc Pull up following revision(s) (requeste...
details: https://anonhg.NetBSD.org/src/rev/c3faa8e14de8
branches: netbsd-9
changeset: 953178:c3faa8e14de8
user: martin <martin%NetBSD.org@localhost>
date: Sun Feb 28 07:01:01 2021 +0000
description:
Pull up following revision(s) (requested by isaki in ticket #1216):
sys/arch/hppa/gsc/harmony.c: revision 1.8
sys/arch/hppa/gsc/harmony.c: revision 1.9
sys/arch/hppa/gsc/harmony.c: revision 1.10
Fix locking against myself.
trigger_output will be called with sc_intr_lock held.
>From source code review, not tested.
Fix my mistakes in rev1.6.
- I had to merge the channel bit and the speed bits.
Reported by macallan@.
- I also fix my indent, while I'm here.
Simplify harmony_speed_bits().
It no longer needs to write back the speed value.
diffstat:
sys/arch/hppa/gsc/harmony.c | 53 ++++++++++----------------------------------
1 files changed, 12 insertions(+), 41 deletions(-)
diffs (109 lines):
diff -r a564ec34ccde -r c3faa8e14de8 sys/arch/hppa/gsc/harmony.c
--- a/sys/arch/hppa/gsc/harmony.c Fri Feb 26 13:31:21 2021 +0000
+++ b/sys/arch/hppa/gsc/harmony.c Sun Feb 28 07:01:01 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: harmony.c,v 1.7 2019/06/08 08:02:37 isaki Exp $ */
+/* $NetBSD: harmony.c,v 1.7.2.1 2021/02/28 07:01:01 martin Exp $ */
/* $OpenBSD: harmony.c,v 1.23 2004/02/13 21:28:19 mickey Exp $ */
@@ -165,7 +165,7 @@
int harmony_intr(void *);
void harmony_intr_enable(struct harmony_softc *);
void harmony_intr_disable(struct harmony_softc *);
-uint32_t harmony_speed_bits(struct harmony_softc *, u_int *);
+uint32_t harmony_speed_bits(struct harmony_softc *, u_int);
int harmony_set_gainctl(struct harmony_softc *);
void harmony_reset_codec(struct harmony_softc *);
void harmony_start_cp(struct harmony_softc *, int);
@@ -437,11 +437,10 @@
int
harmony_set_format(void *vsc, int setmode,
const audio_params_t *play, const audio_params_t *rec,
- audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
+ audio_filter_reg_t *pfil, audio_filter_reg_t *rfil)
{
struct harmony_softc *sc;
uint32_t bits;
- int rate;
sc = vsc;
@@ -464,10 +463,8 @@
bits |= CNTL_OLB;
bits |= CNTL_CHANS_STEREO;
-
- /* XXX modify harmony_speed_bits() not to rewrite rate */
- rate = play->sample_rate;
- sc->sc_cntlbits |= harmony_speed_bits(sc, &rate);
+ bits |= harmony_speed_bits(sc, play->sample_rate);
+ sc->sc_cntlbits = bits;
sc->sc_need_commit = 1;
return 0;
@@ -1004,8 +1001,6 @@
return EINVAL;
}
- mutex_spin_enter(&sc->sc_intr_lock);
-
c->c_intr = intr;
c->c_intrarg = intrarg;
c->c_blksz = blksize;
@@ -1020,8 +1015,6 @@
harmony_start_cp(sc, 0);
harmony_intr_enable(sc);
- mutex_spin_exit(&sc->sc_intr_lock);
-
return 0;
}
@@ -1164,39 +1157,17 @@
};
uint32_t
-harmony_speed_bits(struct harmony_softc *sc, u_int *speedp)
+harmony_speed_bits(struct harmony_softc *sc, u_int speed)
{
- int i, n, selected;
-
- selected = -1;
- n = sizeof(harmony_speeds) / sizeof(harmony_speeds[0]);
+ int i;
- if ((*speedp) <= harmony_speeds[0].speed)
- selected = 0;
- else if ((*speedp) >= harmony_speeds[n - 1].speed)
- selected = n - 1;
- else {
- for (i = 1; selected == -1 && i < n; i++) {
- if ((*speedp) == harmony_speeds[i].speed)
- selected = i;
- else if ((*speedp) < harmony_speeds[i].speed) {
- int diff1, diff2;
-
- diff1 = (*speedp) - harmony_speeds[i - 1].speed;
- diff2 = harmony_speeds[i].speed - (*speedp);
- if (diff1 < diff2)
- selected = i - 1;
- else
- selected = i;
- }
+ for (i = 0; i < __arraycount(harmony_speeds); i++) {
+ if (speed == harmony_speeds[i].speed) {
+ return harmony_speeds[i].bits;
}
}
-
- if (selected == -1)
- selected = 2;
-
- *speedp = harmony_speeds[selected].speed;
- return harmony_speeds[selected].bits;
+ /* If this happens, harmony_formats[] is wrong */
+ panic("speed %u not supported", speed);
}
int
Home |
Main Index |
Thread Index |
Old Index