• Home
  • Raw
  • Download

Lines Matching refs:ctx

128 static int s6e8aa0_clear_error(struct s6e8aa0 *ctx)  in s6e8aa0_clear_error()  argument
130 int ret = ctx->error; in s6e8aa0_clear_error()
132 ctx->error = 0; in s6e8aa0_clear_error()
136 static void s6e8aa0_dcs_write(struct s6e8aa0 *ctx, const void *data, size_t len) in s6e8aa0_dcs_write() argument
138 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in s6e8aa0_dcs_write()
141 if (ctx->error < 0) in s6e8aa0_dcs_write()
146 dev_err(ctx->dev, "error %zd writing dcs seq: %*ph\n", ret, in s6e8aa0_dcs_write()
148 ctx->error = ret; in s6e8aa0_dcs_write()
152 static int s6e8aa0_dcs_read(struct s6e8aa0 *ctx, u8 cmd, void *data, size_t len) in s6e8aa0_dcs_read() argument
154 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in s6e8aa0_dcs_read()
157 if (ctx->error < 0) in s6e8aa0_dcs_read()
158 return ctx->error; in s6e8aa0_dcs_read()
162 dev_err(ctx->dev, "error %d reading dcs seq(%#x)\n", ret, cmd); in s6e8aa0_dcs_read()
163 ctx->error = ret; in s6e8aa0_dcs_read()
169 #define s6e8aa0_dcs_write_seq(ctx, seq...) \ argument
173 s6e8aa0_dcs_write(ctx, d, ARRAY_SIZE(d));\
176 #define s6e8aa0_dcs_write_seq_static(ctx, seq...) \ argument
179 s6e8aa0_dcs_write(ctx, d, ARRAY_SIZE(d));\
182 static void s6e8aa0_apply_level_1_key(struct s6e8aa0 *ctx) in s6e8aa0_apply_level_1_key() argument
184 s6e8aa0_dcs_write_seq_static(ctx, 0xf0, 0x5a, 0x5a); in s6e8aa0_apply_level_1_key()
187 static void s6e8aa0_panel_cond_set_v142(struct s6e8aa0 *ctx) in s6e8aa0_panel_cond_set_v142() argument
192 u8 aid = aids[ctx->id >> 5]; in s6e8aa0_panel_cond_set_v142()
201 if (ctx->flip_vertical) { in s6e8aa0_panel_cond_set_v142()
207 if (ctx->flip_horizontal) { in s6e8aa0_panel_cond_set_v142()
213 if (ctx->flip_horizontal || ctx->flip_vertical) { in s6e8aa0_panel_cond_set_v142()
249 s6e8aa0_dcs_write_seq(ctx, in s6e8aa0_panel_cond_set_v142()
258 static void s6e8aa0_panel_cond_set(struct s6e8aa0 *ctx) in s6e8aa0_panel_cond_set() argument
260 if (ctx->version < 142) in s6e8aa0_panel_cond_set()
261 s6e8aa0_dcs_write_seq_static(ctx, in s6e8aa0_panel_cond_set()
269 s6e8aa0_panel_cond_set_v142(ctx); in s6e8aa0_panel_cond_set()
272 static void s6e8aa0_display_condition_set(struct s6e8aa0 *ctx) in s6e8aa0_display_condition_set() argument
274 s6e8aa0_dcs_write_seq_static(ctx, 0xf2, 0x80, 0x03, 0x0d); in s6e8aa0_display_condition_set()
277 static void s6e8aa0_etc_source_control(struct s6e8aa0 *ctx) in s6e8aa0_etc_source_control() argument
279 s6e8aa0_dcs_write_seq_static(ctx, 0xf6, 0x00, 0x02, 0x00); in s6e8aa0_etc_source_control()
282 static void s6e8aa0_etc_pentile_control(struct s6e8aa0 *ctx) in s6e8aa0_etc_pentile_control() argument
292 if (ctx->version < 142) in s6e8aa0_etc_pentile_control()
293 s6e8aa0_dcs_write(ctx, pent32, ARRAY_SIZE(pent32)); in s6e8aa0_etc_pentile_control()
295 s6e8aa0_dcs_write(ctx, pent142, ARRAY_SIZE(pent142)); in s6e8aa0_etc_pentile_control()
298 static void s6e8aa0_etc_power_control(struct s6e8aa0 *ctx) in s6e8aa0_etc_power_control() argument
308 if (ctx->version < 142) in s6e8aa0_etc_power_control()
309 s6e8aa0_dcs_write(ctx, pwr32, ARRAY_SIZE(pwr32)); in s6e8aa0_etc_power_control()
311 s6e8aa0_dcs_write(ctx, pwr142, ARRAY_SIZE(pwr142)); in s6e8aa0_etc_power_control()
314 static void s6e8aa0_etc_elvss_control(struct s6e8aa0 *ctx) in s6e8aa0_etc_elvss_control() argument
316 u8 id = ctx->id ? 0 : 0x95; in s6e8aa0_etc_elvss_control()
318 s6e8aa0_dcs_write_seq(ctx, 0xb1, 0x04, id); in s6e8aa0_etc_elvss_control()
321 static void s6e8aa0_elvss_nvm_set_v142(struct s6e8aa0 *ctx) in s6e8aa0_elvss_nvm_set_v142() argument
325 switch (ctx->brightness) { in s6e8aa0_elvss_nvm_set_v142()
341 s6e8aa0_dcs_write_seq(ctx, 0xd9, 0x14, 0x40, 0x0c, 0xcb, 0xce, 0x6e, in s6e8aa0_elvss_nvm_set_v142()
345 static void s6e8aa0_elvss_nvm_set(struct s6e8aa0 *ctx) in s6e8aa0_elvss_nvm_set() argument
347 if (ctx->version < 142) in s6e8aa0_elvss_nvm_set()
348 s6e8aa0_dcs_write_seq_static(ctx, in s6e8aa0_elvss_nvm_set()
352 s6e8aa0_elvss_nvm_set_v142(ctx); in s6e8aa0_elvss_nvm_set()
355 static void s6e8aa0_apply_level_2_key(struct s6e8aa0 *ctx) in s6e8aa0_apply_level_2_key() argument
357 s6e8aa0_dcs_write_seq_static(ctx, 0xfc, 0x5a, 0x5a); in s6e8aa0_apply_level_2_key()
764 static void s6e8aa0_brightness_set(struct s6e8aa0 *ctx) in s6e8aa0_brightness_set() argument
768 if (ctx->error) in s6e8aa0_brightness_set()
771 gamma = ctx->variant->gamma_tables[ctx->brightness]; in s6e8aa0_brightness_set()
773 if (ctx->version >= 142) in s6e8aa0_brightness_set()
774 s6e8aa0_elvss_nvm_set(ctx); in s6e8aa0_brightness_set()
776 s6e8aa0_dcs_write(ctx, gamma, GAMMA_TABLE_LEN); in s6e8aa0_brightness_set()
779 s6e8aa0_dcs_write_seq_static(ctx, 0xf7, 0x03); in s6e8aa0_brightness_set()
782 static void s6e8aa0_panel_init(struct s6e8aa0 *ctx) in s6e8aa0_panel_init() argument
784 s6e8aa0_apply_level_1_key(ctx); in s6e8aa0_panel_init()
785 s6e8aa0_apply_level_2_key(ctx); in s6e8aa0_panel_init()
788 s6e8aa0_dcs_write_seq_static(ctx, MIPI_DCS_EXIT_SLEEP_MODE); in s6e8aa0_panel_init()
791 s6e8aa0_panel_cond_set(ctx); in s6e8aa0_panel_init()
792 s6e8aa0_display_condition_set(ctx); in s6e8aa0_panel_init()
793 s6e8aa0_brightness_set(ctx); in s6e8aa0_panel_init()
794 s6e8aa0_etc_source_control(ctx); in s6e8aa0_panel_init()
795 s6e8aa0_etc_pentile_control(ctx); in s6e8aa0_panel_init()
796 s6e8aa0_elvss_nvm_set(ctx); in s6e8aa0_panel_init()
797 s6e8aa0_etc_power_control(ctx); in s6e8aa0_panel_init()
798 s6e8aa0_etc_elvss_control(ctx); in s6e8aa0_panel_init()
799 msleep(ctx->init_delay); in s6e8aa0_panel_init()
802 static void s6e8aa0_set_maximum_return_packet_size(struct s6e8aa0 *ctx, in s6e8aa0_set_maximum_return_packet_size() argument
805 struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); in s6e8aa0_set_maximum_return_packet_size()
808 if (ctx->error < 0) in s6e8aa0_set_maximum_return_packet_size()
813 dev_err(ctx->dev, in s6e8aa0_set_maximum_return_packet_size()
816 ctx->error = ret; in s6e8aa0_set_maximum_return_packet_size()
820 static void s6e8aa0_read_mtp_id(struct s6e8aa0 *ctx) in s6e8aa0_read_mtp_id() argument
825 ret = s6e8aa0_dcs_read(ctx, 0xd1, id, ARRAY_SIZE(id)); in s6e8aa0_read_mtp_id()
827 dev_err(ctx->dev, "read id failed\n"); in s6e8aa0_read_mtp_id()
828 ctx->error = -EIO; in s6e8aa0_read_mtp_id()
832 dev_info(ctx->dev, "ID: 0x%2x, 0x%2x, 0x%2x\n", id[0], id[1], id[2]); in s6e8aa0_read_mtp_id()
839 dev_err(ctx->dev, "unsupported display version %d\n", id[1]); in s6e8aa0_read_mtp_id()
840 ctx->error = -EINVAL; in s6e8aa0_read_mtp_id()
844 ctx->variant = &s6e8aa0_variants[i]; in s6e8aa0_read_mtp_id()
845 ctx->version = id[1]; in s6e8aa0_read_mtp_id()
846 ctx->id = id[2]; in s6e8aa0_read_mtp_id()
849 static void s6e8aa0_set_sequence(struct s6e8aa0 *ctx) in s6e8aa0_set_sequence() argument
851 s6e8aa0_set_maximum_return_packet_size(ctx, 3); in s6e8aa0_set_sequence()
852 s6e8aa0_read_mtp_id(ctx); in s6e8aa0_set_sequence()
853 s6e8aa0_panel_init(ctx); in s6e8aa0_set_sequence()
854 s6e8aa0_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_ON); in s6e8aa0_set_sequence()
857 static int s6e8aa0_power_on(struct s6e8aa0 *ctx) in s6e8aa0_power_on() argument
861 ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in s6e8aa0_power_on()
865 msleep(ctx->power_on_delay); in s6e8aa0_power_on()
867 gpiod_set_value(ctx->reset_gpio, 0); in s6e8aa0_power_on()
869 gpiod_set_value(ctx->reset_gpio, 1); in s6e8aa0_power_on()
871 msleep(ctx->reset_delay); in s6e8aa0_power_on()
876 static int s6e8aa0_power_off(struct s6e8aa0 *ctx) in s6e8aa0_power_off() argument
878 return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in s6e8aa0_power_off()
888 struct s6e8aa0 *ctx = panel_to_s6e8aa0(panel); in s6e8aa0_unprepare() local
890 s6e8aa0_dcs_write_seq_static(ctx, MIPI_DCS_ENTER_SLEEP_MODE); in s6e8aa0_unprepare()
891 s6e8aa0_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_OFF); in s6e8aa0_unprepare()
894 s6e8aa0_clear_error(ctx); in s6e8aa0_unprepare()
896 return s6e8aa0_power_off(ctx); in s6e8aa0_unprepare()
901 struct s6e8aa0 *ctx = panel_to_s6e8aa0(panel); in s6e8aa0_prepare() local
904 ret = s6e8aa0_power_on(ctx); in s6e8aa0_prepare()
908 s6e8aa0_set_sequence(ctx); in s6e8aa0_prepare()
909 ret = ctx->error; in s6e8aa0_prepare()
925 struct s6e8aa0 *ctx = panel_to_s6e8aa0(panel); in s6e8aa0_get_modes() local
934 drm_display_mode_from_videomode(&ctx->vm, mode); in s6e8aa0_get_modes()
935 mode->width_mm = ctx->width_mm; in s6e8aa0_get_modes()
936 mode->height_mm = ctx->height_mm; in s6e8aa0_get_modes()
954 static int s6e8aa0_parse_dt(struct s6e8aa0 *ctx) in s6e8aa0_parse_dt() argument
956 struct device *dev = ctx->dev; in s6e8aa0_parse_dt()
960 ret = of_get_videomode(np, &ctx->vm, 0); in s6e8aa0_parse_dt()
964 of_property_read_u32(np, "power-on-delay", &ctx->power_on_delay); in s6e8aa0_parse_dt()
965 of_property_read_u32(np, "reset-delay", &ctx->reset_delay); in s6e8aa0_parse_dt()
966 of_property_read_u32(np, "init-delay", &ctx->init_delay); in s6e8aa0_parse_dt()
967 of_property_read_u32(np, "panel-width-mm", &ctx->width_mm); in s6e8aa0_parse_dt()
968 of_property_read_u32(np, "panel-height-mm", &ctx->height_mm); in s6e8aa0_parse_dt()
970 ctx->flip_horizontal = of_property_read_bool(np, "flip-horizontal"); in s6e8aa0_parse_dt()
971 ctx->flip_vertical = of_property_read_bool(np, "flip-vertical"); in s6e8aa0_parse_dt()
979 struct s6e8aa0 *ctx; in s6e8aa0_probe() local
982 ctx = devm_kzalloc(dev, sizeof(struct s6e8aa0), GFP_KERNEL); in s6e8aa0_probe()
983 if (!ctx) in s6e8aa0_probe()
986 mipi_dsi_set_drvdata(dsi, ctx); in s6e8aa0_probe()
988 ctx->dev = dev; in s6e8aa0_probe()
995 ret = s6e8aa0_parse_dt(ctx); in s6e8aa0_probe()
999 ctx->supplies[0].supply = "vdd3"; in s6e8aa0_probe()
1000 ctx->supplies[1].supply = "vci"; in s6e8aa0_probe()
1001 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies), in s6e8aa0_probe()
1002 ctx->supplies); in s6e8aa0_probe()
1008 ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in s6e8aa0_probe()
1009 if (IS_ERR(ctx->reset_gpio)) { in s6e8aa0_probe()
1011 PTR_ERR(ctx->reset_gpio)); in s6e8aa0_probe()
1012 return PTR_ERR(ctx->reset_gpio); in s6e8aa0_probe()
1015 ctx->brightness = GAMMA_LEVEL_NUM - 1; in s6e8aa0_probe()
1017 drm_panel_init(&ctx->panel, dev, &s6e8aa0_drm_funcs, in s6e8aa0_probe()
1019 ctx->panel.prepare_prev_first = true; in s6e8aa0_probe()
1021 drm_panel_add(&ctx->panel); in s6e8aa0_probe()
1025 drm_panel_remove(&ctx->panel); in s6e8aa0_probe()
1032 struct s6e8aa0 *ctx = mipi_dsi_get_drvdata(dsi); in s6e8aa0_remove() local
1035 drm_panel_remove(&ctx->panel); in s6e8aa0_remove()