Android 添加3G dongle 支持----内核篇

1. 编译配置

       3G Dongle 是USB设备, 免驱动, 方便使用。 但事实上并不是真的不需要驱动, 只不过是因为USB接口, 基本上所有的设备都支持USB所以通用性更强而已;无论如何 Modem 部分是使用串行协议的, 所以需要USB转串口的支持。 3G 上网还需要ppp拨号才可以, 所以总体内核中需要配置如下功能:

      Device Drivers  --->
    <*> OHCI HCD support 
    [*] Network device support  --->
         <*>   PPP (point-to-point protocol) support
         [*]     PPP multilink support (EXPERIMENTAL)
         [*]     PPP filtering
         <*>     PPP support for async serial ports
         <*>     PPP support for sync tty ports
         <*>     PPP Deflate compression
         <*>     PPP BSD-Compress compression
         <*>     PPP MPPE compression (encryption) (EXPERIMENTAL)
         <*>     PPP over Ethernet (EXPERIMENTAL)
         <*>     PPP over L2TP (EXPERIMENTAL)
    [*] USB support  --->
         <*>   USB Serial Converter support  --->
               <*>   USB driver for GSM and CDMA modems


2.  如何添加一款新型号 3G Dongle 设备

        添加一款对新型号设备的支持, 需要modem驱动中配置相关设备信息,Linux kernel中modem驱动文件 drivers/usb/serial/option.c。例如, 添加华为 E143D, 修改内容如下:

(1) 添加厂商id, E1261产品id  

       #define    HUAWEI_VENDOR_ID      0x12d1             // 华为公司的Vendor id 为 0x12d1,  VID = 0x12d1

       #define    HUAWEI_PRODUCT_E143D      0x143d             // 产品id,    PID = 0x143d

(2) 把VID, PID 添加到列表

static  struct  usb_device_id  option_ids[] = {

...

{ USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143D, 0xff, 0xff, 0xff) },

...

};


其中使用到的 USB 相关的宏定义如下:

/***
0666  * USB_DEVICE - macro used to describe a specific usb device
0667  * @vend: the 16 bit USB Vendor ID
0668  * @prod: the 16 bit USB Product ID
0669  *
0670  * This macro is used to create a struct usb_device_id that matches a
0671  * specific device.
0672  */
0673 #define USB_DEVICE(vend, prod) \
0674     .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
0675     .idVendor = (vend), \
0676     .idProduct = (prod)


/***
0741  * USB_DEVICE_AND_INTERFACE_INFO - describe a specific usb device with a class of usb interfaces
0742  * @vend: the 16 bit USB Vendor ID
0743  * @prod: the 16 bit USB Product ID
0744  * @cl: bInterfaceClass value
0745  * @sc: bInterfaceSubClass value
0746  * @pr: bInterfaceProtocol value
0747  *
0748  * This macro is used to create a struct usb_device_id that matches a
0749  * specific device with a specific class of interfaces.
0750  *
0751  * This is especially useful when explicitly matching devices that have
0752  * vendor specific bDeviceClass values, but standards-compliant interfaces.
0753  */
0754 #define USB_DEVICE_AND_INTERFACE_INFO(vend, prod, cl, sc, pr) \
0755     .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
0756         | USB_DEVICE_ID_MATCH_DEVICE, \
0757     .idVendor = (vend), \
0758     .idProduct = (prod), \
0759     .bInterfaceClass = (cl), \
0760     .bInterfaceSubClass = (sc), \
0761     .bInterfaceProtocol = (pr)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值