struct fbcon_config *mipi_init(void) { int status = 0; struct mipi_dsi_panel_config *panel_info = get_panel_info(); /* Enable MMSS_AHB_ARB_MATER_PORT_E for arbiter master0 and master 1 request */ #if (!DISPLAY_MIPI_PANEL_RENESAS) writel(0x00001800, MMSS_SFPB_GPREG); #endif #if DISPLAY_MIPI_PANEL_TOSHIBA_MDT61 mipi_dsi_phy_init(panel_info); #else mipi_dsi_phy_ctrl_config(panel_info); #endif status += mipi_dsi_panel_initialize(panel_info); #if DISPLAY_MIPI_PANEL_NOVATEK_BLUE mipi_dsi_cmd_bta_sw_trigger(); mipi_novatek_manufacture_id(); #endif mipi_fb_cfg.base = MIPI_FB_ADDR; if (panel_info->mode == MIPI_VIDEO_MODE) status += mipi_dsi_video_config(panel_info->num_of_lanes); if (panel_info->mode == MIPI_CMD_MODE) cmd_mode_status = 1; return &mipi_fb_cfg; }
u8 mipi_mode_get_pwr_mode(struct msm_fb_data_type *mfd) { struct dsi_cmd_desc *cmd; u8 power_mode; cmd = &mot_get_pwr_mode_cmd; power_mode = get_panel_info(mfd, mot_panel, cmd); pr_debug("%s: panel power mode = 0x%x\n", __func__, power_mode); return power_mode; }
u16 mipi_mot_get_controller_drv_ver(struct msm_fb_data_type *mfd) { struct dsi_cmd_desc *cmd; static int controller_drv_ver = INVALID_VALUE; if (controller_drv_ver == INVALID_VALUE) { if (mot_panel == NULL) { pr_err("%s: invalid mot_panel\n", __func__); return -1; } cmd = &mot_controller_drv_ver_cmd; controller_drv_ver = get_panel_info(mfd, mot_panel, cmd); } return controller_drv_ver; }
u16 mipi_mot_get_manufacture_id(struct msm_fb_data_type *mfd) { struct dsi_cmd_desc *cmd; static int manufacture_id = INVALID_VALUE; if (manufacture_id == INVALID_VALUE) { if (mot_panel == NULL) { pr_err("%s: invalid mot_panel\n", __func__); return -1; } cmd = &mot_manufacture_id_cmd; manufacture_id = get_panel_info(mfd, mot_panel, cmd); } return manufacture_id; }
static int mipi_read_cmd_locked(struct msm_fb_data_type *mfd, struct dsi_cmd_desc *cmd, u8 *rd_data) { int ret; mutex_lock(&mfd->dma->ov_mutex); if (atomic_read(&mot_panel->state) == MOT_PANEL_OFF) { ret = MOT_ESD_PANEL_OFF; goto panel_off_ret; } else { mipi_set_tx_power_mode(0); mipi_mot_mipi_busy_wait(mfd); *rd_data = (u8)get_panel_info(mfd, mot_panel, cmd); } ret = MOT_ESD_OK; panel_off_ret: mutex_unlock(&mfd->dma->ov_mutex); return ret; }
static void aat2870_bl_enable(struct backlight_device *bd) { struct aat2870_bl_driver_data *drvdata = dev_get_drvdata(&bd->dev); int i; dbg("enable\n"); if (drvdata->en_pin >= 0) { // #ifdef CONFIG_MACH_LGE gpio_set_value(drvdata->en_pin, 0); mdelay(1); #endif // gpio_set_value(drvdata->en_pin, 1); // #ifdef CONFIG_MACH_LGE udelay(100); if (als_enabled == false) { dbg("Debugging Here : Default Flows\n"); /* Non ALC mode */ aat2870_bl_write(bd, AAT2870_BL_ALSF_, 0x00); /* backlight magnitude */ aat2870_bl_write(bd, AAT2870_BL_BLM, calc_brightness(bd, bd->props.brightness)); // set backlight magnitude because this function // can be called from aat2870_bl_set_ldo() // which does not perform magnitude setting } else { /* Auto Brightness Mode */ #if defined(FEATURE_ALC_TABLE_SELECTION)// int marked_id = get_panel_info(); for (i=0 ; init_alc_currents[marked_id][i].addr != 0xFF ; i++) { aat2870_bl_write(bd, init_alc_currents[marked_id][i].addr, init_alc_currents[marked_id][i].data); udelay(10); #else for (i=0 ; init_alc_currents[i].addr != 0xFF ; i++) { aat2870_bl_write(bd, init_alc_currents[i].addr, init_alc_currents[i].data); udelay(10); #endif /* FEATURE_ALC_TABLE_SELECTION */ } /* ALS Function, Log Scale, Rset 4K/16K, High gain input setting */ aat2870_bl_write(bd, AAT2870_BL_ALSF_, 0x71); /* SBIAS 3.0V, Offset No adjustment */ aat2870_bl_write(bd, AAT2870_BL_SBIAS, 0x01); /* Auto gain control, polling time 2sec, ALC gain -18.25% adjustment */ aat2870_bl_write(bd, AAT2870_BL_ALS_G, 0x07); } /* enable chennel */ aat2870_bl_write(bd, AAT2870_BL_EN, drvdata->avail_ch); if(drvdata->op_mode == AAT2870_OP_MODE_ALC) { dbg("Debugging op_mode [%d]\n", drvdata->op_mode); aat2870_bl_switch_mode(AAT2870_OP_MODE_ALC); dbg("Debugging ALC:ON\n"); } mdelay(1); #endif // } } static void aat2870_bl_disable(struct backlight_device *bd) { struct aat2870_bl_driver_data *drvdata = dev_get_drvdata(&bd->dev); dbg("disable\n"); if (drvdata->en_pin >= 0) { gpio_set_value(drvdata->en_pin, 0); // #ifdef CONFIG_MACH_LGE // to trigger enable during resume drvdata->brightness = 0; #endif // } } int aat2870_bl_set_ldo(enum aat2870_bl_ldo ldo, enum aat2870_bl_ldo_voltage volt, int en) { struct aat2870_bl_driver_data *drvdata; struct backlight_device *bd; int addr, data, shift; int ret = 0; if (!aat2870_bl_drvdata) { pr_err("%s: aat2870_bl_drvdata points NULL\n", AAT2870_BL_DRV_NAME); ret = -ENXIO; goto out; } drvdata = aat2870_bl_drvdata; bd = drvdata->bd; if ((volt < AAT2870_BL_LDO_1_2V) || (volt > AAT2870_BL_LDO_3_3V)) { dev_err(&bd->dev, "invalid LDO voltage: 0x%x\n", volt); ret = -EINVAL; goto out; } switch (ldo) { case AAT2870_BL_LDOA: addr = AAT2870_BL_LDO_AB; shift = 4; break; case AAT2870_BL_LDOB: addr = AAT2870_BL_LDO_AB; shift = 0; break; case AAT2870_BL_LDOC: addr = AAT2870_BL_LDO_CD; shift = 4; break; case AAT2870_BL_LDOD: addr = AAT2870_BL_LDO_CD; shift = 0; break; default: dev_err(&drvdata->bd->dev, "invalid LDO ID: %d\n", ldo); ret = -EINVAL; goto out; } if (drvdata->brightness == 0) aat2870_bl_enable(bd); data = aat2870_bl_read(bd, addr); data &= ~(AAT2870_BL_LDO_MASK << shift); data |= (volt << shift); if (aat2870_bl_write(bd, addr, data) < 0) { ret = -EIO; goto out; } addr = AAT2870_BL_EN_LDO; data = aat2870_bl_read(bd, addr); if (en) data |= (1 << ldo); else data &= ~(1 << ldo); if (aat2870_bl_write(bd, addr, data) < 0) { ret = -EIO; goto out; } out: return ret; } EXPORT_SYMBOL(aat2870_bl_set_ldo); static int aat2870_bl_get_brightness(struct backlight_device *bd) { return bd->props.brightness; } // MOBII_S [[email protected]] 2012-05-07 : Auto Brightness Setting From P990. #if defined(CONFIG_MACH_STAR_P990) || defined(CONFIG_MACH_STAR_SU660) static int aat2870_bl_update_modestatus(struct backlight_device *bd) { //MOBII_CHNANGE_S 20120819 [email protected] : Modify ALS table value struct aat2870_bl_driver_data *drvdata = dev_get_drvdata(&bd->dev); int brightness_mode = bd->props.brightness_mode; int next_mode; static struct aat2870_bl_driver_data *drv; drv = aat2870_bl_drvdata; if(brightness_mode == 1) { next_mode = AAT2870_OP_MODE_ALC; if (drv->lsensor_enable) { schedule_delayed_work(&drv->delayed_work_bl, drv->lsensor_poll_time); } } else { next_mode = AAT2870_OP_MODE_NORMAL; } aat2870_bl_switch_mode(next_mode); drv->op_mode = next_mode; //MOBII_CHNANGE_E 20120819 [email protected] : Modify ALS table value } #endif // MOBII_E [[email protected]] 2012-05-07 : Auto Brightness Setting From P990. static int aat2870_bl_update_status(struct backlight_device *bd) { struct aat2870_bl_driver_data *drvdata = dev_get_drvdata(&bd->dev); int brightness = bd->props.brightness; int ret = 0; if(is_suspended == true) { return 0; } if ((brightness < 0) || (brightness > bd->props.max_brightness)) { dev_err(&bd->dev, "invalid brightness: %d(0 <= brightness <= %d)\n", brightness, bd->props.max_brightness); ret = -EINVAL; goto out; } #if defined (CONFIG_PANICRPT) if( panicrpt_ispanic() == 1) goto out; #endif dbg("props: brightness=%d, power=%d, state=%d\n", bd->props.brightness, bd->props.power, bd->props.state); if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.state & BL_CORE_FBBLANK) || (bd->props.state & BL_CORE_SUSPENDED)) { brightness = 0; } if (brightness == 0) { aat2870_bl_disable(bd); } else { if (drvdata->brightness == 0) { dbg("SEQ3 : enabled Funk!\n"); aat2870_bl_enable(bd); } if (aat2870_bl_write(bd, AAT2870_BL_BLM, calc_brightness(bd, brightness)) < 0) { ret = -EIO; goto out; } // // channel enable is done during aat2870_bl_enable() #ifndef CONFIG_MACH_LGE if (drvdata->brightness == 0) { if (aat2870_bl_write(bd, AAT2870_BL_EN, drvdata->avail_ch) < 0) { ret = -EIO; goto out; } } #endif // } drvdata->brightness = brightness; out: return ret; } static int aat2870_bl_check_fb(struct backlight_device *bd, struct fb_info *fi) { return 1; } static const struct backlight_ops aat2870_bl_ops = { .get_brightness = aat2870_bl_get_brightness, .update_status = aat2870_bl_update_status, // MOBII_S [[email protected]] 2012-05-07 : Auto Brightness Setting From P990. #if defined(CONFIG_MACH_STAR_P990) || defined(CONFIG_MACH_STAR_SU660) .update_modestatus = aat2870_bl_update_modestatus, #endif // MOBII_E [[email protected]] 2012-05-07 : Auto Brightness Setting From P990. .check_fb = aat2870_bl_check_fb, }; static unsigned int aat2870_bl_conv_to_lux(int lev) { struct aat2870_lux_tbl_t *tbl; unsigned val = 0; tbl = aat2870_lux_tbl; for (;;) { if (tbl->lev == lev) { val = tbl->lux; break; } else if (tbl->lev >= 0x1f) { break; } tbl++; } return val; } static int aat2870_bl_send_cmd(struct aat2870_bl_driver_data *drv, struct aat2870_ctl_tbl_t *tbl) { unsigned long delay = 0; if (tbl == NULL) { dbg("input ptr is null\n"); return -EIO; } mutex_lock(&drv->cmd_lock); for( ;;) { if (tbl->reg == 0xFF) { if (tbl->val != 0xFE) { delay = (unsigned long)tbl->val; } else break; } else { if (aat2870_bl_write(drv->bd, tbl->reg, tbl->val) != 0) dbg("i2c failed addr:%d, value:%d\n", tbl->reg, tbl->val); } tbl++; } mutex_unlock(&drv->cmd_lock); return 0; }
static int fimd_attach(device_t dev) { struct panel_info panel; struct fimd_softc *sc; device_t gpio_dev; int reg; sc = device_get_softc(dev); sc->dev = dev; if (bus_alloc_resources(dev, fimd_spec, sc->res)) { device_printf(dev, "could not allocate resources\n"); return (ENXIO); } /* Memory interface */ sc->bst = rman_get_bustag(sc->res[0]); sc->bsh = rman_get_bushandle(sc->res[0]); sc->bst_disp = rman_get_bustag(sc->res[1]); sc->bsh_disp = rman_get_bushandle(sc->res[1]); sc->bst_sysreg = rman_get_bustag(sc->res[2]); sc->bsh_sysreg = rman_get_bushandle(sc->res[2]); if (get_panel_info(sc, &panel)) { device_printf(dev, "Can't get panel info\n"); return (ENXIO); } panel.fixvclk = 0; panel.ivclk = 0; panel.clkval_f = 2; sc->panel = &panel; /* Get the GPIO device, we need this to give power to USB */ gpio_dev = devclass_get_device(devclass_find("gpio"), 0); if (gpio_dev == NULL) { /* TODO */ } reg = bus_space_read_4(sc->bst_sysreg, sc->bsh_sysreg, 0x214); reg |= FIMDBYPASS_DISP1; bus_space_write_4(sc->bst_sysreg, sc->bsh_sysreg, 0x214, reg); sc->sc_info.fb_width = panel.width; sc->sc_info.fb_height = panel.height; sc->sc_info.fb_stride = sc->sc_info.fb_width * 2; sc->sc_info.fb_bpp = sc->sc_info.fb_depth = 16; sc->sc_info.fb_size = sc->sc_info.fb_height * sc->sc_info.fb_stride; sc->sc_info.fb_vbase = (intptr_t)kmem_alloc_contig(kernel_arena, sc->sc_info.fb_size, M_ZERO, 0, ~0, PAGE_SIZE, 0, VM_MEMATTR_UNCACHEABLE); sc->sc_info.fb_pbase = (intptr_t)vtophys(sc->sc_info.fb_vbase); #if 0 printf("%dx%d [%d]\n", sc->sc_info.fb_width, sc->sc_info.fb_height, sc->sc_info.fb_stride); printf("pbase == 0x%08x\n", sc->sc_info.fb_pbase); #endif memset((int8_t *)sc->sc_info.fb_vbase, 0x0, sc->sc_info.fb_size); fimd_init(sc); sc->sc_info.fb_name = device_get_nameunit(dev); /* Ask newbus to attach framebuffer device to me. */ sc->sc_fbd = device_add_child(dev, "fbd", device_get_unit(dev)); if (sc->sc_fbd == NULL) device_printf(dev, "Can't attach fbd device\n"); if (device_probe_and_attach(sc->sc_fbd) != 0) { device_printf(sc->dev, "Failed to attach fbd device\n"); } return (0); }
static int dcu_attach(device_t dev) { struct panel_info panel; struct dcu_softc *sc; device_t gpio_dev; int err; sc = device_get_softc(dev); sc->dev = dev; if (bus_alloc_resources(dev, dcu_spec, sc->res)) { device_printf(dev, "could not allocate resources\n"); return (ENXIO); } /* Memory interface */ sc->bst = rman_get_bustag(sc->res[0]); sc->bsh = rman_get_bushandle(sc->res[0]); /* Setup interrupt handler */ err = bus_setup_intr(dev, sc->res[1], INTR_TYPE_BIO | INTR_MPSAFE, NULL, dcu_intr, sc, &sc->ih); if (err) { device_printf(dev, "Unable to alloc interrupt resource.\n"); return (ENXIO); } if (get_panel_info(sc, &panel)) { device_printf(dev, "Can't get panel info\n"); return (ENXIO); } sc->panel = &panel; /* Bypass timing control (used for raw lcd panels) */ tcon_bypass(); /* Get the GPIO device, we need this to give power to USB */ gpio_dev = devclass_get_device(devclass_find("gpio"), 0); if (gpio_dev == NULL) { device_printf(sc->dev, "Error: failed to get the GPIO dev\n"); return (1); } /* Turn on backlight */ /* TODO: Use FlexTimer/PWM */ GPIO_PIN_SETFLAGS(gpio_dev, panel.backlight_pin, GPIO_PIN_OUTPUT); GPIO_PIN_SET(gpio_dev, panel.backlight_pin, GPIO_PIN_HIGH); sc->sc_info.fb_width = panel.width; sc->sc_info.fb_height = panel.height; sc->sc_info.fb_stride = sc->sc_info.fb_width * 3; sc->sc_info.fb_bpp = sc->sc_info.fb_depth = 24; sc->sc_info.fb_size = sc->sc_info.fb_height * sc->sc_info.fb_stride; sc->sc_info.fb_vbase = (intptr_t)contigmalloc(sc->sc_info.fb_size, M_DEVBUF, M_ZERO, 0, ~0, PAGE_SIZE, 0); sc->sc_info.fb_pbase = (intptr_t)vtophys(sc->sc_info.fb_vbase); #if 0 printf("%dx%d [%d]\n", sc->sc_info.fb_width, sc->sc_info.fb_height, sc->sc_info.fb_stride); printf("pbase == 0x%08x\n", sc->sc_info.fb_pbase); #endif memset((int8_t *)sc->sc_info.fb_vbase, 0x0, sc->sc_info.fb_size); dcu_init(sc); sc->sc_info.fb_name = device_get_nameunit(dev); /* Ask newbus to attach framebuffer device to me. */ sc->sc_fbd = device_add_child(dev, "fbd", device_get_unit(dev)); if (sc->sc_fbd == NULL) device_printf(dev, "Can't attach fbd device\n"); if (device_probe_and_attach(sc->sc_fbd) != 0) { device_printf(sc->dev, "Failed to attach fbd device\n"); } return (0); }
static int __init mipi_video_orise_720p_pt_init(void) { int ret; int rc = 0; if (msm_fb_detect_client("mipi_video_orise_720p")) return 0; /*OPPO Neal add for sharp panel*/ rc = gpio_request(LCD_DIS_GPIO, "LCD_DIS_GPIO"); if (rc < 0) { pr_err("MIPI GPIO LCD_TE_GPIO request failed: %d\n", rc); return -ENODEV; } gpio_direction_output(LCD_DIS_GPIO,0); dis = gpio_get_value(LCD_DIS_GPIO); printk(KERN_ERR "mipi_orise_lcd_probe Neal ******************************: dis = %d\n", dis); gpio_free(LCD_DIS_GPIO); /*OPPO Neal add end*/ pinfo.xres = 1080; pinfo.yres = 1920; pinfo.lcdc.xres_pad = 0; pinfo.lcdc.yres_pad = 0; pinfo.type = MIPI_VIDEO_PANEL; pinfo.pdest = DISPLAY_1; pinfo.wait_cycle = 0; pinfo.bpp = 24; #if 1 /* OPPO 2013-03-07 Gousj Modify begin for solve the issue of lack of virtical pixel. */ //Gousj modified h_back_porch from 100 to 101 /*OPPO Neal add for sharp panel*/ if(get_panel_info() == 0) { pinfo.lcdc.h_back_porch = 100;//100;//80; pinfo.lcdc.v_back_porch = 5; //must > 4,Otherwise,it will increase the burden of clock huyu printk(KERN_ERR "%s: register sharp device!\n", __func__); } else { pinfo.lcdc.h_back_porch = 101;//100;//80; pinfo.lcdc.v_back_porch = 4; //must > 4,Otherwise,it will increase the burden of clock huyu printk(KERN_ERR "%s: register jdi device!\n", __func__); } /*OPPO Neal add end*/ pinfo.lcdc.h_front_porch = 130;//120 pinfo.lcdc.h_pulse_width = 8; //Modified by Gousj on date 2013-3-4 ,the value of v_back_porch decreased from 5 to 4 . pinfo.lcdc.v_front_porch = 3; //Modified by Gousj on date 2013-3-4 ,the value of v_pulse_width decreased from 2 to 1 . pinfo.lcdc.v_pulse_width = 1;//2; /* OPPO 2013-03-07 Gousj Modify end */ #endif pinfo.lcdc.border_clr = 0; /* blk */ pinfo.lcdc.underflow_clr = 0xff; /* blue */ pinfo.lcdc.hsync_skew = 0; /* OPPO 2013-04-22 Gousj Modify for black light not light */ pinfo.bl_max = 127; /* OPPO 2013-04-022 Gousj Modify end */ pinfo.bl_min = 1; pinfo.fb_num = 2; pinfo.mipi.mode = DSI_VIDEO_MODE; pinfo.mipi.pulse_mode_hsa_he = FALSE; pinfo.mipi.hfp_power_stop = TRUE; pinfo.mipi.hbp_power_stop = FALSE; pinfo.mipi.hsa_power_stop = FALSE; pinfo.mipi.eof_bllp_power_stop = FALSE; pinfo.mipi.bllp_power_stop = FALSE; pinfo.mipi.traffic_mode = DSI_BURST_MODE; pinfo.mipi.dst_format = DSI_VIDEO_DST_FORMAT_RGB888; pinfo.mipi.vc = 0; pinfo.mipi.rgb_swap = DSI_RGB_SWAP_RGB; pinfo.mipi.data_lane0 = TRUE; pinfo.mipi.data_lane1 = TRUE; pinfo.mipi.data_lane2 = TRUE; pinfo.mipi.data_lane3 = TRUE; pinfo.mipi.t_clk_post = 0x25;//0x19; pinfo.mipi.t_clk_pre = 0x36;//0x37; pinfo.mipi.stream = 0; /* dma_p */ pinfo.mipi.mdp_trigger = 0; pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW; pinfo.mipi.frame_rate = 60; pinfo.mipi.dsi_phy_db = &dsi_video_mode_phy_db_1080p; pinfo.mipi.tx_eot_append = TRUE; pinfo.mipi.esc_byte_ratio = 4; ret = mipi_orise_device_register(&pinfo, MIPI_DSI_PRIM, MIPI_DSI_PANEL_720P_PT); if (ret) printk(KERN_ERR "%s: failed to register device!\n", __func__); return ret; }