kbtv2 sound saa.c

Yuri Pankov yuri.pankov at gmail.com
Fri Feb 29 05:28:51 UTC 2008


On Fri, Feb 29, 2008 at 01:44:43AM +0100, Danny Pansters wrote:
> On Thursday 28 February 2008 08:20:11 you wrote:
> > On Thu, Feb 28, 2008 at 12:42:38AM +0100, Danny Pansters wrote:
> > > On Wednesday 27 February 2008 18:55:56 you wrote:
> > > <snip>
> > >
> > > > thanks for the hints, but I must admit that I'm totally lost here -
> > > > where can I tweak sound carrier frequency?
> > >
> > > There doesn't seem to be a canned-in way (only for setting NTSC vs PAL),
> > > but Sidney's information gave me a second datapoint (for the actual value
> > > to be set to "audio_options.sao_siffreq1"). It stands to logic that it's
> > > not only a linear but also a proportional equation to convert the actual
> > > freq to the required registry value. In terms of numbers I made it work,
> > > and there seems to be a certain logic in terms of (audio) output
> > > frequency.
> > >
> > > I think the attached patch will work for you, as well as for PAL I (UK)
> > > and hopefully also for NTSC. The sif is switched when broadcast standard
> > > gets changed.
> > >
> > > Here (B/G) it used to be that with other PAL variants the sound would
> > > remain. With the current working version of the saa backend it gets noise
> > > (most cases mixed with the actual original sound) if I switch away from
> > > B/G to any other PAL type as well as if I switch to NTSC, then it gets a
> > > heavy pulse-like noise. Once I switch back to B/G sound is ok again.
> > >
> > > Please try attached patches (1.93 working version, not beta3 yet) to
> > > saa.c and saa.h.
> >
> > Doesn't help. I'll try to look at the code.
> >
> > There's another problem - I get panics with saa driver:
> >
> > panic: Trying sleep, but thread marked as sleeping prohibited
> > cpuid = 0
> > KDB: stack backtrace:
> > db_trace_self_wrapper() at db_trace_self_wrapper+0x2a
> > panic() at panic+0x17d
> > sleepq_add() at sleepq_add+0x2e1
> > _sx_slock_hard() at _sx_slock_hard+0x15d
> > _sx_slock() at _sx_slock+0xc1
> > pfind() at pfind+0x24
> > saa_intr() at saa_intr+0x313
> > ithread_loop() at ithread_loop+0xda
> > fork_exit() at fork_exit+0x12a
> > fork_trampoline() at fork_trampoline+0xe
> > --- trap 0, rip = 0, rsp = 0xffffffffac3c0d30, rbp = 0 ---
> 
> Looks like 32->64 issue

Don't think so, please check Attilio's reply -
http://lists.freebsd.org/pipermail/freebsd-hackers/2008-February/023663.html

I've attached a patch removing pfind() calls from saa_intr, allowing me at
least try to resolve sound issues (I don't think that it is correct,
more than so, quite contrary, I'm pretty sure it is incorrect, but will
do for the time being).

> 
> > Uptime: 26m18s
> > Physical memory: 2034 MB
> > Dumping 190 MB: 175 159 143 127 111 95 79 63 47 31 15
> >
> > I can provide more details if needed.
> >
> >
> > Yuri
> 
> I tried installing 7.0-REL/amd64 from the disc1-3 ISOs on a amd box I had 
> sitting around  (nvidia/asus  based A8N-SLI-SE board) but I can't even 
> reliably run X apps on it (e.g. firefox/konqueror quickly freeze the 
> screen...). Tier-1 my ass.
> 
> I also happen to have a ia64 box but I read it requires a serial console 
> because it has no syscons...
> 
> Dan


Yuri
-------------- next part --------------
diff -ruN /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/Makefile saa/kmod/Makefile
--- /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/Makefile	2008-02-29 08:10:01.000000000 +0300
+++ saa/kmod/Makefile	2008-02-29 07:40:16.000000000 +0300
@@ -1,7 +1,9 @@
-KMOD= saa
-KMODDIR= /boot/modules
-SRCS= iicbus_if.h device_if.h bus_if.h pci_if.h
-SRCS+= saa713x.c saa713x_i2c.c saa713x_video.c saa713x_audio.c
+KMOD=	saa
+KMODDIR=	/boot/modules
+
+SRCS=	iicbus_if.h device_if.h bus_if.h pci_if.h
+SRCS+=	saa713x.c saa713x_i2c.c saa713x_video.c saa713x_audio.c
+
 
 .include "../Makevars"
 CFLAGS+= ${KMOD_FLAGS}
diff -ruN /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/saa713x.c saa/kmod/saa713x.c
--- /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/saa713x.c	2008-02-29 08:10:01.000000000 +0300
+++ saa/kmod/saa713x.c	2008-02-29 08:09:08.000000000 +0300
@@ -308,7 +308,7 @@
 		goto attach_failed;
 	}
 	if (bus_setup_intr(dev, sc->sc_intr_res, INTR_TYPE_AV | INTR_MPSAFE,
-				saa_intr, sc, &sc->sc_intr_cookie) != 0) {
+				NULL, saa_intr, sc, &sc->sc_intr_cookie) != 0) {
 		emsg = "Error setting up interrupt";
 		goto attach_failed;
 	}
