• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[webcam support] USB Host support that YOU can try (now in nightlies)

Search This thread

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
Ok, I guess I'll do some sort of a progress update on the usb audio since so many people are interested.

To use the files referenced here you need to install nightly -100 or later! If you use anything earlier than that version there is a bug in generic framework code that would prevent any audio input from working!

You will need this kernel image: http://nook.handhelds.ru/usbaudio/uImage
that you will need to use as the kernel.
The kernel change is only to allow skype not to enter dead loop when it tries to open a microphone and cannot (when you do not have a usb headset connected).
Unfortunately as soon as the internal mic input is opened, the audio out is also muted so I only include this for convenience of testing. (naturally don't take any of this as an indication that there is internal microphone input or anything.
On the other hand this kernel also includes some groundwork to enable FM radio support (assuming it was properly wired, in the past all attempts failed because these bits were missing)).

The other important bit is the alsa.omap3.so: http://nook.handhelds.ru/usbaudio/alsa.omap3.so
Drop it to /system/lib/hw/ (this on sdcard this is partition2, /lib/hw)

once the files are in place, reboot, connect the audio device, enable usbhost (or the other way around).
The skype will now work. The sound is a bit distorted/sped up due to lack of rate conversion I guess.
My usb headset is limited to 44.1kHz rate where as voice in is usually requested at 8k.
the library I supply hardcodes the rate at 44.1kHz anyway.

I suspect that the microphone only devices (like what is commonly found on web cameras) should also work with sound going to internal speaker.

While you are at it, also please try to see if your audio device supports any other rates than mine. If it will turn out there are many 8k-supporting devices, I can try to add support for it I guess:
Code:
# cat /proc/asound/card1/stream0 
C-Media USB Headphone Set   at usb-musb_hdrc-1.4, full speed : USB Audio

Playback:
  Status: Stop
  Interface 1
    Altset 1
    Format: S16_LE
    Channels: 2
    Endpoint: 1 OUT (ADAPTIVE)
    Rates: 48000, 44100

Capture:
  Status: Stop
  Interface 2
    Altset 1
    Format: S16_LE
    Channels: 1
    Endpoint: 2 IN (ASYNC)
    Rates: 48000, 44100
The important are the "capture" rates. If yours look different, please report here.

Hm... Actually I just tried my usbcam and the rates I see are (and yes, the mic-only input works too, output goes to internal speaker):
Rates: 8000, 16000, 22050, 24000, 32000, 44100, 48000

So I guess I need to add lower rates support after all and it'd work much better as a result.
Also need to figure out how to make ALSA to sample down the rates, I believe there is support for this.
The hardcoded 8k samplerate alsa lib is coming soon, though, after I give it a try locally.

Another useful bit - make sure to press volume-up button while in skype, esp if on internal speaker, as it starts calls at something like 70 or even 60% volume for some reason.
 
Last edited:

racks11479

Senior Member
Jan 2, 2011
990
748
Fresh Meadows
Ok, I guess I'll do some sort of a progress update on the usb audio since so many people are interested.

To use the files referenced here you need to install nightly -100 or later! If you use anything earlier than that version there is a bug in generic framework code that would prevent any audio input from working!

You will need this kernel image: http://nook.handhelds.ru/usbaudio/uImage
that you will need to use as the kernel.
The kernel change is only to allow skype not to enter dead loop when it tries to open a microphone and cannot (when you do not have a usb headset connected).
Unfortunately as soon as the internal mic input is opened, the audio out is also muted so I only include this for convenience of testing. (naturally don't take any of this as an indication that there is internal microphone input or anything.
On the other hand this kernel also includes some groundwork to enable FM radio support (assuming it was properly wired, in the past all attempts failed because these bits were missing.

Sweetness! A great fathers day present for me to play with. Thank you verygreen!!!

-Racks

Sent from my NookColor using Tapatalk
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
like the way this is headed. would love to just hook up my webcam w mic via usb w/ adapter and have gtalk or skype working...
I don't think Skype supports video under Android.
Don't know about gtalk.

The audio you can try right now, in fact I only tested with Skype and I am interested about other apps like gvoice and gtalk in particular, so give it a try and report here ;)
 
  • Like
Reactions: poofyhairguy

jinp6301

Member
Mar 4, 2011
30
0
You need to install the usbhost-enabled kernel again.
*facepalm*

sorry. that was just stupid :p I should have known that.

Another problem I ran into. When im playing music using the standard android music app through the usb (I assume since its not making any sound from the internal speaker), it does not emit any sound and the music seems to be going 5x faster (seek bar moving 5x faster than normal). Any suggestions?

Also thank you for helping out :)
 

