[Q] Camera Swap on rooted TF101

Search This thread

Oblonsky

New member
Mar 5, 2011
4
1
Hi - NaN (not a noob) to software and hacking but new to this device.

I have a rooted TF101 and wonder if anyone's hacked the device so that the front camera becomes the rear and the rear camera becomes the front.

Really just curious before I go ahead and brick my device. I'm thinking about mv /dev/ov5640 and /dev/tegra_camera but that sounds far too easy (and dangerous)...
 

kenshin1388

Senior Member
Sep 27, 2009
202
55
Why would You be interested in swapping the cameras anyways? Seems to be a biit pointless to me as every app ive used with cameras it had support to use front or back.

Sent from my Transformer TF101 using xda premium
 

Oblonsky

New member
Mar 5, 2011
4
1
Well for starters Opera 12, which includes support for getUserMedia() WebRTC extensions uses the first webcam it comes across, the rear. If I wanted to even make a mock up of a video call I would need the front camera (granted this is only good for the lab, not production).

But really I was trying to understand how the underlying media device capability works. If you simply exchange using mv /dev/mi1040 (the front camera device) and /dev/ov5640 (back camera) then it goofs the images to any app that uses cameras.

There must therefore be other layer(s) determining device capabilities, codecs, etc.

There's a file /etc/nvcamera.conf but that only seems to affect the main camera app. I swapped 1 and 0 and front and back tags, although admittedly haven't yet swapped the device ID whilst leaving the front/back tags the same.

And there's a whopping /etc/media_profiles.xml defining all the camera capabilities.

Do I need a reason? Isn't anyone even just curious doing something to push the device and learn more about the platform???
 

Oblonsky

New member
Mar 5, 2011
4
1
How to swap the cameras so Opera 12 uses front camera for getUserMedia()

Ok, here's how I did it.

Essentially you only need to swap the tags 'front' and 'back' in the file /etc/nvcamera.conf

The change is permanent across reboots, but messes the orientation/mirror image of the cameras, so the rear camera becomes a mirror image, not the front. This messes all portrait shots as the camera pic becomes upside down.

Device needs to be rooted.

Need to make /system directory read/write:

# mount -o rw,remount /system

# vi /etc/nvcamera.conf# format, cameraName=device,direction,orientation,type

This is the file before mods
# type can be 'stereo' for stereo capable, 'mono' for not stereo capable,
# 'usb' to enable searching for a usb device and where to put it in the list
# if found. Lines must be shorter then 256 characters
version=1
camera0=/dev/ov5640,back,0,mono
#camera1=/dev/ov5650,back,0,mono // 2nd camera for stereo once supported
camera1=/dev/mi1040,front,0,mono
#camera4=/dev/ov5650,back,0,stereo // virtual stereo device once supported


Change this line:
camera0=/dev/ov5640,back,0,mono

to:
camera0=/dev/ov5640,front,0,mono

And this line:
camera1=/dev/mi1040,front,0,mono

to:
camera1=/dev/mi1040,back,0,mono


Save and it works.
 
  • Like
Reactions: Thing O Doom

neofreek01

Senior Member
Nov 24, 2011
198
77
47
scranton
I also agree. as some may not understand the reasoning, obviously oblonsky has a reason for doing this, just because everyone doesnt understand or agree with him is no reason to cut him off and remove his post... anything anyone learns or attempts to learn about android or the transformers code will progress understanding of the platform and the device. I vote let it stay and continue your endeavor fellow androidian.....
 
  • Like
Reactions: Nos74 and Oblonsky

Oblonsky

New member
Mar 5, 2011
4
1
Yes, thanks guys. I'm already wondering now whether it may be possible to add new cameras, or disable cameras - do more useful stuff than swap cameras. Also I took the time to post the answer to my own question just in case it was useful to anyone else - so it would seem odd to want to remove the information that just *might* be useful to others at some point.
 

Wokoloko

Senior Member
Aug 22, 2006
51
17
Here is a reason to make the front camera the default camera: After getting in a terrible rain, my main camera on the back is not working anymore.
When starting a camera apps, it just quits with kind of a "connection to camera no possible" message.
 

SHUR1KEN

New member
Jun 1, 2019
2
0
Here's another reason to make the front camera as the default

