@@ -148,24 +148,20 @@ static inline struct nt35560 *panel_to_nt35560(struct drm_panel *panel)
148148static int nt35560_set_brightness (struct backlight_device * bl )
149149{
150150 struct nt35560 * nt = bl_get_data (bl );
151- struct mipi_dsi_device * dsi = to_mipi_dsi_device (nt -> dev );
152- int period_ns = 1023 ;
151+ struct mipi_dsi_multi_context dsi_ctx = {
152+ .dsi = to_mipi_dsi_device (nt -> dev )
153+ };
153154 int duty_ns = bl -> props .brightness ;
155+ int period_ns = 1023 ;
154156 u8 pwm_ratio ;
155157 u8 pwm_div ;
156- u8 par ;
157- int ret ;
158158
159159 if (backlight_is_blank (bl )) {
160160 /* Disable backlight */
161- par = 0x00 ;
162- ret = mipi_dsi_dcs_write (dsi , MIPI_DCS_WRITE_CONTROL_DISPLAY ,
163- & par , 1 );
164- if (ret < 0 ) {
165- dev_err (nt -> dev , "failed to disable display backlight (%d)\n" , ret );
166- return ret ;
167- }
168- return 0 ;
161+ mipi_dsi_dcs_write_seq_multi (& dsi_ctx ,
162+ MIPI_DCS_WRITE_CONTROL_DISPLAY ,
163+ 0x00 );
164+ return dsi_ctx .accum_err ;
169165 }
170166
171167 /* Calculate the PWM duty cycle in n/256's */
@@ -176,12 +172,6 @@ static int nt35560_set_brightness(struct backlight_device *bl)
176172
177173 /* Set up PWM dutycycle ONE byte (differs from the standard) */
178174 dev_dbg (nt -> dev , "calculated duty cycle %02x\n" , pwm_ratio );
179- ret = mipi_dsi_dcs_write (dsi , MIPI_DCS_SET_DISPLAY_BRIGHTNESS ,
180- & pwm_ratio , 1 );
181- if (ret < 0 ) {
182- dev_err (nt -> dev , "failed to set display PWM ratio (%d)\n" , ret );
183- return ret ;
184- }
185175
186176 /*
187177 * Sequence to write PWMDIV:
@@ -192,46 +182,23 @@ static int nt35560_set_brightness(struct backlight_device *bl)
192182 * 0x22 PWMDIV
193183 * 0x7F 0xAA CMD2 page 1 lock
194184 */
195- par = 0xaa ;
196- ret = mipi_dsi_dcs_write (dsi , 0xf3 , & par , 1 );
197- if (ret < 0 ) {
198- dev_err (nt -> dev , "failed to unlock CMD 2 (%d)\n" , ret );
199- return ret ;
200- }
201- par = 0x01 ;
202- ret = mipi_dsi_dcs_write (dsi , 0x00 , & par , 1 );
203- if (ret < 0 ) {
204- dev_err (nt -> dev , "failed to enter page 1 (%d)\n" , ret );
205- return ret ;
206- }
207- par = 0x01 ;
208- ret = mipi_dsi_dcs_write (dsi , 0x7d , & par , 1 );
209- if (ret < 0 ) {
210- dev_err (nt -> dev , "failed to disable MTP reload (%d)\n" , ret );
211- return ret ;
212- }
213- ret = mipi_dsi_dcs_write (dsi , 0x22 , & pwm_div , 1 );
214- if (ret < 0 ) {
215- dev_err (nt -> dev , "failed to set PWM divisor (%d)\n" , ret );
216- return ret ;
217- }
218- par = 0xaa ;
219- ret = mipi_dsi_dcs_write (dsi , 0x7f , & par , 1 );
220- if (ret < 0 ) {
221- dev_err (nt -> dev , "failed to lock CMD 2 (%d)\n" , ret );
222- return ret ;
223- }
185+ mipi_dsi_dcs_write_var_seq_multi (& dsi_ctx ,
186+ MIPI_DCS_SET_DISPLAY_BRIGHTNESS ,
187+ pwm_ratio );
188+
189+ mipi_dsi_dcs_write_seq_multi (& dsi_ctx , 0xf3 , 0xaa );
190+ mipi_dsi_dcs_write_seq_multi (& dsi_ctx , 0x00 , 0x01 );
191+ mipi_dsi_dcs_write_seq_multi (& dsi_ctx , 0x7d , 0x01 );
192+
193+ mipi_dsi_dcs_write_var_seq_multi (& dsi_ctx , 0x22 , pwm_div );
194+
195+ mipi_dsi_dcs_write_seq_multi (& dsi_ctx , 0x7f , 0xaa );
224196
225197 /* Enable backlight */
226- par = 0x24 ;
227- ret = mipi_dsi_dcs_write (dsi , MIPI_DCS_WRITE_CONTROL_DISPLAY ,
228- & par , 1 );
229- if (ret < 0 ) {
230- dev_err (nt -> dev , "failed to enable display backlight (%d)\n" , ret );
231- return ret ;
232- }
198+ mipi_dsi_dcs_write_seq_multi (& dsi_ctx , MIPI_DCS_WRITE_CONTROL_DISPLAY ,
199+ 0x24 );
233200
234- return 0 ;
201+ return dsi_ctx . accum_err ;
235202}
236203
237204static const struct backlight_ops nt35560_bl_ops = {
@@ -244,32 +211,23 @@ static const struct backlight_properties nt35560_bl_props = {
244211 .max_brightness = 1023 ,
245212};
246213
247- static int nt35560_read_id (struct nt35560 * nt )
214+ static void nt35560_read_id (struct mipi_dsi_multi_context * dsi_ctx )
248215{
249- struct mipi_dsi_device * dsi = to_mipi_dsi_device ( nt -> dev ) ;
216+ struct device dev = dsi_ctx -> dsi -> dev ;
250217 u8 vendor , version , panel ;
251218 u16 val ;
252- int ret ;
253219
254- ret = mipi_dsi_dcs_read (dsi , NT35560_DCS_READ_ID1 , & vendor , 1 );
255- if (ret < 0 ) {
256- dev_err (nt -> dev , "could not vendor ID byte\n" );
257- return ret ;
258- }
259- ret = mipi_dsi_dcs_read (dsi , NT35560_DCS_READ_ID2 , & version , 1 );
260- if (ret < 0 ) {
261- dev_err (nt -> dev , "could not read device version byte\n" );
262- return ret ;
263- }
264- ret = mipi_dsi_dcs_read (dsi , NT35560_DCS_READ_ID3 , & panel , 1 );
265- if (ret < 0 ) {
266- dev_err (nt -> dev , "could not read panel ID byte\n" );
267- return ret ;
268- }
220+ mipi_dsi_dcs_read_multi (dsi_ctx , NT35560_DCS_READ_ID1 , & vendor , 1 );
221+ mipi_dsi_dcs_read_multi (dsi_ctx , NT35560_DCS_READ_ID2 , & version , 1 );
222+ mipi_dsi_dcs_read_multi (dsi_ctx , NT35560_DCS_READ_ID3 , & panel , 1 );
223+
224+ if (dsi_ctx -> accum_err < 0 )
225+ return ;
269226
270227 if (vendor == 0x00 ) {
271- dev_err (nt -> dev , "device vendor ID is zero\n" );
272- return - ENODEV ;
228+ dev_err (& dev , "device vendor ID is zero\n" );
229+ dsi_ctx -> accum_err = - ENODEV ;
230+ return ;
273231 }
274232
275233 val = (vendor << 8 ) | panel ;
@@ -278,16 +236,16 @@ static int nt35560_read_id(struct nt35560 *nt)
278236 case DISPLAY_SONY_ACX424AKP_ID2 :
279237 case DISPLAY_SONY_ACX424AKP_ID3 :
280238 case DISPLAY_SONY_ACX424AKP_ID4 :
281- dev_info (nt -> dev , "MTP vendor: %02x, version: %02x, panel: %02x\n" ,
239+ dev_info (& dev ,
240+ "MTP vendor: %02x, version: %02x, panel: %02x\n" ,
282241 vendor , version , panel );
283242 break ;
284243 default :
285- dev_info (nt -> dev , "unknown vendor: %02x, version: %02x, panel: %02x\n" ,
244+ dev_info (& dev ,
245+ "unknown vendor: %02x, version: %02x, panel: %02x\n" ,
286246 vendor , version , panel );
287247 break ;
288248 }
289-
290- return 0 ;
291249}
292250
293251static int nt35560_power_on (struct nt35560 * nt )
@@ -322,92 +280,56 @@ static void nt35560_power_off(struct nt35560 *nt)
322280static int nt35560_prepare (struct drm_panel * panel )
323281{
324282 struct nt35560 * nt = panel_to_nt35560 (panel );
325- struct mipi_dsi_device * dsi = to_mipi_dsi_device (nt -> dev );
326- const u8 mddi = 3 ;
283+ struct mipi_dsi_multi_context dsi_ctx = {
284+ .dsi = to_mipi_dsi_device (nt -> dev )
285+ };
327286 int ret ;
328287
329288 ret = nt35560_power_on (nt );
330289 if (ret )
331290 return ret ;
332291
333- ret = nt35560_read_id (nt );
334- if (ret ) {
335- dev_err (nt -> dev , "failed to read panel ID (%d)\n" , ret );
336- goto err_power_off ;
337- }
292+ nt35560_read_id (& dsi_ctx );
338293
339- /* Enabe tearing mode: send TE (tearing effect) at VBLANK */
340- ret = mipi_dsi_dcs_set_tear_on ( dsi ,
294+ /* Enable tearing mode: send TE (tearing effect) at VBLANK */
295+ mipi_dsi_dcs_set_tear_on_multi ( & dsi_ctx ,
341296 MIPI_DSI_DCS_TEAR_MODE_VBLANK );
342- if (ret ) {
343- dev_err (nt -> dev , "failed to enable vblank TE (%d)\n" , ret );
344- goto err_power_off ;
345- }
346297
347298 /*
348299 * Set MDDI
349300 *
350301 * This presumably deactivates the Qualcomm MDDI interface and
351302 * selects DSI, similar code is found in other drivers such as the
352- * Sharp LS043T1LE01 which makes us suspect that this panel may be
353- * using a Novatek NT35565 or similar display driver chip that shares
354- * this command. Due to the lack of documentation we cannot know for
355- * sure.
303+ * Sharp LS043T1LE01.
356304 */
357- ret = mipi_dsi_dcs_write (dsi , NT35560_DCS_SET_MDDI ,
358- & mddi , sizeof (mddi ));
359- if (ret < 0 ) {
360- dev_err (nt -> dev , "failed to set MDDI (%d)\n" , ret );
361- goto err_power_off ;
362- }
305+ mipi_dsi_dcs_write_seq_multi (& dsi_ctx , NT35560_DCS_SET_MDDI , 3 );
363306
364- /* Exit sleep mode */
365- ret = mipi_dsi_dcs_exit_sleep_mode (dsi );
366- if (ret ) {
367- dev_err (nt -> dev , "failed to exit sleep mode (%d)\n" , ret );
368- goto err_power_off ;
369- }
370- msleep (140 );
307+ mipi_dsi_dcs_exit_sleep_mode_multi (& dsi_ctx );
308+ mipi_dsi_msleep (& dsi_ctx , 140 );
371309
372- ret = mipi_dsi_dcs_set_display_on (dsi );
373- if (ret ) {
374- dev_err (nt -> dev , "failed to turn display on (%d)\n" , ret );
375- goto err_power_off ;
376- }
310+ mipi_dsi_dcs_set_display_on_multi (& dsi_ctx );
377311 if (nt -> video_mode ) {
378- /* In video mode turn peripheral on */
379- ret = mipi_dsi_turn_on_peripheral (dsi );
380- if (ret ) {
381- dev_err (nt -> dev , "failed to turn on peripheral\n" );
382- goto err_power_off ;
383- }
312+ mipi_dsi_turn_on_peripheral_multi (& dsi_ctx );
384313 }
385314
386- return 0 ;
387-
388- err_power_off :
389- nt35560_power_off (nt );
390- return ret ;
315+ if (dsi_ctx .accum_err < 0 )
316+ nt35560_power_off (nt );
317+ return dsi_ctx .accum_err ;
391318}
392319
393320static int nt35560_unprepare (struct drm_panel * panel )
394321{
395322 struct nt35560 * nt = panel_to_nt35560 (panel );
396- struct mipi_dsi_device * dsi = to_mipi_dsi_device (nt -> dev );
397- int ret ;
323+ struct mipi_dsi_multi_context dsi_ctx = {
324+ .dsi = to_mipi_dsi_device (nt -> dev )
325+ };
398326
399- ret = mipi_dsi_dcs_set_display_off ( dsi );
400- if ( ret ) {
401- dev_err ( nt -> dev , "failed to turn display off (%d)\n" , ret );
402- return ret ;
403- }
327+ mipi_dsi_dcs_set_display_off_multi ( & dsi_ctx );
328+ mipi_dsi_dcs_enter_sleep_mode_multi ( & dsi_ctx );
329+
330+ if ( dsi_ctx . accum_err < 0 )
331+ return dsi_ctx . accum_err ;
404332
405- /* Enter sleep mode */
406- ret = mipi_dsi_dcs_enter_sleep_mode (dsi );
407- if (ret ) {
408- dev_err (nt -> dev , "failed to enter sleep mode (%d)\n" , ret );
409- return ret ;
410- }
411333 msleep (85 );
412334
413335 nt35560_power_off (nt );
0 commit comments