summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/ttusb-budget
diff options
context:
space:
mode:
authorHolger Waechtler <devnull@localhost>2003-03-17 21:51:28 +0000
committerHolger Waechtler <devnull@localhost>2003-03-17 21:51:28 +0000
commite8d4556487e26de17f3ce4885943a8530db1b9b9 (patch)
treee9ef5dd93bf5ff77559a87c2b30ab1b33d82b330 /linux/drivers/media/dvb/ttusb-budget
parent0e0505bca61e2877a5283e37ad447f1496fb5503 (diff)
downloadmediapointer-dvb-s2-e8d4556487e26de17f3ce4885943a8530db1b9b9.tar.gz
mediapointer-dvb-s2-e8d4556487e26de17f3ce4885943a8530db1b9b9.tar.bz2
crc checking and stc code dump
Diffstat (limited to 'linux/drivers/media/dvb/ttusb-budget')
-rw-r--r--linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c113
1 files changed, 100 insertions, 13 deletions
diff --git a/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index a982e1afb..8bbfa0e13 100644
--- a/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/linux/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -39,13 +39,13 @@
datastreams, especially for dvb-net, but hey, that's not my problem.
TTUSB_DISEQC, TTUSB_TONE:
- let the STC do the diseqc/tone stuff. this isn't support at least with
+ let the STC do the diseqc/tone stuff. this isn't supported at least with
my TTUSB, so let it undef'd unless you want to implement another
frontend. never tested.
DEBUG:
define it to > 3 for really hardcore debugging. you probably don't want
- this if the device is loading at all.
+ this unless the device doesn't load at all.
*/
static int debug = 1;
@@ -114,6 +114,8 @@ struct ttusb {
int filterstate[TTUSB_MAXFILTER]; /* 0: not busy, 1: busy */
#endif
} channel[TTUSB_MAXCHANNEL];
+
+ devfs_handle_t stc_devfs_handle;
};
/* ugly workaround ... don't know why it's neccessary to read */
@@ -274,16 +276,16 @@ int ttusb_boot_dsp (struct ttusb *ttusb)
/* BootBlock */
b [0] = 0xaa;
b [2] = 0x13;
- b [3] = 16;
+ b [3] = 28;
/* upload dsp code in 16 byte steps (36 didn't work for me ...) */
/* 32 is max packet size, no messages should be splitted. */
- for (i=0; i<sizeof(dsp_bootcode); i+=16) {
- memcpy (&b[4], &dsp_bootcode[i], 16);
+ for (i=0; i<sizeof(dsp_bootcode); i+=28) {
+ memcpy (&b[4], &dsp_bootcode[i], 28);
b [1] = ++ttusb->c;
- err = ttusb_cmd (ttusb, b, 20);
+ err = ttusb_cmd (ttusb, b, 32);
if (err)
goto done;
}
@@ -534,8 +536,20 @@ static void ttusb_handle_sec_data(struct ttusb_channel *channel, const u8 *data,
#endif
static
-void ttusb_process_muxpack(struct ttusb *ttusb, const u8 *muxpack)
+void ttusb_process_muxpack(struct ttusb *ttusb, const u8 *muxpack, int len)
{
+ u16 csum=0;
+ int i;
+
+ for (i = 0; i < len; i+=2)
+ csum ^= le16_to_cpup((u16*)(muxpack+i));
+
+ if (csum) {
+ printk ("%s: muxpack with incorrect checksum, ignoring\n",
+ __FUNCTION__);
+ return;
+ }
+
if (muxpack[0] & 0x80)
{
#ifdef TTUSB_HWSECTIONS
@@ -648,14 +662,23 @@ void ttusb_process_frame(struct ttusb *ttusb, u8 *data, int len)
}
}
- /* if length is valid and we reached the end, goto next muxpack */
- if ((ttusb->muxpack_ptr >= 2) && (ttusb->muxpack_ptr == ttusb->muxpack_len))
+ /**
+ * if length is valid and we reached the end:
+ * goto next muxpack
+ */
+ if ((ttusb->muxpack_ptr >= 2) &&
+ (ttusb->muxpack_ptr == ttusb->muxpack_len))
{
- ttusb_process_muxpack(ttusb, ttusb->muxpack);
+ ttusb_process_muxpack(ttusb, ttusb->muxpack,
+ ttusb->muxpack_ptr);
ttusb->muxpack_ptr=0;
- ttusb->muxpack_len=2; /* maximum bytes, until we know the length */
+ /* maximum bytes, until we know the length */
+ ttusb->muxpack_len=2;
- /* no muxpacks left? return to search-sync state */
+ /**
+ * no muxpacks left?
+ * return to search-sync state
+ */
if (! ttusb->mux_npacks--)
{
ttusb->mux_state=0;
@@ -935,6 +958,59 @@ int ttusb_setup_interfaces (struct ttusb *ttusb)
}
+static u8 stc_firmware[8192];
+
+
+static
+int stc_open (struct inode *inode, struct file *file)
+{
+ struct ttusb *ttusb = file->private_data;
+ int addr;
+
+ for (addr=0; addr<8192; addr+=16) {
+ u8 snd_buf[2] = { addr >> 8, addr & 0xFF };
+ ttusb_i2c_msg (ttusb, 0x50, snd_buf, 2, stc_firmware+addr, 16);
+ }
+
+ return 0;
+}
+
+
+static
+ssize_t stc_read (struct file *file, char *buf, size_t count, loff_t *offset)
+{
+ int tc = count;
+
+ if ((tc+*offset) > 8192)
+ tc = 8192 - *offset;
+
+ if (tc < 0)
+ return 0;
+
+ copy_to_user (buf, stc_firmware + *offset, tc);
+
+ *offset += tc;
+
+ return tc;
+}
+
+
+static
+int stc_release(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+
+
+static
+struct file_operations stc_fops = {
+ .owner = THIS_MODULE,
+ .read = stc_read,
+ .open = stc_open,
+ .release = stc_release,
+};
+
+
static
void* ttusb_probe (struct usb_device *udev, unsigned int ifnum,
const struct usb_device_id *id)
@@ -1021,6 +1097,15 @@ void* ttusb_probe (struct usb_device *udev, unsigned int ifnum,
err:
ttusb_start_iso_xfer (ttusb);
+
+ ttusb->stc_devfs_handle = devfs_register(
+ ttusb->adapter->devfs_handle,
+ "ttusb_stc_fw",
+ DEVFS_FL_DEFAULT, 0, 192,
+ S_IFCHR | S_IRUSR | S_IWUSR |
+ S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
+ &stc_fops, ttusb);
+
return (void*) ttusb;
}
@@ -1035,11 +1120,13 @@ void ttusb_disconnect (struct usb_device *udev, void *data)
ttusb_stop_iso_xfer (ttusb);
+ devfs_unregister(ttusb->stc_devfs_handle);
+
ttusb->dvb_demux.dmx.close(&ttusb->dvb_demux.dmx);
dvb_net_release(&ttusb->dvbnet);
dvb_dmxdev_release(&ttusb->dmxdev);
dvb_dmx_release(&ttusb->dvb_demux);
-
+
dvb_unregister_i2c_bus (ttusb_i2c_xfer, ttusb->adapter, 0);
dvb_unregister_adapter (ttusb->adapter);