@@ -360,7 +360,6 @@
 {
 	struct saa_softc *sc = (struct saa_softc *)arg;
 	uint32_t irep, ists, avsts, r, sflag;
-	struct proc *p;
 
 	irep = REG_READ(REG_IREP);
 	sc->sc_sts->ssts_irep = irep;
@@ -421,8 +420,8 @@
 		}
 	}
 
-	/* SFLAG is used to optimise when sc_video_capbuf_sigpid is 
-	 * is equal sc_audio_capbuf_sigpid
+	/* SFLAG is used to optimise when sc_video_capbuf_sigproc is 
+	 * equal to sc_audio_capbuf_sigproc
 	 */
 	sflag = 0;
 	/* USR1 - video capture
@@ -441,22 +440,18 @@
 	if ((sc->sc_sts->ssts_sig_video | sc->sc_sts->ssts_sig_sts) &&
 	    (sc->sc_video_spec.svs_flags & 
 		(VSPEC_FLAG_CAPTURE_SIGNAL | VSPEC_FLAG_STATUS_SIGNAL)) &&
-	    sc->sc_video_capbuf_sigpid != 0) 
+	    sc->sc_video_capbuf_sigproc != NULL) 
 	{
 		if (sc->sc_sts->ssts_sig_video) {
-		    if ((p = pfind(sc->sc_video_capbuf_sigpid)) != NULL) {
-			psignal(p, SIGUSR1);
-			PROC_UNLOCK(p);
+			PROC_LOCK(sc->sc_video_capbuf_sigproc);
+			psignal(sc->sc_video_capbuf_sigproc, SIGUSR1);
+			PROC_UNLOCK(sc->sc_video_capbuf_sigproc);
 			++sflag;
-		    } else
-			sc->sc_video_capbuf_sigpid = 0;
 		} else {
-		    if ((p = pfind(sc->sc_video_capbuf_sigpid)) != NULL) {
-			psignal(p, SIGUSR2);
-			PROC_UNLOCK(p);
+			PROC_LOCK(sc->sc_video_capbuf_sigproc);
+			psignal(sc->sc_video_capbuf_sigproc, SIGUSR2);
+			PROC_UNLOCK(sc->sc_video_capbuf_sigproc);
 			++sflag;
-		    } else
-			sc->sc_video_capbuf_sigpid = 0;
 		}
 	}
 
@@ -464,16 +459,13 @@
 	if ((sc->sc_sts->ssts_sig_audio | sc->sc_sts->ssts_sig_sts) &&
 	    (sc->sc_audio_spec.sas_flags & 
 		(ASPEC_FLAG_CAPTURE_SIGNAL | ASPEC_FLAG_STATUS_SIGNAL)) &&
-	    sc->sc_audio_capbuf_sigpid != 0) 
+	    sc->sc_audio_capbuf_sigproc != NULL) 
 	{
 	    if (sflag == 0 || 
-		(sc->sc_audio_capbuf_sigpid != 
-				sc->sc_video_capbuf_sigpid)) {
-		if ((p = pfind(sc->sc_audio_capbuf_sigpid)) != NULL) {
-			psignal(p, SIGUSR2);
-			PROC_UNLOCK(p);
-	    	} else
-			sc->sc_audio_capbuf_sigpid = 0;
+		(sc->sc_audio_capbuf_sigproc != sc->sc_video_capbuf_sigproc)) {
+			PROC_LOCK(sc->sc_audio_capbuf_sigproc);
+			psignal(sc->sc_audio_capbuf_sigproc, SIGUSR2);
+			PROC_UNLOCK(sc->sc_audio_capbuf_sigproc);
 	    }
 	}
 
diff -ruN /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/saa713x_audio.c saa/kmod/saa713x_audio.c
--- /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/saa713x_audio.c	2008-02-29 08:10:01.000000000 +0300
+++ saa/kmod/saa713x_audio.c	2008-02-29 07:56:28.000000000 +0300
@@ -438,7 +438,6 @@
 	}
 
 	REG_SET(REG_MCR, MCR_CHAN6_TE);
-#if NOT_YET
 	/* 
 	 * Interrupts are always enabled, ie.,
 	 * even when ASPEC_FLAG_CAPTURE_SIGNAL is not specified as
@@ -450,7 +449,6 @@
 	 * Feb/02/2005 Not implemented as it will increase the nr. 
 	 * of interrupts generated by the device.
 	 */
-#endif
 	if (s->sas_flags & ASPEC_FLAG_CAPTURE_SIGNAL) {
 		REG_SET(REG_FIEN,  FIEN_SLICE3_0 | FIEN_SLICE3_1);
 	}
@@ -506,10 +504,11 @@
 			break;
 		}
 		sc->sc_audio_spec = *s;
