All of lore.kernel.org
 help / color / mirror / Atom feed
* DXS volume as PCM on VIA82xx & CMI codecs
@ 2005-02-22 20:54 Takashi Iwai
  2005-02-22 21:53 ` thomas schorpp
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2005-02-22 20:54 UTC (permalink / raw)
  To: alsa-devel

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

Hi,

the patch below is an experimental patch to use DXS volume controls
for the missing PCM volume controls for C-Media codecs.  The DXS
volume controls won't be created any more with this patch.

Please let me know whether it works.


Takashi

[-- Attachment #2: Type: text/plain, Size: 4832 bytes --]

Index: alsa-kernel/pci/via82xx.c
===================================================================
RCS file: /suse/tiwai/cvs/alsa/alsa-kernel/pci/via82xx.c,v
retrieving revision 1.147
diff -u -r1.147 via82xx.c
--- alsa-kernel/pci/via82xx.c	28 Jan 2005 19:27:36 -0000	1.147
+++ alsa-kernel/pci/via82xx.c	22 Feb 2005 20:50:49 -0000
@@ -367,7 +367,7 @@
 	unsigned int mpu_port_saved;
 #endif
 
-	unsigned char playback_volume[4][2]; /* for VIA8233/C/8235; default = 0 */
+	unsigned char playback_volume[2]; /* for VIA8233/C/8235; default = 0 */
 
 	unsigned int intr_mask; /* SGD_SHADOW mask to check interrupts */
 
@@ -942,8 +942,8 @@
 	snd_assert((rbits & ~0xfffff) == 0, return -EINVAL);
 	snd_via82xx_channel_reset(chip, viadev);
 	snd_via82xx_set_table_ptr(chip, viadev);
-	outb(chip->playback_volume[viadev->reg_offset / 0x10][0], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L));
-	outb(chip->playback_volume[viadev->reg_offset / 0x10][1], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R));
+	outb(chip->playback_volume[0], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_L));
+	outb(chip->playback_volume[1], VIADEV_REG(viadev, OFS_PLAYBACK_VOLUME_R));
 	outl((runtime->format == SNDRV_PCM_FORMAT_S16_LE ? VIA8233_REG_TYPE_16BIT : 0) | /* format */
 	     (runtime->channels > 1 ? VIA8233_REG_TYPE_STEREO : 0) | /* stereo */
 	     rbits | /* rate */
@@ -1497,17 +1497,15 @@
 static int snd_via8233_dxs_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
 	via82xx_t *chip = snd_kcontrol_chip(kcontrol);
-	unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id);
-	ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][0];
-	ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume[idx][1];
+	ucontrol->value.integer.value[0] = VIA_DXS_MAX_VOLUME - chip->playback_volume[0];
+	ucontrol->value.integer.value[1] = VIA_DXS_MAX_VOLUME - chip->playback_volume[1];
 	return 0;
 }
 
 static int snd_via8233_dxs_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
 {
 	via82xx_t *chip = snd_kcontrol_chip(kcontrol);
-	unsigned int idx = snd_ctl_get_ioff(kcontrol, &ucontrol->id);
-	unsigned long port = chip->port + 0x10 * idx;
+	unsigned int idx;
 	unsigned char val;
 	int i, change = 0;
 
@@ -1516,19 +1514,21 @@
 		if (val > VIA_DXS_MAX_VOLUME)
 			val = VIA_DXS_MAX_VOLUME;
 		val = VIA_DXS_MAX_VOLUME - val;
-		change |= val != chip->playback_volume[idx][i];
-		if (change) {
-			chip->playback_volume[idx][i] = val;
-			outb(val, port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i);
+		if (val != chip->playback_volume[i]) {
+			change = 1;
+			chip->playback_volume[i] = val;
+			for (idx = 0; idx < 4; idx++) {
+				unsigned long port = chip->port + 0x10 * idx;
+				outb(val, port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i);
+			}
 		}
 	}
 	return change;
 }
 
 static snd_kcontrol_new_t snd_via8233_dxs_volume_control __devinitdata = {
-	.name = "VIA DXS Playback Volume",
+	.name = "PCM Playback Volume",
 	.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
-	.count = 4,
 	.info = snd_via8233_dxs_volume_info,
 	.get = snd_via8233_dxs_volume_get,
 	.put = snd_via8233_dxs_volume_put,
@@ -1657,9 +1657,18 @@
 			return err;
 	}
 	if (chip->chip_type != TYPE_VIA8233A) {
-		err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_dxs_volume_control, chip));
-		if (err < 0)
-			return err;
+		/* when no h/w PCM volume control is found, use DXS volume control
+		 * as the PCM vol control
+		 */
+		snd_ctl_elem_id_t sid;
+		memset(&sid, 0, sizeof(sid));
+		strcpy(sid.name, "PCM Playback Volume");
+		sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
+		if (! snd_ctl_find_id(chip->card, &sid)) {
+			err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_via8233_dxs_volume_control, chip));
+			if (err < 0)
+				return err;
+		}
 	}
 
 	/* select spdif data slot 10/11 */
@@ -1888,6 +1897,15 @@
 		}
 	}
 
+	if (chip->chip_type != TYPE_VIA8233A) {
+		int i, idx;
+		for (idx = 0; idx < 4; idx++) {
+			unsigned long port = chip->port + 0x10 * idx;
+			for (i = 0; i < 2; i++)
+				outb(chip->playback_volume[i], port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i);
+		}
+	}
+
 	return 0;
 }
 
@@ -1923,7 +1941,7 @@
 static int snd_via82xx_resume(snd_card_t *card)
 {
 	via82xx_t *chip = card->pm_private_data;
-	int idx, i;
+	int i;
 
 	pci_enable_device(chip->pci);
 	pci_set_power_state(chip->pci, 0);
@@ -1939,11 +1957,6 @@
 		pci_write_config_byte(chip->pci, VIA8233_SPDIF_CTRL, chip->spdif_ctrl_saved);
 		outb(chip->capture_src_saved[0], chip->port + VIA_REG_CAPTURE_CHANNEL);
 		outb(chip->capture_src_saved[1], chip->port + VIA_REG_CAPTURE_CHANNEL + 0x10);
-		for (idx = 0; idx < 4; idx++) {
-			unsigned long port = chip->port + 0x10 * idx;
-			for (i = 0; i < 2; i++)
-				outb(chip->playback_volume[idx][i], port + VIA_REG_OFS_PLAYBACK_VOLUME_L + i);
-		}
 	}
 
 	snd_ac97_resume(chip->ac97);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: DXS volume as PCM on VIA82xx & CMI codecs
  2005-02-22 20:54 DXS volume as PCM on VIA82xx & CMI codecs Takashi Iwai
@ 2005-02-22 21:53 ` thomas schorpp
  2005-02-23  9:51   ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: thomas schorpp @ 2005-02-22 21:53 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Takashi Iwai wrote:
