All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaime Lopez <jsollano@gmail.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: Re: [PATCH] Add mixer controls to intel8x0m
Date: Wed, 23 Feb 2005 09:41:22 -0600	[thread overview]
Message-ID: <977226cd050223074138d1e0b2@mail.gmail.com> (raw)
In-Reply-To: <s5hy8dfshlm.wl@alsa2.suse.de>

[-- Attachment #1: Type: text/plain, Size: 416 bytes --]

> Please create a unified style patch with diff -u.

here it is

> - The callback function names can be other ones that match better to
>   the control itself

I decided to keep the names but made the callbacks reusable. Hope you
don't mind.

> - Remove spin_lock_irq() around snd_ac97_*() calls
done
> - Clean up the comments
> 
> thanks,
> 
> Takashi
> 

Signed-off-by: Jaime A. Lopez Sollano <jsollano@gmail.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: intel8x0m.c.patch --]
[-- Type: text/x-patch; name="intel8x0m.c.patch", Size: 3948 bytes --]

Index: intel8x0m.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/pci/intel8x0m.c,v
retrieving revision 1.28
diff -u -r1.28 intel8x0m.c
--- intel8x0m.c	17 Feb 2005 14:48:07 -0000	1.28
+++ intel8x0m.c	23 Feb 2005 15:30:10 -0000
@@ -34,7 +34,9 @@
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/ac97_codec.h>
+#include <sound/core.h>
 #include <sound/info.h>
+#include <sound/control.h>
 #include <sound/initval.h>
 
 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
@@ -281,9 +283,63 @@
 #endif
 	{ 0, }
 };
+static int snd_intel8x0m_switch_default_get(snd_kcontrol_t *kcontrol,
+			snd_ctl_elem_value_t *ucontrol);
+static int snd_intel8x0m_switch_default_put(snd_kcontrol_t *kcontrol,
+						snd_ctl_elem_value_t *ucontrol);
+static int snd_intel8x0m_switch_default_info(snd_kcontrol_t *kcontrol,
+						snd_ctl_elem_info_t *uinfo);
+struct snd_intel8x0m_mixer_switch_args {
+	unsigned short reg;
+	unsigned short mask;
+};
+#define PRIVATE_VALUE_INITIALIZER(r,m) \
+(unsigned long)&(struct snd_intel8x0m_mixer_switch_args) \
+{ .reg = r, .mask = m}
+
+static snd_kcontrol_new_t snd_intel8x0m_mixer_switches[] __devinitdata = {
+  { .name  = "Off-hook Switch",
+    .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
+    .info  = snd_intel8x0m_switch_default_info,
+    .get   = snd_intel8x0m_switch_default_get,
+    .put   = snd_intel8x0m_switch_default_put,
+    .private_value = PRIVATE_VALUE_INITIALIZER(AC97_GPIO_STATUS,AC97_GPIO_LINE1_OH)
+  }
+};
 
 MODULE_DEVICE_TABLE(pci, snd_intel8x0m_ids);
 
+static int snd_intel8x0m_switch_default_info(snd_kcontrol_t *kcontrol,
+						snd_ctl_elem_info_t *uinfo)
+{
+	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
+	uinfo->count = 1;
+	uinfo->value.integer.min = 0;
+	uinfo->value.integer.max = 1;
+	return 0;
+}
+
+static int snd_intel8x0m_switch_default_get(snd_kcontrol_t *kcontrol,
+			snd_ctl_elem_value_t *ucontrol)
+{
+	struct snd_intel8x0m_mixer_switch_args *args = (void *)kcontrol->private_value;
+	intel8x0_t *chip = snd_kcontrol_chip(kcontrol);
+	unsigned int status;
+	status = snd_ac97_read(chip->ac97,args->reg)&args->mask?1:0;
+	ucontrol->value.integer.value[0] = status;
+	return 0;
+}
+static int snd_intel8x0m_switch_default_put(snd_kcontrol_t *kcontrol,
+						snd_ctl_elem_value_t *ucontrol)
+{
+	struct snd_intel8x0m_mixer_switch_args *args = (void *)kcontrol->private_value;
+	intel8x0_t *chip = snd_kcontrol_chip(kcontrol);
+	unsigned short new_status = ucontrol->value.integer.value[0]?args->mask:~args->mask;
+	int ret;
+	ret = snd_ac97_update_bits(chip->ac97,args->reg,
+					args->mask, new_status);
+	return ret;
+}
 /*
  *  Lowlevel I/O - busmaster
  */
@@ -638,17 +694,12 @@
 
 static int snd_intel8x0m_pcm_trigger(snd_pcm_substream_t *substream, int cmd)
 {
-	ichdev_t *ichdev = get_ichdev(substream);
 	/* hook off/on on start/stop */
-	/* TODO: move it to ac97 controls */
+	/* Moved this to mixer control */
 	switch (cmd) {
 	case SNDRV_PCM_TRIGGER_START:
-		snd_ac97_update_bits(ichdev->ac97, AC97_GPIO_STATUS,
-				     AC97_GPIO_LINE1_OH, AC97_GPIO_LINE1_OH);
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
-		snd_ac97_update_bits(ichdev->ac97, AC97_GPIO_STATUS,
-				     AC97_GPIO_LINE1_OH, ~AC97_GPIO_LINE1_OH);
 		break;
 	default:
 		return -EINVAL;
@@ -890,6 +941,7 @@
 	ac97_t *x97;
 	int err;
 	unsigned int glob_sta = 0;
+	unsigned int idx;
 	static ac97_bus_ops_t ops = {
 		.write = snd_intel8x0_codec_write,
 		.read = snd_intel8x0_codec_read,
@@ -925,6 +977,10 @@
 		chip->ichd[ICHD_MDMIN].ac97 = x97;
 		chip->ichd[ICHD_MDMOUT].ac97 = x97;
 	}
+	for(idx = 0; idx < ARRAY_SIZE(snd_intel8x0m_mixer_switches); idx++) {
+		if((err = snd_ctl_add(chip->card,snd_ctl_new1(&snd_intel8x0m_mixer_switches[idx],chip))) <0 )
+		goto __err;
+	}
 
 	chip->in_ac97_init = 0;
 	return 0;

      reply	other threads:[~2005-02-23 15:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-22 23:08 [PATCH] Add mixer controls to intel8x0m Jaime Lopez
2005-02-22 23:14 ` Jaime Lopez
2005-02-23 10:20   ` Takashi Iwai
2005-02-23 15:41     ` Jaime Lopez [this message]

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=977226cd050223074138d1e0b2@mail.gmail.com \
    --to=jsollano@gmail.com \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=tiwai@suse.de \
    /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.