Skip to content

Commit

Permalink
konabess: Add support for sd7g1
Browse files Browse the repository at this point in the history
* Also apply 100 letter wraps.
  • Loading branch information
libxzr committed Mar 6, 2023
1 parent c21677b commit d226fc9
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 95 deletions.
63 changes: 52 additions & 11 deletions app/src/main/java/xzr/konabess/ChipInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum type {
waipio_singleBin,
cape_singleBin,
kalama,
diwali,
unknown
}

Expand All @@ -31,7 +32,7 @@ public static boolean shouldIgnoreVoltTable(type type) {
return type == ChipInfo.type.lahaina || type == ChipInfo.type.lahaina_singleBin
|| type == ChipInfo.type.shima || type == ChipInfo.type.yupik
|| type == ChipInfo.type.waipio_singleBin || type == ChipInfo.type.cape_singleBin
|| type == ChipInfo.type.kalama;
|| type == ChipInfo.type.kalama || type == ChipInfo.type.diwali;
}

public static boolean checkChipGeneral(type input) {
Expand Down Expand Up @@ -78,6 +79,8 @@ public static String name2chipdesc(type t, Activity activity) {
return activity.getResources().getString(R.string.sd8g1p_singlebin);
case kalama:
return activity.getResources().getString(R.string.sd8g2);
case diwali:
return activity.getResources().getString(R.string.sd7g1);
}
return activity.getResources().getString(R.string.unknown);
}
Expand Down Expand Up @@ -108,6 +111,8 @@ else if (ChipInfo.which == type.cape_singleBin)
return rpmh_levels_cape.levels;
else if (ChipInfo.which == type.kalama)
return rpmh_levels_kalama.levels;
else if (ChipInfo.which == type.diwali)
return rpmh_levels_diwali.levels;

return new int[]{};
}
Expand Down Expand Up @@ -135,13 +140,16 @@ else if (ChipInfo.which == type.cape_singleBin)
return rpmh_levels_cape.level_str;
else if (ChipInfo.which == type.kalama)
return rpmh_levels_kalama.level_str;
else if (ChipInfo.which == type.diwali)
return rpmh_levels_diwali.level_str;

return new String[]{};
}
}

private static class rpmh_levels_kona {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320, 336, 352, 384, 400, 416};
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand Down Expand Up @@ -206,7 +214,8 @@ private static class rpmh_levels_msmnile {
}

private static class rpmh_levels_lahaina {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320, 336, 352, 384, 400, 416, 432, 448, 464};
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416, 432, 448, 464};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand All @@ -232,7 +241,8 @@ private static class rpmh_levels_lahaina {
}

private static class rpmh_levels_lahaina_singleBin {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320, 336, 352, 384, 400, 416};
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand All @@ -255,7 +265,8 @@ private static class rpmh_levels_lahaina_singleBin {
}

private static class rpmh_levels_lito {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320, 336, 352, 384, 400, 416};
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand All @@ -278,7 +289,8 @@ private static class rpmh_levels_lito {
}

private static class rpmh_levels_lagoon {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320, 336, 352, 384, 400, 416};
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand All @@ -301,7 +313,8 @@ private static class rpmh_levels_lagoon {
}

private static class rpmh_levels_shima {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320, 336, 352, 384, 400, 416};
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand All @@ -324,7 +337,8 @@ private static class rpmh_levels_shima {
}

private static class rpmh_levels_yupik {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320, 336, 352, 384, 400, 416};
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand All @@ -347,7 +361,8 @@ private static class rpmh_levels_yupik {
}

private static class rpmh_levels_waipio {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320, 336, 352, 384, 400, 416};
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand All @@ -370,7 +385,32 @@ private static class rpmh_levels_waipio {
}

private static class rpmh_levels_cape {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320, 336, 352, 384, 400, 416};
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
"LOW_SVS_D1",
"LOW_SVS",
"LOW_SVS_L1",
"LOW_SVS_L2",
"SVS",
"SVS_L0",
"SVS_L1",
"SVS_L2",
"NOM",
"NOM_L1",
"NOM_L2",
"NOM_L3",
"TURBO",
"TURBO_L0",
"TURBO_L1"
};
}

