Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: RFC: patch for support of volume control on DVB-C+analogue-module
Hi!
>
> I'd like to include your patch. Please generate it using 'cvs diff -pu'
> against the LinuxTV CVS repository for both the DVB/-tree and the
> dvb-kernel/ tree. Please send your patch not inlined into the mail in
> order to avoid that mail clients screw it up (I was not able to apply
> your inlined patch - ).
Ok, once again, this time attached using 'cvs diff -pu' for both
DVB/kernel :-)
rgds
Tobias Bratfisch
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); /* headphonesr */
+ 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
Index: linux/drivers/media/dvb/ttpci/av7110.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/av7110.c,v
retrieving revision 1.40
diff -p -u -r1.40 av7110.c
--- linux/drivers/media/dvb/ttpci/av7110.c 22 Apr 2003 16:30:45 -0000 1.40
+++ linux/drivers/media/dvb/ttpci/av7110.c 23 Apr 2003 13:53:50 -0000
@@ -1338,6 +1338,19 @@ RequestParameter(av7110_t *av7110, u16 t
* Firmware commands
****************************************************************************/
+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->i2c_bus;
+ struct i2c_msg msgs;
+
+ msgs.flags=0;
+ msgs.addr=0x40;
+ msgs.len=5;
+ msgs.buf=msg;
+ return i2c->xfer(i2c, &msgs, 1);
+}
inline static int
SendDAC(av7110_t *av7110, u8 addr, u8 data)
@@ -1350,7 +1363,7 @@ SendDAC(av7110_t *av7110, u8 addr, u8 da
static int
SetVolume(av7110_t *av7110, int volleft, int volright)
{
- int err;
+ int err, vol, val, chleft, chright, balance = 0;
DEB_EE(("av7110: %p\n",av7110));
@@ -1372,6 +1385,17 @@ SetVolume(av7110_t *av7110, int volleft,
i2c_writereg(av7110, 0x20, 0x03, volleft);
i2c_writereg(av7110, 0x20, 0x04, volright);
return 0;
+
+ 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); /* headphonesr */
+ return 0;
}
return 0;
}
@@ -2188,20 +2212,6 @@ i2c_writereg(av7110_t *av7110, u8 id, u8
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->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)
{
@@ -4291,6 +4301,7 @@ int av7110_attach (struct saa7146_dev* d
i2c_writereg(av7110, 0x80, 0x0, 0);
printk ("av7110: DVB-C analog module detected, "
"initializing MSP3400\n");
+ av7110->adac_type = DVB_ADAC_MSP;
ddelay(100);
msp_writereg(av7110, 0x12, 0x0013, 0x0c00);
msp_writereg(av7110, 0x12, 0x0000, 0x7f00); // loudspeaker + headphone
@@ -4299,7 +4310,8 @@ int av7110_attach (struct saa7146_dev* d
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
@@ -4307,7 +4319,6 @@ int av7110_attach (struct saa7146_dev* d
outcom(av7110, COMTYPE_AUDIODAC, ADSwitch, 1, 1);
//saa7146_setgpio(dev, 1, SAA7146_GPIO_OUTHI); // RGB on, SCART pin 16
//saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); // SCARTpin 8
- av7110->adac_type = DVB_ADAC_NONE;
}
av7110_setup_irc_config (av7110, 0);
Index: linux/drivers/media/dvb/ttpci/av7110.h
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/ttpci/av7110.h,v
retrieving revision 1.7
diff -p -u -r1.7 av7110.h
--- linux/drivers/media/dvb/ttpci/av7110.h 22 Apr 2003 13:19:05 -0000 1.7
+++ linux/drivers/media/dvb/ttpci/av7110.h 23 Apr 2003 13:53:51 -0000
@@ -480,6 +480,7 @@ typedef struct av7110_s {
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
Home |
Main Index |
Thread Index