> Hi,
> 
> the patch below is an experimental patch to use DXS volume controls
> for the missing PCM volume controls for C-Media codecs.  The DXS
> volume controls won't be created any more with this patch.
> 
> Please let me know whether it works.
> 
> 
> Takashi
> 

yes it does, but the pcm mixer is only accessible from xmms oss-plugin 
not from alsa-plugin and balance doesnt work.

hmm, access bug in xmms, xine does acces the new PCM slider.

ok.

how about balance? its on the master vol only, hm?

tom


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: DXS volume as PCM on VIA82xx & CMI codecs
  2005-02-22 21:53 ` thomas schorpp
@ 2005-02-23  9:51   ` Takashi Iwai
  2005-02-23 10:00     ` thomas schorpp
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2005-02-23  9:51 UTC (permalink / raw)
  To: t.schorpp; +Cc: alsa-devel

At Tue, 22 Feb 2005 22:53:32 +0100,
thomas schorpp wrote:
> 
> Takashi Iwai wrote:
> > Hi,
> > 
> > the patch below is an experimental patch to use DXS volume controls
> > for the missing PCM volume controls for C-Media codecs.  The DXS
> > volume controls won't be created any more with this patch.
> > 
> > Please let me know whether it works.
> > 
> > 
> > Takashi
> > 
> 
> yes it does, but the pcm mixer is only accessible from xmms oss-plugin 
> not from alsa-plugin and balance doesnt work.
> 
> hmm, access bug in xmms, xine does acces the new PCM slider.
> 
> ok.
> 
> how about balance? its on the master vol only, hm?

Can't you change left/right PCM volume independently?


Takashi


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: DXS volume as PCM on VIA82xx & CMI codecs
  2005-02-23  9:51   ` Takashi Iwai