private static class rpmh_levels_diwali {
public static final int[] levels = {16, 48, 56, 64, 80, 96, 128, 144, 192, 224, 256, 320,
336, 352, 384, 400, 416};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand All @@ -393,7 +433,8 @@ private static class rpmh_levels_cape {
}

private static class rpmh_levels_kalama {
public static final int[] levels = {16, 48, 52, 56, 60, 64, 72, 80, 96, 128, 144, 192, 224, 256, 288, 320, 336, 384, 400, 416, 432, 448, 464, 480};
public static final int[] levels = {16, 48, 52, 56, 60, 64, 72, 80, 96, 128, 144, 192,
224, 256, 288, 320, 336, 384, 400, 416, 432, 448, 464, 480};
public static final String[] level_str = {
"RETENTION",
"MIN_SVS",
Expand Down
58 changes: 39 additions & 19 deletions app/src/main/java/xzr/konabess/GpuTableEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static void init() throws IOException {
lines_in_dts = new ArrayList<>();
bins = new ArrayList<>();
bin_position = -1;
BufferedReader bufferedReader = new BufferedReader(new FileReader(new File(KonaBessCore.dts_path)));
BufferedReader bufferedReader =
new BufferedReader(new FileReader(new File(KonaBessCore.dts_path)));
String s;
while ((s = bufferedReader.readLine()) != null) {
lines_in_dts.add(s);
Expand Down Expand Up @@ -82,7 +83,8 @@ public static void decode() throws Exception {
|| ChipInfo.which == ChipInfo.type.lagoon
|| ChipInfo.which == ChipInfo.type.shima
|| ChipInfo.which == ChipInfo.type.yupik
|| ChipInfo.which == ChipInfo.type.kalama)
|| ChipInfo.which == ChipInfo.type.kalama
|| ChipInfo.which == ChipInfo.type.diwali)
&& this_line.contains("qcom,gpu-pwrlevels-")) {
start = i;
if (bin_position < 0)
Expand All @@ -106,7 +108,8 @@ public static void decode() throws Exception {
|| ChipInfo.which == ChipInfo.type.lagoon
|| ChipInfo.which == ChipInfo.type.shima
|| ChipInfo.which == ChipInfo.type.yupik
|| ChipInfo.which == ChipInfo.type.kalama)) {
|| ChipInfo.which == ChipInfo.type.kalama
|| ChipInfo.which == ChipInfo.type.diwali)) {
end = i;
if (end >= start) {
decode_bin(lines_in_dts.subList(start, end + 1));
Expand Down Expand Up @@ -215,7 +218,8 @@ public static List<String> genTable() {
|| ChipInfo.which == ChipInfo.type.lagoon
|| ChipInfo.which == ChipInfo.type.shima
|| ChipInfo.which == ChipInfo.type.yupik
|| ChipInfo.which == ChipInfo.type.kalama) {
|| ChipInfo.which == ChipInfo.type.kalama
|| ChipInfo.which == ChipInfo.type.diwali) {
for (int bin_id = 0; bin_id < bins.size(); bin_id++) {
lines.add("qcom,gpu-pwrlevels-" + bins.get(bin_id).id + " {");
lines.addAll(bins.get(bin_id).header);
Expand Down Expand Up @@ -267,10 +271,12 @@ private static String generateSubtitle(String line) throws Exception {
if ("qcom,level".equals(raw_name) || "qcom,cx-level".equals(raw_name)) {
return GpuVoltEditor.levelint2str(DtsHelper.decode_int_line(line).value);
}
return DtsHelper.shouldUseHex(line) ? DtsHelper.decode_hex_line(line).value : DtsHelper.decode_int_line(line).value + "";
return DtsHelper.shouldUseHex(line) ? DtsHelper.decode_hex_line(line).value :
DtsHelper.decode_int_line(line).value + "";
}

private static void generateALevel(Activity activity, int last, int levelid, LinearLayout page) throws Exception {
private static void generateALevel(Activity activity, int last, int levelid,
LinearLayout page) throws Exception {
((MainActivity) activity).onBackPressedListener = new MainActivity.onBackPressedListener() {
@Override
public void onBackPressed() {
Expand All @@ -291,7 +297,8 @@ public void onBackPressed() {

for (String line : bins.get(last).levels.get(levelid).lines) {
items.add(new ParamAdapter.item() {{
title = KonaBessStr.convert_level_params(DtsHelper.decode_hex_line(line).name, activity);
title = KonaBessStr.convert_level_params(DtsHelper.decode_hex_line(line).name,
activity);
subtitle = generateSubtitle(line);
}});
}
Expand All @@ -302,15 +309,21 @@ public void onBackPressed() {
generateLevels(activity, last, page);
return;
}
String raw_name = DtsHelper.decode_hex_line(bins.get(last).levels.get(levelid).lines.get(position - 1)).name;
String raw_value = DtsHelper.shouldUseHex(bins.get(last).levels.get(levelid).lines.get(position - 1))
? DtsHelper.decode_hex_line(bins.get(last).levels.get(levelid).lines.get(position - 1)).value
: DtsHelper.decode_int_line(bins.get(last).levels.get(levelid).lines.get(position - 1)).value + "";
String raw_name =
DtsHelper.decode_hex_line(bins.get(last).levels.get(levelid).lines.get(position - 1)).name;
String raw_value =
DtsHelper.shouldUseHex(bins.get(last).levels.get(levelid).lines.get(position - 1))
?
DtsHelper.decode_hex_line(bins.get(last).levels.get(levelid).lines.get(position - 1)).value
:
DtsHelper.decode_int_line(bins.get(last).levels.get(levelid).lines.get(position - 1)).value + "";

if (raw_name.equals("qcom,level") || raw_name.equals("qcom,cx-level")) {
try {
Spinner spinner = new Spinner(activity);
spinner.setAdapter(new ArrayAdapter(activity, android.R.layout.simple_dropdown_item_1line, ChipInfo.rpmh_levels.level_str()));
spinner.setAdapter(new ArrayAdapter(activity,
android.R.layout.simple_dropdown_item_1line,
ChipInfo.rpmh_levels.level_str()));
spinner.setSelection(GpuVoltEditor.levelint2int(Integer.parseInt(raw_value)));

new AlertDialog.Builder(activity)
Expand All @@ -321,9 +334,11 @@ public void onBackPressed() {
try {
bins.get(last).levels.get(levelid).lines.set(
position - 1,
DtsHelper.encodeIntOrHexLine(raw_name, ChipInfo.rpmh_levels.levels()[spinner.getSelectedItemPosition()] + ""));
DtsHelper.encodeIntOrHexLine(raw_name,
ChipInfo.rpmh_levels.levels()[spinner.getSelectedItemPosition()] + ""));
generateALevel(activity, last, levelid, page);
Toast.makeText(activity, R.string.save_success, Toast.LENGTH_SHORT).show();
Toast.makeText(activity, R.string.save_success,
Toast.LENGTH_SHORT).show();
} catch (Exception exception) {
DialogUtil.showError(activity, R.string.save_failed);
exception.printStackTrace();
Expand All @@ -337,7 +352,8 @@ public void onBackPressed() {
}
} else {
EditText editText = new EditText(activity);
editText.setInputType(DtsHelper.shouldUseHex(raw_name) ? InputType.TYPE_CLASS_TEXT : InputType.TYPE_CLASS_NUMBER);
editText.setInputType(DtsHelper.shouldUseHex(raw_name) ?
InputType.TYPE_CLASS_TEXT : InputType.TYPE_CLASS_NUMBER);
editText.setText(raw_value);
new AlertDialog.Builder(activity)
.setTitle(activity.getResources().getString(R.string.edit) + " \"" + items.get(position).title + "\"")
Expand All @@ -347,9 +363,11 @@ public void onBackPressed() {
try {
bins.get(last).levels.get(levelid).lines.set(
position - 1,
DtsHelper.encodeIntOrHexLine(raw_name, editText.getText().toString()));
DtsHelper.encodeIntOrHexLine(raw_name,
editText.getText().toString()));
generateALevel(activity, last, levelid, page);
Toast.makeText(activity, R.string.save_success, Toast.LENGTH_SHORT).show();
Toast.makeText(activity, R.string.save_success,
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
DialogUtil.showError(activity, R.string.save_failed);
}
Expand Down Expand Up @@ -515,7 +533,8 @@ public static int min_level_chip_offset() throws Exception {
|| ChipInfo.which == ChipInfo.type.shima || ChipInfo.which == ChipInfo.type.yupik
|| ChipInfo.which == ChipInfo.type.waipio_singleBin
|| ChipInfo.which == ChipInfo.type.cape_singleBin
|| ChipInfo.which == ChipInfo.type.kalama)
|| ChipInfo.which == ChipInfo.type.kalama
|| ChipInfo.which == ChipInfo.type.diwali)
return 1;
if (ChipInfo.which == ChipInfo.type.kona || ChipInfo.which == ChipInfo.type.kona_singleBin
|| ChipInfo.which == ChipInfo.type.msmnile || ChipInfo.which == ChipInfo.type.msmnile_singleBin
Expand Down Expand Up @@ -728,7 +747,8 @@ public void run() {
decode();
patch_throttle_level();
} catch (Exception e) {
activity.runOnUiThread(() -> DialogUtil.showError(activity, R.string.getting_freq_table_failed));
activity.runOnUiThread(() -> DialogUtil.showError(activity,
R.string.getting_freq_table_failed));
}

activity.runOnUiThread(() -> {
Expand Down
Loading

0 comments on commit d226fc9

Please sign in to comment.