Ejemplo n.º 1
0
// Get rows from other half over i2c
bool transport_master(matrix_row_t matrix[]) {
  i2c_readReg(SLAVE_I2C_ADDRESS, I2C_KEYMAP_START, (void *)matrix, sizeof(i2c_buffer->smatrix), TIMEOUT);

  // write backlight info
#  ifdef BACKLIGHT_ENABLE
  uint8_t level = get_backlight_level();
  if (level != i2c_buffer->backlight_level) {
    if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_BACKLIGHT_START, (void *)&level, sizeof(level), TIMEOUT) >= 0) {
      i2c_buffer->backlight_level = level;
    }
  }
#  endif

#  if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_SPLIT)
  if (rgblight_get_change_flags()) {
    rgblight_syncinfo_t rgblight_sync;
    rgblight_get_syncinfo(&rgblight_sync);
    if (i2c_writeReg(SLAVE_I2C_ADDRESS, I2C_RGB_START,
                     (void *)&rgblight_sync, sizeof(rgblight_sync), TIMEOUT) >= 0) {
      rgblight_clear_change_flags();
    }
  }
#  endif

#  ifdef ENCODER_ENABLE
  i2c_readReg(SLAVE_I2C_ADDRESS, I2C_ENCODER_START, (void *)i2c_buffer->encoder_state, sizeof(I2C_slave_buffer_t.encoder_state), TIMEOUT);
  encoder_update_raw(i2c_buffer->encoder_state);
