CVS commit: src/sys/arch/hppa/gsc

2021-02-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Feb  4 15:08:45 UTC 2021

Modified Files:
src/sys/arch/hppa/gsc: harmony.c

Log Message:
Simplify harmony_speed_bits().
It no longer needs to write back the speed value.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/hppa/gsc/harmony.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hppa/gsc/harmony.c
diff -u src/sys/arch/hppa/gsc/harmony.c:1.9 src/sys/arch/hppa/gsc/harmony.c:1.10
--- src/sys/arch/hppa/gsc/harmony.c:1.9	Thu Feb  4 15:06:11 2021
+++ src/sys/arch/hppa/gsc/harmony.c	Thu Feb  4 15:08:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: harmony.c,v 1.9 2021/02/04 15:06:11 isaki Exp $	*/
+/*	$NetBSD: harmony.c,v 1.10 2021/02/04 15:08:44 isaki Exp $	*/
 
 /*	$OpenBSD: harmony.c,v 1.23 2004/02/13 21:28:19 mickey Exp $	*/
 
@@ -165,7 +165,7 @@ CFATTACH_DECL_NEW(harmony, sizeof(struct
 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);
@@ -441,7 +441,6 @@ harmony_set_format(void *vsc, int setmod
 {
 	struct harmony_softc *sc;
 	uint32_t bits;
-	int rate;
 
 	sc = vsc;
 
@@ -464,10 +463,7 @@ harmony_set_format(void *vsc, int setmod
 		bits |= CNTL_OLB;
 
 	bits |= CNTL_CHANS_STEREO;
-
-	/* XXX modify harmony_speed_bits() not to rewrite rate */
-	rate = play->sample_rate;
-	bits |= harmony_speed_bits(sc, );
+	bits |= harmony_speed_bits(sc, play->sample_rate);
 	sc->sc_cntlbits = bits;
 	sc->sc_need_commit = 1;
 
@@ -1161,39 +1157,17 @@ static const struct speed_struct {
 };
 
 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



CVS commit: src/sys/arch/hppa/gsc

2021-02-04 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Feb  4 15:06:11 UTC 2021

Modified Files:
src/sys/arch/hppa/gsc: harmony.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/hppa/gsc/harmony.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hppa/gsc/harmony.c
diff -u src/sys/arch/hppa/gsc/harmony.c:1.8 src/sys/arch/hppa/gsc/harmony.c:1.9
--- src/sys/arch/hppa/gsc/harmony.c:1.8	Wed Feb  3 15:13:49 2021
+++ src/sys/arch/hppa/gsc/harmony.c	Thu Feb  4 15:06:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: harmony.c,v 1.8 2021/02/03 15:13:49 isaki Exp $	*/
+/*	$NetBSD: harmony.c,v 1.9 2021/02/04 15:06:11 isaki Exp $	*/
 
 /*	$OpenBSD: harmony.c,v 1.23 2004/02/13 21:28:19 mickey Exp $	*/
 
@@ -437,7 +437,7 @@ harmony_query_format(void *vsc, audio_fo
 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;
@@ -467,7 +467,8 @@ harmony_set_format(void *vsc, int setmod
 
 	/* XXX modify harmony_speed_bits() not to rewrite rate */
 	rate = play->sample_rate;
-	sc->sc_cntlbits |= harmony_speed_bits(sc, );
+	bits |= harmony_speed_bits(sc, );
+	sc->sc_cntlbits = bits;
 	sc->sc_need_commit = 1;
 
 	return 0;



CVS commit: src/sys/arch/hppa/gsc

2021-02-03 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed Feb  3 15:13:49 UTC 2021

Modified Files:
src/sys/arch/hppa/gsc: harmony.c

Log Message:
Fix locking against myself.
trigger_output will be called with sc_intr_lock held.
>From source code review, not tested.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hppa/gsc/harmony.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hppa/gsc/harmony.c
diff -u src/sys/arch/hppa/gsc/harmony.c:1.7 src/sys/arch/hppa/gsc/harmony.c:1.8
--- src/sys/arch/hppa/gsc/harmony.c:1.7	Sat Jun  8 08:02:37 2019
+++ src/sys/arch/hppa/gsc/harmony.c	Wed Feb  3 15:13:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: harmony.c,v 1.7 2019/06/08 08:02:37 isaki Exp $	*/
+/*	$NetBSD: harmony.c,v 1.8 2021/02/03 15:13:49 isaki Exp $	*/
 
 /*	$OpenBSD: harmony.c,v 1.23 2004/02/13 21:28:19 mickey Exp $	*/
 
@@ -1004,8 +1004,6 @@ harmony_trigger_output(void *vsc, void *
 		return EINVAL;
 	}
 
-	mutex_spin_enter(>sc_intr_lock);
-
 	c->c_intr = intr;
 	c->c_intrarg = intrarg;
 	c->c_blksz = blksize;
@@ -1020,8 +1018,6 @@ harmony_trigger_output(void *vsc, void *
 	harmony_start_cp(sc, 0);
 	harmony_intr_enable(sc);
 
-	mutex_spin_exit(>sc_intr_lock);
-
 	return 0;
 }
 



CVS commit: src/sys/arch/hppa/gsc

2019-04-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Apr 16 12:22:13 UTC 2019

Modified Files:
src/sys/arch/hppa/gsc: if_ie_gsc.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/hppa/gsc/if_ie_gsc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hppa/gsc/if_ie_gsc.c
diff -u src/sys/arch/hppa/gsc/if_ie_gsc.c:1.2 src/sys/arch/hppa/gsc/if_ie_gsc.c:1.3
--- src/sys/arch/hppa/gsc/if_ie_gsc.c:1.2	Thu Feb  8 09:05:18 2018
+++ src/sys/arch/hppa/gsc/if_ie_gsc.c	Tue Apr 16 12:22:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ie_gsc.c,v 1.2 2018/02/08 09:05:18 dholland Exp $	*/
+/*	$NetBSD: if_ie_gsc.c,v 1.3 2019/04/16 12:22:13 skrll Exp $	*/
 
 /*	$OpenBSD: if_ie_gsc.c,v 1.6 2001/01/12 22:57:04 mickey Exp $	*/
 
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ie_gsc.c,v 1.2 2018/02/08 09:05:18 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_gsc.c,v 1.3 2019/04/16 12:22:13 skrll Exp $");
 
 #include 
 #include 
@@ -95,7 +95,7 @@ struct ie_gsc_regs {
 
 struct ie_gsc_softc {
 	struct ie_softc ie;
-	
+
 	/* tag and handle to hppa-specific adapter registers. */
 	bus_space_tag_t iot;
 	bus_space_handle_t ioh;
@@ -139,7 +139,7 @@ ie_gsc_reset(struct ie_softc *sc, int wh
 {
 	struct ie_gsc_softc *gsc = (struct ie_gsc_softc *) sc;
 	int i;
-	
+
 	switch (what) {
 	case CHIP_PROBE:
 		bus_space_write_4(gsc->iot, gsc->ioh, IE_GSC_REG_RESET, 0);
@@ -496,7 +496,7 @@ ie_gsc_attach(device_t parent, device_t 
 	 * SCP can go after that.
 	 */
 	sc->scp = IE_GSC_ALIGN(8);
-	
+
 	/* ISCP follows SCP */
 	sc->iscp = IE_GSC_ALIGN(sc->scp + IE_SCP_SZ);