Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#28297 - 17/03/2001 13:50 Beeping from within kernel/
tonyc
carpal tunnel

Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
Any of you more experience empeg kernel hackers care to share how I can generate a DSP beep from within a kernel driver? I took a look at the example "beep" user program, but somehow I don't think it's that simple when you're trying to do it from within the kernel itself.

-Tony
MkII #554
_________________________
- Tony C
my empeg stuff

Top
#28298 - 18/03/2001 17:40 Re: Beeping from within kernel/ [Re: tonyc]
borislav
addict

Registered: 30/04/2000
Posts: 420
Loc: Sunnyvale, CA, USA
Any of you more experience empeg kernel hackers care to share how I can generate a DSP beep from within a kernel driver? I took a look at the example "beep" user program, but somehow I don't think it's that simple when you're trying to do it from within the kernel itself.

It's actually easier from within the kernel, since you can call the beeping function directly, e.g.
audio_beep(&audio[0], pitch, duration, volume);
audio_beep() and audio[] are defined in empeg/arch/special/empeg_audio2.c, if you want to use them in a different source file you'll have to put the definitions in a header file. The pitch and duration arguments are as described on the developer's site, the volume is a percentage.

BTW, audio_beep() is normally only called from a process context (in the ioctl handler), not sure whether it's completely safe in an interrupt context but it appears to work there too.

Borislav




Top
#28299 - 18/03/2001 20:00 Re: Beeping from within kernel/ [Re: borislav]
tonyc
carpal tunnel

Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
It looks like it's not that easy. It beeps, but immediately panics with the first call. I'm guessing there's something unsafe about calling beep in this way..


audio-empeg: BEEP 200, 60
Internal error: branch through zero: 0
CPU: 0
pc : [<00000004>] lr : [<0209e6bc>]
sp : be3ffce8 ip : 00000000 fp : c0111f24
r10: c0112f60 r9 : c0113cc4 r8 : c01140c4
r7 : c0113cc0 r6 : c0113cc4 r5 : c0113cc0 r4 : 00000000
r3 : 60000013 r2 : c0136654 r1 : c0113d48 r0 : 00000000
Flags: nZCv IRQs on FIQs on Mode SVC_32 Segment kernel
Control: C000517D Table: C000517D DAC: 0000001D
Process swapper (pid: 0, stackpage=c0111000)
...
...
Code: pc not in code space
Aiee, killing interrupt handler
Kernel panic: Attempted to kill the idle task!
In swapper task - not syncing


I guess there's no safe way to call it from inside a driver. The whole reason I'm trying to do this is to provide an audio beep whenever a specific remote key is pressed. I'm building on top of Frank Van Gestel's IR trans patch, and have it so that I can get another 10 functions out of the remote if I use one of the buttons as a "switch functions" button. I wanted a beep when this button is pressed. Since it's not a normal Empeg function, the player doesn't generate beeps for that button. I just wanted to generate a beep inside the IR driver, as in this snippet:


add_timer(&irtrans_timer);
if(data == 0x0000AD0C) {
audio_beep(&audio[0], 60, 200, 100);
irtransmodify=1;


For whatever reason, this causes a massive kernel crash. Guess I should have picked an easier first kernel project :)

-Tony
MkII #554
_________________________
- Tony C
my empeg stuff

Top
#28300 - 19/03/2001 03:02 Re: Beeping from within kernel/ [Re: tonyc]
borislav
addict

Registered: 30/04/2000
Posts: 420
Loc: Sunnyvale, CA, USA
It beeps, but immediately panics with the first call.

Hmm. Works for me...(tm)

Here is what I did to test it:
--- linux-1.02/arch/arm/special/empeg_audio2.c  Sun Jan 28 00:58:34 2001

+++ linux-1.02-beep/arch/arm/special/empeg_audio2.c Mon Mar 19 01:57:41 2001
@@ -1167,6 +1167,11 @@
return(0);
}

+void beep(void)
+{
+ audio_beep(&audio[0], 60, 500, 50);
+}
+
void audio_beep(audio_dev *dev, int pitch, int length, int volume)
{
/* Section 9.8 */
diff -Nur linux-1.02/drivers/char/empeg_ir.c linux-1.02-beep/drivers/char/empeg_ir.c
--- linux-1.02/drivers/char/empeg_ir.c Sun Jan 28 00:58:44 2001
+++ linux-1.02-beep/drivers/char/empeg_ir.c Sun Mar 18 15:50:58 2001
@@ -178,6 +178,8 @@
#define IR_STATE_DATA1 0x0a
#define IR_STATE_DATA2 0x0c

+extern void beep(void);
+
static void ir_append_data(struct ir_dev *dev, ir_code data)
{
/* Now this is called from the bottom half we need to make
@@ -186,6 +188,11 @@
ir_code *new_wp;
unsigned long flags;
save_flags_cli(flags);
+
+ if (data == 0xb91c) {
+ beep();
+ return;
+ }

new_wp = dev->buf_wp + 1;
if (new_wp == dev->buf_end)
The "tuner" button on the remote triggers it.

Can you do a similar patch of your mods? Send them over and I'll try to figure out why it's bombing out.

Borislav



Top
#28301 - 19/03/2001 10:28 Re: Beeping from within kernel/ [Re: borislav]
tonyc
carpal tunnel

Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
D'oh. I'll have to check it out after work tonight.. Not sure what was causing it, but it was quite repeatable.

-Tony
MkII #554
_________________________
- Tony C
my empeg stuff

Top
#28302 - 19/03/2001 18:37 Re: Beeping from within kernel/ [Re: borislav]
tonyc
carpal tunnel

Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
Well, I guess my problems were caused by the kludgy way I had defined all the device structures (audio_buffer, audio_dev, etc.) in a header file. Using a void beep function with no device parameter (as you did) makes that step unnecessary, and fixes my problem. Now I just have a void beep with 3 int parameters for pitch, duration, and volume, and it seems to work great. Thanks much for the assistance!


-Tony
MkII #554
_________________________
- Tony C
my empeg stuff

Top