• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root [DEV] WIP CM9 (Camera) [updated 2/23/2013]

I removed the HTC line and it still compiled over here.

While poking around in cameraHALL.cpp I see a few references to "BOARD_USE_FROYO_LIBCAMERA". We are using the libcamera from Froyo, correct? Maybe enabling this will help.

[HIGH]#if defined(BOARD_USE_FROYO_LIBCAMERA)
#ifndef FIRST_CAMERA_FACING
#define FIRST_CAMERA_FACING CAMERA_FACING_BACK
#endif
#ifndef FIRST_CAMERA_ORIENTATION
#define FIRST_CAMERA_ORIENTATION 90
#endif
static const CameraInfo sCameraInfo[] = {
{
FIRST_CAMERA_FACING,
FIRST_CAMERA_ORIENTATION, /* orientation */
1, /* CAMERA_MODE_2D */
},
{
CAMERA_FACING_FRONT,
270, /* orientation */
1, /* CAMERA_MODE_2D */
}
};
#endif[/HIGH]

I didn't just remove the HTC referance, I also added in the BOARD_CAMERA_USE_GETBUFFERINFO := true from CM7.
When I did it had an error that said something like a bunch of method calls weren't in libcamera2.so. I didn't go any further as I thought I was going in the wrong direction.
Looking at mozzwald's post I see some oreintation definitions that I could play with. Just to see what happens.
 
I just finished an experimental build that flashes the flash and shows the saved picture and then errors out at the jpeg encoder. It only shows having one camera, but it is getting somewhere. It also fixes rotation after switching picture quality, but is mirrored. Panorama doesn't work either. Now I just need to figure out what helped and what didn't.

I figure I will post it if some people want to tinker and check out other apps and stuff.

pa_triumph-1.6a-16FEB2013-Cam-Experiment

Giving this a shot. It looks like the same kernel as cm9 git, what libcamera/liboemcamera have you settled on for this?

EDIT: Got a pretty big chuckle out of your boot logo, hope you didn't spend too much time on that =]

EDIT2: Ok, your ROM here is giving me very interesting results. The camera doesn't crash, I can try to take a picture again. It also appears to be using a different code path in QualcommCameraHardware in taking the picture. It is using native_start_snapshot vs. native_start_video (although if I try the libcamera2.so in your rom, it does use native_start_video... it looks like cm7 is using native_start_snapshot, so I guess this is the right way). Also, I get a backtrace that shows being in runSnapshotThread in /system/lib/hw/camera.msm7x30.so, which I am a bit confused about. Shouldn't it be in libcamera.so...?

EDIT3: Regarding the snapshot vs. video I think I'm just confused because there isn't as much logging in cm7. It appears to use video for the preview mode, then snapshot as it takes the picture.
 
I removed the HTC line and it still compiled over here.

While poking around in cameraHALL.cpp I see a few references to "BOARD_USE_FROYO_LIBCAMERA". We are using the libcamera from Froyo, correct? Maybe enabling this will help.

[HIGH]#if defined(BOARD_USE_FROYO_LIBCAMERA)
#ifndef FIRST_CAMERA_FACING
#define FIRST_CAMERA_FACING CAMERA_FACING_BACK
#endif
#ifndef FIRST_CAMERA_ORIENTATION
#define FIRST_CAMERA_ORIENTATION 90
#endif
static const CameraInfo sCameraInfo[] = {
{
FIRST_CAMERA_FACING,
FIRST_CAMERA_ORIENTATION, /* orientation */
1, /* CAMERA_MODE_2D */
},
{
CAMERA_FACING_FRONT,
270, /* orientation */
1, /* CAMERA_MODE_2D */
}
};
#endif[/HIGH]
Check out my Experimental BoardConfig on github, it has all the flags I could find that might help, https://github.com/BSydz/android_de...mmit/88ba0f33840d1eeb62143c2301f120f704336daf
Giving this a shot. It looks like the same kernel as cm9 git, what libcamera/liboemcamera have you settled on for this?

EDIT: Got a pretty big chuckle out of your boot logo, hope you didn't spend too much time on that =]

EDIT2: Ok, your ROM here is giving me very interesting results. The camera doesn't crash, I can try to take a picture again. It also appears to be using a different code path in QualcommCameraHardware in taking the picture. It is using native_start_snapshot vs. native_start_video (although if I try the libcamera2.so in your rom, it does use native_start_video... it looks like cm7 is using native_start_snapshot, so I guess this is the right way). Also, I get a backtrace that shows being in runSnapshotThread in /system/lib/hw/camera.msm7x30.so, which I am a bit confused about. Shouldn't it be in libcamera.so...?

EDIT3: Regarding the snapshot vs. video I think I'm just confused because there isn't as much logging in cm7. It appears to use video for the preview mode, then snapshot as it takes the picture.

I can't take credit for the boot logo, as I was reading about PA, they had stated if you are gonna release this as PA keep it PA, so I did.

I haven't touched a thing as far as the kernel or the libs are concerned, only the files in the camera folders and building with manteras overlay framework files. I have changed a few things in the BoardConfig, and also updated the headers to reflect the current kernel. Side note: If you use the msm_rotator.h from the kernel it will jack up landscape video playback.

I pulled out an old dusty copy of CM9 I had from sometime last year, and pulled a few things from the frameworks that whyzor, tickerguy, mantera and isaac had worked on. Basically just camera and surface stuff, plus it had another version of the cameraHal files that I was working on that I got some stuff from. That is why it is such a dramatic difference, I threw the kitchen sink at it, to see if it would budge. Now I just have to go through and figure out which changes did what.

I am in the process of setting up my github for PA and had an idea. Since I only changed about 15 files in frameworks, I was gonna try to just include those files in the device files in the overlay/frameworks folder. I got most of it to work but I am having a hard time getting the cameraHal files to find the file. I have tried LOCAL_C_INCLUDES in the mk files every single way I can think of, but it never finds the file.

Any way, good luck everybody.
 
Giving this a shot. It looks like the same kernel as cm9 git, what libcamera/liboemcamera have you settled on for this?

EDIT: Got a pretty big chuckle out of your boot logo, hope you didn't spend too much time on that =]

EDIT2: Ok, your ROM here is giving me very interesting results. The camera doesn't crash, I can try to take a picture again. It also appears to be using a different code path in QualcommCameraHardware in taking the picture. It is using native_start_snapshot vs. native_start_video (although if I try the libcamera2.so in your rom, it does use native_start_video... it looks like cm7 is using native_start_snapshot, so I guess this is the right way). Also, I get a backtrace that shows being in runSnapshotThread in /system/lib/hw/camera.msm7x30.so, which I am a bit confused about. Shouldn't it be in libcamera.so...?

EDIT3: Regarding the snapshot vs. video I think I'm just confused because there isn't as much logging in cm7. It appears to use video for the preview mode, then snapshot as it takes the picture.

As far as the libraries go, I think that there were a bunch of things tried. Not knowing how to do proper logging I'm not sure how to help you. If you guys could give me a quick course on how to set up the phone or how to follow the logcat I could try to help. Or if you want me to run some leg work, like link the device groups to a triumph-??? build then I could do that. I might start there. That way we know what files we are using.
 
As far as the libraries go, I think that there were a bunch of things tried. Not knowing how to do proper logging I'm not sure how to help you. If you guys could give me a quick course on how to set up the phone or how to follow the logcat I could try to help. Or if you want me to run some leg work, like link the device groups to a triumph-??? build then I could do that. I might start there. That way we know what files we are using.

Following the logcat is not too hard. Search for takePicture, and you'll be near the interesting parts. All the stuff that starts with QualcommCameraHardware is in QualcommCameraHardware.cpp, so you can search for strings in there. Just be sure you know what files you're looking at... I've started keeping camerahal/libcamera2 in sync, and copying libcamera2.so over libcamera.so, and also replacing camera.msm7x30.so because it is looking like they are both being used.
 
I've tried a bunch of things today without much progress. One thing I looked at was a disassembly of liboemcamera.so. Some of the stuff in QCamera_Intf.h makes a little more sense now... it looks like the constants in there are derived from the blob. Interestingly, a couple of our constants were off in cam_ctrl_type, but I don't think it's relevant to the issue at hand.

I believe native_stop_video ioctl only fails after the auto focus attempt. If you switch resolutions, native_stop_video is called, and it works, stopping the frame thread, and that is where we see the "after LINK_cam_frame". So, I'm thinking trying to do an auto focus puts it in a state that makes the ioctl fail.

Also related to auto focus, I don't believe it is being started properly on CM9 yet. Looking at the CM7 logs, there are a bunch of "AF not finished" messages that we aren't seeing. Well, this string is in the blob. Unfortunately, it's not in our cm9 blob, but I tried the cm7 blob under cm9, and interestingly enough it is working as well as the cm9 blob. But, I'm also not seeing these AF messages with the cm7 blob, which is why I don't think auto focus is being started properly. There is probably some setup step we are missing, outside that flag I found.

EDIT: One thing I'm still unclear about it what role the kernel has in this mess. At this point, I think it's mostly used for configuring the sensor via i2c, and I don't think it's used at all for video/picture data.
 
I've tried a bunch of things today without much progress. One thing I looked at was a disassembly of liboemcamera.so. Some of the stuff in QCamera_Intf.h makes a little more sense now... it looks like the constants in there are derived from the blob. Interestingly, a couple of our constants were off in cam_ctrl_type, but I don't think it's relevant to the issue at hand.

I believe native_stop_video ioctl only fails after the auto focus attempt. If you switch resolutions, native_stop_video is called, and it works, stopping the frame thread, and that is where we see the "after LINK_cam_frame". So, I'm thinking trying to do an auto focus puts it in a state that makes the ioctl fail.

Also related to auto focus, I don't believe it is being started properly on CM9 yet. Looking at the CM7 logs, there are a bunch of "AF not finished" messages that we aren't seeing. Well, this string is in the blob. Unfortunately, it's not in our cm9 blob, but I tried the cm7 blob under cm9, and interestingly enough it is working as well as the cm9 blob. But, I'm also not seeing these AF messages with the cm7 blob, which is why I don't think auto focus is being started properly. There is probably some setup step we are missing, outside that flag I found.

EDIT: One thing I'm still unclear about it what role the kernel has in this mess. At this point, I think it's mostly used for configuring the sensor via i2c, and I don't think it's used at all for video/picture data.

I can tell you that everyone who built CM7 had a camera that would fail to fully focus. At leas I think that's what would happen as the focus ring would go red (focus failed). What we did was change the focus failed to the green image so that when the camera took it's picture it would be green.
 
I can tell you that everyone who built CM7 had a camera that would fail to fully focus. At leas I think that's what would happen as the focus ring would go red (focus failed). What we did was change the focus failed to the green image so that when the camera took it's picture it would be green.

Hmm my cm7 logcat is not from one I built, but it does finish focusing. I get about 15 of the "AF not finished" messages, then I get "AF finished". I get none of this in cm9.
 
Hmm my cm7 logcat is not from one I built, but it does finish focusing. I get about 15 of the "AF not finished" messages, then I get "AF finished". I get none of this in cm9.

Oh, what one do you have? I can possibly find where the device files came from if that will help.
 
I'm surprised to see USES_OVERLAY = false in board config. Aren't we using an overlay? Or is the one in board config something different?
 
