Skip to content

Commit d5291e3

Browse files
committed
driver: Use drm_connector_helper_get_modes_fixed in get_modes
Save some more boilerplate. Driver also need "select DRM_KMS_HELPER" in Kconfig now.
1 parent 74c1044 commit d5291e3

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

driver.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def generate_includes(p: Panel, options: Options) -> str:
2222
'drm_mipi_dsi.h',
2323
'drm_modes.h',
2424
'drm_panel.h',
25+
'drm_probe_helper.h',
2526
},
2627
}
2728

@@ -537,20 +538,7 @@ def generate_driver(p: Panel, options: Options) -> None:
537538
{simple.generate_mode(p)}
538539
{wrap.join(f'static int {p.short_id}_get_modes(', ',', ')', ['struct drm_panel *panel', 'struct drm_connector *connector'])}
539540
{{
540-
struct drm_display_mode *mode;
541-
542-
mode = drm_mode_duplicate(connector->dev, &{p.short_id}_mode);
543-
if (!mode)
544-
return -ENOMEM;
545-
546-
drm_mode_set_name(mode);
547-
548-
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
549-
connector->display_info.width_mm = mode->width_mm;
550-
connector->display_info.height_mm = mode->height_mm;
551-
drm_mode_probed_add(connector, mode);
552-
553-
return 1;
541+
return drm_connector_helper_get_modes_fixed(connector, &{p.short_id}_mode);
554542
}}
555543
556544
static const struct drm_panel_funcs {p.short_id}_panel_funcs = {{

simple.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def generate_mode(p: Panel) -> str:
1919
.vtotal = {p.v.px} + {p.v.fp} + {p.v.pw} + {p.v.bp},
2020
.width_mm = {p.h.size},
2121
.height_mm = {p.v.size},
22+
.type = DRM_MODE_TYPE_DRIVER,
2223
}};
2324
'''
2425

0 commit comments

Comments
 (0)