legolee

Member
Mar 8, 2006
46
7
verygreen, thanks for your awesome work.
Just tested it with Dalingrin latest OC kernel.
I use a micro USB to USB OTG cable.
My Logitech wireless keyboard+mouse set is working perfectly!
It I connect nook to my apple pro keyboard or razer mouse (without hub), it hangs and needs rebooting.

Tried 2 USB drive and 2 card reader, none of them are working. I don't see and sxx in dev/block. those drive and card reader works well with Samsung Galaxy S2 USB host mode.

Am I out of luck or should I use a micro USB to USB adapter instead of the OTG cable?
Or it is problem of Dalingrin OC kernel?

I also tried with the Belkin 7 ports powered USB hub. But when i connect to my NC, my NC screen is acting crazy and registering ghost touch everywhere.
I thought i was going to burn my NC, but nothing happens :)
 
Last edited:

chisleu

Senior Member
Mar 7, 2011
1,042
105
Myrtle Beach SC
n108 + 6/18 kernel + host app

I was able to mount the memory stick in my old sony camera just fine.

I thought it very wierd that quickpic could see the directories but the term emu couldn't. ls was just not showing anything.

I we get auto mounting working I am going to be pumped!!!
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
It I connect nook to my apple pro keyboard or razer mouse (without hub), it hangs and needs rebooting.
Hm, I have not seen any hangs from connecting USB stuff to my nook. The worst that have happened is the device was just refused as drawing too much power.
I guess if it's a total hang, I cannot get any logs from the event?
Or does it reboot all by itself a few seconds later?

Tried 2 USB drive and 2 card reader, none of them are working. I don't see and sxx in dev/block. those drive and card reader works well with Samsung Galaxy S2 USB host mode.
Nook must be rejecting them due to too much power drawing declared. You should see what dmesg reports. (type dmesg in terminal emulator or after you disconnect the device and disable host mode, type dmesg in adb shell)

Am I out of luck or should I use a micro USB to USB adapter instead of the OTG cable?
Or it is problem of Dalingrin OC kernel?
There is no difference from what adapter you use.
I have not tried OC cable and I guess the power requirements of Nook increase in OC mode, so it might be an interesting idea to confirm this by testing with my usbhost-enabled kernel referenced in the first post, but I don't think it'll make a big difference. Still an interesting experiment to conduct.

I also tried with the Belkin 7 ports powered USB hub. But when i connect to my NC, my NC screen is acting crazy and registering ghost touch everywhere.
I thought i was going to burn my NC, but nothing happens :)
This is a second report like this I got. I don't have a power supply for my supposedly powered hub, but I wonder if it is related to the way usb socket is mounted on some nooks that leads to erratic touchscreen behavior even when plugged in and charging? Do you have such a problem I wonder?
Does your hub supply power to the upstream port too?
When I need more power for my testing devices I just use Y-cable to draw extra power from my PC (external vbus forced in host mode) and it works.
 

verygreen

Senior Member
Feb 13, 2011
1,305
2,637
TN
linuxhacker.ru
*facepalm*

sorry. that was just stupid :p I should have known that.

