W dniu 10.02.2014 14:16, Amit Virdi pisze:
Interrupt endpoints behave quite similar to the bulk endpoints with the
difference that the endpoints expect data sending/reception request at
particular intervals till the whole data has not been transmitted.

The interrupt EP support is added to gadget zero. A new alternate setting (=2)
has been added. It has 6 endpoints (2-BULK, 2-ISOC, 2-INTERRUPT). The default
parameters are set as:
        bInterval: 4
        wMaxPacketSize: 1024
However, the same can be overridden through the module parameter interface.


The module parameter interface is available only in legacy mode,
that is using g_zero.ko. Both sourcesink and loopback now support
configfs.

The code is tested for HS and SS on a platform having DWC3 controller.

Signed-off-by: Amit Virdi <[email protected]>

<snip>

+static unsigned int_interval;
+static unsigned int_maxpacket;
+static unsigned int_mult;
+static unsigned int_maxburst;

For these you need appropriate configfs attributes (files).

Below there is a typical way to create the attributes.

/*
 * "show" means to copy data from kernel to user;
 * you get the opts pointer and copy the relevant data to the page
 */
static ssize_t f_ss_opts_pattern_show(struct f_ss_opts *opts, char *page)
{
        int result;

        mutex_lock(&opts->lock);
        result = sprintf(page, "%d", opts->pattern);
        mutex_unlock(&opts->lock);

        return result;
}

/*
 * "store" means to copy data from user to the kernel;
 * you take data from the page and interpret it;
 * if it is ok, you store it in the opts
 */
static ssize_t f_ss_opts_pattern_store(struct f_ss_opts *opts,
                                       const char *page, size_t len)
{
        int ret;
        u8 num;

        mutex_lock(&opts->lock);
        if (opts->refcnt) {
                ret = -EBUSY;
                goto end;
        }

        ret = kstrtou8(page, 0, &num);
        if (ret)
                goto end;

        if (num != 0 && num != 1 && num != 2) {
                ret = -EINVAL;
                goto end;
        }

        opts->pattern = num;
        ret = len;
end:
        mutex_unlock(&opts->lock);
        return ret;
}

static struct f_ss_opts_attribute f_ss_opts_pattern =
        __CONFIGFS_ATTR(pattern, S_IRUGO | S_IWUSR,
                        f_ss_opts_pattern_show,
                        f_ss_opts_pattern_store);

/*
 * definitions of f_ss_opts_isoc_interval & co follow
 */

...


/*
 * hereyou should create your implementations of
 * f_ss_opts_int_interval_show/store & co
 */

/*
 *and then attach the attributes to the config item;
 * which translates to making new files appear in their
 * directory
 */
static struct configfs_attribute *ss_attrs[] = {
        &f_ss_opts_pattern.attr,
        &f_ss_opts_isoc_interval.attr,
        &f_ss_opts_isoc_maxpacket.attr,
        &f_ss_opts_isoc_mult.attr,
        &f_ss_opts_isoc_maxburst.attr,
        &f_ss_opts_bulk_buflen.attr,

        /* HERE */
        &f_ss_opts_isoc_interval.attr,

        NULL,
};

AP
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to