• Home
  • Raw
  • Download

Lines Matching refs:ctx

129 static int s6e8aa0_clear_error(struct s6e8aa0 *ctx)  in s6e8aa0_clear_error()  argument
131 int ret = ctx->error; in s6e8aa0_clear_error()
133 ctx->error = 0; in s6e8aa0_clear_error()
137 static void s6e8aa0_dcs_write(struct s6e8aa0 *ctx, const void *data, size_t len) in s6e8aa0_dcs_write() argument
139 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in s6e8aa0_dcs_write()
142 if (ctx->error < 0) in s6e8aa0_dcs_write()
147 dev_err(ctx->dev, "error %zd writing dcs seq: %*ph\n", ret, in s6e8aa0_dcs_write()
149 ctx->error = ret; in s6e8aa0_dcs_write()
153 static int s6e8aa0_dcs_read(struct s6e8aa0 *ctx, u8 cmd, void *data, size_t len) in s6e8aa0_dcs_read() argument
155 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in s6e8aa0_dcs_read()
158 if (ctx->error < 0) in s6e8aa0_dcs_read()
159 return ctx->error; in s6e8aa0_dcs_read()
163 dev_err(ctx->dev, "error %d reading dcs seq(%#x)\n", ret, cmd); in s6e8aa0_dcs_read()
164 ctx->error = ret; in s6e8aa0_dcs_read()
170 #define s6e8aa0_dcs_write_seq(ctx, seq...) \ argument
174 s6e8aa0_dcs_write(ctx, d, ARRAY_SIZE(d));\
177 #define s6e8aa0_dcs_write_seq_static(ctx, seq...) \ argument
180 s6e8aa0_dcs_write(ctx, d, ARRAY_SIZE(d));\
183 static void s6e8aa0_apply_level_1_key(struct s6e8aa0 *ctx) in s6e8aa0_apply_level_1_key() argument
185 s6e8aa0_dcs_write_seq_static(ctx, 0xf0, 0x5a, 0x5a); in s6e8aa0_apply_level_1_key()
188 static void s6e8aa0_panel_cond_set_v142(struct s6e8aa0 *ctx) in s6e8aa0_panel_cond_set_v142() argument
193 u8 aid = aids[ctx->id >> 5]; in s6e8aa0_panel_cond_set_v142()
202 if (ctx->flip_vertical) { in s6e8aa0_panel_cond_set_v142()
208 if (ctx->flip_horizontal) { in s6e8aa0_panel_cond_set_v142()
214 if (ctx->flip_horizontal || ctx->flip_vertical) { in s6e8aa0_panel_cond_set_v142()
250 s6e8aa0_dcs_write_seq(ctx, in s6e8aa0_panel_cond_set_v142()
259 static void s6e8aa0_panel_cond_set(struct s6e8aa0 *ctx) in s6e8aa0_panel_cond_set() argument
261 if (ctx->version < 142) in s6e8aa0_panel_cond_set()
262 s6e8aa0_dcs_write_seq_static(ctx, in s6e8aa0_panel_cond_set()
270 s6e8aa0_panel_cond_set_v142(ctx); in s6e8aa0_panel_cond_set()
273 static void s6e8aa0_display_condition_set(struct s6e8aa0 *ctx) in s6e8aa0_display_condition_set() argument
275 s6e8aa0_dcs_write_seq_static(ctx, 0xf2, 0x80, 0x03, 0x0d); in s6e8aa0_display_condition_set()
278 static void s6e8aa0_etc_source_control(struct s6e8aa0 *ctx) in s6e8aa0_etc_source_control() argument
280 s6e8aa0_dcs_write_seq_static(ctx, 0xf6, 0x00, 0x02, 0x00); in s6e8aa0_etc_source_control()
283 static void s6e8aa0_etc_pentile_control(struct s6e8aa0 *ctx) in s6e8aa0_etc_pentile_control() argument
293 if (ctx->version < 142) in s6e8aa0_etc_pentile_control()
294 s6e8aa0_dcs_write(ctx, pent32, ARRAY_SIZE(pent32)); in s6e8aa0_etc_pentile_control()
296 s6e8aa0_dcs_write(ctx, pent142, ARRAY_SIZE(pent142)); in s6e8aa0_etc_pentile_control()
299 static void s6e8aa0_etc_power_control(struct s6e8aa0 *ctx) in s6e8aa0_etc_power_control() argument
309 if (ctx->version < 142) in s6e8aa0_etc_power_control()
310 s6e8aa0_dcs_write(ctx, pwr32, ARRAY_SIZE(pwr32)); in s6e8aa0_etc_power_control()
312 s6e8aa0_dcs_write(ctx, pwr142, ARRAY_SIZE(pwr142)); in s6e8aa0_etc_power_control()
315 static void s6e8aa0_etc_elvss_control(struct s6e8aa0 *ctx) in s6e8aa0_etc_elvss_control() argument
317 u8 id = ctx->id ? 0 : 0x95; in s6e8aa0_etc_elvss_control()
319 s6e8aa0_dcs_write_seq(ctx, 0xb1, 0x04, id); in s6e8aa0_etc_elvss_control()
322 static void s6e8aa0_elvss_nvm_set_v142(struct s6e8aa0 *ctx) in s6e8aa0_elvss_nvm_set_v142() argument
326 switch (ctx->brightness) { in s6e8aa0_elvss_nvm_set_v142()
342 s6e8aa0_dcs_write_seq(ctx, 0xd9, 0x14, 0x40, 0x0c, 0xcb, 0xce, 0x6e, in s6e8aa0_elvss_nvm_set_v142()
346 static void s6e8aa0_elvss_nvm_set(struct s6e8aa0 *ctx) in s6e8aa0_elvss_nvm_set() argument
348 if (ctx->version < 142) in s6e8aa0_elvss_nvm_set()
349 s6e8aa0_dcs_write_seq_static(ctx, in s6e8aa0_elvss_nvm_set()
353 s6e8aa0_elvss_nvm_set_v142(ctx); in s6e8aa0_elvss_nvm_set()
356 static void s6e8aa0_apply_level_2_key(struct s6e8aa0 *ctx) in s6e8aa0_apply_level_2_key() argument
358 s6e8aa0_dcs_write_seq_static(ctx, 0xfc, 0x5a, 0x5a); in s6e8aa0_apply_level_2_key()
765 static void s6e8aa0_brightness_set(struct s6e8aa0 *ctx) in s6e8aa0_brightness_set() argument
769 if (ctx->error) in s6e8aa0_brightness_set()
772 gamma = ctx->variant->gamma_tables[ctx->brightness]; in s6e8aa0_brightness_set()
774 if (ctx->version >= 142) in s6e8aa0_brightness_set()
775 s6e8aa0_elvss_nvm_set(ctx); in s6e8aa0_brightness_set()
777 s6e8aa0_dcs_write(ctx, gamma, GAMMA_TABLE_LEN); in s6e8aa0_brightness_set()
780 s6e8aa0_dcs_write_seq_static(ctx, 0xf7, 0x03); in s6e8aa0_brightness_set()
783 static void s6e8aa0_panel_init(struct s6e8aa0 *ctx) in s6e8aa0_panel_init() argument
785 s6e8aa0_apply_level_1_key(ctx); in s6e8aa0_panel_init()
786 s6e8aa0_apply_level_2_key(ctx); in s6e8aa0_panel_init()
789 s6e8aa0_dcs_write_seq_static(ctx, MIPI_DCS_EXIT_SLEEP_MODE); in s6e8aa0_panel_init()
792 s6e8aa0_panel_cond_set(ctx); in s6e8aa0_panel_init()
793 s6e8aa0_display_condition_set(ctx); in s6e8aa0_panel_init()
794 s6e8aa0_brightness_set(ctx); in s6e8aa0_panel_init()
795 s6e8aa0_etc_source_control(ctx); in s6e8aa0_panel_init()
796 s6e8aa0_etc_pentile_control(ctx); in s6e8aa0_panel_init()
797 s6e8aa0_elvss_nvm_set(ctx); in s6e8aa0_panel_init()
798 s6e8aa0_etc_power_control(ctx); in s6e8aa0_panel_init()
799 s6e8aa0_etc_elvss_control(ctx); in s6e8aa0_panel_init()
800 msleep(ctx->init_delay); in s6e8aa0_panel_init()
803 static void s6e8aa0_set_maximum_return_packet_size(struct s6e8aa0 *ctx, in s6e8aa0_set_maximum_return_packet_size() argument
806 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in s6e8aa0_set_maximum_return_packet_size()
809 if (ctx->error < 0) in s6e8aa0_set_maximum_return_packet_size()
814 dev_err(ctx->dev, in s6e8aa0_set_maximum_return_packet_size()
817 ctx->error = ret; in s6e8aa0_set_maximum_return_packet_size()
821 static void s6e8aa0_read_mtp_id(struct s6e8aa0 *ctx) in s6e8aa0_read_mtp_id() argument
826 ret = s6e8aa0_dcs_read(ctx, 0xd1, id, ARRAY_SIZE(id)); in s6e8aa0_read_mtp_id()
828 dev_err(ctx->dev, "read id failed\n"); in s6e8aa0_read_mtp_id()
829 ctx->error = -EIO; in s6e8aa0_read_mtp_id()
833 dev_info(ctx->dev, "ID: 0x%2x, 0x%2x, 0x%2x\n", id[0], id[1], id[2]); in s6e8aa0_read_mtp_id()
840 dev_err(ctx->dev, "unsupported display version %d\n", id[1]); in s6e8aa0_read_mtp_id()
841 ctx->error = -EINVAL; in s6e8aa0_read_mtp_id()
845 ctx->variant = &s6e8aa0_variants[i]; in s6e8aa0_read_mtp_id()
846 ctx->version = id[1]; in s6e8aa0_read_mtp_id()
847 ctx->id = id[2]; in s6e8aa0_read_mtp_id()
850 static void s6e8aa0_set_sequence(struct s6e8aa0 *ctx) in s6e8aa0_set_sequence() argument
852 s6e8aa0_set_maximum_return_packet_size(ctx, 3); in s6e8aa0_set_sequence()
853 s6e8aa0_read_mtp_id(ctx); in s6e8aa0_set_sequence()
854 s6e8aa0_panel_init(ctx); in s6e8aa0_set_sequence()
855 s6e8aa0_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_ON); in s6e8aa0_set_sequence()
858 static int s6e8aa0_power_on(struct s6e8aa0 *ctx) in s6e8aa0_power_on() argument
862 ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in s6e8aa0_power_on()
866 msleep(ctx->power_on_delay); in s6e8aa0_power_on()
868 gpiod_set_value(ctx->reset_gpio, 0); in s6e8aa0_power_on()
870 gpiod_set_value(ctx->reset_gpio, 1); in s6e8aa0_power_on()
872 msleep(ctx->reset_delay); in s6e8aa0_power_on()
877 static int s6e8aa0_power_off(struct s6e8aa0 *ctx) in s6e8aa0_power_off() argument
879 return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in s6e8aa0_power_off()
889 struct s6e8aa0 *ctx = panel_to_s6e8aa0(panel); in s6e8aa0_unprepare() local
891 s6e8aa0_dcs_write_seq_static(ctx, MIPI_DCS_ENTER_SLEEP_MODE); in s6e8aa0_unprepare()
892 s6e8aa0_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_OFF); in s6e8aa0_unprepare()
895 s6e8aa0_clear_error(ctx); in s6e8aa0_unprepare()
897 return s6e8aa0_power_off(ctx); in s6e8aa0_unprepare()
902 struct s6e8aa0 *ctx = panel_to_s6e8aa0(panel); in s6e8aa0_prepare() local
905 ret = s6e8aa0_power_on(ctx); in s6e8aa0_prepare()
909 s6e8aa0_set_sequence(ctx); in s6e8aa0_prepare()
910 ret = ctx->error; in s6e8aa0_prepare()
926 struct s6e8aa0 *ctx = panel_to_s6e8aa0(panel); in s6e8aa0_get_modes() local
935 drm_display_mode_from_videomode(&ctx->vm, mode); in s6e8aa0_get_modes()
936 mode->width_mm = ctx->width_mm; in s6e8aa0_get_modes()
937 mode->height_mm = ctx->height_mm; in s6e8aa0_get_modes()
955 static int s6e8aa0_parse_dt(struct s6e8aa0 *ctx) in s6e8aa0_parse_dt() argument
957 struct device *dev = ctx->dev; in s6e8aa0_parse_dt()
961 ret = of_get_videomode(np, &ctx->vm, 0); in s6e8aa0_parse_dt()
965 of_property_read_u32(np, "power-on-delay", &ctx->power_on_delay); in s6e8aa0_parse_dt()
966 of_property_read_u32(np, "reset-delay", &ctx->reset_delay); in s6e8aa0_parse_dt()
967 of_property_read_u32(np, "init-delay", &ctx->init_delay); in s6e8aa0_parse_dt()
968 of_property_read_u32(np, "panel-width-mm", &ctx->width_mm); in s6e8aa0_parse_dt()
969 of_property_read_u32(np, "panel-height-mm", &ctx->height_mm); in s6e8aa0_parse_dt()
971 ctx->flip_horizontal = of_property_read_bool(np, "flip-horizontal"); in s6e8aa0_parse_dt()
972 ctx->flip_vertical = of_property_read_bool(np, "flip-vertical"); in s6e8aa0_parse_dt()
980 struct s6e8aa0 *ctx; in s6e8aa0_probe() local
983 ctx = devm_kzalloc(dev, sizeof(struct s6e8aa0), GFP_KERNEL); in s6e8aa0_probe()
984 if (!ctx) in s6e8aa0_probe()
987 mipi_dsi_set_drvdata(dsi, ctx); in s6e8aa0_probe()
989 ctx->dev = dev; in s6e8aa0_probe()
998 ret = s6e8aa0_parse_dt(ctx); in s6e8aa0_probe()
1002 ctx->supplies[0].supply = "vdd3"; in s6e8aa0_probe()
1003 ctx->supplies[1].supply = "vci"; in s6e8aa0_probe()
1004 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies), in s6e8aa0_probe()
1005 ctx->supplies); in s6e8aa0_probe()
1011 ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in s6e8aa0_probe()
1012 if (IS_ERR(ctx->reset_gpio)) { in s6e8aa0_probe()
1014 PTR_ERR(ctx->reset_gpio)); in s6e8aa0_probe()
1015 return PTR_ERR(ctx->reset_gpio); in s6e8aa0_probe()
1018 ctx->brightness = GAMMA_LEVEL_NUM - 1; in s6e8aa0_probe()
1020 drm_panel_init(&ctx->panel); in s6e8aa0_probe()
1021 ctx->panel.dev = dev; in s6e8aa0_probe()
1022 ctx->panel.funcs = &s6e8aa0_drm_funcs; in s6e8aa0_probe()
1024 ret = drm_panel_add(&ctx->panel); in s6e8aa0_probe()
1030 drm_panel_remove(&ctx->panel); in s6e8aa0_probe()
1037 struct s6e8aa0 *ctx = mipi_dsi_get_drvdata(dsi); in s6e8aa0_remove() local
1040 drm_panel_remove(&ctx->panel); in s6e8aa0_remove()