Lines Matching +full:segment +full:- +full:no +full:- +full:remap
1 // SPDX-License-Identifier: GPL-2.0-or-later
122 array->type = type; in ssd1307fb_alloc_array()
136 dev_err(&client->dev, "Couldn't send I2C command.\n"); in ssd1307fb_write_array()
150 return -ENOMEM; in ssd1307fb_write_cmd()
152 array->data[0] = cmd; in ssd1307fb_write_cmd()
163 u8 col_end = col_start + cols - 1; in ssd1307fb_set_col_range()
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()
189 u8 page_end = page_start + pages - 1; in ssd1307fb_set_page_range()
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()
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()
225 return -ENOMEM; in ssd1307fb_update_rect()
236 * wide. Each letter-number combination is a bit that controls 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()
279 array->data[array_idx++] = data; in ssd1307fb_update_rect()
283 ret = ssd1307fb_write_array(par->client, array, width * pages); in ssd1307fb_update_rect()
292 return ssd1307fb_update_rect(par, 0, 0, par->width, par->height); in ssd1307fb_update_display()
297 struct ssd1307fb_par *par = info->par; in ssd1307fb_blank()
300 return ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_OFF); in ssd1307fb_blank()
302 return ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON); in ssd1307fb_blank()
307 struct ssd1307fb_par *par = info->par; in ssd1307fb_defio_damage_range()
315 struct ssd1307fb_par *par = info->par; in ssd1307fb_defio_damage_area()
332 ssd1307fb_update_display(info->par); in ssd1307fb_deferred_io()
341 if (par->device_info->need_pwm) { in ssd1307fb_init()
342 par->pwm = pwm_get(&par->client->dev, NULL); in ssd1307fb_init()
343 if (IS_ERR(par->pwm)) { in ssd1307fb_init()
344 dev_err(&par->client->dev, "Could not get PWM from device tree!\n"); in ssd1307fb_init()
345 return PTR_ERR(par->pwm); in ssd1307fb_init()
348 pwm_init_state(par->pwm, &pwmstate); in ssd1307fb_init()
350 pwm_apply_might_sleep(par->pwm, &pwmstate); in ssd1307fb_init()
353 pwm_enable(par->pwm); in ssd1307fb_init()
355 dev_dbg(&par->client->dev, "Using PWM %s with a %lluns period.\n", in ssd1307fb_init()
356 par->pwm->label, pwm_get_period(par->pwm)); in ssd1307fb_init()
360 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); in ssd1307fb_init()
364 ret = ssd1307fb_write_cmd(par->client, par->contrast); in ssd1307fb_init()
368 /* Set segment re-map */ in ssd1307fb_init()
369 if (par->seg_remap) { in ssd1307fb_init()
370 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON); in ssd1307fb_init()
376 com_invdir = 0xc0 | par->com_invdir << 3; in ssd1307fb_init()
377 ret = ssd1307fb_write_cmd(par->client, com_invdir); in ssd1307fb_init()
382 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO); in ssd1307fb_init()
386 ret = ssd1307fb_write_cmd(par->client, par->height - 1); in ssd1307fb_init()
391 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET); in ssd1307fb_init()
395 ret = ssd1307fb_write_cmd(par->client, par->com_offset); in ssd1307fb_init()
400 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ); in ssd1307fb_init()
404 dclk = ((par->dclk_div - 1) & 0xf) | (par->dclk_frq & 0xf) << 4; in ssd1307fb_init()
405 ret = ssd1307fb_write_cmd(par->client, dclk); in ssd1307fb_init()
410 if (par->area_color_enable || par->low_power) { in ssd1307fb_init()
413 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
418 mode = (par->area_color_enable ? 0x30 : 0) | in ssd1307fb_init()
419 (par->low_power ? 5 : 0); in ssd1307fb_init()
420 ret = ssd1307fb_write_cmd(par->client, mode); in ssd1307fb_init()
426 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD); in ssd1307fb_init()
430 precharge = (par->prechargep1 & 0xf) | (par->prechargep2 & 0xf) << 4; in ssd1307fb_init()
431 ret = ssd1307fb_write_cmd(par->client, precharge); in ssd1307fb_init()
436 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG); in ssd1307fb_init()
440 compins = 0x02 | !par->com_seq << 4 | par->com_lrremap << 5; in ssd1307fb_init()
441 ret = ssd1307fb_write_cmd(par->client, compins); in ssd1307fb_init()
446 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH); in ssd1307fb_init()
450 ret = ssd1307fb_write_cmd(par->client, par->vcomh); in ssd1307fb_init()
454 /* Turn on the DC-DC Charge Pump */ in ssd1307fb_init()
455 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP); in ssd1307fb_init()
459 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
460 BIT(4) | (par->device_info->need_chargepump ? BIT(2) : 0)); in ssd1307fb_init()
465 if (par->lookup_table_set) { in ssd1307fb_init()
468 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
473 for (i = 0; i < ARRAY_SIZE(par->lookup_table); ++i) { in ssd1307fb_init()
474 u8 val = par->lookup_table[i]; in ssd1307fb_init()
477 dev_warn(&par->client->dev, in ssd1307fb_init()
480 ret = ssd1307fb_write_cmd(par->client, val); in ssd1307fb_init()
487 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE); in ssd1307fb_init()
491 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
502 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON); in ssd1307fb_init()
513 int brightness = bdev->props.brightness; in ssd1307fb_update_bl()
515 par->contrast = brightness; in ssd1307fb_update_bl()
517 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); in ssd1307fb_update_bl()
520 ret = ssd1307fb_write_cmd(par->client, par->contrast); in ssd1307fb_update_bl()
530 return par->contrast; in ssd1307fb_get_brightness()
567 .compatible = "solomon,ssd1305fb-i2c",
571 .compatible = "solomon,ssd1306fb-i2c",
575 .compatible = "solomon,ssd1307fb-i2c",
579 .compatible = "solomon,ssd1309fb-i2c",
588 struct device *dev = &client->dev; in ssd1307fb_probe()
599 return -ENOMEM; in ssd1307fb_probe()
601 par = info->par; in ssd1307fb_probe()
602 par->info = info; in ssd1307fb_probe()
603 par->client = client; in ssd1307fb_probe()
605 par->device_info = device_get_match_data(dev); in ssd1307fb_probe()
607 par->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ssd1307fb_probe()
608 if (IS_ERR(par->reset)) { in ssd1307fb_probe()
609 ret = dev_err_probe(dev, PTR_ERR(par->reset), in ssd1307fb_probe()
614 par->vbat_reg = devm_regulator_get_optional(dev, "vbat"); in ssd1307fb_probe()
615 if (IS_ERR(par->vbat_reg)) { in ssd1307fb_probe()
616 ret = PTR_ERR(par->vbat_reg); in ssd1307fb_probe()
617 if (ret == -ENODEV) { in ssd1307fb_probe()
618 par->vbat_reg = NULL; in ssd1307fb_probe()
625 if (device_property_read_u32(dev, "solomon,width", &par->width)) in ssd1307fb_probe()
626 par->width = 96; in ssd1307fb_probe()
628 if (device_property_read_u32(dev, "solomon,height", &par->height)) in ssd1307fb_probe()
629 par->height = 16; in ssd1307fb_probe()
631 if (device_property_read_u32(dev, "solomon,page-offset", &par->page_offset)) in ssd1307fb_probe()
632 par->page_offset = 1; in ssd1307fb_probe()
634 if (device_property_read_u32(dev, "solomon,col-offset", &par->col_offset)) in ssd1307fb_probe()
635 par->col_offset = 0; in ssd1307fb_probe()
637 if (device_property_read_u32(dev, "solomon,com-offset", &par->com_offset)) in ssd1307fb_probe()
638 par->com_offset = 0; in ssd1307fb_probe()
640 if (device_property_read_u32(dev, "solomon,prechargep1", &par->prechargep1)) in ssd1307fb_probe()
641 par->prechargep1 = 2; in ssd1307fb_probe()
643 if (device_property_read_u32(dev, "solomon,prechargep2", &par->prechargep2)) in ssd1307fb_probe()
644 par->prechargep2 = 2; in ssd1307fb_probe()
646 if (!device_property_read_u8_array(dev, "solomon,lookup-table", in ssd1307fb_probe()
647 par->lookup_table, in ssd1307fb_probe()
648 ARRAY_SIZE(par->lookup_table))) in ssd1307fb_probe()
649 par->lookup_table_set = 1; in ssd1307fb_probe()
651 par->seg_remap = !device_property_read_bool(dev, "solomon,segment-no-remap"); in ssd1307fb_probe()
652 par->com_seq = device_property_read_bool(dev, "solomon,com-seq"); in ssd1307fb_probe()
653 par->com_lrremap = device_property_read_bool(dev, "solomon,com-lrremap"); in ssd1307fb_probe()
654 par->com_invdir = device_property_read_bool(dev, "solomon,com-invdir"); in ssd1307fb_probe()
655 par->area_color_enable = in ssd1307fb_probe()
656 device_property_read_bool(dev, "solomon,area-color-enable"); in ssd1307fb_probe()
657 par->low_power = device_property_read_bool(dev, "solomon,low-power"); in ssd1307fb_probe()
659 par->contrast = 127; in ssd1307fb_probe()
660 par->vcomh = par->device_info->default_vcomh; in ssd1307fb_probe()
663 if (device_property_read_u32(dev, "solomon,dclk-div", &par->dclk_div)) in ssd1307fb_probe()
664 par->dclk_div = par->device_info->default_dclk_div; in ssd1307fb_probe()
665 if (device_property_read_u32(dev, "solomon,dclk-frq", &par->dclk_frq)) in ssd1307fb_probe()
666 par->dclk_frq = par->device_info->default_dclk_frq; in ssd1307fb_probe()
668 vmem_size = DIV_ROUND_UP(par->width, 8) * par->height; in ssd1307fb_probe()
674 ret = -ENOMEM; in ssd1307fb_probe()
682 ret = -ENOMEM; in ssd1307fb_probe()
686 ssd1307fb_defio->delay = HZ / refreshrate; in ssd1307fb_probe()
687 ssd1307fb_defio->deferred_io = ssd1307fb_deferred_io; in ssd1307fb_probe()
689 info->fbops = &ssd1307fb_ops; in ssd1307fb_probe()
690 info->fix = ssd1307fb_fix; in ssd1307fb_probe()
691 info->fix.line_length = DIV_ROUND_UP(par->width, 8); in ssd1307fb_probe()
692 info->fbdefio = ssd1307fb_defio; in ssd1307fb_probe()
694 info->var = ssd1307fb_var; in ssd1307fb_probe()
695 info->var.xres = par->width; in ssd1307fb_probe()
696 info->var.xres_virtual = par->width; in ssd1307fb_probe()
697 info->var.yres = par->height; in ssd1307fb_probe()
698 info->var.yres_virtual = par->height; in ssd1307fb_probe()
700 info->screen_buffer = vmem; in ssd1307fb_probe()
701 info->fix.smem_start = __pa(vmem); in ssd1307fb_probe()
702 info->fix.smem_len = vmem_size; in ssd1307fb_probe()
708 if (par->reset) { in ssd1307fb_probe()
710 gpiod_set_value_cansleep(par->reset, 1); in ssd1307fb_probe()
712 gpiod_set_value_cansleep(par->reset, 0); in ssd1307fb_probe()
716 if (par->vbat_reg) { in ssd1307fb_probe()
717 ret = regulator_enable(par->vbat_reg); in ssd1307fb_probe()
728 bl = backlight_device_register("ssd1307fb-bl", dev, par, &ssd1307fb_bl_ops, in ssd1307fb_probe()
735 info->bl_dev = bl; in ssd1307fb_probe()
743 bl->props.brightness = par->contrast; in ssd1307fb_probe()
744 bl->props.max_brightness = MAX_CONTRAST; in ssd1307fb_probe()
746 …framebuffer device registered, using %d bytes of video memory\n", info->node, info->fix.id, vmem_s… in ssd1307fb_probe()
753 pwm_disable(par->pwm); in ssd1307fb_probe()
754 pwm_put(par->pwm); in ssd1307fb_probe()
756 if (par->vbat_reg) in ssd1307fb_probe()
757 regulator_disable(par->vbat_reg); in ssd1307fb_probe()
768 struct ssd1307fb_par *par = info->par; in ssd1307fb_remove()
770 ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_OFF); in ssd1307fb_remove()
772 backlight_device_unregister(info->bl_dev); in ssd1307fb_remove()
775 pwm_disable(par->pwm); in ssd1307fb_remove()
776 pwm_put(par->pwm); in ssd1307fb_remove()
777 if (par->vbat_reg) in ssd1307fb_remove()
778 regulator_disable(par->vbat_reg); in ssd1307fb_remove()
780 __free_pages(__va(info->fix.smem_start), get_order(info->fix.smem_len)); in ssd1307fb_remove()
806 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");