Re: [RFC 1/2] usb: gadget: zero: Add support for interrupt EP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Andrezej,

On 2/10/2014 7:15 PM, Andrzej Pietrasiewicz wrote:
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.


Thanks for the enlightenment. I'll implement parameter passing through configfs.

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

Signed-off-by: Amit Virdi <amit.virdi@xxxxxx>

<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,
};


Ok, I got it.

I'll incorporate your comments and send V1 in sometime.

Regards
Amit Virdi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux