[LG Optimus 3D] tiagoclc:
defcomg,

The attachment from this post is the source code of what?

http://xdaforums.com/showpost.php?p=33912397&postcount=158

Because i found this:

if ( params.getInt(TICameraParameters::KEY_SENSOR_ORIENTATION) != -1 )
{
mSensorOrientation = params.getInt(TICameraParameters::KEY_SENSOR_ORIENTATION);
if (mSensorOrientation == 270 ||mSensorOrientation==90)
{
CAMHAL_LOGEA(" Orientation is 270/90. So setting counter rotation to Ducati");
mSensorOrientation +=180;
mSensorOrientation%=360;
}
}
else
{
mSensorOrientation = 0;
}

CAMHAL_LOGVB("Sensor Orientation set : %d", mSensorOrientation);

in /camera/OMXCameraAdapter/OMXCapture.cpp

And this:

/*** static declarations ***/
static const float RADIANS_2_DEG = (float) (180 / M_PI);
// measured values on device...might need tuning
static const int DEGREES_90_THRESH = 50;
static const int DEGREES_180_THRESH = 170;
static const int DEGREES_270_THRESH = 250;

static int sensor_events_listener(int fd, int events, void* data)
{
SensorListener* listener = (SensorListener*) data;
ssize_t num_sensors;
ASensorEvent sen_events[8];
while ((num_sensors = listener->mSensorEventQueue->read(sen_events, 8)) > 0) {
for (int i = 0; i < num_sensors; i++) {
if (sen_events[i].type == Sensor::TYPE_ACCELEROMETER) {
float x = sen_events[i].vector.azimuth;
float y = sen_events[i].vector.pitch;
float z = sen_events[i].vector.roll;
float radius = 0;
int tilt = 0, orient = 0;

CAMHAL_LOGVA("ACCELEROMETER EVENT");
CAMHAL_LOGVB(" azimuth = %f pitch = %f roll = %f",
sen_events[i].vector.azimuth,
sen_events[i].vector.pitch,
sen_events[i].vector.roll);
// see http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates
// about conversion from cartesian to spherical for orientation calculations
radius = (float) sqrt(x * x + y * y + z * z);
tilt = (int) asinf(z / radius) * RADIANS_2_DEG;
orient = (int) atan2f(-x, y) * RADIANS_2_DEG;

if (orient < 0) {
orient += 360;
}

if (orient >= DEGREES_270_THRESH) {
orient = 270;
} else if (orient >= DEGREES_180_THRESH) {
orient = 180;
} else if (orient >= DEGREES_90_THRESH) {
orient = 90;
} else {
orient = 0;
}
listener->handleOrientation(orient, tilt);
CAMHAL_LOGVB(" tilt = %d orientation = %d", tilt, orient);
} else if (sen_events[i].type == Sensor::TYPE_GYROSCOPE) {
CAMHAL_LOGVA("GYROSCOPE EVENT");
}
}
}

if (num_sensors < 0 && num_sensors != -EAGAIN) {
CAMHAL_LOGEB("reading events failed: %s", strerror(-num_sensors));
}

return 1;
}

in /camera/sensorlistener.cpp

Also this:

//TI extensions to add sensor orientation parameters
const char TICameraParameters::eek:RIENTATION_SENSOR_NONE[] = "0";
const char TICameraParameters::eek:RIENTATION_SENSOR_90[] = "90";
const char TICameraParameters::eek:RIENTATION_SENSOR_180[] = "180";
const char TICameraParameters::eek:RIENTATION_SENSOR_270[] = "270";

in /camera/ticameraparameters.cpp

We could change those values to:

const char TICameraParameters::eek:RIENTATION_SENSOR_NONE[] = "180";
const char TICameraParameters::eek:RIENTATION_SENSOR_90[] = "270";
const char TICameraParameters::eek:RIENTATION_SENSOR_180[] = "0";
const char TICameraParameters::eek:RIENTATION_SENSOR_270[] = "90";

And change this:

static integer_string_pair degress_to_exif_lut [] = {
// degrees, exif_orientation
{0, "1"},
{90, "6"},
{180, "3"},
{270, "8"},
};

from /camera/Encoder_libjpeg.cpp

to:

static integer_string_pair degress_to_exif_lut [] = {
// degrees, exif_orientation
{180, "1"},
{270, "6"},
{0, "3"},
{90, "8"},
};