[Q] How disable VSync - Optimus One, P500, V General

How can I disable VSync on Franco Froyo kernel?

drivers/video/msm/mddi_hitachi_hvga.c
pinfo->lcd.vsync_enable = FALSE;
pinfo->lcd.hw_vsync_mode = FALSE;

Related

Charge Paused, too high or too low temperature

Hi,
I have same problem than Samsung Galaxy Tab with the battery sensor, well not exactly the same problem, my battery sensor is broke and always show -7 degrees celsius so what i want to do is patch the kernel, but i need a bit of help compiling it. I've downloaded the kernel source from samsung repository but i really don't know how to compile my patch, (i'm from java ) and long time ago that i don't compile nothing made on c++. Could some1 guide me?
Thx!
The patch is this:
static int sec_bat_check_temper(struct sec_bat_info *info)
{
struct power_supply *psy
= power_supply_get_by_name(info->fuel_gauge_name);
union power_supply_propval value;
int ret;
int temp;
int temp_adc = s3c_read_temper_adc(info);
int health = info->batt_health;
int low = 0;
int high = 0;
int mid = 0;
calculate_average_adc(info, &info->temper_adc_sample, temp_adc);
if (!info->adc_table || !info->adc_arr_size) {
/* using fake temp */
temp = 300;
info->batt_temp = temp;
return temp;
}
high = info->adc_arr_size - 1;
while (low <= high) {
mid = (low + high) / 2;
if (info->adc_table[mid].adc > temp_adc)
high = mid - 1;
else if (info->adc_table[mid].adc < temp_adc)
low = mid + 1;
else
break;
}
temp = info->adc_table[mid].temperature;
info->batt_temp = temp;
if (temp >= HIGH_BLOCK_TEMP) {
if (health != POWER_SUPPLY_HEALTH_OVERHEAT &&
health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE)
if (info->batt_temp_high_cnt < TEMP_BLOCK_COUNT)
info->batt_temp_high_cnt++;
dev_info(info->dev, "%s: high count = %d\n",
__func__, info->batt_temp_high_cnt);
} else if (temp <= HIGH_RECOVER_TEMP && temp >= LOW_RECOVER_TEMP) {
if (health == POWER_SUPPLY_HEALTH_OVERHEAT ||
health == POWER_SUPPLY_HEALTH_COLD)
if (info->batt_temp_recover_cnt < TEMP_BLOCK_COUNT)
info->batt_temp_recover_cnt++;
dev_info(info->dev, "%s: recovery count = %d\n",
__func__, info->batt_temp_recover_cnt);
} else if (temp <= LOW_BLOCK_TEMP) {
if (health != POWER_SUPPLY_HEALTH_COLD &&
health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE)
if (info->batt_temp_low_cnt < TEMP_BLOCK_COUNT)
info->batt_temp_low_cnt++;
dev_info(info->dev, "%s: low count = %d\n",
__func__, info->batt_temp_low_cnt);
} else {
info->batt_temp_high_cnt = 0;
info->batt_temp_low_cnt = 0;
info->batt_temp_recover_cnt = 0;
}
if (info->batt_temp_high_cnt >= TEMP_BLOCK_COUNT)
info->batt_health = POWER_SUPPLY_HEALTH_OVERHEAT;
else if (info->batt_temp_low_cnt >= TEMP_BLOCK_COUNT)
info->batt_health = POWER_SUPPLY_HEALTH_COLD;
else if (info->batt_temp_recover_cnt >= TEMP_BLOCK_COUNT)
info->batt_health = POWER_SUPPLY_HEALTH_GOOD;
/* Set temperature to fuel gauge */
if (info->fuel_gauge_name) {
value.intval = info->batt_temp / 10;
ret = psy->set_property(psy, POWER_SUPPLY_PROP_TEMP, &value);
if (ret) {
dev_err(info->dev, "%s: fail to set temperature(%d)\n",
__func__, ret);
}
}
dev_info(info->dev, "%s: temp=%d, adc=%d\n", __func__, temp, temp_adc);
return temp;
}
on this method i will return always 30ºC
you are on the right track, but the specifics of your patch arent really the issue. what you have to do first is setup a build environment to compile the kernel. for this you must use ubuntu 10. i setup a virtual machine, installed ubuntu, then sync the source code repository. then do a test compile. when it works, then you change the code you want, and compile and get out any errors. then flash that new kernel to your device.
i made a battery driver patch for a different phone doing similar to what you want. you just have to go to the dev section and get your build envirnment going first.
Hey, I'm sorry for reviving this old Thread, but has the OP any news if he was successful with this patch?
I'm having the same problems with my Note II that I described in this thread :
http://forum.xda-developers.com/showthread.php?t=2503553
I have tried everything even a different battery, but was no use.
I want to patch the part of the Kernel or w/e controls the reading of the temperature to ignore it so I can charge and use my phone normally.
Anyone might help?
juanitolol said:
Hi,
I have same problem than Samsung Galaxy Tab with the battery sensor, well not exactly the same problem, my battery sensor is broke and always show -7 degrees celsius so what i want to do is patch the kernel, but i need a bit of help compiling it. I've downloaded the kernel source from samsung repository but i really don't know how to compile my patch, (i'm from java ) and long time ago that i don't compile nothing made on c++. Could some1 guide me?
Thx!
The patch is this:
static int sec_bat_check_temper(struct sec_bat_info *info)
{
struct power_supply *psy
= power_supply_get_by_name(info->fuel_gauge_name);
union power_supply_propval value;
int ret;
int temp;
int temp_adc = s3c_read_temper_adc(info);
int health = info->batt_health;
int low = 0;
int high = 0;
int mid = 0;
calculate_average_adc(info, &info->temper_adc_sample, temp_adc);
if (!info->adc_table || !info->adc_arr_size) {
/* using fake temp */
temp = 300;
info->batt_temp = temp;
return temp;
}
high = info->adc_arr_size - 1;
while (low <= high) {
mid = (low + high) / 2;
if (info->adc_table[mid].adc > temp_adc)
high = mid - 1;
else if (info->adc_table[mid].adc < temp_adc)
low = mid + 1;
else
break;
}
temp = info->adc_table[mid].temperature;
info->batt_temp = temp;
if (temp >= HIGH_BLOCK_TEMP) {
if (health != POWER_SUPPLY_HEALTH_OVERHEAT &&
health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE)
if (info->batt_temp_high_cnt < TEMP_BLOCK_COUNT)
info->batt_temp_high_cnt++;
dev_info(info->dev, "%s: high count = %d\n",
__func__, info->batt_temp_high_cnt);
} else if (temp <= HIGH_RECOVER_TEMP && temp >= LOW_RECOVER_TEMP) {
if (health == POWER_SUPPLY_HEALTH_OVERHEAT ||
health == POWER_SUPPLY_HEALTH_COLD)
if (info->batt_temp_recover_cnt < TEMP_BLOCK_COUNT)
info->batt_temp_recover_cnt++;
dev_info(info->dev, "%s: recovery count = %d\n",
__func__, info->batt_temp_recover_cnt);
} else if (temp <= LOW_BLOCK_TEMP) {
if (health != POWER_SUPPLY_HEALTH_COLD &&
health != POWER_SUPPLY_HEALTH_UNSPEC_FAILURE)
if (info->batt_temp_low_cnt < TEMP_BLOCK_COUNT)
info->batt_temp_low_cnt++;
dev_info(info->dev, "%s: low count = %d\n",
__func__, info->batt_temp_low_cnt);
} else {
info->batt_temp_high_cnt = 0;
info->batt_temp_low_cnt = 0;
info->batt_temp_recover_cnt = 0;
}
if (info->batt_temp_high_cnt >= TEMP_BLOCK_COUNT)
info->batt_health = POWER_SUPPLY_HEALTH_OVERHEAT;
else if (info->batt_temp_low_cnt >= TEMP_BLOCK_COUNT)
info->batt_health = POWER_SUPPLY_HEALTH_COLD;
else if (info->batt_temp_recover_cnt >= TEMP_BLOCK_COUNT)
info->batt_health = POWER_SUPPLY_HEALTH_GOOD;
/* Set temperature to fuel gauge */
if (info->fuel_gauge_name) {
value.intval = info->batt_temp / 10;
ret = psy->set_property(psy, POWER_SUPPLY_PROP_TEMP, &value);
if (ret) {
dev_err(info->dev, "%s: fail to set temperature(%d)\n",
__func__, ret);
}
}
dev_info(info->dev, "%s: temp=%d, adc=%d\n", __func__, temp, temp_adc);
return temp;
}
on this method i will return always 30ºC
Click to expand...
Click to collapse

[Q] Why has settings stopped working because of this code?

PackageManager pm = getPackageManager();
ComponentName cn1 = new ComponentName("com.modset.launcher",
"com.modset.launcher.LauncherAlias1");
ComponentName cn2 = new ComponentName("com.modset.launcher",
"com.modset.launcher.LauncherAlias2");
int dis = PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
if (pm.getComponentEnabledSetting(cn1) == dis)
dis = 3 - dis;
pm.setComponentEnabledSetting(cn1, dis,
PackageManager.DONT_KILL_APP);
pm.setComponentEnabledSetting(cn2, 3 - dis,
PackageManager.DONT_KILL_APP);

Camera real time image processing

I need to do some image processing in real time on mobile. I am using camera2 library. I managed to put camera preview directly on surfaceView but when i redirect it to ImageReader to do something with frames before i preview them it goes really slow, and there is not even processing just taking Y value from YUV_420_888 and converting it to gray picture in ARGB_8888 format. Code is below. For that one for loop i need about 600ms. And for image processing i will need to go trough that image at least one more time. In Bits array i form ARGB_8888 format out of Y array which is Y value of YUV_420_888 format. I test it on phone with Quad Core 1ghz processor and 1gb ram. Is there any way to speed this code up so i can go lets say 2-3 times trough picture and have at least 7-10 fps? If i delete for loop and just measure fps its 8-12fps. Why is it so slow compering to 25fps when i put it directly on surfaceView?
Code:
private final CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() {
@Override
public void onOpened(@NonNull CameraDevice cameraDevice) {
// This method is called when the camera is opened. We start camera preview here.
mCameraOpenCloseLock.release();
mCameraDevice = cameraDevice;
createCameraPreviewSession();
mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
Image image = reader.acquireLatestImage();
if(image != null) {
ByteBuffer buffer0 = image.getPlanes()[0].getBuffer();
byte[] Y = new byte[buffer0.remaining()];
buffer0.get(Y);
byte[] Bits = new byte[Y.length*4]; //That's where the RGBA array goes.
int Ylength = Y.length;
for (int i = 0; i < Ylength; i++) {
int i1 = i*4;
Bits[i1] =Y[i];
Bits[i1 + 1] =Y[i];
Bits[i1 + 2] = Y[i];
Bits[i1 + 3] = -1;//0xff, that's the alpha.
}
Bitmap bm = Bitmap.createBitmap(image.getWidth(), image.getHeight(), Bitmap.Config.ARGB_8888);
bm.copyPixelsFromBuffer(ByteBuffer.wrap(Bits));
Bitmap scaled = Bitmap.createScaledBitmap(bm, surfaceView.getWidth(), surfaceView.getHeight(), true);
Canvas c;
c = surfaceHolder.lockCanvas();
c.drawBitmap(scaled, 0, 0, null);
surfaceHolder.unlockCanvasAndPost(c);
image.close();
time2 = System.nanoTime();
Log.d("Vreme",Double.toString(1000000000/(time2-time1))+"fps");
time1 = System.nanoTime();
}
}
},mBackgroundHandler);
}
@Override
public void onDisconnected(@NonNull CameraDevice cameraDevice) {
mCameraOpenCloseLock.release();
cameraDevice.close();
mCameraDevice = null;
}
@Override
public void onError(@NonNull CameraDevice cameraDevice, int error) {
mCameraOpenCloseLock.release();
cameraDevice.close();
mCameraDevice = null;
}
};

