Mailing List archive

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

[linux-dvb] RFC: patch for support of volume control on DVB-C+analogue-module



Hi all!

Here's my patch against linuxtv-pre2 that enables volume control for DVB-C
cards via the msp3400 on its analogue extension module:

<begin patch>

diff -ur linuxtv-dvb-1.0.0-pre2/driver/av7110/av7110.c 
linuxtv-dvb-1.0.0-pre2_msp3400/driver/av7110/av7110.c
--- linuxtv-dvb-1.0.0-pre2/driver/av7110/av7110.c       Tue Mar  4 19:29:55 
2003
+++ linuxtv-dvb-1.0.0-pre2_msp3400/driver/av7110/av7110.c       Tue Apr 22 
20:00:15 2003
@@ -118,6 +118,19 @@
         schedule_timeout((HZ*i)/100);
 }
 
+static inline int
+msp_writereg(av7110_t *av7110, u8 dev, u16 reg, u16 val)
+{
+        u8 msg[5]={ dev, reg>>8, reg&0xff, val>>8 , val&0xff }; 
+        struct dvb_i2c_bus *i2c = av7110->saa->i2c_bus;
+        struct i2c_msg msgs;
+
+        msgs.flags=0;
+        msgs.addr=0x40;
+        msgs.len=5;
+        msgs.buf=msg;
+        return i2c->xfer(i2c, &msgs, 1);
+}
 
 /****************************************************************************
  * GPIO and DEBI functions
@@ -1580,7 +1593,7 @@
 SetVolume(av7110_t *av7110, int volleft, int volright)
 {
         int err=0;
-       int chleft, chright;
+       int chleft, chright, vol, val, balance = 0;
         
         switch (av7110->adac_type) {
         case DVB_ADAC_TI:
@@ -1603,6 +1616,17 @@
                 i2c_writereg(av7110, 0x20, 0x04, chright);
                break;
 
+        case DVB_ADAC_MSP:
+          vol  = (volleft > volright) ? volleft : volright;
+          val     = (vol * 0x73 / 255) << 8;
+          if (vol > 0) {
+            balance = ((volright-volleft) * 127) / vol;
+          }
+          msp_writereg(av7110, 0x12, 0x0001, balance << 8);
+          msp_writereg(av7110, 0x12, 0x0000, val); /* loudspeaker */
+          msp_writereg(av7110, 0x12, 0x0006, val); /* headphones */
+          break;
+
        default:
                err = -1;
         }
@@ -2450,20 +2474,6 @@
         return i2c->xfer (i2c, &msgs, 1);
 }
 
-static inline int
-msp_writereg(av7110_t *av7110, u8 dev, u16 reg, u16 val)
-{
-        u8 msg[5]={ dev, reg>>8, reg&0xff, val>>8 , val&0xff }; 
-        struct dvb_i2c_bus *i2c = av7110->saa->i2c_bus;
-        struct i2c_msg msgs;
-
-        msgs.flags=0;
-        msgs.addr=0x40;
-        msgs.len=5;
-        msgs.buf=msg;
-        return i2c->xfer(i2c, &msgs, 1);
-}
-
 static inline u8
 i2c_readreg(av7110_t *av7110, u8 id, u8 reg)
 {
@@ -4773,6 +4783,7 @@
                                 i2c_writereg(av7110, 0x80, 0x0, 0);
                                 printk("av7110: DVB-C analog module detected, 
"
                                        "initializing MSP3400\n");
+                                av7110->adac_type = DVB_ADAC_MSP;
                                 ddelay(10);
                                 msp_writereg(av7110, 0x12, 0x0013, 0x0c00);
                                 msp_writereg(av7110, 0x12, 0x0000, 0x7f00); 
// loudspeaker + headphone
@@ -4781,7 +4792,8 @@
                                 msp_writereg(av7110, 0x12, 0x000a, 0x0220); 
// SCART 1 source
                                 msp_writereg(av7110, 0x12, 0x0007, 0x7f00); 
// SCART 1 volume
                                 msp_writereg(av7110, 0x12, 0x000d, 0x4800); 
// prescale SCART
-                        }
+                        } else 
+                          av7110->adac_type = DVB_ADAC_NONE;
 
                         // switch DVB SCART on
                         outcom(av7110, COMTYPE_AUDIODAC, MainSwitch, 1, 0);
@@ -4789,8 +4801,7 @@
                         
                         //setgpio(av7110, 1, GPIO_OUTHI); // RGB on, SCART 
pin 16
                         //setgpio(av7110, 3, GPIO_OUTLO); // SCARTpin 8
-                        av7110->adac_type = DVB_ADAC_NONE;
-                }
+                 }
 
                av7110_setup_irc_config (av7110, 0);
         }
diff -ur linuxtv-dvb-1.0.0-pre2/driver/av7110/av7110.h 
linuxtv-dvb-1.0.0-pre2_msp3400/driver/av7110/av7110.h
--- linuxtv-dvb-1.0.0-pre2/driver/av7110/av7110.h       Fri Nov  8 16:22:36 
2002
+++ linuxtv-dvb-1.0.0-pre2_msp3400/driver/av7110/av7110.h       Tue Apr 22 
15:08:19 2003
@@ -502,6 +502,7 @@
         int adac_type;         /* audio DAC type */
 #define DVB_ADAC_TI       0
 #define DVB_ADAC_CRYSTAL  1
+#define DVB_ADAC_MSP      2
 #define DVB_ADAC_NONE    -1

</end patch>

What do you think of it?

rgds
Tobias Bratfisch



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



Home | Main Index | Thread Index