Lines Matching +full:com +full:- +full:invdir
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()
298 struct ssd1307fb_par *par = info->par; in ssd1307fb_write()
304 total_size = info->fix.smem_len; in ssd1307fb_write()
307 return -EINVAL; in ssd1307fb_write()
310 count = total_size - p; in ssd1307fb_write()
313 return -EINVAL; in ssd1307fb_write()
315 dst = info->screen_buffer + p; in ssd1307fb_write()
318 return -EFAULT; in ssd1307fb_write()
331 struct ssd1307fb_par *par = info->par; in ssd1307fb_blank()
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()
343 ssd1307fb_update_rect(par, rect->dx, rect->dy, rect->width, in ssd1307fb_fillrect()
344 rect->height); in ssd1307fb_fillrect()
349 struct ssd1307fb_par *par = info->par; in ssd1307fb_copyarea()
351 ssd1307fb_update_rect(par, area->dx, area->dy, area->width, in ssd1307fb_copyarea()
352 area->height); in ssd1307fb_copyarea()
357 struct ssd1307fb_par *par = info->par; in ssd1307fb_imageblit()
359 ssd1307fb_update_rect(par, image->dx, image->dy, image->width, in ssd1307fb_imageblit()
360 image->height); in ssd1307fb_imageblit()
376 ssd1307fb_update_display(info->par); in ssd1307fb_deferred_io()
385 if (par->device_info->need_pwm) { in ssd1307fb_init()
386 par->pwm = pwm_get(&par->client->dev, NULL); in ssd1307fb_init()
387 if (IS_ERR(par->pwm)) { in ssd1307fb_init()
388 dev_err(&par->client->dev, "Could not get PWM from device tree!\n"); in ssd1307fb_init()
389 return PTR_ERR(par->pwm); in ssd1307fb_init()
392 pwm_init_state(par->pwm, &pwmstate); in ssd1307fb_init()
394 pwm_apply_state(par->pwm, &pwmstate); in ssd1307fb_init()
397 pwm_enable(par->pwm); in ssd1307fb_init()
399 dev_dbg(&par->client->dev, "Using PWM%d with a %lluns period.\n", in ssd1307fb_init()
400 par->pwm->pwm, pwm_get_period(par->pwm)); in ssd1307fb_init()
404 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); in ssd1307fb_init()
408 ret = ssd1307fb_write_cmd(par->client, par->contrast); in ssd1307fb_init()
412 /* Set segment re-map */ in ssd1307fb_init()
413 if (par->seg_remap) { in ssd1307fb_init()
414 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON); in ssd1307fb_init()
419 /* Set COM direction */ in ssd1307fb_init()
420 com_invdir = 0xc0 | par->com_invdir << 3; in ssd1307fb_init()
421 ret = ssd1307fb_write_cmd(par->client, com_invdir); in ssd1307fb_init()
426 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_MULTIPLEX_RATIO); in ssd1307fb_init()
430 ret = ssd1307fb_write_cmd(par->client, par->height - 1); in ssd1307fb_init()
435 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_DISPLAY_OFFSET); in ssd1307fb_init()
439 ret = ssd1307fb_write_cmd(par->client, par->com_offset); in ssd1307fb_init()
444 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_CLOCK_FREQ); in ssd1307fb_init()
448 dclk = ((par->dclk_div - 1) & 0xf) | (par->dclk_frq & 0xf) << 4; in ssd1307fb_init()
449 ret = ssd1307fb_write_cmd(par->client, dclk); in ssd1307fb_init()
454 if (par->area_color_enable || par->low_power) { in ssd1307fb_init()
457 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
462 mode = (par->area_color_enable ? 0x30 : 0) | in ssd1307fb_init()
463 (par->low_power ? 5 : 0); in ssd1307fb_init()
464 ret = ssd1307fb_write_cmd(par->client, mode); in ssd1307fb_init()
470 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD); in ssd1307fb_init()
474 precharge = (par->prechargep1 & 0xf) | (par->prechargep2 & 0xf) << 4; in ssd1307fb_init()
475 ret = ssd1307fb_write_cmd(par->client, precharge); in ssd1307fb_init()
479 /* Set COM pins configuration */ in ssd1307fb_init()
480 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COM_PINS_CONFIG); in ssd1307fb_init()
484 compins = 0x02 | !par->com_seq << 4 | par->com_lrremap << 5; in ssd1307fb_init()
485 ret = ssd1307fb_write_cmd(par->client, compins); in ssd1307fb_init()
490 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_VCOMH); in ssd1307fb_init()
494 ret = ssd1307fb_write_cmd(par->client, par->vcomh); in ssd1307fb_init()
498 /* Turn on the DC-DC Charge Pump */ in ssd1307fb_init()
499 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CHARGE_PUMP); in ssd1307fb_init()
503 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
504 BIT(4) | (par->device_info->need_chargepump ? BIT(2) : 0)); in ssd1307fb_init()
509 if (par->lookup_table_set) { in ssd1307fb_init()
512 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
517 for (i = 0; i < ARRAY_SIZE(par->lookup_table); ++i) { in ssd1307fb_init()
518 u8 val = par->lookup_table[i]; in ssd1307fb_init()
521 dev_warn(&par->client->dev, in ssd1307fb_init()
524 ret = ssd1307fb_write_cmd(par->client, val); in ssd1307fb_init()
531 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE); in ssd1307fb_init()
535 ret = ssd1307fb_write_cmd(par->client, in ssd1307fb_init()
546 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON); in ssd1307fb_init()
557 int brightness = bdev->props.brightness; in ssd1307fb_update_bl()
559 par->contrast = brightness; in ssd1307fb_update_bl()
561 ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); in ssd1307fb_update_bl()
564 ret = ssd1307fb_write_cmd(par->client, par->contrast); in ssd1307fb_update_bl()
574 return par->contrast; in ssd1307fb_get_brightness()
580 return (info->bl_dev == bdev); in ssd1307fb_check_fb()
618 .compatible = "solomon,ssd1305fb-i2c",
622 .compatible = "solomon,ssd1306fb-i2c",
626 .compatible = "solomon,ssd1307fb-i2c",
630 .compatible = "solomon,ssd1309fb-i2c",
639 struct device *dev = &client->dev; in ssd1307fb_probe()
651 return -ENOMEM; in ssd1307fb_probe()
653 par = info->par; in ssd1307fb_probe()
654 par->info = info; in ssd1307fb_probe()
655 par->client = client; in ssd1307fb_probe()
657 par->device_info = device_get_match_data(dev); in ssd1307fb_probe()
659 par->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ssd1307fb_probe()
660 if (IS_ERR(par->reset)) { in ssd1307fb_probe()
661 ret = dev_err_probe(dev, 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()
669 if (ret == -ENODEV) { 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()
698 if (!device_property_read_u8_array(dev, "solomon,lookup-table", 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()
708 device_property_read_bool(dev, "solomon,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()
726 ret = -ENOMEM; in ssd1307fb_probe()
734 ret = -ENOMEM; in ssd1307fb_probe()
738 ssd1307fb_defio->delay = HZ / refreshrate; in ssd1307fb_probe()
739 ssd1307fb_defio->deferred_io = ssd1307fb_deferred_io; in ssd1307fb_probe()
741 info->fbops = &ssd1307fb_ops; in ssd1307fb_probe()
742 info->fix = ssd1307fb_fix; in ssd1307fb_probe()
743 info->fix.line_length = DIV_ROUND_UP(par->width, 8); in ssd1307fb_probe()
744 info->fbdefio = ssd1307fb_defio; in ssd1307fb_probe()
746 info->var = ssd1307fb_var; 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()
752 info->screen_buffer = vmem; in ssd1307fb_probe()
753 info->fix.smem_start = __pa(vmem); in ssd1307fb_probe()
754 info->fix.smem_len = vmem_size; 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()
786 snprintf(bl_name, sizeof(bl_name), "ssd1307fb%d", info->node); in ssd1307fb_probe()
795 bl->props.brightness = par->contrast; in ssd1307fb_probe()
796 bl->props.max_brightness = MAX_CONTRAST; in ssd1307fb_probe()
797 info->bl_dev = bl; in ssd1307fb_probe()
799 …framebuffer device registered, using %d bytes of video memory\n", info->node, info->fix.id, vmem_s… 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()
825 ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_OFF); in ssd1307fb_remove()
827 backlight_device_unregister(info->bl_dev); 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()
837 __free_pages(__va(info->fix.smem_start), get_order(info->fix.smem_len)); in ssd1307fb_remove()
863 MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");