summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfxstest.c23
-rwxr-xr-xwcfxs.c13
-rwxr-xr-xwcfxs.h11
-rwxr-xr-xwctdm.c13
-rwxr-xr-xwctdm.h11
5 files changed, 67 insertions, 4 deletions
diff --git a/fxstest.c b/fxstest.c
index 13bb24a..df7a80c 100755
--- a/fxstest.c
+++ b/fxstest.c
@@ -84,6 +84,29 @@ int main(int argc, char *argv[])
}
printf("\n\n");
}
+ } else if (!strcasecmp(argv[2], "setdirect") ||
+ !strcasecmp(argv[2], "setindirect")) {
+ struct wcfxs_regop regop;
+ int val;
+ int reg;
+ if ((argc < 5) || (sscanf(argv[3], "%i", &reg) != 1) ||
+ (sscanf(argv[4], "%i", &val) != 1)) {
+ fprintf(stderr, "Need a register and value...\n");
+ } else {
+ regop.reg = reg;
+ regop.val = val;
+ if (!strcasecmp(argv[2], "setindirect")) {
+ regop.indirect = 1;
+ regop.val &= 0xff;
+ } else {
+ regop.indirect = 0;
+ }
+ res = ioctl(fd, WCFXS_SET_REG, &regop);
+ if (res)
+ fprintf(stderr, "Unable to get registers on channel %s\n", argv[1]);
+ else
+ printf("Success.\n");
+ }
} else
fprintf(stderr, "Invalid command\n");
close(fd);
diff --git a/wcfxs.c b/wcfxs.c
index 8df338a..c54d9d3 100755
--- a/wcfxs.c
+++ b/wcfxs.c
@@ -843,6 +843,7 @@ static int wcfxs_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
{
struct wcfxs_stats stats;
struct wcfxs_regs regs;
+ struct wcfxs_regop regop;
struct wcfxs *wc = chan->pvt;
int x;
switch (cmd) {
@@ -861,6 +862,18 @@ static int wcfxs_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
if (copy_to_user((struct wcfxs_regs *)data, &regs, sizeof(regs)))
return -EFAULT;
break;
+ case WCFXS_SET_REG:
+ if (copy_from_user(&regop, (struct wcfxs_regop *)data, sizeof(regop)))
+ return -EFAULT;
+ if (regop.indirect) {
+ printk("Setting indirect %d to 0x%04x on %d\n", regop.reg, regop.val, chan->chanpos);
+ wcfxs_setreg_indirect(wc, chan->chanpos - 1, regop.reg, regop.val);
+ } else {
+ regop.val &= 0xff;
+ printk("Setting direct %d to %04x on %d\n", regop.reg, regop.val, chan->chanpos);
+ wcfxs_setreg(wc, chan->chanpos - 1, regop.reg, regop.val);
+ }
+ break;
default:
return -ENOTTY;
}
diff --git a/wcfxs.h b/wcfxs.h
index 8fd6d6e..19ed059 100755
--- a/wcfxs.h
+++ b/wcfxs.h
@@ -39,6 +39,13 @@ struct wcfxs_regs {
unsigned short indirect[NUM_INDIRECT_REGS];
};
-#define WCFXS_GET_STATS _IOW (ZT_CODE, 60, struct wcfxs_stats)
-#define WCFXS_GET_REGS _IOW (ZT_CODE, 60, struct wcfxs_regs)
+struct wcfxs_regop {
+ int indirect;
+ unsigned char reg;
+ unsigned short val;
+};
+
+#define WCFXS_GET_STATS _IOR (ZT_CODE, 60, struct wcfxs_stats)
+#define WCFXS_GET_REGS _IOR (ZT_CODE, 61, struct wcfxs_regs)
+#define WCFXS_SET_REG _IOW (ZT_CODE, 62, struct wcfxs_regop)
diff --git a/wctdm.c b/wctdm.c
index 8df338a..c54d9d3 100755
--- a/wctdm.c
+++ b/wctdm.c
@@ -843,6 +843,7 @@ static int wcfxs_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
{
struct wcfxs_stats stats;
struct wcfxs_regs regs;
+ struct wcfxs_regop regop;
struct wcfxs *wc = chan->pvt;
int x;
switch (cmd) {
@@ -861,6 +862,18 @@ static int wcfxs_ioctl(struct zt_chan *chan, unsigned int cmd, unsigned long dat
if (copy_to_user((struct wcfxs_regs *)data, &regs, sizeof(regs)))
return -EFAULT;
break;
+ case WCFXS_SET_REG:
+ if (copy_from_user(&regop, (struct wcfxs_regop *)data, sizeof(regop)))
+ return -EFAULT;
+ if (regop.indirect) {
+ printk("Setting indirect %d to 0x%04x on %d\n", regop.reg, regop.val, chan->chanpos);
+ wcfxs_setreg_indirect(wc, chan->chanpos - 1, regop.reg, regop.val);
+ } else {
+ regop.val &= 0xff;
+ printk("Setting direct %d to %04x on %d\n", regop.reg, regop.val, chan->chanpos);
+ wcfxs_setreg(wc, chan->chanpos - 1, regop.reg, regop.val);
+ }
+ break;
default:
return -ENOTTY;
}
diff --git a/wctdm.h b/wctdm.h
index 8fd6d6e..19ed059 100755
--- a/wctdm.h
+++ b/wctdm.h
@@ -39,6 +39,13 @@ struct wcfxs_regs {
unsigned short indirect[NUM_INDIRECT_REGS];
};
-#define WCFXS_GET_STATS _IOW (ZT_CODE, 60, struct wcfxs_stats)
-#define WCFXS_GET_REGS _IOW (ZT_CODE, 60, struct wcfxs_regs)
+struct wcfxs_regop {
+ int indirect;
+ unsigned char reg;
+ unsigned short val;
+};
+
+#define WCFXS_GET_STATS _IOR (ZT_CODE, 60, struct wcfxs_stats)
+#define WCFXS_GET_REGS _IOR (ZT_CODE, 61, struct wcfxs_regs)
+#define WCFXS_SET_REG _IOW (ZT_CODE, 62, struct wcfxs_regop)