Jump to content

Front Camera on CM6 / CM7


Guest dr.flo
 Share

Recommended Posts

To access the front camera instead of back camera, one could do something like this:

cd /dev/msm_camera

mv msm_camera0 back_cam

mv msm_camera1 front_cam


# to select back cam by default...

ln -s back_cam msm_camera0


# or to select front cam

ln -s front_cam msm_camera0

edit:

Now here is the script to do it. Install it via CWM and you will have a new shell command "camswitch" in /system/bin.

Tested on CM6 only. Might as well work on CM7.

Can be executed in terminal emulator (su required) or via adb.

The easiest version of executing it is using GScript Lite (-> market). Just add the script once like this:

post-954785-0-16466700-1329515190_thumb.

Then you'll be able to create a shortcut to it on the home screen...

Edited by dr.flo
Link to comment
Share on other sites

do you know by a chance if CyanogenMod's Camera app works with front cam of ANY phone in existence?

The problem is not the camera app. The problem is that native support for multiple cameras was first added in gingerbread. That means in eclair and froyo, when a device had multiple cameras, some vendor specific custom way is used to switch cameras.

There is a function inside libcameraservice (compiled from source) that returns the number of available cameras. This can be modified to return 2 for the pulse. Then the CM7 camera app offers a switch camera button. But is is not functional because we do not know what vendor specific function to call inside our libcamera (telling it to open /dev/msm_camera/msm_camera1) .

If you do not know how to tell the libs they should use camera 1 instead of camera 0 - then the only way to make them use camera 1 is to rename its device into camera 0

For CM6, as this is froyo, there is no way. It simply has no api to select which camera. But the rename trick would work. If I do it, I can record video and take pics from front cam.

Link to comment
Share on other sites

For CM7:

this is what I meant in libcameraservice;

You can see that for HTC devices, the vendor specific way of switching cameras in known. Therefore fore these devices, both cameras are supported in CM7.

#ifdef BOARD_USE_FROYO_LIBCAMERA

static int getNumberOfCameras()

{

	if (access(HTC_SWITCH_CAMERA_FILE_PATH, W_OK) == 0) 

	{    	

    	return 2;	

	}    /* FIXME: Support non-HTC front camera */   


	return 1;

}


#endif


#if defined(BOARD_USE_FROYO_LIBCAMERA) || defined(BOARD_HAVE_HTC_FFC)

#define HTC_SWITCH_CAMERA_FILE_PATH "/sys/android_camera2/htcwc"

static void htcCameraSwitch(int cameraId){

	char buffer[16];	

	int fd;

    if (access(HTC_SWITCH_CAMERA_FILE_PATH, W_OK) == 0)

    {    	

    	snprintf(buffer, sizeof(buffer), "%d", cameraId);

        fd = open(HTC_SWITCH_CAMERA_FILE_PATH, O_WRONLY);    	

   	write(fd, buffer, strlen(buffer));    	

  	close(fd);	

 	}

}

#endif

Link to comment
Share on other sites

thinking is something similar to "/sys/android_camera2/htcwc" in our proprietary libs...

thats what we have to find. then we'll have native support for both cams in CM7.

A quick strings libcamera.so showed that it is not /sys/android_camera2/... - the problem is there are plenty of ways this could have possibly be done. Maybe we have to analyze the stock eclair camera.apk? I've never looked at an apk. Is there java inside? In source form maybe?

Link to comment
Share on other sites

thats what we have to find. then we'll have native support for both cams in CM7.

A quick strings libcamera.so showed that it is not /sys/android_camera2/... - the problem is there are plenty of ways this could have possibly be done. Maybe we have to analyze the stock eclair camera.apk? I've never looked at an apk. Is there java inside? In source form maybe?

yes, it can be decompiled to semi-human-readable (hackable) language - smali. Then can be assembled back.

apk-tool if I recollect correctly does the trick

I guess author of the tool tweaks g maps this way

Edited by pier11
Link to comment
Share on other sites

  • 4 weeks later...

this is a great fix, finally i can see my front camera working.

btw im using the txg rom and i cant switch off the auto focus from the camera app, i can record video with the front camera though. there is a way for me to include the switch in resolution and quality in the script so it can be done automatically? i dont have too much experience in android but at least i could research if im pointed in the right way.

GREAT WORK DUDE

Edited by felip3
Link to comment
Share on other sites

This is really weird, but Gscript Lite isn't showing in my Market using dr.flo's CM6. Can someone upload the apk? Thanks.

Nevermind. I found it elsewhere. Still, I'm curious about why I couldn't see it on the Market.

Confirmed, works perfectly as expected, both pictures and video. Thanks.

Edited by twrock
Link to comment
Share on other sites

This is really weird, but Gscript Lite isn't showing in my Market using dr.flo's CM6. Can someone upload the apk? Thanks.

Nevermind. I found it elsewhere. Still, I'm curious about why I couldn't see it on the Market.

strange, shows up on the Market with um840 rom. But I might have less restrictions due to geo location...

Link to comment
Share on other sites

this is a great fix, finally i can see my front camera working.

btw im using the txg rom and i cant switch off the auto focus from the camera app, i can record video with the front camera though. there is a way for me to include the switch in resolution and quality in the script so it can be done automatically? i dont have too much experience in android but at least i could research if im pointed in the right way.