#  endif

  return true;
}
Ejemplo n.º 2
0
static int update_brightness(int brightness)
{
	int backlightlevel;

	backlightlevel = get_backlight_level(brightness);

	return 0;
}
Ejemplo n.º 3
0
int CABL::Notify(uint32_t notification_type) {
    int32_t ret = 0;
    LOGD_IF(mDebug, "Starting %s ", __func__);
    pthread_mutex_lock(&mCABLLock);
    if (mHistStatus == 0 && (notification_type == NOTIFY_TYPE_BL_UPDATE || notification_type == NOTIFY_TYPE_UPDATE)) {
        uint32_t level = get_backlight_level();
        if (level <= mOEMParams.bl_min_level) {
            LOGE_IF(mDebug, "New BL level %d lower than min level %u,"
                    " Skip this update for calc",
                    level, mOEMParams.bl_min_level);
            if (mPrevNotify == NOTIFY_TYPE_SUSPEND)
                ret = -1;
            goto exit_early;
        }
        if (eStatus == CABL_OFF) {
            pthread_mutex_unlock(&mCABLLock);
            return ret;
        }
        LOGD_IF(mDebug, "Start notification received, start histogram");
        ret = startHistogram();
        if (0 == ret) {
            mHistStatus = 1;
            pthread_cond_signal(&mCABLCond);
        }
    } else if (mHistStatus == 1 &&
        (notification_type == NOTIFY_TYPE_SUSPEND ||
        notification_type == NOTIFY_TYPE_NO_UPDATE)) {
        LOGD_IF(mDebug, "Stop notification received, stop histogram");
        if(!stopHistogram(mHistStatus))
            mHistStatus = 0;
        if (notification_type == NOTIFY_TYPE_SUSPEND)
            abl_reset_history();

    }

    if (notification_type == NOTIFY_TYPE_BL_UPDATE) {
        if (mRefresher) {
            mRefresher->Control(1);
            LOGE_IF(mDebug, "Calling refresh()");
            mRefresher->Refresh(1, 16);
            mRefresher->Control(0);
        }
    }
exit_early:
    mPrevNotify = notification_type;
    pthread_mutex_unlock(&mCABLLock);
    return ret;
}
Ejemplo n.º 4
0
static int update_brightness(int brightness)
{
	int backlightlevel;

	backlightlevel = get_backlight_level(brightness);

	while (s5p_mipi_dsi_wr_data(dsim_base, MIPI_DSI_DCS_LONG_WRITE,
			(unsigned int)gamma22_table[backlightlevel],
				GAMMA_PARAM_SIZE) == -1)
		printk(KERN_ERR "fail to write gamma value.\n");

	while (s5p_mipi_dsi_wr_data(dsim_base, MIPI_DSI_DCS_LONG_WRITE,
			(unsigned int)gamma_update,
				ARRAY_SIZE(gamma_update)) == -1)
		printk(KERN_ERR "fail to update gamma value.\n");
	return 1;
}
Ejemplo n.º 5
0
static int update_brightness(int brightness)
{
	int backlightlevel;

	backlightlevel = get_backlight_level(brightness);
	/* Need to implemnt
	while (s5p_mipi_dsi_wr_data(dsim_base, MIPI_DSI_DCS_LONG_WRITE,
			(unsigned int)gamma22_table[backlightlevel],
				GAMMA_PARAM_SIZE) == -1)
		printk(KERN_ERR "fail to write gamma value.\n");

	while (s5p_mipi_dsi_wr_data(dsim_base, MIPI_DSI_DCS_LONG_WRITE,
			(unsigned int)SEQ_GAMMA_UPDATE,
				ARRAY_SIZE(SEQ_GAMMA_UPDATE)) == -1)
		printk(KERN_ERR "fail to update gamma value.\n");
	*/
	return 0;
}
Ejemplo n.º 6
0
int is_backlight_modified(CABL *cabl, uint32_t *old_lvl)
{
    int ret;
    uint32_t temp_lvl = get_backlight_level();

    struct fb_cmap cmap;
    if (temp_lvl != *old_lvl) {
        ret = 1;
        LOGD_IF(cabl->mDebug, "The BL level changed,");
        *old_lvl = temp_lvl;
        LOGD_IF(cabl->mDebug, "The BL level changed to %u", temp_lvl);
        /* Reset the orig level only if > than the min level */
        if (temp_lvl >= cabl->mOEMParams.bl_min_level) {
            cabl->mOEMParams.orig_level = temp_lvl;
            abl_change_orig_bl_level(&cabl->mOEMParams);
            //set the new restore level
            cabl->mUserBLLevel = temp_lvl;
        }
    } else {
        ret = 0;
    }
    return ret;
}
Ejemplo n.º 7
0
int32_t CABL::start_cabl() {
    LOGD_IF(mDebug, "Start_CABL E");
    pthread_mutex_lock(&mCABLCtrlLock);
    if (gHwInfo.nPriDisplayHistBins == 0) {
        LOGE("CABL not supported on this HW!");
        pthread_mutex_unlock(&mCABLCtrlLock);
        return -1;
    }

    if (!mEnable) {
        LOGE("CABL not enabled!");
        pthread_mutex_unlock(&mCABLCtrlLock);
        return -1;
    }
    pthread_mutex_lock(&mCABLLock);
    if (eStatus == CABL_ON) {
        LOGD("CABL is already on!");
        pthread_mutex_unlock(&mCABLLock);
        pthread_mutex_unlock(&mCABLCtrlLock);
        return 0;
    }
    pthread_mutex_unlock(&mCABLLock);
    /* Get the user defined power saving level */
    char property[PROPERTY_VALUE_MAX];
    if (property_get("hw.cabl.level", property, NULL) > 0) {
        int newLvl = ql_string2int(property);
        if (newLvl == ABL_QUALITY_AUTO) {
            mPowerSaveLevel = ABL_QUALITY_HIGH;
        } else if ((newLvl < 0) || (newLvl > ABL_QUALITY_MAX)) {
            mPowerSaveLevel = ABL_QUALITY_HIGH;
            LOGE("Invalid power saving level, setting hw.cabl.level to High");
        } else if (newLvl < ABL_QUALITY_MAX) {
            mPowerSaveLevel = newLvl;
        }
        LOGD_IF(mDebug, "Power saving level: %d", mPowerSaveLevel);
    }

    // Reset CABL structure to 0 to clear any garbage static data
    memset(&mColorMap, 0, sizeof(struct fb_cmap));

    /* Get the backlight level and initialize the new level to it */
    mUserBLLevel = get_backlight_level();

    /* oem initialization */
    mOEM.ConfigureABLParameters(&mOEMParams, mPowerSaveLevel, mUserBLLevel);
    set_interpolated_bl_min_level(&mOEMParams);

    // Check if initial level is more than the minimum allowed level
    // otherwise, set it to the min level
    uint32_t init_level = (mUserBLLevel >= mOEMParams.bl_min_level) ?
            mUserBLLevel : mOEMParams.bl_min_level;
    LOGD_IF(mDebug, "Original backlight level %03u "
            "Initializing with: %03u Min level: %03d",
            mUserBLLevel, init_level, mOEMParams.bl_min_level);

    /* driver initialization */
    int32_t ret = abl_init(FBFd, &mColorMap, &mOEMParams, &mHistInfo,
                                                mPowerSaveLevel, init_level);
    if (ret) {
        LOGE("abl_init() failed!");
        free_cmap(&mColorMap);
        pthread_mutex_unlock(&mCABLCtrlLock);
        return ret;
    }

    mRefresher = ScreenRefresher::getInstance();

    /* ABL Init is done, let the control
     * thread start the histogram */
    stopHistogram(mHistStatus);
    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
    /* update the CABL status so threads can run */
    eStatus = CABL_ON;
    /* Start the worker thread */
    int32_t err = pthread_create(&mWorkerThreadID, &attr, worker, this);
    if (err) {
        LOGE("CABL: Failed to start the control thread");
        eStatus = CABL_OFF;
        free_cmap(&mColorMap);
        pthread_attr_destroy(&attr);
        pthread_mutex_unlock(&mCABLCtrlLock);
        return -1;
    }
    pthread_attr_destroy(&attr);
    LOGD_IF(mDebug, "Start_CABL X");
    pthread_mutex_unlock(&mCABLCtrlLock);
    return 0;
}