Honestly I don't know. I noticed that's different in CM7.`

I've recompiled with it set, seems to "work" just as well.

On a slightly different note, it looks like if BOARD_USE_FROYO_LIBCAMERA is set, the little gallery preview thumbnail in the bottom right stops working. Other than that it seems the same.
 
What I really want to see: a QualcommCameraHardware.cpp from cm7... does that exist? I'm pretty sure the one in hardware/msm7k/libcamera is not the real one because we appear to be using the one in device/motorola/triumph/prebuilt/Camera.
 
What I really want to see: a QualcommCameraHardware.cpp from cm7... does that exist? I'm pretty sure the one in hardware/msm7k/libcamera is not the real one because we appear to be using the one in device/motorola/triumph/prebuilt/Camera.
Check this out, it doesn't have to do with CM7 but may give some leads on the camera.

http://androidforums.com/triumph-al...-ics-development-post4522169.html#post4522169

This seems to be the source of the cameraHal
http://forum.xda-developers.com/showthread.php?t=1427030&highlight=permissions#
 
I have been trying to get the cm7 liboemcamera.so and libcamera.so running in cm9. I've got it working now, and the autofocus is finishing properly. I'm still getting the native_stop_video ioctl fail, but now there is an error message from the blob before that:

02-19 01:17:20.043 E/mm-camera( 5284): config_proc_CAMERA_STOP_VIDEO: state is not correct ctrl->state = 24
02-19 01:17:20.043 E/mm-camera( 5284): Fatal Error: config_proc_ctrl_command cmd=58 is pending, new cmd=58

So, I guess this state problem is why the ioctl is failing.
 
I just finished an experimental build that flashes the flash and shows the saved picture and then errors out at the jpeg encoder. It only shows having one camera, but it is getting somewhere. It also fixes rotation after switching picture quality, but is mirrored. Panorama doesn't work either. Now I just need to figure out what helped and what didn't.

I figure I will post it if some people want to tinker and check out other apps and stuff.

pa_triumph-1.6a-16FEB2013-Cam-Experiment
Ok a little update on this ROM.The video doesn't work for ooVoo on this build but the video works on Skype.Also ActionSnap works on fast shot mode but it saves the picture upside down.Going to check a few other things out.

UPDATE:
CameraMX don't work on this build and neither does Silent Camera.Now on to test the CM9 2-21 build.
 
Ok a little update on this ROM.The video doesn't work for ooVoo on this build but the video works on Skype.Also ActionSnap works on fast shot mode but it saves the picture upside down.Going to check a few other things out.

http://forum.xda-developers.com/showthread.php?t=2144869

See if you can use the new snapchat beta. You may even be able to save video, hold down the blue button and wait for the video to record, then hit the save button and it may work. Also does it detect the FFC?
 
Apparently the kernel does have more to do with this than I have been thinking. I have successfully taken a picture with the cm7 kernel and cm7 libs under cm9. Caveats: 1) touchscreen isn't properly working (I had to pull in cm9 kernel touchscreen driver to get it working to the limited extent it is now) 2) camera app doesn't display any data (although the picture saves correctly -- probably gralloc related).

Next step is either pull camera stuff out of cm7 kernel or pull gralloc stuff out of cm9. Part of me even wants to try going way back to original motorola kernel because g60 said wifi/bt deepsleep issues are gone, but I looked at that a bit a couple months ago and it seemed like a nightmare.
 
Apparently the kernel does have more to do with this than I have been thinking. I have successfully taken a picture with the cm7 kernel and cm7 libs under cm9. Caveats: 1) touchscreen isn't properly working (I had to pull in cm9 kernel touchscreen driver to get it working to the limited extent it is now) 2) camera app doesn't display any data (although the picture saves correctly -- probably gralloc related).

Next step is either pull camera stuff out of cm7 kernel or pull gralloc stuff out of cm9. Part of me even wants to try going way back to original motorola kernel because g60 said wifi/bt deepsleep issues are gone, but I looked at that a bit a couple months ago and it seemed like a nightmare.
You can take the m410 kernel or the Sharp kernel from my github and apply the TS drivers and this to get it working. https://github.com/mantera/triumph-kernel-msm7x30/commit/46cea7ad007cf38438208ce14dd1c3b4890f70c3

What blobs are you using from CM7, just the 2 camera files or the mmjpeg and stuff as well?
 
Back
Top Bottom