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

Commit 1638fd12 authored by Xu Han's avatar Xu Han
Browse files

hal: configure the path for flicker sensor

Flicker sensor / rainbow sensor is connected to audio codec
on SDM845.

This change configures how the flicker sensor data
is rounted from AMIC1 to HAL. It has no impact on power consumption.

Camera HAL uses pcm_read to enable the the data path in camera use cases.

Bug: 77698944
Test: audio recording and playback
Change-Id: I8a776d7b3c13c7350875d7e7f024afdf632f3d8d
parent 9954631a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -132,6 +132,10 @@ ifeq ($(strip $(AUDIO_FEATURE_SUPPORTED_EXTERNAL_BT)),true)
    LOCAL_CFLAGS += -DEXTERNAL_BT_SUPPORTED
endif

ifeq ($(strip $(AUDIO_FEATURE_FLICKER_SENSOR_INPUT)),true)
    LOCAL_CFLAGS += -DFLICKER_SENSOR_INPUT
endif

ifeq ($(strip $(AUDIO_FEATURE_NO_AUDIO_OUT)),true)
    LOCAL_CFLAGS += -DNO_AUDIO_OUT
endif
+42 −0
Original line number Diff line number Diff line
@@ -1312,6 +1312,44 @@ platform_backend_app_type_cfg_init(struct platform_data *pdata,
    return 0;
}

static void configure_flicker_sensor_input(struct mixer *mixer)
{
    struct mixer_ctl *ctl;
    const char* ctl1 = "AIF3_CAP Mixer SLIM TX2";
    int setting1 = 1;
    const char* ctl2 = "CDC_IF TX2 MUX";
    const char* setting2 = "DEC2";
    const char* ctl3 = "SLIM_1_TX Channels";
    const char* setting3 = "One";
    const char* ctl4 = "ADC MUX2";
    const char* setting4 = "AMIC";
    const char* ctl5 = "AMIC MUX2";
    const char* setting5 = "ADC1";
    const char* ctl6 = "DEC2 Volume";
    int setting6 = 84;
    const char* ctl7 = "MultiMedia2 Mixer SLIM_1_TX";
    int setting7 = 1;
    const char* ctl8 = "SLIM_1_TX SampleRate";
    const char* setting8 = "KHZ_8";

    ctl = mixer_get_ctl_by_name(mixer, ctl1);
    mixer_ctl_set_value(ctl, 0, setting1);
    ctl = mixer_get_ctl_by_name(mixer, ctl2);
    mixer_ctl_set_enum_by_string(ctl, setting2);
    ctl = mixer_get_ctl_by_name(mixer, ctl3);
    mixer_ctl_set_enum_by_string(ctl, setting3);
    ctl = mixer_get_ctl_by_name(mixer, ctl4);
    mixer_ctl_set_enum_by_string(ctl, setting4);
    ctl = mixer_get_ctl_by_name(mixer, ctl5);
    mixer_ctl_set_enum_by_string(ctl, setting5);
    ctl = mixer_get_ctl_by_name(mixer, ctl6);
    mixer_ctl_set_value(ctl, 0, setting6);
    ctl = mixer_get_ctl_by_name(mixer, ctl7);
    mixer_ctl_set_value(ctl, 0, setting7);
    ctl = mixer_get_ctl_by_name(mixer, ctl8);
    mixer_ctl_set_enum_by_string(ctl, setting8);
}

void *platform_init(struct audio_device *adev)
{
    char value[PROPERTY_VALUE_MAX];
@@ -1523,6 +1561,10 @@ void *platform_init(struct audio_device *adev)
            ALOGV("%s: Could not find the symbol acdb_loader_send_gain_dep_cal from %s",
                  __func__, LIB_ACDB_LOADER);

#if defined (FLICKER_SENSOR_INPUT)
        configure_flicker_sensor_input(adev->mixer);
#endif

#if defined (PLATFORM_MSM8994) || (PLATFORM_MSM8996) || (PLATFORM_MSM8998) || (PLATFORM_SDM845)
        acdb_init_v2_cvd_t acdb_init_local;
        acdb_init_local = (acdb_init_v2_cvd_t)dlsym(my_data->acdb_handle,