I have a phone that's about 5 years old. It's been through heavy and rough usage. Hence, the connection between the motherboard and camera module are fried.
Now, when I have to login into WhatsApp Web or the WhatsApp App for Windows, I cannot because it needs a QR code scanned - which triggers the back camera.
So, I'm going to go ahead and try this, kudos! :D
 

mayowa_olu

Member
Apr 12, 2017
12
1
I have a phone that's about 5 years old. It's been through heavy and rough usage. Hence, the connection between the motherboard and camera module are fried.
Now, when I have to login into WhatsApp Web or the WhatsApp App for Windows, I cannot because it needs a QR code scanned - which triggers the back camera.
So, I'm going to go ahead and try this, kudos! :D


Uhm did it work?
 

SHUR1KEN

New member
Jun 1, 2019
2
0
Unfortunately, no, it didn't. Apparently, WhatsApp has gotten rid of the gate that used to allow for the "exploit" to happen before. I have heard of users doing it 2 years ago.

Anyway, what I had to do in my case was, I had to maintain pressure at the point on the camera module where it connects to the motherboard, while navigating to WhatsApp Web and scanning the QR code, all without even the most minute of movements. Otherwise the phone would fail to detect the camera module all over again, demanding me to repeat the whole thing again + a manual camera driver reset from my ROM settings.

Tried it like 20+ times. Succeeded in 1/20 of them... **** was tough, bro.
 

mafrasi2

New member
May 10, 2012
4
0
Huawei P40 Pro
I finally managed to do this on my Redmi Note 5. This is probably applicable to most other devices as well.

  1. Remount the system partition as writable:
    Code:
    $ su -c mount -o rw,remount /system
  2. Edit /system/vendor/etc/camera/camera_config.xml and swap all
    Code:
    <Position>BACK</Position>
    to
    Code:
    <Position>FRONT</Position>
    and vice versa.
  3. Reboot.
 

TheSnowpup

New member
Apr 17, 2020
1
0
Do you think this will still work?

If I unroot after modifying the file, will the change persist?

Many thanks for your excellent work.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    I also agree. as some may not understand the reasoning, obviously oblonsky has a reason for doing this, just because everyone doesnt understand or agree with him is no reason to cut him off and remove his post... anything anyone learns or attempts to learn about android or the transformers code will progress understanding of the platform and the device. I vote let it stay and continue your endeavor fellow androidian.....
    1
    There was a point where Yahoo IM would use the back camera (when it was avaiable native to the TF). There was a member "droidx" he modified some files and got the front camera working with it. You're better off looking at modifying files as oppose to rewiring cameras.

    More info here
    http://xdaforums.com/showthread.php?t=1087769
    1
    How to swap the cameras so Opera 12 uses front camera for getUserMedia()

    Ok, here's how I did it.

    Essentially you only need to swap the tags 'front' and 'back' in the file /etc/nvcamera.conf

    The change is permanent across reboots, but messes the orientation/mirror image of the cameras, so the rear camera becomes a mirror image, not the front. This messes all portrait shots as the camera pic becomes upside down.

    Device needs to be rooted.

    Need to make /system directory read/write:

    # mount -o rw,remount /system

    # vi /etc/nvcamera.conf# format, cameraName=device,direction,orientation,type

    This is the file before mods
    # type can be 'stereo' for stereo capable, 'mono' for not stereo capable,
    # 'usb' to enable searching for a usb device and where to put it in the list
    # if found. Lines must be shorter then 256 characters
    version=1
    camera0=/dev/ov5640,back,0,mono
    #camera1=/dev/ov5650,back,0,mono // 2nd camera for stereo once supported
    camera1=/dev/mi1040,front,0,mono
    #camera4=/dev/ov5650,back,0,stereo // virtual stereo device once supported


    Change this line:
    camera0=/dev/ov5640,back,0,mono

    to:
    camera0=/dev/ov5640,front,0,mono

    And this line:
    camera1=/dev/mi1040,front,0,mono

    to:
    camera1=/dev/mi1040,back,0,mono


    Save and it works.
    1
    No keep it, that's a good thing to have available to see or as a project. I love to learn things like this.
    1
    No keep it, that's a good thing to have available to see or as a project. I love to learn things like this.

    I second doom. It's about pushing the limits of the device.

    Good on ya for doing this.

    Sent from my SCH-I500 using Tapatalk 2