Lines Matching +full:com +full:- +full:lrremap
1 // SPDX-License-Identifier: GPL-2.0-only
6 * Author: Javier Martinez Canillas <javierm@redhat.com>
138 return regmap_bulk_write(ssd130x->regmap, SSD130X_DATA, values, count); in ssd130x_write_data()
160 ret = regmap_write(ssd130x->regmap, SSD130X_COMMAND, value); in ssd130x_write_cmd()
163 } while (--count); in ssd130x_write_cmd()
175 u8 col_end = col_start + cols - 1; in ssd130x_set_col_range()
178 if (col_start == ssd130x->col_start && col_end == ssd130x->col_end) in ssd130x_set_col_range()
185 ssd130x->col_start = col_start; in ssd130x_set_col_range()
186 ssd130x->col_end = col_end; in ssd130x_set_col_range()
193 u8 page_end = page_start + pages - 1; in ssd130x_set_page_range()
196 if (page_start == ssd130x->page_start && page_end == ssd130x->page_end) in ssd130x_set_page_range()
203 ssd130x->page_start = page_start; in ssd130x_set_page_range()
204 ssd130x->page_end = page_end; in ssd130x_set_page_range()
230 struct device *dev = ssd130x->dev; in ssd130x_pwm_enable()
233 ssd130x->pwm = pwm_get(dev, NULL); in ssd130x_pwm_enable()
234 if (IS_ERR(ssd130x->pwm)) { in ssd130x_pwm_enable()
236 return PTR_ERR(ssd130x->pwm); in ssd130x_pwm_enable()
239 pwm_init_state(ssd130x->pwm, &pwmstate); in ssd130x_pwm_enable()
241 pwm_apply_state(ssd130x->pwm, &pwmstate); in ssd130x_pwm_enable()
244 pwm_enable(ssd130x->pwm); in ssd130x_pwm_enable()
247 ssd130x->pwm->pwm, pwm_get_period(ssd130x->pwm)); in ssd130x_pwm_enable()
254 if (!ssd130x->reset) in ssd130x_reset()
258 gpiod_set_value_cansleep(ssd130x->reset, 1); in ssd130x_reset()
260 gpiod_set_value_cansleep(ssd130x->reset, 0); in ssd130x_reset()
266 struct device *dev = ssd130x->dev; in ssd130x_power_on()
271 ret = regulator_enable(ssd130x->vcc_reg); in ssd130x_power_on()
277 if (ssd130x->device_info->need_pwm) { in ssd130x_power_on()
281 regulator_disable(ssd130x->vcc_reg); in ssd130x_power_on()
291 pwm_disable(ssd130x->pwm); in ssd130x_power_off()
292 pwm_put(ssd130x->pwm); in ssd130x_power_off()
294 regulator_disable(ssd130x->vcc_reg); in ssd130x_power_off()
303 ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_CONTRAST, ssd130x->contrast); in ssd130x_init()
307 /* Set segment re-map */ in ssd130x_init()
309 SSD130X_SET_SEG_REMAP_SET(ssd130x->seg_remap)); in ssd130x_init()
314 /* Set COM direction */ in ssd130x_init()
316 SSD130X_SET_COM_SCAN_DIR_SET(ssd130x->com_invdir)); in ssd130x_init()
322 ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_MULTIPLEX_RATIO, ssd130x->height - 1); in ssd130x_init()
327 ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_DISPLAY_OFFSET, ssd130x->com_offset); in ssd130x_init()
332 dclk = (SSD130X_SET_CLOCK_DIV_SET(ssd130x->dclk_div - 1) | in ssd130x_init()
333 SSD130X_SET_CLOCK_FREQ_SET(ssd130x->dclk_frq)); in ssd130x_init()
339 if (ssd130x->area_color_enable || ssd130x->low_power) { in ssd130x_init()
342 if (ssd130x->area_color_enable) in ssd130x_init()
345 if (ssd130x->low_power) in ssd130x_init()
354 precharge = (SSD130X_SET_PRECHARGE_PERIOD1_SET(ssd130x->prechargep1) | in ssd130x_init()
355 SSD130X_SET_PRECHARGE_PERIOD2_SET(ssd130x->prechargep2)); in ssd130x_init()
360 /* Set COM pins configuration */ in ssd130x_init()
362 compins |= (SSD130X_SET_COM_PINS_CONFIG1_SET(ssd130x->com_seq) | in ssd130x_init()
363 SSD130X_SET_COM_PINS_CONFIG2_SET(ssd130x->com_lrremap)); in ssd130x_init()
369 ret = ssd130x_write_cmd(ssd130x, 2, SSD130X_SET_VCOMH, ssd130x->vcomh); in ssd130x_init()
373 /* Turn on the DC-DC Charge Pump */ in ssd130x_init()
376 if (ssd130x->device_info->need_chargepump) in ssd130x_init()
384 if (ssd130x->lookup_table_set) { in ssd130x_init()
391 for (i = 0; i < ARRAY_SIZE(ssd130x->lookup_table); i++) { in ssd130x_init()
392 u8 val = ssd130x->lookup_table[i]; in ssd130x_init()
395 dev_warn(ssd130x->dev, in ssd130x_init()
405 if (ssd130x->page_address_mode) in ssd130x_init()
417 unsigned int x = rect->x1; in ssd130x_update_rect()
418 unsigned int y = rect->y1; in ssd130x_update_rect()
423 struct drm_device *drm = &ssd130x->drm; in ssd130x_update_rect()
432 return -ENOMEM; in ssd130x_update_rect()
443 * wide. Each letter-number combination is a bit that controls in ssd130x_update_rect()
463 if (!ssd130x->page_address_mode) { in ssd130x_update_rect()
465 ret = ssd130x_set_col_range(ssd130x, ssd130x->col_offset + x, width); in ssd130x_update_rect()
469 ret = ssd130x_set_page_range(ssd130x, ssd130x->page_offset + y / 8, pages); in ssd130x_update_rect()
478 if (8 * (y / 8 + i + 1) > ssd130x->height) in ssd130x_update_rect()
479 m = ssd130x->height % 8; in ssd130x_update_rect()
496 if (ssd130x->page_address_mode) { in ssd130x_update_rect()
498 ssd130x->page_offset + i, in ssd130x_update_rect()
499 ssd130x->col_offset + x); in ssd130x_update_rect()
512 if (!ssd130x->page_address_mode) in ssd130x_update_rect()
525 .x2 = ssd130x->width, in ssd130x_clear_screen()
527 .y2 = ssd130x->height, in ssd130x_clear_screen()
530 buf = kcalloc(DIV_ROUND_UP(ssd130x->width, 8), ssd130x->height, in ssd130x_clear_screen()
543 struct ssd130x_device *ssd130x = drm_to_ssd130x(fb->dev); in ssd130x_fb_blit_rect()
550 rect->y1 = round_down(rect->y1, 8); in ssd130x_fb_blit_rect()
551 rect->y2 = min_t(unsigned int, round_up(rect->y2, 8), ssd130x->height); in ssd130x_fb_blit_rect()
556 return -ENOMEM; in ssd130x_fb_blit_rect()
581 struct drm_device *drm = plane->dev; in ssd130x_primary_plane_helper_atomic_update()
588 dst_clip = plane_state->dst; in ssd130x_primary_plane_helper_atomic_update()
595 ssd130x_fb_blit_rect(plane_state->fb, &shadow_plane_state->data[0], &dst_clip); in ssd130x_primary_plane_helper_atomic_update()
603 struct drm_device *drm = plane->dev; in ssd130x_primary_plane_helper_atomic_disable()
632 struct ssd130x_device *ssd130x = drm_to_ssd130x(crtc->dev); in ssd130x_crtc_helper_mode_valid()
634 if (mode->hdisplay != ssd130x->mode.hdisplay && in ssd130x_crtc_helper_mode_valid()
635 mode->vdisplay != ssd130x->mode.vdisplay) in ssd130x_crtc_helper_mode_valid()
637 else if (mode->hdisplay != ssd130x->mode.hdisplay) in ssd130x_crtc_helper_mode_valid()
639 else if (mode->vdisplay != ssd130x->mode.vdisplay) in ssd130x_crtc_helper_mode_valid()
670 struct drm_device *drm = crtc->dev; in ssd130x_crtc_reset()
690 struct drm_device *drm = encoder->dev; in ssd130x_encoder_helper_atomic_enable()
700 backlight_enable(ssd130x->bl_dev); in ssd130x_encoder_helper_atomic_enable()
706 struct drm_device *drm = encoder->dev; in ssd130x_encoder_helper_atomic_disable()
709 backlight_disable(ssd130x->bl_dev); in ssd130x_encoder_helper_atomic_disable()
727 struct ssd130x_device *ssd130x = drm_to_ssd130x(connector->dev); in ssd130x_connector_helper_get_modes()
729 struct device *dev = ssd130x->dev; in ssd130x_connector_helper_get_modes()
731 mode = drm_mode_duplicate(connector->dev, &ssd130x->mode); in ssd130x_connector_helper_get_modes()
738 drm_set_preferred_mode(connector, mode->hdisplay, mode->vdisplay); in ssd130x_connector_helper_get_modes()
785 ssd130x->contrast = brightness; in ssd130x_update_bl()
791 ret = ssd130x_write_cmd(ssd130x, 1, ssd130x->contrast); in ssd130x_update_bl()
804 struct device *dev = ssd130x->dev; in ssd130x_parse_properties()
806 if (device_property_read_u32(dev, "solomon,width", &ssd130x->width)) in ssd130x_parse_properties()
807 ssd130x->width = 96; in ssd130x_parse_properties()
809 if (device_property_read_u32(dev, "solomon,height", &ssd130x->height)) in ssd130x_parse_properties()
810 ssd130x->height = 16; in ssd130x_parse_properties()
812 if (device_property_read_u32(dev, "solomon,page-offset", &ssd130x->page_offset)) in ssd130x_parse_properties()
813 ssd130x->page_offset = 1; in ssd130x_parse_properties()
815 if (device_property_read_u32(dev, "solomon,col-offset", &ssd130x->col_offset)) in ssd130x_parse_properties()
816 ssd130x->col_offset = 0; in ssd130x_parse_properties()
818 if (device_property_read_u32(dev, "solomon,com-offset", &ssd130x->com_offset)) in ssd130x_parse_properties()
819 ssd130x->com_offset = 0; in ssd130x_parse_properties()
821 if (device_property_read_u32(dev, "solomon,prechargep1", &ssd130x->prechargep1)) in ssd130x_parse_properties()
822 ssd130x->prechargep1 = 2; in ssd130x_parse_properties()
824 if (device_property_read_u32(dev, "solomon,prechargep2", &ssd130x->prechargep2)) in ssd130x_parse_properties()
825 ssd130x->prechargep2 = 2; in ssd130x_parse_properties()
827 if (!device_property_read_u8_array(dev, "solomon,lookup-table", in ssd130x_parse_properties()
828 ssd130x->lookup_table, in ssd130x_parse_properties()
829 ARRAY_SIZE(ssd130x->lookup_table))) in ssd130x_parse_properties()
830 ssd130x->lookup_table_set = 1; in ssd130x_parse_properties()
832 ssd130x->seg_remap = !device_property_read_bool(dev, "solomon,segment-no-remap"); in ssd130x_parse_properties()
833 ssd130x->com_seq = device_property_read_bool(dev, "solomon,com-seq"); in ssd130x_parse_properties()
834 ssd130x->com_lrremap = device_property_read_bool(dev, "solomon,com-lrremap"); in ssd130x_parse_properties()
835 ssd130x->com_invdir = device_property_read_bool(dev, "solomon,com-invdir"); in ssd130x_parse_properties()
836 ssd130x->area_color_enable = in ssd130x_parse_properties()
837 device_property_read_bool(dev, "solomon,area-color-enable"); in ssd130x_parse_properties()
838 ssd130x->low_power = device_property_read_bool(dev, "solomon,low-power"); in ssd130x_parse_properties()
840 ssd130x->contrast = 127; in ssd130x_parse_properties()
841 ssd130x->vcomh = ssd130x->device_info->default_vcomh; in ssd130x_parse_properties()
844 if (device_property_read_u32(dev, "solomon,dclk-div", &ssd130x->dclk_div)) in ssd130x_parse_properties()
845 ssd130x->dclk_div = ssd130x->device_info->default_dclk_div; in ssd130x_parse_properties()
846 if (device_property_read_u32(dev, "solomon,dclk-frq", &ssd130x->dclk_frq)) in ssd130x_parse_properties()
847 ssd130x->dclk_frq = ssd130x->device_info->default_dclk_frq; in ssd130x_parse_properties()
852 struct drm_display_mode *mode = &ssd130x->mode; in ssd130x_init_modeset()
853 struct device *dev = ssd130x->dev; in ssd130x_init_modeset()
854 struct drm_device *drm = &ssd130x->drm; in ssd130x_init_modeset()
872 mode->type = DRM_MODE_TYPE_DRIVER; in ssd130x_init_modeset()
873 mode->clock = 1; in ssd130x_init_modeset()
874 mode->hdisplay = mode->htotal = ssd130x->width; in ssd130x_init_modeset()
875 mode->hsync_start = mode->hsync_end = ssd130x->width; in ssd130x_init_modeset()
876 mode->vdisplay = mode->vtotal = ssd130x->height; in ssd130x_init_modeset()
877 mode->vsync_start = mode->vsync_end = ssd130x->height; in ssd130x_init_modeset()
878 mode->width_mm = 27; in ssd130x_init_modeset()
879 mode->height_mm = 27; in ssd130x_init_modeset()
881 max_width = max_t(unsigned long, mode->hdisplay, DRM_SHADOW_PLANE_MAX_WIDTH); in ssd130x_init_modeset()
882 max_height = max_t(unsigned long, mode->vdisplay, DRM_SHADOW_PLANE_MAX_HEIGHT); in ssd130x_init_modeset()
884 drm->mode_config.min_width = mode->hdisplay; in ssd130x_init_modeset()
885 drm->mode_config.max_width = max_width; in ssd130x_init_modeset()
886 drm->mode_config.min_height = mode->vdisplay; in ssd130x_init_modeset()
887 drm->mode_config.max_height = max_height; in ssd130x_init_modeset()
888 drm->mode_config.preferred_depth = 32; in ssd130x_init_modeset()
889 drm->mode_config.funcs = &ssd130x_mode_config_funcs; in ssd130x_init_modeset()
893 primary_plane = &ssd130x->primary_plane; in ssd130x_init_modeset()
908 crtc = &ssd130x->crtc; in ssd130x_init_modeset()
920 encoder = &ssd130x->encoder; in ssd130x_init_modeset()
930 encoder->possible_crtcs = drm_crtc_mask(crtc); in ssd130x_init_modeset()
934 connector = &ssd130x->connector; in ssd130x_init_modeset()
957 struct device *dev = ssd130x->dev; in ssd130x_get_resources()
959 ssd130x->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); in ssd130x_get_resources()
960 if (IS_ERR(ssd130x->reset)) in ssd130x_get_resources()
961 return dev_err_probe(dev, PTR_ERR(ssd130x->reset), in ssd130x_get_resources()
964 ssd130x->vcc_reg = devm_regulator_get(dev, "vcc"); in ssd130x_get_resources()
965 if (IS_ERR(ssd130x->vcc_reg)) in ssd130x_get_resources()
966 return dev_err_probe(dev, PTR_ERR(ssd130x->vcc_reg), in ssd130x_get_resources()
985 drm = &ssd130x->drm; in ssd130x_probe()
987 ssd130x->dev = dev; in ssd130x_probe()
988 ssd130x->regmap = regmap; in ssd130x_probe()
989 ssd130x->device_info = device_get_match_data(dev); in ssd130x_probe()
991 if (ssd130x->device_info->page_mode_only) in ssd130x_probe()
992 ssd130x->page_address_mode = 1; in ssd130x_probe()
1006 bl->props.brightness = ssd130x->contrast; in ssd130x_probe()
1007 bl->props.max_brightness = MAX_CONTRAST; in ssd130x_probe()
1008 ssd130x->bl_dev = bl; in ssd130x_probe()
1026 drm_dev_unplug(&ssd130x->drm); in ssd130x_remove()
1032 drm_atomic_helper_shutdown(&ssd130x->drm); in ssd130x_shutdown()
1037 MODULE_AUTHOR("Javier Martinez Canillas <javierm@redhat.com>");