-		if (s->sas_flags & ASPEC_FLAG_CAPTURE_SIGNAL)
-			sc->sc_audio_capbuf_sigpid = td->td_proc->p_pid;
-		else
-			sc->sc_audio_capbuf_sigpid = 0;
+		if (s->sas_flags & ASPEC_FLAG_CAPTURE_SIGNAL) {
+			sc->sc_audio_capbuf_sigproc = pfind(td->td_proc->p_pid);
+			PROC_UNLOCK(sc->sc_audio_capbuf_sigproc);
+		} else
+			sc->sc_audio_capbuf_sigproc = NULL;
 		rval =  saa_audio_capture_on(sc, s);
 		break;
 	}
@@ -518,7 +517,7 @@
 		if (!(sc->sc_audio_flags & SCAF_ON))
 			break;
 		rval = saa_audio_capture_off(sc);
-		sc->sc_audio_capbuf_sigpid = 0;
+		sc->sc_audio_capbuf_sigproc = NULL;
 		break;
 	}
 	case GETAUDIOOPT:
diff -ruN /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/saa713x_var.h saa/kmod/saa713x_var.h
--- /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/saa713x_var.h	2004-12-09 11:53:08.000000000 +0300
+++ saa/kmod/saa713x_var.h	2008-02-29 07:54:52.000000000 +0300
@@ -3,23 +3,9 @@
 
 #include <sys/param.h>
 
-#if defined(SAA_DSHM) && __FreeBSD_version < 502121
-#error "FreeBSD version incompatible with SAA_DSHM, please refer to Makefile."
-#endif
-
-#if __FreeBSD_version > 502102
 #define DVERSION	.d_version = D_VERSION,
 #define DFLAGS
-#else
-#define DVERSION
-#define DFLAGS		.d_flags = D_NOGIANT,
-#endif
-
-#if __FreeBSD_version > 502114
 #define DPTYPE		struct cdev*
-#else
-#define DPTYPE		dev_t
-#endif
 
 extern devclass_t saa_devclass;
 
@@ -80,7 +66,7 @@
 	vm_offset_t 		sc_video_capbuf_shmaddr[2];
 	int 			sc_video_capbuf_shmlen[2];
 
-	pid_t			sc_video_capbuf_sigpid;
+	struct proc		*sc_video_capbuf_sigproc;
 
 	struct saa_status	*sc_sts;	
 
@@ -95,7 +81,7 @@
 	struct saa_audio_spec	sc_audio_spec;
 	uint32_t		sc_audio_flags;
 
-	pid_t			sc_audio_capbuf_sigpid;
+	struct proc		*sc_audio_capbuf_sigproc;
 
 	int			sc_audio_capbuf_sz;
 	bus_dma_tag_t		sc_audio_capbuf_tag;
diff -ruN /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/saa713x_video.c saa/kmod/saa713x_video.c
--- /usr/ports/multimedia/kbtv2-kmod-saa/work/kbtv-1.92/kmod/saa/kmod/saa713x_video.c	2008-02-29 08:10:01.000000000 +0300
+++ saa/kmod/saa713x_video.c	2008-02-29 07:20:17.000000000 +0300
@@ -1115,9 +1115,10 @@
 		}
 		/* XXX Only status signal is valid in overlay mode */
 		if (o->svs_flags & VSPEC_FLAG_STATUS_SIGNAL) {
-			sc->sc_video_capbuf_sigpid = td->td_proc->p_pid;
+			sc->sc_video_capbuf_sigproc = pfind(td->td_proc->p_pid);
+			PROC_UNLOCK(sc->sc_video_capbuf_sigproc);
 		} else
-			sc->sc_video_capbuf_sigpid = 0;
+			sc->sc_video_capbuf_sigproc = NULL;
 		rval = saa_video_overlay_on(sc, &sc->sc_video_spec);
 		break;
 	}
@@ -1136,10 +1137,11 @@
 		}
 		sc->sc_video_spec = *o;
 		if (o->svs_flags & (VSPEC_FLAG_CAPTURE_SIGNAL | 
-				  	VSPEC_FLAG_STATUS_SIGNAL))
-			sc->sc_video_capbuf_sigpid = td->td_proc->p_pid;
-		else
-			sc->sc_video_capbuf_sigpid = 0;
+				  	VSPEC_FLAG_STATUS_SIGNAL)) {
+			sc->sc_video_capbuf_sigproc = pfind(td->td_proc->p_pid);
+			PROC_UNLOCK(sc->sc_video_capbuf_sigproc);
+		} else
+			sc->sc_video_capbuf_sigproc = NULL;
 		rval = saa_video_capture_on(sc, &sc->sc_video_spec, td);
 		break;
 	}
@@ -1147,7 +1149,7 @@
 		if (!(sc->sc_video_flags & SCVF_CAPTURE))
 			break;
 		saa_video_capture_off(sc);
-		sc->sc_video_capbuf_sigpid = 0;
+		sc->sc_video_capbuf_sigproc = NULL;
 		break;
 	case SETCLIPINFO:
 	{


More information about the freebsd-multimedia mailing list