Lines Matching refs:st7571

97 	int (*init)(struct st7571_device *st7571);
98 int (*parse_dt)(struct st7571_device *st7571);
103 void (*prepare_buffer)(struct st7571_device *st7571,
176 struct st7571_device *st7571 = i2c_get_clientdata(client); in st7571_regmap_write() local
180 .addr = st7571->client->addr, in st7571_regmap_write()
181 .flags = st7571->ignore_nak ? I2C_M_IGNORE_NAK : 0, in st7571_regmap_write()
186 ret = i2c_transfer(st7571->client->adapter, &msg, 1); in st7571_regmap_write()
194 if (ret < 0 && st7571->ignore_nak) in st7571_regmap_write()
207 static int st7571_send_command_list(struct st7571_device *st7571, in st7571_send_command_list() argument
213 ret = regmap_write(st7571->regmap, ST7571_COMMAND_MODE, cmd_list[i]); in st7571_send_command_list()
248 static int st7571_set_position(struct st7571_device *st7571, int x, int y) in st7571_set_position() argument
256 return st7571_send_command_list(st7571, cmd_list, ARRAY_SIZE(cmd_list)); in st7571_set_position()
259 static int st7571_fb_clear_screen(struct st7571_device *st7571) in st7571_fb_clear_screen() argument
261 u32 npixels = st7571->ncols * round_up(st7571->nlines, ST7571_PAGE_HEIGHT) * st7571->bpp; in st7571_fb_clear_screen()
265 regmap_bulk_write(st7571->regmap, ST7571_DATA_MODE, &pixelvalue, 1); in st7571_fb_clear_screen()
270 static void st7571_prepare_buffer_monochrome(struct st7571_device *st7571, in st7571_prepare_buffer_monochrome() argument
283 iosys_map_set_vaddr(&dst, st7571->hwbuf); in st7571_prepare_buffer_monochrome()
290 memcpy(st7571->hwbuf, vmap->vaddr, size); in st7571_prepare_buffer_monochrome()
295 static void st7571_prepare_buffer_grayscale(struct st7571_device *st7571, in st7571_prepare_buffer_grayscale() argument
308 iosys_map_set_vaddr(&dst, st7571->hwbuf); in st7571_prepare_buffer_grayscale()
315 memcpy(st7571->hwbuf, vmap->vaddr, size); in st7571_prepare_buffer_grayscale()
320 memcpy(st7571->hwbuf, vmap->vaddr, size); in st7571_prepare_buffer_grayscale()
327 struct st7571_device *st7571 = drm_to_st7571(fb->dev); in st7571_fb_update_rect_monochrome() local
328 char *row = st7571->row; in st7571_fb_update_rect_monochrome()
332 rect->y2 = min_t(unsigned int, round_up(rect->y2, ST7571_PAGE_HEIGHT), st7571->nlines); in st7571_fb_update_rect_monochrome()
336 row[x] = st7571_transform_xy(st7571->hwbuf, x, y); in st7571_fb_update_rect_monochrome()
338 st7571_set_position(st7571, rect->x1, y); in st7571_fb_update_rect_monochrome()
342 regmap_bulk_write(st7571->regmap, ST7571_DATA_MODE, row + x, 1); in st7571_fb_update_rect_monochrome()
350 struct st7571_device *st7571 = drm_to_st7571(fb->dev); in st7571_fb_update_rect_grayscale() local
352 char *row = st7571->row; in st7571_fb_update_rect_grayscale()
358 rect->y2 = min_t(unsigned int, round_up(rect->y2, ST7571_PAGE_HEIGHT), st7571->nlines); in st7571_fb_update_rect_grayscale()
376 row[x] = st7571_transform_xy(st7571->hwbuf, x, y); in st7571_fb_update_rect_grayscale()
378 st7571_set_position(st7571, rect->x1, y); in st7571_fb_update_rect_grayscale()
382 regmap_bulk_write(st7571->regmap, ST7571_DATA_MODE, row + x, 1); in st7571_fb_update_rect_grayscale()
398 regmap_bulk_write(st7571->regmap, ST7571_DATA_MODE, row + x, 1); in st7571_fb_update_rect_grayscale()
407 struct st7571_device *st7571 = drm_to_st7571(conn->dev); in st7571_connector_get_modes() local
409 return drm_connector_helper_get_modes_fixed(conn, &st7571->mode); in st7571_connector_get_modes()
470 struct st7571_device *st7571 = drm_to_st7571(plane->dev); in st7571_primary_plane_helper_atomic_update() local
485 st7571->pformat->prepare_buffer(st7571, in st7571_primary_plane_helper_atomic_update()
490 st7571->pformat->update_rect(fb, &damage); in st7571_primary_plane_helper_atomic_update()
503 struct st7571_device *st7571 = drm_to_st7571(plane->dev); in st7571_primary_plane_helper_atomic_disable() local
509 st7571_fb_clear_screen(st7571); in st7571_primary_plane_helper_atomic_disable()
534 struct st7571_device *st7571 = drm_to_st7571(crtc->dev); in st7571_crtc_mode_valid() local
536 return drm_crtc_helper_mode_valid_fixed(crtc, mode, &st7571->mode); in st7571_crtc_mode_valid()
561 struct st7571_device *st7571 = drm_to_st7571(drm); in st7571_encoder_atomic_enable() local
565 ret = st7571->pdata->init(st7571); in st7571_encoder_atomic_enable()
569 st7571_send_command_list(st7571, &command, 1); in st7571_encoder_atomic_enable()
576 struct st7571_device *st7571 = drm_to_st7571(drm); in st7571_encoder_atomic_disable() local
579 st7571_send_command_list(st7571, &command, 1); in st7571_encoder_atomic_disable()
610 static struct drm_display_mode st7571_mode(struct st7571_device *st7571) in st7571_mode() argument
613 DRM_SIMPLE_MODE(st7571->ncols, st7571->nlines, in st7571_mode()
614 st7571->width_mm, st7571->height_mm), in st7571_mode()
620 static int st7571_mode_config_init(struct st7571_device *st7571) in st7571_mode_config_init() argument
622 struct drm_device *dev = &st7571->dev; in st7571_mode_config_init()
623 const struct st7571_panel_constraints *constraints = &st7571->pdata->constraints; in st7571_mode_config_init()
640 static int st7571_plane_init(struct st7571_device *st7571, in st7571_plane_init() argument
643 struct drm_plane *primary_plane = &st7571->primary_plane; in st7571_plane_init()
644 struct drm_device *dev = &st7571->dev; in st7571_plane_init()
662 static int st7571_crtc_init(struct st7571_device *st7571) in st7571_crtc_init() argument
664 struct drm_plane *primary_plane = &st7571->primary_plane; in st7571_crtc_init()
665 struct drm_crtc *crtc = &st7571->crtc; in st7571_crtc_init()
666 struct drm_device *dev = &st7571->dev; in st7571_crtc_init()
679 static int st7571_encoder_init(struct st7571_device *st7571) in st7571_encoder_init() argument
681 struct drm_encoder *encoder = &st7571->encoder; in st7571_encoder_init()
682 struct drm_crtc *crtc = &st7571->crtc; in st7571_encoder_init()
683 struct drm_device *dev = &st7571->dev; in st7571_encoder_init()
697 static int st7571_connector_init(struct st7571_device *st7571) in st7571_connector_init() argument
699 struct drm_connector *connector = &st7571->connector; in st7571_connector_init()
700 struct drm_encoder *encoder = &st7571->encoder; in st7571_connector_init()
701 struct drm_device *dev = &st7571->dev; in st7571_connector_init()
740 static int st7571_validate_parameters(struct st7571_device *st7571) in st7571_validate_parameters() argument
742 struct device *dev = st7571->dev.dev; in st7571_validate_parameters()
743 const struct st7571_panel_constraints *constraints = &st7571->pdata->constraints; in st7571_validate_parameters()
745 if (st7571->width_mm == 0) { in st7571_validate_parameters()
750 if (st7571->height_mm == 0) { in st7571_validate_parameters()
755 if (st7571->nlines < constraints->min_nlines || in st7571_validate_parameters()
756 st7571->nlines > constraints->max_nlines) { in st7571_validate_parameters()
761 if (st7571->startline + st7571->nlines > constraints->max_nlines) { in st7571_validate_parameters()
766 if (st7571->ncols < constraints->min_ncols || in st7571_validate_parameters()
767 st7571->ncols > constraints->max_ncols) { in st7571_validate_parameters()
772 if (st7571->grayscale && !constraints->support_grayscale) { in st7571_validate_parameters()
806 static int st7571_parse_dt(struct st7571_device *st7571) in st7571_parse_dt() argument
808 struct device *dev = &st7571->client->dev; in st7571_parse_dt()
819 of_property_read_u32(np, "width-mm", &st7571->width_mm); in st7571_parse_dt()
820 of_property_read_u32(np, "height-mm", &st7571->height_mm); in st7571_parse_dt()
821 st7571->grayscale = of_property_read_bool(np, "sitronix,grayscale"); in st7571_parse_dt()
823 if (st7571->grayscale) { in st7571_parse_dt()
824 st7571->pformat = &st7571_grayscale; in st7571_parse_dt()
825 st7571->bpp = 2; in st7571_parse_dt()
827 st7571->pformat = &st7571_monochrome; in st7571_parse_dt()
828 st7571->bpp = 1; in st7571_parse_dt()
831 st7571->startline = dt.vfront_porch.typ; in st7571_parse_dt()
832 st7571->nlines = dt.vactive.typ; in st7571_parse_dt()
833 st7571->ncols = dt.hactive.typ; in st7571_parse_dt()
835 st7571->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in st7571_parse_dt()
836 if (IS_ERR(st7571->reset)) in st7571_parse_dt()
837 return dev_err_probe(dev, PTR_ERR(st7571->reset), in st7571_parse_dt()
844 static void st7571_reset(struct st7571_device *st7571) in st7571_reset() argument
846 gpiod_set_value_cansleep(st7571->reset, 1); in st7571_reset()
848 gpiod_set_value_cansleep(st7571->reset, 0); in st7571_reset()
883 static int st7571_lcd_init(struct st7571_device *st7571) in st7571_lcd_init() argument
902 ST7571_SET_START_LINE_LSB(st7571->startline), in st7571_lcd_init()
910 ST7571_SET_DISPLAY_DUTY_LSB(st7571->nlines), in st7571_lcd_init()
917 ST7571_SET_COLOR_MODE(st7571->pformat->mode), in st7571_lcd_init()
925 st7571_reset(st7571); in st7571_lcd_init()
927 return st7571_send_command_list(st7571, commands, ARRAY_SIZE(commands)); in st7571_lcd_init()
932 struct st7571_device *st7571; in st7571_probe() local
936 st7571 = devm_drm_dev_alloc(&client->dev, &st7571_driver, in st7571_probe()
938 if (IS_ERR(st7571)) in st7571_probe()
939 return PTR_ERR(st7571); in st7571_probe()
941 dev = &st7571->dev; in st7571_probe()
942 st7571->client = client; in st7571_probe()
943 i2c_set_clientdata(client, st7571); in st7571_probe()
944 st7571->pdata = device_get_match_data(&client->dev); in st7571_probe()
946 ret = st7571->pdata->parse_dt(st7571); in st7571_probe()
950 ret = st7571_validate_parameters(st7571); in st7571_probe()
954 st7571->mode = st7571_mode(st7571); in st7571_probe()
963 st7571->ignore_nak = true; in st7571_probe()
965 st7571->regmap = devm_regmap_init(&client->dev, &st7571_regmap_bus, in st7571_probe()
967 if (IS_ERR(st7571->regmap)) { in st7571_probe()
968 return dev_err_probe(&client->dev, PTR_ERR(st7571->regmap), in st7571_probe()
972 st7571->hwbuf = devm_kzalloc(&client->dev, in st7571_probe()
973 (st7571->nlines * st7571->ncols * st7571->bpp) / 8, in st7571_probe()
975 if (!st7571->hwbuf) in st7571_probe()
978 st7571->row = devm_kzalloc(&client->dev, in st7571_probe()
979 (st7571->ncols * st7571->bpp), in st7571_probe()
981 if (!st7571->row) in st7571_probe()
984 ret = st7571_mode_config_init(st7571); in st7571_probe()
989 ret = st7571_plane_init(st7571, st7571->pformat); in st7571_probe()
994 ret = st7571_crtc_init(st7571); in st7571_probe()
999 ret = st7571_encoder_init(st7571); in st7571_probe()
1004 ret = st7571_connector_init(st7571); in st7571_probe()
1022 struct st7571_device *st7571 = i2c_get_clientdata(client); in st7571_remove() local
1024 drm_dev_unplug(&st7571->dev); in st7571_remove()