summaryrefslogtreecommitdiff
path: root/linux/drivers/media
diff options
context:
space:
mode:
authorHolger Waechtler <devnull@localhost>2003-06-13 20:32:41 +0000
committerHolger Waechtler <devnull@localhost>2003-06-13 20:32:41 +0000
commit07e4c27ee61a298e28ad61b55df67ba81b6a07e2 (patch)
treef1430d26451471022583411174d360fc3be23485 /linux/drivers/media
parentc753e6c0e69454b99f32da5e5fd38794418d48c8 (diff)
downloadmediapointer-dvb-s2-07e4c27ee61a298e28ad61b55df67ba81b6a07e2.tar.gz
mediapointer-dvb-s2-07e4c27ee61a298e28ad61b55df67ba81b6a07e2.tar.bz2
read MAC from EEPROM if available, contributed by Michael Glaum <mglaum@kvh.com>
Diffstat (limited to 'linux/drivers/media')
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvbdev.h1
-rw-r--r--linux/drivers/media/dvb/ttpci/Makefile18
-rw-r--r--linux/drivers/media/dvb/ttpci/av7110.c4
-rw-r--r--linux/drivers/media/dvb/ttpci/budget-core.c3
-rw-r--r--linux/drivers/media/dvb/ttpci/ttpci_eeprom.c107
-rw-r--r--linux/drivers/media/dvb/ttpci/ttpci_eeprom.h32
6 files changed, 156 insertions, 9 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.h b/linux/drivers/media/dvb/dvb-core/dvbdev.h
index 967bdadf1..b9eac9b46 100644
--- a/linux/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/linux/drivers/media/dvb/dvb-core/dvbdev.h
@@ -52,6 +52,7 @@ struct dvb_adapter {
struct list_head list_head;
struct list_head device_list;
const char *name;
+ u8 proposed_mac [6];
};
diff --git a/linux/drivers/media/dvb/ttpci/Makefile b/linux/drivers/media/dvb/ttpci/Makefile
index c1e1f7b4c..da44ce79d 100644
--- a/linux/drivers/media/dvb/ttpci/Makefile
+++ b/linux/drivers/media/dvb/ttpci/Makefile
@@ -3,16 +3,16 @@
# and the AV7110 DVB device driver
#
-dvb-ttpci-budget-objs := budget.o
-dvb-ttpci-budget-av-objs := budget-av.o
-dvb-ttpci-budget-ci-objs := budget-ci.o
-dvb-ttpci-budget-patch-objs := budget-patch.o
-dvb-ttpci-objs := av7110.o av7110_ipack.o av7110_ir.o
+dvb-ttpci-budget-objs := budget-core.o budget.o ttpci-eeprom.o
+dvb-ttpci-budget-av-objs := budget-core.o budget-av.o ttpci-eeprom.o
+dvb-ttpci-budget-ci-objs := budget-core.o budget-ci.o ttpci-eeprom.o
+dvb-ttpci-budget-patch-objs := budget-core.o budget-patch.o ttpci-eeprom.o
+dvb-ttpci-objs := av7110.o av7110_ipack.o av7110_ir.o ttpci-eeprom.o
-obj-$(CONFIG_DVB_BUDGET) += budget-core.o dvb-ttpci-budget.o
-obj-$(CONFIG_DVB_BUDGET_CI) += budget-core.o dvb-ttpci-budget-ci.o
-obj-$(CONFIG_DVB_BUDGET_AV) += budget-core.o dvb-ttpci-budget-av.o
-obj-$(CONFIG_DVB_BUDGET_PATCH) += budget-core.o dvb-ttpci-budget-patch.o
+obj-$(CONFIG_DVB_BUDGET) += dvb-ttpci-budget.o
+obj-$(CONFIG_DVB_BUDGET_CI) += dvb-ttpci-budget-ci.o
+obj-$(CONFIG_DVB_BUDGET_AV) += dvb-ttpci-budget-av.o
+obj-$(CONFIG_DVB_BUDGET_PATCH) += dvb-ttpci-budget-patch.o
obj-$(CONFIG_DVB_AV7110) += dvb-ttpci.o
EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/
diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c
index 01d5cd25b..2df03db9d 100644
--- a/linux/drivers/media/dvb/ttpci/av7110.c
+++ b/linux/drivers/media/dvb/ttpci/av7110.c
@@ -86,9 +86,11 @@
#define DEB_EE(x)
#endif
+#include "ttpci-eeprom.h"
#include "av7110.h"
#include "av7110_ipack.h"
+
static int AV_StartPlay(struct av7110 *av7110, int av);
static void restart_feeds(struct av7110 *av7110);
static int bootarm(struct av7110 *av7110);
@@ -4443,6 +4445,8 @@ int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *p
return -ENOMEM;
}
+ ttpci_eeprom_parse_mac(av7110->i2c_bus);
+
saa7146_write(dev, PCI_BT_V1, 0x1c00101f);
saa7146_write(dev, BCS_CTRL, 0x80400040);
diff --git a/linux/drivers/media/dvb/ttpci/budget-core.c b/linux/drivers/media/dvb/ttpci/budget-core.c
index 041265b7a..a2227a94b 100644
--- a/linux/drivers/media/dvb/ttpci/budget-core.c
+++ b/linux/drivers/media/dvb/ttpci/budget-core.c
@@ -1,4 +1,5 @@
#include "budget.h"
+#include "ttpci_eeprom.h"
int budget_debug = 0;
@@ -240,6 +241,8 @@ int ttpci_budget_init (struct budget *budget,
return -ENOMEM;
}
+ ttpci_eeprom_parse_mac(budget->i2c_bus);
+
if( NULL == (budget->grabbing = saa7146_vmalloc_build_pgtable(dev->pci,length,&budget->pt))) {
ret = -ENOMEM;
goto err;
diff --git a/linux/drivers/media/dvb/ttpci/ttpci_eeprom.c b/linux/drivers/media/dvb/ttpci/ttpci_eeprom.c
new file mode 100644
index 000000000..aa9c68f0b
--- /dev/null
+++ b/linux/drivers/media/dvb/ttpci/ttpci_eeprom.c
@@ -0,0 +1,107 @@
+/*
+ Retrieve encoded MAC address from ATMEL ttpci_eeprom serial 2-wire EEPROM,
+ decode it and store it in associated adapter net device
+
+ Robert Schlabbach GMX
+ Michael Glaum KVH Industries
+ Holger Waechtler Convergence
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <asm/errno.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/string.h>
+
+#include "dvb_i2c.h"
+#include "dvb_functions.h"
+
+#if 0
+#define dprintk(x...) printk(x)
+#else
+#define dprintk(x...)
+#endif
+
+
+static
+int ttpci_eeprom_read_encodedMAC (struct dvb_i2c_bus *i2c, u8 * encodedMAC )
+{
+ int ret;
+ u8 b0 [] = { 0xd4 };
+ struct i2c_msg msg [] = { { addr: 0x50, flags: 0, buf: b0, len: 1 },
+ { addr: 0x50, flags: I2C_M_RD, buf: encodedMAC, len: 6 } };
+
+ dprintk ("%s\n", __FUNCTION__);
+
+ ret = i2c->xfer (i2c, msg, 2);
+
+ if (ret != 2) // Assume EEPROM isn't there
+ return( -ENODEV );
+
+ return 0;
+}
+
+static
+void decodeMAC (u8 *decodedMAC, const u8* encodedMAC)
+{
+ u8 ormask0[3] = { 0x54, 0x7B, 0x9E };
+ u8 ormask1[3] = { 0xD3, 0xF1, 0x23 };
+ u8 low;
+ u8 high;
+ u8 shift;
+ int i;
+
+ decodedMAC[0] = 0x00;
+ decodedMAC[1] = 0xD0;
+ decodedMAC[2] = 0x5C;
+
+ for (i=0; i<3; i++) {
+ low = encodedMAC[ 2*i ] ^ ormask0[i];
+ high = encodedMAC[ 2*i+1 ] ^ ormask1[i];
+ shift = ( high >> 6 ) & 0x3;
+
+ decodedMAC[5-i] = ((high<<8) | low) >> shift;
+ }
+
+}
+
+
+int ttpci_eeprom_parse_mac (struct dvb_i2c_bus *i2c)
+{
+ int ret;
+ u8 encodedMAC[6];
+ u8 decodedMAC[6];
+
+ ret = ttpci_eeprom_read_encodedMAC(i2c, encodedMAC);
+
+ if (ret != 0) { // Will only be -ENODEV
+ dprintk("Couldn't read from EEPROM: not there?\n");
+ return ret;
+ }
+
+ decodeMAC(decodedMAC, encodedMAC);
+ memcpy(i2c->adapter->proposed_mac, decodedMAC, 6);
+
+ dprintk("%s adapter %i has MAC addr = %x:%x:%x:%x:%x:%x\n",
+ i2c->adapter->name, i2c->adapter->num,
+ decodedMAC[0],decodedMAC[1],decodedMAC[2],
+ decodedMAC[3],decodedMAC[4],decodedMAC[5]);
+
+ return 0;
+}
+
+
diff --git a/linux/drivers/media/dvb/ttpci/ttpci_eeprom.h b/linux/drivers/media/dvb/ttpci/ttpci_eeprom.h
new file mode 100644
index 000000000..66cb85ced
--- /dev/null
+++ b/linux/drivers/media/dvb/ttpci/ttpci_eeprom.h
@@ -0,0 +1,32 @@
+/*
+ Retrieve encoded MAC address from ATMEL ttpci_eeprom serial 2-wire EEPROM,
+ decode it and store it in associated adapter net device
+
+ Robert Schlabbach GMX
+ Michael Glaum KVH Industries
+ Holger Waechtler Convergence
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __TTPCI_EEPROM_H__
+#define __TTPCI_EEPROM_H__
+
+#include "dvb_i2c.h"
+
+extern int ttpci_eeprom_parse_mac (struct dvb_i2c_bus *i2c);
+
+#endif