All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@suse.cz>
To: Stas Sergeev <stsp@aknet.ru>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux kernel <linux-kernel@vger.kernel.org>
Subject: Re: [patch 2/2] pcspeaker driver update
Date: Tue, 14 Jun 2005 20:55:35 +0200	[thread overview]
Message-ID: <20050614185535.GA4041@ucw.cz> (raw)
In-Reply-To: <42AF25C7.90109@aknet.ru>

On Tue, Jun 14, 2005 at 10:45:27PM +0400, Stas Sergeev wrote:

> Hello.
> 
> Attached patch does the following:
> - changes the pcspeaker driver to
> use the i8253_lock instead of i8253_beep_lock

This doesn't seem right. The driver programs an independent part of the
chip and I don't see a reason to cause the time code to wait because
we're trying to do a beep.

There is a reason for two separate locks.

> - adds the SND_SUSPEND event that allows
> to disable and re-enable the driver. It
> is necessary, for example, for the PCM
> PC-Speaker driver (which is currently in
> an ALSA CVS), as it doesn't want to
> interfere with the pcspkr, so it needs
> some way to disable the thing.

Can't you just use input_grab() for this? SND_SUSPEND really seems
inappropriate, since it's not a sound event.

> Can this please be applied?

Not yet.

> Signed-off-by: stsp@aknet.ru

> diff -urN linux-2.6.12-rc6/drivers/input/misc/pcspkr.c linux-2.6.12-rc6-spinlk/drivers/input/misc/pcspkr.c
> --- linux-2.6.12-rc6/drivers/input/misc/pcspkr.c	2005-06-07 11:11:49.000000000 +0400
> +++ linux-2.6.12-rc6-spinlk/drivers/input/misc/pcspkr.c	2005-06-14 12:57:59.000000000 +0400
> @@ -18,6 +18,7 @@
>  #include <linux/input.h>
>  #include <asm/8253pit.h>
>  #include <asm/io.h>
> +#include <asm/timer.h>
>  
>  MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
>  MODULE_DESCRIPTION("PC Speaker beeper driver");
> @@ -26,27 +27,13 @@
>  static char pcspkr_name[] = "PC Speaker";
>  static char pcspkr_phys[] = "isa0061/input0";
>  static struct input_dev pcspkr_dev;
> +enum { PCSPKR_NORMAL, PCSPKR_SUSPENDED };
>  
> -static DEFINE_SPINLOCK(i8253_beep_lock);
> -
> -static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
> +static void pcspkr_do_sound(unsigned int count)
>  {
> -	unsigned int count = 0;
>  	unsigned long flags;
>  
> -	if (type != EV_SND)
> -		return -1;
> -
> -	switch (code) {
> -		case SND_BELL: if (value) value = 1000;
> -		case SND_TONE: break;
> -		default: return -1;
> -	}
> -
> -	if (value > 20 && value < 32767)
> -		count = PIT_TICK_RATE / value;
> -
> -	spin_lock_irqsave(&i8253_beep_lock, flags);
> +	spin_lock_irqsave(&i8253_lock, flags);
>  
>  	if (count) {
>  		/* enable counter 2 */
> @@ -61,7 +48,32 @@
>  		outb(inb_p(0x61) & 0xFC, 0x61);
>  	}
>  
> -	spin_unlock_irqrestore(&i8253_beep_lock, flags);
> +	spin_unlock_irqrestore(&i8253_lock, flags);
> +}
> +
> +static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
> +{
> +	unsigned int count = 0;
> +
> +	if (type != EV_SND)
> +		return -1;
> +
> +	switch (code) {
> +		case SND_BELL: if (value) value = 1000;
> +		case SND_TONE: break;
> +		case SND_SUSPEND:
> +			dev->state = value ? PCSPKR_SUSPENDED : PCSPKR_NORMAL;
> +			return 0;
> +		default: return -1;
> +	}
> +
> +	if (dev->state == PCSPKR_SUSPENDED)
> +		return 0;
> +
> +	if (value > 20 && value < 32767)
> +		count = PIT_TICK_RATE / value;
> +
> +	pcspkr_do_sound(count);
>  
>  	return 0;
>  }
> @@ -69,7 +81,7 @@
>  static int __init pcspkr_init(void)
>  {
>  	pcspkr_dev.evbit[0] = BIT(EV_SND);
> -	pcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
> +	pcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE) | BIT(SND_SUSPEND);
>  	pcspkr_dev.event = pcspkr_event;
>  
>  	pcspkr_dev.name = pcspkr_name;
> @@ -78,6 +90,7 @@
>  	pcspkr_dev.id.vendor = 0x001f;
>  	pcspkr_dev.id.product = 0x0001;
>  	pcspkr_dev.id.version = 0x0100;
> +	pcspkr_dev.state = PCSPKR_NORMAL;
>  
>  	input_register_device(&pcspkr_dev);
>  
> @@ -90,7 +103,7 @@
>  {
>          input_unregister_device(&pcspkr_dev);
>  	/* turn off the speaker */
> -	pcspkr_event(NULL, EV_SND, SND_BELL, 0);
> +	pcspkr_do_sound(0);
>  }
>  
>  module_init(pcspkr_init);
> diff -urN linux-2.6.12-rc6/include/linux/input.h linux-2.6.12-rc6-spinlk/include/linux/input.h
> --- linux-2.6.12-rc6/include/linux/input.h	2005-06-07 11:12:29.000000000 +0400
> +++ linux-2.6.12-rc6-spinlk/include/linux/input.h	2005-06-14 12:58:41.000000000 +0400
> @@ -593,6 +593,7 @@
>  #define SND_CLICK		0x00
>  #define SND_BELL		0x01
>  #define SND_TONE		0x02
> +#define SND_SUSPEND		0x03
>  #define SND_MAX			0x07
>  
>  /*


-- 
Vojtech Pavlik
SuSE Labs, SuSE CR

  reply	other threads:[~2005-06-14 18:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-14 18:45 [patch 2/2] pcspeaker driver update Stas Sergeev
2005-06-14 18:55 ` Vojtech Pavlik [this message]
2005-06-14 19:29   ` Stas Sergeev
2005-06-14 20:00     ` Vojtech Pavlik
2005-06-15 16:45       ` Stas Sergeev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050614185535.GA4041@ucw.cz \
    --to=vojtech@suse.cz \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stsp@aknet.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.