Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: how to read audio volume?



On Út, 2002-10-29 at 14:30, Holger Waechtler wrote:
> Johannes Stezenbach wrote:
> > Andreas Oberritter wrote:
> > 
> >>why is there no such thing like an AUDIO_GET_MIXER ioctl, which
> >>applications could use to report the current audio volume, for example
> >>to set up a volume bar. Adding a struct audio_mixer to struct
> >>audio_status would be a solution for this, too.
> > 
> > 
> > It's not there because it wasn't in the original Nokia API,
> > and we didn't need it. But I think it would make sense to
> > add it. I would prefer to add a struct audio_mixer field to
> > struct audio_status.
> 
> (any contributors out there?;)
> 

I'v made a little patch against today's CVS.

/Honza

--- include/linux/dvb/audio.h.ori	2002-10-29 15:59:37.000000000 +0100
+++ include/linux/dvb/audio.h	2002-10-29 14:54:03.000000000 +0100
@@ -50,6 +50,11 @@
 	AUDIO_MONO_RIGHT, 
 } audio_channel_select_t;
 
+typedef struct audio_mixer { 
+        unsigned int volume_left;
+        unsigned int volume_right;
+  // what else do we need? bass, pass-through, ...
+} audio_mixer_t;
 
 typedef struct audio_status { 
         int                    AV_sync_state;  /* sync audio and video? */
@@ -58,15 +63,10 @@
         audio_stream_source_t  stream_source;  /* current stream source */
         audio_channel_select_t channel_select; /* currently selected channel */
         int                    bypass_mode;    /* pass on audio data to */
+        audio_mixer_t          mixer_state; //hop@
 } audio_status_t;                              /* separate decoder hardware */
 

-typedef struct audio_mixer { 
-        unsigned int volume_left;
-        unsigned int volume_right;
-  // what else do we need? bass, pass-through, ...
-} audio_mixer_t;
-
 
 typedef
 struct audio_karaoke{  /* if Vocal1 or Vocal2 are non-zero, they get mixed  */


--- driver/av7110/av7110.c.ori	2002-10-29 16:01:43.000000000 +0100
+++ driver/av7110/av7110.c	2002-10-29 15:56:05.000000000 +0100
@@ -1599,29 +1599,36 @@
 static int
 SetVolume(av7110_t *av7110, int volleft, int volright)
 {
-        int err;
+        int err=0;
+	int chleft, chright;
         
         switch (av7110->adac_type) {
         case DVB_ADAC_TI:
-                volleft=(volleft*256)/946;
-                volright=(volright*256)/946;
-                if (volleft > 0x45)
-                        volleft=0x45;
-                if (volright > 0x45)
-                        volright=0x45;
-                err=SendDAC(av7110, 3, 0x80 + volleft);
+                chleft=(volleft*256)/946;
+                chright=(volright*256)/946;
+                if (chleft > 0x45)
+                        chleft=0x45;
+                if (chright > 0x45)
+                        chright=0x45;
+                err=SendDAC(av7110, 3, 0x80 + chleft);
                 if (err)
                         return err;
-                return SendDAC(av7110, 4, volright);
+                err=SendDAC(av7110, 4, chright);
+		break;
                 
         case DVB_ADAC_CRYSTAL:
-                volleft=127-volleft/2;
-                volright=127-volright/2;
-                i2c_writereg(av7110, 0x20, 0x03, volleft);
-                i2c_writereg(av7110, 0x20, 0x04, volright);
-                return 0;
+                chleft=127-volleft/2;
+                chright=127-volright/2;
+                i2c_writereg(av7110, 0x20, 0x03, chleft);
+                i2c_writereg(av7110, 0x20, 0x04, chright);
+                break;
         }
-        return 0;
+	if(!err)
+        {
+		av7110->audiostate.mixer_state.volume_left = volleft;
+		av7110->audiostate.mixer_state.volume_right = volright;
+	}
+        return err;
 }
 
 #ifdef USE_OSD
@@ -4340,7 +4347,7 @@
         {
                 struct audio_mixer *amix=(struct audio_mixer *)parg;
 
-                SetVolume(av7110, amix->volume_left, amix->volume_right);
+                ret=SetVolume(av7110, amix->volume_left, amix->volume_right);
                 break;
         }
         case AUDIO_SET_STREAMTYPE:



--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index