实现在gadget中添加一个新的in端点进行数据传输

主要是这个函数,函数的说明

/**
 * usb_ep_autoconfig - choose an endpoint matching the descriptor
 * @gadget: The device to which the endpoint must belong.
 * @desc: Endpoint descriptor, with endpoint direction and transfer mode
 *    initialized.  For periodic transfers, the maximum packet
 *    size must also be initialized.  This is modified on success.
 *
 * By choosing an endpoint to use with the specified descriptor, this
 * routine simplifies writing gadget drivers that work with multiple
 * USB device controllers.  The endpoint would be passed later to
 * usb_ep_enable(), along with some descriptor.
 *
 * That second descriptor won't always be the same as the first one.
 * For example, isochronous endpoints can be autoconfigured for high
 * bandwidth, and then used in several lower bandwidth altsettings.
 * Also, high and full speed descriptors will be different.
 *
 * Be sure to examine and test the results of autoconfiguration on your
 * hardware.  This code may not make the best choices about how to use the
 * USB controller, and it can't know all the restrictions that may apply.
 * Some combinations of driver and hardware won't be able to autoconfigure.
 *
 * On success, this returns an un-claimed usb_ep, and modifies the endpoint
 * descriptor bEndpointAddress.  For bulk endpoints, the wMaxPacket value
 * is initialized as if the endpoint were used at full speed.  To prevent
 * the endpoint from being returned by a later autoconfig call, claim it
 * by assigning ep->driver_data to some non-null value.
 *
 * On failure, this returns a null endpoint descriptor.
 */

0、在f_sourcesink结构体里加上新的端点指针,与新的请求指针

struct usb_ep        *in_ep1;
struct usb_request *in_req1;

1、定义端点描述符

static struct usb_endpoint_descriptor fs_source_desc1 = {
    .bLength =        USB_DT_ENDPOINT_SIZE,
    .bDescriptorType =    USB_DT_ENDPOINT,

.bEndpointAddress =    0x83,
    .bmAttributes =        USB_ENDPOINT_XFER_BULK,
};

2、配置的描述符

static struct usb_descriptor_header *fs_source_sink_descs[] = {
    (struct usb_descriptor_header *) &source_sink_intf,
    (struct usb_descriptor_header *) &fs_source_desc,
    (struct usb_descriptor_header *) &fs_source_desc1,
    (struct usb_descriptor_header *) &fs_sink_desc,
    NULL,
};

3、将端点的描述符fs_source_desc1与定义的端点匹配

in_ep1是增加的端点

ss->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc);
    ss->in_ep1 = usb_ep_autoconfig(cdev->gadget, &fs_source_desc1);/

4、给端点分配请求

ss->in_req = alloc_ep_req(ss->in_ep, TX_REQ_LEN);
    if(ss->in_req == NULL){
        DBG_PRT("Alloc_ep_req for write in failed.\n");
        return -EFAULT;
    }
    ss->in_req->complete = source_sink_complete;

ss->in_req1 = alloc_ep_req(ss->in_ep1, TX_REQ_LEN);
    if(ss->in_req1 == NULL){
        DBG_PRT("Alloc_ep_req for write in failed.\n");
        return -EFAULT;
    }
    ss->in_req1->complete = source_sink_complete;

5、在写函数中将原端点未写完的数据通过新端点写

ret = usb_ep_queue(ss->in_ep1, ss->in_req1, GFP_ATOMIC);

gadget usb 增加端点相关推荐

  1. stm32 USB增加端点总结

    stm32 USB增加端点总结(端点用法) 在原有的端点1和端点2基础上增加一个双向端点3. 由于EP3端点缓冲区只有512-32-64*7=32字节大小,所以发送长度不能大于32,否则多余的数据会丢 ...

  2. USB的端点描述符详解-重新排版

    USB的端点描述符详解 端点描述符,是描述USB通信通道或管道的类型和功能的标准USB描述符. 端点描述符和接口描述符还有配置描述符一样,不能单独发送给USB主机,需要以配置描述符集合的形式发送给主机 ...

  3. Linux那些事儿 之 戏说USB(14)端点

    端点是USB数据传输的终点.看看它在内核里的定义 include/linux/usb.h struct usb_host_endpoint {struct usb_endpoint_descripto ...

  4. USB的端点与管道以及设备、配置、接口、端点

    1.端点的引入 2.端点与管道 3.特殊端点 4.USB端点的四种类型 5.USB逻辑设备 6.设备.配置.接口.端点 7.

  5. USB总线-Linux内核USB3.0设备控制器之dwc3 gadget驱动初始化过程分析(五)

    1.概述 USB设备控制器(UDC)驱动的框图如下图所示,由三部分组成.第一部分是UDC驱动核心层,在drivers/usb/gadget/udc/core.c文件中实现,该层是一个兼容层,将USB ...

  6. USB gadget设备驱动解析

    利用Linux USB gadget设备驱动可以实现一些比较有意思的功能,举两个例子: 1.一个嵌入式产品中的某个存储设备,或是一个存储设备的某个分区,可以作为一个U盘被PC:设别,从而非常方便的完成 ...

  7. USB gadget(1)----controller driver

    USB gadget usb device driver 分为三部分, usb controller driver, gadget driver 和function driver. gadget dr ...

  8. linux usb gadget驱动详解(二)

    在上篇<linux usb gadget驱动详解(一)>中,我们了解到gadget的测试方法,但在最后,我们留下一个问题,就是怎样使用新的方法进行usb gadget驱动测试. 我们发现l ...

  9. 【随笔记】linux usb gadget ncm wrong ndp sign 问题修复

    一.模拟网卡简介 在 Linux 通过 usb 模拟网卡时,有四种方式: 1. 使用 usb gadget rndis 2. 使用 usb gadget ecm 3. 使用 usb gadget nc ...

最新文章

  1. linux vim 基本操作
  2. 大利好!学历低的算法工程师要起飞了,这波惊喜来的太突然!
  3. Java三大主流开源工作流引擎技术分析
  4. 达内出来的混得怎么样了_《士兵突击》主演现状:混得最好的不是王宝强,而是一向低调的他...
  5. 选择判断语句(switch)
  6. 一个报文的路由器之旅_【NE探秘】一个报文的路由器之旅
  7. Excel制作随机抽取名单
  8. 小程序开发 缓存的应用
  9. Android第四十五天
  10. er图 navicat_navicat怎么生成er图
  11. 计划任务执行 php代码,php实现Windows任务计划定时执行的代码以及扩展(图)
  12. centos 卸载 jdk
  13. FMEA软件七步法(FMEAHunter)
  14. Da黄蜂vep云课堂6.05录屏截屏提取为mp4教程
  15. dtft频移性质_08 DTFT变换的性质
  16. linux下xampp的使用教程,Linux下安装xampp教程
  17. 外卖行业现状分析_餐饮外卖行业现状 传统餐饮业的痛点分析
  18. node.js中express框架的使用
  19. 关于宏基暗影骑士擎笔记本如何关闭触摸板的问题记录
  20. 算法设计与分析第三章作业

热门文章

  1. 编译原理:句子、句型和语言的概念区分
  2. Conda环境搭建以及激活
  3. 栈空间内存和堆空间内存
  4. 信息与计算机教案,信息与信息技术教案
  5. 网人笔记_拔剑-浆糊的传说_新浪博客
  6. Java工作小组组名,小组口号-小组队名和口号-口号
  7. Ubuntu上python打包为可执行文件方法
  8. EXCEL 加减乘除
  9. HCIP理论笔记整理
  10. eclipse不用方向键移动光标