static int spi_write_gmtb(const LCD_INIT_TABLE init_table[], unsigned size) { int i, ret = -1; uint8_t buf[18]; for (i = 0; i < size; i++) buf[i] = init_table[i].val; #ifdef CONFIG_MICROP_COMMON ret = microp_i2c_write(MICROP_I2C_WCMD_LCM_BURST, buf, 18); if (ret < 0) { D("%s: write gamma table failed\n", __func__); return ret; } buf[0] = 0x00; buf[1] = 0x01; ret = microp_i2c_write(MICROP_I2C_WCMD_LCM_BURST_EN, buf, 2); if (ret < 0) { D("%s: burst data enable failed\n", __func__); return ret; } #endif return ret; }
static void curcial_oj_shutdown(int enable) { uint8_t cmd[3]; memset(cmd, 0, sizeof(uint8_t)*3); cmd[2] = 0x80; if (enable) microp_i2c_write(0x91, cmd, 3); else microp_i2c_write(0x90, cmd, 3); }
static void curcial_oj_polling_mode(uint8_t mode) { uint8_t cmd[2]; cmd[0] = mode; microp_i2c_write(OJ_REGISTER_OJ_POLLING, cmd, 1); }
static void chacha_brightness_set(struct led_classdev *led_cdev, enum led_brightness val) { struct msm_mddi_client_data *client = renesas.client_data; unsigned int shrink_bl = chacha_panel_shrink(val); struct mddi_cmd *pcmd = renesas_backlight_cmd_table; uint8_t data[4] = { /* PWM setting of microp, see p.8 */ 0x05, /* Fading time; suggested: 5/10/15/20/25 */ val, /* Duty Cycle */ 0x00, /* Channel H byte */ 0x01, /* Channel L byte */ }; if (atomic_read(&lcm_init_done) == 0) { return; } if (renesas.last_shrink_bl == shrink_bl) { printk(KERN_DEBUG "[BKL] identical shrink_bl\n"); return; } pcmd->vals[4] = shrink_bl; mutex_lock(&renesas.lock); client->remote_write_vals(client, pcmd->vals, pcmd->cmd, pcmd->len); microp_i2c_write(0x25, data, sizeof(data)); chacha_brightness_value = val; renesas.last_shrink_bl = shrink_bl; mutex_unlock(&renesas.lock); }
static int spade_adjust_backlight(enum led_brightness val) { uint8_t data[4] = { /* PWM setting of microp, see p.8 */ 0x05, /* Fading time; suggested: 5/10/15/20/25 */ val, /* Duty Cycle */ 0x00, /* Channel H byte */ 0x20, /* Channel L byte */ }; uint8_t shrink_br; mutex_lock(&panel_lock); if (val == 0) shrink_br = 0; else if (val <= 30) shrink_br = 7; else if ((val > 30) && (val <= 143)) shrink_br = (91 - 7) * (val - 30) / (143 - 30) + 7; else shrink_br = (217 - 91) * (val - 143) / (255 - 143) + 91; data[1] = shrink_br; LCMDBG("(%d), shrink_br=%d\n", val, shrink_br); microp_i2c_write(0x25, data, sizeof(data)); last_val = shrink_br ? shrink_br: last_val; mutex_unlock(&panel_lock); return shrink_br; }
/*----------------------------------------------------------------------------*/ static int express_adjust_backlight(enum led_brightness val) { uint8_t shrink_br = 0; uint8_t data[4] = { /* PWM setting of microp, see p.8 */ 0x05, /* Fading time; suggested: 5/10/15/20/25 */ val, /* Duty Cycle */ 0x00, /* Channel H byte */ 0x20, /* Channel L byte */ }; if(val == 0) data[0] = 0; mutex_lock(&panel_lock); shrink_br = express_shrink_pwm(val, PWM_USER_DEF, PWM_USER_MIN, PWM_USER_MAX, PWM_SAM_DEF, PWM_SAM_MIN, PWM_SAM_MAX); data[1] = shrink_br; PR_DISP_DEBUG("[lcm](%d), shrink_br=%d\n", val, shrink_br); microp_i2c_write(0x25, data, sizeof(data)); last_val = shrink_br ? shrink_br: last_val; mutex_unlock(&panel_lock); #if 0 return shrink_br; #else return val; #endif }
static int icong_microp_function_init(struct i2c_client *client) { struct microp_i2c_platform_data *pdata; struct microp_i2c_client_data *cdata; uint8_t data[20]; int i, j; int ret; icong_microp_client = client; pdata = client->dev.platform_data; cdata = i2c_get_clientdata(client); /* Headset remote key */ ret = microp_function_check(client, MICROP_FUNCTION_REMOTEKEY); if (ret >= 0) { i = ret; pdata->function_node[MICROP_FUNCTION_REMOTEKEY] = i; cdata->int_pin.int_remotekey = pdata->microp_function[i].int_pin; for (j = 0; j < 6; j++) { data[j] = (uint8_t)(pdata->microp_function[i].levels[j] >> 8); data[j + 6] = (uint8_t)(pdata->microp_function[i].levels[j]); } ret = microp_i2c_write(MICROP_I2C_WCMD_REMOTEKEY_TABLE, data, 12); if (ret) goto exit; }
static int sonywvga_panel_blank(struct msm_lcdc_panel_ops *panel_data) { uint8_t data[4] = {0, 0, 0, 0}; LCMDBG("%s\n", __func__); mutex_lock(&panel_lock); blank_msg.cmd = 0x28; qspi_send_9bit(&blank_msg); blank_msg.cmd = 0x10; qspi_send_9bit(&blank_msg); hr_msleep(40); g_unblank_stage = 0; mutex_unlock(&panel_lock); sonywvga_panel_power(0); if (!is_sony_spi()) { data[0] = 5; data[1] = 0; data[3] = 1; microp_i2c_write(0x25, data, 4); } return 0; }
static int sony_tft_panel_blank(struct msm_lcdc_panel_ops *ops) { uint8_t data[4] = {0, 0, 0, 0}; pr_info("%s: +()\n", __func__); mutex_lock(&panel_lock); clk_enable(spi_clk); qspi_send_9bit(0x0, 0x28); qspi_send_9bit(0x0, 0x10); clk_disable(spi_clk); msleep(40); sony_tft_panel_power(0); tft_panel_on = 0; mutex_unlock(&panel_lock); if (!is_sony_spi()) { data[0] = 5; data[1] = 0; data[3] = 1; microp_i2c_write(0x25, data, 4); } pr_info("%s: -()\n", __func__); return 0; }
static int __capella_cm3602_power(int on) { uint8_t data[3], addr; int ret; printk(KERN_DEBUG "%s: Turn the capella_cm3602 power %s\n", __func__, (on) ? "on" : "off"); if (on) gpio_direction_output(INCREDIBLEC_GPIO_PROXIMITY_EN_N, 1); data[0] = 0x00; data[1] = 0x00; data[2] = 0x04; addr = on ? MICROP_I2C_WCMD_GPO_LED_STATUS_EN : MICROP_I2C_WCMD_GPO_LED_STATUS_DIS; ret = microp_i2c_write(addr, data, 3); if (ret < 0) pr_err("%s: %s capella power failed\n", __func__, (on ? "enable" : "disable")); if (!on) gpio_direction_output(INCREDIBLEC_GPIO_PROXIMITY_EN_N, 0); return ret; }
static int lcm_spi_write(unsigned char add, unsigned char val) { uint8_t buf[3] = {0, add, val}; int ret = 0; if (!panel_type){ ret = microp_i2c_write(MICROP_I2C_WCMD_LCM_REGISTER, buf, 3); } else { ret = microp_i2c_write(0x6F, buf, 3); } if (ret < 0) { D("%s: microp_spi_write fail\n", __func__); return ret; } return ret; }
static void curcial_oj_burst_read(uint8_t *data) { uint8_t cmd[2]; cmd[0] = 0x01; microp_i2c_write(OJ_REGISTER_BURST_REQUEST, cmd, 1); microp_i2c_read(OJ_REGISTER_BURST_READ, data, BURST_DATA_SIZE); }
static void curcial_oj_shutdown (int enable) { uint8_t cmd[3]; memset(cmd, 0x00, sizeof(uint8_t)*3); /* microp firmware(v04) non-shutdown by default */ cmd[2] = 0x20; microp_i2c_write(0x90, cmd, 3); }
static void curcial_oj_shutdown(int enable) { uint8_t cmd[3]; memset(cmd, 0x00, sizeof(uint8_t)*3); cmd[2] = 0x20; // microp firmware(v04) non-shutdown by default microp_i2c_write(0x90, cmd, 3); pr_err("%s\n", __func__); }
static uint8_t curcial_oj_register_read(uint8_t reg) { uint8_t cmd[2]; cmd[0] = 0; cmd[1] = reg; microp_i2c_write(OJ_REGISTER_REQUEST, cmd, 2); microp_i2c_read(OJ_REGISTER_READ, cmd, 2); return cmd[1]; }
static void sony_tft_set_pwm_val(int val) { uint8_t data[4] = {0,0,0,0}; unsigned int min_pwm, def_pwm, max_pwm; pr_info("%s: %d\n", __func__, val); last_val = val; if (!tft_panel_on) return; if(!is_sony_spi()) { min_pwm = SONY_TFT_MIN_PANEL_UP_VAL; def_pwm = SONY_TFT_DEF_PANEL_UP_VAL; max_pwm = SONY_TFT_MAX_PANEL_UP_VAL; } else { min_pwm = SONY_TFT_MIN_PANEL_VAL; def_pwm = SONY_TFT_DEF_PANEL_VAL; max_pwm = SONY_TFT_MAX_PANEL_VAL; } if (val <= SONY_TFT_DEF_USER_VAL) { if (val <= SONY_TFT_MIN_USER_VAL) val = min_pwm; else val = (def_pwm - min_pwm) * (val - SONY_TFT_MIN_USER_VAL) / SONY_TFT_DEF_USER_DELTA + min_pwm; } else { val = (max_pwm - def_pwm) * (val - SONY_TFT_DEF_USER_VAL) / (SONY_TFT_MAX_USER_VAL - SONY_TFT_DEF_USER_VAL) + def_pwm; } if (!is_sony_spi()) { data[0] = 5; data[1] = val; data[3] = 1; microp_i2c_write(0x25, data, 4); } else { clk_enable(spi_clk); qspi_send_9bit(0x0, 0x51); qspi_send_9bit(0x1, val); qspi_send_9bit(0x0, 0x53); qspi_send_9bit(0x1, 0x24); clk_disable(spi_clk); } }
int microp_set_adc_req(uint8_t value) { int ret; uint8_t cmd[1]; cmd[0] = value; //value; TODO finish code... now only keys ADC ret = microp_i2c_write(MICROP_I2C_WCMD_ADC_REQ, cmd, 1); if (ret < 0) { pr_err("%s: request adc fail\n", __func__); return -EIO; } return 0; }
static int htcleo_brightness_onoff_bkl(int enable) { int ret; uint8_t data[1]; #ifdef CONFIG_HTCLEO_BTN_BACKLIGHT_MANAGER // Disable button backlight along with screen if (!enable) gpio_set_value(BUTTON_BACKLIGHT_GPIO, 0); #endif data[0] = enable ? 1 : 0; ret = microp_i2c_write(MICROP_I2C_WCMD_BL_EN, data, 1); if (ret != 0) pr_err("%s: set failed\n", __func__); return 0; }
/* * Caller must make sure the spi is ready * */ static void sonywvga_set_gamma_val(int val) { uint8_t data[4] = {0, 0, 0, 0}; if (!is_sony_spi()) { //turn on backlight data[0] = 5; data[1] = sonywvga_panel_shrink_pwm(val); data[3] = 1; microp_i2c_write(0x25, data, 4); } else { shrink_pwm = sonywvga_panel_shrink_pwm(val); qspi_send_9bit(&gamma_update); lcm_write_tb(SONY_GAMMA_UPDATE_TABLE, ARRAY_SIZE(SONY_GAMMA_UPDATE_TABLE)); } last_val_pwm = val; }
static int htcleo_brightness_autobacklight(uint8_t value) { int ret; uint8_t data[2]; LCMDBG("%s:(%d)\n", __func__, value); if(value!=0 && value!=1) return -1; data[0] = 1; data[1] = value; ret = microp_i2c_write(MICROP_I2C_WCMD_AUTO_BL_CTL, data, 2); if (ret != 0) { pr_err("%s: set auto light sensor fail\n", __func__); return ret; } auto_bl_state=value; return 0; }
static int htcleo_brightness_set_bkl(uint8_t value) { int ret; uint8_t cmd[2]; LCMDBG("%s:(%d)\n", __func__, value); if (value > 9) { value = 9; } // setvalue cmd[0] = value << 4; ret = microp_i2c_write(MICROP_I2C_WCMD_LCM_BL_MANU_CTL, cmd, 1); // 22 if (ret < 0) { pr_err("%s: request adc fail\n", __func__); return -EIO; } return 0; }
static int spade_adjust_backlight(enum led_brightness val) { uint32_t def_bl; uint8_t data[4] = { /* PWM setting of microp, see p.8 */ 0x05, /* Fading time; suggested: 5/10/15/20/25 */ val, /* Duty Cycle */ 0x00, /* Channel H byte */ 0x20, /* Channel L byte */ }; uint8_t shrink_br; if (panel_type == PANEL_ID_SPADE_SHA_N90) def_bl = 101; else def_bl = 91; mutex_lock(&panel_lock); if (val == 0) shrink_br = 0; else if (val <= 30) shrink_br = 7; else if ((val > 30) && (val <= 143)) shrink_br = (def_bl - 7) * (val - 30) / (143 - 30) + 7; else shrink_br = (217 - def_bl) * (val - 143) / (255 - 143) + def_bl; if (shrink_br == 0) data[0] = 0; data[1] = shrink_br; microp_i2c_write(0x25, data, sizeof(data)); last_val = shrink_br ? shrink_br: last_val; mutex_unlock(&panel_lock); return shrink_br; }
static void microp_special_led_setting(void) { uint8_t data[3] = {0x19, 0x19, 0xA0}; microp_i2c_write(MICROP_I2C_WCMD_FACEBOOK_LED_TIMESET, data, 3); }