Android [USB]如何同时打开UMS和BICR(CD-ROM)

前言
         欢迎大家我分享和推荐好用的代码段~~
声明
         欢迎转载,但请保留文章原始出处:
         CSDN
http://www.csdn.net
         雨季o莫忧离:http://blog.csdn.net/luckkof

正文

 

手机连接电脑时,能同时看到内卡,外卡和虚拟光驱盘符

1.      LUN改成3個,並且最後一個定義為CDROM

kernel\drivers\usb\gadget\android.c

 

static int mass_storage_function_init(struct android_usb_function *f,

                                        struct usb_composite_dev *cdev)

{

        struct mass_storage_function_config *config;

        struct fsg_common *common;

        int err;

        int i;

 

        config = kzalloc(sizeof(struct mass_storage_function_config),

                                                                GFP_KERNEL);

        if (!config)

                return -ENOMEM;

 

#ifdef MTK_MULTI_STORAGE_SUPPORT

#ifdef MTK_SHARED_SDCARD

#define NLUN_STORAGE 1

#else

#define NLUN_STORAGE 2

#endif

#else

#define NLUN_STORAGE 1

#endif

 

#define NLUN_STORAGE 3    //add 1/3

 

        config->fsg.nluns = NLUN_STORAGE;

 

        for(i = 0; i < config->fsg.nluns; i++) {

                config->fsg.luns[i].removable = 1;

                config->fsg.luns[i].nofua = 1;

        }

 

        config->fsg.luns[NLUN_STORAGE-1].cdrom = 1;  //add 2/3

 

        common = fsg_common_init(NULL, cdev, &config->fsg);

        if (IS_ERR(common)) {

                kfree(config);

                return PTR_ERR(common);

        }

 

        err = sysfs_create_link(&f->dev->kobj,

                                &common->luns[0].dev.kobj,

                                "lun");

 

        if (err) {

                kfree(config);

                return err;

        }

 

        /*

        * "i" starts from "1", cuz dont want to change the naming of

        * the original path of "lun0".

        */

        for(i = 1; i < config->fsg.nluns; i++) {

                char string_lun[5]={0};

 

                sprintf(string_lun, "lun%d",i);

 

                err = sysfs_create_link(&f->dev->kobj,

                                &common->luns[i].dev.kobj,

                                string_lun);

                if (err) {

                        kfree(config);

                        return err;

                }

        }

 

        common->android_callback = &mass_storage_callback;

 

        config->common = common;

        f->config = config;

        return 0;

}

2.      loop0一開機就寫入lun2/file裡,讓PC可以看到CD-ROM內容。

 

mediatek\config\mt6589\init.usb.rc

 

on init

# Workarunod for USB unknow device issue

# USB would switch correct function when set properity sys.usb.config

    setprop sys.usb.vid 0BB4

    write /sys/class/android_usb/android0/iSerial $ro.serialno

    write /sys/class/android_usb/android0/idVendor $sys.usb.vid

 

on post-fs-data

    chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file

    chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file

    chown system system /sys/class/android_usb/android0/f_rndis/ethaddr

    chmod 0660 /sys/class/android_usb/android0/f_rndis/ethaddr

 

    write /sys/class/android_usb/android0/f_rndis/wceis 1

    write /sys/class/android_usb/android0/f_rndis/manufacturer MediaTek   

    write /sys/class/android_usb/android0/f_rndis/vendorID $sys.usb.vid

    write /sys/class/android_usb/android0/f_mass_storage/lun2/file "/dev/block/loop0" 

#add 3/3

 

3.      BICRUI不顯示。

 

mediatek\config\[PROJECT]\system.prop

 

ro.sys.usb.bicr=no


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。