@@ -100,106 +100,87 @@ static void nt35950_reset(struct nt35950 *nt)
100
100
101
101
/*
102
102
* nt35950_set_cmd2_page - Select manufacturer control (CMD2) page
103
+ * @dsi_ctx: context for mipi_dsi functions
103
104
* @nt: Main driver structure
104
105
* @page: Page number (0-7)
105
- *
106
- * Return: Number of transferred bytes or negative number on error
107
106
*/
108
- static int nt35950_set_cmd2_page (struct nt35950 * nt , u8 page )
107
+ static void nt35950_set_cmd2_page (struct mipi_dsi_multi_context * dsi_ctx ,
108
+ struct nt35950 * nt , u8 page )
109
109
{
110
110
const u8 mauc_cmd2_page [] = { MCS_CMD_MAUCCTR , 0x55 , 0xaa , 0x52 ,
111
111
0x08 , page };
112
- int ret ;
113
112
114
- ret = mipi_dsi_dcs_write_buffer ( nt -> dsi [ 0 ] , mauc_cmd2_page ,
113
+ mipi_dsi_dcs_write_buffer_multi ( dsi_ctx , mauc_cmd2_page ,
115
114
ARRAY_SIZE (mauc_cmd2_page ));
116
- if (ret < 0 )
117
- return ret ;
118
-
119
- nt -> last_page = page ;
120
- return 0 ;
115
+ if (!dsi_ctx -> accum_err )
116
+ nt -> last_page = page ;
121
117
}
122
118
123
119
/*
124
120
* nt35950_set_data_compression - Set data compression mode
121
+ * @dsi_ctx: context for mipi_dsi functions
125
122
* @nt: Main driver structure
126
123
* @comp_mode: Compression mode
127
- *
128
- * Return: Number of transferred bytes or negative number on error
129
124
*/
130
- static int nt35950_set_data_compression (struct nt35950 * nt , u8 comp_mode )
125
+ static void nt35950_set_data_compression (struct mipi_dsi_multi_context * dsi_ctx ,
126
+ struct nt35950 * nt , u8 comp_mode )
131
127
{
132
128
u8 cmd_data_compression [] = { MCS_PARAM_DATA_COMPRESSION , comp_mode };
133
129
u8 cmd_vesa_dsc_on [] = { MCS_PARAM_VESA_DSC_ON , !!comp_mode };
134
130
u8 cmd_vesa_dsc_setting [] = { MCS_PARAM_VESA_DSC_SETTING , 0x03 };
135
131
u8 last_page = nt -> last_page ;
136
- int ret ;
137
132
138
133
/* Set CMD2 Page 0 if we're not there yet */
139
- if (last_page != 0 ) {
140
- ret = nt35950_set_cmd2_page (nt , 0 );
141
- if (ret < 0 )
142
- return ret ;
143
- }
134
+ if (last_page != 0 )
135
+ nt35950_set_cmd2_page (dsi_ctx , nt , 0 );
144
136
145
- ret = mipi_dsi_dcs_write_buffer ( nt -> dsi [ 0 ] , cmd_data_compression ,
137
+ mipi_dsi_dcs_write_buffer_multi ( dsi_ctx , cmd_data_compression ,
146
138
ARRAY_SIZE (cmd_data_compression ));
147
- if (ret < 0 )
148
- return ret ;
149
-
150
- ret = mipi_dsi_dcs_write_buffer (nt -> dsi [0 ], cmd_vesa_dsc_on ,
139
+ mipi_dsi_dcs_write_buffer_multi (dsi_ctx , cmd_vesa_dsc_on ,
151
140
ARRAY_SIZE (cmd_vesa_dsc_on ));
152
- if (ret < 0 )
153
- return ret ;
154
141
155
142
/* Set the vesa dsc setting on Page 4 */
156
- ret = nt35950_set_cmd2_page (nt , 4 );
157
- if (ret < 0 )
158
- return ret ;
143
+ nt35950_set_cmd2_page (dsi_ctx , nt , 4 );
159
144
160
145
/* Display Stream Compression setting, always 0x03 */
161
- ret = mipi_dsi_dcs_write_buffer ( nt -> dsi [ 0 ] , cmd_vesa_dsc_setting ,
146
+ mipi_dsi_dcs_write_buffer_multi ( dsi_ctx , cmd_vesa_dsc_setting ,
162
147
ARRAY_SIZE (cmd_vesa_dsc_setting ));
163
- if (ret < 0 )
164
- return ret ;
165
148
166
149
/* Get back to the previously set page */
167
- return nt35950_set_cmd2_page (nt , last_page );
150
+ nt35950_set_cmd2_page (dsi_ctx , nt , last_page );
168
151
}
169
152
170
153
/*
171
154
* nt35950_set_scaler - Enable/disable resolution upscaling
172
- * @nt: Main driver structure
155
+ * @dsi_ctx: context for mipi_dsi functions
173
156
* @scale_up: Scale up function control
174
- *
175
- * Return: Number of transferred bytes or negative number on error
176
157
*/
177
- static int nt35950_set_scaler (struct nt35950 * nt , u8 scale_up )
158
+ static void nt35950_set_scaler (struct mipi_dsi_multi_context * dsi_ctx ,
159
+ u8 scale_up )
178
160
{
179
161
u8 cmd_scaler [] = { MCS_PARAM_SCALER_FUNCTION , scale_up };
180
162
181
- return mipi_dsi_dcs_write_buffer ( nt -> dsi [ 0 ] , cmd_scaler ,
182
- ARRAY_SIZE (cmd_scaler ));
163
+ mipi_dsi_dcs_write_buffer_multi ( dsi_ctx , cmd_scaler ,
164
+ ARRAY_SIZE (cmd_scaler ));
183
165
}
184
166
185
167
/*
186
168
* nt35950_set_scale_mode - Resolution upscaling mode
187
- * @nt: Main driver structure
169
+ * @dsi_ctx: context for mipi_dsi functions
188
170
* @mode: Scaler mode (MCS_DATA_COMPRESSION_*)
189
- *
190
- * Return: Number of transferred bytes or negative number on error
191
171
*/
192
- static int nt35950_set_scale_mode (struct nt35950 * nt , u8 mode )
172
+ static void nt35950_set_scale_mode (struct mipi_dsi_multi_context * dsi_ctx ,
173
+ u8 mode )
193
174
{
194
175
u8 cmd_scaler [] = { MCS_PARAM_SCALEUP_MODE , mode };
195
176
196
- return mipi_dsi_dcs_write_buffer ( nt -> dsi [ 0 ] , cmd_scaler ,
197
- ARRAY_SIZE (cmd_scaler ));
177
+ mipi_dsi_dcs_write_buffer_multi ( dsi_ctx , cmd_scaler ,
178
+ ARRAY_SIZE (cmd_scaler ));
198
179
}
199
180
200
181
/*
201
182
* nt35950_inject_black_image - Display a completely black image
202
- * @nt: Main driver structure
183
+ * @dsi_ctx: context for mipi_dsi functions
203
184
*
204
185
* After IC setup, the attached panel may show random data
205
186
* due to driveric behavior changes (resolution, compression,
@@ -208,43 +189,34 @@ static int nt35950_set_scale_mode(struct nt35950 *nt, u8 mode)
208
189
* the display.
209
190
* It makes sense to push a black image before sending the sleep-out
210
191
* and display-on commands.
211
- *
212
- * Return: Number of transferred bytes or negative number on error
213
192
*/
214
- static int nt35950_inject_black_image (struct nt35950 * nt )
193
+ static void nt35950_inject_black_image (struct mipi_dsi_multi_context * dsi_ctx )
215
194
{
216
195
const u8 cmd0_black_img [] = { 0x6f , 0x01 };
217
196
const u8 cmd1_black_img [] = { 0xf3 , 0x10 };
218
197
u8 cmd_test [] = { 0xff , 0xaa , 0x55 , 0xa5 , 0x80 };
219
- int ret ;
220
198
221
199
/* Enable test command */
222
- ret = mipi_dsi_dcs_write_buffer (nt -> dsi [0 ], cmd_test , ARRAY_SIZE (cmd_test ));
223
- if (ret < 0 )
224
- return ret ;
200
+ mipi_dsi_dcs_write_buffer_multi (dsi_ctx , cmd_test , ARRAY_SIZE (cmd_test ));
225
201
226
202
/* Send a black image */
227
- ret = mipi_dsi_dcs_write_buffer ( nt -> dsi [ 0 ] , cmd0_black_img ,
203
+ mipi_dsi_dcs_write_buffer_multi ( dsi_ctx , cmd0_black_img ,
228
204
ARRAY_SIZE (cmd0_black_img ));
229
- if (ret < 0 )
230
- return ret ;
231
- ret = mipi_dsi_dcs_write_buffer (nt -> dsi [0 ], cmd1_black_img ,
205
+ mipi_dsi_dcs_write_buffer_multi (dsi_ctx , cmd1_black_img ,
232
206
ARRAY_SIZE (cmd1_black_img ));
233
- if (ret < 0 )
234
- return ret ;
235
207
236
208
/* Disable test command */
237
209
cmd_test [ARRAY_SIZE (cmd_test ) - 1 ] = 0x00 ;
238
- return mipi_dsi_dcs_write_buffer ( nt -> dsi [ 0 ] , cmd_test , ARRAY_SIZE (cmd_test ));
210
+ mipi_dsi_dcs_write_buffer_multi ( dsi_ctx , cmd_test , ARRAY_SIZE (cmd_test ));
239
211
}
240
212
241
213
/*
242
214
* nt35950_set_dispout - Set Display Output register parameters
243
215
* @nt: Main driver structure
244
- *
245
- * Return: Number of transferred bytes or negative number on error
216
+ * @dsi_ctx: context for mipi_dsi functions
246
217
*/
247
- static int nt35950_set_dispout (struct nt35950 * nt )
218
+ static void nt35950_set_dispout (struct mipi_dsi_multi_context * dsi_ctx ,
219
+ struct nt35950 * nt )
248
220
{
249
221
u8 cmd_dispout [] = { MCS_PARAM_DISP_OUTPUT_CTRL , 0x00 };
250
222
const struct nt35950_panel_mode * mode_data = nt -> desc -> mode_data ;
@@ -254,8 +226,8 @@ static int nt35950_set_dispout(struct nt35950 *nt)
254
226
if (mode_data [nt -> cur_mode ].enable_sram )
255
227
cmd_dispout [1 ] |= MCS_DISP_OUT_SRAM_EN ;
256
228
257
- return mipi_dsi_dcs_write_buffer ( nt -> dsi [ 0 ] , cmd_dispout ,
258
- ARRAY_SIZE (cmd_dispout ));
229
+ mipi_dsi_dcs_write_buffer_multi ( dsi_ctx , cmd_dispout ,
230
+ ARRAY_SIZE (cmd_dispout ));
259
231
}
260
232
261
233
static int nt35950_get_current_mode (struct nt35950 * nt )
@@ -284,109 +256,67 @@ static int nt35950_on(struct nt35950 *nt)
284
256
{
285
257
const struct nt35950_panel_mode * mode_data = nt -> desc -> mode_data ;
286
258
struct mipi_dsi_device * dsi = nt -> dsi [0 ];
287
- struct device * dev = & dsi -> dev ;
288
- int ret ;
259
+ struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
289
260
290
261
nt -> cur_mode = nt35950_get_current_mode (nt );
291
262
nt -> dsi [0 ]-> mode_flags |= MIPI_DSI_MODE_LPM ;
292
263
nt -> dsi [1 ]-> mode_flags |= MIPI_DSI_MODE_LPM ;
293
264
294
- ret = nt35950_set_cmd2_page (nt , 0 );
295
- if (ret < 0 )
296
- return ret ;
265
+ nt35950_set_cmd2_page (& dsi_ctx , nt , 0 );
266
+ nt35950_set_data_compression (& dsi_ctx , nt , mode_data [nt -> cur_mode ].compression );
267
+ nt35950_set_scale_mode (& dsi_ctx , mode_data [nt -> cur_mode ].scaler_mode );
268
+ nt35950_set_scaler (& dsi_ctx , mode_data [nt -> cur_mode ].scaler_on );
269
+ nt35950_set_dispout (& dsi_ctx , nt );
297
270
298
- ret = nt35950_set_data_compression (nt , mode_data [nt -> cur_mode ].compression );
299
- if (ret < 0 )
300
- return ret ;
301
-
302
- ret = nt35950_set_scale_mode (nt , mode_data [nt -> cur_mode ].scaler_mode );
303
- if (ret < 0 )
304
- return ret ;
305
-
306
- ret = nt35950_set_scaler (nt , mode_data [nt -> cur_mode ].scaler_on );
307
- if (ret < 0 )
308
- return ret ;
309
-
310
- ret = nt35950_set_dispout (nt );
311
- if (ret < 0 )
312
- return ret ;
313
-
314
- ret = mipi_dsi_dcs_set_tear_on (dsi , MIPI_DSI_DCS_TEAR_MODE_VBLANK );
315
- if (ret < 0 ) {
316
- dev_err (dev , "Failed to set tear on: %d\n" , ret );
317
- return ret ;
318
- }
319
-
320
- ret = mipi_dsi_dcs_set_tear_scanline (dsi , 0 );
321
- if (ret < 0 ) {
322
- dev_err (dev , "Failed to set tear scanline: %d\n" , ret );
323
- return ret ;
324
- }
271
+ mipi_dsi_dcs_set_tear_on_multi (& dsi_ctx , MIPI_DSI_DCS_TEAR_MODE_VBLANK );
272
+ mipi_dsi_dcs_set_tear_scanline_multi (& dsi_ctx , 0 );
325
273
326
274
/* CMD2 Page 1 */
327
- ret = nt35950_set_cmd2_page (nt , 1 );
328
- if (ret < 0 )
329
- return ret ;
275
+ nt35950_set_cmd2_page (& dsi_ctx , nt , 1 );
330
276
331
277
/* Unknown command */
332
- mipi_dsi_dcs_write_seq ( dsi , 0xd4 , 0x88 , 0x88 );
278
+ mipi_dsi_dcs_write_seq_multi ( & dsi_ctx , 0xd4 , 0x88 , 0x88 );
333
279
334
280
/* CMD2 Page 7 */
335
- ret = nt35950_set_cmd2_page (nt , 7 );
336
- if (ret < 0 )
337
- return ret ;
281
+ nt35950_set_cmd2_page (& dsi_ctx , nt , 7 );
338
282
339
283
/* Enable SubPixel Rendering */
340
- mipi_dsi_dcs_write_seq ( dsi , MCS_PARAM_SPR_EN , 0x01 );
284
+ mipi_dsi_dcs_write_seq_multi ( & dsi_ctx , MCS_PARAM_SPR_EN , 0x01 );
341
285
342
286
/* SPR Mode: YYG Rainbow-RGB */
343
- mipi_dsi_dcs_write_seq (dsi , MCS_PARAM_SPR_MODE , MCS_SPR_MODE_YYG_RAINBOW_RGB );
287
+ mipi_dsi_dcs_write_seq_multi (& dsi_ctx , MCS_PARAM_SPR_MODE ,
288
+ MCS_SPR_MODE_YYG_RAINBOW_RGB );
344
289
345
290
/* CMD3 */
346
- ret = nt35950_inject_black_image (nt );
347
- if ( ret < 0 )
348
- return ret ;
291
+ nt35950_inject_black_image (& dsi_ctx );
292
+ mipi_dsi_dcs_exit_sleep_mode_multi ( & dsi_ctx );
293
+ mipi_dsi_msleep ( & dsi_ctx , 120 ) ;
349
294
350
- ret = mipi_dsi_dcs_exit_sleep_mode (dsi );
351
- if (ret < 0 )
352
- return ret ;
353
- msleep (120 );
295
+ mipi_dsi_dcs_set_display_on_multi (& dsi_ctx );
296
+ mipi_dsi_msleep (& dsi_ctx , 120 );
354
297
355
- ret = mipi_dsi_dcs_set_display_on (dsi );
356
- if (ret < 0 )
357
- return ret ;
358
- msleep (120 );
298
+ if (dsi_ctx .accum_err )
299
+ return dsi_ctx .accum_err ;
359
300
360
301
nt -> dsi [0 ]-> mode_flags &= ~MIPI_DSI_MODE_LPM ;
361
302
nt -> dsi [1 ]-> mode_flags &= ~MIPI_DSI_MODE_LPM ;
362
303
363
304
return 0 ;
364
305
}
365
306
366
- static int nt35950_off (struct nt35950 * nt )
307
+ static void nt35950_off (struct nt35950 * nt )
367
308
{
368
- struct device * dev = & nt -> dsi [0 ]-> dev ;
369
- int ret ;
309
+ struct mipi_dsi_device * dsi = nt -> dsi [0 ];
310
+ struct mipi_dsi_multi_context dsi_ctx = { . dsi = dsi } ;
370
311
371
- ret = mipi_dsi_dcs_set_display_off (nt -> dsi [0 ]);
372
- if (ret < 0 ) {
373
- dev_err (dev , "Failed to set display off: %d\n" , ret );
374
- goto set_lpm ;
375
- }
376
- usleep_range (10000 , 11000 );
312
+ mipi_dsi_dcs_set_display_off_multi (& dsi_ctx );
313
+ mipi_dsi_usleep_range (& dsi_ctx , 10000 , 11000 );
377
314
378
- ret = mipi_dsi_dcs_enter_sleep_mode (nt -> dsi [0 ]);
379
- if (ret < 0 ) {
380
- dev_err (dev , "Failed to enter sleep mode: %d\n" , ret );
381
- goto set_lpm ;
382
- }
383
- msleep (150 );
315
+ mipi_dsi_dcs_enter_sleep_mode_multi (& dsi_ctx );
316
+ mipi_dsi_msleep (& dsi_ctx , 150 );
384
317
385
- set_lpm :
386
318
nt -> dsi [0 ]-> mode_flags |= MIPI_DSI_MODE_LPM ;
387
319
nt -> dsi [1 ]-> mode_flags |= MIPI_DSI_MODE_LPM ;
388
-
389
- return 0 ;
390
320
}
391
321
392
322
static int nt35950_sharp_init_vregs (struct nt35950 * nt , struct device * dev )
@@ -427,7 +357,6 @@ static int nt35950_sharp_init_vregs(struct nt35950 *nt, struct device *dev)
427
357
static int nt35950_prepare (struct drm_panel * panel )
428
358
{
429
359
struct nt35950 * nt = to_nt35950 (panel );
430
- struct device * dev = & nt -> dsi [0 ]-> dev ;
431
360
int ret ;
432
361
433
362
ret = regulator_enable (nt -> vregs [0 ].consumer );
@@ -452,10 +381,6 @@ static int nt35950_prepare(struct drm_panel *panel)
452
381
nt35950_reset (nt );
453
382
454
383
ret = nt35950_on (nt );
455
- if (ret < 0 ) {
456
- dev_err (dev , "Failed to initialize panel: %d\n" , ret );
457
- goto end ;
458
- }
459
384
460
385
end :
461
386
if (ret < 0 ) {
@@ -469,12 +394,8 @@ static int nt35950_prepare(struct drm_panel *panel)
469
394
static int nt35950_unprepare (struct drm_panel * panel )
470
395
{
471
396
struct nt35950 * nt = to_nt35950 (panel );
472
- struct device * dev = & nt -> dsi [0 ]-> dev ;
473
- int ret ;
474
397
475
- ret = nt35950_off (nt );
476
- if (ret < 0 )
477
- dev_err (dev , "Failed to deinitialize panel: %d\n" , ret );
398
+ nt35950_off (nt );
478
399
479
400
gpiod_set_value_cansleep (nt -> reset_gpio , 0 );
480
401
regulator_bulk_disable (ARRAY_SIZE (nt -> vregs ), nt -> vregs );
0 commit comments