added i2c_mangle.ko, ethtool, change AXE modules loading
This commit is contained in:
parent
bc5a8c6301
commit
fc81c50197
31
Makefile
31
Makefile
@ -30,6 +30,8 @@ DROPBEAR=dropbear-2015.67
|
||||
DROPBEAR_SBIN_FILES=dropbear
|
||||
DROPBEAR_BIN_FILES=dbclient dropbearconvert dropbearkey scp
|
||||
|
||||
ETHTOOL=ethtool-3.18
|
||||
|
||||
# 10087?
|
||||
OSCAM_REV=10619
|
||||
|
||||
@ -64,17 +66,19 @@ dist:
|
||||
# create CPIO
|
||||
#
|
||||
|
||||
fs.cpio: kernel-modules busybox dropbear minisatip oscam tools/axehelper
|
||||
fs.cpio: kernel-modules busybox dropbear ethtool minisatip oscam tools/axehelper
|
||||
fakeroot tools/do_min_fs.py \
|
||||
-r "$(VERSION)" \
|
||||
-b "bash strace" \
|
||||
$(foreach m,$(EXTRA_AXE_MODULES), -e "$(EXTRA_AXE_MODULES_DIR)/$(m):lib/modules/axe/$(m)") \
|
||||
$(foreach m,$(ORIG_FILES), -e "$(EXTRA_AXE_MODULES_DIR)/../$(m):lib/modules/axe/$(m)") \
|
||||
-e "tools/i2c_mangle.ko:lib/modules/axe/i2c_mangle.ko" \
|
||||
$(foreach m,$(KMODULES), -e "kernel/$(m):lib/modules/$(m)") \
|
||||
-e "tools/axehelper:sbin/axehelper" \
|
||||
-e "apps/$(BUSYBOX)/busybox:bin/busybox" \
|
||||
$(foreach f,$(DROPBEAR_SBIN_FILES), -e "apps/$(DROPBEAR)/$(f):sbin/$(f)") \
|
||||
$(foreach f,$(DROPBEAR_BIN_FILES), -e "apps/$(DROPBEAR)/$(f):usr/bin/$(f)") \
|
||||
-e "apps/$(ETHTOOL)/ethtool:sbin/ethtool" \
|
||||
-e "apps/minisatip/minisatip:sbin/minisatip" \
|
||||
-e "apps/minisatip/icons/lr.jpg:usr/share/minisatip/icons/lr.jpg" \
|
||||
-e "apps/minisatip/icons/lr.png:usr/share/minisatip/icons/lr.png" \
|
||||
@ -131,7 +135,10 @@ kernel/arch/sh/boot/uImage.gz: kernel/drivers/usb/serial/cp210x.ko fs.cpio
|
||||
make -C kernel -j ${CPUS} PATH="$(PATH):$(TOOLPATH)" \
|
||||
ARCH=sh CROSS_COMPILE=$(TOOLCHAIN_KERNEL)/bin/sh4-linux- uImage.gz
|
||||
|
||||
.PHONY: kernel-modules
|
||||
tools/i2c_mangle.ko: tools/i2c_mangle.c
|
||||
make -C tools ARCH=sh CROSS_COMPILE=$(TOOLCHAIN_KERNEL)/bin/sh4-linux- all
|
||||
|
||||
.PHONY: kernel-modules tools/i2c_mangle.ko
|
||||
kernel-modules: kernel/drivers/usb/serial/cp210x.ko
|
||||
|
||||
.PHONY: kernel
|
||||
@ -250,6 +257,26 @@ apps/$(DROPBEAR)/dropbear: apps/$(DROPBEAR)/configure
|
||||
.PHONY: dropbear
|
||||
dropbear: apps/$(DROPBEAR)/dropbear
|
||||
|
||||
#
|
||||
# ethtool
|
||||
#
|
||||
|
||||
apps/$(ETHTOOL)/configure:
|
||||
$(call WGET,https://www.kernel.org/pub/software/network/ethtool/$(ETHTOOL).tar.gz,apps/$(ETHTOOL).tar.gz)
|
||||
tar -C apps -xzf apps/$(ETHTOOL).tar.gz
|
||||
|
||||
apps/$(ETHTOOL)/ethtool: apps/$(ETHTOOL)/configure
|
||||
cd apps/$(ETHTOOL) && \
|
||||
CC=$(TOOLCHAIN)/bin/sh4-linux-gcc \
|
||||
CFLAGS="-O2" \
|
||||
./configure \
|
||||
--host=sh4-linux \
|
||||
--prefix=/
|
||||
make -C apps/$(ETHTOOL)
|
||||
|
||||
.PHONY: ethtool
|
||||
ethtool: apps/$(ETHTOOL)/ethtool
|
||||
|
||||
#
|
||||
# oscam
|
||||
#
|
||||
|
@ -2,9 +2,15 @@
|
||||
# SATIP AXE firmware configuration
|
||||
#
|
||||
|
||||
CFGVER="8"
|
||||
HOSTNAME="satip-axe"
|
||||
KMODULES="drivers/usb/serial/cp210x.ko drivers/usb/serial/pl2303.ko drivers/usb/serial/ftdi_sio.ko"
|
||||
|
||||
#
|
||||
# STV6210 baseband amplifier gain (0dB .. 16dB - 2dB step)
|
||||
#
|
||||
STV6210_BAMP="16dB"
|
||||
|
||||
#
|
||||
# ttyUSB names
|
||||
#
|
||||
|
@ -54,12 +54,14 @@ fi
|
||||
ifconfig lo 127.0.0.1 netmask 255.255.255.0
|
||||
|
||||
# AXE modules and AXE hw initialization
|
||||
sync
|
||||
logger -p local0.notice "AXE drivers load start"
|
||||
axehelper i2c_reg_read 0xd0 0xf000 > /dev/null 2> /dev/null || logger -p local0.notice "I2C Demod #1(D0) failed"
|
||||
axehelper i2c_reg_read 0xd2 0xf000 > /dev/null 2> /dev/null || logger -p local0.notice "I2C Demod #2(D2) failed"
|
||||
d=/lib/modules/axe
|
||||
insmod $d/stapi_core_stripped.ko
|
||||
insmod $d/stapi_ioctl_stripped.ko
|
||||
insmod $d/axe_i2c.ko
|
||||
echo "i2c_dbg_trans 1" > /proc/bus/ivo_i2c
|
||||
insmod $d/i2c_mangle.ko
|
||||
insmod $d/axe_fe.ko
|
||||
insmod $d/axe_fp.ko
|
||||
insmod $d/axe_dmx.ko
|
||||
@ -102,11 +104,9 @@ for i in $(cat /proc/devices); do
|
||||
maj=
|
||||
done
|
||||
/etc/init.d/axe &
|
||||
axehelper wait 5000 -10 /tmp/axe-done
|
||||
axehelper wait 2000 -10
|
||||
#nc -l 127.0.0.1:1001 -e /bin/true
|
||||
nc -l 127.0.0.1:1001 -e /bin/true
|
||||
rm -f /root/main_init.sh /tmp/axe-done
|
||||
echo "i2c_dbg_trans 0" > /proc/bus/ivo_i2c
|
||||
logger -p local0.notice "AXE drivers load finish"
|
||||
|
||||
# hostname
|
||||
test -r /etc/sysconfig/config && . /etc/sysconfig/config
|
||||
|
@ -6,12 +6,16 @@ if test "$MINISATIP" != "yes"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
. /etc/init.d/axe-settings
|
||||
|
||||
# renice kernel demuxers
|
||||
if test "$DEMUXERS_RENICE" = "yes"; then
|
||||
a=""
|
||||
for i in $(ps -o pid,nice,comm | grep "kdmxts_64" | cut -d 'k' -f 1); do
|
||||
if test "$i" -gt 15; then a="$a $i"; fi
|
||||
done
|
||||
renice -15 $a
|
||||
fi
|
||||
|
||||
cd /tmp
|
||||
while test ! -f /tmp/nosatip; do
|
||||
@ -20,8 +24,8 @@ while test ! -f /tmp/nosatip; do
|
||||
done
|
||||
. /etc/sysconfig/config
|
||||
nice -5 minisatip -f -g $MINISATIP_OPTS
|
||||
logger "minisatip exited $?, restarting"
|
||||
done
|
||||
logger -p local0.notice "minisatip exited $?, restarting"
|
||||
if test -f /tmp/nosatip; then
|
||||
sleep 87323123
|
||||
fi
|
||||
done
|
||||
|
6
tools/.gitignore
vendored
6
tools/.gitignore
vendored
@ -1,6 +1,12 @@
|
||||
*.cmd
|
||||
axehelper
|
||||
axehelper.x86_64
|
||||
syscall-dump.o
|
||||
syscall-dump.o.x86_64
|
||||
syscall-dump.so
|
||||
syscall-dump.so.x86_64
|
||||
i2c_mangle.mod.*
|
||||
i2c_mangle.o
|
||||
i2c_mangle.ko
|
||||
Module.symvers
|
||||
modules.order
|
||||
|
7
tools/Makefile
Normal file
7
tools/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
obj-m=i2c_mangle.o
|
||||
|
||||
all:
|
||||
make -C $(PWD)/kernel ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD)/tools modules
|
||||
|
||||
clean:
|
||||
make -C $(PWD)/kernel ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD)/tools clean
|
187
tools/i2c_mangle.c
Normal file
187
tools/i2c_mangle.c
Normal file
@ -0,0 +1,187 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/hardirq.h>
|
||||
#include <linux/irqflags.h>
|
||||
#include <linux/rwsem.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
#define STV6120_1 (0xc0 >> 1)
|
||||
#define STV6120_2 (0xc6 >> 1)
|
||||
|
||||
extern int (*i2c_transfer_mangle)(struct i2c_adapter *adap, struct i2c_msg *msg, int num);
|
||||
int i2c_transfer2(struct i2c_adapter *adap, struct i2c_msg *msg, int num);
|
||||
|
||||
static struct i2c_adapter *i2c_adapter0;
|
||||
static int i2c_mangle_enable = 1;
|
||||
static int i2c_mangle_debug = 0;
|
||||
static int stv6120_gain = 8;
|
||||
|
||||
static void i2c_transfer_axe_dump(struct i2c_msg *msgs, int num)
|
||||
{
|
||||
int ret;
|
||||
|
||||
for (ret = 0; ret < num; ret++) {
|
||||
printk("i2c master_xfer[%d] %c, addr=0x%02x, "
|
||||
"len=%d%s, flags=0x%x\n", ret, (msgs[ret].flags & I2C_M_RD)
|
||||
? 'R' : 'W', msgs[ret].addr, msgs[ret].len,
|
||||
(msgs[ret].flags & I2C_M_RECV_LEN) ? "+" : "",
|
||||
msgs[ret].flags);
|
||||
}
|
||||
}
|
||||
|
||||
static void mangle(u8 *dst, struct i2c_msg *m, int i, int val, int shift, int mask)
|
||||
{
|
||||
memcpy(dst, m->buf, m->len);
|
||||
dst[i] &= ~(mask << shift);
|
||||
dst[i] |= (val & mask) << shift;
|
||||
if (i2c_mangle_debug & 2)
|
||||
printk("i2c mangle: i=%d val=0x%x shift=%i mask=0x%x (orig 0x%x new 0x%x)\n",
|
||||
i, val, shift, mask, m->buf[i], dst[i]);
|
||||
if (m->buf[i] != dst[i])
|
||||
m->buf = dst;
|
||||
}
|
||||
|
||||
static void i2c_transfer_axe_mangle(struct i2c_msg *msgs, int num)
|
||||
{
|
||||
static u8 mbuf[4][32];
|
||||
struct i2c_msg *m;
|
||||
int ret, r, i;
|
||||
|
||||
for (ret = 0; ret < num && ret < ARRAY_SIZE(mbuf); ret++) {
|
||||
m = msgs + ret;
|
||||
if (m->len < 1 || (m->flags & I2C_M_RD) != 0)
|
||||
continue;
|
||||
if (m->addr == STV6120_1 || m->addr == STV6120_2)
|
||||
for (r = m->buf[0], i = 1; i < m->len; i++, r++)
|
||||
if (r == 0x01 || r == 0x0b)
|
||||
mangle(mbuf[ret], m, i, stv6120_gain, 0, 0x0f);
|
||||
}
|
||||
}
|
||||
|
||||
static int i2c_transfer_axe(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
|
||||
{
|
||||
if (adap == i2c_adapter0) {
|
||||
if (i2c_mangle_debug & 1)
|
||||
i2c_transfer_axe_dump(msgs, num);
|
||||
if (i2c_mangle_enable)
|
||||
i2c_transfer_axe_mangle(msgs, num);
|
||||
}
|
||||
return i2c_transfer2(adap, msgs, num);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
static ssize_t i2c_mangle_enable_show
|
||||
(struct device *dev, struct device_attribute *attr, char *page)
|
||||
{
|
||||
return sprintf(page, "%u\n", i2c_mangle_enable);
|
||||
}
|
||||
|
||||
static ssize_t i2c_mangle_enable_store
|
||||
(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
int val = 0;
|
||||
if (sscanf(buf, "%u", &val) != 1)
|
||||
return -EINVAL;
|
||||
i2c_mangle_enable = val;
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(i2c_mangle_enable, 0644,
|
||||
i2c_mangle_enable_show,
|
||||
i2c_mangle_enable_store);
|
||||
|
||||
static ssize_t i2c_mangle_debug_show
|
||||
(struct device *dev, struct device_attribute *attr, char *page)
|
||||
{
|
||||
return sprintf(page, "%u\n", i2c_mangle_debug);
|
||||
}
|
||||
|
||||
static ssize_t i2c_mangle_debug_store
|
||||
(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
int val = 0;
|
||||
if (sscanf(buf, "%u", &val) != 1)
|
||||
return -EINVAL;
|
||||
i2c_mangle_debug = val;
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(i2c_mangle_debug, 0644,
|
||||
i2c_mangle_debug_show,
|
||||
i2c_mangle_debug_store);
|
||||
|
||||
static ssize_t stv6120_gain_show
|
||||
(struct device *dev, struct device_attribute *attr, char *page)
|
||||
{
|
||||
return sprintf(page, "%u\n", stv6120_gain);
|
||||
}
|
||||
|
||||
static ssize_t stv6120_gain_store
|
||||
(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
int val = 0;
|
||||
if (sscanf(buf, "%u", &val) != 1)
|
||||
return -EINVAL;
|
||||
stv6120_gain = val;
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(stv6120_gain, 0644,
|
||||
stv6120_gain_show,
|
||||
stv6120_gain_store);
|
||||
|
||||
static void sysfs_create_entries(void)
|
||||
{
|
||||
struct kobject *kobj = &i2c_adapter0->dev.kobj;
|
||||
|
||||
sysfs_create_file(kobj, &dev_attr_i2c_mangle_enable.attr);
|
||||
sysfs_create_file(kobj, &dev_attr_i2c_mangle_debug.attr);
|
||||
sysfs_create_file(kobj, &dev_attr_stv6120_gain.attr);
|
||||
}
|
||||
|
||||
static void sysfs_remove_entries(void)
|
||||
{
|
||||
struct kobject *kobj = &i2c_adapter0->dev.kobj;
|
||||
|
||||
sysfs_remove_file(kobj, &dev_attr_i2c_mangle_enable.attr);
|
||||
sysfs_remove_file(kobj, &dev_attr_i2c_mangle_debug.attr);
|
||||
sysfs_remove_file(kobj, &dev_attr_stv6120_gain.attr);
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
||||
int init_module(void)
|
||||
{
|
||||
i2c_adapter0 = i2c_get_adapter(0);
|
||||
if (i2c_adapter0 == NULL) {
|
||||
printk(KERN_ERR "i2c_mangle: unable to find adapter 0\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
sysfs_create_entries();
|
||||
i2c_transfer_mangle = i2c_transfer_axe;
|
||||
printk(KERN_INFO "I2C-Bus AXE mangle module loaded\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cleanup_module(void)
|
||||
{
|
||||
sysfs_remove_entries();
|
||||
i2c_transfer_mangle = NULL;
|
||||
i2c_put_adapter(i2c_adapter0);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Jaroslav Kysela");
|
||||
MODULE_DESCRIPTION("I2C-Bus AXE mangle module");
|
||||
MODULE_LICENSE("GPL");
|
Loading…
Reference in New Issue
Block a user