Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3628f45d authored by Rohit Sekhar's avatar Rohit Sekhar Committed by Mohammed Althaf T
Browse files

CameraController2: Expose QCFA Dimension for Fairphone

* This patch exposes the non Pixel binned 48 MP / 50 MP modes on FP4/FP5.
* This patch is generic & could be extended to any other applicable qcom device,
  but with the existing camera app logic, the default resolution would
  be the non pixel binned one, which is not a sane default.
* FP4/FP5 override default resolution with config_e_os_camera_default_resolution_lens.
parent adc83831
Loading
Loading
Loading
Loading
+17 −18
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public class CameraController2 extends CameraController {
    private final String cameraIdS; // ID string of logical camera
    private final String cameraIdSPhysical; // if non-null, ID string of underlying physical camera

    private final boolean is_fairphone_4;
    private final boolean is_fairphone;
    private final boolean is_samsung;
    private final boolean is_samsung_s7; // Galaxy S7 or Galaxy S7 Edge
    private final boolean is_samsung_galaxy_s;
@@ -2109,13 +2109,13 @@ public class CameraController2 extends CameraController {
        this.camera_error_cb = camera_error_cb;

        //this.is_oneplus = Build.MANUFACTURER.toLowerCase(Locale.US).contains("oneplus");
        this.is_fairphone_4 = Build.MODEL.toLowerCase(Locale.US).contains("fp4");
        this.is_fairphone = Build.MANUFACTURER.toLowerCase(Locale.US).contains("fairphone");
        this.is_samsung = Build.MANUFACTURER.toLowerCase(Locale.US).contains("samsung");
        this.is_samsung_s7 = Build.MODEL.toLowerCase(Locale.US).contains("sm-g93");
        this.is_samsung_galaxy_s = is_samsung && ( Build.MODEL.toLowerCase(Locale.US).contains("sm-g") || Build.MODEL.toLowerCase(Locale.US).contains("sm-s") );
        this.is_samsung_galaxy_f = is_samsung && Build.MODEL.toLowerCase(Locale.US).contains("sm-f");
        if( MyDebug.LOG ) {
            Log.d(TAG, "is_fairphone_4: " + is_fairphone_4);
            Log.d(TAG, "is_fairphone: " + is_fairphone);
            Log.d(TAG, "is_samsung: " + is_samsung);
            Log.d(TAG, "is_samsung_s7: " + is_samsung_s7);
            Log.d(TAG, "is_samsung_galaxy_s: " + is_samsung_galaxy_s);
@@ -3075,24 +3075,23 @@ public class CameraController2 extends CameraController {
            }
        }

        if (is_fairphone_4 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            CameraCharacteristics.Key<int[]> fairphoneAvailableStreamConfigurations =
                    new CameraCharacteristics.Key<>("fp.scaler.availableStreamConfigurations", int[].class);
            int[] fpStreamConfigs = characteristics.get(fairphoneAvailableStreamConfigurations);

            for (int i = 0; i < fpStreamConfigs.length / 4; i++) {
                int width = fpStreamConfigs[i * 4 + 1];
                int height = fpStreamConfigs[i * 4 + 2];
                int output = fpStreamConfigs[i * 4 + 3];

                if (output != 0) {
                    Size size = new Size(width, height);
                    if (!camera_features.picture_sizes.contains(size)) {
        if(is_fairphone && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
            CameraCharacteristics.Key<int[]> qcfaDimensionKey =
                    new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.quadra_cfa.qcfa_dimension", int[].class);
            try {
                int[] qcfaDimension = characteristics.get(qcfaDimensionKey);
                if (qcfaDimension != null && qcfaDimension.length == 2) {
                    int qcfaWidth = qcfaDimension[0];
                    int qcfaHeight = qcfaDimension[1];
                    Size qcfaSize = new Size(qcfaWidth, qcfaHeight);
                    if (!camera_features.picture_sizes.contains(qcfaSize)) {
                        if (MyDebug.LOG)
                            Log.d(TAG, "custom scaler size: " + height + " x " + width);
                        camera_features.picture_sizes.add(size);
                            Log.d(TAG, "Adding QCFA size: " + qcfaWidth + " x " + qcfaHeight);
                        camera_features.picture_sizes.add(qcfaSize);
                    }
                }
            } catch (IllegalArgumentException e) {
              e.printStackTrace();
            }
        }