GREAT WORK DUDE

My guess about the inability to switch focus mode is related to all of the hacking necessary to get the camera working in Tom G's CM6 port. I'm testing dr.flo's CM6.1 Stable rom at the moment, and the camera in that rom works as expected.

So if you can wait a little while, I believe I will have an update to TXG (or a new rom mod similar to TXG) based on dr.flo's CM6. But I will not promise it will be available today. ;) At the moment I'm having some trouble with the initial setup upon first boot after flashing the rom. I'd like to make the rom as noob friendly as possible, and setup problems need to be corrected first.

Edit: Sorry, don't hold me to that promise. Things have turned out to be more complicated than I anticipated. I've had multiple problems, many more than I anticipated, and I'm not having positive results trying to build the full rom. If you want, you can just go through that thread and do all the the steps to install it in parts.

Edited by twrock
Link to comment
Share on other sites

strange, shows up on the Market with um840 rom. But I might have less restrictions due to geo location...

It might also have been a location problem for me. Google and Taiwan are still fighting over access to the Android Market, because the Taiwan government passed a law that all internet sales had to come with a 14 day return policy. The Market has a 15 minute return policy, so Google turned off paid apps for us. But I think it also sometimes affects other things not showing up. Usually I can work around all of that, but sometimes not.

Link to comment
Share on other sites

To access the front camera instead of back camera, one could do something like this:

cd /dev/msm_camera

mv msm_camera0 back_cam

mv msm_camera1 front_cam


# to select back cam by default...

ln -s back_cam msm_camera0


# or to select front cam

ln -s front_cam msm_camera0

edit:

Now here is the script to do it. Install it via CWM and you will have a new shell command "camswitch" in /system/bin.

Tested on CM6 only. Might as well work on CM7.

Can be executed in terminal emulator (su required) or via adb.

The easiest version of executing it is using GScript Lite (-> market). Just add the script once like this:

post-954785-0-16466700-1329515190_thumb.

Then you'll be able to create a shortcut to it on the home screen...

it works on cm7 i can see front camera working but i can²t take picture..how do i turn off autofocus in cm7?

edit ihave been in camera parameters and both option about focus are off...

so what sould i replace as files to make it work on cm7? thx

edit2 would it be possible with that script to have video call working on cm6 clean?

Edited by desalesouche
Link to comment
Share on other sites

edit2 would it be possible with that script to have video call working on cm6 clean?

Try it. Should work.

As for the questions regarding cm7 - I currently don't run that rom. I don't know which options the camera app has there. On cm6, I select "normal" as focus mode. And don't forget QVGA picture resolution.

But all this should not be needed for video calling applications as it affects picture mode only.

Link to comment
Share on other sites

just want to tell everyone that if you install camera 360 you can use this trick in any rom, the app has te ability to disable the focus. im using the front camera in cm7 with camera 360, (i couldnt use it with the stock camera app)

Link to comment
Share on other sites

just want to tell everyone that if you install camera 360 you can use this trick in any rom, the app has te ability to disable the focus. im using the front camera in cm7 with camera 360, (i couldnt use it with the stock camera app)

can you make videocall /visio with cm7?
Link to comment
Share on other sites

can you make videocall /visio with cm7?

i can record videos with the front camera for sure, i will download skype or something and try videocalling and post if it works, i think there wont be problems at all.

Link to comment
Share on other sites

i can record videos with the front camera for sure, i will download skype or something and try videocalling and post if it works, i think there wont be problems at all.

:) thanks for trying...hope it would work...

edit: impatient to know result of your test :unsure:

Edited by desalesouche
Link to comment
Share on other sites

:) thanks for trying...hope it would work...

im sad to say that it didnt work, i tried skype and if you receive a videocall you get sound working ok but the ui freezes, you cant even hang up, the call keeps going but you cant see or send any video, i also tried downloading tango but i had no luck either, i think the problem is not in the cam itself but in the lack of native videocalling support. im not sure, i didnt even make a videocall of any kind before. if you know of somenthing else i can try just tell me.

Link to comment
Share on other sites

im sad to say that it didnt work, i tried skype and if you receive a videocall you get sound working ok but the ui freezes, you cant even hang up, the call keeps going but you cant see or send any video, i also tried downloading tango but i had no luck either, i think the problem is not in the cam itself but in the lack of native videocalling support. im not sure, i didnt even make a videocall of any kind before. if you know of somenthing else i can try just tell me.

i have heard about fring on market who allow to make visio.i have heard about yahoo messenger who suppose to work but only with back camera (may be they update it?)

Link to comment
Share on other sites

i have heard about fring on market who allow to make visio.i have heard about yahoo messenger who suppose to work but only with back camera (may be they update it?)

two things to help narrow down experiments:

- a video calling solution that was known to work with back cam only should now work with whatever cam is selected.

- a video calling app that did not work with back cam in the past will also not work now

Link to comment
Share on other sites

two things to help narrow down experiments:

- a video calling solution that was known to work with back cam only should now work with whatever cam is selected.

- a video calling app that did not work with back cam in the past will also not work now

i was thinking that thx to your and others works, the possibility to port visio/video call on cm7.2 should be soon there :) this is my feeling .but i might be wrong...would it be better to try with um840 rom?

so i don't know about other videocall app that might be tested.

Edited by desalesouche
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.