Skip to content

Commit 1d9793b

Browse files
committed
Add --dcs-no-get-brightness to disable generating get_brightness() for DCS
This is broken for some panels.
1 parent 9d3e989 commit 1d9793b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

driver.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ def generate_backlight(p: Panel, options: Options) -> str:
289289
290290
return 0;
291291
}}
292+
'''
292293

294+
if options.dcs_get_brightness:
295+
s += f'''
293296
// TODO: Check if /sys/class/backlight/.../actual_brightness actually returns
294297
// correct values. If not, remove this function.
295298
static int {p.short_id}_bl_get_brightness(struct backlight_device *bl)
@@ -308,10 +311,14 @@ def generate_backlight(p: Panel, options: Options) -> str:
308311
309312
return brightness{brightness_mask};
310313
}}
314+
'''
315+
get_brightness = f'\n\t.get_brightness = {p.short_id}_bl_get_brightness,'
316+
else:
317+
get_brightness = ''
311318

319+
s += f'''
312320
static const struct backlight_ops {p.short_id}_bl_ops = {{
313-
.update_status = {p.short_id}_bl_update_status,
314-
.get_brightness = {p.short_id}_bl_get_brightness,
321+
.update_status = {p.short_id}_bl_update_status,{get_brightness}
315322
}};
316323
'''
317324
s += f'''

generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Options:
1717
regulator: Optional[List[str]]
1818
backlight: bool
1919
backlight_gpio: bool
20+
dcs_get_brightness: bool
2021
ignore_wait: int
2122
dumb_dcs: bool
2223

lmdpdg.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def generate(p: Panel, options: generator.Options) -> None:
4242
parser.add_argument('--no-backlight', dest='backlight', action='store_false', default=True, help="""
4343
Do not generate any backlight/brightness related code.
4444
""")
45+
parser.add_argument('--dcs-no-get-brightness', dest='dcs_get_brightness', action='store_false', default=True, help="""
46+
Do not generate get_brightness() function for DCS backlight/brightness code.
47+
Some panels do not implement the MIPI DCS Get Display Brightness command correctly.
48+
""")
4549
parser.add_argument('--ignore-wait', type=int, default=0, help="""
4650
Ignore wait in command sequences that is smaller that the specified value.
4751
Some device trees add a useless 1ms wait after each command, making the driver

0 commit comments

Comments
 (0)