40
40
struct acx424akp {
41
41
struct drm_panel panel ;
42
42
struct device * dev ;
43
- struct backlight_device * bl ;
44
43
struct regulator * supply ;
45
44
struct gpio_desc * reset_gpio ;
46
45
bool video_mode ;
@@ -102,6 +101,18 @@ static int acx424akp_set_brightness(struct backlight_device *bl)
102
101
u8 par ;
103
102
int ret ;
104
103
104
+ if (backlight_is_blank (bl )) {
105
+ /* Disable backlight */
106
+ par = 0x00 ;
107
+ ret = mipi_dsi_dcs_write (dsi , MIPI_DCS_WRITE_CONTROL_DISPLAY ,
108
+ & par , 1 );
109
+ if (ret ) {
110
+ dev_err (acx -> dev , "failed to disable display backlight (%d)\n" , ret );
111
+ return ret ;
112
+ }
113
+ return 0 ;
114
+ }
115
+
105
116
/* Calculate the PWM duty cycle in n/256's */
106
117
pwm_ratio = max (((duty_ns * 256 ) / period_ns ) - 1 , 1 );
107
118
pwm_div = max (1 ,
@@ -172,6 +183,12 @@ static const struct backlight_ops acx424akp_bl_ops = {
172
183
.update_status = acx424akp_set_brightness ,
173
184
};
174
185
186
+ static const struct backlight_properties acx424akp_bl_props = {
187
+ .type = BACKLIGHT_RAW ,
188
+ .brightness = 512 ,
189
+ .max_brightness = 1023 ,
190
+ };
191
+
175
192
static int acx424akp_read_id (struct acx424akp * acx )
176
193
{
177
194
struct mipi_dsi_device * dsi = to_mipi_dsi_device (acx -> dev );
@@ -310,8 +327,6 @@ static int acx424akp_prepare(struct drm_panel *panel)
310
327
}
311
328
}
312
329
313
- acx -> bl -> props .power = FB_BLANK_NORMAL ;
314
-
315
330
return 0 ;
316
331
317
332
err_power_off :
@@ -323,18 +338,8 @@ static int acx424akp_unprepare(struct drm_panel *panel)
323
338
{
324
339
struct acx424akp * acx = panel_to_acx424akp (panel );
325
340
struct mipi_dsi_device * dsi = to_mipi_dsi_device (acx -> dev );
326
- u8 par ;
327
341
int ret ;
328
342
329
- /* Disable backlight */
330
- par = 0x00 ;
331
- ret = mipi_dsi_dcs_write (dsi , MIPI_DCS_WRITE_CONTROL_DISPLAY ,
332
- & par , 1 );
333
- if (ret ) {
334
- dev_err (acx -> dev , "failed to disable display backlight (%d)\n" , ret );
335
- return ret ;
336
- }
337
-
338
343
ret = mipi_dsi_dcs_set_display_off (dsi );
339
344
if (ret ) {
340
345
dev_err (acx -> dev , "failed to turn display off (%d)\n" , ret );
@@ -350,36 +355,10 @@ static int acx424akp_unprepare(struct drm_panel *panel)
350
355
msleep (85 );
351
356
352
357
acx424akp_power_off (acx );
353
- acx -> bl -> props .power = FB_BLANK_POWERDOWN ;
354
-
355
- return 0 ;
356
- }
357
-
358
- static int acx424akp_enable (struct drm_panel * panel )
359
- {
360
- struct acx424akp * acx = panel_to_acx424akp (panel );
361
-
362
- /*
363
- * The backlight is on as long as the display is on
364
- * so no use to call backlight_enable() here.
365
- */
366
- acx -> bl -> props .power = FB_BLANK_UNBLANK ;
367
358
368
359
return 0 ;
369
360
}
370
361
371
- static int acx424akp_disable (struct drm_panel * panel )
372
- {
373
- struct acx424akp * acx = panel_to_acx424akp (panel );
374
-
375
- /*
376
- * The backlight is on as long as the display is on
377
- * so no use to call backlight_disable() here.
378
- */
379
- acx -> bl -> props .power = FB_BLANK_NORMAL ;
380
-
381
- return 0 ;
382
- }
383
362
384
363
static int acx424akp_get_modes (struct drm_panel * panel ,
385
364
struct drm_connector * connector )
@@ -409,10 +388,8 @@ static int acx424akp_get_modes(struct drm_panel *panel,
409
388
}
410
389
411
390
static const struct drm_panel_funcs acx424akp_drm_funcs = {
412
- .disable = acx424akp_disable ,
413
391
.unprepare = acx424akp_unprepare ,
414
392
.prepare = acx424akp_prepare ,
415
- .enable = acx424akp_enable ,
416
393
.get_modes = acx424akp_get_modes ,
417
394
};
418
395
@@ -458,25 +435,18 @@ static int acx424akp_probe(struct mipi_dsi_device *dsi)
458
435
/* This asserts RESET by default */
459
436
acx -> reset_gpio = devm_gpiod_get_optional (dev , "reset" ,
460
437
GPIOD_OUT_HIGH );
461
- if (IS_ERR (acx -> reset_gpio )) {
462
- ret = PTR_ERR (acx -> reset_gpio );
463
- if (ret != - EPROBE_DEFER )
464
- dev_err (dev , "failed to request GPIO (%d)\n" , ret );
465
- return ret ;
466
- }
438
+ if (IS_ERR (acx -> reset_gpio ))
439
+ return dev_err_probe (dev , PTR_ERR (acx -> reset_gpio ),
440
+ "failed to request GPIO\n" );
467
441
468
442
drm_panel_init (& acx -> panel , dev , & acx424akp_drm_funcs ,
469
443
DRM_MODE_CONNECTOR_DSI );
470
444
471
- acx -> bl = devm_backlight_device_register (dev , "acx424akp" , dev , acx ,
472
- & acx424akp_bl_ops , NULL );
473
- if (IS_ERR (acx -> bl )) {
474
- dev_err (dev , "failed to register backlight device\n" );
475
- return PTR_ERR (acx -> bl );
476
- }
477
- acx -> bl -> props .max_brightness = 1023 ;
478
- acx -> bl -> props .brightness = 512 ;
479
- acx -> bl -> props .power = FB_BLANK_POWERDOWN ;
445
+ acx -> panel .backlight = devm_backlight_device_register (dev , "acx424akp" , dev , acx ,
446
+ & acx424akp_bl_ops , & acx424akp_bl_props );
447
+ if (IS_ERR (acx -> panel .backlight ))
448
+ return dev_err_probe (dev , PTR_ERR (acx -> panel .backlight ),
449
+ "failed to register backlight device\n" );
480
450
481
451
drm_panel_add (& acx -> panel );
482
452
0 commit comments