@ 2005-02-23 10:00     ` thomas schorpp
  2005-02-23 10:33       ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: thomas schorpp @ 2005-02-23 10:00 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Takashi Iwai wrote:
> At Tue, 22 Feb 2005 22:53:32 +0100,
> thomas schorpp wrote:
> 
>>Takashi Iwai wrote:
>>
>>>Hi,
>>>
>>>the patch below is an experimental patch to use DXS volume controls
>>>for the missing PCM volume controls for C-Media codecs.  The DXS
>>>volume controls won't be created any more with this patch.
>>>
>>>Please let me know whether it works.
>>>
>>>
>>>Takashi
>>>
>>
>>yes it does, but the pcm mixer is only accessible from xmms oss-plugin 
>>not from alsa-plugin and balance doesnt work.
>>
>>hmm, access bug in xmms, xine does acces the new PCM slider.
>>
>>ok.
>>
>>how about balance? its on the master vol only, hm?
> 
> 
> Can't you change left/right PCM volume independently?
> 

yes, but only with alsamixergui or maybe the gnomemixer, not with suse's 
  preffered kde mixer kmix.

> 
> Takashi
> 

tom


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: DXS volume as PCM on VIA82xx & CMI codecs
  2005-02-23 10:00     ` thomas schorpp
@ 2005-02-23 10:33       ` Takashi Iwai
  2005-02-23 10:43         ` thomas schorpp
  0 siblings, 1 reply; 6+ messages in thread
From: Takashi Iwai @ 2005-02-23 10:33 UTC (permalink / raw)
  To: t.schorpp; +Cc: alsa-devel

At Wed, 23 Feb 2005 11:00:39 +0100,
thomas schorpp wrote:
> 
> Takashi Iwai wrote:
> > At Tue, 22 Feb 2005 22:53:32 +0100,
> > thomas schorpp wrote:
> > 
> >>Takashi Iwai wrote:
> >>
> >>>Hi,
> >>>
> >>>the patch below is an experimental patch to use DXS volume controls
> >>>for the missing PCM volume controls for C-Media codecs.  The DXS
> >>>volume controls won't be created any more with this patch.
> >>>
> >>>Please let me know whether it works.
> >>>
> >>>
> >>>Takashi
> >>>
> >>
> >>yes it does, but the pcm mixer is only accessible from xmms oss-plugin 
> >>not from alsa-plugin and balance doesnt work.
> >>
> >>hmm, access bug in xmms, xine does acces the new PCM slider.
> >>
> >>ok.
> >>
> >>how about balance? its on the master vol only, hm?
> > 
> > 
> > Can't you change left/right PCM volume independently?
> > 
> 
> yes, but only with alsamixergui or maybe the gnomemixer, not with suse's 
>   preffered kde mixer kmix.

Then it's a bug of kmix...


Takashi


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: DXS volume as PCM on VIA82xx & CMI codecs
  2005-02-23 10:33       ` Takashi Iwai
@ 2005-02-23 10:43         ` thomas schorpp
  0 siblings, 0 replies; 6+ messages in thread
From: thomas schorpp @ 2005-02-23 10:43 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: alsa-devel

Takashi Iwai wrote:
> At Wed, 23 Feb 2005 11:00:39 +0100,
> thomas schorpp wrote:
> 
>>Takashi Iwai wrote:
>>
>>>At Tue, 22 Feb 2005 22:53:32 +0100,
>>>thomas schorpp wrote:
>>>
>>>
>>>>Takashi Iwai wrote:
>>>>
>>>>
>>>>>Hi,
>>>>>
>>>>>the patch below is an experimental patch to use DXS volume controls
>>>>>for the missing PCM volume controls for C-Media codecs.  The DXS
>>>>>volume controls won't be created any more with this patch.
>>>>>
>>>>>Please let me know whether it works.
>>>>>
>>>>>
>>>>>Takashi
>>>>>
>>>>
>>>>yes it does, but the pcm mixer is only accessible from xmms oss-plugin 
>>>>not from alsa-plugin and balance doesnt work.
>>>>
>>>>hmm, access bug in xmms, xine does acces the new PCM slider.
>>>>
>>>>ok.
>>>>
>>>>how about balance? its on the master vol only, hm?
>>>
>>>
>>>Can't you change left/right PCM volume independently?
>>>
>>
>>yes, but only with alsamixergui or maybe the gnomemixer, not with suse's 
>>  preffered kde mixer kmix.
> 
> 
> Then it's a bug of kmix...

missing feature. design looks like balance only over master vol.

BTW, the 2.8.0 gnome-media volume control (gstreamer) wont work at all, 
says it cant find devices, but its their problem to fix...

tom

> 
> 
> Takashi
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-02-23 10:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-22 20:54 DXS volume as PCM on VIA82xx & CMI codecs Takashi Iwai
2005-02-22 21:53 ` thomas schorpp
2005-02-23  9:51   ` Takashi Iwai
2005-02-23 10:00     ` thomas schorpp
2005-02-23 10:33       ` Takashi Iwai
2005-02-23 10:43         ` thomas schorpp

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.