Video Encryption Decryption takes too much time

This is code for encryption of video
FileInputStream fis = new FileInputStream(extStore+"/digilearn/try.mp4");
FileOutputStream fos = new FileOutputStream(extStore+"/digilearn/enctry.mp4");
SecretKeySpec sks = new SecretKeySpec("MyDifficultPassw".getBytes(),
"AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.ENCRYPT_MODE, sks);
CipherOutputStream cos = new CipherOutputStream(fos, cipher);
int b;
byte[] d = new byte[8192];
while ((b = fis.read(d)) != -1) {
cos.write(d, 0, b);
}
// Flush and close streams.
cos.flush();
cos.close();
fis.close();
This is the code for decryption of video
File extStore = Environment.getExternalStorageDirectory();
FileInputStream fis = new FileInputStream(extStore+"/digilearn/enctry.mp4");
FileOutputStream fos = new FileOutputStream(extStore+"/digilearn/dectry.mp4");
SecretKeySpec sks = new SecretKeySpec("MyDifficultPassw".getBytes(),
"AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, sks);
CipherInputStream cis = new CipherInputStream(fis, cipher);
int b;
byte[] d = new byte[2*8192];
while ((b = cis.read(d)) != -1) {
fos.write(d, 0, b);
}
fos.flush();
fos.close();
cis.close();
with above code encryption and decryption both works but it take too much time when encrypted video file from sd card with video size is 1 GB.

Android VideoView Resize Algorithm - Bilinear or Bicubic?

Hi, community,
I was trying to resize a video to be played on Google Pixel 5 to fit the screen. I am able to achieve the required but I need to dig a bit deeper to understand the functioning under the hood. I want to understand if the resizing is happening on hardware or software? Also, what is the algorithm used in the resizing operation whether it is bilinear or bicubic or Lanczos or anything else?
Java:
public void setVideo(String id)
{
System.out.println("Starting video");
System.out.println(id);
String videoPath = Environment.getExternalStorageDirectory().getPath()+"/"+ id;
videoView.setVideoPath(videoPath);
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int screenWidth = metrics.widthPixels;
int screenHeight = metrics.heightPixels;
float screenProportion = (float) screenWidth / (float) screenHeight;
android.view.ViewGroup.LayoutParams lp = videoView.getLayoutParams();
int VideoWidth = mp.getVideoWidth();
int VideoHeight = mp.getVideoHeight();
float videoProportion = (float) VideoWidth / (float) VideoHeight;
if (videoProportion > screenProportion) {
lp.width = screenWidth;
lp.height = (int) ((float) screenWidth / videoProportion);
} else {
lp.width = (int) (videoProportion * (float) screenHeight);
lp.height = screenHeight;
}
videoView.setLayoutParams(lp);
}
});
videoView.start();

Categories

Resources