Another problem I ran into. When im playing music using the standard android music app through the usb (I assume since its not making any sound from the internal speaker), it does not emit any sound and the music seems to be going 5x faster (seek bar moving 5x faster than normal). Any suggestions?
Well, actually I only tested with Skype before this moment.
But I just tested with playing an ogg file (from /system/media/ringtones) in File Manager and it works.
Also I see that adjusting volume beeps into my headphones I use for testing too.
Have you tried increasing volume? Nook seems to be getting very low volume for me often (probably because it's all too easy to press the volume down button without noticing).
 

jinp6301

Member
Mar 4, 2011
30
0
Well, actually I only tested with Skype before this moment.
But I just tested with playing an ogg file (from /system/media/ringtones) in File Manager and it works.
Also I see that adjusting volume beeps into my headphones I use for testing too.
Have you tried increasing volume? Nook seems to be getting very low volume for me often (probably because it's all too easy to press the volume down button without noticing).
hmm, still no go. no sound coming out of both the internal speaker and the usb audio, the seek bar moves erratically. what can i do to check whats going on between the usb audio and the nook? dmesg?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 26
    USB support and usb audio support were recently picked up by mainstream, so starting from nightly 135 you get all of the below (except for the webcam support). I am leaving the old information for history preservation purposes. The usb mode utility is replaced by Nook Tweaks

    IMPORTANT! READ TO THE VERY END FIRST!

    Ok, so I know some people want to try the usbhost mode and I am releasing this trial package to gather feedback and see how it works in the wild.
    I am not responsible if you fry your nook (see below).

    First, you need some hardware, namely microUSB to USB Female adapter. Something like this one. (There are cheaper ones on ebay, but delivery time is about 3 weeks, I got mine for $1.43).
    Also an USB gender changer will work.

    Then you need a kernel with usbhost enabled. I made a package that you can install onto emmc with CWM, or the same package could be installed on SD card if you use my installer. This package is only for CM7 users that already converted to .32 kernel. If you still run 2.6.29 kernel (ie CM7.0.3) - you need to upgrade to a fresh nightly like -87 or wait longer.

    You can get the kernel here: http://nook.handhelds.ru/usbhost/update-CM7-green-usbhost-2-emmc.zip

    As you probably know, the Nook Color comes a little bit crippled in a sense that id pin on the OTG controller is not connected and so we cannot rely on it to properly choose mode. Instead I wrote an app to achieve the switching.
    The app is ugly as hell, sorry, it's my first attempt at writing an Android app, bear with me, it would become better (I accept free Android programming lessons too! ;) ).
    You can get the app here: http://nook.handhelds.ru/usbhost/NookUsbHostSwitcher.apk
    The app requires root, so make sure to allow it once asked and make it to remember the setting.

    Install the kernel, install the app.
    Reboot into the new kernel.
    Run the app and you'll see a big "ToggleButton". When it's in Off mode, that means your nook is in usb client mode.
    When you press it for the first time it will change to On, that means usb host.
    (you can connect your external accessory before or after you enable the host mode).
    When you press it again, it will change to Off and switch back to the client mode.
    I recommend that before switching the host mode off you first disconnect your accessory, otherwise the internal hub cannot switch off.
    (note that in some configurations the host mode enabling did not work for me on the first try and I needed to turn it off and on several times before the device registered. I believe there is no such problem with this kernel, but keep in mind such a possibility)
    Addition in v2:
    A second button is now added that lets you to force "external" vbus source. When you make it to ON, the battery charger pump is opened and connected to vbus terminals. In this state it is safe to connect nook to a power source, usb host will work and the battery should be charging at the same time.
    Even without external power if your battery has high enough voltage (usually when it's full for me), it still somewhat works.
    Additionally if you try to enable HostMode and an external power source is connected already, the "external" power mode is enabled (not shown in the app, though). This is to avert a potential disaster from below and to save battery.
    Now the important part: When the Nook is in host mode, it drives 5V vbus off the connector at all times. If you connect the nook to a PC in this state, the PC will try to drive it's own vbus. Last time I tried to do this, my usb port in the nook fried! You've been warned! But that was before I had the host mode working and it might have been caused by a number of other things I was doing at the time too. Anyway I am not very keen on repeating this experiment again. If you are curious and decide to try it anyway regardless of the warning, make a comment and tell me what happened ;)

    Supported devices (this is important, right?)
    Note that only low power devices will work if you don't have an externally powered hub. Don't expect to be able to drive a cdrom or a hard drive out of just nook. 100mA is the current limit. (Current testing shows that if you use ISB hub, even unpowered, it hides this issue).
    • All keyboards should be supported. (the keymap in CM7 is a bit strange, though, you'll see it).
    • All mice should be supported too, though I have not tried.
    • I enabled Xbox and PS3 controllers support, but have not tried.
    • Usb camera support - I only enabled UVC-compliant cameras (Microsoft Live cameras are compliant for example, probably many others). You also need specially built nigthtly with videocam support (try Camera app).
    • USB storage - generic support enabled, so should work for you.
    • Serial port support - only generic support enabled (I guess GPS devices mostly work as serial ports)
    • USB audio support enabled - not sure if the Android has any idea how to support it.

    The kernel is basically normal dalingrin's kernel with USB host support enabled and ipv6 disabled (to keep kernel size below 3M threshold).

    Kernel source (for the curious and if you want to build your own kernel with some mode devices support): git://github.com/dalingrin/nook_kernel.git branch usbhost

    Enjoy and share your experience.
    9
    Ok, I guess I'll do some sort of a progress update on the usb audio since so many people are interested.

    To use the files referenced here you need to install nightly -100 or later! If you use anything earlier than that version there is a bug in generic framework code that would prevent any audio input from working!

    You will need this kernel image: http://nook.handhelds.ru/usbaudio/uImage
    that you will need to use as the kernel.
    The kernel change is only to allow skype not to enter dead loop when it tries to open a microphone and cannot (when you do not have a usb headset connected).
    Unfortunately as soon as the internal mic input is opened, the audio out is also muted so I only include this for convenience of testing. (naturally don't take any of this as an indication that there is internal microphone input or anything.
    On the other hand this kernel also includes some groundwork to enable FM radio support (assuming it was properly wired, in the past all attempts failed because these bits were missing)).

    The other important bit is the alsa.omap3.so: http://nook.handhelds.ru/usbaudio/alsa.omap3.so
    Drop it to /system/lib/hw/ (this on sdcard this is partition2, /lib/hw)

    once the files are in place, reboot, connect the audio device, enable usbhost (or the other way around).
    The skype will now work. The sound is a bit distorted/sped up due to lack of rate conversion I guess.
    My usb headset is limited to 44.1kHz rate where as voice in is usually requested at 8k.
    the library I supply hardcodes the rate at 44.1kHz anyway.

    I suspect that the microphone only devices (like what is commonly found on web cameras) should also work with sound going to internal speaker.

    While you are at it, also please try to see if your audio device supports any other rates than mine. If it will turn out there are many 8k-supporting devices, I can try to add support for it I guess:
    Code:
    # cat /proc/asound/card1/stream0 
    C-Media USB Headphone Set   at usb-musb_hdrc-1.4, full speed : USB Audio
    
    Playback:
      Status: Stop
      Interface 1
        Altset 1
        Format: S16_LE
        Channels: 2
        Endpoint: 1 OUT (ADAPTIVE)
        Rates: 48000, 44100
    
    Capture:
      Status: Stop
      Interface 2
        Altset 1
        Format: S16_LE
        Channels: 1
        Endpoint: 2 IN (ASYNC)
        Rates: 48000, 44100
    The important are the "capture" rates. If yours look different, please report here.

    Hm... Actually I just tried my usbcam and the rates I see are (and yes, the mic-only input works too, output goes to internal speaker):
    Rates: 8000, 16000, 22050, 24000, 32000, 44100, 48000

    So I guess I need to add lower rates support after all and it'd work much better as a result.
    Also need to figure out how to make ALSA to sample down the rates, I believe there is support for this.
    The hardcoded 8k samplerate alsa lib is coming soon, though, after I give it a try locally.

    Another useful bit - make sure to press volume-up button while in skype, esp if on internal speaker, as it starts calls at something like 70 or even 60% volume for some reason.
    6
    I just got USB camera working (to some degree. preview window shows stuff).
    Only for uvc cameras supported by the kernel.

    Most of the work was done by CoreDruids by adding support for v4l cameras to Froyo. I merely ported their work to current CM7 sources. (links to follow once I submit changes to the repo. I expect this to be interesting to a lot of people as lately there were released plenty of tablets without cameras).

    My camera is MS Lifecam HD and seems to be too power-hungry for Nook to drive, so I used the just released ability to have externally driven vbus and borrowed the power from my desktop. Keep this in mind if you try with your camera and it does not work at first. (without it if I use the camera + keyboard on just nook power, stuff dies on init. If I use just the camera (over unpowered usb hub in both cases to hide power-hungry profile from the nook) it inits fine, but dies due to lack of power once real video stream is attempted (protocol error visible in logcat from v4l module)).

    Edit: So here is a special nightly build with webcam support. Try Camera app, that one certainly works. http://nook.handhelds.ru/usbhost/update-cm-7.1.0-RC0-encore-KANG-signed.zip This nightly already includes usbhost enabled kernel, but you still need to install the usbhost switchign app separately if you don't have it.

    Source changes for those interested. Generic libcamera stuff: http://review.cyanogenmod.com/5928 and Nook specific parts: http://review.cyanogenmod.com/5929
    5
    Microphones still aren't working, are they? Has anyone tried a USB mic?

    They sort of do in the latest nightly with a fix (http://review.cyanogenmod.com/5985 ) and recompiled alsa hw lib, but now there is a rate mismatch (usb device I have does not want to work at 8kHz), so all you hear is some bubbling.
    I am digging in this today and so hopefully a "Working skype" video is forthcoming at the end of the day ;)
    5
    I have updated the Nook Color Tweaks app with USB host support but I have no way of testing it.

    I would like to get confirmation that it works.

    Note: CM after version 7.1 is released this week will have automatic USB storage mounting for external disks. This app has a handy dandy shortcut in the notifications to safely unmount the disk. In order to test this notification you will need to manually mount to /mnt/usbdisk until the changes are merged into CM7.1

    The app should be partially compatible with verygreen's modified kernel but will need the 06/18 OC kernel to use all the features.

    As a bonus the app has boot features added by FatTire