Commit 1bdd49f8 authored by Federico Vaga's avatar Federico Vaga

zio_channel: added the current control for each channel

The current control used to be per-trigger (i.e., per-cset).
However, some parameters are per-channel (like the gain),
so each channel now has its own current control structure.

Also, zio-dump now shows device and trigger attributes, both standard
and
extended ones.
Signed-off-by: 's avatarFederico Vaga <federico.vaga@gmail.com>
Acked-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent ca2cda56
......@@ -33,14 +33,12 @@ struct zio_ti {
unsigned long flags; /* input or output, etc */
struct spinlock lock;
struct zio_control *current_ctrl; /* the active one */
/* This is for software stamping */
struct timespec tstamp;
uint64_t tstamp_extra;
/* Standard and extended attributes for this object */
struct zio_attribute_set zattr_set;
struct zio_ctrl_attr zattr_val;
const struct zio_trigger_operations *t_op;
};
......
......@@ -158,7 +158,6 @@ struct zio_channel {
unsigned int index; /* index within parent */
unsigned long flags;
struct zio_attribute_set zattr_set;
struct zio_ctrl_attr zattr_val;
struct device *ctrl_dev; /* control char device */
struct device *data_dev; /* data char device */
......@@ -166,6 +165,7 @@ struct zio_channel {
void *priv_d; /* private for the device */
void *priv_t; /* private for the trigger */
struct zio_control *current_ctrl; /* the active one */
struct zio_block *user_block; /* being transferred w/ user */
struct zio_block *active_block; /* being managed by hardware */
};
......
......@@ -35,7 +35,7 @@ void read_channel(int cfd, int dfd, FILE *log)
prgname);
exit(1);
default:
fprintf(stderr, "%s: ctrl read: %i bytes (expected %i)\n",
fprintf(stderr, "%s: ctrl read: %i bytes (expected %li)\n",
prgname, i, sizeof(ctrl));
/* continue anyways */
case sizeof(ctrl):
......@@ -82,6 +82,39 @@ void read_channel(int cfd, int dfd, FILE *log)
(long long)ctrl.tstamp.secs,
(long long)ctrl.tstamp.ticks,
(long long)ctrl.tstamp.bins);
/* Print attributes */
printf("Device attributes:\n");
printf(" Standard: 0x%04x\n ",
ctrl.attr_channel.std_mask);
for (i = 0; i < 16; ++i) {
if (i == 8)
printf("\n ");
printf ("0x%x ", ctrl.attr_channel.std_val[i]);
}
printf("\n Extened: 0x%08x\n ",
ctrl.attr_channel.ext_mask);
for (i = 0; i < 32; ++i) {
if (i == 8 || i == 16 || i == 24)
printf("\n ");
printf ("0x%x ", ctrl.attr_channel.ext_val[i]);
}
printf("\nTrigger attributes:\n");
printf(" Standard: 0x%04x\n ",
ctrl.attr_trigger.std_mask);
for (i = 0; i < 16; ++i) {
if (i == 8)
printf("\n ");
printf ("0x%x ", ctrl.attr_trigger.std_val[i]);
}
printf("\n Extened: 0x%08x \n ",
ctrl.attr_trigger.ext_mask);
for (i = 0; i < 32; ++i) {
if (i == 8 || i == 16 || i == 24)
printf("\n ");
printf ("0x%x ", ctrl.attr_trigger.ext_val[i]);
}
printf("\n");
/* FIXME: some control information is missing */
i = read(dfd, buf, sizeof(buf));
......
......@@ -40,19 +40,9 @@ static struct zio_attribute zti_ext_attr[] = {
static int zti_conf_set(struct kobject *kobj, struct zio_attribute *zattr,
uint32_t usr_val)
{
struct zio_ti *ti = to_zio_ti(kobj);
pr_debug("%s:%d\n", __func__, __LINE__);
zattr->value = usr_val;
switch (zattr->priv.addr) {
case ZTI_ATTR_NSAMPLES:
ti->current_ctrl->nsamples = usr_val;
break;
/* other attributes are read-only */
default:
pr_err("%s: unknown \"addr\" for configuration\n", __func__);
return -EINVAL;
}
return 0;
}
......@@ -106,10 +96,6 @@ static struct zio_ti *zti_create(struct zio_trigger_type *trig,
if (!ti)
return ERR_PTR(-ENOMEM);
/* The current control is already filled: just set nsamples */
ctrl->nsamples = zti_std_attr[ZATTR_TRIG_NSAMPLES].value;
ti->current_ctrl = ctrl;
ret = request_irq(zti_irq, zti_handler, IRQF_SHARED
| IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
KBUILD_MODNAME, ti);
......
......@@ -50,13 +50,13 @@ static int ztt_conf_set(struct kobject *kobj, struct zio_attribute *zattr,
pr_debug("%s:%d\n", __func__, __LINE__);
zattr->value = usr_val;
switch (zattr->priv.addr) {
case ZTT_ATTR_NSAMPLES:
ti->current_ctrl->nsamples = usr_val;
break;
case ZTT_ATTR_PERIOD:
ztt = to_ztt_instance(ti);
ztt->period = msecs_to_jiffies(usr_val);
break;
case ZTT_ATTR_NSAMPLES:
/* Nothing to do */
break;
default:
pr_err("%s: unknown \"addr\" 0x%lx for configuration\n",
__func__, zattr->priv.addr);
......@@ -131,10 +131,6 @@ static struct zio_ti *ztt_create(struct zio_trigger_type *trig,
return ERR_PTR(-ENOMEM);
ti = &ztt_instance->ti;
/* The current control is already filled: just set nsamples */
ctrl->nsamples = ztt_std_attr[ZATTR_TRIG_NSAMPLES].value;
ti->current_ctrl = ctrl;
/* Fill own fields */
setup_timer(&ztt_instance->timer, ztt_fn,
(unsigned long)(&ztt_instance->ti));
......
......@@ -27,11 +27,8 @@ static DEFINE_ZATTR_STD(TRIG, ztu_std_attr) = {
int ztu_conf_set(struct kobject *kobj, struct zio_attribute *zattr,
uint32_t usr_val)
{
struct zio_ti *ti = to_zio_ti(kobj);
pr_debug("%s:%d\n", __func__, __LINE__);
zattr->value = usr_val;
ti->current_ctrl->nsamples = usr_val; /* We have this one only */
return 0;
}
......@@ -65,7 +62,6 @@ static int ztu_config(struct zio_ti *ti, struct zio_control *ctrl)
{
pr_debug("%s:%d\n", __func__, __LINE__);
ti->current_ctrl->nsamples = ctrl->nsamples;
return 0;
}
......@@ -80,9 +76,6 @@ static struct zio_ti *ztu_create(struct zio_trigger_type *trig,
ti = kzalloc(sizeof(*ti), GFP_KERNEL);
if (!ti)
return ERR_PTR(-ENOMEM);
/* The current control is already filled: just set nsamples */
ctrl->nsamples = ztu_std_attr[ZATTR_TRIG_NSAMPLES].value;
ti->current_ctrl = ctrl;
return ti;
}
......
......@@ -338,7 +338,7 @@ static struct zio_block *__zio_write_allocblock(struct zio_bi *bi,
ctrl = zio_alloc_control(GFP_KERNEL);
if (!ctrl)
return NULL;
memcpy(ctrl, bi->cset->ti->current_ctrl, ZIO_CONTROL_SIZE);
memcpy(ctrl, bi->chan->current_ctrl, ZIO_CONTROL_SIZE);
}
datalen = ctrl->ssize * ctrl->nsamples;
block = bi->b_op->alloc_block(bi, ctrl, datalen, GFP_KERNEL);
......@@ -482,7 +482,7 @@ static ssize_t zio_generic_write(struct file *f, const char __user *ubuf,
if (copy_from_user(ctrl, ubuf, count))
return -EFAULT;
memcpy(bi->cset->ti->current_ctrl, ctrl, count);
memcpy(chan->current_ctrl, ctrl, count);
*offp += count;
return count;
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment