Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/panel: novatek-nt36672a: Convert to mipi_dsi_*_multi() helpers

Convert the driver to use the non-deprecated mipi_dsi_*_multi() helpers and
mipi_dsi_msleep().

Switch DCS command sequences to the multi context API and
accumulate errors via struct mipi_dsi_multi_context. Replace
open-coded error handling with the multi helpers and convert
nt36672a_send_cmds() and power sequencing accordingly.

This patch is intended to functionally be a no-op, though there is one
slight change. Previously a failure in regulator_bulk_disable() would
have caused nt36672a_panel_unprepare() to return an error. Now it
won't. No other errors in nt36672a_panel_unprepare() were propagated,
so this makes things consistent.

Signed-off-by: Chintan Patel <chintanlike@gmail.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://patch.msgid.link/20260305044921.10942-1-chintanlike@gmail.com

authored by

Chintan Patel and committed by
Douglas Anderson
bc4cb68a ecbcceea

+30 -64
+30 -64
drivers/gpu/drm/panel/panel-novatek-nt36672a.c
··· 79 79 return container_of(panel, struct nt36672a_panel, base); 80 80 } 81 81 82 - static int nt36672a_send_cmds(struct drm_panel *panel, const struct nt36672a_panel_cmd *cmds, 83 - int num) 82 + static void nt36672a_send_cmds(struct mipi_dsi_multi_context *dsi_ctx, 83 + const struct nt36672a_panel_cmd *cmds, int num) 84 84 { 85 - struct nt36672a_panel *pinfo = to_nt36672a_panel(panel); 86 85 unsigned int i; 87 - int err; 88 86 89 87 for (i = 0; i < num; i++) { 90 88 const struct nt36672a_panel_cmd *cmd = &cmds[i]; 91 89 92 - err = mipi_dsi_dcs_write(pinfo->link, cmd->data[0], cmd->data + 1, 1); 93 - 94 - if (err < 0) 95 - return err; 90 + /* cmd->data[0] is the DCS command, cmd->data[1] is the parameter */ 91 + mipi_dsi_dcs_write_buffer_multi(dsi_ctx, cmd->data, sizeof(cmd->data)); 96 92 } 97 - 98 - return 0; 99 93 } 100 94 101 - static int nt36672a_panel_power_off(struct drm_panel *panel) 95 + static void nt36672a_panel_power_off(struct drm_panel *panel) 102 96 { 103 97 struct nt36672a_panel *pinfo = to_nt36672a_panel(panel); 104 - int ret = 0; 98 + int ret; 105 99 106 100 gpiod_set_value(pinfo->reset_gpio, 1); 107 101 108 102 ret = regulator_bulk_disable(ARRAY_SIZE(pinfo->supplies), pinfo->supplies); 109 103 if (ret) 110 104 dev_err(panel->dev, "regulator_bulk_disable failed %d\n", ret); 111 - 112 - return ret; 113 105 } 114 106 115 107 static int nt36672a_panel_unprepare(struct drm_panel *panel) 116 108 { 117 109 struct nt36672a_panel *pinfo = to_nt36672a_panel(panel); 118 - int ret; 110 + struct mipi_dsi_multi_context dsi_ctx = { .dsi = pinfo->link }; 119 111 120 112 /* send off cmds */ 121 - ret = nt36672a_send_cmds(panel, pinfo->desc->off_cmds, 122 - pinfo->desc->num_off_cmds); 113 + nt36672a_send_cmds(&dsi_ctx, pinfo->desc->off_cmds, 114 + pinfo->desc->num_off_cmds); 123 115 124 - if (ret < 0) 125 - dev_err(panel->dev, "failed to send DCS off cmds: %d\n", ret); 126 - 127 - ret = mipi_dsi_dcs_set_display_off(pinfo->link); 128 - if (ret < 0) 129 - dev_err(panel->dev, "set_display_off cmd failed ret = %d\n", ret); 116 + /* Reset error to continue with display off even if send_cmds failed */ 117 + dsi_ctx.accum_err = 0; 118 + mipi_dsi_dcs_set_display_off_multi(&dsi_ctx); 119 + /* Reset error to continue power-down even if display off failed */ 120 + dsi_ctx.accum_err = 0; 130 121 131 122 /* 120ms delay required here as per DCS spec */ 132 123 msleep(120); 133 124 134 - ret = mipi_dsi_dcs_enter_sleep_mode(pinfo->link); 135 - if (ret < 0) 136 - dev_err(panel->dev, "enter_sleep cmd failed ret = %d\n", ret); 125 + mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx); 137 126 138 127 /* 0x3C = 60ms delay */ 139 128 msleep(60); 140 129 141 - ret = nt36672a_panel_power_off(panel); 142 - if (ret < 0) 143 - dev_err(panel->dev, "power_off failed ret = %d\n", ret); 130 + nt36672a_panel_power_off(panel); 144 131 145 - return ret; 132 + return 0; 146 133 } 147 134 148 135 static int nt36672a_panel_power_on(struct nt36672a_panel *pinfo) ··· 157 170 static int nt36672a_panel_prepare(struct drm_panel *panel) 158 171 { 159 172 struct nt36672a_panel *pinfo = to_nt36672a_panel(panel); 160 - int err; 173 + struct mipi_dsi_multi_context dsi_ctx = { .dsi = pinfo->link }; 161 174 162 - err = nt36672a_panel_power_on(pinfo); 163 - if (err < 0) 164 - goto poweroff; 175 + dsi_ctx.accum_err = nt36672a_panel_power_on(pinfo); 165 176 166 177 /* send first part of init cmds */ 167 - err = nt36672a_send_cmds(panel, pinfo->desc->on_cmds_1, 168 - pinfo->desc->num_on_cmds_1); 178 + nt36672a_send_cmds(&dsi_ctx, pinfo->desc->on_cmds_1, 179 + pinfo->desc->num_on_cmds_1); 169 180 170 - if (err < 0) { 171 - dev_err(panel->dev, "failed to send DCS Init 1st Code: %d\n", err); 172 - goto poweroff; 173 - } 174 - 175 - err = mipi_dsi_dcs_exit_sleep_mode(pinfo->link); 176 - if (err < 0) { 177 - dev_err(panel->dev, "failed to exit sleep mode: %d\n", err); 178 - goto poweroff; 179 - } 181 + mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx); 180 182 181 183 /* 0x46 = 70 ms delay */ 182 - msleep(70); 184 + mipi_dsi_msleep(&dsi_ctx, 70); 183 185 184 - err = mipi_dsi_dcs_set_display_on(pinfo->link); 185 - if (err < 0) { 186 - dev_err(panel->dev, "failed to Set Display ON: %d\n", err); 187 - goto poweroff; 188 - } 186 + mipi_dsi_dcs_set_display_on_multi(&dsi_ctx); 189 187 190 188 /* Send rest of the init cmds */ 191 - err = nt36672a_send_cmds(panel, pinfo->desc->on_cmds_2, 192 - pinfo->desc->num_on_cmds_2); 189 + nt36672a_send_cmds(&dsi_ctx, pinfo->desc->on_cmds_2, 190 + pinfo->desc->num_on_cmds_2); 193 191 194 - if (err < 0) { 195 - dev_err(panel->dev, "failed to send DCS Init 2nd Code: %d\n", err); 196 - goto poweroff; 197 - } 192 + mipi_dsi_msleep(&dsi_ctx, 120); 198 193 199 - msleep(120); 194 + if (dsi_ctx.accum_err < 0) 195 + gpiod_set_value(pinfo->reset_gpio, 0); 200 196 201 - return 0; 202 - 203 - poweroff: 204 - gpiod_set_value(pinfo->reset_gpio, 0); 205 - return err; 197 + return dsi_ctx.accum_err; 206 198 } 207 199 208 200 static int nt36672a_panel_get_modes(struct drm_panel *panel,