Android:光感自动调节亮度

        展锐光感自动调节亮度功能,光感数据上报对应的背光亮度设置,其实其他平台像MTK,高通也差不多,大同小异,主要是搜索关键字:config_autoBrightnessLevels、config_screenBrightnessBacklight,就会发现只是文件路径不太一样。

        通过修改sensorhub下光感原始数据上报,或者根据实际情况去调节brightness level都能实现自动调节亮度功能的灵敏度,看个人喜欢。

展锐的代码路径如下:

device\sprd\roc1\common\overlay\frameworks\base\core\res\res\values\config.xml

    <!-- Array of light sensor LUX values to define our levels for auto backlight brightness support.
         The N entries of this array define N  1 zones as follows:

         Zone 0:        0 <= LUX < array[0]
         Zone 1:        array[0] <= LUX < array[1]
         ...
         Zone N:        array[N - 1] <= LUX < array[N]
         Zone N + 1     array[N] <= LUX < infinity

         Must be overridden in platform specific overlays -->
    <integer-array name="config_autoBrightnessLevels">
        <item>16</item>
        <item>32</item>
        <item>50</item>
        <item>100</item>
        <item>140</item>
        <item>180</item>
        <item>240</item>
        <item>300</item>
        <item>600</item>
        <item>800</item>
        <item>1000</item>
        <item>2000</item>
        <item>3000</item>
        <item>4000</item>
        <item>5000</item>
        <item>6000</item>
        <item>8000</item>
        <item>10000</item>
		<item>20000</item>
		<item>30000</item>
    </integer-array>
    <!-- Array of desired screen brightness in nits corresponding to the lux values
         in the config_autoBrightnessLevels array. As with config_screenBrightnessMinimumNits and
         config_screenBrightnessMaximumNits, the display brightness is defined as the measured
         brightness of an all-white image.

         If this is defined then:
            - config_autoBrightnessLcdBacklightValues should not be defined
            - config_screenBrightnessNits must be defined
            - config_screenBrightnessBacklight must be defined

         This array should have size one greater than the size of the config_autoBrightnessLevels
         array. The brightness values must be non-negative and non-decreasing. This must be
         overridden in platform specific overlays -->
    <array name="config_autoBrightnessDisplayValuesNits">
        <item>10.45935</item>   <!-- 0-16 -->
        <item>29.25559</item>   <!-- 16-32 -->
        <item>34.240692</item>  <!-- 32-50 -->
        <item>37.514347</item>  <!-- 50-100 -->
        <item>40.018696</item>  <!-- 100-140 -->
        <item>46.885098</item>  <!-- 140-180 -->
        <item>51.626434</item>  <!-- 180-240 -->
        <item>58.610405</item>  <!-- 240-300 -->
        <item>66.890915</item>  <!-- 300-600 -->
        <item>77.61644</item>   <!-- 600-800 -->
        <item>90.221886</item>  <!-- 800-1000 -->
        <item>105.80314</item>  <!-- 1000-2000 -->
        <item>126.073845</item> <!-- 2000-3000 -->
        <item>154.16931</item>  <!-- 3000-4000 -->
        <item>191.83717</item>  <!-- 4000-5000 -->
        <item>240.74442</item>  <!-- 5000-6000 -->
        <item>294.84857</item>  <!-- 6000-8000 -->
        <item>348.05453</item>  <!-- 8000-10000 -->
        <item>394.98703</item>  <!-- 10000-20000 -->
		<item>405.2315</item>  <!-- 20000-30000 -->
		<item>410.3658</item>  <!-- 30000+ -->
    </array>

    <!-- An array describing the screen's backlight values corresponding to the brightness
         values in the config_screenBrightnessNits array.

         This array should be equal in size to config_screenBrightnessBacklight. -->
    <integer-array name="config_screenBrightnessBacklight">
        <item>0</item>
        <item>5</item>
        <item>10</item>
        <item>15</item>
        <item>20</item>
        <item>25</item>
        <item>30</item>
        <item>35</item>
        <item>40</item>
        <item>45</item>
        <item>60</item>
        <item>75</item>
        <item>90</item>
        <item>105</item>
        <item>120</item>
        <item>135</item>
        <item>150</item>
        <item>165</item>
        <item>180</item>
        <item>195</item>
        <item>210</item>
        <item>225</item>
        <item>240</item>
        <item>255</item>
    </integer-array>

查看光感数据上报原始值节点:

cat /sys/devices/virtual/sprd_sensorhub/sensor_hub/raw_data_als

可以跟一下代码就会发现在kernel下:

kernel4.14\drivers\iio\sprd_hub\shub_core.c

static ssize_t raw_data_als_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{
	struct shub_data *sensor = dev_get_drvdata(dev);
	u8 data[2];
	u16 *ptr;
	int err;

	ptr = (u16 *)data;
	if (sensor->mcu_mode <= SHUB_OPDOWNLOAD) {
		dev_err(dev, "mcu_mode == SHUB_BOOT!\n");
		return -EINVAL;
	}

	err = shub_sipc_read(sensor,
			     SHUB_GET_LIGHT_RAWDATA_SUBTYPE, data, sizeof(data));
	if (err < 0) {
		dev_err(dev, "read RegMapR_GetLightRawData failed!\n");
		return err;
	}
	return sprintf(buf, "%d\n", ptr[0]);
}
static DEVICE_ATTR_RO(raw_data_als);

  • 5
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

leezs0614

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值