Lines Matching refs:ctx

145 static int st7789v_spi_write(struct st7789v *ctx, enum st7789v_prefix prefix,
154 return spi_sync_transfer(ctx->spi, &xfer, 1);
157 static int st7789v_write_command(struct st7789v *ctx, u8 cmd)
159 return st7789v_spi_write(ctx, ST7789V_COMMAND, cmd);
162 static int st7789v_write_data(struct st7789v *ctx, u8 cmd)
164 return st7789v_spi_write(ctx, ST7789V_DATA, cmd);
167 static int st7789v_read_data(struct st7789v *ctx, u8 cmd, u8 *buf,
196 ret = spi_sync(ctx->spi, &msg);
212 struct st7789v *ctx = panel_to_st7789v(panel);
217 if (ctx->spi->mode & SPI_NO_RX)
220 ret = st7789v_read_data(ctx, MIPI_DCS_GET_DISPLAY_ID, ids, ST7789V_IDS_SIZE);
335 struct st7789v *ctx = panel_to_st7789v(panel);
338 mode = drm_mode_duplicate(connector->dev, ctx->info->mode);
341 ctx->info->mode->hdisplay, ctx->info->mode->vdisplay,
342 drm_mode_vrefresh(ctx->info->mode));
352 connector->display_info.width_mm = ctx->info->mode->width_mm;
353 connector->display_info.height_mm = ctx->info->mode->height_mm;
354 connector->display_info.bus_flags = ctx->info->bus_flags;
356 &ctx->info->bus_format, 1);
362 drm_connector_set_panel_orientation(connector, ctx->orientation);
369 struct st7789v *ctx = panel_to_st7789v(p);
371 return ctx->orientation;
376 struct st7789v *ctx = panel_to_st7789v(panel);
380 if (!ctx->info->partial_mode)
385 switch (ctx->info->bus_format) {
394 ctx->info->bus_format);
401 if (ctx->info->mode->flags & DRM_MODE_FLAG_PVSYNC)
403 if (ctx->info->mode->flags & DRM_MODE_FLAG_PHSYNC)
405 if (ctx->info->bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE)
407 if (ctx->info->bus_flags & DRM_BUS_FLAG_DE_LOW)
410 ret = regulator_enable(ctx->power);
414 gpiod_set_value(ctx->reset, 1);
416 gpiod_set_value(ctx->reset, 0);
427 ST7789V_TEST(ret, st7789v_write_command(ctx, MIPI_DCS_EXIT_SLEEP_MODE));
432 ST7789V_TEST(ret, st7789v_write_command(ctx,
434 ST7789V_TEST(ret, st7789v_write_data(ctx, 0));
436 ST7789V_TEST(ret, st7789v_write_command(ctx,
438 ST7789V_TEST(ret, st7789v_write_data(ctx, pixel_fmt));
440 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_PORCTRL_CMD));
441 ST7789V_TEST(ret, st7789v_write_data(ctx, 0xc));
442 ST7789V_TEST(ret, st7789v_write_data(ctx, 0xc));
443 ST7789V_TEST(ret, st7789v_write_data(ctx, 0));
444 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PORCTRL_IDLE_BP(3) |
446 ST7789V_TEST(ret, st7789v_write_data(ctx,
450 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_GCTRL_CMD));
451 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_GCTRL_VGLS(5) |
454 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_VCOMS_CMD));
455 ST7789V_TEST(ret, st7789v_write_data(ctx, 0x2b));
457 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_LCMCTRL_CMD));
458 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_LCMCTRL_XMH |
462 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_VDVVRHEN_CMD));
463 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_VDVVRHEN_CMDEN));
465 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_VRHS_CMD));
466 ST7789V_TEST(ret, st7789v_write_data(ctx, 0xf));
468 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_VDVS_CMD));
469 ST7789V_TEST(ret, st7789v_write_data(ctx, 0x20));
471 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_FRCTRL2_CMD));
472 ST7789V_TEST(ret, st7789v_write_data(ctx, 0xf));
474 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_PWCTRL1_CMD));
475 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PWCTRL1_MAGIC));
476 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PWCTRL1_AVDD(2) |
480 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_PVGAMCTRL_CMD));
481 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP63(0xd)));
482 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP1(0xca)));
483 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP2(0xe)));
484 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP4(8)));
485 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP6(9)));
486 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP13(7)));
487 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP20(0x2d)));
488 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP27(0xb) |
490 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP43(0x3d)));
491 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_JP1(3) |
493 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP57(0xa)));
494 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP59(0xa)));
495 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP61(0x1b)));
496 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_PVGAMCTRL_VP62(0x28)));
498 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_NVGAMCTRL_CMD));
499 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN63(0xd)));
500 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN1(0xca)));
501 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN2(0xf)));
502 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN4(8)));
503 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN6(8)));
504 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN13(7)));
505 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN20(0x2e)));
506 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN27(0xc) |
508 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN43(0x40)));
509 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_JN1(3) |
511 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN57(9)));
512 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN59(0xb)));
513 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN61(0x1b)));
514 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_NVGAMCTRL_VN62(0x28)));
516 if (ctx->info->invert_mode) {
517 ST7789V_TEST(ret, st7789v_write_command(ctx,
520 ST7789V_TEST(ret, st7789v_write_command(ctx,
524 if (ctx->info->partial_mode) {
526 (ctx->info->partial_start >> 8) & 0xff,
527 (ctx->info->partial_start >> 0) & 0xff,
528 ((ctx->info->partial_end - 1) >> 8) & 0xff,
529 ((ctx->info->partial_end - 1) >> 0) & 0xff,
538 ctx, MIPI_DCS_ENTER_PARTIAL_MODE));
541 ctx, MIPI_DCS_SET_PAGE_ADDRESS));
542 ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[0]));
543 ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[1]));
544 ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[2]));
545 ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[3]));
548 ctx, MIPI_DCS_SET_PARTIAL_ROWS));
549 ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[0]));
550 ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[1]));
551 ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[2]));
552 ST7789V_TEST(ret, st7789v_write_data(ctx, area_data[3]));
555 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_RAMCTRL_CMD));
556 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RAMCTRL_DM_RGB |
558 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RAMCTRL_EPF(3) |
561 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_RGBCTRL_CMD));
562 ST7789V_TEST(ret, st7789v_write_data(ctx, mode |
565 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_VBP(8)));
566 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_HBP(20)));
573 struct st7789v *ctx = panel_to_st7789v(panel);
575 return st7789v_write_command(ctx, MIPI_DCS_SET_DISPLAY_ON);
580 struct st7789v *ctx = panel_to_st7789v(panel);
583 ST7789V_TEST(ret, st7789v_write_command(ctx, MIPI_DCS_SET_DISPLAY_OFF));
590 struct st7789v *ctx = panel_to_st7789v(panel);
593 ST7789V_TEST(ret, st7789v_write_command(ctx, MIPI_DCS_ENTER_SLEEP_MODE));
595 regulator_disable(ctx->power);
612 struct st7789v *ctx;
615 ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
616 if (!ctx)
619 spi_set_drvdata(spi, ctx);
620 ctx->spi = spi;
627 ctx->info = device_get_match_data(&spi->dev);
629 drm_panel_init(&ctx->panel, dev, &st7789v_drm_funcs,
632 ctx->power = devm_regulator_get(dev, "power");
633 ret = PTR_ERR_OR_ZERO(ctx->power);
637 ctx->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
638 ret = PTR_ERR_OR_ZERO(ctx->reset);
642 ret = drm_panel_of_backlight(&ctx->panel);
646 of_drm_get_panel_orientation(spi->dev.of_node, &ctx->orientation);
648 drm_panel_add(&ctx->panel);
655 struct st7789v *ctx = spi_get_drvdata(spi);
657 drm_panel_remove(&ctx->panel);