Lines Matching refs:par
160 static int ssd1307fb_set_col_range(struct ssd1307fb_par *par, u8 col_start, in ssd1307fb_set_col_range() argument
166 if (col_start == par->col_start && col_end == par->col_end) in ssd1307fb_set_col_range()
169 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE); in ssd1307fb_set_col_range()
173 ret = ssd1307fb_write_cmd(par->client, col_start); in ssd1307fb_set_col_range()
177 ret = ssd1307fb_write_cmd(par->client, col_end); in ssd1307fb_set_col_range()
181 par->col_start = col_start; in ssd1307fb_set_col_range()
182 par->col_end = col_end; in ssd1307fb_set_col_range()
186 static int ssd1307fb_set_page_range(struct ssd1307fb_par *par, u8 page_start, in ssd1307fb_set_page_range() argument
192 if (page_start == par->page_start && page_end == par->page_end) in ssd1307fb_set_page_range()
195 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE); in ssd1307fb_set_page_range()
199 ret = ssd1307fb_write_cmd(par->client, page_start); in ssd1307fb_set_page_range()
203 ret = ssd1307fb_write_cmd(par->client, page_end); in ssd1307fb_set_page_range()
207 par->page_start = page_start; in ssd1307fb_set_page_range()
208 par->page_end = page_end; in ssd1307fb_set_page_range()
212 static int ssd1307fb_update_rect(struct ssd1307fb_par *par, unsigned int x, in ssd1307fb_update_rect() argument
217 u8 *vmem = par->info->screen_buffer; in ssd1307fb_update_rect()
218 unsigned int line_length = par->info->fix.line_length; in ssd1307fb_update_rect()
256 ret = ssd1307fb_set_col_range(par, par->col_offset + x, width); in ssd1307fb_update_rect()
260 ret = ssd1307fb_set_page_range(par, par->page_offset + y / 8, pages); in ssd1307fb_update_rect()
268 if (8 * (i + 1) > par->height) in ssd1307fb_update_rect()
269 m = par->height % 8; in ssd1307fb_update_rect()
283 ret = ssd1307fb_write_array(par->client, array, width * pages); in ssd1307fb_update_rect()
290 static int ssd1307fb_update_display(struct ssd1307fb_par *par) in ssd1307fb_update_display() argument
292 return ssd1307fb_update_rect(par, 0, 0, par->width, par->height); in ssd1307fb_update_display()
298 struct ssd1307fb_par *par = info->par; in ssd1307fb_write() local
320 ret = ssd1307fb_update_display(par); in ssd1307fb_write()
331 struct ssd1307fb_par *par = info->par; in ssd1307fb_blank() local
334 return ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_OFF); in ssd1307fb_blank()
336 return ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON); in ssd1307fb_blank()
341 struct ssd1307fb_par *par = info->par; in ssd1307fb_fillrect() local
343 ssd1307fb_update_rect(par, rect->dx, rect->dy, rect->width, in ssd1307fb_fillrect()
349 struct ssd1307fb_par *par = info->par; in ssd1307fb_copyarea() local
351 ssd1307fb_update_rect(par, area->dx, area->dy, area->width, in ssd1307fb_copyarea()
357 struct ssd1307fb_par *par = info->par; in ssd1307fb_imageblit() local
359 ssd1307fb_update_rect(par, image->dx, image->dy, image->width, in ssd1307fb_imageblit()
375 ssd1307fb_update_display(info->par); in ssd1307fb_deferred_io()
378 static int ssd1307fb_init(struct ssd1307fb_par *par) in ssd1307fb_init() argument
384 if (par->device_info->need_pwm) { in ssd1307fb_init()
385 par->pwm = pwm_get(&par->client->dev, NULL); in ssd1307fb_init()
386 if (IS_ERR(par->pwm)) { in ssd1307fb_init()
387 dev_err(&par->client->dev, "Could not get PWM from device tree!\n"); in ssd1307fb_init()
388 return PTR_ERR(par->pwm); in ssd1307fb_init()
391 pwm_init_state(par->pwm, &pwmstate); in ssd1307fb_init()
393 pwm_apply_state(par->pwm, &pwmstate); in ssd1307fb_init()
396 pwm_enable(par->pwm); in ssd1307fb_init()
398 dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n", in ssd1307fb_init()
399 par->pwm->pwm, pwm_get_period(par->pwm)); in ssd1307fb_init()
403 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); in ssd1307fb_init()
407 ret = ssd1307fb_write_cmd(par->client, par->contrast); in ssd1307fb_init()
412 if (par->seg_remap) { in ssd1307fb_init()
413 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON); in ssd1307fb_init()
419 com_invdir = 0xc0 | par->com_invdir << 3; in ssd1307fb_init()
420 ret = ssd1307fb_write_cmd(par->client, com_invdir); in ssd1307fb_init()
425 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO); in ssd1307fb_init()
429 ret = ssd1307fb_write_cmd(par->client, par->height - 1); in ssd1307fb_init()
434 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET); in ssd1307fb_init()
438 ret = ssd1307fb_write_cmd(par->client, par->com_offset); in ssd1307fb_init()
443 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ); in ssd1307fb_init()
447 dclk = ((par->dclk_div - 1) & 0xf) | (par->dclk_frq & 0xf) << 4; in ssd1307fb_init()
448 ret = ssd1307fb_write_cmd(par->client, dclk); in ssd1307fb_init()
453 if (par->area_color_enable || par->low_power) { in ssd1307fb_init()
456 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
461 mode = (par->area_color_enable ? 0x30 : 0) | in ssd1307fb_init()
462 (par->low_power ? 5 : 0); in ssd1307fb_init()
463 ret = ssd1307fb_write_cmd(par->client, mode); in ssd1307fb_init()
469 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD); in ssd1307fb_init()
473 precharge = (par->prechargep1 & 0xf) | (par->prechargep2 & 0xf) << 4; in ssd1307fb_init()
474 ret = ssd1307fb_write_cmd(par->client, precharge); in ssd1307fb_init()
479 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG); in ssd1307fb_init()
483 compins = 0x02 | !par->com_seq << 4 | par->com_lrremap << 5; in ssd1307fb_init()
484 ret = ssd1307fb_write_cmd(par->client, compins); in ssd1307fb_init()
489 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH); in ssd1307fb_init()
493 ret = ssd1307fb_write_cmd(par->client, par->vcomh); in ssd1307fb_init()
498 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP); in ssd1307fb_init()
502 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
503 BIT(4) | (par->device_info->need_chargepump ? BIT(2) : 0)); in ssd1307fb_init()
508 if (par->lookup_table_set) { in ssd1307fb_init()
511 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
516 for (i = 0; i < ARRAY_SIZE(par->lookup_table); ++i) { in ssd1307fb_init()
517 u8 val = par->lookup_table[i]; in ssd1307fb_init()
520 dev_warn(&par->client->dev, in ssd1307fb_init()
523 ret = ssd1307fb_write_cmd(par->client, val); in ssd1307fb_init()
530 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE); in ssd1307fb_init()
534 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
540 ret = ssd1307fb_update_display(par); in ssd1307fb_init()
545 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON); in ssd1307fb_init()
554 struct ssd1307fb_par *par = bl_get_data(bdev); in ssd1307fb_update_bl() local
558 par->contrast = brightness; in ssd1307fb_update_bl()
560 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); in ssd1307fb_update_bl()
563 ret = ssd1307fb_write_cmd(par->client, par->contrast); in ssd1307fb_update_bl()
571 struct ssd1307fb_par *par = bl_get_data(bdev); in ssd1307fb_get_brightness() local
573 return par->contrast; in ssd1307fb_get_brightness()
644 struct ssd1307fb_par *par; in ssd1307fb_probe() local
652 par = info->par; in ssd1307fb_probe()
653 par->info = info; in ssd1307fb_probe()
654 par->client = client; in ssd1307fb_probe()
656 par->device_info = device_get_match_data(dev); in ssd1307fb_probe()
658 par->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ssd1307fb_probe()
659 if (IS_ERR(par->reset)) { in ssd1307fb_probe()
661 PTR_ERR(par->reset)); in ssd1307fb_probe()
662 ret = PTR_ERR(par->reset); in ssd1307fb_probe()
666 par->vbat_reg = devm_regulator_get_optional(dev, "vbat"); in ssd1307fb_probe()
667 if (IS_ERR(par->vbat_reg)) { in ssd1307fb_probe()
668 ret = PTR_ERR(par->vbat_reg); in ssd1307fb_probe()
670 par->vbat_reg = NULL; in ssd1307fb_probe()
677 if (device_property_read_u32(dev, "solomon,width", &par->width)) in ssd1307fb_probe()
678 par->width = 96; in ssd1307fb_probe()
680 if (device_property_read_u32(dev, "solomon,height", &par->height)) in ssd1307fb_probe()
681 par->height = 16; in ssd1307fb_probe()
683 if (device_property_read_u32(dev, "solomon,page-offset", &par->page_offset)) in ssd1307fb_probe()
684 par->page_offset = 1; in ssd1307fb_probe()
686 if (device_property_read_u32(dev, "solomon,col-offset", &par->col_offset)) in ssd1307fb_probe()
687 par->col_offset = 0; in ssd1307fb_probe()
689 if (device_property_read_u32(dev, "solomon,com-offset", &par->com_offset)) in ssd1307fb_probe()
690 par->com_offset = 0; in ssd1307fb_probe()
692 if (device_property_read_u32(dev, "solomon,prechargep1", &par->prechargep1)) in ssd1307fb_probe()
693 par->prechargep1 = 2; in ssd1307fb_probe()
695 if (device_property_read_u32(dev, "solomon,prechargep2", &par->prechargep2)) in ssd1307fb_probe()
696 par->prechargep2 = 2; in ssd1307fb_probe()
699 par->lookup_table, in ssd1307fb_probe()
700 ARRAY_SIZE(par->lookup_table))) in ssd1307fb_probe()
701 par->lookup_table_set = 1; in ssd1307fb_probe()
703 par->seg_remap = !device_property_read_bool(dev, "solomon,segment-no-remap"); in ssd1307fb_probe()
704 par->com_seq = device_property_read_bool(dev, "solomon,com-seq"); in ssd1307fb_probe()
705 par->com_lrremap = device_property_read_bool(dev, "solomon,com-lrremap"); in ssd1307fb_probe()
706 par->com_invdir = device_property_read_bool(dev, "solomon,com-invdir"); in ssd1307fb_probe()
707 par->area_color_enable = in ssd1307fb_probe()
709 par->low_power = device_property_read_bool(dev, "solomon,low-power"); in ssd1307fb_probe()
711 par->contrast = 127; in ssd1307fb_probe()
712 par->vcomh = par->device_info->default_vcomh; in ssd1307fb_probe()
715 if (device_property_read_u32(dev, "solomon,dclk-div", &par->dclk_div)) in ssd1307fb_probe()
716 par->dclk_div = par->device_info->default_dclk_div; in ssd1307fb_probe()
717 if (device_property_read_u32(dev, "solomon,dclk-frq", &par->dclk_frq)) in ssd1307fb_probe()
718 par->dclk_frq = par->device_info->default_dclk_frq; in ssd1307fb_probe()
720 vmem_size = DIV_ROUND_UP(par->width, 8) * par->height; in ssd1307fb_probe()
743 info->fix.line_length = DIV_ROUND_UP(par->width, 8); in ssd1307fb_probe()
747 info->var.xres = par->width; in ssd1307fb_probe()
748 info->var.xres_virtual = par->width; in ssd1307fb_probe()
749 info->var.yres = par->height; in ssd1307fb_probe()
750 info->var.yres_virtual = par->height; in ssd1307fb_probe()
760 if (par->reset) { in ssd1307fb_probe()
762 gpiod_set_value_cansleep(par->reset, 1); in ssd1307fb_probe()
764 gpiod_set_value_cansleep(par->reset, 0); in ssd1307fb_probe()
768 if (par->vbat_reg) { in ssd1307fb_probe()
769 ret = regulator_enable(par->vbat_reg); in ssd1307fb_probe()
776 ret = ssd1307fb_init(par); in ssd1307fb_probe()
787 bl = backlight_device_register(bl_name, dev, par, &ssd1307fb_bl_ops, in ssd1307fb_probe()
795 bl->props.brightness = par->contrast; in ssd1307fb_probe()
806 if (par->device_info->need_pwm) { in ssd1307fb_probe()
807 pwm_disable(par->pwm); in ssd1307fb_probe()
808 pwm_put(par->pwm); in ssd1307fb_probe()
811 if (par->vbat_reg) in ssd1307fb_probe()
812 regulator_disable(par->vbat_reg); in ssd1307fb_probe()
823 struct ssd1307fb_par *par = info->par; in ssd1307fb_remove() local
825 ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_OFF); in ssd1307fb_remove()
830 if (par->device_info->need_pwm) { in ssd1307fb_remove()
831 pwm_disable(par->pwm); in ssd1307fb_remove()
832 pwm_put(par->pwm); in ssd1307fb_remove()
834 if (par->vbat_reg) in ssd1307fb_remove()
835 regulator_disable(par->vbat_reg); in ssd1307fb_remove()